@stonecrop/schema 0.8.8 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cli.cjs +1 -0
  2. package/dist/cli.cjs.map +1 -0
  3. package/dist/cli.js +1 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/converter/heuristics.js +254 -0
  6. package/dist/converter/index.js +164 -0
  7. package/dist/converter/scalars.js +86 -0
  8. package/dist/converter/types.js +5 -0
  9. package/dist/doctype.js +52 -0
  10. package/dist/field.js +82 -0
  11. package/dist/fieldtype.js +70 -0
  12. package/dist/index-COrltkHl.js +1 -0
  13. package/dist/index-COrltkHl.js.map +1 -0
  14. package/dist/index-aeXXzPET.cjs +1 -0
  15. package/dist/index-aeXXzPET.cjs.map +1 -0
  16. package/dist/index.cjs +1 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.js +1 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/naming.js +106 -0
  21. package/dist/{index.d.ts → schema.d.ts} +10 -2
  22. package/dist/schema.tsbuildinfo +1 -0
  23. package/dist/src/cli.d.ts +15 -0
  24. package/dist/src/cli.d.ts.map +1 -0
  25. package/dist/src/converter/heuristics.d.ts +60 -0
  26. package/dist/src/converter/heuristics.d.ts.map +1 -0
  27. package/dist/src/converter/index.d.ts +47 -0
  28. package/dist/src/converter/index.d.ts.map +1 -0
  29. package/dist/src/converter/scalars.d.ts +46 -0
  30. package/dist/src/converter/scalars.d.ts.map +1 -0
  31. package/dist/src/converter/types.d.ts +145 -0
  32. package/dist/src/converter/types.d.ts.map +1 -0
  33. package/dist/src/doctype.d.ts +312 -0
  34. package/dist/src/doctype.d.ts.map +1 -0
  35. package/dist/src/field.d.ts +137 -0
  36. package/dist/src/field.d.ts.map +1 -0
  37. package/dist/src/fieldtype.d.ts +41 -0
  38. package/dist/src/fieldtype.d.ts.map +1 -0
  39. package/dist/src/index.d.ts +11 -0
  40. package/dist/src/index.d.ts.map +1 -0
  41. package/dist/src/naming.d.ts +80 -0
  42. package/dist/src/naming.d.ts.map +1 -0
  43. package/dist/src/tsdoc-metadata.json +11 -0
  44. package/dist/src/validation.d.ts +55 -0
  45. package/dist/src/validation.d.ts.map +1 -0
  46. package/dist/validation.js +60 -0
  47. package/package.json +5 -5
  48. package/dist/cli.d.ts +0 -1
package/dist/field.js ADDED
@@ -0,0 +1,82 @@
1
+ import { z } from 'zod';
2
+ import { StonecropFieldType } from './fieldtype';
3
+ /**
4
+ * Field options - flexible bag for type-specific configuration.
5
+ *
6
+ * Usage by fieldtype:
7
+ * - Link/Doctype: target doctype slug as string ("customer", "sales-order-item")
8
+ * - Select: array of choices (["Draft", "Submitted", "Cancelled"])
9
+ * - Decimal: config object (\{ precision: 10, scale: 2 \})
10
+ * - Code: config object (\{ language: "python" \})
11
+ *
12
+ * @public
13
+ */
14
+ export const FieldOptions = z.union([
15
+ z.string(), // Link/Doctype target: "customer"
16
+ z.array(z.string()), // Select choices: ["A", "B", "C"]
17
+ z.record(z.string(), z.unknown()), // Config: \{ precision: 10, scale: 2 \}
18
+ ]);
19
+ /**
20
+ * Validation configuration for form fields
21
+ * @public
22
+ */
23
+ export const FieldValidation = z
24
+ .object({
25
+ /** Error message to display when validation fails */
26
+ errorMessage: z.string(),
27
+ })
28
+ .passthrough();
29
+ /**
30
+ * Unified field metadata - the single source of truth for field definitions.
31
+ * Works for both forms (AForm) and tables (ATable).
32
+ *
33
+ * Core principle: "Text" is "Text" regardless of rendering context.
34
+ *
35
+ * @public
36
+ */
37
+ export const FieldMeta = z.object({
38
+ // === CORE (required) ===
39
+ /** Unique identifier for the field within its doctype */
40
+ fieldname: z.string().min(1),
41
+ /** Semantic field type - determines behavior and default component */
42
+ fieldtype: StonecropFieldType,
43
+ // === COMPONENT (optional - derived from fieldtype when not specified) ===
44
+ /** Vue component to render this field. If not specified, derived from TYPE_MAP */
45
+ component: z.string().optional(),
46
+ // === DISPLAY ===
47
+ /** Human-readable label for the field */
48
+ label: z.string().optional(),
49
+ /** Width of the field (CSS value, e.g., "40ch", "200px") */
50
+ width: z.string().optional(),
51
+ /** Text alignment within the field */
52
+ align: z.enum(['left', 'center', 'right', 'start', 'end']).optional(),
53
+ // === BEHAVIOR ===
54
+ /** Whether the field is required */
55
+ required: z.boolean().optional(),
56
+ /** Whether the field is read-only */
57
+ readOnly: z.boolean().optional(),
58
+ /** Whether the field is editable (for table cells) */
59
+ edit: z.boolean().optional(),
60
+ /** Whether the field is hidden from the UI */
61
+ hidden: z.boolean().optional(),
62
+ // === VALUE ===
63
+ /** Current value of the field */
64
+ value: z.unknown().optional(),
65
+ /** Default value for new records */
66
+ default: z.unknown().optional(),
67
+ // === TYPE-SPECIFIC ===
68
+ /**
69
+ * Type-specific options:
70
+ * - Link: target doctype slug ("customer")
71
+ * - Doctype: child doctype slug ("sales-order-item")
72
+ * - Select: choices array (["Draft", "Submitted"])
73
+ * - Decimal: \{ precision, scale \}
74
+ * - Code: \{ language \}
75
+ */
76
+ options: FieldOptions.optional(),
77
+ /** Input mask pattern (e.g., "##/##/####" for dates) */
78
+ mask: z.string().optional(),
79
+ // === VALIDATION ===
80
+ /** Validation configuration */
81
+ validation: FieldValidation.optional(),
82
+ });
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Stonecrop field types - the semantic type of the field.
4
+ * These are consistent across forms and tables.
5
+ * @public
6
+ */
7
+ export const StonecropFieldType = z.enum([
8
+ 'Data', // Short text, varchar
9
+ 'Text', // Long text
10
+ 'Int', // Integer
11
+ 'Float', // Floating point (IEEE 754)
12
+ 'Decimal', // Arbitrary precision decimal
13
+ 'Check', // Boolean/checkbox
14
+ 'Date', // Date only
15
+ 'Time', // Time only
16
+ 'Datetime', // Date and time
17
+ 'Duration', // Time interval
18
+ 'DateRange', // Date range
19
+ 'JSON', // JSON data
20
+ 'Code', // Code/source (with syntax highlighting)
21
+ 'Link', // Reference to another doctype
22
+ 'Doctype', // Child doctype (renders as table)
23
+ 'Attach', // File attachment
24
+ 'Currency', // Currency value
25
+ 'Quantity', // Quantity with unit
26
+ 'Select', // Dropdown selection
27
+ ]);
28
+ /**
29
+ * Mapping from StonecropFieldType to default Vue component.
30
+ * Components can be overridden in the field definition.
31
+ * @public
32
+ */
33
+ export const TYPE_MAP = {
34
+ // Text
35
+ Data: { component: 'ATextInput', fieldtype: 'Data' },
36
+ Text: { component: 'ATextInput', fieldtype: 'Text' },
37
+ // Numeric
38
+ Int: { component: 'ANumericInput', fieldtype: 'Int' },
39
+ Float: { component: 'ANumericInput', fieldtype: 'Float' },
40
+ Decimal: { component: 'ADecimalInput', fieldtype: 'Decimal' },
41
+ // Boolean
42
+ Check: { component: 'ACheckbox', fieldtype: 'Check' },
43
+ // Date/Time
44
+ Date: { component: 'ADatePicker', fieldtype: 'Date' },
45
+ Time: { component: 'ATimeInput', fieldtype: 'Time' },
46
+ Datetime: { component: 'ADatetimePicker', fieldtype: 'Datetime' },
47
+ Duration: { component: 'ADurationInput', fieldtype: 'Duration' },
48
+ DateRange: { component: 'ADateRangePicker', fieldtype: 'DateRange' },
49
+ // Structured
50
+ JSON: { component: 'ACodeEditor', fieldtype: 'JSON' },
51
+ Code: { component: 'ACodeEditor', fieldtype: 'Code' },
52
+ // Relational
53
+ Link: { component: 'ALink', fieldtype: 'Link' },
54
+ Doctype: { component: 'ATable', fieldtype: 'Doctype' },
55
+ // Files
56
+ Attach: { component: 'AFileAttach', fieldtype: 'Attach' },
57
+ // Specialized
58
+ Currency: { component: 'ACurrencyInput', fieldtype: 'Currency' },
59
+ Quantity: { component: 'AQuantityInput', fieldtype: 'Quantity' },
60
+ Select: { component: 'ADropdown', fieldtype: 'Select' },
61
+ };
62
+ /**
63
+ * Get the default component for a field type
64
+ * @param fieldtype - The semantic field type
65
+ * @returns The default component name
66
+ * @public
67
+ */
68
+ export function getDefaultComponent(fieldtype) {
69
+ return TYPE_MAP[fieldtype]?.component ?? 'ATextInput';
70
+ }
@@ -398,3 +398,4 @@ export {
398
398
  fe as t,
399
399
  pe as v
400
400
  };
401
+ //# sourceMappingURL=index-COrltkHl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-COrltkHl.js","sources":["../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 * Stonecrop field types - the semantic type of the field.\n * These are consistent across forms and tables.\n * @public\n */\nexport const StonecropFieldType = z.enum([\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'Doctype', // Child doctype (renders as table)\n\t'Attach', // File attachment\n\t'Currency', // Currency value\n\t'Quantity', // Quantity with unit\n\t'Select', // Dropdown selection\n])\n\n/**\n * Stonecrop field type enum inferred from Zod schema\n * @public\n */\nexport type StonecropFieldType = z.infer<typeof StonecropFieldType>\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: StonecropFieldType\n}\n\n/**\n * Mapping from StonecropFieldType to default Vue component.\n * Components can be overridden in the field definition.\n * @public\n */\nexport const TYPE_MAP: Record<StonecropFieldType, 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: 'ADatePicker', 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\tDoctype: { component: 'ATable', fieldtype: 'Doctype' },\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\n/**\n * Get the default component for a field type\n * @param fieldtype - The semantic field type\n * @returns The default component name\n * @public\n */\nexport function getDefaultComponent(fieldtype: StonecropFieldType): string {\n\treturn TYPE_MAP[fieldtype]?.component ?? 'ATextInput'\n}\n","import { z } from 'zod'\n\nimport { StonecropFieldType } from './fieldtype'\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.union([\n\tz.string(), // Link/Doctype target: \"customer\"\n\tz.array(z.string()), // Select choices: [\"A\", \"B\", \"C\"]\n\tz.record(z.string(), z.unknown()), // Config: \\{ precision: 10, scale: 2 \\}\n])\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.object({\n\t\t/** Error message to display when validation fails */\n\t\terrorMessage: z.string(),\n\t})\n\t.passthrough()\n\n/**\n * Field validation type inferred from Zod schema\n * @public\n */\nexport type FieldValidation = z.infer<typeof FieldValidation>\n\n/**\n * Unified field metadata - the single source of truth for field definitions.\n * Works for both forms (AForm) and tables (ATable).\n *\n * Core principle: \"Text\" is \"Text\" regardless of rendering context.\n *\n * @public\n */\nexport const FieldMeta = z.object({\n\t// === CORE (required) ===\n\n\t/** Unique identifier for the field within its doctype */\n\tfieldname: z.string().min(1),\n\n\t/** Semantic field type - determines behavior and default component */\n\tfieldtype: StonecropFieldType,\n\n\t// === COMPONENT (optional - derived from fieldtype when not specified) ===\n\n\t/** Vue component to render this field. If not specified, derived from TYPE_MAP */\n\tcomponent: z.string().optional(),\n\n\t// === DISPLAY ===\n\n\t/** Human-readable label for the field */\n\tlabel: z.string().optional(),\n\n\t/** Width of the field (CSS value, e.g., \"40ch\", \"200px\") */\n\twidth: z.string().optional(),\n\n\t/** Text alignment within the field */\n\talign: z.enum(['left', 'center', 'right', 'start', 'end']).optional(),\n\n\t// === BEHAVIOR ===\n\n\t/** Whether the field is required */\n\trequired: z.boolean().optional(),\n\n\t/** Whether the field is read-only */\n\treadOnly: z.boolean().optional(),\n\n\t/** Whether the field is editable (for table cells) */\n\tedit: z.boolean().optional(),\n\n\t/** Whether the field is hidden from the UI */\n\thidden: z.boolean().optional(),\n\n\t// === VALUE ===\n\n\t/** Current value of the field */\n\tvalue: z.unknown().optional(),\n\n\t/** Default value for new records */\n\tdefault: z.unknown().optional(),\n\n\t// === TYPE-SPECIFIC ===\n\n\t/**\n\t * Type-specific options:\n\t * - Link: target doctype slug (\"customer\")\n\t * - Doctype: child doctype slug (\"sales-order-item\")\n\t * - Select: choices array ([\"Draft\", \"Submitted\"])\n\t * - Decimal: \\{ precision, scale \\}\n\t * - Code: \\{ language \\}\n\t */\n\toptions: FieldOptions.optional(),\n\n\t/** Input mask pattern (e.g., \"##/##/####\" for dates) */\n\tmask: z.string().optional(),\n\n\t// === VALIDATION ===\n\n\t/** Validation configuration */\n\tvalidation: FieldValidation.optional(),\n})\n\n/**\n * Field metadata type inferred from Zod schema\n * @public\n */\nexport type FieldMeta = z.infer<typeof FieldMeta>\n","import { z } from 'zod'\n\nimport { FieldMeta } from './field'\n\n/**\n * Action definition within a workflow\n * @public\n */\nexport const ActionDefinition = z.object({\n\t/** Display label for the action */\n\tlabel: z.string().min(1),\n\n\t/** Handler function name or path */\n\thandler: z.string().min(1),\n\n\t/** Fields that must have values before action can execute */\n\trequiredFields: z.array(z.string()).optional(),\n\n\t/** Workflow states where this action is available */\n\tallowedStates: z.array(z.string()).optional(),\n\n\t/** Whether to show a confirmation dialog */\n\tconfirm: z.boolean().optional(),\n\n\t/** Additional arguments for the action */\n\targs: z.record(z.string(), z.unknown()).optional(),\n})\n\n/**\n * Action definition type inferred from Zod schema\n * @public\n */\nexport type ActionDefinition = z.infer<typeof ActionDefinition>\n\n/**\n * Workflow metadata - states and actions for a doctype\n * @public\n */\nexport const WorkflowMeta = z.object({\n\t/** List of workflow states */\n\tstates: z.array(z.string()).optional(),\n\n\t/** Actions available in this workflow */\n\tactions: z.record(z.string(), ActionDefinition).optional(),\n})\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.object({\n\t/** Display name of the doctype */\n\tname: z.string().min(1),\n\n\t/** URL-friendly slug (kebab-case) */\n\tslug: z.string().min(1).optional(),\n\n\t/** Database table name */\n\ttableName: z.string().optional(),\n\n\t/** Field definitions */\n\tfields: z.array(FieldMeta),\n\n\t/** Workflow configuration */\n\tworkflow: WorkflowMeta.optional(),\n\n\t/** Parent doctype for inheritance */\n\tinherits: z.string().optional(),\n\n\t/** Doctype to use for list views */\n\tlistDoctype: z.string().optional(),\n\n\t/** Parent doctype for child tables */\n\tparentDoctype: z.string().optional(),\n})\n\n/**\n * Doctype metadata type inferred from Zod schema\n * @public\n */\nexport type DoctypeMeta = z.infer<typeof DoctypeMeta>\n","import { FieldMeta } 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: (string | number)[]\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\n * @param data - Data to validate\n * @returns Validation result\n * @public\n */\nexport function validateField(data: unknown): ValidationResult {\n\tconst result = FieldMeta.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 FieldMeta\n * @throws ZodError if validation fails\n * @public\n */\nexport function parseField(data: unknown): FieldMeta {\n\treturn FieldMeta.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 { FieldMeta } 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: 'ADatePicker', 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 * @internal\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\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 } 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\n\treturn { namedType: current as GraphQLNamedType, 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\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\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 → Doctype (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.fieldtype = 'Doctype'\n\t\t\tbase.options = toSlug(connectionNodeTypeName)\n\t\t\treturn base\n\t\t}\n\n\t\t// 5. List of entity type → Doctype\n\t\tif (isList && entityTypes.has(namedType.name)) {\n\t\t\tbase.component = 'ATable'\n\t\t\tbase.fieldtype = 'Doctype'\n\t\t\tbase.options = toSlug(namedType.name)\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 { toSlug, pascalToSnake } from '../naming'\nimport type { IntrospectionSource, GraphQLConversionOptions, ConvertedGraphQLDoctype } from './types'\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\tconst deriveTableName = options.deriveTableName ?? ((typeName: string) => pascalToSnake(typeName))\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 convertedFields = Object.entries(fields)\n\t\t\t.filter(([fieldName, field]) => isEntityField(fieldName, field, type))\n\t\t\t.map(([fieldName, field]) => {\n\t\t\t\t// Check for full custom classification first\n\t\t\t\tif (options.classifyField) {\n\t\t\t\t\tconst custom = options.classifyField(fieldName, field, type)\n\t\t\t\t\tif (custom !== null && custom !== undefined) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tfieldname: fieldName,\n\t\t\t\t\t\t\tlabel: custom.label ?? fieldName,\n\t\t\t\t\t\t\tcomponent: custom.component ?? 'ATextInput',\n\t\t\t\t\t\t\tfieldtype: custom.fieldtype ?? 'Data',\n\t\t\t\t\t\t\t...custom,\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Default classification\n\t\t\t\tconst classified = classifyFieldType(fieldName, field, entityTypes, options)\n\n\t\t\t\t// Apply per-field overrides\n\t\t\t\tif (typeOverrides?.[fieldName]) {\n\t\t\t\t\treturn { ...classified, ...typeOverrides[fieldName] }\n\t\t\t\t}\n\n\t\t\t\treturn classified\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, ...clean } = field\n\t\t\t\t\treturn clean\n\t\t\t\t}\n\t\t\t\treturn field\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,\n\t\t}\n\n\t\tconst tableName = deriveTableName(typeName)\n\t\tif (tableName) {\n\t\t\tdoctype.tableName = tableName\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":["StonecropFieldType","z","TYPE_MAP","getDefaultComponent","fieldtype","FieldOptions","FieldValidation","FieldMeta","ActionDefinition","WorkflowMeta","DoctypeMeta","validateField","data","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","getConnectionNodeType","edgesField","edgesType","edgesIsList","isObjectType","nodeField","nodeType","classifyFieldType","field","entityTypes","options","namedType","scalarMap","base","isScalarType","template","isEnumType","v","connectionNodeTypeName","convertGraphQLSchema","source","schema","buildGraphQLSchema","typeMap","rootTypeNames","queryType","mutationType","subscriptionType","isEntityType","filteredEntityTypes","includeSet","t","excludeSet","isEntityField","deriveTableName","doctypes","typeOverrides","convertedFields","custom","classified","_graphqlType","_unmapped","clean","doctype","buildSchema","buildClientSchema"],"mappings":";;AAOO,MAAMA,IAAqBC,EAAE,KAAK;AAAA,EACxC;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACD,CAAC,GA6BYC,IAAsD;AAAA;AAAA,EAElE,MAAM,EAAE,WAAW,cAAc,WAAW,OAAA;AAAA,EAC5C,MAAM,EAAE,WAAW,cAAc,WAAW,OAAA;AAAA;AAAA,EAG5C,KAAK,EAAE,WAAW,iBAAiB,WAAW,MAAA;AAAA,EAC9C,OAAO,EAAE,WAAW,iBAAiB,WAAW,QAAA;AAAA,EAChD,SAAS,EAAE,WAAW,iBAAiB,WAAW,UAAA;AAAA;AAAA,EAGlD,OAAO,EAAE,WAAW,aAAa,WAAW,QAAA;AAAA;AAAA,EAG5C,MAAM,EAAE,WAAW,eA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,YAAY1E,IAGjByC,EAAQ,wBACXiC,EAAQ,mBAAmB1D,IAG5BkD,EAAS,KAAKQ,CAAO;AAAA,EACtB;AAEA,SAAOR;AACR;AASA,SAASb,GAAmBF,GAA4C;AACvE,SAAI,OAAOA,KAAW,WAEdwB,EAAYxB,CAAM,IAInByB,EAAkBzB,CAAM;AAChC;"}
@@ -1 +1,2 @@
1
1
  "use strict";const e=require("zod"),l=require("graphql"),_=e.z.enum(["Data","Text","Int","Float","Decimal","Check","Date","Time","Datetime","Duration","DateRange","JSON","Code","Link","Doctype","Attach","Currency","Quantity","Select"]),L={Data:{component:"ATextInput",fieldtype:"Data"},Text:{component:"ATextInput",fieldtype:"Text"},Int:{component:"ANumericInput",fieldtype:"Int"},Float:{component:"ANumericInput",fieldtype:"Float"},Decimal:{component:"ADecimalInput",fieldtype:"Decimal"},Check:{component:"ACheckbox",fieldtype:"Check"},Date:{component:"ADatePicker",fieldtype:"Date"},Time:{component:"ATimeInput",fieldtype:"Time"},Datetime:{component:"ADatetimePicker",fieldtype:"Datetime"},Duration:{component:"ADurationInput",fieldtype:"Duration"},DateRange:{component:"ADateRangePicker",fieldtype:"DateRange"},JSON:{component:"ACodeEditor",fieldtype:"JSON"},Code:{component:"ACodeEditor",fieldtype:"Code"},Link:{component:"ALink",fieldtype:"Link"},Doctype:{component:"ATable",fieldtype:"Doctype"},Attach:{component:"AFileAttach",fieldtype:"Attach"},Currency:{component:"ACurrencyInput",fieldtype:"Currency"},Quantity:{component:"AQuantityInput",fieldtype:"Quantity"},Select:{component:"ADropdown",fieldtype:"Select"}};function B(t){return L[t]?.component??"ATextInput"}const k=e.z.union([e.z.string(),e.z.array(e.z.string()),e.z.record(e.z.string(),e.z.unknown())]),N=e.z.object({errorMessage:e.z.string()}).passthrough(),D=e.z.object({fieldname:e.z.string().min(1),fieldtype:_,component:e.z.string().optional(),label:e.z.string().optional(),width:e.z.string().optional(),align:e.z.enum(["left","center","right","start","end"]).optional(),required:e.z.boolean().optional(),readOnly:e.z.boolean().optional(),edit:e.z.boolean().optional(),hidden:e.z.boolean().optional(),value:e.z.unknown().optional(),default:e.z.unknown().optional(),options:k.optional(),mask:e.z.string().optional(),validation:N.optional()}),O=e.z.object({label:e.z.string().min(1),handler:e.z.string().min(1),requiredFields:e.z.array(e.z.string()).optional(),allowedStates:e.z.array(e.z.string()).optional(),confirm:e.z.boolean().optional(),args:e.z.record(e.z.string(),e.z.unknown()).optional()}),E=e.z.object({states:e.z.array(e.z.string()).optional(),actions:e.z.record(e.z.string(),O).optional()}),z=e.z.object({name:e.z.string().min(1),slug:e.z.string().min(1).optional(),tableName:e.z.string().optional(),fields:e.z.array(D),workflow:E.optional(),inherits:e.z.string().optional(),listDoctype:e.z.string().optional(),parentDoctype:e.z.string().optional()});function G(t){const n=D.safeParse(t);return n.success?{success:!0,errors:[]}:{success:!1,errors:n.error.issues.map(i=>({path:i.path,message:i.message}))}}function Y(t){const n=z.safeParse(t);return n.success?{success:!0,errors:[]}:{success:!1,errors:n.error.issues.map(i=>({path:i.path,message:i.message}))}}function Z(t){return D.parse(t)}function K(t){return z.parse(t)}function V(t){return t.replace(/_([a-z])/g,(n,i)=>i.toUpperCase())}function H(t){return t.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`)}function X(t){return t.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" ")}function M(t){const n=t.replace(/([A-Z])/g," $1").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function ee(t){return t.split(/[-_\s]+/).map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join("")}function T(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function w(t){return t.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[\s-]+/g,"_").toLowerCase()}const v={String:{component:"ATextInput",fieldtype:"Data"},Int:{component:"ANumericInput",fieldtype:"Int"},Float:{component:"ANumericInput",fieldtype:"Float"},Boolean:{component:"ACheckbox",fieldtype:"Check"},ID:{component:"ATextInput",fieldtype:"Data"}},P={BigFloat:{component:"ADecimalInput",fieldtype:"Decimal"},BigDecimal:{component:"ADecimalInput",fieldtype:"Decimal"},Decimal:{component:"ADecimalInput",fieldtype:"Decimal"},BigInt:{component:"ANumericInput",fieldtype:"Int"},Long:{component:"ANumericInput",fieldtype:"Int"},UUID:{component:"ATextInput",fieldtype:"Data"},DateTime:{component:"ADatetimePicker",fieldtype:"Datetime"},Datetime:{component:"ADatetimePicker",fieldtype:"Datetime"},Date:{component:"ADatePicker",fieldtype:"Date"},Time:{component:"ATimeInput",fieldtype:"Time"},Interval:{component:"ADurationInput",fieldtype:"Duration"},Duration:{component:"ADurationInput",fieldtype:"Duration"},JSON:{component:"ACodeEditor",fieldtype:"JSON"},JSONObject:{component:"ACodeEditor",fieldtype:"JSON"},JsonNode:{component:"ACodeEditor",fieldtype:"JSON"}},j=new Set(["Cursor"]);function x(t){const n={...P};for(const[i,a]of Object.entries(v))n[i]=a;if(t)for(const[i,a]of Object.entries(t))n[i]={component:a.component??"ATextInput",fieldtype:a.fieldtype??"Data"};return n}const te=["Connection","Edge","Input","Patch","Payload","Condition","Filter","OrderBy","Aggregate","AggregateResult","AggregateFilter","DeleteResponse","InsertResponse","UpdateResponse","MutationResponse"],ne=new Set(["Query","Mutation","Subscription"]);function R(t,n){if(t.startsWith("__")||ne.has(t)||t==="Node")return!1;for(const a of te)if(t.endsWith(a))return!1;const i=n.getFields();return Object.keys(i).length!==0}const oe=new Set(["nodeId","__typename","clientMutationId"]);function q(t,n,i){return!oe.has(t)}function I(t){let n=!1,i=!1,a=t;return l.isNonNullType(a)&&(n=!0,a=a.ofType),l.isListType(a)&&(i=!0,a=a.ofType,l.isNonNullType(a)&&(a=a.ofType)),{namedType:a,required:n,isList:i}}function ie(t){const i=t.getFields().edges;if(!i)return;const{namedType:a,isList:r}=I(i.type);if(!r||!l.isObjectType(a))return;const d=a.getFields().node;if(!d)return;const{namedType:m}=I(d.type);if(l.isObjectType(m))return m.name}function U(t,n,i,a={}){const{namedType:r,required:y,isList:d}=I(n.type),m=x(a.customScalars),o={fieldname:t,label:M(t),component:"ATextInput",fieldtype:"Data"};if(y&&(o.required=!0),l.isScalarType(r)){if(j.has(r.name))return o._unmapped=!0,a.includeUnmappedMeta&&(o._graphqlType=r.name),o;const c=m[r.name];return c?(o.component=c.component,o.fieldtype=c.fieldtype):(o._unmapped=!0,a.includeUnmappedMeta&&(o._graphqlType=r.name)),o}if(l.isEnumType(r))return o.component="ADropdown",o.fieldtype="Select",o.options=r.getValues().map(c=>c.name),o;if(l.isObjectType(r)){if(!d&&i.has(r.name))return o.component="ALink",o.fieldtype="Link",o.options=T(r.name),o;const c=ie(r);return c&&i.has(c)?(o.component="ATable",o.fieldtype="Doctype",o.options=T(c),o):d&&i.has(r.name)?(o.component="ATable",o.fieldtype="Doctype",o.options=T(r.name),o):(o._unmapped=!0,a.includeUnmappedMeta&&(o._graphqlType=r.name),o)}return o._unmapped=!0,a.includeUnmappedMeta&&(o._graphqlType=r.name),o}function ae(t,n={}){const i=re(t),a=i.getTypeMap(),r=new Set,y=i.getQueryType(),d=i.getMutationType(),m=i.getSubscriptionType();y&&r.add(y.name),d&&r.add(d.name),m&&r.add(m.name);const o=n.isEntityType??R,c=new Set;for(const[p,s]of Object.entries(a))l.isObjectType(s)&&(r.has(p)||o(p,s)&&c.add(p));let A=c;if(n.include){const p=new Set(n.include);A=new Set([...c].filter(s=>p.has(s)))}if(n.exclude){const p=new Set(n.exclude);A=new Set([...A].filter(s=>!p.has(s)))}const Q=n.isEntityField??q,J=n.deriveTableName??(p=>w(p)),b=[];for(const p of A){const s=a[p];if(!l.isObjectType(s))continue;const W=s.getFields(),C=n.typeOverrides?.[p],$=Object.entries(W).filter(([u,g])=>Q(u,g,s)).map(([u,g])=>{if(n.classifyField){const f=n.classifyField(u,g,s);if(f!=null)return{fieldname:u,label:f.label??u,component:f.component??"ATextInput",fieldtype:f.fieldtype??"Data",...f}}const h=U(u,g,c,n);return C?.[u]?{...h,...C[u]}:h}).map(u=>{if(!n.includeUnmappedMeta){const{_graphqlType:g,_unmapped:h,...f}=u;return f}return u}),S={name:p,slug:T(p),fields:$},F=J(p);F&&(S.tableName=F),n.includeUnmappedMeta&&(S._graphqlTypeName=p),b.push(S)}return b}function re(t){return typeof t=="string"?l.buildSchema(t):l.buildClientSchema(t)}exports.ActionDefinition=O;exports.DoctypeMeta=z;exports.FieldMeta=D;exports.FieldOptions=k;exports.FieldValidation=N;exports.GQL_SCALAR_MAP=v;exports.INTERNAL_SCALARS=j;exports.StonecropFieldType=_;exports.TYPE_MAP=L;exports.WELL_KNOWN_SCALARS=P;exports.WorkflowMeta=E;exports.buildScalarMap=x;exports.camelToLabel=M;exports.camelToSnake=H;exports.classifyFieldType=U;exports.convertGraphQLSchema=ae;exports.defaultIsEntityField=q;exports.defaultIsEntityType=R;exports.getDefaultComponent=B;exports.parseDoctype=K;exports.parseField=Z;exports.pascalToSnake=w;exports.snakeToCamel=V;exports.snakeToLabel=X;exports.toPascalCase=ee;exports.toSlug=T;exports.validateDoctype=Y;exports.validateField=G;
2
+ //# sourceMappingURL=index-aeXXzPET.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-aeXXzPET.cjs","sources":["../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 * Stonecrop field types - the semantic type of the field.\n * These are consistent across forms and tables.\n * @public\n */\nexport const StonecropFieldType = z.enum([\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'Doctype', // Child doctype (renders as table)\n\t'Attach', // File attachment\n\t'Currency', // Currency value\n\t'Quantity', // Quantity with unit\n\t'Select', // Dropdown selection\n])\n\n/**\n * Stonecrop field type enum inferred from Zod schema\n * @public\n */\nexport type StonecropFieldType = z.infer<typeof StonecropFieldType>\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: StonecropFieldType\n}\n\n/**\n * Mapping from StonecropFieldType to default Vue component.\n * Components can be overridden in the field definition.\n * @public\n */\nexport const TYPE_MAP: Record<StonecropFieldType, 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: 'ADatePicker', 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\tDoctype: { component: 'ATable', fieldtype: 'Doctype' },\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\n/**\n * Get the default component for a field type\n * @param fieldtype - The semantic field type\n * @returns The default component name\n * @public\n */\nexport function getDefaultComponent(fieldtype: StonecropFieldType): string {\n\treturn TYPE_MAP[fieldtype]?.component ?? 'ATextInput'\n}\n","import { z } from 'zod'\n\nimport { StonecropFieldType } from './fieldtype'\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.union([\n\tz.string(), // Link/Doctype target: \"customer\"\n\tz.array(z.string()), // Select choices: [\"A\", \"B\", \"C\"]\n\tz.record(z.string(), z.unknown()), // Config: \\{ precision: 10, scale: 2 \\}\n])\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.object({\n\t\t/** Error message to display when validation fails */\n\t\terrorMessage: z.string(),\n\t})\n\t.passthrough()\n\n/**\n * Field validation type inferred from Zod schema\n * @public\n */\nexport type FieldValidation = z.infer<typeof FieldValidation>\n\n/**\n * Unified field metadata - the single source of truth for field definitions.\n * Works for both forms (AForm) and tables (ATable).\n *\n * Core principle: \"Text\" is \"Text\" regardless of rendering context.\n *\n * @public\n */\nexport const FieldMeta = z.object({\n\t// === CORE (required) ===\n\n\t/** Unique identifier for the field within its doctype */\n\tfieldname: z.string().min(1),\n\n\t/** Semantic field type - determines behavior and default component */\n\tfieldtype: StonecropFieldType,\n\n\t// === COMPONENT (optional - derived from fieldtype when not specified) ===\n\n\t/** Vue component to render this field. If not specified, derived from TYPE_MAP */\n\tcomponent: z.string().optional(),\n\n\t// === DISPLAY ===\n\n\t/** Human-readable label for the field */\n\tlabel: z.string().optional(),\n\n\t/** Width of the field (CSS value, e.g., \"40ch\", \"200px\") */\n\twidth: z.string().optional(),\n\n\t/** Text alignment within the field */\n\talign: z.enum(['left', 'center', 'right', 'start', 'end']).optional(),\n\n\t// === BEHAVIOR ===\n\n\t/** Whether the field is required */\n\trequired: z.boolean().optional(),\n\n\t/** Whether the field is read-only */\n\treadOnly: z.boolean().optional(),\n\n\t/** Whether the field is editable (for table cells) */\n\tedit: z.boolean().optional(),\n\n\t/** Whether the field is hidden from the UI */\n\thidden: z.boolean().optional(),\n\n\t// === VALUE ===\n\n\t/** Current value of the field */\n\tvalue: z.unknown().optional(),\n\n\t/** Default value for new records */\n\tdefault: z.unknown().optional(),\n\n\t// === TYPE-SPECIFIC ===\n\n\t/**\n\t * Type-specific options:\n\t * - Link: target doctype slug (\"customer\")\n\t * - Doctype: child doctype slug (\"sales-order-item\")\n\t * - Select: choices array ([\"Draft\", \"Submitted\"])\n\t * - Decimal: \\{ precision, scale \\}\n\t * - Code: \\{ language \\}\n\t */\n\toptions: FieldOptions.optional(),\n\n\t/** Input mask pattern (e.g., \"##/##/####\" for dates) */\n\tmask: z.string().optional(),\n\n\t// === VALIDATION ===\n\n\t/** Validation configuration */\n\tvalidation: FieldValidation.optional(),\n})\n\n/**\n * Field metadata type inferred from Zod schema\n * @public\n */\nexport type FieldMeta = z.infer<typeof FieldMeta>\n","import { z } from 'zod'\n\nimport { FieldMeta } from './field'\n\n/**\n * Action definition within a workflow\n * @public\n */\nexport const ActionDefinition = z.object({\n\t/** Display label for the action */\n\tlabel: z.string().min(1),\n\n\t/** Handler function name or path */\n\thandler: z.string().min(1),\n\n\t/** Fields that must have values before action can execute */\n\trequiredFields: z.array(z.string()).optional(),\n\n\t/** Workflow states where this action is available */\n\tallowedStates: z.array(z.string()).optional(),\n\n\t/** Whether to show a confirmation dialog */\n\tconfirm: z.boolean().optional(),\n\n\t/** Additional arguments for the action */\n\targs: z.record(z.string(), z.unknown()).optional(),\n})\n\n/**\n * Action definition type inferred from Zod schema\n * @public\n */\nexport type ActionDefinition = z.infer<typeof ActionDefinition>\n\n/**\n * Workflow metadata - states and actions for a doctype\n * @public\n */\nexport const WorkflowMeta = z.object({\n\t/** List of workflow states */\n\tstates: z.array(z.string()).optional(),\n\n\t/** Actions available in this workflow */\n\tactions: z.record(z.string(), ActionDefinition).optional(),\n})\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.object({\n\t/** Display name of the doctype */\n\tname: z.string().min(1),\n\n\t/** URL-friendly slug (kebab-case) */\n\tslug: z.string().min(1).optional(),\n\n\t/** Database table name */\n\ttableName: z.string().optional(),\n\n\t/** Field definitions */\n\tfields: z.array(FieldMeta),\n\n\t/** Workflow configuration */\n\tworkflow: WorkflowMeta.optional(),\n\n\t/** Parent doctype for inheritance */\n\tinherits: z.string().optional(),\n\n\t/** Doctype to use for list views */\n\tlistDoctype: z.string().optional(),\n\n\t/** Parent doctype for child tables */\n\tparentDoctype: z.string().optional(),\n})\n\n/**\n * Doctype metadata type inferred from Zod schema\n * @public\n */\nexport type DoctypeMeta = z.infer<typeof DoctypeMeta>\n","import { FieldMeta } 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: (string | number)[]\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\n * @param data - Data to validate\n * @returns Validation result\n * @public\n */\nexport function validateField(data: unknown): ValidationResult {\n\tconst result = FieldMeta.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 FieldMeta\n * @throws ZodError if validation fails\n * @public\n */\nexport function parseField(data: unknown): FieldMeta {\n\treturn FieldMeta.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 { FieldMeta } 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: 'ADatePicker', 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 * @internal\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\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 } 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\n\treturn { namedType: current as GraphQLNamedType, 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\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\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 → Doctype (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.fieldtype = 'Doctype'\n\t\t\tbase.options = toSlug(connectionNodeTypeName)\n\t\t\treturn base\n\t\t}\n\n\t\t// 5. List of entity type → Doctype\n\t\tif (isList && entityTypes.has(namedType.name)) {\n\t\t\tbase.component = 'ATable'\n\t\t\tbase.fieldtype = 'Doctype'\n\t\t\tbase.options = toSlug(namedType.name)\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 { toSlug, pascalToSnake } from '../naming'\nimport type { IntrospectionSource, GraphQLConversionOptions, ConvertedGraphQLDoctype } from './types'\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\tconst deriveTableName = options.deriveTableName ?? ((typeName: string) => pascalToSnake(typeName))\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 convertedFields = Object.entries(fields)\n\t\t\t.filter(([fieldName, field]) => isEntityField(fieldName, field, type))\n\t\t\t.map(([fieldName, field]) => {\n\t\t\t\t// Check for full custom classification first\n\t\t\t\tif (options.classifyField) {\n\t\t\t\t\tconst custom = options.classifyField(fieldName, field, type)\n\t\t\t\t\tif (custom !== null && custom !== undefined) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tfieldname: fieldName,\n\t\t\t\t\t\t\tlabel: custom.label ?? fieldName,\n\t\t\t\t\t\t\tcomponent: custom.component ?? 'ATextInput',\n\t\t\t\t\t\t\tfieldtype: custom.fieldtype ?? 'Data',\n\t\t\t\t\t\t\t...custom,\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Default classification\n\t\t\t\tconst classified = classifyFieldType(fieldName, field, entityTypes, options)\n\n\t\t\t\t// Apply per-field overrides\n\t\t\t\tif (typeOverrides?.[fieldName]) {\n\t\t\t\t\treturn { ...classified, ...typeOverrides[fieldName] }\n\t\t\t\t}\n\n\t\t\t\treturn classified\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, ...clean } = field\n\t\t\t\t\treturn clean\n\t\t\t\t}\n\t\t\t\treturn field\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,\n\t\t}\n\n\t\tconst tableName = deriveTableName(typeName)\n\t\tif (tableName) {\n\t\t\tdoctype.tableName = tableName\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":["StonecropFieldType","z","TYPE_MAP","getDefaultComponent","fieldtype","FieldOptions","FieldValidation","FieldMeta","ActionDefinition","WorkflowMeta","DoctypeMeta","validateField","data","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","getConnectionNodeType","edgesField","edgesType","edgesIsList","isObjectType","nodeField","nodeType","classifyFieldType","field","entityTypes","options","namedType","scalarMap","base","isScalarType","template","isEnumType","v","connectionNodeTypeName","convertGraphQLSchema","source","schema","buildGraphQLSchema","typeMap","rootTypeNames","queryType","mutationType","subscriptionType","isEntityType","filteredEntityTypes","includeSet","t","excludeSet","isEntityField","deriveTableName","doctypes","typeOverrides","convertedFields","custom","classified","_graphqlType","_unmapped","clean","doctype","buildSchema","buildClientSchema"],"mappings":"yDAOaA,EAAqBC,EAAAA,EAAE,KAAK,CACxC,OACA,OACA,MACA,QACA,UACA,QACA,OACA,OACA,WACA,WACA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G,EAAWiB,CAAK,IAAMyB,EAAc1C,EAAWiB,EAAOtB,CAAI,CAAC,EACpE,IAAI,CAAC,CAACK,EAAWiB,CAAK,IAAM,CAE5B,GAAIE,EAAQ,cAAe,CAC1B,MAAM4B,EAAS5B,EAAQ,cAAcnB,EAAWiB,EAAOtB,CAAI,EAC3D,GAAIoD,GAAW,KACd,MAAO,CACN,UAAW/C,EACX,MAAO+C,EAAO,OAAS/C,EACvB,UAAW+C,EAAO,WAAa,aAC/B,UAAWA,EAAO,WAAa,OAC/B,GAAGA,CAAA,CAGN,CAGA,MAAMC,EAAahC,EAAkBhB,EAAWiB,EAAOC,EAAaC,CAAO,EAG3E,OAAI0B,IAAgB7C,CAAS,EACrB,CAAE,GAAGgD,EAAY,GAAGH,EAAc7C,CAAS,CAAA,EAG5CgD,CACR,CAAC,EAEA,IAAI/B,GAAS,CACb,GAAI,CAACE,EAAQ,oBAAqB,CACjC,KAAM,CAAE,aAAA8B,EAAc,UAAAC,EAAW,GAAGC,GAAUlC,EAC9C,OAAOkC,CACR,CACA,OAAOlC,CACR,CAAC,EAEImC,EAAmC,CACxC,KAAM1D,EACN,KAAMf,EAAOe,CAAQ,EACrB,OAAQoD,CAAA,EAGHpE,EAAYiE,EAAgBjD,CAAQ,EACtChB,IACH0E,EAAQ,UAAY1E,GAGjByC,EAAQ,sBACXiC,EAAQ,iBAAmB1D,GAG5BkD,EAAS,KAAKQ,CAAO,CACtB,CAEA,OAAOR,CACR,CASA,SAASb,GAAmBF,EAA4C,CACvE,OAAI,OAAOA,GAAW,SAEdwB,EAAAA,YAAYxB,CAAM,EAInByB,EAAAA,kBAAkBzB,CAAM,CAChC"}
package/dist/index.cjs CHANGED
@@ -1 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-aeXXzPET.cjs");exports.ActionDefinition=e.ActionDefinition;exports.DoctypeMeta=e.DoctypeMeta;exports.FieldMeta=e.FieldMeta;exports.FieldOptions=e.FieldOptions;exports.FieldValidation=e.FieldValidation;exports.GQL_SCALAR_MAP=e.GQL_SCALAR_MAP;exports.INTERNAL_SCALARS=e.INTERNAL_SCALARS;exports.StonecropFieldType=e.StonecropFieldType;exports.TYPE_MAP=e.TYPE_MAP;exports.WELL_KNOWN_SCALARS=e.WELL_KNOWN_SCALARS;exports.WorkflowMeta=e.WorkflowMeta;exports.buildScalarMap=e.buildScalarMap;exports.camelToLabel=e.camelToLabel;exports.camelToSnake=e.camelToSnake;exports.classifyFieldType=e.classifyFieldType;exports.convertGraphQLSchema=e.convertGraphQLSchema;exports.defaultIsEntityField=e.defaultIsEntityField;exports.defaultIsEntityType=e.defaultIsEntityType;exports.getDefaultComponent=e.getDefaultComponent;exports.parseDoctype=e.parseDoctype;exports.parseField=e.parseField;exports.pascalToSnake=e.pascalToSnake;exports.snakeToCamel=e.snakeToCamel;exports.snakeToLabel=e.snakeToLabel;exports.toPascalCase=e.toPascalCase;exports.toSlug=e.toSlug;exports.validateDoctype=e.validateDoctype;exports.validateField=e.validateField;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -29,3 +29,4 @@ export {
29
29
  v as validateDoctype,
30
30
  I as validateField
31
31
  };
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/dist/naming.js ADDED
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Naming Convention Utilities
3
+ * Converts between various naming conventions (snake_case, camelCase, PascalCase, kebab-case)
4
+ * @packageDocumentation
5
+ */
6
+ /**
7
+ * Converts snake_case to camelCase
8
+ * @param snakeCase - Snake case string
9
+ * @returns Camel case string
10
+ * @public
11
+ * @example
12
+ * ```typescript
13
+ * snakeToCamel('user_email') // 'userEmail'
14
+ * snakeToCamel('created_at') // 'createdAt'
15
+ * ```
16
+ */
17
+ export function snakeToCamel(snakeCase) {
18
+ return snakeCase.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
19
+ }
20
+ /**
21
+ * Converts camelCase to snake_case
22
+ * @param camelCase - Camel case string
23
+ * @returns Snake case string
24
+ * @public
25
+ * @example
26
+ * ```typescript
27
+ * camelToSnake('userEmail') // 'user_email'
28
+ * camelToSnake('createdAt') // 'created_at'
29
+ * ```
30
+ */
31
+ export function camelToSnake(camelCase) {
32
+ return camelCase.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
33
+ }
34
+ /**
35
+ * Converts snake_case to Title Case label
36
+ * @param snakeCase - Snake case string
37
+ * @returns Title case label
38
+ * @public
39
+ * @example
40
+ * ```typescript
41
+ * snakeToLabel('user_email') // 'User Email'
42
+ * snakeToLabel('first_name') // 'First Name'
43
+ * ```
44
+ */
45
+ export function snakeToLabel(snakeCase) {
46
+ return snakeCase
47
+ .split('_')
48
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
49
+ .join(' ');
50
+ }
51
+ /**
52
+ * Converts camelCase to Title Case label
53
+ * @param camelCase - Camel case string
54
+ * @returns Title case label
55
+ * @public
56
+ * @example
57
+ * ```typescript
58
+ * camelToLabel('userEmail') // 'User Email'
59
+ * camelToLabel('firstName') // 'First Name'
60
+ * ```
61
+ */
62
+ export function camelToLabel(camelCase) {
63
+ const withSpaces = camelCase.replace(/([A-Z])/g, ' $1').trim();
64
+ return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1);
65
+ }
66
+ /**
67
+ * Convert table name to PascalCase doctype name
68
+ * @param tableName - SQL table name (snake_case)
69
+ * @returns PascalCase name
70
+ * @public
71
+ */
72
+ export function toPascalCase(tableName) {
73
+ return tableName
74
+ .split(/[-_\s]+/)
75
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
76
+ .join('');
77
+ }
78
+ /**
79
+ * Convert to kebab-case slug
80
+ * @param name - Name to convert
81
+ * @returns kebab-case slug
82
+ * @public
83
+ */
84
+ export function toSlug(name) {
85
+ return name
86
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
87
+ .replace(/[\s_]+/g, '-')
88
+ .toLowerCase();
89
+ }
90
+ /**
91
+ * Convert PascalCase to snake_case (e.g., for deriving table names from type names)
92
+ * @param pascal - PascalCase string
93
+ * @returns snake_case string
94
+ * @public
95
+ * @example
96
+ * ```typescript
97
+ * pascalToSnake('SalesOrder') // 'sales_order'
98
+ * pascalToSnake('SalesOrderItem') // 'sales_order_item'
99
+ * ```
100
+ */
101
+ export function pascalToSnake(pascal) {
102
+ return pascal
103
+ .replace(/([a-z])([A-Z])/g, '$1_$2')
104
+ .replace(/[\s-]+/g, '_')
105
+ .toLowerCase();
106
+ }
@@ -1,6 +1,6 @@
1
1
  import { GraphQLField } from 'graphql';
2
2
  import { GraphQLObjectType } from 'graphql';
3
- import { IntrospectionQuery } from 'graphql';
3
+ import type { IntrospectionQuery } from 'graphql';
4
4
  import { z } from 'zod';
5
5
 
6
6
  /**
@@ -42,7 +42,15 @@ export declare const ActionDefinition: z.ZodObject<{
42
42
  */
43
43
  export declare type ActionDefinition = z.infer<typeof ActionDefinition>;
44
44
 
45
- /* Excluded from this release type: buildScalarMap */
45
+ /**
46
+ * Build a merged scalar map from the built-in maps and user-provided custom scalars.
47
+ * Precedence (highest to lowest): customScalars → GQL_SCALAR_MAP → WELL_KNOWN_SCALARS
48
+ *
49
+ * @param customScalars - User-provided scalar overrides
50
+ * @returns Merged scalar map
51
+ * @internal
52
+ */
53
+ export declare function buildScalarMap(customScalars?: Record<string, Partial<FieldTemplate>>): Record<string, FieldTemplate>;
46
54
 
47
55
  /**
48
56
  * Converts camelCase to Title Case label
@@ -0,0 +1 @@
1
+ {"version":"5.9.3"}
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Stonecrop Schema CLI
4
+ *
5
+ * Converts GraphQL introspection results to Stonecrop doctype JSON schemas.
6
+ *
7
+ * Usage:
8
+ * stonecrop-schema generate --endpoint <url> --output <dir>
9
+ * stonecrop-schema generate --introspection <file.json> --output <dir>
10
+ * stonecrop-schema generate --sdl <file.graphql> --output <dir>
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG"}