@aikirun/workflow 0.10.1 → 0.11.1

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.
package/dist/index.d.ts CHANGED
@@ -255,7 +255,8 @@ interface WorkflowVersion<Input, Output, AppContext, TEventsDefinition extends E
255
255
  with(): WorkflowBuilder<Input, Output, AppContext, TEventsDefinition>;
256
256
  start: (client: Client<AppContext>, ...args: Input extends void ? [] : [Input]) => Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
257
257
  startAsChild: <ParentInput, ParentEventsDefinition extends EventsDefinition>(parentRun: WorkflowRunContext<ParentInput, AppContext, ParentEventsDefinition>, ...args: Input extends void ? [] : [Input]) => Promise<ChildWorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
258
- getHandle: (client: Client<AppContext>, runId: string) => Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
258
+ getHandleById: (client: Client<AppContext>, runId: string) => Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
259
+ getHandleByReferenceId: (client: Client<AppContext>, referenceId: string) => Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
259
260
  [INTERNAL]: {
260
261
  eventsDefinition: TEventsDefinition;
261
262
  handler: (run: WorkflowRunContext<Input, AppContext, TEventsDefinition>, input: Input, context: AppContext) => Promise<void>;
@@ -277,7 +278,8 @@ declare class WorkflowVersionImpl<Input, Output, AppContext, TEventsDefinition e
277
278
  start(client: Client<AppContext>, ...args: Input extends void ? [] : [Input]): Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
278
279
  startAsChild(parentRun: WorkflowRunContext<unknown, AppContext, EventsDefinition>, ...args: Input extends void ? [] : [Input]): Promise<ChildWorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
279
280
  private assertUniqueChildRunReferenceId;
280
- getHandle(client: Client<AppContext>, runId: string): Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
281
+ getHandleById(client: Client<AppContext>, runId: string): Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
282
+ getHandleByReferenceId(client: Client<AppContext>, referenceId: string): Promise<WorkflowRunHandle<Input, Output, AppContext, TEventsDefinition>>;
281
283
  private handler;
282
284
  private tryExecuteWorkflow;
283
285
  private assertRetryAllowed;
package/dist/index.js CHANGED
@@ -178,11 +178,12 @@ function set(obj, path, value) {
178
178
  let currentValue = obj;
179
179
  for (let i = 0; i < keys.length - 1; i++) {
180
180
  const key = keys[i];
181
- currentValue = currentValue[key];
182
- if (currentValue === void 0 || currentValue === null) {
183
- currentValue = {};
184
- currentValue[key] = currentValue;
181
+ let nextValue = currentValue[key];
182
+ if (nextValue === void 0 || nextValue === null) {
183
+ nextValue = {};
184
+ currentValue[key] = nextValue;
185
185
  }
186
+ currentValue = nextValue;
186
187
  }
187
188
  const lastKey = keys[keys.length - 1];
188
189
  currentValue[lastKey] = value;
@@ -985,9 +986,17 @@ var WorkflowVersionImpl = class _WorkflowVersionImpl {
985
986
  throw error;
986
987
  }
987
988
  }
988
- async getHandle(client, runId) {
989
+ async getHandleById(client, runId) {
989
990
  return workflowRunHandle(client, runId, this[INTERNAL5].eventsDefinition);
990
991
  }
992
+ async getHandleByReferenceId(client, referenceId) {
993
+ const { run } = await client.api.workflowRun.getByReferenceIdV1({
994
+ name: this.name,
995
+ versionId: this.versionId,
996
+ referenceId
997
+ });
998
+ return workflowRunHandle(client, run, this[INTERNAL5].eventsDefinition);
999
+ }
991
1000
  async handler(run, input, context) {
992
1001
  const { logger } = run;
993
1002
  const { handle } = run[INTERNAL5];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikirun/workflow",
3
- "version": "0.10.1",
3
+ "version": "0.11.1",
4
4
  "description": "Workflow SDK for Aiki - define durable workflows with tasks, sleeps, waits, and event handling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "build": "tsup"
19
19
  },
20
20
  "dependencies": {
21
- "@aikirun/types": "0.10.1",
21
+ "@aikirun/types": "0.11.1",
22
22
  "@standard-schema/spec": "^1.1.0"
23
23
  },
24
24
  "publishConfig": {