@eloxiv/contracts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (537) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/dist/Agent.d.ts +792 -0
  4. package/dist/Agent.d.ts.map +1 -0
  5. package/dist/Agent.js +610 -0
  6. package/dist/Agent.js.map +1 -0
  7. package/dist/Analytics.d.ts +46 -0
  8. package/dist/Analytics.d.ts.map +1 -0
  9. package/dist/Analytics.js +89 -0
  10. package/dist/Analytics.js.map +1 -0
  11. package/dist/Approval.d.ts +70 -0
  12. package/dist/Approval.d.ts.map +1 -0
  13. package/dist/Approval.js +127 -0
  14. package/dist/Approval.js.map +1 -0
  15. package/dist/Catalog.d.ts +238 -0
  16. package/dist/Catalog.d.ts.map +1 -0
  17. package/dist/Catalog.js +169 -0
  18. package/dist/Catalog.js.map +1 -0
  19. package/dist/Checklist.d.ts +99 -0
  20. package/dist/Checklist.d.ts.map +1 -0
  21. package/dist/Checklist.js +105 -0
  22. package/dist/Checklist.js.map +1 -0
  23. package/dist/Data.d.ts +107 -0
  24. package/dist/Data.d.ts.map +1 -0
  25. package/dist/Data.js +93 -0
  26. package/dist/Data.js.map +1 -0
  27. package/dist/Devices.d.ts +857 -0
  28. package/dist/Devices.d.ts.map +1 -0
  29. package/dist/Devices.js +590 -0
  30. package/dist/Devices.js.map +1 -0
  31. package/dist/Durable.d.ts +406 -0
  32. package/dist/Durable.d.ts.map +1 -0
  33. package/dist/Durable.js +203 -0
  34. package/dist/Durable.js.map +1 -0
  35. package/dist/Errors.d.ts +95 -0
  36. package/dist/Errors.d.ts.map +1 -0
  37. package/dist/Errors.js +72 -0
  38. package/dist/Errors.js.map +1 -0
  39. package/dist/JsonSchema.d.ts +355 -0
  40. package/dist/JsonSchema.d.ts.map +1 -0
  41. package/dist/JsonSchema.js +151 -0
  42. package/dist/JsonSchema.js.map +1 -0
  43. package/dist/Manifest.d.ts +353 -0
  44. package/dist/Manifest.d.ts.map +1 -0
  45. package/dist/Manifest.js +894 -0
  46. package/dist/Manifest.js.map +1 -0
  47. package/dist/Module.d.ts +447 -0
  48. package/dist/Module.d.ts.map +1 -0
  49. package/dist/Module.js +221 -0
  50. package/dist/Module.js.map +1 -0
  51. package/dist/Optimistic.d.ts +192 -0
  52. package/dist/Optimistic.d.ts.map +1 -0
  53. package/dist/Optimistic.js +319 -0
  54. package/dist/Optimistic.js.map +1 -0
  55. package/dist/Projection.d.ts +163 -0
  56. package/dist/Projection.d.ts.map +1 -0
  57. package/dist/Projection.js +158 -0
  58. package/dist/Projection.js.map +1 -0
  59. package/dist/Proposals.d.ts +103 -0
  60. package/dist/Proposals.d.ts.map +1 -0
  61. package/dist/Proposals.js +72 -0
  62. package/dist/Proposals.js.map +1 -0
  63. package/dist/Receipt.d.ts +243 -0
  64. package/dist/Receipt.d.ts.map +1 -0
  65. package/dist/Receipt.js +108 -0
  66. package/dist/Receipt.js.map +1 -0
  67. package/dist/Records.d.ts +297 -0
  68. package/dist/Records.d.ts.map +1 -0
  69. package/dist/Records.js +171 -0
  70. package/dist/Records.js.map +1 -0
  71. package/dist/Render.d.ts +207 -0
  72. package/dist/Render.d.ts.map +1 -0
  73. package/dist/Render.js +502 -0
  74. package/dist/Render.js.map +1 -0
  75. package/dist/Rpc.d.ts +115 -0
  76. package/dist/Rpc.d.ts.map +1 -0
  77. package/dist/Rpc.js +68 -0
  78. package/dist/Rpc.js.map +1 -0
  79. package/dist/SearchLanguages.d.ts +4 -0
  80. package/dist/SearchLanguages.d.ts.map +1 -0
  81. package/dist/SearchLanguages.js +33 -0
  82. package/dist/SearchLanguages.js.map +1 -0
  83. package/dist/Service.d.ts +59 -0
  84. package/dist/Service.d.ts.map +1 -0
  85. package/dist/Service.js +38 -0
  86. package/dist/Service.js.map +1 -0
  87. package/dist/Versions.d.ts +9 -0
  88. package/dist/Versions.d.ts.map +1 -0
  89. package/dist/Versions.js +78 -0
  90. package/dist/Versions.js.map +1 -0
  91. package/dist/contracts/ActionConsent.d.ts +189 -0
  92. package/dist/contracts/ActionConsent.d.ts.map +1 -0
  93. package/dist/contracts/ActionConsent.js +129 -0
  94. package/dist/contracts/ActionConsent.js.map +1 -0
  95. package/dist/contracts/ActionRegistry.d.ts +149 -0
  96. package/dist/contracts/ActionRegistry.d.ts.map +1 -0
  97. package/dist/contracts/ActionRegistry.js +37 -0
  98. package/dist/contracts/ActionRegistry.js.map +1 -0
  99. package/dist/contracts/Actor.d.ts +129 -0
  100. package/dist/contracts/Actor.d.ts.map +1 -0
  101. package/dist/contracts/Actor.js +47 -0
  102. package/dist/contracts/Actor.js.map +1 -0
  103. package/dist/contracts/AgentResources.d.ts +248 -0
  104. package/dist/contracts/AgentResources.d.ts.map +1 -0
  105. package/dist/contracts/AgentResources.js +158 -0
  106. package/dist/contracts/AgentResources.js.map +1 -0
  107. package/dist/contracts/AgentRuntime.d.ts +453 -0
  108. package/dist/contracts/AgentRuntime.d.ts.map +1 -0
  109. package/dist/contracts/AgentRuntime.js +117 -0
  110. package/dist/contracts/AgentRuntime.js.map +1 -0
  111. package/dist/contracts/Approvals.d.ts +303 -0
  112. package/dist/contracts/Approvals.d.ts.map +1 -0
  113. package/dist/contracts/Approvals.js +117 -0
  114. package/dist/contracts/Approvals.js.map +1 -0
  115. package/dist/contracts/Audit.d.ts +510 -0
  116. package/dist/contracts/Audit.d.ts.map +1 -0
  117. package/dist/contracts/Audit.js +139 -0
  118. package/dist/contracts/Audit.js.map +1 -0
  119. package/dist/contracts/CalendarProvider.d.ts +572 -0
  120. package/dist/contracts/CalendarProvider.d.ts.map +1 -0
  121. package/dist/contracts/CalendarProvider.js +203 -0
  122. package/dist/contracts/CalendarProvider.js.map +1 -0
  123. package/dist/contracts/Capability.d.ts +197 -0
  124. package/dist/contracts/Capability.d.ts.map +1 -0
  125. package/dist/contracts/Capability.js +189 -0
  126. package/dist/contracts/Capability.js.map +1 -0
  127. package/dist/contracts/ClientSDK.d.ts +250 -0
  128. package/dist/contracts/ClientSDK.d.ts.map +1 -0
  129. package/dist/contracts/ClientSDK.js +184 -0
  130. package/dist/contracts/ClientSDK.js.map +1 -0
  131. package/dist/contracts/CollabDocument.d.ts +781 -0
  132. package/dist/contracts/CollabDocument.d.ts.map +1 -0
  133. package/dist/contracts/CollabDocument.js +364 -0
  134. package/dist/contracts/CollabDocument.js.map +1 -0
  135. package/dist/contracts/Command.d.ts +183 -0
  136. package/dist/contracts/Command.d.ts.map +1 -0
  137. package/dist/contracts/Command.js +66 -0
  138. package/dist/contracts/Command.js.map +1 -0
  139. package/dist/contracts/Connections.d.ts +612 -0
  140. package/dist/contracts/Connections.d.ts.map +1 -0
  141. package/dist/contracts/Connections.js +323 -0
  142. package/dist/contracts/Connections.js.map +1 -0
  143. package/dist/contracts/ContextAccounting.d.ts +79 -0
  144. package/dist/contracts/ContextAccounting.d.ts.map +1 -0
  145. package/dist/contracts/ContextAccounting.js +32 -0
  146. package/dist/contracts/ContextAccounting.js.map +1 -0
  147. package/dist/contracts/Daemon.d.ts +486 -0
  148. package/dist/contracts/Daemon.d.ts.map +1 -0
  149. package/dist/contracts/Daemon.js +192 -0
  150. package/dist/contracts/Daemon.js.map +1 -0
  151. package/dist/contracts/DbTx.d.ts +149 -0
  152. package/dist/contracts/DbTx.d.ts.map +1 -0
  153. package/dist/contracts/DbTx.js +94 -0
  154. package/dist/contracts/DbTx.js.map +1 -0
  155. package/dist/contracts/Delegation.d.ts +121 -0
  156. package/dist/contracts/Delegation.d.ts.map +1 -0
  157. package/dist/contracts/Delegation.js +76 -0
  158. package/dist/contracts/Delegation.js.map +1 -0
  159. package/dist/contracts/DeviceControl.d.ts +293 -0
  160. package/dist/contracts/DeviceControl.d.ts.map +1 -0
  161. package/dist/contracts/DeviceControl.js +107 -0
  162. package/dist/contracts/DeviceControl.js.map +1 -0
  163. package/dist/contracts/Directory.d.ts +492 -0
  164. package/dist/contracts/Directory.d.ts.map +1 -0
  165. package/dist/contracts/Directory.js +225 -0
  166. package/dist/contracts/Directory.js.map +1 -0
  167. package/dist/contracts/DirectoryProvider.d.ts +214 -0
  168. package/dist/contracts/DirectoryProvider.d.ts.map +1 -0
  169. package/dist/contracts/DirectoryProvider.js +73 -0
  170. package/dist/contracts/DirectoryProvider.js.map +1 -0
  171. package/dist/contracts/DocumentSource.d.ts +190 -0
  172. package/dist/contracts/DocumentSource.d.ts.map +1 -0
  173. package/dist/contracts/DocumentSource.js +64 -0
  174. package/dist/contracts/DocumentSource.js.map +1 -0
  175. package/dist/contracts/Files.d.ts +762 -0
  176. package/dist/contracts/Files.d.ts.map +1 -0
  177. package/dist/contracts/Files.js +339 -0
  178. package/dist/contracts/Files.js.map +1 -0
  179. package/dist/contracts/Flags.d.ts +265 -0
  180. package/dist/contracts/Flags.d.ts.map +1 -0
  181. package/dist/contracts/Flags.js +197 -0
  182. package/dist/contracts/Flags.js.map +1 -0
  183. package/dist/contracts/Host.d.ts +320 -0
  184. package/dist/contracts/Host.d.ts.map +1 -0
  185. package/dist/contracts/Host.js +224 -0
  186. package/dist/contracts/Host.js.map +1 -0
  187. package/dist/contracts/HttpApi.d.ts +102 -0
  188. package/dist/contracts/HttpApi.d.ts.map +1 -0
  189. package/dist/contracts/HttpApi.js +89 -0
  190. package/dist/contracts/HttpApi.js.map +1 -0
  191. package/dist/contracts/Ingestion.d.ts +522 -0
  192. package/dist/contracts/Ingestion.d.ts.map +1 -0
  193. package/dist/contracts/Ingestion.js +275 -0
  194. package/dist/contracts/Ingestion.js.map +1 -0
  195. package/dist/contracts/Ingress.d.ts +132 -0
  196. package/dist/contracts/Ingress.d.ts.map +1 -0
  197. package/dist/contracts/Ingress.js +102 -0
  198. package/dist/contracts/Ingress.js.map +1 -0
  199. package/dist/contracts/Invocation.d.ts +361 -0
  200. package/dist/contracts/Invocation.d.ts.map +1 -0
  201. package/dist/contracts/Invocation.js +104 -0
  202. package/dist/contracts/Invocation.js.map +1 -0
  203. package/dist/contracts/LocalClient.d.ts +878 -0
  204. package/dist/contracts/LocalClient.d.ts.map +1 -0
  205. package/dist/contracts/LocalClient.js +423 -0
  206. package/dist/contracts/LocalClient.js.map +1 -0
  207. package/dist/contracts/Locale.d.ts +162 -0
  208. package/dist/contracts/Locale.d.ts.map +1 -0
  209. package/dist/contracts/Locale.js +123 -0
  210. package/dist/contracts/Locale.js.map +1 -0
  211. package/dist/contracts/MachineIdentity.d.ts +434 -0
  212. package/dist/contracts/MachineIdentity.d.ts.map +1 -0
  213. package/dist/contracts/MachineIdentity.js +223 -0
  214. package/dist/contracts/MachineIdentity.js.map +1 -0
  215. package/dist/contracts/MailProvider.d.ts +791 -0
  216. package/dist/contracts/MailProvider.d.ts.map +1 -0
  217. package/dist/contracts/MailProvider.js +237 -0
  218. package/dist/contracts/MailProvider.js.map +1 -0
  219. package/dist/contracts/Memory.d.ts +62 -0
  220. package/dist/contracts/Memory.d.ts.map +1 -0
  221. package/dist/contracts/Memory.js +43 -0
  222. package/dist/contracts/Memory.js.map +1 -0
  223. package/dist/contracts/Messaging.d.ts +154 -0
  224. package/dist/contracts/Messaging.d.ts.map +1 -0
  225. package/dist/contracts/Messaging.js +97 -0
  226. package/dist/contracts/Messaging.js.map +1 -0
  227. package/dist/contracts/Metering.d.ts +334 -0
  228. package/dist/contracts/Metering.d.ts.map +1 -0
  229. package/dist/contracts/Metering.js +202 -0
  230. package/dist/contracts/Metering.js.map +1 -0
  231. package/dist/contracts/ModelProvider.d.ts +142 -0
  232. package/dist/contracts/ModelProvider.d.ts.map +1 -0
  233. package/dist/contracts/ModelProvider.js +72 -0
  234. package/dist/contracts/ModelProvider.js.map +1 -0
  235. package/dist/contracts/ModuleManifest.d.ts +2519 -0
  236. package/dist/contracts/ModuleManifest.d.ts.map +1 -0
  237. package/dist/contracts/ModuleManifest.js +272 -0
  238. package/dist/contracts/ModuleManifest.js.map +1 -0
  239. package/dist/contracts/NotificationChannel.d.ts +378 -0
  240. package/dist/contracts/NotificationChannel.d.ts.map +1 -0
  241. package/dist/contracts/NotificationChannel.js +136 -0
  242. package/dist/contracts/NotificationChannel.js.map +1 -0
  243. package/dist/contracts/Notifications.d.ts +417 -0
  244. package/dist/contracts/Notifications.d.ts.map +1 -0
  245. package/dist/contracts/Notifications.js +267 -0
  246. package/dist/contracts/Notifications.js.map +1 -0
  247. package/dist/contracts/Outbox.d.ts +469 -0
  248. package/dist/contracts/Outbox.d.ts.map +1 -0
  249. package/dist/contracts/Outbox.js +215 -0
  250. package/dist/contracts/Outbox.js.map +1 -0
  251. package/dist/contracts/Privacy.d.ts +1029 -0
  252. package/dist/contracts/Privacy.d.ts.map +1 -0
  253. package/dist/contracts/Privacy.js +437 -0
  254. package/dist/contracts/Privacy.js.map +1 -0
  255. package/dist/contracts/Progress.d.ts +305 -0
  256. package/dist/contracts/Progress.d.ts.map +1 -0
  257. package/dist/contracts/Progress.js +174 -0
  258. package/dist/contracts/Progress.js.map +1 -0
  259. package/dist/contracts/QuerySurface.d.ts +231 -0
  260. package/dist/contracts/QuerySurface.d.ts.map +1 -0
  261. package/dist/contracts/QuerySurface.js +113 -0
  262. package/dist/contracts/QuerySurface.js.map +1 -0
  263. package/dist/contracts/Readiness.d.ts +105 -0
  264. package/dist/contracts/Readiness.d.ts.map +1 -0
  265. package/dist/contracts/Readiness.js +57 -0
  266. package/dist/contracts/Readiness.js.map +1 -0
  267. package/dist/contracts/Release.d.ts +295 -0
  268. package/dist/contracts/Release.d.ts.map +1 -0
  269. package/dist/contracts/Release.js +175 -0
  270. package/dist/contracts/Release.js.map +1 -0
  271. package/dist/contracts/ResultRendering.d.ts +533 -0
  272. package/dist/contracts/ResultRendering.d.ts.map +1 -0
  273. package/dist/contracts/ResultRendering.js +59 -0
  274. package/dist/contracts/ResultRendering.js.map +1 -0
  275. package/dist/contracts/Sandbox.d.ts +1164 -0
  276. package/dist/contracts/Sandbox.d.ts.map +1 -0
  277. package/dist/contracts/Sandbox.js +550 -0
  278. package/dist/contracts/Sandbox.js.map +1 -0
  279. package/dist/contracts/Scheduler.d.ts +814 -0
  280. package/dist/contracts/Scheduler.d.ts.map +1 -0
  281. package/dist/contracts/Scheduler.js +202 -0
  282. package/dist/contracts/Scheduler.js.map +1 -0
  283. package/dist/contracts/ScreenContext.d.ts +514 -0
  284. package/dist/contracts/ScreenContext.d.ts.map +1 -0
  285. package/dist/contracts/ScreenContext.js +272 -0
  286. package/dist/contracts/ScreenContext.js.map +1 -0
  287. package/dist/contracts/Search.d.ts +308 -0
  288. package/dist/contracts/Search.d.ts.map +1 -0
  289. package/dist/contracts/Search.js +107 -0
  290. package/dist/contracts/Search.js.map +1 -0
  291. package/dist/contracts/Secrets.d.ts +483 -0
  292. package/dist/contracts/Secrets.d.ts.map +1 -0
  293. package/dist/contracts/Secrets.js +136 -0
  294. package/dist/contracts/Secrets.js.map +1 -0
  295. package/dist/contracts/Settings.d.ts +221 -0
  296. package/dist/contracts/Settings.d.ts.map +1 -0
  297. package/dist/contracts/Settings.js +163 -0
  298. package/dist/contracts/Settings.js.map +1 -0
  299. package/dist/contracts/Sharing.d.ts +319 -0
  300. package/dist/contracts/Sharing.d.ts.map +1 -0
  301. package/dist/contracts/Sharing.js +172 -0
  302. package/dist/contracts/Sharing.js.map +1 -0
  303. package/dist/contracts/Slot.d.ts +162 -0
  304. package/dist/contracts/Slot.d.ts.map +1 -0
  305. package/dist/contracts/Slot.js +56 -0
  306. package/dist/contracts/Slot.js.map +1 -0
  307. package/dist/contracts/Space.d.ts +256 -0
  308. package/dist/contracts/Space.d.ts.map +1 -0
  309. package/dist/contracts/Space.js +133 -0
  310. package/dist/contracts/Space.js.map +1 -0
  311. package/dist/contracts/StorageAdapter.d.ts +124 -0
  312. package/dist/contracts/StorageAdapter.d.ts.map +1 -0
  313. package/dist/contracts/StorageAdapter.js +96 -0
  314. package/dist/contracts/StorageAdapter.js.map +1 -0
  315. package/dist/contracts/StorageBackend.d.ts +310 -0
  316. package/dist/contracts/StorageBackend.d.ts.map +1 -0
  317. package/dist/contracts/StorageBackend.js +196 -0
  318. package/dist/contracts/StorageBackend.js.map +1 -0
  319. package/dist/contracts/Sync.d.ts +286 -0
  320. package/dist/contracts/Sync.d.ts.map +1 -0
  321. package/dist/contracts/Sync.js +157 -0
  322. package/dist/contracts/Sync.js.map +1 -0
  323. package/dist/contracts/Telemetry.d.ts +183 -0
  324. package/dist/contracts/Telemetry.d.ts.map +1 -0
  325. package/dist/contracts/Telemetry.js +153 -0
  326. package/dist/contracts/Telemetry.js.map +1 -0
  327. package/dist/contracts/ThemeTokens.d.ts +212 -0
  328. package/dist/contracts/ThemeTokens.d.ts.map +1 -0
  329. package/dist/contracts/ThemeTokens.js +111 -0
  330. package/dist/contracts/ThemeTokens.js.map +1 -0
  331. package/dist/contracts/ToolSource.d.ts +135 -0
  332. package/dist/contracts/ToolSource.d.ts.map +1 -0
  333. package/dist/contracts/ToolSource.js +81 -0
  334. package/dist/contracts/ToolSource.js.map +1 -0
  335. package/dist/contracts/Versioning.d.ts +363 -0
  336. package/dist/contracts/Versioning.d.ts.map +1 -0
  337. package/dist/contracts/Versioning.js +201 -0
  338. package/dist/contracts/Versioning.js.map +1 -0
  339. package/dist/contracts/View.d.ts +232 -0
  340. package/dist/contracts/View.d.ts.map +1 -0
  341. package/dist/contracts/View.js +102 -0
  342. package/dist/contracts/View.js.map +1 -0
  343. package/dist/contracts/WorkItems.d.ts +242 -0
  344. package/dist/contracts/WorkItems.d.ts.map +1 -0
  345. package/dist/contracts/WorkItems.js +126 -0
  346. package/dist/contracts/WorkItems.js.map +1 -0
  347. package/dist/contracts/Workflow.d.ts +191 -0
  348. package/dist/contracts/Workflow.d.ts.map +1 -0
  349. package/dist/contracts/Workflow.js +63 -0
  350. package/dist/contracts/Workflow.js.map +1 -0
  351. package/dist/contracts/index.d.ts +75 -0
  352. package/dist/contracts/index.d.ts.map +1 -0
  353. package/dist/contracts/index.js +196 -0
  354. package/dist/contracts/index.js.map +1 -0
  355. package/dist/devices/module.d.ts +3777 -0
  356. package/dist/devices/module.d.ts.map +1 -0
  357. package/dist/devices/module.js +179 -0
  358. package/dist/devices/module.js.map +1 -0
  359. package/dist/drizzle/Entity.d.ts +148 -0
  360. package/dist/drizzle/Entity.d.ts.map +1 -0
  361. package/dist/drizzle/Entity.js +396 -0
  362. package/dist/drizzle/Entity.js.map +1 -0
  363. package/dist/index.d.ts +20 -0
  364. package/dist/index.d.ts.map +1 -0
  365. package/dist/index.js +20 -0
  366. package/dist/index.js.map +1 -0
  367. package/package.json +48 -3
  368. package/schema/Actor.json +46 -0
  369. package/schema/AuditRecord.json +403 -0
  370. package/schema/DaemonHealth.json +29 -0
  371. package/schema/InvocationError.json +257 -0
  372. package/schema/InvocationReceipt.json +253 -0
  373. package/schema/Lockfile.json +129 -0
  374. package/schema/OutboxEvent.json +36 -0
  375. package/schema/PairingConfirm.json +33 -0
  376. package/schema/PairingResult.json +18 -0
  377. package/schema/PairingStart.json +18 -0
  378. package/schema/ProvenanceEntry.json +110 -0
  379. package/schema/ReplayEnvelope.json +269 -0
  380. package/schema/Surface.json +17 -0
  381. package/schema/codegen/LocalClient.json +1295 -0
  382. package/schema/codegen/Sandbox.json +320 -0
  383. package/schema/contracts/ActionConsent.json +1930 -0
  384. package/schema/contracts/ActionRegistry.json +722 -0
  385. package/schema/contracts/Actor.json +451 -0
  386. package/schema/contracts/AgentResources.json +1400 -0
  387. package/schema/contracts/AgentRuntime.json +4017 -0
  388. package/schema/contracts/Approvals.json +2916 -0
  389. package/schema/contracts/Audit.json +3268 -0
  390. package/schema/contracts/CalendarProvider.json +5557 -0
  391. package/schema/contracts/ClientSDK.json +1400 -0
  392. package/schema/contracts/CollabDocument.json +4012 -0
  393. package/schema/contracts/Command.json +616 -0
  394. package/schema/contracts/Connections.json +6687 -0
  395. package/schema/contracts/ContextAccounting.json +685 -0
  396. package/schema/contracts/Daemon.json +4555 -0
  397. package/schema/contracts/DbTx.json +321 -0
  398. package/schema/contracts/Delegation.json +949 -0
  399. package/schema/contracts/DeviceControl.json +2626 -0
  400. package/schema/contracts/Directory.json +5168 -0
  401. package/schema/contracts/DirectoryProvider.json +2090 -0
  402. package/schema/contracts/DocumentSource.json +2044 -0
  403. package/schema/contracts/Files.json +4122 -0
  404. package/schema/contracts/Flags.json +1202 -0
  405. package/schema/contracts/Host.json +1769 -0
  406. package/schema/contracts/HttpApi.json +1615 -0
  407. package/schema/contracts/Ingestion.json +3211 -0
  408. package/schema/contracts/Ingress.json +819 -0
  409. package/schema/contracts/Invocation.json +2044 -0
  410. package/schema/contracts/LocalClient.json +6642 -0
  411. package/schema/contracts/Locale.json +654 -0
  412. package/schema/contracts/MachineIdentity.json +2303 -0
  413. package/schema/contracts/MailProvider.json +6663 -0
  414. package/schema/contracts/Memory.json +579 -0
  415. package/schema/contracts/Messaging.json +1764 -0
  416. package/schema/contracts/Metering.json +3060 -0
  417. package/schema/contracts/ModelProvider.json +1127 -0
  418. package/schema/contracts/ModuleManifest.json +9449 -0
  419. package/schema/contracts/NotificationChannel.json +986 -0
  420. package/schema/contracts/Notifications.json +4280 -0
  421. package/schema/contracts/Outbox.json +1451 -0
  422. package/schema/contracts/Privacy.json +4354 -0
  423. package/schema/contracts/Progress.json +1524 -0
  424. package/schema/contracts/QuerySurface.json +661 -0
  425. package/schema/contracts/Readiness.json +209 -0
  426. package/schema/contracts/Release.json +805 -0
  427. package/schema/contracts/ResultRendering.json +2859 -0
  428. package/schema/contracts/Sandbox.json +2286 -0
  429. package/schema/contracts/Scheduler.json +6138 -0
  430. package/schema/contracts/ScreenContext.json +1238 -0
  431. package/schema/contracts/Search.json +1058 -0
  432. package/schema/contracts/Secrets.json +2444 -0
  433. package/schema/contracts/Settings.json +654 -0
  434. package/schema/contracts/Sharing.json +2854 -0
  435. package/schema/contracts/Slot.json +537 -0
  436. package/schema/contracts/Space.json +892 -0
  437. package/schema/contracts/StorageAdapter.json +623 -0
  438. package/schema/contracts/StorageBackend.json +2421 -0
  439. package/schema/contracts/Sync.json +894 -0
  440. package/schema/contracts/Telemetry.json +696 -0
  441. package/schema/contracts/ThemeTokens.json +547 -0
  442. package/schema/contracts/ToolSource.json +1333 -0
  443. package/schema/contracts/Versioning.json +1481 -0
  444. package/schema/contracts/View.json +750 -0
  445. package/schema/contracts/WorkItems.json +1731 -0
  446. package/schema/contracts/Workflow.json +1242 -0
  447. package/src/Agent.ts +758 -0
  448. package/src/Analytics.ts +110 -0
  449. package/src/Approval.ts +131 -0
  450. package/src/Catalog.ts +192 -0
  451. package/src/Checklist.ts +162 -0
  452. package/src/Data.ts +109 -0
  453. package/src/Devices.ts +721 -0
  454. package/src/Durable.ts +240 -0
  455. package/src/Errors.ts +111 -0
  456. package/src/JsonSchema.ts +166 -0
  457. package/src/Manifest.ts +1147 -0
  458. package/src/Module.ts +640 -0
  459. package/src/Optimistic.ts +332 -0
  460. package/src/Projection.ts +207 -0
  461. package/src/Proposals.ts +89 -0
  462. package/src/Receipt.ts +125 -0
  463. package/src/Records.ts +197 -0
  464. package/src/Render.ts +515 -0
  465. package/src/Rpc.ts +113 -0
  466. package/src/SearchLanguages.ts +33 -0
  467. package/src/Service.ts +102 -0
  468. package/src/Versions.ts +69 -0
  469. package/src/contracts/ActionConsent.ts +150 -0
  470. package/src/contracts/ActionRegistry.ts +39 -0
  471. package/src/contracts/Actor.ts +53 -0
  472. package/src/contracts/AgentResources.ts +167 -0
  473. package/src/contracts/AgentRuntime.ts +154 -0
  474. package/src/contracts/Approvals.ts +133 -0
  475. package/src/contracts/Audit.ts +160 -0
  476. package/src/contracts/CalendarProvider.ts +241 -0
  477. package/src/contracts/Capability.ts +246 -0
  478. package/src/contracts/ClientSDK.ts +199 -0
  479. package/src/contracts/CollabDocument.ts +420 -0
  480. package/src/contracts/Command.ts +74 -0
  481. package/src/contracts/Connections.ts +360 -0
  482. package/src/contracts/ContextAccounting.ts +35 -0
  483. package/src/contracts/Daemon.ts +247 -0
  484. package/src/contracts/DbTx.ts +110 -0
  485. package/src/contracts/Delegation.ts +91 -0
  486. package/src/contracts/DeviceControl.ts +143 -0
  487. package/src/contracts/Directory.ts +384 -0
  488. package/src/contracts/DirectoryProvider.ts +82 -0
  489. package/src/contracts/DocumentSource.ts +71 -0
  490. package/src/contracts/Files.ts +395 -0
  491. package/src/contracts/Flags.ts +241 -0
  492. package/src/contracts/Host.ts +245 -0
  493. package/src/contracts/HttpApi.ts +100 -0
  494. package/src/contracts/Ingestion.ts +315 -0
  495. package/src/contracts/Ingress.ts +132 -0
  496. package/src/contracts/Invocation.ts +122 -0
  497. package/src/contracts/LocalClient.ts +614 -0
  498. package/src/contracts/Locale.ts +133 -0
  499. package/src/contracts/MachineIdentity.ts +305 -0
  500. package/src/contracts/MailProvider.ts +272 -0
  501. package/src/contracts/Memory.ts +47 -0
  502. package/src/contracts/Messaging.ts +108 -0
  503. package/src/contracts/Metering.ts +231 -0
  504. package/src/contracts/ModelProvider.ts +87 -0
  505. package/src/contracts/ModuleManifest.ts +310 -0
  506. package/src/contracts/NotificationChannel.ts +158 -0
  507. package/src/contracts/Notifications.ts +309 -0
  508. package/src/contracts/Outbox.ts +246 -0
  509. package/src/contracts/Privacy.ts +502 -0
  510. package/src/contracts/Progress.ts +196 -0
  511. package/src/contracts/QuerySurface.ts +134 -0
  512. package/src/contracts/Readiness.ts +67 -0
  513. package/src/contracts/Release.ts +199 -0
  514. package/src/contracts/ResultRendering.ts +65 -0
  515. package/src/contracts/Sandbox.ts +648 -0
  516. package/src/contracts/Scheduler.ts +237 -0
  517. package/src/contracts/ScreenContext.ts +316 -0
  518. package/src/contracts/Search.ts +126 -0
  519. package/src/contracts/Secrets.ts +162 -0
  520. package/src/contracts/Settings.ts +207 -0
  521. package/src/contracts/Sharing.ts +205 -0
  522. package/src/contracts/Slot.ts +61 -0
  523. package/src/contracts/Space.ts +157 -0
  524. package/src/contracts/StorageAdapter.ts +104 -0
  525. package/src/contracts/StorageBackend.ts +220 -0
  526. package/src/contracts/Sync.ts +180 -0
  527. package/src/contracts/Telemetry.ts +177 -0
  528. package/src/contracts/ThemeTokens.ts +136 -0
  529. package/src/contracts/ToolSource.ts +94 -0
  530. package/src/contracts/Versioning.ts +237 -0
  531. package/src/contracts/View.ts +116 -0
  532. package/src/contracts/WorkItems.ts +144 -0
  533. package/src/contracts/Workflow.ts +67 -0
  534. package/src/contracts/index.ts +205 -0
  535. package/src/devices/module.ts +201 -0
  536. package/src/drizzle/Entity.ts +524 -0
  537. package/src/index.ts +19 -0
@@ -0,0 +1,196 @@
1
+ /**
2
+ * StorageBackend: where the bytes of files live (docs/contracts/storage-backend.md). A capability the deployment
3
+ * chooses (a local directory for development and tests, an S3-compatible object store in production), never a
4
+ * module's: the Files contract keeps every file's metadata, ownership and authorisation in the kernel's tables and
5
+ * hands the backend opaque keys only. A backend authorises nothing itself; whoever holds a key it is given reads
6
+ * or writes the object, so keys and signed URLs are issued only by the kernel, after its policy checks.
7
+ *
8
+ * Operations exchange object bodies as bytes in process; the JSON form below carries them base64-encoded, the way
9
+ * DocumentSource carries content.
10
+ */
11
+ import { Schema } from "effect";
12
+ import { defineOperation, defineServiceContract } from "../Service.js";
13
+ /**
14
+ * An object key: 1 to 1024 characters of `A-Z a-z 0-9 / _ . = -`, no empty segment, no `.` or `..` segment, not
15
+ * starting or ending with `/`. Every backend accepts exactly these (a local directory maps them onto paths, an
16
+ * object store uses them as they are), so a key never escapes its backend's root.
17
+ */
18
+ export const STORAGE_KEY_PATTERN = /^(?!.*\/\/)(?!\/)(?!.*\/$)(?!(?:.*\/)?\.\.?(?:\/|$))[A-Za-z0-9/_.=-]{1,1024}$/u;
19
+ export const StorageKey = Schema.String.check(Schema.isPattern(STORAGE_KEY_PATTERN));
20
+ /** What a backend can do beyond put, get, head, delete and list (which every backend does). */
21
+ export const StorageCapabilities = Schema.Struct({
22
+ /** `signedUrl` issues URLs a client uses directly, without the kernel in between. */
23
+ signedUrls: Schema.Boolean,
24
+ /** `createMultipart`, `uploadPart`, `listParts`, `completeMultipart`, `abortMultipart`. */
25
+ multipart: Schema.Boolean,
26
+ /** `get` with a byte range. */
27
+ ranges: Schema.Boolean,
28
+ });
29
+ export const StoredObject = Schema.Struct({
30
+ key: Schema.String,
31
+ size: Schema.Number,
32
+ /** An opaque version tag that changes whenever the object's content changes. */
33
+ etag: Schema.String,
34
+ contentType: Schema.NullOr(Schema.String),
35
+ /** ISO 8601, UTC. */
36
+ modifiedAt: Schema.String,
37
+ });
38
+ /** Inclusive byte range, as HTTP's `Range: bytes=start-end`. */
39
+ export const ByteRange = Schema.Struct({ start: Schema.Int, end: Schema.Int });
40
+ export const UploadedPart = Schema.Struct({ partNumber: Schema.Int, etag: Schema.String, size: Schema.Number });
41
+ export const SignedUrlRequest = Schema.Struct({
42
+ key: StorageKey,
43
+ method: Schema.Literals(["GET", "PUT"]),
44
+ /** Seconds the URL works for: 1 to 604800 (seven days, S3's limit). */
45
+ expiresInSeconds: Schema.Int,
46
+ /** PUT: the exact body length the URL accepts (signed, so another length is refused). */
47
+ contentLength: Schema.optionalKey(Schema.Number),
48
+ /** PUT: the content type the URL accepts. */
49
+ contentType: Schema.optionalKey(Schema.String),
50
+ /** GET: the `Content-Type` the response carries, whatever the object was stored with. */
51
+ responseContentType: Schema.optionalKey(Schema.String),
52
+ /** GET: the `Content-Disposition` the response carries (`attachment; filename=...`). */
53
+ responseContentDisposition: Schema.optionalKey(Schema.String),
54
+ /** A multipart part: the URL uploads part `partNumber` of `uploadId` (method PUT). */
55
+ part: Schema.optionalKey(Schema.Struct({ uploadId: Schema.String, partNumber: Schema.Int })),
56
+ });
57
+ export const SignedUrl = Schema.Struct({
58
+ url: Schema.String,
59
+ method: Schema.Literals(["GET", "PUT"]),
60
+ /** Headers the client must send with the request, exactly. */
61
+ headers: Schema.Record(Schema.String, Schema.String),
62
+ /** ISO 8601, UTC. */
63
+ expiresAt: Schema.String,
64
+ });
65
+ /** The object (or multipart upload) does not exist. */
66
+ export class StorageNotFound extends Schema.TaggedError()("StorageNotFound", {
67
+ message: Schema.String,
68
+ key: Schema.String,
69
+ }) {
70
+ }
71
+ /** The request conflicts with the object's state: a part list that does not match what was uploaded, a range past the end. */
72
+ export class StorageConflict extends Schema.TaggedError()("StorageConflict", {
73
+ message: Schema.String,
74
+ key: Schema.String,
75
+ }) {
76
+ }
77
+ /** The request is malformed (a key outside `StorageKey`, a part number out of range) or the backend lacks the capability. */
78
+ export class StorageInvalid extends Schema.TaggedError()("StorageInvalid", {
79
+ message: Schema.String,
80
+ }) {
81
+ }
82
+ /** The backend cannot be reached or refused the deployment's credentials; retry later. */
83
+ export class StorageUnavailable extends Schema.TaggedError()("StorageUnavailable", {
84
+ message: Schema.String,
85
+ /** The backend's own status (an HTTP status for an object store), when it gave one. */
86
+ status: Schema.NullOr(Schema.Int),
87
+ }) {
88
+ }
89
+ export const StorageError = Schema.Union([StorageNotFound, StorageConflict, StorageInvalid, StorageUnavailable]);
90
+ const Base64 = Schema.String;
91
+ export const StorageBackendContract = defineServiceContract({
92
+ name: "StorageBackend",
93
+ kind: "capability",
94
+ version: "1.0.0",
95
+ description: "Blob storage for the Files contract: put, get (whole or a byte range), head, delete and list objects by opaque keys; signed URLs a client uses directly; and multipart uploads (parts uploaded independently and in any order, so an interrupted upload resumes). A backend authorises nothing: the kernel issues keys and signed URLs only after its own policy checks. Implementations: a local directory (development, tests) and any S3-compatible object store.",
96
+ operations: {
97
+ capabilities: defineOperation({
98
+ description: "What the backend supports beyond the core operations.",
99
+ input: Schema.Struct({}),
100
+ output: StorageCapabilities,
101
+ errors: Schema.Never,
102
+ }),
103
+ put: defineOperation({
104
+ description: "Store an object under `key`, replacing any object there, atomically: a reader sees the old content or the new, never part of either.",
105
+ input: Schema.Struct({ key: StorageKey, contentType: Schema.NullOr(Schema.String), bodyBase64: Base64 }),
106
+ output: StoredObject,
107
+ errors: StorageError,
108
+ }),
109
+ get: defineOperation({
110
+ description: "An object's content, or the inclusive byte `range` of it (capability `ranges`; a range starting past the end is StorageConflict, one ending past it is cut at the end).",
111
+ input: Schema.Struct({ key: StorageKey, range: Schema.optionalKey(ByteRange) }),
112
+ output: Schema.Struct({ object: StoredObject, bodyBase64: Base64 }),
113
+ errors: StorageError,
114
+ }),
115
+ head: defineOperation({
116
+ description: "An object's metadata, without its content.",
117
+ input: Schema.Struct({ key: StorageKey }),
118
+ output: StoredObject,
119
+ errors: StorageError,
120
+ }),
121
+ delete: defineOperation({
122
+ description: "Delete an object. Deleting one that does not exist succeeds (deletion is idempotent).",
123
+ input: Schema.Struct({ key: StorageKey }),
124
+ output: Schema.Void,
125
+ errors: StorageError,
126
+ }),
127
+ list: defineOperation({
128
+ description: "Objects whose key starts with `prefix`, in key order (byte order), one page at a time: `cursor` from the previous page's `nextCursor` (null when there are no more). Objects of unfinished multipart uploads are not listed.",
129
+ input: Schema.Struct({
130
+ prefix: Schema.String,
131
+ cursor: Schema.optionalKey(Schema.NullOr(Schema.String)),
132
+ limit: Schema.optionalKey(Schema.Int),
133
+ }),
134
+ output: Schema.Struct({ objects: Schema.Array(StoredObject), nextCursor: Schema.NullOr(Schema.String) }),
135
+ errors: StorageError,
136
+ }),
137
+ signedUrl: defineOperation({
138
+ description: "A URL a client uses directly (capability `signedUrls`): GET reads the object, PUT stores one (or a multipart part) of exactly `contentLength` bytes. It works until it expires and cannot be revoked before; the kernel keeps it short.",
139
+ input: SignedUrlRequest,
140
+ output: SignedUrl,
141
+ errors: StorageError,
142
+ }),
143
+ createMultipart: defineOperation({
144
+ description: "Start a multipart upload to `key` (capability `multipart`). Nothing is visible at `key` until it completes.",
145
+ input: Schema.Struct({ key: StorageKey, contentType: Schema.NullOr(Schema.String) }),
146
+ output: Schema.Struct({ uploadId: Schema.String }),
147
+ errors: StorageError,
148
+ }),
149
+ uploadPart: defineOperation({
150
+ description: "Upload part `partNumber` (1 to 10000) of a multipart upload. Uploading a part again replaces it; parts may arrive in any order. Every part but the last must hold at least the backend's minimum part size (5 MiB on S3).",
151
+ input: Schema.Struct({
152
+ key: StorageKey,
153
+ uploadId: Schema.String,
154
+ partNumber: Schema.Int,
155
+ bodyBase64: Base64,
156
+ }),
157
+ output: UploadedPart,
158
+ errors: StorageError,
159
+ }),
160
+ listParts: defineOperation({
161
+ description: "The parts of an unfinished multipart upload received so far, in part order: how a client resumes.",
162
+ input: Schema.Struct({ key: StorageKey, uploadId: Schema.String }),
163
+ output: Schema.Array(UploadedPart),
164
+ errors: StorageError,
165
+ }),
166
+ completeMultipart: defineOperation({
167
+ description: "Assemble the named parts, in part order, into the object at `key`, atomically. Each part's etag must be the one its upload returned (StorageConflict otherwise).",
168
+ input: Schema.Struct({
169
+ key: StorageKey,
170
+ uploadId: Schema.String,
171
+ parts: Schema.Array(Schema.Struct({ partNumber: Schema.Int, etag: Schema.String })),
172
+ }),
173
+ output: StoredObject,
174
+ errors: StorageError,
175
+ }),
176
+ abortMultipart: defineOperation({
177
+ description: "Abandon a multipart upload and free its parts. Aborting one that does not exist succeeds.",
178
+ input: Schema.Struct({ key: StorageKey, uploadId: Schema.String }),
179
+ output: Schema.Void,
180
+ errors: StorageError,
181
+ }),
182
+ },
183
+ types: {
184
+ StorageCapabilities,
185
+ StoredObject,
186
+ ByteRange,
187
+ UploadedPart,
188
+ SignedUrlRequest,
189
+ SignedUrl,
190
+ StorageNotFound,
191
+ StorageConflict,
192
+ StorageInvalid,
193
+ StorageUnavailable,
194
+ },
195
+ });
196
+ //# sourceMappingURL=StorageBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageBackend.js","sourceRoot":"","sources":["../../src/contracts/StorageBackend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gFAAgF,CAAA;AACnH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC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,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;aACpF,CAAC;YACF,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,YAAY;SACrB,CAAC;QACF,cAAc,EAAE,eAAe,CAAC;YAC9B,WAAW,EAAE,2FAA2F;YACxG,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;YAClE,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,MAAM,EAAE,YAAY;SACrB,CAAC;KACH;IACD,KAAK,EAAE;QACL,mBAAmB;QACnB,YAAY;QACZ,SAAS;QACT,YAAY;QACZ,gBAAgB;QAChB,SAAS;QACT,eAAe;QACf,eAAe;QACf,cAAc;QACd,kBAAkB;KACnB;CACF,CAAC,CAAA"}
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Sync (decisions 2 and 5): each client's policy-scoped partial replica.
3
+ * Documented in docs/contracts/sync.md; conformance kit
4
+ * `@eloxiv/testing/conformance/Sync`.
5
+ */
6
+ import { Schema } from "effect";
7
+ import { Unauthenticated } from "../Errors.ts";
8
+ /**
9
+ * The header zero-cache sends its API key in (its `ZERO_MUTATE_API_KEY`) with every push it forwards to the kernel:
10
+ * a push that carries the key came from zero-cache, for the client group of the connection it came over.
11
+ */
12
+ export declare const ZERO_API_KEY_HEADER = "x-api-key";
13
+ /**
14
+ * zero-cache's API key outside production when `ELOXIV_ZERO_API_KEY` is unset: the kernel and the launchers that start
15
+ * zero-cache (`eloxiv dev`, `eloxiv start`, the tests) use it alike. Production requires a key of its own.
16
+ */
17
+ export declare const DEV_ZERO_API_KEY = "eloxiv-dev-zero-api-key";
18
+ /** A client's request to resolve one named query (zero-cache forwards it to `POST /zero/query`). */
19
+ export declare const SyncQueryRequest: Schema.Struct<{
20
+ readonly name: Schema.String;
21
+ readonly args: Schema.$Array<Schema.Unknown>;
22
+ /** The client's headers: `authorization: Bearer <session token>`; `x-eloxiv-org` picks the organisation. */
23
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
24
+ }>;
25
+ export type SyncQueryRequest = typeof SyncQueryRequest.Type;
26
+ /** The module's query with the entities' compiled read filters added: what zero-cache runs for this client. */
27
+ export declare const ScopedQuery: Schema.Struct<{
28
+ readonly name: Schema.String;
29
+ /** The query's ZQL abstract syntax tree. */
30
+ readonly ast: Schema.Unknown;
31
+ }>;
32
+ export type ScopedQuery = typeof ScopedQuery.Type;
33
+ /** The kernel refused to serve a query (on the wire: Zero's `{ error: "app", message }`). */
34
+ export declare const QueryRefused: Schema.TaggedStruct<"QueryRefused", {
35
+ readonly name: Schema.String;
36
+ readonly message: Schema.String;
37
+ }>;
38
+ export type QueryRefused = typeof QueryRefused.Type;
39
+ /**
40
+ * One optimistic write a client pushed (Zero's custom mutation): the action it names (`name`, e.g. `hello.greet`),
41
+ * its encoded input (`args[0]`), and the client's own sequence number for it (`id`, per `clientID`).
42
+ */
43
+ export declare const SyncMutation: Schema.Struct<{
44
+ readonly type: Schema.Literal<"custom">;
45
+ readonly id: Schema.Int;
46
+ readonly clientID: Schema.String;
47
+ readonly name: Schema.String;
48
+ readonly args: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
49
+ readonly timestamp: Schema.Number;
50
+ }>;
51
+ export type SyncMutation = typeof SyncMutation.Type;
52
+ /**
53
+ * A push (zero-cache forwards it to `POST /zero/mutate?schema=<shard>&appID=<app>` with the client's
54
+ * `authorization` header and, when the client names them, `x-eloxiv-org` and `x-eloxiv-client-version`): one
55
+ * client group's mutations, in the order each client made them.
56
+ */
57
+ export declare const SyncPushRequest: Schema.Struct<{
58
+ /** zero-cache's shard schema (`<app id>_<shard>`), which records each client's last mutation and its results. */
59
+ readonly schema: Schema.String;
60
+ readonly appID: Schema.String;
61
+ readonly clientGroupID: Schema.String;
62
+ readonly mutations: Schema.$Array<Schema.Struct<{
63
+ readonly type: Schema.Literal<"custom">;
64
+ readonly id: Schema.Int;
65
+ readonly clientID: Schema.String;
66
+ readonly name: Schema.String;
67
+ readonly args: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
68
+ readonly timestamp: Schema.Number;
69
+ }>>;
70
+ readonly pushVersion: Schema.Literal<1>;
71
+ readonly timestamp: Schema.Number;
72
+ readonly requestID: Schema.String;
73
+ }>;
74
+ export type SyncPushRequest = typeof SyncPushRequest.Type;
75
+ /**
76
+ * What became of one mutation (Zero's mutation result): `{}` confirmed (the action ran, or a retry replayed its
77
+ * receipt; the replica holds the server's rows from now on); `{ error: "app", message, details }` refused, with the
78
+ * invocation's error, encoded, as `details` (`Forbidden`, `InvalidInput`, `ApprovalRequired` with its `approvalId`,
79
+ * `ConsentRequired` with its `consentId`, `ActionFailed`, ...); `{ error: "alreadyProcessed" }` a retry of a mutation
80
+ * the kernel answered before.
81
+ */
82
+ export declare const SyncMutationResult: Schema.Union<readonly [Schema.Struct<{}>, Schema.Struct<{
83
+ readonly error: Schema.Literal<"app">;
84
+ readonly message: Schema.String;
85
+ readonly details: Schema.Codec<Schema.Json, Schema.Json, never, never>;
86
+ }>, Schema.Struct<{
87
+ readonly error: Schema.Literal<"alreadyProcessed">;
88
+ readonly details: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
89
+ }>]>;
90
+ /** The kernel's answer to a push (Zero's `MutateResponse`, or its `PushFailed` for an out-of-order mutation). */
91
+ export declare const SyncPushResponse: Schema.Union<readonly [Schema.Struct<{
92
+ readonly kind: Schema.Literal<"MutateResponse">;
93
+ readonly userID: Schema.String;
94
+ readonly mutations: Schema.$Array<Schema.Struct<{
95
+ readonly id: Schema.Struct<{
96
+ readonly clientID: Schema.String;
97
+ readonly id: Schema.Int;
98
+ }>;
99
+ readonly result: Schema.Union<readonly [Schema.Struct<{}>, Schema.Struct<{
100
+ readonly error: Schema.Literal<"app">;
101
+ readonly message: Schema.String;
102
+ readonly details: Schema.Codec<Schema.Json, Schema.Json, never, never>;
103
+ }>, Schema.Struct<{
104
+ readonly error: Schema.Literal<"alreadyProcessed">;
105
+ readonly details: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
106
+ }>]>;
107
+ }>>;
108
+ }>, Schema.Struct<{
109
+ readonly kind: Schema.Literal<"PushFailed">;
110
+ readonly origin: Schema.Literal<"server">;
111
+ readonly reason: Schema.Literals<readonly ["oooMutation", "parse", "unsupportedPushVersion", "database", "internal"]>;
112
+ readonly message: Schema.String;
113
+ readonly mutationIDs: Schema.$Array<Schema.Struct<{
114
+ readonly clientID: Schema.String;
115
+ readonly id: Schema.Int;
116
+ }>>;
117
+ }>]>;
118
+ /**
119
+ * The push was refused as a whole (HTTP 403, so zero-cache closes the connection): a shard schema other than the
120
+ * one zero-cache keeps for this kernel's app, or a client another user's pushes already claimed.
121
+ */
122
+ export declare const PushRefused: Schema.TaggedStruct<"PushRefused", {
123
+ readonly message: Schema.String;
124
+ }>;
125
+ export type PushRefused = typeof PushRefused.Type;
126
+ /** Zero table names the kernel reserves for its live tables (directory facts, grants, link redemptions). */
127
+ export declare const ReservedSyncTables: Schema.Literals<readonly ["eloxivSyncOrg", "eloxivSyncFact", "eloxivShareGrant", "eloxivShareRedemption"]>;
128
+ export declare const SyncContract: import("../Service.ts").ServiceContract<"Sync", {
129
+ readonly query: {
130
+ description: string;
131
+ input: Schema.Struct<{
132
+ readonly name: Schema.String;
133
+ readonly args: Schema.$Array<Schema.Unknown>;
134
+ /** The client's headers: `authorization: Bearer <session token>`; `x-eloxiv-org` picks the organisation. */
135
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
136
+ }>;
137
+ output: Schema.Struct<{
138
+ readonly name: Schema.String;
139
+ /** The query's ZQL abstract syntax tree. */
140
+ readonly ast: Schema.Unknown;
141
+ }>;
142
+ errors: Schema.Union<readonly [typeof Unauthenticated, Schema.TaggedStruct<"QueryRefused", {
143
+ readonly name: Schema.String;
144
+ readonly message: Schema.String;
145
+ }>]>;
146
+ };
147
+ readonly mutate: {
148
+ description: string;
149
+ input: Schema.Struct<{
150
+ /** zero-cache's shard schema (`<app id>_<shard>`), which records each client's last mutation and its results. */
151
+ readonly schema: Schema.String;
152
+ readonly appID: Schema.String;
153
+ readonly clientGroupID: Schema.String;
154
+ readonly mutations: Schema.$Array<Schema.Struct<{
155
+ readonly type: Schema.Literal<"custom">;
156
+ readonly id: Schema.Int;
157
+ readonly clientID: Schema.String;
158
+ readonly name: Schema.String;
159
+ readonly args: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
160
+ readonly timestamp: Schema.Number;
161
+ }>>;
162
+ readonly pushVersion: Schema.Literal<1>;
163
+ readonly timestamp: Schema.Number;
164
+ readonly requestID: Schema.String;
165
+ }>;
166
+ output: Schema.Union<readonly [Schema.Struct<{
167
+ readonly kind: Schema.Literal<"MutateResponse">;
168
+ readonly userID: Schema.String;
169
+ readonly mutations: Schema.$Array<Schema.Struct<{
170
+ readonly id: Schema.Struct<{
171
+ readonly clientID: Schema.String;
172
+ readonly id: Schema.Int;
173
+ }>;
174
+ readonly result: Schema.Union<readonly [Schema.Struct<{}>, Schema.Struct<{
175
+ readonly error: Schema.Literal<"app">;
176
+ readonly message: Schema.String;
177
+ readonly details: Schema.Codec<Schema.Json, Schema.Json, never, never>;
178
+ }>, Schema.Struct<{
179
+ readonly error: Schema.Literal<"alreadyProcessed">;
180
+ readonly details: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
181
+ }>]>;
182
+ }>>;
183
+ }>, Schema.Struct<{
184
+ readonly kind: Schema.Literal<"PushFailed">;
185
+ readonly origin: Schema.Literal<"server">;
186
+ readonly reason: Schema.Literals<readonly ["oooMutation", "parse", "unsupportedPushVersion", "database", "internal"]>;
187
+ readonly message: Schema.String;
188
+ readonly mutationIDs: Schema.$Array<Schema.Struct<{
189
+ readonly clientID: Schema.String;
190
+ readonly id: Schema.Int;
191
+ }>>;
192
+ }>]>;
193
+ errors: Schema.Union<readonly [typeof Unauthenticated, Schema.TaggedStruct<"PushRefused", {
194
+ readonly message: Schema.String;
195
+ }>]>;
196
+ };
197
+ readonly checkSchema: {
198
+ description: string;
199
+ input: Schema.Struct<{
200
+ readonly schema: Schema.Unknown;
201
+ }>;
202
+ output: Schema.$Array<Schema.String>;
203
+ errors: Schema.Never;
204
+ };
205
+ }, {
206
+ readonly SyncQueryRequest: Schema.Struct<{
207
+ readonly name: Schema.String;
208
+ readonly args: Schema.$Array<Schema.Unknown>;
209
+ /** The client's headers: `authorization: Bearer <session token>`; `x-eloxiv-org` picks the organisation. */
210
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
211
+ }>;
212
+ readonly ScopedQuery: Schema.Struct<{
213
+ readonly name: Schema.String;
214
+ /** The query's ZQL abstract syntax tree. */
215
+ readonly ast: Schema.Unknown;
216
+ }>;
217
+ readonly QueryRefused: Schema.TaggedStruct<"QueryRefused", {
218
+ readonly name: Schema.String;
219
+ readonly message: Schema.String;
220
+ }>;
221
+ readonly ReservedSyncTables: Schema.Literals<readonly ["eloxivSyncOrg", "eloxivSyncFact", "eloxivShareGrant", "eloxivShareRedemption"]>;
222
+ readonly SyncMutation: Schema.Struct<{
223
+ readonly type: Schema.Literal<"custom">;
224
+ readonly id: Schema.Int;
225
+ readonly clientID: Schema.String;
226
+ readonly name: Schema.String;
227
+ readonly args: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
228
+ readonly timestamp: Schema.Number;
229
+ }>;
230
+ readonly SyncPushRequest: Schema.Struct<{
231
+ /** zero-cache's shard schema (`<app id>_<shard>`), which records each client's last mutation and its results. */
232
+ readonly schema: Schema.String;
233
+ readonly appID: Schema.String;
234
+ readonly clientGroupID: Schema.String;
235
+ readonly mutations: Schema.$Array<Schema.Struct<{
236
+ readonly type: Schema.Literal<"custom">;
237
+ readonly id: Schema.Int;
238
+ readonly clientID: Schema.String;
239
+ readonly name: Schema.String;
240
+ readonly args: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
241
+ readonly timestamp: Schema.Number;
242
+ }>>;
243
+ readonly pushVersion: Schema.Literal<1>;
244
+ readonly timestamp: Schema.Number;
245
+ readonly requestID: Schema.String;
246
+ }>;
247
+ readonly SyncMutationResult: Schema.Union<readonly [Schema.Struct<{}>, Schema.Struct<{
248
+ readonly error: Schema.Literal<"app">;
249
+ readonly message: Schema.String;
250
+ readonly details: Schema.Codec<Schema.Json, Schema.Json, never, never>;
251
+ }>, Schema.Struct<{
252
+ readonly error: Schema.Literal<"alreadyProcessed">;
253
+ readonly details: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
254
+ }>]>;
255
+ readonly SyncPushResponse: Schema.Union<readonly [Schema.Struct<{
256
+ readonly kind: Schema.Literal<"MutateResponse">;
257
+ readonly userID: Schema.String;
258
+ readonly mutations: Schema.$Array<Schema.Struct<{
259
+ readonly id: Schema.Struct<{
260
+ readonly clientID: Schema.String;
261
+ readonly id: Schema.Int;
262
+ }>;
263
+ readonly result: Schema.Union<readonly [Schema.Struct<{}>, Schema.Struct<{
264
+ readonly error: Schema.Literal<"app">;
265
+ readonly message: Schema.String;
266
+ readonly details: Schema.Codec<Schema.Json, Schema.Json, never, never>;
267
+ }>, Schema.Struct<{
268
+ readonly error: Schema.Literal<"alreadyProcessed">;
269
+ readonly details: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
270
+ }>]>;
271
+ }>>;
272
+ }>, Schema.Struct<{
273
+ readonly kind: Schema.Literal<"PushFailed">;
274
+ readonly origin: Schema.Literal<"server">;
275
+ readonly reason: Schema.Literals<readonly ["oooMutation", "parse", "unsupportedPushVersion", "database", "internal"]>;
276
+ readonly message: Schema.String;
277
+ readonly mutationIDs: Schema.$Array<Schema.Struct<{
278
+ readonly clientID: Schema.String;
279
+ readonly id: Schema.Int;
280
+ }>>;
281
+ }>]>;
282
+ readonly PushRefused: Schema.TaggedStruct<"PushRefused", {
283
+ readonly message: Schema.String;
284
+ }>;
285
+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AAO,WAAW,CAAC,IAAI,CAAA;AAEjD,4GAA4G;AAC5G,eAAO,MAAM,kBAAkB,4GAK7B,CAAA;AAEF,eAAO,MAAM,YAAY;;QAanB,WAAW;QAKX,KAAK;;;YAnHT,4GAA4G;;;QAoHxG,MAAM;;YA5GV,4CAA4C;;;QA6GxC,MAAM;;;;;;QAGN,WAAW;QAOX,KAAK;YA1FT,iHAAiH;;;;;;;;;;;;;;;;QA2F7G,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;QACN,MAAM;;;;;QAGN,WAAW;QAMX,KAAK;;;QACL,MAAM;QACN,MAAM;;;;;;QA5IV,4GAA4G;;;;;QAQ5G,4CAA4C;;;;;;;;;;;;;;;;;QA6B5C,iHAAiH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqHjH,CAAA"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Sync (decisions 2 and 5): each client's policy-scoped partial replica.
3
+ * Documented in docs/contracts/sync.md; conformance kit
4
+ * `@eloxiv/testing/conformance/Sync`.
5
+ */
6
+ import { Schema } from "effect";
7
+ import { Unauthenticated } from "../Errors.js";
8
+ import { defineServiceContract } from "../Service.js";
9
+ /**
10
+ * The header zero-cache sends its API key in (its `ZERO_MUTATE_API_KEY`) with every push it forwards to the kernel:
11
+ * a push that carries the key came from zero-cache, for the client group of the connection it came over.
12
+ */
13
+ export const ZERO_API_KEY_HEADER = "x-api-key";
14
+ /**
15
+ * zero-cache's API key outside production when `ELOXIV_ZERO_API_KEY` is unset: the kernel and the launchers that start
16
+ * zero-cache (`eloxiv dev`, `eloxiv start`, the tests) use it alike. Production requires a key of its own.
17
+ */
18
+ export const DEV_ZERO_API_KEY = "eloxiv-dev-zero-api-key";
19
+ /** A client's request to resolve one named query (zero-cache forwards it to `POST /zero/query`). */
20
+ export const SyncQueryRequest = Schema.Struct({
21
+ name: Schema.String,
22
+ args: Schema.Array(Schema.Unknown),
23
+ /** The client's headers: `authorization: Bearer <session token>`; `x-eloxiv-org` picks the organisation. */
24
+ headers: Schema.Record(Schema.String, Schema.String),
25
+ });
26
+ /** The module's query with the entities' compiled read filters added: what zero-cache runs for this client. */
27
+ export const ScopedQuery = Schema.Struct({
28
+ name: Schema.String,
29
+ /** The query's ZQL abstract syntax tree. */
30
+ ast: Schema.Unknown,
31
+ });
32
+ /** The kernel refused to serve a query (on the wire: Zero's `{ error: "app", message }`). */
33
+ export const QueryRefused = Schema.TaggedStruct("QueryRefused", { name: Schema.String, message: Schema.String });
34
+ /**
35
+ * One optimistic write a client pushed (Zero's custom mutation): the action it names (`name`, e.g. `hello.greet`),
36
+ * its encoded input (`args[0]`), and the client's own sequence number for it (`id`, per `clientID`).
37
+ */
38
+ export const SyncMutation = Schema.Struct({
39
+ type: Schema.Literal("custom"),
40
+ id: Schema.Int,
41
+ clientID: Schema.String,
42
+ name: Schema.String,
43
+ args: Schema.Array(Schema.Json),
44
+ timestamp: Schema.Number,
45
+ });
46
+ /**
47
+ * A push (zero-cache forwards it to `POST /zero/mutate?schema=<shard>&appID=<app>` with the client's
48
+ * `authorization` header and, when the client names them, `x-eloxiv-org` and `x-eloxiv-client-version`): one
49
+ * client group's mutations, in the order each client made them.
50
+ */
51
+ export const SyncPushRequest = Schema.Struct({
52
+ /** zero-cache's shard schema (`<app id>_<shard>`), which records each client's last mutation and its results. */
53
+ schema: Schema.String,
54
+ appID: Schema.String,
55
+ clientGroupID: Schema.String,
56
+ mutations: Schema.Array(SyncMutation),
57
+ pushVersion: Schema.Literal(1),
58
+ timestamp: Schema.Number,
59
+ requestID: Schema.String,
60
+ });
61
+ /**
62
+ * What became of one mutation (Zero's mutation result): `{}` confirmed (the action ran, or a retry replayed its
63
+ * receipt; the replica holds the server's rows from now on); `{ error: "app", message, details }` refused, with the
64
+ * invocation's error, encoded, as `details` (`Forbidden`, `InvalidInput`, `ApprovalRequired` with its `approvalId`,
65
+ * `ConsentRequired` with its `consentId`, `ActionFailed`, ...); `{ error: "alreadyProcessed" }` a retry of a mutation
66
+ * the kernel answered before.
67
+ */
68
+ export const SyncMutationResult = Schema.Union([
69
+ Schema.Struct({}),
70
+ Schema.Struct({ error: Schema.Literal("app"), message: Schema.String, details: Schema.Json }),
71
+ Schema.Struct({ error: Schema.Literal("alreadyProcessed"), details: Schema.optionalKey(Schema.Json) }),
72
+ ]);
73
+ /** The kernel's answer to a push (Zero's `MutateResponse`, or its `PushFailed` for an out-of-order mutation). */
74
+ export const SyncPushResponse = Schema.Union([
75
+ Schema.Struct({
76
+ kind: Schema.Literal("MutateResponse"),
77
+ userID: Schema.String,
78
+ mutations: Schema.Array(Schema.Struct({
79
+ id: Schema.Struct({ clientID: Schema.String, id: Schema.Int }),
80
+ result: SyncMutationResult,
81
+ })),
82
+ }),
83
+ Schema.Struct({
84
+ kind: Schema.Literal("PushFailed"),
85
+ origin: Schema.Literal("server"),
86
+ reason: Schema.Literals(["oooMutation", "parse", "unsupportedPushVersion", "database", "internal"]),
87
+ message: Schema.String,
88
+ mutationIDs: Schema.Array(Schema.Struct({ clientID: Schema.String, id: Schema.Int })),
89
+ }),
90
+ ]);
91
+ /**
92
+ * The push was refused as a whole (HTTP 403, so zero-cache closes the connection): a shard schema other than the
93
+ * one zero-cache keeps for this kernel's app, or a client another user's pushes already claimed.
94
+ */
95
+ export const PushRefused = Schema.TaggedStruct("PushRefused", { message: Schema.String });
96
+ /** Zero table names the kernel reserves for its live tables (directory facts, grants, link redemptions). */
97
+ export const ReservedSyncTables = Schema.Literals([
98
+ "eloxivSyncOrg",
99
+ "eloxivSyncFact",
100
+ "eloxivShareGrant",
101
+ "eloxivShareRedemption",
102
+ ]);
103
+ export const SyncContract = defineServiceContract({
104
+ name: "Sync",
105
+ kind: "kernel",
106
+ version: "3.2.0",
107
+ description: "Policy-scoped partial replication. Clients keep a local replica per user and organisation; the kernel " +
108
+ "resolves each named query for the authenticated actor by adding the read policy of the entity whose table it reads, compiled from " +
109
+ "Cedar into ZQL (the same policy that authorises actions), and each related table's own entity's read " +
110
+ "policy to its rows; refuses queries it cannot authorise; and refuses to start with a sync schema whose " +
111
+ "columns do not match the entity contracts. Writes go through actions: a replica's optimistic writes are pushed " +
112
+ "to the kernel and run through the invocation path as the action they name, and the replica keeps the result.",
113
+ operations: {
114
+ query: {
115
+ description: "Resolve a named query for the caller: run the module's query, infer its entity from the table it reads " +
116
+ "(through the sync schema; a table no entity governs is refused), add that entity's compiled read filter for the caller's user and organisation, and add " +
117
+ "each related table's (`related()`, `whereExists()`) own entity's read filter to that subquery. A query " +
118
+ "reaching a table no entity governs is refused.",
119
+ input: SyncQueryRequest,
120
+ output: ScopedQuery,
121
+ errors: Schema.Union([Unauthenticated, QueryRefused]),
122
+ },
123
+ mutate: {
124
+ description: "Run a client's pushed optimistic writes, in order, each as the action it names (only actions that declare " +
125
+ "an optimistic effect, declarative or the module's own custom prediction, which never runs here), through the one invocation path as the signed-in person (surface `sync`): identity, " +
126
+ "policy, consent or approval, idempotency (keyed by the client and its mutation id, so a retried push replays " +
127
+ "the receipt), execute, audit and outbox. The client's last mutation id advances in the action's own " +
128
+ "transaction, so the replica receives the server's rows and the confirmation together; a refused mutation " +
129
+ "advances it with the error recorded, so the replica drops the prediction and its caller gets the error.",
130
+ input: SyncPushRequest,
131
+ output: SyncPushResponse,
132
+ errors: Schema.Union([Unauthenticated, PushRefused]),
133
+ },
134
+ checkSchema: {
135
+ description: "Check an app's sync schema (generated from the entities) against the entity contracts before serving it: " +
136
+ "every table over an entity is exactly what the generator writes for it (the entity syncs; each column is a " +
137
+ "synced field reading the field's column, with its type and nullability; every synced field, the primary " +
138
+ "key and an organisation column are there), and no table takes a name the kernel reserves. Returns the problems found; the kernel does not start " +
139
+ "while there are any.",
140
+ input: Schema.Struct({ schema: Schema.Unknown }),
141
+ output: Schema.Array(Schema.String),
142
+ errors: Schema.Never,
143
+ },
144
+ },
145
+ types: {
146
+ SyncQueryRequest,
147
+ ScopedQuery,
148
+ QueryRefused,
149
+ ReservedSyncTables,
150
+ SyncMutation,
151
+ SyncPushRequest,
152
+ SyncMutationResult,
153
+ SyncPushResponse,
154
+ PushRefused,
155
+ },
156
+ });
157
+ //# sourceMappingURL=Sync.js.map