@owlmeans/planning 0.1.18-rc.2 → 0.1.18-rc.21

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 (228) hide show
  1. package/README.md +69 -26
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/planning/SKILL.md +157 -45
  4. package/build/aliases/types.d.ts +49 -0
  5. package/build/aliases/types.d.ts.map +1 -0
  6. package/build/aliases/types.js +2 -0
  7. package/build/aliases/types.js.map +1 -0
  8. package/build/aliases.d.ts +4 -0
  9. package/build/aliases.d.ts.map +1 -0
  10. package/build/aliases.js +27 -0
  11. package/build/aliases.js.map +1 -0
  12. package/build/consts.d.ts +23 -34
  13. package/build/consts.d.ts.map +1 -1
  14. package/build/consts.js +26 -25
  15. package/build/consts.js.map +1 -1
  16. package/build/entrypoints/types.d.ts +96 -0
  17. package/build/entrypoints/types.d.ts.map +1 -0
  18. package/build/entrypoints/types.js +2 -0
  19. package/build/entrypoints/types.js.map +1 -0
  20. package/build/entrypoints.d.ts +5 -1
  21. package/build/entrypoints.d.ts.map +1 -1
  22. package/build/entrypoints.js +17 -6
  23. package/build/entrypoints.js.map +1 -1
  24. package/build/errors.d.ts +41 -0
  25. package/build/errors.d.ts.map +1 -1
  26. package/build/errors.js +61 -0
  27. package/build/errors.js.map +1 -1
  28. package/build/helpers/apply/consts.local.d.ts +7 -0
  29. package/build/helpers/apply/consts.local.d.ts.map +1 -0
  30. package/build/helpers/apply/consts.local.js +9 -0
  31. package/build/helpers/apply/consts.local.js.map +1 -0
  32. package/build/helpers/apply/types.d.ts +32 -0
  33. package/build/helpers/apply/types.d.ts.map +1 -0
  34. package/build/helpers/apply/types.js +2 -0
  35. package/build/helpers/apply/types.js.map +1 -0
  36. package/build/helpers/apply.d.ts +5 -23
  37. package/build/helpers/apply.d.ts.map +1 -1
  38. package/build/helpers/apply.js +121 -143
  39. package/build/helpers/apply.js.map +1 -1
  40. package/build/helpers/card/types.d.ts +20 -0
  41. package/build/helpers/card/types.d.ts.map +1 -0
  42. package/build/helpers/card/types.js +2 -0
  43. package/build/helpers/card/types.js.map +1 -0
  44. package/build/helpers/card.d.ts +11 -7
  45. package/build/helpers/card.d.ts.map +1 -1
  46. package/build/helpers/card.js +41 -28
  47. package/build/helpers/card.js.map +1 -1
  48. package/build/helpers/changes/consts.local.d.ts +13 -0
  49. package/build/helpers/changes/consts.local.d.ts.map +1 -0
  50. package/build/helpers/changes/consts.local.js +13 -0
  51. package/build/helpers/changes/consts.local.js.map +1 -0
  52. package/build/helpers/changes/types.d.ts +58 -0
  53. package/build/helpers/changes/types.d.ts.map +1 -0
  54. package/build/helpers/changes/types.js +2 -0
  55. package/build/helpers/changes/types.js.map +1 -0
  56. package/build/helpers/changes.d.ts +11 -42
  57. package/build/helpers/changes.d.ts.map +1 -1
  58. package/build/helpers/changes.js +234 -251
  59. package/build/helpers/changes.js.map +1 -1
  60. package/build/helpers/code/types.d.ts +27 -0
  61. package/build/helpers/code/types.d.ts.map +1 -0
  62. package/build/helpers/code/types.js +2 -0
  63. package/build/helpers/code/types.js.map +1 -0
  64. package/build/helpers/code.d.ts +6 -17
  65. package/build/helpers/code.d.ts.map +1 -1
  66. package/build/helpers/code.js +39 -40
  67. package/build/helpers/code.js.map +1 -1
  68. package/build/helpers/index.d.ts +12 -0
  69. package/build/helpers/index.d.ts.map +1 -1
  70. package/build/helpers/index.js +2 -0
  71. package/build/helpers/index.js.map +1 -1
  72. package/build/helpers/query/types.d.ts +23 -0
  73. package/build/helpers/query/types.d.ts.map +1 -0
  74. package/build/helpers/query/types.js +2 -0
  75. package/build/helpers/query/types.js.map +1 -0
  76. package/build/helpers/query.d.ts +25 -17
  77. package/build/helpers/query.d.ts.map +1 -1
  78. package/build/helpers/query.js +108 -280
  79. package/build/helpers/query.js.map +1 -1
  80. package/build/helpers/scoped/types.d.ts +59 -0
  81. package/build/helpers/scoped/types.d.ts.map +1 -0
  82. package/build/helpers/scoped/types.js +2 -0
  83. package/build/helpers/scoped/types.js.map +1 -0
  84. package/build/helpers/scoped.d.ts +24 -0
  85. package/build/helpers/scoped.d.ts.map +1 -0
  86. package/build/helpers/scoped.js +197 -0
  87. package/build/helpers/scoped.js.map +1 -0
  88. package/build/helpers/specification/types.d.ts +24 -0
  89. package/build/helpers/specification/types.d.ts.map +1 -0
  90. package/build/helpers/specification/types.js +2 -0
  91. package/build/helpers/specification/types.js.map +1 -0
  92. package/build/helpers/specification.d.ts +9 -13
  93. package/build/helpers/specification.d.ts.map +1 -1
  94. package/build/helpers/specification.js +47 -44
  95. package/build/helpers/specification.js.map +1 -1
  96. package/build/helpers/status/types.d.ts +48 -0
  97. package/build/helpers/status/types.d.ts.map +1 -0
  98. package/build/helpers/status/types.js +2 -0
  99. package/build/helpers/status/types.js.map +1 -0
  100. package/build/helpers/status.d.ts +16 -29
  101. package/build/helpers/status.d.ts.map +1 -1
  102. package/build/helpers/status.js +77 -73
  103. package/build/helpers/status.js.map +1 -1
  104. package/build/helpers/types.local.d.ts +17 -0
  105. package/build/helpers/types.local.d.ts.map +1 -0
  106. package/build/helpers/types.local.js +2 -0
  107. package/build/helpers/types.local.js.map +1 -0
  108. package/build/helpers/validate/types.d.ts +30 -0
  109. package/build/helpers/validate/types.d.ts.map +1 -0
  110. package/build/helpers/validate/types.js +2 -0
  111. package/build/helpers/validate/types.js.map +1 -0
  112. package/build/helpers/validate.d.ts +8 -19
  113. package/build/helpers/validate.d.ts.map +1 -1
  114. package/build/helpers/validate.js +74 -79
  115. package/build/helpers/validate.js.map +1 -1
  116. package/build/helpers/wire/types.d.ts +28 -0
  117. package/build/helpers/wire/types.d.ts.map +1 -0
  118. package/build/helpers/wire/types.js +2 -0
  119. package/build/helpers/wire/types.js.map +1 -0
  120. package/build/helpers/wire.d.ts +4 -0
  121. package/build/helpers/wire.d.ts.map +1 -0
  122. package/build/helpers/wire.js +215 -0
  123. package/build/helpers/wire.js.map +1 -0
  124. package/build/i18n/be.json +5 -0
  125. package/build/i18n/de.json +5 -0
  126. package/build/i18n/en.json +5 -0
  127. package/build/i18n/es.json +5 -0
  128. package/build/i18n/fr.json +56 -0
  129. package/build/i18n/pl.json +5 -0
  130. package/build/i18n/ru.json +5 -0
  131. package/build/i18n/uk.json +5 -0
  132. package/build/i18n.js +5 -4
  133. package/build/i18n.js.map +1 -1
  134. package/build/index.d.ts +4 -0
  135. package/build/index.d.ts.map +1 -1
  136. package/build/index.js +2 -0
  137. package/build/index.js.map +1 -1
  138. package/build/models/index.d.ts +2 -3
  139. package/build/models/index.d.ts.map +1 -1
  140. package/build/models/index.js +1 -15
  141. package/build/models/index.js.map +1 -1
  142. package/build/models/model.d.ts +5 -0
  143. package/build/models/model.d.ts.map +1 -0
  144. package/build/models/model.js +16 -0
  145. package/build/models/model.js.map +1 -0
  146. package/build/models/project.d.ts +2 -1
  147. package/build/models/project.d.ts.map +1 -1
  148. package/build/models/project.js.map +1 -1
  149. package/build/models/specification.d.ts +2 -1
  150. package/build/models/specification.d.ts.map +1 -1
  151. package/build/models/specification.js.map +1 -1
  152. package/build/models/types.d.ts +69 -0
  153. package/build/models/types.d.ts.map +1 -0
  154. package/build/models/types.js +2 -0
  155. package/build/models/types.js.map +1 -0
  156. package/build/models/workcard.d.ts +2 -1
  157. package/build/models/workcard.d.ts.map +1 -1
  158. package/build/models/workcard.js +12 -12
  159. package/build/models/workcard.js.map +1 -1
  160. package/build/schemas.d.ts +10 -2
  161. package/build/schemas.d.ts.map +1 -1
  162. package/build/schemas.js +87 -1
  163. package/build/schemas.js.map +1 -1
  164. package/build/types.d.ts +199 -148
  165. package/build/types.d.ts.map +1 -1
  166. package/build/utils.d.ts +6 -0
  167. package/build/utils.d.ts.map +1 -0
  168. package/build/utils.js +6 -0
  169. package/build/utils.js.map +1 -0
  170. package/package.json +11 -11
  171. package/src/aliases/types.ts +38 -0
  172. package/src/aliases.ts +31 -0
  173. package/src/consts.ts +26 -25
  174. package/src/entrypoints/types.ts +68 -0
  175. package/src/entrypoints.ts +34 -14
  176. package/src/errors.ts +71 -0
  177. package/src/helpers/apply/consts.local.ts +10 -0
  178. package/src/helpers/apply/types.ts +32 -0
  179. package/src/helpers/apply.ts +135 -152
  180. package/src/helpers/card/types.ts +20 -0
  181. package/src/helpers/card.ts +59 -33
  182. package/src/helpers/changes/consts.local.ts +17 -0
  183. package/src/helpers/changes/types.ts +66 -0
  184. package/src/helpers/changes.ts +267 -280
  185. package/src/helpers/code/types.ts +31 -0
  186. package/src/helpers/code.ts +52 -48
  187. package/src/helpers/index.ts +13 -0
  188. package/src/helpers/query/types.ts +26 -0
  189. package/src/helpers/query.ts +144 -314
  190. package/src/helpers/scoped/types.ts +64 -0
  191. package/src/helpers/scoped.ts +257 -0
  192. package/src/helpers/specification/types.ts +26 -0
  193. package/src/helpers/specification.ts +69 -51
  194. package/src/helpers/status/types.ts +46 -0
  195. package/src/helpers/status.ts +117 -93
  196. package/src/helpers/types.local.ts +18 -0
  197. package/src/helpers/validate/types.ts +30 -0
  198. package/src/helpers/validate.ts +84 -77
  199. package/src/helpers/wire/types.ts +31 -0
  200. package/src/helpers/wire.ts +251 -0
  201. package/src/i18n/be.json +5 -0
  202. package/src/i18n/de.json +5 -0
  203. package/src/i18n/en.json +5 -0
  204. package/src/i18n/es.json +5 -0
  205. package/src/i18n/fr.json +56 -0
  206. package/src/i18n/pl.json +5 -0
  207. package/src/i18n/ru.json +5 -0
  208. package/src/i18n/uk.json +5 -0
  209. package/src/i18n.ts +6 -4
  210. package/src/index.ts +4 -0
  211. package/src/models/index.ts +2 -17
  212. package/src/models/model.ts +18 -0
  213. package/src/models/project.ts +2 -1
  214. package/src/models/specification.ts +2 -1
  215. package/src/models/types.ts +70 -0
  216. package/src/models/workcard.ts +14 -16
  217. package/src/schemas.ts +98 -2
  218. package/src/types.ts +207 -126
  219. package/src/utils.ts +9 -0
  220. package/tests/apply.spec.ts +95 -31
  221. package/tests/code.spec.ts +9 -9
  222. package/tests/entrypoints.spec.ts +18 -2
  223. package/tests/error-status.spec.ts +6 -1
  224. package/tests/models.spec.ts +16 -15
  225. package/tests/query.spec.ts +13 -15
  226. package/tests/schemas.spec.ts +8 -8
  227. package/tests/scoped.spec.ts +154 -0
  228. package/tests/status.spec.ts +31 -22
@@ -0,0 +1,197 @@
1
+ import { memoHelper } from '@owlmeans/context';
2
+ import { PlanningSchemaKind, SchemaOrigin, WorkcardKind } from '../consts.js';
3
+ import { PlanningUnsupported, SchemaInvalid, SchemaSealed } from '../errors.js';
4
+ import { makeSchemaRegistry } from '../registry.js';
5
+ import { StatusFlowSchemaSchema, WorkcardTypeSchemaSchema } from '../schemas.js';
6
+ import { makeAjv, validateHelper } from './validate.js';
7
+ const messageOf = (error) => error instanceof Error ? error.message : `${error}`;
8
+ export const createScopedSchemaHelper = () => {
9
+ const checkers = memoHelper.once(() => {
10
+ const ajv = makeAjv();
11
+ return { flow: ajv.compile(StatusFlowSchemaSchema), type: ajv.compile(WorkcardTypeSchemaSchema) };
12
+ });
13
+ const schemaRecordKey = (record) => `${record.entityId}\u0000${record.project ?? ''}\u0000${record.kind}\u0000${record.key}`;
14
+ const schemaKeyOf = (kind, definition) => kind === PlanningSchemaKind.Type ? definition.type : definition.id;
15
+ const openType = (type) => type.kind === WorkcardKind.Card && type.overridable === true;
16
+ const assertOverridable = (code, kind, key) => {
17
+ if (kind === PlanningSchemaKind.Type) {
18
+ if (code.has(key) && !openType(code.type(key))) {
19
+ throw new SchemaSealed(`type:${key}`);
20
+ }
21
+ return;
22
+ }
23
+ const flow = code.flows().find(entry => entry.id === key);
24
+ if (flow != null && flow.overridable !== true) {
25
+ throw new SchemaSealed(`flow:${key}`);
26
+ }
27
+ };
28
+ const assertFlowSchema = (flow) => {
29
+ const validate = checkers().flow;
30
+ if (!validate(flow)) {
31
+ throw new SchemaInvalid(`flow:${flow?.id ?? ''}:${validateHelper.ajvErrorText(validate.errors)}`);
32
+ }
33
+ const keys = new Set();
34
+ for (const status of flow.statuses) {
35
+ if (keys.has(status.key)) {
36
+ throw new SchemaInvalid(`flow:${flow.id}:status-repeated:${status.key}`);
37
+ }
38
+ keys.add(status.key);
39
+ }
40
+ for (const rule of flow.transitions) {
41
+ if (!keys.has(rule.to)) {
42
+ throw new SchemaInvalid(`flow:${flow.id}:${rule.name}:to:${rule.to}`);
43
+ }
44
+ if (typeof rule.from === 'string') {
45
+ if (rule.from !== '*') {
46
+ throw new SchemaInvalid(`flow:${flow.id}:${rule.name}:from:${rule.from}`);
47
+ }
48
+ continue;
49
+ }
50
+ const unknown = rule.from.find(status => !keys.has(status));
51
+ if (unknown != null) {
52
+ throw new SchemaInvalid(`flow:${flow.id}:${rule.name}:from:${unknown}`);
53
+ }
54
+ }
55
+ };
56
+ const assertTypeSchema = (type, flows) => {
57
+ const validate = checkers().type;
58
+ if (!validate(type)) {
59
+ throw new SchemaInvalid(`type:${type?.type ?? ''}:${validateHelper.ajvErrorText(validate.errors)}`);
60
+ }
61
+ if (type.kind !== WorkcardKind.Card) {
62
+ throw new SchemaInvalid(`type:${type.type}:kind:${type.kind}`);
63
+ }
64
+ try {
65
+ makeAjv().compile(type.fields);
66
+ }
67
+ catch (error) {
68
+ throw new SchemaInvalid(`type:${type.type}:fields:${messageOf(error)}`);
69
+ }
70
+ const seen = new Set();
71
+ for (const id of type.flows) {
72
+ if (seen.has(id)) {
73
+ throw new SchemaInvalid(`type:${type.type}:flow-repeated:${id}`);
74
+ }
75
+ seen.add(id);
76
+ try {
77
+ flows.flow(id);
78
+ }
79
+ catch {
80
+ throw new SchemaInvalid(`type:${type.type}:flow:${id}`);
81
+ }
82
+ }
83
+ };
84
+ const resolveKind = (kind, code, keyOf, open, valid, layers) => {
85
+ const coded = new Map(code.map(definition => [keyOf(definition), definition]));
86
+ const byKey = (records) => new Map(records
87
+ .filter(record => record.kind === kind)
88
+ .map(record => [record.key, record])
89
+ .filter(([key, record]) => {
90
+ const definition = record.definition;
91
+ return valid(definition) && keyOf(definition) === key;
92
+ }));
93
+ const entity = byKey(layers.entity);
94
+ const project = byKey(layers.project);
95
+ const added = [...new Set([...entity.keys(), ...project.keys()])].filter(key => !coded.has(key)).sort();
96
+ const stamped = (record) => ({ ...record.definition, version: record.version });
97
+ const result = { definitions: [], origins: {}, retired: [] };
98
+ for (const key of [...coded.keys(), ...added]) {
99
+ const declared = coded.get(key);
100
+ const candidates = [];
101
+ if (declared == null || open(declared)) {
102
+ const own = project.get(key);
103
+ if (own != null) {
104
+ candidates.push({ origin: SchemaOrigin.Project, definition: stamped(own), retired: own.retired === true });
105
+ }
106
+ const shared = entity.get(key);
107
+ if (shared != null) {
108
+ candidates.push({ origin: SchemaOrigin.Entity, definition: stamped(shared), retired: shared.retired === true });
109
+ }
110
+ }
111
+ if (declared != null) {
112
+ candidates.push({ origin: SchemaOrigin.Code, definition: declared, retired: false });
113
+ }
114
+ // A retired record gives way to a live declaration below it; only when every layer holding the
115
+ // key retired it does the key resolve retired — still there for the cards that use it.
116
+ const chosen = candidates.find(candidate => !candidate.retired) ?? candidates[0];
117
+ if (chosen == null) {
118
+ continue;
119
+ }
120
+ result.definitions.push(chosen.definition);
121
+ result.origins[key] = chosen.origin;
122
+ if (chosen.retired) {
123
+ result.retired.push(key);
124
+ }
125
+ }
126
+ return result;
127
+ };
128
+ const resolveScopedBundle = (code, records, scope) => {
129
+ const mine = records.filter(record => record.entityId === scope.entityId);
130
+ const layers = {
131
+ entity: mine.filter(record => record.project == null),
132
+ project: scope.project == null ? [] : mine.filter(record => record.project === scope.project),
133
+ };
134
+ const types = resolveKind(PlanningSchemaKind.Type, code.types, type => type.type, openType, type => type != null && typeof type.type === 'string' && type.kind === WorkcardKind.Card, layers);
135
+ const flows = resolveKind(PlanningSchemaKind.Flow, code.flows, flow => flow.id, flow => flow.overridable === true, flow => flow != null && typeof flow.id === 'string', layers);
136
+ return structuredClone({
137
+ version: code.version,
138
+ types: types.definitions,
139
+ flows: flows.definitions,
140
+ scope: scope.project == null ? { entityId: scope.entityId } : { entityId: scope.entityId, project: scope.project },
141
+ revision: scope.revision ?? 0,
142
+ origins: { types: types.origins, flows: flows.origins },
143
+ retired: { types: types.retired, flows: flows.retired },
144
+ });
145
+ };
146
+ const scopedRegistryOf = (bundle) => {
147
+ const base = makeSchemaRegistry(bundle);
148
+ const kept = structuredClone(bundle);
149
+ const refuse = () => {
150
+ throw new PlanningUnsupported('schemas:read-only');
151
+ };
152
+ const originsOf = (kind) => kind === PlanningSchemaKind.Type ? kept.origins?.types : kept.origins?.flows;
153
+ const retiredOf = (kind) => kind === PlanningSchemaKind.Type ? kept.retired?.types : kept.retired?.flows;
154
+ return {
155
+ ...base,
156
+ registerType: refuse,
157
+ registerFlow: refuse,
158
+ load: refuse,
159
+ scope: kept.scope ?? { entityId: '' },
160
+ revision: kept.revision ?? 0,
161
+ originOf: (kind, key) => originsOf(kind)?.[key]
162
+ ?? ((kind === PlanningSchemaKind.Type ? base.has(key) : base.flows().some(flow => flow.id === key))
163
+ ? SchemaOrigin.Code
164
+ : undefined),
165
+ isRetired: (kind, key) => retiredOf(kind)?.includes(key) === true,
166
+ bundle: () => structuredClone(kept),
167
+ };
168
+ };
169
+ const flowInUse = (bundle, flow) => {
170
+ if (bundle.retired?.flows.includes(flow) !== true) {
171
+ return undefined;
172
+ }
173
+ return bundle.types.find(type => bundle.retired?.types.includes(type.type) !== true && type.flows.includes(flow))?.type;
174
+ };
175
+ return {
176
+ schemaRecordKey, schemaKeyOf, assertOverridable, assertFlowSchema, assertTypeSchema, resolveScopedBundle,
177
+ scopedRegistryOf, flowInUse,
178
+ };
179
+ };
180
+ export const scopedSchemaHelper = createScopedSchemaHelper();
181
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.schemaRecordKey(…)` */
182
+ export const schemaRecordKey = (record) => scopedSchemaHelper.schemaRecordKey(record);
183
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.schemaKeyOf(…)` */
184
+ export const schemaKeyOf = (kind, definition) => scopedSchemaHelper.schemaKeyOf(kind, definition);
185
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.assertOverridable(…)` */
186
+ export const assertOverridable = (code, kind, key) => scopedSchemaHelper.assertOverridable(code, kind, key);
187
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.assertFlowSchema(…)` */
188
+ export const assertFlowSchema = (flow) => scopedSchemaHelper.assertFlowSchema(flow);
189
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.assertTypeSchema(…)` */
190
+ export const assertTypeSchema = (type, flows) => scopedSchemaHelper.assertTypeSchema(type, flows);
191
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.resolveScopedBundle(…)` */
192
+ export const resolveScopedBundle = (code, records, scope) => scopedSchemaHelper.resolveScopedBundle(code, records, scope);
193
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.scopedRegistryOf(…)` */
194
+ export const scopedRegistryOf = (bundle) => scopedSchemaHelper.scopedRegistryOf(bundle);
195
+ /** @deprecated compat:factory-refactor — use `scopedSchemaHelper.flowInUse(…)` */
196
+ export const flowInUse = (bundle, flow) => scopedSchemaHelper.flowInUse(bundle, flow);
197
+ //# sourceMappingURL=scoped.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoped.js","sourceRoot":"","sources":["../../src/helpers/scoped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAOhF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEvD,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,KAA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yFAAyF;AACzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAA0B,EAAwB,EAAE,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;AAEjI,kFAAkF;AAClF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAA0B,EAAE,IAAY,EAAsB,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import type { AnyTypeSchema, PlanningSchemaRegistry, Specification, SpecificationSlot, Workcard } from '../../types.js';
2
+ /** The slot and revision rules of the documents a parent card carries. */
3
+ export interface SpecificationHelper {
4
+ /** The slot a parent type declares for a category. */
5
+ slotOf: (type: AnyTypeSchema, category: string) => SpecificationSlot | undefined;
6
+ isRevisioned: (slot?: SpecificationSlot | null) => boolean;
7
+ bodyCharsOf: (body?: string | null) => number | undefined;
8
+ /** The revision a write lands as: 1 for a new document, current + 1 after, none when unrevisioned. */
9
+ nextRevision: (current: Pick<Specification, 'revision'> | null | undefined, slot?: SpecificationSlot | null) => number | undefined;
10
+ /**
11
+ * The current document of a category among a parent's specifications: the highest revision, then
12
+ * the most recently updated. `null` when the category has none.
13
+ */
14
+ currentSpecification: (specs: Workcard[], category: string) => Specification | null;
15
+ /**
16
+ * The specification type a new document of a slot is created with: the slot's own `type`, else
17
+ * the only registered specification type, else the one sharing the parent type's prefix
18
+ * (`viable:project` → `viable:spec`).
19
+ *
20
+ * @throws {UnknownWorkcardType} when none or several candidates remain
21
+ */
22
+ specificationTypeOf: (registry: Pick<PlanningSchemaRegistry, 'types'>, parentType: string, slot?: SpecificationSlot | null) => string;
23
+ }
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/helpers/specification/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEvH,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,MAAM,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAA;IAChF,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,iBAAiB,GAAG,IAAI,KAAK,OAAO,CAAA;IAC1D,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,GAAG,SAAS,CAAA;IACzD,sGAAsG;IACtG,YAAY,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,IAAI,KAAK,MAAM,GAAG,SAAS,CAAA;IAClI;;;OAGG;IACH,oBAAoB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,KAAK,aAAa,GAAG,IAAI,CAAA;IACnF;;;;;;OAMG;IACH,mBAAmB,EAAE,CACnB,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,IAAI,KACjG,MAAM,CAAA;CACZ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/helpers/specification/types.ts"],"names":[],"mappings":""}
@@ -1,21 +1,17 @@
1
1
  import type { AnyTypeSchema, PlanningSchemaRegistry, Specification, SpecificationSlot, Workcard } from '../types.js';
2
- /** The slot a parent type declares for a category. */
2
+ import type { SpecificationHelper } from './specification/types.js';
3
+ export declare const createSpecificationHelper: () => SpecificationHelper;
4
+ export declare const specificationHelper: SpecificationHelper;
5
+ /** @deprecated compat:factory-refactor — use `specificationHelper.slotOf(…)` */
3
6
  export declare const slotOf: (type: AnyTypeSchema, category: string) => SpecificationSlot | undefined;
7
+ /** @deprecated compat:factory-refactor — use `specificationHelper.isRevisioned(…)` */
4
8
  export declare const isRevisioned: (slot?: SpecificationSlot | null) => boolean;
9
+ /** @deprecated compat:factory-refactor — use `specificationHelper.bodyCharsOf(…)` */
5
10
  export declare const bodyCharsOf: (body?: string | null) => number | undefined;
6
- /** The revision a write lands as: 1 for a new document, current + 1 after, none when unrevisioned. */
11
+ /** @deprecated compat:factory-refactor — use `specificationHelper.nextRevision(…)` */
7
12
  export declare const nextRevision: (current: Pick<Specification, 'revision'> | null | undefined, slot?: SpecificationSlot | null) => number | undefined;
8
- /**
9
- * The current document of a category among a parent's specifications: the highest revision, then
10
- * the most recently updated. `null` when the category has none.
11
- */
13
+ /** @deprecated compat:factory-refactor — use `specificationHelper.currentSpecification(…)` */
12
14
  export declare const currentSpecification: (specs: Workcard[], category: string) => Specification | null;
13
- /**
14
- * The specification type a new document of a slot is created with: the slot's own `type`, else
15
- * the only registered specification type, else the one sharing the parent type's prefix
16
- * (`viable:project` → `viable:spec`).
17
- *
18
- * @throws {UnknownWorkcardType} when none or several candidates remain
19
- */
15
+ /** @deprecated compat:factory-refactor — use `specificationHelper.specificationTypeOf(…)` */
20
16
  export declare const specificationTypeOf: (registry: Pick<PlanningSchemaRegistry, 'types'>, parentType: string, slot?: SpecificationSlot | null) => string;
21
17
  //# sourceMappingURL=specification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"specification.d.ts","sourceRoot":"","sources":["../../src/helpers/specification.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAClF,MAAM,aAAa,CAAA;AAEpB,sDAAsD;AACtD,eAAO,MAAM,MAAM,SAAU,aAAa,YAAY,MAAM,KAAG,iBAAiB,GAAG,SACrB,CAA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a,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,SAAS,iBAAiB,GAAG,IAAI,KAC3F,MAAM,GAAG,SAA4D,CAAA;AAExE,8FAA8F;AAC9F,eAAO,MAAM,oBAAoB,UAAW,QAAQ,EAAE,YAAY,MAAM,KAAG,aAAa,GAAG,IAChC,CAAA;AAE3D,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,aACpB,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,cAAc,MAAM,SAAS,iBAAiB,GAAG,IAAI,KACnG,MAA6E,CAAA"}
@@ -1,48 +1,51 @@
1
1
  import { WorkcardKind } from '../consts.js';
2
2
  import { UnknownWorkcardType } from '../errors.js';
3
- /** The slot a parent type declares for a category. */
4
- export const slotOf = (type, category) => type.specifications.find(slot => slot.category === category);
5
- export const isRevisioned = (slot) => slot?.revisioned === true;
6
- export const bodyCharsOf = (body) => body == null ? undefined : body.length;
7
- /** The revision a write lands as: 1 for a new document, current + 1 after, none when unrevisioned. */
8
- export const nextRevision = (current, slot) => isRevisioned(slot) ? (current?.revision ?? 0) + 1 : undefined;
9
- /**
10
- * The current document of a category among a parent's specifications: the highest revision, then
11
- * the most recently updated. `null` when the category has none.
12
- */
13
- export const currentSpecification = (specs, category) => specs
14
- .filter((spec) => spec.kind === WorkcardKind.Specification
15
- && spec.category === category)
16
- .reduce((best, spec) => {
17
- if (best == null) {
18
- return spec;
19
- }
20
- const byRevision = (spec.revision ?? 0) - (best.revision ?? 0);
21
- if (byRevision !== 0) {
22
- return byRevision > 0 ? spec : best;
23
- }
24
- return (spec.updatedAt ?? spec.createdAt) > (best.updatedAt ?? best.createdAt) ? spec : best;
25
- }, null);
26
- const prefixOf = (type) => type.includes(':') ? type.slice(0, type.lastIndexOf(':')) : '';
27
- /**
28
- * The specification type a new document of a slot is created with: the slot's own `type`, else
29
- * the only registered specification type, else the one sharing the parent type's prefix
30
- * (`viable:project` → `viable:spec`).
31
- *
32
- * @throws {UnknownWorkcardType} when none or several candidates remain
33
- */
34
- export const specificationTypeOf = (registry, parentType, slot) => {
35
- if (slot?.type != null) {
36
- return slot.type;
37
- }
38
- const candidates = registry.types().filter(type => type.kind === WorkcardKind.Specification);
39
- if (candidates.length === 1) {
40
- return candidates[0].type;
41
- }
42
- const prefixed = candidates.filter(type => prefixOf(type.type) === prefixOf(parentType));
43
- if (prefixed.length === 1) {
44
- return prefixed[0].type;
45
- }
46
- throw new UnknownWorkcardType(`specification:${parentType}:${slot?.category ?? ''}`);
3
+ export const createSpecificationHelper = () => {
4
+ const slotOf = (type, category) => type.specifications.find(slot => slot.category === category);
5
+ const isRevisioned = (slot) => slot?.revisioned === true;
6
+ const bodyCharsOf = (body) => body == null ? undefined : body.length;
7
+ const nextRevision = (current, slot) => isRevisioned(slot) ? (current?.revision ?? 0) + 1 : undefined;
8
+ const currentSpecification = (specs, category) => specs
9
+ .filter((spec) => spec.kind === WorkcardKind.Specification
10
+ && spec.category === category)
11
+ .reduce((best, spec) => {
12
+ if (best == null) {
13
+ return spec;
14
+ }
15
+ const byRevision = (spec.revision ?? 0) - (best.revision ?? 0);
16
+ if (byRevision !== 0) {
17
+ return byRevision > 0 ? spec : best;
18
+ }
19
+ return (spec.updatedAt ?? spec.createdAt) > (best.updatedAt ?? best.createdAt) ? spec : best;
20
+ }, null);
21
+ const prefixOf = (type) => type.includes(':') ? type.slice(0, type.lastIndexOf(':')) : '';
22
+ const specificationTypeOf = (registry, parentType, slot) => {
23
+ if (slot?.type != null) {
24
+ return slot.type;
25
+ }
26
+ const candidates = registry.types().filter(type => type.kind === WorkcardKind.Specification);
27
+ if (candidates.length === 1) {
28
+ return candidates[0].type;
29
+ }
30
+ const prefixed = candidates.filter(type => prefixOf(type.type) === prefixOf(parentType));
31
+ if (prefixed.length === 1) {
32
+ return prefixed[0].type;
33
+ }
34
+ throw new UnknownWorkcardType(`specification:${parentType}:${slot?.category ?? ''}`);
35
+ };
36
+ return { slotOf, isRevisioned, bodyCharsOf, nextRevision, currentSpecification, specificationTypeOf };
47
37
  };
38
+ export const specificationHelper = createSpecificationHelper();
39
+ /** @deprecated compat:factory-refactor — use `specificationHelper.slotOf(…)` */
40
+ export const slotOf = (type, category) => specificationHelper.slotOf(type, category);
41
+ /** @deprecated compat:factory-refactor — use `specificationHelper.isRevisioned(…)` */
42
+ export const isRevisioned = (slot) => specificationHelper.isRevisioned(slot);
43
+ /** @deprecated compat:factory-refactor — use `specificationHelper.bodyCharsOf(…)` */
44
+ export const bodyCharsOf = (body) => specificationHelper.bodyCharsOf(body);
45
+ /** @deprecated compat:factory-refactor — use `specificationHelper.nextRevision(…)` */
46
+ export const nextRevision = (current, slot) => specificationHelper.nextRevision(current, slot);
47
+ /** @deprecated compat:factory-refactor — use `specificationHelper.currentSpecification(…)` */
48
+ export const currentSpecification = (specs, category) => specificationHelper.currentSpecification(specs, category);
49
+ /** @deprecated compat:factory-refactor — use `specificationHelper.specificationTypeOf(…)` */
50
+ export const specificationTypeOf = (registry, parentType, slot) => specificationHelper.specificationTypeOf(registry, parentType, slot);
48
51
  //# sourceMappingURL=specification.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"specification.js","sourceRoot":"","sources":["../../src/helpers/specification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAKlD,sDAAsD;AACtD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAmB,EAAE,QAAgB,EAAiC,EAAE,CAC7F,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAA;AAE9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAA+B,EAAW,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;AAEnG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAoB,EAAsB,EAAE,CAA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FlowSchema, StatusTransitionRule } from '../../types.js';
3
+ import type { FlowLookup } from '../types.local.js';
4
+ /** The status-flow rules: statuses, the transitions a flow offers, and the intrinsic state. */
5
+ export interface StatusHelper {
6
+ /** The primary flow id of a type — `flows[0]`. @throws {UnknownStatusFlow} when it declares none */
7
+ primaryFlowOf: (type: AnyTypeSchema) => string;
8
+ flowIdsOf: (type: AnyTypeSchema) => string[];
9
+ statusDefinitionOf: (flow: StatusFlowSchema, status: string) => StatusDefinition | undefined;
10
+ /** The intrinsic state a status maps onto, or `undefined` for a status the flow does not declare. */
11
+ intrinsicOf: (flow: StatusFlowSchema, status: string) => IntrinsicStatus | undefined;
12
+ /** The status marked `initial`, else the first one. @throws {PlanningError} for a flow with none */
13
+ initialStatusOf: (flow: StatusFlowSchema) => string;
14
+ isTerminal: (flow: StatusFlowSchema, status: string) => boolean;
15
+ /**
16
+ * The rule a named transition follows from a status.
17
+ *
18
+ * A name may be declared several times with different `from` sets; the rule naming the status
19
+ * explicitly wins, and a `'*'` rule of that name answers only when none does. A status the flow
20
+ * does NOT declare — a card whose flow changed under it — matches every rule of the name, the first
21
+ * declared answering: such a card can always move back onto the flow it now runs.
22
+ */
23
+ ruleOf: (flow: StatusFlowSchema, transition: string, from: string) => StatusTransitionRule | undefined;
24
+ canTransit: (flow: StatusFlowSchema, transition: string, from: string) => boolean;
25
+ /**
26
+ * Every transition available from a status, one rule per name (the one `ruleOf` would pick), in
27
+ * declaration order. `explicit: true` keeps only the rules offered to a person.
28
+ */
29
+ transitionsFrom: (flow: StatusFlowSchema, status: string, opts?: {
30
+ explicit?: boolean;
31
+ }) => StatusTransitionRule[];
32
+ /**
33
+ * A new card's status per flow: every flow's initial status, with the primary one overridden by
34
+ * `status` when the draft names one.
35
+ *
36
+ * @throws {UnknownStatusFlow}
37
+ */
38
+ initialFlowsOf: (type: AnyTypeSchema, registry: FlowLookup, status?: string) => Record<string, string>;
39
+ /**
40
+ * The card's intrinsic state over its flows. {@link IntrinsicPolicy.Primary} reads the primary
41
+ * flow; {@link IntrinsicPolicy.All} takes the least advanced flow. A status the flow does not
42
+ * declare reads as planned.
43
+ *
44
+ * @throws {UnknownStatusFlow}
45
+ */
46
+ resolveIntrinsic: (type: AnyTypeSchema, flows: Record<string, string>, registry: FlowLookup) => IntrinsicStatus;
47
+ }
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/helpers/status/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,+FAA+F;AAC/F,MAAM,WAAW,YAAY;IAC3B,oGAAoG;IACpG,aAAa,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,MAAM,CAAA;IAC9C,SAAS,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,MAAM,EAAE,CAAA;IAC5C,kBAAkB,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS,CAAA;IAC5F,qGAAqG;IACrG,WAAW,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAA;IACpF,oGAAoG;IACpG,eAAe,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,MAAM,CAAA;IACnD,UAAU,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAA;IAC/D;;;;;;;OAOG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,oBAAoB,GAAG,SAAS,CAAA;IACtG,UAAU,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;IACjF;;;OAGG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,oBAAoB,EAAE,CAAA;IAClH;;;;;OAKG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtG;;;;;;OAMG;IACH,gBAAgB,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,KAAK,eAAe,CAAA;CAChH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/helpers/status/types.ts"],"names":[],"mappings":""}
@@ -1,44 +1,31 @@
1
1
  import { IntrinsicStatus } from '../consts.js';
2
- import type { AnyTypeSchema, PlanningSchemaRegistry, StatusDefinition, StatusFlowSchema, StatusTransitionRule } from '../types.js';
3
- type FlowLookup = Pick<PlanningSchemaRegistry, 'flow'>;
4
- /** The primary flow id of a type — `flows[0]`. @throws {UnknownStatusFlow} when it declares none */
2
+ import type { AnyTypeSchema, StatusDefinition, StatusFlowSchema, StatusTransitionRule } from '../types.js';
3
+ import type { StatusHelper } from './status/types.js';
4
+ import type { FlowLookup } from './types.local.js';
5
+ export declare const createStatusHelper: () => StatusHelper;
6
+ export declare const statusHelper: StatusHelper;
7
+ /** @deprecated compat:factory-refactor — use `statusHelper.primaryFlowOf(…)` */
5
8
  export declare const primaryFlowOf: (type: AnyTypeSchema) => string;
9
+ /** @deprecated compat:factory-refactor — use `statusHelper.flowIdsOf(…)` */
6
10
  export declare const flowIdsOf: (type: AnyTypeSchema) => string[];
11
+ /** @deprecated compat:factory-refactor — use `statusHelper.statusDefinitionOf(…)` */
7
12
  export declare const statusDefinitionOf: (flow: StatusFlowSchema, status: string) => StatusDefinition | undefined;
8
- /** The intrinsic state a status maps onto, or `undefined` for a status the flow does not declare. */
13
+ /** @deprecated compat:factory-refactor — use `statusHelper.intrinsicOf(…)` */
9
14
  export declare const intrinsicOf: (flow: StatusFlowSchema, status: string) => IntrinsicStatus | undefined;
10
- /** The status marked `initial`, else the first one. @throws {PlanningError} for a flow with none */
15
+ /** @deprecated compat:factory-refactor — use `statusHelper.initialStatusOf(…)` */
11
16
  export declare const initialStatusOf: (flow: StatusFlowSchema) => string;
17
+ /** @deprecated compat:factory-refactor — use `statusHelper.isTerminal(…)` */
12
18
  export declare const isTerminal: (flow: StatusFlowSchema, status: string) => boolean;
13
- /**
14
- * The rule a named transition follows from a status.
15
- *
16
- * A name may be declared several times with different `from` sets; the rule naming the status
17
- * explicitly wins, and a `'*'` rule of that name answers only when none does.
18
- */
19
+ /** @deprecated compat:factory-refactor — use `statusHelper.ruleOf(…)` */
19
20
  export declare const ruleOf: (flow: StatusFlowSchema, transition: string, from: string) => StatusTransitionRule | undefined;
21
+ /** @deprecated compat:factory-refactor — use `statusHelper.canTransit(…)` */
20
22
  export declare const canTransit: (flow: StatusFlowSchema, transition: string, from: string) => boolean;
21
- /**
22
- * Every transition available from a status, one rule per name (the one `ruleOf` would pick), in
23
- * declaration order. `explicit: true` keeps only the rules offered to a person.
24
- */
23
+ /** @deprecated compat:factory-refactor — use `statusHelper.transitionsFrom(…)` */
25
24
  export declare const transitionsFrom: (flow: StatusFlowSchema, status: string, opts?: {
26
25
  explicit?: boolean;
27
26
  }) => StatusTransitionRule[];
28
- /**
29
- * A new card's status per flow: every flow's initial status, with the primary one overridden by
30
- * `status` when the draft names one.
31
- *
32
- * @throws {UnknownStatusFlow}
33
- */
27
+ /** @deprecated compat:factory-refactor — use `statusHelper.initialFlowsOf(…)` */
34
28
  export declare const initialFlowsOf: (type: AnyTypeSchema, registry: FlowLookup, status?: string) => Record<string, string>;
35
- /**
36
- * The card's intrinsic state over its flows. {@link IntrinsicPolicy.Primary} reads the primary
37
- * flow; {@link IntrinsicPolicy.All} takes the least advanced flow. A status the flow does not
38
- * declare reads as planned.
39
- *
40
- * @throws {UnknownStatusFlow}
41
- */
29
+ /** @deprecated compat:factory-refactor — use `statusHelper.resolveIntrinsic(…)` */
42
30
  export declare const resolveIntrinsic: (type: AnyTypeSchema, flows: Record<string, string>, registry: FlowLookup) => IntrinsicStatus;
43
- export {};
44
31
  //# sourceMappingURL=status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/helpers/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,eAAe,EAAE,MAAM,cAAc,CAAA;AAE5F,OAAO,KAAK,EACV,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAChG,MAAM,aAAa,CAAA;AAEpB,KAAK,UAAU,GAAG,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;AAEtD,oGAAoG;AACpG,eAAO,MAAM,aAAa,SAAU,aAAa,KAAG,MAOnD,CAAA;AAED,eAAO,MAAM,SAAS,SAAU,aAAa,KAAG,MAAM,EAAqB,CAAA;AAE3E,eAAO,MAAM,kBAAkB,SAAU,gBAAgB,UAAU,MAAM,KAAG,gBAAgB,GAAG,SAClC,CAAA;AAE7D,qGAAqG;AACrG,eAAO,MAAM,WAAW,SAAU,gBAAgB,UAAU,MAAM,KAAG,eAAe,GAAG,SAC1C,CAAA;AAE7C,oGAAoG;AACpG,eAAO,MAAM,eAAe,SAAU,gBAAgB,KAAG,MAOxD,CAAA;AAED,eAAO,MAAM,UAAU,SA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