@asaidimu/hestia 1.13.0 → 1.14.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/index.d.mts CHANGED
@@ -2,8 +2,8 @@ import { ApiResponse } from "@asaidimu/network-client";
2
2
  import { Issue, SystemError } from "@asaidimu/utils-error";
3
3
  import { DataStore, ReactiveDataStore } from "@asaidimu/utils-store";
4
4
  import { QueryDSL, QueryFilter, SortConfiguration } from "@asaidimu/query";
5
- import { SimplePersistence } from "@asaidimu/utils-persistence";
6
5
  import { SchemaDefinition } from "@asaidimu/utils-schema";
6
+ import { SimplePersistence } from "@asaidimu/utils-persistence";
7
7
  //#region core/types.d.ts
8
8
  interface DocumentMetadata {
9
9
  checksum: string;
@@ -142,12 +142,15 @@ interface DocumentStore<T extends Record<string, any>, TFindOptions = Record<str
142
142
  */
143
143
  delete: (options: TDeleteOptions) => Promise<void>;
144
144
  /**
145
- * Updates an existing record.
146
- * @param props An object containing the ID of the record to update, the partial data, and optional update options.
145
+ * Updates existing records.
146
+ * @param props An object containing the partial data plus exactly one
147
+ * target: an `id` or a `filter`. Optional update options ride in `options`.
147
148
  * @returns A promise that resolves to the updated record or undefined if not found.
148
149
  */
149
150
  update: (props: {
150
151
  data: Partial<T>;
152
+ id?: string;
153
+ filter?: QueryFilter<T>;
151
154
  options?: TUpdateOptions;
152
155
  }) => Promise<Document<T> | undefined>;
153
156
  /**
@@ -474,11 +477,26 @@ declare const ROUTE_TABLE: {
474
477
  readonly route: "/system/collections/document/update/{name}/{doc_id}";
475
478
  readonly arguments: readonly ["name", "doc_id"];
476
479
  };
480
+ readonly "system:collections:document:update_many": {
481
+ readonly method: "PATCH";
482
+ readonly route: "/system/collections/document/update_many/{name}";
483
+ readonly arguments: readonly ["name"];
484
+ };
477
485
  readonly "system:collections:user:query": {
478
486
  readonly method: "POST";
479
487
  readonly route: "/system/collections/user/query";
480
488
  readonly arguments: readonly [];
481
489
  };
490
+ readonly "system:collections:view:create": {
491
+ readonly method: "POST";
492
+ readonly route: "/system/collections/view/create/{name}";
493
+ readonly arguments: readonly ["name"];
494
+ };
495
+ readonly "system:collections:view:refresh": {
496
+ readonly method: "PATCH";
497
+ readonly route: "/system/collections/view/refresh/{name}";
498
+ readonly arguments: readonly ["name"];
499
+ };
482
500
  readonly "system:core:capability:list": {
483
501
  readonly method: "GET";
484
502
  readonly route: "/system/core/capability/list";
@@ -963,6 +981,27 @@ declare class WailsTransport implements Transport<RouteName> {
963
981
  openStream(path: string, handlers: StreamHandlers, _options?: StreamOptions): Promise<void>;
964
982
  }
965
983
  //#endregion
984
+ //#region core/document.d.ts
985
+ /** Methods attached to every document via {@link proxiedDocument}. */
986
+ interface DocumentMethods {
987
+ /** The document's envelope id (`_id_`). */
988
+ id(): string;
989
+ /** The document's envelope metadata (`_metadata_`). */
990
+ metadata(): DocumentMetadata;
991
+ }
992
+ /** A document with {@link DocumentMethods} attached. */
993
+ type ProxiedDocument<T extends Record<string, any>> = Document<T> & DocumentMethods;
994
+ /**
995
+ * Wraps a document in a Proxy exposing `id()` and `metadata()` alongside
996
+ * every payload field. Property reads/writes, `Object.keys`, spread, and
997
+ * `JSON.stringify` behave exactly as on the raw document (the methods are
998
+ * not own properties, so serialisation is unaffected). A payload field
999
+ * literally named `id` or `metadata` wins over the method.
1000
+ */
1001
+ declare function proxiedDocument<T extends Record<string, any>>(doc: Document<T>): ProxiedDocument<T>;
1002
+ /** Maps a page's documents through {@link proxiedDocument}. */
1003
+ declare function proxiedPage<T extends Record<string, any>>(page: Page<T>): Page<ProxiedDocument<T>>;
1004
+ //#endregion
966
1005
  //#region core/collection.d.ts
967
1006
  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>> {
968
1007
  private client;
@@ -972,17 +1011,18 @@ declare class HestiaCollection<T extends Record<string, any>> implements Documen
972
1011
  private pager;
973
1012
  constructor(client: Transport, collectionName: string, defaultLimit?: number);
974
1013
  name(): string;
975
- find(query?: Record<string, unknown>): Promise<Page<T>>;
976
- read(id: string): Promise<Document<T> | undefined>;
1014
+ find(query?: QueryDSL<T>): Promise<Page<ProxiedDocument<T>>>;
1015
+ read(id: string): Promise<ProxiedDocument<T> | undefined>;
977
1016
  create(props: {
978
1017
  data: Partial<T>;
979
- }): Promise<Document<T> | undefined>;
1018
+ }): Promise<ProxiedDocument<T> | undefined>;
980
1019
  update(props: {
981
1020
  data: Partial<T>;
982
- options?: string;
983
- }): Promise<Document<T> | undefined>;
1021
+ id?: string;
1022
+ filter?: QueryFilter<T>;
1023
+ }): Promise<ProxiedDocument<T> | undefined>;
984
1024
  delete(id: string): Promise<void>;
985
- list(options?: Record<string, unknown>): Promise<Page<T>>;
1025
+ list(options?: Record<string, unknown>): Promise<Page<ProxiedDocument<T>>>;
986
1026
  upload(_props: {
987
1027
  file: File;
988
1028
  }): Promise<Document<T> | undefined>;
@@ -996,6 +1036,77 @@ declare class HestiaCollection<T extends Record<string, any>> implements Documen
996
1036
  page(_options?: Record<string, unknown>): PagedData<T>;
997
1037
  }
998
1038
  //#endregion
1039
+ //#region system/collections/types.d.ts
1040
+ interface CollectionMeta {
1041
+ name: string;
1042
+ schema: SchemaDefinition;
1043
+ created: string;
1044
+ updated: string;
1045
+ }
1046
+ type CollectionDocument = Document<{
1047
+ schema: SchemaDefinition;
1048
+ }>;
1049
+ interface DataViewMeta {
1050
+ name: string;
1051
+ materialized: boolean;
1052
+ target: string;
1053
+ }
1054
+ //#endregion
1055
+ //#region core/data-view.d.ts
1056
+ interface DataViewDefinition<T extends Record<string, any>> {
1057
+ name: string;
1058
+ /** Stored query. `target.name` pins the underlying collection (required by the server). */
1059
+ query: QueryDSL<T> & {
1060
+ target: {
1061
+ name: string;
1062
+ };
1063
+ };
1064
+ materialized?: boolean;
1065
+ }
1066
+ /**
1067
+ * Read-only view over a stored server query — the view counterpart to
1068
+ * HestiaCollection. Reads flow through the regular document:query /
1069
+ * document:get messages addressed at the view name; document writes are
1070
+ * rejected server-side (ERR_PERSISTENCE_READ_ONLY) and throw client-side.
1071
+ * Materialized snapshots are rebuilt via refresh().
1072
+ */
1073
+ declare class HestiaDataView<T extends Record<string, any>> implements DocumentStore<T, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
1074
+ private client;
1075
+ private viewName;
1076
+ private defaultLimit;
1077
+ private pagerOptions;
1078
+ private pager;
1079
+ constructor(client: Transport, viewName: string, defaultLimit?: number);
1080
+ /** Registers a view on the server and returns a handle to it. */
1081
+ static create<T extends Record<string, any>>(client: Transport, definition: DataViewDefinition<T>): Promise<HestiaDataView<T>>;
1082
+ name(): string;
1083
+ find(query?: QueryDSL<T>): Promise<Page<ProxiedDocument<T>>>;
1084
+ read(id: string): Promise<ProxiedDocument<T> | undefined>;
1085
+ /** Rebuilds a materialized view's snapshot. Fails on virtual views. */
1086
+ refresh(): Promise<ProxiedDocument<DataViewMeta> | undefined>;
1087
+ create(_props: {
1088
+ data: Partial<T>;
1089
+ }): Promise<ProxiedDocument<T> | undefined>;
1090
+ update(_props: {
1091
+ data: Partial<T>;
1092
+ id?: string;
1093
+ filter?: QueryFilter<T>;
1094
+ }): Promise<ProxiedDocument<T> | undefined>;
1095
+ delete(_id: string): Promise<void>;
1096
+ list(options?: Record<string, unknown>): Promise<Page<ProxiedDocument<T>>>;
1097
+ upload(_props: {
1098
+ file: File;
1099
+ }): Promise<ProxiedDocument<T> | undefined>;
1100
+ subscribe(_scope: string, _callback: (event: StoreEvent) => void): Promise<() => void>;
1101
+ notify(_event: StoreEvent): Promise<void>;
1102
+ stream(_options: Record<string, unknown>, _onStreamChange: () => void): {
1103
+ stream: () => AsyncIterable<Document<T>>;
1104
+ cancel: () => void;
1105
+ status: () => "active" | "cancelled" | "completed";
1106
+ };
1107
+ page(_options?: Record<string, unknown>): PagedData<T>;
1108
+ }
1109
+ //#endregion
999
1110
  //#region core/errors.d.ts
1000
1111
  interface ServerErrorBody {
1001
1112
  code?: string;
@@ -1070,8 +1181,9 @@ declare class HestiaUsers implements DocumentStore<UserData, QueryDSL<UserData>,
1070
1181
  list(options?: QueryDSL<UserData>): Promise<Page<UserData>>;
1071
1182
  read(id: string): Promise<Document<UserData> | undefined>;
1072
1183
  update(props: {
1184
+ id?: string;
1073
1185
  data: Partial<UserData>;
1074
- options?: string;
1186
+ filter?: QueryFilter<UserData>;
1075
1187
  }): Promise<Document<UserData> | undefined>;
1076
1188
  delete(id: string): Promise<void>;
1077
1189
  create({ data: payload }: {
@@ -1133,8 +1245,9 @@ declare class HestiaKeyStore implements DocumentStore<APIKey, QueryDSL<APIKey>,
1133
1245
  data: Partial<APIKey>;
1134
1246
  }): Promise<Document<APIKey> | undefined>;
1135
1247
  update(props: {
1248
+ id?: string;
1136
1249
  data: Partial<APIKey>;
1137
- options?: string;
1250
+ filter?: QueryFilter<APIKey>;
1138
1251
  }): Promise<Document<APIKey> | undefined>;
1139
1252
  delete(id: string): Promise<void>;
1140
1253
  upload(_props: {
@@ -1272,8 +1385,9 @@ declare class HestiaPolicies implements DocumentStore<Policy, QueryDSL<Policy>,
1272
1385
  options?: string;
1273
1386
  }): Promise<Document<Policy> | undefined>;
1274
1387
  update(props: {
1388
+ id?: string;
1275
1389
  data: UpdatePolicyRequest;
1276
- options?: string;
1390
+ filter?: QueryFilter<Policy>;
1277
1391
  }): Promise<Document<Policy> | undefined>;
1278
1392
  setEnabled(name: string, enabled: boolean): Promise<Document<Policy>>;
1279
1393
  delete(_id: string): Promise<void>;
@@ -1302,8 +1416,9 @@ declare class HestiaRules implements DocumentStore<PolicyRule, Record<string, un
1302
1416
  options?: string;
1303
1417
  }): Promise<Document<PolicyRule> | undefined>;
1304
1418
  update(props: {
1419
+ id?: string;
1305
1420
  data: UpdateRuleRequest;
1306
- options?: string;
1421
+ filter?: QueryFilter<PolicyRule>;
1307
1422
  }): Promise<Document<PolicyRule> | undefined>;
1308
1423
  delete(name: string): Promise<void>;
1309
1424
  validate(request: ValidateRuleRequest): Promise<ValidateRuleResult>;
@@ -1375,7 +1490,7 @@ declare class HestiaAuditLogs implements DocumentStore<AuditEntry, QueryDSL<Audi
1375
1490
  }): Promise<Document<AuditEntry> | undefined>;
1376
1491
  update(_props: {
1377
1492
  data: Partial<AuditEntry>;
1378
- options?: string;
1493
+ id?: string;
1379
1494
  }): Promise<Document<AuditEntry> | undefined>;
1380
1495
  delete(_id: string): Promise<void>;
1381
1496
  upload(_props: {
@@ -1771,8 +1886,9 @@ declare class BlobNamespace implements DocumentStore<BlobMeta, QueryDSL<BlobMeta
1771
1886
  data: Partial<BlobMeta>;
1772
1887
  }): Promise<Document<BlobMeta> | undefined>;
1773
1888
  update(props: {
1889
+ id?: string;
1774
1890
  data: Partial<BlobMeta>;
1775
- options?: Record<string, any>;
1891
+ filter?: QueryFilter<BlobMeta>;
1776
1892
  }): Promise<Document<BlobMeta> | undefined>;
1777
1893
  delete(key: string): Promise<void>;
1778
1894
  rename(oldKey: string, newKey: string): Promise<void>;
@@ -1834,17 +1950,6 @@ declare class HestiaBlobClient {
1834
1950
  namespace(ns: string): BlobNamespace;
1835
1951
  }
1836
1952
  //#endregion
1837
- //#region system/collections/types.d.ts
1838
- interface CollectionMeta {
1839
- name: string;
1840
- schema: SchemaDefinition;
1841
- created: string;
1842
- updated: string;
1843
- }
1844
- type CollectionDocument = Document<{
1845
- schema: SchemaDefinition;
1846
- }>;
1847
- //#endregion
1848
1953
  //#region system/collections/store.d.ts
1849
1954
  declare class HestiaCollections implements DocumentStore<CollectionMeta, Record<string, unknown>, string, Record<string, unknown>, Record<string, unknown>, string, string, Record<string, unknown>> {
1850
1955
  private client;
@@ -1856,7 +1961,7 @@ declare class HestiaCollections implements DocumentStore<CollectionMeta, Record<
1856
1961
  }): Promise<Document<CollectionMeta> | undefined>;
1857
1962
  update(_props: {
1858
1963
  data: Partial<CollectionMeta>;
1859
- options?: string;
1964
+ id?: string;
1860
1965
  }): Promise<Document<CollectionMeta> | undefined>;
1861
1966
  delete(name: string): Promise<void>;
1862
1967
  list(_options?: Record<string, unknown>): Promise<Page<CollectionMeta>>;
@@ -1872,6 +1977,7 @@ declare class HestiaCollections implements DocumentStore<CollectionMeta, Record<
1872
1977
  };
1873
1978
  page(_options?: Record<string, unknown>): PagedData<CollectionMeta>;
1874
1979
  documents<T extends Record<string, any>>(collectionName: string): HestiaCollection<T>;
1980
+ view<T extends Record<string, any>>(viewName: string): HestiaDataView<T>;
1875
1981
  }
1876
1982
  //#endregion
1877
1983
  //#region system/notifications/types.d.ts
@@ -2314,7 +2420,7 @@ declare class HestiaCore implements DocumentStore<any, Record<string, unknown>,
2314
2420
  }): Promise<Document<any> | undefined>;
2315
2421
  update(_props: {
2316
2422
  data: Partial<any>;
2317
- options?: string;
2423
+ id?: string;
2318
2424
  }): Promise<Document<any> | undefined>;
2319
2425
  delete(_id: string): Promise<void>;
2320
2426
  list(_options?: Record<string, unknown>): Promise<Page<any>>;
@@ -2361,6 +2467,7 @@ declare class HestiaClient {
2361
2467
  readonly settings: HestiaSettingStore;
2362
2468
  readonly updates: HestiaUpdates;
2363
2469
  readonly workflows: HestiaWorkflowStore;
2470
+ readonly operations: HestiaOperations;
2364
2471
  private tokenProvider;
2365
2472
  private onAuthStateChanged?;
2366
2473
  constructor(config: HestiaConfig);
@@ -2371,6 +2478,7 @@ declare class HestiaClient {
2371
2478
  startHeartbeat(intervalMs?: number): void;
2372
2479
  stopHeartbeat(): void;
2373
2480
  collection<T extends Record<string, any>>(name: string): HestiaCollection<T>;
2481
+ view<T extends Record<string, any>>(name: string): HestiaDataView<T>;
2374
2482
  ready(): Promise<void>;
2375
2483
  }
2376
2484
  //#endregion
@@ -2391,4 +2499,4 @@ interface ArrayPagerOptions<T extends Record<string, any>, F = any> {
2391
2499
  }
2392
2500
  declare function createArrayPager<T extends Record<string, any>, F = any>(options: ArrayPagerOptions<T, F>): PagedData<T>;
2393
2501
  //#endregion
2394
- export { APIKey, APIKeyWithSecret, AccessLogFields, AimdController, ArrayPagerOptions, AuditEntry, Binding, BlobDocument, BlobMeta, BlobNamespace, BootstrapPasswordRequest, ChangePasswordRequest, CollectionDocument, CollectionMeta, CompactResult, CompiledWorkflow, CreateKeyRequest, CreateNamespaceRequest, CreateNotificationInput, CreatePolicyRequest, CreateRuleRequest, CreateSchedulePayload, CreateUserRequest, DispatchInput, Document, DocumentStore, EdgeRole, EmitEventPayload, FetchResult, HandleKind, HandleSpec, HandleType, HestiaAppLogs, HestiaAuditLogs, HestiaAuth, HestiaBlobClient, HestiaClient, HestiaCollection, HestiaCollections, HestiaCore, HestiaKeyStore, HestiaNetworkClient, HestiaNotificationStore, HestiaOperations, HestiaPolicies, HestiaResponse, HestiaRules, HestiaScheduleStore, HestiaSettingStore, HestiaUpdates, HestiaUsers, HestiaWorkflowStore, HttpTransport, IdentityProvider, InvokeWorkflowPayload, InvokeWorkflowResult, ListBlobsRequest, LogEntry, LogFilter, LogListResult, LogQuery, LoginRequest, LoginResult, NamespaceInfo, NamespaceStats, NodeDefinition, NodeType, Notification, NotificationAction, Page, PagedData, PagerRefreshOptions, PaginationInfo, Policy, PolicyRule, RateLimitConfig, RegisterRequest, RegisterWorkflowPayload, ReloadResult, RequestLogEntry, RequestOptions, ResumableUpload, ResumeWorkflowPayload, ResumeWorkflowResult, RuleNode, RunMeta, RunOutcome, RunStatus, RunWorkflowPayload, Schedule, ServerHealth, SetPolicyEnabledRequest, SettingDocument, StoreEvent, StreamHandlers, StreamOptions, ThrottleAction, ThrottleConfig, TimelineEvent, Transport, UnreadCount, UpdateApplyResult, UpdateAvailability, UpdateChangelog, UpdateCheckResult, UpdateKeyRequest, UpdatePolicyRequest, UpdatePolicyRuleRequest, UpdateRuleRequest, UpdateSchedulePayload, UpdateStageResult, UpdateStatus, UpdateUserRequest, UploadBeginResult, UploadJobSnapshot, UploadJobStore, UploadJobsState, UploadOptions, UploadPersistence, UploadPhase, UploadProgressInfo, UploadProgressResult, UploadQueue, UploadQueueOptions, UploadStatus, UploadTransport, UserData, UserIdentity, ValidateRuleRequest, ValidateRuleResult, WailsTransport, WorkflowDefinition, WorkflowEdge, WorkflowNode, createArrayPager, createPagedController, getCachedHandles, getMissingRanges, internalError, notFound, parseErrorBody, permissionDenied, toSystemError };
2502
+ export { APIKey, APIKeyWithSecret, AccessLogFields, AimdController, ArrayPagerOptions, AuditEntry, Binding, BlobDocument, BlobMeta, BlobNamespace, BootstrapPasswordRequest, ChangePasswordRequest, CollectionDocument, CollectionMeta, CompactResult, CompiledWorkflow, CreateKeyRequest, CreateNamespaceRequest, CreateNotificationInput, CreatePolicyRequest, CreateRuleRequest, CreateSchedulePayload, CreateUserRequest, type DataViewDefinition, DataViewMeta, DispatchInput, Document, DocumentMetadata, type DocumentMethods, DocumentStore, EdgeRole, EmitEventPayload, FetchResult, HandleKind, HandleSpec, HandleType, HestiaAppLogs, HestiaAuditLogs, HestiaAuth, HestiaBlobClient, HestiaClient, HestiaCollection, HestiaCollections, HestiaCore, HestiaDataView, HestiaKeyStore, HestiaNetworkClient, HestiaNotificationStore, HestiaOperations, HestiaPolicies, HestiaResponse, HestiaRules, HestiaScheduleStore, HestiaSettingStore, HestiaUpdates, HestiaUsers, HestiaWorkflowStore, HttpTransport, IdentityProvider, InvokeWorkflowPayload, InvokeWorkflowResult, ListBlobsRequest, LogEntry, LogFilter, LogListResult, LogQuery, LoginRequest, LoginResult, NamespaceInfo, NamespaceStats, NodeDefinition, NodeType, Notification, NotificationAction, Page, PagedData, PagerRefreshOptions, PaginationInfo, Policy, PolicyRule, type ProxiedDocument, RateLimitConfig, RegisterRequest, RegisterWorkflowPayload, ReloadResult, RequestLogEntry, RequestOptions, ResumableUpload, ResumeWorkflowPayload, ResumeWorkflowResult, RuleNode, RunMeta, RunOutcome, RunStatus, RunWorkflowPayload, Schedule, ServerHealth, SetPolicyEnabledRequest, SettingDocument, StoreEvent, StreamHandlers, StreamOptions, ThrottleAction, ThrottleConfig, TimelineEvent, Transport, UnreadCount, UpdateApplyResult, UpdateAvailability, UpdateChangelog, UpdateCheckResult, UpdateKeyRequest, UpdatePolicyRequest, UpdatePolicyRuleRequest, UpdateRuleRequest, UpdateSchedulePayload, UpdateStageResult, UpdateStatus, UpdateUserRequest, UploadBeginResult, UploadJobSnapshot, UploadJobStore, UploadJobsState, UploadOptions, UploadPersistence, UploadPhase, UploadProgressInfo, UploadProgressResult, UploadQueue, UploadQueueOptions, UploadStatus, UploadTransport, UserData, UserIdentity, ValidateRuleRequest, ValidateRuleResult, WailsTransport, WorkflowDefinition, WorkflowEdge, WorkflowNode, createArrayPager, createPagedController, getCachedHandles, getMissingRanges, internalError, notFound, parseErrorBody, permissionDenied, proxiedDocument, proxiedPage, toSystemError };