@stonecrop/schema 0.14.0 → 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.
Files changed (138) hide show
  1. package/package.json +14 -9
  2. package/dist/cli.cjs +0 -41
  3. package/dist/cli.cjs.map +0 -1
  4. package/dist/converter/heuristics.js +0 -258
  5. package/dist/converter/index.js +0 -181
  6. package/dist/converter/scalars.js +0 -86
  7. package/dist/converter/types.js +0 -5
  8. package/dist/converter-CYNFRwPg.js +0 -512
  9. package/dist/converter-CYNFRwPg.js.map +0 -1
  10. package/dist/converter-DNwpowpq.js +0 -459
  11. package/dist/converter-DNwpowpq.js.map +0 -1
  12. package/dist/doctype.js +0 -152
  13. package/dist/field.js +0 -110
  14. package/dist/fieldtype.js +0 -97
  15. package/dist/index--rNo7Kel.js +0 -494
  16. package/dist/index--rNo7Kel.js.map +0 -1
  17. package/dist/index-0qWNlDQ5.js +0 -450
  18. package/dist/index-0qWNlDQ5.js.map +0 -1
  19. package/dist/index-2UVTfbcY.js +0 -448
  20. package/dist/index-2UVTfbcY.js.map +0 -1
  21. package/dist/index-9QjWZ_PC.js +0 -449
  22. package/dist/index-9QjWZ_PC.js.map +0 -1
  23. package/dist/index-BCADNO5M.js +0 -449
  24. package/dist/index-BCADNO5M.js.map +0 -1
  25. package/dist/index-BJjSlCSo.js +0 -496
  26. package/dist/index-BJjSlCSo.js.map +0 -1
  27. package/dist/index-BRQJGVFR.js +0 -453
  28. package/dist/index-BRQJGVFR.js.map +0 -1
  29. package/dist/index-BatnoC-J.js +0 -429
  30. package/dist/index-BatnoC-J.js.map +0 -1
  31. package/dist/index-BbG7Mzvg.js +0 -495
  32. package/dist/index-BbG7Mzvg.js.map +0 -1
  33. package/dist/index-BdCmYHg0.js +0 -493
  34. package/dist/index-BdCmYHg0.js.map +0 -1
  35. package/dist/index-BhMd2_xl.js +0 -454
  36. package/dist/index-BhMd2_xl.js.map +0 -1
  37. package/dist/index-BzhZpuzA.js +0 -556
  38. package/dist/index-BzhZpuzA.js.map +0 -1
  39. package/dist/index-C1oC7Xwz.js +0 -552
  40. package/dist/index-C1oC7Xwz.js.map +0 -1
  41. package/dist/index-C5ANE_rn.js +0 -501
  42. package/dist/index-C5ANE_rn.js.map +0 -1
  43. package/dist/index-C8F23K8c.js +0 -555
  44. package/dist/index-C8F23K8c.js.map +0 -1
  45. package/dist/index-CD5wQNH-.js +0 -516
  46. package/dist/index-CD5wQNH-.js.map +0 -1
  47. package/dist/index-CLc5mUMQ.js +0 -478
  48. package/dist/index-CLc5mUMQ.js.map +0 -1
  49. package/dist/index-CMeexvC6.js +0 -459
  50. package/dist/index-CMeexvC6.js.map +0 -1
  51. package/dist/index-COrltkHl.js +0 -401
  52. package/dist/index-COrltkHl.js.map +0 -1
  53. package/dist/index-CX662Zb2.js +0 -551
  54. package/dist/index-CX662Zb2.js.map +0 -1
  55. package/dist/index-Cq_yfoqI.js +0 -553
  56. package/dist/index-Cq_yfoqI.js.map +0 -1
  57. package/dist/index-Cu-6609R.js +0 -493
  58. package/dist/index-Cu-6609R.js.map +0 -1
  59. package/dist/index-CvN9xK1B.js +0 -453
  60. package/dist/index-CvN9xK1B.js.map +0 -1
  61. package/dist/index-CzoRIy1-.js +0 -408
  62. package/dist/index-CzoRIy1-.js.map +0 -1
  63. package/dist/index-D66L9JNw.js +0 -506
  64. package/dist/index-D66L9JNw.js.map +0 -1
  65. package/dist/index-D68mWfHm.js +0 -510
  66. package/dist/index-D68mWfHm.js.map +0 -1
  67. package/dist/index-D6Up-BP5.js +0 -435
  68. package/dist/index-D6Up-BP5.js.map +0 -1
  69. package/dist/index-D8R5ppAg.js +0 -529
  70. package/dist/index-D8R5ppAg.js.map +0 -1
  71. package/dist/index-D9qPYlSk.js +0 -491
  72. package/dist/index-D9qPYlSk.js.map +0 -1
  73. package/dist/index-DCjAX4l-.js +0 -516
  74. package/dist/index-DCjAX4l-.js.map +0 -1
  75. package/dist/index-DE0b6fs6.js +0 -515
  76. package/dist/index-DE0b6fs6.js.map +0 -1
  77. package/dist/index-DEkR-1RC.js +0 -496
  78. package/dist/index-DEkR-1RC.js.map +0 -1
  79. package/dist/index-DIY_FLR2.js +0 -516
  80. package/dist/index-DIY_FLR2.js.map +0 -1
  81. package/dist/index-DIb_Z0wI.js +0 -476
  82. package/dist/index-DIb_Z0wI.js.map +0 -1
  83. package/dist/index-DNROIEMe.js +0 -449
  84. package/dist/index-DNROIEMe.js.map +0 -1
  85. package/dist/index-DT-NJBvW.js +0 -510
  86. package/dist/index-DT-NJBvW.js.map +0 -1
  87. package/dist/index-DUFcQC-H.js +0 -449
  88. package/dist/index-DUFcQC-H.js.map +0 -1
  89. package/dist/index-DVVTsJNb.js +0 -495
  90. package/dist/index-DVVTsJNb.js.map +0 -1
  91. package/dist/index-DYy5E1cU.js +0 -508
  92. package/dist/index-DYy5E1cU.js.map +0 -1
  93. package/dist/index-DdC5tpt-.js +0 -488
  94. package/dist/index-DdC5tpt-.js.map +0 -1
  95. package/dist/index-Dk593rMz.js +0 -512
  96. package/dist/index-Dk593rMz.js.map +0 -1
  97. package/dist/index-DmD8vmuB.js +0 -449
  98. package/dist/index-DmD8vmuB.js.map +0 -1
  99. package/dist/index-DpCFgELB.js +0 -514
  100. package/dist/index-DpCFgELB.js.map +0 -1
  101. package/dist/index-DqxTn6jG.js +0 -488
  102. package/dist/index-DqxTn6jG.js.map +0 -1
  103. package/dist/index-DyK5-0kh.js +0 -514
  104. package/dist/index-DyK5-0kh.js.map +0 -1
  105. package/dist/index-Vd0_gZjr.js +0 -451
  106. package/dist/index-Vd0_gZjr.js.map +0 -1
  107. package/dist/index-XSSAHj8g.js +0 -495
  108. package/dist/index-XSSAHj8g.js.map +0 -1
  109. package/dist/index-XZZbfFxT.js +0 -434
  110. package/dist/index-XZZbfFxT.js.map +0 -1
  111. package/dist/index-YP0m26Y5.js +0 -555
  112. package/dist/index-YP0m26Y5.js.map +0 -1
  113. package/dist/index-_3q9Bzka.js +0 -512
  114. package/dist/index-_3q9Bzka.js.map +0 -1
  115. package/dist/index-aeXXzPET.cjs +0 -2
  116. package/dist/index-aeXXzPET.cjs.map +0 -1
  117. package/dist/index-glU_Uw7z.js +0 -543
  118. package/dist/index-glU_Uw7z.js.map +0 -1
  119. package/dist/index-i0Uz8G2K.js +0 -554
  120. package/dist/index-i0Uz8G2K.js.map +0 -1
  121. package/dist/index-neVkjlgB.js +0 -446
  122. package/dist/index-neVkjlgB.js.map +0 -1
  123. package/dist/index-xdlVWldg.js +0 -408
  124. package/dist/index-xdlVWldg.js.map +0 -1
  125. package/dist/index.cjs +0 -2
  126. package/dist/index.cjs.map +0 -1
  127. package/dist/jsonschema.js +0 -225
  128. package/dist/naming.js +0 -106
  129. package/dist/src/fieldtype.d.ts +0 -63
  130. package/dist/src/fieldtype.d.ts.map +0 -1
  131. package/dist/src/fieldtype.js +0 -106
  132. package/dist/src/jsonschema.d.ts +0 -95
  133. package/dist/src/jsonschema.d.ts.map +0 -1
  134. package/dist/src/schema-field.d.ts +0 -66
  135. package/dist/src/schema-field.d.ts.map +0 -1
  136. package/dist/src/schema-field.js +0 -0
  137. package/dist/src/tsdoc-metadata.json +0 -11
  138. package/dist/validation.js +0 -60
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Vd0_gZjr.js","sources":["../src/table.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\nimport type { ColumnSchema } from './column-schema'\nimport type { InteractionMode } from './mode'\nimport { TableViewConfig } from './table'\n\n/**\n * Field options - flexible bag for type-specific configuration.\n *\n * Usage:\n * - Select: array of choices ([\"Draft\", \"Submitted\", \"Cancelled\"])\n * - Decimal: config object (\\{ precision: 10, scale: 2 \\})\n * - Code: config object (\\{ language: \"python\" \\})\n *\n * Deliberately *not* a bare string: a string once meant \"link target\", which made the value's\n * shape encode its meaning. That job belongs to `ValueField.doctype`, leaving this a plain\n * choices-or-config bag.\n *\n * @public\n */\nexport const FieldOptions = z\n\t.union([\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. `component` determines how it renders; the attributes below\n * carry everything else that is not a rendering concern.\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/**\n\t * Vue component that renders this field — the primary (and only) rendering axis. Required:\n\t * there is nothing left to derive it from, and a field without one has nothing to render it.\n\t * Any string is valid; naming a custom component is how an app renders a field Stonecrop\n\t * ships no widget for. See `CANONICAL_COMPONENTS` for the set Stonecrop provides.\n\t */\n\tcomponent: string\n\t/** True for the field that identifies the record's primary-key column. */\n\tprimaryKey?: boolean\n\t/** True for a computed/display field with no backing DB column — excluded from SQL SELECT. */\n\tcomputed?: boolean\n\t/** Editor language for code fields (e.g. `'json'`, `'typescript'`) — the only thing distinguishing\n\t * a JSON editor from a code editor, since both render with `ACodeEditor`. */\n\tlanguage?: string\n\t/**\n\t * Target doctype slug. Presence is what makes a field a link.\n\t *\n\t * How it renders is decided by `component`, not by this: `AFormLink` renders an\n\t * inline id-picker, while `AForm`/`ATable` expand the target (see `linkRenderMode`). Expansion\n\t * metadata — backlink, fetch strategy, authoritative cardinality — lives in the doctype's\n\t * `links` map, which is additive and never required for a plain foreign key.\n\t */\n\tdoctype?: 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/** Serialized `(value) => string` function for display formatting — distinct from `mask` (input).\n\t * Spreads through `schemaToColumns` to `ColumnSchema.format`; deserialized at render time by\n\t * ATable's `getFormattedValue`. */\n\tformat?: string\n\t/** Per-field interaction mode override */\n\tmode?: InteractionMode\n\t/** Type-specific options: Select choices, Decimal precision config, etc. A link's target is not\n\t * here — it is `doctype`. */\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\t/**\n\t * Provenance marker — stamped only by the GraphQL converter; absence means hand-authored.\n\t * When present, the docbuilder freezes the field's identity set (`fieldname`, `primaryKey`,\n\t * `required`, `options`, `cardinality`, `doctype`), since `fieldname` is the GraphQL/column\n\t * binding and `doctype` is the FK's target. `component` is deliberately **not** frozen: it\n\t * chooses the widget, which is an authoring decision the database has no opinion about.\n\t */\n\tsource?: 'introspected'\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 — a `schema` key means fieldset, `columns` means table, anything else\n * is a value field.\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\tcomponent: z.string().min(1),\n\t\t\tprimaryKey: z.boolean().optional(),\n\t\t\tcomputed: z.boolean().optional(),\n\t\t\tlanguage: z.string().optional(),\n\t\t\tdoctype: z.string().min(1).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\tformat: 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\tsource: z.literal('introspected').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/** 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 stateless command actions with no workflow effect at all (print, email, etc.) */\n\t\tstateless: z.boolean().optional(),\n\n\t\t/**\n\t\t * True for an internal self-transition: the action runs within the current state without\n\t\t * advancing the workflow (e.g. `save`, which mutates record data but stays put). Scoped by\n\t\t * `allowedStates`, rendered as a self-loop in the graph, and has no `nextState`. Distinct from\n\t\t * `stateless` (which has no workflow presence at all): a self-transition is graph-owned and,\n\t\t * unlike a stateless command, persists record data on dispatch.\n\t\t */\n\t\tselfTransition: 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 * Reactive field-validation trigger — advisory, client-side only.\n *\n * A Trigger is a docbuilder-authored validator: when any field in `on` is edited, its\n * `clientHandler` runs (client-side, no rollback) and may flag a field inline to block save\n * in the UI. It is deliberately a **sibling** to {@link (ActionDefinition:type)}, not a member of it —\n * a reactive validator is not a user-invoked action, so it lives in the `triggers` map on\n * {@link (WorkflowMeta:type)} and never appears to action readers (transition/command dropdowns, the FSM graph).\n *\n * The two bindings are independent: `on` is the fire-set (which fields' edits run it), while the\n * `setError(field, msg)` call inside `clientHandler` chooses which field displays the error.\n * @public\n */\nexport const TriggerDefinition = z\n\t.object({\n\t\t/** Optional display label; the map key is the trigger's identity */\n\t\tlabel: z.string().optional(),\n\n\t\t/** Fieldnames whose edits fire this trigger (fires when any listed field changes) */\n\t\ton: z.array(z.string()),\n\n\t\t/** JS function body stored as a string; run client-side with `{ record, value, setError }`. Advisory. */\n\t\tclientHandler: z.string(),\n\t})\n\t.meta({\n\t\ttitle: 'TriggerDefinition',\n\t\tdescription: 'Reactive field-validation trigger — advisory client-side',\n\t})\n\n/**\n * Trigger definition type inferred from Zod schema\n * @public\n */\nexport type TriggerDefinition = z.infer<typeof TriggerDefinition>\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(action: { allowedStates?: string[] | null }, currentState: string): boolean {\n\tconst allowedStates = action.allowedStates\n\tif (!allowedStates || allowedStates.length === 0) return true\n\treturn allowedStates.includes(currentState)\n}\n\n/**\n * DocBuilder graph layout — node positions for the workflow-state graph, keyed by state name.\n * Pure authoring view-state: persisted in the doctype JSON so an author's manual arrangement\n * survives reloads, but — exactly like {@link (WorkflowMeta:type)}'s `triggers` — it is client-only\n * and never mirrored into the runtime GraphQL SDL (see the WorkflowMeta type in the host SDLs, which\n * expose only `states`/`actions`). The shape mirrors VueFlow's node fields; `position` is the node's\n * canvas coordinate and `targetPosition`/`sourcePosition` are the handle sides.\n * @public\n */\nexport const WorkflowLayout = z.record(\n\tz.string(),\n\tz.object({\n\t\tposition: z.object({ x: z.number(), y: z.number() }).optional(),\n\t\ttargetPosition: z.enum(['left', 'top', 'right', 'bottom']).optional(),\n\t\tsourcePosition: z.enum(['left', 'top', 'right', 'bottom']).optional(),\n\t})\n)\n\n/**\n * Workflow layout type inferred from Zod schema\n * @public\n */\nexport type WorkflowLayout = z.infer<typeof WorkflowLayout>\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\n\t\t/** Reactive field-validation triggers (advisory, client-side), keyed by trigger name */\n\t\ttriggers: z.record(z.string(), TriggerDefinition).optional(),\n\n\t\t/**\n\t\t * DocBuilder node positions keyed by state name — authoring view-state. Persisted here so a\n\t\t * doctype author's manual graph arrangement survives reloads; like `triggers`, it is client-only\n\t\t * and never enters the runtime GraphQL SDL. See {@link (WorkflowLayout:variable)}.\n\t\t */\n\t\tlayout: WorkflowLayout.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 (a link field is one carrying `doctype`) */\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 './types'\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' },\n\tInt: { component: 'ANumericInput' },\n\tFloat: { component: 'ANumericInput' },\n\tBoolean: { component: 'ACheckbox' },\n\tID: { component: 'ATextInput' },\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 — all numeric variants render with ANumericInput.\n\tBigFloat: { component: 'ANumericInput' },\n\tBigDecimal: { component: 'ANumericInput' },\n\tDecimal: { component: 'ANumericInput' },\n\tBigInt: { component: 'ANumericInput' },\n\tLong: { component: 'ANumericInput' },\n\n\t// Identifiers\n\tUUID: { component: 'ATextInput' },\n\n\t// Date / Time — no dedicated Time SFC exists; Time falls back to a plain text input.\n\tDateTime: { component: 'ADateTime' },\n\tDatetime: { component: 'ADateTime' },\n\tDate: { component: 'ADate' },\n\tTime: { component: 'ATextInput' },\n\tInterval: { component: 'ADuration' },\n\tDuration: { component: 'ADuration' },\n\n\t// Structured data\n\tJSON: { component: 'ACodeEditor' },\n\tJSONObject: { component: 'ACodeEditor' },\n\tJsonNode: { component: 'ACodeEditor' },\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] = { component: value.component ?? 'ATextInput' }\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 './types'\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}\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 = 'AFormLink'\n\t\t\t\tbase.doctype = 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} 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.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 = 'AFormLink'\n\t\t\tbase.doctype = 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.doctype = toSlug(connectionNodeTypeName)\n\t\t\tbase.cardinality = 'noneOrMany'\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.doctype = toSlug(namedType.name)\n\t\t\tbase.cardinality = 'noneOrMany'\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: 'ANumericInput' }\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\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 && field.doctype && field.cardinality) {\n\t\t\t\t\tlinks[field.fieldname] = {\n\t\t\t\t\t\ttarget: field.doctype,\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, and stamp provenance.\n\t\t\t// Stamped last so every classification path (default, classifyField,\n\t\t\t// typeOverrides) carries the marker — the docbuilder's identity lock\n\t\t\t// keys off it, and an override must not be able to unset it.\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 Object.assign(clean, { source: 'introspected' as const })\n\t\t\t\t}\n\t\t\t\tconst { _isLink, ...rest } = field\n\t\t\t\treturn Object.assign(rest, { source: 'introspected' as const })\n\t\t\t})\n\n\t\tconst doctype: ConvertedGraphQLDoctype = {\n\t\t\tname: typeName,\n\t\t\tslug: toSlug(typeName),\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","FieldOptions","FieldValidation","injectKind","data","obj","createDoctypeFieldSchemas","ValueFieldSchema","TableFieldSchema","DoctypeFieldSchema","FieldsetFieldSchema","rawUnion","schemas","Cardinality","SyncFetch","LazyFetch","CustomFetch","FetchStrategy","LinkDeclaration","ActionDefinition","TriggerDefinition","isActionAllowedInState","action","currentState","allowedStates","WorkflowLayout","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,QAAQ,aAAa,kBAAkB,QAAQ,SAAS,YAAY,CAAC,EAAE,SAAA;AAAA;AAAA,EAGrF,WAAWA,EAAE,QAAA,EAAU,SAAA;AAAA;AAAA,EAGvB,sBAAsBA,EAAE,KAAK,CAAC,QAAQ,UAAU,MAAM,CAAC,EAAE,SAAA;AAAA;AAAA,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MACrB,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;"}
@@ -1,495 +0,0 @@
1
- import { z as e } from "zod";
2
- import { isScalarType as N, isEnumType as x, isObjectType as T, isNonNullType as C, isListType as j, isNamedType as v, buildSchema as P, buildClientSchema as U } from "graphql";
3
- const q = [
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
- "PrimaryKey"
41
- // Primary key field — used by the middleware to identify the record's PK column
42
- ], R = e.string().min(1).meta({
43
- title: "StonecropFieldType",
44
- description: "Semantic field types for Stonecrop doctypes, consistent across forms and tables"
45
- });
46
- function Q(t) {
47
- return q.includes(t);
48
- }
49
- const J = {
50
- // Text
51
- Data: { component: "ATextInput", fieldtype: "Data" },
52
- Text: { component: "ATextInput", fieldtype: "Text" },
53
- // Numeric
54
- Int: { component: "ANumericInput", fieldtype: "Int" },
55
- Float: { component: "ANumericInput", fieldtype: "Float" },
56
- Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
57
- // Boolean
58
- Check: { component: "ACheckbox", fieldtype: "Check" },
59
- // Date/Time
60
- Date: { component: "ADate", fieldtype: "Date" },
61
- Time: { component: "ATimeInput", fieldtype: "Time" },
62
- Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
63
- Duration: { component: "ADurationInput", fieldtype: "Duration" },
64
- DateRange: { component: "ADateRangePicker", fieldtype: "DateRange" },
65
- // Structured
66
- JSON: { component: "ACodeEditor", fieldtype: "JSON" },
67
- Code: { component: "ACodeEditor", fieldtype: "Code" },
68
- // Relational
69
- Link: { component: "ALink", fieldtype: "Link" },
70
- // Files
71
- Attach: { component: "AFileAttach", fieldtype: "Attach" },
72
- // Specialized
73
- Currency: { component: "ACurrencyInput", fieldtype: "Currency" },
74
- Quantity: { component: "AQuantityInput", fieldtype: "Quantity" },
75
- Select: { component: "ADropdown", fieldtype: "Select" },
76
- // Identity — PK fields are typically hidden; no interactive component is needed
77
- PrimaryKey: { component: "ATextInput", fieldtype: "PrimaryKey" }
78
- };
79
- function W(t) {
80
- return J[t]?.component ?? "ATextInput";
81
- }
82
- function Te(t) {
83
- return Q(t) ? W(t) : "ATextInput";
84
- }
85
- const z = e.union([
86
- e.string(),
87
- // Link/Doctype target: "customer"
88
- e.array(e.string()),
89
- // Select choices: ["A", "B", "C"]
90
- e.record(e.string(), e.unknown())
91
- // Config: \{ precision: 10, scale: 2 \}
92
- ]).meta({
93
- title: "FieldOptions",
94
- description: "Field options - flexible bag for type-specific configuration"
95
- }), B = e.looseObject({
96
- /** Error message to display when validation fails */
97
- errorMessage: e.string()
98
- }).meta({
99
- title: "FieldValidation",
100
- description: "Validation configuration for form fields"
101
- }), k = e.object({
102
- // === CORE (required) ===
103
- /** Unique identifier for the field within its doctype */
104
- fieldname: e.string().min(1),
105
- /** Semantic field type - determines behavior and default component */
106
- fieldtype: R,
107
- // === COMPONENT (optional - derived from fieldtype when not specified) ===
108
- /** Vue component to render this field. If not specified, derived from TYPE_MAP */
109
- component: e.string().optional(),
110
- // === DISPLAY ===
111
- /** Human-readable label for the field */
112
- label: e.string().optional(),
113
- /** Width of the field (CSS value, e.g., "40ch", "200px") */
114
- width: e.string().optional(),
115
- /** Text alignment within the field */
116
- align: e.enum(["left", "center", "right", "start", "end"]).optional(),
117
- // === BEHAVIOR ===
118
- /** Whether the field is required */
119
- required: e.boolean().optional(),
120
- /** Whether the field is read-only */
121
- readOnly: e.boolean().optional(),
122
- /** Whether the field is editable (for table cells) */
123
- edit: e.boolean().optional(),
124
- /** Whether the field is hidden from the UI */
125
- hidden: e.boolean().optional(),
126
- // === VALUE ===
127
- /** Current value of the field */
128
- value: e.unknown().optional(),
129
- /** Default value for new records */
130
- default: e.unknown().optional(),
131
- // === TYPE-SPECIFIC ===
132
- /**
133
- * Type-specific options:
134
- * - Link: target doctype slug ("customer")
135
- * - Doctype: child doctype slug ("sales-order-item")
136
- * - Select: choices array (["Draft", "Submitted"])
137
- * - Decimal: \{ precision, scale \}
138
- * - Code: \{ language \}
139
- */
140
- options: z.optional(),
141
- /**
142
- * Cardinality for Doctype fields:
143
- * - 'one': exactly 1 (default)
144
- * - 'atMostOne': 0 or 1
145
- * - 'noneOrMany': 0 or more
146
- * - 'atLeastOne': 1 or more
147
- */
148
- cardinality: e.enum(["one", "atMostOne", "noneOrMany", "atLeastOne"]).optional(),
149
- /**
150
- * Input mask pattern. Accepts either a plain mask string or a stringified
151
- * arrow function that receives `locale` and returns a mask string.
152
- *
153
- * Plain pattern: `"##/##/####"`
154
- *
155
- * Function pattern: `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`
156
- */
157
- mask: e.string().optional(),
158
- // === VALIDATION ===
159
- /** Validation configuration */
160
- validation: B.optional()
161
- }).meta({
162
- title: "FieldMeta",
163
- description: "Unified field metadata - the single source of truth for field definitions, works for both forms (AForm) and tables (ATable)"
164
- }), $ = e.enum(["atMostOne", "one", "noneOrMany", "atLeastOne"]).meta({
165
- title: "Cardinality",
166
- description: "Cardinality for relationship links between doctypes"
167
- }), G = e.object({
168
- /** Fetch method type */
169
- method: e.literal("sync"),
170
- /** Optional limit on number of records to fetch */
171
- limit: e.number().int().positive().optional()
172
- }).meta({
173
- title: "SyncFetch",
174
- description: "Sync fetch strategy - data is fetched in the initial query"
175
- }), K = e.object({
176
- /** Fetch method type */
177
- method: e.literal("lazy")
178
- }).meta({
179
- title: "LazyFetch",
180
- description: "Lazy fetch strategy - data is fetched on demand in a separate query"
181
- }), V = e.object({
182
- /** Fetch method type */
183
- method: e.literal("custom"),
184
- /** Serialized handler function to invoke */
185
- handler: e.string()
186
- }).meta({
187
- title: "CustomFetch",
188
- description: "Custom fetch strategy - uses a custom handler function"
189
- }), Y = e.discriminatedUnion("method", [G, K, V]).meta({
190
- title: "FetchStrategy",
191
- description: "Fetch strategy for link data loading"
192
- }), Z = e.object({
193
- /** Target doctype slug */
194
- target: e.string().min(1),
195
- /** Cardinality of the relationship */
196
- cardinality: $,
197
- /** Backlink fieldname on the target doctype that points back to this link */
198
- backlink: e.string().optional(),
199
- /** Override default rendering component (AForm for 1:1, ATable for 1:many) */
200
- component: e.string().optional(),
201
- /** Fieldname of the corresponding Link field in the fields array */
202
- fieldname: e.string().min(1).optional(),
203
- /** Fetch strategy for loading nested data */
204
- fetch: Y.optional(),
205
- /** Whether to block workflow actions until nested data is loaded (default: true) */
206
- blockWorkflows: e.boolean().optional()
207
- }).meta({
208
- title: "LinkDeclaration",
209
- description: "Declares a relationship from one doctype to another"
210
- }), H = e.object({
211
- /** Display label for the action */
212
- label: e.string().min(1),
213
- /** Handler function name or path */
214
- handler: e.string().min(1),
215
- /** Fields that must have values before action can execute */
216
- requiredFields: e.array(e.string()).optional(),
217
- /** Workflow states where this action is available */
218
- allowedStates: e.array(e.string()).optional(),
219
- /** Whether to show a confirmation dialog */
220
- confirm: e.boolean().optional(),
221
- /** Additional arguments for the action */
222
- args: e.record(e.string(), e.unknown()).optional()
223
- }).meta({
224
- title: "ActionDefinition",
225
- description: "Action definition within a workflow"
226
- }), X = e.object({
227
- /** List of workflow states */
228
- states: e.array(e.string()).optional(),
229
- /** Actions available in this workflow */
230
- actions: e.record(e.string(), H).optional()
231
- }).meta({
232
- title: "WorkflowMeta",
233
- description: "Workflow metadata - states and actions for a doctype"
234
- }), L = e.object({
235
- /** Display name of the doctype */
236
- name: e.string().min(1),
237
- /** URL-friendly slug (kebab-case) */
238
- slug: e.string().min(1).optional(),
239
- /** Field definitions (including link fields with fieldtype: 'Link') */
240
- fields: e.array(k),
241
- /** Relationship links to other doctypes */
242
- links: e.record(e.string(), Z).optional(),
243
- /** Workflow configuration */
244
- workflow: X.optional(),
245
- /** Parent doctype for inheritance */
246
- inherits: e.string().optional()
247
- }).meta({
248
- title: "DoctypeMeta",
249
- description: "Doctype metadata - complete definition of a doctype"
250
- });
251
- function Ae(t) {
252
- const n = k.safeParse(t);
253
- return n.success ? { success: !0, errors: [] } : {
254
- success: !1,
255
- errors: n.error.issues.map((a) => ({
256
- path: a.path,
257
- message: a.message
258
- }))
259
- };
260
- }
261
- function De(t) {
262
- const n = L.safeParse(t);
263
- return n.success ? { success: !0, errors: [] } : {
264
- success: !1,
265
- errors: n.error.issues.map((a) => ({
266
- path: a.path,
267
- message: a.message
268
- }))
269
- };
270
- }
271
- function Se(t) {
272
- return k.parse(t);
273
- }
274
- function Ie(t) {
275
- return L.parse(t);
276
- }
277
- function ke(t) {
278
- return t.replace(/_([a-z])/g, (n, a) => a.toUpperCase());
279
- }
280
- function be(t) {
281
- return t.replace(/[A-Z]/g, (n) => `_${n.toLowerCase()}`);
282
- }
283
- function Fe(t) {
284
- return t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
285
- }
286
- function ee(t) {
287
- const n = t.replace(/([A-Z])/g, " $1").trim();
288
- return n.charAt(0).toUpperCase() + n.slice(1);
289
- }
290
- function te(t) {
291
- return t.split(/[-_\s]+/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join("");
292
- }
293
- function h(t) {
294
- return t.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
295
- }
296
- function Ce(t) {
297
- return t.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
298
- }
299
- const ne = {
300
- String: { component: "ATextInput", fieldtype: "Data" },
301
- Int: { component: "ANumericInput", fieldtype: "Int" },
302
- Float: { component: "ANumericInput", fieldtype: "Float" },
303
- Boolean: { component: "ACheckbox", fieldtype: "Check" },
304
- ID: { component: "ATextInput", fieldtype: "Data" }
305
- }, ie = {
306
- // Arbitrary precision / large numbers
307
- BigFloat: { component: "ADecimalInput", fieldtype: "Decimal" },
308
- BigDecimal: { component: "ADecimalInput", fieldtype: "Decimal" },
309
- Decimal: { component: "ADecimalInput", fieldtype: "Decimal" },
310
- BigInt: { component: "ANumericInput", fieldtype: "Int" },
311
- Long: { component: "ANumericInput", fieldtype: "Int" },
312
- // Identifiers
313
- UUID: { component: "ATextInput", fieldtype: "Data" },
314
- // Date / Time
315
- DateTime: { component: "ADatetimePicker", fieldtype: "Datetime" },
316
- Datetime: { component: "ADatetimePicker", fieldtype: "Datetime" },
317
- Date: { component: "ADate", fieldtype: "Date" },
318
- Time: { component: "ATimeInput", fieldtype: "Time" },
319
- Interval: { component: "ADurationInput", fieldtype: "Duration" },
320
- Duration: { component: "ADurationInput", fieldtype: "Duration" },
321
- // Structured data
322
- JSON: { component: "ACodeEditor", fieldtype: "JSON" },
323
- JSONObject: { component: "ACodeEditor", fieldtype: "JSON" },
324
- JsonNode: { component: "ACodeEditor", fieldtype: "JSON" }
325
- }, oe = /* @__PURE__ */ new Set(["Cursor"]);
326
- function ae(t) {
327
- const n = { ...ie };
328
- for (const [a, o] of Object.entries(ne))
329
- n[a] = o;
330
- if (t)
331
- for (const [a, o] of Object.entries(t))
332
- n[a] = {
333
- component: o.component ?? "ATextInput",
334
- fieldtype: o.fieldtype ?? "Data"
335
- };
336
- return n;
337
- }
338
- const re = [
339
- "Connection",
340
- "Edge",
341
- "Input",
342
- "Patch",
343
- "Payload",
344
- "Condition",
345
- "Filter",
346
- "OrderBy",
347
- "Aggregate",
348
- "AggregateResult",
349
- "AggregateFilter",
350
- "DeleteResponse",
351
- "InsertResponse",
352
- "UpdateResponse",
353
- "MutationResponse"
354
- ], se = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]);
355
- function ce(t, n) {
356
- if (t.startsWith("__") || se.has(t) || t === "Node")
357
- return !1;
358
- for (const o of re)
359
- if (t.endsWith(o))
360
- return !1;
361
- const a = n.getFields();
362
- return Object.keys(a).length !== 0;
363
- }
364
- const pe = /* @__PURE__ */ new Set(["nodeId", "__typename", "clientMutationId"]);
365
- function le(t, n, a) {
366
- return !pe.has(t);
367
- }
368
- function I(t) {
369
- let n = !1, a = !1, o = t;
370
- if (C(o) && (n = !0, o = o.ofType), j(o) && (a = !0, o = o.ofType, C(o) && (o = o.ofType)), !v(o))
371
- throw new Error(`Expected a named GraphQL type, got: ${String(o)}`);
372
- return { namedType: o, required: n, isList: a };
373
- }
374
- function de(t) {
375
- const a = t.getFields().edges;
376
- if (!a) return;
377
- const { namedType: o, isList: r } = I(a.type);
378
- if (!r || !T(o)) return;
379
- const d = o.getFields().node;
380
- if (!d) return;
381
- const { namedType: u } = I(d.type);
382
- if (T(u))
383
- return u.name;
384
- }
385
- function ue(t, n, a, o = {}) {
386
- const { namedType: r, required: y, isList: d } = I(n.type), u = ae(o.customScalars), i = {
387
- fieldname: t,
388
- label: ee(t),
389
- component: "ATextInput",
390
- fieldtype: "Data"
391
- };
392
- if (y && (i.required = !0), N(r)) {
393
- if (oe.has(r.name))
394
- return i._unmapped = !0, o.includeUnmappedMeta && (i._graphqlType = r.name), i;
395
- if (r.name === "ID") {
396
- const m = te(t);
397
- if (a.has(m))
398
- return i.component = "ALink", i.fieldtype = "Link", i.options = h(m), i;
399
- }
400
- const c = u[r.name];
401
- return c ? (i.component = c.component, i.fieldtype = c.fieldtype) : (i._unmapped = !0, o.includeUnmappedMeta && (i._graphqlType = r.name)), i;
402
- }
403
- if (x(r))
404
- return i.component = "ADropdown", i.fieldtype = "Select", i.options = r.getValues().map((c) => c.name), i;
405
- if (T(r)) {
406
- if (!d && a.has(r.name))
407
- return i.component = "ALink", i.fieldtype = "Link", i.options = h(r.name), i;
408
- const c = de(r);
409
- return c && a.has(c) ? (i.component = "ATable", i._isLink = !0, i.options = h(c), i.cardinality = "noneOrMany", delete i.fieldtype, i) : d && a.has(r.name) ? (i.component = "ATable", i._isLink = !0, i.options = h(r.name), i.cardinality = "noneOrMany", delete i.fieldtype, i) : (i._unmapped = !0, o.includeUnmappedMeta && (i._graphqlType = r.name), i);
410
- }
411
- return i._unmapped = !0, o.includeUnmappedMeta && (i._graphqlType = r.name), i;
412
- }
413
- function Le(t, n = {}) {
414
- const a = me(t), o = a.getTypeMap(), r = /* @__PURE__ */ new Set(), y = a.getQueryType(), d = a.getMutationType(), u = a.getSubscriptionType();
415
- y && r.add(y.name), d && r.add(d.name), u && r.add(u.name);
416
- const i = n.isEntityType ?? ce, c = /* @__PURE__ */ new Set();
417
- for (const [p, l] of Object.entries(o))
418
- T(l) && (r.has(p) || i(p, l) && c.add(p));
419
- let m = c;
420
- if (n.include) {
421
- const p = new Set(n.include);
422
- m = new Set([...c].filter((l) => p.has(l)));
423
- }
424
- if (n.exclude) {
425
- const p = new Set(n.exclude);
426
- m = new Set([...m].filter((l) => !p.has(l)));
427
- }
428
- const _ = n.isEntityField ?? le, b = [];
429
- for (const p of m) {
430
- const l = o[p];
431
- if (!T(l)) continue;
432
- const w = l.getFields(), F = n.typeOverrides?.[p], O = Object.entries(w).filter(([s, g]) => _(s, g, l)).map(([s, g]) => {
433
- if (n.classifyField) {
434
- const f = n.classifyField(s, g, l);
435
- if (f != null)
436
- return {
437
- fieldname: s,
438
- label: f.label ?? s,
439
- component: f.component ?? "ATextInput",
440
- fieldtype: f.fieldtype ?? "Data",
441
- ...f
442
- };
443
- }
444
- const A = ue(s, g, c, n);
445
- return F?.[s] ? { ...A, ...F[s] } : A;
446
- }), D = {}, M = O.filter((s) => s._isLink && typeof s.options == "string" && s.cardinality ? (D[s.fieldname] = {
447
- target: s.options,
448
- cardinality: s.cardinality
449
- }, !1) : !0).map((s) => {
450
- if (!n.includeUnmappedMeta) {
451
- const { _graphqlType: f, _unmapped: fe, _isLink: ye, ...E } = s;
452
- return E;
453
- }
454
- const { _isLink: g, ...A } = s;
455
- return A;
456
- }), S = {
457
- name: p,
458
- slug: h(p),
459
- fields: M
460
- };
461
- Object.keys(D).length > 0 && (S.links = D), n.includeUnmappedMeta && (S._graphqlTypeName = p), b.push(S);
462
- }
463
- return b;
464
- }
465
- function me(t) {
466
- return typeof t == "string" ? P(t) : U(t);
467
- }
468
- export {
469
- q as B,
470
- ne as G,
471
- oe as I,
472
- R as S,
473
- J as T,
474
- ie as W,
475
- be as a,
476
- ae as b,
477
- ee as c,
478
- ue as d,
479
- Le as e,
480
- le as f,
481
- ce as g,
482
- W as h,
483
- Q as i,
484
- Se as j,
485
- Ce as k,
486
- Fe as l,
487
- h as m,
488
- Ae as n,
489
- Ie as p,
490
- Te as r,
491
- ke as s,
492
- te as t,
493
- De as v
494
- };
495
- //# sourceMappingURL=index-XSSAHj8g.js.map