js-bao-wss-client / ResourceMetadataReadResult
Type Alias: ResourceMetadataReadResult<T>
ResourceMetadataReadResult<
T> = {category:string;data:T;exists:true;resourceId:string;resourceType:string;schemaVersion:number; } | {category:string;data:Record<never,never>;exists:false;resourceId:string;resourceType:string;schemaVersion:null; }
Result of a single-category metadata read (resourceMetadata.get). A discriminated union on exists: when a row was written the read carries the typed data and its schemaVersion; when no row exists yet the read still succeeds but data is an empty object and schemaVersion is null. Narrow on exists before reading data — the empty branch does not carry T, so a typed caller cannot access T's fields without checking first.
Type Parameters
T
T extends object = Record<string, unknown>
Union Members
Type Literal
{ category: string; data: T; exists: true; resourceId: string; resourceType: string; schemaVersion: number; }
category
category:
string
data
data:
T
The stored metadata object.
exists
exists:
true
A stored row exists for this resource and category.
resourceId
resourceId:
string
resourceType
resourceType:
string
schemaVersion
schemaVersion:
number
Schema version the stored data was validated against.
Type Literal
{ category: string; data: Record<never, never>; exists: false; resourceId: string; resourceType: string; schemaVersion: null; }
category
category:
string
data
data:
Record<never,never>
No row has been written yet, so this is an empty object. Typed as an object with no keys (not Record<string, never>, which declares every key as never and lets data.field collapse to the true branch's type — defeating the narrowing). A caller must check exists before reading T's fields.
exists
exists:
false
No stored row exists for this resource and category.
resourceId
resourceId:
string
resourceType
resourceType:
string
schemaVersion
schemaVersion:
null
No stored row, so there is no schema version.