@xemahq/temporal-runtime 0.6.0 → 0.8.0
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 +203 -11
- package/dist/bin/controller-token-publisher.d.ts +3 -0
- package/dist/bin/controller-token-publisher.d.ts.map +1 -0
- package/dist/bin/controller-token-publisher.js +18 -0
- package/dist/bin/controller-token-publisher.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/access-token.d.ts +11 -0
- package/dist/lib/access-token.d.ts.map +1 -0
- package/dist/lib/access-token.js +30 -0
- package/dist/lib/access-token.js.map +1 -0
- package/dist/lib/base-temporal-client.service.d.ts +3 -2
- package/dist/lib/base-temporal-client.service.d.ts.map +1 -1
- package/dist/lib/base-temporal-client.service.js +5 -5
- package/dist/lib/base-temporal-client.service.js.map +1 -1
- package/dist/lib/biome-worker.d.ts +107 -0
- package/dist/lib/biome-worker.d.ts.map +1 -0
- package/dist/lib/biome-worker.js +348 -0
- package/dist/lib/biome-worker.js.map +1 -0
- package/dist/lib/bounded-retry.d.ts +22 -0
- package/dist/lib/bounded-retry.d.ts.map +1 -0
- package/dist/lib/bounded-retry.js +67 -0
- package/dist/lib/bounded-retry.js.map +1 -0
- package/dist/lib/client-credentials-token-source.d.ts +23 -0
- package/dist/lib/client-credentials-token-source.d.ts.map +1 -0
- package/dist/lib/client-credentials-token-source.js +108 -0
- package/dist/lib/client-credentials-token-source.js.map +1 -0
- package/dist/lib/connection.d.ts +48 -9
- package/dist/lib/connection.d.ts.map +1 -1
- package/dist/lib/connection.js +153 -41
- package/dist/lib/connection.js.map +1 -1
- package/dist/lib/controller-token-publisher.d.ts +51 -0
- package/dist/lib/controller-token-publisher.d.ts.map +1 -0
- package/dist/lib/controller-token-publisher.js +116 -0
- package/dist/lib/controller-token-publisher.js.map +1 -0
- package/dist/lib/fairness-constants.d.ts +4 -0
- package/dist/lib/fairness-constants.d.ts.map +1 -0
- package/dist/lib/fairness-constants.js +7 -0
- package/dist/lib/fairness-constants.js.map +1 -0
- package/dist/lib/fairness.d.ts +13 -0
- package/dist/lib/fairness.d.ts.map +1 -0
- package/dist/lib/fairness.js +56 -0
- package/dist/lib/fairness.js.map +1 -0
- package/dist/lib/nexus-constants.d.ts +8 -0
- package/dist/lib/nexus-constants.d.ts.map +1 -0
- package/dist/lib/nexus-constants.js +14 -0
- package/dist/lib/nexus-constants.js.map +1 -0
- package/dist/lib/nexus-contract.d.ts +43 -0
- package/dist/lib/nexus-contract.d.ts.map +1 -0
- package/dist/lib/nexus-contract.js +101 -0
- package/dist/lib/nexus-contract.js.map +1 -0
- package/dist/lib/nexus-handler.d.ts +32 -0
- package/dist/lib/nexus-handler.d.ts.map +1 -0
- package/dist/lib/nexus-handler.js +144 -0
- package/dist/lib/nexus-handler.js.map +1 -0
- package/dist/lib/nexus-workflow.d.ts +22 -0
- package/dist/lib/nexus-workflow.d.ts.map +1 -0
- package/dist/lib/nexus-workflow.js +74 -0
- package/dist/lib/nexus-workflow.js.map +1 -0
- package/dist/lib/org-erasure.d.ts +13 -0
- package/dist/lib/org-erasure.d.ts.map +1 -0
- package/dist/lib/org-erasure.js +68 -0
- package/dist/lib/org-erasure.js.map +1 -0
- package/dist/lib/proactive-token-refresher.d.ts +47 -0
- package/dist/lib/proactive-token-refresher.d.ts.map +1 -0
- package/dist/lib/proactive-token-refresher.js +147 -0
- package/dist/lib/proactive-token-refresher.js.map +1 -0
- package/dist/lib/search-attribute-constants.d.ts +3 -0
- package/dist/lib/search-attribute-constants.d.ts.map +1 -0
- package/dist/lib/search-attribute-constants.js +6 -0
- package/dist/lib/search-attribute-constants.js.map +1 -0
- package/dist/lib/search-attributes.d.ts +4 -18
- package/dist/lib/search-attributes.d.ts.map +1 -1
- package/dist/lib/search-attributes.js +33 -40
- package/dist/lib/search-attributes.js.map +1 -1
- package/dist/lib/standalone-activity.d.ts +23 -0
- package/dist/lib/standalone-activity.d.ts.map +1 -0
- package/dist/lib/standalone-activity.js +48 -0
- package/dist/lib/standalone-activity.js.map +1 -0
- package/dist/lib/versioned-worker.d.ts +26 -0
- package/dist/lib/versioned-worker.d.ts.map +1 -0
- package/dist/lib/versioned-worker.js +60 -0
- package/dist/lib/versioned-worker.js.map +1 -0
- package/dist/lib/worker-deployment-version.d.ts +8 -0
- package/dist/lib/worker-deployment-version.d.ts.map +1 -0
- package/dist/lib/worker-deployment-version.js +45 -0
- package/dist/lib/worker-deployment-version.js.map +1 -0
- package/dist/lib/worker.d.ts +8 -7
- package/dist/lib/worker.d.ts.map +1 -1
- package/dist/lib/worker.js +55 -37
- package/dist/lib/worker.js.map +1 -1
- package/dist/lib/workflow-interceptors/fairness-guard.d.ts +4 -0
- package/dist/lib/workflow-interceptors/fairness-guard.d.ts.map +1 -0
- package/dist/lib/workflow-interceptors/fairness-guard.js +79 -0
- package/dist/lib/workflow-interceptors/fairness-guard.js.map +1 -0
- package/dist/lib/workflow-interceptors/fairness-propagation.d.ts +3 -0
- package/dist/lib/workflow-interceptors/fairness-propagation.d.ts.map +1 -0
- package/dist/lib/workflow-interceptors/fairness-propagation.js +6 -0
- package/dist/lib/workflow-interceptors/fairness-propagation.js.map +1 -0
- package/dist/lib/workflow-interceptors/org-fairness-required.d.ts +3 -0
- package/dist/lib/workflow-interceptors/org-fairness-required.d.ts.map +1 -0
- package/dist/lib/workflow-interceptors/org-fairness-required.js +6 -0
- package/dist/lib/workflow-interceptors/org-fairness-required.js.map +1 -0
- package/dist/lib/workflow-interceptors/org-search-attribute.d.ts +3 -0
- package/dist/lib/workflow-interceptors/org-search-attribute.d.ts.map +1 -0
- package/dist/lib/workflow-interceptors/org-search-attribute.js +49 -0
- package/dist/lib/workflow-interceptors/org-search-attribute.js.map +1 -0
- package/dist/lib/workflow-purity.d.ts +27 -0
- package/dist/lib/workflow-purity.d.ts.map +1 -0
- package/dist/lib/workflow-purity.js +115 -0
- package/dist/lib/workflow-purity.js.map +1 -0
- package/package.json +33 -10
package/README.md
CHANGED
|
@@ -28,16 +28,17 @@
|
|
|
28
28
|
|
|
29
29
|
## Overview
|
|
30
30
|
|
|
31
|
-
Shared runtime glue for services that run Temporal
|
|
32
|
-
workflows
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
visibility search attributes.
|
|
31
|
+
Shared runtime glue for services that run Temporal workers or start
|
|
32
|
+
workflows: connection handling, an on-behalf-of activity-auth context, biome
|
|
33
|
+
worker components on Worker Deployment versioning, org fairness, Standalone
|
|
34
|
+
Activities, an authenticated service HTTP client for activities, idempotent
|
|
35
|
+
schedule reconciliation, and a closed set of visibility search attributes.
|
|
37
36
|
|
|
38
37
|
## When to use it
|
|
39
38
|
|
|
40
|
-
-
|
|
39
|
+
- A biome ships a `kind: worker` component and needs to run its workflows,
|
|
40
|
+
activities or Nexus handlers.
|
|
41
|
+
- A service starts a workflow or a one-shot durable activity for an org.
|
|
41
42
|
|
|
42
43
|
## Installation
|
|
43
44
|
|
|
@@ -47,17 +48,208 @@ pnpm add @xemahq/temporal-runtime
|
|
|
47
48
|
|
|
48
49
|
## Usage
|
|
49
50
|
|
|
51
|
+
### A biome worker component
|
|
52
|
+
|
|
53
|
+
Define the component from its manifest's worker protocol (revision `v2`), then
|
|
54
|
+
compose one or more definitions into a process. The process connects once,
|
|
55
|
+
derives its namespace from the deployment id and trust domain, and polls every
|
|
56
|
+
declared task queue (`<biomeId>:<name>`) with a versioned worker.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import {
|
|
60
|
+
composeBiomeWorkers,
|
|
61
|
+
defineBiomeWorker,
|
|
62
|
+
resolveWorkerDeploymentVersionFromEnv,
|
|
63
|
+
} from '@xemahq/temporal-runtime';
|
|
64
|
+
|
|
65
|
+
const translation = defineBiomeWorker({
|
|
66
|
+
biomeId: 'pai-core',
|
|
67
|
+
componentKey: 'translation-worker',
|
|
68
|
+
origin: BiomeOrigin.FirstParty,
|
|
69
|
+
protocol: manifest.components[i].protocol, // as declared, parsed here
|
|
70
|
+
workflowsPath: require.resolve('./workflows'),
|
|
71
|
+
activities,
|
|
72
|
+
nexusServices: [{ service: 'agent-session', version: 'v1', handler }],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const process = await composeBiomeWorkers({
|
|
76
|
+
connection, // a NativeConnection you own
|
|
77
|
+
deploymentId: env('XEMA_DEPLOYMENT_ID'),
|
|
78
|
+
version: resolveWorkerDeploymentVersionFromEnv(env),
|
|
79
|
+
definitions: [translation],
|
|
80
|
+
});
|
|
81
|
+
await process.run(); // process.shutdown() on SIGTERM
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The implementations must match the manifest: `workflowsPath` iff a queue
|
|
85
|
+
serves `workflows`, `activities` iff a queue serves `activities`, and exactly
|
|
86
|
+
one handler per `nexus.provides` entry. A mismatch, mixed trust domains, or a
|
|
87
|
+
task queue polled twice refuses at boot with a `BiomeWorkerError`.
|
|
88
|
+
|
|
89
|
+
### Versioning
|
|
90
|
+
|
|
91
|
+
Every worker polls as one Worker Deployment version, and every workflow it
|
|
92
|
+
starts is PINNED to that version. In a cluster the version comes from the
|
|
93
|
+
Temporal Worker Controller (`TEMPORAL_DEPLOYMENT_NAME`,
|
|
94
|
+
`TEMPORAL_WORKER_BUILD_ID`); there is no default and no unversioned mode. So a
|
|
95
|
+
run started on an old version finishes there, new runs go to the current
|
|
96
|
+
version, and an old version drains only when its pinned runs end. Biomes
|
|
97
|
+
composed into one process share that process's version; a biome that releases
|
|
98
|
+
on its own cadence runs in its own process.
|
|
99
|
+
|
|
100
|
+
### Org fairness
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
await startWorkflowForOrg(client, 'translationWorkflow', {
|
|
104
|
+
orgId, taskQueue, workflowId, args: [input],
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The org id is the fairness key. The run's activities and child workflows carry
|
|
109
|
+
it, scheduling work under a different key fails the run, and a
|
|
110
|
+
`fairness: 'org'` queue refuses work that arrives without one. Nexus
|
|
111
|
+
operations do not carry a priority in SDK 1.24, so a Nexus handler sets the
|
|
112
|
+
fairness key of the work it starts from the caller's org.
|
|
113
|
+
|
|
114
|
+
### Nexus services
|
|
115
|
+
|
|
116
|
+
A biome publishes its contract as its own package, importing only the
|
|
117
|
+
sandbox-safe subpath:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { asyncOperation, defineNexusContract, NexusOperationScope, syncOperation }
|
|
121
|
+
from '@xemahq/temporal-runtime/nexus-contract';
|
|
122
|
+
|
|
123
|
+
export const agentSessionContract = defineNexusContract({
|
|
124
|
+
service: 'agent-session',
|
|
125
|
+
version: 'v1',
|
|
126
|
+
operations: {
|
|
127
|
+
start: asyncOperation<StartInput, StartResult>({ scope: NexusOperationScope.Org }),
|
|
128
|
+
erase: syncOperation<EraseInput, EraseReceipt>({ scope: NexusOperationScope.Org }),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The provider implements it and passes the result to `defineBiomeWorker`, where
|
|
134
|
+
it is checked against the manifest's `nexus.provides` (operations and modes):
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
nexusServices: [nexusHandlerFor(agentSessionContract, {
|
|
138
|
+
start: (ctx, input) => ctx.startWorkflow(sessionWorkflow, { workflowId, args: [input] }),
|
|
139
|
+
erase: async (ctx, input) => eraseSession(ctx.orgId, input),
|
|
140
|
+
})],
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Callers call it from workflow code:
|
|
144
|
+
|
|
50
145
|
```ts
|
|
51
|
-
import {
|
|
146
|
+
import { nexusClientFor } from '@xemahq/temporal-runtime/nexus-workflow';
|
|
147
|
+
try {
|
|
148
|
+
const result = await nexusClientFor(agentSessionContract)
|
|
149
|
+
.executeOperation('start', input, { scheduleToCloseTimeout: '2h' });
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error instanceof NexusOperationTimedOut) { /* typed ending: error.timeoutType */ }
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`composeBiomeWorkers` takes the distribution lock (`lock: { biomes, nexusBindings }`).
|
|
157
|
+
A caller's bundle carries exactly the endpoints its manifest requires and the
|
|
158
|
+
lock binds; a provider admits only the caller namespaces the lock binds, read
|
|
159
|
+
from the request's calling-workflow link. The caller run's org travels as the
|
|
160
|
+
`xema-org-id` header; an org-scoped operation refuses a request without it, and
|
|
161
|
+
`ctx.startWorkflow` makes it the started run's fairness key and `OrgId`.
|
|
162
|
+
|
|
163
|
+
### Standalone Activities
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
await startStandaloneActivity(client, {
|
|
167
|
+
id: `outbox:${table}:${rowId}`,
|
|
168
|
+
type: 'relayOutboxRow',
|
|
169
|
+
taskQueue,
|
|
170
|
+
orgId, // or null: stated, never omitted
|
|
171
|
+
idConflict: StandaloneActivityIdConflict.UseExisting,
|
|
172
|
+
startToCloseTimeout: '1m',
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Search attributes and org erasure
|
|
177
|
+
|
|
178
|
+
A deployment namespace declares ONE custom search attribute, `OrgId` (Keyword),
|
|
179
|
+
and the shared-infra provisioning Job declares it, not a workload: adding
|
|
180
|
+
search attributes is an admin call the workload role cannot make. At boot a
|
|
181
|
+
starter calls `verifyPlatformSearchAttributes(connection, namespace)`, which
|
|
182
|
+
reads the namespace and refuses to boot, naming what is missing.
|
|
183
|
+
|
|
184
|
+
Every org-scoped run carries `OrgId`. `startWorkflowForOrg` sets it, and so does
|
|
185
|
+
`buildPlatformSearchAttributes({ orgId })`; a child workflow inherits it from its
|
|
186
|
+
parent, since every bundle compiles in the propagation interceptor. Org erasure
|
|
187
|
+
then deletes that org's executions from the shared namespace:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
await eraseOrgWorkflowExecutions(client, { orgId, reason: 'org erased' });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Running executions are terminated, then every one is deleted. Other orgs'
|
|
194
|
+
executions, and cluster-wide runs with no `OrgId`, are untouched. If the
|
|
195
|
+
erasure does not finish before its deadline, the call throws.
|
|
52
196
|
|
|
53
|
-
|
|
54
|
-
|
|
197
|
+
### Connecting
|
|
198
|
+
|
|
199
|
+
Every worker and client connects to the frontend over TLS, verified against the
|
|
200
|
+
server CA, with a JWT bearer from the infra realm. There is no plaintext or
|
|
201
|
+
unauthenticated mode. The bearer comes from OAuth client-credentials for the
|
|
202
|
+
process's workload trust identity, and it is replaced before it expires.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import {
|
|
206
|
+
connectTemporalClient,
|
|
207
|
+
connectTemporalWorker,
|
|
208
|
+
temporalConnectionOptionsFromEnv,
|
|
209
|
+
} from '@xemahq/temporal-runtime';
|
|
210
|
+
|
|
211
|
+
const options = temporalConnectionOptionsFromEnv((name) => config.get(name));
|
|
212
|
+
const worker = await connectTemporalWorker(options);
|
|
213
|
+
const client = await connectTemporalClient(options);
|
|
214
|
+
// worker.connection / client.connection go to the SDK; close() stops refreshing.
|
|
55
215
|
```
|
|
56
216
|
|
|
217
|
+
`temporalConnectionOptionsFromEnv` takes an injected reader and reads
|
|
218
|
+
`TEMPORAL_ADDRESS`, `TEMPORAL_TLS_CA_PATH`, `TEMPORAL_AUTH_TOKEN_ENDPOINT`,
|
|
219
|
+
`TEMPORAL_AUTH_CLIENT_ID`, `TEMPORAL_AUTH_CLIENT_SECRET_FILE` and
|
|
220
|
+
`TEMPORAL_AUTH_AUDIENCE` (all required). It also reads
|
|
221
|
+
`TEMPORAL_TLS_SERVER_NAME` and the `TEMPORAL_TLS_CLIENT_CERT_PATH` /
|
|
222
|
+
`TEMPORAL_TLS_CLIENT_KEY_PATH` pair, which are optional.
|
|
223
|
+
|
|
224
|
+
### Keeping any client-credentials token current
|
|
225
|
+
|
|
226
|
+
`ProactiveTokenRefresher` is the one refresh mechanism. The connections use it,
|
|
227
|
+
and so can any other holder of an infra-realm token:
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
const tokens = await ProactiveTokenRefresher.start({
|
|
231
|
+
source: createClientCredentialsTokenSource(temporalClientCredentialsFromEnv(env)),
|
|
232
|
+
description: 'controller client',
|
|
233
|
+
});
|
|
234
|
+
await tokens.subscribe((token) => writeSecret(token.value));
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
It refreshes at 75% of the issuer's lifetime and retries with backoff while the
|
|
238
|
+
current token is still valid. If the token expires with no replacement, it
|
|
239
|
+
crashes the process (or calls the `onFatal` you pass instead).
|
|
240
|
+
|
|
241
|
+
### Tests
|
|
242
|
+
|
|
243
|
+
`pnpm test` runs the unit suite. `pnpm test:integration` starts one Temporal
|
|
244
|
+
1.32 server per run, in Docker, with frontend TLS and the JWT authorizer, and
|
|
245
|
+
runs the connection suite against it.
|
|
246
|
+
|
|
57
247
|
## Peer requirements
|
|
58
248
|
|
|
59
|
-
- `@nestjs/common` ^
|
|
249
|
+
- `@nestjs/common` ^11
|
|
60
250
|
- `reflect-metadata` ^0.2
|
|
251
|
+
- `@xemahq/contracts` >=0.55.0
|
|
252
|
+
- `@xemahq/identity-client` >=0.9.0
|
|
61
253
|
|
|
62
254
|
## License
|
|
63
255
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-token-publisher.d.ts","sourceRoot":"","sources":["../../src/bin/controller-token-publisher.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const controller_token_publisher_1 = require("../lib/controller-token-publisher");
|
|
5
|
+
const logger = {
|
|
6
|
+
log: (message) => {
|
|
7
|
+
process.stdout.write(`${message}\n`);
|
|
8
|
+
},
|
|
9
|
+
warn: (message) => console.warn(message),
|
|
10
|
+
error: (message) => console.error(message),
|
|
11
|
+
};
|
|
12
|
+
async function main() {
|
|
13
|
+
const options = await (0, controller_token_publisher_1.controllerTokenPublisherOptionsFromEnv)((name) => process.env[name]);
|
|
14
|
+
await (0, controller_token_publisher_1.startControllerTokenPublisher)(options, { logger });
|
|
15
|
+
logger.log(`Worker Controller token publisher: ${options.clientId} → ${options.target.namespace}/${options.target.secretName}#${options.target.secretKey}`);
|
|
16
|
+
}
|
|
17
|
+
void main();
|
|
18
|
+
//# sourceMappingURL=controller-token-publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-token-publisher.js","sourceRoot":"","sources":["../../src/bin/controller-token-publisher.ts"],"names":[],"mappings":";;;AAUA,kFAG2C;AAE3C,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,CAAC,OAAe,EAAE,EAAE;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IAChD,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;CACnD,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,MAAM,IAAA,mEAAsC,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1F,MAAM,IAAA,0DAA6B,EAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,CAAC,sCAAsC,OAAO,CAAC,QAAQ,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;AAC9J,CAAC;AAKD,KAAK,IAAI,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
export * from './lib/connection';
|
|
2
|
+
export * from './lib/controller-token-publisher';
|
|
3
|
+
export * from './lib/access-token';
|
|
4
|
+
export * from './lib/bounded-retry';
|
|
5
|
+
export * from './lib/client-credentials-token-source';
|
|
6
|
+
export * from './lib/proactive-token-refresher';
|
|
2
7
|
export * from './lib/namespace';
|
|
3
8
|
export * from './lib/base-temporal-client.service';
|
|
4
9
|
export * from './lib/activity-auth-context';
|
|
5
10
|
export * from './lib/on-behalf-of-interceptor';
|
|
6
11
|
export * from './lib/worker';
|
|
12
|
+
export * from './lib/workflow-purity';
|
|
13
|
+
export * from './lib/worker-deployment-version';
|
|
14
|
+
export * from './lib/biome-worker';
|
|
15
|
+
export * from './lib/fairness';
|
|
16
|
+
export * from './lib/nexus-contract';
|
|
17
|
+
export * from './lib/nexus-handler';
|
|
18
|
+
export { NEXUS_CALLER_NOT_BOUND, NEXUS_ENDPOINTS_NOT_DEFINED, NEXUS_OPERATION_TIMED_OUT, NEXUS_ORG_MISSING, NEXUS_SERVICE_NOT_BOUND, nexusServiceKey, } from './lib/nexus-constants';
|
|
19
|
+
export * from './lib/standalone-activity';
|
|
7
20
|
export * from './lib/auth-kind';
|
|
8
21
|
export * from './lib/service-http-client';
|
|
9
22
|
export * from './lib/schedule';
|
|
10
23
|
export * from './lib/search-attributes';
|
|
24
|
+
export * from './lib/org-erasure';
|
|
11
25
|
export * from './lib/temporal-sdk';
|
|
12
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8CA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uCAAuC,CAAC;AACtD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,15 +14,36 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.nexusServiceKey = exports.NEXUS_SERVICE_NOT_BOUND = exports.NEXUS_ORG_MISSING = exports.NEXUS_OPERATION_TIMED_OUT = exports.NEXUS_ENDPOINTS_NOT_DEFINED = exports.NEXUS_CALLER_NOT_BOUND = void 0;
|
|
17
18
|
__exportStar(require("./lib/connection"), exports);
|
|
19
|
+
__exportStar(require("./lib/controller-token-publisher"), exports);
|
|
20
|
+
__exportStar(require("./lib/access-token"), exports);
|
|
21
|
+
__exportStar(require("./lib/bounded-retry"), exports);
|
|
22
|
+
__exportStar(require("./lib/client-credentials-token-source"), exports);
|
|
23
|
+
__exportStar(require("./lib/proactive-token-refresher"), exports);
|
|
18
24
|
__exportStar(require("./lib/namespace"), exports);
|
|
19
25
|
__exportStar(require("./lib/base-temporal-client.service"), exports);
|
|
20
26
|
__exportStar(require("./lib/activity-auth-context"), exports);
|
|
21
27
|
__exportStar(require("./lib/on-behalf-of-interceptor"), exports);
|
|
22
28
|
__exportStar(require("./lib/worker"), exports);
|
|
29
|
+
__exportStar(require("./lib/workflow-purity"), exports);
|
|
30
|
+
__exportStar(require("./lib/worker-deployment-version"), exports);
|
|
31
|
+
__exportStar(require("./lib/biome-worker"), exports);
|
|
32
|
+
__exportStar(require("./lib/fairness"), exports);
|
|
33
|
+
__exportStar(require("./lib/nexus-contract"), exports);
|
|
34
|
+
__exportStar(require("./lib/nexus-handler"), exports);
|
|
35
|
+
var nexus_constants_1 = require("./lib/nexus-constants");
|
|
36
|
+
Object.defineProperty(exports, "NEXUS_CALLER_NOT_BOUND", { enumerable: true, get: function () { return nexus_constants_1.NEXUS_CALLER_NOT_BOUND; } });
|
|
37
|
+
Object.defineProperty(exports, "NEXUS_ENDPOINTS_NOT_DEFINED", { enumerable: true, get: function () { return nexus_constants_1.NEXUS_ENDPOINTS_NOT_DEFINED; } });
|
|
38
|
+
Object.defineProperty(exports, "NEXUS_OPERATION_TIMED_OUT", { enumerable: true, get: function () { return nexus_constants_1.NEXUS_OPERATION_TIMED_OUT; } });
|
|
39
|
+
Object.defineProperty(exports, "NEXUS_ORG_MISSING", { enumerable: true, get: function () { return nexus_constants_1.NEXUS_ORG_MISSING; } });
|
|
40
|
+
Object.defineProperty(exports, "NEXUS_SERVICE_NOT_BOUND", { enumerable: true, get: function () { return nexus_constants_1.NEXUS_SERVICE_NOT_BOUND; } });
|
|
41
|
+
Object.defineProperty(exports, "nexusServiceKey", { enumerable: true, get: function () { return nexus_constants_1.nexusServiceKey; } });
|
|
42
|
+
__exportStar(require("./lib/standalone-activity"), exports);
|
|
23
43
|
__exportStar(require("./lib/auth-kind"), exports);
|
|
24
44
|
__exportStar(require("./lib/service-http-client"), exports);
|
|
25
45
|
__exportStar(require("./lib/schedule"), exports);
|
|
26
46
|
__exportStar(require("./lib/search-attributes"), exports);
|
|
47
|
+
__exportStar(require("./lib/org-erasure"), exports);
|
|
27
48
|
__exportStar(require("./lib/temporal-sdk"), exports);
|
|
28
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA8CA,mDAAiC;AACjC,mEAAiD;AACjD,qDAAmC;AACnC,sDAAoC;AACpC,wEAAsD;AACtD,kEAAgD;AAChD,kDAAgC;AAChC,qEAAmD;AACnD,8DAA4C;AAC5C,iEAA+C;AAC/C,+CAA6B;AAC7B,wDAAsC;AACtC,kEAAgD;AAChD,qDAAmC;AACnC,iDAA+B;AAC/B,uDAAqC;AACrC,sDAAoC;AACpC,yDAO+B;AAN7B,yHAAA,sBAAsB,OAAA;AACtB,8HAAA,2BAA2B,OAAA;AAC3B,4HAAA,yBAAyB,OAAA;AACzB,oHAAA,iBAAiB,OAAA;AACjB,0HAAA,uBAAuB,OAAA;AACvB,kHAAA,eAAe,OAAA;AAEjB,4DAA0C;AAC1C,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,0DAAwC;AACxC,oDAAkC;AAClC,qDAAmC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface AccessToken {
|
|
2
|
+
readonly value: string;
|
|
3
|
+
readonly expiresAt: number;
|
|
4
|
+
}
|
|
5
|
+
export type AccessTokenSource = () => Promise<AccessToken>;
|
|
6
|
+
export interface AccessTokenClaims {
|
|
7
|
+
readonly aud: readonly string[];
|
|
8
|
+
readonly exp: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function decodeAccessTokenClaims(token: string): AccessTokenClaims;
|
|
11
|
+
//# sourceMappingURL=access-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-token.d.ts","sourceRoot":"","sources":["../../src/lib/access-token.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAQD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;AAG3D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAQD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAyBxE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeAccessTokenClaims = decodeAccessTokenClaims;
|
|
4
|
+
function decodeAccessTokenClaims(token) {
|
|
5
|
+
const parts = token.split('.');
|
|
6
|
+
const payloadSegment = parts[1];
|
|
7
|
+
if (parts.length !== 3 || payloadSegment === undefined) {
|
|
8
|
+
throw new Error('Temporal access token is not a JWT (expected three dot-separated segments).');
|
|
9
|
+
}
|
|
10
|
+
let payload;
|
|
11
|
+
try {
|
|
12
|
+
payload = JSON.parse(Buffer.from(payloadSegment, 'base64url').toString('utf8'));
|
|
13
|
+
}
|
|
14
|
+
catch (cause) {
|
|
15
|
+
throw new Error('Temporal access token payload is not valid base64url JSON.', { cause });
|
|
16
|
+
}
|
|
17
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
18
|
+
throw new Error('Temporal access token payload is not a JSON object.');
|
|
19
|
+
}
|
|
20
|
+
const record = payload;
|
|
21
|
+
const rawAud = record['aud'];
|
|
22
|
+
const aud = typeof rawAud === 'string'
|
|
23
|
+
? [rawAud]
|
|
24
|
+
: Array.isArray(rawAud)
|
|
25
|
+
? rawAud.filter((entry) => typeof entry === 'string')
|
|
26
|
+
: [];
|
|
27
|
+
const rawExp = record['exp'];
|
|
28
|
+
return { aud, exp: typeof rawExp === 'number' ? rawExp : undefined };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=access-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-token.js","sourceRoot":"","sources":["../../src/lib/access-token.ts"],"names":[],"mappings":";;AAgCA,0DAyBC;AAzBD,SAAgB,uBAAuB,CAAC,KAAa;IACnD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAClF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,4DAA4D,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3F,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,MAAM,GAAG,OAAkC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,GAAG,GACP,OAAO,MAAM,KAAK,QAAQ;QACxB,CAAC,CAAC,CAAC,MAAM,CAAC;QACV,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACrB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;YACtE,CAAC,CAAC,EAAE,CAAC;IACX,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger, type OnApplicationBootstrap, type OnModuleDestroy } from '@nestjs/common';
|
|
2
|
-
import { type TemporalConnectionOptions } from './connection';
|
|
2
|
+
import { type TemporalConnectionDeps, type TemporalConnectionOptions } from './connection';
|
|
3
3
|
import { Client, Connection, type ClientOptions } from './temporal-sdk';
|
|
4
4
|
export declare abstract class BaseTemporalClientService implements OnApplicationBootstrap, OnModuleDestroy {
|
|
5
5
|
protected readonly logger: Logger;
|
|
@@ -7,7 +7,8 @@ export declare abstract class BaseTemporalClientService implements OnApplication
|
|
|
7
7
|
private client;
|
|
8
8
|
private resolvedNamespace;
|
|
9
9
|
protected abstract resolveNamespace(): string;
|
|
10
|
-
protected resolveConnectionOptions(): TemporalConnectionOptions;
|
|
10
|
+
protected abstract resolveConnectionOptions(): TemporalConnectionOptions;
|
|
11
|
+
protected resolveConnectionDeps(): TemporalConnectionDeps;
|
|
11
12
|
protected resolveClientOptions(): Omit<ClientOptions, 'connection' | 'namespace'> | undefined;
|
|
12
13
|
onApplicationBootstrap(): Promise<void>;
|
|
13
14
|
onModuleDestroy(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-temporal-client.service.d.ts","sourceRoot":"","sources":["../../src/lib/base-temporal-client.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"base-temporal-client.service.d.ts","sourceRoot":"","sources":["../../src/lib/base-temporal-client.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAqDxE,8BACsB,yBACpB,YAAW,sBAAsB,EAAE,eAAe;IAElD,SAAS,CAAC,QAAQ,CAAC,MAAM,SAAqC;IAE9D,OAAO,CAAC,UAAU,CAAyC;IAC3D,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,iBAAiB,CAAuB;IAMhD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,IAAI,MAAM;IAO7C,SAAS,CAAC,QAAQ,CAAC,wBAAwB,IAAI,yBAAyB;IAOxE,SAAS,CAAC,qBAAqB,IAAI,sBAAsB;IASzD,SAAS,CAAC,oBAAoB,IAC1B,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAC/C,SAAS;IAIP,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAevC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IActC,SAAS,CAAC,SAAS,IAAI,MAAM;IAW7B,SAAS,CAAC,aAAa,IAAI,UAAU;IAWrC,SAAS,CAAC,YAAY,IAAI,MAAM;CASjC"}
|
|
@@ -15,18 +15,18 @@ let BaseTemporalClientService = class BaseTemporalClientService {
|
|
|
15
15
|
connection = null;
|
|
16
16
|
client = null;
|
|
17
17
|
resolvedNamespace = null;
|
|
18
|
-
|
|
19
|
-
return
|
|
18
|
+
resolveConnectionDeps() {
|
|
19
|
+
return { logger: this.logger };
|
|
20
20
|
}
|
|
21
21
|
resolveClientOptions() {
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
24
|
async onApplicationBootstrap() {
|
|
25
25
|
const namespace = this.resolveNamespace();
|
|
26
|
-
this.connection = await (0, connection_1.connectTemporalClient)(this.resolveConnectionOptions());
|
|
26
|
+
this.connection = await (0, connection_1.connectTemporalClient)(this.resolveConnectionOptions(), this.resolveConnectionDeps());
|
|
27
27
|
this.resolvedNamespace = namespace;
|
|
28
28
|
this.client = new temporal_sdk_1.Client({
|
|
29
|
-
connection: this.connection,
|
|
29
|
+
connection: this.connection.connection,
|
|
30
30
|
namespace,
|
|
31
31
|
...this.resolveClientOptions(),
|
|
32
32
|
});
|
|
@@ -53,7 +53,7 @@ let BaseTemporalClientService = class BaseTemporalClientService {
|
|
|
53
53
|
throw new Error(`${this.constructor.name} is not initialized — getConnection() called ` +
|
|
54
54
|
'before onApplicationBootstrap or after onModuleDestroy.');
|
|
55
55
|
}
|
|
56
|
-
return this.connection;
|
|
56
|
+
return this.connection.connection;
|
|
57
57
|
}
|
|
58
58
|
getNamespace() {
|
|
59
59
|
if (!this.resolvedNamespace) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-temporal-client.service.js","sourceRoot":"","sources":["../../src/lib/base-temporal-client.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAExB,
|
|
1
|
+
{"version":3,"file":"base-tem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AI,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAMS,SAAS;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,2CAA2C;gBACjE,yDAAyD,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGS,aAAa;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,+CAA+C;gBACrE,yDAAyD,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IACpC,CAAC;IAGS,YAAY;QACpB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,8CAA8C;gBACpE,yDAAyD,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;CACF,CAAA;AAtGqB,8DAAyB;oCAAzB,yBAAyB;IAD9C,IAAA,mBAAU,GAAE;GACS,yBAAyB,CAsG9C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { BiomeWorkerTaskQueueFairness, BiomeWorkerTaskQueueServes, type BiomeOrigin } from '@xemahq/contracts/biome';
|
|
2
|
+
import { type LockedNexusBinding } from '@xemahq/contracts/distribution';
|
|
3
|
+
import { type ProcessTrustPolicy } from '@xemahq/contracts/process-topology';
|
|
4
|
+
import { type PlatformWorkerSinks, type PlatformWorkerTuning } from './versioned-worker';
|
|
5
|
+
import { type WorkerDeploymentVersion } from './worker-deployment-version';
|
|
6
|
+
import type { XemaNexusServiceImplementation } from './nexus-handler';
|
|
7
|
+
import type { PayloadCodec } from '@temporalio/common';
|
|
8
|
+
import type { ActivityInterceptorsFactory, NativeConnection, Worker } from '@temporalio/worker';
|
|
9
|
+
export declare enum BiomeWorkerErrorCode {
|
|
10
|
+
ProtocolNotWorkerV2 = "protocol-not-worker-v2",
|
|
11
|
+
ImplementationMismatch = "implementation-mismatch",
|
|
12
|
+
NexusMismatch = "nexus-mismatch",
|
|
13
|
+
InvalidComponentKey = "invalid-component-key",
|
|
14
|
+
DuplicateComponent = "duplicate-component",
|
|
15
|
+
DuplicateTaskQueue = "duplicate-task-queue",
|
|
16
|
+
MixedTrustDomains = "mixed-trust-domains",
|
|
17
|
+
EmptyComposition = "empty-composition",
|
|
18
|
+
NexusLockMissing = "nexus-lock-missing",
|
|
19
|
+
NexusBindingAbsent = "nexus-binding-absent",
|
|
20
|
+
NexusBindingMismatch = "nexus-binding-mismatch"
|
|
21
|
+
}
|
|
22
|
+
export declare class BiomeWorkerError extends Error {
|
|
23
|
+
readonly code: BiomeWorkerErrorCode;
|
|
24
|
+
constructor(code: BiomeWorkerErrorCode, message: string);
|
|
25
|
+
}
|
|
26
|
+
export interface DefineBiomeWorkerOptions {
|
|
27
|
+
readonly biomeId: string;
|
|
28
|
+
readonly componentKey: string;
|
|
29
|
+
readonly origin: BiomeOrigin;
|
|
30
|
+
readonly protocol: unknown;
|
|
31
|
+
readonly workflowsPath?: string;
|
|
32
|
+
readonly activities?: object;
|
|
33
|
+
readonly nexusServices?: readonly XemaNexusServiceImplementation[];
|
|
34
|
+
readonly workflowInterceptorModules?: readonly string[];
|
|
35
|
+
readonly activityInterceptors?: readonly ActivityInterceptorsFactory[];
|
|
36
|
+
readonly payloadCodec?: PayloadCodec;
|
|
37
|
+
readonly sinks?: PlatformWorkerSinks;
|
|
38
|
+
readonly tuning?: PlatformWorkerTuning;
|
|
39
|
+
}
|
|
40
|
+
export interface BiomeWorkerQueue {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly taskQueue: string;
|
|
43
|
+
readonly serves: readonly BiomeWorkerTaskQueueServes[];
|
|
44
|
+
readonly fairness: BiomeWorkerTaskQueueFairness;
|
|
45
|
+
readonly nexusServices: readonly XemaNexusServiceImplementation[];
|
|
46
|
+
}
|
|
47
|
+
export interface BiomeNexusRequirement {
|
|
48
|
+
readonly service: string;
|
|
49
|
+
readonly version: string;
|
|
50
|
+
readonly optional: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface BiomeWorkerDefinition {
|
|
53
|
+
readonly biomeId: string;
|
|
54
|
+
readonly componentKey: string;
|
|
55
|
+
readonly origin: BiomeOrigin;
|
|
56
|
+
readonly queues: readonly BiomeWorkerQueue[];
|
|
57
|
+
readonly nexusRequires: readonly BiomeNexusRequirement[];
|
|
58
|
+
readonly workflowsPath?: string;
|
|
59
|
+
readonly activities?: object;
|
|
60
|
+
readonly workflowInterceptorModules: readonly string[];
|
|
61
|
+
readonly activityInterceptors: readonly ActivityInterceptorsFactory[];
|
|
62
|
+
readonly payloadCodec?: PayloadCodec;
|
|
63
|
+
readonly sinks?: PlatformWorkerSinks;
|
|
64
|
+
readonly tuning: PlatformWorkerTuning;
|
|
65
|
+
}
|
|
66
|
+
export declare function defineBiomeWorker(options: DefineBiomeWorkerOptions): BiomeWorkerDefinition;
|
|
67
|
+
export interface ComposeBiomeWorkersOptions {
|
|
68
|
+
readonly connection: NativeConnection;
|
|
69
|
+
readonly deploymentId: string;
|
|
70
|
+
readonly version: WorkerDeploymentVersion;
|
|
71
|
+
readonly trustPolicy?: ProcessTrustPolicy;
|
|
72
|
+
readonly definitions: readonly BiomeWorkerDefinition[];
|
|
73
|
+
readonly lock?: ComposeNexusLock;
|
|
74
|
+
}
|
|
75
|
+
export interface ComposeNexusLock {
|
|
76
|
+
readonly biomes: readonly {
|
|
77
|
+
readonly id: string;
|
|
78
|
+
readonly origin: BiomeOrigin;
|
|
79
|
+
}[];
|
|
80
|
+
readonly nexusBindings?: readonly LockedNexusBinding[];
|
|
81
|
+
}
|
|
82
|
+
export interface ResolvedNexusTopology {
|
|
83
|
+
readonly allowedCallers: ReadonlyMap<string, ReadonlySet<string>>;
|
|
84
|
+
readonly endpoints: ReadonlyMap<string, Readonly<Record<string, string>>>;
|
|
85
|
+
}
|
|
86
|
+
export declare function resolveNexusTopology(options: {
|
|
87
|
+
readonly deploymentId: string;
|
|
88
|
+
readonly trustPolicy?: ProcessTrustPolicy;
|
|
89
|
+
readonly definitions: readonly BiomeWorkerDefinition[];
|
|
90
|
+
readonly lock?: ComposeNexusLock;
|
|
91
|
+
}): ResolvedNexusTopology;
|
|
92
|
+
export interface ComposedBiomeWorker {
|
|
93
|
+
readonly biomeId: string;
|
|
94
|
+
readonly componentKey: string;
|
|
95
|
+
readonly taskQueue: string;
|
|
96
|
+
readonly worker: Worker;
|
|
97
|
+
}
|
|
98
|
+
export interface ComposedBiomeWorkers {
|
|
99
|
+
readonly trustDomain: string;
|
|
100
|
+
readonly namespace: string;
|
|
101
|
+
readonly version: WorkerDeploymentVersion;
|
|
102
|
+
readonly workers: readonly ComposedBiomeWorker[];
|
|
103
|
+
run(): Promise<void>;
|
|
104
|
+
shutdown(): void;
|
|
105
|
+
}
|
|
106
|
+
export declare function composeBiomeWorkers(options: ComposeBiomeWorkersOptions): Promise<ComposedBiomeWorkers>;
|
|
107
|
+
//# sourceMappingURL=biome-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biome-worker.d.ts","sourceRoot":"","sources":["../../src/lib/biome-worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,4BAA4B,EAC5B,0BAA0B,EAC1B,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,oCAAoC,CAAC;AAS5C,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAC1B,MAAM,o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