@ai-matrx/data 0.18.35 → 0.18.37
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 +14 -0
- package/README.md +1 -1
- package/dist/db.cjs +39 -0
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +52 -2
- package/dist/db.d.ts +52 -2
- package/dist/db.js +39 -0
- package/dist/db.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/net.cjs.map +1 -1
- package/dist/net.d.cts +1 -1
- package/dist/net.d.ts +1 -1
- package/dist/net.js.map +1 -1
- package/package.json +1 -1
package/dist/db.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ import './net.cjs';
|
|
|
10
10
|
* direct-Supabase writes.
|
|
11
11
|
*
|
|
12
12
|
* Cross-repo system-of-record:
|
|
13
|
-
* common-docs/systems/
|
|
13
|
+
* common-docs/systems/architecture/optimistic-concurrency/FEATURE.md — read it
|
|
14
14
|
* before touching this feature in ANY repo.
|
|
15
15
|
*
|
|
16
16
|
* The revision token is the canonical `version` int column (bumped by the
|
|
@@ -761,4 +761,54 @@ type WriteOneRowResult<Row> = {
|
|
|
761
761
|
*/
|
|
762
762
|
declare function writeOneRow<Row>(write: PromiseLike<RowsResponse<Row>>, options: Pick<WriteOneOptions, "action" | "noun" | "compareAndSet">): Promise<WriteOneRowResult<Row>>;
|
|
763
763
|
|
|
764
|
-
|
|
764
|
+
/**
|
|
765
|
+
* @ai-matrx/data/db — record-unavailable: THE one shape for "a single-record
|
|
766
|
+
* read came back with zero rows".
|
|
767
|
+
*
|
|
768
|
+
* Ported from matrx-frontend `lib/records/recordUnavailable.ts`, which keeps
|
|
769
|
+
* its capture helpers (`recordUnavailable`, `resolveRecordUnavailableCapture`)
|
|
770
|
+
* and re-exports this class — so `RecordUnavailableError` is ONE class across
|
|
771
|
+
* the app and `@ai-matrx/chat`, and every `instanceof` keeps working.
|
|
772
|
+
*
|
|
773
|
+
* Zero rows is at least three different situations: the row was soft-deleted,
|
|
774
|
+
* the row is alive but this reader's access (org membership / permission
|
|
775
|
+
* grant) does not reach it, or the id is stale/wrong. Asserting deletion for
|
|
776
|
+
* all three is what D133 cost — two agent-review items were rejected as "site
|
|
777
|
+
* deleted or is no longer accessible" while the brand AND site were live and
|
|
778
|
+
* un-deleted; the null was RLS.
|
|
779
|
+
*
|
|
780
|
+
* So `deleted` is claimed ONLY when a probe proved it. Everything else is
|
|
781
|
+
* `unknown` and says both possibilities out loud. Never construct the error
|
|
782
|
+
* directly at a read site: the host's `recordUnavailable(...)` builds it AND
|
|
783
|
+
* captures it — the capture is the loud half of the contract.
|
|
784
|
+
*/
|
|
785
|
+
/** `deleted` is PROVEN (a probe read the row and saw `deleted_at`). */
|
|
786
|
+
type RecordUnavailableReason = "deleted" | "unknown";
|
|
787
|
+
/** The truth an access resolver can add after the initial ambiguous read failure. */
|
|
788
|
+
type RecordUnavailableResolution = "denied" | "deleted" | "missing" | "signed-out" | "ok";
|
|
789
|
+
declare class RecordUnavailableError extends Error {
|
|
790
|
+
readonly entity: string;
|
|
791
|
+
readonly reason: RecordUnavailableReason;
|
|
792
|
+
readonly recordId?: string | undefined;
|
|
793
|
+
/**
|
|
794
|
+
* Canonical entity token, when the read site knows it. With a token AND a
|
|
795
|
+
* recordId the renderer stops describing the ambiguity and ASKS the platform
|
|
796
|
+
* instead — an access gate resolves which of the four it really is.
|
|
797
|
+
* Without one, honest ambiguity is still the best available answer.
|
|
798
|
+
*/
|
|
799
|
+
readonly token?: string | undefined;
|
|
800
|
+
/** Diagnostics identity for reconciling this exact capture in place. */
|
|
801
|
+
captureId?: string | undefined;
|
|
802
|
+
/** Last truth written to diagnostics; avoids duplicate reconciliation. */
|
|
803
|
+
captureResolution: RecordUnavailableReason | RecordUnavailableResolution;
|
|
804
|
+
constructor(input: {
|
|
805
|
+
entity: string;
|
|
806
|
+
reason: RecordUnavailableReason;
|
|
807
|
+
recordId?: string | undefined;
|
|
808
|
+
token?: string | undefined;
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
declare function recordUnavailableMessage(entity: string, reason: RecordUnavailableReason): string;
|
|
812
|
+
declare function isRecordUnavailableError(value: unknown): value is RecordUnavailableError;
|
|
813
|
+
|
|
814
|
+
export { type ActiveOrgCookie, type ActiveOrgCookieOptions, type ActiveOrgSelection, type AuthRetryableResult, BulkWriteError, type CreateActiveOrgCookieArgs, type CreateOAuthRefreshFetchArgs, type CreateSessionRetryOptions, DEFAULT_ACTIVE_ORG_COOKIE_MAX_AGE, DEFAULT_ACTIVE_ORG_COOKIE_NAME, type GuardedUpdateArgs, type GuardedUpdateResult, IncompleteReadError, type JsonObject, type MergeJsonColumnArgs, type MergeJsonColumnResult, type OAuthRefreshStorage, type PagedReadQuery, type PagedReadResult, type ReadAllRowsOptions, type ReadAllRowsRestOptions, RecordUnavailableError, type RecordUnavailableReason, type RecordUnavailableResolution, type SessionSource, SessionUnavailableError, type TryWriteOneResult, type VersionedRow, WriteDidNotLandError, type WriteDidNotLandReason, type WriteFailureWords, type WriteOneAction, type WriteOneOptions, type WriteOneRowResult, WriteRefusedError, asJsonObject, assertWriteLanded, createActiveOrgCookie, createOAuthRefreshFetch, createSessionRetry, decodeActiveOrgSelection, decodeOAuthRefreshClaims, describeWriteFailure, encodeActiveOrgSelection, guardedUpdate, isMissingSessionError, isRecordUnavailableError, mergeJsonColumn, personSentence, readAllRows, readAllRowsRest, recordUnavailableMessage, serverMessageFromBody, tryReadAllRows, tryReadAllRowsRest, tryWriteOne, writeFailureStatus, writeOne, writeOneRow };
|
package/dist/db.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import './net.js';
|
|
|
10
10
|
* direct-Supabase writes.
|
|
11
11
|
*
|
|
12
12
|
* Cross-repo system-of-record:
|
|
13
|
-
* common-docs/systems/
|
|
13
|
+
* common-docs/systems/architecture/optimistic-concurrency/FEATURE.md — read it
|
|
14
14
|
* before touching this feature in ANY repo.
|
|
15
15
|
*
|
|
16
16
|
* The revision token is the canonical `version` int column (bumped by the
|
|
@@ -761,4 +761,54 @@ type WriteOneRowResult<Row> = {
|
|
|
761
761
|
*/
|
|
762
762
|
declare function writeOneRow<Row>(write: PromiseLike<RowsResponse<Row>>, options: Pick<WriteOneOptions, "action" | "noun" | "compareAndSet">): Promise<WriteOneRowResult<Row>>;
|
|
763
763
|
|
|
764
|
-
|
|
764
|
+
/**
|
|
765
|
+
* @ai-matrx/data/db — record-unavailable: THE one shape for "a single-record
|
|
766
|
+
* read came back with zero rows".
|
|
767
|
+
*
|
|
768
|
+
* Ported from matrx-frontend `lib/records/recordUnavailable.ts`, which keeps
|
|
769
|
+
* its capture helpers (`recordUnavailable`, `resolveRecordUnavailableCapture`)
|
|
770
|
+
* and re-exports this class — so `RecordUnavailableError` is ONE class across
|
|
771
|
+
* the app and `@ai-matrx/chat`, and every `instanceof` keeps working.
|
|
772
|
+
*
|
|
773
|
+
* Zero rows is at least three different situations: the row was soft-deleted,
|
|
774
|
+
* the row is alive but this reader's access (org membership / permission
|
|
775
|
+
* grant) does not reach it, or the id is stale/wrong. Asserting deletion for
|
|
776
|
+
* all three is what D133 cost — two agent-review items were rejected as "site
|
|
777
|
+
* deleted or is no longer accessible" while the brand AND site were live and
|
|
778
|
+
* un-deleted; the null was RLS.
|
|
779
|
+
*
|
|
780
|
+
* So `deleted` is claimed ONLY when a probe proved it. Everything else is
|
|
781
|
+
* `unknown` and says both possibilities out loud. Never construct the error
|
|
782
|
+
* directly at a read site: the host's `recordUnavailable(...)` builds it AND
|
|
783
|
+
* captures it — the capture is the loud half of the contract.
|
|
784
|
+
*/
|
|
785
|
+
/** `deleted` is PROVEN (a probe read the row and saw `deleted_at`). */
|
|
786
|
+
type RecordUnavailableReason = "deleted" | "unknown";
|
|
787
|
+
/** The truth an access resolver can add after the initial ambiguous read failure. */
|
|
788
|
+
type RecordUnavailableResolution = "denied" | "deleted" | "missing" | "signed-out" | "ok";
|
|
789
|
+
declare class RecordUnavailableError extends Error {
|
|
790
|
+
readonly entity: string;
|
|
791
|
+
readonly reason: RecordUnavailableReason;
|
|
792
|
+
readonly recordId?: string | undefined;
|
|
793
|
+
/**
|
|
794
|
+
* Canonical entity token, when the read site knows it. With a token AND a
|
|
795
|
+
* recordId the renderer stops describing the ambiguity and ASKS the platform
|
|
796
|
+
* instead — an access gate resolves which of the four it really is.
|
|
797
|
+
* Without one, honest ambiguity is still the best available answer.
|
|
798
|
+
*/
|
|
799
|
+
readonly token?: string | undefined;
|
|
800
|
+
/** Diagnostics identity for reconciling this exact capture in place. */
|
|
801
|
+
captureId?: string | undefined;
|
|
802
|
+
/** Last truth written to diagnostics; avoids duplicate reconciliation. */
|
|
803
|
+
captureResolution: RecordUnavailableReason | RecordUnavailableResolution;
|
|
804
|
+
constructor(input: {
|
|
805
|
+
entity: string;
|
|
806
|
+
reason: RecordUnavailableReason;
|
|
807
|
+
recordId?: string | undefined;
|
|
808
|
+
token?: string | undefined;
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
declare function recordUnavailableMessage(entity: string, reason: RecordUnavailableReason): string;
|
|
812
|
+
declare function isRecordUnavailableError(value: unknown): value is RecordUnavailableError;
|
|
813
|
+
|
|
814
|
+
export { type ActiveOrgCookie, type ActiveOrgCookieOptions, type ActiveOrgSelection, type AuthRetryableResult, BulkWriteError, type CreateActiveOrgCookieArgs, type CreateOAuthRefreshFetchArgs, type CreateSessionRetryOptions, DEFAULT_ACTIVE_ORG_COOKIE_MAX_AGE, DEFAULT_ACTIVE_ORG_COOKIE_NAME, type GuardedUpdateArgs, type GuardedUpdateResult, IncompleteReadError, type JsonObject, type MergeJsonColumnArgs, type MergeJsonColumnResult, type OAuthRefreshStorage, type PagedReadQuery, type PagedReadResult, type ReadAllRowsOptions, type ReadAllRowsRestOptions, RecordUnavailableError, type RecordUnavailableReason, type RecordUnavailableResolution, type SessionSource, SessionUnavailableError, type TryWriteOneResult, type VersionedRow, WriteDidNotLandError, type WriteDidNotLandReason, type WriteFailureWords, type WriteOneAction, type WriteOneOptions, type WriteOneRowResult, WriteRefusedError, asJsonObject, assertWriteLanded, createActiveOrgCookie, createOAuthRefreshFetch, createSessionRetry, decodeActiveOrgSelection, decodeOAuthRefreshClaims, describeWriteFailure, encodeActiveOrgSelection, guardedUpdate, isMissingSessionError, isRecordUnavailableError, mergeJsonColumn, personSentence, readAllRows, readAllRowsRest, recordUnavailableMessage, serverMessageFromBody, tryReadAllRows, tryReadAllRowsRest, tryWriteOne, writeFailureStatus, writeOne, writeOneRow };
|
package/dist/db.js
CHANGED
|
@@ -855,12 +855,49 @@ async function writeOneRow(write, options) {
|
|
|
855
855
|
})
|
|
856
856
|
};
|
|
857
857
|
}
|
|
858
|
+
|
|
859
|
+
// src/db/record-unavailable.ts
|
|
860
|
+
var RecordUnavailableError = class extends Error {
|
|
861
|
+
entity;
|
|
862
|
+
reason;
|
|
863
|
+
recordId;
|
|
864
|
+
/**
|
|
865
|
+
* Canonical entity token, when the read site knows it. With a token AND a
|
|
866
|
+
* recordId the renderer stops describing the ambiguity and ASKS the platform
|
|
867
|
+
* instead — an access gate resolves which of the four it really is.
|
|
868
|
+
* Without one, honest ambiguity is still the best available answer.
|
|
869
|
+
*/
|
|
870
|
+
token;
|
|
871
|
+
/** Diagnostics identity for reconciling this exact capture in place. */
|
|
872
|
+
captureId;
|
|
873
|
+
/** Last truth written to diagnostics; avoids duplicate reconciliation. */
|
|
874
|
+
captureResolution;
|
|
875
|
+
constructor(input) {
|
|
876
|
+
super(recordUnavailableMessage(input.entity, input.reason));
|
|
877
|
+
this.name = "RecordUnavailableError";
|
|
878
|
+
this.entity = input.entity;
|
|
879
|
+
this.reason = input.reason;
|
|
880
|
+
this.recordId = input.recordId;
|
|
881
|
+
this.token = input.token;
|
|
882
|
+
this.captureResolution = input.reason;
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
function recordUnavailableMessage(entity, reason) {
|
|
886
|
+
if (reason === "deleted") {
|
|
887
|
+
return `This ${entity} was deleted, so it can no longer be opened.`;
|
|
888
|
+
}
|
|
889
|
+
return `We couldn't open this ${entity}. It may have been deleted, or it may belong to an organization you don't have access to.`;
|
|
890
|
+
}
|
|
891
|
+
function isRecordUnavailableError(value) {
|
|
892
|
+
return value instanceof RecordUnavailableError;
|
|
893
|
+
}
|
|
858
894
|
export {
|
|
859
895
|
BulkWriteError,
|
|
860
896
|
DEFAULT_ACTIVE_ORG_COOKIE_MAX_AGE,
|
|
861
897
|
DEFAULT_ACTIVE_ORG_COOKIE_NAME,
|
|
862
898
|
DEFAULT_AUTH_COOKIE_NAME,
|
|
863
899
|
IncompleteReadError,
|
|
900
|
+
RecordUnavailableError,
|
|
864
901
|
SessionUnavailableError,
|
|
865
902
|
WriteDidNotLandError,
|
|
866
903
|
WriteRefusedError,
|
|
@@ -876,11 +913,13 @@ export {
|
|
|
876
913
|
encodeActiveOrgSelection,
|
|
877
914
|
guardedUpdate,
|
|
878
915
|
isMissingSessionError,
|
|
916
|
+
isRecordUnavailableError,
|
|
879
917
|
mergeJsonColumn,
|
|
880
918
|
parseCookieHeader,
|
|
881
919
|
personSentence,
|
|
882
920
|
readAllRows,
|
|
883
921
|
readAllRowsRest,
|
|
922
|
+
recordUnavailableMessage,
|
|
884
923
|
serverMessageFromBody,
|
|
885
924
|
tryReadAllRows,
|
|
886
925
|
tryReadAllRowsRest,
|