@asaidimu/hestia 1.0.1 → 1.0.2
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/LICENSE.md +22 -0
- package/index.cjs +8 -0
- package/index.d.cts +920 -0
- package/index.d.mts +920 -0
- package/index.mjs +8 -0
- package/package.json +25 -22
- package/auth/store.ts +0 -75
- package/auth/types.ts +0 -38
- package/blobs/store.ts +0 -209
- package/blobs/types.ts +0 -28
- package/collections/store.ts +0 -88
- package/collections/types.ts +0 -11
- package/container.ts +0 -93
- package/core/client.ts +0 -408
- package/core/collection.ts +0 -145
- package/core/errors.ts +0 -55
- package/core/pager.ts +0 -162
- package/core/types.ts +0 -279
- package/index.ts +0 -39
- package/system/api-keys/store.ts +0 -107
- package/system/api-keys/types.ts +0 -31
- package/system/capabilities/store.ts +0 -67
- package/system/capabilities/types.ts +0 -1
- package/system/identity/store.ts +0 -113
- package/system/identity/types.ts +0 -31
- package/system/policies/store.ts +0 -177
- package/system/policies/types.ts +0 -43
- package/test-setup.ts +0 -53
- package/utils/index.ts +0 -1
- package/utils/pager.ts +0 -230
- package/vitest.config.ts +0 -8
package/index.d.cts
ADDED
|
@@ -0,0 +1,920 @@
|
|
|
1
|
+
import { QueryDSL, QueryFilter, SortConfiguration } from "@asaidimu/query";
|
|
2
|
+
import { ApiResponse } from "@asaidimu/network-client";
|
|
3
|
+
import { Issue, SystemError } from "@asaidimu/utils-error";
|
|
4
|
+
import { DataStore, ReactiveDataStore } from "@asaidimu/utils-store";
|
|
5
|
+
import { SchemaDefinition } from "@asaidimu/utils-schema";
|
|
6
|
+
//#region core/types.d.ts
|
|
7
|
+
interface DocumentMetadata {
|
|
8
|
+
checksum: string;
|
|
9
|
+
created: string;
|
|
10
|
+
updated: string;
|
|
11
|
+
version: number;
|
|
12
|
+
}
|
|
13
|
+
interface BaseDocument {
|
|
14
|
+
_id_: string;
|
|
15
|
+
_metadata_: DocumentMetadata;
|
|
16
|
+
}
|
|
17
|
+
type Document<T extends Record<string, any>> = BaseDocument & T;
|
|
18
|
+
/**
|
|
19
|
+
* Provides comprehensive pagination information for a collection of records.
|
|
20
|
+
*/
|
|
21
|
+
type PaginationInfo = {
|
|
22
|
+
/** The current page number (1-based). */
|
|
23
|
+
number: number;
|
|
24
|
+
/** The maximum number of items requested per page. */
|
|
25
|
+
size: number;
|
|
26
|
+
/** The number of items in the current page */
|
|
27
|
+
count: number;
|
|
28
|
+
/** The total count of all items across all pages. */
|
|
29
|
+
total: number;
|
|
30
|
+
/** The total number of available pages. */
|
|
31
|
+
pages: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Represents a single paginated response containing a list of records and pagination details.
|
|
35
|
+
* @template T The type of the records in the page.
|
|
36
|
+
*/
|
|
37
|
+
interface Page<T extends Record<string, any>> {
|
|
38
|
+
/** The array of records for the current page. */
|
|
39
|
+
data: Document<T>[];
|
|
40
|
+
/** Indicates if the data query is currently loading. */
|
|
41
|
+
loading: boolean;
|
|
42
|
+
/** An error object if the query failed, otherwise `undefined`. */
|
|
43
|
+
error?: any | undefined;
|
|
44
|
+
/** Pagination metadata providing details about the current page and total collection. */
|
|
45
|
+
page: PaginationInfo;
|
|
46
|
+
}
|
|
47
|
+
interface PagerRefreshOptions {
|
|
48
|
+
sort?: SortConfiguration | SortConfiguration[];
|
|
49
|
+
filter?: QueryFilter;
|
|
50
|
+
delay?: number;
|
|
51
|
+
size?: number;
|
|
52
|
+
page?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Represents the complete state and control mechanisms for consuming paginated data.
|
|
56
|
+
* @template T The type of the records in the page (`TableRowData` or an extension).
|
|
57
|
+
*/
|
|
58
|
+
interface PagedData<T extends Record<string, any>> {
|
|
59
|
+
id: () => string;
|
|
60
|
+
/** The current paginated data, or `undefined` if not found or still loading. */
|
|
61
|
+
page: () => Page<T>;
|
|
62
|
+
/** Function to fetch a specific page of data.
|
|
63
|
+
* @param page The 1-based page number to fetch.
|
|
64
|
+
*/
|
|
65
|
+
navigate: (page: number) => Promise<void>;
|
|
66
|
+
sort: (sort: SortConfiguration<T> | SortConfiguration<T>[]) => Promise<void>;
|
|
67
|
+
filter: (filter?: QueryFilter<T>) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Function to change the page size of the data
|
|
70
|
+
*/
|
|
71
|
+
resize: (size: number, page: number) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Function to force a refresh of the current page data, optionally with a delay.
|
|
74
|
+
* @param delay Optional delay in milliseconds before the refresh operation starts.
|
|
75
|
+
*/
|
|
76
|
+
refresh: (opts?: PagerRefreshOptions) => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Subscribes to page changes.
|
|
79
|
+
* The callback is invoked immediately with the current page, and then on every
|
|
80
|
+
* subsequent change (navigation, resize, SSE patch, refresh).
|
|
81
|
+
*
|
|
82
|
+
* @param listener A function that receives the current Page<T>.
|
|
83
|
+
* @returns An unsubscribe function.
|
|
84
|
+
*/
|
|
85
|
+
subscribe: (listener: (page: Page<T>) => void) => () => void;
|
|
86
|
+
/**
|
|
87
|
+
* Invalidates the pagination controller, cleaning up any cached resources
|
|
88
|
+
* (e.g., store subscriptions, in‑flight requests) and removing internal state.
|
|
89
|
+
* After calling `invalidate()`, the controller should no longer be used.
|
|
90
|
+
*
|
|
91
|
+
* This is useful when the component using the pager is unmounted or when
|
|
92
|
+
* you need to reset the pagination state completely.
|
|
93
|
+
*/
|
|
94
|
+
invalidate: () => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Represents an event emitted by the store, typically for notifications or state changes.
|
|
98
|
+
*/
|
|
99
|
+
interface StoreEvent {
|
|
100
|
+
/** The scope of the event, indicating its type and context. Custom scopes are allowed. */
|
|
101
|
+
scope: string;
|
|
102
|
+
/** Optional payload carrying data related to the event. */
|
|
103
|
+
payload?: any;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Defines the core interface for interacting with a remote data store.
|
|
107
|
+
* @template T The type of the records managed by the store, extending Record.
|
|
108
|
+
* @template TFindOptions Options for the find operation.
|
|
109
|
+
* @template TReadOptions Options for the read operation.
|
|
110
|
+
* @template TListOptions Options for the list operation.
|
|
111
|
+
* @template TPageOptions Options for the paging operation.
|
|
112
|
+
* @template TDeleteOptions Options for the delete operation.
|
|
113
|
+
* @template TUpdateOptions Options for the update operation.
|
|
114
|
+
* @template TCreateOptions Options for the create operation.
|
|
115
|
+
* @template TUploadOptions Options for the upload operation.
|
|
116
|
+
* @template TStreamOptions Options for the stream operation.
|
|
117
|
+
*/
|
|
118
|
+
interface DocumentStore<T extends Record<string, any>, TFindOptions = Record<string, unknown>, TReadOptions = Record<string, unknown>, TListOptions = Record<string, unknown>, TPageOptions = Record<string, unknown>, TDeleteOptions = Record<string, unknown>, TUpdateOptions = Record<string, unknown>, TCreateOptions = Record<string, unknown>, TUploadOptions = Record<string, unknown>, TStreamOptions = Record<string, unknown>> {
|
|
119
|
+
/**
|
|
120
|
+
* Finds records based on provided options, returning a paginated result.
|
|
121
|
+
* @param options The options for the find operation.
|
|
122
|
+
* @returns A promise that resolves to a Page of records.
|
|
123
|
+
*/
|
|
124
|
+
find: (options: TFindOptions) => Promise<Page<T>>;
|
|
125
|
+
/**
|
|
126
|
+
* Reads a single record by its identifier or other read options.
|
|
127
|
+
* @param options The options for the read operation, typically including an ID.
|
|
128
|
+
* @returns A promise that resolves to the record or undefined if not found.
|
|
129
|
+
*/
|
|
130
|
+
read: (options: TReadOptions) => Promise<Document<T> | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* Lists records based on provided options, returning a paginated result.
|
|
133
|
+
* @param options The options for the list operation.
|
|
134
|
+
* @returns A promise that resolves to a Page of records.
|
|
135
|
+
*/
|
|
136
|
+
list: (options: TListOptions) => Promise<Page<T>>;
|
|
137
|
+
/**
|
|
138
|
+
* Deletes a record based on provided options, typically including an ID.
|
|
139
|
+
* @param options The options for the delete operation.
|
|
140
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
141
|
+
*/
|
|
142
|
+
delete: (options: TDeleteOptions) => Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Updates an existing record.
|
|
145
|
+
* @param props An object containing the ID of the record to update, the partial data, and optional update options.
|
|
146
|
+
* @returns A promise that resolves to the updated record or undefined if not found.
|
|
147
|
+
*/
|
|
148
|
+
update: (props: {
|
|
149
|
+
data: Partial<T>;
|
|
150
|
+
options?: TUpdateOptions;
|
|
151
|
+
}) => Promise<Document<T> | undefined>;
|
|
152
|
+
/**
|
|
153
|
+
* Creates a new record.
|
|
154
|
+
* @param props An object containing the data for the new record and optional create options.
|
|
155
|
+
* @returns A promise that resolves to the newly created record or undefined if creation failed.
|
|
156
|
+
*/
|
|
157
|
+
create: (props: {
|
|
158
|
+
data: Partial<T>;
|
|
159
|
+
options?: TCreateOptions;
|
|
160
|
+
}) => Promise<Document<T> | undefined>;
|
|
161
|
+
/**
|
|
162
|
+
* Uploads a file associated with a record. Optionally updates the record with upload details.
|
|
163
|
+
* @param props An object containing the file to upload and optional upload options.
|
|
164
|
+
* @returns A promise that resolves to the updated record after upload or undefined if upload failed.
|
|
165
|
+
*/
|
|
166
|
+
upload: (props: {
|
|
167
|
+
file: File;
|
|
168
|
+
options?: TUploadOptions;
|
|
169
|
+
}) => Promise<Document<T> | undefined>;
|
|
170
|
+
/**
|
|
171
|
+
* Subscribes to store events for a given scope.
|
|
172
|
+
* @param scope The event scope to subscribe to (e.g., 'todos:created:success', '*').
|
|
173
|
+
* @param callback The function to call when an event matching the scope is received.
|
|
174
|
+
* @returns A promise that resolves to an unsubscribe function. Call this function to stop receiving events.
|
|
175
|
+
*/
|
|
176
|
+
subscribe(scope: string, callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
177
|
+
/**
|
|
178
|
+
* Notifies the store of an event, which can then be broadcast to subscribers.
|
|
179
|
+
* @param event The StoreEvent to notify.
|
|
180
|
+
* @returns A promise that resolves when the notification has been processed.
|
|
181
|
+
*/
|
|
182
|
+
notify: (event: StoreEvent) => Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Establishes a stream of records based on provided options.
|
|
185
|
+
* @param options Options for configuring the stream (e.g., batch size, delay, filters).
|
|
186
|
+
* @param onStreamChange A callback function that is called when the stream's status changes.
|
|
187
|
+
* @returns An object containing the async iterable stream, a cancel function, and a status getter.
|
|
188
|
+
*/
|
|
189
|
+
stream: (options: TStreamOptions, onStreamChange: () => void) => {
|
|
190
|
+
/** An async iterable that yields records as they become available in the stream. */
|
|
191
|
+
stream: () => AsyncIterable<Document<T>>;
|
|
192
|
+
/** A function to call to cancel the ongoing stream. */
|
|
193
|
+
cancel: () => void;
|
|
194
|
+
/** A getter function that returns the current status of the stream ('active', 'cancelled', or 'completed'). */
|
|
195
|
+
status: () => "active" | "cancelled" | "completed";
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Creates a paginated data controller for this store.
|
|
199
|
+
*
|
|
200
|
+
* @param options - The pagination options, whose type is defined by the
|
|
201
|
+
* store's `TPageOptions` generic parameter. This lets you
|
|
202
|
+
* pass any configuration (e.g., filters, sorting, custom
|
|
203
|
+
* pagination metadata) that your store implementation needs.
|
|
204
|
+
* @returns A `PagedData<T>` controller that manages loading, navigation,
|
|
205
|
+
* resizing, and refresh.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* // Define your store with a custom TPageOptions type
|
|
209
|
+
* interface MyTodoStore extends DocumentStore<
|
|
210
|
+
* Todo,
|
|
211
|
+
* FindOptions,
|
|
212
|
+
* ReadOptions,
|
|
213
|
+
* ListOptions,
|
|
214
|
+
* { page: number; size: number; sort?: string; filter?: string }
|
|
215
|
+
* > {}
|
|
216
|
+
*
|
|
217
|
+
* // Use it
|
|
218
|
+
* const todosPaged = myTodoStore.page({
|
|
219
|
+
* page: 1,
|
|
220
|
+
* size: 10,
|
|
221
|
+
* sort: 'createdAt',
|
|
222
|
+
* filter: 'done:false'
|
|
223
|
+
* });
|
|
224
|
+
*
|
|
225
|
+
* // Get current page state
|
|
226
|
+
* const { data, loading, page } = todosPaged.page();
|
|
227
|
+
* console.log(`Page ${page.number} of ${page.pages}`);
|
|
228
|
+
*
|
|
229
|
+
* // Navigate
|
|
230
|
+
* await todosPaged.navigate(2);
|
|
231
|
+
*/
|
|
232
|
+
page(options: TPageOptions): PagedData<T>;
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region system/identity/types.d.ts
|
|
236
|
+
interface UserData {
|
|
237
|
+
email: string;
|
|
238
|
+
name: string;
|
|
239
|
+
verified: boolean;
|
|
240
|
+
permissions: string[];
|
|
241
|
+
deleted?: string | null;
|
|
242
|
+
}
|
|
243
|
+
type UserIdentity = Document<UserData>;
|
|
244
|
+
interface CreateUserRequest {
|
|
245
|
+
email: string;
|
|
246
|
+
password: string;
|
|
247
|
+
name: string;
|
|
248
|
+
permissions?: string[];
|
|
249
|
+
verified?: boolean;
|
|
250
|
+
}
|
|
251
|
+
interface UpdateUserRequest {
|
|
252
|
+
name?: string;
|
|
253
|
+
email?: string;
|
|
254
|
+
permissions?: string[];
|
|
255
|
+
verified?: boolean;
|
|
256
|
+
}
|
|
257
|
+
interface ChangePasswordRequest {
|
|
258
|
+
current: string;
|
|
259
|
+
new: string;
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region core/client.d.ts
|
|
263
|
+
interface IdentityProvider {
|
|
264
|
+
identity(): UserIdentity | null;
|
|
265
|
+
token(key: "access" | "refresh"): string | null;
|
|
266
|
+
setTokens(access: string, refresh: string): Promise<void>;
|
|
267
|
+
setIdentity(id: UserIdentity | null): Promise<void>;
|
|
268
|
+
clear(): Promise<void>;
|
|
269
|
+
}
|
|
270
|
+
declare class HestiaResponse<T> {
|
|
271
|
+
readonly data: T;
|
|
272
|
+
readonly status: number;
|
|
273
|
+
constructor(data: T, status: number);
|
|
274
|
+
}
|
|
275
|
+
type BodyType = "json" | "form" | "text" | "blob" | "stream" | "auto";
|
|
276
|
+
type ResponseType = "json" | "text" | "blob" | "arrayBuffer" | "formData" | "auto";
|
|
277
|
+
interface RequestOptions {
|
|
278
|
+
headers?: Record<string, string>;
|
|
279
|
+
responseType?: ResponseType;
|
|
280
|
+
bodyType?: BodyType;
|
|
281
|
+
signal?: AbortSignal;
|
|
282
|
+
}
|
|
283
|
+
interface StreamHandlers {
|
|
284
|
+
onMessage: (data: string) => void;
|
|
285
|
+
onError?: (err: Error) => void;
|
|
286
|
+
onOpen?: () => void;
|
|
287
|
+
onClose?: () => void;
|
|
288
|
+
}
|
|
289
|
+
interface StreamOptions {
|
|
290
|
+
headers?: Record<string, string>;
|
|
291
|
+
signal?: AbortSignal;
|
|
292
|
+
}
|
|
293
|
+
declare class HestiaNetworkClient {
|
|
294
|
+
private baseUrl;
|
|
295
|
+
private apiPrefix;
|
|
296
|
+
private tokens;
|
|
297
|
+
private onAuthStateChanged?;
|
|
298
|
+
private raw;
|
|
299
|
+
private refreshing;
|
|
300
|
+
private refreshFailed;
|
|
301
|
+
constructor(baseUrl: string, apiPrefix: string, tokens: IdentityProvider, onAuthStateChanged?: (() => void) | undefined);
|
|
302
|
+
base(): string;
|
|
303
|
+
prefix(): string;
|
|
304
|
+
private canonicalPath;
|
|
305
|
+
storeTokens(access: string, refresh?: string): Promise<void>;
|
|
306
|
+
private refreshToken;
|
|
307
|
+
private doRefresh;
|
|
308
|
+
private request;
|
|
309
|
+
get<T>(path: string, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
310
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
311
|
+
patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
312
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
313
|
+
delete<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
314
|
+
openStream(path: string, handlers: StreamHandlers, options?: StreamOptions): Promise<void>;
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region core/collection.d.ts
|
|
318
|
+
declare class HestiaCollection<T extends Record<string, any>> implements DocumentStore<T, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
319
|
+
private client;
|
|
320
|
+
private collectionName;
|
|
321
|
+
private defaultLimit;
|
|
322
|
+
private pagerOptions;
|
|
323
|
+
private pager;
|
|
324
|
+
constructor(client: HestiaNetworkClient, collectionName: string, defaultLimit?: number);
|
|
325
|
+
name(): string;
|
|
326
|
+
private get queryPath();
|
|
327
|
+
private get documentsPath();
|
|
328
|
+
private documentPath;
|
|
329
|
+
find(query?: Record<string, unknown>): Promise<Page<T>>;
|
|
330
|
+
read(id: string): Promise<Document<T> | undefined>;
|
|
331
|
+
create(props: {
|
|
332
|
+
data: Partial<T>;
|
|
333
|
+
}): Promise<Document<T> | undefined>;
|
|
334
|
+
update(props: {
|
|
335
|
+
data: Partial<T>;
|
|
336
|
+
options?: string;
|
|
337
|
+
}): Promise<Document<T> | undefined>;
|
|
338
|
+
delete(id: string): Promise<void>;
|
|
339
|
+
list(options?: Record<string, unknown>): Promise<Page<T>>;
|
|
340
|
+
upload(_props: {
|
|
341
|
+
file: File;
|
|
342
|
+
}): Promise<Document<T> | undefined>;
|
|
343
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
344
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
345
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
346
|
+
stream: () => AsyncIterable<Document<T>>;
|
|
347
|
+
cancel: () => void;
|
|
348
|
+
status: () => "active" | "cancelled" | "completed";
|
|
349
|
+
};
|
|
350
|
+
page(_options?: Record<string, unknown>): PagedData<T>;
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region core/errors.d.ts
|
|
354
|
+
interface ServerErrorBody {
|
|
355
|
+
code?: string;
|
|
356
|
+
message?: string;
|
|
357
|
+
details?: {
|
|
358
|
+
issues?: Issue[];
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
declare function parseErrorBody(raw: Response): Promise<ServerErrorBody | null>;
|
|
362
|
+
declare function toSystemError(response: ApiResponse<unknown>, body: ServerErrorBody | null): SystemError;
|
|
363
|
+
declare function notFound(path?: string): SystemError;
|
|
364
|
+
declare function permissionDenied(operation?: string): SystemError;
|
|
365
|
+
declare function internalError(cause?: unknown): SystemError;
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region core/pager.d.ts
|
|
368
|
+
interface PageOptions<T extends Record<string, any>> {
|
|
369
|
+
page?: number;
|
|
370
|
+
size?: number;
|
|
371
|
+
sort?: SortConfiguration<T> | SortConfiguration<T>[];
|
|
372
|
+
filter?: QueryFilter<T>;
|
|
373
|
+
}
|
|
374
|
+
declare function createPagedController<T extends Record<string, any>>(collectionName: string, store: DataStore<any>, options: PageOptions<T>, find: (query: QueryDSL<T>) => Promise<Page<T>>): PagedData<T>;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region auth/types.d.ts
|
|
377
|
+
interface TokenPair {
|
|
378
|
+
access: string;
|
|
379
|
+
refresh: string;
|
|
380
|
+
type: string;
|
|
381
|
+
validity: number;
|
|
382
|
+
}
|
|
383
|
+
interface LoginResult {
|
|
384
|
+
token: TokenPair;
|
|
385
|
+
user: UserIdentity;
|
|
386
|
+
}
|
|
387
|
+
interface ServerHealth {
|
|
388
|
+
bootstrapped: boolean;
|
|
389
|
+
ok: boolean;
|
|
390
|
+
}
|
|
391
|
+
interface LoginRequest {
|
|
392
|
+
email: string;
|
|
393
|
+
password: string;
|
|
394
|
+
}
|
|
395
|
+
interface RegisterRequest {
|
|
396
|
+
email: string;
|
|
397
|
+
password: string;
|
|
398
|
+
name: string;
|
|
399
|
+
}
|
|
400
|
+
interface RefreshRequest {
|
|
401
|
+
refresh_token: string;
|
|
402
|
+
}
|
|
403
|
+
interface BootstrapPasswordRequest {
|
|
404
|
+
password: string;
|
|
405
|
+
email: string;
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region auth/store.d.ts
|
|
409
|
+
declare class HestiaAuth {
|
|
410
|
+
private client;
|
|
411
|
+
private provider;
|
|
412
|
+
constructor(client: HestiaNetworkClient, provider: IdentityProvider);
|
|
413
|
+
health(): Promise<ServerHealth>;
|
|
414
|
+
login(email: string, password: string): Promise<LoginResult>;
|
|
415
|
+
register(email: string, password: string, name: string): Promise<{
|
|
416
|
+
_id_: string;
|
|
417
|
+
email: string;
|
|
418
|
+
name: string;
|
|
419
|
+
}>;
|
|
420
|
+
refresh(refreshToken?: string): Promise<TokenPair>;
|
|
421
|
+
logout(): Promise<void>;
|
|
422
|
+
requestPasswordReset(email: string): Promise<void>;
|
|
423
|
+
confirmPasswordReset(resetToken: string, password: string): Promise<void>;
|
|
424
|
+
bootstrap(key: string, password: string, email: string): Promise<void>;
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region system/identity/store.d.ts
|
|
428
|
+
declare class HestiaUsers implements DocumentStore<UserData, QueryDSL<UserData>, string, QueryDSL<UserData>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
429
|
+
private client;
|
|
430
|
+
private pagerOptions;
|
|
431
|
+
private pager;
|
|
432
|
+
constructor(client: HestiaNetworkClient);
|
|
433
|
+
name(): string;
|
|
434
|
+
find(query?: QueryDSL<UserData>): Promise<Page<UserData>>;
|
|
435
|
+
list(options?: QueryDSL<UserData>): Promise<Page<UserData>>;
|
|
436
|
+
read(id: string): Promise<Document<UserData> | undefined>;
|
|
437
|
+
update(props: {
|
|
438
|
+
data: Partial<UserData>;
|
|
439
|
+
options?: string;
|
|
440
|
+
}): Promise<Document<UserData> | undefined>;
|
|
441
|
+
delete(id: string): Promise<void>;
|
|
442
|
+
create(props: {
|
|
443
|
+
data: Partial<UserData>;
|
|
444
|
+
}): Promise<Document<UserData> | undefined>;
|
|
445
|
+
upload(_props: {
|
|
446
|
+
file: File;
|
|
447
|
+
}): Promise<Document<UserData> | undefined>;
|
|
448
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
449
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
450
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
451
|
+
stream: () => AsyncIterable<Document<UserData>>;
|
|
452
|
+
cancel: () => void;
|
|
453
|
+
status: () => "active" | "cancelled" | "completed";
|
|
454
|
+
};
|
|
455
|
+
page(_options?: Record<string, unknown>): PagedData<UserData>;
|
|
456
|
+
changePassword(userId: string, current: string, newPassword: string): Promise<void>;
|
|
457
|
+
}
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region system/api-keys/types.d.ts
|
|
460
|
+
interface APIKey {
|
|
461
|
+
_id_: string;
|
|
462
|
+
name: string;
|
|
463
|
+
prefix: string;
|
|
464
|
+
operations: string[];
|
|
465
|
+
status: string;
|
|
466
|
+
expiry?: string | null;
|
|
467
|
+
environment?: string;
|
|
468
|
+
usage?: number;
|
|
469
|
+
last_used?: string | null;
|
|
470
|
+
_metadata_: Record<string, unknown>;
|
|
471
|
+
}
|
|
472
|
+
interface APIKeyWithSecret extends APIKey {
|
|
473
|
+
key: string;
|
|
474
|
+
}
|
|
475
|
+
interface CreateKeyRequest {
|
|
476
|
+
name: string;
|
|
477
|
+
environment?: string;
|
|
478
|
+
operations?: string[];
|
|
479
|
+
expiry?: string;
|
|
480
|
+
}
|
|
481
|
+
interface UpdateKeyRequest {
|
|
482
|
+
name?: string;
|
|
483
|
+
environment?: string;
|
|
484
|
+
operations?: string[];
|
|
485
|
+
status?: "active" | "revoked";
|
|
486
|
+
expiry?: string;
|
|
487
|
+
}
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region system/api-keys/store.d.ts
|
|
490
|
+
declare class HestiaKeyStore implements DocumentStore<APIKey, QueryDSL<APIKey>, string, QueryDSL<APIKey>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
491
|
+
private client;
|
|
492
|
+
private pager;
|
|
493
|
+
constructor(client: HestiaNetworkClient);
|
|
494
|
+
private basePath;
|
|
495
|
+
find(_query?: QueryDSL<APIKey>): Promise<Page<APIKey>>;
|
|
496
|
+
list(options?: QueryDSL<APIKey>): Promise<Page<APIKey>>;
|
|
497
|
+
read(id: string): Promise<Document<APIKey> | undefined>;
|
|
498
|
+
create(props: {
|
|
499
|
+
data: Partial<APIKey>;
|
|
500
|
+
}): Promise<Document<APIKey> | undefined>;
|
|
501
|
+
update(props: {
|
|
502
|
+
data: Partial<APIKey>;
|
|
503
|
+
options?: string;
|
|
504
|
+
}): Promise<Document<APIKey> | undefined>;
|
|
505
|
+
delete(id: string): Promise<void>;
|
|
506
|
+
upload(_props: {
|
|
507
|
+
file: File;
|
|
508
|
+
}): Promise<Document<APIKey> | undefined>;
|
|
509
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
510
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
511
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
512
|
+
stream: () => AsyncIterable<Document<APIKey>>;
|
|
513
|
+
cancel: () => void;
|
|
514
|
+
status: () => "active" | "cancelled" | "completed";
|
|
515
|
+
};
|
|
516
|
+
page(_options?: Record<string, unknown>): PagedData<APIKey>;
|
|
517
|
+
rotate(id: string): Promise<Document<APIKeyWithSecret>>;
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region system/policies/types.d.ts
|
|
521
|
+
interface OperationPolicy {
|
|
522
|
+
name: string;
|
|
523
|
+
ruleKey: string;
|
|
524
|
+
description?: string;
|
|
525
|
+
intentType?: "COMMAND" | "QUERY";
|
|
526
|
+
}
|
|
527
|
+
interface UpsertOperationRequest {
|
|
528
|
+
ruleKey: string;
|
|
529
|
+
description?: string;
|
|
530
|
+
intentType?: "COMMAND" | "QUERY";
|
|
531
|
+
}
|
|
532
|
+
interface IamRule {
|
|
533
|
+
name: string;
|
|
534
|
+
ruleType?: string;
|
|
535
|
+
expression?: string;
|
|
536
|
+
description?: string;
|
|
537
|
+
}
|
|
538
|
+
interface UpsertRuleRequest {
|
|
539
|
+
expression: string;
|
|
540
|
+
ruleType?: string;
|
|
541
|
+
description?: string;
|
|
542
|
+
}
|
|
543
|
+
interface ValidateRuleRequest {
|
|
544
|
+
expression: string;
|
|
545
|
+
identity?: Record<string, unknown>;
|
|
546
|
+
resource?: Record<string, unknown>;
|
|
547
|
+
environment?: Record<string, unknown>;
|
|
548
|
+
}
|
|
549
|
+
interface ValidateRuleResult {
|
|
550
|
+
valid: boolean;
|
|
551
|
+
compile?: string;
|
|
552
|
+
result?: boolean;
|
|
553
|
+
}
|
|
554
|
+
interface ReloadResult {
|
|
555
|
+
operations: number;
|
|
556
|
+
rules: number;
|
|
557
|
+
}
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region system/policies/store.d.ts
|
|
560
|
+
declare class HestiaPolicies implements DocumentStore<OperationPolicy, QueryDSL<OperationPolicy>, string, QueryDSL<OperationPolicy>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
561
|
+
private client;
|
|
562
|
+
private pager;
|
|
563
|
+
private operationsPath;
|
|
564
|
+
private rulesPath;
|
|
565
|
+
constructor(client: HestiaNetworkClient);
|
|
566
|
+
private collectionQuery;
|
|
567
|
+
find(query?: QueryDSL<OperationPolicy>): Promise<Page<OperationPolicy>>;
|
|
568
|
+
list(options?: QueryDSL<OperationPolicy>): Promise<Page<OperationPolicy>>;
|
|
569
|
+
read(id: string): Promise<Document<OperationPolicy> | undefined>;
|
|
570
|
+
create(props: {
|
|
571
|
+
data: Partial<OperationPolicy>;
|
|
572
|
+
}): Promise<Document<OperationPolicy> | undefined>;
|
|
573
|
+
update(props: {
|
|
574
|
+
data: Partial<OperationPolicy>;
|
|
575
|
+
options?: string;
|
|
576
|
+
}): Promise<Document<OperationPolicy> | undefined>;
|
|
577
|
+
delete(id: string): Promise<void>;
|
|
578
|
+
upsertOperation(name: string, data: UpsertOperationRequest): Promise<Document<OperationPolicy>>;
|
|
579
|
+
getRule(name: string): Promise<Document<IamRule> | undefined>;
|
|
580
|
+
upsertRule(name: string, data: UpsertRuleRequest): Promise<Document<IamRule>>;
|
|
581
|
+
deleteRule(name: string): Promise<void>;
|
|
582
|
+
listRules(options?: Record<string, unknown>): Promise<Page<IamRule>>;
|
|
583
|
+
validateRule(expression: string): Promise<boolean>;
|
|
584
|
+
reload(): Promise<ReloadResult>;
|
|
585
|
+
upload(_props: {
|
|
586
|
+
file: File;
|
|
587
|
+
}): Promise<Document<OperationPolicy> | undefined>;
|
|
588
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
589
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
590
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
591
|
+
stream: () => AsyncIterable<Document<OperationPolicy>>;
|
|
592
|
+
cancel: () => void;
|
|
593
|
+
status: () => "active" | "cancelled" | "completed";
|
|
594
|
+
};
|
|
595
|
+
page(_options?: Record<string, unknown>): PagedData<OperationPolicy>;
|
|
596
|
+
}
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region system/logs/types.d.ts
|
|
599
|
+
interface AuditEntry {
|
|
600
|
+
event_id: string;
|
|
601
|
+
occurred_at: string;
|
|
602
|
+
recorded_at: string;
|
|
603
|
+
trace_id?: string;
|
|
604
|
+
request_id?: string;
|
|
605
|
+
actor_id: string;
|
|
606
|
+
actor_type: "user" | "service" | "system" | "anonymous";
|
|
607
|
+
on_behalf_of_id?: string;
|
|
608
|
+
auth_method?: "password" | "oauth" | "api_key" | "mtls" | "sso" | "service_account" | "none";
|
|
609
|
+
session_id?: string;
|
|
610
|
+
operation: "create" | "read" | "update" | "delete" | "login" | "logout" | "grant" | "revoke" | "execute" | "other";
|
|
611
|
+
resource_type: string;
|
|
612
|
+
resource_id?: string;
|
|
613
|
+
event_name: string;
|
|
614
|
+
status: "success" | "failure" | "denied" | "error";
|
|
615
|
+
severity?: "info" | "warning" | "critical";
|
|
616
|
+
error_code?: string;
|
|
617
|
+
error_message?: string;
|
|
618
|
+
latency_ms: number;
|
|
619
|
+
source_ip?: string;
|
|
620
|
+
user_agent?: string;
|
|
621
|
+
service_name: string;
|
|
622
|
+
region?: string;
|
|
623
|
+
}
|
|
624
|
+
type RequestLogEntry = AuditEntry;
|
|
625
|
+
interface LogFilter {
|
|
626
|
+
actor_id?: string;
|
|
627
|
+
actor_type?: string;
|
|
628
|
+
operation?: string;
|
|
629
|
+
status?: string;
|
|
630
|
+
resource_type?: string;
|
|
631
|
+
trace_id?: string;
|
|
632
|
+
start?: string;
|
|
633
|
+
end?: string;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region system/logs/store.d.ts
|
|
637
|
+
declare class HestiaLogs implements DocumentStore<AuditEntry, QueryDSL<AuditEntry>, string, QueryDSL<AuditEntry>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
638
|
+
private client;
|
|
639
|
+
private baseUrl;
|
|
640
|
+
private pagerOptions;
|
|
641
|
+
private pager;
|
|
642
|
+
private apiPrefix;
|
|
643
|
+
constructor(client: HestiaNetworkClient, baseUrl: string, apiPrefix?: string);
|
|
644
|
+
find(query?: QueryDSL<AuditEntry>): Promise<Page<AuditEntry>>;
|
|
645
|
+
list(options?: QueryDSL<AuditEntry>): Promise<Page<AuditEntry>>;
|
|
646
|
+
read(_id: string): Promise<Document<AuditEntry> | undefined>;
|
|
647
|
+
create(_props: {
|
|
648
|
+
data: Partial<AuditEntry>;
|
|
649
|
+
}): Promise<Document<AuditEntry> | undefined>;
|
|
650
|
+
update(_props: {
|
|
651
|
+
data: Partial<AuditEntry>;
|
|
652
|
+
options?: string;
|
|
653
|
+
}): Promise<Document<AuditEntry> | undefined>;
|
|
654
|
+
delete(_id: string): Promise<void>;
|
|
655
|
+
upload(_props: {
|
|
656
|
+
file: File;
|
|
657
|
+
}): Promise<Document<AuditEntry> | undefined>;
|
|
658
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
659
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
660
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
661
|
+
stream: () => AsyncIterable<Document<AuditEntry>>;
|
|
662
|
+
cancel: () => void;
|
|
663
|
+
status: () => "active" | "cancelled" | "completed";
|
|
664
|
+
};
|
|
665
|
+
page(_options?: Record<string, unknown>): PagedData<AuditEntry>;
|
|
666
|
+
getStreamUrl(): string;
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region blobs/types.d.ts
|
|
670
|
+
interface NamespaceInfo {
|
|
671
|
+
id: string;
|
|
672
|
+
display_name: string;
|
|
673
|
+
}
|
|
674
|
+
interface BlobMeta {
|
|
675
|
+
key: string;
|
|
676
|
+
namespace_id: string;
|
|
677
|
+
content_type: string;
|
|
678
|
+
size: number;
|
|
679
|
+
created_at: string;
|
|
680
|
+
updated_at?: string;
|
|
681
|
+
custom?: Record<string, any>;
|
|
682
|
+
}
|
|
683
|
+
type BlobDocument = Document<BlobMeta>;
|
|
684
|
+
interface ListBlobsRequest {
|
|
685
|
+
prefix?: string;
|
|
686
|
+
limit?: number;
|
|
687
|
+
}
|
|
688
|
+
interface CreateNamespaceRequest {
|
|
689
|
+
display_name?: string;
|
|
690
|
+
ns?: string;
|
|
691
|
+
}
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region blobs/store.d.ts
|
|
694
|
+
declare class BlobNamespace implements DocumentStore<BlobMeta, QueryDSL<BlobMeta>, string, QueryDSL<BlobMeta>, Record<string, unknown>, string, Record<string, any>, Record<string, unknown>, {
|
|
695
|
+
key: string;
|
|
696
|
+
contentType?: string;
|
|
697
|
+
}, Record<string, unknown>> {
|
|
698
|
+
private client;
|
|
699
|
+
private ns;
|
|
700
|
+
private pagerOptions;
|
|
701
|
+
private pager;
|
|
702
|
+
private prefixFilter;
|
|
703
|
+
constructor(client: HestiaNetworkClient, ns: string);
|
|
704
|
+
name(): string;
|
|
705
|
+
setPrefix(prefix: string): void;
|
|
706
|
+
private basePath;
|
|
707
|
+
find(query?: QueryDSL<BlobMeta>): Promise<Page<BlobMeta>>;
|
|
708
|
+
read(key: string): Promise<Document<BlobMeta> | undefined>;
|
|
709
|
+
create(_props: {
|
|
710
|
+
data: Partial<BlobMeta>;
|
|
711
|
+
}): Promise<Document<BlobMeta> | undefined>;
|
|
712
|
+
update(props: {
|
|
713
|
+
data: Partial<BlobMeta>;
|
|
714
|
+
options?: Record<string, any>;
|
|
715
|
+
}): Promise<Document<BlobMeta> | undefined>;
|
|
716
|
+
delete(key: string): Promise<void>;
|
|
717
|
+
list(options?: QueryDSL<BlobMeta>): Promise<Page<BlobMeta>>;
|
|
718
|
+
upload(props: {
|
|
719
|
+
file: File;
|
|
720
|
+
options?: {
|
|
721
|
+
key?: string;
|
|
722
|
+
contentType?: string;
|
|
723
|
+
};
|
|
724
|
+
}): Promise<Document<BlobMeta> | undefined>;
|
|
725
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
726
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
727
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
728
|
+
stream: () => AsyncIterable<Document<BlobMeta>>;
|
|
729
|
+
cancel: () => void;
|
|
730
|
+
status: () => "active" | "cancelled" | "completed";
|
|
731
|
+
};
|
|
732
|
+
page(_options?: Record<string, unknown>): PagedData<BlobMeta>;
|
|
733
|
+
download(key: string): Promise<{
|
|
734
|
+
data: Blob;
|
|
735
|
+
contentType: string;
|
|
736
|
+
}>;
|
|
737
|
+
}
|
|
738
|
+
declare class HestiaBlobClient {
|
|
739
|
+
private client;
|
|
740
|
+
private apiPrefix;
|
|
741
|
+
constructor(client: HestiaNetworkClient, apiPrefix?: string);
|
|
742
|
+
private nsBase;
|
|
743
|
+
namespaces(): Promise<NamespaceInfo[]>;
|
|
744
|
+
createNamespace(data: CreateNamespaceRequest): Promise<NamespaceInfo>;
|
|
745
|
+
deleteNamespace(ns: string): Promise<void>;
|
|
746
|
+
blob(namespace: string, key: string): string;
|
|
747
|
+
namespace(ns: string): BlobNamespace;
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region collections/types.d.ts
|
|
751
|
+
interface CollectionMeta {
|
|
752
|
+
name: string;
|
|
753
|
+
schema: SchemaDefinition;
|
|
754
|
+
created: string;
|
|
755
|
+
updated: string;
|
|
756
|
+
}
|
|
757
|
+
type CollectionDocument = Document<{
|
|
758
|
+
schema: any;
|
|
759
|
+
}>;
|
|
760
|
+
//#endregion
|
|
761
|
+
//#region collections/store.d.ts
|
|
762
|
+
declare class HestiaCollections implements DocumentStore<CollectionMeta, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
763
|
+
private client;
|
|
764
|
+
constructor(client: HestiaNetworkClient);
|
|
765
|
+
find(_query?: Record<string, unknown>): Promise<Page<CollectionMeta>>;
|
|
766
|
+
read(name: string): Promise<Document<CollectionMeta> | undefined>;
|
|
767
|
+
create(props: {
|
|
768
|
+
data: Partial<CollectionMeta>;
|
|
769
|
+
}): Promise<Document<CollectionMeta> | undefined>;
|
|
770
|
+
update(_props: {
|
|
771
|
+
data: Partial<CollectionMeta>;
|
|
772
|
+
options?: string;
|
|
773
|
+
}): Promise<Document<CollectionMeta> | undefined>;
|
|
774
|
+
delete(name: string): Promise<void>;
|
|
775
|
+
list(_options?: Record<string, unknown>): Promise<Page<CollectionMeta>>;
|
|
776
|
+
upload(_props: {
|
|
777
|
+
file: File;
|
|
778
|
+
}): Promise<Document<CollectionMeta> | undefined>;
|
|
779
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
780
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
781
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
782
|
+
stream: () => AsyncIterable<Document<CollectionMeta>>;
|
|
783
|
+
cancel: () => void;
|
|
784
|
+
status: () => "active" | "cancelled" | "completed";
|
|
785
|
+
};
|
|
786
|
+
page(_options?: Record<string, unknown>): PagedData<CollectionMeta>;
|
|
787
|
+
documents<T extends Record<string, any>>(collectionName: string): HestiaCollection<T>;
|
|
788
|
+
}
|
|
789
|
+
//#endregion
|
|
790
|
+
//#region node_modules/@asaidimu/utils-persistence/index.d.ts
|
|
791
|
+
interface SimplePersistence<T> {
|
|
792
|
+
/**
|
|
793
|
+
* Persists data to storage.
|
|
794
|
+
*
|
|
795
|
+
* @param id The **unique identifier of the *consumer instance*** making the change. This is NOT the ID of the data (`T`) itself.
|
|
796
|
+
* Think of it as the ID of the specific browser tab, component, or module that's currently interacting with the persistence layer.
|
|
797
|
+
* It should typically be a **UUID** generated once at the consumer instance's instantiation.
|
|
798
|
+
* This `id` is crucial for the `subscribe` method, helping to differentiate updates originating from the current instance versus other instances/tabs, thereby preventing self-triggered notification loops.
|
|
799
|
+
* @param state The state (of type T) to persist. This state is generally considered the **global or shared state** that all instances interact with.
|
|
800
|
+
* @returns `true` if the operation was successful, `false` if an error occurred. For asynchronous implementations (like `IndexedDBPersistence`), this returns a `Promise<boolean>`.
|
|
801
|
+
*/
|
|
802
|
+
set(id: string, state: T): boolean | Promise<boolean>;
|
|
803
|
+
/**
|
|
804
|
+
* Retrieves the global persisted data from storage.
|
|
805
|
+
*
|
|
806
|
+
* @returns The retrieved state of type `T`, or `null` if no data is found or if an error occurs during retrieval/parsing.
|
|
807
|
+
* For asynchronous implementations, this returns a `Promise<T | null>`.
|
|
808
|
+
*/
|
|
809
|
+
get(): (T | null) | Promise<T | null>;
|
|
810
|
+
/**
|
|
811
|
+
* Subscribes to changes in the global persisted data that originate from *other* instances of your application (e.g., other tabs or independent components using the same persistence layer).
|
|
812
|
+
*
|
|
813
|
+
* @param id The **unique identifier of the *consumer instance* subscribing**. This allows the persistence implementation to filter out notifications that were initiated by the subscribing instance itself.
|
|
814
|
+
* @param callback The function to call when the global persisted data changes from *another* source. The new state (`T`) is passed as an argument to this callback.
|
|
815
|
+
* @returns A function that, when called, will unsubscribe the provided callback from future updates. Call this when your component or instance is no longer active to prevent memory leaks.
|
|
816
|
+
*/
|
|
817
|
+
subscribe(id: string, callback: (state: T) => void): () => void;
|
|
818
|
+
/**
|
|
819
|
+
* Clears (removes) the entire global persisted data from storage.
|
|
820
|
+
*
|
|
821
|
+
* @returns `true` if the operation was successful, `false` if an error occurred. For asynchronous implementations, this returns a `Promise<boolean>`.
|
|
822
|
+
*/
|
|
823
|
+
clear(): boolean | Promise<boolean>;
|
|
824
|
+
/**
|
|
825
|
+
* Returns metadata about the persistence layer.
|
|
826
|
+
*
|
|
827
|
+
* This is useful for distinguishing between multiple apps running on the same host
|
|
828
|
+
* (e.g., several apps served at `localhost:3000` that share the same storage key).
|
|
829
|
+
*
|
|
830
|
+
* @returns An object containing:
|
|
831
|
+
* - `version`: The semantic version string of the persistence schema or application.
|
|
832
|
+
* - `id`: A unique identifier for the application using this persistence instance.
|
|
833
|
+
*/
|
|
834
|
+
stats(): {
|
|
835
|
+
version: string;
|
|
836
|
+
id: string;
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* Closes the persistence instance, releasing the file watcher.
|
|
840
|
+
* Call this when shutting down to clean up resources.
|
|
841
|
+
*/
|
|
842
|
+
close?: () => Promise<void>;
|
|
843
|
+
}
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region system/capabilities/store.d.ts
|
|
846
|
+
declare class HestiaCapabilities implements DocumentStore<any, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
847
|
+
private client;
|
|
848
|
+
constructor(client: HestiaNetworkClient);
|
|
849
|
+
find(_query?: Record<string, unknown>): Promise<Page<any>>;
|
|
850
|
+
read(_id: string): Promise<Document<any> | undefined>;
|
|
851
|
+
create(_props: {
|
|
852
|
+
data: Partial<any>;
|
|
853
|
+
}): Promise<Document<any> | undefined>;
|
|
854
|
+
update(_props: {
|
|
855
|
+
data: Partial<any>;
|
|
856
|
+
options?: string;
|
|
857
|
+
}): Promise<Document<any> | undefined>;
|
|
858
|
+
delete(_id: string): Promise<void>;
|
|
859
|
+
list(_options?: Record<string, unknown>): Promise<Page<any>>;
|
|
860
|
+
upload(_props: {
|
|
861
|
+
file: File;
|
|
862
|
+
}): Promise<Document<any> | undefined>;
|
|
863
|
+
subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
|
|
864
|
+
notify(_event: StoreEvent): Promise<void>;
|
|
865
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
866
|
+
stream: () => AsyncIterable<Document<any>>;
|
|
867
|
+
cancel: () => void;
|
|
868
|
+
status: () => "active" | "cancelled" | "completed";
|
|
869
|
+
};
|
|
870
|
+
page(_options?: Record<string, unknown>): PagedData<any>;
|
|
871
|
+
}
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region container.d.ts
|
|
874
|
+
interface HestiaConfig {
|
|
875
|
+
baseUrl: string;
|
|
876
|
+
apiPrefix?: string;
|
|
877
|
+
persistence?: SimplePersistence<AuthState>;
|
|
878
|
+
}
|
|
879
|
+
interface AuthState {
|
|
880
|
+
access: string | null;
|
|
881
|
+
refresh: string | null;
|
|
882
|
+
identity: UserIdentity | null;
|
|
883
|
+
}
|
|
884
|
+
declare class HestiaClient {
|
|
885
|
+
readonly store: ReactiveDataStore<AuthState>;
|
|
886
|
+
readonly client: HestiaNetworkClient;
|
|
887
|
+
readonly auth: HestiaAuth;
|
|
888
|
+
readonly users: HestiaUsers;
|
|
889
|
+
readonly keys: HestiaKeyStore;
|
|
890
|
+
readonly policies: HestiaPolicies;
|
|
891
|
+
readonly logs: HestiaLogs;
|
|
892
|
+
readonly collections: HestiaCollections;
|
|
893
|
+
readonly blobs: HestiaBlobClient;
|
|
894
|
+
readonly capabilities: HestiaCapabilities;
|
|
895
|
+
private tokenProvider;
|
|
896
|
+
private onAuthStateChanged?;
|
|
897
|
+
constructor(config: HestiaConfig);
|
|
898
|
+
onAuthStateChange(callback: () => void): void;
|
|
899
|
+
authenticated(): boolean;
|
|
900
|
+
collection<T extends Record<string, any>>(name: string): HestiaCollection<T>;
|
|
901
|
+
}
|
|
902
|
+
//#endregion
|
|
903
|
+
//#region utils/pager.d.ts
|
|
904
|
+
interface FetchResult<T extends Record<string, any>> {
|
|
905
|
+
data: T[];
|
|
906
|
+
replace: boolean;
|
|
907
|
+
scope: 'page' | 'collection';
|
|
908
|
+
total?: number;
|
|
909
|
+
}
|
|
910
|
+
interface ArrayPagerOptions<T extends Record<string, any>, F = any> {
|
|
911
|
+
collectionName: string;
|
|
912
|
+
initialData?: T[];
|
|
913
|
+
page?: number;
|
|
914
|
+
size?: number;
|
|
915
|
+
customFunctions?: Record<string, (...args: any[]) => boolean>;
|
|
916
|
+
fetch?: (query: QueryDSL<T, F>) => Promise<FetchResult<T>> | FetchResult<T>;
|
|
917
|
+
}
|
|
918
|
+
declare function createArrayPager<T extends Record<string, any>, F = any>(options: ArrayPagerOptions<T, F>): PagedData<T>;
|
|
919
|
+
//#endregion
|
|
920
|
+
export { APIKey, APIKeyWithSecret, ArrayPagerOptions, AuditEntry, BlobDocument, BlobMeta, BlobNamespace, BootstrapPasswordRequest, ChangePasswordRequest, CollectionDocument, CollectionMeta, CreateKeyRequest, CreateNamespaceRequest, CreateUserRequest, Document, DocumentStore, FetchResult, HestiaAuth, HestiaBlobClient, HestiaClient, HestiaCollection, HestiaCollections, HestiaKeyStore, HestiaLogs, HestiaNetworkClient, HestiaPolicies, HestiaResponse, HestiaUsers, IamRule, IdentityProvider, ListBlobsRequest, LogFilter, LoginRequest, LoginResult, NamespaceInfo, OperationPolicy, Page, PagedData, PagerRefreshOptions, PaginationInfo, RefreshRequest, RegisterRequest, ReloadResult, RequestLogEntry, ServerHealth, StoreEvent, StreamHandlers, StreamOptions, TokenPair, UpdateKeyRequest, UpdateUserRequest, UpsertOperationRequest, UpsertRuleRequest, UserData, UserIdentity, ValidateRuleRequest, ValidateRuleResult, createArrayPager, createPagedController, internalError, notFound, parseErrorBody, permissionDenied, toSystemError };
|