Skip to content

folders

client.folders lists a folder’s index and searches across folder indexes already opened on the device.

list

list opens the key domain’s folder index. It gets one decision and one access event. The SDK confirms the index is up to date before it returns it.

list(folder: Locator): Promise<Decided<Listing>>

Parameters

NameTypeDescription
folderLocatorThe folder to list.

Returns: Decided<Listing>: on allow, the folder’s entries.

Records: View, on the folder index.

Errors: locked, no-session, unreachable, storage-unreachable, container-invalid, trust-failed.

search opens the folder index of every key domain in the person’s data scope, or of the datasets named. Each index open is its own decision. The SDK then searches the decrypted indexes on the device. The access event records the indexes opened, never the query. A result is a locator. Opening it is an open of its own.

search(query: SearchQuery, scope?: { datasets?: string[] }): Promise<SearchResult>

Parameters

NameTypeDescription
querySearchQueryThe text and index fields to match, on the device.
scope{ datasets?: string[] }, optionalRestricts the search to the datasets named. Otherwise searches every dataset in the person’s data scope.

Returns: SearchResult: the matching entries, and which indexes were denied.

Records: Query Records, one per index opened.

Errors: locked, no-session, unreachable.

Types

VersionInfo

interface VersionInfo {
version: number;
savedAt: Date;
writer: RecipientId;
baseVersion?: number;
pending: boolean;
retired: boolean;
}
FieldTypeDescription
versionnumberThe version number.
savedAtDateWhen this version was saved.
writerRecipientIdThe device that saved it.
baseVersionnumber, optionalThe version it was saved from.
pendingbooleanAn AI agent’s version, written but not current until its delegator accepts it.
retiredbooleanWhether this version is in the recycle bin.

Entry

interface Entry {
locator: Locator;
kind: ObjectKind | 'folder';
name: string;
type?: string;
times: { created: Date; saved: Date };
currentVersion?: number;
versions: VersionInfo[];
indexFields: { [field: string]: FieldValue };
recipients: Person[];
domainRoot?: Locator;
}
FieldTypeDescription
locatorLocatorThe entry’s locator.
kindObjectKind | 'folder'Whether this entry is a record, a file, or a folder.
namestringOnly a device that may open the index sees a name.
typestring, optionalThe media type, for a file.
times{ created, saved }When the entry was created and last saved.
currentVersionnumber, optionalThe current version, absent for a folder.
versionsVersionInfo[]Every version of this entry.
indexFields{ [field: string]: FieldValue }The dataset’s index fields as the Client that saved the version wrote them.
recipientsPerson[]The record’s recipients. The next save keeps their access too.
domainRootLocator, optionalFor a folder that is a key domain of its own.

Listing

interface Listing {
dataset: string;
domain: Locator;
folder: Locator;
entries: Entry[];
}
FieldTypeDescription
datasetstringThe dataset the folder belongs to.
domainLocatorThe key domain the folder’s index is under.
folderLocatorThe folder that was listed.
entriesEntry[]The folder’s entries.

SearchQuery

interface SearchQuery {
text?: string;
indexFields?: { [field: string]: FieldValue };
kind?: ObjectKind;
savedFrom?: Date;
savedTo?: Date;
}
FieldTypeDescription
textstring, optionalMatched over names and index fields, on the device.
indexFields{ [field: string]: FieldValue }, optionalExact index field values to match.
kindObjectKind, optionalRestricts to records or files.
savedFromDate, optionalOnly entries saved on or after this date.
savedToDate, optionalOnly entries saved on or before this date.

SearchResult

interface SearchResult {
entries: (Entry & { dataset: string; domain: Locator; folder: Locator })[];
indexes: { domain: Locator; decision: Decided<{}> }[];
}
FieldTypeDescription
entriesan Entry, plus dataset, domain and folderThe matching entries, with where each one lives.
indexes{ domain, decision }[]One decision per folder index opened. A denied index yields no entries and is listed here.

Folders

interface Folders {
list(folder: Locator): Promise<Decided<Listing>>;
search(query: SearchQuery, scope?: { datasets?: string[] }): Promise<SearchResult>;
}

Folders groups the two methods above into the namespace client.folders.