@sixb/core 0.1.18 → 0.1.19

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 (404) hide show
  1. package/README.md +7 -6
  2. package/dist/actions/commit-edits.d.ts +7 -19
  3. package/dist/actions/commit-edits.d.ts.map +1 -1
  4. package/dist/actions/errors.d.ts +0 -3
  5. package/dist/actions/errors.d.ts.map +1 -1
  6. package/dist/actions/execution.d.ts +10 -3
  7. package/dist/actions/execution.d.ts.map +1 -1
  8. package/dist/actions/index.d.ts +6 -9
  9. package/dist/actions/index.d.ts.map +1 -1
  10. package/dist/actions/index.js +51 -50
  11. package/dist/actions/index.js.map +1 -1
  12. package/dist/actions/request.d.ts +14 -25
  13. package/dist/actions/request.d.ts.map +1 -1
  14. package/dist/actions/run/context.d.ts +40 -0
  15. package/dist/actions/run/context.d.ts.map +1 -0
  16. package/dist/actions/run/edits-commit.d.ts +31 -0
  17. package/dist/actions/run/edits-commit.d.ts.map +1 -0
  18. package/dist/actions/run/effects.d.ts +23 -0
  19. package/dist/actions/run/effects.d.ts.map +1 -0
  20. package/dist/actions/run/execute.d.ts +30 -0
  21. package/dist/actions/run/execute.d.ts.map +1 -0
  22. package/dist/actions/run/executor.d.ts +95 -0
  23. package/dist/actions/run/executor.d.ts.map +1 -0
  24. package/dist/actions/run/normalize.d.ts +36 -0
  25. package/dist/actions/run/normalize.d.ts.map +1 -0
  26. package/dist/actions/run/phase-types.d.ts +18 -0
  27. package/dist/actions/run/phase-types.d.ts.map +1 -0
  28. package/dist/actions/run/phases.d.ts +20 -0
  29. package/dist/actions/run/phases.d.ts.map +1 -0
  30. package/dist/actions/run/run-action.d.ts +25 -0
  31. package/dist/actions/run/run-action.d.ts.map +1 -0
  32. package/dist/actions/run/signals.d.ts +67 -0
  33. package/dist/actions/run/signals.d.ts.map +1 -0
  34. package/dist/actions/run/state.d.ts +47 -0
  35. package/dist/actions/run/state.d.ts.map +1 -0
  36. package/dist/actions/run/types.d.ts +54 -0
  37. package/dist/actions/run/types.d.ts.map +1 -0
  38. package/dist/actions/run/writeback.d.ts +17 -0
  39. package/dist/actions/run/writeback.d.ts.map +1 -0
  40. package/dist/actions/run-authorization.d.ts +1 -1
  41. package/dist/actions/run-authorization.d.ts.map +1 -1
  42. package/dist/actions/run-persistence.d.ts +53 -0
  43. package/dist/actions/run-persistence.d.ts.map +1 -0
  44. package/dist/actions/types/context.d.ts +10 -0
  45. package/dist/actions/types/context.d.ts.map +1 -1
  46. package/dist/agents/index.js +52 -55
  47. package/dist/agents/index.js.map +1 -1
  48. package/dist/agents/streams/index.js +2 -2
  49. package/dist/agents/streams/internal.js +2 -2
  50. package/dist/auth/index.js +11 -11
  51. package/dist/auth/index.js.map +1 -1
  52. package/dist/authorization/event-visibility.d.ts.map +1 -1
  53. package/dist/authorization/index.js +3 -3
  54. package/dist/bootstrap/index.js +46 -49
  55. package/dist/bootstrap/index.js.map +2 -2
  56. package/dist/{chunk-d0eb5yy6.js → chunk-1f7wpmyp.js} +5 -5
  57. package/dist/{chunk-d0eb5yy6.js.map → chunk-1f7wpmyp.js.map} +1 -1
  58. package/dist/{chunk-vgk3hknm.js → chunk-1k89ecfr.js} +1 -1
  59. package/dist/{chunk-6h5m9xjx.js → chunk-3gnrh4ve.js} +6 -10
  60. package/dist/{chunk-6h5m9xjx.js.map → chunk-3gnrh4ve.js.map} +4 -4
  61. package/dist/{chunk-htr6wjmv.js → chunk-4tcx876c.js} +15 -15
  62. package/dist/{chunk-htr6wjmv.js.map → chunk-4tcx876c.js.map} +1 -1
  63. package/dist/{chunk-za5yd58j.js → chunk-52bk93x8.js} +2 -2
  64. package/dist/{chunk-22v5bpz3.js → chunk-5e43w60z.js} +1 -1
  65. package/dist/{chunk-zxawp1n2.js → chunk-7kg3k1m9.js} +1 -1
  66. package/dist/{chunk-ny3xyvcn.js → chunk-7mbzgd9m.js} +3 -3
  67. package/dist/{chunk-b9affek3.js → chunk-7n440zgt.js} +30 -30
  68. package/dist/{chunk-b9affek3.js.map → chunk-7n440zgt.js.map} +4 -4
  69. package/dist/{chunk-kkqwzy6h.js → chunk-7t429e3f.js} +1 -1
  70. package/dist/{chunk-s4jhg8a3.js → chunk-80mc0971.js} +13 -13
  71. package/dist/{chunk-s4jhg8a3.js.map → chunk-80mc0971.js.map} +1 -1
  72. package/dist/{chunk-1b1f2d5f.js → chunk-85yvv5n0.js} +8 -8
  73. package/dist/{chunk-1b1f2d5f.js.map → chunk-85yvv5n0.js.map} +1 -1
  74. package/dist/{chunk-6fsr7y93.js → chunk-8mx7qw3y.js} +14 -13
  75. package/dist/{chunk-6fsr7y93.js.map → chunk-8mx7qw3y.js.map} +4 -4
  76. package/dist/{chunk-kpx7jrmn.js → chunk-91mg3nj9.js} +59 -59
  77. package/dist/{chunk-kpx7jrmn.js.map → chunk-91mg3nj9.js.map} +5 -5
  78. package/dist/{chunk-48e3cn2d.js → chunk-9gyp8hg1.js} +2 -2
  79. package/dist/{chunk-ewqa58h9.js → chunk-9k93ah50.js} +4 -4
  80. package/dist/{chunk-ewqa58h9.js.map → chunk-9k93ah50.js.map} +1 -1
  81. package/dist/{chunk-4wn7bxxa.js → chunk-9ybhtmg4.js} +1 -1
  82. package/dist/{chunk-fc5zfxy1.js → chunk-a40ad1ft.js} +5 -13
  83. package/dist/chunk-a40ad1ft.js.map +10 -0
  84. package/dist/{chunk-vz3gc1tm.js → chunk-aff7cyea.js} +62 -64
  85. package/dist/{chunk-vz3gc1tm.js.map → chunk-aff7cyea.js.map} +4 -4
  86. package/dist/{chunk-y2aq6ag9.js → chunk-b38szspf.js} +5 -14
  87. package/dist/chunk-b38szspf.js.map +11 -0
  88. package/dist/{chunk-r2y23egw.js → chunk-bkpke1sg.js} +1 -10
  89. package/dist/chunk-bkpke1sg.js.map +10 -0
  90. package/dist/{chunk-bs7sqkre.js → chunk-bpgy64fw.js} +1 -1
  91. package/dist/{chunk-vx2yp45y.js → chunk-c85m1hyj.js} +2 -2
  92. package/dist/{chunk-v6xpd60t.js → chunk-d2ync1v3.js} +5 -5
  93. package/dist/{chunk-fe52eczz.js → chunk-ey3pyej1.js} +6345 -2125
  94. package/dist/chunk-ey3pyej1.js.map +106 -0
  95. package/dist/{chunk-vjcd8d27.js → chunk-fa02jy15.js} +1 -1
  96. package/dist/{chunk-y05543x6.js → chunk-hvsb78a1.js} +4 -4
  97. package/dist/{chunk-y05543x6.js.map → chunk-hvsb78a1.js.map} +1 -1
  98. package/dist/{chunk-qq90g05n.js → chunk-j2bp5ryw.js} +53 -244
  99. package/dist/{chunk-qq90g05n.js.map → chunk-j2bp5ryw.js.map} +3 -3
  100. package/dist/{chunk-qmnnhde6.js → chunk-kg5j6fct.js} +1 -1
  101. package/dist/{chunk-de4z2bj6.js → chunk-kyzq4wy9.js} +6 -6
  102. package/dist/{chunk-wr8qp979.js → chunk-m427qgq0.js} +9 -5
  103. package/dist/{chunk-wr8qp979.js.map → chunk-m427qgq0.js.map} +4 -3
  104. package/dist/{chunk-e1c18xjx.js → chunk-nq6gpjt7.js} +4 -45
  105. package/dist/{chunk-e1c18xjx.js.map → chunk-nq6gpjt7.js.map} +5 -5
  106. package/dist/{chunk-ex496vct.js → chunk-nre82s12.js} +1 -1
  107. package/dist/{chunk-1hqwggsn.js → chunk-nzapm6p0.js} +1 -2
  108. package/dist/chunk-nzapm6p0.js.map +12 -0
  109. package/dist/{chunk-wt4szfec.js → chunk-pbcbn83d.js} +4 -4
  110. package/dist/{chunk-wt4szfec.js.map → chunk-pbcbn83d.js.map} +1 -1
  111. package/dist/{chunk-7hpdd6r9.js → chunk-q1vkr2ys.js} +4 -4
  112. package/dist/{chunk-zb77kjth.js → chunk-rhg02hxq.js} +3 -3
  113. package/dist/{chunk-y9jmd7e5.js → chunk-s16apyk9.js} +102 -16
  114. package/dist/chunk-s16apyk9.js.map +16 -0
  115. package/dist/{chunk-yv9czyfr.js → chunk-t6vq7bff.js} +5 -5
  116. package/dist/{chunk-qkvz64nd.js → chunk-tjb1mk5t.js} +2 -2
  117. package/dist/{chunk-p844e0rn.js → chunk-tpn40322.js} +2 -2
  118. package/dist/{chunk-rt9p8m9t.js → chunk-v9xd5wzd.js} +1 -1
  119. package/dist/{chunk-2vhg6ysa.js → chunk-vyf9kfqf.js} +1 -1
  120. package/dist/{chunk-k6hrnf35.js → chunk-wwdfe68s.js} +51 -4
  121. package/dist/chunk-wwdfe68s.js.map +11 -0
  122. package/dist/{chunk-f1zxad2t.js → chunk-wz0xs816.js} +6 -6
  123. package/dist/{chunk-f1zxad2t.js.map → chunk-wz0xs816.js.map} +1 -1
  124. package/dist/chunk-y0c4e6ex.js +16 -0
  125. package/dist/chunk-y0c4e6ex.js.map +10 -0
  126. package/dist/{chunk-qkbx3tf6.js → chunk-y7rqfrgg.js} +6 -13
  127. package/dist/{chunk-qkbx3tf6.js.map → chunk-y7rqfrgg.js.map} +4 -4
  128. package/dist/{chunk-dfm066qg.js → chunk-yxd3nnqt.js} +2 -29
  129. package/dist/chunk-yxd3nnqt.js.map +11 -0
  130. package/dist/{chunk-70jmg2zx.js → chunk-yzwja0mj.js} +4 -19
  131. package/dist/{chunk-70jmg2zx.js.map → chunk-yzwja0mj.js.map} +3 -3
  132. package/dist/{chunk-p0dqwj3n.js → chunk-zrmy8zvw.js} +66 -47
  133. package/dist/{chunk-p0dqwj3n.js.map → chunk-zrmy8zvw.js.map} +4 -4
  134. package/dist/deploy/index.d.ts +1 -1
  135. package/dist/deploy/index.d.ts.map +1 -1
  136. package/dist/deploy/internal.js +10 -8
  137. package/dist/deploy/internal.js.map +4 -4
  138. package/dist/deploy/services.d.ts +1 -2
  139. package/dist/deploy/services.d.ts.map +1 -1
  140. package/dist/deploy/types.d.ts +6 -5
  141. package/dist/deploy/types.d.ts.map +1 -1
  142. package/dist/deploy/validation.d.ts.map +1 -1
  143. package/dist/edits/index.js +3 -5
  144. package/dist/edits/index.js.map +1 -1
  145. package/dist/error-reporting/internal.js +3 -3
  146. package/dist/error-reporting/types.d.ts +2 -9
  147. package/dist/error-reporting/types.d.ts.map +1 -1
  148. package/dist/errors/catalog.d.ts +12 -0
  149. package/dist/errors/catalog.d.ts.map +1 -1
  150. package/dist/errors/internal.js +1 -1
  151. package/dist/events/definitions.d.ts +0 -5
  152. package/dist/events/definitions.d.ts.map +1 -1
  153. package/dist/events/index.d.ts +3 -3
  154. package/dist/events/index.d.ts.map +1 -1
  155. package/dist/events/index.js +6 -8
  156. package/dist/events/index.js.map +1 -1
  157. package/dist/events/scope.d.ts +0 -1
  158. package/dist/events/scope.d.ts.map +1 -1
  159. package/dist/events/scope.js +1 -1
  160. package/dist/events/selectors/builder.d.ts +1 -8
  161. package/dist/events/selectors/builder.d.ts.map +1 -1
  162. package/dist/events/selectors/index.d.ts +2 -2
  163. package/dist/events/selectors/index.d.ts.map +1 -1
  164. package/dist/events/selectors/index.js +2 -2
  165. package/dist/events/selectors/predicate.d.ts.map +1 -1
  166. package/dist/events/selectors/types.d.ts +2 -33
  167. package/dist/events/selectors/types.d.ts.map +1 -1
  168. package/dist/events/types/index.d.ts +1 -12
  169. package/dist/events/types/index.d.ts.map +1 -1
  170. package/dist/execution/agent.js +41 -44
  171. package/dist/execution/agent.js.map +1 -1
  172. package/dist/execution/primitive.js +57 -88
  173. package/dist/execution/primitive.js.map +3 -4
  174. package/dist/execution/request.js +35 -38
  175. package/dist/execution/request.js.map +2 -2
  176. package/dist/index.d.ts +3 -3
  177. package/dist/index.d.ts.map +1 -1
  178. package/dist/index.js +111 -120
  179. package/dist/index.js.map +1 -1
  180. package/dist/materialization/index.js +3 -3
  181. package/dist/materialization/index.js.map +1 -1
  182. package/dist/materialization/model.d.ts +19 -6
  183. package/dist/materialization/model.d.ts.map +1 -1
  184. package/dist/materializer/index.js +31 -31
  185. package/dist/materializer/index.js.map +1 -1
  186. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  187. package/dist/models/execution/index.js +18 -18
  188. package/dist/objects/action/errors.d.ts +0 -9
  189. package/dist/objects/action/errors.d.ts.map +1 -1
  190. package/dist/objects/action/index.d.ts +3 -3
  191. package/dist/objects/action/index.d.ts.map +1 -1
  192. package/dist/objects/action/request.d.ts +2 -8
  193. package/dist/objects/action/request.d.ts.map +1 -1
  194. package/dist/objects/execution.d.ts +0 -2
  195. package/dist/objects/execution.d.ts.map +1 -1
  196. package/dist/objects/index.js +44 -29
  197. package/dist/objects/index.js.map +1 -1
  198. package/dist/objects/query/index.js +29 -29
  199. package/dist/objects/query/index.js.map +1 -1
  200. package/dist/objects/sdk/object-handle.d.ts.map +1 -1
  201. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  202. package/dist/objects/service/index.d.ts +0 -1
  203. package/dist/objects/service/index.d.ts.map +1 -1
  204. package/dist/ontology/index.js +5 -5
  205. package/dist/ontology/index.js.map +1 -1
  206. package/dist/ontology/internal.js +2 -2
  207. package/dist/pipelines/index.js +28 -28
  208. package/dist/projections/internal.js +22 -22
  209. package/dist/projections/internal.js.map +1 -1
  210. package/dist/query.js +2 -2
  211. package/dist/queues/in-memory.d.ts +1 -2
  212. package/dist/queues/in-memory.d.ts.map +1 -1
  213. package/dist/queues/index.d.ts +1 -1
  214. package/dist/queues/index.d.ts.map +1 -1
  215. package/dist/queues/index.js +1 -1
  216. package/dist/queues/types.d.ts +0 -7
  217. package/dist/queues/types.d.ts.map +1 -1
  218. package/dist/runtime/host.d.ts.map +1 -1
  219. package/dist/runtime/internal.js +24 -25
  220. package/dist/runtime/internal.js.map +1 -1
  221. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  222. package/dist/runtime/types.d.ts +16 -36
  223. package/dist/runtime/types.d.ts.map +1 -1
  224. package/dist/sandboxes/index.js +5 -5
  225. package/dist/schedules/builders.d.ts.map +1 -1
  226. package/dist/schedules/index.js +3 -3
  227. package/dist/schedules/runtime.d.ts.map +1 -1
  228. package/dist/schedules/validation.d.ts +0 -1
  229. package/dist/schedules/validation.d.ts.map +1 -1
  230. package/dist/security/every.d.ts +1 -1
  231. package/dist/shares/internal.js +17 -17
  232. package/dist/storage/action-runs/failure.js +2 -2
  233. package/dist/storage/action-runs/idempotency.d.ts +3 -4
  234. package/dist/storage/action-runs/idempotency.d.ts.map +1 -1
  235. package/dist/storage/action-runs/in-memory.d.ts +2 -9
  236. package/dist/storage/action-runs/in-memory.d.ts.map +1 -1
  237. package/dist/storage/action-runs/index.d.ts +1 -3
  238. package/dist/storage/action-runs/index.d.ts.map +1 -1
  239. package/dist/storage/action-runs/provider.js +1 -1
  240. package/dist/storage/action-runs/record.d.ts +20 -0
  241. package/dist/storage/action-runs/record.d.ts.map +1 -0
  242. package/dist/storage/action-runs/types.d.ts +39 -68
  243. package/dist/storage/action-runs/types.d.ts.map +1 -1
  244. package/dist/storage/ai-limits/enforcement.js +2 -2
  245. package/dist/storage/connector-connections/provider.js +1 -1
  246. package/dist/storage/file-upload-sessions/provider.js +9 -9
  247. package/dist/storage/index.d.ts +2 -2
  248. package/dist/storage/index.d.ts.map +1 -1
  249. package/dist/storage/index.js +30 -31
  250. package/dist/storage/index.js.map +1 -1
  251. package/dist/storage/internal.d.ts +1 -1
  252. package/dist/storage/internal.d.ts.map +1 -1
  253. package/dist/storage/internal.js +9 -12
  254. package/dist/storage/internal.js.map +1 -1
  255. package/dist/storage/objects/execution-limits.d.ts +1 -1
  256. package/dist/storage/objects/execution-limits.d.ts.map +1 -1
  257. package/dist/storage/ontology/provider.js +2 -2
  258. package/dist/storage/projection-runs/provider.js +2 -2
  259. package/dist/storage/types.d.ts +1 -1
  260. package/dist/storage/types.d.ts.map +1 -1
  261. package/dist/storage/workflow-runs/provider.js +9 -9
  262. package/dist/syncs/index.js +29 -29
  263. package/dist/testing/action-execution.d.ts +34 -4
  264. package/dist/testing/action-execution.d.ts.map +1 -1
  265. package/dist/testing/action-run-storage-contract.d.ts +11 -0
  266. package/dist/testing/action-run-storage-contract.d.ts.map +1 -0
  267. package/dist/testing/index.d.ts +2 -1
  268. package/dist/testing/index.d.ts.map +1 -1
  269. package/dist/testing/index.js +3202 -2860
  270. package/dist/testing/index.js.map +7 -6
  271. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  272. package/dist/testing/queues-contract.d.ts.map +1 -1
  273. package/dist/webhooks/internal.js +23 -23
  274. package/dist/webhooks/internal.js.map +1 -1
  275. package/dist/workers/index.js +1 -1
  276. package/dist/workflows/index.js +48 -51
  277. package/dist/workflows/index.js.map +1 -1
  278. package/package.json +1 -7
  279. package/src/actions/commit-edits.ts +9 -37
  280. package/src/actions/errors.ts +0 -4
  281. package/src/actions/execution.ts +10 -10
  282. package/src/actions/index.ts +5 -24
  283. package/src/actions/request.ts +157 -295
  284. package/src/actions/run/context.ts +193 -0
  285. package/src/actions/run/edits-commit.ts +102 -0
  286. package/src/actions/run/effects.ts +105 -0
  287. package/src/actions/run/execute.ts +113 -0
  288. package/src/actions/run/executor.ts +314 -0
  289. package/src/actions/run/normalize.ts +142 -0
  290. package/src/actions/run/phase-types.ts +20 -0
  291. package/src/actions/run/phases.ts +150 -0
  292. package/src/actions/run/run-action.ts +170 -0
  293. package/src/actions/run/signals.ts +118 -0
  294. package/src/actions/run/state.ts +95 -0
  295. package/src/actions/run/types.ts +61 -0
  296. package/src/actions/run/writeback.ts +79 -0
  297. package/src/actions/run-authorization.ts +1 -1
  298. package/src/actions/run-persistence.ts +105 -0
  299. package/src/actions/types/context.ts +10 -0
  300. package/src/authorization/event-visibility.ts +0 -12
  301. package/src/deploy/index.ts +0 -1
  302. package/src/deploy/services.ts +2 -11
  303. package/src/deploy/types.ts +6 -6
  304. package/src/deploy/validation.ts +12 -6
  305. package/src/error-reporting/types.ts +2 -10
  306. package/src/errors/catalog.ts +13 -0
  307. package/src/events/definitions.ts +0 -17
  308. package/src/events/index.ts +0 -14
  309. package/src/events/scope.ts +0 -12
  310. package/src/events/selectors/builder.ts +0 -51
  311. package/src/events/selectors/index.ts +0 -6
  312. package/src/events/selectors/predicate.ts +0 -2
  313. package/src/events/selectors/types.ts +7 -65
  314. package/src/events/types/index.ts +0 -11
  315. package/src/index.ts +1 -19
  316. package/src/materialization/model.ts +26 -9
  317. package/src/materializer/README.md +6 -1
  318. package/src/materializer/edits/commit.ts +42 -32
  319. package/src/materializer/shared/normalize.ts +25 -14
  320. package/src/objects/action/errors.ts +0 -12
  321. package/src/objects/action/index.ts +3 -3
  322. package/src/objects/action/request.ts +2 -29
  323. package/src/objects/execution.ts +2 -2
  324. package/src/objects/sdk/object-handle.ts +3 -29
  325. package/src/objects/sdk/object-set.ts +5 -30
  326. package/src/objects/service/index.ts +0 -1
  327. package/src/queues/in-memory.ts +0 -6
  328. package/src/queues/index.ts +0 -2
  329. package/src/queues/types.ts +0 -11
  330. package/src/runtime/host.ts +5 -0
  331. package/src/runtime/resolve-definitions.ts +0 -1
  332. package/src/runtime/types.ts +16 -45
  333. package/src/schedules/builders.ts +1 -4
  334. package/src/schedules/runtime.ts +0 -41
  335. package/src/schedules/validation.ts +2 -16
  336. package/src/security/every.ts +1 -1
  337. package/src/storage/action-runs/idempotency.ts +13 -41
  338. package/src/storage/action-runs/in-memory.ts +20 -311
  339. package/src/storage/action-runs/index.ts +1 -16
  340. package/src/storage/action-runs/record.ts +130 -0
  341. package/src/storage/action-runs/types.ts +37 -92
  342. package/src/storage/index.ts +1 -9
  343. package/src/storage/internal.ts +1 -7
  344. package/src/storage/objects/execution-limits.ts +3 -2
  345. package/src/storage/types.ts +2 -4
  346. package/src/testing/action-execution.ts +73 -13
  347. package/src/testing/action-run-storage-contract.ts +335 -0
  348. package/src/testing/index.ts +8 -1
  349. package/src/testing/materializer-storage-contract.ts +174 -18
  350. package/src/testing/queues-contract.ts +0 -18
  351. package/dist/actions/run-dispatch.d.ts +0 -25
  352. package/dist/actions/run-dispatch.d.ts.map +0 -1
  353. package/dist/actions/worker.d.ts +0 -3
  354. package/dist/actions/worker.d.ts.map +0 -1
  355. package/dist/actions/worker.js +0 -325
  356. package/dist/actions/worker.js.map +0 -11
  357. package/dist/chunk-1hqwggsn.js.map +0 -12
  358. package/dist/chunk-85cd7e8c.js +0 -51
  359. package/dist/chunk-85cd7e8c.js.map +0 -10
  360. package/dist/chunk-dfm066qg.js.map +0 -11
  361. package/dist/chunk-fc5zfxy1.js.map +0 -11
  362. package/dist/chunk-fe52eczz.js.map +0 -49
  363. package/dist/chunk-fx93hd2n.js +0 -1614
  364. package/dist/chunk-fx93hd2n.js.map +0 -20
  365. package/dist/chunk-k6hrnf35.js.map +0 -10
  366. package/dist/chunk-qxvp5epv.js +0 -1329
  367. package/dist/chunk-qxvp5epv.js.map +0 -36
  368. package/dist/chunk-r2y23egw.js.map +0 -10
  369. package/dist/chunk-tffvfy6s.js +0 -593
  370. package/dist/chunk-tffvfy6s.js.map +0 -15
  371. package/dist/chunk-y2aq6ag9.js.map +0 -11
  372. package/dist/chunk-y9jmd7e5.js.map +0 -15
  373. package/dist/chunk-zvx7h87b.js +0 -12
  374. package/dist/chunk-zvx7h87b.js.map +0 -10
  375. package/dist/events/types/actions.d.ts +0 -39
  376. package/dist/events/types/actions.d.ts.map +0 -1
  377. package/dist/objects/service/action-service.d.ts +0 -13
  378. package/dist/objects/service/action-service.d.ts.map +0 -1
  379. package/src/actions/run-dispatch.ts +0 -282
  380. package/src/actions/worker.ts +0 -2
  381. package/src/events/types/actions.ts +0 -42
  382. package/src/objects/service/action-service.ts +0 -43
  383. /package/dist/{chunk-vgk3hknm.js.map → chunk-1k89ecfr.js.map} +0 -0
  384. /package/dist/{chunk-za5yd58j.js.map → chunk-52bk93x8.js.map} +0 -0
  385. /package/dist/{chunk-22v5bpz3.js.map → chunk-5e43w60z.js.map} +0 -0
  386. /package/dist/{chunk-zxawp1n2.js.map → chunk-7kg3k1m9.js.map} +0 -0
  387. /package/dist/{chunk-ny3xyvcn.js.map → chunk-7mbzgd9m.js.map} +0 -0
  388. /package/dist/{chunk-kkqwzy6h.js.map → chunk-7t429e3f.js.map} +0 -0
  389. /package/dist/{chunk-48e3cn2d.js.map → chunk-9gyp8hg1.js.map} +0 -0
  390. /package/dist/{chunk-4wn7bxxa.js.map → chunk-9ybhtmg4.js.map} +0 -0
  391. /package/dist/{chunk-bs7sqkre.js.map → chunk-bpgy64fw.js.map} +0 -0
  392. /package/dist/{chunk-vx2yp45y.js.map → chunk-c85m1hyj.js.map} +0 -0
  393. /package/dist/{chunk-v6xpd60t.js.map → chunk-d2ync1v3.js.map} +0 -0
  394. /package/dist/{chunk-vjcd8d27.js.map → chunk-fa02jy15.js.map} +0 -0
  395. /package/dist/{chunk-qmnnhde6.js.map → chunk-kg5j6fct.js.map} +0 -0
  396. /package/dist/{chunk-de4z2bj6.js.map → chunk-kyzq4wy9.js.map} +0 -0
  397. /package/dist/{chunk-ex496vct.js.map → chunk-nre82s12.js.map} +0 -0
  398. /package/dist/{chunk-7hpdd6r9.js.map → chunk-q1vkr2ys.js.map} +0 -0
  399. /package/dist/{chunk-zb77kjth.js.map → chunk-rhg02hxq.js.map} +0 -0
  400. /package/dist/{chunk-yv9czyfr.js.map → chunk-t6vq7bff.js.map} +0 -0
  401. /package/dist/{chunk-qkvz64nd.js.map → chunk-tjb1mk5t.js.map} +0 -0
  402. /package/dist/{chunk-p844e0rn.js.map → chunk-tpn40322.js.map} +0 -0
  403. /package/dist/{chunk-rt9p8m9t.js.map → chunk-v9xd5wzd.js.map} +0 -0
  404. /package/dist/{chunk-2vhg6ysa.js.map → chunk-vyf9kfqf.js.map} +0 -0
@@ -1,1329 +0,0 @@
1
- // @bun
2
- import {
3
- createSixbError2
4
- } from "./chunk-6fsr7y93.js";
5
- import {
6
- resolveRuntimeAuthorizationForProject,
7
- AuthorizationError2,
8
- assertAuthorized2,
9
- assertCanEdit2,
10
- assertCanAppendTelemetry2
11
- } from "./chunk-qkbx3tf6.js";
12
- import {
13
- assertValidFileRefs2,
14
- normalizeObjectProperties2,
15
- assertPropertyTokenBelongsToObjectType2,
16
- assertLinkTokenBelongsToObjectType2,
17
- assertKnownProperties2,
18
- validateObjectProperties2,
19
- assertLinkTargetType2,
20
- normalizeLinkProperties2,
21
- validateLinkProperties2,
22
- assertTelemetryProperty2
23
- } from "./chunk-y05543x6.js";
24
- import {
25
- linkRefKey2,
26
- telemetryPointKey2
27
- } from "./chunk-b9affek3.js";
28
- import {
29
- objectBatchKey2,
30
- vectorConfiguration,
31
- vectorSources,
32
- normalizeVector2
33
- } from "./chunk-qq90g05n.js";
34
- import {
35
- validateObjectQuery2,
36
- explainObjectQuery2
37
- } from "./chunk-htr6wjmv.js";
38
- import {
39
- assertAuthorizedObjectReaderBinding,
40
- getAuthorizedOntologyView,
41
- requestAction3,
42
- requestActionAndWait2
43
- } from "./chunk-fx93hd2n.js";
44
- import {
45
- shareSixbErrorReporter2
46
- } from "./chunk-vjcd8d27.js";
47
- import {
48
- normalizeJsonProperties2
49
- } from "./chunk-p0dqwj3n.js";
50
- import {
51
- getOntologyMutationRuntime2,
52
- shareOntologyMutationRuntime2
53
- } from "./chunk-85cd7e8c.js";
54
- import {
55
- resolveFileRefAtPath2,
56
- openFileRef2,
57
- jsonPointerSegment2
58
- } from "./chunk-3zxk45er.js";
59
- import {
60
- createObjectQueryBuilder2
61
- } from "./chunk-ewqa58h9.js";
62
- import {
63
- ObjectQueryPlanningError2
64
- } from "./chunk-kpx7jrmn.js";
65
- import {
66
- ObjectNotFoundError2
67
- } from "./chunk-y9jmd7e5.js";
68
- import {
69
- MaterializationValidationError2,
70
- MaterializationObjectNotFoundError2
71
- } from "./chunk-96yw3pwd.js";
72
- import {
73
- RuntimeError2
74
- } from "./chunk-m4ehq95f.js";
75
- import {
76
- OntologyValidationError2,
77
- OntologyNotFoundError2
78
- } from "./chunk-cqr3acm1.js";
79
- import {
80
- sameEmbeddingModel
81
- } from "./chunk-kyjcwqz6.js";
82
- import {
83
- stableJsonStringify2
84
- } from "./chunk-wy0qdqfm.js";
85
- var __defProp = Object.defineProperty;
86
- var __returnValue = (v) => v;
87
- function __exportSetter(name, newValue) {
88
- this[name] = __returnValue.bind(null, newValue);
89
- }
90
- var __export = (target, all) => {
91
- for (var name in all)
92
- __defProp(target, name, {
93
- get: all[name],
94
- enumerable: true,
95
- configurable: true,
96
- set: __exportSetter.bind(all, name)
97
- });
98
- };
99
-
100
- // src/objects/action/request.ts
101
- async function requestAction2(ctx, params) {
102
- return requestAction3(ctx, ctx.execution, {
103
- actionId: params.actionId,
104
- subject: {
105
- kind: "object",
106
- objectTypeId: ctx.objectType.id,
107
- primaryId: params.primaryId
108
- },
109
- params: params.params,
110
- runId: params.options?.runId,
111
- signal: params.options?.signal
112
- });
113
- }
114
- async function requestActionAndWait(ctx, params) {
115
- return requestActionAndWait2(ctx, ctx.execution, {
116
- actionId: params.actionId,
117
- subject: {
118
- kind: "object",
119
- objectTypeId: ctx.objectType.id,
120
- primaryId: params.primaryId
121
- },
122
- params: params.params,
123
- runId: params.options?.runId,
124
- timeoutMs: params.options?.timeoutMs,
125
- signal: params.options?.signal,
126
- onRequested: params.options?.onRequested
127
- });
128
- }
129
- // src/objects/errors.ts
130
- class ObjectError2 extends Error {
131
- name = "ObjectError";
132
- }
133
-
134
- // src/objects/materializer-adapter.ts
135
- import { randomUUID } from "crypto";
136
- async function commitRuntimeOperations(ctx, operations) {
137
- const mutations = getOntologyMutationRuntime2(ctx);
138
- const commit = await mutations.commitEdits({
139
- mode: "atomic",
140
- source: { kind: "runtime", requestId: randomUUID() },
141
- operations,
142
- expectedObjects: [],
143
- expectedLinks: [],
144
- expectedLinkScopes: []
145
- });
146
- return commit;
147
- }
148
- async function commitRuntimeBatch(ctx, groups) {
149
- const operations = groups.flatMap((group) => group.operations);
150
- if (operations.length === 0) {
151
- return { commit: null, outcomes: new Map };
152
- }
153
- const operationGroups = groups.filter((group) => group.operations.length > 1).map((group) => group.operations.map((operation) => operation.id));
154
- const mutations = getOntologyMutationRuntime2(ctx);
155
- const commit = await mutations.commitEdits({
156
- mode: "continue",
157
- source: { kind: "runtime", requestId: randomUUID() },
158
- operations,
159
- ...operationGroups.length > 0 ? { operationGroups } : {}
160
- });
161
- const byId = new Map(commit.outcomes.map((outcome) => [outcome.id, outcome]));
162
- const outcomes = new Map;
163
- for (const group of groups) {
164
- outcomes.set(group.index, group.operations.map((operation) => requireOutcome(byId, operation.id)));
165
- }
166
- return { commit, outcomes };
167
- }
168
- function runtimeOperationId(index, subOrdinal = 0) {
169
- return subOrdinal === 0 ? `op:${index}` : `op:${index}.${subOrdinal}`;
170
- }
171
- function normalizeRuntimeObject(input) {
172
- const { objectType, primaryPropertyId, properties, valueTypesById } = input;
173
- assertKnownProperties2(objectType, properties);
174
- validateObjectProperties2(objectType, properties, valueTypesById);
175
- assertValidFileRefs2(properties, objectType.id);
176
- const primaryValue = properties[primaryPropertyId];
177
- if (primaryValue === undefined || primaryValue === null) {
178
- throw new OntologyValidationError2(`[Sixb] Missing primary property '${primaryPropertyId}' in upsert for '${objectType.id}'`);
179
- }
180
- const normalized = normalizeObjectProperties2(objectType.properties, properties, valueTypesById, objectType.id);
181
- const { [primaryPropertyId]: _identity, ...managed } = normalized;
182
- return {
183
- primaryId: String(primaryValue),
184
- properties: normalizeJsonProperties2(managed, `${objectType.id} properties`)
185
- };
186
- }
187
- function normalizeRuntimeLink(input) {
188
- const { objectType, linkDefinition, linkId, targetTypeId, properties, valueTypesById } = input;
189
- assertLinkTargetType2(objectType.id, linkId, linkDefinition, targetTypeId, input.isValidLinkTarget);
190
- validateLinkProperties2(objectType, linkDefinition, properties, undefined, valueTypesById);
191
- assertValidFileRefs2(properties, `${objectType.id}.${linkId}`);
192
- const normalized = normalizeLinkProperties2(objectType, linkDefinition, properties, valueTypesById);
193
- if (normalized === undefined)
194
- return;
195
- return normalizeJsonProperties2(normalized, `${objectType.id}.${linkId} properties`);
196
- }
197
- function objectUpsertOperation(input) {
198
- return { id: input.id, kind: "object.upsert", ref: input.ref, properties: input.properties };
199
- }
200
- function objectDeleteOperation(input) {
201
- return { id: input.id, kind: "object.delete", ref: input.ref };
202
- }
203
- function objectRestoreOperation(input) {
204
- return { id: input.id, kind: "object.restore", ref: input.ref };
205
- }
206
- function linkUpsertOperation(input) {
207
- return {
208
- id: input.id,
209
- kind: "link.upsert",
210
- ref: input.ref,
211
- ...input.properties !== undefined ? { properties: input.properties } : {}
212
- };
213
- }
214
- function linkDeleteOperation(input) {
215
- return { id: input.id, kind: "link.delete", ref: input.ref };
216
- }
217
- function requireItemOutcomes(commit, index) {
218
- const outcomes = commit.outcomes.get(index);
219
- if (!outcomes || outcomes.length === 0) {
220
- throw new ObjectError2(`[Sixb] Materializer returned no outcome for batch item ${index}.`);
221
- }
222
- return outcomes;
223
- }
224
- function requireEffectiveObject(outcome) {
225
- if (!outcome.ok || !outcome.object) {
226
- throw new ObjectError2(`[Sixb] Materializer returned no effective object for '${outcome.id}'.`);
227
- }
228
- return outcome.object;
229
- }
230
- function toObjectRow(projectId, snapshot) {
231
- return {
232
- projectId,
233
- objectTypeId: snapshot.ref.objectTypeId,
234
- primaryId: snapshot.ref.primaryId,
235
- properties: structuredClone(snapshot.properties),
236
- createdAt: new Date(snapshot.createdAt),
237
- updatedAt: new Date(snapshot.updatedAt),
238
- version: snapshot.version,
239
- lastCommitId: snapshot.lastCommitId
240
- };
241
- }
242
- function toItemError(error) {
243
- switch (error.code) {
244
- case "validation":
245
- return new OntologyValidationError2(error.message);
246
- }
247
- }
248
- function requireOutcome(outcomes, id) {
249
- const outcome = outcomes.get(id);
250
- if (!outcome) {
251
- throw new ObjectError2(`[Sixb] Materializer returned no outcome for '${id}'.`);
252
- }
253
- return outcome;
254
- }
255
-
256
- // src/objects/link/authorization.ts
257
- function assertCanWriteLink(ctx, endpoints) {
258
- assertCanEdit2(ctx, endpoints.sourceTypeId);
259
- assertAuthorized2(ctx, { kind: "object.view", objectTypeId: endpoints.targetTypeId });
260
- }
261
-
262
- // src/objects/link/remove.ts
263
- async function removeLink2(ctx, params) {
264
- const { objectType, linkDefinition, ontology } = ctx;
265
- const { sourceId, linkId, targetTypeId, targetId } = params;
266
- assertCanWriteLink(ctx, { sourceTypeId: objectType.id, targetTypeId });
267
- assertLinkTargetType2(objectType.id, linkId, linkDefinition, targetTypeId, (expected, actual) => ontology.isValidLinkTarget(expected, actual));
268
- await commitRuntimeOperations(ctx, [
269
- linkDeleteOperation({
270
- id: runtimeOperationId(0),
271
- ref: {
272
- source: { objectTypeId: objectType.id, primaryId: sourceId },
273
- linkId,
274
- target: { objectTypeId: targetTypeId, primaryId: targetId }
275
- }
276
- })
277
- ]);
278
- }
279
-
280
- // src/objects/link/endpoints.ts
281
- function collectEndpointLookups(items) {
282
- const lookups = [];
283
- const seen = new Set;
284
- for (const item of items) {
285
- for (const endpoint of [
286
- { objectTypeId: item.objectType.id, primaryId: item.sourceId },
287
- { objectTypeId: item.targetTypeId, primaryId: item.targetId }
288
- ]) {
289
- const key = endpointKey(endpoint.objectTypeId, endpoint.primaryId);
290
- if (seen.has(key))
291
- continue;
292
- seen.add(key);
293
- lookups.push(endpoint);
294
- }
295
- }
296
- return lookups;
297
- }
298
- async function loadEndpointExistence(ctx, lookups) {
299
- if (lookups.length === 0)
300
- return new Set;
301
- const rows = await ctx.storage.objects.getByPrimaryIdBatch({
302
- projectId: ctx.projectId,
303
- items: lookups
304
- });
305
- return new Set(rows.keys());
306
- }
307
- function requireEndpoints(item, existing) {
308
- if (!existing.has(endpointKey(item.objectType.id, item.sourceId))) {
309
- throw new ObjectNotFoundError2(item.objectType.id, item.sourceId, "Source object not found");
310
- }
311
- if (!existing.has(endpointKey(item.targetTypeId, item.targetId))) {
312
- throw new ObjectNotFoundError2(item.targetTypeId, item.targetId, "Target object not found");
313
- }
314
- }
315
- function endpointKey(objectTypeId, primaryId) {
316
- return objectBatchKey2(objectTypeId, primaryId);
317
- }
318
-
319
- // src/objects/link/upsert.ts
320
- async function upsertLink2(ctx, params) {
321
- const { objectType, linkDefinition, ontology } = ctx;
322
- const { sourceId, linkId, targetTypeId, targetId, properties } = params;
323
- assertCanWriteLink(ctx, { sourceTypeId: objectType.id, targetTypeId });
324
- const endpoints = { objectType, sourceId, targetTypeId, targetId };
325
- requireEndpoints(endpoints, await loadEndpointExistence(ctx, collectEndpointLookups([endpoints])));
326
- const normalizedProperties = normalizeRuntimeLink({
327
- objectType,
328
- linkDefinition,
329
- linkId,
330
- targetTypeId,
331
- properties,
332
- valueTypesById: ontology.getValueTypesById(),
333
- isValidLinkTarget: (expected, actual) => ontology.isValidLinkTarget(expected, actual)
334
- });
335
- await commitRuntimeOperations(ctx, [
336
- linkUpsertOperation({
337
- id: runtimeOperationId(0),
338
- ref: {
339
- source: { objectTypeId: objectType.id, primaryId: sourceId },
340
- linkId,
341
- target: { objectTypeId: targetTypeId, primaryId: targetId }
342
- },
343
- ...normalizedProperties !== undefined ? { properties: normalizedProperties } : {}
344
- })
345
- ]);
346
- }
347
-
348
- // src/objects/runtime-batch.ts
349
- async function runRuntimeItemBatch(batch) {
350
- const { items } = batch;
351
- if (items.length === 0)
352
- return [];
353
- const results = new Array(items.length);
354
- const planned = [];
355
- const claims = new Map;
356
- const aliases = new Map;
357
- for (const [index, item] of items.entries()) {
358
- let plan;
359
- try {
360
- plan = batch.plan(item, index);
361
- } catch (error) {
362
- results[index] = {
363
- ok: false,
364
- error: error instanceof Error ? error : new Error(String(error))
365
- };
366
- continue;
367
- }
368
- const claimed = claims.get(plan.key);
369
- if (claimed) {
370
- if (claimed.fingerprint !== plan.fingerprint) {
371
- results[index] = {
372
- ok: false,
373
- error: new OntologyValidationError2(`[Sixb] Conflicting duplicate ${plan.label} at batch positions ${claimed.index} and ${index}`)
374
- };
375
- continue;
376
- }
377
- aliases.set(index, claimed.index);
378
- continue;
379
- }
380
- claims.set(plan.key, { index, fingerprint: plan.fingerprint });
381
- planned.push({ index, operations: plan.operations });
382
- }
383
- const commit = await commitRuntimeBatch(batch.ctx, planned);
384
- for (const { index } of planned) {
385
- const outcomes = requireItemOutcomes(commit, index);
386
- const failed = outcomes.find((outcome) => !outcome.ok);
387
- results[index] = failed?.ok === false ? { ok: false, error: toItemError(failed.error) } : { ok: true, value: batch.value(outcomes) };
388
- }
389
- for (const [index, source] of aliases) {
390
- results[index] = results[source];
391
- }
392
- return results;
393
- }
394
-
395
- // src/objects/link/upsert-batch.ts
396
- async function upsertLinkBatch2(ctx, items) {
397
- const { ontology } = ctx;
398
- if (items.length === 0)
399
- return [];
400
- for (const item of items) {
401
- assertCanWriteLink(ctx, {
402
- sourceTypeId: item.objectType.id,
403
- targetTypeId: item.targetTypeId
404
- });
405
- }
406
- const existing = await loadEndpointExistence(ctx, collectEndpointLookups(items));
407
- const valueTypesById = ontology.getValueTypesById();
408
- return runRuntimeItemBatch({
409
- ctx,
410
- items,
411
- plan(item, index) {
412
- requireEndpoints(item, existing);
413
- const properties = normalizeRuntimeLink({
414
- objectType: item.objectType,
415
- linkDefinition: item.linkDefinition,
416
- linkId: item.linkId,
417
- targetTypeId: item.targetTypeId,
418
- properties: item.properties,
419
- valueTypesById,
420
- isValidLinkTarget: (expected, actual) => ontology.isValidLinkTarget(expected, actual)
421
- });
422
- const ref = {
423
- source: { objectTypeId: item.objectType.id, primaryId: item.sourceId },
424
- linkId: item.linkId,
425
- target: { objectTypeId: item.targetTypeId, primaryId: item.targetId }
426
- };
427
- const edge = linkRefKey2(ref);
428
- return {
429
- key: edge,
430
- label: `link '${item.objectType.id}:${item.sourceId}.${item.linkId} -> ${item.targetTypeId}:${item.targetId}'`,
431
- fingerprint: stableJsonStringify2(properties ?? null),
432
- operations: [
433
- linkUpsertOperation({
434
- id: runtimeOperationId(index),
435
- ref,
436
- ...properties !== undefined ? { properties } : {}
437
- })
438
- ]
439
- };
440
- },
441
- value: () => {
442
- return;
443
- }
444
- });
445
- }
446
- // src/objects/object/delete.ts
447
- async function deleteObject2(ctx, primaryId) {
448
- assertCanEdit2(ctx, ctx.objectType.id);
449
- await commitRuntimeOperations(ctx, [
450
- objectDeleteOperation({
451
- id: runtimeOperationId(0),
452
- ref: { objectTypeId: ctx.objectType.id, primaryId }
453
- })
454
- ]);
455
- }
456
- async function restoreObject2(ctx, primaryId) {
457
- assertCanEdit2(ctx, ctx.objectType.id);
458
- await commitRuntimeOperations(ctx, [
459
- objectRestoreOperation({
460
- id: runtimeOperationId(0),
461
- ref: { objectTypeId: ctx.objectType.id, primaryId }
462
- })
463
- ]);
464
- }
465
-
466
- // src/objects/object/upsert.ts
467
- async function upsertObject2(ctx, properties) {
468
- assertCanEdit2(ctx, ctx.objectType.id);
469
- const { objectType, primaryPropertyId, ontology } = ctx;
470
- const normalized = normalizeRuntimeObject({
471
- objectType,
472
- primaryPropertyId,
473
- properties,
474
- valueTypesById: ontology.getValueTypesById()
475
- });
476
- const ref = { objectTypeId: objectType.id, primaryId: normalized.primaryId };
477
- const commit = await commitRuntimeOperations(ctx, [
478
- objectUpsertOperation({ id: runtimeOperationId(0), ref, properties: normalized.properties })
479
- ]);
480
- return ctx.objectReader.redactWrittenRow(toObjectRow(ctx.projectId, requireEffectiveObject(commit.outcomes[0])));
481
- }
482
-
483
- // src/objects/object/upsert-batch.ts
484
- async function upsertObjectBatch2(ctx, items) {
485
- assertCanEdit2(ctx, ctx.objectType.id);
486
- const { objectType, primaryPropertyId, ontology } = ctx;
487
- const valueTypesById = ontology.getValueTypesById();
488
- return runRuntimeItemBatch({
489
- ctx,
490
- items,
491
- plan(item, index) {
492
- const normalized = normalizeRuntimeObject({
493
- objectType,
494
- primaryPropertyId,
495
- properties: item.properties,
496
- valueTypesById
497
- });
498
- const ref = { objectTypeId: objectType.id, primaryId: normalized.primaryId };
499
- return {
500
- key: `${ref.objectTypeId}:${ref.primaryId}`,
501
- label: `object '${ref.objectTypeId}:${ref.primaryId}'`,
502
- fingerprint: stableJsonStringify2(normalized.properties),
503
- operations: [
504
- objectUpsertOperation({
505
- id: runtimeOperationId(index),
506
- ref,
507
- properties: normalized.properties
508
- })
509
- ]
510
- };
511
- },
512
- value: ([outcome]) => ctx.objectReader.redactWrittenRow(toObjectRow(ctx.projectId, requireEffectiveObject(outcome)))
513
- });
514
- }
515
- // src/objects/telemetry/write-batch.ts
516
- import { randomUUID as randomUUID2 } from "crypto";
517
- async function writeTelemetryBatch2(ctx, points) {
518
- for (const objectTypeId of new Set(points.map((point) => point.series.object.objectTypeId))) {
519
- assertCanAppendTelemetry2(ctx, objectTypeId);
520
- }
521
- if (points.length === 0)
522
- return null;
523
- let commit;
524
- try {
525
- commit = await getOntologyMutationRuntime2(ctx).appendTelemetry({
526
- source: { kind: "runtime", requestId: randomUUID2() },
527
- points
528
- });
529
- } catch (error) {
530
- if (error instanceof MaterializationObjectNotFoundError2) {
531
- throw new ObjectNotFoundError2(error.objectTypeId, error.primaryId, "Object not found for telemetry append");
532
- }
533
- throw error;
534
- }
535
- return commit;
536
- }
537
-
538
- // src/objects/telemetry/append-batch.ts
539
- function isUnitBearingValue(raw) {
540
- if (raw === null || typeof raw !== "object") {
541
- return false;
542
- }
543
- const record = raw;
544
- return "value" in record && typeof record.unit === "string" && Object.keys(record).length === 2;
545
- }
546
- async function appendTelemetryBatch2(ctx, items) {
547
- assertCanAppendTelemetry2(ctx, ctx.objectType.id);
548
- const { objectType } = ctx;
549
- const points = new Map;
550
- for (const item of items) {
551
- const at = (item.at ?? new Date).toISOString();
552
- for (const [propertyId, rawValue] of Object.entries(item.properties)) {
553
- const propertyToken = objectType.p[propertyId];
554
- if (!propertyToken) {
555
- throw new OntologyValidationError2(`Unknown property '${objectType.id}.${propertyId}'`);
556
- }
557
- assertTelemetryProperty2(propertyToken.property);
558
- const series = {
559
- object: { objectTypeId: objectType.id, primaryId: item.id },
560
- propertyId: propertyToken.id
561
- };
562
- points.set(telemetryPointKey2(series, at), {
563
- series,
564
- value: isUnitBearingValue(rawValue) ? rawValue.value : rawValue,
565
- ...isUnitBearingValue(rawValue) ? { unit: rawValue.unit } : {},
566
- at
567
- });
568
- }
569
- }
570
- await writeTelemetryBatch2(ctx, [...points.values()]);
571
- }
572
-
573
- // src/objects/telemetry/history.ts
574
- async function getTelemetryHistoryBatch2(input, options) {
575
- const objectReader = options.objectReader;
576
- const storage = options.storage;
577
- const projectId = objectReader.projectId;
578
- const request = snapshotTelemetryHistoryInput(input, objectReader);
579
- const uniqueSeries = deduplicateSeries(request.series);
580
- const readableSeries = await selectReadableSeries(uniqueSeries, objectReader);
581
- const resultsBySeries = await readAndValidateHistory({
582
- storage,
583
- projectId,
584
- request,
585
- series: readableSeries
586
- });
587
- const releasableSeries = readableSeries.length === 0 ? [] : await selectReadableSeries(readableSeries, objectReader);
588
- const result = assembleHistoryResults({ request, resultsBySeries, releasableSeries });
589
- objectReader.assertVisibleOutputWithinLimit(result);
590
- return result;
591
- }
592
- async function getLatestTelemetryPoint(input, options) {
593
- const objectReader = options.objectReader;
594
- const storage = options.storage;
595
- const projectId = objectReader.projectId;
596
- const series = snapshotTelemetrySeries(input);
597
- const readable = await objectReader.canReadObjectProperty(objectPropertySelection(series));
598
- if (!readable)
599
- return visibleLatestResult(null, objectReader);
600
- const rawResult = await storage.getLatest({ projectId, ...series });
601
- const result = rawResult === null ? null : snapshotProviderPoint(rawResult);
602
- if (result)
603
- assertTimeseriesPointMatchesSeries(projectId, series, result);
604
- const releaseReadable = await objectReader.canReadObjectProperty(objectPropertySelection(series));
605
- if (!releaseReadable)
606
- return visibleLatestResult(null, objectReader);
607
- return visibleLatestResult(result, objectReader);
608
- }
609
- function deduplicateSeries(series) {
610
- const uniqueSeries = new Map;
611
- for (const item of series) {
612
- const key = seriesKey(item);
613
- if (!uniqueSeries.has(key))
614
- uniqueSeries.set(key, item);
615
- }
616
- return [...uniqueSeries.values()];
617
- }
618
- async function selectReadableSeries(series, objectReader) {
619
- const readable = await objectReader.canReadObjectPropertiesBatch({
620
- items: series.map(objectPropertySelection)
621
- });
622
- return series.filter((_, index) => readable[index] === true);
623
- }
624
- async function readAndValidateHistory(input) {
625
- const { storage, projectId, request, series } = input;
626
- const providerRequest = structuredClone({
627
- projectId,
628
- series,
629
- ...request.from === undefined ? {} : { from: request.from },
630
- ...request.to === undefined ? {} : { to: request.to },
631
- ...request.limitPerSeries === undefined ? {} : { limitPerSeries: request.limitPerSeries },
632
- ...request.order === undefined ? {} : { order: request.order }
633
- });
634
- const stored = series.length === 0 ? [] : await storage.getHistoryBatch(providerRequest);
635
- if (!Array.isArray(stored))
636
- throw invalidTimeseriesProviderResult();
637
- const storedCount = stored.length;
638
- if (!Number.isSafeInteger(storedCount) || storedCount > series.length) {
639
- throw invalidTimeseriesProviderResult();
640
- }
641
- const seriesKeys = new Set(series.map(seriesKey));
642
- const providerResultBySeries = new Map;
643
- for (let index = 0;index < storedCount; index += 1) {
644
- const providerResult = snapshotProviderResult(stored[index], request.limitPerSeries);
645
- const key = seriesKey(providerResult);
646
- if (providerResultBySeries.has(key) || !seriesKeys.has(key)) {
647
- throw invalidTimeseriesProviderResult();
648
- }
649
- for (const point of providerResult.points) {
650
- assertTimeseriesPointMatchesSeries(projectId, providerResult, point);
651
- }
652
- providerResultBySeries.set(key, providerResult);
653
- }
654
- return providerResultBySeries;
655
- }
656
- function assembleHistoryResults(input) {
657
- const { request, resultsBySeries, releasableSeries } = input;
658
- const releasableSeriesKeys = new Set(releasableSeries.map(seriesKey));
659
- const releasedPoints = request.series.map((series) => releasableSeriesKeys.has(seriesKey(series)) ? resultsBySeries.get(seriesKey(series))?.points ?? [] : []);
660
- const pointOccurrences = releasedPoints.reduce((total, points) => total + points.length, 0);
661
- if (request.maxPointOccurrences !== undefined && pointOccurrences > request.maxPointOccurrences) {
662
- throw invalidTimeseriesProviderResult();
663
- }
664
- return request.series.map((series, index) => ({
665
- ...series,
666
- points: releasedPoints[index].map((point) => structuredClone(point))
667
- }));
668
- }
669
- function snapshotTelemetrySeries(series) {
670
- if (typeof series !== "object" || series === null || Array.isArray(series)) {
671
- throw new Error("[Sixb] Telemetry history series must be an object.");
672
- }
673
- const objectTypeId = telemetryIdentifier(series.objectTypeId, "objectTypeId");
674
- const objectId = telemetryIdentifier(series.objectId, "objectId");
675
- const propertyId = telemetryIdentifier(series.propertyId, "propertyId");
676
- return structuredClone({ objectTypeId, objectId, propertyId });
677
- }
678
- function assertTimeseriesPointMatchesSeries(projectId, series, point) {
679
- if (typeof point !== "object" || point === null || point.projectId !== projectId || point.objectTypeId !== series.objectTypeId || point.objectId !== series.objectId || point.propertyId !== series.propertyId) {
680
- throw invalidTimeseriesProviderResult();
681
- }
682
- }
683
- function snapshotTelemetryHistoryInput(input, objectReader) {
684
- const authoredSeries = input.series;
685
- const from = input.from;
686
- const to = input.to;
687
- const limitPerSeries = input.limitPerSeries;
688
- const order = input.order;
689
- if (!Array.isArray(authoredSeries)) {
690
- throw new Error("[Sixb] Telemetry history series must be an array.");
691
- }
692
- if (order !== undefined && order !== "asc" && order !== "desc") {
693
- throw new Error("[Sixb] Telemetry history order must be 'asc' or 'desc'.");
694
- }
695
- const seriesCount = authoredSeries.length;
696
- const admission = objectReader.admitTelemetryHistoryRead({
697
- seriesCount,
698
- ...limitPerSeries === undefined ? {} : { limitPerSeries }
699
- });
700
- const series = [];
701
- for (let index = 0;index < seriesCount; index += 1) {
702
- series.push(snapshotTelemetrySeries(authoredSeries[index]));
703
- }
704
- return structuredClone({
705
- series,
706
- ...from === undefined ? {} : { from },
707
- ...to === undefined ? {} : { to },
708
- ...admission.limitPerSeries === undefined ? {} : { limitPerSeries: admission.limitPerSeries },
709
- ...order === undefined ? {} : { order },
710
- ...admission.maxPointOccurrences === undefined ? {} : { maxPointOccurrences: admission.maxPointOccurrences }
711
- });
712
- }
713
- function objectPropertySelection(series) {
714
- return {
715
- objectTypeId: series.objectTypeId,
716
- primaryId: series.objectId,
717
- propertyId: series.propertyId
718
- };
719
- }
720
- function visibleLatestResult(result, objectReader) {
721
- objectReader.assertVisibleOutputWithinLimit(result);
722
- return result;
723
- }
724
- function snapshotProviderResult(result, maxPointsPerSeries) {
725
- try {
726
- if (typeof result !== "object" || result === null || Array.isArray(result)) {
727
- throw invalidTimeseriesProviderResult();
728
- }
729
- const series = snapshotTelemetrySeries(result);
730
- const authoredPoints = result.points;
731
- if (!Array.isArray(authoredPoints))
732
- throw invalidTimeseriesProviderResult();
733
- const pointCount = authoredPoints.length;
734
- if (!Number.isSafeInteger(pointCount) || maxPointsPerSeries !== undefined && pointCount > maxPointsPerSeries) {
735
- throw invalidTimeseriesProviderResult();
736
- }
737
- const points = [];
738
- for (let index = 0;index < pointCount; index += 1) {
739
- points.push(snapshotProviderPoint(authoredPoints[index]));
740
- }
741
- return { ...series, points };
742
- } catch (error) {
743
- if (isInvalidTimeseriesProviderResult(error))
744
- throw error;
745
- throw invalidTimeseriesProviderResult(error);
746
- }
747
- }
748
- function snapshotProviderPoint(point) {
749
- try {
750
- const snapshot = structuredClone(point);
751
- if (!snapshot || typeof snapshot !== "object")
752
- throw invalidTimeseriesProviderResult();
753
- return snapshot;
754
- } catch (error) {
755
- if (isInvalidTimeseriesProviderResult(error))
756
- throw error;
757
- throw invalidTimeseriesProviderResult(error);
758
- }
759
- }
760
- function invalidTimeseriesProviderResult(cause) {
761
- return createSixbError2("internal.unexpected", "[Sixb] Timeseries storage returned data outside the requested series.", cause === undefined ? {} : { cause });
762
- }
763
- function isInvalidTimeseriesProviderResult(error) {
764
- return error instanceof Error && "code" in error && error.code === "internal.unexpected" && error.message === "[Sixb] Timeseries storage returned data outside the requested series.";
765
- }
766
- function telemetryIdentifier(value, field) {
767
- if (typeof value !== "string" || !value.trim()) {
768
- throw new Error(`[Sixb] Telemetry history ${field} must be a non-empty string.`);
769
- }
770
- return value;
771
- }
772
- function seriesKey(series) {
773
- return JSON.stringify([series.objectTypeId, series.objectId, series.propertyId]);
774
- }
775
- // src/objects/context/resolve.ts
776
- function requireLinkDefinition2(objectType, linkId) {
777
- const def = objectType.links.find((l) => l.id === linkId);
778
- if (!def)
779
- throw new OntologyNotFoundError2(`Unknown link '${objectType.id}.${linkId}'`);
780
- return def;
781
- }
782
- function resolveObjectContext2(runtime, objectTypeId) {
783
- const objectType = runtime.ontology.resolveObjectType(objectTypeId);
784
- const primaryPropertyId = runtime.ontology.getPrimaryPropertyId(objectTypeId);
785
- return { ...runtime, objectType, primaryPropertyId };
786
- }
787
- function resolveLinkContext2(objCtx, linkId) {
788
- const linkDefinition = requireLinkDefinition2(objCtx.objectType, linkId);
789
- return { ...objCtx, linkDefinition };
790
- }
791
- // src/objects/vectors/handle.ts
792
- import { randomUUID as randomUUID3 } from "crypto";
793
- function createObjectVectorHandle(ctx, primaryId, profileName) {
794
- const ref = Object.freeze({ objectTypeId: ctx.objectType.id, primaryId });
795
- const profileDefinition = ctx.ontology.resolveObjectType(ref.objectTypeId).search?.vectors?.[profileName];
796
- if (!profileDefinition)
797
- throw new MaterializationValidationError2(`Unknown vector profile: ${profileName}`);
798
- const vectors = ctx.storage.ontology.vectors;
799
- if (!vectors)
800
- throw new MaterializationValidationError2("Storage does not support vector profiles.");
801
- const assertReadable = async () => {
802
- const allowed = await ctx.objectReader.canReadObjectPropertiesBatch({
803
- items: profileDefinition.source.map((propertyId) => ({ ...ref, propertyId }))
804
- });
805
- if (allowed.some((value) => !value))
806
- throw new AuthorizationError2(`view:object:${ref.objectTypeId}`, "[Sixb] Vector profile requires access to all its source properties.");
807
- };
808
- return Object.freeze({
809
- async index() {
810
- assertCanEdit2(ctx, ref.objectTypeId);
811
- await assertReadable();
812
- const mutations = getOntologyMutationRuntime2(ctx);
813
- const model = ctx.embeddingModels?.getByRef({
814
- provider: profileDefinition.model.providerId,
815
- modelId: profileDefinition.model.modelId
816
- })?.model;
817
- if (!model || !sameEmbeddingModel(model, profileDefinition.model)) {
818
- throw new MaterializationValidationError2(`Vector profile '${profileName}' requires its configured embedding model.`);
819
- }
820
- const row = await ctx.objectReader.getByPrimaryId(ref);
821
- if (!row)
822
- throw new MaterializationValidationError2("Cannot index a missing object.");
823
- const current = (await vectors.list({ projectId: ctx.projectId, ref })).find((entry) => entry.profile === profileName);
824
- const input = {
825
- projectId: ctx.projectId,
826
- ref,
827
- profile: profileName,
828
- configuration: vectorConfiguration(profileDefinition),
829
- ...vectorSources(profileDefinition.source, row.properties),
830
- expectedObject: { ref, exists: true, version: row.version, lastCommitId: row.lastCommitId },
831
- expectedVectorCommitId: current?.lastCommitId ?? null
832
- };
833
- const result = await model.embed({ texts: [input.text], purpose: "document" });
834
- if (!Array.isArray(result?.vectors) || result.vectors.length !== 1) {
835
- throw new MaterializationValidationError2("Embedding model must return exactly one vector for one input text.");
836
- }
837
- const values = normalizeVector2(result.vectors[0], profileDefinition.model.definition.dimensions);
838
- assertCanEdit2(ctx, ref.objectTypeId);
839
- await assertReadable();
840
- await mutations.commitEdits({
841
- mode: "atomic",
842
- source: { kind: "runtime", requestId: randomUUID3() },
843
- operations: [],
844
- vectorWrites: [{ input, values }],
845
- expectedObjects: [input.expectedObject],
846
- expectedLinks: [],
847
- expectedLinkScopes: []
848
- });
849
- }
850
- });
851
- }
852
-
853
- // src/objects/sdk/file-handle.ts
854
- function createObjectFileHandle(ctx, primaryId, property, index) {
855
- const { objectType } = ctx;
856
- assertPropertyTokenBelongsToObjectType2(objectType, property);
857
- const registered = ctx.ontology.resolveObjectType(objectType.id).properties.find((candidate) => candidate.id === property.id);
858
- if (!registered) {
859
- throw new OntologyValidationError2(`[Sixb] Unknown property '${property.id}' for object type '${objectType.id}'`);
860
- }
861
- const path = filePropertyPath(objectType.id, registered, index);
862
- return {
863
- async open() {
864
- const row = await ctx.objectReader.getByPrimaryId({ objectTypeId: objectType.id, primaryId });
865
- if (!row)
866
- return null;
867
- if (row.redactions?.[property.id]) {
868
- const markings = registered.markings ?? [];
869
- const marking = markings.find((markingId) => !ctx.authorization?.clearances?.has(markingId)) ?? markings[0];
870
- throw new AuthorizationError2(`clearance:marking:${marking}`, `[Sixb] Cannot open file '${objectType.id}.${property.id}': it requires clearance for marking '${marking}'.`);
871
- }
872
- const fileRef = resolveFileRefAtPath2(row, path);
873
- return fileRef ? openFileRef2(ctx.blobStorage, fileRef) : null;
874
- }
875
- };
876
- }
877
- function filePropertyPath(objectTypeId, property, index) {
878
- const { schema } = property;
879
- const name = `${objectTypeId}.${property.id}`;
880
- if (schema === "fileRef") {
881
- if (index !== undefined) {
882
- throw new OntologyValidationError2(`[Sixb] Property ${name} holds one file; omit the index.`);
883
- }
884
- return `/properties/${jsonPointerSegment2(property.id)}`;
885
- }
886
- if (typeof schema === "object" && schema.type === "array" && schema.items === "fileRef") {
887
- if (index === undefined || !Number.isSafeInteger(index) || index < 0) {
888
- throw new OntologyValidationError2(`[Sixb] Property ${name} holds a list of files; pass the index of the file to open.`);
889
- }
890
- return `/properties/${jsonPointerSegment2(property.id)}/${index}`;
891
- }
892
- throw new OntologyValidationError2(`[Sixb] Property ${name} is not a file: file() takes a "fileRef" property or a list of them.`);
893
- }
894
-
895
- // src/objects/sdk/telemetry-channel.ts
896
- function createTelemetryChannel(ctx, primaryId) {
897
- return (property) => {
898
- const { objectType } = ctx;
899
- assertPropertyTokenBelongsToObjectType2(objectType, property);
900
- assertTelemetryProperty2(property.property);
901
- const series = { objectTypeId: objectType.id, objectId: primaryId, propertyId: property.id };
902
- const channel = {
903
- append: async (input) => {
904
- await writeTelemetryBatch2(ctx, [
905
- {
906
- series: {
907
- object: { objectTypeId: objectType.id, primaryId },
908
- propertyId: property.id
909
- },
910
- value: input.value,
911
- ...input.unit !== undefined ? { unit: input.unit } : {},
912
- at: input.at.toISOString()
913
- }
914
- ]);
915
- },
916
- history: async (input = {}) => {
917
- const timeseries = ctx.storage.timeseries;
918
- const objectReader = ctx.objectReader;
919
- if (!timeseries) {
920
- throw new RuntimeError2("[Sixb] Reading telemetry requires storage.timeseries support.");
921
- }
922
- const from = input.from;
923
- const to = input.to;
924
- const limit = input.limit;
925
- const order = input.order;
926
- const [result] = await getTelemetryHistoryBatch2({
927
- series: [series],
928
- ...from !== undefined ? { from } : {},
929
- ...to !== undefined ? { to } : {},
930
- ...limit !== undefined ? { limitPerSeries: limit } : {},
931
- ...order !== undefined ? { order } : {}
932
- }, {
933
- storage: timeseries,
934
- objectReader
935
- });
936
- return (result?.points ?? []).map((point) => ({
937
- value: point.value,
938
- at: point.at,
939
- ...point.unit !== undefined ? { unit: point.unit } : {}
940
- }));
941
- }
942
- };
943
- return channel;
944
- };
945
- }
946
-
947
- // src/objects/sdk/object-handle.ts
948
- function createObjectByIdHandle(ctx, primaryId) {
949
- const objectHandle = {
950
- vector: (profileName) => createObjectVectorHandle(ctx, primaryId, profileName),
951
- get: async () => {
952
- const row = await ctx.objectReader.getByPrimaryId({
953
- objectTypeId: ctx.objectType.id,
954
- primaryId
955
- });
956
- return row ? row : null;
957
- },
958
- listLinks: async (linkToken) => {
959
- if (linkToken) {
960
- assertLinkTokenBelongsToObjectType2(ctx.objectType, linkToken);
961
- }
962
- return ctx.objectReader.listLinks({
963
- objectTypeId: ctx.objectType.id,
964
- objectId: primaryId,
965
- linkId: linkToken?.id
966
- });
967
- },
968
- link: async (linkToken, target, options) => {
969
- assertLinkTokenBelongsToObjectType2(ctx.objectType, linkToken);
970
- const linkCtx = { ...ctx, linkDefinition: linkToken.link };
971
- await upsertLink2(linkCtx, {
972
- sourceId: primaryId,
973
- linkId: linkToken.id,
974
- targetTypeId: target.objectTypeId,
975
- targetId: target.primaryId,
976
- properties: options?.properties
977
- });
978
- },
979
- unlink: async (linkToken, target) => {
980
- assertLinkTokenBelongsToObjectType2(ctx.objectType, linkToken);
981
- const linkCtx = { ...ctx, linkDefinition: linkToken.link };
982
- await removeLink2(linkCtx, {
983
- sourceId: primaryId,
984
- linkId: linkToken.id,
985
- targetTypeId: target.objectTypeId,
986
- targetId: target.primaryId
987
- });
988
- },
989
- delete: async () => {
990
- await deleteObject2(ctx, primaryId);
991
- },
992
- restore: async () => {
993
- await restoreObject2(ctx, primaryId);
994
- },
995
- requestAction: async (input) => {
996
- const actionId = input.action?.id ?? input.actionId;
997
- if (!actionId) {
998
- throw new OntologyValidationError2("[Sixb] requestAction requires either 'action' or 'actionId'");
999
- }
1000
- return requestAction2(ctx, {
1001
- primaryId,
1002
- actionId,
1003
- params: input.params,
1004
- options: { runId: input.runId }
1005
- });
1006
- },
1007
- requestActionAndWait: async (input) => {
1008
- const actionId = input.action?.id ?? input.actionId;
1009
- if (!actionId) {
1010
- throw new OntologyValidationError2("[Sixb] requestActionAndWait requires either 'action' or 'actionId'");
1011
- }
1012
- return requestActionAndWait(ctx, {
1013
- primaryId,
1014
- actionId,
1015
- params: input.params,
1016
- options: {
1017
- timeoutMs: input.timeoutMs,
1018
- signal: input.signal
1019
- }
1020
- });
1021
- },
1022
- telemetry: createTelemetryChannel(ctx, primaryId),
1023
- file: (property, index) => createObjectFileHandle(ctx, primaryId, property, index)
1024
- };
1025
- return objectHandle;
1026
- }
1027
-
1028
- // src/objects/sdk/runtime-query-executor.ts
1029
- function createRuntimeQueryExecutor(params) {
1030
- const { ontology, objectReader } = params;
1031
- return {
1032
- async list(query, options) {
1033
- try {
1034
- return await objectReader.executeQuery({
1035
- query,
1036
- includeTotal: options?.includeTotal,
1037
- signal: options?.signal
1038
- });
1039
- } catch (error) {
1040
- if (error instanceof ObjectQueryPlanningError2) {
1041
- throw addSdkPlanningHints(error);
1042
- }
1043
- throw error;
1044
- }
1045
- },
1046
- async count(query) {
1047
- const result = await objectReader.count({ query });
1048
- return result.count;
1049
- },
1050
- async exists(query) {
1051
- const result = await objectReader.exists({ query });
1052
- return result.exists;
1053
- },
1054
- async facets(query, facets) {
1055
- const result = await objectReader.facet({ query, facets });
1056
- return {
1057
- total: result.total,
1058
- facets: result.facets.map((facet) => ({
1059
- propertyId: facet.propertyId,
1060
- buckets: [...facet.buckets]
1061
- }))
1062
- };
1063
- },
1064
- validate(query) {
1065
- return validateObjectQuery2(query, { ontology, normalize: false });
1066
- },
1067
- explain(query) {
1068
- return explainObjectQuery2(query, { ontology, normalize: false });
1069
- }
1070
- };
1071
- }
1072
- function addSdkPlanningHints(error) {
1073
- if (!error.issues.some((issue) => issue.code === "fallback_requires_bound"))
1074
- return error;
1075
- return new ObjectQueryPlanningError2(error.issues.map((issue) => issue.code === "fallback_requires_bound" ? {
1076
- ...issue,
1077
- message: "Object query fallback requires an explicit result bound. Add .limit(n) or .page({ pageSize: n }) before .list()."
1078
- } : issue));
1079
- }
1080
-
1081
- // src/objects/sdk/object-set.ts
1082
- function createObjectSet2(params) {
1083
- assertAuthorizedObjectReaderBinding({
1084
- reader: params.objectReader,
1085
- scope: { execution: params.execution, authorization: params.runtimeAuthorization }
1086
- });
1087
- const { objectType } = params;
1088
- const primaryProp = objectType.properties.find((p) => p.primary);
1089
- if (!primaryProp) {
1090
- throw new OntologyValidationError2(`Object type '${objectType.id}' has no primary property`);
1091
- }
1092
- const primaryPropertyId = primaryProp.id;
1093
- const {
1094
- projectId,
1095
- broker,
1096
- ontology,
1097
- actionRegistry,
1098
- events,
1099
- storage,
1100
- queues,
1101
- objectReader,
1102
- runtimeAuthorization,
1103
- authorization,
1104
- execution
1105
- } = params;
1106
- const queryExecutor = createRuntimeQueryExecutor({
1107
- ontology,
1108
- objectReader
1109
- });
1110
- const resolvedCtx = {
1111
- embeddingModels: params.embeddingModels,
1112
- projectId,
1113
- broker,
1114
- ontology,
1115
- actionRegistry,
1116
- events,
1117
- storage,
1118
- queues,
1119
- objectReader,
1120
- runtimeAuthorization,
1121
- authorization,
1122
- execution,
1123
- blobStorage: params.blobStorage,
1124
- objectType,
1125
- primaryPropertyId
1126
- };
1127
- shareOntologyMutationRuntime2(params, resolvedCtx);
1128
- shareSixbErrorReporter2(params, resolvedCtx);
1129
- const objectSet = {
1130
- get: async (id) => {
1131
- const row = await objectReader.getByPrimaryId({
1132
- objectTypeId: objectType.id,
1133
- primaryId: id
1134
- });
1135
- return row ? row : null;
1136
- },
1137
- upsert: async (input) => {
1138
- const row = await upsertObject2(resolvedCtx, input.properties);
1139
- return row;
1140
- },
1141
- query: () => createObjectQueryBuilder2({
1142
- query: { kind: "start", objectTypeId: objectType.id },
1143
- executor: queryExecutor
1144
- }),
1145
- byId: (id) => createObjectByIdHandle(resolvedCtx, id),
1146
- list: async (input) => {
1147
- const result = await objectReader.list({
1148
- objectTypeId: objectType.id,
1149
- primaryIdPrefix: input?.idPrefix,
1150
- primaryIdSuffix: input?.idSuffix,
1151
- updatedAfter: input?.updatedAfter,
1152
- updatedBefore: input?.updatedBefore,
1153
- createdAfter: input?.createdAfter,
1154
- createdBefore: input?.createdBefore,
1155
- limit: input?.limit,
1156
- offset: input?.offset,
1157
- orderBy: input?.orderBy,
1158
- order: input?.order
1159
- });
1160
- return {
1161
- objects: result.objects.map((row) => row),
1162
- hasMore: result.hasMore,
1163
- total: result.total ?? result.objects.length
1164
- };
1165
- },
1166
- appendTelemetryBatch: async (items) => {
1167
- await appendTelemetryBatch2(resolvedCtx, items);
1168
- },
1169
- requestAction: async (input) => {
1170
- const actionId = input.action?.id ?? input.actionId;
1171
- if (!actionId) {
1172
- throw new OntologyValidationError2("[Sixb] requestAction requires either 'action' or 'actionId'");
1173
- }
1174
- return requestAction2(resolvedCtx, {
1175
- primaryId: input.id,
1176
- actionId,
1177
- params: input.params,
1178
- options: { runId: input.runId }
1179
- });
1180
- },
1181
- requestActionAndWait: async (input) => {
1182
- const actionId = input.action?.id ?? input.actionId;
1183
- if (!actionId) {
1184
- throw new OntologyValidationError2("[Sixb] requestActionAndWait requires either 'action' or 'actionId'");
1185
- }
1186
- return requestActionAndWait(resolvedCtx, {
1187
- primaryId: input.id,
1188
- actionId,
1189
- params: input.params,
1190
- options: {
1191
- timeoutMs: input.timeoutMs,
1192
- signal: input.signal
1193
- }
1194
- });
1195
- },
1196
- upsertLink: async (input) => {
1197
- const linkDefinition = requireLinkDefinition2(objectType, input.linkId);
1198
- const linkCtx = { ...resolvedCtx, linkDefinition };
1199
- await upsertLink2(linkCtx, {
1200
- sourceId: input.sourceId,
1201
- linkId: input.linkId,
1202
- targetTypeId: input.targetTypeId,
1203
- targetId: input.targetId,
1204
- properties: input.properties
1205
- });
1206
- },
1207
- removeLink: async (input) => {
1208
- const linkDefinition = requireLinkDefinition2(objectType, input.linkId);
1209
- const linkCtx = { ...resolvedCtx, linkDefinition };
1210
- await removeLink2(linkCtx, {
1211
- sourceId: input.sourceId,
1212
- linkId: input.linkId,
1213
- targetTypeId: input.targetTypeId,
1214
- targetId: input.targetId
1215
- });
1216
- }
1217
- };
1218
- return objectSet;
1219
- }
1220
- // src/objects/service/index.ts
1221
- var exports_service = {};
1222
- __export(exports_service, {
1223
- appendTelemetry: () => appendTelemetry,
1224
- listObjects: () => listObjects,
1225
- removeLink: () => removeLink3,
1226
- requestAction: () => requestAction,
1227
- requestActionAndWait: () => requestActionAndWait3,
1228
- upsertLink: () => upsertLink3,
1229
- upsertLinkBatch: () => upsertLinkBatch3,
1230
- upsertObject: () => upsertObject3,
1231
- upsertObjectBatch: () => upsertObjectBatch3
1232
- });
1233
-
1234
- // src/objects/service/action-service.ts
1235
- async function requestAction(runtime, execution, objectTypeId, primaryId, actionId, params, options) {
1236
- const ctx = { ...resolveObjectContext2(runtime, objectTypeId), execution };
1237
- return requestAction2(ctx, { primaryId, actionId, params, options });
1238
- }
1239
- async function requestActionAndWait3(runtime, execution, objectTypeId, primaryId, actionId, params, options) {
1240
- const ctx = { ...resolveObjectContext2(runtime, objectTypeId), execution };
1241
- return requestActionAndWait(ctx, { primaryId, actionId, params, options });
1242
- }
1243
- // src/objects/service/link-service.ts
1244
- async function upsertLink3(runtime, objectTypeId, sourceId, linkId, target) {
1245
- const ctx = resolveObjectContext2(runtime, objectTypeId);
1246
- const linkCtx = resolveLinkContext2(ctx, linkId);
1247
- await upsertLink2(linkCtx, {
1248
- sourceId,
1249
- linkId,
1250
- targetTypeId: target.targetTypeId,
1251
- targetId: target.targetId,
1252
- properties: target.properties
1253
- });
1254
- }
1255
- async function upsertLinkBatch3(runtime, items) {
1256
- const resolvedItems = items.map((item) => {
1257
- const objectType = runtime.ontology.resolveObjectType(item.objectTypeId);
1258
- const linkDefinition = requireLinkDefinition2(objectType, item.linkId);
1259
- return {
1260
- objectType,
1261
- linkDefinition,
1262
- sourceId: item.sourceId,
1263
- linkId: item.linkId,
1264
- targetTypeId: item.target.targetTypeId,
1265
- targetId: item.target.targetId,
1266
- properties: item.target.properties
1267
- };
1268
- });
1269
- return upsertLinkBatch2(runtime, resolvedItems);
1270
- }
1271
- async function removeLink3(runtime, objectTypeId, sourceId, linkId, target) {
1272
- const ctx = resolveObjectContext2(runtime, objectTypeId);
1273
- const linkCtx = resolveLinkContext2(ctx, linkId);
1274
- await removeLink2(linkCtx, {
1275
- sourceId,
1276
- linkId,
1277
- targetTypeId: target.targetTypeId,
1278
- targetId: target.targetId
1279
- });
1280
- }
1281
- // src/objects/service/list-service.ts
1282
- async function listObjects(runtime, params) {
1283
- const objectTypeIds = resolveTypeFilter(runtime, params.objectTypeIds);
1284
- if (objectTypeIds !== undefined && objectTypeIds.length === 0) {
1285
- return { objects: [], hasMore: false, total: 0 };
1286
- }
1287
- const result = await runtime.objectReader.list({
1288
- objectTypeId: objectTypeIds?.length === 1 ? objectTypeIds[0] : objectTypeIds,
1289
- primaryIdPrefix: params.idPrefix,
1290
- primaryIdSuffix: params.idSuffix,
1291
- updatedAfter: params.updatedAfter,
1292
- updatedBefore: params.updatedBefore,
1293
- createdAfter: params.createdAfter,
1294
- createdBefore: params.createdBefore,
1295
- limit: params.limit,
1296
- offset: params.offset,
1297
- orderBy: params.orderBy,
1298
- order: params.order
1299
- });
1300
- return {
1301
- objects: [...result.objects],
1302
- hasMore: result.hasMore,
1303
- total: result.total
1304
- };
1305
- }
1306
- function resolveTypeFilter(runtime, requested) {
1307
- const ontology = resolveRuntimeAuthorizationForProject(runtime).type === "delegated" ? getAuthorizedOntologyView(runtime.objectReader) : runtime.ontology;
1308
- if (requested) {
1309
- for (const objectTypeId of requested) {
1310
- ontology.resolveObjectType(objectTypeId);
1311
- }
1312
- }
1313
- return requested ? [...new Set(requested.flatMap((id) => [id, ...ontology.listSubTypes(id)]))] : undefined;
1314
- }
1315
- // src/objects/service/object-service.ts
1316
- async function upsertObject3(runtime, objectTypeId, properties) {
1317
- return upsertObject2(resolveObjectContext2(runtime, objectTypeId), properties);
1318
- }
1319
- async function upsertObjectBatch3(runtime, objectTypeId, items) {
1320
- return upsertObjectBatch2(resolveObjectContext2(runtime, objectTypeId), items);
1321
- }
1322
- // src/objects/service/telemetry-service.ts
1323
- async function appendTelemetry(runtime, objectTypeId, items) {
1324
- const ctx = resolveObjectContext2(runtime, objectTypeId);
1325
- await appendTelemetryBatch2(ctx, items);
1326
- }
1327
- export { requestAction2, ObjectError2, removeLink2, upsertLink2, upsertLinkBatch2, deleteObject2, restoreObject2, upsertObject2, upsertObjectBatch2, writeTelemetryBatch2, appendTelemetryBatch2, getTelemetryHistoryBatch2, getLatestTelemetryPoint, requireLinkDefinition2, resolveObjectContext2, resolveLinkContext2, createObjectSet2, upsertLink3, upsertLinkBatch3, removeLink3, listObjects, upsertObject3, upsertObjectBatch3, appendTelemetry, exports_service };
1328
-
1329
- //# debugId=90347800675626DB64756E2164756E21