How to use the infusion.each function in infusion

To help you get started, we’ve selected a few infusion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GPII / universal / tests / production / all-tests.js View on Github external
var fluid = require("infusion"),
    kettle = fluid.require("kettle");

// Ensure this happens first, to catch errors during code loading.
kettle.loadTestingSupport();

// Pass the current `require` to `fluid.require`, as nyc's instrumentation is hooked into it.
fluid.require("%gpii-universal", require);

var testIncludes = [
    "./CloudStatusProductionTests.js",
    "./SettingsGetProductionTests.js",
    "./SettingsPutProductionTests.js"
];

fluid.each(testIncludes, function (path) {
    require(path);
});
github GPII / universal / tests / SolutionsRegistryTests.js View on Github external
fluid.each(settingsDefs, function (settingsDef) {
                var isValid = gpii.tests.universal.solutionsRegistry.validateSinglePayload(
                    preferencePayload,
                    settingsDef.schema,
                    "settings file " + settingsFilePath + " -> " + preferenceKey
                );

                if (!isValid) {
                    fileErrors++;
                }
            });
        }
        // "SR" preferences, which are "deep", i.e. multiple key:value pairs per solution.
        else {
            fluid.each(preferencePayload, function (prefValue, prefKey) {
                var solutionKey = preferenceKey.replace("http://registry.gpii.net/applications/", "");
                var settingsLabel = "settings file " + settingsFilePath + " -> " + solutionKey + " -> " + prefKey;
                var settingsDefs = fluid.get(settingsIndex, [solutionKey, prefKey]);

                if (!settingsDefs || settingsDefs.length === 0)  {
                    fluid.log("WARNING, setting found that does not correspond to a known setting: " + settingsLabel);
                }

                fluid.each(settingsDefs, function (settingsDef) {
                    if (settingsDef.schema) {
                        var isValid = gpii.tests.universal.solutionsRegistry.validateSinglePayload(
                            prefValue,
                            settingsDef.schema,
                            settingsLabel
                        );
                        if (!isValid) {
github GPII / universal / gpii / node_modules / flowManager / src / PCPInterface.js View on Github external
gpii.pcpInterface.sendUserMessage = function (socket, text, messageType, extras) {
        console.log("User message sent: " + text);
        fluid.each(gpii.pcpInterface.sockets, function (s) {
            if ((s === null) || (s.disconnected === true)) {
                fluid.log("No PCP connected on this socket, so discarding message: " + text);
            } else {
                // Default to 'infoMessage'
                var message = {
                    type: (messageType === undefined) ? "infoMessage" : messageType,
                    message: text
                };
                if (extras) {
                    message = $.extend(true, {}, message, extras);
                }

                s.emit("message", message, fluid.log);
            }
        });
    };
github GPII / universal / scripts / migration / schema-0.2-GPII-4014 / verify.js View on Github external
gpii.migration.GPII4014.verifyDocsData = function (responseString, options) {
    var allDocs = JSON.parse(responseString);
    var totalNumOfDocs = allDocs.total_rows;
    var numOfVerified = 0;
    var numOfErrorDocs = 0;
    var togo = fluid.promise();

    fluid.each(allDocs.rows, function (aRow) {
        var hasError = false;
        var aDoc = aRow.doc;
        // To filter out the "_design/views" doc that doesn't have the "schemaVersion" field
        if (aDoc.schemaVersion) {
            numOfVerified++;
            if (aDoc.schemaVersion !== gpii.migration.GPII4014.newSchemaVersion) {
                console.log("Error with the document _id \"" + aDoc._id + "\": schema version is ", aDoc.schemaVersion, ", not ", gpii.migration.GPII4014.newSchemaVersion);
                hasError = true;
            }
            if (aDoc.timestampUpdated === null) {
                console.log("Error with the document _id \"" + aDoc._id + "\": the value of timestampUpdated is empty");
                hasError = true;
            }
            if (aDoc.type === "clientCredential") {
                var docFields = {
                    allowedIPBlocks: aDoc.allowedIPBlocks,
github GPII / universal / gpii / node_modules / eventLog / src / metrics.js View on Github external
gpii.metrics.logonStateChanged = function (that, lifecycleManager, oldValue, newValue) {
    if (oldValue && oldValue.type === "login" && (newValue.type === "logout" || !newValue.inProgress)) {
        var session = lifecycleManager.getSession(oldValue.gpiiKey);
        // The reason for this null checker is that the lifecyclaManager's "session" may be null after
        // having logged on with a bogus token which terminated the request in error before the
        // "session" could be created.
        if (session) {
            // Log the solution IDs that hadn't been applied.
            var expectedSolutions = fluid.keys(session.model.activeConfiguration.lifecycleInstructions);
            fluid.each(expectedSolutions, function (id) {
                if (!session.model.appliedSolutions[id]) {
                    that.logMetric("solution-failed", {
                        solutionID: id
                    });
                }
            });
        }
    }
};
github GPII / universal / tests / SolutionsRegistryTests.js View on Github external
gpii.tests.universal.solutionsRegistry.indexSrEntries = function (indexObject, srData) {
    fluid.each(srData, function (solutionDef, solutionKey) {
        fluid.each(solutionDef.settingsHandlers, function (settingsHandler) {
            fluid.each(settingsHandler.supportedSettings, function (settingDef, settingKey) {
                gpii.tests.universal.solutionsRegistry.indexSingleSolution(indexObject, [solutionKey, settingKey], settingDef);
            });
        });
    });
};
github GPII / universal / gpii / node_modules / gpiiFramework / source.js View on Github external
gpii.source.finalInit = function (that) {
        fluid.each(that.options.invokers, function (invoker, name) {
            that.server[name](that.options.path, that[name]);
        });
    };
github GPII / universal / gpii / node_modules / configurationManager / src / ConfigurationManager.js View on Github external
fluid.each(handlerResponse, function (handler, idx) {
            if (handler[solutionId] !== null && handler[solutionId] !== undefined) {
                var settings = handler[solutionId].settings;
                fluid.each(settings, function (setting, key) {
                    returnSettings[key] = setting.oldValue;
                });	
            }
        });
        return returnSettings;
github GPII / universal / gpii / node_modules / ontologyHandler / src / ontologyHandler.js View on Github external
gpii.ontologyHandler.collectPaths = function (obj, search, target, pathArray) {
        if (!(pathArray instanceof Array)) {
            pathArray = [];
        }
        fluid.each(obj, function (entry, key) {
            pathArray.push(key);
            if (entry === search) {
                var path = fluid.pathUtil.composeSegments.apply(null, pathArray);
                target.push(path);
                pathArray.pop(key);
                return;
            }
            if (!fluid.isPrimitive(entry)) {
                gpii.ontologyHandler.collectPaths(entry, search, target, pathArray);
            }
            pathArray.pop(key);
        });
    };
github GPII / universal / scripts / archiveAndFlushAccessTokens.js View on Github external
gpii.accessTokens.filterExpiredAccessTokens = function (responseString, options) {
    if (options.deleteAll) {
        fluid.log("Deleting all access tokens...");
    } else {
        fluid.log("Filtering for expired access tokens...");
    }
    var tokens = JSON.parse(responseString);
    var expiredTokens = [];
    options.totalTokens = 0;
    if (tokens.rows) {
        fluid.each(tokens.rows, function (aRow) {
            var aToken = aRow.value.authorization;
            if (options.deleteAll || Date.now() > Date.parse(aToken.timestampExpires)) {
                expiredTokens.push(aToken);
            }
            options.totalTokens++;
        });
        options.accessTokens = expiredTokens;
    }
    return expiredTokens;
};