@plures/praxis 1.0.3 → 1.1.1
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/README.md +162 -375
- package/core/codegen/docs-generator.ts +5 -2
- package/core/codegen/index.ts +1 -1
- 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 +215139 -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-QRYKRIDU.js +210960 -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 +58 -23
- 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 +7 -8
- package/src/cli/index.ts +14 -10
- 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/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/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/commands/verify.d.ts +0 -10
- package/dist/src/cli/commands/verify.d.ts.map +0 -1
- package/dist/src/cli/commands/verify.js +0 -39
- package/dist/src/cli/commands/verify.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 -226
- 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/ast-analyzer/src/ast-analyzer.d.ts +0 -8
- package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts.map +0 -1
- package/dist/tools/ast-analyzer/src/ast-analyzer.js +0 -119
- package/dist/tools/ast-analyzer/src/ast-analyzer.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/canvas-inspector/src/server.d.ts +0 -2
- package/dist/ui/canvas-inspector/src/server.d.ts.map +0 -1
- package/dist/ui/canvas-inspector/src/server.js +0 -248
- package/dist/ui/canvas-inspector/src/server.js.map +0 -1
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts +0 -5
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts.map +0 -1
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js +0 -58
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.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,175 @@
|
|
|
1
|
+
// src/core/pluresdb/generator.ts
|
|
2
|
+
var PluresDBGenerator = class {
|
|
3
|
+
options;
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = {
|
|
6
|
+
dbVersion: 1,
|
|
7
|
+
enableSync: false,
|
|
8
|
+
autoIndex: "all",
|
|
9
|
+
// Default to indexing all fields for backward compatibility
|
|
10
|
+
...options
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate PluresDB configuration from schema
|
|
15
|
+
*/
|
|
16
|
+
generateConfig(schema) {
|
|
17
|
+
const files = [];
|
|
18
|
+
files.push(this.generateConfigFile(schema));
|
|
19
|
+
return files;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate pluresdb-config.ts file
|
|
23
|
+
*/
|
|
24
|
+
generateConfigFile(schema) {
|
|
25
|
+
const lines = [];
|
|
26
|
+
const dbName = this.options.dbName || schema.name.toLowerCase();
|
|
27
|
+
lines.push("/**");
|
|
28
|
+
lines.push(` * PluresDB Configuration for ${schema.name}`);
|
|
29
|
+
lines.push(" * Generated from Praxis schema");
|
|
30
|
+
lines.push(" */");
|
|
31
|
+
lines.push("");
|
|
32
|
+
lines.push("// import { createPluresDB } from '@plures/pluresdb';");
|
|
33
|
+
lines.push("");
|
|
34
|
+
lines.push("/**");
|
|
35
|
+
lines.push(" * Database store configuration");
|
|
36
|
+
lines.push(" * ");
|
|
37
|
+
const autoIndexStrategy = this.options.autoIndex || "all";
|
|
38
|
+
if (autoIndexStrategy === "all") {
|
|
39
|
+
lines.push(" * Indexing: All string, number, and date fields are auto-indexed by default.");
|
|
40
|
+
lines.push(' * For large datasets, consider using autoIndex: "explicit" to only index');
|
|
41
|
+
lines.push(" * fields explicitly defined in the schema.");
|
|
42
|
+
} else if (autoIndexStrategy === "explicit") {
|
|
43
|
+
lines.push(" * Indexing: Only fields explicitly defined in schema indexes are indexed.");
|
|
44
|
+
} else if (autoIndexStrategy === "none") {
|
|
45
|
+
lines.push(" * Indexing: Auto-indexing disabled. Only explicit schema indexes are used.");
|
|
46
|
+
}
|
|
47
|
+
lines.push(" */");
|
|
48
|
+
lines.push("export const stores = {");
|
|
49
|
+
if (schema.models && schema.models.length > 0) {
|
|
50
|
+
for (const model of schema.models) {
|
|
51
|
+
const storeName = model.name.toLowerCase() + "s";
|
|
52
|
+
const storeConfig = this.generateStoreConfig(model);
|
|
53
|
+
lines.push(` ${storeName}: {`);
|
|
54
|
+
lines.push(` keyPath: '${storeConfig.keyPath}',`);
|
|
55
|
+
if (storeConfig.indexes.length > 0) {
|
|
56
|
+
lines.push(` indexes: [${storeConfig.indexes.map((idx) => `'${idx}'`).join(", ")}],`);
|
|
57
|
+
}
|
|
58
|
+
lines.push(" },");
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
lines.push(" // No models defined in schema");
|
|
62
|
+
}
|
|
63
|
+
lines.push("};");
|
|
64
|
+
lines.push("");
|
|
65
|
+
lines.push("/**");
|
|
66
|
+
lines.push(" * Database configuration");
|
|
67
|
+
lines.push(" */");
|
|
68
|
+
lines.push("export const dbConfig = {");
|
|
69
|
+
lines.push(` name: '${dbName}',`);
|
|
70
|
+
lines.push(` version: ${this.options.dbVersion},`);
|
|
71
|
+
lines.push(" stores,");
|
|
72
|
+
if (this.options.enableSync) {
|
|
73
|
+
lines.push(" sync: {");
|
|
74
|
+
lines.push(" enabled: true,");
|
|
75
|
+
if (this.options.syncEndpoint) {
|
|
76
|
+
lines.push(` endpoint: '${this.options.syncEndpoint}',`);
|
|
77
|
+
} else {
|
|
78
|
+
lines.push(" endpoint: 'ws://localhost:8080/sync',");
|
|
79
|
+
}
|
|
80
|
+
lines.push(" conflictResolution: 'last-write-wins',");
|
|
81
|
+
lines.push(" },");
|
|
82
|
+
}
|
|
83
|
+
lines.push("};");
|
|
84
|
+
lines.push("");
|
|
85
|
+
lines.push("/**");
|
|
86
|
+
lines.push(" * Initialize PluresDB");
|
|
87
|
+
lines.push(" * @returns Configured PluresDB instance");
|
|
88
|
+
lines.push(" */");
|
|
89
|
+
lines.push("export function initDB() {");
|
|
90
|
+
lines.push(" // Create and configure PluresDB instance");
|
|
91
|
+
lines.push(" const db = createInMemoryDB();");
|
|
92
|
+
lines.push(" ");
|
|
93
|
+
lines.push(" // Initialize stores based on configuration");
|
|
94
|
+
lines.push(" for (const storeDef of dbConfig.stores) {");
|
|
95
|
+
lines.push(" // Pre-create store paths");
|
|
96
|
+
lines.push(" db.set(`stores/${storeDef.name}/_meta`, {");
|
|
97
|
+
lines.push(" keyPath: storeDef.keyPath,");
|
|
98
|
+
lines.push(" indexes: storeDef.indexes,");
|
|
99
|
+
lines.push(" createdAt: Date.now(),");
|
|
100
|
+
lines.push(" });");
|
|
101
|
+
lines.push(" }");
|
|
102
|
+
lines.push(" ");
|
|
103
|
+
lines.push(" console.log(`PluresDB initialized: ${dbConfig.name}`);");
|
|
104
|
+
lines.push(" return db;");
|
|
105
|
+
lines.push("}");
|
|
106
|
+
lines.push("");
|
|
107
|
+
lines.push("/**");
|
|
108
|
+
lines.push(" * Get store by name");
|
|
109
|
+
lines.push(" */");
|
|
110
|
+
lines.push(
|
|
111
|
+
"export function getStore(db: ReturnType<typeof createInMemoryDB>, storeName: string) {"
|
|
112
|
+
);
|
|
113
|
+
lines.push(" const storeDef = dbConfig.stores.find(s => s.name === storeName);");
|
|
114
|
+
lines.push(" if (!storeDef) {");
|
|
115
|
+
lines.push(' throw new Error(`Store "${storeName}" not found in configuration`);');
|
|
116
|
+
lines.push(" }");
|
|
117
|
+
lines.push(" return {");
|
|
118
|
+
lines.push(" get: (key: string) => db.get(`stores/${storeName}/${key}`),");
|
|
119
|
+
lines.push(
|
|
120
|
+
" set: (key: string, value: unknown) => db.set(`stores/${storeName}/${key}`, value),"
|
|
121
|
+
);
|
|
122
|
+
lines.push(" delete: (key: string) => db.delete(`stores/${storeName}/${key}`),");
|
|
123
|
+
lines.push(" watch: (key: string, callback: (data: unknown) => void) => ");
|
|
124
|
+
lines.push(" db.watch(`stores/${storeName}/${key}`, callback),");
|
|
125
|
+
lines.push(" };");
|
|
126
|
+
lines.push("}");
|
|
127
|
+
return {
|
|
128
|
+
path: `${this.options.outputDir}/pluresdb-config.ts`,
|
|
129
|
+
content: lines.join("\n"),
|
|
130
|
+
type: "config"
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Generate store configuration for a model
|
|
135
|
+
*/
|
|
136
|
+
generateStoreConfig(model) {
|
|
137
|
+
const idField = model.fields.find((f) => f.name === "id" || f.name === "_id");
|
|
138
|
+
const keyPath = idField ? idField.name : "id";
|
|
139
|
+
const indexes = [];
|
|
140
|
+
const autoIndexStrategy = this.options.autoIndex || "all";
|
|
141
|
+
if (autoIndexStrategy === "all") {
|
|
142
|
+
for (const field of model.fields) {
|
|
143
|
+
if (field.name !== keyPath) {
|
|
144
|
+
if (field.type === "string" || field.type === "number" || field.type === "date") {
|
|
145
|
+
indexes.push(field.name);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (model.indexes) {
|
|
151
|
+
for (const indexDef of model.indexes) {
|
|
152
|
+
for (const fieldName of indexDef.fields) {
|
|
153
|
+
if (!indexes.includes(fieldName) && fieldName !== keyPath) {
|
|
154
|
+
indexes.push(fieldName);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
keyPath,
|
|
161
|
+
indexes
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
function createPluresDBGenerator(outputDir, options) {
|
|
166
|
+
return new PluresDBGenerator({
|
|
167
|
+
outputDir,
|
|
168
|
+
...options
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
PluresDBGenerator,
|
|
174
|
+
createPluresDBGenerator
|
|
175
|
+
};
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
// src/integrations/code-canvas.ts
|
|
2
|
+
function schemaToCanvas(schema, _options = {}) {
|
|
3
|
+
const nodes = [];
|
|
4
|
+
const edges = [];
|
|
5
|
+
let nodeId = 0;
|
|
6
|
+
let yOffset = 0;
|
|
7
|
+
const xSpacing = 200;
|
|
8
|
+
const ySpacing = 100;
|
|
9
|
+
if (schema.models) {
|
|
10
|
+
schema.models.forEach((model, index) => {
|
|
11
|
+
const pos = model.position && (model.position.x !== 0 || model.position.y !== 0) ? model.position : { x: 50, y: yOffset + index * ySpacing };
|
|
12
|
+
const node = {
|
|
13
|
+
id: model.id || `model-${nodeId++}`,
|
|
14
|
+
type: "model",
|
|
15
|
+
label: model.name,
|
|
16
|
+
x: pos.x,
|
|
17
|
+
y: pos.y,
|
|
18
|
+
width: 150,
|
|
19
|
+
height: 60,
|
|
20
|
+
data: model,
|
|
21
|
+
style: {
|
|
22
|
+
backgroundColor: "#e3f2fd",
|
|
23
|
+
borderColor: "#1976d2"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
nodes.push(node);
|
|
27
|
+
});
|
|
28
|
+
yOffset += schema.models.length * ySpacing + 50;
|
|
29
|
+
}
|
|
30
|
+
if (schema.components) {
|
|
31
|
+
schema.components.forEach((component, index) => {
|
|
32
|
+
const pos = component.position && (component.position.x !== 0 || component.position.y !== 0) ? component.position : { x: 50 + xSpacing, y: yOffset + index * ySpacing };
|
|
33
|
+
const node = {
|
|
34
|
+
id: component.id || `component-${nodeId++}`,
|
|
35
|
+
type: "component",
|
|
36
|
+
label: component.name,
|
|
37
|
+
x: pos.x,
|
|
38
|
+
y: pos.y,
|
|
39
|
+
width: 150,
|
|
40
|
+
height: 60,
|
|
41
|
+
data: component,
|
|
42
|
+
style: {
|
|
43
|
+
backgroundColor: "#e8f5e9",
|
|
44
|
+
borderColor: "#388e3c"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
nodes.push(node);
|
|
48
|
+
if (component.model) {
|
|
49
|
+
const modelNode = nodes.find((n) => n.type === "model" && n.label === component.model);
|
|
50
|
+
if (modelNode) {
|
|
51
|
+
edges.push({
|
|
52
|
+
id: `edge-${edges.length}`,
|
|
53
|
+
source: node.id,
|
|
54
|
+
target: modelNode.id,
|
|
55
|
+
type: "reference",
|
|
56
|
+
label: "uses"
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
yOffset += schema.components.length * ySpacing + 50;
|
|
62
|
+
}
|
|
63
|
+
if (schema.events) {
|
|
64
|
+
schema.events.forEach((event, index) => {
|
|
65
|
+
const pos = event.position && (event.position.x !== 0 || event.position.y !== 0) ? event.position : { x: 50 + xSpacing * 2, y: yOffset + index * ySpacing };
|
|
66
|
+
const node = {
|
|
67
|
+
id: event.id || `event-${nodeId++}`,
|
|
68
|
+
type: "event",
|
|
69
|
+
label: event.tag,
|
|
70
|
+
x: pos.x,
|
|
71
|
+
y: pos.y,
|
|
72
|
+
width: 150,
|
|
73
|
+
height: 50,
|
|
74
|
+
data: event,
|
|
75
|
+
style: {
|
|
76
|
+
backgroundColor: "#fff3e0",
|
|
77
|
+
borderColor: "#f57c00"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
nodes.push(node);
|
|
81
|
+
});
|
|
82
|
+
yOffset += schema.events.length * ySpacing + 30;
|
|
83
|
+
}
|
|
84
|
+
if (schema.facts) {
|
|
85
|
+
schema.facts.forEach((fact, index) => {
|
|
86
|
+
const pos = fact.position && (fact.position.x !== 0 || fact.position.y !== 0) ? fact.position : { x: 50 + xSpacing * 3, y: yOffset + index * ySpacing };
|
|
87
|
+
const node = {
|
|
88
|
+
id: fact.id || `fact-${nodeId++}`,
|
|
89
|
+
type: "fact",
|
|
90
|
+
label: fact.tag,
|
|
91
|
+
x: pos.x,
|
|
92
|
+
y: pos.y,
|
|
93
|
+
width: 150,
|
|
94
|
+
height: 50,
|
|
95
|
+
data: fact,
|
|
96
|
+
style: {
|
|
97
|
+
backgroundColor: "#fce4ec",
|
|
98
|
+
borderColor: "#c2185b"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
nodes.push(node);
|
|
102
|
+
});
|
|
103
|
+
yOffset += schema.facts.length * ySpacing + 30;
|
|
104
|
+
}
|
|
105
|
+
if (schema.rules) {
|
|
106
|
+
schema.rules.forEach((rule, index) => {
|
|
107
|
+
const pos = rule.position && (rule.position.x !== 0 || rule.position.y !== 0) ? rule.position : { x: 50 + xSpacing * 4, y: yOffset + index * ySpacing };
|
|
108
|
+
const node = {
|
|
109
|
+
id: rule.id || `rule-${nodeId++}`,
|
|
110
|
+
type: "rule",
|
|
111
|
+
label: rule.id,
|
|
112
|
+
x: pos.x,
|
|
113
|
+
y: pos.y,
|
|
114
|
+
width: 150,
|
|
115
|
+
height: 50,
|
|
116
|
+
data: rule,
|
|
117
|
+
style: {
|
|
118
|
+
backgroundColor: "#e1f5fe",
|
|
119
|
+
borderColor: "#0288d1"
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
nodes.push(node);
|
|
123
|
+
if (rule.triggers) {
|
|
124
|
+
rule.triggers.forEach((trigger) => {
|
|
125
|
+
const eventNode = nodes.find((n) => n.type === "event" && n.label === trigger);
|
|
126
|
+
if (eventNode) {
|
|
127
|
+
edges.push({
|
|
128
|
+
id: `edge-${edges.length}`,
|
|
129
|
+
source: eventNode.id,
|
|
130
|
+
target: node.id,
|
|
131
|
+
type: "event",
|
|
132
|
+
label: "triggers"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
yOffset += schema.rules.length * ySpacing + 30;
|
|
139
|
+
}
|
|
140
|
+
if (schema.constraints) {
|
|
141
|
+
schema.constraints.forEach((constraint, index) => {
|
|
142
|
+
const pos = constraint.position && (constraint.position.x !== 0 || constraint.position.y !== 0) ? constraint.position : { x: 50 + xSpacing * 5, y: yOffset + index * ySpacing };
|
|
143
|
+
const node = {
|
|
144
|
+
id: constraint.id || `constraint-${nodeId++}`,
|
|
145
|
+
type: "constraint",
|
|
146
|
+
label: constraint.id,
|
|
147
|
+
x: pos.x,
|
|
148
|
+
y: pos.y,
|
|
149
|
+
width: 150,
|
|
150
|
+
height: 50,
|
|
151
|
+
data: constraint,
|
|
152
|
+
style: {
|
|
153
|
+
backgroundColor: "#ffebee",
|
|
154
|
+
borderColor: "#c62828"
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
nodes.push(node);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
id: `canvas-${Date.now()}`,
|
|
162
|
+
name: schema.name || "Praxis Schema",
|
|
163
|
+
version: schema.$version || "1.0.0",
|
|
164
|
+
nodes,
|
|
165
|
+
edges,
|
|
166
|
+
flows: schema.flows || [],
|
|
167
|
+
metadata: {
|
|
168
|
+
created: Date.now(),
|
|
169
|
+
modified: Date.now(),
|
|
170
|
+
description: schema.description
|
|
171
|
+
},
|
|
172
|
+
viewport: { x: 0, y: 0, zoom: 1 }
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function canvasToSchema(canvas) {
|
|
176
|
+
const models = [];
|
|
177
|
+
const components = [];
|
|
178
|
+
const events = [];
|
|
179
|
+
const facts = [];
|
|
180
|
+
const rules = [];
|
|
181
|
+
const constraints = [];
|
|
182
|
+
for (const node of canvas.nodes) {
|
|
183
|
+
const position = { x: node.x, y: node.y };
|
|
184
|
+
switch (node.type) {
|
|
185
|
+
case "model":
|
|
186
|
+
if (node.data) {
|
|
187
|
+
models.push({ ...node.data, position });
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case "component":
|
|
191
|
+
if (node.data) {
|
|
192
|
+
components.push({ ...node.data, position });
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case "event":
|
|
196
|
+
if (node.data) {
|
|
197
|
+
events.push({ ...node.data, position });
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case "fact":
|
|
201
|
+
if (node.data) {
|
|
202
|
+
facts.push({ ...node.data, position });
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case "rule":
|
|
206
|
+
if (node.data) {
|
|
207
|
+
rules.push({ ...node.data, position });
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case "constraint":
|
|
211
|
+
if (node.data) {
|
|
212
|
+
constraints.push({ ...node.data, position });
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
$version: "1.0.0",
|
|
219
|
+
id: canvas.id,
|
|
220
|
+
name: canvas.name,
|
|
221
|
+
description: canvas.metadata?.description,
|
|
222
|
+
models,
|
|
223
|
+
components,
|
|
224
|
+
events,
|
|
225
|
+
facts,
|
|
226
|
+
rules,
|
|
227
|
+
constraints,
|
|
228
|
+
flows: canvas.flows || [],
|
|
229
|
+
metadata: canvas.metadata
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function canvasToYaml(canvas) {
|
|
233
|
+
const lines = [
|
|
234
|
+
`# ${canvas.name}`,
|
|
235
|
+
`# Generated by Praxis CodeCanvas Integration`,
|
|
236
|
+
`# Version: ${canvas.version}`,
|
|
237
|
+
"",
|
|
238
|
+
"nodes:"
|
|
239
|
+
];
|
|
240
|
+
for (const node of canvas.nodes) {
|
|
241
|
+
lines.push(` - id: "${node.id}"`);
|
|
242
|
+
lines.push(` type: "${node.type}"`);
|
|
243
|
+
lines.push(` label: "${node.label}"`);
|
|
244
|
+
lines.push(` x: ${node.x}`);
|
|
245
|
+
lines.push(` y: ${node.y}`);
|
|
246
|
+
lines.push(` width: ${node.width}`);
|
|
247
|
+
lines.push(` height: ${node.height}`);
|
|
248
|
+
if (node.fsmState) {
|
|
249
|
+
lines.push(` fsmState: "${node.fsmState}"`);
|
|
250
|
+
}
|
|
251
|
+
lines.push("");
|
|
252
|
+
}
|
|
253
|
+
lines.push("edges:");
|
|
254
|
+
for (const edge of canvas.edges) {
|
|
255
|
+
lines.push(` - id: "${edge.id}"`);
|
|
256
|
+
lines.push(` source: "${edge.source}"`);
|
|
257
|
+
lines.push(` target: "${edge.target}"`);
|
|
258
|
+
if (edge.label) {
|
|
259
|
+
lines.push(` label: "${edge.label}"`);
|
|
260
|
+
}
|
|
261
|
+
if (edge.type) {
|
|
262
|
+
lines.push(` type: "${edge.type}"`);
|
|
263
|
+
}
|
|
264
|
+
lines.push("");
|
|
265
|
+
}
|
|
266
|
+
return lines.join("\n");
|
|
267
|
+
}
|
|
268
|
+
function canvasToMermaid(canvas) {
|
|
269
|
+
const lines = ["graph TD"];
|
|
270
|
+
for (const node of canvas.nodes) {
|
|
271
|
+
let shape;
|
|
272
|
+
switch (node.type) {
|
|
273
|
+
case "model":
|
|
274
|
+
shape = `[${node.label}]`;
|
|
275
|
+
break;
|
|
276
|
+
case "component":
|
|
277
|
+
shape = `(${node.label})`;
|
|
278
|
+
break;
|
|
279
|
+
case "event":
|
|
280
|
+
shape = `{{${node.label}}}`;
|
|
281
|
+
break;
|
|
282
|
+
case "fact":
|
|
283
|
+
shape = `((${node.label}))`;
|
|
284
|
+
break;
|
|
285
|
+
case "rule":
|
|
286
|
+
shape = `[/${node.label}/]`;
|
|
287
|
+
break;
|
|
288
|
+
case "constraint":
|
|
289
|
+
shape = `[\\${node.label}\\]`;
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
shape = `[${node.label}]`;
|
|
293
|
+
}
|
|
294
|
+
lines.push(` ${node.id}${shape}`);
|
|
295
|
+
}
|
|
296
|
+
lines.push("");
|
|
297
|
+
for (const edge of canvas.edges) {
|
|
298
|
+
const label = edge.label ? `|${edge.label}|` : "";
|
|
299
|
+
lines.push(` ${edge.source} -->${label} ${edge.target}`);
|
|
300
|
+
}
|
|
301
|
+
return lines.join("\n");
|
|
302
|
+
}
|
|
303
|
+
function validateWithGuardian(files, activity, lifecycle) {
|
|
304
|
+
const errors = [];
|
|
305
|
+
const warnings = [];
|
|
306
|
+
const currentState = lifecycle.find((s) => s.id === activity.activity);
|
|
307
|
+
if (!currentState) {
|
|
308
|
+
errors.push({
|
|
309
|
+
code: "INVALID_ACTIVITY",
|
|
310
|
+
message: `Activity "${activity.activity}" is not a valid lifecycle state`,
|
|
311
|
+
rule: "lifecycle-state"
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (activity.allowedPaths) {
|
|
315
|
+
for (const file of files) {
|
|
316
|
+
const allowed = activity.allowedPaths.some((pattern) => {
|
|
317
|
+
const regex = new RegExp("^" + pattern.replace(/\*/g, ".*") + "$");
|
|
318
|
+
return regex.test(file);
|
|
319
|
+
});
|
|
320
|
+
if (!allowed) {
|
|
321
|
+
errors.push({
|
|
322
|
+
code: "PATH_NOT_ALLOWED",
|
|
323
|
+
message: `File "${file}" is not allowed during "${activity.activity}" activity`,
|
|
324
|
+
file,
|
|
325
|
+
rule: "allowed-paths"
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
valid: errors.length === 0,
|
|
332
|
+
errors,
|
|
333
|
+
warnings,
|
|
334
|
+
filesChecked: files,
|
|
335
|
+
activity
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function createCanvasEditor(config) {
|
|
339
|
+
const document = config.document || (config.schema ? schemaToCanvas(config.schema, { layout: config.layout }) : {
|
|
340
|
+
id: `canvas-${Date.now()}`,
|
|
341
|
+
name: "New Canvas",
|
|
342
|
+
version: "1.0.0",
|
|
343
|
+
nodes: [],
|
|
344
|
+
edges: [],
|
|
345
|
+
metadata: { created: Date.now(), modified: Date.now() },
|
|
346
|
+
viewport: { x: 0, y: 0, zoom: 1 }
|
|
347
|
+
});
|
|
348
|
+
let nodeIdCounter = document.nodes.length;
|
|
349
|
+
let edgeIdCounter = document.edges.length;
|
|
350
|
+
return {
|
|
351
|
+
document,
|
|
352
|
+
addNode(node) {
|
|
353
|
+
const fullNode = {
|
|
354
|
+
...node,
|
|
355
|
+
id: `node-${nodeIdCounter++}`
|
|
356
|
+
};
|
|
357
|
+
document.nodes.push(fullNode);
|
|
358
|
+
document.metadata.modified = Date.now();
|
|
359
|
+
return fullNode;
|
|
360
|
+
},
|
|
361
|
+
removeNode(id) {
|
|
362
|
+
const index = document.nodes.findIndex((n) => n.id === id);
|
|
363
|
+
if (index !== -1) {
|
|
364
|
+
document.nodes.splice(index, 1);
|
|
365
|
+
document.edges = document.edges.filter((e) => e.source !== id && e.target !== id);
|
|
366
|
+
document.metadata.modified = Date.now();
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
addEdge(edge) {
|
|
370
|
+
const fullEdge = {
|
|
371
|
+
...edge,
|
|
372
|
+
id: `edge-${edgeIdCounter++}`
|
|
373
|
+
};
|
|
374
|
+
document.edges.push(fullEdge);
|
|
375
|
+
document.metadata.modified = Date.now();
|
|
376
|
+
return fullEdge;
|
|
377
|
+
},
|
|
378
|
+
removeEdge(id) {
|
|
379
|
+
const index = document.edges.findIndex((e) => e.id === id);
|
|
380
|
+
if (index !== -1) {
|
|
381
|
+
document.edges.splice(index, 1);
|
|
382
|
+
document.metadata.modified = Date.now();
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
toSchema() {
|
|
386
|
+
return canvasToSchema(document);
|
|
387
|
+
},
|
|
388
|
+
toYaml() {
|
|
389
|
+
return canvasToYaml(document);
|
|
390
|
+
},
|
|
391
|
+
toMermaid() {
|
|
392
|
+
return canvasToMermaid(document);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export {
|
|
398
|
+
schemaToCanvas,
|
|
399
|
+
canvasToSchema,
|
|
400
|
+
canvasToYaml,
|
|
401
|
+
canvasToMermaid,
|
|
402
|
+
validateWithGuardian,
|
|
403
|
+
createCanvasEditor
|
|
404
|
+
};
|