@stonecrop/schema 0.13.14 → 0.15.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 +38 -92
- package/dist/cli.js +6 -6
- package/dist/index-rozX0Luh.js +458 -0
- package/dist/index-rozX0Luh.js.map +1 -0
- package/dist/index.js +70 -31
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +324 -88
- package/dist/src/column-schema.d.ts +17 -8
- package/dist/src/column-schema.d.ts.map +1 -1
- package/dist/src/component-meta.d.ts +96 -0
- package/dist/src/component-meta.d.ts.map +1 -0
- package/dist/src/component-meta.js +85 -0
- package/dist/src/converter/heuristics.d.ts.map +1 -1
- package/dist/src/converter/heuristics.js +6 -13
- package/dist/src/converter/index.d.ts +1 -1
- package/dist/src/converter/index.d.ts.map +1 -1
- package/dist/src/converter/index.js +9 -8
- package/dist/src/converter/scalars.d.ts +1 -1
- package/dist/src/converter/scalars.d.ts.map +1 -1
- package/dist/src/converter/scalars.js +23 -26
- package/dist/src/converter/types.d.ts +17 -8
- package/dist/src/converter/types.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +127 -9
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +80 -7
- package/dist/src/field.d.ts +69 -12
- package/dist/src/field.d.ts.map +1 -1
- package/dist/src/field.js +45 -7
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -3
- package/package.json +14 -9
- package/dist/cli.cjs +0 -41
- package/dist/cli.cjs.map +0 -1
- package/dist/converter/heuristics.js +0 -258
- package/dist/converter/index.js +0 -181
- package/dist/converter/scalars.js +0 -86
- package/dist/converter/types.js +0 -5
- package/dist/converter-CYNFRwPg.js +0 -512
- package/dist/converter-CYNFRwPg.js.map +0 -1
- package/dist/converter-DNwpowpq.js +0 -459
- package/dist/converter-DNwpowpq.js.map +0 -1
- package/dist/doctype.js +0 -152
- package/dist/field.js +0 -110
- package/dist/fieldtype.js +0 -97
- package/dist/index--rNo7Kel.js +0 -494
- package/dist/index--rNo7Kel.js.map +0 -1
- package/dist/index-0qWNlDQ5.js +0 -450
- package/dist/index-0qWNlDQ5.js.map +0 -1
- package/dist/index-2UVTfbcY.js +0 -448
- package/dist/index-2UVTfbcY.js.map +0 -1
- package/dist/index-9QjWZ_PC.js +0 -449
- package/dist/index-9QjWZ_PC.js.map +0 -1
- package/dist/index-BCADNO5M.js +0 -449
- package/dist/index-BCADNO5M.js.map +0 -1
- package/dist/index-BJjSlCSo.js +0 -496
- package/dist/index-BJjSlCSo.js.map +0 -1
- package/dist/index-BRQJGVFR.js +0 -453
- package/dist/index-BRQJGVFR.js.map +0 -1
- package/dist/index-BatnoC-J.js +0 -429
- package/dist/index-BatnoC-J.js.map +0 -1
- package/dist/index-BbG7Mzvg.js +0 -495
- package/dist/index-BbG7Mzvg.js.map +0 -1
- package/dist/index-BdCmYHg0.js +0 -493
- package/dist/index-BdCmYHg0.js.map +0 -1
- package/dist/index-BhMd2_xl.js +0 -454
- package/dist/index-BhMd2_xl.js.map +0 -1
- package/dist/index-C5ANE_rn.js +0 -501
- package/dist/index-C5ANE_rn.js.map +0 -1
- package/dist/index-CLc5mUMQ.js +0 -478
- package/dist/index-CLc5mUMQ.js.map +0 -1
- package/dist/index-COrltkHl.js +0 -401
- package/dist/index-COrltkHl.js.map +0 -1
- package/dist/index-Cu-6609R.js +0 -493
- package/dist/index-Cu-6609R.js.map +0 -1
- package/dist/index-CvN9xK1B.js +0 -453
- package/dist/index-CvN9xK1B.js.map +0 -1
- package/dist/index-CzoRIy1-.js +0 -408
- package/dist/index-CzoRIy1-.js.map +0 -1
- package/dist/index-D66L9JNw.js +0 -506
- package/dist/index-D66L9JNw.js.map +0 -1
- package/dist/index-D68mWfHm.js +0 -510
- package/dist/index-D68mWfHm.js.map +0 -1
- package/dist/index-D6Up-BP5.js +0 -435
- package/dist/index-D6Up-BP5.js.map +0 -1
- package/dist/index-D9qPYlSk.js +0 -491
- package/dist/index-D9qPYlSk.js.map +0 -1
- package/dist/index-DEkR-1RC.js +0 -496
- package/dist/index-DEkR-1RC.js.map +0 -1
- package/dist/index-DIY_FLR2.js +0 -516
- package/dist/index-DIY_FLR2.js.map +0 -1
- package/dist/index-DIb_Z0wI.js +0 -476
- package/dist/index-DIb_Z0wI.js.map +0 -1
- package/dist/index-DNROIEMe.js +0 -449
- package/dist/index-DNROIEMe.js.map +0 -1
- package/dist/index-DT-NJBvW.js +0 -510
- package/dist/index-DT-NJBvW.js.map +0 -1
- package/dist/index-DUFcQC-H.js +0 -449
- package/dist/index-DUFcQC-H.js.map +0 -1
- package/dist/index-DVVTsJNb.js +0 -495
- package/dist/index-DVVTsJNb.js.map +0 -1
- package/dist/index-DYy5E1cU.js +0 -508
- package/dist/index-DYy5E1cU.js.map +0 -1
- package/dist/index-DdC5tpt-.js +0 -488
- package/dist/index-DdC5tpt-.js.map +0 -1
- package/dist/index-Dk593rMz.js +0 -512
- package/dist/index-Dk593rMz.js.map +0 -1
- package/dist/index-DmD8vmuB.js +0 -449
- package/dist/index-DmD8vmuB.js.map +0 -1
- package/dist/index-DpCFgELB.js +0 -514
- package/dist/index-DpCFgELB.js.map +0 -1
- package/dist/index-DqxTn6jG.js +0 -488
- package/dist/index-DqxTn6jG.js.map +0 -1
- package/dist/index-DyK5-0kh.js +0 -514
- package/dist/index-DyK5-0kh.js.map +0 -1
- package/dist/index-XSSAHj8g.js +0 -495
- package/dist/index-XSSAHj8g.js.map +0 -1
- package/dist/index-XZZbfFxT.js +0 -434
- package/dist/index-XZZbfFxT.js.map +0 -1
- package/dist/index-_3q9Bzka.js +0 -512
- package/dist/index-_3q9Bzka.js.map +0 -1
- package/dist/index-aeXXzPET.cjs +0 -2
- package/dist/index-aeXXzPET.cjs.map +0 -1
- package/dist/index-neVkjlgB.js +0 -446
- package/dist/index-neVkjlgB.js.map +0 -1
- package/dist/index-xdlVWldg.js +0 -408
- package/dist/index-xdlVWldg.js.map +0 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/jsonschema.js +0 -225
- package/dist/naming.js +0 -106
- package/dist/src/fieldtype.d.ts +0 -63
- package/dist/src/fieldtype.d.ts.map +0 -1
- package/dist/src/fieldtype.js +0 -105
- package/dist/src/jsonschema.d.ts +0 -95
- package/dist/src/jsonschema.d.ts.map +0 -1
- package/dist/src/schema-field.d.ts +0 -66
- package/dist/src/schema-field.d.ts.map +0 -1
- package/dist/src/schema-field.js +0 -0
- package/dist/src/tsdoc-metadata.json +0 -11
- package/dist/validation.js +0 -60
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-DIY_FLR2.js","sources":["../src/table.ts","../src/fieldtype.ts","../src/field.ts","../src/doctype.ts","../src/validation.ts","../src/naming.ts","../src/converter/scalars.ts","../src/converter/heuristics.ts","../src/converter/index.ts"],"sourcesContent":["import { z } from 'zod'\n\n/**\n * JSON-safe view configuration for table fields in doctype authoring.\n *\n * This is the authoring-time subset of `@stonecrop/atable`'s `TableConfig`. It covers\n * the view discriminator and structural options that can be expressed in static JSON.\n * `rowActions` (which requires function-typed handlers) stays in the runtime `TableConfig`.\n *\n * @public\n */\nexport const TableViewConfig = z\n\t.object({\n\t\t/** The table view type */\n\t\tview: z.enum(['list', 'uncounted', 'list-expansion', 'tree', 'gantt', 'tree-gantt']).optional(),\n\n\t\t/** Allow the table to use the full width of its container */\n\t\tfullWidth: z.boolean().optional(),\n\n\t\t/** Default expansion state for tree views */\n\t\tdefaultTreeExpansion: z.enum(['root', 'branch', 'leaf']).optional(),\n\n\t\t/** Enable dependency graph connections for Gantt views */\n\t\tdependencyGraph: z.boolean().optional(),\n\t})\n\t.meta({\n\t\ttitle: 'TableViewConfig',\n\t\tdescription: 'JSON-safe view configuration for table fields in doctype authoring',\n\t})\n\n/**\n * Table view configuration type inferred from Zod schema\n * @public\n */\nexport type TableViewConfig = z.infer<typeof TableViewConfig>\n","import { z } from 'zod'\n\n/**\n * The complete list of field types built into Stonecrop.\n * User apps can use any string as a fieldtype; this const is the exhaustive set of types\n * that Stonecrop provides default components for.\n * @public\n */\nexport const BUILTIN_FIELD_TYPES = [\n\t'Data', // Short text, varchar\n\t'Text', // Long text\n\t'Int', // Integer\n\t'Float', // Floating point (IEEE 754)\n\t'Decimal', // Arbitrary precision decimal\n\t'Check', // Boolean/checkbox\n\t'Date', // Date only\n\t'Time', // Time only\n\t'Datetime', // Date and time\n\t'Duration', // Time interval\n\t'DateRange', // Date range\n\t'JSON', // JSON data\n\t'Code', // Code/source (with syntax highlighting)\n\t'Link', // Reference to another doctype\n\t'Attach', // File attachment\n\t'Currency', // Currency value\n\t'Quantity', // Quantity with unit\n\t'Select', // Dropdown selection\n\t'PrimaryKey', // Primary key field — used by the middleware to identify the record's PK column\n\t'Fieldset', // UI grouping container — no DB column; children are flat columns\n\t'Display', // Computed/read-only field — no DB column; excluded from SQL SELECT\n] as const\n\n/**\n * Union of all builtin fieldtype string literals.\n * @public\n */\nexport type BuiltinFieldType = (typeof BUILTIN_FIELD_TYPES)[number]\n\n/**\n * Stonecrop field type — any non-empty string is valid; Stonecrop provides default components\n * for the builtin types listed in {@link BUILTIN_FIELD_TYPES}. Custom fieldtypes are supported\n * by supplying an explicit `component` on the field definition.\n * @public\n */\nexport const StonecropFieldType = z.string().min(1).meta({\n\ttitle: 'StonecropFieldType',\n\tdescription: 'Semantic field types for Stonecrop doctypes, consistent across forms and tables',\n})\n\n/**\n * Returns `true` when `fieldtype` is one of the builtin types Stonecrop ships with.\n * @public\n */\nexport function isBuiltinFieldType(fieldtype: string): fieldtype is BuiltinFieldType {\n\treturn (BUILTIN_FIELD_TYPES as readonly string[]).includes(fieldtype)\n}\n\n/**\n * Field template for TYPE_MAP entries.\n * Defines the default component and semantic field type for a field.\n * @public\n */\nexport interface FieldTemplate {\n\t/**\n\t * The Vue component name to render this field (e.g., 'ATextInput', 'ADropdown')\n\t */\n\tcomponent: string\n\t/**\n\t * The semantic field type (e.g., 'Data', 'Int', 'Select')\n\t */\n\tfieldtype: BuiltinFieldType\n}\n\n/**\n * Mapping from builtin fieldtypes to their default Vue component.\n * Components can be overridden in the field definition.\n * @public\n */\nexport const TYPE_MAP: Record<BuiltinFieldType, FieldTemplate> = {\n\t// Text\n\tData: { component: 'ATextInput', fieldtype: 'Data' },\n\tText: { component: 'ATextInput', fieldtype: 'Text' },\n\n\t// Numeric\n\tInt: { component: 'ANumericInput', fieldtype: 'Int' },\n\tFloat: { component: 'ANumericInput', fieldtype: 'Float' },\n\tDecimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },\n\n\t// Boolean\n\tCheck: { component: 'ACheckbox', fieldtype: 'Check' },\n\n\t// Date/Time\n\tDate: { component: 'ADate', fieldtype: 'Date' },\n\tTime: { component: 'ATimeInput', fieldtype: 'Time' },\n\tDatetime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },\n\tDuration: { component: 'ADurationInput', fieldtype: 'Duration' },\n\tDateRange: { component: 'ADateRangePicker', fieldtype: 'DateRange' },\n\n\t// Structured\n\tJSON: { component: 'ACodeEditor', fieldtype: 'JSON' },\n\tCode: { component: 'ACodeEditor', fieldtype: 'Code' },\n\n\t// Relational\n\tLink: { component: 'ALink', fieldtype: 'Link' },\n\n\t// Files\n\tAttach: { component: 'AFileAttach', fieldtype: 'Attach' },\n\n\t// Specialized\n\tCurrency: { component: 'ACurrencyInput', fieldtype: 'Currency' },\n\tQuantity: { component: 'AQuantityInput', fieldtype: 'Quantity' },\n\tSelect: { component: 'ADropdown', fieldtype: 'Select' },\n\n\t// Identity — PK fields are typically hidden; no interactive component is needed\n\tPrimaryKey: { component: 'ATextInput', fieldtype: 'PrimaryKey' },\n\n\t// Layout — UI grouping containers and computed fields with no backing DB column\n\tFieldset: { component: 'AFieldset', fieldtype: 'Fieldset' },\n\tDisplay: { component: 'ATextInput', fieldtype: 'Display' },\n}\n\n/**\n * Get the default component for a builtin field type.\n * For an open-string fieldtype that may be custom, use {@link resolveComponent} instead.\n * @param fieldtype - A builtin field type\n * @returns The default component name\n * @public\n */\nexport function getDefaultComponent(fieldtype: BuiltinFieldType): string {\n\treturn TYPE_MAP[fieldtype]?.component ?? 'ATextInput'\n}\n\n/**\n * Resolve the component name for any fieldtype string, falling back to `'ATextInput'`\n * for unknown custom types.\n * @param fieldtype - Any fieldtype string (builtin or custom)\n * @returns The component name to use for rendering\n * @public\n */\nexport function resolveComponent(fieldtype: string): string {\n\treturn isBuiltinFieldType(fieldtype) ? getDefaultComponent(fieldtype) : 'ATextInput'\n}\n","import { z } from 'zod'\n\nimport type { ColumnSchema } from './column-schema'\nimport { StonecropFieldType } from './fieldtype'\nimport type { InteractionMode } from './mode'\nimport { TableViewConfig } from './table'\n\n/**\n * Field options - flexible bag for type-specific configuration.\n *\n * Usage by fieldtype:\n * - Link/Doctype: target doctype slug as string (\"customer\", \"sales-order-item\")\n * - Select: array of choices ([\"Draft\", \"Submitted\", \"Cancelled\"])\n * - Decimal: config object (\\{ precision: 10, scale: 2 \\})\n * - Code: config object (\\{ language: \"python\" \\})\n *\n * @public\n */\nexport const FieldOptions = z\n\t.union([\n\t\tz.string(), // Link/Doctype target: \"customer\"\n\t\tz.array(z.string()), // Select choices: [\"A\", \"B\", \"C\"]\n\t\tz.record(z.string(), z.unknown()), // Config: \\{ precision: 10, scale: 2 \\}\n\t])\n\t.meta({\n\t\ttitle: 'FieldOptions',\n\t\tdescription: 'Field options - flexible bag for type-specific configuration',\n\t})\n\n/**\n * Field options type inferred from Zod schema\n * @public\n */\nexport type FieldOptions = z.infer<typeof FieldOptions>\n\n/**\n * Validation configuration for form fields\n * @public\n */\nexport const FieldValidation = z\n\t.looseObject({\n\t\t/** Error message to display when validation fails */\n\t\terrorMessage: z.string(),\n\t})\n\t.meta({\n\t\ttitle: 'FieldValidation',\n\t\tdescription: 'Validation configuration for form fields',\n\t})\n\n/**\n * Field validation type inferred from Zod schema\n * @public\n */\nexport type FieldValidation = z.infer<typeof FieldValidation>\n\n// ---------------------------------------------------------------------------\n// DoctypeField — the discriminated union of authoring-time field variants\n// ---------------------------------------------------------------------------\n\n/**\n * A field that holds a scalar value, a link to another record, or a select choice.\n * The most common kind of field. `fieldtype` determines the default component and behavior.\n * @public\n */\nexport interface ValueField {\n\t/** Discriminator — identifies this as a value-holding field */\n\tkind: 'field'\n\t/** Unique identifier for this field within its doctype */\n\tfieldname: string\n\t/** Semantic field type — determines behavior and default rendering component */\n\tfieldtype: string\n\t/** Vue component to render this field. Derived from `fieldtype` when absent. */\n\tcomponent?: string\n\t/** Human-readable label */\n\tlabel?: string\n\t/** CSS width (e.g. `\"40ch\"`, `\"200px\"`) */\n\twidth?: string\n\t/** Text alignment */\n\talign?: 'left' | 'center' | 'right' | 'start' | 'end'\n\t/** Whether the field is editable in table cell context */\n\tedit?: boolean\n\t/** Input mask pattern or serialized function */\n\tmask?: string\n\t/** Per-field interaction mode override */\n\tmode?: InteractionMode\n\t/** Type-specific options: Link target slug, Select choices, Decimal precision config, etc. */\n\toptions?: FieldOptions\n\t/** Whether the field is required */\n\trequired?: boolean\n\t/** Whether the field is read-only */\n\treadOnly?: boolean\n\t/** Whether the field is hidden from the UI */\n\thidden?: boolean\n\t/** Default value for new records */\n\tdefault?: unknown\n\t/** Validation configuration */\n\tvalidation?: FieldValidation\n\t/** Cardinality for Link fields — authoritative value on LinkDeclaration takes precedence */\n\tcardinality?: 'atMostOne' | 'one' | 'noneOrMany' | 'atLeastOne'\n}\n\n/**\n * A layout container that groups other fields. Resolves to a nested AForm.\n * @public\n */\nexport interface FieldsetField {\n\t/** Discriminator — identifies this as a fieldset container */\n\tkind: 'fieldset'\n\t/** Unique identifier for this fieldset within its doctype */\n\tfieldname: string\n\t/** Vue component to render this fieldset. Defaults to `'AFieldset'` in resolveSchema. */\n\tcomponent?: string\n\t/** Human-readable label for the fieldset legend */\n\tlabel?: string\n\t/** Whether the fieldset can be collapsed */\n\tcollapsible?: boolean\n\t/** Interaction mode for all children inside this fieldset */\n\tmode?: InteractionMode\n\t/** Nested field definitions — resolved recursively by resolveSchema */\n\tschema: DoctypeField[]\n}\n\n/**\n * An inline table whose columns are defined directly in the schema (no linked doctype).\n * Use when the table data does not warrant a separate doctype.\n * @public\n */\nexport interface TableField {\n\t/** Discriminator — identifies this as an inline table */\n\tkind: 'table'\n\t/** Unique identifier for this table within its doctype */\n\tfieldname: string\n\t/** Vue component to render this table. Defaults to `'ATable'` in resolveSchema. */\n\tcomponent?: string\n\t/** Human-readable label */\n\tlabel?: string\n\t/** Column definitions — use ColumnSchema (fieldname key) from \\@stonecrop/schema */\n\tcolumns: ColumnSchema[]\n\t/** View configuration — defaults to `{ view: 'list' }` in resolveSchema when absent */\n\tconfig?: TableViewConfig\n\t/** Interaction mode for all cells inside this table */\n\tmode?: InteractionMode\n}\n\n/**\n * Union of all authoring-time field variants.\n * Use `kind` to discriminate: `'field'` | `'fieldset'` | `'table'`.\n * @public\n */\nexport type DoctypeField = ValueField | FieldsetField | TableField\n\n// ---------------------------------------------------------------------------\n// Zod runtime validation schemas\n// ---------------------------------------------------------------------------\n\n/**\n * Infers the `kind` discriminant from the structural properties of a raw field\n * object, then injects it if absent. This allows authored JSON to omit `kind`\n * entirely — authors write only `fieldtype`, `schema`, or `columns`.\n *\n * Rules (applied in order):\n * has `schema` → fieldset\n * has `columns` → table\n * otherwise → field (value-holding scalar or link)\n *\n * Objects that already carry `kind` pass through unchanged (backward-compatible).\n */\nfunction injectKind(data: unknown): unknown {\n\tif (typeof data !== 'object' || data === null || Array.isArray(data)) return data\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- safe: non-null, non-array object verified by guards above\n\tconst obj = data as Record<string, unknown>\n\tif ('kind' in obj) return data\n\tif ('schema' in obj) return { kind: 'fieldset', ...obj }\n\tif ('columns' in obj) return { kind: 'table', ...obj }\n\treturn { kind: 'field', ...obj }\n}\n\nfunction createDoctypeFieldSchemas() {\n\tconst ValueFieldSchema = z\n\t\t.object({\n\t\t\tkind: z.literal('field'),\n\t\t\tfieldname: z.string().min(1),\n\t\t\tfieldtype: StonecropFieldType,\n\t\t\tcomponent: z.string().optional(),\n\t\t\tlabel: z.string().optional(),\n\t\t\twidth: z.string().optional(),\n\t\t\talign: z.enum(['left', 'center', 'right', 'start', 'end']).optional(),\n\t\t\tedit: z.boolean().optional(),\n\t\t\tmask: z.string().optional(),\n\t\t\tmode: z.enum(['edit', 'read', 'display']).optional(),\n\t\t\toptions: FieldOptions.optional(),\n\t\t\trequired: z.boolean().optional(),\n\t\t\treadOnly: z.boolean().optional(),\n\t\t\thidden: z.boolean().optional(),\n\t\t\tdefault: z.unknown().optional(),\n\t\t\tvalidation: FieldValidation.optional(),\n\t\t\tcardinality: z.enum(['atMostOne', 'one', 'noneOrMany', 'atLeastOne']).optional(),\n\t\t})\n\t\t.meta({ title: 'ValueField' })\n\n\tconst TableFieldSchema = z\n\t\t.object({\n\t\t\tkind: z.literal('table'),\n\t\t\tfieldname: z.string().min(1),\n\t\t\tcomponent: z.string().optional(),\n\t\t\tlabel: z.string().optional(),\n\t\t\t// Validates that each column has fieldname; allows all other ColumnSchema properties\n\t\t\tcolumns: z.array(z.object({ fieldname: z.string().min(1) }).passthrough()),\n\t\t\tconfig: TableViewConfig.optional(),\n\t\t\tmode: z.enum(['edit', 'read', 'display']).optional(),\n\t\t})\n\t\t.meta({ title: 'TableField' })\n\n\t// DoctypeFieldSchema must be declared before FieldsetFieldSchema so the z.lazy\n\t// callback can close over it. The placeholder is overwritten below; the callback\n\t// only runs at parse time, after the real discriminated union is assigned.\n\t// See: https://zod.dev/api?id=discriminated-unions#discriminated-unions\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- required by Zod's recursive schema pattern; z.never() placeholder is overwritten before any parse call\n\tlet DoctypeFieldSchema: z.ZodType<DoctypeField> = z.never() as unknown as z.ZodType<DoctypeField>\n\n\t// FieldsetFieldSchema stays as a plain ZodObject (not z.ZodType<T>) so that\n\t// z.discriminatedUnion can inspect its 'kind' discriminant property.\n\tconst FieldsetFieldSchema = z\n\t\t.object({\n\t\t\tkind: z.literal('fieldset'),\n\t\t\tfieldname: z.string().min(1),\n\t\t\tcomponent: z.string().optional(),\n\t\t\tlabel: z.string().optional(),\n\t\t\tcollapsible: z.boolean().optional(),\n\t\t\tmode: z.enum(['edit', 'read', 'display']).optional(),\n\t\t\tschema: z.lazy(() => DoctypeFieldSchema.array()),\n\t\t})\n\t\t.meta({ title: 'FieldsetField' })\n\n\tconst rawUnion = z.discriminatedUnion('kind', [ValueFieldSchema, FieldsetFieldSchema, TableFieldSchema])\n\n\t// Overwrite the placeholder with the preprocessed schema. Because z.lazy captures\n\t// DoctypeFieldSchema by closure reference, the lazy callback in FieldsetFieldSchema\n\t// will resolve to this preprocessed version — so nested fieldsets also inject `kind`.\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- ZodPipe output is DoctypeField; same pattern as the z.never() placeholder above\n\tDoctypeFieldSchema = z.preprocess(injectKind, rawUnion) as unknown as z.ZodType<DoctypeField>\n\n\treturn { ValueFieldSchema, TableFieldSchema, FieldsetFieldSchema, DoctypeFieldSchema }\n}\n\nconst schemas = createDoctypeFieldSchemas()\n\n/**\n * Zod runtime validation schema for ValueField.\n * @public\n */\nexport const ValueFieldSchema = schemas.ValueFieldSchema\n\n/**\n * Zod runtime validation schema for FieldsetField.\n * Recursive — FieldsetField.schema is validated against DoctypeFieldSchema.\n * @public\n */\nexport const FieldsetFieldSchema = schemas.FieldsetFieldSchema\n\n/**\n * Zod runtime validation schema for TableField.\n * @public\n */\nexport const TableFieldSchema = schemas.TableFieldSchema\n\n/**\n * Zod runtime validation schema for the DoctypeField discriminated union.\n * Validates all three field variants: `'field'`, `'fieldset'`, `'table'`.\n * @public\n */\nexport const DoctypeFieldSchema = schemas.DoctypeFieldSchema\n","import { z } from 'zod'\n\nimport { DoctypeFieldSchema } from './field'\n\n/**\n * Cardinality for relationship links.\n * @public\n */\nexport const Cardinality = z.enum(['atMostOne', 'one', 'noneOrMany', 'atLeastOne']).meta({\n\ttitle: 'Cardinality',\n\tdescription: 'Cardinality for relationship links between doctypes',\n})\n\n/**\n * Cardinality type inferred from Zod schema\n * @public\n */\nexport type Cardinality = z.infer<typeof Cardinality>\n\n/**\n * Serialized function type - a function serialized to a string.\n * Used for custom fetch handlers.\n * @public\n */\nexport type SerializedFunction = string\n\n/**\n * Sync fetch strategy - data is fetched in the initial query.\n * @public\n */\nexport const SyncFetch = z\n\t.object({\n\t\t/** Fetch method type */\n\t\tmethod: z.literal('sync'),\n\t\t/** Optional limit on number of records to fetch */\n\t\tlimit: z.number().int().positive().optional(),\n\t})\n\t.meta({\n\t\ttitle: 'SyncFetch',\n\t\tdescription: 'Sync fetch strategy - data is fetched in the initial query',\n\t})\n\n/**\n * Sync fetch strategy type\n * @public\n */\nexport type SyncFetch = z.infer<typeof SyncFetch>\n\n/**\n * Lazy fetch strategy - data is fetched on demand in a separate query.\n * @public\n */\nexport const LazyFetch = z\n\t.object({\n\t\t/** Fetch method type */\n\t\tmethod: z.literal('lazy'),\n\t})\n\t.meta({\n\t\ttitle: 'LazyFetch',\n\t\tdescription: 'Lazy fetch strategy - data is fetched on demand in a separate query',\n\t})\n\n/**\n * Lazy fetch strategy type\n * @public\n */\nexport type LazyFetch = z.infer<typeof LazyFetch>\n\n/**\n * Custom fetch strategy - uses a custom handler function.\n * @public\n */\nexport const CustomFetch = z\n\t.object({\n\t\t/** Fetch method type */\n\t\tmethod: z.literal('custom'),\n\t\t/** Serialized handler function to invoke */\n\t\thandler: z.string(),\n\t})\n\t.meta({\n\t\ttitle: 'CustomFetch',\n\t\tdescription: 'Custom fetch strategy - uses a custom handler function',\n\t})\n\n/**\n * Custom fetch strategy type\n * @public\n */\nexport type CustomFetch = z.infer<typeof CustomFetch>\n\n/**\n * Fetch strategy for link data loading.\n * - sync: fetched in the initial query\n * - lazy: fetched on demand in a separate query\n * - custom: uses a custom handler function\n * @public\n */\nexport const FetchStrategy = z.discriminatedUnion('method', [SyncFetch, LazyFetch, CustomFetch]).meta({\n\ttitle: 'FetchStrategy',\n\tdescription: 'Fetch strategy for link data loading',\n})\n\n/**\n * Fetch strategy type\n * @public\n */\nexport type FetchStrategy = z.infer<typeof FetchStrategy>\n\n/**\n * Link declaration - describes a relationship from one doctype to another.\n * @public\n */\nexport const LinkDeclaration = z\n\t.object({\n\t\t/** Target doctype slug */\n\t\ttarget: z.string().min(1),\n\n\t\t/** Cardinality of the relationship */\n\t\tcardinality: Cardinality,\n\n\t\t/** Backlink fieldname on the target doctype that points back to this link */\n\t\tbacklink: z.string().optional(),\n\n\t\t/** Override default rendering component (AForm for 1:1, ATable for 1:many) */\n\t\tcomponent: z.string().optional(),\n\n\t\t/** Fieldname of the corresponding Link field in the fields array */\n\t\tfieldname: z.string().min(1).optional(),\n\n\t\t/** Fetch strategy for loading nested data */\n\t\tfetch: FetchStrategy.optional(),\n\n\t\t/** Whether to block workflow actions until nested data is loaded (default: true) */\n\t\tblockWorkflows: z.boolean().optional(),\n\t})\n\t.meta({\n\t\ttitle: 'LinkDeclaration',\n\t\tdescription: 'Declares a relationship from one doctype to another',\n\t})\n\n/**\n * Link declaration type inferred from Zod schema\n * @public\n */\nexport type LinkDeclaration = z.infer<typeof LinkDeclaration>\n\n/**\n * Action definition within a workflow\n * @public\n */\nexport const ActionDefinition = z\n\t.object({\n\t\t/** Display label for the action */\n\t\tlabel: z.string().min(1),\n\n\t\t/** Handler function name or path */\n\t\thandler: z.string().min(1),\n\n\t\t/** Fields that must have values before action can execute */\n\t\trequiredFields: z.array(z.string()).optional(),\n\n\t\t/** Workflow states where this action is available */\n\t\tallowedStates: z.array(z.string()).optional(),\n\n\t\t/** The state the record transitions to after this action executes */\n\t\tnextState: z.string().optional(),\n\n\t\t/** True for side-effect actions that do not change workflow state (save, print, email, etc.) */\n\t\tstateless: z.boolean().optional(),\n\n\t\t/** JS function body stored as a string; executed client-side via AsyncFunction with injected API surface */\n\t\tclientHandler: z.string().optional(),\n\t})\n\t.meta({\n\t\ttitle: 'ActionDefinition',\n\t\tdescription: 'Action definition within a workflow',\n\t})\n\n/**\n * Action definition type inferred from Zod schema\n * @public\n */\nexport type ActionDefinition = z.infer<typeof ActionDefinition>\n\n/**\n * Whether a workflow action may run from `currentState`.\n *\n * Single source of truth for the \"is this action available here\" rule, shared by\n * the frontend (`getAvailableTransitions`) and the server-side dispatch guard so\n * the two can never disagree. Empty or absent `allowedStates` means the action is\n * available in ALL states — a plain `allowedStates.includes(currentState)` would\n * wrongly block such actions everywhere.\n *\n * @public\n */\nexport function isActionAllowedInState(\n\taction: { allowedStates?: string[] | null },\n\tcurrentState: string\n): boolean {\n\tconst allowedStates = action.allowedStates\n\tif (!allowedStates || allowedStates.length === 0) return true\n\treturn allowedStates.includes(currentState)\n}\n\n/**\n * Workflow metadata - states and actions for a doctype\n * @public\n */\nexport const WorkflowMeta = z\n\t.object({\n\t\t/** List of workflow states */\n\t\tstates: z.array(z.string()).optional(),\n\n\t\t/** Actions available in this workflow */\n\t\tactions: z.record(z.string(), ActionDefinition).optional(),\n\t})\n\t.meta({\n\t\ttitle: 'WorkflowMeta',\n\t\tdescription: 'Workflow metadata - states and actions for a doctype',\n\t})\n\n/**\n * Workflow metadata type inferred from Zod schema\n * @public\n */\nexport type WorkflowMeta = z.infer<typeof WorkflowMeta>\n\n/**\n * Doctype metadata - complete definition of a doctype\n * @public\n */\nexport const DoctypeMeta = z\n\t.object({\n\t\t/** Display name of the doctype */\n\t\tname: z.string().min(1),\n\n\t\t/** URL-friendly slug (kebab-case) */\n\t\tslug: z.string().min(1).optional(),\n\n\t\t/** Field definitions (including link fields with fieldtype: 'Link') */\n\t\tfields: z.array(DoctypeFieldSchema),\n\n\t\t/** Relationship links to other doctypes */\n\t\tlinks: z.record(z.string(), LinkDeclaration).optional(),\n\n\t\t/** Workflow configuration */\n\t\tworkflow: WorkflowMeta.optional(),\n\n\t\t/** Parent doctype for inheritance */\n\t\tinherits: z.string().optional(),\n\t})\n\t.meta({\n\t\ttitle: 'DoctypeMeta',\n\t\tdescription: 'Doctype metadata - complete definition of a doctype',\n\t})\n\n/**\n * Doctype metadata type inferred from Zod schema\n * @public\n */\nexport type DoctypeMeta = z.infer<typeof DoctypeMeta>\n\n/**\n * Context for identifying what doctype/record we're working with.\n * Used by graphql-middleware and graphql-client to resolve schema metadata.\n * @public\n */\nexport interface DoctypeContext {\n\t/** Doctype name (e.g., 'Task', 'Customer') */\n\tdoctype: string\n\t/** Optional record ID for viewing/editing a specific record */\n\trecordId?: string\n\t/** Additional context properties */\n\t[key: string]: unknown\n}\n\n/**\n * Base interface for doctype metadata passed to DataClient methods.\n * Only requires properties needed for record fetching.\n * @public\n */\nexport interface DoctypeRef {\n\t/** Doctype name (e.g., 'Task', 'Customer') */\n\tname: string\n\t/** URL-friendly slug (e.g., 'task', 'customer') */\n\tslug?: string\n}\n\n/**\n * Options for fetching a single record\n * @public\n */\nexport interface GetRecordOptions {\n\t/**\n\t * Include nested link sub-selections.\n\t * - `true`: include all descendant links\n\t * - `string[]`: include only named links\n\t * - `false` / omitted: scalar fields only (default)\n\t */\n\tincludeNested?: boolean | string[]\n\n\t/**\n\t * Maximum depth for recursive sub-selections.\n\t * No default — unlimited when omitted.\n\t */\n\tmaxDepth?: number\n}\n\n/**\n * Options for fetching multiple records\n * @public\n */\nexport interface GetRecordsOptions {\n\t/** Filter expression (field-value pairs) */\n\tfilters?: Record<string, unknown>\n\t/** Order by expression (e.g. 'NAME_ASC') */\n\torderBy?: string\n\t/** Maximum number of records to return */\n\tlimit?: number\n\t/** Number of records to skip */\n\toffset?: number\n}\n\n/**\n * Result from getRecord - includes the record data\n * @public\n */\nexport interface GetRecordResult {\n\t/** The record data, or null if not found */\n\trecord: Record<string, unknown> | null\n}\n\n/**\n * Interface for data clients that fetch doctype metadata and records.\n * Implemented by \\@stonecrop/graphql-client's StonecropClient.\n * Custom implementations can use any backend (REST, local storage, etc.).\n *\n * @typeParam T - Doctype reference type for record operations (defaults to DoctypeRef)\n * @typeParam M - Doctype metadata return type for getMeta (defaults to DoctypeMeta)\n * @public\n */\nexport interface DataClient<T extends DoctypeRef = DoctypeRef, M = DoctypeMeta> {\n\t/**\n\t * Fetch doctype metadata\n\t * @param context - Doctype context identifying the doctype\n\t * @returns Doctype metadata or null if not found\n\t */\n\tgetMeta(context: DoctypeContext): Promise<M | null>\n\n\t/**\n\t * Fetch a single record by ID\n\t *\n\t * When `includeNested` is set, builds a query with sub-selections for descendant\n\t * links and returns ancestor + merged descendants. When omitted, returns flat scalar data.\n\t *\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param recordId - Record ID to fetch\n\t * @param options - Query options\n\t * @returns Record data wrapped in GetRecordResult\n\t */\n\tgetRecord(doctype: T, recordId: string, options?: GetRecordOptions): Promise<GetRecordResult>\n\n\t/**\n\t * Fetch multiple records\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param options - Query options\n\t * @returns Array of record data\n\t */\n\tgetRecords(doctype: T, options?: GetRecordsOptions): Promise<Record<string, unknown>[]>\n\n\t/**\n\t * Execute a doctype action (e.g., SUBMIT, APPROVE, save).\n\t * All state changes flow through this single mutation endpoint.\n\t *\n\t * @param doctype - Doctype reference (name and optional slug)\n\t * @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')\n\t * @param args - Action arguments (typically record ID and/or form data)\n\t * @returns Action result with success status, response data, and any error\n\t */\n\trunAction(\n\t\tdoctype: T,\n\t\taction: string,\n\t\targs?: unknown[]\n\t): Promise<{ success: boolean; data: unknown; error: string | null }>\n}\n","import { DoctypeFieldSchema } from './field'\nimport { DoctypeMeta } from './doctype'\n\n/**\n * Validation error with path information\n * @public\n */\nexport interface ValidationError {\n\t/** Path to the invalid property */\n\tpath: PropertyKey[]\n\n\t/** Error message */\n\tmessage: string\n}\n\n/**\n * Result of a validation operation\n * @public\n */\nexport interface ValidationResult {\n\t/** Whether validation passed */\n\tsuccess: boolean\n\n\t/** List of validation errors (empty if success) */\n\terrors: ValidationError[]\n}\n\n/**\n * Validate a field definition against the DoctypeField discriminated union\n * @param data - Data to validate\n * @returns Validation result\n * @public\n */\nexport function validateField(data: unknown): ValidationResult {\n\tconst result = DoctypeFieldSchema.safeParse(data)\n\n\tif (result.success) {\n\t\treturn { success: true, errors: [] }\n\t}\n\n\treturn {\n\t\tsuccess: false,\n\t\terrors: result.error.issues.map(issue => ({\n\t\t\tpath: issue.path,\n\t\t\tmessage: issue.message,\n\t\t})),\n\t}\n}\n\n/**\n * Validate a doctype definition\n * @param data - Data to validate\n * @returns Validation result\n * @public\n */\nexport function validateDoctype(data: unknown): ValidationResult {\n\tconst result = DoctypeMeta.safeParse(data)\n\n\tif (result.success) {\n\t\treturn { success: true, errors: [] }\n\t}\n\n\treturn {\n\t\tsuccess: false,\n\t\terrors: result.error.issues.map(issue => ({\n\t\t\tpath: issue.path,\n\t\t\tmessage: issue.message,\n\t\t})),\n\t}\n}\n\n/**\n * Parse and validate a field, throwing on failure\n * @param data - Data to parse\n * @returns Validated DoctypeField\n * @throws ZodError if validation fails\n * @public\n */\nexport function parseField(data: unknown): import('./field').DoctypeField {\n\treturn DoctypeFieldSchema.parse(data)\n}\n\n/**\n * Parse and validate a doctype, throwing on failure\n * @param data - Data to parse\n * @returns Validated DoctypeMeta\n * @throws ZodError if validation fails\n * @public\n */\nexport function parseDoctype(data: unknown): DoctypeMeta {\n\treturn DoctypeMeta.parse(data)\n}\n\n// Re-export types for convenience\nexport type { DoctypeField, ValueField, FieldsetField, TableField } from './field'\nexport type { DoctypeMeta } from './doctype'\n","/**\n * Naming Convention Utilities\n * Converts between various naming conventions (snake_case, camelCase, PascalCase, kebab-case)\n * @packageDocumentation\n */\n\n/**\n * Converts snake_case to camelCase\n * @param snakeCase - Snake case string\n * @returns Camel case string\n * @public\n * @example\n * ```typescript\n * snakeToCamel('user_email') // 'userEmail'\n * snakeToCamel('created_at') // 'createdAt'\n * ```\n */\nexport function snakeToCamel(snakeCase: string): string {\n\treturn snakeCase.replace(/_([a-z])/g, (_: string, letter: string) => letter.toUpperCase())\n}\n\n/**\n * Converts camelCase to snake_case\n * @param camelCase - Camel case string\n * @returns Snake case string\n * @public\n * @example\n * ```typescript\n * camelToSnake('userEmail') // 'user_email'\n * camelToSnake('createdAt') // 'created_at'\n * ```\n */\nexport function camelToSnake(camelCase: string): string {\n\treturn camelCase.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`)\n}\n\n/**\n * Converts snake_case to Title Case label\n * @param snakeCase - Snake case string\n * @returns Title case label\n * @public\n * @example\n * ```typescript\n * snakeToLabel('user_email') // 'User Email'\n * snakeToLabel('first_name') // 'First Name'\n * ```\n */\nexport function snakeToLabel(snakeCase: string): string {\n\treturn snakeCase\n\t\t.split('_')\n\t\t.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(' ')\n}\n\n/**\n * Converts camelCase to Title Case label\n * @param camelCase - Camel case string\n * @returns Title case label\n * @public\n * @example\n * ```typescript\n * camelToLabel('userEmail') // 'User Email'\n * camelToLabel('firstName') // 'First Name'\n * ```\n */\nexport function camelToLabel(camelCase: string): string {\n\tconst withSpaces = camelCase.replace(/([A-Z])/g, ' $1').trim()\n\treturn withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1)\n}\n\n/**\n * Convert table name to PascalCase doctype name\n * @param tableName - SQL table name (snake_case)\n * @returns PascalCase name\n * @public\n */\nexport function toPascalCase(tableName: string): string {\n\treturn tableName\n\t\t.split(/[-_\\s]+/)\n\t\t.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join('')\n}\n\n/**\n * Convert to kebab-case slug\n * @param name - Name to convert\n * @returns kebab-case slug\n * @public\n */\nexport function toSlug(name: string): string {\n\treturn name\n\t\t.replace(/([a-z])([A-Z])/g, '$1-$2')\n\t\t.replace(/[\\s_]+/g, '-')\n\t\t.toLowerCase()\n}\n\n/**\n * Convert PascalCase to snake_case (e.g., for deriving table names from type names)\n * @param pascal - PascalCase string\n * @returns snake_case string\n * @public\n * @example\n * ```typescript\n * pascalToSnake('SalesOrder') // 'sales_order'\n * pascalToSnake('SalesOrderItem') // 'sales_order_item'\n * ```\n */\nexport function pascalToSnake(pascal: string): string {\n\treturn pascal\n\t\t.replace(/([a-z])([A-Z])/g, '$1_$2')\n\t\t.replace(/[\\s-]+/g, '_')\n\t\t.toLowerCase()\n}\n","/**\n * GraphQL Scalar Type Mappings\n *\n * Maps standard GraphQL scalars and well-known custom scalars to Stonecrop field types.\n * Source-agnostic — covers scalars commonly emitted by PostGraphile, Hasura, Apollo, etc.\n *\n * Users can extend these via the `customScalars` option in `GraphQLConversionOptions`.\n *\n * @packageDocumentation\n */\n\nimport type { FieldTemplate } from '../fieldtype'\n\n/**\n * Mapping from standard GraphQL scalar types to Stonecrop field types.\n * These are defined by the GraphQL specification and are always available.\n *\n * @public\n */\nexport const GQL_SCALAR_MAP: Record<string, FieldTemplate> = {\n\tString: { component: 'ATextInput', fieldtype: 'Data' },\n\tInt: { component: 'ANumericInput', fieldtype: 'Int' },\n\tFloat: { component: 'ANumericInput', fieldtype: 'Float' },\n\tBoolean: { component: 'ACheckbox', fieldtype: 'Check' },\n\tID: { component: 'ATextInput', fieldtype: 'Data' },\n}\n\n/**\n * Mapping from well-known custom GraphQL scalars to Stonecrop field types.\n * These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)\n * without baking in knowledge of any specific server.\n *\n * Entries here have lower precedence than `customScalars` from options, but higher\n * precedence than unknown/unmapped scalars.\n *\n * @public\n */\nexport const WELL_KNOWN_SCALARS: Record<string, FieldTemplate> = {\n\t// Arbitrary precision / large numbers\n\tBigFloat: { component: 'ADecimalInput', fieldtype: 'Decimal' },\n\tBigDecimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },\n\tDecimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },\n\tBigInt: { component: 'ANumericInput', fieldtype: 'Int' },\n\tLong: { component: 'ANumericInput', fieldtype: 'Int' },\n\n\t// Identifiers\n\tUUID: { component: 'ATextInput', fieldtype: 'Data' },\n\n\t// Date / Time\n\tDateTime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },\n\tDatetime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },\n\tDate: { component: 'ADate', fieldtype: 'Date' },\n\tTime: { component: 'ATimeInput', fieldtype: 'Time' },\n\tInterval: { component: 'ADurationInput', fieldtype: 'Duration' },\n\tDuration: { component: 'ADurationInput', fieldtype: 'Duration' },\n\n\t// Structured data\n\tJSON: { component: 'ACodeEditor', fieldtype: 'JSON' },\n\tJSONObject: { component: 'ACodeEditor', fieldtype: 'JSON' },\n\tJsonNode: { component: 'ACodeEditor', fieldtype: 'JSON' },\n}\n\n/**\n * Set of scalar type names that are internal to GraphQL servers and should be skipped\n * during field conversion (they don't represent meaningful data fields).\n *\n * @public\n */\nexport const INTERNAL_SCALARS = new Set(['Cursor'])\n\n/**\n * Build a merged scalar map from the built-in maps and user-provided custom scalars.\n * Precedence (highest to lowest): customScalars → GQL_SCALAR_MAP → WELL_KNOWN_SCALARS\n *\n * @param customScalars - User-provided scalar overrides\n * @returns Merged scalar map\n * @public\n */\nexport function buildScalarMap(customScalars?: Record<string, Partial<FieldTemplate>>): Record<string, FieldTemplate> {\n\tconst merged: Record<string, FieldTemplate> = { ...WELL_KNOWN_SCALARS }\n\n\t// Standard scalars override well-known\n\tfor (const [key, value] of Object.entries(GQL_SCALAR_MAP)) {\n\t\tmerged[key] = value\n\t}\n\n\t// Custom scalars override everything\n\tif (customScalars) {\n\t\tfor (const [key, value] of Object.entries(customScalars)) {\n\t\t\tmerged[key] = {\n\t\t\t\tcomponent: value.component ?? 'ATextInput',\n\t\t\t\tfieldtype: value.fieldtype ?? 'Data',\n\t\t\t}\n\t\t}\n\t}\n\n\treturn merged\n}\n","/**\n * Default heuristics for identifying entity types and fields in a GraphQL schema.\n *\n * These heuristics work across common GraphQL servers (PostGraphile, Hasura, Apollo, etc.)\n * by detecting widely-adopted conventions like the Relay connection pattern.\n *\n * All heuristics can be overridden via the `isEntityType`, `isEntityField`, and\n * `classifyField` options in `GraphQLConversionOptions`.\n *\n * @packageDocumentation\n */\n\nimport {\n\tisScalarType,\n\tisEnumType,\n\tisObjectType,\n\tisListType,\n\tisNonNullType,\n\tisNamedType,\n\ttype GraphQLObjectType,\n\ttype GraphQLField,\n\ttype GraphQLOutputType,\n\ttype GraphQLNamedType,\n} from 'graphql'\n\nimport type { FieldTemplate } from '../fieldtype'\nimport type { GraphQLConversionFieldMeta, GraphQLConversionOptions } from './types'\nimport { buildScalarMap, INTERNAL_SCALARS } from './scalars'\nimport { toSlug, camelToLabel, toPascalCase } from '../naming'\n\n/**\n * Suffixes that identify synthetic/framework types generated by GraphQL servers.\n * Types ending with these suffixes are typically not entities.\n */\nconst SYNTHETIC_SUFFIXES = [\n\t'Connection',\n\t'Edge',\n\t'Input',\n\t'Patch',\n\t'Payload',\n\t'Condition',\n\t'Filter',\n\t'OrderBy',\n\t'Aggregate',\n\t'AggregateResult',\n\t'AggregateFilter',\n\t'DeleteResponse',\n\t'InsertResponse',\n\t'UpdateResponse',\n\t'MutationResponse',\n]\n\n/**\n * Root operation type names that are never entities.\n */\nconst ROOT_TYPE_NAMES = new Set(['Query', 'Mutation', 'Subscription'])\n\n/**\n * Default heuristic to determine if a GraphQL object type represents an entity.\n * An entity type becomes a Stonecrop doctype.\n *\n * This heuristic excludes:\n * - Introspection types (`__*`)\n * - Root operation types (`Query`, `Mutation`, `Subscription`)\n * - Types with synthetic suffixes (e.g., `*Connection`, `*Edge`, `*Input`)\n * - Types starting with `Node` interface marker (exact match only)\n *\n * @param typeName - The GraphQL type name\n * @param type - The GraphQL object type definition\n * @returns `true` if this type should become a Stonecrop doctype\n * @public\n */\nexport function defaultIsEntityType(typeName: string, type: GraphQLObjectType): boolean {\n\t// Exclude introspection types\n\tif (typeName.startsWith('__')) {\n\t\treturn false\n\t}\n\n\t// Exclude root operation types\n\tif (ROOT_TYPE_NAMES.has(typeName)) {\n\t\treturn false\n\t}\n\n\t// Exclude the Node interface marker type\n\tif (typeName === 'Node') {\n\t\treturn false\n\t}\n\n\t// Exclude types matching synthetic suffixes\n\tfor (const suffix of SYNTHETIC_SUFFIXES) {\n\t\tif (typeName.endsWith(suffix)) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Must have at least one field\n\tconst fields = type.getFields()\n\tif (Object.keys(fields).length === 0) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/**\n * Fields to skip by default on entity types.\n * These are internal to GraphQL servers and don't represent semantic data.\n */\nconst SKIP_FIELDS = new Set(['nodeId', '__typename', 'clientMutationId'])\n\n/**\n * Default heuristic to filter fields on entity types.\n * Skips internal fields that don't represent meaningful data.\n *\n * @param fieldName - The GraphQL field name\n * @param _field - The GraphQL field definition (unused in default implementation)\n * @param _parentType - The parent entity type (unused in default implementation)\n * @returns `true` if this field should be included\n * @public\n */\nexport function defaultIsEntityField(\n\tfieldName: string,\n\t_field: GraphQLField<unknown, unknown>,\n\t_parentType: GraphQLObjectType\n): boolean {\n\treturn !SKIP_FIELDS.has(fieldName)\n}\n\n/**\n * Unwrap NonNull and List wrappers from a GraphQL type, tracking nullability.\n *\n * @param type - The GraphQL output type\n * @returns The unwrapped named type, whether it's required, and whether it's a list\n * @internal\n */\nfunction unwrapType(type: GraphQLOutputType): {\n\tnamedType: GraphQLNamedType\n\trequired: boolean\n\tisList: boolean\n} {\n\tlet required = false\n\tlet isList = false\n\tlet current: GraphQLOutputType = type\n\n\t// Unwrap outer NonNull\n\tif (isNonNullType(current)) {\n\t\trequired = true\n\t\tcurrent = current.ofType\n\t}\n\n\t// Unwrap List\n\tif (isListType(current)) {\n\t\tisList = true\n\t\tcurrent = current.ofType\n\n\t\t// Unwrap inner NonNull (e.g., [Type!])\n\t\tif (isNonNullType(current)) {\n\t\t\tcurrent = current.ofType\n\t\t}\n\t}\n\n\t// At this point, current should be a named type (scalar, enum, or object)\n\tif (!isNamedType(current)) {\n\t\tthrow new Error(`Expected a named GraphQL type, got: ${String(current)}`)\n\t}\n\treturn { namedType: current, required, isList }\n}\n\n/**\n * Check if a GraphQL object type looks like a Relay Connection type.\n * A connection type has an `edges` field returning a list of edge types,\n * where each edge has a `node` field.\n *\n * @param type - The GraphQL object type to check\n * @returns The node type name if this is a connection, or `undefined`\n * @internal\n */\nfunction getConnectionNodeType(type: GraphQLObjectType): string | undefined {\n\tconst fields = type.getFields()\n\n\t// Must have an 'edges' field\n\tconst edgesField = fields['edges']\n\tif (!edgesField) return undefined\n\n\t// edges must be a list\n\tconst { namedType: edgesType, isList: edgesIsList } = unwrapType(edgesField.type)\n\tif (!edgesIsList || !isObjectType(edgesType)) return undefined\n\n\t// Each edge must have a 'node' field\n\tconst edgeFields = edgesType.getFields()\n\tconst nodeField = edgeFields['node']\n\tif (!nodeField) return undefined\n\n\tconst { namedType: nodeType } = unwrapType(nodeField.type)\n\tif (!isObjectType(nodeType)) return undefined\n\n\treturn nodeType.name\n}\n\n/**\n * Classify a single GraphQL field into a Stonecrop field definition.\n *\n * Classification rules (in order):\n * 1. Scalar types → look up in merged scalar map\n * 2. Enum types → `Select` with enum values as options\n * 3. Object types that are entities → `Link` with slug as options\n * 4. Object types that are Connections → `Doctype` with node type slug as options\n * 5. List of entity type → `Doctype` with item type slug as options\n * 6. Anything else → `Data` with `_unmapped: true`\n *\n * @param fieldName - The GraphQL field name\n * @param field - The GraphQL field definition\n * @param entityTypes - Set of type names classified as entities\n * @param options - Conversion options (for custom scalars, unmapped meta, etc.)\n * @returns The Stonecrop field definition\n * @public\n */\nexport function classifyFieldType(\n\tfieldName: string,\n\tfield: GraphQLField<unknown, unknown>,\n\tentityTypes: Set<string>,\n\toptions: GraphQLConversionOptions = {}\n): GraphQLConversionFieldMeta {\n\tconst { namedType, required, isList } = unwrapType(field.type)\n\tconst scalarMap = buildScalarMap(options.customScalars)\n\n\tconst base: GraphQLConversionFieldMeta = {\n\t\tkind: 'field',\n\t\tfieldname: fieldName,\n\t\tlabel: camelToLabel(fieldName),\n\t\tcomponent: 'ATextInput',\n\t\tfieldtype: 'Data',\n\t}\n\n\tif (required) {\n\t\tbase.required = true\n\t}\n\n\t// 1. Scalar types\n\tif (isScalarType(namedType)) {\n\t\t// Skip internal scalars (e.g., Cursor)\n\t\tif (INTERNAL_SCALARS.has(namedType.name)) {\n\t\t\tbase._unmapped = true\n\t\t\tif (options.includeUnmappedMeta) {\n\t\t\t\tbase._graphqlType = namedType.name\n\t\t\t}\n\t\t\treturn base\n\t\t}\n\n\t\t// Special case: ID fields that reference an entity type → Link\n\t\tif (namedType.name === 'ID') {\n\t\t\tconst candidateTypeName = toPascalCase(fieldName)\n\t\t\tif (entityTypes.has(candidateTypeName)) {\n\t\t\t\tbase.component = 'ALink'\n\t\t\t\tbase.fieldtype = 'Link'\n\t\t\t\tbase.options = toSlug(candidateTypeName)\n\t\t\t\treturn base\n\t\t\t}\n\t\t}\n\n\t\tconst template: FieldTemplate | undefined = scalarMap[namedType.name]\n\t\tif (template) {\n\t\t\tbase.component = template.component\n\t\t\tbase.fieldtype = template.fieldtype\n\t\t} else {\n\t\t\t// Unknown scalar — default to Data with unmapped marker\n\t\t\tbase._unmapped = true\n\t\t\tif (options.includeUnmappedMeta) {\n\t\t\t\tbase._graphqlType = namedType.name\n\t\t\t}\n\t\t}\n\t\treturn base\n\t}\n\n\t// 2. Enum types → Select\n\tif (isEnumType(namedType)) {\n\t\tbase.component = 'ADropdown'\n\t\tbase.fieldtype = 'Select'\n\t\tbase.options = namedType.getValues().map(v => v.name)\n\t\treturn base\n\t}\n\n\t// 3–5. Object types\n\tif (isObjectType(namedType)) {\n\t\t// 3. Direct reference to an entity type → Link\n\t\tif (!isList && entityTypes.has(namedType.name)) {\n\t\t\tbase.component = 'ALink'\n\t\t\tbase.fieldtype = 'Link'\n\t\t\tbase.options = toSlug(namedType.name)\n\t\t\treturn base\n\t\t}\n\n\t\t// 4. Connection type → link (child table)\n\t\tconst connectionNodeTypeName = getConnectionNodeType(namedType)\n\t\tif (connectionNodeTypeName && entityTypes.has(connectionNodeTypeName)) {\n\t\t\tbase.component = 'ATable'\n\t\t\tbase._isLink = true\n\t\t\tbase.options = toSlug(connectionNodeTypeName)\n\t\t\tbase.cardinality = 'noneOrMany'\n\t\t\tdelete base.fieldtype\n\t\t\treturn base\n\t\t}\n\n\t\t// 5. List of entity type → link\n\t\tif (isList && entityTypes.has(namedType.name)) {\n\t\t\tbase.component = 'ATable'\n\t\t\tbase._isLink = true\n\t\t\tbase.options = toSlug(namedType.name)\n\t\t\tbase.cardinality = 'noneOrMany'\n\t\t\tdelete base.fieldtype\n\t\t\treturn base\n\t\t}\n\n\t\t// Unknown object type — mark as unmapped\n\t\tbase._unmapped = true\n\t\tif (options.includeUnmappedMeta) {\n\t\t\tbase._graphqlType = namedType.name\n\t\t}\n\t\treturn base\n\t}\n\n\t// Fallback — shouldn't normally be reached\n\tbase._unmapped = true\n\tif (options.includeUnmappedMeta) {\n\t\tbase._graphqlType = namedType.name\n\t}\n\treturn base\n}\n","/**\n * GraphQL Introspection to Stonecrop Schema Converter\n *\n * Converts a standard GraphQL introspection result (or SDL string) into\n * Stonecrop doctype schemas. Source-agnostic — works with any GraphQL server.\n *\n * @packageDocumentation\n */\n\nimport { buildClientSchema, buildSchema, isObjectType, type GraphQLSchema } from 'graphql'\n\nimport type { LinkDeclaration } from '../doctype'\nimport { toSlug } from '../naming'\nimport type { IntrospectionSource, GraphQLConversionOptions, ConvertedGraphQLDoctype } from './types'\nimport type { ValueField } from '../field'\nimport { defaultIsEntityType, defaultIsEntityField, classifyFieldType } from './heuristics'\n\n/**\n * Convert a GraphQL schema to Stonecrop doctype schemas.\n *\n * Accepts either an `IntrospectionQuery` result object or an SDL string.\n * Entity types are identified using heuristics (or a custom `isEntityType` function)\n * and converted to `DoctypeMeta`-compatible JSON objects.\n *\n * @param source - GraphQL introspection result or SDL string\n * @param options - Conversion options for controlling output format and behavior\n * @returns Array of converted Stonecrop doctype definitions\n *\n * @example\n * ```typescript\n * // From introspection result (fetched from any GraphQL server)\n * const introspection = await fetchIntrospection('http://localhost:5000/graphql')\n * const doctypes = convertGraphQLSchema(introspection)\n *\n * // From SDL string\n * const sdl = fs.readFileSync('schema.graphql', 'utf-8')\n * const doctypes = convertGraphQLSchema(sdl)\n *\n * // With PostGraphile custom scalars\n * const doctypes = convertGraphQLSchema(introspection, {\n * customScalars: {\n * BigFloat: { component: 'ADecimalInput', fieldtype: 'Decimal' }\n * }\n * })\n * ```\n *\n * @public\n */\nexport function convertGraphQLSchema(\n\tsource: IntrospectionSource,\n\toptions: GraphQLConversionOptions = {}\n): ConvertedGraphQLDoctype[] {\n\tconst schema = buildGraphQLSchema(source)\n\tconst typeMap = schema.getTypeMap()\n\n\t// Determine the root operation type names to exclude\n\tconst rootTypeNames = new Set<string>()\n\tconst queryType = schema.getQueryType()\n\tconst mutationType = schema.getMutationType()\n\tconst subscriptionType = schema.getSubscriptionType()\n\tif (queryType) rootTypeNames.add(queryType.name)\n\tif (mutationType) rootTypeNames.add(mutationType.name)\n\tif (subscriptionType) rootTypeNames.add(subscriptionType.name)\n\n\t// Use custom or default entity type detector\n\tconst isEntityType = options.isEntityType ?? defaultIsEntityType\n\n\t// Phase 1: Identify all entity types\n\tconst entityTypes = new Set<string>()\n\tfor (const [typeName, type] of Object.entries(typeMap)) {\n\t\tif (!isObjectType(type)) continue\n\n\t\t// Always skip root operation types (even if custom isEntityType doesn't)\n\t\tif (rootTypeNames.has(typeName)) continue\n\n\t\tif (isEntityType(typeName, type)) {\n\t\t\tentityTypes.add(typeName)\n\t\t}\n\t}\n\n\t// Phase 2: Apply include/exclude filters\n\tlet filteredEntityTypes = entityTypes\n\n\tif (options.include) {\n\t\tconst includeSet = new Set(options.include)\n\t\tfilteredEntityTypes = new Set([...entityTypes].filter(t => includeSet.has(t)))\n\t}\n\n\tif (options.exclude) {\n\t\tconst excludeSet = new Set(options.exclude)\n\t\tfilteredEntityTypes = new Set([...filteredEntityTypes].filter(t => !excludeSet.has(t)))\n\t}\n\n\t// Phase 3: Convert each entity type to a doctype\n\tconst isEntityField = options.isEntityField ?? defaultIsEntityField\n\n\tconst doctypes: ConvertedGraphQLDoctype[] = []\n\n\tfor (const typeName of filteredEntityTypes) {\n\t\tconst type = typeMap[typeName]\n\t\tif (!isObjectType(type)) continue\n\n\t\tconst fields = type.getFields()\n\t\tconst typeOverrides = options.typeOverrides?.[typeName]\n\n\t\tconst entityFields = Object.entries(fields).filter(([fieldName, field]) => isEntityField(fieldName, field, type))\n\n\t\t// oxlint-disable-next-line oxc/no-map-spread -- ...custom spread required; Object.assign cannot preserve the metadata-carrying inferred union type from classifyField\n\t\tconst allClassifiedFields = entityFields.map(([fieldName, field]) => {\n\t\t\t// Check for full custom classification first\n\t\t\tif (options.classifyField) {\n\t\t\t\tconst custom = options.classifyField(fieldName, field, type)\n\t\t\t\tif (custom !== null && custom !== undefined) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: 'field' as const,\n\t\t\t\t\t\tfieldname: fieldName,\n\t\t\t\t\t\tlabel: custom.label ?? fieldName,\n\t\t\t\t\t\tcomponent: custom.component ?? 'ATextInput',\n\t\t\t\t\t\tfieldtype: custom.fieldtype ?? 'Data',\n\t\t\t\t\t\t...custom,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Default classification\n\t\t\tconst classified = classifyFieldType(fieldName, field, entityTypes, options)\n\n\t\t\t// Apply per-field overrides\n\t\t\tif (typeOverrides?.[fieldName]) {\n\t\t\t\treturn Object.assign(classified, typeOverrides[fieldName])\n\t\t\t}\n\n\t\t\treturn classified\n\t\t})\n\n\t\t// Separate scalar fields from link fields\n\t\tconst links: Record<string, LinkDeclaration> = {}\n\t\tconst convertedFields = allClassifiedFields\n\t\t\t.filter(field => {\n\t\t\t\tif (field._isLink && typeof field.options === 'string' && field.cardinality) {\n\t\t\t\t\tlinks[field.fieldname] = {\n\t\t\t\t\t\ttarget: field.options,\n\t\t\t\t\t\tcardinality: field.cardinality,\n\t\t\t\t\t}\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t})\n\t\t\t// Clean up internal metadata unless requested\n\t\t\t.map(field => {\n\t\t\t\tif (!options.includeUnmappedMeta) {\n\t\t\t\t\tconst { _graphqlType, _unmapped, _isLink, ...clean } = field\n\t\t\t\t\treturn clean\n\t\t\t\t}\n\t\t\t\tconst { _isLink, ...rest } = field\n\t\t\t\treturn rest\n\t\t\t})\n\n\t\tconst doctype: ConvertedGraphQLDoctype = {\n\t\t\tname: typeName,\n\t\t\tslug: toSlug(typeName),\n\t\t\t// 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\n\t\t\tfields: convertedFields as ValueField[],\n\t\t}\n\n\t\tif (Object.keys(links).length > 0) {\n\t\t\tdoctype.links = links\n\t\t}\n\n\t\tif (options.includeUnmappedMeta) {\n\t\t\tdoctype._graphqlTypeName = typeName\n\t\t}\n\n\t\tdoctypes.push(doctype)\n\t}\n\n\treturn doctypes\n}\n\n/**\n * Build a GraphQLSchema from either an introspection result or SDL string.\n *\n * @param source - IntrospectionQuery object or SDL string\n * @returns A complete GraphQLSchema\n * @internal\n */\nfunction buildGraphQLSchema(source: IntrospectionSource): GraphQLSchema {\n\tif (typeof source === 'string') {\n\t\t// SDL string\n\t\treturn buildSchema(source)\n\t}\n\n\t// IntrospectionQuery result\n\treturn buildClientSchema(source)\n}\n\n// ═══════════════════════════════════════════════════════════════\n// Re-exports\n// ═══════════════════════════════════════════════════════════════\n\n// Main converter (this file)\nexport { convertGraphQLSchema as default }\n\n// Types\nexport type {\n\tIntrospectionSource,\n\tGraphQLConversionOptions,\n\tGraphQLConversionFieldMeta,\n\tConvertedGraphQLDoctype,\n} from './types'\n\n// Scalar maps\nexport { GQL_SCALAR_MAP, WELL_KNOWN_SCALARS, INTERNAL_SCALARS, buildScalarMap } from './scalars'\n\n// Heuristics\nexport { defaultIsEntityType, defaultIsEntityField, classifyFieldType } from './heuristics'\n\n// Naming utilities\nexport { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from '../naming'\n"],"names":["TableViewConfig","z","BUILTIN_FIELD_TYPES","StonecropFieldType","isBuiltinFieldType","fieldtype","TYPE_MAP","getDefaultComponent","resolveComponent","FieldOptions","FieldValidation","injectKind","data","obj","createDoctypeFieldSchemas","ValueFieldSchema","TableFieldSchema","DoctypeFieldSchema","FieldsetFieldSchema","rawUnion","schemas","Cardinality","SyncFetch","LazyFetch","CustomFetch","FetchStrategy","LinkDeclaration","ActionDefinition","isActionAllowedInState","action","currentState","allowedStates","WorkflowMeta","DoctypeMeta","validateField","result","issue","validateDoctype","parseField","parseDoctype","snakeToCamel","snakeCase","_","letter","camelToSnake","camelCase","snakeToLabel","word","camelToLabel","withSpaces","toPascalCase","tableName","toSlug","name","pascalToSnake","pascal","GQL_SCALAR_MAP","WELL_KNOWN_SCALARS","INTERNAL_SCALARS","buildScalarMap","customScalars","merged","key","value","SYNTHETIC_SUFFIXES","ROOT_TYPE_NAMES","defaultIsEntityType","typeName","type","suffix","fields","SKIP_FIELDS","defaultIsEntityField","fieldName","_field","_parentType","unwrapType","required","isList","current","isNonNullType","isListType","isNamedType","getConnectionNodeType","edgesField","edgesType","edgesIsList","isObjectType","nodeField","nodeType","classifyFieldType","field","entityTypes","options","namedType","scalarMap","base","isScalarType","candidateTypeName","template","isEnumType","v","connectionNodeTypeName","convertGraphQLSchema","source","schema","buildGraphQLSchema","typeMap","rootTypeNames","queryType","mutationType","subscriptionType","isEntityType","filteredEntityTypes","includeSet","t","excludeSet","isEntityField","doctypes","typeOverrides","allClassifiedFields","custom","classified","links","convertedFields","_graphqlType","_unmapped","_isLink","clean","rest","doctype","buildSchema","buildClientSchema"],"mappings":";;AAWO,MAAMA,IAAkBC,EAC7B,OAAO;AAAA;AAAA,EAEP,MAAMA,EAAE,KAAK,CAAC,QAA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AAc,WAAAC,IAAW,SAAAC,IAAS,GAAGC,MAAUrC;AACvD,eAAOqC;AAAA,MACR;AACA,YAAM,EAAE,SAAAD,GAAS,GAAGE,EAAA,IAAStC;AAC7B,aAAOsC;AAAA,IACR,CAAC,GAEIC,IAAmC;AAAA,MACxC,MAAM/D;AAAA,MACN,MAAMf,EAAOe,CAAQ;AAAA;AAAA,MAErB,QAAQyD;AAAA,IAAA;AAGT,IAAI,OAAO,KAAKD,CAAK,EAAE,SAAS,MAC/BO,EAAQ,QAAQP,IAGb9B,EAAQ,wBACXqC,EAAQ,mBAAmB/D,IAG5BmD,EAAS,KAAKY,CAAO;AAAA,EACtB;AAEA,SAAOZ;AACR;AASA,SAASZ,GAAmBF,GAA4C;AACvE,SAAI,OAAOA,KAAW,WAEd2B,EAAY3B,CAAM,IAInB4B,EAAkB5B,CAAM;AAChC;"}
|
package/dist/index-DIb_Z0wI.js
DELETED
|
@@ -1,476 +0,0 @@
|
|
|
1
|
-
import { z as e } from "zod";
|
|
2
|
-
import { isScalarType as v, isEnumType as x, isObjectType as g, isNonNullType as L, isListType as U, buildSchema as q, buildClientSchema as P } from "graphql";
|
|
3
|
-
const R = e.enum([
|
|
4
|
-
"Data",
|
|
5
|
-
// Short text, varchar
|
|
6
|
-
"Text",
|
|
7
|
-
// Long text
|
|
8
|
-
"Int",
|
|
9
|
-
// Integer
|
|
10
|
-
"Float",
|
|
11
|
-
// Floating point (IEEE 754)
|
|
12
|
-
"Decimal",
|
|
13
|
-
// Arbitrary precision decimal
|
|
14
|
-
"Check",
|
|
15
|
-
// Boolean/checkbox
|
|
16
|
-
"Date",
|
|
17
|
-
// Date only
|
|
18
|
-
"Time",
|
|
19
|
-
// Time only
|
|
20
|
-
"Datetime",
|
|
21
|
-
// Date and time
|
|
22
|
-
"Duration",
|
|
23
|
-
// Time interval
|
|
24
|
-
"DateRange",
|
|
25
|
-
// Date range
|
|
26
|
-
"JSON",
|
|
27
|
-
// JSON data
|
|
28
|
-
"Code",
|
|
29
|
-
// Code/source (with syntax highlighting)
|
|
30
|
-
"Link",
|
|
31
|
-
// Reference to another doctype
|
|
32
|
-
"Attach",
|
|
33
|
-
// File attachment
|
|
34
|
-
"Currency",
|
|
35
|
-
// Currency value
|
|
36
|
-
"Quantity",
|
|
37
|
-
// Quantity with unit
|
|
38
|
-
"Select"
|
|
39
|
-
// Dropdown selection
|
|
40
|
-
]).meta({
|
|
41
|
-
title: "StonecropFieldType",
|
|
42
|
-
description: "Semantic field types for Stonecrop doctypes, consistent across forms and tables"
|
|
43
|
-
}), J = {
|
|
44
|
-
// Text
|
|
45
|
-
Data: { component: "ATextInput", fieldtype: "Data" },
|
|
46
|
-
Text: { component: "ATextInput", fieldtype: "Text" },
|
|
47
|
-
// Numeric
|
|
48
|
-
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
49
|
-
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
50
|
-
Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
51
|
-
// Boolean
|
|
52
|
-
Check: { component: "ACheckbox", fieldtype: "Check" },
|
|
53
|
-
// Date/Time
|
|
54
|
-
Date: { component: "ADate", fieldtype: "Date" },
|
|
55
|
-
Time: { component: "ATimeInput", fieldtype: "Time" },
|
|
56
|
-
Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
|
|
57
|
-
Duration: { component: "ADurationInput", fieldtype: "Duration" },
|
|
58
|
-
DateRange: { component: "ADateRangePicker", fieldtype: "DateRange" },
|
|
59
|
-
// Structured
|
|
60
|
-
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
61
|
-
Code: { component: "ACodeEditor", fieldtype: "Code" },
|
|
62
|
-
// Relational
|
|
63
|
-
Link: { component: "ALink", fieldtype: "Link" },
|
|
64
|
-
// Files
|
|
65
|
-
Attach: { component: "AFileAttach", fieldtype: "Attach" },
|
|
66
|
-
// Specialized
|
|
67
|
-
Currency: { component: "ACurrencyInput", fieldtype: "Currency" },
|
|
68
|
-
Quantity: { component: "AQuantityInput", fieldtype: "Quantity" },
|
|
69
|
-
Select: { component: "ADropdown", fieldtype: "Select" }
|
|
70
|
-
};
|
|
71
|
-
function ge(t) {
|
|
72
|
-
return J[t]?.component ?? "ATextInput";
|
|
73
|
-
}
|
|
74
|
-
const Q = e.union([
|
|
75
|
-
e.string(),
|
|
76
|
-
// Link/Doctype target: "customer"
|
|
77
|
-
e.array(e.string()),
|
|
78
|
-
// Select choices: ["A", "B", "C"]
|
|
79
|
-
e.record(e.string(), e.unknown())
|
|
80
|
-
// Config: \{ precision: 10, scale: 2 \}
|
|
81
|
-
]).meta({
|
|
82
|
-
title: "FieldOptions",
|
|
83
|
-
description: "Field options - flexible bag for type-specific configuration"
|
|
84
|
-
}), z = e.looseObject({
|
|
85
|
-
/** Error message to display when validation fails */
|
|
86
|
-
errorMessage: e.string()
|
|
87
|
-
}).meta({
|
|
88
|
-
title: "FieldValidation",
|
|
89
|
-
description: "Validation configuration for form fields"
|
|
90
|
-
}), k = e.object({
|
|
91
|
-
// === CORE (required) ===
|
|
92
|
-
/** Unique identifier for the field within its doctype */
|
|
93
|
-
fieldname: e.string().min(1),
|
|
94
|
-
/** Semantic field type - determines behavior and default component */
|
|
95
|
-
fieldtype: R,
|
|
96
|
-
// === COMPONENT (optional - derived from fieldtype when not specified) ===
|
|
97
|
-
/** Vue component to render this field. If not specified, derived from TYPE_MAP */
|
|
98
|
-
component: e.string().optional(),
|
|
99
|
-
// === DISPLAY ===
|
|
100
|
-
/** Human-readable label for the field */
|
|
101
|
-
label: e.string().optional(),
|
|
102
|
-
/** Width of the field (CSS value, e.g., "40ch", "200px") */
|
|
103
|
-
width: e.string().optional(),
|
|
104
|
-
/** Text alignment within the field */
|
|
105
|
-
align: e.enum(["left", "center", "right", "start", "end"]).optional(),
|
|
106
|
-
// === BEHAVIOR ===
|
|
107
|
-
/** Whether the field is required */
|
|
108
|
-
required: e.boolean().optional(),
|
|
109
|
-
/** Whether the field is read-only */
|
|
110
|
-
readOnly: e.boolean().optional(),
|
|
111
|
-
/** Whether the field is editable (for table cells) */
|
|
112
|
-
edit: e.boolean().optional(),
|
|
113
|
-
/** Whether the field is hidden from the UI */
|
|
114
|
-
hidden: e.boolean().optional(),
|
|
115
|
-
// === VALUE ===
|
|
116
|
-
/** Current value of the field */
|
|
117
|
-
value: e.unknown().optional(),
|
|
118
|
-
/** Default value for new records */
|
|
119
|
-
default: e.unknown().optional(),
|
|
120
|
-
// === TYPE-SPECIFIC ===
|
|
121
|
-
/**
|
|
122
|
-
* Type-specific options:
|
|
123
|
-
* - Link: target doctype slug ("customer")
|
|
124
|
-
* - Doctype: child doctype slug ("sales-order-item")
|
|
125
|
-
* - Select: choices array (["Draft", "Submitted"])
|
|
126
|
-
* - Decimal: \{ precision, scale \}
|
|
127
|
-
* - Code: \{ language \}
|
|
128
|
-
*/
|
|
129
|
-
options: Q.optional(),
|
|
130
|
-
/**
|
|
131
|
-
* Cardinality for Doctype fields:
|
|
132
|
-
* - 'one': exactly 1 (default)
|
|
133
|
-
* - 'atMostOne': 0 or 1
|
|
134
|
-
* - 'noneOrMany': 0 or more
|
|
135
|
-
* - 'atLeastOne': 1 or more
|
|
136
|
-
*/
|
|
137
|
-
cardinality: e.enum(["one", "atMostOne", "noneOrMany", "atLeastOne"]).optional(),
|
|
138
|
-
/**
|
|
139
|
-
* Input mask pattern. Accepts either a plain mask string or a stringified
|
|
140
|
-
* arrow function that receives `locale` and returns a mask string.
|
|
141
|
-
*
|
|
142
|
-
* Plain pattern: `"##/##/####"`
|
|
143
|
-
*
|
|
144
|
-
* Function pattern: `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`
|
|
145
|
-
*/
|
|
146
|
-
mask: e.string().optional(),
|
|
147
|
-
// === VALIDATION ===
|
|
148
|
-
/** Validation configuration */
|
|
149
|
-
validation: z.optional()
|
|
150
|
-
}).meta({
|
|
151
|
-
title: "FieldMeta",
|
|
152
|
-
description: "Unified field metadata - the single source of truth for field definitions, works for both forms (AForm) and tables (ATable)"
|
|
153
|
-
}), W = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
|
|
154
|
-
title: "Cardinality",
|
|
155
|
-
description: "Cardinality for relationship links between doctypes"
|
|
156
|
-
}), $ = e.object({
|
|
157
|
-
/** Fetch method type */
|
|
158
|
-
method: e.literal("sync"),
|
|
159
|
-
/** Optional limit on number of records to fetch */
|
|
160
|
-
limit: e.number().int().positive().optional()
|
|
161
|
-
}).meta({
|
|
162
|
-
title: "SyncFetch",
|
|
163
|
-
description: "Sync fetch strategy - data is fetched in the initial query"
|
|
164
|
-
}), B = e.object({
|
|
165
|
-
/** Fetch method type */
|
|
166
|
-
method: e.literal("lazy")
|
|
167
|
-
}).meta({
|
|
168
|
-
title: "LazyFetch",
|
|
169
|
-
description: "Lazy fetch strategy - data is fetched on demand in a separate query"
|
|
170
|
-
}), G = e.object({
|
|
171
|
-
/** Fetch method type */
|
|
172
|
-
method: e.literal("custom"),
|
|
173
|
-
/** Serialized handler function to invoke */
|
|
174
|
-
handler: e.string()
|
|
175
|
-
}).meta({
|
|
176
|
-
title: "CustomFetch",
|
|
177
|
-
description: "Custom fetch strategy - uses a custom handler function"
|
|
178
|
-
}), V = e.discriminatedUnion("method", [$, B, G]).meta({
|
|
179
|
-
title: "FetchStrategy",
|
|
180
|
-
description: "Fetch strategy for link data loading"
|
|
181
|
-
}), Z = e.object({
|
|
182
|
-
/** Target doctype slug */
|
|
183
|
-
target: e.string().min(1),
|
|
184
|
-
/** Cardinality of the relationship */
|
|
185
|
-
cardinality: W,
|
|
186
|
-
/** Backlink fieldname on the target doctype that points back to this link */
|
|
187
|
-
backlink: e.string().optional(),
|
|
188
|
-
/** Override default rendering component (AForm for 1:1, ATable for 1:many) */
|
|
189
|
-
component: e.string().optional(),
|
|
190
|
-
/** Fieldname of the corresponding Link field in the fields array */
|
|
191
|
-
fieldname: e.string().min(1).optional(),
|
|
192
|
-
/** Fetch strategy for loading nested data */
|
|
193
|
-
fetch: V.optional()
|
|
194
|
-
}).meta({
|
|
195
|
-
title: "LinkDeclaration",
|
|
196
|
-
description: "Declares a relationship from one doctype to another"
|
|
197
|
-
}), Y = e.object({
|
|
198
|
-
/** Display label for the action */
|
|
199
|
-
label: e.string().min(1),
|
|
200
|
-
/** Handler function name or path */
|
|
201
|
-
handler: e.string().min(1),
|
|
202
|
-
/** Fields that must have values before action can execute */
|
|
203
|
-
requiredFields: e.array(e.string()).optional(),
|
|
204
|
-
/** Workflow states where this action is available */
|
|
205
|
-
allowedStates: e.array(e.string()).optional(),
|
|
206
|
-
/** Whether to show a confirmation dialog */
|
|
207
|
-
confirm: e.boolean().optional(),
|
|
208
|
-
/** Additional arguments for the action */
|
|
209
|
-
args: e.record(e.string(), e.unknown()).optional()
|
|
210
|
-
}).meta({
|
|
211
|
-
title: "ActionDefinition",
|
|
212
|
-
description: "Action definition within a workflow"
|
|
213
|
-
}), K = e.object({
|
|
214
|
-
/** List of workflow states */
|
|
215
|
-
states: e.array(e.string()).optional(),
|
|
216
|
-
/** Actions available in this workflow */
|
|
217
|
-
actions: e.record(e.string(), Y).optional()
|
|
218
|
-
}).meta({
|
|
219
|
-
title: "WorkflowMeta",
|
|
220
|
-
description: "Workflow metadata - states and actions for a doctype"
|
|
221
|
-
}), _ = e.object({
|
|
222
|
-
/** Display name of the doctype */
|
|
223
|
-
name: e.string().min(1),
|
|
224
|
-
/** URL-friendly slug (kebab-case) */
|
|
225
|
-
slug: e.string().min(1).optional(),
|
|
226
|
-
/** Database table name */
|
|
227
|
-
tableName: e.string().optional(),
|
|
228
|
-
/** Field definitions (including link fields with fieldtype: 'Link') */
|
|
229
|
-
fields: e.array(k),
|
|
230
|
-
/** Relationship links to other doctypes */
|
|
231
|
-
links: e.record(e.string(), Z).optional(),
|
|
232
|
-
/** Workflow configuration */
|
|
233
|
-
workflow: K.optional(),
|
|
234
|
-
/** Parent doctype for inheritance */
|
|
235
|
-
inherits: e.string().optional()
|
|
236
|
-
}).meta({
|
|
237
|
-
title: "DoctypeMeta",
|
|
238
|
-
description: "Doctype metadata - complete definition of a doctype"
|
|
239
|
-
});
|
|
240
|
-
function he(t) {
|
|
241
|
-
const n = k.safeParse(t);
|
|
242
|
-
return n.success ? { success: !0, errors: [] } : {
|
|
243
|
-
success: !1,
|
|
244
|
-
errors: n.error.issues.map((o) => ({
|
|
245
|
-
path: o.path,
|
|
246
|
-
message: o.message
|
|
247
|
-
}))
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function Ae(t) {
|
|
251
|
-
const n = _.safeParse(t);
|
|
252
|
-
return n.success ? { success: !0, errors: [] } : {
|
|
253
|
-
success: !1,
|
|
254
|
-
errors: n.error.issues.map((o) => ({
|
|
255
|
-
path: o.path,
|
|
256
|
-
message: o.message
|
|
257
|
-
}))
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function Te(t) {
|
|
261
|
-
return k.parse(t);
|
|
262
|
-
}
|
|
263
|
-
function De(t) {
|
|
264
|
-
return _.parse(t);
|
|
265
|
-
}
|
|
266
|
-
function Se(t) {
|
|
267
|
-
return t.replace(/_([a-z])/g, (n, o) => o.toUpperCase());
|
|
268
|
-
}
|
|
269
|
-
function be(t) {
|
|
270
|
-
return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
|
|
271
|
-
}
|
|
272
|
-
function ke(t) {
|
|
273
|
-
return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
|
|
274
|
-
}
|
|
275
|
-
function H(t) {
|
|
276
|
-
const n = t.replace(/([A-Z])/g, " $1").trim();
|
|
277
|
-
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
278
|
-
}
|
|
279
|
-
function Fe(t) {
|
|
280
|
-
return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
|
|
281
|
-
}
|
|
282
|
-
function D(t) {
|
|
283
|
-
return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
284
|
-
}
|
|
285
|
-
function X(t) {
|
|
286
|
-
return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
|
|
287
|
-
}
|
|
288
|
-
const ee = {
|
|
289
|
-
String: { component: "ATextInput", fieldtype: "Data" },
|
|
290
|
-
Int: { component: "ANumericInput", fieldtype: "Int" },
|
|
291
|
-
Float: { component: "ANumericInput", fieldtype: "Float" },
|
|
292
|
-
Boolean: { component: "ACheckbox", fieldtype: "Check" },
|
|
293
|
-
ID: { component: "ATextInput", fieldtype: "Data" }
|
|
294
|
-
}, te = {
|
|
295
|
-
// Arbitrary precision / large numbers
|
|
296
|
-
BigFloat: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
297
|
-
BigDecimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
298
|
-
Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
|
|
299
|
-
BigInt: { component: "ANumericInput", fieldtype: "Int" },
|
|
300
|
-
Long: { component: "ANumericInput", fieldtype: "Int" },
|
|
301
|
-
// Identifiers
|
|
302
|
-
UUID: { component: "ATextInput", fieldtype: "Data" },
|
|
303
|
-
// Date / Time
|
|
304
|
-
DateTime: { component: "ADatetimePicker", fieldtype: "Datetime" },
|
|
305
|
-
Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
|
|
306
|
-
Date: { component: "ADate", fieldtype: "Date" },
|
|
307
|
-
Time: { component: "ATimeInput", fieldtype: "Time" },
|
|
308
|
-
Interval: { component: "ADurationInput", fieldtype: "Duration" },
|
|
309
|
-
Duration: { component: "ADurationInput", fieldtype: "Duration" },
|
|
310
|
-
// Structured data
|
|
311
|
-
JSON: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
312
|
-
JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
|
|
313
|
-
JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
|
|
314
|
-
}, ne = /* @__PURE__ */ new Set(["Cursor"]);
|
|
315
|
-
function ie(t) {
|
|
316
|
-
const n = { ...te };
|
|
317
|
-
for (const [o, a] of Object.entries(ee))
|
|
318
|
-
n[o] = a;
|
|
319
|
-
if (t)
|
|
320
|
-
for (const [o, a] of Object.entries(t))
|
|
321
|
-
n[o] = {
|
|
322
|
-
component: a.component ?? "ATextInput",
|
|
323
|
-
fieldtype: a.fieldtype ?? "Data"
|
|
324
|
-
};
|
|
325
|
-
return n;
|
|
326
|
-
}
|
|
327
|
-
const oe = [
|
|
328
|
-
"Connection",
|
|
329
|
-
"Edge",
|
|
330
|
-
"Input",
|
|
331
|
-
"Patch",
|
|
332
|
-
"Payload",
|
|
333
|
-
"Condition",
|
|
334
|
-
"Filter",
|
|
335
|
-
"OrderBy",
|
|
336
|
-
"Aggregate",
|
|
337
|
-
"AggregateResult",
|
|
338
|
-
"AggregateFilter",
|
|
339
|
-
"DeleteResponse",
|
|
340
|
-
"InsertResponse",
|
|
341
|
-
"UpdateResponse",
|
|
342
|
-
"MutationResponse"
|
|
343
|
-
], ae = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
|
|
344
|
-
function re(t, n) {
|
|
345
|
-
if (t.startsWith("__") || ae.has(t) || t === "Node")
|
|
346
|
-
return !1;
|
|
347
|
-
for (const a of oe)
|
|
348
|
-
if (t.endsWith(a))
|
|
349
|
-
return !1;
|
|
350
|
-
const o = n.getFields();
|
|
351
|
-
return Object.keys(o).length !== 0;
|
|
352
|
-
}
|
|
353
|
-
const se = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
|
|
354
|
-
function ce(t, n, o) {
|
|
355
|
-
return !se.has(t);
|
|
356
|
-
}
|
|
357
|
-
function b(t) {
|
|
358
|
-
let n = !1, o = !1, a = t;
|
|
359
|
-
return L(a) && (n = !0, a = a.ofType), U(a) && (o = !0, a = a.ofType, L(a) && (a = a.ofType)), { namedType: a, required: n, isList: o };
|
|
360
|
-
}
|
|
361
|
-
function le(t) {
|
|
362
|
-
const o = t.getFields().edges;
|
|
363
|
-
if (!o) return;
|
|
364
|
-
const { namedType: a, isList: r } = b(o.type);
|
|
365
|
-
if (!r || !g(a)) return;
|
|
366
|
-
const d = a.getFields().node;
|
|
367
|
-
if (!d) return;
|
|
368
|
-
const { namedType: u } = b(d.type);
|
|
369
|
-
if (g(u))
|
|
370
|
-
return u.name;
|
|
371
|
-
}
|
|
372
|
-
function pe(t, n, o, a = {}) {
|
|
373
|
-
const { namedType: r, required: f, isList: d } = b(n.type), u = ie(a.customScalars), i = {
|
|
374
|
-
fieldname: t,
|
|
375
|
-
label: H(t),
|
|
376
|
-
component: "ATextInput",
|
|
377
|
-
fieldtype: "Data"
|
|
378
|
-
};
|
|
379
|
-
if (f && (i.required = !0), v(r)) {
|
|
380
|
-
if (ne.has(r.name))
|
|
381
|
-
return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
|
|
382
|
-
const l = u[r.name];
|
|
383
|
-
return l ? (i.component = l.component, i.fieldtype = l.fieldtype) : (i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name)), i;
|
|
384
|
-
}
|
|
385
|
-
if (x(r))
|
|
386
|
-
return i.component = "ADropdown", i.fieldtype = "Select", i.options = r.getValues().map((l) => l.name), i;
|
|
387
|
-
if (g(r)) {
|
|
388
|
-
if (!d && o.has(r.name))
|
|
389
|
-
return i.component = "ALink", i.fieldtype = "Link", i.options = D(r.name), i;
|
|
390
|
-
const l = le(r);
|
|
391
|
-
return l && o.has(l) ? (i.component = "ATable", i._isLink = !0, i.options = D(l), i.cardinality = "noneOrMany", delete i.fieldtype, i) : d && o.has(r.name) ? (i.component = "ATable", i._isLink = !0, i.options = D(r.name), i.cardinality = "noneOrMany", delete i.fieldtype, i) : (i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i);
|
|
392
|
-
}
|
|
393
|
-
return i._unmapped = !0, a.includeUnmappedMeta && (i._graphqlType = r.name), i;
|
|
394
|
-
}
|
|
395
|
-
function Ie(t, n = {}) {
|
|
396
|
-
const o = de(t), a = o.getTypeMap(), r = /* @__PURE__ */ new Set(), f = o.getQueryType(), d = o.getMutationType(), u = o.getSubscriptionType();
|
|
397
|
-
f && r.add(f.name), d && r.add(d.name), u && r.add(u.name);
|
|
398
|
-
const i = n.isEntityType ?? re, l = /* @__PURE__ */ new Set();
|
|
399
|
-
for (const [c, p] of Object.entries(a))
|
|
400
|
-
g(p) && (r.has(c) || i(c, p) && l.add(c));
|
|
401
|
-
let h = l;
|
|
402
|
-
if (n.include) {
|
|
403
|
-
const c = new Set(n.include);
|
|
404
|
-
h = new Set([...l].filter((p) => c.has(p)));
|
|
405
|
-
}
|
|
406
|
-
if (n.exclude) {
|
|
407
|
-
const c = new Set(n.exclude);
|
|
408
|
-
h = new Set([...h].filter((p) => !c.has(p)));
|
|
409
|
-
}
|
|
410
|
-
const O = n.isEntityField ?? ce, w = n.deriveTableName ?? ((c) => X(c)), F = [];
|
|
411
|
-
for (const c of h) {
|
|
412
|
-
const p = a[c];
|
|
413
|
-
if (!g(p)) continue;
|
|
414
|
-
const M = p.getFields(), I = n.typeOverrides?.[c], N = Object.entries(M).filter(([s, y]) => O(s, y, p)).map(([s, y]) => {
|
|
415
|
-
if (n.classifyField) {
|
|
416
|
-
const m = n.classifyField(s, y, p);
|
|
417
|
-
if (m != null)
|
|
418
|
-
return {
|
|
419
|
-
fieldname: s,
|
|
420
|
-
label: m.label ?? s,
|
|
421
|
-
component: m.component ?? "ATextInput",
|
|
422
|
-
fieldtype: m.fieldtype ?? "Data",
|
|
423
|
-
...m
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
const T = pe(s, y, l, n);
|
|
427
|
-
return I?.[s] ? { ...T, ...I[s] } : T;
|
|
428
|
-
}), S = {}, E = N.filter((s) => s._isLink && typeof s.options == "string" && s.cardinality ? (S[s.fieldname] = {
|
|
429
|
-
target: s.options,
|
|
430
|
-
cardinality: s.cardinality
|
|
431
|
-
}, !1) : !0).map((s) => {
|
|
432
|
-
if (!n.includeUnmappedMeta) {
|
|
433
|
-
const { _graphqlType: m, _unmapped: ue, _isLink: me, ...j } = s;
|
|
434
|
-
return j;
|
|
435
|
-
}
|
|
436
|
-
const { _isLink: y, ...T } = s;
|
|
437
|
-
return T;
|
|
438
|
-
}), A = {
|
|
439
|
-
name: c,
|
|
440
|
-
slug: D(c),
|
|
441
|
-
fields: E
|
|
442
|
-
};
|
|
443
|
-
Object.keys(S).length > 0 && (A.links = S);
|
|
444
|
-
const C = w(c);
|
|
445
|
-
C && (A.tableName = C), n.includeUnmappedMeta && (A._graphqlTypeName = c), F.push(A);
|
|
446
|
-
}
|
|
447
|
-
return F;
|
|
448
|
-
}
|
|
449
|
-
function de(t) {
|
|
450
|
-
return typeof t == "string" ? q(t) : P(t);
|
|
451
|
-
}
|
|
452
|
-
export {
|
|
453
|
-
ee as G,
|
|
454
|
-
ne as I,
|
|
455
|
-
R as S,
|
|
456
|
-
J as T,
|
|
457
|
-
te as W,
|
|
458
|
-
be as a,
|
|
459
|
-
ie as b,
|
|
460
|
-
H as c,
|
|
461
|
-
pe as d,
|
|
462
|
-
Ie as e,
|
|
463
|
-
ce as f,
|
|
464
|
-
re as g,
|
|
465
|
-
ge as h,
|
|
466
|
-
Te as i,
|
|
467
|
-
X as j,
|
|
468
|
-
ke as k,
|
|
469
|
-
D as l,
|
|
470
|
-
he as m,
|
|
471
|
-
De as p,
|
|
472
|
-
Se as s,
|
|
473
|
-
Fe as t,
|
|
474
|
-
Ae as v
|
|
475
|
-
};
|
|
476
|
-
//# sourceMappingURL=index-DIb_Z0wI.js.map
|