@owlmeans/planning 0.1.18-rc.8 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -29
- package/agent-meta/manifest.json +131 -4
- package/agent-meta/skills/planning/SKILL.md +78 -171
- package/agent-meta/skills/planning/parts/collaboration.md +67 -0
- package/agent-meta/skills/planning/parts/errors.md +51 -0
- package/agent-meta/skills/planning/parts/fold.md +69 -0
- package/agent-meta/skills/planning/parts/mounting.md +64 -0
- package/agent-meta/skills/planning/parts/types.md +141 -0
- package/build/aliases/types.d.ts +72 -0
- package/build/aliases/types.d.ts.map +1 -0
- package/build/aliases/types.js +2 -0
- package/build/aliases/types.js.map +1 -0
- package/build/aliases.d.ts +4 -0
- package/build/aliases.d.ts.map +1 -0
- package/build/aliases.js +28 -0
- package/build/aliases.js.map +1 -0
- package/build/consts.d.ts +43 -34
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +49 -25
- package/build/consts.js.map +1 -1
- package/build/entrypoints/types.d.ts +105 -0
- package/build/entrypoints/types.d.ts.map +1 -0
- package/build/entrypoints/types.js +2 -0
- package/build/entrypoints/types.js.map +1 -0
- package/build/entrypoints.d.ts +5 -1
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +24 -6
- package/build/entrypoints.js.map +1 -1
- package/build/errors.d.ts +41 -0
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js +61 -0
- package/build/errors.js.map +1 -1
- package/build/helpers/app/consts.local.d.ts +5 -0
- package/build/helpers/app/consts.local.d.ts.map +1 -0
- package/build/helpers/app/consts.local.js +5 -0
- package/build/helpers/app/consts.local.js.map +1 -0
- package/build/helpers/app/types.d.ts +53 -0
- package/build/helpers/app/types.d.ts.map +1 -0
- package/build/helpers/app/types.js +2 -0
- package/build/helpers/app/types.js.map +1 -0
- package/build/helpers/app.d.ts +4 -0
- package/build/helpers/app.d.ts.map +1 -0
- package/build/helpers/app.js +139 -0
- package/build/helpers/app.js.map +1 -0
- package/build/helpers/apply/consts.local.d.ts +7 -0
- package/build/helpers/apply/consts.local.d.ts.map +1 -0
- package/build/helpers/apply/consts.local.js +9 -0
- package/build/helpers/apply/consts.local.js.map +1 -0
- package/build/helpers/apply/types.d.ts +32 -0
- package/build/helpers/apply/types.d.ts.map +1 -0
- package/build/helpers/apply/types.js +2 -0
- package/build/helpers/apply/types.js.map +1 -0
- package/build/helpers/apply.d.ts +5 -23
- package/build/helpers/apply.d.ts.map +1 -1
- package/build/helpers/apply.js +127 -144
- package/build/helpers/apply.js.map +1 -1
- package/build/helpers/card/types.d.ts +20 -0
- package/build/helpers/card/types.d.ts.map +1 -0
- package/build/helpers/card/types.js +2 -0
- package/build/helpers/card/types.js.map +1 -0
- package/build/helpers/card.d.ts +11 -7
- package/build/helpers/card.d.ts.map +1 -1
- package/build/helpers/card.js +41 -28
- package/build/helpers/card.js.map +1 -1
- package/build/helpers/changes/consts.local.d.ts +13 -0
- package/build/helpers/changes/consts.local.d.ts.map +1 -0
- package/build/helpers/changes/consts.local.js +13 -0
- package/build/helpers/changes/consts.local.js.map +1 -0
- package/build/helpers/changes/types.d.ts +58 -0
- package/build/helpers/changes/types.d.ts.map +1 -0
- package/build/helpers/changes/types.js +2 -0
- package/build/helpers/changes/types.js.map +1 -0
- package/build/helpers/changes.d.ts +11 -42
- package/build/helpers/changes.d.ts.map +1 -1
- package/build/helpers/changes.js +237 -251
- package/build/helpers/changes.js.map +1 -1
- package/build/helpers/code/types.d.ts +27 -0
- package/build/helpers/code/types.d.ts.map +1 -0
- package/build/helpers/code/types.js +2 -0
- package/build/helpers/code/types.js.map +1 -0
- package/build/helpers/code.d.ts +6 -17
- package/build/helpers/code.d.ts.map +1 -1
- package/build/helpers/code.js +39 -40
- package/build/helpers/code.js.map +1 -1
- package/build/helpers/index.d.ts +16 -0
- package/build/helpers/index.d.ts.map +1 -1
- package/build/helpers/index.js +4 -0
- package/build/helpers/index.js.map +1 -1
- package/build/helpers/query/types.d.ts +23 -0
- package/build/helpers/query/types.d.ts.map +1 -0
- package/build/helpers/query/types.js +2 -0
- package/build/helpers/query/types.js.map +1 -0
- package/build/helpers/query.d.ts +25 -17
- package/build/helpers/query.d.ts.map +1 -1
- package/build/helpers/query.js +108 -280
- package/build/helpers/query.js.map +1 -1
- package/build/helpers/reply/consts.d.ts +2 -0
- package/build/helpers/reply/consts.d.ts.map +1 -0
- package/build/helpers/reply/consts.js +2 -0
- package/build/helpers/reply/consts.js.map +1 -0
- package/build/helpers/reply/types.d.ts +10 -0
- package/build/helpers/reply/types.d.ts.map +1 -0
- package/build/helpers/reply/types.js +2 -0
- package/build/helpers/reply/types.js.map +1 -0
- package/build/helpers/reply.d.ts +5 -0
- package/build/helpers/reply.d.ts.map +1 -0
- package/build/helpers/reply.js +29 -0
- package/build/helpers/reply.js.map +1 -0
- package/build/helpers/scoped/types.d.ts +73 -0
- package/build/helpers/scoped/types.d.ts.map +1 -0
- package/build/helpers/scoped/types.js +2 -0
- package/build/helpers/scoped/types.js.map +1 -0
- package/build/helpers/scoped.d.ts +25 -0
- package/build/helpers/scoped.d.ts.map +1 -0
- package/build/helpers/scoped.js +223 -0
- package/build/helpers/scoped.js.map +1 -0
- package/build/helpers/specification/types.d.ts +24 -0
- package/build/helpers/specification/types.d.ts.map +1 -0
- package/build/helpers/specification/types.js +2 -0
- package/build/helpers/specification/types.js.map +1 -0
- package/build/helpers/specification.d.ts +9 -13
- package/build/helpers/specification.d.ts.map +1 -1
- package/build/helpers/specification.js +47 -44
- package/build/helpers/specification.js.map +1 -1
- package/build/helpers/status/types.d.ts +48 -0
- package/build/helpers/status/types.d.ts.map +1 -0
- package/build/helpers/status/types.js +2 -0
- package/build/helpers/status/types.js.map +1 -0
- package/build/helpers/status.d.ts +16 -29
- package/build/helpers/status.d.ts.map +1 -1
- package/build/helpers/status.js +77 -73
- package/build/helpers/status.js.map +1 -1
- package/build/helpers/types.local.d.ts +17 -0
- package/build/helpers/types.local.d.ts.map +1 -0
- package/build/helpers/types.local.js +2 -0
- package/build/helpers/types.local.js.map +1 -0
- package/build/helpers/validate/types.d.ts +31 -0
- package/build/helpers/validate/types.d.ts.map +1 -0
- package/build/helpers/validate/types.js +2 -0
- package/build/helpers/validate/types.js.map +1 -0
- package/build/helpers/validate.d.ts +8 -19
- package/build/helpers/validate.d.ts.map +1 -1
- package/build/helpers/validate.js +79 -79
- package/build/helpers/validate.js.map +1 -1
- package/build/helpers/wire/types.d.ts +28 -0
- package/build/helpers/wire/types.d.ts.map +1 -0
- package/build/helpers/wire/types.js +2 -0
- package/build/helpers/wire/types.js.map +1 -0
- package/build/helpers/wire.d.ts +4 -0
- package/build/helpers/wire.d.ts.map +1 -0
- package/build/helpers/wire.js +216 -0
- package/build/helpers/wire.js.map +1 -0
- package/build/i18n/be.json +5 -0
- package/build/i18n/de.json +5 -0
- package/build/i18n/en.json +5 -0
- package/build/i18n/es.json +5 -0
- package/build/i18n/fr.json +5 -0
- package/build/i18n/pl.json +5 -0
- package/build/i18n/ru.json +5 -0
- package/build/i18n/uk.json +5 -0
- package/build/i18n.js +3 -3
- package/build/i18n.js.map +1 -1
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/models/index.d.ts +2 -3
- package/build/models/index.d.ts.map +1 -1
- package/build/models/index.js +1 -15
- package/build/models/index.js.map +1 -1
- package/build/models/model.d.ts +5 -0
- package/build/models/model.d.ts.map +1 -0
- package/build/models/model.js +16 -0
- package/build/models/model.js.map +1 -0
- package/build/models/project.d.ts +2 -1
- package/build/models/project.d.ts.map +1 -1
- package/build/models/project.js.map +1 -1
- package/build/models/specification.d.ts +2 -1
- package/build/models/specification.d.ts.map +1 -1
- package/build/models/specification.js.map +1 -1
- package/build/models/types.d.ts +69 -0
- package/build/models/types.d.ts.map +1 -0
- package/build/models/types.js +2 -0
- package/build/models/types.js.map +1 -0
- package/build/models/workcard.d.ts +2 -1
- package/build/models/workcard.d.ts.map +1 -1
- package/build/models/workcard.js +12 -12
- package/build/models/workcard.js.map +1 -1
- package/build/registry.d.ts +3 -2
- package/build/registry.d.ts.map +1 -1
- package/build/registry.js +51 -3
- package/build/registry.js.map +1 -1
- package/build/resources/mentions.d.ts +4 -0
- package/build/resources/mentions.d.ts.map +1 -0
- package/build/resources/mentions.js +15 -0
- package/build/resources/mentions.js.map +1 -0
- package/build/resources/protocol/types.d.ts +30 -0
- package/build/resources/protocol/types.d.ts.map +1 -0
- package/build/resources/protocol/types.js +2 -0
- package/build/resources/protocol/types.js.map +1 -0
- package/build/resources/protocol.d.ts +6 -0
- package/build/resources/protocol.d.ts.map +1 -0
- package/build/resources/protocol.js +31 -0
- package/build/resources/protocol.js.map +1 -0
- package/build/resources/types.d.ts +146 -0
- package/build/resources/types.d.ts.map +1 -0
- package/build/resources/types.js +2 -0
- package/build/resources/types.js.map +1 -0
- package/build/resources/types.local.d.ts +6 -0
- package/build/resources/types.local.d.ts.map +1 -0
- package/build/resources/types.local.js +2 -0
- package/build/resources/types.local.js.map +1 -0
- package/build/schemas.d.ts +21 -2
- package/build/schemas.d.ts.map +1 -1
- package/build/schemas.js +164 -2
- package/build/schemas.js.map +1 -1
- package/build/types.d.ts +330 -151
- package/build/types.d.ts.map +1 -1
- package/build/utils.d.ts +6 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +6 -0
- package/build/utils.js.map +1 -0
- package/package.json +13 -13
- package/src/aliases/types.ts +41 -0
- package/src/aliases.ts +34 -0
- package/src/consts.ts +50 -25
- package/src/entrypoints/types.ts +77 -0
- package/src/entrypoints.ts +53 -24
- package/src/errors.ts +71 -0
- package/src/helpers/app/consts.local.ts +5 -0
- package/src/helpers/app/types.ts +54 -0
- package/src/helpers/app.ts +158 -0
- package/src/helpers/apply/consts.local.ts +10 -0
- package/src/helpers/apply/types.ts +32 -0
- package/src/helpers/apply.ts +141 -153
- package/src/helpers/card/types.ts +20 -0
- package/src/helpers/card.ts +59 -33
- package/src/helpers/changes/consts.local.ts +17 -0
- package/src/helpers/changes/types.ts +66 -0
- package/src/helpers/changes.ts +270 -280
- package/src/helpers/code/types.ts +31 -0
- package/src/helpers/code.ts +52 -48
- package/src/helpers/index.ts +17 -0
- package/src/helpers/query/types.ts +26 -0
- package/src/helpers/query.ts +144 -314
- package/src/helpers/reply/consts.ts +1 -0
- package/src/helpers/reply/types.ts +13 -0
- package/src/helpers/reply.ts +27 -0
- package/src/helpers/scoped/types.ts +78 -0
- package/src/helpers/scoped.ts +281 -0
- package/src/helpers/specification/types.ts +26 -0
- package/src/helpers/specification.ts +69 -51
- package/src/helpers/status/types.ts +46 -0
- package/src/helpers/status.ts +117 -93
- package/src/helpers/types.local.ts +18 -0
- package/src/helpers/validate/types.ts +31 -0
- package/src/helpers/validate.ts +89 -77
- package/src/helpers/wire/types.ts +31 -0
- package/src/helpers/wire.ts +252 -0
- package/src/i18n/be.json +5 -0
- package/src/i18n/de.json +5 -0
- package/src/i18n/en.json +5 -0
- package/src/i18n/es.json +5 -0
- package/src/i18n/fr.json +5 -0
- package/src/i18n/pl.json +5 -0
- package/src/i18n/ru.json +5 -0
- package/src/i18n/uk.json +5 -0
- package/src/i18n.ts +4 -3
- package/src/index.ts +8 -0
- package/src/models/index.ts +2 -17
- package/src/models/model.ts +18 -0
- package/src/models/project.ts +2 -1
- package/src/models/specification.ts +2 -1
- package/src/models/types.ts +70 -0
- package/src/models/workcard.ts +14 -16
- package/src/registry.ts +55 -4
- package/src/resources/mentions.ts +11 -0
- package/src/resources/protocol/types.ts +21 -0
- package/src/resources/protocol.ts +36 -0
- package/src/resources/types.local.ts +5 -0
- package/src/resources/types.ts +148 -0
- package/src/schemas.ts +179 -4
- package/src/types.ts +334 -130
- package/src/utils.ts +9 -0
- package/tests/app.spec.ts +188 -0
- package/tests/apply.spec.ts +95 -31
- package/tests/code.spec.ts +9 -9
- package/tests/csp.spec.ts +122 -0
- package/tests/entrypoints.spec.ts +18 -2
- package/tests/error-status.spec.ts +6 -1
- package/tests/models.spec.ts +24 -16
- package/tests/query.spec.ts +13 -15
- package/tests/schemas.spec.ts +8 -8
- package/tests/scoped.spec.ts +161 -0
- package/tests/status.spec.ts +31 -22
package/src/types.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type { AssigneeSchemaRegistry, AssigneeTypeSchema, PlanningResourceFacade, PlanningRecordStore, Assignee, Team, Comment, CommentMention } from './resources/types.js'
|
|
2
|
+
import type { PlanningResourceKind, ProjectMode } from './consts.js'
|
|
1
3
|
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
2
|
-
import type { EntrypointProtocol, OpenRequest, OpenValue } from '@owlmeans/entrypoint'
|
|
3
4
|
import type { Criteria, ListOptions, ListResult, ResourceRecord } from '@owlmeans/resource'
|
|
4
|
-
import type { RouteParent } from '@owlmeans/route'
|
|
5
5
|
import type { AnySchema, ValidateFunction } from 'ajv'
|
|
6
6
|
import type {
|
|
7
|
-
CodeScope, CodeStyle, CommitState, IntrinsicPolicy, IntrinsicStatus,
|
|
8
|
-
TransitionAction, WorkcardKind,
|
|
7
|
+
CodeScope, CodeStyle, CommitState, IntrinsicPolicy, IntrinsicStatus, PlanningSchemaKind, SchemaOrigin,
|
|
8
|
+
SchemaWriteMode, SpecificationFormat, TransitionAction, WorkcardKind,
|
|
9
9
|
} from './consts.js'
|
|
10
|
+
import type { WorkcardModel } from './models/types.js'
|
|
10
11
|
|
|
11
12
|
// ─── Records ─────────────────────────────────────────────────────────────────────────────────────
|
|
12
13
|
|
|
@@ -27,6 +28,12 @@ export interface Workcard extends ResourceRecord {
|
|
|
27
28
|
description?: string
|
|
28
29
|
/** Primary parent id. Absent on a root project. */
|
|
29
30
|
parent?: string
|
|
31
|
+
/** Derived from the actual primary parent; never an independent reference. */
|
|
32
|
+
parentType?: string
|
|
33
|
+
reporter?: string
|
|
34
|
+
assignee?: string
|
|
35
|
+
/** Project visibility metadata, interpreted only by a host policy hook. */
|
|
36
|
+
mode?: ProjectMode
|
|
30
37
|
/** EVERY parent — many-to-many membership with no junction row. Always contains `parent`. */
|
|
31
38
|
parents: string[]
|
|
32
39
|
/** Status key of the PRIMARY flow. Mirror of `flows[primaryFlow]`. */
|
|
@@ -83,6 +90,8 @@ export interface Relationship extends ResourceRecord {
|
|
|
83
90
|
type: string
|
|
84
91
|
from: string
|
|
85
92
|
to: string
|
|
93
|
+
fromKind?: PlanningResourceKind
|
|
94
|
+
toKind?: PlanningResourceKind
|
|
86
95
|
project?: string
|
|
87
96
|
fields?: Record<string, unknown>
|
|
88
97
|
createdAt: string
|
|
@@ -95,6 +104,8 @@ export interface RelationshipDraft {
|
|
|
95
104
|
/** Defaults to the card the transition is about. */
|
|
96
105
|
from?: string
|
|
97
106
|
to: string
|
|
107
|
+
fromKind?: PlanningResourceKind
|
|
108
|
+
toKind?: PlanningResourceKind
|
|
98
109
|
fields?: Record<string, unknown>
|
|
99
110
|
}
|
|
100
111
|
|
|
@@ -121,9 +132,7 @@ export interface TransitionCommit {
|
|
|
121
132
|
* Every key carries a NEW VALUE, never a delta. `fields` and `flows` merge shallowly into the
|
|
122
133
|
* card's; every other key replaces. Clearing is `Transition.unset`.
|
|
123
134
|
*/
|
|
124
|
-
export
|
|
125
|
-
& Partial<Omit<Workcard, 'id' | 'kind' | 'type' | 'entityId' | 'seq' | 'head' | 'createdAt'>>
|
|
126
|
-
& Partial<Pick<Specification, 'category' | 'format' | 'body' | 'ref' | 'revision' | 'version' | 'bodyChars'>>
|
|
135
|
+
export interface WorkcardChanges extends Partial<Omit<Workcard, 'id' | 'kind' | 'type' | 'entityId' | 'seq' | 'head' | 'createdAt'>>, Partial<Pick<Specification, 'category' | 'format' | 'body' | 'ref' | 'revision' | 'version' | 'bodyChars'>> {}
|
|
127
136
|
|
|
128
137
|
/** The event. Append-only, never edited; folding every transition of a card in `seq` order IS the card. */
|
|
129
138
|
export interface Transition extends ResourceRecord {
|
|
@@ -186,6 +195,50 @@ export interface StatusFlowSchema {
|
|
|
186
195
|
statuses: StatusDefinition[]
|
|
187
196
|
transitions: StatusTransitionRule[]
|
|
188
197
|
label?: string
|
|
198
|
+
/** A presentation hint: the colour family an application marks this flow with. Free text. */
|
|
199
|
+
tone?: string
|
|
200
|
+
/** A presentation hint: the icon name an application marks this flow with. Free text. */
|
|
201
|
+
icon?: string
|
|
202
|
+
/**
|
|
203
|
+
* A code-registered flow is sealed against a data-defined override unless it says so. Meaningless
|
|
204
|
+
* on a data-defined flow: a project may override any organization-wide record.
|
|
205
|
+
*/
|
|
206
|
+
overridable?: boolean
|
|
207
|
+
/**
|
|
208
|
+
* The application's own properties of this flow (`description`, …), closed over what the
|
|
209
|
+
* application declares in `PlanningAppDeclarations.flow`. Refused on a data-defined flow when the
|
|
210
|
+
* application declares none.
|
|
211
|
+
*/
|
|
212
|
+
app?: Record<string, unknown>
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* One kind of property set an application declares in code: an object schema whose `properties`
|
|
217
|
+
* (and `required`) several plugins merge by name. No other keyword is admitted — a merge could not
|
|
218
|
+
* honour it.
|
|
219
|
+
*/
|
|
220
|
+
export interface PlanningAppSchema {
|
|
221
|
+
type?: 'object'
|
|
222
|
+
/** The JSON schema of each property, by name — no `.` or `$` in a name. */
|
|
223
|
+
properties: Record<string, AnySchema>
|
|
224
|
+
/** Names every record of the kind carries; each one declared in `properties`. */
|
|
225
|
+
required?: string[]
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* What an application pregenerates beside its people's own custom fields — declared in code
|
|
230
|
+
* (`PlanningPlugin.schemas.app`, `PlanningServiceOptions.schemas.app`), served in the bundle.
|
|
231
|
+
*/
|
|
232
|
+
export interface PlanningAppDeclarations {
|
|
233
|
+
/** The `app` bag of every type declaration — checked on a data-defined card type's write. */
|
|
234
|
+
type?: PlanningAppSchema
|
|
235
|
+
/** The `app` bag of every flow declaration — checked on a data-defined flow's write. */
|
|
236
|
+
flow?: PlanningAppSchema
|
|
237
|
+
/**
|
|
238
|
+
* Base `fields` of every card of kind `card` — code or data-defined type — validated beside the
|
|
239
|
+
* type's own `fields` schema. Projects and specifications are not affected.
|
|
240
|
+
*/
|
|
241
|
+
card?: PlanningAppSchema
|
|
189
242
|
}
|
|
190
243
|
|
|
191
244
|
export interface SpecificationSlot {
|
|
@@ -221,6 +274,11 @@ export interface RelationshipType {
|
|
|
221
274
|
from?: string[]
|
|
222
275
|
/** Card types allowed at the `to` end. Any when omitted. */
|
|
223
276
|
to?: string[]
|
|
277
|
+
fromKind?: PlanningResourceKind
|
|
278
|
+
toKind?: PlanningResourceKind
|
|
279
|
+
/** A fields property whose references derive this relationship index. */
|
|
280
|
+
field?: string
|
|
281
|
+
multiple?: boolean
|
|
224
282
|
inverse?: string
|
|
225
283
|
/** At most one relationship of this type leaves a card. */
|
|
226
284
|
single?: boolean
|
|
@@ -239,16 +297,39 @@ export interface WorkcardTypeSchema {
|
|
|
239
297
|
/** Slots the type's cards carry as children. */
|
|
240
298
|
specifications: SpecificationSlot[]
|
|
241
299
|
relationships?: RelationshipType[]
|
|
300
|
+
/** Primary/direct hierarchy declarations. Missing means the legacy project-only rule. */
|
|
301
|
+
parents?: { types?: string[], required?: boolean }
|
|
302
|
+
children?: { types: string[] }
|
|
242
303
|
/** Allowed labels. Any when omitted. */
|
|
243
304
|
labels?: string[]
|
|
244
305
|
code?: CodePolicy
|
|
245
306
|
label?: string
|
|
307
|
+
/** A presentation hint: the colour family an application marks this type's cards with. Free text. */
|
|
308
|
+
tone?: string
|
|
309
|
+
/** A presentation hint: the icon name an application marks this type's cards with. Free text. */
|
|
310
|
+
icon?: string
|
|
311
|
+
/**
|
|
312
|
+
* A code-registered card type is sealed against a data-defined override unless it says so.
|
|
313
|
+
* Meaningless on a data-defined type: a project may override any organization-wide record.
|
|
314
|
+
*/
|
|
315
|
+
overridable?: boolean
|
|
316
|
+
/**
|
|
317
|
+
* The application's own properties of this type (`description`, …), closed over what the
|
|
318
|
+
* application declares in `PlanningAppDeclarations.type`. Refused on a data-defined type when the
|
|
319
|
+
* application declares none.
|
|
320
|
+
*/
|
|
321
|
+
app?: Record<string, unknown>
|
|
246
322
|
}
|
|
247
323
|
|
|
248
324
|
export interface ProjectTypeSchema extends Omit<WorkcardTypeSchema, 'kind'> {
|
|
249
325
|
kind: WorkcardKind.Project
|
|
250
326
|
cardTypes: string[]
|
|
251
327
|
projectTypes?: string[]
|
|
328
|
+
/**
|
|
329
|
+
* The project admits cards of data-defined types (organization-wide or its own) beside the
|
|
330
|
+
* `cardTypes` it lists.
|
|
331
|
+
*/
|
|
332
|
+
scopedCardTypes?: boolean
|
|
252
333
|
}
|
|
253
334
|
|
|
254
335
|
export type AnyTypeSchema = WorkcardTypeSchema | ProjectTypeSchema
|
|
@@ -257,11 +338,23 @@ export interface PlanningSchemaBundle {
|
|
|
257
338
|
version: number
|
|
258
339
|
types: AnyTypeSchema[]
|
|
259
340
|
flows: StatusFlowSchema[]
|
|
341
|
+
assigneeTypes?: AssigneeTypeSchema[]
|
|
342
|
+
/** The application's declarations, merged — absent when it declares none. */
|
|
343
|
+
app?: PlanningAppDeclarations
|
|
260
344
|
}
|
|
261
345
|
|
|
262
|
-
export interface PlanningSchemaRegistry {
|
|
346
|
+
export interface PlanningSchemaRegistry extends AssigneeSchemaRegistry {
|
|
263
347
|
registerType: (schema: AnyTypeSchema) => void
|
|
264
348
|
registerFlow: (flow: StatusFlowSchema) => void
|
|
349
|
+
/**
|
|
350
|
+
* Replace the application's declarations (already merged; `undefined` clears them) — drops every
|
|
351
|
+
* cached validator.
|
|
352
|
+
*
|
|
353
|
+
* @throws {SchemaInvalid} a malformed declaration
|
|
354
|
+
*/
|
|
355
|
+
registerApp: (app?: PlanningAppDeclarations) => void
|
|
356
|
+
/** The application's declarations in force, `undefined` when there are none. Do not mutate. */
|
|
357
|
+
app: () => PlanningAppDeclarations | undefined
|
|
265
358
|
types: () => AnyTypeSchema[]
|
|
266
359
|
/** @throws {UnknownWorkcardType} */
|
|
267
360
|
type: (type: string) => AnyTypeSchema
|
|
@@ -271,19 +364,184 @@ export interface PlanningSchemaRegistry {
|
|
|
271
364
|
flow: (id: string) => StatusFlowSchema
|
|
272
365
|
/** @throws {UnknownWorkcardType | UnknownStatusFlow} */
|
|
273
366
|
primaryFlow: (type: string) => StatusFlowSchema
|
|
274
|
-
/**
|
|
367
|
+
/**
|
|
368
|
+
* The schema a type's `fields` validate against: its own `fields`, plus the application's base
|
|
369
|
+
* card fields for a type of kind `card` (`appSchemaHelper.fieldsSchemaOf`). What a browser form
|
|
370
|
+
* hands `makePlanningFieldValidator`.
|
|
371
|
+
*
|
|
372
|
+
* @throws {UnknownWorkcardType}
|
|
373
|
+
*/
|
|
374
|
+
fieldsSchema: (type: string) => AnySchema
|
|
375
|
+
/** The compiled, cached validator of a type's {@link fieldsSchema}. */
|
|
275
376
|
validator: (type: string) => ValidateFunction
|
|
276
377
|
bundle: () => PlanningSchemaBundle
|
|
277
378
|
/** Replace everything with a bundle — a client's boot. */
|
|
278
379
|
load: (bundle: PlanningSchemaBundle) => void
|
|
279
380
|
}
|
|
280
381
|
|
|
382
|
+
// ─── Data-defined (scoped) schemas ───────────────────────────────────────────────────────────────
|
|
383
|
+
|
|
384
|
+
/** The layer a record belongs to: an organization, and optionally one of its project cards. */
|
|
385
|
+
export interface SchemaScope {
|
|
386
|
+
entityId: string
|
|
387
|
+
/** A project card id; the organization-wide layer when omitted. */
|
|
388
|
+
project?: string
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* A card type or a status flow defined as data — organization-wide, or scoped to one project.
|
|
393
|
+
*
|
|
394
|
+
* `version` is the record's compare-and-set token and is also written into the declaration's own
|
|
395
|
+
* `version`: a write lands only at its layer's next version (1 for a new key).
|
|
396
|
+
*/
|
|
397
|
+
export interface ScopedSchemaRecord extends ResourceRecord {
|
|
398
|
+
id?: string
|
|
399
|
+
entityId: string
|
|
400
|
+
/** A project card id; absent on an organization-wide record. */
|
|
401
|
+
project?: string
|
|
402
|
+
kind: PlanningSchemaKind
|
|
403
|
+
/** The type key or the flow id. */
|
|
404
|
+
key: string
|
|
405
|
+
version: number
|
|
406
|
+
/** A `WorkcardTypeSchema` of kind `card`, or a `StatusFlowSchema`. */
|
|
407
|
+
definition: WorkcardTypeSchema | StatusFlowSchema | AssigneeTypeSchema
|
|
408
|
+
/**
|
|
409
|
+
* Retired: offered for nothing new, still resolved for what already uses it. A retired record
|
|
410
|
+
* gives way to a live declaration of the same key in a lower layer.
|
|
411
|
+
*/
|
|
412
|
+
retired?: boolean
|
|
413
|
+
/** The organization's schema revision this write landed at — assigned by the store. */
|
|
414
|
+
rev?: number
|
|
415
|
+
createdAt: string
|
|
416
|
+
updatedAt?: string
|
|
417
|
+
by?: TransitionActor
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export interface ScopedSchemaWhere {
|
|
421
|
+
entityId: string
|
|
422
|
+
/** A project id — that project's layer; `null` — the organization-wide layer; omitted — every layer. */
|
|
423
|
+
project?: string | null
|
|
424
|
+
kind?: PlanningSchemaKind
|
|
425
|
+
key?: string | string[]
|
|
426
|
+
retired?: boolean
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* The optional port a store implements to hold data-defined types and flows. A store without it
|
|
431
|
+
* resolves every type and flow from the code registry alone.
|
|
432
|
+
*/
|
|
433
|
+
export interface SchemaStore {
|
|
434
|
+
list: (where: ScopedSchemaWhere) => Promise<ScopedSchemaRecord[]>
|
|
435
|
+
/**
|
|
436
|
+
* Write one record — compare-and-set on `version`: the stored record of the same layer and key
|
|
437
|
+
* must be at `record.version - 1` (absent for version 1). Bumps the organization's revision.
|
|
438
|
+
*
|
|
439
|
+
* @throws {SchemaConflict}
|
|
440
|
+
*/
|
|
441
|
+
put: (record: ScopedSchemaRecord) => Promise<ScopedSchemaRecord>
|
|
442
|
+
/** Remove a project's whole layer (its project was purged). Bumps the revision. */
|
|
443
|
+
purge: (where: { entityId: string, project: string }) => Promise<number>
|
|
444
|
+
/** The organization's monotonic schema revision — 0 before its first write. */
|
|
445
|
+
revision: (entityId: string) => Promise<number>
|
|
446
|
+
/** Hear of every write of an organization's records, from this process and — where the store can — others. */
|
|
447
|
+
watch?: (listener: (entityId: string) => void) => Unsubscribe
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export interface SchemaKey {
|
|
451
|
+
kind: PlanningSchemaKind
|
|
452
|
+
key: string
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/** What a scoped bundle adds, per kind: where each key resolved from, and which keys are retired. */
|
|
456
|
+
export interface ScopedSchemaOrigins {
|
|
457
|
+
types: Record<string, SchemaOrigin>
|
|
458
|
+
flows: Record<string, SchemaOrigin>
|
|
459
|
+
assigneeTypes?: Record<string, SchemaOrigin>
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface ScopedSchemaRetired {
|
|
463
|
+
types: string[]
|
|
464
|
+
flows: string[]
|
|
465
|
+
assigneeTypes?: string[]
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* A bundle resolved for one layer: the code registry, overlaid by the organization's records, then
|
|
470
|
+
* by the project's. Retired declarations stay in `types`/`flows` (existing cards still resolve them)
|
|
471
|
+
* and are listed in `retired`. Readers of the plain bundle ignore the extra keys.
|
|
472
|
+
*/
|
|
473
|
+
export interface ScopedSchemaBundle extends PlanningSchemaBundle {
|
|
474
|
+
scope?: SchemaScope
|
|
475
|
+
/** The organization's schema revision the bundle was resolved at. */
|
|
476
|
+
revision?: number
|
|
477
|
+
origins?: ScopedSchemaOrigins
|
|
478
|
+
retired?: ScopedSchemaRetired
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** A read-only registry over one resolved layer. Its `register*` and `load` refuse. */
|
|
482
|
+
export interface ScopedSchemaRegistry extends PlanningSchemaRegistry {
|
|
483
|
+
scope: SchemaScope
|
|
484
|
+
revision: number
|
|
485
|
+
/** `undefined` for a key the layer does not resolve. */
|
|
486
|
+
originOf: (kind: PlanningSchemaKind, key: string) => SchemaOrigin | undefined
|
|
487
|
+
isRetired: (kind: PlanningSchemaKind, key: string) => boolean
|
|
488
|
+
bundle: () => ScopedSchemaBundle
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/** Declarations written together — flows first, so a type may name a flow defined beside it. */
|
|
492
|
+
export interface SchemaDeclarations {
|
|
493
|
+
types?: WorkcardTypeSchema[]
|
|
494
|
+
flows?: StatusFlowSchema[]
|
|
495
|
+
assigneeTypes?: AssigneeTypeSchema[]
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export interface SchemaWriteOptions {
|
|
499
|
+
/** A project card id — that project's layer; the organization-wide layer when omitted. */
|
|
500
|
+
project?: string
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Data-defined types and flows — present on a facade whose store implements
|
|
505
|
+
* {@link PlanningStore.schemas}. Only card types and flows are data-defined; projects and
|
|
506
|
+
* specifications always resolve in code.
|
|
507
|
+
*/
|
|
508
|
+
export interface PlanningDefinitions {
|
|
509
|
+
/** The layer resolved: the organization-wide one, or a project's (which includes it). */
|
|
510
|
+
bundle: (project?: string) => Promise<ScopedSchemaBundle>
|
|
511
|
+
registry: (project?: string) => Promise<ScopedSchemaRegistry>
|
|
512
|
+
/** The records of one layer (`project: null` the organization's; omitted — every layer). */
|
|
513
|
+
records: (opts?: { project?: string | null, kind?: PlanningSchemaKind, retired?: boolean }) => Promise<ScopedSchemaRecord[]>
|
|
514
|
+
/**
|
|
515
|
+
* Compare-and-set: `type.version` must be the layer's next version (1 for a new key).
|
|
516
|
+
*
|
|
517
|
+
* @throws {SchemaConflict | SchemaSealed | SchemaInvalid | WorkcardNotFound}
|
|
518
|
+
*/
|
|
519
|
+
putType: (type: WorkcardTypeSchema, opts?: SchemaWriteOptions) => Promise<ScopedSchemaRecord>
|
|
520
|
+
/** Compare-and-set, as {@link putType}. */
|
|
521
|
+
putAssigneeType: (schema: AssigneeTypeSchema) => Promise<ScopedSchemaRecord>
|
|
522
|
+
putFlow: (flow: StatusFlowSchema, opts?: SchemaWriteOptions) => Promise<ScopedSchemaRecord>
|
|
523
|
+
/** Every declaration at its layer's next version — flows first, then types. */
|
|
524
|
+
define: (declarations: SchemaDeclarations, opts?: SchemaWriteOptions) => Promise<ScopedSchemaRecord[]>
|
|
525
|
+
/** Only the keys the layer lacks, at version 1 — idempotent. */
|
|
526
|
+
seed: (declarations: SchemaDeclarations, opts?: SchemaWriteOptions) => Promise<ScopedSchemaRecord[]>
|
|
527
|
+
/**
|
|
528
|
+
* Retire a key at a layer. Existing cards keep resolving it; nothing new is created with it.
|
|
529
|
+
*
|
|
530
|
+
* @throws {SchemaInUse} a flow still resolved by a live type of an affected layer
|
|
531
|
+
* @throws {UnknownWorkcardType | UnknownStatusFlow} the layer holds no record of the key
|
|
532
|
+
*/
|
|
533
|
+
retire: (kind: PlanningSchemaKind, key: string, opts?: SchemaWriteOptions) => Promise<ScopedSchemaRecord>
|
|
534
|
+
}
|
|
535
|
+
|
|
281
536
|
// ─── Execution and receipts ──────────────────────────────────────────────────────────────────────
|
|
282
537
|
|
|
283
538
|
export interface WorkcardDraft {
|
|
284
539
|
kind: WorkcardKind
|
|
285
540
|
type: string
|
|
286
541
|
parent?: string
|
|
542
|
+
reporter?: string
|
|
543
|
+
assignee?: string
|
|
544
|
+
mode?: ProjectMode
|
|
287
545
|
parents?: string[]
|
|
288
546
|
title: string
|
|
289
547
|
description?: string
|
|
@@ -375,7 +633,7 @@ export interface CommitFilter {
|
|
|
375
633
|
kind?: WorkcardKind
|
|
376
634
|
}
|
|
377
635
|
|
|
378
|
-
export
|
|
636
|
+
export interface Unsubscribe { (): void }
|
|
379
637
|
|
|
380
638
|
export interface CommitSource {
|
|
381
639
|
status: (transition: string) => Promise<CommitStatus>
|
|
@@ -389,7 +647,8 @@ export interface CommitSource {
|
|
|
389
647
|
export interface TransitionWhere {
|
|
390
648
|
entityId: string
|
|
391
649
|
card?: string | string[]
|
|
392
|
-
project
|
|
650
|
+
/** One project, or any of several. */
|
|
651
|
+
project?: string | string[]
|
|
393
652
|
sinceSeq?: number
|
|
394
653
|
state?: CommitState
|
|
395
654
|
action?: TransitionAction | TransitionAction[]
|
|
@@ -422,6 +681,11 @@ export interface ProjectionStore {
|
|
|
422
681
|
count: (where: Criteria<Workcard>) => Promise<number>
|
|
423
682
|
summary: (parents: string[], where?: Criteria<Workcard>) => Promise<SummaryView>
|
|
424
683
|
put: (card: Workcard) => Promise<void>
|
|
684
|
+
/**
|
|
685
|
+
* Remove a record — the fold of its `delete` — with its comments and mentions, and its own
|
|
686
|
+
* documents (the specifications whose primary parent is it, and theirs in turn) with their edges,
|
|
687
|
+
* comments, mentions and log. The record's own log stays: its delete row is the tombstone.
|
|
688
|
+
*/
|
|
425
689
|
drop: (id: string, entityId: string) => Promise<void>
|
|
426
690
|
/** Fold what is pending for the card — now or through a durable server projection. */
|
|
427
691
|
project: (card: string, hint?: { transition?: string }) => Promise<void>
|
|
@@ -456,6 +720,10 @@ export interface RelationshipWhere {
|
|
|
456
720
|
from?: string | string[]
|
|
457
721
|
to?: string | string[]
|
|
458
722
|
type?: string | string[]
|
|
723
|
+
fromKind?: PlanningResourceKind
|
|
724
|
+
toKind?: PlanningResourceKind
|
|
725
|
+
/** The project an edge is filed under. A store that ignores it is narrowed by the facade. */
|
|
726
|
+
project?: string | string[]
|
|
459
727
|
}
|
|
460
728
|
|
|
461
729
|
export interface RelationshipStore {
|
|
@@ -473,6 +741,8 @@ export interface PlanningStoreCapabilities {
|
|
|
473
741
|
|
|
474
742
|
/** Only `cards` is required — which is what keeps a foreign provider possible. */
|
|
475
743
|
export interface PlanningStore {
|
|
744
|
+
validateProjection?: (before: Workcard | null, after: Workcard | null, transition: Transition) => Promise<void>
|
|
745
|
+
projectReferences?: (after: Workcard, transition: Transition) => Promise<void>
|
|
476
746
|
alias?: string
|
|
477
747
|
capabilities?: PlanningStoreCapabilities
|
|
478
748
|
/** The id a new card gets. */
|
|
@@ -482,6 +752,14 @@ export interface PlanningStore {
|
|
|
482
752
|
specs?: SpecificationStore
|
|
483
753
|
links?: RelationshipStore
|
|
484
754
|
commits?: CommitSource
|
|
755
|
+
/** Data-defined card/assignee types and flows. Without it their declarations resolve in code. */
|
|
756
|
+
schemas?: SchemaStore
|
|
757
|
+
assignees?: PlanningRecordStore<Assignee>
|
|
758
|
+
teams?: PlanningRecordStore<Team>
|
|
759
|
+
comments?: PlanningRecordStore<Comment>
|
|
760
|
+
mentions?: PlanningRecordStore<CommentMention>
|
|
761
|
+
/** Serialize dependent writes across processes in this organization. */
|
|
762
|
+
unit?: <R>(entityId: string, run: () => Promise<R>) => Promise<R>
|
|
485
763
|
}
|
|
486
764
|
|
|
487
765
|
// ─── Queries ─────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -515,6 +793,8 @@ export interface SpecificationQuery extends ListOptions<Specification> {
|
|
|
515
793
|
}
|
|
516
794
|
|
|
517
795
|
export interface RelationshipQuery extends ListOptions<Relationship> {
|
|
796
|
+
fromKind?: PlanningResourceKind
|
|
797
|
+
toKind?: PlanningResourceKind
|
|
518
798
|
from?: string | string[]
|
|
519
799
|
to?: string | string[]
|
|
520
800
|
type?: string | string[]
|
|
@@ -572,6 +852,8 @@ export interface SpecificationQueryWire extends ListWire {
|
|
|
572
852
|
}
|
|
573
853
|
|
|
574
854
|
export interface RelationshipQueryWire extends ListWire {
|
|
855
|
+
fromKind?: PlanningResourceKind
|
|
856
|
+
toKind?: PlanningResourceKind
|
|
575
857
|
from?: string
|
|
576
858
|
to?: string
|
|
577
859
|
type?: string
|
|
@@ -613,18 +895,51 @@ export interface RevisionsQuery {
|
|
|
613
895
|
limit?: number
|
|
614
896
|
}
|
|
615
897
|
|
|
898
|
+
export interface SchemaListQuery {
|
|
899
|
+
/** A project card id — that project's layer; the organization-wide one when omitted. */
|
|
900
|
+
project?: string
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/** The one write of data-defined types and flows over the wire. */
|
|
904
|
+
export interface SchemaDefineRequest {
|
|
905
|
+
/** A project card id — that project's layer; the organization-wide one when omitted. */
|
|
906
|
+
project?: string
|
|
907
|
+
/** `define` when omitted. */
|
|
908
|
+
mode?: SchemaWriteMode
|
|
909
|
+
types?: WorkcardTypeSchema[]
|
|
910
|
+
flows?: StatusFlowSchema[]
|
|
911
|
+
assigneeTypes?: AssigneeTypeSchema[]
|
|
912
|
+
/** Keys retired at the layer after the declarations are written. */
|
|
913
|
+
retire?: SchemaKey[]
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/** What a `schema.define` answers: the records it wrote, and the layer as it resolves afterwards. */
|
|
917
|
+
export interface SchemaDefineReply {
|
|
918
|
+
records: ScopedSchemaRecord[]
|
|
919
|
+
bundle: ScopedSchemaBundle
|
|
920
|
+
}
|
|
921
|
+
|
|
616
922
|
// ─── Facade, scope, service, plugin seam ─────────────────────────────────────────────────────────
|
|
617
923
|
|
|
618
924
|
export interface PlanningScope {
|
|
619
925
|
entityId: string
|
|
620
926
|
profileId?: string
|
|
621
927
|
userId?: string
|
|
928
|
+
/** Trusted planning actor, resolved by a host auth plugin. */
|
|
929
|
+
assigneeId?: string
|
|
930
|
+
defaultAssigneeId?: string
|
|
622
931
|
service?: string
|
|
623
932
|
channel?: string
|
|
624
933
|
actor?: TransitionActor
|
|
934
|
+
/**
|
|
935
|
+
* The only project cards this scope may see and write — the projects themselves and every card
|
|
936
|
+
* whose `parents` name one (a card's document through its card). Every project when omitted.
|
|
937
|
+
* Advisory on a client, where the server decides.
|
|
938
|
+
*/
|
|
939
|
+
projects?: string[]
|
|
625
940
|
}
|
|
626
941
|
|
|
627
|
-
export interface PlanningFacade {
|
|
942
|
+
export interface PlanningFacade extends PlanningResourceFacade {
|
|
628
943
|
scope: PlanningScope
|
|
629
944
|
schemas: PlanningSchemaRegistry
|
|
630
945
|
cards: {
|
|
@@ -652,6 +967,8 @@ export interface PlanningFacade {
|
|
|
652
967
|
commits: CommitSource
|
|
653
968
|
execute: (exec: TransitionExecution, opts?: ExecuteOptions) => Promise<TransitionReceipt>
|
|
654
969
|
model: <T extends Workcard = Workcard>(card: T | string) => Promise<WorkcardModel<T>>
|
|
970
|
+
/** Data-defined types and flows — present only where the store holds them. */
|
|
971
|
+
definitions?: PlanningDefinitions
|
|
655
972
|
}
|
|
656
973
|
|
|
657
974
|
export interface WithPlanningService {
|
|
@@ -699,7 +1016,11 @@ export interface PlanningPlugin {
|
|
|
699
1016
|
name: string
|
|
700
1017
|
/** Ascending; `DEFAULT_PLUGIN_ORDER` (50) when omitted. */
|
|
701
1018
|
order?: number
|
|
702
|
-
|
|
1019
|
+
/**
|
|
1020
|
+
* Code declarations. `app` — the application's own definition properties and base card fields —
|
|
1021
|
+
* is merged over every plugin in plugin order (`appSchemaHelper.merge`), not replaced.
|
|
1022
|
+
*/
|
|
1023
|
+
schemas?: { types?: AnyTypeSchema[], flows?: StatusFlowSchema[], assigneeTypes?: AssigneeTypeSchema[], app?: PlanningAppDeclarations }
|
|
703
1024
|
owns?: (type: string) => boolean
|
|
704
1025
|
store?: PlanningStore | ((ctx: BasicContext<BasicConfig>) => PlanningStore)
|
|
705
1026
|
mintCode?: (draft: WorkcardDraft, taken: (code: string) => Promise<boolean>, ctx: PlanningExecContext) => Promise<string | undefined>
|
|
@@ -717,120 +1038,3 @@ export interface PlanningService {
|
|
|
717
1038
|
/** Runs the ordered `after` chain — called by the process that FOLDED the transition. */
|
|
718
1039
|
committed: (event: CommitEvent) => Promise<void>
|
|
719
1040
|
}
|
|
720
|
-
|
|
721
|
-
// ─── Models ──────────────────────────────────────────────────────────────────────────────────────
|
|
722
|
-
|
|
723
|
-
export interface ExecuteMeta {
|
|
724
|
-
actor?: TransitionActor
|
|
725
|
-
cause?: string
|
|
726
|
-
key?: string
|
|
727
|
-
expectSeq?: number | null
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
export type ModelExecuteOptions = ExecuteOptions & ExecuteMeta
|
|
731
|
-
|
|
732
|
-
export interface SpecificationWriteOptions extends ModelExecuteOptions {
|
|
733
|
-
format?: SpecificationFormat
|
|
734
|
-
version?: number
|
|
735
|
-
ref?: string
|
|
736
|
-
/** The title a new document gets; the category when omitted. */
|
|
737
|
-
title?: string
|
|
738
|
-
/** The specification type; resolved from the slot and the registry when omitted. */
|
|
739
|
-
type?: string
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
export interface WorkcardModel<T extends Workcard = Workcard> {
|
|
743
|
-
record: T
|
|
744
|
-
id: string
|
|
745
|
-
kind: WorkcardKind
|
|
746
|
-
type: string
|
|
747
|
-
schema: () => AnyTypeSchema
|
|
748
|
-
flow: (id?: string) => StatusFlowSchema
|
|
749
|
-
statusOf: (flowId?: string) => string
|
|
750
|
-
intrinsicOf: (flowId?: string) => IntrinsicStatus
|
|
751
|
-
can: (transition: string, flowId?: string) => boolean
|
|
752
|
-
available: (flowId?: string) => StatusTransitionRule[]
|
|
753
|
-
pending: () => boolean
|
|
754
|
-
transit: (transition: string, changes?: WorkcardChanges, opts?: ModelExecuteOptions & { flow?: string }) => Promise<TransitionReceipt>
|
|
755
|
-
update: (changes: WorkcardChanges, opts?: ModelExecuteOptions & { unset?: string[] }) => Promise<TransitionReceipt>
|
|
756
|
-
remove: (opts?: ModelExecuteOptions) => Promise<TransitionReceipt>
|
|
757
|
-
link: (type: string, to: string, fields?: Record<string, unknown>, opts?: ModelExecuteOptions) => Promise<TransitionReceipt>
|
|
758
|
-
unlink: (type: string, to: string, opts?: ModelExecuteOptions) => Promise<TransitionReceipt>
|
|
759
|
-
children: (query?: Omit<WorkcardQuery, 'parent'>) => Promise<ListResult<Workcard>>
|
|
760
|
-
relationships: (query?: RelationshipQuery) => Promise<ListResult<Relationship>>
|
|
761
|
-
transitions: (query?: Omit<TransitionQuery, 'card'>) => Promise<ListResult<Transition>>
|
|
762
|
-
specification: (category: string) => Promise<Specification | null>
|
|
763
|
-
specifications: (query?: SpecificationQuery) => Promise<ListResult<Specification>>
|
|
764
|
-
revisions: (category: string, limit?: number) => Promise<SpecificationRevision[]>
|
|
765
|
-
/** Create the slot's document, or revise it when it already exists. */
|
|
766
|
-
write: (category: string, body: string, opts?: SpecificationWriteOptions) => Promise<TransitionReceipt>
|
|
767
|
-
reload: () => Promise<WorkcardModel<T>>
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
export interface ProjectModel extends WorkcardModel<Project> {
|
|
771
|
-
cards: (query?: Omit<WorkcardQuery, 'within' | 'kind'>) => Promise<ListResult<Workcard>>
|
|
772
|
-
projects: (query?: Omit<WorkcardQuery, 'within' | 'kind'>) => Promise<ListResult<Workcard>>
|
|
773
|
-
summary: (query?: Omit<SummaryQuery, 'parents'>) => Promise<IntrinsicCounts>
|
|
774
|
-
/** A `delete` of the project — the store removes everything under it. */
|
|
775
|
-
purge: (opts?: ModelExecuteOptions) => Promise<TransitionReceipt>
|
|
776
|
-
reload: () => Promise<ProjectModel>
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
export interface SpecificationModel extends WorkcardModel<Specification> {
|
|
780
|
-
body: () => string | undefined
|
|
781
|
-
revise: (body: string, opts?: ModelExecuteOptions & { version?: number, ref?: string }) => Promise<TransitionReceipt>
|
|
782
|
-
history: (limit?: number) => Promise<SpecificationRevision[]>
|
|
783
|
-
reload: () => Promise<SpecificationModel>
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
// ─── Protocol tree ───────────────────────────────────────────────────────────────────────────────
|
|
787
|
-
|
|
788
|
-
export interface PlanningBaseOptions {
|
|
789
|
-
/** The base alias every leaf alias derives from (`planningAliases`). */
|
|
790
|
-
alias: string
|
|
791
|
-
/** Defaults to `PLANNING_PATH`. */
|
|
792
|
-
path?: string
|
|
793
|
-
parent?: RouteParent
|
|
794
|
-
service?: string
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
export interface PlanningProtocolOptions {
|
|
798
|
-
base: PlanningBaseOptions
|
|
799
|
-
/** The guard(s) the base carries; every HTTP leaf inherits them. */
|
|
800
|
-
guards: string | readonly string[]
|
|
801
|
-
gate?: { alias: string, params?: string | readonly string[] }
|
|
802
|
-
/**
|
|
803
|
-
* The socket base the commit feed hangs under. The feed inherits THAT base's guards; the
|
|
804
|
-
* planning base when omitted.
|
|
805
|
-
*/
|
|
806
|
-
socketBase?: RouteParent
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
export interface PlanningProtocols {
|
|
810
|
-
base: EntrypointProtocol<OpenRequest, OpenValue>
|
|
811
|
-
schema: {
|
|
812
|
-
list: EntrypointProtocol<{}, PlanningSchemaBundle>
|
|
813
|
-
}
|
|
814
|
-
card: {
|
|
815
|
-
list: EntrypointProtocol<{ query: WorkcardQueryWire }, ListResult<Workcard>>
|
|
816
|
-
summary: EntrypointProtocol<{ query: SummaryQueryWire }, SummaryView>
|
|
817
|
-
get: EntrypointProtocol<{ params: WorkcardParams }, Workcard>
|
|
818
|
-
transitions: EntrypointProtocol<{ params: WorkcardParams, query: TransitionQueryWire }, ListResult<Transition>>
|
|
819
|
-
specifications: EntrypointProtocol<{ params: WorkcardParams, query: SpecificationQueryWire }, ListResult<Specification>>
|
|
820
|
-
}
|
|
821
|
-
spec: {
|
|
822
|
-
get: EntrypointProtocol<{ params: WorkcardParams }, Specification>
|
|
823
|
-
revisions: EntrypointProtocol<{ params: WorkcardParams, query: RevisionsQuery }, SpecificationRevisionList>
|
|
824
|
-
}
|
|
825
|
-
link: {
|
|
826
|
-
list: EntrypointProtocol<{ query: RelationshipQueryWire }, ListResult<Relationship>>
|
|
827
|
-
}
|
|
828
|
-
transition: {
|
|
829
|
-
get: EntrypointProtocol<{ params: TransitionParams }, Transition>
|
|
830
|
-
}
|
|
831
|
-
execute: EntrypointProtocol<{ body: ExecuteRequest }, TransitionReceiptView>
|
|
832
|
-
commit: {
|
|
833
|
-
get: EntrypointProtocol<{ params: TransitionParams, query: CommitQuery }, CommitStatus>
|
|
834
|
-
events: EntrypointProtocol<{ query: CommitFeedQuery }, CommitEvent>
|
|
835
|
-
}
|
|
836
|
-
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { planningAliasHelper } from './aliases.js'
|
|
2
|
+
import type { PlanningAliases, PlanningDefinitionAliases } from './aliases/types.js'
|
|
3
|
+
|
|
4
|
+
/** @deprecated compat:factory-refactor — use `planningAliasHelper.planningAliases(…)` */
|
|
5
|
+
export const planningAliases = (base: string): PlanningAliases => planningAliasHelper.planningAliases(base)
|
|
6
|
+
|
|
7
|
+
/** @deprecated compat:factory-refactor — use `planningAliasHelper.planningDefinitionAliases(…)` */
|
|
8
|
+
export const planningDefinitionAliases = (base: string): PlanningDefinitionAliases =>
|
|
9
|
+
planningAliasHelper.planningDefinitionAliases(base)
|