@bjornpagen/bumbledb-log 1.3.0 → 1.3.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.
Files changed (122) hide show
  1. package/README.md +152 -63
  2. package/dist/admin.d.ts +1 -1
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +13 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/codes.d.ts +1 -1
  7. package/dist/codes.d.ts.map +1 -1
  8. package/dist/codes.js +1 -8
  9. package/dist/codes.js.map +1 -1
  10. package/dist/errors.d.ts +7 -21
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.js +11 -45
  13. package/dist/errors.js.map +1 -1
  14. package/dist/identity.d.ts +0 -8
  15. package/dist/identity.d.ts.map +1 -1
  16. package/dist/identity.js +0 -5
  17. package/dist/identity.js.map +1 -1
  18. package/dist/index.d.ts +5 -3
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/machine.d.ts +4 -28
  23. package/dist/machine.d.ts.map +1 -1
  24. package/dist/machine.js +183 -246
  25. package/dist/machine.js.map +1 -1
  26. package/dist/native.d.ts +59 -154
  27. package/dist/native.d.ts.map +1 -1
  28. package/dist/native.js.map +1 -1
  29. package/dist/options.d.ts +2 -11
  30. package/dist/options.d.ts.map +1 -1
  31. package/dist/outcome.d.ts +1 -85
  32. package/dist/outcome.d.ts.map +1 -1
  33. package/dist/schema-files.d.ts +16 -0
  34. package/dist/schema-files.d.ts.map +1 -0
  35. package/dist/schema-files.js +77 -0
  36. package/dist/schema-files.js.map +1 -0
  37. package/dist/schema.d.ts +6 -9
  38. package/dist/schema.d.ts.map +1 -1
  39. package/dist/schema.js +8 -8
  40. package/dist/schema.js.map +1 -1
  41. package/dist/transition.d.ts +75 -0
  42. package/dist/transition.d.ts.map +1 -0
  43. package/dist/transition.js +3 -0
  44. package/dist/transition.js.map +1 -0
  45. package/pack-provenance.json +4 -4
  46. package/package.json +4 -8
  47. package/dist/migration-ops.d.ts +0 -20
  48. package/dist/migration-ops.d.ts.map +0 -1
  49. package/dist/migration-ops.js +0 -7
  50. package/dist/migration-ops.js.map +0 -1
  51. package/dist/migrations/bin.d.ts.map +0 -1
  52. package/dist/migrations/bin.js +0 -30
  53. package/dist/migrations/bin.js.map +0 -1
  54. package/dist/migrations/canonical.d.ts +0 -40
  55. package/dist/migrations/canonical.d.ts.map +0 -1
  56. package/dist/migrations/canonical.js +0 -165
  57. package/dist/migrations/canonical.js.map +0 -1
  58. package/dist/migrations/cli.d.ts +0 -29
  59. package/dist/migrations/cli.d.ts.map +0 -1
  60. package/dist/migrations/cli.js +0 -124
  61. package/dist/migrations/cli.js.map +0 -1
  62. package/dist/migrations/codec.d.ts +0 -74
  63. package/dist/migrations/codec.d.ts.map +0 -1
  64. package/dist/migrations/codec.js +0 -2
  65. package/dist/migrations/codec.js.map +0 -1
  66. package/dist/migrations/decode.d.ts +0 -16
  67. package/dist/migrations/decode.d.ts.map +0 -1
  68. package/dist/migrations/decode.js +0 -302
  69. package/dist/migrations/decode.js.map +0 -1
  70. package/dist/migrations/diff.d.ts +0 -39
  71. package/dist/migrations/diff.d.ts.map +0 -1
  72. package/dist/migrations/diff.js +0 -385
  73. package/dist/migrations/diff.js.map +0 -1
  74. package/dist/migrations/expr.d.ts +0 -22
  75. package/dist/migrations/expr.d.ts.map +0 -1
  76. package/dist/migrations/expr.js +0 -257
  77. package/dist/migrations/expr.js.map +0 -1
  78. package/dist/migrations/fail.d.ts +0 -22
  79. package/dist/migrations/fail.d.ts.map +0 -1
  80. package/dist/migrations/fail.js +0 -52
  81. package/dist/migrations/fail.js.map +0 -1
  82. package/dist/migrations/fsops.d.ts +0 -37
  83. package/dist/migrations/fsops.d.ts.map +0 -1
  84. package/dist/migrations/fsops.js +0 -222
  85. package/dist/migrations/fsops.js.map +0 -1
  86. package/dist/migrations/generate.d.ts +0 -11
  87. package/dist/migrations/generate.d.ts.map +0 -1
  88. package/dist/migrations/generate.js +0 -455
  89. package/dist/migrations/generate.js.map +0 -1
  90. package/dist/migrations/index.d.ts +0 -23
  91. package/dist/migrations/index.d.ts.map +0 -1
  92. package/dist/migrations/index.js +0 -6
  93. package/dist/migrations/index.js.map +0 -1
  94. package/dist/migrations/intent.d.ts +0 -86
  95. package/dist/migrations/intent.d.ts.map +0 -1
  96. package/dist/migrations/intent.js +0 -97
  97. package/dist/migrations/intent.js.map +0 -1
  98. package/dist/migrations/lock.d.ts +0 -27
  99. package/dist/migrations/lock.d.ts.map +0 -1
  100. package/dist/migrations/lock.js +0 -14
  101. package/dist/migrations/lock.js.map +0 -1
  102. package/dist/migrations/native.d.ts +0 -26
  103. package/dist/migrations/native.d.ts.map +0 -1
  104. package/dist/migrations/native.js +0 -124
  105. package/dist/migrations/native.js.map +0 -1
  106. package/dist/migrations/repo.d.ts +0 -38
  107. package/dist/migrations/repo.d.ts.map +0 -1
  108. package/dist/migrations/repo.js +0 -191
  109. package/dist/migrations/repo.js.map +0 -1
  110. package/dist/migrations/theory.d.ts +0 -21
  111. package/dist/migrations/theory.d.ts.map +0 -1
  112. package/dist/migrations/theory.js +0 -107
  113. package/dist/migrations/theory.js.map +0 -1
  114. package/dist/migrations/types.d.ts +0 -251
  115. package/dist/migrations/types.d.ts.map +0 -1
  116. package/dist/migrations/types.js +0 -2
  117. package/dist/migrations/types.js.map +0 -1
  118. package/dist/migrations/workflow.d.ts +0 -11
  119. package/dist/migrations/workflow.d.ts.map +0 -1
  120. package/dist/migrations/workflow.js +0 -14
  121. package/dist/migrations/workflow.js.map +0 -1
  122. /package/dist/{migrations/bin.d.ts → bin.d.ts} +0 -0
@@ -1,107 +0,0 @@
1
- const MAX_RELATIONS = 4096;
2
- const MAX_FIELDS = 4096;
3
- const MAX_NAME = 255;
4
- function refuse(detail) {
5
- return { ok: false, detail };
6
- }
7
- function isRecord(value) {
8
- return typeof value === "object" && value !== null && !Array.isArray(value);
9
- }
10
- function boundedName(value) {
11
- return typeof value === "string" && value.length > 0 && value.length <= MAX_NAME && !value.includes("\0")
12
- ? value
13
- : null;
14
- }
15
- /** Canonical type spelling for exact comparison and messages. */
16
- function typeKey(value) {
17
- if (typeof value === "string") {
18
- return ["bool", "u64", "i64", "f64", "string", "uuid"].includes(value) ? JSON.stringify(value) : null;
19
- }
20
- if (!isRecord(value)) {
21
- return null;
22
- }
23
- const keys = Object.keys(value);
24
- if (keys.length !== 1) {
25
- return null;
26
- }
27
- if (keys[0] === "fixedBytes" && typeof value.fixedBytes === "number" && Number.isSafeInteger(value.fixedBytes)) {
28
- return `{"fixedBytes":${value.fixedBytes}}`;
29
- }
30
- if (keys[0] === "interval" && typeof value.interval === "string" && ["u64", "i64", "f64"].includes(value.interval)) {
31
- return `{"interval":"${value.interval}"}`;
32
- }
33
- if (keys[0] === "fixedInterval" && isRecord(value.fixedInterval)) {
34
- const element = value.fixedInterval.element;
35
- const width = value.fixedInterval.width;
36
- if (typeof element === "string" && ["u64", "i64"].includes(element) && typeof width === "string") {
37
- return `{"fixedInterval":{"element":"${element}","width":"${width}"}}`;
38
- }
39
- }
40
- return null;
41
- }
42
- /** Parse one snapshot text (already size-bounded by the file reader). */
43
- export function parseTheory(raw) {
44
- let tree;
45
- try {
46
- tree = JSON.parse(raw);
47
- }
48
- catch {
49
- return refuse("snapshot is not JSON");
50
- }
51
- if (!isRecord(tree) || !Array.isArray(tree.relations) || !Array.isArray(tree.statements)) {
52
- return refuse("snapshot must be the {relations, statements} theory grammar");
53
- }
54
- if (tree.relations.length > MAX_RELATIONS) {
55
- return refuse(`snapshot exceeds ${MAX_RELATIONS} relations`);
56
- }
57
- const relations = [];
58
- const seen = new Set();
59
- for (const entry of tree.relations) {
60
- if (!isRecord(entry)) {
61
- return refuse("relation entry");
62
- }
63
- const name = boundedName(entry.name);
64
- if (name === null) {
65
- return refuse("relation name");
66
- }
67
- if (seen.has(name)) {
68
- return refuse(`duplicate relation ${name}`);
69
- }
70
- seen.add(name);
71
- if (!Array.isArray(entry.fields) || entry.fields.length > MAX_FIELDS) {
72
- return refuse(`relation ${name} fields`);
73
- }
74
- const fields = [];
75
- const fieldNames = new Set();
76
- for (const field of entry.fields) {
77
- if (!isRecord(field)) {
78
- return refuse(`relation ${name} field entry`);
79
- }
80
- const fieldName = boundedName(field.name);
81
- if (fieldName === null || fieldNames.has(fieldName)) {
82
- return refuse(`relation ${name} field name`);
83
- }
84
- fieldNames.add(fieldName);
85
- const key = typeKey(field.type);
86
- if (key === null) {
87
- return refuse(`relation ${name} field ${fieldName} type`);
88
- }
89
- if (field.generation !== undefined) {
90
- return refuse("fresh generation is deleted");
91
- }
92
- fields.push({ name: fieldName, type: key });
93
- }
94
- const extension = entry.extension;
95
- if (extension !== undefined && extension !== null && !Array.isArray(extension)) {
96
- return refuse(`relation ${name} extension`);
97
- }
98
- relations.push({
99
- name,
100
- fields,
101
- closed: Array.isArray(extension)
102
- });
103
- }
104
- return { ok: true, snapshot: { relations } };
105
- }
106
- export const EMPTY_THEORY = Object.freeze({ relations: Object.freeze([]) });
107
- //# sourceMappingURL=theory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theory.js","sourceRoot":"","sources":["../../src/migrations/theory.ts"],"names":[],"mappings":"AAWA,MAAM,aAAa,GAAG,IAAI,CAAA;AAC1B,MAAM,UAAU,GAAG,IAAI,CAAA;AACvB,MAAM,QAAQ,GAAG,GAAG,CAAA;AAMpB,SAAS,MAAM,CAAC,MAAc;IAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC7B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5E,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAA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I,GAAG,KAAK,IAAI,EAAE,CAAC;gBAClB,OAAO,MAAM,CAAC,YAAY,IAAI,UAAU,SAAS,OAAO,CAAC,CAAA;YAC1D,CAAC;YACD,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBACpC,OAAO,MAAM,CAAC,6BAA6B,CAAC,CAAA;YAC7C,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QAC5C,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;QACjC,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAChF,OAAO,MAAM,CAAC,YAAY,IAAI,YAAY,CAAC,CAAA;QAC5C,CAAC;QACD,SAAS,CAAC,IAAI,CAAC;YACd,IAAI;YACJ,MAAM;YACN,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;SAChC,CAAC,CAAA;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,EAAE,CAAA;AAC7C,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAmB,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA"}
@@ -1,251 +0,0 @@
1
- /**
2
- * C11 data model — the generated repo-local migration artifacts,
3
- * mirroring the native codec exactly
4
- * (`crates/bumbledb-log/src/migration/{plan,manifest}.rs` and
5
- * `crates/bumbledb-log/src/schema_file.rs`, P09). Everything here is plain
6
- * readonly data: a plan file is inert canonical JSON, never executable
7
- * TypeScript, and a well-shaped object alone is not a checked plan — the
8
- * native migration codec is the one validation, rendering and digest
9
- * authority. Every 32-byte digest is 64 lowercase hex computed natively;
10
- * TypeScript never reimplements the canonical framing, hashing or scalar
11
- * arithmetic.
12
- *
13
- * Human labels versus digests: `id` (`0001-note-pinned`) is a stable human
14
- * label (1..=64 of `[a-z0-9-]`, unique per manifest) for review and file
15
- * names. It never participates in identity; `planDigest`/`prefixDigest`/
16
- * `planSetDigest` are the commitments, and a changed plan under a reused
17
- * label is drift.
18
- */
19
- import type { Schema, SchemaRelations } from "@bjornpagen/bumbledb";
20
- import type { DatabaseIdentity, DecisionDigest, OperationId, PlanSetDigest } from "../identity.js";
21
- import type { MigrationIntent } from "./intent.js";
22
- /**
23
- * One canonical value cell (`migration::json` grammar, shared by plans and
24
- * schema snapshots): a single-arm object. Integers are decimal strings;
25
- * `$f64` is the canonical bit image (canonical quiet NaN, canonical +0) as
26
- * 16 lowercase hex digits; `uuid` is canonical UUID; bytes are lowercase
27
- * hex; intervals are `[start, end]` pairs in their element spelling.
28
- */
29
- export type PlanValue = {
30
- readonly bool: boolean;
31
- } | {
32
- readonly u64: string;
33
- } | {
34
- readonly i64: string;
35
- } | {
36
- readonly $f64: string;
37
- } | {
38
- readonly uuid: string;
39
- } | {
40
- readonly string: string;
41
- } | {
42
- readonly fixedBytes: string;
43
- } | {
44
- readonly intervalU64: readonly [string, string];
45
- } | {
46
- readonly intervalI64: readonly [string, string];
47
- } | {
48
- readonly intervalF64: readonly [string, string];
49
- };
50
- /**
51
- * The generated expression fragment: exactly the core `ScalarExpr` roster
52
- * with the migration context's named SOURCE-field reference in the variable
53
- * position. Source-field arithmetic may stay unresolved until native compile
54
- * binds it. The core `ScalarEvaluator` is the one meaning. No closure,
55
- * module path or opaque "run this code" node exists.
56
- */
57
- export type PlanExpression = {
58
- readonly kind: "measure";
59
- readonly expr: PlanExpression;
60
- } | {
61
- readonly kind: "mulDiv";
62
- readonly a: PlanExpression;
63
- readonly b: PlanExpression;
64
- readonly divisor: PlanExpression;
65
- readonly rounding: "towardZero" | "nearestTiesAwayFromZero" | "nearestTiesToEven";
66
- } | {
67
- readonly kind: "field";
68
- readonly name: string;
69
- } | {
70
- readonly kind: "literal";
71
- readonly value: PlanValue;
72
- } | {
73
- readonly kind: "negate";
74
- readonly expr: PlanExpression;
75
- } | {
76
- readonly kind: "isNaN";
77
- readonly expr: PlanExpression;
78
- } | {
79
- readonly kind: "isFinite";
80
- readonly expr: PlanExpression;
81
- } | {
82
- readonly kind: "add" | "subtract" | "multiply" | "divide";
83
- readonly left: PlanExpression;
84
- readonly right: PlanExpression;
85
- } | {
86
- readonly kind: "cast";
87
- readonly cast: "toF64" | "toF64Exact" | "toI64Exact" | "toU64Exact";
88
- readonly expr: PlanExpression;
89
- };
90
- export interface PlanFieldMap {
91
- readonly target: string;
92
- readonly expression: PlanExpression;
93
- }
94
- /**
95
- * The finite operation roster. Coverage is total over ORDINARY relations
96
- * (closed relations are sealed schema axioms, unnameable by data ops):
97
- * every ordinary source relation appears exactly once as `map-relation.
98
- * source` or `drop-relation.source`; every ordinary target relation exactly
99
- * once as `map-relation.target` or `empty-relation.target`. Seeds follow
100
- * their producing operation; `validate-schema` is the required final
101
- * operation and must name `toSchemaId`.
102
- */
103
- export type PlanOperation = {
104
- readonly kind: "map-relation";
105
- readonly source: string;
106
- readonly target: string;
107
- readonly fields: readonly PlanFieldMap[];
108
- } | {
109
- readonly kind: "empty-relation";
110
- readonly target: string;
111
- } | {
112
- readonly kind: "drop-relation";
113
- readonly source: string;
114
- } | {
115
- readonly kind: "seed";
116
- readonly target: string;
117
- readonly rows: ReadonlyArray<readonly PlanValue[]>;
118
- } | {
119
- readonly kind: "validate-schema";
120
- readonly schemaId: string;
121
- };
122
- /**
123
- * One explicit data-loss acknowledgement: a dropped source relation
124
- * (`field` absent) or a source field no expression references. Every actual
125
- * loss needs exactly one acknowledgement and stale acknowledgements refuse
126
- * — both directions are re-judged natively.
127
- */
128
- export interface PlanLoss {
129
- readonly relation: string;
130
- readonly field?: string;
131
- }
132
- /** One generated `NNNN-label.plan.json`. Immutable once recorded. */
133
- export interface MigrationPlan {
134
- readonly planVersion: 1;
135
- /** Decimal manifest index, contiguous from "0". */
136
- readonly sequence: string;
137
- /** The stable human label, e.g. `0001-note-pinned`. */
138
- readonly id: string;
139
- readonly fromSchemaId: string;
140
- readonly toSchemaId: string;
141
- readonly operations: readonly PlanOperation[];
142
- readonly destructive: readonly PlanLoss[];
143
- }
144
- /** One recorded chain identity inside `manifest.json`. */
145
- export interface ManifestEntry {
146
- readonly sequence: string;
147
- readonly id: string;
148
- readonly fromSchemaId: string;
149
- readonly toSchemaId: string;
150
- readonly planDigest: string;
151
- readonly prefixDigest: string;
152
- }
153
- /**
154
- * The ordered chain of recorded identities. Prefix hashing is acyclic,
155
- * domain-separated and NATIVE: `basePrefixDigest` commits the manifest/plan
156
- * codec versions and the empty-base SchemaId; each entry's `prefixDigest`
157
- * commits the previous prefix plus the canonical entry frame excluding its
158
- * own prefix field. Verification is recomputation, never trust in text.
159
- */
160
- export interface MigrationManifest {
161
- readonly manifestVersion: 1;
162
- readonly planVersion: 1;
163
- readonly baseSchemaId: string;
164
- readonly basePrefixDigest: string;
165
- readonly entries: readonly ManifestEntry[];
166
- }
167
- /**
168
- * The app's small deployed expectation (chapter 33 `runtime-contract.json`).
169
- * `schemaId`/`appliedPrefixDigest` are exactly P08's `RuntimeExpectation`
170
- * fields; `steps` is the decimal count of recorded manifest entries.
171
- */
172
- export interface RuntimeContract {
173
- readonly contractVersion: 1;
174
- readonly schemaId: string;
175
- readonly appliedPrefixDigest: string;
176
- readonly steps: string;
177
- }
178
- /** What the generated static `index.ts` exports: data imports only. */
179
- export interface GeneratedMigrations {
180
- readonly manifest: MigrationManifest;
181
- readonly plans: readonly MigrationPlan[];
182
- /**
183
- * Canonical `schema_file::render` texts: empty-base first, then each
184
- * recorded plan target — exactly `entries.length + 1` rows. Mandatory
185
- * for native chain compile (C8/D20); empty source is not a shortcut.
186
- */
187
- readonly snapshots: readonly string[];
188
- }
189
- export interface TheoryField {
190
- readonly name: string;
191
- /** Canonical JSON spelling of the field type, for exact comparison. */
192
- readonly type: string;
193
- }
194
- export interface TheoryRelation {
195
- readonly name: string;
196
- readonly fields: readonly TheoryField[];
197
- readonly closed: boolean;
198
- }
199
- export interface TheorySnapshot {
200
- readonly relations: readonly TheoryRelation[];
201
- }
202
- export interface MigrationRepository {
203
- /** The checked-in migrations directory, e.g. `bumbledb/migrations`. */
204
- readonly directory: string;
205
- /**
206
- * Where the runtime contract is written; default
207
- * `<directory>/runtime-contract.json`.
208
- */
209
- readonly contract?: string;
210
- }
211
- export interface GenerateOptions<Rels extends SchemaRelations> {
212
- readonly schema: Schema<Rels>;
213
- readonly intent?: MigrationIntent<Rels>;
214
- /**
215
- * Stable human label suffix for the new plan (`[a-z0-9-]`; the full id
216
- * becomes `NNNN-<label>` and must stay within 64). When absent a
217
- * deterministic label is derived from the diff.
218
- */
219
- readonly label?: string;
220
- readonly repository: MigrationRepository;
221
- }
222
- export type CheckOptions<Rels extends SchemaRelations> = Omit<GenerateOptions<Rels>, "label">;
223
- export interface GenerationReport {
224
- readonly status: "unchanged" | "generated";
225
- readonly planId: string | null;
226
- readonly contract: RuntimeContract;
227
- /** Repository-relative paths written by this run (empty when unchanged). */
228
- readonly files: readonly string[];
229
- /**
230
- * Repository-relative interrupted-generation leftovers this run removed
231
- * (unrecorded next-sequence drafts only; recorded history is never touched).
232
- */
233
- readonly removed: readonly string[];
234
- }
235
- export interface CheckReport {
236
- readonly status: "clean" | "generation-required";
237
- readonly detail: string;
238
- readonly contract: RuntimeContract;
239
- }
240
- /**
241
- * The activation reference returned inside `ready-to-switch` (P09
242
- * `ActivationRef`): durable in the target control before any activation
243
- * attempt, passed back verbatim to `activateMigration`/`abortMigration`.
244
- */
245
- export interface ActivationRef {
246
- readonly operation: OperationId;
247
- readonly planSetDigest: PlanSetDigest;
248
- readonly target: DatabaseIdentity;
249
- readonly targetGenesis: DecisionDigest;
250
- }
251
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRo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aAAa;IAC7B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAA;IAC/B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAA;CACtC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/migrations/types.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- /**
2
- * The one production binding of the generator: `makeGenerator` over the
3
- * native `MigrationCodec`. The CLI (`#migrations/cli.ts`) and the direct API
4
- * (`#migrations/index.ts`) both import THESE values, so their outcomes are
5
- * identical by construction (TS-MIG-10) — there is no second generator
6
- * instance, codec or workflow.
7
- */
8
- import { makeGenerator } from "./generate.js";
9
- export declare const generateMigrations: ReturnType<typeof makeGenerator>["generateMigrations"];
10
- export declare const checkMigrations: ReturnType<typeof makeGenerator>["checkMigrations"];
11
- //# sourceMappingURL=workflow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/migrations/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAMvD,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,oBAAoB,CAAiC,CAAA;AACvH,eAAO,MAAM,eAAe,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,iBAAiB,CAA8B,CAAA"}
@@ -1,14 +0,0 @@
1
- /**
2
- * The one production binding of the generator: `makeGenerator` over the
3
- * native `MigrationCodec`. The CLI (`#migrations/cli.ts`) and the direct API
4
- * (`#migrations/index.ts`) both import THESE values, so their outcomes are
5
- * identical by construction (TS-MIG-10) — there is no second generator
6
- * instance, codec or workflow.
7
- */
8
- import { makeGenerator } from "#migrations/generate.ts";
9
- import { productionExclusion } from "#migrations/lock.ts";
10
- import { productionCodec } from "#migrations/native.ts";
11
- const production = makeGenerator(productionCodec, productionExclusion);
12
- export const generateMigrations = production.generateMigrations;
13
- export const checkMigrations = production.checkMigrations;
14
- //# sourceMappingURL=workflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/migrations/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,UAAU,GAAG,aAAa,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,kBAAkB,GAA2D,UAAU,CAAC,kBAAkB,CAAA;AACvH,MAAM,CAAC,MAAM,eAAe,GAAwD,UAAU,CAAC,eAAe,CAAA"}
File without changes