@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.
- package/README.md +13 -13
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/postgres-resource/SKILL.md +1 -1
- package/build/consts.d.ts +9 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +6 -0
- package/build/consts.js.map +1 -1
- package/build/declarations/types.d.ts +12 -0
- package/build/declarations/types.d.ts.map +1 -0
- package/build/declarations/types.js +2 -0
- package/build/declarations/types.js.map +1 -0
- package/build/declarations.d.ts +5 -1
- package/build/declarations.d.ts.map +1 -1
- package/build/declarations.js +25 -15
- package/build/declarations.js.map +1 -1
- package/build/errors.d.ts +0 -20
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js +1 -111
- package/build/errors.js.map +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/pg-error/types.d.ts +24 -0
- package/build/pg-error/types.d.ts.map +1 -0
- package/build/pg-error/types.js +2 -0
- package/build/pg-error/types.js.map +1 -0
- package/build/pg-error.d.ts +4 -0
- package/build/pg-error.d.ts.map +1 -0
- package/build/pg-error.js +100 -0
- package/build/pg-error.js.map +1 -0
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +15 -11
- package/build/resource.js.map +1 -1
- package/build/types.d.ts.map +1 -1
- package/build/utils/consts.local.d.ts +2 -0
- package/build/utils/consts.local.d.ts.map +1 -1
- package/build/utils/consts.local.js +2 -0
- package/build/utils/consts.local.js.map +1 -1
- package/build/utils/criteria/types.d.ts +31 -0
- package/build/utils/criteria/types.d.ts.map +1 -0
- package/build/utils/criteria/types.js +2 -0
- package/build/utils/criteria/types.js.map +1 -0
- package/build/utils/criteria.d.ts +3 -27
- package/build/utils/criteria.d.ts.map +1 -1
- package/build/utils/criteria.js +86 -104
- package/build/utils/criteria.js.map +1 -1
- package/build/utils/diff/types.d.ts +40 -0
- package/build/utils/diff/types.d.ts.map +1 -0
- package/build/utils/diff/types.js +2 -0
- package/build/utils/diff/types.js.map +1 -0
- package/build/utils/diff.d.ts +5 -35
- package/build/utils/diff.d.ts.map +1 -1
- package/build/utils/diff.js +320 -344
- package/build/utils/diff.js.map +1 -1
- package/build/utils/index.d.ts +9 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/introspect/types.d.ts +9 -0
- package/build/utils/introspect/types.d.ts.map +1 -0
- package/build/utils/introspect/types.js +2 -0
- package/build/utils/introspect/types.js.map +1 -0
- package/build/utils/introspect.d.ts +3 -3
- package/build/utils/introspect.d.ts.map +1 -1
- package/build/utils/introspect.js +41 -38
- package/build/utils/introspect.js.map +1 -1
- package/build/utils/life-cycle/types.d.ts +37 -0
- package/build/utils/life-cycle/types.d.ts.map +1 -0
- package/build/utils/life-cycle/types.js +2 -0
- package/build/utils/life-cycle/types.js.map +1 -0
- package/build/utils/life-cycle.d.ts +3 -33
- package/build/utils/life-cycle.d.ts.map +1 -1
- package/build/utils/life-cycle.js +88 -108
- package/build/utils/life-cycle.js.map +1 -1
- package/build/utils/marshal/types.d.ts +39 -0
- package/build/utils/marshal/types.d.ts.map +1 -0
- package/build/utils/marshal/types.js +2 -0
- package/build/utils/marshal/types.js.map +1 -0
- package/build/utils/marshal.d.ts +4 -32
- package/build/utils/marshal.d.ts.map +1 -1
- package/build/utils/marshal.js +121 -144
- package/build/utils/marshal.js.map +1 -1
- package/build/utils/migrations.d.ts.map +1 -1
- package/build/utils/migrations.js +41 -36
- package/build/utils/migrations.js.map +1 -1
- package/build/utils/name/types.d.ts +43 -0
- package/build/utils/name/types.d.ts.map +1 -0
- package/build/utils/name/types.js +2 -0
- package/build/utils/name/types.js.map +1 -0
- package/build/utils/name.d.ts +6 -35
- package/build/utils/name.d.ts.map +1 -1
- package/build/utils/name.js +38 -57
- package/build/utils/name.js.map +1 -1
- package/build/utils/schema/types.d.ts +22 -0
- package/build/utils/schema/types.d.ts.map +1 -0
- package/build/utils/schema/types.js +2 -0
- package/build/utils/schema/types.js.map +1 -0
- package/build/utils/schema.d.ts +4 -24
- package/build/utils/schema.d.ts.map +1 -1
- package/build/utils/schema.js +339 -352
- package/build/utils/schema.js.map +1 -1
- package/build/utils/sql/types.d.ts +25 -0
- package/build/utils/sql/types.d.ts.map +1 -0
- package/build/utils/sql/types.js +2 -0
- package/build/utils/sql/types.js.map +1 -0
- package/build/utils/sql.d.ts +4 -18
- package/build/utils/sql.d.ts.map +1 -1
- package/build/utils/sql.js +0 -0
- package/build/utils/sql.js.map +1 -1
- package/build/utils/sync/types.d.ts +25 -0
- package/build/utils/sync/types.d.ts.map +1 -0
- package/build/utils/sync/types.js +2 -0
- package/build/utils/sync/types.js.map +1 -0
- package/build/utils/sync.d.ts +2 -19
- package/build/utils/sync.d.ts.map +1 -1
- package/build/utils/sync.js +64 -71
- package/build/utils/sync.js.map +1 -1
- package/package.json +7 -7
- package/src/consts.ts +7 -0
- package/src/declarations/types.ts +12 -0
- package/src/declarations.ts +29 -14
- package/src/errors.ts +1 -121
- package/src/index.ts +3 -0
- package/src/pg-error/types.ts +23 -0
- package/src/pg-error.ts +114 -0
- package/src/resource.ts +17 -13
- package/src/types.ts +1 -0
- package/src/utils/consts.local.ts +3 -0
- package/src/utils/criteria/types.ts +32 -0
- package/src/utils/criteria.ts +95 -110
- package/src/utils/diff/types.ts +41 -0
- package/src/utils/diff.ts +330 -348
- package/src/utils/index.ts +9 -0
- package/src/utils/introspect/types.ts +9 -0
- package/src/utils/introspect.ts +51 -45
- package/src/utils/life-cycle/types.ts +41 -0
- package/src/utils/life-cycle.ts +102 -121
- package/src/utils/marshal/types.ts +40 -0
- package/src/utils/marshal.ts +129 -147
- package/src/utils/migrations.ts +39 -33
- package/src/utils/name/types.ts +44 -0
- package/src/utils/name.ts +47 -60
- package/src/utils/schema/types.ts +26 -0
- package/src/utils/schema.ts +359 -366
- package/src/utils/sql/types.ts +25 -0
- package/src/utils/sql.ts +0 -0
- package/src/utils/sync/types.ts +25 -0
- package/src/utils/sync.ts +62 -68
- package/tests/criteria.spec.ts +4 -1
- package/tests/diff.spec.ts +4 -1
- package/tests/errors.spec.ts +4 -3
- package/tests/name.spec.ts +5 -3
- package/tests/schema.spec.ts +3 -1
- package/tests/sql.spec.ts +20 -22
package/build/utils/name.d.ts
CHANGED
|
@@ -1,39 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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":"
|
|
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"}
|
package/build/utils/name.js
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
//# sourceMappingURL=name.js.map
|
package/build/utils/name.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.js","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAGjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"name.js","sourceRoot":"","sources":["../../src/utils/name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAGjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAiB,EAAE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,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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/schema/types.ts"],"names":[],"mappings":""}
|
package/build/utils/schema.d.ts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import type { AnySchema } from 'ajv';
|
|
2
2
|
import type { PgIndexSpec, TableSpec } from '../types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
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"}
|