@dotbep/core 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +14 -18
  2. package/dist/index.js +255 -277
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -619,6 +619,7 @@ export declare interface BepTypes {
619
619
  eventId: string;
620
620
  } & Record<string, unknown>>;
621
621
  resolvers: Record<string, (url: string, ...args: any[]) => unknown>;
622
+ triggers: Record<string, (rawPayload: unknown) => Promise<WorkflowInstance['trackedAsset']>>;
622
623
  env: Record<string, string>;
623
624
  }
624
625
 
@@ -889,7 +890,9 @@ export declare class Engine {
889
890
  get runtime(): Runtime<any>;
890
891
  /** Namespaced workflow instance operations. */
891
892
  readonly workflows: {
892
- create(workflowId: string, trackedAsset: WorkflowInstance['trackedAsset'], initiatedBy: string): Promise<WorkflowInstance | null>;
893
+ create(workflowId: string, trackedAsset: WorkflowInstance['trackedAsset'] | {
894
+ rawPayload: unknown;
895
+ }, initiatedBy: string): Promise<WorkflowInstance | null>;
893
896
  emit(instanceId: string, event: IncomingEvent): Promise<EventResult>;
894
897
  get(instanceId: string): Promise<WorkflowInstance | null>;
895
898
  list(filter?: InstanceFilter): Promise<WorkflowInstance[]>;
@@ -1292,21 +1295,6 @@ export declare const FlowDiagramSchema: z.ZodObject<{
1292
1295
  }, z.core.$strip>]>>;
1293
1296
  }, z.core.$strip>;
1294
1297
 
1295
- /**
1296
- * Converts a resolved FlowDiagram to a Mermaid flowchart string.
1297
- * Node IDs are prefixed with `_` to avoid conflicts with Mermaid reserved words
1298
- * (e.g. "end", "start"). Quotes in labels are escaped to `#quot;`.
1299
- *
1300
- * Node order: start always first, end always last. If topologicalSort is enabled,
1301
- * intermediate nodes are ordered via BFS from start for better Dagre layout.
1302
- */
1303
- export declare function flowDiagramToMermaid(diagram: FlowDiagramResolved, raciKey?: RaciKey, options?: FlowDiagramToMermaidOptions): string;
1304
-
1305
- declare interface FlowDiagramToMermaidOptions {
1306
- raciKey?: RaciKey;
1307
- topologicalSort?: boolean;
1308
- }
1309
-
1310
1298
  export declare type FlowDirectEdge = z.infer<typeof FlowDirectEdgeSchema>;
1311
1299
 
1312
1300
  export declare const FlowDirectEdgeSchema: z.ZodObject<{
@@ -2138,8 +2126,6 @@ export declare type RaciEntry = {
2138
2126
  members: Member[];
2139
2127
  };
2140
2128
 
2141
- export declare type RaciKey = 'responsible' | 'accountable' | 'consulted' | 'informed';
2142
-
2143
2129
  /**
2144
2130
  * Resolved RACI assignment for one letter (R/A/C/I) at a node.
2145
2131
  * Three levels of specificity: emails > teams+roles > roles.
@@ -2244,12 +2230,14 @@ export declare class Runtime<T extends {
2244
2230
  effects: Record<string, any>;
2245
2231
  automations: Record<string, any>;
2246
2232
  resolvers: Record<string, any>;
2233
+ triggers: Record<string, any>;
2247
2234
  env: Record<string, any>;
2248
2235
  } = BepTypes> {
2249
2236
  env: T['env'];
2250
2237
  readonly effects: Record<string, EffectHandler>;
2251
2238
  readonly automations: Record<string, AutomationHandler>;
2252
2239
  readonly resolvers: Record<string, ResolverHandler>;
2240
+ readonly triggers: Record<string, TriggerHandler>;
2253
2241
  /** Set by Engine.init() — available inside handlers via this.engine */
2254
2242
  _engine: EngineRef | null;
2255
2243
  get engine(): EngineRef;
@@ -2257,6 +2245,7 @@ export declare class Runtime<T extends {
2257
2245
  protected effect<K extends keyof T['effects'] & string>(key: K, handler: (instance: WorkflowInstance, ...args: Parameters<T['effects'][K]>) => Promise<void>): this;
2258
2246
  protected automation<K extends keyof T['automations'] & string>(key: K, handler: (instance: WorkflowInstance, ...args: Parameters<T['automations'][K]>) => Promise<ReturnType<T['automations'][K]>>): this;
2259
2247
  protected resolver<K extends keyof T['resolvers'] & string>(key: K, handler: (...args: Parameters<T['resolvers'][K]>) => Promise<ReturnType<T['resolvers'][K]>>): this;
2248
+ protected trigger<K extends keyof T['triggers'] & string>(key: K, handler: (rawPayload: unknown) => Promise<WorkflowInstance['trackedAsset']>): this;
2260
2249
  /* Excluded from this release type: _runResolver */
2261
2250
  }
2262
2251
 
@@ -2472,6 +2461,13 @@ export declare interface TransitionStep {
2472
2461
  toNodeId: string;
2473
2462
  }
2474
2463
 
2464
+ /**
2465
+ * Handler registered for a specific workflow trigger (keyed by Workflow.id).
2466
+ * Receives a raw payload from an external system and returns the trackedAsset
2467
+ * that the engine will use to create the workflow instance.
2468
+ */
2469
+ export declare type TriggerHandler = (rawPayload: unknown) => Promise<WorkflowInstance['trackedAsset']>;
2470
+
2475
2471
  /**
2476
2472
  * Validates all token-bearing entity IDs in a BEP against a naming convention.
2477
2473
  * Used when setting a new convention to ensure all existing data is compatible.