@kozou/core 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +202 -0
  2. package/dist/buildSchemaContext.d.ts +19 -0
  3. package/dist/buildSchemaContext.d.ts.map +1 -0
  4. package/dist/buildSchemaContext.js +287 -0
  5. package/dist/buildSchemaContext.js.map +1 -0
  6. package/dist/checkEnum.d.ts +3 -0
  7. package/dist/checkEnum.d.ts.map +1 -0
  8. package/dist/checkEnum.js +35 -0
  9. package/dist/checkEnum.js.map +1 -0
  10. package/dist/displayField.d.ts +7 -0
  11. package/dist/displayField.d.ts.map +1 -0
  12. package/dist/displayField.js +10 -0
  13. package/dist/displayField.js.map +1 -0
  14. package/dist/index.d.ts +11 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +11 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/loadUIHints.d.ts +16 -0
  19. package/dist/loadUIHints.d.ts.map +1 -0
  20. package/dist/loadUIHints.js +50 -0
  21. package/dist/loadUIHints.js.map +1 -0
  22. package/dist/parseCommentTags.d.ts +9 -0
  23. package/dist/parseCommentTags.d.ts.map +1 -0
  24. package/dist/parseCommentTags.js +62 -0
  25. package/dist/parseCommentTags.js.map +1 -0
  26. package/dist/types/adapter.d.ts +45 -0
  27. package/dist/types/adapter.d.ts.map +1 -0
  28. package/dist/types/adapter.js +8 -0
  29. package/dist/types/adapter.js.map +1 -0
  30. package/dist/types/context.d.ts +105 -0
  31. package/dist/types/context.d.ts.map +1 -0
  32. package/dist/types/context.js +7 -0
  33. package/dist/types/context.js.map +1 -0
  34. package/dist/types/raw.d.ts +89 -0
  35. package/dist/types/raw.d.ts.map +1 -0
  36. package/dist/types/raw.js +8 -0
  37. package/dist/types/raw.js.map +1 -0
  38. package/dist/types/ui-hints.d.ts +339 -0
  39. package/dist/types/ui-hints.d.ts.map +1 -0
  40. package/dist/types/ui-hints.js +50 -0
  41. package/dist/types/ui-hints.js.map +1 -0
  42. package/dist/widget.d.ts +11 -0
  43. package/dist/widget.d.ts.map +1 -0
  44. package/dist/widget.js +31 -0
  45. package/dist/widget.js.map +1 -0
  46. package/package.json +42 -4
  47. package/README.md +0 -3
@@ -0,0 +1,339 @@
1
+ import { z } from 'zod';
2
+ declare const relationHintsSchema: z.ZodObject<{
3
+ labelField: z.ZodOptional<z.ZodString>;
4
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ labelField?: string | undefined;
7
+ searchFields?: string[] | undefined;
8
+ }, {
9
+ labelField?: string | undefined;
10
+ searchFields?: string[] | undefined;
11
+ }>;
12
+ declare const columnHintsSchema: z.ZodObject<{
13
+ label: z.ZodOptional<z.ZodString>;
14
+ widget: z.ZodOptional<z.ZodEnum<["text", "textarea", "number", "boolean", "date", "datetime", "enum-select", "relation-select", "json", "image-url", "uuid", "currency"]>>;
15
+ readonly: z.ZodOptional<z.ZodBoolean>;
16
+ /** Used for relation rendering; only meaningful when widget = relation-select */
17
+ relation: z.ZodOptional<z.ZodObject<{
18
+ labelField: z.ZodOptional<z.ZodString>;
19
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ labelField?: string | undefined;
22
+ searchFields?: string[] | undefined;
23
+ }, {
24
+ labelField?: string | undefined;
25
+ searchFields?: string[] | undefined;
26
+ }>>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ label?: string | undefined;
29
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
30
+ readonly?: boolean | undefined;
31
+ relation?: {
32
+ labelField?: string | undefined;
33
+ searchFields?: string[] | undefined;
34
+ } | undefined;
35
+ }, {
36
+ label?: string | undefined;
37
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
38
+ readonly?: boolean | undefined;
39
+ relation?: {
40
+ labelField?: string | undefined;
41
+ searchFields?: string[] | undefined;
42
+ } | undefined;
43
+ }>;
44
+ declare const tableHintsSchema: z.ZodObject<{
45
+ label: z.ZodOptional<z.ZodString>;
46
+ displayField: z.ZodOptional<z.ZodString>;
47
+ columns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
48
+ label: z.ZodOptional<z.ZodString>;
49
+ widget: z.ZodOptional<z.ZodEnum<["text", "textarea", "number", "boolean", "date", "datetime", "enum-select", "relation-select", "json", "image-url", "uuid", "currency"]>>;
50
+ readonly: z.ZodOptional<z.ZodBoolean>;
51
+ /** Used for relation rendering; only meaningful when widget = relation-select */
52
+ relation: z.ZodOptional<z.ZodObject<{
53
+ labelField: z.ZodOptional<z.ZodString>;
54
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
55
+ }, "strip", z.ZodTypeAny, {
56
+ labelField?: string | undefined;
57
+ searchFields?: string[] | undefined;
58
+ }, {
59
+ labelField?: string | undefined;
60
+ searchFields?: string[] | undefined;
61
+ }>>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ label?: string | undefined;
64
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
65
+ readonly?: boolean | undefined;
66
+ relation?: {
67
+ labelField?: string | undefined;
68
+ searchFields?: string[] | undefined;
69
+ } | undefined;
70
+ }, {
71
+ label?: string | undefined;
72
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
73
+ readonly?: boolean | undefined;
74
+ relation?: {
75
+ labelField?: string | undefined;
76
+ searchFields?: string[] | undefined;
77
+ } | undefined;
78
+ }>>>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ label?: string | undefined;
81
+ displayField?: string | undefined;
82
+ columns?: Record<string, {
83
+ label?: string | undefined;
84
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
85
+ readonly?: boolean | undefined;
86
+ relation?: {
87
+ labelField?: string | undefined;
88
+ searchFields?: string[] | undefined;
89
+ } | undefined;
90
+ }> | undefined;
91
+ }, {
92
+ label?: string | undefined;
93
+ displayField?: string | undefined;
94
+ columns?: Record<string, {
95
+ label?: string | undefined;
96
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
97
+ readonly?: boolean | undefined;
98
+ relation?: {
99
+ labelField?: string | undefined;
100
+ searchFields?: string[] | undefined;
101
+ } | undefined;
102
+ }> | undefined;
103
+ }>;
104
+ declare const viewHintsSchema: z.ZodObject<{
105
+ label: z.ZodOptional<z.ZodString>;
106
+ columns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
107
+ label: z.ZodOptional<z.ZodString>;
108
+ widget: z.ZodOptional<z.ZodEnum<["text", "textarea", "number", "boolean", "date", "datetime", "enum-select", "relation-select", "json", "image-url", "uuid", "currency"]>>;
109
+ readonly: z.ZodOptional<z.ZodBoolean>;
110
+ /** Used for relation rendering; only meaningful when widget = relation-select */
111
+ relation: z.ZodOptional<z.ZodObject<{
112
+ labelField: z.ZodOptional<z.ZodString>;
113
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ labelField?: string | undefined;
116
+ searchFields?: string[] | undefined;
117
+ }, {
118
+ labelField?: string | undefined;
119
+ searchFields?: string[] | undefined;
120
+ }>>;
121
+ }, "strip", z.ZodTypeAny, {
122
+ label?: string | undefined;
123
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
124
+ readonly?: boolean | undefined;
125
+ relation?: {
126
+ labelField?: string | undefined;
127
+ searchFields?: string[] | undefined;
128
+ } | undefined;
129
+ }, {
130
+ label?: string | undefined;
131
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
132
+ readonly?: boolean | undefined;
133
+ relation?: {
134
+ labelField?: string | undefined;
135
+ searchFields?: string[] | undefined;
136
+ } | undefined;
137
+ }>>>;
138
+ }, "strip", z.ZodTypeAny, {
139
+ label?: string | undefined;
140
+ columns?: Record<string, {
141
+ label?: string | undefined;
142
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
143
+ readonly?: boolean | undefined;
144
+ relation?: {
145
+ labelField?: string | undefined;
146
+ searchFields?: string[] | undefined;
147
+ } | undefined;
148
+ }> | undefined;
149
+ }, {
150
+ label?: string | undefined;
151
+ columns?: Record<string, {
152
+ label?: string | undefined;
153
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
154
+ readonly?: boolean | undefined;
155
+ relation?: {
156
+ labelField?: string | undefined;
157
+ searchFields?: string[] | undefined;
158
+ } | undefined;
159
+ }> | undefined;
160
+ }>;
161
+ /** Top-level zod schema for UIHints YAML. Used by loadUIHints. */
162
+ export declare const uiHintsSchema: z.ZodObject<{
163
+ tables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
164
+ label: z.ZodOptional<z.ZodString>;
165
+ displayField: z.ZodOptional<z.ZodString>;
166
+ columns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
167
+ label: z.ZodOptional<z.ZodString>;
168
+ widget: z.ZodOptional<z.ZodEnum<["text", "textarea", "number", "boolean", "date", "datetime", "enum-select", "relation-select", "json", "image-url", "uuid", "currency"]>>;
169
+ readonly: z.ZodOptional<z.ZodBoolean>;
170
+ /** Used for relation rendering; only meaningful when widget = relation-select */
171
+ relation: z.ZodOptional<z.ZodObject<{
172
+ labelField: z.ZodOptional<z.ZodString>;
173
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
174
+ }, "strip", z.ZodTypeAny, {
175
+ labelField?: string | undefined;
176
+ searchFields?: string[] | undefined;
177
+ }, {
178
+ labelField?: string | undefined;
179
+ searchFields?: string[] | undefined;
180
+ }>>;
181
+ }, "strip", z.ZodTypeAny, {
182
+ label?: string | undefined;
183
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
184
+ readonly?: boolean | undefined;
185
+ relation?: {
186
+ labelField?: string | undefined;
187
+ searchFields?: string[] | undefined;
188
+ } | undefined;
189
+ }, {
190
+ label?: string | undefined;
191
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
192
+ readonly?: boolean | undefined;
193
+ relation?: {
194
+ labelField?: string | undefined;
195
+ searchFields?: string[] | undefined;
196
+ } | undefined;
197
+ }>>>;
198
+ }, "strip", z.ZodTypeAny, {
199
+ label?: string | undefined;
200
+ displayField?: string | undefined;
201
+ columns?: Record<string, {
202
+ label?: string | undefined;
203
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
204
+ readonly?: boolean | undefined;
205
+ relation?: {
206
+ labelField?: string | undefined;
207
+ searchFields?: string[] | undefined;
208
+ } | undefined;
209
+ }> | undefined;
210
+ }, {
211
+ label?: string | undefined;
212
+ displayField?: string | undefined;
213
+ columns?: Record<string, {
214
+ label?: string | undefined;
215
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
216
+ readonly?: boolean | undefined;
217
+ relation?: {
218
+ labelField?: string | undefined;
219
+ searchFields?: string[] | undefined;
220
+ } | undefined;
221
+ }> | undefined;
222
+ }>>>;
223
+ views: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
224
+ label: z.ZodOptional<z.ZodString>;
225
+ columns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
226
+ label: z.ZodOptional<z.ZodString>;
227
+ widget: z.ZodOptional<z.ZodEnum<["text", "textarea", "number", "boolean", "date", "datetime", "enum-select", "relation-select", "json", "image-url", "uuid", "currency"]>>;
228
+ readonly: z.ZodOptional<z.ZodBoolean>;
229
+ /** Used for relation rendering; only meaningful when widget = relation-select */
230
+ relation: z.ZodOptional<z.ZodObject<{
231
+ labelField: z.ZodOptional<z.ZodString>;
232
+ searchFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ labelField?: string | undefined;
235
+ searchFields?: string[] | undefined;
236
+ }, {
237
+ labelField?: string | undefined;
238
+ searchFields?: string[] | undefined;
239
+ }>>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ label?: string | undefined;
242
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
243
+ readonly?: boolean | undefined;
244
+ relation?: {
245
+ labelField?: string | undefined;
246
+ searchFields?: string[] | undefined;
247
+ } | undefined;
248
+ }, {
249
+ label?: string | undefined;
250
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
251
+ readonly?: boolean | undefined;
252
+ relation?: {
253
+ labelField?: string | undefined;
254
+ searchFields?: string[] | undefined;
255
+ } | undefined;
256
+ }>>>;
257
+ }, "strip", z.ZodTypeAny, {
258
+ label?: string | undefined;
259
+ columns?: Record<string, {
260
+ label?: string | undefined;
261
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
262
+ readonly?: boolean | undefined;
263
+ relation?: {
264
+ labelField?: string | undefined;
265
+ searchFields?: string[] | undefined;
266
+ } | undefined;
267
+ }> | undefined;
268
+ }, {
269
+ label?: string | undefined;
270
+ columns?: Record<string, {
271
+ label?: string | undefined;
272
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
273
+ readonly?: boolean | undefined;
274
+ relation?: {
275
+ labelField?: string | undefined;
276
+ searchFields?: string[] | undefined;
277
+ } | undefined;
278
+ }> | undefined;
279
+ }>>>;
280
+ }, "strip", z.ZodTypeAny, {
281
+ tables?: Record<string, {
282
+ label?: string | undefined;
283
+ displayField?: string | undefined;
284
+ columns?: Record<string, {
285
+ label?: string | undefined;
286
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
287
+ readonly?: boolean | undefined;
288
+ relation?: {
289
+ labelField?: string | undefined;
290
+ searchFields?: string[] | undefined;
291
+ } | undefined;
292
+ }> | undefined;
293
+ }> | undefined;
294
+ views?: Record<string, {
295
+ label?: string | undefined;
296
+ columns?: Record<string, {
297
+ label?: string | undefined;
298
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
299
+ readonly?: boolean | undefined;
300
+ relation?: {
301
+ labelField?: string | undefined;
302
+ searchFields?: string[] | undefined;
303
+ } | undefined;
304
+ }> | undefined;
305
+ }> | undefined;
306
+ }, {
307
+ tables?: Record<string, {
308
+ label?: string | undefined;
309
+ displayField?: string | undefined;
310
+ columns?: Record<string, {
311
+ label?: string | undefined;
312
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
313
+ readonly?: boolean | undefined;
314
+ relation?: {
315
+ labelField?: string | undefined;
316
+ searchFields?: string[] | undefined;
317
+ } | undefined;
318
+ }> | undefined;
319
+ }> | undefined;
320
+ views?: Record<string, {
321
+ label?: string | undefined;
322
+ columns?: Record<string, {
323
+ label?: string | undefined;
324
+ widget?: "number" | "boolean" | "text" | "textarea" | "date" | "datetime" | "enum-select" | "relation-select" | "json" | "image-url" | "uuid" | "currency" | undefined;
325
+ readonly?: boolean | undefined;
326
+ relation?: {
327
+ labelField?: string | undefined;
328
+ searchFields?: string[] | undefined;
329
+ } | undefined;
330
+ }> | undefined;
331
+ }> | undefined;
332
+ }>;
333
+ export type UIHints = z.infer<typeof uiHintsSchema>;
334
+ export type TableHints = z.infer<typeof tableHintsSchema>;
335
+ export type ColumnHints = z.infer<typeof columnHintsSchema>;
336
+ export type ViewHints = z.infer<typeof viewHintsSchema>;
337
+ export type RelationHints = z.infer<typeof relationHintsSchema>;
338
+ export {};
339
+ //# sourceMappingURL=ui-hints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-hints.d.ts","sourceRoot":"","sources":["../../src/types/ui-hints.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,QAAA,MAAM,mBAAmB;;;;;;;;;EAGvB,CAAC;AAEH,QAAA,MAAM,iBAAiB;;;;IAIrB,iFAAiF;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEjF,CAAC;AAEH,QAAA,MAAM,gBAAgB;;;;;;;QAJpB,iFAAiF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQjF,CAAC;AAEH,QAAA,MAAM,eAAe;;;;;;QAVnB,iFAAiF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAajF,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,aAAa;;;;;;;;YAhBxB,iFAAiF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAAjF,iFAAiF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBjF,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ // UIHints type definitions + zod schema per Kozou v0.1 spec §4.3.
2
+ //
3
+ // Kozou v0.1 spec §16.1 leaves the final YAML grammar intentionally open
4
+ // ("finalised during implementation"). In v0.1 we treat the TypeScript
5
+ // shape in spec §4.3 as the minimal source of truth and validate the
6
+ // parsed YAML with zod from loadUIHints.
7
+ //
8
+ // Extension surface: when v0.2 adds relations or validation rules, extend
9
+ // this schema and update Kozou v0.1 spec §4.3 in the same PR (§0 rule).
10
+ import { z } from 'zod';
11
+ const widgetTypeSchema = z.enum([
12
+ 'text',
13
+ 'textarea',
14
+ 'number',
15
+ 'boolean',
16
+ 'date',
17
+ 'datetime',
18
+ 'enum-select',
19
+ 'relation-select',
20
+ 'json',
21
+ 'image-url',
22
+ 'uuid',
23
+ 'currency',
24
+ ]);
25
+ const relationHintsSchema = z.object({
26
+ labelField: z.string().min(1).optional(),
27
+ searchFields: z.array(z.string().min(1)).optional(),
28
+ });
29
+ const columnHintsSchema = z.object({
30
+ label: z.string().min(1).optional(),
31
+ widget: widgetTypeSchema.optional(),
32
+ readonly: z.boolean().optional(),
33
+ /** Used for relation rendering; only meaningful when widget = relation-select */
34
+ relation: relationHintsSchema.optional(),
35
+ });
36
+ const tableHintsSchema = z.object({
37
+ label: z.string().min(1).optional(),
38
+ displayField: z.string().min(1).optional(),
39
+ columns: z.record(z.string(), columnHintsSchema).optional(),
40
+ });
41
+ const viewHintsSchema = z.object({
42
+ label: z.string().min(1).optional(),
43
+ columns: z.record(z.string(), columnHintsSchema).optional(),
44
+ });
45
+ /** Top-level zod schema for UIHints YAML. Used by loadUIHints. */
46
+ export const uiHintsSchema = z.object({
47
+ tables: z.record(z.string(), tableHintsSchema).optional(),
48
+ views: z.record(z.string(), viewHintsSchema).optional(),
49
+ });
50
+ //# sourceMappingURL=ui-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-hints.js","sourceRoot":"","sources":["../../src/types/ui-hints.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,qEAAqE;AACrE,yCAAyC;AACzC,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AAExE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC9B,MAAM;IACN,UAAU;IACV,QAAQ;IACR,SAAS;IACT,MAAM;IACN,UAAU;IACV,aAAa;IACb,iBAAiB;IACjB,MAAM;IACN,WAAW;IACX,MAAM;IACN,UAAU;CACX,CAAiC,CAAC;AAEnC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACnC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,iFAAiF;IACjF,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,QAAQ,EAAE;CAC5D,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,QAAQ,EAAE;CAC5D,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IACzD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE;CACxD,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { RawColumn } from './types/raw.js';
2
+ import type { WidgetType } from './types/context.js';
3
+ export type InferWidgetInput = {
4
+ column: RawColumn;
5
+ isForeignKey: boolean;
6
+ enumValues: string[] | null;
7
+ /** parseCommentTags(column.comment).body */
8
+ commentBody: string;
9
+ };
10
+ export declare function inferWidget(input: InferWidgetInput): WidgetType;
11
+ //# sourceMappingURL=widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AASrD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5B,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,CAe/D"}
package/dist/widget.js ADDED
@@ -0,0 +1,31 @@
1
+ const NUMERIC_UDT = new Set(['int2', 'int4', 'int8', 'numeric', 'float4', 'float8']);
2
+ const DATETIME_UDT = new Set(['timestamp', 'timestamptz', 'time', 'timetz']);
3
+ const JSON_UDT = new Set(['json', 'jsonb']);
4
+ const URL_HINT_RE = /(?:^|_)url\b|image/i;
5
+ const TEXTAREA_HINT_RE = /html|markdown|body|content/i;
6
+ export function inferWidget(input) {
7
+ const { column, isForeignKey, enumValues, commentBody } = input;
8
+ const udt = column.udtName;
9
+ if (isForeignKey)
10
+ return 'relation-select';
11
+ if (enumValues !== null && enumValues.length > 0)
12
+ return 'enum-select';
13
+ if (udt === 'uuid')
14
+ return 'uuid';
15
+ if (udt === 'bool')
16
+ return 'boolean';
17
+ if (NUMERIC_UDT.has(udt))
18
+ return 'number';
19
+ if (udt === 'date')
20
+ return 'date';
21
+ if (DATETIME_UDT.has(udt))
22
+ return 'datetime';
23
+ if (JSON_UDT.has(udt))
24
+ return 'json';
25
+ if (udt === 'text' && URL_HINT_RE.test(column.name))
26
+ return 'image-url';
27
+ if (udt === 'text' && TEXTAREA_HINT_RE.test(commentBody))
28
+ return 'textarea';
29
+ return 'text';
30
+ }
31
+ //# sourceMappingURL=widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.js","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AACrF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7E,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5C,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAC1C,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAUvD,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAChE,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC;IAE3B,IAAI,YAAY;QAAE,OAAO,iBAAiB,CAAC;IAC3C,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,aAAa,CAAC;IACvE,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,SAAS,CAAC;IACrC,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1C,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,UAAU,CAAC;IAC7C,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IACrC,IAAI,GAAG,KAAK,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,WAAW,CAAC;IACxE,IAAI,GAAG,KAAK,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;QAAE,OAAO,UAAU,CAAC;IAC5E,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,45 @@
1
1
  {
2
2
  "name": "@kozou/core",
3
- "version": "0.0.1",
4
- "description": "Placeholder; v0.1.0 release lands via CI shortly.",
3
+ "version": "0.1.0",
4
+ "description": "Kozou core: Schema Context, type definitions, UI Hints zod schema, DataAdapter interface.",
5
5
  "license": "Apache-2.0",
6
- "publishConfig": { "access": "public" }
7
- }
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/kozou-dev/kozou.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "homepage": "https://kozou.org",
12
+ "bugs": {
13
+ "url": "https://github.com/kozou-dev/kozou/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "provenance": true
31
+ },
32
+ "dependencies": {
33
+ "yaml": "^2.6.0",
34
+ "zod": "^3.23.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/pg": "^8.11.0",
38
+ "pg": "^8.13.0"
39
+ },
40
+ "scripts": {
41
+ "typecheck": "tsc --noEmit",
42
+ "build": "tsc",
43
+ "test": "vitest run --coverage"
44
+ }
45
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @kozou/core
2
-
3
- Placeholder publish. The real v0.1.0 release lands via CI shortly. See https://github.com/kozou-dev/kozou for the source.