@plures/praxis 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FRAMEWORK.md +55 -5
- package/LICENSE +21 -21
- package/README.md +162 -375
- package/core/codegen/docs-generator.ts +5 -2
- package/core/codegen/index.ts +1 -1
- package/core/codegen/ts-generator.ts +15 -15
- package/core/db-adapter/index.ts +2 -2
- package/core/db-adapter/sync-engine.ts +17 -6
- package/core/logic-engine/engine.ts +1 -1
- package/core/logic-engine/index.ts +2 -2
- package/core/logic-engine/protocol.ts +1 -1
- package/core/logic-engine/psf-adapter.ts +8 -4
- package/core/logic-engine/rules.ts +1 -1
- package/core/schema-engine/compiler.ts +53 -11
- package/core/schema-engine/generator.ts +17 -7
- package/core/schema-engine/index.ts +2 -2
- package/core/schema-engine/psf.ts +12 -3
- package/core/schema-engine/types.ts +3 -11
- package/core/schema-engine/validator.ts +112 -22
- package/dist/browser/engine-BjdqxeXG.d.ts +333 -0
- package/dist/browser/index.d.ts +3004 -0
- package/dist/browser/index.js +2892 -0
- package/dist/{src → browser}/integrations/svelte.d.ts +19 -17
- package/dist/browser/integrations/svelte.js +298 -0
- package/dist/node/auth-STARLY7I.js +207 -0
- package/dist/node/build-Y7OT5VBF.js +144 -0
- package/dist/node/canvas-UERZHJYW.js +362 -0
- package/dist/node/chunk-DSDC2JWZ.js +256 -0
- package/dist/node/chunk-FXQZXAWF.js +175 -0
- package/dist/node/chunk-N5Y37EUV.js +202 -0
- package/dist/node/chunk-QGM4M3NI.js +37 -0
- package/dist/node/chunk-RJMWCNHR.js +175 -0
- package/dist/node/chunk-SRM3OPPM.js +404 -0
- package/dist/node/chunk-UATVJBNV.js +175 -0
- package/dist/node/chunk-UY7YEBE2.js +159 -0
- package/dist/node/chunk-XCY2VIFX.js +143 -0
- package/dist/node/chunk-YXH4Y7ZZ.js +349 -0
- package/dist/node/cli/index.cjs +217418 -0
- package/dist/node/cli/index.d.cts +1 -0
- package/dist/node/cli/index.d.ts +1 -0
- package/dist/node/cli/index.js +690 -0
- package/dist/node/cloud/index.cjs +1043 -0
- package/dist/node/cloud/index.d.cts +864 -0
- package/dist/node/cloud/index.d.ts +864 -0
- package/dist/node/cloud/index.js +456 -0
- package/dist/node/cloud-AXOK4PSN.js +212 -0
- package/dist/node/component.cjs +374 -0
- package/dist/node/component.d.cts +125 -0
- package/dist/{src/core/component/generator.d.ts → node/component.d.ts} +11 -8
- package/dist/node/component.js +9 -0
- package/dist/node/components/index.cjs +216 -0
- package/dist/node/components/index.d.cts +43 -0
- package/dist/{src → node}/components/index.d.ts +8 -8
- package/dist/node/components/index.js +7 -0
- package/dist/node/create-TRLSVCNQ.js +584 -0
- package/dist/node/dev-PMJZUYGE.js +65 -0
- package/dist/node/engine-1iqLe6_P.d.ts +214 -0
- package/dist/node/engine-CVJobhHm.d.cts +214 -0
- package/dist/node/index.cjs +3247 -0
- package/dist/node/index.d.cts +2579 -0
- package/dist/node/index.d.ts +2579 -0
- package/dist/node/index.js +2098 -0
- package/dist/node/integrations/svelte.cjs +330 -0
- package/dist/node/integrations/svelte.d.cts +309 -0
- package/dist/node/integrations/svelte.d.ts +309 -0
- package/dist/node/integrations/svelte.js +300 -0
- package/dist/node/orchestrate-737TCL5H.js +127 -0
- package/dist/{src/core/protocol.d.ts → node/protocol-Qek7ebBl.d.cts} +11 -10
- package/dist/node/protocol-Qek7ebBl.d.ts +122 -0
- package/dist/node/schema.cjs +200 -0
- package/dist/{src/core/schema/types.d.ts → node/schema.d.cts} +30 -29
- package/dist/node/schema.d.ts +371 -0
- package/dist/node/schema.js +9 -0
- package/dist/{src/runtime/terminal-adapter.d.ts → node/terminal-adapter-07HGftGQ.d.ts} +86 -11
- package/dist/node/terminal-adapter-XLtCjjb_.d.cts +231 -0
- package/dist/node/verify-YBZ7W24H.js +213239 -0
- package/docs/MONETIZATION.md +21 -16
- package/docs/REACTIVE_REDESIGN.md +132 -0
- package/docs/README.md +47 -36
- package/docs/SVELTE_INTEGRATION_STRATEGY.md +68 -0
- package/docs/TERMINAL_NODE.md +27 -24
- package/docs/core/building-extensions.md +58 -61
- package/docs/core/cli-usage.md +59 -59
- package/docs/core/code-canvas-sync.md +28 -16
- package/docs/core/logic-engine.md +77 -82
- package/docs/core/pluresdb-integration.md +29 -39
- package/docs/core/schema-model.md +66 -52
- package/docs/core/ui-generation.md +57 -49
- package/docs/core/what-is-praxis.md +32 -15
- package/docs/guides/canvas.md +21 -5
- package/docs/guides/getting-started.md +13 -7
- package/docs/guides/history-state-pattern.md +65 -51
- package/docs/guides/orchestration.md +46 -32
- package/docs/guides/parallel-state-pattern.md +56 -72
- package/docs/guides/svelte-integration.md +45 -53
- package/docs/tutorials/README.md +16 -0
- package/docs/tutorials/ecommerce-cart.md +177 -95
- package/docs/tutorials/first-app.md +26 -41
- package/docs/tutorials/form-builder.md +191 -138
- package/docs/tutorials/todo-pluresdb.md +71 -69
- package/package.json +132 -96
- package/src/__tests__/actors.test.ts +68 -68
- package/src/__tests__/billing.test.ts +32 -32
- package/src/__tests__/canvas-components.test.ts +94 -73
- package/src/__tests__/cli-create.test.ts +28 -28
- package/src/__tests__/cloud.test.ts +36 -36
- package/src/__tests__/code-canvas-integration.test.ts +132 -141
- package/src/__tests__/docs-generator.test.ts +3 -9
- package/src/__tests__/dsl.test.ts +58 -64
- package/src/__tests__/edge-cases.test.ts +106 -108
- package/src/__tests__/engine.test.ts +51 -25
- package/src/__tests__/generators.test.ts +42 -44
- package/src/__tests__/introspection.test.ts +104 -114
- package/src/__tests__/pluresdb.test.ts +189 -187
- package/src/__tests__/protocol.test.ts +15 -15
- package/src/__tests__/provisioning.test.ts +61 -61
- package/src/__tests__/schema.test.ts +7 -11
- package/src/__tests__/state-docs-integration.test.ts +162 -145
- package/src/__tests__/svelte-integration.test.ts +16 -19
- package/src/__tests__/tauri-integration.test.ts +149 -147
- package/src/__tests__/terminal-node.test.ts +12 -7
- package/src/__tests__/unum-integration.test.ts +68 -68
- package/src/adapters/cli.ts +21 -15
- package/src/cli/commands/auth.ts +82 -78
- package/src/cli/commands/build.ts +29 -27
- package/src/cli/commands/canvas.ts +338 -127
- package/src/cli/commands/cloud.ts +47 -47
- package/src/cli/commands/create.ts +59 -47
- package/src/cli/commands/dev.ts +12 -12
- package/src/cli/commands/generate.ts +29 -40
- package/src/cli/commands/orchestrate.ts +24 -24
- package/src/cli/commands/verify.ts +49 -0
- package/src/cli/index.ts +21 -2
- package/src/cloud/README.md +28 -15
- package/src/cloud/auth.ts +55 -70
- package/src/cloud/billing.ts +59 -58
- package/src/cloud/client.ts +29 -35
- package/src/cloud/index.ts +19 -40
- package/src/cloud/marketplace.ts +69 -78
- package/src/cloud/provisioning.ts +42 -51
- package/src/cloud/relay/endpoints.ts +30 -34
- package/src/cloud/relay/health/index.ts +1 -1
- package/src/cloud/relay/stats/index.ts +1 -1
- package/src/cloud/relay/sync/index.ts +1 -1
- package/src/cloud/relay/usage/index.ts +1 -1
- package/src/cloud/sponsors.ts +31 -34
- package/src/cloud/types.ts +4 -4
- package/src/components/README.md +1 -0
- package/src/components/TerminalNode.svelte +457 -457
- package/src/components/index.ts +3 -4
- package/src/core/actors.ts +7 -7
- package/src/core/component/generator.ts +10 -28
- package/src/core/engine.ts +51 -24
- package/src/core/introspection.ts +37 -35
- package/src/core/logic/generator.ts +62 -62
- package/src/core/pluresdb/adapter.ts +8 -8
- package/src/core/pluresdb/generator.ts +39 -35
- package/src/core/pluresdb/index.ts +9 -12
- package/src/core/pluresdb/schema-registry.ts +22 -25
- package/src/core/pluresdb/store.ts +57 -57
- package/src/core/protocol.ts +14 -14
- package/src/core/reactive-engine.svelte.ts +65 -0
- package/src/core/reactive-engine.ts +67 -0
- package/src/core/rules.ts +4 -4
- package/src/core/schema/loader.common.ts +150 -0
- package/src/core/schema/loader.ts +19 -149
- package/src/core/schema/normalize.ts +34 -51
- package/src/core/schema/types.ts +47 -11
- package/src/dsl/index.ts +8 -8
- package/src/dsl.ts +11 -17
- package/src/examples/advanced-todo/App.svelte +506 -506
- package/src/examples/advanced-todo/README.md +58 -40
- package/src/examples/advanced-todo/index.ts +3 -3
- package/src/examples/auth-basic/index.ts +30 -30
- package/src/examples/cart/index.ts +50 -50
- package/src/examples/hero-ecommerce/index.ts +130 -157
- package/src/examples/svelte-counter/index.ts +22 -26
- package/src/flows.ts +6 -17
- package/src/index.browser.ts +204 -0
- package/src/index.ts +37 -42
- package/src/integrations/code-canvas.ts +237 -193
- package/src/integrations/pluresdb.ts +55 -35
- package/src/integrations/state-docs.ts +104 -104
- package/src/integrations/svelte.ts +35 -35
- package/src/integrations/tauri.ts +75 -73
- package/src/integrations/unum.ts +68 -61
- package/src/registry.ts +7 -14
- package/src/runtime/terminal-adapter.ts +31 -26
- package/src/step.ts +10 -16
- package/src/types.ts +1 -1
- package/templates/basic-app/README.md +6 -9
- package/templates/fullstack-app/README.md +10 -0
- package/dist/core/codegen/docs-generator.d.ts +0 -123
- package/dist/core/codegen/docs-generator.d.ts.map +0 -1
- package/dist/core/codegen/docs-generator.js +0 -674
- package/dist/core/codegen/docs-generator.js.map +0 -1
- package/dist/core/codegen/index.d.ts +0 -11
- package/dist/core/codegen/index.d.ts.map +0 -1
- package/dist/core/codegen/index.js +0 -13
- package/dist/core/codegen/index.js.map +0 -1
- package/dist/core/codegen/ts-generator.d.ts +0 -8
- package/dist/core/codegen/ts-generator.d.ts.map +0 -1
- package/dist/core/codegen/ts-generator.js +0 -8
- package/dist/core/codegen/ts-generator.js.map +0 -1
- package/dist/core/db-adapter/index.d.ts +0 -18
- package/dist/core/db-adapter/index.d.ts.map +0 -1
- package/dist/core/db-adapter/index.js +0 -23
- package/dist/core/db-adapter/index.js.map +0 -1
- package/dist/core/db-adapter/sync-engine.d.ts +0 -180
- package/dist/core/db-adapter/sync-engine.d.ts.map +0 -1
- package/dist/core/db-adapter/sync-engine.js +0 -342
- package/dist/core/db-adapter/sync-engine.js.map +0 -1
- package/dist/core/logic-engine/engine.d.ts +0 -8
- package/dist/core/logic-engine/engine.d.ts.map +0 -1
- package/dist/core/logic-engine/engine.js +0 -8
- package/dist/core/logic-engine/engine.js.map +0 -1
- package/dist/core/logic-engine/index.d.ts +0 -16
- package/dist/core/logic-engine/index.d.ts.map +0 -1
- package/dist/core/logic-engine/index.js +0 -16
- package/dist/core/logic-engine/index.js.map +0 -1
- package/dist/core/logic-engine/protocol.d.ts +0 -7
- package/dist/core/logic-engine/protocol.d.ts.map +0 -1
- package/dist/core/logic-engine/protocol.js +0 -7
- package/dist/core/logic-engine/protocol.js.map +0 -1
- package/dist/core/logic-engine/psf-adapter.d.ts +0 -88
- package/dist/core/logic-engine/psf-adapter.d.ts.map +0 -1
- package/dist/core/logic-engine/psf-adapter.js +0 -207
- package/dist/core/logic-engine/psf-adapter.js.map +0 -1
- package/dist/core/logic-engine/rules.d.ts +0 -7
- package/dist/core/logic-engine/rules.d.ts.map +0 -1
- package/dist/core/logic-engine/rules.js +0 -7
- package/dist/core/logic-engine/rules.js.map +0 -1
- package/dist/core/schema-engine/compiler.d.ts +0 -198
- package/dist/core/schema-engine/compiler.d.ts.map +0 -1
- package/dist/core/schema-engine/compiler.js +0 -262
- package/dist/core/schema-engine/compiler.js.map +0 -1
- package/dist/core/schema-engine/generator.d.ts +0 -115
- package/dist/core/schema-engine/generator.d.ts.map +0 -1
- package/dist/core/schema-engine/generator.js +0 -506
- package/dist/core/schema-engine/generator.js.map +0 -1
- package/dist/core/schema-engine/index.d.ts +0 -18
- package/dist/core/schema-engine/index.d.ts.map +0 -1
- package/dist/core/schema-engine/index.js +0 -18
- package/dist/core/schema-engine/index.js.map +0 -1
- package/dist/core/schema-engine/psf.d.ts +0 -612
- package/dist/core/schema-engine/psf.d.ts.map +0 -1
- package/dist/core/schema-engine/psf.js +0 -45
- package/dist/core/schema-engine/psf.js.map +0 -1
- package/dist/core/schema-engine/types.d.ts +0 -10
- package/dist/core/schema-engine/types.d.ts.map +0 -1
- package/dist/core/schema-engine/types.js +0 -7
- package/dist/core/schema-engine/types.js.map +0 -1
- package/dist/core/schema-engine/validator.d.ts +0 -140
- package/dist/core/schema-engine/validator.d.ts.map +0 -1
- package/dist/core/schema-engine/validator.js +0 -407
- package/dist/core/schema-engine/validator.js.map +0 -1
- package/dist/src/adapters/cli.d.ts +0 -43
- package/dist/src/adapters/cli.d.ts.map +0 -1
- package/dist/src/adapters/cli.js +0 -126
- package/dist/src/adapters/cli.js.map +0 -1
- package/dist/src/cli/commands/auth.d.ts +0 -26
- package/dist/src/cli/commands/auth.d.ts.map +0 -1
- package/dist/src/cli/commands/auth.js +0 -233
- package/dist/src/cli/commands/auth.js.map +0 -1
- package/dist/src/cli/commands/build.d.ts +0 -23
- package/dist/src/cli/commands/build.d.ts.map +0 -1
- package/dist/src/cli/commands/build.js +0 -162
- package/dist/src/cli/commands/build.js.map +0 -1
- package/dist/src/cli/commands/canvas.d.ts +0 -23
- package/dist/src/cli/commands/canvas.d.ts.map +0 -1
- package/dist/src/cli/commands/canvas.js +0 -215
- package/dist/src/cli/commands/canvas.js.map +0 -1
- package/dist/src/cli/commands/cloud.d.ts +0 -27
- package/dist/src/cli/commands/cloud.d.ts.map +0 -1
- package/dist/src/cli/commands/cloud.js +0 -232
- package/dist/src/cli/commands/cloud.js.map +0 -1
- package/dist/src/cli/commands/create.d.ts +0 -21
- package/dist/src/cli/commands/create.d.ts.map +0 -1
- package/dist/src/cli/commands/create.js +0 -621
- package/dist/src/cli/commands/create.js.map +0 -1
- package/dist/src/cli/commands/dev.d.ts +0 -21
- package/dist/src/cli/commands/dev.d.ts.map +0 -1
- package/dist/src/cli/commands/dev.js +0 -71
- package/dist/src/cli/commands/dev.js.map +0 -1
- package/dist/src/cli/commands/generate.d.ts +0 -25
- package/dist/src/cli/commands/generate.d.ts.map +0 -1
- package/dist/src/cli/commands/generate.js +0 -168
- package/dist/src/cli/commands/generate.js.map +0 -1
- package/dist/src/cli/commands/orchestrate.d.ts +0 -44
- package/dist/src/cli/commands/orchestrate.d.ts.map +0 -1
- package/dist/src/cli/commands/orchestrate.js +0 -150
- package/dist/src/cli/commands/orchestrate.js.map +0 -1
- package/dist/src/cli/index.d.ts +0 -8
- package/dist/src/cli/index.d.ts.map +0 -1
- package/dist/src/cli/index.js +0 -211
- package/dist/src/cli/index.js.map +0 -1
- package/dist/src/cloud/auth.d.ts +0 -51
- package/dist/src/cloud/auth.d.ts.map +0 -1
- package/dist/src/cloud/auth.js +0 -194
- package/dist/src/cloud/auth.js.map +0 -1
- package/dist/src/cloud/billing.d.ts +0 -184
- package/dist/src/cloud/billing.d.ts.map +0 -1
- package/dist/src/cloud/billing.js +0 -179
- package/dist/src/cloud/billing.js.map +0 -1
- package/dist/src/cloud/client.d.ts +0 -39
- package/dist/src/cloud/client.d.ts.map +0 -1
- package/dist/src/cloud/client.js +0 -176
- package/dist/src/cloud/client.js.map +0 -1
- package/dist/src/cloud/index.d.ts +0 -44
- package/dist/src/cloud/index.d.ts.map +0 -1
- package/dist/src/cloud/index.js +0 -44
- package/dist/src/cloud/index.js.map +0 -1
- package/dist/src/cloud/marketplace.d.ts +0 -166
- package/dist/src/cloud/marketplace.d.ts.map +0 -1
- package/dist/src/cloud/marketplace.js +0 -159
- package/dist/src/cloud/marketplace.js.map +0 -1
- package/dist/src/cloud/provisioning.d.ts +0 -110
- package/dist/src/cloud/provisioning.d.ts.map +0 -1
- package/dist/src/cloud/provisioning.js +0 -148
- package/dist/src/cloud/provisioning.js.map +0 -1
- package/dist/src/cloud/relay/endpoints.d.ts +0 -62
- package/dist/src/cloud/relay/endpoints.d.ts.map +0 -1
- package/dist/src/cloud/relay/endpoints.js +0 -217
- package/dist/src/cloud/relay/endpoints.js.map +0 -1
- package/dist/src/cloud/relay/health/index.d.ts +0 -5
- package/dist/src/cloud/relay/health/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/health/index.js +0 -9
- package/dist/src/cloud/relay/health/index.js.map +0 -1
- package/dist/src/cloud/relay/stats/index.d.ts +0 -5
- package/dist/src/cloud/relay/stats/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/stats/index.js +0 -9
- package/dist/src/cloud/relay/stats/index.js.map +0 -1
- package/dist/src/cloud/relay/sync/index.d.ts +0 -5
- package/dist/src/cloud/relay/sync/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/sync/index.js +0 -9
- package/dist/src/cloud/relay/sync/index.js.map +0 -1
- package/dist/src/cloud/relay/usage/index.d.ts +0 -5
- package/dist/src/cloud/relay/usage/index.d.ts.map +0 -1
- package/dist/src/cloud/relay/usage/index.js +0 -9
- package/dist/src/cloud/relay/usage/index.js.map +0 -1
- package/dist/src/cloud/sponsors.d.ts +0 -81
- package/dist/src/cloud/sponsors.d.ts.map +0 -1
- package/dist/src/cloud/sponsors.js +0 -130
- package/dist/src/cloud/sponsors.js.map +0 -1
- package/dist/src/cloud/types.d.ts +0 -169
- package/dist/src/cloud/types.d.ts.map +0 -1
- package/dist/src/cloud/types.js +0 -7
- package/dist/src/cloud/types.js.map +0 -1
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/components/index.js +0 -17
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/core/actors.d.ts +0 -95
- package/dist/src/core/actors.d.ts.map +0 -1
- package/dist/src/core/actors.js +0 -158
- package/dist/src/core/actors.js.map +0 -1
- package/dist/src/core/component/generator.d.ts.map +0 -1
- package/dist/src/core/component/generator.js +0 -349
- package/dist/src/core/component/generator.js.map +0 -1
- package/dist/src/core/engine.d.ts +0 -92
- package/dist/src/core/engine.d.ts.map +0 -1
- package/dist/src/core/engine.js +0 -199
- package/dist/src/core/engine.js.map +0 -1
- package/dist/src/core/introspection.d.ts +0 -141
- package/dist/src/core/introspection.d.ts.map +0 -1
- package/dist/src/core/introspection.js +0 -208
- package/dist/src/core/introspection.js.map +0 -1
- package/dist/src/core/logic/generator.d.ts +0 -76
- package/dist/src/core/logic/generator.d.ts.map +0 -1
- package/dist/src/core/logic/generator.js +0 -370
- package/dist/src/core/logic/generator.js.map +0 -1
- package/dist/src/core/pluresdb/adapter.d.ts +0 -72
- package/dist/src/core/pluresdb/adapter.d.ts.map +0 -1
- package/dist/src/core/pluresdb/adapter.js +0 -73
- package/dist/src/core/pluresdb/adapter.js.map +0 -1
- package/dist/src/core/pluresdb/generator.d.ts +0 -58
- package/dist/src/core/pluresdb/generator.d.ts.map +0 -1
- package/dist/src/core/pluresdb/generator.js +0 -191
- package/dist/src/core/pluresdb/generator.js.map +0 -1
- package/dist/src/core/pluresdb/index.d.ts +0 -15
- package/dist/src/core/pluresdb/index.d.ts.map +0 -1
- package/dist/src/core/pluresdb/index.js +0 -11
- package/dist/src/core/pluresdb/index.js.map +0 -1
- package/dist/src/core/pluresdb/schema-registry.d.ts +0 -104
- package/dist/src/core/pluresdb/schema-registry.d.ts.map +0 -1
- package/dist/src/core/pluresdb/schema-registry.js +0 -130
- package/dist/src/core/pluresdb/schema-registry.js.map +0 -1
- package/dist/src/core/pluresdb/store.d.ts +0 -199
- package/dist/src/core/pluresdb/store.d.ts.map +0 -1
- package/dist/src/core/pluresdb/store.js +0 -344
- package/dist/src/core/pluresdb/store.js.map +0 -1
- package/dist/src/core/protocol.d.ts.map +0 -1
- package/dist/src/core/protocol.js +0 -46
- package/dist/src/core/protocol.js.map +0 -1
- package/dist/src/core/rules.d.ts +0 -120
- package/dist/src/core/rules.d.ts.map +0 -1
- package/dist/src/core/rules.js +0 -81
- package/dist/src/core/rules.js.map +0 -1
- package/dist/src/core/schema/loader.d.ts +0 -47
- package/dist/src/core/schema/loader.d.ts.map +0 -1
- package/dist/src/core/schema/loader.js +0 -189
- package/dist/src/core/schema/loader.js.map +0 -1
- package/dist/src/core/schema/normalize.d.ts +0 -72
- package/dist/src/core/schema/normalize.d.ts.map +0 -1
- package/dist/src/core/schema/normalize.js +0 -190
- package/dist/src/core/schema/normalize.js.map +0 -1
- package/dist/src/core/schema/types.d.ts.map +0 -1
- package/dist/src/core/schema/types.js +0 -161
- package/dist/src/core/schema/types.js.map +0 -1
- package/dist/src/dsl/index.d.ts +0 -152
- package/dist/src/dsl/index.d.ts.map +0 -1
- package/dist/src/dsl/index.js +0 -132
- package/dist/src/dsl/index.js.map +0 -1
- package/dist/src/dsl.d.ts +0 -124
- package/dist/src/dsl.d.ts.map +0 -1
- package/dist/src/dsl.js +0 -130
- package/dist/src/dsl.js.map +0 -1
- package/dist/src/examples/advanced-todo/index.d.ts +0 -55
- package/dist/src/examples/advanced-todo/index.d.ts.map +0 -1
- package/dist/src/examples/advanced-todo/index.js +0 -222
- package/dist/src/examples/advanced-todo/index.js.map +0 -1
- package/dist/src/examples/auth-basic/index.d.ts +0 -17
- package/dist/src/examples/auth-basic/index.d.ts.map +0 -1
- package/dist/src/examples/auth-basic/index.js +0 -122
- package/dist/src/examples/auth-basic/index.js.map +0 -1
- package/dist/src/examples/cart/index.d.ts +0 -19
- package/dist/src/examples/cart/index.d.ts.map +0 -1
- package/dist/src/examples/cart/index.js +0 -202
- package/dist/src/examples/cart/index.js.map +0 -1
- package/dist/src/examples/hero-ecommerce/index.d.ts +0 -39
- package/dist/src/examples/hero-ecommerce/index.d.ts.map +0 -1
- package/dist/src/examples/hero-ecommerce/index.js +0 -506
- package/dist/src/examples/hero-ecommerce/index.js.map +0 -1
- package/dist/src/examples/svelte-counter/index.d.ts +0 -31
- package/dist/src/examples/svelte-counter/index.d.ts.map +0 -1
- package/dist/src/examples/svelte-counter/index.js +0 -123
- package/dist/src/examples/svelte-counter/index.js.map +0 -1
- package/dist/src/flows.d.ts +0 -125
- package/dist/src/flows.d.ts.map +0 -1
- package/dist/src/flows.js +0 -160
- package/dist/src/flows.js.map +0 -1
- package/dist/src/index.d.ts +0 -77
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -64
- package/dist/src/index.js.map +0 -1
- package/dist/src/integrations/code-canvas.d.ts +0 -265
- package/dist/src/integrations/code-canvas.d.ts.map +0 -1
- package/dist/src/integrations/code-canvas.js +0 -451
- package/dist/src/integrations/code-canvas.js.map +0 -1
- package/dist/src/integrations/pluresdb.d.ts +0 -117
- package/dist/src/integrations/pluresdb.d.ts.map +0 -1
- package/dist/src/integrations/pluresdb.js +0 -117
- package/dist/src/integrations/pluresdb.js.map +0 -1
- package/dist/src/integrations/state-docs.d.ts +0 -191
- package/dist/src/integrations/state-docs.d.ts.map +0 -1
- package/dist/src/integrations/state-docs.js +0 -515
- package/dist/src/integrations/state-docs.js.map +0 -1
- package/dist/src/integrations/svelte.d.ts.map +0 -1
- package/dist/src/integrations/svelte.js +0 -447
- package/dist/src/integrations/svelte.js.map +0 -1
- package/dist/src/integrations/tauri.d.ts +0 -360
- package/dist/src/integrations/tauri.d.ts.map +0 -1
- package/dist/src/integrations/tauri.js +0 -278
- package/dist/src/integrations/tauri.js.map +0 -1
- package/dist/src/integrations/unum.d.ts +0 -159
- package/dist/src/integrations/unum.d.ts.map +0 -1
- package/dist/src/integrations/unum.js +0 -240
- package/dist/src/integrations/unum.js.map +0 -1
- package/dist/src/registry.d.ts +0 -94
- package/dist/src/registry.d.ts.map +0 -1
- package/dist/src/registry.js +0 -181
- package/dist/src/registry.js.map +0 -1
- package/dist/src/runtime/terminal-adapter.d.ts.map +0 -1
- package/dist/src/runtime/terminal-adapter.js +0 -239
- package/dist/src/runtime/terminal-adapter.js.map +0 -1
- package/dist/src/step.d.ts +0 -34
- package/dist/src/step.d.ts.map +0 -1
- package/dist/src/step.js +0 -111
- package/dist/src/step.js.map +0 -1
- package/dist/src/types.d.ts +0 -63
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -6
- package/dist/src/types.js.map +0 -1
- package/dist/tools/cli/commands/index.d.ts +0 -7
- package/dist/tools/cli/commands/index.d.ts.map +0 -1
- package/dist/tools/cli/commands/index.js +0 -7
- package/dist/tools/cli/commands/index.js.map +0 -1
- package/dist/tools/cli/index.d.ts +0 -8
- package/dist/tools/cli/index.d.ts.map +0 -1
- package/dist/tools/cli/index.js +0 -9
- package/dist/tools/cli/index.js.map +0 -1
- package/dist/tools/watcher/index.d.ts +0 -105
- package/dist/tools/watcher/index.d.ts.map +0 -1
- package/dist/tools/watcher/index.js +0 -213
- package/dist/tools/watcher/index.js.map +0 -1
- package/dist/ui/canvas/canvas-projection.d.ts +0 -78
- package/dist/ui/canvas/canvas-projection.d.ts.map +0 -1
- package/dist/ui/canvas/canvas-projection.js +0 -416
- package/dist/ui/canvas/canvas-projection.js.map +0 -1
- package/dist/ui/canvas/canvas-state.d.ts +0 -200
- package/dist/ui/canvas/canvas-state.d.ts.map +0 -1
- package/dist/ui/canvas/canvas-state.js +0 -464
- package/dist/ui/canvas/canvas-state.js.map +0 -1
- package/dist/ui/canvas/components/index.d.ts +0 -95
- package/dist/ui/canvas/components/index.d.ts.map +0 -1
- package/dist/ui/canvas/components/index.js +0 -19
- package/dist/ui/canvas/components/index.js.map +0 -1
- package/dist/ui/canvas/index.d.ts +0 -32
- package/dist/ui/canvas/index.d.ts.map +0 -1
- package/dist/ui/canvas/index.js +0 -32
- package/dist/ui/canvas/index.js.map +0 -1
- package/dist/ui/svelte-generator/index.d.ts +0 -9
- package/dist/ui/svelte-generator/index.d.ts.map +0 -1
- package/dist/ui/svelte-generator/index.js +0 -11
- package/dist/ui/svelte-generator/index.js.map +0 -1
- package/dist/ui/svelte-generator/psf-generator.d.ts +0 -128
- package/dist/ui/svelte-generator/psf-generator.d.ts.map +0 -1
- package/dist/ui/svelte-generator/psf-generator.js +0 -506
- package/dist/ui/svelte-generator/psf-generator.js.map +0 -1
package/src/integrations/unum.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unum Integration
|
|
3
|
-
*
|
|
4
|
-
* Integration with plures/unum - A modern Svelte binding library for PluresDB
|
|
3
|
+
*
|
|
4
|
+
* Integration with plures/unum - A modern Svelte binding library for PluresDB
|
|
5
5
|
* with full Svelte 5 compatibility. Provides identity and channels support.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* Features:
|
|
8
8
|
* - Svelte 4 & 5 Compatible: Works with both store-based and runes-based reactivity
|
|
9
9
|
* - Type-Safe: Full TypeScript support with proper types
|
|
10
10
|
* - Action-Based: Modern Svelte actions for DOM binding
|
|
11
11
|
* - Store-Based: Writable store implementation for reactive data
|
|
12
12
|
* - Collection Support: Easy handling of PluresDB collections
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* @see https://github.com/plures/unum
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { LogicEngine } from
|
|
18
|
-
import type { PraxisEvent, PraxisFact } from
|
|
19
|
-
import type { PraxisDB } from
|
|
17
|
+
import type { LogicEngine } from '../core/engine.js';
|
|
18
|
+
import type { PraxisEvent, PraxisFact } from '../core/protocol.js';
|
|
19
|
+
import type { PraxisDB } from '../core/pluresdb/adapter.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Unum store interface for reactive PluresDB data
|
|
@@ -97,53 +97,53 @@ export interface UnumAdapterConfig {
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Unum adapter for Praxis engine integration
|
|
100
|
-
*
|
|
100
|
+
*
|
|
101
101
|
* Provides identity management and channel-based communication
|
|
102
102
|
* for distributed Praxis applications.
|
|
103
103
|
*/
|
|
104
104
|
export interface UnumAdapter {
|
|
105
105
|
/** Current identity */
|
|
106
106
|
identity: UnumIdentity | null;
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
/** Create or update identity */
|
|
109
109
|
setIdentity(identity: Omit<UnumIdentity, 'id' | 'createdAt'>): Promise<UnumIdentity>;
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
/** Get identity by ID */
|
|
112
112
|
getIdentity(id: string): Promise<UnumIdentity | null>;
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
/** Create a new channel */
|
|
115
115
|
createChannel(name: string, members?: string[]): Promise<UnumChannel>;
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
/** Join an existing channel */
|
|
118
118
|
joinChannel(channelId: string): Promise<UnumChannel>;
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
/** List available channels */
|
|
121
121
|
listChannels(): Promise<UnumChannel[]>;
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
/** Broadcast a Praxis event to a channel */
|
|
124
124
|
broadcastEvent(channelId: string, event: PraxisEvent): Promise<void>;
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
/** Broadcast a Praxis fact to a channel */
|
|
127
127
|
broadcastFact(channelId: string, fact: PraxisFact): Promise<void>;
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
/** Subscribe to events from a channel */
|
|
130
130
|
subscribeToEvents(channelId: string, handler: (event: PraxisEvent) => void): () => void;
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
/** Subscribe to facts from a channel */
|
|
133
133
|
subscribeToFacts(channelId: string, handler: (fact: PraxisFact) => void): () => void;
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
/** Disconnect and cleanup */
|
|
136
136
|
disconnect(): Promise<void>;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Create a Unum adapter for Praxis engine integration
|
|
141
|
-
*
|
|
141
|
+
*
|
|
142
142
|
* @example
|
|
143
143
|
* ```typescript
|
|
144
144
|
* import { createUnumAdapter } from '@plures/praxis/integrations/unum';
|
|
145
145
|
* import { createInMemoryDB } from '@plures/praxis/integrations/pluresdb';
|
|
146
|
-
*
|
|
146
|
+
*
|
|
147
147
|
* const db = createInMemoryDB();
|
|
148
148
|
* const unum = await createUnumAdapter({
|
|
149
149
|
* db,
|
|
@@ -152,10 +152,10 @@ export interface UnumAdapter {
|
|
|
152
152
|
* },
|
|
153
153
|
* realtime: true,
|
|
154
154
|
* });
|
|
155
|
-
*
|
|
155
|
+
*
|
|
156
156
|
* // Create a channel
|
|
157
157
|
* const channel = await unum.createChannel('my-channel');
|
|
158
|
-
*
|
|
158
|
+
*
|
|
159
159
|
* // Broadcast events to the channel
|
|
160
160
|
* await unum.broadcastEvent(channel.id, myEvent);
|
|
161
161
|
* ```
|
|
@@ -163,11 +163,11 @@ export interface UnumAdapter {
|
|
|
163
163
|
export async function createUnumAdapter(config: UnumAdapterConfig): Promise<UnumAdapter> {
|
|
164
164
|
const { db, realtime = true } = config;
|
|
165
165
|
// syncInterval could be used for periodic sync in a more complete implementation
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
let currentIdentity: UnumIdentity | null = null;
|
|
168
168
|
const channels = new Map<string, UnumChannel>();
|
|
169
169
|
const subscriptions = new Set<() => void>();
|
|
170
|
-
|
|
170
|
+
|
|
171
171
|
// Set initial identity if provided
|
|
172
172
|
if (config.identity) {
|
|
173
173
|
currentIdentity = {
|
|
@@ -177,8 +177,10 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
177
177
|
};
|
|
178
178
|
await db.set(`unum/identities/${currentIdentity.id}`, currentIdentity);
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
async function setIdentity(
|
|
180
|
+
|
|
181
|
+
async function setIdentity(
|
|
182
|
+
identity: Omit<UnumIdentity, 'id' | 'createdAt'>
|
|
183
|
+
): Promise<UnumIdentity> {
|
|
182
184
|
currentIdentity = {
|
|
183
185
|
...identity,
|
|
184
186
|
id: generateId(),
|
|
@@ -187,11 +189,11 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
187
189
|
await db.set(`unum/identities/${currentIdentity.id}`, currentIdentity);
|
|
188
190
|
return currentIdentity;
|
|
189
191
|
}
|
|
190
|
-
|
|
192
|
+
|
|
191
193
|
async function getIdentity(id: string): Promise<UnumIdentity | null> {
|
|
192
|
-
return await db.get(`unum/identities/${id}`) as UnumIdentity | null;
|
|
194
|
+
return (await db.get(`unum/identities/${id}`)) as UnumIdentity | null;
|
|
193
195
|
}
|
|
194
|
-
|
|
196
|
+
|
|
195
197
|
async function createChannel(name: string, members?: string[]): Promise<UnumChannel> {
|
|
196
198
|
const channelId = generateId();
|
|
197
199
|
const channelData = {
|
|
@@ -201,41 +203,44 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
201
203
|
createdAt: Date.now(),
|
|
202
204
|
createdBy: currentIdentity?.id,
|
|
203
205
|
};
|
|
204
|
-
|
|
206
|
+
|
|
205
207
|
await db.set(`unum/channels/${channelId}`, channelData);
|
|
206
|
-
|
|
208
|
+
|
|
207
209
|
const channel = createChannelInstance(channelId, name);
|
|
208
210
|
channels.set(channelId, channel);
|
|
209
211
|
return channel;
|
|
210
212
|
}
|
|
211
|
-
|
|
213
|
+
|
|
212
214
|
async function joinChannel(channelId: string): Promise<UnumChannel> {
|
|
213
215
|
const existing = channels.get(channelId);
|
|
214
216
|
if (existing) return existing;
|
|
215
|
-
|
|
216
|
-
const channelData = await db.get(`unum/channels/${channelId}`) as {
|
|
217
|
+
|
|
218
|
+
const channelData = (await db.get(`unum/channels/${channelId}`)) as {
|
|
219
|
+
id: string;
|
|
220
|
+
name: string;
|
|
221
|
+
} | null;
|
|
217
222
|
if (!channelData) {
|
|
218
223
|
throw new Error(`Channel ${channelId} not found`);
|
|
219
224
|
}
|
|
220
|
-
|
|
225
|
+
|
|
221
226
|
const channel = createChannelInstance(channelData.id, channelData.name);
|
|
222
227
|
channels.set(channelId, channel);
|
|
223
228
|
return channel;
|
|
224
229
|
}
|
|
225
|
-
|
|
230
|
+
|
|
226
231
|
async function listChannels(): Promise<UnumChannel[]> {
|
|
227
232
|
return Array.from(channels.values());
|
|
228
233
|
}
|
|
229
|
-
|
|
234
|
+
|
|
230
235
|
function createChannelInstance(id: string, name: string): UnumChannel {
|
|
231
236
|
const handlers = new Set<(message: UnumMessage) => void>();
|
|
232
|
-
|
|
237
|
+
|
|
233
238
|
return {
|
|
234
239
|
id,
|
|
235
240
|
name,
|
|
236
241
|
subscribe(handler: (message: UnumMessage) => void): () => void {
|
|
237
242
|
handlers.add(handler);
|
|
238
|
-
|
|
243
|
+
|
|
239
244
|
// Set up database subscription if realtime is enabled
|
|
240
245
|
if (realtime) {
|
|
241
246
|
const unsub = db.watch(`unum/channels/${id}/messages`, (data) => {
|
|
@@ -245,7 +250,7 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
245
250
|
});
|
|
246
251
|
subscriptions.add(unsub);
|
|
247
252
|
}
|
|
248
|
-
|
|
253
|
+
|
|
249
254
|
return () => {
|
|
250
255
|
handlers.delete(handler);
|
|
251
256
|
};
|
|
@@ -257,16 +262,16 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
257
262
|
channelId: id,
|
|
258
263
|
timestamp: Date.now(),
|
|
259
264
|
};
|
|
260
|
-
|
|
265
|
+
|
|
261
266
|
await db.set(`unum/channels/${id}/messages/${fullMessage.id}`, fullMessage);
|
|
262
|
-
|
|
267
|
+
|
|
263
268
|
// Notify local handlers
|
|
264
|
-
handlers.forEach(h => h(fullMessage));
|
|
269
|
+
handlers.forEach((h) => h(fullMessage));
|
|
265
270
|
},
|
|
266
271
|
async getMembers(): Promise<UnumIdentity[]> {
|
|
267
|
-
const channelData = await db.get(`unum/channels/${id}`) as { members?: string[] } | null;
|
|
272
|
+
const channelData = (await db.get(`unum/channels/${id}`)) as { members?: string[] } | null;
|
|
268
273
|
if (!channelData?.members) return [];
|
|
269
|
-
|
|
274
|
+
|
|
270
275
|
const members: UnumIdentity[] = [];
|
|
271
276
|
for (const memberId of channelData.members) {
|
|
272
277
|
const identity = await getIdentity(memberId);
|
|
@@ -279,13 +284,13 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
279
284
|
},
|
|
280
285
|
};
|
|
281
286
|
}
|
|
282
|
-
|
|
287
|
+
|
|
283
288
|
async function broadcastEvent(channelId: string, event: PraxisEvent): Promise<void> {
|
|
284
289
|
const channel = channels.get(channelId);
|
|
285
290
|
if (!channel) {
|
|
286
291
|
throw new Error(`Not joined to channel ${channelId}`);
|
|
287
292
|
}
|
|
288
|
-
|
|
293
|
+
|
|
289
294
|
await channel.publish({
|
|
290
295
|
id: generateId(),
|
|
291
296
|
sender: currentIdentity || { id: 'anonymous', createdAt: Date.now() },
|
|
@@ -293,13 +298,13 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
293
298
|
type: 'event',
|
|
294
299
|
});
|
|
295
300
|
}
|
|
296
|
-
|
|
301
|
+
|
|
297
302
|
async function broadcastFact(channelId: string, fact: PraxisFact): Promise<void> {
|
|
298
303
|
const channel = channels.get(channelId);
|
|
299
304
|
if (!channel) {
|
|
300
305
|
throw new Error(`Not joined to channel ${channelId}`);
|
|
301
306
|
}
|
|
302
|
-
|
|
307
|
+
|
|
303
308
|
await channel.publish({
|
|
304
309
|
id: generateId(),
|
|
305
310
|
sender: currentIdentity || { id: 'anonymous', createdAt: Date.now() },
|
|
@@ -307,49 +312,51 @@ export async function createUnumAdapter(config: UnumAdapterConfig): Promise<Unum
|
|
|
307
312
|
type: 'fact',
|
|
308
313
|
});
|
|
309
314
|
}
|
|
310
|
-
|
|
315
|
+
|
|
311
316
|
function subscribeToEvents(channelId: string, handler: (event: PraxisEvent) => void): () => void {
|
|
312
317
|
const channel = channels.get(channelId);
|
|
313
318
|
if (!channel) {
|
|
314
319
|
throw new Error(`Not joined to channel ${channelId}`);
|
|
315
320
|
}
|
|
316
|
-
|
|
321
|
+
|
|
317
322
|
return channel.subscribe((message) => {
|
|
318
323
|
if (message.type === 'event') {
|
|
319
324
|
handler(message.content as PraxisEvent);
|
|
320
325
|
}
|
|
321
326
|
});
|
|
322
327
|
}
|
|
323
|
-
|
|
328
|
+
|
|
324
329
|
function subscribeToFacts(channelId: string, handler: (fact: PraxisFact) => void): () => void {
|
|
325
330
|
const channel = channels.get(channelId);
|
|
326
331
|
if (!channel) {
|
|
327
332
|
throw new Error(`Not joined to channel ${channelId}`);
|
|
328
333
|
}
|
|
329
|
-
|
|
334
|
+
|
|
330
335
|
return channel.subscribe((message) => {
|
|
331
336
|
if (message.type === 'fact') {
|
|
332
337
|
handler(message.content as PraxisFact);
|
|
333
338
|
}
|
|
334
339
|
});
|
|
335
340
|
}
|
|
336
|
-
|
|
341
|
+
|
|
337
342
|
async function disconnect(): Promise<void> {
|
|
338
343
|
// Cleanup all subscriptions
|
|
339
|
-
subscriptions.forEach(unsub => unsub());
|
|
344
|
+
subscriptions.forEach((unsub) => unsub());
|
|
340
345
|
subscriptions.clear();
|
|
341
|
-
|
|
346
|
+
|
|
342
347
|
// Leave all channels
|
|
343
348
|
for (const channel of channels.values()) {
|
|
344
349
|
await channel.leave();
|
|
345
350
|
}
|
|
346
351
|
channels.clear();
|
|
347
|
-
|
|
352
|
+
|
|
348
353
|
currentIdentity = null;
|
|
349
354
|
}
|
|
350
|
-
|
|
355
|
+
|
|
351
356
|
return {
|
|
352
|
-
get identity() {
|
|
357
|
+
get identity() {
|
|
358
|
+
return currentIdentity;
|
|
359
|
+
},
|
|
353
360
|
setIdentity,
|
|
354
361
|
getIdentity,
|
|
355
362
|
createChannel,
|
|
@@ -372,11 +379,11 @@ function generateId(): string {
|
|
|
372
379
|
|
|
373
380
|
/**
|
|
374
381
|
* Attach Unum adapter to a Praxis engine
|
|
375
|
-
*
|
|
382
|
+
*
|
|
376
383
|
* Enables automatic event/fact broadcasting to connected channels.
|
|
377
384
|
* This is a placeholder for future integration where the engine
|
|
378
385
|
* would emit events that get broadcast to channels.
|
|
379
|
-
*
|
|
386
|
+
*
|
|
380
387
|
* @param _engine - The Praxis logic engine
|
|
381
388
|
* @param _adapter - The Unum adapter
|
|
382
389
|
* @param _channelId - The channel to broadcast to
|
package/src/registry.ts
CHANGED
|
@@ -9,10 +9,7 @@ import type { Rule, Constraint, ConstraintViolation } from './dsl.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* Registry for managing rules and constraints.
|
|
11
11
|
*/
|
|
12
|
-
export class Registry<
|
|
13
|
-
S extends PraxisState = PraxisState,
|
|
14
|
-
E extends PraxisEvent = PraxisEvent
|
|
15
|
-
> {
|
|
12
|
+
export class Registry<S extends PraxisState = PraxisState, E extends PraxisEvent = PraxisEvent> {
|
|
16
13
|
private rules: Map<string, Rule<S, E>> = new Map();
|
|
17
14
|
private constraints: Map<string, Constraint<S>> = new Map();
|
|
18
15
|
|
|
@@ -113,14 +110,12 @@ export class Registry<
|
|
|
113
110
|
*/
|
|
114
111
|
evaluateRules(state: S, event: E): Effect[] {
|
|
115
112
|
const effects: Effect[] = [];
|
|
116
|
-
|
|
113
|
+
|
|
117
114
|
// Get rules that match the event type
|
|
118
115
|
const applicableRules = this.getRulesForEvent(event.type);
|
|
119
|
-
|
|
116
|
+
|
|
120
117
|
// Sort by priority (higher priority first)
|
|
121
|
-
const sortedRules = applicableRules.sort(
|
|
122
|
-
(a, b) => (b.priority ?? 0) - (a.priority ?? 0)
|
|
123
|
-
);
|
|
118
|
+
const sortedRules = applicableRules.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
124
119
|
|
|
125
120
|
// Evaluate each rule
|
|
126
121
|
for (const rule of sortedRules) {
|
|
@@ -149,9 +144,7 @@ export class Registry<
|
|
|
149
144
|
if (!constraint.check(state)) {
|
|
150
145
|
violations.push({
|
|
151
146
|
constraintId: constraint.id,
|
|
152
|
-
message:
|
|
153
|
-
constraint.errorMessage ||
|
|
154
|
-
`Constraint '${constraint.id}' violated`,
|
|
147
|
+
message: constraint.errorMessage || `Constraint '${constraint.id}' violated`,
|
|
155
148
|
state,
|
|
156
149
|
});
|
|
157
150
|
}
|
|
@@ -198,7 +191,7 @@ export class Registry<
|
|
|
198
191
|
rulesByEventType: Record<string, number>;
|
|
199
192
|
} {
|
|
200
193
|
const rulesByEventType: Record<string, number> = {};
|
|
201
|
-
|
|
194
|
+
|
|
202
195
|
for (const rule of this.rules.values()) {
|
|
203
196
|
const eventType = rule.eventType || '*';
|
|
204
197
|
rulesByEventType[eventType] = (rulesByEventType[eventType] || 0) + 1;
|
|
@@ -217,7 +210,7 @@ export class Registry<
|
|
|
217
210
|
*/
|
|
218
211
|
export function createRegistry<
|
|
219
212
|
S extends PraxisState = PraxisState,
|
|
220
|
-
E extends PraxisEvent = PraxisEvent
|
|
213
|
+
E extends PraxisEvent = PraxisEvent,
|
|
221
214
|
>(): Registry<S, E> {
|
|
222
215
|
return new Registry<S, E>();
|
|
223
216
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Terminal Node Runtime Adapter
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Handles terminal command execution and state management.
|
|
5
5
|
* Integrates with pluresDB for state synchronization.
|
|
6
6
|
*/
|
|
@@ -82,23 +82,28 @@ async function defaultExecutor(
|
|
|
82
82
|
const { exec } = await import('child_process');
|
|
83
83
|
const { promisify } = await import('util');
|
|
84
84
|
const execAsync = promisify(exec);
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
// Get process.env safely (only available in Node.js environments)
|
|
87
|
-
const processEnv = typeof process !==
|
|
88
|
-
|
|
87
|
+
const processEnv = typeof process !== 'undefined' ? process.env : {};
|
|
88
|
+
|
|
89
89
|
const result = await execAsync(command, {
|
|
90
90
|
cwd: options.cwd,
|
|
91
91
|
env: { ...processEnv, ...options.env },
|
|
92
92
|
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
93
93
|
timeout: 60000, // 60 second timeout
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
return {
|
|
97
97
|
output: result.stdout + (result.stderr ? `\n${result.stderr}` : ''),
|
|
98
98
|
exitCode: 0,
|
|
99
99
|
};
|
|
100
100
|
} catch (error: unknown) {
|
|
101
|
-
const execError = error as {
|
|
101
|
+
const execError = error as {
|
|
102
|
+
stdout?: string;
|
|
103
|
+
stderr?: string;
|
|
104
|
+
code?: number;
|
|
105
|
+
message?: string;
|
|
106
|
+
};
|
|
102
107
|
return {
|
|
103
108
|
output: (execError.stdout || '') + (execError.stderr || ''),
|
|
104
109
|
exitCode: execError.code || 1,
|
|
@@ -109,7 +114,7 @@ async function defaultExecutor(
|
|
|
109
114
|
|
|
110
115
|
/**
|
|
111
116
|
* Terminal Runtime Adapter
|
|
112
|
-
*
|
|
117
|
+
*
|
|
113
118
|
* Manages terminal node execution and state.
|
|
114
119
|
* Supports command execution with history tracking and PluresDB integration.
|
|
115
120
|
*/
|
|
@@ -137,22 +142,22 @@ export class TerminalAdapter {
|
|
|
137
142
|
|
|
138
143
|
/**
|
|
139
144
|
* Execute a terminal command
|
|
140
|
-
*
|
|
145
|
+
*
|
|
141
146
|
* @param command - Command to execute
|
|
142
147
|
* @returns Execution result
|
|
143
148
|
*/
|
|
144
149
|
async executeCommand(command: string): Promise<TerminalExecutionResult> {
|
|
145
150
|
// Add to history
|
|
146
151
|
this.state.history.push(command);
|
|
147
|
-
|
|
152
|
+
|
|
148
153
|
const timestamp = Date.now();
|
|
149
|
-
|
|
154
|
+
|
|
150
155
|
// Execute the command
|
|
151
156
|
const { output, exitCode, error } = await this.executor(command, {
|
|
152
157
|
cwd: this.state.cwd,
|
|
153
158
|
env: this.state.env,
|
|
154
159
|
});
|
|
155
|
-
|
|
160
|
+
|
|
156
161
|
const result: TerminalExecutionResult = {
|
|
157
162
|
command,
|
|
158
163
|
output,
|
|
@@ -219,13 +224,13 @@ export class TerminalAdapter {
|
|
|
219
224
|
|
|
220
225
|
/**
|
|
221
226
|
* Sync state to PluresDB
|
|
222
|
-
*
|
|
227
|
+
*
|
|
223
228
|
* @param path - PluresDB path for storing results
|
|
224
229
|
* @param data - Data to sync
|
|
225
230
|
*/
|
|
226
231
|
private async syncToPluresDB(path: string, data: TerminalExecutionResult): Promise<void> {
|
|
227
232
|
if (!this.db) return;
|
|
228
|
-
|
|
233
|
+
|
|
229
234
|
try {
|
|
230
235
|
// Store the execution result
|
|
231
236
|
await this.db.set(path, {
|
|
@@ -233,7 +238,7 @@ export class TerminalAdapter {
|
|
|
233
238
|
nodeId: this.state.nodeId,
|
|
234
239
|
syncedAt: Date.now(),
|
|
235
240
|
});
|
|
236
|
-
|
|
241
|
+
|
|
237
242
|
// Also append to history path
|
|
238
243
|
const historyPath = `${path}/history`;
|
|
239
244
|
const historyKey = `${historyPath}/${data.timestamp}`;
|
|
@@ -248,7 +253,7 @@ export class TerminalAdapter {
|
|
|
248
253
|
*/
|
|
249
254
|
async loadFromPluresDB(): Promise<void> {
|
|
250
255
|
if (!this.db || !this.inputPath) return;
|
|
251
|
-
|
|
256
|
+
|
|
252
257
|
try {
|
|
253
258
|
const data = await this.db.get(this.inputPath);
|
|
254
259
|
if (data && typeof data === 'object') {
|
|
@@ -276,7 +281,7 @@ export class TerminalAdapter {
|
|
|
276
281
|
*/
|
|
277
282
|
watchInput(callback: (command: string) => void): (() => void) | null {
|
|
278
283
|
if (!this.db || !this.inputPath) return null;
|
|
279
|
-
|
|
284
|
+
|
|
280
285
|
return this.db.watch(this.inputPath, (data) => {
|
|
281
286
|
if (data && typeof data === 'object' && 'command' in data) {
|
|
282
287
|
callback((data as { command: string }).command);
|
|
@@ -287,19 +292,17 @@ export class TerminalAdapter {
|
|
|
287
292
|
|
|
288
293
|
/**
|
|
289
294
|
* Create a terminal adapter instance
|
|
290
|
-
*
|
|
295
|
+
*
|
|
291
296
|
* @param options - Terminal adapter options
|
|
292
297
|
* @returns Terminal adapter instance
|
|
293
298
|
*/
|
|
294
|
-
export function createTerminalAdapter(
|
|
295
|
-
options: TerminalAdapterOptions
|
|
296
|
-
): TerminalAdapter {
|
|
299
|
+
export function createTerminalAdapter(options: TerminalAdapterOptions): TerminalAdapter {
|
|
297
300
|
return new TerminalAdapter(options);
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
/**
|
|
301
304
|
* Run a terminal command (convenience function)
|
|
302
|
-
*
|
|
305
|
+
*
|
|
303
306
|
* @param nodeId - Terminal node identifier
|
|
304
307
|
* @param command - Command to execute
|
|
305
308
|
* @param options - Additional options
|
|
@@ -308,13 +311,14 @@ export function createTerminalAdapter(
|
|
|
308
311
|
export async function runTerminalCommand(
|
|
309
312
|
nodeId: string,
|
|
310
313
|
command: string,
|
|
311
|
-
options?: { cwd?: string; env?: Record<string, string>; db?: PraxisDB }
|
|
314
|
+
options?: { cwd?: string; env?: Record<string, string>; db?: PraxisDB; executor?: CommandExecutor }
|
|
312
315
|
): Promise<TerminalExecutionResult> {
|
|
313
316
|
const adapter = createTerminalAdapter({
|
|
314
317
|
nodeId,
|
|
315
318
|
cwd: options?.cwd,
|
|
316
319
|
env: options?.env,
|
|
317
320
|
db: options?.db,
|
|
321
|
+
executor: options?.executor,
|
|
318
322
|
});
|
|
319
323
|
return adapter.executeCommand(command);
|
|
320
324
|
}
|
|
@@ -327,10 +331,11 @@ export function createMockExecutor(
|
|
|
327
331
|
responses: Record<string, { output: string; exitCode: number; error?: string }>
|
|
328
332
|
): CommandExecutor {
|
|
329
333
|
return async (command: string) => {
|
|
330
|
-
const response = responses[command] ||
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
+
const response = responses[command] ||
|
|
335
|
+
responses['*'] || {
|
|
336
|
+
output: `Mock output for: ${command}`,
|
|
337
|
+
exitCode: 0,
|
|
338
|
+
};
|
|
334
339
|
return response;
|
|
335
340
|
};
|
|
336
341
|
}
|
package/src/step.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { Registry } from './registry.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export interface StepOptions<
|
|
13
13
|
S extends PraxisState = PraxisState,
|
|
14
|
-
E extends PraxisEvent = PraxisEvent
|
|
14
|
+
E extends PraxisEvent = PraxisEvent,
|
|
15
15
|
> {
|
|
16
16
|
/** Registry containing rules and constraints */
|
|
17
17
|
registry?: Registry<S, E>;
|
|
@@ -27,7 +27,7 @@ export interface StepOptions<
|
|
|
27
27
|
*/
|
|
28
28
|
export function createStepFunction<
|
|
29
29
|
S extends PraxisState = PraxisState,
|
|
30
|
-
E extends PraxisEvent = PraxisEvent
|
|
30
|
+
E extends PraxisEvent = PraxisEvent,
|
|
31
31
|
>(options: StepOptions<S, E> = {}): StepFunction<S, E> {
|
|
32
32
|
const { registry, checkConstraints = true, reducer } = options;
|
|
33
33
|
|
|
@@ -38,9 +38,7 @@ export function createStepFunction<
|
|
|
38
38
|
if (checkConstraints && registry) {
|
|
39
39
|
const violations = registry.checkConstraints(state);
|
|
40
40
|
if (violations.length > 0) {
|
|
41
|
-
errors.push(
|
|
42
|
-
...violations.map((v) => `Pre-condition: ${v.message}`)
|
|
43
|
-
);
|
|
41
|
+
errors.push(...violations.map((v) => `Pre-condition: ${v.message}`));
|
|
44
42
|
// Return current state with errors
|
|
45
43
|
return { state, errors };
|
|
46
44
|
}
|
|
@@ -78,9 +76,7 @@ export function createStepFunction<
|
|
|
78
76
|
if (checkConstraints && registry) {
|
|
79
77
|
const violations = registry.checkConstraints(newState);
|
|
80
78
|
if (violations.length > 0) {
|
|
81
|
-
errors.push(
|
|
82
|
-
...violations.map((v) => `Post-condition: ${v.message}`)
|
|
83
|
-
);
|
|
79
|
+
errors.push(...violations.map((v) => `Post-condition: ${v.message}`));
|
|
84
80
|
// Return previous state with errors to maintain invariants
|
|
85
81
|
return { state, errors };
|
|
86
82
|
}
|
|
@@ -98,10 +94,9 @@ export function createStepFunction<
|
|
|
98
94
|
* Simple step function that just applies a reducer.
|
|
99
95
|
* Useful for basic state transitions without rules or constraints.
|
|
100
96
|
*/
|
|
101
|
-
export function step<
|
|
102
|
-
S
|
|
103
|
-
|
|
104
|
-
>(reducer: (state: S, event: E) => S): StepFunction<S, E> {
|
|
97
|
+
export function step<S extends PraxisState = PraxisState, E extends PraxisEvent = PraxisEvent>(
|
|
98
|
+
reducer: (state: S, event: E) => S
|
|
99
|
+
): StepFunction<S, E> {
|
|
105
100
|
return (state: S, event: E): StepResult<S> => {
|
|
106
101
|
try {
|
|
107
102
|
const newState = reducer(state, event);
|
|
@@ -120,10 +115,9 @@ export function step<
|
|
|
120
115
|
* Each step function is applied in sequence, with the output of one
|
|
121
116
|
* becoming the input to the next.
|
|
122
117
|
*/
|
|
123
|
-
export function compose<
|
|
124
|
-
S
|
|
125
|
-
|
|
126
|
-
>(...steps: StepFunction<S, E>[]): StepFunction<S, E> {
|
|
118
|
+
export function compose<S extends PraxisState = PraxisState, E extends PraxisEvent = PraxisEvent>(
|
|
119
|
+
...steps: StepFunction<S, E>[]
|
|
120
|
+
): StepFunction<S, E> {
|
|
127
121
|
return (state: S, event: E): StepResult<S> => {
|
|
128
122
|
let currentState = state;
|
|
129
123
|
const allEffects: StepResult<S>['effects'] = [];
|
package/src/types.ts
CHANGED