How to use the @ibm-functions/composer.deserialize function in @ibm-functions/composer

To help you get started, we’ve selected a few @ibm-functions/composer 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 ibm-functions / shell / app / plugins / modules / composer / lib / create-from-source.js View on Github external
}

                        debug('res', typeof res, res)

                        if (typeof res === 'function') {
                            res = res()
                        }

                        if (isValidFSM(res)) {
                            return res

                        } else {
                            let err = ''
                            try {
                                // maybe the code did a console.log?
                                const maybe = openwhiskComposer.deserialize(JSON.parse(logMessage))
                                if (isValidFSM(maybe)) {
                                    return maybe
                                }
                            } catch (e) {
                                err = e
                            }

                            throw new Error(`Unable to compile your composition
${err}
${errorMessage}`)
                        }
                    } catch (err) {
                        const junkMatch = err.stack.match(/\s+at Object\.exports\.runInNewContext/)
                              || err.stack.match(/\s+at Object\.runInNewContext/)
                              || err.stack.match(/\s+at fs\.readFile/),
                              _message = err.message.indexOf('Invalid argument to compile') >= 0? 'Your source code did not produce a valid app.' : (!junkMatch ? e.stack : err.stack.substring(0, junkMatch.index).replace(/\s+.*create-from-source([^\n])*/g, '\n').replace(/(evalmachine.)/g, filename).replace(/\s+at createScript([^\n])*/g, '\n').trim()),
github ibm-functions / shell / app / plugins / modules / composer / lib / composer.js View on Github external
exports.getFSM = entity => {
    const fsmAnnotation = exports.fsmAnnotation(entity)

    if (fsmAnnotation) {
        return openwhiskComposer.deserialize(fsmAnnotation.value)
    }
}