@owlmeans/planning 0.1.18-rc.0

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.
Files changed (139) hide show
  1. package/README.md +169 -0
  2. package/agent-meta/manifest.json +16 -0
  3. package/agent-meta/skills/planning/SKILL.md +248 -0
  4. package/build/consts.d.ts +126 -0
  5. package/build/consts.d.ts.map +1 -0
  6. package/build/consts.js +129 -0
  7. package/build/consts.js.map +1 -0
  8. package/build/entrypoints.d.ts +14 -0
  9. package/build/entrypoints.d.ts.map +1 -0
  10. package/build/entrypoints.js +69 -0
  11. package/build/entrypoints.js.map +1 -0
  12. package/build/errors.d.ts +94 -0
  13. package/build/errors.d.ts.map +1 -0
  14. package/build/errors.js +169 -0
  15. package/build/errors.js.map +1 -0
  16. package/build/helpers/apply.d.ts +27 -0
  17. package/build/helpers/apply.d.ts.map +1 -0
  18. package/build/helpers/apply.js +162 -0
  19. package/build/helpers/apply.js.map +1 -0
  20. package/build/helpers/card.d.ts +17 -0
  21. package/build/helpers/card.d.ts.map +1 -0
  22. package/build/helpers/card.js +31 -0
  23. package/build/helpers/card.js.map +1 -0
  24. package/build/helpers/changes.d.ts +51 -0
  25. package/build/helpers/changes.d.ts.map +1 -0
  26. package/build/helpers/changes.js +277 -0
  27. package/build/helpers/changes.js.map +1 -0
  28. package/build/helpers/code.d.ts +24 -0
  29. package/build/helpers/code.d.ts.map +1 -0
  30. package/build/helpers/code.js +47 -0
  31. package/build/helpers/code.js.map +1 -0
  32. package/build/helpers/index.d.ts +9 -0
  33. package/build/helpers/index.d.ts.map +1 -0
  34. package/build/helpers/index.js +9 -0
  35. package/build/helpers/index.js.map +1 -0
  36. package/build/helpers/query.d.ts +39 -0
  37. package/build/helpers/query.d.ts.map +1 -0
  38. package/build/helpers/query.js +293 -0
  39. package/build/helpers/query.js.map +1 -0
  40. package/build/helpers/specification.d.ts +21 -0
  41. package/build/helpers/specification.d.ts.map +1 -0
  42. package/build/helpers/specification.js +48 -0
  43. package/build/helpers/specification.js.map +1 -0
  44. package/build/helpers/status.d.ts +44 -0
  45. package/build/helpers/status.d.ts.map +1 -0
  46. package/build/helpers/status.js +78 -0
  47. package/build/helpers/status.js.map +1 -0
  48. package/build/helpers/validate.d.ts +30 -0
  49. package/build/helpers/validate.d.ts.map +1 -0
  50. package/build/helpers/validate.js +93 -0
  51. package/build/helpers/validate.js.map +1 -0
  52. package/build/i18n/be.json +51 -0
  53. package/build/i18n/de.json +51 -0
  54. package/build/i18n/en.json +51 -0
  55. package/build/i18n/es.json +51 -0
  56. package/build/i18n/pl.json +51 -0
  57. package/build/i18n/ru.json +51 -0
  58. package/build/i18n/uk.json +51 -0
  59. package/build/i18n.d.ts +2 -0
  60. package/build/i18n.d.ts.map +1 -0
  61. package/build/i18n.js +19 -0
  62. package/build/i18n.js.map +1 -0
  63. package/build/index.d.ts +10 -0
  64. package/build/index.d.ts.map +1 -0
  65. package/build/index.js +9 -0
  66. package/build/index.js.map +1 -0
  67. package/build/models/index.d.ts +7 -0
  68. package/build/models/index.d.ts.map +1 -0
  69. package/build/models/index.js +19 -0
  70. package/build/models/index.js.map +1 -0
  71. package/build/models/project.d.ts +4 -0
  72. package/build/models/project.d.ts.map +1 -0
  73. package/build/models/project.js +17 -0
  74. package/build/models/project.js.map +1 -0
  75. package/build/models/specification.d.ts +4 -0
  76. package/build/models/specification.d.ts.map +1 -0
  77. package/build/models/specification.js +15 -0
  78. package/build/models/specification.js.map +1 -0
  79. package/build/models/workcard.d.ts +14 -0
  80. package/build/models/workcard.d.ts.map +1 -0
  81. package/build/models/workcard.js +103 -0
  82. package/build/models/workcard.js.map +1 -0
  83. package/build/queue/index.d.ts +25 -0
  84. package/build/queue/index.d.ts.map +1 -0
  85. package/build/queue/index.js +14 -0
  86. package/build/queue/index.js.map +1 -0
  87. package/build/registry.d.ts +10 -0
  88. package/build/registry.d.ts.map +1 -0
  89. package/build/registry.js +75 -0
  90. package/build/registry.js.map +1 -0
  91. package/build/schemas.d.ts +56 -0
  92. package/build/schemas.d.ts.map +1 -0
  93. package/build/schemas.js +578 -0
  94. package/build/schemas.js.map +1 -0
  95. package/build/types.d.ts +785 -0
  96. package/build/types.d.ts.map +1 -0
  97. package/build/types.js +2 -0
  98. package/build/types.js.map +1 -0
  99. package/package.json +58 -0
  100. package/src/consts.ts +136 -0
  101. package/src/entrypoints.ts +127 -0
  102. package/src/errors.ts +207 -0
  103. package/src/helpers/apply.ts +183 -0
  104. package/src/helpers/card.ts +42 -0
  105. package/src/helpers/changes.ts +333 -0
  106. package/src/helpers/code.ts +66 -0
  107. package/src/helpers/index.ts +8 -0
  108. package/src/helpers/query.ts +345 -0
  109. package/src/helpers/specification.ts +65 -0
  110. package/src/helpers/status.ts +117 -0
  111. package/src/helpers/validate.ts +107 -0
  112. package/src/i18n/be.json +51 -0
  113. package/src/i18n/de.json +51 -0
  114. package/src/i18n/en.json +51 -0
  115. package/src/i18n/es.json +51 -0
  116. package/src/i18n/pl.json +51 -0
  117. package/src/i18n/ru.json +51 -0
  118. package/src/i18n/uk.json +51 -0
  119. package/src/i18n.ts +21 -0
  120. package/src/index.ts +9 -0
  121. package/src/models/index.ts +21 -0
  122. package/src/models/project.ts +24 -0
  123. package/src/models/specification.ts +21 -0
  124. package/src/models/workcard.ts +138 -0
  125. package/src/queue/index.ts +31 -0
  126. package/src/registry.ts +90 -0
  127. package/src/schemas.ts +654 -0
  128. package/src/types.ts +837 -0
  129. package/tests/apply.spec.ts +176 -0
  130. package/tests/code.spec.ts +40 -0
  131. package/tests/entrypoints.spec.ts +57 -0
  132. package/tests/fixtures.ts +124 -0
  133. package/tests/i18n.spec.ts +30 -0
  134. package/tests/models.spec.ts +133 -0
  135. package/tests/query.spec.ts +90 -0
  136. package/tests/schemas.spec.ts +74 -0
  137. package/tests/status.spec.ts +75 -0
  138. package/tests/tsconfig.json +17 -0
  139. package/tsconfig.json +15 -0
@@ -0,0 +1,129 @@
1
+ /** What a workcard IS. Cards, projects and specifications share one id space and one fold. */
2
+ export var WorkcardKind;
3
+ (function (WorkcardKind) {
4
+ WorkcardKind["Card"] = "card";
5
+ WorkcardKind["Project"] = "project";
6
+ WorkcardKind["Specification"] = "specification";
7
+ })(WorkcardKind || (WorkcardKind = {}));
8
+ /**
9
+ * The three states every status of every flow maps onto.
10
+ *
11
+ * A provider's statuses are its own vocabulary; these three are the only ones generic code — a
12
+ * summary, a board header, a gate — ever reads.
13
+ */
14
+ export var IntrinsicStatus;
15
+ (function (IntrinsicStatus) {
16
+ IntrinsicStatus["Planned"] = "planned";
17
+ IntrinsicStatus["InProgress"] = "in-progress";
18
+ IntrinsicStatus["Closed"] = "closed";
19
+ })(IntrinsicStatus || (IntrinsicStatus = {}));
20
+ /** Advancement order — `resolveIntrinsic` under {@link IntrinsicPolicy.All} takes the minimum. */
21
+ export const INTRINSIC_ORDER = Object.freeze({
22
+ [IntrinsicStatus.Planned]: 0,
23
+ [IntrinsicStatus.InProgress]: 1,
24
+ [IntrinsicStatus.Closed]: 2,
25
+ });
26
+ /** How a type running several flows answers its one intrinsic status. */
27
+ export var IntrinsicPolicy;
28
+ (function (IntrinsicPolicy) {
29
+ /** The primary flow's status decides. */
30
+ IntrinsicPolicy["Primary"] = "primary";
31
+ /** The least advanced flow decides — closed only when every flow is closed. */
32
+ IntrinsicPolicy["All"] = "all";
33
+ })(IntrinsicPolicy || (IntrinsicPolicy = {}));
34
+ export var TransitionAction;
35
+ (function (TransitionAction) {
36
+ TransitionAction["Create"] = "create";
37
+ TransitionAction["Update"] = "update";
38
+ TransitionAction["Transit"] = "transit";
39
+ TransitionAction["Link"] = "link";
40
+ TransitionAction["Unlink"] = "unlink";
41
+ TransitionAction["Delete"] = "delete";
42
+ })(TransitionAction || (TransitionAction = {}));
43
+ export var CommitState;
44
+ (function (CommitState) {
45
+ CommitState["Pending"] = "pending";
46
+ CommitState["Committed"] = "committed";
47
+ CommitState["Failed"] = "failed";
48
+ })(CommitState || (CommitState = {}));
49
+ export var SpecificationFormat;
50
+ (function (SpecificationFormat) {
51
+ SpecificationFormat["Markdown"] = "markdown";
52
+ SpecificationFormat["Json"] = "json";
53
+ SpecificationFormat["Text"] = "text";
54
+ })(SpecificationFormat || (SpecificationFormat = {}));
55
+ export var CodeStyle;
56
+ (function (CodeStyle) {
57
+ CodeStyle["Random"] = "random";
58
+ CodeStyle["Sequential"] = "sequential";
59
+ CodeStyle["Slug"] = "slug";
60
+ })(CodeStyle || (CodeStyle = {}));
61
+ /** Where a minted code must be unique. */
62
+ export var CodeScope;
63
+ (function (CodeScope) {
64
+ CodeScope["Parent"] = "parent";
65
+ CodeScope["Entity"] = "entity";
66
+ })(CodeScope || (CodeScope = {}));
67
+ /** Service alias of the planning facade host. Identical on the server and in a client. */
68
+ export const PLANNING_SERVICE = 'planning';
69
+ /** The path segment the protocol tree answers under when the mount names none. */
70
+ export const PLANNING_PATH = '/planning';
71
+ /** The socket frame name the commit feed pushes under. */
72
+ export const PLANNING_COMMIT_EVENT = 'planning-commit';
73
+ /** The i18n resource the package's labels are registered under (`lib:planning.*`). */
74
+ export const PLANNING_I18N = 'planning';
75
+ /** A `from` that matches every status of the flow. */
76
+ export const ANY_STATUS = '*';
77
+ /** How long `committed()` waits by default, in milliseconds. */
78
+ export const DEFAULT_COMMIT_TIMEOUT = 30_000;
79
+ /** Seconds a single long poll of `commit.get` holds by default. */
80
+ export const DEFAULT_COMMIT_POLL = 20;
81
+ /** The longest single long poll a server grants, in seconds. */
82
+ export const MAX_COMMIT_POLL = 55;
83
+ /** Re-rolls a code policy gets before it refuses with `CodeTaken`. */
84
+ export const CODE_MINT_ATTEMPTS = 8;
85
+ /** Random part length of a code policy that names none. */
86
+ export const DEFAULT_CODE_LENGTH = 6;
87
+ export const DEFAULT_PLUGIN_ORDER = 50;
88
+ export const DEFAULT_PAGE_SIZE = 100;
89
+ export const PLANNING_SCHEMA_VERSION = 1;
90
+ export const TITLE_MAX = 2048;
91
+ export const DESCRIPTION_MAX = 16384;
92
+ export const CODE_MAX = 64;
93
+ export const TYPE_MAX = 128;
94
+ export const LABEL_MAX = 64;
95
+ export const MAX_LABELS = 32;
96
+ export const MAX_PARENTS = 32;
97
+ export const BODY_MAX = 1_048_576;
98
+ export const CAUSE_MAX = 256;
99
+ export const KEY_MAX = 256;
100
+ export const REF_MAX = 1024;
101
+ export const QUERY_TEXT_MAX = 256;
102
+ /** The longest list a wire query carries in one value (ids, parents). */
103
+ export const MAX_QUERY_LIST = 500;
104
+ /**
105
+ * The aliases one planning tree answers under, derived from the mount's base alias.
106
+ *
107
+ * Two mounts of the tree in one deployment are two base aliases, never two copies of this table —
108
+ * which is why nothing here is a global constant.
109
+ */
110
+ export const planningAliases = (base) => Object.freeze({
111
+ base,
112
+ schema: Object.freeze({ list: `${base}:schema:list` }),
113
+ card: Object.freeze({
114
+ list: `${base}:card:list`,
115
+ summary: `${base}:card:summary`,
116
+ get: `${base}:card:get`,
117
+ transitions: `${base}:card:transitions`,
118
+ specifications: `${base}:card:specifications`,
119
+ }),
120
+ spec: Object.freeze({
121
+ get: `${base}:specification:get`,
122
+ revisions: `${base}:specification:revisions`,
123
+ }),
124
+ link: Object.freeze({ list: `${base}:link:list` }),
125
+ transition: Object.freeze({ get: `${base}:transition:get` }),
126
+ execute: `${base}:execute`,
127
+ commit: Object.freeze({ get: `${base}:commit:get`, events: `${base}:commit:events` }),
128
+ });
129
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,+CAA+B,CAAA;AACjC,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,6CAA0B,CAAA;IAC1B,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,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { PlanningProtocolOptions, PlanningProtocols } from './types.js';
2
+ /**
3
+ * Declare the planning surface — one immutable tree a server binds and a client calls.
4
+ *
5
+ * Every leaf hangs under ONE base carrying the guards (and the gate), so they cannot drift apart;
6
+ * aliases derive from `opts.base.alias`. Static `/cards/summary` is declared before parametric
7
+ * `/cards/:id`. The commit feed is a socket under `socketBase` when given (it then inherits that
8
+ * base's guards), under the planning base otherwise.
9
+ *
10
+ * Queries travel as their `*Wire` shapes: encode with `encode*Query` before a call, decode with
11
+ * `decode*Query` in a handler.
12
+ */
13
+ export declare const makePlanningProtocols: (opts: PlanningProtocolOptions) => PlanningProtocols;
14
+ //# sourceMappingURL=entrypoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAC+D,uBAAuB,EAChG,iBAAiB,EAIlB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,SAAU,uBAAuB,KAAG,iBAiGrE,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint';
2
+ import { backend, route, RouteMethod, socket } from '@owlmeans/route';
3
+ import { PLANNING_PATH, planningAliases } from './consts.js';
4
+ import { CommitQuerySchema, ExecuteRequestSchema, RelationshipQuerySchema, RevisionsQuerySchema, SpecificationQuerySchema, SummaryQuerySchema, TransitionParamsSchema, TransitionQuerySchema, WorkcardParamsSchema, WorkcardQuerySchema, } from './schemas.js';
5
+ /**
6
+ * Declare the planning surface — one immutable tree a server binds and a client calls.
7
+ *
8
+ * Every leaf hangs under ONE base carrying the guards (and the gate), so they cannot drift apart;
9
+ * aliases derive from `opts.base.alias`. Static `/cards/summary` is declared before parametric
10
+ * `/cards/:id`. The commit feed is a socket under `socketBase` when given (it then inherits that
11
+ * base's guards), under the planning base otherwise.
12
+ *
13
+ * Queries travel as their `*Wire` shapes: encode with `encode*Query` before a call, decode with
14
+ * `decode*Query` in a handler.
15
+ */
16
+ export const makePlanningProtocols = (opts) => {
17
+ const aliases = planningAliases(opts.base.alias);
18
+ const mount = {
19
+ ...(opts.base.parent != null ? { parent: opts.base.parent } : {}),
20
+ ...(opts.base.service != null ? { service: opts.base.service } : {}),
21
+ };
22
+ const base = openProtocol(route(aliases.base, opts.base.path ?? PLANNING_PATH, backend(mount)), {
23
+ guards: opts.guards,
24
+ ...(opts.gate != null ? { gate: opts.gate } : {}),
25
+ });
26
+ const get = (alias, path) => route(alias, path, backend({ parent: base }, RouteMethod.GET));
27
+ return Object.freeze({
28
+ base,
29
+ schema: Object.freeze({
30
+ list: protocol(get(aliases.schema.list, '/schemas'), contract(typed())),
31
+ }),
32
+ card: Object.freeze({
33
+ list: protocol(get(aliases.card.list, '/cards'), contract.request({ query: typed(WorkcardQuerySchema) }, typed())),
34
+ // Static before parametric: `/cards/summary` must never be read as a card id.
35
+ summary: protocol(get(aliases.card.summary, '/cards/summary'), contract.request({ query: typed(SummaryQuerySchema) }, typed())),
36
+ get: protocol(get(aliases.card.get, '/cards/:id'), contract.request({ params: typed(WorkcardParamsSchema) }, typed())),
37
+ transitions: protocol(get(aliases.card.transitions, '/cards/:id/transitions'), contract.request({
38
+ params: typed(WorkcardParamsSchema),
39
+ query: typed(TransitionQuerySchema),
40
+ }, typed())),
41
+ specifications: protocol(get(aliases.card.specifications, '/cards/:id/specifications'), contract.request({
42
+ params: typed(WorkcardParamsSchema),
43
+ query: typed(SpecificationQuerySchema),
44
+ }, typed())),
45
+ }),
46
+ spec: Object.freeze({
47
+ get: protocol(get(aliases.spec.get, '/specifications/:id'), contract.request({ params: typed(WorkcardParamsSchema) }, typed())),
48
+ revisions: protocol(get(aliases.spec.revisions, '/specifications/:id/revisions'), contract.request({
49
+ params: typed(WorkcardParamsSchema),
50
+ query: typed(RevisionsQuerySchema),
51
+ }, typed())),
52
+ }),
53
+ link: Object.freeze({
54
+ list: protocol(get(aliases.link.list, '/links'), contract.request({ query: typed(RelationshipQuerySchema) }, typed())),
55
+ }),
56
+ transition: Object.freeze({
57
+ get: protocol(get(aliases.transition.get, '/transitions/:transition'), contract.request({ params: typed(TransitionParamsSchema) }, typed())),
58
+ }),
59
+ execute: protocol(route(aliases.execute, '/execute', backend({ parent: base }, RouteMethod.POST)), contract.request({ body: typed(ExecuteRequestSchema) }, typed())),
60
+ commit: Object.freeze({
61
+ get: protocol(get(aliases.commit.get, '/commits/:transition'), contract.request({
62
+ params: typed(TransitionParamsSchema),
63
+ query: typed(CommitQuerySchema),
64
+ }, typed())),
65
+ events: protocol(route(aliases.commit.events, '/commits', socket({ parent: opts.socketBase ?? base })), contract.request({ query: typed() }, typed())),
66
+ }),
67
+ });
68
+ };
69
+ //# sourceMappingURL=entrypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE9E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAErE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EACL,iBAAiB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,oBAAoB,EACtF,wBAAwB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,qBAAqB,EAC3F,oBAAoB,EAAE,mBAAmB,GAC1C,MAAM,cAAc,CAAA;AASrB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAA6B,EAAqB,EAAE;IACxF,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAChD,MAAM,KA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X,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,sBAAsB,CAAC,EAC/C,QAAQ,CAAC,OAAO,CAAC;gBACf,MAAM,EAAE,KAAK,CAAmB,sBAAsB,CAAC;gBACvD,KAAK,EAAE,KAAK,CAAc,iBAAiB,CAAC;aAC7C,EAAE,KAAK,EAAgB,CAAC,CAC1B;YACD,MAAM,EAAE,QAAQ,CACd,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC,CAAC,EACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAmB,EAAE,EAAE,KAAK,EAAe,CAAC,CAC5E;SACF,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,94 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ /**
3
+ * The planning refusal family.
4
+ *
5
+ * Every message starts with `planning:` followed by the class's own marker (`workcard-not-found:`,
6
+ * `illegal-transition:` …) and the detail. The marker is what survives a hop where the class is not
7
+ * registered, so it is part of the contract, not decoration.
8
+ */
9
+ export declare class PlanningError extends ResilientError {
10
+ static typeName: string;
11
+ constructor(message?: string);
12
+ }
13
+ /** The card does not exist — or belongs to another entity, which is deliberately the same answer. */
14
+ export declare class WorkcardNotFound extends PlanningError {
15
+ static typeName: string;
16
+ constructor(message?: string);
17
+ }
18
+ export declare class UnknownWorkcardType extends PlanningError {
19
+ static typeName: string;
20
+ constructor(message?: string);
21
+ }
22
+ export declare class UnknownStatusFlow extends PlanningError {
23
+ static typeName: string;
24
+ constructor(message?: string);
25
+ }
26
+ export declare class ParentNotFound extends PlanningError {
27
+ static typeName: string;
28
+ constructor(message?: string);
29
+ }
30
+ /** The parent project's type does not list this card (or project) type. */
31
+ export declare class CardTypeNotAllowed extends PlanningError {
32
+ static typeName: string;
33
+ constructor(message?: string);
34
+ }
35
+ /** A plugin's `before` middleware refused the execution without a class of its own. */
36
+ export declare class PlanningRefused extends PlanningError {
37
+ static typeName: string;
38
+ constructor(message?: string);
39
+ }
40
+ /** The flow offers no rule of that name from the card's current status. */
41
+ export declare class IllegalTransition extends PlanningError {
42
+ static typeName: string;
43
+ constructor(message?: string);
44
+ }
45
+ export declare class FieldsInvalid extends PlanningError {
46
+ static typeName: string;
47
+ constructor(message?: string);
48
+ }
49
+ export declare class LabelNotAllowed extends PlanningError {
50
+ static typeName: string;
51
+ constructor(message?: string);
52
+ }
53
+ export declare class SpecificationSlotUnknown extends PlanningError {
54
+ static typeName: string;
55
+ constructor(message?: string);
56
+ }
57
+ /** A second document for a slot that holds one — revise the existing record instead. */
58
+ export declare class SpecificationRevisionConflict extends PlanningError {
59
+ static typeName: string;
60
+ constructor(message?: string);
61
+ }
62
+ export declare class RelationshipRefused extends PlanningError {
63
+ static typeName: string;
64
+ constructor(message?: string);
65
+ }
66
+ export declare class CodeTaken extends PlanningError {
67
+ static typeName: string;
68
+ constructor(message?: string);
69
+ }
70
+ /** `expectSeq` no longer matches the card's head — somebody else wrote first. Re-read and retry. */
71
+ export declare class WorkcardConflict extends PlanningError {
72
+ static typeName: string;
73
+ constructor(message?: string);
74
+ }
75
+ /** The transition was appended but did not commit in time. It stays pending — nothing is undone. */
76
+ export declare class CommitTimeout extends PlanningError {
77
+ static typeName: string;
78
+ constructor(message?: string);
79
+ }
80
+ export declare class CommitFailed extends PlanningError {
81
+ static typeName: string;
82
+ constructor(message?: string);
83
+ }
84
+ /** A card of another entity was addressed. Handlers answer it as {@link WorkcardNotFound}. */
85
+ export declare class PlanningScopeMismatch extends PlanningError {
86
+ static typeName: string;
87
+ constructor(message?: string);
88
+ }
89
+ /** The store behind this type cannot do what was asked (a foreign provider without a log). */
90
+ export declare class PlanningUnsupported extends PlanningError {
91
+ static typeName: string;
92
+ constructor(message?: string);
93
+ }
94
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1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AY,OAAO,GAAE,MAAgB,EAGpC;CACF"}
@@ -0,0 +1,169 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ /**
3
+ * The planning refusal family.
4
+ *
5
+ * Every message starts with `planning:` followed by the class's own marker (`workcard-not-found:`,
6
+ * `illegal-transition:` …) and the detail. The marker is what survives a hop where the class is not
7
+ * registered, so it is part of the contract, not decoration.
8
+ */
9
+ export class PlanningError extends ResilientError {
10
+ static typeName = 'PlanningError';
11
+ constructor(message = 'error') {
12
+ super(PlanningError.typeName, `planning:${message}`);
13
+ }
14
+ }
15
+ /** The card does not exist — or belongs to another entity, which is deliberately the same answer. */
16
+ export class WorkcardNotFound extends PlanningError {
17
+ static typeName = `${PlanningError.typeName}WorkcardNotFound`;
18
+ constructor(message = 'error') {
19
+ super(`workcard-not-found:${message}`);
20
+ this.type = WorkcardNotFound.typeName;
21
+ }
22
+ }
23
+ export class UnknownWorkcardType extends PlanningError {
24
+ static typeName = `${PlanningError.typeName}UnknownWorkcardType`;
25
+ constructor(message = 'error') {
26
+ super(`unknown-type:${message}`);
27
+ this.type = UnknownWorkcardType.typeName;
28
+ }
29
+ }
30
+ export class UnknownStatusFlow extends PlanningError {
31
+ static typeName = `${PlanningError.typeName}UnknownStatusFlow`;
32
+ constructor(message = 'error') {
33
+ super(`unknown-flow:${message}`);
34
+ this.type = UnknownStatusFlow.typeName;
35
+ }
36
+ }
37
+ export class ParentNotFound extends PlanningError {
38
+ static typeName = `${PlanningError.typeName}ParentNotFound`;
39
+ constructor(message = 'error') {
40
+ super(`parent-not-found:${message}`);
41
+ this.type = ParentNotFound.typeName;
42
+ }
43
+ }
44
+ /** The parent project's type does not list this card (or project) type. */
45
+ export class CardTypeNotAllowed extends PlanningError {
46
+ static typeName = `${PlanningError.typeName}CardTypeNotAllowed`;
47
+ constructor(message = 'error') {
48
+ super(`card-type-not-allowed:${message}`);
49
+ this.type = CardTypeNotAllowed.typeName;
50
+ }
51
+ }
52
+ /** A plugin's `before` middleware refused the execution without a class of its own. */
53
+ export class PlanningRefused extends PlanningError {
54
+ static typeName = `${PlanningError.typeName}Refused`;
55
+ constructor(message = 'error') {
56
+ super(`refused:${message}`);
57
+ this.type = PlanningRefused.typeName;
58
+ }
59
+ }
60
+ /** The flow offers no rule of that name from the card's current status. */
61
+ export class IllegalTransition extends PlanningError {
62
+ static typeName = `${PlanningError.typeName}IllegalTransition`;
63
+ constructor(message = 'error') {
64
+ super(`illegal-transition:${message}`);
65
+ this.type = IllegalTransition.typeName;
66
+ }
67
+ }
68
+ export class FieldsInvalid extends PlanningError {
69
+ static typeName = `${PlanningError.typeName}FieldsInvalid`;
70
+ constructor(message = 'error') {
71
+ super(`fields-invalid:${message}`);
72
+ this.type = FieldsInvalid.typeName;
73
+ }
74
+ }
75
+ export class LabelNotAllowed extends PlanningError {
76
+ static typeName = `${PlanningError.typeName}LabelNotAllowed`;
77
+ constructor(message = 'error') {
78
+ super(`label-not-allowed:${message}`);
79
+ this.type = LabelNotAllowed.typeName;
80
+ }
81
+ }
82
+ export class SpecificationSlotUnknown extends PlanningError {
83
+ static typeName = `${PlanningError.typeName}SpecificationSlotUnknown`;
84
+ constructor(message = 'error') {
85
+ super(`specification-slot-unknown:${message}`);
86
+ this.type = SpecificationSlotUnknown.typeName;
87
+ }
88
+ }
89
+ /** A second document for a slot that holds one — revise the existing record instead. */
90
+ export class SpecificationRevisionConflict extends PlanningError {
91
+ static typeName = `${PlanningError.typeName}SpecificationRevisionConflict`;
92
+ constructor(message = 'error') {
93
+ super(`specification-revision-conflict:${message}`);
94
+ this.type = SpecificationRevisionConflict.typeName;
95
+ }
96
+ }
97
+ export class RelationshipRefused extends PlanningError {
98
+ static typeName = `${PlanningError.typeName}RelationshipRefused`;
99
+ constructor(message = 'error') {
100
+ super(`relationship-refused:${message}`);
101
+ this.type = RelationshipRefused.typeName;
102
+ }
103
+ }
104
+ export class CodeTaken extends PlanningError {
105
+ static typeName = `${PlanningError.typeName}CodeTaken`;
106
+ constructor(message = 'error') {
107
+ super(`code-taken:${message}`);
108
+ this.type = CodeTaken.typeName;
109
+ }
110
+ }
111
+ /** `expectSeq` no longer matches the card's head — somebody else wrote first. Re-read and retry. */
112
+ export class WorkcardConflict extends PlanningError {
113
+ static typeName = `${PlanningError.typeName}WorkcardConflict`;
114
+ constructor(message = 'error') {
115
+ super(`workcard-conflict:${message}`);
116
+ this.type = WorkcardConflict.typeName;
117
+ }
118
+ }
119
+ /** The transition was appended but did not commit in time. It stays pending — nothing is undone. */
120
+ export class CommitTimeout extends PlanningError {
121
+ static typeName = `${PlanningError.typeName}CommitTimeout`;
122
+ constructor(message = 'error') {
123
+ super(`commit-timeout:${message}`);
124
+ this.type = CommitTimeout.typeName;
125
+ }
126
+ }
127
+ export class CommitFailed extends PlanningError {
128
+ static typeName = `${PlanningError.typeName}CommitFailed`;
129
+ constructor(message = 'error') {
130
+ super(`commit-failed:${message}`);
131
+ this.type = CommitFailed.typeName;
132
+ }
133
+ }
134
+ /** A card of another entity was addressed. Handlers answer it as {@link WorkcardNotFound}. */
135
+ export class PlanningScopeMismatch extends PlanningError {
136
+ static typeName = `${PlanningError.typeName}ScopeMismatch`;
137
+ constructor(message = 'error') {
138
+ super(`scope-mismatch:${message}`);
139
+ this.type = PlanningScopeMismatch.typeName;
140
+ }
141
+ }
142
+ /** The store behind this type cannot do what was asked (a foreign provider without a log). */
143
+ export class PlanningUnsupported extends PlanningError {
144
+ static typeName = `${PlanningError.typeName}Unsupported`;
145
+ constructor(message = 'error') {
146
+ super(`unsupported:${message}`);
147
+ this.type = PlanningUnsupported.typeName;
148
+ }
149
+ }
150
+ ResilientError.registerErrorClass(PlanningError);
151
+ ResilientError.registerErrorClass(WorkcardNotFound);
152
+ ResilientError.registerErrorClass(UnknownWorkcardType);
153
+ ResilientError.registerErrorClass(UnknownStatusFlow);
154
+ ResilientError.registerErrorClass(ParentNotFound);
155
+ ResilientError.registerErrorClass(CardTypeNotAllowed);
156
+ ResilientError.registerErrorClass(PlanningRefused);
157
+ ResilientError.registerErrorClass(IllegalTransition);
158
+ ResilientError.registerErrorClass(FieldsInvalid);
159
+ ResilientError.registerErrorClass(LabelNotAllowed);
160
+ ResilientError.registerErrorClass(SpecificationSlotUnknown);
161
+ ResilientError.registerErrorClass(SpecificationRevisionConflict);
162
+ ResilientError.registerErrorClass(RelationshipRefused);
163
+ ResilientError.registerErrorClass(CodeTaken);
164
+ ResilientError.registerErrorClass(WorkcardConflict);
165
+ ResilientError.registerErrorClass(CommitTimeout);
166
+ ResilientError.registerErrorClass(CommitFailed);
167
+ ResilientError.registerErrorClass(PlanningScopeMismatch);
168
+ ResilientError.registerErrorClass(PlanningUnsupported);
169
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IACxC,MAAM,CAAU,QAAQ,GAAW,eAAe,CAAA;IAEzD,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,YAAY,OAAO,EAAE,CAAC,CAAA;IACtD,CAAC;CACF;AAED,qGAAqG;AACrG,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAC1C,MAAM,CAAU,QAAQ,GAAW,GAAG,aAAa,CAAC,QAAQ,kBAAkB,CAAA;IAErF,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAA;IACvC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAC7C,MAAM,CAAU,QAAQ,GAAW,GAAG,aAAa,CAAC,QAAQ,qBAAqB,CAAA;IAExF,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,gBA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AAC,eAAe,CAAC,CAAA;AAClD,cAAc,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAA;AAC3D,cAAc,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,CAAA;AAChE,cAAc,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;AACtD,cAAc,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;AAC5C,cAAc,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;AACnD,cAAc,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;AAChD,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,CAAA;AACxD,cAAc,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,27 @@
1
+ import type { Relationship, Transition, Workcard } from '../types.js';
2
+ /**
3
+ * THE fold: the card after one transition. Pure, total, no I/O — every store (memory, Mongo, a
4
+ * client mirror) folds with this and nothing else, so one log always means one card.
5
+ *
6
+ * - An already-applied transition (`seq <= card.seq`) returns the card unchanged: re-folding is
7
+ * safe.
8
+ * - Anything but the next seq (`card.seq + 1`, or 1 for a create with no card) is refused with
9
+ * `PlanningError('fold:out-of-order')`.
10
+ * - `create` builds the whole record from `changes` plus the transition's identity; `delete`
11
+ * answers `null`; `link`/`unlink` only move `seq`/`head`/`updatedAt` (the edges are
12
+ * {@link applyRelationship}'s); `update`/`transit` write `changes` — `fields` and `flows` merge,
13
+ * everything else replaces — and clear `unset`.
14
+ * - Every result has `seq = transition.seq`, `head = max(head, seq)`, `updatedAt = transition.at`.
15
+ *
16
+ * @throws {PlanningError} `planning:fold:out-of-order:…`
17
+ */
18
+ export declare const applyTransition: <T extends Workcard = Workcard>(card: T | null | undefined, transition: Transition) => T | null;
19
+ /**
20
+ * The relationships after one transition. Pure and total, like {@link applyTransition}.
21
+ *
22
+ * `create` adds its `links`, `link` adds its `link`, `unlink` removes the matching edge, and a
23
+ * `delete` removes every edge touching the card. An edge that already exists is kept as it is, so
24
+ * re-folding adds nothing. Every other action answers the list unchanged. Always a new array.
25
+ */
26
+ export declare const applyRelationship: (links: Relationship[], transition: Transition) => Relationship[];
27
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/helpers/apply.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAqB,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AA+DxF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,QAAQ,GAAG,QAAQ,QACrD,CAAC,GAAG,IAAI,GAAG,SAAS,cAAc,UAAU,KACjD,CAAC,GAAG,IAoDN,CAAA;AAgBD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,UAAW,YAAY,EAAE,cAAc,UAAU,KAAG,YAAY,EAwB7F,CAAA"}