@yieldstar/core 0.4.0-alpha.2 → 0.4.0

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.
@@ -1,21 +1,28 @@
1
- export type TriggerEvent<WorkflowId extends string, EventParams = any> = EventParams extends void ? {
1
+ import { FreezableMap } from "../utils/map";
2
+ export type EventParams = Record<string, any> | void;
3
+ export type EventContext = ReadonlyMap<any, any>;
4
+ export type MiddlewareEventContext = FreezableMap<any, any>;
5
+ export type TriggerEvent<WorkflowId extends string, Params extends EventParams = EventParams> = Params extends void ? {
2
6
  workflowId: WorkflowId;
3
7
  executionId?: string;
4
8
  params?: undefined;
5
9
  } : {
6
10
  workflowId: WorkflowId;
7
11
  executionId?: string;
8
- params: EventParams;
12
+ params: Params;
9
13
  };
10
- export type ExecutionEvent<EventParams = any> = {
14
+ export type ExecutionEvent<Params extends EventParams = EventParams> = {
11
15
  workflowId: string;
12
16
  executionId: string;
13
- params: EventParams;
17
+ params: Params;
14
18
  };
15
- export type WorkflowEvent<EventParams = any, Context extends ReadonlyMap<any, any> = ReadonlyMap<any, any>> = {
19
+ export type WorkflowEvent<Params extends EventParams = EventParams, Context extends ReadonlyMap<any, any> = ReadonlyMap<any, any>> = {
16
20
  workflowId: string;
17
21
  executionId: string;
18
- params: EventParams;
22
+ params: Params;
23
+ context: Context;
24
+ };
25
+ export type MiddlewareEvent<Params extends EventParams = EventParams, Context extends MiddlewareEventContext = MiddlewareEventContext> = ExecutionEvent<Params> & {
19
26
  context: Context;
20
27
  };
21
28
  //# sourceMappingURL=event.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/base/event.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CACtB,UAAU,SAAS,MAAM,EACzB,WAAW,GAAG,GAAG,IACf,WAAW,SAAS,IAAI,GACxB;IACE,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,C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AAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,WAAW,GAAG,WAAW,IAAI;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,CACvB,MAAM,SAAS,WAAW,GAAG,WAAW,EACxC,OAAO,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,IAC3D;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,CACzB,MAAM,SAAS,WAAW,GAAG,WAAW,EACxC,OAAO,SAAS,sBAAsB,GAAG,sBAAsB,IAC7D,cAAc,CAAC,MAAM,CAAC,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
@@ -2,6 +2,6 @@ import type { EventEmitter } from "node:events";
2
2
  import type { ExecutionEvent } from "./event";
3
3
  export type WorkflowInvoker = {
4
4
  workflowEndEmitter: EventEmitter;
5
- execute<EventParams>(event: ExecutionEvent<EventParams>): Promise<void>;
5
+ execute(event: ExecutionEvent): Promise<void>;
6
6
  };
7
7
  //# sourceMappingURL=invoker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/base/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,YAAY,CAAC;IACjC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE,CAAC"}
1
+ {"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/base/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,YAAY,CAAC;IACjC,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAAC"}
@@ -1,9 +1,5 @@
1
1
  import type { Logger } from "pino";
2
- import { ExecutionEvent } from "./event";
3
- import { FreezableMap } from "../utils/map";
4
- export type MiddlewareEvent = ExecutionEvent & {
5
- context: FreezableMap<string, any>;
6
- };
2
+ import type { MiddlewareEvent } from "./event";
7
3
  export type MiddlewareNext = () => Promise<Response>;
8
4
  export type MiddlewareFunction = (req: Request, event: MiddlewareEvent, next: MiddlewareNext, logger: Logger) => Promise<Response>;
9
5
  //# sourceMappingURL=middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/base/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/base/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,QAAQ,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from "pino";
2
2
  import type { WorkflowResult } from "./step";
3
3
  import type { WorkflowEvent } from "./event";
4
- export type EventProcessor<EventParams = any, Result = any, Context extends ReadonlyMap<any, any> = ReadonlyMap<any, any>> = (event: WorkflowEvent<EventParams, Context>, logger: Logger) => Promise<void | WorkflowResult<Result>>;
4
+ export type EventProcessor = (event: WorkflowEvent, logger: Logger) => Promise<void | WorkflowResult<any>>;
5
5
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/base/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,cAAc,CACxB,WAAW,GAAG,GAAG,EACjB,MAAM,GAAG,GAAG,EACZ,OAAO,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,IAC3D,CACF,KAAK,EAAE,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,EAC1C,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/base/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,CAC3B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { ExecutionEvent } from "./event";
1
+ import type { WorkflowEvent, EventParams } from "./event";
2
2
  export interface SchedulerClient {
3
- requestWakeUp<EventParams>(event: ExecutionEvent<EventParams>, resumeIn?: number): Promise<void>;
3
+ requestWakeUp<Params extends EventParams>(event: WorkflowEvent<Params>, resumeIn?: number): Promise<void>;
4
4
  }
5
5
  //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/base/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,WAAW,EACvB,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,EAClC,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/base/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,MAAM,SAAS,WAAW,EACtC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,EAC5B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
@@ -1,14 +1,14 @@
1
1
  import type { Logger } from "pino";
2
+ import type { EventParams, WorkflowEvent, EventContext } from "./event";
2
3
  import { HeapClient } from "./heap";
3
4
  import { StepResponse, WorkflowResult } from "./step";
4
- import type { WorkflowEvent } from "./event";
5
- export type WorkflowGeneratorParams<EventParams, Context extends ReadonlyMap<any, any>> = {
6
- event: WorkflowEvent<EventParams, Context>;
5
+ export type WorkflowGeneratorParams<Params extends EventParams, Context extends EventContext> = {
6
+ event: WorkflowEvent<Params, Context>;
7
7
  heapClient: HeapClient;
8
8
  logger: Logger;
9
9
  };
10
- export type WorkflowGenerator<EventParams, Result, Context extends Map<any, any>> = (genParams: WorkflowGeneratorParams<EventParams, Context>) => AsyncGenerator<StepResponse, WorkflowResult<Result>, StepResponse>;
11
- export type WorkflowGeneratorReturnType<CG> = CG extends WorkflowGenerator<infer EventParams, infer Result, infer Context> ? Result : never;
10
+ export type WorkflowGenerator<Params extends EventParams, Result, Context extends EventContext> = (genParams: WorkflowGeneratorParams<Params, Context>) => AsyncGenerator<StepResponse, WorkflowResult<Result>, StepResponse>;
11
+ export type WorkflowGeneratorReturnType<CG> = CG extends WorkflowGenerator<infer Params, infer Result, infer Context> ? Result : never;
12
12
  export type WorkflowRouter = Record<string, WorkflowGenerator<any, any, any>>;
13
13
  export type EventOfWorkflow<W extends WorkflowGenerator<any, any, any>> = Parameters<W>[0]["event"];
14
14
  export type EventParamsOf<W extends WorkflowGenerator<any, any, any>> = Parameters<W>[0]["event"]["params"];
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/base/workflow.ts"],"names":[],"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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAE5B,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAClE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,10 +2,11 @@ export type { HeapClient, HeapRecord } from "./base/heap";
2
2
  export type { WorkflowInvoker } from "./base/invoker";
3
3
  export type { EventProcessor } from "./base/runtime";
4
4
  export type { SchedulerClient } from "./base/scheduler";
5
- export type { ExecutionEvent, TriggerEvent, WorkflowEvent } from "./base/event";
6
- export type { MiddlewareNext, MiddlewareEvent, MiddlewareFunction, } from "./base/middleware";
5
+ export type { EventParams, EventContext, ExecutionEvent, MiddlewareEvent, TriggerEvent, WorkflowEvent, } from "./base/event";
6
+ export type { MiddlewareNext, MiddlewareFunction } from "./base/middleware";
7
7
  export type { WorkflowGenerator, WorkflowGeneratorReturnType, WorkflowRouter, EventOfWorkflow, EventParamsOf, } from "./base/workflow";
8
8
  export { StepCacheCheck, StepDelay, StepError, StepInvalid, StepKey, StepResponse, StepResult, WorkflowDelay, WorkflowRestart, WorkflowResult, } from "./base/step";
9
9
  export { WorkflowRunner } from "./lib/workflow-runner";
10
10
  export { ReadOnlyMap, FreezableMap } from "./utils/map";
11
+ export { errorWithOriginalStack } from "./utils/error";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,kBA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c,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -136,6 +136,14 @@ class WorkflowRunner {
136
136
  throw new Error("Workflow runner critical error. This is likely because your worklow and worker are referencing different versions of @yieldstar/core.");
137
137
  }
138
138
  }
139
+ // src/utils/error.ts
140
+ function errorWithOriginalStack(error, fn) {
141
+ const err = new Error(error.message);
142
+ Error.captureStackTrace(err, fn);
143
+ err.stack = error.stack;
144
+ throw err;
145
+ }
146
+
139
147
  // src/utils/map.ts
140
148
  class ReadOnlyMap {
141
149
  sourceMap;
@@ -178,24 +186,28 @@ class FreezableMap extends Map {
178
186
  }
179
187
  set(key, value) {
180
188
  if (this.frozen) {
181
- throw new Error("Cannot call set on a frozen map");
189
+ const error = new Error("Cannot call set on a frozen map");
190
+ throw errorWithOriginalStack(error, this.set);
182
191
  }
183
192
  return super.set(key, value);
184
193
  }
185
194
  delete(key) {
186
195
  if (this.frozen) {
187
- throw new Error("Cannot call delete on a frozen map");
196
+ const error = new Error("Cannot call delete on a frozen map");
197
+ throw errorWithOriginalStack(error, this.delete);
188
198
  }
189
199
  return super.delete(key);
190
200
  }
191
201
  clear() {
192
202
  if (this.frozen) {
193
- throw new Error("Cannot call clear on a frozen map");
203
+ const error = new Error("Cannot call clear on a frozen map");
204
+ throw errorWithOriginalStack(error, this.clear);
194
205
  }
195
206
  return super.clear();
196
207
  }
197
208
  }
198
209
  export {
210
+ errorWithOriginalStack,
199
211
  WorkflowRunner,
200
212
  WorkflowResult,
201
213
  WorkflowRestart,
@@ -10,7 +10,7 @@ export declare class WorkflowRunner<Router extends Record<string, WorkflowGenera
10
10
  router: Router;
11
11
  logger: Logger;
12
12
  });
13
- run: EventProcessor<any, any>;
13
+ run: EventProcessor;
14
14
  private runWorkflows;
15
15
  }
16
16
  //# sourceMappingURL=workflow-runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/lib/workflow-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,cAAc,EAEf,MAAM,IAAI,CAAC;AAGZ,qBAAa,cAAc,CACzB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB;IAMD,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CA0B3B;YAEY,YAAY;CAgC3B"}
1
+ {"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/lib/workflow-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,cAAc,EAGf,MAAM,IAAI,CAAC;AAIZ,qBAAa,cAAc,CACzB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB;IAMD,GAAG,EAAE,cAAc,CA0BjB;YAEY,YAAY;CAgC3B"}
@@ -0,0 +1,2 @@
1
+ export declare function errorWithOriginalStack(error: Error, fn: Function): void;
2
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,QAKhE"}
@@ -4,11 +4,11 @@ export declare class ReadOnlyMap<K, V> implements ReadonlyMap<K, V> {
4
4
  get(key: K): V | undefined;
5
5
  has(key: K): boolean;
6
6
  get size(): number;
7
- entries(): ReturnType<Map<K, V>["entries"]>;
8
- keys(): ReturnType<Map<K, V>["keys"]>;
9
- values(): ReturnType<Map<K, V>["values"]>;
7
+ entries(): MapIterator<[K, V]>;
8
+ keys(): MapIterator<K>;
9
+ values(): MapIterator<V>;
10
10
  forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
11
- [Symbol.iterator](): ReturnType<Map<K, V>[typeof Symbol.iterator]>;
11
+ [Symbol.iterator](): MapIterator<[K, V]>;
12
12
  }
13
13
  export declare class FreezableMap<K, V> extends Map<K, V> {
14
14
  private frozen;
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,SAAS,CAAY;gBAEjB,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAIhC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAI1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,IAAI,I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CAAC,GAAG,CAAC,GAAG,SAAS;IAI1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9B,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAItB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAIxB,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EACtD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAIP,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAGzC;AAED,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,CAAS;IAEvB,MAAM,IAAI,IAAI;IAId,QAAQ,IAAI,OAAO;IAInB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAQ3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAQvB,KAAK,IAAI,IAAI;CAOd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yieldstar/core",
3
- "version": "0.4.0-alpha.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/base/event.ts CHANGED
@@ -1,7 +1,13 @@
1
+ import { FreezableMap } from "../utils/map";
2
+
3
+ export type EventParams = Record<string, any> | void;
4
+ export type EventContext = ReadonlyMap<any, any>;
5
+ export type MiddlewareEventContext = FreezableMap<any, any>;
6
+
1
7
  export type TriggerEvent<
2
8
  WorkflowId extends string,
3
- EventParams = any
4
- > = EventParams extends void
9
+ Params extends EventParams = EventParams
10
+ > = Params extends void
5
11
  ? {
6
12
  workflowId: WorkflowId;
7
13
  executionId?: string;
@@ -10,21 +16,28 @@ export type TriggerEvent<
10
16
  : {
11
17
  workflowId: WorkflowId;
12
18
  executionId?: string;
13
- params: EventParams;
19
+ params: Params;
14
20
  };
15
21
 
16
- export type ExecutionEvent<EventParams = any> = {
22
+ export type ExecutionEvent<Params extends EventParams = EventParams> = {
17
23
  workflowId: string;
18
24
  executionId: string;
19
- params: EventParams;
25
+ params: Params;
20
26
  };
21
27
 
22
28
  export type WorkflowEvent<
23
- EventParams = any,
29
+ Params extends EventParams = EventParams,
24
30
  Context extends ReadonlyMap<any, any> = ReadonlyMap<any, any>
25
31
  > = {
26
32
  workflowId: string;
27
33
  executionId: string;
28
- params: EventParams;
34
+ params: Params;
35
+ context: Context;
36
+ };
37
+
38
+ export type MiddlewareEvent<
39
+ Params extends EventParams = EventParams,
40
+ Context extends MiddlewareEventContext = MiddlewareEventContext
41
+ > = ExecutionEvent<Params> & {
29
42
  context: Context;
30
43
  };
@@ -3,5 +3,5 @@ import type { ExecutionEvent } from "./event";
3
3
 
4
4
  export type WorkflowInvoker = {
5
5
  workflowEndEmitter: EventEmitter;
6
- execute<EventParams>(event: ExecutionEvent<EventParams>): Promise<void>;
6
+ execute(event: ExecutionEvent): Promise<void>;
7
7
  };
@@ -1,10 +1,5 @@
1
1
  import type { Logger } from "pino";
2
- import { ExecutionEvent } from "./event";
3
- import { FreezableMap } from "../utils/map";
4
-
5
- export type MiddlewareEvent = ExecutionEvent & {
6
- context: FreezableMap<string, any>;
7
- };
2
+ import type { MiddlewareEvent } from "./event";
8
3
 
9
4
  export type MiddlewareNext = () => Promise<Response>;
10
5
 
@@ -2,11 +2,7 @@ import type { Logger } from "pino";
2
2
  import type { WorkflowResult } from "./step";
3
3
  import type { WorkflowEvent } from "./event";
4
4
 
5
- export type EventProcessor<
6
- EventParams = any,
7
- Result = any,
8
- Context extends ReadonlyMap<any, any> = ReadonlyMap<any, any>
9
- > = (
10
- event: WorkflowEvent<EventParams, Context>,
5
+ export type EventProcessor = (
6
+ event: WorkflowEvent,
11
7
  logger: Logger
12
- ) => Promise<void | WorkflowResult<Result>>;
8
+ ) => Promise<void | WorkflowResult<any>>;
@@ -1,8 +1,8 @@
1
- import type { ExecutionEvent } from "./event";
1
+ import type { WorkflowEvent, EventParams } from "./event";
2
2
 
3
3
  export interface SchedulerClient {
4
- requestWakeUp<EventParams>(
5
- event: ExecutionEvent<EventParams>,
4
+ requestWakeUp<Params extends EventParams>(
5
+ event: WorkflowEvent<Params>,
6
6
  resumeIn?: number
7
7
  ): Promise<void>;
8
8
  }
@@ -1,27 +1,27 @@
1
1
  import type { Logger } from "pino";
2
+ import type { EventParams, WorkflowEvent, EventContext } from "./event";
2
3
  import { HeapClient } from "./heap";
3
4
  import { StepResponse, WorkflowResult } from "./step";
4
- import type { WorkflowEvent } from "./event";
5
5
 
6
6
  export type WorkflowGeneratorParams<
7
- EventParams,
8
- Context extends ReadonlyMap<any, any>
7
+ Params extends EventParams,
8
+ Context extends EventContext
9
9
  > = {
10
- event: WorkflowEvent<EventParams, Context>;
10
+ event: WorkflowEvent<Params, Context>;
11
11
  heapClient: HeapClient;
12
12
  logger: Logger;
13
13
  };
14
14
 
15
15
  export type WorkflowGenerator<
16
- EventParams,
16
+ Params extends EventParams,
17
17
  Result,
18
- Context extends Map<any, any>
18
+ Context extends EventContext
19
19
  > = (
20
- genParams: WorkflowGeneratorParams<EventParams, Context>
20
+ genParams: WorkflowGeneratorParams<Params, Context>
21
21
  ) => AsyncGenerator<StepResponse, WorkflowResult<Result>, StepResponse>;
22
22
 
23
23
  export type WorkflowGeneratorReturnType<CG> = CG extends WorkflowGenerator<
24
- infer EventParams,
24
+ infer Params,
25
25
  infer Result,
26
26
  infer Context
27
27
  >
package/src/index.ts CHANGED
@@ -2,13 +2,16 @@ export type { HeapClient, HeapRecord } from "./base/heap";
2
2
  export type { WorkflowInvoker } from "./base/invoker";
3
3
  export type { EventProcessor } from "./base/runtime";
4
4
  export type { SchedulerClient } from "./base/scheduler";
5
- export type { ExecutionEvent, TriggerEvent, WorkflowEvent } from "./base/event";
6
-
7
5
  export type {
8
- MiddlewareNext,
6
+ EventParams,
7
+ EventContext,
8
+ ExecutionEvent,
9
9
  MiddlewareEvent,
10
- MiddlewareFunction,
11
- } from "./base/middleware";
10
+ TriggerEvent,
11
+ WorkflowEvent,
12
+ } from "./base/event";
13
+
14
+ export type { MiddlewareNext, MiddlewareFunction } from "./base/middleware";
12
15
 
13
16
  export type {
14
17
  WorkflowGenerator,
@@ -32,4 +35,6 @@ export {
32
35
  } from "./base/step";
33
36
 
34
37
  export { WorkflowRunner } from "./lib/workflow-runner";
38
+
35
39
  export { ReadOnlyMap, FreezableMap } from "./utils/map";
40
+ export { errorWithOriginalStack } from "./utils/error";
@@ -5,8 +5,10 @@ import type {
5
5
  SchedulerClient,
6
6
  EventProcessor,
7
7
  WorkflowEvent,
8
+ EventParams,
8
9
  } from "..";
9
10
  import { StepDelay, WorkflowDelay, WorkflowResult } from "..";
11
+ import { EventContext } from "../base/event";
10
12
 
11
13
  export class WorkflowRunner<
12
14
  Router extends Record<string, WorkflowGenerator<any, any, any>>
@@ -26,7 +28,7 @@ export class WorkflowRunner<
26
28
  this.router = params.router;
27
29
  }
28
30
 
29
- run: EventProcessor<any, any> = async (event, logger) => {
31
+ run: EventProcessor = async (event, logger) => {
30
32
  const workflow = this.router[event.workflowId];
31
33
 
32
34
  if (!workflow) {
@@ -55,12 +57,12 @@ export class WorkflowRunner<
55
57
  };
56
58
 
57
59
  private async runWorkflows<
58
- EventParams,
60
+ Params extends EventParams,
59
61
  Result,
60
- Context extends Map<any, any>
62
+ Context extends EventContext
61
63
  >(params: {
62
- workflow: WorkflowGenerator<EventParams, Result, Context>;
63
- event: WorkflowEvent<EventParams, Context>;
64
+ workflow: WorkflowGenerator<Params, Result, Context>;
65
+ event: WorkflowEvent<Params, Context>;
64
66
  logger: Logger;
65
67
  }): Promise<WorkflowResult<Result> | WorkflowDelay> {
66
68
  const { workflow, event, logger } = params;
@@ -0,0 +1,6 @@
1
+ export function errorWithOriginalStack(error: Error, fn: Function) {
2
+ const err = new Error(error.message);
3
+ Error.captureStackTrace(err, fn);
4
+ err.stack = error.stack;
5
+ throw err;
6
+ }
@@ -11,6 +11,11 @@ test("ReadOnlyMap", () => {
11
11
  expect(readOnlyMap.get("key")).toBe("value");
12
12
  expect(readOnlyMap.has("key")).toBe(true);
13
13
  expect(readOnlyMap.size).toBe(1);
14
+ expect(Array.from(readOnlyMap.entries())).toEqual([["key", "value"]]);
15
+ expect(Array.from(readOnlyMap.keys())).toEqual(["key"]);
16
+ expect(Array.from(readOnlyMap.values())).toEqual(["value"]);
17
+ expect(readOnlyMap.forEach).toBeInstanceOf(Function);
18
+ expect(readOnlyMap[Symbol.iterator]).toBeInstanceOf(Function);
14
19
 
15
20
  expect("set" in readOnlyMap).toBe(false);
16
21
  expect("delete" in readOnlyMap).toBe(false);
package/src/utils/map.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { errorWithOriginalStack } from "./error";
2
+
1
3
  export class ReadOnlyMap<K, V> implements ReadonlyMap<K, V> {
2
4
  private sourceMap: Map<K, V>;
3
5
 
@@ -17,15 +19,15 @@ export class ReadOnlyMap<K, V> implements ReadonlyMap<K, V> {
17
19
  return this.sourceMap.size;
18
20
  }
19
21
 
20
- entries(): ReturnType<Map<K, V>["entries"]> {
22
+ entries(): MapIterator<[K, V]> {
21
23
  return this.sourceMap.entries();
22
24
  }
23
25
 
24
- keys(): ReturnType<Map<K, V>["keys"]> {
26
+ keys(): MapIterator<K> {
25
27
  return this.sourceMap.keys();
26
28
  }
27
29
 
28
- values(): ReturnType<Map<K, V>["values"]> {
30
+ values(): MapIterator<V> {
29
31
  return this.sourceMap.values();
30
32
  }
31
33
 
@@ -36,7 +38,7 @@ export class ReadOnlyMap<K, V> implements ReadonlyMap<K, V> {
36
38
  return this.sourceMap.forEach(callbackfn, thisArg);
37
39
  }
38
40
 
39
- [Symbol.iterator](): ReturnType<Map<K, V>[typeof Symbol.iterator]> {
41
+ [Symbol.iterator](): MapIterator<[K, V]> {
40
42
  return this.sourceMap[Symbol.iterator]();
41
43
  }
42
44
  }
@@ -54,21 +56,24 @@ export class FreezableMap<K, V> extends Map<K, V> {
54
56
 
55
57
  set(key: K, value: V): this {
56
58
  if (this.frozen) {
57
- throw new Error("Cannot call set on a frozen map");
59
+ const error = new Error("Cannot call set on a frozen map");
60
+ throw errorWithOriginalStack(error, this.set);
58
61
  }
59
62
  return super.set(key, value);
60
63
  }
61
64
 
62
65
  delete(key: K): boolean {
63
66
  if (this.frozen) {
64
- throw new Error("Cannot call delete on a frozen map");
67
+ const error = new Error("Cannot call delete on a frozen map");
68
+ throw errorWithOriginalStack(error, this.delete);
65
69
  }
66
70
  return super.delete(key);
67
71
  }
68
72
 
69
73
  clear(): void {
70
74
  if (this.frozen) {
71
- throw new Error("Cannot call clear on a frozen map");
75
+ const error = new Error("Cannot call clear on a frozen map");
76
+ throw errorWithOriginalStack(error, this.clear);
72
77
  }
73
78
  return super.clear();
74
79
  }