@ai-matrx/records 0.55.1 → 0.56.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/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -65,6 +75,7 @@ __export(src_exports, {
65
75
  TABLE_TYPES: () => TABLE_TYPES,
66
76
  VALUE_ALTERNATE_KEYS: () => VALUE_ALTERNATE_KEYS,
67
77
  VALUE_ENVELOPE_KEYS: () => VALUE_ENVELOPE_KEYS,
78
+ actionRefusals: () => actionRefusals,
68
79
  archivedByLine: () => archivedByLine,
69
80
  archivedWhen: () => archivedWhen,
70
81
  asPermissionLevel: () => asPermissionLevel,
@@ -79,6 +90,8 @@ __export(src_exports, {
79
90
  emptyArchiveLine: () => emptyArchiveLine,
80
91
  emptyPortalArchiveLine: () => emptyPortalArchiveLine,
81
92
  err: () => err,
93
+ exampleSpec: () => exampleSpec,
94
+ exportPageXlsx: () => exportPageXlsx,
82
95
  fieldKindFor: () => fieldKindFor,
83
96
  forgetAllOps: () => forgetAllOps,
84
97
  highestLevel: () => highestLevel,
@@ -339,6 +352,7 @@ function fieldKindFor(field, kernel) {
339
352
  return "text";
340
353
  }
341
354
  }
355
+ var UUID_TEXT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
342
356
  var TRUE_WORDS = /* @__PURE__ */ new Set(["true", "yes", "y", "1", "\u2713", "x", "checked", "on"]);
343
357
  var FALSE_WORDS = /* @__PURE__ */ new Set(["false", "no", "n", "0", "", "unchecked", "off"]);
344
358
  function coercionLabel(field) {
@@ -430,11 +444,23 @@ function coerceTypedAnswer(field, raw, opts = {}) {
430
444
  // id belongs, and every filter, colour and rollup built on that column
431
445
  // would stop agreeing with it. So it is refused and the person is told
432
446
  // which control does hold it.
447
+ //
448
+ // BUT AN ID IS AN IDENTITY (RELATION-TARGETS, 2026-09-23). A Person or File
449
+ // column holds the kernel Person / File record, and the store itself now
450
+ // turns the id a writer actually holds — a member's user id, an uploaded
451
+ // file's id, or the record's own id — into that record at every write door
452
+ // (`custom.relation_kernel_record`), refusing anything else in its own
453
+ // words ("… names someone who is not a member of …"). So an import column
454
+ // of member ids, or an agent handing over the file it just uploaded, is a
455
+ // value and not a refusal; the store, not this mirror, decides whether the
456
+ // id is somebody here.
433
457
  case "member":
458
+ if (UUID_TEXT.test(text)) return { value: text.toLowerCase() };
434
459
  return {
435
460
  refusal: `${label} names a person in this organization, so it is chosen rather than typed. Open it and pick them.`
436
461
  };
437
462
  case "attachment":
463
+ if (UUID_TEXT.test(text)) return { value: text.toLowerCase() };
438
464
  return {
439
465
  refusal: `${label} holds a file, which cannot arrive as typed-in text. Open it and attach the file.`
440
466
  };
@@ -539,6 +565,80 @@ function stableFilterKey(filter) {
539
565
  return `{${parts.join(",")}}`;
540
566
  }
541
567
 
568
+ // src/grid.ts
569
+ function actionRefusals(error) {
570
+ return Array.isArray(error.detail) ? error.detail : [];
571
+ }
572
+ function exampleSpec(useCase) {
573
+ return {
574
+ business: useCase.business.name,
575
+ tables: useCase.tables.map((t) => ({
576
+ token: t.token,
577
+ name: t.name,
578
+ labelSingular: t.labelSingular,
579
+ labelPlural: t.labelPlural,
580
+ type: t.type,
581
+ display: t.display,
582
+ weight: t.weight,
583
+ ordered: t.ordered,
584
+ titleField: t.titleField,
585
+ describes: t.describes,
586
+ fields: t.fields.map((f) => ({
587
+ key: f.key,
588
+ label: f.label,
589
+ parityType: f.parityType,
590
+ multi: f.multi,
591
+ dated: f.dated,
592
+ required: f.required,
593
+ unit: f.unit ?? void 0,
594
+ rules: f.rules,
595
+ choices: f.choices,
596
+ source: f.source,
597
+ computeOn: f.computeOn,
598
+ relationTarget: f.relationTarget,
599
+ relationMax: f.relationMax,
600
+ sensitivity: f.sensitivity,
601
+ contextPolicy: f.contextPolicy
602
+ })),
603
+ rows: t.rows
604
+ }))
605
+ };
606
+ }
607
+ function exportCellText(value) {
608
+ if (value === null || value === void 0) return "";
609
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
610
+ return JSON.stringify(value);
611
+ }
612
+ async function exportPageXlsx(page, labels = {}, sheetLabel = "Records") {
613
+ const XLSX = await import("xlsx");
614
+ const header = page.columns.map((c) => labels[c] ?? c);
615
+ const body = page.rows.map((row) => page.columns.map((c) => exportCellText(row[c])));
616
+ const workbook = XLSX.utils.book_new();
617
+ const name = sheetLabel.replace(/[\\/?*[\]:]/g, " ").trim().slice(0, 31) || "Records";
618
+ XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet([header, ...body]), name);
619
+ const withheld = Object.entries(page.withheld ?? {});
620
+ if (withheld.length > 0) {
621
+ XLSX.utils.book_append_sheet(
622
+ workbook,
623
+ XLSX.utils.aoa_to_sheet([
624
+ ["Column", "Why it is empty in this export"],
625
+ ...withheld.map(([k, v]) => [labels[k] ?? k, typeof v === "string" ? v : JSON.stringify(v)])
626
+ ]),
627
+ "Withheld columns"
628
+ );
629
+ }
630
+ if (page.page?.next !== null && page.page?.next !== void 0) {
631
+ XLSX.utils.book_append_sheet(
632
+ workbook,
633
+ XLSX.utils.aoa_to_sheet([[
634
+ `This file holds the first ${page.page.returned} rows. The table has more; export again from row ${page.page.next + 1}.`
635
+ ]]),
636
+ "More rows"
637
+ );
638
+ }
639
+ return XLSX.write(workbook, { type: "array", bookType: "xlsx", compression: true });
640
+ }
641
+
542
642
  // src/capture-queue.ts
543
643
  var DB_NAME = "matrx-capture";
544
644
  var DB_VERSION = 1;