@owlmeans/server-planning 0.1.18-rc.8 → 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/store/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommitEvent, CommitSource, CommitStatus, PlanningStore, ProjectionStore, Relationship, RelationshipStore, SpecificationStore, Transition, TransitionStore, Workcard } from '@owlmeans/planning';
|
|
1
|
+
import type { CommitEvent, CommitSource, CommitStatus, PlanningStore, ProjectionStore, Relationship, RelationshipStore, SchemaStore, ScopedSchemaRecord, SpecificationStore, Transition, TransitionStore, Workcard } from '@owlmeans/planning';
|
|
2
2
|
/** What a folding store calls for every committed transition — the service's `committed`. */
|
|
3
3
|
export interface CommitListener {
|
|
4
4
|
(event: CommitEvent): Promise<void>;
|
|
@@ -41,6 +41,11 @@ export interface FoldOptions {
|
|
|
41
41
|
limit?: number;
|
|
42
42
|
/** Called between transitions — a queue processor renews its lock here. */
|
|
43
43
|
touch?: () => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Runs one transition's store writes as a unit — a transactional store opens a savepoint here, so
|
|
46
|
+
* a write the database refuses leaves nothing of that transition behind and the fold goes past it.
|
|
47
|
+
*/
|
|
48
|
+
unit?: <R>(run: () => Promise<R>) => Promise<R>;
|
|
44
49
|
}
|
|
45
50
|
export interface FoldResult {
|
|
46
51
|
card: Workcard | null;
|
|
@@ -53,6 +58,8 @@ export interface MemoryPlanningStoreSeed {
|
|
|
53
58
|
cards?: Workcard[];
|
|
54
59
|
links?: Relationship[];
|
|
55
60
|
transitions?: Transition[];
|
|
61
|
+
/** Data-defined type and flow records — kept only by a store built with `schemas: true`. */
|
|
62
|
+
schemas?: ScopedSchemaRecord[];
|
|
56
63
|
}
|
|
57
64
|
export interface MemoryPlanningStoreOptions {
|
|
58
65
|
/** Fold and publish inside `project()`. Default `true`; `false` folds only on `flush()`. */
|
|
@@ -63,6 +70,11 @@ export interface MemoryPlanningStoreOptions {
|
|
|
63
70
|
/** The commit listener used until a service binds its own. */
|
|
64
71
|
onCommitted?: CommitListener;
|
|
65
72
|
alias?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Hold data-defined types and flows (the `schemas` port). Off by default: a store without it
|
|
75
|
+
* resolves every type and flow from the code registry, exactly as before.
|
|
76
|
+
*/
|
|
77
|
+
schemas?: boolean;
|
|
66
78
|
}
|
|
67
79
|
export interface MemoryPlanningStore extends BindablePlanningStore {
|
|
68
80
|
transitions: TransitionStore;
|
|
@@ -70,6 +82,8 @@ export interface MemoryPlanningStore extends BindablePlanningStore {
|
|
|
70
82
|
specs: SpecificationStore;
|
|
71
83
|
links: RelationshipStore;
|
|
72
84
|
commits: CommitHub;
|
|
85
|
+
/** Present when the store was built with `schemas: true`. */
|
|
86
|
+
schemas?: SchemaStore;
|
|
73
87
|
bind: (committed: CommitListener) => void;
|
|
74
88
|
/** Fold what is pending — for one card, or for every card with a pending transition. */
|
|
75
89
|
flush: (card?: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EACrF,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EACrF,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EACnG,QAAQ,EACT,MAAM,oBAAoB,CAAA;AAE3B,6FAA6F;AAC7F,MAAM,WAAW,cAAc;IAC7B,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,KAAK,IAAI,CAAA;CAC3C;AAED,MAAM,WAAW,gBAAgB;IAC/B,6FAA6F;IAC7F,MAAM,EA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AAK,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.js","sourceRoot":"","sources":["../../src/store/types.local.ts"],"names":[],"mappings":""}
|
package/build/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext, LazyService } from '@owlmeans/context';
|
|
2
2
|
import type { AbstractRequest } from '@owlmeans/entrypoint';
|
|
3
|
-
import type { AnyTypeSchema, PlanningPlugin, PlanningScope, PlanningService, PlanningStore, StatusFlowSchema, WithPlanningService } from '@owlmeans/planning';
|
|
3
|
+
import type { AssigneeTypeSchema, AnyTypeSchema, PlanningAppDeclarations, PlanningPlugin, PlanningScope, PlanningService, PlanningStore, StatusFlowSchema, WithPlanningService, PlanningSchemaRegistry, SchemaStore, ScopedSchemaRegistry, CommitEvent, PlanningExecContext, PlanningHookContext, TransitionExecution, WorkcardDraft } from '@owlmeans/planning';
|
|
4
4
|
import type { ApiServerAppend } from '@owlmeans/server-api';
|
|
5
5
|
import type { ServerConfig, ServerContext } from '@owlmeans/server-context';
|
|
6
|
+
import type { StoreRoute } from './store/types.js';
|
|
6
7
|
export interface Config extends ServerConfig {
|
|
7
8
|
}
|
|
8
9
|
export interface Context<C extends Config = Config> extends ServerContext<C>, ApiServerAppend, WithPlanningService {
|
|
@@ -11,10 +12,15 @@ export interface PlanningServiceOptions {
|
|
|
11
12
|
/** The default store — every type no plugin owns. An in-memory store when omitted. */
|
|
12
13
|
store?: PlanningStore;
|
|
13
14
|
plugins?: PlanningPlugin[];
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Schemas registered before any plugin's; `app` is the first source every plugin's `schemas.app`
|
|
17
|
+
* is merged over.
|
|
18
|
+
*/
|
|
15
19
|
schemas?: {
|
|
16
20
|
types?: AnyTypeSchema[];
|
|
17
21
|
flows?: StatusFlowSchema[];
|
|
22
|
+
assigneeTypes?: AssigneeTypeSchema[];
|
|
23
|
+
app?: PlanningAppDeclarations;
|
|
18
24
|
};
|
|
19
25
|
/** Run the `after` chain in this process. Default `true`. */
|
|
20
26
|
hooks?: boolean;
|
|
@@ -34,6 +40,49 @@ export interface PlanningHostService extends PlanningService, LazyService {
|
|
|
34
40
|
export interface PlanningScopeExtractor {
|
|
35
41
|
(req: AbstractRequest, ctx: BasicContext<BasicConfig>): Partial<PlanningScope> | Promise<Partial<PlanningScope>>;
|
|
36
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A grant: `true` for everything the request can see, a list for those project cards only (the
|
|
45
|
+
* parent of a created project, the deleted project, the schema layer).
|
|
46
|
+
*/
|
|
47
|
+
export type PlanningGrant = boolean | string[];
|
|
48
|
+
export interface PlanningAccessGrants {
|
|
49
|
+
/** Create a project — at the root only with `true`; a list names the parent projects. */
|
|
50
|
+
manageAssignees?: boolean;
|
|
51
|
+
manageTeams?: boolean;
|
|
52
|
+
createProjects?: PlanningGrant;
|
|
53
|
+
/** Delete a project — a list names the projects. */
|
|
54
|
+
deleteProjects?: PlanningGrant;
|
|
55
|
+
/** Write data-defined types and flows — the organization-wide layer only with `true`. */
|
|
56
|
+
defineSchemas?: PlanningGrant;
|
|
57
|
+
}
|
|
58
|
+
/** What a hosting application decides about one request. */
|
|
59
|
+
export interface PlanningAccess {
|
|
60
|
+
/** The organization the request acts in — the only source of it once a resolver is given. */
|
|
61
|
+
entityId: string;
|
|
62
|
+
/** Narrows every read and write to these project cards. Every project when omitted. */
|
|
63
|
+
projects?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* The project cards the request may WRITE in: `execute` on a card, specification or link inside
|
|
66
|
+
* one of them (the same rule a narrowed read admits — the project, the cards whose `parents` name
|
|
67
|
+
* it, a specification through its parent card), and `schema.define` of a project layer. A project
|
|
68
|
+
* outside `projects` is still unreachable. Omitted — writes reach every project `projects` admits;
|
|
69
|
+
* present — anything else is refused with `PlanningForbidden` (403). Creating a project is
|
|
70
|
+
* `grants.createProjects`' alone; the organization-wide schema layer is `grants.defineSchemas`'.
|
|
71
|
+
*/
|
|
72
|
+
writes?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Gates the writes above. Omitted — nothing is gated; present — a flag it leaves out is refused
|
|
75
|
+
* with `PlanningForbidden`.
|
|
76
|
+
*/
|
|
77
|
+
grants?: PlanningAccessGrants;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolves a request's access. A throw is the request's answer (an `AuthForbidden` answers 403
|
|
81
|
+
* like any other guard refusal).
|
|
82
|
+
*/
|
|
83
|
+
export interface PlanningAccessResolver {
|
|
84
|
+
(req: AbstractRequest, ctx: BasicContext<BasicConfig>): Promise<PlanningAccess>;
|
|
85
|
+
}
|
|
37
86
|
export interface PlanningHandlerOptions {
|
|
38
87
|
/** The planning service alias. `PLANNING_SERVICE` when omitted. */
|
|
39
88
|
service?: string;
|
|
@@ -42,5 +91,80 @@ export interface PlanningHandlerOptions {
|
|
|
42
91
|
/** The longest single long poll, in seconds — clamps `commit.get`'s `wait` and `execute`'s `timeout`. */
|
|
43
92
|
maxPoll?: number;
|
|
44
93
|
scope?: PlanningScopeExtractor;
|
|
94
|
+
/**
|
|
95
|
+
* The hosting application's access decision per request. Without it the organization is the
|
|
96
|
+
* request's own (`requireEntityKey`) and nothing is narrowed or gated.
|
|
97
|
+
*/
|
|
98
|
+
access?: PlanningAccessResolver;
|
|
99
|
+
}
|
|
100
|
+
export interface SchemaViewsOptions {
|
|
101
|
+
/** The code registry every layer starts from. */
|
|
102
|
+
code: () => PlanningSchemaRegistry;
|
|
103
|
+
/** Bumps whenever the code registry changes (a plugin's `use`). */
|
|
104
|
+
version: () => number;
|
|
105
|
+
/** The schema port, when the store has one. */
|
|
106
|
+
port: () => SchemaStore | undefined;
|
|
107
|
+
/** How many resolved layers are kept. */
|
|
108
|
+
limit?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface SchemaViews {
|
|
111
|
+
/** The code registry itself without a port; the resolved layer with one. */
|
|
112
|
+
of: (entityId: string, project?: string) => Promise<PlanningSchemaRegistry>;
|
|
113
|
+
/** @throws {PlanningUnsupported} without a port */
|
|
114
|
+
scoped: (entityId: string, project?: string) => Promise<ScopedSchemaRegistry>;
|
|
115
|
+
}
|
|
116
|
+
export interface ProjectionOptions {
|
|
117
|
+
/** The planning service alias. */
|
|
118
|
+
service?: string;
|
|
119
|
+
/** The store the queue folds — the service's default store when omitted. */
|
|
120
|
+
store?: (service: PlanningService) => PlanningStore;
|
|
121
|
+
/** Where events go — the store's commit hub `publish` when it has one. */
|
|
122
|
+
publish?: (event: CommitEvent) => Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
export interface PluginRegistry {
|
|
125
|
+
/**
|
|
126
|
+
* Register, or replace the plugin of the same `name`. Its schemas are contributed now; the
|
|
127
|
+
* application's declarations are re-merged from the service's own and every plugin's, in plugin
|
|
128
|
+
* order (`appSchemaHelper.merge`), so a replaced plugin's declarations leave with it.
|
|
129
|
+
*
|
|
130
|
+
* @throws {SchemaInvalid} a malformed `schemas.app` — the plugin is not registered
|
|
131
|
+
*/
|
|
132
|
+
use: (plugin: PlanningPlugin) => void;
|
|
133
|
+
/** Every plugin, `order` ascending (registration order among equals). */
|
|
134
|
+
plugins: () => PlanningPlugin[];
|
|
135
|
+
/** The owning plugins that supply a store, in plugin order, each store resolved once. */
|
|
136
|
+
routes: (ctx?: BasicContext<BasicConfig>) => StoreRoute[];
|
|
137
|
+
/** The first owning plugin's store for a type, else `fallback`. */
|
|
138
|
+
storeFor: (type: string | undefined, fallback: PlanningStore, ctx?: BasicContext<BasicConfig>) => PlanningStore;
|
|
139
|
+
/** The first plugin answering a code wins. */
|
|
140
|
+
mintCode: (draft: WorkcardDraft, taken: (code: string) => Promise<boolean>, contextOf: (plugin: PlanningPlugin) => PlanningExecContext) => Promise<string | undefined>;
|
|
141
|
+
/** The `before` chain; answers the execution the chain left. */
|
|
142
|
+
before: (exec: TransitionExecution, contextOf: (plugin: PlanningPlugin) => PlanningExecContext) => Promise<TransitionExecution>;
|
|
143
|
+
/** The `after` chain; a failing hook is logged and the chain goes on. */
|
|
144
|
+
after: (event: CommitEvent, contextOf: (plugin: PlanningPlugin) => PlanningHookContext) => Promise<void>;
|
|
145
|
+
/** Bumps on every `use` — what a cached composite store is keyed by. */
|
|
146
|
+
version: () => number;
|
|
147
|
+
}
|
|
148
|
+
export interface PlanningServiceApi extends Pick<PlanningService, 'use' | 'plugins' | 'schemas' | 'store' | 'for' | 'committed'> {
|
|
149
|
+
}
|
|
150
|
+
/** What the facade and the executor reach the service through. */
|
|
151
|
+
export interface PlanningRuntime {
|
|
152
|
+
service: () => PlanningService;
|
|
153
|
+
registry: PluginRegistry;
|
|
154
|
+
options: PlanningServiceOptions;
|
|
155
|
+
context: () => BasicContext<BasicConfig> | undefined;
|
|
156
|
+
/** The composite store reads and commits go through. */
|
|
157
|
+
reader: () => PlanningStore;
|
|
158
|
+
/** Every distinct store: the default one first, then each plugin's. */
|
|
159
|
+
stores: () => PlanningStore[];
|
|
160
|
+
/** The default store's data-defined schema port, when it has one. */
|
|
161
|
+
schemaStore: () => SchemaStore | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* The registry a card of this organization (and project) resolves through. Without a schema
|
|
164
|
+
* port it is the service's code registry itself — the very same object.
|
|
165
|
+
*/
|
|
166
|
+
schemasFor: (entityId: string, project?: string) => Promise<PlanningSchemaRegistry>;
|
|
167
|
+
/** The resolved layer. @throws {PlanningUnsupported} without a schema port */
|
|
168
|
+
scopedSchemas: (entityId: string, project?: string) => Promise<ScopedSchemaRegistry>;
|
|
45
169
|
}
|
|
46
170
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,M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xD,MAAM,EAAE,MAAM,aAAa,CAAA;IAC3B,uEAAuE;IACvE,MAAM,EAAE,MAAM,aAAa,EAAE,CAAA;IAC7B,qEAAqE;IACrE,WAAW,EAAE,MAAM,WAAW,GAAG,SAAS,CAAA;IAC1C;;;OAGG;IACH,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACnF,8EAA8E;IAC9E,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAA;CACrF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlanningSchemaKind, type AssigneeTypeSchema, type StatusFlowSchema, type WorkcardTypeSchema } from '@owlmeans/planning';
|
|
2
|
+
export interface Planned {
|
|
3
|
+
kind: PlanningSchemaKind;
|
|
4
|
+
key: string;
|
|
5
|
+
definition: WorkcardTypeSchema | StatusFlowSchema | AssigneeTypeSchema;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=types.local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEhI,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,kBAAkB,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,kBAAkB,CAAA;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.js","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Workcard } from '@owlmeans/planning';
|
|
2
|
+
import type { PlanningAccess, PlanningAccessGrants } from '../../types.js';
|
|
3
|
+
/** The write rules of one resolved {@link PlanningAccess} — no access at all gates nothing. */
|
|
4
|
+
export interface PlanningAccessModel {
|
|
5
|
+
readonly record: PlanningAccess | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Refuse a write the access does not grant. No access, or access without `grants`, gates nothing;
|
|
8
|
+
* a `grants` object refuses every flag it leaves out. `true` grants everything; a list grants the
|
|
9
|
+
* project ids it names — `target` is the project the write is about (`undefined` for the
|
|
10
|
+
* organization's root, which only `true` reaches).
|
|
11
|
+
*
|
|
12
|
+
* @throws {PlanningForbidden}
|
|
13
|
+
*/
|
|
14
|
+
assertGranted: (grant: keyof PlanningAccessGrants, target?: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* A card the access's `writes` admits — the rule a narrowed read admits, over `writes`: a project
|
|
17
|
+
* it names, or a card whose `parents` name one. A specification is admitted through its parent card
|
|
18
|
+
* by the caller. No `writes` admits everything.
|
|
19
|
+
*/
|
|
20
|
+
writableIn: (card: Pick<Workcard, 'id' | 'parents'>) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Refuse a write into a project the access's `writes` leaves out. No `writes` refuses nothing;
|
|
23
|
+
* `target` is the project the write is in (`undefined` for the organization's root, which a set
|
|
24
|
+
* `writes` never admits).
|
|
25
|
+
*
|
|
26
|
+
* @throws {PlanningForbidden}
|
|
27
|
+
*/
|
|
28
|
+
assertWrites: (target?: string) => void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/access/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE1E,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAA;IAC3C;;;;;;;OAOG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,oBAAoB,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3E;;;;OAIG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC,KAAK,OAAO,CAAA;IAC/D;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/access/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/utils/access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,eAAO,MAAM,uBAAuB,WAAY,cAAc,GAAG,SAAS,KAAG,mBA4B5E,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PlanningForbidden } from '@owlmeans/planning';
|
|
2
|
+
export const makePlanningAccessModel = (access) => {
|
|
3
|
+
const assertGranted = (grant, target) => {
|
|
4
|
+
if (access?.grants == null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const granted = access.grants[grant];
|
|
8
|
+
if (granted === true || (Array.isArray(granted) && target != null && granted.includes(target))) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
throw new PlanningForbidden(`${grant}:${target ?? 'root'}`);
|
|
12
|
+
};
|
|
13
|
+
const writableIn = (card) => {
|
|
14
|
+
const writes = access?.writes;
|
|
15
|
+
if (writes == null) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return (card.id != null && writes.includes(card.id)) || card.parents.some(parent => writes.includes(parent));
|
|
19
|
+
};
|
|
20
|
+
const assertWrites = (target) => {
|
|
21
|
+
if (access?.writes == null || (target != null && access.writes.includes(target))) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new PlanningForbidden(`writes:${target ?? 'root'}`);
|
|
25
|
+
};
|
|
26
|
+
return { record: access, assertGranted, writableIn, assertWrites };
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/utils/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,oBAAoB,CAAA;AAIrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAkC,EAAuB,EAAE;IACjG,MAAM,aAAa,GAAG,CAAC,KAAiC,EAAE,MAAe,EAAQ,EAAE;QACjF,IAAI,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;YAC3B,OAAM;QACR,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACpC,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YAC/F,OAAM;QACR,CAAC;QACD,MAAM,IAAI,iBAAiB,CAAC,GAAG,KAAK,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC,CAAA;IAC7D,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,CAAC,IAAsC,EAAW,EAAE;QACrE,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,CAAA;QAC7B,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9G,CAAC,CAAA;IAED,MAAM,YAAY,GAAG,CAAC,MAAe,EAAQ,EAAE;QAC7C,IAAI,MAAM,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACjF,OAAM;QACR,CAAC;QACD,MAAM,IAAI,iBAAiB,CAAC,UAAU,MAAM,IAAI,MAAM,EAAE,CAAC,CAAA;IAC3D,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,CAAA;AACpE,CAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WorkcardNotFound, Workcard, PlanningReply } from '@owlmeans/planning';
|
|
2
|
+
/** What every handler answers with when a record is not the caller's: absence, never a refusal. */
|
|
3
|
+
export interface GuardHelper {
|
|
4
|
+
notFoundOf: (id: string) => WorkcardNotFound;
|
|
5
|
+
/**
|
|
6
|
+
* A record of another entity is absent, not forbidden.
|
|
7
|
+
*
|
|
8
|
+
* @throws {WorkcardNotFound}
|
|
9
|
+
*/
|
|
10
|
+
assertScope: <T extends Pick<Workcard, 'entityId'>>(record: T | null | undefined, scope: {
|
|
11
|
+
entityId: string;
|
|
12
|
+
}, id: string) => T;
|
|
13
|
+
/**
|
|
14
|
+
* Run a handler body so that a scope mismatch leaves as `WorkcardNotFound` — telling "not yours"
|
|
15
|
+
* apart from "does not exist" is what turns an id space into an enumeration oracle.
|
|
16
|
+
*/
|
|
17
|
+
concealed: <T>(run: () => Promise<T>) => Promise<T>;
|
|
18
|
+
/** Conceal scope failures and project storage metadata out of a public reply. */
|
|
19
|
+
reply: <T>(run: () => Promise<T>) => Promise<PlanningReply<T>>;
|
|
20
|
+
/** Seconds as the wire sends them, clamped to `[0, max]`. */
|
|
21
|
+
clampSeconds: (value: unknown, max: number) => number;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/guard/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEnF,mGAAmG;AACnG,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,gBAAgB,CAAA;IAC5C;;;;OAIG;IACH,WAAW,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC,CAAA;IAC/H;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD,iFAAiF;IACjF,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9D,6DAA6D;IAC7D,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/guard/types.ts"],"names":[],"mappings":""}
|
package/build/utils/guard.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { WorkcardNotFound } from '@owlmeans/planning';
|
|
2
2
|
import type { Workcard } from '@owlmeans/planning';
|
|
3
|
+
import type { GuardHelper } from './guard/types.js';
|
|
4
|
+
export declare const createGuardHelper: () => GuardHelper;
|
|
5
|
+
export declare const guardHelper: GuardHelper;
|
|
6
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.notFoundOf(…)` */
|
|
3
7
|
export declare const notFoundOf: (id: string) => WorkcardNotFound;
|
|
4
|
-
/**
|
|
5
|
-
* A record of another entity is absent, not forbidden.
|
|
6
|
-
*
|
|
7
|
-
* @throws {WorkcardNotFound}
|
|
8
|
-
*/
|
|
8
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.assertScope(…)` */
|
|
9
9
|
export declare const assertScope: <T extends Pick<Workcard, 'entityId'>>(record: T | null | undefined, scope: {
|
|
10
10
|
entityId: string;
|
|
11
11
|
}, id: string) => T;
|
|
12
|
-
/**
|
|
13
|
-
* Run a handler body so that a scope mismatch leaves as `WorkcardNotFound` — telling "not yours"
|
|
14
|
-
* apart from "does not exist" is what turns an id space into an enumeration oracle.
|
|
15
|
-
*/
|
|
12
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.concealed(…)` */
|
|
16
13
|
export declare const concealed: <T>(run: () => Promise<T>) => Promise<T>;
|
|
17
|
-
/**
|
|
14
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.clampSeconds(…)` */
|
|
18
15
|
export declare const clampSeconds: (value: unknown, max: number) => number;
|
|
19
16
|
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/utils/guard.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/utils/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,eAAO,MAAM,iBAAiB,QAAO,WAgCpC,CAAA;AAED,eAAO,MAAM,WAAW,aAAsB,CAAA;AAE9C,4EAA4E;AAC5E,eAAO,MAAM,UAAU,OAAQ,MAAM,KAAG,gBAA8C,CAAA;AAEtF,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,UACtD,CAAC,GAAG,IAAI,GAAG,SAAS,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,MAAM,MAAM,KACpE,CAAkD,CAAA;AAErD,2EAA2E;AAC3E,eAAO,MAAM,SAAS,GAAU,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAwC,CAAA;AAE5G,8EAA8E;AAC9E,eAAO,MAAM,YAAY,UAAW,OAAO,OAAO,MAAM,KAAG,MAA8C,CAAA"}
|
package/build/utils/guard.js
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import { PlanningScopeMismatch, WorkcardNotFound } from '@owlmeans/planning';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export const assertScope = (record, scope, id) => {
|
|
9
|
-
if (record == null || record.entityId !== scope.entityId) {
|
|
10
|
-
throw notFoundOf(id);
|
|
11
|
-
}
|
|
12
|
-
return record;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Run a handler body so that a scope mismatch leaves as `WorkcardNotFound` — telling "not yours"
|
|
16
|
-
* apart from "does not exist" is what turns an id space into an enumeration oracle.
|
|
17
|
-
*/
|
|
18
|
-
export const concealed = async (run) => {
|
|
19
|
-
try {
|
|
20
|
-
return await run();
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
if (error instanceof PlanningScopeMismatch
|
|
24
|
-
|| error?.type === PlanningScopeMismatch.typeName) {
|
|
25
|
-
throw new WorkcardNotFound();
|
|
1
|
+
import { planningReplyHelper, PlanningScopeMismatch, WorkcardNotFound } from '@owlmeans/planning';
|
|
2
|
+
export const createGuardHelper = () => {
|
|
3
|
+
const notFoundOf = (id) => new WorkcardNotFound(id);
|
|
4
|
+
const assertScope = (record, scope, id) => {
|
|
5
|
+
if (record == null || record.entityId !== scope.entityId) {
|
|
6
|
+
throw notFoundOf(id);
|
|
26
7
|
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
return record;
|
|
9
|
+
};
|
|
10
|
+
const concealed = async (run) => {
|
|
11
|
+
try {
|
|
12
|
+
return await run();
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error instanceof PlanningScopeMismatch
|
|
16
|
+
|| error?.type === PlanningScopeMismatch.typeName) {
|
|
17
|
+
throw new WorkcardNotFound();
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const clampSeconds = (value, max) => {
|
|
23
|
+
const number = typeof value === 'number' ? value : Number(value ?? 0);
|
|
24
|
+
return Number.isFinite(number) ? Math.min(Math.max(number, 0), max) : 0;
|
|
25
|
+
};
|
|
26
|
+
return { notFoundOf, assertScope, concealed, clampSeconds,
|
|
27
|
+
reply: async (run) => planningReplyHelper.project(await concealed(run)),
|
|
28
|
+
};
|
|
34
29
|
};
|
|
30
|
+
export const guardHelper = createGuardHelper();
|
|
31
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.notFoundOf(…)` */
|
|
32
|
+
export const notFoundOf = (id) => guardHelper.notFoundOf(id);
|
|
33
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.assertScope(…)` */
|
|
34
|
+
export const assertScope = (record, scope, id) => guardHelper.assertScope(record, scope, id);
|
|
35
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.concealed(…)` */
|
|
36
|
+
export const concealed = async (run) => await guardHelper.concealed(run);
|
|
37
|
+
/** @deprecated compat:factory-refactor — use `guardHelper.clampSeconds(…)` */
|
|
38
|
+
export const clampSeconds = (value, max) => guardHelper.clampSeconds(value, max);
|
|
35
39
|
//# sourceMappingURL=guard.js.map
|
package/build/utils/guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/utils/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/utils/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAgB,EAAE;IACjD,MAAM,UAAU,GAAG,CAAC,EAAU,EAAoB,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAA;IAE7E,MAAM,WAAW,GAAG,CAClB,MAA4B,EAAE,KAA2B,EAAE,EAAU,EAClE,EAAE;QACL,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC;YACzD,MAAM,UAAU,CAAC,EAAE,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,KAAK,EAAK,GAAqB,EAAc,EAAE;QAC/D,IAAI,CAAC;YACH,OAAO,MAAM,GAAG,EAAE,C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AAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAK,GAAqB,EAAc,EAAE,CAAC,MAAM,WAAW,CAAC,SAAS,CAAI,GAAG,CAAC,CAAA;AAE5G,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,GAAW,EAAU,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AbstractRequest } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { PlanningFacade, PlanningScope, PlanningService } from '@owlmeans/planning';
|
|
3
|
+
import type { PlanningHandlerOptions } from '../../types.js';
|
|
4
|
+
import type { HandlerScope } from '../types.js';
|
|
5
|
+
/** The planning service of one context, as a request handler reaches it. */
|
|
6
|
+
export interface PlanningHandlerHelper {
|
|
7
|
+
planningServiceOf: (opts?: Pick<PlanningHandlerOptions, 'service'>) => PlanningService;
|
|
8
|
+
/**
|
|
9
|
+
* The facade a handler works through, and the access it was resolved under.
|
|
10
|
+
*
|
|
11
|
+
* Without `opts.access` it is exactly the request's scope plus what `opts.scope` derives. With it,
|
|
12
|
+
* the resolver names the organization and the visible projects; a throw from the resolver is the
|
|
13
|
+
* request's error.
|
|
14
|
+
*/
|
|
15
|
+
handlerScopeOf: (req: AbstractRequest, opts?: PlanningHandlerOptions) => Promise<HandlerScope>;
|
|
16
|
+
/** The facade a handler works through: the request's scope plus what `opts.scope` derives. */
|
|
17
|
+
handlerFacade: (req: AbstractRequest, opts?: PlanningHandlerOptions) => Promise<PlanningFacade>;
|
|
18
|
+
/**
|
|
19
|
+
* The facade a hand-written handler works through: the request's entity and subject, plus `extra`
|
|
20
|
+
* (a `channel`) — never an entity from the request body.
|
|
21
|
+
*
|
|
22
|
+
* @throws {AuthorizationError} when the request carries no organization
|
|
23
|
+
*/
|
|
24
|
+
planningFor: (req: AbstractRequest, extra?: Partial<PlanningScope>, opts?: Pick<PlanningHandlerOptions, 'service'>) => PlanningFacade;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/handler/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,KAAK,eAAe,CAAA;IACtF;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IAC9F,8FAA8F;IAC9F,aAAa,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;IAC/F;;;;;OAKG;IACH,WAAW,EAAE,CACX,GAAG,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,KACjG,cAAc,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/handler/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type BasicConfig, type BasicContext } from '@owlmeans/context';
|
|
2
|
+
import type { PlanningHandlerHelper } from './handler/types.js';
|
|
3
|
+
export declare const makePlanningHandlerHelper: (ctx: BasicContext<BasicConfig>) => PlanningHandlerHelper;
|
|
4
|
+
/** The handler helper of a context — one per context. */
|
|
5
|
+
export declare const planningHandlerOf: (target: BasicContext<BasicConfig>) => PlanningHandlerHelper;
|
|
6
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAInF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAI/D,eAAO,MAAM,yBAAyB,QAAS,YAAY,CAAC,WAAW,CAAC,KAAG,qBAuB1E,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,8DAAgD,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { memoHelper } from '@owlmeans/context';
|
|
2
|
+
import { PLANNING_SERVICE } from '@owlmeans/planning';
|
|
3
|
+
import { makeRequestScope } from './request.js';
|
|
4
|
+
export const makePlanningHandlerHelper = (ctx) => {
|
|
5
|
+
const planningServiceOf = (opts) => ctx.service(opts?.service ?? PLANNING_SERVICE);
|
|
6
|
+
const handlerScopeOf = async (req, opts) => {
|
|
7
|
+
const planningService = planningServiceOf(opts);
|
|
8
|
+
const extra = await opts?.scope?.(req, ctx);
|
|
9
|
+
if (opts?.access == null) {
|
|
10
|
+
return { facade: planningService.for(makeRequestScope(req).scopeOf(extra ?? undefined)) };
|
|
11
|
+
}
|
|
12
|
+
const access = await opts.access(req, ctx);
|
|
13
|
+
return { facade: planningService.for(makeRequestScope(req).accessScopeOf(access, extra ?? undefined)), access };
|
|
14
|
+
};
|
|
15
|
+
const handlerFacade = async (req, opts) => (await handlerScopeOf(req, opts)).facade;
|
|
16
|
+
const planningFor = (req, extra, opts) => planningServiceOf(opts).for(makeRequestScope(req).scopeOf(extra));
|
|
17
|
+
return { planningServiceOf, handlerScopeOf, handlerFacade, planningFor };
|
|
18
|
+
};
|
|
19
|
+
/** The handler helper of a context — one per context. */
|
|
20
|
+
export const planningHandlerOf = memoHelper.oncePer(makePlanningHandlerHelper);
|
|
21
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,mBAAmB,CAAA;AAEnF,OAAO,EAAE,gBAAgB,EAAiE,MAAM,oBAAoB,CAAA;AAGpH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,GAA8B,EAAyB,EAAE;IACjG,MAAM,iBAAiB,GAAG,CAAC,IAA8C,EAAmB,EAAE,CAC5F,GAAG,CAAC,OAAO,CAAsB,IAAI,EAAE,OAAO,IAAI,gBAAgB,CAAC,CAAA;IAErE,MAAM,cAAc,GAAG,KAAK,EAAE,GAAoB,EAAE,IAA6B,EAAyB,EAAE;QAC1G,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;QAC/C,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAC3C,IAAI,IAAI,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,CAAA;QAC3F,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAE1C,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAA;IACjH,CAAC,CAAA;IAED,MAAM,aAAa,GAAG,KAAK,EAAE,GAAoB,EAAE,IAA6B,EAA2B,EAAE,CAC3G,CAAC,MAAM,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IAE1C,MAAM,WAAW,GAAG,CAClB,GAAoB,EAAE,KAA8B,EAAE,IAA8C,EACpF,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAEtF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAC1E,CAAC,CAAA;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAA"}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export type * from './types.js';
|
|
2
|
+
export type * from './access/types.js';
|
|
3
|
+
export type * from './guard/types.js';
|
|
4
|
+
export type * from './handler/types.js';
|
|
5
|
+
export type * from './request/types.js';
|
|
6
|
+
export * from './access.js';
|
|
1
7
|
export * from './guard.js';
|
|
8
|
+
export * from './handler.js';
|
|
9
|
+
export * from './request.js';
|
|
2
10
|
export * from './scope.js';
|
|
3
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,kBAAkB,CAAA;AACrC,mBAAmB,oBAAoB,CAAA;AACvC,mBAAmB,oBAAoB,CAAA;AAEvC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|