@atscript/db 0.1.161 → 0.1.163

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 (65) hide show
  1. package/dist/agg.cjs +1 -1
  2. package/dist/agg.d.cts +1 -1
  3. package/dist/agg.d.mts +1 -1
  4. package/dist/agg.mjs +1 -1
  5. package/dist/{aggregate-fns-B_sgl4mB.mjs → aggregate-fns-DsS9UQVB.mjs} +1 -1
  6. package/dist/{aggregate-fns-DFtKAv7Q.cjs → aggregate-fns-DupYzFD7.cjs} +1 -1
  7. package/dist/{buckets-B4T_alUe.d.cts → buckets-B8UOod-v.d.cts} +488 -57
  8. package/dist/{buckets-8mG67Mtw.d.mts → buckets-CHyspjYP.d.mts} +488 -57
  9. package/dist/{column-diff-DpeUbhEI.cjs → column-diff-BIGX3sRH.cjs} +853 -232
  10. package/dist/{column-diff-DR1glykD.mjs → column-diff-BfNIlMwX.mjs} +836 -233
  11. package/dist/{validator-B3xlbrWf.d.cts → db-error-B_DRL1E9.d.cts} +18 -89
  12. package/dist/{validator-B3xlbrWf.d.mts → db-error-B_DRL1E9.d.mts} +18 -89
  13. package/dist/{db-error-JcfJqqpk.cjs → db-error-DmF1_xrz.cjs} +13 -0
  14. package/dist/{db-error-eSsQX7rt.mjs → db-error-hraC12B9.mjs} +8 -1
  15. package/dist/{db-validator-plugin-BWy60OvG.d.cts → db-validator-plugin-wRqMYNBI.d.cts} +6 -0
  16. package/dist/{db-validator-plugin-BWy60OvG.d.mts → db-validator-plugin-wRqMYNBI.d.mts} +6 -0
  17. package/dist/{fk-diff-5gX42hBt.d.mts → fk-diff-BNGawZi9.d.cts} +34 -10
  18. package/dist/{fk-diff-BWdQ7kRZ.d.cts → fk-diff-rj9N2QLw.d.mts} +34 -10
  19. package/dist/index.cjs +15 -11
  20. package/dist/index.d.cts +24 -21
  21. package/dist/index.d.mts +24 -21
  22. package/dist/index.mjs +10 -12
  23. package/dist/{nested-writer-BOj_c_lI.mjs → nested-writer-ClUX0DB0.mjs} +16 -22
  24. package/dist/{nested-writer-Bl1SZS7x.cjs → nested-writer-yCy6wGuN.cjs} +16 -22
  25. package/dist/{object-CtPYTIvy.d.cts → object-Czia_qD4.d.cts} +7 -1
  26. package/dist/{object-CtPYTIvy.d.mts → object-Czia_qD4.d.mts} +7 -1
  27. package/dist/{object-Djg28csK.cjs → object-GjsuPNqo.cjs} +19 -0
  28. package/dist/{object-TkiJQ-Dp.mjs → object-PQ1J8jri.mjs} +14 -1
  29. package/dist/ops.cjs +6 -21
  30. package/dist/ops.mjs +6 -21
  31. package/dist/plugin.cjs +263 -323
  32. package/dist/plugin.mjs +163 -223
  33. package/dist/rel.cjs +2 -2
  34. package/dist/rel.d.cts +3 -3
  35. package/dist/rel.d.mts +3 -3
  36. package/dist/rel.mjs +2 -2
  37. package/dist/{relation-helpers-17_2f5hX.d.mts → relation-helpers-DloMywNs.d.cts} +1 -1
  38. package/dist/{relation-helpers-BLBrLQYi.d.cts → relation-helpers-zwt19E7r.d.mts} +1 -1
  39. package/dist/{relation-loader-DeulLrAw.cjs → relation-loader-DujL_Mh9.cjs} +1 -1
  40. package/dist/{relation-loader-CNBMPfRr.mjs → relation-loader-Qv3LrQ42.mjs} +1 -1
  41. package/dist/{search-fields-CT_UZ9fg.cjs → search-fields-B49-RCWd.cjs} +65 -1
  42. package/dist/{search-fields-CE8cmj9X.mjs → search-fields-BPNsxrCk.mjs} +48 -2
  43. package/dist/search-fields-CHqqcC3W.d.cts +30 -0
  44. package/dist/search-fields-CHqqcC3W.d.mts +30 -0
  45. package/dist/server-stamped-B6XbUQ4p.cjs +33 -0
  46. package/dist/server-stamped-BoP56K9M.mjs +22 -0
  47. package/dist/shared.cjs +42 -26
  48. package/dist/shared.d.cts +98 -4
  49. package/dist/shared.d.mts +98 -4
  50. package/dist/shared.mjs +4 -2
  51. package/dist/sync.cjs +228 -65
  52. package/dist/sync.d.cts +41 -5
  53. package/dist/sync.d.mts +41 -5
  54. package/dist/sync.mjs +228 -66
  55. package/dist/{validator-B4YDLUkj.cjs → validator-DK9Ijpo7.cjs} +3 -2
  56. package/dist/validator-DX97RzC2.d.cts +108 -0
  57. package/dist/validator-DX97RzC2.d.mts +108 -0
  58. package/dist/{validator-B3fPJjS1.mjs → validator-DuDWsIdQ.mjs} +3 -2
  59. package/dist/validator.cjs +6 -3
  60. package/dist/validator.d.cts +5 -4
  61. package/dist/validator.d.mts +5 -4
  62. package/dist/validator.mjs +5 -4
  63. package/dist/{validation-utils-BGjqc2jU.mjs → view-validation-BcgDq7M9.mjs} +364 -20
  64. package/dist/{validation-utils-CtLNlBtB.cjs → view-validation-BiDLCYMw.cjs} +452 -18
  65. package/package.json +6 -6
package/dist/sync.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { At as TPrimaryKeyChange, Jn as TGenericLogger, Lt as TTableOptionDiff, U as TDbFieldMeta, et as TDbObjectKind, gt as TEnsureTableOptions, jt as TReferencingForeignKey, mt as TDerivedChangeReason, nn as DbSpace, vt as TExistingForeignKey, yt as TExistingTableOption } from "./buckets-B4T_alUe.cjs";
2
- import { _ as computeTableSnapshot, a as hasForeignKeyChanges, b as snapshotToExistingTableOptions, c as TFieldSnapshot, d as TViewColumnSnapshot, f as TViewJoinSnapshot, g as computeTableHash, h as computeSchemaHash, i as fkKey, l as TForeignKeySnapshot, m as canonicalizeQueryNode, n as computeForeignKeyDiff, o as computeColumnDiff, p as TViewSnapshot, t as TForeignKeyDiff, u as TTableSnapshot, v as computeViewSnapshot, y as snapshotToExistingColumns } from "./fk-diff-BWdQ7kRZ.cjs";
1
+ import { Ct as TEnsureTableOptions, Et as TExistingTableOption, G as TDbFieldMeta, Pt as TIndexChange, Tt as TExistingForeignKey, Vt as TReferencingForeignKey, at as TDbObjectKind, cr as TGenericLogger, gn as DbSpace, qt as TTableOptionDiff, xt as TDerivedChangeReason, zt as TPrimaryKeyChange } from "./buckets-B8UOod-v.cjs";
2
+ import { S as snapshotToExistingTableOptions, _ as computeSchemaHash, a as hasForeignKeyChanges, b as computeViewSnapshot, d as TForeignKeySnapshot, f as TTableSnapshot, g as canonicalizeQueryNode, h as TViewSnapshot, i as fkKey, l as sameDefaultValue, m as TViewJoinSnapshot, n as computeForeignKeyDiff, o as TColumnDiffOptions, p as TViewColumnSnapshot, s as computeColumnDiff, t as TForeignKeyDiff, u as TFieldSnapshot, v as computeTableHash, x as snapshotToExistingColumns, y as computeTableSnapshot } from "./fk-diff-BNGawZi9.cjs";
3
3
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
4
4
 
5
5
  //#region src/schema/sync-entry.d.ts
@@ -150,6 +150,23 @@ interface TSyncEntryInit {
150
150
  * @since 0.1.141
151
151
  */
152
152
  cascadeFrom?: string[];
153
+ /**
154
+ * `true` on a managed view whose own definition changed since the last
155
+ * sync — the reason it is dropped and recreated. Printed as
156
+ * `· definition changed`.
157
+ * @since 0.1.162
158
+ */
159
+ definitionChanged?: boolean;
160
+ /**
161
+ * Managed indexes created, dropped or rebuilt (definition drift). On a
162
+ * plan entry: what the run's index sync would do to the live table as it
163
+ * is now (before the entry's column changes; not planned for a table the
164
+ * run creates, recreates or renames). On a run entry: what it did — not
165
+ * reported for a created or recreated table. Either marks the entry
166
+ * `alter`.
167
+ * @since 0.1.162
168
+ */
169
+ indexChanges?: TIndexChange[];
153
170
  }
154
171
  declare class SyncEntry {
155
172
  readonly name: string;
@@ -223,6 +240,10 @@ declare class SyncEntry {
223
240
  readonly refused: boolean;
224
241
  /** @since 0.1.141 — see {@link TSyncEntryInit.cascadeFrom}. */
225
242
  readonly cascadeFrom: string[];
243
+ /** @since 0.1.162 — see {@link TSyncEntryInit.definitionChanged}. */
244
+ readonly definitionChanged: boolean;
245
+ /** @since 0.1.162 — see {@link TSyncEntryInit.indexChanges}. */
246
+ readonly indexChanges: TIndexChange[];
226
247
  constructor(init: TSyncEntryInit);
227
248
  /**
228
249
  * The init object this entry was built from — lets callers derive a
@@ -259,8 +280,9 @@ declare class SyncEntry {
259
280
  /** `! PK (id) → (code) — rebuild (table is empty)` / `— rebuild (rows satisfy the new key)` / `— skipped (safe mode)` */
260
281
  private printPkChange;
261
282
  /**
262
- * `! col: t1 → t2 — drop` (plan), or `! type col (t1 → t2) — skipped (safe
263
- * mode)` in plan and result when the `'drop'` recreate was skipped.
283
+ * `! col: t1 → t2 — drop` (plan), `~ col: t1 → t2 — type changed` (result),
284
+ * or `! type col (t1 → t2) — skipped (safe mode)` in plan and result when
285
+ * the `'drop'` recreate was skipped.
264
286
  */
265
287
  private printTypeChanges;
266
288
  /**
@@ -278,6 +300,12 @@ declare class SyncEntry {
278
300
  * change. Both: `! option k: a → b — skipped (safe mode)` when pending.
279
301
  */
280
302
  private printOptionChanges;
303
+ /** `+ FK(a) → t — add` / `- … — remove` / `~ … — details` (plan); `added` / `removed` (result). */
304
+ private printForeignKeys;
305
+ /** `+ index name — add` / `- … — drop` / `~ … — rebuild` (plan); `added` / `dropped` / `rebuilt` (result). */
306
+ private printIndexChanges;
307
+ /** `· definition changed` — why a managed view is recreated. */
308
+ private printDefinitionChanged;
281
309
  /** `· after: a, b` (plan only — the executor already runs in this order). */
282
310
  private printDependsOn;
283
311
  /** `· upstream view "x" recreated` — why an unchanged view is recreated. */
@@ -423,6 +451,14 @@ declare class SchemaSync {
423
451
  * `safe` — safe mode skips the key rebuild, so its plan rule does not apply.
424
452
  */
425
453
  private discoverTable;
454
+ /**
455
+ * Folds the index / foreign-key work on each live table as it is now
456
+ * (`planIndexes` / `planForeignKeys`) into its plan entry. Read only when
457
+ * plan entries are reported (`plan()`, a refused run) — a run reports what
458
+ * `syncIndexes` / `syncForeignKeys` did.
459
+ */
460
+ private planLiveWork;
461
+ private planTableLiveWork;
426
462
  /**
427
463
  * Pure validation over the discovery facts. Every refusal is a change that
428
464
  * no order of DDL can apply safely; the messages are user-facing.
@@ -566,4 +602,4 @@ declare function syncSchema(space: DbSpace, types: readonly TAtscriptAnnotatedTy
566
602
  */
567
603
  declare function planSchema(space: DbSpace, types: readonly TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
568
604
  //#endregion
569
- export { SchemaSync, SyncEntry, type TDbObjectKind, type TDependencyEdge, type TEnsureTableOptions, type TExistingForeignKey, type TFieldSnapshot, type TForeignKeyDiff, type TForeignKeySnapshot, type TPrimaryKeyChange, type TReferencingForeignKey, type TSyncColors, type TSyncDerivedChange, type TSyncEntryInit, type TSyncEntryStatus, type TSyncOptions, type TSyncPlan, type TSyncResult, type TSyncSkippedWork, type TTableSnapshot, type TViewColumnSnapshot, type TViewJoinSnapshot, type TViewSnapshot, canonicalizeQueryNode, computeColumnDiff, computeForeignKeyDiff, computeSchemaHash, computeTableHash, computeTableOptionDiff, computeTableSnapshot, computeViewSnapshot, fkKey, hasForeignKeyChanges, planSchema, readStoredSnapshot, snapshotToExistingColumns, snapshotToExistingTableOptions, syncSchema, topoOrder };
605
+ export { SchemaSync, SyncEntry, type TColumnDiffOptions, type TDbObjectKind, type TDependencyEdge, type TEnsureTableOptions, type TExistingForeignKey, type TFieldSnapshot, type TForeignKeyDiff, type TForeignKeySnapshot, type TPrimaryKeyChange, type TReferencingForeignKey, type TSyncColors, type TSyncDerivedChange, type TSyncEntryInit, type TSyncEntryStatus, type TSyncOptions, type TSyncPlan, type TSyncResult, type TSyncSkippedWork, type TTableSnapshot, type TViewColumnSnapshot, type TViewJoinSnapshot, type TViewSnapshot, canonicalizeQueryNode, computeColumnDiff, computeForeignKeyDiff, computeSchemaHash, computeTableHash, computeTableOptionDiff, computeTableSnapshot, computeViewSnapshot, fkKey, hasForeignKeyChanges, planSchema, readStoredSnapshot, sameDefaultValue, snapshotToExistingColumns, snapshotToExistingTableOptions, syncSchema, topoOrder };
package/dist/sync.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { At as TPrimaryKeyChange, Jn as TGenericLogger, Lt as TTableOptionDiff, U as TDbFieldMeta, et as TDbObjectKind, gt as TEnsureTableOptions, jt as TReferencingForeignKey, mt as TDerivedChangeReason, nn as DbSpace, vt as TExistingForeignKey, yt as TExistingTableOption } from "./buckets-8mG67Mtw.mjs";
2
- import { _ as computeTableSnapshot, a as hasForeignKeyChanges, b as snapshotToExistingTableOptions, c as TFieldSnapshot, d as TViewColumnSnapshot, f as TViewJoinSnapshot, g as computeTableHash, h as computeSchemaHash, i as fkKey, l as TForeignKeySnapshot, m as canonicalizeQueryNode, n as computeForeignKeyDiff, o as computeColumnDiff, p as TViewSnapshot, t as TForeignKeyDiff, u as TTableSnapshot, v as computeViewSnapshot, y as snapshotToExistingColumns } from "./fk-diff-5gX42hBt.mjs";
1
+ import { Ct as TEnsureTableOptions, Et as TExistingTableOption, G as TDbFieldMeta, Pt as TIndexChange, Tt as TExistingForeignKey, Vt as TReferencingForeignKey, at as TDbObjectKind, cr as TGenericLogger, gn as DbSpace, qt as TTableOptionDiff, xt as TDerivedChangeReason, zt as TPrimaryKeyChange } from "./buckets-CHyspjYP.mjs";
2
+ import { S as snapshotToExistingTableOptions, _ as computeSchemaHash, a as hasForeignKeyChanges, b as computeViewSnapshot, d as TForeignKeySnapshot, f as TTableSnapshot, g as canonicalizeQueryNode, h as TViewSnapshot, i as fkKey, l as sameDefaultValue, m as TViewJoinSnapshot, n as computeForeignKeyDiff, o as TColumnDiffOptions, p as TViewColumnSnapshot, s as computeColumnDiff, t as TForeignKeyDiff, u as TFieldSnapshot, v as computeTableHash, x as snapshotToExistingColumns, y as computeTableSnapshot } from "./fk-diff-rj9N2QLw.mjs";
3
3
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
4
4
 
5
5
  //#region src/schema/sync-entry.d.ts
@@ -150,6 +150,23 @@ interface TSyncEntryInit {
150
150
  * @since 0.1.141
151
151
  */
152
152
  cascadeFrom?: string[];
153
+ /**
154
+ * `true` on a managed view whose own definition changed since the last
155
+ * sync — the reason it is dropped and recreated. Printed as
156
+ * `· definition changed`.
157
+ * @since 0.1.162
158
+ */
159
+ definitionChanged?: boolean;
160
+ /**
161
+ * Managed indexes created, dropped or rebuilt (definition drift). On a
162
+ * plan entry: what the run's index sync would do to the live table as it
163
+ * is now (before the entry's column changes; not planned for a table the
164
+ * run creates, recreates or renames). On a run entry: what it did — not
165
+ * reported for a created or recreated table. Either marks the entry
166
+ * `alter`.
167
+ * @since 0.1.162
168
+ */
169
+ indexChanges?: TIndexChange[];
153
170
  }
154
171
  declare class SyncEntry {
155
172
  readonly name: string;
@@ -223,6 +240,10 @@ declare class SyncEntry {
223
240
  readonly refused: boolean;
224
241
  /** @since 0.1.141 — see {@link TSyncEntryInit.cascadeFrom}. */
225
242
  readonly cascadeFrom: string[];
243
+ /** @since 0.1.162 — see {@link TSyncEntryInit.definitionChanged}. */
244
+ readonly definitionChanged: boolean;
245
+ /** @since 0.1.162 — see {@link TSyncEntryInit.indexChanges}. */
246
+ readonly indexChanges: TIndexChange[];
226
247
  constructor(init: TSyncEntryInit);
227
248
  /**
228
249
  * The init object this entry was built from — lets callers derive a
@@ -259,8 +280,9 @@ declare class SyncEntry {
259
280
  /** `! PK (id) → (code) — rebuild (table is empty)` / `— rebuild (rows satisfy the new key)` / `— skipped (safe mode)` */
260
281
  private printPkChange;
261
282
  /**
262
- * `! col: t1 → t2 — drop` (plan), or `! type col (t1 → t2) — skipped (safe
263
- * mode)` in plan and result when the `'drop'` recreate was skipped.
283
+ * `! col: t1 → t2 — drop` (plan), `~ col: t1 → t2 — type changed` (result),
284
+ * or `! type col (t1 → t2) — skipped (safe mode)` in plan and result when
285
+ * the `'drop'` recreate was skipped.
264
286
  */
265
287
  private printTypeChanges;
266
288
  /**
@@ -278,6 +300,12 @@ declare class SyncEntry {
278
300
  * change. Both: `! option k: a → b — skipped (safe mode)` when pending.
279
301
  */
280
302
  private printOptionChanges;
303
+ /** `+ FK(a) → t — add` / `- … — remove` / `~ … — details` (plan); `added` / `removed` (result). */
304
+ private printForeignKeys;
305
+ /** `+ index name — add` / `- … — drop` / `~ … — rebuild` (plan); `added` / `dropped` / `rebuilt` (result). */
306
+ private printIndexChanges;
307
+ /** `· definition changed` — why a managed view is recreated. */
308
+ private printDefinitionChanged;
281
309
  /** `· after: a, b` (plan only — the executor already runs in this order). */
282
310
  private printDependsOn;
283
311
  /** `· upstream view "x" recreated` — why an unchanged view is recreated. */
@@ -423,6 +451,14 @@ declare class SchemaSync {
423
451
  * `safe` — safe mode skips the key rebuild, so its plan rule does not apply.
424
452
  */
425
453
  private discoverTable;
454
+ /**
455
+ * Folds the index / foreign-key work on each live table as it is now
456
+ * (`planIndexes` / `planForeignKeys`) into its plan entry. Read only when
457
+ * plan entries are reported (`plan()`, a refused run) — a run reports what
458
+ * `syncIndexes` / `syncForeignKeys` did.
459
+ */
460
+ private planLiveWork;
461
+ private planTableLiveWork;
426
462
  /**
427
463
  * Pure validation over the discovery facts. Every refusal is a change that
428
464
  * no order of DDL can apply safely; the messages are user-facing.
@@ -566,4 +602,4 @@ declare function syncSchema(space: DbSpace, types: readonly TAtscriptAnnotatedTy
566
602
  */
567
603
  declare function planSchema(space: DbSpace, types: readonly TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
568
604
  //#endregion
569
- export { SchemaSync, SyncEntry, type TDbObjectKind, type TDependencyEdge, type TEnsureTableOptions, type TExistingForeignKey, type TFieldSnapshot, type TForeignKeyDiff, type TForeignKeySnapshot, type TPrimaryKeyChange, type TReferencingForeignKey, type TSyncColors, type TSyncDerivedChange, type TSyncEntryInit, type TSyncEntryStatus, type TSyncOptions, type TSyncPlan, type TSyncResult, type TSyncSkippedWork, type TTableSnapshot, type TViewColumnSnapshot, type TViewJoinSnapshot, type TViewSnapshot, canonicalizeQueryNode, computeColumnDiff, computeForeignKeyDiff, computeSchemaHash, computeTableHash, computeTableOptionDiff, computeTableSnapshot, computeViewSnapshot, fkKey, hasForeignKeyChanges, planSchema, readStoredSnapshot, snapshotToExistingColumns, snapshotToExistingTableOptions, syncSchema, topoOrder };
605
+ export { SchemaSync, SyncEntry, type TColumnDiffOptions, type TDbObjectKind, type TDependencyEdge, type TEnsureTableOptions, type TExistingForeignKey, type TFieldSnapshot, type TForeignKeyDiff, type TForeignKeySnapshot, type TPrimaryKeyChange, type TReferencingForeignKey, type TSyncColors, type TSyncDerivedChange, type TSyncEntryInit, type TSyncEntryStatus, type TSyncOptions, type TSyncPlan, type TSyncResult, type TSyncSkippedWork, type TTableSnapshot, type TViewColumnSnapshot, type TViewJoinSnapshot, type TViewSnapshot, canonicalizeQueryNode, computeColumnDiff, computeForeignKeyDiff, computeSchemaHash, computeTableHash, computeTableOptionDiff, computeTableSnapshot, computeViewSnapshot, fkKey, hasForeignKeyChanges, planSchema, readStoredSnapshot, sameDefaultValue, snapshotToExistingColumns, snapshotToExistingTableOptions, syncSchema, topoOrder };