@superdurable/dex 0.1.2 → 0.1.4
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/README.md +82 -3
- package/dist/src/attribute-store-sync.d.ts +5 -0
- package/dist/src/attribute-store-sync.js +19 -0
- package/dist/src/attribute-store-sync.js.map +1 -0
- package/dist/src/blob-cache.d.ts +36 -0
- package/dist/src/blob-cache.js +13 -0
- package/dist/src/blob-cache.js.map +1 -1
- package/dist/src/client.d.ts +186 -5
- package/dist/src/client.js +174 -33
- package/dist/src/client.js.map +1 -1
- package/dist/src/codec.d.ts +73 -0
- package/dist/src/codec.js +23 -0
- package/dist/src/codec.js.map +1 -1
- package/dist/src/context.d.ts +80 -0
- package/dist/src/errors.d.ts +122 -6
- package/dist/src/errors.js +139 -9
- package/dist/src/errors.js.map +1 -1
- package/dist/src/flow.d.ts +36 -1
- package/dist/src/flow.js +96 -28
- package/dist/src/flow.js.map +1 -1
- package/dist/src/gen/dex.d.ts +58 -9
- package/dist/src/gen/dex.js +417 -55
- package/dist/src/gen/dex.js.map +1 -1
- package/dist/src/grpc-status.d.ts +5 -4
- package/dist/src/grpc-status.js +52 -6
- package/dist/src/grpc-status.js.map +1 -1
- package/dist/src/invocation-context.js +3 -0
- package/dist/src/invocation-context.js.map +1 -1
- package/dist/src/options.d.ts +162 -0
- package/dist/src/options.js +53 -0
- package/dist/src/options.js.map +1 -1
- package/dist/src/persistence.d.ts +103 -0
- package/dist/src/persistence.js +98 -0
- package/dist/src/persistence.js.map +1 -1
- package/dist/src/rpc.d.ts +58 -5
- package/dist/src/rpc.js +17 -0
- package/dist/src/rpc.js.map +1 -1
- package/dist/src/step.d.ts +164 -2
- package/dist/src/step.js +85 -0
- package/dist/src/step.js.map +1 -1
- package/dist/src/value-mapper.d.ts +1 -0
- package/dist/src/value-mapper.js +75 -14
- package/dist/src/value-mapper.js.map +1 -1
- package/dist/src/wait.d.ts +180 -0
- package/dist/src/wait.js +157 -0
- package/dist/src/wait.js.map +1 -1
- package/dist/src/worker-dispatcher.js +55 -29
- package/dist/src/worker-dispatcher.js.map +1 -1
- package/dist/src/worker.d.ts +30 -1
- package/dist/src/worker.js +48 -2
- package/dist/src/worker.js.map +1 -1
- package/native/linux-aarch64/dex_blob_cache_node.node +0 -0
- package/native/linux-x86_64/dex_blob_cache_node.node +0 -0
- package/native/macos-aarch64/dex_blob_cache_node.node +0 -0
- package/native/macos-x86_64/dex_blob_cache_node.node +0 -0
- package/native/windows-x86_64/dex_blob_cache_node.node +0 -0
- package/package.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ServiceError } from "@grpc/grpc-js";
|
|
2
|
-
import {
|
|
3
|
-
export declare function workerServiceError(failure: unknown):
|
|
4
|
-
export
|
|
1
|
+
import { type ServiceError as GrpcServiceError } from "@grpc/grpc-js";
|
|
2
|
+
import { DexServiceError } from "./errors.js";
|
|
3
|
+
export declare function workerServiceError(failure: unknown): GrpcServiceError;
|
|
4
|
+
export type FlowTargetRequirement = "none" | "existing" | "active";
|
|
5
|
+
export declare function translateServiceError(error: GrpcServiceError, operation: string, flowId: string | undefined, requirement: FlowTargetRequirement): DexServiceError;
|
package/dist/src/grpc-status.js
CHANGED
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
9
|
import { Metadata, status } from "@grpc/grpc-js";
|
|
10
10
|
import { ErrorResponse, ErrorSubStatus as ProtoErrorSubStatus, WorkerErrorResponse, } from "./gen/dex.js";
|
|
11
|
-
import {
|
|
11
|
+
import { DexServiceError, ErrorSubStatus, FlowAlreadyStartedError, FlowNotActiveError, FlowNotFoundError, LongPollTimeoutError, RpcLockConflictError, WorkerInvocationError, } from "./errors.js";
|
|
12
12
|
const statusDetailsKey = "grpc-status-details-bin";
|
|
13
13
|
export function workerServiceError(failure) {
|
|
14
14
|
const cause = failure instanceof Error ? failure : new Error(String(failure));
|
|
15
15
|
const detail = cause.message || cause.name;
|
|
16
|
-
const worker = WorkerErrorResponse.encode({
|
|
16
|
+
const worker = WorkerErrorResponse.encode({
|
|
17
|
+
detail,
|
|
18
|
+
errorType: cause.name,
|
|
19
|
+
stackTrace: cause.stack ?? "",
|
|
20
|
+
}).finish();
|
|
17
21
|
const metadata = new Metadata();
|
|
18
22
|
metadata.set(statusDetailsKey, Buffer.from(encodeStatus(status.UNKNOWN, detail, [
|
|
19
23
|
{ typeUrl: "type.googleapis.com/dex.WorkerErrorResponse", value: worker },
|
|
@@ -24,10 +28,45 @@ export function workerServiceError(failure) {
|
|
|
24
28
|
metadata,
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
|
-
export function translateServiceError(error) {
|
|
28
|
-
|
|
31
|
+
export function translateServiceError(error, operation, flowId, requirement) {
|
|
32
|
+
let response;
|
|
33
|
+
try {
|
|
34
|
+
response = errorResponse(error);
|
|
35
|
+
}
|
|
36
|
+
catch (failure) {
|
|
37
|
+
return new DexServiceError(error.code, ErrorSubStatus.UNCATEGORIZED, `Dex returned malformed error details: ${failure instanceof Error ? failure.message : String(failure)}`, operation, flowId, { cause: error });
|
|
38
|
+
}
|
|
29
39
|
const detail = response?.detail || error.details || error.message;
|
|
30
|
-
|
|
40
|
+
const subStatus = response === undefined ? ErrorSubStatus.UNCATEGORIZED : mapSubStatus(response.subStatus);
|
|
41
|
+
const parameters = [
|
|
42
|
+
error.code,
|
|
43
|
+
subStatus,
|
|
44
|
+
detail,
|
|
45
|
+
operation,
|
|
46
|
+
flowId,
|
|
47
|
+
{ cause: error },
|
|
48
|
+
];
|
|
49
|
+
switch (subStatus) {
|
|
50
|
+
case ErrorSubStatus.FLOW_ALREADY_STARTED:
|
|
51
|
+
return new FlowAlreadyStartedError(...parameters);
|
|
52
|
+
case ErrorSubStatus.FLOW_NOT_EXISTS:
|
|
53
|
+
if (requirement === "existing") {
|
|
54
|
+
return new FlowNotFoundError(...parameters);
|
|
55
|
+
}
|
|
56
|
+
if (requirement === "active") {
|
|
57
|
+
return new FlowNotActiveError(...parameters);
|
|
58
|
+
}
|
|
59
|
+
return new DexServiceError(...parameters);
|
|
60
|
+
case ErrorSubStatus.WORKER_API_ERROR:
|
|
61
|
+
if (error.code === status.ABORTED) {
|
|
62
|
+
return new RpcLockConflictError(...parameters);
|
|
63
|
+
}
|
|
64
|
+
return new WorkerInvocationError(error.code, subStatus, detail, operation, flowId, workerCode(response), response?.originalWorkerErrorType ?? "", response?.originalWorkerErrorDetail ?? "", { cause: error });
|
|
65
|
+
case ErrorSubStatus.LONG_POLL_TIMEOUT:
|
|
66
|
+
return new LongPollTimeoutError(...parameters);
|
|
67
|
+
default:
|
|
68
|
+
return new DexServiceError(...parameters);
|
|
69
|
+
}
|
|
31
70
|
}
|
|
32
71
|
function errorResponse(error) {
|
|
33
72
|
const encoded = error.metadata.get(statusDetailsKey)[0];
|
|
@@ -38,6 +77,13 @@ function errorResponse(error) {
|
|
|
38
77
|
const detail = decoded.details.find((candidate) => candidate.typeUrl.endsWith("/dex.ErrorResponse"));
|
|
39
78
|
return detail === undefined ? undefined : ErrorResponse.decode(detail.value);
|
|
40
79
|
}
|
|
80
|
+
function workerCode(response) {
|
|
81
|
+
if (response === undefined || response.originalWorkerErrorStatus === 0) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const code = response.originalWorkerErrorStatus;
|
|
85
|
+
return Object.values(status).includes(code) ? code : status.UNKNOWN;
|
|
86
|
+
}
|
|
41
87
|
function mapSubStatus(value) {
|
|
42
88
|
switch (value) {
|
|
43
89
|
case ProtoErrorSubStatus.ERROR_SUB_STATUS_UNCATEGORIZED:
|
|
@@ -51,7 +97,7 @@ function mapSubStatus(value) {
|
|
|
51
97
|
case ProtoErrorSubStatus.ERROR_SUB_STATUS_LONG_POLL_TIME_OUT:
|
|
52
98
|
return ErrorSubStatus.LONG_POLL_TIMEOUT;
|
|
53
99
|
default:
|
|
54
|
-
return
|
|
100
|
+
return ErrorSubStatus.UNCATEGORIZED;
|
|
55
101
|
}
|
|
56
102
|
}
|
|
57
103
|
function encodeStatus(code, message, details) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-status.js","sourceRoot":"","sources":["../../src/grpc-status.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAExD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"grpc-status.js","sourceRoot":"","sources":["../../src/grpc-status.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAExD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAyC,MAAM,eAAe,CAAC;AAExF,OAAO,EACL,aAAa,EACb,cAAc,IAAI,mBAAmB,EACrC,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GAEtB,MAAM,aAAa,CAAC;AAErB,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAOnD,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,KAAK,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC;IAC3C,MAAM,MAAM,GAAG,mBAAmB,CAAC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AAC,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,SAAS,CAAC,MAAoB,EAAE,MAAc;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC;IAChC,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,KAAK,GAAgC,IAAI,UAAU,EAAE,CAAC;IAC1D,OAAO,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC5B,CAAC;aAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// See the LICENSE file in the repository root.
|
|
6
6
|
//
|
|
7
7
|
// SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
|
|
8
|
+
import { mapAttributeStoreSync } from "./attribute-store-sync.js";
|
|
8
9
|
import { ConditionStatus, IndexType as ProtoIndexType, } from "./gen/dex.js";
|
|
9
10
|
import { AttributeMap, IndexType } from "./persistence.js";
|
|
10
11
|
import { decodeValue, deletionValue, encodeValue } from "./value-mapper.js";
|
|
@@ -91,6 +92,7 @@ export class InvocationContext {
|
|
|
91
92
|
key,
|
|
92
93
|
value: encodeValue(attribute.codec, value),
|
|
93
94
|
indexConfig: mapIndex(attribute.index),
|
|
95
|
+
syncConfig: mapAttributeStoreSync(attribute),
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
deleteAttribute(attribute, instance) {
|
|
@@ -100,6 +102,7 @@ export class InvocationContext {
|
|
|
100
102
|
key,
|
|
101
103
|
value: deletionValue(),
|
|
102
104
|
indexConfig: mapIndex(attribute.index),
|
|
105
|
+
syncConfig: mapAttributeStoreSync(attribute),
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
108
|
publish(channel, value, instance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invocation-context.js","sourceRoot":"","sources":["../../src/invocation-context.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;
|
|
1
|
+
{"version":3,"file":"invocation-context.js","sourceRoot":"","sources":["../../src/invocation-context.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EACL,eAAe,EACf,SAAS,IAAI,cAAc,GAS5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAgB,MAAM,WAAW,CAAC;AAIrD,MAAM,OAAO,iBA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IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,UAAU,CAAC,wDAAwD,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC"}
|
package/dist/src/options.d.ts
CHANGED
|
@@ -1,106 +1,268 @@
|
|
|
1
1
|
import type { Attribute, AttributeMap } from "./persistence.js";
|
|
2
2
|
import type { RetryPolicy, StepDurability } from "./step.js";
|
|
3
|
+
/** Configures FlowService connectivity and default Flow routing. */
|
|
3
4
|
export interface ClientOptions {
|
|
5
|
+
/** Plaintext Dex gRPC target; defaults to `localhost:8801`. */
|
|
4
6
|
readonly serverAddress?: string;
|
|
7
|
+
/** Worker endpoint advertised by `startFlow` unless a Flow overrides it. */
|
|
5
8
|
readonly workerTarget?: WorkerTarget;
|
|
6
9
|
}
|
|
10
|
+
/** Controls which active Steps are included in Flow search indexing. */
|
|
7
11
|
export declare const ActiveStepSearchMode: Readonly<{
|
|
12
|
+
/** Uses the Dex server's current default policy. */
|
|
8
13
|
readonly DEFAULT: "default";
|
|
14
|
+
/** Indexes every active Step. */
|
|
9
15
|
readonly ALL: "all";
|
|
10
16
|
}>;
|
|
17
|
+
/** Represents a value from {@link ActiveStepSearchMode}. */
|
|
11
18
|
export type ActiveStepSearchMode = (typeof ActiveStepSearchMode)[keyof typeof ActiveStepSearchMode];
|
|
19
|
+
/** Controls whether `startFlow` may reuse a previously used Flow ID. */
|
|
12
20
|
export declare const IdReusePolicy: Readonly<{
|
|
21
|
+
/** Uses the Dex server's default reuse policy. */
|
|
13
22
|
readonly DEFAULT: "default";
|
|
23
|
+
/** Reuses an ID only after an unsuccessful closed run. */
|
|
14
24
|
readonly ALLOW_IF_PREVIOUS_FAILED: "allowIfPreviousFailed";
|
|
25
|
+
/** Reuses an ID after any closed run. */
|
|
15
26
|
readonly ALLOW_IF_NOT_RUNNING: "allowIfNotRunning";
|
|
27
|
+
/** Terminates an active run before starting the replacement. */
|
|
16
28
|
readonly ALLOW_TERMINATE_IF_RUNNING: "allowTerminateIfRunning";
|
|
29
|
+
/** Rejects every previously used Flow ID. */
|
|
17
30
|
readonly DISALLOW: "disallow";
|
|
18
31
|
}>;
|
|
32
|
+
/** Represents a value from {@link IdReusePolicy}. */
|
|
19
33
|
export type IdReusePolicy = (typeof IdReusePolicy)[keyof typeof IdReusePolicy];
|
|
34
|
+
/** Overrides mutable server behavior for one Flow execution. */
|
|
20
35
|
export interface FlowConfig {
|
|
36
|
+
/** Optional active-Step visibility indexing policy. */
|
|
21
37
|
readonly activeStepSearchMode?: ActiveStepSearchMode;
|
|
38
|
+
/**
|
|
39
|
+
* Selects the server-configured Attribute Store receiving opted-in Attribute writes.
|
|
40
|
+
*
|
|
41
|
+
* Omit this property to preserve the existing Flow setting. An explicit empty string is sent with
|
|
42
|
+
* presence and disables later synchronization. Projection is asynchronous and never rolls back Flow
|
|
43
|
+
* Attribute writes when the external store update fails.
|
|
44
|
+
*/
|
|
45
|
+
readonly attributeStoreName?: string;
|
|
46
|
+
/** Positive history-event threshold requesting continue-as-new. */
|
|
22
47
|
readonly continueAsNewThreshold?: number;
|
|
48
|
+
/** Positive history page-size budget in bytes for continue-as-new. */
|
|
23
49
|
readonly continueAsNewPageSizeBytes?: number;
|
|
50
|
+
/** Default durability for later Step handler results. */
|
|
24
51
|
readonly stepDurability?: StepDurability;
|
|
52
|
+
/** Worker endpoint used for later handler calls. */
|
|
25
53
|
readonly workerTarget?: WorkerTarget;
|
|
26
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Describes one Attribute value written atomically when a Flow starts.
|
|
57
|
+
* @typeParam T - Attribute value type.
|
|
58
|
+
*/
|
|
27
59
|
export interface InitialAttribute<T> {
|
|
60
|
+
/** Registered singleton Attribute or AttributeMap definition. */
|
|
28
61
|
readonly attribute: Attribute<T> | AttributeMap<T>;
|
|
62
|
+
/** Required non-empty map key; omitted for a singleton Attribute. */
|
|
29
63
|
readonly instance?: string;
|
|
64
|
+
/** Typed initial value. */
|
|
30
65
|
readonly value: T;
|
|
31
66
|
}
|
|
67
|
+
/** Creates type-safe initial Attribute writes for {@link StartFlowOptions}. */
|
|
32
68
|
export declare const InitialAttribute: Readonly<{
|
|
69
|
+
/**
|
|
70
|
+
* Creates a singleton Attribute initialization.
|
|
71
|
+
* @typeParam T - Attribute value type.
|
|
72
|
+
* @param attribute - Registered singleton Attribute.
|
|
73
|
+
* @param value - Typed initial value.
|
|
74
|
+
* @returns The Attribute initialization value.
|
|
75
|
+
*/
|
|
33
76
|
of<T>(attribute: Attribute<T>, value: T): InitialAttribute<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Creates an AttributeMap instance initialization.
|
|
79
|
+
* @typeParam T - Attribute value type.
|
|
80
|
+
* @param attribute - Registered AttributeMap.
|
|
81
|
+
* @param instance - Non-empty logical map key.
|
|
82
|
+
* @param value - Typed initial value.
|
|
83
|
+
* @returns The AttributeMap initialization value.
|
|
84
|
+
*/
|
|
34
85
|
mapValue<T>(attribute: AttributeMap<T>, instance: string, value: T): InitialAttribute<T>;
|
|
35
86
|
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Configures creation of a new Flow execution. All durations use milliseconds.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const status = new Attribute("status", stringCodec);
|
|
93
|
+
* const options: StartFlowOptions = {
|
|
94
|
+
* timeoutMs: 30 * 60_000,
|
|
95
|
+
* idReusePolicy: IdReusePolicy.ALLOW_IF_NOT_RUNNING,
|
|
96
|
+
* attributes: [InitialAttribute.of(status, "queued")],
|
|
97
|
+
* configOverride: { activeStepSearchMode: ActiveStepSearchMode.ALL },
|
|
98
|
+
* };
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
36
101
|
export interface StartFlowOptions {
|
|
102
|
+
/** Maximum Flow lifetime in milliseconds; uses registered defaults when omitted. */
|
|
37
103
|
readonly timeoutMs?: number;
|
|
104
|
+
/** Delay before the starting Step becomes eligible, in milliseconds. */
|
|
38
105
|
readonly startDelayMs?: number;
|
|
106
|
+
/** Flow ID reuse policy; uses `DEFAULT` when omitted. */
|
|
39
107
|
readonly idReusePolicy?: IdReusePolicy;
|
|
108
|
+
/** Server-supported cron expression for recurring runs. */
|
|
40
109
|
readonly cronSchedule?: string;
|
|
110
|
+
/** Optional Flow-level retry policy. */
|
|
41
111
|
readonly retryPolicy?: RetryPolicy;
|
|
112
|
+
/** Initial Attribute writes applied atomically with Flow creation. */
|
|
42
113
|
readonly attributes?: readonly InitialAttribute<any>[];
|
|
114
|
+
/** Flow configuration applied over registered defaults. */
|
|
43
115
|
readonly configOverride?: FlowConfig;
|
|
116
|
+
/** Returns the existing run instead of raising an already-started error. */
|
|
44
117
|
readonly ignoreAlreadyStarted?: boolean;
|
|
118
|
+
/** Non-empty idempotency key; generates a UUID when omitted. */
|
|
45
119
|
readonly requestId?: string;
|
|
46
120
|
}
|
|
121
|
+
/** Describes the lifecycle state of one Flow run. */
|
|
47
122
|
export type FlowStatus = "running" | "completed" | "failed" | "cancelled" | "terminated" | "timedOut" | "continuedAsNew";
|
|
123
|
+
/** Summarizes the current or latest run for one Flow ID. */
|
|
48
124
|
export interface FlowInfo {
|
|
125
|
+
/** Stable application-assigned Flow ID. */
|
|
49
126
|
readonly flowId: string;
|
|
127
|
+
/** Server-assigned run ID. */
|
|
50
128
|
readonly runId: string;
|
|
129
|
+
/** Registered Flow type. */
|
|
51
130
|
readonly flowType: string;
|
|
131
|
+
/** Current lifecycle state. */
|
|
52
132
|
readonly status: FlowStatus;
|
|
133
|
+
/** UTC run start timestamp. */
|
|
53
134
|
readonly startedAt: Date;
|
|
54
135
|
}
|
|
136
|
+
/** Represents one indexed Flow run returned by `searchFlows`. */
|
|
137
|
+
export interface SearchFlowEntry {
|
|
138
|
+
/** Stable application-assigned Flow ID. */
|
|
139
|
+
readonly flowId: string;
|
|
140
|
+
/** Server-assigned run ID for this entry. */
|
|
141
|
+
readonly runId: string;
|
|
142
|
+
/** Registered Flow type. */
|
|
143
|
+
readonly flowType: string;
|
|
144
|
+
/** Indexed lifecycle state. */
|
|
145
|
+
readonly status: FlowStatus;
|
|
146
|
+
/** UTC start timestamp. */
|
|
147
|
+
readonly startedAt: Date;
|
|
148
|
+
/** UTC close timestamp, or `undefined` for open or unknown runs. */
|
|
149
|
+
readonly closedAt: Date | undefined;
|
|
150
|
+
/** Hydrated values keyed by physical search-index name. */
|
|
151
|
+
readonly indexedAttributes: ReadonlyMap<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
/** Contains one server-ordered page of Flow search results. */
|
|
154
|
+
export interface SearchFlowsPage {
|
|
155
|
+
/** Result entries in server-defined query order. */
|
|
156
|
+
readonly flows: readonly SearchFlowEntry[];
|
|
157
|
+
/** Opaque next-page token, or an empty string on the final page. */
|
|
158
|
+
readonly nextPageToken: string;
|
|
159
|
+
}
|
|
160
|
+
/** Identifies one numbered execution of a registered Step type. */
|
|
55
161
|
export interface StepExecutionId {
|
|
162
|
+
/** Registered Step type. */
|
|
56
163
|
readonly stepType: string;
|
|
164
|
+
/** Positive execution number; defaults to the first execution. */
|
|
57
165
|
readonly number?: number;
|
|
58
166
|
}
|
|
167
|
+
/** Creates normalized {@link StepExecutionId} values. */
|
|
59
168
|
export declare const StepExecutionId: Readonly<{
|
|
169
|
+
/**
|
|
170
|
+
* Creates a Step execution identifier.
|
|
171
|
+
* @param stepType - Non-empty registered Step type.
|
|
172
|
+
* @param number - Positive execution number; defaults to one.
|
|
173
|
+
* @returns The normalized identifier.
|
|
174
|
+
*/
|
|
60
175
|
of(stepType: string, number?: number): StepExecutionId;
|
|
61
176
|
}>;
|
|
177
|
+
/** Selects one Timer condition within a Step execution. */
|
|
62
178
|
export interface TimerId {
|
|
179
|
+
/** Stable condition ID, mutually exclusive with `conditionIndex`. */
|
|
63
180
|
readonly conditionId?: string;
|
|
181
|
+
/** Zero-based condition index, mutually exclusive with `conditionId`. */
|
|
64
182
|
readonly conditionIndex?: number;
|
|
65
183
|
}
|
|
184
|
+
/** Creates Timer selectors by stable ID or Wait-tree position. */
|
|
66
185
|
export declare const TimerId: Readonly<{
|
|
186
|
+
/**
|
|
187
|
+
* Selects a Timer by stable condition ID.
|
|
188
|
+
* @param conditionId - Non-empty ID assigned by `Timer.byDuration`.
|
|
189
|
+
* @returns An ID-based Timer selector.
|
|
190
|
+
*/
|
|
67
191
|
byConditionId(conditionId: string): TimerId;
|
|
192
|
+
/**
|
|
193
|
+
* Selects a Timer by zero-based Wait-tree position.
|
|
194
|
+
* @param conditionIndex - Non-negative flattened Timer index.
|
|
195
|
+
* @returns An index-based Timer selector.
|
|
196
|
+
*/
|
|
68
197
|
byConditionIndex(conditionIndex: number): TimerId;
|
|
69
198
|
}>;
|
|
199
|
+
/** Selects the history point from which a Flow reset resumes. */
|
|
70
200
|
export declare const ResetType: Readonly<{
|
|
201
|
+
/** Restarts from the beginning of the Flow. */
|
|
71
202
|
readonly BEGINNING: "beginning";
|
|
203
|
+
/** Resumes at a specific history event ID. */
|
|
72
204
|
readonly HISTORY_EVENT_ID: "historyEventId";
|
|
205
|
+
/** Resumes at the first event at or after a timestamp. */
|
|
73
206
|
readonly HISTORY_EVENT_TIME: "historyEventTime";
|
|
207
|
+
/** Resumes at the latest execution of a Step type. */
|
|
74
208
|
readonly STEP_TYPE: "stepType";
|
|
209
|
+
/** Resumes at one exact Step execution ID. */
|
|
75
210
|
readonly STEP_EXECUTION_ID: "stepExecutionId";
|
|
76
211
|
}>;
|
|
212
|
+
/** Represents a value from {@link ResetType}. */
|
|
77
213
|
export type ResetType = (typeof ResetType)[keyof typeof ResetType];
|
|
214
|
+
/** Configures creation of a new run from existing Flow history. */
|
|
78
215
|
export interface ResetFlowOptions {
|
|
216
|
+
/** Reset-point selector kind. */
|
|
79
217
|
readonly type: ResetType;
|
|
218
|
+
/** Event ID used with `HISTORY_EVENT_ID`. */
|
|
80
219
|
readonly historyEventId?: bigint;
|
|
220
|
+
/** Timestamp used with `HISTORY_EVENT_TIME`. */
|
|
81
221
|
readonly historyEventTime?: Date;
|
|
222
|
+
/** Registered Step type used with `STEP_TYPE`. */
|
|
82
223
|
readonly stepType?: string;
|
|
224
|
+
/** Exact execution ID used with `STEP_EXECUTION_ID`. */
|
|
83
225
|
readonly stepExecutionId?: string;
|
|
226
|
+
/** Optional operator-readable reset reason. */
|
|
84
227
|
readonly reason?: string;
|
|
228
|
+
/** Prevents reapplication of Channel messages after the reset point. */
|
|
85
229
|
readonly skipChannelMessagesReapply?: boolean;
|
|
230
|
+
/** Prevents reapplication of locking RPC effects after the reset point. */
|
|
86
231
|
readonly skipLockingRpcReapply?: boolean;
|
|
87
232
|
}
|
|
233
|
+
/** Selects how an active Flow should close. */
|
|
88
234
|
export declare const StopType: Readonly<{
|
|
235
|
+
/** Requests cooperative cancellation. */
|
|
89
236
|
readonly CANCEL: "cancel";
|
|
237
|
+
/** Forces immediate termination. */
|
|
90
238
|
readonly TERMINATE: "terminate";
|
|
239
|
+
/** Closes the Flow as failed. */
|
|
91
240
|
readonly FAIL: "fail";
|
|
92
241
|
}>;
|
|
242
|
+
/** Represents a value from {@link StopType}. */
|
|
93
243
|
export type StopType = (typeof StopType)[keyof typeof StopType];
|
|
244
|
+
/** Configures a `stopFlow` request. */
|
|
94
245
|
export interface StopFlowOptions {
|
|
246
|
+
/** Stop behavior; defaults to cooperative cancellation. */
|
|
95
247
|
readonly type?: StopType;
|
|
248
|
+
/** Optional operator-readable reason recorded by Dex. */
|
|
96
249
|
readonly reason?: string;
|
|
97
250
|
}
|
|
251
|
+
/** Configures Worker networking and startup synchronization. */
|
|
98
252
|
export interface WorkerOptions {
|
|
253
|
+
/** Local plaintext WorkerService listener; defaults to `:8803`. */
|
|
99
254
|
readonly bindAddress?: string;
|
|
255
|
+
/** Endpoint advertised to Dex; derived from `bindAddress` when omitted. */
|
|
100
256
|
readonly workerTarget?: WorkerTarget;
|
|
257
|
+
/** Dex FlowService target; defaults to `localhost:8801`. */
|
|
101
258
|
readonly serverAddress?: string;
|
|
259
|
+
/** Startup Indexed Attribute synchronization deadline in milliseconds. Defaults to 120000. */
|
|
260
|
+
readonly attributeIndexSyncTimeoutMs?: number;
|
|
102
261
|
}
|
|
262
|
+
/** Identifies the application Worker endpoint advertised to Dex. */
|
|
103
263
|
export interface WorkerTarget {
|
|
264
|
+
/** Plaintext gRPC target; headless targets must use `host:port`. */
|
|
104
265
|
readonly address: string;
|
|
266
|
+
/** Whether Dex connects directly without service discovery. */
|
|
105
267
|
readonly headless?: boolean;
|
|
106
268
|
}
|
package/dist/src/options.js
CHANGED
|
@@ -6,50 +6,103 @@
|
|
|
6
6
|
//
|
|
7
7
|
// SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
|
|
8
8
|
import { requireName } from "./validation.js";
|
|
9
|
+
/** Controls which active Steps are included in Flow search indexing. */
|
|
9
10
|
export const ActiveStepSearchMode = Object.freeze({
|
|
11
|
+
/** Uses the Dex server's current default policy. */
|
|
10
12
|
DEFAULT: "default",
|
|
13
|
+
/** Indexes every active Step. */
|
|
11
14
|
ALL: "all",
|
|
12
15
|
});
|
|
16
|
+
/** Controls whether `startFlow` may reuse a previously used Flow ID. */
|
|
13
17
|
export const IdReusePolicy = Object.freeze({
|
|
18
|
+
/** Uses the Dex server's default reuse policy. */
|
|
14
19
|
DEFAULT: "default",
|
|
20
|
+
/** Reuses an ID only after an unsuccessful closed run. */
|
|
15
21
|
ALLOW_IF_PREVIOUS_FAILED: "allowIfPreviousFailed",
|
|
22
|
+
/** Reuses an ID after any closed run. */
|
|
16
23
|
ALLOW_IF_NOT_RUNNING: "allowIfNotRunning",
|
|
24
|
+
/** Terminates an active run before starting the replacement. */
|
|
17
25
|
ALLOW_TERMINATE_IF_RUNNING: "allowTerminateIfRunning",
|
|
26
|
+
/** Rejects every previously used Flow ID. */
|
|
18
27
|
DISALLOW: "disallow",
|
|
19
28
|
});
|
|
29
|
+
/** Creates type-safe initial Attribute writes for {@link StartFlowOptions}. */
|
|
20
30
|
export const InitialAttribute = Object.freeze({
|
|
31
|
+
/**
|
|
32
|
+
* Creates a singleton Attribute initialization.
|
|
33
|
+
* @typeParam T - Attribute value type.
|
|
34
|
+
* @param attribute - Registered singleton Attribute.
|
|
35
|
+
* @param value - Typed initial value.
|
|
36
|
+
* @returns The Attribute initialization value.
|
|
37
|
+
*/
|
|
21
38
|
of(attribute, value) {
|
|
22
39
|
return { attribute, value };
|
|
23
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* Creates an AttributeMap instance initialization.
|
|
43
|
+
* @typeParam T - Attribute value type.
|
|
44
|
+
* @param attribute - Registered AttributeMap.
|
|
45
|
+
* @param instance - Non-empty logical map key.
|
|
46
|
+
* @param value - Typed initial value.
|
|
47
|
+
* @returns The AttributeMap initialization value.
|
|
48
|
+
*/
|
|
24
49
|
mapValue(attribute, instance, value) {
|
|
25
50
|
requireName(instance);
|
|
26
51
|
return { attribute, instance, value };
|
|
27
52
|
},
|
|
28
53
|
});
|
|
54
|
+
/** Creates normalized {@link StepExecutionId} values. */
|
|
29
55
|
export const StepExecutionId = Object.freeze({
|
|
56
|
+
/**
|
|
57
|
+
* Creates a Step execution identifier.
|
|
58
|
+
* @param stepType - Non-empty registered Step type.
|
|
59
|
+
* @param number - Positive execution number; defaults to one.
|
|
60
|
+
* @returns The normalized identifier.
|
|
61
|
+
*/
|
|
30
62
|
of(stepType, number) {
|
|
31
63
|
return { stepType, number: number ?? 1 };
|
|
32
64
|
},
|
|
33
65
|
});
|
|
66
|
+
/** Creates Timer selectors by stable ID or Wait-tree position. */
|
|
34
67
|
export const TimerId = Object.freeze({
|
|
68
|
+
/**
|
|
69
|
+
* Selects a Timer by stable condition ID.
|
|
70
|
+
* @param conditionId - Non-empty ID assigned by `Timer.byDuration`.
|
|
71
|
+
* @returns An ID-based Timer selector.
|
|
72
|
+
*/
|
|
35
73
|
byConditionId(conditionId) {
|
|
36
74
|
requireName(conditionId);
|
|
37
75
|
return { conditionId };
|
|
38
76
|
},
|
|
77
|
+
/**
|
|
78
|
+
* Selects a Timer by zero-based Wait-tree position.
|
|
79
|
+
* @param conditionIndex - Non-negative flattened Timer index.
|
|
80
|
+
* @returns An index-based Timer selector.
|
|
81
|
+
*/
|
|
39
82
|
byConditionIndex(conditionIndex) {
|
|
40
83
|
return { conditionIndex };
|
|
41
84
|
},
|
|
42
85
|
});
|
|
86
|
+
/** Selects the history point from which a Flow reset resumes. */
|
|
43
87
|
export const ResetType = Object.freeze({
|
|
88
|
+
/** Restarts from the beginning of the Flow. */
|
|
44
89
|
BEGINNING: "beginning",
|
|
90
|
+
/** Resumes at a specific history event ID. */
|
|
45
91
|
HISTORY_EVENT_ID: "historyEventId",
|
|
92
|
+
/** Resumes at the first event at or after a timestamp. */
|
|
46
93
|
HISTORY_EVENT_TIME: "historyEventTime",
|
|
94
|
+
/** Resumes at the latest execution of a Step type. */
|
|
47
95
|
STEP_TYPE: "stepType",
|
|
96
|
+
/** Resumes at one exact Step execution ID. */
|
|
48
97
|
STEP_EXECUTION_ID: "stepExecutionId",
|
|
49
98
|
});
|
|
99
|
+
/** Selects how an active Flow should close. */
|
|
50
100
|
export const StopType = Object.freeze({
|
|
101
|
+
/** Requests cooperative cancellation. */
|
|
51
102
|
CANCEL: "cancel",
|
|
103
|
+
/** Forces immediate termination. */
|
|
52
104
|
TERMINATE: "terminate",
|
|
105
|
+
/** Closes the Flow as failed. */
|
|
53
106
|
FAIL: "fail",
|
|
54
107
|
});
|
|
55
108
|
//# sourceMappingURL=options.js.map
|
package/dist/src/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uDAAuD;AACvD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AAIxD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,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