@temelj/workflow 0.0.0-alpha.1 → 0.0.0-alpha.2

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 (64) hide show
  1. package/dist/bundle.d.mts +29 -0
  2. package/dist/bundle.mjs +28 -0
  3. package/dist/client/create.d.mts +10 -2
  4. package/dist/client/create.mjs +5 -3
  5. package/dist/client/facades.mjs +6 -3
  6. package/dist/client/run-handle.d.mts +1 -0
  7. package/dist/client/run-handle.mjs +3 -1
  8. package/dist/cloudflare/cloudflare.d.mts +12 -0
  9. package/dist/cloudflare/codec.d.mts +16 -0
  10. package/dist/cloudflare/codec.mjs +25 -0
  11. package/dist/cloudflare/entrypoint.d.mts +12 -0
  12. package/dist/cloudflare/entrypoint.mjs +18 -0
  13. package/dist/cloudflare/execution.d.mts +13 -0
  14. package/dist/cloudflare/execution.mjs +28 -0
  15. package/dist/cloudflare/host.d.mts +19 -0
  16. package/dist/cloudflare/host.mjs +24 -0
  17. package/dist/cloudflare/mod.d.mts +8 -0
  18. package/dist/cloudflare/mod.mjs +7 -0
  19. package/dist/cloudflare/name.d.mts +5 -0
  20. package/dist/cloudflare/name.mjs +22 -0
  21. package/dist/cloudflare/registry.d.mts +24 -0
  22. package/dist/cloudflare/registry.mjs +26 -0
  23. package/dist/cloudflare/runtime.d.mts +30 -0
  24. package/dist/cloudflare/runtime.mjs +226 -0
  25. package/dist/cloudflare/step.d.mts +22 -0
  26. package/dist/cloudflare/step.mjs +160 -0
  27. package/dist/cloudflare/types.d.mts +87 -0
  28. package/dist/cloudflare/types.mjs +1 -0
  29. package/dist/engine/inspection-api.mjs +2 -1
  30. package/dist/engine/inspection.mjs +7 -5
  31. package/dist/engine/message.mjs +16 -13
  32. package/dist/engine/observation.mjs +1 -3
  33. package/dist/engine/run-data.mjs +2 -1
  34. package/dist/engine/run-service.mjs +2 -1
  35. package/dist/engine/start-api.mjs +2 -1
  36. package/dist/engine/state.mjs +2 -1
  37. package/dist/engine/stream.d.mts +1 -0
  38. package/dist/engine/stream.mjs +1 -0
  39. package/dist/engine/task.mjs +2 -1
  40. package/dist/errors/definition.d.mts +1 -0
  41. package/dist/errors/definition.mjs +3 -0
  42. package/dist/errors/details.mjs +2 -1
  43. package/dist/history/replay-projection.mjs +1 -3
  44. package/dist/mod.d.mts +2 -1
  45. package/dist/mod.mjs +2 -1
  46. package/dist/otel.mjs +4 -2
  47. package/dist/runtime.d.mts +1 -0
  48. package/dist/runtime.mjs +7 -3
  49. package/dist/store/cleanup.mjs +3 -26
  50. package/dist/store/message-index.mjs +2 -1
  51. package/dist/store/query.mjs +5 -3
  52. package/dist/store/run.mjs +9 -6
  53. package/dist/store/schedule.mjs +5 -3
  54. package/dist/store/step-attempt.mjs +5 -3
  55. package/dist/store-keys.d.mts +2 -1
  56. package/dist/store-keys.mjs +24 -1
  57. package/dist/types/common.d.mts +1 -0
  58. package/dist/types/common.mjs +1 -0
  59. package/dist/types/runtime.d.mts +10 -2
  60. package/dist/worker/error.d.mts +1 -0
  61. package/dist/worker/error.mjs +1 -0
  62. package/dist/worker.d.mts +1 -0
  63. package/dist/worker.mjs +1 -0
  64. package/package.json +15 -10
@@ -10,6 +10,7 @@ import "./state.mjs";
10
10
  import { makeStreamChunkCursorKey, pageItems } from "../pagination.mjs";
11
11
  import { resolveWorkflowCommandIdentity } from "./command-identity.mjs";
12
12
  import { appendDurableStepStartedEvent, appendDurableStepTerminalEvent } from "./durable-command.mjs";
13
+ import "temporal-polyfill/global";
13
14
  import { deepEquals } from "@temelj/value";
14
15
  //#region src/engine/stream.ts
15
16
  const DEFAULT_MAXIMUM_STREAM_CHUNKS = 1e3;
@@ -146,7 +146,8 @@ function createWorkflowStepTaskApi(environment, executionSignal) {
146
146
  async sleep(commandId, duration) {
147
147
  const resolvedDuration = duration.total({ unit: "millisecond" });
148
148
  safeDuration(resolvedDuration, "Workflow sleep duration");
149
- await sleepUntil(environment, commandId, now().add(Temporal.Duration.from({ milliseconds: resolvedDuration })), { duration });
149
+ const until = now().add(Temporal.Duration.from({ milliseconds: resolvedDuration }));
150
+ await sleepUntil(environment, commandId, until, { duration });
150
151
  },
151
152
  async sleepUntil(commandId, timestamp) {
152
153
  await sleepUntil(environment, commandId, timestamp, {});
@@ -16,6 +16,7 @@ declare class WorkflowDefinitionError extends WorkflowError {
16
16
  static compiledMetadataMissing(this: void): never;
17
17
  static compiledStepMetadataMissing(this: void): never;
18
18
  static implementationAlreadyRegistered(this: void, key: string): never;
19
+ static implementationNotBundled(this: void, key: string): never;
19
20
  }
20
21
  //#endregion
21
22
  export { WorkflowDefinitionError };
@@ -46,6 +46,9 @@ var WorkflowDefinitionError = class WorkflowDefinitionError extends WorkflowErro
46
46
  static implementationAlreadyRegistered(key) {
47
47
  throw new WorkflowDefinitionError(`Workflow implementation already registered: ${key}`, WorkflowDefinitionError.implementationAlreadyRegistered);
48
48
  }
49
+ static implementationNotBundled(key) {
50
+ throw new WorkflowDefinitionError(`Workflow implementation is not included in the workflow bundle: ${key}`, WorkflowDefinitionError.implementationNotBundled);
51
+ }
49
52
  };
50
53
  //#endregion
51
54
  export { WorkflowDefinitionError };
@@ -14,7 +14,8 @@ function unprefixWorkflowErrorCauseDetails(details) {
14
14
  const message = typeof unprefixed.message === "string" && unprefixed.message.trim() !== "" ? unprefixed.message : name;
15
15
  const stack = typeof unprefixed.stack === "string" && unprefixed.stack.trim() !== "" ? unprefixed.stack : void 0;
16
16
  const code = workflowErrorCodeSchema.safeParse(unprefixed.code);
17
- const sanitizedDetails = sanitizedWorkflowErrorDetails(Object.fromEntries(Object.entries(unprefixed).filter(([key]) => key !== "code" && key !== "name" && key !== "message" && key !== "stack")));
17
+ const publicDetails = Object.fromEntries(Object.entries(unprefixed).filter(([key]) => key !== "code" && key !== "name" && key !== "message" && key !== "stack"));
18
+ const sanitizedDetails = sanitizedWorkflowErrorDetails(publicDetails);
18
19
  return {
19
20
  ...code.success ? { code: code.data } : {},
20
21
  name,
@@ -203,9 +203,7 @@ function appendWorkflowReplayProjectionEvent(projection, event, index) {
203
203
  });
204
204
  break;
205
205
  }
206
- case "deterministic_value_recorded":
207
- projection.deterministicValue.set(event.stepId, event);
208
- break;
206
+ case "deterministic_value_recorded": projection.deterministicValue.set(event.stepId, event);
209
207
  }
210
208
  }
211
209
  function appendStartedEvent(startedEventsByStepId, event) {
package/dist/mod.d.mts CHANGED
@@ -22,6 +22,7 @@ import { RunTelemetryContext, RunTelemetryResultContext, StepTelemetryContext, S
22
22
  import { WORKFLOW_ATTRIBUTE_MAX_COUNT, WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH, WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES, WORKFLOW_ATTRIBUTE_RESERVED_PREFIX, WorkflowAttributePatch, WorkflowAttributeValue, WorkflowLifecycleCallback, WorkflowLifecycleEvent, WorkflowMaterializedStepType, WorkflowRunAttributes, WorkflowRunRecord, WorkflowRunRetryReason, WorkflowRunStatus, WorkflowRunTransitionReason, WorkflowRunWorkflowName, WorkflowRunWorkflowVersion, WorkflowStepIdentity, WorkflowStepType, WorkflowTerminalRunStatus, WorkflowValueIssue, persistedValueIssue, workflowAttributeKeySchema, workflowAttributePatchSchema, workflowAttributePrimitiveValueSchema, workflowAttributeValueSchema, workflowMaterializedStepTypeSchema, workflowPersistedValueSchema, workflowRunAttributesSchema, workflowRunRecordSchema, workflowRunRetryReasonSchema, workflowRunStatusSchema, workflowRunTransitionReasonSchema, workflowStepTypeSchema, workflowTerminalRunStatusSchema } from "./types/run.mjs";
23
23
  import { WorkflowErrorOptions, WorkflowErrorRecord, WorkflowNonRetryableErrorOptions, WorkflowRetryableErrorOptions, workflowErrorRecordSchema } from "./types/error.mjs";
24
24
  import { AttributesSetEvent, ChildWorkflowCompletedEvent, ChildWorkflowEventKind, ChildWorkflowFailedEvent, ChildWorkflowStartedEvent, DataEventKind, DeterministicEventKind, DeterministicValueRecordedEvent, EventDescriptor, EventDescriptorCategory, EventDescriptorStepAttempt, EventKind, EventRecord, MessageEventKind, MessageSendCompletedEvent, MessageSendFailedEvent, MessageSendStartedEvent, MessageSentEvent, MessageSentPayload, MessageWaitCompletedEvent, MessageWaitFailedEvent, MessageWaitSource, MessageWaitStartedEvent, MetadataSetEvent, SleepCompletedEvent, SleepEventKind, SleepStartedEvent, StreamChunkEvent, StreamClosedEvent, StreamEventKind, StreamFailedError, StreamFailedEvent, StreamStartedEvent, WorkflowEvent, WorkflowRunEvent, WorkflowRunEventKind, WorkflowStepCompletedEvent, WorkflowStepEventKind, WorkflowStepFailedEvent, WorkflowStepStartedEvent, workflowAttributesSetEventSchema, workflowChildWorkflowCompletedEventSchema, workflowChildWorkflowEventKindSchema, workflowChildWorkflowFailedEventSchema, workflowChildWorkflowStartedEventSchema, workflowCompletedEventSchema, workflowDataEventKindSchema, workflowDeterministicEventKindSchema, workflowDeterministicValueRecordedEventSchema, workflowEventKindSchema, workflowEventRecordListSchema, workflowEventRecordSchema, workflowFailedEventSchema, workflowMessageEventKindSchema, workflowMessageSendCompletedEventSchema, workflowMessageSendFailedEventSchema, workflowMessageSendStartedEventSchema, workflowMessageSentEventSchema, workflowMessageWaitCompletedEventSchema, workflowMessageWaitFailedEventSchema, workflowMessageWaitSourceSchema, workflowMessageWaitStartedEventSchema, workflowMessageWaiterStepIdsSchema, workflowMetadataSetEventSchema, workflowRunEventKindSchema, workflowSleepCompletedEventSchema, workflowSleepEventKindSchema, workflowSleepStartedEventSchema, workflowStartedEventSchema, workflowStepCompletedEventSchema, workflowStepEventKindSchema, workflowStepFailedEventSchema, workflowStepStartedEventSchema, workflowStreamChunkEventSchema, workflowStreamClosedEventSchema, workflowStreamEventKindSchema, workflowStreamFailedEventSchema, workflowStreamStartedEventSchema } from "./types/events.mjs";
25
+ import { WorkflowBundle, WorkflowBundleEntry, createWorkflowBundleRegistry, defineWorkflowBundle } from "./bundle.mjs";
25
26
  import { ScheduleNextOptions, WorkflowBatchStartItem, WorkflowMarkRunPermanentlyFailedOptions, WorkflowReleaseStaleLeaseOptions, WorkflowRerunOptions, WorkflowRescheduleRunOptions, WorkflowRetryFailedRunOptions, WorkflowRunArguments, WorkflowRunParentOptions, WorkflowStartOptions, WorkflowVersionResolver } from "./types/run-options.mjs";
26
27
  import { CreateWorkflowEngineOptions, WorkflowDeterministicBytesContext, WorkflowDeterministicValueContext, WorkflowEngineSerializationLimits, WorkflowExecutionLimits, WorkflowRecordedIdContext } from "./types/engine-options.mjs";
27
28
  import { CreateWorkflowWorkerOptions, WorkflowWakeDueRunsOptions, WorkflowWorker, WorkflowWorkerLeaseOptions, WorkflowWorkerRunFilterOptions, WorkflowWorkerRunOptions, WorkflowWorkerRunResult } from "./types/worker.mjs";
@@ -49,4 +50,4 @@ import { CreateWorkflowRuntimeOptions, WorkflowRuntimeLocksApi, WorkflowRuntimeR
49
50
  import { WorkflowRuntime, createWorkflowRuntime, getWorkflowRuntimeRun, startWorkflowRuntimeRun } from "./runtime.mjs";
50
51
  import { defineWorkflowStep } from "./step-definition.mjs";
51
52
  import { WebhookResumer, parseWebhookToken, resumeWebhook } from "./webhook.mjs";
52
- export { type AcquireLockOptions, type AttributesSetEvent, type BroadcastMessageChannelObject, type BroadcastMessageChannelOptions, type BroadcastMessageInput, type BroadcastMessageOptions, type BroadcastMessageResult, type ChildWorkflowCompletedEvent, type ChildWorkflowEventKind, type ChildWorkflowFailedEvent, type ChildWorkflowStartedEvent, type ChildWorkflowStartedObservationEvent, type CleanupMarkerRecord, type CleanupMode, type CleanupObservationEvent, type CleanupRunResult, type CleanupRunsOptions, type CleanupRunsResult, type CleanupStatusFilter, type CompiledWorkflowFunction, type CompletedResult, type CreateHookOptions, type CreateStreamOptions, type CreateWebhookOptions, type CreateWorkflowClientOptions, type CreateWorkflowEngineOptions, type CreateWorkflowRuntimeOptions, type CreateWorkflowWorkerOptions, type Cursor, type CursorKeyPart, type CursorPayload, type DataEventKind, type DeterministicEventKind, type DeterministicValueRecordedEvent, type DurableEventObservationEvent, type EventDescriptor, type EventDescriptorCategory, type EventDescriptorStepAttempt, type EventKind, type EventRecord, type ExecutionResult, type ExecutionResultBase, type ExecutionResultKind, type FailedResult, type FollowStreamOptions, type HandleOperations, type Hook, type HookCreator, type HookInspection, type HookInspectionStatus, type HookKind, type HookToken, type HookTokenPayload, type ListSchedulesOptions, type ListSchedulesPageOptions, type LockRecord, type MessageChannel, type MessageChannelConfig, type MessageChannelKeyArgs, type MessageChannelTypes, type MessageEventKind, type MessageId, type MessageObservationEvent, type MessageSendCompletedEvent, type MessageSendFailedEvent, type MessageSendStartedEvent, type MessageSentEvent, type MessageSentPayload, type MessageWaitCompletedEvent, type MessageWaitFailedEvent, type MessageWaitSource, type MessageWaitStartedEvent, type MetadataSetEvent, type ObservationEmitter, type ObservationEventHandler, type ObservationEventMap, type ObservationEventPattern, type ObservationUnsubscribe, type PageDirection, type PageOptions, type ParsedWorkflowHookToken, type ParsedWorkflowWebhookToken, type ReadStreamOptions, type ReadStreamPageOptions, type Registry, type RegistryLike, type ReleaseLockOptions, type ReleaseStaleLockOptions, type ResultOptions, type ResumeHookOptions, type ResumeObservationEvent, type ResumeWebhookOptions, type RetentionPolicyOptions, type RunId, type RunObservationEvent, type RunTelemetryContext, type RunTelemetryResultContext, type ScheduleCatchUpPolicy, type ScheduleConfig, type ScheduleId, type ScheduleNextOptions, type ScheduleOverlapPolicy, type ScheduleRecord, type ScheduleRunCreatedObservationEvent, type ScheduleStatus, type ScheduleTickObservationEvent, type SendMessageChannelObject, type SendMessageChannelOptions, type SendMessageInput, type SendMessageOptions, type SleepCompletedEvent, type SleepEventKind, type SleepStartedEvent, type StepAttemptObservationEvent, type StepId, type StepTelemetryContext, type StepTelemetryResultContext, type StorageTelemetryContext, type StorageTelemetryOperation, type Stream, type StreamChunk, type StreamChunkEvent, type StreamChunkUpdate, type StreamClosedEvent, type StreamEventKind, type StreamFailedError, type StreamFailedEvent, type StreamInfo, type StreamObservationEvent, type StreamPage, type StreamStartedEvent, type StreamState, type StreamStatus, type StreamTerminalUpdate, type StreamUpdate, type StreamUpdateBase, type StreamUpdateKind, type Telemetry, type TelemetryContext, type TelemetryEngine, type TickSchedulesOptions, type TickSchedulesResult, type Timeline, type TimelineAttributesEntry, type TimelineChildWorkflowEntry, type TimelineChildWorkflowStatus, type TimelineDeterministicEntry, type TimelineEntry, type TimelineEntryKind, type TimelineEntryRecord, type TimelineMessageEntry, type TimelineMessageStatus, type TimelineMetadataEntry, type TimelineRecordedStatus, type TimelineSetStatus, type TimelineSleepEntry, type TimelineSleepStatus, type TimelineStepEntry, type TimelineStepStatus, type TimelineStreamEntry, type TimelineStreamStatus, type TimelineWorkflowEntry, type TimelineWorkflowStatus, type WORKFLOW_ATTRIBUTE_MAX_COUNT, type WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH, type WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES, type WORKFLOW_ATTRIBUTE_RESERVED_PREFIX, type WaitForMessageChannelObject, type WaitForMessageChannelOptions, type WaitForMessageInput, type WaitForMessageOptions, type WaitStreamOptions, type WaitingResult, type Webhook, type WebhookCreator, WebhookResumer, type WorkerOperationObservationEvent, type WorkflowActiveChildWorkflowSummary, type WorkflowActiveMessageWaitSummary, type WorkflowAttributePatch, type WorkflowAttributeValue, type WorkflowBatchStartItem, WorkflowCapabilityError, type WorkflowChildWorkflowCancellationPolicy, WorkflowChildWorkflowTimeoutError, type WorkflowClient, type WorkflowClientAdminApi, type WorkflowClientHooksApi, type WorkflowClientLocksApi, type WorkflowClientMessagesApi, type WorkflowClientProcessRunOptions, type WorkflowClientRunsApi, type WorkflowClientSchedulesApi, type WorkflowClientStreamsApi, type WorkflowClientWorkerOptions, type WorkflowClientWorkersApi, type WorkflowContext, type WorkflowDefinition, type WorkflowDefinitionConfig, WorkflowDefinitionError, type WorkflowDefinitionTypes, type WorkflowDeterministicApi, type WorkflowDeterministicBytesContext, type WorkflowDeterministicValueContext, WorkflowDurationError, type WorkflowEngineSerializationLimits, WorkflowError, WorkflowErrorCode, type WorkflowErrorCode as WorkflowErrorCodeType, type WorkflowErrorOptions, type WorkflowErrorRecord, type WorkflowEvent, type WorkflowExecutionLimits, type WorkflowHandle, type WorkflowHandler, WorkflowHookDisposedError, WorkflowHookError, type WorkflowImplementation, WorkflowImplementationNotFoundError, type WorkflowInputFromSchema, type WorkflowLifecycleCallback, type WorkflowLifecycleEvent, type WorkflowListRunsOptions, type WorkflowListRunsPageOptions, type WorkflowListStepAttemptsOptions, type WorkflowListStepAttemptsPageOptions, WorkflowLockError, WorkflowLockStateError, type WorkflowMarkRunPermanentlyFailedOptions, type WorkflowMaterializedStepType, WorkflowMessageDeliveryError, WorkflowMessageError, WorkflowMessageIdempotencyConflictError, WorkflowMessageWaitTimeoutError, type WorkflowMissingImplementationRetryConfig, WorkflowNonRetryableError, type WorkflowNonRetryableErrorOptions, WorkflowOptionsError, type WorkflowPage, WorkflowPermanentFailureError, type WorkflowRawInputFromSchema, type WorkflowRecordedIdContext, type WorkflowRecoveryChildWorkflowWaitSummary, type WorkflowRecoveryDueSummary, type WorkflowRecoveryFailedSummary, type WorkflowRecoveryLeaseSummary, type WorkflowRecoveryLockSummary, type WorkflowRecoveryMessageWaitSummary, type WorkflowRecoveryMissingImplementationSummary, type WorkflowRecoveryRetrySummary, type WorkflowRecoveryScheduleSummary, type WorkflowRecoverySleepWaitSummary, type WorkflowRecoverySummary, type WorkflowRecoverySummaryOptions, type WorkflowRecoveryWaitSummary, type WorkflowReleaseStaleLeaseOptions, WorkflowReplayDivergenceError, type WorkflowRerunOptions, type WorkflowRescheduleRunOptions, WorkflowResultTimeoutError, type WorkflowRetryConfig, type WorkflowRetryFailedRunOptions, WorkflowRetryableError, type WorkflowRetryableErrorOptions, type WorkflowRunArguments, type WorkflowRunAttributes, WorkflowRunCanceledError, WorkflowRunCancellationError, type WorkflowRunChildWorkflowSummary, type WorkflowRunCleanupSummary, type WorkflowRunContext, WorkflowRunDeadlineExceededError, WorkflowRunError, type WorkflowRunEvent, type WorkflowRunEventKind, type WorkflowRunFailureErrorSummary, type WorkflowRunFailureSummary, type WorkflowRunHandle, type WorkflowRunHookSummary, WorkflowRunInvalidError, type WorkflowRunLeaseSummary, type WorkflowRunMessageSummary, WorkflowRunMismatchError, WorkflowRunNotFoundError, WorkflowRunParentError, type WorkflowRunParentOptions, type WorkflowRunRecord, type WorkflowRunRetryReason, type WorkflowRunRetryReasonCounts, type WorkflowRunRetrySummary, type WorkflowRunSleepSummary, type WorkflowRunStatus, type WorkflowRunStatusCounts, type WorkflowRunStatusRunIds, type WorkflowRunStreamSummary, type WorkflowRunSummary, type WorkflowRunSummaryOptions, WorkflowRunTransitionError, type WorkflowRunTransitionReason, type WorkflowRunTransitionReasonCounts, type WorkflowRunTransitionReasonRunIds, type WorkflowRunTransitionSummary, type WorkflowRunWorkflowCount, type WorkflowRunWorkflowName, type WorkflowRunWorkflowSummary, type WorkflowRunWorkflowVersion, type WorkflowRunnable, WorkflowRuntime, WorkflowRuntimeError, type WorkflowRuntimeLocksApi, type WorkflowRuntimeRunsApi, type WorkflowRuntimeSchedulesApi, WorkflowScheduleAlreadyExistsError, WorkflowScheduleError, WorkflowSerializationError, type WorkflowStartOptions, type WorkflowStartTarget, WorkflowStateError, type WorkflowStepAcquireLockOptions, type WorkflowStepApi, type WorkflowStepAttemptFailureErrorSummary, type WorkflowStepAttemptFailureSummary, type WorkflowStepAttemptKindAttemptKeys, type WorkflowStepAttemptKindCounts, type WorkflowStepAttemptKindStepIds, WorkflowStepAttemptLimitError, type WorkflowStepAttemptRecord, type WorkflowStepAttemptStatus, type WorkflowStepAttemptStatusAttemptKeys, type WorkflowStepAttemptStatusCounts, type WorkflowStepAttemptStatusStepIds, type WorkflowStepAttemptSummary, type WorkflowStepCompletedEvent, type WorkflowStepContext, type WorkflowStepDefinition, type WorkflowStepDefinitionHandler, type WorkflowStepDefinitionTypes, type WorkflowStepDeterministicApi, WorkflowStepError, type WorkflowStepEventKind, WorkflowStepExecutionError, type WorkflowStepFailedEvent, type WorkflowStepHookApi, type WorkflowStepHookCreateApi, type WorkflowStepIdentity, type WorkflowStepLockApi, type WorkflowStepMessageApi, type WorkflowStepMetadata, type WorkflowStepReleaseLockOptions, type WorkflowStepRetryConfig, WorkflowStepRetryLimitError, type WorkflowStepRunConfig, type WorkflowStepRunDataApi, type WorkflowStepRunWorkflowOptions, type WorkflowStepStartWorkflowOptions, type WorkflowStepStartedEvent, type WorkflowStepStreamApi, type WorkflowStepTaskApi, WorkflowStepTimeoutError, type WorkflowStepType, type WorkflowStepWorkflowApi, WorkflowStreamError, WorkflowStreamNotFoundError, type WorkflowTerminalRunStatus, type WorkflowTerminalRunStatusCounts, type WorkflowTerminalRunStatusRunIds, type WorkflowValueIssue, type WorkflowVersionResolver, type WorkflowWakeDueRunsOptions, type WorkflowWorker, type WorkflowWorkerLeaseOptions, type WorkflowWorkerRunFilterOptions, type WorkflowWorkerRunOptions, type WorkflowWorkerRunResult, attachWorkflowDefinition, attachWorkflowStepDefinition, callWorkflowStepFunction, createWorkflowClient, createWorkflowRuntime, defineMessageChannel, defineWorkflow, defineWorkflowStep, getCompiledWorkflowDefinition, getCompiledWorkflowStepDefinition, getWorkflowFunctionDefinition, getWorkflowRuntimeRun, getWorkflowStepFunctionDefinition, implementWorkflow, parseWebhookToken, parseWorkflowRuntime, type persistedValueIssue, registerWorkflowFunctions, resumeWebhook, runWorkflowFunction, type scheduleIdSchema, startWorkflowRuntimeRun, type workflowAttributeKeySchema, type workflowAttributePatchSchema, type workflowAttributePrimitiveValueSchema, type workflowAttributeValueSchema, type workflowAttributesSetEventSchema, type workflowChildWorkflowCancellationPolicySchema, type workflowChildWorkflowCompletedEventSchema, type workflowChildWorkflowEventKindSchema, type workflowChildWorkflowFailedEventSchema, type workflowChildWorkflowStartedEventSchema, type workflowCleanupMarkerRecordSchema, type workflowCleanupModeSchema, type workflowCompletedEventSchema, type workflowCursorKeyPartSchema, type workflowCursorPayloadSchema, type workflowCursorSchema, type workflowDataEventKindSchema, type workflowDeterministicEventKindSchema, type workflowDeterministicValueRecordedEventSchema, workflowErrorCodeSchema, workflowErrorRecordSchema, workflowErrorRecordView, type workflowEventKindSchema, type workflowEventRecordListSchema, type workflowEventRecordSchema, type workflowFailedEventSchema, type workflowLockRecordSchema, type workflowMaterializedStepTypeSchema, type workflowMessageEventKindSchema, type workflowMessageSendCompletedEventSchema, type workflowMessageSendFailedEventSchema, type workflowMessageSendStartedEventSchema, type workflowMessageSentEventSchema, type workflowMessageWaitCompletedEventSchema, type workflowMessageWaitFailedEventSchema, type workflowMessageWaitSourceSchema, type workflowMessageWaitStartedEventSchema, type workflowMessageWaiterStepIdsSchema, type workflowMetadataSetEventSchema, type workflowPageDirectionSchema, type workflowPersistedValueSchema, type workflowRunAttributesSchema, type workflowRunEventKindSchema, type workflowRunRecordSchema, type workflowRunRetryReasonSchema, type workflowRunStatusSchema, type workflowRunTransitionReasonSchema, workflowRuntimeSchema, type workflowScheduleCatchUpPolicySchema, type workflowScheduleOverlapPolicySchema, type workflowSchedulePositiveDurationSchema, type workflowScheduleRecordSchema, type workflowScheduleStatusSchema, type workflowSleepCompletedEventSchema, type workflowSleepEventKindSchema, type workflowSleepStartedEventSchema, type workflowStartedEventSchema, type workflowStepAttemptRecordSchema, type workflowStepAttemptStatusSchema, type workflowStepCompletedEventSchema, type workflowStepEventKindSchema, type workflowStepFailedEventSchema, type workflowStepStartedEventSchema, type workflowStepTypeSchema, type workflowStreamChunkEventSchema, type workflowStreamClosedEventSchema, type workflowStreamEventKindSchema, type workflowStreamFailedEventSchema, type workflowStreamStartedEventSchema, type workflowTelemetryContextSchema, type workflowTerminalRunStatusSchema };
53
+ export { type AcquireLockOptions, type AttributesSetEvent, type BroadcastMessageChannelObject, type BroadcastMessageChannelOptions, type BroadcastMessageInput, type BroadcastMessageOptions, type BroadcastMessageResult, type ChildWorkflowCompletedEvent, type ChildWorkflowEventKind, type ChildWorkflowFailedEvent, type ChildWorkflowStartedEvent, type ChildWorkflowStartedObservationEvent, type CleanupMarkerRecord, type CleanupMode, type CleanupObservationEvent, type CleanupRunResult, type CleanupRunsOptions, type CleanupRunsResult, type CleanupStatusFilter, type CompiledWorkflowFunction, type CompletedResult, type CreateHookOptions, type CreateStreamOptions, type CreateWebhookOptions, type CreateWorkflowClientOptions, type CreateWorkflowEngineOptions, type CreateWorkflowRuntimeOptions, type CreateWorkflowWorkerOptions, type Cursor, type CursorKeyPart, type CursorPayload, type DataEventKind, type DeterministicEventKind, type DeterministicValueRecordedEvent, type DurableEventObservationEvent, type EventDescriptor, type EventDescriptorCategory, type EventDescriptorStepAttempt, type EventKind, type EventRecord, type ExecutionResult, type ExecutionResultBase, type ExecutionResultKind, type FailedResult, type FollowStreamOptions, type HandleOperations, type Hook, type HookCreator, type HookInspection, type HookInspectionStatus, type HookKind, type HookToken, type HookTokenPayload, type ListSchedulesOptions, type ListSchedulesPageOptions, type LockRecord, type MessageChannel, type MessageChannelConfig, type MessageChannelKeyArgs, type MessageChannelTypes, type MessageEventKind, type MessageId, type MessageObservationEvent, type MessageSendCompletedEvent, type MessageSendFailedEvent, type MessageSendStartedEvent, type MessageSentEvent, type MessageSentPayload, type MessageWaitCompletedEvent, type MessageWaitFailedEvent, type MessageWaitSource, type MessageWaitStartedEvent, type MetadataSetEvent, type ObservationEmitter, type ObservationEventHandler, type ObservationEventMap, type ObservationEventPattern, type ObservationUnsubscribe, type PageDirection, type PageOptions, type ParsedWorkflowHookToken, type ParsedWorkflowWebhookToken, type ReadStreamOptions, type ReadStreamPageOptions, type Registry, type RegistryLike, type ReleaseLockOptions, type ReleaseStaleLockOptions, type ResultOptions, type ResumeHookOptions, type ResumeObservationEvent, type ResumeWebhookOptions, type RetentionPolicyOptions, type RunId, type RunObservationEvent, type RunTelemetryContext, type RunTelemetryResultContext, type ScheduleCatchUpPolicy, type ScheduleConfig, type ScheduleId, type ScheduleNextOptions, type ScheduleOverlapPolicy, type ScheduleRecord, type ScheduleRunCreatedObservationEvent, type ScheduleStatus, type ScheduleTickObservationEvent, type SendMessageChannelObject, type SendMessageChannelOptions, type SendMessageInput, type SendMessageOptions, type SleepCompletedEvent, type SleepEventKind, type SleepStartedEvent, type StepAttemptObservationEvent, type StepId, type StepTelemetryContext, type StepTelemetryResultContext, type StorageTelemetryContext, type StorageTelemetryOperation, type Stream, type StreamChunk, type StreamChunkEvent, type StreamChunkUpdate, type StreamClosedEvent, type StreamEventKind, type StreamFailedError, type StreamFailedEvent, type StreamInfo, type StreamObservationEvent, type StreamPage, type StreamStartedEvent, type StreamState, type StreamStatus, type StreamTerminalUpdate, type StreamUpdate, type StreamUpdateBase, type StreamUpdateKind, type Telemetry, type TelemetryContext, type TelemetryEngine, type TickSchedulesOptions, type TickSchedulesResult, type Timeline, type TimelineAttributesEntry, type TimelineChildWorkflowEntry, type TimelineChildWorkflowStatus, type TimelineDeterministicEntry, type TimelineEntry, type TimelineEntryKind, type TimelineEntryRecord, type TimelineMessageEntry, type TimelineMessageStatus, type TimelineMetadataEntry, type TimelineRecordedStatus, type TimelineSetStatus, type TimelineSleepEntry, type TimelineSleepStatus, type TimelineStepEntry, type TimelineStepStatus, type TimelineStreamEntry, type TimelineStreamStatus, type TimelineWorkflowEntry, type TimelineWorkflowStatus, type WORKFLOW_ATTRIBUTE_MAX_COUNT, type WORKFLOW_ATTRIBUTE_MAX_KEY_LENGTH, type WORKFLOW_ATTRIBUTE_MAX_VALUE_BYTES, type WORKFLOW_ATTRIBUTE_RESERVED_PREFIX, type WaitForMessageChannelObject, type WaitForMessageChannelOptions, type WaitForMessageInput, type WaitForMessageOptions, type WaitStreamOptions, type WaitingResult, type Webhook, type WebhookCreator, WebhookResumer, type WorkerOperationObservationEvent, type WorkflowActiveChildWorkflowSummary, type WorkflowActiveMessageWaitSummary, type WorkflowAttributePatch, type WorkflowAttributeValue, type WorkflowBatchStartItem, WorkflowBundle, WorkflowBundleEntry, WorkflowCapabilityError, type WorkflowChildWorkflowCancellationPolicy, WorkflowChildWorkflowTimeoutError, type WorkflowClient, type WorkflowClientAdminApi, type WorkflowClientHooksApi, type WorkflowClientLocksApi, type WorkflowClientMessagesApi, type WorkflowClientProcessRunOptions, type WorkflowClientRunsApi, type WorkflowClientSchedulesApi, type WorkflowClientStreamsApi, type WorkflowClientWorkerOptions, type WorkflowClientWorkersApi, type WorkflowContext, type WorkflowDefinition, type WorkflowDefinitionConfig, WorkflowDefinitionError, type WorkflowDefinitionTypes, type WorkflowDeterministicApi, type WorkflowDeterministicBytesContext, type WorkflowDeterministicValueContext, WorkflowDurationError, type WorkflowEngineSerializationLimits, WorkflowError, WorkflowErrorCode, type WorkflowErrorCode as WorkflowErrorCodeType, type WorkflowErrorOptions, type WorkflowErrorRecord, type WorkflowEvent, type WorkflowExecutionLimits, type WorkflowHandle, type WorkflowHandler, WorkflowHookDisposedError, WorkflowHookError, type WorkflowImplementation, WorkflowImplementationNotFoundError, type WorkflowInputFromSchema, type WorkflowLifecycleCallback, type WorkflowLifecycleEvent, type WorkflowListRunsOptions, type WorkflowListRunsPageOptions, type WorkflowListStepAttemptsOptions, type WorkflowListStepAttemptsPageOptions, WorkflowLockError, WorkflowLockStateError, type WorkflowMarkRunPermanentlyFailedOptions, type WorkflowMaterializedStepType, WorkflowMessageDeliveryError, WorkflowMessageError, WorkflowMessageIdempotencyConflictError, WorkflowMessageWaitTimeoutError, type WorkflowMissingImplementationRetryConfig, WorkflowNonRetryableError, type WorkflowNonRetryableErrorOptions, WorkflowOptionsError, type WorkflowPage, WorkflowPermanentFailureError, type WorkflowRawInputFromSchema, type WorkflowRecordedIdContext, type WorkflowRecoveryChildWorkflowWaitSummary, type WorkflowRecoveryDueSummary, type WorkflowRecoveryFailedSummary, type WorkflowRecoveryLeaseSummary, type WorkflowRecoveryLockSummary, type WorkflowRecoveryMessageWaitSummary, type WorkflowRecoveryMissingImplementationSummary, type WorkflowRecoveryRetrySummary, type WorkflowRecoveryScheduleSummary, type WorkflowRecoverySleepWaitSummary, type WorkflowRecoverySummary, type WorkflowRecoverySummaryOptions, type WorkflowRecoveryWaitSummary, type WorkflowReleaseStaleLeaseOptions, WorkflowReplayDivergenceError, type WorkflowRerunOptions, type WorkflowRescheduleRunOptions, WorkflowResultTimeoutError, type WorkflowRetryConfig, type WorkflowRetryFailedRunOptions, WorkflowRetryableError, type WorkflowRetryableErrorOptions, type WorkflowRunArguments, type WorkflowRunAttributes, WorkflowRunCanceledError, WorkflowRunCancellationError, type WorkflowRunChildWorkflowSummary, type WorkflowRunCleanupSummary, type WorkflowRunContext, WorkflowRunDeadlineExceededError, WorkflowRunError, type WorkflowRunEvent, type WorkflowRunEventKind, type WorkflowRunFailureErrorSummary, type WorkflowRunFailureSummary, type WorkflowRunHandle, type WorkflowRunHookSummary, WorkflowRunInvalidError, type WorkflowRunLeaseSummary, type WorkflowRunMessageSummary, WorkflowRunMismatchError, WorkflowRunNotFoundError, WorkflowRunParentError, type WorkflowRunParentOptions, type WorkflowRunRecord, type WorkflowRunRetryReason, type WorkflowRunRetryReasonCounts, type WorkflowRunRetrySummary, type WorkflowRunSleepSummary, type WorkflowRunStatus, type WorkflowRunStatusCounts, type WorkflowRunStatusRunIds, type WorkflowRunStreamSummary, type WorkflowRunSummary, type WorkflowRunSummaryOptions, WorkflowRunTransitionError, type WorkflowRunTransitionReason, type WorkflowRunTransitionReasonCounts, type WorkflowRunTransitionReasonRunIds, type WorkflowRunTransitionSummary, type WorkflowRunWorkflowCount, type WorkflowRunWorkflowName, type WorkflowRunWorkflowSummary, type WorkflowRunWorkflowVersion, type WorkflowRunnable, WorkflowRuntime, WorkflowRuntimeError, type WorkflowRuntimeLocksApi, type WorkflowRuntimeRunsApi, type WorkflowRuntimeSchedulesApi, WorkflowScheduleAlreadyExistsError, WorkflowScheduleError, WorkflowSerializationError, type WorkflowStartOptions, type WorkflowStartTarget, WorkflowStateError, type WorkflowStepAcquireLockOptions, type WorkflowStepApi, type WorkflowStepAttemptFailureErrorSummary, type WorkflowStepAttemptFailureSummary, type WorkflowStepAttemptKindAttemptKeys, type WorkflowStepAttemptKindCounts, type WorkflowStepAttemptKindStepIds, WorkflowStepAttemptLimitError, type WorkflowStepAttemptRecord, type WorkflowStepAttemptStatus, type WorkflowStepAttemptStatusAttemptKeys, type WorkflowStepAttemptStatusCounts, type WorkflowStepAttemptStatusStepIds, type WorkflowStepAttemptSummary, type WorkflowStepCompletedEvent, type WorkflowStepContext, type WorkflowStepDefinition, type WorkflowStepDefinitionHandler, type WorkflowStepDefinitionTypes, type WorkflowStepDeterministicApi, WorkflowStepError, type WorkflowStepEventKind, WorkflowStepExecutionError, type WorkflowStepFailedEvent, type WorkflowStepHookApi, type WorkflowStepHookCreateApi, type WorkflowStepIdentity, type WorkflowStepLockApi, type WorkflowStepMessageApi, type WorkflowStepMetadata, type WorkflowStepReleaseLockOptions, type WorkflowStepRetryConfig, WorkflowStepRetryLimitError, type WorkflowStepRunConfig, type WorkflowStepRunDataApi, type WorkflowStepRunWorkflowOptions, type WorkflowStepStartWorkflowOptions, type WorkflowStepStartedEvent, type WorkflowStepStreamApi, type WorkflowStepTaskApi, WorkflowStepTimeoutError, type WorkflowStepType, type WorkflowStepWorkflowApi, WorkflowStreamError, WorkflowStreamNotFoundError, type WorkflowTerminalRunStatus, type WorkflowTerminalRunStatusCounts, type WorkflowTerminalRunStatusRunIds, type WorkflowValueIssue, type WorkflowVersionResolver, type WorkflowWakeDueRunsOptions, type WorkflowWorker, type WorkflowWorkerLeaseOptions, type WorkflowWorkerRunFilterOptions, type WorkflowWorkerRunOptions, type WorkflowWorkerRunResult, attachWorkflowDefinition, attachWorkflowStepDefinition, callWorkflowStepFunction, createWorkflowBundleRegistry, createWorkflowClient, createWorkflowRuntime, defineMessageChannel, defineWorkflow, defineWorkflowBundle, defineWorkflowStep, getCompiledWorkflowDefinition, getCompiledWorkflowStepDefinition, getWorkflowFunctionDefinition, getWorkflowRuntimeRun, getWorkflowStepFunctionDefinition, implementWorkflow, parseWebhookToken, parseWorkflowRuntime, type persistedValueIssue, registerWorkflowFunctions, resumeWebhook, runWorkflowFunction, type scheduleIdSchema, startWorkflowRuntimeRun, type workflowAttributeKeySchema, type workflowAttributePatchSchema, type workflowAttributePrimitiveValueSchema, type workflowAttributeValueSchema, type workflowAttributesSetEventSchema, type workflowChildWorkflowCancellationPolicySchema, type workflowChildWorkflowCompletedEventSchema, type workflowChildWorkflowEventKindSchema, type workflowChildWorkflowFailedEventSchema, type workflowChildWorkflowStartedEventSchema, type workflowCleanupMarkerRecordSchema, type workflowCleanupModeSchema, type workflowCompletedEventSchema, type workflowCursorKeyPartSchema, type workflowCursorPayloadSchema, type workflowCursorSchema, type workflowDataEventKindSchema, type workflowDeterministicEventKindSchema, type workflowDeterministicValueRecordedEventSchema, workflowErrorCodeSchema, workflowErrorRecordSchema, workflowErrorRecordView, type workflowEventKindSchema, type workflowEventRecordListSchema, type workflowEventRecordSchema, type workflowFailedEventSchema, type workflowLockRecordSchema, type workflowMaterializedStepTypeSchema, type workflowMessageEventKindSchema, type workflowMessageSendCompletedEventSchema, type workflowMessageSendFailedEventSchema, type workflowMessageSendStartedEventSchema, type workflowMessageSentEventSchema, type workflowMessageWaitCompletedEventSchema, type workflowMessageWaitFailedEventSchema, type workflowMessageWaitSourceSchema, type workflowMessageWaitStartedEventSchema, type workflowMessageWaiterStepIdsSchema, type workflowMetadataSetEventSchema, type workflowPageDirectionSchema, type workflowPersistedValueSchema, type workflowRunAttributesSchema, type workflowRunEventKindSchema, type workflowRunRecordSchema, type workflowRunRetryReasonSchema, type workflowRunStatusSchema, type workflowRunTransitionReasonSchema, workflowRuntimeSchema, type workflowScheduleCatchUpPolicySchema, type workflowScheduleOverlapPolicySchema, type workflowSchedulePositiveDurationSchema, type workflowScheduleRecordSchema, type workflowScheduleStatusSchema, type workflowSleepCompletedEventSchema, type workflowSleepEventKindSchema, type workflowSleepStartedEventSchema, type workflowStartedEventSchema, type workflowStepAttemptRecordSchema, type workflowStepAttemptStatusSchema, type workflowStepCompletedEventSchema, type workflowStepEventKindSchema, type workflowStepFailedEventSchema, type workflowStepStartedEventSchema, type workflowStepTypeSchema, type workflowStreamChunkEventSchema, type workflowStreamClosedEventSchema, type workflowStreamEventKindSchema, type workflowStreamFailedEventSchema, type workflowStreamStartedEventSchema, type workflowTelemetryContextSchema, type workflowTerminalRunStatusSchema };
package/dist/mod.mjs CHANGED
@@ -16,6 +16,7 @@ import { WorkflowStepAttemptLimitError, WorkflowStepExecutionError, WorkflowStep
16
16
  import { WorkflowStreamError, WorkflowStreamNotFoundError } from "./errors/stream.mjs";
17
17
  import "./errors/mod.mjs";
18
18
  import { attachWorkflowDefinition, attachWorkflowStepDefinition, callWorkflowStepFunction, getCompiledWorkflowDefinition, getCompiledWorkflowStepDefinition, getWorkflowFunctionDefinition, getWorkflowStepFunctionDefinition, registerWorkflowFunctions, runWorkflowFunction } from "./compiled-function.mjs";
19
+ import { createWorkflowBundleRegistry, defineWorkflowBundle } from "./bundle.mjs";
19
20
  import { defineMessageChannel, defineWorkflow, implementWorkflow } from "./definition.mjs";
20
21
  import { createWorkflowClient } from "./client/create.mjs";
21
22
  import "./client/mod.mjs";
@@ -23,4 +24,4 @@ import { parseWorkflowRuntime, workflowRuntimeSchema } from "./types/runtime.mjs
23
24
  import { WorkflowRuntime, createWorkflowRuntime, getWorkflowRuntimeRun, startWorkflowRuntimeRun } from "./runtime.mjs";
24
25
  import { defineWorkflowStep } from "./step-definition.mjs";
25
26
  import { parseWebhookToken, resumeWebhook } from "./webhook.mjs";
26
- export { WorkflowCapabilityError, WorkflowChildWorkflowTimeoutError, WorkflowDefinitionError, WorkflowDurationError, WorkflowError, WorkflowErrorCode, WorkflowHookDisposedError, WorkflowHookError, WorkflowImplementationNotFoundError, WorkflowLockError, WorkflowLockStateError, WorkflowMessageDeliveryError, WorkflowMessageError, WorkflowMessageIdempotencyConflictError, WorkflowMessageWaitTimeoutError, WorkflowNonRetryableError, WorkflowOptionsError, WorkflowPermanentFailureError, WorkflowReplayDivergenceError, WorkflowResultTimeoutError, WorkflowRetryableError, WorkflowRunCanceledError, WorkflowRunCancellationError, WorkflowRunDeadlineExceededError, WorkflowRunError, WorkflowRunInvalidError, WorkflowRunMismatchError, WorkflowRunNotFoundError, WorkflowRunParentError, WorkflowRunTransitionError, WorkflowRuntime, WorkflowRuntimeError, WorkflowScheduleAlreadyExistsError, WorkflowScheduleError, WorkflowSerializationError, WorkflowStateError, WorkflowStepAttemptLimitError, WorkflowStepError, WorkflowStepExecutionError, WorkflowStepRetryLimitError, WorkflowStepTimeoutError, WorkflowStreamError, WorkflowStreamNotFoundError, attachWorkflowDefinition, attachWorkflowStepDefinition, callWorkflowStepFunction, createWorkflowClient, createWorkflowRuntime, defineMessageChannel, defineWorkflow, defineWorkflowStep, getCompiledWorkflowDefinition, getCompiledWorkflowStepDefinition, getWorkflowFunctionDefinition, getWorkflowRuntimeRun, getWorkflowStepFunctionDefinition, implementWorkflow, parseWebhookToken, parseWorkflowRuntime, registerWorkflowFunctions, resumeWebhook, runWorkflowFunction, startWorkflowRuntimeRun, workflowErrorCodeSchema, workflowErrorRecordSchema, workflowErrorRecordView, workflowRuntimeSchema };
27
+ export { WorkflowCapabilityError, WorkflowChildWorkflowTimeoutError, WorkflowDefinitionError, WorkflowDurationError, WorkflowError, WorkflowErrorCode, WorkflowHookDisposedError, WorkflowHookError, WorkflowImplementationNotFoundError, WorkflowLockError, WorkflowLockStateError, WorkflowMessageDeliveryError, WorkflowMessageError, WorkflowMessageIdempotencyConflictError, WorkflowMessageWaitTimeoutError, WorkflowNonRetryableError, WorkflowOptionsError, WorkflowPermanentFailureError, WorkflowReplayDivergenceError, WorkflowResultTimeoutError, WorkflowRetryableError, WorkflowRunCanceledError, WorkflowRunCancellationError, WorkflowRunDeadlineExceededError, WorkflowRunError, WorkflowRunInvalidError, WorkflowRunMismatchError, WorkflowRunNotFoundError, WorkflowRunParentError, WorkflowRunTransitionError, WorkflowRuntime, WorkflowRuntimeError, WorkflowScheduleAlreadyExistsError, WorkflowScheduleError, WorkflowSerializationError, WorkflowStateError, WorkflowStepAttemptLimitError, WorkflowStepError, WorkflowStepExecutionError, WorkflowStepRetryLimitError, WorkflowStepTimeoutError, WorkflowStreamError, WorkflowStreamNotFoundError, attachWorkflowDefinition, attachWorkflowStepDefinition, callWorkflowStepFunction, createWorkflowBundleRegistry, createWorkflowClient, createWorkflowRuntime, defineMessageChannel, defineWorkflow, defineWorkflowBundle, defineWorkflowStep, getCompiledWorkflowDefinition, getCompiledWorkflowStepDefinition, getWorkflowFunctionDefinition, getWorkflowRuntimeRun, getWorkflowStepFunctionDefinition, implementWorkflow, parseWebhookToken, parseWorkflowRuntime, registerWorkflowFunctions, resumeWebhook, runWorkflowFunction, startWorkflowRuntimeRun, workflowErrorCodeSchema, workflowErrorRecordSchema, workflowErrorRecordView, workflowRuntimeSchema };
package/dist/otel.mjs CHANGED
@@ -192,7 +192,8 @@ var OpenTelemetryWorkflowTelemetry = class {
192
192
  this.#recordRunTransition(event);
193
193
  const attributes = this.#runMetricAttributes(event, { [WORKFLOW_ATTRIBUTES.workerOperation]: event.reason });
194
194
  this.#workerClaims.add(1, attributes);
195
- const latency = optionalDurationBetweenMilliseconds(event.previousRun?.availableAt ?? event.run.availableAt ?? event.run.createdAt, event.timestamp);
195
+ const startedAt = event.previousRun?.availableAt ?? event.run.availableAt ?? event.run.createdAt;
196
+ const latency = optionalDurationBetweenMilliseconds(startedAt, event.timestamp);
196
197
  if (latency !== void 0) this.#pendingToClaimedLatency.record(latency, attributes);
197
198
  break;
198
199
  }
@@ -200,7 +201,8 @@ var OpenTelemetryWorkflowTelemetry = class {
200
201
  const event = payload;
201
202
  this.#recordRunTransition(event);
202
203
  if (event.previousRun?.status !== "waiting") break;
203
- const latency = optionalDurationBetweenMilliseconds(event.previousRun.availableAt ?? event.previousRun.lastTransitionAt, event.timestamp);
204
+ const startedAt = event.previousRun.availableAt ?? event.previousRun.lastTransitionAt;
205
+ const latency = optionalDurationBetweenMilliseconds(startedAt, event.timestamp);
204
206
  if (latency !== void 0) this.#waitingToResumedLatency.record(latency, this.#runMetricAttributes(event));
205
207
  break;
206
208
  }
@@ -4,6 +4,7 @@ import "./types/run.mjs";
4
4
  import { WorkflowRunArguments, WorkflowStartOptions } from "./types/run-options.mjs";
5
5
  import { CompiledWorkflowFunction, WorkflowClientWorkersApi, WorkflowRunHandle } from "./types/client.mjs";
6
6
  import { CreateWorkflowRuntimeOptions, WorkflowRuntime as WorkflowRuntime$1, WorkflowRuntimeLocksApi, WorkflowRuntimeRunsApi, WorkflowRuntimeSchedulesApi } from "./types/runtime.mjs";
7
+ import "temporal-polyfill/global";
7
8
  //#region src/runtime.d.ts
8
9
  /** Creates a workflow runtime backed by a workflow client. */
9
10
  declare function createWorkflowRuntime(options?: CreateWorkflowRuntimeOptions): WorkflowRuntime$1;
package/dist/runtime.mjs CHANGED
@@ -5,12 +5,14 @@ import { WorkflowDefinitionError } from "./errors/definition.mjs";
5
5
  import { WorkflowRuntimeError } from "./errors/runtime.mjs";
6
6
  import "./errors/mod.mjs";
7
7
  import { getCompiledWorkflowDefinition } from "./compiled-function.mjs";
8
+ import { Registry } from "./registry.mjs";
9
+ import { createWorkflowBundleRegistry } from "./bundle.mjs";
8
10
  import { workflowErrorFromRecord } from "./errors/records.mjs";
9
11
  import { durationBetween } from "./temporal.mjs";
10
12
  import { nonNegativeTimerDelay, sleep } from "./timer.mjs";
11
- import { Registry } from "./registry.mjs";
12
13
  import { createWorkflowClient } from "./client/create.mjs";
13
14
  import { parseWorkflowRuntime } from "./types/runtime.mjs";
15
+ import "temporal-polyfill/global";
14
16
  //#region src/runtime.ts
15
17
  const DEFAULT_RESULT_POLL_INTERVAL = Temporal.Duration.from({ milliseconds: 100 });
16
18
  const WORKFLOW_RUNTIME_CLOCKS = /* @__PURE__ */ new WeakMap();
@@ -29,10 +31,12 @@ var WorkflowRuntime = class {
29
31
  #client;
30
32
  #registry;
31
33
  constructor(options = {}) {
34
+ const { registry, workflows, ...runtimeOptions } = options;
35
+ if (registry !== void 0 && workflows !== void 0) throw new TypeError("Workflow runtime options cannot include both registry and workflows");
32
36
  const now = options.now ?? Temporal.Now.instant;
33
- this.#registry = options.registry ?? new Registry();
37
+ this.#registry = registry ?? (workflows === void 0 ? new Registry() : createWorkflowBundleRegistry(workflows));
34
38
  this.#client = createWorkflowClient({
35
- ...options,
39
+ ...runtimeOptions,
36
40
  registry: this.#registry,
37
41
  now
38
42
  });
@@ -1,12 +1,10 @@
1
1
  import { WorkflowStateError } from "../errors/base.mjs";
2
- import { makeWorkflowStepAttemptKey } from "../history/attempt-key.mjs";
3
2
  import { isTerminalWorkflowRunStatus } from "../utility.mjs";
4
- import { omitUndefined } from "../collection.mjs";
5
3
  import "../errors/mod.mjs";
4
+ import { omitUndefined } from "../collection.mjs";
6
5
  import { compareOptionalTimestamps } from "../temporal.mjs";
7
- import "../history/mod.mjs";
8
6
  import { supportsWorkflowConditionalWrite } from "./capabilities.mjs";
9
- import { makeCleanupMarkerKey, makeCleanupMarkerKeyPrefix, makeEventsKey, makeIdempotencyKey, makeMessageIdempotencyKey, makeRunKey, makeStepAttemptKeyPrefix } from "../store-keys.mjs";
7
+ import { isStepAttemptKey, makeCleanupMarkerKey, makeCleanupMarkerKeyPrefix, makeEventsKey, makeIdempotencyKey, makeMessageIdempotencyKey, makeRunKey, makeStepAttemptKeyPrefix } from "../store-keys.mjs";
10
8
  import { isSameWorkflowStorageValue } from "./revision.mjs";
11
9
  import { toStorageValue } from "./storage-value.mjs";
12
10
  import { isReadableMessageIdempotencyIndex, isSameMessageIdempotencyIndex, readableCleanupMarkerRecord } from "./validation.mjs";
@@ -16,28 +14,7 @@ import { messageIdempotencyIndexValuesFromEvents } from "./message-index.mjs";
16
14
  //#region src/store/cleanup.ts
17
15
  async function stepAttemptKeysForCleanup(storage, namespace, runId) {
18
16
  const prefix = makeStepAttemptKeyPrefix(namespace, runId);
19
- return [...new Set((await storage.keys({ prefix })).filter((key) => isStepAttemptKey(key, prefix)))];
20
- }
21
- function isStepAttemptKey(key, prefix) {
22
- if (!key.startsWith(prefix)) return false;
23
- const attemptKey = decodeStepAttemptKey(key, prefix);
24
- if (attemptKey === void 0) return false;
25
- const separator = attemptKey.lastIndexOf(":");
26
- if (!attemptKey.startsWith("run:") || separator <= 4) return false;
27
- const stepId = attemptKey.slice(4, separator);
28
- const attempt = Number(attemptKey.slice(separator + 1));
29
- try {
30
- return makeWorkflowStepAttemptKey(stepId, attempt) === attemptKey;
31
- } catch {
32
- return false;
33
- }
34
- }
35
- function decodeStepAttemptKey(key, prefix) {
36
- try {
37
- return decodeURIComponent(key.slice(prefix.length));
38
- } catch {
39
- return;
40
- }
17
+ return [...new Set((await storage.keys({ prefix })).filter((key) => isStepAttemptKey(key, namespace, runId)))];
41
18
  }
42
19
  async function messageIdempotencyIndexesForCleanup(storage, namespace, runId, events) {
43
20
  const candidatesByKey = /* @__PURE__ */ new Map();
@@ -55,7 +55,8 @@ async function indexMessageIdempotencyKey(storage, namespace, runId, event, even
55
55
  return;
56
56
  }
57
57
  if (await storage.compareAndSet(key, void 0, toStorageValue(value))) return;
58
- if (isSameMessageIdempotencyIndex(await storage.get(key), value)) return;
58
+ const current = await storage.get(key);
59
+ if (isSameMessageIdempotencyIndex(current, value)) return;
59
60
  WorkflowMessageIdempotencyConflictError.conflict({
60
61
  runId,
61
62
  messageId: indexedEvent.messageId,
@@ -1,13 +1,14 @@
1
1
  import { WorkflowRunNotFoundError } from "../errors/run.mjs";
2
- import { matchesOptionalValue, uniqueBy } from "../collection.mjs";
3
2
  import "../errors/mod.mjs";
3
+ import { matchesOptionalValue, uniqueBy } from "../collection.mjs";
4
4
  import { compareOptionalTimestamps, matchesOptionalDurationRange, matchesOptionalTimestampRange, matchesTimestampRange } from "../temporal.mjs";
5
5
  import { makeRunKeyPrefix, makeScheduleKeyPrefix } from "../store-keys.mjs";
6
6
  import { isListableWorkflowRunRecord, isReadableScheduleRecord } from "./validation.mjs";
7
7
  import { reconcileStepAttempts } from "./materialization.mjs";
8
8
  //#region src/store/query.ts
9
9
  async function queryWorkflowRuns(storage, namespace, options, query) {
10
- const uniqueRuns = uniqueBy((await storage.entries({ prefix: makeRunKeyPrefix(namespace) })).map((entry) => entry.value).filter((run) => isListableWorkflowRunRecord(run, namespace)).filter((run) => matchesWorkflowRunListOptions(run, options)), (run) => run.id);
10
+ const runs = (await storage.entries({ prefix: makeRunKeyPrefix(namespace) })).map((entry) => entry.value).filter((run) => isListableWorkflowRunRecord(run, namespace)).filter((run) => matchesWorkflowRunListOptions(run, options));
11
+ const uniqueRuns = uniqueBy(runs, (run) => run.id);
11
12
  if (!query.sort) return uniqueRuns;
12
13
  return [...uniqueRuns].sort(compareWorkflowRunsForQuery);
13
14
  }
@@ -16,7 +17,8 @@ async function queryWorkflowStepAttempts(storage, namespace, store, runId, optio
16
17
  return (await reconcileStepAttempts(storage, namespace, runId, await store.getEvents(runId))).filter((attempt) => matchesWorkflowStepAttemptListOptions(attempt, options));
17
18
  }
18
19
  async function querySchedules(storage, namespace, options, _query) {
19
- return uniqueBy((await storage.entries({ prefix: makeScheduleKeyPrefix(namespace) })).map((entry) => entry.value).filter((schedule) => isReadableScheduleRecord(schedule, namespace)).filter((schedule) => matchesScheduleListOptions(schedule, options)).sort(compareSchedulesForQuery), (schedule) => schedule.id);
20
+ const schedules = (await storage.entries({ prefix: makeScheduleKeyPrefix(namespace) })).map((entry) => entry.value).filter((schedule) => isReadableScheduleRecord(schedule, namespace)).filter((schedule) => matchesScheduleListOptions(schedule, options)).sort(compareSchedulesForQuery);
21
+ return uniqueBy(schedules, (schedule) => schedule.id);
20
22
  }
21
23
  function compareWorkflowRunsForQuery(left, right) {
22
24
  const createdOrder = compareOptionalTimestamps(left.createdAt, right.createdAt);
@@ -1,8 +1,8 @@
1
1
  import { WorkflowStateError } from "../errors/base.mjs";
2
2
  import { WorkflowRunNotFoundError } from "../errors/run.mjs";
3
3
  import { isTerminalWorkflowLifecycleEventForRun, isTerminalWorkflowRunStatus, limitWorkflowItems, nextRunAttempt } from "../utility.mjs";
4
- import { omitUndefined } from "../collection.mjs";
5
4
  import "../errors/mod.mjs";
5
+ import { omitUndefined } from "../collection.mjs";
6
6
  import { supportsWorkflowConditionalWrite } from "./capabilities.mjs";
7
7
  import { makeRunKey } from "../store-keys.mjs";
8
8
  import { isSameWorkflowStorageValue } from "./revision.mjs";
@@ -36,19 +36,21 @@ async function getWorkflowRun(storage, namespace, runId) {
36
36
  return isReadableWorkflowRunRecord(run, namespace) ? run : void 0;
37
37
  }
38
38
  async function listWorkflowRuns(storage, namespace, options) {
39
- return limitWorkflowItems(await queryWorkflowRuns(storage, namespace, options, {
39
+ const runs = await queryWorkflowRuns(storage, namespace, options, {
40
40
  label: "Workflow run list options",
41
41
  sort: true
42
- }), options?.limit);
42
+ });
43
+ return limitWorkflowItems(runs, options?.limit);
43
44
  }
44
45
  async function listWorkflowRunsPage(storage, namespace, options) {
45
- return pageItems(await queryWorkflowRuns(storage, namespace, {
46
+ const runs = await queryWorkflowRuns(storage, namespace, {
46
47
  ...options,
47
48
  limit: void 0
48
49
  }, {
49
50
  label: "Workflow run page options",
50
51
  sort: true
51
- }), options, "Workflow run page", makeWorkflowRunCursorKey);
52
+ });
53
+ return pageItems(runs, options, "Workflow run page", makeWorkflowRunCursorKey);
52
54
  }
53
55
  async function countWorkflowRuns(storage, namespace, options) {
54
56
  return (await queryWorkflowRuns(storage, namespace, options, {
@@ -88,7 +90,8 @@ async function isStoredWorkflowRunRevisionCurrent(storage, namespace, currentRun
88
90
  return isSameReadableWorkflowRunRevision(await getReadableStoredWorkflowRunValue(storage, namespace, currentRun.id), currentRun, namespace);
89
91
  }
90
92
  async function getReadableStoredWorkflowRun(storage, namespace, runId) {
91
- const run = parseStoredWorkflowRunRecord(await storage.get(makeRunKey(namespace, runId)));
93
+ const runValue = await storage.get(makeRunKey(namespace, runId));
94
+ const run = parseStoredWorkflowRunRecord(runValue);
92
95
  return isReadableWorkflowRunRecord(run, namespace) ? run : void 0;
93
96
  }
94
97
  async function getReadableStoredWorkflowRunValue(storage, namespace, runId) {
@@ -29,13 +29,15 @@ async function updateScheduleIfCurrent(storage, namespace, current, next) {
29
29
  return await storage.compareAndSet(makeScheduleKey(namespace, current.id), toStorageValue(current), toStorageValue(compact)) ? compact : void 0;
30
30
  }
31
31
  async function listSchedules(storage, namespace, options) {
32
- return limitWorkflowItems(await querySchedules(storage, namespace, options, { label: "Workflow schedule list options" }), options?.limit);
32
+ const schedules = await querySchedules(storage, namespace, options, { label: "Workflow schedule list options" });
33
+ return limitWorkflowItems(schedules, options?.limit);
33
34
  }
34
35
  async function listSchedulesPage(storage, namespace, options) {
35
- return pageItems(await querySchedules(storage, namespace, {
36
+ const schedules = await querySchedules(storage, namespace, {
36
37
  ...options,
37
38
  limit: void 0
38
- }, { label: "Workflow schedule page options" }), options, "Workflow schedule page", makeScheduleCursorKey);
39
+ }, { label: "Workflow schedule page options" });
40
+ return pageItems(schedules, options, "Workflow schedule page", makeScheduleCursorKey);
39
41
  }
40
42
  //#endregion
41
43
  export { createSchedule, getReadableSchedule, listSchedules, listSchedulesPage, updateScheduleIfCurrent };
@@ -4,13 +4,15 @@ import { reconcileStepAttempts } from "./materialization.mjs";
4
4
  import { getRequiredStoreRun, queryWorkflowStepAttempts } from "./query.mjs";
5
5
  //#region src/store/step-attempt.ts
6
6
  async function listWorkflowStepAttempts(storage, namespace, store, runId, options) {
7
- return limitWorkflowItems(await queryWorkflowStepAttempts(storage, namespace, store, runId, options, { label: "Workflow step attempt list options" }), options?.limit);
7
+ const attempts = await queryWorkflowStepAttempts(storage, namespace, store, runId, options, { label: "Workflow step attempt list options" });
8
+ return limitWorkflowItems(attempts, options?.limit);
8
9
  }
9
10
  async function listWorkflowStepAttemptsPage(storage, namespace, store, runId, options) {
10
- return pageItems(await queryWorkflowStepAttempts(storage, namespace, store, runId, {
11
+ const attempts = await queryWorkflowStepAttempts(storage, namespace, store, runId, {
11
12
  ...options,
12
13
  limit: void 0
13
- }, { label: "Workflow step attempt page options" }), options, "Workflow step attempt page", makeWorkflowStepAttemptCursorKey);
14
+ }, { label: "Workflow step attempt page options" });
15
+ return pageItems(attempts, options, "Workflow step attempt page", makeWorkflowStepAttemptCursorKey);
14
16
  }
15
17
  async function countWorkflowStepAttempts(storage, namespace, store, runId, options) {
16
18
  return (await queryWorkflowStepAttempts(storage, namespace, store, runId, options, { label: "Workflow step attempt list options" })).length;
@@ -27,6 +27,7 @@ declare function makeEventsKey(namespace: string, runId: RunId): WorkflowEventsK
27
27
  declare function makeStepAttemptKey(namespace: string, runId: RunId, attemptKey: string): WorkflowStepAttemptKey;
28
28
  /** Builds a workflow step-attempt storage key prefix. */
29
29
  declare function makeStepAttemptKeyPrefix(namespace: string, runId: RunId): WorkflowStepAttemptKeyPrefix;
30
+ declare function isStepAttemptKey(key: string, namespace: string, runId: RunId): boolean;
30
31
  /** Builds a workflow message idempotency storage key. */
31
32
  declare function makeMessageIdempotencyKey(namespace: string, runId: RunId, idempotencyKey: string): MessageIdempotencyKey;
32
33
  /** Builds a workflow schedule storage key. */
@@ -46,4 +47,4 @@ declare function makeIdempotencyKey(namespace: string, options: WorkflowIdempote
46
47
  /** Builds a workflow run storage key prefix. */
47
48
  declare function makeRunKeyPrefix(namespace: string): WorkflowRunKeyPrefix;
48
49
  //#endregion
49
- export { MessageIdempotencyKey, WorkflowCleanupMarkerKey, WorkflowCleanupMarkerKeyPrefix, WorkflowEventsKey, WorkflowIdempotencyKey, WorkflowLockKey, WorkflowLockKeyPrefix, WorkflowNamespacePrefix, WorkflowRunKey, WorkflowRunKeyPrefix, WorkflowScheduleKey, WorkflowScheduleKeyPrefix, WorkflowStepAttemptKey, WorkflowStepAttemptKeyPrefix, makeCleanupMarkerKey, makeCleanupMarkerKeyPrefix, makeEventsKey, makeIdempotencyKey, makeLockKey, makeLockKeyPrefix, makeMessageIdempotencyKey, makeRunKey, makeRunKeyPrefix, makeScheduleKey, makeScheduleKeyPrefix, makeStepAttemptKey, makeStepAttemptKeyPrefix, makeWorkflowIdempotencyKey };
50
+ export { MessageIdempotencyKey, WorkflowCleanupMarkerKey, WorkflowCleanupMarkerKeyPrefix, WorkflowEventsKey, WorkflowIdempotencyKey, WorkflowLockKey, WorkflowLockKeyPrefix, WorkflowNamespacePrefix, WorkflowRunKey, WorkflowRunKeyPrefix, WorkflowScheduleKey, WorkflowScheduleKeyPrefix, WorkflowStepAttemptKey, WorkflowStepAttemptKeyPrefix, isStepAttemptKey, makeCleanupMarkerKey, makeCleanupMarkerKeyPrefix, makeEventsKey, makeIdempotencyKey, makeLockKey, makeLockKeyPrefix, makeMessageIdempotencyKey, makeRunKey, makeRunKeyPrefix, makeScheduleKey, makeScheduleKeyPrefix, makeStepAttemptKey, makeStepAttemptKeyPrefix, makeWorkflowIdempotencyKey };
@@ -1,3 +1,4 @@
1
+ import { makeWorkflowStepAttemptKey } from "./history/attempt-key.mjs";
1
2
  //#region src/store-keys.ts
2
3
  /** Builds a validated workflow idempotency storage key. */
3
4
  function makeWorkflowIdempotencyKey(namespace, options) {
@@ -19,6 +20,28 @@ function makeStepAttemptKey(namespace, runId, attemptKey) {
19
20
  function makeStepAttemptKeyPrefix(namespace, runId) {
20
21
  return `${namespacePrefix(namespace)}step-attempt:${runId}:`;
21
22
  }
23
+ function isStepAttemptKey(key, namespace, runId) {
24
+ const prefix = makeStepAttemptKeyPrefix(namespace, runId);
25
+ if (!key.startsWith(prefix)) return false;
26
+ const attemptKey = decodeStepAttemptKey(key, prefix);
27
+ if (attemptKey === void 0) return false;
28
+ const separator = attemptKey.lastIndexOf(":");
29
+ if (!attemptKey.startsWith("run:") || separator <= 4) return false;
30
+ const stepId = attemptKey.slice(4, separator);
31
+ const attempt = Number(attemptKey.slice(separator + 1));
32
+ try {
33
+ return makeWorkflowStepAttemptKey(stepId, attempt) === attemptKey;
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+ function decodeStepAttemptKey(key, prefix) {
39
+ try {
40
+ return decodeURIComponent(key.slice(prefix.length));
41
+ } catch {
42
+ return;
43
+ }
44
+ }
22
45
  /** Builds a workflow message idempotency storage key. */
23
46
  function makeMessageIdempotencyKey(namespace, runId, idempotencyKey) {
24
47
  return `${namespacePrefix(namespace)}message-idempotency:${encodeURIComponent(runId)}:${encodeURIComponent(idempotencyKey)}`;
@@ -60,4 +83,4 @@ function namespacePrefix(namespace) {
60
83
  return `workflow:${encodeURIComponent(namespace)}:`;
61
84
  }
62
85
  //#endregion
63
- export { makeCleanupMarkerKey, makeCleanupMarkerKeyPrefix, makeEventsKey, makeIdempotencyKey, makeLockKey, makeLockKeyPrefix, makeMessageIdempotencyKey, makeRunKey, makeRunKeyPrefix, makeScheduleKey, makeScheduleKeyPrefix, makeStepAttemptKey, makeStepAttemptKeyPrefix, makeWorkflowIdempotencyKey };
86
+ export { isStepAttemptKey, makeCleanupMarkerKey, makeCleanupMarkerKeyPrefix, makeEventsKey, makeIdempotencyKey, makeLockKey, makeLockKeyPrefix, makeMessageIdempotencyKey, makeRunKey, makeRunKeyPrefix, makeScheduleKey, makeScheduleKeyPrefix, makeStepAttemptKey, makeStepAttemptKeyPrefix, makeWorkflowIdempotencyKey };
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import "temporal-polyfill/global";
2
3
  //#region src/types/common.d.ts
3
4
  declare const temporalInstantSchema: z.ZodCustom<Temporal.Instant, Temporal.Instant>;
4
5
  declare const temporalDurationSchema: z.ZodCustom<Temporal.Duration, Temporal.Duration>;
@@ -1,5 +1,6 @@
1
1
  import { durationTotal } from "../utility.mjs";
2
2
  import { z } from "zod";
3
+ import "temporal-polyfill/global";
3
4
  //#region src/types/common.ts
4
5
  const temporalInstantSchema = z.instanceof(Temporal.Instant, { error: "Expected a Temporal.Instant" });
5
6
  const temporalDurationSchema = z.instanceof(Temporal.Duration, { error: "Expected a Temporal.Duration" });
@@ -6,6 +6,7 @@ import { AcquireLockOptions, LockRecord, ReleaseLockOptions, ReleaseStaleLockOpt
6
6
  import { WorkflowListRunsOptions } from "./run-list.mjs";
7
7
  import { Telemetry } from "./telemetry.mjs";
8
8
  import { WorkflowLifecycleCallback, WorkflowRunRecord } from "./run.mjs";
9
+ import { WorkflowBundle } from "../bundle.mjs";
9
10
  import { ScheduleNextOptions, WorkflowRunArguments, WorkflowStartOptions } from "./run-options.mjs";
10
11
  import { WorkflowDeterministicBytesContext, WorkflowDeterministicValueContext, WorkflowExecutionLimits, WorkflowRecordedIdContext } from "./engine-options.mjs";
11
12
  import { WorkflowClientEngine, WorkflowWorkerEngine } from "./engine.mjs";
@@ -26,10 +27,9 @@ declare const workflowRuntimeSchema: z.ZodObject<{
26
27
  /** Asserts that a value has the minimum shape required by runtime helper functions. */
27
28
  declare function parseWorkflowRuntime(value: unknown): asserts value is WorkflowRuntime;
28
29
  /** Options for workflow creation runtime. */
29
- interface CreateWorkflowRuntimeOptions extends WorkflowExecutionLimits {
30
+ interface CreateWorkflowRuntimeBaseOptions extends WorkflowExecutionLimits {
30
31
  readonly engine?: WorkflowClientEngine;
31
32
  readonly workerEngine?: WorkflowWorkerEngine;
32
- readonly registry?: RegistryLike;
33
33
  /**
34
34
  * Clock used for workflow timestamps and the first value recorded by
35
35
  * deterministic time commands.
@@ -71,6 +71,14 @@ interface CreateWorkflowRuntimeOptions extends WorkflowExecutionLimits {
71
71
  readonly telemetry?: Telemetry | false;
72
72
  readonly logger?: Logger | false;
73
73
  }
74
+ /** Options for creating a workflow runtime with either a registry or an immutable bundle. */
75
+ type CreateWorkflowRuntimeOptions = CreateWorkflowRuntimeBaseOptions & ({
76
+ readonly registry?: RegistryLike;
77
+ readonly workflows?: never;
78
+ } | {
79
+ readonly registry?: never;
80
+ readonly workflows?: WorkflowBundle;
81
+ });
74
82
  /** Describes the workflow runtime contract. */
75
83
  interface WorkflowRuntime {
76
84
  /** Grouped run handle and run listing operations. */
@@ -1,6 +1,7 @@
1
1
  import { WorkflowResolvedMissingImplementationRetryConfig } from "../types/retry.mjs";
2
2
  import { WorkflowRunRecord } from "../types/run.mjs";
3
3
  import { WorkflowErrorRecord } from "../types/error.mjs";
4
+ import "temporal-polyfill/global";
4
5
  //#region src/worker/error.d.ts
5
6
  declare const DEFAULT_MISSING_IMPLEMENTATION_RETRY_INTERVAL: Temporal.Duration;
6
7
  declare function makeMissingImplementationNotFoundErrorRecord(run: WorkflowRunRecord): WorkflowErrorRecord;
@@ -2,6 +2,7 @@ import { WorkflowOptionsError } from "../errors/base.mjs";
2
2
  import { WorkflowRunDeadlineExceededError } from "../errors/run.mjs";
3
3
  import { durationTotal, isPositiveSafeInteger, safeDuration } from "../utility.mjs";
4
4
  import { WorkflowImplementationNotFoundError } from "../errors/implementation.mjs";
5
+ import "temporal-polyfill/global";
5
6
  //#region src/worker/error.ts
6
7
  const DEFAULT_MISSING_IMPLEMENTATION_RETRY_INTERVAL = Temporal.Duration.from({ seconds: 30 });
7
8
  function makeMissingImplementationNotFoundErrorRecord(run) {
package/dist/worker.d.mts CHANGED
@@ -2,6 +2,7 @@ import { RunId } from "./types/run-id.mjs";
2
2
  import { ExecutionResult } from "./types/result.mjs";
3
3
  import { WorkflowRunRecord } from "./types/run.mjs";
4
4
  import { CreateWorkflowWorkerOptions, WorkflowWorker as WorkflowWorker$1, WorkflowWorkerLeaseOptions, WorkflowWorkerRunFilterOptions, WorkflowWorkerRunOptions, WorkflowWorkerRunResult } from "./types/worker.mjs";
5
+ import "temporal-polyfill/global";
5
6
  //#region src/worker.d.ts
6
7
  /** Storage-backed workflow worker implementation. */
7
8
  declare class WorkflowWorker implements WorkflowWorker$1 {
package/dist/worker.mjs CHANGED
@@ -8,6 +8,7 @@ import { resolveMissingImplementationRetryConfig } from "./engine/retry.mjs";
8
8
  import { patchRunIfCurrent, transitionRunToFailed, transitionRunToMissingImplementationWait, wakeParentRunForTerminalChild, wakeParentRunForWaitingChild } from "./engine/state.mjs";
9
9
  import { requireWorkflowStoreCapabilities } from "./store/capabilities.mjs";
10
10
  import { DEFAULT_MISSING_IMPLEMENTATION_RETRY_INTERVAL, makeMissingImplementationDeadlineErrorRecord, makeMissingImplementationNotFoundErrorRecord, missingImplementationRetryDelay, toWorkflowWorkerErrorRecord } from "./worker/error.mjs";
11
+ import "temporal-polyfill/global";
11
12
  //#region src/worker.ts
12
13
  const DEFAULT_WORKER_LEASE_DURATION = Temporal.Duration.from({ seconds: 30 });
13
14
  const DEFAULT_WORKER_POLL_INTERVAL = Temporal.Duration.from({ milliseconds: 100 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temelj/workflow",
3
- "version": "0.0.0-alpha.1",
3
+ "version": "0.0.0-alpha.2",
4
4
  "description": "Durable, vendor-agnostic, extendible workflows.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -72,35 +72,40 @@
72
72
  "./worker": {
73
73
  "types": "./dist/worker.d.mts",
74
74
  "import": "./dist/worker.mjs"
75
+ },
76
+ "./cloudflare": {
77
+ "types": "./dist/cloudflare/mod.d.mts",
78
+ "import": "./dist/cloudflare/mod.mjs"
75
79
  }
76
80
  },
77
81
  "dependencies": {
78
82
  "@opentelemetry/api": "^1.9.1",
79
- "oxc-parser": "0.141.0",
83
+ "oxc-parser": "0.144.0",
84
+ "temporal-polyfill": "^1.0.4",
80
85
  "unplugin": "^3.3.0",
81
86
  "zod": "^4.4.3",
82
87
  "@temelj/event": "0.1.0",
83
- "@temelj/standard-schema": "0.1.0",
88
+ "@temelj/log": "0.1.0",
84
89
  "@temelj/storage": "0.4.0",
85
90
  "@temelj/string": "0.14.0",
86
91
  "@temelj/value": "0.14.0",
87
- "@temelj/log": "0.1.0"
92
+ "@temelj/standard-schema": "0.1.0"
88
93
  },
89
94
  "devDependencies": {
90
95
  "@opentelemetry/sdk-metrics": "^2.10.0",
91
96
  "@opentelemetry/sdk-trace-base": "^2.10.0",
92
- "@rspack/core": "^2.1.5",
97
+ "@rspack/core": "^2.1.10",
93
98
  "@types/node": "26.1.1",
94
- "esbuild": "^0.28.1",
95
- "rolldown": "^1.2.0",
96
- "rollup": "^4.62.2",
99
+ "esbuild": "^0.28.2",
100
+ "rolldown": "^1.2.4",
101
+ "rollup": "^4.62.4",
97
102
  "shx": "^0.4.0",
98
103
  "tsdown": "^0.22.14",
99
104
  "typedoc": "^0.28.20",
100
105
  "typescript": "^7.0.2",
101
- "vite": "^8.1.5",
106
+ "vite": "^8.2.1",
102
107
  "vitest": "^4.1.10",
103
- "webpack": "^5.109.0"
108
+ "webpack": "^5.109.2"
104
109
  },
105
110
  "peerDependencies": {
106
111
  "@rspack/core": "^2.0.0",