How to use the @accordproject/concerto-core.Logger.warn function in @accordproject/concerto-core

To help you get started, we’ve selected a few @accordproject/concerto-core 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 accordproject / cicero / packages / cicero-cli / lib / commands.js View on Github external
.then(async (template) => {
                // Initialize clause
                clause = new Clause(template);
                clause.parse(sampleText, currentTime);

                let stateJson;
                if(!fs.existsSync(statePath)) {
                    Logger.warn('A state file was not provided, initializing state. Try the --state flag or create a state.json in the root folder of your template.');
                    const initResult = await engine.init(clause, currentTime);
                    stateJson = initResult.state;
                } else {
                    stateJson = JSON.parse(fs.readFileSync(statePath, 'utf8'));
                }

                // First execution to get the initial response
                const firstRequest = requestsJson[0];
                const initResponse = engine.trigger(clause, firstRequest, stateJson, currentTime);
                // Get all the other requests and chain execution through Promise.reduce()
                const otherRequests = requestsJson.slice(1, requestsJson.length);
                return otherRequests.reduce((promise,requestJson) => {
                    return promise.then((result) => {
                        return engine.trigger(clause, requestJson, result.state);
                    });
                }, initResponse);
github accordproject / cicero / packages / cicero-core / src / templatelibrary.js View on Github external
}

        const templateUriInfo = TemplateLibrary.parseURI(templateUri);
        const templateIndex = await this.getTemplateIndex();
        const templateMetadata = templateIndex[`${templateUriInfo.templateName}@${templateUriInfo.templateVersion}`];
        if(!templateMetadata) {
            throw new Error(`Failed to find template ${templateUri}`);
        }

        // fetch the template
        const template = await Template.fromUrl(templateMetadata.url);

        // check the hash matches
        const templateHash = template.getHash();
        if(templateHash !== templateUriInfo.templateHash) {
            Logger.warn(`Requested template ${templateUri} but the hash of the template is ${templateHash}`);
        }

        globalTemplateCache.set(cacheKey, template);

        return template;
    }
github accordproject / cicero / packages / cicero-core / src / metadata.js View on Github external
this.readme = readme;
        this.samples = samples;
        this.request = request;

        this.type = templateTypes.CONTRACT;
        if (packageJson.accordproject && packageJson.accordproject.template) {
            if(packageJson.accordproject.template !== 'contract' &&
            packageJson.accordproject.template !== 'clause'){
                throw new Error('A cicero template must be either a "contract" or a "clause".');
            }

            if(packageJson.accordproject.template === 'clause'){
                this.type = templateTypes.CLAUSE;
            }
        } else {
            Logger.warn('No cicero template type specified. Assuming that this is a contract template');
        }
    }