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.
Files changed (67) hide show
  1. package/esm/plugins/index.d.ts +1 -1
  2. package/esm/plugins/meta-schema.d.ts +3 -18
  3. package/esm/plugins/meta-schema.js +3 -19
  4. package/package.json +12 -11
  5. package/plugins/index.d.ts +1 -1
  6. package/plugins/meta-schema.d.ts +3 -18
  7. package/plugins/meta-schema.js +11 -16
  8. package/esm/plugins/meta-schema/cache.d.ts +0 -4
  9. package/esm/plugins/meta-schema/cache.js +0 -7
  10. package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
  11. package/esm/plugins/meta-schema/constraint-meta-builders.js +0 -51
  12. package/esm/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
  13. package/esm/plugins/meta-schema/encoding-meta-builders.js +0 -84
  14. package/esm/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
  15. package/esm/plugins/meta-schema/graphql-meta-field.js +0 -314
  16. package/esm/plugins/meta-schema/inflection-utils.d.ts +0 -4
  17. package/esm/plugins/meta-schema/inflection-utils.js +0 -20
  18. package/esm/plugins/meta-schema/name-meta-builders.d.ts +0 -4
  19. package/esm/plugins/meta-schema/name-meta-builders.js +0 -38
  20. package/esm/plugins/meta-schema/plugin.d.ts +0 -2
  21. package/esm/plugins/meta-schema/plugin.js +0 -23
  22. package/esm/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
  23. package/esm/plugins/meta-schema/relation-meta-builders.js +0 -119
  24. package/esm/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
  25. package/esm/plugins/meta-schema/scope-meta-builders.js +0 -40
  26. package/esm/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
  27. package/esm/plugins/meta-schema/storage-search-meta-builders.js +0 -180
  28. package/esm/plugins/meta-schema/table-meta-builder.d.ts +0 -2
  29. package/esm/plugins/meta-schema/table-meta-builder.js +0 -99
  30. package/esm/plugins/meta-schema/table-meta-context.d.ts +0 -13
  31. package/esm/plugins/meta-schema/table-meta-context.js +0 -11
  32. package/esm/plugins/meta-schema/table-resource-utils.d.ts +0 -12
  33. package/esm/plugins/meta-schema/table-resource-utils.js +0 -50
  34. package/esm/plugins/meta-schema/type-mappings.d.ts +0 -7
  35. package/esm/plugins/meta-schema/type-mappings.js +0 -100
  36. package/esm/plugins/meta-schema/types.d.ts +0 -325
  37. package/esm/plugins/meta-schema/types.js +0 -1
  38. package/plugins/meta-schema/cache.d.ts +0 -4
  39. package/plugins/meta-schema/cache.js +0 -12
  40. package/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
  41. package/plugins/meta-schema/constraint-meta-builders.js +0 -58
  42. package/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
  43. package/plugins/meta-schema/encoding-meta-builders.js +0 -87
  44. package/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
  45. package/plugins/meta-schema/graphql-meta-field.js +0 -317
  46. package/plugins/meta-schema/inflection-utils.d.ts +0 -4
  47. package/plugins/meta-schema/inflection-utils.js +0 -25
  48. package/plugins/meta-schema/name-meta-builders.d.ts +0 -4
  49. package/plugins/meta-schema/name-meta-builders.js +0 -43
  50. package/plugins/meta-schema/plugin.d.ts +0 -2
  51. package/plugins/meta-schema/plugin.js +0 -26
  52. package/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
  53. package/plugins/meta-schema/relation-meta-builders.js +0 -124
  54. package/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
  55. package/plugins/meta-schema/scope-meta-builders.js +0 -43
  56. package/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
  57. package/plugins/meta-schema/storage-search-meta-builders.js +0 -186
  58. package/plugins/meta-schema/table-meta-builder.d.ts +0 -2
  59. package/plugins/meta-schema/table-meta-builder.js +0 -102
  60. package/plugins/meta-schema/table-meta-context.d.ts +0 -13
  61. package/plugins/meta-schema/table-meta-context.js +0 -15
  62. package/plugins/meta-schema/table-resource-utils.d.ts +0 -12
  63. package/plugins/meta-schema/table-resource-utils.js +0 -60
  64. package/plugins/meta-schema/type-mappings.d.ts +0 -7
  65. package/plugins/meta-schema/type-mappings.js +0 -104
  66. package/plugins/meta-schema/types.d.ts +0 -325
  67. package/plugins/meta-schema/types.js +0 -2
@@ -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 './meta-schema/types';
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
- * Exposes a `_meta` GraphQL query that provides metadata about tables, fields,
5
- * constraints, indexes, and relations for code generation tooling.
4
+ * Re-exported from the `graphile-meta` package for backward compatibility.
6
5
  */
7
- import type { GraphileConfig } from 'graphile-config';
8
- import { cachedTablesMeta } from './meta-schema/cache';
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
- * Exposes a `_meta` GraphQL query that provides metadata about tables, fields,
5
- * constraints, indexes, and relations for code generation tooling.
4
+ * Re-exported from the `graphile-meta` package for backward compatibility.
6
5
  */
7
- import { cachedTablesMeta } from './meta-schema/cache';
8
- import { buildScalarEncoding } from './meta-schema/encoding-meta-builders';
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.1",
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.1",
52
+ "graphile-bulk-mutations": "^1.5.2",
53
53
  "graphile-config": "1.0.1",
54
- "graphile-connection-filter": "^2.5.1",
55
- "graphile-i18n": "^2.5.1",
56
- "graphile-llm": "^1.5.1",
57
- "graphile-ltree": "^2.5.1",
58
- "graphile-pg-aggregates": "^2.5.1",
59
- "graphile-postgis": "^3.5.1",
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.1",
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.1",
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": "f36bcdd2b5dada626955e9e05b19c80ca9f92ed5"
93
+ "gitHead": "12818db1a9b212cb2bf2b879f4bf1c5b1991d075"
93
94
  }
@@ -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 './meta-schema/types';
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
- * Exposes a `_meta` GraphQL query that provides metadata about tables, fields,
5
- * constraints, indexes, and relations for code generation tooling.
4
+ * Re-exported from the `graphile-meta` package for backward compatibility.
6
5
  */
7
- import type { GraphileConfig } from 'graphile-config';
8
- import { cachedTablesMeta } from './meta-schema/cache';
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';
@@ -2,21 +2,16 @@
2
2
  /**
3
3
  * PostGraphile v5 Meta Schema Plugin
4
4
  *
5
- * Exposes a `_meta` GraphQL query that provides metadata about tables, fields,
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._buildScalarEncoding = exports._cachedTablesMeta = exports._buildFieldMeta = exports._pgTypeToGqlType = exports.MetaSchemaPreset = exports.MetaSchemaPlugin = void 0;
10
- const cache_1 = require("./meta-schema/cache");
11
- Object.defineProperty(exports, "_cachedTablesMeta", { enumerable: true, get: function () { return cache_1.cachedTablesMeta; } });
12
- const encoding_meta_builders_1 = require("./meta-schema/encoding-meta-builders");
13
- Object.defineProperty(exports, "_buildScalarEncoding", { enumerable: true, get: function () { return encoding_meta_builders_1.buildScalarEncoding; } });
14
- const plugin_1 = require("./meta-schema/plugin");
15
- Object.defineProperty(exports, "MetaSchemaPlugin", { enumerable: true, get: function () { return plugin_1.MetaSchemaPlugin; } });
16
- const type_mappings_1 = require("./meta-schema/type-mappings");
17
- Object.defineProperty(exports, "_buildFieldMeta", { enumerable: true, get: function () { return type_mappings_1.buildFieldMeta; } });
18
- Object.defineProperty(exports, "_pgTypeToGqlType", { enumerable: true, get: function () { return type_mappings_1.pgTypeToGqlType; } });
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,4 +0,0 @@
1
- import type { TableMeta } from './types';
2
- export declare let cachedTablesMeta: TableMeta[];
3
- export declare function getCachedTablesMeta(): TableMeta[];
4
- export declare function setCachedTablesMeta(tablesMeta: TableMeta[]): void;
@@ -1,7 +0,0 @@
1
- export let cachedTablesMeta = [];
2
- export function getCachedTablesMeta() {
3
- return cachedTablesMeta;
4
- }
5
- export function setCachedTablesMeta(tablesMeta) {
6
- cachedTablesMeta = tablesMeta;
7
- }
@@ -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,2 +0,0 @@
1
- import type { PgAttribute, ScalarEncodingMeta } from './types';
2
- export declare function buildScalarEncoding(attr: PgAttribute | null | undefined): ScalarEncodingMeta | null;
@@ -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
- }
@@ -1,4 +0,0 @@
1
- import type { TableMeta } from './types';
2
- type FieldMap = Record<string, unknown>;
3
- export declare function extendQueryWithMetaField(fields: FieldMap, tablesMeta: TableMeta[]): FieldMap;
4
- export {};