@dotbep/core 0.2.15 → 0.2.17

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 +20 -18
  2. package/dist/index.js +378 -385
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -619,6 +619,10 @@ 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<{
623
+ trackedAsset: WorkflowInstance['trackedAsset'];
624
+ workflowId: string;
625
+ }>>;
622
626
  env: Record<string, string>;
623
627
  }
624
628
 
@@ -889,7 +893,9 @@ export declare class Engine {
889
893
  get runtime(): Runtime<any>;
890
894
  /** Namespaced workflow instance operations. */
891
895
  readonly workflows: {
892
- create(workflowId: string, trackedAsset: WorkflowInstance['trackedAsset'], initiatedBy: string): Promise<WorkflowInstance | null>;
896
+ create(id: string, trackedAsset: WorkflowInstance['trackedAsset'] | {
897
+ rawPayload: unknown;
898
+ }, initiatedBy: string): Promise<WorkflowInstance | null>;
893
899
  emit(instanceId: string, event: IncomingEvent): Promise<EventResult>;
894
900
  get(instanceId: string): Promise<WorkflowInstance | null>;
895
901
  list(filter?: InstanceFilter): Promise<WorkflowInstance[]>;
@@ -1292,21 +1298,6 @@ export declare const FlowDiagramSchema: z.ZodObject<{
1292
1298
  }, z.core.$strip>]>>;
1293
1299
  }, z.core.$strip>;
1294
1300
 
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
1301
  export declare type FlowDirectEdge = z.infer<typeof FlowDirectEdgeSchema>;
1311
1302
 
1312
1303
  export declare const FlowDirectEdgeSchema: z.ZodObject<{
@@ -2138,8 +2129,6 @@ export declare type RaciEntry = {
2138
2129
  members: Member[];
2139
2130
  };
2140
2131
 
2141
- export declare type RaciKey = 'responsible' | 'accountable' | 'consulted' | 'informed';
2142
-
2143
2132
  /**
2144
2133
  * Resolved RACI assignment for one letter (R/A/C/I) at a node.
2145
2134
  * Three levels of specificity: emails > teams+roles > roles.
@@ -2244,12 +2233,14 @@ export declare class Runtime<T extends {
2244
2233
  effects: Record<string, any>;
2245
2234
  automations: Record<string, any>;
2246
2235
  resolvers: Record<string, any>;
2236
+ triggers: Record<string, any>;
2247
2237
  env: Record<string, any>;
2248
2238
  } = BepTypes> {
2249
2239
  env: T['env'];
2250
2240
  readonly effects: Record<string, EffectHandler>;
2251
2241
  readonly automations: Record<string, AutomationHandler>;
2252
2242
  readonly resolvers: Record<string, ResolverHandler>;
2243
+ readonly triggers: Record<string, TriggerHandler>;
2253
2244
  /** Set by Engine.init() — available inside handlers via this.engine */
2254
2245
  _engine: EngineRef | null;
2255
2246
  get engine(): EngineRef;
@@ -2257,6 +2248,7 @@ export declare class Runtime<T extends {
2257
2248
  protected effect<K extends keyof T['effects'] & string>(key: K, handler: (instance: WorkflowInstance, ...args: Parameters<T['effects'][K]>) => Promise<void>): this;
2258
2249
  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
2250
  protected resolver<K extends keyof T['resolvers'] & string>(key: K, handler: (...args: Parameters<T['resolvers'][K]>) => Promise<ReturnType<T['resolvers'][K]>>): this;
2251
+ protected trigger<K extends keyof T['triggers'] & string>(key: K, handler: (...args: Parameters<T['triggers'][K]>) => ReturnType<T['triggers'][K]>): this;
2260
2252
  /* Excluded from this release type: _runResolver */
2261
2253
  }
2262
2254
 
@@ -2472,6 +2464,16 @@ export declare interface TransitionStep {
2472
2464
  toNodeId: string;
2473
2465
  }
2474
2466
 
2467
+ /**
2468
+ * Handler registered for a specific software trigger (keyed by Software.id).
2469
+ * Receives a raw payload from an external system and returns the trackedAsset
2470
+ * plus the workflowId the engine will use to create the workflow instance.
2471
+ */
2472
+ export declare type TriggerHandler = (rawPayload: unknown) => Promise<{
2473
+ trackedAsset: WorkflowInstance['trackedAsset'];
2474
+ workflowId: string;
2475
+ }>;
2476
+
2475
2477
  /**
2476
2478
  * Validates all token-bearing entity IDs in a BEP against a naming convention.
2477
2479
  * Used when setting a new convention to ensure all existing data is compatible.