@astrale-os/sdk 0.6.0-beta.4 → 0.6.0-beta.41
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 +191 -58
- 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 +47 -31
- 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/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/properties.d.ts +5 -3
- package/dist/application/mutation/authoring/properties.js +35 -2
- package/dist/application/mutation/authoring/transition.js +4 -1
- package/dist/application/mutation/execution/execute.js +1 -1
- package/dist/application/mutation/failure.d.ts +6 -0
- package/dist/application/mutation/failure.js +24 -18
- package/dist/application/mutation/index.d.ts +1 -1
- package/dist/application/query/collection/union.js +11 -4
- package/dist/application/query/composite/plan.d.ts +0 -4
- package/dist/application/query/composite/plan.js +0 -2
- package/dist/application/query/conformance.d.ts +15 -0
- package/dist/application/query/conformance.js +46 -0
- package/dist/application/query/define.js +4 -3
- package/dist/application/query/execution/execute.d.ts +0 -1
- package/dist/application/query/execution/execute.js +7 -1
- package/dist/application/query/failure.d.ts +8 -0
- package/dist/application/query/failure.js +8 -0
- package/dist/application/query/index.d.ts +1 -1
- package/dist/application/query/index.js +1 -1
- package/dist/application/routes/admission.d.ts +2 -2
- package/dist/application/routes/admission.js +1 -1
- package/dist/application/routes/route.d.ts +2 -2
- package/dist/application/runtime/actions.js +3 -0
- 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 +197 -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/file.d.ts +10 -0
- package/dist/deployment/adapter/bundle/index.d.ts +2 -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/context.d.ts +94 -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 +8 -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 +28 -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 +11 -0
- package/dist/execution/invocation/capabilities/bind.js +25 -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/context.d.ts +7 -6
- package/dist/execution/invocation/dispatch/context.js +11 -44
- package/dist/execution/invocation/dispatch/workflow.js +0 -4
- 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 +0 -17
- package/dist/execution/invocation/result/index.d.ts +2 -2
- package/dist/execution/invocation/result/index.js +1 -1
- package/dist/execution/invocation/result/project.js +41 -1
- 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 +39 -0
- package/dist/execution/workflows/failure.js +143 -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 +365 -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 +61 -11
- 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/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 +6 -1
- package/dist/testing/index.js +5 -1
- package/dist/testing/load.js +1 -1
- 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 +246 -90
- 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/imports.d.ts +0 -1
- package/dist/tooling/linter/adapters/typescript/imports.js +1 -5
- package/dist/tooling/linter/adapters/typescript/index.d.ts +1 -1
- package/dist/tooling/linter/adapters/typescript/index.js +1 -1
- 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/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/dependencies.js +13 -72
- package/dist/tooling/linter/implementations/source/global.js +1 -2
- package/dist/tooling/linter/implementations/source/mutations.js +18 -29
- 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 +12 -4
- package/dist/tooling/linter/implementations/source/shared.js +101 -46
- package/dist/tooling/linter/implementations/source/verifiers.js +0 -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 +14 -63
- package/dist/tooling/linter/requirements/registry.js +6 -8
- 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 +445 -0
- package/docs/handler-dependencies.md +213 -0
- package/docs/release.md +155 -0
- package/docs/schema-cost.md +124 -0
- package/package.json +45 -16
- 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/{deployment/adapter/deploy/context.js → application/workflow/durable.js} +0 -0
- /package/dist/deployment/adapter/{deploy/index.js → bundle/bundle.js} +0 -0
- /package/dist/deployment/adapter/{deploy/result.js → bundle/file.js} +0 -0
- /package/dist/deployment/adapter/{prepare → bundle}/index.js +0 -0
- /package/dist/deployment/adapter/{prepare/artifact.js → release/command.js} +0 -0
- /package/dist/deployment/adapter/{prepare → release}/context.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,7 +1,42 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { propertyChain, unwrap, visit } from '../../adapters/typescript/index.js';
|
|
3
|
-
import { ambiguity, calls, production, staticId, violation } from './shared.js';
|
|
4
|
-
|
|
2
|
+
import { expressionType, propertyChain, unwrap, visit, visitOwnBody, } from '../../adapters/typescript/index.js';
|
|
3
|
+
import { ambiguity, calls, contextPath, globalCallName, globalPath, production, propertyExpression, staticId, violation, } from './shared.js';
|
|
4
|
+
// `query` and `mutate` are the durable Step sugar over `run`; each is one Step too.
|
|
5
|
+
const STEP_METHODS = new Set(['run', 'query', 'mutate']);
|
|
6
|
+
// Members only a durable Workflow context has: using one proves the Workflow durable.
|
|
7
|
+
const DURABLE_CONTEXT_MEMBERS = new Set([
|
|
8
|
+
'awaitSignal',
|
|
9
|
+
'cancelled',
|
|
10
|
+
'exhausted',
|
|
11
|
+
'retryAfter',
|
|
12
|
+
'sleep',
|
|
13
|
+
]);
|
|
14
|
+
const AUTHORITIES = new Set(['caller', 'self']);
|
|
15
|
+
// Raw Kernel graph reads a Step's `kernel` offers beside `mutate`.
|
|
16
|
+
const KERNEL_READS = new Set(['query', 'get', 'getOrThrow', 'neighbors']);
|
|
17
|
+
// Global reads a replay answers anew: the clock and randomness.
|
|
18
|
+
const REPLAY_VALUES = new Set([
|
|
19
|
+
'Date.now',
|
|
20
|
+
'Math.random',
|
|
21
|
+
'crypto.randomUUID',
|
|
22
|
+
'crypto.getRandomValues',
|
|
23
|
+
'performance.now',
|
|
24
|
+
]);
|
|
25
|
+
// Array methods that run their callback once per element.
|
|
26
|
+
const ITERATING_METHODS = new Set([
|
|
27
|
+
'every',
|
|
28
|
+
'filter',
|
|
29
|
+
'find',
|
|
30
|
+
'findIndex',
|
|
31
|
+
'findLast',
|
|
32
|
+
'findLastIndex',
|
|
33
|
+
'flatMap',
|
|
34
|
+
'forEach',
|
|
35
|
+
'map',
|
|
36
|
+
'reduce',
|
|
37
|
+
'reduceRight',
|
|
38
|
+
'some',
|
|
39
|
+
]);
|
|
5
40
|
export const workflowRules = [
|
|
6
41
|
{
|
|
7
42
|
id: 'FNC-INT-TYPES',
|
|
@@ -50,7 +85,7 @@ export const workflowRules = [
|
|
|
50
85
|
const method = stepMethod(node, roots);
|
|
51
86
|
if (!method)
|
|
52
87
|
return;
|
|
53
|
-
const id =
|
|
88
|
+
const id = stepId(node.arguments[0]);
|
|
54
89
|
if (!id || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(id)) {
|
|
55
90
|
evidence.push(violation(file, node.arguments[0] ?? node, `Workflow ${method} step ID is not a non-empty kebab-case literal.`));
|
|
56
91
|
}
|
|
@@ -67,7 +102,7 @@ export const workflowRules = [
|
|
|
67
102
|
},
|
|
68
103
|
{
|
|
69
104
|
id: 'FNC-NO-NEST',
|
|
70
|
-
ruleRevision: '
|
|
105
|
+
ruleRevision: '28e764f96932bbee59a2ae6399569789a1cd2bda8e2a14ce9da5afbd348e3a63',
|
|
71
106
|
evaluate(project) {
|
|
72
107
|
const evidence = [];
|
|
73
108
|
for (const file of production(project, 'functions')) {
|
|
@@ -109,7 +144,465 @@ export const workflowRules = [
|
|
|
109
144
|
return evidence;
|
|
110
145
|
},
|
|
111
146
|
},
|
|
147
|
+
{
|
|
148
|
+
id: 'FNC-STEP-READS',
|
|
149
|
+
ruleRevision: '16b3a7c85214d5c0c6cfaede5099c16223da1c3fd98dec9781910634bab89343',
|
|
150
|
+
evaluate(project) {
|
|
151
|
+
const evidence = [];
|
|
152
|
+
for (const step of durableSteps(project, evidence)) {
|
|
153
|
+
const operations = stepOperations(project, step);
|
|
154
|
+
const effects = operations.filter(({ kind }) => kind === 'effect');
|
|
155
|
+
const reads = operations.filter((operation) => operation.kind === 'observation' &&
|
|
156
|
+
effects.some((effect) => precedes(operation, effect, step.callback)));
|
|
157
|
+
if (reads.length === 0)
|
|
158
|
+
continue;
|
|
159
|
+
evidence.push(violation(step.file, step.call, `Durable step ${step.label} reads (${names(reads)}) before it writes (${names(effects)}); a retry after its write would read that write. Read in an earlier step.`));
|
|
160
|
+
}
|
|
161
|
+
return evidence;
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: 'FNC-EFFECT-STEP',
|
|
166
|
+
ruleRevision: 'edadc22d3dbe2d35a4e8c0c341245808cb2d9f4fb1accf953a05f6162956bea1',
|
|
167
|
+
evaluate(project) {
|
|
168
|
+
const evidence = [];
|
|
169
|
+
for (const step of durableSteps(project, evidence)) {
|
|
170
|
+
const effects = stepOperations(project, step).filter(({ kind }) => kind === 'effect');
|
|
171
|
+
// An effect runs again when it sits in a loop or two of its traces can run in one run.
|
|
172
|
+
const again = (effect) => effect.traces.some((trace) => trace.some((node) => repeated(node, step.callback))) ||
|
|
173
|
+
together(effect.traces, effect.traces, step.callback);
|
|
174
|
+
const involved = effects.filter((effect) => again(effect) ||
|
|
175
|
+
effects.some((other) => other !== effect && together(effect.traces, other.traces, step.callback)));
|
|
176
|
+
if (involved.length === 0)
|
|
177
|
+
continue;
|
|
178
|
+
const listed = involved
|
|
179
|
+
.map((effect) => (again(effect) ? `${effect.name} repeatedly` : effect.name))
|
|
180
|
+
.join(', ');
|
|
181
|
+
evidence.push(violation(step.file, step.call, `Durable step ${step.label} performs several effects (${listed}); if one fails after another committed, the Workflow cannot tell. Give each effect its own step.`));
|
|
182
|
+
}
|
|
183
|
+
return evidence;
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 'FNC-STEP-RETRY',
|
|
188
|
+
ruleRevision: 'fefbd4cb783e08b0dfe49788ff036ecff61da9190fd1b64152f92ef3a254a195',
|
|
189
|
+
evaluate(project) {
|
|
190
|
+
const evidence = [];
|
|
191
|
+
for (const step of durableSteps(project, evidence)) {
|
|
192
|
+
for (const operation of stepOperations(project, step)) {
|
|
193
|
+
if (operation.kind !== 'unkeyed')
|
|
194
|
+
continue;
|
|
195
|
+
evidence.push(violation(step.file, operation.node, `Durable step ${step.label} calls ${operation.name}, which runs again when the step is retried; make it idempotent, declare the callee durable, or move it out of the durable Workflow.`));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return evidence;
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'FNC-REPLAY-VALUES',
|
|
203
|
+
ruleRevision: 'ddadc9e08be8faa36c38fd47d82d6c7815f68ffcac8806af958b13df3872b995',
|
|
204
|
+
evaluate(project) {
|
|
205
|
+
const evidence = [];
|
|
206
|
+
for (const workflow of durableWorkflows(project, evidence)) {
|
|
207
|
+
for (const { node, name } of replayValues(workflow.file, workflow.run)) {
|
|
208
|
+
evidence.push(violation(workflow.file, node, `Durable Workflow reads ${name} outside its steps; a replay reads another value and can take another path. Read it in a step.`));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return evidence;
|
|
212
|
+
},
|
|
213
|
+
},
|
|
112
214
|
];
|
|
215
|
+
/** The `step.run` callbacks of every Workflow its source proves durable. */
|
|
216
|
+
function durableSteps(project, evidence) {
|
|
217
|
+
return durableWorkflows(project, evidence).flatMap(({ steps }) => steps);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Every Workflow its source proves durable, with its `step.run` callbacks: it uses a member only the
|
|
221
|
+
* durable context has, `step.query` or `step.mutate`, or a Step callback that receives
|
|
222
|
+
* capabilities. An inline Workflow never replays nor retries a step and is not inspected.
|
|
223
|
+
*/
|
|
224
|
+
function durableWorkflows(project, evidence) {
|
|
225
|
+
const workflows = [];
|
|
226
|
+
for (const file of production(project, 'functions')) {
|
|
227
|
+
const helpers = localFunctions(file.source);
|
|
228
|
+
for (const definition of workflowDefinitions(file)) {
|
|
229
|
+
if (definition.origin === 'ambiguous') {
|
|
230
|
+
evidence.push(ambiguity(file, definition.call, 'Workflow definition resolves through a local facade whose ultimate public constructor origin is unknown.'));
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const { run } = definition;
|
|
234
|
+
if (!run)
|
|
235
|
+
continue;
|
|
236
|
+
const roots = stepRoots(run);
|
|
237
|
+
const runs = [];
|
|
238
|
+
let durable = usesDurableContext(run);
|
|
239
|
+
visitOwnBody(run, (node) => {
|
|
240
|
+
if (!ts.isCallExpression(node))
|
|
241
|
+
return;
|
|
242
|
+
const method = stepMethod(node, roots);
|
|
243
|
+
if (!method)
|
|
244
|
+
return;
|
|
245
|
+
if (method === 'query' || method === 'mutate' || declaredStep(node.arguments[0])) {
|
|
246
|
+
durable = true;
|
|
247
|
+
}
|
|
248
|
+
if (method !== 'run')
|
|
249
|
+
return;
|
|
250
|
+
const callback = node.arguments[1] && stepRunCallback(node.arguments[1], helpers);
|
|
251
|
+
if (!callback)
|
|
252
|
+
return;
|
|
253
|
+
if (callback.parameters.length > 0)
|
|
254
|
+
durable = true;
|
|
255
|
+
const id = stepId(node.arguments[0]);
|
|
256
|
+
runs.push({ file, call: node, label: id ?? 'with a dynamic id', callback });
|
|
257
|
+
});
|
|
258
|
+
if (durable)
|
|
259
|
+
workflows.push({ file, run, steps: runs });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return workflows;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Reads of the clock and randomness in the code a replay runs again: the run's own body, and the
|
|
266
|
+
* functions it invokes there at once, immediately invoked or as an iterating Array callback. Step
|
|
267
|
+
* callbacks and every other nested function run at a time the source does not prove, and are
|
|
268
|
+
* skipped.
|
|
269
|
+
*/
|
|
270
|
+
function replayValues(file, run) {
|
|
271
|
+
const found = [];
|
|
272
|
+
const walk = (node) => {
|
|
273
|
+
if (ts.isFunctionLike(node) && !invokedAtOnce(node))
|
|
274
|
+
return;
|
|
275
|
+
const name = replayValue(file, node);
|
|
276
|
+
if (name)
|
|
277
|
+
found.push({ node, name });
|
|
278
|
+
node.forEachChild(walk);
|
|
279
|
+
};
|
|
280
|
+
if (run.body)
|
|
281
|
+
walk(run.body);
|
|
282
|
+
return found;
|
|
283
|
+
}
|
|
284
|
+
/** The clock or random value `node` reads from a global, as the rule names it. */
|
|
285
|
+
function replayValue(file, node) {
|
|
286
|
+
if (ts.isNewExpression(node)) {
|
|
287
|
+
const path = globalPath(file, node.expression);
|
|
288
|
+
return path?.join('.') === 'Date' && (node.arguments?.length ?? 0) === 0
|
|
289
|
+
? 'new Date()'
|
|
290
|
+
: undefined;
|
|
291
|
+
}
|
|
292
|
+
if (!ts.isCallExpression(node))
|
|
293
|
+
return undefined;
|
|
294
|
+
const name = globalPath(file, node.expression)?.join('.');
|
|
295
|
+
// `Date` called as a function answers the current time, whatever it receives.
|
|
296
|
+
if (name === 'Date')
|
|
297
|
+
return 'Date()';
|
|
298
|
+
return name !== undefined && REPLAY_VALUES.has(name) ? `${name}()` : undefined;
|
|
299
|
+
}
|
|
300
|
+
/** A function the code around it runs at once: immediately invoked, or an iterating Array callback. */
|
|
301
|
+
function invokedAtOnce(fn) {
|
|
302
|
+
if (!ts.isArrowFunction(fn) && !ts.isFunctionExpression(fn))
|
|
303
|
+
return false;
|
|
304
|
+
let site = fn;
|
|
305
|
+
while (ts.isParenthesizedExpression(site.parent))
|
|
306
|
+
site = site.parent;
|
|
307
|
+
return ((ts.isCallExpression(site.parent) && site.parent.expression === site) || iteratingCallback(fn));
|
|
308
|
+
}
|
|
309
|
+
/** Only a durable Step takes a declaration, `{ id, retry, timeoutMs }`, in place of its id. */
|
|
310
|
+
function declaredStep(argument) {
|
|
311
|
+
return argument !== undefined && ts.isObjectLiteralExpression(unwrap(argument));
|
|
312
|
+
}
|
|
313
|
+
/** A Step's literal id: its first argument, or the `id` of the declaration written there. */
|
|
314
|
+
function stepId(argument) {
|
|
315
|
+
if (argument === undefined)
|
|
316
|
+
return undefined;
|
|
317
|
+
const value = unwrap(argument);
|
|
318
|
+
return ts.isObjectLiteralExpression(value)
|
|
319
|
+
? staticId(propertyExpression(value, 'id'))
|
|
320
|
+
: staticId(value);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* A `step.run` callback written inline or named by one local function. Any other is not inspected;
|
|
324
|
+
* FNC-NO-NEST reports it as ambiguous.
|
|
325
|
+
*/
|
|
326
|
+
function stepRunCallback(argument, helpers) {
|
|
327
|
+
const value = unwrap(argument);
|
|
328
|
+
if (ts.isArrowFunction(value) || ts.isFunctionExpression(value))
|
|
329
|
+
return value;
|
|
330
|
+
if (!ts.isIdentifier(value))
|
|
331
|
+
return undefined;
|
|
332
|
+
const candidates = helpers.get(value.text) ?? [];
|
|
333
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
334
|
+
}
|
|
335
|
+
function usesDurableContext(run) {
|
|
336
|
+
const parameter = run.parameters[0]?.name;
|
|
337
|
+
if (parameter && ts.isObjectBindingPattern(parameter)) {
|
|
338
|
+
return parameter.elements.some((element) => {
|
|
339
|
+
const name = element.propertyName ?? element.name;
|
|
340
|
+
return ts.isIdentifier(name) && DURABLE_CONTEXT_MEMBERS.has(name.text);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (!parameter || !ts.isIdentifier(parameter) || !run.body)
|
|
344
|
+
return false;
|
|
345
|
+
let found = false;
|
|
346
|
+
visit(run.body, (node) => {
|
|
347
|
+
if (ts.isPropertyAccessExpression(node) &&
|
|
348
|
+
DURABLE_CONTEXT_MEMBERS.has(node.name.text) &&
|
|
349
|
+
contextPath(node, run)?.length === 1)
|
|
350
|
+
found = true;
|
|
351
|
+
});
|
|
352
|
+
return found;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Operations of one step whose kind is provable, with the traces that run them. An operation of
|
|
356
|
+
* unprovable kind, or in a local helper the step never mentions, is omitted.
|
|
357
|
+
*/
|
|
358
|
+
function stepOperations(project, step) {
|
|
359
|
+
const operations = [];
|
|
360
|
+
const body = step.callback.body;
|
|
361
|
+
if (!body)
|
|
362
|
+
return operations;
|
|
363
|
+
visit(body, (node) => {
|
|
364
|
+
if (!ts.isCallExpression(node))
|
|
365
|
+
return;
|
|
366
|
+
const operation = callOperation(project, step, node);
|
|
367
|
+
if (!operation)
|
|
368
|
+
return;
|
|
369
|
+
const traces = runTraces(node, step.callback);
|
|
370
|
+
if (traces.length > 0)
|
|
371
|
+
operations.push({ ...operation, traces });
|
|
372
|
+
});
|
|
373
|
+
return operations;
|
|
374
|
+
}
|
|
375
|
+
function callOperation(project, step, node) {
|
|
376
|
+
if (globalCallName(step.file, node) === 'fetch')
|
|
377
|
+
return { kind: 'unkeyed', node, name: 'fetch' };
|
|
378
|
+
const path = contextPath(node.expression, step.callback);
|
|
379
|
+
return path && capabilityOperation(project, step.file, node, path);
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* The traces through which the step callback reaches `node`: the node itself, or, inside a local
|
|
383
|
+
* helper bound to a name, each mention of that name followed by the node.
|
|
384
|
+
*/
|
|
385
|
+
function runTraces(node, callback, active = new Set()) {
|
|
386
|
+
for (let current = node.parent; current && current !== callback; current = current.parent) {
|
|
387
|
+
const name = ts.isFunctionLike(current) ? helperName(current) : undefined;
|
|
388
|
+
if (!name)
|
|
389
|
+
continue;
|
|
390
|
+
if (active.has(current))
|
|
391
|
+
return [];
|
|
392
|
+
active.add(current);
|
|
393
|
+
const traces = mentions(name, callback)
|
|
394
|
+
.filter(invokes)
|
|
395
|
+
.flatMap((mention) => runTraces(mention, callback, active).map((trace) => [...trace, node]));
|
|
396
|
+
active.delete(current);
|
|
397
|
+
return traces;
|
|
398
|
+
}
|
|
399
|
+
return [[node]];
|
|
400
|
+
}
|
|
401
|
+
function helperName(fn) {
|
|
402
|
+
const name = ts.isFunctionDeclaration(fn)
|
|
403
|
+
? fn.name
|
|
404
|
+
: (ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) &&
|
|
405
|
+
ts.isVariableDeclaration(fn.parent) &&
|
|
406
|
+
fn.parent.initializer === fn
|
|
407
|
+
? fn.parent.name
|
|
408
|
+
: undefined;
|
|
409
|
+
return name && ts.isIdentifier(name) ? name : undefined;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Whether a mention of a helper runs it: the helper is called, or handed to an iterating Array
|
|
413
|
+
* method as its callback. A helper only referenced, returned or stored is not known to run.
|
|
414
|
+
*/
|
|
415
|
+
function invokes(mention) {
|
|
416
|
+
const parent = mention.parent;
|
|
417
|
+
if (!ts.isCallExpression(parent))
|
|
418
|
+
return false;
|
|
419
|
+
return parent.expression === mention || iteratingCallback(mention);
|
|
420
|
+
}
|
|
421
|
+
/** Whether `node` is the callback, the first argument, of an iterating Array method call. */
|
|
422
|
+
function iteratingCallback(node) {
|
|
423
|
+
const parent = node.parent;
|
|
424
|
+
return (parent !== undefined &&
|
|
425
|
+
ts.isCallExpression(parent) &&
|
|
426
|
+
parent.arguments[0] === node &&
|
|
427
|
+
ITERATING_METHODS.has(propertyChain(parent.expression)?.at(-1) ?? ''));
|
|
428
|
+
}
|
|
429
|
+
/** The identifiers of `scope` other than `name` itself that refer to its text, not as a member. */
|
|
430
|
+
function mentions(name, scope) {
|
|
431
|
+
const found = [];
|
|
432
|
+
visit(scope, (node) => {
|
|
433
|
+
if (node === name || !ts.isIdentifier(node) || node.text !== name.text)
|
|
434
|
+
return;
|
|
435
|
+
const parent = node.parent;
|
|
436
|
+
if ((ts.isPropertyAccessExpression(parent) || ts.isPropertyAssignment(parent)) &&
|
|
437
|
+
parent.name === node)
|
|
438
|
+
return;
|
|
439
|
+
found.push(node);
|
|
440
|
+
});
|
|
441
|
+
return found;
|
|
442
|
+
}
|
|
443
|
+
function capabilityOperation(project, file, node, path) {
|
|
444
|
+
const name = path.join('.');
|
|
445
|
+
const method = path.at(-1);
|
|
446
|
+
const selected = (parts) => parts.length === 0 || (parts.length === 1 && AUTHORITIES.has(parts[0]));
|
|
447
|
+
if (path.length === 1 && (method === 'query' || method === 'mutate')) {
|
|
448
|
+
return { kind: method === 'query' ? 'observation' : 'effect', node, name };
|
|
449
|
+
}
|
|
450
|
+
if (path[0] === 'graph' && selected(path.slice(1, -1))) {
|
|
451
|
+
if (method === 'query')
|
|
452
|
+
return { kind: 'observation', node, name };
|
|
453
|
+
if (method === 'mutate')
|
|
454
|
+
return { kind: 'effect', node, name };
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
if (path[0] === 'kernel' && selected(path.slice(1, -1))) {
|
|
458
|
+
if (KERNEL_READS.has(method))
|
|
459
|
+
return { kind: 'observation', node, name };
|
|
460
|
+
if (method === 'mutate')
|
|
461
|
+
return { kind: 'effect', node, name };
|
|
462
|
+
if (method !== 'invoke')
|
|
463
|
+
return undefined;
|
|
464
|
+
const target = node.arguments[0] && unwrap(node.arguments[0]);
|
|
465
|
+
if (target &&
|
|
466
|
+
(ts.isStringLiteralLike(target) ||
|
|
467
|
+
ts.isTemplateExpression(target) ||
|
|
468
|
+
stringTyped(project, file, target))) {
|
|
469
|
+
return { kind: 'unkeyed', node, name: `${name} of an untyped Path` };
|
|
470
|
+
}
|
|
471
|
+
return invocation(project, file, node, name);
|
|
472
|
+
}
|
|
473
|
+
if (path[0] === 'dependencies' && path.length === 4 && AUTHORITIES.has(path[2])) {
|
|
474
|
+
return method === 'invoke' ? invocation(project, file, node, name) : undefined;
|
|
475
|
+
}
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* A call the types prove durable answers with its Execution and carries the step's key; one they
|
|
480
|
+
* prove ordinary carries none. Without types, or with an unresolved result, the kind is unprovable.
|
|
481
|
+
*/
|
|
482
|
+
function invocation(project, file, node, name) {
|
|
483
|
+
const resolved = expressionType(project, file, node);
|
|
484
|
+
if (resolved === undefined)
|
|
485
|
+
return undefined;
|
|
486
|
+
const output = resolved.checker.getAwaitedType(resolved.type) ?? resolved.type;
|
|
487
|
+
const kinds = new Set((output.isUnion() ? output.types : [output]).map(resultKind));
|
|
488
|
+
if (kinds.size !== 1)
|
|
489
|
+
return undefined;
|
|
490
|
+
const [kind] = kinds;
|
|
491
|
+
if (kind === 'durable')
|
|
492
|
+
return { kind: 'effect', node, name };
|
|
493
|
+
if (kind === 'ordinary') {
|
|
494
|
+
return { kind: 'unkeyed', node, name: `${name} of a callable that is not durable` };
|
|
495
|
+
}
|
|
496
|
+
return undefined;
|
|
497
|
+
}
|
|
498
|
+
/** Whether the types prove `expression` a string, which only an untyped Path is. */
|
|
499
|
+
function stringTyped(project, file, expression) {
|
|
500
|
+
const resolved = expressionType(project, file, expression);
|
|
501
|
+
if (resolved === undefined)
|
|
502
|
+
return false;
|
|
503
|
+
const types = resolved.type.isUnion() ? resolved.type.types : [resolved.type];
|
|
504
|
+
return types.every((type) => (type.flags & ts.TypeFlags.StringLike) !== 0);
|
|
505
|
+
}
|
|
506
|
+
function resultKind(type) {
|
|
507
|
+
if (type.flags &
|
|
508
|
+
(ts.TypeFlags.Any |
|
|
509
|
+
ts.TypeFlags.Unknown |
|
|
510
|
+
ts.TypeFlags.Never |
|
|
511
|
+
ts.TypeFlags.TypeParameter |
|
|
512
|
+
ts.TypeFlags.Conditional |
|
|
513
|
+
ts.TypeFlags.IndexedAccess)) {
|
|
514
|
+
return 'unprovable';
|
|
515
|
+
}
|
|
516
|
+
return (type.aliasSymbol ?? type.getSymbol())?.getName() === 'ExecutionRef'
|
|
517
|
+
? 'durable'
|
|
518
|
+
: 'ordinary';
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Whether some run of the step can reach `read` before `effect` completes. Two traces are ordered
|
|
522
|
+
* where they part, in source order: a read that ends first precedes the effect or builds its
|
|
523
|
+
* arguments, unless both sit in the step's own body and take exclusive branches. Inside a helper no
|
|
524
|
+
* branch is exclusive, since each call may take another. A read after the effect sees the same
|
|
525
|
+
* committed write on every attempt.
|
|
526
|
+
*/
|
|
527
|
+
function precedes(read, effect, callback) {
|
|
528
|
+
return read.traces.some((first) => effect.traces.some((second) => before(first, second, callback)));
|
|
529
|
+
}
|
|
530
|
+
/** Whether one run of the step can reach two distinct traces, one from each list. */
|
|
531
|
+
function together(traces, others, callback) {
|
|
532
|
+
return traces.some((trace) => others.some((other) => other !== trace && (before(trace, other, callback) || before(other, trace, callback))));
|
|
533
|
+
}
|
|
534
|
+
/** Whether a run can reach the end of `first` before `second` completes, by the order above. */
|
|
535
|
+
function before(first, second, callback) {
|
|
536
|
+
const index = first.findIndex((node, position) => node !== second[position]);
|
|
537
|
+
const left = first[index];
|
|
538
|
+
const right = second[index];
|
|
539
|
+
if (!left || !right)
|
|
540
|
+
return false;
|
|
541
|
+
return left.end < right.end && !exclusive(left, right, callback);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Whether no run of the step reaches `effect` after `read`: both sit directly in the callback, and
|
|
545
|
+
* they take the two branches of one condition outside any loop, or `read` sits in a branch that
|
|
546
|
+
* returns or throws without `effect`.
|
|
547
|
+
*/
|
|
548
|
+
function exclusive(read, effect, callback) {
|
|
549
|
+
if (owner(read) !== callback || owner(effect) !== callback)
|
|
550
|
+
return false;
|
|
551
|
+
for (let node = read; node.parent && node !== callback.body; node = node.parent) {
|
|
552
|
+
const parent = node.parent;
|
|
553
|
+
if (ts.isIfStatement(parent) && node !== parent.expression) {
|
|
554
|
+
const other = node === parent.thenStatement ? parent.elseStatement : parent.thenStatement;
|
|
555
|
+
if (other && within(effect, other) && !repeated(parent, callback))
|
|
556
|
+
return true;
|
|
557
|
+
if (exits(node) && !within(effect, node))
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
if (ts.isConditionalExpression(parent) && node !== parent.condition) {
|
|
561
|
+
const other = node === parent.whenTrue ? parent.whenFalse : parent.whenTrue;
|
|
562
|
+
if (within(effect, other) && !repeated(parent, callback))
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* A site the step may run more than once: in a loop, or in or as the callback of an iterating
|
|
570
|
+
* Array method.
|
|
571
|
+
*/
|
|
572
|
+
function repeated(node, callback) {
|
|
573
|
+
for (let current = node; current && current !== callback; current = current.parent) {
|
|
574
|
+
if (current !== node && ts.isIterationStatement(current, false))
|
|
575
|
+
return true;
|
|
576
|
+
if (iteratingCallback(current))
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
/** A statement whose every run ends in `return` or `throw`. */
|
|
582
|
+
function exits(statement) {
|
|
583
|
+
if (ts.isReturnStatement(statement) || ts.isThrowStatement(statement))
|
|
584
|
+
return true;
|
|
585
|
+
if (ts.isBlock(statement)) {
|
|
586
|
+
const last = statement.statements.at(-1);
|
|
587
|
+
return last !== undefined && exits(last);
|
|
588
|
+
}
|
|
589
|
+
return (ts.isIfStatement(statement) &&
|
|
590
|
+
statement.elseStatement !== undefined &&
|
|
591
|
+
exits(statement.thenStatement) &&
|
|
592
|
+
exits(statement.elseStatement));
|
|
593
|
+
}
|
|
594
|
+
function owner(node) {
|
|
595
|
+
let current = node.parent;
|
|
596
|
+
while (current && !ts.isFunctionLike(current))
|
|
597
|
+
current = current.parent;
|
|
598
|
+
return current;
|
|
599
|
+
}
|
|
600
|
+
function within(node, container) {
|
|
601
|
+
return node.pos >= container.pos && node.end <= container.end;
|
|
602
|
+
}
|
|
603
|
+
function names(operations) {
|
|
604
|
+
return operations.map(({ name }) => name).join(', ');
|
|
605
|
+
}
|
|
113
606
|
function workflowDefinitions(file) {
|
|
114
607
|
return calls(file, 'defineWorkflow').map(({ call: factory, origin }) => {
|
|
115
608
|
const call = ts.isCallExpression(factory.parent) && factory.parent.expression === factory
|
|
@@ -154,17 +647,6 @@ function stepMethod(call, roots) {
|
|
|
154
647
|
? chain.at(-1)
|
|
155
648
|
: undefined;
|
|
156
649
|
}
|
|
157
|
-
function visitOwnBody(fn, callback) {
|
|
158
|
-
if (!fn.body)
|
|
159
|
-
return;
|
|
160
|
-
const walk = (node) => {
|
|
161
|
-
callback(node);
|
|
162
|
-
if (node !== fn.body && ts.isFunctionLike(node))
|
|
163
|
-
return;
|
|
164
|
-
node.forEachChild(walk);
|
|
165
|
-
};
|
|
166
|
-
walk(fn.body);
|
|
167
|
-
}
|
|
168
650
|
function localFunctions(source) {
|
|
169
651
|
const result = new Map();
|
|
170
652
|
const add = (name, fn) => {
|
|
@@ -192,7 +674,7 @@ function traceNestedSteps(file, fn, workflowRun, roots, helpers, evidence, activ
|
|
|
192
674
|
return;
|
|
193
675
|
if (ts.isCallExpression(node)) {
|
|
194
676
|
const nested = stepMethod(node, roots);
|
|
195
|
-
if (nested
|
|
677
|
+
if (nested !== undefined) {
|
|
196
678
|
evidence.push(violation(file, node, `step.run callback reaches nested step.${nested}.`));
|
|
197
679
|
return;
|
|
198
680
|
}
|