@nagi-js/core 0.1.1-rc.16 → 0.1.1-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +73 -2
- package/dist/index.js +428 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -291,7 +291,6 @@ interface StepConfigBase<Input, N extends NeedsMap> {
|
|
|
291
291
|
readonly input: NoInfer<Input>;
|
|
292
292
|
readonly needs: NoInfer<ResolvedNeeds<N>>;
|
|
293
293
|
}) => boolean;
|
|
294
|
-
readonly timeoutMs?: Millis;
|
|
295
294
|
}
|
|
296
295
|
interface StepLifecycleHooks<Output> {
|
|
297
296
|
readonly onStart?: (event: StepStartEvent) => void | Promise<void>;
|
|
@@ -328,6 +327,7 @@ interface StreamingTaskConfig<Input, N extends NeedsMap, Output, Chunk> extends
|
|
|
328
327
|
interface SignalConfig<Input, N extends NeedsMap, Schema extends StandardSchemaV1> extends StepConfigBase<Input, N> {
|
|
329
328
|
readonly schema: Schema;
|
|
330
329
|
readonly names?: readonly [string, ...string[]];
|
|
330
|
+
readonly timeoutMs: Millis | "unbounded";
|
|
331
331
|
}
|
|
332
332
|
interface MatchArmGuard<Input, N extends NeedsMap, M extends StepMap> {
|
|
333
333
|
readonly when: (args: {
|
|
@@ -482,7 +482,17 @@ interface WorkerConfig {
|
|
|
482
482
|
readonly concurrency?: number;
|
|
483
483
|
readonly pollIntervalMs?: Millis;
|
|
484
484
|
readonly signal?: AbortSignal;
|
|
485
|
+
readonly timerSweepIntervalMs?: Millis;
|
|
486
|
+
readonly snapshotGonePolicy?: SnapshotGonePolicy;
|
|
487
|
+
readonly maxConcurrencyPerFlow?: number;
|
|
485
488
|
}
|
|
489
|
+
type SnapshotGoneDisposition = {
|
|
490
|
+
readonly action: "retry";
|
|
491
|
+
readonly delayMs: Millis;
|
|
492
|
+
} | {
|
|
493
|
+
readonly action: "fail";
|
|
494
|
+
};
|
|
495
|
+
type SnapshotGonePolicy = (readCount: number) => SnapshotGoneDisposition;
|
|
486
496
|
interface WorkerRunOnceOpts {
|
|
487
497
|
readonly maxSteps?: number;
|
|
488
498
|
}
|
|
@@ -516,6 +526,12 @@ type SettleSignalResult = {
|
|
|
516
526
|
} | {
|
|
517
527
|
readonly tag: "noop";
|
|
518
528
|
};
|
|
529
|
+
interface TimedOutSignal {
|
|
530
|
+
readonly runId: RunId$1;
|
|
531
|
+
readonly stepId: StepId;
|
|
532
|
+
readonly attempt: AttemptNumber;
|
|
533
|
+
readonly fireAt: Date;
|
|
534
|
+
}
|
|
519
535
|
interface Store {
|
|
520
536
|
appendFact(runId: RunId$1, fact: Fact): Promise<void>;
|
|
521
537
|
loadRunState(runId: RunId$1): Promise<RunState>;
|
|
@@ -555,6 +571,11 @@ interface Store {
|
|
|
555
571
|
readonly queue: Queue;
|
|
556
572
|
readonly limit?: number;
|
|
557
573
|
}): Promise<readonly ReapedLease[]>;
|
|
574
|
+
upsertTimer(runId: RunId$1, stepId: StepId, fireAt: Date): Promise<void>;
|
|
575
|
+
sweepSignalTimeouts(args: {
|
|
576
|
+
readonly now: Date;
|
|
577
|
+
readonly limit?: number;
|
|
578
|
+
}): Promise<readonly TimedOutSignal[]>;
|
|
558
579
|
settleStep(runId: RunId$1, stepId: StepId, fact: StepCompletedFact | StepFailedFact): Promise<void>;
|
|
559
580
|
recordOnce(runId: RunId$1, stepId: StepId, scope: string, value: Json): Promise<void>;
|
|
560
581
|
getOnce(runId: RunId$1, stepId: StepId, scope: string): Promise<Json | null>;
|
|
@@ -630,6 +651,8 @@ interface QueueMessage {
|
|
|
630
651
|
readonly stepId: StepId;
|
|
631
652
|
readonly payload: Json;
|
|
632
653
|
readonly attempt: AttemptNumber;
|
|
654
|
+
readonly readCount: number;
|
|
655
|
+
readonly flowId?: string;
|
|
633
656
|
}
|
|
634
657
|
interface QueueDequeueOpts {
|
|
635
658
|
readonly count: number;
|
|
@@ -638,6 +661,13 @@ interface QueueEnqueueOpts {
|
|
|
638
661
|
readonly attempt?: AttemptNumber;
|
|
639
662
|
readonly delayMs?: Millis;
|
|
640
663
|
readonly payload?: Json;
|
|
664
|
+
readonly flowId?: string;
|
|
665
|
+
}
|
|
666
|
+
interface QueueInspectEntry {
|
|
667
|
+
readonly stepId: StepId;
|
|
668
|
+
readonly attempt: AttemptNumber;
|
|
669
|
+
readonly readCount: number;
|
|
670
|
+
readonly visibleAt: Date;
|
|
641
671
|
}
|
|
642
672
|
interface Queue {
|
|
643
673
|
enqueue(runId: RunId$1, stepId: StepId, opts?: QueueEnqueueOpts): Promise<void>;
|
|
@@ -648,6 +678,7 @@ interface Queue {
|
|
|
648
678
|
}): Promise<void>;
|
|
649
679
|
extend(receipt: string, leaseMs: Millis): Promise<void>;
|
|
650
680
|
ensureSchema?(): Promise<void>;
|
|
681
|
+
inspect?(runId: RunId$1): Promise<readonly QueueInspectEntry[]>;
|
|
651
682
|
}
|
|
652
683
|
interface Clock {
|
|
653
684
|
now(): Date;
|
|
@@ -884,6 +915,11 @@ declare class NagiValidationError extends Error {
|
|
|
884
915
|
declare class NagiRuntimeError extends Error {
|
|
885
916
|
constructor(message: string);
|
|
886
917
|
}
|
|
918
|
+
declare class NagiNonRetryableError extends Error {
|
|
919
|
+
constructor(message: string, opts?: {
|
|
920
|
+
readonly cause?: unknown;
|
|
921
|
+
});
|
|
922
|
+
}
|
|
887
923
|
declare class NagiCanceledError extends Error {
|
|
888
924
|
readonly runId: RunId$1;
|
|
889
925
|
readonly canceledByRunId: RunId$1;
|
|
@@ -894,6 +930,16 @@ declare class NagiCanceledError extends Error {
|
|
|
894
930
|
readonly concurrencyKey: string;
|
|
895
931
|
});
|
|
896
932
|
}
|
|
933
|
+
declare class NagiSignalTimeoutError extends Error {
|
|
934
|
+
readonly runId: RunId$1;
|
|
935
|
+
readonly stepId: string;
|
|
936
|
+
readonly fireAt: Date;
|
|
937
|
+
constructor({ runId, stepId, fireAt, }: {
|
|
938
|
+
readonly runId: RunId$1;
|
|
939
|
+
readonly stepId: string;
|
|
940
|
+
readonly fireAt: Date;
|
|
941
|
+
});
|
|
942
|
+
}
|
|
897
943
|
declare class NagiFlowSnapshotGoneError extends Error {
|
|
898
944
|
readonly runId: RunId$1;
|
|
899
945
|
readonly flowId: string;
|
|
@@ -939,9 +985,11 @@ declare class InMemoryStore implements Store, StreamTransport {
|
|
|
939
985
|
private readonly globalFacts;
|
|
940
986
|
private readonly activeByKey;
|
|
941
987
|
private readonly keyByActiveRun;
|
|
988
|
+
private readonly slotByRun;
|
|
942
989
|
private readonly childrenByParent;
|
|
943
990
|
private readonly summaries;
|
|
944
991
|
private readonly streamHub;
|
|
992
|
+
private readonly signalTimers;
|
|
945
993
|
private readonly leaseMs;
|
|
946
994
|
constructor(opts?: InMemoryStoreOpts);
|
|
947
995
|
appendFact(runId: RunId$1, fact: Fact): Promise<void>;
|
|
@@ -985,6 +1033,11 @@ declare class InMemoryStore implements Store, StreamTransport {
|
|
|
985
1033
|
readonly signalName?: string;
|
|
986
1034
|
};
|
|
987
1035
|
}): Promise<SettleSignalResult>;
|
|
1036
|
+
upsertTimer(runId: RunId$1, stepId: StepId, fireAt: Date): Promise<void>;
|
|
1037
|
+
sweepSignalTimeouts(args: {
|
|
1038
|
+
readonly now: Date;
|
|
1039
|
+
readonly limit?: number;
|
|
1040
|
+
}): Promise<readonly TimedOutSignal[]>;
|
|
988
1041
|
recordOnce(runId: RunId$1, stepId: StepId, scope: string, value: Json): Promise<void>;
|
|
989
1042
|
getOnce(runId: RunId$1, stepId: StepId, scope: string): Promise<Json | null>;
|
|
990
1043
|
runStep<T extends Json>(runId: RunId$1, _stepId: StepId, _attempt: AttemptNumber, body: (tx: Tx) => Promise<{
|
|
@@ -1028,6 +1081,7 @@ declare class InMemoryQueue implements Queue {
|
|
|
1028
1081
|
delayMs?: Millis;
|
|
1029
1082
|
}): Promise<void>;
|
|
1030
1083
|
extend(receipt: string, leaseMs: Millis): Promise<void>;
|
|
1084
|
+
inspect(runId: RunId$1): Promise<readonly QueueInspectEntry[]>;
|
|
1031
1085
|
}
|
|
1032
1086
|
interface InMemoryClockOpts {
|
|
1033
1087
|
readonly trigger?: InMemoryTrigger;
|
|
@@ -1066,6 +1120,7 @@ interface NagiConfig {
|
|
|
1066
1120
|
readonly codeVersion?: string;
|
|
1067
1121
|
readonly heartbeatIntervalMs?: Millis;
|
|
1068
1122
|
readonly heartbeatLeaseMs?: Millis;
|
|
1123
|
+
readonly leaseHoldWarnMs?: Millis;
|
|
1069
1124
|
readonly reaperIntervalMs?: Millis;
|
|
1070
1125
|
}
|
|
1071
1126
|
interface StartOpts {
|
|
@@ -1098,6 +1153,7 @@ interface Wf<TFlows extends ReadonlyArray<Flow> = ReadonlyArray<Flow>> {
|
|
|
1098
1153
|
replay(runId: RunId$1, opts?: ReplayOpts): Promise<void>;
|
|
1099
1154
|
queryRuns(opts?: QueryRunsOpts<FlowIdOf<TFlows>>): Promise<QueryRunsResult<FlowIdOf<TFlows>>>;
|
|
1100
1155
|
describe(runId: RunId$1): Promise<RunDescription>;
|
|
1156
|
+
inspectQueue(runId: RunId$1): Promise<readonly QueueInspectEntry[]>;
|
|
1101
1157
|
subscribe<C = Json>(runId: RunId$1, stepId: StepId, opts?: {
|
|
1102
1158
|
readonly replayBuffered?: boolean;
|
|
1103
1159
|
}): AsyncIterable<StreamEvent<C>>;
|
|
@@ -1145,6 +1201,19 @@ declare function decideSignal(args: {
|
|
|
1145
1201
|
readonly signalName?: string;
|
|
1146
1202
|
} | undefined;
|
|
1147
1203
|
}): SignalDecision;
|
|
1204
|
+
type TimeoutDecision = {
|
|
1205
|
+
readonly kind: "noop";
|
|
1206
|
+
} | {
|
|
1207
|
+
readonly kind: "fail";
|
|
1208
|
+
readonly attempt: AttemptNumber;
|
|
1209
|
+
readonly fact: StepFailedFact;
|
|
1210
|
+
};
|
|
1211
|
+
declare function decideTimeout(args: {
|
|
1212
|
+
readonly runState: RunState;
|
|
1213
|
+
readonly stepId: StepId;
|
|
1214
|
+
readonly fireAt: Date;
|
|
1215
|
+
readonly at: Date;
|
|
1216
|
+
}): TimeoutDecision;
|
|
1148
1217
|
|
|
1149
1218
|
declare class NagiAbortError extends Error {
|
|
1150
1219
|
readonly runId: RunId$1;
|
|
@@ -1152,4 +1221,6 @@ declare class NagiAbortError extends Error {
|
|
|
1152
1221
|
constructor(runId: RunId$1, kind: "run" | "step");
|
|
1153
1222
|
}
|
|
1154
1223
|
|
|
1155
|
-
|
|
1224
|
+
declare const defaultSnapshotGonePolicy: SnapshotGonePolicy;
|
|
1225
|
+
|
|
1226
|
+
export { type Anomaly, type AttemptNumber, type BackoffStrategy, type Builder, type CancelArgs, type CanonicalDag, type CanonicalMatchArm, type CanonicalRetryPolicy, type CanonicalSchema, type CanonicalStep, type ClaimToken, type Clock, type ConcurrencyMode, DEFAULT_REAPER_INTERVAL_MS, type Fact, type FactKind, type Flow, type FlowCanceledByConcurrencyFact, type FlowCanceledByOperatorFact, type FlowCanceledExplicitlyFact, type FlowCanceledFact, type FlowCompleteEvent, type FlowCompletedFact, type FlowConcurrency, type FlowConfig, type FlowErrorEvent, type FlowEvent, type FlowFailedFact, type FlowHooks, type FlowIdOf, type FlowInput, type FlowOutput, type FlowRefUpdatedFact, type FlowStartEvent, type FlowStartedFact, type GlobalFact, InMemoryClock, InMemoryQueue, InMemoryStore, InMemoryTrigger, type InferSchemaInput, type InferSchemaOutput, type Json, type LeaseReapedFact, type LogEntry, type LogLevel, type Logger, type MatchArm, type MatchArmGuard, type MatchArmOtherwise, type MatchArmOutput, type MatchArmSelectedFact, type MatchArmShape, type MatchGuardConfig, type Millis, NagiAbortError, NagiCanceledError, NagiConcurrencyConflictError, type NagiConfig, NagiFlowSnapshotGoneError, NagiNonRetryableError, type NagiRunConfig, NagiRuntimeError, NagiSignalTimeoutError, NagiSnapshotDriftError, NagiValidationError, type NeedRef, type NeedsMap, type NeedsOutputs, type OnceRecordedFact, type Operator, type OperatorAuditOpts, type Optional, type ParentLink, type ParentRef, type PrunableStatus, type PruneOpts, type PruneResult, type QueryRunsOpts, type QueryRunsResult, type QueryRunsWhere, type Queue, type QueueDequeueOpts, type QueueEnqueueOpts, type QueueInspectEntry, type QueueMessage, type ReapedLease, type ReaperDecision, type Register, type ReplayMode, type ReplayOpts, type Resolved, type ResolvedConcurrency, type ResolvedNeeds, type RetryPolicy, type RunCancelCause, type RunDescription, RunId, type RunPhase, type RunState, type RunStatus, type RunSummary, type RunView, type RuntimeHandle, type SerializedError, type SettleSignalResult, type SignalBufferedFact, type SignalConfig, type SignalDecision, type SignalReceivedEvent, type SignalReceivedFact, type SignalSentEvent, type SignalSentFact, type SkipReason, type SnapshotChangedEdge, type SnapshotChangedField, type SnapshotDiff, type SnapshotGoneDisposition, type SnapshotGonePolicy, StandardSchemaV1, type StartOpts, type StartStagedOpts, type StartStagedResult, type Step, type StepAbortRequestedFact, type StepCancelCause, type StepCanceledFact, type StepCompleteEvent, type StepCompletedFact, type StepCtx, type StepErrorEvent, type StepEvent, type StepFailedFact, type StepId, type StepKind, type StepMap, type StepOutput, type StepResetFact, type StepRetriedFact, type StepRetryEvent, type StepRunStatus, type StepSkippedFact, type StepStartEvent, type StepStartedFact, type StepState, type StepStatus, type StepView, type Store, type StreamEvent, type StreamTransport, type StreamingStepCtx, type StreamingTaskConfig, type StringKeyOf, type SubflowConfig, type SubflowStepOutput, type TaskConfig, type TimedOutSignal, type TimeoutDecision, type Trigger, type Tx, type Wf, type Worker, type WorkerConfig, type WorkerRunOnceOpts, type WorkerRunResult, type WorkerRunUntilEmptyOpts, attemptOf, canonicalize, decideExpiredLeaseAction, decideSignal, decideTimeout, defaultSnapshotGonePolicy, diffSnapshots, errorOf, fingerprintFlows, flow, isStepTerminal, isTerminalRun, nagi, optional, outputOf, foldRun as projectRunState, resolvedOf, runStatusOf, sha256Canonical, stepStateOf, stepStatusOf, unwrap };
|