graphile-settings 6.5.1 → 6.5.3
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/esm/plugins/index.d.ts +1 -1
- package/esm/plugins/meta-schema.d.ts +3 -18
- package/esm/plugins/meta-schema.js +3 -19
- package/package.json +12 -11
- package/plugins/index.d.ts +1 -1
- package/plugins/meta-schema.d.ts +3 -18
- package/plugins/meta-schema.js +11 -16
- package/esm/plugins/meta-schema/cache.d.ts +0 -4
- package/esm/plugins/meta-schema/cache.js +0 -7
- package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
- package/esm/plugins/meta-schema/constraint-meta-builders.js +0 -51
- package/esm/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
- package/esm/plugins/meta-schema/encoding-meta-builders.js +0 -84
- package/esm/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
- package/esm/plugins/meta-schema/graphql-meta-field.js +0 -314
- package/esm/plugins/meta-schema/inflection-utils.d.ts +0 -4
- package/esm/plugins/meta-schema/inflection-utils.js +0 -20
- package/esm/plugins/meta-schema/name-meta-builders.d.ts +0 -4
- package/esm/plugins/meta-schema/name-meta-builders.js +0 -38
- package/esm/plugins/meta-schema/plugin.d.ts +0 -2
- package/esm/plugins/meta-schema/plugin.js +0 -23
- package/esm/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
- package/esm/plugins/meta-schema/relation-meta-builders.js +0 -119
- package/esm/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
- package/esm/plugins/meta-schema/scope-meta-builders.js +0 -40
- package/esm/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
- package/esm/plugins/meta-schema/storage-search-meta-builders.js +0 -180
- package/esm/plugins/meta-schema/table-meta-builder.d.ts +0 -2
- package/esm/plugins/meta-schema/table-meta-builder.js +0 -99
- package/esm/plugins/meta-schema/table-meta-context.d.ts +0 -13
- package/esm/plugins/meta-schema/table-meta-context.js +0 -11
- package/esm/plugins/meta-schema/table-resource-utils.d.ts +0 -12
- package/esm/plugins/meta-schema/table-resource-utils.js +0 -50
- package/esm/plugins/meta-schema/type-mappings.d.ts +0 -7
- package/esm/plugins/meta-schema/type-mappings.js +0 -100
- package/esm/plugins/meta-schema/types.d.ts +0 -325
- package/esm/plugins/meta-schema/types.js +0 -1
- package/plugins/meta-schema/cache.d.ts +0 -4
- package/plugins/meta-schema/cache.js +0 -12
- package/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
- package/plugins/meta-schema/constraint-meta-builders.js +0 -58
- package/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
- package/plugins/meta-schema/encoding-meta-builders.js +0 -87
- package/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
- package/plugins/meta-schema/graphql-meta-field.js +0 -317
- package/plugins/meta-schema/inflection-utils.d.ts +0 -4
- package/plugins/meta-schema/inflection-utils.js +0 -25
- package/plugins/meta-schema/name-meta-builders.d.ts +0 -4
- package/plugins/meta-schema/name-meta-builders.js +0 -43
- package/plugins/meta-schema/plugin.d.ts +0 -2
- package/plugins/meta-schema/plugin.js +0 -26
- package/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
- package/plugins/meta-schema/relation-meta-builders.js +0 -124
- package/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
- package/plugins/meta-schema/scope-meta-builders.js +0 -43
- package/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
- package/plugins/meta-schema/storage-search-meta-builders.js +0 -186
- package/plugins/meta-schema/table-meta-builder.d.ts +0 -2
- package/plugins/meta-schema/table-meta-builder.js +0 -102
- package/plugins/meta-schema/table-meta-context.d.ts +0 -13
- package/plugins/meta-schema/table-meta-context.js +0 -15
- package/plugins/meta-schema/table-resource-utils.d.ts +0 -12
- package/plugins/meta-schema/table-resource-utils.js +0 -60
- package/plugins/meta-schema/type-mappings.d.ts +0 -7
- package/plugins/meta-schema/type-mappings.js +0 -104
- package/plugins/meta-schema/types.d.ts +0 -325
- package/plugins/meta-schema/types.js +0 -2
package/esm/plugins/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { ManyToManyOptInPlugin, ManyToManyOptInPreset, } from './many-to-many-pr
|
|
|
12
12
|
export { createUniqueLookupPlugin, PrimaryKeyOnlyPlugin, NoUniqueLookupPlugin, PrimaryKeyOnlyPreset, NoUniqueLookupPreset, } from './primary-key-only';
|
|
13
13
|
export type { UniqueLookupOptions } from './primary-key-only';
|
|
14
14
|
export { MetaSchemaPlugin, MetaSchemaPreset, } from './meta-schema';
|
|
15
|
-
export type { TableMeta, FieldMeta, TypeMeta, IndexMeta, ConstraintsMeta, PrimaryKeyConstraintMeta, UniqueConstraintMeta, ForeignKeyConstraintMeta, RelationsMeta, BelongsToRelation, HasRelation, ManyToManyRelation, InflectionMeta, QueryMeta, } from '
|
|
15
|
+
export type { TableMeta, FieldMeta, TypeMeta, IndexMeta, ConstraintsMeta, PrimaryKeyConstraintMeta, UniqueConstraintMeta, ForeignKeyConstraintMeta, RelationsMeta, BelongsToRelation, HasRelation, ManyToManyRelation, InflectionMeta, QueryMeta, } from 'graphile-meta';
|
|
16
16
|
export { PgTypeMappingsPlugin, PgTypeMappingsPreset, } from './pg-type-mappings';
|
|
17
17
|
export type { TypeMapping } from './pg-type-mappings';
|
|
18
18
|
export { PublicKeySignature } from './PublicKeySignature';
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PostGraphile v5 Meta Schema Plugin
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* constraints, indexes, and relations for code generation tooling.
|
|
4
|
+
* Re-exported from the `graphile-meta` package for backward compatibility.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { buildScalarEncoding } from './meta-schema/encoding-meta-builders';
|
|
10
|
-
import { MetaSchemaPlugin } from './meta-schema/plugin';
|
|
11
|
-
import { buildFieldMeta, pgTypeToGqlType } from './meta-schema/type-mappings';
|
|
12
|
-
export { MetaSchemaPlugin };
|
|
13
|
-
export declare const MetaSchemaPreset: GraphileConfig.Preset;
|
|
14
|
-
/** @internal Exported for testing only */
|
|
15
|
-
export { pgTypeToGqlType as _pgTypeToGqlType };
|
|
16
|
-
/** @internal Exported for testing only */
|
|
17
|
-
export { buildFieldMeta as _buildFieldMeta };
|
|
18
|
-
/** @internal Exported for testing only */
|
|
19
|
-
export { cachedTablesMeta as _cachedTablesMeta };
|
|
20
|
-
/** @internal Exported for testing only */
|
|
21
|
-
export { buildScalarEncoding as _buildScalarEncoding };
|
|
22
|
-
export default MetaSchemaPlugin;
|
|
6
|
+
export { _buildFieldMeta, _buildScalarEncoding, _cachedTablesMeta, _pgTypeToGqlType, MetaSchemaPlugin, MetaSchemaPreset, } from 'graphile-meta';
|
|
7
|
+
export { MetaSchemaPlugin as default } from 'graphile-meta';
|
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PostGraphile v5 Meta Schema Plugin
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* constraints, indexes, and relations for code generation tooling.
|
|
4
|
+
* Re-exported from the `graphile-meta` package for backward compatibility.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { MetaSchemaPlugin } from './meta-schema/plugin';
|
|
10
|
-
import { buildFieldMeta, pgTypeToGqlType } from './meta-schema/type-mappings';
|
|
11
|
-
export { MetaSchemaPlugin };
|
|
12
|
-
export const MetaSchemaPreset = {
|
|
13
|
-
plugins: [MetaSchemaPlugin],
|
|
14
|
-
};
|
|
15
|
-
/** @internal Exported for testing only */
|
|
16
|
-
export { pgTypeToGqlType as _pgTypeToGqlType };
|
|
17
|
-
/** @internal Exported for testing only */
|
|
18
|
-
export { buildFieldMeta as _buildFieldMeta };
|
|
19
|
-
/** @internal Exported for testing only */
|
|
20
|
-
export { cachedTablesMeta as _cachedTablesMeta };
|
|
21
|
-
/** @internal Exported for testing only */
|
|
22
|
-
export { buildScalarEncoding as _buildScalarEncoding };
|
|
23
|
-
export default MetaSchemaPlugin;
|
|
6
|
+
export { _buildFieldMeta, _buildScalarEncoding, _cachedTablesMeta, _pgTypeToGqlType, MetaSchemaPlugin, MetaSchemaPreset, } from 'graphile-meta';
|
|
7
|
+
export { MetaSchemaPlugin as default } from 'graphile-meta';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-settings",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.3",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "graphile settings",
|
|
6
6
|
"main": "index.js",
|
|
@@ -49,17 +49,18 @@
|
|
|
49
49
|
"graphile-bucket-provisioner-plugin": "1.4.0",
|
|
50
50
|
"graphile-build": "5.0.2",
|
|
51
51
|
"graphile-build-pg": "5.0.2",
|
|
52
|
-
"graphile-bulk-mutations": "^1.5.
|
|
52
|
+
"graphile-bulk-mutations": "^1.5.2",
|
|
53
53
|
"graphile-config": "1.0.1",
|
|
54
|
-
"graphile-connection-filter": "^2.5.
|
|
55
|
-
"graphile-i18n": "^2.5.
|
|
56
|
-
"graphile-llm": "^1.5.
|
|
57
|
-
"graphile-ltree": "^2.5.
|
|
58
|
-
"graphile-
|
|
59
|
-
"graphile-
|
|
54
|
+
"graphile-connection-filter": "^2.5.2",
|
|
55
|
+
"graphile-i18n": "^2.5.2",
|
|
56
|
+
"graphile-llm": "^1.5.2",
|
|
57
|
+
"graphile-ltree": "^2.5.2",
|
|
58
|
+
"graphile-meta": "^1.1.1",
|
|
59
|
+
"graphile-pg-aggregates": "^2.5.2",
|
|
60
|
+
"graphile-postgis": "^3.5.2",
|
|
60
61
|
"graphile-presigned-url-plugin": "^1.4.0",
|
|
61
62
|
"graphile-realtime-subscriptions": "^1.4.0",
|
|
62
|
-
"graphile-search": "^2.5.
|
|
63
|
+
"graphile-search": "^2.5.2",
|
|
63
64
|
"graphile-upload-plugin": "^2.18.0",
|
|
64
65
|
"graphile-utils": "5.0.1",
|
|
65
66
|
"graphql": "16.13.0",
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
"@types/express": "^5.0.6",
|
|
78
79
|
"@types/pg": "^8.20.0",
|
|
79
80
|
"@types/request-ip": "^0.0.41",
|
|
80
|
-
"graphile-test": "^5.5.
|
|
81
|
+
"graphile-test": "^5.5.2",
|
|
81
82
|
"makage": "^0.3.0",
|
|
82
83
|
"nodemon": "^3.1.14",
|
|
83
84
|
"ts-node": "^10.9.2"
|
|
@@ -89,5 +90,5 @@
|
|
|
89
90
|
"constructive",
|
|
90
91
|
"graphql"
|
|
91
92
|
],
|
|
92
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "12818db1a9b212cb2bf2b879f4bf1c5b1991d075"
|
|
93
94
|
}
|
package/plugins/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { ManyToManyOptInPlugin, ManyToManyOptInPreset, } from './many-to-many-pr
|
|
|
12
12
|
export { createUniqueLookupPlugin, PrimaryKeyOnlyPlugin, NoUniqueLookupPlugin, PrimaryKeyOnlyPreset, NoUniqueLookupPreset, } from './primary-key-only';
|
|
13
13
|
export type { UniqueLookupOptions } from './primary-key-only';
|
|
14
14
|
export { MetaSchemaPlugin, MetaSchemaPreset, } from './meta-schema';
|
|
15
|
-
export type { TableMeta, FieldMeta, TypeMeta, IndexMeta, ConstraintsMeta, PrimaryKeyConstraintMeta, UniqueConstraintMeta, ForeignKeyConstraintMeta, RelationsMeta, BelongsToRelation, HasRelation, ManyToManyRelation, InflectionMeta, QueryMeta, } from '
|
|
15
|
+
export type { TableMeta, FieldMeta, TypeMeta, IndexMeta, ConstraintsMeta, PrimaryKeyConstraintMeta, UniqueConstraintMeta, ForeignKeyConstraintMeta, RelationsMeta, BelongsToRelation, HasRelation, ManyToManyRelation, InflectionMeta, QueryMeta, } from 'graphile-meta';
|
|
16
16
|
export { PgTypeMappingsPlugin, PgTypeMappingsPreset, } from './pg-type-mappings';
|
|
17
17
|
export type { TypeMapping } from './pg-type-mappings';
|
|
18
18
|
export { PublicKeySignature } from './PublicKeySignature';
|
package/plugins/meta-schema.d.ts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PostGraphile v5 Meta Schema Plugin
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* constraints, indexes, and relations for code generation tooling.
|
|
4
|
+
* Re-exported from the `graphile-meta` package for backward compatibility.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { buildScalarEncoding } from './meta-schema/encoding-meta-builders';
|
|
10
|
-
import { MetaSchemaPlugin } from './meta-schema/plugin';
|
|
11
|
-
import { buildFieldMeta, pgTypeToGqlType } from './meta-schema/type-mappings';
|
|
12
|
-
export { MetaSchemaPlugin };
|
|
13
|
-
export declare const MetaSchemaPreset: GraphileConfig.Preset;
|
|
14
|
-
/** @internal Exported for testing only */
|
|
15
|
-
export { pgTypeToGqlType as _pgTypeToGqlType };
|
|
16
|
-
/** @internal Exported for testing only */
|
|
17
|
-
export { buildFieldMeta as _buildFieldMeta };
|
|
18
|
-
/** @internal Exported for testing only */
|
|
19
|
-
export { cachedTablesMeta as _cachedTablesMeta };
|
|
20
|
-
/** @internal Exported for testing only */
|
|
21
|
-
export { buildScalarEncoding as _buildScalarEncoding };
|
|
22
|
-
export default MetaSchemaPlugin;
|
|
6
|
+
export { _buildFieldMeta, _buildScalarEncoding, _cachedTablesMeta, _pgTypeToGqlType, MetaSchemaPlugin, MetaSchemaPreset, } from 'graphile-meta';
|
|
7
|
+
export { MetaSchemaPlugin as default } from 'graphile-meta';
|
package/plugins/meta-schema.js
CHANGED
|
@@ -2,21 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* PostGraphile v5 Meta Schema Plugin
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* constraints, indexes, and relations for code generation tooling.
|
|
5
|
+
* Re-exported from the `graphile-meta` package for backward compatibility.
|
|
7
6
|
*/
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "MetaSchemaPlugin", { enumerable: true, get: function () { return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
exports.MetaSchemaPreset = {
|
|
20
|
-
plugins: [plugin_1.MetaSchemaPlugin],
|
|
21
|
-
};
|
|
22
|
-
exports.default = plugin_1.MetaSchemaPlugin;
|
|
8
|
+
exports.default = exports.MetaSchemaPreset = exports.MetaSchemaPlugin = exports._pgTypeToGqlType = exports._cachedTablesMeta = exports._buildScalarEncoding = exports._buildFieldMeta = void 0;
|
|
9
|
+
var graphile_meta_1 = require("graphile-meta");
|
|
10
|
+
Object.defineProperty(exports, "_buildFieldMeta", { enumerable: true, get: function () { return graphile_meta_1._buildFieldMeta; } });
|
|
11
|
+
Object.defineProperty(exports, "_buildScalarEncoding", { enumerable: true, get: function () { return graphile_meta_1._buildScalarEncoding; } });
|
|
12
|
+
Object.defineProperty(exports, "_cachedTablesMeta", { enumerable: true, get: function () { return graphile_meta_1._cachedTablesMeta; } });
|
|
13
|
+
Object.defineProperty(exports, "_pgTypeToGqlType", { enumerable: true, get: function () { return graphile_meta_1._pgTypeToGqlType; } });
|
|
14
|
+
Object.defineProperty(exports, "MetaSchemaPlugin", { enumerable: true, get: function () { return graphile_meta_1.MetaSchemaPlugin; } });
|
|
15
|
+
Object.defineProperty(exports, "MetaSchemaPreset", { enumerable: true, get: function () { return graphile_meta_1.MetaSchemaPreset; } });
|
|
16
|
+
var graphile_meta_2 = require("graphile-meta");
|
|
17
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return graphile_meta_2.MetaSchemaPlugin; } });
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type BuildContext } from './table-meta-context';
|
|
2
|
-
import type { ForeignKeyConstraintMeta, PgAttribute, PgCodec, PgRelation, PgUnique, PrimaryKeyConstraintMeta, UniqueConstraintMeta } from './types';
|
|
3
|
-
export declare function buildForeignKeyConstraint(constraintName: string, localCodec: PgCodec, localAttributes: Record<string, PgAttribute>, localAttributeNames: string[], remoteCodec: PgCodec | undefined, remoteAttributes: Record<string, PgAttribute>, remoteAttributeNames: string[], context: BuildContext): ForeignKeyConstraintMeta;
|
|
4
|
-
export declare function buildIndexes(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], context: BuildContext): {
|
|
5
|
-
name: string;
|
|
6
|
-
isUnique: boolean;
|
|
7
|
-
isPrimary: boolean;
|
|
8
|
-
columns: string[];
|
|
9
|
-
fields: import("./types").FieldMeta[];
|
|
10
|
-
}[];
|
|
11
|
-
export declare function buildPrimaryKey(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], context: BuildContext): PrimaryKeyConstraintMeta | null;
|
|
12
|
-
export declare function buildUniqueConstraints(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], context: BuildContext): UniqueConstraintMeta[];
|
|
13
|
-
export declare function buildForeignKeyConstraints(codec: PgCodec, attributes: Record<string, PgAttribute>, relations: Record<string, PgRelation>, context: BuildContext): ForeignKeyConstraintMeta[];
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { buildFieldMeta } from './type-mappings';
|
|
2
|
-
import { buildFieldList } from './table-meta-context';
|
|
3
|
-
export function buildForeignKeyConstraint(constraintName, localCodec, localAttributes, localAttributeNames, remoteCodec, remoteAttributes, remoteAttributeNames, context) {
|
|
4
|
-
const referencedTable = remoteCodec?.name || 'unknown';
|
|
5
|
-
const referencedFields = remoteAttributeNames.map((attrName) => remoteCodec ? context.inflectAttr(attrName, remoteCodec) : attrName);
|
|
6
|
-
return {
|
|
7
|
-
name: constraintName,
|
|
8
|
-
fields: buildFieldList(localAttributeNames, localCodec, localAttributes, context),
|
|
9
|
-
referencedTable,
|
|
10
|
-
referencedFields,
|
|
11
|
-
refFields: remoteAttributeNames.map((attrName) => buildFieldMeta(remoteCodec ? context.inflectAttr(attrName, remoteCodec) : attrName, remoteAttributes[attrName], context.build)),
|
|
12
|
-
refTable: { name: referencedTable },
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function buildIndexes(codec, attributes, uniques, context) {
|
|
16
|
-
return uniques.map((unique) => ({
|
|
17
|
-
name: unique.tags?.name || `${codec.name}_${unique.attributes.join('_')}_idx`,
|
|
18
|
-
isUnique: true,
|
|
19
|
-
isPrimary: !!unique.isPrimary,
|
|
20
|
-
columns: unique.attributes.map((attrName) => context.inflectAttr(attrName, codec)),
|
|
21
|
-
fields: buildFieldList(unique.attributes, codec, attributes, context),
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
export function buildPrimaryKey(codec, attributes, uniques, context) {
|
|
25
|
-
const primaryUnique = uniques.find((unique) => unique.isPrimary);
|
|
26
|
-
if (!primaryUnique)
|
|
27
|
-
return null;
|
|
28
|
-
return {
|
|
29
|
-
name: primaryUnique.tags?.name || `${codec.name}_pkey`,
|
|
30
|
-
fields: buildFieldList(primaryUnique.attributes, codec, attributes, context),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function buildUniqueConstraints(codec, attributes, uniques, context) {
|
|
34
|
-
return uniques
|
|
35
|
-
.filter((unique) => !unique.isPrimary)
|
|
36
|
-
.map((unique) => ({
|
|
37
|
-
name: unique.tags?.name || `${codec.name}_${unique.attributes.join('_')}_key`,
|
|
38
|
-
fields: buildFieldList(unique.attributes, codec, attributes, context),
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
export function buildForeignKeyConstraints(codec, attributes, relations, context) {
|
|
42
|
-
const constraints = [];
|
|
43
|
-
for (const [relationName, relation] of Object.entries(relations)) {
|
|
44
|
-
if (relation.isReferencee)
|
|
45
|
-
continue;
|
|
46
|
-
const remoteCodec = relation.remoteResource?.codec;
|
|
47
|
-
const remoteAttributes = remoteCodec?.attributes || {};
|
|
48
|
-
constraints.push(buildForeignKeyConstraint(relationName, codec, attributes, relation.localAttributes || [], remoteCodec, remoteAttributes, relation.remoteAttributes || [], context));
|
|
49
|
-
}
|
|
50
|
-
return constraints;
|
|
51
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scalar encoding contracts — the one piece of field metadata standard GraphQL
|
|
3
|
-
* introspection can't provide.
|
|
4
|
-
*
|
|
5
|
-
* Introspection tells a client a field's scalar *name* (`GeoJSON`, `LTree`,
|
|
6
|
-
* `Interval`, `BigInt`, `vector`, …) but not how to serialize/parse it or its
|
|
7
|
-
* structural parameters (geometry subtype/SRID, vector dimensions, ltree
|
|
8
|
-
* dot-path semantics). Without that, generated clients treat these as opaque
|
|
9
|
-
* strings / `any` and mis-encode inputs or fail to parse outputs.
|
|
10
|
-
*
|
|
11
|
-
* `kind` is derived deterministically from the *underlying* codec (array and
|
|
12
|
-
* domain wrappers unwrapped first, first match wins) so exactly one kind is
|
|
13
|
-
* ever assigned and nothing can clobber it. Structural extras (subtype, SRID,
|
|
14
|
-
* dimensions) are read verbatim from attribute extensions — never guessed, and
|
|
15
|
-
* `null` when absent.
|
|
16
|
-
*/
|
|
17
|
-
/** pg type name → encoding kind. Plain scalars are intentionally absent → null. */
|
|
18
|
-
const KIND_BY_PG_TYPE = {
|
|
19
|
-
int8: 'bigint',
|
|
20
|
-
bigint: 'bigint',
|
|
21
|
-
numeric: 'bigint',
|
|
22
|
-
timestamptz: 'datetime',
|
|
23
|
-
timestamp: 'datetime',
|
|
24
|
-
date: 'date',
|
|
25
|
-
time: 'time',
|
|
26
|
-
timetz: 'time',
|
|
27
|
-
interval: 'interval',
|
|
28
|
-
uuid: 'uuid',
|
|
29
|
-
geometry: 'geojson',
|
|
30
|
-
geography: 'geojson',
|
|
31
|
-
point: 'point',
|
|
32
|
-
inet: 'inet',
|
|
33
|
-
cidr: 'inet',
|
|
34
|
-
ltree: 'ltree',
|
|
35
|
-
vector: 'vector',
|
|
36
|
-
bytea: 'bytea'
|
|
37
|
-
};
|
|
38
|
-
/** Unwrap array-of and domain-of wrappers to the underlying scalar/record codec. */
|
|
39
|
-
function underlyingCodec(codec) {
|
|
40
|
-
let current = codec ?? null;
|
|
41
|
-
const seen = new Set();
|
|
42
|
-
while (current && !seen.has(current) && (current.arrayOfCodec || current.domainOfCodec)) {
|
|
43
|
-
seen.add(current);
|
|
44
|
-
current = current.arrayOfCodec || current.domainOfCodec || null;
|
|
45
|
-
}
|
|
46
|
-
return current;
|
|
47
|
-
}
|
|
48
|
-
/** True when a codec is a composite/record type (has named attributes). */
|
|
49
|
-
function isCompositeCodec(codec) {
|
|
50
|
-
return !!codec?.attributes && Object.keys(codec.attributes).length > 0;
|
|
51
|
-
}
|
|
52
|
-
export function buildScalarEncoding(attr) {
|
|
53
|
-
const codec = underlyingCodec(attr?.codec);
|
|
54
|
-
if (!codec)
|
|
55
|
-
return null;
|
|
56
|
-
const ext = attr?.extensions ?? undefined;
|
|
57
|
-
const kind = KIND_BY_PG_TYPE[codec.name];
|
|
58
|
-
if (!kind) {
|
|
59
|
-
// Composite/record types are the only non-mapped scalars worth describing;
|
|
60
|
-
// everything else (text, int, bool, json, enum, …) is fully covered by gqlType.
|
|
61
|
-
if (isCompositeCodec(codec)) {
|
|
62
|
-
return { kind: 'composite', fields: null };
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
switch (kind) {
|
|
67
|
-
case 'geojson':
|
|
68
|
-
return {
|
|
69
|
-
kind,
|
|
70
|
-
geometrySubtype: typeof ext?.geometrySubtype === 'string' ? ext.geometrySubtype : null,
|
|
71
|
-
srid: typeof ext?.geometrySrid === 'number' ? ext.geometrySrid : null
|
|
72
|
-
};
|
|
73
|
-
case 'vector':
|
|
74
|
-
return {
|
|
75
|
-
kind,
|
|
76
|
-
elementType: 'float',
|
|
77
|
-
dimensions: typeof ext?.vectorDimensions === 'number' ? ext.vectorDimensions : null
|
|
78
|
-
};
|
|
79
|
-
case 'ltree':
|
|
80
|
-
return { kind, dotPath: true };
|
|
81
|
-
default:
|
|
82
|
-
return { kind };
|
|
83
|
-
}
|
|
84
|
-
}
|