<commit_before>Definition
==========

Base of all bpmn activity types.

<!-- toc -->

- [API](#api)
  - [`new Definition(moddleContext[, options])`](#new-definitionmoddlecontext-options)
  - [`execute([options[, callback]])`](#executeoptions-callback)
  - [`getProcesses([options[, callback]])`](#getprocessesoptions-callback)
  - [`getChildActivityById(id)`](#getchildactivitybyidid)
  - [`stop()`](#stop)
  - [`getState()`](#getstate)
  - [`resume(definitionState)`](#resumedefinitionstate)
- [Events](#events)
  - [`start`](#start)
  - [`end`](#end)
  - [`error`](#error)

<!-- tocstop -->

# API

## `new Definition(moddleContext[, options])`

Definition constructor.

- `moddleContext`: Moddle context
- `options`: Optional execute options
  - `variables`
  - `services`
  - `listener`

## `execute([options[, callback]])`

- `options`: Optional execute options, defaults to constructor options
  - `variables`
  - `services`
  - `listener`
- `callback`: Optional callback
  - `err`: Occasional error
  - `mainProcess`: Executing process
  - `processes`: All processes including executable process

## `getProcesses([options[, callback]])`

Get process(es) from passed moddle context. If the definition has status running the running processes are returned.

- `options`: Optional execute options, defaults to constructor options
  - `variables`
  - `services`
  - `listener`
- `callback`: Optional callback
  - `err`: Occasional error
  - `mainProcess`: Executable process
  - `processes`: All processes including executable process

## `getChildActivityById(id)`

Get process actitivy by id. Loops processes to return first child activity with id.

## `stop()`

Stop execution.

## `getState()`

Get activity state.

- `id`: Activity id
- `type`: Activity type
- `entered`: The activity is entered, i.e. in a running state

## `resume(definitionState[options[, callback]])`

Resume execution. Resumed with data from [`getState()`](#getstate).

- `options`: Optional execute options, defaults to constructor options
  - `listener`
- `callback`: Optional callback
  - `err`: Occasional error
  - `mainProcess`: Executing process
  - `processes`: All processes including executable process

# Events

## `start`
## `end`
## `error`<commit_msg>More doc<commit_after>Definition
==========

Executable BPMN 2 definition. Pass moddle context and execute.

<!-- toc -->

- [API](#api)
  - [`new Definition(moddleContext[, options])`](#new-definitionmoddlecontext-options)
  - [`execute([options[, callback]])`](#executeoptions-callback)
  - [`stop()`](#stop)
  - [`getState()`](#getstate)
  - [`resume(definitionState[, options[, callback]])`](#resumedefinitionstate-options-callback)
  - [`getProcesses([options[, callback]])`](#getprocessesoptions-callback)
  - [`getChildActivityById(id)`](#getchildactivitybyidid)
- [Events](#events)
  - [`start`](#start)
  - [`end`](#end)
  - [`error`](#error)

<!-- tocstop -->

# API

## `new Definition(moddleContext[, options])`

Definition constructor.

- `moddleContext`: Moddle context
- `options`: Optional execute options
  - `variables`
  - `services`
  - `listener`

## `execute([options[, callback]])`

- `options`: Optional execute options, defaults to constructor options
  - `variables`
  - `services`
  - `listener`
- `callback`: Optional callback
  - `err`: Occasional error
  - `mainProcess`: Executing process
  - `processes`: All processes including executable process

## `stop()`

Stop execution.

## `getState()`

Get definition state.

- `state`: State of definition, `pending`, `running`, or `completed`
- `moddleContext`: Definition moddle context
- `processes`: Object with processes with id as key
  - `variables`: Execution variables
  - `services`: Execution services
  - `children`: List of child states
    - `entered`: Boolean indicating if the child is currently executing

## `resume(definitionState[, options[, callback]])`

Resume execution. Resumed with data from [`getState()`](#getstate).

- `options`: Optional execute options, defaults to constructor options
  - `listener`
- `callback`: Optional callback
  - `err`: Occasional error
  - `mainProcess`: Executing process
  - `processes`: All processes including executable process

## `getProcesses([options[, callback]])`

Returns list of definiton processes with options. If the definition is running the running processes are returned.

The function is synchronous but can be passed a callback to get the first executable process.

- `options`: Optional execute options, defaults to constructor options
  - `variables`
  - `services`
  - `listener`
- `callback`: Optional callback
  - `err`: Occasional error
  - `mainProcess`: First executable process
  - `processes`: All processes including executable process

## `getChildActivityById(id)`

Get process activity by id. Loops processes to return first child activity that match id.

# Events

Emitted events.

## `start`

Definition has executed but not yet started any processes.

## `end`

All processes have completed.

## `error`

A non-recoverable error has ocurred.
{'fraction_non_alphanumeric': 0.14989123986553293, 'fraction_numerical': 0.00019774569903104609, 'mean_word_length': 4.657718120805369, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '611619', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1438, 'n_words': 446}