deltafold 0.2.0 → 0.2.1
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 +33 -1
- package/dist/changelog.d.ts +10 -10
- package/dist/changelog.js +4 -4
- package/dist/changelog.js.map +1 -1
- package/dist/{document-BZcZo9nr.js → document-HfPyYxEd.js} +20 -20
- package/dist/{document-BZcZo9nr.js.map → document-HfPyYxEd.js.map} +1 -1
- package/dist/{document-DWHsgywm.d.ts → document-gtXeGFJR.d.ts} +41 -41
- package/dist/{document-DWHsgywm.d.ts.map → document-gtXeGFJR.d.ts.map} +1 -1
- package/dist/html.d.ts +2 -2
- package/dist/html.js +2 -2
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +437 -105
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +750 -273
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +2 -2
- package/dist/markdown.js.map +1 -1
- package/dist/{mdast-DiRsYwPU.js → mdast-Oqkh0Gs1.js} +2 -2
- package/dist/{mdast-DiRsYwPU.js.map → mdast-Oqkh0Gs1.js.map} +1 -1
- package/dist/{package-BfBYnaCz.d.ts → package-CA5R57IC.d.ts} +117 -112
- package/dist/{package-BfBYnaCz.d.ts.map → package-CA5R57IC.d.ts.map} +1 -1
- package/package.json +3 -3
- package/src/features/documents/changelog.ts +8 -8
- package/src/features/documents/document.ts +39 -39
- package/src/features/documents/index.ts +2 -2
- package/src/features/execution/executor.ts +485 -313
- package/src/features/execution/handler.ts +30 -30
- package/src/features/execution/interaction.ts +11 -11
- package/src/features/execution/observation.ts +489 -0
- package/src/features/execution/observer.ts +395 -0
- package/src/features/package.ts +3 -3
- package/src/features/planning/history.ts +10 -10
- package/src/features/planning/identifiers.ts +7 -4
- package/src/features/planning/resolve-error.ts +13 -13
- package/src/features/planning/resolve.ts +11 -4
- package/src/features/planning/validate.ts +1 -1
- package/src/foundation/action.ts +17 -17
- package/src/foundation/change.ts +10 -10
- package/src/foundation/instruction.ts +5 -5
- package/src/foundation/migration.ts +12 -12
- package/src/foundation/plan.ts +23 -18
- package/src/foundation/rule.ts +6 -6
- package/src/foundation/shortcut.ts +6 -6
- package/src/foundation/version.ts +6 -6
- package/src/index.ts +14 -12
- package/src/renderers/html.ts +1 -1
- package/src/renderers/markdown.ts +1 -1
package/src/foundation/action.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Instruction } from "./instruction.ts";
|
|
|
5
5
|
/**
|
|
6
6
|
* Describes one kind of consumer-owned operation and its payload.
|
|
7
7
|
*
|
|
8
|
-
* @since
|
|
8
|
+
* @since 0.0.1
|
|
9
9
|
*/
|
|
10
10
|
export type Kind<P> = {
|
|
11
11
|
readonly _tag: "ActionKind";
|
|
@@ -19,7 +19,7 @@ export type Kind<P> = {
|
|
|
19
19
|
* One concrete instruction. Its `id` identifies the instruction across plans, handler
|
|
20
20
|
* bindings, rules, and reports.
|
|
21
21
|
*
|
|
22
|
-
* @since
|
|
22
|
+
* @since 0.0.1
|
|
23
23
|
*/
|
|
24
24
|
export type Action<Id extends string = string, P = unknown> = {
|
|
25
25
|
readonly _tag: "Action";
|
|
@@ -33,14 +33,14 @@ export type Action<Id extends string = string, P = unknown> = {
|
|
|
33
33
|
/**
|
|
34
34
|
* Any action instance.
|
|
35
35
|
*
|
|
36
|
-
* @since
|
|
36
|
+
* @since 0.0.1
|
|
37
37
|
*/
|
|
38
38
|
export type Any = Action<string, any>;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* A mention of an action in prose. It does not declare an occurrence.
|
|
42
42
|
*
|
|
43
|
-
* @since
|
|
43
|
+
* @since 0.0.1
|
|
44
44
|
*/
|
|
45
45
|
export type Ref = {
|
|
46
46
|
readonly _tag: "ActionRef";
|
|
@@ -50,7 +50,7 @@ export type Ref = {
|
|
|
50
50
|
/**
|
|
51
51
|
* Children run one after another.
|
|
52
52
|
*
|
|
53
|
-
* @since
|
|
53
|
+
* @since 0.0.1
|
|
54
54
|
*/
|
|
55
55
|
export type Sequence<A extends Any = Any> = {
|
|
56
56
|
readonly _tag: "Sequence";
|
|
@@ -62,7 +62,7 @@ export type Sequence<A extends Any = Any> = {
|
|
|
62
62
|
/**
|
|
63
63
|
* How many branches of a parallel group may run at the same time.
|
|
64
64
|
*
|
|
65
|
-
* @since
|
|
65
|
+
* @since 0.0.1
|
|
66
66
|
*/
|
|
67
67
|
export type Concurrency = number | "unbounded";
|
|
68
68
|
|
|
@@ -70,7 +70,7 @@ export type Concurrency = number | "unbounded";
|
|
|
70
70
|
* Branches are independent of each other and may run concurrently. The group asserts
|
|
71
71
|
* that independence; the concurrency limit only controls scheduling.
|
|
72
72
|
*
|
|
73
|
-
* @since
|
|
73
|
+
* @since 0.0.1
|
|
74
74
|
*/
|
|
75
75
|
export type Parallel<A extends Any = Any> = {
|
|
76
76
|
readonly _tag: "Parallel";
|
|
@@ -83,14 +83,14 @@ export type Parallel<A extends Any = Any> = {
|
|
|
83
83
|
/**
|
|
84
84
|
* A node that declares action occurrences.
|
|
85
85
|
*
|
|
86
|
-
* @since
|
|
86
|
+
* @since 0.0.1
|
|
87
87
|
*/
|
|
88
88
|
export type Step<A extends Any = Any> = A | Instruction<A> | Sequence<A> | Parallel<A>;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Extracts the action instances declared by a step.
|
|
92
92
|
*
|
|
93
|
-
* @since
|
|
93
|
+
* @since 0.0.1
|
|
94
94
|
*/
|
|
95
95
|
export type ActionsOf<S> =
|
|
96
96
|
S extends Action<infer Id, infer P>
|
|
@@ -119,7 +119,7 @@ export type ActionsOf<S> =
|
|
|
119
119
|
* });
|
|
120
120
|
* ```
|
|
121
121
|
*
|
|
122
|
-
* @since
|
|
122
|
+
* @since 0.0.1
|
|
123
123
|
*/
|
|
124
124
|
export const define = <P>(
|
|
125
125
|
kind: string,
|
|
@@ -144,14 +144,14 @@ export const define = <P>(
|
|
|
144
144
|
/**
|
|
145
145
|
* Mentions an action in prose without declaring another occurrence.
|
|
146
146
|
*
|
|
147
|
-
* @since
|
|
147
|
+
* @since 0.0.1
|
|
148
148
|
*/
|
|
149
149
|
export const ref = (action: Any): Ref => ({ _tag: "ActionRef", action });
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Declares steps that run one after another.
|
|
153
153
|
*
|
|
154
|
-
* @since
|
|
154
|
+
* @since 0.0.1
|
|
155
155
|
*/
|
|
156
156
|
export const sequence = <const S extends ReadonlyArray<Step>>(
|
|
157
157
|
children: S,
|
|
@@ -161,7 +161,7 @@ export const sequence = <const S extends ReadonlyArray<Step>>(
|
|
|
161
161
|
* Declares independent branches that may run concurrently. Each branch can be a single
|
|
162
162
|
* step or a sequence.
|
|
163
163
|
*
|
|
164
|
-
* @since
|
|
164
|
+
* @since 0.0.1
|
|
165
165
|
*/
|
|
166
166
|
export const parallel = <const S extends ReadonlyArray<Step>>(
|
|
167
167
|
branches: S,
|
|
@@ -172,17 +172,17 @@ export const parallel = <const S extends ReadonlyArray<Step>>(
|
|
|
172
172
|
concurrency: options.concurrency ?? "unbounded",
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
/** @since
|
|
175
|
+
/** @since 0.0.1 */
|
|
176
176
|
export const isAction = (value: unknown): value is Any =>
|
|
177
177
|
Predicate.isTagged(value, "Action") && Predicate.hasProperty(value, "id");
|
|
178
178
|
|
|
179
|
-
/** @since
|
|
179
|
+
/** @since 0.0.1 */
|
|
180
180
|
export const isRef = (value: unknown): value is Ref => Predicate.isTagged(value, "ActionRef");
|
|
181
181
|
|
|
182
|
-
/** @since
|
|
182
|
+
/** @since 0.0.1 */
|
|
183
183
|
export const isSequence = (value: unknown): value is Sequence =>
|
|
184
184
|
Predicate.isTagged(value, "Sequence");
|
|
185
185
|
|
|
186
|
-
/** @since
|
|
186
|
+
/** @since 0.0.1 */
|
|
187
187
|
export const isParallel = (value: unknown): value is Parallel =>
|
|
188
188
|
Predicate.isTagged(value, "Parallel");
|
package/src/foundation/change.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { describeValue, dedent, isScalar, type Scalar } from "./template.ts";
|
|
|
5
5
|
/**
|
|
6
6
|
* The metadata of a change whose shape is not known statically.
|
|
7
7
|
*
|
|
8
|
-
* @since
|
|
8
|
+
* @since 0.0.1
|
|
9
9
|
*/
|
|
10
10
|
export type Metadata = { readonly [field: string]: unknown };
|
|
11
11
|
|
|
12
|
-
/** @since
|
|
12
|
+
/** @since 0.0.1 */
|
|
13
13
|
export type NoMetadata = { readonly [field: string]: undefined };
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -19,7 +19,7 @@ export type NoMetadata = { readonly [field: string]: undefined };
|
|
|
19
19
|
* deltafold does not interpret `metadata`. Consumers choose its fields, such as a
|
|
20
20
|
* classification or a breaking flag, and what they mean.
|
|
21
21
|
*
|
|
22
|
-
* @since
|
|
22
|
+
* @since 0.0.1
|
|
23
23
|
*/
|
|
24
24
|
export type Change<M extends object = Metadata> = {
|
|
25
25
|
readonly _tag: "Change";
|
|
@@ -37,14 +37,14 @@ export type Change<M extends object = Metadata> = {
|
|
|
37
37
|
* A change whose metadata type is not known statically. Its metadata is an object, so
|
|
38
38
|
* reading a field requires narrowing first.
|
|
39
39
|
*
|
|
40
|
-
* @since
|
|
40
|
+
* @since 0.0.1
|
|
41
41
|
*/
|
|
42
42
|
export type Any = Change<object>;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Relationships to other changes.
|
|
46
46
|
*
|
|
47
|
-
* @since
|
|
47
|
+
* @since 0.0.1
|
|
48
48
|
*/
|
|
49
49
|
export type Relations = {
|
|
50
50
|
readonly reverts?: ReadonlyArray<Any>;
|
|
@@ -54,7 +54,7 @@ export type Relations = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Takes the description as a tagged template and returns the change.
|
|
56
56
|
*
|
|
57
|
-
* @since
|
|
57
|
+
* @since 0.0.1
|
|
58
58
|
*/
|
|
59
59
|
export type Describe<M extends object> = (
|
|
60
60
|
strings: TemplateStringsArray,
|
|
@@ -101,7 +101,7 @@ const describe =
|
|
|
101
101
|
* `;
|
|
102
102
|
* ```
|
|
103
103
|
*
|
|
104
|
-
* @since
|
|
104
|
+
* @since 0.0.1
|
|
105
105
|
*/
|
|
106
106
|
export function make(id: string): Describe<NoMetadata>;
|
|
107
107
|
export function make<const M extends object>(
|
|
@@ -116,7 +116,7 @@ export function make(id: string, metadata: object = {}, relations: Relations = {
|
|
|
116
116
|
/**
|
|
117
117
|
* Makes changes that share one metadata shape.
|
|
118
118
|
*
|
|
119
|
-
* @since
|
|
119
|
+
* @since 0.0.1
|
|
120
120
|
*/
|
|
121
121
|
export type Definition<M extends object> = {
|
|
122
122
|
readonly make: (id: string, metadata: M, relations?: Relations) => Describe<M>;
|
|
@@ -139,9 +139,9 @@ export type Definition<M extends object> = {
|
|
|
139
139
|
* `;
|
|
140
140
|
* ```
|
|
141
141
|
*
|
|
142
|
-
* @since
|
|
142
|
+
* @since 0.0.1
|
|
143
143
|
*/
|
|
144
144
|
export const define = <M extends object>(): Definition<M> => ({ make: make<M> });
|
|
145
145
|
|
|
146
|
-
/** @since
|
|
146
|
+
/** @since 0.0.1 */
|
|
147
147
|
export const isChange = (value: unknown): value is Change => Predicate.isTagged(value, "Change");
|
|
@@ -7,7 +7,7 @@ import { describeValue, dedent, isScalar, type Scalar } from "./template.ts";
|
|
|
7
7
|
/**
|
|
8
8
|
* Literal prose.
|
|
9
9
|
*
|
|
10
|
-
* @since
|
|
10
|
+
* @since 0.0.1
|
|
11
11
|
*/
|
|
12
12
|
export type Text = {
|
|
13
13
|
readonly _tag: "Text";
|
|
@@ -17,14 +17,14 @@ export type Text = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Prose content: text and action mentions.
|
|
19
19
|
*
|
|
20
|
-
* @since
|
|
20
|
+
* @since 0.0.1
|
|
21
21
|
*/
|
|
22
22
|
export type Prose = ReadonlyArray<Text | Action.Ref>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Values accepted inside prose templates.
|
|
26
26
|
*
|
|
27
|
-
* @since
|
|
27
|
+
* @since 0.0.1
|
|
28
28
|
*/
|
|
29
29
|
export type ProseValue = Scalar | Action.Ref;
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ export type ProseValue = Scalar | Action.Ref;
|
|
|
33
33
|
* occurrence; when optimization removes the action, the block leaves the resolved guide
|
|
34
34
|
* with it.
|
|
35
35
|
*
|
|
36
|
-
* @since
|
|
36
|
+
* @since 0.0.1
|
|
37
37
|
*/
|
|
38
38
|
export type Instruction<A extends Action.Any = Action.Any> = {
|
|
39
39
|
readonly _tag: "Instruction";
|
|
@@ -99,7 +99,7 @@ export const prose = (
|
|
|
99
99
|
* `;
|
|
100
100
|
* ```
|
|
101
101
|
*
|
|
102
|
-
* @since
|
|
102
|
+
* @since 0.0.1
|
|
103
103
|
*/
|
|
104
104
|
export const instruction =
|
|
105
105
|
<A extends Action.Any>(action: A) =>
|
|
@@ -13,7 +13,7 @@ export type { Instruction, Prose, ProseValue, Text } from "./instruction.ts";
|
|
|
13
13
|
/**
|
|
14
14
|
* Prose, mentions, and occurrence-declaring steps in template order.
|
|
15
15
|
*
|
|
16
|
-
* @since
|
|
16
|
+
* @since 0.0.1
|
|
17
17
|
*/
|
|
18
18
|
export type Content<A extends Action.Any = Action.Any> = ReadonlyArray<
|
|
19
19
|
Text | Action.Ref | Action.Step<A>
|
|
@@ -22,11 +22,11 @@ export type Content<A extends Action.Any = Action.Any> = ReadonlyArray<
|
|
|
22
22
|
/**
|
|
23
23
|
* Values accepted in migration templates.
|
|
24
24
|
*
|
|
25
|
-
* @since
|
|
25
|
+
* @since 0.0.1
|
|
26
26
|
*/
|
|
27
27
|
export type Interpolation = Scalar | Action.Ref | Action.Step;
|
|
28
28
|
|
|
29
|
-
/** @since
|
|
29
|
+
/** @since 0.0.1 */
|
|
30
30
|
export type Migration<A extends Action.Any = Action.Any, C extends Change.Any = Change.Any> = {
|
|
31
31
|
readonly _tag: "Migration";
|
|
32
32
|
readonly id: string;
|
|
@@ -48,25 +48,25 @@ export type Migration<A extends Action.Any = Action.Any, C extends Change.Any =
|
|
|
48
48
|
/**
|
|
49
49
|
* Any migration.
|
|
50
50
|
*
|
|
51
|
-
* @since
|
|
51
|
+
* @since 0.0.1
|
|
52
52
|
*/
|
|
53
53
|
export type Any = Migration<any>;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* The action instances a migration can contribute to a plan.
|
|
57
57
|
*
|
|
58
|
-
* @since
|
|
58
|
+
* @since 0.0.1
|
|
59
59
|
*/
|
|
60
60
|
export type ActionsOf<M> = M extends Migration<infer A> ? A : never;
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* The changes a migration addresses.
|
|
64
64
|
*
|
|
65
|
-
* @since
|
|
65
|
+
* @since 0.0.1
|
|
66
66
|
*/
|
|
67
67
|
export type ChangesOf<M> = M extends Migration<any, infer C> ? C : never;
|
|
68
68
|
|
|
69
|
-
/** @since
|
|
69
|
+
/** @since 0.0.1 */
|
|
70
70
|
export type Options<C extends Change.Any = Change.Any> = {
|
|
71
71
|
readonly from: Version;
|
|
72
72
|
readonly to: Version;
|
|
@@ -74,7 +74,7 @@ export type Options<C extends Change.Any = Change.Any> = {
|
|
|
74
74
|
readonly cost?: number;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
/** @since
|
|
77
|
+
/** @since 0.0.1 */
|
|
78
78
|
export const isMigration = (value: unknown): value is Any => Predicate.isTagged(value, "Migration");
|
|
79
79
|
|
|
80
80
|
const isStep = (value: unknown): value is Action.Step =>
|
|
@@ -162,7 +162,7 @@ const content = (
|
|
|
162
162
|
* `;
|
|
163
163
|
* ```
|
|
164
164
|
*
|
|
165
|
-
* @since
|
|
165
|
+
* @since 0.0.1
|
|
166
166
|
*/
|
|
167
167
|
export const make =
|
|
168
168
|
<C extends Change.Any = never>(id: string, options: Options<C>) =>
|
|
@@ -181,7 +181,7 @@ export const make =
|
|
|
181
181
|
revert: undefined,
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
/** @since
|
|
184
|
+
/** @since 0.0.1 */
|
|
185
185
|
export type NoopOptions<C extends Change.Any = Change.Any> = Options<C> & {
|
|
186
186
|
/** Also declares the reverse transition as zero-work. */
|
|
187
187
|
readonly reversible?: boolean;
|
|
@@ -192,7 +192,7 @@ export type NoopOptions<C extends Change.Any = Change.Any> = Options<C> & {
|
|
|
192
192
|
* like any migration. Do not use it to hide missing support for changes that need
|
|
193
193
|
* instructions.
|
|
194
194
|
*
|
|
195
|
-
* @since
|
|
195
|
+
* @since 0.0.1
|
|
196
196
|
*/
|
|
197
197
|
export const noop = <C extends Change.Any = never>(
|
|
198
198
|
id: string,
|
|
@@ -223,7 +223,7 @@ export const noop = <C extends Change.Any = never>(
|
|
|
223
223
|
* `;
|
|
224
224
|
* ```
|
|
225
225
|
*
|
|
226
|
-
* @since
|
|
226
|
+
* @since 0.0.1
|
|
227
227
|
*/
|
|
228
228
|
export const withRevert =
|
|
229
229
|
<A extends Action.Any, C extends Change.Any>(migration: Migration<A, C>) =>
|
package/src/foundation/plan.ts
CHANGED
|
@@ -9,14 +9,14 @@ import type { Version } from "./version.ts";
|
|
|
9
9
|
/**
|
|
10
10
|
* Which side of a migration runs.
|
|
11
11
|
*
|
|
12
|
-
* @since
|
|
12
|
+
* @since 0.0.1
|
|
13
13
|
*/
|
|
14
14
|
export type Direction = "forward" | "revert";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* How an occurrence entered the plan.
|
|
18
18
|
*
|
|
19
|
-
* @since
|
|
19
|
+
* @since 0.0.1
|
|
20
20
|
*/
|
|
21
21
|
export type Origin =
|
|
22
22
|
| { readonly _tag: "Declared" }
|
|
@@ -32,7 +32,7 @@ export type Origin =
|
|
|
32
32
|
* it combines the migration, direction, and action identifiers, or the rule and the
|
|
33
33
|
* replaced occurrences for a replacement.
|
|
34
34
|
*
|
|
35
|
-
* @since
|
|
35
|
+
* @since 0.0.1
|
|
36
36
|
*/
|
|
37
37
|
export type Occurrence<A extends Action.Any = Action.Any> = {
|
|
38
38
|
readonly _tag: "Occurrence";
|
|
@@ -51,13 +51,13 @@ export type Occurrence<A extends Action.Any = Action.Any> = {
|
|
|
51
51
|
readonly origin: Origin;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
/** @since
|
|
54
|
+
/** @since 0.0.1 */
|
|
55
55
|
export type Sequence<A extends Action.Any = Action.Any> = {
|
|
56
56
|
readonly _tag: "Sequence";
|
|
57
57
|
readonly children: ReadonlyArray<Node<A>>;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
/** @since
|
|
60
|
+
/** @since 0.0.1 */
|
|
61
61
|
export type Parallel<A extends Action.Any = Action.Any> = {
|
|
62
62
|
readonly _tag: "Parallel";
|
|
63
63
|
readonly branches: ReadonlyArray<Node<A>>;
|
|
@@ -67,14 +67,14 @@ export type Parallel<A extends Action.Any = Action.Any> = {
|
|
|
67
67
|
/**
|
|
68
68
|
* The declared execution structure.
|
|
69
69
|
*
|
|
70
|
-
* @since
|
|
70
|
+
* @since 0.0.1
|
|
71
71
|
*/
|
|
72
72
|
export type Node<A extends Action.Any = Action.Any> = Occurrence<A> | Sequence<A> | Parallel<A>;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Resolved prose for a guide. Occurrences render as their instruction or description.
|
|
76
76
|
*
|
|
77
|
-
* @since
|
|
77
|
+
* @since 0.0.1
|
|
78
78
|
*/
|
|
79
79
|
export type GuideItem<A extends Action.Any = Action.Any> =
|
|
80
80
|
| Text
|
|
@@ -91,10 +91,15 @@ export type GuideItem<A extends Action.Any = Action.Any> =
|
|
|
91
91
|
* One migration in the route. Steps are sequential barriers: a step starts only after
|
|
92
92
|
* the previous step completed.
|
|
93
93
|
*
|
|
94
|
-
* @since
|
|
94
|
+
* @since 0.0.1
|
|
95
95
|
*/
|
|
96
96
|
export type Step<A extends Action.Any = Action.Any> = {
|
|
97
97
|
readonly _tag: "Step";
|
|
98
|
+
/**
|
|
99
|
+
* Identifies the migration side within the route: the migration identifier, followed by
|
|
100
|
+
* `/revert` for a reverse migration. Declared occurrence identifiers start with it.
|
|
101
|
+
*/
|
|
102
|
+
readonly id: string;
|
|
98
103
|
readonly migration: Migration.Any;
|
|
99
104
|
readonly direction: Direction;
|
|
100
105
|
readonly from: Version;
|
|
@@ -112,7 +117,7 @@ export type Step<A extends Action.Any = Action.Any> = {
|
|
|
112
117
|
/**
|
|
113
118
|
* Why the plan differs from the declared migrations.
|
|
114
119
|
*
|
|
115
|
-
* @since
|
|
120
|
+
* @since 0.0.1
|
|
116
121
|
*/
|
|
117
122
|
export type Explanation =
|
|
118
123
|
| {
|
|
@@ -131,7 +136,7 @@ export type Explanation =
|
|
|
131
136
|
/**
|
|
132
137
|
* A hop in a route: the migrations between two versions, or a shortcut.
|
|
133
138
|
*
|
|
134
|
-
* @since
|
|
139
|
+
* @since 0.0.1
|
|
135
140
|
*/
|
|
136
141
|
export type Hop =
|
|
137
142
|
| {
|
|
@@ -154,7 +159,7 @@ export type Hop =
|
|
|
154
159
|
readonly shortcut: Shortcut.Any;
|
|
155
160
|
};
|
|
156
161
|
|
|
157
|
-
/** @since
|
|
162
|
+
/** @since 0.0.1 */
|
|
158
163
|
export type Route = {
|
|
159
164
|
/**
|
|
160
165
|
* Identifies the route for explicit selection: version identifiers joined by `>`,
|
|
@@ -168,7 +173,7 @@ export type Route = {
|
|
|
168
173
|
/**
|
|
169
174
|
* How the requested target relates to the source in release ancestry.
|
|
170
175
|
*
|
|
171
|
-
* @since
|
|
176
|
+
* @since 0.0.1
|
|
172
177
|
*/
|
|
173
178
|
export type RequestDirection = "none" | "upgrade" | "downgrade" | "cross-branch";
|
|
174
179
|
|
|
@@ -176,7 +181,7 @@ export type RequestDirection = "none" | "upgrade" | "downgrade" | "cross-branch"
|
|
|
176
181
|
* When executors check handler coverage. Static plans also expose uncovered actions in
|
|
177
182
|
* the execution's type.
|
|
178
183
|
*
|
|
179
|
-
* @since
|
|
184
|
+
* @since 0.0.1
|
|
180
185
|
*/
|
|
181
186
|
export type Coverage = "static" | "runtime";
|
|
182
187
|
|
|
@@ -184,7 +189,7 @@ export type Coverage = "static" | "runtime";
|
|
|
184
189
|
* A resolved, optimized route between two versions. Every step stays traceable to its
|
|
185
190
|
* migration and the changes that migration addresses.
|
|
186
191
|
*
|
|
187
|
-
* @since
|
|
192
|
+
* @since 0.0.1
|
|
188
193
|
*/
|
|
189
194
|
export type Plan<
|
|
190
195
|
A extends Action.Any = Action.Any,
|
|
@@ -212,21 +217,21 @@ export type Plan<
|
|
|
212
217
|
/**
|
|
213
218
|
* Any plan.
|
|
214
219
|
*
|
|
215
|
-
* @since
|
|
220
|
+
* @since 0.0.1
|
|
216
221
|
*/
|
|
217
222
|
export type Any = Plan<any, any>;
|
|
218
223
|
|
|
219
224
|
/**
|
|
220
225
|
* The action instances of a plan.
|
|
221
226
|
*
|
|
222
|
-
* @since
|
|
227
|
+
* @since 0.0.1
|
|
223
228
|
*/
|
|
224
229
|
export type ActionsOf<P> = P extends Plan<infer A, any> ? A : never;
|
|
225
230
|
|
|
226
231
|
/**
|
|
227
232
|
* Whether the plan has no action occurrences. An empty plan is valid.
|
|
228
233
|
*
|
|
229
|
-
* @since
|
|
234
|
+
* @since 0.0.1
|
|
230
235
|
*/
|
|
231
236
|
export const isEmpty = (plan: Any): boolean => plan.occurrences.length === 0;
|
|
232
237
|
|
|
@@ -235,7 +240,7 @@ export const isEmpty = (plan: Any): boolean => plan.occurrences.length === 0;
|
|
|
235
240
|
* loaded plans whose action union is not known statically. Executors still reject
|
|
236
241
|
* missing handlers before any action body runs.
|
|
237
242
|
*
|
|
238
|
-
* @since
|
|
243
|
+
* @since 0.0.1
|
|
239
244
|
*/
|
|
240
245
|
export const withRuntimeCoverage = <A extends Action.Any, Ch extends Change.Any>(
|
|
241
246
|
plan: Plan<A, Coverage, Ch>,
|
package/src/foundation/rule.ts
CHANGED
|
@@ -6,11 +6,11 @@ import type * as Action from "./action.ts";
|
|
|
6
6
|
* What a rule matches: an action instance, or a parallel group matched by its branch
|
|
7
7
|
* structure. Matching a parallel group is an explicit structural rule.
|
|
8
8
|
*
|
|
9
|
-
* @since
|
|
9
|
+
* @since 0.0.1
|
|
10
10
|
*/
|
|
11
11
|
export type Pattern = Action.Any | Action.Parallel;
|
|
12
12
|
|
|
13
|
-
/** @since
|
|
13
|
+
/** @since 0.0.1 */
|
|
14
14
|
export type Rule<A extends Action.Any = Action.Any> = {
|
|
15
15
|
readonly _tag: "Rule";
|
|
16
16
|
readonly id: string;
|
|
@@ -22,14 +22,14 @@ export type Rule<A extends Action.Any = Action.Any> = {
|
|
|
22
22
|
/**
|
|
23
23
|
* Any rule.
|
|
24
24
|
*
|
|
25
|
-
* @since
|
|
25
|
+
* @since 0.0.1
|
|
26
26
|
*/
|
|
27
27
|
export type Any = Rule<any>;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* The action instances a rule can contribute to a plan.
|
|
31
31
|
*
|
|
32
|
-
* @since
|
|
32
|
+
* @since 0.0.1
|
|
33
33
|
*/
|
|
34
34
|
export type ActionsOf<R> = R extends Rule<infer A> ? A : never;
|
|
35
35
|
|
|
@@ -55,7 +55,7 @@ export type ActionsOf<R> = R extends Rule<infer A> ? A : never;
|
|
|
55
55
|
* });
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
|
-
* @since
|
|
58
|
+
* @since 0.0.1
|
|
59
59
|
*/
|
|
60
60
|
export const replace = <A extends Action.Any = never>(
|
|
61
61
|
id: string,
|
|
@@ -70,5 +70,5 @@ export const replace = <A extends Action.Any = never>(
|
|
|
70
70
|
replacement: options.replacement,
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
/** @since
|
|
73
|
+
/** @since 0.0.1 */
|
|
74
74
|
export const isRule = (value: unknown): value is Any => Predicate.isTagged(value, "Rule");
|
|
@@ -5,7 +5,7 @@ import type * as Change from "./change.ts";
|
|
|
5
5
|
import type * as Migration from "./migration.ts";
|
|
6
6
|
import type { Version } from "./version.ts";
|
|
7
7
|
|
|
8
|
-
/** @since
|
|
8
|
+
/** @since 0.0.1 */
|
|
9
9
|
export type Shortcut<A extends Action.Any = Action.Any, C extends Change.Any = Change.Any> = {
|
|
10
10
|
readonly _tag: "Shortcut";
|
|
11
11
|
readonly id: string;
|
|
@@ -22,21 +22,21 @@ export type Shortcut<A extends Action.Any = Action.Any, C extends Change.Any = C
|
|
|
22
22
|
/**
|
|
23
23
|
* Any shortcut.
|
|
24
24
|
*
|
|
25
|
-
* @since
|
|
25
|
+
* @since 0.0.1
|
|
26
26
|
*/
|
|
27
27
|
export type Any = Shortcut<any>;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* The action instances a shortcut can contribute to a plan.
|
|
31
31
|
*
|
|
32
|
-
* @since
|
|
32
|
+
* @since 0.0.1
|
|
33
33
|
*/
|
|
34
34
|
export type ActionsOf<S> = S extends Shortcut<infer A> ? A : never;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* The changes addressed by a shortcut's migrations.
|
|
38
38
|
*
|
|
39
|
-
* @since
|
|
39
|
+
* @since 0.0.1
|
|
40
40
|
*/
|
|
41
41
|
export type ChangesOf<S> = S extends Shortcut<any, infer C> ? C : never;
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ export type ChangesOf<S> = S extends Shortcut<any, infer C> ? C : never;
|
|
|
54
54
|
* });
|
|
55
55
|
* ```
|
|
56
56
|
*
|
|
57
|
-
* @since
|
|
57
|
+
* @since 0.0.1
|
|
58
58
|
*/
|
|
59
59
|
export const make = <A extends Action.Any, C extends Change.Any = never>(
|
|
60
60
|
id: string,
|
|
@@ -75,5 +75,5 @@ export const make = <A extends Action.Any, C extends Change.Any = never>(
|
|
|
75
75
|
cost: options.cost,
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
/** @since
|
|
78
|
+
/** @since 0.0.1 */
|
|
79
79
|
export const isShortcut = (value: unknown): value is Any => Predicate.isTagged(value, "Shortcut");
|
|
@@ -2,7 +2,7 @@ import { Predicate } from "effect";
|
|
|
2
2
|
|
|
3
3
|
import type * as Change from "./change.ts";
|
|
4
4
|
|
|
5
|
-
/** @since
|
|
5
|
+
/** @since 0.0.1 */
|
|
6
6
|
export type Version<C extends Change.Any = Change.Any> = {
|
|
7
7
|
readonly _tag: "Version";
|
|
8
8
|
readonly id: string;
|
|
@@ -16,7 +16,7 @@ export type Version<C extends Change.Any = Change.Any> = {
|
|
|
16
16
|
readonly changes: ReadonlyArray<C>;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
/** @since
|
|
19
|
+
/** @since 0.0.1 */
|
|
20
20
|
export type Options<C extends Change.Any = Change.Any> = {
|
|
21
21
|
readonly previous?: Version;
|
|
22
22
|
readonly changes: ReadonlyArray<C>;
|
|
@@ -31,7 +31,7 @@ export type Options<C extends Change.Any = Change.Any> = {
|
|
|
31
31
|
* const v100 = Version.make("1.0.0", { previous: v0, changes: [timeoutRenamed] });
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
34
|
-
* @since
|
|
34
|
+
* @since 0.0.1
|
|
35
35
|
*/
|
|
36
36
|
export const make = <C extends Change.Any = never>(
|
|
37
37
|
id: string,
|
|
@@ -43,14 +43,14 @@ export const make = <C extends Change.Any = never>(
|
|
|
43
43
|
changes: options.changes,
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
/** @since
|
|
46
|
+
/** @since 0.0.1 */
|
|
47
47
|
export const isVersion = (value: unknown): value is Version => Predicate.isTagged(value, "Version");
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Release metadata attached to a version by release tooling. It does not modify the
|
|
51
51
|
* version registered in history.
|
|
52
52
|
*
|
|
53
|
-
* @since
|
|
53
|
+
* @since 0.0.1
|
|
54
54
|
*/
|
|
55
55
|
export type Release<M> = {
|
|
56
56
|
readonly _tag: "Release";
|
|
@@ -69,7 +69,7 @@ export type Release<M> = {
|
|
|
69
69
|
* });
|
|
70
70
|
* ```
|
|
71
71
|
*
|
|
72
|
-
* @since
|
|
72
|
+
* @since 0.0.1
|
|
73
73
|
*/
|
|
74
74
|
export const withMetadata = <const M>(version: Version, metadata: M): Release<M> => ({
|
|
75
75
|
_tag: "Release",
|