@stonecrop/schema 0.11.9 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -430,7 +430,7 @@ This package provides the type system used throughout Stonecrop:
430
430
  - **`@stonecrop/stonecrop`** - Registry uses `DoctypeMeta` for schema storage; `getDescendantLinks()` / `getAncestorLinks()` for relationship traversal
431
431
  - **`@stonecrop/graphql-client`** - `StonecropClient` implements `DataClient`; uses `GetRecordOptions` / `GetRecordsOptions` for fetch parameters
432
432
  - **`@stonecrop/aform`** - Renders fields based on `FieldMeta` definitions
433
- - **`@stonecrop/atable`** - Uses `FieldMeta` for column configuration
433
+ - **`@stonecrop/atable`** - Uses `ColumnSchema` for schema-driven column derivation; `TableColumn` (ATable's runtime column type) extends `ColumnSchema`, widening `format`/`modalComponent` to accept live functions and adding `mask`/`originalIndex`
434
434
  - **Backend APIs** - Validates and stores doctypes using these schemas
435
435
 
436
436
  ## Development
package/dist/schema.d.ts CHANGED
@@ -109,6 +109,154 @@ export declare type Cardinality = z.infer<typeof Cardinality>;
109
109
  */
110
110
  export declare function classifyFieldType(fieldName: string, field: GraphQLField<unknown, unknown>, entityTypes: Set<string>, options?: GraphQLConversionOptions): GraphQLConversionFieldMeta;
111
111
 
112
+ /**
113
+ * Authoring contract for doctype field declarations that can be rendered as table columns.
114
+ * Pass a `ColumnSchema[]` array to ATable's `:schema` prop; `schemaToColumns` converts it
115
+ * to `TableColumn[]` internally — callers working from a doctype schema never need to
116
+ * construct `TableColumn` directly.
117
+ *
118
+ * Notes on specific properties:
119
+ * - `align` uses an explicit string union rather than `CanvasTextAlign` — this package is
120
+ * used server-side by the CLI where browser DOM types are absent. The values are identical.
121
+ * - `format` is a serialized function string; the table store's `getFormattedValue` deserializes
122
+ * it via `Function(...)`. `TableColumn.format` widens this to also accept a live function.
123
+ * - `mask` is absent — it is function-typed only and cannot be serialized to JSON. It lives
124
+ * exclusively on `TableColumn`.
125
+ * - `modalComponent` is string-only — functions cannot appear in schema JSON. `TableColumn`
126
+ * widens this to also accept a factory function.
127
+ *
128
+ * @public
129
+ */
130
+ export declare interface ColumnSchema {
131
+ /** Unique identifier for the field within its doctype. Maps to `name` on `TableColumn`. */
132
+ fieldname: string;
133
+ /**
134
+ * Semantic field type (e.g. `'Data'`, `'Int'`, `'Date'`, `'Check'`). Fields without a
135
+ * `fieldtype` are treated as non-scalar (nested table or fieldset) and excluded by
136
+ * `schemaToColumns`.
137
+ */
138
+ fieldtype?: string;
139
+ /**
140
+ * Human-readable column header. When absent, ATable assigns labels alphabetically
141
+ * (A, B, C, …).
142
+ */
143
+ label?: string;
144
+ /** When `true`, the field is excluded from the derived columns by `schemaToColumns`. */
145
+ hidden?: boolean;
146
+ /**
147
+ * Horizontal text alignment for the column cell and header.
148
+ *
149
+ * @defaultValue 'left'
150
+ */
151
+ align?: 'left' | 'right' | 'center' | 'start' | 'end';
152
+ /**
153
+ * Whether the column cell is editable in the table.
154
+ *
155
+ * @defaultValue false
156
+ */
157
+ edit?: boolean;
158
+ /**
159
+ * CSS width of the column (e.g. `'20ch'`, `'200px'`).
160
+ *
161
+ * @defaultValue '40ch'
162
+ */
163
+ width?: string;
164
+ /**
165
+ * When `true`, the column is pinned to the left side of the table.
166
+ *
167
+ * @defaultValue false
168
+ */
169
+ pinned?: boolean;
170
+ /**
171
+ * When `true`, the column can be resized by dragging the header edge.
172
+ *
173
+ * @defaultValue false
174
+ */
175
+ resizable?: boolean;
176
+ /**
177
+ * When `true`, clicking the column header sorts the table by this column.
178
+ *
179
+ * @defaultValue true
180
+ */
181
+ sortable?: boolean;
182
+ /**
183
+ * When `true`, a filter control is rendered in the column header.
184
+ *
185
+ * @defaultValue true
186
+ */
187
+ filterable?: boolean;
188
+ /**
189
+ * The type of filter control to render. When absent, a default is derived from `fieldtype`
190
+ * (`Check` → `checkbox`, `Date` → `date`, `Datetime` → `dateRange`, `Select` → `select`,
191
+ * numeric types → `number`, everything else → `text`).
192
+ */
193
+ filterType?: 'text' | 'select' | 'number' | 'date' | 'dateRange' | 'checkbox' | 'component';
194
+ /**
195
+ * Static option list for `filterType: 'select'`. When absent, options are derived from
196
+ * the unique values present in the column's rows.
197
+ */
198
+ filterOptions?: any[];
199
+ /** Registered component name used when `filterType` is `'component'`. */
200
+ filterComponent?: string;
201
+ /**
202
+ * Registered component name rendered inside the table cell instead of the default display.
203
+ * When absent, the table renders the value as plain text in a `<td>`.
204
+ */
205
+ cellComponent?: string;
206
+ /**
207
+ * Additional props passed to `cellComponent`.
208
+ *
209
+ * Only applicable when `cellComponent` is set.
210
+ */
211
+ cellComponentProps?: Record<string, any>;
212
+ /**
213
+ * Registered component name rendered in the cell's modal editor. String-only — functions
214
+ * cannot appear in schema JSON. `TableColumn.modalComponent` widens this to also accept a
215
+ * factory function.
216
+ *
217
+ * The following props are automatically passed to the modal component:
218
+ * - `colIndex` — the column index of the current cell
219
+ * - `rowIndex` — the row index of the current cell
220
+ * - `store` — the table data store
221
+ */
222
+ modalComponent?: string;
223
+ /**
224
+ * Extra props passed to `modalComponent` in addition to the standard cell props.
225
+ *
226
+ * Only applicable when `modalComponent` is set.
227
+ */
228
+ modalComponentExtraProps?: Record<string, any>;
229
+ /**
230
+ * Serialized function string used to format the cell value for display. Deserialized at
231
+ * render time by the table store's `getFormattedValue`. `TableColumn.format` widens this
232
+ * to also accept a live function directly.
233
+ */
234
+ format?: string;
235
+ /**
236
+ * When `true`, this column is treated as a Gantt bar column.
237
+ *
238
+ * Only applicable for Gantt tables.
239
+ *
240
+ * @defaultValue false
241
+ */
242
+ isGantt?: boolean;
243
+ /**
244
+ * Registered component name used to render Gantt bars in this column.
245
+ *
246
+ * Only applicable for Gantt tables.
247
+ *
248
+ * @defaultValue 'AGanttCell'
249
+ */
250
+ ganttComponent?: string;
251
+ /**
252
+ * Number of columns this Gantt bar spans across. When absent, the bar stretches to cover
253
+ * all non-pinned columns in the table.
254
+ *
255
+ * Only applicable for Gantt tables.
256
+ */
257
+ colspan?: number;
258
+ }
259
+
112
260
  /**
113
261
  * Output of GraphQL schema conversion — one per entity type.
114
262
  *
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Authoring contract for doctype field declarations that can be rendered as table columns.
3
+ * Pass a `ColumnSchema[]` array to ATable's `:schema` prop; `schemaToColumns` converts it
4
+ * to `TableColumn[]` internally — callers working from a doctype schema never need to
5
+ * construct `TableColumn` directly.
6
+ *
7
+ * Notes on specific properties:
8
+ * - `align` uses an explicit string union rather than `CanvasTextAlign` — this package is
9
+ * used server-side by the CLI where browser DOM types are absent. The values are identical.
10
+ * - `format` is a serialized function string; the table store's `getFormattedValue` deserializes
11
+ * it via `Function(...)`. `TableColumn.format` widens this to also accept a live function.
12
+ * - `mask` is absent — it is function-typed only and cannot be serialized to JSON. It lives
13
+ * exclusively on `TableColumn`.
14
+ * - `modalComponent` is string-only — functions cannot appear in schema JSON. `TableColumn`
15
+ * widens this to also accept a factory function.
16
+ *
17
+ * @public
18
+ */
19
+ export interface ColumnSchema {
20
+ /** Unique identifier for the field within its doctype. Maps to `name` on `TableColumn`. */
21
+ fieldname: string;
22
+ /**
23
+ * Semantic field type (e.g. `'Data'`, `'Int'`, `'Date'`, `'Check'`). Fields without a
24
+ * `fieldtype` are treated as non-scalar (nested table or fieldset) and excluded by
25
+ * `schemaToColumns`.
26
+ */
27
+ fieldtype?: string;
28
+ /**
29
+ * Human-readable column header. When absent, ATable assigns labels alphabetically
30
+ * (A, B, C, …).
31
+ */
32
+ label?: string;
33
+ /** When `true`, the field is excluded from the derived columns by `schemaToColumns`. */
34
+ hidden?: boolean;
35
+ /**
36
+ * Horizontal text alignment for the column cell and header.
37
+ *
38
+ * @defaultValue 'left'
39
+ */
40
+ align?: 'left' | 'right' | 'center' | 'start' | 'end';
41
+ /**
42
+ * Whether the column cell is editable in the table.
43
+ *
44
+ * @defaultValue false
45
+ */
46
+ edit?: boolean;
47
+ /**
48
+ * CSS width of the column (e.g. `'20ch'`, `'200px'`).
49
+ *
50
+ * @defaultValue '40ch'
51
+ */
52
+ width?: string;
53
+ /**
54
+ * When `true`, the column is pinned to the left side of the table.
55
+ *
56
+ * @defaultValue false
57
+ */
58
+ pinned?: boolean;
59
+ /**
60
+ * When `true`, the column can be resized by dragging the header edge.
61
+ *
62
+ * @defaultValue false
63
+ */
64
+ resizable?: boolean;
65
+ /**
66
+ * When `true`, clicking the column header sorts the table by this column.
67
+ *
68
+ * @defaultValue true
69
+ */
70
+ sortable?: boolean;
71
+ /**
72
+ * When `true`, a filter control is rendered in the column header.
73
+ *
74
+ * @defaultValue true
75
+ */
76
+ filterable?: boolean;
77
+ /**
78
+ * The type of filter control to render. When absent, a default is derived from `fieldtype`
79
+ * (`Check` → `checkbox`, `Date` → `date`, `Datetime` → `dateRange`, `Select` → `select`,
80
+ * numeric types → `number`, everything else → `text`).
81
+ */
82
+ filterType?: 'text' | 'select' | 'number' | 'date' | 'dateRange' | 'checkbox' | 'component';
83
+ /**
84
+ * Static option list for `filterType: 'select'`. When absent, options are derived from
85
+ * the unique values present in the column's rows.
86
+ */
87
+ filterOptions?: any[];
88
+ /** Registered component name used when `filterType` is `'component'`. */
89
+ filterComponent?: string;
90
+ /**
91
+ * Registered component name rendered inside the table cell instead of the default display.
92
+ * When absent, the table renders the value as plain text in a `<td>`.
93
+ */
94
+ cellComponent?: string;
95
+ /**
96
+ * Additional props passed to `cellComponent`.
97
+ *
98
+ * Only applicable when `cellComponent` is set.
99
+ */
100
+ cellComponentProps?: Record<string, any>;
101
+ /**
102
+ * Registered component name rendered in the cell's modal editor. String-only — functions
103
+ * cannot appear in schema JSON. `TableColumn.modalComponent` widens this to also accept a
104
+ * factory function.
105
+ *
106
+ * The following props are automatically passed to the modal component:
107
+ * - `colIndex` — the column index of the current cell
108
+ * - `rowIndex` — the row index of the current cell
109
+ * - `store` — the table data store
110
+ */
111
+ modalComponent?: string;
112
+ /**
113
+ * Extra props passed to `modalComponent` in addition to the standard cell props.
114
+ *
115
+ * Only applicable when `modalComponent` is set.
116
+ */
117
+ modalComponentExtraProps?: Record<string, any>;
118
+ /**
119
+ * Serialized function string used to format the cell value for display. Deserialized at
120
+ * render time by the table store's `getFormattedValue`. `TableColumn.format` widens this
121
+ * to also accept a live function directly.
122
+ */
123
+ format?: string;
124
+ /**
125
+ * When `true`, this column is treated as a Gantt bar column.
126
+ *
127
+ * Only applicable for Gantt tables.
128
+ *
129
+ * @defaultValue false
130
+ */
131
+ isGantt?: boolean;
132
+ /**
133
+ * Registered component name used to render Gantt bars in this column.
134
+ *
135
+ * Only applicable for Gantt tables.
136
+ *
137
+ * @defaultValue 'AGanttCell'
138
+ */
139
+ ganttComponent?: string;
140
+ /**
141
+ * Number of columns this Gantt bar spans across. When absent, the bar stretches to cover
142
+ * all non-pinned columns in the table.
143
+ *
144
+ * Only applicable for Gantt tables.
145
+ */
146
+ colspan?: number;
147
+ }
148
+ //# sourceMappingURL=column-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-schema.d.ts","sourceRoot":"","sources":["../../src/column-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,YAAY;IAC5B,2FAA2F;IAC3F,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAA;IAErD;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;IAE3F;;;OAGG;IACH,aAAa,CAAC,EAAE,GAAG,EAAE,CAAA;IAErB,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAExC;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE9C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB"}
File without changes
@@ -4,4 +4,5 @@ export type { ActionDefinition, Cardinality, CustomFetch, DataClient, DoctypeCon
4
4
  export { parseDoctype, parseField, validateDoctype, validateField, type ValidationError, type ValidationResult, } from './validation';
5
5
  export { buildScalarMap, classifyFieldType, convertGraphQLSchema, defaultIsEntityField, defaultIsEntityType, GQL_SCALAR_MAP, INTERNAL_SCALARS, WELL_KNOWN_SCALARS, type ConvertedGraphQLDoctype, type GraphQLConversionFieldMeta, type GraphQLConversionOptions, type IntrospectionSource, } from './converter';
6
6
  export { toSlug, toPascalCase, pascalToSnake, snakeToCamel, camelToSnake, snakeToLabel, camelToLabel } from './naming';
7
+ export type { ColumnSchema } from './column-schema';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GAClB,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGvE,YAAY,EACX,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,YAAY,GACZ,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACxB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GAClB,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGvE,YAAY,EACX,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,YAAY,GACZ,MAAM,WAAW,CAAA;AAGlB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACxB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGtH,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/schema",
3
- "version": "0.11.9",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "types": "./dist/schema.d.ts",
6
6
  "exports": {