@aikirun/workflow 0.16.0 → 0.17.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.
package/dist/index.d.ts CHANGED
@@ -5,12 +5,12 @@ import { WorkflowRun, TerminalWorkflowRunStatus, WorkflowRunState, WorkflowRunId
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
6
  import { DurationObject, Duration } from '@aikirun/types/duration';
7
7
  import { SleepResult } from '@aikirun/types/sleep';
8
- import { EventSendOptions, EventWaitOptions, EventWaitState } from '@aikirun/types/event';
8
+ import { EventSendOptions, EventWaitOptions, EventWaitResult } from '@aikirun/types/event';
9
9
  import { Serializable } from '@aikirun/types/serializable';
10
10
  import { DistributiveOmit, RequireAtLeastOneProp } from '@aikirun/types/utils';
11
11
  import { TaskId } from '@aikirun/types/task';
12
12
  import { WorkflowRunStateRequest, WorkflowRunTransitionTaskStateRequestV1 } from '@aikirun/types/workflow-run-api';
13
- import { OverlapPolicy, ScheduleActivateOptions, ScheduleId } from '@aikirun/types/schedule';
13
+ import { ScheduleOverlapPolicy, ScheduleActivateOptions, ScheduleId } from '@aikirun/types/schedule';
14
14
 
15
15
  type NonEmptyArray<T> = [T, ...T[]];
16
16
 
@@ -151,8 +151,8 @@ type EventWaiters<TEvents extends EventsDefinition> = {
151
151
  [K in keyof TEvents]: EventWaiter<EventData<TEvents[K]>>;
152
152
  };
153
153
  interface EventWaiter<Data> {
154
- wait(options?: EventWaitOptions<false>): Promise<EventWaitState<Data, false>>;
155
- wait(options: EventWaitOptions<true>): Promise<EventWaitState<Data, true>>;
154
+ wait(options?: EventWaitOptions<false>): Promise<EventWaitResult<Data, false>>;
155
+ wait(options: EventWaitOptions<true>): Promise<EventWaitResult<Data, true>>;
156
156
  }
157
157
  type EventSenders<TEvents extends EventsDefinition> = {
158
158
  [K in keyof TEvents]: EventSender<EventData<TEvents[K]>>;
@@ -309,12 +309,12 @@ interface CronScheduleParams {
309
309
  type: "cron";
310
310
  expression: string;
311
311
  timezone?: string;
312
- overlapPolicy?: OverlapPolicy;
312
+ overlapPolicy?: ScheduleOverlapPolicy;
313
313
  }
314
314
  interface IntervalScheduleParams {
315
315
  type: "interval";
316
316
  every: DurationObject;
317
- overlapPolicy?: OverlapPolicy;
317
+ overlapPolicy?: ScheduleOverlapPolicy;
318
318
  }
319
319
  type ScheduleParams = CronScheduleParams | IntervalScheduleParams;
320
320
  interface ScheduleHandle {
package/dist/index.js CHANGED
@@ -77,6 +77,9 @@ function delay(ms, options) {
77
77
  });
78
78
  }
79
79
 
80
+ // ../../lib/crypto/hash.ts
81
+ import { createHash } from "crypto";
82
+
80
83
  // ../../lib/json/stable-stringify.ts
81
84
  function stableStringify(value) {
82
85
  return stringifyValue(value);
@@ -320,17 +323,17 @@ function createEventWaiter(handle, eventName, schema, logger) {
320
323
  let nextEventIndex = 0;
321
324
  async function wait(options) {
322
325
  await handle.refresh();
323
- const events = handle.run.eventsQueue[eventName]?.events ?? [];
324
- const event2 = events[nextEventIndex];
325
- if (event2) {
326
+ const eventWaits = handle.run.eventWaitQueues[eventName]?.eventWaits ?? [];
327
+ const eventWait = eventWaits[nextEventIndex];
328
+ if (eventWait) {
326
329
  nextEventIndex++;
327
- if (event2.status === "timeout") {
330
+ if (eventWait.status === "timeout") {
328
331
  logger.debug("Timed out waiting for event");
329
332
  return { timeout: true };
330
333
  }
331
- let data = event2.data;
334
+ let data = eventWait.data;
332
335
  if (schema) {
333
- const schemaValidation = schema["~standard"].validate(event2.data);
336
+ const schemaValidation = schema["~standard"].validate(eventWait.data);
334
337
  const schemaValidationResult = schemaValidation instanceof Promise ? await schemaValidation : schemaValidation;
335
338
  if (!schemaValidationResult.issues) {
336
339
  data = schemaValidationResult.value;
@@ -804,7 +807,7 @@ import { INTERNAL as INTERNAL6 } from "@aikirun/types/symbols";
804
807
 
805
808
  // ../../lib/address/index.ts
806
809
  function getWorkflowRunAddress(name, versionId, referenceId) {
807
- return `${name}/${versionId}/${referenceId}`;
810
+ return `${name}:${versionId}:${referenceId}`;
808
811
  }
809
812
 
810
813
  // workflow-version.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikirun/workflow",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
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.16.0",
21
+ "@aikirun/types": "0.17.0",
22
22
  "@standard-schema/spec": "^1.1.0"
23
23
  },
24
24
  "publishConfig": {