@contello/store 2.1.1 → 3.0.1

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/dist/index.d.ts CHANGED
@@ -1,81 +1,81 @@
1
- import { Schema, ConnectionEvents, SourceDef, SourceCardinality, UploadData, UploadMetadata, UploadOptions, DownloadResult, ProxyResult, ContelloClient } from '@contello/client';
2
- import { MaybePromise, ReadonlyDeep } from 'projected';
3
- export { MaybePromise, ReadonlyDeep, maybeCatch, maybeThen } from 'projected';
1
+ import { ConnectionEvents, ContelloClient, DownloadResult, ProxyResult, Schema, SourceCardinality, SourceDef, UploadData, UploadMetadata, UploadOptions } from "@contello/client";
2
+ import { MaybePromise, MaybePromise as MaybePromise$1, ReadonlyDeep, ReadonlyDeep as ReadonlyDeep$1, maybeCatch, maybeThen } from "projected";
4
3
 
4
+ //#region src/routes-mapping.d.ts
5
5
  type StoreRouteCustomHeader = {
6
- name: string;
7
- value: string;
6
+ name: string;
7
+ value: string;
8
8
  };
9
9
  type StoreRoute = {
10
- id: string;
11
- path: string;
12
- customHeaders: StoreRouteCustomHeader[];
10
+ id: string;
11
+ path: string;
12
+ customHeaders: StoreRouteCustomHeader[];
13
13
  } & ({
14
- type: 'redirect';
15
- location: string;
16
- status: number;
14
+ type: 'redirect';
15
+ location: string;
16
+ status: number;
17
17
  } | {
18
- type: 'text';
19
- content: string;
20
- mimeType: string;
18
+ type: 'text';
19
+ content: string;
20
+ mimeType: string;
21
21
  } | {
22
- type: 'asset';
23
- assetId: string;
24
- fileId: string;
25
- contentDisposition: 'inline' | 'attachment';
26
- mimeType: string;
22
+ type: 'asset';
23
+ assetId: string;
24
+ fileId: string;
25
+ contentDisposition: 'inline' | 'attachment';
26
+ mimeType: string;
27
27
  } | {
28
- type: 'entity';
29
- model: string;
30
- entityType: string;
31
- entityId: string;
28
+ type: 'entity';
29
+ model: string;
30
+ entityType: string;
31
+ entityId: string;
32
32
  });
33
-
33
+ //#endregion
34
+ //#region src/watcher.d.ts
34
35
  type UpdateEvent<TEntityType extends string = string> = {
35
- id: string;
36
- mutation: 'create';
37
- target: 'route';
38
- after: StoreRoute;
36
+ id: string;
37
+ mutation: 'create';
38
+ target: 'route';
39
+ after: StoreRoute;
39
40
  } | {
40
- id: string;
41
- mutation: 'update';
42
- target: 'route';
43
- after: StoreRoute;
44
- before: StoreRoute;
41
+ id: string;
42
+ mutation: 'update';
43
+ target: 'route';
44
+ after: StoreRoute;
45
+ before: StoreRoute;
45
46
  } | {
46
- id: string;
47
- mutation: 'delete';
48
- target: 'route';
47
+ id: string;
48
+ mutation: 'delete';
49
+ target: 'route';
49
50
  } | {
50
- id: string;
51
- mutation: 'create' | 'update' | 'delete';
52
- target: 'asset';
51
+ id: string;
52
+ mutation: 'create' | 'update' | 'delete';
53
+ target: 'asset';
53
54
  } | {
54
- id: string;
55
- mutation: 'create' | 'update' | 'delete';
56
- target: 'i18nMessage';
57
- token: string;
55
+ id: string;
56
+ mutation: 'create' | 'update' | 'delete';
57
+ target: 'i18nMessage';
58
+ token: string;
58
59
  } | {
59
- id: string;
60
- mutation: 'create' | 'update' | 'delete';
61
- target: 'entity';
62
- model: TEntityType;
60
+ id: string;
61
+ mutation: 'create' | 'update' | 'delete';
62
+ target: 'entity';
63
+ model: TEntityType;
63
64
  };
64
65
  type UpdateMutationType = UpdateEvent['mutation'];
65
66
  type UpdateEventFor<T extends UpdateEvent['target']> = Extract<UpdateEvent, {
66
- target: T;
67
+ target: T;
67
68
  }>;
68
69
  type UpdateBatch = {
69
- readonly events: UpdateEvent[];
70
- readonly route: UpdateEventFor<'route'>[];
71
- readonly asset: UpdateEventFor<'asset'>[];
72
- readonly i18nMessage: UpdateEventFor<'i18nMessage'>[];
73
- /** entity events grouped by model typename */
74
- readonly entity: Map<string, UpdateEventFor<'entity'>[]>;
75
- /** route events grouped by target entity model (both after and before targets for updates) */
76
- readonly routeByEntityModel: Map<string, UpdateEventFor<'route'>[]>;
77
- };
78
-
70
+ readonly events: UpdateEvent[];
71
+ readonly route: UpdateEventFor<'route'>[];
72
+ readonly asset: UpdateEventFor<'asset'>[];
73
+ readonly i18nMessage: UpdateEventFor<'i18nMessage'>[]; /** entity events grouped by model typename */
74
+ readonly entity: Map<string, UpdateEventFor<'entity'>[]>; /** route events grouped by target entity model (both after and before targets for updates) */
75
+ readonly routeByEntityModel: Map<string, UpdateEventFor<'route'>[]>;
76
+ };
77
+ //#endregion
78
+ //#region src/dependency-collector.d.ts
79
79
  /**
80
80
  * passed to `map()` so the mapper can declare which external entities this item depends on.
81
81
  * calls are collected during mapping and indexed once the item key is known.
@@ -91,26 +91,25 @@ type UpdateBatch = {
91
91
  * for cases where only an id is known without the full GraphQL object.
92
92
  */
93
93
  type MapperContext<TModels extends string = string> = {
94
- track(obj: {
95
- __typename: string;
96
- id: string;
97
- }): void;
98
- trackEntity(typename: TModels, id: string): void;
99
- trackAsset(id: string): void;
100
- trackRoute(id: string): void;
94
+ track(obj: {
95
+ __typename: string;
96
+ id: string;
97
+ }): void;
98
+ trackEntity(typename: TModels, id: string): void;
99
+ trackAsset(id: string): void;
100
+ trackRoute(id: string): void;
101
101
  };
102
-
102
+ //#endregion
103
+ //#region src/types.d.ts
103
104
  /** Extracts the typed fragment result from a SourceDef. */
104
105
  type ExtractSourceResult<S extends SourceDef<string, 'entity' | 'singleton'>> = NonNullable<S['__result']>;
105
106
  /** Keys of `schema.sources` whose entries match the given cardinality. */
106
107
  type SourceKeysOf<TSchema, TCardinality extends SourceCardinality> = TSchema extends {
107
- sources: infer TSources;
108
- } ? {
109
- [K in keyof TSources]: TSources[K] extends SourceDef<any, TCardinality, any> ? K : never;
110
- }[keyof TSources] : never;
108
+ sources: infer TSources;
109
+ } ? { [K in keyof TSources]: TSources[K] extends SourceDef<any, TCardinality, any> ? K : never }[keyof TSources] : never;
111
110
  /** The SourceDef at `schema.sources[TKey]`. */
112
111
  type SourceAt<TSchema, TKey> = TSchema extends {
113
- sources: infer TSources;
112
+ sources: infer TSources;
114
113
  } ? TKey extends keyof TSources ? TSources[TKey] : never : never;
115
114
  /**
116
115
  * For `define*(arg, options?)` — accepts either a string key (looked up in `schema.sources`) or a SourceDef directly.
@@ -119,15 +118,15 @@ type SourceAt<TSchema, TKey> = TSchema extends {
119
118
  */
120
119
  type ResolveSource<TSchema, T> = T extends string ? SourceAt<TSchema, T> : T extends SourceDef<any, any, any> ? T : never;
121
120
  type CreateStoreOptions<TSchema extends Schema | undefined = undefined> = {
122
- url: string;
123
- project: string;
124
- token: string;
125
- schema?: TSchema | undefined;
126
- connections?: number | undefined;
127
- onConnected?: (() => void) | undefined;
128
- onReconnecting?: (() => void) | undefined;
129
- onError?: ((error: unknown) => void) | undefined;
130
- connectionEvents?: ConnectionEvents | undefined;
121
+ url: string;
122
+ project: string;
123
+ token: string;
124
+ schema?: TSchema | undefined;
125
+ connections?: number | undefined;
126
+ onConnected?: (() => void) | undefined;
127
+ onReconnecting?: (() => void) | undefined;
128
+ onError?: ((error: unknown) => void) | undefined;
129
+ connectionEvents?: ConnectionEvents | undefined;
131
130
  };
132
131
  /**
133
132
  * What triggered a refresh:
@@ -139,336 +138,339 @@ type CreateStoreOptions<TSchema extends Schema | undefined = undefined> = {
139
138
  type RefreshKind = 'upstream-update' | 'ttl' | 'on-demand';
140
139
  /** Refresh event shape for stores keyed by id (collection, lazy-collection, routes, assets, i18n). */
141
140
  type RefreshEvent = {
142
- ids: string[];
143
- kind: RefreshKind;
141
+ ids: string[];
142
+ kind: RefreshKind;
144
143
  };
145
144
  /** Refresh event shape for stores with no id concept (singleton). */
146
145
  type SingletonRefreshEvent = {
147
- kind: RefreshKind;
146
+ kind: RefreshKind;
148
147
  };
149
148
  /** Cache options for non-lazy collections and singletons. */
150
149
  type CacheOptions = {
151
- /**
152
- * Periodic full refresh — guards against stale data from missed update events.
153
- * Defaults to 3 hours; set `0` or `false` to disable.
154
- */
155
- ttl?: number | false | undefined;
156
- /**
157
- * Controls how the cache responds to Contello update events.
158
- * `'refresh'` (default) serves stale data while a partial fetch runs in the background (SWR);
159
- * only the ids touched by the update are re-fetched, not the whole collection.
160
- * `'clear'` wipes the cache immediately so the next `get()` awaits the fresh result.
161
- * Note: the partial-refresh path is bypassed in `'clear'` mode.
162
- */
163
- eviction?: 'refresh' | 'clear' | undefined;
150
+ /**
151
+ * Periodic full refresh — guards against stale data from missed update events.
152
+ * Defaults to 3 hours; set `0` or `false` to disable.
153
+ */
154
+ ttl?: number | false | undefined;
155
+ /**
156
+ * Controls how the cache responds to Contello update events.
157
+ * `'refresh'` (default) serves stale data while a partial fetch runs in the background (SWR);
158
+ * only the ids touched by the update are re-fetched, not the whole collection.
159
+ * `'clear'` wipes the cache immediately so the next `get()` awaits the fresh result.
160
+ * Note: the partial-refresh path is bypassed in `'clear'` mode.
161
+ */
162
+ eviction?: 'refresh' | 'clear' | undefined;
164
163
  };
165
164
  /**
166
165
  * Cache options for sync collections and singletons. `eviction` is omitted — clearing
167
166
  * the cache would break the sync guarantee.
168
167
  */
169
168
  type SyncCacheOptions = {
170
- /**
171
- * Periodic full refresh — guards against stale data from missed update events.
172
- * Defaults to 3 hours; set `0` or `false` to disable.
173
- */
174
- ttl?: number | false | undefined;
169
+ /**
170
+ * Periodic full refresh — guards against stale data from missed update events.
171
+ * Defaults to 3 hours; set `0` or `false` to disable.
172
+ */
173
+ ttl?: number | false | undefined;
175
174
  };
176
175
  /** Cache options for lazy collections. */
177
176
  type LazyCacheOptions = {
178
- /** Maximum number of items kept in the LRU cache. Defaults to 1000. */
179
- max?: number | undefined;
180
- /**
181
- * Per-item LRU eviction — expired items are dropped on next access and
182
- * re-fetched lazily. Defaults to 3 hours; set `0` or `false` to disable.
183
- */
184
- ttl?: number | false | undefined;
177
+ /** Maximum number of items kept in the LRU cache. Defaults to 1000. */max?: number | undefined;
178
+ /**
179
+ * Per-item LRU eviction — expired items are dropped on next access and
180
+ * re-fetched lazily. Defaults to 3 hours; set `0` or `false` to disable.
181
+ */
182
+ ttl?: number | false | undefined;
185
183
  };
186
184
  type SingletonOptions<TRaw, TMapped, TModels extends string = string> = {
187
- name?: string | undefined;
188
- map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>) | undefined;
189
- cache?: CacheOptions | undefined;
190
- onLoad?: (() => void) | undefined;
191
- onRefresh?: ((event: SingletonRefreshEvent) => void) | undefined;
185
+ name?: string | undefined;
186
+ map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise$1<TMapped>) | undefined;
187
+ cache?: CacheOptions | undefined;
188
+ onLoad?: (() => void) | undefined;
189
+ onRefresh?: ((event: SingletonRefreshEvent) => void) | undefined;
192
190
  };
193
191
  type SingletonSyncOptions<TRaw, TMapped, TModels extends string = string> = {
194
- name?: string | undefined;
195
- map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>) | undefined;
196
- cache?: SyncCacheOptions | undefined;
197
- onLoad?: (() => void) | undefined;
198
- onRefresh?: ((event: SingletonRefreshEvent) => void) | undefined;
192
+ name?: string | undefined;
193
+ map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise$1<TMapped>) | undefined;
194
+ cache?: SyncCacheOptions | undefined;
195
+ onLoad?: (() => void) | undefined;
196
+ onRefresh?: ((event: SingletonRefreshEvent) => void) | undefined;
199
197
  };
200
198
  type Loadable = {
201
- load(): Promise<void>;
199
+ load(): Promise<void>;
202
200
  };
203
201
  type Singleton<T> = {
204
- readonly name: string;
205
- readonly refresh$: AsyncIterable<SingletonRefreshEvent>;
206
- load(): Promise<void>;
207
- get(): MaybePromise<ReadonlyDeep<T>>;
208
- refresh(): void;
202
+ readonly name: string;
203
+ readonly refresh$: AsyncIterable<SingletonRefreshEvent>;
204
+ load(): Promise<void>;
205
+ get(): MaybePromise$1<ReadonlyDeep$1<T>>;
206
+ refresh(): void;
209
207
  };
210
208
  type SingletonSync<T> = {
211
- readonly name: string;
212
- readonly refresh$: AsyncIterable<SingletonRefreshEvent>;
213
- load(): Promise<void>;
214
- get(): ReadonlyDeep<T>;
215
- refresh(): void;
209
+ readonly name: string;
210
+ readonly refresh$: AsyncIterable<SingletonRefreshEvent>;
211
+ load(): Promise<void>;
212
+ get(): ReadonlyDeep$1<T>;
213
+ refresh(): void;
216
214
  };
217
215
  type CollectionOptions<TRaw, TMapped extends {
218
- id: string;
216
+ id: string;
219
217
  }, TModels extends string = string> = {
220
- name?: string | undefined;
221
- map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>) | undefined;
222
- sort?: ((a: TMapped, b: TMapped) => number) | undefined;
223
- cache?: CacheOptions | undefined;
224
- onLoad?: ((ids: string[]) => void) | undefined;
225
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
218
+ name?: string | undefined;
219
+ map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise$1<TMapped>) | undefined;
220
+ sort?: ((a: TMapped, b: TMapped) => number) | undefined;
221
+ cache?: CacheOptions | undefined;
222
+ onLoad?: ((ids: string[]) => void) | undefined;
223
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
226
224
  };
227
225
  type CollectionSyncOptions<TRaw, TMapped extends {
228
- id: string;
226
+ id: string;
229
227
  }, TModels extends string = string> = {
230
- name?: string | undefined;
231
- map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>) | undefined;
232
- sort?: ((a: TMapped, b: TMapped) => number) | undefined;
233
- cache?: SyncCacheOptions | undefined;
234
- onLoad?: ((ids: string[]) => void) | undefined;
235
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
228
+ name?: string | undefined;
229
+ map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise$1<TMapped>) | undefined;
230
+ sort?: ((a: TMapped, b: TMapped) => number) | undefined;
231
+ cache?: SyncCacheOptions | undefined;
232
+ onLoad?: ((ids: string[]) => void) | undefined;
233
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
236
234
  };
237
235
  type Collection<T> = {
238
- readonly name: string;
239
- readonly refresh$: AsyncIterable<RefreshEvent>;
240
- load(): Promise<void>;
241
- get(id: string): MaybePromise<ReadonlyDeep<T> | undefined>;
242
- get(ids: readonly string[]): MaybePromise<ReadonlyArray<ReadonlyDeep<T>>>;
243
- getAll(): MaybePromise<ReadonlyArray<ReadonlyDeep<T>>>;
244
- refresh(): void;
236
+ readonly name: string;
237
+ readonly refresh$: AsyncIterable<RefreshEvent>;
238
+ load(): Promise<void>;
239
+ get(id: string): MaybePromise$1<ReadonlyDeep$1<T> | undefined>;
240
+ get(ids: readonly string[]): MaybePromise$1<ReadonlyArray<ReadonlyDeep$1<T>>>;
241
+ getAll(): MaybePromise$1<ReadonlyArray<ReadonlyDeep$1<T>>>;
242
+ refresh(): void;
245
243
  };
246
244
  type CollectionSync<T> = {
247
- readonly name: string;
248
- readonly refresh$: AsyncIterable<RefreshEvent>;
249
- load(): Promise<void>;
250
- get(id: string): ReadonlyDeep<T> | undefined;
251
- get(ids: readonly string[]): ReadonlyArray<ReadonlyDeep<T>>;
252
- getAll(): ReadonlyArray<ReadonlyDeep<T>>;
253
- refresh(): void;
245
+ readonly name: string;
246
+ readonly refresh$: AsyncIterable<RefreshEvent>;
247
+ load(): Promise<void>;
248
+ get(id: string): ReadonlyDeep$1<T> | undefined;
249
+ get(ids: readonly string[]): ReadonlyArray<ReadonlyDeep$1<T>>;
250
+ getAll(): ReadonlyArray<ReadonlyDeep$1<T>>;
251
+ refresh(): void;
254
252
  };
255
253
  type LazyCollectionOptions<TRaw, TMapped extends {
256
- id: string;
254
+ id: string;
257
255
  }, TModels extends string = string> = {
258
- name?: string | undefined;
259
- cache?: LazyCacheOptions | undefined;
260
- map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>) | undefined;
261
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
256
+ name?: string | undefined;
257
+ cache?: LazyCacheOptions | undefined;
258
+ map?: ((item: TRaw, ref: MapperContext<TModels>) => MaybePromise$1<TMapped>) | undefined;
259
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
262
260
  };
263
261
  type LazyCollection<T> = {
264
- readonly name: string;
265
- readonly refresh$: AsyncIterable<RefreshEvent>;
266
- get(id: string): MaybePromise<ReadonlyDeep<T> | undefined>;
267
- get(ids: readonly string[]): MaybePromise<ReadonlyArray<ReadonlyDeep<T>>>;
268
- refresh(): void;
269
- clear(): void;
270
- };
271
-
262
+ readonly name: string;
263
+ readonly refresh$: AsyncIterable<RefreshEvent>;
264
+ get(id: string): MaybePromise$1<ReadonlyDeep$1<T> | undefined>;
265
+ get(ids: readonly string[]): MaybePromise$1<ReadonlyArray<ReadonlyDeep$1<T>>>;
266
+ refresh(): void;
267
+ clear(): void;
268
+ };
269
+ //#endregion
270
+ //#region src/lazy-assets.d.ts
272
271
  type StoreFileMetadata = {
273
- width: number;
274
- height: number;
272
+ width: number;
273
+ height: number;
275
274
  };
276
275
  type StoreFile = {
277
- uid: string;
278
- mimeType: string;
279
- metadata: StoreFileMetadata | undefined;
276
+ uid: string;
277
+ mimeType: string;
278
+ metadata: StoreFileMetadata | undefined;
280
279
  };
281
280
  type StoreAsset = {
282
- id: string;
283
- original: StoreFile;
284
- preview: StoreFile | undefined;
285
- optimized: StoreFile[];
281
+ id: string;
282
+ original: StoreFile;
283
+ preview: StoreFile | undefined;
284
+ optimized: StoreFile[];
286
285
  };
287
286
  type LazyAssetsOptions = {
288
- cache?: LazyCacheOptions | undefined;
289
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
287
+ cache?: LazyCacheOptions | undefined;
288
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
290
289
  };
291
290
  type LazyAssets = {
292
- readonly refresh$: AsyncIterable<RefreshEvent>;
293
- get(id: string): Promise<ReadonlyDeep<StoreAsset> | undefined>;
294
- get(ids: readonly string[]): Promise<ReadonlyDeep<StoreAsset[]>>;
295
- upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
296
- download(fileId: string): Promise<DownloadResult>;
297
- proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
298
- refresh(): void;
299
- clear(): void;
300
- };
301
-
291
+ readonly refresh$: AsyncIterable<RefreshEvent>;
292
+ get(id: string): Promise<ReadonlyDeep$1<StoreAsset> | undefined>;
293
+ get(ids: readonly string[]): Promise<ReadonlyDeep$1<StoreAsset[]>>;
294
+ upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
295
+ download(fileId: string): Promise<DownloadResult>;
296
+ proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
297
+ refresh(): void;
298
+ clear(): void;
299
+ };
300
+ //#endregion
301
+ //#region src/assets.d.ts
302
302
  type AssetsOptions = {
303
- cache?: CacheOptions | undefined;
304
- onLoad?: ((ids: string[]) => void) | undefined;
305
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
303
+ cache?: CacheOptions | undefined;
304
+ onLoad?: ((ids: string[]) => void) | undefined;
305
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
306
306
  };
307
307
  type AssetsSyncOptions = {
308
- cache?: SyncCacheOptions | undefined;
309
- onLoad?: ((ids: string[]) => void) | undefined;
310
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
308
+ cache?: SyncCacheOptions | undefined;
309
+ onLoad?: ((ids: string[]) => void) | undefined;
310
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
311
311
  };
312
312
  type Assets = {
313
- readonly refresh$: AsyncIterable<RefreshEvent>;
314
- load(): Promise<void>;
315
- get(id: string): MaybePromise<ReadonlyDeep<StoreAsset> | undefined>;
316
- get(ids: readonly string[]): MaybePromise<ReadonlyArray<ReadonlyDeep<StoreAsset>>>;
317
- upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
318
- download(fileId: string): Promise<DownloadResult>;
319
- proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
320
- refresh(): void;
313
+ readonly refresh$: AsyncIterable<RefreshEvent>;
314
+ load(): Promise<void>;
315
+ get(id: string): MaybePromise$1<ReadonlyDeep$1<StoreAsset> | undefined>;
316
+ get(ids: readonly string[]): MaybePromise$1<ReadonlyArray<ReadonlyDeep$1<StoreAsset>>>;
317
+ upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
318
+ download(fileId: string): Promise<DownloadResult>;
319
+ proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
320
+ refresh(): void;
321
321
  };
322
322
  type AssetsSync = {
323
- readonly refresh$: AsyncIterable<RefreshEvent>;
324
- load(): Promise<void>;
325
- get(id: string): ReadonlyDeep<StoreAsset> | undefined;
326
- get(ids: readonly string[]): ReadonlyArray<ReadonlyDeep<StoreAsset>>;
327
- upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
328
- download(fileId: string): Promise<DownloadResult>;
329
- proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
330
- refresh(): void;
331
- };
332
-
323
+ readonly refresh$: AsyncIterable<RefreshEvent>;
324
+ load(): Promise<void>;
325
+ get(id: string): ReadonlyDeep$1<StoreAsset> | undefined;
326
+ get(ids: readonly string[]): ReadonlyArray<ReadonlyDeep$1<StoreAsset>>;
327
+ upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
328
+ download(fileId: string): Promise<DownloadResult>;
329
+ proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
330
+ refresh(): void;
331
+ };
332
+ //#endregion
333
+ //#region src/i18n.d.ts
333
334
  type I18nTranslation = {
334
- language: string;
335
- value: string;
335
+ language: string;
336
+ value: string;
336
337
  };
337
338
  type I18nVariableInput = {
338
- name: string;
339
- description: string;
340
- example: string;
339
+ name: string;
340
+ description: string;
341
+ example: string;
341
342
  };
342
343
  type I18nInitialTranslation = {
343
- language: string;
344
- message: string;
344
+ language: string;
345
+ message: string;
345
346
  };
346
347
  type I18nMessageRegistrationDefinition = {
347
- token: string;
348
- example?: string | undefined;
349
- description?: string | undefined;
350
- variables?: I18nVariableInput[] | undefined;
351
- /** always overwrites existing translations for this token */
352
- translations?: I18nInitialTranslation[] | undefined;
353
- /** only applied when the token is newly registered (existing translations are preserved) */
354
- initialTranslations?: I18nInitialTranslation[] | undefined;
348
+ token: string;
349
+ example?: string | undefined;
350
+ description?: string | undefined;
351
+ variables?: I18nVariableInput[] | undefined; /** always overwrites existing translations for this token */
352
+ translations?: I18nInitialTranslation[] | undefined; /** only applied when the token is newly registered (existing translations are preserved) */
353
+ initialTranslations?: I18nInitialTranslation[] | undefined;
355
354
  };
356
355
  type I18nMessageDef = {
357
- collection: string;
358
- cache?: SyncCacheOptions | undefined;
359
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
356
+ collection: string;
357
+ cache?: SyncCacheOptions | undefined;
358
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
360
359
  };
361
360
  type I18nMessage = {
362
- id: string;
363
- token: string;
364
- translations: Map<string, string>;
361
+ id: string;
362
+ token: string;
363
+ translations: Map<string, string>;
365
364
  };
366
365
  type I18nMessages = {
367
- readonly refresh$: AsyncIterable<RefreshEvent>;
368
- get(id: string): MaybePromise<ReadonlyDeep<I18nMessage> | undefined>;
369
- get(ids: readonly string[]): MaybePromise<ReadonlyDeep<I18nMessage[]>>;
370
- getAll(): MaybePromise<ReadonlyDeep<I18nMessage[]>>;
371
- register(messages: I18nMessageRegistrationDefinition[]): Promise<void>;
372
- refresh(): void;
373
- /** Completes refresh$ and detaches from the watcher — called by `Store.destroy()`. */
374
- destroy(): void;
375
- };
376
-
366
+ readonly refresh$: AsyncIterable<RefreshEvent>;
367
+ get(id: string): MaybePromise$1<ReadonlyDeep$1<I18nMessage> | undefined>;
368
+ get(ids: readonly string[]): MaybePromise$1<ReadonlyDeep$1<I18nMessage[]>>;
369
+ getAll(): MaybePromise$1<ReadonlyDeep$1<I18nMessage[]>>;
370
+ register(messages: I18nMessageRegistrationDefinition[]): Promise<void>;
371
+ refresh(): void; /** Completes refresh$ and detaches from the watcher — called by `Store.destroy()`. */
372
+ destroy(): void;
373
+ };
374
+ //#endregion
375
+ //#region src/lazy-routes.d.ts
377
376
  type LazyRoutesOptions = {
378
- cache?: LazyCacheOptions | undefined;
379
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
377
+ cache?: LazyCacheOptions | undefined;
378
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
380
379
  };
381
380
  type LazyRoutes = {
382
- readonly refresh$: AsyncIterable<RefreshEvent>;
383
- get(id: string): Promise<ReadonlyDeep<StoreRoute> | undefined>;
384
- get(ids: readonly string[]): Promise<ReadonlyDeep<StoreRoute[]>>;
385
- getByPath(path: string): Promise<ReadonlyDeep<StoreRoute> | undefined>;
386
- getByPath(paths: readonly string[]): Promise<ReadonlyDeep<StoreRoute[]>>;
387
- refresh(): void;
388
- clear(): void;
389
- };
390
-
381
+ readonly refresh$: AsyncIterable<RefreshEvent>;
382
+ get(id: string): Promise<ReadonlyDeep$1<StoreRoute> | undefined>;
383
+ get(ids: readonly string[]): Promise<ReadonlyDeep$1<StoreRoute[]>>;
384
+ getByPath(path: string): Promise<ReadonlyDeep$1<StoreRoute> | undefined>;
385
+ getByPath(paths: readonly string[]): Promise<ReadonlyDeep$1<StoreRoute[]>>;
386
+ refresh(): void;
387
+ clear(): void;
388
+ };
389
+ //#endregion
390
+ //#region src/routes.d.ts
391
391
  type RoutesOptions = {
392
- cache?: CacheOptions | undefined;
393
- onLoad?: ((ids: string[]) => void) | undefined;
394
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
392
+ cache?: CacheOptions | undefined;
393
+ onLoad?: ((ids: string[]) => void) | undefined;
394
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
395
395
  };
396
396
  type RoutesSyncOptions = {
397
- cache?: SyncCacheOptions | undefined;
398
- onLoad?: ((ids: string[]) => void) | undefined;
399
- onRefresh?: ((event: RefreshEvent) => void) | undefined;
397
+ cache?: SyncCacheOptions | undefined;
398
+ onLoad?: ((ids: string[]) => void) | undefined;
399
+ onRefresh?: ((event: RefreshEvent) => void) | undefined;
400
400
  };
401
401
  type Routes = {
402
- readonly refresh$: AsyncIterable<RefreshEvent>;
403
- load(): Promise<void>;
404
- get(id: string): MaybePromise<ReadonlyDeep<StoreRoute> | undefined>;
405
- get(ids: readonly string[]): MaybePromise<ReadonlyArray<ReadonlyDeep<StoreRoute>>>;
406
- getByPath(path: string): MaybePromise<ReadonlyDeep<StoreRoute> | undefined>;
407
- getByPath(paths: readonly string[]): MaybePromise<ReadonlyArray<ReadonlyDeep<StoreRoute>>>;
408
- refresh(): void;
402
+ readonly refresh$: AsyncIterable<RefreshEvent>;
403
+ load(): Promise<void>;
404
+ get(id: string): MaybePromise$1<ReadonlyDeep$1<StoreRoute> | undefined>;
405
+ get(ids: readonly string[]): MaybePromise$1<ReadonlyArray<ReadonlyDeep$1<StoreRoute>>>;
406
+ getByPath(path: string): MaybePromise$1<ReadonlyDeep$1<StoreRoute> | undefined>;
407
+ getByPath(paths: readonly string[]): MaybePromise$1<ReadonlyArray<ReadonlyDeep$1<StoreRoute>>>;
408
+ refresh(): void;
409
409
  };
410
410
  type RoutesSync = {
411
- readonly refresh$: AsyncIterable<RefreshEvent>;
412
- load(): Promise<void>;
413
- get(id: string): ReadonlyDeep<StoreRoute> | undefined;
414
- get(ids: readonly string[]): ReadonlyArray<ReadonlyDeep<StoreRoute>>;
415
- getByPath(path: string): ReadonlyDeep<StoreRoute> | undefined;
416
- getByPath(paths: readonly string[]): ReadonlyArray<ReadonlyDeep<StoreRoute>>;
417
- refresh(): void;
418
- };
419
-
411
+ readonly refresh$: AsyncIterable<RefreshEvent>;
412
+ load(): Promise<void>;
413
+ get(id: string): ReadonlyDeep$1<StoreRoute> | undefined;
414
+ get(ids: readonly string[]): ReadonlyArray<ReadonlyDeep$1<StoreRoute>>;
415
+ getByPath(path: string): ReadonlyDeep$1<StoreRoute> | undefined;
416
+ getByPath(paths: readonly string[]): ReadonlyArray<ReadonlyDeep$1<StoreRoute>>;
417
+ refresh(): void;
418
+ };
419
+ //#endregion
420
+ //#region src/store.d.ts
420
421
  /** Project the model-reference-name union out of a Schema generic, falling back to `string`. */
421
422
  type ModelsOf<TSchema> = TSchema extends {
422
- models: infer M;
423
+ models: infer M;
423
424
  } ? keyof M & string : string;
424
425
  type CollectionArg<TSchema> = SourceKeysOf<TSchema, 'entity'> | SourceDef<ModelsOf<TSchema>, 'entity'>;
425
426
  type SingletonArg<TSchema> = SourceKeysOf<TSchema, 'singleton'> | SourceDef<ModelsOf<TSchema>, 'singleton'>;
426
427
  type CollectionRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>>;
427
428
  type SingletonRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>>;
428
429
  declare class Store<TSchema extends Schema | undefined = undefined> {
429
- private _client;
430
- private _resolver;
431
- private _watcher;
432
- private _schema;
433
- private _cleanups;
434
- private _refreshByTtl;
435
- /**
436
- * Multicast update-batch stream from the watcher. Consume with `for await (const batch of updates$)`;
437
- * each iteration starts an independent fan-out from the shared source.
438
- */
439
- readonly updates$: AsyncIterable<UpdateBatch>;
440
- constructor(options: CreateStoreOptions<TSchema>);
441
- get client(): ContelloClient<TSchema>;
442
- init(): Promise<void>;
443
- destroy(): Promise<void>;
444
- /** Resolve a string key (looked up via `schema.sources`) or a SourceDef directly to a SourceDef. */
445
- private _resolveSource;
446
- defineSingleton<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Singleton<TMapped>;
447
- defineSingletonSync<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonSyncOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): SingletonSync<TMapped>;
448
- defineCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
449
- id: string;
450
- } = CollectionRaw<TSchema, TArg> & {
451
- id: string;
452
- }>(sourceOrKey: TArg, options?: CollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Collection<TMapped>;
453
- defineCollectionSync<TArg extends CollectionArg<TSchema>, TMapped extends {
454
- id: string;
455
- } = CollectionRaw<TSchema, TArg> & {
456
- id: string;
457
- }>(sourceOrKey: TArg, options?: CollectionSyncOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): CollectionSync<TMapped>;
458
- defineLazyCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
459
- id: string;
460
- } = CollectionRaw<TSchema, TArg> & {
461
- id: string;
462
- }>(sourceOrKey: TArg, options?: LazyCollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): LazyCollection<TMapped>;
463
- defineAssets(options?: AssetsOptions | undefined): Assets;
464
- defineAssetsSync(options?: AssetsSyncOptions | undefined): AssetsSync;
465
- defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets;
466
- defineRoutes(options?: RoutesOptions | undefined): Routes;
467
- defineRoutesSync(options?: RoutesSyncOptions | undefined): RoutesSync;
468
- defineLazyRoutes(options?: LazyRoutesOptions | undefined): LazyRoutes;
469
- defineI18nMessages(def: I18nMessageDef): I18nMessages;
470
- ping: () => Promise<void>;
430
+ private _client;
431
+ private _resolver;
432
+ private _watcher;
433
+ private _schema;
434
+ private _cleanups;
435
+ private _refreshByTtl;
436
+ /**
437
+ * Multicast update-batch stream from the watcher. Consume with `for await (const batch of updates$)`;
438
+ * each iteration starts an independent fan-out from the shared source.
439
+ */
440
+ readonly updates$: AsyncIterable<UpdateBatch>;
441
+ ping: () => Promise<void>;
442
+ constructor(options: CreateStoreOptions<TSchema>);
443
+ /** Resolve a string key (looked up via `schema.sources`) or a SourceDef directly to a SourceDef. */
444
+ private _resolveSource;
445
+ get client(): ContelloClient<TSchema>;
446
+ init(): Promise<void>;
447
+ destroy(): Promise<void>;
448
+ defineSingleton<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Singleton<TMapped>;
449
+ defineSingletonSync<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonSyncOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): SingletonSync<TMapped>;
450
+ defineCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
451
+ id: string;
452
+ } = CollectionRaw<TSchema, TArg> & {
453
+ id: string;
454
+ }>(sourceOrKey: TArg, options?: CollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Collection<TMapped>;
455
+ defineCollectionSync<TArg extends CollectionArg<TSchema>, TMapped extends {
456
+ id: string;
457
+ } = CollectionRaw<TSchema, TArg> & {
458
+ id: string;
459
+ }>(sourceOrKey: TArg, options?: CollectionSyncOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): CollectionSync<TMapped>;
460
+ defineLazyCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
461
+ id: string;
462
+ } = CollectionRaw<TSchema, TArg> & {
463
+ id: string;
464
+ }>(sourceOrKey: TArg, options?: LazyCollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): LazyCollection<TMapped>;
465
+ defineAssets(options?: AssetsOptions | undefined): Assets;
466
+ defineAssetsSync(options?: AssetsSyncOptions | undefined): AssetsSync;
467
+ defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets;
468
+ defineRoutes(options?: RoutesOptions | undefined): Routes;
469
+ defineRoutesSync(options?: RoutesSyncOptions | undefined): RoutesSync;
470
+ defineLazyRoutes(options?: LazyRoutesOptions | undefined): LazyRoutes;
471
+ defineI18nMessages(def: I18nMessageDef): I18nMessages;
471
472
  }
472
473
  declare function createStore<TSchema extends Schema | undefined = undefined>(options: CreateStoreOptions<TSchema>): Store<TSchema>;
473
-
474
- export { type Assets, type AssetsOptions, type AssetsSync, type AssetsSyncOptions, type CacheOptions, type Collection, type CollectionOptions, type CollectionSync, type CollectionSyncOptions, type CreateStoreOptions, type ExtractSourceResult, type I18nInitialTranslation, type I18nMessage, type I18nMessageDef, type I18nMessageRegistrationDefinition, type I18nMessages, type I18nTranslation, type I18nVariableInput, type LazyAssets, type LazyAssetsOptions, type LazyCacheOptions, type LazyCollection, type LazyCollectionOptions, type LazyRoutes, type LazyRoutesOptions, type Loadable, type MapperContext, type ResolveSource, type Routes, type RoutesOptions, type RoutesSync, type RoutesSyncOptions, type Singleton, type SingletonOptions, type SingletonSync, type SingletonSyncOptions, type SourceAt, type SourceKeysOf, Store, type StoreAsset, type StoreFile, type StoreFileMetadata, type StoreRoute, type StoreRouteCustomHeader, type SyncCacheOptions, type UpdateBatch, type UpdateEvent, type UpdateEventFor, type UpdateMutationType, createStore };
474
+ //#endregion
475
+ export { type Assets, type AssetsOptions, type AssetsSync, type AssetsSyncOptions, type CacheOptions, type Collection, type CollectionOptions, type CollectionSync, type CollectionSyncOptions, type CreateStoreOptions, type ExtractSourceResult, type I18nInitialTranslation, type I18nMessage, type I18nMessageDef, type I18nMessageRegistrationDefinition, type I18nMessages, type I18nTranslation, type I18nVariableInput, type LazyAssets, type LazyAssetsOptions, type LazyCacheOptions, type LazyCollection, type LazyCollectionOptions, type LazyRoutes, type LazyRoutesOptions, type Loadable, type MapperContext, type MaybePromise, type ReadonlyDeep, type ResolveSource, type Routes, type RoutesOptions, type RoutesSync, type RoutesSyncOptions, type Singleton, type SingletonOptions, type SingletonSync, type SingletonSyncOptions, type SourceAt, type SourceKeysOf, Store, type StoreAsset, type StoreFile, type StoreFileMetadata, type StoreRoute, type StoreRouteCustomHeader, type SyncCacheOptions, type UpdateBatch, type UpdateEvent, type UpdateEventFor, type UpdateMutationType, createStore, maybeCatch, maybeThen };
476
+ //# sourceMappingURL=index.d.ts.map