@ai-matrx/records 0.99.31 → 0.99.33
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/CHANGELOG.md +21 -0
- package/dist/{client-Dthx26hr.d.ts → client-CSfkP7Xf.d.ts} +11 -80
- package/dist/{client-B7KEs9hi.d.cts → client-jKf1Z-kp.d.cts} +11 -80
- package/dist/core/index.cjs +149 -105
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +18 -359
- package/dist/core/index.d.ts +18 -359
- package/dist/core/index.js +149 -105
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +280 -236
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +12 -11
- package/dist/data/index.d.ts +12 -11
- package/dist/data/index.js +280 -236
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-CvBu5dTJ.d.ts → declareTable-0emxEewn.d.ts} +3 -3
- package/dist/{declareTable-enQs2N0E.d.cts → declareTable-800bwUn3.d.cts} +3 -3
- package/dist/door-call/index.cjs +1287 -0
- package/dist/door-call/index.cjs.map +1 -0
- package/dist/door-call/index.d.cts +20 -0
- package/dist/door-call/index.d.ts +20 -0
- package/dist/door-call/index.js +1264 -0
- package/dist/door-call/index.js.map +1 -0
- package/dist/{doors-KbjyhBW-.d.cts → doors-BgjRUdxw.d.cts} +14 -2
- package/dist/{doors-C2-sFvAk.d.ts → doors-D7_jEKtg.d.ts} +14 -2
- package/dist/entity/index.d.cts +7 -7
- package/dist/entity/index.d.ts +7 -7
- package/dist/{field-ppX29ddi.d.cts → field-B8loYt-A.d.cts} +1 -1
- package/dist/{field-BHlhq24W.d.ts → field-DaE90BZ7.d.ts} +1 -1
- package/dist/forms/index.d.cts +3 -3
- package/dist/forms/index.d.ts +3 -3
- package/dist/index.d.cts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/memory/index.d.cts +7 -7
- package/dist/memory/index.d.ts +7 -7
- package/dist/{objectOrganization-Cu73SBxH.d.cts → objectOrganization-B5YFGVUB.d.cts} +2 -2
- package/dist/{objectOrganization-DtR3lWG2.d.ts → objectOrganization-DozoVIxS.d.ts} +2 -2
- package/dist/pickListDoors-C-_eAEGL.d.cts +135 -0
- package/dist/pickListDoors-DgWVnNRI.d.ts +135 -0
- package/dist/{port-Bk7TG0aE.d.ts → port-D6wepPvr.d.ts} +3 -3
- package/dist/{port-rqQEGhew.d.cts → port-O-UdH1HS.d.cts} +3 -3
- package/dist/{portal-DmxuUr2f.d.ts → portal-CAssJHRZ.d.ts} +1 -1
- package/dist/{portal-ffH13fsE.d.cts → portal-L_mN8l9P.d.cts} +1 -1
- package/dist/{ports-BCNNghmf.d.ts → ports-CmmvR8OI.d.ts} +2 -2
- package/dist/{ports-iATV-A2v.d.cts → ports-alv3bgKY.d.cts} +2 -2
- package/dist/questions/index.d.cts +10 -9
- package/dist/questions/index.d.ts +10 -9
- package/dist/react/index.cjs +363 -319
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +37 -22
- package/dist/react/index.d.ts +37 -22
- package/dist/react/index.js +363 -319
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.d.cts +3 -3
- package/dist/realtime/index.d.ts +3 -3
- package/dist/{record-C8q21jjB.d.cts → record-CTgSgWe3.d.cts} +1 -1
- package/dist/{record-C8q21jjB.d.ts → record-CTgSgWe3.d.ts} +1 -1
- package/dist/{relation-Bwp8iuei.d.cts → relation-BjjjXyqn.d.cts} +2 -2
- package/dist/{relation-Bsjwkn6N.d.ts → relation-T4biacnz.d.ts} +2 -2
- package/dist/results/index.cjs +245 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.d.cts +24 -0
- package/dist/results/index.d.ts +24 -0
- package/dist/results/index.js +222 -0
- package/dist/results/index.js.map +1 -0
- package/dist/{rule-BQwUtKk5.d.cts → rule-49jO7lN-.d.cts} +1 -1
- package/dist/{rule-cGqclk_0.d.ts → rule-DzNj0QvN.d.ts} +1 -1
- package/dist/scopes/index.cjs +7 -0
- package/dist/scopes/index.cjs.map +1 -1
- package/dist/scopes/index.d.cts +3 -3
- package/dist/scopes/index.d.ts +3 -3
- package/dist/scopes/index.js +7 -0
- package/dist/scopes/index.js.map +1 -1
- package/dist/search/index.d.cts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/setup/index.cjs +289 -245
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +13 -12
- package/dist/setup/index.d.ts +13 -12
- package/dist/setup/index.js +289 -245
- package/dist/setup/index.js.map +1 -1
- package/dist/{subscription-eNzL9scc.d.ts → subscription-Bp1RSb6p.d.ts} +2 -2
- package/dist/{subscription-Ba8RKtPA.d.cts → subscription-CuaGi3lC.d.cts} +2 -2
- package/dist/table-logic-BPquabNN.d.ts +328 -0
- package/dist/table-logic-CTh6lwaq.d.cts +328 -0
- package/dist/templates/index.d.cts +10 -10
- package/dist/templates/index.d.ts +10 -10
- package/dist/typed-table/index.cjs +280 -236
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +11 -10
- package/dist/typed-table/index.d.ts +11 -10
- package/dist/typed-table/index.js +280 -236
- package/dist/typed-table/index.js.map +1 -1
- package/dist/{types-C4XCuv8O.d.cts → types-B54BeQzf.d.cts} +2 -2
- package/dist/{types-BlzdL4Vd.d.cts → types-BWfL38XJ.d.cts} +2 -2
- package/dist/{types-BBR2NGqj.d.ts → types-BZcYXFK3.d.ts} +2 -2
- package/dist/{types-EKwXJfxY.d.cts → types-Bztv0-pH.d.cts} +2 -2
- package/dist/{types-CmkHpvll.d.ts → types-CjGuR5ks.d.ts} +2 -2
- package/dist/{types-CrkzINrb.d.ts → types-bN7dG2ji.d.ts} +2 -2
- package/dist/use-cases/index.d.cts +5 -5
- package/dist/use-cases/index.d.ts +5 -5
- package/dist/{validate-BKeBAVSi.d.cts → validate-8VBa2xIU.d.cts} +1 -1
- package/dist/{validate-BB6DWgCP.d.ts → validate-xBnply7J.d.ts} +1 -1
- package/dist/views/index.d.cts +10 -9
- package/dist/views/index.d.ts +10 -9
- package/package.json +24 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-
|
|
2
|
-
export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-
|
|
3
|
-
import { c as AggregateMeasure, b as AggregateFilter } from '../subscription-
|
|
4
|
-
import { U as UseCase, o as UseCaseRelationship } from '../types-
|
|
5
|
-
import { U as UseCaseProblem } from '../validate-
|
|
6
|
-
export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-
|
|
7
|
-
import { d as RecordsDataSource } from '../ports-
|
|
8
|
-
import '../record-
|
|
9
|
-
import '../rule-
|
|
10
|
-
import '../field-
|
|
1
|
+
import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-BWfL38XJ.cjs';
|
|
2
|
+
export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-BWfL38XJ.cjs';
|
|
3
|
+
import { c as AggregateMeasure, b as AggregateFilter } from '../subscription-CuaGi3lC.cjs';
|
|
4
|
+
import { U as UseCase, o as UseCaseRelationship } from '../types-Bztv0-pH.cjs';
|
|
5
|
+
import { U as UseCaseProblem } from '../validate-8VBa2xIU.cjs';
|
|
6
|
+
export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-8VBa2xIU.cjs';
|
|
7
|
+
import { d as RecordsDataSource } from '../ports-alv3bgKY.cjs';
|
|
8
|
+
import '../record-CTgSgWe3.cjs';
|
|
9
|
+
import '../rule-49jO7lN-.cjs';
|
|
10
|
+
import '../field-B8loYt-A.cjs';
|
|
11
11
|
|
|
12
12
|
/** The UTC offset ("-04:00") of a local wall-clock moment in an IANA zone. */
|
|
13
13
|
declare function zoneOffset(localIso: string, timeZone: string): string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-
|
|
2
|
-
export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-
|
|
3
|
-
import { c as AggregateMeasure, b as AggregateFilter } from '../subscription-
|
|
4
|
-
import { U as UseCase, o as UseCaseRelationship } from '../types-
|
|
5
|
-
import { U as UseCaseProblem } from '../validate-
|
|
6
|
-
export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-
|
|
7
|
-
import { d as RecordsDataSource } from '../ports-
|
|
8
|
-
import '../record-
|
|
9
|
-
import '../rule-
|
|
10
|
-
import '../field-
|
|
1
|
+
import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-BZcYXFK3.js';
|
|
2
|
+
export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-BZcYXFK3.js';
|
|
3
|
+
import { c as AggregateMeasure, b as AggregateFilter } from '../subscription-Bp1RSb6p.js';
|
|
4
|
+
import { U as UseCase, o as UseCaseRelationship } from '../types-CjGuR5ks.js';
|
|
5
|
+
import { U as UseCaseProblem } from '../validate-xBnply7J.js';
|
|
6
|
+
export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-xBnply7J.js';
|
|
7
|
+
import { d as RecordsDataSource } from '../ports-CmmvR8OI.js';
|
|
8
|
+
import '../record-CTgSgWe3.js';
|
|
9
|
+
import '../rule-DzNj0QvN.js';
|
|
10
|
+
import '../field-DaE90BZ7.js';
|
|
11
11
|
|
|
12
12
|
/** The UTC offset ("-04:00") of a local wall-clock moment in an IANA zone. */
|
|
13
13
|
declare function zoneOffset(localIso: string, timeZone: string): string;
|
|
@@ -391,137 +391,6 @@ function isWritingDoor(door) {
|
|
|
391
391
|
return /(_declare|_set(_|$)|_update|_write|_delete|_restore|_archive|_upsert|_reparent|_change|_duplicate|_move|_decide|_run$|_submit|_publish|_import_|_start$|_complete|_sign$|_add$|_retire|_propose|_promote|_land$|_pin$|_mute|_snooze|_unsnooze|_clear|_unclear|_revoke|_issue|_bind|_unbind|_apply|_backfill|_sync$|_decorate|_designate|_ensure|^migrate_|^set_table_|^home_add|^capture_|^claim_|^record_stage|^anon_|^io_import_|^io_comment_resolve|^enrich_(declare|land|pin)|^field_(declare|duplicate|propose|restore|retire|update)|^table_(declare|ensure|from_example|move|sync)|^value_restore|^relation_own)/.test(door);
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
// src/core/recordChanges.ts
|
|
395
|
-
var import_global_slot = require("@ai-matrx/kit/global-slot");
|
|
396
|
-
var listeners = (0, import_global_slot.globalSlot)("ai-matrx.records.record-change-listeners", () => /* @__PURE__ */ new Set());
|
|
397
|
-
function announceRecordChanged(recordId) {
|
|
398
|
-
for (const listener of [...listeners]) {
|
|
399
|
-
try {
|
|
400
|
-
listener(recordId);
|
|
401
|
-
} catch (thrown) {
|
|
402
|
-
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
var removed = (0, import_global_slot.globalSlot)("ai-matrx.records.removed-records", () => /* @__PURE__ */ new Set());
|
|
407
|
-
function markRecordRemoved(recordId) {
|
|
408
|
-
removed.add(recordId);
|
|
409
|
-
}
|
|
410
|
-
function markRecordRestored(recordId) {
|
|
411
|
-
removed.delete(recordId);
|
|
412
|
-
}
|
|
413
|
-
function onRecordChanged(listener) {
|
|
414
|
-
listeners.add(listener);
|
|
415
|
-
return () => listeners.delete(listener);
|
|
416
|
-
}
|
|
417
|
-
var tableListeners = (0, import_global_slot.globalSlot)("ai-matrx.records.table-structure-listeners", () => /* @__PURE__ */ new Set());
|
|
418
|
-
function announceTableStructureChanged(tableId) {
|
|
419
|
-
for (const listener of [...tableListeners]) {
|
|
420
|
-
try {
|
|
421
|
-
listener(tableId);
|
|
422
|
-
} catch (thrown) {
|
|
423
|
-
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// src/archive.ts
|
|
429
|
-
var DEFAULT_ARCHIVE_LANE = "org";
|
|
430
|
-
|
|
431
|
-
// src/aggregate.ts
|
|
432
|
-
function isRuleFilter(filter) {
|
|
433
|
-
if (!filter || typeof filter !== "object" || Array.isArray(filter)) return false;
|
|
434
|
-
const node = filter;
|
|
435
|
-
return typeof node.op === "string" && Array.isArray(node.args);
|
|
436
|
-
}
|
|
437
|
-
function stableFilterKey(filter) {
|
|
438
|
-
if (!filter) return "{}";
|
|
439
|
-
if (isRuleFilter(filter)) return JSON.stringify(filter);
|
|
440
|
-
const keys = Object.keys(filter).sort();
|
|
441
|
-
if (keys.length === 0) return "{}";
|
|
442
|
-
const parts = keys.map((key) => {
|
|
443
|
-
const value = filter[key];
|
|
444
|
-
if (value !== null && typeof value === "object") {
|
|
445
|
-
const window = value;
|
|
446
|
-
return `${JSON.stringify(key)}:{"from":${JSON.stringify(window.from ?? null)},"to":${JSON.stringify(window.to ?? null)}}`;
|
|
447
|
-
}
|
|
448
|
-
return `${JSON.stringify(key)}:${JSON.stringify(value ?? null)}`;
|
|
449
|
-
});
|
|
450
|
-
return `{${parts.join(",")}}`;
|
|
451
|
-
}
|
|
452
|
-
function liftWithheld(rows) {
|
|
453
|
-
let shared;
|
|
454
|
-
for (const row of rows) {
|
|
455
|
-
const m = (row.measures ?? {})["_withheld"];
|
|
456
|
-
if (m !== void 0 && m !== null && typeof m === "object") {
|
|
457
|
-
shared = m;
|
|
458
|
-
break;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return rows.map((row) => {
|
|
462
|
-
const measures = row.measures ?? {};
|
|
463
|
-
const own = measures["_withheld"];
|
|
464
|
-
const marker = own !== void 0 && own !== null && typeof own === "object" ? own : shared;
|
|
465
|
-
const rowCount = row.row_count ?? 0;
|
|
466
|
-
if (marker === void 0 || marker === null || typeof marker !== "object") {
|
|
467
|
-
return rowCount === row.row_count ? row : { ...row, row_count: rowCount };
|
|
468
|
-
}
|
|
469
|
-
const { _withheld: _drop, ...rest } = measures;
|
|
470
|
-
const withheld = {};
|
|
471
|
-
for (const [name, raw] of Object.entries(marker)) {
|
|
472
|
-
const m = raw ?? {};
|
|
473
|
-
withheld[name] = {
|
|
474
|
-
reason: m.withheld?.reason ?? null,
|
|
475
|
-
needs: m.withheld?.needs ?? null,
|
|
476
|
-
or: m.withheld?.or ?? null,
|
|
477
|
-
...m.says ? { says: m.says } : {},
|
|
478
|
-
...m.label ? { label: m.label } : {},
|
|
479
|
-
...m.field_key ? { field_key: m.field_key } : {}
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
return { ...row, measures: rest, withheld, row_count: rowCount };
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// src/record.ts
|
|
487
|
-
function isLockedStub(row) {
|
|
488
|
-
if (!row) return false;
|
|
489
|
-
if (row.level !== null && row.level !== void 0) return false;
|
|
490
|
-
const doc = row.document;
|
|
491
|
-
if (!doc || typeof doc !== "object") return false;
|
|
492
|
-
const keys = Object.keys(doc);
|
|
493
|
-
if (keys.length === 0 || keys.length > 3) return false;
|
|
494
|
-
const d = doc;
|
|
495
|
-
return d["exists"] === true && keys.every((k) => k === "id" || k === "exists" || k === "submitted_at");
|
|
496
|
-
}
|
|
497
|
-
function splitLockedRows(rows) {
|
|
498
|
-
const open = [];
|
|
499
|
-
let locked = 0;
|
|
500
|
-
for (const row of rows) {
|
|
501
|
-
if (isLockedStub(row)) locked += 1;
|
|
502
|
-
else open.push(row);
|
|
503
|
-
}
|
|
504
|
-
return { rows: open, locked };
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// src/subscription.ts
|
|
508
|
-
function callersTimeZone() {
|
|
509
|
-
try {
|
|
510
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
511
|
-
} catch {
|
|
512
|
-
return null;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
function withCallersClock(spec, zone = callersTimeZone()) {
|
|
516
|
-
if (!zone || spec.quiet_hours?.tz) return spec;
|
|
517
|
-
return { ...spec, quiet_hours: { ...spec.quiet_hours ?? {}, tz: zone } };
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// src/rowLabel.ts
|
|
521
|
-
function clearsRowLabel(formula) {
|
|
522
|
-
return formula == null || formula.trim() === "";
|
|
523
|
-
}
|
|
524
|
-
|
|
525
394
|
// src/results.ts
|
|
526
395
|
var ok = (data) => ({ ok: true, data });
|
|
527
396
|
var err = (error) => ({ ok: false, error });
|
|
@@ -692,6 +561,230 @@ function mapPgError(error, where) {
|
|
|
692
561
|
return mapped;
|
|
693
562
|
}
|
|
694
563
|
|
|
564
|
+
// src/core/doorCall.ts
|
|
565
|
+
var DEFAULT_DOOR_SCHEMA = "custom";
|
|
566
|
+
function canonicalArgs(value) {
|
|
567
|
+
return JSON.stringify(
|
|
568
|
+
value,
|
|
569
|
+
(_key, held) => held && typeof held === "object" && !Array.isArray(held) ? Object.fromEntries(Object.keys(held).sort().map((k) => [k, held[k]])) : held
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
|
|
573
|
+
"refused_by_rule",
|
|
574
|
+
"stale_write",
|
|
575
|
+
"invalid_argument",
|
|
576
|
+
"already_exists",
|
|
577
|
+
"missing_reference"
|
|
578
|
+
]);
|
|
579
|
+
function isAPersonsRefusal(code) {
|
|
580
|
+
return A_PERSONS_REFUSAL.has(code);
|
|
581
|
+
}
|
|
582
|
+
function recordsErrorSink(onError) {
|
|
583
|
+
return onError ?? ((e) => {
|
|
584
|
+
const line = `[@ai-matrx/records] ${e.where}: ${e.code} \u2014 ${e.message}${e.hint ? ` (${e.hint})` : ""}`;
|
|
585
|
+
if (isAPersonsRefusal(e.code)) console.info(line);
|
|
586
|
+
else console.error(line);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function doorAbsentRefusal(name, owedBy) {
|
|
590
|
+
return {
|
|
591
|
+
code: "door_absent",
|
|
592
|
+
message: `The record store has no door \`custom.${name}\` yet, so this call was not made. Nothing was read and nothing was written.`,
|
|
593
|
+
hint: owedBy ? `That door is ${owedBy}. Until it lands, this call refuses rather than guessing: an empty answer here would read like "there is nothing", which is a different sentence.` : `No lane in the build book claims this door. Either the name is wrong, or the door was removed from the store and this package has not been regenerated \u2014 run \`pnpm records:generate\`.`
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function primedDoorAnswer(door, args) {
|
|
597
|
+
const look = LOOK_WRITES[door];
|
|
598
|
+
if (look) {
|
|
599
|
+
dropPrimedDoorAnswers(look);
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
if (isWritingDoor(door)) {
|
|
603
|
+
dropPrimedDoorAnswers();
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
|
|
607
|
+
}
|
|
608
|
+
function createDoorCall(options) {
|
|
609
|
+
const { dataSource, doorReady: doorReady2, held, wrote } = options;
|
|
610
|
+
const schema = options.schema ?? DEFAULT_DOOR_SCHEMA;
|
|
611
|
+
const scream = recordsErrorSink(options.onError);
|
|
612
|
+
const absent = options.absent ?? ((door) => doorAbsentRefusal(door));
|
|
613
|
+
const readsInFlight = /* @__PURE__ */ new Map();
|
|
614
|
+
const say = (refusal2, where) => scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
|
|
615
|
+
return async function callDoor(door, args, where, opts) {
|
|
616
|
+
const primed = primedDoorAnswer(door, args);
|
|
617
|
+
if (primed) return ok(primed.data);
|
|
618
|
+
if (held) {
|
|
619
|
+
const bundled = await held(door, args);
|
|
620
|
+
if (bundled) return ok(bundled.data);
|
|
621
|
+
}
|
|
622
|
+
if (doorReady2 && !doorReady2(door)) {
|
|
623
|
+
const refusal2 = absent(door);
|
|
624
|
+
say(refusal2, where);
|
|
625
|
+
return err(refusal2);
|
|
626
|
+
}
|
|
627
|
+
const flightKey = isWritingDoor(door) ? null : `${door}|${canonicalArgs(args)}`;
|
|
628
|
+
const flying = flightKey ? readsInFlight.get(flightKey) : void 0;
|
|
629
|
+
const response = await (flying ?? (() => {
|
|
630
|
+
const call = Promise.resolve(dataSource.rpc(`${door}`, args, { schema }));
|
|
631
|
+
if (flightKey) {
|
|
632
|
+
readsInFlight.set(flightKey, call);
|
|
633
|
+
const forget = () => {
|
|
634
|
+
if (readsInFlight.get(flightKey) === call) readsInFlight.delete(flightKey);
|
|
635
|
+
};
|
|
636
|
+
call.then(forget, forget);
|
|
637
|
+
}
|
|
638
|
+
return call;
|
|
639
|
+
})());
|
|
640
|
+
if (response.error) {
|
|
641
|
+
const code = response.error.code;
|
|
642
|
+
const refusal2 = !doorReady2 && (code === "PGRST202" || code === "42883") ? absent(door) : mapPgError(response.error, where);
|
|
643
|
+
if (opts?.quiet) console.info(`[@ai-matrx/records] ${where}: ${refusal2.code} - ${refusal2.message}`);
|
|
644
|
+
else say(refusal2, where);
|
|
645
|
+
return err(refusal2);
|
|
646
|
+
}
|
|
647
|
+
if (isWritingDoor(door) || LOOK_WRITES[door]) {
|
|
648
|
+
const tableId = args["p_table_id"];
|
|
649
|
+
wrote?.(door, args);
|
|
650
|
+
forgetPrimedTablePageBundlesOf(typeof tableId === "string" ? tableId : null);
|
|
651
|
+
dropPrimedDoorAnswers(LOOK_WRITES[door]);
|
|
652
|
+
}
|
|
653
|
+
return ok(response.data);
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/core/recordChanges.ts
|
|
658
|
+
var import_global_slot = require("@ai-matrx/kit/global-slot");
|
|
659
|
+
var listeners = (0, import_global_slot.globalSlot)("ai-matrx.records.record-change-listeners", () => /* @__PURE__ */ new Set());
|
|
660
|
+
function announceRecordChanged(recordId) {
|
|
661
|
+
for (const listener of [...listeners]) {
|
|
662
|
+
try {
|
|
663
|
+
listener(recordId);
|
|
664
|
+
} catch (thrown) {
|
|
665
|
+
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
var removed = (0, import_global_slot.globalSlot)("ai-matrx.records.removed-records", () => /* @__PURE__ */ new Set());
|
|
670
|
+
function markRecordRemoved(recordId) {
|
|
671
|
+
removed.add(recordId);
|
|
672
|
+
}
|
|
673
|
+
function markRecordRestored(recordId) {
|
|
674
|
+
removed.delete(recordId);
|
|
675
|
+
}
|
|
676
|
+
function onRecordChanged(listener) {
|
|
677
|
+
listeners.add(listener);
|
|
678
|
+
return () => listeners.delete(listener);
|
|
679
|
+
}
|
|
680
|
+
var tableListeners = (0, import_global_slot.globalSlot)("ai-matrx.records.table-structure-listeners", () => /* @__PURE__ */ new Set());
|
|
681
|
+
function announceTableStructureChanged(tableId) {
|
|
682
|
+
for (const listener of [...tableListeners]) {
|
|
683
|
+
try {
|
|
684
|
+
listener(tableId);
|
|
685
|
+
} catch (thrown) {
|
|
686
|
+
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// src/archive.ts
|
|
692
|
+
var DEFAULT_ARCHIVE_LANE = "org";
|
|
693
|
+
|
|
694
|
+
// src/aggregate.ts
|
|
695
|
+
function isRuleFilter(filter) {
|
|
696
|
+
if (!filter || typeof filter !== "object" || Array.isArray(filter)) return false;
|
|
697
|
+
const node = filter;
|
|
698
|
+
return typeof node.op === "string" && Array.isArray(node.args);
|
|
699
|
+
}
|
|
700
|
+
function stableFilterKey(filter) {
|
|
701
|
+
if (!filter) return "{}";
|
|
702
|
+
if (isRuleFilter(filter)) return JSON.stringify(filter);
|
|
703
|
+
const keys = Object.keys(filter).sort();
|
|
704
|
+
if (keys.length === 0) return "{}";
|
|
705
|
+
const parts = keys.map((key) => {
|
|
706
|
+
const value = filter[key];
|
|
707
|
+
if (value !== null && typeof value === "object") {
|
|
708
|
+
const window = value;
|
|
709
|
+
return `${JSON.stringify(key)}:{"from":${JSON.stringify(window.from ?? null)},"to":${JSON.stringify(window.to ?? null)}}`;
|
|
710
|
+
}
|
|
711
|
+
return `${JSON.stringify(key)}:${JSON.stringify(value ?? null)}`;
|
|
712
|
+
});
|
|
713
|
+
return `{${parts.join(",")}}`;
|
|
714
|
+
}
|
|
715
|
+
function liftWithheld(rows) {
|
|
716
|
+
let shared;
|
|
717
|
+
for (const row of rows) {
|
|
718
|
+
const m = (row.measures ?? {})["_withheld"];
|
|
719
|
+
if (m !== void 0 && m !== null && typeof m === "object") {
|
|
720
|
+
shared = m;
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return rows.map((row) => {
|
|
725
|
+
const measures = row.measures ?? {};
|
|
726
|
+
const own = measures["_withheld"];
|
|
727
|
+
const marker = own !== void 0 && own !== null && typeof own === "object" ? own : shared;
|
|
728
|
+
const rowCount = row.row_count ?? 0;
|
|
729
|
+
if (marker === void 0 || marker === null || typeof marker !== "object") {
|
|
730
|
+
return rowCount === row.row_count ? row : { ...row, row_count: rowCount };
|
|
731
|
+
}
|
|
732
|
+
const { _withheld: _drop, ...rest } = measures;
|
|
733
|
+
const withheld = {};
|
|
734
|
+
for (const [name, raw] of Object.entries(marker)) {
|
|
735
|
+
const m = raw ?? {};
|
|
736
|
+
withheld[name] = {
|
|
737
|
+
reason: m.withheld?.reason ?? null,
|
|
738
|
+
needs: m.withheld?.needs ?? null,
|
|
739
|
+
or: m.withheld?.or ?? null,
|
|
740
|
+
...m.says ? { says: m.says } : {},
|
|
741
|
+
...m.label ? { label: m.label } : {},
|
|
742
|
+
...m.field_key ? { field_key: m.field_key } : {}
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
return { ...row, measures: rest, withheld, row_count: rowCount };
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// src/record.ts
|
|
750
|
+
function isLockedStub(row) {
|
|
751
|
+
if (!row) return false;
|
|
752
|
+
if (row.level !== null && row.level !== void 0) return false;
|
|
753
|
+
const doc = row.document;
|
|
754
|
+
if (!doc || typeof doc !== "object") return false;
|
|
755
|
+
const keys = Object.keys(doc);
|
|
756
|
+
if (keys.length === 0 || keys.length > 3) return false;
|
|
757
|
+
const d = doc;
|
|
758
|
+
return d["exists"] === true && keys.every((k) => k === "id" || k === "exists" || k === "submitted_at");
|
|
759
|
+
}
|
|
760
|
+
function splitLockedRows(rows) {
|
|
761
|
+
const open = [];
|
|
762
|
+
let locked = 0;
|
|
763
|
+
for (const row of rows) {
|
|
764
|
+
if (isLockedStub(row)) locked += 1;
|
|
765
|
+
else open.push(row);
|
|
766
|
+
}
|
|
767
|
+
return { rows: open, locked };
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// src/subscription.ts
|
|
771
|
+
function callersTimeZone() {
|
|
772
|
+
try {
|
|
773
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
774
|
+
} catch {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
function withCallersClock(spec, zone = callersTimeZone()) {
|
|
779
|
+
if (!zone || spec.quiet_hours?.tz) return spec;
|
|
780
|
+
return { ...spec, quiet_hours: { ...spec.quiet_hours ?? {}, tz: zone } };
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/rowLabel.ts
|
|
784
|
+
function clearsRowLabel(formula) {
|
|
785
|
+
return formula == null || formula.trim() === "";
|
|
786
|
+
}
|
|
787
|
+
|
|
695
788
|
// src/relation.ts
|
|
696
789
|
var import_uuid2 = require("@ai-matrx/kit/uuid");
|
|
697
790
|
function isReverseField(field2) {
|
|
@@ -1471,11 +1564,51 @@ function createScopeDoors(call) {
|
|
|
1471
1564
|
source_type: String(envelope.data?.source_type ?? cell.source_type ?? "ai_enriched")
|
|
1472
1565
|
}
|
|
1473
1566
|
};
|
|
1567
|
+
},
|
|
1568
|
+
tableProvision({ organization_id, item_id, scope_id, home_id }) {
|
|
1569
|
+
return call(
|
|
1570
|
+
"scope_table_provision",
|
|
1571
|
+
{ p_organization_id: organization_id, p_item_id: item_id, p_scope_id: scope_id, p_home_id: home_id ?? null },
|
|
1572
|
+
"scopeTableProvision"
|
|
1573
|
+
);
|
|
1474
1574
|
}
|
|
1475
1575
|
};
|
|
1476
1576
|
return doors;
|
|
1477
1577
|
}
|
|
1478
1578
|
|
|
1579
|
+
// src/core/pickListDoors.ts
|
|
1580
|
+
var PICK_LIST_DOORS = {
|
|
1581
|
+
pickListGet: "pick_list_get",
|
|
1582
|
+
pickListForSelection: "pick_list_for_selection",
|
|
1583
|
+
pickListUpdate: "pick_list_update"
|
|
1584
|
+
};
|
|
1585
|
+
function createPickListDoors(callDoor) {
|
|
1586
|
+
return {
|
|
1587
|
+
async pickListGet({ list_id }) {
|
|
1588
|
+
return callDoor(PICK_LIST_DOORS.pickListGet, { p_list_id: list_id }, "pickListGet");
|
|
1589
|
+
},
|
|
1590
|
+
async pickListForSelection({ list_id }) {
|
|
1591
|
+
return callDoor(
|
|
1592
|
+
PICK_LIST_DOORS.pickListForSelection,
|
|
1593
|
+
{ p_list_id: list_id },
|
|
1594
|
+
"pickListForSelection"
|
|
1595
|
+
);
|
|
1596
|
+
},
|
|
1597
|
+
async pickListUpdate({ list_id, list_name, description, items }) {
|
|
1598
|
+
return callDoor(
|
|
1599
|
+
PICK_LIST_DOORS.pickListUpdate,
|
|
1600
|
+
{
|
|
1601
|
+
p_list_id: list_id,
|
|
1602
|
+
p_list_name: list_name ?? null,
|
|
1603
|
+
p_description: description ?? null,
|
|
1604
|
+
p_items: items ? [...items] : null
|
|
1605
|
+
},
|
|
1606
|
+
"pickListUpdate"
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1479
1612
|
// src/choice.ts
|
|
1480
1613
|
var import_uuid4 = require("@ai-matrx/kit/uuid");
|
|
1481
1614
|
var CHOICE_NUDGES = ["ask", "always_add", "never_add"];
|
|
@@ -2797,12 +2930,7 @@ function doorReady(config, name) {
|
|
|
2797
2930
|
return DOOR_NAMES.has(name) || Boolean(config?.knownDoors?.includes(name));
|
|
2798
2931
|
}
|
|
2799
2932
|
function doorAbsent(name) {
|
|
2800
|
-
|
|
2801
|
-
return {
|
|
2802
|
-
code: "door_absent",
|
|
2803
|
-
message: `The record store has no door \`custom.${name}\` yet, so this call was not made. Nothing was read and nothing was written.`,
|
|
2804
|
-
hint: owed ? `That door is ${owed}. Until it lands, this call refuses rather than guessing: an empty answer here would read like "there is nothing", which is a different sentence.` : `No lane in the build book claims this door. Either the name is wrong, or the door was removed from the store and this package has not been regenerated \u2014 run \`pnpm records:generate\`.`
|
|
2805
|
-
};
|
|
2933
|
+
return doorAbsentRefusal(name, OWED_BY[name]);
|
|
2806
2934
|
}
|
|
2807
2935
|
var DOORS = {
|
|
2808
2936
|
// THE READ DOOR (DOOR-1). Every read of a record's values goes through these
|
|
@@ -3582,29 +3710,6 @@ function intersectIds(sets) {
|
|
|
3582
3710
|
|
|
3583
3711
|
// src/core/client.ts
|
|
3584
3712
|
var DEFAULT_SCHEMA = "custom";
|
|
3585
|
-
function canonicalArgs(value) {
|
|
3586
|
-
return JSON.stringify(
|
|
3587
|
-
value,
|
|
3588
|
-
(_key, held) => held && typeof held === "object" && !Array.isArray(held) ? Object.fromEntries(Object.keys(held).sort().map((k) => [k, held[k]])) : held
|
|
3589
|
-
);
|
|
3590
|
-
}
|
|
3591
|
-
var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
|
|
3592
|
-
"refused_by_rule",
|
|
3593
|
-
"stale_write",
|
|
3594
|
-
"invalid_argument",
|
|
3595
|
-
"already_exists",
|
|
3596
|
-
"missing_reference"
|
|
3597
|
-
]);
|
|
3598
|
-
function isAPersonsRefusal(code) {
|
|
3599
|
-
return A_PERSONS_REFUSAL.has(code);
|
|
3600
|
-
}
|
|
3601
|
-
function sink(config) {
|
|
3602
|
-
return config.onError ?? ((e) => {
|
|
3603
|
-
const line = `[@ai-matrx/records] ${e.where}: ${e.code} \u2014 ${e.message}${e.hint ? ` (${e.hint})` : ""}`;
|
|
3604
|
-
if (isAPersonsRefusal(e.code)) console.info(line);
|
|
3605
|
-
else console.error(line);
|
|
3606
|
-
});
|
|
3607
|
-
}
|
|
3608
3713
|
var TABLE_LIST_PAGE = 500;
|
|
3609
3714
|
var TABLE_ARCHIVE_PASS = 20;
|
|
3610
3715
|
var TABLE_RESTORE_PASS = 20;
|
|
@@ -3617,7 +3722,7 @@ function createRecordsClient(given) {
|
|
|
3617
3722
|
const org = config.organizationId;
|
|
3618
3723
|
const ledger = config.opLedger ?? defaultOpLedger;
|
|
3619
3724
|
const mintOp = () => ledger.mint();
|
|
3620
|
-
const scream =
|
|
3725
|
+
const scream = recordsErrorSink(config.onError);
|
|
3621
3726
|
const BUNDLE_TTL_MS = 1e4;
|
|
3622
3727
|
const BUNDLE_OPENERS = /* @__PURE__ */ new Set(["applicable_fields", "views", "view_look_read", "table_decorations", "row_actions", "reverse_columns", "record_change_actions", "grid_layout", "io_imports"]);
|
|
3623
3728
|
const bundleParts = /* @__PURE__ */ new Map();
|
|
@@ -3759,56 +3864,20 @@ function createRecordsClient(given) {
|
|
|
3759
3864
|
bundleAsked.delete(tableId);
|
|
3760
3865
|
for (const key of [...bundleParts.keys()]) if (key.includes(tableId)) bundleParts.delete(key);
|
|
3761
3866
|
}
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
}
|
|
3772
|
-
return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
|
|
3773
|
-
}
|
|
3774
|
-
const readsInFlight = /* @__PURE__ */ new Map();
|
|
3775
|
-
async function callDoor(door, args, where, opts) {
|
|
3776
|
-
const primed = primedFor(door, args);
|
|
3777
|
-
if (primed) return ok(primed.data);
|
|
3778
|
-
const bundled = await fromBundle(door, args);
|
|
3779
|
-
if (bundled) return ok(bundled.data);
|
|
3780
|
-
if (!doorReady(config, door)) {
|
|
3781
|
-
const refusal2 = doorAbsent(door);
|
|
3782
|
-
scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
|
|
3783
|
-
return err(refusal2);
|
|
3784
|
-
}
|
|
3785
|
-
const flightKey = isWritingDoor(door) ? null : `${door}|${canonicalArgs(args)}`;
|
|
3786
|
-
const flying = flightKey ? readsInFlight.get(flightKey) : void 0;
|
|
3787
|
-
const response = await (flying ?? (() => {
|
|
3788
|
-
const call = Promise.resolve(config.dataSource.rpc(`${door}`, args, { schema }));
|
|
3789
|
-
if (flightKey) {
|
|
3790
|
-
readsInFlight.set(flightKey, call);
|
|
3791
|
-
const forget = () => {
|
|
3792
|
-
if (readsInFlight.get(flightKey) === call) readsInFlight.delete(flightKey);
|
|
3793
|
-
};
|
|
3794
|
-
call.then(forget, forget);
|
|
3795
|
-
}
|
|
3796
|
-
return call;
|
|
3797
|
-
})());
|
|
3798
|
-
if (response.error) {
|
|
3799
|
-
const refusal2 = mapPgError(response.error, where);
|
|
3800
|
-
if (opts?.quiet) console.info(`[@ai-matrx/records] ${where}: ${refusal2.code} - ${refusal2.message}`);
|
|
3801
|
-
else scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
|
|
3802
|
-
return err(refusal2);
|
|
3803
|
-
}
|
|
3804
|
-
if (isWritingDoor(door) || LOOK_WRITES[door]) {
|
|
3867
|
+
const primedFor = primedDoorAnswer;
|
|
3868
|
+
const callDoor = createDoorCall({
|
|
3869
|
+
dataSource: config.dataSource,
|
|
3870
|
+
schema,
|
|
3871
|
+
onError: scream,
|
|
3872
|
+
doorReady: (door) => doorReady(config, door),
|
|
3873
|
+
absent: doorAbsent,
|
|
3874
|
+
held: fromBundle,
|
|
3875
|
+
wrote: (_door, args) => {
|
|
3805
3876
|
const tableId = args["p_table_id"];
|
|
3806
3877
|
bundleDrop(typeof tableId === "string" ? tableId : null);
|
|
3807
|
-
forgetPrimedTablePageBundlesOf(typeof tableId === "string" ? tableId : null);
|
|
3808
|
-
dropPrimedDoorAnswers(LOOK_WRITES[door]);
|
|
3809
3878
|
}
|
|
3810
|
-
|
|
3811
|
-
|
|
3879
|
+
});
|
|
3880
|
+
const scopes = createScopeDoors(callDoor);
|
|
3812
3881
|
function structureMoved(tableId, result) {
|
|
3813
3882
|
if (result.ok) {
|
|
3814
3883
|
bundleDrop(tableId);
|
|
@@ -4007,7 +4076,7 @@ function createRecordsClient(given) {
|
|
|
4007
4076
|
const unavailableReason = (error) => `${error.message}${error.hint ? ` ${error.hint}` : ""}`;
|
|
4008
4077
|
const client = {
|
|
4009
4078
|
config,
|
|
4010
|
-
scopes
|
|
4079
|
+
scopes,
|
|
4011
4080
|
async recordWrite({ table_id, data }) {
|
|
4012
4081
|
const result = await callDoor(
|
|
4013
4082
|
DOORS.recordWrite,
|
|
@@ -4706,28 +4775,7 @@ function createRecordsClient(given) {
|
|
|
4706
4775
|
"fieldOptions"
|
|
4707
4776
|
);
|
|
4708
4777
|
},
|
|
4709
|
-
|
|
4710
|
-
return callDoor(DOORS.pickListGet, { p_list_id: list_id }, "pickListGet");
|
|
4711
|
-
},
|
|
4712
|
-
async pickListForSelection({ list_id }) {
|
|
4713
|
-
return callDoor(
|
|
4714
|
-
DOORS.pickListForSelection,
|
|
4715
|
-
{ p_list_id: list_id },
|
|
4716
|
-
"pickListForSelection"
|
|
4717
|
-
);
|
|
4718
|
-
},
|
|
4719
|
-
async pickListUpdate({ list_id, list_name, description, items }) {
|
|
4720
|
-
return callDoor(
|
|
4721
|
-
DOORS.pickListUpdate,
|
|
4722
|
-
{
|
|
4723
|
-
p_list_id: list_id,
|
|
4724
|
-
p_list_name: list_name ?? null,
|
|
4725
|
-
p_description: description ?? null,
|
|
4726
|
-
p_items: items ? [...items] : null
|
|
4727
|
-
},
|
|
4728
|
-
"pickListUpdate"
|
|
4729
|
-
);
|
|
4730
|
-
},
|
|
4778
|
+
...createPickListDoors(callDoor),
|
|
4731
4779
|
async fieldChoiceUsage({ field_id }) {
|
|
4732
4780
|
const result = await callDoor(
|
|
4733
4781
|
DOORS.fieldChoiceUsage,
|
|
@@ -7261,11 +7309,7 @@ function createRecordsClient(given) {
|
|
|
7261
7309
|
);
|
|
7262
7310
|
},
|
|
7263
7311
|
async scopeTableProvision({ home_id, item_id, scope_id }) {
|
|
7264
|
-
return
|
|
7265
|
-
DOORS.scopeTableProvision,
|
|
7266
|
-
{ p_organization_id: org, p_item_id: item_id, p_scope_id: scope_id, p_home_id: home_id ?? null },
|
|
7267
|
-
"scopeTableProvision"
|
|
7268
|
-
);
|
|
7312
|
+
return scopes.tableProvision({ organization_id: org, item_id, scope_id, home_id: home_id ?? null });
|
|
7269
7313
|
},
|
|
7270
7314
|
async tableRowCounts({ table_ids }) {
|
|
7271
7315
|
return callDoor(
|