@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
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,690 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createPluresDBGenerator
4
+ } from "../chunk-RJMWCNHR.js";
5
+ import {
6
+ loadSchemaFromFile,
7
+ validateForGeneration
8
+ } from "../chunk-UY7YEBE2.js";
9
+ import "../chunk-UATVJBNV.js";
10
+ import {
11
+ createComponentGenerator
12
+ } from "../chunk-YXH4Y7ZZ.js";
13
+ import "../chunk-QGM4M3NI.js";
14
+
15
+ // src/cli/index.ts
16
+ import { Command } from "commander";
17
+
18
+ // src/cli/commands/generate.ts
19
+ import { mkdir, writeFile } from "fs/promises";
20
+ import { dirname, resolve } from "path";
21
+
22
+ // src/core/schema/normalize.ts
23
+ function normalizeSchema(schema, options = {}) {
24
+ const schemaPrefix = options.schemaPrefix || schema.name;
25
+ const normalizedModels = normalizeModels(schema.models || [], schemaPrefix, options);
26
+ const modelMap = new Map(normalizedModels.map((model) => [model.name, model]));
27
+ const normalizedComponents = normalizeComponents(
28
+ schema.components || [],
29
+ schemaPrefix,
30
+ modelMap,
31
+ options
32
+ );
33
+ const normalizedLogic = normalizeLogic(schema.logic || [], schemaPrefix, options);
34
+ return {
35
+ ...schema,
36
+ models: normalizedModels,
37
+ components: normalizedComponents,
38
+ logic: normalizedLogic
39
+ };
40
+ }
41
+ function normalizeModels(models, schemaPrefix, _options) {
42
+ return models.map((model) => {
43
+ const fullName = `${schemaPrefix}.${model.name}`;
44
+ const dependencies = extractModelDependencies(model);
45
+ const allFields = [...model.fields];
46
+ return {
47
+ ...model,
48
+ fullName,
49
+ allFields,
50
+ dependencies
51
+ };
52
+ });
53
+ }
54
+ function extractModelDependencies(model) {
55
+ const dependencies = /* @__PURE__ */ new Set();
56
+ for (const field of model.fields) {
57
+ if (typeof field.type === "object" && "reference" in field.type) {
58
+ dependencies.add(field.type.reference);
59
+ }
60
+ }
61
+ if (model.relationships) {
62
+ for (const rel of model.relationships) {
63
+ dependencies.add(rel.target);
64
+ }
65
+ }
66
+ return Array.from(dependencies);
67
+ }
68
+ function normalizeComponents(components, schemaPrefix, modelMap, _options) {
69
+ return components.map((component) => {
70
+ const fullName = `${schemaPrefix}.${component.name}`;
71
+ const resolvedModel = component.model ? modelMap.get(component.model) : void 0;
72
+ return {
73
+ ...component,
74
+ fullName,
75
+ resolvedModel
76
+ };
77
+ });
78
+ }
79
+ function normalizeLogic(logic, schemaPrefix, _options) {
80
+ return logic.map((logicDef) => {
81
+ const fullId = `${schemaPrefix}.${logicDef.id}`;
82
+ return {
83
+ ...logicDef,
84
+ fullId
85
+ };
86
+ });
87
+ }
88
+
89
+ // src/core/logic/generator.ts
90
+ var LogicGenerator = class {
91
+ options;
92
+ constructor(options) {
93
+ this.options = {
94
+ typescript: true,
95
+ includeDocs: true,
96
+ ...options
97
+ };
98
+ }
99
+ /**
100
+ * Generate all logic files from schema
101
+ */
102
+ generateLogic(schema) {
103
+ const files = [];
104
+ const allLogic = schema.logic || [];
105
+ if (allLogic.length === 0) {
106
+ files.push(this.generateFactsFile([]));
107
+ files.push(this.generateEventsFile([]));
108
+ files.push(this.generateRulesFile([]));
109
+ files.push(this.generateEngineFile(schema));
110
+ files.push(this.generateIndexFile());
111
+ return files;
112
+ }
113
+ const allFacts = allLogic.flatMap((logic) => logic.facts || []);
114
+ const allEvents = allLogic.flatMap((logic) => logic.events || []);
115
+ const allRules = allLogic.flatMap((logic) => logic.rules || []);
116
+ files.push(this.generateFactsFile(allFacts));
117
+ files.push(this.generateEventsFile(allEvents));
118
+ files.push(this.generateRulesFile(allRules));
119
+ files.push(this.generateEngineFile(schema));
120
+ files.push(this.generateIndexFile());
121
+ return files;
122
+ }
123
+ /**
124
+ * Generate facts.ts file
125
+ */
126
+ generateFactsFile(facts) {
127
+ const ext = this.options.typescript ? "ts" : "js";
128
+ const lines = [];
129
+ lines.push("import { defineFact } from '@plures/praxis';");
130
+ lines.push("");
131
+ if (this.options.includeDocs) {
132
+ lines.push("/**");
133
+ lines.push(" * Fact definitions");
134
+ lines.push(" */");
135
+ lines.push("");
136
+ }
137
+ if (facts.length === 0) {
138
+ lines.push("// No facts defined in schema");
139
+ lines.push("// Example:");
140
+ lines.push(
141
+ '// export const UserCreated = defineFact<"UserCreated", { userId: string }>("UserCreated");'
142
+ );
143
+ } else {
144
+ for (const fact of facts) {
145
+ if (this.options.includeDocs && fact.description) {
146
+ lines.push(`/** ${fact.description} */`);
147
+ }
148
+ const payloadType = this.generatePayloadType(fact.payload);
149
+ lines.push(
150
+ `export const ${fact.tag} = defineFact<"${fact.tag}", ${payloadType}>("${fact.tag}");`
151
+ );
152
+ lines.push("");
153
+ }
154
+ }
155
+ return {
156
+ path: `${this.options.outputDir}/facts.${ext}`,
157
+ content: lines.join("\n"),
158
+ type: "facts"
159
+ };
160
+ }
161
+ /**
162
+ * Generate events.ts file
163
+ */
164
+ generateEventsFile(events) {
165
+ const ext = this.options.typescript ? "ts" : "js";
166
+ const lines = [];
167
+ lines.push("import { defineEvent } from '@plures/praxis';");
168
+ lines.push("");
169
+ if (this.options.includeDocs) {
170
+ lines.push("/**");
171
+ lines.push(" * Event definitions");
172
+ lines.push(" */");
173
+ lines.push("");
174
+ }
175
+ if (events.length === 0) {
176
+ lines.push("// No events defined in schema");
177
+ lines.push("// Example:");
178
+ lines.push(
179
+ '// export const CreateUser = defineEvent<"CREATE_USER", { name: string; email: string }>("CREATE_USER");'
180
+ );
181
+ } else {
182
+ for (const event of events) {
183
+ if (this.options.includeDocs && event.description) {
184
+ lines.push(`/** ${event.description} */`);
185
+ }
186
+ const payloadType = this.generatePayloadType(event.payload);
187
+ lines.push(
188
+ `export const ${event.tag} = defineEvent<"${event.tag}", ${payloadType}>("${event.tag}");`
189
+ );
190
+ lines.push("");
191
+ }
192
+ }
193
+ return {
194
+ path: `${this.options.outputDir}/events.${ext}`,
195
+ content: lines.join("\n"),
196
+ type: "events"
197
+ };
198
+ }
199
+ /**
200
+ * Generate rules.ts file
201
+ */
202
+ generateRulesFile(rules) {
203
+ const ext = this.options.typescript ? "ts" : "js";
204
+ const lines = [];
205
+ lines.push("import { defineRule } from '@plures/praxis';");
206
+ lines.push("import * as Facts from './facts.js';");
207
+ lines.push("import * as Events from './events.js';");
208
+ lines.push("");
209
+ if (this.options.includeDocs) {
210
+ lines.push("/**");
211
+ lines.push(" * Rule definitions");
212
+ lines.push(" */");
213
+ lines.push("");
214
+ }
215
+ if (rules.length === 0) {
216
+ lines.push("// No rules defined in schema");
217
+ lines.push("// Example:");
218
+ lines.push("// export const createUserRule = defineRule({");
219
+ lines.push("// id: 'user.create',");
220
+ lines.push("// description: 'Create user on CREATE_USER event',");
221
+ lines.push("// impl: (state, events) => {");
222
+ lines.push("// const event = events.find(Events.CreateUser.is);");
223
+ lines.push("// if (event) {");
224
+ lines.push('// return [Facts.UserCreated.create({ userId: "new-id" })];');
225
+ lines.push("// }");
226
+ lines.push("// return [];");
227
+ lines.push("// },");
228
+ lines.push("// });");
229
+ lines.push("");
230
+ lines.push("export const rules = [];");
231
+ } else {
232
+ for (const rule of rules) {
233
+ if (this.options.includeDocs && rule.description) {
234
+ lines.push(`/** ${rule.description} */`);
235
+ }
236
+ lines.push(`export const ${this.sanitizeIdentifier(rule.id)}Rule = defineRule({`);
237
+ lines.push(` id: '${rule.id}',`);
238
+ lines.push(` description: '${rule.description}',`);
239
+ if (rule.priority !== void 0) {
240
+ lines.push(` priority: ${rule.priority},`);
241
+ }
242
+ const eventTriggers = rule.on || [];
243
+ const condition = rule.when || "true";
244
+ const action = rule.then;
245
+ lines.push(" impl: (state, events) => {");
246
+ if (eventTriggers.length > 0) {
247
+ lines.push(` // Filter for triggering events: ${eventTriggers.join(", ")}`);
248
+ lines.push(` const triggerEvents = events.filter(e => `);
249
+ lines.push(` [${eventTriggers.map((e) => `'${e}'`).join(", ")}].includes(e.tag)`);
250
+ lines.push(" );");
251
+ lines.push(" if (triggerEvents.length === 0) return [];");
252
+ lines.push("");
253
+ }
254
+ if (condition && condition !== "true") {
255
+ lines.push(` // Condition: ${condition}`);
256
+ lines.push(` // Implement condition logic here`);
257
+ lines.push("");
258
+ }
259
+ lines.push(` // Action: ${action}`);
260
+ const factMatch = action.match(/emit\s*\(\s*['"](\w+)['"]/);
261
+ if (factMatch) {
262
+ const factName = factMatch[1];
263
+ lines.push(` return [{ tag: '${factName}', payload: {} }];`);
264
+ } else if (action.includes("return")) {
265
+ lines.push(` ${action}`);
266
+ } else {
267
+ lines.push(" return [];");
268
+ }
269
+ lines.push(" },");
270
+ lines.push("});");
271
+ lines.push("");
272
+ }
273
+ lines.push("export const rules = [");
274
+ for (const rule of rules) {
275
+ lines.push(` ${this.sanitizeIdentifier(rule.id)}Rule,`);
276
+ }
277
+ lines.push("];");
278
+ }
279
+ return {
280
+ path: `${this.options.outputDir}/rules.${ext}`,
281
+ content: lines.join("\n"),
282
+ type: "rules"
283
+ };
284
+ }
285
+ /**
286
+ * Generate engine.ts file
287
+ */
288
+ generateEngineFile(schema) {
289
+ const ext = this.options.typescript ? "ts" : "js";
290
+ const lines = [];
291
+ lines.push("import { createPraxisEngine, PraxisRegistry } from '@plures/praxis';");
292
+ lines.push("import { rules } from './rules.js';");
293
+ lines.push("");
294
+ if (this.options.includeDocs) {
295
+ lines.push("/**");
296
+ lines.push(` * ${schema.name} Logic Engine`);
297
+ if (schema.description) {
298
+ lines.push(` * ${schema.description}`);
299
+ }
300
+ lines.push(" */");
301
+ lines.push("");
302
+ }
303
+ if (this.options.typescript) {
304
+ lines.push("/**");
305
+ lines.push(" * Application context type");
306
+ lines.push(" */");
307
+ lines.push("export interface AppContext {");
308
+ if (schema.models && schema.models.length > 0) {
309
+ for (const model of schema.models) {
310
+ lines.push(` ${model.name.toLowerCase()}s: ${model.name}[];`);
311
+ }
312
+ } else {
313
+ lines.push(" // Add your context properties here");
314
+ }
315
+ lines.push("}");
316
+ lines.push("");
317
+ if (schema.models && schema.models.length > 0) {
318
+ for (const model of schema.models) {
319
+ lines.push(`export interface ${model.name} {`);
320
+ for (const field of model.fields) {
321
+ const optional = field.optional ? "?" : "";
322
+ const type = this.mapFieldType(field.type);
323
+ lines.push(` ${field.name}${optional}: ${type};`);
324
+ }
325
+ lines.push("}");
326
+ lines.push("");
327
+ }
328
+ }
329
+ }
330
+ lines.push("/**");
331
+ lines.push(" * Create the logic engine");
332
+ lines.push(" */");
333
+ lines.push("export function createEngine() {");
334
+ lines.push(" const registry = new PraxisRegistry<AppContext>();");
335
+ lines.push("");
336
+ lines.push(" // Register all rules");
337
+ lines.push(" for (const rule of rules) {");
338
+ lines.push(" registry.registerRule(rule);");
339
+ lines.push(" }");
340
+ lines.push("");
341
+ lines.push(" // Create engine with initial context");
342
+ lines.push(" const initialContext: AppContext = {");
343
+ if (schema.models && schema.models.length > 0) {
344
+ for (const model of schema.models) {
345
+ lines.push(` ${model.name.toLowerCase()}s: [],`);
346
+ }
347
+ } else {
348
+ lines.push(" // Initialize your context here");
349
+ }
350
+ lines.push(" };");
351
+ lines.push("");
352
+ lines.push(" return createPraxisEngine({");
353
+ lines.push(" initialContext,");
354
+ lines.push(" registry,");
355
+ lines.push(" });");
356
+ lines.push("}");
357
+ return {
358
+ path: `${this.options.outputDir}/engine.${ext}`,
359
+ content: lines.join("\n"),
360
+ type: "engine"
361
+ };
362
+ }
363
+ /**
364
+ * Generate index.ts file
365
+ */
366
+ generateIndexFile() {
367
+ const ext = this.options.typescript ? "ts" : "js";
368
+ const lines = [];
369
+ lines.push("export * from './facts.js';");
370
+ lines.push("export * from './events.js';");
371
+ lines.push("export * from './rules.js';");
372
+ lines.push("export * from './engine.js';");
373
+ return {
374
+ path: `${this.options.outputDir}/index.${ext}`,
375
+ content: lines.join("\n"),
376
+ type: "index"
377
+ };
378
+ }
379
+ /**
380
+ * Generate TypeScript type from payload definition
381
+ */
382
+ generatePayloadType(payload) {
383
+ const fields = Object.entries(payload).map(([key, type]) => `${key}: ${type}`).join("; ");
384
+ return `{ ${fields} }`;
385
+ }
386
+ /**
387
+ * Map field type to TypeScript type
388
+ */
389
+ mapFieldType(type) {
390
+ if (typeof type === "string") {
391
+ switch (type) {
392
+ case "string":
393
+ return "string";
394
+ case "number":
395
+ return "number";
396
+ case "boolean":
397
+ return "boolean";
398
+ case "date":
399
+ return "Date";
400
+ case "array":
401
+ return "unknown[]";
402
+ case "object":
403
+ return "Record<string, unknown>";
404
+ default:
405
+ return "unknown";
406
+ }
407
+ }
408
+ if (typeof type === "object") {
409
+ if ("array" in type) {
410
+ const innerType = this.mapFieldType(type.array);
411
+ return `${innerType}[]`;
412
+ }
413
+ if ("reference" in type) {
414
+ return type.reference;
415
+ }
416
+ }
417
+ return "unknown";
418
+ }
419
+ /**
420
+ * Sanitize identifier for variable names
421
+ */
422
+ sanitizeIdentifier(id) {
423
+ return id.replace(/[^a-zA-Z0-9_]/g, "_");
424
+ }
425
+ };
426
+ function createLogicGenerator(outputDir, options) {
427
+ return new LogicGenerator({
428
+ outputDir,
429
+ ...options
430
+ });
431
+ }
432
+
433
+ // src/cli/commands/generate.ts
434
+ async function generate(options) {
435
+ try {
436
+ const schemaPath = options.schema || "./praxis.schema.js";
437
+ const resolvedSchemaPath = resolve(process.cwd(), schemaPath);
438
+ console.log(`Loading schema from: ${resolvedSchemaPath}`);
439
+ const loadResult = await loadSchemaFromFile(resolvedSchemaPath, {
440
+ validate: true
441
+ });
442
+ if (loadResult.errors.length > 0) {
443
+ console.error("\u274C Failed to load schema:");
444
+ loadResult.errors.forEach((error) => console.error(` - ${error}`));
445
+ process.exit(1);
446
+ }
447
+ if (!loadResult.schema) {
448
+ console.error("\u274C No schema found");
449
+ process.exit(1);
450
+ }
451
+ const generationValidation = validateForGeneration(loadResult.schema);
452
+ if (!generationValidation.valid) {
453
+ console.error("\u274C Schema validation failed:");
454
+ generationValidation.errors.forEach((error) => console.error(` - ${error.message}`));
455
+ process.exit(1);
456
+ }
457
+ console.log("\u2713 Schema loaded successfully");
458
+ console.log("Normalizing schema...");
459
+ const normalizedSchema = normalizeSchema(loadResult.schema);
460
+ console.log("\u2713 Schema normalized");
461
+ const outputDir = options.output || "./generated";
462
+ const resolvedOutputDir = resolve(process.cwd(), outputDir);
463
+ const target = options.target || "all";
464
+ let generatedFiles = 0;
465
+ if (target === "all" || target === "logic") {
466
+ console.log("\nGenerating logic module...");
467
+ const logicOutputDir = `${resolvedOutputDir}/logic`;
468
+ await generateLogic(normalizedSchema, logicOutputDir);
469
+ generatedFiles += 5;
470
+ console.log(`\u2713 Logic module generated in ${logicOutputDir}`);
471
+ }
472
+ if (target === "all" || target === "components") {
473
+ console.log("\nGenerating components...");
474
+ const componentsOutputDir = `${resolvedOutputDir}/components`;
475
+ const componentCount = await generateComponents(normalizedSchema, componentsOutputDir);
476
+ generatedFiles += componentCount;
477
+ console.log(`\u2713 ${componentCount} components generated in ${componentsOutputDir}`);
478
+ }
479
+ if (target === "all" || target === "pluresdb") {
480
+ console.log("\nGenerating PluresDB configuration...");
481
+ const dbOutputDir = resolvedOutputDir;
482
+ await generatePluresDB(normalizedSchema, dbOutputDir, options.autoIndex);
483
+ generatedFiles += 1;
484
+ console.log(`\u2713 PluresDB config generated in ${dbOutputDir}`);
485
+ }
486
+ console.log(`
487
+ \u2705 Generation complete! ${generatedFiles} files generated.`);
488
+ if (options.watch) {
489
+ console.log("\n\u{1F440} Watching for changes...");
490
+ console.log("(Watch mode not yet implemented)");
491
+ }
492
+ } catch (error) {
493
+ console.error("\u274C Generation failed:");
494
+ if (error instanceof Error) {
495
+ console.error(error.message);
496
+ if (process.env.DEBUG) {
497
+ console.error(error.stack);
498
+ }
499
+ } else {
500
+ console.error("Unknown error");
501
+ }
502
+ process.exit(1);
503
+ }
504
+ }
505
+ async function generateLogic(schema, outputDir) {
506
+ const generator = createLogicGenerator(outputDir);
507
+ const files = generator.generateLogic(schema);
508
+ for (const file of files) {
509
+ await ensureDir(dirname(file.path));
510
+ await writeFile(file.path, file.content, "utf-8");
511
+ }
512
+ }
513
+ async function generateComponents(schema, outputDir) {
514
+ if (!schema.components || schema.components.length === 0) {
515
+ console.log(" No components defined in schema");
516
+ return 0;
517
+ }
518
+ const generator = createComponentGenerator(outputDir, {
519
+ typescript: true,
520
+ includeTests: false,
521
+ includeDocs: true
522
+ });
523
+ let fileCount = 0;
524
+ for (const component of schema.components) {
525
+ const model = component.resolvedModel || void 0;
526
+ const result = generator.generateComponent(component, model);
527
+ if (!result.success) {
528
+ console.error(` \u26A0\uFE0F Failed to generate ${component.name}:`);
529
+ result.errors.forEach((error) => console.error(` - ${error.message}`));
530
+ continue;
531
+ }
532
+ for (const file of result.files) {
533
+ await ensureDir(dirname(file.path));
534
+ await writeFile(file.path, file.content, "utf-8");
535
+ fileCount++;
536
+ }
537
+ }
538
+ return fileCount;
539
+ }
540
+ async function generatePluresDB(schema, outputDir, autoIndex) {
541
+ const generator = createPluresDBGenerator(outputDir, {
542
+ dbName: schema.name.toLowerCase(),
543
+ enableSync: false,
544
+ autoIndex: autoIndex || "all"
545
+ });
546
+ const files = generator.generateConfig(schema);
547
+ for (const file of files) {
548
+ await ensureDir(dirname(file.path));
549
+ await writeFile(file.path, file.content, "utf-8");
550
+ }
551
+ }
552
+ async function ensureDir(dir) {
553
+ try {
554
+ await mkdir(dir, { recursive: true });
555
+ } catch (error) {
556
+ if (error.code !== "EEXIST") {
557
+ throw error;
558
+ }
559
+ }
560
+ }
561
+
562
+ // src/cli/index.ts
563
+ var program = new Command();
564
+ program.name("praxis").description("Praxis Framework - Full-stack application development").version("0.2.1");
565
+ program.command("login").description("Authenticate with GitHub for Praxis Cloud access").option("--token <token>", "Use a personal access token instead of device flow").action(async (options) => {
566
+ try {
567
+ const { loginCommand } = await import("../auth-STARLY7I.js");
568
+ await loginCommand(options);
569
+ } catch (error) {
570
+ console.error("Error during login:", error);
571
+ process.exit(1);
572
+ }
573
+ });
574
+ program.command("logout").description("Log out from Praxis Cloud").action(async () => {
575
+ try {
576
+ const { logoutCommand } = await import("../auth-STARLY7I.js");
577
+ await logoutCommand();
578
+ } catch (error) {
579
+ console.error("Error during logout:", error);
580
+ process.exit(1);
581
+ }
582
+ });
583
+ program.command("whoami").description("Show current authenticated user").action(async () => {
584
+ try {
585
+ const { whoamiCommand } = await import("../auth-STARLY7I.js");
586
+ await whoamiCommand();
587
+ } catch (error) {
588
+ console.error("Error checking authentication:", error);
589
+ process.exit(1);
590
+ }
591
+ });
592
+ program.command("create <type> [name]").description("Create a new Praxis project or component").option("-t, --template <template>", "Template to use", "basic").option("-d, --directory <dir>", "Output directory").option("--features <features...>", "Features to include").action(async (type, name, options) => {
593
+ try {
594
+ const { create } = await import("../create-TRLSVCNQ.js");
595
+ await create(type, name, options);
596
+ } catch (error) {
597
+ console.error("Error creating:", error);
598
+ process.exit(1);
599
+ }
600
+ });
601
+ program.command("generate").description("Generate code from schemas").option("-s, --schema <file>", "Schema file path").option("-t, --target <target>", "Generation target (all, logic, components, pluresdb)", "all").option("-o, --output <dir>", "Output directory", "./generated").option("-w, --watch", "Watch for changes").option(
602
+ "--auto-index <strategy>",
603
+ "Auto-indexing strategy for PluresDB (all, explicit, none)",
604
+ "all"
605
+ ).action(async (options) => {
606
+ await generate(options);
607
+ });
608
+ program.command("canvas [schema]").description("Open CodeCanvas for visual editing").option("-p, --port <port>", "Port for Canvas server", "3000").option("-m, --mode <mode>", "Mode (edit, view, present)", "edit").option("-e, --export <format>", "Export format (yaml, mermaid, json)").option("-o, --output <file>", "Output file for export").action(async (schema, options) => {
609
+ try {
610
+ const { canvas } = await import("../canvas-UERZHJYW.js");
611
+ await canvas(schema, options);
612
+ } catch (error) {
613
+ console.error("Error with canvas:", error);
614
+ process.exit(1);
615
+ }
616
+ });
617
+ program.command("orchestrate").description("Manage orchestration and distributed coordination").option("-c, --config <file>", "Orchestration configuration file").option("-n, --nodes <count>", "Number of nodes", "1").option("-a, --action <action>", "Action (init, start, stop, status)", "status").action(async (options) => {
618
+ try {
619
+ const { orchestrate } = await import("../orchestrate-737TCL5H.js");
620
+ await orchestrate(options);
621
+ } catch (error) {
622
+ console.error("Error with orchestration:", error);
623
+ process.exit(1);
624
+ }
625
+ });
626
+ program.command("dev").description("Start development server").option("-p, --port <port>", "Port number", "5173").option("-h, --host <host>", "Host to bind to", "localhost").option("-o, --open", "Open browser").action(async (options) => {
627
+ try {
628
+ const { dev } = await import("../dev-PMJZUYGE.js");
629
+ await dev(options);
630
+ } catch (error) {
631
+ console.error("Error starting dev server:", error);
632
+ process.exit(1);
633
+ }
634
+ });
635
+ program.command("build").description("Build application for production").option("-o, --output <dir>", "Output directory", "./dist").option("--target <target>", "Build target (web, desktop, mobile)", "web").option("--minify", "Minify output", true).option("--sourcemap", "Generate source maps", false).action(async (options) => {
636
+ try {
637
+ const { build } = await import("../build-Y7OT5VBF.js");
638
+ await build(options);
639
+ } catch (error) {
640
+ console.error("Error building:", error);
641
+ process.exit(1);
642
+ }
643
+ });
644
+ var cloudCmd = program.command("cloud").description("Manage Praxis Cloud connection and synchronization");
645
+ cloudCmd.command("init").description("Connect to Praxis Cloud (setup wizard)").option("-e, --endpoint <url>", "Azure Function App endpoint URL").option("-a, --app-id <id>", "Application identifier").option("--auto-sync", "Enable automatic synchronization", false).option("--interval <ms>", "Sync interval in milliseconds", "5000").action(async (options) => {
646
+ try {
647
+ const { cloudInit } = await import("../cloud-AXOK4PSN.js");
648
+ await cloudInit(options);
649
+ } catch (error) {
650
+ console.error("Error initializing cloud connection:", error);
651
+ process.exit(1);
652
+ }
653
+ });
654
+ cloudCmd.command("status").description("Check Praxis Cloud connection status").action(async () => {
655
+ try {
656
+ const { cloudStatus } = await import("../cloud-AXOK4PSN.js");
657
+ await cloudStatus();
658
+ } catch (error) {
659
+ console.error("Error checking cloud status:", error);
660
+ process.exit(1);
661
+ }
662
+ });
663
+ cloudCmd.command("sync").description("Manually trigger cloud synchronization").action(async () => {
664
+ try {
665
+ const { cloudSync } = await import("../cloud-AXOK4PSN.js");
666
+ await cloudSync();
667
+ } catch (error) {
668
+ console.error("Error syncing to cloud:", error);
669
+ process.exit(1);
670
+ }
671
+ });
672
+ cloudCmd.command("usage").description("View cloud usage metrics").action(async () => {
673
+ try {
674
+ const { cloudUsage } = await import("../cloud-AXOK4PSN.js");
675
+ await cloudUsage();
676
+ } catch (error) {
677
+ console.error("Error retrieving usage metrics:", error);
678
+ process.exit(1);
679
+ }
680
+ });
681
+ program.command("verify <type>").description("Verify project implementation (e.g., implementation)").option("-d, --detailed", "Show detailed analysis").action(async (type, options) => {
682
+ try {
683
+ const { verify } = await import("../verify-YBZ7W24H.js");
684
+ await verify(type, options);
685
+ } catch (error) {
686
+ console.error("Error verifying:", error);
687
+ process.exit(1);
688
+ }
689
+ });
690
+ program.parse();