@plures/praxis 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FRAMEWORK.md +55 -5
- package/README.md +162 -375
- package/core/codegen/docs-generator.ts +5 -2
- package/core/codegen/index.ts +1 -1
- package/core/db-adapter/index.ts +2 -2
- package/core/db-adapter/sync-engine.ts +17 -6
- package/core/logic-engine/engine.ts +1 -1
- package/core/logic-engine/index.ts +2 -2
- package/core/logic-engine/protocol.ts +1 -1
- package/core/logic-engine/psf-adapter.ts +8 -4
- package/core/logic-engine/rules.ts +1 -1
- package/core/schema-engine/compiler.ts +53 -11
- package/core/schema-engine/generator.ts +17 -7
- package/core/schema-engine/index.ts +2 -2
- package/core/schema-engine/psf.ts +12 -3
- package/core/schema-engine/types.ts +3 -11
- package/core/schema-engine/validator.ts +112 -22
- package/dist/browser/engine-BjdqxeXG.d.ts +333 -0
- package/dist/browser/index.d.ts +3004 -0
- package/dist/browser/index.js +2892 -0
- package/dist/{src → browser}/integrations/svelte.d.ts +19 -17
- package/dist/browser/integrations/svelte.js +298 -0
- package/dist/node/auth-STARLY7I.js +207 -0
- package/dist/node/build-Y7OT5VBF.js +144 -0
- package/dist/node/canvas-UERZHJYW.js +362 -0
- package/dist/node/chunk-DSDC2JWZ.js +256 -0
- package/dist/node/chunk-FXQZXAWF.js +175 -0
- package/dist/node/chunk-N5Y37EUV.js +202 -0
- package/dist/node/chunk-QGM4M3NI.js +37 -0
- package/dist/node/chunk-RJMWCNHR.js +175 -0
- package/dist/node/chunk-SRM3OPPM.js +404 -0
- package/dist/node/chunk-UATVJBNV.js +175 -0
- package/dist/node/chunk-UY7YEBE2.js +159 -0
- package/dist/node/chunk-XCY2VIFX.js +143 -0
- package/dist/node/chunk-YXH4Y7ZZ.js +349 -0
- package/dist/node/cli/index.cjs +215139 -0
- package/dist/node/cli/index.d.cts +1 -0
- package/dist/node/cli/index.d.ts +1 -0
- package/dist/node/cli/index.js +690 -0
- package/dist/node/cloud/index.cjs +1043 -0
- package/dist/node/cloud/index.d.cts +864 -0
- package/dist/node/cloud/index.d.ts +864 -0
- package/dist/node/cloud/index.js +456 -0
- package/dist/node/cloud-AXOK4PSN.js +212 -0
- package/dist/node/component.cjs +374 -0
- package/dist/node/component.d.cts +125 -0
- package/dist/{src/core/component/generator.d.ts → node/component.d.ts} +11 -8
- package/dist/node/component.js +9 -0
- package/dist/node/components/index.cjs +216 -0
- package/dist/node/components/index.d.cts +43 -0
- package/dist/{src → node}/components/index.d.ts +8 -8
- package/dist/node/components/index.js +7 -0
- package/dist/node/create-TRLSVCNQ.js +584 -0
- package/dist/node/dev-PMJZUYGE.js +65 -0
- package/dist/node/engine-1iqLe6_P.d.ts +214 -0
- package/dist/node/engine-CVJobhHm.d.cts +214 -0
- package/dist/node/index.cjs +3247 -0
- package/dist/node/index.d.cts +2579 -0
- package/dist/node/index.d.ts +2579 -0
- package/dist/node/index.js +2098 -0
- package/dist/node/integrations/svelte.cjs +330 -0
- package/dist/node/integrations/svelte.d.cts +309 -0
- package/dist/node/integrations/svelte.d.ts +309 -0
- package/dist/node/integrations/svelte.js +300 -0
- package/dist/node/orchestrate-737TCL5H.js +127 -0
- package/dist/{src/core/protocol.d.ts → node/protocol-Qek7ebBl.d.cts} +11 -10
- package/dist/node/protocol-Qek7ebBl.d.ts +122 -0
- package/dist/node/schema.cjs +200 -0
- package/dist/{src/core/schema/types.d.ts → node/schema.d.cts} +30 -29
- package/dist/node/schema.d.ts +371 -0
- package/dist/node/schema.js +9 -0
- package/dist/{src/runtime/terminal-adapter.d.ts → node/terminal-adapter-07HGftGQ.d.ts} +86 -11
- package/dist/node/terminal-adapter-XLtCjjb_.d.cts +231 -0
- package/dist/node/verify-QRYKRIDU.js +210960 -0
- package/docs/MONETIZATION.md +21 -16
- package/docs/REACTIVE_REDESIGN.md +132 -0
- package/docs/README.md +47 -36
- package/docs/SVELTE_INTEGRATION_STRATEGY.md +68 -0
- package/docs/TERMINAL_NODE.md +27 -24
- package/docs/core/building-extensions.md +58 -61
- package/docs/core/cli-usage.md +59 -59
- package/docs/core/code-canvas-sync.md +28 -16
- package/docs/core/logic-engine.md +77 -82
- package/docs/core/pluresdb-integration.md +29 -39
- package/docs/core/schema-model.md +66 -52
- package/docs/core/ui-generation.md +57 -49
- package/docs/core/what-is-praxis.md +32 -15
- package/docs/guides/canvas.md +21 -5
- package/docs/guides/getting-started.md +13 -7
- package/docs/guides/history-state-pattern.md +65 -51
- package/docs/guides/orchestration.md +46 -32
- package/docs/guides/parallel-state-pattern.md +56 -72
- package/docs/guides/svelte-integration.md +45 -53
- package/docs/tutorials/README.md +16 -0
- package/docs/tutorials/ecommerce-cart.md +177 -95
- package/docs/tutorials/first-app.md +26 -41
- package/docs/tutorials/form-builder.md +191 -138
- package/docs/tutorials/todo-pluresdb.md +71 -69
- package/package.json +58 -23
- package/src/__tests__/actors.test.ts +68 -68
- package/src/__tests__/billing.test.ts +32 -32
- package/src/__tests__/canvas-components.test.ts +94 -73
- package/src/__tests__/cli-create.test.ts +28 -28
- package/src/__tests__/cloud.test.ts +36 -36
- package/src/__tests__/code-canvas-integration.test.ts +132 -141
- package/src/__tests__/docs-generator.test.ts +3 -9
- package/src/__tests__/dsl.test.ts +58 -64
- package/src/__tests__/edge-cases.test.ts +106 -108
- package/src/__tests__/engine.test.ts +51 -25
- package/src/__tests__/generators.test.ts +42 -44
- package/src/__tests__/introspection.test.ts +104 -114
- package/src/__tests__/pluresdb.test.ts +189 -187
- package/src/__tests__/protocol.test.ts +15 -15
- package/src/__tests__/provisioning.test.ts +61 -61
- package/src/__tests__/schema.test.ts +7 -11
- package/src/__tests__/state-docs-integration.test.ts +162 -145
- package/src/__tests__/svelte-integration.test.ts +16 -19
- package/src/__tests__/tauri-integration.test.ts +149 -147
- package/src/__tests__/terminal-node.test.ts +12 -7
- package/src/__tests__/unum-integration.test.ts +68 -68
- package/src/adapters/cli.ts +21 -15
- package/src/cli/commands/auth.ts +82 -78
- package/src/cli/commands/build.ts +29 -27
- package/src/cli/commands/canvas.ts +338 -127
- package/src/cli/commands/cloud.ts +47 -47
- package/src/cli/commands/create.ts +59 -47
- package/src/cli/commands/dev.ts +12 -12
- package/src/cli/commands/generate.ts +29 -40
- package/src/cli/commands/orchestrate.ts +24 -24
- package/src/cli/commands/verify.ts +7 -8
- package/src/cli/index.ts +14 -10
- package/src/cloud/README.md +28 -15
- package/src/cloud/auth.ts +55 -70
- package/src/cloud/billing.ts +59 -58
- package/src/cloud/client.ts +29 -35
- package/src/cloud/index.ts +19 -40
- package/src/cloud/marketplace.ts +69 -78
- package/src/cloud/provisioning.ts +42 -51
- package/src/cloud/relay/endpoints.ts +30 -34
- package/src/cloud/relay/health/index.ts +1 -1
- package/src/cloud/relay/stats/index.ts +1 -1
- package/src/cloud/relay/sync/index.ts +1 -1
- package/src/cloud/relay/usage/index.ts +1 -1
- package/src/cloud/sponsors.ts +31 -34
- package/src/cloud/types.ts +4 -4
- package/src/components/README.md +1 -0
- package/src/components/index.ts +3 -4
- package/src/core/actors.ts +7 -7
- package/src/core/component/generator.ts +10 -28
- package/src/core/engine.ts +51 -24
- package/src/core/introspection.ts +37 -35
- package/src/core/logic/generator.ts +62 -62
- package/src/core/pluresdb/adapter.ts +8 -8
- package/src/core/pluresdb/generator.ts +39 -35
- package/src/core/pluresdb/index.ts +9 -12
- package/src/core/pluresdb/schema-registry.ts +22 -25
- package/src/core/pluresdb/store.ts +57 -57
- package/src/core/protocol.ts +14 -14
- package/src/core/reactive-engine.svelte.ts +65 -0
- package/src/core/reactive-engine.ts +67 -0
- package/src/core/rules.ts +4 -4
- package/src/core/schema/loader.common.ts +150 -0
- package/src/core/schema/loader.ts +19 -149
- package/src/core/schema/normalize.ts +34 -51
- package/src/core/schema/types.ts +47 -11
- package/src/dsl/index.ts +8 -8
- package/src/dsl.ts +11 -17
- package/src/examples/advanced-todo/README.md +58 -40
- package/src/examples/advanced-todo/index.ts +3 -3
- package/src/examples/auth-basic/index.ts +30 -30
- package/src/examples/cart/index.ts +50 -50
- package/src/examples/hero-ecommerce/index.ts +130 -157
- package/src/examples/svelte-counter/index.ts +22 -26
- package/src/flows.ts +6 -17
- package/src/index.browser.ts +204 -0
- package/src/index.ts +37 -42
- package/src/integrations/code-canvas.ts +237 -193
- package/src/integrations/pluresdb.ts +55 -35
- package/src/integrations/state-docs.ts +104 -104
- package/src/integrations/svelte.ts +35 -35
- package/src/integrations/tauri.ts +75 -73
- package/src/integrations/unum.ts +68 -61
- package/src/registry.ts +7 -14
- package/src/runtime/terminal-adapter.ts +31 -26
- package/src/step.ts +10 -16
- package/src/types.ts +1 -1
- package/templates/basic-app/README.md +6 -9
- package/templates/fullstack-app/README.md +10 -0
- package/dist/core/codegen/docs-generator.d.ts +0 -123
- package/dist/core/codegen/docs-generator.d.ts.map +0 -1
- package/dist/core/codegen/docs-generator.js +0 -674
- package/dist/core/codegen/docs-generator.js.map +0 -1
- package/dist/core/codegen/index.d.ts +0 -11
- package/dist/core/codegen/index.d.ts.map +0 -1
- package/dist/core/codegen/index.js +0 -13
- package/dist/core/codegen/index.js.map +0 -1
- package/dist/core/codegen/ts-generator.d.ts +0 -8
- package/dist/core/codegen/ts-generator.d.ts.map +0 -1
- package/dist/core/codegen/ts-generator.js +0 -8
- package/dist/core/codegen/ts-generator.js.map +0 -1
- package/dist/core/db-adapter/index.d.ts +0 -18
- package/dist/core/db-adapter/index.d.ts.map +0 -1
- package/dist/core/db-adapter/index.js +0 -23
- package/dist/core/db-adapter/index.js.map +0 -1
- package/dist/core/db-adapter/sync-engine.d.ts +0 -180
- package/dist/core/db-adapter/sync-engine.d.ts.map +0 -1
- package/dist/core/db-adapter/sync-engine.js +0 -342
- package/dist/core/db-adapter/sync-engine.js.map +0 -1
- package/dist/core/logic-engine/engine.d.ts +0 -8
- package/dist/core/logic-engine/engine.d.ts.map +0 -1
- package/dist/core/logic-engine/engine.js +0 -8
- package/dist/core/logic-engine/engine.js.map +0 -1
- package/dist/core/logic-engine/index.d.ts +0 -16
- package/dist/core/logic-engine/index.d.ts.map +0 -1
- package/dist/core/logic-engine/index.js +0 -16
- package/dist/core/logic-engine/index.js.map +0 -1
- package/dist/core/logic-engine/protocol.d.ts +0 -7
- package/dist/core/logic-engine/protocol.d.ts.map +0 -1
- package/dist/core/logic-engine/protocol.js +0 -7
- package/dist/core/logic-engine/protocol.js.map +0 -1
- package/dist/core/logic-engine/psf-adapter.d.ts +0 -88
- package/dist/core/logic-engine/psf-adapter.d.ts.map +0 -1
- package/dist/core/logic-engine/psf-adapter.js +0 -207
- package/dist/core/logic-engine/psf-adapter.js.map +0 -1
- package/dist/core/logic-engine/rules.d.ts +0 -7
- package/dist/core/logic-engine/rules.d.ts.map +0 -1
- package/dist/core/logic-engine/rules.js +0 -7
- package/dist/core/logic-engine/rules.js.map +0 -1
- package/dist/core/schema-engine/compiler.d.ts +0 -198
- package/dist/core/schema-engine/compiler.d.ts.map +0 -1
- package/dist/core/schema-engine/compiler.js +0 -262
- package/dist/core/schema-engine/compiler.js.map +0 -1
- package/dist/core/schema-engine/generator.d.ts +0 -115
- package/dist/core/schema-engine/generator.d.ts.map +0 -1
- package/dist/core/schema-engine/generator.js +0 -506
- package/dist/core/schema-engine/generator.js.map +0 -1
- package/dist/core/schema-engine/index.d.ts +0 -18
- package/dist/core/schema-engine/index.d.ts.map +0 -1
- package/dist/core/schema-engine/index.js +0 -18
- package/dist/core/schema-engine/index.js.map +0 -1
- package/dist/core/schema-engine/psf.d.ts +0 -612
- package/dist/core/schema-engine/psf.d.ts.map +0 -1
- package/dist/core/schema-engine/psf.js +0 -45
- package/dist/core/schema-engine/psf.js.map +0 -1
- package/dist/core/schema-engine/types.d.ts +0 -10
- package/dist/core/schema-engine/types.d.ts.map +0 -1
- package/dist/core/schema-engine/types.js +0 -7
- package/dist/core/schema-engine/types.js.map +0 -1
- package/dist/core/schema-engine/validator.d.ts +0 -140
- package/dist/core/schema-engine/validator.d.ts.map +0 -1
- package/dist/core/schema-engine/validator.js +0 -407
- package/dist/core/schema-engine/validator.js.map +0 -1
- package/dist/src/adapters/cli.d.ts +0 -43
- package/dist/src/adapters/cli.d.ts.map +0 -1
- package/dist/src/adapters/cli.js +0 -126
- package/dist/src/adapters/cli.js.map +0 -1
- package/dist/src/cli/commands/auth.d.ts +0 -26
- package/dist/src/cli/commands/auth.d.ts.map +0 -1
- package/dist/src/cli/commands/auth.js +0 -233
- package/dist/src/cli/commands/auth.js.map +0 -1
- package/dist/src/cli/commands/build.d.ts +0 -23
- package/dist/src/cli/commands/build.d.ts.map +0 -1
- package/dist/src/cli/commands/build.js +0 -162
- package/dist/src/cli/commands/build.js.map +0 -1
- package/dist/src/cli/commands/canvas.d.ts +0 -23
- package/dist/src/cli/commands/canvas.d.ts.map +0 -1
- package/dist/src/cli/commands/canvas.js +0 -215
- package/dist/src/cli/commands/canvas.js.map +0 -1
- package/dist/src/cli/commands/cloud.d.ts +0 -27
- package/dist/src/cli/commands/cloud.d.ts.map +0 -1
- package/dist/src/cli/commands/cloud.js +0 -232
- package/dist/src/cli/commands/cloud.js.map +0 -1
- package/dist/src/cli/commands/create.d.ts +0 -21
- package/dist/src/cli/commands/create.d.ts.map +0 -1
- package/dist/src/cli/commands/create.js +0 -621
- package/dist/src/cli/commands/create.js.map +0 -1
- package/dist/src/cli/commands/dev.d.ts +0 -21
- package/dist/src/cli/commands/dev.d.ts.map +0 -1
- package/dist/src/cli/commands/dev.js +0 -71
- package/dist/src/cli/commands/dev.js.map +0 -1
- package/dist/src/cli/commands/generate.d.ts +0 -25
- package/dist/src/cli/commands/generate.d.ts.map +0 -1
- package/dist/src/cli/commands/generate.js +0 -168
- package/dist/src/cli/commands/generate.js.map +0 -1
- package/dist/src/cli/commands/orchestrate.d.ts +0 -44
- package/dist/src/cli/commands/orchestrate.d.ts.map +0 -1
- package/dist/src/cli/commands/orchestrate.js +0 -150
- package/dist/src/cli/commands/orchestrate.js.map +0 -1
- package/dist/src/cli/commands/verify.d.ts +0 -10
- package/dist/src/cli/commands/verify.d.ts.map +0 -1
- package/dist/src/cli/commands/verify.js +0 -39
- package/dist/src/cli/commands/verify.js.map +0 -1
- package/dist/src/cli/index.d.ts +0 -8
- package/dist/src/cli/index.d.ts.map +0 -1
- package/dist/src/cli/index.js +0 -226
- package/dist/src/cli/index.js.map +0 -1
- package/dist/src/cloud/auth.d.ts +0 -51
- package/dist/src/cloud/auth.d.ts.map +0 -1
- package/dist/src/cloud/auth.js +0 -194
- package/dist/src/cloud/auth.js.map +0 -1
- package/dist/src/cloud/billing.d.ts +0 -184
- package/dist/src/cloud/billing.d.ts.map +0 -1
- package/dist/src/cloud/billing.js +0 -179
- package/dist/src/cloud/billing.js.map +0 -1
- package/dist/src/cloud/client.d.ts +0 -39
- package/dist/src/cloud/client.d.ts.map +0 -1
- package/dist/src/cloud/client.js +0 -176
- package/dist/src/cloud/client.js.map +0 -1
- package/dist/src/cloud/index.d.ts +0 -44
- package/dist/src/cloud/index.d.ts.map +0 -1
- package/dist/src/cloud/index.js +0 -44
- package/dist/src/cloud/index.js.map +0 -1
- package/dist/src/cloud/marketplace.d.ts +0 -166
- package/dist/src/cloud/marketplace.d.ts.map +0 -1
- package/dist/src/cloud/marketplace.js +0 -159
- package/dist/src/cloud/marketplace.js.map +0 -1
- package/dist/src/cloud/provisioning.d.ts +0 -110
- package/dist/src/cloud/provisioning.d.ts.map +0 -1
- package/dist/src/cloud/provisioning.js +0 -148
- package/dist/src/cloud/provisioning.js.map +0 -1
- package/dist/src/cloud/relay/endpoints.d.ts +0 -62
- package/dist/src/cloud/relay/endpoints.d.ts.map +0 -1
- package/dist/src/cloud/relay/endpoints.js +0 -217
- package/dist/src/cloud/relay/endpoints.js.map +0 -1
- package/dist/src/cloud/relay/health/index.d.ts +0 -5
- package/dist/src/cloud/relay/health/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/health/index.js +0 -9
- package/dist/src/cloud/relay/health/index.js.map +0 -1
- package/dist/src/cloud/relay/stats/index.d.ts +0 -5
- package/dist/src/cloud/relay/stats/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/stats/index.js +0 -9
- package/dist/src/cloud/relay/stats/index.js.map +0 -1
- package/dist/src/cloud/relay/sync/index.d.ts +0 -5
- package/dist/src/cloud/relay/sync/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/sync/index.js +0 -9
- package/dist/src/cloud/relay/sync/index.js.map +0 -1
- package/dist/src/cloud/relay/usage/index.d.ts +0 -5
- package/dist/src/cloud/relay/usage/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/usage/index.js +0 -9
- package/dist/src/cloud/relay/usage/index.js.map +0 -1
- package/dist/src/cloud/sponsors.d.ts +0 -81
- package/dist/src/cloud/sponsors.d.ts.map +0 -1
- package/dist/src/cloud/sponsors.js +0 -130
- package/dist/src/cloud/sponsors.js.map +0 -1
- package/dist/src/cloud/types.d.ts +0 -169
- package/dist/src/cloud/types.d.ts.map +0 -1
- package/dist/src/cloud/types.js +0 -7
- package/dist/src/cloud/types.js.map +0 -1
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/components/index.js +0 -17
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/core/actors.d.ts +0 -95
- package/dist/src/core/actors.d.ts.map +0 -1
- package/dist/src/core/actors.js +0 -158
- package/dist/src/core/actors.js.map +0 -1
- package/dist/src/core/component/generator.d.ts.map +0 -1
- package/dist/src/core/component/generator.js +0 -349
- package/dist/src/core/component/generator.js.map +0 -1
- package/dist/src/core/engine.d.ts +0 -92
- package/dist/src/core/engine.d.ts.map +0 -1
- package/dist/src/core/engine.js +0 -199
- package/dist/src/core/engine.js.map +0 -1
- package/dist/src/core/introspection.d.ts +0 -141
- package/dist/src/core/introspection.d.ts.map +0 -1
- package/dist/src/core/introspection.js +0 -208
- package/dist/src/core/introspection.js.map +0 -1
- package/dist/src/core/logic/generator.d.ts +0 -76
- package/dist/src/core/logic/generator.d.ts.map +0 -1
- package/dist/src/core/logic/generator.js +0 -370
- package/dist/src/core/logic/generator.js.map +0 -1
- package/dist/src/core/pluresdb/adapter.d.ts +0 -72
- package/dist/src/core/pluresdb/adapter.d.ts.map +0 -1
- package/dist/src/core/pluresdb/adapter.js +0 -73
- package/dist/src/core/pluresdb/adapter.js.map +0 -1
- package/dist/src/core/pluresdb/generator.d.ts +0 -58
- package/dist/src/core/pluresdb/generator.d.ts.map +0 -1
- package/dist/src/core/pluresdb/generator.js +0 -191
- package/dist/src/core/pluresdb/generator.js.map +0 -1
- package/dist/src/core/pluresdb/index.d.ts +0 -15
- package/dist/src/core/pluresdb/index.d.ts.map +0 -1
- package/dist/src/core/pluresdb/index.js +0 -11
- package/dist/src/core/pluresdb/index.js.map +0 -1
- package/dist/src/core/pluresdb/schema-registry.d.ts +0 -104
- package/dist/src/core/pluresdb/schema-registry.d.ts.map +0 -1
- package/dist/src/core/pluresdb/schema-registry.js +0 -130
- package/dist/src/core/pluresdb/schema-registry.js.map +0 -1
- package/dist/src/core/pluresdb/store.d.ts +0 -199
- package/dist/src/core/pluresdb/store.d.ts.map +0 -1
- package/dist/src/core/pluresdb/store.js +0 -344
- package/dist/src/core/pluresdb/store.js.map +0 -1
- package/dist/src/core/protocol.d.ts.map +0 -1
- package/dist/src/core/protocol.js +0 -46
- package/dist/src/core/protocol.js.map +0 -1
- package/dist/src/core/rules.d.ts +0 -120
- package/dist/src/core/rules.d.ts.map +0 -1
- package/dist/src/core/rules.js +0 -81
- package/dist/src/core/rules.js.map +0 -1
- package/dist/src/core/schema/loader.d.ts +0 -47
- package/dist/src/core/schema/loader.d.ts.map +0 -1
- package/dist/src/core/schema/loader.js +0 -189
- package/dist/src/core/schema/loader.js.map +0 -1
- package/dist/src/core/schema/normalize.d.ts +0 -72
- package/dist/src/core/schema/normalize.d.ts.map +0 -1
- package/dist/src/core/schema/normalize.js +0 -190
- package/dist/src/core/schema/normalize.js.map +0 -1
- package/dist/src/core/schema/types.d.ts.map +0 -1
- package/dist/src/core/schema/types.js +0 -161
- package/dist/src/core/schema/types.js.map +0 -1
- package/dist/src/dsl/index.d.ts +0 -152
- package/dist/src/dsl/index.d.ts.map +0 -1
- package/dist/src/dsl/index.js +0 -132
- package/dist/src/dsl/index.js.map +0 -1
- package/dist/src/dsl.d.ts +0 -124
- package/dist/src/dsl.d.ts.map +0 -1
- package/dist/src/dsl.js +0 -130
- package/dist/src/dsl.js.map +0 -1
- package/dist/src/examples/advanced-todo/index.d.ts +0 -55
- package/dist/src/examples/advanced-todo/index.d.ts.map +0 -1
- package/dist/src/examples/advanced-todo/index.js +0 -222
- package/dist/src/examples/advanced-todo/index.js.map +0 -1
- package/dist/src/examples/auth-basic/index.d.ts +0 -17
- package/dist/src/examples/auth-basic/index.d.ts.map +0 -1
- package/dist/src/examples/auth-basic/index.js +0 -122
- package/dist/src/examples/auth-basic/index.js.map +0 -1
- package/dist/src/examples/cart/index.d.ts +0 -19
- package/dist/src/examples/cart/index.d.ts.map +0 -1
- package/dist/src/examples/cart/index.js +0 -202
- package/dist/src/examples/cart/index.js.map +0 -1
- package/dist/src/examples/hero-ecommerce/index.d.ts +0 -39
- package/dist/src/examples/hero-ecommerce/index.d.ts.map +0 -1
- package/dist/src/examples/hero-ecommerce/index.js +0 -506
- package/dist/src/examples/hero-ecommerce/index.js.map +0 -1
- package/dist/src/examples/svelte-counter/index.d.ts +0 -31
- package/dist/src/examples/svelte-counter/index.d.ts.map +0 -1
- package/dist/src/examples/svelte-counter/index.js +0 -123
- package/dist/src/examples/svelte-counter/index.js.map +0 -1
- package/dist/src/flows.d.ts +0 -125
- package/dist/src/flows.d.ts.map +0 -1
- package/dist/src/flows.js +0 -160
- package/dist/src/flows.js.map +0 -1
- package/dist/src/index.d.ts +0 -77
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -64
- package/dist/src/index.js.map +0 -1
- package/dist/src/integrations/code-canvas.d.ts +0 -265
- package/dist/src/integrations/code-canvas.d.ts.map +0 -1
- package/dist/src/integrations/code-canvas.js +0 -451
- package/dist/src/integrations/code-canvas.js.map +0 -1
- package/dist/src/integrations/pluresdb.d.ts +0 -117
- package/dist/src/integrations/pluresdb.d.ts.map +0 -1
- package/dist/src/integrations/pluresdb.js +0 -117
- package/dist/src/integrations/pluresdb.js.map +0 -1
- package/dist/src/integrations/state-docs.d.ts +0 -191
- package/dist/src/integrations/state-docs.d.ts.map +0 -1
- package/dist/src/integrations/state-docs.js +0 -515
- package/dist/src/integrations/state-docs.js.map +0 -1
- package/dist/src/integrations/svelte.d.ts.map +0 -1
- package/dist/src/integrations/svelte.js +0 -447
- package/dist/src/integrations/svelte.js.map +0 -1
- package/dist/src/integrations/tauri.d.ts +0 -360
- package/dist/src/integrations/tauri.d.ts.map +0 -1
- package/dist/src/integrations/tauri.js +0 -278
- package/dist/src/integrations/tauri.js.map +0 -1
- package/dist/src/integrations/unum.d.ts +0 -159
- package/dist/src/integrations/unum.d.ts.map +0 -1
- package/dist/src/integrations/unum.js +0 -240
- package/dist/src/integrations/unum.js.map +0 -1
- package/dist/src/registry.d.ts +0 -94
- package/dist/src/registry.d.ts.map +0 -1
- package/dist/src/registry.js +0 -181
- package/dist/src/registry.js.map +0 -1
- package/dist/src/runtime/terminal-adapter.d.ts.map +0 -1
- package/dist/src/runtime/terminal-adapter.js +0 -239
- package/dist/src/runtime/terminal-adapter.js.map +0 -1
- package/dist/src/step.d.ts +0 -34
- package/dist/src/step.d.ts.map +0 -1
- package/dist/src/step.js +0 -111
- package/dist/src/step.js.map +0 -1
- package/dist/src/types.d.ts +0 -63
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -6
- package/dist/src/types.js.map +0 -1
- package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts +0 -8
- package/dist/tools/ast-analyzer/src/ast-analyzer.d.ts.map +0 -1
- package/dist/tools/ast-analyzer/src/ast-analyzer.js +0 -119
- package/dist/tools/ast-analyzer/src/ast-analyzer.js.map +0 -1
- package/dist/tools/cli/commands/index.d.ts +0 -7
- package/dist/tools/cli/commands/index.d.ts.map +0 -1
- package/dist/tools/cli/commands/index.js +0 -7
- package/dist/tools/cli/commands/index.js.map +0 -1
- package/dist/tools/cli/index.d.ts +0 -8
- package/dist/tools/cli/index.d.ts.map +0 -1
- package/dist/tools/cli/index.js +0 -9
- package/dist/tools/cli/index.js.map +0 -1
- package/dist/tools/watcher/index.d.ts +0 -105
- package/dist/tools/watcher/index.d.ts.map +0 -1
- package/dist/tools/watcher/index.js +0 -213
- package/dist/tools/watcher/index.js.map +0 -1
- package/dist/ui/canvas/canvas-projection.d.ts +0 -78
- package/dist/ui/canvas/canvas-projection.d.ts.map +0 -1
- package/dist/ui/canvas/canvas-projection.js +0 -416
- package/dist/ui/canvas/canvas-projection.js.map +0 -1
- package/dist/ui/canvas/canvas-state.d.ts +0 -200
- package/dist/ui/canvas/canvas-state.d.ts.map +0 -1
- package/dist/ui/canvas/canvas-state.js +0 -464
- package/dist/ui/canvas/canvas-state.js.map +0 -1
- package/dist/ui/canvas/components/index.d.ts +0 -95
- package/dist/ui/canvas/components/index.d.ts.map +0 -1
- package/dist/ui/canvas/components/index.js +0 -19
- package/dist/ui/canvas/components/index.js.map +0 -1
- package/dist/ui/canvas/index.d.ts +0 -32
- package/dist/ui/canvas/index.d.ts.map +0 -1
- package/dist/ui/canvas/index.js +0 -32
- package/dist/ui/canvas/index.js.map +0 -1
- package/dist/ui/canvas-inspector/src/server.d.ts +0 -2
- package/dist/ui/canvas-inspector/src/server.d.ts.map +0 -1
- package/dist/ui/canvas-inspector/src/server.js +0 -248
- package/dist/ui/canvas-inspector/src/server.js.map +0 -1
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts +0 -5
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.d.ts.map +0 -1
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js +0 -58
- package/dist/ui/canvas-inspector/src/verify-fsm-implementation.js.map +0 -1
- package/dist/ui/svelte-generator/index.d.ts +0 -9
- package/dist/ui/svelte-generator/index.d.ts.map +0 -1
- package/dist/ui/svelte-generator/index.js +0 -11
- package/dist/ui/svelte-generator/index.js.map +0 -1
- package/dist/ui/svelte-generator/psf-generator.d.ts +0 -128
- package/dist/ui/svelte-generator/psf-generator.d.ts.map +0 -1
- package/dist/ui/svelte-generator/psf-generator.js +0 -506
- package/dist/ui/svelte-generator/psf-generator.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* DSL tests
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { describe, it, expect } from
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
6
|
import {
|
|
7
7
|
defineFact,
|
|
8
8
|
defineEvent,
|
|
@@ -11,141 +11,135 @@ import {
|
|
|
11
11
|
defineModule,
|
|
12
12
|
findEvent,
|
|
13
13
|
findFact,
|
|
14
|
-
} from
|
|
14
|
+
} from '../dsl/index.js';
|
|
15
15
|
|
|
16
|
-
describe(
|
|
17
|
-
describe(
|
|
18
|
-
it(
|
|
19
|
-
const TestFact = defineFact<
|
|
16
|
+
describe('DSL Helpers', () => {
|
|
17
|
+
describe('defineFact', () => {
|
|
18
|
+
it('should create a fact definition', () => {
|
|
19
|
+
const TestFact = defineFact<'TestFact', { value: number }>('TestFact');
|
|
20
20
|
|
|
21
|
-
expect(TestFact.tag).toBe(
|
|
21
|
+
expect(TestFact.tag).toBe('TestFact');
|
|
22
22
|
|
|
23
23
|
const fact = TestFact.create({ value: 42 });
|
|
24
|
-
expect(fact.tag).toBe(
|
|
24
|
+
expect(fact.tag).toBe('TestFact');
|
|
25
25
|
expect(fact.payload.value).toBe(42);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it(
|
|
29
|
-
const TestFact = defineFact<
|
|
28
|
+
it('should provide type guard', () => {
|
|
29
|
+
const TestFact = defineFact<'TestFact', { value: number }>('TestFact');
|
|
30
30
|
const fact = TestFact.create({ value: 42 });
|
|
31
31
|
|
|
32
32
|
expect(TestFact.is(fact)).toBe(true);
|
|
33
|
-
expect(TestFact.is({ tag:
|
|
33
|
+
expect(TestFact.is({ tag: 'OtherFact', payload: {} })).toBe(false);
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
describe(
|
|
38
|
-
it(
|
|
39
|
-
const TestEvent = defineEvent<
|
|
37
|
+
describe('defineEvent', () => {
|
|
38
|
+
it('should create an event definition', () => {
|
|
39
|
+
const TestEvent = defineEvent<'TEST', { action: string }>('TEST');
|
|
40
40
|
|
|
41
|
-
expect(TestEvent.tag).toBe(
|
|
41
|
+
expect(TestEvent.tag).toBe('TEST');
|
|
42
42
|
|
|
43
|
-
const event = TestEvent.create({ action:
|
|
44
|
-
expect(event.tag).toBe(
|
|
45
|
-
expect(event.payload.action).toBe(
|
|
43
|
+
const event = TestEvent.create({ action: 'test' });
|
|
44
|
+
expect(event.tag).toBe('TEST');
|
|
45
|
+
expect(event.payload.action).toBe('test');
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
it(
|
|
49
|
-
const TestEvent = defineEvent<
|
|
50
|
-
const event = TestEvent.create({ action:
|
|
48
|
+
it('should provide type guard', () => {
|
|
49
|
+
const TestEvent = defineEvent<'TEST', { action: string }>('TEST');
|
|
50
|
+
const event = TestEvent.create({ action: 'test' });
|
|
51
51
|
|
|
52
52
|
expect(TestEvent.is(event)).toBe(true);
|
|
53
|
-
expect(TestEvent.is({ tag:
|
|
53
|
+
expect(TestEvent.is({ tag: 'OTHER', payload: {} })).toBe(false);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
describe(
|
|
58
|
-
it(
|
|
57
|
+
describe('defineRule', () => {
|
|
58
|
+
it('should create a rule descriptor', () => {
|
|
59
59
|
const rule = defineRule({
|
|
60
|
-
id:
|
|
61
|
-
description:
|
|
60
|
+
id: 'test.rule',
|
|
61
|
+
description: 'Test rule',
|
|
62
62
|
impl: () => [],
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
expect(rule.id).toBe(
|
|
66
|
-
expect(rule.description).toBe(
|
|
67
|
-
expect(typeof rule.impl).toBe(
|
|
65
|
+
expect(rule.id).toBe('test.rule');
|
|
66
|
+
expect(rule.description).toBe('Test rule');
|
|
67
|
+
expect(typeof rule.impl).toBe('function');
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
describe(
|
|
72
|
-
it(
|
|
71
|
+
describe('defineConstraint', () => {
|
|
72
|
+
it('should create a constraint descriptor', () => {
|
|
73
73
|
const constraint = defineConstraint({
|
|
74
|
-
id:
|
|
75
|
-
description:
|
|
74
|
+
id: 'test.constraint',
|
|
75
|
+
description: 'Test constraint',
|
|
76
76
|
impl: () => true,
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
expect(constraint.id).toBe(
|
|
80
|
-
expect(constraint.description).toBe(
|
|
81
|
-
expect(typeof constraint.impl).toBe(
|
|
79
|
+
expect(constraint.id).toBe('test.constraint');
|
|
80
|
+
expect(constraint.description).toBe('Test constraint');
|
|
81
|
+
expect(typeof constraint.impl).toBe('function');
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
describe(
|
|
86
|
-
it(
|
|
85
|
+
describe('defineModule', () => {
|
|
86
|
+
it('should create a module', () => {
|
|
87
87
|
const rule = defineRule({
|
|
88
|
-
id:
|
|
89
|
-
description:
|
|
88
|
+
id: 'test.rule',
|
|
89
|
+
description: 'Test rule',
|
|
90
90
|
impl: () => [],
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
const constraint = defineConstraint({
|
|
94
|
-
id:
|
|
95
|
-
description:
|
|
94
|
+
id: 'test.constraint',
|
|
95
|
+
description: 'Test constraint',
|
|
96
96
|
impl: () => true,
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
const module = defineModule({
|
|
100
100
|
rules: [rule],
|
|
101
101
|
constraints: [constraint],
|
|
102
|
-
meta: { version:
|
|
102
|
+
meta: { version: '1.0.0' },
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
expect(module.rules).toHaveLength(1);
|
|
106
106
|
expect(module.constraints).toHaveLength(1);
|
|
107
|
-
expect(module.meta?.version).toBe(
|
|
107
|
+
expect(module.meta?.version).toBe('1.0.0');
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
describe(
|
|
112
|
-
it(
|
|
113
|
-
const TestEvent = defineEvent<
|
|
114
|
-
const events = [
|
|
115
|
-
{ tag: "OTHER", payload: {} },
|
|
116
|
-
TestEvent.create({ value: 42 }),
|
|
117
|
-
];
|
|
111
|
+
describe('findEvent', () => {
|
|
112
|
+
it('should find matching event', () => {
|
|
113
|
+
const TestEvent = defineEvent<'TEST', { value: number }>('TEST');
|
|
114
|
+
const events = [{ tag: 'OTHER', payload: {} }, TestEvent.create({ value: 42 })];
|
|
118
115
|
|
|
119
116
|
const found = findEvent(events, TestEvent);
|
|
120
117
|
expect(found).toBeDefined();
|
|
121
118
|
expect(found?.payload.value).toBe(42);
|
|
122
119
|
});
|
|
123
120
|
|
|
124
|
-
it(
|
|
125
|
-
const TestEvent = defineEvent<
|
|
126
|
-
const events = [{ tag:
|
|
121
|
+
it('should return undefined if not found', () => {
|
|
122
|
+
const TestEvent = defineEvent<'TEST', { value: number }>('TEST');
|
|
123
|
+
const events = [{ tag: 'OTHER', payload: {} }];
|
|
127
124
|
|
|
128
125
|
const found = findEvent(events, TestEvent);
|
|
129
126
|
expect(found).toBeUndefined();
|
|
130
127
|
});
|
|
131
128
|
});
|
|
132
129
|
|
|
133
|
-
describe(
|
|
134
|
-
it(
|
|
135
|
-
const TestFact = defineFact<
|
|
136
|
-
const facts = [
|
|
137
|
-
{ tag: "OtherFact", payload: {} },
|
|
138
|
-
TestFact.create({ value: 42 }),
|
|
139
|
-
];
|
|
130
|
+
describe('findFact', () => {
|
|
131
|
+
it('should find matching fact', () => {
|
|
132
|
+
const TestFact = defineFact<'TestFact', { value: number }>('TestFact');
|
|
133
|
+
const facts = [{ tag: 'OtherFact', payload: {} }, TestFact.create({ value: 42 })];
|
|
140
134
|
|
|
141
135
|
const found = findFact(facts, TestFact);
|
|
142
136
|
expect(found).toBeDefined();
|
|
143
137
|
expect(found?.payload.value).toBe(42);
|
|
144
138
|
});
|
|
145
139
|
|
|
146
|
-
it(
|
|
147
|
-
const TestFact = defineFact<
|
|
148
|
-
const facts = [{ tag:
|
|
140
|
+
it('should return undefined if not found', () => {
|
|
141
|
+
const TestFact = defineFact<'TestFact', { value: number }>('TestFact');
|
|
142
|
+
const facts = [{ tag: 'OtherFact', payload: {} }];
|
|
149
143
|
|
|
150
144
|
const found = findFact(facts, TestFact);
|
|
151
145
|
expect(found).toBeUndefined();
|
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
* Edge cases and failure path tests
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { describe, it, expect } from
|
|
6
|
-
import { createPraxisEngine } from
|
|
7
|
-
import { PraxisRegistry } from
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
import { createPraxisEngine } from '../core/engine.js';
|
|
7
|
+
import { PraxisRegistry } from '../core/rules.js';
|
|
8
8
|
import {
|
|
9
9
|
defineRule,
|
|
10
10
|
defineConstraint,
|
|
11
11
|
defineEvent,
|
|
12
12
|
defineFact,
|
|
13
13
|
defineModule,
|
|
14
|
-
} from
|
|
14
|
+
} from '../dsl/index.js';
|
|
15
15
|
|
|
16
|
-
describe(
|
|
17
|
-
describe(
|
|
18
|
-
it(
|
|
19
|
-
const ErrorEvent = defineEvent<
|
|
16
|
+
describe('Edge Cases and Failure Paths', () => {
|
|
17
|
+
describe('Rule Errors', () => {
|
|
18
|
+
it('should handle rule that throws an error', () => {
|
|
19
|
+
const ErrorEvent = defineEvent<'ERROR', {}>('ERROR');
|
|
20
20
|
|
|
21
21
|
const errorRule = defineRule<{ value: number }>({
|
|
22
|
-
id:
|
|
23
|
-
description:
|
|
22
|
+
id: 'error.rule',
|
|
23
|
+
description: 'Rule that throws',
|
|
24
24
|
impl: () => {
|
|
25
|
-
throw new Error(
|
|
25
|
+
throw new Error('Intentional error');
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -37,29 +37,29 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
37
37
|
const result = engine.step([ErrorEvent.create({})]);
|
|
38
38
|
|
|
39
39
|
expect(result.diagnostics).toHaveLength(1);
|
|
40
|
-
expect(result.diagnostics[0]?.kind).toBe(
|
|
41
|
-
expect(result.diagnostics[0]?.message).toContain(
|
|
40
|
+
expect(result.diagnostics[0]?.kind).toBe('rule-error');
|
|
41
|
+
expect(result.diagnostics[0]?.message).toContain('Intentional error');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
it(
|
|
45
|
-
const TestEvent = defineEvent<
|
|
46
|
-
const Success = defineFact<
|
|
44
|
+
it('should continue processing other rules after one fails', () => {
|
|
45
|
+
const TestEvent = defineEvent<'TEST', {}>('TEST');
|
|
46
|
+
const Success = defineFact<'Success', { ruleId: string }>('Success');
|
|
47
47
|
|
|
48
48
|
const errorRule = defineRule<{ count: number }>({
|
|
49
|
-
id:
|
|
50
|
-
description:
|
|
49
|
+
id: 'error.rule',
|
|
50
|
+
description: 'Rule that throws',
|
|
51
51
|
impl: () => {
|
|
52
|
-
throw new Error(
|
|
52
|
+
throw new Error('Error');
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
const successRule = defineRule<{ count: number }>({
|
|
57
|
-
id:
|
|
58
|
-
description:
|
|
57
|
+
id: 'success.rule',
|
|
58
|
+
description: 'Rule that succeeds',
|
|
59
59
|
impl: (state, events) => {
|
|
60
60
|
if (events.some(TestEvent.is)) {
|
|
61
61
|
state.context.count += 1;
|
|
62
|
-
return [Success.create({ ruleId:
|
|
62
|
+
return [Success.create({ ruleId: 'success.rule' })];
|
|
63
63
|
}
|
|
64
64
|
return [];
|
|
65
65
|
},
|
|
@@ -78,20 +78,20 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
78
78
|
|
|
79
79
|
// Should have both error diagnostic and success fact
|
|
80
80
|
expect(result.diagnostics).toHaveLength(1);
|
|
81
|
-
expect(result.diagnostics[0]?.kind).toBe(
|
|
82
|
-
expect(result.state.facts.some((f) => f.tag ===
|
|
81
|
+
expect(result.diagnostics[0]?.kind).toBe('rule-error');
|
|
82
|
+
expect(result.state.facts.some((f) => f.tag === 'Success')).toBe(true);
|
|
83
83
|
expect(engine.getContext().count).toBe(1);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
it(
|
|
87
|
-
const TestEvent = defineEvent<
|
|
86
|
+
it('should handle rule returning invalid data', () => {
|
|
87
|
+
const TestEvent = defineEvent<'TEST', {}>('TEST');
|
|
88
88
|
|
|
89
89
|
const invalidRule = defineRule<{ value: number }>({
|
|
90
|
-
id:
|
|
91
|
-
description:
|
|
90
|
+
id: 'invalid.rule',
|
|
91
|
+
description: 'Rule that returns invalid facts',
|
|
92
92
|
impl: () => {
|
|
93
93
|
// Return invalid fact structure
|
|
94
|
-
return [{ tag:
|
|
94
|
+
return [{ tag: 'Invalid', notPayload: 'wrong' }] as any;
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
97
|
|
|
@@ -109,13 +109,13 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
describe(
|
|
113
|
-
it(
|
|
112
|
+
describe('Constraint Violations', () => {
|
|
113
|
+
it('should handle constraint that throws an error', () => {
|
|
114
114
|
const errorConstraint = defineConstraint<{ value: number }>({
|
|
115
|
-
id:
|
|
116
|
-
description:
|
|
115
|
+
id: 'error.constraint',
|
|
116
|
+
description: 'Constraint that throws',
|
|
117
117
|
impl: () => {
|
|
118
|
-
throw new Error(
|
|
118
|
+
throw new Error('Constraint error');
|
|
119
119
|
},
|
|
120
120
|
});
|
|
121
121
|
|
|
@@ -130,14 +130,14 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
130
130
|
const result = engine.step([]);
|
|
131
131
|
|
|
132
132
|
expect(result.diagnostics).toHaveLength(1);
|
|
133
|
-
expect(result.diagnostics[0]?.kind).toBe(
|
|
134
|
-
expect(result.diagnostics[0]?.message).toContain(
|
|
133
|
+
expect(result.diagnostics[0]?.kind).toBe('constraint-violation');
|
|
134
|
+
expect(result.diagnostics[0]?.message).toContain('Constraint error');
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
it(
|
|
137
|
+
it('should report constraint violation with false return', () => {
|
|
138
138
|
const failConstraint = defineConstraint<{ value: number }>({
|
|
139
|
-
id:
|
|
140
|
-
description:
|
|
139
|
+
id: 'fail.constraint',
|
|
140
|
+
description: 'Always fails',
|
|
141
141
|
impl: () => false,
|
|
142
142
|
});
|
|
143
143
|
|
|
@@ -152,16 +152,16 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
152
152
|
const result = engine.step([]);
|
|
153
153
|
|
|
154
154
|
expect(result.diagnostics).toHaveLength(1);
|
|
155
|
-
expect(result.diagnostics[0]?.kind).toBe(
|
|
156
|
-
expect(result.diagnostics[0]?.message).toContain(
|
|
155
|
+
expect(result.diagnostics[0]?.kind).toBe('constraint-violation');
|
|
156
|
+
expect(result.diagnostics[0]?.message).toContain('fail.constraint');
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
it(
|
|
159
|
+
it('should report constraint violation with custom message', () => {
|
|
160
160
|
const customMessageConstraint = defineConstraint<{ value: number }>({
|
|
161
|
-
id:
|
|
162
|
-
description:
|
|
161
|
+
id: 'custom.constraint',
|
|
162
|
+
description: 'Custom message constraint',
|
|
163
163
|
impl: (state) => {
|
|
164
|
-
return state.context.value >= 0 ||
|
|
164
|
+
return state.context.value >= 0 || 'Value must be non-negative';
|
|
165
165
|
},
|
|
166
166
|
});
|
|
167
167
|
|
|
@@ -176,20 +176,20 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
176
176
|
const result = engine.step([]);
|
|
177
177
|
|
|
178
178
|
expect(result.diagnostics).toHaveLength(1);
|
|
179
|
-
expect(result.diagnostics[0]?.message).toBe(
|
|
179
|
+
expect(result.diagnostics[0]?.message).toBe('Value must be non-negative');
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
it(
|
|
182
|
+
it('should check multiple constraints and report all violations', () => {
|
|
183
183
|
const constraint1 = defineConstraint<{ value: number }>({
|
|
184
|
-
id:
|
|
185
|
-
description:
|
|
186
|
-
impl: () =>
|
|
184
|
+
id: 'constraint1',
|
|
185
|
+
description: 'Constraint 1',
|
|
186
|
+
impl: () => 'Violation 1',
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
const constraint2 = defineConstraint<{ value: number }>({
|
|
190
|
-
id:
|
|
191
|
-
description:
|
|
192
|
-
impl: () =>
|
|
190
|
+
id: 'constraint2',
|
|
191
|
+
description: 'Constraint 2',
|
|
192
|
+
impl: () => 'Violation 2',
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
const registry = new PraxisRegistry<{ value: number }>();
|
|
@@ -204,13 +204,13 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
204
204
|
const result = engine.step([]);
|
|
205
205
|
|
|
206
206
|
expect(result.diagnostics).toHaveLength(2);
|
|
207
|
-
expect(result.diagnostics[0]?.message).toBe(
|
|
208
|
-
expect(result.diagnostics[1]?.message).toBe(
|
|
207
|
+
expect(result.diagnostics[0]?.message).toBe('Violation 1');
|
|
208
|
+
expect(result.diagnostics[1]?.message).toBe('Violation 2');
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
describe(
|
|
213
|
-
it(
|
|
212
|
+
describe('Registry Edge Cases', () => {
|
|
213
|
+
it('should handle non-existent rule ID in config', () => {
|
|
214
214
|
const registry = new PraxisRegistry<{ value: number }>();
|
|
215
215
|
const engine = createPraxisEngine({
|
|
216
216
|
initialContext: { value: 0 },
|
|
@@ -218,16 +218,16 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
const result = engine.stepWithConfig([], {
|
|
221
|
-
ruleIds: [
|
|
221
|
+
ruleIds: ['nonexistent.rule'],
|
|
222
222
|
constraintIds: [],
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
expect(result.diagnostics).toHaveLength(1);
|
|
226
|
-
expect(result.diagnostics[0]?.kind).toBe(
|
|
227
|
-
expect(result.diagnostics[0]?.message).toContain(
|
|
226
|
+
expect(result.diagnostics[0]?.kind).toBe('rule-error');
|
|
227
|
+
expect(result.diagnostics[0]?.message).toContain('not found in registry');
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
-
it(
|
|
230
|
+
it('should handle non-existent constraint ID in config', () => {
|
|
231
231
|
const registry = new PraxisRegistry<{ value: number }>();
|
|
232
232
|
const engine = createPraxisEngine({
|
|
233
233
|
initialContext: { value: 0 },
|
|
@@ -236,18 +236,18 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
236
236
|
|
|
237
237
|
const result = engine.stepWithConfig([], {
|
|
238
238
|
ruleIds: [],
|
|
239
|
-
constraintIds: [
|
|
239
|
+
constraintIds: ['nonexistent.constraint'],
|
|
240
240
|
});
|
|
241
241
|
|
|
242
242
|
expect(result.diagnostics).toHaveLength(1);
|
|
243
|
-
expect(result.diagnostics[0]?.kind).toBe(
|
|
244
|
-
expect(result.diagnostics[0]?.message).toContain(
|
|
243
|
+
expect(result.diagnostics[0]?.kind).toBe('constraint-violation');
|
|
244
|
+
expect(result.diagnostics[0]?.message).toContain('not found in registry');
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
it(
|
|
247
|
+
it('should throw when registering duplicate rule IDs', () => {
|
|
248
248
|
const rule = defineRule({
|
|
249
|
-
id:
|
|
250
|
-
description:
|
|
249
|
+
id: 'duplicate',
|
|
250
|
+
description: 'Test',
|
|
251
251
|
impl: () => [],
|
|
252
252
|
});
|
|
253
253
|
|
|
@@ -259,10 +259,10 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
259
259
|
);
|
|
260
260
|
});
|
|
261
261
|
|
|
262
|
-
it(
|
|
262
|
+
it('should throw when registering duplicate constraint IDs', () => {
|
|
263
263
|
const constraint = defineConstraint({
|
|
264
|
-
id:
|
|
265
|
-
description:
|
|
264
|
+
id: 'duplicate',
|
|
265
|
+
description: 'Test',
|
|
266
266
|
impl: () => true,
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -274,17 +274,17 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
274
274
|
);
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
-
it(
|
|
277
|
+
it('should register module with multiple rules and constraints', () => {
|
|
278
278
|
const module = defineModule({
|
|
279
279
|
rules: [
|
|
280
|
-
defineRule({ id:
|
|
281
|
-
defineRule({ id:
|
|
280
|
+
defineRule({ id: 'rule1', description: 'Rule 1', impl: () => [] }),
|
|
281
|
+
defineRule({ id: 'rule2', description: 'Rule 2', impl: () => [] }),
|
|
282
282
|
],
|
|
283
283
|
constraints: [
|
|
284
|
-
defineConstraint({ id:
|
|
285
|
-
defineConstraint({ id:
|
|
284
|
+
defineConstraint({ id: 'c1', description: 'C1', impl: () => true }),
|
|
285
|
+
defineConstraint({ id: 'c2', description: 'C2', impl: () => true }),
|
|
286
286
|
],
|
|
287
|
-
meta: { version:
|
|
287
|
+
meta: { version: '1.0.0' },
|
|
288
288
|
});
|
|
289
289
|
|
|
290
290
|
const registry = new PraxisRegistry();
|
|
@@ -295,8 +295,8 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
295
295
|
});
|
|
296
296
|
});
|
|
297
297
|
|
|
298
|
-
describe(
|
|
299
|
-
it(
|
|
298
|
+
describe('Context and State Edge Cases', () => {
|
|
299
|
+
it('should handle empty events array', () => {
|
|
300
300
|
const registry = new PraxisRegistry<{ value: number }>();
|
|
301
301
|
const engine = createPraxisEngine({
|
|
302
302
|
initialContext: { value: 0 },
|
|
@@ -308,7 +308,7 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
308
308
|
expect(result.diagnostics).toHaveLength(0);
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
-
it(
|
|
311
|
+
it('should handle complex nested context', () => {
|
|
312
312
|
interface ComplexContext {
|
|
313
313
|
nested: {
|
|
314
314
|
deep: {
|
|
@@ -319,13 +319,13 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
319
319
|
map: Map<string, number>;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
const TestEvent = defineEvent<
|
|
322
|
+
const TestEvent = defineEvent<'TEST', {}>('TEST');
|
|
323
323
|
const rule = defineRule<ComplexContext>({
|
|
324
|
-
id:
|
|
325
|
-
description:
|
|
324
|
+
id: 'complex.rule',
|
|
325
|
+
description: 'Complex context rule',
|
|
326
326
|
impl: (state) => {
|
|
327
327
|
state.context.nested.deep.value += 1;
|
|
328
|
-
state.context.nested.deep.array.push(
|
|
328
|
+
state.context.nested.deep.array.push('item');
|
|
329
329
|
return [];
|
|
330
330
|
},
|
|
331
331
|
});
|
|
@@ -341,7 +341,7 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
341
341
|
array: [],
|
|
342
342
|
},
|
|
343
343
|
},
|
|
344
|
-
map: new Map([[
|
|
344
|
+
map: new Map([['key', 1]]),
|
|
345
345
|
},
|
|
346
346
|
registry,
|
|
347
347
|
});
|
|
@@ -353,11 +353,9 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
353
353
|
expect(context.nested.deep.array).toHaveLength(1);
|
|
354
354
|
});
|
|
355
355
|
|
|
356
|
-
it(
|
|
357
|
-
const NullFact = defineFact<
|
|
358
|
-
const UndefinedFact = defineFact<
|
|
359
|
-
"UndefinedFact"
|
|
360
|
-
);
|
|
356
|
+
it('should handle null and undefined in payloads', () => {
|
|
357
|
+
const NullFact = defineFact<'NullFact', { value: null }>('NullFact');
|
|
358
|
+
const UndefinedFact = defineFact<'UndefinedFact', { value: undefined }>('UndefinedFact');
|
|
361
359
|
|
|
362
360
|
const fact1 = NullFact.create({ value: null });
|
|
363
361
|
const fact2 = UndefinedFact.create({ value: undefined });
|
|
@@ -366,13 +364,13 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
366
364
|
expect(fact2.payload.value).toBeUndefined();
|
|
367
365
|
});
|
|
368
366
|
|
|
369
|
-
it(
|
|
370
|
-
const TestEvent = defineEvent<
|
|
371
|
-
const TestFact = defineFact<
|
|
367
|
+
it('should handle large number of facts', () => {
|
|
368
|
+
const TestEvent = defineEvent<'TEST', {}>('TEST');
|
|
369
|
+
const TestFact = defineFact<'TestFact', { index: number }>('TestFact');
|
|
372
370
|
|
|
373
371
|
const rule = defineRule<{ count: number }>({
|
|
374
|
-
id:
|
|
375
|
-
description:
|
|
372
|
+
id: 'many.facts',
|
|
373
|
+
description: 'Generate many facts',
|
|
376
374
|
impl: (_state, events) => {
|
|
377
375
|
if (events.some(TestEvent.is)) {
|
|
378
376
|
const facts = [];
|
|
@@ -397,7 +395,7 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
397
395
|
expect(result.state.facts).toHaveLength(1000);
|
|
398
396
|
});
|
|
399
397
|
|
|
400
|
-
it(
|
|
398
|
+
it('should isolate context mutations between getContext calls', () => {
|
|
401
399
|
const registry = new PraxisRegistry<{ value: number }>();
|
|
402
400
|
const engine = createPraxisEngine({
|
|
403
401
|
initialContext: { value: 10 },
|
|
@@ -412,14 +410,14 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
412
410
|
});
|
|
413
411
|
});
|
|
414
412
|
|
|
415
|
-
describe(
|
|
416
|
-
it(
|
|
417
|
-
const TestEvent = defineEvent<
|
|
418
|
-
const TestFact = defineFact<
|
|
413
|
+
describe('Event Processing Edge Cases', () => {
|
|
414
|
+
it('should handle duplicate events', () => {
|
|
415
|
+
const TestEvent = defineEvent<'TEST', { id: string }>('TEST');
|
|
416
|
+
const TestFact = defineFact<'TestFact', { count: number }>('TestFact');
|
|
419
417
|
|
|
420
418
|
const rule = defineRule<{ count: number }>({
|
|
421
|
-
id:
|
|
422
|
-
description:
|
|
419
|
+
id: 'count.events',
|
|
420
|
+
description: 'Count test events',
|
|
423
421
|
impl: (_state, events) => {
|
|
424
422
|
const testEvents = events.filter(TestEvent.is);
|
|
425
423
|
if (testEvents.length > 0) {
|
|
@@ -437,20 +435,20 @@ describe("Edge Cases and Failure Paths", () => {
|
|
|
437
435
|
registry,
|
|
438
436
|
});
|
|
439
437
|
|
|
440
|
-
const event = TestEvent.create({ id:
|
|
438
|
+
const event = TestEvent.create({ id: 'test' });
|
|
441
439
|
const result = engine.step([event, event, event]);
|
|
442
440
|
|
|
443
|
-
const fact = result.state.facts.find((f) => f.tag ===
|
|
441
|
+
const fact = result.state.facts.find((f) => f.tag === 'TestFact');
|
|
444
442
|
expect(fact?.payload).toEqual({ count: 3 });
|
|
445
443
|
});
|
|
446
444
|
|
|
447
|
-
it(
|
|
448
|
-
const EmptyEvent = defineEvent<
|
|
449
|
-
const EmptyFact = defineFact<
|
|
445
|
+
it('should handle events with empty payloads', () => {
|
|
446
|
+
const EmptyEvent = defineEvent<'EMPTY', {}>('EMPTY');
|
|
447
|
+
const EmptyFact = defineFact<'EmptyFact', {}>('EmptyFact');
|
|
450
448
|
|
|
451
449
|
const rule = defineRule<{ triggered: boolean }>({
|
|
452
|
-
id:
|
|
453
|
-
description:
|
|
450
|
+
id: 'empty.rule',
|
|
451
|
+
description: 'Handle empty events',
|
|
454
452
|
impl: (state, events) => {
|
|
455
453
|
if (events.some(EmptyEvent.is)) {
|
|
456
454
|
state.context.triggered = true;
|