@ai-matrx/records 0.99.14 → 0.99.16

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 (50) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{client-BhrN1XK2.d.cts → client-D8vzRl-L.d.cts} +2 -83
  3. package/dist/{client-BTUMagai.d.ts → client-DuoWeGcM.d.ts} +2 -83
  4. package/dist/core/index.cjs +6 -6
  5. package/dist/core/index.cjs.map +1 -1
  6. package/dist/core/index.d.cts +4 -3
  7. package/dist/core/index.d.ts +4 -3
  8. package/dist/core/index.js +6 -6
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/data/index.cjs +6 -6
  11. package/dist/data/index.cjs.map +1 -1
  12. package/dist/data/index.d.cts +2 -1
  13. package/dist/data/index.d.ts +2 -1
  14. package/dist/data/index.js +6 -6
  15. package/dist/data/index.js.map +1 -1
  16. package/dist/{declareTable-D8Mq6wNq.d.ts → declareTable-DO8U62Pf.d.ts} +1 -1
  17. package/dist/{declareTable-BU3IURyS.d.cts → declareTable-T0LWvfIO.d.cts} +1 -1
  18. package/dist/index.d.cts +3 -2
  19. package/dist/index.d.ts +3 -2
  20. package/dist/questions/index.d.cts +2 -1
  21. package/dist/questions/index.d.ts +2 -1
  22. package/dist/react/index.cjs +20 -20
  23. package/dist/react/index.cjs.map +1 -1
  24. package/dist/react/index.js +18 -18
  25. package/dist/react/index.js.map +1 -1
  26. package/dist/scopes/index.cjs +2 -2
  27. package/dist/scopes/index.cjs.map +1 -1
  28. package/dist/scopes/index.js +2 -2
  29. package/dist/scopes/index.js.map +1 -1
  30. package/dist/setup/index.cjs +8 -8
  31. package/dist/setup/index.cjs.map +1 -1
  32. package/dist/setup/index.d.cts +2 -1
  33. package/dist/setup/index.d.ts +2 -1
  34. package/dist/setup/index.js +8 -8
  35. package/dist/setup/index.js.map +1 -1
  36. package/dist/table-kind/index.cjs +421 -0
  37. package/dist/table-kind/index.cjs.map +1 -0
  38. package/dist/table-kind/index.d.cts +83 -0
  39. package/dist/table-kind/index.d.ts +83 -0
  40. package/dist/table-kind/index.js +400 -0
  41. package/dist/table-kind/index.js.map +1 -0
  42. package/dist/typed-table/index.cjs +3 -3
  43. package/dist/typed-table/index.cjs.map +1 -1
  44. package/dist/typed-table/index.d.cts +3 -2
  45. package/dist/typed-table/index.d.ts +3 -2
  46. package/dist/typed-table/index.js +3 -3
  47. package/dist/typed-table/index.js.map +1 -1
  48. package/dist/views/index.d.cts +2 -1
  49. package/dist/views/index.d.ts +2 -1
  50. package/package.json +12 -2
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/table-kind.ts
21
+ var table_kind_exports = {};
22
+ __export(table_kind_exports, {
23
+ TABLE_KIND_PREFIX: () => TABLE_KIND_PREFIX,
24
+ fieldKindOf: () => fieldKindOf,
25
+ isTableKind: () => isTableKind,
26
+ tableIdOf: () => tableIdOf,
27
+ tableJsonSchema: () => tableJsonSchema,
28
+ tableKindMapping: () => tableKindMapping,
29
+ tableKindSlug: () => tableKindSlug,
30
+ tableRenderSchema: () => tableRenderSchema
31
+ });
32
+ module.exports = __toCommonJS(table_kind_exports);
33
+ var import_uuid = require("@ai-matrx/kit/uuid");
34
+
35
+ // src/table-kind-mapping.json
36
+ var table_kind_mapping_default = {
37
+ about: "THE ONE MAPPING from a store Field to a kind's three schemas (KINDS-GLUE wave 3 \xA72). Hand-written here; aidream copies it verbatim to packages/matrx-graph/matrx_graph/table_kind_mapping.json (scripts/generate_table_kind_mapping.py --check). Both languages derive from this file only: @ai-matrx/records src/table-kind.ts and matrx_graph.table_kinds. Keys of `kinds` are the store's field kinds (custom.field_kinds() plus the formula `system` kinds custom.field_kind_of answers). Stored mode only: `column_source_default` is custom.table_column_source's answer when the facts carry none (silence means the doctrine: Field rows are the columns); `platform_keys` mirrors custom.record_platform_keys() with each key's shape (parent_id: custom.containment_parent's uuid cast; icon: the record's own @ai-matrx/icons name, a string or null); `stored_patterns` mirror custom.validate_values' relation id regex and, for dates, refuse a string the timestamptz cast can never read (no digits, not a special word) while never refusing one it can.",
38
+ version: 2,
39
+ kernels: {
40
+ file: "11111111-0000-4000-8000-000000000006",
41
+ person: "11111111-0000-4000-8000-000000000005"
42
+ },
43
+ system_kinds: ["created_by", "modified_by", "autonumber", "created_time", "modified_time"],
44
+ by_behaviour: {
45
+ text: "text",
46
+ range: "number",
47
+ list: "select",
48
+ relation: "relation",
49
+ boolean: "checkbox",
50
+ formula: "formula"
51
+ },
52
+ choice_enum_limit: 100,
53
+ rating_max: 5,
54
+ address_parts: ["street", "city", "region", "postal_code", "country"],
55
+ address_part_max: 200,
56
+ column_source_default: "fields",
57
+ platform_keys: {
58
+ parent_id: { type: ["string", "null"], pattern: "^(?:\\{[0-9a-fA-F]{4}(?:-?[0-9a-fA-F]{4}){7}\\}|[0-9a-fA-F]{4}(?:-?[0-9a-fA-F]{4}){7})$" },
59
+ icon: { type: ["string", "null"] }
60
+ },
61
+ stored_patterns: {
62
+ record_id: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
63
+ datetime: "[0-9][^0-9]+[0-9]|[0-9]{5}|^\\s*(?:[Nn][Oo][Ww]|[Tt][Oo][Dd][Aa][Yy]|[Tt][Oo][Mm][Oo][Rr][Rr][Oo][Ww]|[Yy][Ee][Ss][Tt][Ee][Rr][Dd][Aa][Yy]|[Ee][Pp][Oo][Cc][Hh])(?![A-Za-z])"
64
+ },
65
+ kinds: {
66
+ text: { shape: "string", value: { type: "string" } },
67
+ long_text: { shape: "string", value: { type: "string" } },
68
+ email: { shape: "string", value: { type: "string", format: "email" } },
69
+ phone: { shape: "string", value: { type: "string" } },
70
+ url: { shape: "string", value: { type: "string" } },
71
+ barcode: { shape: "string", value: { type: "string", maxLength: 256 } },
72
+ rich_text: { shape: "string", value: { type: "string" }, hint: "Markdown, no HTML." },
73
+ signature: { shape: "string", value: { type: "string", readOnly: true }, authored: false },
74
+ number: { shape: "number", value: { type: "number" } },
75
+ currency: { shape: "number", value: { type: "number" }, unit: true },
76
+ percent: { shape: "number", value: { type: "number" }, hint: "A whole percent: 6 means 6%." },
77
+ rating: { shape: "number", value: { type: "integer", minimum: 0 }, rating: true },
78
+ duration: { shape: "number", value: { type: "number", minimum: 0 }, hint: "A length of time in seconds." },
79
+ datetime: { shape: "datetime" },
80
+ checkbox: { shape: "boolean", value: { type: "boolean" } },
81
+ select: { shape: "choice" },
82
+ multi_select: { shape: "choice" },
83
+ status: { shape: "choice" },
84
+ relation: { shape: "relation" },
85
+ member: { shape: "relation" },
86
+ attachment: { shape: "relation", authored: false },
87
+ entity_reference: { shape: "entity_reference" },
88
+ address: { shape: "address" },
89
+ formula: { shape: "computed" },
90
+ lookup: { shape: "computed" },
91
+ rollup: { shape: "computed" },
92
+ count: { shape: "computed" },
93
+ created_by: { shape: "computed" },
94
+ modified_by: { shape: "computed" },
95
+ autonumber: { shape: "computed" },
96
+ created_time: { shape: "computed" },
97
+ modified_time: { shape: "computed" }
98
+ },
99
+ render: {
100
+ string: { one: { type: "string" }, many: { type: "string[]" } },
101
+ number: { one: { type: "number" }, many: { type: "number[]" } },
102
+ boolean: { one: { type: "boolean" }, many: { type: "boolean[]" } },
103
+ datetime: { one: { type: "union", scalars: ["string", "number"] }, many: { type: "json" } },
104
+ relation: { one: { type: "json" }, many: { type: "json" } },
105
+ entity_reference: { one: { type: "json" }, many: { type: "json" } },
106
+ address: { one: { type: "json" }, many: { type: "json" } },
107
+ computed: { one: { type: "json" }, many: { type: "json" } }
108
+ }
109
+ };
110
+
111
+ // src/table-kind.ts
112
+ var TABLE_KIND_PREFIX = "table:";
113
+ var KIND_KEY = "__kind";
114
+ var M = table_kind_mapping_default;
115
+ function tableKindMapping() {
116
+ return M;
117
+ }
118
+ function isTableKind(slug) {
119
+ return typeof slug === "string" && slug.startsWith(TABLE_KIND_PREFIX) && (0, import_uuid.isLowercaseUuidShape)(slug.slice(TABLE_KIND_PREFIX.length));
120
+ }
121
+ function tableKindSlug(tableId) {
122
+ const slug = `${TABLE_KIND_PREFIX}${String(tableId).trim().toLowerCase()}`;
123
+ if (!isTableKind(slug)) throw new Error(`${JSON.stringify(tableId)} is not a table id`);
124
+ return slug;
125
+ }
126
+ function tableIdOf(slug) {
127
+ if (!isTableKind(slug)) throw new Error(`${JSON.stringify(slug)} is not a table kind`);
128
+ return slug.slice(TABLE_KIND_PREFIX.length);
129
+ }
130
+ function clone(value) {
131
+ return JSON.parse(JSON.stringify(value));
132
+ }
133
+ function truthy(value) {
134
+ return value === true || value === "true";
135
+ }
136
+ function configOf(d) {
137
+ const cfg = d.config;
138
+ return cfg && typeof cfg === "object" && !Array.isArray(cfg) ? cfg : {};
139
+ }
140
+ function parityType(d) {
141
+ const t = d.type;
142
+ const fmt = d.format;
143
+ const cfg = configOf(d);
144
+ if (t === "boolean") return "checkbox";
145
+ if (t === "list") return truthy(d.multi) ? "multi_select" : "select";
146
+ if (t === "relation" && d.relation_target === M.kernels.file) return "attachment";
147
+ if (t === "relation" && d.relation_target === M.kernels.person) return "member";
148
+ if (t === "formula" && "pick" in cfg) return "lookup";
149
+ if (t === "formula" && "agg" in cfg) return "rollup";
150
+ if (t === "formula" && "expr" in cfg) return "formula";
151
+ if (t === "text" && (fmt === "url" || fmt === "email" || fmt === "phone")) return fmt;
152
+ if (t === "range" && fmt === "percent") return "percent";
153
+ if (t === "range" && d.unit && fmt === "currency") return "currency";
154
+ if (t === "range" && (cfg.kind === "date" || cfg.kind === "datetime")) return "datetime";
155
+ return null;
156
+ }
157
+ function fieldKindOf(d) {
158
+ const t = d.type;
159
+ const fmt = d.format;
160
+ const cfg = configOf(d);
161
+ if (t === "range" && (fmt === "rating" || fmt === "duration")) return fmt;
162
+ if (t === "text" && (fmt === "address" || fmt === "barcode" || fmt === "rich_text" || fmt === "signature")) return fmt;
163
+ if (t === "list" && fmt === "status") return "status";
164
+ if (t === "formula" && fmt === "count" && cfg.agg === "count") return "count";
165
+ if (t === "formula" && typeof cfg.system === "string" && M.system_kinds.includes(cfg.system)) return cfg.system;
166
+ if (t === "relation" && Array.isArray(cfg.allowed_types)) return "entity_reference";
167
+ const parity = parityType(d);
168
+ if (parity !== null) return parity;
169
+ if (t === "text") return fmt === "long" || truthy(cfg.multiline) ? "long_text" : "text";
170
+ if (t === "range") return "number";
171
+ if (t === "relation") return "relation";
172
+ return null;
173
+ }
174
+ function fieldKind(d) {
175
+ if ("field_kind" in d) return typeof d.field_kind === "string" ? d.field_kind : null;
176
+ return fieldKindOf(d);
177
+ }
178
+ function kindSpec(d) {
179
+ const kind = fieldKind(d) ?? M.by_behaviour[String(d.type)] ?? "formula";
180
+ return M.kinds[kind] ?? M.kinds.formula;
181
+ }
182
+ function unconditionalRules(d) {
183
+ const rules = Array.isArray(d.rules) ? d.rules : [];
184
+ return rules.filter(
185
+ (r) => !!r && typeof r === "object" && !Array.isArray(r) && !(Array.isArray(r.applies_to_types) && r.applies_to_types.length > 0) && !(typeof r.applies_to_types === "string" && r.applies_to_types !== "")
186
+ );
187
+ }
188
+ function numberOf(value) {
189
+ if (typeof value === "boolean") return null;
190
+ if (typeof value === "number" && Number.isFinite(value)) return value;
191
+ if (typeof value === "string" && /^-?[0-9]+(\.[0-9]+)?$/.test(value)) return Number(value);
192
+ return null;
193
+ }
194
+ function choiceTokens(facts, key) {
195
+ const tokens = [];
196
+ for (const choice of facts.choices?.[key] ?? []) {
197
+ for (const token of [choice.key, choice.label, choice.id]) {
198
+ if (typeof token === "string" && token && !tokens.includes(token)) tokens.push(token);
199
+ }
200
+ }
201
+ return tokens;
202
+ }
203
+ function liveChoiceKeys(facts, key) {
204
+ const keys = [];
205
+ for (const choice of facts.choices?.[key] ?? []) {
206
+ const k = choice.key;
207
+ if (!choice.retired && typeof k === "string" && k && !keys.includes(k)) keys.push(k);
208
+ }
209
+ return keys;
210
+ }
211
+ function item(facts, d, mode) {
212
+ const spec = kindSpec(d);
213
+ const shape = spec.shape;
214
+ const cfg = configOf(d);
215
+ const key = String(d.key);
216
+ if (shape === "string" || shape === "number" || shape === "boolean") {
217
+ const out = clone(spec.value ?? {});
218
+ for (const rule of unconditionalRules(d)) {
219
+ const kind = rule.kind;
220
+ const value = numberOf(rule.value);
221
+ if (shape === "number" && kind === "min" && value !== null) out.minimum = value;
222
+ else if (shape === "number" && kind === "max" && value !== null) out.maximum = value;
223
+ else if (shape === "string" && kind === "length" && value !== null) out.maxLength = Math.trunc(value);
224
+ }
225
+ if (spec.rating && !("maximum" in out)) out.maximum = M.rating_max;
226
+ if (spec.unit && d.unit && mode === "stored") out["x-matrx-unit"] = d.unit;
227
+ return out;
228
+ }
229
+ if (shape === "datetime") {
230
+ if (mode === "stored") return { type: ["number", "string"], pattern: M.stored_patterns.datetime };
231
+ return { type: "string", format: cfg.kind === "date" ? "date" : "date-time" };
232
+ }
233
+ if (shape === "choice") {
234
+ if (truthy(cfg.allow_other)) return { type: "string" };
235
+ if (mode === "stored") return { type: "string", enum: choiceTokens(facts, key) };
236
+ const live = liveChoiceKeys(facts, key);
237
+ if (live.length === 0 || live.length > M.choice_enum_limit) return { type: "string" };
238
+ return { type: "string", enum: live };
239
+ }
240
+ if (shape === "relation") {
241
+ if (mode === "stored") return { type: "string", format: "uuid", pattern: M.stored_patterns.record_id };
242
+ return { type: "string", format: "uuid" };
243
+ }
244
+ if (shape === "entity_reference") {
245
+ const allowed = (Array.isArray(cfg.allowed_types) ? cfg.allowed_types : []).filter(
246
+ (t) => typeof t === "string"
247
+ );
248
+ const id = { type: "string", format: "uuid" };
249
+ if (mode === "stored") id.pattern = M.stored_patterns.record_id;
250
+ const out = {
251
+ type: "object",
252
+ properties: { token: { type: "string", enum: allowed }, id },
253
+ required: ["token", "id"]
254
+ };
255
+ if (mode === "authored") out.additionalProperties = false;
256
+ return out;
257
+ }
258
+ if (shape === "address") {
259
+ const part = mode === "authored" ? { type: "string", maxLength: M.address_part_max } : { type: ["string", "null"], maxLength: M.address_part_max };
260
+ const out = {
261
+ type: "object",
262
+ properties: Object.fromEntries(M.address_parts.map((p) => [p, { ...part }])),
263
+ additionalProperties: false
264
+ };
265
+ if (mode === "stored") out.minProperties = 1;
266
+ return out;
267
+ }
268
+ return { readOnly: true };
269
+ }
270
+ function isTyped(d) {
271
+ return Array.isArray(d.applies_to_types) && d.applies_to_types.length > 0;
272
+ }
273
+ function storedValue(facts, d) {
274
+ const shape = kindSpec(d).shape;
275
+ if (shape === "computed") return { readOnly: true };
276
+ const one = item(facts, d, "stored");
277
+ const required = truthy(d.required) && !isTyped(d);
278
+ let value;
279
+ if (shape === "relation" || shape === "entity_reference") {
280
+ const many = { type: "array", items: one };
281
+ const ceiling = numberOf(d.relation_max);
282
+ if (ceiling !== null) many.maxItems = Math.trunc(ceiling);
283
+ if (required) many.minItems = 1;
284
+ value = { anyOf: [one, many] };
285
+ } else if (truthy(d.multi)) {
286
+ value = { type: "array", items: one };
287
+ if (required) value.minItems = 1;
288
+ } else {
289
+ value = one;
290
+ }
291
+ return required ? value : { anyOf: [value, { type: "null" }] };
292
+ }
293
+ function authoredValue(facts, d, typeLabels2) {
294
+ const spec = kindSpec(d);
295
+ const shape = spec.shape;
296
+ const one = item(facts, d, "authored");
297
+ let value;
298
+ if (shape === "relation" || shape === "entity_reference") {
299
+ value = { type: "array", items: one };
300
+ const ceiling = numberOf(d.relation_max);
301
+ if (ceiling !== null) value.maxItems = Math.trunc(ceiling);
302
+ } else if (truthy(d.multi)) {
303
+ value = { type: "array", items: one };
304
+ } else {
305
+ value = one;
306
+ }
307
+ const extras = [];
308
+ if (spec.unit && d.unit) extras.push(`Amount in ${String(d.unit)}.`);
309
+ if (spec.hint) extras.push(spec.hint);
310
+ if (typeLabels2.length > 0) extras.push(`Only for ${typeLabels2.join(", ")} records.`);
311
+ const label = String(d.label || d.key);
312
+ value.description = extras.length > 0 ? `${label}. ${extras.join(" ")}` : label;
313
+ return value;
314
+ }
315
+ function isAuthored(d) {
316
+ const spec = kindSpec(d);
317
+ return spec.shape !== "computed" && spec.authored !== false;
318
+ }
319
+ function typeChoice(facts, word) {
320
+ for (const choice of facts.choices?.[facts.type_field ?? ""] ?? []) {
321
+ if (word === choice.key || word === choice.label || word === choice.id) return choice;
322
+ }
323
+ return null;
324
+ }
325
+ function typeSynonyms(facts, word) {
326
+ const choice = typeChoice(facts, word);
327
+ if (!choice) return [word, [word]];
328
+ const out = [];
329
+ for (const token of [choice.key, choice.label, choice.id]) {
330
+ if (typeof token === "string" && token && !out.includes(token)) out.push(token);
331
+ }
332
+ return [String(choice.key || word), out];
333
+ }
334
+ function typeLabels(facts, d) {
335
+ const labels = [];
336
+ for (const word of d.applies_to_types ?? []) {
337
+ const choice = typeChoice(facts, String(word));
338
+ const label = choice ? String(choice.label || choice.key) : String(word);
339
+ if (!labels.includes(label)) labels.push(label);
340
+ }
341
+ return labels;
342
+ }
343
+ function liveFields(facts) {
344
+ return (facts.fields ?? []).filter((d) => !!d && typeof d === "object" && !!d.key);
345
+ }
346
+ function tableJsonSchema(facts, mode) {
347
+ const slug = tableKindSlug(String(facts.table_id));
348
+ const fields = liveFields(facts);
349
+ const properties = { [KIND_KEY]: { const: slug } };
350
+ const required = [KIND_KEY];
351
+ if (mode === "stored") {
352
+ const branches = /* @__PURE__ */ new Map();
353
+ for (const d of fields) {
354
+ const key = String(d.key);
355
+ properties[key] = storedValue(facts, d);
356
+ const computed = kindSpec(d).shape === "computed";
357
+ if (!truthy(d.required) || computed) continue;
358
+ if (!isTyped(d)) {
359
+ required.push(key);
360
+ continue;
361
+ }
362
+ if (!facts.type_field) continue;
363
+ for (const word of d.applies_to_types) {
364
+ const [typeKey, synonyms] = typeSynonyms(facts, String(word));
365
+ let branch = branches.get(typeKey);
366
+ if (!branch) {
367
+ branch = {
368
+ if: { properties: { [facts.type_field]: { enum: synonyms } }, required: [facts.type_field] },
369
+ then: { required: [], properties: {} }
370
+ };
371
+ branches.set(typeKey, branch);
372
+ }
373
+ if (!branch.then.required.includes(key)) {
374
+ branch.then.required.push(key);
375
+ branch.then.properties[key] = { not: { type: "null" } };
376
+ }
377
+ }
378
+ }
379
+ const platformKeys = Array.isArray(facts.platform_keys) ? facts.platform_keys : Object.keys(M.platform_keys);
380
+ for (const name of platformKeys) {
381
+ if (typeof name === "string" && !(name in properties)) properties[name] = clone(M.platform_keys[name] ?? {});
382
+ }
383
+ const schema = {
384
+ type: "object",
385
+ properties,
386
+ patternProperties: { "^_": {} },
387
+ required
388
+ };
389
+ if ((facts.column_source || M.column_source_default) === "fields") schema.additionalProperties = false;
390
+ if (branches.size > 0) schema.allOf = [...branches.values()];
391
+ return schema;
392
+ }
393
+ for (const d of fields) {
394
+ if (!isAuthored(d)) continue;
395
+ const key = String(d.key);
396
+ const typed = isTyped(d);
397
+ properties[key] = authoredValue(facts, d, typed ? typeLabels(facts, d) : []);
398
+ if (truthy(d.required) && !typed) required.push(key);
399
+ }
400
+ return { type: "object", properties, required, additionalProperties: false };
401
+ }
402
+ function tableRenderSchema(facts) {
403
+ const slug = tableKindSlug(String(facts.table_id));
404
+ const out = {};
405
+ for (const d of liveFields(facts)) {
406
+ const key = String(d.key);
407
+ const shape = kindSpec(d).shape;
408
+ const multi = truthy(d.multi);
409
+ let field;
410
+ if (shape === "choice") {
411
+ field = { type: multi ? "string[]" : "enum", values: choiceTokens(facts, key) };
412
+ if (truthy(configOf(d).allow_other)) field.open = true;
413
+ } else {
414
+ field = clone(M.render[shape][multi ? "many" : "one"]);
415
+ }
416
+ field.nullable = true;
417
+ out[key] = field;
418
+ }
419
+ return { kind: slug, fields: out };
420
+ }
421
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/table-kind.ts","../../src/table-kind-mapping.json"],"sourcesContent":["// src/table-kind.ts — A TABLE IS A KIND (KINDS-GLUE wave 3 §1–2).\n//\n// `table:<uuid>` names \"a record of that Table\". It is never a registry row: its schema is\n// derived, when asked for, from the Table's live Fields as the store's door\n// `custom.table_kind_facts` (N1) answers them — `TableKindFacts` is that door's JSON verbatim.\n//\n// ONE MAPPING, THREE OUTPUTS, TWO LANGUAGES. `table-kind-mapping.json` beside this file is the\n// one data file (aidream copies it verbatim into matrx-graph). From it:\n// - stored — the JSON Schema a value is validated against (mirrors custom.validate_values and\n// custom._undeclared_key_guard: closed only on a `fields` Table, platform keys allowed;\n// uses the door's column_source / platform_keys / per-Field field_kind when present,\n// else derives them);\n// - authored — a plain object every provider binds (no allOf / if / patternProperties);\n// - render — the content-ir KindSchema the web draws with, never stricter than the store.\n// Each is Fields-only here (`tableJsonSchema`, `tableRenderSchema`); the control keys are wave 2's\n// one function (`withControlKeys` / `withControlKeyFields` in @ai-matrx/content-ir), applied by\n// the caller. The Python twin is `matrx_graph.table_kinds`; both write byte-identical JSON for\n// the golden fixture (guard 3 (a), `__tests__/table-kind-round-trip.test.ts`).\n\nimport { isLowercaseUuidShape } from \"@ai-matrx/kit/uuid\";\nimport MAPPING from \"./table-kind-mapping.json\";\n\nexport const TABLE_KIND_PREFIX = \"table:\";\nconst KIND_KEY = \"__kind\";\n\ntype Json = Record<string, unknown>;\n\n/** `custom.table_kind_facts(p_table_id)` verbatim (N1). */\nexport interface TableKindFacts {\n organization_id: string;\n table_id: string;\n name: string | null;\n title_field: string | null;\n agent_writable: boolean;\n purpose: string | null;\n version: number | null;\n type_field: string | null;\n stamp: string | null;\n /** Every live Field document (typed ones included), plus `id` and `version`, in `sort` order. */\n fields: Array<Record<string, unknown>>;\n /** `{<list field key>: [{key, label, id, retired, position}]}`, retired included, live first. */\n choices: Record<string, Array<{ key?: string | null; label?: string | null; id?: string | null; retired?: boolean; position?: number | null }>>;\n /** `custom.table_column_source` (`fields` / `free_form` / `code`) once the door carries it; absent, the mapping's default. */\n column_source?: string | null;\n /** `custom.record_platform_keys()` once the door carries it; absent, the mapping's keys. */\n platform_keys?: string[] | null;\n}\n\n/** The content-ir `KindSchema` shape, structurally (this package does not depend on content-ir). */\nexport interface TableRenderSchema {\n kind: string;\n fields: Record<string, Record<string, unknown>>;\n}\n\nexport type TableSchemaMode = \"stored\" | \"authored\";\n\ntype KindSpec = {\n shape: \"string\" | \"number\" | \"boolean\" | \"datetime\" | \"choice\" | \"relation\" | \"entity_reference\" | \"address\" | \"computed\";\n value?: Json;\n authored?: boolean;\n unit?: boolean;\n hint?: string;\n rating?: boolean;\n};\n\ntype Mapping = {\n kernels: { file: string; person: string };\n system_kinds: string[];\n by_behaviour: Record<string, string>;\n choice_enum_limit: number;\n rating_max: number;\n address_parts: string[];\n address_part_max: number;\n column_source_default: string;\n platform_keys: Record<string, Json>;\n stored_patterns: { record_id: string; datetime: string };\n kinds: Record<string, KindSpec>;\n render: Record<string, { one: Json; many: Json }>;\n};\n\nconst M = MAPPING as unknown as Mapping;\n\n/** The one mapping (records' own file; the Python copy is generated from it). */\nexport function tableKindMapping(): Readonly<Mapping> {\n return M;\n}\n\nexport function isTableKind(slug: unknown): slug is `table:${string}` {\n return typeof slug === \"string\" && slug.startsWith(TABLE_KIND_PREFIX) && isLowercaseUuidShape(slug.slice(TABLE_KIND_PREFIX.length));\n}\n\nexport function tableKindSlug(tableId: string): `table:${string}` {\n const slug = `${TABLE_KIND_PREFIX}${String(tableId).trim().toLowerCase()}`;\n if (!isTableKind(slug)) throw new Error(`${JSON.stringify(tableId)} is not a table id`);\n return slug;\n}\n\nexport function tableIdOf(slug: string): string {\n if (!isTableKind(slug)) throw new Error(`${JSON.stringify(slug)} is not a table kind`);\n return slug.slice(TABLE_KIND_PREFIX.length);\n}\n\n// ── field kinds ─────────────────────────────────────────────────────────────────────────\n\nfunction clone<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nfunction truthy(value: unknown): boolean {\n return value === true || value === \"true\";\n}\n\nfunction configOf(d: Json): Json {\n const cfg = d.config;\n return cfg && typeof cfg === \"object\" && !Array.isArray(cfg) ? (cfg as Json) : {};\n}\n\n/** Twin of `custom.parity_type` — the first answer wins. */\nfunction parityType(d: Json): string | null {\n const t = d.type;\n const fmt = d.format;\n const cfg = configOf(d);\n if (t === \"boolean\") return \"checkbox\";\n if (t === \"list\") return truthy(d.multi) ? \"multi_select\" : \"select\";\n if (t === \"relation\" && d.relation_target === M.kernels.file) return \"attachment\";\n if (t === \"relation\" && d.relation_target === M.kernels.person) return \"member\";\n if (t === \"formula\" && \"pick\" in cfg) return \"lookup\";\n if (t === \"formula\" && \"agg\" in cfg) return \"rollup\";\n if (t === \"formula\" && \"expr\" in cfg) return \"formula\";\n if (t === \"text\" && (fmt === \"url\" || fmt === \"email\" || fmt === \"phone\")) return fmt;\n if (t === \"range\" && fmt === \"percent\") return \"percent\";\n if (t === \"range\" && d.unit && fmt === \"currency\") return \"currency\";\n if (t === \"range\" && (cfg.kind === \"date\" || cfg.kind === \"datetime\")) return \"datetime\";\n return null;\n}\n\n/** Twin of `custom.field_kind_of`: the field kind a stored Field document declares. */\nexport function fieldKindOf(d: Record<string, unknown>): string | null {\n const t = d.type;\n const fmt = d.format;\n const cfg = configOf(d);\n if (t === \"range\" && (fmt === \"rating\" || fmt === \"duration\")) return fmt;\n if (t === \"text\" && (fmt === \"address\" || fmt === \"barcode\" || fmt === \"rich_text\" || fmt === \"signature\")) return fmt;\n if (t === \"list\" && fmt === \"status\") return \"status\";\n if (t === \"formula\" && fmt === \"count\" && cfg.agg === \"count\") return \"count\";\n if (t === \"formula\" && typeof cfg.system === \"string\" && M.system_kinds.includes(cfg.system)) return cfg.system;\n if (t === \"relation\" && Array.isArray(cfg.allowed_types)) return \"entity_reference\";\n const parity = parityType(d);\n if (parity !== null) return parity;\n if (t === \"text\") return fmt === \"long\" || truthy(cfg.multiline) ? \"long_text\" : \"text\";\n if (t === \"range\") return \"number\";\n if (t === \"relation\") return \"relation\";\n return null;\n}\n\n/**\n * The store's own `field_kind` when the facts carry it (`custom.field_kind_of` per Field, asked\n * of the door); otherwise this twin's derivation of the same answer.\n */\nfunction fieldKind(d: Json): string | null {\n if (\"field_kind\" in d) return typeof d.field_kind === \"string\" ? d.field_kind : null;\n return fieldKindOf(d);\n}\n\nfunction kindSpec(d: Json): KindSpec {\n const kind = fieldKind(d) ?? M.by_behaviour[String(d.type)] ?? \"formula\";\n return M.kinds[kind] ?? M.kinds.formula!;\n}\n\n// ── per Field ───────────────────────────────────────────────────────────────────────────\n\nfunction unconditionalRules(d: Json): Json[] {\n const rules = Array.isArray(d.rules) ? (d.rules as unknown[]) : [];\n return rules.filter(\n (r): r is Json =>\n !!r &&\n typeof r === \"object\" &&\n !Array.isArray(r) &&\n !(Array.isArray((r as Json).applies_to_types) && ((r as Json).applies_to_types as unknown[]).length > 0) &&\n !(typeof (r as Json).applies_to_types === \"string\" && (r as Json).applies_to_types !== \"\"),\n );\n}\n\n/** A rule's number, as Python's twin writes it (6.0 is 6). */\nfunction numberOf(value: unknown): number | null {\n if (typeof value === \"boolean\") return null;\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\n if (typeof value === \"string\" && /^-?[0-9]+(\\.[0-9]+)?$/.test(value)) return Number(value);\n return null;\n}\n\nfunction choiceTokens(facts: TableKindFacts, key: string): string[] {\n const tokens: string[] = [];\n for (const choice of facts.choices?.[key] ?? []) {\n for (const token of [choice.key, choice.label, choice.id]) {\n if (typeof token === \"string\" && token && !tokens.includes(token)) tokens.push(token);\n }\n }\n return tokens;\n}\n\nfunction liveChoiceKeys(facts: TableKindFacts, key: string): string[] {\n const keys: string[] = [];\n for (const choice of facts.choices?.[key] ?? []) {\n const k = choice.key;\n if (!choice.retired && typeof k === \"string\" && k && !keys.includes(k)) keys.push(k);\n }\n return keys;\n}\n\nfunction item(facts: TableKindFacts, d: Json, mode: TableSchemaMode): Json {\n const spec = kindSpec(d);\n const shape = spec.shape;\n const cfg = configOf(d);\n const key = String(d.key);\n if (shape === \"string\" || shape === \"number\" || shape === \"boolean\") {\n const out = clone(spec.value ?? {});\n for (const rule of unconditionalRules(d)) {\n const kind = rule.kind;\n const value = numberOf(rule.value);\n if (shape === \"number\" && kind === \"min\" && value !== null) out.minimum = value;\n else if (shape === \"number\" && kind === \"max\" && value !== null) out.maximum = value;\n else if (shape === \"string\" && kind === \"length\" && value !== null) out.maxLength = Math.trunc(value);\n }\n if (spec.rating && !(\"maximum\" in out)) out.maximum = M.rating_max;\n if (spec.unit && d.unit && mode === \"stored\") out[\"x-matrx-unit\"] = d.unit;\n return out;\n }\n if (shape === \"datetime\") {\n // The store casts a string to timestamptz; the pattern refuses what no cast can read.\n if (mode === \"stored\") return { type: [\"number\", \"string\"], pattern: M.stored_patterns.datetime };\n return { type: \"string\", format: cfg.kind === \"date\" ? \"date\" : \"date-time\" };\n }\n if (shape === \"choice\") {\n if (truthy(cfg.allow_other)) return { type: \"string\" };\n if (mode === \"stored\") return { type: \"string\", enum: choiceTokens(facts, key) };\n const live = liveChoiceKeys(facts, key);\n if (live.length === 0 || live.length > M.choice_enum_limit) return { type: \"string\" };\n return { type: \"string\", enum: live };\n }\n if (shape === \"relation\") {\n // custom.validate_values refuses a value that is not an id by this very regex.\n if (mode === \"stored\") return { type: \"string\", format: \"uuid\", pattern: M.stored_patterns.record_id };\n return { type: \"string\", format: \"uuid\" };\n }\n if (shape === \"entity_reference\") {\n const allowed = (Array.isArray(cfg.allowed_types) ? (cfg.allowed_types as unknown[]) : []).filter(\n (t): t is string => typeof t === \"string\",\n );\n const id: Json = { type: \"string\", format: \"uuid\" };\n if (mode === \"stored\") id.pattern = M.stored_patterns.record_id;\n const out: Json = {\n type: \"object\",\n properties: { token: { type: \"string\", enum: allowed }, id },\n required: [\"token\", \"id\"],\n };\n if (mode === \"authored\") out.additionalProperties = false;\n return out;\n }\n if (shape === \"address\") {\n const part: Json =\n mode === \"authored\"\n ? { type: \"string\", maxLength: M.address_part_max }\n : { type: [\"string\", \"null\"], maxLength: M.address_part_max };\n const out: Json = {\n type: \"object\",\n properties: Object.fromEntries(M.address_parts.map((p) => [p, { ...part }])),\n additionalProperties: false,\n };\n if (mode === \"stored\") out.minProperties = 1;\n return out;\n }\n return { readOnly: true };\n}\n\nfunction isTyped(d: Json): boolean {\n return Array.isArray(d.applies_to_types) && (d.applies_to_types as unknown[]).length > 0;\n}\n\nfunction storedValue(facts: TableKindFacts, d: Json): Json {\n const shape = kindSpec(d).shape;\n if (shape === \"computed\") return { readOnly: true };\n const one = item(facts, d, \"stored\");\n const required = truthy(d.required) && !isTyped(d);\n let value: Json;\n if (shape === \"relation\" || shape === \"entity_reference\") {\n const many: Json = { type: \"array\", items: one };\n const ceiling = numberOf(d.relation_max);\n if (ceiling !== null) many.maxItems = Math.trunc(ceiling);\n if (required) many.minItems = 1;\n value = { anyOf: [one, many] };\n } else if (truthy(d.multi)) {\n value = { type: \"array\", items: one };\n if (required) value.minItems = 1;\n } else {\n value = one;\n }\n return required ? value : { anyOf: [value, { type: \"null\" }] };\n}\n\nfunction authoredValue(facts: TableKindFacts, d: Json, typeLabels: string[]): Json {\n const spec = kindSpec(d);\n const shape = spec.shape;\n const one = item(facts, d, \"authored\");\n let value: Json;\n if (shape === \"relation\" || shape === \"entity_reference\") {\n value = { type: \"array\", items: one };\n const ceiling = numberOf(d.relation_max);\n if (ceiling !== null) value.maxItems = Math.trunc(ceiling);\n } else if (truthy(d.multi)) {\n value = { type: \"array\", items: one };\n } else {\n value = one;\n }\n const extras: string[] = [];\n if (spec.unit && d.unit) extras.push(`Amount in ${String(d.unit)}.`);\n if (spec.hint) extras.push(spec.hint);\n if (typeLabels.length > 0) extras.push(`Only for ${typeLabels.join(\", \")} records.`);\n const label = String(d.label || d.key);\n value.description = extras.length > 0 ? `${label}. ${extras.join(\" \")}` : label;\n return value;\n}\n\nfunction isAuthored(d: Json): boolean {\n const spec = kindSpec(d);\n return spec.shape !== \"computed\" && spec.authored !== false;\n}\n\nfunction typeChoice(facts: TableKindFacts, word: string) {\n for (const choice of facts.choices?.[facts.type_field ?? \"\"] ?? []) {\n if (word === choice.key || word === choice.label || word === choice.id) return choice;\n }\n return null;\n}\n\nfunction typeSynonyms(facts: TableKindFacts, word: string): [string, string[]] {\n const choice = typeChoice(facts, word);\n if (!choice) return [word, [word]];\n const out: string[] = [];\n for (const token of [choice.key, choice.label, choice.id]) {\n if (typeof token === \"string\" && token && !out.includes(token)) out.push(token);\n }\n return [String(choice.key || word), out];\n}\n\nfunction typeLabels(facts: TableKindFacts, d: Json): string[] {\n const labels: string[] = [];\n for (const word of (d.applies_to_types as unknown[]) ?? []) {\n const choice = typeChoice(facts, String(word));\n const label = choice ? String(choice.label || choice.key) : String(word);\n if (!labels.includes(label)) labels.push(label);\n }\n return labels;\n}\n\nfunction liveFields(facts: TableKindFacts): Json[] {\n return (facts.fields ?? []).filter((d): d is Json => !!d && typeof d === \"object\" && !!(d as Json).key);\n}\n\n// ── whole schemas ───────────────────────────────────────────────────────────────────────\n\n/** The Fields-only JSON Schema of a record of this Table (no control keys). */\nexport function tableJsonSchema(facts: TableKindFacts, mode: TableSchemaMode): Json {\n const slug = tableKindSlug(String(facts.table_id));\n const fields = liveFields(facts);\n const properties: Json = { [KIND_KEY]: { const: slug } };\n const required: string[] = [KIND_KEY];\n\n if (mode === \"stored\") {\n const branches = new Map<string, { if: Json; then: { required: string[]; properties: Json } }>();\n for (const d of fields) {\n const key = String(d.key);\n properties[key] = storedValue(facts, d);\n const computed = kindSpec(d).shape === \"computed\";\n if (!truthy(d.required) || computed) continue;\n if (!isTyped(d)) {\n required.push(key);\n continue;\n }\n if (!facts.type_field) continue;\n for (const word of d.applies_to_types as unknown[]) {\n const [typeKey, synonyms] = typeSynonyms(facts, String(word));\n let branch = branches.get(typeKey);\n if (!branch) {\n branch = {\n if: { properties: { [facts.type_field]: { enum: synonyms } }, required: [facts.type_field] },\n then: { required: [], properties: {} },\n };\n branches.set(typeKey, branch);\n }\n if (!branch.then.required.includes(key)) {\n branch.then.required.push(key);\n branch.then.properties[key] = { not: { type: \"null\" } };\n }\n }\n }\n const platformKeys = Array.isArray(facts.platform_keys) ? facts.platform_keys : Object.keys(M.platform_keys);\n for (const name of platformKeys) {\n // A key the platform writes into every record (custom.record_platform_keys()); a Field of\n // the same name is the column and keeps its own shape.\n if (typeof name === \"string\" && !(name in properties)) properties[name] = clone(M.platform_keys[name] ?? {});\n }\n const schema: Json = {\n type: \"object\",\n properties,\n patternProperties: { \"^_\": {} },\n required,\n };\n // custom._undeclared_key_guard judges only a `fields` Table: a free_form (document) or code\n // Table keeps any key, so its schema stays open (custom.table_column_source).\n if ((facts.column_source || M.column_source_default) === \"fields\") schema.additionalProperties = false;\n if (branches.size > 0) schema.allOf = [...branches.values()];\n return schema;\n }\n\n for (const d of fields) {\n if (!isAuthored(d)) continue;\n const key = String(d.key);\n const typed = isTyped(d);\n properties[key] = authoredValue(facts, d, typed ? typeLabels(facts, d) : []);\n if (truthy(d.required) && !typed) required.push(key);\n }\n return { type: \"object\", properties, required, additionalProperties: false };\n}\n\n/**\n * The Fields-only content-ir `KindSchema` the web draws a record of this Table with: every Field\n * nullable and optional, choices open to every word the store accepts (keys, labels, ids,\n * retired included). Wrap it with `withControlKeyFields` from @ai-matrx/content-ir — table kinds\n * never pass through `kindSchemaFromJsonSchema`.\n */\nexport function tableRenderSchema(facts: TableKindFacts): TableRenderSchema {\n const slug = tableKindSlug(String(facts.table_id));\n const out: Record<string, Record<string, unknown>> = {};\n for (const d of liveFields(facts)) {\n const key = String(d.key);\n const shape = kindSpec(d).shape;\n const multi = truthy(d.multi);\n let field: Json;\n if (shape === \"choice\") {\n field = { type: multi ? \"string[]\" : \"enum\", values: choiceTokens(facts, key) };\n if (truthy(configOf(d).allow_other)) field.open = true;\n } else {\n field = clone(M.render[shape]![multi ? \"many\" : \"one\"]);\n }\n field.nullable = true;\n out[key] = field;\n }\n return { kind: slug, fields: out };\n}\n","{\n \"about\": \"THE ONE MAPPING from a store Field to a kind's three schemas (KINDS-GLUE wave 3 §2). Hand-written here; aidream copies it verbatim to packages/matrx-graph/matrx_graph/table_kind_mapping.json (scripts/generate_table_kind_mapping.py --check). Both languages derive from this file only: @ai-matrx/records src/table-kind.ts and matrx_graph.table_kinds. Keys of `kinds` are the store's field kinds (custom.field_kinds() plus the formula `system` kinds custom.field_kind_of answers). Stored mode only: `column_source_default` is custom.table_column_source's answer when the facts carry none (silence means the doctrine: Field rows are the columns); `platform_keys` mirrors custom.record_platform_keys() with each key's shape (parent_id: custom.containment_parent's uuid cast; icon: the record's own @ai-matrx/icons name, a string or null); `stored_patterns` mirror custom.validate_values' relation id regex and, for dates, refuse a string the timestamptz cast can never read (no digits, not a special word) while never refusing one it can.\",\n \"version\": 2,\n \"kernels\": {\n \"file\": \"11111111-0000-4000-8000-000000000006\",\n \"person\": \"11111111-0000-4000-8000-000000000005\"\n },\n \"system_kinds\": [\"created_by\", \"modified_by\", \"autonumber\", \"created_time\", \"modified_time\"],\n \"by_behaviour\": {\n \"text\": \"text\",\n \"range\": \"number\",\n \"list\": \"select\",\n \"relation\": \"relation\",\n \"boolean\": \"checkbox\",\n \"formula\": \"formula\"\n },\n \"choice_enum_limit\": 100,\n \"rating_max\": 5,\n \"address_parts\": [\"street\", \"city\", \"region\", \"postal_code\", \"country\"],\n \"address_part_max\": 200,\n \"column_source_default\": \"fields\",\n \"platform_keys\": {\n \"parent_id\": { \"type\": [\"string\", \"null\"], \"pattern\": \"^(?:\\\\{[0-9a-fA-F]{4}(?:-?[0-9a-fA-F]{4}){7}\\\\}|[0-9a-fA-F]{4}(?:-?[0-9a-fA-F]{4}){7})$\" },\n \"icon\": { \"type\": [\"string\", \"null\"] }\n },\n \"stored_patterns\": {\n \"record_id\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\",\n \"datetime\": \"[0-9][^0-9]+[0-9]|[0-9]{5}|^\\\\s*(?:[Nn][Oo][Ww]|[Tt][Oo][Dd][Aa][Yy]|[Tt][Oo][Mm][Oo][Rr][Rr][Oo][Ww]|[Yy][Ee][Ss][Tt][Ee][Rr][Dd][Aa][Yy]|[Ee][Pp][Oo][Cc][Hh])(?![A-Za-z])\"\n },\n \"kinds\": {\n \"text\": { \"shape\": \"string\", \"value\": { \"type\": \"string\" } },\n \"long_text\": { \"shape\": \"string\", \"value\": { \"type\": \"string\" } },\n \"email\": { \"shape\": \"string\", \"value\": { \"type\": \"string\", \"format\": \"email\" } },\n \"phone\": { \"shape\": \"string\", \"value\": { \"type\": \"string\" } },\n \"url\": { \"shape\": \"string\", \"value\": { \"type\": \"string\" } },\n \"barcode\": { \"shape\": \"string\", \"value\": { \"type\": \"string\", \"maxLength\": 256 } },\n \"rich_text\": { \"shape\": \"string\", \"value\": { \"type\": \"string\" }, \"hint\": \"Markdown, no HTML.\" },\n \"signature\": { \"shape\": \"string\", \"value\": { \"type\": \"string\", \"readOnly\": true }, \"authored\": false },\n \"number\": { \"shape\": \"number\", \"value\": { \"type\": \"number\" } },\n \"currency\": { \"shape\": \"number\", \"value\": { \"type\": \"number\" }, \"unit\": true },\n \"percent\": { \"shape\": \"number\", \"value\": { \"type\": \"number\" }, \"hint\": \"A whole percent: 6 means 6%.\" },\n \"rating\": { \"shape\": \"number\", \"value\": { \"type\": \"integer\", \"minimum\": 0 }, \"rating\": true },\n \"duration\": { \"shape\": \"number\", \"value\": { \"type\": \"number\", \"minimum\": 0 }, \"hint\": \"A length of time in seconds.\" },\n \"datetime\": { \"shape\": \"datetime\" },\n \"checkbox\": { \"shape\": \"boolean\", \"value\": { \"type\": \"boolean\" } },\n \"select\": { \"shape\": \"choice\" },\n \"multi_select\": { \"shape\": \"choice\" },\n \"status\": { \"shape\": \"choice\" },\n \"relation\": { \"shape\": \"relation\" },\n \"member\": { \"shape\": \"relation\" },\n \"attachment\": { \"shape\": \"relation\", \"authored\": false },\n \"entity_reference\": { \"shape\": \"entity_reference\" },\n \"address\": { \"shape\": \"address\" },\n \"formula\": { \"shape\": \"computed\" },\n \"lookup\": { \"shape\": \"computed\" },\n \"rollup\": { \"shape\": \"computed\" },\n \"count\": { \"shape\": \"computed\" },\n \"created_by\": { \"shape\": \"computed\" },\n \"modified_by\": { \"shape\": \"computed\" },\n \"autonumber\": { \"shape\": \"computed\" },\n \"created_time\": { \"shape\": \"computed\" },\n \"modified_time\": { \"shape\": \"computed\" }\n },\n \"render\": {\n \"string\": { \"one\": { \"type\": \"string\" }, \"many\": { \"type\": \"string[]\" } },\n \"number\": { \"one\": { \"type\": \"number\" }, \"many\": { \"type\": \"number[]\" } },\n \"boolean\": { \"one\": { \"type\": \"boolean\" }, \"many\": { \"type\": \"boolean[]\" } },\n \"datetime\": { \"one\": { \"type\": \"union\", \"scalars\": [\"string\", \"number\"] }, \"many\": { \"type\": \"json\" } },\n \"relation\": { \"one\": { \"type\": \"json\" }, \"many\": { \"type\": \"json\" } },\n \"entity_reference\": { \"one\": { \"type\": \"json\" }, \"many\": { \"type\": \"json\" } },\n \"address\": { \"one\": { \"type\": \"json\" }, \"many\": { \"type\": \"json\" } },\n \"computed\": { \"one\": { \"type\": \"json\" }, \"many\": { \"type\": \"json\" } }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,kBAAqC;;;ACnBrC;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0,0 +1,83 @@
1
+ declare const TABLE_KIND_PREFIX = "table:";
2
+ type Json = Record<string, unknown>;
3
+ /** `custom.table_kind_facts(p_table_id)` verbatim (N1). */
4
+ interface TableKindFacts {
5
+ organization_id: string;
6
+ table_id: string;
7
+ name: string | null;
8
+ title_field: string | null;
9
+ agent_writable: boolean;
10
+ purpose: string | null;
11
+ version: number | null;
12
+ type_field: string | null;
13
+ stamp: string | null;
14
+ /** Every live Field document (typed ones included), plus `id` and `version`, in `sort` order. */
15
+ fields: Array<Record<string, unknown>>;
16
+ /** `{<list field key>: [{key, label, id, retired, position}]}`, retired included, live first. */
17
+ choices: Record<string, Array<{
18
+ key?: string | null;
19
+ label?: string | null;
20
+ id?: string | null;
21
+ retired?: boolean;
22
+ position?: number | null;
23
+ }>>;
24
+ /** `custom.table_column_source` (`fields` / `free_form` / `code`) once the door carries it; absent, the mapping's default. */
25
+ column_source?: string | null;
26
+ /** `custom.record_platform_keys()` once the door carries it; absent, the mapping's keys. */
27
+ platform_keys?: string[] | null;
28
+ }
29
+ /** The content-ir `KindSchema` shape, structurally (this package does not depend on content-ir). */
30
+ interface TableRenderSchema {
31
+ kind: string;
32
+ fields: Record<string, Record<string, unknown>>;
33
+ }
34
+ type TableSchemaMode = "stored" | "authored";
35
+ type KindSpec = {
36
+ shape: "string" | "number" | "boolean" | "datetime" | "choice" | "relation" | "entity_reference" | "address" | "computed";
37
+ value?: Json;
38
+ authored?: boolean;
39
+ unit?: boolean;
40
+ hint?: string;
41
+ rating?: boolean;
42
+ };
43
+ type Mapping = {
44
+ kernels: {
45
+ file: string;
46
+ person: string;
47
+ };
48
+ system_kinds: string[];
49
+ by_behaviour: Record<string, string>;
50
+ choice_enum_limit: number;
51
+ rating_max: number;
52
+ address_parts: string[];
53
+ address_part_max: number;
54
+ column_source_default: string;
55
+ platform_keys: Record<string, Json>;
56
+ stored_patterns: {
57
+ record_id: string;
58
+ datetime: string;
59
+ };
60
+ kinds: Record<string, KindSpec>;
61
+ render: Record<string, {
62
+ one: Json;
63
+ many: Json;
64
+ }>;
65
+ };
66
+ /** The one mapping (records' own file; the Python copy is generated from it). */
67
+ declare function tableKindMapping(): Readonly<Mapping>;
68
+ declare function isTableKind(slug: unknown): slug is `table:${string}`;
69
+ declare function tableKindSlug(tableId: string): `table:${string}`;
70
+ declare function tableIdOf(slug: string): string;
71
+ /** Twin of `custom.field_kind_of`: the field kind a stored Field document declares. */
72
+ declare function fieldKindOf(d: Record<string, unknown>): string | null;
73
+ /** The Fields-only JSON Schema of a record of this Table (no control keys). */
74
+ declare function tableJsonSchema(facts: TableKindFacts, mode: TableSchemaMode): Json;
75
+ /**
76
+ * The Fields-only content-ir `KindSchema` the web draws a record of this Table with: every Field
77
+ * nullable and optional, choices open to every word the store accepts (keys, labels, ids,
78
+ * retired included). Wrap it with `withControlKeyFields` from @ai-matrx/content-ir — table kinds
79
+ * never pass through `kindSchemaFromJsonSchema`.
80
+ */
81
+ declare function tableRenderSchema(facts: TableKindFacts): TableRenderSchema;
82
+
83
+ export { TABLE_KIND_PREFIX, type TableKindFacts, type TableRenderSchema, type TableSchemaMode, fieldKindOf, isTableKind, tableIdOf, tableJsonSchema, tableKindMapping, tableKindSlug, tableRenderSchema };