@stonecrop/schema 0.13.8 → 0.13.9
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 +36 -15
- package/dist/cli.js +6 -6
- package/dist/{index-C08kwqyS.js → index-C5ANE_rn.js} +230 -231
- package/dist/index-C5ANE_rn.js.map +1 -0
- package/dist/{index-COp1U6eU.js → index-D66L9JNw.js} +220 -219
- package/dist/index-D66L9JNw.js.map +1 -0
- package/dist/index.js +30 -25
- package/dist/schema.d.ts +256 -91
- package/dist/src/converter/heuristics.d.ts.map +1 -1
- package/dist/src/converter/heuristics.js +1 -0
- package/dist/src/converter/index.d.ts.map +1 -1
- package/dist/src/converter/index.js +6 -4
- package/dist/src/converter/types.d.ts +6 -6
- package/dist/src/converter/types.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +4 -35
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +2 -2
- package/dist/src/field.d.ts +163 -18
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +108 -72
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/validation.d.ts +4 -5
- package/dist/src/validation.d.ts.map +1 -1
- package/dist/src/validation.js +5 -5
- package/package.json +1 -1
- package/dist/index-C08kwqyS.js.map +0 -1
- package/dist/index-COp1U6eU.js.map +0 -1
- package/dist/index-leHOZ3ll.js +0 -502
- package/dist/index-leHOZ3ll.js.map +0 -1
package/dist/schema.d.ts
CHANGED
|
@@ -77,8 +77,8 @@ export declare function camelToSnake(camelCase: string): string;
|
|
|
77
77
|
* @public
|
|
78
78
|
*/
|
|
79
79
|
export declare const Cardinality: z.ZodEnum<{
|
|
80
|
-
one: "one";
|
|
81
80
|
atMostOne: "atMostOne";
|
|
81
|
+
one: "one";
|
|
82
82
|
noneOrMany: "noneOrMany";
|
|
83
83
|
atLeastOne: "atLeastOne";
|
|
84
84
|
}>;
|
|
@@ -263,8 +263,8 @@ export declare interface ColumnSchema {
|
|
|
263
263
|
* @public
|
|
264
264
|
*/
|
|
265
265
|
export declare interface ConvertedGraphQLDoctype extends Omit<DoctypeMeta, 'fields'> {
|
|
266
|
-
/** Field definitions
|
|
267
|
-
fields:
|
|
266
|
+
/** Field definitions — GraphQL conversion metadata stripped; same shape as DoctypeMeta.fields */
|
|
267
|
+
fields: ValueField[];
|
|
268
268
|
/** Original GraphQL type name (for debugging/reference) */
|
|
269
269
|
_graphqlTypeName?: string;
|
|
270
270
|
}
|
|
@@ -411,6 +411,20 @@ export declare interface DoctypeContext {
|
|
|
411
411
|
[key: string]: unknown;
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Union of all authoring-time field variants.
|
|
416
|
+
* Use `kind` to discriminate: `'field'` | `'fieldset'` | `'table'`.
|
|
417
|
+
* @public
|
|
418
|
+
*/
|
|
419
|
+
export declare type DoctypeField = ValueField | FieldsetField | TableField;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Zod runtime validation schema for the DoctypeField discriminated union.
|
|
423
|
+
* Validates all three field variants: `'field'`, `'fieldset'`, `'table'`.
|
|
424
|
+
* @public
|
|
425
|
+
*/
|
|
426
|
+
export declare const DoctypeFieldSchema: z.ZodType<DoctypeField, unknown, z.core.$ZodTypeInternals<DoctypeField, unknown>>;
|
|
427
|
+
|
|
414
428
|
/**
|
|
415
429
|
* Doctype metadata - complete definition of a doctype
|
|
416
430
|
* @public
|
|
@@ -418,43 +432,12 @@ export declare interface DoctypeContext {
|
|
|
418
432
|
export declare const DoctypeMeta: z.ZodObject<{
|
|
419
433
|
name: z.ZodString;
|
|
420
434
|
slug: z.ZodOptional<z.ZodString>;
|
|
421
|
-
fields: z.ZodArray<z.
|
|
422
|
-
fieldname: z.ZodString;
|
|
423
|
-
fieldtype: z.ZodString;
|
|
424
|
-
component: z.ZodOptional<z.ZodString>;
|
|
425
|
-
label: z.ZodOptional<z.ZodString>;
|
|
426
|
-
width: z.ZodOptional<z.ZodString>;
|
|
427
|
-
align: z.ZodOptional<z.ZodEnum<{
|
|
428
|
-
left: "left";
|
|
429
|
-
center: "center";
|
|
430
|
-
right: "right";
|
|
431
|
-
start: "start";
|
|
432
|
-
end: "end";
|
|
433
|
-
}>>;
|
|
434
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
435
|
-
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
436
|
-
edit: z.ZodOptional<z.ZodBoolean>;
|
|
437
|
-
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
438
|
-
value: z.ZodOptional<z.ZodUnknown>;
|
|
439
|
-
default: z.ZodOptional<z.ZodUnknown>;
|
|
440
|
-
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
441
|
-
cardinality: z.ZodOptional<z.ZodEnum<{
|
|
442
|
-
one: "one";
|
|
443
|
-
atMostOne: "atMostOne";
|
|
444
|
-
noneOrMany: "noneOrMany";
|
|
445
|
-
atLeastOne: "atLeastOne";
|
|
446
|
-
}>>;
|
|
447
|
-
mask: z.ZodOptional<z.ZodString>;
|
|
448
|
-
validation: z.ZodOptional<z.ZodObject<{
|
|
449
|
-
errorMessage: z.ZodString;
|
|
450
|
-
}, z.core.$loose>>;
|
|
451
|
-
schema: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
452
|
-
}, z.core.$strip>>;
|
|
435
|
+
fields: z.ZodArray<z.ZodType<DoctypeField, unknown, z.core.$ZodTypeInternals<DoctypeField, unknown>>>;
|
|
453
436
|
links: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
454
437
|
target: z.ZodString;
|
|
455
438
|
cardinality: z.ZodEnum<{
|
|
456
|
-
one: "one";
|
|
457
439
|
atMostOne: "atMostOne";
|
|
440
|
+
one: "one";
|
|
458
441
|
noneOrMany: "noneOrMany";
|
|
459
442
|
atLeastOne: "atLeastOne";
|
|
460
443
|
}>;
|
|
@@ -527,54 +510,6 @@ export declare const FetchStrategy: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
527
510
|
*/
|
|
528
511
|
export declare type FetchStrategy = z.infer<typeof FetchStrategy>;
|
|
529
512
|
|
|
530
|
-
/**
|
|
531
|
-
* Unified field metadata - the single source of truth for field definitions.
|
|
532
|
-
* Works for both forms (AForm) and tables (ATable).
|
|
533
|
-
*
|
|
534
|
-
* Core principle: "Text" is "Text" regardless of rendering context.
|
|
535
|
-
*
|
|
536
|
-
* @public
|
|
537
|
-
*/
|
|
538
|
-
export declare const FieldMeta: z.ZodObject<{
|
|
539
|
-
fieldname: z.ZodString;
|
|
540
|
-
fieldtype: z.ZodString;
|
|
541
|
-
component: z.ZodOptional<z.ZodString>;
|
|
542
|
-
label: z.ZodOptional<z.ZodString>;
|
|
543
|
-
width: z.ZodOptional<z.ZodString>;
|
|
544
|
-
align: z.ZodOptional<z.ZodEnum<{
|
|
545
|
-
left: "left";
|
|
546
|
-
center: "center";
|
|
547
|
-
right: "right";
|
|
548
|
-
start: "start";
|
|
549
|
-
end: "end";
|
|
550
|
-
}>>;
|
|
551
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
552
|
-
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
553
|
-
edit: z.ZodOptional<z.ZodBoolean>;
|
|
554
|
-
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
555
|
-
value: z.ZodOptional<z.ZodUnknown>;
|
|
556
|
-
default: z.ZodOptional<z.ZodUnknown>;
|
|
557
|
-
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
558
|
-
cardinality: z.ZodOptional<z.ZodEnum<{
|
|
559
|
-
one: "one";
|
|
560
|
-
atMostOne: "atMostOne";
|
|
561
|
-
noneOrMany: "noneOrMany";
|
|
562
|
-
atLeastOne: "atLeastOne";
|
|
563
|
-
}>>;
|
|
564
|
-
mask: z.ZodOptional<z.ZodString>;
|
|
565
|
-
validation: z.ZodOptional<z.ZodObject<{
|
|
566
|
-
/** Error message to display when validation fails */
|
|
567
|
-
errorMessage: z.ZodString;
|
|
568
|
-
}, z.core.$loose>>;
|
|
569
|
-
schema: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
570
|
-
}, z.core.$strip>;
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Field metadata type inferred from Zod schema
|
|
574
|
-
* @public
|
|
575
|
-
*/
|
|
576
|
-
export declare type FieldMeta = z.infer<typeof FieldMeta>;
|
|
577
|
-
|
|
578
513
|
/**
|
|
579
514
|
* Field options - flexible bag for type-specific configuration.
|
|
580
515
|
*
|
|
@@ -594,6 +529,46 @@ export declare const FieldOptions: z.ZodUnion<readonly [z.ZodString, z.ZodArray<
|
|
|
594
529
|
*/
|
|
595
530
|
export declare type FieldOptions = z.infer<typeof FieldOptions>;
|
|
596
531
|
|
|
532
|
+
/**
|
|
533
|
+
* A layout container that groups other fields. Resolves to a nested AForm.
|
|
534
|
+
* @public
|
|
535
|
+
*/
|
|
536
|
+
export declare interface FieldsetField {
|
|
537
|
+
/** Discriminator — identifies this as a fieldset container */
|
|
538
|
+
kind: 'fieldset';
|
|
539
|
+
/** Unique identifier for this fieldset within its doctype */
|
|
540
|
+
fieldname: string;
|
|
541
|
+
/** Vue component to render this fieldset. Defaults to `'AFieldset'` in resolveSchema. */
|
|
542
|
+
component?: string;
|
|
543
|
+
/** Human-readable label for the fieldset legend */
|
|
544
|
+
label?: string;
|
|
545
|
+
/** Whether the fieldset can be collapsed */
|
|
546
|
+
collapsible?: boolean;
|
|
547
|
+
/** Interaction mode for all children inside this fieldset */
|
|
548
|
+
mode?: InteractionMode;
|
|
549
|
+
/** Nested field definitions — resolved recursively by resolveSchema */
|
|
550
|
+
schema: DoctypeField[];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Zod runtime validation schema for FieldsetField.
|
|
555
|
+
* Recursive — FieldsetField.schema is validated against DoctypeFieldSchema.
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
export declare const FieldsetFieldSchema: z.ZodObject<{
|
|
559
|
+
kind: z.ZodLiteral<"fieldset">;
|
|
560
|
+
fieldname: z.ZodString;
|
|
561
|
+
component: z.ZodOptional<z.ZodString>;
|
|
562
|
+
label: z.ZodOptional<z.ZodString>;
|
|
563
|
+
collapsible: z.ZodOptional<z.ZodBoolean>;
|
|
564
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
565
|
+
edit: "edit";
|
|
566
|
+
read: "read";
|
|
567
|
+
display: "display";
|
|
568
|
+
}>>;
|
|
569
|
+
schema: z.ZodLazy<z.ZodArray<z.ZodType<DoctypeField, unknown, z.core.$ZodTypeInternals<DoctypeField, unknown>>>>;
|
|
570
|
+
}, z.core.$strip>;
|
|
571
|
+
|
|
597
572
|
/**
|
|
598
573
|
* Field template for TYPE_MAP entries.
|
|
599
574
|
* Defines the default component and semantic field type for a field.
|
|
@@ -691,7 +666,7 @@ export declare const GQL_SCALAR_MAP: Record<string, FieldTemplate>;
|
|
|
691
666
|
*
|
|
692
667
|
* @public
|
|
693
668
|
*/
|
|
694
|
-
export declare interface GraphQLConversionFieldMeta extends Omit<
|
|
669
|
+
export declare interface GraphQLConversionFieldMeta extends Omit<ValueField, 'fieldtype'> {
|
|
695
670
|
/** Semantic field type - optional for link fields which don't have a fieldtype */
|
|
696
671
|
fieldtype?: string;
|
|
697
672
|
/** Original GraphQL type name (for debugging/reference) */
|
|
@@ -732,7 +707,7 @@ export declare interface GraphQLConversionOptions {
|
|
|
732
707
|
* }
|
|
733
708
|
* ```
|
|
734
709
|
*/
|
|
735
|
-
typeOverrides?: Record<string, Record<string, Partial<
|
|
710
|
+
typeOverrides?: Record<string, Record<string, Omit<Partial<ValueField>, 'kind'>>>;
|
|
736
711
|
/**
|
|
737
712
|
* Map custom or non-standard GraphQL scalar types to Stonecrop field types.
|
|
738
713
|
* Merged with the built-in scalar maps (GQL_SCALAR_MAP + WELL_KNOWN_SCALARS).
|
|
@@ -782,7 +757,7 @@ export declare interface GraphQLConversionOptions {
|
|
|
782
757
|
* @param parentType - The parent entity type
|
|
783
758
|
* @returns Partial field meta to use, or `null` for default behavior
|
|
784
759
|
*/
|
|
785
|
-
classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Partial<
|
|
760
|
+
classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Omit<Partial<ValueField>, 'kind'> | null;
|
|
786
761
|
/**
|
|
787
762
|
* Include `_graphqlType` and `_unmapped` metadata on converted fields.
|
|
788
763
|
* Useful for debugging conversions. Defaults to `false`.
|
|
@@ -790,6 +765,21 @@ export declare interface GraphQLConversionOptions {
|
|
|
790
765
|
includeUnmappedMeta?: boolean;
|
|
791
766
|
}
|
|
792
767
|
|
|
768
|
+
/**
|
|
769
|
+
* Controls the level of user interaction for a field, container, or table.
|
|
770
|
+
*
|
|
771
|
+
* - `'edit'` — field is fully interactive; user can change the value
|
|
772
|
+
* - `'read'` — field is non-interactive but displayed with form chrome (input outline, etc.)
|
|
773
|
+
* - `'display'` — field is non-interactive and displayed as plain text; no form chrome
|
|
774
|
+
*
|
|
775
|
+
* Applied at authoring time via `mode` on any `DoctypeField` variant. Propagated through
|
|
776
|
+
* `resolveSchema()` into the resolved output types. Nested `AForm` and `ATable` components
|
|
777
|
+
* inherit `mode` from their parent unless overridden at the field level.
|
|
778
|
+
*
|
|
779
|
+
* @public
|
|
780
|
+
*/
|
|
781
|
+
export declare type InteractionMode = 'edit' | 'read' | 'display';
|
|
782
|
+
|
|
793
783
|
/**
|
|
794
784
|
* Set of scalar type names that are internal to GraphQL servers and should be skipped
|
|
795
785
|
* during field conversion (they don't represent meaningful data fields).
|
|
@@ -840,8 +830,8 @@ export declare type LazyFetch = z.infer<typeof LazyFetch>;
|
|
|
840
830
|
export declare const LinkDeclaration: z.ZodObject<{
|
|
841
831
|
target: z.ZodString;
|
|
842
832
|
cardinality: z.ZodEnum<{
|
|
843
|
-
one: "one";
|
|
844
833
|
atMostOne: "atMostOne";
|
|
834
|
+
one: "one";
|
|
845
835
|
noneOrMany: "noneOrMany";
|
|
846
836
|
atLeastOne: "atLeastOne";
|
|
847
837
|
}>;
|
|
@@ -878,11 +868,11 @@ export declare function parseDoctype(data: unknown): DoctypeMeta;
|
|
|
878
868
|
/**
|
|
879
869
|
* Parse and validate a field, throwing on failure
|
|
880
870
|
* @param data - Data to parse
|
|
881
|
-
* @returns Validated
|
|
871
|
+
* @returns Validated DoctypeField
|
|
882
872
|
* @throws ZodError if validation fails
|
|
883
873
|
* @public
|
|
884
874
|
*/
|
|
885
|
-
export declare function parseField(data: unknown):
|
|
875
|
+
export declare function parseField(data: unknown): DoctypeField;
|
|
886
876
|
|
|
887
877
|
/**
|
|
888
878
|
* Convert PascalCase to snake_case (e.g., for deriving table names from type names)
|
|
@@ -962,6 +952,97 @@ export declare const SyncFetch: z.ZodObject<{
|
|
|
962
952
|
*/
|
|
963
953
|
export declare type SyncFetch = z.infer<typeof SyncFetch>;
|
|
964
954
|
|
|
955
|
+
/**
|
|
956
|
+
* An inline table whose columns are defined directly in the schema (no linked doctype).
|
|
957
|
+
* Use when the table data does not warrant a separate doctype.
|
|
958
|
+
* @public
|
|
959
|
+
*/
|
|
960
|
+
export declare interface TableField {
|
|
961
|
+
/** Discriminator — identifies this as an inline table */
|
|
962
|
+
kind: 'table';
|
|
963
|
+
/** Unique identifier for this table within its doctype */
|
|
964
|
+
fieldname: string;
|
|
965
|
+
/** Vue component to render this table. Defaults to `'ATable'` in resolveSchema. */
|
|
966
|
+
component?: string;
|
|
967
|
+
/** Human-readable label */
|
|
968
|
+
label?: string;
|
|
969
|
+
/** Column definitions — use ColumnSchema (fieldname key) from \@stonecrop/schema */
|
|
970
|
+
columns: ColumnSchema[];
|
|
971
|
+
/** View configuration — defaults to `{ view: 'list' }` in resolveSchema when absent */
|
|
972
|
+
config?: TableViewConfig;
|
|
973
|
+
/** Interaction mode for all cells inside this table */
|
|
974
|
+
mode?: InteractionMode;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Zod runtime validation schema for TableField.
|
|
979
|
+
* @public
|
|
980
|
+
*/
|
|
981
|
+
export declare const TableFieldSchema: z.ZodObject<{
|
|
982
|
+
kind: z.ZodLiteral<"table">;
|
|
983
|
+
fieldname: z.ZodString;
|
|
984
|
+
component: z.ZodOptional<z.ZodString>;
|
|
985
|
+
label: z.ZodOptional<z.ZodString>;
|
|
986
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
987
|
+
fieldname: z.ZodString;
|
|
988
|
+
}, z.core.$loose>>;
|
|
989
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
990
|
+
view: z.ZodOptional<z.ZodEnum<{
|
|
991
|
+
list: "list";
|
|
992
|
+
uncounted: "uncounted";
|
|
993
|
+
"list-expansion": "list-expansion";
|
|
994
|
+
tree: "tree";
|
|
995
|
+
gantt: "gantt";
|
|
996
|
+
"tree-gantt": "tree-gantt";
|
|
997
|
+
}>>;
|
|
998
|
+
fullWidth: z.ZodOptional<z.ZodBoolean>;
|
|
999
|
+
defaultTreeExpansion: z.ZodOptional<z.ZodEnum<{
|
|
1000
|
+
root: "root";
|
|
1001
|
+
branch: "branch";
|
|
1002
|
+
leaf: "leaf";
|
|
1003
|
+
}>>;
|
|
1004
|
+
dependencyGraph: z.ZodOptional<z.ZodBoolean>;
|
|
1005
|
+
}, z.core.$strip>>;
|
|
1006
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
1007
|
+
edit: "edit";
|
|
1008
|
+
read: "read";
|
|
1009
|
+
display: "display";
|
|
1010
|
+
}>>;
|
|
1011
|
+
}, z.core.$strip>;
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* JSON-safe view configuration for table fields in doctype authoring.
|
|
1015
|
+
*
|
|
1016
|
+
* This is the authoring-time subset of `@stonecrop/atable`'s `TableConfig`. It covers
|
|
1017
|
+
* the view discriminator and structural options that can be expressed in static JSON.
|
|
1018
|
+
* `rowActions` (which requires function-typed handlers) stays in the runtime `TableConfig`.
|
|
1019
|
+
*
|
|
1020
|
+
* @public
|
|
1021
|
+
*/
|
|
1022
|
+
export declare const TableViewConfig: z.ZodObject<{
|
|
1023
|
+
view: z.ZodOptional<z.ZodEnum<{
|
|
1024
|
+
list: "list";
|
|
1025
|
+
uncounted: "uncounted";
|
|
1026
|
+
"list-expansion": "list-expansion";
|
|
1027
|
+
tree: "tree";
|
|
1028
|
+
gantt: "gantt";
|
|
1029
|
+
"tree-gantt": "tree-gantt";
|
|
1030
|
+
}>>;
|
|
1031
|
+
fullWidth: z.ZodOptional<z.ZodBoolean>;
|
|
1032
|
+
defaultTreeExpansion: z.ZodOptional<z.ZodEnum<{
|
|
1033
|
+
root: "root";
|
|
1034
|
+
branch: "branch";
|
|
1035
|
+
leaf: "leaf";
|
|
1036
|
+
}>>;
|
|
1037
|
+
dependencyGraph: z.ZodOptional<z.ZodBoolean>;
|
|
1038
|
+
}, z.core.$strip>;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Table view configuration type inferred from Zod schema
|
|
1042
|
+
* @public
|
|
1043
|
+
*/
|
|
1044
|
+
export declare type TableViewConfig = z.infer<typeof TableViewConfig>;
|
|
1045
|
+
|
|
965
1046
|
/**
|
|
966
1047
|
* Convert table name to PascalCase doctype name
|
|
967
1048
|
* @param tableName - SQL table name (snake_case)
|
|
@@ -994,7 +1075,7 @@ export declare const TYPE_MAP: Record<BuiltinFieldType, FieldTemplate>;
|
|
|
994
1075
|
export declare function validateDoctype(data: unknown): ValidationResult;
|
|
995
1076
|
|
|
996
1077
|
/**
|
|
997
|
-
* Validate a field definition
|
|
1078
|
+
* Validate a field definition against the DoctypeField discriminated union
|
|
998
1079
|
* @param data - Data to validate
|
|
999
1080
|
* @returns Validation result
|
|
1000
1081
|
* @public
|
|
@@ -1023,6 +1104,90 @@ export declare interface ValidationResult {
|
|
|
1023
1104
|
errors: ValidationError[];
|
|
1024
1105
|
}
|
|
1025
1106
|
|
|
1107
|
+
/**
|
|
1108
|
+
* A field that holds a scalar value, a link to another record, or a select choice.
|
|
1109
|
+
* The most common kind of field. `fieldtype` determines the default component and behavior.
|
|
1110
|
+
* @public
|
|
1111
|
+
*/
|
|
1112
|
+
export declare interface ValueField {
|
|
1113
|
+
/** Discriminator — identifies this as a value-holding field */
|
|
1114
|
+
kind: 'field';
|
|
1115
|
+
/** Unique identifier for this field within its doctype */
|
|
1116
|
+
fieldname: string;
|
|
1117
|
+
/** Semantic field type — determines behavior and default rendering component */
|
|
1118
|
+
fieldtype: string;
|
|
1119
|
+
/** Vue component to render this field. Derived from `fieldtype` when absent. */
|
|
1120
|
+
component?: string;
|
|
1121
|
+
/** Human-readable label */
|
|
1122
|
+
label?: string;
|
|
1123
|
+
/** CSS width (e.g. `"40ch"`, `"200px"`) */
|
|
1124
|
+
width?: string;
|
|
1125
|
+
/** Text alignment */
|
|
1126
|
+
align?: 'left' | 'center' | 'right' | 'start' | 'end';
|
|
1127
|
+
/** Whether the field is editable in table cell context */
|
|
1128
|
+
edit?: boolean;
|
|
1129
|
+
/** Input mask pattern or serialized function */
|
|
1130
|
+
mask?: string;
|
|
1131
|
+
/** Per-field interaction mode override */
|
|
1132
|
+
mode?: InteractionMode;
|
|
1133
|
+
/** Type-specific options: Link target slug, Select choices, Decimal precision config, etc. */
|
|
1134
|
+
options?: FieldOptions;
|
|
1135
|
+
/** Whether the field is required */
|
|
1136
|
+
required?: boolean;
|
|
1137
|
+
/** Whether the field is read-only */
|
|
1138
|
+
readOnly?: boolean;
|
|
1139
|
+
/** Whether the field is hidden from the UI */
|
|
1140
|
+
hidden?: boolean;
|
|
1141
|
+
/** Default value for new records */
|
|
1142
|
+
default?: unknown;
|
|
1143
|
+
/** Validation configuration */
|
|
1144
|
+
validation?: FieldValidation;
|
|
1145
|
+
/** Cardinality for Link fields — authoritative value on LinkDeclaration takes precedence */
|
|
1146
|
+
cardinality?: 'atMostOne' | 'one' | 'noneOrMany' | 'atLeastOne';
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Zod runtime validation schema for ValueField.
|
|
1151
|
+
* @public
|
|
1152
|
+
*/
|
|
1153
|
+
export declare const ValueFieldSchema: z.ZodObject<{
|
|
1154
|
+
kind: z.ZodLiteral<"field">;
|
|
1155
|
+
fieldname: z.ZodString;
|
|
1156
|
+
fieldtype: z.ZodString;
|
|
1157
|
+
component: z.ZodOptional<z.ZodString>;
|
|
1158
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1159
|
+
width: z.ZodOptional<z.ZodString>;
|
|
1160
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
1161
|
+
left: "left";
|
|
1162
|
+
right: "right";
|
|
1163
|
+
center: "center";
|
|
1164
|
+
start: "start";
|
|
1165
|
+
end: "end";
|
|
1166
|
+
}>>;
|
|
1167
|
+
edit: z.ZodOptional<z.ZodBoolean>;
|
|
1168
|
+
mask: z.ZodOptional<z.ZodString>;
|
|
1169
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
1170
|
+
edit: "edit";
|
|
1171
|
+
read: "read";
|
|
1172
|
+
display: "display";
|
|
1173
|
+
}>>;
|
|
1174
|
+
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
1175
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
1176
|
+
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
1177
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
1178
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
1179
|
+
validation: z.ZodOptional<z.ZodObject<{
|
|
1180
|
+
/** Error message to display when validation fails */
|
|
1181
|
+
errorMessage: z.ZodString;
|
|
1182
|
+
}, z.core.$loose>>;
|
|
1183
|
+
cardinality: z.ZodOptional<z.ZodEnum<{
|
|
1184
|
+
atMostOne: "atMostOne";
|
|
1185
|
+
one: "one";
|
|
1186
|
+
noneOrMany: "noneOrMany";
|
|
1187
|
+
atLeastOne: "atLeastOne";
|
|
1188
|
+
}>>;
|
|
1189
|
+
}, z.core.$strip>;
|
|
1190
|
+
|
|
1026
1191
|
/**
|
|
1027
1192
|
* Mapping from well-known custom GraphQL scalars to Stonecrop field types.
|
|
1028
1193
|
* These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heuristics.d.ts","sourceRoot":"","sources":["../../../src/converter/heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAON,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AA+BnF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CA8BtF;AAQD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACtC,WAAW,EAAE,iBAAiB,GAC5B,OAAO,CAET;AAyED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,OAAO,GAAE,wBAA6B,GACpC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"heuristics.d.ts","sourceRoot":"","sources":["../../../src/converter/heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAON,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AA+BnF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CA8BtF;AAQD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACtC,WAAW,EAAE,iBAAiB,GAC5B,OAAO,CAET;AAyED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,OAAO,GAAE,wBAA6B,GACpC,0BAA0B,CAyG5B"}
|
|
@@ -178,6 +178,7 @@ export function classifyFieldType(fieldName, field, entityTypes, options = {}) {
|
|
|
178
178
|
const { namedType, required, isList } = unwrapType(field.type);
|
|
179
179
|
const scalarMap = buildScalarMap(options.customScalars);
|
|
180
180
|
const base = {
|
|
181
|
+
kind: 'field',
|
|
181
182
|
fieldname: fieldName,
|
|
182
183
|
label: camelToLabel(fieldName),
|
|
183
184
|
component: 'ATextInput',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAIrG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,GAAE,wBAA6B,GACpC,uBAAuB,EAAE,CA8H3B;AAwBD,OAAO,EAAE,oBAAoB,IAAI,OAAO,EAAE,CAAA;AAG1C,YAAY,EACX,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,GACvB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAGhG,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAG3F,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -87,14 +87,15 @@ export function convertGraphQLSchema(source, options = {}) {
|
|
|
87
87
|
continue;
|
|
88
88
|
const fields = type.getFields();
|
|
89
89
|
const typeOverrides = options.typeOverrides?.[typeName];
|
|
90
|
-
const
|
|
91
|
-
// oxlint-disable-next-line oxc/no-map-spread -- spread required
|
|
92
|
-
const allClassifiedFields =
|
|
90
|
+
const entityFields = Object.entries(fields).filter(([fieldName, field]) => isEntityField(fieldName, field, type));
|
|
91
|
+
// oxlint-disable-next-line oxc/no-map-spread -- ...custom spread required; Object.assign cannot preserve the metadata-carrying inferred union type from classifyField
|
|
92
|
+
const allClassifiedFields = entityFields.map(([fieldName, field]) => {
|
|
93
93
|
// Check for full custom classification first
|
|
94
94
|
if (options.classifyField) {
|
|
95
95
|
const custom = options.classifyField(fieldName, field, type);
|
|
96
96
|
if (custom !== null && custom !== undefined) {
|
|
97
97
|
return {
|
|
98
|
+
kind: 'field',
|
|
98
99
|
fieldname: fieldName,
|
|
99
100
|
label: custom.label ?? fieldName,
|
|
100
101
|
component: custom.component ?? 'ATextInput',
|
|
@@ -107,7 +108,7 @@ export function convertGraphQLSchema(source, options = {}) {
|
|
|
107
108
|
const classified = classifyFieldType(fieldName, field, entityTypes, options);
|
|
108
109
|
// Apply per-field overrides
|
|
109
110
|
if (typeOverrides?.[fieldName]) {
|
|
110
|
-
return
|
|
111
|
+
return Object.assign(classified, typeOverrides[fieldName]);
|
|
111
112
|
}
|
|
112
113
|
return classified;
|
|
113
114
|
});
|
|
@@ -136,6 +137,7 @@ export function convertGraphQLSchema(source, options = {}) {
|
|
|
136
137
|
const doctype = {
|
|
137
138
|
name: typeName,
|
|
138
139
|
slug: toSlug(typeName),
|
|
140
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- safe: heuristics always set a fieldtype default ('Data'); the optional fieldtype on GraphQLConversionFieldMeta is for intermediate processing, not because output fields lack fieldtype
|
|
139
141
|
fields: convertedFields,
|
|
140
142
|
};
|
|
141
143
|
if (Object.keys(links).length > 0) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { IntrospectionQuery } from 'graphql';
|
|
7
7
|
import type { GraphQLObjectType, GraphQLField } from 'graphql';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ValueField } from '../field';
|
|
9
9
|
import type { FieldTemplate } from '../fieldtype';
|
|
10
10
|
/**
|
|
11
11
|
* Input source for the GraphQL schema converter.
|
|
@@ -51,7 +51,7 @@ export interface GraphQLConversionOptions {
|
|
|
51
51
|
* }
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
typeOverrides?: Record<string, Record<string, Partial<
|
|
54
|
+
typeOverrides?: Record<string, Record<string, Omit<Partial<ValueField>, 'kind'>>>;
|
|
55
55
|
/**
|
|
56
56
|
* Map custom or non-standard GraphQL scalar types to Stonecrop field types.
|
|
57
57
|
* Merged with the built-in scalar maps (GQL_SCALAR_MAP + WELL_KNOWN_SCALARS).
|
|
@@ -101,7 +101,7 @@ export interface GraphQLConversionOptions {
|
|
|
101
101
|
* @param parentType - The parent entity type
|
|
102
102
|
* @returns Partial field meta to use, or `null` for default behavior
|
|
103
103
|
*/
|
|
104
|
-
classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Partial<
|
|
104
|
+
classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Omit<Partial<ValueField>, 'kind'> | null;
|
|
105
105
|
/**
|
|
106
106
|
* Include `_graphqlType` and `_unmapped` metadata on converted fields.
|
|
107
107
|
* Useful for debugging conversions. Defaults to `false`.
|
|
@@ -114,7 +114,7 @@ export interface GraphQLConversionOptions {
|
|
|
114
114
|
*
|
|
115
115
|
* @public
|
|
116
116
|
*/
|
|
117
|
-
export interface GraphQLConversionFieldMeta extends Omit<
|
|
117
|
+
export interface GraphQLConversionFieldMeta extends Omit<ValueField, 'fieldtype'> {
|
|
118
118
|
/** Semantic field type - optional for link fields which don't have a fieldtype */
|
|
119
119
|
fieldtype?: string;
|
|
120
120
|
/** Original GraphQL type name (for debugging/reference) */
|
|
@@ -130,8 +130,8 @@ export interface GraphQLConversionFieldMeta extends Omit<FieldMeta, 'fieldtype'>
|
|
|
130
130
|
* @public
|
|
131
131
|
*/
|
|
132
132
|
export interface ConvertedGraphQLDoctype extends Omit<DoctypeMeta, 'fields'> {
|
|
133
|
-
/** Field definitions
|
|
134
|
-
fields:
|
|
133
|
+
/** Field definitions — GraphQL conversion metadata stripped; same shape as DoctypeMeta.fields */
|
|
134
|
+
fields: ValueField[];
|
|
135
135
|
/** Original GraphQL type name (for debugging/reference) */
|
|
136
136
|
_graphqlTypeName?: string;
|
|
137
137
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;;;;;;;;;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;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAEjF;;;;;;;;;;;;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,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IAChF,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,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"}
|
package/dist/src/doctype.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { z } from 'zod';
|
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
export declare const Cardinality: z.ZodEnum<{
|
|
7
|
-
one: "one";
|
|
8
7
|
atMostOne: "atMostOne";
|
|
8
|
+
one: "one";
|
|
9
9
|
noneOrMany: "noneOrMany";
|
|
10
10
|
atLeastOne: "atLeastOne";
|
|
11
11
|
}>;
|
|
@@ -86,8 +86,8 @@ export type FetchStrategy = z.infer<typeof FetchStrategy>;
|
|
|
86
86
|
export declare const LinkDeclaration: z.ZodObject<{
|
|
87
87
|
target: z.ZodString;
|
|
88
88
|
cardinality: z.ZodEnum<{
|
|
89
|
-
one: "one";
|
|
90
89
|
atMostOne: "atMostOne";
|
|
90
|
+
one: "one";
|
|
91
91
|
noneOrMany: "noneOrMany";
|
|
92
92
|
atLeastOne: "atLeastOne";
|
|
93
93
|
}>;
|
|
@@ -154,43 +154,12 @@ export type WorkflowMeta = z.infer<typeof WorkflowMeta>;
|
|
|
154
154
|
export declare const DoctypeMeta: z.ZodObject<{
|
|
155
155
|
name: z.ZodString;
|
|
156
156
|
slug: z.ZodOptional<z.ZodString>;
|
|
157
|
-
fields: z.ZodArray<z.
|
|
158
|
-
fieldname: z.ZodString;
|
|
159
|
-
fieldtype: z.ZodString;
|
|
160
|
-
component: z.ZodOptional<z.ZodString>;
|
|
161
|
-
label: z.ZodOptional<z.ZodString>;
|
|
162
|
-
width: z.ZodOptional<z.ZodString>;
|
|
163
|
-
align: z.ZodOptional<z.ZodEnum<{
|
|
164
|
-
left: "left";
|
|
165
|
-
center: "center";
|
|
166
|
-
right: "right";
|
|
167
|
-
start: "start";
|
|
168
|
-
end: "end";
|
|
169
|
-
}>>;
|
|
170
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
171
|
-
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
-
edit: z.ZodOptional<z.ZodBoolean>;
|
|
173
|
-
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
174
|
-
value: z.ZodOptional<z.ZodUnknown>;
|
|
175
|
-
default: z.ZodOptional<z.ZodUnknown>;
|
|
176
|
-
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
177
|
-
cardinality: z.ZodOptional<z.ZodEnum<{
|
|
178
|
-
one: "one";
|
|
179
|
-
atMostOne: "atMostOne";
|
|
180
|
-
noneOrMany: "noneOrMany";
|
|
181
|
-
atLeastOne: "atLeastOne";
|
|
182
|
-
}>>;
|
|
183
|
-
mask: z.ZodOptional<z.ZodString>;
|
|
184
|
-
validation: z.ZodOptional<z.ZodObject<{
|
|
185
|
-
errorMessage: z.ZodString;
|
|
186
|
-
}, z.core.$loose>>;
|
|
187
|
-
schema: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
188
|
-
}, z.core.$strip>>;
|
|
157
|
+
fields: z.ZodArray<z.ZodType<import("./field").DoctypeField, unknown, z.core.$ZodTypeInternals<import("./field").DoctypeField, unknown>>>;
|
|
189
158
|
links: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
190
159
|
target: z.ZodString;
|
|
191
160
|
cardinality: z.ZodEnum<{
|
|
192
|
-
one: "one";
|
|
193
161
|
atMostOne: "atMostOne";
|
|
162
|
+
one: "one";
|
|
194
163
|
noneOrMany: "noneOrMany";
|
|
195
164
|
atLeastOne: "atLeastOne";
|
|
196
165
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;EAGtB,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEvC;;;GAGG;AACH,eAAO,MAAM,SAAS;;;iBAUnB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEjD;;;GAG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;;;OAUG;IACH,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAE7F;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAEvF;;;;;;;;OAQG;IACH,SAAS,CACR,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,OAAO,EAAE,GACd,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;CACrE"}
|
package/dist/src/doctype.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { DoctypeFieldSchema } from './field';
|
|
3
3
|
/**
|
|
4
4
|
* Cardinality for relationship links.
|
|
5
5
|
* @public
|
|
@@ -136,7 +136,7 @@ export const DoctypeMeta = z
|
|
|
136
136
|
/** URL-friendly slug (kebab-case) */
|
|
137
137
|
slug: z.string().min(1).optional(),
|
|
138
138
|
/** Field definitions (including link fields with fieldtype: 'Link') */
|
|
139
|
-
fields: z.array(
|
|
139
|
+
fields: z.array(DoctypeFieldSchema),
|
|
140
140
|
/** Relationship links to other doctypes */
|
|
141
141
|
links: z.record(z.string(), LinkDeclaration).optional(),
|
|
142
142
|
/** Workflow configuration */
|