@owlmeans/postgres-resource 0.1.18-rc.42 → 0.1.18-rc.43

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 (154) hide show
  1. package/README.md +13 -13
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/postgres-resource/SKILL.md +1 -1
  4. package/build/consts.d.ts +9 -0
  5. package/build/consts.d.ts.map +1 -1
  6. package/build/consts.js +6 -0
  7. package/build/consts.js.map +1 -1
  8. package/build/declarations/types.d.ts +12 -0
  9. package/build/declarations/types.d.ts.map +1 -0
  10. package/build/declarations/types.js +2 -0
  11. package/build/declarations/types.js.map +1 -0
  12. package/build/declarations.d.ts +5 -1
  13. package/build/declarations.d.ts.map +1 -1
  14. package/build/declarations.js +25 -15
  15. package/build/declarations.js.map +1 -1
  16. package/build/errors.d.ts +0 -20
  17. package/build/errors.d.ts.map +1 -1
  18. package/build/errors.js +1 -111
  19. package/build/errors.js.map +1 -1
  20. package/build/index.d.ts +3 -0
  21. package/build/index.d.ts.map +1 -1
  22. package/build/index.js +1 -0
  23. package/build/index.js.map +1 -1
  24. package/build/pg-error/types.d.ts +24 -0
  25. package/build/pg-error/types.d.ts.map +1 -0
  26. package/build/pg-error/types.js +2 -0
  27. package/build/pg-error/types.js.map +1 -0
  28. package/build/pg-error.d.ts +4 -0
  29. package/build/pg-error.d.ts.map +1 -0
  30. package/build/pg-error.js +100 -0
  31. package/build/pg-error.js.map +1 -0
  32. package/build/resource.d.ts.map +1 -1
  33. package/build/resource.js +15 -11
  34. package/build/resource.js.map +1 -1
  35. package/build/types.d.ts.map +1 -1
  36. package/build/utils/consts.local.d.ts +2 -0
  37. package/build/utils/consts.local.d.ts.map +1 -1
  38. package/build/utils/consts.local.js +2 -0
  39. package/build/utils/consts.local.js.map +1 -1
  40. package/build/utils/criteria/types.d.ts +31 -0
  41. package/build/utils/criteria/types.d.ts.map +1 -0
  42. package/build/utils/criteria/types.js +2 -0
  43. package/build/utils/criteria/types.js.map +1 -0
  44. package/build/utils/criteria.d.ts +3 -27
  45. package/build/utils/criteria.d.ts.map +1 -1
  46. package/build/utils/criteria.js +86 -104
  47. package/build/utils/criteria.js.map +1 -1
  48. package/build/utils/diff/types.d.ts +40 -0
  49. package/build/utils/diff/types.d.ts.map +1 -0
  50. package/build/utils/diff/types.js +2 -0
  51. package/build/utils/diff/types.js.map +1 -0
  52. package/build/utils/diff.d.ts +5 -35
  53. package/build/utils/diff.d.ts.map +1 -1
  54. package/build/utils/diff.js +320 -344
  55. package/build/utils/diff.js.map +1 -1
  56. package/build/utils/index.d.ts +9 -0
  57. package/build/utils/index.d.ts.map +1 -1
  58. package/build/utils/index.js.map +1 -1
  59. package/build/utils/introspect/types.d.ts +9 -0
  60. package/build/utils/introspect/types.d.ts.map +1 -0
  61. package/build/utils/introspect/types.js +2 -0
  62. package/build/utils/introspect/types.js.map +1 -0
  63. package/build/utils/introspect.d.ts +3 -3
  64. package/build/utils/introspect.d.ts.map +1 -1
  65. package/build/utils/introspect.js +41 -38
  66. package/build/utils/introspect.js.map +1 -1
  67. package/build/utils/life-cycle/types.d.ts +37 -0
  68. package/build/utils/life-cycle/types.d.ts.map +1 -0
  69. package/build/utils/life-cycle/types.js +2 -0
  70. package/build/utils/life-cycle/types.js.map +1 -0
  71. package/build/utils/life-cycle.d.ts +3 -33
  72. package/build/utils/life-cycle.d.ts.map +1 -1
  73. package/build/utils/life-cycle.js +88 -108
  74. package/build/utils/life-cycle.js.map +1 -1
  75. package/build/utils/marshal/types.d.ts +39 -0
  76. package/build/utils/marshal/types.d.ts.map +1 -0
  77. package/build/utils/marshal/types.js +2 -0
  78. package/build/utils/marshal/types.js.map +1 -0
  79. package/build/utils/marshal.d.ts +4 -32
  80. package/build/utils/marshal.d.ts.map +1 -1
  81. package/build/utils/marshal.js +121 -144
  82. package/build/utils/marshal.js.map +1 -1
  83. package/build/utils/migrations.d.ts.map +1 -1
  84. package/build/utils/migrations.js +41 -36
  85. package/build/utils/migrations.js.map +1 -1
  86. package/build/utils/name/types.d.ts +43 -0
  87. package/build/utils/name/types.d.ts.map +1 -0
  88. package/build/utils/name/types.js +2 -0
  89. package/build/utils/name/types.js.map +1 -0
  90. package/build/utils/name.d.ts +6 -35
  91. package/build/utils/name.d.ts.map +1 -1
  92. package/build/utils/name.js +38 -57
  93. package/build/utils/name.js.map +1 -1
  94. package/build/utils/schema/types.d.ts +22 -0
  95. package/build/utils/schema/types.d.ts.map +1 -0
  96. package/build/utils/schema/types.js +2 -0
  97. package/build/utils/schema/types.js.map +1 -0
  98. package/build/utils/schema.d.ts +4 -24
  99. package/build/utils/schema.d.ts.map +1 -1
  100. package/build/utils/schema.js +339 -352
  101. package/build/utils/schema.js.map +1 -1
  102. package/build/utils/sql/types.d.ts +25 -0
  103. package/build/utils/sql/types.d.ts.map +1 -0
  104. package/build/utils/sql/types.js +2 -0
  105. package/build/utils/sql/types.js.map +1 -0
  106. package/build/utils/sql.d.ts +4 -18
  107. package/build/utils/sql.d.ts.map +1 -1
  108. package/build/utils/sql.js +0 -0
  109. package/build/utils/sql.js.map +1 -1
  110. package/build/utils/sync/types.d.ts +25 -0
  111. package/build/utils/sync/types.d.ts.map +1 -0
  112. package/build/utils/sync/types.js +2 -0
  113. package/build/utils/sync/types.js.map +1 -0
  114. package/build/utils/sync.d.ts +2 -19
  115. package/build/utils/sync.d.ts.map +1 -1
  116. package/build/utils/sync.js +64 -71
  117. package/build/utils/sync.js.map +1 -1
  118. package/package.json +7 -7
  119. package/src/consts.ts +7 -0
  120. package/src/declarations/types.ts +12 -0
  121. package/src/declarations.ts +29 -14
  122. package/src/errors.ts +1 -121
  123. package/src/index.ts +3 -0
  124. package/src/pg-error/types.ts +23 -0
  125. package/src/pg-error.ts +114 -0
  126. package/src/resource.ts +17 -13
  127. package/src/types.ts +1 -0
  128. package/src/utils/consts.local.ts +3 -0
  129. package/src/utils/criteria/types.ts +32 -0
  130. package/src/utils/criteria.ts +95 -110
  131. package/src/utils/diff/types.ts +41 -0
  132. package/src/utils/diff.ts +330 -348
  133. package/src/utils/index.ts +9 -0
  134. package/src/utils/introspect/types.ts +9 -0
  135. package/src/utils/introspect.ts +51 -45
  136. package/src/utils/life-cycle/types.ts +41 -0
  137. package/src/utils/life-cycle.ts +102 -121
  138. package/src/utils/marshal/types.ts +40 -0
  139. package/src/utils/marshal.ts +129 -147
  140. package/src/utils/migrations.ts +39 -33
  141. package/src/utils/name/types.ts +44 -0
  142. package/src/utils/name.ts +47 -60
  143. package/src/utils/schema/types.ts +26 -0
  144. package/src/utils/schema.ts +359 -366
  145. package/src/utils/sql/types.ts +25 -0
  146. package/src/utils/sql.ts +0 -0
  147. package/src/utils/sync/types.ts +25 -0
  148. package/src/utils/sync.ts +62 -68
  149. package/tests/criteria.spec.ts +4 -1
  150. package/tests/diff.spec.ts +4 -1
  151. package/tests/errors.spec.ts +4 -3
  152. package/tests/name.spec.ts +5 -3
  153. package/tests/schema.spec.ts +3 -1
  154. package/tests/sql.spec.ts +20 -22
@@ -0,0 +1,40 @@
1
+ import type { BasicContext } from '@owlmeans/context';
2
+ import type { DdlPlan, DdlStatement, LiveTable, TableSpec } from '../../types.js';
3
+ /** Structure reconciliation: the DDL that converges a live table onto its compiled spec. */
4
+ export interface PgDiffHelper {
5
+ /**
6
+ * The form an index or constraint definition is compared in, so the statement this package emits
7
+ * and the text Postgres reports for the object it created compare equal.
8
+ *
9
+ * Postgres deparses what it stores: it leaves an identifier unquoted when it can, casts every
10
+ * literal (`''::text`), casts a `varchar` column inside an expression, wraps a partial predicate and
11
+ * each of its operator expressions in parentheses, and rewrites `x IN (…)` as `x = ANY (ARRAY[…])`.
12
+ * Comparing the raw texts made every boot drop and recreate every declared index and every enum
13
+ * `CHECK`. So both sides lose case, quotes, casts, whitespace and parentheses, and `= ANY (ARRAY[…])`
14
+ * reads as `IN (…)`. What that cannot tell apart — two definitions differing only in how their
15
+ * operators group — is a change to make under a new name.
16
+ */
17
+ canonicalDefinition: (definition: string) => string;
18
+ /**
19
+ * Foreign keys are planned separately from the rest of the table, and applied only once
20
+ * every resource has initialized: a key points at a table another resource owns, and that
21
+ * resource's own `init()` may not have run yet.
22
+ *
23
+ * @throws {PostgresPlaceholderError} when a target can't be resolved.
24
+ */
25
+ planForeignKeys: (spec: TableSpec, context?: BasicContext<any>) => DdlStatement[];
26
+ /**
27
+ * Compare the compiled specification against the live table and produce the ordered DDL
28
+ * that converges one onto the other.
29
+ *
30
+ * Statement order is load bearing:
31
+ * - `DROP COLUMN` is last, because a `USING` cast or a backfill may legitimately read a
32
+ * column that is about to disappear.
33
+ * - A primary key constraint is never dropped: it cascades into every referencing key and
34
+ * can't be undone inside the same transaction once dependents exist.
35
+ *
36
+ * Foreign keys are not part of the plan at all — see {@link PgDiffHelper.planForeignKeys}.
37
+ */
38
+ planSync: (spec: TableSpec, live: LiveTable, additive?: boolean) => DdlPlan;
39
+ }
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/diff/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAEjF,4FAA4F;AAC5F,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;OAWG;IACH,mBAAmB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAA;IACnD;;;;;;OAMG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,KAAK,YAAY,EAAE,CAAA;IACjF;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;CAC5E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/diff/types.ts"],"names":[],"mappings":""}
@@ -1,37 +1,7 @@
1
- import type { BasicContext } from '@owlmeans/context';
2
- import type { DdlPlan, DdlStatement, LiveTable, TableSpec } from '../types.js';
3
- /**
4
- * The form an index or constraint definition is compared in, so the statement this package emits
5
- * and the text Postgres reports for the object it created compare equal.
6
- *
7
- * Postgres deparses what it stores: it leaves an identifier unquoted when it can, casts every
8
- * literal (`''::text`), casts a `varchar` column inside an expression, wraps a partial predicate and
9
- * each of its operator expressions in parentheses, and rewrites `x IN (…)` as `x = ANY (ARRAY[…])`.
10
- * Comparing the raw texts made every boot drop and recreate every declared index and every enum
11
- * `CHECK`. So both sides lose case, quotes, casts, whitespace and parentheses, and `= ANY (ARRAY[…])`
12
- * reads as `IN (…)`. What that cannot tell apart — two definitions differing only in how their
13
- * operators group — is a change to make under a new name.
14
- */
15
- export declare const canonicalDefinition: (definition: string) => string;
16
- /**
17
- * Foreign keys are planned separately from the rest of the table, and applied only once
18
- * every resource has initialized: a key points at a table another resource owns, and that
19
- * resource's own `init()` may not have run yet.
20
- *
21
- * @throws {PostgresPlaceholderError} when a target can't be resolved.
22
- */
23
- export declare const planForeignKeys: (spec: TableSpec, context?: BasicContext<any>) => DdlStatement[];
24
- /**
25
- * Compare the compiled specification against the live table and produce the ordered DDL
26
- * that converges one onto the other.
27
- *
28
- * Statement order is load bearing:
29
- * - `DROP COLUMN` is last, because a `USING` cast or a backfill may legitimately read a
30
- * column that is about to disappear.
31
- * - A primary key constraint is never dropped: it cascades into every referencing key and
32
- * can't be undone inside the same transaction once dependents exist.
33
- *
34
- * Foreign keys are not part of the plan at all — see {@link planForeignKeys}.
35
- */
1
+ import type { DdlPlan, LiveTable, TableSpec } from '../types.js';
2
+ import type { PgDiffHelper } from './diff/types.js';
3
+ export declare const createPgDiffHelper: () => PgDiffHelper;
4
+ export declare const pgDiffHelper: PgDiffHelper;
5
+ /** @deprecated compat:factory-refactor — use `pgDiffHelper.planSync(…)` */
36
6
  export declare const planSync: (spec: TableSpec, live: LiveTable, additive?: boolean) => DdlPlan;
37
7
  //# sourceMappingURL=diff.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/utils/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKrD,OAAO,KAAK,EACE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAiC,SAAS,EACvF,MAAM,aAAa,CAAA;AAkCpB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,eAAgB,MAAM,KAAG,MAKb,CAAA;AAyB5C;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SACpB,SAAS,YAAY,YAAY,CAAC,GAAG,CAAC,KAC3C,YAAY,EAwCb,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,SACb,SAAS,QAAQ,SAAS,aAAY,OAAO,KAClD,OAwPF,CAAA"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/utils/diff.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACE,OAAO,EAAgB,SAAS,EAAiC,SAAS,EACvF,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,eAAO,MAAM,kBAAkB,QAAO,YA8XrC,CAAA;AAED,eAAO,MAAM,YAAY,cAAuB,CAAA;AAEhD,2EAA2E;AAC3E,eAAO,MAAM,QAAQ,SAAU,SAAS,QAAQ,SAAS,aAAY,OAAO,KAAW,OAC1C,CAAA"}