@contello/store 3.0.0 → 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/fragments.d.ts +3 -1
- package/dist/fragments.d.ts.map +1 -0
- package/dist/fragments.js +18 -11
- package/dist/fragments.js.map +1 -0
- package/dist/index.cjs +1631 -1937
- package/dist/index.d.cts +326 -324
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +326 -324
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1604 -1947
- package/dist/index.js.map +1 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MaybePromise, ReadonlyDeep } from
|
|
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
|
-
|
|
7
|
-
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
8
|
};
|
|
9
9
|
type StoreRoute = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
id: string;
|
|
11
|
+
path: string;
|
|
12
|
+
customHeaders: StoreRouteCustomHeader[];
|
|
13
13
|
} & ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
type: 'redirect';
|
|
15
|
+
location: string;
|
|
16
|
+
status: number;
|
|
17
17
|
} | {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
type: 'text';
|
|
19
|
+
content: string;
|
|
20
|
+
mimeType: string;
|
|
21
21
|
} | {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
type: 'asset';
|
|
23
|
+
assetId: string;
|
|
24
|
+
fileId: string;
|
|
25
|
+
contentDisposition: 'inline' | 'attachment';
|
|
26
|
+
mimeType: string;
|
|
27
27
|
} | {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
id: string;
|
|
37
|
+
mutation: 'create';
|
|
38
|
+
target: 'route';
|
|
39
|
+
after: StoreRoute;
|
|
39
40
|
} | {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
id: string;
|
|
42
|
+
mutation: 'update';
|
|
43
|
+
target: 'route';
|
|
44
|
+
after: StoreRoute;
|
|
45
|
+
before: StoreRoute;
|
|
45
46
|
} | {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
id: string;
|
|
48
|
+
mutation: 'delete';
|
|
49
|
+
target: 'route';
|
|
49
50
|
} | {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
id: string;
|
|
52
|
+
mutation: 'create' | 'update' | 'delete';
|
|
53
|
+
target: 'asset';
|
|
53
54
|
} | {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
id: string;
|
|
56
|
+
mutation: 'create' | 'update' | 'delete';
|
|
57
|
+
target: 'i18nMessage';
|
|
58
|
+
token: string;
|
|
58
59
|
} | {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
67
|
+
target: T;
|
|
67
68
|
}>;
|
|
68
69
|
type UpdateBatch = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
146
|
+
kind: RefreshKind;
|
|
148
147
|
};
|
|
149
148
|
/** Cache options for non-lazy collections and singletons. */
|
|
150
149
|
type CacheOptions = {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
199
|
+
load(): Promise<void>;
|
|
202
200
|
};
|
|
203
201
|
type Singleton<T> = {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
216
|
+
id: string;
|
|
219
217
|
}, TModels extends string = string> = {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
226
|
+
id: string;
|
|
229
227
|
}, TModels extends string = string> = {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
254
|
+
id: string;
|
|
257
255
|
}, TModels extends string = string> = {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
274
|
-
|
|
272
|
+
width: number;
|
|
273
|
+
height: number;
|
|
275
274
|
};
|
|
276
275
|
type StoreFile = {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
uid: string;
|
|
277
|
+
mimeType: string;
|
|
278
|
+
metadata: StoreFileMetadata | undefined;
|
|
280
279
|
};
|
|
281
280
|
type StoreAsset = {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
id: string;
|
|
282
|
+
original: StoreFile;
|
|
283
|
+
preview: StoreFile | undefined;
|
|
284
|
+
optimized: StoreFile[];
|
|
286
285
|
};
|
|
287
286
|
type LazyAssetsOptions = {
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
cache?: LazyCacheOptions | undefined;
|
|
288
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
290
289
|
};
|
|
291
290
|
type LazyAssets = {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
cache?: CacheOptions | undefined;
|
|
304
|
+
onLoad?: ((ids: string[]) => void) | undefined;
|
|
305
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
306
306
|
};
|
|
307
307
|
type AssetsSyncOptions = {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
cache?: SyncCacheOptions | undefined;
|
|
309
|
+
onLoad?: ((ids: string[]) => void) | undefined;
|
|
310
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
311
311
|
};
|
|
312
312
|
type Assets = {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
335
|
-
|
|
335
|
+
language: string;
|
|
336
|
+
value: string;
|
|
336
337
|
};
|
|
337
338
|
type I18nVariableInput = {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
name: string;
|
|
340
|
+
description: string;
|
|
341
|
+
example: string;
|
|
341
342
|
};
|
|
342
343
|
type I18nInitialTranslation = {
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
language: string;
|
|
345
|
+
message: string;
|
|
345
346
|
};
|
|
346
347
|
type I18nMessageRegistrationDefinition = {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
collection: string;
|
|
357
|
+
cache?: SyncCacheOptions | undefined;
|
|
358
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
360
359
|
};
|
|
361
360
|
type I18nMessage = {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
361
|
+
id: string;
|
|
362
|
+
token: string;
|
|
363
|
+
translations: Map<string, string>;
|
|
365
364
|
};
|
|
366
365
|
type I18nMessages = {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
|
|
379
|
-
|
|
377
|
+
cache?: LazyCacheOptions | undefined;
|
|
378
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
380
379
|
};
|
|
381
380
|
type LazyRoutes = {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
cache?: CacheOptions | undefined;
|
|
393
|
+
onLoad?: ((ids: string[]) => void) | undefined;
|
|
394
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
395
395
|
};
|
|
396
396
|
type RoutesSyncOptions = {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
cache?: SyncCacheOptions | undefined;
|
|
398
|
+
onLoad?: ((ids: string[]) => void) | undefined;
|
|
399
|
+
onRefresh?: ((event: RefreshEvent) => void) | undefined;
|
|
400
400
|
};
|
|
401
401
|
type Routes = {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
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
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|