@astrale-os/sdk 0.6.0-beta.5 → 0.6.0-beta.51
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/README.md +213 -60
- package/dist/application/action/action.d.ts +6 -0
- package/dist/application/action/authoring.d.ts +1 -1
- package/dist/application/action/context.d.ts +89 -33
- package/dist/application/action/define.d.ts +3 -3
- package/dist/application/action/index.d.ts +1 -1
- package/dist/application/define.d.ts +8 -6
- package/dist/application/define.js +28 -14
- package/dist/application/dependency/index.d.ts +1 -1
- package/dist/application/dependency/invoker.d.ts +21 -10
- package/dist/application/domain.d.ts +30 -0
- package/dist/application/error/error.d.ts +16 -1
- package/dist/application/error/error.js +39 -5
- package/dist/application/error/index.d.ts +1 -1
- package/dist/application/error/index.js +1 -1
- package/dist/application/index.d.ts +4 -4
- package/dist/application/index.js +1 -1
- package/dist/application/integration/define.d.ts +8 -1
- package/dist/application/integration/index.d.ts +2 -2
- package/dist/application/integration/integration.d.ts +13 -1
- package/dist/application/integration/operation.d.ts +16 -3
- package/dist/application/mutation/authoring/builder.d.ts +81 -33
- package/dist/application/mutation/authoring/builder.js +100 -30
- package/dist/application/mutation/authoring/guard.d.ts +37 -0
- package/dist/application/mutation/authoring/guard.js +150 -0
- package/dist/application/mutation/authoring/index.d.ts +5 -2
- package/dist/application/mutation/authoring/index.js +2 -1
- package/dist/application/mutation/authoring/names.d.ts +19 -0
- package/dist/application/mutation/authoring/names.js +83 -0
- package/dist/application/mutation/authoring/properties.d.ts +5 -3
- package/dist/application/mutation/authoring/properties.js +35 -2
- package/dist/application/mutation/authoring/transition.d.ts +3 -2
- package/dist/application/mutation/authoring/transition.js +4 -1
- package/dist/application/mutation/define.d.ts +24 -10
- package/dist/application/mutation/define.js +49 -53
- package/dist/application/mutation/execution/execute.d.ts +2 -2
- package/dist/application/mutation/execution/execute.js +78 -7
- package/dist/application/mutation/execution/executor.d.ts +4 -1
- package/dist/application/mutation/execution/executor.js +6 -1
- package/dist/application/mutation/failure.d.ts +17 -1
- package/dist/application/mutation/failure.js +40 -19
- package/dist/application/mutation/index.d.ts +9 -5
- package/dist/application/mutation/index.js +5 -2
- package/dist/application/mutation/legacy/v6/builder.d.ts +84 -0
- package/dist/application/mutation/legacy/v6/define.d.ts +18 -0
- package/dist/application/mutation/legacy/v6/define.js +56 -0
- package/dist/application/mutation/legacy/v6/mutation.d.ts +28 -0
- package/dist/application/mutation/{authoring → legacy/v6}/precondition.d.ts +4 -0
- package/dist/application/mutation/mutation.d.ts +47 -19
- package/dist/application/query/answer/answer.d.ts +117 -0
- package/dist/application/query/answer/conformance.d.ts +4 -0
- package/dist/application/query/answer/conformance.js +27 -0
- package/dist/application/query/answer/facts.d.ts +17 -0
- package/dist/application/query/answer/facts.js +57 -0
- package/dist/application/query/composite/builder.d.ts +1 -1
- package/dist/application/query/composite/builder.js +2 -2
- package/dist/application/query/composite/plan.d.ts +1 -5
- package/dist/application/query/composite/plan.js +1 -3
- package/dist/application/query/composite/query.d.ts +1 -2
- package/dist/application/query/define.d.ts +3 -34
- package/dist/application/query/define.js +5 -131
- package/dist/application/query/defined/define.d.ts +45 -0
- package/dist/application/query/defined/define.js +96 -0
- package/dist/application/query/defined/query.d.ts +139 -0
- package/dist/application/query/definition.d.ts +12 -0
- package/dist/application/query/definition.js +47 -0
- package/dist/application/query/execution/bounds.d.ts +22 -0
- package/dist/application/query/execution/bounds.js +88 -0
- package/dist/application/query/execution/client.d.ts +21 -0
- package/dist/application/query/execution/crossings.d.ts +25 -0
- package/dist/application/query/execution/crossings.js +218 -0
- package/dist/application/query/execution/error.d.ts +71 -0
- package/dist/application/query/execution/error.js +50 -0
- package/dist/application/query/execution/execute.d.ts +4 -10
- package/dist/application/query/execution/execute.js +3 -45
- package/dist/application/query/execution/executor.d.ts +2 -2
- package/dist/application/query/execution/refusal.d.ts +37 -0
- package/dist/application/query/execution/refusal.js +80 -0
- package/dist/application/query/execution/rows.d.ts +42 -0
- package/dist/application/query/execution/rows.js +326 -0
- package/dist/application/query/execution/run.d.ts +85 -0
- package/dist/application/query/execution/run.js +372 -0
- package/dist/application/query/execution/split.d.ts +24 -0
- package/dist/application/query/execution/split.js +190 -0
- package/dist/application/query/failure.d.ts +8 -0
- package/dist/application/query/failure.js +8 -0
- package/dist/application/query/handles/build.d.ts +10 -0
- package/dist/application/query/handles/build.js +53 -0
- package/dist/application/query/handles/conditions.d.ts +94 -0
- package/dist/application/query/handles/domain.d.ts +157 -0
- package/dist/application/query/handles/handles.d.ts +285 -0
- package/dist/application/query/handles/handles.js +1 -0
- package/dist/application/query/handles/model.d.ts +106 -0
- package/dist/application/query/handles/model.js +261 -0
- package/dist/application/query/handles/plan.d.ts +100 -0
- package/dist/application/query/handles/plan.js +37 -0
- package/dist/application/query/handles/reads.d.ts +106 -0
- package/dist/application/query/handles/reads.js +978 -0
- package/dist/application/query/handles/relations.d.ts +106 -0
- package/dist/application/query/handles/relations.js +1 -0
- package/dist/application/query/handles/rows.d.ts +94 -0
- package/dist/application/query/handles/rows.js +4 -0
- package/dist/application/query/handles/terms.d.ts +103 -0
- package/dist/application/query/handles/terms.js +282 -0
- package/dist/application/query/index.d.ts +14 -8
- package/dist/application/query/index.js +10 -5
- package/dist/application/query/language/index.d.ts +2 -0
- package/dist/application/query/language/index.js +2 -0
- package/dist/application/query/language/query.d.ts +323 -0
- package/dist/application/query/language/query.js +2 -0
- package/dist/application/query/{collection → legacy/v6/collection}/identity.d.ts +2 -2
- package/dist/application/query/{collection → legacy/v6/collection}/metadata.d.ts +1 -1
- package/dist/application/query/{collection → legacy/v6/collection}/union.d.ts +4 -4
- package/dist/application/query/{collection → legacy/v6/collection}/union.js +15 -8
- package/dist/application/query/legacy/v6/conformance.d.ts +15 -0
- package/dist/application/query/legacy/v6/conformance.js +46 -0
- package/dist/application/query/legacy/v6/define.d.ts +37 -0
- package/dist/application/query/legacy/v6/define.js +90 -0
- package/dist/application/query/legacy/v6/execution/execute.d.ts +18 -0
- package/dist/application/query/legacy/v6/execution/execute.js +50 -0
- package/dist/application/query/legacy/v6/index.d.ts +7 -0
- package/dist/application/query/legacy/v6/index.js +3 -0
- package/dist/application/query/legacy/v6/kernel.d.ts +6 -0
- package/dist/application/query/legacy/v6/kernel.js +5 -0
- package/dist/application/query/{single → legacy/v6/single}/pagination.js +1 -1
- package/dist/application/query/{single → legacy/v6/single}/query.d.ts +2 -14
- package/dist/application/query/legacy/v6/single/query.js +1 -0
- package/dist/application/query/query.d.ts +19 -4
- package/dist/application/routes/admission.d.ts +3 -3
- package/dist/application/routes/admission.js +3 -3
- package/dist/application/routes/index.d.ts +3 -2
- package/dist/application/routes/route.d.ts +3 -3
- package/dist/application/runtime/actions.js +3 -0
- package/dist/application/runtime/declarations.d.ts +6 -6
- package/dist/application/runtime/define.d.ts +5 -5
- package/dist/application/runtime/workflows.d.ts +3 -1
- package/dist/application/runtime/workflows.js +3 -4
- package/dist/application/view/define.js +4 -6
- package/dist/application/view/frontend.d.ts +2 -2
- package/dist/application/view/index.d.ts +1 -1
- package/dist/application/view/route.d.ts +0 -14
- package/dist/application/view/route.js +1 -64
- package/dist/application/workflow/authoring.d.ts +3 -2
- package/dist/application/workflow/context.d.ts +8 -2
- package/dist/application/workflow/define.d.ts +4 -4
- package/dist/application/workflow/define.js +14 -9
- package/dist/application/workflow/durable.d.ts +211 -0
- package/dist/application/workflow/durable.js +1 -0
- package/dist/application/workflow/index.d.ts +3 -2
- package/dist/application/workflow/runner/inline.js +3 -4
- package/dist/application/workflow/runner/runner.d.ts +2 -2
- package/dist/application/workflow/step/output.d.ts +2 -0
- package/dist/application/workflow/step/output.js +73 -0
- package/dist/application/workflow/workflow.d.ts +5 -3
- package/dist/deployment/adapter/adapter.d.ts +55 -13
- package/dist/deployment/adapter/bundle/bundle.d.ts +36 -0
- package/dist/deployment/adapter/bundle/bundle.js +1 -0
- package/dist/deployment/adapter/bundle/file.d.ts +10 -0
- package/dist/deployment/adapter/bundle/file.js +1 -0
- package/dist/deployment/adapter/bundle/index.d.ts +2 -0
- package/dist/deployment/adapter/bundle/index.js +1 -0
- package/dist/deployment/adapter/define.d.ts +4 -3
- package/dist/deployment/adapter/define.js +107 -23
- package/dist/deployment/adapter/index.d.ts +4 -3
- package/dist/deployment/adapter/index.js +1 -0
- package/dist/deployment/adapter/release/command.d.ts +33 -0
- package/dist/deployment/adapter/release/command.js +1 -0
- package/dist/deployment/adapter/release/context.d.ts +94 -0
- package/dist/deployment/adapter/release/context.js +1 -0
- package/dist/deployment/adapter/release/index.d.ts +4 -0
- package/dist/deployment/adapter/release/index.js +1 -0
- package/dist/deployment/adapter/release/list.d.ts +53 -0
- package/dist/deployment/adapter/release/list.js +1 -0
- package/dist/deployment/adapter/release/refusal.d.ts +10 -0
- package/dist/deployment/adapter/release/refusal.js +14 -0
- package/dist/deployment/adapter/release/result.d.ts +56 -0
- package/dist/deployment/adapter/release/result.js +1 -0
- package/dist/deployment/address/configuration.d.ts +96 -0
- package/dist/deployment/address/configuration.js +274 -0
- package/dist/deployment/address/fingerprint.d.ts +5 -0
- package/dist/deployment/address/fingerprint.js +27 -0
- package/dist/deployment/address/index.d.ts +5 -0
- package/dist/deployment/address/index.js +4 -0
- package/dist/deployment/address/label.d.ts +42 -0
- package/dist/deployment/address/label.js +80 -0
- package/dist/deployment/address/line.d.ts +29 -0
- package/dist/deployment/address/line.js +53 -0
- package/dist/deployment/address/record.d.ts +73 -0
- package/dist/deployment/address/record.js +138 -0
- package/dist/deployment/address/summary.d.ts +30 -0
- package/dist/deployment/address/summary.js +1 -0
- package/dist/deployment/address/vectors.d.ts +60 -0
- package/dist/deployment/address/vectors.js +517 -0
- package/dist/deployment/authoring.d.ts +0 -2
- package/dist/deployment/authoring.js +0 -1
- package/dist/deployment/build/build.d.ts +15 -2
- package/dist/deployment/build/compile.d.ts +4 -4
- package/dist/deployment/build/compile.js +19 -17
- package/dist/deployment/build/frontend/compilation.d.ts +2 -4
- package/dist/deployment/build/frontend/compilation.js +0 -5
- package/dist/deployment/build/frontend/digest.js +1 -5
- package/dist/deployment/build/index.d.ts +1 -0
- package/dist/deployment/build/index.js +1 -0
- package/dist/deployment/build/manifest.d.ts +59 -0
- package/dist/deployment/build/manifest.js +118 -0
- package/dist/deployment/build/material.d.ts +2 -2
- package/dist/deployment/build/material.js +31 -13
- package/dist/deployment/build/schema.d.ts +2 -2
- package/dist/deployment/deployment.d.ts +3 -2
- package/dist/deployment/environment.d.ts +6 -0
- package/dist/deployment/environment.js +6 -0
- package/dist/deployment/index.d.ts +4 -6
- package/dist/deployment/index.js +1 -2
- package/dist/deployment/release/addressing.d.ts +6 -5
- package/dist/deployment/release/addressing.js +2 -3
- package/dist/deployment/release/assemble.d.ts +6 -3
- package/dist/deployment/release/assemble.js +12 -10
- package/dist/deployment/release/release.d.ts +16 -5
- package/dist/deployment/release/seal.d.ts +14 -0
- package/dist/deployment/release/seal.js +22 -0
- package/dist/deployment/release/{publication → served}/callables.d.ts +2 -2
- package/dist/deployment/release/{publication → served}/callables.js +2 -2
- package/dist/deployment/release/served/index.d.ts +11 -0
- package/dist/deployment/release/served/index.js +26 -0
- package/dist/deployment/release/{publication → served}/views.d.ts +2 -2
- package/dist/deployment/release/{publication → served}/views.js +0 -1
- package/dist/deployment/runtime/admission.d.ts +2 -2
- package/dist/deployment/runtime/admission.js +5 -5
- package/dist/deployment/verify/index.d.ts +3 -4
- package/dist/deployment/verify/index.js +2 -3
- package/dist/deployment/verify/preflight/bundle.d.ts +18 -0
- package/dist/deployment/verify/preflight/bundle.js +71 -0
- package/dist/deployment/verify/preflight/index.d.ts +1 -12
- package/dist/deployment/verify/preflight/index.js +1 -12
- package/dist/deployment/verify/readiness/fetch.d.ts +13 -0
- package/dist/deployment/verify/readiness/fetch.js +26 -0
- package/dist/deployment/verify/readiness/identity.d.ts +3 -6
- package/dist/deployment/verify/readiness/identity.js +3 -3
- package/dist/deployment/verify/readiness/index.d.ts +15 -8
- package/dist/deployment/verify/readiness/index.js +25 -6
- package/dist/deployment/verify/readiness/release.d.ts +8 -0
- package/dist/deployment/verify/readiness/release.js +22 -0
- package/dist/deployment/worker/address.d.ts +26 -0
- package/dist/deployment/worker/address.js +43 -0
- package/dist/deployment/worker/build.d.ts +60 -0
- package/dist/deployment/worker/build.js +172 -0
- package/dist/deployment/worker/configuration.d.ts +73 -0
- package/dist/deployment/worker/configuration.js +165 -0
- package/dist/deployment/worker/content.d.ts +38 -0
- package/dist/deployment/worker/content.js +169 -0
- package/dist/deployment/worker/index.d.ts +29 -0
- package/dist/deployment/worker/index.js +29 -0
- package/dist/deployment/worker/limits.d.ts +30 -0
- package/dist/deployment/worker/limits.js +30 -0
- package/dist/deployment/worker/record.d.ts +29 -0
- package/dist/deployment/worker/record.js +69 -0
- package/dist/deployment/worker/request.d.ts +118 -0
- package/dist/deployment/worker/request.js +280 -0
- package/dist/deployment/worker/response.d.ts +101 -0
- package/dist/deployment/worker/response.js +207 -0
- package/dist/execution/cache/cache.d.ts +17 -0
- package/dist/execution/cache/cache.js +11 -0
- package/dist/execution/cache/index.d.ts +2 -0
- package/dist/execution/cache/index.js +2 -0
- package/dist/execution/cache/memory.d.ts +13 -0
- package/dist/execution/cache/memory.js +48 -0
- package/dist/execution/identity/authentication.d.ts +33 -3
- package/dist/execution/identity/authentication.js +90 -36
- package/dist/execution/identity/callback.d.ts +20 -20
- package/dist/execution/identity/callback.js +34 -26
- package/dist/execution/identity/delivery.d.ts +6 -4
- package/dist/execution/identity/delivery.js +25 -20
- package/dist/execution/identity/identity.d.ts +17 -3
- package/dist/execution/identity/identity.js +12 -4
- package/dist/execution/identity/jwks.d.ts +5 -0
- package/dist/execution/identity/jwks.js +92 -102
- package/dist/execution/index.d.ts +6 -4
- package/dist/execution/index.js +4 -2
- package/dist/execution/invocation/admission/age.d.ts +57 -0
- package/dist/execution/invocation/admission/age.js +208 -0
- package/dist/execution/invocation/admission/authentication.d.ts +13 -13
- package/dist/execution/invocation/admission/authentication.js +52 -44
- package/dist/execution/invocation/admission/authority.d.ts +28 -6
- package/dist/execution/invocation/admission/authority.js +9 -2
- package/dist/execution/invocation/admission/index.d.ts +4 -3
- package/dist/execution/invocation/admission/index.js +3 -2
- package/dist/execution/invocation/admission/input.d.ts +2 -2
- package/dist/execution/invocation/admission/input.js +16 -2
- package/dist/execution/invocation/admission/target.d.ts +11 -0
- package/dist/execution/invocation/admission/target.js +22 -3
- package/dist/execution/invocation/capabilities/bind.d.ts +14 -0
- package/dist/execution/invocation/capabilities/bind.js +74 -0
- package/dist/execution/invocation/capabilities/index.d.ts +1 -0
- package/dist/execution/invocation/capabilities/index.js +1 -0
- package/dist/execution/invocation/dependency/bind.d.ts +3 -1
- package/dist/execution/invocation/dependency/bind.js +36 -16
- package/dist/execution/invocation/dispatch/action.js +4 -2
- package/dist/execution/invocation/dispatch/context.d.ts +7 -6
- package/dist/execution/invocation/dispatch/context.js +11 -44
- package/dist/execution/invocation/dispatch/workflow.js +4 -6
- package/dist/execution/invocation/handler.js +8 -2
- package/dist/execution/invocation/index.d.ts +2 -2
- package/dist/execution/invocation/index.js +1 -1
- package/dist/execution/invocation/integration/authentication.d.ts +3 -3
- package/dist/execution/invocation/integration/authentication.js +7 -7
- package/dist/execution/invocation/integration/call.d.ts +2 -1
- package/dist/execution/invocation/integration/call.js +3 -3
- package/dist/execution/invocation/integration/clients.d.ts +1 -1
- package/dist/execution/invocation/integration/index.d.ts +1 -0
- package/dist/execution/invocation/integration/index.js +1 -0
- package/dist/execution/invocation/invocation.d.ts +6 -0
- package/dist/execution/invocation/invocation.js +129 -21
- package/dist/execution/invocation/lifecycle/active.d.ts +8 -2
- package/dist/execution/invocation/lifecycle/active.js +3 -3
- package/dist/execution/invocation/lifecycle/index.d.ts +1 -1
- package/dist/execution/invocation/result/errors.d.ts +0 -10
- package/dist/execution/invocation/result/errors.js +4 -16
- package/dist/execution/invocation/result/index.d.ts +3 -2
- package/dist/execution/invocation/result/index.js +2 -1
- package/dist/execution/invocation/result/project.js +41 -1
- package/dist/execution/invocation/result/undeclared.d.ts +7 -0
- package/dist/execution/invocation/result/undeclared.js +18 -0
- package/dist/execution/node/serve.d.ts +2 -2
- package/dist/execution/node/serve.js +1 -1
- package/dist/execution/runtime/index.d.ts +1 -0
- package/dist/execution/runtime/index.js +1 -0
- package/dist/execution/runtime/load.d.ts +3 -3
- package/dist/execution/runtime/load.js +3 -2
- package/dist/execution/runtime/release.d.ts +17 -0
- package/dist/execution/runtime/release.js +7 -0
- package/dist/execution/serve.d.ts +18 -4
- package/dist/execution/serve.js +10 -0
- package/dist/execution/service/create.js +43 -7
- package/dist/execution/service/initialization.d.ts +4 -4
- package/dist/execution/service/initialization.js +23 -14
- package/dist/execution/service/release.d.ts +2 -2
- package/dist/execution/service/release.js +3 -2
- package/dist/execution/service/service.d.ts +20 -5
- package/dist/execution/service/serving/delivery.d.ts +5 -0
- package/dist/execution/service/{publication → serving}/delivery.js +4 -1
- package/dist/execution/service/{publication → serving}/index.d.ts +1 -1
- package/dist/execution/service/serving/installation.d.ts +4 -0
- package/dist/execution/service/serving/installation.js +9 -0
- package/dist/execution/service/serving/source.d.ts +11 -0
- package/dist/execution/service/serving/source.js +15 -0
- package/dist/execution/workflows/attempts.d.ts +87 -0
- package/dist/execution/workflows/attempts.js +205 -0
- package/dist/execution/workflows/discovery.d.ts +14 -0
- package/dist/execution/workflows/discovery.js +151 -0
- package/dist/execution/workflows/engine.d.ts +83 -0
- package/dist/execution/workflows/engine.js +1 -0
- package/dist/execution/workflows/envelope.d.ts +12 -0
- package/dist/execution/workflows/envelope.js +46 -0
- package/dist/execution/workflows/failure.d.ts +56 -0
- package/dist/execution/workflows/failure.js +204 -0
- package/dist/execution/workflows/index.d.ts +4 -0
- package/dist/execution/workflows/index.js +3 -0
- package/dist/execution/workflows/integrations.d.ts +13 -0
- package/dist/execution/workflows/integrations.js +25 -0
- package/dist/execution/workflows/options.d.ts +81 -0
- package/dist/execution/workflows/options.js +158 -0
- package/dist/execution/workflows/receiver.d.ts +24 -0
- package/dist/execution/workflows/receiver.js +99 -0
- package/dist/execution/workflows/route.d.ts +12 -0
- package/dist/execution/workflows/route.js +35 -0
- package/dist/execution/workflows/run.d.ts +23 -0
- package/dist/execution/workflows/run.js +369 -0
- package/dist/execution/workflows/steps.d.ts +48 -0
- package/dist/execution/workflows/steps.js +93 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/platform/graph/alias.d.ts +1 -5
- package/dist/platform/graph/alias.js +1 -5
- package/dist/platform/graph/document/index.d.ts +1 -1
- package/dist/platform/graph/document/index.js +1 -1
- package/dist/platform/graph/index.d.ts +1 -1
- package/dist/platform/graph/index.js +1 -1
- package/dist/platform/release/index.d.ts +2 -0
- package/dist/platform/release/index.js +2 -0
- package/dist/platform/schema/callable-authoring.d.ts +21 -0
- package/dist/platform/schema/callable-authoring.js +27 -0
- package/dist/platform/schema/class-authoring.d.ts +56 -12
- package/dist/platform/schema/class-authoring.js +37 -4
- package/dist/platform/schema/class-icon-svg.d.ts +9 -0
- package/dist/platform/schema/class-icon-svg.js +29 -0
- package/dist/platform/schema/class-icon.d.ts +3 -8
- package/dist/platform/schema/class-icon.js +2 -29
- package/dist/platform/schema/index.d.ts +6 -4
- package/dist/platform/schema/index.js +2 -1
- package/dist/platform/schema/kernel-compiled.d.ts +2 -0
- package/dist/platform/schema/kernel-compiled.js +2 -0
- package/dist/platform/schema/kernel.d.ts +4 -2
- package/dist/platform/schema/property.d.ts +5 -0
- package/dist/platform/schema/schema-authoring.d.ts +14 -7
- package/dist/platform/schema/schema-authoring.js +5 -1
- package/dist/platform/versioning/dependents.d.ts +18 -0
- package/dist/platform/versioning/dependents.js +15 -0
- package/dist/platform/versioning/index.d.ts +5 -0
- package/dist/platform/versioning/index.js +5 -0
- package/dist/platform/versioning/name.d.ts +38 -0
- package/dist/platform/versioning/name.js +58 -0
- package/dist/platform/versioning/reference.d.ts +48 -0
- package/dist/platform/versioning/reference.js +95 -0
- package/dist/platform/versioning/version.d.ts +72 -0
- package/dist/platform/versioning/version.js +98 -0
- package/dist/project/admit.js +1 -5
- package/dist/project/define.d.ts +4 -4
- package/dist/project/define.js +55 -35
- package/dist/project/index.d.ts +1 -1
- package/dist/project/install-command.d.ts +6 -0
- package/dist/project/install-command.js +9 -0
- package/dist/project/project.d.ts +10 -8
- package/dist/testing/dataset/define.d.ts +1 -1
- package/dist/testing/durable/engine.d.ts +128 -0
- package/dist/testing/durable/engine.js +619 -0
- package/dist/testing/durable/index.d.ts +3 -0
- package/dist/testing/durable/index.js +1 -0
- package/dist/testing/durable/steps.d.ts +30 -0
- package/dist/testing/durable/steps.js +45 -0
- package/dist/testing/index.d.ts +8 -1
- package/dist/testing/index.js +6 -1
- package/dist/testing/load.js +1 -1
- package/dist/testing/query.d.ts +22 -0
- package/dist/testing/query.js +35 -0
- package/dist/tooling/cli/adapter-command.d.ts +35 -0
- package/dist/tooling/cli/adapter-command.js +66 -0
- package/dist/tooling/cli/arguments.d.ts +17 -6
- package/dist/tooling/cli/arguments.js +175 -52
- package/dist/tooling/cli/build.d.ts +55 -0
- package/dist/tooling/cli/build.js +77 -0
- package/dist/tooling/cli/bun.d.ts +0 -1
- package/dist/tooling/cli/bun.js +0 -7
- package/dist/tooling/cli/commit.d.ts +35 -0
- package/dist/tooling/cli/commit.js +235 -0
- package/dist/tooling/cli/deploy-mode.d.ts +26 -0
- package/dist/tooling/cli/deploy-mode.js +59 -0
- package/dist/tooling/cli/deploy-result.d.ts +80 -0
- package/dist/tooling/cli/deploy-result.js +64 -0
- package/dist/tooling/cli/diff/declared.d.ts +7 -0
- package/dist/tooling/cli/diff/declared.js +27 -0
- package/dist/tooling/cli/diff/index.d.ts +30 -0
- package/dist/tooling/cli/diff/index.js +58 -0
- package/dist/tooling/cli/diff/render.d.ts +15 -0
- package/dist/tooling/cli/diff/render.js +131 -0
- package/dist/tooling/cli/diff/report.d.ts +88 -0
- package/dist/tooling/cli/diff/report.js +154 -0
- package/dist/tooling/cli/dotenv.d.ts +5 -5
- package/dist/tooling/cli/dotenv.js +6 -36
- package/dist/tooling/cli/help.js +173 -60
- package/dist/tooling/cli/immutable-deployment.d.ts +83 -0
- package/dist/tooling/cli/immutable-deployment.js +135 -0
- package/dist/tooling/cli/index.d.ts +12 -4
- package/dist/tooling/cli/index.js +6 -3
- package/dist/tooling/cli/installed-on.d.ts +83 -0
- package/dist/tooling/cli/installed-on.js +156 -0
- package/dist/tooling/cli/list.d.ts +152 -0
- package/dist/tooling/cli/list.js +331 -0
- package/dist/tooling/cli/log.d.ts +5 -2
- package/dist/tooling/cli/log.js +9 -2
- package/dist/tooling/cli/orchestrate.d.ts +0 -6
- package/dist/tooling/cli/orchestrate.js +252 -91
- package/dist/tooling/cli/project.d.ts +3 -3
- package/dist/tooling/cli/publish/index.d.ts +81 -0
- package/dist/tooling/cli/publish/index.js +383 -0
- package/dist/tooling/cli/publish/report.d.ts +49 -0
- package/dist/tooling/cli/publish/report.js +15 -0
- package/dist/tooling/cli/registry/client.d.ts +121 -0
- package/dist/tooling/cli/registry/client.js +354 -0
- package/dist/tooling/cli/registry/error.d.ts +11 -0
- package/dist/tooling/cli/registry/error.js +17 -0
- package/dist/tooling/cli/registry/executable.d.ts +35 -0
- package/dist/tooling/cli/registry/executable.js +96 -0
- package/dist/tooling/cli/registry/index.d.ts +9 -0
- package/dist/tooling/cli/registry/index.js +8 -0
- package/dist/tooling/cli/registry/installations.d.ts +67 -0
- package/dist/tooling/cli/registry/installations.js +108 -0
- package/dist/tooling/cli/registry/process.d.ts +36 -0
- package/dist/tooling/cli/registry/process.js +119 -0
- package/dist/tooling/cli/secrets.d.ts +9 -0
- package/dist/tooling/cli/secrets.js +19 -0
- package/dist/tooling/cli/yank.d.ts +34 -0
- package/dist/tooling/cli/yank.js +32 -0
- package/dist/tooling/linter/adapters/typescript/definition-calls.d.ts +34 -0
- package/dist/tooling/linter/adapters/typescript/definition-calls.js +88 -0
- package/dist/tooling/linter/adapters/typescript/imports.d.ts +0 -1
- package/dist/tooling/linter/adapters/typescript/imports.js +1 -5
- package/dist/tooling/linter/adapters/typescript/index.d.ts +3 -2
- package/dist/tooling/linter/adapters/typescript/index.js +3 -2
- package/dist/tooling/linter/adapters/typescript/query-observation.js +37 -12
- package/dist/tooling/linter/adapters/typescript/syntax.d.ts +3 -3
- package/dist/tooling/linter/adapters/typescript/syntax.js +13 -25
- package/dist/tooling/linter/adapters/typescript/type-analysis.d.ts +2 -0
- package/dist/tooling/linter/adapters/typescript/type-analysis.js +10 -0
- package/dist/tooling/linter/implementations/source/callable-requirements.d.ts +1 -2
- package/dist/tooling/linter/implementations/source/callable-requirements.js +11 -16
- package/dist/tooling/linter/implementations/source/definitions.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/definitions.js +425 -0
- package/dist/tooling/linter/implementations/source/dependencies.js +13 -72
- package/dist/tooling/linter/implementations/source/global.js +18 -11
- package/dist/tooling/linter/implementations/source/mutations.js +146 -48
- package/dist/tooling/linter/implementations/source/policy-edges.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/policy-edges.js +113 -0
- package/dist/tooling/linter/implementations/source/providers.js +5 -5
- package/dist/tooling/linter/implementations/source/queries.js +1 -17
- package/dist/tooling/linter/implementations/source/shared.d.ts +19 -5
- package/dist/tooling/linter/implementations/source/shared.js +131 -55
- package/dist/tooling/linter/implementations/source/verifiers.js +4 -2
- package/dist/tooling/linter/implementations/source/views.js +2 -2
- package/dist/tooling/linter/implementations/source/workflows.js +499 -17
- package/dist/tooling/linter/policy/generated.js +15 -64
- package/dist/tooling/linter/requirements/registry.js +11 -9
- package/dist/tooling/packaging/declarations/ownership.js +1 -1
- package/dist/tooling/packaging/finalize.d.ts +1 -1
- package/dist/tooling/packaging/finalize.js +1 -1
- package/docs/admission-age.md +88 -0
- package/docs/auth-api-migration.md +55 -0
- package/docs/business-errors.md +42 -0
- package/docs/domain-definition-migration.md +44 -0
- package/docs/domain-schema-migration.md +36 -0
- package/docs/durable-workflows.md +473 -0
- package/docs/handler-dependencies.md +285 -0
- package/docs/legacy/query-v6.md +62 -0
- package/docs/queries.md +492 -0
- package/docs/release.md +155 -0
- package/docs/schema-cost.md +124 -0
- package/package.json +53 -21
- package/dist/application/application.d.ts +0 -28
- package/dist/application/query/execution/projection.d.ts +0 -3
- package/dist/application/query/execution/projection.js +0 -3
- package/dist/deployment/adapter/deploy/context.d.ts +0 -15
- package/dist/deployment/adapter/deploy/index.d.ts +0 -2
- package/dist/deployment/adapter/deploy/result.d.ts +0 -50
- package/dist/deployment/adapter/prepare/artifact.d.ts +0 -33
- package/dist/deployment/adapter/prepare/context.d.ts +0 -23
- package/dist/deployment/adapter/prepare/index.d.ts +0 -2
- package/dist/deployment/deploy.d.ts +0 -20
- package/dist/deployment/deploy.js +0 -31
- package/dist/deployment/release/publication/index.d.ts +0 -6
- package/dist/deployment/release/publication/index.js +0 -6
- package/dist/deployment/release/publication/manifest.d.ts +0 -3
- package/dist/deployment/release/publication/manifest.js +0 -5
- package/dist/deployment/release/publication/requirements.d.ts +0 -3
- package/dist/deployment/release/publication/requirements.js +0 -3
- package/dist/deployment/release/publication/seal.d.ts +0 -10
- package/dist/deployment/release/publication/seal.js +0 -39
- package/dist/deployment/verify/preflight/artifact.d.ts +0 -6
- package/dist/deployment/verify/preflight/artifact.js +0 -122
- package/dist/deployment/verify/preflight/publication.d.ts +0 -4
- package/dist/deployment/verify/preflight/publication.js +0 -14
- package/dist/deployment/verify/readiness/deployment.d.ts +0 -3
- package/dist/deployment/verify/readiness/deployment.js +0 -151
- package/dist/deployment/verify/readiness/publication.d.ts +0 -11
- package/dist/deployment/verify/readiness/publication.js +0 -41
- package/dist/execution/service/errors.d.ts +0 -3
- package/dist/execution/service/errors.js +0 -3
- package/dist/execution/service/publication/delivery.d.ts +0 -2
- package/dist/execution/service/publication/installation.d.ts +0 -3
- package/dist/execution/service/publication/installation.js +0 -8
- package/dist/execution/service/publication/source.d.ts +0 -3
- package/dist/execution/service/publication/source.js +0 -11
- package/dist/platform/publication/index.d.ts +0 -2
- package/dist/platform/publication/index.js +0 -2
- package/dist/tooling/cli/astrale/authority.d.ts +0 -5
- package/dist/tooling/cli/astrale/authority.js +0 -11
- package/dist/tooling/cli/astrale/executable.d.ts +0 -2
- package/dist/tooling/cli/astrale/executable.js +0 -47
- package/dist/tooling/cli/astrale/failure.d.ts +0 -6
- package/dist/tooling/cli/astrale/failure.js +0 -48
- package/dist/tooling/cli/astrale/instance.d.ts +0 -11
- package/dist/tooling/cli/astrale/instance.js +0 -52
- package/dist/tooling/cli/astrale/process.d.ts +0 -13
- package/dist/tooling/cli/astrale/process.js +0 -94
- package/dist/tooling/cli/astrale/version.d.ts +0 -18
- package/dist/tooling/cli/astrale/version.js +0 -55
- package/dist/tooling/cli/credential.d.ts +0 -2
- package/dist/tooling/cli/credential.js +0 -57
- package/dist/tooling/cli/deprecations.d.ts +0 -9
- package/dist/tooling/cli/deprecations.js +0 -15
- package/dist/tooling/cli/development/candidate.d.ts +0 -25
- package/dist/tooling/cli/development/candidate.js +0 -176
- package/dist/tooling/cli/development/deployment.d.ts +0 -16
- package/dist/tooling/cli/development/deployment.js +0 -39
- package/dist/tooling/cli/development/develop.d.ts +0 -11
- package/dist/tooling/cli/development/develop.js +0 -243
- package/dist/tooling/cli/development/lease.d.ts +0 -18
- package/dist/tooling/cli/development/lease.js +0 -163
- package/dist/tooling/cli/development/lifecycle.d.ts +0 -9
- package/dist/tooling/cli/development/lifecycle.js +0 -43
- package/dist/tooling/cli/development/project-imports.d.ts +0 -22
- package/dist/tooling/cli/development/project-imports.js +0 -39
- package/dist/tooling/cli/development/project-lock.d.ts +0 -16
- package/dist/tooling/cli/development/project-lock.js +0 -41
- package/dist/tooling/cli/development/rebuild.d.ts +0 -13
- package/dist/tooling/cli/development/rebuild.js +0 -58
- package/dist/tooling/cli/development/release-evidence.d.ts +0 -4
- package/dist/tooling/cli/development/release-evidence.js +0 -10
- package/dist/tooling/cli/development/report.d.ts +0 -6
- package/dist/tooling/cli/development/report.js +0 -14
- package/dist/tooling/cli/development/session-file.d.ts +0 -53
- package/dist/tooling/cli/development/session-file.js +0 -337
- package/dist/tooling/cli/development/source-watch.d.ts +0 -14
- package/dist/tooling/cli/development/source-watch.js +0 -140
- package/dist/tooling/cli/development/sources.d.ts +0 -7
- package/dist/tooling/cli/development/sources.js +0 -48
- package/dist/tooling/cli/development/target-lock.d.ts +0 -16
- package/dist/tooling/cli/development/target-lock.js +0 -68
- package/dist/tooling/cli/development/view.d.ts +0 -28
- package/dist/tooling/cli/development/view.js +0 -151
- package/dist/tooling/cli/environment-release.d.ts +0 -21
- package/dist/tooling/cli/environment-release.js +0 -46
- package/dist/tooling/cli/evidence.d.ts +0 -11
- package/dist/tooling/cli/evidence.js +0 -53
- package/dist/tooling/cli/installation/index.d.ts +0 -2
- package/dist/tooling/cli/installation/index.js +0 -1
- package/dist/tooling/cli/installation/observation.d.ts +0 -10
- package/dist/tooling/cli/installation/observation.js +0 -44
- package/dist/tooling/cli/installation/reconcile.d.ts +0 -32
- package/dist/tooling/cli/installation/reconcile.js +0 -122
- package/dist/tooling/linter/implementations/source/migrations.d.ts +0 -2
- package/dist/tooling/linter/implementations/source/migrations.js +0 -113
- package/dist/tooling/linter/qualification/index.d.ts +0 -10
- package/dist/tooling/linter/qualification/index.js +0 -2
- package/dist/tooling/linter/qualification/query-fixtures.d.ts +0 -2
- package/dist/tooling/linter/qualification/query-fixtures.js +0 -68
- package/dist/tooling/linter/qualification/runner.d.ts +0 -3
- package/dist/tooling/linter/qualification/runner.js +0 -6
- /package/dist/application/{application.js → domain.js} +0 -0
- /package/dist/application/{query/single/query.js → mutation/legacy/v6/builder.js} +0 -0
- /package/dist/{deployment/adapter/deploy/context.js → application/mutation/legacy/v6/mutation.js} +0 -0
- /package/dist/application/mutation/{authoring → legacy/v6}/precondition.js +0 -0
- /package/dist/{deployment/adapter/deploy/index.js → application/query/answer/answer.js} +0 -0
- /package/dist/{deployment/adapter/deploy/result.js → application/query/defined/query.js} +0 -0
- /package/dist/{deployment/adapter/prepare/artifact.js → application/query/execution/client.js} +0 -0
- /package/dist/{deployment/adapter/prepare/context.js → application/query/handles/conditions.js} +0 -0
- /package/dist/{deployment/adapter/prepare/index.js → application/query/handles/domain.js} +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/identity.js +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/limits.d.ts +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/limits.js +0 -0
- /package/dist/application/query/{collection → legacy/v6/collection}/metadata.js +0 -0
- /package/dist/application/query/{execution → legacy/v6/execution}/pages.d.ts +0 -0
- /package/dist/application/query/{execution → legacy/v6/execution}/pages.js +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/index.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/index.js +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/node.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/node.js +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/pagination.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/selection.d.ts +0 -0
- /package/dist/application/query/{single → legacy/v6/single}/selection.js +0 -0
- /package/dist/deployment/release/{publication → served}/routes.d.ts +0 -0
- /package/dist/deployment/release/{publication → served}/routes.js +0 -0
- /package/dist/execution/service/{publication → serving}/index.js +0 -0
|
@@ -1,56 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const mutation = Object.freeze({ kind: 'mutation' });
|
|
10
|
-
projectors.set(mutation, project);
|
|
11
|
-
return mutation;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
export function realizeMutation(mutation, domain) {
|
|
15
|
-
const project = projectors.get(mutation);
|
|
16
|
-
if (project === undefined)
|
|
17
|
-
throw new TypeError('Mutation must be produced by defineMutation.');
|
|
18
|
-
if (!isDomain(domain))
|
|
19
|
-
throw new TypeError('Mutation projection requires an admitted Domain.');
|
|
20
|
-
let byDomain = realized.get(mutation);
|
|
21
|
-
const cached = byDomain?.get(domain);
|
|
22
|
-
if (cached !== undefined)
|
|
23
|
-
return cached;
|
|
24
|
-
const authored = project(domain);
|
|
25
|
-
if (isPromiseLike(authored))
|
|
26
|
-
throw new TypeError('Mutation projection must be synchronous.');
|
|
27
|
-
const admitted = admitMutation(authored);
|
|
28
|
-
if (byDomain === undefined) {
|
|
29
|
-
byDomain = new WeakMap();
|
|
30
|
-
realized.set(mutation, byDomain);
|
|
31
|
-
}
|
|
32
|
-
byDomain.set(domain, admitted);
|
|
33
|
-
return admitted;
|
|
1
|
+
import { collectDefinition, MAXIMUM_DEFINITION_ID, DEFINITION_ID } from '../query/defined/define.js';
|
|
2
|
+
import { describe } from '../query/handles/terms.js';
|
|
3
|
+
import { defineMutation as defineClosureMutation } from './legacy/v6/define.js';
|
|
4
|
+
const FIELDS = new Set(['build', 'output', 'reject', 'errors']);
|
|
5
|
+
const specs = new WeakMap();
|
|
6
|
+
/** The `build`, `output` and `reject` of a defined Mutation; `undefined` for anything else. */
|
|
7
|
+
export function mutationSpecOf(mutation) {
|
|
8
|
+
return typeof mutation === 'object' && mutation !== null ? specs.get(mutation) : undefined;
|
|
34
9
|
}
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
if (typeof
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
10
|
+
function defineV7Mutation(id, spec) {
|
|
11
|
+
if (typeof id !== 'string' || id.length > MAXIMUM_DEFINITION_ID || !DEFINITION_ID.test(id))
|
|
12
|
+
throw new TypeError(`A Mutation id is lowercase segments of letters, digits and hyphens joined by dots, at most ${MAXIMUM_DEFINITION_ID} characters ('issues.issue.open'); got ${describe(id)}.`);
|
|
13
|
+
if (typeof spec !== 'object' || spec === null || Array.isArray(spec))
|
|
14
|
+
throw new TypeError(`Mutation ${id} takes { build, output?, reject?, errors? }; got ${describe(spec)}.`);
|
|
15
|
+
const fields = spec;
|
|
16
|
+
const unknown = Reflect.ownKeys(fields).filter((key) => typeof key !== 'string' || !FIELDS.has(key));
|
|
17
|
+
if (unknown.length > 0)
|
|
18
|
+
throw new TypeError(`Mutation ${id} takes build, output, reject and errors only; got ${unknown.map(String).join(', ')}.`);
|
|
19
|
+
const { build, output, reject } = fields;
|
|
20
|
+
if (typeof build !== 'function')
|
|
21
|
+
throw new TypeError(`Mutation ${id}'s build is a function of (input, d, mutation); got ${describe(build)}.`);
|
|
22
|
+
if (output !== undefined && typeof output !== 'function')
|
|
23
|
+
throw new TypeError(`Mutation ${id}'s output is a function of (result, input); got ${describe(output)}.`);
|
|
24
|
+
if (reject !== undefined && typeof reject !== 'function')
|
|
25
|
+
throw new TypeError(`Mutation ${id}'s reject is a function of (failure, input, context); got ${describe(reject)}.`);
|
|
26
|
+
const errors = fields.errors ?? {};
|
|
27
|
+
if (typeof errors !== 'object' || errors === null || Array.isArray(errors))
|
|
28
|
+
throw new TypeError(`Mutation ${id}'s errors is a record of declared errors by UPPER_SNAKE code; got ${describe(errors)}.`);
|
|
29
|
+
const mutation = Object.freeze({
|
|
30
|
+
kind: 'mutation',
|
|
31
|
+
id,
|
|
32
|
+
errors: Object.freeze({ ...errors }),
|
|
33
|
+
});
|
|
34
|
+
collectDefinition(mutation);
|
|
35
|
+
specs.set(mutation, Object.freeze({
|
|
36
|
+
build: build,
|
|
37
|
+
...(output === undefined ? {} : { output: output }),
|
|
38
|
+
...(reject === undefined ? {} : { reject: reject }),
|
|
39
|
+
}));
|
|
40
|
+
return mutation;
|
|
51
41
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Define a Mutation: `defineMutation<Schema>()('issues.issue.open', { build, output?, reject?,
|
|
44
|
+
* errors? })`. The closure form, `defineMutation<Schema>()((domain) => ({ id, build, project? }))`,
|
|
45
|
+
* stays, deprecated.
|
|
46
|
+
*/
|
|
47
|
+
export function defineMutation() {
|
|
48
|
+
const closure = defineClosureMutation();
|
|
49
|
+
return ((first, spec) => typeof first === 'string'
|
|
50
|
+
? defineV7Mutation(first, spec)
|
|
51
|
+
: closure(first));
|
|
56
52
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type MutationAST as MutationASTValue, type MutationResult } from '@astrale-os/kernel-core/graph/mutate';
|
|
2
2
|
import type { GraphMutationOptions } from '../../../platform/client/index.js';
|
|
3
3
|
import type { Domain } from '../../../platform/schema/index.js';
|
|
4
|
-
import type { Mutation } from '../mutation.js';
|
|
4
|
+
import type { Mutation, DefinedMutation } from '../mutation.js';
|
|
5
5
|
/** Exact caller-scoped canonical document capability required by Mutation execution. */
|
|
6
6
|
export type MutationClient = Readonly<{
|
|
7
7
|
mutate(ast: MutationASTValue, options?: GraphMutationOptions): Promise<MutationResult>;
|
|
8
8
|
}>;
|
|
9
|
-
export declare function executeMutation<DomainValue extends Domain, Input, Output>(client: MutationClient, domain: DomainValue, definition: Mutation<DomainValue, Input, Output>, input: Input): Promise<Output>;
|
|
9
|
+
export declare function executeMutation<DomainValue extends Domain, Input, Output>(client: MutationClient, domain: DomainValue, definition: Mutation<DomainValue, Input, Output> | DefinedMutation<string, Input, Output>, input: Input): Promise<Output>;
|
|
@@ -1,21 +1,92 @@
|
|
|
1
1
|
import { MutationAST, } from '@astrale-os/kernel-core/graph/mutate';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { outputContext } from '../../query/execution/run.js';
|
|
3
|
+
import { handlesOf } from '../../query/handles/build.js';
|
|
4
|
+
import { modelOf } from '../../query/handles/model.js';
|
|
5
|
+
import { preconditionNames, richMutationBuilder } from '../authoring/index.js';
|
|
6
|
+
import { mutationSpecOf } from '../define.js';
|
|
4
7
|
import { mutationFailure } from '../failure.js';
|
|
8
|
+
import { realizeMutation } from '../legacy/v6/define.js';
|
|
5
9
|
import { projectMutation } from './projection.js';
|
|
6
10
|
export async function executeMutation(client, domain, definition, input) {
|
|
7
11
|
if (client === null || typeof client !== 'object' || typeof client.mutate !== 'function') {
|
|
8
12
|
throw new TypeError('Mutation execution requires a Client mutate capability.');
|
|
9
13
|
}
|
|
10
|
-
const
|
|
14
|
+
const spec = mutationSpecOf(definition);
|
|
15
|
+
const operation = spec === undefined
|
|
16
|
+
? closureOperation(definition, domain)
|
|
17
|
+
: definedOperation(definition, spec, domain);
|
|
18
|
+
const names = preconditionNames();
|
|
19
|
+
let ast;
|
|
11
20
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
// `build` receives the same handles as a Query's `build`, for the Classes it names and the
|
|
22
|
+
// ranges its guards take.
|
|
23
|
+
const d = lazyHandles(domain);
|
|
24
|
+
// What `build` returns reaches the core builder, which refuses a promise or a value.
|
|
25
|
+
ast = MutationAST.build((builder) => operation.build(input, richMutationBuilder(builder, names, operation.form), d));
|
|
26
|
+
return operation.output(await client.mutate(ast), input);
|
|
14
27
|
}
|
|
15
28
|
catch (cause) {
|
|
16
|
-
|
|
29
|
+
// A refusal points at a precondition of the built Mutation by its index.
|
|
30
|
+
const built = ast;
|
|
31
|
+
const expected = mutationFailure(cause, built === undefined ? undefined : (index) => names.at(built, index));
|
|
17
32
|
if (operation.reject !== undefined && expected !== undefined)
|
|
18
|
-
return operation.reject(expected);
|
|
33
|
+
return operation.reject(expected, input);
|
|
19
34
|
throw cause;
|
|
20
35
|
}
|
|
21
36
|
}
|
|
37
|
+
function closureOperation(mutation, domain) {
|
|
38
|
+
const definition = realizeMutation(mutation, domain);
|
|
39
|
+
return {
|
|
40
|
+
form: 'closure',
|
|
41
|
+
build: (input, builder, d) => definition.build(input, builder, d),
|
|
42
|
+
output: (result, input) => projectMutation(definition, result, input),
|
|
43
|
+
...(definition.reject === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { reject: (failure) => definition.reject(failure) }),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function definedOperation(mutation, spec, domain) {
|
|
49
|
+
const { build, output, reject } = spec;
|
|
50
|
+
return {
|
|
51
|
+
form: 'defined',
|
|
52
|
+
build: (input, builder, d) => {
|
|
53
|
+
const written = build(input, d, builder);
|
|
54
|
+
if (isPromiseLike(written)) {
|
|
55
|
+
// Refused before any write is sent: a write after its first await fails, and is observed.
|
|
56
|
+
;
|
|
57
|
+
written.then(undefined, () => undefined);
|
|
58
|
+
throw new TypeError(`Mutation ${mutation.id}'s build is synchronous: it writes the Mutation, and awaits nothing.`);
|
|
59
|
+
}
|
|
60
|
+
return written;
|
|
61
|
+
},
|
|
62
|
+
output: (result, input) => (output === undefined ? result : output(result, input)),
|
|
63
|
+
...(reject === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: {
|
|
66
|
+
reject: (failure, input) => reject(failure, input, outputContext(mutation, modelOf(domain))),
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function isPromiseLike(value) {
|
|
71
|
+
return (value !== null &&
|
|
72
|
+
(typeof value === 'object' || typeof value === 'function') &&
|
|
73
|
+
typeof value.then === 'function');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The Domain's handles, built on first use: a `build` that reads none never loads the Kernel's
|
|
77
|
+
* Classes they include.
|
|
78
|
+
*/
|
|
79
|
+
function lazyHandles(domain) {
|
|
80
|
+
let handles;
|
|
81
|
+
const resolved = () => (handles ??= handlesOf(domain));
|
|
82
|
+
// An extensible, empty target: every trap may then answer from the handles.
|
|
83
|
+
return new Proxy(Object.create(null), {
|
|
84
|
+
get: (_, key) => Reflect.get(resolved(), key),
|
|
85
|
+
has: (_, key) => Reflect.has(resolved(), key),
|
|
86
|
+
ownKeys: () => Reflect.ownKeys(resolved()),
|
|
87
|
+
getOwnPropertyDescriptor: (_, key) => {
|
|
88
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(resolved(), key);
|
|
89
|
+
return descriptor === undefined ? undefined : { ...descriptor, configurable: true };
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Domain, schema } from '../../../platform/schema/index.js';
|
|
2
2
|
import type { Mutation } from '../mutation.js';
|
|
3
3
|
import type { MutationClient } from './execute.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Invocation-bound executor for Mutations of the closure form. A defined Mutation names its
|
|
6
|
+
* authority on each call, `mutate(mutation, input, { as })`, so it is refused here.
|
|
7
|
+
*/
|
|
5
8
|
export interface MutationExecutor<DomainValue extends Domain = Domain> {
|
|
6
9
|
<Input, Output>(definition: Mutation<DomainValue, Input, Output>, input: Input): Promise<Output>;
|
|
7
10
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { mutationSpecOf } from '../define.js';
|
|
1
2
|
import { executeMutation } from './execute.js';
|
|
2
3
|
/** Private Runtime binding to one Client and the exact loaded root Domain. */
|
|
3
4
|
export function bindMutation(client, domain) {
|
|
4
5
|
const executable = domain;
|
|
5
|
-
const execute = (definition, input) =>
|
|
6
|
+
const execute = async (definition, input) => {
|
|
7
|
+
if (mutationSpecOf(definition) !== undefined)
|
|
8
|
+
throw new TypeError(`Mutation ${definition.id} is called with mutate(mutation, input, { as: 'executor' | 'caller' }).`);
|
|
9
|
+
return executeMutation(client, executable, definition, input);
|
|
10
|
+
};
|
|
6
11
|
return execute;
|
|
7
12
|
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export interface KernelMutationFailure extends Error {
|
|
2
2
|
readonly code: `MUTATION_${string}`;
|
|
3
3
|
readonly outcomeKnown: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The post-state rule a `MUTATION_POST_STATE_INVALID` refusal names, such as `duplicate-key`
|
|
6
|
+
* for a value a Class key already holds. Absent when the Kernel names none, and for every other
|
|
7
|
+
* refusal.
|
|
8
|
+
*/
|
|
9
|
+
readonly rule?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The name of the precondition a `MUTATION_PRECONDITION_FAILED` refusal points at: the `name`
|
|
12
|
+
* its `expect.*` verb was given. Absent when that precondition has no name, when the Kernel
|
|
13
|
+
* points at none, and for every other refusal.
|
|
14
|
+
*/
|
|
15
|
+
readonly precondition?: string;
|
|
4
16
|
}
|
|
5
17
|
export interface StateTransitionFailure extends Error {
|
|
6
18
|
readonly code: 'STATE_TRANSITION_ILLEGAL';
|
|
@@ -10,4 +22,8 @@ export interface StateTransitionFailure extends Error {
|
|
|
10
22
|
}
|
|
11
23
|
export type MutationFailure = KernelMutationFailure | StateTransitionFailure;
|
|
12
24
|
export declare function stateTransitionFailure(from: string, event: string): StateTransitionFailure;
|
|
13
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The Mutation refusal `input` carries, if any. `nameAt` names the precondition at an index of
|
|
27
|
+
* the built Mutation's `preconditions`, the index a precondition refusal points at.
|
|
28
|
+
*/
|
|
29
|
+
export declare function mutationFailure(input: unknown, nameAt?: (index: number) => string | undefined): MutationFailure | undefined;
|
|
@@ -10,12 +10,17 @@ export function stateTransitionFailure(from, event) {
|
|
|
10
10
|
localStateTransitionFailures.add(failure);
|
|
11
11
|
return failure;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The Mutation refusal `input` carries, if any. `nameAt` names the precondition at an index of
|
|
15
|
+
* the built Mutation's `preconditions`, the index a precondition refusal points at.
|
|
16
|
+
*/
|
|
17
|
+
export function mutationFailure(input, nameAt) {
|
|
14
18
|
if (!(input instanceof Error))
|
|
15
19
|
return undefined;
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
20
|
+
const reason = mutationReason(input);
|
|
21
|
+
if (reason === undefined)
|
|
18
22
|
return undefined;
|
|
23
|
+
const { code } = reason;
|
|
19
24
|
const explicit = input.outcomeKnown;
|
|
20
25
|
if (explicit !== undefined && typeof explicit !== 'boolean')
|
|
21
26
|
return undefined;
|
|
@@ -28,30 +33,46 @@ export function mutationFailure(input) {
|
|
|
28
33
|
return undefined;
|
|
29
34
|
return input;
|
|
30
35
|
}
|
|
36
|
+
const rule = code === 'MUTATION_POST_STATE_INVALID' ? reason.rule : undefined;
|
|
37
|
+
const precondition = code === 'MUTATION_PRECONDITION_FAILED' && reason.precondition !== undefined
|
|
38
|
+
? nameAt?.(reason.precondition)
|
|
39
|
+
: undefined;
|
|
31
40
|
return Object.assign(new Error(input.message, { cause: input }), {
|
|
32
41
|
code,
|
|
33
42
|
outcomeKnown: explicit !== false && !UNKNOWN_OUTCOME_CODES.has(code),
|
|
43
|
+
...(rule === undefined ? {} : { rule }),
|
|
44
|
+
...(precondition === undefined ? {} : { precondition }),
|
|
34
45
|
});
|
|
35
46
|
}
|
|
36
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The Mutation refusal an error carries, on itself, as its Kernel reason, or as its protocol data:
|
|
49
|
+
* its code and, from the same carrier's details, the post-state rule it names and the index of the
|
|
50
|
+
* precondition it points at.
|
|
51
|
+
*/
|
|
52
|
+
function mutationReason(input) {
|
|
37
53
|
const value = input;
|
|
38
54
|
if (value.code === 'STATE_TRANSITION_ILLEGAL')
|
|
39
|
-
return value.code;
|
|
40
|
-
for (const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
return { code: value.code };
|
|
56
|
+
for (const carrier of [value, value.reason, value.data]) {
|
|
57
|
+
const code = typeof carrier === 'string' ? carrier : field(carrier, 'code');
|
|
58
|
+
if (typeof code !== 'string' || !code.startsWith('MUTATION_'))
|
|
59
|
+
continue;
|
|
60
|
+
const details = field(carrier, 'details');
|
|
61
|
+
const rule = field(details, 'rule');
|
|
62
|
+
const precondition = field(details, 'precondition');
|
|
63
|
+
return {
|
|
64
|
+
code: code,
|
|
65
|
+
...(typeof rule === 'string' ? { rule } : {}),
|
|
66
|
+
...(isIndex(precondition) ? { precondition } : {}),
|
|
67
|
+
};
|
|
48
68
|
}
|
|
49
69
|
return undefined;
|
|
50
70
|
}
|
|
51
|
-
function
|
|
52
|
-
return typeof input === '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
function isIndex(input) {
|
|
72
|
+
return typeof input === 'number' && Number.isSafeInteger(input) && input >= 0;
|
|
73
|
+
}
|
|
74
|
+
function field(input, key) {
|
|
75
|
+
return input !== null && typeof input === 'object' && !Array.isArray(input)
|
|
76
|
+
? Reflect.get(input, key)
|
|
77
|
+
: undefined;
|
|
57
78
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { defineMutation } from './define.js';
|
|
2
2
|
export { executeMutation, type MutationClient, type MutationExecutor } from './execution/index.js';
|
|
3
3
|
export type { MutationFailure } from './failure.js';
|
|
4
|
-
export type { Mutation, MutationDefinition, MutationInputOf, MutationOutputOf } from './mutation.js';
|
|
5
|
-
export type { CreatedNode, EdgeSelector, ExistingEndpoint, MutationEndpoint, QueryPrecondition, RichMutationBuilder, RichPropertyConditions, RichPropertyDelta, RichPropertyInput, RichPropertyName, } from './authoring/index.js';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export type { Mutation, MutationDefinition, MutationInputOf, MutationOutputOf, DefinedMutation, DefinedMutationFactory, } from './mutation.js';
|
|
5
|
+
export type { ClosureMutationBuilder, CountBounds, CreatedNode, EdgeSelector, ExistingEndpoint, GuardIdentity, GuardRange, MutationEndpoint, PreconditionOptions, QueryPrecondition, DefinedMutationBuilder, RichMutationBuilder, RichPropertyConditions, RichPropertyDelta, RichPropertyInput, RichPropertyName, } from './authoring/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Canonical low-level Mutation documents remain available as the explicit escape hatch, listed one
|
|
8
|
+
* by one as the SDK has exported them, so a newer Kernel's Mutation internals never reach it.
|
|
9
|
+
*/
|
|
10
|
+
export { MutationAST, MutationASTDecodeError, MutationResult, MutationResultDecodeError, } from '@astrale-os/kernel-core/graph/mutate';
|
|
11
|
+
export type { EdgeCreateOperation, EdgeDeleteOperation, EdgeUpdateOperation, MutationBuilder, MutationEdgeSelector, MutationInput, MutationInputEdgeSelector, MutationInputEndpoint, MutationInputOperation, MutationInputPrecondition, MutationOperation, MutationPrecondition, MutationPropertyConditions, MutationPropertyConditionsInput, MutationProps, MutationPropsInput, MutationQueryPrecondition, MutationQueryPreconditionInput, MutationStructuralLimits, NodeCreateOperation, NodeDeleteOperation, NodeUpdateOperation, QueryExpectedSelection, } from '@astrale-os/kernel-core/graph/mutate';
|
|
12
|
+
export type { LocalAlias } from '../../platform/graph/alias.js';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { defineMutation } from './define.js';
|
|
2
2
|
export { executeMutation } from './execution/index.js';
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Canonical low-level Mutation documents remain available as the explicit escape hatch, listed one
|
|
5
|
+
* by one as the SDK has exported them, so a newer Kernel's Mutation internals never reach it.
|
|
6
|
+
*/
|
|
7
|
+
export { MutationAST, MutationASTDecodeError, MutationResult, MutationResultDecodeError, } from '@astrale-os/kernel-core/graph/mutate';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { EdgeSlug } from '@astrale-os/kernel-core/graph/edge';
|
|
2
|
+
import type { QueryEdgeAST, QueryNodeAST } from '@astrale-os/kernel-core/graph/query';
|
|
3
|
+
import type { ResolvedClass } from '@astrale-os/kernel-dsl/v1';
|
|
4
|
+
import type { CreatedNode, ExistingEndpoint, MutationEndpoint } from '../../authoring/endpoint.js';
|
|
5
|
+
import type { CountBounds, GuardIdentity, GuardRange, PreconditionOptions } from '../../authoring/guard.js';
|
|
6
|
+
import type { RichPropertyConditions, RichPropertyDelta, RichPropertyInput } from '../../authoring/properties.js';
|
|
7
|
+
import type { EventOfTopology, StateOfTopology, StatePropertyName, StatePropertyTopology, StateTransitionInput } from '../../authoring/transition.js';
|
|
8
|
+
import type { QueryPrecondition } from './precondition.js';
|
|
9
|
+
/**
|
|
10
|
+
* The builder of the closure form (`defineMutation<Schema>()((domain) => …)`), deprecated: each
|
|
11
|
+
* verb names its Class as resolved, `domain.classes.<Class>`. Each precondition verb (`expect.*`)
|
|
12
|
+
* takes `{ name }` last: a refusal of the Mutation because that precondition fails carries the
|
|
13
|
+
* name as `failure.precondition`. A name is unique in its Mutation.
|
|
14
|
+
*/
|
|
15
|
+
export interface ClosureMutationBuilder {
|
|
16
|
+
readonly expect: {
|
|
17
|
+
/** The Node exists, of this Class, and its Properties meet `props`. */
|
|
18
|
+
node<Class extends ResolvedClass<'node'>>(input: {
|
|
19
|
+
readonly node: ExistingEndpoint;
|
|
20
|
+
readonly class: Class;
|
|
21
|
+
readonly props?: RichPropertyConditions<Class>;
|
|
22
|
+
}, options?: PreconditionOptions): ClosureMutationBuilder;
|
|
23
|
+
/** The Edge exists, its slug is `slug`, and its Properties meet `props`. */
|
|
24
|
+
edge<Class extends ResolvedClass<'edge'>>(input: EdgeSelector<Class> & {
|
|
25
|
+
readonly slug?: EdgeSlug | null;
|
|
26
|
+
readonly props?: RichPropertyConditions<Class>;
|
|
27
|
+
}, options?: PreconditionOptions): ClosureMutationBuilder;
|
|
28
|
+
/**
|
|
29
|
+
* A guard (Mutation v4): no root of the range matches. It takes a range built from the handles
|
|
30
|
+
* `build` receives, `d.<Class>.where(…)`, or a canonical v7 Query.
|
|
31
|
+
*/
|
|
32
|
+
none<S, K extends string>(range: GuardRange<S, K>, options?: PreconditionOptions): ClosureMutationBuilder;
|
|
33
|
+
/** A guard (Mutation v4): a root of the range matches. */
|
|
34
|
+
exists<S, K extends string>(range: GuardRange<S, K>, options?: PreconditionOptions): ClosureMutationBuilder;
|
|
35
|
+
/**
|
|
36
|
+
* A guard (Mutation v4): the number of the range's roots is `bounds`, or lies within
|
|
37
|
+
* `{ atLeast?, atMost? }`, bounded at least once.
|
|
38
|
+
*/
|
|
39
|
+
count<S, K extends string>(range: GuardRange<S, K>, bounds: CountBounds, options?: PreconditionOptions): ClosureMutationBuilder;
|
|
40
|
+
/**
|
|
41
|
+
* A guard (Mutation v4): the range's roots, in its `orderBy`, are exactly these identities, in
|
|
42
|
+
* the order a read of them returned them: a `NodeId` per Node, an `EdgeKey` per Edge.
|
|
43
|
+
*/
|
|
44
|
+
unchanged<S, K extends string>(range: GuardRange<S, K>, ids: readonly GuardIdentity[], options?: PreconditionOptions): ClosureMutationBuilder;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Query V6 precondition (Mutation v3): write a guard on a range,
|
|
47
|
+
* `expect.unchanged(range, ids)`. A Mutation holds guards or V6 Query preconditions,
|
|
48
|
+
* never both.
|
|
49
|
+
*/
|
|
50
|
+
query<Query extends QueryNodeAST | QueryEdgeAST>(input: QueryPrecondition<Query>): ClosureMutationBuilder;
|
|
51
|
+
};
|
|
52
|
+
createNode<Class extends ResolvedClass<'node'>>(input: {
|
|
53
|
+
readonly as: string;
|
|
54
|
+
readonly class: Class;
|
|
55
|
+
readonly props?: RichPropertyInput<Class>;
|
|
56
|
+
}): CreatedNode<Class>;
|
|
57
|
+
updateNode<Class extends ResolvedClass<'node'>>(input: {
|
|
58
|
+
readonly node: ExistingEndpoint;
|
|
59
|
+
readonly class: Class;
|
|
60
|
+
readonly props: RichPropertyDelta<Class>;
|
|
61
|
+
}): this;
|
|
62
|
+
transition<Class extends ResolvedClass<'node'>, Property extends StatePropertyName<Class>, From extends StateOfTopology<StatePropertyTopology<Class, Property>>, Event extends EventOfTopology<StatePropertyTopology<Class, Property>, From>>(input: StateTransitionInput<Class, Property, From, Event>): this;
|
|
63
|
+
deleteNode<Class extends ResolvedClass<'node'>>(input: {
|
|
64
|
+
readonly node: ExistingEndpoint;
|
|
65
|
+
readonly class: Class;
|
|
66
|
+
}): this;
|
|
67
|
+
createEdge<Class extends ResolvedClass<'edge'>>(input: {
|
|
68
|
+
readonly class: Class;
|
|
69
|
+
readonly source: MutationEndpoint;
|
|
70
|
+
readonly target: MutationEndpoint;
|
|
71
|
+
readonly slug?: EdgeSlug;
|
|
72
|
+
readonly props?: RichPropertyInput<Class>;
|
|
73
|
+
}): this;
|
|
74
|
+
updateEdge<Class extends ResolvedClass<'edge'>>(input: EdgeSelector<Class> & {
|
|
75
|
+
readonly slug?: EdgeSlug | null;
|
|
76
|
+
readonly props?: RichPropertyDelta<Class>;
|
|
77
|
+
}): this;
|
|
78
|
+
deleteEdge<Class extends ResolvedClass<'edge'>>(input: EdgeSelector<Class>): this;
|
|
79
|
+
}
|
|
80
|
+
export interface EdgeSelector<Class extends ResolvedClass<'edge'>> {
|
|
81
|
+
readonly source: ExistingEndpoint;
|
|
82
|
+
readonly target: ExistingEndpoint;
|
|
83
|
+
readonly class: Class;
|
|
84
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MutationResult } from '@astrale-os/kernel-core/graph/mutate';
|
|
2
|
+
import type { Domain, schema } from '../../../../platform/schema/index.js';
|
|
3
|
+
import type { Handles } from '../../../query/handles/handles.js';
|
|
4
|
+
import type { Mutation, MutationDefinition } from './mutation.js';
|
|
5
|
+
type ResolvedDomainOf<Schema extends schema.DomainSchema> = Extract<schema.DomainOf<Schema>, Domain>;
|
|
6
|
+
type AuthoringDomainOf<Schema extends schema.DomainSchema> = ResolvedDomainOf<Schema>;
|
|
7
|
+
export interface MutationProjector<Schema extends schema.DomainSchema> {
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated The closure form: define the Mutation from a string id,
|
|
10
|
+
* `defineMutation<Schema>()(id, { build(input, d, mutation), output?, reject?, errors? })`. A
|
|
11
|
+
* Mutation of this form called without `as` writes as the executor.
|
|
12
|
+
*/
|
|
13
|
+
<Input, Output = MutationResult>(project: (domain: AuthoringDomainOf<Schema>) => MutationDefinition<Input, Output, Handles<Schema>>): Mutation<ResolvedDomainOf<Schema>, Input, Output>;
|
|
14
|
+
}
|
|
15
|
+
/** Define one inert Mutation of the closure form, projected from its exact loaded Domain. */
|
|
16
|
+
export declare function defineMutation<Schema extends schema.DomainSchema>(): MutationProjector<Schema>;
|
|
17
|
+
export declare function realizeMutation<DomainValue extends Domain, Input, Output>(mutation: Mutation<DomainValue, Input, Output>, domain: DomainValue): MutationDefinition<Input, Output>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isDomain } from '@astrale-os/kernel-dsl/v1/domain';
|
|
2
|
+
const projectors = new WeakMap();
|
|
3
|
+
const realized = new WeakMap();
|
|
4
|
+
/** Define one inert Mutation of the closure form, projected from its exact loaded Domain. */
|
|
5
|
+
export function defineMutation() {
|
|
6
|
+
return ((project) => {
|
|
7
|
+
if (typeof project !== 'function')
|
|
8
|
+
throw new TypeError('Mutation projection must be a function.');
|
|
9
|
+
const mutation = Object.freeze({ kind: 'mutation' });
|
|
10
|
+
projectors.set(mutation, project);
|
|
11
|
+
return mutation;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function realizeMutation(mutation, domain) {
|
|
15
|
+
const project = projectors.get(mutation);
|
|
16
|
+
if (project === undefined)
|
|
17
|
+
throw new TypeError('Mutation must be produced by defineMutation.');
|
|
18
|
+
if (!isDomain(domain))
|
|
19
|
+
throw new TypeError('Mutation projection requires an admitted Domain.');
|
|
20
|
+
let byDomain = realized.get(mutation);
|
|
21
|
+
const cached = byDomain?.get(domain);
|
|
22
|
+
if (cached !== undefined)
|
|
23
|
+
return cached;
|
|
24
|
+
const authored = project(domain);
|
|
25
|
+
if (isPromiseLike(authored))
|
|
26
|
+
throw new TypeError('Mutation projection must be synchronous.');
|
|
27
|
+
const admitted = admitMutation(authored);
|
|
28
|
+
if (byDomain === undefined) {
|
|
29
|
+
byDomain = new WeakMap();
|
|
30
|
+
realized.set(mutation, byDomain);
|
|
31
|
+
}
|
|
32
|
+
byDomain.set(domain, admitted);
|
|
33
|
+
return admitted;
|
|
34
|
+
}
|
|
35
|
+
function admitMutation(definition) {
|
|
36
|
+
if (definition === null || typeof definition !== 'object' || Array.isArray(definition))
|
|
37
|
+
invalid();
|
|
38
|
+
if (typeof definition.id !== 'string' ||
|
|
39
|
+
definition.id.length === 0 ||
|
|
40
|
+
definition.id.trim() !== definition.id ||
|
|
41
|
+
typeof definition.build !== 'function' ||
|
|
42
|
+
(definition.project !== undefined && typeof definition.project !== 'function') ||
|
|
43
|
+
(definition.reject !== undefined && typeof definition.reject !== 'function') ||
|
|
44
|
+
Reflect.ownKeys(definition).some((key) => key !== 'id' && key !== 'build' && key !== 'project' && key !== 'reject')) {
|
|
45
|
+
invalid();
|
|
46
|
+
}
|
|
47
|
+
return Object.freeze({ ...definition });
|
|
48
|
+
}
|
|
49
|
+
function invalid() {
|
|
50
|
+
throw new TypeError('Mutation definition is invalid.');
|
|
51
|
+
}
|
|
52
|
+
function isPromiseLike(input) {
|
|
53
|
+
return (input !== null &&
|
|
54
|
+
(typeof input === 'object' || typeof input === 'function') &&
|
|
55
|
+
typeof input.then === 'function');
|
|
56
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MutationResult } from '@astrale-os/kernel-core/graph/mutate';
|
|
2
|
+
import type { Domain } from '../../../../platform/schema/index.js';
|
|
3
|
+
import type { MutationFailure } from '../../failure.js';
|
|
4
|
+
import type { ClosureMutationBuilder } from './builder.js';
|
|
5
|
+
declare const MUTATION_DOMAIN: unique symbol;
|
|
6
|
+
declare const MUTATION_INPUT: unique symbol;
|
|
7
|
+
declare const MUTATION_OUTPUT: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* A Mutation of the closure form, deprecated: inert and Domain-bound. Its projector is retained
|
|
10
|
+
* privately by the SDK.
|
|
11
|
+
*/
|
|
12
|
+
export interface Mutation<DomainValue extends Domain = Domain, Input = unknown, Output = MutationResult> {
|
|
13
|
+
readonly kind: 'mutation';
|
|
14
|
+
readonly [MUTATION_DOMAIN]: (domain: DomainValue) => DomainValue;
|
|
15
|
+
readonly [MUTATION_INPUT]?: Input;
|
|
16
|
+
readonly [MUTATION_OUTPUT]?: Output;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Canonical admitted operation produced by realizing one Mutation of the closure form. `build`
|
|
20
|
+
* receives the same handles `D` as a Query's `build`, for the ranges its guards take.
|
|
21
|
+
*/
|
|
22
|
+
export interface MutationDefinition<Input, Output = MutationResult, D = unknown> {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
build(input: Input, mutation: ClosureMutationBuilder, d: D): undefined;
|
|
25
|
+
project?(result: MutationResult, input: NoInfer<Input>): Output;
|
|
26
|
+
reject?(failure: MutationFailure): Output;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { MutationBuilder } from '@astrale-os/kernel-core/graph/mutate';
|
|
2
2
|
import type { QueryEdgeAST, QueryNodeAST, QueryResultFor, QuerySelectionFor } from '@astrale-os/kernel-core/graph/query';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Query V6 precondition (Mutation v3): write a guard on a Query v7,
|
|
5
|
+
* `expect.unchanged(query, identities)`, `expect.none`, `expect.exists` or `expect.count`.
|
|
6
|
+
*/
|
|
3
7
|
export interface QueryPrecondition<Query extends QueryNodeAST | QueryEdgeAST> {
|
|
4
8
|
readonly query: Query;
|
|
5
9
|
readonly equals: QuerySelectionFor<QueryResultFor<Query>>;
|