@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
@@ -1,39 +1,10 @@
1
- import type { DbConfig, ResourceRecord } from '@owlmeans/resource';
2
- import type { PostgresResource } from '../types.js';
3
- /**
4
- * Coerce an arbitrary name into a legal Postgres identifier of at most 63 bytes.
5
- *
6
- * Postgres cuts anything past `NAMEDATALEN - 1` off server side and says nothing about
7
- * it, so two names that differ only beyond byte 63 would collapse into one identifier.
8
- * Clamping here instead leaves room for a hash suffix that keeps them apart.
9
- */
1
+ import type { PgNameHelper } from './name/types.js';
2
+ export declare const createPgNameHelper: () => PgNameHelper;
3
+ export declare const pgNameHelper: PgNameHelper;
4
+ /** @deprecated compat:factory-refactor — use `pgNameHelper.pgIdentifier(…)` */
10
5
  export declare const pgIdentifier: (name: string) => string;
11
- /**
12
- * Assert a value is safe to interpolate as an identifier. Postgres can't bind identifiers
13
- * as parameters, so every one of them reaches the server as text — which makes this the
14
- * only thing standing between a config value and injection.
15
- *
16
- * @throws {SyntaxError}
17
- */
18
- export declare const assertSqlIdentifier: (value: string, what?: string) => string;
19
- /** Quote an identifier for emission, doubling any interior quote. */
6
+ /** @deprecated compat:factory-refactor — use `pgNameHelper.quoteIdent(…)` */
20
7
  export declare const quoteIdent: (value: string) => string;
21
- /**
22
- * Quote a string literal. Only ever used for values Postgres refuses to bind — notably
23
- * the password in `CREATE ROLE`.
24
- *
25
- * @throws {SyntaxError} on a NUL byte, which no escaping makes safe.
26
- */
27
- export declare const quoteLiteral: (value: string) => string;
28
- export declare const qualify: (schema: string, table: string) => string;
29
- /**
30
- * Physical table name of a resource: the explicit `name`, else the resource alias,
31
- * prefixed per `DbConfig.resourcePrefix` and sanitized.
32
- */
33
- export declare const pgTableName: (config: DbConfig, resource: PostgresResource<ResourceRecord>) => string;
34
- /**
35
- * Derive a pair of int32s for `pg_advisory_lock` from a qualified table name, so every
36
- * replica booting against the same table serializes on the same key.
37
- */
8
+ /** @deprecated compat:factory-refactor — use `pgNameHelper.advisoryKey(…)` */
38
9
  export declare const advisoryKey: (qualified: string) => [number, number];
39
10
  //# sourceMappingURL=name.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGnD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,KAAG,MAS3C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,UAAW,MAAM,SAAQ,MAAM,KAAkB,MAMhF,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAA0C,CAAA;AAErF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,MAM5C,CAAA;AAED,eAAO,MAAM,OAAO,WAAY,MAAM,SAAS,MAAM,KAAG,MACV,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,WAAW,WAAY,QAAQ,YAAY,gBAAgB,CAAC,cAAc,CAAC,KAAG,MACT,CAAA;AAElF;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAe,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAK9D,CAAA"}
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,eAAO,MAAM,kBAAkB,QAAO,YA4CrC,CAAA;AAED,eAAO,MAAM,YAAY,cAAuB,CAAA;AAEhD,+EAA+E;AAC/E,eAAO,MAAM,YAAY,SAAU,MAAM,KAAG,MAAyC,CAAA;AAErF,6EAA6E;AAC7E,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAwC,CAAA;AAEnF,8EAA8E;AAC9E,eAAO,MAAM,WAAW,cAAe,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAwC,CAAA"}
@@ -2,62 +2,43 @@ import { sha256 } from '@noble/hashes/sha2.js';
2
2
  import { hex } from '@scure/base';
3
3
  import { PG_MAX_IDENTIFIER } from '../consts.js';
4
4
  import { SAFE_IDENTIFIER } from './consts.local.js';
5
- /**
6
- * Coerce an arbitrary name into a legal Postgres identifier of at most 63 bytes.
7
- *
8
- * Postgres cuts anything past `NAMEDATALEN - 1` off server side and says nothing about
9
- * it, so two names that differ only beyond byte 63 would collapse into one identifier.
10
- * Clamping here instead leaves room for a hash suffix that keeps them apart.
11
- */
12
- export const pgIdentifier = (name) => {
13
- const sanitized = name.replace(/[^A-Za-z0-9_$]/g, '_');
14
- const prefixed = /^[A-Za-z_]/.test(sanitized) ? sanitized : `_${sanitized}`;
15
- if (Buffer.byteLength(prefixed, 'utf8') <= PG_MAX_IDENTIFIER) {
16
- return prefixed;
17
- }
18
- const digest = hex.encode(sha256(new TextEncoder().encode(name))).substring(0, 32);
19
- return `${prefixed.substring(0, 30)}_${digest}`;
20
- };
21
- /**
22
- * Assert a value is safe to interpolate as an identifier. Postgres can't bind identifiers
23
- * as parameters, so every one of them reaches the server as text — which makes this the
24
- * only thing standing between a config value and injection.
25
- *
26
- * @throws {SyntaxError}
27
- */
28
- export const assertSqlIdentifier = (value, what = 'identifier') => {
29
- if (!SAFE_IDENTIFIER.test(value) || Buffer.byteLength(value, 'utf8') > PG_MAX_IDENTIFIER) {
30
- throw new SyntaxError(`postgres:unsafe-${what}:${value}`);
31
- }
32
- return value;
33
- };
34
- /** Quote an identifier for emission, doubling any interior quote. */
35
- export const quoteIdent = (value) => `"${value.replace(/"/g, '""')}"`;
36
- /**
37
- * Quote a string literal. Only ever used for values Postgres refuses to bind — notably
38
- * the password in `CREATE ROLE`.
39
- *
40
- * @throws {SyntaxError} on a NUL byte, which no escaping makes safe.
41
- */
42
- export const quoteLiteral = (value) => {
43
- if (value.includes('\0')) {
44
- throw new SyntaxError('postgres:unsafe-literal:nul-byte');
45
- }
46
- return `'${value.replace(/'/g, "''")}'`;
47
- };
48
- export const qualify = (schema, table) => `${quoteIdent(schema)}.${quoteIdent(table)}`;
49
- /**
50
- * Physical table name of a resource: the explicit `name`, else the resource alias,
51
- * prefixed per `DbConfig.resourcePrefix` and sanitized.
52
- */
53
- export const pgTableName = (config, resource) => pgIdentifier(`${config.resourcePrefix ?? ''}${resource.name ?? resource.alias}`);
54
- /**
55
- * Derive a pair of int32s for `pg_advisory_lock` from a qualified table name, so every
56
- * replica booting against the same table serializes on the same key.
57
- */
58
- export const advisoryKey = (qualified) => {
59
- const digest = sha256(new TextEncoder().encode(`owlmeans:${qualified}`));
60
- const view = new DataView(digest.buffer, digest.byteOffset, digest.byteLength);
61
- return [view.getInt32(0, false), view.getInt32(4, false)];
5
+ export const createPgNameHelper = () => {
6
+ const pgIdentifier = (name) => {
7
+ const sanitized = name.replace(/[^A-Za-z0-9_$]/g, '_');
8
+ const prefixed = /^[A-Za-z_]/.test(sanitized) ? sanitized : `_${sanitized}`;
9
+ if (Buffer.byteLength(prefixed, 'utf8') <= PG_MAX_IDENTIFIER) {
10
+ return prefixed;
11
+ }
12
+ const digest = hex.encode(sha256(new TextEncoder().encode(name))).substring(0, 32);
13
+ return `${prefixed.substring(0, 30)}_${digest}`;
14
+ };
15
+ const assertSqlIdentifier = (value, what = 'identifier') => {
16
+ if (!SAFE_IDENTIFIER.test(value) || Buffer.byteLength(value, 'utf8') > PG_MAX_IDENTIFIER) {
17
+ throw new SyntaxError(`postgres:unsafe-${what}:${value}`);
18
+ }
19
+ return value;
20
+ };
21
+ const quoteIdent = (value) => `"${value.replace(/"/g, '""')}"`;
22
+ const quoteLiteral = (value) => {
23
+ if (value.includes('\0')) {
24
+ throw new SyntaxError('postgres:unsafe-literal:nul-byte');
25
+ }
26
+ return `'${value.replace(/'/g, "''")}'`;
27
+ };
28
+ const qualify = (schema, table) => `${quoteIdent(schema)}.${quoteIdent(table)}`;
29
+ const pgTableName = (config, resource) => pgIdentifier(`${config.resourcePrefix ?? ''}${resource.name ?? resource.alias}`);
30
+ const advisoryKey = (qualified) => {
31
+ const digest = sha256(new TextEncoder().encode(`owlmeans:${qualified}`));
32
+ const view = new DataView(digest.buffer, digest.byteOffset, digest.byteLength);
33
+ return [view.getInt32(0, false), view.getInt32(4, false)];
34
+ };
35
+ return { pgIdentifier, assertSqlIdentifier, quoteIdent, quoteLiteral, qualify, pgTableName, advisoryKey };
62
36
  };
37
+ export const pgNameHelper = createPgNameHelper();
38
+ /** @deprecated compat:factory-refactor — use `pgNameHelper.pgIdentifier(…)` */
39
+ export const pgIdentifier = (name) => pgNameHelper.pgIdentifier(name);
40
+ /** @deprecated compat:factory-refactor — use `pgNameHelper.quoteIdent(…)` */
41
+ export const quoteIdent = (value) => pgNameHelper.quoteIdent(value);
42
+ /** @deprecated compat:factory-refactor — use `pgNameHelper.advisoryKey(…)` */
43
+ export const advisoryKey = (qualified) => pgNameHelper.advisoryKey(qualified);
63
44
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U,CAAC,CAAA;QAE9E,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3D,CAAC,CAAA;IAED,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAA;AAC3G,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAA;AAEhD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;AAErF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAEnF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAoB,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { AnySchema } from 'ajv';
2
+ import type { PgIndexSpec, TableSpec } from '../../types.js';
3
+ /** The JSON Schema → table specification compiler. */
4
+ export interface PgSchemaHelper {
5
+ /**
6
+ * Normalize a Postgres type name to the spelling `format_type()` reports, so the drift
7
+ * comparison against a live table is an exact string match instead of a fuzzy one.
8
+ */
9
+ toFormatType: (type: string) => string;
10
+ /**
11
+ * Compile a resource's AJV schema into the table specification that drives both DDL
12
+ * emission and drift detection.
13
+ *
14
+ * `extraIndexes` carries what `resource.index()` declared. It's compiled here rather than
15
+ * merged afterwards so chained declarations get the same property-to-column mapping and
16
+ * the same generated names as schema-borne ones.
17
+ *
18
+ * @throws {UnsupportedArgumentError} when an override asks for something unrepresentable.
19
+ */
20
+ schemaToTableSpec: (alias: string, schema: AnySchema | undefined, pgSchema: string, table: string, autoSync: boolean, extraIndexes?: PgIndexSpec[]) => TableSpec;
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/schema/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE5D,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACtC;;;;;;;;;OASG;IACH,iBAAiB,EAAE,CACjB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAC7E,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,WAAW,EAAE,KAC5C,SAAS,CAAA;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/schema/types.ts"],"names":[],"mappings":""}
@@ -1,28 +1,8 @@
1
1
  import type { AnySchema } from 'ajv';
2
2
  import type { PgIndexSpec, TableSpec } from '../types.js';
3
- /**
4
- * Normalize a Postgres type name to the spelling `format_type()` reports, so the drift
5
- * comparison against a live table is an exact string match instead of a fuzzy one.
6
- */
7
- export declare const toFormatType: (type: string) => string;
8
- /**
9
- * Compile a resource's AJV schema into the table specification that drives both DDL
10
- * emission and drift detection.
11
- *
12
- * `extraIndexes` carries what `resource.index()` declared. It's compiled here rather than
13
- * merged afterwards so chained declarations get the same property-to-column mapping and
14
- * the same generated names as schema-borne ones.
15
- *
16
- * @throws {UnsupportedArgumentError} when an override asks for something unrepresentable.
17
- */
3
+ import type { PgSchemaHelper } from './schema/types.js';
4
+ export declare const createPgSchemaHelper: () => PgSchemaHelper;
5
+ export declare const pgSchemaHelper: PgSchemaHelper;
6
+ /** @deprecated compat:factory-refactor — use `pgSchemaHelper.schemaToTableSpec(…)` */
18
7
  export declare const schemaToTableSpec: (alias: string, schema: AnySchema | undefined, pgSchema: string, table: string, autoSync: boolean, extraIndexes?: PgIndexSpec[]) => TableSpec;
19
- /**
20
- * AJV keyword registration for consumers running in strict mode. The mapper reads the raw
21
- * schema object and never validates through AJV, so this is purely to stop strict mode
22
- * rejecting a schema that carries `pg` overrides.
23
- */
24
- export declare const pgKeyword: {
25
- keyword: string;
26
- valid: boolean;
27
- };
28
8
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAMpC,OAAO,KAAK,EAA2C,WAAW,EAAqD,SAAS,EAAE,MAAM,aAAa,CAAA;AAQrJ;;;GAGG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,KAAG,MAmB3C,CAAA;AAqMD;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,UACrB,MAAM,UAAU,SAAS,GAAG,SAAS,YAAY,MAAM,SAAS,MAAM,YACnE,OAAO,iBAAgB,WAAW,EAAE,KAC7C,SA8KF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;CAAuC,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAMpC,OAAO,KAAK,EAA2C,WAAW,EAAqD,SAAS,EAAE,MAAM,aAAa,CAAA;AAGrJ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAKvD,eAAO,MAAM,oBAAoB,QAAO,cA+YvC,CAAA;AAED,eAAO,MAAM,cAAc,gBAAyB,CAAA;AAEpD,sFAAsF;AACtF,eAAO,MAAM,iBAAiB,UACrB,MAAM,UAAU,SAAS,GAAG,SAAS,YAAY,MAAM,SAAS,MAAM,YACnE,OAAO,iBAAgB,WAAW,EAAE,KAC7C,SAAqG,CAAA"}