@burdenoff/be-sdk 2026.510.79

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.
Files changed (220) hide show
  1. package/README.md +173 -0
  2. package/configs/eslint/index.js +492 -0
  3. package/configs/tsconfig/tsconfig.json +53 -0
  4. package/dist/EventQueueFactory-6NMSGECR.js +8 -0
  5. package/dist/EventQueueFactory-6NMSGECR.js.map +1 -0
  6. package/dist/auth/index.d.ts +66 -0
  7. package/dist/auth/index.js +8 -0
  8. package/dist/auth/index.js.map +1 -0
  9. package/dist/cache/index.d.ts +2 -0
  10. package/dist/cache/index.js +6 -0
  11. package/dist/cache/index.js.map +1 -0
  12. package/dist/captcha/index.d.ts +1 -0
  13. package/dist/captcha/index.js +4 -0
  14. package/dist/captcha/index.js.map +1 -0
  15. package/dist/chunk-2HANKZZM.js +245 -0
  16. package/dist/chunk-2HANKZZM.js.map +1 -0
  17. package/dist/chunk-2SD5L2F2.js +816 -0
  18. package/dist/chunk-2SD5L2F2.js.map +1 -0
  19. package/dist/chunk-3O2RQOPV.js +1068 -0
  20. package/dist/chunk-3O2RQOPV.js.map +1 -0
  21. package/dist/chunk-4B43DZIS.js +560 -0
  22. package/dist/chunk-4B43DZIS.js.map +1 -0
  23. package/dist/chunk-4XAEES25.js +2444 -0
  24. package/dist/chunk-4XAEES25.js.map +1 -0
  25. package/dist/chunk-4XGGWW36.js +1405 -0
  26. package/dist/chunk-4XGGWW36.js.map +1 -0
  27. package/dist/chunk-5LXDPGDH.js +245 -0
  28. package/dist/chunk-5LXDPGDH.js.map +1 -0
  29. package/dist/chunk-AI7L22ZJ.js +472 -0
  30. package/dist/chunk-AI7L22ZJ.js.map +1 -0
  31. package/dist/chunk-CBZNP6RF.js +286 -0
  32. package/dist/chunk-CBZNP6RF.js.map +1 -0
  33. package/dist/chunk-ELLX3K54.js +613 -0
  34. package/dist/chunk-ELLX3K54.js.map +1 -0
  35. package/dist/chunk-F5XEAGHQ.js +1875 -0
  36. package/dist/chunk-F5XEAGHQ.js.map +1 -0
  37. package/dist/chunk-FNZEQOJY.js +628 -0
  38. package/dist/chunk-FNZEQOJY.js.map +1 -0
  39. package/dist/chunk-GTEMQXCA.js +516 -0
  40. package/dist/chunk-GTEMQXCA.js.map +1 -0
  41. package/dist/chunk-HIWTWIGQ.js +226 -0
  42. package/dist/chunk-HIWTWIGQ.js.map +1 -0
  43. package/dist/chunk-IYE2NTRX.js +764 -0
  44. package/dist/chunk-IYE2NTRX.js.map +1 -0
  45. package/dist/chunk-J26YGR2U.js +1484 -0
  46. package/dist/chunk-J26YGR2U.js.map +1 -0
  47. package/dist/chunk-JG2FTZPI.js +509 -0
  48. package/dist/chunk-JG2FTZPI.js.map +1 -0
  49. package/dist/chunk-JVBTNSPG.js +1551 -0
  50. package/dist/chunk-JVBTNSPG.js.map +1 -0
  51. package/dist/chunk-L7ZMN2FJ.js +12 -0
  52. package/dist/chunk-L7ZMN2FJ.js.map +1 -0
  53. package/dist/chunk-M5IMU3US.js +473 -0
  54. package/dist/chunk-M5IMU3US.js.map +1 -0
  55. package/dist/chunk-MLW2HPS5.js +1267 -0
  56. package/dist/chunk-MLW2HPS5.js.map +1 -0
  57. package/dist/chunk-MNCGUYLJ.js +269 -0
  58. package/dist/chunk-MNCGUYLJ.js.map +1 -0
  59. package/dist/chunk-MOCUBSTW.js +373 -0
  60. package/dist/chunk-MOCUBSTW.js.map +1 -0
  61. package/dist/chunk-NGMEI42S.js +103 -0
  62. package/dist/chunk-NGMEI42S.js.map +1 -0
  63. package/dist/chunk-NUB5GQTU.js +270 -0
  64. package/dist/chunk-NUB5GQTU.js.map +1 -0
  65. package/dist/chunk-OVSYMNCI.js +145 -0
  66. package/dist/chunk-OVSYMNCI.js.map +1 -0
  67. package/dist/chunk-QLVKMWFA.js +94 -0
  68. package/dist/chunk-QLVKMWFA.js.map +1 -0
  69. package/dist/chunk-SAG6ZYWQ.js +89 -0
  70. package/dist/chunk-SAG6ZYWQ.js.map +1 -0
  71. package/dist/chunk-SAK2JCA7.js +198 -0
  72. package/dist/chunk-SAK2JCA7.js.map +1 -0
  73. package/dist/chunk-SBS4S2PJ.js +100 -0
  74. package/dist/chunk-SBS4S2PJ.js.map +1 -0
  75. package/dist/chunk-SNEOLWXT.js +148 -0
  76. package/dist/chunk-SNEOLWXT.js.map +1 -0
  77. package/dist/chunk-TKBD2ONF.js +564 -0
  78. package/dist/chunk-TKBD2ONF.js.map +1 -0
  79. package/dist/chunk-UBXFIIAW.js +127 -0
  80. package/dist/chunk-UBXFIIAW.js.map +1 -0
  81. package/dist/chunk-VI4VSNTI.js +57 -0
  82. package/dist/chunk-VI4VSNTI.js.map +1 -0
  83. package/dist/chunk-VWCN5PMD.js +268 -0
  84. package/dist/chunk-VWCN5PMD.js.map +1 -0
  85. package/dist/chunk-XC2YD6CF.js +913 -0
  86. package/dist/chunk-XC2YD6CF.js.map +1 -0
  87. package/dist/chunk-XE4OXN2W.js +10 -0
  88. package/dist/chunk-XE4OXN2W.js.map +1 -0
  89. package/dist/chunk-YMZEUTD2.js +110 -0
  90. package/dist/chunk-YMZEUTD2.js.map +1 -0
  91. package/dist/chunk-Z4IRLBWO.js +758 -0
  92. package/dist/chunk-Z4IRLBWO.js.map +1 -0
  93. package/dist/client/internal-client.d.ts +7 -0
  94. package/dist/client/internal-client.js +5 -0
  95. package/dist/client/internal-client.js.map +1 -0
  96. package/dist/client-CSjIrYKS.d.ts +77 -0
  97. package/dist/config-UKE2E3BW.js +4 -0
  98. package/dist/config-UKE2E3BW.js.map +1 -0
  99. package/dist/crypto/index.d.ts +1 -0
  100. package/dist/crypto/index.js +4 -0
  101. package/dist/crypto/index.js.map +1 -0
  102. package/dist/database/index.d.ts +117 -0
  103. package/dist/database/index.js +7 -0
  104. package/dist/database/index.js.map +1 -0
  105. package/dist/dataloader/index.d.ts +1 -0
  106. package/dist/dataloader/index.js +4 -0
  107. package/dist/dataloader/index.js.map +1 -0
  108. package/dist/esm-K6H7EIWK.js +1450 -0
  109. package/dist/esm-K6H7EIWK.js.map +1 -0
  110. package/dist/event-queue/index.d.ts +6 -0
  111. package/dist/event-queue/index.js +10 -0
  112. package/dist/event-queue/index.js.map +1 -0
  113. package/dist/export/index.d.ts +2 -0
  114. package/dist/export/index.js +9 -0
  115. package/dist/export/index.js.map +1 -0
  116. package/dist/feature-flags/index.d.ts +1 -0
  117. package/dist/feature-flags/index.js +4 -0
  118. package/dist/feature-flags/index.js.map +1 -0
  119. package/dist/gateway/index.d.ts +4 -0
  120. package/dist/gateway/index.js +8 -0
  121. package/dist/gateway/index.js.map +1 -0
  122. package/dist/gateway/security/index.d.ts +2 -0
  123. package/dist/gateway/security/index.js +5 -0
  124. package/dist/gateway/security/index.js.map +1 -0
  125. package/dist/graph/index.d.ts +9 -0
  126. package/dist/graph/index.js +13 -0
  127. package/dist/graph/index.js.map +1 -0
  128. package/dist/graph-emitter-Bk0FqD53.d.ts +47 -0
  129. package/dist/graphql/index.d.ts +2 -0
  130. package/dist/graphql/index.js +7 -0
  131. package/dist/graphql/index.js.map +1 -0
  132. package/dist/graphql/services/index.d.ts +24 -0
  133. package/dist/graphql/services/index.js +5 -0
  134. package/dist/graphql/services/index.js.map +1 -0
  135. package/dist/graphql-BAVrUgBF.d.ts +22 -0
  136. package/dist/i18n/index.d.ts +2 -0
  137. package/dist/i18n/index.js +5 -0
  138. package/dist/i18n/index.js.map +1 -0
  139. package/dist/i18n-DA6IPnYy.d.ts +101 -0
  140. package/dist/index-4gKQKZ2B.d.ts +71 -0
  141. package/dist/index-B18rrFru.d.ts +42 -0
  142. package/dist/index-B70b5mYS.d.ts +33 -0
  143. package/dist/index-BMq3lFjj.d.ts +247 -0
  144. package/dist/index-BODgvRtL.d.ts +316 -0
  145. package/dist/index-BS2idbnr.d.ts +874 -0
  146. package/dist/index-BV3G48cH.d.ts +124 -0
  147. package/dist/index-CHbVw5M7.d.ts +73 -0
  148. package/dist/index-Cq_xNjcv.d.ts +602 -0
  149. package/dist/index-CrQgidpx.d.ts +77 -0
  150. package/dist/index-CyVEg86m.d.ts +309 -0
  151. package/dist/index-DOcBnmMe.d.ts +166 -0
  152. package/dist/index-DSOpj8DI.d.ts +17 -0
  153. package/dist/index-DW9q22GH.d.ts +75 -0
  154. package/dist/index-DlFDFyWD.d.ts +55 -0
  155. package/dist/index-DoK0bjhH.d.ts +607 -0
  156. package/dist/index-Dtf6FBaD.d.ts +199 -0
  157. package/dist/index-KVWGHMbS.d.ts +415 -0
  158. package/dist/index-PaojfSdd.d.ts +71 -0
  159. package/dist/index-RU_M5c74.d.ts +163 -0
  160. package/dist/index-UhkH2eaB.d.ts +192 -0
  161. package/dist/index-e_18DzAg.d.ts +18 -0
  162. package/dist/index-jOuh_TKn.d.ts +59 -0
  163. package/dist/index.d.ts +584 -0
  164. package/dist/index.js +2626 -0
  165. package/dist/index.js.map +1 -0
  166. package/dist/init/index.d.ts +2 -0
  167. package/dist/init/index.js +12 -0
  168. package/dist/init/index.js.map +1 -0
  169. package/dist/instrumentation/index.d.ts +3 -0
  170. package/dist/instrumentation/index.js +5 -0
  171. package/dist/instrumentation/index.js.map +1 -0
  172. package/dist/layer/index.d.ts +2 -0
  173. package/dist/layer/index.js +6 -0
  174. package/dist/layer/index.js.map +1 -0
  175. package/dist/layer-DDip18KY.d.ts +67 -0
  176. package/dist/logger/index.d.ts +2 -0
  177. package/dist/logger/index.js +4 -0
  178. package/dist/logger/index.js.map +1 -0
  179. package/dist/middleware/index.d.ts +3 -0
  180. package/dist/middleware/index.js +5 -0
  181. package/dist/middleware/index.js.map +1 -0
  182. package/dist/notifications/index.d.ts +4 -0
  183. package/dist/notifications/index.js +7 -0
  184. package/dist/notifications/index.js.map +1 -0
  185. package/dist/observability/index.d.ts +3 -0
  186. package/dist/observability/index.js +5 -0
  187. package/dist/observability/index.js.map +1 -0
  188. package/dist/pino-logger-RYLGXPHZ.js +5 -0
  189. package/dist/pino-logger-RYLGXPHZ.js.map +1 -0
  190. package/dist/prisma/generator/index.d.ts +1 -0
  191. package/dist/prisma/generator/index.js +228 -0
  192. package/dist/prisma/generator/index.js.map +1 -0
  193. package/dist/prisma/index.d.ts +5 -0
  194. package/dist/prisma/index.js +12 -0
  195. package/dist/prisma/index.js.map +1 -0
  196. package/dist/prisma-extension-krXnYnrN.d.ts +30 -0
  197. package/dist/rbac/index.d.ts +116 -0
  198. package/dist/rbac/index.js +7 -0
  199. package/dist/rbac/index.js.map +1 -0
  200. package/dist/sdk-THO3IWEE.js +136 -0
  201. package/dist/sdk-THO3IWEE.js.map +1 -0
  202. package/dist/server/index.d.ts +359 -0
  203. package/dist/server/index.js +884 -0
  204. package/dist/server/index.js.map +1 -0
  205. package/dist/telemetry/index.d.ts +83 -0
  206. package/dist/telemetry/index.js +209 -0
  207. package/dist/telemetry/index.js.map +1 -0
  208. package/dist/temporal/index.d.ts +148 -0
  209. package/dist/temporal/index.js +6 -0
  210. package/dist/temporal/index.js.map +1 -0
  211. package/dist/tracker/index.d.ts +5 -0
  212. package/dist/tracker/index.js +9 -0
  213. package/dist/tracker/index.js.map +1 -0
  214. package/dist/types-Bo2wkjSP.d.ts +35 -0
  215. package/dist/utils/index.d.ts +1 -0
  216. package/dist/utils/index.js +4 -0
  217. package/dist/utils/index.js.map +1 -0
  218. package/dist/workspace-guard-LHBNK4TG.js +5 -0
  219. package/dist/workspace-guard-LHBNK4TG.js.map +1 -0
  220. package/package.json +241 -0
@@ -0,0 +1,758 @@
1
+ import { DEFAULT_LAYER_RESOURCES } from './chunk-NGMEI42S.js';
2
+ import { logger } from './chunk-CBZNP6RF.js';
3
+ import { __name } from './chunk-XE4OXN2W.js';
4
+
5
+ // src/temporal/client.ts
6
+ var temporalClientModule = null;
7
+ async function getTemporalClientModule() {
8
+ if (!temporalClientModule) {
9
+ temporalClientModule = await import('@temporalio/client');
10
+ }
11
+ return temporalClientModule;
12
+ }
13
+ __name(getTemporalClientModule, "getTemporalClientModule");
14
+ var TemporalClient = class {
15
+ static {
16
+ __name(this, "TemporalClient");
17
+ }
18
+ client = null;
19
+ connection = null;
20
+ config;
21
+ isConnected = false;
22
+ constructor(config) {
23
+ this.config = {
24
+ connectionTimeout: 1e4,
25
+ tls: false,
26
+ ...config
27
+ };
28
+ }
29
+ /**
30
+ * Connect to Temporal server
31
+ */
32
+ async connect() {
33
+ if (this.client && this.isConnected) {
34
+ return this.client;
35
+ }
36
+ try {
37
+ logger.info("Connecting to Temporal server", {
38
+ address: this.config.address,
39
+ namespace: this.config.namespace
40
+ });
41
+ const { Connection, Client } = await getTemporalClientModule();
42
+ this.connection = await Connection.connect({
43
+ address: this.config.address,
44
+ tls: this.config.tls ? this.config.tlsOptions : void 0
45
+ });
46
+ this.client = new Client({
47
+ connection: this.connection,
48
+ namespace: this.config.namespace
49
+ });
50
+ this.isConnected = true;
51
+ logger.info("Successfully connected to Temporal", {
52
+ address: this.config.address,
53
+ namespace: this.config.namespace
54
+ });
55
+ return this.client;
56
+ } catch (error) {
57
+ logger.error("Failed to connect to Temporal", {
58
+ error: error instanceof Error ? error.message : String(error),
59
+ address: this.config.address
60
+ });
61
+ throw error;
62
+ }
63
+ }
64
+ /**
65
+ * Disconnect from Temporal server
66
+ */
67
+ async disconnect() {
68
+ if (this.connection) {
69
+ await this.connection.close();
70
+ this.connection = null;
71
+ this.client = null;
72
+ this.isConnected = false;
73
+ logger.info("Disconnected from Temporal", {
74
+ address: this.config.address
75
+ });
76
+ }
77
+ }
78
+ /**
79
+ * Get the underlying Temporal client
80
+ */
81
+ async getClient() {
82
+ return this.connect();
83
+ }
84
+ /**
85
+ * Start a workflow execution using string workflow name
86
+ * Note: Since workflow is specified as string (not function reference),
87
+ * return type is WorkflowHandle without type parameter
88
+ */
89
+ async startWorkflow(workflowType, options) {
90
+ const client = await this.connect();
91
+ try {
92
+ logger.debug("Starting workflow", {
93
+ workflowType,
94
+ workflowId: options.workflowId,
95
+ taskQueue: options.taskQueue
96
+ });
97
+ const handle = await client.workflow.start(workflowType, {
98
+ workflowId: options.workflowId,
99
+ taskQueue: options.taskQueue,
100
+ args: options.args ?? [],
101
+ workflowExecutionTimeout: options.workflowExecutionTimeout,
102
+ workflowRunTimeout: options.workflowRunTimeout,
103
+ workflowTaskTimeout: options.workflowTaskTimeout,
104
+ cronSchedule: options.cronSchedule,
105
+ memo: options.memo,
106
+ searchAttributes: options.searchAttributes
107
+ });
108
+ logger.info("Workflow started successfully", {
109
+ workflowType,
110
+ workflowId: options.workflowId
111
+ });
112
+ return handle;
113
+ } catch (error) {
114
+ logger.error("Failed to start workflow", {
115
+ workflowType,
116
+ workflowId: options.workflowId,
117
+ error: error instanceof Error ? error.message : String(error)
118
+ });
119
+ throw error;
120
+ }
121
+ }
122
+ /**
123
+ * Execute a workflow and wait for result using string workflow name
124
+ * Note: Since workflow is specified as string (not function reference),
125
+ * return type is unknown (caller must assert type if needed)
126
+ */
127
+ async executeWorkflow(workflowType, options) {
128
+ const client = await this.connect();
129
+ try {
130
+ logger.debug("Executing workflow", {
131
+ workflowType,
132
+ workflowId: options.workflowId,
133
+ taskQueue: options.taskQueue
134
+ });
135
+ const result = await client.workflow.execute(workflowType, {
136
+ workflowId: options.workflowId,
137
+ taskQueue: options.taskQueue,
138
+ args: options.args ?? [],
139
+ workflowExecutionTimeout: options.workflowExecutionTimeout,
140
+ workflowRunTimeout: options.workflowRunTimeout,
141
+ workflowTaskTimeout: options.workflowTaskTimeout,
142
+ memo: options.memo,
143
+ searchAttributes: options.searchAttributes
144
+ });
145
+ logger.info("Workflow executed successfully", {
146
+ workflowType,
147
+ workflowId: options.workflowId
148
+ });
149
+ return result;
150
+ } catch (error) {
151
+ logger.error("Failed to execute workflow", {
152
+ workflowType,
153
+ workflowId: options.workflowId,
154
+ error: error instanceof Error ? error.message : String(error)
155
+ });
156
+ throw error;
157
+ }
158
+ }
159
+ /**
160
+ * Get workflow handle by ID
161
+ */
162
+ async getWorkflowHandle(workflowId, runId) {
163
+ const client = await this.connect();
164
+ return client.workflow.getHandle(workflowId, runId);
165
+ }
166
+ /**
167
+ * Signal a running workflow
168
+ */
169
+ async signalWorkflow(workflowId, signalName, args) {
170
+ const handle = await this.getWorkflowHandle(workflowId);
171
+ try {
172
+ await handle.signal(signalName, args);
173
+ logger.info("Workflow signal sent", {
174
+ workflowId,
175
+ signalName
176
+ });
177
+ } catch (error) {
178
+ logger.error("Failed to signal workflow", {
179
+ workflowId,
180
+ signalName,
181
+ error: error instanceof Error ? error.message : String(error)
182
+ });
183
+ throw error;
184
+ }
185
+ }
186
+ /**
187
+ * Query a running workflow
188
+ */
189
+ async queryWorkflow(workflowId, queryName, args) {
190
+ const handle = await this.getWorkflowHandle(workflowId);
191
+ try {
192
+ const result = await handle.query(queryName, args);
193
+ logger.debug("Workflow query executed", {
194
+ workflowId,
195
+ queryName
196
+ });
197
+ return result;
198
+ } catch (error) {
199
+ logger.error("Failed to query workflow", {
200
+ workflowId,
201
+ queryName,
202
+ error: error instanceof Error ? error.message : String(error)
203
+ });
204
+ throw error;
205
+ }
206
+ }
207
+ /**
208
+ * Cancel a running workflow
209
+ */
210
+ async cancelWorkflow(workflowId) {
211
+ const handle = await this.getWorkflowHandle(workflowId);
212
+ try {
213
+ await handle.cancel();
214
+ logger.info("Workflow cancelled", {
215
+ workflowId
216
+ });
217
+ } catch (error) {
218
+ logger.error("Failed to cancel workflow", {
219
+ workflowId,
220
+ error: error instanceof Error ? error.message : String(error)
221
+ });
222
+ throw error;
223
+ }
224
+ }
225
+ /**
226
+ * Terminate a running workflow
227
+ */
228
+ async terminateWorkflow(workflowId, reason) {
229
+ const handle = await this.getWorkflowHandle(workflowId);
230
+ try {
231
+ await handle.terminate(reason);
232
+ logger.info("Workflow terminated", {
233
+ workflowId,
234
+ reason
235
+ });
236
+ } catch (error) {
237
+ logger.error("Failed to terminate workflow", {
238
+ workflowId,
239
+ error: error instanceof Error ? error.message : String(error)
240
+ });
241
+ throw error;
242
+ }
243
+ }
244
+ /**
245
+ * Describe a workflow execution
246
+ */
247
+ async describeWorkflow(workflowId) {
248
+ const handle = await this.getWorkflowHandle(workflowId);
249
+ try {
250
+ const description = await handle.describe();
251
+ logger.debug("Workflow described", {
252
+ workflowId,
253
+ status: description.status.name
254
+ });
255
+ return description;
256
+ } catch (error) {
257
+ logger.error("Failed to describe workflow", {
258
+ workflowId,
259
+ error: error instanceof Error ? error.message : String(error)
260
+ });
261
+ throw error;
262
+ }
263
+ }
264
+ /**
265
+ * Get workflow result
266
+ */
267
+ async getWorkflowResult(workflowId) {
268
+ const handle = await this.getWorkflowHandle(workflowId);
269
+ try {
270
+ const result = await handle.result();
271
+ logger.info("Workflow result retrieved", {
272
+ workflowId
273
+ });
274
+ return result;
275
+ } catch (error) {
276
+ logger.error("Failed to get workflow result", {
277
+ workflowId,
278
+ error: error instanceof Error ? error.message : String(error)
279
+ });
280
+ throw error;
281
+ }
282
+ }
283
+ /**
284
+ * Check if client is connected
285
+ */
286
+ isClientConnected() {
287
+ return this.isConnected;
288
+ }
289
+ /**
290
+ * Get configuration
291
+ */
292
+ getConfig() {
293
+ return {
294
+ ...this.config
295
+ };
296
+ }
297
+ };
298
+ var TemporalClientFactory = class {
299
+ static {
300
+ __name(this, "TemporalClientFactory");
301
+ }
302
+ /**
303
+ * Create a Temporal client for workspace modules
304
+ */
305
+ static createWorkspaceClient(config) {
306
+ const address = config?.address || process.env["TEMPORAL_WORKSPACE_URL"] || "localhost:7233";
307
+ const namespace = config?.namespace || process.env["TEMPORAL_NAMESPACE"] || "workspace-default";
308
+ const taskQueue = config?.taskQueue || process.env["TEMPORAL_TASK_QUEUE"];
309
+ return new TemporalClient({
310
+ address,
311
+ namespace,
312
+ taskQueue,
313
+ ...config
314
+ });
315
+ }
316
+ /**
317
+ * Create a Temporal client for tenant modules
318
+ */
319
+ static createTenantClient(config) {
320
+ const address = config?.address || process.env["TEMPORAL_TENANT_URL"] || "localhost:7233";
321
+ const namespace = config?.namespace || process.env["TEMPORAL_NAMESPACE"] || "tenant-default";
322
+ const taskQueue = config?.taskQueue || process.env["TEMPORAL_TASK_QUEUE"];
323
+ return new TemporalClient({
324
+ address,
325
+ namespace,
326
+ taskQueue,
327
+ ...config
328
+ });
329
+ }
330
+ /**
331
+ * Create a Temporal client from environment variables
332
+ * Automatically detects workspace vs tenant based on TEMPORAL_MODULE_TYPE
333
+ */
334
+ static createFromEnv() {
335
+ const moduleType = process.env["TEMPORAL_MODULE_TYPE"] || "workspace";
336
+ if (moduleType === "tenant") {
337
+ return this.createTenantClient();
338
+ }
339
+ return this.createWorkspaceClient();
340
+ }
341
+ // ========================================================================
342
+ // Layer-Aware Factory Methods
343
+ // ========================================================================
344
+ /**
345
+ * Create a Temporal client for a specific layer
346
+ *
347
+ * @param layer - Service layer ('wspace' or 'global')
348
+ * @param serviceName - Service name for identification
349
+ * @param config - Optional configuration overrides
350
+ * @returns Temporal client configured for the layer
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * const client = TemporalClientFactory.createClientForLayer('wspace', 'wspace-tags-svc');
355
+ * await client.connect();
356
+ * await client.startWorkflow('processTagUpdate', {
357
+ * workflowId: 'tag-update-123',
358
+ * taskQueue: 'wspace-tags-queue',
359
+ * });
360
+ * ```
361
+ */
362
+ static createClientForLayer(layer, serviceName, config) {
363
+ const envPrefix = layer.toUpperCase();
364
+ const defaults = DEFAULT_LAYER_RESOURCES[layer];
365
+ const address = config?.address || process.env[`${envPrefix}_TEMPORAL_ADDRESS`] || process.env["TEMPORAL_ADDRESS"] || defaults.temporalAddress;
366
+ const layerPrefix = `${layer}-`;
367
+ const derivedNamespace = `${layer}-${serviceName.replace(layerPrefix, "").replace("-svc", "")}`;
368
+ const namespace = config?.namespace || process.env[`${envPrefix}_TEMPORAL_NAMESPACE`] || process.env["TEMPORAL_NAMESPACE"] || derivedNamespace;
369
+ const taskQueue = config?.taskQueue || process.env[`${envPrefix}_TEMPORAL_TASK_QUEUE`] || process.env["TEMPORAL_TASK_QUEUE"] || `${serviceName}-queue`;
370
+ logger.info("[TemporalClientFactory] Creating layer client", {
371
+ layer,
372
+ serviceName,
373
+ address,
374
+ namespace,
375
+ taskQueue
376
+ });
377
+ return new TemporalClient({
378
+ address,
379
+ namespace,
380
+ taskQueue,
381
+ ...config
382
+ });
383
+ }
384
+ /**
385
+ * Create a Temporal client from layer environment detection
386
+ *
387
+ * @param serviceName - Service name for identification
388
+ * @returns Temporal client configured based on detected layer
389
+ */
390
+ static createFromLayerEnv(serviceName) {
391
+ const layer = process.env["SERVICE_LAYER"] || (serviceName.startsWith("global-") ? "global" : "wspace");
392
+ return this.createClientForLayer(layer, serviceName);
393
+ }
394
+ };
395
+
396
+ // src/temporal/worker.ts
397
+ var temporalWorkerModule = null;
398
+ async function getTemporalWorkerModule() {
399
+ if (!temporalWorkerModule) {
400
+ temporalWorkerModule = await import('@temporalio/worker');
401
+ }
402
+ return temporalWorkerModule;
403
+ }
404
+ __name(getTemporalWorkerModule, "getTemporalWorkerModule");
405
+ var TemporalWorker = class {
406
+ static {
407
+ __name(this, "TemporalWorker");
408
+ }
409
+ worker = null;
410
+ connection = null;
411
+ config;
412
+ isRunning = false;
413
+ constructor(config) {
414
+ this.config = {
415
+ maxConcurrentWorkflowTaskExecutions: 100,
416
+ maxConcurrentActivityTaskExecutions: 100,
417
+ debugMode: false,
418
+ ...config
419
+ };
420
+ }
421
+ /**
422
+ * Start the worker
423
+ */
424
+ async start() {
425
+ if (this.isRunning) {
426
+ logger.warn("Worker already running", {
427
+ taskQueue: this.config.taskQueue
428
+ });
429
+ return;
430
+ }
431
+ try {
432
+ logger.info("Starting Temporal worker", {
433
+ address: this.config.address,
434
+ namespace: this.config.namespace,
435
+ taskQueue: this.config.taskQueue
436
+ });
437
+ const { Worker, NativeConnection } = await getTemporalWorkerModule();
438
+ this.connection = await NativeConnection.connect({
439
+ address: this.config.address,
440
+ tls: this.config.tls
441
+ });
442
+ this.worker = await Worker.create({
443
+ connection: this.connection,
444
+ namespace: this.config.namespace,
445
+ taskQueue: this.config.taskQueue,
446
+ workflowsPath: this.config.workflowsPath,
447
+ activities: this.config.activities,
448
+ maxConcurrentWorkflowTaskExecutions: this.config.maxConcurrentWorkflowTaskExecutions,
449
+ maxConcurrentActivityTaskExecutions: this.config.maxConcurrentActivityTaskExecutions
450
+ });
451
+ this.isRunning = true;
452
+ logger.info("Temporal worker started successfully", {
453
+ taskQueue: this.config.taskQueue,
454
+ workflowsPath: this.config.workflowsPath
455
+ });
456
+ await this.worker.run();
457
+ } catch (error) {
458
+ logger.error("Failed to start Temporal worker", {
459
+ error: error instanceof Error ? error.message : String(error),
460
+ taskQueue: this.config.taskQueue
461
+ });
462
+ throw error;
463
+ }
464
+ }
465
+ /**
466
+ * Stop the worker
467
+ */
468
+ async stop() {
469
+ if (!this.isRunning || !this.worker) {
470
+ logger.warn("Worker not running", {
471
+ taskQueue: this.config.taskQueue
472
+ });
473
+ return;
474
+ }
475
+ try {
476
+ logger.info("Stopping Temporal worker", {
477
+ taskQueue: this.config.taskQueue
478
+ });
479
+ this.worker.shutdown();
480
+ this.isRunning = false;
481
+ if (this.connection) {
482
+ await this.connection.close();
483
+ this.connection = null;
484
+ }
485
+ this.worker = null;
486
+ logger.info("Temporal worker stopped successfully", {
487
+ taskQueue: this.config.taskQueue
488
+ });
489
+ } catch (error) {
490
+ logger.error("Failed to stop Temporal worker", {
491
+ error: error instanceof Error ? error.message : String(error),
492
+ taskQueue: this.config.taskQueue
493
+ });
494
+ throw error;
495
+ }
496
+ }
497
+ /**
498
+ * Check if worker is running
499
+ */
500
+ isWorkerRunning() {
501
+ return this.isRunning;
502
+ }
503
+ /**
504
+ * Get worker configuration
505
+ */
506
+ getConfig() {
507
+ return {
508
+ ...this.config
509
+ };
510
+ }
511
+ };
512
+ var TemporalWorkerFactory = class {
513
+ static {
514
+ __name(this, "TemporalWorkerFactory");
515
+ }
516
+ /**
517
+ * Create a Temporal worker for workspace modules
518
+ */
519
+ static createWorkspaceWorker(config) {
520
+ const address = config.address || process.env["TEMPORAL_WORKSPACE_URL"] || "localhost:7233";
521
+ const namespace = config.namespace || process.env["TEMPORAL_NAMESPACE"] || "workspace-default";
522
+ const taskQueue = config.taskQueue || process.env["TEMPORAL_TASK_QUEUE"] || "workspace-default-tasks";
523
+ return new TemporalWorker({
524
+ address,
525
+ namespace,
526
+ taskQueue,
527
+ workflowsPath: config.workflowsPath,
528
+ activities: config.activities
529
+ });
530
+ }
531
+ /**
532
+ * Create a Temporal worker for tenant modules
533
+ */
534
+ static createTenantWorker(config) {
535
+ const address = config.address || process.env["TEMPORAL_TENANT_URL"] || "localhost:7233";
536
+ const namespace = config.namespace || process.env["TEMPORAL_NAMESPACE"] || "tenant-default";
537
+ const taskQueue = config.taskQueue || process.env["TEMPORAL_TASK_QUEUE"] || "tenant-default-tasks";
538
+ return new TemporalWorker({
539
+ address,
540
+ namespace,
541
+ taskQueue,
542
+ workflowsPath: config.workflowsPath,
543
+ activities: config.activities
544
+ });
545
+ }
546
+ /**
547
+ * Create a Temporal worker from environment variables
548
+ * Automatically detects workspace vs tenant based on TEMPORAL_MODULE_TYPE
549
+ */
550
+ static createFromEnv(config) {
551
+ const moduleType = process.env["TEMPORAL_MODULE_TYPE"] || "workspace";
552
+ if (moduleType === "tenant") {
553
+ return this.createTenantWorker(config);
554
+ }
555
+ return this.createWorkspaceWorker(config);
556
+ }
557
+ };
558
+ var TemporalWorkerManager = class {
559
+ static {
560
+ __name(this, "TemporalWorkerManager");
561
+ }
562
+ workers = /* @__PURE__ */ new Map();
563
+ /**
564
+ * Register a worker
565
+ */
566
+ registerWorker(name, worker) {
567
+ if (this.workers.has(name)) {
568
+ logger.warn("Worker already registered, replacing", {
569
+ name
570
+ });
571
+ }
572
+ this.workers.set(name, worker);
573
+ }
574
+ /**
575
+ * Start all registered workers
576
+ */
577
+ async startAll() {
578
+ logger.info("Starting all Temporal workers", {
579
+ count: this.workers.size
580
+ });
581
+ const startPromises = Array.from(this.workers.entries()).map(async ([name, worker]) => {
582
+ try {
583
+ await worker.start();
584
+ logger.info("Worker started", {
585
+ name
586
+ });
587
+ } catch (error) {
588
+ logger.error("Failed to start worker", {
589
+ name,
590
+ error: error instanceof Error ? error.message : String(error)
591
+ });
592
+ throw error;
593
+ }
594
+ });
595
+ await Promise.all(startPromises);
596
+ }
597
+ /**
598
+ * Stop all registered workers
599
+ */
600
+ async stopAll() {
601
+ logger.info("Stopping all Temporal workers", {
602
+ count: this.workers.size
603
+ });
604
+ const stopPromises = Array.from(this.workers.entries()).map(async ([name, worker]) => {
605
+ try {
606
+ await worker.stop();
607
+ logger.info("Worker stopped", {
608
+ name
609
+ });
610
+ } catch (error) {
611
+ logger.error("Failed to stop worker", {
612
+ name,
613
+ error: error instanceof Error ? error.message : String(error)
614
+ });
615
+ }
616
+ });
617
+ await Promise.all(stopPromises);
618
+ }
619
+ /**
620
+ * Get a worker by name
621
+ */
622
+ getWorker(name) {
623
+ return this.workers.get(name);
624
+ }
625
+ /**
626
+ * Remove a worker
627
+ */
628
+ removeWorker(name) {
629
+ return this.workers.delete(name);
630
+ }
631
+ /**
632
+ * Get all registered worker names
633
+ */
634
+ getWorkerNames() {
635
+ return Array.from(this.workers.keys());
636
+ }
637
+ };
638
+
639
+ // src/temporal/module.ts
640
+ var TemporalModule = class _TemporalModule {
641
+ static {
642
+ __name(this, "TemporalModule");
643
+ }
644
+ client;
645
+ workerManager;
646
+ config;
647
+ constructor(config) {
648
+ this.config = {
649
+ autoConnect: true,
650
+ ...config
651
+ };
652
+ if (config.moduleType === "tenant") {
653
+ this.client = TemporalClientFactory.createTenantClient({
654
+ address: config.address,
655
+ namespace: config.namespace,
656
+ taskQueue: config.taskQueue
657
+ });
658
+ } else {
659
+ this.client = TemporalClientFactory.createWorkspaceClient({
660
+ address: config.address,
661
+ namespace: config.namespace,
662
+ taskQueue: config.taskQueue
663
+ });
664
+ }
665
+ this.workerManager = new TemporalWorkerManager();
666
+ if (this.config.autoConnect) {
667
+ this.initialize();
668
+ }
669
+ }
670
+ /**
671
+ * Initialize the Temporal module (connect client)
672
+ * This is called automatically if autoConnect is true
673
+ */
674
+ initialize() {
675
+ this.client.connect().catch((error) => {
676
+ logger.error("Failed to auto-connect to Temporal", {
677
+ error: error instanceof Error ? error.message : String(error)
678
+ });
679
+ });
680
+ }
681
+ /**
682
+ * Get the Temporal client
683
+ */
684
+ getClient() {
685
+ return this.client;
686
+ }
687
+ /**
688
+ * Get the worker manager
689
+ */
690
+ getWorkerManager() {
691
+ return this.workerManager;
692
+ }
693
+ /**
694
+ * Create and register a worker
695
+ */
696
+ createWorker(config) {
697
+ const worker = this.config.moduleType === "tenant" ? TemporalWorkerFactory.createTenantWorker({
698
+ workflowsPath: config.workflowsPath,
699
+ activities: config.activities,
700
+ taskQueue: config.taskQueue,
701
+ namespace: this.config.namespace,
702
+ address: this.config.address
703
+ }) : TemporalWorkerFactory.createWorkspaceWorker({
704
+ workflowsPath: config.workflowsPath,
705
+ activities: config.activities,
706
+ taskQueue: config.taskQueue,
707
+ namespace: this.config.namespace,
708
+ address: this.config.address
709
+ });
710
+ this.workerManager.registerWorker(config.name, worker);
711
+ return worker;
712
+ }
713
+ /**
714
+ * Start all registered workers
715
+ */
716
+ async startWorkers() {
717
+ await this.workerManager.startAll();
718
+ }
719
+ /**
720
+ * Stop all registered workers
721
+ */
722
+ async stopWorkers() {
723
+ await this.workerManager.stopAll();
724
+ }
725
+ /**
726
+ * Disconnect from Temporal
727
+ */
728
+ async disconnect() {
729
+ await this.client.disconnect();
730
+ }
731
+ /**
732
+ * Get module configuration
733
+ */
734
+ getConfig() {
735
+ return {
736
+ ...this.config
737
+ };
738
+ }
739
+ /**
740
+ * Create a Temporal module from environment variables
741
+ */
742
+ static fromEnv() {
743
+ const moduleType = process.env["TEMPORAL_MODULE_TYPE"] || "workspace";
744
+ const address = moduleType === "tenant" ? process.env["TEMPORAL_TENANT_URL"] || "localhost:7233" : process.env["TEMPORAL_WORKSPACE_URL"] || "localhost:7233";
745
+ const namespace = process.env["TEMPORAL_NAMESPACE"];
746
+ const taskQueue = process.env["TEMPORAL_TASK_QUEUE"];
747
+ return new _TemporalModule({
748
+ moduleType,
749
+ address,
750
+ namespace,
751
+ taskQueue
752
+ });
753
+ }
754
+ };
755
+
756
+ export { TemporalClient, TemporalClientFactory, TemporalModule, TemporalWorker, TemporalWorkerFactory, TemporalWorkerManager };
757
+ //# sourceMappingURL=chunk-Z4IRLBWO.js.map
758
+ //# sourceMappingURL=chunk-Z4IRLBWO.js.map