deltafold 0.0.0 → 0.0.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 +274 -4
- package/dist/changelog.d.ts +116 -0
- package/dist/changelog.d.ts.map +1 -0
- package/dist/changelog.js +304 -0
- package/dist/changelog.js.map +1 -0
- package/dist/document-BZcZo9nr.js +171 -0
- package/dist/document-BZcZo9nr.js.map +1 -0
- package/dist/document-DWHsgywm.d.ts +257 -0
- package/dist/document-DWHsgywm.d.ts.map +1 -0
- package/dist/html.d.ts +8 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +13 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +378 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2058 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.d.ts +8 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +16 -0
- package/dist/markdown.js.map +1 -0
- package/dist/mdast-DiRsYwPU.js +108 -0
- package/dist/mdast-DiRsYwPU.js.map +1 -0
- package/dist/package-BfBYnaCz.d.ts +1125 -0
- package/dist/package-BfBYnaCz.d.ts.map +1 -0
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/package.json +13 -1
- package/src/features/documents/changelog.ts +450 -0
- package/src/features/documents/document.ts +357 -0
- package/src/features/documents/index.ts +4 -0
- package/src/features/documents/public-document.ts +31 -0
- package/src/features/documents/sections.ts +44 -0
- package/src/features/execution/executor.ts +826 -0
- package/src/features/execution/handler.ts +257 -0
- package/src/features/execution/settlement.ts +49 -0
- package/src/features/package.ts +32 -0
- package/src/features/planning/guide.ts +56 -0
- package/src/features/planning/history.ts +174 -0
- package/src/features/planning/identifiers.ts +43 -0
- package/src/features/planning/resolve-error.ts +201 -0
- package/src/features/planning/resolve.ts +724 -0
- package/src/features/planning/rewrite.ts +331 -0
- package/src/features/planning/validate.ts +388 -0
- package/src/foundation/action.ts +188 -0
- package/src/foundation/change.ts +147 -0
- package/src/foundation/instruction.ts +110 -0
- package/src/foundation/migration.ts +236 -0
- package/src/foundation/plan.ts +245 -0
- package/src/foundation/rule.ts +74 -0
- package/src/foundation/shortcut.ts +79 -0
- package/src/foundation/template.ts +28 -0
- package/src/foundation/version.ts +78 -0
- package/src/index.ts +22 -11
- package/src/renderers/html.ts +12 -0
- package/src/renderers/markdown.ts +12 -0
- package/src/renderers/mdast.ts +120 -0
- package/src/types.ts +2 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Data } from "effect";
|
|
2
|
+
|
|
3
|
+
import type { RequestDirection } from "../../foundation/plan.ts";
|
|
4
|
+
import type { Issue } from "./validate.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A candidate route, summarized for diagnostics and explicit selection.
|
|
8
|
+
*
|
|
9
|
+
* @since @next
|
|
10
|
+
*/
|
|
11
|
+
export type RouteSummary = {
|
|
12
|
+
/** Pass this as the `route` option to select the route. */
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly migrations: ReadonlyArray<string>;
|
|
15
|
+
readonly shortcuts: ReadonlyArray<string>;
|
|
16
|
+
/** Optimized action count, or `undefined` when the route failed to optimize. */
|
|
17
|
+
readonly actions: number | undefined;
|
|
18
|
+
readonly cost: number;
|
|
19
|
+
/** Why the route cannot be planned, if it cannot. */
|
|
20
|
+
readonly failure: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An ancestry hop with no declared route in the requested direction.
|
|
25
|
+
*
|
|
26
|
+
* @since @next
|
|
27
|
+
*/
|
|
28
|
+
export type Blocker = {
|
|
29
|
+
readonly from: string;
|
|
30
|
+
readonly to: string;
|
|
31
|
+
readonly reason: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The history's declarations are invalid. Resolution needs a valid history.
|
|
36
|
+
*
|
|
37
|
+
* @since @next
|
|
38
|
+
*/
|
|
39
|
+
export class InvalidHistory extends Data.TaggedError("InvalidHistory")<{
|
|
40
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
41
|
+
}> {
|
|
42
|
+
override get message() {
|
|
43
|
+
return `The history has ${this.issues.length} declaration issue(s): ${this.issues
|
|
44
|
+
.map((issue) => issue.message)
|
|
45
|
+
.join(" ")}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @since @next */
|
|
50
|
+
export class UnknownVersion extends Data.TaggedError("UnknownVersion")<{
|
|
51
|
+
readonly version: string;
|
|
52
|
+
readonly known: ReadonlyArray<string>;
|
|
53
|
+
}> {
|
|
54
|
+
override get message() {
|
|
55
|
+
return `Version "${this.version}" is not registered in the history.`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* No declared route connects the versions. This never means that no work is needed:
|
|
61
|
+
* declare `Migration.noop` for a supported zero-work transition.
|
|
62
|
+
*
|
|
63
|
+
* @since @next
|
|
64
|
+
*/
|
|
65
|
+
export class UnsupportedRoute extends Data.TaggedError("UnsupportedRoute")<{
|
|
66
|
+
readonly from: string;
|
|
67
|
+
readonly to: string;
|
|
68
|
+
readonly direction: RequestDirection;
|
|
69
|
+
/** Versions that are reachable from `from` in the requested direction. */
|
|
70
|
+
readonly reachable: ReadonlyArray<string>;
|
|
71
|
+
/** Reachable versions closest to `to` along release ancestry. Ties are all listed. */
|
|
72
|
+
readonly closest: ReadonlyArray<string>;
|
|
73
|
+
readonly blockers: ReadonlyArray<Blocker>;
|
|
74
|
+
}> {
|
|
75
|
+
override get message() {
|
|
76
|
+
const closest =
|
|
77
|
+
this.closest.length === 0 ? "" : ` Closest reachable: ${this.closest.join(", ")}.`;
|
|
78
|
+
|
|
79
|
+
return `No declared ${this.direction} route from "${this.from}" to "${this.to}".${closest}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Several routes connect the versions and no selection or policy chose one.
|
|
85
|
+
*
|
|
86
|
+
* @since @next
|
|
87
|
+
*/
|
|
88
|
+
export class AmbiguousRoute extends Data.TaggedError("AmbiguousRoute")<{
|
|
89
|
+
readonly from: string;
|
|
90
|
+
readonly to: string;
|
|
91
|
+
readonly candidates: ReadonlyArray<RouteSummary>;
|
|
92
|
+
readonly policy: string | undefined;
|
|
93
|
+
}> {
|
|
94
|
+
override get message() {
|
|
95
|
+
const ids = this.candidates.map((candidate) => `"${candidate.id}"`).join(", ");
|
|
96
|
+
const reason =
|
|
97
|
+
this.policy === undefined ? "" : ` after applying the "${this.policy}" policy`;
|
|
98
|
+
|
|
99
|
+
return `${this.candidates.length} routes connect "${this.from}" and "${this.to}"${reason}: ${ids}. Select one with the \`route\` option, or choose a route policy.`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The `route` option names no candidate route.
|
|
105
|
+
*
|
|
106
|
+
* @since @next
|
|
107
|
+
*/
|
|
108
|
+
export class UnknownRoute extends Data.TaggedError("UnknownRoute")<{
|
|
109
|
+
readonly route: string;
|
|
110
|
+
readonly candidates: ReadonlyArray<RouteSummary>;
|
|
111
|
+
}> {
|
|
112
|
+
override get message() {
|
|
113
|
+
return `No candidate route has the identifier "${this.route}". Candidates: ${this.candidates
|
|
114
|
+
.map((candidate) => `"${candidate.id}"`)
|
|
115
|
+
.join(", ")}.`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Rules rewrite a sequence back into itself.
|
|
121
|
+
*
|
|
122
|
+
* @since @next
|
|
123
|
+
*/
|
|
124
|
+
export class RewriteCycle extends Data.TaggedError("RewriteCycle")<{
|
|
125
|
+
readonly route: string;
|
|
126
|
+
readonly rules: ReadonlyArray<string>;
|
|
127
|
+
readonly actions: string;
|
|
128
|
+
}> {
|
|
129
|
+
override get message() {
|
|
130
|
+
return `Rules ${this.rules.map((rule) => `"${rule}"`).join(", ")} rewrite a sequence back into itself on route "${this.route}".`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Rules can produce different results depending on which applies first.
|
|
136
|
+
*
|
|
137
|
+
* @since @next
|
|
138
|
+
*/
|
|
139
|
+
export class ConflictingRewrites extends Data.TaggedError("ConflictingRewrites")<{
|
|
140
|
+
readonly route: string;
|
|
141
|
+
readonly outcomes: ReadonlyArray<{
|
|
142
|
+
readonly actions: string;
|
|
143
|
+
readonly rules: ReadonlyArray<string>;
|
|
144
|
+
}>;
|
|
145
|
+
}> {
|
|
146
|
+
override get message() {
|
|
147
|
+
return `Rules produce ${this.outcomes.length} different results on route "${this.route}", depending on the order they apply in.`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Optimization explored too many states or chained too many rule applications, for
|
|
153
|
+
* example because a rule keeps growing the sequence.
|
|
154
|
+
*
|
|
155
|
+
* @since @next
|
|
156
|
+
*/
|
|
157
|
+
export class RewriteLimitExceeded extends Data.TaggedError("RewriteLimitExceeded")<{
|
|
158
|
+
readonly route: string;
|
|
159
|
+
readonly limit: "states" | "depth";
|
|
160
|
+
readonly value: number;
|
|
161
|
+
}> {
|
|
162
|
+
override get message() {
|
|
163
|
+
return this.limit === "states"
|
|
164
|
+
? `Optimizing route "${this.route}" explored more than ${this.value} states.`
|
|
165
|
+
: `Optimizing route "${this.route}" chained more than ${this.value} rule applications.`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* More candidate routes exist than the resolver enumerates.
|
|
171
|
+
*
|
|
172
|
+
* @since @next
|
|
173
|
+
*/
|
|
174
|
+
export class TooManyRoutes extends Data.TaggedError("TooManyRoutes")<{
|
|
175
|
+
readonly from: string;
|
|
176
|
+
readonly to: string;
|
|
177
|
+
readonly limit: number;
|
|
178
|
+
}> {
|
|
179
|
+
override get message() {
|
|
180
|
+
return `More than ${this.limit} routes connect "${this.from}" and "${this.to}".`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** @since @next */
|
|
185
|
+
export type RewriteError = RewriteCycle | ConflictingRewrites | RewriteLimitExceeded;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Why a plan could not be resolved. `UnsupportedRoute` lists the reachable versions, the
|
|
189
|
+
* closest ones by release ancestry, and blockers. `AmbiguousRoute` lists the candidate
|
|
190
|
+
* routes: pass one as `route`, or choose a `policy`.
|
|
191
|
+
*
|
|
192
|
+
* @since @next
|
|
193
|
+
*/
|
|
194
|
+
export type ResolveError =
|
|
195
|
+
| InvalidHistory
|
|
196
|
+
| UnknownVersion
|
|
197
|
+
| UnsupportedRoute
|
|
198
|
+
| AmbiguousRoute
|
|
199
|
+
| UnknownRoute
|
|
200
|
+
| TooManyRoutes
|
|
201
|
+
| RewriteError;
|