@ai-matrx/records 0.79.1 → 0.80.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/CHANGELOG.md +7 -0
- package/dist/app-table/index.cjs +26 -6
- package/dist/app-table/index.cjs.map +1 -1
- package/dist/app-table/index.js +26 -6
- package/dist/app-table/index.js.map +1 -1
- package/dist/core/index.cjs +36 -6
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +22 -1
- package/dist/core/index.d.ts +22 -1
- package/dist/core/index.js +36 -6
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +26 -6
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.js +26 -6
- package/dist/data/index.js.map +1 -1
- package/dist/react/index.cjs +26 -6
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +26 -6
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -468,6 +468,27 @@ declare function outcomeForBlock(outcomes: LandingOutcomes, block: LandingBlock)
|
|
|
468
468
|
/** True when any landing of `kind` for this block is in the record store. */
|
|
469
469
|
declare function blockLandedInStore(outcomes: LandingOutcomes, block: LandingBlock): boolean;
|
|
470
470
|
|
|
471
|
+
/** What a data source's `rpc` answers for `custom.table_page_bundle` (PostgREST's `{ data, error }`). */
|
|
472
|
+
interface PrimedBundleAnswer {
|
|
473
|
+
data: unknown;
|
|
474
|
+
error: unknown;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Hand the records client a table page's bundle that was asked elsewhere (the server render, as the
|
|
478
|
+
* same person). The next records client that opens this Table in this organization uses it instead of
|
|
479
|
+
* asking — once, within PRIMED_TTL_MS.
|
|
480
|
+
*/
|
|
481
|
+
declare function primeTablePageBundle(input: {
|
|
482
|
+
organizationId: string;
|
|
483
|
+
tableId: string;
|
|
484
|
+
viewId?: string | null;
|
|
485
|
+
answer: Promise<PrimedBundleAnswer> | PrimedBundleAnswer;
|
|
486
|
+
}): void;
|
|
487
|
+
/** The primed answer for this page, once — or null (none, or stale). */
|
|
488
|
+
declare function takePrimedTablePageBundle(organizationId: string | null | undefined, tableId: string, viewId: string | null | undefined): Promise<PrimedBundleAnswer> | null;
|
|
489
|
+
/** Tests only: forget every primed answer. */
|
|
490
|
+
declare function forgetPrimedTablePageBundles(): void;
|
|
491
|
+
|
|
471
492
|
/**
|
|
472
493
|
* The structural shape of the supabase client this adapter needs. Deliberately
|
|
473
494
|
* NOT `SupabaseClient<Database>`: a generated `Database` type makes
|
|
@@ -648,4 +669,4 @@ type ReadFileText = (fileId: Uuid) => Promise<string>;
|
|
|
648
669
|
*/
|
|
649
670
|
declare function withWholeValues(rows: ExportRow[], read?: ReadFileText | null): Promise<ExportRow[]>;
|
|
650
671
|
|
|
651
|
-
export { type BlockOutcome, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_VALUE_MAX_BYTES, DOORS, type DoorKey, type ExportRow, Field, LANDING_SOURCE_TYPE, LANDING_TARGET_TYPES, type Landing, type LandingBlock, type LandingOutcomes, type LandingState, type LandingStore, MAPPED_SQLSTATES, type MirrorLimits, OUTPUT_KEPT_KEY, PRODUCED_BY_LABEL, type ParsedImport, PgError, PredictedRefusal, type ReadFileText, ReadValue, RecordDocument, RecordsDataSource, RecordsError, RecordsResult, StaleWriteDetail, type SupabaseLike, TableKindFacts, Uuid, WHOLE_VALUE_SOURCE_KIND, type WholeValuePointer, announceRecordChanged, announceTableStructureChanged, asRecordsDataSource, blockLandedInStore, cellText, doorAbsent, doorCensus, doorExists, doorReady, exportCellText, exportCsv, exportXlsx, importCsv, importXlsx, landingOutcomesFor, mapPgError, onRecordChanged, onTableStructureChanged, outcomeForBlock, outputIsKept, parseCsv, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, tableKindFacts, toAoa, valuesAreUnconfirmed, wholeValueNotRead, wholeValueOf, wholeValueOfRead, wholeValueSize, withWholeValues };
|
|
672
|
+
export { type BlockOutcome, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_VALUE_MAX_BYTES, DOORS, type DoorKey, type ExportRow, Field, LANDING_SOURCE_TYPE, LANDING_TARGET_TYPES, type Landing, type LandingBlock, type LandingOutcomes, type LandingState, type LandingStore, MAPPED_SQLSTATES, type MirrorLimits, OUTPUT_KEPT_KEY, PRODUCED_BY_LABEL, type ParsedImport, PgError, PredictedRefusal, type PrimedBundleAnswer, type ReadFileText, ReadValue, RecordDocument, RecordsDataSource, RecordsError, RecordsResult, StaleWriteDetail, type SupabaseLike, TableKindFacts, Uuid, WHOLE_VALUE_SOURCE_KIND, type WholeValuePointer, announceRecordChanged, announceTableStructureChanged, asRecordsDataSource, blockLandedInStore, cellText, doorAbsent, doorCensus, doorExists, doorReady, exportCellText, exportCsv, exportXlsx, forgetPrimedTablePageBundles, importCsv, importXlsx, landingOutcomesFor, mapPgError, onRecordChanged, onTableStructureChanged, outcomeForBlock, outputIsKept, parseCsv, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, primeTablePageBundle, staleWriteDetail, supabaseDataSource, tableKindFacts, takePrimedTablePageBundle, toAoa, valuesAreUnconfirmed, wholeValueNotRead, wholeValueOf, wholeValueOfRead, wholeValueSize, withWholeValues };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -468,6 +468,27 @@ declare function outcomeForBlock(outcomes: LandingOutcomes, block: LandingBlock)
|
|
|
468
468
|
/** True when any landing of `kind` for this block is in the record store. */
|
|
469
469
|
declare function blockLandedInStore(outcomes: LandingOutcomes, block: LandingBlock): boolean;
|
|
470
470
|
|
|
471
|
+
/** What a data source's `rpc` answers for `custom.table_page_bundle` (PostgREST's `{ data, error }`). */
|
|
472
|
+
interface PrimedBundleAnswer {
|
|
473
|
+
data: unknown;
|
|
474
|
+
error: unknown;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Hand the records client a table page's bundle that was asked elsewhere (the server render, as the
|
|
478
|
+
* same person). The next records client that opens this Table in this organization uses it instead of
|
|
479
|
+
* asking — once, within PRIMED_TTL_MS.
|
|
480
|
+
*/
|
|
481
|
+
declare function primeTablePageBundle(input: {
|
|
482
|
+
organizationId: string;
|
|
483
|
+
tableId: string;
|
|
484
|
+
viewId?: string | null;
|
|
485
|
+
answer: Promise<PrimedBundleAnswer> | PrimedBundleAnswer;
|
|
486
|
+
}): void;
|
|
487
|
+
/** The primed answer for this page, once — or null (none, or stale). */
|
|
488
|
+
declare function takePrimedTablePageBundle(organizationId: string | null | undefined, tableId: string, viewId: string | null | undefined): Promise<PrimedBundleAnswer> | null;
|
|
489
|
+
/** Tests only: forget every primed answer. */
|
|
490
|
+
declare function forgetPrimedTablePageBundles(): void;
|
|
491
|
+
|
|
471
492
|
/**
|
|
472
493
|
* The structural shape of the supabase client this adapter needs. Deliberately
|
|
473
494
|
* NOT `SupabaseClient<Database>`: a generated `Database` type makes
|
|
@@ -648,4 +669,4 @@ type ReadFileText = (fileId: Uuid) => Promise<string>;
|
|
|
648
669
|
*/
|
|
649
670
|
declare function withWholeValues(rows: ExportRow[], read?: ReadFileText | null): Promise<ExportRow[]>;
|
|
650
671
|
|
|
651
|
-
export { type BlockOutcome, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_VALUE_MAX_BYTES, DOORS, type DoorKey, type ExportRow, Field, LANDING_SOURCE_TYPE, LANDING_TARGET_TYPES, type Landing, type LandingBlock, type LandingOutcomes, type LandingState, type LandingStore, MAPPED_SQLSTATES, type MirrorLimits, OUTPUT_KEPT_KEY, PRODUCED_BY_LABEL, type ParsedImport, PgError, PredictedRefusal, type ReadFileText, ReadValue, RecordDocument, RecordsDataSource, RecordsError, RecordsResult, StaleWriteDetail, type SupabaseLike, TableKindFacts, Uuid, WHOLE_VALUE_SOURCE_KIND, type WholeValuePointer, announceRecordChanged, announceTableStructureChanged, asRecordsDataSource, blockLandedInStore, cellText, doorAbsent, doorCensus, doorExists, doorReady, exportCellText, exportCsv, exportXlsx, importCsv, importXlsx, landingOutcomesFor, mapPgError, onRecordChanged, onTableStructureChanged, outcomeForBlock, outputIsKept, parseCsv, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, tableKindFacts, toAoa, valuesAreUnconfirmed, wholeValueNotRead, wholeValueOf, wholeValueOfRead, wholeValueSize, withWholeValues };
|
|
672
|
+
export { type BlockOutcome, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_VALUE_MAX_BYTES, DOORS, type DoorKey, type ExportRow, Field, LANDING_SOURCE_TYPE, LANDING_TARGET_TYPES, type Landing, type LandingBlock, type LandingOutcomes, type LandingState, type LandingStore, MAPPED_SQLSTATES, type MirrorLimits, OUTPUT_KEPT_KEY, PRODUCED_BY_LABEL, type ParsedImport, PgError, PredictedRefusal, type PrimedBundleAnswer, type ReadFileText, ReadValue, RecordDocument, RecordsDataSource, RecordsError, RecordsResult, StaleWriteDetail, type SupabaseLike, TableKindFacts, Uuid, WHOLE_VALUE_SOURCE_KIND, type WholeValuePointer, announceRecordChanged, announceTableStructureChanged, asRecordsDataSource, blockLandedInStore, cellText, doorAbsent, doorCensus, doorExists, doorReady, exportCellText, exportCsv, exportXlsx, forgetPrimedTablePageBundles, importCsv, importXlsx, landingOutcomesFor, mapPgError, onRecordChanged, onTableStructureChanged, outcomeForBlock, outputIsKept, parseCsv, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, primeTablePageBundle, staleWriteDetail, supabaseDataSource, tableKindFacts, takePrimedTablePageBundle, toAoa, valuesAreUnconfirmed, wholeValueNotRead, wholeValueOf, wholeValueOfRead, wholeValueSize, withWholeValues };
|
package/dist/core/index.js
CHANGED
|
@@ -4812,6 +4812,26 @@ function tableRenderSchema(facts) {
|
|
|
4812
4812
|
return { kind: slug, fields: out };
|
|
4813
4813
|
}
|
|
4814
4814
|
|
|
4815
|
+
// src/core/primedBundle.ts
|
|
4816
|
+
var PRIMED_TTL_MS = 15e3;
|
|
4817
|
+
var primed = /* @__PURE__ */ new Map();
|
|
4818
|
+
var primedKey = (organizationId, tableId, viewId) => `${organizationId}|${tableId}|${viewId ?? ""}`;
|
|
4819
|
+
function primeTablePageBundle(input) {
|
|
4820
|
+
const answer = Promise.resolve(input.answer).catch((thrown) => ({ data: null, error: thrown }));
|
|
4821
|
+
primed.set(primedKey(input.organizationId, input.tableId, input.viewId), { answer, at: Date.now() });
|
|
4822
|
+
}
|
|
4823
|
+
function takePrimedTablePageBundle(organizationId, tableId, viewId) {
|
|
4824
|
+
if (!organizationId) return null;
|
|
4825
|
+
const key = primedKey(organizationId, tableId, viewId);
|
|
4826
|
+
const held = primed.get(key);
|
|
4827
|
+
if (!held) return null;
|
|
4828
|
+
primed.delete(key);
|
|
4829
|
+
return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
|
|
4830
|
+
}
|
|
4831
|
+
function forgetPrimedTablePageBundles() {
|
|
4832
|
+
primed.clear();
|
|
4833
|
+
}
|
|
4834
|
+
|
|
4815
4835
|
// src/core/keysetCursor.ts
|
|
4816
4836
|
function utf8ToBinary(text2) {
|
|
4817
4837
|
let out = "";
|
|
@@ -5761,13 +5781,20 @@ function createRecordsClient(given) {
|
|
|
5761
5781
|
}
|
|
5762
5782
|
async function fillBundle(tableId, viewId) {
|
|
5763
5783
|
try {
|
|
5764
|
-
const
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
)
|
|
5784
|
+
const view = typeof viewId === "string" ? viewId : null;
|
|
5785
|
+
const usable = (r) => r !== null && !r.error && r.data !== null && typeof r.data === "object" && Array.isArray(r.data.parts);
|
|
5786
|
+
const primedAnswer = takePrimedTablePageBundle(org, tableId, view);
|
|
5787
|
+
let response = primedAnswer ? await primedAnswer : null;
|
|
5788
|
+
if (!usable(response)) {
|
|
5789
|
+
response = await config.dataSource.rpc(
|
|
5790
|
+
"table_page_bundle",
|
|
5791
|
+
{ p_organization_id: org, p_table_id: tableId, p_view_id: view },
|
|
5792
|
+
{ schema }
|
|
5793
|
+
);
|
|
5794
|
+
}
|
|
5795
|
+
if (!usable(response)) return;
|
|
5769
5796
|
const answer = response.data;
|
|
5770
|
-
if (
|
|
5797
|
+
if (!answer || !Array.isArray(answer.parts)) return;
|
|
5771
5798
|
const now = Date.now();
|
|
5772
5799
|
for (const part of answer.parts) {
|
|
5773
5800
|
if (part.error !== void 0 || part.data === void 0) continue;
|
|
@@ -9967,6 +9994,7 @@ export {
|
|
|
9967
9994
|
fieldKindFor,
|
|
9968
9995
|
fieldKindOf,
|
|
9969
9996
|
forgetAllOps,
|
|
9997
|
+
forgetPrimedTablePageBundles,
|
|
9970
9998
|
hasQuietHours,
|
|
9971
9999
|
highestLevel,
|
|
9972
10000
|
holdsARetiredChoice,
|
|
@@ -10035,6 +10063,7 @@ export {
|
|
|
10035
10063
|
predictWriteRefusals,
|
|
10036
10064
|
previewRetype,
|
|
10037
10065
|
previewRuleChange,
|
|
10066
|
+
primeTablePageBundle,
|
|
10038
10067
|
publicFormPath,
|
|
10039
10068
|
rankTypedMatches,
|
|
10040
10069
|
ratingMaxOf,
|
|
@@ -10071,6 +10100,7 @@ export {
|
|
|
10071
10100
|
tableKindMapping,
|
|
10072
10101
|
tableKindSlug,
|
|
10073
10102
|
tableRenderSchema,
|
|
10103
|
+
takePrimedTablePageBundle,
|
|
10074
10104
|
toAoa,
|
|
10075
10105
|
tokenFor,
|
|
10076
10106
|
twoDigitYear,
|