@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
package/src/components/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Praxis Svelte Components
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Exports types and interfaces for Svelte components in Praxis/RuneBook applications.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Note: Svelte components (.svelte files) must be imported directly in Svelte applications.
|
|
7
7
|
* This module provides TypeScript types for component props.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```svelte
|
|
11
11
|
* <script>
|
|
@@ -43,4 +43,3 @@ export interface TerminalNodeProps {
|
|
|
43
43
|
*/
|
|
44
44
|
export type { TerminalAdapter } from '../runtime/terminal-adapter.js';
|
|
45
45
|
export { createTerminalAdapter } from '../runtime/terminal-adapter.js';
|
|
46
|
-
|
package/src/core/actors.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Actors System
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Actors are effectful units that:
|
|
5
5
|
* - Observe Praxis logic state
|
|
6
6
|
* - Perform side effects (network I/O, database operations, timers, etc.)
|
|
7
7
|
* - Feed new events/facts back into the engine
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Actors provide the bridge between pure logic and the effectful world.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { LogicEngine } from
|
|
13
|
-
import type { PraxisEvent, PraxisState } from
|
|
12
|
+
import type { LogicEngine } from './engine.js';
|
|
13
|
+
import type { PraxisEvent, PraxisState } from './protocol.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Actor interface
|
|
17
|
-
*
|
|
17
|
+
*
|
|
18
18
|
* An actor observes state changes and can:
|
|
19
19
|
* - React to state changes (onStateChange)
|
|
20
20
|
* - Perform initialization (onStart)
|
|
@@ -38,7 +38,7 @@ export interface Actor<TContext = unknown> {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Actor manager
|
|
41
|
-
*
|
|
41
|
+
*
|
|
42
42
|
* Manages the lifecycle of actors and coordinates their interaction with the engine.
|
|
43
43
|
*/
|
|
44
44
|
export class ActorManager<TContext = unknown> {
|
|
@@ -85,7 +85,7 @@ export class ActorManager<TContext = unknown> {
|
|
|
85
85
|
throw new Error(`Actor "${actorId}" is already started`);
|
|
86
86
|
}
|
|
87
87
|
if (!this.engine) {
|
|
88
|
-
throw new Error(
|
|
88
|
+
throw new Error('Actor manager not attached to an engine');
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
this.activeActors.add(actorId);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Praxis Component Generator
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Generates Svelte components from schema definitions.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -71,10 +71,7 @@ export class ComponentGenerator {
|
|
|
71
71
|
/**
|
|
72
72
|
* Generate component from definition
|
|
73
73
|
*/
|
|
74
|
-
generateComponent(
|
|
75
|
-
component: ComponentDefinition,
|
|
76
|
-
model?: ModelDefinition
|
|
77
|
-
): GenerationResult {
|
|
74
|
+
generateComponent(component: ComponentDefinition, model?: ModelDefinition): GenerationResult {
|
|
78
75
|
const files: GeneratedFile[] = [];
|
|
79
76
|
const errors: GenerationError[] = [];
|
|
80
77
|
|
|
@@ -135,10 +132,7 @@ export class ComponentGenerator {
|
|
|
135
132
|
/**
|
|
136
133
|
* Generate Svelte component code
|
|
137
134
|
*/
|
|
138
|
-
private generateSvelteComponent(
|
|
139
|
-
component: ComponentDefinition,
|
|
140
|
-
model?: ModelDefinition
|
|
141
|
-
): string {
|
|
135
|
+
private generateSvelteComponent(component: ComponentDefinition, model?: ModelDefinition): string {
|
|
142
136
|
const script = this.generateScript(component, model);
|
|
143
137
|
const template = this.generateTemplate(component, model);
|
|
144
138
|
const styles = this.generateStyles(component);
|
|
@@ -157,7 +151,7 @@ ${styles ? `<style>\n${styles}\n</style>` : ''}`;
|
|
|
157
151
|
*/
|
|
158
152
|
private generateScript(
|
|
159
153
|
component: ComponentDefinition,
|
|
160
|
-
_model?: ModelDefinition
|
|
154
|
+
_model?: ModelDefinition // Prefix with _ to indicate intentionally unused
|
|
161
155
|
): string {
|
|
162
156
|
const lines: string[] = [];
|
|
163
157
|
|
|
@@ -169,11 +163,8 @@ ${styles ? `<style>\n${styles}\n</style>` : ''}`;
|
|
|
169
163
|
if (component.props && component.props.length > 0) {
|
|
170
164
|
component.props.forEach((prop) => {
|
|
171
165
|
const typeAnnotation = this.config.typescript ? `: ${prop.type}` : '';
|
|
172
|
-
const defaultValue =
|
|
173
|
-
|
|
174
|
-
lines.push(
|
|
175
|
-
` export let ${prop.name}${typeAnnotation}${defaultValue};`
|
|
176
|
-
);
|
|
166
|
+
const defaultValue = prop.default !== undefined ? ` = ${JSON.stringify(prop.default)}` : '';
|
|
167
|
+
lines.push(` export let ${prop.name}${typeAnnotation}${defaultValue};`);
|
|
177
168
|
});
|
|
178
169
|
lines.push('');
|
|
179
170
|
}
|
|
@@ -230,10 +221,7 @@ ${styles ? `<style>\n${styles}\n</style>` : ''}`;
|
|
|
230
221
|
/**
|
|
231
222
|
* Generate component template
|
|
232
223
|
*/
|
|
233
|
-
private generateTemplate(
|
|
234
|
-
component: ComponentDefinition,
|
|
235
|
-
model?: ModelDefinition
|
|
236
|
-
): string {
|
|
224
|
+
private generateTemplate(component: ComponentDefinition, model?: ModelDefinition): string {
|
|
237
225
|
switch (component.type) {
|
|
238
226
|
case 'form':
|
|
239
227
|
return this.generateFormTemplate(component, model);
|
|
@@ -251,10 +239,7 @@ ${styles ? `<style>\n${styles}\n</style>` : ''}`;
|
|
|
251
239
|
/**
|
|
252
240
|
* Generate form template
|
|
253
241
|
*/
|
|
254
|
-
private generateFormTemplate(
|
|
255
|
-
component: ComponentDefinition,
|
|
256
|
-
model?: ModelDefinition
|
|
257
|
-
): string {
|
|
242
|
+
private generateFormTemplate(component: ComponentDefinition, model?: ModelDefinition): string {
|
|
258
243
|
const fields = model?.fields || [];
|
|
259
244
|
const formFields = fields
|
|
260
245
|
.map((field) => {
|
|
@@ -268,10 +253,7 @@ ${styles ? `<style>\n${styles}\n</style>` : ''}`;
|
|
|
268
253
|
/**
|
|
269
254
|
* Generate display template
|
|
270
255
|
*/
|
|
271
|
-
private generateDisplayTemplate(
|
|
272
|
-
component: ComponentDefinition,
|
|
273
|
-
model?: ModelDefinition
|
|
274
|
-
): string {
|
|
256
|
+
private generateDisplayTemplate(component: ComponentDefinition, model?: ModelDefinition): string {
|
|
275
257
|
const fields = model?.fields || [];
|
|
276
258
|
const displayFields = fields
|
|
277
259
|
.map((field) => {
|
|
@@ -287,7 +269,7 @@ ${styles ? `<style>\n${styles}\n</style>` : ''}`;
|
|
|
287
269
|
*/
|
|
288
270
|
private generateListTemplate(
|
|
289
271
|
component: ComponentDefinition,
|
|
290
|
-
_model?: ModelDefinition
|
|
272
|
+
_model?: ModelDefinition // Prefix with _ to indicate intentionally unused
|
|
291
273
|
): string {
|
|
292
274
|
return `<div class="${component.name.toLowerCase()}">\n {#each items as item}\n <div class="item">{item.name}</div>\n {/each}\n</div>`;
|
|
293
275
|
}
|
package/src/core/engine.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Praxis Logic Engine
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* The logic engine manages state, processes events through rules,
|
|
5
5
|
* checks constraints, and provides a strongly-typed API for application logic.
|
|
6
6
|
*/
|
|
@@ -12,9 +12,9 @@ import type {
|
|
|
12
12
|
PraxisStepConfig,
|
|
13
13
|
PraxisStepResult,
|
|
14
14
|
PraxisDiagnostics,
|
|
15
|
-
} from
|
|
16
|
-
import { PRAXIS_PROTOCOL_VERSION } from
|
|
17
|
-
import { PraxisRegistry } from
|
|
15
|
+
} from './protocol.js';
|
|
16
|
+
import { PRAXIS_PROTOCOL_VERSION } from './protocol.js';
|
|
17
|
+
import { PraxisRegistry } from './rules.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Options for creating a Praxis engine
|
|
@@ -30,9 +30,39 @@ export interface PraxisEngineOptions<TContext = unknown> {
|
|
|
30
30
|
initialMeta?: Record<string, unknown>;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Clone helper that avoids structuredClone failures on non-cloneable values
|
|
35
|
+
* (e.g., functions, timers). Falls back to a shallow copy when necessary.
|
|
36
|
+
*/
|
|
37
|
+
function safeClone<T>(value: T): T {
|
|
38
|
+
if (value === null || typeof value !== 'object') {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Prefer structuredClone for deep, data-safe copies when available
|
|
43
|
+
// (handles Map, Set, Date, etc.). Guard for environments that lack it.
|
|
44
|
+
if (typeof globalThis.structuredClone === 'function') {
|
|
45
|
+
try {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
47
|
+
return globalThis.structuredClone(value);
|
|
48
|
+
} catch {
|
|
49
|
+
// fall through to safer copies
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
55
|
+
return [...(value as unknown as unknown[])] as unknown as T;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Shallow copy as a safe fallback for objects containing functions or
|
|
59
|
+
// other non-structured-clone-able members.
|
|
60
|
+
return { ...(value as Record<string, unknown>) } as unknown as T;
|
|
61
|
+
}
|
|
62
|
+
|
|
33
63
|
/**
|
|
34
64
|
* The Praxis Logic Engine
|
|
35
|
-
*
|
|
65
|
+
*
|
|
36
66
|
* Manages application logic through facts, events, rules, and constraints.
|
|
37
67
|
* The engine is strongly typed and functional - all state updates are immutable.
|
|
38
68
|
*/
|
|
@@ -55,9 +85,9 @@ export class LogicEngine<TContext = unknown> {
|
|
|
55
85
|
*/
|
|
56
86
|
getState(): Readonly<PraxisState & { context: TContext }> {
|
|
57
87
|
return {
|
|
58
|
-
context:
|
|
88
|
+
context: safeClone(this.state.context),
|
|
59
89
|
facts: [...this.state.facts],
|
|
60
|
-
meta: this.state.meta ?
|
|
90
|
+
meta: this.state.meta ? safeClone(this.state.meta) : undefined,
|
|
61
91
|
protocolVersion: this.state.protocolVersion,
|
|
62
92
|
};
|
|
63
93
|
}
|
|
@@ -66,7 +96,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
66
96
|
* Get the current context
|
|
67
97
|
*/
|
|
68
98
|
getContext(): TContext {
|
|
69
|
-
return
|
|
99
|
+
return safeClone(this.state.context);
|
|
70
100
|
}
|
|
71
101
|
|
|
72
102
|
/**
|
|
@@ -79,7 +109,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
79
109
|
/**
|
|
80
110
|
* Process events through the engine.
|
|
81
111
|
* Applies all registered rules and checks all registered constraints.
|
|
82
|
-
*
|
|
112
|
+
*
|
|
83
113
|
* @param events Events to process
|
|
84
114
|
* @returns Result with new state and diagnostics
|
|
85
115
|
*/
|
|
@@ -93,15 +123,12 @@ export class LogicEngine<TContext = unknown> {
|
|
|
93
123
|
|
|
94
124
|
/**
|
|
95
125
|
* Process events with specific rule and constraint configuration.
|
|
96
|
-
*
|
|
126
|
+
*
|
|
97
127
|
* @param events Events to process
|
|
98
128
|
* @param config Step configuration
|
|
99
129
|
* @returns Result with new state and diagnostics
|
|
100
130
|
*/
|
|
101
|
-
stepWithConfig(
|
|
102
|
-
events: PraxisEvent[],
|
|
103
|
-
config: PraxisStepConfig
|
|
104
|
-
): PraxisStepResult {
|
|
131
|
+
stepWithConfig(events: PraxisEvent[], config: PraxisStepConfig): PraxisStepResult {
|
|
105
132
|
const diagnostics: PraxisDiagnostics[] = [];
|
|
106
133
|
let newState = { ...this.state };
|
|
107
134
|
|
|
@@ -111,7 +138,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
111
138
|
const rule = this.registry.getRule(ruleId);
|
|
112
139
|
if (!rule) {
|
|
113
140
|
diagnostics.push({
|
|
114
|
-
kind:
|
|
141
|
+
kind: 'rule-error',
|
|
115
142
|
message: `Rule "${ruleId}" not found in registry`,
|
|
116
143
|
data: { ruleId },
|
|
117
144
|
});
|
|
@@ -123,7 +150,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
123
150
|
newFacts.push(...ruleFacts);
|
|
124
151
|
} catch (error) {
|
|
125
152
|
diagnostics.push({
|
|
126
|
-
kind:
|
|
153
|
+
kind: 'rule-error',
|
|
127
154
|
message: `Error executing rule "${ruleId}": ${error instanceof Error ? error.message : String(error)}`,
|
|
128
155
|
data: { ruleId, error },
|
|
129
156
|
});
|
|
@@ -141,7 +168,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
141
168
|
const constraint = this.registry.getConstraint(constraintId);
|
|
142
169
|
if (!constraint) {
|
|
143
170
|
diagnostics.push({
|
|
144
|
-
kind:
|
|
171
|
+
kind: 'constraint-violation',
|
|
145
172
|
message: `Constraint "${constraintId}" not found in registry`,
|
|
146
173
|
data: { constraintId },
|
|
147
174
|
});
|
|
@@ -152,20 +179,20 @@ export class LogicEngine<TContext = unknown> {
|
|
|
152
179
|
const result = constraint.impl(newState);
|
|
153
180
|
if (result === false) {
|
|
154
181
|
diagnostics.push({
|
|
155
|
-
kind:
|
|
182
|
+
kind: 'constraint-violation',
|
|
156
183
|
message: `Constraint "${constraintId}" violated`,
|
|
157
184
|
data: { constraintId, description: constraint.description },
|
|
158
185
|
});
|
|
159
|
-
} else if (typeof result ===
|
|
186
|
+
} else if (typeof result === 'string') {
|
|
160
187
|
diagnostics.push({
|
|
161
|
-
kind:
|
|
188
|
+
kind: 'constraint-violation',
|
|
162
189
|
message: result,
|
|
163
190
|
data: { constraintId, description: constraint.description },
|
|
164
191
|
});
|
|
165
192
|
}
|
|
166
193
|
} catch (error) {
|
|
167
194
|
diagnostics.push({
|
|
168
|
-
kind:
|
|
195
|
+
kind: 'constraint-violation',
|
|
169
196
|
message: `Error checking constraint "${constraintId}": ${error instanceof Error ? error.message : String(error)}`,
|
|
170
197
|
data: { constraintId, error },
|
|
171
198
|
});
|
|
@@ -184,7 +211,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
184
211
|
/**
|
|
185
212
|
* Update the context directly (for exceptional cases).
|
|
186
213
|
* Generally, context should be updated through rules.
|
|
187
|
-
*
|
|
214
|
+
*
|
|
188
215
|
* @param updater Function that produces new context from old context
|
|
189
216
|
*/
|
|
190
217
|
updateContext(updater: (context: TContext) => TContext): void {
|
|
@@ -197,7 +224,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
197
224
|
/**
|
|
198
225
|
* Add facts directly (for exceptional cases).
|
|
199
226
|
* Generally, facts should be added through rules.
|
|
200
|
-
*
|
|
227
|
+
*
|
|
201
228
|
* @param facts Facts to add
|
|
202
229
|
*/
|
|
203
230
|
addFacts(facts: PraxisFact[]): void {
|
|
@@ -232,7 +259,7 @@ export class LogicEngine<TContext = unknown> {
|
|
|
232
259
|
|
|
233
260
|
/**
|
|
234
261
|
* Create a new Praxis logic engine.
|
|
235
|
-
*
|
|
262
|
+
*
|
|
236
263
|
* @param options Engine options
|
|
237
264
|
* @returns New LogicEngine instance
|
|
238
265
|
*/
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Introspection and Visualization Utilities
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Provides APIs to introspect the registry, generate schemas,
|
|
5
5
|
* and export graph representations for external tools.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { PraxisRegistry, RuleDescriptor, ConstraintDescriptor } from
|
|
8
|
+
import type { PraxisRegistry, RuleDescriptor, ConstraintDescriptor } from './rules.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Graph node representing a rule in the system
|
|
12
12
|
*/
|
|
13
13
|
export interface RuleNode {
|
|
14
14
|
id: string;
|
|
15
|
-
type:
|
|
15
|
+
type: 'rule';
|
|
16
16
|
description: string;
|
|
17
17
|
meta?: Record<string, unknown>;
|
|
18
18
|
}
|
|
@@ -22,7 +22,7 @@ export interface RuleNode {
|
|
|
22
22
|
*/
|
|
23
23
|
export interface ConstraintNode {
|
|
24
24
|
id: string;
|
|
25
|
-
type:
|
|
25
|
+
type: 'constraint';
|
|
26
26
|
description: string;
|
|
27
27
|
meta?: Record<string, unknown>;
|
|
28
28
|
}
|
|
@@ -33,7 +33,7 @@ export interface ConstraintNode {
|
|
|
33
33
|
export interface GraphEdge {
|
|
34
34
|
from: string;
|
|
35
35
|
to: string;
|
|
36
|
-
type:
|
|
36
|
+
type: 'triggers' | 'constrains' | 'depends-on';
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -55,7 +55,7 @@ export interface RegistryGraph {
|
|
|
55
55
|
export interface RuleSchema {
|
|
56
56
|
id: string;
|
|
57
57
|
description: string;
|
|
58
|
-
type:
|
|
58
|
+
type: 'rule';
|
|
59
59
|
meta?: Record<string, unknown>;
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -65,7 +65,7 @@ export interface RuleSchema {
|
|
|
65
65
|
export interface ConstraintSchema {
|
|
66
66
|
id: string;
|
|
67
67
|
description: string;
|
|
68
|
-
type:
|
|
68
|
+
type: 'constraint';
|
|
69
69
|
meta?: Record<string, unknown>;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -119,14 +119,14 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
119
119
|
const rules: RuleSchema[] = this.registry.getAllRules().map((rule) => ({
|
|
120
120
|
id: rule.id,
|
|
121
121
|
description: rule.description,
|
|
122
|
-
type:
|
|
122
|
+
type: 'rule' as const,
|
|
123
123
|
meta: rule.meta,
|
|
124
124
|
}));
|
|
125
125
|
|
|
126
126
|
const constraints: ConstraintSchema[] = this.registry.getAllConstraints().map((constraint) => ({
|
|
127
127
|
id: constraint.id,
|
|
128
128
|
description: constraint.description,
|
|
129
|
-
type:
|
|
129
|
+
type: 'constraint' as const,
|
|
130
130
|
meta: constraint.meta,
|
|
131
131
|
}));
|
|
132
132
|
|
|
@@ -143,7 +143,7 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Generate a graph representation of the registry
|
|
146
|
-
*
|
|
146
|
+
*
|
|
147
147
|
* This creates nodes for rules and constraints.
|
|
148
148
|
* Edges can be inferred from metadata if rules/constraints
|
|
149
149
|
* document their dependencies.
|
|
@@ -156,7 +156,7 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
156
156
|
for (const rule of this.registry.getAllRules()) {
|
|
157
157
|
nodes.push({
|
|
158
158
|
id: rule.id,
|
|
159
|
-
type:
|
|
159
|
+
type: 'rule',
|
|
160
160
|
description: rule.description,
|
|
161
161
|
meta: rule.meta,
|
|
162
162
|
});
|
|
@@ -170,7 +170,7 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
170
170
|
edges.push({
|
|
171
171
|
from: String(dep),
|
|
172
172
|
to: rule.id,
|
|
173
|
-
type:
|
|
173
|
+
type: 'depends-on',
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -180,7 +180,7 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
180
180
|
for (const constraint of this.registry.getAllConstraints()) {
|
|
181
181
|
nodes.push({
|
|
182
182
|
id: constraint.id,
|
|
183
|
-
type:
|
|
183
|
+
type: 'constraint',
|
|
184
184
|
description: constraint.description,
|
|
185
185
|
meta: constraint.meta,
|
|
186
186
|
});
|
|
@@ -194,7 +194,7 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
194
194
|
edges.push({
|
|
195
195
|
from: constraint.id,
|
|
196
196
|
to: String(target),
|
|
197
|
-
type:
|
|
197
|
+
type: 'constrains',
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -205,75 +205,77 @@ export class RegistryIntrospector<TContext = unknown> {
|
|
|
205
205
|
edges,
|
|
206
206
|
meta: {
|
|
207
207
|
nodeCount: nodes.length,
|
|
208
|
-
ruleCount: nodes.filter((n) => n.type ===
|
|
209
|
-
constraintCount: nodes.filter((n) => n.type ===
|
|
208
|
+
ruleCount: nodes.filter((n) => n.type === 'rule').length,
|
|
209
|
+
constraintCount: nodes.filter((n) => n.type === 'constraint').length,
|
|
210
210
|
},
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
215
|
* Export graph in DOT format (Graphviz)
|
|
216
|
-
*
|
|
216
|
+
*
|
|
217
217
|
* This can be rendered with Graphviz tools or online services.
|
|
218
218
|
*/
|
|
219
219
|
exportDOT(): string {
|
|
220
220
|
const graph = this.generateGraph();
|
|
221
221
|
const lines: string[] = [];
|
|
222
222
|
|
|
223
|
-
lines.push(
|
|
224
|
-
lines.push(
|
|
225
|
-
lines.push(
|
|
226
|
-
lines.push(
|
|
223
|
+
lines.push('digraph PraxisRegistry {');
|
|
224
|
+
lines.push(' rankdir=TB;');
|
|
225
|
+
lines.push(' node [shape=box, style=rounded];');
|
|
226
|
+
lines.push('');
|
|
227
227
|
|
|
228
228
|
// Add nodes
|
|
229
229
|
for (const node of graph.nodes) {
|
|
230
|
-
const shape = node.type ===
|
|
231
|
-
const color = node.type ===
|
|
230
|
+
const shape = node.type === 'rule' ? 'box' : 'diamond';
|
|
231
|
+
const color = node.type === 'rule' ? 'lightblue' : 'lightcoral';
|
|
232
232
|
const label = `${node.id}\\n${node.description}`;
|
|
233
|
-
lines.push(
|
|
233
|
+
lines.push(
|
|
234
|
+
` "${node.id}" [label="${label}", shape=${shape}, style=filled, fillcolor=${color}];`
|
|
235
|
+
);
|
|
234
236
|
}
|
|
235
237
|
|
|
236
|
-
lines.push(
|
|
238
|
+
lines.push('');
|
|
237
239
|
|
|
238
240
|
// Add edges
|
|
239
241
|
for (const edge of graph.edges) {
|
|
240
|
-
const style = edge.type ===
|
|
242
|
+
const style = edge.type === 'constrains' ? 'dashed' : 'solid';
|
|
241
243
|
lines.push(` "${edge.from}" -> "${edge.to}" [label="${edge.type}", style=${style}];`);
|
|
242
244
|
}
|
|
243
245
|
|
|
244
|
-
lines.push(
|
|
246
|
+
lines.push('}');
|
|
245
247
|
|
|
246
|
-
return lines.join(
|
|
248
|
+
return lines.join('\n');
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
/**
|
|
250
252
|
* Export graph in Mermaid format
|
|
251
|
-
*
|
|
253
|
+
*
|
|
252
254
|
* Mermaid is a markdown-friendly diagramming language.
|
|
253
255
|
*/
|
|
254
256
|
exportMermaid(): string {
|
|
255
257
|
const graph = this.generateGraph();
|
|
256
258
|
const lines: string[] = [];
|
|
257
259
|
|
|
258
|
-
lines.push(
|
|
260
|
+
lines.push('graph TB');
|
|
259
261
|
|
|
260
262
|
// Add nodes
|
|
261
263
|
for (const node of graph.nodes) {
|
|
262
|
-
const shape = node.type ===
|
|
263
|
-
const endShape = node.type ===
|
|
264
|
+
const shape = node.type === 'rule' ? '[' : '{';
|
|
265
|
+
const endShape = node.type === 'rule' ? ']' : '}';
|
|
264
266
|
const label = `${node.id}<br/>${node.description}`;
|
|
265
267
|
lines.push(` ${node.id}${shape}"${label}"${endShape}`);
|
|
266
268
|
}
|
|
267
269
|
|
|
268
|
-
lines.push(
|
|
270
|
+
lines.push('');
|
|
269
271
|
|
|
270
272
|
// Add edges
|
|
271
273
|
for (const edge of graph.edges) {
|
|
272
|
-
const arrow = edge.type ===
|
|
274
|
+
const arrow = edge.type === 'constrains' ? '-.->|constrains|' : '-->|' + edge.type + '|';
|
|
273
275
|
lines.push(` ${edge.from} ${arrow} ${edge.to}`);
|
|
274
276
|
}
|
|
275
277
|
|
|
276
|
-
return lines.join(
|
|
278
|
+
return lines.join('\n');
|
|
277
279
|
}
|
|
278
280
|
|
|
279
281
|
/**
|