How to use the bpmn-elements.Environment function in bpmn-elements

To help you get started, we’ve selected a few bpmn-elements 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 paed01 / bpmn-engine / index.js View on Github external
const sources = [];
  const typeResolver = TypeResolver({
    ...elements,
    ...(options.elements || {})
  }, defaultTypeResolver);

  function defaultTypeResolver(elementTypes) {
    if (options.typeResolver) return options.typeResolver(elementTypes);
    elementTypes['bpmn:DataObject'] = ProcessOutputDataObject;
  }

  const pendingSources = [];
  if (options.source) pendingSources.push(serializeSource(options.source));
  if (options.moddleContext) pendingSources.push(serializeModdleContext(options.moddleContext));

  let environment = elements.Environment(options);
  const emitter = new EventEmitter();

  const engine = Object.assign(emitter, {
    execute,
    logger,
    getDefinitionById,
    getDefinitions,
    getState,
    recover,
    resume,
    stop,
    waitFor,
  });

  const broker = Broker(engine);
  broker.assertExchange('event', 'topic', {autoDelete: false});
github paed01 / bpmn-engine / index.js View on Github external
function recover(savedState, recoverOptions) {
    if (!savedState) return engine;

    logger.debug(`<${name}> recover`);

    if (!name) name = savedState.name;
    if (recoverOptions) environment = elements.Environment(recoverOptions);
    if (savedState.environment) environment = environment.recover(savedState.environment);

    if (!savedState.definitions) return engine;

    loadedDefinitions = savedState.definitions.map((dState) => {
      const source = deserialize(JSON.parse(dState.source), typeResolver);

      logger.debug(`<${name}> recover ${dState.type} <${dState.id}>`);

      const definition = loadDefinition(source);
      definition.recover(dState);

      return definition;
    });

    return engine;

bpmn-elements

Executable workflow elements based on BPMN 2.0

MIT
Latest version published 2 months ago

Package Health Score

68 / 100
Full package analysis