@ai-matrx/records 0.92.2 → 0.93.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 (102) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/{client-Dzd8gtAo.d.ts → client-DsPuWFp0.d.ts} +8 -8
  3. package/dist/{client-Cn3odIIB.d.cts → client-EyD3rS0T.d.cts} +8 -8
  4. package/dist/core/index.cjs +101 -32
  5. package/dist/core/index.cjs.map +1 -1
  6. package/dist/core/index.d.cts +16 -15
  7. package/dist/core/index.d.ts +16 -15
  8. package/dist/core/index.js +101 -32
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/data/index.cjs +46 -24
  11. package/dist/data/index.cjs.map +1 -1
  12. package/dist/data/index.d.cts +11 -11
  13. package/dist/data/index.d.ts +11 -11
  14. package/dist/data/index.js +46 -24
  15. package/dist/data/index.js.map +1 -1
  16. package/dist/{declareTable-CrL6AZKB.d.cts → declareTable-Bkk_Ewib.d.cts} +4 -4
  17. package/dist/{declareTable-ZRW5EsTQ.d.ts → declareTable-kL5qZoTe.d.ts} +4 -4
  18. package/dist/entity/index.cjs +43 -29
  19. package/dist/entity/index.cjs.map +1 -1
  20. package/dist/entity/index.d.cts +7 -6
  21. package/dist/entity/index.d.ts +7 -6
  22. package/dist/entity/index.js +43 -29
  23. package/dist/entity/index.js.map +1 -1
  24. package/dist/entity/react.cjs +43 -29
  25. package/dist/entity/react.cjs.map +1 -1
  26. package/dist/entity/react.js +43 -29
  27. package/dist/entity/react.js.map +1 -1
  28. package/dist/{field-CCY1rG9l.d.cts → field-6rwt4ejZ.d.cts} +1 -1
  29. package/dist/{field-enufS5ry.d.ts → field-B-WaVZnS.d.ts} +1 -1
  30. package/dist/forms/index.d.cts +3 -3
  31. package/dist/forms/index.d.ts +3 -3
  32. package/dist/index.cjs +92 -25
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +13 -33
  35. package/dist/index.d.ts +13 -33
  36. package/dist/index.js +92 -25
  37. package/dist/index.js.map +1 -1
  38. package/dist/memory/index.d.cts +7 -7
  39. package/dist/memory/index.d.ts +7 -7
  40. package/dist/objectOrganization-BII_K3Gm.d.ts +45 -0
  41. package/dist/objectOrganization-DfjDQtDb.d.cts +45 -0
  42. package/dist/{port-C54ykAOv.d.ts → port--acgmxh5.d.ts} +5 -2
  43. package/dist/{port-Drioh9al.d.cts → port-Cx76dq-X.d.cts} +5 -2
  44. package/dist/{portal-DRdmZ-xv.d.cts → portal-9sRr6cpG.d.cts} +1 -1
  45. package/dist/{portal-or_f7BkT.d.ts → portal-BDAqsGkg.d.ts} +1 -1
  46. package/dist/{ports-s0D2jvqn.d.cts → ports-9BQ3zo2y.d.cts} +108 -2
  47. package/dist/{ports-BeOgjwYl.d.ts → ports-DYWE1ENo.d.ts} +108 -2
  48. package/dist/react/index.cjs +101 -32
  49. package/dist/react/index.cjs.map +1 -1
  50. package/dist/react/index.d.cts +1463 -1363
  51. package/dist/react/index.d.ts +1463 -1363
  52. package/dist/react/index.js +101 -32
  53. package/dist/react/index.js.map +1 -1
  54. package/dist/realtime/index.cjs +43 -13
  55. package/dist/realtime/index.cjs.map +1 -1
  56. package/dist/realtime/index.d.cts +9 -3
  57. package/dist/realtime/index.d.ts +9 -3
  58. package/dist/realtime/index.js +43 -13
  59. package/dist/realtime/index.js.map +1 -1
  60. package/dist/{record-BwCf9wKW.d.cts → record-DmmeuUrC.d.cts} +1 -1
  61. package/dist/{record-BwCf9wKW.d.ts → record-DmmeuUrC.d.ts} +1 -1
  62. package/dist/{relation-eLMgv_dV.d.ts → relation-Op1M67le.d.ts} +2 -2
  63. package/dist/{relation-8vAWCa67.d.cts → relation-qrb2NbHf.d.cts} +2 -2
  64. package/dist/{rule-wHI5B0Ka.d.cts → rule-CeHg1sy1.d.cts} +1 -1
  65. package/dist/{rule-D9yNiorf.d.ts → rule-tN2lxvJ1.d.ts} +1 -1
  66. package/dist/search/index.d.cts +1 -1
  67. package/dist/search/index.d.ts +1 -1
  68. package/dist/setup/index.cjs +117 -42
  69. package/dist/setup/index.cjs.map +1 -1
  70. package/dist/setup/index.d.cts +25 -11
  71. package/dist/setup/index.d.ts +25 -11
  72. package/dist/setup/index.js +117 -42
  73. package/dist/setup/index.js.map +1 -1
  74. package/dist/{subscription-CdoI-UaB.d.cts → subscription-Drbxn-9Z.d.cts} +3 -3
  75. package/dist/{subscription-BynsG1K6.d.ts → subscription-hdTaRrfK.d.ts} +3 -3
  76. package/dist/{table-kind-i3lZJa3f.d.ts → table-kind-BZkvzBgc.d.ts} +4 -29
  77. package/dist/{table-kind-DzctQ7dO.d.cts → table-kind-C-hZxDN7.d.cts} +4 -29
  78. package/dist/templates/index.d.cts +10 -10
  79. package/dist/templates/index.d.ts +10 -10
  80. package/dist/typed-table/index.cjs +46 -24
  81. package/dist/typed-table/index.cjs.map +1 -1
  82. package/dist/typed-table/index.d.cts +10 -10
  83. package/dist/typed-table/index.d.ts +10 -10
  84. package/dist/typed-table/index.js +46 -24
  85. package/dist/typed-table/index.js.map +1 -1
  86. package/dist/{types-BvL_oKFl.d.ts → types-BauAeFW8.d.ts} +2 -2
  87. package/dist/{types-DAFP6XFe.d.cts → types-CBmUdBT0.d.cts} +2 -2
  88. package/dist/{types-BKYEeFt4.d.cts → types-Dek9owBe.d.cts} +2 -2
  89. package/dist/{types-D8qdG3Lg.d.cts → types-DsgXrESm.d.cts} +2 -2
  90. package/dist/{types-cpKY7Pjb.d.ts → types-HVgWcZDY.d.ts} +2 -2
  91. package/dist/{types-DYzXhD7j.d.ts → types-hrw-Eff1.d.ts} +2 -2
  92. package/dist/use-cases/index.d.cts +5 -5
  93. package/dist/use-cases/index.d.ts +5 -5
  94. package/dist/{validate-DfNMxjmU.d.cts → validate-B_iUeyh2.d.cts} +1 -1
  95. package/dist/{validate-DbvAParj.d.ts → validate-w-HGGTf-.d.ts} +1 -1
  96. package/dist/views/index.cjs +438 -0
  97. package/dist/views/index.cjs.map +1 -0
  98. package/dist/views/index.d.cts +401 -0
  99. package/dist/views/index.d.ts +401 -0
  100. package/dist/views/index.js +415 -0
  101. package/dist/views/index.js.map +1 -0
  102. package/package.json +13 -3
@@ -1,6 +1,6 @@
1
- import { k as PortalAccent } from '../portal-or_f7BkT.js';
2
- import { F as FormSummary, R as RuleExpression } from '../rule-D9yNiorf.js';
3
- import { U as Uuid } from '../record-BwCf9wKW.js';
1
+ import { k as PortalAccent } from '../portal-BDAqsGkg.js';
2
+ import { F as FormSummary, R as RuleExpression } from '../rule-tN2lxvJ1.js';
3
+ import { U as Uuid } from '../record-DmmeuUrC.js';
4
4
 
5
5
  /**
6
6
  * THE WORDS FOR EACH STATE, SAID ONCE, FOR EVERY SCREEN THAT SHOWS A FORM.
package/dist/index.cjs CHANGED
@@ -98,6 +98,7 @@ __export(src_exports, {
98
98
  TABLE_TYPES: () => TABLE_TYPES,
99
99
  VALUE_ALTERNATE_KEYS: () => VALUE_ALTERNATE_KEYS,
100
100
  VALUE_ENVELOPE_KEYS: () => VALUE_ENVELOPE_KEYS,
101
+ WHERE_ID_OPENS_DOOR: () => WHERE_ID_OPENS_DOOR,
101
102
  actionRefusals: () => actionRefusals,
102
103
  addressFromText: () => addressFromText,
103
104
  addressMapUrl: () => addressMapUrl,
@@ -123,8 +124,10 @@ __export(src_exports, {
123
124
  coerceTypedAnswer: () => coerceTypedAnswer,
124
125
  coerceTypedAnswers: () => coerceTypedAnswers,
125
126
  coercionLabel: () => coercionLabel,
127
+ createOpLedger: () => createOpLedger,
126
128
  decideTypedChoice: () => decideTypedChoice,
127
129
  declareDrillDefinition: () => declareDrillDefinition,
130
+ defaultOpLedger: () => defaultOpLedger,
128
131
  drillAnswerOf: () => drillAnswerOf,
129
132
  drillFindingKnob: () => drillFindingKnob,
130
133
  durationText: () => durationText,
@@ -202,6 +205,7 @@ __export(src_exports, {
202
205
  publicFormPath: () => publicFormPath,
203
206
  rankTypedMatches: () => rankTypedMatches,
204
207
  ratingMaxOf: () => ratingMaxOf,
208
+ readObjectOrganizationAnswer: () => readObjectOrganizationAnswer,
205
209
  readTypedDate: () => readTypedDate,
206
210
  readTypedDuration: () => readTypedDuration,
207
211
  readTypedNumber: () => readTypedNumber,
@@ -216,6 +220,7 @@ __export(src_exports, {
216
220
  relationNamesIn: () => relationNamesIn,
217
221
  rememberedOpCount: () => rememberedOpCount,
218
222
  removedChoicesInUse: () => removedChoicesInUse,
223
+ resolveObjectOrganization: () => resolveObjectOrganization,
219
224
  richTextPlain: () => richTextPlain,
220
225
  ruleThatRefuses: () => ruleThatRefuses,
221
226
  rulesWithTopStar: () => rulesWithTopStar,
@@ -238,6 +243,7 @@ __export(src_exports, {
238
243
  typedMatchScore: () => typedMatchScore,
239
244
  typedTimeText: () => typedTimeText,
240
245
  valueConverts: () => valueConverts,
246
+ whereIdOpensPort: () => whereIdOpensPort,
241
247
  withCallersClock: () => withCallersClock,
242
248
  withRowCounts: () => withRowCounts,
243
249
  withTablePlacement: () => withTablePlacement
@@ -2477,44 +2483,105 @@ function sourceArchivedOf(value) {
2477
2483
  return out;
2478
2484
  }
2479
2485
 
2486
+ // src/objectOrganization.ts
2487
+ var WHERE_ID_OPENS_DOOR = "where_id_opens";
2488
+ function doorIsAbsent(error) {
2489
+ if (error.code === "PGRST202" || error.code === "42883") return true;
2490
+ return /could not find the function/i.test(error.message ?? "");
2491
+ }
2492
+ var DOOR_ABSENT_WHY = "custom.where_id_opens is missing from this database, so this page cannot tell which organization the record lives in and holds instead of guessing. Remedy: the chair applies migrations/campaign/openbyid_one_address_opens_any_id.sql and openbyid_the_resolver_can_be_reached.sql.";
2493
+ async function resolveObjectOrganization(dataSource, id) {
2494
+ let answered;
2495
+ try {
2496
+ answered = await dataSource.rpc(WHERE_ID_OPENS_DOOR, { p_id: id }, { schema: "custom" });
2497
+ } catch (thrown) {
2498
+ return { state: "unavailable", why: thrown instanceof Error ? thrown.message : "The record store did not answer." };
2499
+ }
2500
+ return readObjectOrganizationAnswer(answered, id);
2501
+ }
2502
+ function readObjectOrganizationAnswer(answered, id) {
2503
+ if (answered.error) {
2504
+ if (doorIsAbsent(answered.error)) {
2505
+ console.warn(`[@ai-matrx/records] ${DOOR_ABSENT_WHY}`);
2506
+ return { state: "unavailable", why: DOOR_ABSENT_WHY };
2507
+ }
2508
+ return { state: "unavailable", why: answered.error.message ?? "The record store refused to say where this is." };
2509
+ }
2510
+ const row = answered.data;
2511
+ if (row === null || row === void 0) return { state: "not-given" };
2512
+ if (typeof row !== "object" || typeof row.organization_id !== "string" || typeof row.kind !== "string") {
2513
+ return { state: "unavailable", why: "The record store answered something this page cannot read." };
2514
+ }
2515
+ return {
2516
+ state: "found",
2517
+ organizationId: row.organization_id,
2518
+ kind: row.kind,
2519
+ path: typeof row.path === "string" ? row.path : null,
2520
+ live: row.live !== false,
2521
+ resolvedId: typeof row.resolved_id === "string" ? row.resolved_id : id
2522
+ };
2523
+ }
2524
+ function whereIdOpensPort(dataSource) {
2525
+ return { organizationOf: (id) => resolveObjectOrganization(dataSource, id) };
2526
+ }
2527
+
2480
2528
  // src/ops.ts
2481
2529
  var import_global_slot = require("@ai-matrx/kit/global-slot");
2482
2530
  var REMEMBER_MS = 3e4;
2483
2531
  var REMEMBER_MAX = 500;
2484
- var ours = (0, import_global_slot.globalSlot)("ai-matrx.records.op-ledger", () => /* @__PURE__ */ new Map());
2485
- function trim(now) {
2486
- for (const [id, at] of ours) {
2487
- if (now - at <= REMEMBER_MS) break;
2488
- ours.delete(id);
2489
- }
2490
- while (ours.size > REMEMBER_MAX) {
2491
- const oldest = ours.keys().next();
2492
- if (oldest.done === true) break;
2493
- ours.delete(oldest.value);
2532
+ function ledgerOver(ours) {
2533
+ function trim(now) {
2534
+ for (const [id, at] of ours) {
2535
+ if (now - at <= REMEMBER_MS) break;
2536
+ ours.delete(id);
2537
+ }
2538
+ while (ours.size > REMEMBER_MAX) {
2539
+ const oldest = ours.keys().next();
2540
+ if (oldest.done === true) break;
2541
+ ours.delete(oldest.value);
2542
+ }
2494
2543
  }
2544
+ return {
2545
+ mint() {
2546
+ const id = crypto.randomUUID();
2547
+ const now = Date.now();
2548
+ ours.set(id, now);
2549
+ trim(now);
2550
+ return id;
2551
+ },
2552
+ isOwn(opId) {
2553
+ if (!opId) return false;
2554
+ const at = ours.get(opId);
2555
+ if (at === void 0) return false;
2556
+ if (Date.now() - at > REMEMBER_MS) {
2557
+ ours.delete(opId);
2558
+ return false;
2559
+ }
2560
+ return true;
2561
+ },
2562
+ clear() {
2563
+ ours.clear();
2564
+ },
2565
+ get size() {
2566
+ return ours.size;
2567
+ }
2568
+ };
2569
+ }
2570
+ function createOpLedger() {
2571
+ return ledgerOver(/* @__PURE__ */ new Map());
2495
2572
  }
2573
+ var defaultOpLedger = ledgerOver((0, import_global_slot.globalSlot)("ai-matrx.records.op-ledger", () => /* @__PURE__ */ new Map()));
2496
2574
  function mintOpId() {
2497
- const id = crypto.randomUUID();
2498
- const now = Date.now();
2499
- ours.set(id, now);
2500
- trim(now);
2501
- return id;
2575
+ return defaultOpLedger.mint();
2502
2576
  }
2503
2577
  function isOwnOp(opId) {
2504
- if (!opId) return false;
2505
- const at = ours.get(opId);
2506
- if (at === void 0) return false;
2507
- if (Date.now() - at > REMEMBER_MS) {
2508
- ours.delete(opId);
2509
- return false;
2510
- }
2511
- return true;
2578
+ return defaultOpLedger.isOwn(opId);
2512
2579
  }
2513
2580
  function forgetAllOps() {
2514
- ours.clear();
2581
+ defaultOpLedger.clear();
2515
2582
  }
2516
2583
  function rememberedOpCount() {
2517
- return ours.size;
2584
+ return defaultOpLedger.size;
2518
2585
  }
2519
2586
 
2520
2587
  // src/store.generated.ts