@owlmeans/server-planning 0.1.18-rc.9 → 0.1.18
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 +92 -19
- package/agent-meta/manifest.json +105 -4
- package/agent-meta/skills/server-planning/SKILL.md +89 -138
- package/agent-meta/skills/server-planning/parts/auxiliary.md +54 -0
- package/agent-meta/skills/server-planning/parts/executor.md +82 -0
- package/agent-meta/skills/server-planning/parts/schemas.md +26 -0
- package/agent-meta/skills/server-planning/parts/serving.md +88 -0
- package/agent-meta/skills/server-planning/parts/stores.md +91 -0
- package/build/actions/apply-schema-request.d.ts +8 -0
- package/build/actions/apply-schema-request.d.ts.map +1 -0
- package/build/actions/apply-schema-request.js +33 -0
- package/build/actions/apply-schema-request.js.map +1 -0
- package/build/actions/commit.d.ts +3 -3
- package/build/actions/commit.d.ts.map +1 -1
- package/build/actions/commit.js +5 -4
- package/build/actions/commit.js.map +1 -1
- package/build/actions/define-schemas.d.ts +13 -0
- package/build/actions/define-schemas.d.ts.map +1 -0
- package/build/actions/define-schemas.js +28 -0
- package/build/actions/define-schemas.js.map +1 -0
- package/build/actions/execute.d.ts +11 -10
- package/build/actions/execute.d.ts.map +1 -1
- package/build/actions/execute.js +17 -27
- package/build/actions/execute.js.map +1 -1
- package/build/actions/execution/types.d.ts +34 -0
- package/build/actions/execution/types.d.ts.map +1 -0
- package/build/actions/execution/types.js +2 -0
- package/build/actions/execution/types.js.map +1 -0
- package/build/actions/execution.d.ts +4 -0
- package/build/actions/execution.d.ts.map +1 -0
- package/build/actions/execution.js +88 -0
- package/build/actions/execution.js.map +1 -0
- package/build/actions/get-card.d.ts +6 -0
- package/build/actions/get-card.d.ts.map +1 -0
- package/build/actions/get-card.js +9 -0
- package/build/actions/get-card.js.map +1 -0
- package/build/actions/get-specification.d.ts +6 -0
- package/build/actions/get-specification.d.ts.map +1 -0
- package/build/actions/get-specification.js +9 -0
- package/build/actions/get-specification.js.map +1 -0
- package/build/actions/index.d.ts +12 -3
- package/build/actions/index.d.ts.map +1 -1
- package/build/actions/index.js +11 -3
- package/build/actions/index.js.map +1 -1
- package/build/actions/links.d.ts +3 -3
- package/build/actions/links.d.ts.map +1 -1
- package/build/actions/links.js +6 -5
- package/build/actions/links.js.map +1 -1
- package/build/actions/list-card-specifications.d.ts +6 -0
- package/build/actions/list-card-specifications.d.ts.map +1 -0
- package/build/actions/list-card-specifications.js +11 -0
- package/build/actions/list-card-specifications.js.map +1 -0
- package/build/actions/list-card-transitions.d.ts +6 -0
- package/build/actions/list-card-transitions.d.ts.map +1 -0
- package/build/actions/list-card-transitions.js +11 -0
- package/build/actions/list-card-transitions.js.map +1 -0
- package/build/actions/list-cards.d.ts +6 -0
- package/build/actions/list-cards.d.ts.map +1 -0
- package/build/actions/list-cards.js +10 -0
- package/build/actions/list-cards.js.map +1 -0
- package/build/actions/list-schemas.d.ts +13 -0
- package/build/actions/list-schemas.d.ts.map +1 -0
- package/build/actions/list-schemas.js +20 -0
- package/build/actions/list-schemas.js.map +1 -0
- package/build/actions/list-specification-revisions.d.ts +6 -0
- package/build/actions/list-specification-revisions.d.ts.map +1 -0
- package/build/actions/list-specification-revisions.js +10 -0
- package/build/actions/list-specification-revisions.js.map +1 -0
- package/build/actions/resources.d.ts +5 -0
- package/build/actions/resources.d.ts.map +1 -0
- package/build/actions/resources.js +111 -0
- package/build/actions/resources.js.map +1 -0
- package/build/actions/summarize-cards.d.ts +6 -0
- package/build/actions/summarize-cards.d.ts.map +1 -0
- package/build/actions/summarize-cards.js +11 -0
- package/build/actions/summarize-cards.js.map +1 -0
- package/build/actions/transitions.d.ts +3 -3
- package/build/actions/transitions.d.ts.map +1 -1
- package/build/actions/transitions.js +4 -3
- package/build/actions/transitions.js.map +1 -1
- package/build/actions/types.d.ts +6 -0
- package/build/actions/types.d.ts.map +1 -0
- package/build/actions/types.js +2 -0
- package/build/actions/types.js.map +1 -0
- package/build/actions/watch.d.ts +2 -2
- package/build/actions/watch.d.ts.map +1 -1
- package/build/actions/watch.js +8 -6
- package/build/actions/watch.js.map +1 -1
- package/build/conformance/assert/types.d.ts +19 -0
- package/build/conformance/assert/types.d.ts.map +1 -0
- package/build/conformance/assert/types.js +2 -0
- package/build/conformance/assert/types.js.map +1 -0
- package/build/conformance/assert.d.ts +15 -0
- package/build/conformance/assert.d.ts.map +1 -0
- package/build/conformance/assert.js +52 -0
- package/build/conformance/assert.js.map +1 -0
- package/build/conformance/cases.d.ts +7 -0
- package/build/conformance/cases.d.ts.map +1 -0
- package/build/conformance/cases.js +544 -0
- package/build/conformance/cases.js.map +1 -0
- package/build/conformance/clock.d.ts +6 -0
- package/build/conformance/clock.d.ts.map +1 -0
- package/build/conformance/clock.js +12 -0
- package/build/conformance/clock.js.map +1 -0
- package/build/conformance/consts.d.ts +30 -0
- package/build/conformance/consts.d.ts.map +1 -0
- package/build/conformance/consts.js +159 -0
- package/build/conformance/consts.js.map +1 -0
- package/build/conformance/errors.d.ts +5 -0
- package/build/conformance/errors.d.ts.map +1 -0
- package/build/conformance/errors.js +8 -0
- package/build/conformance/errors.js.map +1 -0
- package/build/conformance/fixtures/types.d.ts +13 -0
- package/build/conformance/fixtures/types.d.ts.map +1 -0
- package/build/conformance/fixtures/types.js +2 -0
- package/build/conformance/fixtures/types.js.map +1 -0
- package/build/conformance/fixtures.d.ts +14 -0
- package/build/conformance/fixtures.d.ts.map +1 -0
- package/build/conformance/fixtures.js +26 -0
- package/build/conformance/fixtures.js.map +1 -0
- package/build/conformance/index.d.ts +15 -0
- package/build/conformance/index.d.ts.map +1 -0
- package/build/conformance/index.js +12 -0
- package/build/conformance/index.js.map +1 -0
- package/build/conformance/resources.d.ts +4 -0
- package/build/conformance/resources.d.ts.map +1 -0
- package/build/conformance/resources.js +228 -0
- package/build/conformance/resources.js.map +1 -0
- package/build/conformance/types.d.ts +18 -0
- package/build/conformance/types.d.ts.map +1 -0
- package/build/conformance/types.js +2 -0
- package/build/conformance/types.js.map +1 -0
- package/build/consts.d.ts +5 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +5 -0
- package/build/consts.js.map +1 -1
- package/build/definitions.d.ts +18 -0
- package/build/definitions.d.ts.map +1 -0
- package/build/definitions.js +225 -0
- package/build/definitions.js.map +1 -0
- package/build/executor/changes/types.d.ts +36 -0
- package/build/executor/changes/types.d.ts.map +1 -0
- package/build/executor/changes/types.js +2 -0
- package/build/executor/changes/types.js.map +1 -0
- package/build/executor/changes.d.ts +3 -30
- package/build/executor/changes.d.ts.map +1 -1
- package/build/executor/changes.js +42 -51
- package/build/executor/changes.js.map +1 -1
- package/build/executor/code/types.d.ts +17 -0
- package/build/executor/code/types.d.ts.map +1 -0
- package/build/executor/code/types.js +2 -0
- package/build/executor/code/types.js.map +1 -0
- package/build/executor/code.d.ts +3 -14
- package/build/executor/code.d.ts.map +1 -1
- package/build/executor/code.js +50 -54
- package/build/executor/code.js.map +1 -1
- package/build/executor/consts.local.d.ts +5 -0
- package/build/executor/consts.local.d.ts.map +1 -0
- package/build/executor/consts.local.js +6 -0
- package/build/executor/consts.local.js.map +1 -0
- package/build/executor/creator/types.d.ts +33 -0
- package/build/executor/creator/types.d.ts.map +1 -0
- package/build/executor/creator/types.js +2 -0
- package/build/executor/creator/types.js.map +1 -0
- package/build/executor/creator.d.ts +11 -0
- package/build/executor/creator.d.ts.map +1 -0
- package/build/executor/creator.js +32 -0
- package/build/executor/creator.js.map +1 -0
- package/build/executor/resolve/types.d.ts +30 -0
- package/build/executor/resolve/types.d.ts.map +1 -0
- package/build/executor/resolve/types.js +2 -0
- package/build/executor/resolve/types.js.map +1 -0
- package/build/executor/resolve.d.ts +5 -34
- package/build/executor/resolve.d.ts.map +1 -1
- package/build/executor/resolve.js +169 -110
- package/build/executor/resolve.js.map +1 -1
- package/build/executor/types.d.ts +23 -0
- package/build/executor/types.d.ts.map +1 -0
- package/build/executor/types.js +2 -0
- package/build/executor/types.js.map +1 -0
- package/build/executor/validate.d.ts +6 -5
- package/build/executor/validate.d.ts.map +1 -1
- package/build/executor/validate.js +38 -27
- package/build/executor/validate.js.map +1 -1
- package/build/executor.d.ts +11 -7
- package/build/executor.d.ts.map +1 -1
- package/build/executor.js +27 -21
- package/build/executor.js.map +1 -1
- package/build/facade.d.ts +20 -2
- package/build/facade.d.ts.map +1 -1
- package/build/facade.js +144 -22
- package/build/facade.js.map +1 -1
- package/build/helper.d.ts +5 -9
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +12 -11
- package/build/helper.js.map +1 -1
- package/build/hierarchy/types.d.ts +20 -0
- package/build/hierarchy/types.d.ts.map +1 -0
- package/build/hierarchy/types.js +2 -0
- package/build/hierarchy/types.js.map +1 -0
- package/build/hierarchy.d.ts +5 -0
- package/build/hierarchy.d.ts.map +1 -0
- package/build/hierarchy.js +133 -0
- package/build/hierarchy.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/invariants/types.d.ts +6 -0
- package/build/invariants/types.d.ts.map +1 -0
- package/build/invariants/types.js +2 -0
- package/build/invariants/types.js.map +1 -0
- package/build/invariants.d.ts +5 -0
- package/build/invariants.d.ts.map +1 -0
- package/build/invariants.js +126 -0
- package/build/invariants.js.map +1 -0
- package/build/projection.d.ts +4 -10
- package/build/projection.d.ts.map +1 -1
- package/build/projection.js +7 -5
- package/build/projection.js.map +1 -1
- package/build/queue/consts.d.ts +5 -0
- package/build/queue/consts.d.ts.map +1 -0
- package/build/queue/consts.js +5 -0
- package/build/queue/consts.js.map +1 -0
- package/build/queue/declare.d.ts +5 -0
- package/build/queue/declare.d.ts.map +1 -0
- package/build/queue/declare.js +5 -0
- package/build/queue/declare.js.map +1 -0
- package/build/queue/index.d.ts +3 -18
- package/build/queue/index.d.ts.map +1 -1
- package/build/queue/index.js +2 -7
- package/build/queue/index.js.map +1 -1
- package/build/queue/types.d.ts +13 -0
- package/build/queue/types.d.ts.map +1 -0
- package/build/queue/types.js +2 -0
- package/build/queue/types.js.map +1 -0
- package/build/registry.d.ts +5 -22
- package/build/registry.d.ts.map +1 -1
- package/build/registry.js +16 -10
- package/build/registry.js.map +1 -1
- package/build/resources.d.ts +5 -0
- package/build/resources.d.ts.map +1 -0
- package/build/resources.js +287 -0
- package/build/resources.js.map +1 -0
- package/build/service.d.ts +3 -16
- package/build/service.d.ts.map +1 -1
- package/build/service.js +12 -0
- package/build/service.js.map +1 -1
- package/build/store/commits.d.ts.map +1 -1
- package/build/store/commits.js +3 -1
- package/build/store/commits.js.map +1 -1
- package/build/store/composite.d.ts +1 -0
- package/build/store/composite.d.ts.map +1 -1
- package/build/store/composite.js +7 -2
- package/build/store/composite.js.map +1 -1
- package/build/store/consts.local.d.ts +2 -0
- package/build/store/consts.local.d.ts.map +1 -0
- package/build/store/consts.local.js +2 -0
- package/build/store/consts.local.js.map +1 -0
- package/build/store/fold/types.d.ts +43 -0
- package/build/store/fold/types.d.ts.map +1 -0
- package/build/store/fold/types.js +2 -0
- package/build/store/fold/types.js.map +1 -0
- package/build/store/fold.d.ts +8 -30
- package/build/store/fold.d.ts.map +1 -1
- package/build/store/fold.js +190 -198
- package/build/store/fold.js.map +1 -1
- package/build/store/index.d.ts +1 -0
- package/build/store/index.d.ts.map +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/memory.d.ts +12 -0
- package/build/store/memory.d.ts.map +1 -1
- package/build/store/memory.js +0 -0
- package/build/store/memory.js.map +1 -1
- package/build/store/types.d.ts +15 -1
- package/build/store/types.d.ts.map +1 -1
- package/build/store/types.local.d.ts +5 -0
- package/build/store/types.local.d.ts.map +1 -0
- package/build/store/types.local.js +2 -0
- package/build/store/types.local.js.map +1 -0
- package/build/types.d.ts +126 -2
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +7 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/utils/access/types.d.ts +30 -0
- package/build/utils/access/types.d.ts.map +1 -0
- package/build/utils/access/types.js +2 -0
- package/build/utils/access/types.js.map +1 -0
- package/build/utils/access.d.ts +4 -0
- package/build/utils/access.d.ts.map +1 -0
- package/build/utils/access.js +28 -0
- package/build/utils/access.js.map +1 -0
- package/build/utils/guard/types.d.ts +23 -0
- package/build/utils/guard/types.d.ts.map +1 -0
- package/build/utils/guard/types.js +2 -0
- package/build/utils/guard/types.js.map +1 -0
- package/build/utils/guard.d.ts +7 -10
- package/build/utils/guard.d.ts.map +1 -1
- package/build/utils/guard.js +36 -32
- package/build/utils/guard.js.map +1 -1
- package/build/utils/handler/types.d.ts +26 -0
- package/build/utils/handler/types.d.ts.map +1 -0
- package/build/utils/handler/types.js +2 -0
- package/build/utils/handler/types.js.map +1 -0
- package/build/utils/handler.d.ts +6 -0
- package/build/utils/handler.d.ts.map +1 -0
- package/build/utils/handler.js +21 -0
- package/build/utils/handler.js.map +1 -0
- package/build/utils/index.d.ts +8 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +3 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/request/types.d.ts +23 -0
- package/build/utils/request/types.d.ts.map +1 -0
- package/build/utils/request/types.js +2 -0
- package/build/utils/request/types.js.map +1 -0
- package/build/utils/request.d.ts +4 -0
- package/build/utils/request.d.ts.map +1 -0
- package/build/utils/request.js +27 -0
- package/build/utils/request.js.map +1 -0
- package/build/utils/scope.d.ts +17 -13
- package/build/utils/scope.d.ts.map +1 -1
- package/build/utils/scope.js +21 -35
- package/build/utils/scope.js.map +1 -1
- package/build/utils/types.d.ts +8 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/package.json +30 -22
- package/src/actions/apply-schema-request.ts +36 -0
- package/src/actions/commit.ts +7 -5
- package/src/actions/define-schemas.ts +34 -0
- package/src/actions/execute.ts +32 -34
- package/src/actions/execution/types.ts +34 -0
- package/src/actions/execution.ts +100 -0
- package/src/actions/get-card.ts +14 -0
- package/src/actions/get-specification.ts +14 -0
- package/src/actions/index.ts +13 -3
- package/src/actions/links.ts +8 -6
- package/src/actions/list-card-specifications.ts +15 -0
- package/src/actions/list-card-transitions.ts +15 -0
- package/src/actions/list-cards.ts +14 -0
- package/src/actions/list-schemas.ts +29 -0
- package/src/actions/list-specification-revisions.ts +15 -0
- package/src/actions/resources.ts +79 -0
- package/src/actions/summarize-cards.ts +15 -0
- package/src/actions/transitions.ts +6 -4
- package/src/actions/types.ts +5 -0
- package/src/actions/watch.ts +11 -7
- package/src/conformance/assert/types.ts +16 -0
- package/src/conformance/assert.ts +67 -0
- package/src/conformance/cases.ts +631 -0
- package/src/conformance/clock.ts +11 -0
- package/src/conformance/consts.ts +165 -0
- package/src/conformance/errors.ts +7 -0
- package/src/conformance/fixtures/types.ts +11 -0
- package/src/conformance/fixtures.ts +46 -0
- package/src/conformance/index.ts +14 -0
- package/src/conformance/resources.ts +227 -0
- package/src/conformance/types.ts +20 -0
- package/src/consts.ts +6 -0
- package/src/definitions.ts +264 -0
- package/src/executor/changes/types.ts +38 -0
- package/src/executor/changes.ts +49 -68
- package/src/executor/code/types.ts +23 -0
- package/src/executor/code.ts +62 -69
- package/src/executor/consts.local.ts +8 -0
- package/src/executor/creator/types.ts +33 -0
- package/src/executor/creator.ts +43 -0
- package/src/executor/resolve/types.ts +30 -0
- package/src/executor/resolve.ts +181 -139
- package/src/executor/types.ts +23 -0
- package/src/executor/validate.ts +40 -38
- package/src/executor.ts +33 -27
- package/src/facade.ts +132 -29
- package/src/helper.ts +12 -11
- package/src/hierarchy/types.ts +20 -0
- package/src/hierarchy.ts +113 -0
- package/src/index.ts +1 -0
- package/src/invariants/types.ts +6 -0
- package/src/invariants.ts +106 -0
- package/src/projection.ts +12 -18
- package/src/queue/consts.ts +5 -0
- package/src/queue/declare.ts +7 -0
- package/src/queue/index.ts +3 -25
- package/src/queue/types.ts +14 -0
- package/src/registry.ts +18 -36
- package/src/resources.ts +256 -0
- package/src/service.ts +16 -20
- package/src/store/commits.ts +5 -4
- package/src/store/composite.ts +7 -2
- package/src/store/consts.local.ts +1 -0
- package/src/store/fold/types.ts +44 -0
- package/src/store/fold.ts +214 -212
- package/src/store/index.ts +1 -0
- package/src/store/memory.ts +0 -0
- package/src/store/types.local.ts +3 -0
- package/src/store/types.ts +16 -1
- package/src/types.local.ts +7 -0
- package/src/types.ts +139 -6
- package/src/utils/access/types.ts +30 -0
- package/src/utils/access.ts +33 -0
- package/src/utils/guard/types.ts +21 -0
- package/src/utils/guard.ts +44 -31
- package/src/utils/handler/types.ts +28 -0
- package/src/utils/handler.ts +35 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/request/types.ts +23 -0
- package/src/utils/request.ts +40 -0
- package/src/utils/scope.ts +39 -42
- package/src/utils/types.ts +8 -0
- package/tests/access.spec.ts +160 -0
- package/tests/app.spec.ts +112 -0
- package/tests/conformance.spec.ts +47 -0
- package/tests/create-example.spec.ts +202 -0
- package/tests/creator.spec.ts +257 -0
- package/tests/entrypoints.spec.ts +5 -0
- package/tests/memory-store.spec.ts +52 -0
- package/tests/narrowing.spec.ts +94 -0
- package/tests/plugins.spec.ts +4 -3
- package/tests/writes.spec.ts +140 -0
- package/build/actions/cards.d.ts +0 -16
- package/build/actions/cards.d.ts.map +0 -1
- package/build/actions/cards.js +0 -32
- package/build/actions/cards.js.map +0 -1
- package/build/actions/schemas.d.ts +0 -6
- package/build/actions/schemas.d.ts.map +0 -1
- package/build/actions/schemas.js +0 -9
- package/build/actions/schemas.js.map +0 -1
- package/build/actions/specs.d.ts +0 -10
- package/build/actions/specs.d.ts.map +0 -1
- package/build/actions/specs.js +0 -14
- package/build/actions/specs.js.map +0 -1
- package/src/actions/cards.ts +0 -52
- package/src/actions/schemas.ts +0 -15
- package/src/actions/specs.ts +0 -23
package/build/utils/index.js
CHANGED
package/build/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAMA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PlanningScope, TransitionActor } from '@owlmeans/planning';
|
|
2
|
+
import type { PlanningAccess } from '../../types.js';
|
|
3
|
+
/** One request's identity as planning reads it — built at the top of a handler, never stored. */
|
|
4
|
+
export interface RequestScope {
|
|
5
|
+
/** The authenticated subject of a request, as a transition names it. */
|
|
6
|
+
actorOf: () => TransitionActor;
|
|
7
|
+
/**
|
|
8
|
+
* The scope a request reads and writes as.
|
|
9
|
+
*
|
|
10
|
+
* `entityId` is `requireEntityKey(req)` — the resolved organization id, never a value from the
|
|
11
|
+
* body or the query — and `extra` cannot replace it; `extra` adds what the deployment derives
|
|
12
|
+
* (a `channel`, a `service`). The actor is the authenticated subject plus that channel.
|
|
13
|
+
*
|
|
14
|
+
* @throws {AuthorizationError} when the request carries no organization
|
|
15
|
+
*/
|
|
16
|
+
scopeOf: (extra?: Partial<PlanningScope>) => PlanningScope;
|
|
17
|
+
/**
|
|
18
|
+
* The scope of a request under a resolved {@link PlanningAccess}: the organization is the
|
|
19
|
+
* resolver's — never the token's, never `extra`'s — and `projects` narrows it.
|
|
20
|
+
*/
|
|
21
|
+
accessScopeOf: (access: PlanningAccess, extra?: Partial<PlanningScope>) => PlanningScope;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/request/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,OAAO,EAAE,MAAM,eAAe,CAAA;IAC9B;;;;;;;;OAQG;IACH,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,aAAa,CAAA;IAC1D;;;OAGG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,aAAa,CAAA;CACzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/request/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMtD,eAAO,MAAM,gBAAgB,QAAS,eAAe,KAAG,YA6BvD,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { makeEntityScope } from '@owlmeans/auth-common';
|
|
2
|
+
const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value != null && value !== ''));
|
|
3
|
+
export const makeRequestScope = (req) => {
|
|
4
|
+
const actorOf = () => clean({
|
|
5
|
+
profileId: req.auth?.profileId,
|
|
6
|
+
userId: req.auth?.userId,
|
|
7
|
+
});
|
|
8
|
+
const scopeWith = (entityId, extra) => {
|
|
9
|
+
const subject = actorOf();
|
|
10
|
+
const channel = extra?.channel ?? extra?.actor?.channel;
|
|
11
|
+
return clean({
|
|
12
|
+
...extra,
|
|
13
|
+
...subject,
|
|
14
|
+
entityId,
|
|
15
|
+
channel,
|
|
16
|
+
actor: clean({ ...extra?.actor, ...subject, channel }),
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const scopeOf = (extra) => scopeWith(makeEntityScope(req).requireEntityKey(), extra);
|
|
20
|
+
const accessScopeOf = (access, extra) => {
|
|
21
|
+
const { projects: _projects, entityId: _entityId, ...rest } = extra ?? {};
|
|
22
|
+
const scope = scopeWith(access.entityId, rest);
|
|
23
|
+
return access.projects != null ? { ...scope, projects: [...access.projects] } : scope;
|
|
24
|
+
};
|
|
25
|
+
return { actorOf, scopeOf, accessScopeOf };
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,KAAK,GAAG,CAAmB,MAAS,EAAK,EAAE,CAC/C,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC,CAAM,CAAA;AAEtG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAAgB,EAAE;IACrE,MAAM,OAAO,GAAG,GAAoB,EAAE,CAAC,KAAK,CAAC;QAC3C,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS;QAC9B,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM;KACzB,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,KAA8B,EAAiB,EAAE;QACpF,MAAM,OAAO,GAAG,OAAO,EAAE,CAAA;QACzB,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,KAAK,EAAE,OAAO,CAAA;QAEvD,OAAO,KAAK,CAAC;YACX,GAAG,KAAK;YACR,GAAG,OAAO;YACV,QAAQ;YACR,OAAO;YACP,KAAK,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;SACvD,CAAkB,CAAA;IACrB,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,CAAC,KAA8B,EAAiB,EAAE,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC,CAAA;IAE5H,MAAM,aAAa,GAAG,CAAC,MAAsB,EAAE,KAA8B,EAAiB,EAAE;QAC9F,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAA;QACzE,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAE9C,OAAO,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;IACvF,CAAC,CAAA;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA;AAC5C,CAAC,CAAA"}
|
package/build/utils/scope.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
2
2
|
import type { AbstractRequest } from '@owlmeans/entrypoint';
|
|
3
|
-
import type { PlanningFacade, PlanningScope, PlanningService, TransitionActor } from '@owlmeans/planning';
|
|
4
|
-
import type { PlanningHandlerOptions } from '../types.js';
|
|
5
|
-
|
|
3
|
+
import type { PlanningFacade, PlanningScope, PlanningService, TransitionActor, Workcard } from '@owlmeans/planning';
|
|
4
|
+
import type { PlanningAccess, PlanningAccessGrants, PlanningHandlerOptions } from '../types.js';
|
|
5
|
+
import type { HandlerScope } from './types.js';
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `makeRequestScope(req).actorOf()` */
|
|
6
7
|
export declare const actorOf: (req: AbstractRequest) => TransitionActor;
|
|
7
|
-
/**
|
|
8
|
-
* The scope a request reads and writes as.
|
|
9
|
-
*
|
|
10
|
-
* `entityId` is `requireEntityKey(req)` — the resolved organization id, never a value from the
|
|
11
|
-
* body or the query — and `extra` cannot replace it; `extra` adds what the deployment derives
|
|
12
|
-
* (a `channel`, a `service`). The actor is the authenticated subject plus that channel.
|
|
13
|
-
*
|
|
14
|
-
* @throws {AuthorizationError} when the request carries no organization
|
|
15
|
-
*/
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `makeRequestScope(req).scopeOf(…)` */
|
|
16
9
|
export declare const scopeOf: (req: AbstractRequest, extra?: Partial<PlanningScope>) => PlanningScope;
|
|
10
|
+
/** @deprecated compat:factory-refactor — use `makeRequestScope(req).accessScopeOf(…)` */
|
|
11
|
+
export declare const accessScopeOf: (req: AbstractRequest, access: PlanningAccess, extra?: Partial<PlanningScope>) => PlanningScope;
|
|
12
|
+
/** @deprecated compat:factory-refactor — use `planningHandlerOf(ctx).planningServiceOf(…)` */
|
|
17
13
|
export declare const planningServiceOf: (ctx: BasicContext<BasicConfig>, opts?: Pick<PlanningHandlerOptions, 'service'>) => PlanningService;
|
|
18
|
-
/**
|
|
14
|
+
/** @deprecated compat:factory-refactor — use `planningHandlerOf(ctx).handlerScopeOf(…)` */
|
|
15
|
+
export declare const handlerScopeOf: (ctx: BasicContext<BasicConfig>, req: AbstractRequest, opts?: PlanningHandlerOptions) => Promise<HandlerScope>;
|
|
16
|
+
/** @deprecated compat:factory-refactor — use `planningHandlerOf(ctx).handlerFacade(…)` */
|
|
19
17
|
export declare const handlerFacade: (ctx: BasicContext<BasicConfig>, req: AbstractRequest, opts?: PlanningHandlerOptions) => Promise<PlanningFacade>;
|
|
18
|
+
/** @deprecated compat:factory-refactor — use `makePlanningAccessModel(access).assertGranted(…)` */
|
|
19
|
+
export declare const assertGranted: (access: PlanningAccess | undefined, grant: keyof PlanningAccessGrants, target?: string) => void;
|
|
20
|
+
/** @deprecated compat:factory-refactor — use `makePlanningAccessModel(access).writableIn(…)` */
|
|
21
|
+
export declare const writableIn: (access: PlanningAccess | undefined, card: Pick<Workcard, 'id' | 'parents'>) => boolean;
|
|
22
|
+
/** @deprecated compat:factory-refactor — use `makePlanningAccessModel(access).assertWrites(…)` */
|
|
23
|
+
export declare const assertWrites: (access: PlanningAccess | undefined, target?: string) => void;
|
|
20
24
|
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/utils/scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/utils/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACnH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAI/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,kFAAkF;AAClF,eAAO,MAAM,OAAO,QAAS,eAAe,KAAG,eAAkD,CAAA;AAEjG,mFAAmF;AACnF,eAAO,MAAM,OAAO,QAAS,eAAe,UAAU,OAAO,CAAC,aAAa,CAAC,KAAG,aACzC,CAAA;AAEtC,yFAAyF;AACzF,eAAO,MAAM,aAAa,QACnB,eAAe,UAAU,cAAc,UAAU,OAAO,CAAC,aAAa,CAAC,KAC3E,aAAmE,CAAA;AAEtE,8FAA8F;AAC9F,eAAO,MAAM,iBAAiB,QACvB,YAAY,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,KAC7E,eAAiE,CAAA;AAEpE,2FAA2F;AAC3F,eAAO,MAAM,cAAc,QACpB,YAAY,CAAC,WAAW,CAAC,OAAO,eAAe,SAAS,sBAAsB,KAClF,OAAO,CAAC,YAAY,CAA2D,CAAA;AAElF,0FAA0F;AAC1F,eAAO,MAAM,aAAa,QACnB,YAAY,CAAC,WAAW,CAAC,OAAO,eAAe,SAAS,sBAAsB,KAClF,OAAO,CAAC,cAAc,CAA0D,CAAA;AAEnF,mGAAmG;AACnG,eAAO,MAAM,aAAa,WAChB,cAAc,GAAG,SAAS,SAAS,MAAM,oBAAoB,WAAW,MAAM,KACrF,IAAoE,CAAA;AAEvE,gGAAgG;AAChG,eAAO,MAAM,UAAU,WAAY,cAAc,GAAG,SAAS,QAAQ,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC,KAAG,OACtD,CAAA;AAElD,kGAAkG;AAClG,eAAO,MAAM,YAAY,WAAY,cAAc,GAAG,SAAS,WAAW,MAAM,KAAG,IAC7B,CAAA"}
|
package/build/utils/scope.js
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
export const actorOf = (req) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return clean({
|
|
23
|
-
...extra,
|
|
24
|
-
...subject,
|
|
25
|
-
entityId,
|
|
26
|
-
channel,
|
|
27
|
-
actor: clean({ ...extra?.actor, ...subject, channel }),
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
export const planningServiceOf = (ctx, opts) => ctx.service(opts?.service ?? PLANNING_SERVICE);
|
|
31
|
-
/** The facade a handler works through: the request's scope plus what `opts.scope` derives. */
|
|
32
|
-
export const handlerFacade = async (ctx, req, opts) => {
|
|
33
|
-
const extra = await opts?.scope?.(req, ctx);
|
|
34
|
-
return planningServiceOf(ctx, opts).for(scopeOf(req, extra ?? undefined));
|
|
35
|
-
};
|
|
1
|
+
import { makePlanningAccessModel } from './access.js';
|
|
2
|
+
import { planningHandlerOf } from './handler.js';
|
|
3
|
+
import { makeRequestScope } from './request.js';
|
|
4
|
+
/** @deprecated compat:factory-refactor — use `makeRequestScope(req).actorOf()` */
|
|
5
|
+
export const actorOf = (req) => makeRequestScope(req).actorOf();
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `makeRequestScope(req).scopeOf(…)` */
|
|
7
|
+
export const scopeOf = (req, extra) => makeRequestScope(req).scopeOf(extra);
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `makeRequestScope(req).accessScopeOf(…)` */
|
|
9
|
+
export const accessScopeOf = (req, access, extra) => makeRequestScope(req).accessScopeOf(access, extra);
|
|
10
|
+
/** @deprecated compat:factory-refactor — use `planningHandlerOf(ctx).planningServiceOf(…)` */
|
|
11
|
+
export const planningServiceOf = (ctx, opts) => planningHandlerOf(ctx).planningServiceOf(opts);
|
|
12
|
+
/** @deprecated compat:factory-refactor — use `planningHandlerOf(ctx).handlerScopeOf(…)` */
|
|
13
|
+
export const handlerScopeOf = async (ctx, req, opts) => await planningHandlerOf(ctx).handlerScopeOf(req, opts);
|
|
14
|
+
/** @deprecated compat:factory-refactor — use `planningHandlerOf(ctx).handlerFacade(…)` */
|
|
15
|
+
export const handlerFacade = async (ctx, req, opts) => await planningHandlerOf(ctx).handlerFacade(req, opts);
|
|
16
|
+
/** @deprecated compat:factory-refactor — use `makePlanningAccessModel(access).assertGranted(…)` */
|
|
17
|
+
export const assertGranted = (access, grant, target) => makePlanningAccessModel(access).assertGranted(grant, target);
|
|
18
|
+
/** @deprecated compat:factory-refactor — use `makePlanningAccessModel(access).writableIn(…)` */
|
|
19
|
+
export const writableIn = (access, card) => makePlanningAccessModel(access).writableIn(card);
|
|
20
|
+
/** @deprecated compat:factory-refactor — use `makePlanningAccessModel(access).assertWrites(…)` */
|
|
21
|
+
export const assertWrites = (access, target) => makePlanningAccessModel(access).assertWrites(target);
|
|
36
22
|
//# sourceMappingURL=scope.js.map
|
package/build/utils/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/utils/scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/utils/scope.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,kFAAkF;AAClF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAoB,EAAmB,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAA;AAEjG,mFAAmF;AACnF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAoB,EAAE,KAA8B,EAAiB,EAAE,CAC7F,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtC,yFAAyF;AACzF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAoB,EAAE,MAAsB,EAAE,KAA8B,EAC7D,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEtE,8FAA8F;AAC9F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAA8B,EAAE,IAA8C,EAC7D,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAEpE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,GAA8B,EAAE,GAAoB,EAAE,IAA6B,EAC5D,EAAE,CAAC,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAElF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,GAA8B,EAAE,GAAoB,EAAE,IAA6B,EAC1D,EAAE,CAAC,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAEnF,mGAAmG;AACnG,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAAkC,EAAE,KAAiC,EAAE,MAAe,EAChF,EAAE,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAEvE,gGAAgG;AAChG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAkC,EAAE,IAAsC,EAAW,EAAE,CAChH,uBAAuB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAElD,kGAAkG;AAClG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAkC,EAAE,MAAe,EAAQ,EAAE,CACxF,uBAAuB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PlanningFacade } from '@owlmeans/planning';
|
|
2
|
+
import type { PlanningAccess } from '../types.js';
|
|
3
|
+
export interface HandlerScope {
|
|
4
|
+
facade: PlanningFacade;
|
|
5
|
+
/** The resolver's answer, when the handler options carry one. */
|
|
6
|
+
access?: PlanningAccess;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,cAAc,CAAA;IACtB,iEAAiE;IACjE,MAAM,CAAC,EAAE,cAAc,CAAA;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-planning",
|
|
3
|
-
"version": "0.1.18
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "The general planning implementation
|
|
5
|
+
"description": "The general planning implementation \u2014 the planning service and its plugin/middleware registry, the transition executor, the in-memory store, the protocol handlers and the commit feed.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc -b",
|
|
@@ -34,35 +34,43 @@
|
|
|
34
34
|
"default": "./build/queue/index.js",
|
|
35
35
|
"module": "./build/queue/index.js",
|
|
36
36
|
"types": "./build/queue/index.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./conformance": {
|
|
39
|
+
"import": "./build/conformance/index.js",
|
|
40
|
+
"require": "./build/conformance/index.js",
|
|
41
|
+
"default": "./build/conformance/index.js",
|
|
42
|
+
"module": "./build/conformance/index.js",
|
|
43
|
+
"types": "./build/conformance/index.d.ts"
|
|
37
44
|
}
|
|
38
45
|
},
|
|
39
46
|
"dependencies": {
|
|
40
|
-
"@owlmeans/auth": "^0.1.18
|
|
41
|
-
"@owlmeans/auth-common": "^0.1.18
|
|
42
|
-
"@owlmeans/basic-ids": "^0.1.18
|
|
43
|
-
"@owlmeans/context": "^0.1.18
|
|
44
|
-
"@owlmeans/entrypoint": "^0.1.18
|
|
45
|
-
"@owlmeans/error": "^0.1.18
|
|
46
|
-
"@owlmeans/planning": "^0.1.18
|
|
47
|
-
"@owlmeans/queue": "^0.1.18
|
|
48
|
-
"@owlmeans/resource": "^0.1.18
|
|
49
|
-
"@owlmeans/
|
|
50
|
-
"@owlmeans/
|
|
51
|
-
"@owlmeans/server-
|
|
52
|
-
"@owlmeans/server-
|
|
53
|
-
"@owlmeans/server-
|
|
54
|
-
"@owlmeans/socket": "^0.1.18
|
|
47
|
+
"@owlmeans/auth": "^0.1.18",
|
|
48
|
+
"@owlmeans/auth-common": "^0.1.18",
|
|
49
|
+
"@owlmeans/basic-ids": "^0.1.18",
|
|
50
|
+
"@owlmeans/context": "^0.1.18",
|
|
51
|
+
"@owlmeans/entrypoint": "^0.1.18",
|
|
52
|
+
"@owlmeans/error": "^0.1.18",
|
|
53
|
+
"@owlmeans/planning": "^0.1.18",
|
|
54
|
+
"@owlmeans/queue": "^0.1.18",
|
|
55
|
+
"@owlmeans/resource": "^0.1.18",
|
|
56
|
+
"@owlmeans/log": "^0.1.18",
|
|
57
|
+
"@owlmeans/route": "^0.1.18",
|
|
58
|
+
"@owlmeans/server-api": "^0.1.18",
|
|
59
|
+
"@owlmeans/server-context": "^0.1.18",
|
|
60
|
+
"@owlmeans/server-entrypoint": "^0.1.18",
|
|
61
|
+
"@owlmeans/server-socket": "^0.1.18",
|
|
62
|
+
"@owlmeans/socket": "^0.1.18"
|
|
55
63
|
},
|
|
56
64
|
"peerDependencies": {
|
|
57
65
|
"ajv": "*",
|
|
58
66
|
"ajv-formats": "*"
|
|
59
67
|
},
|
|
60
68
|
"devDependencies": {
|
|
61
|
-
"@owlmeans/dep-config": "
|
|
62
|
-
"@owlmeans/test": "^0.1.18
|
|
63
|
-
"@types/bun": "^1.4.
|
|
64
|
-
"@types/node": "^26.
|
|
65
|
-
"ajv": "^8.
|
|
69
|
+
"@owlmeans/dep-config": "^0.1.18",
|
|
70
|
+
"@owlmeans/test": "^0.1.18",
|
|
71
|
+
"@types/bun": "^1.4.2",
|
|
72
|
+
"@types/node": "^26.6.4",
|
|
73
|
+
"ajv": "^8.20.0",
|
|
66
74
|
"ajv-formats": "^3.0.1",
|
|
67
75
|
"nodemon": "^3.1.14",
|
|
68
76
|
"typescript": "^7.0.2"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SchemaWriteMode, type PlanningDefinitions, type SchemaDefineReply, type SchemaDefineRequest, type ScopedSchemaRecord } from '@owlmeans/planning'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Apply one `schema.define` request to a facade's definitions: the declarations in the request's
|
|
5
|
+
* mode (flows before types), then the retirements — answering what was written and the layer as it
|
|
6
|
+
* resolves afterwards.
|
|
7
|
+
*/
|
|
8
|
+
export const applySchemaRequest = async (
|
|
9
|
+
definitions: PlanningDefinitions, request: SchemaDefineRequest
|
|
10
|
+
): Promise<SchemaDefineReply> => {
|
|
11
|
+
const layer = request.project != null ? { project: request.project } : {}
|
|
12
|
+
const declarations = { types: request.types ?? [], flows: request.flows ?? [], assigneeTypes: request.assigneeTypes ?? [] }
|
|
13
|
+
const records: ScopedSchemaRecord[] = []
|
|
14
|
+
|
|
15
|
+
switch (request.mode ?? SchemaWriteMode.Define) {
|
|
16
|
+
case SchemaWriteMode.Put:
|
|
17
|
+
for (const schema of declarations.assigneeTypes) records.push(await definitions.putAssigneeType(schema))
|
|
18
|
+
for (const flow of declarations.flows) {
|
|
19
|
+
records.push(await definitions.putFlow(flow, layer))
|
|
20
|
+
}
|
|
21
|
+
for (const type of declarations.types) {
|
|
22
|
+
records.push(await definitions.putType(type, layer))
|
|
23
|
+
}
|
|
24
|
+
break
|
|
25
|
+
case SchemaWriteMode.Seed:
|
|
26
|
+
records.push(...await definitions.seed(declarations, layer))
|
|
27
|
+
break
|
|
28
|
+
default:
|
|
29
|
+
records.push(...await definitions.define(declarations, layer))
|
|
30
|
+
}
|
|
31
|
+
for (const key of request.retire ?? []) {
|
|
32
|
+
records.push(await definitions.retire(key.kind, key.key, layer))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { records, bundle: await definitions.bundle(request.project) }
|
|
36
|
+
}
|
package/src/actions/commit.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { handlers } from '@owlmeans/server-api'
|
|
|
2
2
|
import { CommitState, MAX_COMMIT_POLL } from '@owlmeans/planning'
|
|
3
3
|
import type { CommitStatus, PlanningProtocols } from '@owlmeans/planning'
|
|
4
4
|
import type { Context, PlanningHandlerOptions } from '../types.js'
|
|
5
|
-
import {
|
|
5
|
+
import { guardHelper } from '../utils/guard.js'
|
|
6
|
+
import { planningHandlerOf } from '../utils/handler.js'
|
|
7
|
+
import type { RequestHandler } from './types.js'
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* The poll tool: a commit's status, held open up to `wait` seconds (clamped to `maxPoll`).
|
|
@@ -15,13 +17,13 @@ import { clampSeconds, concealed, handlerFacade } from '../utils/index.js'
|
|
|
15
17
|
*/
|
|
16
18
|
export const getCommit = (
|
|
17
19
|
protocol: PlanningProtocols['commit']['get'], opts?: PlanningHandlerOptions
|
|
18
|
-
):
|
|
19
|
-
handlers<Context>().request(protocol, async (req, ctx) =>
|
|
20
|
-
const facade = await handlerFacade(
|
|
20
|
+
): RequestHandler =>
|
|
21
|
+
handlers<Context>().request(protocol, async (req, ctx) => guardHelper.reply(async (): Promise<CommitStatus> => {
|
|
22
|
+
const facade = await planningHandlerOf(ctx).handlerFacade(req, opts)
|
|
21
23
|
const transition = `${req.params.transition}`
|
|
22
24
|
|
|
23
25
|
let status = await facade.commits.status(transition)
|
|
24
|
-
const wait = clampSeconds(req.query?.wait, opts?.maxPoll ?? MAX_COMMIT_POLL)
|
|
26
|
+
const wait = guardHelper.clampSeconds(req.query?.wait, opts?.maxPoll ?? MAX_COMMIT_POLL)
|
|
25
27
|
if (status.state !== CommitState.Pending || wait <= 0) {
|
|
26
28
|
return status
|
|
27
29
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { handlers } from '@owlmeans/server-api'
|
|
2
|
+
import { PlanningUnsupported, type PlanningProtocols, type SchemaDefineReply, type SchemaDefineRequest } from '@owlmeans/planning'
|
|
3
|
+
import type { Context, PlanningHandlerOptions } from '../types.js'
|
|
4
|
+
import { makePlanningAccessModel } from '../utils/access.js'
|
|
5
|
+
import { guardHelper } from '../utils/guard.js'
|
|
6
|
+
import { planningHandlerOf } from '../utils/handler.js'
|
|
7
|
+
import { applySchemaRequest } from './apply-schema-request.js'
|
|
8
|
+
import type { RequestHandler } from './types.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The write of data-defined types and flows. A project layer needs the project in the access's
|
|
12
|
+
* `writes` when the resolver answers it; then `grants.defineSchemas` gates when the resolver answers
|
|
13
|
+
* grants (the organization-wide layer needs `true`, a project layer its id).
|
|
14
|
+
*
|
|
15
|
+
* @throws {PlanningUnsupported} where the store holds no data-defined schemas
|
|
16
|
+
* @throws {PlanningForbidden | SchemaConflict | SchemaSealed | SchemaInvalid | SchemaInUse | WorkcardNotFound}
|
|
17
|
+
*/
|
|
18
|
+
export const defineSchemas = (
|
|
19
|
+
protocol: NonNullable<PlanningProtocols['schema']['define']>, opts?: PlanningHandlerOptions
|
|
20
|
+
): RequestHandler =>
|
|
21
|
+
handlers<Context>().request(protocol, async (req, ctx) => guardHelper.reply(async (): Promise<SchemaDefineReply> => {
|
|
22
|
+
const { facade, access } = await planningHandlerOf(ctx).handlerScopeOf(req, opts)
|
|
23
|
+
const request = (req.body ?? {}) as SchemaDefineRequest
|
|
24
|
+
if (facade.definitions == null) {
|
|
25
|
+
throw new PlanningUnsupported('definitions')
|
|
26
|
+
}
|
|
27
|
+
const model = makePlanningAccessModel(access)
|
|
28
|
+
if (request.project != null) {
|
|
29
|
+
model.assertWrites(request.project)
|
|
30
|
+
}
|
|
31
|
+
model.assertGranted('defineSchemas', request.project)
|
|
32
|
+
|
|
33
|
+
return await applySchemaRequest(facade.definitions, request)
|
|
34
|
+
}))
|
package/src/actions/execute.ts
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
1
|
import { handlers } from '@owlmeans/server-api'
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_COMMIT_POLL } from '@owlmeans/planning'
|
|
3
3
|
import type {
|
|
4
|
-
ExecuteOptions, ExecuteRequest, PlanningProtocols, PlanningScope, TransitionExecution,
|
|
4
|
+
ExecuteOptions, ExecuteRequest, PlanningFacade, PlanningProtocols, PlanningScope, TransitionExecution,
|
|
5
|
+
TransitionReceiptView,
|
|
5
6
|
} from '@owlmeans/planning'
|
|
6
|
-
import type { Context, PlanningHandlerOptions } from '../types.js'
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* `createdBy` is the authenticated subject, whatever the body claimed.
|
|
12
|
-
*/
|
|
13
|
-
export const wireExecution = (body: ExecuteRequest, scope: PlanningScope): TransitionExecution => {
|
|
14
|
-
const { wait: _wait, timeout: _timeout, actor: _actor, ...exec } = body
|
|
15
|
-
if (exec.action === TransitionAction.Create && exec.card != null && typeof exec.card === 'object') {
|
|
16
|
-
const { createdBy: _createdBy, ...draft } = exec.card
|
|
17
|
-
const subject = scope.profileId ?? scope.userId
|
|
18
|
-
exec.card = subject != null ? { ...draft, createdBy: subject } : draft
|
|
19
|
-
}
|
|
20
|
-
return exec
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** `wait`/`timeout` as a server grants them: the timeout never holds a request past `maxPoll`. */
|
|
24
|
-
export const executeOptionsOf = (body: Pick<ExecuteRequest, 'wait' | 'timeout'>, maxPoll: number): ExecuteOptions => {
|
|
25
|
-
const ceiling = maxPoll * 1000
|
|
26
|
-
if (body.wait !== true) {
|
|
27
|
-
return {}
|
|
28
|
-
}
|
|
29
|
-
const asked = Number(body.timeout ?? DEFAULT_COMMIT_TIMEOUT)
|
|
30
|
-
return { wait: true, timeout: Math.min(Number.isFinite(asked) && asked > 0 ? asked : DEFAULT_COMMIT_TIMEOUT, ceiling) }
|
|
31
|
-
}
|
|
7
|
+
import type { Context, PlanningAccess, PlanningHandlerOptions } from '../types.js'
|
|
8
|
+
import { guardHelper } from '../utils/guard.js'
|
|
9
|
+
import { planningHandlerOf } from '../utils/handler.js'
|
|
10
|
+
import { executionHelper } from './execution.js'
|
|
11
|
+
import type { RequestHandler } from './types.js'
|
|
32
12
|
|
|
33
13
|
/** The one write route. */
|
|
34
14
|
export const executePlanning = (
|
|
35
15
|
protocol: PlanningProtocols['execute'], opts?: PlanningHandlerOptions
|
|
36
|
-
):
|
|
37
|
-
handlers<Context>().request(protocol, async (req, ctx) =>
|
|
38
|
-
const facade = await
|
|
16
|
+
): RequestHandler =>
|
|
17
|
+
handlers<Context>().request(protocol, async (req, ctx) => guardHelper.reply(async (): Promise<TransitionReceiptView> => {
|
|
18
|
+
const { facade, access } = await planningHandlerOf(ctx).handlerScopeOf(req, opts)
|
|
39
19
|
const body = (req.body ?? {}) as ExecuteRequest
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
)
|
|
20
|
+
const exec = executionHelper.wireExecution(body, facade.scope)
|
|
21
|
+
await executionHelper.assertExecutionGranted(facade, exec, access)
|
|
22
|
+
const receipt = await facade.execute(exec, executionHelper.executeOptionsOf(body, opts?.maxPoll ?? MAX_COMMIT_POLL))
|
|
43
23
|
|
|
44
24
|
return receipt.card !== undefined
|
|
45
25
|
? { transition: receipt.transition, card: receipt.card }
|
|
46
26
|
: { transition: receipt.transition }
|
|
47
27
|
}))
|
|
28
|
+
|
|
29
|
+
/** @deprecated compat:factory-refactor — use `executionHelper.wireExecution(…)` */
|
|
30
|
+
export const wireExecution = (body: ExecuteRequest, scope: PlanningScope): TransitionExecution =>
|
|
31
|
+
executionHelper.wireExecution(body, scope)
|
|
32
|
+
|
|
33
|
+
/** @deprecated compat:factory-refactor — use `executionHelper.executeOptionsOf(…)` */
|
|
34
|
+
export const executeOptionsOf = (body: Pick<ExecuteRequest, 'wait' | 'timeout'>, maxPoll: number): ExecuteOptions =>
|
|
35
|
+
executionHelper.executeOptionsOf(body, maxPoll)
|
|
36
|
+
|
|
37
|
+
/** @deprecated compat:factory-refactor — use `executionHelper.assertExecutionWrites(…)` */
|
|
38
|
+
export const assertExecutionWrites = async (
|
|
39
|
+
facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess
|
|
40
|
+
): Promise<void> => await executionHelper.assertExecutionWrites(facade, exec, access)
|
|
41
|
+
|
|
42
|
+
/** @deprecated compat:factory-refactor — use `executionHelper.assertExecutionGranted(…)` */
|
|
43
|
+
export const assertExecutionGranted = async (
|
|
44
|
+
facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess
|
|
45
|
+
): Promise<void> => await executionHelper.assertExecutionGranted(facade, exec, access)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ExecuteOptions, ExecuteRequest, PlanningFacade, PlanningScope, TransitionExecution } from '@owlmeans/planning'
|
|
2
|
+
import type { PlanningAccess } from '../../types.js'
|
|
3
|
+
|
|
4
|
+
/** What a wire execution may say, how long it may hold, and what access it needs. */
|
|
5
|
+
export interface ExecutionHelper {
|
|
6
|
+
/**
|
|
7
|
+
* What a wire execution may say. `actor` is dropped — the scope names the writer — and a create's
|
|
8
|
+
* `createdBy` claim is dropped too: the executor's `creatorHelper.withCreator` stamps the
|
|
9
|
+
* authenticated subject, the same rule an in-process create follows. Applied here as well, so the
|
|
10
|
+
* returned execution already carries it. A `createdBy` in `changes` or `unset` is not dropped: the
|
|
11
|
+
* executor refuses it on every action (`assertCreatorFixed`), so no body moves an owner.
|
|
12
|
+
*/
|
|
13
|
+
wireExecution: (body: ExecuteRequest, scope: PlanningScope) => TransitionExecution
|
|
14
|
+
/** `wait`/`timeout` as a server grants them: the timeout never holds a request past `maxPoll`. */
|
|
15
|
+
executeOptionsOf: (body: Pick<ExecuteRequest, 'wait' | 'timeout'>, maxPoll: number) => ExecuteOptions
|
|
16
|
+
/**
|
|
17
|
+
* Refuse an execution outside the access's `writes`: the card it acts on (a specification through
|
|
18
|
+
* its parent card), or every parent a create names, must be one `writableIn` admits. A create
|
|
19
|
+
* of a project is `grants.createProjects`' alone. A card or parent this scope cannot see is left to
|
|
20
|
+
* the executor, which answers it as absent.
|
|
21
|
+
*
|
|
22
|
+
* @throws {PlanningForbidden}
|
|
23
|
+
*/
|
|
24
|
+
assertExecutionWrites: (facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess) => Promise<void>
|
|
25
|
+
/**
|
|
26
|
+
* The access a wire execution needs. `writes` first ({@link ExecutionHelper.assertExecutionWrites});
|
|
27
|
+
* then the grants: `createProjects` for a project create (its primary parent, or the root),
|
|
28
|
+
* `deleteProjects` for the delete of a project card. A card this scope cannot see is left to the
|
|
29
|
+
* executor, which answers it as absent.
|
|
30
|
+
*
|
|
31
|
+
* @throws {PlanningForbidden}
|
|
32
|
+
*/
|
|
33
|
+
assertExecutionGranted: (facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess) => Promise<void>
|
|
34
|
+
}
|