@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,136 @@
1
+ /**
2
+ * Secrets: scoped secret custody, encrypted at rest with envelope encryption. See docs/contracts/secrets.md.
3
+ */
4
+ import { Schema } from "effect";
5
+ import { Forbidden, InvalidInput, Unauthenticated } from "../Errors.js";
6
+ import { defineOperation, defineServiceContract } from "../Service.js";
7
+ /** Who a secret belongs to: an organisation, a person in it, or a Connection (its tokens). */
8
+ export const SecretScope = Schema.Union([
9
+ Schema.Struct({ kind: Schema.Literal("org"), orgId: Schema.String }),
10
+ Schema.Struct({ kind: Schema.Literal("user"), orgId: Schema.String, userId: Schema.String }),
11
+ Schema.Struct({ kind: Schema.Literal("connection"), orgId: Schema.String, connectionId: Schema.String }),
12
+ ]);
13
+ /** What can be known about a secret without reading it. Never its value. */
14
+ export const SecretMetadata = Schema.Struct({
15
+ scope: SecretScope,
16
+ name: Schema.String,
17
+ /** The key-encryption key its data key is wrapped with. */
18
+ keyId: Schema.String,
19
+ /** Incremented on every write and every rotation. */
20
+ version: Schema.Int,
21
+ /** The only origins the kernel sends it to (null: wherever what uses it sends it). */
22
+ allowedOrigins: Schema.NullOr(Schema.Array(Schema.String)),
23
+ /** The feature that manages it (null: the person or administrator who put it); management cannot delete it. */
24
+ managedBy: Schema.NullOr(Schema.String),
25
+ /** Its last four characters after an ellipsis (`…f00d`), for a value of at least 16; null otherwise. */
26
+ hint: Schema.NullOr(Schema.String),
27
+ createdAt: Schema.String,
28
+ updatedAt: Schema.String,
29
+ });
30
+ /** What uses a secret: a Connection that sends it, or a requirement the app declares for a feature. */
31
+ export const SecretUsage = Schema.Union([
32
+ Schema.Struct({
33
+ kind: Schema.Literal("connection"),
34
+ connectionId: Schema.String,
35
+ provider: Schema.String,
36
+ label: Schema.String,
37
+ /** `credential` (sent to its endpoint) or `client-secret` (its OAuth client's). */
38
+ as: Schema.Literals(["credential", "client-secret"]),
39
+ }),
40
+ Schema.Struct({ kind: Schema.Literal("requirement"), feature: Schema.String, description: Schema.String }),
41
+ ]);
42
+ /** A secret an app needs (`KernelApp.secrets`): put by an administrator (`org`) or each person (`user`). */
43
+ export const SecretRequirement = Schema.Struct({
44
+ scope: Schema.Literals(["org", "user"]),
45
+ name: Schema.String,
46
+ feature: Schema.String,
47
+ description: Schema.String,
48
+ });
49
+ export const SecretInventoryEntry = Schema.Struct({
50
+ scope: Schema.Literals(["org", "user"]),
51
+ name: Schema.String,
52
+ /** Null when it is required but not put yet. */
53
+ metadata: Schema.NullOr(SecretMetadata),
54
+ usages: Schema.Array(SecretUsage),
55
+ });
56
+ export class SecretNotFound extends Schema.TaggedError()("SecretNotFound", { message: Schema.String }, { httpApiStatus: 404 }) {
57
+ }
58
+ /** The stored ciphertext could not be decrypted (an unknown or retired key, or tampered data). */
59
+ export class SecretUnreadable extends Schema.TaggedError()("SecretUnreadable", { message: Schema.String }, { httpApiStatus: 500 }) {
60
+ }
61
+ const SecretName = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]{0,99}$/u));
62
+ const ManagedScope = Schema.Union([
63
+ Schema.Struct({ kind: Schema.Literal("org"), orgId: Schema.String }),
64
+ Schema.Struct({ kind: Schema.Literal("user"), orgId: Schema.String, userId: Schema.String }),
65
+ ]);
66
+ const ManageError = Schema.Union([Unauthenticated, Forbidden, InvalidInput]);
67
+ export const SecretsContract = defineServiceContract({
68
+ name: "Secrets",
69
+ kind: "kernel",
70
+ version: "1.1.0",
71
+ description: "Scoped secrets (organisation, user, connection), encrypted at rest with envelope encryption: each value under its own data key (AES-256-GCM, bound to its scope and name), the data key wrapped by a key-encryption key from a pluggable KeyEncryption (the deployment key from configuration by default; a KMS can replace it). Rotation re-encrypts every secret under the current key. Access goes only through the kernel: every read and write is audited by name and scope, never by value, and module roles cannot reach the storage.",
72
+ operations: {
73
+ put: defineOperation({
74
+ description: "Store (or replace) a secret. In process for the kernel; over HTTP (POST /kernel/secrets/put) a signed-in person stores secrets of their own (`user`) or, with eloxiv.secrets.manage, of their organisation (`org`).",
75
+ input: Schema.Struct({
76
+ scope: SecretScope,
77
+ name: SecretName,
78
+ value: Schema.String,
79
+ /** Origins (`https://api.example.com`) it may be sent to; the kernel refuses to send it anywhere else. */
80
+ allowedOrigins: Schema.optionalKey(Schema.Array(Schema.String)),
81
+ }),
82
+ output: SecretMetadata,
83
+ errors: Schema.Union([ManageError, SecretUnreadable]),
84
+ }),
85
+ read: defineOperation({
86
+ description: "A secret's value: in process only (the kernel and its Connections), audited as eloxiv.secrets.read. Never over a surface.",
87
+ input: Schema.Struct({ scope: SecretScope, name: SecretName, purpose: Schema.String }),
88
+ output: Schema.Struct({ value: Schema.String, metadata: SecretMetadata }),
89
+ errors: Schema.Union([SecretNotFound, SecretUnreadable]),
90
+ }),
91
+ delete: defineOperation({
92
+ description: "Delete a secret (or every secret of a scope). Audited. Over HTTP a secret a feature manages (`managedBy`) is refused: it is removed where it is managed.",
93
+ input: Schema.Struct({ scope: SecretScope, name: Schema.optionalKey(SecretName) }),
94
+ output: Schema.Struct({ deleted: Schema.Int }),
95
+ errors: ManageError,
96
+ }),
97
+ list: defineOperation({
98
+ description: "The secrets of a scope, as metadata (never values).",
99
+ input: Schema.Struct({ scope: SecretScope }),
100
+ output: Schema.Array(SecretMetadata),
101
+ errors: ManageError,
102
+ }),
103
+ inventory: defineOperation({
104
+ description: "POST /kernel/secrets/inventory, for a signed-in person: their own secrets and, with eloxiv.secrets.manage, the organisation's, each with what uses it (the Connections that send it, the app's requirements), and the required secrets not put yet (metadata null). Never values.",
105
+ input: Schema.Struct({}),
106
+ output: Schema.Struct({ secrets: Schema.Array(SecretInventoryEntry) }),
107
+ errors: ManageError,
108
+ }),
109
+ previewRemoval: defineOperation({
110
+ description: "POST /kernel/secrets/preview-removal: what deleting one secret would break (its usages), and whether management may delete it (`managedBy` null), before anything is deleted.",
111
+ input: Schema.Struct({ scope: ManagedScope, name: SecretName }),
112
+ output: Schema.Struct({
113
+ metadata: Schema.NullOr(SecretMetadata),
114
+ usages: Schema.Array(SecretUsage),
115
+ deletable: Schema.Boolean,
116
+ }),
117
+ errors: ManageError,
118
+ }),
119
+ rotate: defineOperation({
120
+ description: "Re-encrypt every secret not yet under the current key-encryption key (a new data key and new ciphertext each), so a retired key can be removed. A secret that does not decrypt (its key is not configured, or it was tampered with) is left as it is and counted in `unreadable`. Audited once with the counts.",
121
+ input: Schema.Struct({}),
122
+ output: Schema.Struct({ rotated: Schema.Int, unreadable: Schema.Int, keyId: Schema.String }),
123
+ errors: SecretUnreadable,
124
+ }),
125
+ },
126
+ types: {
127
+ SecretScope,
128
+ SecretMetadata,
129
+ SecretUsage,
130
+ SecretRequirement,
131
+ SecretInventoryEntry,
132
+ SecretNotFound,
133
+ SecretUnreadable,
134
+ },
135
+ });
136
+ //# sourceMappingURL=Secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Secrets.js","sourceRoot":"","sources":["../../src/contracts/Secrets.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAEtE,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;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AE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;YAC/D,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;gBACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;gBACvC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;gBACjC,SAAS,EAAE,MAAM,CAAC,OAAO;aAC1B,CAAC;YACF,MAAM,EAAE,WAAW;SACpB,CAAC;QACF,MAAM,EAAE,eAAe,CAAC;YACtB,WAAW,EACT,iTAAiT;YACnT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;YAC5F,MAAM,EAAE,gBAAgB;SACzB,CAAC;KACH;IACD,KAAK,EAAE;QACL,WAAW;QACX,cAAc;QACd,WAAW;QACX,iBAAiB;QACjB,oBAAoB;QACpB,cAAc;QACd,gBAAgB;KACjB;CACF,CAAC,CAAA"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Settings: scoped values declared in module manifests (`settings`), each with a value schema and a default,
3
+ * read by key only. Documented in docs/contracts/settings.md; conformance kit
4
+ * `@eloxiv/testing/conformance/Settings`.
5
+ *
6
+ * A value can be set at four levels, narrowest first: a person's own (`user`, in the organisation they act
7
+ * in), the organisation's (`org`), the deployment's (`app`, configuration) and the module installation's
8
+ * (`module`, configuration). A setting's declared scope is the narrowest level it accepts; a read takes the
9
+ * first level from there that holds a value, then the declared default (`resolveSetting`).
10
+ */
11
+ import { Schema } from "effect";
12
+ import { Forbidden, InvalidInput, Unauthenticated } from "../Errors.ts";
13
+ import { SettingScope } from "../Manifest.ts";
14
+ /** The permission organisation administrators need to set or clear organisation-level values. */
15
+ export declare const SETTINGS_MANAGE = "eloxiv.settings.manage";
16
+ /** Where a value lives, narrowest first. */
17
+ export declare const SETTING_LEVELS: readonly ["user", "org", "app", "module"];
18
+ export type SettingLevel = (typeof SETTING_LEVELS)[number];
19
+ export declare const SettingLevel: Schema.Literals<readonly ["user", "org", "app", "module"]>;
20
+ /** Levels a person or an organisation administrator writes through actions; `app` and `module` are configuration. */
21
+ export declare const WritableLevel: Schema.Literals<readonly ["user", "org"]>;
22
+ export type WritableLevel = typeof WritableLevel.Type;
23
+ /** The levels a setting of `scope` resolves through, in order. */
24
+ export declare const settingLevels: (scope: SettingScope) => ReadonlyArray<SettingLevel>;
25
+ export interface ResolvedSetting {
26
+ /** The encoded (JSON) value. */
27
+ readonly value: unknown;
28
+ /** The level it came from, or `default`. */
29
+ readonly source: SettingLevel | "default";
30
+ }
31
+ /**
32
+ * Resolve a setting by its declared scope order: the first of its levels (`settingLevels`) that holds a value
33
+ * in `values`, else the declared default. Clients resolve with the same function over their replica.
34
+ */
35
+ export declare const resolveSetting: (declaration: {
36
+ readonly scope: SettingScope;
37
+ readonly default: unknown;
38
+ }, values: Partial<Readonly<Record<SettingLevel, unknown>>>) => ResolvedSetting;
39
+ /** The id of a stored value: one per level, organisation, person and key. */
40
+ export declare const settingValueId: (level: WritableLevel, orgId: string, userId: string | null, key: string) => string;
41
+ /** A stored user- or organisation-level value, as the replica holds it (table `eloxiv_settings.value`). */
42
+ export declare const SettingValue: Schema.Struct<{
43
+ readonly id: Schema.String;
44
+ readonly key: Schema.String;
45
+ readonly level: Schema.Literals<readonly ["user", "org"]>;
46
+ readonly orgId: Schema.String;
47
+ /** The person, for a user-level value; `null` for an organisation-level one. */
48
+ readonly userId: Schema.NullOr<Schema.String>;
49
+ readonly value: Schema.Unknown;
50
+ readonly updatedBy: Schema.String;
51
+ readonly updatedAt: Schema.Number;
52
+ }>;
53
+ export type SettingValue = typeof SettingValue.Type;
54
+ export declare const SettingKey: Schema.Struct<{
55
+ readonly key: Schema.String;
56
+ }>;
57
+ export declare const SettingRead: Schema.Struct<{
58
+ readonly key: Schema.String;
59
+ /** The encoded (JSON) value. */
60
+ readonly value: Schema.Unknown;
61
+ readonly source: Schema.Literals<readonly ["user", "org", "app", "module", "default"]>;
62
+ }>;
63
+ export type SettingRead = typeof SettingRead.Type;
64
+ export declare const SettingWrite: Schema.Struct<{
65
+ readonly key: Schema.String;
66
+ /** `user` (your own value) or `org` (the organisation's, administrators only). Default: the setting's scope. */
67
+ readonly level: Schema.optionalKey<Schema.Literals<readonly ["user", "org"]>>;
68
+ /** The encoded (JSON) value; it must decode against the setting's schema. */
69
+ readonly value: Schema.Unknown;
70
+ }>;
71
+ export type SettingWrite = typeof SettingWrite.Type;
72
+ export declare const SettingClear: Schema.Struct<{
73
+ readonly key: Schema.String;
74
+ readonly level: Schema.optionalKey<Schema.Literals<readonly ["user", "org"]>>;
75
+ }>;
76
+ export type SettingClear = typeof SettingClear.Type;
77
+ export declare const SettingChanged: Schema.Struct<{
78
+ readonly id: Schema.String;
79
+ readonly key: Schema.String;
80
+ readonly level: Schema.Literals<readonly ["user", "org"]>;
81
+ }>;
82
+ /** A deployment value (`app` or `module` level), set by configuration or a deployment administrator. */
83
+ export declare const SettingConfigure: Schema.Struct<{
84
+ readonly key: Schema.String;
85
+ readonly level: Schema.Literals<readonly ["app", "module"]>;
86
+ /** The encoded value, or `null` to remove it. */
87
+ readonly value: Schema.Unknown;
88
+ }>;
89
+ export type SettingConfigure = typeof SettingConfigure.Type;
90
+ /** What the audit record of a settings write holds as `detail`. */
91
+ export declare const SettingAuditDetail: Schema.Struct<{
92
+ readonly key: Schema.String;
93
+ readonly level: Schema.Literals<readonly ["user", "org", "app", "module"]>;
94
+ readonly subject: Schema.NullOr<Schema.String>;
95
+ readonly before: Schema.Unknown;
96
+ readonly after: Schema.Unknown;
97
+ }>;
98
+ /** The kernel actions (module `settings`). */
99
+ export declare const SETTINGS_ACTIONS: {
100
+ readonly get: "settings.get";
101
+ readonly set: "settings.set";
102
+ readonly clear: "settings.clear";
103
+ };
104
+ /**
105
+ * Each person's preferences, declared by the kernel's `settings` module (user scope: a person's own value, else
106
+ * their organisation's, else the default), synced to their replica like any setting: their language, their time
107
+ * zone (a cron schedule they create with `timeZone: "local"` runs in it), and their light, dark or system theme.
108
+ */
109
+ export declare const PREFERENCE_SETTINGS: {
110
+ readonly locale: "settings.locale";
111
+ readonly timeZone: "settings.timeZone";
112
+ readonly theme: "settings.theme";
113
+ };
114
+ /** A BCP 47 language tag (`en`, `ar`, `pt-BR`), or null for the browser's. */
115
+ export declare const PreferredLocale: Schema.NullOr<Schema.String>;
116
+ /** An IANA time zone (`Europe/London`, `UTC`), or null for the device's. */
117
+ export declare const PreferredTimeZone: Schema.NullOr<Schema.String>;
118
+ export declare const PreferredTheme: Schema.Literals<readonly ["system", "light", "dark"]>;
119
+ /** The declarations (`settings` in the settings module's manifest). */
120
+ export declare const PREFERENCE_DECLARATIONS: {
121
+ readonly "settings.locale": {
122
+ readonly description: "Your language for the app (a BCP 47 tag), or null for your browser's.";
123
+ readonly scope: "user";
124
+ readonly schema: Schema.NullOr<Schema.String>;
125
+ readonly default: null;
126
+ };
127
+ readonly "settings.timeZone": {
128
+ readonly description: "Your time zone (IANA), or null for your device's. Schedules you create in local time use it.";
129
+ readonly scope: "user";
130
+ readonly schema: Schema.NullOr<Schema.String>;
131
+ readonly default: null;
132
+ };
133
+ readonly "settings.theme": {
134
+ readonly description: "Light, dark, or following your system.";
135
+ readonly scope: "user";
136
+ readonly schema: Schema.Literals<readonly ["system", "light", "dark"]>;
137
+ readonly default: "system";
138
+ };
139
+ };
140
+ export declare const SettingsContract: import("../Service.ts").ServiceContract<"Settings", {
141
+ readonly get: import("../Service.ts").OperationContract<Schema.Struct<{
142
+ readonly key: Schema.String;
143
+ }>, Schema.Struct<{
144
+ readonly key: Schema.String;
145
+ /** The encoded (JSON) value. */
146
+ readonly value: Schema.Unknown;
147
+ readonly source: Schema.Literals<readonly ["user", "org", "app", "module", "default"]>;
148
+ }>, Schema.Union<readonly [typeof Unauthenticated, typeof Forbidden, typeof InvalidInput]>>;
149
+ readonly set: import("../Service.ts").OperationContract<Schema.Struct<{
150
+ readonly key: Schema.String;
151
+ /** `user` (your own value) or `org` (the organisation's, administrators only). Default: the setting's scope. */
152
+ readonly level: Schema.optionalKey<Schema.Literals<readonly ["user", "org"]>>;
153
+ /** The encoded (JSON) value; it must decode against the setting's schema. */
154
+ readonly value: Schema.Unknown;
155
+ }>, Schema.Struct<{
156
+ readonly id: Schema.String;
157
+ readonly key: Schema.String;
158
+ readonly level: Schema.Literals<readonly ["user", "org"]>;
159
+ }>, Schema.Union<readonly [typeof Unauthenticated, typeof Forbidden, typeof InvalidInput]>>;
160
+ readonly clear: import("../Service.ts").OperationContract<Schema.Struct<{
161
+ readonly key: Schema.String;
162
+ readonly level: Schema.optionalKey<Schema.Literals<readonly ["user", "org"]>>;
163
+ }>, Schema.Struct<{
164
+ readonly id: Schema.String;
165
+ readonly key: Schema.String;
166
+ readonly level: Schema.Literals<readonly ["user", "org"]>;
167
+ }>, Schema.Union<readonly [typeof Unauthenticated, typeof Forbidden, typeof InvalidInput]>>;
168
+ readonly configure: import("../Service.ts").OperationContract<Schema.Struct<{
169
+ readonly key: Schema.String;
170
+ readonly level: Schema.Literals<readonly ["app", "module"]>;
171
+ /** The encoded value, or `null` to remove it. */
172
+ readonly value: Schema.Unknown;
173
+ }>, Schema.Struct<{
174
+ readonly key: Schema.String;
175
+ readonly level: Schema.Literals<readonly ["app", "module"]>;
176
+ }>, typeof InvalidInput>;
177
+ }, {
178
+ readonly SettingValue: Schema.Struct<{
179
+ readonly id: Schema.String;
180
+ readonly key: Schema.String;
181
+ readonly level: Schema.Literals<readonly ["user", "org"]>;
182
+ readonly orgId: Schema.String;
183
+ /** The person, for a user-level value; `null` for an organisation-level one. */
184
+ readonly userId: Schema.NullOr<Schema.String>;
185
+ readonly value: Schema.Unknown;
186
+ readonly updatedBy: Schema.String;
187
+ readonly updatedAt: Schema.Number;
188
+ }>;
189
+ readonly SettingRead: Schema.Struct<{
190
+ readonly key: Schema.String;
191
+ /** The encoded (JSON) value. */
192
+ readonly value: Schema.Unknown;
193
+ readonly source: Schema.Literals<readonly ["user", "org", "app", "module", "default"]>;
194
+ }>;
195
+ readonly SettingWrite: Schema.Struct<{
196
+ readonly key: Schema.String;
197
+ /** `user` (your own value) or `org` (the organisation's, administrators only). Default: the setting's scope. */
198
+ readonly level: Schema.optionalKey<Schema.Literals<readonly ["user", "org"]>>;
199
+ /** The encoded (JSON) value; it must decode against the setting's schema. */
200
+ readonly value: Schema.Unknown;
201
+ }>;
202
+ readonly SettingClear: Schema.Struct<{
203
+ readonly key: Schema.String;
204
+ readonly level: Schema.optionalKey<Schema.Literals<readonly ["user", "org"]>>;
205
+ }>;
206
+ readonly SettingConfigure: Schema.Struct<{
207
+ readonly key: Schema.String;
208
+ readonly level: Schema.Literals<readonly ["app", "module"]>;
209
+ /** The encoded value, or `null` to remove it. */
210
+ readonly value: Schema.Unknown;
211
+ }>;
212
+ readonly SettingLevel: Schema.Literals<readonly ["user", "org", "app", "module"]>;
213
+ readonly SettingAuditDetail: Schema.Struct<{
214
+ readonly key: Schema.String;
215
+ readonly level: Schema.Literals<readonly ["user", "org", "app", "module"]>;
216
+ readonly subject: Schema.NullOr<Schema.String>;
217
+ readonly before: Schema.Unknown;
218
+ readonly after: Schema.Unknown;
219
+ }>;
220
+ }>;
221
+ //# sourceMappingURL=Settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Settings.d.ts","sourceRoot":"","sources":["../../src/contracts/Settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,iGAAi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,eAAO,MAAM,gBAAgB;;;;;QAxF3B,gCAAgC;;;;;;QAQhC,gHAAgH;;QAEhH,6EAA6E;;;;;;;;;;;;;;;;;;QAkB7E,iDAAiD;;;;;;;;;;;;QAxCjD,gFAAgF;;;;;;;;QAYhF,gCAAgC;;;;;;QAQhC,gHAAgH;;QAEhH,6EAA6E;;;;;;;;;;QAkB7E,iDAAiD;;;;;;;;;;;EAwGjD,CAAA"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Settings: scoped values declared in module manifests (`settings`), each with a value schema and a default,
3
+ * read by key only. Documented in docs/contracts/settings.md; conformance kit
4
+ * `@eloxiv/testing/conformance/Settings`.
5
+ *
6
+ * A value can be set at four levels, narrowest first: a person's own (`user`, in the organisation they act
7
+ * in), the organisation's (`org`), the deployment's (`app`, configuration) and the module installation's
8
+ * (`module`, configuration). A setting's declared scope is the narrowest level it accepts; a read takes the
9
+ * first level from there that holds a value, then the declared default (`resolveSetting`).
10
+ */
11
+ import { Schema } from "effect";
12
+ import { Forbidden, InvalidInput, Unauthenticated } from "../Errors.js";
13
+ import { SettingScope } from "../Manifest.js";
14
+ import { defineOperation, defineServiceContract } from "../Service.js";
15
+ /** The permission organisation administrators need to set or clear organisation-level values. */
16
+ export const SETTINGS_MANAGE = "eloxiv.settings.manage";
17
+ /** Where a value lives, narrowest first. */
18
+ export const SETTING_LEVELS = ["user", "org", "app", "module"];
19
+ export const SettingLevel = Schema.Literals(SETTING_LEVELS);
20
+ /** Levels a person or an organisation administrator writes through actions; `app` and `module` are configuration. */
21
+ export const WritableLevel = Schema.Literals(["user", "org"]);
22
+ /** The levels a setting of `scope` resolves through, in order. */
23
+ export const settingLevels = (scope) => SETTING_LEVELS.slice(SETTING_LEVELS.indexOf(scope));
24
+ /**
25
+ * Resolve a setting by its declared scope order: the first of its levels (`settingLevels`) that holds a value
26
+ * in `values`, else the declared default. Clients resolve with the same function over their replica.
27
+ */
28
+ export const resolveSetting = (declaration, values) => {
29
+ for (const level of settingLevels(declaration.scope)) {
30
+ if (values[level] !== undefined)
31
+ return { value: values[level], source: level };
32
+ }
33
+ return { value: declaration.default, source: "default" };
34
+ };
35
+ /** The id of a stored value: one per level, organisation, person and key. */
36
+ export const settingValueId = (level, orgId, userId, key) => `${level}:${orgId}:${userId ?? ""}:${key}`;
37
+ /** A stored user- or organisation-level value, as the replica holds it (table `eloxiv_settings.value`). */
38
+ export const SettingValue = Schema.Struct({
39
+ id: Schema.String,
40
+ key: Schema.String,
41
+ level: WritableLevel,
42
+ orgId: Schema.String,
43
+ /** The person, for a user-level value; `null` for an organisation-level one. */
44
+ userId: Schema.NullOr(Schema.String),
45
+ value: Schema.Unknown,
46
+ updatedBy: Schema.String,
47
+ updatedAt: Schema.Number,
48
+ });
49
+ export const SettingKey = Schema.Struct({ key: Schema.String });
50
+ export const SettingRead = Schema.Struct({
51
+ key: Schema.String,
52
+ /** The encoded (JSON) value. */
53
+ value: Schema.Unknown,
54
+ source: Schema.Literals([...SETTING_LEVELS, "default"]),
55
+ });
56
+ export const SettingWrite = Schema.Struct({
57
+ key: Schema.String,
58
+ /** `user` (your own value) or `org` (the organisation's, administrators only). Default: the setting's scope. */
59
+ level: Schema.optionalKey(WritableLevel),
60
+ /** The encoded (JSON) value; it must decode against the setting's schema. */
61
+ value: Schema.Unknown,
62
+ });
63
+ export const SettingClear = Schema.Struct({ key: Schema.String, level: Schema.optionalKey(WritableLevel) });
64
+ export const SettingChanged = Schema.Struct({
65
+ id: Schema.String,
66
+ key: Schema.String,
67
+ level: WritableLevel,
68
+ });
69
+ /** A deployment value (`app` or `module` level), set by configuration or a deployment administrator. */
70
+ export const SettingConfigure = Schema.Struct({
71
+ key: Schema.String,
72
+ level: Schema.Literals(["app", "module"]),
73
+ /** The encoded value, or `null` to remove it. */
74
+ value: Schema.Unknown,
75
+ });
76
+ /** What the audit record of a settings write holds as `detail`. */
77
+ export const SettingAuditDetail = Schema.Struct({
78
+ key: Schema.String,
79
+ level: SettingLevel,
80
+ subject: Schema.NullOr(Schema.String),
81
+ before: Schema.Unknown,
82
+ after: Schema.Unknown,
83
+ });
84
+ /** The kernel actions (module `settings`). */
85
+ export const SETTINGS_ACTIONS = { get: "settings.get", set: "settings.set", clear: "settings.clear" };
86
+ /**
87
+ * Each person's preferences, declared by the kernel's `settings` module (user scope: a person's own value, else
88
+ * their organisation's, else the default), synced to their replica like any setting: their language, their time
89
+ * zone (a cron schedule they create with `timeZone: "local"` runs in it), and their light, dark or system theme.
90
+ */
91
+ export const PREFERENCE_SETTINGS = {
92
+ locale: "settings.locale",
93
+ timeZone: "settings.timeZone",
94
+ theme: "settings.theme",
95
+ };
96
+ /** A BCP 47 language tag (`en`, `ar`, `pt-BR`), or null for the browser's. */
97
+ export const PreferredLocale = Schema.NullOr(Schema.String.check(Schema.isPattern(/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8}){0,3}$/)));
98
+ /** An IANA time zone (`Europe/London`, `UTC`), or null for the device's. */
99
+ export const PreferredTimeZone = Schema.NullOr(Schema.String.check(Schema.isPattern(/^(UTC|[A-Za-z_]+(\/[A-Za-z0-9_+-]+){1,2})$/)));
100
+ export const PreferredTheme = Schema.Literals(["system", "light", "dark"]);
101
+ /** The declarations (`settings` in the settings module's manifest). */
102
+ export const PREFERENCE_DECLARATIONS = {
103
+ [PREFERENCE_SETTINGS.locale]: {
104
+ description: "Your language for the app (a BCP 47 tag), or null for your browser's.",
105
+ scope: "user",
106
+ schema: PreferredLocale,
107
+ default: null,
108
+ },
109
+ [PREFERENCE_SETTINGS.timeZone]: {
110
+ description: "Your time zone (IANA), or null for your device's. Schedules you create in local time use it.",
111
+ scope: "user",
112
+ schema: PreferredTimeZone,
113
+ default: null,
114
+ },
115
+ [PREFERENCE_SETTINGS.theme]: {
116
+ description: "Light, dark, or following your system.",
117
+ scope: "user",
118
+ schema: PreferredTheme,
119
+ default: "system",
120
+ },
121
+ };
122
+ export const SettingsContract = defineServiceContract({
123
+ name: "Settings",
124
+ kind: "kernel",
125
+ version: "1.0.0",
126
+ description: "Scoped values declared in module manifests (user, org, app and module scopes), each with a value schema and " +
127
+ "a default. Reads are keyed (get resolves one key through the declared scope order) and never list. Writes are " +
128
+ "kernel actions authorised by level (a person writes their own user-level values; organisation administrators " +
129
+ "the organisation's), validated against the schema and audited; app and module levels are configuration. " +
130
+ "User- and organisation-level values sync to the person's replica. Secrets never go in settings.",
131
+ operations: {
132
+ get: defineOperation({
133
+ description: "The value of one declared setting for the caller, resolved through its scope's levels (user, org, app, " +
134
+ "module) to the declared default, with the level it came from. Unknown keys are InvalidInput.",
135
+ input: SettingKey,
136
+ output: SettingRead,
137
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
138
+ }),
139
+ set: defineOperation({
140
+ description: "Set a user-level value (your own) or an organisation-level value (administrators, with " +
141
+ "eloxiv.settings.manage). The value must decode against the setting's schema, and the level must be one " +
142
+ "the setting's scope accepts. Audited with the value before and after.",
143
+ input: SettingWrite,
144
+ output: SettingChanged,
145
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
146
+ }),
147
+ clear: defineOperation({
148
+ description: "Remove a user- or organisation-level value, so reads fall through to the next level. Audited.",
149
+ input: SettingClear,
150
+ output: SettingChanged,
151
+ errors: Schema.Union([Unauthenticated, Forbidden, InvalidInput]),
152
+ }),
153
+ configure: defineOperation({
154
+ description: "Operators only (in process, not a surface): set or remove a deployment value at the app or module level. " +
155
+ "Validated against the schema and audited as eloxiv.settings.configure.",
156
+ input: SettingConfigure,
157
+ output: Schema.Struct({ key: Schema.String, level: Schema.Literals(["app", "module"]) }),
158
+ errors: InvalidInput,
159
+ }),
160
+ },
161
+ types: { SettingValue, SettingRead, SettingWrite, SettingClear, SettingConfigure, SettingLevel, SettingAuditDetail },
162
+ });
163
+ //# sourceMappingURL=Settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../src/contracts/Settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAC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