@ai-matrx/records 0.80.8 → 0.81.1
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 +23 -0
- package/dist/app-table/index.cjs.map +1 -1
- package/dist/app-table/index.js.map +1 -1
- package/dist/core/index.cjs +74 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +35 -1
- package/dist/core/index.d.ts +35 -1
- package/dist/core/index.js +74 -0
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.js.map +1 -1
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.js.map +1 -1
- package/dist/react/index.cjs +268 -98
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +60 -1
- package/dist/react/index.d.ts +60 -1
- package/dist/react/index.js +206 -36
- package/dist/react/index.js.map +1 -1
- package/dist/templates/index.cjs +1 -1
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/templates/index.js.map +1 -1
- package/package.json +18 -3
package/dist/core/index.d.cts
CHANGED
|
@@ -679,4 +679,38 @@ type ReadFileText = (fileId: Uuid) => Promise<string>;
|
|
|
679
679
|
*/
|
|
680
680
|
declare function withWholeValues(rows: ExportRow[], read?: ReadFileText | null): Promise<ExportRow[]>;
|
|
681
681
|
|
|
682
|
-
|
|
682
|
+
/** One door's answer, under its exact arguments. Plain JSON: it crosses from server to browser. */
|
|
683
|
+
interface RecordsSeedAnswer {
|
|
684
|
+
door: string;
|
|
685
|
+
args: Record<string, unknown>;
|
|
686
|
+
data: unknown;
|
|
687
|
+
}
|
|
688
|
+
/** What a server asked for a page, as the person, and when. */
|
|
689
|
+
interface RecordsSeed {
|
|
690
|
+
/** Epoch ms when the server asked. */
|
|
691
|
+
at: number;
|
|
692
|
+
answers: RecordsSeedAnswer[];
|
|
693
|
+
}
|
|
694
|
+
/** The match key: a door and every argument, keys sorted at every depth. */
|
|
695
|
+
declare function seedKey(door: string, args: Record<string, unknown>): string;
|
|
696
|
+
/**
|
|
697
|
+
* A data source that asks `source` and keeps every answer a door GAVE (errors are not kept). For a
|
|
698
|
+
* server render: create a records client over it, ask what the page will ask, then `seed()`.
|
|
699
|
+
*/
|
|
700
|
+
declare function recordingDataSource(source: RecordsDataSource): {
|
|
701
|
+
source: RecordsDataSource;
|
|
702
|
+
seed: () => RecordsSeed;
|
|
703
|
+
};
|
|
704
|
+
/** The seed as a lookup, built once per seed. */
|
|
705
|
+
declare function seedIndex(seed: RecordsSeed): Map<string, unknown>;
|
|
706
|
+
/**
|
|
707
|
+
* ONE RUN AGAINST THE SEED: a data source answering from `index` only, and whether the run asked a
|
|
708
|
+
* door the seed does not hold. It never opens a bundle itself (`opensInOneCall` off): the bundle's
|
|
709
|
+
* parts are already answers in the index.
|
|
710
|
+
*/
|
|
711
|
+
declare function seededDataSource(index: Map<string, unknown>): {
|
|
712
|
+
source: RecordsDataSource;
|
|
713
|
+
missed: () => boolean;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
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, type RecordsSeed, type RecordsSeedAnswer, 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, primeRecordPageBundle, primeTablePageBundle, recordingDataSource, seedIndex, seedKey, seededDataSource, staleWriteDetail, supabaseDataSource, tableKindFacts, takePrimedTablePageBundle, toAoa, valuesAreUnconfirmed, wholeValueNotRead, wholeValueOf, wholeValueOfRead, wholeValueSize, withWholeValues };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -679,4 +679,38 @@ type ReadFileText = (fileId: Uuid) => Promise<string>;
|
|
|
679
679
|
*/
|
|
680
680
|
declare function withWholeValues(rows: ExportRow[], read?: ReadFileText | null): Promise<ExportRow[]>;
|
|
681
681
|
|
|
682
|
-
|
|
682
|
+
/** One door's answer, under its exact arguments. Plain JSON: it crosses from server to browser. */
|
|
683
|
+
interface RecordsSeedAnswer {
|
|
684
|
+
door: string;
|
|
685
|
+
args: Record<string, unknown>;
|
|
686
|
+
data: unknown;
|
|
687
|
+
}
|
|
688
|
+
/** What a server asked for a page, as the person, and when. */
|
|
689
|
+
interface RecordsSeed {
|
|
690
|
+
/** Epoch ms when the server asked. */
|
|
691
|
+
at: number;
|
|
692
|
+
answers: RecordsSeedAnswer[];
|
|
693
|
+
}
|
|
694
|
+
/** The match key: a door and every argument, keys sorted at every depth. */
|
|
695
|
+
declare function seedKey(door: string, args: Record<string, unknown>): string;
|
|
696
|
+
/**
|
|
697
|
+
* A data source that asks `source` and keeps every answer a door GAVE (errors are not kept). For a
|
|
698
|
+
* server render: create a records client over it, ask what the page will ask, then `seed()`.
|
|
699
|
+
*/
|
|
700
|
+
declare function recordingDataSource(source: RecordsDataSource): {
|
|
701
|
+
source: RecordsDataSource;
|
|
702
|
+
seed: () => RecordsSeed;
|
|
703
|
+
};
|
|
704
|
+
/** The seed as a lookup, built once per seed. */
|
|
705
|
+
declare function seedIndex(seed: RecordsSeed): Map<string, unknown>;
|
|
706
|
+
/**
|
|
707
|
+
* ONE RUN AGAINST THE SEED: a data source answering from `index` only, and whether the run asked a
|
|
708
|
+
* door the seed does not hold. It never opens a bundle itself (`opensInOneCall` off): the bundle's
|
|
709
|
+
* parts are already answers in the index.
|
|
710
|
+
*/
|
|
711
|
+
declare function seededDataSource(index: Map<string, unknown>): {
|
|
712
|
+
source: RecordsDataSource;
|
|
713
|
+
missed: () => boolean;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
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, type RecordsSeed, type RecordsSeedAnswer, 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, primeRecordPageBundle, primeTablePageBundle, recordingDataSource, seedIndex, seedKey, seededDataSource, staleWriteDetail, supabaseDataSource, tableKindFacts, takePrimedTablePageBundle, toAoa, valuesAreUnconfirmed, wholeValueNotRead, wholeValueOf, wholeValueOfRead, wholeValueSize, withWholeValues };
|
package/dist/core/index.js
CHANGED
|
@@ -9948,6 +9948,76 @@ function fromMatrix(matrix) {
|
|
|
9948
9948
|
});
|
|
9949
9949
|
return { headers, rows: rows2 };
|
|
9950
9950
|
}
|
|
9951
|
+
|
|
9952
|
+
// src/core/seed.ts
|
|
9953
|
+
var BUNDLE_DOORS = /* @__PURE__ */ new Set(["table_page_bundle", "record_page_bundle"]);
|
|
9954
|
+
function seedKey(door, args) {
|
|
9955
|
+
return `${door}|${canonicalArgs(args)}`;
|
|
9956
|
+
}
|
|
9957
|
+
function answersOf(door, args, data) {
|
|
9958
|
+
const out = [{ door, args, data }];
|
|
9959
|
+
if (!BUNDLE_DOORS.has(door) || !data || typeof data !== "object") return out;
|
|
9960
|
+
const parts = data.parts;
|
|
9961
|
+
if (!Array.isArray(parts)) return out;
|
|
9962
|
+
for (const part of parts) {
|
|
9963
|
+
if (part.error !== void 0 || part.data === void 0) continue;
|
|
9964
|
+
if (typeof part.door !== "string" || !part.args || typeof part.args !== "object") continue;
|
|
9965
|
+
out.push({ door: part.door, args: part.args, data: part.data });
|
|
9966
|
+
}
|
|
9967
|
+
return out;
|
|
9968
|
+
}
|
|
9969
|
+
function recordingDataSource(source) {
|
|
9970
|
+
const kept = /* @__PURE__ */ new Map();
|
|
9971
|
+
const recording = {
|
|
9972
|
+
...source.opensInOneCall ? { opensInOneCall: true } : {},
|
|
9973
|
+
rpc(fn, args, options) {
|
|
9974
|
+
return Promise.resolve(source.rpc(fn, args, options)).then((answer) => {
|
|
9975
|
+
if (!answer.error && (options?.schema ?? "custom") === "custom") {
|
|
9976
|
+
for (const a of answersOf(fn, args, answer.data)) kept.set(seedKey(a.door, a.args), a);
|
|
9977
|
+
}
|
|
9978
|
+
return answer;
|
|
9979
|
+
});
|
|
9980
|
+
},
|
|
9981
|
+
schema: (name) => source.schema(name)
|
|
9982
|
+
};
|
|
9983
|
+
return { source: recording, seed: () => ({ at: Date.now(), answers: [...kept.values()] }) };
|
|
9984
|
+
}
|
|
9985
|
+
function seedIndex(seed) {
|
|
9986
|
+
const index = /* @__PURE__ */ new Map();
|
|
9987
|
+
for (const a of seed.answers) {
|
|
9988
|
+
for (const spread of answersOf(a.door, a.args, a.data)) index.set(seedKey(spread.door, spread.args), spread.data);
|
|
9989
|
+
}
|
|
9990
|
+
return index;
|
|
9991
|
+
}
|
|
9992
|
+
var MISS = { code: "SEED_MISS", message: "Not in the page's seed.", details: null, hint: null };
|
|
9993
|
+
function missingQuery(onMiss) {
|
|
9994
|
+
const answer = () => {
|
|
9995
|
+
onMiss();
|
|
9996
|
+
return Promise.resolve({ data: null, error: MISS, count: null });
|
|
9997
|
+
};
|
|
9998
|
+
const chain = new Proxy(function() {
|
|
9999
|
+
}, {
|
|
10000
|
+
get(_target, prop) {
|
|
10001
|
+
if (prop === "then") return (ok2, bad) => answer().then(ok2, bad);
|
|
10002
|
+
return () => chain;
|
|
10003
|
+
},
|
|
10004
|
+
apply: () => chain
|
|
10005
|
+
});
|
|
10006
|
+
return { select: () => chain };
|
|
10007
|
+
}
|
|
10008
|
+
function seededDataSource(index) {
|
|
10009
|
+
let missed = false;
|
|
10010
|
+
const source = {
|
|
10011
|
+
rpc(fn, args) {
|
|
10012
|
+
const key = seedKey(fn, args);
|
|
10013
|
+
if (index.has(key)) return Promise.resolve({ data: index.get(key), error: null });
|
|
10014
|
+
missed = true;
|
|
10015
|
+
return Promise.resolve({ data: null, error: MISS });
|
|
10016
|
+
},
|
|
10017
|
+
schema: () => ({ from: () => missingQuery(() => missed = true) })
|
|
10018
|
+
};
|
|
10019
|
+
return { source, missed: () => missed };
|
|
10020
|
+
}
|
|
9951
10021
|
export {
|
|
9952
10022
|
ABSENCE_REASONS,
|
|
9953
10023
|
ACTOR_VOCABULARY,
|
|
@@ -10163,6 +10233,7 @@ export {
|
|
|
10163
10233
|
recordChangeTrigger,
|
|
10164
10234
|
recordSourceKey,
|
|
10165
10235
|
recordSourceTable,
|
|
10236
|
+
recordingDataSource,
|
|
10166
10237
|
recordsUseSentence,
|
|
10167
10238
|
rehomeSentence,
|
|
10168
10239
|
relationNameIndexOf,
|
|
@@ -10176,6 +10247,9 @@ export {
|
|
|
10176
10247
|
safeLinkHref,
|
|
10177
10248
|
sameDocument,
|
|
10178
10249
|
scopeChip,
|
|
10250
|
+
seedIndex,
|
|
10251
|
+
seedKey,
|
|
10252
|
+
seededDataSource,
|
|
10179
10253
|
sheetSyncSpec,
|
|
10180
10254
|
sourceArchivedOf,
|
|
10181
10255
|
splitListCell,
|