@oatscenter/trellis 0.100.0-rc.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/README.md +59 -0
- package/auth/authorization/client_context.d.ts +61 -0
- package/auth/authorization/client_context.js +266 -0
- package/auth/authorization/nats_registry.d.ts +41 -0
- package/auth/authorization/nats_registry.js +283 -0
- package/auth/authorization/provider_cache.d.ts +90 -0
- package/auth/authorization/provider_cache.js +783 -0
- package/auth/authorization/refresh.d.ts +46 -0
- package/auth/authorization/refresh.js +246 -0
- package/auth/authorization/types.d.ts +207 -0
- package/auth/authorization/types.js +60 -0
- package/auth/authorization_context.d.ts +11 -0
- package/auth/authorization_context.js +10 -0
- package/auth/browser/flow_types.d.ts +84 -0
- package/auth/browser/flow_types.js +70 -0
- package/auth/browser/portal.d.ts +21 -0
- package/auth/browser/portal.js +307 -0
- package/auth/browser/storage.d.ts +26 -0
- package/auth/browser/storage.js +224 -0
- package/auth/browser.d.ts +11 -0
- package/auth/browser.js +10 -0
- package/auth/browser_recovery.d.ts +13 -0
- package/auth/browser_recovery.js +38 -0
- package/auth/device_activation.d.ts +134 -0
- package/auth/device_activation.js +376 -0
- package/auth/http_error.d.ts +12 -0
- package/auth/http_error.js +32 -0
- package/auth/keys.d.ts +5 -0
- package/auth/keys.js +63 -0
- package/auth/mod.d.ts +16 -0
- package/auth/mod.js +16 -0
- package/auth/proof.d.ts +31 -0
- package/auth/proof.js +95 -0
- package/auth/protocol_wasm/trellis_protocol_wasm.d.ts +138 -0
- package/auth/protocol_wasm/trellis_protocol_wasm.js +605 -0
- package/auth/protocol_wasm/trellis_protocol_wasm_bg.wasm +0 -0
- package/auth/protocol_wasm/trellis_protocol_wasm_bytes.d.ts +1 -0
- package/auth/protocol_wasm/trellis_protocol_wasm_bytes.js +2 -0
- package/auth/protocol_wasm.d.ts +179 -0
- package/auth/protocol_wasm.js +133 -0
- package/auth/session_auth.d.ts +30 -0
- package/auth/session_auth.js +77 -0
- package/auth/session_proof.d.ts +53 -0
- package/auth/session_proof.js +43 -0
- package/auth/time.d.ts +6 -0
- package/auth/time.js +7 -0
- package/auth/trellis_id.d.ts +1 -0
- package/auth/trellis_id.js +5 -0
- package/auth/utils.d.ts +10 -0
- package/auth/utils.js +69 -0
- package/auth.d.ts +1 -0
- package/auth.js +1 -0
- package/caller.d.ts +111 -0
- package/caller.js +85 -0
- package/client.d.ts +14 -0
- package/client.js +1 -0
- package/client_connect.d.ts +143 -0
- package/client_connect.js +1097 -0
- package/codec.d.ts +13 -0
- package/codec.js +192 -0
- package/connection.d.ts +107 -0
- package/connection.js +396 -0
- package/device/activation.d.ts +42 -0
- package/device/activation.js +319 -0
- package/device.d.ts +80 -0
- package/device.js +687 -0
- package/env.d.ts +2 -0
- package/env.js +10 -0
- package/errors/AuthError.d.ts +30 -0
- package/errors/AuthError.js +34 -0
- package/errors/KVError.d.ts +30 -0
- package/errors/KVError.js +36 -0
- package/errors/OperationLifecycleError.d.ts +110 -0
- package/errors/OperationLifecycleError.js +142 -0
- package/errors/RemoteError.d.ts +61 -0
- package/errors/RemoteError.js +72 -0
- package/errors/SchemaValidationError.d.ts +48 -0
- package/errors/SchemaValidationError.js +49 -0
- package/errors/StoreError.d.ts +21 -0
- package/errors/StoreError.js +31 -0
- package/errors/TransferError.d.ts +21 -0
- package/errors/TransferError.js +31 -0
- package/errors/TransportError.d.ts +29 -0
- package/errors/TransportError.js +33 -0
- package/errors/TrellisError.d.ts +15 -0
- package/errors/TrellisError.js +15 -0
- package/errors/ValidationError.d.ts +50 -0
- package/errors/ValidationError.js +59 -0
- package/errors/index.d.ts +254 -0
- package/errors/index.js +238 -0
- package/generated.d.ts +4 -0
- package/generated.js +3 -0
- package/generated_support.d.ts +120 -0
- package/generated_support.js +359 -0
- package/globals.d.ts +9 -0
- package/globals.js +16 -0
- package/health_transport.d.ts +18 -0
- package/health_transport.js +32 -0
- package/helpers.d.ts +11 -0
- package/helpers.js +53 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/internal_sdk/generated/apis/auth/mod.d.ts +805 -0
- package/internal_sdk/generated/apis/auth/mod.js +958 -0
- package/internal_sdk/generated/apis/core/mod.d.ts +79 -0
- package/internal_sdk/generated/apis/core/mod.js +93 -0
- package/internal_sdk/generated/apis/events/mod.d.ts +224 -0
- package/internal_sdk/generated/apis/events/mod.js +313 -0
- package/internal_sdk/generated/apis/health/mod.d.ts +106 -0
- package/internal_sdk/generated/apis/health/mod.js +132 -0
- package/internal_sdk/generated/apis/index.d.ts +7 -0
- package/internal_sdk/generated/apis/index.js +8 -0
- package/internal_sdk/generated/apis/jobs/mod.d.ts +176 -0
- package/internal_sdk/generated/apis/jobs/mod.js +209 -0
- package/internal_sdk/generated/apis/state/mod.d.ts +104 -0
- package/internal_sdk/generated/apis/state/mod.js +139 -0
- package/internal_sdk/generated/index.d.ts +4 -0
- package/internal_sdk/generated/index.js +5 -0
- package/internal_sdk/generated/package.json +18 -0
- package/internal_sdk/generated/participants/cli/mod.d.ts +402 -0
- package/internal_sdk/generated/participants/cli/mod.js +460 -0
- package/internal_sdk/generated/participants/cli/types.d.ts +2 -0
- package/internal_sdk/generated/participants/cli/types.js +3 -0
- package/internal_sdk/generated/participants/console/mod.d.ts +489 -0
- package/internal_sdk/generated/participants/console/mod.js +579 -0
- package/internal_sdk/generated/participants/console/types.d.ts +2 -0
- package/internal_sdk/generated/participants/console/types.js +3 -0
- package/internal_sdk/generated/participants/eventsRuntime/mod.d.ts +64 -0
- package/internal_sdk/generated/participants/eventsRuntime/mod.js +42 -0
- package/internal_sdk/generated/participants/eventsRuntime/types.d.ts +2 -0
- package/internal_sdk/generated/participants/eventsRuntime/types.js +3 -0
- package/internal_sdk/generated/participants/healthRuntime/mod.d.ts +58 -0
- package/internal_sdk/generated/participants/healthRuntime/mod.js +36 -0
- package/internal_sdk/generated/participants/healthRuntime/types.d.ts +2 -0
- package/internal_sdk/generated/participants/healthRuntime/types.js +3 -0
- package/internal_sdk/generated/participants/index.d.ts +8 -0
- package/internal_sdk/generated/participants/index.js +9 -0
- package/internal_sdk/generated/participants/jobsRuntime/mod.d.ts +64 -0
- package/internal_sdk/generated/participants/jobsRuntime/mod.js +42 -0
- package/internal_sdk/generated/participants/jobsRuntime/types.d.ts +2 -0
- package/internal_sdk/generated/participants/jobsRuntime/types.js +3 -0
- package/internal_sdk/generated/participants/platform/mod.d.ts +164 -0
- package/internal_sdk/generated/participants/platform/mod.js +149 -0
- package/internal_sdk/generated/participants/platform/types.d.ts +7 -0
- package/internal_sdk/generated/participants/platform/types.js +5 -0
- package/internal_sdk/generated/participants/portal/mod.d.ts +131 -0
- package/internal_sdk/generated/participants/portal/mod.js +109 -0
- package/internal_sdk/generated/participants/portal/types.d.ts +2 -0
- package/internal_sdk/generated/participants/portal/types.js +3 -0
- package/internal_sdk/generated/types/_internal/p0.d.ts +13511 -0
- package/internal_sdk/generated/types/_internal/p0.js +6105 -0
- package/internal_sdk/generated/types/index.d.ts +2951 -0
- package/internal_sdk/generated/types/index.js +1477 -0
- package/jobs.d.ts +309 -0
- package/jobs.js +389 -0
- package/kv.d.ts +85 -0
- package/kv.js +330 -0
- package/operations.d.ts +189 -0
- package/operations.js +847 -0
- package/package.json +73 -0
- package/pagination.d.ts +25 -0
- package/pagination.js +117 -0
- package/participant.d.ts +6 -0
- package/participant.js +6 -0
- package/participant_runtime/api.d.ts +131 -0
- package/participant_runtime/api.js +42 -0
- package/participant_runtime/json.d.ts +16 -0
- package/participant_runtime/json.js +193 -0
- package/participant_runtime/metadata.d.ts +34 -0
- package/participant_runtime/metadata.js +4 -0
- package/participant_runtime/participant.d.ts +200 -0
- package/participant_runtime/participant.js +330 -0
- package/participant_runtime/schemas.d.ts +347 -0
- package/participant_runtime/schemas.js +211 -0
- package/participant_runtime/surface_names.d.ts +16 -0
- package/participant_runtime/surface_names.js +34 -0
- package/portable.d.ts +30 -0
- package/portable.js +14 -0
- package/provider.d.ts +69 -0
- package/provider.js +68 -0
- package/runtime_transport.d.ts +25 -0
- package/runtime_transport.js +48 -0
- package/service/mod.d.ts +14 -0
- package/service/mod.js +13 -0
- package/service/outbox_inbox.d.ts +259 -0
- package/service/outbox_inbox.js +908 -0
- package/service/runtime/bootstrap.d.ts +56 -0
- package/service/runtime/bootstrap.js +226 -0
- package/service/runtime/core.d.ts +46 -0
- package/service/runtime/core.js +1747 -0
- package/service/runtime/health.d.ts +97 -0
- package/service/runtime/health.js +153 -0
- package/service/runtime/health_schemas.d.ts +23 -0
- package/service/runtime/health_schemas.js +20 -0
- package/service/runtime/internal_jobs/active-job.d.ts +40 -0
- package/service/runtime/internal_jobs/active-job.js +91 -0
- package/service/runtime/internal_jobs/bindings.d.ts +40 -0
- package/service/runtime/internal_jobs/bindings.js +1 -0
- package/service/runtime/internal_jobs/cancellation-registry.d.ts +13 -0
- package/service/runtime/internal_jobs/cancellation-registry.js +55 -0
- package/service/runtime/internal_jobs/heartbeat.d.ts +33 -0
- package/service/runtime/internal_jobs/heartbeat.js +65 -0
- package/service/runtime/internal_jobs/job-manager.d.ts +126 -0
- package/service/runtime/internal_jobs/job-manager.js +821 -0
- package/service/runtime/internal_jobs/key-coordinator.d.ts +280 -0
- package/service/runtime/internal_jobs/key-coordinator.js +747 -0
- package/service/runtime/internal_jobs/projection.d.ts +3 -0
- package/service/runtime/internal_jobs/projection.js +42 -0
- package/service/runtime/internal_jobs/runtime-worker.d.ts +126 -0
- package/service/runtime/internal_jobs/runtime-worker.js +454 -0
- package/service/runtime/internal_jobs/types.d.ts +246 -0
- package/service/runtime/internal_jobs/types.js +163 -0
- package/service/runtime/logger.d.ts +2 -0
- package/service/runtime/logger.js +7 -0
- package/service/runtime/runtime.d.ts +16 -0
- package/service/runtime/runtime.js +1 -0
- package/service/runtime/service.d.ts +372 -0
- package/service/runtime/service.js +1896 -0
- package/service/runtime/transfer/download.d.ts +27 -0
- package/service/runtime/transfer/download.js +1 -0
- package/service/runtime/transfer/protocol.d.ts +15 -0
- package/service/runtime/transfer/protocol.js +46 -0
- package/service/runtime/transfer/queue.d.ts +18 -0
- package/service/runtime/transfer/queue.js +136 -0
- package/service/runtime/transfer/upload.d.ts +40 -0
- package/service/runtime/transfer/upload.js +27 -0
- package/service/runtime/transfer.d.ts +62 -0
- package/service/runtime/transfer.js +763 -0
- package/session.d.ts +862 -0
- package/session.js +3407 -0
- package/store.d.ts +71 -0
- package/store.js +412 -0
- package/store_entry.d.ts +20 -0
- package/store_entry.js +75 -0
- package/tasks.d.ts +10 -0
- package/tasks.js +28 -0
- package/telemetry/carrier.d.ts +8 -0
- package/telemetry/carrier.js +20 -0
- package/telemetry/core.d.ts +7 -0
- package/telemetry/core.js +14 -0
- package/telemetry/env.d.ts +2 -0
- package/telemetry/env.js +10 -0
- package/telemetry/init.d.ts +2 -0
- package/telemetry/init.js +7 -0
- package/telemetry/metrics.d.ts +81 -0
- package/telemetry/metrics.js +267 -0
- package/telemetry/mod.d.ts +13 -0
- package/telemetry/mod.js +8 -0
- package/telemetry/nats.d.ts +6 -0
- package/telemetry/nats.js +6 -0
- package/telemetry/result.d.ts +1 -0
- package/telemetry/result.js +18 -0
- package/telemetry/runtime.d.ts +1 -0
- package/telemetry/runtime.js +141 -0
- package/telemetry/trace.d.ts +4 -0
- package/telemetry/trace.js +26 -0
- package/telemetry/trellis.d.ts +1 -0
- package/telemetry/trellis.js +1 -0
- package/telemetry.d.ts +1 -0
- package/telemetry.js +1 -0
- package/transfer.d.ts +112 -0
- package/transfer.js +525 -0
- package/transfer_protocol.d.ts +1 -0
- package/transfer_protocol.js +13 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { NatsConnection } from "@nats-io/nats-core";
|
|
2
|
+
import type { JobContext, JobEvent, JobState } from "./types.ts";
|
|
3
|
+
export type JobKeyStalePolicy = "fail-stale" | "block";
|
|
4
|
+
export type JobQueueWhenFull = "reject" | "coalesce" | "replace-oldest";
|
|
5
|
+
export type JobKeyConcurrencyBinding = {
|
|
6
|
+
key: string[];
|
|
7
|
+
maxActive?: number;
|
|
8
|
+
heartbeatIntervalMs?: number;
|
|
9
|
+
heartbeatTtlMs?: number;
|
|
10
|
+
stalePolicy?: JobKeyStalePolicy;
|
|
11
|
+
};
|
|
12
|
+
export type JobQueuePolicyBinding = {
|
|
13
|
+
maxQueuedPerKey?: number;
|
|
14
|
+
whenFull?: JobQueueWhenFull;
|
|
15
|
+
};
|
|
16
|
+
export type NormalizedJobKeyPolicy = {
|
|
17
|
+
key: string[];
|
|
18
|
+
maxActive: number;
|
|
19
|
+
heartbeatIntervalMs: number;
|
|
20
|
+
heartbeatTtlMs: number;
|
|
21
|
+
stalePolicy: JobKeyStalePolicy;
|
|
22
|
+
queue: {
|
|
23
|
+
maxQueuedPerKey: number;
|
|
24
|
+
whenFull: JobQueueWhenFull;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type DerivedJobKey = {
|
|
28
|
+
service: string;
|
|
29
|
+
jobType: string;
|
|
30
|
+
key: string;
|
|
31
|
+
keyHash: string;
|
|
32
|
+
kvKey: string;
|
|
33
|
+
};
|
|
34
|
+
export type JobKeyQueued = {
|
|
35
|
+
jobId: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
requestId: string;
|
|
38
|
+
context: JobContext;
|
|
39
|
+
submissionId?: string;
|
|
40
|
+
};
|
|
41
|
+
export type JobKeyActiveSlot = {
|
|
42
|
+
jobId: string;
|
|
43
|
+
slotToken: string;
|
|
44
|
+
instanceId: string;
|
|
45
|
+
startedAt: string;
|
|
46
|
+
heartbeatAt: string;
|
|
47
|
+
leaseExpiresAt: string;
|
|
48
|
+
tries: number;
|
|
49
|
+
context: JobContext;
|
|
50
|
+
};
|
|
51
|
+
export type JobKeyState = {
|
|
52
|
+
version: 1;
|
|
53
|
+
service: string;
|
|
54
|
+
jobType: string;
|
|
55
|
+
key: string;
|
|
56
|
+
keyHash: string;
|
|
57
|
+
maxActive: number;
|
|
58
|
+
maxQueuedPerKey?: number;
|
|
59
|
+
active: JobKeyActiveSlot[];
|
|
60
|
+
queued: JobKeyQueued[];
|
|
61
|
+
staleTakeoverCount: number;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
coalescedBySubmissionId?: Record<string, {
|
|
64
|
+
existingJobId: string;
|
|
65
|
+
reason: "queue-full" | "active-limit";
|
|
66
|
+
}>;
|
|
67
|
+
acceptedBySubmissionId?: Record<string, {
|
|
68
|
+
jobId: string;
|
|
69
|
+
}>;
|
|
70
|
+
replacedBySubmissionId?: Record<string, ReplacedQueuedJob>;
|
|
71
|
+
};
|
|
72
|
+
export type JobKeyIdentity = {
|
|
73
|
+
service: string;
|
|
74
|
+
jobType: string;
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
export type ReplacedQueuedJob = JobKeyIdentity & {
|
|
78
|
+
createdAt: string;
|
|
79
|
+
requestId: string;
|
|
80
|
+
context: JobContext;
|
|
81
|
+
};
|
|
82
|
+
export type JobAdmissionRequest = {
|
|
83
|
+
service: string;
|
|
84
|
+
jobType: string;
|
|
85
|
+
jobId: string;
|
|
86
|
+
payload: unknown;
|
|
87
|
+
context: JobContext;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
policy: NormalizedJobKeyPolicy;
|
|
90
|
+
strictCreate: boolean;
|
|
91
|
+
submissionId?: string;
|
|
92
|
+
};
|
|
93
|
+
export type JobAdmissionOutcome = {
|
|
94
|
+
kind: "accepted";
|
|
95
|
+
key: string;
|
|
96
|
+
keyHash: string;
|
|
97
|
+
state: JobKeyState;
|
|
98
|
+
} | {
|
|
99
|
+
kind: "rejected";
|
|
100
|
+
key: string;
|
|
101
|
+
reason: "active-limit" | "queue-depth" | "stale-blocked";
|
|
102
|
+
active: number;
|
|
103
|
+
queued: number;
|
|
104
|
+
limit: number;
|
|
105
|
+
} | {
|
|
106
|
+
kind: "coalesced";
|
|
107
|
+
key: string;
|
|
108
|
+
existing: JobKeyIdentity;
|
|
109
|
+
reason: "queue-full" | "active-limit";
|
|
110
|
+
} | {
|
|
111
|
+
kind: "replaced";
|
|
112
|
+
key: string;
|
|
113
|
+
keyHash: string;
|
|
114
|
+
replaced: ReplacedQueuedJob;
|
|
115
|
+
state: JobKeyState;
|
|
116
|
+
};
|
|
117
|
+
export type ActiveSlotAcquireRequest = {
|
|
118
|
+
service: string;
|
|
119
|
+
jobType: string;
|
|
120
|
+
jobId: string;
|
|
121
|
+
payload: unknown;
|
|
122
|
+
context: JobContext;
|
|
123
|
+
workEventType?: JobEvent["eventType"];
|
|
124
|
+
lifecycleState?: JobState;
|
|
125
|
+
tries: number;
|
|
126
|
+
instanceId: string;
|
|
127
|
+
now: string;
|
|
128
|
+
policy: NormalizedJobKeyPolicy;
|
|
129
|
+
};
|
|
130
|
+
export type ActiveSlotAcquireOutcome = {
|
|
131
|
+
kind: "acquired";
|
|
132
|
+
key: string;
|
|
133
|
+
keyHash: string;
|
|
134
|
+
slotToken: string;
|
|
135
|
+
stale: JobKeyActiveSlot[];
|
|
136
|
+
state: JobKeyState;
|
|
137
|
+
} | {
|
|
138
|
+
kind: "blocked";
|
|
139
|
+
key: string;
|
|
140
|
+
reason: "active-limit" | "not-queued" | "stale-blocked";
|
|
141
|
+
active: number;
|
|
142
|
+
queued: number;
|
|
143
|
+
limit: number;
|
|
144
|
+
};
|
|
145
|
+
export type ActiveSlotLease = {
|
|
146
|
+
key: string;
|
|
147
|
+
keyHash: string;
|
|
148
|
+
slotToken: string;
|
|
149
|
+
policy: NormalizedJobKeyPolicy;
|
|
150
|
+
};
|
|
151
|
+
export type ActiveSlotRenewOutcome = {
|
|
152
|
+
kind: "renewed";
|
|
153
|
+
state: JobKeyState;
|
|
154
|
+
} | {
|
|
155
|
+
kind: "lost";
|
|
156
|
+
};
|
|
157
|
+
export type ActiveSlotReleaseOutcome = {
|
|
158
|
+
kind: "released";
|
|
159
|
+
state: JobKeyState;
|
|
160
|
+
} | {
|
|
161
|
+
kind: "staleCompletion";
|
|
162
|
+
};
|
|
163
|
+
export type JobKeyCoordinator = {
|
|
164
|
+
admitCreate(request: JobAdmissionRequest): Promise<JobAdmissionOutcome>;
|
|
165
|
+
restoreReplacedQueuedJob(args: {
|
|
166
|
+
service: string;
|
|
167
|
+
jobType: string;
|
|
168
|
+
replacementJobId: string;
|
|
169
|
+
replaced: ReplacedQueuedJob;
|
|
170
|
+
payload: unknown;
|
|
171
|
+
now: string;
|
|
172
|
+
policy: NormalizedJobKeyPolicy;
|
|
173
|
+
submissionId?: string;
|
|
174
|
+
}): Promise<QueuedJobRestoreOutcome>;
|
|
175
|
+
removeQueuedJob(args: {
|
|
176
|
+
service: string;
|
|
177
|
+
jobType: string;
|
|
178
|
+
jobId: string;
|
|
179
|
+
payload: unknown;
|
|
180
|
+
now: string;
|
|
181
|
+
policy: NormalizedJobKeyPolicy;
|
|
182
|
+
submissionId?: string;
|
|
183
|
+
}): Promise<QueuedJobRemovalOutcome>;
|
|
184
|
+
removeQueuedJobById?(args: {
|
|
185
|
+
service: string;
|
|
186
|
+
jobType: string;
|
|
187
|
+
jobId: string;
|
|
188
|
+
now: string;
|
|
189
|
+
}): Promise<QueuedJobRemovalOutcome>;
|
|
190
|
+
acquireActiveSlot(request: ActiveSlotAcquireRequest): Promise<ActiveSlotAcquireOutcome>;
|
|
191
|
+
renewHeartbeat(args: {
|
|
192
|
+
service: string;
|
|
193
|
+
jobType: string;
|
|
194
|
+
jobId: string;
|
|
195
|
+
lease: ActiveSlotLease;
|
|
196
|
+
now: string;
|
|
197
|
+
}): Promise<ActiveSlotRenewOutcome>;
|
|
198
|
+
releaseActiveSlot(args: {
|
|
199
|
+
service: string;
|
|
200
|
+
jobType: string;
|
|
201
|
+
jobId: string;
|
|
202
|
+
lease: ActiveSlotLease;
|
|
203
|
+
now: string;
|
|
204
|
+
}): Promise<ActiveSlotReleaseOutcome>;
|
|
205
|
+
};
|
|
206
|
+
export type QueuedJobRemovalOutcome = {
|
|
207
|
+
kind: "removed";
|
|
208
|
+
state: JobKeyState;
|
|
209
|
+
} | {
|
|
210
|
+
kind: "not-found";
|
|
211
|
+
};
|
|
212
|
+
export type QueuedJobRestoreOutcome = {
|
|
213
|
+
kind: "restored";
|
|
214
|
+
state: JobKeyState;
|
|
215
|
+
};
|
|
216
|
+
/** Normalizes keyed queue policy defaults when bindings omit normalized values. */
|
|
217
|
+
export declare function normalizeJobKeyPolicy(args: {
|
|
218
|
+
keyConcurrency: JobKeyConcurrencyBinding;
|
|
219
|
+
queue?: JobQueuePolicyBinding;
|
|
220
|
+
}): NormalizedJobKeyPolicy;
|
|
221
|
+
/** Derives the display key and stable hash for a keyed job payload. */
|
|
222
|
+
export declare function deriveJobKey(args: {
|
|
223
|
+
service: string;
|
|
224
|
+
jobType: string;
|
|
225
|
+
payload: unknown;
|
|
226
|
+
template: string[];
|
|
227
|
+
}): Promise<DerivedJobKey>;
|
|
228
|
+
/** Produces a stable SHA-256 hex hash for a display key. */
|
|
229
|
+
export declare function stableKeyHash(value: string): Promise<string>;
|
|
230
|
+
/** Applies keyed admission policy to an existing key state. */
|
|
231
|
+
export declare function reduceAdmission(args: {
|
|
232
|
+
state: JobKeyState | undefined;
|
|
233
|
+
derived: DerivedJobKey;
|
|
234
|
+
request: Omit<JobAdmissionRequest, "payload" | "policy">;
|
|
235
|
+
policy: NormalizedJobKeyPolicy;
|
|
236
|
+
}): JobAdmissionOutcome;
|
|
237
|
+
/** Restores the replaced queued reservation when replacement lifecycle publish fails. */
|
|
238
|
+
export declare function reduceRestoreReplacedQueuedJob(args: {
|
|
239
|
+
state: JobKeyState | undefined;
|
|
240
|
+
derived: DerivedJobKey;
|
|
241
|
+
replacementJobId: string;
|
|
242
|
+
replaced: ReplacedQueuedJob;
|
|
243
|
+
now: string;
|
|
244
|
+
policy: NormalizedJobKeyPolicy;
|
|
245
|
+
submissionId?: string;
|
|
246
|
+
}): QueuedJobRestoreOutcome;
|
|
247
|
+
/** Applies active slot acquisition policy to an existing key state. */
|
|
248
|
+
export declare function reduceAcquireActiveSlot(args: {
|
|
249
|
+
state: JobKeyState | undefined;
|
|
250
|
+
derived: DerivedJobKey;
|
|
251
|
+
request: Omit<ActiveSlotAcquireRequest, "payload" | "policy">;
|
|
252
|
+
policy: NormalizedJobKeyPolicy;
|
|
253
|
+
slotToken: string;
|
|
254
|
+
}): ActiveSlotAcquireOutcome;
|
|
255
|
+
/** Removes a queued keyed-job reservation when work is terminal before start. */
|
|
256
|
+
export declare function reduceRemoveQueuedJob(args: {
|
|
257
|
+
state: JobKeyState | undefined;
|
|
258
|
+
jobId: string;
|
|
259
|
+
now: string;
|
|
260
|
+
submissionId?: string;
|
|
261
|
+
}): QueuedJobRemovalOutcome;
|
|
262
|
+
/** Renews a matching active slot lease in key state. */
|
|
263
|
+
export declare function reduceRenewHeartbeat(args: {
|
|
264
|
+
state: JobKeyState | undefined;
|
|
265
|
+
jobId: string;
|
|
266
|
+
slotToken: string;
|
|
267
|
+
now: string;
|
|
268
|
+
policy: NormalizedJobKeyPolicy;
|
|
269
|
+
}): ActiveSlotRenewOutcome;
|
|
270
|
+
/** Releases a matching active slot or reports a stale completion. */
|
|
271
|
+
export declare function reduceReleaseActiveSlot(args: {
|
|
272
|
+
state: JobKeyState | undefined;
|
|
273
|
+
jobId: string;
|
|
274
|
+
slotToken: string;
|
|
275
|
+
now: string;
|
|
276
|
+
}): ActiveSlotReleaseOutcome;
|
|
277
|
+
/** Creates a NATS KV backed coordinator for the Trellis-owned JOBS_KEYS bucket. */
|
|
278
|
+
export declare function createNatsJobKeyCoordinator(nats: NatsConnection, bucketPrefix?: string): JobKeyCoordinator;
|
|
279
|
+
/** Returns whether an unknown value is a well-formed keyed job coordination state. */
|
|
280
|
+
export declare function isJobKeyState(value: unknown): value is JobKeyState;
|