@qlever-llc/trellis 0.6.0 → 0.7.0-rc.2

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 (254) hide show
  1. package/README.md +6 -2
  2. package/esm/auth/device_activation.d.ts +194 -0
  3. package/esm/auth/device_activation.d.ts.map +1 -0
  4. package/esm/auth/{workload_activation.js → device_activation.js} +85 -60
  5. package/esm/auth/mod.d.ts +2 -2
  6. package/esm/auth/mod.d.ts.map +1 -1
  7. package/esm/auth/mod.js +2 -2
  8. package/esm/auth/protocol.d.ts +175 -72
  9. package/esm/auth/protocol.d.ts.map +1 -1
  10. package/esm/auth/protocol.js +126 -78
  11. package/esm/contracts/mod.d.ts +22 -2
  12. package/esm/contracts/mod.d.ts.map +1 -1
  13. package/esm/contracts/mod.js +30 -4
  14. package/esm/contracts/protocol.d.ts +34 -0
  15. package/esm/contracts/protocol.d.ts.map +1 -1
  16. package/esm/contracts/protocol.js +15 -0
  17. package/esm/server/deno.d.ts +1 -6
  18. package/esm/server/deno.d.ts.map +1 -1
  19. package/esm/server/deno.js +1 -16
  20. package/esm/server/mod.d.ts +3 -2
  21. package/esm/server/mod.d.ts.map +1 -1
  22. package/esm/server/mod.js +2 -2
  23. package/esm/server/node.d.ts +1 -6
  24. package/esm/server/node.d.ts.map +1 -1
  25. package/esm/server/node.js +1 -16
  26. package/esm/server/service.d.ts +32 -10
  27. package/esm/server/service.d.ts.map +1 -1
  28. package/esm/server/service.js +188 -41
  29. package/esm/server/transfer.d.ts +41 -0
  30. package/esm/server/transfer.d.ts.map +1 -0
  31. package/esm/server/transfer.js +418 -0
  32. package/esm/telemetry/init.d.ts +4 -0
  33. package/esm/telemetry/init.d.ts.map +1 -0
  34. package/esm/telemetry/init.js +7 -0
  35. package/esm/telemetry/mod.d.ts +1 -2
  36. package/esm/telemetry/mod.d.ts.map +1 -1
  37. package/esm/telemetry/mod.js +1 -2
  38. package/esm/telemetry/runtime.d.ts.map +1 -1
  39. package/esm/telemetry/runtime.js +9 -5
  40. package/esm/telemetry/trellis.d.ts +0 -1
  41. package/esm/telemetry/trellis.d.ts.map +1 -1
  42. package/esm/telemetry/trellis.js +0 -6
  43. package/esm/trellis/_sdk/activity/contract.d.ts +1 -1
  44. package/esm/trellis/_sdk/activity/contract.d.ts.map +1 -1
  45. package/esm/trellis/_sdk/activity/contract.js +2 -2
  46. package/esm/trellis/_sdk/activity/types.d.ts +1 -1
  47. package/esm/trellis/_sdk/activity/types.js +1 -1
  48. package/esm/trellis/_sdk/auth/api.d.ts.map +1 -1
  49. package/esm/trellis/_sdk/auth/api.js +132 -110
  50. package/esm/trellis/_sdk/auth/contract.d.ts +1 -1
  51. package/esm/trellis/_sdk/auth/contract.d.ts.map +1 -1
  52. package/esm/trellis/_sdk/auth/contract.js +2 -2
  53. package/esm/trellis/_sdk/auth/schemas.d.ts +4212 -3069
  54. package/esm/trellis/_sdk/auth/schemas.d.ts.map +1 -1
  55. package/esm/trellis/_sdk/auth/schemas.js +144 -125
  56. package/esm/trellis/_sdk/auth/types.d.ts +417 -267
  57. package/esm/trellis/_sdk/auth/types.d.ts.map +1 -1
  58. package/esm/trellis/_sdk/auth/types.js +1 -1
  59. package/esm/trellis/_sdk/core/contract.d.ts +1 -1
  60. package/esm/trellis/_sdk/core/contract.d.ts.map +1 -1
  61. package/esm/trellis/_sdk/core/contract.js +2 -2
  62. package/esm/trellis/_sdk/core/schemas.d.ts +122 -0
  63. package/esm/trellis/_sdk/core/schemas.d.ts.map +1 -1
  64. package/esm/trellis/_sdk/core/schemas.js +4 -4
  65. package/esm/trellis/_sdk/core/types.d.ts +18 -1
  66. package/esm/trellis/_sdk/core/types.d.ts.map +1 -1
  67. package/esm/trellis/_sdk/core/types.js +1 -1
  68. package/esm/trellis/_sdk/state/_dnt.polyfills.d.ts +12 -0
  69. package/esm/trellis/_sdk/state/_dnt.polyfills.d.ts.map +1 -0
  70. package/esm/trellis/_sdk/state/_dnt.polyfills.js +15 -0
  71. package/esm/trellis/_sdk/state/api.d.ts +10 -0
  72. package/esm/trellis/_sdk/state/api.d.ts.map +1 -0
  73. package/esm/trellis/_sdk/state/api.js +71 -0
  74. package/esm/trellis/_sdk/state/contract.d.ts +8 -0
  75. package/esm/trellis/_sdk/state/contract.d.ts.map +1 -0
  76. package/esm/trellis/_sdk/state/contract.js +59 -0
  77. package/esm/trellis/_sdk/state/mod.d.ts +7 -0
  78. package/esm/trellis/_sdk/state/mod.d.ts.map +1 -0
  79. package/esm/trellis/_sdk/state/mod.js +5 -0
  80. package/esm/trellis/_sdk/state/package.json +3 -0
  81. package/esm/trellis/_sdk/state/schemas.d.ts +1437 -0
  82. package/esm/trellis/_sdk/state/schemas.d.ts.map +1 -0
  83. package/esm/trellis/_sdk/state/schemas.js +62 -0
  84. package/esm/trellis/_sdk/state/types.d.ts +206 -0
  85. package/esm/trellis/_sdk/state/types.d.ts.map +1 -0
  86. package/esm/trellis/_sdk/state/types.js +3 -0
  87. package/esm/trellis/client_connect.d.ts +53 -0
  88. package/esm/trellis/client_connect.d.ts.map +1 -0
  89. package/esm/trellis/client_connect.js +300 -0
  90. package/esm/trellis/contract.d.ts +1 -7
  91. package/esm/trellis/contract.d.ts.map +1 -1
  92. package/esm/trellis/contract.js +1 -12
  93. package/esm/trellis/device.d.ts +41 -0
  94. package/esm/trellis/device.d.ts.map +1 -0
  95. package/esm/trellis/device.js +209 -0
  96. package/esm/trellis/errors/AuthError.d.ts +1 -1
  97. package/esm/trellis/errors/AuthError.js +9 -9
  98. package/esm/trellis/errors/StoreError.d.ts +22 -0
  99. package/esm/trellis/errors/StoreError.d.ts.map +1 -0
  100. package/esm/trellis/errors/StoreError.js +41 -0
  101. package/esm/trellis/errors/TransferError.d.ts +22 -0
  102. package/esm/trellis/errors/TransferError.d.ts.map +1 -0
  103. package/esm/trellis/errors/TransferError.js +41 -0
  104. package/esm/trellis/errors/index.d.ts +8 -0
  105. package/esm/trellis/errors/index.d.ts.map +1 -1
  106. package/esm/trellis/errors/index.js +8 -0
  107. package/esm/trellis/index.d.ts +10 -4
  108. package/esm/trellis/index.d.ts.map +1 -1
  109. package/esm/trellis/index.js +6 -4
  110. package/esm/trellis/kv.d.ts +2 -0
  111. package/esm/trellis/kv.d.ts.map +1 -1
  112. package/esm/trellis/kv.js +6 -0
  113. package/esm/trellis/models/trellis/TrellisError.d.ts +15 -1
  114. package/esm/trellis/models/trellis/TrellisError.d.ts.map +1 -1
  115. package/esm/trellis/models/trellis/TrellisError.js +4 -0
  116. package/esm/trellis/runtime_transport.d.ts +12 -0
  117. package/esm/trellis/runtime_transport.d.ts.map +1 -0
  118. package/esm/trellis/runtime_transport.js +35 -0
  119. package/esm/trellis/sdk/state.d.ts +4 -0
  120. package/esm/trellis/sdk/state.d.ts.map +1 -0
  121. package/esm/trellis/sdk/state.js +3 -0
  122. package/esm/trellis/store.d.ts +51 -0
  123. package/esm/trellis/store.d.ts.map +1 -0
  124. package/esm/trellis/store.js +310 -0
  125. package/esm/trellis/tracing.js +1 -1
  126. package/esm/trellis/transfer.d.ts +118 -0
  127. package/esm/trellis/transfer.d.ts.map +1 -0
  128. package/esm/trellis/transfer.js +357 -0
  129. package/esm/trellis/trellis.d.ts +3 -0
  130. package/esm/trellis/trellis.d.ts.map +1 -1
  131. package/esm/trellis/trellis.js +48 -17
  132. package/package.json +8 -3
  133. package/script/auth/device_activation.d.ts +194 -0
  134. package/script/auth/device_activation.d.ts.map +1 -0
  135. package/script/auth/{workload_activation.js → device_activation.js} +99 -74
  136. package/script/auth/mod.d.ts +2 -2
  137. package/script/auth/mod.d.ts.map +1 -1
  138. package/script/auth/mod.js +84 -76
  139. package/script/auth/protocol.d.ts +175 -72
  140. package/script/auth/protocol.d.ts.map +1 -1
  141. package/script/auth/protocol.js +129 -81
  142. package/script/contracts/mod.d.ts +22 -2
  143. package/script/contracts/mod.d.ts.map +1 -1
  144. package/script/contracts/mod.js +32 -4
  145. package/script/contracts/protocol.d.ts +34 -0
  146. package/script/contracts/protocol.d.ts.map +1 -1
  147. package/script/contracts/protocol.js +16 -1
  148. package/script/telemetry/init.d.ts +4 -0
  149. package/script/telemetry/init.d.ts.map +1 -0
  150. package/script/telemetry/init.js +11 -0
  151. package/script/telemetry/mod.d.ts +1 -2
  152. package/script/telemetry/mod.d.ts.map +1 -1
  153. package/script/telemetry/mod.js +1 -4
  154. package/script/telemetry/runtime.d.ts.map +1 -1
  155. package/script/telemetry/runtime.js +9 -28
  156. package/script/telemetry/trellis.d.ts +0 -1
  157. package/script/telemetry/trellis.d.ts.map +1 -1
  158. package/script/telemetry/trellis.js +0 -7
  159. package/script/trellis/_sdk/activity/contract.d.ts +1 -1
  160. package/script/trellis/_sdk/activity/contract.d.ts.map +1 -1
  161. package/script/trellis/_sdk/activity/contract.js +2 -2
  162. package/script/trellis/_sdk/activity/types.d.ts +1 -1
  163. package/script/trellis/_sdk/activity/types.js +1 -1
  164. package/script/trellis/_sdk/auth/api.d.ts.map +1 -1
  165. package/script/trellis/_sdk/auth/api.js +132 -110
  166. package/script/trellis/_sdk/auth/contract.d.ts +1 -1
  167. package/script/trellis/_sdk/auth/contract.d.ts.map +1 -1
  168. package/script/trellis/_sdk/auth/contract.js +2 -2
  169. package/script/trellis/_sdk/auth/schemas.d.ts +4212 -3069
  170. package/script/trellis/_sdk/auth/schemas.d.ts.map +1 -1
  171. package/script/trellis/_sdk/auth/schemas.js +144 -125
  172. package/script/trellis/_sdk/auth/types.d.ts +417 -267
  173. package/script/trellis/_sdk/auth/types.d.ts.map +1 -1
  174. package/script/trellis/_sdk/auth/types.js +1 -1
  175. package/script/trellis/_sdk/core/contract.d.ts +1 -1
  176. package/script/trellis/_sdk/core/contract.d.ts.map +1 -1
  177. package/script/trellis/_sdk/core/contract.js +2 -2
  178. package/script/trellis/_sdk/core/schemas.d.ts +122 -0
  179. package/script/trellis/_sdk/core/schemas.d.ts.map +1 -1
  180. package/script/trellis/_sdk/core/schemas.js +4 -4
  181. package/script/trellis/_sdk/core/types.d.ts +18 -1
  182. package/script/trellis/_sdk/core/types.d.ts.map +1 -1
  183. package/script/trellis/_sdk/core/types.js +1 -1
  184. package/script/trellis/_sdk/state/_dnt.polyfills.d.ts +12 -0
  185. package/script/trellis/_sdk/state/_dnt.polyfills.d.ts.map +1 -0
  186. package/script/trellis/_sdk/state/_dnt.polyfills.js +16 -0
  187. package/script/trellis/_sdk/state/api.d.ts +10 -0
  188. package/script/trellis/_sdk/state/api.d.ts.map +1 -0
  189. package/script/trellis/_sdk/state/api.js +74 -0
  190. package/script/trellis/_sdk/state/contract.d.ts +8 -0
  191. package/script/trellis/_sdk/state/contract.d.ts.map +1 -0
  192. package/script/trellis/_sdk/state/contract.js +62 -0
  193. package/script/trellis/_sdk/state/mod.d.ts +7 -0
  194. package/script/trellis/_sdk/state/mod.d.ts.map +1 -0
  195. package/script/trellis/_sdk/state/mod.js +30 -0
  196. package/script/trellis/_sdk/state/package.json +3 -0
  197. package/script/trellis/_sdk/state/schemas.d.ts +1437 -0
  198. package/script/trellis/_sdk/state/schemas.d.ts.map +1 -0
  199. package/script/trellis/_sdk/state/schemas.js +65 -0
  200. package/script/trellis/_sdk/state/types.d.ts +206 -0
  201. package/script/trellis/_sdk/state/types.d.ts.map +1 -0
  202. package/script/trellis/_sdk/state/types.js +6 -0
  203. package/script/trellis/client_connect.d.ts +53 -0
  204. package/script/trellis/client_connect.d.ts.map +1 -0
  205. package/script/trellis/client_connect.js +304 -0
  206. package/script/trellis/contract.d.ts +1 -7
  207. package/script/trellis/contract.d.ts.map +1 -1
  208. package/script/trellis/contract.js +1 -12
  209. package/script/trellis/device.d.ts +41 -0
  210. package/script/trellis/device.d.ts.map +1 -0
  211. package/script/trellis/device.js +213 -0
  212. package/script/trellis/errors/AuthError.d.ts +1 -1
  213. package/script/trellis/errors/AuthError.js +9 -9
  214. package/script/trellis/errors/StoreError.d.ts +22 -0
  215. package/script/trellis/errors/StoreError.d.ts.map +1 -0
  216. package/script/trellis/errors/StoreError.js +48 -0
  217. package/script/trellis/errors/TransferError.d.ts +22 -0
  218. package/script/trellis/errors/TransferError.d.ts.map +1 -0
  219. package/script/trellis/errors/TransferError.js +48 -0
  220. package/script/trellis/errors/index.d.ts +8 -0
  221. package/script/trellis/errors/index.d.ts.map +1 -1
  222. package/script/trellis/errors/index.js +13 -1
  223. package/script/trellis/index.d.ts +10 -4
  224. package/script/trellis/index.d.ts.map +1 -1
  225. package/script/trellis/index.js +17 -6
  226. package/script/trellis/kv.d.ts +2 -0
  227. package/script/trellis/kv.d.ts.map +1 -1
  228. package/script/trellis/kv.js +6 -0
  229. package/script/trellis/models/trellis/TrellisError.d.ts +15 -1
  230. package/script/trellis/models/trellis/TrellisError.d.ts.map +1 -1
  231. package/script/trellis/models/trellis/TrellisError.js +4 -0
  232. package/script/trellis/runtime_transport.d.ts +12 -0
  233. package/script/trellis/runtime_transport.d.ts.map +1 -0
  234. package/script/trellis/runtime_transport.js +37 -0
  235. package/script/trellis/store.d.ts +51 -0
  236. package/script/trellis/store.d.ts.map +1 -0
  237. package/script/trellis/store.js +316 -0
  238. package/script/trellis/tracing.js +1 -1
  239. package/script/trellis/transfer.d.ts +118 -0
  240. package/script/trellis/transfer.d.ts.map +1 -0
  241. package/script/trellis/transfer.js +367 -0
  242. package/script/trellis/trellis.d.ts +3 -0
  243. package/script/trellis/trellis.d.ts.map +1 -1
  244. package/script/trellis/trellis.js +48 -17
  245. package/esm/auth/workload_activation.d.ts +0 -192
  246. package/esm/auth/workload_activation.d.ts.map +0 -1
  247. package/esm/trellis/workload.d.ts +0 -45
  248. package/esm/trellis/workload.d.ts.map +0 -1
  249. package/esm/trellis/workload.js +0 -144
  250. package/script/auth/workload_activation.d.ts +0 -192
  251. package/script/auth/workload_activation.d.ts.map +0 -1
  252. package/script/trellis/workload.d.ts +0 -45
  253. package/script/trellis/workload.d.ts.map +0 -1
  254. package/script/trellis/workload.js +0 -172
@@ -0,0 +1,418 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _AsyncChunkQueue_values, _AsyncChunkQueue_resolvers, _AsyncChunkQueue_closed, _AsyncChunkQueue_error, _ServiceTransfer_instances, _ServiceTransfer_name, _ServiceTransfer_nc, _ServiceTransfer_auth, _ServiceTransfer_stores, _ServiceTransfer_chunkBytes, _ServiceTransfer_uploadSessions, _ServiceTransfer_downloadSessions, _ServiceTransfer_openStore, _ServiceTransfer_runUploadSession, _ServiceTransfer_handleUploadMessage, _ServiceTransfer_runDownloadSession, _ServiceTransfer_handleDownloadRequest, _ServiceTransfer_expireUploadSession, _ServiceTransfer_cleanupUploadSession, _ServiceTransfer_cleanupDownloadSession;
13
+ import { isErr, Result } from "@qlever-llc/result";
14
+ import { headers as natsHeaders } from "@nats-io/nats-core";
15
+ import { ulid } from "ulid";
16
+ import { TransferError } from "../trellis/errors/TransferError.js";
17
+ import { verifyTransferMessage } from "../trellis/transfer.js";
18
+ const UPLOAD_SUBJECT_PREFIX = "transfer.v1.upload";
19
+ const DOWNLOAD_SUBJECT_PREFIX = "transfer.v1.download";
20
+ const TRANSFER_SEQUENCE_HEADER = "trellis-transfer-seq";
21
+ const TRANSFER_EOF_HEADER = "trellis-transfer-eof";
22
+ const DEFAULT_TRANSFER_CHUNK_BYTES = 256 * 1024;
23
+ class AsyncChunkQueue {
24
+ constructor() {
25
+ _AsyncChunkQueue_values.set(this, []);
26
+ _AsyncChunkQueue_resolvers.set(this, []);
27
+ _AsyncChunkQueue_closed.set(this, false);
28
+ _AsyncChunkQueue_error.set(this, void 0);
29
+ }
30
+ push(chunk) {
31
+ if (__classPrivateFieldGet(this, _AsyncChunkQueue_closed, "f")) {
32
+ return;
33
+ }
34
+ const resolver = __classPrivateFieldGet(this, _AsyncChunkQueue_resolvers, "f").shift();
35
+ if (resolver) {
36
+ resolver({ value: chunk, done: false });
37
+ return;
38
+ }
39
+ __classPrivateFieldGet(this, _AsyncChunkQueue_values, "f").push(chunk);
40
+ }
41
+ close() {
42
+ if (__classPrivateFieldGet(this, _AsyncChunkQueue_closed, "f")) {
43
+ return;
44
+ }
45
+ __classPrivateFieldSet(this, _AsyncChunkQueue_closed, true, "f");
46
+ while (__classPrivateFieldGet(this, _AsyncChunkQueue_resolvers, "f").length > 0) {
47
+ __classPrivateFieldGet(this, _AsyncChunkQueue_resolvers, "f").shift()?.({ value: undefined, done: true });
48
+ }
49
+ }
50
+ fail(error) {
51
+ if (__classPrivateFieldGet(this, _AsyncChunkQueue_closed, "f")) {
52
+ return;
53
+ }
54
+ __classPrivateFieldSet(this, _AsyncChunkQueue_error, error, "f");
55
+ __classPrivateFieldSet(this, _AsyncChunkQueue_closed, true, "f");
56
+ while (__classPrivateFieldGet(this, _AsyncChunkQueue_resolvers, "f").length > 0) {
57
+ __classPrivateFieldGet(this, _AsyncChunkQueue_resolvers, "f").shift()?.({ value: undefined, done: true });
58
+ }
59
+ }
60
+ async next() {
61
+ if (__classPrivateFieldGet(this, _AsyncChunkQueue_values, "f").length > 0) {
62
+ return { value: __classPrivateFieldGet(this, _AsyncChunkQueue_values, "f").shift(), done: false };
63
+ }
64
+ if (__classPrivateFieldGet(this, _AsyncChunkQueue_error, "f")) {
65
+ throw __classPrivateFieldGet(this, _AsyncChunkQueue_error, "f");
66
+ }
67
+ if (__classPrivateFieldGet(this, _AsyncChunkQueue_closed, "f")) {
68
+ return { value: undefined, done: true };
69
+ }
70
+ return await new Promise((resolve) => {
71
+ __classPrivateFieldGet(this, _AsyncChunkQueue_resolvers, "f").push(resolve);
72
+ });
73
+ }
74
+ [(_AsyncChunkQueue_values = new WeakMap(), _AsyncChunkQueue_resolvers = new WeakMap(), _AsyncChunkQueue_closed = new WeakMap(), _AsyncChunkQueue_error = new WeakMap(), Symbol.asyncIterator)]() {
75
+ return {
76
+ next: () => this.next(),
77
+ };
78
+ }
79
+ }
80
+ function fileInfoFromStoreInfo(info) {
81
+ return {
82
+ key: info.key,
83
+ size: info.size,
84
+ updatedAt: info.updatedAt,
85
+ ...(info.digest ? { digest: info.digest } : {}),
86
+ ...(info.contentType ? { contentType: info.contentType } : {}),
87
+ metadata: info.metadata,
88
+ };
89
+ }
90
+ function replyError(msg, error) {
91
+ const headers = natsHeaders();
92
+ headers.set("status", "error");
93
+ msg.respond(JSON.stringify(error.toSerializable()), { headers });
94
+ }
95
+ function publishError(nc, subject, error) {
96
+ const headers = natsHeaders();
97
+ headers.set("status", "error");
98
+ nc.publish(subject, JSON.stringify(error.toSerializable()), { headers });
99
+ }
100
+ function parseSeq(msg) {
101
+ const raw = msg.headers?.get(TRANSFER_SEQUENCE_HEADER);
102
+ if (!raw) {
103
+ return Result.err(new TransferError({ operation: "transfer", context: { reason: "missing_sequence" } }));
104
+ }
105
+ const value = Number(raw);
106
+ if (!Number.isInteger(value) || value < 0) {
107
+ return Result.err(new TransferError({ operation: "transfer", context: { reason: "invalid_sequence", raw } }));
108
+ }
109
+ return Result.ok(value);
110
+ }
111
+ async function* iterateStream(stream) {
112
+ const reader = stream.getReader();
113
+ try {
114
+ while (true) {
115
+ const next = await reader.read();
116
+ if (next.done) {
117
+ return;
118
+ }
119
+ yield next.value;
120
+ }
121
+ }
122
+ finally {
123
+ reader.releaseLock();
124
+ }
125
+ }
126
+ export class ServiceTransfer {
127
+ constructor(opts) {
128
+ _ServiceTransfer_instances.add(this);
129
+ _ServiceTransfer_name.set(this, void 0);
130
+ _ServiceTransfer_nc.set(this, void 0);
131
+ _ServiceTransfer_auth.set(this, void 0);
132
+ _ServiceTransfer_stores.set(this, void 0);
133
+ _ServiceTransfer_chunkBytes.set(this, void 0);
134
+ _ServiceTransfer_uploadSessions.set(this, new Map());
135
+ _ServiceTransfer_downloadSessions.set(this, new Map());
136
+ __classPrivateFieldSet(this, _ServiceTransfer_name, opts.name, "f");
137
+ __classPrivateFieldSet(this, _ServiceTransfer_nc, opts.nc, "f");
138
+ __classPrivateFieldSet(this, _ServiceTransfer_auth, opts.auth, "f");
139
+ __classPrivateFieldSet(this, _ServiceTransfer_stores, opts.stores, "f");
140
+ __classPrivateFieldSet(this, _ServiceTransfer_chunkBytes, opts.chunkBytes ?? DEFAULT_TRANSFER_CHUNK_BYTES, "f");
141
+ }
142
+ async initiateUpload(args) {
143
+ const store = await __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_openStore).call(this, args.store, "initiateUpload");
144
+ const storeValue = store.take();
145
+ if (isErr(storeValue)) {
146
+ return Result.err(storeValue.error);
147
+ }
148
+ const transferId = ulid();
149
+ const subject = `${UPLOAD_SUBJECT_PREFIX}.${__classPrivateFieldGet(this, _ServiceTransfer_auth, "f").sessionKey.slice(0, 16)}.${transferId}`;
150
+ const expiresAtMs = Date.now() + args.expiresInMs;
151
+ const queue = new AsyncChunkQueue();
152
+ const subscription = __classPrivateFieldGet(this, _ServiceTransfer_nc, "f").subscribe(subject);
153
+ const putPromise = storeValue.put(args.key, queue, {
154
+ ...(args.contentType ? { contentType: args.contentType } : {}),
155
+ ...(args.metadata ? { metadata: args.metadata } : {}),
156
+ });
157
+ const session = {
158
+ kind: "upload",
159
+ subject,
160
+ transferId,
161
+ sessionKey: args.sessionKey,
162
+ expiresAtMs,
163
+ store: storeValue,
164
+ key: args.key,
165
+ ...(args.maxBytes !== undefined ? { maxBytes: args.maxBytes } : {}),
166
+ ...(args.contentType ? { contentType: args.contentType } : {}),
167
+ ...(args.metadata ? { metadata: args.metadata } : {}),
168
+ subscription,
169
+ timeoutId: setTimeout(() => __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, subject), args.expiresInMs),
170
+ queue,
171
+ putPromise,
172
+ nextSeq: 0,
173
+ receivedBytes: 0,
174
+ };
175
+ __classPrivateFieldGet(this, _ServiceTransfer_uploadSessions, "f").set(subject, session);
176
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_runUploadSession).call(this, session);
177
+ return Result.ok({
178
+ type: "TransferGrant",
179
+ kind: "upload",
180
+ service: __classPrivateFieldGet(this, _ServiceTransfer_name, "f"),
181
+ sessionKey: args.sessionKey,
182
+ transferId,
183
+ subject,
184
+ expiresAt: new Date(expiresAtMs).toISOString(),
185
+ chunkBytes: __classPrivateFieldGet(this, _ServiceTransfer_chunkBytes, "f"),
186
+ ...(args.maxBytes !== undefined ? { maxBytes: args.maxBytes } : {}),
187
+ ...(args.contentType ? { contentType: args.contentType } : {}),
188
+ ...(args.metadata ? { metadata: args.metadata } : {}),
189
+ });
190
+ }
191
+ async initiateDownload(args) {
192
+ const store = await __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_openStore).call(this, args.store, "initiateDownload");
193
+ const storeValue = store.take();
194
+ if (isErr(storeValue)) {
195
+ return Result.err(storeValue.error);
196
+ }
197
+ const entry = await storeValue.get(args.key);
198
+ const entryValue = entry.take();
199
+ if (isErr(entryValue)) {
200
+ return Result.err(new TransferError({ operation: "initiateDownload", cause: entryValue.error }));
201
+ }
202
+ const transferId = ulid();
203
+ const subject = `${DOWNLOAD_SUBJECT_PREFIX}.${__classPrivateFieldGet(this, _ServiceTransfer_auth, "f").sessionKey.slice(0, 16)}.${transferId}`;
204
+ const expiresAtMs = Date.now() + args.expiresInMs;
205
+ const subscription = __classPrivateFieldGet(this, _ServiceTransfer_nc, "f").subscribe(subject);
206
+ const session = {
207
+ kind: "download",
208
+ subject,
209
+ transferId,
210
+ sessionKey: args.sessionKey,
211
+ expiresAtMs,
212
+ store: storeValue,
213
+ key: args.key,
214
+ info: fileInfoFromStoreInfo(entryValue.info),
215
+ subscription,
216
+ timeoutId: setTimeout(() => __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_cleanupDownloadSession).call(this, subject), args.expiresInMs),
217
+ };
218
+ __classPrivateFieldGet(this, _ServiceTransfer_downloadSessions, "f").set(subject, session);
219
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_runDownloadSession).call(this, session);
220
+ return Result.ok({
221
+ type: "TransferGrant",
222
+ kind: "download",
223
+ service: __classPrivateFieldGet(this, _ServiceTransfer_name, "f"),
224
+ sessionKey: args.sessionKey,
225
+ transferId,
226
+ subject,
227
+ expiresAt: new Date(expiresAtMs).toISOString(),
228
+ chunkBytes: __classPrivateFieldGet(this, _ServiceTransfer_chunkBytes, "f"),
229
+ info: session.info,
230
+ });
231
+ }
232
+ async stop() {
233
+ for (const subject of [...__classPrivateFieldGet(this, _ServiceTransfer_uploadSessions, "f").keys()]) {
234
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, subject);
235
+ }
236
+ for (const subject of [...__classPrivateFieldGet(this, _ServiceTransfer_downloadSessions, "f").keys()]) {
237
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_cleanupDownloadSession).call(this, subject);
238
+ }
239
+ }
240
+ }
241
+ _ServiceTransfer_name = new WeakMap(), _ServiceTransfer_nc = new WeakMap(), _ServiceTransfer_auth = new WeakMap(), _ServiceTransfer_stores = new WeakMap(), _ServiceTransfer_chunkBytes = new WeakMap(), _ServiceTransfer_uploadSessions = new WeakMap(), _ServiceTransfer_downloadSessions = new WeakMap(), _ServiceTransfer_instances = new WeakSet(), _ServiceTransfer_openStore = async function _ServiceTransfer_openStore(alias, operation) {
242
+ const handle = __classPrivateFieldGet(this, _ServiceTransfer_stores, "f")[alias];
243
+ if (!handle) {
244
+ return Result.err(new TransferError({ operation, context: { reason: "unknown_store", store: alias } }));
245
+ }
246
+ const store = await handle.open();
247
+ const value = store.take();
248
+ if (isErr(value)) {
249
+ return Result.err(new TransferError({ operation, cause: value.error, context: { store: alias } }));
250
+ }
251
+ return Result.ok(value);
252
+ }, _ServiceTransfer_runUploadSession = async function _ServiceTransfer_runUploadSession(session) {
253
+ try {
254
+ for await (const msg of session.subscription) {
255
+ await __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_handleUploadMessage).call(this, session, msg);
256
+ if (!__classPrivateFieldGet(this, _ServiceTransfer_uploadSessions, "f").has(session.subject)) {
257
+ break;
258
+ }
259
+ }
260
+ }
261
+ finally {
262
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_cleanupUploadSession).call(this, session.subject);
263
+ }
264
+ }, _ServiceTransfer_handleUploadMessage = async function _ServiceTransfer_handleUploadMessage(session, msg) {
265
+ if (Date.now() >= session.expiresAtMs) {
266
+ replyError(msg, new TransferError({ operation: "put", context: { reason: "expired" } }));
267
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
268
+ return;
269
+ }
270
+ const authenticated = await verifyTransferMessage({
271
+ expectedSessionKey: session.sessionKey,
272
+ subject: msg.subject,
273
+ payload: msg.data,
274
+ proof: msg.headers?.get("proof"),
275
+ sessionKey: msg.headers?.get("session-key"),
276
+ });
277
+ if (!authenticated) {
278
+ replyError(msg, new TransferError({ operation: "put", context: { reason: "invalid_proof" } }));
279
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
280
+ return;
281
+ }
282
+ const seq = parseSeq(msg).take();
283
+ if (isErr(seq)) {
284
+ replyError(msg, seq.error);
285
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
286
+ return;
287
+ }
288
+ if (seq !== session.nextSeq) {
289
+ replyError(msg, new TransferError({
290
+ operation: "put",
291
+ context: { reason: "out_of_order", expected: session.nextSeq, actual: seq },
292
+ }));
293
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
294
+ return;
295
+ }
296
+ if (msg.data.length > 0) {
297
+ if (msg.data.length > __classPrivateFieldGet(this, _ServiceTransfer_chunkBytes, "f")) {
298
+ replyError(msg, new TransferError({ operation: "put", context: { reason: "chunk_too_large", maxChunkBytes: __classPrivateFieldGet(this, _ServiceTransfer_chunkBytes, "f") } }));
299
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
300
+ return;
301
+ }
302
+ session.receivedBytes += msg.data.length;
303
+ if (session.maxBytes !== undefined && session.receivedBytes > session.maxBytes) {
304
+ replyError(msg, new TransferError({
305
+ operation: "put",
306
+ context: { reason: "max_bytes_exceeded", maxBytes: session.maxBytes, attemptedBytes: session.receivedBytes },
307
+ }));
308
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
309
+ return;
310
+ }
311
+ session.queue.push(msg.data);
312
+ }
313
+ session.nextSeq += 1;
314
+ if (msg.headers?.get(TRANSFER_EOF_HEADER) === "true") {
315
+ session.queue.close();
316
+ const putResult = await session.putPromise;
317
+ const putValue = putResult.take();
318
+ if (isErr(putValue)) {
319
+ replyError(msg, new TransferError({ operation: "put", cause: putValue.error }));
320
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
321
+ return;
322
+ }
323
+ const stored = await session.store.get(session.key);
324
+ const storedValue = stored.take();
325
+ if (isErr(storedValue)) {
326
+ replyError(msg, new TransferError({ operation: "put", cause: storedValue.error }));
327
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_expireUploadSession).call(this, session.subject);
328
+ return;
329
+ }
330
+ msg.respond(JSON.stringify({ status: "complete", info: fileInfoFromStoreInfo(storedValue.info) }));
331
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_cleanupUploadSession).call(this, session.subject);
332
+ return;
333
+ }
334
+ msg.respond(JSON.stringify({ status: "continue" }));
335
+ }, _ServiceTransfer_runDownloadSession = async function _ServiceTransfer_runDownloadSession(session) {
336
+ try {
337
+ for await (const msg of session.subscription) {
338
+ await __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_handleDownloadRequest).call(this, session, msg);
339
+ break;
340
+ }
341
+ }
342
+ finally {
343
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_cleanupDownloadSession).call(this, session.subject);
344
+ }
345
+ }, _ServiceTransfer_handleDownloadRequest = async function _ServiceTransfer_handleDownloadRequest(session, msg) {
346
+ const reply = msg.reply;
347
+ if (!reply || !reply.startsWith(`_INBOX.${session.sessionKey.slice(0, 16)}.`)) {
348
+ replyError(msg, new TransferError({ operation: "get", context: { reason: "reply_subject_mismatch" } }));
349
+ return;
350
+ }
351
+ if (Date.now() >= session.expiresAtMs) {
352
+ publishError(__classPrivateFieldGet(this, _ServiceTransfer_nc, "f"), reply, new TransferError({ operation: "get", context: { reason: "expired" } }));
353
+ return;
354
+ }
355
+ const authenticated = await verifyTransferMessage({
356
+ expectedSessionKey: session.sessionKey,
357
+ subject: msg.subject,
358
+ payload: msg.data,
359
+ proof: msg.headers?.get("proof"),
360
+ sessionKey: msg.headers?.get("session-key"),
361
+ });
362
+ if (!authenticated) {
363
+ publishError(__classPrivateFieldGet(this, _ServiceTransfer_nc, "f"), reply, new TransferError({ operation: "get", context: { reason: "invalid_proof" } }));
364
+ return;
365
+ }
366
+ const entry = await session.store.get(session.key);
367
+ const entryValue = entry.take();
368
+ if (isErr(entryValue)) {
369
+ publishError(__classPrivateFieldGet(this, _ServiceTransfer_nc, "f"), reply, new TransferError({ operation: "get", cause: entryValue.error }));
370
+ return;
371
+ }
372
+ const stream = await entryValue.stream();
373
+ const streamValue = stream.take();
374
+ if (isErr(streamValue)) {
375
+ publishError(__classPrivateFieldGet(this, _ServiceTransfer_nc, "f"), reply, new TransferError({ operation: "get", cause: streamValue.error }));
376
+ return;
377
+ }
378
+ let seq = 0;
379
+ try {
380
+ for await (const chunk of iterateStream(streamValue)) {
381
+ const headers = natsHeaders();
382
+ headers.set(TRANSFER_SEQUENCE_HEADER, String(seq));
383
+ __classPrivateFieldGet(this, _ServiceTransfer_nc, "f").publish(reply, chunk, { headers });
384
+ seq += 1;
385
+ }
386
+ const finalHeaders = natsHeaders();
387
+ finalHeaders.set(TRANSFER_SEQUENCE_HEADER, String(seq));
388
+ finalHeaders.set(TRANSFER_EOF_HEADER, "true");
389
+ __classPrivateFieldGet(this, _ServiceTransfer_nc, "f").publish(reply, new Uint8Array(), { headers: finalHeaders });
390
+ await __classPrivateFieldGet(this, _ServiceTransfer_nc, "f").flush();
391
+ }
392
+ catch (cause) {
393
+ publishError(__classPrivateFieldGet(this, _ServiceTransfer_nc, "f"), reply, new TransferError({ operation: "get", cause }));
394
+ }
395
+ }, _ServiceTransfer_expireUploadSession = function _ServiceTransfer_expireUploadSession(subject) {
396
+ const session = __classPrivateFieldGet(this, _ServiceTransfer_uploadSessions, "f").get(subject);
397
+ if (!session) {
398
+ return;
399
+ }
400
+ session.queue.fail(new TransferError({ operation: "put", context: { reason: "expired" } }));
401
+ __classPrivateFieldGet(this, _ServiceTransfer_instances, "m", _ServiceTransfer_cleanupUploadSession).call(this, subject);
402
+ }, _ServiceTransfer_cleanupUploadSession = function _ServiceTransfer_cleanupUploadSession(subject) {
403
+ const session = __classPrivateFieldGet(this, _ServiceTransfer_uploadSessions, "f").get(subject);
404
+ if (!session) {
405
+ return;
406
+ }
407
+ clearTimeout(session.timeoutId);
408
+ session.subscription.unsubscribe();
409
+ __classPrivateFieldGet(this, _ServiceTransfer_uploadSessions, "f").delete(subject);
410
+ }, _ServiceTransfer_cleanupDownloadSession = function _ServiceTransfer_cleanupDownloadSession(subject) {
411
+ const session = __classPrivateFieldGet(this, _ServiceTransfer_downloadSessions, "f").get(subject);
412
+ if (!session) {
413
+ return;
414
+ }
415
+ clearTimeout(session.timeoutId);
416
+ session.subscription.unsubscribe();
417
+ __classPrivateFieldGet(this, _ServiceTransfer_downloadSessions, "f").delete(subject);
418
+ };
@@ -0,0 +1,4 @@
1
+ import { initTelemetry } from "./runtime.js";
2
+ export declare function initTracing(serviceName: string): void;
3
+ export { initTelemetry };
4
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/telemetry/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAGrD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { configureErrorTraceId } from "./result.js";
2
+ import { initTelemetry } from "./runtime.js";
3
+ export function initTracing(serviceName) {
4
+ configureErrorTraceId();
5
+ initTelemetry(serviceName);
6
+ }
7
+ export { initTelemetry };
@@ -6,6 +6,5 @@ export { getEnv } from "./env.js";
6
6
  export type { NatsHeadersLike } from "./nats.js";
7
7
  export { createNatsHeaderCarrier } from "./nats.js";
8
8
  export { configureErrorTraceId } from "./result.js";
9
- export { initTelemetry } from "./runtime.js";
10
- export { getTrellisTracer, initTracing, startClientSpan, startServerSpan } from "./trellis.js";
9
+ export { getTrellisTracer, startClientSpan, startServerSpan } from "./trellis.js";
11
10
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/telemetry/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACzF,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,QAAQ,EACR,cAAc,EACd,KAAK,EACL,QAAQ,EACR,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/telemetry/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACzF,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,QAAQ,EACR,cAAc,EACd,KAAK,EACL,QAAQ,EACR,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
@@ -3,5 +3,4 @@ export { context, getActiveSpan, getTracer, SpanKind, SpanStatusCode, trace, wit
3
3
  export { getEnv } from "./env.js";
4
4
  export { createNatsHeaderCarrier } from "./nats.js";
5
5
  export { configureErrorTraceId } from "./result.js";
6
- export { initTelemetry } from "./runtime.js";
7
- export { getTrellisTracer, initTracing, startClientSpan, startServerSpan } from "./trellis.js";
6
+ export { getTrellisTracer, startClientSpan, startServerSpan } from "./trellis.js";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/telemetry/runtime.ts"],"names":[],"mappings":"AAsEA,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAKvD"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/telemetry/runtime.ts"],"names":[],"mappings":"AAuFA,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAKvD"}
@@ -1,13 +1,17 @@
1
1
  import { getEnv } from "./env.js";
2
2
  let initialized = false;
3
3
  let provider;
4
+ function runtimeImport(specifier) {
5
+ const load = new Function("specifier", "return import(specifier);");
6
+ return load(specifier);
7
+ }
4
8
  async function loadTracingRuntime() {
5
9
  const [traceNode, otlp, traceBase, resources, semantic] = await Promise.all([
6
- import("@opentelemetry/sdk-trace-node"),
7
- import("@opentelemetry/exporter-trace-otlp-http"),
8
- import("@opentelemetry/sdk-trace-base"),
9
- import("@opentelemetry/resources"),
10
- import("@opentelemetry/semantic-conventions"),
10
+ runtimeImport(["@opentelemetry", "sdk-trace-node"].join("/")),
11
+ runtimeImport(["@opentelemetry", "exporter-trace-otlp-http"].join("/")),
12
+ runtimeImport(["@opentelemetry", "sdk-trace-base"].join("/")),
13
+ runtimeImport(["@opentelemetry", "resources"].join("/")),
14
+ runtimeImport(["@opentelemetry", "semantic-conventions"].join("/")),
11
15
  ]);
12
16
  return {
13
17
  NodeTracerProvider: traceNode.NodeTracerProvider,
@@ -1,3 +1,2 @@
1
1
  export { getTrellisTracer, startClientSpan, startServerSpan } from "./trace.js";
2
- export declare function initTracing(serviceName: string): void;
3
2
  //# sourceMappingURL=trellis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trellis.d.ts","sourceRoot":"","sources":["../../src/telemetry/trellis.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhF,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAGrD"}
1
+ {"version":3,"file":"trellis.d.ts","sourceRoot":"","sources":["../../src/telemetry/trellis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -1,7 +1 @@
1
- import { configureErrorTraceId } from "./result.js";
2
- import { initTelemetry } from "./runtime.js";
3
1
  export { getTrellisTracer, startClientSpan, startServerSpan } from "./trace.js";
4
- export function initTracing(serviceName) {
5
- configureErrorTraceId();
6
- initTelemetry(serviceName);
7
- }
@@ -1,7 +1,7 @@
1
1
  import type { SdkContractModule, TrellisContractV1 } from "../../../contracts/mod.js";
2
2
  import { API } from "./api.js";
3
3
  export declare const CONTRACT_ID: "trellis.activity@v1";
4
- export declare const CONTRACT_DIGEST: "mP5-UZveN1iEWgDwCvoVBwtz7sgxWwPnHY1rJr4cT6Q";
4
+ export declare const CONTRACT_DIGEST: "8XMeFEPqJwnSMoVDShJ3C-S_7WXjeJMDftajM-GHBhg";
5
5
  export declare const CONTRACT: TrellisContractV1;
6
6
  export declare const activity: SdkContractModule<typeof CONTRACT_ID, typeof API.owned>;
7
7
  export declare const use: any;
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAW,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,eAAO,MAAM,WAAW,uBAAiC,CAAC;AAC1D,eAAO,MAAM,eAAe,+CAAyD,CAAC;AACtF,eAAO,MAAM,QAAQ,EAAuwK,iBAAiB,CAAC;AA2B9yK,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,OAAO,WAAW,EAAE,OAAO,GAAG,CAAC,KAAK,CAqC5E,CAAC;AAEF,eAAO,MAAM,GAAG,KAAe,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAW,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,eAAO,MAAM,WAAW,uBAAiC,CAAC;AAC1D,eAAO,MAAM,eAAe,+CAAyD,CAAC;AACtF,eAAO,MAAM,QAAQ,EAAwxK,iBAAiB,CAAC;AA2B/zK,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,OAAO,WAAW,EAAE,OAAO,GAAG,CAAC,KAAK,CAqC5E,CAAC;AAEF,eAAO,MAAM,GAAG,KAAe,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { API } from "./api.js";
2
2
  const CONTRACT_MODULE_METADATA = Symbol.for("../../../contracts/mod.js/contract-module");
3
3
  export const CONTRACT_ID = "trellis.activity@v1";
4
- export const CONTRACT_DIGEST = "mP5-UZveN1iEWgDwCvoVBwtz7sgxWwPnHY1rJr4cT6Q";
5
- export const CONTRACT = { "description": "Project authentication activity into queryable audit records.", "displayName": "Trellis Activity", "events": { "Activity.Recorded": { "capabilities": { "publish": ["service:events:activity"], "subscribe": ["service:events:activity"] }, "event": { "schema": "ActivityRecordedEvent" }, "subject": "events.v1.Activity.Recorded", "version": "v1" } }, "format": "trellis.contract.v1", "id": "trellis.activity@v1", "resources": { "kv": { "activity": { "history": 1, "purpose": "Store normalized audit activity entries for the service projection.", "required": true, "ttlMs": 0 } } }, "rpc": { "Activity.Get": { "capabilities": { "call": ["admin"] }, "errors": [{ "type": "ValidationError" }, { "type": "UnexpectedError" }], "input": { "schema": "ActivityGetRequest" }, "output": { "schema": "ActivityGetResponse" }, "subject": "rpc.v1.Activity.Get", "version": "v1" }, "Activity.Health": { "capabilities": { "call": [] }, "errors": [{ "type": "UnexpectedError" }], "input": { "schema": "HealthRequest" }, "output": { "schema": "HealthResponse" }, "subject": "rpc.v1.Activity.Health", "version": "v1" }, "Activity.List": { "capabilities": { "call": ["admin"] }, "errors": [{ "type": "ValidationError" }, { "type": "UnexpectedError" }], "input": { "schema": "ActivityListRequest" }, "output": { "schema": "ActivityListResponse" }, "subject": "rpc.v1.Activity.List", "version": "v1" } }, "schemas": { "ActivityGetRequest": { "additionalProperties": false, "properties": { "id": { "type": "string" } }, "required": ["id"], "type": "object" }, "ActivityGetResponse": { "additionalProperties": false, "properties": { "entry": { "additionalProperties": false, "properties": { "actor": { "type": "string" }, "id": { "type": "string" }, "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "metadata": { "patternProperties": { "^.*$": {} }, "type": "object" }, "occurredAt": { "format": "date-time", "type": "string" }, "principalId": { "type": "string" }, "principalLabel": { "type": "string" }, "principalOrigin": { "type": "string" }, "sessionKey": { "type": "string" }, "summary": { "type": "string" }, "userNkey": { "type": "string" } }, "required": ["id", "kind", "occurredAt", "principalOrigin", "principalId", "principalLabel", "summary"], "type": "object" } }, "required": ["entry"], "type": "object" }, "ActivityListRequest": { "additionalProperties": false, "properties": { "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "limit": { "maximum": 200, "minimum": 1, "type": "integer" } }, "type": "object" }, "ActivityListResponse": { "additionalProperties": false, "properties": { "entries": { "items": { "additionalProperties": false, "properties": { "actor": { "type": "string" }, "id": { "type": "string" }, "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "metadata": { "patternProperties": { "^.*$": {} }, "type": "object" }, "occurredAt": { "format": "date-time", "type": "string" }, "principalId": { "type": "string" }, "principalLabel": { "type": "string" }, "principalOrigin": { "type": "string" }, "sessionKey": { "type": "string" }, "summary": { "type": "string" }, "userNkey": { "type": "string" } }, "required": ["id", "kind", "occurredAt", "principalOrigin", "principalId", "principalLabel", "summary"], "type": "object" }, "type": "array" } }, "required": ["entries"], "type": "object" }, "ActivityRecordedEvent": { "additionalProperties": false, "properties": { "actor": { "type": "string" }, "header": { "additionalProperties": false, "properties": { "id": { "type": "string" }, "time": { "format": "date-time", "type": "string" } }, "required": ["id", "time"], "type": "object" }, "id": { "type": "string" }, "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "metadata": { "patternProperties": { "^.*$": {} }, "type": "object" }, "occurredAt": { "format": "date-time", "type": "string" }, "principalId": { "type": "string" }, "principalLabel": { "type": "string" }, "principalOrigin": { "type": "string" }, "sessionKey": { "type": "string" }, "summary": { "type": "string" }, "userNkey": { "type": "string" } }, "required": ["header", "id", "kind", "occurredAt", "principalOrigin", "principalId", "principalLabel", "summary"], "type": "object" }, "HealthRequest": { "additionalProperties": false, "properties": {}, "type": "object" }, "HealthResponse": { "additionalProperties": false, "properties": { "checks": { "items": { "additionalProperties": false, "properties": { "error": { "type": "string" }, "latencyMs": { "type": "number" }, "name": { "type": "string" }, "status": { "anyOf": [{ "const": "ok", "type": "string" }, { "const": "failed", "type": "string" }] } }, "required": ["name", "status", "latencyMs"], "type": "object" }, "type": "array" }, "service": { "type": "string" }, "status": { "anyOf": [{ "const": "healthy", "type": "string" }, { "const": "unhealthy", "type": "string" }, { "const": "degraded", "type": "string" }] }, "timestamp": { "format": "date-time", "type": "string" } }, "required": ["status", "service", "timestamp", "checks"], "type": "object" } }, "uses": { "auth": { "contract": "trellis.auth@v1", "events": { "subscribe": ["Auth.Connect", "Auth.ConnectionKicked", "Auth.Disconnect", "Auth.SessionRevoked"] }, "rpc": { "call": ["Auth.Me", "Auth.Logout", "Auth.RenewBindingToken"] } }, "core": { "contract": "trellis.core@v1", "rpc": { "call": ["Trellis.Bindings.Get", "Trellis.Catalog"] } } } };
4
+ export const CONTRACT_DIGEST = "8XMeFEPqJwnSMoVDShJ3C-S_7WXjeJMDftajM-GHBhg";
5
+ export const CONTRACT = { "description": "Project authentication activity into queryable audit records.", "displayName": "Trellis Activity", "events": { "Activity.Recorded": { "capabilities": { "publish": ["service:events:activity"], "subscribe": ["service:events:activity"] }, "event": { "schema": "ActivityRecordedEvent" }, "subject": "events.v1.Activity.Recorded", "version": "v1" } }, "format": "trellis.contract.v1", "id": "trellis.activity@v1", "kind": "service", "resources": { "kv": { "activity": { "history": 1, "purpose": "Store normalized audit activity entries for the service projection.", "required": true, "ttlMs": 0 } } }, "rpc": { "Activity.Get": { "capabilities": { "call": ["admin"] }, "errors": [{ "type": "ValidationError" }, { "type": "UnexpectedError" }], "input": { "schema": "ActivityGetRequest" }, "output": { "schema": "ActivityGetResponse" }, "subject": "rpc.v1.Activity.Get", "version": "v1" }, "Activity.Health": { "capabilities": { "call": [] }, "errors": [{ "type": "UnexpectedError" }], "input": { "schema": "HealthRequest" }, "output": { "schema": "HealthResponse" }, "subject": "rpc.v1.Activity.Health", "version": "v1" }, "Activity.List": { "capabilities": { "call": ["admin"] }, "errors": [{ "type": "ValidationError" }, { "type": "UnexpectedError" }], "input": { "schema": "ActivityListRequest" }, "output": { "schema": "ActivityListResponse" }, "subject": "rpc.v1.Activity.List", "version": "v1" } }, "schemas": { "ActivityGetRequest": { "additionalProperties": false, "properties": { "id": { "type": "string" } }, "required": ["id"], "type": "object" }, "ActivityGetResponse": { "additionalProperties": false, "properties": { "entry": { "additionalProperties": false, "properties": { "actor": { "type": "string" }, "id": { "type": "string" }, "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "metadata": { "patternProperties": { "^.*$": {} }, "type": "object" }, "occurredAt": { "format": "date-time", "type": "string" }, "principalId": { "type": "string" }, "principalLabel": { "type": "string" }, "principalOrigin": { "type": "string" }, "sessionKey": { "type": "string" }, "summary": { "type": "string" }, "userNkey": { "type": "string" } }, "required": ["id", "kind", "occurredAt", "principalOrigin", "principalId", "principalLabel", "summary"], "type": "object" } }, "required": ["entry"], "type": "object" }, "ActivityListRequest": { "additionalProperties": false, "properties": { "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "limit": { "maximum": 200, "minimum": 1, "type": "integer" } }, "type": "object" }, "ActivityListResponse": { "additionalProperties": false, "properties": { "entries": { "items": { "additionalProperties": false, "properties": { "actor": { "type": "string" }, "id": { "type": "string" }, "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "metadata": { "patternProperties": { "^.*$": {} }, "type": "object" }, "occurredAt": { "format": "date-time", "type": "string" }, "principalId": { "type": "string" }, "principalLabel": { "type": "string" }, "principalOrigin": { "type": "string" }, "sessionKey": { "type": "string" }, "summary": { "type": "string" }, "userNkey": { "type": "string" } }, "required": ["id", "kind", "occurredAt", "principalOrigin", "principalId", "principalLabel", "summary"], "type": "object" }, "type": "array" } }, "required": ["entries"], "type": "object" }, "ActivityRecordedEvent": { "additionalProperties": false, "properties": { "actor": { "type": "string" }, "header": { "additionalProperties": false, "properties": { "id": { "type": "string" }, "time": { "format": "date-time", "type": "string" } }, "required": ["id", "time"], "type": "object" }, "id": { "type": "string" }, "kind": { "anyOf": [{ "const": "auth.connect", "type": "string" }, { "const": "auth.disconnect", "type": "string" }, { "const": "auth.session_revoked", "type": "string" }, { "const": "auth.connection_kicked", "type": "string" }] }, "metadata": { "patternProperties": { "^.*$": {} }, "type": "object" }, "occurredAt": { "format": "date-time", "type": "string" }, "principalId": { "type": "string" }, "principalLabel": { "type": "string" }, "principalOrigin": { "type": "string" }, "sessionKey": { "type": "string" }, "summary": { "type": "string" }, "userNkey": { "type": "string" } }, "required": ["header", "id", "kind", "occurredAt", "principalOrigin", "principalId", "principalLabel", "summary"], "type": "object" }, "HealthRequest": { "additionalProperties": false, "properties": {}, "type": "object" }, "HealthResponse": { "additionalProperties": false, "properties": { "checks": { "items": { "additionalProperties": false, "properties": { "error": { "type": "string" }, "latencyMs": { "type": "number" }, "name": { "type": "string" }, "status": { "anyOf": [{ "const": "ok", "type": "string" }, { "const": "failed", "type": "string" }] } }, "required": ["name", "status", "latencyMs"], "type": "object" }, "type": "array" }, "service": { "type": "string" }, "status": { "anyOf": [{ "const": "healthy", "type": "string" }, { "const": "unhealthy", "type": "string" }, { "const": "degraded", "type": "string" }] }, "timestamp": { "format": "date-time", "type": "string" } }, "required": ["status", "service", "timestamp", "checks"], "type": "object" } }, "uses": { "auth": { "contract": "trellis.auth@v1", "events": { "subscribe": ["Auth.Connect", "Auth.ConnectionKicked", "Auth.Disconnect", "Auth.SessionRevoked"] }, "rpc": { "call": ["Auth.Me", "Auth.Logout", "Auth.RenewBindingToken"] } }, "core": { "contract": "trellis.core@v1", "rpc": { "call": ["Trellis.Bindings.Get", "Trellis.Catalog"] } } } };
6
6
  function assertSelectedKeysExist(kind, keys, api) {
7
7
  if (!keys) {
8
8
  return;
@@ -1,5 +1,5 @@
1
1
  export declare const CONTRACT_ID: "trellis.activity@v1";
2
- export declare const CONTRACT_DIGEST: "mP5-UZveN1iEWgDwCvoVBwtz7sgxWwPnHY1rJr4cT6Q";
2
+ export declare const CONTRACT_DIGEST: "8XMeFEPqJwnSMoVDShJ3C-S_7WXjeJMDftajM-GHBhg";
3
3
  export type ActivityGetInput = {
4
4
  id: string;
5
5
  };
@@ -1,3 +1,3 @@
1
1
  // Generated from ./generated/contracts/manifests/trellis.activity@v1.json
2
2
  export const CONTRACT_ID = "trellis.activity@v1";
3
- export const CONTRACT_DIGEST = "mP5-UZveN1iEWgDwCvoVBwtz7sgxWwPnHY1rJr4cT6Q";
3
+ export const CONTRACT_DIGEST = "8XMeFEPqJwnSMoVDShJ3C-S_7WXjeJMDftajM-GHBhg";
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,YA2VA,CAAC;AAIvB,eAAO,MAAM,GAAG;;;;CAIN,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,KAAK,CAAC;AACxC,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,OAAO,CAAC;AACrC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,YAiXA,CAAC;AAIvB,eAAO,MAAM,GAAG;;;;CAIN,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,KAAK,CAAC;AACxC,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,OAAO,CAAC;AACrC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC"}