@plures/praxis 1.0.3 → 1.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 (534) hide show
  1. package/FRAMEWORK.md +55 -5
  2. package/LICENSE +21 -21
  3. package/README.md +162 -375
  4. package/core/codegen/docs-generator.ts +5 -2
  5. package/core/codegen/index.ts +1 -1
  6. package/core/codegen/ts-generator.ts +15 -15
  7. package/core/db-adapter/index.ts +2 -2
  8. package/core/db-adapter/sync-engine.ts +17 -6
  9. package/core/logic-engine/engine.ts +1 -1
  10. package/core/logic-engine/index.ts +2 -2
  11. package/core/logic-engine/protocol.ts +1 -1
  12. package/core/logic-engine/psf-adapter.ts +8 -4
  13. package/core/logic-engine/rules.ts +1 -1
  14. package/core/schema-engine/compiler.ts +53 -11
  15. package/core/schema-engine/generator.ts +17 -7
  16. package/core/schema-engine/index.ts +2 -2
  17. package/core/schema-engine/psf.ts +12 -3
  18. package/core/schema-engine/types.ts +3 -11
  19. package/core/schema-engine/validator.ts +112 -22
  20. package/dist/browser/engine-BjdqxeXG.d.ts +333 -0
  21. package/dist/browser/index.d.ts +3004 -0
  22. package/dist/browser/index.js +2892 -0
  23. package/dist/{src → browser}/integrations/svelte.d.ts +19 -17
  24. package/dist/browser/integrations/svelte.js +298 -0
  25. package/dist/node/auth-STARLY7I.js +207 -0
  26. package/dist/node/build-Y7OT5VBF.js +144 -0
  27. package/dist/node/canvas-UERZHJYW.js +362 -0
  28. package/dist/node/chunk-DSDC2JWZ.js +256 -0
  29. package/dist/node/chunk-FXQZXAWF.js +175 -0
  30. package/dist/node/chunk-N5Y37EUV.js +202 -0
  31. package/dist/node/chunk-QGM4M3NI.js +37 -0
  32. package/dist/node/chunk-RJMWCNHR.js +175 -0
  33. package/dist/node/chunk-SRM3OPPM.js +404 -0
  34. package/dist/node/chunk-UATVJBNV.js +175 -0
  35. package/dist/node/chunk-UY7YEBE2.js +159 -0
  36. package/dist/node/chunk-XCY2VIFX.js +143 -0
  37. package/dist/node/chunk-YXH4Y7ZZ.js +349 -0
  38. package/dist/node/cli/index.cjs +217418 -0
  39. package/dist/node/cli/index.d.cts +1 -0
  40. package/dist/node/cli/index.d.ts +1 -0
  41. package/dist/node/cli/index.js +690 -0
  42. package/dist/node/cloud/index.cjs +1043 -0
  43. package/dist/node/cloud/index.d.cts +864 -0
  44. package/dist/node/cloud/index.d.ts +864 -0
  45. package/dist/node/cloud/index.js +456 -0
  46. package/dist/node/cloud-AXOK4PSN.js +212 -0
  47. package/dist/node/component.cjs +374 -0
  48. package/dist/node/component.d.cts +125 -0
  49. package/dist/{src/core/component/generator.d.ts → node/component.d.ts} +11 -8
  50. package/dist/node/component.js +9 -0
  51. package/dist/node/components/index.cjs +216 -0
  52. package/dist/node/components/index.d.cts +43 -0
  53. package/dist/{src → node}/components/index.d.ts +8 -8
  54. package/dist/node/components/index.js +7 -0
  55. package/dist/node/create-TRLSVCNQ.js +584 -0
  56. package/dist/node/dev-PMJZUYGE.js +65 -0
  57. package/dist/node/engine-1iqLe6_P.d.ts +214 -0
  58. package/dist/node/engine-CVJobhHm.d.cts +214 -0
  59. package/dist/node/index.cjs +3247 -0
  60. package/dist/node/index.d.cts +2579 -0
  61. package/dist/node/index.d.ts +2579 -0
  62. package/dist/node/index.js +2098 -0
  63. package/dist/node/integrations/svelte.cjs +330 -0
  64. package/dist/node/integrations/svelte.d.cts +309 -0
  65. package/dist/node/integrations/svelte.d.ts +309 -0
  66. package/dist/node/integrations/svelte.js +300 -0
  67. package/dist/node/orchestrate-737TCL5H.js +127 -0
  68. package/dist/{src/core/protocol.d.ts → node/protocol-Qek7ebBl.d.cts} +11 -10
  69. package/dist/node/protocol-Qek7ebBl.d.ts +122 -0
  70. package/dist/node/schema.cjs +200 -0
  71. package/dist/{src/core/schema/types.d.ts → node/schema.d.cts} +30 -29
  72. package/dist/node/schema.d.ts +371 -0
  73. package/dist/node/schema.js +9 -0
  74. package/dist/{src/runtime/terminal-adapter.d.ts → node/terminal-adapter-07HGftGQ.d.ts} +86 -11
  75. package/dist/node/terminal-adapter-XLtCjjb_.d.cts +231 -0
  76. package/dist/node/verify-YBZ7W24H.js +213239 -0
  77. package/docs/MONETIZATION.md +21 -16
  78. package/docs/REACTIVE_REDESIGN.md +132 -0
  79. package/docs/README.md +47 -36
  80. package/docs/SVELTE_INTEGRATION_STRATEGY.md +68 -0
  81. package/docs/TERMINAL_NODE.md +27 -24
  82. package/docs/core/building-extensions.md +58 -61
  83. package/docs/core/cli-usage.md +59 -59
  84. package/docs/core/code-canvas-sync.md +28 -16
  85. package/docs/core/logic-engine.md +77 -82
  86. package/docs/core/pluresdb-integration.md +29 -39
  87. package/docs/core/schema-model.md +66 -52
  88. package/docs/core/ui-generation.md +57 -49
  89. package/docs/core/what-is-praxis.md +32 -15
  90. package/docs/guides/canvas.md +21 -5
  91. package/docs/guides/getting-started.md +13 -7
  92. package/docs/guides/history-state-pattern.md +65 -51
  93. package/docs/guides/orchestration.md +46 -32
  94. package/docs/guides/parallel-state-pattern.md +56 -72
  95. package/docs/guides/svelte-integration.md +45 -53
  96. package/docs/tutorials/README.md +16 -0
  97. package/docs/tutorials/ecommerce-cart.md +177 -95
  98. package/docs/tutorials/first-app.md +26 -41
  99. package/docs/tutorials/form-builder.md +191 -138
  100. package/docs/tutorials/todo-pluresdb.md +71 -69
  101. package/package.json +132 -97
  102. package/src/__tests__/actors.test.ts +68 -68
  103. package/src/__tests__/billing.test.ts +32 -32
  104. package/src/__tests__/canvas-components.test.ts +94 -73
  105. package/src/__tests__/cli-create.test.ts +28 -28
  106. package/src/__tests__/cloud.test.ts +36 -36
  107. package/src/__tests__/code-canvas-integration.test.ts +132 -141
  108. package/src/__tests__/docs-generator.test.ts +3 -9
  109. package/src/__tests__/dsl.test.ts +58 -64
  110. package/src/__tests__/edge-cases.test.ts +106 -108
  111. package/src/__tests__/engine.test.ts +51 -25
  112. package/src/__tests__/generators.test.ts +42 -44
  113. package/src/__tests__/introspection.test.ts +104 -114
  114. package/src/__tests__/pluresdb.test.ts +189 -187
  115. package/src/__tests__/protocol.test.ts +15 -15
  116. package/src/__tests__/provisioning.test.ts +61 -61
  117. package/src/__tests__/schema.test.ts +7 -11
  118. package/src/__tests__/state-docs-integration.test.ts +162 -145
  119. package/src/__tests__/svelte-integration.test.ts +16 -19
  120. package/src/__tests__/tauri-integration.test.ts +149 -147
  121. package/src/__tests__/terminal-node.test.ts +12 -7
  122. package/src/__tests__/unum-integration.test.ts +68 -68
  123. package/src/adapters/cli.ts +21 -15
  124. package/src/cli/commands/auth.ts +82 -78
  125. package/src/cli/commands/build.ts +29 -27
  126. package/src/cli/commands/canvas.ts +338 -127
  127. package/src/cli/commands/cloud.ts +47 -47
  128. package/src/cli/commands/create.ts +59 -47
  129. package/src/cli/commands/dev.ts +12 -12
  130. package/src/cli/commands/generate.ts +29 -40
  131. package/src/cli/commands/orchestrate.ts +24 -24
  132. package/src/cli/commands/verify.ts +7 -8
  133. package/src/cli/index.ts +14 -10
  134. package/src/cloud/README.md +28 -15
  135. package/src/cloud/auth.ts +55 -70
  136. package/src/cloud/billing.ts +59 -58
  137. package/src/cloud/client.ts +29 -35
  138. package/src/cloud/index.ts +19 -40
  139. package/src/cloud/marketplace.ts +69 -78
  140. package/src/cloud/provisioning.ts +42 -51
  141. package/src/cloud/relay/endpoints.ts +30 -34
  142. package/src/cloud/relay/health/index.ts +1 -1
  143. package/src/cloud/relay/stats/index.ts +1 -1
  144. package/src/cloud/relay/sync/index.ts +1 -1
  145. package/src/cloud/relay/usage/index.ts +1 -1
  146. package/src/cloud/sponsors.ts +31 -34
  147. package/src/cloud/types.ts +4 -4
  148. package/src/components/README.md +1 -0
  149. package/src/components/TerminalNode.svelte +457 -457
  150. package/src/components/index.ts +3 -4
  151. package/src/core/actors.ts +7 -7
  152. package/src/core/component/generator.ts +10 -28
  153. package/src/core/engine.ts +51 -24
  154. package/src/core/introspection.ts +37 -35
  155. package/src/core/logic/generator.ts +62 -62
  156. package/src/core/pluresdb/adapter.ts +8 -8
  157. package/src/core/pluresdb/generator.ts +39 -35
  158. package/src/core/pluresdb/index.ts +9 -12
  159. package/src/core/pluresdb/schema-registry.ts +22 -25
  160. package/src/core/pluresdb/store.ts +57 -57
  161. package/src/core/protocol.ts +14 -14
  162. package/src/core/reactive-engine.svelte.ts +65 -0
  163. package/src/core/reactive-engine.ts +67 -0
  164. package/src/core/rules.ts +4 -4
  165. package/src/core/schema/loader.common.ts +150 -0
  166. package/src/core/schema/loader.ts +19 -149
  167. package/src/core/schema/normalize.ts +34 -51
  168. package/src/core/schema/types.ts +47 -11
  169. package/src/dsl/index.ts +8 -8
  170. package/src/dsl.ts +11 -17
  171. package/src/examples/advanced-todo/App.svelte +506 -506
  172. package/src/examples/advanced-todo/README.md +58 -40
  173. package/src/examples/advanced-todo/index.ts +3 -3
  174. package/src/examples/auth-basic/index.ts +30 -30
  175. package/src/examples/cart/index.ts +50 -50
  176. package/src/examples/hero-ecommerce/index.ts +130 -157
  177. package/src/examples/svelte-counter/index.ts +22 -26
  178. package/src/flows.ts +6 -17
  179. package/src/index.browser.ts +204 -0
  180. package/src/index.ts +37 -42
  181. package/src/integrations/code-canvas.ts +237 -193
  182. package/src/integrations/pluresdb.ts +55 -35
  183. package/src/integrations/state-docs.ts +104 -104
  184. package/src/integrations/svelte.ts +35 -35
  185. package/src/integrations/tauri.ts +75 -73
  186. package/src/integrations/unum.ts +68 -61
  187. package/src/registry.ts +7 -14
  188. package/src/runtime/terminal-adapter.ts +31 -26
  189. package/src/step.ts +10 -16
  190. package/src/types.ts +1 -1
  191. package/templates/basic-app/README.md +6 -9
  192. package/templates/fullstack-app/README.md +10 -0
  193. package/dist/core/codegen/docs-generator.d.ts +0 -123
  194. package/dist/core/codegen/docs-generator.d.ts.map +0 -1
  195. package/dist/core/codegen/docs-generator.js +0 -674
  196. package/dist/core/codegen/docs-generator.js.map +0 -1
  197. package/dist/core/codegen/index.d.ts +0 -11
  198. package/dist/core/codegen/index.d.ts.map +0 -1
  199. package/dist/core/codegen/index.js +0 -13
  200. package/dist/core/codegen/index.js.map +0 -1
  201. package/dist/core/codegen/ts-generator.d.ts +0 -8
  202. package/dist/core/codegen/ts-generator.d.ts.map +0 -1
  203. package/dist/core/codegen/ts-generator.js +0 -8
  204. package/dist/core/codegen/ts-generator.js.map +0 -1
  205. package/dist/core/db-adapter/index.d.ts +0 -18
  206. package/dist/core/db-adapter/index.d.ts.map +0 -1
  207. package/dist/core/db-adapter/index.js +0 -23
  208. package/dist/core/db-adapter/index.js.map +0 -1
  209. package/dist/core/db-adapter/sync-engine.d.ts +0 -180
  210. package/dist/core/db-adapter/sync-engine.d.ts.map +0 -1
  211. package/dist/core/db-adapter/sync-engine.js +0 -342
  212. package/dist/core/db-adapter/sync-engine.js.map +0 -1
  213. package/dist/core/logic-engine/engine.d.ts +0 -8
  214. package/dist/core/logic-engine/engine.d.ts.map +0 -1
  215. package/dist/core/logic-engine/engine.js +0 -8
  216. package/dist/core/logic-engine/engine.js.map +0 -1
  217. package/dist/core/logic-engine/index.d.ts +0 -16
  218. package/dist/core/logic-engine/index.d.ts.map +0 -1
  219. package/dist/core/logic-engine/index.js +0 -16
  220. package/dist/core/logic-engine/index.js.map +0 -1
  221. package/dist/core/logic-engine/protocol.d.ts +0 -7
  222. package/dist/core/logic-engine/protocol.d.ts.map +0 -1
  223. package/dist/core/logic-engine/protocol.js +0 -7
  224. package/dist/core/logic-engine/protocol.js.map +0 -1
  225. package/dist/core/logic-engine/psf-adapter.d.ts +0 -88
  226. package/dist/core/logic-engine/psf-adapter.d.ts.map +0 -1
  227. package/dist/core/logic-engine/psf-adapter.js +0 -207
  228. package/dist/core/logic-engine/psf-adapter.js.map +0 -1
  229. package/dist/core/logic-engine/rules.d.ts +0 -7
  230. package/dist/core/logic-engine/rules.d.ts.map +0 -1
  231. package/dist/core/logic-engine/rules.js +0 -7
  232. package/dist/core/logic-engine/rules.js.map +0 -1
  233. package/dist/core/schema-engine/compiler.d.ts +0 -198
  234. package/dist/core/schema-engine/compiler.d.ts.map +0 -1
  235. package/dist/core/schema-engine/compiler.js +0 -262
  236. package/dist/core/schema-engine/compiler.js.map +0 -1
  237. package/dist/core/schema-engine/generator.d.ts +0 -115
  238. package/dist/core/schema-engine/generator.d.ts.map +0 -1
  239. package/dist/core/schema-engine/generator.js +0 -506
  240. package/dist/core/schema-engine/generator.js.map +0 -1
  241. package/dist/core/schema-engine/index.d.ts +0 -18
  242. package/dist/core/schema-engine/index.d.ts.map +0 -1
  243. package/dist/core/schema-engine/index.js +0 -18
  244. package/dist/core/schema-engine/index.js.map +0 -1
  245. package/dist/core/schema-engine/psf.d.ts +0 -612
  246. package/dist/core/schema-engine/psf.d.ts.map +0 -1
  247. package/dist/core/schema-engine/psf.js +0 -45
  248. package/dist/core/schema-engine/psf.js.map +0 -1
  249. package/dist/core/schema-engine/types.d.ts +0 -10
  250. package/dist/core/schema-engine/types.d.ts.map +0 -1
  251. package/dist/core/schema-engine/types.js +0 -7
  252. package/dist/core/schema-engine/types.js.map +0 -1
  253. package/dist/core/schema-engine/validator.d.ts +0 -140
  254. package/dist/core/schema-engine/validator.d.ts.map +0 -1
  255. package/dist/core/schema-engine/validator.js +0 -407
  256. package/dist/core/schema-engine/validator.js.map +0 -1
  257. package/dist/src/adapters/cli.d.ts +0 -43
  258. package/dist/src/adapters/cli.d.ts.map +0 -1
  259. package/dist/src/adapters/cli.js +0 -126
  260. package/dist/src/adapters/cli.js.map +0 -1
  261. package/dist/src/cli/commands/auth.d.ts +0 -26
  262. package/dist/src/cli/commands/auth.d.ts.map +0 -1
  263. package/dist/src/cli/commands/auth.js +0 -233
  264. package/dist/src/cli/commands/auth.js.map +0 -1
  265. package/dist/src/cli/commands/build.d.ts +0 -23
  266. package/dist/src/cli/commands/build.d.ts.map +0 -1
  267. package/dist/src/cli/commands/build.js +0 -162
  268. package/dist/src/cli/commands/build.js.map +0 -1
  269. package/dist/src/cli/commands/canvas.d.ts +0 -23
  270. package/dist/src/cli/commands/canvas.d.ts.map +0 -1
  271. package/dist/src/cli/commands/canvas.js +0 -215
  272. package/dist/src/cli/commands/canvas.js.map +0 -1
  273. package/dist/src/cli/commands/cloud.d.ts +0 -27
  274. package/dist/src/cli/commands/cloud.d.ts.map +0 -1
  275. package/dist/src/cli/commands/cloud.js +0 -232
  276. package/dist/src/cli/commands/cloud.js.map +0 -1
  277. package/dist/src/cli/commands/create.d.ts +0 -21
  278. package/dist/src/cli/commands/create.d.ts.map +0 -1
  279. package/dist/src/cli/commands/create.js +0 -621
  280. package/dist/src/cli/commands/create.js.map +0 -1
  281. package/dist/src/cli/commands/dev.d.ts +0 -21
  282. package/dist/src/cli/commands/dev.d.ts.map +0 -1
  283. package/dist/src/cli/commands/dev.js +0 -71
  284. package/dist/src/cli/commands/dev.js.map +0 -1
  285. package/dist/src/cli/commands/generate.d.ts +0 -25
  286. package/dist/src/cli/commands/generate.d.ts.map +0 -1
  287. package/dist/src/cli/commands/generate.js +0 -168
  288. package/dist/src/cli/commands/generate.js.map +0 -1
  289. package/dist/src/cli/commands/orchestrate.d.ts +0 -44
  290. package/dist/src/cli/commands/orchestrate.d.ts.map +0 -1
  291. package/dist/src/cli/commands/orchestrate.js +0 -150
  292. package/dist/src/cli/commands/orchestrate.js.map +0 -1
  293. package/dist/src/cli/commands/verify.d.ts +0 -10
  294. package/dist/src/cli/commands/verify.d.ts.map +0 -1
  295. package/dist/src/cli/commands/verify.js +0 -39
  296. package/dist/src/cli/commands/verify.js.map +0 -1
  297. package/dist/src/cli/index.d.ts +0 -8
  298. package/dist/src/cli/index.d.ts.map +0 -1
  299. package/dist/src/cli/index.js +0 -226
  300. package/dist/src/cli/index.js.map +0 -1
  301. package/dist/src/cloud/auth.d.ts +0 -51
  302. package/dist/src/cloud/auth.d.ts.map +0 -1
  303. package/dist/src/cloud/auth.js +0 -194
  304. package/dist/src/cloud/auth.js.map +0 -1
  305. package/dist/src/cloud/billing.d.ts +0 -184
  306. package/dist/src/cloud/billing.d.ts.map +0 -1
  307. package/dist/src/cloud/billing.js +0 -179
  308. package/dist/src/cloud/billing.js.map +0 -1
  309. package/dist/src/cloud/client.d.ts +0 -39
  310. package/dist/src/cloud/client.d.ts.map +0 -1
  311. package/dist/src/cloud/client.js +0 -176
  312. package/dist/src/cloud/client.js.map +0 -1
  313. package/dist/src/cloud/index.d.ts +0 -44
  314. package/dist/src/cloud/index.d.ts.map +0 -1
  315. package/dist/src/cloud/index.js +0 -44
  316. package/dist/src/cloud/index.js.map +0 -1
  317. package/dist/src/cloud/marketplace.d.ts +0 -166
  318. package/dist/src/cloud/marketplace.d.ts.map +0 -1
  319. package/dist/src/cloud/marketplace.js +0 -159
  320. package/dist/src/cloud/marketplace.js.map +0 -1
  321. package/dist/src/cloud/provisioning.d.ts +0 -110
  322. package/dist/src/cloud/provisioning.d.ts.map +0 -1
  323. package/dist/src/cloud/provisioning.js +0 -148
  324. package/dist/src/cloud/provisioning.js.map +0 -1
  325. package/dist/src/cloud/relay/endpoints.d.ts +0 -62
  326. package/dist/src/cloud/relay/endpoints.d.ts.map +0 -1
  327. package/dist/src/cloud/relay/endpoints.js +0 -217
  328. package/dist/src/cloud/relay/endpoints.js.map +0 -1
  329. package/dist/src/cloud/relay/health/index.d.ts +0 -5
  330. package/dist/src/cloud/relay/health/index.d.ts.map +0 -1
  331. package/dist/src/cloud/relay/health/index.js +0 -9
  332. package/dist/src/cloud/relay/health/index.js.map +0 -1
  333. package/dist/src/cloud/relay/stats/index.d.ts +0 -5
  334. package/dist/src/cloud/relay/stats/index.d.ts.map +0 -1
  335. package/dist/src/cloud/relay/stats/index.js +0 -9
  336. package/dist/src/cloud/relay/stats/index.js.map +0 -1
  337. package/dist/src/cloud/relay/sync/index.d.ts +0 -5
  338. package/dist/src/cloud/relay/sync/index.d.ts.map +0 -1
  339. package/dist/src/cloud/relay/sync/index.js +0 -9
  340. package/dist/src/cloud/relay/sync/index.js.map +0 -1
  341. package/dist/src/cloud/relay/usage/index.d.ts +0 -5
  342. package/dist/src/cloud/relay/usage/index.d.ts.map +0 -1
  343. package/dist/src/cloud/relay/usage/index.js +0 -9
  344. package/dist/src/cloud/relay/usage/index.js.map +0 -1
  345. package/dist/src/cloud/sponsors.d.ts +0 -81
  346. package/dist/src/cloud/sponsors.d.ts.map +0 -1
  347. package/dist/src/cloud/sponsors.js +0 -130
  348. package/dist/src/cloud/sponsors.js.map +0 -1
  349. package/dist/src/cloud/types.d.ts +0 -169
  350. package/dist/src/cloud/types.d.ts.map +0 -1
  351. package/dist/src/cloud/types.js +0 -7
  352. package/dist/src/cloud/types.js.map +0 -1
  353. package/dist/src/components/index.d.ts.map +0 -1
  354. package/dist/src/components/index.js +0 -17
  355. package/dist/src/components/index.js.map +0 -1
  356. package/dist/src/core/actors.d.ts +0 -95
  357. package/dist/src/core/actors.d.ts.map +0 -1
  358. package/dist/src/core/actors.js +0 -158
  359. package/dist/src/core/actors.js.map +0 -1
  360. package/dist/src/core/component/generator.d.ts.map +0 -1
  361. package/dist/src/core/component/generator.js +0 -349
  362. package/dist/src/core/component/generator.js.map +0 -1
  363. package/dist/src/core/engine.d.ts +0 -92
  364. package/dist/src/core/engine.d.ts.map +0 -1
  365. package/dist/src/core/engine.js +0 -199
  366. package/dist/src/core/engine.js.map +0 -1
  367. package/dist/src/core/introspection.d.ts +0 -141
  368. package/dist/src/core/introspection.d.ts.map +0 -1
  369. package/dist/src/core/introspection.js +0 -208
  370. package/dist/src/core/introspection.js.map +0 -1
  371. package/dist/src/core/logic/generator.d.ts +0 -76
  372. package/dist/src/core/logic/generator.d.ts.map +0 -1
  373. package/dist/src/core/logic/generator.js +0 -370
  374. package/dist/src/core/logic/generator.js.map +0 -1
  375. package/dist/src/core/pluresdb/adapter.d.ts +0 -72
  376. package/dist/src/core/pluresdb/adapter.d.ts.map +0 -1
  377. package/dist/src/core/pluresdb/adapter.js +0 -73
  378. package/dist/src/core/pluresdb/adapter.js.map +0 -1
  379. package/dist/src/core/pluresdb/generator.d.ts +0 -58
  380. package/dist/src/core/pluresdb/generator.d.ts.map +0 -1
  381. package/dist/src/core/pluresdb/generator.js +0 -191
  382. package/dist/src/core/pluresdb/generator.js.map +0 -1
  383. package/dist/src/core/pluresdb/index.d.ts +0 -15
  384. package/dist/src/core/pluresdb/index.d.ts.map +0 -1
  385. package/dist/src/core/pluresdb/index.js +0 -11
  386. package/dist/src/core/pluresdb/index.js.map +0 -1
  387. package/dist/src/core/pluresdb/schema-registry.d.ts +0 -104
  388. package/dist/src/core/pluresdb/schema-registry.d.ts.map +0 -1
  389. package/dist/src/core/pluresdb/schema-registry.js +0 -130
  390. package/dist/src/core/pluresdb/schema-registry.js.map +0 -1
  391. package/dist/src/core/pluresdb/store.d.ts +0 -199
  392. package/dist/src/core/pluresdb/store.d.ts.map +0 -1
  393. package/dist/src/core/pluresdb/store.js +0 -344
  394. package/dist/src/core/pluresdb/store.js.map +0 -1
  395. package/dist/src/core/protocol.d.ts.map +0 -1
  396. package/dist/src/core/protocol.js +0 -46
  397. package/dist/src/core/protocol.js.map +0 -1
  398. package/dist/src/core/rules.d.ts +0 -120
  399. package/dist/src/core/rules.d.ts.map +0 -1
  400. package/dist/src/core/rules.js +0 -81
  401. package/dist/src/core/rules.js.map +0 -1
  402. package/dist/src/core/schema/loader.d.ts +0 -47
  403. package/dist/src/core/schema/loader.d.ts.map +0 -1
  404. package/dist/src/core/schema/loader.js +0 -189
  405. package/dist/src/core/schema/loader.js.map +0 -1
  406. package/dist/src/core/schema/normalize.d.ts +0 -72
  407. package/dist/src/core/schema/normalize.d.ts.map +0 -1
  408. package/dist/src/core/schema/normalize.js +0 -190
  409. package/dist/src/core/schema/normalize.js.map +0 -1
  410. package/dist/src/core/schema/types.d.ts.map +0 -1
  411. package/dist/src/core/schema/types.js +0 -161
  412. package/dist/src/core/schema/types.js.map +0 -1
  413. package/dist/src/dsl/index.d.ts +0 -152
  414. package/dist/src/dsl/index.d.ts.map +0 -1
  415. package/dist/src/dsl/index.js +0 -132
  416. package/dist/src/dsl/index.js.map +0 -1
  417. package/dist/src/dsl.d.ts +0 -124
  418. package/dist/src/dsl.d.ts.map +0 -1
  419. package/dist/src/dsl.js +0 -130
  420. package/dist/src/dsl.js.map +0 -1
  421. package/dist/src/examples/advanced-todo/index.d.ts +0 -55
  422. package/dist/src/examples/advanced-todo/index.d.ts.map +0 -1
  423. package/dist/src/examples/advanced-todo/index.js +0 -222
  424. package/dist/src/examples/advanced-todo/index.js.map +0 -1
  425. package/dist/src/examples/auth-basic/index.d.ts +0 -17
  426. package/dist/src/examples/auth-basic/index.d.ts.map +0 -1
  427. package/dist/src/examples/auth-basic/index.js +0 -122
  428. package/dist/src/examples/auth-basic/index.js.map +0 -1
  429. package/dist/src/examples/cart/index.d.ts +0 -19
  430. package/dist/src/examples/cart/index.d.ts.map +0 -1
  431. package/dist/src/examples/cart/index.js +0 -202
  432. package/dist/src/examples/cart/index.js.map +0 -1
  433. package/dist/src/examples/hero-ecommerce/index.d.ts +0 -39
  434. package/dist/src/examples/hero-ecommerce/index.d.ts.map +0 -1
  435. package/dist/src/examples/hero-ecommerce/index.js +0 -506
  436. package/dist/src/examples/hero-ecommerce/index.js.map +0 -1
  437. package/dist/src/examples/svelte-counter/index.d.ts +0 -31
  438. package/dist/src/examples/svelte-counter/index.d.ts.map +0 -1
  439. package/dist/src/examples/svelte-counter/index.js +0 -123
  440. package/dist/src/examples/svelte-counter/index.js.map +0 -1
  441. package/dist/src/flows.d.ts +0 -125
  442. package/dist/src/flows.d.ts.map +0 -1
  443. package/dist/src/flows.js +0 -160
  444. package/dist/src/flows.js.map +0 -1
  445. package/dist/src/index.d.ts +0 -77
  446. package/dist/src/index.d.ts.map +0 -1
  447. package/dist/src/index.js +0 -64
  448. package/dist/src/index.js.map +0 -1
  449. package/dist/src/integrations/code-canvas.d.ts +0 -265
  450. package/dist/src/integrations/code-canvas.d.ts.map +0 -1
  451. package/dist/src/integrations/code-canvas.js +0 -451
  452. package/dist/src/integrations/code-canvas.js.map +0 -1
  453. package/dist/src/integrations/pluresdb.d.ts +0 -117
  454. package/dist/src/integrations/pluresdb.d.ts.map +0 -1
  455. package/dist/src/integrations/pluresdb.js +0 -117
  456. package/dist/src/integrations/pluresdb.js.map +0 -1
  457. package/dist/src/integrations/state-docs.d.ts +0 -191
  458. package/dist/src/integrations/state-docs.d.ts.map +0 -1
  459. package/dist/src/integrations/state-docs.js +0 -515
  460. package/dist/src/integrations/state-docs.js.map +0 -1
  461. package/dist/src/integrations/svelte.d.ts.map +0 -1
  462. package/dist/src/integrations/svelte.js +0 -447
  463. package/dist/src/integrations/svelte.js.map +0 -1
  464. package/dist/src/integrations/tauri.d.ts +0 -360
  465. package/dist/src/integrations/tauri.d.ts.map +0 -1
  466. package/dist/src/integrations/tauri.js +0 -278
  467. package/dist/src/integrations/tauri.js.map +0 -1
  468. package/dist/src/integrations/unum.d.ts +0 -159
  469. package/dist/src/integrations/unum.d.ts.map +0 -1
  470. package/dist/src/integrations/unum.js +0 -240
  471. package/dist/src/integrations/unum.js.map +0 -1
  472. package/dist/src/registry.d.ts +0 -94
  473. package/dist/src/registry.d.ts.map +0 -1
  474. package/dist/src/registry.js +0 -181
  475. package/dist/src/registry.js.map +0 -1
  476. package/dist/src/runtime/terminal-adapter.d.ts.map +0 -1
  477. package/dist/src/runtime/terminal-adapter.js +0 -239
  478. package/dist/src/runtime/terminal-adapter.js.map +0 -1
  479. package/dist/src/step.d.ts +0 -34
  480. package/dist/src/step.d.ts.map +0 -1
  481. package/dist/src/step.js +0 -111
  482. package/dist/src/step.js.map +0 -1
  483. package/dist/src/types.d.ts +0 -63
  484. package/dist/src/types.d.ts.map +0 -1
  485. package/dist/src/types.js +0 -6
  486. package/dist/src/types.js.map +0 -1
  487. package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts +0 -8
  488. package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts.map +0 -1
  489. package/dist/tools/ast-analyzer/src/ast-analyzer.js +0 -119
  490. package/dist/tools/ast-analyzer/src/ast-analyzer.js.map +0 -1
  491. package/dist/tools/cli/commands/index.d.ts +0 -7
  492. package/dist/tools/cli/commands/index.d.ts.map +0 -1
  493. package/dist/tools/cli/commands/index.js +0 -7
  494. package/dist/tools/cli/commands/index.js.map +0 -1
  495. package/dist/tools/cli/index.d.ts +0 -8
  496. package/dist/tools/cli/index.d.ts.map +0 -1
  497. package/dist/tools/cli/index.js +0 -9
  498. package/dist/tools/cli/index.js.map +0 -1
  499. package/dist/tools/watcher/index.d.ts +0 -105
  500. package/dist/tools/watcher/index.d.ts.map +0 -1
  501. package/dist/tools/watcher/index.js +0 -213
  502. package/dist/tools/watcher/index.js.map +0 -1
  503. package/dist/ui/canvas/canvas-projection.d.ts +0 -78
  504. package/dist/ui/canvas/canvas-projection.d.ts.map +0 -1
  505. package/dist/ui/canvas/canvas-projection.js +0 -416
  506. package/dist/ui/canvas/canvas-projection.js.map +0 -1
  507. package/dist/ui/canvas/canvas-state.d.ts +0 -200
  508. package/dist/ui/canvas/canvas-state.d.ts.map +0 -1
  509. package/dist/ui/canvas/canvas-state.js +0 -464
  510. package/dist/ui/canvas/canvas-state.js.map +0 -1
  511. package/dist/ui/canvas/components/index.d.ts +0 -95
  512. package/dist/ui/canvas/components/index.d.ts.map +0 -1
  513. package/dist/ui/canvas/components/index.js +0 -19
  514. package/dist/ui/canvas/components/index.js.map +0 -1
  515. package/dist/ui/canvas/index.d.ts +0 -32
  516. package/dist/ui/canvas/index.d.ts.map +0 -1
  517. package/dist/ui/canvas/index.js +0 -32
  518. package/dist/ui/canvas/index.js.map +0 -1
  519. package/dist/ui/canvas-inspector/src/server.d.ts +0 -2
  520. package/dist/ui/canvas-inspector/src/server.d.ts.map +0 -1
  521. package/dist/ui/canvas-inspector/src/server.js +0 -248
  522. package/dist/ui/canvas-inspector/src/server.js.map +0 -1
  523. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts +0 -5
  524. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts.map +0 -1
  525. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js +0 -58
  526. package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js.map +0 -1
  527. package/dist/ui/svelte-generator/index.d.ts +0 -9
  528. package/dist/ui/svelte-generator/index.d.ts.map +0 -1
  529. package/dist/ui/svelte-generator/index.js +0 -11
  530. package/dist/ui/svelte-generator/index.js.map +0 -1
  531. package/dist/ui/svelte-generator/psf-generator.d.ts +0 -128
  532. package/dist/ui/svelte-generator/psf-generator.d.ts.map +0 -1
  533. package/dist/ui/svelte-generator/psf-generator.js +0 -506
  534. package/dist/ui/svelte-generator/psf-generator.js.map +0 -1
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * Unum Integration
3
- *
4
- * Integration with plures/unum - A modern Svelte binding library for PluresDB
3
+ *
4
+ * Integration with plures/unum - A modern Svelte binding library for PluresDB
5
5
  * with full Svelte 5 compatibility. Provides identity and channels support.
6
- *
6
+ *
7
7
  * Features:
8
8
  * - Svelte 4 & 5 Compatible: Works with both store-based and runes-based reactivity
9
9
  * - Type-Safe: Full TypeScript support with proper types
10
10
  * - Action-Based: Modern Svelte actions for DOM binding
11
11
  * - Store-Based: Writable store implementation for reactive data
12
12
  * - Collection Support: Easy handling of PluresDB collections
13
- *
13
+ *
14
14
  * @see https://github.com/plures/unum
15
15
  */
16
16
 
17
- import type { LogicEngine } from "../core/engine.js";
18
- import type { PraxisEvent, PraxisFact } from "../core/protocol.js";
19
- import type { PraxisDB } from "../core/pluresdb/adapter.js";
17
+ import type { LogicEngine } from '../core/engine.js';
18
+ import type { PraxisEvent, PraxisFact } from '../core/protocol.js';
19
+ import type { PraxisDB } from '../core/pluresdb/adapter.js';
20
20
 
21
21
  /**
22
22
  * Unum store interface for reactive PluresDB data
@@ -97,53 +97,53 @@ export interface UnumAdapterConfig {
97
97
 
98
98
  /**
99
99
  * Unum adapter for Praxis engine integration
100
- *
100
+ *
101
101
  * Provides identity management and channel-based communication
102
102
  * for distributed Praxis applications.
103
103
  */
104
104
  export interface UnumAdapter {
105
105
  /** Current identity */
106
106
  identity: UnumIdentity | null;
107
-
107
+
108
108
  /** Create or update identity */
109
109
  setIdentity(identity: Omit<UnumIdentity, 'id' | 'createdAt'>): Promise<UnumIdentity>;
110
-
110
+
111
111
  /** Get identity by ID */
112
112
  getIdentity(id: string): Promise<UnumIdentity | null>;
113
-
113
+
114
114
  /** Create a new channel */
115
115
  createChannel(name: string, members?: string[]): Promise<UnumChannel>;
116
-
116
+
117
117
  /** Join an existing channel */
118
118
  joinChannel(channelId: string): Promise<UnumChannel>;
119
-
119
+
120
120
  /** List available channels */
121
121
  listChannels(): Promise<UnumChannel[]>;
122
-
122
+
123
123
  /** Broadcast a Praxis event to a channel */
124
124
  broadcastEvent(channelId: string, event: PraxisEvent): Promise<void>;
125
-
125
+
126
126
  /** Broadcast a Praxis fact to a channel */
127
127
  broadcastFact(channelId: string, fact: PraxisFact): Promise<void>;
128
-
128
+
129
129
  /** Subscribe to events from a channel */
130
130
  subscribeToEvents(channelId: string, handler: (event: PraxisEvent) => void): () => void;
131
-
131
+
132
132
  /** Subscribe to facts from a channel */
133
133
  subscribeToFacts(channelId: string, handler: (fact: PraxisFact) => void): () => void;
134
-
134
+
135
135
  /** Disconnect and cleanup */
136
136
  disconnect(): Promise<void>;
137
137
  }
138
138
 
139
139
  /**
140
140
  * Create a Unum adapter for Praxis engine integration
141
- *
141
+ *
142
142
  * @example
143
143
  * ```typescript
144
144
  * import { createUnumAdapter } from '@plures/praxis/integrations/unum';
145
145
  * import { createInMemoryDB } from '@plures/praxis/integrations/pluresdb';
146
- *
146
+ *
147
147
  * const db = createInMemoryDB();
148
148
  * const unum = await createUnumAdapter({
149
149
  * db,
@@ -152,10 +152,10 @@ export interface UnumAdapter {
152
152
  * },
153
153
  * realtime: true,
154
154
  * });
155
- *
155
+ *
156
156
  * // Create a channel
157
157
  * const channel = await unum.createChannel('my-channel');
158
- *
158
+ *
159
159
  * // Broadcast events to the channel
160
160
  * await unum.broadcastEvent(channel.id, myEvent);
161
161
  * ```
@@ -163,11 +163,11 @@ export interface UnumAdapter {
163
163
  export async function createUnumAdapter(config: UnumAdapterConfig): Promise<UnumAdapter> {
164
164
  const { db, realtime = true } = config;
165
165
  // syncInterval could be used for periodic sync in a more complete implementation
166
-
166
+
167
167
  let currentIdentity: UnumIdentity | null = null;
168
168
  const channels = new Map<string, UnumChannel>();
169
169
  const subscriptions = new Set<() => void>();
170
-
170
+
171
171
  // Set initial identity if provided
172
172
  if (config.identity) {
173
173
  currentIdentity = {
@@ -177,8 +177,10 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
177
177
  };
178
178
  await db.set(`unum/identities/${currentIdentity.id}`, currentIdentity);
179
179
  }
180
-
181
- async function setIdentity(identity: Omit<UnumIdentity, 'id' | 'createdAt'>): Promise<UnumIdentity> {
180
+
181
+ async function setIdentity(
182
+ identity: Omit<UnumIdentity, 'id' | 'createdAt'>
183
+ ): Promise<UnumIdentity> {
182
184
  currentIdentity = {
183
185
  ...identity,
184
186
  id: generateId(),
@@ -187,11 +189,11 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
187
189
  await db.set(`unum/identities/${currentIdentity.id}`, currentIdentity);
188
190
  return currentIdentity;
189
191
  }
190
-
192
+
191
193
  async function getIdentity(id: string): Promise<UnumIdentity | null> {
192
- return await db.get(`unum/identities/${id}`) as UnumIdentity | null;
194
+ return (await db.get(`unum/identities/${id}`)) as UnumIdentity | null;
193
195
  }
194
-
196
+
195
197
  async function createChannel(name: string, members?: string[]): Promise<UnumChannel> {
196
198
  const channelId = generateId();
197
199
  const channelData = {
@@ -201,41 +203,44 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
201
203
  createdAt: Date.now(),
202
204
  createdBy: currentIdentity?.id,
203
205
  };
204
-
206
+
205
207
  await db.set(`unum/channels/${channelId}`, channelData);
206
-
208
+
207
209
  const channel = createChannelInstance(channelId, name);
208
210
  channels.set(channelId, channel);
209
211
  return channel;
210
212
  }
211
-
213
+
212
214
  async function joinChannel(channelId: string): Promise<UnumChannel> {
213
215
  const existing = channels.get(channelId);
214
216
  if (existing) return existing;
215
-
216
- const channelData = await db.get(`unum/channels/${channelId}`) as { id: string; name: string } | null;
217
+
218
+ const channelData = (await db.get(`unum/channels/${channelId}`)) as {
219
+ id: string;
220
+ name: string;
221
+ } | null;
217
222
  if (!channelData) {
218
223
  throw new Error(`Channel ${channelId} not found`);
219
224
  }
220
-
225
+
221
226
  const channel = createChannelInstance(channelData.id, channelData.name);
222
227
  channels.set(channelId, channel);
223
228
  return channel;
224
229
  }
225
-
230
+
226
231
  async function listChannels(): Promise<UnumChannel[]> {
227
232
  return Array.from(channels.values());
228
233
  }
229
-
234
+
230
235
  function createChannelInstance(id: string, name: string): UnumChannel {
231
236
  const handlers = new Set<(message: UnumMessage) => void>();
232
-
237
+
233
238
  return {
234
239
  id,
235
240
  name,
236
241
  subscribe(handler: (message: UnumMessage) => void): () => void {
237
242
  handlers.add(handler);
238
-
243
+
239
244
  // Set up database subscription if realtime is enabled
240
245
  if (realtime) {
241
246
  const unsub = db.watch(`unum/channels/${id}/messages`, (data) => {
@@ -245,7 +250,7 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
245
250
  });
246
251
  subscriptions.add(unsub);
247
252
  }
248
-
253
+
249
254
  return () => {
250
255
  handlers.delete(handler);
251
256
  };
@@ -257,16 +262,16 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
257
262
  channelId: id,
258
263
  timestamp: Date.now(),
259
264
  };
260
-
265
+
261
266
  await db.set(`unum/channels/${id}/messages/${fullMessage.id}`, fullMessage);
262
-
267
+
263
268
  // Notify local handlers
264
- handlers.forEach(h => h(fullMessage));
269
+ handlers.forEach((h) => h(fullMessage));
265
270
  },
266
271
  async getMembers(): Promise<UnumIdentity[]> {
267
- const channelData = await db.get(`unum/channels/${id}`) as { members?: string[] } | null;
272
+ const channelData = (await db.get(`unum/channels/${id}`)) as { members?: string[] } | null;
268
273
  if (!channelData?.members) return [];
269
-
274
+
270
275
  const members: UnumIdentity[] = [];
271
276
  for (const memberId of channelData.members) {
272
277
  const identity = await getIdentity(memberId);
@@ -279,13 +284,13 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
279
284
  },
280
285
  };
281
286
  }
282
-
287
+
283
288
  async function broadcastEvent(channelId: string, event: PraxisEvent): Promise<void> {
284
289
  const channel = channels.get(channelId);
285
290
  if (!channel) {
286
291
  throw new Error(`Not joined to channel ${channelId}`);
287
292
  }
288
-
293
+
289
294
  await channel.publish({
290
295
  id: generateId(),
291
296
  sender: currentIdentity || { id: 'anonymous', createdAt: Date.now() },
@@ -293,13 +298,13 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
293
298
  type: 'event',
294
299
  });
295
300
  }
296
-
301
+
297
302
  async function broadcastFact(channelId: string, fact: PraxisFact): Promise<void> {
298
303
  const channel = channels.get(channelId);
299
304
  if (!channel) {
300
305
  throw new Error(`Not joined to channel ${channelId}`);
301
306
  }
302
-
307
+
303
308
  await channel.publish({
304
309
  id: generateId(),
305
310
  sender: currentIdentity || { id: 'anonymous', createdAt: Date.now() },
@@ -307,49 +312,51 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
307
312
  type: 'fact',
308
313
  });
309
314
  }
310
-
315
+
311
316
  function subscribeToEvents(channelId: string, handler: (event: PraxisEvent) => void): () => void {
312
317
  const channel = channels.get(channelId);
313
318
  if (!channel) {
314
319
  throw new Error(`Not joined to channel ${channelId}`);
315
320
  }
316
-
321
+
317
322
  return channel.subscribe((message) => {
318
323
  if (message.type === 'event') {
319
324
  handler(message.content as PraxisEvent);
320
325
  }
321
326
  });
322
327
  }
323
-
328
+
324
329
  function subscribeToFacts(channelId: string, handler: (fact: PraxisFact) => void): () => void {
325
330
  const channel = channels.get(channelId);
326
331
  if (!channel) {
327
332
  throw new Error(`Not joined to channel ${channelId}`);
328
333
  }
329
-
334
+
330
335
  return channel.subscribe((message) => {
331
336
  if (message.type === 'fact') {
332
337
  handler(message.content as PraxisFact);
333
338
  }
334
339
  });
335
340
  }
336
-
341
+
337
342
  async function disconnect(): Promise<void> {
338
343
  // Cleanup all subscriptions
339
- subscriptions.forEach(unsub => unsub());
344
+ subscriptions.forEach((unsub) => unsub());
340
345
  subscriptions.clear();
341
-
346
+
342
347
  // Leave all channels
343
348
  for (const channel of channels.values()) {
344
349
  await channel.leave();
345
350
  }
346
351
  channels.clear();
347
-
352
+
348
353
  currentIdentity = null;
349
354
  }
350
-
355
+
351
356
  return {
352
- get identity() { return currentIdentity; },
357
+ get identity() {
358
+ return currentIdentity;
359
+ },
353
360
  setIdentity,
354
361
  getIdentity,
355
362
  createChannel,
@@ -372,11 +379,11 @@ function generateId(): string {
372
379
 
373
380
  /**
374
381
  * Attach Unum adapter to a Praxis engine
375
- *
382
+ *
376
383
  * Enables automatic event/fact broadcasting to connected channels.
377
384
  * This is a placeholder for future integration where the engine
378
385
  * would emit events that get broadcast to channels.
379
- *
386
+ *
380
387
  * @param _engine - The Praxis logic engine
381
388
  * @param _adapter - The Unum adapter
382
389
  * @param _channelId - The channel to broadcast to
package/src/registry.ts CHANGED
@@ -9,10 +9,7 @@ import type { Rule, Constraint, ConstraintViolation } from './dsl.js';
9
9
  /**
10
10
  * Registry for managing rules and constraints.
11
11
  */
12
- export class Registry<
13
- S extends PraxisState = PraxisState,
14
- E extends PraxisEvent = PraxisEvent
15
- > {
12
+ export class Registry<S extends PraxisState = PraxisState, E extends PraxisEvent = PraxisEvent> {
16
13
  private rules: Map<string, Rule<S, E>> = new Map();
17
14
  private constraints: Map<string, Constraint<S>> = new Map();
18
15
 
@@ -113,14 +110,12 @@ export class Registry<
113
110
  */
114
111
  evaluateRules(state: S, event: E): Effect[] {
115
112
  const effects: Effect[] = [];
116
-
113
+
117
114
  // Get rules that match the event type
118
115
  const applicableRules = this.getRulesForEvent(event.type);
119
-
116
+
120
117
  // Sort by priority (higher priority first)
121
- const sortedRules = applicableRules.sort(
122
- (a, b) => (b.priority ?? 0) - (a.priority ?? 0)
123
- );
118
+ const sortedRules = applicableRules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
124
119
 
125
120
  // Evaluate each rule
126
121
  for (const rule of sortedRules) {
@@ -149,9 +144,7 @@ export class Registry<
149
144
  if (!constraint.check(state)) {
150
145
  violations.push({
151
146
  constraintId: constraint.id,
152
- message:
153
- constraint.errorMessage ||
154
- `Constraint '${constraint.id}' violated`,
147
+ message: constraint.errorMessage || `Constraint '${constraint.id}' violated`,
155
148
  state,
156
149
  });
157
150
  }
@@ -198,7 +191,7 @@ export class Registry<
198
191
  rulesByEventType: Record<string, number>;
199
192
  } {
200
193
  const rulesByEventType: Record<string, number> = {};
201
-
194
+
202
195
  for (const rule of this.rules.values()) {
203
196
  const eventType = rule.eventType || '*';
204
197
  rulesByEventType[eventType] = (rulesByEventType[eventType] || 0) + 1;
@@ -217,7 +210,7 @@ export class Registry<
217
210
  */
218
211
  export function createRegistry<
219
212
  S extends PraxisState = PraxisState,
220
- E extends PraxisEvent = PraxisEvent
213
+ E extends PraxisEvent = PraxisEvent,
221
214
  >(): Registry<S, E> {
222
215
  return new Registry<S, E>();
223
216
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Terminal Node Runtime Adapter
3
- *
3
+ *
4
4
  * Handles terminal command execution and state management.
5
5
  * Integrates with pluresDB for state synchronization.
6
6
  */
@@ -82,23 +82,28 @@ async function defaultExecutor(
82
82
  const { exec } = await import('child_process');
83
83
  const { promisify } = await import('util');
84
84
  const execAsync = promisify(exec);
85
-
85
+
86
86
  // Get process.env safely (only available in Node.js environments)
87
- const processEnv = typeof process !== "undefined" ? process.env : {};
88
-
87
+ const processEnv = typeof process !== 'undefined' ? process.env : {};
88
+
89
89
  const result = await execAsync(command, {
90
90
  cwd: options.cwd,
91
91
  env: { ...processEnv, ...options.env },
92
92
  maxBuffer: 10 * 1024 * 1024, // 10MB buffer
93
93
  timeout: 60000, // 60 second timeout
94
94
  });
95
-
95
+
96
96
  return {
97
97
  output: result.stdout + (result.stderr ? `\n${result.stderr}` : ''),
98
98
  exitCode: 0,
99
99
  };
100
100
  } catch (error: unknown) {
101
- const execError = error as { stdout?: string; stderr?: string; code?: number; message?: string };
101
+ const execError = error as {
102
+ stdout?: string;
103
+ stderr?: string;
104
+ code?: number;
105
+ message?: string;
106
+ };
102
107
  return {
103
108
  output: (execError.stdout || '') + (execError.stderr || ''),
104
109
  exitCode: execError.code || 1,
@@ -109,7 +114,7 @@ async function defaultExecutor(
109
114
 
110
115
  /**
111
116
  * Terminal Runtime Adapter
112
- *
117
+ *
113
118
  * Manages terminal node execution and state.
114
119
  * Supports command execution with history tracking and PluresDB integration.
115
120
  */
@@ -137,22 +142,22 @@ export class TerminalAdapter {
137
142
 
138
143
  /**
139
144
  * Execute a terminal command
140
- *
145
+ *
141
146
  * @param command - Command to execute
142
147
  * @returns Execution result
143
148
  */
144
149
  async executeCommand(command: string): Promise<TerminalExecutionResult> {
145
150
  // Add to history
146
151
  this.state.history.push(command);
147
-
152
+
148
153
  const timestamp = Date.now();
149
-
154
+
150
155
  // Execute the command
151
156
  const { output, exitCode, error } = await this.executor(command, {
152
157
  cwd: this.state.cwd,
153
158
  env: this.state.env,
154
159
  });
155
-
160
+
156
161
  const result: TerminalExecutionResult = {
157
162
  command,
158
163
  output,
@@ -219,13 +224,13 @@ export class TerminalAdapter {
219
224
 
220
225
  /**
221
226
  * Sync state to PluresDB
222
- *
227
+ *
223
228
  * @param path - PluresDB path for storing results
224
229
  * @param data - Data to sync
225
230
  */
226
231
  private async syncToPluresDB(path: string, data: TerminalExecutionResult): Promise<void> {
227
232
  if (!this.db) return;
228
-
233
+
229
234
  try {
230
235
  // Store the execution result
231
236
  await this.db.set(path, {
@@ -233,7 +238,7 @@ export class TerminalAdapter {
233
238
  nodeId: this.state.nodeId,
234
239
  syncedAt: Date.now(),
235
240
  });
236
-
241
+
237
242
  // Also append to history path
238
243
  const historyPath = `${path}/history`;
239
244
  const historyKey = `${historyPath}/${data.timestamp}`;
@@ -248,7 +253,7 @@ export class TerminalAdapter {
248
253
  */
249
254
  async loadFromPluresDB(): Promise<void> {
250
255
  if (!this.db || !this.inputPath) return;
251
-
256
+
252
257
  try {
253
258
  const data = await this.db.get(this.inputPath);
254
259
  if (data && typeof data === 'object') {
@@ -276,7 +281,7 @@ export class TerminalAdapter {
276
281
  */
277
282
  watchInput(callback: (command: string) => void): (() => void) | null {
278
283
  if (!this.db || !this.inputPath) return null;
279
-
284
+
280
285
  return this.db.watch(this.inputPath, (data) => {
281
286
  if (data && typeof data === 'object' && 'command' in data) {
282
287
  callback((data as { command: string }).command);
@@ -287,19 +292,17 @@ export class TerminalAdapter {
287
292
 
288
293
  /**
289
294
  * Create a terminal adapter instance
290
- *
295
+ *
291
296
  * @param options - Terminal adapter options
292
297
  * @returns Terminal adapter instance
293
298
  */
294
- export function createTerminalAdapter(
295
- options: TerminalAdapterOptions
296
- ): TerminalAdapter {
299
+ export function createTerminalAdapter(options: TerminalAdapterOptions): TerminalAdapter {
297
300
  return new TerminalAdapter(options);
298
301
  }
299
302
 
300
303
  /**
301
304
  * Run a terminal command (convenience function)
302
- *
305
+ *
303
306
  * @param nodeId - Terminal node identifier
304
307
  * @param command - Command to execute
305
308
  * @param options - Additional options
@@ -308,13 +311,14 @@ export function createTerminalAdapter(
308
311
  export async function runTerminalCommand(
309
312
  nodeId: string,
310
313
  command: string,
311
- options?: { cwd?: string; env?: Record<string, string>; db?: PraxisDB }
314
+ options?: { cwd?: string; env?: Record<string, string>; db?: PraxisDB; executor?: CommandExecutor }
312
315
  ): Promise<TerminalExecutionResult> {
313
316
  const adapter = createTerminalAdapter({
314
317
  nodeId,
315
318
  cwd: options?.cwd,
316
319
  env: options?.env,
317
320
  db: options?.db,
321
+ executor: options?.executor,
318
322
  });
319
323
  return adapter.executeCommand(command);
320
324
  }
@@ -327,10 +331,11 @@ export function createMockExecutor(
327
331
  responses: Record<string, { output: string; exitCode: number; error?: string }>
328
332
  ): CommandExecutor {
329
333
  return async (command: string) => {
330
- const response = responses[command] || responses['*'] || {
331
- output: `Mock output for: ${command}`,
332
- exitCode: 0,
333
- };
334
+ const response = responses[command] ||
335
+ responses['*'] || {
336
+ output: `Mock output for: ${command}`,
337
+ exitCode: 0,
338
+ };
334
339
  return response;
335
340
  };
336
341
  }
package/src/step.ts CHANGED
@@ -11,7 +11,7 @@ import type { Registry } from './registry.js';
11
11
  */
12
12
  export interface StepOptions<
13
13
  S extends PraxisState = PraxisState,
14
- E extends PraxisEvent = PraxisEvent
14
+ E extends PraxisEvent = PraxisEvent,
15
15
  > {
16
16
  /** Registry containing rules and constraints */
17
17
  registry?: Registry<S, E>;
@@ -27,7 +27,7 @@ export interface StepOptions<
27
27
  */
28
28
  export function createStepFunction<
29
29
  S extends PraxisState = PraxisState,
30
- E extends PraxisEvent = PraxisEvent
30
+ E extends PraxisEvent = PraxisEvent,
31
31
  >(options: StepOptions<S, E> = {}): StepFunction<S, E> {
32
32
  const { registry, checkConstraints = true, reducer } = options;
33
33
 
@@ -38,9 +38,7 @@ export function createStepFunction<
38
38
  if (checkConstraints && registry) {
39
39
  const violations = registry.checkConstraints(state);
40
40
  if (violations.length > 0) {
41
- errors.push(
42
- ...violations.map((v) => `Pre-condition: ${v.message}`)
43
- );
41
+ errors.push(...violations.map((v) => `Pre-condition: ${v.message}`));
44
42
  // Return current state with errors
45
43
  return { state, errors };
46
44
  }
@@ -78,9 +76,7 @@ export function createStepFunction<
78
76
  if (checkConstraints && registry) {
79
77
  const violations = registry.checkConstraints(newState);
80
78
  if (violations.length > 0) {
81
- errors.push(
82
- ...violations.map((v) => `Post-condition: ${v.message}`)
83
- );
79
+ errors.push(...violations.map((v) => `Post-condition: ${v.message}`));
84
80
  // Return previous state with errors to maintain invariants
85
81
  return { state, errors };
86
82
  }
@@ -98,10 +94,9 @@ export function createStepFunction<
98
94
  * Simple step function that just applies a reducer.
99
95
  * Useful for basic state transitions without rules or constraints.
100
96
  */
101
- export function step<
102
- S extends PraxisState = PraxisState,
103
- E extends PraxisEvent = PraxisEvent
104
- >(reducer: (state: S, event: E) => S): StepFunction<S, E> {
97
+ export function step<S extends PraxisState = PraxisState, E extends PraxisEvent = PraxisEvent>(
98
+ reducer: (state: S, event: E) => S
99
+ ): StepFunction<S, E> {
105
100
  return (state: S, event: E): StepResult<S> => {
106
101
  try {
107
102
  const newState = reducer(state, event);
@@ -120,10 +115,9 @@ export function step<
120
115
  * Each step function is applied in sequence, with the output of one
121
116
  * becoming the input to the next.
122
117
  */
123
- export function compose<
124
- S extends PraxisState = PraxisState,
125
- E extends PraxisEvent = PraxisEvent
126
- >(...steps: StepFunction<S, E>[]): StepFunction<S, E> {
118
+ export function compose<S extends PraxisState = PraxisState, E extends PraxisEvent = PraxisEvent>(
119
+ ...steps: StepFunction<S, E>[]
120
+ ): StepFunction<S, E> {
127
121
  return (state: S, event: E): StepResult<S> => {
128
122
  let currentState = state;
129
123
  const allEffects: StepResult<S>['effects'] = [];
package/src/types.ts CHANGED
@@ -66,5 +66,5 @@ export interface Effect {
66
66
  */
67
67
  export type StepFunction<
68
68
  S extends PraxisState = PraxisState,
69
- E extends PraxisEvent = PraxisEvent
69
+ E extends PraxisEvent = PraxisEvent,
70
70
  > = (state: S, event: E) => StepResult<S>;