@asaidimu/hestia 1.0.7 → 1.2.0
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/README.md +9 -2
- package/index.cjs +3 -3
- package/index.d.cts +415 -75
- package/index.d.mts +102 -82
- package/index.mjs +3 -3
- package/package.json +2 -2
package/index.d.cts
CHANGED
|
@@ -3,18 +3,19 @@ import { ApiResponse } from "@asaidimu/network-client";
|
|
|
3
3
|
import { Issue, SystemError } from "@asaidimu/utils-error";
|
|
4
4
|
import { DataStore, ReactiveDataStore } from "@asaidimu/utils-store";
|
|
5
5
|
import { SchemaDefinition } from "@asaidimu/utils-schema";
|
|
6
|
+
import { SimplePersistence } from "@asaidimu/utils-persistence";
|
|
6
7
|
//#region core/types.d.ts
|
|
7
|
-
interface DocumentMetadata {
|
|
8
|
+
interface DocumentMetadata$1 {
|
|
8
9
|
checksum: string;
|
|
9
10
|
created: string;
|
|
10
11
|
updated: string;
|
|
11
12
|
version: number;
|
|
12
13
|
}
|
|
13
|
-
interface BaseDocument {
|
|
14
|
+
interface BaseDocument$1 {
|
|
14
15
|
_id_: string;
|
|
15
|
-
_metadata_: DocumentMetadata;
|
|
16
|
+
_metadata_: DocumentMetadata$1;
|
|
16
17
|
}
|
|
17
|
-
type Document<T extends Record<string, any>> = BaseDocument & T;
|
|
18
|
+
type Document<T extends Record<string, any>> = BaseDocument$1 & T;
|
|
18
19
|
/**
|
|
19
20
|
* Provides comprehensive pagination information for a collection of records.
|
|
20
21
|
*/
|
|
@@ -270,12 +271,12 @@ declare class HestiaResponse<T> {
|
|
|
270
271
|
readonly status: number;
|
|
271
272
|
constructor(data: T, status: number);
|
|
272
273
|
}
|
|
273
|
-
type BodyType = "json" | "form" | "text" | "blob" | "stream" | "auto";
|
|
274
|
-
type ResponseType = "json" | "text" | "blob" | "arrayBuffer" | "formData" | "auto";
|
|
274
|
+
type BodyType$1 = "json" | "form" | "text" | "blob" | "stream" | "auto";
|
|
275
|
+
type ResponseType$1 = "json" | "text" | "blob" | "arrayBuffer" | "formData" | "auto";
|
|
275
276
|
interface RequestOptions {
|
|
276
277
|
headers?: Record<string, string>;
|
|
277
|
-
responseType?: ResponseType;
|
|
278
|
-
bodyType?: BodyType;
|
|
278
|
+
responseType?: ResponseType$1;
|
|
279
|
+
bodyType?: BodyType$1;
|
|
279
280
|
signal?: AbortSignal;
|
|
280
281
|
}
|
|
281
282
|
interface StreamHandlers {
|
|
@@ -288,17 +289,50 @@ interface StreamOptions {
|
|
|
288
289
|
headers?: Record<string, string>;
|
|
289
290
|
signal?: AbortSignal;
|
|
290
291
|
}
|
|
291
|
-
|
|
292
|
+
interface DispatchInput {
|
|
293
|
+
arguments?: Record<string, string>;
|
|
294
|
+
modifiers?: Record<string, string | string[]>;
|
|
295
|
+
payload?: unknown;
|
|
296
|
+
headers?: Record<string, string>;
|
|
297
|
+
responseType?: ResponseType$1;
|
|
298
|
+
bodyType?: BodyType$1;
|
|
299
|
+
signal?: AbortSignal;
|
|
300
|
+
}
|
|
301
|
+
interface Transport {
|
|
302
|
+
base(): string;
|
|
303
|
+
prefix(): string;
|
|
304
|
+
ready(): Promise<void>;
|
|
305
|
+
dispatch<T>(name: string, input?: DispatchInput): Promise<HestiaResponse<T>>;
|
|
306
|
+
get<T>(path: string, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
307
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
308
|
+
patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
309
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
310
|
+
delete<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
311
|
+
check<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
312
|
+
openStream(path: string, handlers: StreamHandlers, options?: StreamOptions): Promise<void>;
|
|
313
|
+
}
|
|
314
|
+
declare class HttpTransport implements Transport {
|
|
292
315
|
private baseUrl;
|
|
293
316
|
private apiPrefix;
|
|
294
317
|
private provider;
|
|
295
318
|
private onAuthStateChanged?;
|
|
296
319
|
private raw;
|
|
320
|
+
private heartbeatTimer?;
|
|
321
|
+
private defaultHeartbeatInterval;
|
|
322
|
+
private routeCache;
|
|
297
323
|
constructor(baseUrl: string, apiPrefix: string, provider: IdentityProvider, onAuthStateChanged?: (() => void) | undefined);
|
|
324
|
+
private getRouteCache;
|
|
325
|
+
private substituteArgs;
|
|
326
|
+
dispatch<T>(name: string, input?: DispatchInput): Promise<HestiaResponse<T>>;
|
|
298
327
|
base(): string;
|
|
299
328
|
prefix(): string;
|
|
329
|
+
ready(): Promise<void>;
|
|
330
|
+
startHeartbeat(intervalMs?: number): void;
|
|
331
|
+
stopHeartbeat(): void;
|
|
332
|
+
private heartbeat;
|
|
300
333
|
private canonicalPath;
|
|
301
334
|
private request;
|
|
335
|
+
check<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
302
336
|
get<T>(path: string, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
303
337
|
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
304
338
|
patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
@@ -306,6 +340,48 @@ declare class HestiaNetworkClient {
|
|
|
306
340
|
delete<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
307
341
|
openStream(path: string, handlers: StreamHandlers, options?: StreamOptions): Promise<void>;
|
|
308
342
|
}
|
|
343
|
+
declare const HestiaNetworkClient: typeof HttpTransport;
|
|
344
|
+
type HestiaNetworkClient = HttpTransport;
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region core/wails-transport.d.ts
|
|
347
|
+
declare global {
|
|
348
|
+
interface Window {
|
|
349
|
+
go?: Record<string, Record<string, Record<string, (...args: unknown[]) => Promise<unknown>>>>;
|
|
350
|
+
runtime?: {
|
|
351
|
+
Call: (method: string, ...args: unknown[]) => Promise<unknown>;
|
|
352
|
+
EventsOn: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
353
|
+
EventsOff: (event: string) => void;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
interface WailsTransportConfig {
|
|
358
|
+
pkg: string;
|
|
359
|
+
struct: string;
|
|
360
|
+
}
|
|
361
|
+
declare class WailsTransport implements Transport {
|
|
362
|
+
private baseUrl;
|
|
363
|
+
private apiPrefix;
|
|
364
|
+
private init;
|
|
365
|
+
private config?;
|
|
366
|
+
constructor(config?: WailsTransportConfig);
|
|
367
|
+
private resolveService;
|
|
368
|
+
base(): string;
|
|
369
|
+
prefix(): string;
|
|
370
|
+
/**
|
|
371
|
+
* Polls window.go until Wails bindings are available.
|
|
372
|
+
* Concurrent callers share the single initialization attempt.
|
|
373
|
+
*/
|
|
374
|
+
ready(timeoutMs?: number): Promise<void>;
|
|
375
|
+
dispatch<T>(name: string, input?: DispatchInput): Promise<HestiaResponse<T>>;
|
|
376
|
+
check<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
377
|
+
get<T>(path: string, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
378
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
379
|
+
patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
380
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
381
|
+
delete<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HestiaResponse<T>>;
|
|
382
|
+
private request;
|
|
383
|
+
openStream(path: string, handlers: StreamHandlers, _options?: StreamOptions): Promise<void>;
|
|
384
|
+
}
|
|
309
385
|
//#endregion
|
|
310
386
|
//#region core/collection.d.ts
|
|
311
387
|
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>> {
|
|
@@ -314,11 +390,8 @@ declare class HestiaCollection<T extends Record<string, any>> implements Documen
|
|
|
314
390
|
private defaultLimit;
|
|
315
391
|
private pagerOptions;
|
|
316
392
|
private pager;
|
|
317
|
-
constructor(client:
|
|
393
|
+
constructor(client: Transport, collectionName: string, defaultLimit?: number);
|
|
318
394
|
name(): string;
|
|
319
|
-
private get queryPath();
|
|
320
|
-
private get documentsPath();
|
|
321
|
-
private documentPath;
|
|
322
395
|
find(query?: Record<string, unknown>): Promise<Page<T>>;
|
|
323
396
|
read(id: string): Promise<Document<T> | undefined>;
|
|
324
397
|
create(props: {
|
|
@@ -392,7 +465,7 @@ interface BootstrapPasswordRequest {
|
|
|
392
465
|
declare class HestiaAuth {
|
|
393
466
|
private client;
|
|
394
467
|
private provider;
|
|
395
|
-
constructor(client:
|
|
468
|
+
constructor(client: Transport, provider: IdentityProvider);
|
|
396
469
|
health(): Promise<ServerHealth>;
|
|
397
470
|
login(email: string, password: string): Promise<LoginResult>;
|
|
398
471
|
register(email: string, password: string, name: string): Promise<{
|
|
@@ -411,7 +484,7 @@ declare class HestiaUsers implements DocumentStore<UserData, QueryDSL<UserData>,
|
|
|
411
484
|
private client;
|
|
412
485
|
private pagerOptions;
|
|
413
486
|
private pager;
|
|
414
|
-
constructor(client:
|
|
487
|
+
constructor(client: Transport);
|
|
415
488
|
name(): string;
|
|
416
489
|
find(query?: QueryDSL<UserData>): Promise<Page<UserData>>;
|
|
417
490
|
list(options?: QueryDSL<UserData>): Promise<Page<UserData>>;
|
|
@@ -421,7 +494,7 @@ declare class HestiaUsers implements DocumentStore<UserData, QueryDSL<UserData>,
|
|
|
421
494
|
options?: string;
|
|
422
495
|
}): Promise<Document<UserData> | undefined>;
|
|
423
496
|
delete(id: string): Promise<void>;
|
|
424
|
-
create(
|
|
497
|
+
create(_props: {
|
|
425
498
|
data: Partial<UserData>;
|
|
426
499
|
}): Promise<Document<UserData> | undefined>;
|
|
427
500
|
upload(_props: {
|
|
@@ -472,8 +545,7 @@ interface UpdateKeyRequest {
|
|
|
472
545
|
declare class HestiaKeyStore implements DocumentStore<APIKey, QueryDSL<APIKey>, string, QueryDSL<APIKey>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
473
546
|
private client;
|
|
474
547
|
private pager;
|
|
475
|
-
constructor(client:
|
|
476
|
-
private basePath;
|
|
548
|
+
constructor(client: Transport);
|
|
477
549
|
find(_query?: QueryDSL<APIKey>): Promise<Page<APIKey>>;
|
|
478
550
|
list(options?: QueryDSL<APIKey>): Promise<Page<APIKey>>;
|
|
479
551
|
read(id: string): Promise<Document<APIKey> | undefined>;
|
|
@@ -509,7 +581,7 @@ interface Operation {
|
|
|
509
581
|
//#region system/operations/store.d.ts
|
|
510
582
|
declare class HestiaOperations {
|
|
511
583
|
private client;
|
|
512
|
-
constructor(client:
|
|
584
|
+
constructor(client: Transport);
|
|
513
585
|
list(): Promise<Page<Operation>>;
|
|
514
586
|
read(name: string): Promise<Document<Operation> | undefined>;
|
|
515
587
|
}
|
|
@@ -536,7 +608,7 @@ interface SetPolicyEnabledRequest {
|
|
|
536
608
|
declare class HestiaPolicies implements DocumentStore<Policy, QueryDSL<Policy>, string, QueryDSL<Policy>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
537
609
|
private client;
|
|
538
610
|
private pager;
|
|
539
|
-
constructor(client:
|
|
611
|
+
constructor(client: Transport);
|
|
540
612
|
find(_query?: QueryDSL<Policy>): Promise<Page<Policy>>;
|
|
541
613
|
query(qdsl: Record<string, unknown>): Promise<Page<Policy>>;
|
|
542
614
|
list(_options?: QueryDSL<Policy>): Promise<Page<Policy>>;
|
|
@@ -598,14 +670,17 @@ interface RuleNode {
|
|
|
598
670
|
conditions?: RuleNode[];
|
|
599
671
|
}
|
|
600
672
|
interface ValidateRuleRequest {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
673
|
+
rule: string | RuleNode;
|
|
674
|
+
context?: {
|
|
675
|
+
identity?: Record<string, unknown>;
|
|
676
|
+
resource?: Record<string, unknown>;
|
|
677
|
+
environment?: Record<string, unknown>;
|
|
678
|
+
};
|
|
605
679
|
}
|
|
606
680
|
interface ValidateRuleResult {
|
|
607
681
|
valid: boolean;
|
|
608
682
|
result?: boolean;
|
|
683
|
+
error?: string;
|
|
609
684
|
}
|
|
610
685
|
interface ReloadResult {
|
|
611
686
|
operations: number;
|
|
@@ -615,7 +690,7 @@ interface ReloadResult {
|
|
|
615
690
|
//#region system/rules/store.d.ts
|
|
616
691
|
declare class HestiaRules implements DocumentStore<PolicyRule, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
617
692
|
private client;
|
|
618
|
-
constructor(client:
|
|
693
|
+
constructor(client: Transport);
|
|
619
694
|
find(_query?: Record<string, unknown>): Promise<Page<PolicyRule>>;
|
|
620
695
|
list(_options?: Record<string, unknown>): Promise<Page<PolicyRule>>;
|
|
621
696
|
read(id: string): Promise<Document<PolicyRule> | undefined>;
|
|
@@ -628,7 +703,7 @@ declare class HestiaRules implements DocumentStore<PolicyRule, Record<string, un
|
|
|
628
703
|
options?: string;
|
|
629
704
|
}): Promise<Document<PolicyRule> | undefined>;
|
|
630
705
|
delete(name: string): Promise<void>;
|
|
631
|
-
validate(
|
|
706
|
+
validate(request: ValidateRuleRequest): Promise<ValidateRuleResult>;
|
|
632
707
|
reload(): Promise<ReloadResult>;
|
|
633
708
|
upload(_props: {
|
|
634
709
|
file: File;
|
|
@@ -688,7 +763,7 @@ declare class HestiaLogs implements DocumentStore<AuditEntry, QueryDSL<AuditEntr
|
|
|
688
763
|
private pagerOptions;
|
|
689
764
|
private pager;
|
|
690
765
|
private apiPrefix;
|
|
691
|
-
constructor(client:
|
|
766
|
+
constructor(client: Transport, baseUrl: string, apiPrefix?: string);
|
|
692
767
|
find(query?: QueryDSL<AuditEntry>): Promise<Page<AuditEntry>>;
|
|
693
768
|
list(options?: QueryDSL<AuditEntry>): Promise<Page<AuditEntry>>;
|
|
694
769
|
read(_id: string): Promise<Document<AuditEntry> | undefined>;
|
|
@@ -748,10 +823,9 @@ declare class BlobNamespace implements DocumentStore<BlobMeta, QueryDSL<BlobMeta
|
|
|
748
823
|
private pagerOptions;
|
|
749
824
|
private pager;
|
|
750
825
|
private prefixFilter;
|
|
751
|
-
constructor(client:
|
|
826
|
+
constructor(client: Transport, ns: string);
|
|
752
827
|
name(): string;
|
|
753
828
|
setPrefix(prefix: string): void;
|
|
754
|
-
private basePath;
|
|
755
829
|
find(query?: QueryDSL<BlobMeta>): Promise<Page<BlobMeta>>;
|
|
756
830
|
read(key: string): Promise<Document<BlobMeta> | undefined>;
|
|
757
831
|
create(_props: {
|
|
@@ -786,8 +860,7 @@ declare class BlobNamespace implements DocumentStore<BlobMeta, QueryDSL<BlobMeta
|
|
|
786
860
|
declare class HestiaBlobClient {
|
|
787
861
|
private client;
|
|
788
862
|
private apiPrefix;
|
|
789
|
-
constructor(client:
|
|
790
|
-
private nsBase;
|
|
863
|
+
constructor(client: Transport, apiPrefix?: string);
|
|
791
864
|
namespaces(): Promise<NamespaceInfo[]>;
|
|
792
865
|
createNamespace(data: CreateNamespaceRequest): Promise<NamespaceInfo>;
|
|
793
866
|
deleteNamespace(ns: string): Promise<void>;
|
|
@@ -809,7 +882,7 @@ type CollectionDocument = Document<{
|
|
|
809
882
|
//#region collections/store.d.ts
|
|
810
883
|
declare class HestiaCollections implements DocumentStore<CollectionMeta, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
811
884
|
private client;
|
|
812
|
-
constructor(client:
|
|
885
|
+
constructor(client: Transport);
|
|
813
886
|
find(_query?: Record<string, unknown>): Promise<Page<CollectionMeta>>;
|
|
814
887
|
read(name: string): Promise<Document<CollectionMeta> | undefined>;
|
|
815
888
|
create(props: {
|
|
@@ -835,65 +908,330 @@ declare class HestiaCollections implements DocumentStore<CollectionMeta, Record<
|
|
|
835
908
|
documents<T extends Record<string, any>>(collectionName: string): HestiaCollection<T>;
|
|
836
909
|
}
|
|
837
910
|
//#endregion
|
|
838
|
-
//#region
|
|
839
|
-
|
|
911
|
+
//#region dist/index.d.mts
|
|
912
|
+
//#region core/types.d.ts
|
|
913
|
+
interface DocumentMetadata {
|
|
914
|
+
checksum: string;
|
|
915
|
+
created: string;
|
|
916
|
+
updated: string;
|
|
917
|
+
version: number;
|
|
918
|
+
}
|
|
919
|
+
interface BaseDocument {
|
|
920
|
+
_id_: string;
|
|
921
|
+
_metadata_: DocumentMetadata;
|
|
922
|
+
}
|
|
923
|
+
type Document$1<T extends Record<string, any>> = BaseDocument & T;
|
|
924
|
+
/**
|
|
925
|
+
* Provides comprehensive pagination information for a collection of records.
|
|
926
|
+
*/
|
|
927
|
+
type PaginationInfo$1 = {
|
|
928
|
+
/** The current page number (1-based). */
|
|
929
|
+
number: number;
|
|
930
|
+
/** The maximum number of items requested per page. */
|
|
931
|
+
size: number;
|
|
932
|
+
/** The number of items in the current page */
|
|
933
|
+
count: number;
|
|
934
|
+
/** The total count of all items across all pages. */
|
|
935
|
+
total: number;
|
|
936
|
+
/** The total number of available pages. */
|
|
937
|
+
pages: number;
|
|
938
|
+
};
|
|
939
|
+
/**
|
|
940
|
+
* Represents a single paginated response containing a list of records and pagination details.
|
|
941
|
+
* @template T The type of the records in the page.
|
|
942
|
+
*/
|
|
943
|
+
interface Page$1<T extends Record<string, any>> {
|
|
944
|
+
/** The array of records for the current page. */
|
|
945
|
+
data: Document$1<T>[];
|
|
946
|
+
/** Indicates if the data query is currently loading. */
|
|
947
|
+
loading: boolean;
|
|
948
|
+
/** An error object if the query failed, otherwise `undefined`. */
|
|
949
|
+
error?: any | undefined;
|
|
950
|
+
/** Pagination metadata providing details about the current page and total collection. */
|
|
951
|
+
page: PaginationInfo$1;
|
|
952
|
+
}
|
|
953
|
+
interface PagerRefreshOptions$1 {
|
|
954
|
+
sort?: SortConfiguration | SortConfiguration[];
|
|
955
|
+
filter?: QueryFilter;
|
|
956
|
+
delay?: number;
|
|
957
|
+
size?: number;
|
|
958
|
+
page?: number;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Represents the complete state and control mechanisms for consuming paginated data.
|
|
962
|
+
* @template T The type of the records in the page (`TableRowData` or an extension).
|
|
963
|
+
*/
|
|
964
|
+
interface PagedData$1<T extends Record<string, any>> {
|
|
965
|
+
id: () => string;
|
|
966
|
+
/** The current paginated data, or `undefined` if not found or still loading. */
|
|
967
|
+
page: () => Page$1<T>;
|
|
968
|
+
/** Function to fetch a specific page of data.
|
|
969
|
+
* @param page The 1-based page number to fetch.
|
|
970
|
+
*/
|
|
971
|
+
navigate: (page: number) => Promise<void>;
|
|
972
|
+
sort: (sort: SortConfiguration<T> | SortConfiguration<T>[]) => Promise<void>;
|
|
973
|
+
filter: (filter?: QueryFilter<T>) => Promise<void>;
|
|
840
974
|
/**
|
|
841
|
-
*
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
* Think of it as the ID of the specific browser tab, component, or module that's currently interacting with the persistence layer.
|
|
845
|
-
* It should typically be a **UUID** generated once at the consumer instance's instantiation.
|
|
846
|
-
* 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.
|
|
847
|
-
* @param state The state (of type T) to persist. This state is generally considered the **global or shared state** that all instances interact with.
|
|
848
|
-
* @returns `true` if the operation was successful, `false` if an error occurred. For asynchronous implementations (like `IndexedDBPersistence`), this returns a `Promise<boolean>`.
|
|
849
|
-
*/
|
|
850
|
-
set(id: string, state: T): boolean | Promise<boolean>;
|
|
975
|
+
* Function to change the page size of the data
|
|
976
|
+
*/
|
|
977
|
+
resize: (size: number, page: number) => Promise<void>;
|
|
851
978
|
/**
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
* @returns The retrieved state of type `T`, or `null` if no data is found or if an error occurs during retrieval/parsing.
|
|
855
|
-
* For asynchronous implementations, this returns a `Promise<T | null>`.
|
|
979
|
+
* Function to force a refresh of the current page data, optionally with a delay.
|
|
980
|
+
* @param delay Optional delay in milliseconds before the refresh operation starts.
|
|
856
981
|
*/
|
|
857
|
-
|
|
982
|
+
refresh: (opts?: PagerRefreshOptions$1) => Promise<void>;
|
|
858
983
|
/**
|
|
859
|
-
* Subscribes to changes
|
|
984
|
+
* Subscribes to page changes.
|
|
985
|
+
* The callback is invoked immediately with the current page, and then on every
|
|
986
|
+
* subsequent change (navigation, resize, SSE patch, refresh).
|
|
860
987
|
*
|
|
861
|
-
* @param
|
|
862
|
-
* @
|
|
863
|
-
* @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.
|
|
988
|
+
* @param listener A function that receives the current Page<T>.
|
|
989
|
+
* @returns An unsubscribe function.
|
|
864
990
|
*/
|
|
865
|
-
subscribe
|
|
991
|
+
subscribe: (listener: (page: Page$1<T>) => void) => () => void;
|
|
866
992
|
/**
|
|
867
|
-
*
|
|
993
|
+
* Invalidates the pagination controller, cleaning up any cached resources
|
|
994
|
+
* (e.g., store subscriptions, in‑flight requests) and removing internal state.
|
|
995
|
+
* After calling `invalidate()`, the controller should no longer be used.
|
|
868
996
|
*
|
|
869
|
-
*
|
|
997
|
+
* This is useful when the component using the pager is unmounted or when
|
|
998
|
+
* you need to reset the pagination state completely.
|
|
870
999
|
*/
|
|
871
|
-
|
|
1000
|
+
invalidate: () => void;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Represents an event emitted by the store, typically for notifications or state changes.
|
|
1004
|
+
*/
|
|
1005
|
+
interface StoreEvent$1 {
|
|
1006
|
+
/** The scope of the event, indicating its type and context. Custom scopes are allowed. */
|
|
1007
|
+
scope: string;
|
|
1008
|
+
/** Optional payload carrying data related to the event. */
|
|
1009
|
+
payload?: any;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Defines the core interface for interacting with a remote data store.
|
|
1013
|
+
* @template T The type of the records managed by the store, extending Record.
|
|
1014
|
+
* @template TFindOptions Options for the find operation.
|
|
1015
|
+
* @template TReadOptions Options for the read operation.
|
|
1016
|
+
* @template TListOptions Options for the list operation.
|
|
1017
|
+
* @template TPageOptions Options for the paging operation.
|
|
1018
|
+
* @template TDeleteOptions Options for the delete operation.
|
|
1019
|
+
* @template TUpdateOptions Options for the update operation.
|
|
1020
|
+
* @template TCreateOptions Options for the create operation.
|
|
1021
|
+
* @template TUploadOptions Options for the upload operation.
|
|
1022
|
+
* @template TStreamOptions Options for the stream operation.
|
|
1023
|
+
*/
|
|
1024
|
+
interface DocumentStore$1<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>> {
|
|
872
1025
|
/**
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
*
|
|
880
|
-
*
|
|
1026
|
+
* Finds records based on provided options, returning a paginated result.
|
|
1027
|
+
* @param options The options for the find operation.
|
|
1028
|
+
* @returns A promise that resolves to a Page of records.
|
|
1029
|
+
*/
|
|
1030
|
+
find: (options: TFindOptions) => Promise<Page$1<T>>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Reads a single record by its identifier or other read options.
|
|
1033
|
+
* @param options The options for the read operation, typically including an ID.
|
|
1034
|
+
* @returns A promise that resolves to the record or undefined if not found.
|
|
881
1035
|
*/
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1036
|
+
read: (options: TReadOptions) => Promise<Document$1<T> | undefined>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Lists records based on provided options, returning a paginated result.
|
|
1039
|
+
* @param options The options for the list operation.
|
|
1040
|
+
* @returns A promise that resolves to a Page of records.
|
|
1041
|
+
*/
|
|
1042
|
+
list: (options: TListOptions) => Promise<Page$1<T>>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Deletes a record based on provided options, typically including an ID.
|
|
1045
|
+
* @param options The options for the delete operation.
|
|
1046
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
1047
|
+
*/
|
|
1048
|
+
delete: (options: TDeleteOptions) => Promise<void>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Updates an existing record.
|
|
1051
|
+
* @param props An object containing the ID of the record to update, the partial data, and optional update options.
|
|
1052
|
+
* @returns A promise that resolves to the updated record or undefined if not found.
|
|
1053
|
+
*/
|
|
1054
|
+
update: (props: {
|
|
1055
|
+
data: Partial<T>;
|
|
1056
|
+
options?: TUpdateOptions;
|
|
1057
|
+
}) => Promise<Document$1<T> | undefined>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Creates a new record.
|
|
1060
|
+
* @param props An object containing the data for the new record and optional create options.
|
|
1061
|
+
* @returns A promise that resolves to the newly created record or undefined if creation failed.
|
|
1062
|
+
*/
|
|
1063
|
+
create: (props: {
|
|
1064
|
+
data: Partial<T>;
|
|
1065
|
+
options?: TCreateOptions;
|
|
1066
|
+
}) => Promise<Document$1<T> | undefined>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Uploads a file associated with a record. Optionally updates the record with upload details.
|
|
1069
|
+
* @param props An object containing the file to upload and optional upload options.
|
|
1070
|
+
* @returns A promise that resolves to the updated record after upload or undefined if upload failed.
|
|
1071
|
+
*/
|
|
1072
|
+
upload: (props: {
|
|
1073
|
+
file: File;
|
|
1074
|
+
options?: TUploadOptions;
|
|
1075
|
+
}) => Promise<Document$1<T> | undefined>;
|
|
1076
|
+
/**
|
|
1077
|
+
* Subscribes to store events for a given scope.
|
|
1078
|
+
* @param scope The event scope to subscribe to (e.g., 'todos:created:success', '*').
|
|
1079
|
+
* @param callback The function to call when an event matching the scope is received.
|
|
1080
|
+
* @returns A promise that resolves to an unsubscribe function. Call this function to stop receiving events.
|
|
1081
|
+
*/
|
|
1082
|
+
subscribe(scope: string, callback: (event: StoreEvent$1) => void): Promise<() => void>;
|
|
1083
|
+
/**
|
|
1084
|
+
* Notifies the store of an event, which can then be broadcast to subscribers.
|
|
1085
|
+
* @param event The StoreEvent to notify.
|
|
1086
|
+
* @returns A promise that resolves when the notification has been processed.
|
|
1087
|
+
*/
|
|
1088
|
+
notify: (event: StoreEvent$1) => Promise<void>;
|
|
1089
|
+
/**
|
|
1090
|
+
* Establishes a stream of records based on provided options.
|
|
1091
|
+
* @param options Options for configuring the stream (e.g., batch size, delay, filters).
|
|
1092
|
+
* @param onStreamChange A callback function that is called when the stream's status changes.
|
|
1093
|
+
* @returns An object containing the async iterable stream, a cancel function, and a status getter.
|
|
1094
|
+
*/
|
|
1095
|
+
stream: (options: TStreamOptions, onStreamChange: () => void) => {
|
|
1096
|
+
/** An async iterable that yields records as they become available in the stream. */
|
|
1097
|
+
stream: () => AsyncIterable<Document$1<T>>;
|
|
1098
|
+
/** A function to call to cancel the ongoing stream. */
|
|
1099
|
+
cancel: () => void;
|
|
1100
|
+
/** A getter function that returns the current status of the stream ('active', 'cancelled', or 'completed'). */
|
|
1101
|
+
status: () => "active" | "cancelled" | "completed";
|
|
885
1102
|
};
|
|
886
1103
|
/**
|
|
887
|
-
*
|
|
888
|
-
*
|
|
1104
|
+
* Creates a paginated data controller for this store.
|
|
1105
|
+
*
|
|
1106
|
+
* @param options - The pagination options, whose type is defined by the
|
|
1107
|
+
* store's `TPageOptions` generic parameter. This lets you
|
|
1108
|
+
* pass any configuration (e.g., filters, sorting, custom
|
|
1109
|
+
* pagination metadata) that your store implementation needs.
|
|
1110
|
+
* @returns A `PagedData<T>` controller that manages loading, navigation,
|
|
1111
|
+
* resizing, and refresh.
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* // Define your store with a custom TPageOptions type
|
|
1115
|
+
* interface MyTodoStore extends DocumentStore<
|
|
1116
|
+
* Todo,
|
|
1117
|
+
* FindOptions,
|
|
1118
|
+
* ReadOptions,
|
|
1119
|
+
* ListOptions,
|
|
1120
|
+
* { page: number; size: number; sort?: string; filter?: string }
|
|
1121
|
+
* > {}
|
|
1122
|
+
*
|
|
1123
|
+
* // Use it
|
|
1124
|
+
* const todosPaged = myTodoStore.page({
|
|
1125
|
+
* page: 1,
|
|
1126
|
+
* size: 10,
|
|
1127
|
+
* sort: 'createdAt',
|
|
1128
|
+
* filter: 'done:false'
|
|
1129
|
+
* });
|
|
1130
|
+
*
|
|
1131
|
+
* // Get current page state
|
|
1132
|
+
* const { data, loading, page } = todosPaged.page();
|
|
1133
|
+
* console.log(`Page ${page.number} of ${page.pages}`);
|
|
1134
|
+
*
|
|
1135
|
+
* // Navigate
|
|
1136
|
+
* await todosPaged.navigate(2);
|
|
889
1137
|
*/
|
|
890
|
-
|
|
1138
|
+
page(options: TPageOptions): PagedData$1<T>;
|
|
1139
|
+
}
|
|
1140
|
+
declare class HestiaResponse$1<T> {
|
|
1141
|
+
readonly data: T;
|
|
1142
|
+
readonly status: number;
|
|
1143
|
+
constructor(data: T, status: number);
|
|
1144
|
+
}
|
|
1145
|
+
type BodyType = "json" | "form" | "text" | "blob" | "stream" | "auto";
|
|
1146
|
+
type ResponseType = "json" | "text" | "blob" | "arrayBuffer" | "formData" | "auto";
|
|
1147
|
+
interface RequestOptions$1 {
|
|
1148
|
+
headers?: Record<string, string>;
|
|
1149
|
+
responseType?: ResponseType;
|
|
1150
|
+
bodyType?: BodyType;
|
|
1151
|
+
signal?: AbortSignal;
|
|
1152
|
+
}
|
|
1153
|
+
interface StreamHandlers$1 {
|
|
1154
|
+
onMessage: (data: string) => void;
|
|
1155
|
+
onError?: (err: Error) => void;
|
|
1156
|
+
onOpen?: () => void;
|
|
1157
|
+
onClose?: () => void;
|
|
1158
|
+
}
|
|
1159
|
+
interface StreamOptions$1 {
|
|
1160
|
+
headers?: Record<string, string>;
|
|
1161
|
+
signal?: AbortSignal;
|
|
1162
|
+
}
|
|
1163
|
+
interface DispatchInput$1 {
|
|
1164
|
+
arguments?: Record<string, string>;
|
|
1165
|
+
modifiers?: Record<string, string | string[]>;
|
|
1166
|
+
payload?: unknown;
|
|
1167
|
+
headers?: Record<string, string>;
|
|
1168
|
+
responseType?: ResponseType;
|
|
1169
|
+
bodyType?: BodyType;
|
|
1170
|
+
signal?: AbortSignal;
|
|
1171
|
+
}
|
|
1172
|
+
interface Transport$1 {
|
|
1173
|
+
base(): string;
|
|
1174
|
+
prefix(): string;
|
|
1175
|
+
ready(): Promise<void>;
|
|
1176
|
+
dispatch<T>(name: string, input?: DispatchInput$1): Promise<HestiaResponse$1<T>>;
|
|
1177
|
+
get<T>(path: string, options?: RequestOptions$1): Promise<HestiaResponse$1<T>>;
|
|
1178
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions$1): Promise<HestiaResponse$1<T>>;
|
|
1179
|
+
patch<T>(path: string, body?: unknown, options?: RequestOptions$1): Promise<HestiaResponse$1<T>>;
|
|
1180
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions$1): Promise<HestiaResponse$1<T>>;
|
|
1181
|
+
delete<T>(path: string, body?: unknown, options?: RequestOptions$1): Promise<HestiaResponse$1<T>>;
|
|
1182
|
+
check<T>(path: string, body?: unknown, options?: RequestOptions$1): Promise<HestiaResponse$1<T>>;
|
|
1183
|
+
openStream(path: string, handlers: StreamHandlers$1, options?: StreamOptions$1): Promise<void>;
|
|
1184
|
+
}
|
|
1185
|
+
//#endregion
|
|
1186
|
+
//#region core/wails-transport.d.ts
|
|
1187
|
+
declare global {
|
|
1188
|
+
interface Window {
|
|
1189
|
+
go?: Record<string, Record<string, Record<string, (...args: unknown[]) => Promise<unknown>>>>;
|
|
1190
|
+
runtime?: {
|
|
1191
|
+
Call: (method: string, ...args: unknown[]) => Promise<unknown>;
|
|
1192
|
+
EventsOn: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
1193
|
+
EventsOff: (event: string) => void;
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region core/collection.d.ts
|
|
1199
|
+
declare class HestiaCollection$1<T extends Record<string, any>> implements DocumentStore$1<T, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
1200
|
+
private client;
|
|
1201
|
+
private collectionName;
|
|
1202
|
+
private defaultLimit;
|
|
1203
|
+
private pagerOptions;
|
|
1204
|
+
private pager;
|
|
1205
|
+
constructor(client: Transport$1, collectionName: string, defaultLimit?: number);
|
|
1206
|
+
name(): string;
|
|
1207
|
+
find(query?: Record<string, unknown>): Promise<Page$1<T>>;
|
|
1208
|
+
read(id: string): Promise<Document$1<T> | undefined>;
|
|
1209
|
+
create(props: {
|
|
1210
|
+
data: Partial<T>;
|
|
1211
|
+
}): Promise<Document$1<T> | undefined>;
|
|
1212
|
+
update(props: {
|
|
1213
|
+
data: Partial<T>;
|
|
1214
|
+
options?: string;
|
|
1215
|
+
}): Promise<Document$1<T> | undefined>;
|
|
1216
|
+
delete(id: string): Promise<void>;
|
|
1217
|
+
list(options?: Record<string, unknown>): Promise<Page$1<T>>;
|
|
1218
|
+
upload(_props: {
|
|
1219
|
+
file: File;
|
|
1220
|
+
}): Promise<Document$1<T> | undefined>;
|
|
1221
|
+
subscribe(_scope: string, _callback: (event: StoreEvent$1) => void): Promise<() => void>;
|
|
1222
|
+
notify(_event: StoreEvent$1): Promise<void>;
|
|
1223
|
+
stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
|
|
1224
|
+
stream: () => AsyncIterable<Document$1<T>>;
|
|
1225
|
+
cancel: () => void;
|
|
1226
|
+
status: () => "active" | "cancelled" | "completed";
|
|
1227
|
+
};
|
|
1228
|
+
page(_options?: Record<string, unknown>): PagedData$1<T>;
|
|
891
1229
|
}
|
|
892
1230
|
//#endregion
|
|
893
1231
|
//#region system/capabilities/store.d.ts
|
|
894
1232
|
declare class HestiaCapabilities implements DocumentStore<any, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
|
|
895
1233
|
private client;
|
|
896
|
-
constructor(client:
|
|
1234
|
+
constructor(client: Transport);
|
|
897
1235
|
find(_query?: Record<string, unknown>): Promise<Page<any>>;
|
|
898
1236
|
read(_id: string): Promise<Document<any> | undefined>;
|
|
899
1237
|
create(_props: {
|
|
@@ -923,13 +1261,14 @@ interface HestiaConfig {
|
|
|
923
1261
|
baseUrl: string;
|
|
924
1262
|
apiPrefix?: string;
|
|
925
1263
|
persistence?: SimplePersistence<AuthState>;
|
|
1264
|
+
transport?: Transport;
|
|
926
1265
|
}
|
|
927
1266
|
interface AuthState {
|
|
928
1267
|
identity: UserIdentity | null;
|
|
929
1268
|
}
|
|
930
1269
|
declare class HestiaClient {
|
|
931
1270
|
readonly store: ReactiveDataStore<AuthState>;
|
|
932
|
-
readonly client:
|
|
1271
|
+
readonly client: Transport;
|
|
933
1272
|
readonly auth: HestiaAuth;
|
|
934
1273
|
readonly users: HestiaUsers;
|
|
935
1274
|
readonly keys: HestiaKeyStore;
|
|
@@ -944,7 +1283,8 @@ declare class HestiaClient {
|
|
|
944
1283
|
constructor(config: HestiaConfig);
|
|
945
1284
|
onAuthStateChange(callback: () => void): void;
|
|
946
1285
|
authenticated(): boolean;
|
|
947
|
-
collection<T extends Record<string, any>>(name: string): HestiaCollection<T>;
|
|
1286
|
+
collection<T extends Record<string, any>>(name: string): HestiaCollection$1<T>;
|
|
1287
|
+
ready(): Promise<void>;
|
|
948
1288
|
}
|
|
949
1289
|
//#endregion
|
|
950
1290
|
//#region utils/pager.d.ts
|
|
@@ -964,4 +1304,4 @@ interface ArrayPagerOptions<T extends Record<string, any>, F = any> {
|
|
|
964
1304
|
}
|
|
965
1305
|
declare function createArrayPager<T extends Record<string, any>, F = any>(options: ArrayPagerOptions<T, F>): PagedData<T>;
|
|
966
1306
|
//#endregion
|
|
967
|
-
export { APIKey, APIKeyWithSecret, ArrayPagerOptions, AuditEntry, BlobDocument, BlobMeta, BlobNamespace, BootstrapPasswordRequest, ChangePasswordRequest, CollectionDocument, CollectionMeta, CreateKeyRequest, CreateNamespaceRequest, CreatePolicyRequest, CreateRuleRequest, CreateUserRequest, Document, DocumentStore, FetchResult, HestiaAuth, HestiaBlobClient, HestiaClient, HestiaCollection, HestiaCollections, HestiaKeyStore, HestiaLogs, HestiaNetworkClient, HestiaOperations, HestiaPolicies, HestiaResponse, HestiaRules, HestiaUsers, IdentityProvider, ListBlobsRequest, LogFilter, LoginRequest, LoginResult, NamespaceInfo, Operation, Page, PagedData, PagerRefreshOptions, PaginationInfo, Policy, PolicyRule, RegisterRequest, ReloadResult, RequestLogEntry, RuleNode, ServerHealth, SetPolicyEnabledRequest, StoreEvent, StreamHandlers, StreamOptions, UpdateKeyRequest, UpdatePolicyRuleRequest, UpdateRuleRequest, UpdateUserRequest, UserData, UserIdentity, ValidateRuleRequest, ValidateRuleResult, createArrayPager, createPagedController, internalError, notFound, parseErrorBody, permissionDenied, toSystemError };
|
|
1307
|
+
export { APIKey, APIKeyWithSecret, ArrayPagerOptions, AuditEntry, BlobDocument, BlobMeta, BlobNamespace, BootstrapPasswordRequest, ChangePasswordRequest, CollectionDocument, CollectionMeta, CreateKeyRequest, CreateNamespaceRequest, CreatePolicyRequest, CreateRuleRequest, CreateUserRequest, DispatchInput, Document, DocumentStore, FetchResult, HestiaAuth, HestiaBlobClient, HestiaClient, HestiaCollection, HestiaCollections, HestiaKeyStore, HestiaLogs, HestiaNetworkClient, HestiaOperations, HestiaPolicies, HestiaResponse, HestiaRules, HestiaUsers, HttpTransport, IdentityProvider, ListBlobsRequest, LogFilter, LoginRequest, LoginResult, NamespaceInfo, Operation, Page, PagedData, PagerRefreshOptions, PaginationInfo, Policy, PolicyRule, RegisterRequest, ReloadResult, RequestLogEntry, RequestOptions, RuleNode, ServerHealth, SetPolicyEnabledRequest, StoreEvent, StreamHandlers, StreamOptions, Transport, UpdateKeyRequest, UpdatePolicyRuleRequest, UpdateRuleRequest, UpdateUserRequest, UserData, UserIdentity, ValidateRuleRequest, ValidateRuleResult, WailsTransport, createArrayPager, createPagedController, internalError, notFound, parseErrorBody, permissionDenied, toSystemError };
|