@stonecrop/schema 0.31.0 → 0.32.0
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 +10 -10
- package/dist/cli.js +194 -121
- package/dist/cli.js.map +1 -1
- package/dist/converter-CLwduvT_.js +2102 -0
- package/dist/converter-CLwduvT_.js.map +1 -0
- package/dist/flatten-Bx2cfvw3.js +37 -0
- package/dist/flatten-Bx2cfvw3.js.map +1 -0
- package/dist/index.js +123 -117
- package/dist/index.js.map +1 -1
- package/dist/record-BQOOi83C.js +134 -0
- package/dist/record-BQOOi83C.js.map +1 -0
- package/dist/record.js +2 -6
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +34 -18
- package/dist/flatten-C1MjkzFh.js +0 -10
- package/dist/flatten-C1MjkzFh.js.map +0 -1
- package/dist/record-Bc0lI9Rq.js +0 -61
- package/dist/record-Bc0lI9Rq.js.map +0 -1
- package/dist/record.js.map +0 -1
- package/dist/schema.tsbuildinfo +0 -1
- package/dist/src/badge.d.ts +0 -74
- package/dist/src/badge.d.ts.map +0 -1
- package/dist/src/badge.js +0 -158
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -292
- package/dist/src/column-schema.d.ts +0 -163
- package/dist/src/column-schema.d.ts.map +0 -1
- package/dist/src/column-schema.js +0 -0
- package/dist/src/component-meta.d.ts +0 -96
- package/dist/src/component-meta.d.ts.map +0 -1
- package/dist/src/component-meta.js +0 -88
- package/dist/src/converter/aggregate.d.ts +0 -127
- package/dist/src/converter/aggregate.d.ts.map +0 -1
- package/dist/src/converter/aggregate.js +0 -235
- package/dist/src/converter/authored.d.ts +0 -43
- package/dist/src/converter/authored.d.ts.map +0 -1
- package/dist/src/converter/authored.js +0 -52
- package/dist/src/converter/heuristics.d.ts +0 -60
- package/dist/src/converter/heuristics.d.ts.map +0 -1
- package/dist/src/converter/heuristics.js +0 -304
- package/dist/src/converter/index.d.ts +0 -51
- package/dist/src/converter/index.d.ts.map +0 -1
- package/dist/src/converter/index.js +0 -195
- package/dist/src/converter/merge.d.ts +0 -102
- package/dist/src/converter/merge.d.ts.map +0 -1
- package/dist/src/converter/merge.js +0 -136
- package/dist/src/converter/scalars.d.ts +0 -46
- package/dist/src/converter/scalars.d.ts.map +0 -1
- package/dist/src/converter/scalars.js +0 -83
- package/dist/src/converter/types.d.ts +0 -157
- package/dist/src/converter/types.d.ts.map +0 -1
- package/dist/src/converter/types.js +0 -5
- package/dist/src/doctype.d.ts +0 -516
- package/dist/src/doctype.d.ts.map +0 -1
- package/dist/src/doctype.js +0 -343
- package/dist/src/field.d.ts +0 -423
- package/dist/src/field.d.ts.map +0 -1
- package/dist/src/field.js +0 -378
- package/dist/src/flatten.d.ts +0 -29
- package/dist/src/flatten.d.ts.map +0 -1
- package/dist/src/flatten.js +0 -38
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -20
- package/dist/src/mode.d.ts +0 -15
- package/dist/src/mode.d.ts.map +0 -1
- package/dist/src/mode.js +0 -0
- package/dist/src/naming.d.ts +0 -80
- package/dist/src/naming.d.ts.map +0 -1
- package/dist/src/naming.js +0 -106
- package/dist/src/record.d.ts +0 -29
- package/dist/src/record.d.ts.map +0 -1
- package/dist/src/record.js +0 -55
- package/dist/src/table.d.ts +0 -33
- package/dist/src/table.d.ts.map +0 -1
- package/dist/src/table.js +0 -25
- package/dist/src/validation.d.ts +0 -54
- package/dist/src/validation.d.ts.map +0 -1
- package/dist/src/validation.js +0 -60
- package/dist/validation-C9P__pRF.js +0 -994
- package/dist/validation-C9P__pRF.js.map +0 -1
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Merge introspected schema facts into an already-authored doctype.
|
|
3
|
-
*
|
|
4
|
-
* The authored doctype is the source of truth. Generation **verifies** it and stamps provenance;
|
|
5
|
-
* it does not overwrite. That polarity is deliberate and load-bearing — a doctype legitimately
|
|
6
|
-
* declares a `primaryKey` the schema cannot express. A natural business key is very often a
|
|
7
|
-
* `UNIQUE` constraint rather than the table's `PRIMARY KEY`, and where a table carries several
|
|
8
|
-
* uniques no rule can pick between them. Overwriting identity from the schema would silently
|
|
9
|
-
* re-key such a doctype on every regeneration and break the handlers that key on the old value.
|
|
10
|
-
*
|
|
11
|
-
* So divergence is **reported, never applied** — a human decides. The only mutation this performs
|
|
12
|
-
* is adding `source: 'introspected'` to fields confirmed to exist in the GraphQL schema.
|
|
13
|
-
*
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
*/
|
|
16
|
-
import { INTROSPECTED_IDENTITY_PROPS } from '../field';
|
|
17
|
-
import { authoredPrimaryKey, flattenAuthored, isAuthoredRecord } from './authored';
|
|
18
|
-
function describe(value) {
|
|
19
|
-
return value === undefined ? '—' : JSON.stringify(value);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Verify an authored doctype against freshly generated output and stamp provenance.
|
|
23
|
-
*
|
|
24
|
-
* @param authored - the doctype as it exists on disk; every key not named below is preserved verbatim
|
|
25
|
-
* @param generated - `convertGraphQLSchema` output for the corresponding GraphQL type. For a
|
|
26
|
-
* `subset` merge this is the **entity**, whose fields are the set the subset is curated from
|
|
27
|
-
* @param options - see {@link MergeOptions}
|
|
28
|
-
* @returns the doctype to write, plus a drift report
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const [generated] = convertGraphQLSchema(introspection, { include: ['Uom'] })
|
|
33
|
-
* const { doctype, drift } = mergeIntrospectedDoctype(JSON.parse(onDisk), generated)
|
|
34
|
-
* if (drift.identityDrift.length) console.warn(drift.identityDrift.join('\n'))
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
export function mergeIntrospectedDoctype(authored, generated, options = {}) {
|
|
40
|
-
const authoredFields = Array.isArray(authored.fields) ? authored.fields.filter(isAuthoredRecord) : [];
|
|
41
|
-
const generatedByName = new Map(generated.fields.map(f => [f.fieldname, f]));
|
|
42
|
-
// Expanding links live in `links`, not `fields`, so a field naming one is modelled, not orphaned.
|
|
43
|
-
const generatedLinkNames = new Set(Object.keys(generated.links ?? {}));
|
|
44
|
-
const drift = {
|
|
45
|
-
doctype: typeof authored.name === 'string' ? authored.name : '(unnamed)',
|
|
46
|
-
mode: 'clean',
|
|
47
|
-
tagged: [],
|
|
48
|
-
orphan: [],
|
|
49
|
-
omitted: [],
|
|
50
|
-
componentDrift: [],
|
|
51
|
-
requiredDrift: [],
|
|
52
|
-
identityDrift: [],
|
|
53
|
-
};
|
|
54
|
-
const tag = (field) => {
|
|
55
|
-
// Containers have no column of their own; recurse and leave the container itself alone.
|
|
56
|
-
if (Array.isArray(field.schema)) {
|
|
57
|
-
return { ...field, schema: field.schema.filter(isAuthoredRecord).map(tag) };
|
|
58
|
-
}
|
|
59
|
-
const name = typeof field.fieldname === 'string' ? field.fieldname : '';
|
|
60
|
-
const match = generatedByName.get(name);
|
|
61
|
-
if (!match) {
|
|
62
|
-
// A computed field declares up front that it has no backing column, so it is not a
|
|
63
|
-
// discrepancy. Everything else is worth surfacing — it may be an app component, or a
|
|
64
|
-
// column that has since been dropped.
|
|
65
|
-
if (field.computed !== true && !generatedLinkNames.has(name))
|
|
66
|
-
drift.orphan.push(name);
|
|
67
|
-
return field;
|
|
68
|
-
}
|
|
69
|
-
drift.tagged.push(name);
|
|
70
|
-
if (match.component !== field.component) {
|
|
71
|
-
drift.componentDrift.push(`${name}: authored=${describe(field.component)} schema=${describe(match.component)}`);
|
|
72
|
-
}
|
|
73
|
-
if (Boolean(match.required) !== Boolean(field.required)) {
|
|
74
|
-
drift.requiredDrift.push(`${name}: authored=${Boolean(field.required)} schema=${Boolean(match.required)}`);
|
|
75
|
-
}
|
|
76
|
-
for (const prop of INTROSPECTED_IDENTITY_PROPS) {
|
|
77
|
-
if (prop === 'fieldname' || prop === 'required')
|
|
78
|
-
continue;
|
|
79
|
-
const authoredValue = field[prop];
|
|
80
|
-
const schemaValue = match[prop];
|
|
81
|
-
// Absent on both sides is agreement, not drift — most fields set none of these.
|
|
82
|
-
if (authoredValue === undefined && schemaValue === undefined)
|
|
83
|
-
continue;
|
|
84
|
-
if (JSON.stringify(authoredValue) !== JSON.stringify(schemaValue)) {
|
|
85
|
-
drift.identityDrift.push(`${name}.${prop}: authored=${describe(authoredValue)} schema=${describe(schemaValue)}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return { ...field, source: 'introspected' };
|
|
89
|
-
};
|
|
90
|
-
const merged = { ...authored, fields: authoredFields.map(tag) };
|
|
91
|
-
// A curated subset omits columns by definition, so the bucket that reports omissions has
|
|
92
|
-
// nothing true to say about one.
|
|
93
|
-
if (!options.subset) {
|
|
94
|
-
const authoredNames = new Set(flattenAuthored(authoredFields).map(f => f.fieldname));
|
|
95
|
-
drift.omitted = generated.fields.map(f => f.fieldname).filter(n => !authoredNames.has(n));
|
|
96
|
-
}
|
|
97
|
-
// Classify identity last, once every field has been compared.
|
|
98
|
-
const authoredPk = authoredPrimaryKey(authored);
|
|
99
|
-
const generatedPk = generated.fields.find(f => f.primaryKey === true);
|
|
100
|
-
if (authoredPk && generatedPk && authoredPk !== generatedPk.fieldname) {
|
|
101
|
-
drift.mode = 'partial';
|
|
102
|
-
drift.reason = `authored primary key '${authoredPk}' is not the derivable '${generatedPk.fieldname}' — left as authored`;
|
|
103
|
-
}
|
|
104
|
-
else if (authoredPk && !generatedPk) {
|
|
105
|
-
drift.mode = 'partial';
|
|
106
|
-
drift.reason = `authored primary key '${authoredPk}' is not derivable from the schema — left as authored`;
|
|
107
|
-
}
|
|
108
|
-
else if (!authoredPk && generatedPk) {
|
|
109
|
-
drift.mode = 'partial';
|
|
110
|
-
drift.reason = `schema suggests '${generatedPk.fieldname}' as primary key but the doctype declares none — not applied`;
|
|
111
|
-
}
|
|
112
|
-
return { doctype: merged, drift };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Render a drift report as human-readable lines. Empty when generation agrees with the doctype.
|
|
116
|
-
*
|
|
117
|
-
* @param drift - a report from {@link mergeIntrospectedDoctype}
|
|
118
|
-
* @returns one line per finding, ready to print
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
export function formatDoctypeDrift(drift) {
|
|
123
|
-
const lines = [];
|
|
124
|
-
if (drift.reason)
|
|
125
|
-
lines.push(` ${drift.doctype}: ${drift.reason}`);
|
|
126
|
-
const bucket = (label, entries) => {
|
|
127
|
-
if (entries.length)
|
|
128
|
-
lines.push(` ${drift.doctype}: ${label} ${entries.join('; ')}`);
|
|
129
|
-
};
|
|
130
|
-
bucket('identity drift', drift.identityDrift);
|
|
131
|
-
bucket('component drift', drift.componentDrift);
|
|
132
|
-
bucket('required drift', drift.requiredDrift);
|
|
133
|
-
bucket('authored fields with no schema field:', drift.orphan);
|
|
134
|
-
bucket('schema fields not modelled:', drift.omitted);
|
|
135
|
-
return lines;
|
|
136
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GraphQL Scalar Type Mappings
|
|
3
|
-
*
|
|
4
|
-
* Maps standard GraphQL scalars and well-known custom scalars to Stonecrop field types.
|
|
5
|
-
* Source-agnostic — covers scalars commonly emitted by PostGraphile, Hasura, Apollo, etc.
|
|
6
|
-
*
|
|
7
|
-
* Users can extend these via the `customScalars` option in `GraphQLConversionOptions`.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
|
-
import type { FieldTemplate } from './types';
|
|
12
|
-
/**
|
|
13
|
-
* Mapping from standard GraphQL scalar types to Stonecrop field types.
|
|
14
|
-
* These are defined by the GraphQL specification and are always available.
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export declare const GQL_SCALAR_MAP: Record<string, FieldTemplate>;
|
|
19
|
-
/**
|
|
20
|
-
* Mapping from well-known custom GraphQL scalars to Stonecrop field types.
|
|
21
|
-
* These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)
|
|
22
|
-
* without baking in knowledge of any specific server.
|
|
23
|
-
*
|
|
24
|
-
* Entries here have lower precedence than `customScalars` from options, but higher
|
|
25
|
-
* precedence than unknown/unmapped scalars.
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare const WELL_KNOWN_SCALARS: Record<string, FieldTemplate>;
|
|
30
|
-
/**
|
|
31
|
-
* Set of scalar type names that are internal to GraphQL servers and should be skipped
|
|
32
|
-
* during field conversion (they don't represent meaningful data fields).
|
|
33
|
-
*
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export declare const INTERNAL_SCALARS: Set<string>;
|
|
37
|
-
/**
|
|
38
|
-
* Build a merged scalar map from the built-in maps and user-provided custom scalars.
|
|
39
|
-
* Precedence (highest to lowest): customScalars → GQL_SCALAR_MAP → WELL_KNOWN_SCALARS
|
|
40
|
-
*
|
|
41
|
-
* @param customScalars - User-provided scalar overrides
|
|
42
|
-
* @returns Merged scalar map
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export declare function buildScalarMap(customScalars?: Record<string, Partial<FieldTemplate>>): Record<string, FieldTemplate>;
|
|
46
|
-
//# sourceMappingURL=scalars.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scalars.d.ts","sourceRoot":"","sources":["../../../src/converter/scalars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAMxD,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAuB5D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAsB,CAAA;AAEnD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAgBpH"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GraphQL Scalar Type Mappings
|
|
3
|
-
*
|
|
4
|
-
* Maps standard GraphQL scalars and well-known custom scalars to Stonecrop field types.
|
|
5
|
-
* Source-agnostic — covers scalars commonly emitted by PostGraphile, Hasura, Apollo, etc.
|
|
6
|
-
*
|
|
7
|
-
* Users can extend these via the `customScalars` option in `GraphQLConversionOptions`.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Mapping from standard GraphQL scalar types to Stonecrop field types.
|
|
13
|
-
* These are defined by the GraphQL specification and are always available.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export const GQL_SCALAR_MAP = {
|
|
18
|
-
String: { component: 'ATextInput' },
|
|
19
|
-
Int: { component: 'ANumericInput' },
|
|
20
|
-
Float: { component: 'ANumericInput' },
|
|
21
|
-
Boolean: { component: 'ACheckbox' },
|
|
22
|
-
ID: { component: 'ATextInput' },
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Mapping from well-known custom GraphQL scalars to Stonecrop field types.
|
|
26
|
-
* These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)
|
|
27
|
-
* without baking in knowledge of any specific server.
|
|
28
|
-
*
|
|
29
|
-
* Entries here have lower precedence than `customScalars` from options, but higher
|
|
30
|
-
* precedence than unknown/unmapped scalars.
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export const WELL_KNOWN_SCALARS = {
|
|
35
|
-
// Arbitrary precision / large numbers — all numeric variants render with ANumericInput.
|
|
36
|
-
BigFloat: { component: 'ANumericInput' },
|
|
37
|
-
BigDecimal: { component: 'ANumericInput' },
|
|
38
|
-
Decimal: { component: 'ANumericInput' },
|
|
39
|
-
BigInt: { component: 'ANumericInput' },
|
|
40
|
-
Long: { component: 'ANumericInput' },
|
|
41
|
-
// Identifiers
|
|
42
|
-
UUID: { component: 'ATextInput' },
|
|
43
|
-
// Date / Time — no dedicated Time SFC exists; Time falls back to a plain text input.
|
|
44
|
-
DateTime: { component: 'ADateTime' },
|
|
45
|
-
Datetime: { component: 'ADateTime' },
|
|
46
|
-
Date: { component: 'ADate' },
|
|
47
|
-
Time: { component: 'ATextInput' },
|
|
48
|
-
Interval: { component: 'ADuration' },
|
|
49
|
-
Duration: { component: 'ADuration' },
|
|
50
|
-
// Structured data
|
|
51
|
-
JSON: { component: 'ACodeEditor' },
|
|
52
|
-
JSONObject: { component: 'ACodeEditor' },
|
|
53
|
-
JsonNode: { component: 'ACodeEditor' },
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Set of scalar type names that are internal to GraphQL servers and should be skipped
|
|
57
|
-
* during field conversion (they don't represent meaningful data fields).
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
export const INTERNAL_SCALARS = new Set(['Cursor']);
|
|
62
|
-
/**
|
|
63
|
-
* Build a merged scalar map from the built-in maps and user-provided custom scalars.
|
|
64
|
-
* Precedence (highest to lowest): customScalars → GQL_SCALAR_MAP → WELL_KNOWN_SCALARS
|
|
65
|
-
*
|
|
66
|
-
* @param customScalars - User-provided scalar overrides
|
|
67
|
-
* @returns Merged scalar map
|
|
68
|
-
* @public
|
|
69
|
-
*/
|
|
70
|
-
export function buildScalarMap(customScalars) {
|
|
71
|
-
const merged = { ...WELL_KNOWN_SCALARS };
|
|
72
|
-
// Standard scalars override well-known
|
|
73
|
-
for (const [key, value] of Object.entries(GQL_SCALAR_MAP)) {
|
|
74
|
-
merged[key] = value;
|
|
75
|
-
}
|
|
76
|
-
// Custom scalars override everything
|
|
77
|
-
if (customScalars) {
|
|
78
|
-
for (const [key, value] of Object.entries(customScalars)) {
|
|
79
|
-
merged[key] = { component: value.component ?? 'ATextInput' };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return merged;
|
|
83
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for the GraphQL introspection to Stonecrop schema converter.
|
|
3
|
-
* Source-agnostic — works with any GraphQL server (PostGraphile, Hasura, Apollo, etc.)
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
import type { IntrospectionQuery } from 'graphql';
|
|
7
|
-
import type { GraphQLObjectType, GraphQLField } from 'graphql';
|
|
8
|
-
import type { ValueField } from '../field';
|
|
9
|
-
/**
|
|
10
|
-
* The component a GraphQL scalar maps to.
|
|
11
|
-
*
|
|
12
|
-
* A one-property interface rather than a bare string so `customScalars` stays extensible: an
|
|
13
|
-
* override is a `Partial<FieldTemplate>`, and widening this later does not change that signature.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export interface FieldTemplate {
|
|
18
|
-
/** The Vue component name to render fields of this scalar type (e.g. `'ATextInput'`). */
|
|
19
|
-
component: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Input source for the GraphQL schema converter.
|
|
23
|
-
* Accepts either a standard GraphQL introspection result or an SDL string.
|
|
24
|
-
*
|
|
25
|
-
* - `IntrospectionQuery`: The raw result of a GraphQL introspection query (from any server)
|
|
26
|
-
* - `string`: An SDL (Schema Definition Language) string
|
|
27
|
-
*
|
|
28
|
-
* Note: URL fetching is intentionally not supported in the library API.
|
|
29
|
-
* Use the CLI (`stonecrop-schema generate --endpoint <url>`) for endpoint fetching,
|
|
30
|
-
* or fetch the introspection result yourself and pass it in.
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export type IntrospectionSource = IntrospectionQuery | string;
|
|
35
|
-
/**
|
|
36
|
-
* Options for converting a GraphQL schema to Stonecrop doctype schemas.
|
|
37
|
-
* All hooks are optional — sensible defaults are provided for common GraphQL patterns.
|
|
38
|
-
*
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
export interface GraphQLConversionOptions {
|
|
42
|
-
/**
|
|
43
|
-
* GraphQL type names to exclude from conversion.
|
|
44
|
-
* Applied after `isEntityType` filtering.
|
|
45
|
-
*/
|
|
46
|
-
exclude?: string[];
|
|
47
|
-
/**
|
|
48
|
-
* Whitelist of GraphQL type names to convert.
|
|
49
|
-
* When provided, only these types are considered (after `isEntityType` filtering).
|
|
50
|
-
*/
|
|
51
|
-
include?: string[];
|
|
52
|
-
/**
|
|
53
|
-
* Emit a doctype under a different name than its GraphQL type. Key is the GraphQL type name,
|
|
54
|
-
* value is the doctype `name`; `slug` is derived from the value.
|
|
55
|
-
*
|
|
56
|
-
* This exists for the case where a doctype is not one-to-one with a table — a second view over
|
|
57
|
-
* an existing type, say, distinguished only by presentation. Without it the converter can only
|
|
58
|
-
* ever name a doctype after its type.
|
|
59
|
-
*
|
|
60
|
-
* Keep it consistent with the middleware's `tables` option, which maps the resulting doctype
|
|
61
|
-
* name to its SQL target.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* { Plan: 'Planner' } // emits a doctype named Planner, slug 'planner', from type Plan
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
doctypeNames?: Record<string, string>;
|
|
69
|
-
/**
|
|
70
|
-
* Called with any advisory message raised during conversion — currently only the
|
|
71
|
-
* un-normalized-PostGraphile warning. Left to the caller so the library never writes to the
|
|
72
|
-
* console itself.
|
|
73
|
-
*/
|
|
74
|
-
onWarning?: (message: string) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Map custom or non-standard GraphQL scalar types to the component that renders them.
|
|
77
|
-
* Merged with the built-in scalar maps (GQL_SCALAR_MAP + WELL_KNOWN_SCALARS).
|
|
78
|
-
* User-provided entries take highest precedence.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* {
|
|
83
|
-
* MyCustomMoney: { component: 'ANumericInput' },
|
|
84
|
-
* PostGISPoint: { component: 'ATextInput' }
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
customScalars?: Record<string, Partial<FieldTemplate>>;
|
|
89
|
-
/**
|
|
90
|
-
* Custom function to determine if a GraphQL object type represents an entity (→ doctype).
|
|
91
|
-
* When provided, replaces the default heuristic entirely.
|
|
92
|
-
*
|
|
93
|
-
* The default heuristic excludes types matching synthetic patterns:
|
|
94
|
-
* `*Connection`, `*Edge`, `*Input`, `*Patch`, `*Payload`, `*Condition`,
|
|
95
|
-
* `*Filter`, `*OrderBy`, `*Aggregate`, `Query`, `Mutation`, `Subscription`, `__*`.
|
|
96
|
-
*
|
|
97
|
-
* @param typeName - The GraphQL type name
|
|
98
|
-
* @param type - The full GraphQL object type definition
|
|
99
|
-
* @returns `true` if this type should become a Stonecrop doctype
|
|
100
|
-
*/
|
|
101
|
-
isEntityType?: (typeName: string, type: GraphQLObjectType) => boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Custom function to filter which fields on an entity type are included.
|
|
104
|
-
* When provided, replaces the default field filter.
|
|
105
|
-
*
|
|
106
|
-
* The default filter excludes `nodeId`, `__typename`, and `clientMutationId`.
|
|
107
|
-
*
|
|
108
|
-
* @param fieldName - The GraphQL field name
|
|
109
|
-
* @param field - The full GraphQL field definition
|
|
110
|
-
* @param parentType - The parent entity type
|
|
111
|
-
* @returns `true` if this field should be included
|
|
112
|
-
*/
|
|
113
|
-
isEntityField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Escape hatch: fully override the classification of a specific field.
|
|
116
|
-
* When this returns a non-null value, it is used as the field definition
|
|
117
|
-
* (merged with the field name). Return `null` to fall through to default classification.
|
|
118
|
-
*
|
|
119
|
-
* @param fieldName - The GraphQL field name
|
|
120
|
-
* @param field - The full GraphQL field definition
|
|
121
|
-
* @param parentType - The parent entity type
|
|
122
|
-
* @returns Partial field meta to use, or `null` for default behavior
|
|
123
|
-
*/
|
|
124
|
-
classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Omit<Partial<ValueField>, 'kind'> | null;
|
|
125
|
-
/**
|
|
126
|
-
* Include `_graphqlType` and `_unmapped` metadata on converted fields.
|
|
127
|
-
* Useful for debugging conversions. Defaults to `false`.
|
|
128
|
-
*/
|
|
129
|
-
includeUnmappedMeta?: boolean;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Extended field metadata with optional GraphQL conversion metadata.
|
|
133
|
-
* Only present when `includeUnmappedMeta` is enabled.
|
|
134
|
-
*
|
|
135
|
-
* @public
|
|
136
|
-
*/
|
|
137
|
-
export interface GraphQLConversionFieldMeta extends ValueField {
|
|
138
|
-
/** Original GraphQL type name (for debugging/reference) */
|
|
139
|
-
_graphqlType?: string;
|
|
140
|
-
/** Marks fields that couldn't be automatically mapped */
|
|
141
|
-
_unmapped?: boolean;
|
|
142
|
-
/** Marks relationship fields that belong in `links`, not `fields` */
|
|
143
|
-
_isLink?: boolean;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Output of GraphQL schema conversion — one per entity type.
|
|
147
|
-
*
|
|
148
|
-
* @public
|
|
149
|
-
*/
|
|
150
|
-
export interface ConvertedGraphQLDoctype extends Omit<DoctypeMeta, 'fields'> {
|
|
151
|
-
/** Field definitions — GraphQL conversion metadata stripped; same shape as DoctypeMeta.fields */
|
|
152
|
-
fields: ValueField[];
|
|
153
|
-
/** Original GraphQL type name (for debugging/reference) */
|
|
154
|
-
_graphqlTypeName?: string;
|
|
155
|
-
}
|
|
156
|
-
import type { DoctypeMeta } from '../doctype';
|
|
157
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/converter/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC7B,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,MAAM,CAAA;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAErC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAErC;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;IAEtD;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAA;IAErE;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAA;IAEpH;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CACf,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACrC,UAAU,EAAE,iBAAiB,KACzB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IAE7C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA2B,SAAQ,UAAU;IAC7D,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC3E,iGAAiG;IACjG,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAGD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
|