@plures/praxis 1.0.2 → 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.
- package/FRAMEWORK.md +55 -5
- package/LICENSE +21 -21
- package/README.md +162 -375
- package/core/codegen/docs-generator.ts +5 -2
- package/core/codegen/index.ts +1 -1
- package/core/codegen/ts-generator.ts +15 -15
- package/core/db-adapter/index.ts +2 -2
- package/core/db-adapter/sync-engine.ts +17 -6
- package/core/logic-engine/engine.ts +1 -1
- package/core/logic-engine/index.ts +2 -2
- package/core/logic-engine/protocol.ts +1 -1
- package/core/logic-engine/psf-adapter.ts +8 -4
- package/core/logic-engine/rules.ts +1 -1
- package/core/schema-engine/compiler.ts +53 -11
- package/core/schema-engine/generator.ts +17 -7
- package/core/schema-engine/index.ts +2 -2
- package/core/schema-engine/psf.ts +12 -3
- package/core/schema-engine/types.ts +3 -11
- package/core/schema-engine/validator.ts +112 -22
- package/dist/browser/engine-BjdqxeXG.d.ts +333 -0
- package/dist/browser/index.d.ts +3004 -0
- package/dist/browser/index.js +2892 -0
- package/dist/{src → browser}/integrations/svelte.d.ts +19 -17
- package/dist/browser/integrations/svelte.js +298 -0
- package/dist/node/auth-STARLY7I.js +207 -0
- package/dist/node/build-Y7OT5VBF.js +144 -0
- package/dist/node/canvas-UERZHJYW.js +362 -0
- package/dist/node/chunk-DSDC2JWZ.js +256 -0
- package/dist/node/chunk-FXQZXAWF.js +175 -0
- package/dist/node/chunk-N5Y37EUV.js +202 -0
- package/dist/node/chunk-QGM4M3NI.js +37 -0
- package/dist/node/chunk-RJMWCNHR.js +175 -0
- package/dist/node/chunk-SRM3OPPM.js +404 -0
- package/dist/node/chunk-UATVJBNV.js +175 -0
- package/dist/node/chunk-UY7YEBE2.js +159 -0
- package/dist/node/chunk-XCY2VIFX.js +143 -0
- package/dist/node/chunk-YXH4Y7ZZ.js +349 -0
- package/dist/node/cli/index.cjs +217418 -0
- package/dist/node/cli/index.d.cts +1 -0
- package/dist/node/cli/index.d.ts +1 -0
- package/dist/node/cli/index.js +690 -0
- package/dist/node/cloud/index.cjs +1043 -0
- package/dist/node/cloud/index.d.cts +864 -0
- package/dist/node/cloud/index.d.ts +864 -0
- package/dist/node/cloud/index.js +456 -0
- package/dist/node/cloud-AXOK4PSN.js +212 -0
- package/dist/node/component.cjs +374 -0
- package/dist/node/component.d.cts +125 -0
- package/dist/{src/core/component/generator.d.ts → node/component.d.ts} +11 -8
- package/dist/node/component.js +9 -0
- package/dist/node/components/index.cjs +216 -0
- package/dist/node/components/index.d.cts +43 -0
- package/dist/{src → node}/components/index.d.ts +8 -8
- package/dist/node/components/index.js +7 -0
- package/dist/node/create-TRLSVCNQ.js +584 -0
- package/dist/node/dev-PMJZUYGE.js +65 -0
- package/dist/node/engine-1iqLe6_P.d.ts +214 -0
- package/dist/node/engine-CVJobhHm.d.cts +214 -0
- package/dist/node/index.cjs +3247 -0
- package/dist/node/index.d.cts +2579 -0
- package/dist/node/index.d.ts +2579 -0
- package/dist/node/index.js +2098 -0
- package/dist/node/integrations/svelte.cjs +330 -0
- package/dist/node/integrations/svelte.d.cts +309 -0
- package/dist/node/integrations/svelte.d.ts +309 -0
- package/dist/node/integrations/svelte.js +300 -0
- package/dist/node/orchestrate-737TCL5H.js +127 -0
- package/dist/{src/core/protocol.d.ts → node/protocol-Qek7ebBl.d.cts} +11 -10
- package/dist/node/protocol-Qek7ebBl.d.ts +122 -0
- package/dist/node/schema.cjs +200 -0
- package/dist/{src/core/schema/types.d.ts → node/schema.d.cts} +30 -29
- package/dist/node/schema.d.ts +371 -0
- package/dist/node/schema.js +9 -0
- package/dist/{src/runtime/terminal-adapter.d.ts → node/terminal-adapter-07HGftGQ.d.ts} +86 -11
- package/dist/node/terminal-adapter-XLtCjjb_.d.cts +231 -0
- package/dist/node/verify-YBZ7W24H.js +213239 -0
- package/docs/MONETIZATION.md +21 -16
- package/docs/REACTIVE_REDESIGN.md +132 -0
- package/docs/README.md +47 -36
- package/docs/SVELTE_INTEGRATION_STRATEGY.md +68 -0
- package/docs/TERMINAL_NODE.md +27 -24
- package/docs/core/building-extensions.md +58 -61
- package/docs/core/cli-usage.md +59 -59
- package/docs/core/code-canvas-sync.md +28 -16
- package/docs/core/logic-engine.md +77 -82
- package/docs/core/pluresdb-integration.md +29 -39
- package/docs/core/schema-model.md +66 -52
- package/docs/core/ui-generation.md +57 -49
- package/docs/core/what-is-praxis.md +32 -15
- package/docs/guides/canvas.md +21 -5
- package/docs/guides/getting-started.md +13 -7
- package/docs/guides/history-state-pattern.md +65 -51
- package/docs/guides/orchestration.md +46 -32
- package/docs/guides/parallel-state-pattern.md +56 -72
- package/docs/guides/svelte-integration.md +45 -53
- package/docs/tutorials/README.md +16 -0
- package/docs/tutorials/ecommerce-cart.md +177 -95
- package/docs/tutorials/first-app.md +26 -41
- package/docs/tutorials/form-builder.md +191 -138
- package/docs/tutorials/todo-pluresdb.md +71 -69
- package/package.json +132 -96
- package/src/__tests__/actors.test.ts +68 -68
- package/src/__tests__/billing.test.ts +32 -32
- package/src/__tests__/canvas-components.test.ts +94 -73
- package/src/__tests__/cli-create.test.ts +28 -28
- package/src/__tests__/cloud.test.ts +36 -36
- package/src/__tests__/code-canvas-integration.test.ts +132 -141
- package/src/__tests__/docs-generator.test.ts +3 -9
- package/src/__tests__/dsl.test.ts +58 -64
- package/src/__tests__/edge-cases.test.ts +106 -108
- package/src/__tests__/engine.test.ts +51 -25
- package/src/__tests__/generators.test.ts +42 -44
- package/src/__tests__/introspection.test.ts +104 -114
- package/src/__tests__/pluresdb.test.ts +189 -187
- package/src/__tests__/protocol.test.ts +15 -15
- package/src/__tests__/provisioning.test.ts +61 -61
- package/src/__tests__/schema.test.ts +7 -11
- package/src/__tests__/state-docs-integration.test.ts +162 -145
- package/src/__tests__/svelte-integration.test.ts +16 -19
- package/src/__tests__/tauri-integration.test.ts +149 -147
- package/src/__tests__/terminal-node.test.ts +12 -7
- package/src/__tests__/unum-integration.test.ts +68 -68
- package/src/adapters/cli.ts +21 -15
- package/src/cli/commands/auth.ts +82 -78
- package/src/cli/commands/build.ts +29 -27
- package/src/cli/commands/canvas.ts +338 -127
- package/src/cli/commands/cloud.ts +47 -47
- package/src/cli/commands/create.ts +59 -47
- package/src/cli/commands/dev.ts +12 -12
- package/src/cli/commands/generate.ts +29 -40
- package/src/cli/commands/orchestrate.ts +24 -24
- package/src/cli/commands/verify.ts +49 -0
- package/src/cli/index.ts +21 -2
- package/src/cloud/README.md +28 -15
- package/src/cloud/auth.ts +55 -70
- package/src/cloud/billing.ts +59 -58
- package/src/cloud/client.ts +29 -35
- package/src/cloud/index.ts +19 -40
- package/src/cloud/marketplace.ts +69 -78
- package/src/cloud/provisioning.ts +42 -51
- package/src/cloud/relay/endpoints.ts +30 -34
- package/src/cloud/relay/health/index.ts +1 -1
- package/src/cloud/relay/stats/index.ts +1 -1
- package/src/cloud/relay/sync/index.ts +1 -1
- package/src/cloud/relay/usage/index.ts +1 -1
- package/src/cloud/sponsors.ts +31 -34
- package/src/cloud/types.ts +4 -4
- package/src/components/README.md +1 -0
- package/src/components/TerminalNode.svelte +457 -457
- package/src/components/index.ts +3 -4
- package/src/core/actors.ts +7 -7
- package/src/core/component/generator.ts +10 -28
- package/src/core/engine.ts +51 -24
- package/src/core/introspection.ts +37 -35
- package/src/core/logic/generator.ts +62 -62
- package/src/core/pluresdb/adapter.ts +8 -8
- package/src/core/pluresdb/generator.ts +39 -35
- package/src/core/pluresdb/index.ts +9 -12
- package/src/core/pluresdb/schema-registry.ts +22 -25
- package/src/core/pluresdb/store.ts +57 -57
- package/src/core/protocol.ts +14 -14
- package/src/core/reactive-engine.svelte.ts +65 -0
- package/src/core/reactive-engine.ts +67 -0
- package/src/core/rules.ts +4 -4
- package/src/core/schema/loader.common.ts +150 -0
- package/src/core/schema/loader.ts +19 -149
- package/src/core/schema/normalize.ts +34 -51
- package/src/core/schema/types.ts +47 -11
- package/src/dsl/index.ts +8 -8
- package/src/dsl.ts +11 -17
- package/src/examples/advanced-todo/App.svelte +506 -506
- package/src/examples/advanced-todo/README.md +58 -40
- package/src/examples/advanced-todo/index.ts +3 -3
- package/src/examples/auth-basic/index.ts +30 -30
- package/src/examples/cart/index.ts +50 -50
- package/src/examples/hero-ecommerce/index.ts +130 -157
- package/src/examples/svelte-counter/index.ts +22 -26
- package/src/flows.ts +6 -17
- package/src/index.browser.ts +204 -0
- package/src/index.ts +37 -42
- package/src/integrations/code-canvas.ts +237 -193
- package/src/integrations/pluresdb.ts +55 -35
- package/src/integrations/state-docs.ts +104 -104
- package/src/integrations/svelte.ts +35 -35
- package/src/integrations/tauri.ts +75 -73
- package/src/integrations/unum.ts +68 -61
- package/src/registry.ts +7 -14
- package/src/runtime/terminal-adapter.ts +31 -26
- package/src/step.ts +10 -16
- package/src/types.ts +1 -1
- package/templates/basic-app/README.md +6 -9
- package/templates/fullstack-app/README.md +10 -0
- package/dist/core/codegen/docs-generator.d.ts +0 -123
- package/dist/core/codegen/docs-generator.d.ts.map +0 -1
- package/dist/core/codegen/docs-generator.js +0 -674
- package/dist/core/codegen/docs-generator.js.map +0 -1
- package/dist/core/codegen/index.d.ts +0 -11
- package/dist/core/codegen/index.d.ts.map +0 -1
- package/dist/core/codegen/index.js +0 -13
- package/dist/core/codegen/index.js.map +0 -1
- package/dist/core/codegen/ts-generator.d.ts +0 -8
- package/dist/core/codegen/ts-generator.d.ts.map +0 -1
- package/dist/core/codegen/ts-generator.js +0 -8
- package/dist/core/codegen/ts-generator.js.map +0 -1
- package/dist/core/db-adapter/index.d.ts +0 -18
- package/dist/core/db-adapter/index.d.ts.map +0 -1
- package/dist/core/db-adapter/index.js +0 -23
- package/dist/core/db-adapter/index.js.map +0 -1
- package/dist/core/db-adapter/sync-engine.d.ts +0 -180
- package/dist/core/db-adapter/sync-engine.d.ts.map +0 -1
- package/dist/core/db-adapter/sync-engine.js +0 -342
- package/dist/core/db-adapter/sync-engine.js.map +0 -1
- package/dist/core/logic-engine/engine.d.ts +0 -8
- package/dist/core/logic-engine/engine.d.ts.map +0 -1
- package/dist/core/logic-engine/engine.js +0 -8
- package/dist/core/logic-engine/engine.js.map +0 -1
- package/dist/core/logic-engine/index.d.ts +0 -16
- package/dist/core/logic-engine/index.d.ts.map +0 -1
- package/dist/core/logic-engine/index.js +0 -16
- package/dist/core/logic-engine/index.js.map +0 -1
- package/dist/core/logic-engine/protocol.d.ts +0 -7
- package/dist/core/logic-engine/protocol.d.ts.map +0 -1
- package/dist/core/logic-engine/protocol.js +0 -7
- package/dist/core/logic-engine/protocol.js.map +0 -1
- package/dist/core/logic-engine/psf-adapter.d.ts +0 -88
- package/dist/core/logic-engine/psf-adapter.d.ts.map +0 -1
- package/dist/core/logic-engine/psf-adapter.js +0 -207
- package/dist/core/logic-engine/psf-adapter.js.map +0 -1
- package/dist/core/logic-engine/rules.d.ts +0 -7
- package/dist/core/logic-engine/rules.d.ts.map +0 -1
- package/dist/core/logic-engine/rules.js +0 -7
- package/dist/core/logic-engine/rules.js.map +0 -1
- package/dist/core/schema-engine/compiler.d.ts +0 -198
- package/dist/core/schema-engine/compiler.d.ts.map +0 -1
- package/dist/core/schema-engine/compiler.js +0 -262
- package/dist/core/schema-engine/compiler.js.map +0 -1
- package/dist/core/schema-engine/generator.d.ts +0 -115
- package/dist/core/schema-engine/generator.d.ts.map +0 -1
- package/dist/core/schema-engine/generator.js +0 -506
- package/dist/core/schema-engine/generator.js.map +0 -1
- package/dist/core/schema-engine/index.d.ts +0 -18
- package/dist/core/schema-engine/index.d.ts.map +0 -1
- package/dist/core/schema-engine/index.js +0 -18
- package/dist/core/schema-engine/index.js.map +0 -1
- package/dist/core/schema-engine/psf.d.ts +0 -612
- package/dist/core/schema-engine/psf.d.ts.map +0 -1
- package/dist/core/schema-engine/psf.js +0 -45
- package/dist/core/schema-engine/psf.js.map +0 -1
- package/dist/core/schema-engine/types.d.ts +0 -10
- package/dist/core/schema-engine/types.d.ts.map +0 -1
- package/dist/core/schema-engine/types.js +0 -7
- package/dist/core/schema-engine/types.js.map +0 -1
- package/dist/core/schema-engine/validator.d.ts +0 -140
- package/dist/core/schema-engine/validator.d.ts.map +0 -1
- package/dist/core/schema-engine/validator.js +0 -407
- package/dist/core/schema-engine/validator.js.map +0 -1
- package/dist/src/adapters/cli.d.ts +0 -43
- package/dist/src/adapters/cli.d.ts.map +0 -1
- package/dist/src/adapters/cli.js +0 -126
- package/dist/src/adapters/cli.js.map +0 -1
- package/dist/src/cli/commands/auth.d.ts +0 -26
- package/dist/src/cli/commands/auth.d.ts.map +0 -1
- package/dist/src/cli/commands/auth.js +0 -233
- package/dist/src/cli/commands/auth.js.map +0 -1
- package/dist/src/cli/commands/build.d.ts +0 -23
- package/dist/src/cli/commands/build.d.ts.map +0 -1
- package/dist/src/cli/commands/build.js +0 -162
- package/dist/src/cli/commands/build.js.map +0 -1
- package/dist/src/cli/commands/canvas.d.ts +0 -23
- package/dist/src/cli/commands/canvas.d.ts.map +0 -1
- package/dist/src/cli/commands/canvas.js +0 -215
- package/dist/src/cli/commands/canvas.js.map +0 -1
- package/dist/src/cli/commands/cloud.d.ts +0 -27
- package/dist/src/cli/commands/cloud.d.ts.map +0 -1
- package/dist/src/cli/commands/cloud.js +0 -232
- package/dist/src/cli/commands/cloud.js.map +0 -1
- package/dist/src/cli/commands/create.d.ts +0 -21
- package/dist/src/cli/commands/create.d.ts.map +0 -1
- package/dist/src/cli/commands/create.js +0 -621
- package/dist/src/cli/commands/create.js.map +0 -1
- package/dist/src/cli/commands/dev.d.ts +0 -21
- package/dist/src/cli/commands/dev.d.ts.map +0 -1
- package/dist/src/cli/commands/dev.js +0 -71
- package/dist/src/cli/commands/dev.js.map +0 -1
- package/dist/src/cli/commands/generate.d.ts +0 -25
- package/dist/src/cli/commands/generate.d.ts.map +0 -1
- package/dist/src/cli/commands/generate.js +0 -168
- package/dist/src/cli/commands/generate.js.map +0 -1
- package/dist/src/cli/commands/orchestrate.d.ts +0 -44
- package/dist/src/cli/commands/orchestrate.d.ts.map +0 -1
- package/dist/src/cli/commands/orchestrate.js +0 -150
- package/dist/src/cli/commands/orchestrate.js.map +0 -1
- package/dist/src/cli/index.d.ts +0 -8
- package/dist/src/cli/index.d.ts.map +0 -1
- package/dist/src/cli/index.js +0 -211
- package/dist/src/cli/index.js.map +0 -1
- package/dist/src/cloud/auth.d.ts +0 -51
- package/dist/src/cloud/auth.d.ts.map +0 -1
- package/dist/src/cloud/auth.js +0 -194
- package/dist/src/cloud/auth.js.map +0 -1
- package/dist/src/cloud/billing.d.ts +0 -184
- package/dist/src/cloud/billing.d.ts.map +0 -1
- package/dist/src/cloud/billing.js +0 -179
- package/dist/src/cloud/billing.js.map +0 -1
- package/dist/src/cloud/client.d.ts +0 -39
- package/dist/src/cloud/client.d.ts.map +0 -1
- package/dist/src/cloud/client.js +0 -176
- package/dist/src/cloud/client.js.map +0 -1
- package/dist/src/cloud/index.d.ts +0 -44
- package/dist/src/cloud/index.d.ts.map +0 -1
- package/dist/src/cloud/index.js +0 -44
- package/dist/src/cloud/index.js.map +0 -1
- package/dist/src/cloud/marketplace.d.ts +0 -166
- package/dist/src/cloud/marketplace.d.ts.map +0 -1
- package/dist/src/cloud/marketplace.js +0 -159
- package/dist/src/cloud/marketplace.js.map +0 -1
- package/dist/src/cloud/provisioning.d.ts +0 -110
- package/dist/src/cloud/provisioning.d.ts.map +0 -1
- package/dist/src/cloud/provisioning.js +0 -148
- package/dist/src/cloud/provisioning.js.map +0 -1
- package/dist/src/cloud/relay/endpoints.d.ts +0 -62
- package/dist/src/cloud/relay/endpoints.d.ts.map +0 -1
- package/dist/src/cloud/relay/endpoints.js +0 -217
- package/dist/src/cloud/relay/endpoints.js.map +0 -1
- package/dist/src/cloud/relay/health/index.d.ts +0 -5
- package/dist/src/cloud/relay/health/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/health/index.js +0 -9
- package/dist/src/cloud/relay/health/index.js.map +0 -1
- package/dist/src/cloud/relay/stats/index.d.ts +0 -5
- package/dist/src/cloud/relay/stats/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/stats/index.js +0 -9
- package/dist/src/cloud/relay/stats/index.js.map +0 -1
- package/dist/src/cloud/relay/sync/index.d.ts +0 -5
- package/dist/src/cloud/relay/sync/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/sync/index.js +0 -9
- package/dist/src/cloud/relay/sync/index.js.map +0 -1
- package/dist/src/cloud/relay/usage/index.d.ts +0 -5
- package/dist/src/cloud/relay/usage/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/usage/index.js +0 -9
- package/dist/src/cloud/relay/usage/index.js.map +0 -1
- package/dist/src/cloud/sponsors.d.ts +0 -81
- package/dist/src/cloud/sponsors.d.ts.map +0 -1
- package/dist/src/cloud/sponsors.js +0 -130
- package/dist/src/cloud/sponsors.js.map +0 -1
- package/dist/src/cloud/types.d.ts +0 -169
- package/dist/src/cloud/types.d.ts.map +0 -1
- package/dist/src/cloud/types.js +0 -7
- package/dist/src/cloud/types.js.map +0 -1
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/components/index.js +0 -17
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/core/actors.d.ts +0 -95
- package/dist/src/core/actors.d.ts.map +0 -1
- package/dist/src/core/actors.js +0 -158
- package/dist/src/core/actors.js.map +0 -1
- package/dist/src/core/component/generator.d.ts.map +0 -1
- package/dist/src/core/component/generator.js +0 -349
- package/dist/src/core/component/generator.js.map +0 -1
- package/dist/src/core/engine.d.ts +0 -92
- package/dist/src/core/engine.d.ts.map +0 -1
- package/dist/src/core/engine.js +0 -199
- package/dist/src/core/engine.js.map +0 -1
- package/dist/src/core/introspection.d.ts +0 -141
- package/dist/src/core/introspection.d.ts.map +0 -1
- package/dist/src/core/introspection.js +0 -208
- package/dist/src/core/introspection.js.map +0 -1
- package/dist/src/core/logic/generator.d.ts +0 -76
- package/dist/src/core/logic/generator.d.ts.map +0 -1
- package/dist/src/core/logic/generator.js +0 -370
- package/dist/src/core/logic/generator.js.map +0 -1
- package/dist/src/core/pluresdb/adapter.d.ts +0 -72
- package/dist/src/core/pluresdb/adapter.d.ts.map +0 -1
- package/dist/src/core/pluresdb/adapter.js +0 -73
- package/dist/src/core/pluresdb/adapter.js.map +0 -1
- package/dist/src/core/pluresdb/generator.d.ts +0 -58
- package/dist/src/core/pluresdb/generator.d.ts.map +0 -1
- package/dist/src/core/pluresdb/generator.js +0 -191
- package/dist/src/core/pluresdb/generator.js.map +0 -1
- package/dist/src/core/pluresdb/index.d.ts +0 -15
- package/dist/src/core/pluresdb/index.d.ts.map +0 -1
- package/dist/src/core/pluresdb/index.js +0 -11
- package/dist/src/core/pluresdb/index.js.map +0 -1
- package/dist/src/core/pluresdb/schema-registry.d.ts +0 -104
- package/dist/src/core/pluresdb/schema-registry.d.ts.map +0 -1
- package/dist/src/core/pluresdb/schema-registry.js +0 -130
- package/dist/src/core/pluresdb/schema-registry.js.map +0 -1
- package/dist/src/core/pluresdb/store.d.ts +0 -199
- package/dist/src/core/pluresdb/store.d.ts.map +0 -1
- package/dist/src/core/pluresdb/store.js +0 -344
- package/dist/src/core/pluresdb/store.js.map +0 -1
- package/dist/src/core/protocol.d.ts.map +0 -1
- package/dist/src/core/protocol.js +0 -46
- package/dist/src/core/protocol.js.map +0 -1
- package/dist/src/core/rules.d.ts +0 -120
- package/dist/src/core/rules.d.ts.map +0 -1
- package/dist/src/core/rules.js +0 -81
- package/dist/src/core/rules.js.map +0 -1
- package/dist/src/core/schema/loader.d.ts +0 -47
- package/dist/src/core/schema/loader.d.ts.map +0 -1
- package/dist/src/core/schema/loader.js +0 -189
- package/dist/src/core/schema/loader.js.map +0 -1
- package/dist/src/core/schema/normalize.d.ts +0 -72
- package/dist/src/core/schema/normalize.d.ts.map +0 -1
- package/dist/src/core/schema/normalize.js +0 -190
- package/dist/src/core/schema/normalize.js.map +0 -1
- package/dist/src/core/schema/types.d.ts.map +0 -1
- package/dist/src/core/schema/types.js +0 -161
- package/dist/src/core/schema/types.js.map +0 -1
- package/dist/src/dsl/index.d.ts +0 -152
- package/dist/src/dsl/index.d.ts.map +0 -1
- package/dist/src/dsl/index.js +0 -132
- package/dist/src/dsl/index.js.map +0 -1
- package/dist/src/dsl.d.ts +0 -124
- package/dist/src/dsl.d.ts.map +0 -1
- package/dist/src/dsl.js +0 -130
- package/dist/src/dsl.js.map +0 -1
- package/dist/src/examples/advanced-todo/index.d.ts +0 -55
- package/dist/src/examples/advanced-todo/index.d.ts.map +0 -1
- package/dist/src/examples/advanced-todo/index.js +0 -222
- package/dist/src/examples/advanced-todo/index.js.map +0 -1
- package/dist/src/examples/auth-basic/index.d.ts +0 -17
- package/dist/src/examples/auth-basic/index.d.ts.map +0 -1
- package/dist/src/examples/auth-basic/index.js +0 -122
- package/dist/src/examples/auth-basic/index.js.map +0 -1
- package/dist/src/examples/cart/index.d.ts +0 -19
- package/dist/src/examples/cart/index.d.ts.map +0 -1
- package/dist/src/examples/cart/index.js +0 -202
- package/dist/src/examples/cart/index.js.map +0 -1
- package/dist/src/examples/hero-ecommerce/index.d.ts +0 -39
- package/dist/src/examples/hero-ecommerce/index.d.ts.map +0 -1
- package/dist/src/examples/hero-ecommerce/index.js +0 -506
- package/dist/src/examples/hero-ecommerce/index.js.map +0 -1
- package/dist/src/examples/svelte-counter/index.d.ts +0 -31
- package/dist/src/examples/svelte-counter/index.d.ts.map +0 -1
- package/dist/src/examples/svelte-counter/index.js +0 -123
- package/dist/src/examples/svelte-counter/index.js.map +0 -1
- package/dist/src/flows.d.ts +0 -125
- package/dist/src/flows.d.ts.map +0 -1
- package/dist/src/flows.js +0 -160
- package/dist/src/flows.js.map +0 -1
- package/dist/src/index.d.ts +0 -77
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -64
- package/dist/src/index.js.map +0 -1
- package/dist/src/integrations/code-canvas.d.ts +0 -265
- package/dist/src/integrations/code-canvas.d.ts.map +0 -1
- package/dist/src/integrations/code-canvas.js +0 -451
- package/dist/src/integrations/code-canvas.js.map +0 -1
- package/dist/src/integrations/pluresdb.d.ts +0 -117
- package/dist/src/integrations/pluresdb.d.ts.map +0 -1
- package/dist/src/integrations/pluresdb.js +0 -117
- package/dist/src/integrations/pluresdb.js.map +0 -1
- package/dist/src/integrations/state-docs.d.ts +0 -191
- package/dist/src/integrations/state-docs.d.ts.map +0 -1
- package/dist/src/integrations/state-docs.js +0 -515
- package/dist/src/integrations/state-docs.js.map +0 -1
- package/dist/src/integrations/svelte.d.ts.map +0 -1
- package/dist/src/integrations/svelte.js +0 -447
- package/dist/src/integrations/svelte.js.map +0 -1
- package/dist/src/integrations/tauri.d.ts +0 -360
- package/dist/src/integrations/tauri.d.ts.map +0 -1
- package/dist/src/integrations/tauri.js +0 -278
- package/dist/src/integrations/tauri.js.map +0 -1
- package/dist/src/integrations/unum.d.ts +0 -159
- package/dist/src/integrations/unum.d.ts.map +0 -1
- package/dist/src/integrations/unum.js +0 -240
- package/dist/src/integrations/unum.js.map +0 -1
- package/dist/src/registry.d.ts +0 -94
- package/dist/src/registry.d.ts.map +0 -1
- package/dist/src/registry.js +0 -181
- package/dist/src/registry.js.map +0 -1
- package/dist/src/runtime/terminal-adapter.d.ts.map +0 -1
- package/dist/src/runtime/terminal-adapter.js +0 -239
- package/dist/src/runtime/terminal-adapter.js.map +0 -1
- package/dist/src/step.d.ts +0 -34
- package/dist/src/step.d.ts.map +0 -1
- package/dist/src/step.js +0 -111
- package/dist/src/step.js.map +0 -1
- package/dist/src/types.d.ts +0 -63
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -6
- package/dist/src/types.js.map +0 -1
- package/dist/tools/cli/commands/index.d.ts +0 -7
- package/dist/tools/cli/commands/index.d.ts.map +0 -1
- package/dist/tools/cli/commands/index.js +0 -7
- package/dist/tools/cli/commands/index.js.map +0 -1
- package/dist/tools/cli/index.d.ts +0 -8
- package/dist/tools/cli/index.d.ts.map +0 -1
- package/dist/tools/cli/index.js +0 -9
- package/dist/tools/cli/index.js.map +0 -1
- package/dist/tools/watcher/index.d.ts +0 -105
- package/dist/tools/watcher/index.d.ts.map +0 -1
- package/dist/tools/watcher/index.js +0 -213
- package/dist/tools/watcher/index.js.map +0 -1
- package/dist/ui/canvas/canvas-projection.d.ts +0 -78
- package/dist/ui/canvas/canvas-projection.d.ts.map +0 -1
- package/dist/ui/canvas/canvas-projection.js +0 -416
- package/dist/ui/canvas/canvas-projection.js.map +0 -1
- package/dist/ui/canvas/canvas-state.d.ts +0 -200
- package/dist/ui/canvas/canvas-state.d.ts.map +0 -1
- package/dist/ui/canvas/canvas-state.js +0 -464
- package/dist/ui/canvas/canvas-state.js.map +0 -1
- package/dist/ui/canvas/components/index.d.ts +0 -95
- package/dist/ui/canvas/components/index.d.ts.map +0 -1
- package/dist/ui/canvas/components/index.js +0 -19
- package/dist/ui/canvas/components/index.js.map +0 -1
- package/dist/ui/canvas/index.d.ts +0 -32
- package/dist/ui/canvas/index.d.ts.map +0 -1
- package/dist/ui/canvas/index.js +0 -32
- package/dist/ui/canvas/index.js.map +0 -1
- package/dist/ui/svelte-generator/index.d.ts +0 -9
- package/dist/ui/svelte-generator/index.d.ts.map +0 -1
- package/dist/ui/svelte-generator/index.js +0 -11
- package/dist/ui/svelte-generator/index.js.map +0 -1
- package/dist/ui/svelte-generator/psf-generator.d.ts +0 -128
- package/dist/ui/svelte-generator/psf-generator.d.ts.map +0 -1
- package/dist/ui/svelte-generator/psf-generator.js +0 -506
- package/dist/ui/svelte-generator/psf-generator.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Praxis Reactive Logic Engine
|
|
3
|
+
*
|
|
4
|
+
* A Svelte 5 native implementation of the Praxis Logic Engine.
|
|
5
|
+
* Uses Runes ($state, $derived, $effect) for fine-grained reactivity.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
console.log("Reactive Engine Loaded");
|
|
9
|
+
|
|
10
|
+
export interface ReactiveEngineOptions<TContext> {
|
|
11
|
+
initialContext: TContext;
|
|
12
|
+
initialFacts?: any[];
|
|
13
|
+
initialMeta?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ReactiveLogicEngine<TContext extends object> {
|
|
17
|
+
// The single source of truth, reactive by default
|
|
18
|
+
// We use $state.raw for things that shouldn't be deeply reactive if needed,
|
|
19
|
+
// but for context we usually want deep reactivity.
|
|
20
|
+
state = $state<{
|
|
21
|
+
context: TContext;
|
|
22
|
+
facts: any[];
|
|
23
|
+
meta: Record<string, unknown>;
|
|
24
|
+
}>({
|
|
25
|
+
context: {} as TContext,
|
|
26
|
+
facts: [],
|
|
27
|
+
meta: {}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
constructor(options: ReactiveEngineOptions<TContext>) {
|
|
31
|
+
this.state.context = options.initialContext;
|
|
32
|
+
this.state.facts = options.initialFacts ?? [];
|
|
33
|
+
this.state.meta = options.initialMeta ?? {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Access the reactive context directly.
|
|
38
|
+
* Consumers can use this in $derived() or $effect().
|
|
39
|
+
*/
|
|
40
|
+
get context() {
|
|
41
|
+
return this.state.context;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Access the reactive facts list.
|
|
46
|
+
*/
|
|
47
|
+
get facts() {
|
|
48
|
+
return this.state.facts;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Apply a mutation to the state.
|
|
53
|
+
* This is the "Action" or "Rule" equivalent.
|
|
54
|
+
*
|
|
55
|
+
* @param mutator A function that receives the state and modifies it.
|
|
56
|
+
*/
|
|
57
|
+
apply(mutator: (state: { context: TContext; facts: any[]; meta: Record<string, unknown> }) => void) {
|
|
58
|
+
mutator(this.state);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Access the reactive meta.
|
|
63
|
+
*/
|
|
64
|
+
get meta() {
|
|
65
|
+
return this.state.meta;
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/core/rules.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rules and Constraints System
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module defines the types and registry for rules and constraints.
|
|
5
5
|
* Rules and constraints are identified by stable IDs and can be described as data,
|
|
6
6
|
* making them portable across languages and suitable for DSL-based definitions.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { PraxisEvent, PraxisFact, PraxisState } from
|
|
9
|
+
import type { PraxisEvent, PraxisFact, PraxisState } from './protocol.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Unique identifier for a rule
|
|
@@ -21,7 +21,7 @@ export type ConstraintId = string;
|
|
|
21
21
|
/**
|
|
22
22
|
* A rule function derives new facts or transitions from context + input facts/events.
|
|
23
23
|
* Rules must be pure - no side effects.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* @param state Current Praxis state
|
|
26
26
|
* @param events Events to process
|
|
27
27
|
* @returns Array of new facts to add to the state
|
|
@@ -34,7 +34,7 @@ export type RuleFn<TContext = unknown> = (
|
|
|
34
34
|
/**
|
|
35
35
|
* A constraint function checks that an invariant holds.
|
|
36
36
|
* Constraints must be pure - no side effects.
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* @param state Current Praxis state
|
|
39
39
|
* @returns true if constraint is satisfied, false or error message if violated
|
|
40
40
|
*/
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Praxis Schema Loader (Common/Browser Compatible)
|
|
3
|
+
*
|
|
4
|
+
* Core schema loading and validation functions that don't depend on Node.js APIs.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { load as yamlLoad } from 'js-yaml';
|
|
8
|
+
import type { PraxisSchema, ValidationResult } from './types.js';
|
|
9
|
+
import { validateSchema } from './types.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Loader options
|
|
13
|
+
*/
|
|
14
|
+
export interface LoaderOptions {
|
|
15
|
+
/** Validate schema after loading */
|
|
16
|
+
validate?: boolean;
|
|
17
|
+
/** Base directory for resolving relative paths */
|
|
18
|
+
baseDir?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Loader result
|
|
23
|
+
*/
|
|
24
|
+
export interface LoaderResult {
|
|
25
|
+
/** Loaded schema */
|
|
26
|
+
schema?: PraxisSchema;
|
|
27
|
+
/** Validation result */
|
|
28
|
+
validation?: ValidationResult;
|
|
29
|
+
/** Load errors */
|
|
30
|
+
errors: string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create a new empty schema
|
|
35
|
+
*/
|
|
36
|
+
export function createSchema(name: string): PraxisSchema {
|
|
37
|
+
return {
|
|
38
|
+
version: '1.0.0',
|
|
39
|
+
name,
|
|
40
|
+
description: `Schema for ${name}`,
|
|
41
|
+
models: [],
|
|
42
|
+
components: [],
|
|
43
|
+
logic: [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Load schema from JSON string
|
|
49
|
+
*/
|
|
50
|
+
export function loadSchemaFromJson(json: string, options: LoaderOptions = {}): LoaderResult {
|
|
51
|
+
const errors: string[] = [];
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const schema = JSON.parse(json) as PraxisSchema;
|
|
55
|
+
|
|
56
|
+
// Validate if requested
|
|
57
|
+
let validation: ValidationResult | undefined;
|
|
58
|
+
if (options.validate !== false) {
|
|
59
|
+
validation = validateSchema(schema);
|
|
60
|
+
if (!validation.valid) {
|
|
61
|
+
errors.push('Schema validation failed:');
|
|
62
|
+
validation.errors.forEach((error) => {
|
|
63
|
+
errors.push(` ${error.path}: ${error.message}`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
schema,
|
|
70
|
+
validation,
|
|
71
|
+
errors,
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (error instanceof Error) {
|
|
75
|
+
errors.push(`Failed to parse JSON: ${error.message}`);
|
|
76
|
+
} else {
|
|
77
|
+
errors.push('Failed to parse JSON: Unknown error');
|
|
78
|
+
}
|
|
79
|
+
return { errors };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Load schema from YAML string
|
|
85
|
+
*/
|
|
86
|
+
export function loadSchemaFromYaml(yaml: string, options: LoaderOptions = {}): LoaderResult {
|
|
87
|
+
const errors: string[] = [];
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const schema = yamlLoad(yaml) as PraxisSchema;
|
|
91
|
+
|
|
92
|
+
// Validate if requested
|
|
93
|
+
let validation: ValidationResult | undefined;
|
|
94
|
+
if (options.validate !== false) {
|
|
95
|
+
validation = validateSchema(schema);
|
|
96
|
+
if (!validation.valid) {
|
|
97
|
+
errors.push('Schema validation failed:');
|
|
98
|
+
validation.errors.forEach((error) => {
|
|
99
|
+
errors.push(` ${error.path}: ${error.message}`);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
schema,
|
|
106
|
+
validation,
|
|
107
|
+
errors,
|
|
108
|
+
};
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (error instanceof Error) {
|
|
111
|
+
errors.push(`Failed to parse YAML: ${error.message}`);
|
|
112
|
+
} else {
|
|
113
|
+
errors.push('Failed to parse YAML: Unknown error');
|
|
114
|
+
}
|
|
115
|
+
return { errors };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Validate that a loaded schema has required fields for generation
|
|
121
|
+
*/
|
|
122
|
+
export function validateForGeneration(schema: PraxisSchema): ValidationResult {
|
|
123
|
+
const errors: string[] = [];
|
|
124
|
+
|
|
125
|
+
// Check for entities/models
|
|
126
|
+
if (!schema.models || schema.models.length === 0) {
|
|
127
|
+
errors.push('Schema must define at least one model for generation');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Check that models have valid fields
|
|
131
|
+
schema.models?.forEach((model, index) => {
|
|
132
|
+
if (!model.fields || model.fields.length === 0) {
|
|
133
|
+
errors.push(`Model "${model.name}" at index ${index} must have at least one field`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
model.fields?.forEach((field, fieldIndex) => {
|
|
137
|
+
if (!field.name) {
|
|
138
|
+
errors.push(`Field at index ${fieldIndex} in model "${model.name}" must have a name`);
|
|
139
|
+
}
|
|
140
|
+
if (!field.type) {
|
|
141
|
+
errors.push(`Field "${field.name}" in model "${model.name}" must have a type`);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
valid: errors.length === 0,
|
|
148
|
+
errors: errors.map((message) => ({ path: 'schema', message })),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Praxis Schema Loader
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Loads and validates Praxis schema files.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { readFile } from 'node:fs/promises';
|
|
8
8
|
import { pathToFileURL } from 'node:url';
|
|
9
|
-
import { load as yamlLoad } from 'js-yaml';
|
|
10
9
|
import type { PraxisSchema, ValidationResult } from './types.js';
|
|
11
10
|
import { validateSchema } from './types.js';
|
|
11
|
+
import {
|
|
12
|
+
loadSchemaFromJson,
|
|
13
|
+
loadSchemaFromYaml,
|
|
14
|
+
LoaderOptions,
|
|
15
|
+
LoaderResult,
|
|
16
|
+
} from './loader.common.js';
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export interface LoaderOptions {
|
|
17
|
-
/** Validate schema after loading */
|
|
18
|
-
validate?: boolean;
|
|
19
|
-
/** Base directory for resolving relative paths */
|
|
20
|
-
baseDir?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Loader result
|
|
25
|
-
*/
|
|
26
|
-
export interface LoaderResult {
|
|
27
|
-
/** Loaded schema */
|
|
28
|
-
schema?: PraxisSchema;
|
|
29
|
-
/** Validation result */
|
|
30
|
-
validation?: ValidationResult;
|
|
31
|
-
/** Load errors */
|
|
32
|
-
errors: string[];
|
|
33
|
-
}
|
|
18
|
+
// Re-export common functions
|
|
19
|
+
export * from './loader.common.js';
|
|
34
20
|
|
|
35
21
|
/**
|
|
36
22
|
* Load a Praxis schema from a file
|
|
@@ -40,20 +26,20 @@ export async function loadSchema(
|
|
|
40
26
|
options: LoaderOptions = {}
|
|
41
27
|
): Promise<LoaderResult> {
|
|
42
28
|
const errors: string[] = [];
|
|
43
|
-
|
|
29
|
+
|
|
44
30
|
try {
|
|
45
31
|
// Only .js files are supported. TypeScript schema files must be compiled to .js first.
|
|
46
32
|
// Use a compiled JavaScript file for your schema.
|
|
47
33
|
// Dynamic import is used, which works with .js files only.
|
|
48
|
-
|
|
34
|
+
|
|
49
35
|
// Convert to absolute URL for ES module import
|
|
50
36
|
let fileUrl = pathToFileURL(filePath).href;
|
|
51
|
-
|
|
37
|
+
|
|
52
38
|
// Attempt to import .ts or .js files directly. If import fails, error will be caught below.
|
|
53
|
-
|
|
39
|
+
|
|
54
40
|
// Dynamic import of the schema file
|
|
55
41
|
const module = await import(fileUrl);
|
|
56
|
-
|
|
42
|
+
|
|
57
43
|
// Look for common schema export names
|
|
58
44
|
let schema: PraxisSchema | undefined;
|
|
59
45
|
if (module.default) {
|
|
@@ -67,23 +53,20 @@ export async function loadSchema(
|
|
|
67
53
|
const exports = Object.values(module);
|
|
68
54
|
const possibleSchema = exports.find(
|
|
69
55
|
(exp): exp is PraxisSchema =>
|
|
70
|
-
typeof exp === 'object' &&
|
|
71
|
-
exp !== null &&
|
|
72
|
-
'version' in exp &&
|
|
73
|
-
'name' in exp
|
|
56
|
+
typeof exp === 'object' && exp !== null && 'version' in exp && 'name' in exp
|
|
74
57
|
);
|
|
75
58
|
if (possibleSchema) {
|
|
76
59
|
schema = possibleSchema;
|
|
77
60
|
}
|
|
78
61
|
}
|
|
79
|
-
|
|
62
|
+
|
|
80
63
|
if (!schema) {
|
|
81
64
|
errors.push(
|
|
82
65
|
'Schema file must export a PraxisSchema object (as default, schema, or appSchema)'
|
|
83
66
|
);
|
|
84
67
|
return { errors };
|
|
85
68
|
}
|
|
86
|
-
|
|
69
|
+
|
|
87
70
|
// Validate if requested
|
|
88
71
|
let validation: ValidationResult | undefined;
|
|
89
72
|
if (options.validate !== false) {
|
|
@@ -95,7 +78,7 @@ export async function loadSchema(
|
|
|
95
78
|
});
|
|
96
79
|
}
|
|
97
80
|
}
|
|
98
|
-
|
|
81
|
+
|
|
99
82
|
return {
|
|
100
83
|
schema,
|
|
101
84
|
validation,
|
|
@@ -111,83 +94,7 @@ export async function loadSchema(
|
|
|
111
94
|
}
|
|
112
95
|
}
|
|
113
96
|
|
|
114
|
-
/**
|
|
115
|
-
* Load schema from JSON string
|
|
116
|
-
*/
|
|
117
|
-
export function loadSchemaFromJson(
|
|
118
|
-
json: string,
|
|
119
|
-
options: LoaderOptions = {}
|
|
120
|
-
): LoaderResult {
|
|
121
|
-
const errors: string[] = [];
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const schema = JSON.parse(json) as PraxisSchema;
|
|
125
|
-
|
|
126
|
-
// Validate if requested
|
|
127
|
-
let validation: ValidationResult | undefined;
|
|
128
|
-
if (options.validate !== false) {
|
|
129
|
-
validation = validateSchema(schema);
|
|
130
|
-
if (!validation.valid) {
|
|
131
|
-
errors.push('Schema validation failed:');
|
|
132
|
-
validation.errors.forEach((error) => {
|
|
133
|
-
errors.push(` ${error.path}: ${error.message}`);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return {
|
|
139
|
-
schema,
|
|
140
|
-
validation,
|
|
141
|
-
errors,
|
|
142
|
-
};
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error instanceof Error) {
|
|
145
|
-
errors.push(`Failed to parse JSON: ${error.message}`);
|
|
146
|
-
} else {
|
|
147
|
-
errors.push('Failed to parse JSON: Unknown error');
|
|
148
|
-
}
|
|
149
|
-
return { errors };
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
97
|
|
|
153
|
-
/**
|
|
154
|
-
* Load schema from YAML string
|
|
155
|
-
*/
|
|
156
|
-
export function loadSchemaFromYaml(
|
|
157
|
-
yaml: string,
|
|
158
|
-
options: LoaderOptions = {}
|
|
159
|
-
): LoaderResult {
|
|
160
|
-
const errors: string[] = [];
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
const schema = yamlLoad(yaml) as PraxisSchema;
|
|
164
|
-
|
|
165
|
-
// Validate if requested
|
|
166
|
-
let validation: ValidationResult | undefined;
|
|
167
|
-
if (options.validate !== false) {
|
|
168
|
-
validation = validateSchema(schema);
|
|
169
|
-
if (!validation.valid) {
|
|
170
|
-
errors.push('Schema validation failed:');
|
|
171
|
-
validation.errors.forEach((error) => {
|
|
172
|
-
errors.push(` ${error.path}: ${error.message}`);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
schema,
|
|
179
|
-
validation,
|
|
180
|
-
errors,
|
|
181
|
-
};
|
|
182
|
-
} catch (error) {
|
|
183
|
-
if (error instanceof Error) {
|
|
184
|
-
errors.push(`Failed to parse YAML: ${error.message}`);
|
|
185
|
-
} else {
|
|
186
|
-
errors.push('Failed to parse YAML: Unknown error');
|
|
187
|
-
}
|
|
188
|
-
return { errors };
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
98
|
|
|
192
99
|
/**
|
|
193
100
|
* Load schema from file (supports .ts, .json, and .yaml/.yml)
|
|
@@ -207,41 +114,4 @@ export async function loadSchemaFromFile(
|
|
|
207
114
|
}
|
|
208
115
|
}
|
|
209
116
|
|
|
210
|
-
|
|
211
|
-
* Validate that a loaded schema has required fields for generation
|
|
212
|
-
*/
|
|
213
|
-
export function validateForGeneration(schema: PraxisSchema): ValidationResult {
|
|
214
|
-
const errors: string[] = [];
|
|
215
|
-
|
|
216
|
-
// Check for entities/models
|
|
217
|
-
if (!schema.models || schema.models.length === 0) {
|
|
218
|
-
errors.push('Schema must define at least one model for generation');
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Check that models have valid fields
|
|
222
|
-
schema.models?.forEach((model, index) => {
|
|
223
|
-
if (!model.fields || model.fields.length === 0) {
|
|
224
|
-
errors.push(
|
|
225
|
-
`Model "${model.name}" at index ${index} must have at least one field`
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
model.fields?.forEach((field, fieldIndex) => {
|
|
230
|
-
if (!field.name) {
|
|
231
|
-
errors.push(
|
|
232
|
-
`Field at index ${fieldIndex} in model "${model.name}" must have a name`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
if (!field.type) {
|
|
236
|
-
errors.push(
|
|
237
|
-
`Field "${field.name}" in model "${model.name}" must have a type`
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
valid: errors.length === 0,
|
|
245
|
-
errors: errors.map((message) => ({ path: 'schema', message })),
|
|
246
|
-
};
|
|
247
|
-
}
|
|
117
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Praxis Schema Normalizer
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Expands and normalizes schema definitions for code generation.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -74,19 +74,13 @@ export function normalizeSchema(
|
|
|
74
74
|
options: NormalizationOptions = {}
|
|
75
75
|
): NormalizedSchema {
|
|
76
76
|
const schemaPrefix = options.schemaPrefix || schema.name;
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
// Normalize models
|
|
79
|
-
const normalizedModels = normalizeModels(
|
|
80
|
-
|
|
81
|
-
schemaPrefix,
|
|
82
|
-
options
|
|
83
|
-
);
|
|
84
|
-
|
|
79
|
+
const normalizedModels = normalizeModels(schema.models || [], schemaPrefix, options);
|
|
80
|
+
|
|
85
81
|
// Create model lookup map
|
|
86
|
-
const modelMap = new Map(
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
|
|
82
|
+
const modelMap = new Map(normalizedModels.map((model) => [model.name, model]));
|
|
83
|
+
|
|
90
84
|
// Normalize components
|
|
91
85
|
const normalizedComponents = normalizeComponents(
|
|
92
86
|
schema.components || [],
|
|
@@ -94,14 +88,10 @@ export function normalizeSchema(
|
|
|
94
88
|
modelMap,
|
|
95
89
|
options
|
|
96
90
|
);
|
|
97
|
-
|
|
91
|
+
|
|
98
92
|
// Normalize logic
|
|
99
|
-
const normalizedLogic = normalizeLogic(
|
|
100
|
-
|
|
101
|
-
schemaPrefix,
|
|
102
|
-
options
|
|
103
|
-
);
|
|
104
|
-
|
|
93
|
+
const normalizedLogic = normalizeLogic(schema.logic || [], schemaPrefix, options);
|
|
94
|
+
|
|
105
95
|
return {
|
|
106
96
|
...schema,
|
|
107
97
|
models: normalizedModels,
|
|
@@ -121,11 +111,11 @@ function normalizeModels(
|
|
|
121
111
|
return models.map((model) => {
|
|
122
112
|
const fullName = `${schemaPrefix}.${model.name}`;
|
|
123
113
|
const dependencies = extractModelDependencies(model);
|
|
124
|
-
|
|
114
|
+
|
|
125
115
|
// For now, allFields is the same as fields
|
|
126
116
|
// In the future, this could include inherited fields
|
|
127
117
|
const allFields = [...model.fields];
|
|
128
|
-
|
|
118
|
+
|
|
129
119
|
return {
|
|
130
120
|
...model,
|
|
131
121
|
fullName,
|
|
@@ -140,20 +130,20 @@ function normalizeModels(
|
|
|
140
130
|
*/
|
|
141
131
|
function extractModelDependencies(model: ModelDefinition): string[] {
|
|
142
132
|
const dependencies = new Set<string>();
|
|
143
|
-
|
|
133
|
+
|
|
144
134
|
for (const field of model.fields) {
|
|
145
135
|
if (typeof field.type === 'object' && 'reference' in field.type) {
|
|
146
136
|
dependencies.add(field.type.reference);
|
|
147
137
|
}
|
|
148
138
|
}
|
|
149
|
-
|
|
139
|
+
|
|
150
140
|
// Add relationship dependencies
|
|
151
141
|
if (model.relationships) {
|
|
152
142
|
for (const rel of model.relationships) {
|
|
153
143
|
dependencies.add(rel.target);
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
|
-
|
|
146
|
+
|
|
157
147
|
return Array.from(dependencies);
|
|
158
148
|
}
|
|
159
149
|
|
|
@@ -168,10 +158,8 @@ function normalizeComponents(
|
|
|
168
158
|
): NormalizedComponent[] {
|
|
169
159
|
return components.map((component) => {
|
|
170
160
|
const fullName = `${schemaPrefix}.${component.name}`;
|
|
171
|
-
const resolvedModel = component.model
|
|
172
|
-
|
|
173
|
-
: undefined;
|
|
174
|
-
|
|
161
|
+
const resolvedModel = component.model ? modelMap.get(component.model) : undefined;
|
|
162
|
+
|
|
175
163
|
return {
|
|
176
164
|
...component,
|
|
177
165
|
fullName,
|
|
@@ -190,7 +178,7 @@ function normalizeLogic(
|
|
|
190
178
|
): NormalizedLogic[] {
|
|
191
179
|
return logic.map((logicDef) => {
|
|
192
180
|
const fullId = `${schemaPrefix}.${logicDef.id}`;
|
|
193
|
-
|
|
181
|
+
|
|
194
182
|
return {
|
|
195
183
|
...logicDef,
|
|
196
184
|
fullId,
|
|
@@ -201,30 +189,27 @@ function normalizeLogic(
|
|
|
201
189
|
/**
|
|
202
190
|
* Expand field type to fully qualified type string
|
|
203
191
|
*/
|
|
204
|
-
export function expandFieldType(
|
|
205
|
-
fieldType: any,
|
|
206
|
-
schemaPrefix: string = ''
|
|
207
|
-
): string {
|
|
192
|
+
export function expandFieldType(fieldType: any, schemaPrefix: string = ''): string {
|
|
208
193
|
if (typeof fieldType === 'string') {
|
|
209
194
|
return fieldType;
|
|
210
195
|
}
|
|
211
|
-
|
|
196
|
+
|
|
212
197
|
if (typeof fieldType === 'object') {
|
|
213
198
|
if ('array' in fieldType) {
|
|
214
199
|
const innerType = expandFieldType(fieldType.array, schemaPrefix);
|
|
215
200
|
return `${innerType}[]`;
|
|
216
201
|
}
|
|
217
|
-
|
|
202
|
+
|
|
218
203
|
if ('object' in fieldType) {
|
|
219
204
|
return 'object';
|
|
220
205
|
}
|
|
221
|
-
|
|
206
|
+
|
|
222
207
|
if ('reference' in fieldType) {
|
|
223
208
|
const refName = fieldType.reference;
|
|
224
209
|
return schemaPrefix ? `${schemaPrefix}.${refName}` : refName;
|
|
225
210
|
}
|
|
226
211
|
}
|
|
227
|
-
|
|
212
|
+
|
|
228
213
|
return 'unknown';
|
|
229
214
|
}
|
|
230
215
|
|
|
@@ -250,13 +235,13 @@ export function fieldTypeToTypeScript(fieldType: any): string {
|
|
|
250
235
|
return 'unknown';
|
|
251
236
|
}
|
|
252
237
|
}
|
|
253
|
-
|
|
238
|
+
|
|
254
239
|
if (typeof fieldType === 'object') {
|
|
255
240
|
if ('array' in fieldType) {
|
|
256
241
|
const innerType = fieldTypeToTypeScript(fieldType.array);
|
|
257
242
|
return `${innerType}[]`;
|
|
258
243
|
}
|
|
259
|
-
|
|
244
|
+
|
|
260
245
|
if ('object' in fieldType) {
|
|
261
246
|
const fields = fieldType.object;
|
|
262
247
|
const fieldTypes = Object.entries(fields)
|
|
@@ -267,30 +252,28 @@ export function fieldTypeToTypeScript(fieldType: any): string {
|
|
|
267
252
|
.join('; ');
|
|
268
253
|
return `{ ${fieldTypes} }`;
|
|
269
254
|
}
|
|
270
|
-
|
|
255
|
+
|
|
271
256
|
if ('reference' in fieldType) {
|
|
272
257
|
return fieldType.reference;
|
|
273
258
|
}
|
|
274
259
|
}
|
|
275
|
-
|
|
260
|
+
|
|
276
261
|
return 'unknown';
|
|
277
262
|
}
|
|
278
263
|
|
|
279
264
|
/**
|
|
280
265
|
* Sort models by dependency order (models with no dependencies first)
|
|
281
266
|
*/
|
|
282
|
-
export function sortModelsByDependencies(
|
|
283
|
-
models: NormalizedModel[]
|
|
284
|
-
): NormalizedModel[] {
|
|
267
|
+
export function sortModelsByDependencies(models: NormalizedModel[]): NormalizedModel[] {
|
|
285
268
|
const sorted: NormalizedModel[] = [];
|
|
286
269
|
const visited = new Set<string>();
|
|
287
270
|
const visiting = new Set<string>();
|
|
288
|
-
|
|
271
|
+
|
|
289
272
|
function visit(model: NormalizedModel) {
|
|
290
273
|
if (visited.has(model.name)) {
|
|
291
274
|
return;
|
|
292
275
|
}
|
|
293
|
-
|
|
276
|
+
|
|
294
277
|
if (visiting.has(model.name)) {
|
|
295
278
|
// Circular dependency detected, just add it
|
|
296
279
|
visiting.delete(model.name);
|
|
@@ -298,9 +281,9 @@ export function sortModelsByDependencies(
|
|
|
298
281
|
visited.add(model.name);
|
|
299
282
|
return;
|
|
300
283
|
}
|
|
301
|
-
|
|
284
|
+
|
|
302
285
|
visiting.add(model.name);
|
|
303
|
-
|
|
286
|
+
|
|
304
287
|
// Visit dependencies first
|
|
305
288
|
for (const depName of model.dependencies) {
|
|
306
289
|
const dep = models.find((m) => m.name === depName);
|
|
@@ -308,15 +291,15 @@ export function sortModelsByDependencies(
|
|
|
308
291
|
visit(dep);
|
|
309
292
|
}
|
|
310
293
|
}
|
|
311
|
-
|
|
294
|
+
|
|
312
295
|
visiting.delete(model.name);
|
|
313
296
|
visited.add(model.name);
|
|
314
297
|
sorted.push(model);
|
|
315
298
|
}
|
|
316
|
-
|
|
299
|
+
|
|
317
300
|
for (const model of models) {
|
|
318
301
|
visit(model);
|
|
319
302
|
}
|
|
320
|
-
|
|
303
|
+
|
|
321
304
|
return sorted;
|
|
322
305
|
}
|