@xemahq/temporal-runtime 0.1.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/LICENSE +201 -0
- package/README.md +64 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/activity-auth-context.d.ts +8 -0
- package/dist/lib/activity-auth-context.d.ts.map +1 -0
- package/dist/lib/activity-auth-context.js +13 -0
- package/dist/lib/activity-auth-context.js.map +1 -0
- package/dist/lib/auth-kind.d.ts +19 -0
- package/dist/lib/auth-kind.d.ts.map +1 -0
- package/dist/lib/auth-kind.js +11 -0
- package/dist/lib/auth-kind.js.map +1 -0
- package/dist/lib/connection.d.ts +14 -0
- package/dist/lib/connection.d.ts.map +1 -0
- package/dist/lib/connection.js +62 -0
- package/dist/lib/connection.js.map +1 -0
- package/dist/lib/on-behalf-of-interceptor.d.ts +5 -0
- package/dist/lib/on-behalf-of-interceptor.d.ts.map +1 -0
- package/dist/lib/on-behalf-of-interceptor.js +23 -0
- package/dist/lib/on-behalf-of-interceptor.js.map +1 -0
- package/dist/lib/schedule.d.ts +17 -0
- package/dist/lib/schedule.d.ts.map +1 -0
- package/dist/lib/schedule.js +43 -0
- package/dist/lib/schedule.js.map +1 -0
- package/dist/lib/search-attributes.d.ts +28 -0
- package/dist/lib/search-attributes.d.ts.map +1 -0
- package/dist/lib/search-attributes.js +58 -0
- package/dist/lib/search-attributes.js.map +1 -0
- package/dist/lib/service-http-client.d.ts +51 -0
- package/dist/lib/service-http-client.d.ts.map +1 -0
- package/dist/lib/service-http-client.js +178 -0
- package/dist/lib/service-http-client.js.map +1 -0
- package/dist/lib/temporal-sdk.d.ts +4 -0
- package/dist/lib/temporal-sdk.d.ts.map +1 -0
- package/dist/lib/temporal-sdk.js +9 -0
- package/dist/lib/temporal-sdk.js.map +1 -0
- package/dist/lib/worker.d.ts +17 -0
- package/dist/lib/worker.d.ts.map +1 -0
- package/dist/lib/worker.js +39 -0
- package/dist/lib/worker.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend, and
|
|
172
|
+
hold each Contributor harmless for any liability incurred by, or
|
|
173
|
+
claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Xema
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<svg width="680" height="120" viewBox="0 0 680 120" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="@xemahq/temporal-runtime">
|
|
3
|
+
<rect width="680" height="120" rx="14" fill="#0B1020"/>
|
|
4
|
+
<g transform="translate(28,34)">
|
|
5
|
+
<path d="M26 0 L52 15 L52 45 L26 60 L0 45 L0 15 Z" fill="#8B5CF6" opacity="0.18"/>
|
|
6
|
+
<path d="M26 12 L41 21 L41 39 L26 48 L11 39 L11 21 Z" fill="#8B5CF6"/>
|
|
7
|
+
</g>
|
|
8
|
+
<text x="92" y="52" font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="22" fill="#F8FAFC" font-weight="700">@xemahq/temporal-runtime</text>
|
|
9
|
+
<text x="92" y="80" font-family="ui-sans-serif,system-ui,sans-serif" font-size="15" fill="#94A3B8">Shared glue for Temporal workers and clients</text>
|
|
10
|
+
<text x="652" y="105" text-anchor="end" font-family="ui-sans-serif,system-ui,sans-serif" font-size="12" fill="#475569">xema.dev</text>
|
|
11
|
+
</svg>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://xema.dev">Website</a> ·
|
|
16
|
+
<a href="https://www.npmjs.com/package/@xemahq/temporal-runtime">npm</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img alt="npm" src="https://img.shields.io/npm/v/%40xemahq%2Ftemporal-runtime?color=2563eb&label=npm">
|
|
21
|
+
<img alt="license" src="https://img.shields.io/npm/l/%40xemahq%2Ftemporal-runtime?color=10b981">
|
|
22
|
+
<img alt="types" src="https://img.shields.io/npm/types/%40xemahq%2Ftemporal-runtime?color=3178c6">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
# @xemahq/temporal-runtime
|
|
26
|
+
|
|
27
|
+
> Shared glue for Temporal workers and clients
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
Shared runtime glue for services that run Temporal workflow workers or start
|
|
32
|
+
workflows. It provides one battle-tested setup so services do not drift:
|
|
33
|
+
connection handling, an on-behalf-of activity-auth context, a worker factory
|
|
34
|
+
that wires the interceptor and payload codec, an authenticated service HTTP
|
|
35
|
+
client for activities, idempotent schedule reconciliation, and a closed set of
|
|
36
|
+
visibility search attributes.
|
|
37
|
+
|
|
38
|
+
## When to use it
|
|
39
|
+
|
|
40
|
+
- Use it in any service that runs a Temporal worker or starts a workflow.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm add @xemahq/temporal-runtime
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createPlatformWorker } from '@xemahq/temporal-runtime';
|
|
52
|
+
|
|
53
|
+
const worker = await createPlatformWorker(workerOptions);
|
|
54
|
+
await worker.run();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Peer requirements
|
|
58
|
+
|
|
59
|
+
- `@nestjs/common` ^10 || ^11
|
|
60
|
+
- `reflect-metadata` ^0.2
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
Apache-2.0 © Xema — [xema.dev](https://xema.dev)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './lib/connection';
|
|
2
|
+
export * from './lib/activity-auth-context';
|
|
3
|
+
export * from './lib/on-behalf-of-interceptor';
|
|
4
|
+
export * from './lib/worker';
|
|
5
|
+
export * from './lib/auth-kind';
|
|
6
|
+
export * from './lib/service-http-client';
|
|
7
|
+
export * from './lib/schedule';
|
|
8
|
+
export * from './lib/search-attributes';
|
|
9
|
+
export * from './lib/temporal-sdk';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/connection"), exports);
|
|
18
|
+
__exportStar(require("./lib/activity-auth-context"), exports);
|
|
19
|
+
__exportStar(require("./lib/on-behalf-of-interceptor"), exports);
|
|
20
|
+
__exportStar(require("./lib/worker"), exports);
|
|
21
|
+
__exportStar(require("./lib/auth-kind"), exports);
|
|
22
|
+
__exportStar(require("./lib/service-http-client"), exports);
|
|
23
|
+
__exportStar(require("./lib/schedule"), exports);
|
|
24
|
+
__exportStar(require("./lib/search-attributes"), exports);
|
|
25
|
+
__exportStar(require("./lib/temporal-sdk"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAsBA,mDAAiC;AACjC,8DAA4C;AAC5C,iEAA+C;AAC/C,+CAA6B;AAC7B,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,0DAAwC;AACxC,qDAAmC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ActivityAuthContext {
|
|
2
|
+
readonly actorSubject: string | null;
|
|
3
|
+
readonly orgId?: string;
|
|
4
|
+
readonly correlationId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function getActivityAuthContext(): ActivityAuthContext | undefined;
|
|
7
|
+
export declare function runWithActivityAuthContext<T>(context: ActivityAuthContext, fn: () => Promise<T>): Promise<T>;
|
|
8
|
+
//# sourceMappingURL=activity-auth-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-auth-context.d.ts","sourceRoot":"","sources":["../../src/lib/activity-auth-context.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,mBAAmB;IAElC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AASD,wBAAgB,sBAAsB,IAAI,mBAAmB,GAAG,SAAS,CAExE;AAOD,wBAAsB,0BAA0B,CAAC,CAAC,EAChD,OAAO,EAAE,mBAAmB,EAC5B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getActivityAuthContext = getActivityAuthContext;
|
|
4
|
+
exports.runWithActivityAuthContext = runWithActivityAuthContext;
|
|
5
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
6
|
+
const storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
7
|
+
function getActivityAuthContext() {
|
|
8
|
+
return storage.getStore();
|
|
9
|
+
}
|
|
10
|
+
async function runWithActivityAuthContext(context, fn) {
|
|
11
|
+
return storage.run(context, fn);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=activity-auth-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-auth-context.js","sourceRoot":"","sources":["../../src/lib/activity-auth-context.ts"],"names":[],"mappings":";;AAuCA,wDAEC;AAOD,gEAKC;AArDD,uDAAqD;AAgCrD,MAAM,OAAO,GAAG,IAAI,oCAAiB,EAAuB,CAAC;AAO7D,SAAgB,sBAAsB;IACpC,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAOM,KAAK,UAAU,0BAA0B,CAC9C,OAA4B,EAC5B,EAAoB;IAEpB,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum ServiceAuthKind {
|
|
2
|
+
OnBehalfOfActor = "on-behalf-of-actor",
|
|
3
|
+
Service = "service",
|
|
4
|
+
ExternalBearer = "external-bearer",
|
|
5
|
+
None = "none"
|
|
6
|
+
}
|
|
7
|
+
export type ServiceAuthSpec = {
|
|
8
|
+
readonly kind: ServiceAuthKind.OnBehalfOfActor;
|
|
9
|
+
readonly audience?: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: ServiceAuthKind.Service;
|
|
12
|
+
readonly audience?: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: ServiceAuthKind.ExternalBearer;
|
|
15
|
+
readonly token: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: ServiceAuthKind.None;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=auth-kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-kind.d.ts","sourceRoot":"","sources":["../../src/lib/auth-kind.ts"],"names":[],"mappings":"AAmBA,oBAAY,eAAe;IACzB,eAAe,uBAAuB;IACtC,OAAO,YAAY;IACnB,cAAc,oBAAoB;IAQlC,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GACvB;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,eAAe,CAAC;IAE/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;CACrC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceAuthKind = void 0;
|
|
4
|
+
var ServiceAuthKind;
|
|
5
|
+
(function (ServiceAuthKind) {
|
|
6
|
+
ServiceAuthKind["OnBehalfOfActor"] = "on-behalf-of-actor";
|
|
7
|
+
ServiceAuthKind["Service"] = "service";
|
|
8
|
+
ServiceAuthKind["ExternalBearer"] = "external-bearer";
|
|
9
|
+
ServiceAuthKind["None"] = "none";
|
|
10
|
+
})(ServiceAuthKind || (exports.ServiceAuthKind = ServiceAuthKind = {}));
|
|
11
|
+
//# sourceMappingURL=auth-kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-kind.js","sourceRoot":"","sources":["../../src/lib/auth-kind.ts"],"names":[],"mappings":";;;AAmBA,IAAY,eAYX;AAZD,WAAY,eAAe;IACzB,yDAAsC,CAAA;IACtC,sCAAmB,CAAA;IACnB,qDAAkC,CAAA;IAQlC,gCAAa,CAAA;AACf,CAAC,EAZW,eAAe,+BAAf,eAAe,QAY1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Connection } from '@temporalio/client';
|
|
2
|
+
import { NativeConnection } from '@temporalio/worker';
|
|
3
|
+
export interface TemporalConnectionOptions {
|
|
4
|
+
readonly address: string;
|
|
5
|
+
readonly tls?: {
|
|
6
|
+
readonly clientCertPath: string;
|
|
7
|
+
readonly clientKeyPath: string;
|
|
8
|
+
readonly serverName?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function connectTemporalWorker(options: TemporalConnectionOptions): Promise<NativeConnection>;
|
|
12
|
+
export declare function connectTemporalClient(options: TemporalConnectionOptions): Promise<Connection>;
|
|
13
|
+
export declare function resolveTemporalConnectionOptionsFromEnv(): TemporalConnectionOptions;
|
|
14
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/lib/connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAgBtD,MAAM,WAAW,yBAAyB;IAExC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,GAAG,CAAC,EAAE;QACb,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAE/B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AA6BD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,gBAAgB,CAAC,CAQ3B;AAOD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,UAAU,CAAC,CAQrB;AAWD,wBAAgB,uCAAuC,IAAI,yBAAyB,CAyBnF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectTemporalWorker = connectTemporalWorker;
|
|
4
|
+
exports.connectTemporalClient = connectTemporalClient;
|
|
5
|
+
exports.resolveTemporalConnectionOptionsFromEnv = resolveTemporalConnectionOptionsFromEnv;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const client_1 = require("@temporalio/client");
|
|
8
|
+
const worker_1 = require("@temporalio/worker");
|
|
9
|
+
function readTlsPair(tls) {
|
|
10
|
+
return {
|
|
11
|
+
clientCertPair: {
|
|
12
|
+
crt: (0, node_fs_1.readFileSync)(tls.clientCertPath),
|
|
13
|
+
key: (0, node_fs_1.readFileSync)(tls.clientKeyPath),
|
|
14
|
+
},
|
|
15
|
+
...(tls.serverName !== undefined
|
|
16
|
+
? { serverNameOverride: tls.serverName }
|
|
17
|
+
: {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function connectTemporalWorker(options) {
|
|
21
|
+
if (!options.tls) {
|
|
22
|
+
return worker_1.NativeConnection.connect({ address: options.address });
|
|
23
|
+
}
|
|
24
|
+
return worker_1.NativeConnection.connect({
|
|
25
|
+
address: options.address,
|
|
26
|
+
tls: readTlsPair(options.tls),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function connectTemporalClient(options) {
|
|
30
|
+
if (!options.tls) {
|
|
31
|
+
return client_1.Connection.connect({ address: options.address });
|
|
32
|
+
}
|
|
33
|
+
return client_1.Connection.connect({
|
|
34
|
+
address: options.address,
|
|
35
|
+
tls: readTlsPair(options.tls),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function resolveTemporalConnectionOptionsFromEnv() {
|
|
39
|
+
const address = process.env.TEMPORAL_ADDRESS?.trim();
|
|
40
|
+
if (!address) {
|
|
41
|
+
throw new Error('TEMPORAL_ADDRESS is required for a Temporal connection.');
|
|
42
|
+
}
|
|
43
|
+
if (process.env.TEMPORAL_TLS_ENABLED !== 'true') {
|
|
44
|
+
return { address };
|
|
45
|
+
}
|
|
46
|
+
const clientCertPath = process.env.TEMPORAL_TLS_CLIENT_CERT_PATH?.trim();
|
|
47
|
+
const clientKeyPath = process.env.TEMPORAL_TLS_CLIENT_KEY_PATH?.trim();
|
|
48
|
+
if (!clientCertPath || !clientKeyPath) {
|
|
49
|
+
throw new Error('TEMPORAL_TLS_ENABLED=true requires both TEMPORAL_TLS_CLIENT_CERT_PATH ' +
|
|
50
|
+
'and TEMPORAL_TLS_CLIENT_KEY_PATH.');
|
|
51
|
+
}
|
|
52
|
+
const serverName = process.env.TEMPORAL_TLS_SERVER_NAME?.trim();
|
|
53
|
+
return {
|
|
54
|
+
address,
|
|
55
|
+
tls: {
|
|
56
|
+
clientCertPath,
|
|
57
|
+
clientKeyPath,
|
|
58
|
+
...(serverName ? { serverName } : {}),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/lib/connection.ts"],"names":[],"mappings":";;AA0DA,sDAUC;AAOD,sDAUC;AAWD,0FAyBC;AAzHD,qCAAuC;AAEvC,+CAAgD;AAChD,+CAAsD;AAqCtD,SAAS,WAAW,CAClB,GAAkD;IAElD,OAAO;QACL,cAAc,EAAE;YACd,GAAG,EAAE,IAAA,sBAAY,EAAC,GAAG,CAAC,cAAc,CAAC;YACrC,GAAG,EAAE,IAAA,sBAAY,EAAC,GAAG,CAAC,aAAa,CAAC;SACrC;QACD,GAAG,CAAC,GAAG,CAAC,UAAU,KAAK,SAAS;YAC9B,CAAC,CAAC,EAAE,kBAAkB,EAAE,GAAG,CAAC,UAAU,EAAE;YACxC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC;AAMM,KAAK,UAAU,qBAAqB,CACzC,OAAkC;IAElC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACjB,OAAO,yBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,yBAAgB,CAAC,OAAO,CAAC;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC;AAOM,KAAK,UAAU,qBAAqB,CACzC,OAAkC;IAElC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACjB,OAAO,mBAAU,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,mBAAU,CAAC,OAAO,CAAC;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC;AAWD,SAAgB,uCAAuC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM,EAAE,CAAC;QAChD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IACD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,EAAE,CAAC;IACzE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,IAAI,EAAE,CAAC;IACvE,IAAI,CAAC,cAAc,IAAI,CAAC,aAAa,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,wEAAwE;YACtE,mCAAmC,CACtC,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,EAAE,CAAC;IAChE,OAAO;QACL,OAAO;QACP,GAAG,EAAE;YACH,cAAc;YACd,aAAa;YACb,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ActivityExecuteInput, ActivityInboundCallsInterceptor, Next } from '@temporalio/worker';
|
|
2
|
+
export declare class OnBehalfOfActivityInterceptor implements ActivityInboundCallsInterceptor {
|
|
3
|
+
execute(input: ActivityExecuteInput, next: Next<ActivityInboundCallsInterceptor, 'execute'>): Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=on-behalf-of-interceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-behalf-of-interceptor.d.ts","sourceRoot":"","sources":["../../src/lib/on-behalf-of-interceptor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAC/B,IAAI,EACL,MAAM,oBAAoB,CAAC;AAkB5B,qBAAa,6BACX,YAAW,+BAA+B;IAEpC,OAAO,CACX,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,IAAI,CAAC,+BAA+B,EAAE,SAAS,CAAC,GACrD,OAAO,CAAC,OAAO,CAAC;CAIpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnBehalfOfActivityInterceptor = void 0;
|
|
4
|
+
const activity_auth_context_1 = require("./activity-auth-context");
|
|
5
|
+
class OnBehalfOfActivityInterceptor {
|
|
6
|
+
async execute(input, next) {
|
|
7
|
+
const context = extractAuthContext(input);
|
|
8
|
+
return (0, activity_auth_context_1.runWithActivityAuthContext)(context, () => next(input));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.OnBehalfOfActivityInterceptor = OnBehalfOfActivityInterceptor;
|
|
12
|
+
function extractAuthContext(input) {
|
|
13
|
+
const first = input.args[0];
|
|
14
|
+
const ctx = first?.context;
|
|
15
|
+
return {
|
|
16
|
+
actorSubject: ctx?.actorSubject ?? null,
|
|
17
|
+
...(ctx?.orgId !== undefined ? { orgId: ctx.orgId } : {}),
|
|
18
|
+
...(ctx?.correlationId !== undefined
|
|
19
|
+
? { correlationId: ctx.correlationId }
|
|
20
|
+
: {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=on-behalf-of-interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-behalf-of-interceptor.js","sourceRoot":"","sources":["../../src/lib/on-behalf-of-interceptor.ts"],"names":[],"mappings":";;;AAAA,mEAGiC;AAwBjC,MAAa,6BAA6B;IAGxC,KAAK,CAAC,OAAO,CACX,KAA2B,EAC3B,IAAsD;QAEtD,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,IAAA,kDAA0B,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC;CACF;AAVD,sEAUC;AAED,SAAS,kBAAkB,CAAC,KAA2B;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAQb,CAAC;IACd,MAAM,GAAG,GAAG,KAAK,EAAE,OAAO,CAAC;IAC3B,OAAO;QACL,YAAY,EAAE,GAAG,EAAE,YAAY,IAAI,IAAI;QACvC,GAAG,CAAC,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,SAAS;YAClC,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE;YACtC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Client } from '@temporalio/client';
|
|
2
|
+
import type { Duration } from '@temporalio/common';
|
|
3
|
+
export interface PlatformScheduleSpec {
|
|
4
|
+
readonly scheduleId: string;
|
|
5
|
+
readonly every: Duration;
|
|
6
|
+
readonly catchupWindow: Duration;
|
|
7
|
+
readonly workflowType: string;
|
|
8
|
+
readonly taskQueue: string;
|
|
9
|
+
readonly args: readonly unknown[];
|
|
10
|
+
readonly note: string;
|
|
11
|
+
readonly searchAttributes?: Record<string, string[]>;
|
|
12
|
+
}
|
|
13
|
+
export interface UpsertPlatformScheduleResult {
|
|
14
|
+
readonly created: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function upsertPlatformSchedule(client: Client, spec: PlatformScheduleSpec): Promise<UpsertPlatformScheduleResult>;
|
|
17
|
+
//# sourceMappingURL=schedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../src/lib/schedule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,oBAAoB,CAAC;AAW7D,MAAM,WAAW,oBAAoB;IAEnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAKzB,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IAEjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAM3B,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAMlC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAOtB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACtD;AAGD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAaD,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,4BAA4B,CAAC,CA+CvC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upsertPlatformSchedule = upsertPlatformSchedule;
|
|
4
|
+
const client_1 = require("@temporalio/client");
|
|
5
|
+
async function upsertPlatformSchedule(client, spec) {
|
|
6
|
+
const definition = {
|
|
7
|
+
spec: { intervals: [{ every: spec.every }] },
|
|
8
|
+
action: {
|
|
9
|
+
type: 'startWorkflow',
|
|
10
|
+
workflowType: spec.workflowType,
|
|
11
|
+
taskQueue: spec.taskQueue,
|
|
12
|
+
args: spec.args,
|
|
13
|
+
workflowId: spec.scheduleId,
|
|
14
|
+
...(spec.searchAttributes
|
|
15
|
+
? { searchAttributes: spec.searchAttributes }
|
|
16
|
+
: {}),
|
|
17
|
+
},
|
|
18
|
+
policies: {
|
|
19
|
+
overlap: 'SKIP',
|
|
20
|
+
catchupWindow: spec.catchupWindow,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
await client.schedule.create({
|
|
25
|
+
scheduleId: spec.scheduleId,
|
|
26
|
+
...definition,
|
|
27
|
+
state: { paused: false, note: spec.note },
|
|
28
|
+
});
|
|
29
|
+
return { created: true };
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (!(err instanceof client_1.ScheduleAlreadyRunning)) {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
const handle = client.schedule.getHandle(spec.scheduleId);
|
|
36
|
+
await handle.update((previous) => ({
|
|
37
|
+
...definition,
|
|
38
|
+
state: { paused: previous.state.paused, note: previous.state.note },
|
|
39
|
+
}));
|
|
40
|
+
return { created: false };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=schedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../src/lib/schedule.ts"],"names":[],"mappings":";;AAiEA,wDAkDC;AAnHD,+CAA4D;AAiErD,KAAK,UAAU,sBAAsB,CAC1C,MAAc,EACd,IAA0B;IAE1B,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE;QAC5C,MAAM,EAAE;YACN,IAAI,EAAE,eAAwB;YAC9B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAA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} from '@temporalio/client';
|
|
3
|
+
import type { PlatformWorkflowDomain } from '@xemahq/kernel-contracts/workflow';
|
|
4
|
+
export declare const SEARCH_ATTR_ORG_ID = "OrgId";
|
|
5
|
+
export declare const SEARCH_ATTR_PROJECT_ID = "ProjectId";
|
|
6
|
+
export declare const SEARCH_ATTR_WORKFLOW_DOMAIN = "WorkflowDomain";
|
|
7
|
+
export declare const SEARCH_ATTR_SUBJECT_ID = "SubjectId";
|
|
8
|
+
export declare const SEARCH_ATTR_INTEGRATION_PROVIDER_ID = "IntegrationProviderId";
|
|
9
|
+
export declare const SEARCH_ATTR_REGISTRY_KIND = "RegistryKind";
|
|
10
|
+
export declare const SEARCH_ATTR_IMAGE_DIGEST = "ImageDigest";
|
|
11
|
+
interface PlatformSearchAttribute {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly type: temporal.api.enums.v1.IndexedValueType;
|
|
14
|
+
}
|
|
15
|
+
export declare const PLATFORM_SEARCH_ATTRIBUTES: readonly PlatformSearchAttribute[];
|
|
16
|
+
export interface PlatformSearchAttributeInput {
|
|
17
|
+
readonly workflowDomain: PlatformWorkflowDomain;
|
|
18
|
+
readonly orgId?: string;
|
|
19
|
+
readonly projectId?: string;
|
|
20
|
+
readonly subjectId?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function buildPlatformSearchAttributes(input: PlatformSearchAttributeInput): Record<string, string[]>;
|
|
23
|
+
export interface RegisterSearchAttributesResult {
|
|
24
|
+
readonly registered: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export declare function registerPlatformSearchAttributes(connection: Connection, namespace: string): Promise<RegisterSearchAttributesResult>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=search-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-attributes.d.ts","sourceRoot":"","sources":["../../src/lib/search-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC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.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLATFORM_SEARCH_ATTRIBUTES = exports.SEARCH_ATTR_IMAGE_DIGEST = exports.SEARCH_ATTR_REGISTRY_KIND = exports.SEARCH_ATTR_INTEGRATION_PROVIDER_ID = exports.SEARCH_ATTR_SUBJECT_ID = exports.SEARCH_ATTR_WORKFLOW_DOMAIN = exports.SEARCH_ATTR_PROJECT_ID = exports.SEARCH_ATTR_ORG_ID = void 0;
|
|
4
|
+
exports.buildPlatformSearchAttributes = buildPlatformSearchAttributes;
|
|
5
|
+
exports.registerPlatformSearchAttributes = registerPlatformSearchAttributes;
|
|
6
|
+
const proto_1 = require("@temporalio/proto");
|
|
7
|
+
exports.SEARCH_ATTR_ORG_ID = 'OrgId';
|
|
8
|
+
exports.SEARCH_ATTR_PROJECT_ID = 'ProjectId';
|
|
9
|
+
exports.SEARCH_ATTR_WORKFLOW_DOMAIN = 'WorkflowDomain';
|
|
10
|
+
exports.SEARCH_ATTR_SUBJECT_ID = 'SubjectId';
|
|
11
|
+
exports.SEARCH_ATTR_INTEGRATION_PROVIDER_ID = 'IntegrationProviderId';
|
|
12
|
+
exports.SEARCH_ATTR_REGISTRY_KIND = 'RegistryKind';
|
|
13
|
+
exports.SEARCH_ATTR_IMAGE_DIGEST = 'ImageDigest';
|
|
14
|
+
const KEYWORD = proto_1.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD;
|
|
15
|
+
exports.PLATFORM_SEARCH_ATTRIBUTES = [
|
|
16
|
+
{ name: exports.SEARCH_ATTR_ORG_ID, type: KEYWORD },
|
|
17
|
+
{ name: exports.SEARCH_ATTR_PROJECT_ID, type: KEYWORD },
|
|
18
|
+
{ name: exports.SEARCH_ATTR_WORKFLOW_DOMAIN, type: KEYWORD },
|
|
19
|
+
{ name: exports.SEARCH_ATTR_SUBJECT_ID, type: KEYWORD },
|
|
20
|
+
{ name: exports.SEARCH_ATTR_INTEGRATION_PROVIDER_ID, type: KEYWORD },
|
|
21
|
+
{ name: exports.SEARCH_ATTR_REGISTRY_KIND, type: KEYWORD },
|
|
22
|
+
{ name: exports.SEARCH_ATTR_IMAGE_DIGEST, type: KEYWORD },
|
|
23
|
+
];
|
|
24
|
+
function buildPlatformSearchAttributes(input) {
|
|
25
|
+
const attrs = {
|
|
26
|
+
[exports.SEARCH_ATTR_WORKFLOW_DOMAIN]: [input.workflowDomain],
|
|
27
|
+
};
|
|
28
|
+
if (input.orgId) {
|
|
29
|
+
attrs[exports.SEARCH_ATTR_ORG_ID] = [input.orgId];
|
|
30
|
+
}
|
|
31
|
+
if (input.projectId) {
|
|
32
|
+
attrs[exports.SEARCH_ATTR_PROJECT_ID] = [input.projectId];
|
|
33
|
+
}
|
|
34
|
+
if (input.subjectId) {
|
|
35
|
+
attrs[exports.SEARCH_ATTR_SUBJECT_ID] = [input.subjectId];
|
|
36
|
+
}
|
|
37
|
+
return attrs;
|
|
38
|
+
}
|
|
39
|
+
async function registerPlatformSearchAttributes(connection, namespace) {
|
|
40
|
+
const listResponse = await connection.operatorService.listSearchAttributes({
|
|
41
|
+
namespace,
|
|
42
|
+
});
|
|
43
|
+
const existing = new Set(Object.keys(listResponse.customAttributes ?? {}));
|
|
44
|
+
const missing = exports.PLATFORM_SEARCH_ATTRIBUTES.filter((attr) => !existing.has(attr.name));
|
|
45
|
+
if (missing.length === 0) {
|
|
46
|
+
return { registered: [] };
|
|
47
|
+
}
|
|
48
|
+
const searchAttributes = {};
|
|
49
|
+
for (const attr of missing) {
|
|
50
|
+
searchAttributes[attr.name] = attr.type;
|
|
51
|
+
}
|
|
52
|
+
await connection.operatorService.addSearchAttributes({
|
|
53
|
+
namespace,
|
|
54
|
+
searchAttributes,
|
|
55
|
+
});
|
|
56
|
+
return { registered: missing.map((attr) => attr.name) };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=search-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-attributes.js","sourceR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-0,0 +1,51 @@
|
|
|
1
|
+
import { IdentityBootstrapService } from '@xemahq/identity-client';
|
|
2
|
+
import { type ServiceAuthSpec } from './auth-kind';
|
|
3
|
+
export interface ServiceRequest {
|
|
4
|
+
readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
7
|
+
readonly body?: string | Uint8Array | null;
|
|
8
|
+
readonly timeoutMs?: number;
|
|
9
|
+
readonly auth: ServiceAuthSpec;
|
|
10
|
+
readonly orgId?: string;
|
|
11
|
+
readonly projectId?: string;
|
|
12
|
+
readonly correlationId?: string;
|
|
13
|
+
readonly actorSubject?: string | null;
|
|
14
|
+
readonly pipelineRunId?: string;
|
|
15
|
+
readonly pipelinePhaseKey?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ServiceResponse<TBody = unknown> {
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
20
|
+
readonly body: TBody;
|
|
21
|
+
readonly rawBody: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ServiceHttpClientOptions {
|
|
24
|
+
readonly defaultTimeoutMs?: number;
|
|
25
|
+
readonly correlationIdFactory?: () => string;
|
|
26
|
+
}
|
|
27
|
+
export declare class ServiceHttpClient {
|
|
28
|
+
private readonly identity;
|
|
29
|
+
private readonly logger;
|
|
30
|
+
private readonly defaultTimeoutMs;
|
|
31
|
+
private readonly correlationIdFactory;
|
|
32
|
+
constructor(identity: IdentityBootstrapService, options?: ServiceHttpClientOptions);
|
|
33
|
+
request<TBody = unknown>(req: ServiceRequest): Promise<ServiceResponse<TBody>>;
|
|
34
|
+
requestJsonOrThrow<TBody = unknown>(req: ServiceRequest): Promise<TBody>;
|
|
35
|
+
private resolveToken;
|
|
36
|
+
private buildHeaders;
|
|
37
|
+
private parseBody;
|
|
38
|
+
}
|
|
39
|
+
export declare class ServiceHttpError extends Error {
|
|
40
|
+
readonly status: number;
|
|
41
|
+
readonly rawBody: string;
|
|
42
|
+
readonly method: string;
|
|
43
|
+
readonly url: string;
|
|
44
|
+
constructor(message: string, details: {
|
|
45
|
+
status: number;
|
|
46
|
+
rawBody: string;
|
|
47
|
+
method?: string;
|
|
48
|
+
url?: string;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=service-http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-http-client.d.ts","sourceRoot":"","sources":["../../src/lib/service-http-client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAQpE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAE3C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAK5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAOhC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAStC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAOhC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;A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E,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE;CAU9E"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var ServiceHttpClient_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ServiceHttpError = exports.ServiceHttpClient = void 0;
|
|
17
|
+
const node_crypto_1 = require("node:crypto");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const identity_client_1 = require("@xemahq/identity-client");
|
|
20
|
+
const activity_auth_context_1 = require("./activity-auth-context");
|
|
21
|
+
const auth_kind_1 = require("./auth-kind");
|
|
22
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
23
|
+
let ServiceHttpClient = ServiceHttpClient_1 = class ServiceHttpClient {
|
|
24
|
+
identity;
|
|
25
|
+
logger = new common_1.Logger(ServiceHttpClient_1.name);
|
|
26
|
+
defaultTimeoutMs;
|
|
27
|
+
correlationIdFactory;
|
|
28
|
+
constructor(identity, options) {
|
|
29
|
+
this.identity = identity;
|
|
30
|
+
this.defaultTimeoutMs = options?.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
31
|
+
this.correlationIdFactory = options?.correlationIdFactory ?? defaultCorrelationIdFactory;
|
|
32
|
+
}
|
|
33
|
+
async request(req) {
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
const timeoutMs = req.timeoutMs ?? this.defaultTimeoutMs;
|
|
36
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
37
|
+
const authToken = await this.resolveToken(req.auth);
|
|
38
|
+
const headers = this.buildHeaders(req, authToken);
|
|
39
|
+
const init = {
|
|
40
|
+
method: req.method,
|
|
41
|
+
headers,
|
|
42
|
+
signal: controller.signal,
|
|
43
|
+
...(req.body !== undefined && req.body !== null && {
|
|
44
|
+
body: typeof req.body === 'string'
|
|
45
|
+
? req.body
|
|
46
|
+
: Buffer.from(req.body.buffer, req.body.byteOffset, req.body.byteLength),
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
const response = await fetch(req.url, init);
|
|
51
|
+
const rawBody = await response.text();
|
|
52
|
+
const body = this.parseBody(rawBody, response);
|
|
53
|
+
const outHeaders = {};
|
|
54
|
+
response.headers.forEach((value, key) => {
|
|
55
|
+
outHeaders[key] = value;
|
|
56
|
+
});
|
|
57
|
+
this.logger.debug(`${req.method} ${req.url} → ${response.status} (${rawBody.length} bytes)`);
|
|
58
|
+
return {
|
|
59
|
+
status: response.status,
|
|
60
|
+
headers: outHeaders,
|
|
61
|
+
body,
|
|
62
|
+
rawBody,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async requestJsonOrThrow(req) {
|
|
70
|
+
const response = await this.request(req);
|
|
71
|
+
if (response.status < 200 || response.status >= 300) {
|
|
72
|
+
throw new ServiceHttpError(`${req.method} ${req.url} failed with status ${response.status}`, {
|
|
73
|
+
status: response.status,
|
|
74
|
+
rawBody: response.rawBody,
|
|
75
|
+
method: req.method,
|
|
76
|
+
url: req.url,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return response.body;
|
|
80
|
+
}
|
|
81
|
+
async resolveToken(spec) {
|
|
82
|
+
switch (spec.kind) {
|
|
83
|
+
case auth_kind_1.ServiceAuthKind.OnBehalfOfActor: {
|
|
84
|
+
const actor = (0, activity_auth_context_1.getActivityAuthContext)();
|
|
85
|
+
if (actor?.actorSubject) {
|
|
86
|
+
if (!actor.orgId) {
|
|
87
|
+
throw new Error('Activity auth context missing orgId for on-behalf-of token mint');
|
|
88
|
+
}
|
|
89
|
+
const params = spec.audience !== undefined
|
|
90
|
+
? {
|
|
91
|
+
userId: actor.actorSubject,
|
|
92
|
+
orgId: actor.orgId,
|
|
93
|
+
audience: spec.audience,
|
|
94
|
+
}
|
|
95
|
+
: { userId: actor.actorSubject, orgId: actor.orgId };
|
|
96
|
+
return this.identity.getUserAccessToken(params);
|
|
97
|
+
}
|
|
98
|
+
return this.identity.getAccessToken();
|
|
99
|
+
}
|
|
100
|
+
case auth_kind_1.ServiceAuthKind.Service:
|
|
101
|
+
return this.identity.getAccessToken();
|
|
102
|
+
case auth_kind_1.ServiceAuthKind.ExternalBearer:
|
|
103
|
+
return spec.token;
|
|
104
|
+
case auth_kind_1.ServiceAuthKind.None:
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
buildHeaders(req, authToken) {
|
|
109
|
+
const headers = new Headers(req.headers ?? {});
|
|
110
|
+
if (authToken !== null) {
|
|
111
|
+
headers.set('Authorization', `Bearer ${authToken}`);
|
|
112
|
+
}
|
|
113
|
+
if (req.orgId) {
|
|
114
|
+
headers.set('X-Org-Id', req.orgId);
|
|
115
|
+
}
|
|
116
|
+
if (req.projectId) {
|
|
117
|
+
headers.set('X-Project-Id', req.projectId);
|
|
118
|
+
}
|
|
119
|
+
if (req.pipelineRunId) {
|
|
120
|
+
headers.set('X-Pipeline-Run-Id', req.pipelineRunId);
|
|
121
|
+
}
|
|
122
|
+
if (req.pipelinePhaseKey) {
|
|
123
|
+
headers.set('X-Pipeline-Phase-Key', req.pipelinePhaseKey);
|
|
124
|
+
}
|
|
125
|
+
headers.set('X-Correlation-Id', req.correlationId ?? this.correlationIdFactory());
|
|
126
|
+
const actorSubject = req.actorSubject !== undefined
|
|
127
|
+
? req.actorSubject
|
|
128
|
+
: ((0, activity_auth_context_1.getActivityAuthContext)()?.actorSubject ?? null);
|
|
129
|
+
if (actorSubject) {
|
|
130
|
+
headers.set('X-Xema-Actor-Subject', actorSubject);
|
|
131
|
+
}
|
|
132
|
+
if (!headers.has('Content-Type') && req.body !== undefined && req.body !== null) {
|
|
133
|
+
headers.set('Content-Type', typeof req.body === 'string' ? 'application/json' : 'application/octet-stream');
|
|
134
|
+
}
|
|
135
|
+
return headers;
|
|
136
|
+
}
|
|
137
|
+
parseBody(raw, response) {
|
|
138
|
+
if (raw.length === 0) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
142
|
+
if (contentType.includes('application/json')) {
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(raw);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
throw new ServiceHttpError(`Failed to parse JSON response: ${err.message}`, { status: response.status, rawBody: raw });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return raw;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
exports.ServiceHttpClient = ServiceHttpClient;
|
|
154
|
+
exports.ServiceHttpClient = ServiceHttpClient = ServiceHttpClient_1 = __decorate([
|
|
155
|
+
(0, common_1.Injectable)(),
|
|
156
|
+
__param(1, (0, common_1.Optional)()),
|
|
157
|
+
__metadata("design:paramtypes", [identity_client_1.IdentityBootstrapService, Object])
|
|
158
|
+
], ServiceHttpClient);
|
|
159
|
+
class ServiceHttpError extends Error {
|
|
160
|
+
status;
|
|
161
|
+
rawBody;
|
|
162
|
+
method;
|
|
163
|
+
url;
|
|
164
|
+
constructor(message, details) {
|
|
165
|
+
super(message);
|
|
166
|
+
this.name = 'ServiceHttpError';
|
|
167
|
+
this.status = details.status;
|
|
168
|
+
this.rawBody = details.rawBody;
|
|
169
|
+
this.method = details.method ?? '';
|
|
170
|
+
this.url = details.url ?? '';
|
|
171
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.ServiceHttpError = ServiceHttpError;
|
|
175
|
+
function defaultCorrelationIdFactory() {
|
|
176
|
+
return `urn:xema:${(0, node_crypto_1.randomUUID)()}`;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=service-http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-http-client.js","sourceRoot":"","sources":["../../src/lib/service-http-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAAyC;AAEzC,2CAA8D;AAC9D,6DAAmE;AAEnE,mEAAiE;AACjE,2CAAoE;AAkEpE,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAyB3B,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAMT;IALF,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAC5C,gBAAgB,CAAS;IACzB,oBAAoB,CAAe;IAEpD,YACmB,QAAkC,EACvC,OAAkC;QAD7B,aAAQ,GAAR,QAAQ,CAA0B;QAGnD,IAAI,CAAC,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,IAAI,kBAAkB,CAAC;QACxE,IAAI,CAAC,oBAAoB,GAAG,OAAO,EAAE,oBAAoB,IAAI,2BAA2B,CAAC;IAC3F,CAAC;IAED,KAAK,CAAC,OAAO,C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
|
1
|
+
export { Client, Connection, ScheduleAlreadyRunning, WorkflowExecutionAlreadyStartedError, } from '@temporalio/client';
|
|
2
|
+
export type { ClientOptions, ConnectionOptions, WorkflowExecutionStatusName, } from '@temporalio/client';
|
|
3
|
+
export type { Duration, Workflow } from '@temporalio/common';
|
|
4
|
+
//# sourceMappingURL=temporal-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal-sdk.d.ts","sourceRoot":"","sources":["../../src/lib/temporal-sdk.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,MAAM,EACN,UAAU,EACV,sBAAsB,EACtB,oCAAoC,GACrC,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowExecutionAlreadyStartedError = exports.ScheduleAlreadyRunning = exports.Connection = exports.Client = void 0;
|
|
4
|
+
var client_1 = require("@temporalio/client");
|
|
5
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
6
|
+
Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return client_1.Connection; } });
|
|
7
|
+
Object.defineProperty(exports, "ScheduleAlreadyRunning", { enumerable: true, get: function () { return client_1.ScheduleAlreadyRunning; } });
|
|
8
|
+
Object.defineProperty(exports, "WorkflowExecutionAlreadyStartedError", { enumerable: true, get: function () { return client_1.WorkflowExecutionAlreadyStartedError; } });
|
|
9
|
+
//# sourceMappingURL=temporal-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal-sdk.js","sourceRoot":"","sources":["../../src/lib/temporal-sdk.ts"],"names":[],"mappings":";;;AAmBA,6CAK4B;AAJ1B,gGAAA,MAAM,OAAA;AACN,oGAAA,UAAU,OAAA;AACV,gHAAA,sBAAsB,OAAA;AACtB,8HAAA,oCAAoC,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Worker, type NativeConnection, type WorkflowBundle } from '@temporalio/worker';
|
|
2
|
+
import type { PayloadCodec } from '@temporalio/common';
|
|
3
|
+
export declare function bundlePlatformWorkflows(workflowsPath: string): Promise<WorkflowBundle>;
|
|
4
|
+
export interface PlatformWorkerOptions {
|
|
5
|
+
readonly connection: NativeConnection;
|
|
6
|
+
readonly namespace: string;
|
|
7
|
+
readonly taskQueue: string;
|
|
8
|
+
readonly workflowBundle: WorkflowBundle;
|
|
9
|
+
readonly activities: object;
|
|
10
|
+
readonly buildId: string;
|
|
11
|
+
readonly useVersioning?: boolean;
|
|
12
|
+
readonly payloadCodec?: PayloadCodec;
|
|
13
|
+
readonly maxConcurrentActivityTaskExecutions?: number;
|
|
14
|
+
readonly maxConcurrentWorkflowTaskExecutions?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function createPlatformWorker(options: PlatformWorkerOptions): Promise<Worker>;
|
|
17
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/lib/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,MAAM,EACN,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOvD,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,MAAM,WAAW,qBAAqB;IAEpC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAEtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAExC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAK5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAKjC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,mCAAmC,CAAC,EAAE,MAAM,CAAC;IACtD,QAAQ,CAAC,mCAAmC,CAAC,EAAE,MAAM,CAAC;CACvD;AAYD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundlePlatformWorkflows = bundlePlatformWorkflows;
|
|
4
|
+
exports.createPlatformWorker = createPlatformWorker;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const worker_1 = require("@temporalio/worker");
|
|
7
|
+
const on_behalf_of_interceptor_1 = require("./on-behalf-of-interceptor");
|
|
8
|
+
async function bundlePlatformWorkflows(workflowsPath) {
|
|
9
|
+
return (0, worker_1.bundleWorkflowCode)({ workflowsPath });
|
|
10
|
+
}
|
|
11
|
+
async function createPlatformWorker(options) {
|
|
12
|
+
return worker_1.Worker.create({
|
|
13
|
+
connection: options.connection,
|
|
14
|
+
namespace: options.namespace,
|
|
15
|
+
taskQueue: options.taskQueue,
|
|
16
|
+
workflowBundle: options.workflowBundle,
|
|
17
|
+
activities: options.activities,
|
|
18
|
+
identity: `xema-platform-worker-${options.namespace}-${options.taskQueue}-${(0, node_crypto_1.randomUUID)().slice(0, 8)}`,
|
|
19
|
+
interceptors: {
|
|
20
|
+
activity: [() => ({ inbound: new on_behalf_of_interceptor_1.OnBehalfOfActivityInterceptor() })],
|
|
21
|
+
},
|
|
22
|
+
buildId: options.buildId,
|
|
23
|
+
useVersioning: options.useVersioning ?? false,
|
|
24
|
+
...(options.payloadCodec
|
|
25
|
+
? { dataConverter: { payloadCodecs: [options.payloadCodec] } }
|
|
26
|
+
: {}),
|
|
27
|
+
...(options.maxConcurrentActivityTaskExecutions !== undefined
|
|
28
|
+
? {
|
|
29
|
+
maxConcurrentActivityTaskExecutions: options.maxConcurrentActivityTaskExecutions,
|
|
30
|
+
}
|
|
31
|
+
: {}),
|
|
32
|
+
...(options.maxConcurrentWorkflowTaskExecutions !== undefined
|
|
33
|
+
? {
|
|
34
|
+
maxConcurrentWorkflowTaskExecutions: options.maxConcurrentWorkflowTaskExecutions,
|
|
35
|
+
}
|
|
36
|
+
: {}),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/lib/worker.ts"],"names":[],"mappings":";;AAkBA,0DAIC;AAsCD,oDA+BC;AA3FD,6CAAyC;AAEzC,+CAK4B;AAE5B,yEAA2E;AASpE,KAAK,UAAU,uBAAuB,CAC3C,aAAqB;IAErB,OAAO,IAAA,2BAAkB,EAAC,EAAE,aAAa,EAAE,CAAC,CAAC;AAC/C,CAAC;AAsCM,KAAK,UAAU,oBAAoB,CACxC,OAA8B;IAE9B,OAAO,eAAM,CAAC,MAAM,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,QAAQ,EAAE,wBAAwB,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,IAAI,IAAA,wBAAU,GAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACtG,YAAY,EAAE;YACZ,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,wDAA6B,EAAE,EAAE,CAAC,CAAC;SACrE;QACD,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,KAAK;QAC7C,GAAG,CAAC,OAAO,CAAC,YAAY;YACtB,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,aAAa,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE;YAC9D,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,OAAO,CAAC,mCAAmC,KAAK,SAAS;YAC3D,CAAC,CAAC;gBACE,mCAAmC,EACjC,OAAO,CAAC,mCAAmC;aAC9C;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,OAAO,CAAC,mCAAmC,KAAK,SAAS;YAC3D,CAAC,CAAC;gBACE,mCAAmC,EACjC,OAAO,CAAC,mCAAmC;aAC9C;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xemahq/temporal-runtime",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"registry": "https://npm.pkg.github.com"
|
|
6
|
+
},
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@nestjs/common": "11.1.13",
|
|
14
|
+
"@types/node": "25.2.3",
|
|
15
|
+
"prettier": "3.6.2",
|
|
16
|
+
"reflect-metadata": "0.2.2",
|
|
17
|
+
"typescript": "5.9.3"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@nestjs/common": "^10 || ^11",
|
|
21
|
+
"reflect-metadata": "^0.2"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@temporalio/client": "^1.16.2",
|
|
25
|
+
"@temporalio/common": "^1.16.2",
|
|
26
|
+
"@temporalio/proto": "^1.16.2",
|
|
27
|
+
"@temporalio/worker": "^1.16.2",
|
|
28
|
+
"@xemahq/identity-client": "^0.3.2",
|
|
29
|
+
"@xemahq/kernel-contracts": "^0.2.0"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"xema-source": "./src/index.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./dist/lib/*": {
|
|
38
|
+
"types": "./dist/lib/*.d.ts",
|
|
39
|
+
"default": "./dist/lib/*.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "rm -rf dist",
|
|
44
|
+
"build": "tsc -p tsconfig.json",
|
|
45
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
47
|
+
}
|
|
48
|
+
}
|