@contello/store 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +307 -161
- package/dist/index.d.cts +48 -73
- package/dist/index.d.ts +48 -73
- package/dist/index.js +307 -159
- package/package.json +5 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { OperationMap, ContelloClient, ConnectionEvents, UploadData, UploadMetadata, UploadOptions, DownloadResult } from '@contello/client';
|
|
1
2
|
import { Observable } from 'rxjs';
|
|
2
|
-
import { ContelloSdkClient } from '@contello/sdk-client';
|
|
3
3
|
import { MaybePromise } from 'projected';
|
|
4
4
|
|
|
5
5
|
type StoreRouteCustomHeader = {
|
|
@@ -26,6 +26,7 @@ type StoreRoute = {
|
|
|
26
26
|
mimeType: string;
|
|
27
27
|
} | {
|
|
28
28
|
type: 'entity';
|
|
29
|
+
model: string;
|
|
29
30
|
entityType: string;
|
|
30
31
|
entityId: string;
|
|
31
32
|
});
|
|
@@ -89,30 +90,28 @@ type UpdateBatch = {
|
|
|
89
90
|
* explicit methods (`trackEntity`, `trackAsset`, `trackRoute`) are available
|
|
90
91
|
* for cases where only an id is known without the full GraphQL object.
|
|
91
92
|
*/
|
|
92
|
-
type MapperContext<
|
|
93
|
+
type MapperContext<TModels extends string = string> = {
|
|
93
94
|
track(obj: {
|
|
94
95
|
__typename: string;
|
|
95
96
|
id: string;
|
|
96
97
|
}): void;
|
|
97
|
-
trackEntity(typename:
|
|
98
|
+
trackEntity(typename: TModels, id: string): void;
|
|
98
99
|
trackAsset(id: string): void;
|
|
99
100
|
trackRoute(id: string): void;
|
|
100
101
|
};
|
|
101
102
|
|
|
102
103
|
type Fetchable<T> = MaybePromise<T> | Observable<T>;
|
|
103
|
-
type
|
|
104
|
-
getSdk: (requester: any) => TSdk;
|
|
105
|
-
pooling?: {
|
|
106
|
-
size?: number | undefined;
|
|
107
|
-
} | undefined;
|
|
108
|
-
};
|
|
109
|
-
type CreateStoreOptions<TSdk, TEntityTypes extends string = string> = {
|
|
104
|
+
type CreateStoreOptions<TOps extends OperationMap | undefined = undefined, TModels extends string = string> = {
|
|
110
105
|
url: string;
|
|
111
106
|
project: string;
|
|
112
107
|
token: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
models?: Record<TModels, string> | undefined;
|
|
109
|
+
operations?: TOps | undefined;
|
|
110
|
+
connections?: number | undefined;
|
|
111
|
+
onConnected?: (() => void) | undefined;
|
|
112
|
+
onReconnecting?: (() => void) | undefined;
|
|
113
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
114
|
+
connectionEvents?: ConnectionEvents | undefined;
|
|
116
115
|
};
|
|
117
116
|
/** Cache options for non-lazy collections and singletons. */
|
|
118
117
|
type CacheOptions = {
|
|
@@ -137,20 +136,20 @@ type LazyCacheOptions = {
|
|
|
137
136
|
/** Items are evicted from the LRU cache after this many ms. */
|
|
138
137
|
ttl?: number | undefined;
|
|
139
138
|
};
|
|
140
|
-
type SingletonDef<
|
|
139
|
+
type SingletonDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped, TModels extends string = string> = {
|
|
141
140
|
name?: string | undefined;
|
|
142
141
|
model: TModel;
|
|
143
|
-
fetch: (
|
|
144
|
-
map: (item: TRaw, ref: MapperContext<
|
|
142
|
+
fetch: (client: ContelloClient<TOps>) => MaybePromise<TRaw>;
|
|
143
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>;
|
|
145
144
|
cache?: CacheOptions | undefined;
|
|
146
145
|
onLoad?: (() => void) | undefined;
|
|
147
146
|
onRefresh?: (() => void) | undefined;
|
|
148
147
|
};
|
|
149
|
-
type SingletonSyncDef<
|
|
148
|
+
type SingletonSyncDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped, TModels extends string = string> = {
|
|
150
149
|
name?: string | undefined;
|
|
151
150
|
model: TModel;
|
|
152
|
-
fetch: (
|
|
153
|
-
map: (item: TRaw, ref: MapperContext<
|
|
151
|
+
fetch: (client: ContelloClient<TOps>) => MaybePromise<TRaw>;
|
|
152
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => TMapped;
|
|
154
153
|
cache?: SyncCacheOptions | undefined;
|
|
155
154
|
onLoad?: (() => void) | undefined;
|
|
156
155
|
onRefresh?: (() => void) | undefined;
|
|
@@ -169,24 +168,24 @@ type SingletonSync<T> = {
|
|
|
169
168
|
get(): T;
|
|
170
169
|
refresh(): void;
|
|
171
170
|
};
|
|
172
|
-
type CollectionDef<
|
|
171
|
+
type CollectionDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped extends {
|
|
173
172
|
id: string;
|
|
174
|
-
},
|
|
173
|
+
}, TModels extends string = string> = {
|
|
175
174
|
name?: string | undefined;
|
|
176
175
|
model: TModel;
|
|
177
|
-
fetch: (
|
|
178
|
-
map: (item: TRaw, ref: MapperContext<
|
|
176
|
+
fetch: (client: ContelloClient<TOps>) => Fetchable<TRaw[]>;
|
|
177
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>;
|
|
179
178
|
cache?: CacheOptions | undefined;
|
|
180
179
|
onLoad?: ((ids: string[]) => void) | undefined;
|
|
181
180
|
onRefresh?: ((ids: string[]) => void) | undefined;
|
|
182
181
|
};
|
|
183
|
-
type CollectionSyncDef<
|
|
182
|
+
type CollectionSyncDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped extends {
|
|
184
183
|
id: string;
|
|
185
|
-
},
|
|
184
|
+
}, TModels extends string = string> = {
|
|
186
185
|
name?: string | undefined;
|
|
187
186
|
model: TModel;
|
|
188
|
-
fetch: (
|
|
189
|
-
map: (item: TRaw, ref: MapperContext<
|
|
187
|
+
fetch: (client: ContelloClient<TOps>) => Fetchable<TRaw[]>;
|
|
188
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => TMapped;
|
|
190
189
|
cache?: SyncCacheOptions | undefined;
|
|
191
190
|
onLoad?: ((ids: string[]) => void) | undefined;
|
|
192
191
|
onRefresh?: ((ids: string[]) => void) | undefined;
|
|
@@ -209,14 +208,14 @@ type CollectionSync<T> = {
|
|
|
209
208
|
getAll(): T[];
|
|
210
209
|
refresh(): void;
|
|
211
210
|
};
|
|
212
|
-
type LazyCollectionDef<
|
|
211
|
+
type LazyCollectionDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped extends {
|
|
213
212
|
id: string;
|
|
214
|
-
},
|
|
213
|
+
}, TModels extends string = string> = {
|
|
215
214
|
name?: string | undefined;
|
|
216
215
|
model: TModel;
|
|
217
216
|
cache?: LazyCacheOptions | undefined;
|
|
218
|
-
fetch: (ids: string[],
|
|
219
|
-
map: (item: TRaw, ref: MapperContext<
|
|
217
|
+
fetch: (ids: string[], client: ContelloClient<TOps>) => Fetchable<TRaw[]>;
|
|
218
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>;
|
|
220
219
|
onRefresh?: ((ids: string[]) => void) | undefined;
|
|
221
220
|
};
|
|
222
221
|
type LazyCollection<T> = {
|
|
@@ -233,12 +232,12 @@ type StoreFileMetadata = {
|
|
|
233
232
|
type StoreFile = {
|
|
234
233
|
uid: string;
|
|
235
234
|
mimeType: string;
|
|
236
|
-
metadata: StoreFileMetadata |
|
|
235
|
+
metadata: StoreFileMetadata | undefined;
|
|
237
236
|
};
|
|
238
237
|
type StoreAsset = {
|
|
239
238
|
id: string;
|
|
240
239
|
original: StoreFile;
|
|
241
|
-
preview: StoreFile |
|
|
240
|
+
preview: StoreFile | undefined;
|
|
242
241
|
optimized: StoreFile[];
|
|
243
242
|
};
|
|
244
243
|
type AssetCollectionOptions = {
|
|
@@ -248,7 +247,8 @@ type Assets = {
|
|
|
248
247
|
readonly refresh$: Observable<string[]>;
|
|
249
248
|
get(id: string): Promise<StoreAsset | undefined>;
|
|
250
249
|
get(ids: string[]): Promise<StoreAsset[]>;
|
|
251
|
-
|
|
250
|
+
upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
|
|
251
|
+
download(fileId: string): Promise<DownloadResult>;
|
|
252
252
|
};
|
|
253
253
|
|
|
254
254
|
type I18nTranslation = {
|
|
@@ -301,55 +301,30 @@ type Routes = {
|
|
|
301
301
|
getByPath(paths: string[]): Promise<StoreRoute[]>;
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
declare class Store<
|
|
305
|
-
private
|
|
306
|
-
private
|
|
307
|
-
private _entityTypes;
|
|
304
|
+
declare class Store<TOps extends OperationMap | undefined = undefined, TModels extends string = string> {
|
|
305
|
+
private _client;
|
|
306
|
+
private _resolver;
|
|
308
307
|
private _watcher;
|
|
309
308
|
readonly updates$: Observable<UpdateBatch>;
|
|
310
|
-
constructor(options: CreateStoreOptions<
|
|
311
|
-
private get sdk();
|
|
309
|
+
constructor(options: CreateStoreOptions<TOps, TModels>);
|
|
312
310
|
init(): Promise<void>;
|
|
313
311
|
destroy(): Promise<void>;
|
|
314
|
-
defineSingleton<TModel extends
|
|
315
|
-
defineSingletonSync<TModel extends
|
|
316
|
-
defineCollection<TModel extends
|
|
312
|
+
defineSingleton<TModel extends TModels, TRaw, TMapped>(def: SingletonDef<TOps, TModel, TRaw, TMapped, TModels>): Singleton<TMapped>;
|
|
313
|
+
defineSingletonSync<TModel extends TModels, TRaw, TMapped>(def: SingletonSyncDef<TOps, TModel, TRaw, TMapped, TModels>): SingletonSync<TMapped>;
|
|
314
|
+
defineCollection<TModel extends TModels, TRaw, TMapped extends {
|
|
317
315
|
id: string;
|
|
318
|
-
}>(def: CollectionDef<
|
|
319
|
-
defineCollectionSync<TModel extends
|
|
316
|
+
}>(def: CollectionDef<TOps, TModel, TRaw, TMapped, TModels>): Collection<TMapped>;
|
|
317
|
+
defineCollectionSync<TModel extends TModels, TRaw, TMapped extends {
|
|
320
318
|
id: string;
|
|
321
|
-
}>(def: CollectionSyncDef<
|
|
322
|
-
defineLazyCollection<TModel extends
|
|
319
|
+
}>(def: CollectionSyncDef<TOps, TModel, TRaw, TMapped, TModels>): CollectionSync<TMapped>;
|
|
320
|
+
defineLazyCollection<TModel extends TModels, TRaw, TMapped extends {
|
|
323
321
|
id: string;
|
|
324
|
-
}>(def: LazyCollectionDef<
|
|
322
|
+
}>(def: LazyCollectionDef<TOps, TModel, TRaw, TMapped, TModels>): LazyCollection<TMapped>;
|
|
325
323
|
defineAssets(options?: AssetCollectionOptions | undefined): Assets;
|
|
326
324
|
defineRoutes(options?: RouteCollectionOptions | undefined): Routes;
|
|
327
325
|
defineI18nMessages(def: I18nMessageDef): I18nMessages;
|
|
328
326
|
ping: () => Promise<void>;
|
|
329
327
|
}
|
|
330
|
-
declare function createStore<
|
|
331
|
-
|
|
332
|
-
declare const NO_MATCH: unique symbol;
|
|
333
|
-
type FlatRef = {
|
|
334
|
-
_flatId?: string | null;
|
|
335
|
-
};
|
|
336
|
-
type MapFn<TResult> = (refs: readonly FlatRef[] | null | undefined) => TResult[];
|
|
337
|
-
type Visitors<TFlat extends {
|
|
338
|
-
__typename: string;
|
|
339
|
-
} & FlatRef, TResult> = {
|
|
340
|
-
[K in TFlat['__typename']]?: (component: Extract<TFlat, {
|
|
341
|
-
__typename: K;
|
|
342
|
-
}>, map: MapFn<TResult>) => TResult | null | undefined | false | 0 | '';
|
|
343
|
-
} & {
|
|
344
|
-
[NO_MATCH]?: (component: TFlat) => void;
|
|
345
|
-
};
|
|
346
|
-
declare class ComponentMapper<TFlat extends {
|
|
347
|
-
__typename: string;
|
|
348
|
-
} & FlatRef, TResult> {
|
|
349
|
-
private readonly visitors;
|
|
350
|
-
constructor(visitors: Visitors<TFlat, TResult>);
|
|
351
|
-
map(flat: readonly TFlat[] | null | undefined, refs: readonly FlatRef[] | null | undefined): TResult[];
|
|
352
|
-
private resolveRefs;
|
|
353
|
-
}
|
|
328
|
+
declare function createStore<TOps extends OperationMap | undefined = undefined, TModels extends string = string>(options: CreateStoreOptions<TOps, TModels>): Store<TOps, TModels>;
|
|
354
329
|
|
|
355
|
-
export { type AssetCollectionOptions, type Assets, type CacheOptions, type Collection, type CollectionDef, type CollectionSync, type CollectionSyncDef,
|
|
330
|
+
export { type AssetCollectionOptions, type Assets, type CacheOptions, type Collection, type CollectionDef, type CollectionSync, type CollectionSyncDef, type CreateStoreOptions, type Fetchable, type I18nInitialTranslation, type I18nMessage, type I18nMessageDef, type I18nMessageRegistrationDefinition, type I18nMessages, type I18nTranslation, type I18nVariableInput, type LazyCacheOptions, type LazyCollection, type LazyCollectionDef, type MapperContext, type RouteCollectionOptions, type Routes, type Singleton, type SingletonDef, type SingletonSync, type SingletonSyncDef, Store, type StoreAsset, type StoreFile, type StoreFileMetadata, type StoreRoute, type StoreRouteCustomHeader, type SyncCacheOptions, type UpdateBatch, type UpdateEvent, type UpdateEventFor, type UpdateMutationType, createStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { OperationMap, ContelloClient, ConnectionEvents, UploadData, UploadMetadata, UploadOptions, DownloadResult } from '@contello/client';
|
|
1
2
|
import { Observable } from 'rxjs';
|
|
2
|
-
import { ContelloSdkClient } from '@contello/sdk-client';
|
|
3
3
|
import { MaybePromise } from 'projected';
|
|
4
4
|
|
|
5
5
|
type StoreRouteCustomHeader = {
|
|
@@ -26,6 +26,7 @@ type StoreRoute = {
|
|
|
26
26
|
mimeType: string;
|
|
27
27
|
} | {
|
|
28
28
|
type: 'entity';
|
|
29
|
+
model: string;
|
|
29
30
|
entityType: string;
|
|
30
31
|
entityId: string;
|
|
31
32
|
});
|
|
@@ -89,30 +90,28 @@ type UpdateBatch = {
|
|
|
89
90
|
* explicit methods (`trackEntity`, `trackAsset`, `trackRoute`) are available
|
|
90
91
|
* for cases where only an id is known without the full GraphQL object.
|
|
91
92
|
*/
|
|
92
|
-
type MapperContext<
|
|
93
|
+
type MapperContext<TModels extends string = string> = {
|
|
93
94
|
track(obj: {
|
|
94
95
|
__typename: string;
|
|
95
96
|
id: string;
|
|
96
97
|
}): void;
|
|
97
|
-
trackEntity(typename:
|
|
98
|
+
trackEntity(typename: TModels, id: string): void;
|
|
98
99
|
trackAsset(id: string): void;
|
|
99
100
|
trackRoute(id: string): void;
|
|
100
101
|
};
|
|
101
102
|
|
|
102
103
|
type Fetchable<T> = MaybePromise<T> | Observable<T>;
|
|
103
|
-
type
|
|
104
|
-
getSdk: (requester: any) => TSdk;
|
|
105
|
-
pooling?: {
|
|
106
|
-
size?: number | undefined;
|
|
107
|
-
} | undefined;
|
|
108
|
-
};
|
|
109
|
-
type CreateStoreOptions<TSdk, TEntityTypes extends string = string> = {
|
|
104
|
+
type CreateStoreOptions<TOps extends OperationMap | undefined = undefined, TModels extends string = string> = {
|
|
110
105
|
url: string;
|
|
111
106
|
project: string;
|
|
112
107
|
token: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
models?: Record<TModels, string> | undefined;
|
|
109
|
+
operations?: TOps | undefined;
|
|
110
|
+
connections?: number | undefined;
|
|
111
|
+
onConnected?: (() => void) | undefined;
|
|
112
|
+
onReconnecting?: (() => void) | undefined;
|
|
113
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
114
|
+
connectionEvents?: ConnectionEvents | undefined;
|
|
116
115
|
};
|
|
117
116
|
/** Cache options for non-lazy collections and singletons. */
|
|
118
117
|
type CacheOptions = {
|
|
@@ -137,20 +136,20 @@ type LazyCacheOptions = {
|
|
|
137
136
|
/** Items are evicted from the LRU cache after this many ms. */
|
|
138
137
|
ttl?: number | undefined;
|
|
139
138
|
};
|
|
140
|
-
type SingletonDef<
|
|
139
|
+
type SingletonDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped, TModels extends string = string> = {
|
|
141
140
|
name?: string | undefined;
|
|
142
141
|
model: TModel;
|
|
143
|
-
fetch: (
|
|
144
|
-
map: (item: TRaw, ref: MapperContext<
|
|
142
|
+
fetch: (client: ContelloClient<TOps>) => MaybePromise<TRaw>;
|
|
143
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>;
|
|
145
144
|
cache?: CacheOptions | undefined;
|
|
146
145
|
onLoad?: (() => void) | undefined;
|
|
147
146
|
onRefresh?: (() => void) | undefined;
|
|
148
147
|
};
|
|
149
|
-
type SingletonSyncDef<
|
|
148
|
+
type SingletonSyncDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped, TModels extends string = string> = {
|
|
150
149
|
name?: string | undefined;
|
|
151
150
|
model: TModel;
|
|
152
|
-
fetch: (
|
|
153
|
-
map: (item: TRaw, ref: MapperContext<
|
|
151
|
+
fetch: (client: ContelloClient<TOps>) => MaybePromise<TRaw>;
|
|
152
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => TMapped;
|
|
154
153
|
cache?: SyncCacheOptions | undefined;
|
|
155
154
|
onLoad?: (() => void) | undefined;
|
|
156
155
|
onRefresh?: (() => void) | undefined;
|
|
@@ -169,24 +168,24 @@ type SingletonSync<T> = {
|
|
|
169
168
|
get(): T;
|
|
170
169
|
refresh(): void;
|
|
171
170
|
};
|
|
172
|
-
type CollectionDef<
|
|
171
|
+
type CollectionDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped extends {
|
|
173
172
|
id: string;
|
|
174
|
-
},
|
|
173
|
+
}, TModels extends string = string> = {
|
|
175
174
|
name?: string | undefined;
|
|
176
175
|
model: TModel;
|
|
177
|
-
fetch: (
|
|
178
|
-
map: (item: TRaw, ref: MapperContext<
|
|
176
|
+
fetch: (client: ContelloClient<TOps>) => Fetchable<TRaw[]>;
|
|
177
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>;
|
|
179
178
|
cache?: CacheOptions | undefined;
|
|
180
179
|
onLoad?: ((ids: string[]) => void) | undefined;
|
|
181
180
|
onRefresh?: ((ids: string[]) => void) | undefined;
|
|
182
181
|
};
|
|
183
|
-
type CollectionSyncDef<
|
|
182
|
+
type CollectionSyncDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped extends {
|
|
184
183
|
id: string;
|
|
185
|
-
},
|
|
184
|
+
}, TModels extends string = string> = {
|
|
186
185
|
name?: string | undefined;
|
|
187
186
|
model: TModel;
|
|
188
|
-
fetch: (
|
|
189
|
-
map: (item: TRaw, ref: MapperContext<
|
|
187
|
+
fetch: (client: ContelloClient<TOps>) => Fetchable<TRaw[]>;
|
|
188
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => TMapped;
|
|
190
189
|
cache?: SyncCacheOptions | undefined;
|
|
191
190
|
onLoad?: ((ids: string[]) => void) | undefined;
|
|
192
191
|
onRefresh?: ((ids: string[]) => void) | undefined;
|
|
@@ -209,14 +208,14 @@ type CollectionSync<T> = {
|
|
|
209
208
|
getAll(): T[];
|
|
210
209
|
refresh(): void;
|
|
211
210
|
};
|
|
212
|
-
type LazyCollectionDef<
|
|
211
|
+
type LazyCollectionDef<TOps extends OperationMap | undefined, TModel extends string, TRaw, TMapped extends {
|
|
213
212
|
id: string;
|
|
214
|
-
},
|
|
213
|
+
}, TModels extends string = string> = {
|
|
215
214
|
name?: string | undefined;
|
|
216
215
|
model: TModel;
|
|
217
216
|
cache?: LazyCacheOptions | undefined;
|
|
218
|
-
fetch: (ids: string[],
|
|
219
|
-
map: (item: TRaw, ref: MapperContext<
|
|
217
|
+
fetch: (ids: string[], client: ContelloClient<TOps>) => Fetchable<TRaw[]>;
|
|
218
|
+
map: (item: TRaw, ref: MapperContext<TModels>) => MaybePromise<TMapped>;
|
|
220
219
|
onRefresh?: ((ids: string[]) => void) | undefined;
|
|
221
220
|
};
|
|
222
221
|
type LazyCollection<T> = {
|
|
@@ -233,12 +232,12 @@ type StoreFileMetadata = {
|
|
|
233
232
|
type StoreFile = {
|
|
234
233
|
uid: string;
|
|
235
234
|
mimeType: string;
|
|
236
|
-
metadata: StoreFileMetadata |
|
|
235
|
+
metadata: StoreFileMetadata | undefined;
|
|
237
236
|
};
|
|
238
237
|
type StoreAsset = {
|
|
239
238
|
id: string;
|
|
240
239
|
original: StoreFile;
|
|
241
|
-
preview: StoreFile |
|
|
240
|
+
preview: StoreFile | undefined;
|
|
242
241
|
optimized: StoreFile[];
|
|
243
242
|
};
|
|
244
243
|
type AssetCollectionOptions = {
|
|
@@ -248,7 +247,8 @@ type Assets = {
|
|
|
248
247
|
readonly refresh$: Observable<string[]>;
|
|
249
248
|
get(id: string): Promise<StoreAsset | undefined>;
|
|
250
249
|
get(ids: string[]): Promise<StoreAsset[]>;
|
|
251
|
-
|
|
250
|
+
upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
|
|
251
|
+
download(fileId: string): Promise<DownloadResult>;
|
|
252
252
|
};
|
|
253
253
|
|
|
254
254
|
type I18nTranslation = {
|
|
@@ -301,55 +301,30 @@ type Routes = {
|
|
|
301
301
|
getByPath(paths: string[]): Promise<StoreRoute[]>;
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
declare class Store<
|
|
305
|
-
private
|
|
306
|
-
private
|
|
307
|
-
private _entityTypes;
|
|
304
|
+
declare class Store<TOps extends OperationMap | undefined = undefined, TModels extends string = string> {
|
|
305
|
+
private _client;
|
|
306
|
+
private _resolver;
|
|
308
307
|
private _watcher;
|
|
309
308
|
readonly updates$: Observable<UpdateBatch>;
|
|
310
|
-
constructor(options: CreateStoreOptions<
|
|
311
|
-
private get sdk();
|
|
309
|
+
constructor(options: CreateStoreOptions<TOps, TModels>);
|
|
312
310
|
init(): Promise<void>;
|
|
313
311
|
destroy(): Promise<void>;
|
|
314
|
-
defineSingleton<TModel extends
|
|
315
|
-
defineSingletonSync<TModel extends
|
|
316
|
-
defineCollection<TModel extends
|
|
312
|
+
defineSingleton<TModel extends TModels, TRaw, TMapped>(def: SingletonDef<TOps, TModel, TRaw, TMapped, TModels>): Singleton<TMapped>;
|
|
313
|
+
defineSingletonSync<TModel extends TModels, TRaw, TMapped>(def: SingletonSyncDef<TOps, TModel, TRaw, TMapped, TModels>): SingletonSync<TMapped>;
|
|
314
|
+
defineCollection<TModel extends TModels, TRaw, TMapped extends {
|
|
317
315
|
id: string;
|
|
318
|
-
}>(def: CollectionDef<
|
|
319
|
-
defineCollectionSync<TModel extends
|
|
316
|
+
}>(def: CollectionDef<TOps, TModel, TRaw, TMapped, TModels>): Collection<TMapped>;
|
|
317
|
+
defineCollectionSync<TModel extends TModels, TRaw, TMapped extends {
|
|
320
318
|
id: string;
|
|
321
|
-
}>(def: CollectionSyncDef<
|
|
322
|
-
defineLazyCollection<TModel extends
|
|
319
|
+
}>(def: CollectionSyncDef<TOps, TModel, TRaw, TMapped, TModels>): CollectionSync<TMapped>;
|
|
320
|
+
defineLazyCollection<TModel extends TModels, TRaw, TMapped extends {
|
|
323
321
|
id: string;
|
|
324
|
-
}>(def: LazyCollectionDef<
|
|
322
|
+
}>(def: LazyCollectionDef<TOps, TModel, TRaw, TMapped, TModels>): LazyCollection<TMapped>;
|
|
325
323
|
defineAssets(options?: AssetCollectionOptions | undefined): Assets;
|
|
326
324
|
defineRoutes(options?: RouteCollectionOptions | undefined): Routes;
|
|
327
325
|
defineI18nMessages(def: I18nMessageDef): I18nMessages;
|
|
328
326
|
ping: () => Promise<void>;
|
|
329
327
|
}
|
|
330
|
-
declare function createStore<
|
|
331
|
-
|
|
332
|
-
declare const NO_MATCH: unique symbol;
|
|
333
|
-
type FlatRef = {
|
|
334
|
-
_flatId?: string | null;
|
|
335
|
-
};
|
|
336
|
-
type MapFn<TResult> = (refs: readonly FlatRef[] | null | undefined) => TResult[];
|
|
337
|
-
type Visitors<TFlat extends {
|
|
338
|
-
__typename: string;
|
|
339
|
-
} & FlatRef, TResult> = {
|
|
340
|
-
[K in TFlat['__typename']]?: (component: Extract<TFlat, {
|
|
341
|
-
__typename: K;
|
|
342
|
-
}>, map: MapFn<TResult>) => TResult | null | undefined | false | 0 | '';
|
|
343
|
-
} & {
|
|
344
|
-
[NO_MATCH]?: (component: TFlat) => void;
|
|
345
|
-
};
|
|
346
|
-
declare class ComponentMapper<TFlat extends {
|
|
347
|
-
__typename: string;
|
|
348
|
-
} & FlatRef, TResult> {
|
|
349
|
-
private readonly visitors;
|
|
350
|
-
constructor(visitors: Visitors<TFlat, TResult>);
|
|
351
|
-
map(flat: readonly TFlat[] | null | undefined, refs: readonly FlatRef[] | null | undefined): TResult[];
|
|
352
|
-
private resolveRefs;
|
|
353
|
-
}
|
|
328
|
+
declare function createStore<TOps extends OperationMap | undefined = undefined, TModels extends string = string>(options: CreateStoreOptions<TOps, TModels>): Store<TOps, TModels>;
|
|
354
329
|
|
|
355
|
-
export { type AssetCollectionOptions, type Assets, type CacheOptions, type Collection, type CollectionDef, type CollectionSync, type CollectionSyncDef,
|
|
330
|
+
export { type AssetCollectionOptions, type Assets, type CacheOptions, type Collection, type CollectionDef, type CollectionSync, type CollectionSyncDef, type CreateStoreOptions, type Fetchable, type I18nInitialTranslation, type I18nMessage, type I18nMessageDef, type I18nMessageRegistrationDefinition, type I18nMessages, type I18nTranslation, type I18nVariableInput, type LazyCacheOptions, type LazyCollection, type LazyCollectionDef, type MapperContext, type RouteCollectionOptions, type Routes, type Singleton, type SingletonDef, type SingletonSync, type SingletonSyncDef, Store, type StoreAsset, type StoreFile, type StoreFileMetadata, type StoreRoute, type StoreRouteCustomHeader, type SyncCacheOptions, type UpdateBatch, type UpdateEvent, type UpdateEventFor, type UpdateMutationType, createStore };
|