@stonecrop/schema 0.28.0 → 0.30.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/dist/cli.js +1 -1
- package/dist/flatten-C1MjkzFh.js +10 -0
- package/dist/flatten-C1MjkzFh.js.map +1 -0
- package/dist/index.js +90 -122
- package/dist/index.js.map +1 -1
- package/dist/record-Bc0lI9Rq.js +61 -0
- package/dist/record-Bc0lI9Rq.js.map +1 -0
- package/dist/record.js +6 -0
- package/dist/record.js.map +1 -0
- package/dist/schema.d.ts +34 -0
- package/dist/src/field.d.ts +2 -21
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +4 -32
- package/dist/src/flatten.d.ts +29 -0
- package/dist/src/flatten.d.ts.map +1 -0
- package/dist/src/flatten.js +38 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/record.d.ts +29 -0
- package/dist/src/record.d.ts.map +1 -0
- package/dist/src/record.js +55 -0
- package/dist/{validation-BjRDR6sh.js → validation-C9P__pRF.js} +62 -68
- package/dist/validation-C9P__pRF.js.map +1 -0
- package/package.json +1 -1
- package/dist/validation-BjRDR6sh.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../src/flatten.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC,EAAE,CAU1F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively flatten Fieldset containers into a flat array of non-container fields.
|
|
3
|
+
* Fieldset entries are replaced by their children; all other fields pass through.
|
|
4
|
+
*
|
|
5
|
+
* A fieldset is a layout grouping, not a scope: every field inside one is a field of the doctype,
|
|
6
|
+
* with a column of its own and a name a link can bind to. Anything asking "what does this doctype
|
|
7
|
+
* declare" must therefore descend, and the two ways to get that wrong point opposite ways — the
|
|
8
|
+
* SELECT builder would omit real columns, while a validator would report a working declaration as
|
|
9
|
+
* broken.
|
|
10
|
+
*
|
|
11
|
+
* Lives here rather than in the adapter because both sides need it: the middleware builds SQL from
|
|
12
|
+
* it, and `DoctypeMeta`'s own validation asks the same question at the load gate. It sat in the
|
|
13
|
+
* adapter while the validator hand-rolled a top-level-only scan, and that is exactly the second
|
|
14
|
+
* failure this comment names — a `displayField` inside a fieldset was rejected at authoring time
|
|
15
|
+
* and would have worked at runtime.
|
|
16
|
+
*
|
|
17
|
+
* A module of its own, importing nothing at runtime, because callers need the descent without
|
|
18
|
+
* needing the rest of `field.ts` — which defines the Zod schemas, so a runtime edge to it is a
|
|
19
|
+
* runtime edge to Zod. Zod reaching a Nitro SSR entry collides with the `process` Nitro imports
|
|
20
|
+
* there and takes the server down with a `SyntaxError` per request, which no build reports.
|
|
21
|
+
* `field.ts` still calls this and `index.ts` still exports it, so nothing outside moves.
|
|
22
|
+
*
|
|
23
|
+
* @param fields - the doctype's top-level fields
|
|
24
|
+
* @returns every non-container field, fieldset children included
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export function flattenFields(fields) {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (const f of fields) {
|
|
30
|
+
if (f.kind === 'fieldset') {
|
|
31
|
+
result.push(...flattenFields(f.schema));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
result.push(f);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ export type { InteractionMode } from './mode';
|
|
|
2
2
|
export { TableViewConfig } from './table';
|
|
3
3
|
export { CANONICAL_COMPONENTS, COMPONENT_CATEGORY, COMPONENT_LINK_EXPANSION, componentCategory, componentLinkExpansion, resolveLinkRenderMode, type ComponentCategory, type LinkExpansion, type LinkRenderMode, } from './component-meta';
|
|
4
4
|
export type { DoctypeField, FieldOptions, FieldValidation, FieldsetField, TableField, ValueField } from './field';
|
|
5
|
-
export { DoctypeFieldSchema, FieldsetFieldSchema,
|
|
5
|
+
export { DoctypeFieldSchema, FieldsetFieldSchema, getDisplayField, getPrimaryKeyField, getRecordIdentity, getRecordIdField, INTROSPECTED_IDENTITY_PROPS, normalizeFieldKind, inferFieldKind, stripFieldKind, TableFieldSchema, ValueFieldSchema, } from './field';
|
|
6
|
+
export { flattenFields } from './flatten';
|
|
7
|
+
export { unwrapInlineLinks } from './record';
|
|
6
8
|
export { ActionDefinition, TriggerDefinition, WorkflowLayout, WorkflowMeta, getDoctypeSlug, isActionAllowedInState, LINK_DISPLAY_SUFFIX, linkDisplayFieldname, } from './doctype';
|
|
7
9
|
export type { Cardinality, CustomFetch, DataClient, DoctypeContext, DoctypeMeta, DoctypeRef, FetchStrategy, GetRecordOptions, GetRecordResult, GetRecordsOptions, GetRecordsResult, LazyFetch, LinkDeclaration, SerializedFunction, SyncFetch, } from './doctype';
|
|
8
10
|
export { parseDoctype, parseField, validateDoctype, validateField, type ValidationError, type ValidationResult, } from './validation';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,kBAAkB,CAAA;AAGzB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACjH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,kBAAkB,CAAA;AAGzB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACjH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAGzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAK5C,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,GACpB,MAAM,WAAW,CAAA;AAClB,YAAY,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,SAAS,GACT,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,WAAW,GAChB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGtH,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,YAAY,EACX,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,YAAY,EACZ,aAAa,GACb,MAAM,SAAS,CAAA;AAChB,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,aAAa,GACb,MAAM,SAAS,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
export { TableViewConfig } from './table';
|
|
3
3
|
// Component → semantic category — the single source of "what kind of value does this component render"
|
|
4
4
|
export { CANONICAL_COMPONENTS, COMPONENT_CATEGORY, COMPONENT_LINK_EXPANSION, componentCategory, componentLinkExpansion, resolveLinkRenderMode, } from './component-meta';
|
|
5
|
-
export { DoctypeFieldSchema, FieldsetFieldSchema,
|
|
5
|
+
export { DoctypeFieldSchema, FieldsetFieldSchema, getDisplayField, getPrimaryKeyField, getRecordIdentity, getRecordIdField, INTROSPECTED_IDENTITY_PROPS, normalizeFieldKind, inferFieldKind, stripFieldKind, TableFieldSchema, ValueFieldSchema, } from './field';
|
|
6
|
+
// Field descent, kept a leaf so a caller needing only the descent does not take on zod
|
|
7
|
+
export { flattenFields } from './flatten';
|
|
8
|
+
// Record shaping — the single definition of what a record looks like on its way to the server
|
|
9
|
+
export { unwrapInlineLinks } from './record';
|
|
6
10
|
// Doctype schema
|
|
7
11
|
// ActionDefinition and WorkflowMeta are exported as values (Zod schemas) so consumers can use
|
|
8
12
|
// .safeParse(), .shape, etc. at runtime. TypeScript types are inferred from the same exports.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DoctypeField } from './field';
|
|
2
|
+
/**
|
|
3
|
+
* Reduce a record's *inline* link values to the ids that get persisted.
|
|
4
|
+
*
|
|
5
|
+
* The adapter returns an inline link as `{ id, displayText }`, so that is what a record holds
|
|
6
|
+
* everywhere it is read — the store, a list row, a form field. A column takes the id alone, so
|
|
7
|
+
* this is the single definition of the shape a record leaves in, and it belongs at the boundary
|
|
8
|
+
* a record crosses on its way to the server, never on the way into the store.
|
|
9
|
+
*
|
|
10
|
+
* Doing it on the way in destroys the text the adapter looked up: nothing else holds it, so the
|
|
11
|
+
* field that resolved a moment ago renders its raw id, and the same record then renders
|
|
12
|
+
* differently depending on whether anything had edited the form yet. That is the bug this exists
|
|
13
|
+
* to prevent, and its damage is a wrong render, not a throw.
|
|
14
|
+
*
|
|
15
|
+
* Only *inline* links may be reduced. An inline link's value is indistinguishable by inspection
|
|
16
|
+
* from an expanded one (`{ id, ...the whole target record }`), so `component` — which states
|
|
17
|
+
* which of the two a field is — is what tells them apart, via {@link componentLinkExpansion}.
|
|
18
|
+
* Reducing an expanded link would send the id in place of the record.
|
|
19
|
+
*
|
|
20
|
+
* Fieldsets are descended into in both shapes a record appears in: flat, as the store and the
|
|
21
|
+
* server hold it, and nested under the fieldset's own key, as a form emits it.
|
|
22
|
+
*
|
|
23
|
+
* @param fields - the doctype's top-level fields
|
|
24
|
+
* @param record - the record to reduce; not mutated
|
|
25
|
+
* @returns a shallow copy with every inline link reduced to its id
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare function unwrapInlineLinks(fields: readonly DoctypeField[], record: Record<string, any>): Record<string, any>;
|
|
29
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAWnH"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { componentLinkExpansion } from './component-meta';
|
|
2
|
+
import { flattenFields } from './flatten';
|
|
3
|
+
/**
|
|
4
|
+
* Reduce a record's *inline* link values to the ids that get persisted.
|
|
5
|
+
*
|
|
6
|
+
* The adapter returns an inline link as `{ id, displayText }`, so that is what a record holds
|
|
7
|
+
* everywhere it is read — the store, a list row, a form field. A column takes the id alone, so
|
|
8
|
+
* this is the single definition of the shape a record leaves in, and it belongs at the boundary
|
|
9
|
+
* a record crosses on its way to the server, never on the way into the store.
|
|
10
|
+
*
|
|
11
|
+
* Doing it on the way in destroys the text the adapter looked up: nothing else holds it, so the
|
|
12
|
+
* field that resolved a moment ago renders its raw id, and the same record then renders
|
|
13
|
+
* differently depending on whether anything had edited the form yet. That is the bug this exists
|
|
14
|
+
* to prevent, and its damage is a wrong render, not a throw.
|
|
15
|
+
*
|
|
16
|
+
* Only *inline* links may be reduced. An inline link's value is indistinguishable by inspection
|
|
17
|
+
* from an expanded one (`{ id, ...the whole target record }`), so `component` — which states
|
|
18
|
+
* which of the two a field is — is what tells them apart, via {@link componentLinkExpansion}.
|
|
19
|
+
* Reducing an expanded link would send the id in place of the record.
|
|
20
|
+
*
|
|
21
|
+
* Fieldsets are descended into in both shapes a record appears in: flat, as the store and the
|
|
22
|
+
* server hold it, and nested under the fieldset's own key, as a form emits it.
|
|
23
|
+
*
|
|
24
|
+
* @param fields - the doctype's top-level fields
|
|
25
|
+
* @param record - the record to reduce; not mutated
|
|
26
|
+
* @returns a shallow copy with every inline link reduced to its id
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export function unwrapInlineLinks(fields, record) {
|
|
30
|
+
const inline = new Set(flattenFields(fields)
|
|
31
|
+
.filter(field => field.kind === 'field' && Boolean(field.doctype))
|
|
32
|
+
.filter(field => componentLinkExpansion(field.component) === 'inline')
|
|
33
|
+
.map(field => field.fieldname));
|
|
34
|
+
if (inline.size === 0)
|
|
35
|
+
return record;
|
|
36
|
+
const fieldsets = new Set(fields.filter(field => field.kind === 'fieldset').map(field => field.fieldname));
|
|
37
|
+
return unwrapWith(inline, fieldsets, record);
|
|
38
|
+
}
|
|
39
|
+
function unwrapWith(inline, fieldsets, record) {
|
|
40
|
+
const result = { ...record };
|
|
41
|
+
for (const [key, value] of Object.entries(result)) {
|
|
42
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
43
|
+
continue;
|
|
44
|
+
if (inline.has(key)) {
|
|
45
|
+
// `'id' in value` rather than a truthiness test: an inline link that was never resolved
|
|
46
|
+
// is still a bare scalar, and reducing it a second time would be a no-op at best.
|
|
47
|
+
if ('id' in value)
|
|
48
|
+
result[key] = value.id;
|
|
49
|
+
}
|
|
50
|
+
else if (fieldsets.has(key)) {
|
|
51
|
+
result[key] = unwrapWith(inline, fieldsets, value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { f as T } from "./flatten-C1MjkzFh.js";
|
|
1
2
|
import { isScalarType as J, isEnumType as Q, isObjectType as D, isNonNullType as E, isListType as Y, isNamedType as H, buildSchema as Z, buildClientSchema as X } from "graphql";
|
|
2
3
|
import { z as n } from "zod";
|
|
3
4
|
function I(e) {
|
|
@@ -14,13 +15,13 @@ function ee(e) {
|
|
|
14
15
|
const t = x(e.fields.filter(I)).find((i) => i.primaryKey === !0);
|
|
15
16
|
return typeof t?.fieldname == "string" ? t.fieldname : void 0;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function He(e) {
|
|
18
19
|
return e.replace(/_([a-z])/g, (t, i) => i.toUpperCase());
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function Ze(e) {
|
|
21
22
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function Xe(e) {
|
|
24
25
|
return e.split("_").map((t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()).join(" ");
|
|
25
26
|
}
|
|
26
27
|
function te(e) {
|
|
@@ -30,10 +31,10 @@ function te(e) {
|
|
|
30
31
|
function ne(e) {
|
|
31
32
|
return e.split(/[-_\s]+/).map((t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()).join("");
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function k(e) {
|
|
34
35
|
return e.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function et(e) {
|
|
37
38
|
return e.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
38
39
|
}
|
|
39
40
|
const ie = {
|
|
@@ -141,7 +142,7 @@ function he(e, t, i, a = {}) {
|
|
|
141
142
|
if (o.name === "ID") {
|
|
142
143
|
const g = ne(e);
|
|
143
144
|
if (i.has(g))
|
|
144
|
-
return s.component = "AFormLink", s.doctype =
|
|
145
|
+
return s.component = "AFormLink", s.doctype = k(g), s;
|
|
145
146
|
}
|
|
146
147
|
const m = $[o.name];
|
|
147
148
|
return m ? s.component = m.component : (s._unmapped = !0, a.includeUnmappedMeta && (s._graphqlType = o.name)), s;
|
|
@@ -150,9 +151,9 @@ function he(e, t, i, a = {}) {
|
|
|
150
151
|
return s.component = "ADropdown", s.options = o.getValues().map((m) => m.name), s;
|
|
151
152
|
if (D(o)) {
|
|
152
153
|
if (!d && i.has(o.name))
|
|
153
|
-
return s.component = "AFormLink", s.doctype =
|
|
154
|
+
return s.component = "AFormLink", s.doctype = k(o.name), s;
|
|
154
155
|
const m = fe(o);
|
|
155
|
-
return m && i.has(m) ? (s.component = "ATable", s._isLink = !0, s.doctype =
|
|
156
|
+
return m && i.has(m) ? (s.component = "ATable", s._isLink = !0, s.doctype = k(m), s.cardinality = "noneOrMany", s) : d && i.has(o.name) ? (s.component = "ATable", s._isLink = !0, s.doctype = k(o.name), s.cardinality = "noneOrMany", s) : (s._unmapped = !0, a.includeUnmappedMeta && (s._graphqlType = o.name), s);
|
|
156
157
|
}
|
|
157
158
|
return s._unmapped = !0, a.includeUnmappedMeta && (s._graphqlType = o.name), s;
|
|
158
159
|
}
|
|
@@ -475,7 +476,7 @@ const ve = /* @__PURE__ */ ge(Fe), we = n.object({
|
|
|
475
476
|
}).meta({
|
|
476
477
|
title: "TableViewConfig",
|
|
477
478
|
description: "JSON-safe view configuration for table fields in doctype authoring"
|
|
478
|
-
}),
|
|
479
|
+
}), Se = n.union([
|
|
479
480
|
n.array(n.string()),
|
|
480
481
|
// Select choices: ["A", "B", "C"]
|
|
481
482
|
n.record(n.string(), n.unknown())
|
|
@@ -483,7 +484,7 @@ const ve = /* @__PURE__ */ ge(Fe), we = n.object({
|
|
|
483
484
|
]).meta({
|
|
484
485
|
title: "FieldOptions",
|
|
485
486
|
description: "Field options - flexible bag for type-specific configuration"
|
|
486
|
-
}),
|
|
487
|
+
}), ke = n.looseObject({
|
|
487
488
|
/** Error message to display when validation fails */
|
|
488
489
|
errorMessage: n.string()
|
|
489
490
|
}).meta({
|
|
@@ -522,22 +523,16 @@ const De = [
|
|
|
522
523
|
function N(e) {
|
|
523
524
|
return T(e).find((t) => t.kind === "field" && !!t.primaryKey);
|
|
524
525
|
}
|
|
525
|
-
function T(e) {
|
|
526
|
-
const t = [];
|
|
527
|
-
for (const i of e)
|
|
528
|
-
i.kind === "fieldset" ? t.push(...T(i.schema)) : t.push(i);
|
|
529
|
-
return t;
|
|
530
|
-
}
|
|
531
526
|
function je(e, t) {
|
|
532
527
|
if (t)
|
|
533
528
|
return T(e).find(
|
|
534
529
|
(i) => i.kind === "field" && !i.computed && i.fieldname === t
|
|
535
530
|
);
|
|
536
531
|
}
|
|
537
|
-
function
|
|
532
|
+
function tt(e) {
|
|
538
533
|
return N(e)?.fieldname ?? "id";
|
|
539
534
|
}
|
|
540
|
-
function
|
|
535
|
+
function nt(e, t) {
|
|
541
536
|
const i = N(e), a = i ? [t[i.fieldname], t.id] : [t.id];
|
|
542
537
|
for (const o of a) {
|
|
543
538
|
if (typeof o == "number") return String(o);
|
|
@@ -561,12 +556,12 @@ function Le() {
|
|
|
561
556
|
mask: n.string().optional(),
|
|
562
557
|
format: n.string().optional(),
|
|
563
558
|
mode: n.enum(["edit", "read", "display"]).optional(),
|
|
564
|
-
options:
|
|
559
|
+
options: Se.optional(),
|
|
565
560
|
required: n.boolean().optional(),
|
|
566
561
|
readOnly: n.boolean().optional(),
|
|
567
562
|
hidden: n.boolean().optional(),
|
|
568
563
|
default: n.unknown().optional(),
|
|
569
|
-
validation:
|
|
564
|
+
validation: ke.optional(),
|
|
570
565
|
cardinality: n.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).optional(),
|
|
571
566
|
source: n.literal("introspected").optional()
|
|
572
567
|
}).meta({ title: "ValueField" }), t = n.object({
|
|
@@ -591,7 +586,7 @@ function Le() {
|
|
|
591
586
|
}).meta({ title: "FieldsetField" }), o = n.discriminatedUnion("kind", [e, a, t]);
|
|
592
587
|
return i = n.preprocess(M, o), { ValueFieldSchema: e, TableFieldSchema: t, FieldsetFieldSchema: a, DoctypeFieldSchema: i };
|
|
593
588
|
}
|
|
594
|
-
const _ = Le(),
|
|
589
|
+
const _ = Le(), it = _.ValueFieldSchema, at = _.FieldsetFieldSchema, ot = _.TableFieldSchema, q = _.DoctypeFieldSchema, Ie = n.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
595
590
|
title: "Cardinality",
|
|
596
591
|
description: "Cardinality for relationship links between doctypes"
|
|
597
592
|
}), Ce = n.object({
|
|
@@ -672,7 +667,7 @@ const _ = Le(), nt = _.ValueFieldSchema, it = _.FieldsetFieldSchema, at = _.Tabl
|
|
|
672
667
|
title: "TriggerDefinition",
|
|
673
668
|
description: "Reactive field-validation trigger — advisory client-side"
|
|
674
669
|
});
|
|
675
|
-
function
|
|
670
|
+
function rt(e, t) {
|
|
676
671
|
const i = e.allowedStates;
|
|
677
672
|
return !i || i.length === 0 ? !0 : i.includes(t);
|
|
678
673
|
}
|
|
@@ -749,10 +744,10 @@ const Ee = n.record(
|
|
|
749
744
|
}
|
|
750
745
|
});
|
|
751
746
|
function K(e) {
|
|
752
|
-
return e.slug ||
|
|
747
|
+
return e.slug || k(e.name);
|
|
753
748
|
}
|
|
754
749
|
const ze = "__display";
|
|
755
|
-
function
|
|
750
|
+
function st(e) {
|
|
756
751
|
return `${e}${ze}`;
|
|
757
752
|
}
|
|
758
753
|
function W(e) {
|
|
@@ -766,7 +761,7 @@ function Me(e, t) {
|
|
|
766
761
|
const { source: o, ...c } = i;
|
|
767
762
|
return {
|
|
768
763
|
name: a,
|
|
769
|
-
slug:
|
|
764
|
+
slug: k(a),
|
|
770
765
|
fields: [{ ...c, primaryKey: !0, ...o === void 0 ? {} : { source: o } }]
|
|
771
766
|
};
|
|
772
767
|
}
|
|
@@ -788,7 +783,7 @@ function Ke(e) {
|
|
|
788
783
|
}).map((a) => a.name)
|
|
789
784
|
);
|
|
790
785
|
}
|
|
791
|
-
function
|
|
786
|
+
function lt(e, t = {}) {
|
|
792
787
|
const i = new Set(e.map((c) => c.name)), a = /* @__PURE__ */ new Set(), o = Ke(e);
|
|
793
788
|
return e.flatMap((c) => {
|
|
794
789
|
const d = `/${K(c)}`, $ = o.has(c.name) ? { ...c, route: `${d}/:id` } : c, s = { generated: $, basis: $, subset: !1 };
|
|
@@ -820,7 +815,7 @@ function st(e, t = {}) {
|
|
|
820
815
|
function j(e) {
|
|
821
816
|
return e === void 0 ? "—" : JSON.stringify(e);
|
|
822
817
|
}
|
|
823
|
-
function
|
|
818
|
+
function ct(e, t, i = {}) {
|
|
824
819
|
const a = Array.isArray(e.fields) ? e.fields.filter(I) : [], o = new Map(t.fields.map((p) => [p.fieldname, p])), c = new Set(Object.keys(t.links ?? {})), d = {
|
|
825
820
|
doctype: typeof e.name == "string" ? e.name : "(unnamed)",
|
|
826
821
|
mode: "clean",
|
|
@@ -851,7 +846,7 @@ function lt(e, t, i = {}) {
|
|
|
851
846
|
const m = ee(e), g = t.fields.find((p) => p.primaryKey === !0);
|
|
852
847
|
return m && g && m !== g.fieldname ? (d.mode = "partial", d.reason = `authored primary key '${m}' is not the derivable '${g.fieldname}' — left as authored`) : m && !g ? (d.mode = "partial", d.reason = `authored primary key '${m}' is not derivable from the schema — left as authored`) : !m && g && (d.mode = "partial", d.reason = `schema suggests '${g.fieldname}' as primary key but the doctype declares none — not applied`), { doctype: s, drift: d };
|
|
853
848
|
}
|
|
854
|
-
function
|
|
849
|
+
function ut(e) {
|
|
855
850
|
const t = [];
|
|
856
851
|
e.reason && t.push(` ${e.doctype}: ${e.reason}`);
|
|
857
852
|
const i = (a, o) => {
|
|
@@ -859,7 +854,7 @@ function ct(e) {
|
|
|
859
854
|
};
|
|
860
855
|
return i("identity drift", e.identityDrift), i("component drift", e.componentDrift), i("required drift", e.requiredDrift), i("authored fields with no schema field:", e.orphan), i("schema fields not modelled:", e.omitted), t;
|
|
861
856
|
}
|
|
862
|
-
function
|
|
857
|
+
function dt(e, t = {}) {
|
|
863
858
|
const i = We(e), a = i.getTypeMap(), o = /* @__PURE__ */ new Set(), c = i.getQueryType(), d = i.getMutationType(), $ = i.getSubscriptionType();
|
|
864
859
|
c && o.add(c.name), d && o.add(d.name), $ && o.add($.name);
|
|
865
860
|
const s = t.isEntityType ?? ce, m = /* @__PURE__ */ new Set();
|
|
@@ -883,10 +878,10 @@ function ut(e, t = {}) {
|
|
|
883
878
|
`${f}: schema exposes both 'id' (Relay identifier) and 'rowId' (the real column). Skipping 'id' and emitting 'rowId' verbatim — no primary key can be derived. Override the '_attributeName' and 'nodeIdFieldName' inflectors so the column keeps its own name.`
|
|
884
879
|
);
|
|
885
880
|
const b = Object.entries(r).filter(
|
|
886
|
-
([h,
|
|
887
|
-
).map(([h,
|
|
881
|
+
([h, S]) => p(h, S, u) && !(l && h === "id")
|
|
882
|
+
).map(([h, S]) => {
|
|
888
883
|
if (t.classifyField) {
|
|
889
|
-
const A = t.classifyField(h,
|
|
884
|
+
const A = t.classifyField(h, S, u);
|
|
890
885
|
if (A != null)
|
|
891
886
|
return {
|
|
892
887
|
kind: "field",
|
|
@@ -896,23 +891,23 @@ function ut(e, t = {}) {
|
|
|
896
891
|
...A
|
|
897
892
|
};
|
|
898
893
|
}
|
|
899
|
-
return he(h,
|
|
894
|
+
return he(h, S, m, t);
|
|
900
895
|
}), F = b.find(
|
|
901
896
|
(h) => h.fieldname === "id" && h.required && !h.doctype && !h._isLink
|
|
902
897
|
)?.fieldname, w = {}, V = b.filter((h) => h._isLink && h.doctype && h.cardinality ? (w[h.fieldname] = {
|
|
903
898
|
target: h.doctype,
|
|
904
899
|
cardinality: h.cardinality
|
|
905
900
|
}, !1) : !0).map((h) => {
|
|
906
|
-
const
|
|
901
|
+
const S = h.fieldname === F ? { primaryKey: !0 } : {};
|
|
907
902
|
if (!t.includeUnmappedMeta) {
|
|
908
903
|
const { _graphqlType: Ve, _unmapped: Be, _isLink: Ge, ...G } = h;
|
|
909
|
-
return Object.assign(G,
|
|
904
|
+
return Object.assign(G, S, { source: "introspected" });
|
|
910
905
|
}
|
|
911
906
|
const { _isLink: A, ...B } = h;
|
|
912
|
-
return Object.assign(B,
|
|
907
|
+
return Object.assign(B, S, { source: "introspected" });
|
|
913
908
|
}), R = t.doctypeNames?.[f] ?? f, O = {
|
|
914
909
|
name: R,
|
|
915
|
-
slug:
|
|
910
|
+
slug: k(R),
|
|
916
911
|
fields: V
|
|
917
912
|
};
|
|
918
913
|
Object.keys(w).length > 0 && (O.links = w), t.includeUnmappedMeta && (O._graphqlTypeName = f), y.push(O);
|
|
@@ -922,7 +917,7 @@ function ut(e, t = {}) {
|
|
|
922
917
|
function We(e) {
|
|
923
918
|
return typeof e == "string" ? Z(e) : X(e);
|
|
924
919
|
}
|
|
925
|
-
function
|
|
920
|
+
function pt(e) {
|
|
926
921
|
const t = q.safeParse(e);
|
|
927
922
|
return t.success ? { success: !0, errors: [] } : {
|
|
928
923
|
success: !1,
|
|
@@ -932,7 +927,7 @@ function dt(e) {
|
|
|
932
927
|
}))
|
|
933
928
|
};
|
|
934
929
|
}
|
|
935
|
-
function
|
|
930
|
+
function mt(e) {
|
|
936
931
|
const t = U.safeParse(e);
|
|
937
932
|
return t.success ? { success: !0, errors: [] } : {
|
|
938
933
|
success: !1,
|
|
@@ -942,59 +937,58 @@ function pt(e) {
|
|
|
942
937
|
}))
|
|
943
938
|
};
|
|
944
939
|
}
|
|
945
|
-
function
|
|
940
|
+
function ft(e) {
|
|
946
941
|
return q.parse(e);
|
|
947
942
|
}
|
|
948
|
-
function
|
|
943
|
+
function ht(e) {
|
|
949
944
|
return U.parse(e);
|
|
950
945
|
}
|
|
951
946
|
export {
|
|
952
947
|
qe as A,
|
|
953
|
-
|
|
954
|
-
|
|
948
|
+
rt as B,
|
|
949
|
+
st as C,
|
|
955
950
|
q as D,
|
|
956
|
-
|
|
957
|
-
|
|
951
|
+
Ae as E,
|
|
952
|
+
at as F,
|
|
958
953
|
ie as G,
|
|
959
|
-
|
|
954
|
+
ht as H,
|
|
960
955
|
oe as I,
|
|
961
956
|
ft as J,
|
|
962
|
-
|
|
957
|
+
et as K,
|
|
963
958
|
ze as L,
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
nt as V,
|
|
959
|
+
He as M,
|
|
960
|
+
Xe as N,
|
|
961
|
+
ne as O,
|
|
962
|
+
k as P,
|
|
963
|
+
pt as Q,
|
|
964
|
+
ot as T,
|
|
965
|
+
it as V,
|
|
972
966
|
ae as W,
|
|
973
967
|
ee as a,
|
|
974
968
|
De as b,
|
|
975
|
-
|
|
969
|
+
dt as c,
|
|
976
970
|
we as d,
|
|
977
971
|
Re as e,
|
|
978
|
-
|
|
972
|
+
ut as f,
|
|
979
973
|
Ee as g,
|
|
980
974
|
Pe as h,
|
|
981
975
|
W as i,
|
|
982
976
|
Me as j,
|
|
983
977
|
re as k,
|
|
984
978
|
te as l,
|
|
985
|
-
|
|
986
|
-
|
|
979
|
+
ct as m,
|
|
980
|
+
Ze as n,
|
|
987
981
|
he as o,
|
|
988
|
-
|
|
982
|
+
lt as p,
|
|
989
983
|
me as q,
|
|
990
984
|
ce as r,
|
|
991
985
|
Te as s,
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
986
|
+
je as t,
|
|
987
|
+
K as u,
|
|
988
|
+
mt as v,
|
|
989
|
+
N as w,
|
|
990
|
+
tt as x,
|
|
991
|
+
nt as y,
|
|
992
|
+
z
|
|
999
993
|
};
|
|
1000
|
-
//# sourceMappingURL=validation-
|
|
994
|
+
//# sourceMappingURL=validation-C9P__pRF.js.map
|