@web-ts-toolkit/access-router-client 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. package/README.md +39 -12
  2. package/index.d.mts +218 -193
  3. package/index.d.ts +218 -193
  4. package/index.js +785 -905
  5. package/index.mjs +781 -902
  6. package/package.json +13 -11
package/index.d.ts CHANGED
@@ -1,34 +1,5 @@
1
1
  import * as axios from 'axios';
2
- import { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosHeaders } from 'axios';
3
-
4
- declare class Model<T extends Document, TData extends Partial<T> = T> {
5
- private _data;
6
- private _snapshot;
7
- private readonly _service;
8
- private modifiedPaths;
9
- constructor(data: TData, adapter: ModelService<T>);
10
- static create<T, TData extends Partial<T> = T>(data: TData, adapter: ModelService<T>): Model<T, TData> & TData;
11
- save(reqConfig?: AxiosRequestConfig): Promise<any>;
12
- isDirty(path?: keyof TData | string): boolean;
13
- markModified(path: keyof TData | string): this;
14
- get<TKey extends keyof TData>(path: TKey): TData[TKey];
15
- get(path: string): unknown;
16
- set<TKey extends keyof TData>(path: TKey, value: TData[TKey]): this;
17
- set(path: string, value: unknown): this;
18
- assign(partial: Partial<TData>): this;
19
- reset(): this;
20
- toObject(): TData;
21
- toJSON(): TData;
22
- private updateModel;
23
- private replaceData;
24
- private initializeDirtyState;
25
- private prepareData;
26
- private defineHiddenDataProp;
27
- private defineHiddenAdapterProp;
28
- private definePublicDataProps;
29
- private trackModified;
30
- private normalizePath;
31
- }
2
+ import { AxiosInstance, AxiosResponse, AxiosRequestConfig, AxiosHeaders } from 'axios';
32
3
 
33
4
  interface SubQueryOptions {
34
5
  path?: string;
@@ -186,6 +157,195 @@ interface AdditionalReqConfig {
186
157
  throwOnError?: boolean;
187
158
  }
188
159
 
160
+ interface ResultError {
161
+ success: boolean;
162
+ raw: unknown;
163
+ data: unknown;
164
+ message: string;
165
+ status: number;
166
+ headers: Record<string, unknown>;
167
+ }
168
+ declare class Service {
169
+ protected _axios: AxiosInstance;
170
+ protected _basePath: string;
171
+ private _wrap;
172
+ constructor(axios: AxiosInstance, basePath: string);
173
+ protected handleSuccess(res: AxiosResponse<unknown, unknown>, extra?: {}): Response<unknown>;
174
+ protected handleError<T extends ResultError>(error: {
175
+ response?: {
176
+ status: number;
177
+ headers: Record<string, unknown>;
178
+ data: unknown;
179
+ };
180
+ request?: unknown;
181
+ message?: string;
182
+ }): T;
183
+ wrapGet<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
184
+ wrapPost<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (data?: unknown, options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
185
+ wrapPut<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (data?: unknown, options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
186
+ wrapPatch<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (data?: unknown, options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
187
+ wrapDelete<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
188
+ updateHeaders(headers: AxiosRequestConfig['headers'], { ignoreCache }: {
189
+ ignoreCache?: boolean;
190
+ }): AxiosHeaders | (Partial<axios.RawAxiosHeaders & {
191
+ Accept: axios.AxiosHeaderValue;
192
+ "Content-Length": axios.AxiosHeaderValue;
193
+ "User-Agent": axios.AxiosHeaderValue;
194
+ "Content-Encoding": axios.AxiosHeaderValue;
195
+ Authorization: axios.AxiosHeaderValue;
196
+ Location: axios.AxiosHeaderValue;
197
+ } & {
198
+ 'Content-Type': axios.AxiosHeaderValue;
199
+ }> & Partial<{
200
+ get: AxiosHeaders;
201
+ delete: AxiosHeaders;
202
+ head: AxiosHeaders;
203
+ options: AxiosHeaders;
204
+ post: AxiosHeaders;
205
+ put: AxiosHeaders;
206
+ patch: AxiosHeaders;
207
+ purge: AxiosHeaders;
208
+ link: AxiosHeaders;
209
+ unlink: AxiosHeaders;
210
+ query: AxiosHeaders;
211
+ } & {
212
+ common: AxiosHeaders;
213
+ }>);
214
+ }
215
+ declare class ServiceError extends Error {
216
+ success: boolean;
217
+ raw: unknown;
218
+ data: unknown;
219
+ status: number;
220
+ headers: Record<string, unknown>;
221
+ constructor(result: ResultError);
222
+ }
223
+
224
+ type RequestConfig$1 = AxiosRequestConfig & AdditionalReqConfig;
225
+ interface Props$1 {
226
+ axios: AxiosInstance;
227
+ modelName: string;
228
+ basePath: string;
229
+ queryPath: string;
230
+ mutationPath: string;
231
+ onSuccess: ResponseCallback;
232
+ onFailure: ResponseCallback;
233
+ throwOnError: boolean;
234
+ }
235
+ declare class ModelService<T extends Document> extends Service {
236
+ private _modelName;
237
+ private _queryPath;
238
+ private _mutationPath;
239
+ private _handleCallbacks;
240
+ private _defaults;
241
+ constructor({ axios, modelName, basePath, queryPath, mutationPath, onSuccess, onFailure, throwOnError }: Props$1, defaults?: Defaults);
242
+ list<TData extends Partial<T> = T>(args?: ListArgs, options?: ListOptions, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<ListModelResponse<T, TData>>;
243
+ listAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: ListAdvancedArgs<TSelect>, options?: ListAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ListModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
244
+ create<TData extends Partial<T> = T>(data: object, options?: CreateOptions, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<ModelResponse<T, TData>>;
245
+ createAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(data: object, args?: CreateAdvancedArgs<TSelect>, options?: CreateAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
246
+ upsert<TData extends Partial<T> = T>(data: object, options?: UpsertOptions, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<ModelResponse<T, TData>>;
247
+ upsertAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(data: object, args?: UpsertAdvancedArgs<TSelect>, options?: UpsertAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
248
+ delete(identifier: string, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<Response<string, string>>;
249
+ new<TData extends Partial<T> = T>(axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<ModelResponse<T, TData>>;
250
+ distinct(field: string, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<Response<string[], string[]>>;
251
+ distinctAdvanced(field: string, conditions: FilterQuery<T>, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<Response<string[], string[]>>;
252
+ count(axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<Response<number, number>>;
253
+ countAdvanced(filter: FilterQuery<T>, args?: {
254
+ access?: 'list' | 'read';
255
+ }, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<Response<number, number>>;
256
+ read<TData extends Partial<T> = T>(identifier: string, options?: ReadOptions, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<ModelResponse<T, TData>>;
257
+ readAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(identifier: string, args?: ReadAdvancedArgs<TSelect>, options?: ReadAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
258
+ readAdvancedFilter<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: ReadAdvancedArgs<TSelect>, options?: ReadAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
259
+ update<TData extends Partial<T> = T>(identifier: string, data: object, options?: UpdateOptions, axiosRequestConfig?: RequestConfig$1): ModelPromiseMeta & LazyRequest<ModelResponse<T, TData>>;
260
+ updateAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(identifier: string, data: object, args?: UpdateAdvancedArgs<TSelect>, options?: UpdateAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
261
+ id(id: string): {
262
+ subs: <S = T>(field: keyof T) => {
263
+ list: (axiosRequestConfig?: AxiosRequestConfig<any> & {
264
+ throwOnError?: boolean;
265
+ }) => ModelPromiseMeta & LazyRequest<ListModelResponse<S>>;
266
+ listAdvanced: <TData extends Partial<S> = never, TSelect extends readonly string[] = readonly string[]>(filter?: FilterQuery<S>, args?: {
267
+ select?: TSelect;
268
+ }, axiosRequestConfig?: AxiosRequestConfig<any> & {
269
+ throwOnError?: boolean;
270
+ }) => ModelPromiseMeta & LazyRequest<ListModelResponse<S, ResolvedSelectedShape<S, TSelect, TData>>>;
271
+ read: (subId: string, axiosRequestConfig?: AxiosRequestConfig<any> & {
272
+ throwOnError?: boolean;
273
+ }) => ModelPromiseMeta & LazyRequest<ModelResponse<S>>;
274
+ readAdvanced: <TData extends Partial<S> = never, TSelect_1 extends readonly string[] = readonly string[]>(subId: string, args?: {
275
+ select?: TSelect_1;
276
+ populate?: unknown;
277
+ }, axiosRequestConfig?: AxiosRequestConfig<any> & {
278
+ throwOnError?: boolean;
279
+ }) => ModelPromiseMeta & LazyRequest<ModelResponse<S, ResolvedSelectedShape<S, TSelect_1, TData>>>;
280
+ update: (subId: string, data: object, axiosRequestConfig?: AxiosRequestConfig<any> & {
281
+ throwOnError?: boolean;
282
+ }) => ModelPromiseMeta & LazyRequest<ModelResponse<S>>;
283
+ bulkUpdate: (data: object[], axiosRequestConfig?: AxiosRequestConfig<any> & {
284
+ throwOnError?: boolean;
285
+ }) => ModelPromiseMeta & LazyRequest<ListModelResponse<S>>;
286
+ create: (data: object, axiosRequestConfig?: AxiosRequestConfig<any> & {
287
+ throwOnError?: boolean;
288
+ }) => ModelPromiseMeta & LazyRequest<ModelResponse<S>>;
289
+ delete: (subId: string, axiosRequestConfig?: AxiosRequestConfig<any> & {
290
+ throwOnError?: boolean;
291
+ }) => ModelPromiseMeta & LazyRequest<Response<string, string>>;
292
+ };
293
+ fetch: (args?: ReadAdvancedArgs, options?: ReadAdvancedOptions, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ModelResponse<T, Partial<T>>>;
294
+ };
295
+ }
296
+
297
+ type RequestConfig = AxiosRequestConfig & AdditionalReqConfig;
298
+ interface Props {
299
+ axios: AxiosInstance;
300
+ dataName: string;
301
+ basePath: string;
302
+ queryPath: string;
303
+ onSuccess: ResponseCallback;
304
+ onFailure: ResponseCallback;
305
+ throwOnError: boolean;
306
+ }
307
+ declare class DataService<T> extends Service {
308
+ private _dataName;
309
+ private _queryPath;
310
+ private _handleCallbacks;
311
+ private _defaults;
312
+ constructor({ axios, dataName, basePath, queryPath, onSuccess, onFailure, throwOnError }: Props, defaults?: DataDefaults);
313
+ list<TData extends Partial<T> = T>(args?: DataListArgs, options?: DataListOptions, axiosRequestConfig?: RequestConfig): DataPromiseMeta & LazyRequest<ListDataResponse<TData>>;
314
+ listAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: DataListAdvancedArgs<TSelect>, options?: DataListAdvancedOptions, axiosRequestConfig?: RequestConfig): DataRequest<ListDataResponse<ResolvedSelectedShape<T, TSelect, TData>>>;
315
+ read<TData extends Partial<T> = T>(identifier: string, options?: DataReadOptions, axiosRequestConfig?: RequestConfig): DataPromiseMeta & LazyRequest<DataResponse<TData>>;
316
+ readAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(identifier: string, args?: DataReadAdvancedArgs<TSelect>, options?: DataReadAdvancedOptions, axiosRequestConfig?: RequestConfig): DataRequest<DataResponse<ResolvedSelectedShape<T, TSelect, TData>>>;
317
+ readAdvancedFilter<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: DataReadAdvancedArgs<TSelect>, options?: DataReadAdvancedOptions, axiosRequestConfig?: RequestConfig): DataRequest<DataResponse<ResolvedSelectedShape<T, TSelect, TData>>>;
318
+ }
319
+
320
+ declare class Model<T extends Document, TData extends Partial<T> = T> {
321
+ private _data;
322
+ private _snapshot;
323
+ private readonly _service;
324
+ private modifiedPaths;
325
+ constructor(data: TData, adapter: ModelService<T>);
326
+ static create<T, TData extends Partial<T> = T>(data: TData, adapter: ModelService<T>): Model<T, TData> & TData;
327
+ save(reqConfig?: AxiosRequestConfig): Promise<any>;
328
+ isDirty(path?: keyof TData | string): boolean;
329
+ markModified(path: keyof TData | string): this;
330
+ get<TKey extends keyof TData>(path: TKey): TData[TKey];
331
+ get(path: string): unknown;
332
+ set<TKey extends keyof TData>(path: TKey, value: TData[TKey]): this;
333
+ set(path: string, value: unknown): this;
334
+ assign(partial: Partial<TData>): this;
335
+ reset(): this;
336
+ toObject(): TData;
337
+ toJSON(): TData;
338
+ private updateModel;
339
+ private replaceData;
340
+ private initializeDirtyState;
341
+ private prepareData;
342
+ private defineHiddenDataProp;
343
+ private defineHiddenAdapterProp;
344
+ private definePublicDataProps;
345
+ private trackModified;
346
+ private normalizePath;
347
+ }
348
+
189
349
  type AnyArray<T> = T[] | ReadonlyArray<T>;
190
350
  type Unpacked<T> = T extends (infer U)[] ? U : T extends ReadonlyArray<infer U> ? U : T;
191
351
  type ApplyBasicQueryCasting<T> = T | T[] | (T extends (infer U)[] ? U : unknown) | unknown;
@@ -236,6 +396,13 @@ type QuerySelector<T> = {
236
396
  $options?: T extends string ? string : never;
237
397
  };
238
398
 
399
+ /**
400
+ * Wraps a lazy promise function with optional metadata.
401
+ * The promise is only created when `.then()`, `.catch()`, `.finally()`, or `.exec()` is called.
402
+ * Metadata properties are merged onto the returned object via `Object.assign`.
403
+ */
404
+ declare const wrapLazyPromise: <T, M = undefined>(promiseFn: () => Promise<T>, meta?: M) => M & LazyRequest<T>;
405
+
239
406
  type KeyValueProjection<TKey extends string = string> = Partial<Record<TKey, 1 | -1>>;
240
407
  type Projection = readonly string[] | string | KeyValueProjection;
241
408
  type SelectableKey<T> = Extract<keyof T, string>;
@@ -306,6 +473,7 @@ interface RootModelQueryMeta {
306
473
  data?: unknown;
307
474
  args?: Record<string, unknown>;
308
475
  options?: Record<string, unknown>;
476
+ order?: number;
309
477
  sqOptions?: SubQueryOptions;
310
478
  }
311
479
  interface RootDataQueryMeta {
@@ -317,17 +485,9 @@ interface RootDataQueryMeta {
317
485
  data?: unknown;
318
486
  args?: Record<string, unknown>;
319
487
  options?: Record<string, unknown>;
488
+ order?: number;
320
489
  }
321
490
  type RootQueryMeta = RootModelQueryMeta | RootDataQueryMeta;
322
- interface SubQueryMeta {
323
- model: string;
324
- op: 'list' | 'read';
325
- id?: string;
326
- filter?: unknown;
327
- args?: Record<string, unknown>;
328
- options?: Record<string, unknown>;
329
- sqOptions?: SubQueryOptions;
330
- }
331
491
  interface ModelPromiseMeta {
332
492
  __op: string;
333
493
  __query: RootModelQueryMeta;
@@ -350,158 +510,13 @@ interface DataPromiseMeta {
350
510
  __service?: DataService<unknown>;
351
511
  }
352
512
  type DataRequest<T> = DataPromiseMeta & LazyRequest<T>;
353
- declare const wrapLazyPromise: <T, M = undefined>(promiseFn: () => Promise<T>, meta?: M) => M & LazyRequest<T>;
513
+
354
514
  type ResponseCallback = (res: unknown) => void;
355
515
  interface WrapOptions {
356
516
  queryParams?: Record<string, unknown>;
357
517
  pathParams?: Record<string, string | number>;
358
518
  }
359
519
 
360
- interface ResultError {
361
- success: boolean;
362
- raw: unknown;
363
- data: unknown;
364
- message: string;
365
- status: number;
366
- headers: Record<string, unknown>;
367
- }
368
- declare class Service {
369
- protected _axios: AxiosInstance;
370
- protected _basePath: string;
371
- constructor(axios: AxiosInstance, basePath: string);
372
- protected handleSuccess(res: AxiosResponse<unknown, unknown>, extra?: {}): Response<unknown>;
373
- protected handleError<T extends ResultError>(error: {
374
- response?: {
375
- status: number;
376
- headers: Record<string, unknown>;
377
- data: unknown;
378
- };
379
- request?: unknown;
380
- message?: string;
381
- }): T;
382
- wrapGet<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
383
- wrapPost<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (data?: unknown, options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
384
- wrapPut<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (data?: unknown, options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
385
- wrapPatch<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (data?: unknown, options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
386
- wrapDelete<T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig): (options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<AxiosResponse<T, any, {}>>;
387
- updateHeaders(headers: AxiosRequestConfig['headers'], { ignoreCache }: {
388
- ignoreCache?: boolean;
389
- }): AxiosHeaders | (Partial<axios.RawAxiosHeaders & {
390
- Accept: axios.AxiosHeaderValue;
391
- "Content-Length": axios.AxiosHeaderValue;
392
- "User-Agent": axios.AxiosHeaderValue;
393
- "Content-Encoding": axios.AxiosHeaderValue;
394
- Authorization: axios.AxiosHeaderValue;
395
- Location: axios.AxiosHeaderValue;
396
- } & {
397
- 'Content-Type': axios.AxiosHeaderValue;
398
- }> & Partial<{
399
- get: AxiosHeaders;
400
- delete: AxiosHeaders;
401
- head: AxiosHeaders;
402
- options: AxiosHeaders;
403
- post: AxiosHeaders;
404
- put: AxiosHeaders;
405
- patch: AxiosHeaders;
406
- purge: AxiosHeaders;
407
- link: AxiosHeaders;
408
- unlink: AxiosHeaders;
409
- query: AxiosHeaders;
410
- } & {
411
- common: AxiosHeaders;
412
- }>);
413
- }
414
- declare class ServiceError extends Error {
415
- success: boolean;
416
- raw: unknown;
417
- data: unknown;
418
- status: number;
419
- headers: Record<string, unknown>;
420
- constructor(result: ResultError);
421
- }
422
-
423
- type RequestConfig$1 = AxiosRequestConfig & AdditionalReqConfig;
424
- interface Props$1 {
425
- axios: AxiosInstance;
426
- modelName: string;
427
- basePath: string;
428
- queryPath: string;
429
- mutationPath: string;
430
- onSuccess: ResponseCallback;
431
- onFailure: ResponseCallback;
432
- throwOnError: boolean;
433
- }
434
- declare class ModelService<T extends Document> extends Service {
435
- private _modelName;
436
- private _queryPath;
437
- private _mutationPath;
438
- private _handleCallbacks;
439
- private _defaults;
440
- constructor({ axios, modelName, basePath, queryPath, mutationPath, onSuccess, onFailure, throwOnError }: Props$1, defaults?: Defaults);
441
- list<TData extends Partial<T> = T>(args?: ListArgs, options?: ListOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ListModelResponse<T, TData>>;
442
- listAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: ListAdvancedArgs<TSelect>, options?: ListAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ListModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
443
- read<TData extends Partial<T> = T>(identifier: string, options?: ReadOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, TData>>;
444
- readAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(identifier: string, args?: ReadAdvancedArgs<TSelect>, options?: ReadAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
445
- readAdvancedFilter<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: ReadAdvancedArgs<TSelect>, options?: ReadAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
446
- new<TData extends Partial<T> = T>(axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, TData>>;
447
- create<TData extends Partial<T> = T>(data: object, options?: CreateOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, TData>>;
448
- createAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(data: object, args?: CreateAdvancedArgs<TSelect>, options?: CreateAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
449
- update<TData extends Partial<T> = T>(identifier: string, data: object, options?: UpdateOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, TData>>;
450
- updateAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(identifier: string, data: object, args?: UpdateAdvancedArgs<TSelect>, options?: UpdateAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
451
- upsert<TData extends Partial<T> = T>(data: object, options?: UpsertOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, TData>>;
452
- upsertAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(data: object, args?: UpsertAdvancedArgs<TSelect>, options?: UpsertAdvancedOptions, axiosRequestConfig?: RequestConfig$1): ModelRequest<ModelResponse<T, ResolvedSelectedShape<T, TSelect, TData>>>;
453
- delete(identifier: string, axiosRequestConfig?: RequestConfig$1): ModelRequest<Response<string, string>>;
454
- distinct(field: string, axiosRequestConfig?: RequestConfig$1): ModelRequest<Response<string[], string[]>>;
455
- distinctAdvanced(field: string, conditions: FilterQuery<T>, axiosRequestConfig?: RequestConfig$1): ModelRequest<Response<string[], string[]>>;
456
- count(axiosRequestConfig?: RequestConfig$1): ModelRequest<Response<number, number>>;
457
- countAdvanced(filter: FilterQuery<T>, args?: {
458
- access?: string;
459
- }, axiosRequestConfig?: RequestConfig$1): ModelRequest<Response<number, number>>;
460
- id(id: string): {
461
- subs: <S = T>(field: keyof T) => {
462
- list: (axiosRequestConfig?: RequestConfig$1) => ModelRequest<ListModelResponse<S>>;
463
- listAdvanced: <TData extends Partial<S> | never = never, TSelect extends readonly string[] = readonly string[]>(filter?: FilterQuery<S>, args?: {
464
- select?: TSelect;
465
- }, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ListModelResponse<S, ResolvedSelectedShape<S, TSelect, TData>>>;
466
- read: (subId: string, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ModelResponse<S>>;
467
- readAdvanced: <TData extends Partial<S> | never = never, TSelect_1 extends readonly string[] = readonly string[]>(subId: string, args?: {
468
- select?: TSelect_1;
469
- populate?: unknown;
470
- }, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ModelResponse<S, ResolvedSelectedShape<S, TSelect_1, TData>>>;
471
- update: (subId: string, data: object, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ModelResponse<S>>;
472
- bulkUpdate: (data: object[], _options?: object, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ListModelResponse<S>>;
473
- create: (data: object, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ModelResponse<S>>;
474
- delete: (subId: string, axiosRequestConfig?: RequestConfig$1) => ModelRequest<Response<string, string>>;
475
- };
476
- fetch: (args?: ReadAdvancedArgs, options?: ReadAdvancedOptions, axiosRequestConfig?: RequestConfig$1) => ModelRequest<ModelResponse<T, Partial<T>>>;
477
- };
478
- private processListResult;
479
- }
480
-
481
- type RequestConfig = AxiosRequestConfig & AdditionalReqConfig;
482
- interface Props {
483
- axios: AxiosInstance;
484
- dataName: string;
485
- basePath: string;
486
- queryPath: string;
487
- onSuccess: ResponseCallback;
488
- onFailure: ResponseCallback;
489
- throwOnError: boolean;
490
- }
491
- declare class DataService<T> extends Service {
492
- private _dataName;
493
- private _queryPath;
494
- private _handleCallbacks;
495
- private _defaults;
496
- constructor({ axios, dataName, basePath, queryPath, onSuccess, onFailure, throwOnError }: Props, defaults?: DataDefaults);
497
- list<TData extends Partial<T> = T>(args?: DataListArgs, options?: DataListOptions, axiosRequestConfig?: RequestConfig): DataRequest<ListDataResponse<TData>>;
498
- listAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: DataListAdvancedArgs<TSelect>, options?: DataListAdvancedOptions, axiosRequestConfig?: RequestConfig): DataRequest<ListDataResponse<ResolvedSelectedShape<T, TSelect, TData>>>;
499
- read<TData extends Partial<T> = T>(identifier: string, options?: DataReadOptions, axiosRequestConfig?: RequestConfig): DataRequest<DataResponse<TData>>;
500
- readAdvanced<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(identifier: string, args?: DataReadAdvancedArgs<TSelect>, options?: DataReadAdvancedOptions, axiosRequestConfig?: RequestConfig): DataRequest<DataResponse<ResolvedSelectedShape<T, TSelect, TData>>>;
501
- readAdvancedFilter<TData extends Partial<T> | never = never, TSelect extends Projection = Projection>(filter: FilterQuery<T>, args?: DataReadAdvancedArgs<TSelect>, options?: DataReadAdvancedOptions, axiosRequestConfig?: RequestConfig): DataRequest<DataResponse<ResolvedSelectedShape<T, TSelect, TData>>>;
502
- private processListResult;
503
- }
504
-
505
520
  interface AdapterOptions {
506
521
  rootRouterPath?: string;
507
522
  onSuccess?: ResponseCallback;
@@ -530,25 +545,35 @@ declare function createAdapter(axiosConfig?: AxiosRequestConfig, adapterOptions?
530
545
  axios: axios.AxiosInstance;
531
546
  createModelService: <T>({ modelName, basePath, queryPath, mutationPath, onSuccess, onFailure, throwOnError, }: ModelServiceOptions, defaults?: Defaults) => ModelService<T>;
532
547
  createDataService: <T>({ dataName, basePath, queryPath, onSuccess, onFailure, throwOnError }: DataServiceOptions, defaults?: DataDefaults) => DataService<T>;
533
- wrapGet: <T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig) => (options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
534
- wrapPost: <T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig) => (data?: unknown, options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
535
- wrapPut: <T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig) => (data?: unknown, options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
536
- wrapPatch: <T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig) => (data?: unknown, options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
537
- wrapDelete: <T = unknown>(url: string, defaultAxiosRequestConfig?: AxiosRequestConfig) => (options?: WrapOptions, axiosRequestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
548
+ wrapGet: <T = unknown>(url: string, defaultConfig?: AxiosRequestConfig) => (options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
549
+ wrapPost: <T = unknown>(url: string, defaultConfig?: AxiosRequestConfig) => (data?: unknown, options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
550
+ wrapPut: <T = unknown>(url: string, defaultConfig?: AxiosRequestConfig) => (data?: unknown, options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
551
+ wrapPatch: <T = unknown>(url: string, defaultConfig?: AxiosRequestConfig) => (data?: unknown, options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
552
+ wrapDelete: <T = unknown>(url: string, defaultConfig?: AxiosRequestConfig) => (options?: WrapOptions, requestConfig?: AxiosRequestConfig) => Promise<axios.AxiosResponse<T, any, {}>>;
538
553
  group: <T extends readonly (ModelRequest<unknown> | DataRequest<unknown>)[]>(...proms: T) => Promise<{ [K in keyof T]: Awaited<T[K]>; }>;
539
554
  }>;
540
555
 
556
+ declare enum CustomHeaders {
557
+ TotalCount = "wtt-total-count",
558
+ ReturnedCount = "wtt-returned-count",
559
+ Page = "wtt-page",
560
+ PageSize = "wtt-page-size",
561
+ TotalPages = "wtt-total-pages",
562
+ HasNextPage = "wtt-has-next-page",
563
+ HasPreviousPage = "wtt-has-previous-page"
564
+ }
565
+
541
566
  declare function replaceItemById<T extends {
542
567
  _id: string;
543
- }>(items: T[], newItem: T, options?: {
568
+ }>(items: T[], targetItem: T, options?: {
544
569
  merge: boolean;
545
570
  }): T[];
546
571
  declare function removeItemById<T extends {
547
572
  _id: string;
548
- }>(items: T[], newItem: T): T[];
573
+ }>(items: T[], targetItem: T): T[];
549
574
 
550
575
  declare const _default: {
551
576
  createAdapter: typeof createAdapter;
552
577
  };
553
578
 
554
- export { type ArrayDataResponse, type ArrayModelResponse, type DataPromiseMeta, type DataRequest, type DataResponse, DataService, type Document, type FilterQuery, type Include, type KeyValueProjection, type LazyRequest, type ListDataResponse, type ListModelResponse, Model, type ModelPromiseMeta, type ModelRequest, type ModelResponse, ModelService, type Populate, type PopulateAccess, type Projection, type ResolvedSelectedShape, type Response, type ResponseCallback, type ResultError, type RootDataQueryMeta, type RootModelQueryMeta, type RootQueryMeta, type SelectedKeys, type SelectedShape, Service, ServiceError, type Sort, type SortOrder, type SubQueryMeta, type Task, type WrapOptions, createAdapter, _default as default, removeItemById, replaceItemById, wrapLazyPromise };
579
+ export { type AdditionalReqConfig, type ArrayDataResponse, type ArrayModelResponse, type CreateAdvancedArgs, type CreateAdvancedOptions, type CreateOptions, CustomHeaders, type DataDefaults, type DataListAdvancedArgs, type DataListAdvancedOptions, type DataListArgs, type DataListOptions, type DataPromiseMeta, type DataReadAdvancedArgs, type DataReadAdvancedOptions, type DataReadOptions, type DataRequest, type DataResponse, DataService, type Defaults, type Document, type FilterQuery, type Include, type KeyValueProjection, type LazyRequest, type ListAdvancedArgs, type ListAdvancedOptions, type ListArgs, type ListDataResponse, type ListModelResponse, type ListOptions, Model, type ModelPromiseMeta, type ModelRequest, type ModelResponse, ModelService, type Populate, type PopulateAccess, type Projection, type ReadAdvancedArgs, type ReadAdvancedOptions, type ReadOptions, type ResolvedSelectedShape, type Response, type ResponseCallback, type ResultError, type RootDataQueryMeta, type RootModelQueryMeta, type RootQueryMeta, type SelectedKeys, type SelectedShape, Service, ServiceError, type Sort, type SortOrder, type SubQueryOptions, type Task, type UpdateAdvancedArgs, type UpdateAdvancedOptions, type UpdateOptions, type UpsertAdvancedArgs, type UpsertAdvancedOptions, type UpsertOptions, type WrapOptions, createAdapter, _default as default, removeItemById, replaceItemById, wrapLazyPromise };