@owlmeans/server-planning 0.1.18-rc.21 → 0.1.18-rc.23
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 +24 -17
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-planning/SKILL.md +28 -28
- 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 +31 -0
- package/build/actions/apply-schema-request.js.map +1 -0
- package/build/actions/cards.d.ts +5 -3
- package/build/actions/cards.d.ts.map +1 -1
- package/build/actions/cards.js +1 -1
- package/build/actions/cards.js.map +1 -1
- 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 +8 -28
- package/build/actions/execute.d.ts.map +1 -1
- package/build/actions/execute.js +17 -101
- 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 +79 -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/schemas.d.ts +5 -3
- package/build/actions/schemas.d.ts.map +1 -1
- package/build/actions/schemas.js.map +1 -1
- package/build/actions/specs.d.ts +4 -2
- package/build/actions/specs.d.ts.map +1 -1
- package/build/actions/specs.js.map +1 -1
- 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 +5 -3
- package/build/actions/types.d.ts.map +1 -1
- package/build/actions/watch.d.ts +2 -2
- package/build/actions/watch.d.ts.map +1 -1
- package/build/actions/watch.js +2 -2
- 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 +8 -13
- package/build/conformance/assert.d.ts.map +1 -1
- package/build/conformance/assert.js +41 -43
- package/build/conformance/assert.js.map +1 -1
- package/build/conformance/cases.d.ts.map +1 -1
- package/build/conformance/cases.js +86 -67
- package/build/conformance/cases.js.map +1 -1
- 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 +3 -1
- package/build/conformance/consts.d.ts.map +1 -1
- package/build/conformance/consts.js +84 -1
- package/build/conformance/consts.js.map +1 -1
- 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 +8 -8
- package/build/conformance/fixtures.d.ts.map +1 -1
- package/build/conformance/fixtures.js +24 -107
- package/build/conformance/fixtures.js.map +1 -1
- package/build/conformance/index.d.ts +3 -0
- package/build/conformance/index.d.ts.map +1 -1
- package/build/conformance/index.js +1 -0
- package/build/conformance/index.js.map +1 -1
- package/build/definitions.d.ts.map +1 -1
- package/build/definitions.js +9 -9
- package/build/definitions.js.map +1 -1
- 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/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 +6 -25
- package/build/executor/creator.d.ts.map +1 -1
- package/build/executor/creator.js +26 -41
- package/build/executor/creator.js.map +1 -1
- 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 +4 -41
- package/build/executor/resolve.d.ts.map +1 -1
- package/build/executor/resolve.js +142 -157
- package/build/executor/resolve.js.map +1 -1
- package/build/executor/types.d.ts +0 -2
- package/build/executor/types.d.ts.map +1 -1
- package/build/executor/validate.d.ts +1 -1
- package/build/executor/validate.d.ts.map +1 -1
- package/build/executor/validate.js +16 -15
- package/build/executor/validate.js.map +1 -1
- package/build/executor.d.ts +4 -3
- package/build/executor.d.ts.map +1 -1
- package/build/executor.js +18 -17
- package/build/executor.js.map +1 -1
- package/build/facade.d.ts.map +1 -1
- package/build/facade.js +16 -16
- package/build/facade.js.map +1 -1
- package/build/helper.d.ts +1 -6
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +3 -8
- package/build/helper.js.map +1 -1
- package/build/projection.d.ts +2 -0
- package/build/projection.d.ts.map +1 -1
- package/build/projection.js +6 -4
- package/build/projection.js.map +1 -1
- 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 +1 -4
- package/build/queue/index.d.ts.map +1 -1
- package/build/queue/index.js +1 -4
- package/build/queue/index.js.map +1 -1
- package/build/store/composite.d.ts.map +1 -1
- package/build/store/composite.js +2 -2
- package/build/store/composite.js.map +1 -1
- 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 +7 -30
- package/build/store/fold.d.ts.map +1 -1
- package/build/store/fold.js +185 -203
- 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.map +1 -1
- package/build/store/memory.js +0 -0
- package/build/store/memory.js.map +1 -1
- package/build/store/types.local.d.ts +3 -1
- package/build/store/types.local.d.ts.map +1 -1
- package/build/types.d.ts +2 -1
- package/build/types.d.ts.map +1 -1
- 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 +21 -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 +33 -31
- 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 -1
- 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 +10 -43
- package/build/utils/scope.d.ts.map +1 -1
- package/build/utils/scope.js +21 -99
- package/build/utils/scope.js.map +1 -1
- package/package.json +18 -18
- package/src/actions/apply-schema-request.ts +35 -0
- package/src/actions/commit.ts +7 -5
- package/src/actions/define-schemas.ts +34 -0
- package/src/actions/execute.ts +30 -115
- package/src/actions/execution/types.ts +34 -0
- package/src/actions/execution.ts +96 -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/{specs.ts → list-specification-revisions.ts} +4 -11
- package/src/actions/summarize-cards.ts +15 -0
- package/src/actions/transitions.ts +6 -4
- package/src/actions/types.ts +4 -3
- package/src/actions/watch.ts +4 -3
- package/src/conformance/assert/types.ts +16 -0
- package/src/conformance/assert.ts +49 -41
- package/src/conformance/cases.ts +88 -67
- package/src/conformance/clock.ts +11 -0
- package/src/conformance/consts.ts +87 -1
- package/src/conformance/errors.ts +7 -0
- package/src/conformance/fixtures/types.ts +11 -0
- package/src/conformance/fixtures.ts +32 -107
- package/src/conformance/index.ts +3 -0
- package/src/definitions.ts +9 -9
- package/src/executor/changes/types.ts +38 -0
- package/src/executor/changes.ts +48 -63
- package/src/executor/code/types.ts +23 -0
- package/src/executor/code.ts +60 -61
- package/src/executor/creator/types.ts +33 -0
- package/src/executor/creator.ts +33 -41
- package/src/executor/resolve/types.ts +30 -0
- package/src/executor/resolve.ts +153 -167
- package/src/executor/types.ts +0 -3
- package/src/executor/validate.ts +17 -16
- package/src/executor.ts +20 -17
- package/src/facade.ts +16 -16
- package/src/helper.ts +3 -8
- package/src/projection.ts +8 -4
- package/src/queue/declare.ts +7 -0
- package/src/queue/index.ts +1 -8
- package/src/store/composite.ts +2 -2
- package/src/store/fold/types.ts +44 -0
- package/src/store/fold.ts +209 -212
- package/src/store/index.ts +1 -0
- package/src/store/memory.ts +0 -0
- package/src/store/types.local.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/access/types.ts +30 -0
- package/src/utils/access.ts +33 -0
- package/src/utils/guard/types.ts +19 -0
- package/src/utils/guard.ts +41 -30
- package/src/utils/handler/types.ts +28 -0
- package/src/utils/handler.ts +35 -0
- package/src/utils/index.ts +9 -1
- package/src/utils/request/types.ts +23 -0
- package/src/utils/request.ts +40 -0
- package/src/utils/scope.ts +25 -108
- package/tests/creator.spec.ts +18 -18
- package/src/actions/cards.ts +0 -48
- package/src/actions/schemas.ts +0 -87
|
@@ -1,55 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { changesHelper, CommitState, TransitionAction } from '@owlmeans/planning';
|
|
2
2
|
const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* `profileId`, `userId`, `service` and `channel` come only from the scope (the server builds it
|
|
17
|
-
* from the authenticated request); the descriptive `agent`/`runId` an in-process caller passes on
|
|
18
|
-
* the execution are kept unless the scope's own actor names them.
|
|
19
|
-
*/
|
|
20
|
-
export const actorOf = (scope, exec) => clean({
|
|
21
|
-
agent: exec.actor?.agent,
|
|
22
|
-
runId: exec.actor?.runId,
|
|
23
|
-
...clean({ profileId: scope.profileId, userId: scope.userId, service: scope.service }),
|
|
24
|
-
...clean(scope.actor ?? {}),
|
|
25
|
-
channel: scope.channel ?? scope.actor?.channel,
|
|
26
|
-
});
|
|
27
|
-
const withFrom = (link, card) => ({ ...link, from: link.from ?? card });
|
|
28
|
-
/** Step 11's record: the event as it is appended, `pending`. */
|
|
29
|
-
export const transitionOf = (params) => {
|
|
30
|
-
const { exec, resolved, scope, set, cardId, seq, project, at } = params;
|
|
31
|
-
const kind = resolved.create ? exec.card.kind : resolved.card.kind;
|
|
32
|
-
return clean({
|
|
33
|
-
entityId: scope.entityId,
|
|
34
|
-
card: cardId,
|
|
35
|
-
kind,
|
|
36
|
-
type: resolved.type.type,
|
|
37
|
-
project,
|
|
38
|
-
seq,
|
|
39
|
-
action: exec.action,
|
|
40
|
-
flow: set.flow,
|
|
41
|
-
transition: exec.action === TransitionAction.Transit ? exec.transition : undefined,
|
|
42
|
-
from: set.from,
|
|
43
|
-
to: set.to,
|
|
44
|
-
changes: set.changes,
|
|
45
|
-
unset: set.unset.length > 0 ? set.unset : undefined,
|
|
46
|
-
link: exec.link != null && exec.action !== TransitionAction.Create ? withFrom(exec.link, cardId) : undefined,
|
|
47
|
-
links: resolved.create && (exec.links?.length ?? 0) > 0 ? exec.links.map(link => withFrom(link, cardId)) : undefined,
|
|
48
|
-
actor: actorOf(scope, exec),
|
|
49
|
-
cause: exec.cause,
|
|
50
|
-
key: exec.key,
|
|
51
|
-
at,
|
|
52
|
-
commit: { state: CommitState.Pending },
|
|
3
|
+
export const createChangesUtils = () => {
|
|
4
|
+
const changeSetOf = (exec, resolved, schemas, at) => {
|
|
5
|
+
const set = changesHelper.computeChanges(resolved.card, exec, resolved.type, schemas, at, { slot: resolved.slot });
|
|
6
|
+
const empty = exec.action === TransitionAction.Update && changesHelper.isEmptyChange(set);
|
|
7
|
+
return { set, empty };
|
|
8
|
+
};
|
|
9
|
+
const actorOf = (scope, exec) => clean({
|
|
10
|
+
agent: exec.actor?.agent,
|
|
11
|
+
runId: exec.actor?.runId,
|
|
12
|
+
...clean({ profileId: scope.profileId, userId: scope.userId, service: scope.service }),
|
|
13
|
+
...clean(scope.actor ?? {}),
|
|
14
|
+
channel: scope.channel ?? scope.actor?.channel,
|
|
53
15
|
});
|
|
16
|
+
const withFrom = (link, card) => ({ ...link, from: link.from ?? card });
|
|
17
|
+
const transitionOf = (params) => {
|
|
18
|
+
const { exec, resolved, scope, set, cardId, seq, project, at } = params;
|
|
19
|
+
const kind = resolved.create ? exec.card.kind : resolved.card.kind;
|
|
20
|
+
return clean({
|
|
21
|
+
entityId: scope.entityId,
|
|
22
|
+
card: cardId,
|
|
23
|
+
kind,
|
|
24
|
+
type: resolved.type.type,
|
|
25
|
+
project,
|
|
26
|
+
seq,
|
|
27
|
+
action: exec.action,
|
|
28
|
+
flow: set.flow,
|
|
29
|
+
transition: exec.action === TransitionAction.Transit ? exec.transition : undefined,
|
|
30
|
+
from: set.from,
|
|
31
|
+
to: set.to,
|
|
32
|
+
changes: set.changes,
|
|
33
|
+
unset: set.unset.length > 0 ? set.unset : undefined,
|
|
34
|
+
link: exec.link != null && exec.action !== TransitionAction.Create ? withFrom(exec.link, cardId) : undefined,
|
|
35
|
+
links: resolved.create && (exec.links?.length ?? 0) > 0 ? exec.links.map(link => withFrom(link, cardId)) : undefined,
|
|
36
|
+
actor: actorOf(scope, exec),
|
|
37
|
+
cause: exec.cause,
|
|
38
|
+
key: exec.key,
|
|
39
|
+
at,
|
|
40
|
+
commit: { state: CommitState.Pending },
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return { changeSetOf, actorOf, transitionOf };
|
|
54
44
|
};
|
|
45
|
+
export const changesUtils = createChangesUtils();
|
|
55
46
|
//# sourceMappingURL=changes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../../src/executor/changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../../src/execut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,KAAK,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;YAC5G,KAAK,EAAE,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YACrH,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,EAAE;YACF,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,EAAE;SACvC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlanningExecContext, PlanningPlugin, PlanningScope, TransitionExecution } from '@owlmeans/planning';
|
|
2
|
+
import type { PluginRegistry } from '../../types.js';
|
|
3
|
+
import type { Resolved } from '../types.js';
|
|
4
|
+
/** Step 8 of the write path: the code a card gets, unique within its policy's scope. */
|
|
5
|
+
export interface CodeUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Step 8: the code a new card gets, or the check a changed code passes.
|
|
8
|
+
*
|
|
9
|
+
* A caller-supplied code is checked for uniqueness; otherwise the plugins' `mintCode` chain answers
|
|
10
|
+
* (first answer wins, and is checked too); otherwise the type's policy mints one — a slug policy
|
|
11
|
+
* derives it from the title. A type with no policy and no supplied code gets none.
|
|
12
|
+
*
|
|
13
|
+
* @throws {CodeTaken}
|
|
14
|
+
*/
|
|
15
|
+
assignCode: (exec: TransitionExecution, resolved: Resolved, scope: PlanningScope, registry: PluginRegistry, contextOf: (plugin: PlanningPlugin) => PlanningExecContext) => Promise<TransitionExecution>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/code/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACjH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACxB;;;;;;;;OAQG;IACH,UAAU,EAAE,CACV,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,mBAAmB,KACvD,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/code/types.ts"],"names":[],"mappings":""}
|
package/build/executor/code.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const takenProbe: (resolved: Resolved, scope: PlanningScope, parent: string | undefined) => (code: string) => Promise<boolean>;
|
|
5
|
-
/**
|
|
6
|
-
* Step 8: the code a new card gets, or the check a changed code passes.
|
|
7
|
-
*
|
|
8
|
-
* A caller-supplied code is checked for uniqueness; otherwise the plugins' `mintCode` chain answers
|
|
9
|
-
* (first answer wins, and is checked too); otherwise the type's policy mints one — a slug policy
|
|
10
|
-
* derives it from the title. A type with no policy and no supplied code gets none.
|
|
11
|
-
*
|
|
12
|
-
* @throws {CodeTaken}
|
|
13
|
-
*/
|
|
14
|
-
export declare const assignCode: (exec: TransitionExecution, resolved: Resolved, scope: PlanningScope, registry: PluginRegistry, contextOf: (plugin: PlanningPlugin) => PlanningExecContext) => Promise<TransitionExecution>;
|
|
1
|
+
import type { CodeUtils } from './code/types.js';
|
|
2
|
+
export declare const createCodeUtils: () => CodeUtils;
|
|
3
|
+
export declare const codeUtils: CodeUtils;
|
|
15
4
|
//# sourceMappingURL=code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGhD,eAAO,MAAM,eAAe,QAAO,SAmElC,CAAA;AAED,eAAO,MAAM,SAAS,WAAoB,CAAA"}
|
package/build/executor/code.js
CHANGED
|
@@ -1,59 +1,55 @@
|
|
|
1
|
-
import { CODE_MINT_ATTEMPTS, CodeScope, CodeStyle, CodeTaken,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { CODE_MINT_ATTEMPTS, codeHelper, CodeScope, CodeStyle, CodeTaken, TransitionAction } from '@owlmeans/planning';
|
|
2
|
+
export const createCodeUtils = () => {
|
|
3
|
+
/** The criteria a code must be unique within — the policy's scope, `parent` when there is none. */
|
|
4
|
+
const scopeCriteria = (scope, type, parent, policy) => ({
|
|
5
|
+
entityId: scope.entityId,
|
|
6
|
+
type,
|
|
7
|
+
...((policy?.uniqueWithin ?? CodeScope.Parent) === CodeScope.Parent ? { parent: parent ?? null } : {}),
|
|
8
|
+
});
|
|
9
|
+
/** Is a code taken within the scope the type's policy names (its parent when it names none)? */
|
|
10
|
+
const takenProbe = (resolved, scope, parent) => {
|
|
11
|
+
const base = scopeCriteria(scope, resolved.type.type, parent, resolved.type.code);
|
|
12
|
+
return async (code) => await resolved.store.cards.count({ ...base, code }) > 0;
|
|
13
|
+
};
|
|
14
|
+
const assignCode = async (exec, resolved, scope, registry, contextOf) => {
|
|
15
|
+
const policy = resolved.type.code;
|
|
16
|
+
if (exec.action !== TransitionAction.Create) {
|
|
17
|
+
const code = exec.changes?.code;
|
|
18
|
+
if (code != null && code !== resolved.card?.code
|
|
19
|
+
&& await takenProbe(resolved, scope, exec.changes?.parent ?? resolved.card?.parent)(code)) {
|
|
20
|
+
throw new CodeTaken(code);
|
|
21
|
+
}
|
|
22
|
+
return exec;
|
|
23
|
+
}
|
|
24
|
+
const draft = exec.card;
|
|
25
|
+
const taken = takenProbe(resolved, scope, draft.parent);
|
|
26
|
+
if (draft.code != null && draft.code !== '') {
|
|
27
|
+
if (await taken(draft.code)) {
|
|
28
|
+
throw new CodeTaken(draft.code);
|
|
29
|
+
}
|
|
30
|
+
return exec;
|
|
31
|
+
}
|
|
32
|
+
if (policy == null) {
|
|
33
|
+
return exec;
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (await taken(draft.code)) {
|
|
35
|
-
throw new CodeTaken(draft.code);
|
|
35
|
+
let code = await registry.mintCode(draft, taken, contextOf);
|
|
36
|
+
if (code != null) {
|
|
37
|
+
if (await taken(code)) {
|
|
38
|
+
throw new CodeTaken(code);
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new CodeTaken(code);
|
|
41
|
+
else {
|
|
42
|
+
const count = policy.style === CodeStyle.Sequential
|
|
43
|
+
? await resolved.store.cards.count(scopeCriteria(scope, draft.type, draft.parent, policy))
|
|
44
|
+
: undefined;
|
|
45
|
+
code = await codeHelper.mintCode(policy, taken, CODE_MINT_ATTEMPTS, {
|
|
46
|
+
...(policy.style === CodeStyle.Slug ? { seed: draft.title } : {}),
|
|
47
|
+
...(count != null ? { count } : {}),
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
? await resolved.store.cards.count(scopeCriteria(scope, draft.type, draft.parent, policy))
|
|
51
|
-
: undefined;
|
|
52
|
-
code = await mintCode(policy, taken, CODE_MINT_ATTEMPTS, {
|
|
53
|
-
...(policy.style === CodeStyle.Slug ? { seed: draft.title } : {}),
|
|
54
|
-
...(count != null ? { count } : {}),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return { ...exec, card: { ...draft, code } };
|
|
50
|
+
return { ...exec, card: { ...draft, code } };
|
|
51
|
+
};
|
|
52
|
+
return { assignCode };
|
|
58
53
|
};
|
|
54
|
+
export const codeUtils = createCodeUtils();
|
|
59
55
|
//# sourceMappingURL=code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAg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CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC1F,CAAC,CAAC,SAAS,CAAA;YACb,IAAI,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE;gBAClE,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,CAAA;IAC9C,CAAC,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PlanningScope, TransitionExecution } from '@owlmeans/planning';
|
|
2
|
+
/** Who owns a card: `createdBy`, stamped from the scope on a create and fixed after it. */
|
|
3
|
+
export interface CreatorHelper {
|
|
4
|
+
/**
|
|
5
|
+
* The subject a create made under `scope` is stamped with as its `createdBy`: the scope's
|
|
6
|
+
* `profileId`, else its `userId`, else the same two of its `actor` — the authenticated subject an
|
|
7
|
+
* HTTP scope carries, in the same format. `undefined` for a scope that names nobody (a service or a
|
|
8
|
+
* system scope).
|
|
9
|
+
*/
|
|
10
|
+
creatorOf: (scope: PlanningScope) => string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* A create's draft with `createdBy` defaulted to {@link CreatorHelper.creatorOf} the scope. A
|
|
13
|
+
* `createdBy` the caller supplied wins; a scope that names nobody leaves the draft as it is;
|
|
14
|
+
* anything but a create is returned untouched. Never mutates `exec`.
|
|
15
|
+
*
|
|
16
|
+
* The executor applies it to every execution, so an in-process facade create and a wire create
|
|
17
|
+
* stamp the same value.
|
|
18
|
+
*/
|
|
19
|
+
withCreator: (exec: TransitionExecution, scope: PlanningScope) => TransitionExecution;
|
|
20
|
+
/**
|
|
21
|
+
* Refuse an execution that names `createdBy` in `changes` or `unset`, whatever the action — a
|
|
22
|
+
* create included, whose owner is its draft's. After the create it never moves, so an ownership
|
|
23
|
+
* check (`card.createdBy === profileId`) cannot be bypassed by anyone allowed to update the card.
|
|
24
|
+
*
|
|
25
|
+
* The executor runs it with the immutables of step 6, after the `before` chain, so a wire body, an
|
|
26
|
+
* in-process caller and a plugin are refused alike. It is the executor's own check, whatever
|
|
27
|
+
* `@owlmeans/planning` build `changesHelper.assertMutable` comes from.
|
|
28
|
+
*
|
|
29
|
+
* @throws {PlanningError} `planning:immutable:createdBy`
|
|
30
|
+
*/
|
|
31
|
+
assertCreatorFixed: (exec: TransitionExecution) => void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/creator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,GAAG,SAAS,CAAA;IACvD;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,aAAa,KAAK,mBAAmB,CAAA;IACrF;;;;;;;;;;OAUG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/creator/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +1,11 @@
|
|
|
1
1
|
import { type PlanningScope, type TransitionExecution } from '@owlmeans/planning';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* system scope).
|
|
7
|
-
*/
|
|
2
|
+
import type { CreatorHelper } from './creator/types.js';
|
|
3
|
+
export declare const createCreatorHelper: () => CreatorHelper;
|
|
4
|
+
export declare const creatorHelper: CreatorHelper;
|
|
5
|
+
/** @deprecated compat:factory-refactor — use `creatorHelper.creatorOf(…)` */
|
|
8
6
|
export declare const creatorOf: (scope: PlanningScope) => string | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* A create's draft with `createdBy` defaulted to {@link creatorOf} the scope. A `createdBy` the
|
|
11
|
-
* caller supplied wins; a scope that names nobody leaves the draft as it is; anything but a create
|
|
12
|
-
* is returned untouched. Never mutates `exec`.
|
|
13
|
-
*
|
|
14
|
-
* The executor applies it to every execution, so an in-process facade create and a wire create
|
|
15
|
-
* stamp the same value.
|
|
16
|
-
*/
|
|
7
|
+
/** @deprecated compat:factory-refactor — use `creatorHelper.withCreator(…)` */
|
|
17
8
|
export declare const withCreator: (exec: TransitionExecution, scope: PlanningScope) => TransitionExecution;
|
|
18
|
-
/**
|
|
19
|
-
* Refuse an execution that names `createdBy` in `changes` or `unset`, whatever the action — a
|
|
20
|
-
* create included, whose owner is its draft's. After the create it never moves, so an ownership
|
|
21
|
-
* check (`card.createdBy === profileId`) cannot be bypassed by anyone allowed to update the card.
|
|
22
|
-
*
|
|
23
|
-
* The executor runs it with the immutables of step 6, after the `before` chain, so a wire body, an
|
|
24
|
-
* in-process caller and a plugin are refused alike. It is the executor's own check, whatever
|
|
25
|
-
* `@owlmeans/planning` build `assertMutable` comes from.
|
|
26
|
-
*
|
|
27
|
-
* @throws {PlanningError} `planning:immutable:createdBy`
|
|
28
|
-
*/
|
|
9
|
+
/** @deprecated compat:factory-refactor — use `creatorHelper.assertCreatorFixed(…)` */
|
|
29
10
|
export declare const assertCreatorFixed: (exec: TransitionExecution) => void;
|
|
30
11
|
//# sourceMappingURL=creator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.d.ts","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"creator.d.ts","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAElH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,eAAO,MAAM,mBAAmB,QAAO,aAwBtC,CAAA;AAED,eAAO,MAAM,aAAa,eAAwB,CAAA;AAElD,6EAA6E;AAC7E,eAAO,MAAM,SAAS,UAAW,aAAa,KAAG,MAAM,GAAG,SAA2C,CAAA;AAErG,+EAA+E;AAC/E,eAAO,MAAM,WAAW,SAAU,mBAAmB,SAAS,aAAa,KAAG,mBACtC,CAAA;AAExC,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,SAAU,mBAAmB,KAAG,IAA8C,CAAA"}
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
import { PlanningError, TransitionAction } from '@owlmeans/planning';
|
|
2
2
|
import { CREATOR } from './consts.local.js';
|
|
3
3
|
const named = (value) => value != null && value !== '';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (named(exec.card.createdBy)) {
|
|
24
|
-
return exec;
|
|
25
|
-
}
|
|
26
|
-
const creator = creatorOf(scope);
|
|
27
|
-
return creator == null ? exec : { ...exec, card: { ...exec.card, createdBy: creator } };
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Refuse an execution that names `createdBy` in `changes` or `unset`, whatever the action — a
|
|
31
|
-
* create included, whose owner is its draft's. After the create it never moves, so an ownership
|
|
32
|
-
* check (`card.createdBy === profileId`) cannot be bypassed by anyone allowed to update the card.
|
|
33
|
-
*
|
|
34
|
-
* The executor runs it with the immutables of step 6, after the `before` chain, so a wire body, an
|
|
35
|
-
* in-process caller and a plugin are refused alike. It is the executor's own check, whatever
|
|
36
|
-
* `@owlmeans/planning` build `assertMutable` comes from.
|
|
37
|
-
*
|
|
38
|
-
* @throws {PlanningError} `planning:immutable:createdBy`
|
|
39
|
-
*/
|
|
40
|
-
export const assertCreatorFixed = (exec) => {
|
|
41
|
-
if (exec.changes?.[CREATOR] !== undefined
|
|
42
|
-
|| (exec.unset ?? []).some(path => path.split('.')[0] === CREATOR)) {
|
|
43
|
-
throw new PlanningError(`immutable:${CREATOR}`);
|
|
44
|
-
}
|
|
4
|
+
export const createCreatorHelper = () => {
|
|
5
|
+
const creatorOf = (scope) => [scope.profileId, scope.userId, scope.actor?.profileId, scope.actor?.userId].find(named);
|
|
6
|
+
const withCreator = (exec, scope) => {
|
|
7
|
+
if (exec.action !== TransitionAction.Create || exec.card == null || typeof exec.card !== 'object') {
|
|
8
|
+
return exec;
|
|
9
|
+
}
|
|
10
|
+
if (named(exec.card.createdBy)) {
|
|
11
|
+
return exec;
|
|
12
|
+
}
|
|
13
|
+
const creator = creatorOf(scope);
|
|
14
|
+
return creator == null ? exec : { ...exec, card: { ...exec.card, createdBy: creator } };
|
|
15
|
+
};
|
|
16
|
+
const assertCreatorFixed = (exec) => {
|
|
17
|
+
if (exec.changes?.[CREATOR] !== undefined
|
|
18
|
+
|| (exec.unset ?? []).some(path => path.split('.')[0] === CREATOR)) {
|
|
19
|
+
throw new PlanningError(`immutable:${CREATOR}`);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return { creatorOf, withCreator, assertCreatorFixed };
|
|
45
23
|
};
|
|
24
|
+
export const creatorHelper = createCreatorHelper();
|
|
25
|
+
/** @deprecated compat:factory-refactor — use `creatorHelper.creatorOf(…)` */
|
|
26
|
+
export const creatorOf = (scope) => creatorHelper.creatorOf(scope);
|
|
27
|
+
/** @deprecated compat:factory-refactor — use `creatorHelper.withCreator(…)` */
|
|
28
|
+
export const withCreator = (exec, scope) => creatorHelper.withCreator(exec, scope);
|
|
29
|
+
/** @deprecated compat:factory-refactor — use `creatorHelper.assertCreatorFixed(…)` */
|
|
30
|
+
export const assertCreatorFixed = (exec) => creatorHelper.assertCreatorFixed(exec);
|
|
46
31
|
//# sourceMappingURL=creator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.js","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAgD,MAAM,oBAAoB,CAAA;AAClH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"creator.js","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAgD,MAAM,oBAAoB,CAAA;AAClH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAG3C,MAAM,KAAK,GAAG,CAAC,KAAqB,EAAmB,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,CAAA;AAEvF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAkB,EAAE;IACrD,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAsB,EAAE,CAC7D,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK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E;AAC7E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAsB,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAErG,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAyB,EAAE,KAAoB,EAAuB,EAAE,CAClG,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAExC,sFAAsF;AACtF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAyB,EAAQ,EAAE,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PlanningFacade, PlanningSchemaRegistry, TransitionExecution, Workcard, WorkcardKind } from '@owlmeans/planning';
|
|
2
|
+
import type { Resolved } from '../types.js';
|
|
3
|
+
/** Steps 1 and 4 of the write path, over one service runtime. */
|
|
4
|
+
export interface ResolveUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Step 1: a deep copy with trimmed text, `parents ∋ parent` on a draft, and no duplicate `unset`
|
|
7
|
+
* paths. The caller's object is never touched.
|
|
8
|
+
*/
|
|
9
|
+
normalizeExecution: (input: TransitionExecution) => TransitionExecution;
|
|
10
|
+
/**
|
|
11
|
+
* The parent type's rule for a child of `kind`/`type`: a project lists the `cardTypes` (and
|
|
12
|
+
* `projectTypes`) it admits, and one declaring `scopedCardTypes` also admits a card type its layer
|
|
13
|
+
* (`view`, the parent project's resolved schemas) defines as data. Project types are code's alone.
|
|
14
|
+
*
|
|
15
|
+
* @throws {CardTypeNotAllowed}
|
|
16
|
+
*/
|
|
17
|
+
assertChildAllowed: (parent: Workcard, kind: WorkcardKind, type: string, view?: PlanningSchemaRegistry) => void;
|
|
18
|
+
/** The layer a parent project admits data-defined children through — `undefined` without a schema port. */
|
|
19
|
+
childViewOf: (entityId: string, parent: Workcard) => Promise<PlanningSchemaRegistry | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Step 4: the card, its type and flow, its parent and — for a specification — its slot.
|
|
22
|
+
*
|
|
23
|
+
* @throws {WorkcardNotFound | PlanningScopeMismatch | UnknownWorkcardType | UnknownStatusFlow}
|
|
24
|
+
* @throws {ParentNotFound | CardTypeNotAllowed | PlanningError}
|
|
25
|
+
*/
|
|
26
|
+
resolveExecution: (facade: PlanningFacade, exec: TransitionExecution) => Promise<Resolved>;
|
|
27
|
+
/** The project a transition is filed under: a project's own id, else its parent's project. */
|
|
28
|
+
projectFor: (resolved: Resolved, exec: TransitionExecution, cardId: string) => string | undefined;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/resolve/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC7H,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,mBAAmB,CAAA;IACvE;;;;;;OAMG;IACH,kBAAkB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAC/G,2GAA2G;IAC3G,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAA;IAChG;;;;;OAKG;IACH,gBAAgB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1F,8FAA8F;IAC9F,UAAU,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;CAClG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/resolve/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
import { WorkcardKind, type PlanningFacade, type PlanningSchemaRegistry, type TransitionExecution, type Workcard } from '@owlmeans/planning';
|
|
2
1
|
import type { PlanningRuntime } from '../types.js';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
declare const normalizeExecution: (input: TransitionExecution) => TransitionExecution;
|
|
9
|
-
/**
|
|
10
|
-
* The parent type's rule for a child of `kind`/`type`: a project lists the `cardTypes` (and
|
|
11
|
-
* `projectTypes`) it admits, and one declaring `scopedCardTypes` also admits a card type its layer
|
|
12
|
-
* (`view`, the parent project's resolved schemas) defines as data. Project types are code's alone.
|
|
13
|
-
*
|
|
14
|
-
* @throws {CardTypeNotAllowed}
|
|
15
|
-
*/
|
|
16
|
-
declare const assertChildAllowed: (runtime: PlanningRuntime, parent: Workcard, kind: WorkcardKind, type: string, view?: PlanningSchemaRegistry) => void;
|
|
17
|
-
/** The layer a parent project admits data-defined children through — `undefined` without a schema port. */
|
|
18
|
-
declare const childViewOf: (runtime: PlanningRuntime, entityId: string, parent: Workcard) => Promise<PlanningSchemaRegistry | undefined>;
|
|
19
|
-
/**
|
|
20
|
-
* Step 4: the card, its type and flow, its parent and — for a specification — its slot.
|
|
21
|
-
*
|
|
22
|
-
* @throws {WorkcardNotFound | PlanningScopeMismatch | UnknownWorkcardType | UnknownStatusFlow}
|
|
23
|
-
* @throws {ParentNotFound | CardTypeNotAllowed | PlanningError}
|
|
24
|
-
*/
|
|
25
|
-
declare const resolveExecution: (runtime: PlanningRuntime, facade: PlanningFacade, exec: TransitionExecution) => Promise<Resolved>;
|
|
26
|
-
/** The project a transition is filed under: a project's own id, else its parent's project. */
|
|
27
|
-
declare const projectFor: (resolved: Resolved, exec: TransitionExecution, cardId: string) => string | undefined;
|
|
28
|
-
export declare const createResolveHelper: () => {
|
|
29
|
-
normalizeExecution: typeof normalizeExecution;
|
|
30
|
-
assertChildAllowed: typeof assertChildAllowed;
|
|
31
|
-
childViewOf: typeof childViewOf;
|
|
32
|
-
resolveExecution: typeof resolveExecution;
|
|
33
|
-
projectFor: typeof projectFor;
|
|
34
|
-
};
|
|
35
|
-
export declare const resolveHelper: {
|
|
36
|
-
normalizeExecution: typeof normalizeExecution;
|
|
37
|
-
assertChildAllowed: typeof assertChildAllowed;
|
|
38
|
-
childViewOf: typeof childViewOf;
|
|
39
|
-
resolveExecution: typeof resolveExecution;
|
|
40
|
-
projectFor: typeof projectFor;
|
|
41
|
-
};
|
|
42
|
-
export {};
|
|
2
|
+
import type { ResolveUtils } from './resolve/types.js';
|
|
3
|
+
export declare const makeResolveUtils: (runtime: PlanningRuntime) => ResolveUtils;
|
|
4
|
+
/** The resolution steps of one service runtime — one per runtime. */
|
|
5
|
+
export declare const resolveUtilsOf: (target: PlanningRuntime) => ResolveUtils;
|
|
43
6
|
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/executor/resolve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/executor/resolve.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AA6BtD,eAAO,MAAM,gBAAgB,YAAa,eAAe,KAAG,YAsK3D,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,cAAc,2CAAuC,CAAA"}
|