@stonecrop/schema 0.8.7 → 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
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Default heuristics for identifying entity types and fields in a GraphQL schema.
3
+ *
4
+ * These heuristics work across common GraphQL servers (PostGraphile, Hasura, Apollo, etc.)
5
+ * by detecting widely-adopted conventions like the Relay connection pattern.
6
+ *
7
+ * All heuristics can be overridden via the `isEntityType`, `isEntityField`, and
8
+ * `classifyField` options in `GraphQLConversionOptions`.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import { type GraphQLObjectType, type GraphQLField } from 'graphql';
13
+ import type { GraphQLConversionFieldMeta, GraphQLConversionOptions } from './types';
14
+ /**
15
+ * Default heuristic to determine if a GraphQL object type represents an entity.
16
+ * An entity type becomes a Stonecrop doctype.
17
+ *
18
+ * This heuristic excludes:
19
+ * - Introspection types (`__*`)
20
+ * - Root operation types (`Query`, `Mutation`, `Subscription`)
21
+ * - Types with synthetic suffixes (e.g., `*Connection`, `*Edge`, `*Input`)
22
+ * - Types starting with `Node` interface marker (exact match only)
23
+ *
24
+ * @param typeName - The GraphQL type name
25
+ * @param type - The GraphQL object type definition
26
+ * @returns `true` if this type should become a Stonecrop doctype
27
+ * @public
28
+ */
29
+ export declare function defaultIsEntityType(typeName: string, type: GraphQLObjectType): boolean;
30
+ /**
31
+ * Default heuristic to filter fields on entity types.
32
+ * Skips internal fields that don't represent meaningful data.
33
+ *
34
+ * @param fieldName - The GraphQL field name
35
+ * @param _field - The GraphQL field definition (unused in default implementation)
36
+ * @param _parentType - The parent entity type (unused in default implementation)
37
+ * @returns `true` if this field should be included
38
+ * @public
39
+ */
40
+ export declare function defaultIsEntityField(fieldName: string, _field: GraphQLField<unknown, unknown>, _parentType: GraphQLObjectType): boolean;
41
+ /**
42
+ * Classify a single GraphQL field into a Stonecrop field definition.
43
+ *
44
+ * Classification rules (in order):
45
+ * 1. Scalar types → look up in merged scalar map
46
+ * 2. Enum types → `Select` with enum values as options
47
+ * 3. Object types that are entities → `Link` with slug as options
48
+ * 4. Object types that are Connections → `Doctype` with node type slug as options
49
+ * 5. List of entity type → `Doctype` with item type slug as options
50
+ * 6. Anything else → `Data` with `_unmapped: true`
51
+ *
52
+ * @param fieldName - The GraphQL field name
53
+ * @param field - The GraphQL field definition
54
+ * @param entityTypes - Set of type names classified as entities
55
+ * @param options - Conversion options (for custom scalars, unmapped meta, etc.)
56
+ * @returns The Stonecrop field definition
57
+ * @public
58
+ */
59
+ export declare function classifyFieldType(fieldName: string, field: GraphQLField<unknown, unknown>, entityTypes: Set<string>, options?: GraphQLConversionOptions): GraphQLConversionFieldMeta;
60
+ //# sourceMappingURL=heuristics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heuristics.d.ts","sourceRoot":"","sources":["../../../src/converter/heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAMN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AA+BnF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CA8BtF;AAQD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACtC,WAAW,EAAE,iBAAiB,GAC5B,OAAO,CAET;AAsED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,OAAO,GAAE,wBAA6B,GACpC,0BAA0B,CAyF5B"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * GraphQL Introspection to Stonecrop Schema Converter
3
+ *
4
+ * Converts a standard GraphQL introspection result (or SDL string) into
5
+ * Stonecrop doctype schemas. Source-agnostic — works with any GraphQL server.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { IntrospectionSource, GraphQLConversionOptions, ConvertedGraphQLDoctype } from './types';
10
+ /**
11
+ * Convert a GraphQL schema to Stonecrop doctype schemas.
12
+ *
13
+ * Accepts either an `IntrospectionQuery` result object or an SDL string.
14
+ * Entity types are identified using heuristics (or a custom `isEntityType` function)
15
+ * and converted to `DoctypeMeta`-compatible JSON objects.
16
+ *
17
+ * @param source - GraphQL introspection result or SDL string
18
+ * @param options - Conversion options for controlling output format and behavior
19
+ * @returns Array of converted Stonecrop doctype definitions
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // From introspection result (fetched from any GraphQL server)
24
+ * const introspection = await fetchIntrospection('http://localhost:5000/graphql')
25
+ * const doctypes = convertGraphQLSchema(introspection)
26
+ *
27
+ * // From SDL string
28
+ * const sdl = fs.readFileSync('schema.graphql', 'utf-8')
29
+ * const doctypes = convertGraphQLSchema(sdl)
30
+ *
31
+ * // With PostGraphile custom scalars
32
+ * const doctypes = convertGraphQLSchema(introspection, {
33
+ * customScalars: {
34
+ * BigFloat: { component: 'ADecimalInput', fieldtype: 'Decimal' }
35
+ * }
36
+ * })
37
+ * ```
38
+ *
39
+ * @public
40
+ */
41
+ export declare function convertGraphQLSchema(source: IntrospectionSource, options?: GraphQLConversionOptions): ConvertedGraphQLDoctype[];
42
+ export { convertGraphQLSchema as default };
43
+ export type { IntrospectionSource, GraphQLConversionOptions, GraphQLConversionFieldMeta, ConvertedGraphQLDoctype, } from './types';
44
+ export { GQL_SCALAR_MAP, WELL_KNOWN_SCALARS, INTERNAL_SCALARS, buildScalarMap } from './scalars';
45
+ export { defaultIsEntityType, defaultIsEntityField, classifyFieldType } from './heuristics';
46
+ export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from '../naming';
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAGrG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,GAAE,wBAA6B,GACpC,uBAAuB,EAAE,CA8G3B;AAwBD,OAAO,EAAE,oBAAoB,IAAI,OAAO,EAAE,CAAA;AAG1C,YAAY,EACX,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,GACvB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAGhG,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAG3F,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * GraphQL Scalar Type Mappings
3
+ *
4
+ * Maps standard GraphQL scalars and well-known custom scalars to Stonecrop field types.
5
+ * Source-agnostic — covers scalars commonly emitted by PostGraphile, Hasura, Apollo, etc.
6
+ *
7
+ * Users can extend these via the `customScalars` option in `GraphQLConversionOptions`.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import type { FieldTemplate } from '../fieldtype';
12
+ /**
13
+ * Mapping from standard GraphQL scalar types to Stonecrop field types.
14
+ * These are defined by the GraphQL specification and are always available.
15
+ *
16
+ * @public
17
+ */
18
+ export declare const GQL_SCALAR_MAP: Record<string, FieldTemplate>;
19
+ /**
20
+ * Mapping from well-known custom GraphQL scalars to Stonecrop field types.
21
+ * These cover scalars commonly used across GraphQL servers (PostGraphile, Hasura, etc.)
22
+ * without baking in knowledge of any specific server.
23
+ *
24
+ * Entries here have lower precedence than `customScalars` from options, but higher
25
+ * precedence than unknown/unmapped scalars.
26
+ *
27
+ * @public
28
+ */
29
+ export declare const WELL_KNOWN_SCALARS: Record<string, FieldTemplate>;
30
+ /**
31
+ * Set of scalar type names that are internal to GraphQL servers and should be skipped
32
+ * during field conversion (they don't represent meaningful data fields).
33
+ *
34
+ * @public
35
+ */
36
+ export declare const INTERNAL_SCALARS: Set<string>;
37
+ /**
38
+ * Build a merged scalar map from the built-in maps and user-provided custom scalars.
39
+ * Precedence (highest to lowest): customScalars → GQL_SCALAR_MAP → WELL_KNOWN_SCALARS
40
+ *
41
+ * @param customScalars - User-provided scalar overrides
42
+ * @returns Merged scalar map
43
+ * @internal
44
+ */
45
+ export declare function buildScalarMap(customScalars?: Record<string, Partial<FieldTemplate>>): Record<string, FieldTemplate>;
46
+ //# sourceMappingURL=scalars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalars.d.ts","sourceRoot":"","sources":["../../../src/converter/scalars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAMxD,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAuB5D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAsB,CAAA;AAEnD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAmBpH"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Types for the GraphQL introspection to Stonecrop schema converter.
3
+ * Source-agnostic — works with any GraphQL server (PostGraphile, Hasura, Apollo, etc.)
4
+ * @packageDocumentation
5
+ */
6
+ import type { IntrospectionQuery } from 'graphql';
7
+ import type { GraphQLObjectType, GraphQLField } from 'graphql';
8
+ import type { FieldMeta } from '../field';
9
+ import type { FieldTemplate } from '../fieldtype';
10
+ /**
11
+ * Input source for the GraphQL schema converter.
12
+ * Accepts either a standard GraphQL introspection result or an SDL string.
13
+ *
14
+ * - `IntrospectionQuery`: The raw result of a GraphQL introspection query (from any server)
15
+ * - `string`: An SDL (Schema Definition Language) string
16
+ *
17
+ * Note: URL fetching is intentionally not supported in the library API.
18
+ * Use the CLI (`stonecrop-schema generate --endpoint <url>`) for endpoint fetching,
19
+ * or fetch the introspection result yourself and pass it in.
20
+ *
21
+ * @public
22
+ */
23
+ export type IntrospectionSource = IntrospectionQuery | string;
24
+ /**
25
+ * Options for converting a GraphQL schema to Stonecrop doctype schemas.
26
+ * All hooks are optional — sensible defaults are provided for common GraphQL patterns.
27
+ *
28
+ * @public
29
+ */
30
+ export interface GraphQLConversionOptions {
31
+ /**
32
+ * GraphQL type names to exclude from conversion.
33
+ * Applied after `isEntityType` filtering.
34
+ */
35
+ exclude?: string[];
36
+ /**
37
+ * Whitelist of GraphQL type names to convert.
38
+ * When provided, only these types are considered (after `isEntityType` filtering).
39
+ */
40
+ include?: string[];
41
+ /**
42
+ * Per-type, per-field overrides for the converted field definitions.
43
+ * Outer key is the GraphQL type name, inner key is the field name.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * {
48
+ * SalesOrder: {
49
+ * totalAmount: { fieldtype: 'Currency', component: 'ACurrencyInput' }
50
+ * }
51
+ * }
52
+ * ```
53
+ */
54
+ typeOverrides?: Record<string, Record<string, Partial<FieldMeta>>>;
55
+ /**
56
+ * Map custom or non-standard GraphQL scalar types to Stonecrop field types.
57
+ * Merged with the built-in scalar maps (GQL_SCALAR_MAP + WELL_KNOWN_SCALARS).
58
+ * User-provided entries take highest precedence.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * {
63
+ * MyCustomMoney: { component: 'ACurrencyInput', fieldtype: 'Currency' },
64
+ * PostGISPoint: { component: 'ATextInput', fieldtype: 'Data' }
65
+ * }
66
+ * ```
67
+ */
68
+ customScalars?: Record<string, Partial<FieldTemplate>>;
69
+ /**
70
+ * Custom function to determine if a GraphQL object type represents an entity (→ doctype).
71
+ * When provided, replaces the default heuristic entirely.
72
+ *
73
+ * The default heuristic excludes types matching synthetic patterns:
74
+ * `*Connection`, `*Edge`, `*Input`, `*Patch`, `*Payload`, `*Condition`,
75
+ * `*Filter`, `*OrderBy`, `*Aggregate`, `Query`, `Mutation`, `Subscription`, `__*`.
76
+ *
77
+ * @param typeName - The GraphQL type name
78
+ * @param type - The full GraphQL object type definition
79
+ * @returns `true` if this type should become a Stonecrop doctype
80
+ */
81
+ isEntityType?: (typeName: string, type: GraphQLObjectType) => boolean;
82
+ /**
83
+ * Custom function to filter which fields on an entity type are included.
84
+ * When provided, replaces the default field filter.
85
+ *
86
+ * The default filter excludes `nodeId`, `__typename`, and `clientMutationId`.
87
+ *
88
+ * @param fieldName - The GraphQL field name
89
+ * @param field - The full GraphQL field definition
90
+ * @param parentType - The parent entity type
91
+ * @returns `true` if this field should be included
92
+ */
93
+ isEntityField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => boolean;
94
+ /**
95
+ * Escape hatch: fully override the classification of a specific field.
96
+ * When this returns a non-null value, it is used as the field definition
97
+ * (merged with the field name). Return `null` to fall through to default classification.
98
+ *
99
+ * @param fieldName - The GraphQL field name
100
+ * @param field - The full GraphQL field definition
101
+ * @param parentType - The parent entity type
102
+ * @returns Partial field meta to use, or `null` for default behavior
103
+ */
104
+ classifyField?: (fieldName: string, field: GraphQLField<unknown, unknown>, parentType: GraphQLObjectType) => Partial<FieldMeta> | null;
105
+ /**
106
+ * Custom function to derive the database table name from a GraphQL type name.
107
+ * The default converts PascalCase to snake_case (e.g., `SalesOrder` → `sales_order`).
108
+ *
109
+ * Return `undefined` to omit `tableName` from the output.
110
+ *
111
+ * @param typeName - The GraphQL type name
112
+ * @returns The derived table name, or `undefined`
113
+ */
114
+ deriveTableName?: (typeName: string) => string | undefined;
115
+ /**
116
+ * Include `_graphqlType` and `_unmapped` metadata on converted fields.
117
+ * Useful for debugging conversions. Defaults to `false`.
118
+ */
119
+ includeUnmappedMeta?: boolean;
120
+ }
121
+ /**
122
+ * Extended field metadata with optional GraphQL conversion metadata.
123
+ * Only present when `includeUnmappedMeta` is enabled.
124
+ *
125
+ * @public
126
+ */
127
+ export interface GraphQLConversionFieldMeta extends FieldMeta {
128
+ /** Original GraphQL type name (for debugging/reference) */
129
+ _graphqlType?: string;
130
+ /** Marks fields that couldn't be automatically mapped */
131
+ _unmapped?: boolean;
132
+ }
133
+ /**
134
+ * Output of GraphQL schema conversion — one per entity type.
135
+ *
136
+ * @public
137
+ */
138
+ export interface ConvertedGraphQLDoctype extends Omit<DoctypeMeta, 'fields'> {
139
+ /** Field definitions with optional GraphQL conversion metadata */
140
+ fields: GraphQLConversionFieldMeta[];
141
+ /** Original GraphQL type name (for debugging/reference) */
142
+ _graphqlTypeName?: string;
143
+ }
144
+ import type { DoctypeMeta } from '../doctype';
145
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/converter/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,MAAM,CAAA;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAElE;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;IAEtD;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAA;IAErE;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAA;IAEpH;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CACf,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACrC,UAAU,EAAE,iBAAiB,KACzB,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;IAE9B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;IAE1D;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC3E,kEAAkE;IAClE,MAAM,EAAE,0BAA0B,EAAE,CAAA;IACpC,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAGD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,312 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Action definition within a workflow
4
+ * @public
5
+ */
6
+ export declare const ActionDefinition: z.ZodObject<{
7
+ /** Display label for the action */
8
+ label: z.ZodString;
9
+ /** Handler function name or path */
10
+ handler: z.ZodString;
11
+ /** Fields that must have values before action can execute */
12
+ requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
+ /** Workflow states where this action is available */
14
+ allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
+ /** Whether to show a confirmation dialog */
16
+ confirm: z.ZodOptional<z.ZodBoolean>;
17
+ /** Additional arguments for the action */
18
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ label: string;
21
+ handler: string;
22
+ requiredFields?: string[] | undefined;
23
+ allowedStates?: string[] | undefined;
24
+ confirm?: boolean | undefined;
25
+ args?: Record<string, unknown> | undefined;
26
+ }, {
27
+ label: string;
28
+ handler: string;
29
+ requiredFields?: string[] | undefined;
30
+ allowedStates?: string[] | undefined;
31
+ confirm?: boolean | undefined;
32
+ args?: Record<string, unknown> | undefined;
33
+ }>;
34
+ /**
35
+ * Action definition type inferred from Zod schema
36
+ * @public
37
+ */
38
+ export type ActionDefinition = z.infer<typeof ActionDefinition>;
39
+ /**
40
+ * Workflow metadata - states and actions for a doctype
41
+ * @public
42
+ */
43
+ export declare const WorkflowMeta: z.ZodObject<{
44
+ /** List of workflow states */
45
+ states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
46
+ /** Actions available in this workflow */
47
+ actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
48
+ /** Display label for the action */
49
+ label: z.ZodString;
50
+ /** Handler function name or path */
51
+ handler: z.ZodString;
52
+ /** Fields that must have values before action can execute */
53
+ requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
54
+ /** Workflow states where this action is available */
55
+ allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
56
+ /** Whether to show a confirmation dialog */
57
+ confirm: z.ZodOptional<z.ZodBoolean>;
58
+ /** Additional arguments for the action */
59
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ label: string;
62
+ handler: string;
63
+ requiredFields?: string[] | undefined;
64
+ allowedStates?: string[] | undefined;
65
+ confirm?: boolean | undefined;
66
+ args?: Record<string, unknown> | undefined;
67
+ }, {
68
+ label: string;
69
+ handler: string;
70
+ requiredFields?: string[] | undefined;
71
+ allowedStates?: string[] | undefined;
72
+ confirm?: boolean | undefined;
73
+ args?: Record<string, unknown> | undefined;
74
+ }>>>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ states?: string[] | undefined;
77
+ actions?: Record<string, {
78
+ label: string;
79
+ handler: string;
80
+ requiredFields?: string[] | undefined;
81
+ allowedStates?: string[] | undefined;
82
+ confirm?: boolean | undefined;
83
+ args?: Record<string, unknown> | undefined;
84
+ }> | undefined;
85
+ }, {
86
+ states?: string[] | undefined;
87
+ actions?: Record<string, {
88
+ label: string;
89
+ handler: string;
90
+ requiredFields?: string[] | undefined;
91
+ allowedStates?: string[] | undefined;
92
+ confirm?: boolean | undefined;
93
+ args?: Record<string, unknown> | undefined;
94
+ }> | undefined;
95
+ }>;
96
+ /**
97
+ * Workflow metadata type inferred from Zod schema
98
+ * @public
99
+ */
100
+ export type WorkflowMeta = z.infer<typeof WorkflowMeta>;
101
+ /**
102
+ * Doctype metadata - complete definition of a doctype
103
+ * @public
104
+ */
105
+ export declare const DoctypeMeta: z.ZodObject<{
106
+ /** Display name of the doctype */
107
+ name: z.ZodString;
108
+ /** URL-friendly slug (kebab-case) */
109
+ slug: z.ZodOptional<z.ZodString>;
110
+ /** Database table name */
111
+ tableName: z.ZodOptional<z.ZodString>;
112
+ /** Field definitions */
113
+ fields: z.ZodArray<z.ZodObject<{
114
+ fieldname: z.ZodString;
115
+ fieldtype: z.ZodEnum<["Data", "Text", "Int", "Float", "Decimal", "Check", "Date", "Time", "Datetime", "Duration", "DateRange", "JSON", "Code", "Link", "Doctype", "Attach", "Currency", "Quantity", "Select"]>;
116
+ component: z.ZodOptional<z.ZodString>;
117
+ label: z.ZodOptional<z.ZodString>;
118
+ width: z.ZodOptional<z.ZodString>;
119
+ align: z.ZodOptional<z.ZodEnum<["left", "center", "right", "start", "end"]>>;
120
+ required: z.ZodOptional<z.ZodBoolean>;
121
+ readOnly: z.ZodOptional<z.ZodBoolean>;
122
+ edit: z.ZodOptional<z.ZodBoolean>;
123
+ hidden: z.ZodOptional<z.ZodBoolean>;
124
+ value: z.ZodOptional<z.ZodUnknown>;
125
+ default: z.ZodOptional<z.ZodUnknown>;
126
+ options: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
127
+ mask: z.ZodOptional<z.ZodString>;
128
+ validation: z.ZodOptional<z.ZodObject<{
129
+ errorMessage: z.ZodString;
130
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
131
+ errorMessage: z.ZodString;
132
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
133
+ errorMessage: z.ZodString;
134
+ }, z.ZodTypeAny, "passthrough">>>;
135
+ }, "strip", z.ZodTypeAny, {
136
+ fieldname: string;
137
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
138
+ value?: unknown;
139
+ options?: string | string[] | Record<string, unknown> | undefined;
140
+ validation?: z.objectOutputType<{
141
+ errorMessage: z.ZodString;
142
+ }, z.ZodTypeAny, "passthrough"> | undefined;
143
+ component?: string | undefined;
144
+ label?: string | undefined;
145
+ width?: string | undefined;
146
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
147
+ required?: boolean | undefined;
148
+ readOnly?: boolean | undefined;
149
+ edit?: boolean | undefined;
150
+ hidden?: boolean | undefined;
151
+ default?: unknown;
152
+ mask?: string | undefined;
153
+ }, {
154
+ fieldname: string;
155
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
156
+ value?: unknown;
157
+ options?: string | string[] | Record<string, unknown> | undefined;
158
+ validation?: z.objectInputType<{
159
+ errorMessage: z.ZodString;
160
+ }, z.ZodTypeAny, "passthrough"> | undefined;
161
+ component?: string | undefined;
162
+ label?: string | undefined;
163
+ width?: string | undefined;
164
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
165
+ required?: boolean | undefined;
166
+ readOnly?: boolean | undefined;
167
+ edit?: boolean | undefined;
168
+ hidden?: boolean | undefined;
169
+ default?: unknown;
170
+ mask?: string | undefined;
171
+ }>, "many">;
172
+ /** Workflow configuration */
173
+ workflow: z.ZodOptional<z.ZodObject<{
174
+ /** List of workflow states */
175
+ states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
176
+ /** Actions available in this workflow */
177
+ actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
178
+ /** Display label for the action */
179
+ label: z.ZodString;
180
+ /** Handler function name or path */
181
+ handler: z.ZodString;
182
+ /** Fields that must have values before action can execute */
183
+ requiredFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
184
+ /** Workflow states where this action is available */
185
+ allowedStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
186
+ /** Whether to show a confirmation dialog */
187
+ confirm: z.ZodOptional<z.ZodBoolean>;
188
+ /** Additional arguments for the action */
189
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
190
+ }, "strip", z.ZodTypeAny, {
191
+ label: string;
192
+ handler: string;
193
+ requiredFields?: string[] | undefined;
194
+ allowedStates?: string[] | undefined;
195
+ confirm?: boolean | undefined;
196
+ args?: Record<string, unknown> | undefined;
197
+ }, {
198
+ label: string;
199
+ handler: string;
200
+ requiredFields?: string[] | undefined;
201
+ allowedStates?: string[] | undefined;
202
+ confirm?: boolean | undefined;
203
+ args?: Record<string, unknown> | undefined;
204
+ }>>>;
205
+ }, "strip", z.ZodTypeAny, {
206
+ states?: string[] | undefined;
207
+ actions?: Record<string, {
208
+ label: string;
209
+ handler: string;
210
+ requiredFields?: string[] | undefined;
211
+ allowedStates?: string[] | undefined;
212
+ confirm?: boolean | undefined;
213
+ args?: Record<string, unknown> | undefined;
214
+ }> | undefined;
215
+ }, {
216
+ states?: string[] | undefined;
217
+ actions?: Record<string, {
218
+ label: string;
219
+ handler: string;
220
+ requiredFields?: string[] | undefined;
221
+ allowedStates?: string[] | undefined;
222
+ confirm?: boolean | undefined;
223
+ args?: Record<string, unknown> | undefined;
224
+ }> | undefined;
225
+ }>>;
226
+ /** Parent doctype for inheritance */
227
+ inherits: z.ZodOptional<z.ZodString>;
228
+ /** Doctype to use for list views */
229
+ listDoctype: z.ZodOptional<z.ZodString>;
230
+ /** Parent doctype for child tables */
231
+ parentDoctype: z.ZodOptional<z.ZodString>;
232
+ }, "strip", z.ZodTypeAny, {
233
+ name: string;
234
+ fields: {
235
+ fieldname: string;
236
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
237
+ value?: unknown;
238
+ options?: string | string[] | Record<string, unknown> | undefined;
239
+ validation?: z.objectOutputType<{
240
+ errorMessage: z.ZodString;
241
+ }, z.ZodTypeAny, "passthrough"> | undefined;
242
+ component?: string | undefined;
243
+ label?: string | undefined;
244
+ width?: string | undefined;
245
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
246
+ required?: boolean | undefined;
247
+ readOnly?: boolean | undefined;
248
+ edit?: boolean | undefined;
249
+ hidden?: boolean | undefined;
250
+ default?: unknown;
251
+ mask?: string | undefined;
252
+ }[];
253
+ slug?: string | undefined;
254
+ tableName?: string | undefined;
255
+ workflow?: {
256
+ states?: string[] | undefined;
257
+ actions?: Record<string, {
258
+ label: string;
259
+ handler: string;
260
+ requiredFields?: string[] | undefined;
261
+ allowedStates?: string[] | undefined;
262
+ confirm?: boolean | undefined;
263
+ args?: Record<string, unknown> | undefined;
264
+ }> | undefined;
265
+ } | undefined;
266
+ inherits?: string | undefined;
267
+ listDoctype?: string | undefined;
268
+ parentDoctype?: string | undefined;
269
+ }, {
270
+ name: string;
271
+ fields: {
272
+ fieldname: string;
273
+ fieldtype: "Data" | "Text" | "Int" | "Float" | "Decimal" | "Check" | "Date" | "Time" | "Datetime" | "Duration" | "DateRange" | "JSON" | "Code" | "Link" | "Doctype" | "Attach" | "Currency" | "Quantity" | "Select";
274
+ value?: unknown;
275
+ options?: string | string[] | Record<string, unknown> | undefined;
276
+ validation?: z.objectInputType<{
277
+ errorMessage: z.ZodString;
278
+ }, z.ZodTypeAny, "passthrough"> | undefined;
279
+ component?: string | undefined;
280
+ label?: string | undefined;
281
+ width?: string | undefined;
282
+ align?: "left" | "center" | "right" | "start" | "end" | undefined;
283
+ required?: boolean | undefined;
284
+ readOnly?: boolean | undefined;
285
+ edit?: boolean | undefined;
286
+ hidden?: boolean | undefined;
287
+ default?: unknown;
288
+ mask?: string | undefined;
289
+ }[];
290
+ slug?: string | undefined;
291
+ tableName?: string | undefined;
292
+ workflow?: {
293
+ states?: string[] | undefined;
294
+ actions?: Record<string, {
295
+ label: string;
296
+ handler: string;
297
+ requiredFields?: string[] | undefined;
298
+ allowedStates?: string[] | undefined;
299
+ confirm?: boolean | undefined;
300
+ args?: Record<string, unknown> | undefined;
301
+ }> | undefined;
302
+ } | undefined;
303
+ inherits?: string | undefined;
304
+ listDoctype?: string | undefined;
305
+ parentDoctype?: string | undefined;
306
+ }>;
307
+ /**
308
+ * Doctype metadata type inferred from Zod schema
309
+ * @public
310
+ */
311
+ export type DoctypeMeta = z.infer<typeof DoctypeMeta>;
312
+ //# sourceMappingURL=doctype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IAC5B,mCAAmC;;IAGnC,oCAAoC;;IAGpC,6DAA6D;;IAG7D,qDAAqD;;IAGrD,4CAA4C;;IAG5C,0CAA0C;;;;;;;;;;;;;;;;EAEzC,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,YAAY;IACxB,8BAA8B;;IAG9B,yCAAyC;;QAjCzC,mCAAmC;;QAGnC,oCAAoC;;QAGpC,6DAA6D;;QAG7D,qDAAqD;;QAGrD,4CAA4C;;QAG5C,0CAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBzC,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,WAAW;IACvB,kCAAkC;;IAGlC,qCAAqC;;IAGrC,0BAA0B;;IAG1B,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGxB,6BAA6B;;QA9B7B,8BAA8B;;QAG9B,yCAAyC;;YAjCzC,mCAAmC;;YAGnC,oCAAoC;;YAGpC,6DAA6D;;YAG7D,qDAAqD;;YAGrD,4CAA4C;;YAG5C,0CAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgD1C,qCAAqC;;IAGrC,oCAAoC;;IAGpC,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAErC,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA"}