@brandboostinggmbh/observable-workflows 0.22.1 → 0.23.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/CHANGELOG.md +16 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,13 +15,28 @@ For NPM packages, changelogs are conventionally stored in a `CHANGELOG.md` file
|
|
|
15
15
|
- The changelog file is also visible in the GitHub repository for easy reference
|
|
16
16
|
|
|
17
17
|
## [Unreleased]
|
|
18
|
-
|
|
19
18
|
### 🚧 Work in Progress
|
|
20
19
|
|
|
21
20
|
Changes that will be included in the next release will be documented here.
|
|
22
21
|
|
|
23
22
|
---
|
|
24
23
|
|
|
24
|
+
## [v0.23.1] - 2026-05-22
|
|
25
|
+
### � Bug Fixes
|
|
26
|
+
|
|
27
|
+
- **`enqueueWorkflowBatch`: preserve per-workflow input when `(workflowType, initialName)` collide** — Previously, the queue message body's `input` was resolved via a content-based `workflows.find((w) => w.workflow.workflowType === p.workflowType && w.initialName === p.initialName)`, which returned the first match for every duplicate. When two or more workflows in the same batch shared both `workflowType` and `initialName`, all duplicates were enqueued with the **first** workflow's input even though their D1 rows and `instanceId`s were correctly distinct — causing silent data corruption in fan-out scenarios. Inputs are now carried through positionally on each prepared entry, which also eliminates a quadratic `find` lookup. Added regression test `tests/enqueue-batch-duplicate-name.test.ts`.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## [v0.23.0] - 2026-03-16
|
|
32
|
+
|
|
33
|
+
### ✨ Features
|
|
34
|
+
|
|
35
|
+
- `call()` and `retry()` now return a `WorkflowCallResult<O>` instead of `void`, containing `instanceId`, `workflowType`, `tenantId`, `result`, `workflowStatus`, `startTime`, `endTime`, `parentInstanceId`, and `triggerId`
|
|
36
|
+
- New exported type `WorkflowCallResult<O, TYPE>` built via `Pick` from `TypedWorkflowRun` with narrowed `workflowStatus: 'completed'` and non-null `result: O` / `endTime: number`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
25
40
|
## [v0.22.1] - 2026-02-19
|
|
26
41
|
|
|
27
42
|
### 📚 Documentation
|
package/dist/index.d.ts
CHANGED
|
@@ -671,8 +671,8 @@ type WorkflowContextOptions = {
|
|
|
671
671
|
};
|
|
672
672
|
type InternalWorkflowContextOptions = WorkflowContextOptions & Required<Pick<WorkflowContextOptions, 'serializer' | 'idFactory'>>;
|
|
673
673
|
type WorkflowContextInstance = {
|
|
674
|
-
call: <I, O>(args: WorkflowCallParams<I, O>) => Promise<
|
|
675
|
-
retry: <I, O>(params: RetryWorkflowParams<I, O>) => Promise<
|
|
674
|
+
call: <I, O>(args: WorkflowCallParams<I, O>) => Promise<WorkflowCallResult<O>>;
|
|
675
|
+
retry: <I, O>(params: RetryWorkflowParams<I, O>) => Promise<WorkflowCallResult<O>>;
|
|
676
676
|
};
|
|
677
677
|
type QueueWorkflowContextOptions = {
|
|
678
678
|
QUEUE: Queue<WorkflowQueueMessage>;
|
|
@@ -778,6 +778,11 @@ type WorkflowCallParams<I, O> = {
|
|
|
778
778
|
/** Optional: Provide an existing workflow instance ID. When provided, this workflow will update the existing instance. This is used when you have an workflow that is marked as waiting or scheduled and want to execute it. */
|
|
779
779
|
scheduledInstanceId?: string | undefined;
|
|
780
780
|
};
|
|
781
|
+
type WorkflowCallResult<O, TYPE extends string = string> = Pick<TypedWorkflowRun<never, O, TYPE>, 'instanceId' | 'workflowType' | 'tenantId' | 'parentInstanceId' | 'triggerId' | 'startTime'> & {
|
|
782
|
+
result: O;
|
|
783
|
+
workflowStatus: 'completed';
|
|
784
|
+
endTime: number;
|
|
785
|
+
};
|
|
781
786
|
type ScheduledWorkflowExecutionStub<O, TYPE extends string = string> = {
|
|
782
787
|
instanceId: string;
|
|
783
788
|
workflowType: TYPE;
|
|
@@ -983,4 +988,4 @@ type R2ExternalBlobStorageOptions = {
|
|
|
983
988
|
*/
|
|
984
989
|
declare function createR2ExternalBlobStorage(options: R2ExternalBlobStorageOptions): ExternalBlobStorage;
|
|
985
990
|
//#endregion
|
|
986
|
-
export { ConsoleWrapper, DateRangeFilter, ExternalBlobStorage, HandleWorkflowQueueMessageParams, InternalWorkflowContextOptions, Log, PossibleValueTypeNames, PossibleValueTypes, PropertyFilter, QueueWorkflowContextOptions, R2ExternalBlobStorageOptions, RetryConfig, Serializer, Step, StepContextOptions, StepCtx, StepWorkflowStatus, StringFilter, ValueTypeMap, WorkflowContext, WorkflowContextInstance, WorkflowContextOptions, WorkflowEnqueueBatchItem, WorkflowFilter, WorkflowFunction, WorkflowProperty, WorkflowPropertyDefinition, WorkflowQueueMessage, WorkflowRun, WorkflowStatus, createCleanupManager, createLogAccessor, createQueueWorkflowContext, createR2ExternalBlobStorage, createStepContext, createWorkflowContext, createWorkflowDependencies, createWorkflowDependency, defaultIdFactory, defaultSerializer, defineWorkflow, deleteWorkflowDependency, deserializeWithExternalStorage, ensureTables, finalizeWorkflowRecord, insertStepRecordFull, insertWorkflowRecord, pushLogToDB, retryD1Operation, serializeWithExternalStorage, tryDeserializeObj, updateWorkflow, updateWorkflowName, upsertWorkflowProperty, workflowTableRowToWorkflowRun };
|
|
991
|
+
export { ConsoleWrapper, DateRangeFilter, ExternalBlobStorage, HandleWorkflowQueueMessageParams, InternalWorkflowContextOptions, Log, PossibleValueTypeNames, PossibleValueTypes, PropertyFilter, QueueWorkflowContextOptions, R2ExternalBlobStorageOptions, RetryConfig, Serializer, Step, StepContextOptions, StepCtx, StepWorkflowStatus, StringFilter, ValueTypeMap, WorkflowCallResult, WorkflowContext, WorkflowContextInstance, WorkflowContextOptions, WorkflowEnqueueBatchItem, WorkflowFilter, WorkflowFunction, WorkflowProperty, WorkflowPropertyDefinition, WorkflowQueueMessage, WorkflowRun, WorkflowStatus, createCleanupManager, createLogAccessor, createQueueWorkflowContext, createR2ExternalBlobStorage, createStepContext, createWorkflowContext, createWorkflowDependencies, createWorkflowDependency, defaultIdFactory, defaultSerializer, defineWorkflow, deleteWorkflowDependency, deserializeWithExternalStorage, ensureTables, finalizeWorkflowRecord, insertStepRecordFull, insertWorkflowRecord, pushLogToDB, retryD1Operation, serializeWithExternalStorage, tryDeserializeObj, updateWorkflow, updateWorkflowName, upsertWorkflowProperty, workflowTableRowToWorkflowRun };
|
package/dist/index.js
CHANGED
|
@@ -1968,7 +1968,8 @@ function createQueueWorkflowContext(options) {
|
|
|
1968
1968
|
triggerId,
|
|
1969
1969
|
initialName,
|
|
1970
1970
|
shouldQueue: !hasDependencies,
|
|
1971
|
-
delaySeconds
|
|
1971
|
+
delaySeconds,
|
|
1972
|
+
input
|
|
1972
1973
|
};
|
|
1973
1974
|
}));
|
|
1974
1975
|
const workflowsWithDeps = preparedWorkflows.filter((p) => !p.shouldQueue).length;
|
|
@@ -1984,7 +1985,7 @@ function createQueueWorkflowContext(options) {
|
|
|
1984
1985
|
type: "workflow-run",
|
|
1985
1986
|
workflowType: p.workflowType,
|
|
1986
1987
|
workflowName: p.initialName,
|
|
1987
|
-
input:
|
|
1988
|
+
input: p.input,
|
|
1988
1989
|
tenantId: p.tenantId,
|
|
1989
1990
|
triggerId: p.triggerId,
|
|
1990
1991
|
queueIdentifier: options.queueIdentifier,
|
|
@@ -2320,6 +2321,17 @@ function createWorkflowContext(options) {
|
|
|
2320
2321
|
result
|
|
2321
2322
|
});
|
|
2322
2323
|
await logBatcher.destroy();
|
|
2324
|
+
return {
|
|
2325
|
+
instanceId,
|
|
2326
|
+
workflowType: workflow.workflowType,
|
|
2327
|
+
tenantId,
|
|
2328
|
+
parentInstanceId: parentInstanceId ?? null,
|
|
2329
|
+
triggerId: triggerId ?? null,
|
|
2330
|
+
startTime,
|
|
2331
|
+
result,
|
|
2332
|
+
workflowStatus,
|
|
2333
|
+
endTime
|
|
2334
|
+
};
|
|
2323
2335
|
} catch (error) {
|
|
2324
2336
|
const endTime = Date.now();
|
|
2325
2337
|
const workflowStatus = "failed";
|
|
@@ -2345,7 +2357,7 @@ function createWorkflowContext(options) {
|
|
|
2345
2357
|
const encodedInput = oldRun?.input;
|
|
2346
2358
|
if (inputRef === void 0 || encodedInput === void 0) throw new Error(`No input found for instanceId ${retryInstanceId}`);
|
|
2347
2359
|
const input = await deserializeWithExternalStorage(encodedInput, inputRef, internalContext.serializer, options.externalBlobStorage);
|
|
2348
|
-
await call({
|
|
2360
|
+
return await call({
|
|
2349
2361
|
workflow,
|
|
2350
2362
|
input,
|
|
2351
2363
|
workflowName: oldWorkflowName ?? "unknown",
|