@plures/praxis 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -97
- 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/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/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
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PluresDB Integration Module
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module exports all PluresDB-related types and functions for Praxis.
|
|
5
5
|
* It provides the core adapter layer, store, and schema registry.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// Adapter - Core interface and in-memory implementation
|
|
9
|
-
export type { PraxisDB, UnsubscribeFn } from
|
|
10
|
-
export { InMemoryPraxisDB, createInMemoryDB } from
|
|
9
|
+
export type { PraxisDB, UnsubscribeFn } from './adapter.js';
|
|
10
|
+
export { InMemoryPraxisDB, createInMemoryDB } from './adapter.js';
|
|
11
11
|
|
|
12
12
|
// Store - Manages facts, events, and reactive updates
|
|
13
|
-
export type { EventStreamEntry, PraxisDBStoreOptions, RuleErrorHandler } from
|
|
13
|
+
export type { EventStreamEntry, PraxisDBStoreOptions, RuleErrorHandler } from './store.js';
|
|
14
14
|
export {
|
|
15
15
|
PraxisDBStore,
|
|
16
16
|
createPraxisDBStore,
|
|
@@ -18,20 +18,17 @@ export {
|
|
|
18
18
|
getFactPath,
|
|
19
19
|
getEventPath,
|
|
20
20
|
generateId,
|
|
21
|
-
} from
|
|
21
|
+
} from './store.js';
|
|
22
22
|
|
|
23
23
|
// Schema Registry - Schema definitions in PluresDB
|
|
24
|
-
export type { StoredSchema } from
|
|
24
|
+
export type { StoredSchema } from './schema-registry.js';
|
|
25
25
|
export {
|
|
26
26
|
PraxisSchemaRegistry,
|
|
27
27
|
createSchemaRegistry,
|
|
28
28
|
registerSchema,
|
|
29
29
|
getSchemaPath,
|
|
30
|
-
} from
|
|
30
|
+
} from './schema-registry.js';
|
|
31
31
|
|
|
32
32
|
// Config Generator - Generate PluresDB config from schemas
|
|
33
|
-
export type {
|
|
34
|
-
|
|
35
|
-
GeneratedPluresDBFile,
|
|
36
|
-
} from "./generator.js";
|
|
37
|
-
export { PluresDBGenerator, createPluresDBGenerator } from "./generator.js";
|
|
33
|
+
export type { PluresDBGeneratorOptions, GeneratedPluresDBFile } from './generator.js';
|
|
34
|
+
export { PluresDBGenerator, createPluresDBGenerator } from './generator.js';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Praxis Schema Registry for PluresDB
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Registers Praxis schema definitions in PluresDB for type-safe storage
|
|
5
5
|
* and cross-agent schema discovery.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { PraxisDB } from
|
|
9
|
-
import type { PraxisSchema } from
|
|
10
|
-
import { PRAXIS_PATHS } from
|
|
8
|
+
import type { PraxisDB } from './adapter.js';
|
|
9
|
+
import type { PraxisSchema } from '../schema/types.js';
|
|
10
|
+
import { PRAXIS_PATHS } from './store.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Get the path for a schema in PluresDB
|
|
@@ -31,7 +31,7 @@ export interface StoredSchema {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* PraxisSchemaRegistry
|
|
34
|
-
*
|
|
34
|
+
*
|
|
35
35
|
* Manages schema definitions in PluresDB.
|
|
36
36
|
* Schemas are stored under `/_praxis/schemas/<schemaName>`
|
|
37
37
|
*/
|
|
@@ -44,24 +44,24 @@ export class PraxisSchemaRegistry {
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Register a schema in PluresDB
|
|
47
|
-
*
|
|
47
|
+
*
|
|
48
48
|
* @param schema The schema to register
|
|
49
49
|
*/
|
|
50
50
|
async register(schema: PraxisSchema): Promise<void> {
|
|
51
51
|
const path = getSchemaPath(schema.name);
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
const storedSchema: StoredSchema = {
|
|
54
54
|
schema,
|
|
55
55
|
registeredAt: Date.now(),
|
|
56
56
|
version: schema.version,
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
await this.db.set(path, storedSchema);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Get a schema by name
|
|
64
|
-
*
|
|
64
|
+
*
|
|
65
65
|
* @param schemaName The schema name
|
|
66
66
|
* @returns The stored schema or undefined if not found
|
|
67
67
|
*/
|
|
@@ -72,7 +72,7 @@ export class PraxisSchemaRegistry {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Check if a schema is registered
|
|
75
|
-
*
|
|
75
|
+
*
|
|
76
76
|
* @param schemaName The schema name
|
|
77
77
|
* @returns True if the schema exists
|
|
78
78
|
*/
|
|
@@ -83,7 +83,7 @@ export class PraxisSchemaRegistry {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Update a schema (replaces existing)
|
|
86
|
-
*
|
|
86
|
+
*
|
|
87
87
|
* @param schema The updated schema
|
|
88
88
|
*/
|
|
89
89
|
async update(schema: PraxisSchema): Promise<void> {
|
|
@@ -92,12 +92,12 @@ export class PraxisSchemaRegistry {
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* List all registered schema names
|
|
95
|
-
*
|
|
95
|
+
*
|
|
96
96
|
* Implementation note: This method uses an index stored at `/_praxis/schemas/_index`.
|
|
97
97
|
* When using InMemoryPraxisDB, schemas must be registered using `registerWithIndex()`
|
|
98
98
|
* for them to appear in this listing. When using a full PluresDB implementation,
|
|
99
99
|
* native listing capabilities should be used instead.
|
|
100
|
-
*
|
|
100
|
+
*
|
|
101
101
|
* @returns Array of registered schema names
|
|
102
102
|
*/
|
|
103
103
|
async list(): Promise<string[]> {
|
|
@@ -108,17 +108,17 @@ export class PraxisSchemaRegistry {
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Register a schema and update the index
|
|
111
|
-
*
|
|
111
|
+
*
|
|
112
112
|
* @param schema The schema to register
|
|
113
113
|
*/
|
|
114
114
|
async registerWithIndex(schema: PraxisSchema): Promise<void> {
|
|
115
115
|
// Register the schema
|
|
116
116
|
await this.register(schema);
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
// Update the index
|
|
119
119
|
const indexPath = `${PRAXIS_PATHS.SCHEMAS}/_index`;
|
|
120
|
-
const existingIndex = await this.db.get<string[]>(indexPath) ?? [];
|
|
121
|
-
|
|
120
|
+
const existingIndex = (await this.db.get<string[]>(indexPath)) ?? [];
|
|
121
|
+
|
|
122
122
|
if (!existingIndex.includes(schema.name)) {
|
|
123
123
|
await this.db.set(indexPath, [...existingIndex, schema.name]);
|
|
124
124
|
}
|
|
@@ -127,12 +127,12 @@ export class PraxisSchemaRegistry {
|
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Register a schema in PluresDB
|
|
130
|
-
*
|
|
130
|
+
*
|
|
131
131
|
* Convenience function for one-off schema registration.
|
|
132
|
-
*
|
|
132
|
+
*
|
|
133
133
|
* @param db The PraxisDB instance
|
|
134
134
|
* @param schema The schema to register
|
|
135
|
-
*
|
|
135
|
+
*
|
|
136
136
|
* @example
|
|
137
137
|
* ```typescript
|
|
138
138
|
* const db = createInMemoryDB();
|
|
@@ -143,17 +143,14 @@ export class PraxisSchemaRegistry {
|
|
|
143
143
|
* });
|
|
144
144
|
* ```
|
|
145
145
|
*/
|
|
146
|
-
export async function registerSchema(
|
|
147
|
-
db: PraxisDB,
|
|
148
|
-
schema: PraxisSchema
|
|
149
|
-
): Promise<void> {
|
|
146
|
+
export async function registerSchema(db: PraxisDB, schema: PraxisSchema): Promise<void> {
|
|
150
147
|
const registry = new PraxisSchemaRegistry(db);
|
|
151
148
|
await registry.registerWithIndex(schema);
|
|
152
149
|
}
|
|
153
150
|
|
|
154
151
|
/**
|
|
155
152
|
* Create a PraxisSchemaRegistry instance
|
|
156
|
-
*
|
|
153
|
+
*
|
|
157
154
|
* @param db The PraxisDB instance
|
|
158
155
|
* @returns PraxisSchemaRegistry instance
|
|
159
156
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PraxisDB Store
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Connects Praxis Facts, Events, Rules, and Constraints to PluresDB.
|
|
5
5
|
* Provides CRDT-backed storage for facts and append-only event streams.
|
|
6
6
|
*/
|
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
// Declare process for TypeScript in non-Node environments (e.g., Deno)
|
|
9
9
|
declare const process: { env: { [key: string]: string | undefined } } | undefined;
|
|
10
10
|
|
|
11
|
-
import type { PraxisDB, UnsubscribeFn } from
|
|
12
|
-
import type { PraxisRegistry } from
|
|
13
|
-
import type { PraxisFact, PraxisEvent, PraxisState } from
|
|
11
|
+
import type { PraxisDB, UnsubscribeFn } from './adapter.js';
|
|
12
|
+
import type { PraxisRegistry } from '../rules.js';
|
|
13
|
+
import type { PraxisFact, PraxisEvent, PraxisState } from '../protocol.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Key paths for Praxis data in PluresDB
|
|
17
17
|
*/
|
|
18
18
|
export const PRAXIS_PATHS = {
|
|
19
19
|
/** Base path for all Praxis data */
|
|
20
|
-
BASE:
|
|
20
|
+
BASE: '/_praxis',
|
|
21
21
|
/** Path for facts storage */
|
|
22
|
-
FACTS:
|
|
22
|
+
FACTS: '/_praxis/facts',
|
|
23
23
|
/** Path for events storage */
|
|
24
|
-
EVENTS:
|
|
24
|
+
EVENTS: '/_praxis/events',
|
|
25
25
|
/** Path for schema registry */
|
|
26
|
-
SCHEMAS:
|
|
26
|
+
SCHEMAS: '/_praxis/schemas',
|
|
27
27
|
} as const;
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -80,9 +80,9 @@ export interface PraxisDBStoreOptions<TContext = unknown> {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* PraxisDBStore
|
|
83
|
-
*
|
|
83
|
+
*
|
|
84
84
|
* Manages persistence and reactive updates for Praxis state in PluresDB.
|
|
85
|
-
*
|
|
85
|
+
*
|
|
86
86
|
* - Facts are stored as CRDT-backed documents under `/_praxis/facts/<factTag>/<id>`
|
|
87
87
|
* - Events are stored as append-only streams under `/_praxis/events/<eventTag>`
|
|
88
88
|
* - Rules are triggered automatically when watched keys change
|
|
@@ -98,7 +98,7 @@ export type RuleErrorHandler = (ruleId: string, error: unknown) => void;
|
|
|
98
98
|
*/
|
|
99
99
|
const defaultErrorHandler: RuleErrorHandler = (ruleId, error) => {
|
|
100
100
|
// Default behavior: silent in production, can be overridden
|
|
101
|
-
if (typeof process !==
|
|
101
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') {
|
|
102
102
|
console.error(`Error executing rule "${ruleId}":`, error);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -120,10 +120,10 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Store a fact in PluresDB
|
|
123
|
-
*
|
|
123
|
+
*
|
|
124
124
|
* Facts are stored under `/_praxis/facts/<factTag>/<id>`
|
|
125
125
|
* If no id is provided in the payload, a timestamp-based id is used.
|
|
126
|
-
*
|
|
126
|
+
*
|
|
127
127
|
* @param fact The fact to store
|
|
128
128
|
* @returns Promise that resolves when the fact is stored
|
|
129
129
|
*/
|
|
@@ -131,31 +131,31 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
131
131
|
// Run constraints before storing
|
|
132
132
|
const constraintResult = await this.checkConstraints([fact]);
|
|
133
133
|
if (!constraintResult.valid) {
|
|
134
|
-
throw new Error(`Constraint violation: ${constraintResult.errors.join(
|
|
134
|
+
throw new Error(`Constraint violation: ${constraintResult.errors.join(', ')}`);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
await this.persistFact(fact);
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
// Trigger rule evaluation - facts stored directly may trigger derived computations
|
|
140
140
|
await this.triggerRules([fact]);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Store multiple facts in PluresDB
|
|
145
|
-
*
|
|
145
|
+
*
|
|
146
146
|
* @param facts The facts to store
|
|
147
147
|
*/
|
|
148
148
|
async storeFacts(facts: PraxisFact[]): Promise<void> {
|
|
149
149
|
// Run constraints before storing
|
|
150
150
|
const constraintResult = await this.checkConstraints(facts);
|
|
151
151
|
if (!constraintResult.valid) {
|
|
152
|
-
throw new Error(`Constraint violation: ${constraintResult.errors.join(
|
|
152
|
+
throw new Error(`Constraint violation: ${constraintResult.errors.join(', ')}`);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
for (const fact of facts) {
|
|
156
156
|
await this.persistFact(fact);
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
// Trigger rule evaluation
|
|
160
160
|
await this.triggerRules(facts);
|
|
161
161
|
}
|
|
@@ -173,7 +173,7 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Get a fact by tag and id
|
|
176
|
-
*
|
|
176
|
+
*
|
|
177
177
|
* @param factTag The fact type tag
|
|
178
178
|
* @param id The fact id
|
|
179
179
|
* @returns The fact or undefined if not found
|
|
@@ -185,35 +185,35 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
187
|
* Append an event to the event stream
|
|
188
|
-
*
|
|
188
|
+
*
|
|
189
189
|
* Events are stored as append-only streams under `/_praxis/events/<eventTag>`
|
|
190
|
-
*
|
|
190
|
+
*
|
|
191
191
|
* @param event The event to append
|
|
192
192
|
*/
|
|
193
193
|
async appendEvent(event: PraxisEvent): Promise<void> {
|
|
194
194
|
const path = getEventPath(event.tag);
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
// Get existing events for this tag
|
|
197
|
-
const existingEvents = await this.db.get<EventStreamEntry[]>(path) ?? [];
|
|
198
|
-
|
|
197
|
+
const existingEvents = (await this.db.get<EventStreamEntry[]>(path)) ?? [];
|
|
198
|
+
|
|
199
199
|
// Create new entry
|
|
200
200
|
const entry: EventStreamEntry = {
|
|
201
201
|
event,
|
|
202
202
|
timestamp: Date.now(),
|
|
203
203
|
sequence: existingEvents.length,
|
|
204
204
|
};
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
// Append and store
|
|
207
207
|
const newEvents = [...existingEvents, entry];
|
|
208
208
|
await this.db.set(path, newEvents);
|
|
209
|
-
|
|
209
|
+
|
|
210
210
|
// Trigger rules with this event
|
|
211
211
|
await this.triggerRulesForEvents([event]);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
215
|
* Append multiple events to their respective streams
|
|
216
|
-
*
|
|
216
|
+
*
|
|
217
217
|
* @param events The events to append
|
|
218
218
|
*/
|
|
219
219
|
async appendEvents(events: PraxisEvent[]): Promise<void> {
|
|
@@ -223,29 +223,29 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
223
223
|
const existing = eventsByTag.get(event.tag) ?? [];
|
|
224
224
|
eventsByTag.set(event.tag, [...existing, event]);
|
|
225
225
|
}
|
|
226
|
-
|
|
226
|
+
|
|
227
227
|
// Append each group
|
|
228
228
|
for (const [tag, tagEvents] of eventsByTag) {
|
|
229
229
|
const path = getEventPath(tag);
|
|
230
|
-
const existingEvents = await this.db.get<EventStreamEntry[]>(path) ?? [];
|
|
230
|
+
const existingEvents = (await this.db.get<EventStreamEntry[]>(path)) ?? [];
|
|
231
231
|
let sequence = existingEvents.length;
|
|
232
|
-
|
|
233
|
-
const newEntries = tagEvents.map(event => ({
|
|
232
|
+
|
|
233
|
+
const newEntries = tagEvents.map((event) => ({
|
|
234
234
|
event,
|
|
235
235
|
timestamp: Date.now(),
|
|
236
236
|
sequence: sequence++,
|
|
237
237
|
}));
|
|
238
|
-
|
|
238
|
+
|
|
239
239
|
await this.db.set(path, [...existingEvents, ...newEntries]);
|
|
240
240
|
}
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
// Trigger rules
|
|
243
243
|
await this.triggerRulesForEvents(events);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
247
|
* Get events from a stream
|
|
248
|
-
*
|
|
248
|
+
*
|
|
249
249
|
* @param eventTag The event type tag
|
|
250
250
|
* @param options Query options
|
|
251
251
|
* @returns Array of event stream entries
|
|
@@ -255,32 +255,32 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
255
255
|
options?: { since?: number; limit?: number }
|
|
256
256
|
): Promise<EventStreamEntry[]> {
|
|
257
257
|
const path = getEventPath(eventTag);
|
|
258
|
-
const events = await this.db.get<EventStreamEntry[]>(path) ?? [];
|
|
259
|
-
|
|
258
|
+
const events = (await this.db.get<EventStreamEntry[]>(path)) ?? [];
|
|
259
|
+
|
|
260
260
|
let result = events;
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
if (options?.since !== undefined) {
|
|
263
263
|
const sinceTimestamp = options.since;
|
|
264
|
-
result = result.filter(e => e.timestamp > sinceTimestamp);
|
|
264
|
+
result = result.filter((e) => e.timestamp > sinceTimestamp);
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
|
|
267
267
|
if (options?.limit !== undefined) {
|
|
268
268
|
result = result.slice(-options.limit);
|
|
269
269
|
}
|
|
270
|
-
|
|
270
|
+
|
|
271
271
|
return result;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
275
|
* Watch a fact path for changes
|
|
276
|
-
*
|
|
276
|
+
*
|
|
277
277
|
* @param factTag The fact type tag to watch
|
|
278
278
|
* @param callback Called when facts of this type change
|
|
279
279
|
* @returns Unsubscribe function
|
|
280
280
|
*/
|
|
281
281
|
watchFacts(factTag: string, callback: (facts: PraxisFact[]) => void): UnsubscribeFn {
|
|
282
282
|
const path = getFactPath(factTag);
|
|
283
|
-
|
|
283
|
+
|
|
284
284
|
// Register the callback
|
|
285
285
|
if (!this.factWatchers.has(factTag)) {
|
|
286
286
|
this.factWatchers.set(factTag, new Set());
|
|
@@ -289,14 +289,14 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
289
289
|
if (watchers) {
|
|
290
290
|
watchers.add(callback);
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
|
|
293
293
|
// Watch the path in the DB
|
|
294
294
|
const unsubscribe = this.db.watch<PraxisFact>(path, (fact) => {
|
|
295
295
|
callback([fact]);
|
|
296
296
|
});
|
|
297
|
-
|
|
297
|
+
|
|
298
298
|
this.subscriptions.push(unsubscribe);
|
|
299
|
-
|
|
299
|
+
|
|
300
300
|
return () => {
|
|
301
301
|
unsubscribe();
|
|
302
302
|
this.factWatchers.get(factTag)?.delete(callback);
|
|
@@ -311,20 +311,20 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
311
311
|
): Promise<{ valid: boolean; errors: string[] }> {
|
|
312
312
|
const constraints = this.registry.getAllConstraints();
|
|
313
313
|
const errors: string[] = [];
|
|
314
|
-
|
|
314
|
+
|
|
315
315
|
// Build a minimal state for constraint checking
|
|
316
316
|
const state: PraxisState & { context: TContext } = {
|
|
317
317
|
context: this.context,
|
|
318
318
|
facts: newFacts,
|
|
319
319
|
meta: {},
|
|
320
320
|
};
|
|
321
|
-
|
|
321
|
+
|
|
322
322
|
for (const constraint of constraints) {
|
|
323
323
|
try {
|
|
324
324
|
const result = constraint.impl(state);
|
|
325
325
|
if (result === false) {
|
|
326
326
|
errors.push(`Constraint "${constraint.id}" violated`);
|
|
327
|
-
} else if (typeof result ===
|
|
327
|
+
} else if (typeof result === 'string') {
|
|
328
328
|
errors.push(result);
|
|
329
329
|
}
|
|
330
330
|
} catch (error) {
|
|
@@ -333,7 +333,7 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
333
333
|
);
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
336
|
+
|
|
337
337
|
return {
|
|
338
338
|
valid: errors.length === 0,
|
|
339
339
|
errors,
|
|
@@ -342,12 +342,12 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
342
342
|
|
|
343
343
|
/**
|
|
344
344
|
* Trigger rules when new facts are added
|
|
345
|
-
*
|
|
345
|
+
*
|
|
346
346
|
* This method is called after facts are stored. It can be extended
|
|
347
347
|
* for derived fact computation where rules generate new facts based
|
|
348
348
|
* on existing facts. Currently implemented as a hook point for future
|
|
349
349
|
* enhancements.
|
|
350
|
-
*
|
|
350
|
+
*
|
|
351
351
|
* @param _newFacts The newly stored facts (unused in current implementation)
|
|
352
352
|
*/
|
|
353
353
|
private async triggerRules(_newFacts: PraxisFact[]): Promise<void> {
|
|
@@ -361,14 +361,14 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
361
361
|
*/
|
|
362
362
|
private async triggerRulesForEvents(events: PraxisEvent[]): Promise<void> {
|
|
363
363
|
const rules = this.registry.getAllRules();
|
|
364
|
-
|
|
364
|
+
|
|
365
365
|
// Build state for rule evaluation
|
|
366
366
|
const state: PraxisState & { context: TContext } = {
|
|
367
367
|
context: this.context,
|
|
368
368
|
facts: [],
|
|
369
369
|
meta: {},
|
|
370
370
|
};
|
|
371
|
-
|
|
371
|
+
|
|
372
372
|
// Execute each rule
|
|
373
373
|
const derivedFacts: PraxisFact[] = [];
|
|
374
374
|
for (const rule of rules) {
|
|
@@ -379,7 +379,7 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
379
379
|
this.onRuleError(rule.id, error);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
|
|
382
|
+
|
|
383
383
|
// Store derived facts (without re-triggering rules to avoid infinite loops)
|
|
384
384
|
if (derivedFacts.length > 0) {
|
|
385
385
|
const constraintResult = await this.checkConstraints(derivedFacts);
|
|
@@ -419,19 +419,19 @@ export class PraxisDBStore<TContext = unknown> {
|
|
|
419
419
|
|
|
420
420
|
/**
|
|
421
421
|
* Create a new PraxisDBStore
|
|
422
|
-
*
|
|
422
|
+
*
|
|
423
423
|
* @param db The PraxisDB instance to use
|
|
424
424
|
* @param registry The PraxisRegistry for rules and constraints
|
|
425
425
|
* @param initialContext Optional initial context
|
|
426
426
|
* @param onRuleError Optional error handler for rule execution errors
|
|
427
427
|
* @returns PraxisDBStore instance
|
|
428
|
-
*
|
|
428
|
+
*
|
|
429
429
|
* @example
|
|
430
430
|
* ```typescript
|
|
431
431
|
* const db = createInMemoryDB();
|
|
432
432
|
* const registry = new PraxisRegistry();
|
|
433
433
|
* const store = createPraxisDBStore(db, registry);
|
|
434
|
-
*
|
|
434
|
+
*
|
|
435
435
|
* await store.storeFact({ tag: "UserLoggedIn", payload: { userId: "alice" } });
|
|
436
436
|
* await store.appendEvent({ tag: "LOGIN", payload: { username: "alice" } });
|
|
437
437
|
* ```
|
package/src/core/protocol.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core Praxis Protocol
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Language-neutral, JSON-friendly protocol that forms the foundation of Praxis.
|
|
5
5
|
* This protocol is designed to be stable and portable across languages (TypeScript, C#, PowerShell, etc.)
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* The protocol defines the conceptual core of the engine:
|
|
8
8
|
* - Pure, deterministic, data in → data out
|
|
9
9
|
* - No side effects, no global state
|
|
10
10
|
* - All higher-level TypeScript APIs are built on top of this protocol
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* ## Protocol Versioning
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* The Praxis protocol follows semantic versioning (MAJOR.MINOR.PATCH):
|
|
15
15
|
* - MAJOR: Breaking changes to core protocol types or semantics
|
|
16
16
|
* - MINOR: Backward-compatible additions to protocol (new optional fields)
|
|
17
17
|
* - PATCH: Clarifications, documentation updates, no functional changes
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* Current version: 1.0.0
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
* ### Stability Guarantees
|
|
22
|
-
*
|
|
22
|
+
*
|
|
23
23
|
* 1. **Core Types Stability**: The following types are considered stable and will not
|
|
24
24
|
* change in backward-incompatible ways within the same major version:
|
|
25
25
|
* - PraxisFact (tag, payload structure)
|
|
26
26
|
* - PraxisEvent (tag, payload structure)
|
|
27
27
|
* - PraxisState (context, facts, meta structure)
|
|
28
28
|
* - PraxisStepFn signature
|
|
29
|
-
*
|
|
29
|
+
*
|
|
30
30
|
* 2. **JSON Compatibility**: All protocol types will remain JSON-serializable.
|
|
31
31
|
* No non-JSON-safe types (functions, symbols, etc.) will be added to the protocol.
|
|
32
|
-
*
|
|
32
|
+
*
|
|
33
33
|
* 3. **Cross-Language Compatibility**: Protocol changes will be coordinated across
|
|
34
34
|
* all official language implementations (TypeScript, C#, PowerShell) to ensure
|
|
35
35
|
* interoperability.
|
|
36
|
-
*
|
|
36
|
+
*
|
|
37
37
|
* 4. **Migration Path**: Major version changes will be accompanied by:
|
|
38
38
|
* - Migration guide
|
|
39
39
|
* - Deprecation warnings in previous version
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
/**
|
|
44
44
|
* Protocol version following semantic versioning
|
|
45
45
|
*/
|
|
46
|
-
export const PRAXIS_PROTOCOL_VERSION =
|
|
46
|
+
export const PRAXIS_PROTOCOL_VERSION = '1.0.0' as const;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* A fact is a typed proposition about the domain.
|
|
@@ -86,7 +86,7 @@ export interface PraxisState {
|
|
|
86
86
|
*/
|
|
87
87
|
export interface PraxisDiagnostics {
|
|
88
88
|
/** Kind of diagnostic */
|
|
89
|
-
kind:
|
|
89
|
+
kind: 'constraint-violation' | 'rule-error';
|
|
90
90
|
/** Human-readable message */
|
|
91
91
|
message: string;
|
|
92
92
|
/** Additional diagnostic data */
|
|
@@ -116,12 +116,12 @@ export interface PraxisStepResult {
|
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* The core step function of the Praxis engine.
|
|
119
|
-
*
|
|
119
|
+
*
|
|
120
120
|
* This is the conceptual heart of the engine:
|
|
121
121
|
* - Takes current state, events, and configuration
|
|
122
122
|
* - Applies rules and checks constraints
|
|
123
123
|
* - Returns new state and diagnostics
|
|
124
|
-
*
|
|
124
|
+
*
|
|
125
125
|
* Pure, deterministic, data in → data out.
|
|
126
126
|
* No side effects, no global state.
|
|
127
127
|
*/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Praxis Reactive Logic Engine
|
|
3
|
+
*
|
|
4
|
+
* A Svelte 5 native implementation of the Praxis Logic Engine.
|
|
5
|
+
* Uses Runes ($state, $derived, $effect) for fine-grained reactivity.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface ReactiveEngineOptions<TContext> {
|
|
9
|
+
initialContext: TContext;
|
|
10
|
+
initialFacts?: any[];
|
|
11
|
+
initialMeta?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ReactiveLogicEngine<TContext extends object> {
|
|
15
|
+
// The single source of truth, reactive by default
|
|
16
|
+
// We use $state.raw for things that shouldn't be deeply reactive if needed,
|
|
17
|
+
// but for context we usually want deep reactivity.
|
|
18
|
+
state = $state<{
|
|
19
|
+
context: TContext;
|
|
20
|
+
facts: any[];
|
|
21
|
+
meta: Record<string, unknown>;
|
|
22
|
+
}>({
|
|
23
|
+
context: {} as TContext,
|
|
24
|
+
facts: [],
|
|
25
|
+
meta: {}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
constructor(options: ReactiveEngineOptions<TContext>) {
|
|
29
|
+
this.state.context = options.initialContext;
|
|
30
|
+
this.state.facts = options.initialFacts ?? [];
|
|
31
|
+
this.state.meta = options.initialMeta ?? {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Access the reactive context directly.
|
|
36
|
+
* Consumers can use this in $derived() or $effect().
|
|
37
|
+
*/
|
|
38
|
+
get context() {
|
|
39
|
+
return this.state.context;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Access the reactive facts list.
|
|
44
|
+
*/
|
|
45
|
+
get facts() {
|
|
46
|
+
return this.state.facts;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Apply a mutation to the state.
|
|
51
|
+
* This is the "Action" or "Rule" equivalent.
|
|
52
|
+
*
|
|
53
|
+
* @param mutator A function that receives the state and modifies it.
|
|
54
|
+
*/
|
|
55
|
+
apply(mutator: (state: { context: TContext; facts: any[]; meta: Record<string, unknown> }) => void) {
|
|
56
|
+
mutator(this.state);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Access the reactive meta.
|
|
61
|
+
*/
|
|
62
|
+
get meta() {
|
|
63
|
+
return this.state.meta;
|
|
64
|
+
}
|
|
65
|
+
}
|