@ethlete/query 5.44.0 → 5.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/fesm2022/ethlete-query.mjs +5292 -6170
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/package.json +16 -10
- package/types/ethlete-query.d.ts +3302 -0
- package/index.d.ts +0 -3614
|
@@ -0,0 +1,3302 @@
|
|
|
1
|
+
import { BehaviorSubject, Observable, Subscribable } from "rxjs";
|
|
2
|
+
import { ContentfulGqlLikePaginated, DynLikePaginated, FormViolationListView, FormViolationView, GgLikePaginated, NormalizedPagination, Paginated } from "@ethlete/types";
|
|
3
|
+
import { HttpClient, HttpContext, HttpErrorResponse, HttpEvent, HttpHeaders, HttpStatusCode } from "@angular/common/http";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { CreateComputedOptions, CreateEffectOptions, DestroyRef, EffectRef, EnvironmentInjector, ErrorHandler, InjectionToken, Injector, OnDestroy, OnInit, PipeTransform, Signal, TrackByFunction, WritableSignal, ɵEffectScheduler } from "@angular/core";
|
|
6
|
+
import * as i1 from "@ethlete/core";
|
|
7
|
+
import { RuntimeError } from "@ethlete/core";
|
|
8
|
+
import { ToObservableOptions, ToSignalOptions } from "@angular/core/rxjs-interop";
|
|
9
|
+
import { FormControl, FormGroup } from "@angular/forms";
|
|
10
|
+
export type EntityKey = string | number;
|
|
11
|
+
export interface EntityStoreConfig {
|
|
12
|
+
name: string;
|
|
13
|
+
logActions?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface InsertFromConfig<OriginStoreType, OriginKeys extends keyof NonNullable<OriginStoreType>, IdFn extends (value: NonNullable<OriginStoreType>) => EntityKey | EntityKey[]> {
|
|
16
|
+
/**
|
|
17
|
+
* The property key of which the value should be replaced.
|
|
18
|
+
*/
|
|
19
|
+
for: OriginKeys;
|
|
20
|
+
/**
|
|
21
|
+
* A function that returns the id of the entity. Can also return an array of ids.
|
|
22
|
+
*/
|
|
23
|
+
id: IdFn;
|
|
24
|
+
}
|
|
25
|
+
export interface RemoveFromConfig<T> {
|
|
26
|
+
/**
|
|
27
|
+
* The where function to select the entities to remove.
|
|
28
|
+
*/
|
|
29
|
+
where: (entity: T) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A function that returns the id of the entity.
|
|
32
|
+
*/
|
|
33
|
+
id: (entity: T) => EntityKey;
|
|
34
|
+
}
|
|
35
|
+
export declare class EntityStore<T> {
|
|
36
|
+
private readonly _config;
|
|
37
|
+
constructor(_config: EntityStoreConfig);
|
|
38
|
+
select(key: EntityKey): Observable<T | null>;
|
|
39
|
+
select(keys: EntityKey[]): Observable<T[]>;
|
|
40
|
+
select(keys: EntityKey[][]): Observable<T[]>;
|
|
41
|
+
/**
|
|
42
|
+
* **Note:** Prefer `select` over `selectWhere` when possible.
|
|
43
|
+
*/
|
|
44
|
+
selectWhere(predicate: (value: T) => boolean): Observable<T[]>;
|
|
45
|
+
set(key: EntityKey, value: T): void;
|
|
46
|
+
set(keys: EntityKey[], values: T[]): void;
|
|
47
|
+
set(keys: EntityKey[][], values: T[][]): void;
|
|
48
|
+
remove(key: EntityKey): void;
|
|
49
|
+
remove(keys: EntityKey[]): void;
|
|
50
|
+
remove(keys: EntityKey[][]): void;
|
|
51
|
+
logState(): void;
|
|
52
|
+
private _select;
|
|
53
|
+
private _selectMany;
|
|
54
|
+
private _set;
|
|
55
|
+
private _remove;
|
|
56
|
+
private _normalizeKeys;
|
|
57
|
+
}
|
|
58
|
+
export declare function mapToPaginated<T>(response: Paginated<T>): import("rxjs").OperatorFunction<unknown, Paginated<T>>;
|
|
59
|
+
/**
|
|
60
|
+
* Use an other store to represent a property of the current entity.
|
|
61
|
+
*/
|
|
62
|
+
export declare const insertFrom: <OriginStoreType, OriginKeys extends keyof NonNullable<OriginStoreType>, SubStoreType extends NonNullable<OriginStoreType>[OriginKeys] extends Array<infer U> ? U : NonNullable<OriginStoreType>[OriginKeys], IdFn extends (value: NonNullable<OriginStoreType>) => EntityKey | EntityKey[], ComputedEntityType extends ReturnType<IdFn> extends Array<unknown> ? OriginStoreType : Omit<OriginStoreType, OriginKeys> & { [K in OriginKeys]: SubStoreType | null; }>(store: EntityStore<SubStoreType>, { for: key, id }: InsertFromConfig<OriginStoreType, OriginKeys, IdFn>) => import("rxjs").OperatorFunction<OriginStoreType, ComputedEntityType | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Remove entities from a store based on a where function.
|
|
65
|
+
*/
|
|
66
|
+
export declare const removeFrom: <T>(store: EntityStore<T>, { where, id }: RemoveFromConfig<T>) => void;
|
|
67
|
+
export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PURGE' | 'LINK' | 'UNLINK' | 'GQL_QUERY' | 'GQL_MUTATE' | 'CUSTOM';
|
|
68
|
+
export interface RequestError<Detail = unknown> {
|
|
69
|
+
url: string;
|
|
70
|
+
status: HttpStatusCode;
|
|
71
|
+
statusText: string;
|
|
72
|
+
detail: Detail;
|
|
73
|
+
httpErrorResponse: HttpErrorResponse;
|
|
74
|
+
}
|
|
75
|
+
export type RequestHeaders = Record<string, string>;
|
|
76
|
+
export type QueryParams = object;
|
|
77
|
+
export type PathParams = Record<string, string | number>;
|
|
78
|
+
export type CacheAdapterFn = (headers: RequestHeaders) => number | null;
|
|
79
|
+
export type RequestHeadersMethodMap = { [M in Method]?: RequestHeaders; };
|
|
80
|
+
export interface PartialXhrState {
|
|
81
|
+
headers: RequestHeaders;
|
|
82
|
+
status: number;
|
|
83
|
+
statusText: string;
|
|
84
|
+
url: string;
|
|
85
|
+
}
|
|
86
|
+
export interface RequestRetryFnConfig {
|
|
87
|
+
error: RequestError;
|
|
88
|
+
headers: RequestHeaders;
|
|
89
|
+
currentRetryCount: number;
|
|
90
|
+
}
|
|
91
|
+
export interface RequestRetryFnResult {
|
|
92
|
+
retry: boolean;
|
|
93
|
+
delay?: number;
|
|
94
|
+
}
|
|
95
|
+
export type RequestRetryFn = (config: RequestRetryFnConfig) => RequestRetryFnResult;
|
|
96
|
+
export interface RequestConfig {
|
|
97
|
+
method: Method;
|
|
98
|
+
urlWithParams: string;
|
|
99
|
+
body?: unknown;
|
|
100
|
+
reportProgress?: boolean;
|
|
101
|
+
withCredentials?: boolean;
|
|
102
|
+
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
|
103
|
+
headers?: RequestHeaders;
|
|
104
|
+
cacheAdapter?: CacheAdapterFn;
|
|
105
|
+
retryFn?: RequestRetryFn;
|
|
106
|
+
}
|
|
107
|
+
export type RequestProgress = {
|
|
108
|
+
current: number;
|
|
109
|
+
percentage?: number;
|
|
110
|
+
total?: number;
|
|
111
|
+
};
|
|
112
|
+
export type RequestEvent<Response = unknown> = {
|
|
113
|
+
type: 'start';
|
|
114
|
+
headers: RequestHeaders;
|
|
115
|
+
isRetry?: boolean;
|
|
116
|
+
retryNumber?: number;
|
|
117
|
+
retryDelay?: number;
|
|
118
|
+
} | {
|
|
119
|
+
type: 'delay-retry';
|
|
120
|
+
headers: RequestHeaders;
|
|
121
|
+
retryNumber: number;
|
|
122
|
+
retryDelay: number;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'download-progress';
|
|
125
|
+
headers: RequestHeaders;
|
|
126
|
+
progress: RequestProgress;
|
|
127
|
+
partialText?: string;
|
|
128
|
+
} | {
|
|
129
|
+
type: 'upload-progress';
|
|
130
|
+
headers: RequestHeaders;
|
|
131
|
+
progress: RequestProgress;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'success';
|
|
134
|
+
headers: RequestHeaders;
|
|
135
|
+
response: Response;
|
|
136
|
+
expiresInTimestamp?: number;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'failure';
|
|
139
|
+
headers: RequestHeaders;
|
|
140
|
+
error: RequestError;
|
|
141
|
+
} | {
|
|
142
|
+
type: 'cancel';
|
|
143
|
+
headers: RequestHeaders;
|
|
144
|
+
};
|
|
145
|
+
export interface BuildQueryStringConfig {
|
|
146
|
+
/**
|
|
147
|
+
* Object notation to use for nested objects.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // dot notation
|
|
151
|
+
* { foo: { bar: 'baz' } } => "foo.bar=baz"
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* // bracket notation
|
|
155
|
+
* { foo: { bar: 'baz' } } => "foo[bar]=baz"
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* // json-stringify notation
|
|
159
|
+
* { foo: { bar: 'baz' } } => "foo={\"bar\":\"baz\"}"
|
|
160
|
+
*
|
|
161
|
+
* @default 'bracket'
|
|
162
|
+
*/
|
|
163
|
+
objectNotation?: 'dot' | 'bracket' | 'json-stringify';
|
|
164
|
+
/**
|
|
165
|
+
* Whether to write array indexes in bracket notation.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // true
|
|
169
|
+
* { foo: ['bar', 'baz'] } => "foo[0]=bar&foo[1]=baz"
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* // false
|
|
173
|
+
* { foo: ['bar', 'baz'] } => "foo[]=bar&foo[]=baz"
|
|
174
|
+
*
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
writeArrayIndexes?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* A list of values that should be ignored when building the query string.
|
|
180
|
+
*
|
|
181
|
+
* Also have a look at `ignoredValuesFns`.
|
|
182
|
+
*
|
|
183
|
+
* @default [undefined, null, Infinity, -Infinity]
|
|
184
|
+
*/
|
|
185
|
+
ignoredValues?: Array<unknown>;
|
|
186
|
+
/**
|
|
187
|
+
* A list of functions that should be used to determine whether a value should be ignored when building the query string.
|
|
188
|
+
*
|
|
189
|
+
* Also have a look at `ignoredValues`.
|
|
190
|
+
*
|
|
191
|
+
* @default [isNaN, isEmptyString]
|
|
192
|
+
*/
|
|
193
|
+
ignoredValuesFns?: Array<(value: unknown) => boolean>;
|
|
194
|
+
}
|
|
195
|
+
export declare const request: <Response = unknown>(config: RequestConfig) => Observable<RequestEvent<Response>>;
|
|
196
|
+
export declare const isNaN: (value: unknown) => boolean;
|
|
197
|
+
export declare const isEmptyString: (value: unknown) => boolean;
|
|
198
|
+
export declare const isRequestError: <T = unknown>(error: unknown) => error is RequestError<T>;
|
|
199
|
+
export declare const buildRoute: (options: {
|
|
200
|
+
base: string;
|
|
201
|
+
route: AnyRoute | null | undefined;
|
|
202
|
+
pathParams?: PathParams;
|
|
203
|
+
queryParams?: QueryParams;
|
|
204
|
+
queryParamConfig?: BuildQueryStringConfig;
|
|
205
|
+
}) => string;
|
|
206
|
+
export declare const buildQueryString: (params: QueryParams, config?: BuildQueryStringConfig) => string | null;
|
|
207
|
+
export declare const extractExpiresInSeconds: (headers: RequestHeaders) => number | null;
|
|
208
|
+
export declare const buildTimestampFromSeconds: (seconds: number | null) => number | null;
|
|
209
|
+
export declare const serializeBody: (body: unknown) => ArrayBuffer | URLSearchParams | Blob | FormData | string | null;
|
|
210
|
+
export declare const transformMethod: (config: {
|
|
211
|
+
method: Method;
|
|
212
|
+
transferVia?: "GET" | "POST";
|
|
213
|
+
}) => "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT" | "PURGE" | "LINK" | "UNLINK" | "CUSTOM";
|
|
214
|
+
export declare const detectContentTypeHeader: (body: unknown) => string | null;
|
|
215
|
+
export declare const hasHeader: (headers: RequestHeaders, header: string) => boolean;
|
|
216
|
+
export declare const forEachHeader: (headers: RequestHeaders, callback: (value: string, key: string) => void) => void;
|
|
217
|
+
export declare const parseAllXhrResponseHeaders: (xhr: XMLHttpRequest) => RequestHeaders;
|
|
218
|
+
export declare const getResponseUrl: (xhr: XMLHttpRequest) => string | null;
|
|
219
|
+
export declare const shouldRetryRequest: RequestRetryFn;
|
|
220
|
+
type SetupQueryDependenciesOptions = {
|
|
221
|
+
clientConfig: QueryClientConfig$1;
|
|
222
|
+
queryConfig: QueryConfig$1 | undefined;
|
|
223
|
+
};
|
|
224
|
+
type QueryDependencies = {
|
|
225
|
+
/** The destroy ref of the query. */
|
|
226
|
+
destroyRef: DestroyRef;
|
|
227
|
+
/** The destroy ref of the scope the query is in (e.g. a component) */
|
|
228
|
+
scopeDestroyRef: DestroyRef;
|
|
229
|
+
/** The query client */
|
|
230
|
+
client: QueryClient$1;
|
|
231
|
+
/** The injector of the query */
|
|
232
|
+
injector: EnvironmentInjector;
|
|
233
|
+
/** The effect scheduler */
|
|
234
|
+
effectScheduler: ɵEffectScheduler;
|
|
235
|
+
/** The error handler */
|
|
236
|
+
ngErrorHandler: ErrorHandler;
|
|
237
|
+
/** The http client */
|
|
238
|
+
httpClient: HttpClient;
|
|
239
|
+
};
|
|
240
|
+
declare const setupQueryDependencies: (options: SetupQueryDependenciesOptions) => QueryDependencies;
|
|
241
|
+
type CreateGqlQueryCreatorOptions<TArgs extends GqlQueryArgs> = Omit<CreateQueryCreatorOptions, 'route'> & {
|
|
242
|
+
route?: RouteType$1<TArgs>;
|
|
243
|
+
};
|
|
244
|
+
type GqlQueryMethod = 'QUERY' | 'MUTATE';
|
|
245
|
+
type GqlQueryTransport = 'GET' | 'POST';
|
|
246
|
+
type InternalCreateGqlQueryCreatorOptions = {
|
|
247
|
+
method: GqlQueryMethod;
|
|
248
|
+
transport: GqlQueryTransport;
|
|
249
|
+
client: QueryClientConfig$1;
|
|
250
|
+
query: string;
|
|
251
|
+
};
|
|
252
|
+
declare const createGqlQueryCreator: <TArgs extends GqlQueryArgs>(options: CreateGqlQueryCreatorOptions<TArgs> | undefined, internals: InternalCreateGqlQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
253
|
+
type GqlQueryArgs = QueryArgs & {
|
|
254
|
+
variables?: Record<string, unknown>;
|
|
255
|
+
};
|
|
256
|
+
type CreateGqlQueryOptions<TArgs extends GqlQueryArgs> = Omit<CreateQueryOptions<TArgs>, 'creator' | 'creatorInternals'> & {
|
|
257
|
+
creator?: CreateGqlQueryCreatorOptions<TArgs>;
|
|
258
|
+
creatorInternals: InternalCreateGqlQueryCreatorOptions;
|
|
259
|
+
};
|
|
260
|
+
type GqlVariablesType<T extends GqlQueryArgs | null> = T extends GqlQueryArgs ? T['variables'] : never;
|
|
261
|
+
declare const isCreateGqlQueryOptions: <TArgs extends QueryArgs>(options: CreateQueryOptions<TArgs> | CreateGqlQueryOptions<TArgs>) => options is CreateGqlQueryOptions<TArgs>;
|
|
262
|
+
declare const createGqlQuery: <TArgs extends GqlQueryArgs>(options: CreateGqlQueryOptions<TArgs>) => Query$1<TArgs>;
|
|
263
|
+
declare const QueryFeatureType: {
|
|
264
|
+
readonly WITH_ARGS: "WITH_ARGS";
|
|
265
|
+
readonly WITH_LOGGING: "WITH_LOGGING";
|
|
266
|
+
readonly WITH_ERROR_HANDLING: "WITH_ERROR_HANDLING";
|
|
267
|
+
readonly WITH_SUCCESS_HANDLING: "WITH_SUCCESS_HANDLING";
|
|
268
|
+
readonly WITH_POLLING: "WITH_POLLING";
|
|
269
|
+
readonly WITH_AUTO_REFRESH: "WITH_AUTO_REFRESH";
|
|
270
|
+
readonly WITH_RESPONSE_UPDATE: "WITH_RESPONSE_UPDATE";
|
|
271
|
+
};
|
|
272
|
+
type QueryFeatureType = (typeof QueryFeatureType)[keyof typeof QueryFeatureType];
|
|
273
|
+
type QueryFeatureContext<TArgs extends QueryArgs> = {
|
|
274
|
+
state: QueryState$1<TArgs>;
|
|
275
|
+
execute: InternalQueryExecute<TArgs>;
|
|
276
|
+
deps: QueryDependencies;
|
|
277
|
+
flags: QueryFeatureFlags;
|
|
278
|
+
};
|
|
279
|
+
type QueryFeatureFn<TArgs extends QueryArgs> = (context: QueryFeatureContext<TArgs>) => void;
|
|
280
|
+
type QueryFeature<TArgs extends QueryArgs> = {
|
|
281
|
+
type: QueryFeatureType;
|
|
282
|
+
fn: (context: QueryFeatureContext<TArgs>) => void;
|
|
283
|
+
};
|
|
284
|
+
declare const createQueryFeature: <TArgs extends QueryArgs>(config: {
|
|
285
|
+
type: QueryFeatureType;
|
|
286
|
+
fn: QueryFeatureFn<TArgs>;
|
|
287
|
+
}) => QueryFeature<TArgs>;
|
|
288
|
+
/**
|
|
289
|
+
* A query feature that allows you to set the arguments of the query.
|
|
290
|
+
* The arguments are read within a computed function, so you can use reactive values.
|
|
291
|
+
*
|
|
292
|
+
* To set the arguments to `null`, return the symbol `CLEAR_QUERY_ARGS`.
|
|
293
|
+
* If you instead return `null`, the arguments won't change.
|
|
294
|
+
*
|
|
295
|
+
* Changing arguments will automatically trigger a new execution of the query if it is eligible for auto execution (e.g. a GET request).
|
|
296
|
+
*/
|
|
297
|
+
declare const withArgs: <TArgs extends QueryArgs>(args: () => NoInfer<RequestArgs<TArgs>> | ClearQueryArgs | null) => QueryFeature<TArgs>;
|
|
298
|
+
type WithPollingFeatureOptions = {
|
|
299
|
+
/** The interval in milliseconds at which the query should be executed */
|
|
300
|
+
interval: number;
|
|
301
|
+
/**
|
|
302
|
+
* Whether the query should be executed initially.
|
|
303
|
+
* By default, the query will be executed after the first interval.
|
|
304
|
+
* @default false
|
|
305
|
+
*/
|
|
306
|
+
executeInitially?: boolean;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* A query feature that will automatically execute the query at a given interval.
|
|
310
|
+
* The interval will be cleared when the query is destroyed.
|
|
311
|
+
* The interval will be reset when the arguments of the query change.
|
|
312
|
+
*
|
|
313
|
+
* @throws If the query is not eligible for auto execution (e.g. a POST request)
|
|
314
|
+
*/
|
|
315
|
+
declare const withPolling: <TArgs extends QueryArgs>(options: WithPollingFeatureOptions) => QueryFeature<TArgs>;
|
|
316
|
+
type WithLoggingFeatureOptions<TArgs extends QueryArgs> = {
|
|
317
|
+
/** A function that will be called with the latest http event */
|
|
318
|
+
logFn: (v: HttpEvent<ResponseType<TArgs>> | null) => void;
|
|
319
|
+
};
|
|
320
|
+
/** A query feature that can be used to log the latest http event */
|
|
321
|
+
declare const withLogging: <TArgs extends QueryArgs>(options: WithLoggingFeatureOptions<TArgs>) => QueryFeature<TArgs>;
|
|
322
|
+
type WithErrorHandlingFeatureOptions = {
|
|
323
|
+
/** A function that will be called with the latest error */
|
|
324
|
+
handler: (e: QueryErrorResponse) => void;
|
|
325
|
+
};
|
|
326
|
+
/** A query feature that can be used to handle errors */
|
|
327
|
+
declare const withErrorHandling: <TArgs extends QueryArgs>(options: WithErrorHandlingFeatureOptions) => QueryFeature<TArgs>;
|
|
328
|
+
type WithSuccessHandlingFeatureOptions<TArgs extends QueryArgs> = {
|
|
329
|
+
/** A function that will be called with the latest response */
|
|
330
|
+
handler: (data: NonNullable<ResponseType<TArgs>>) => void;
|
|
331
|
+
};
|
|
332
|
+
/** A query feature that can be used to handle successful responses */
|
|
333
|
+
declare const withSuccessHandling: <TArgs extends QueryArgs>(options: WithSuccessHandlingFeatureOptions<TArgs>) => QueryFeature<TArgs>;
|
|
334
|
+
type WithAutoRefreshFeatureOptions = {
|
|
335
|
+
/** The signals that should trigger a refresh of the query */
|
|
336
|
+
onSignalChanges: Signal<unknown>[];
|
|
337
|
+
/** Whether to ignore the `onlyManualExecution` query config flag */
|
|
338
|
+
ignoreOnlyManualExecution?: boolean;
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* A query feature that will automatically execute the query when any of the provided signals change
|
|
342
|
+
* @throws If the query is not eligible for auto execution (e.g. a POST request)
|
|
343
|
+
* @throws If the query has the `onlyManualExecution` query config flag set and `ignoreOnlyManualExecution` is not set
|
|
344
|
+
*/
|
|
345
|
+
declare const withAutoRefresh: <TArgs extends QueryArgs>(options: WithAutoRefreshFeatureOptions) => QueryFeature<TArgs>;
|
|
346
|
+
type WithResponseUpdateFeatureFnData<TArgs extends QueryArgs> = {
|
|
347
|
+
/** The current response of the query */
|
|
348
|
+
currentResponse: ResponseType<TArgs> | null;
|
|
349
|
+
};
|
|
350
|
+
type WithResponseUpdateFeatureOptions<TArgs extends QueryArgs> = {
|
|
351
|
+
/**
|
|
352
|
+
* A function that will be called with the latest response
|
|
353
|
+
* If the function returns `null`, the response will not be updated.
|
|
354
|
+
* Otherwise, the response will be updated with the returned value.
|
|
355
|
+
* The function will be called in a reactive signal context.
|
|
356
|
+
* If the query get's executed after the response was updated, the response will be set the the fresh data received from the server.
|
|
357
|
+
*
|
|
358
|
+
* This feature is most useful in combination with web sockets where the data received from the socket might be more up-to-date than the data received previously.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* const matchEvents = mySocket.joinRoom('match-events');
|
|
362
|
+
*
|
|
363
|
+
* const myMatchQuery = getMatch(
|
|
364
|
+
* withArgs(() => ({ matchId: 1 })),
|
|
365
|
+
* withResponseUpdate(({ currentResponse }) => {
|
|
366
|
+
* const matchEvent = matchEvents();
|
|
367
|
+
*
|
|
368
|
+
* if (!matchEvent) return null;
|
|
369
|
+
*
|
|
370
|
+
* // Do some checks here. This is just a very simple example.
|
|
371
|
+
* // To apply partial updates, you can use the spread operator in combination with the current response.
|
|
372
|
+
*
|
|
373
|
+
* return matchEvent;
|
|
374
|
+
* })
|
|
375
|
+
* )
|
|
376
|
+
*/
|
|
377
|
+
updater: (data: WithResponseUpdateFeatureFnData<TArgs>) => ResponseType<TArgs> | null;
|
|
378
|
+
};
|
|
379
|
+
declare const withResponseUpdate: <TArgs extends QueryArgs>(options: WithResponseUpdateFeatureOptions<TArgs>) => QueryFeature<TArgs>;
|
|
380
|
+
/**
|
|
381
|
+
* Returning this inside a withArgs feature will reset the query args to null.
|
|
382
|
+
* This will also pause polling and auto refresh until new args are set.
|
|
383
|
+
*/
|
|
384
|
+
declare const CLEAR_QUERY_ARGS: unique symbol;
|
|
385
|
+
type ClearQueryArgs = typeof CLEAR_QUERY_ARGS;
|
|
386
|
+
/** A angular effect that can be nested inside another effect */
|
|
387
|
+
declare const nestedEffect: (fn: () => void, options?: CreateEffectOptions) => import("@angular/core").EffectRef;
|
|
388
|
+
declare const circularQueryDependencyChecker: () => {
|
|
389
|
+
check: () => void;
|
|
390
|
+
};
|
|
391
|
+
declare const shouldAutoExecuteQuery: (method: QueryMethod) => method is "GET" | "HEAD" | "OPTIONS";
|
|
392
|
+
declare const shouldAutoExecuteGqlQuery: (method: GqlQueryMethod) => method is "QUERY";
|
|
393
|
+
declare const extractExpiresInSeconds$1: (headers: HttpHeaders) => number | null;
|
|
394
|
+
type ShouldRetryRequestOptions = {
|
|
395
|
+
retryCount: number;
|
|
396
|
+
error: HttpErrorResponse;
|
|
397
|
+
};
|
|
398
|
+
type ShouldRetryRequestResult = {
|
|
399
|
+
retry: false;
|
|
400
|
+
} | {
|
|
401
|
+
retry: true;
|
|
402
|
+
delay: number;
|
|
403
|
+
};
|
|
404
|
+
type ShouldRetryRequestFn = (options: ShouldRetryRequestOptions) => ShouldRetryRequestResult;
|
|
405
|
+
declare const shouldRetryRequest$1: (options: ShouldRetryRequestOptions | HttpErrorResponse) => ShouldRetryRequestResult;
|
|
406
|
+
type QueryFeatureFlags = {
|
|
407
|
+
hasWithArgsFeature: boolean;
|
|
408
|
+
shouldAutoExecuteMethod: boolean;
|
|
409
|
+
shouldAutoExecute: boolean;
|
|
410
|
+
hasRouteFunction: boolean;
|
|
411
|
+
onlyManualExecution?: boolean;
|
|
412
|
+
/** Human readable method name */
|
|
413
|
+
method: string;
|
|
414
|
+
};
|
|
415
|
+
declare const getQueryFeatureUsage: <TArgs extends QueryArgs>(options: CreateQueryOptions<TArgs> | CreateGqlQueryOptions<TArgs>) => QueryFeatureFlags;
|
|
416
|
+
declare const applyQueryFeatures: <TArgs extends QueryArgs>(features: QueryFeature<TArgs>[], context: QueryFeatureContext<TArgs>) => void;
|
|
417
|
+
declare const maybeExecute: (options: {
|
|
418
|
+
flags: QueryFeatureFlags;
|
|
419
|
+
execute: InternalQueryExecute<any>;
|
|
420
|
+
}) => void;
|
|
421
|
+
type CreateQueryObjectOptions<TArgs extends QueryArgs> = {
|
|
422
|
+
state: QueryState$1<TArgs>;
|
|
423
|
+
deps: QueryDependencies;
|
|
424
|
+
execute: InternalQueryExecute<TArgs>;
|
|
425
|
+
};
|
|
426
|
+
declare const createQueryObject: <TArgs extends QueryArgs>(options: CreateQueryObjectOptions<TArgs>) => Query$1<TArgs>;
|
|
427
|
+
declare const normalizeQueryRepositoryKey: (key: Signal<QueryKeyOrNone>) => Signal<string>;
|
|
428
|
+
declare const shouldCacheQuery$1: (method: QueryMethod) => method is "GET" | "HEAD" | "OPTIONS";
|
|
429
|
+
declare const buildQueryCacheKey$1: (route: string, args: RequestArgs<QueryArgs> | undefined) => string;
|
|
430
|
+
type QueryErrorResponseList = {
|
|
431
|
+
isList: true;
|
|
432
|
+
errors: QueryErrorResponseItem[];
|
|
433
|
+
};
|
|
434
|
+
type QueryErrorResponseSingle = {
|
|
435
|
+
isList: false;
|
|
436
|
+
error: QueryErrorResponseItem;
|
|
437
|
+
};
|
|
438
|
+
type QueryErrorResponse = {
|
|
439
|
+
raw: HttpErrorResponse;
|
|
440
|
+
retryState: ShouldRetryRequestResult;
|
|
441
|
+
code: HttpStatusCode;
|
|
442
|
+
} & (QueryErrorResponseList | QueryErrorResponseSingle);
|
|
443
|
+
type QueryErrorResponseItem = {
|
|
444
|
+
message: string;
|
|
445
|
+
};
|
|
446
|
+
declare const createQueryErrorResponse: (error: unknown) => QueryErrorResponse;
|
|
447
|
+
type SetupQueryStateOptions = {};
|
|
448
|
+
type QueryStateSubtle<TArgs extends QueryArgs> = {
|
|
449
|
+
request: WritableSignal<HttpRequest<TArgs> | null>;
|
|
450
|
+
};
|
|
451
|
+
type QueryState$1<TArgs extends QueryArgs> = {
|
|
452
|
+
response: WritableSignal<ResponseType<TArgs> | null>;
|
|
453
|
+
args: WritableSignal<RequestArgs<TArgs> | null>;
|
|
454
|
+
latestHttpEvent: WritableSignal<HttpEvent<ResponseType<TArgs>> | null>;
|
|
455
|
+
loading: WritableSignal<HttpRequestLoadingState | null>;
|
|
456
|
+
error: WritableSignal<QueryErrorResponse | null>;
|
|
457
|
+
lastTimeExecutedAt: WritableSignal<number | null>;
|
|
458
|
+
executionState: Signal<QueryExecutionState<TArgs> | null>;
|
|
459
|
+
subtle: QueryStateSubtle<TArgs>;
|
|
460
|
+
};
|
|
461
|
+
type QueryExecutionStateSuccess<TArgs extends QueryArgs> = {
|
|
462
|
+
type: 'success';
|
|
463
|
+
response: ResponseType<TArgs>;
|
|
464
|
+
};
|
|
465
|
+
type QueryExecutionStateFailure = {
|
|
466
|
+
type: 'failure';
|
|
467
|
+
error: QueryErrorResponse;
|
|
468
|
+
};
|
|
469
|
+
type QueryExecutionStateLoadingWithNoResponse = {
|
|
470
|
+
type: 'loading';
|
|
471
|
+
hasCachedResponse: false;
|
|
472
|
+
loading: HttpRequestLoadingState;
|
|
473
|
+
};
|
|
474
|
+
type QueryExecutionStateLoadingWithCachedResponse<TArgs extends QueryArgs> = {
|
|
475
|
+
type: 'loading';
|
|
476
|
+
hasCachedResponse: true;
|
|
477
|
+
loading: HttpRequestLoadingState;
|
|
478
|
+
cachedResponse: ResponseType<TArgs>;
|
|
479
|
+
};
|
|
480
|
+
type QueryExecutionStateLoading<TArgs extends QueryArgs> = QueryExecutionStateLoadingWithNoResponse | QueryExecutionStateLoadingWithCachedResponse<TArgs>;
|
|
481
|
+
type QueryExecutionState<TArgs extends QueryArgs> = QueryExecutionStateSuccess<TArgs> | QueryExecutionStateFailure | QueryExecutionStateLoading<TArgs>;
|
|
482
|
+
declare const setupQueryState: <TArgs extends QueryArgs>(options: SetupQueryStateOptions) => QueryState$1<TArgs>;
|
|
483
|
+
type CreateQueryExecuteOptions<TArgs extends QueryArgs> = {
|
|
484
|
+
deps: QueryDependencies;
|
|
485
|
+
state: QueryState$1<TArgs>;
|
|
486
|
+
creator?: CreateQueryCreatorOptions;
|
|
487
|
+
creatorInternals: InternalCreateQueryCreatorOptions<TArgs>;
|
|
488
|
+
queryConfig: QueryConfig$1;
|
|
489
|
+
};
|
|
490
|
+
type QueryExecuteArgs<TArgs extends QueryArgs> = {
|
|
491
|
+
args?: RequestArgs<TArgs> | null;
|
|
492
|
+
options?: RunQueryExecuteOptions;
|
|
493
|
+
};
|
|
494
|
+
type InternalQueryExecute<TArgs extends QueryArgs> = {
|
|
495
|
+
(executeArgs?: QueryExecuteArgs<TArgs>): void;
|
|
496
|
+
reset: () => void;
|
|
497
|
+
currentRepositoryKey: Signal<QueryKeyOrNone>;
|
|
498
|
+
};
|
|
499
|
+
type QueryExecute<TArgs extends QueryArgs> = (executeArgs?: QueryExecuteArgs<TArgs>) => void;
|
|
500
|
+
declare const createExecuteFn: <TArgs extends QueryArgs>(executeOptions: CreateQueryExecuteOptions<TArgs>) => InternalQueryExecute<TArgs>;
|
|
501
|
+
type ResetExecuteStateOptions<TArgs extends QueryArgs> = {
|
|
502
|
+
executeOptions: Pick<CreateQueryExecuteOptions<TArgs>, 'state' | 'deps'>;
|
|
503
|
+
executeState: QueryExecuteState;
|
|
504
|
+
};
|
|
505
|
+
declare const resetExecuteState: <TArgs extends QueryArgs>(options: ResetExecuteStateOptions<TArgs>) => void;
|
|
506
|
+
type QueryExecuteState = {
|
|
507
|
+
effectRefs: EffectRef[];
|
|
508
|
+
previousKey: WritableSignal<string | false>;
|
|
509
|
+
};
|
|
510
|
+
declare const setupQueryExecuteState: () => QueryExecuteState;
|
|
511
|
+
type RunQueryExecuteOptions = {
|
|
512
|
+
allowCache?: boolean;
|
|
513
|
+
};
|
|
514
|
+
type InternalRunQueryExecuteOptions = {
|
|
515
|
+
/**
|
|
516
|
+
* If true, the request will be forced to be cached (saved inside the query repository).
|
|
517
|
+
* Can be used to e.g. cache GQL queries transported via POST
|
|
518
|
+
*
|
|
519
|
+
* - `true` means the request will always be cached
|
|
520
|
+
* - `false` means the request will never be cached
|
|
521
|
+
* - `undefined` means the request will be cached if the method is GET, OPTIONS or HEAD
|
|
522
|
+
*/
|
|
523
|
+
useQueryRepositoryCache?: boolean;
|
|
524
|
+
};
|
|
525
|
+
type QueryExecuteOptions<TArgs extends QueryArgs> = {
|
|
526
|
+
executeOptions: CreateQueryExecuteOptions<TArgs>;
|
|
527
|
+
executeState: QueryExecuteState;
|
|
528
|
+
args: RequestArgs<TArgs> | null;
|
|
529
|
+
options?: RunQueryExecuteOptions;
|
|
530
|
+
internalOptions?: InternalRunQueryExecuteOptions;
|
|
531
|
+
transformResponse?: (response: any) => any;
|
|
532
|
+
isSecure?: boolean;
|
|
533
|
+
};
|
|
534
|
+
declare const bindSignalToTarget: <T>(signal: Signal<T>, target: WritableSignal<T>) => EffectRef;
|
|
535
|
+
declare const queryExecute: <TArgs extends QueryArgs>(options: QueryExecuteOptions<TArgs>) => void;
|
|
536
|
+
type CleanupPreviousExecuteOptions<TArgs extends QueryArgs> = {
|
|
537
|
+
executeOptions: Pick<CreateQueryExecuteOptions<TArgs>, 'state'>;
|
|
538
|
+
executeState: QueryExecuteState;
|
|
539
|
+
};
|
|
540
|
+
declare const cleanupPreviousExecute: <TArgs extends QueryArgs>(options: CleanupPreviousExecuteOptions<TArgs>) => void;
|
|
541
|
+
type QueryRepositoryRequestOptions<TArgs extends QueryArgs> = {
|
|
542
|
+
/**
|
|
543
|
+
* The route of the request.
|
|
544
|
+
* @example '/users'
|
|
545
|
+
* @example (args) => `/users/${args.userId}`
|
|
546
|
+
*/
|
|
547
|
+
route: RouteType$1<TArgs>;
|
|
548
|
+
/** The HTTP method of the request */
|
|
549
|
+
method: QueryMethod;
|
|
550
|
+
/** If the request is secure (needs authentication) */
|
|
551
|
+
isSecure?: boolean;
|
|
552
|
+
/** The data of the request */
|
|
553
|
+
args?: RequestArgs<TArgs> | null;
|
|
554
|
+
/** The client options of the request */
|
|
555
|
+
clientOptions?: CreateHttpRequestClientOptions;
|
|
556
|
+
/** If set, this request's cache key will be prefixed with this key */
|
|
557
|
+
key?: string;
|
|
558
|
+
/** The previous cache key of the request */
|
|
559
|
+
previousKey?: string | false;
|
|
560
|
+
/** The destroy ref to bind the request to. If the destroy ref is destroyed, the request will be destroyed as well. */
|
|
561
|
+
consumerDestroyRef: DestroyRef;
|
|
562
|
+
/** Configuration on how to run the query */
|
|
563
|
+
runQueryOptions?: RunQueryExecuteOptions;
|
|
564
|
+
/** Internal options for running the query */
|
|
565
|
+
internalRunQueryOptions?: InternalRunQueryExecuteOptions;
|
|
566
|
+
};
|
|
567
|
+
type QueryRepositoryItem<TArgs extends QueryArgs> = {
|
|
568
|
+
/** The key of the request. If the key is `false`, the request is not cached, otherwise it is. */
|
|
569
|
+
key: QueryKeyOrNone;
|
|
570
|
+
/** The request object */
|
|
571
|
+
request: HttpRequest<TArgs>;
|
|
572
|
+
};
|
|
573
|
+
/**
|
|
574
|
+
* The query repository is responsible for managing all requests and their consumers.
|
|
575
|
+
* It will cache requests if they can be cached and reuse them if they are already cached.
|
|
576
|
+
* It will also destroy requests if there are no more consumers left.
|
|
577
|
+
*/
|
|
578
|
+
type QueryRepository = {
|
|
579
|
+
/** Creates a new request. If the request is already cached, it will be reused. */
|
|
580
|
+
request: <TArgs extends QueryArgs>(options: QueryRepositoryRequestOptions<TArgs>) => QueryRepositoryItem<TArgs>;
|
|
581
|
+
/** Removes a consumer from a request by its key. Destroys the request if there are no more consumers left. */
|
|
582
|
+
unbind: (key: QueryKeyOrNone, consumerDestroyRef: DestroyRef) => boolean;
|
|
583
|
+
/** Removes all secure requests and their consumers */
|
|
584
|
+
unbindAllSecure: () => void;
|
|
585
|
+
};
|
|
586
|
+
/** The key of a query */
|
|
587
|
+
type QueryKey = string;
|
|
588
|
+
/** A key that will not be cached */
|
|
589
|
+
type QueryKeyNoCache = false;
|
|
590
|
+
/** A key that may or may not be cached */
|
|
591
|
+
type QueryKeyOrNone = QueryKey | QueryKeyNoCache;
|
|
592
|
+
/** Runs .unbind() if the DestroyRef.onDestroy() gets called */
|
|
593
|
+
type DestroyCleanupCallback = () => void;
|
|
594
|
+
type QueryRepositoryDependencies = {
|
|
595
|
+
/** The HTTP client to use for the requests */
|
|
596
|
+
httpClient: HttpClient;
|
|
597
|
+
/** The error handler to use for the requests */
|
|
598
|
+
ngErrorHandler: ErrorHandler;
|
|
599
|
+
};
|
|
600
|
+
type CreateQueryRepositoryConfig = QueryClientConfig$1 & {
|
|
601
|
+
/** The dependencies of the query repository */
|
|
602
|
+
dependencies: QueryRepositoryDependencies;
|
|
603
|
+
};
|
|
604
|
+
declare const createQueryRepository: (config: CreateQueryRepositoryConfig) => QueryRepository;
|
|
605
|
+
type QueryClient$1 = {
|
|
606
|
+
repository: QueryRepository;
|
|
607
|
+
};
|
|
608
|
+
declare const createQueryClient: (config: QueryClientConfig$1) => QueryClient$1;
|
|
609
|
+
declare const provideQueryClient: (config: QueryClientConfig$1) => {
|
|
610
|
+
provide: QueryClientRef;
|
|
611
|
+
useFactory: () => QueryClient$1;
|
|
612
|
+
};
|
|
613
|
+
type CacheAdapterFn$1 = (headers: HttpHeaders) => number | null;
|
|
614
|
+
type CreateQueryClientConfigOptions = {
|
|
615
|
+
/**
|
|
616
|
+
* The base URL of the client
|
|
617
|
+
* @example 'https://api.example.com/v1'
|
|
618
|
+
*/
|
|
619
|
+
baseUrl: string;
|
|
620
|
+
/** Configuration for building query strings */
|
|
621
|
+
queryString?: BuildQueryStringConfig;
|
|
622
|
+
/** The name of the client */
|
|
623
|
+
name: string;
|
|
624
|
+
/**
|
|
625
|
+
* The cache adapter function to use for the client.
|
|
626
|
+
* It determines how long the response of a request can be cached.
|
|
627
|
+
*
|
|
628
|
+
* @default extractExpiresInSeconds()
|
|
629
|
+
*/
|
|
630
|
+
cacheAdapter?: CacheAdapterFn$1;
|
|
631
|
+
/**
|
|
632
|
+
* The retry function to use for the client.
|
|
633
|
+
* It determines if a request should be retried after it failed.
|
|
634
|
+
*
|
|
635
|
+
* @default shouldRetryRequest()
|
|
636
|
+
*/
|
|
637
|
+
retryFn?: ShouldRetryRequestFn;
|
|
638
|
+
};
|
|
639
|
+
type QueryClientConfig$1 = CreateQueryClientConfigOptions & {
|
|
640
|
+
/** A generated token for dependency injection */
|
|
641
|
+
token: QueryClientRef;
|
|
642
|
+
};
|
|
643
|
+
/**
|
|
644
|
+
* A token for a query client.
|
|
645
|
+
* This token can be used to inject a query client into a service.
|
|
646
|
+
*/
|
|
647
|
+
type QueryClientRef = InjectionToken<QueryClient$1>;
|
|
648
|
+
/**
|
|
649
|
+
* This function creates a query client config.
|
|
650
|
+
* The config is used to create a query client using the `provideQueryClient(myConfig)` function.
|
|
651
|
+
*/
|
|
652
|
+
declare const createQueryClientConfig: (options: CreateQueryClientConfigOptions) => QueryClientConfig$1;
|
|
653
|
+
type RouteType$1<TArgs extends QueryArgs> = PathParamsType<TArgs> extends {
|
|
654
|
+
[key: string]: unknown;
|
|
655
|
+
} ? (args: TArgs['pathParams']) => RouteString$1 : RouteString$1;
|
|
656
|
+
type RouteString$1 = `/${string}`;
|
|
657
|
+
type CreateQueryCreatorOptions = {
|
|
658
|
+
/**
|
|
659
|
+
* If true, the query loading state will include progress information.
|
|
660
|
+
* This is useful for file uploads and downloads.
|
|
661
|
+
*
|
|
662
|
+
* **Warning**: Upload progress events are not supported by browsers when using the fetch API, such as with `provideHttpClient(withFetch())`.
|
|
663
|
+
* In this case, you should use the older XHR implementation by omitting `withFetch()`. But take into account that XHR is not supported in server-side rendering environments.
|
|
664
|
+
*
|
|
665
|
+
* @see https://angular.dev/guide/http/making-requests#receiving-raw-progress-events
|
|
666
|
+
*
|
|
667
|
+
* @default false
|
|
668
|
+
*/
|
|
669
|
+
reportProgress?: boolean;
|
|
670
|
+
/**
|
|
671
|
+
* The response type of the query.
|
|
672
|
+
* @default 'json'
|
|
673
|
+
*/
|
|
674
|
+
responseType?: HttpRequestResponseType;
|
|
675
|
+
/**
|
|
676
|
+
* Whether to include credentials (cookies) in the request or not.
|
|
677
|
+
* @default false
|
|
678
|
+
*/
|
|
679
|
+
withCredentials?: boolean;
|
|
680
|
+
/**
|
|
681
|
+
* This property accepts either a boolean to enable/disable transferring cache for eligible
|
|
682
|
+
* requests performed using `HttpClient`, or an object, which allows to configure cache
|
|
683
|
+
* parameters, such as which headers should be included (no headers are included by default).
|
|
684
|
+
*
|
|
685
|
+
* Setting this property will override the options passed to `provideClientHydration()` for this
|
|
686
|
+
* particular request
|
|
687
|
+
*/
|
|
688
|
+
transferCache?: HttpRequestTransferCacheConfig;
|
|
689
|
+
};
|
|
690
|
+
type QueryCreator$1<TArgs extends QueryArgs> = {
|
|
691
|
+
(...features: QueryFeature<TArgs>[]): Query$1<TArgs>;
|
|
692
|
+
(queryConfig: QueryConfig$1, ...features: QueryFeature<TArgs>[]): Query$1<TArgs>;
|
|
693
|
+
};
|
|
694
|
+
type AnyQueryCreator$1 = QueryCreator$1<any>;
|
|
695
|
+
type QueryArgsOf$1<T extends AnyQueryCreator$1 | AnyNewQuery> = T extends QueryCreator$1<infer TArgs> ? TArgs : T extends Query$1<infer TArgs> ? TArgs : never;
|
|
696
|
+
type RunQueryCreator<TCreator extends AnyQueryCreator$1> = ReturnType<TCreator>;
|
|
697
|
+
type QueryMethod = 'GET' | 'OPTIONS' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'TRACE' | 'CONNECT';
|
|
698
|
+
type InternalCreateQueryCreatorOptions<TArgs extends QueryArgs> = {
|
|
699
|
+
/**
|
|
700
|
+
* The route of the query.
|
|
701
|
+
* If the query has path params, the route should be a function that takes the path params as an argument.
|
|
702
|
+
* Otherwise, it should be a string.
|
|
703
|
+
*/
|
|
704
|
+
route: RouteType$1<TArgs>;
|
|
705
|
+
method: QueryMethod;
|
|
706
|
+
client: QueryClientConfig$1;
|
|
707
|
+
};
|
|
708
|
+
type QueryConfig$1 = {
|
|
709
|
+
/** A custom id to use for this query. Only affects queries that can be cached. */
|
|
710
|
+
key?: string;
|
|
711
|
+
/**
|
|
712
|
+
* If true, the query will not be executed automatically.
|
|
713
|
+
* Does not affect mutations such as POST, PUT etc. since those are never executed automatically.
|
|
714
|
+
*/
|
|
715
|
+
onlyManualExecution?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* If true, the query will not throw an error because a "withArgs()" feature is missing.
|
|
718
|
+
*/
|
|
719
|
+
silenceMissingWithArgsFeatureError?: boolean;
|
|
720
|
+
/**
|
|
721
|
+
* A custom injector to use for this query.
|
|
722
|
+
*/
|
|
723
|
+
injector?: Injector;
|
|
724
|
+
};
|
|
725
|
+
declare const splitQueryConfig: <TArgs extends QueryArgs>(args: (QueryFeature<TArgs> | QueryConfig$1)[]) => {
|
|
726
|
+
features: QueryFeature<TArgs>[];
|
|
727
|
+
queryConfig: QueryConfig$1;
|
|
728
|
+
};
|
|
729
|
+
declare const createQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions | undefined, internals: InternalCreateQueryCreatorOptions<TArgs>) => QueryCreator$1<TArgs>;
|
|
730
|
+
type QueryArgs = {
|
|
731
|
+
response?: any;
|
|
732
|
+
pathParams?: Record<string, string | number>;
|
|
733
|
+
queryParams?: any;
|
|
734
|
+
body?: any;
|
|
735
|
+
headers?: HttpHeaders;
|
|
736
|
+
};
|
|
737
|
+
type ResponseType<T extends QueryArgs | null> = T extends QueryArgs ? T['response'] : never;
|
|
738
|
+
type PathParamsType<T extends QueryArgs | null> = T extends QueryArgs ? T['pathParams'] : never;
|
|
739
|
+
type QueryParamsType<T extends QueryArgs | null> = T extends QueryArgs ? T['queryParams'] : never;
|
|
740
|
+
type BodyType<T extends QueryArgs | null> = T extends QueryArgs ? T['body'] : never;
|
|
741
|
+
type RequestArgs<T extends QueryArgs | null> = T extends QueryArgs ? Omit<T, 'response'> : never;
|
|
742
|
+
type CreateQueryOptions<TArgs extends QueryArgs> = {
|
|
743
|
+
creator?: CreateQueryCreatorOptions;
|
|
744
|
+
creatorInternals: InternalCreateQueryCreatorOptions<TArgs>;
|
|
745
|
+
features: QueryFeature<TArgs>[];
|
|
746
|
+
queryConfig: QueryConfig$1;
|
|
747
|
+
};
|
|
748
|
+
type QueryBase<TArgs extends QueryArgs> = {
|
|
749
|
+
/** The arguments of the last execution of the query. Will be `null` if the query has never been executed */
|
|
750
|
+
args: Signal<RequestArgs<TArgs> | null>;
|
|
751
|
+
/**
|
|
752
|
+
* The latest response of the query. Will be `null` if the query has never been executed.
|
|
753
|
+
* Responses are cached until a new response is received.
|
|
754
|
+
* If a response is present but the next execution of the query fails, the response will be set to `null` again.
|
|
755
|
+
*/
|
|
756
|
+
response: Signal<ResponseType<TArgs> | null>;
|
|
757
|
+
/** The latest Angular HTTP client native http event that occurred during the last execution of the query. Will be `null` if no event occurred. */
|
|
758
|
+
latestHttpEvent: Signal<HttpEvent<ResponseType<TArgs>> | null>;
|
|
759
|
+
/** The loading state of the query. Will be `null` if the query currently isn't loading. */
|
|
760
|
+
loading: Signal<HttpRequestLoadingState | null>;
|
|
761
|
+
/** The error that occurred during the last execution of the query. Will be `null` if no error occurred. */
|
|
762
|
+
error: Signal<QueryErrorResponse | null>;
|
|
763
|
+
/** The time the query was last executed at. Will be `null` if the query has never been executed. */
|
|
764
|
+
lastTimeExecutedAt: Signal<number | null>;
|
|
765
|
+
/** The id of the query */
|
|
766
|
+
id: Signal<string>;
|
|
767
|
+
/** The current state of the query. Will be `null` if the query has never been executed. */
|
|
768
|
+
executionState: Signal<QueryExecutionState<TArgs> | null>;
|
|
769
|
+
};
|
|
770
|
+
/** A snapshot of a query state at a specific point in time */
|
|
771
|
+
type QuerySnapshot<TArgs extends QueryArgs> = QueryBase<TArgs> & {
|
|
772
|
+
/** This signal is `true` until the latest execution of the query has completed in any way (success, error, or cancellation) */
|
|
773
|
+
isAlive: Signal<boolean>;
|
|
774
|
+
};
|
|
775
|
+
type AnyQuerySnapshot = QuerySnapshot<any>;
|
|
776
|
+
type AnyNewQuery = Query$1<any>;
|
|
777
|
+
type QuerySubtle<TArgs extends QueryArgs> = {
|
|
778
|
+
/** Destroys the query and cleans up all resources. The query should not be used after this method is called. */
|
|
779
|
+
destroy: () => void;
|
|
780
|
+
/** Manually sets the response of the query. This will not trigger a new execution of the query. */
|
|
781
|
+
setResponse: (response: ResponseType<TArgs>) => void;
|
|
782
|
+
/** The currently underlying HTTP request of the query. Will be `null` if the query has never been executed. */
|
|
783
|
+
request: Signal<HttpRequest<TArgs> | null>;
|
|
784
|
+
/** The destroy reference used to clean up the query when it is no longer needed */
|
|
785
|
+
destroyRef: DestroyRef;
|
|
786
|
+
/** The Angular injector used to resolve dependencies for the query */
|
|
787
|
+
injector: Injector;
|
|
788
|
+
};
|
|
789
|
+
type Query$1<TArgs extends QueryArgs> = QueryBase<TArgs> & {
|
|
790
|
+
/** Executes the query */
|
|
791
|
+
execute: QueryExecute<TArgs>;
|
|
792
|
+
/** Creates an immutable snapshot of the current query state */
|
|
793
|
+
createSnapshot: () => QuerySnapshot<TArgs>;
|
|
794
|
+
/** Resets the query state to its initial state */
|
|
795
|
+
reset: () => void;
|
|
796
|
+
/** Returns a readonly version of the query */
|
|
797
|
+
asReadonly: () => ReadonlyQuery<TArgs>;
|
|
798
|
+
/** Advanced query features. **WARNING!** Incorrectly using these features will likely **BREAK** your application. You have been warned! */
|
|
799
|
+
subtle: QuerySubtle<TArgs>;
|
|
800
|
+
};
|
|
801
|
+
type ReadonlyQuery<TArgs extends QueryArgs> = Omit<Query$1<TArgs>, 'execute' | 'subtle' | 'reset' | 'asReadonly'>;
|
|
802
|
+
declare const createQuery: <TArgs extends QueryArgs>(options: CreateQueryOptions<TArgs>) => Query$1<TArgs>;
|
|
803
|
+
declare const SPEED_BUFFER_TIME_IN_MS = 2000;
|
|
804
|
+
type HttpRequestTransferCacheConfig = boolean | {
|
|
805
|
+
includeHeaders?: string[];
|
|
806
|
+
};
|
|
807
|
+
type HttpRequestResponseType = 'json' | 'text' | 'blob' | 'arraybuffer';
|
|
808
|
+
type CreateHttpRequestDependencies = {
|
|
809
|
+
/** The http client instance to use for the request */
|
|
810
|
+
httpClient: HttpClient;
|
|
811
|
+
/** The error handler instance to use for the request */
|
|
812
|
+
ngErrorHandler: ErrorHandler;
|
|
813
|
+
};
|
|
814
|
+
type CreateHttpRequestClientOptions = {
|
|
815
|
+
/**
|
|
816
|
+
* Whether to report the progress of the request or not. If the fetch backend is used, this will only work for downloads.
|
|
817
|
+
* @see https://angular.dev/guide/http/making-requests#receiving-raw-progress-events
|
|
818
|
+
* @default false
|
|
819
|
+
*/
|
|
820
|
+
reportProgress?: boolean;
|
|
821
|
+
/**
|
|
822
|
+
* Whether to include credentials in the request or not
|
|
823
|
+
* @default false
|
|
824
|
+
*/
|
|
825
|
+
withCredentials?: boolean;
|
|
826
|
+
/**
|
|
827
|
+
* This property accepts either a boolean to enable/disable transferring cache for eligible
|
|
828
|
+
* requests performed using `HttpClient`, or an object, which allows to configure cache
|
|
829
|
+
* parameters, such as which headers should be included (no headers are included by default).
|
|
830
|
+
*
|
|
831
|
+
* Setting this property will override the options passed to `provideClientHydration()` for this
|
|
832
|
+
* particular request
|
|
833
|
+
*/
|
|
834
|
+
transferCache?: HttpRequestTransferCacheConfig;
|
|
835
|
+
/**
|
|
836
|
+
* The response type of the request
|
|
837
|
+
* @default 'json'
|
|
838
|
+
*/
|
|
839
|
+
responseType?: HttpRequestResponseType;
|
|
840
|
+
/**
|
|
841
|
+
* The context of the request
|
|
842
|
+
* @default undefined
|
|
843
|
+
* @see https://angular.dev/guide/http/interceptors#request-and-response-metadata
|
|
844
|
+
*/
|
|
845
|
+
context?: HttpContext;
|
|
846
|
+
};
|
|
847
|
+
type CreateHttpRequestOptions<TArgs extends QueryArgs> = {
|
|
848
|
+
/** The HTTP method of the request */
|
|
849
|
+
method: QueryMethod;
|
|
850
|
+
/**
|
|
851
|
+
* The full path of the request
|
|
852
|
+
* @example 'https://api.example.com/v1/users'
|
|
853
|
+
*/
|
|
854
|
+
fullPath: string;
|
|
855
|
+
/** The data of the request */
|
|
856
|
+
args?: RequestArgs<TArgs> | null;
|
|
857
|
+
/** The dependencies of the request */
|
|
858
|
+
dependencies: QueryRepositoryDependencies;
|
|
859
|
+
/** The client options of the request */
|
|
860
|
+
clientOptions?: CreateHttpRequestClientOptions;
|
|
861
|
+
/**
|
|
862
|
+
* The cache adapter function to use for the request
|
|
863
|
+
* @default extractExpiresInSeconds()
|
|
864
|
+
*/
|
|
865
|
+
cacheAdapter?: CacheAdapterFn$1;
|
|
866
|
+
/**
|
|
867
|
+
* The retry function to use for the request
|
|
868
|
+
* @default shouldRetryRequest()
|
|
869
|
+
*/
|
|
870
|
+
retryFn?: ShouldRetryRequestFn;
|
|
871
|
+
};
|
|
872
|
+
type HttpRequestLoadingState = {
|
|
873
|
+
/** The time when the request was executed in ms */
|
|
874
|
+
executeTime: number;
|
|
875
|
+
/** The progress of the request. Null if reportProgress is false or progress is not available / unsupported */
|
|
876
|
+
progress: HttpRequestLoadingProgressState | null;
|
|
877
|
+
};
|
|
878
|
+
type HttpRequestLoadingProgressState = {
|
|
879
|
+
/** The total number of bytes to be transferred */
|
|
880
|
+
total: number;
|
|
881
|
+
/** The number of bytes transferred */
|
|
882
|
+
loaded: number;
|
|
883
|
+
/** The percentage of the transfer that is completed */
|
|
884
|
+
percentage: number;
|
|
885
|
+
/** The speed of the transfer in bytes per millisecond */
|
|
886
|
+
speed: number | null;
|
|
887
|
+
/** The estimated remaining time in milliseconds */
|
|
888
|
+
remainingTime: number | null;
|
|
889
|
+
};
|
|
890
|
+
type HttpRequest<TArgs extends QueryArgs> = {
|
|
891
|
+
/** Executes the request */
|
|
892
|
+
execute: (options?: {
|
|
893
|
+
allowCache?: boolean;
|
|
894
|
+
}) => boolean;
|
|
895
|
+
/** Destroys the request (cancels it if in progress) */
|
|
896
|
+
destroy: () => boolean;
|
|
897
|
+
/** The loading state of the request */
|
|
898
|
+
loading: Signal<HttpRequestLoadingState | null>;
|
|
899
|
+
/** The error state of the request */
|
|
900
|
+
error: Signal<QueryErrorResponse | null>;
|
|
901
|
+
/** The response state of the request */
|
|
902
|
+
response: Signal<ResponseType<TArgs> | null>;
|
|
903
|
+
/** The current event of the request */
|
|
904
|
+
currentEvent: Signal<HttpEvent<ResponseType<TArgs>> | HttpErrorEvent | null>;
|
|
905
|
+
/** Whether the request is stale or not aka the cache header has expired */
|
|
906
|
+
isStale: Signal<boolean>;
|
|
907
|
+
};
|
|
908
|
+
/** A custom error event since the Angular http client does not provide a specific event for errors */
|
|
909
|
+
type HttpErrorEvent = {
|
|
910
|
+
type: 'error';
|
|
911
|
+
error: QueryErrorResponse;
|
|
912
|
+
};
|
|
913
|
+
declare const createHttpRequest: <TArgs extends QueryArgs>(options: CreateHttpRequestOptions<TArgs>) => HttpRequest<TArgs>;
|
|
914
|
+
declare const ethletePaginationAdapter: <T>(response: Paginated<T>) => NormalizedPagination<T>;
|
|
915
|
+
declare const ggLikePaginationAdapter: <T>(response: GgLikePaginated<T>) => NormalizedPagination<T>;
|
|
916
|
+
declare const dynLikePaginationAdapter: <T>(response: DynLikePaginated<T>) => NormalizedPagination<T>;
|
|
917
|
+
declare const contentfulGqlLikePaginationAdapter: <T>(response: ContentfulGqlLikePaginated<T>) => NormalizedPagination<T>;
|
|
918
|
+
declare const fakePaginationAdapter: (totalHits?: number) => <T>(response: T) => NormalizedPagination<T>;
|
|
919
|
+
type CreatePagedQueryStackOptions<TArgs extends QueryArgs, TNormPagination extends NormalizedPagination<unknown>> = {
|
|
920
|
+
/**
|
|
921
|
+
* The normalizer function that will be used to normalize the response to a format that the paged query can understand.
|
|
922
|
+
*
|
|
923
|
+
* There are some built-in normalizers that can be used:
|
|
924
|
+
* - `ethletePaginationAdapter`
|
|
925
|
+
* - `ggLikePaginationAdapter`
|
|
926
|
+
* - `dynLikePaginationAdapter`
|
|
927
|
+
* - `contentfulGqlLikePaginationAdapter`
|
|
928
|
+
* - `fakePaginationAdapter` (for testing purposes)
|
|
929
|
+
*
|
|
930
|
+
* @param currentResponse The current response that was fetched.
|
|
931
|
+
* @param allResponses All responses that were fetched till now including the current response and pagination.
|
|
932
|
+
*/
|
|
933
|
+
responseNormalizer: (currentResponse: ResponseType<TArgs>, allResponses: NonNullable<ResponseType<TArgs>>[]) => TNormPagination;
|
|
934
|
+
/**
|
|
935
|
+
* The query creator function that will be used to create the paged query.
|
|
936
|
+
*/
|
|
937
|
+
queryCreator: QueryCreator$1<TArgs>;
|
|
938
|
+
/**
|
|
939
|
+
* The arguments to create the query.
|
|
940
|
+
* The current page will be passed as an argument.
|
|
941
|
+
* This function can be treated like a computed function. It reacts to signal changes.
|
|
942
|
+
* If a signal changes, the paged query will be reset to the initial page.
|
|
943
|
+
*
|
|
944
|
+
* @example (page) => ({ queryParams: { page, limit:20 } }),
|
|
945
|
+
*
|
|
946
|
+
* @param page The page to fetch next. **Do not modify this argument.**
|
|
947
|
+
* @param allResponses All responses that were fetched till now including pagination.
|
|
948
|
+
*/
|
|
949
|
+
args: (page: number, allResponses: NonNullable<ResponseType<TArgs>>[]) => RequestArgs<TArgs> | null;
|
|
950
|
+
/**
|
|
951
|
+
* The features that should be used for all queries in the stack.
|
|
952
|
+
*
|
|
953
|
+
* @throws If the `withArgs` feature is used. This feature is internally used.
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* // Due to limitations in TypeScript, you have to manually add the needed generic types if needed.
|
|
957
|
+
* features: [E.withSuccessHandling<GetPostQueryArgs>({ handler: (post) => console.log(post.title) })]
|
|
958
|
+
*
|
|
959
|
+
* @example
|
|
960
|
+
* // If typings are not needed, you can use the feature without generics.
|
|
961
|
+
* features: [E.withPolling({ interval: 5000 })]
|
|
962
|
+
*/
|
|
963
|
+
features?: QueryFeature<any>[];
|
|
964
|
+
/**
|
|
965
|
+
* The page to start this paged query from.
|
|
966
|
+
* @default 1
|
|
967
|
+
*/
|
|
968
|
+
initialPage?: number;
|
|
969
|
+
/**
|
|
970
|
+
* If true, no queries will be executed while the paged query is loading.
|
|
971
|
+
* This is useful if you need the current response to be used in the next query.
|
|
972
|
+
*/
|
|
973
|
+
blockExecutionDuringLoading?: boolean;
|
|
974
|
+
};
|
|
975
|
+
type PagedQueryStackResetOptions = {
|
|
976
|
+
/**
|
|
977
|
+
* The page to reset this paged query to.
|
|
978
|
+
* This will clear everything and start from this page.
|
|
979
|
+
* @default 1 // or the value passed in the `initialPage` option when creating the paged query.
|
|
980
|
+
*/
|
|
981
|
+
initialPage?: number;
|
|
982
|
+
};
|
|
983
|
+
type PagedQueryStackExecuteOptions<TNormPagination extends NormalizedPagination<unknown>> = {
|
|
984
|
+
/**
|
|
985
|
+
* If provided, only the queries that match the condition will be executed.
|
|
986
|
+
* This will also execute the previous and next query to the one that matched the condition.
|
|
987
|
+
* If not provided, all queries will be executed.
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* myPagedQuery.execute({ where: (item) => item.id === 4 });
|
|
991
|
+
*/
|
|
992
|
+
where?: (item: TNormPagination['items'][number], index: number, array: TNormPagination['items']) => boolean;
|
|
993
|
+
/**
|
|
994
|
+
* If true, the cache will be used (if not expired) and the request will not be made.
|
|
995
|
+
* @default false
|
|
996
|
+
*/
|
|
997
|
+
allowCache?: boolean;
|
|
998
|
+
};
|
|
999
|
+
type PagedQueryStackDirection = 'next' | 'previous';
|
|
1000
|
+
type AnyPagedQueryStack = PagedQueryStack<AnyNewQuery, NormalizedPagination<unknown>>;
|
|
1001
|
+
type PagedQueryStack<TQuery extends AnyNewQuery, TNormPagination extends NormalizedPagination<unknown>> = {
|
|
1002
|
+
/**
|
|
1003
|
+
* The pagination of the last executed query in the paged query.
|
|
1004
|
+
*/
|
|
1005
|
+
maxPagination: Signal<TNormPagination | null>;
|
|
1006
|
+
/**
|
|
1007
|
+
* The pagination of the first executed query in the paged query.
|
|
1008
|
+
*/
|
|
1009
|
+
minPagination: Signal<TNormPagination | null>;
|
|
1010
|
+
/**
|
|
1011
|
+
* Whether the last page of the paged query is loaded or not.
|
|
1012
|
+
*/
|
|
1013
|
+
isLastPageLoaded: Signal<boolean>;
|
|
1014
|
+
/**
|
|
1015
|
+
* Whether the first page of the paged query is loaded or not.
|
|
1016
|
+
*/
|
|
1017
|
+
isFirstPageLoaded: Signal<boolean>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Fetches the previous page of the paged query.
|
|
1020
|
+
*
|
|
1021
|
+
* @throws If the paged query is already at the first page.
|
|
1022
|
+
*/
|
|
1023
|
+
fetchPreviousPage: () => TQuery | null;
|
|
1024
|
+
/**
|
|
1025
|
+
* Fetches the next page of the paged query.
|
|
1026
|
+
*
|
|
1027
|
+
* @throws If the paged query is already at the last page.
|
|
1028
|
+
*/
|
|
1029
|
+
fetchNextPage: () => TQuery | null;
|
|
1030
|
+
/**
|
|
1031
|
+
* Whether the previous page can be fetched or not.
|
|
1032
|
+
*
|
|
1033
|
+
* This will be false if the paged query is already at the first page or if the paged query is loading.
|
|
1034
|
+
*/
|
|
1035
|
+
canFetchPreviousPage: Signal<boolean>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Whether the next page can be fetched or not.
|
|
1038
|
+
*
|
|
1039
|
+
* This will be false if the paged query is already at the last page or if the paged query is loading.
|
|
1040
|
+
*/
|
|
1041
|
+
canFetchNextPage: Signal<boolean>;
|
|
1042
|
+
/**
|
|
1043
|
+
* The items of the paged query.
|
|
1044
|
+
*/
|
|
1045
|
+
items: Signal<TNormPagination['items']>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Whether the paged query is loading or not.
|
|
1048
|
+
*/
|
|
1049
|
+
loading: Signal<boolean>;
|
|
1050
|
+
/**
|
|
1051
|
+
* The error that occurred during the last execution of the paged query.
|
|
1052
|
+
*/
|
|
1053
|
+
error: Signal<QueryErrorResponse | null>;
|
|
1054
|
+
/**
|
|
1055
|
+
* The last query executed in the paged query.
|
|
1056
|
+
*/
|
|
1057
|
+
lastQuery: Signal<Query$1<QueryArgsOf$1<TQuery>> | null>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Whether the paged query is on its first load or not.
|
|
1060
|
+
*/
|
|
1061
|
+
isFirstLoad: Signal<boolean>;
|
|
1062
|
+
/**
|
|
1063
|
+
* The queries in the paged query stack.
|
|
1064
|
+
*/
|
|
1065
|
+
queries: Signal<TQuery[]>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Resets the paged query to the initial page.
|
|
1068
|
+
*/
|
|
1069
|
+
reset: (resetOptions?: PagedQueryStackResetOptions) => void;
|
|
1070
|
+
/**
|
|
1071
|
+
* Executes the paged query.
|
|
1072
|
+
*/
|
|
1073
|
+
execute: (options?: PagedQueryStackExecuteOptions<TNormPagination>) => void;
|
|
1074
|
+
/**
|
|
1075
|
+
* The current direction of the paged query.
|
|
1076
|
+
*/
|
|
1077
|
+
direction: Signal<PagedQueryStackDirection>;
|
|
1078
|
+
};
|
|
1079
|
+
declare const createPagedQueryStack: <TCreator extends AnyQueryCreator$1, TArgs extends QueryArgsOf$1<TCreator>, TNormPagination extends NormalizedPagination<unknown>>(options: CreatePagedQueryStackOptions<TArgs, TNormPagination>) => PagedQueryStack<Query$1<TArgs>, TNormPagination>;
|
|
1080
|
+
/** A query creator that creates a GET query */
|
|
1081
|
+
declare const createGetQuery: (client: QueryClientConfig$1) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1082
|
+
/** A query creator that creates a secure GET query (requires authentication) */
|
|
1083
|
+
declare const createSecureGetQuery: (client: QueryClientConfig$1, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1084
|
+
/** A query creator that creates a POST query */
|
|
1085
|
+
declare const createPostQuery: (client: QueryClientConfig$1) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1086
|
+
/** A query creator that creates a secure POST query (requires authentication) */
|
|
1087
|
+
declare const createSecurePostQuery: (client: QueryClientConfig$1, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1088
|
+
/** A query creator that creates a PUT query */
|
|
1089
|
+
declare const createPutQuery: (client: QueryClientConfig$1) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1090
|
+
/** A query creator that creates a secure PUT query (requires authentication) */
|
|
1091
|
+
declare const createSecurePutQuery: (client: QueryClientConfig$1, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1092
|
+
/** A query creator that creates a DELETE query */
|
|
1093
|
+
declare const createDeleteQuery: (client: QueryClientConfig$1) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1094
|
+
/** A query creator that creates a secure DELETE query (requires authentication) */
|
|
1095
|
+
declare const createSecureDeleteQuery: (client: QueryClientConfig$1, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1096
|
+
/** A query creator that creates a PATCH query */
|
|
1097
|
+
declare const createPatchQuery: (client: QueryClientConfig$1) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1098
|
+
/** A query creator that creates a secure PATCH query (requires authentication) */
|
|
1099
|
+
declare const createSecurePatchQuery: (client: QueryClientConfig$1, authProvider: AnyBearerAuthProviderConfig) => <TArgs extends QueryArgs>(route: RouteType$1<TArgs>, creatorOptions?: CreateQueryCreatorOptions) => QueryCreator$1<TArgs>;
|
|
1100
|
+
declare const QueryRuntimeErrorCode: {
|
|
1101
|
+
readonly QUERY_FEATURE_USED_MULTIPLE_TIMES: 0;
|
|
1102
|
+
readonly WITH_ARGS_QUERY_FEATURE_MISSING_BUT_ROUTE_IS_FUNCTION: 100;
|
|
1103
|
+
readonly WITH_POLLING_USED_ON_UNSUPPORTED_HTTP_METHOD: 101;
|
|
1104
|
+
readonly WITH_AUTO_REFRESH_USED_ON_UNSUPPORTED_HTTP_METHOD: 102;
|
|
1105
|
+
readonly WITH_AUTO_REFRESH_USED_IN_MANUAL_QUERY: 103;
|
|
1106
|
+
readonly SILENCE_MISSING_WITH_ARGS_FEATURE_ERROR_USED_BUT_WITH_ARGS_PRESENT: 104;
|
|
1107
|
+
readonly COOKIE_LOGIN_TRIED_BUT_COOKIE_DISABLED: 200;
|
|
1108
|
+
readonly ENABLE_COOKIE_CALLED_WITHOUT_COOKIE_CONFIG: 201;
|
|
1109
|
+
readonly DISABLE_COOKIE_CALLED_WITHOUT_COOKIE_CONFIG: 202;
|
|
1110
|
+
readonly LOGIN_CALLED_WITHOUT_CONFIG: 203;
|
|
1111
|
+
readonly LOGIN_WITH_TOKEN_CALLED_WITHOUT_CONFIG: 204;
|
|
1112
|
+
readonly REFRESH_TOKEN_CALLED_WITHOUT_CONFIG: 205;
|
|
1113
|
+
readonly SELECT_ROLE_CALLED_WITHOUT_CONFIG: 206;
|
|
1114
|
+
readonly DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_OBJECT: 207;
|
|
1115
|
+
readonly DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_CONTAINING_ACCESS_TOKEN: 208;
|
|
1116
|
+
readonly DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_CONTAINING_REFRESH_TOKEN: 209;
|
|
1117
|
+
readonly UNABLE_TO_DECRYPT_BEARER_TOKEN: 210;
|
|
1118
|
+
readonly BEARER_EXPIRES_IN_PROPERTY_NOT_NUMBER: 211;
|
|
1119
|
+
readonly UNCACHEABLE_REQUEST_HAS_CACHE_KEY_PARAM: 300;
|
|
1120
|
+
readonly UNCACHEABLE_REQUEST_HAS_ALLOW_CACHE_PARAM: 301;
|
|
1121
|
+
readonly PAGED_QUERY_STACK_PAGE_BIGGER_THAN_TOTAL_PAGES: 400;
|
|
1122
|
+
readonly PAGED_QUERY_STACK_NEXT_PAGE_CALLED_WITHOUT_PREVIOUS_PAGE: 401;
|
|
1123
|
+
readonly PAGED_QUERY_STACK_PREVIOUS_PAGE_CALLED_BUT_ALREADY_AT_FIRST_PAGE: 402;
|
|
1124
|
+
readonly QUERY_STACK_WITH_ARGS_USED: 500;
|
|
1125
|
+
readonly QUERY_STACK_WITH_RESPONSE_UPDATE_USED: 501;
|
|
1126
|
+
readonly QUERY_STACK_TOTAL_QUERIES_AND_EXPECTED_QUERIES_MISMATCH: 502;
|
|
1127
|
+
};
|
|
1128
|
+
type QueryRuntimeErrorCode = (typeof QueryRuntimeErrorCode)[keyof typeof QueryRuntimeErrorCode];
|
|
1129
|
+
declare const queryFeatureUsedMultipleTimes: (type: QueryFeatureType) => RuntimeError<0>;
|
|
1130
|
+
declare const withArgsQueryFeatureMissingButRouteIsFunction: () => RuntimeError<100>;
|
|
1131
|
+
declare const withPollingUsedOnUnsupportedHttpMethod: (method: string) => RuntimeError<101>;
|
|
1132
|
+
declare const withAutoRefreshUsedOnUnsupportedHttpMethod: (method: string) => RuntimeError<102>;
|
|
1133
|
+
declare const withAutoRefreshUsedInManualQuery: () => RuntimeError<103>;
|
|
1134
|
+
declare const silenceMissingWithArgsFeatureErrorUsedButWithArgsPresent: () => RuntimeError<104>;
|
|
1135
|
+
declare const cookieLoginTriedButCookieDisabled: () => RuntimeError<200>;
|
|
1136
|
+
declare const enableCookieCalledWithoutCookieConfig: () => RuntimeError<201>;
|
|
1137
|
+
declare const disableCookieCalledWithoutCookieConfig: () => RuntimeError<202>;
|
|
1138
|
+
declare const loginCalledWithoutConfig: () => RuntimeError<203>;
|
|
1139
|
+
declare const loginWithTokenCalledWithoutConfig: () => RuntimeError<204>;
|
|
1140
|
+
declare const refreshTokenCalledWithoutConfig: () => RuntimeError<205>;
|
|
1141
|
+
declare const selectRoleCalledWithoutConfig: () => RuntimeError<206>;
|
|
1142
|
+
declare const defaultResponseTransformerResponseNotObject: (currentType: string) => RuntimeError<207>;
|
|
1143
|
+
declare const defaultResponseTransformerResponseNotContainingAccessToken: () => RuntimeError<208>;
|
|
1144
|
+
declare const defaultResponseTransformerResponseNotContainingRefreshToken: () => RuntimeError<209>;
|
|
1145
|
+
declare const unableToDecryptBearerToken: (token: string) => RuntimeError<210>;
|
|
1146
|
+
declare const bearerExpiresInPropertyNotNumber: (expiresIn: unknown) => RuntimeError<211>;
|
|
1147
|
+
declare const uncacheableRequestHasCacheKeyParam: (key: string) => RuntimeError<300>;
|
|
1148
|
+
declare const uncacheableRequestHasAllowCacheParam: () => RuntimeError<301>;
|
|
1149
|
+
declare const pagedQueryStackPageBiggerThanTotalPages: (page: number, totalPages: number) => RuntimeError<400>;
|
|
1150
|
+
declare const pagedQueryStackNextPageCalledWithoutPreviousPage: () => RuntimeError<401>;
|
|
1151
|
+
declare const pagedQueryStackPreviousPageCalledButAlreadyAtFirstPage: () => RuntimeError<402>;
|
|
1152
|
+
declare const queryStackWithArgsUsed: () => RuntimeError<500>;
|
|
1153
|
+
declare const queryStackWithResponseUpdateUsed: () => RuntimeError<501>;
|
|
1154
|
+
declare const queryStackTotalQueriesAndExpectedQueriesMismatch: (totalQueries: number, expectedQueries: number) => RuntimeError<502>;
|
|
1155
|
+
type CreateQuerySnapshotOptions<TArgs extends QueryArgs> = {
|
|
1156
|
+
state: QueryState$1<TArgs>;
|
|
1157
|
+
deps: QueryDependencies;
|
|
1158
|
+
execute: InternalQueryExecute<TArgs>;
|
|
1159
|
+
};
|
|
1160
|
+
declare const createQuerySnapshotFn: <TArgs extends QueryArgs>(options: CreateQuerySnapshotOptions<TArgs>) => () => QuerySnapshot<TArgs>;
|
|
1161
|
+
type QueryStackSubtle<TCreator extends AnyQueryCreator$1, TQuery extends AnyNewQuery> = {
|
|
1162
|
+
/** Create a new query with the given arguments. You should always prefer the `args` option instead of this. */
|
|
1163
|
+
runWithArgs: (args: RequestArgs<QueryArgsOf$1<TCreator>> | RequestArgs<QueryArgsOf$1<TCreator>>[] | null) => TQuery | null;
|
|
1164
|
+
};
|
|
1165
|
+
type QueryStack<TQuery extends AnyNewQuery, TCreator extends AnyQueryCreator$1, TTransform> = {
|
|
1166
|
+
/** Contains all queries in the stack. */
|
|
1167
|
+
queries: Signal<TQuery[]>;
|
|
1168
|
+
/** Contains the first query in the stack. */
|
|
1169
|
+
firstQuery: Signal<TQuery | null>;
|
|
1170
|
+
/** Contains the last query in the stack. Useful for getting current pagination values. */
|
|
1171
|
+
lastQuery: Signal<TQuery | null>;
|
|
1172
|
+
/** True if any query in the stack is loading. */
|
|
1173
|
+
loading: Signal<boolean>;
|
|
1174
|
+
/** Contains the first error that occurred in the stack. */
|
|
1175
|
+
error: Signal<QueryErrorResponse | null>;
|
|
1176
|
+
/** Contains the responses of all queries in the stack. Will be `null` for queries that are loading or errored. */
|
|
1177
|
+
response: Signal<TTransform>;
|
|
1178
|
+
/** Executes all queries in the stack. */
|
|
1179
|
+
execute: (options?: {
|
|
1180
|
+
allowCache?: boolean;
|
|
1181
|
+
}) => void;
|
|
1182
|
+
/** Destroys all queries in the stack and empties it. This should only be used if `append` is true. */
|
|
1183
|
+
clear: () => void;
|
|
1184
|
+
/** Advanced query stack features. **WARNING!** Incorrectly using these features will likely **BREAK** your application. You have been warned! */
|
|
1185
|
+
subtle: QueryStackSubtle<TCreator, TQuery>;
|
|
1186
|
+
};
|
|
1187
|
+
type AnyQueryStack = QueryStack<AnyNewQuery, AnyQueryCreator$1, any>;
|
|
1188
|
+
type CreateQueryStackOptions<TCreator extends AnyQueryCreator$1, TDeps extends () => any, TTransform = (ResponseType<QueryArgsOf$1<TCreator>> | null)[]> = {
|
|
1189
|
+
/**
|
|
1190
|
+
* The query creator function that will be used to create the query stack.
|
|
1191
|
+
*/
|
|
1192
|
+
queryCreator: TCreator;
|
|
1193
|
+
/**
|
|
1194
|
+
* The dependencies that should trigger a new query stack creation.
|
|
1195
|
+
* This function can be treated like a computed function. It reacts to signal changes.
|
|
1196
|
+
* The return value of this function will be passed to the `args` function.
|
|
1197
|
+
*
|
|
1198
|
+
* This option can be ignored if `append` is false.
|
|
1199
|
+
*/
|
|
1200
|
+
dependencies?: TDeps;
|
|
1201
|
+
/**
|
|
1202
|
+
* The features that should be used for all queries in the stack.
|
|
1203
|
+
*
|
|
1204
|
+
* @throws If the `withArgs` feature is used. This feature is internally used.
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* // Due to limitations in TypeScript, you have to manually add the needed generic types if needed.
|
|
1208
|
+
* features: [E.withSuccessHandling<GetPostQueryArgs>({ handler: (post) => console.log(post.title) })]
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // If typings are not needed, you can use the feature without generics.
|
|
1212
|
+
* features: [E.withPolling({ interval: 5000 })]
|
|
1213
|
+
*/
|
|
1214
|
+
features?: QueryFeature<any>[];
|
|
1215
|
+
/**
|
|
1216
|
+
* The arguments to create queries with.
|
|
1217
|
+
* This function can be treated like a computed function. It reacts to signal changes.
|
|
1218
|
+
* If a signal changes, a new query will be created (and appended to the existing ones if `append` is true).
|
|
1219
|
+
* If this function returns `null`, the args will be ignored.
|
|
1220
|
+
* If this function returns an array, multiple queries will be created.
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* // One query
|
|
1224
|
+
* () => ({ queryParams: { postId: myId() } }),
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* // Multiple queries (these can of cause also be created using a loop)
|
|
1228
|
+
* () => [
|
|
1229
|
+
* { queryParams: { postId: myId() } },
|
|
1230
|
+
* { queryParams: { postId: myOtherId() } },
|
|
1231
|
+
* ],
|
|
1232
|
+
*
|
|
1233
|
+
* @example
|
|
1234
|
+
* // One query with dependencies
|
|
1235
|
+
* (deps) => ({ queryParams: { postId: myId(), limit: deps.limit } }),
|
|
1236
|
+
*/
|
|
1237
|
+
args: (deps: ReturnType<TDeps>) => RequestArgs<QueryArgsOf$1<TCreator>> | RequestArgs<QueryArgsOf$1<TCreator>>[] | null;
|
|
1238
|
+
/**
|
|
1239
|
+
* If true, new queries will be appended to the existing ones. Otherwise, existing queries will be destroyed.
|
|
1240
|
+
* This should be used for things like infinite scrolling where already fetched queries should not be destroyed.
|
|
1241
|
+
*/
|
|
1242
|
+
append?: boolean;
|
|
1243
|
+
/**
|
|
1244
|
+
* If append is true, this function will be called to merge the old and new queries.
|
|
1245
|
+
* Useful if you want to append the new queries in a specific order (e.g. at the beginning).
|
|
1246
|
+
*/
|
|
1247
|
+
appendFn?: (oldQueries: RunQueryCreator<TCreator>[], newQueries: RunQueryCreator<TCreator>[]) => {
|
|
1248
|
+
/** The new queries merged with the old ones. */
|
|
1249
|
+
queries: RunQueryCreator<TCreator>[];
|
|
1250
|
+
/** The last query in the new queries. */
|
|
1251
|
+
lastQuery: RunQueryCreator<TCreator> | null;
|
|
1252
|
+
};
|
|
1253
|
+
/**
|
|
1254
|
+
* Transforms the responses of all queries in the stack. Useful for merging or filtering responses.
|
|
1255
|
+
*/
|
|
1256
|
+
transform?: (responses: ResponseType<QueryArgsOf$1<TCreator>>[]) => TTransform;
|
|
1257
|
+
};
|
|
1258
|
+
/** Transforms an array of arrays into a single array and filters out `null` values. */
|
|
1259
|
+
declare const transformArrayResponse: <T extends (unknown | null)[]>(responses: T) => NonNullable<T[0]>[];
|
|
1260
|
+
/** Transforms an array of paginated responses into a single array and filters out `null` values. */
|
|
1261
|
+
declare const transformPaginatedResponse: <T extends ({
|
|
1262
|
+
items: unknown[];
|
|
1263
|
+
} | null)[]>(responses: T) => NonNullable<NonNullable<T[0]>["items"]>;
|
|
1264
|
+
declare const createQueryStack: <TCreator extends AnyQueryCreator$1, TArgs extends QueryArgsOf$1<TCreator>, TDeps extends () => any, TTransform = (ResponseType<TArgs> | null)[]>(options: CreateQueryStackOptions<TCreator, TDeps, TTransform>) => QueryStack<RunQueryCreator<TCreator>, TCreator, TTransform>;
|
|
1265
|
+
type InternalSecureCreateQueryCreatorOptions<TArgs extends QueryArgs> = InternalCreateQueryCreatorOptions<TArgs> & {
|
|
1266
|
+
authProvider: AnyBearerAuthProviderConfig;
|
|
1267
|
+
};
|
|
1268
|
+
declare const createSecureQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions | undefined, internals: InternalSecureCreateQueryCreatorOptions<TArgs>) => QueryCreator$1<TArgs>;
|
|
1269
|
+
type CreateSecureQueryOptions<TArgs extends QueryArgs> = Omit<CreateQueryOptions<TArgs>, 'creatorInternals'> & {
|
|
1270
|
+
creatorInternals: InternalSecureCreateQueryCreatorOptions<TArgs>;
|
|
1271
|
+
};
|
|
1272
|
+
declare const createSecureQuery: <TArgs extends QueryArgs>(options: CreateSecureQueryOptions<TArgs>) => Query$1<TArgs>;
|
|
1273
|
+
type CreateSecureQueryExecuteOptions<TArgs extends QueryArgs> = Omit<CreateQueryExecuteOptions<TArgs>, 'creatorInternals'> & {
|
|
1274
|
+
creatorInternals: InternalSecureCreateQueryCreatorOptions<TArgs>;
|
|
1275
|
+
};
|
|
1276
|
+
declare const createSecureExecuteFn: <TArgs extends QueryArgs>(executeOptions: CreateSecureQueryExecuteOptions<TArgs>) => InternalQueryExecute<TArgs>;
|
|
1277
|
+
type BearerAuthProviderTokens = {
|
|
1278
|
+
accessToken: string;
|
|
1279
|
+
refreshToken: string;
|
|
1280
|
+
};
|
|
1281
|
+
type BearerAuthProviderRouteConfig<TArgs extends QueryArgs> = {
|
|
1282
|
+
queryCreator: QueryCreator$1<TArgs>;
|
|
1283
|
+
/**
|
|
1284
|
+
* A function that transforms the response into the format that the auth provider expects
|
|
1285
|
+
*
|
|
1286
|
+
* The expected format is an object with the `accessToken` and `refreshToken` properties.
|
|
1287
|
+
*
|
|
1288
|
+
* @default (response) => response
|
|
1289
|
+
*/
|
|
1290
|
+
responseTransformer?: (response: ResponseType<TArgs>) => BearerAuthProviderTokens;
|
|
1291
|
+
};
|
|
1292
|
+
type BearerAuthProviderCookieConfig<TTokenRefreshArgs extends QueryArgs> = {
|
|
1293
|
+
/**
|
|
1294
|
+
* The cookie name where the refresh token is stored
|
|
1295
|
+
* @default 'etAuth'
|
|
1296
|
+
*/
|
|
1297
|
+
name?: string;
|
|
1298
|
+
/**
|
|
1299
|
+
* The domain of the cookie. If not set, the current origin will be used.
|
|
1300
|
+
*
|
|
1301
|
+
* @example
|
|
1302
|
+
* "https://example.com" -> "example.com"
|
|
1303
|
+
* "https://sub.example.com" -> "example.com"
|
|
1304
|
+
*/
|
|
1305
|
+
domain?: string;
|
|
1306
|
+
/**
|
|
1307
|
+
* The days until the cookie expires
|
|
1308
|
+
* @default 30
|
|
1309
|
+
*/
|
|
1310
|
+
expiresInDays?: number;
|
|
1311
|
+
/**
|
|
1312
|
+
* The path of the cookie
|
|
1313
|
+
* @default '/'
|
|
1314
|
+
*/
|
|
1315
|
+
path?: string;
|
|
1316
|
+
/**
|
|
1317
|
+
* Enable or disable the cookie
|
|
1318
|
+
* @default true
|
|
1319
|
+
*/
|
|
1320
|
+
enabled?: boolean;
|
|
1321
|
+
/**
|
|
1322
|
+
* The same site property of the cookie
|
|
1323
|
+
* @default 'lax'
|
|
1324
|
+
*/
|
|
1325
|
+
sameSite?: 'strict' | 'none' | 'lax';
|
|
1326
|
+
/**
|
|
1327
|
+
* A function that turns the token gotten from the cookie into the body for the refresh token request
|
|
1328
|
+
* @default (token) => ({ token })
|
|
1329
|
+
*/
|
|
1330
|
+
refreshArgsTransformer?: (token: string) => RequestArgs<TTokenRefreshArgs>;
|
|
1331
|
+
/**
|
|
1332
|
+
* An array of routes where the auto login via cookie should not be triggered.
|
|
1333
|
+
*
|
|
1334
|
+
* This checks the current route against the array of routes using the `startsWith` method.
|
|
1335
|
+
* Make sure to start each route with a `/`.
|
|
1336
|
+
*
|
|
1337
|
+
* @default []
|
|
1338
|
+
* @example ['/login', '/register']
|
|
1339
|
+
*/
|
|
1340
|
+
autoLoginExcludeRoutes?: string[];
|
|
1341
|
+
};
|
|
1342
|
+
type CreateBearerAuthProviderConfigOptions<TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData> = {
|
|
1343
|
+
/**
|
|
1344
|
+
* The name of the auth provider
|
|
1345
|
+
*/
|
|
1346
|
+
name: string;
|
|
1347
|
+
/**
|
|
1348
|
+
* The query client reference
|
|
1349
|
+
*/
|
|
1350
|
+
queryClientRef: QueryClientRef;
|
|
1351
|
+
/**
|
|
1352
|
+
* The login route configuration
|
|
1353
|
+
*/
|
|
1354
|
+
login?: BearerAuthProviderRouteConfig<TLoginArgs>;
|
|
1355
|
+
/**
|
|
1356
|
+
* The token login route configuration
|
|
1357
|
+
*/
|
|
1358
|
+
tokenLogin?: BearerAuthProviderRouteConfig<TTokenLoginArgs>;
|
|
1359
|
+
/**
|
|
1360
|
+
* The token refresh route configuration
|
|
1361
|
+
*/
|
|
1362
|
+
tokenRefresh?: BearerAuthProviderRouteConfig<TTokenRefreshArgs>;
|
|
1363
|
+
/**
|
|
1364
|
+
* The select role route configuration
|
|
1365
|
+
*/
|
|
1366
|
+
selectRole?: BearerAuthProviderRouteConfig<TSelectRoleArgs>;
|
|
1367
|
+
/**
|
|
1368
|
+
* The cookie configuration for the auth provider
|
|
1369
|
+
*/
|
|
1370
|
+
cookie?: BearerAuthProviderCookieConfig<TTokenRefreshArgs>;
|
|
1371
|
+
/**
|
|
1372
|
+
* The time in milliseconds before the token expires when the refresh should be triggered.
|
|
1373
|
+
* @default 300000 // (5 minutes)
|
|
1374
|
+
*/
|
|
1375
|
+
refreshBuffer?: number;
|
|
1376
|
+
/**
|
|
1377
|
+
* The expires in property name inside the jwt body
|
|
1378
|
+
* @default 'exp'
|
|
1379
|
+
*/
|
|
1380
|
+
expiresInPropertyName?: string;
|
|
1381
|
+
/**
|
|
1382
|
+
* Determines if the token should be refreshed if **any** query returns a 401 response.
|
|
1383
|
+
* @default true
|
|
1384
|
+
*/
|
|
1385
|
+
refreshOnUnauthorizedResponse?: boolean;
|
|
1386
|
+
/**
|
|
1387
|
+
* A function that decrypts the bearer token
|
|
1388
|
+
*/
|
|
1389
|
+
bearerDecryptFn?: (token: string) => TBearerData;
|
|
1390
|
+
};
|
|
1391
|
+
type BearerAuthProviderConfig<TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData> = CreateBearerAuthProviderConfigOptions<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData> & {
|
|
1392
|
+
token: BearerAuthProviderRef<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>;
|
|
1393
|
+
};
|
|
1394
|
+
type AnyBearerAuthProviderConfig = BearerAuthProviderConfig<any, any, any, any, any>;
|
|
1395
|
+
type BearerAuthProviderRef<TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData> = InjectionToken<BearerAuthProvider$1<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>>;
|
|
1396
|
+
declare const createBearerAuthProviderConfig: <TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData>(options: CreateBearerAuthProviderConfigOptions<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>) => BearerAuthProviderConfig<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>;
|
|
1397
|
+
type QuerySnapshotWithType<TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs> = ({
|
|
1398
|
+
type: 'login';
|
|
1399
|
+
} & QuerySnapshot<TLoginArgs>) | ({
|
|
1400
|
+
type: 'tokenLogin';
|
|
1401
|
+
} & QuerySnapshot<TTokenLoginArgs>) | ({
|
|
1402
|
+
type: 'tokenRefresh';
|
|
1403
|
+
} & QuerySnapshot<TTokenRefreshArgs>) | ({
|
|
1404
|
+
type: 'selectRole';
|
|
1405
|
+
} & QuerySnapshot<TSelectRoleArgs>);
|
|
1406
|
+
type BearerAuthProvider$1<TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData> = {
|
|
1407
|
+
/**
|
|
1408
|
+
* Logs in the user with the given args.
|
|
1409
|
+
*/
|
|
1410
|
+
login: (args: RequestArgs<TLoginArgs>) => QuerySnapshot<TLoginArgs>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Logs in the user with the given token.
|
|
1413
|
+
*/
|
|
1414
|
+
loginWithToken: (args: RequestArgs<TTokenLoginArgs>) => QuerySnapshot<TTokenLoginArgs>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Refreshes the token with the given refresh token.
|
|
1417
|
+
*/
|
|
1418
|
+
refreshToken: (args: RequestArgs<TTokenRefreshArgs>) => QuerySnapshot<TTokenRefreshArgs>;
|
|
1419
|
+
/**
|
|
1420
|
+
* Selects the role for the user.
|
|
1421
|
+
*/
|
|
1422
|
+
selectRole: (args: RequestArgs<TSelectRoleArgs>) => QuerySnapshot<TSelectRoleArgs>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Logs out the user and removes the cookie.
|
|
1425
|
+
*/
|
|
1426
|
+
logout: () => void;
|
|
1427
|
+
/**
|
|
1428
|
+
* Enables cookie usage for the auth provider.
|
|
1429
|
+
*/
|
|
1430
|
+
enableCookie: () => void;
|
|
1431
|
+
/**
|
|
1432
|
+
* Disables cookie usage for the auth provider and removes the cookie.
|
|
1433
|
+
*/
|
|
1434
|
+
disableCookie: () => void;
|
|
1435
|
+
/**
|
|
1436
|
+
* Checks if the cookie is present.
|
|
1437
|
+
*/
|
|
1438
|
+
isCookiePresent: () => boolean;
|
|
1439
|
+
/**
|
|
1440
|
+
* Tries to login with the given cookie config.
|
|
1441
|
+
* Returns `true` if a cookie was found, `false` otherwise.
|
|
1442
|
+
*/
|
|
1443
|
+
tryLoginWithCookie: () => boolean;
|
|
1444
|
+
/**
|
|
1445
|
+
* The latest executed query that was not triggered internally.
|
|
1446
|
+
*/
|
|
1447
|
+
latestExecutedQuery: Signal<QuerySnapshotWithType<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs> | null>;
|
|
1448
|
+
/**
|
|
1449
|
+
* A signal that contains the current access and refresh tokens.
|
|
1450
|
+
*/
|
|
1451
|
+
tokens: Signal<BearerAuthProviderTokens | null>;
|
|
1452
|
+
/**
|
|
1453
|
+
* The bearer data that was decrypted from the access token.
|
|
1454
|
+
*/
|
|
1455
|
+
bearerData: Signal<TBearerData | null>;
|
|
1456
|
+
};
|
|
1457
|
+
declare const createBearerAuthProvider: <TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData>(options: BearerAuthProviderConfig<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>) => BearerAuthProvider$1<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>;
|
|
1458
|
+
declare const provideBearerAuthProvider: <TLoginArgs extends QueryArgs, TTokenLoginArgs extends QueryArgs, TTokenRefreshArgs extends QueryArgs, TSelectRoleArgs extends QueryArgs, TBearerData>(config: BearerAuthProviderConfig<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>) => {
|
|
1459
|
+
provide: BearerAuthProviderRef<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>;
|
|
1460
|
+
useFactory: () => BearerAuthProvider$1<TLoginArgs, TTokenLoginArgs, TTokenRefreshArgs, TSelectRoleArgs, TBearerData>;
|
|
1461
|
+
};
|
|
1462
|
+
export type TransformedGqlQuery = {
|
|
1463
|
+
query: string;
|
|
1464
|
+
variables?: string;
|
|
1465
|
+
operationName?: string;
|
|
1466
|
+
};
|
|
1467
|
+
export declare const transformGql: (str: string) => (variables: Record<string, unknown> | null | undefined) => TransformedGqlQuery;
|
|
1468
|
+
export type GQL = string & {
|
|
1469
|
+
gql: 'tag';
|
|
1470
|
+
};
|
|
1471
|
+
export declare const gql: (strings: TemplateStringsArray, ...values: string[]) => GQL;
|
|
1472
|
+
/** A query creator that creates a GQL query where the payload is sent via GET (query params) */
|
|
1473
|
+
declare const createGqlQueryViaGet: (client: QueryClientConfig$1) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => QueryCreator$1<TArgs>;
|
|
1474
|
+
/** A query creator that creates a GQL query where the payload is sent via POST (body) */
|
|
1475
|
+
declare const createGqlQueryViaPost: (client: QueryClientConfig$1) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => QueryCreator$1<TArgs>;
|
|
1476
|
+
/** A query creator that creates a GQL mutation where the payload is sent via GET (query params) */
|
|
1477
|
+
declare const createGqlMutationViaGet: (client: QueryClientConfig$1) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => QueryCreator$1<TArgs>;
|
|
1478
|
+
/** A query creator that creates a GQL mutation where the payload is sent via POST (body) */
|
|
1479
|
+
declare const createGqlMutationViaPost: (client: QueryClientConfig$1) => <TArgs extends GqlQueryArgs>(query: GQL, creatorOptions?: CreateGqlQueryCreatorOptions<TArgs>) => QueryCreator$1<TArgs>;
|
|
1480
|
+
type CreateGqlQueryExecuteOptions<TArgs extends QueryArgs> = {
|
|
1481
|
+
deps: QueryDependencies;
|
|
1482
|
+
state: QueryState$1<TArgs>;
|
|
1483
|
+
creator?: CreateGqlQueryCreatorOptions<TArgs>;
|
|
1484
|
+
creatorInternals: InternalCreateGqlQueryCreatorOptions;
|
|
1485
|
+
queryConfig: QueryConfig$1;
|
|
1486
|
+
};
|
|
1487
|
+
declare const createGqlExecuteFn: <TArgs extends GqlQueryArgs>(executeOptions: CreateGqlQueryExecuteOptions<TArgs>) => InternalQueryExecute<TArgs>;
|
|
1488
|
+
type CreateLegacyQueryOptions<TArgs extends QueryArgs> = {
|
|
1489
|
+
query: Query$1<TArgs>;
|
|
1490
|
+
};
|
|
1491
|
+
declare const transformExecStateToQueryState: <TArgs extends QueryArgs>(execState: QueryExecutionState<TArgs> | null) => QueryState<ResponseType<TArgs>>;
|
|
1492
|
+
declare const isLegacyQuery: <T extends AnyLegacyQuery>(query: unknown) => query is T;
|
|
1493
|
+
type AnyLegacyQuery = LegacyQuery<any, any, any, any, any, any, any>;
|
|
1494
|
+
declare class LegacyQuery<Response, Arguments extends BaseArguments | undefined, Route extends RouteType<Arguments>, Store extends EntityStore<unknown>, Data, Id, TNewQuery extends AnyNewQuery> {
|
|
1495
|
+
newQuery: TNewQuery;
|
|
1496
|
+
_arguments: RequestArgs<QueryArgsOf$1<TNewQuery>>;
|
|
1497
|
+
entity?: QueryEntityConfig<Store, Data, Response, Arguments, Id> | undefined;
|
|
1498
|
+
state$: Observable<QueryState<Data>>;
|
|
1499
|
+
get rawState(): QueryState<any>;
|
|
1500
|
+
get isExpired(): boolean | undefined;
|
|
1501
|
+
get isInUse(): boolean;
|
|
1502
|
+
get isPolling(): boolean;
|
|
1503
|
+
get autoRefreshOnConfig(): Readonly<QueryAutoRefreshConfig>;
|
|
1504
|
+
get store(): null;
|
|
1505
|
+
get canBeCached(): boolean;
|
|
1506
|
+
get _isInMockMode(): boolean;
|
|
1507
|
+
constructor(newQuery: TNewQuery, _arguments: RequestArgs<QueryArgsOf$1<TNewQuery>>, entity?: QueryEntityConfig<Store, Data, Response, Arguments, Id> | undefined);
|
|
1508
|
+
destroy(): void;
|
|
1509
|
+
execute(options?: ExecuteQueryOptions): this;
|
|
1510
|
+
abort(): this;
|
|
1511
|
+
poll(config: PollConfig): this;
|
|
1512
|
+
stopPolling(): this;
|
|
1513
|
+
pausePolling(): this;
|
|
1514
|
+
resumePolling(): this;
|
|
1515
|
+
onSuccess(callback: (response: Data) => void): this;
|
|
1516
|
+
onFailure(callback: (error: RequestError<unknown>) => void): this;
|
|
1517
|
+
}
|
|
1518
|
+
export interface QueryContainerConfig {
|
|
1519
|
+
/**
|
|
1520
|
+
* If `true`, the previous query will be aborted when a new query is pushed into the container.
|
|
1521
|
+
* @default true // Only if the request can be cached (GET, OPTIONS, HEAD and GQL_QUERY). Otherwise false.
|
|
1522
|
+
*/
|
|
1523
|
+
abortPrevious?: boolean;
|
|
1524
|
+
/**
|
|
1525
|
+
* If `true`, the query will be aborted when the container is destroyed.
|
|
1526
|
+
* @default true // Only if the request can be cached (GET, OPTIONS, HEAD and GQL_QUERY). Otherwise false.
|
|
1527
|
+
*/
|
|
1528
|
+
abortOnDestroy?: boolean;
|
|
1529
|
+
/**
|
|
1530
|
+
* If `true`, the previous polling will be stopped when a new query is pushed into the container.
|
|
1531
|
+
* @default true // Only if the query has no other dependents and the request can be cached (GET, OPTIONS, HEAD and GQL_QUERY). Otherwise false.
|
|
1532
|
+
*/
|
|
1533
|
+
stopPreviousPolling?: boolean;
|
|
1534
|
+
}
|
|
1535
|
+
export interface QueryFilterConfig {
|
|
1536
|
+
/**
|
|
1537
|
+
* If `true`, the response will be cached until the next response is received or the query fails.
|
|
1538
|
+
* @default false
|
|
1539
|
+
*/
|
|
1540
|
+
cacheResponse?: boolean;
|
|
1541
|
+
}
|
|
1542
|
+
export declare const addQueryContainerHandling: (obs: Observable<AnyQuery | AnyQuery[] | AnyLegacyQuery | AnyLegacyQuery[] | null>, valueFn: () => AnyQuery | AnyQuery[] | AnyLegacyQuery | AnyLegacyQuery[] | null | undefined, config?: QueryContainerConfig) => void;
|
|
1543
|
+
export declare function toQuerySignal<T extends AnyQuery | AnyLegacyQuery | null>(source: Observable<T> | Subscribable<T>): Signal<T | undefined>;
|
|
1544
|
+
export declare function toQuerySignal<T extends AnyQuery | AnyLegacyQuery | null>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T | undefined>> & {
|
|
1545
|
+
initialValue?: undefined;
|
|
1546
|
+
requireSync?: false;
|
|
1547
|
+
} & QueryContainerConfig): Signal<T | undefined>;
|
|
1548
|
+
export declare function toQuerySignal<T extends AnyQuery | AnyLegacyQuery | null>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T | null>> & {
|
|
1549
|
+
initialValue?: null;
|
|
1550
|
+
requireSync?: false;
|
|
1551
|
+
} & QueryContainerConfig): Signal<T | null>;
|
|
1552
|
+
export declare function toQuerySignal<T extends AnyQuery | AnyLegacyQuery | null>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T>> & {
|
|
1553
|
+
initialValue?: undefined;
|
|
1554
|
+
requireSync: true;
|
|
1555
|
+
} & QueryContainerConfig): Signal<T>;
|
|
1556
|
+
export declare function toQuerySignal<T extends AnyQuery | AnyLegacyQuery | null, const U extends T>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T | U>> & {
|
|
1557
|
+
initialValue: U;
|
|
1558
|
+
requireSync?: false;
|
|
1559
|
+
} & QueryContainerConfig): Signal<T | U>;
|
|
1560
|
+
export declare function effectComputed<T extends AnyQuery | AnyLegacyQuery | AnyQuery[] | AnyLegacyQuery[] | null>(computation: () => T, injector: Injector): Signal<T>;
|
|
1561
|
+
export declare function queryComputed<T extends AnyQuery | AnyLegacyQuery | null>(computation: () => T, options?: CreateComputedOptions<T> & QueryContainerConfig & ToObservableOptions): Signal<T>;
|
|
1562
|
+
/**
|
|
1563
|
+
* Creates a signal that will only be reactive until the first query is created.
|
|
1564
|
+
* All subsequent changes inside the computation will be ignored.
|
|
1565
|
+
*/
|
|
1566
|
+
export declare function queryComputedTillTruthy<T extends AnyQuery | AnyLegacyQuery | null>(computation: () => T, options?: CreateComputedOptions<T> & QueryContainerConfig & ToObservableOptions): Signal<T | null>;
|
|
1567
|
+
export declare function queryArrayComputed<T extends AnyQuery[] | AnyLegacyQuery[] | null>(computation: () => T, options?: CreateComputedOptions<T> & QueryContainerConfig & ToObservableOptions): Signal<T>;
|
|
1568
|
+
export declare function toQuerySubject<T extends AnyQuery | AnyLegacyQuery | null>(source: Signal<T>, options?: ToObservableOptions & QueryContainerConfig): Observable<T>;
|
|
1569
|
+
export declare function queryStateSignal<T extends Signal<AnyQuery | AnyLegacyQuery | AnyQueryCollection | null>>(source: T, options?: QueryFilterConfig): import("@angular/core").WritableSignal<QueryState<QueryDataOf<QueryOf<ReturnType<T>>>> | null>;
|
|
1570
|
+
export type QueryStateSignal<T extends Signal<AnyQuery | AnyLegacyQuery | AnyQueryCollection | null>> = Signal<QueryDataOf<QueryOf<ReturnType<T>>> | null> & {
|
|
1571
|
+
reset: () => void;
|
|
1572
|
+
};
|
|
1573
|
+
export declare function queryStateResponseSignal<T extends Signal<AnyQuery | AnyLegacyQuery | AnyQueryCollection | null>>(source: T, options?: QueryFilterConfig): QueryStateSignal<T>;
|
|
1574
|
+
export declare function queryStateErrorSignal<T extends Signal<AnyQuery | AnyLegacyQuery | AnyQueryCollection | null>>(source: T): Signal<import("@ethlete/query").RequestError<unknown> | null>;
|
|
1575
|
+
export declare function queryStateLoadingSignal<T extends Signal<AnyQuery | AnyLegacyQuery | AnyQueryCollection | null>>(source: T): Signal<import("@ethlete/query").Loading | null>;
|
|
1576
|
+
export declare const deepFreeze: <T extends Record<string, unknown>>(object: T) => T;
|
|
1577
|
+
/**
|
|
1578
|
+
* Dummy function for providing types while not breaking inference.
|
|
1579
|
+
* **This function always returns null.**
|
|
1580
|
+
* @see https://github.com/microsoft/TypeScript/issues/26242
|
|
1581
|
+
* @returns null
|
|
1582
|
+
*/
|
|
1583
|
+
export declare const def: <Data>() => Data;
|
|
1584
|
+
type LegacyArgumentsOfQueryArgs<T extends QueryArgs> = Omit<T, 'response' | 'headers'> & WithHeaders;
|
|
1585
|
+
type QueryArgsOfLegacyArguments<T extends BaseArguments | undefined, J> = Omit<T, 'mock' | 'headers'> & {
|
|
1586
|
+
headers?: HttpHeaders;
|
|
1587
|
+
response?: J;
|
|
1588
|
+
};
|
|
1589
|
+
type CreateLegacyQueryCreatorOptions<TArgs extends QueryArgs, Response, Store extends EntityStore<unknown>, Data, Id> = {
|
|
1590
|
+
creator: QueryCreator$1<TArgs>;
|
|
1591
|
+
/**
|
|
1592
|
+
* Object containing the query's entity store information.
|
|
1593
|
+
*/
|
|
1594
|
+
entity?: QueryEntityConfig<Store, Data, Response, LegacyArgumentsOfQueryArgs<TArgs>, Id>;
|
|
1595
|
+
};
|
|
1596
|
+
type WithLegacyConfig = {
|
|
1597
|
+
/**
|
|
1598
|
+
* Additional configuration for this query.
|
|
1599
|
+
*/
|
|
1600
|
+
config?: QueryConfig & {
|
|
1601
|
+
/**
|
|
1602
|
+
* If set to true, the query will be destroyed when it either succeeds or fails.
|
|
1603
|
+
*/
|
|
1604
|
+
destroyOnResponse?: boolean;
|
|
1605
|
+
};
|
|
1606
|
+
};
|
|
1607
|
+
type LegacyQueryPrepareFn<Arguments extends BaseArguments | undefined, Response, Route extends RouteType<Arguments>, Store extends EntityStore<unknown>, Data, Id, TNewQuery extends AnyNewQuery> = (args: Arguments & WithHeaders & WithLegacyConfig & WithInjector) => LegacyQuery<Response, Arguments, Route, Store, Data, Id, TNewQuery>;
|
|
1608
|
+
type AnyLegacyQueryCreator = LegacyQueryCreator<any, any, any, any, any>;
|
|
1609
|
+
/**
|
|
1610
|
+
* Creates a legacy query creator.
|
|
1611
|
+
* @deprecated This is a temporary solution to support legacy queries. It will be removed in the future.
|
|
1612
|
+
*/
|
|
1613
|
+
declare class LegacyQueryCreator<TArgs extends QueryArgs, Response extends ResponseType<TArgs>, Store extends EntityStore<unknown>, Id, Data = Response> {
|
|
1614
|
+
options: CreateLegacyQueryCreatorOptions<TArgs, Response, Store, Data, Id>;
|
|
1615
|
+
constructor(options: CreateLegacyQueryCreatorOptions<TArgs, Response, Store, Data, Id>);
|
|
1616
|
+
prepare: LegacyQueryPrepareFn<LegacyArgumentsOfQueryArgs<TArgs>, Response, RouteType<LegacyArgumentsOfQueryArgs<TArgs>>, Store, Data, Id, Query$1<TArgs>>;
|
|
1617
|
+
createSubject: (initialValue?: ReturnType<typeof this.prepare> | null, config?: QueryContainerConfig) => BehaviorSubject<LegacyQuery<Response, LegacyArgumentsOfQueryArgs<TArgs>, RouteType<LegacyArgumentsOfQueryArgs<TArgs>>, Store, Data, Id, Query$1<TArgs>> | null>;
|
|
1618
|
+
createSignal: (initialValue?: ReturnType<typeof this.prepare> | null, config?: QueryContainerConfig) => import("@angular/core").WritableSignal<LegacyQuery<Response, LegacyArgumentsOfQueryArgs<TArgs>, RouteType<LegacyArgumentsOfQueryArgs<TArgs>>, Store, Data, Id, Query$1<TArgs>> | null>;
|
|
1619
|
+
behaviorSubject: (initialValue?: ReturnType<typeof this.prepare> | null, config?: QueryContainerConfig) => BehaviorSubject<LegacyQuery<Response, LegacyArgumentsOfQueryArgs<TArgs>, RouteType<LegacyArgumentsOfQueryArgs<TArgs>>, Store, Data, Id, Query$1<TArgs>> | null>;
|
|
1620
|
+
}
|
|
1621
|
+
declare const createLegacyQueryCreator: <TArgs extends QueryArgs, Response extends ResponseType<TArgs>, Store extends EntityStore<unknown>, Id, Data = Response>(options: CreateLegacyQueryCreatorOptions<TArgs, Response, Store, Data, Id>) => LegacyQueryCreator<TArgs, Response, Store, Id, Data>;
|
|
1622
|
+
export declare const parseHttpErrorCodeToTitleDe: (statusCode: HttpStatusCode) => "Ungültige Anfrage" | "Nicht autorisiert" | "Zahlung erforderlich" | "Verboten" | "Nicht gefunden" | "Methode nicht erlaubt" | "Nicht akzeptabel" | "Proxy-Authentifizierung erforderlich" | "Anforderungszeitüberschreitung" | "Konflikt" | "Weg" | "Länge erforderlich" | "Vorbedingung fehlgeschlagen" | "Nutzlast zu groß" | "URI zu lang" | "Nicht unterstützter Medientyp" | "Bereich nicht zufriedenstellend" | "Erwartung fehlgeschlagen" | "Ich bin eine Teekanne" | "Fehlgeleitete Anfrage" | "Unverarbeitbare Entität" | "Gesperrt" | "Fehlgeschlagene Abhängigkeit" | "Zu früh" | "Upgrade erforderlich" | "Vorbedingung erforderlich" | "Zu viele Anfragen" | "Anforderungskopffelder zu groß" | "Aus rechtlichen Gründen nicht verfügbar" | "Interner Serverfehler" | "Nicht implementiert" | "Schlechtes Gateway" | "Dienst nicht verfügbar" | "Gateway-Zeitüberschreitung" | "HTTP-Version nicht unterstützt" | "Variante verhandelt auch" | "Unzureichender Speicher" | "Schleifenerkennung" | "Nicht erweitert" | "Netzwerkauthentifizierung erforderlich" | "Etwas ist schief gelaufen";
|
|
1623
|
+
export declare const parseHttpErrorCodeToMessageDe: (statusCode: HttpStatusCode) => "Entschuldigung, wir konnten Ihre Anfrage nicht bearbeiten. Bitte versuchen Sie es später erneut." | "Sie sind nicht berechtigt, diese Aktion auszuführen. Bitte melden Sie sich an, um fortzufahren." | "Zur Ausführung dieser Aktion ist eine Zahlung erforderlich." | "Sie haben keine Berechtigung, diese Aktion auszuführen." | "Die angeforderte Ressource wurde nicht gefunden." | "Die angeforderte Methode ist für diese Ressource nicht zulässig." | "Die angeforderte Ressource ist nicht in der Lage, eine Antwort zu generieren, die der Liste der akzeptablen Werte entspricht." | "Zur Ausführung dieser Aktion ist eine Proxy-Authentifizierung erforderlich." | "Der Server hat auf die Anforderung gewartet." | "Die Anforderung steht im Widerspruch zum aktuellen Zustand der Ressource." | "Die angeforderte Ressource ist nicht mehr verfügbar und wird auch nicht mehr verfügbar sein." | "Die Anforderung hat die Länge ihres Inhalts nicht angegeben, die von der angeforderten Ressource benötigt wird." | "Der Server erfüllt eine der Voraussetzungen nicht, die der Anforderer an die Anforderung gestellt hat." | "Die Anforderung ist größer als der Server bereit oder in der Lage ist, zu verarbeiten." | "Die bereitgestellte URL war für den Server zu lang, um sie zu verarbeiten." | "Die Anforderungseinheit hat einen Medientyp, den der Server oder die Ressource nicht unterstützt." | "Der Client hat einen Teil der Datei angefordert, aber der Server kann diesen Teil nicht liefern." | "Der Server kann die Anforderungen des Erwartung-Anforderungskopffelds nicht erfüllen." | "Ich bin eine Teekanne." | "Die Anforderung wurde an einen Server gerichtet, der nicht in der Lage ist, eine Antwort zu generieren." | "Die Anforderung war gut formuliert, konnte aber aufgrund semantischer Fehler nicht befolgt werden." | "Die Ressource, auf die zugegriffen wird, ist gesperrt." | "Die Anforderung ist aufgrund eines Fehlers einer vorherigen Anforderung fehlgeschlagen." | "Der Server ist nicht bereit, die Anforderung zu verarbeiten, weil der Benutzer nicht authentifiziert wurde." | "Der Client sollte zu einem anderen Protokoll wie TLS/1.0 wechseln, das im Upgrade-Anforderungskopffeld angegeben ist." | "Der Ursprungsserver erfordert, dass die Anforderung bedingt ist." | "Sie haben in einer bestimmten Zeit zu viele Anfragen gesendet. Bitte versuchen Sie es später erneut." | "Der Server ist nicht bereit, die Anforderung zu verarbeiten, weil seine Kopffelder zu groß sind." | "Die Ressource ist aufgrund einer rechtlichen Forderung nicht verfügbar." | "Etwas ist schief gelaufen. Bitte versuchen Sie es später erneut." | "Der Server unterstützt die zur Erfüllung der Anforderung erforderliche Funktionalität nicht." | "Der Server kann die Anforderung derzeit nicht bearbeiten, da er vorübergehend überlastet oder gewartet wird." | "Der Server hat beim Versuch, die Anforderung abzuschließen, keine rechtzeitige Antwort vom Server erhalten." | "Der Server unterstützt die in der Anforderung verwendete HTTP-Protokollversion nicht." | "Der Server hat einen internen Konfigurationsfehler: Die ausgewählte Variantenressource ist so konfiguriert, dass sie sich selbst in die transparente Inhaltsverhandlung einbindet, und ist daher kein geeigneter Endpunkt im Verhandlungsprozess." | "Die Methode konnte auf die Ressource nicht angewendet werden, weil der Server nicht in der Lage ist, die für die erfolgreiche Ausführung der Anforderung erforderliche Darstellung zu speichern." | "Der Server hat eine Endlosschleife erkannt, während er die Anforderung verarbeitet." | "Weitere Erweiterungen der Anforderung sind erforderlich, damit der Server sie erfüllen kann." | "Sie müssen sich authentifizieren, um Zugang zum Netzwerk zu erhalten." | "Etwas ist schief gelaufen. Überprüfen Sie Ihre Internetverbindung und versuchen Sie es später erneut.";
|
|
1624
|
+
export declare class ParseHttpErrorCodeToTitleDePipe implements PipeTransform {
|
|
1625
|
+
transform: (statusCode: import("@angular/common/http").HttpStatusCode) => "Ungültige Anfrage" | "Nicht autorisiert" | "Zahlung erforderlich" | "Verboten" | "Nicht gefunden" | "Methode nicht erlaubt" | "Nicht akzeptabel" | "Proxy-Authentifizierung erforderlich" | "Anforderungszeitüberschreitung" | "Konflikt" | "Weg" | "Länge erforderlich" | "Vorbedingung fehlgeschlagen" | "Nutzlast zu groß" | "URI zu lang" | "Nicht unterstützter Medientyp" | "Bereich nicht zufriedenstellend" | "Erwartung fehlgeschlagen" | "Ich bin eine Teekanne" | "Fehlgeleitete Anfrage" | "Unverarbeitbare Entität" | "Gesperrt" | "Fehlgeschlagene Abhängigkeit" | "Zu früh" | "Upgrade erforderlich" | "Vorbedingung erforderlich" | "Zu viele Anfragen" | "Anforderungskopffelder zu groß" | "Aus rechtlichen Gründen nicht verfügbar" | "Interner Serverfehler" | "Nicht implementiert" | "Schlechtes Gateway" | "Dienst nicht verfügbar" | "Gateway-Zeitüberschreitung" | "HTTP-Version nicht unterstützt" | "Variante verhandelt auch" | "Unzureichender Speicher" | "Schleifenerkennung" | "Nicht erweitert" | "Netzwerkauthentifizierung erforderlich" | "Etwas ist schief gelaufen";
|
|
1626
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ParseHttpErrorCodeToTitleDePipe, never>;
|
|
1627
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ParseHttpErrorCodeToTitleDePipe, "parseHttpErrorCodeToTitleDe", true>;
|
|
1628
|
+
}
|
|
1629
|
+
export declare class ParseHttpErrorCodeToMessageDePipe implements PipeTransform {
|
|
1630
|
+
transform: (statusCode: import("@angular/common/http").HttpStatusCode) => "Entschuldigung, wir konnten Ihre Anfrage nicht bearbeiten. Bitte versuchen Sie es später erneut." | "Sie sind nicht berechtigt, diese Aktion auszuführen. Bitte melden Sie sich an, um fortzufahren." | "Zur Ausführung dieser Aktion ist eine Zahlung erforderlich." | "Sie haben keine Berechtigung, diese Aktion auszuführen." | "Die angeforderte Ressource wurde nicht gefunden." | "Die angeforderte Methode ist für diese Ressource nicht zulässig." | "Die angeforderte Ressource ist nicht in der Lage, eine Antwort zu generieren, die der Liste der akzeptablen Werte entspricht." | "Zur Ausführung dieser Aktion ist eine Proxy-Authentifizierung erforderlich." | "Der Server hat auf die Anforderung gewartet." | "Die Anforderung steht im Widerspruch zum aktuellen Zustand der Ressource." | "Die angeforderte Ressource ist nicht mehr verfügbar und wird auch nicht mehr verfügbar sein." | "Die Anforderung hat die Länge ihres Inhalts nicht angegeben, die von der angeforderten Ressource benötigt wird." | "Der Server erfüllt eine der Voraussetzungen nicht, die der Anforderer an die Anforderung gestellt hat." | "Die Anforderung ist größer als der Server bereit oder in der Lage ist, zu verarbeiten." | "Die bereitgestellte URL war für den Server zu lang, um sie zu verarbeiten." | "Die Anforderungseinheit hat einen Medientyp, den der Server oder die Ressource nicht unterstützt." | "Der Client hat einen Teil der Datei angefordert, aber der Server kann diesen Teil nicht liefern." | "Der Server kann die Anforderungen des Erwartung-Anforderungskopffelds nicht erfüllen." | "Ich bin eine Teekanne." | "Die Anforderung wurde an einen Server gerichtet, der nicht in der Lage ist, eine Antwort zu generieren." | "Die Anforderung war gut formuliert, konnte aber aufgrund semantischer Fehler nicht befolgt werden." | "Die Ressource, auf die zugegriffen wird, ist gesperrt." | "Die Anforderung ist aufgrund eines Fehlers einer vorherigen Anforderung fehlgeschlagen." | "Der Server ist nicht bereit, die Anforderung zu verarbeiten, weil der Benutzer nicht authentifiziert wurde." | "Der Client sollte zu einem anderen Protokoll wie TLS/1.0 wechseln, das im Upgrade-Anforderungskopffeld angegeben ist." | "Der Ursprungsserver erfordert, dass die Anforderung bedingt ist." | "Sie haben in einer bestimmten Zeit zu viele Anfragen gesendet. Bitte versuchen Sie es später erneut." | "Der Server ist nicht bereit, die Anforderung zu verarbeiten, weil seine Kopffelder zu groß sind." | "Die Ressource ist aufgrund einer rechtlichen Forderung nicht verfügbar." | "Etwas ist schief gelaufen. Bitte versuchen Sie es später erneut." | "Der Server unterstützt die zur Erfüllung der Anforderung erforderliche Funktionalität nicht." | "Der Server kann die Anforderung derzeit nicht bearbeiten, da er vorübergehend überlastet oder gewartet wird." | "Der Server hat beim Versuch, die Anforderung abzuschließen, keine rechtzeitige Antwort vom Server erhalten." | "Der Server unterstützt die in der Anforderung verwendete HTTP-Protokollversion nicht." | "Der Server hat einen internen Konfigurationsfehler: Die ausgewählte Variantenressource ist so konfiguriert, dass sie sich selbst in die transparente Inhaltsverhandlung einbindet, und ist daher kein geeigneter Endpunkt im Verhandlungsprozess." | "Die Methode konnte auf die Ressource nicht angewendet werden, weil der Server nicht in der Lage ist, die für die erfolgreiche Ausführung der Anforderung erforderliche Darstellung zu speichern." | "Der Server hat eine Endlosschleife erkannt, während er die Anforderung verarbeitet." | "Weitere Erweiterungen der Anforderung sind erforderlich, damit der Server sie erfüllen kann." | "Sie müssen sich authentifizieren, um Zugang zum Netzwerk zu erhalten." | "Etwas ist schief gelaufen. Überprüfen Sie Ihre Internetverbindung und versuchen Sie es später erneut.";
|
|
1631
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ParseHttpErrorCodeToMessageDePipe, never>;
|
|
1632
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ParseHttpErrorCodeToMessageDePipe, "parseHttpErrorCodeToMessageDe", true>;
|
|
1633
|
+
}
|
|
1634
|
+
export declare const parseHttpErrorCodeToTitleEn: (statusCode: HttpStatusCode) => "Bad request" | "Unauthorized" | "Payment required" | "Forbidden" | "Not found" | "Method not allowed" | "Not acceptable" | "Proxy authentication required" | "Request timeout" | "Conflict" | "Gone" | "Length required" | "Precondition failed" | "Payload too large" | "URI too long" | "Unsupported media type" | "Range not satisfiable" | "Expectation failed" | "I am a teapot" | "Misdirected request" | "Unprocessable entity" | "Locked" | "Failed dependency" | "Too early" | "Upgrade required" | "Precondition required" | "Too many requests" | "Request header fields too large" | "Unavailable for legal reasons" | "Internal server error" | "Not implemented" | "Bad gateway" | "Service unavailable" | "Gateway timeout" | "HTTP version not supported" | "Variant also negotiates" | "Insufficient storage" | "Loop detected" | "Not extended" | "Network authentication required" | "Something went wrong";
|
|
1635
|
+
export declare const parseHttpErrorCodeToMessageEn: (statusCode: HttpStatusCode) => "Sorry, we could not process your request. Please try again later." | "You are not authorized to perform this action. Please log in to continue." | "Payment is required to complete this action." | "You do not have permission to perform this action." | "The requested resource was not found." | "The requested method is not allowed for this resource." | "The requested resource is not capable of generating a response matching the list of acceptable values." | "Proxy authentication is required to complete this action." | "The server timed out waiting for the request." | "The request conflicts with the current state of the resource." | "The requested resource is no longer available and will not be available again." | "The request did not specify the length of its content, which is required by the requested resource." | "The server does not meet one of the preconditions that the requester put on the request." | "The request is larger than the server is willing or able to process." | "The URL provided was too long for the server to process." | "The request entity has a media type which the server or resource does not support." | "The client has asked for a portion of the file, but the server cannot supply that portion." | "The server cannot meet the requirements of the Expect request-header field." | "I am a teapot." | "The request was directed at a server that is not able to produce a response." | "The request was well-formed but was unable to be followed due to semantic errors." | "The resource that is being accessed is locked." | "The request failed due to failure of a previous request." | "The server is unwilling to process the request because the user has not been authenticated." | "The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field." | "The origin server requires the request to be conditional." | "You have sent too many requests in a given amount of time. Please try again later." | "The server is unwilling to process the request because its header fields are too large." | "The resource is unavailable due to a legal demand." | "Something went wrong on our end. Please try again later." | "The server does not support the functionality required to fulfill the request." | "The server is currently unable to handle the request due to a temporary overload or maintenance of the server." | "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URL or some other auxiliary server it needed to access in attempting to complete the request." | "The server does not support the HTTP protocol version used in the request." | "The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process." | "The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request." | "The server detected an infinite loop while processing the request." | "Further extensions to the request are required for the server to fulfill it." | "You need to authenticate to gain network access." | "Something went wrong. Check your internet connection and try again later.";
|
|
1636
|
+
export declare class ParseHttpErrorCodeToTitleEnPipe implements PipeTransform {
|
|
1637
|
+
transform: (statusCode: import("@angular/common/http").HttpStatusCode) => "Bad request" | "Unauthorized" | "Payment required" | "Forbidden" | "Not found" | "Method not allowed" | "Not acceptable" | "Proxy authentication required" | "Request timeout" | "Conflict" | "Gone" | "Length required" | "Precondition failed" | "Payload too large" | "URI too long" | "Unsupported media type" | "Range not satisfiable" | "Expectation failed" | "I am a teapot" | "Misdirected request" | "Unprocessable entity" | "Locked" | "Failed dependency" | "Too early" | "Upgrade required" | "Precondition required" | "Too many requests" | "Request header fields too large" | "Unavailable for legal reasons" | "Internal server error" | "Not implemented" | "Bad gateway" | "Service unavailable" | "Gateway timeout" | "HTTP version not supported" | "Variant also negotiates" | "Insufficient storage" | "Loop detected" | "Not extended" | "Network authentication required" | "Something went wrong";
|
|
1638
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ParseHttpErrorCodeToTitleEnPipe, never>;
|
|
1639
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ParseHttpErrorCodeToTitleEnPipe, "parseHttpErrorCodeToTitleEn", true>;
|
|
1640
|
+
}
|
|
1641
|
+
export declare class ParseHttpErrorCodeToMessageEnPipe implements PipeTransform {
|
|
1642
|
+
transform: (statusCode: import("@angular/common/http").HttpStatusCode) => "Sorry, we could not process your request. Please try again later." | "You are not authorized to perform this action. Please log in to continue." | "Payment is required to complete this action." | "You do not have permission to perform this action." | "The requested resource was not found." | "The requested method is not allowed for this resource." | "The requested resource is not capable of generating a response matching the list of acceptable values." | "Proxy authentication is required to complete this action." | "The server timed out waiting for the request." | "The request conflicts with the current state of the resource." | "The requested resource is no longer available and will not be available again." | "The request did not specify the length of its content, which is required by the requested resource." | "The server does not meet one of the preconditions that the requester put on the request." | "The request is larger than the server is willing or able to process." | "The URL provided was too long for the server to process." | "The request entity has a media type which the server or resource does not support." | "The client has asked for a portion of the file, but the server cannot supply that portion." | "The server cannot meet the requirements of the Expect request-header field." | "I am a teapot." | "The request was directed at a server that is not able to produce a response." | "The request was well-formed but was unable to be followed due to semantic errors." | "The resource that is being accessed is locked." | "The request failed due to failure of a previous request." | "The server is unwilling to process the request because the user has not been authenticated." | "The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field." | "The origin server requires the request to be conditional." | "You have sent too many requests in a given amount of time. Please try again later." | "The server is unwilling to process the request because its header fields are too large." | "The resource is unavailable due to a legal demand." | "Something went wrong on our end. Please try again later." | "The server does not support the functionality required to fulfill the request." | "The server is currently unable to handle the request due to a temporary overload or maintenance of the server." | "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URL or some other auxiliary server it needed to access in attempting to complete the request." | "The server does not support the HTTP protocol version used in the request." | "The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process." | "The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request." | "The server detected an infinite loop while processing the request." | "Further extensions to the request are required for the server to fulfill it." | "You need to authenticate to gain network access." | "Something went wrong. Check your internet connection and try again later.";
|
|
1643
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ParseHttpErrorCodeToMessageEnPipe, never>;
|
|
1644
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ParseHttpErrorCodeToMessageEnPipe, "parseHttpErrorCodeToMessageEn", true>;
|
|
1645
|
+
}
|
|
1646
|
+
type CreateWebSocketClientTransport = 'polling' | 'websocket' | 'webtransport';
|
|
1647
|
+
type CreateWebSocketClientConfig = {
|
|
1648
|
+
/** A unique name for the client */
|
|
1649
|
+
name: string;
|
|
1650
|
+
/** The URL of the socket io server */
|
|
1651
|
+
url: string;
|
|
1652
|
+
/** A list of transports to try (in order). Engine.io always attempts to connect directly with the first one, provided the feature detection test for it passes. */
|
|
1653
|
+
transports?: CreateWebSocketClientTransport[];
|
|
1654
|
+
};
|
|
1655
|
+
type WebSocketClientRef<TMessageData extends SocketMessageView = SocketMessageView> = InjectionToken<WebSocketClient<TMessageData>>;
|
|
1656
|
+
type WebSocketClientConfig = CreateWebSocketClientConfig & {
|
|
1657
|
+
/** A generated token for dependency injection */
|
|
1658
|
+
token: WebSocketClientRef;
|
|
1659
|
+
};
|
|
1660
|
+
declare const createWebSocketClientConfig: (options: CreateWebSocketClientConfig) => WebSocketClientConfig;
|
|
1661
|
+
/** A default socket io message view */
|
|
1662
|
+
type SocketMessageView<TMessageData = unknown> = {
|
|
1663
|
+
room: string;
|
|
1664
|
+
event: string;
|
|
1665
|
+
data: TMessageData;
|
|
1666
|
+
};
|
|
1667
|
+
type WebSocketClientSubtle = {
|
|
1668
|
+
/** Leave a socket io room */
|
|
1669
|
+
leaveRoom: (room: string) => void;
|
|
1670
|
+
};
|
|
1671
|
+
type WebSocketClient<TMessageData extends SocketMessageView> = {
|
|
1672
|
+
/**
|
|
1673
|
+
* Join a socket io room
|
|
1674
|
+
* If a function is passed, it will be evaluated in a reactive signal context.
|
|
1675
|
+
* If the function returns null, no room will be joined.
|
|
1676
|
+
* If the function returns a string, the previous room will be left and the new room will be joined.
|
|
1677
|
+
*/
|
|
1678
|
+
joinRoom: (room: string | (() => string | null)) => Signal<WebSocketRoom<TMessageData> | null>;
|
|
1679
|
+
/** Whether the client is connected to the server */
|
|
1680
|
+
isConnected: Signal<boolean>;
|
|
1681
|
+
/** Advanced web socket features. **WARNING!** Incorrectly using these features will likely **BREAK** your application. You have been warned! */
|
|
1682
|
+
subtle: WebSocketClientSubtle;
|
|
1683
|
+
};
|
|
1684
|
+
type InternalWebSocketRoom<TMessageData extends SocketMessageView> = {
|
|
1685
|
+
latestMessage: WritableSignal<TMessageData | null>;
|
|
1686
|
+
};
|
|
1687
|
+
type WebSocketRoom<TMessageData extends SocketMessageView> = {
|
|
1688
|
+
/** The latest message received in the room */
|
|
1689
|
+
latestMessage: Signal<TMessageData | null>;
|
|
1690
|
+
};
|
|
1691
|
+
declare const createWebSocketClient: <TMessageData extends SocketMessageView>(config: WebSocketClientConfig) => WebSocketClient<TMessageData>;
|
|
1692
|
+
declare const provideWebSocketClient: (config: WebSocketClientConfig) => {
|
|
1693
|
+
provide: WebSocketClientRef<SocketMessageView>;
|
|
1694
|
+
useFactory: () => WebSocketClient<SocketMessageView<unknown>>;
|
|
1695
|
+
};
|
|
1696
|
+
declare namespace index_d_exports {
|
|
1697
|
+
export { AnyBearerAuthProviderConfig, AnyLegacyQuery, AnyLegacyQueryCreator, AnyNewQuery, AnyPagedQueryStack, AnyQueryCreator$1 as AnyQueryCreator, AnyQuerySnapshot, AnyQueryStack, BearerAuthProvider$1 as BearerAuthProvider, BearerAuthProviderConfig, BearerAuthProviderCookieConfig, BearerAuthProviderRef, BearerAuthProviderRouteConfig, BearerAuthProviderTokens, BodyType, CLEAR_QUERY_ARGS, CacheAdapterFn$1 as CacheAdapterFn, CleanupPreviousExecuteOptions, ClearQueryArgs, CreateBearerAuthProviderConfigOptions, CreateGqlQueryCreatorOptions, CreateGqlQueryExecuteOptions, CreateGqlQueryOptions, CreateHttpRequestClientOptions, CreateHttpRequestDependencies, CreateHttpRequestOptions, CreateLegacyQueryCreatorOptions, CreateLegacyQueryOptions, CreatePagedQueryStackOptions, CreateQueryClientConfigOptions, CreateQueryCreatorOptions, CreateQueryExecuteOptions, CreateQueryObjectOptions, CreateQueryOptions, CreateQueryRepositoryConfig, CreateQuerySnapshotOptions, CreateQueryStackOptions, CreateSecureQueryExecuteOptions, CreateSecureQueryOptions, CreateWebSocketClientConfig, CreateWebSocketClientTransport, DestroyCleanupCallback, GqlQueryArgs, GqlQueryMethod, GqlQueryTransport, GqlVariablesType, HttpErrorEvent, HttpRequest, HttpRequestLoadingProgressState, HttpRequestLoadingState, HttpRequestResponseType, HttpRequestTransferCacheConfig, InternalCreateGqlQueryCreatorOptions, InternalCreateQueryCreatorOptions, InternalQueryExecute, InternalRunQueryExecuteOptions, InternalSecureCreateQueryCreatorOptions, InternalWebSocketRoom, LegacyArgumentsOfQueryArgs, LegacyQuery, LegacyQueryCreator, LegacyQueryPrepareFn, PagedQueryStack, PagedQueryStackDirection, PagedQueryStackExecuteOptions, PagedQueryStackResetOptions, ParseHttpErrorCodeToMessageDePipe, ParseHttpErrorCodeToMessageEnPipe, ParseHttpErrorCodeToTitleDePipe, ParseHttpErrorCodeToTitleEnPipe, PathParamsType, Query$1 as Query, QueryArgs, QueryArgsOf$1 as QueryArgsOf, QueryArgsOfLegacyArguments, QueryBase, QueryClient$1 as QueryClient, QueryClientConfig$1 as QueryClientConfig, QueryClientRef, QueryConfig$1 as QueryConfig, QueryCreator$1 as QueryCreator, QueryDependencies, QueryErrorResponse, QueryErrorResponseItem, QueryErrorResponseList, QueryErrorResponseSingle, QueryExecute, QueryExecuteArgs, QueryExecuteOptions, QueryExecuteState, QueryExecutionState, QueryExecutionStateFailure, QueryExecutionStateLoading, QueryExecutionStateLoadingWithCachedResponse, QueryExecutionStateLoadingWithNoResponse, QueryExecutionStateSuccess, QueryFeature, QueryFeatureContext, QueryFeatureFlags, QueryFeatureFn, QueryFeatureType, QueryKey, QueryKeyNoCache, QueryKeyOrNone, QueryMethod, QueryParamsType, QueryRepository, QueryRepositoryDependencies, QueryRepositoryItem, QueryRepositoryRequestOptions, QueryRuntimeErrorCode, QuerySnapshot, QueryStack, QueryStackSubtle, QueryState$1 as QueryState, QueryStateSubtle, QuerySubtle, ReadonlyQuery, RequestArgs, ResetExecuteStateOptions, ResponseType, RouteString$1 as RouteString, RouteType$1 as RouteType, RunQueryCreator, RunQueryExecuteOptions, SPEED_BUFFER_TIME_IN_MS, SetupQueryDependenciesOptions, SetupQueryStateOptions, ShouldRetryRequestFn, ShouldRetryRequestOptions, ShouldRetryRequestResult, SocketMessageView, WebSocketClient, WebSocketClientConfig, WebSocketClientRef, WebSocketClientSubtle, WebSocketRoom, WithAutoRefreshFeatureOptions, WithErrorHandlingFeatureOptions, WithLegacyConfig, WithLoggingFeatureOptions, WithPollingFeatureOptions, WithResponseUpdateFeatureFnData, WithResponseUpdateFeatureOptions, WithSuccessHandlingFeatureOptions, applyQueryFeatures, bearerExpiresInPropertyNotNumber, bindSignalToTarget, buildQueryCacheKey$1 as buildQueryCacheKey, circularQueryDependencyChecker, cleanupPreviousExecute, contentfulGqlLikePaginationAdapter, cookieLoginTriedButCookieDisabled, createBearerAuthProvider, createBearerAuthProviderConfig, createDeleteQuery, createExecuteFn, createGetQuery, createGqlExecuteFn, createGqlMutationViaGet, createGqlMutationViaPost, createGqlQuery, createGqlQueryCreator, createGqlQueryViaGet, createGqlQueryViaPost, createHttpRequest, createLegacyQueryCreator, createPagedQueryStack, createPatchQuery, createPostQuery, createPutQuery, createQuery, createQueryClient, createQueryClientConfig, createQueryCreator, createQueryErrorResponse, createQueryFeature, createQueryObject, createQueryRepository, createQuerySnapshotFn, createQueryStack, createSecureDeleteQuery, createSecureExecuteFn, createSecureGetQuery, createSecurePatchQuery, createSecurePostQuery, createSecurePutQuery, createSecureQuery, createSecureQueryCreator, createWebSocketClient, createWebSocketClientConfig, defaultResponseTransformerResponseNotContainingAccessToken, defaultResponseTransformerResponseNotContainingRefreshToken, defaultResponseTransformerResponseNotObject, disableCookieCalledWithoutCookieConfig, dynLikePaginationAdapter, enableCookieCalledWithoutCookieConfig, ethletePaginationAdapter, extractExpiresInSeconds$1 as extractExpiresInSeconds, fakePaginationAdapter, getQueryFeatureUsage, ggLikePaginationAdapter, isCreateGqlQueryOptions, isLegacyQuery, loginCalledWithoutConfig, loginWithTokenCalledWithoutConfig, maybeExecute, nestedEffect, normalizeQueryRepositoryKey, pagedQueryStackNextPageCalledWithoutPreviousPage, pagedQueryStackPageBiggerThanTotalPages, pagedQueryStackPreviousPageCalledButAlreadyAtFirstPage, parseHttpErrorCodeToMessageDe, parseHttpErrorCodeToMessageEn, parseHttpErrorCodeToTitleDe, parseHttpErrorCodeToTitleEn, provideBearerAuthProvider, provideQueryClient, provideWebSocketClient, queryExecute, queryFeatureUsedMultipleTimes, queryStackTotalQueriesAndExpectedQueriesMismatch, queryStackWithArgsUsed, queryStackWithResponseUpdateUsed, refreshTokenCalledWithoutConfig, resetExecuteState, selectRoleCalledWithoutConfig, setupQueryDependencies, setupQueryExecuteState, setupQueryState, shouldAutoExecuteGqlQuery, shouldAutoExecuteQuery, shouldCacheQuery$1 as shouldCacheQuery, shouldRetryRequest$1 as shouldRetryRequest, silenceMissingWithArgsFeatureErrorUsedButWithArgsPresent, splitQueryConfig, transformArrayResponse, transformExecStateToQueryState, transformPaginatedResponse, unableToDecryptBearerToken, uncacheableRequestHasAllowCacheParam, uncacheableRequestHasCacheKeyParam, withArgs, withArgsQueryFeatureMissingButRouteIsFunction, withAutoRefresh, withAutoRefreshUsedInManualQuery, withAutoRefreshUsedOnUnsupportedHttpMethod, withErrorHandling, withLogging, withPolling, withPollingUsedOnUnsupportedHttpMethod, withResponseUpdate, withSuccessHandling };
|
|
1698
|
+
}
|
|
1699
|
+
export interface QueryFieldOptions<T = unknown> {
|
|
1700
|
+
/**
|
|
1701
|
+
* The default value of the field.
|
|
1702
|
+
* Will be set to the initial value of the form control if not specified.
|
|
1703
|
+
* If a function is provided, it will be called to get the default value.
|
|
1704
|
+
*/
|
|
1705
|
+
defaultValue?: T | (() => T) | null;
|
|
1706
|
+
/**
|
|
1707
|
+
* Debounce time in milliseconds.
|
|
1708
|
+
*/
|
|
1709
|
+
debounce?: number;
|
|
1710
|
+
/**
|
|
1711
|
+
* Whether the debounce should not be applied if the value is falsy.
|
|
1712
|
+
* This is useful for fields that can be cleared like a search field.
|
|
1713
|
+
*
|
|
1714
|
+
* @default false
|
|
1715
|
+
*/
|
|
1716
|
+
disableDebounceIfFalsy?: boolean;
|
|
1717
|
+
/**
|
|
1718
|
+
* The form control for the field.
|
|
1719
|
+
*/
|
|
1720
|
+
control: FormControl<T | null>;
|
|
1721
|
+
/**
|
|
1722
|
+
* Append the field's value to the url.
|
|
1723
|
+
*
|
|
1724
|
+
* The field wont be appended to the url if one of the following is true:
|
|
1725
|
+
* - It is the default value and `appendDefaultValueToUrl` is `false`
|
|
1726
|
+
* - It is an empty string
|
|
1727
|
+
* - It is `null`
|
|
1728
|
+
* - It is `undefined`
|
|
1729
|
+
*
|
|
1730
|
+
* @default true
|
|
1731
|
+
*/
|
|
1732
|
+
appendToUrl?: boolean;
|
|
1733
|
+
/**
|
|
1734
|
+
* Append the field's value to the url even if it is the default value.
|
|
1735
|
+
* Will be ignored if `appendToUrl` is `false`.
|
|
1736
|
+
*
|
|
1737
|
+
* @default false
|
|
1738
|
+
*/
|
|
1739
|
+
appendDefaultValueToUrl?: boolean;
|
|
1740
|
+
/**
|
|
1741
|
+
* Reset the field's value to the default value if one or more of the specified fields are changed.
|
|
1742
|
+
*
|
|
1743
|
+
* @example
|
|
1744
|
+
* // Given this field is a `page` field, the field will be reset if the `limit`, `query` or `search` fields are changed.
|
|
1745
|
+
* ['limit', 'query', 'search']
|
|
1746
|
+
*/
|
|
1747
|
+
isResetBy?: string | string[];
|
|
1748
|
+
/**
|
|
1749
|
+
* Whether the field should change the count of current active filters.
|
|
1750
|
+
*
|
|
1751
|
+
* Will be `true` for these common fields:
|
|
1752
|
+
* - `page`
|
|
1753
|
+
* - `skip`
|
|
1754
|
+
* - `take`
|
|
1755
|
+
* - `limit`
|
|
1756
|
+
* - `sort`
|
|
1757
|
+
* - `sortBy`
|
|
1758
|
+
* - `sortOrder`
|
|
1759
|
+
* - `query`
|
|
1760
|
+
* - `search`
|
|
1761
|
+
* @default false
|
|
1762
|
+
*/
|
|
1763
|
+
skipInFilterCount?: boolean;
|
|
1764
|
+
/**
|
|
1765
|
+
* By default, the field's string value is transformed to it's matching primitive type.
|
|
1766
|
+
* Meaning that a string `'true'` will be transformed to a boolean `true` and a string `'5'` will be transformed to a number `5`.
|
|
1767
|
+
* If this is set to `true`, the field's value will not be transformed.
|
|
1768
|
+
*
|
|
1769
|
+
* @default false
|
|
1770
|
+
*/
|
|
1771
|
+
skipAutoTransform?: boolean;
|
|
1772
|
+
/**
|
|
1773
|
+
* A function that transforms the the value gotten from the url query params to a value required by the field.
|
|
1774
|
+
* E.g. for a number field, the value from the url query params is a string, but the field requires a number.
|
|
1775
|
+
*
|
|
1776
|
+
* The following common transformations are already implemented:
|
|
1777
|
+
* - `transformToString`
|
|
1778
|
+
* - `transformToStringArray`
|
|
1779
|
+
* - `transformToNumber`
|
|
1780
|
+
* - `transformToNumberArray`
|
|
1781
|
+
* - `transformToBoolean`
|
|
1782
|
+
* - `transformToBooleanArray`
|
|
1783
|
+
* - `transformToDate` (expects a string in the default js format)
|
|
1784
|
+
* - `transformToDateArray` (expects strings in the default js format)
|
|
1785
|
+
* - `transformToSort` (expects a string in the format `field:direction`)
|
|
1786
|
+
*/
|
|
1787
|
+
queryParamToValueTransformFn?: (val: unknown) => T | null;
|
|
1788
|
+
/**
|
|
1789
|
+
* A function that transforms the value of the field to a value that can be appended to the url query params.
|
|
1790
|
+
*
|
|
1791
|
+
* The following common transformations are already implemented:
|
|
1792
|
+
* - `transformToSortQueryParam` (returns an object containing `field` and `direction` properties)
|
|
1793
|
+
*/
|
|
1794
|
+
valueToQueryParamTransformFn?: (val: T | null) => unknown;
|
|
1795
|
+
}
|
|
1796
|
+
export type OptionalQueryFieldOptions<T = string> = Partial<QueryFieldOptions<T>>;
|
|
1797
|
+
export type QueryFormGroupControls<T extends Record<string, QueryField<any>>> = { [Property in keyof T]: T[Property]['control']; };
|
|
1798
|
+
export type QueryFormValue<T extends Record<string, QueryField<any>>> = { [Property in keyof T]: T[Property]['control']['value']; };
|
|
1799
|
+
export type QueryFormOf<T extends FormGroup> = { [K in keyof T['controls']]: QueryField<T['controls'][K]['value']>; };
|
|
1800
|
+
export interface QueryFormGroup extends FormGroup {
|
|
1801
|
+
_setValue: FormGroup['setValue'];
|
|
1802
|
+
_patchValue: FormGroup['patchValue'];
|
|
1803
|
+
setValue(value: unknown, options?: QueryFormWriteOptions): void;
|
|
1804
|
+
patchValue(value: unknown, options?: QueryFormWriteOptions): void;
|
|
1805
|
+
}
|
|
1806
|
+
export interface QueryFormObserveOptions {
|
|
1807
|
+
/**
|
|
1808
|
+
* Whether the form value should be synced to the url query params.
|
|
1809
|
+
* @default true
|
|
1810
|
+
*/
|
|
1811
|
+
writeToQueryParams?: boolean;
|
|
1812
|
+
/**
|
|
1813
|
+
* Whether the form value should be updated when the url query params change.
|
|
1814
|
+
* @default true
|
|
1815
|
+
*/
|
|
1816
|
+
syncOnNavigation?: boolean;
|
|
1817
|
+
/**
|
|
1818
|
+
* If true, the navigation will not create a new entry in the browser's history.
|
|
1819
|
+
* @default false
|
|
1820
|
+
*/
|
|
1821
|
+
replaceUrl?: boolean;
|
|
1822
|
+
}
|
|
1823
|
+
export interface QueryFormValueEvent<T extends Record<string, QueryField<any>>> {
|
|
1824
|
+
previousValue: QueryFormValue<T> | null;
|
|
1825
|
+
currentValue: QueryFormValue<T>;
|
|
1826
|
+
}
|
|
1827
|
+
export interface QueryFormWriteOptions {
|
|
1828
|
+
/**
|
|
1829
|
+
* When true, each change only affects this control, and not its parent.
|
|
1830
|
+
* @default false
|
|
1831
|
+
*/
|
|
1832
|
+
onlySelf?: boolean;
|
|
1833
|
+
/**
|
|
1834
|
+
* When true or not supplied (the default), both the `statusChanges` and `valueChanges`
|
|
1835
|
+
* observables emit events with the latest status and value when the control value is updated.
|
|
1836
|
+
* When false, no events are emitted.
|
|
1837
|
+
* @default true
|
|
1838
|
+
*/
|
|
1839
|
+
emitEvent?: boolean;
|
|
1840
|
+
/**
|
|
1841
|
+
* When true, the `resetBy` conditions will be ignored for this write.
|
|
1842
|
+
* @default false
|
|
1843
|
+
*/
|
|
1844
|
+
skipResets?: boolean;
|
|
1845
|
+
}
|
|
1846
|
+
export declare const transformToString: (value: unknown) => string | null;
|
|
1847
|
+
export declare const transformToStringArray: (value: unknown) => string[] | null;
|
|
1848
|
+
export declare const transformToNumber: (value: unknown) => number | null;
|
|
1849
|
+
export declare const transformToNumberArray: (value: unknown) => number[] | null;
|
|
1850
|
+
export declare const transformToBoolean: (value: unknown) => boolean | null;
|
|
1851
|
+
export declare const transformToBooleanArray: (value: unknown) => boolean[] | null;
|
|
1852
|
+
export declare const transformToDate: (value: unknown) => Date | null;
|
|
1853
|
+
export declare const transformToDateArray: (value: unknown) => Date[] | null;
|
|
1854
|
+
export type SortDirection = 'asc' | 'desc' | '';
|
|
1855
|
+
export interface Sort {
|
|
1856
|
+
active: string;
|
|
1857
|
+
direction: SortDirection;
|
|
1858
|
+
}
|
|
1859
|
+
export declare const transformToSort: (value: unknown) => Sort | null;
|
|
1860
|
+
export declare const transformToSortQueryParam: (value: unknown) => string | null;
|
|
1861
|
+
export declare class QueryField<T> {
|
|
1862
|
+
data: QueryFieldOptions<T>;
|
|
1863
|
+
get control(): FormControl<T | null>;
|
|
1864
|
+
constructor(data: QueryFieldOptions<T>);
|
|
1865
|
+
}
|
|
1866
|
+
export declare class SearchQueryField {
|
|
1867
|
+
_data?: OptionalQueryFieldOptions<string | null> | undefined;
|
|
1868
|
+
get control(): FormControl<string | null>;
|
|
1869
|
+
data: QueryFieldOptions<string | null>;
|
|
1870
|
+
constructor(_data?: OptionalQueryFieldOptions<string | null> | undefined);
|
|
1871
|
+
}
|
|
1872
|
+
export declare class SortQueryField {
|
|
1873
|
+
_data?: OptionalQueryFieldOptions<Sort | null> | undefined;
|
|
1874
|
+
get control(): FormControl<Sort | null>;
|
|
1875
|
+
data: QueryFieldOptions<Sort | null>;
|
|
1876
|
+
constructor(_data?: OptionalQueryFieldOptions<Sort | null> | undefined);
|
|
1877
|
+
}
|
|
1878
|
+
export declare class StringArrayQueryField<T extends string[]> {
|
|
1879
|
+
_data?: OptionalQueryFieldOptions<T | null> | undefined;
|
|
1880
|
+
get control(): FormControl<T | null>;
|
|
1881
|
+
data: QueryFieldOptions<T | null>;
|
|
1882
|
+
constructor(_data?: OptionalQueryFieldOptions<T | null> | undefined);
|
|
1883
|
+
}
|
|
1884
|
+
export declare class BooleanArrayQueryField {
|
|
1885
|
+
_data?: OptionalQueryFieldOptions<boolean[] | null> | undefined;
|
|
1886
|
+
get control(): FormControl<boolean[] | null>;
|
|
1887
|
+
data: QueryFieldOptions<boolean[] | null>;
|
|
1888
|
+
constructor(_data?: OptionalQueryFieldOptions<boolean[] | null> | undefined);
|
|
1889
|
+
}
|
|
1890
|
+
export declare class NumberArrayQueryField {
|
|
1891
|
+
_data?: OptionalQueryFieldOptions<number[] | null> | undefined;
|
|
1892
|
+
get control(): FormControl<number[] | null>;
|
|
1893
|
+
data: QueryFieldOptions<number[] | null>;
|
|
1894
|
+
constructor(_data?: OptionalQueryFieldOptions<number[] | null> | undefined);
|
|
1895
|
+
}
|
|
1896
|
+
export declare class DateQueryField {
|
|
1897
|
+
_data?: OptionalQueryFieldOptions<Date | null> | undefined;
|
|
1898
|
+
get control(): FormControl<Date | null>;
|
|
1899
|
+
data: QueryFieldOptions<Date | null>;
|
|
1900
|
+
constructor(_data?: OptionalQueryFieldOptions<Date | null> | undefined);
|
|
1901
|
+
}
|
|
1902
|
+
export declare class DateArrayQueryField {
|
|
1903
|
+
_data?: OptionalQueryFieldOptions<Date[] | null> | undefined;
|
|
1904
|
+
get control(): FormControl<Date[] | null>;
|
|
1905
|
+
data: QueryFieldOptions<Date[] | null>;
|
|
1906
|
+
constructor(_data?: OptionalQueryFieldOptions<Date[] | null> | undefined);
|
|
1907
|
+
}
|
|
1908
|
+
export interface QueryFormOptions {
|
|
1909
|
+
/**
|
|
1910
|
+
* A prefix to use for the query parameters. This is useful when you have multiple query forms on the same page.
|
|
1911
|
+
*/
|
|
1912
|
+
queryParamPrefix?: string | (() => string);
|
|
1913
|
+
}
|
|
1914
|
+
export type AnyQueryForm = QueryForm<any>;
|
|
1915
|
+
export declare class QueryForm<T extends Record<string, QueryField<any>>> {
|
|
1916
|
+
private _fields;
|
|
1917
|
+
private _options?;
|
|
1918
|
+
private readonly _destroy$;
|
|
1919
|
+
private readonly _unobserveTrigger$;
|
|
1920
|
+
private readonly _router;
|
|
1921
|
+
private readonly _activatedRoute;
|
|
1922
|
+
private readonly _defaultValues;
|
|
1923
|
+
private readonly _zone;
|
|
1924
|
+
private readonly _didValueChanges$;
|
|
1925
|
+
private _isObserving;
|
|
1926
|
+
private _skipNextResets;
|
|
1927
|
+
private _queryParamChanges$;
|
|
1928
|
+
private _queryParams;
|
|
1929
|
+
/**
|
|
1930
|
+
* The angular form group that contains all the fields.
|
|
1931
|
+
*
|
|
1932
|
+
* **Do not** use any of the following methods on this form group:
|
|
1933
|
+
* - `setValue`: Use `QueryForm.setValue` instead.
|
|
1934
|
+
* - `patchValue`: Use `QueryForm.patchValue` instead.
|
|
1935
|
+
* - `valueChanges`: Use `QueryForm.changes$` instead.
|
|
1936
|
+
* - `value`: Use `QueryForm.value` instead.
|
|
1937
|
+
* - `controls`: Use `QueryForm.controls` instead.
|
|
1938
|
+
*/
|
|
1939
|
+
readonly form: FormGroup<QueryFormGroupControls<T>>;
|
|
1940
|
+
private readonly _lastFormValue$;
|
|
1941
|
+
private readonly _currentFormValue$;
|
|
1942
|
+
private get _formValue();
|
|
1943
|
+
private get _form();
|
|
1944
|
+
private readonly _changes$;
|
|
1945
|
+
readonly changes$: import("rxjs").Observable<QueryFormValueEvent<T>>;
|
|
1946
|
+
readonly currentValue$: import("rxjs").Observable<QueryFormValue<T>>;
|
|
1947
|
+
readonly previousValue$: import("rxjs").Observable<QueryFormValue<T> | null>;
|
|
1948
|
+
readonly changes: import("@angular/core").Signal<QueryFormValueEvent<T> | undefined>;
|
|
1949
|
+
readonly currentValue: import("@angular/core").Signal<QueryFormValue<T> | undefined>;
|
|
1950
|
+
readonly previousValue: import("@angular/core").Signal<QueryFormValue<T> | null | undefined>;
|
|
1951
|
+
/**
|
|
1952
|
+
* The number of active filters.
|
|
1953
|
+
*
|
|
1954
|
+
* Excludes the following fields by default:
|
|
1955
|
+
* - `page`
|
|
1956
|
+
* - `skip`
|
|
1957
|
+
* - `take`
|
|
1958
|
+
* - `limit`
|
|
1959
|
+
* - `sort`
|
|
1960
|
+
* - `sortBy`
|
|
1961
|
+
* - `sortOrder`
|
|
1962
|
+
* - `query`
|
|
1963
|
+
* - `search`
|
|
1964
|
+
*/
|
|
1965
|
+
readonly activeFilterCount$: import("rxjs").Observable<number>;
|
|
1966
|
+
get controls(): 0 extends 1 & QueryFormGroupControls<T> ? {
|
|
1967
|
+
[key: string]: import("@angular/forms").AbstractControl<any, any, any>;
|
|
1968
|
+
} : QueryFormGroupControls<T>;
|
|
1969
|
+
get value(): QueryFormValue<T>;
|
|
1970
|
+
get defaultFormValue(): QueryFormValue<T>;
|
|
1971
|
+
constructor(_fields: T, _options?: QueryFormOptions | undefined);
|
|
1972
|
+
observe(options?: QueryFormObserveOptions): this;
|
|
1973
|
+
private _handleQueryFormResets;
|
|
1974
|
+
unobserve(): void;
|
|
1975
|
+
setFormValueFromUrlQueryParams(options: {
|
|
1976
|
+
queryParams: Record<string, unknown>;
|
|
1977
|
+
}): boolean;
|
|
1978
|
+
setValue(value: QueryFormValue<T>, options?: QueryFormWriteOptions): void;
|
|
1979
|
+
patchValue(value: Partial<QueryFormValue<T>>, options?: QueryFormWriteOptions): void;
|
|
1980
|
+
resetFieldToDefault(key: keyof QueryFormValue<T>, options?: QueryFormWriteOptions): void;
|
|
1981
|
+
resetFieldsToDefault(keys: (keyof QueryFormValue<T>)[], options?: QueryFormWriteOptions): void;
|
|
1982
|
+
resetAllFieldsToDefault(options?: QueryFormWriteOptions & {
|
|
1983
|
+
skipFields?: (keyof QueryFormValue<T>)[];
|
|
1984
|
+
}): void;
|
|
1985
|
+
private _getDefaultValue;
|
|
1986
|
+
private _transformKeyToQueryParam;
|
|
1987
|
+
private _isDefaultValue;
|
|
1988
|
+
private _setupFormGroup;
|
|
1989
|
+
private _extractDefaultValues;
|
|
1990
|
+
private _syncViaUrlQueryParams;
|
|
1991
|
+
private _handleFormChange;
|
|
1992
|
+
private _cleanup;
|
|
1993
|
+
}
|
|
1994
|
+
export interface QueryAutoRefreshConfig {
|
|
1995
|
+
/**
|
|
1996
|
+
* Refresh the query when the query client's headers change.
|
|
1997
|
+
* @default true
|
|
1998
|
+
*/
|
|
1999
|
+
queryClientDefaultHeadersChange?: boolean;
|
|
2000
|
+
/**
|
|
2001
|
+
* Refresh the query when the window regains focus.
|
|
2002
|
+
*
|
|
2003
|
+
* This can only be disabled if `autoRefreshQueriesOnWindowFocus` is enabled on the query client.
|
|
2004
|
+
* @default true
|
|
2005
|
+
*/
|
|
2006
|
+
windowFocus?: boolean;
|
|
2007
|
+
}
|
|
2008
|
+
export interface EntitySetParams<Store, Response, Arguments, Id> {
|
|
2009
|
+
/**
|
|
2010
|
+
* The response data.
|
|
2011
|
+
*/
|
|
2012
|
+
response: Response;
|
|
2013
|
+
/**
|
|
2014
|
+
* The id(s) returned by the `id` function.
|
|
2015
|
+
*/
|
|
2016
|
+
id: Id;
|
|
2017
|
+
/**
|
|
2018
|
+
* The arguments passed to the query.
|
|
2019
|
+
*/
|
|
2020
|
+
args: Arguments;
|
|
2021
|
+
/**
|
|
2022
|
+
* The entity store.
|
|
2023
|
+
*/
|
|
2024
|
+
store: Store;
|
|
2025
|
+
}
|
|
2026
|
+
export interface EntityGetParams<Store, Response, Arguments, Id> {
|
|
2027
|
+
/**
|
|
2028
|
+
* The response data.
|
|
2029
|
+
*/
|
|
2030
|
+
response: Response;
|
|
2031
|
+
/**
|
|
2032
|
+
* The id(s) returned by the `id` function.
|
|
2033
|
+
*/
|
|
2034
|
+
id: Id;
|
|
2035
|
+
/**
|
|
2036
|
+
* The arguments passed to the query.
|
|
2037
|
+
*/
|
|
2038
|
+
args: Arguments;
|
|
2039
|
+
/**
|
|
2040
|
+
* The entity store.
|
|
2041
|
+
*/
|
|
2042
|
+
store: Store;
|
|
2043
|
+
}
|
|
2044
|
+
export interface EntityIdParams<Response, Arguments> {
|
|
2045
|
+
/**
|
|
2046
|
+
* The response data.
|
|
2047
|
+
*/
|
|
2048
|
+
response: Response;
|
|
2049
|
+
/**
|
|
2050
|
+
* The arguments passed to the query.
|
|
2051
|
+
*/
|
|
2052
|
+
args: Arguments;
|
|
2053
|
+
}
|
|
2054
|
+
export interface QueryEntityConfig<Store, Data, Response, Arguments, Id> {
|
|
2055
|
+
/**
|
|
2056
|
+
* The entity store to use for the query.
|
|
2057
|
+
*/
|
|
2058
|
+
store: Store;
|
|
2059
|
+
/**
|
|
2060
|
+
* A function that returns the id of the entity. Can also return an array of ids.
|
|
2061
|
+
*/
|
|
2062
|
+
id: (data: EntityIdParams<Response, Arguments>) => Id;
|
|
2063
|
+
/**
|
|
2064
|
+
* A function that returns the response data (can be a subset of the response).
|
|
2065
|
+
*/
|
|
2066
|
+
get?: (data: EntityGetParams<Store, Response, Arguments, Id>) => Observable<Data>;
|
|
2067
|
+
/**
|
|
2068
|
+
* A function to update the entity store every time a new response is received.
|
|
2069
|
+
*/
|
|
2070
|
+
set?: (data: EntitySetParams<Store, Response, Arguments, Id>) => void;
|
|
2071
|
+
}
|
|
2072
|
+
export type QueryConfigBase<Response, Arguments extends BaseArguments | undefined, Store extends EntityStore<unknown>, Data, Id> = {
|
|
2073
|
+
/**
|
|
2074
|
+
* The http method to use for the query.
|
|
2075
|
+
*/
|
|
2076
|
+
method: Method;
|
|
2077
|
+
/**
|
|
2078
|
+
* Determines if the auth provider should be used for this query.
|
|
2079
|
+
* The query **will throw** if the query client's auth provider is unset.
|
|
2080
|
+
*/
|
|
2081
|
+
secure?: boolean;
|
|
2082
|
+
/**
|
|
2083
|
+
* Determines if the query should emit progress events.
|
|
2084
|
+
*/
|
|
2085
|
+
reportProgress?: boolean;
|
|
2086
|
+
/**
|
|
2087
|
+
* Determines the query's response type.
|
|
2088
|
+
* @default 'json'
|
|
2089
|
+
*/
|
|
2090
|
+
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
|
2091
|
+
/**
|
|
2092
|
+
* Whether this request should be sent with outgoing credentials (cookies).
|
|
2093
|
+
* @default false
|
|
2094
|
+
*/
|
|
2095
|
+
withCredentials?: boolean;
|
|
2096
|
+
/**
|
|
2097
|
+
* Configuration for handling auto refresh triggers.
|
|
2098
|
+
*
|
|
2099
|
+
* **Note:** This is only available for queries that can be refreshed. (`GET`, `HEAD`, `OPTIONS`, `GQL_QUERY`)
|
|
2100
|
+
*/
|
|
2101
|
+
autoRefreshOn?: QueryAutoRefreshConfig;
|
|
2102
|
+
/**
|
|
2103
|
+
* Whether to automatically stop polling for this query when the window loses focus.
|
|
2104
|
+
* Polling will resume when the window regains focus.
|
|
2105
|
+
*
|
|
2106
|
+
* This can only be disabled if `enableSmartPolling` is enabled on the query client.
|
|
2107
|
+
* @default true
|
|
2108
|
+
*/
|
|
2109
|
+
enableSmartPolling?: boolean;
|
|
2110
|
+
/**
|
|
2111
|
+
* Object containing the query's type information.
|
|
2112
|
+
*/
|
|
2113
|
+
types?: {
|
|
2114
|
+
/**
|
|
2115
|
+
* The type of the successful response.
|
|
2116
|
+
*/
|
|
2117
|
+
response?: Response;
|
|
2118
|
+
/**
|
|
2119
|
+
* Arguments for executing the query.
|
|
2120
|
+
*
|
|
2121
|
+
* - `pathParams`: The path parameters for the query. (in front of the ? in the url)
|
|
2122
|
+
* - `queryParams`: The query parameters for the query. (after the ? in the url)
|
|
2123
|
+
* - `body`: The body for the query. Unavailable for GET, HEAD and OPTIONS requests.
|
|
2124
|
+
* - `headers`: The headers for the query.
|
|
2125
|
+
* - `variables`: The variables for the query. (graphql only)
|
|
2126
|
+
*/
|
|
2127
|
+
args?: Arguments;
|
|
2128
|
+
};
|
|
2129
|
+
/**
|
|
2130
|
+
* Object containing the query's entity store information.
|
|
2131
|
+
*/
|
|
2132
|
+
entity?: QueryEntityConfig<Store, Data, Response, Arguments, Id>;
|
|
2133
|
+
};
|
|
2134
|
+
export type RestQueryConfig<Route extends RouteType<Arguments>, Response, Arguments extends BaseArguments | undefined, Store extends EntityStore<unknown>, Data, Id> = QueryConfigBase<Response, Arguments, Store, Data, Id> & {
|
|
2135
|
+
/**
|
|
2136
|
+
* The api route to use for the query.
|
|
2137
|
+
*/
|
|
2138
|
+
route: Route;
|
|
2139
|
+
};
|
|
2140
|
+
export type GqlTransferOption = 'GET' | 'POST';
|
|
2141
|
+
export interface GqlQueryConfig<Route extends RouteType<Arguments> | undefined, Response, Arguments extends BaseArguments | undefined, Store extends EntityStore<unknown>, Data, Id> extends QueryConfigBase<Response, Arguments, Store, Data, Id> {
|
|
2142
|
+
/**
|
|
2143
|
+
* The graphql query to use for the query.
|
|
2144
|
+
*/
|
|
2145
|
+
query: string;
|
|
2146
|
+
/**
|
|
2147
|
+
* Determines if the query should be sent via GET or POST.
|
|
2148
|
+
* - `GET`: The query will be sent via query parameters.
|
|
2149
|
+
* - `POST`: The query will be sent via the body.
|
|
2150
|
+
* @default 'POST'
|
|
2151
|
+
*/
|
|
2152
|
+
transferVia?: GqlTransferOption;
|
|
2153
|
+
/**
|
|
2154
|
+
* Subroute to use for the query.
|
|
2155
|
+
*/
|
|
2156
|
+
route?: Route;
|
|
2157
|
+
}
|
|
2158
|
+
export type AnyRestQueryConfig = RestQueryConfig<any, any, any, any, any, any>;
|
|
2159
|
+
export type AnyGqlQueryConfig = GqlQueryConfig<any, any, any, any, any, any>;
|
|
2160
|
+
export type QueryConfigWithoutMethod<Route extends RouteType<Arguments>, Response, Arguments extends BaseArguments | undefined, Store extends EntityStore<unknown>, Data, Id> = Omit<RestQueryConfig<Route, Response, Arguments, Store, Data, Id>, 'method'>;
|
|
2161
|
+
export type GqlQueryConfigWithoutMethod<Route extends RouteType<Arguments>, Response, Arguments extends BaseArguments | undefined, Store extends EntityStore<unknown>, Data, Id> = Omit<GqlQueryConfig<Route, Response, Arguments, Store, Data, Id>, 'method'>;
|
|
2162
|
+
export type BaseArguments = WithHeaders & WithVariables & WithBody & WithQueryParams & WithPathParams & WithMock<unknown>;
|
|
2163
|
+
export interface WithHeaders {
|
|
2164
|
+
/**
|
|
2165
|
+
* The headers to send with the query.
|
|
2166
|
+
*/
|
|
2167
|
+
headers?: Record<string, string>;
|
|
2168
|
+
}
|
|
2169
|
+
export interface QueryMockConfig<MockResponse> {
|
|
2170
|
+
/**
|
|
2171
|
+
* The mock response to use for the query.
|
|
2172
|
+
*/
|
|
2173
|
+
response?: MockResponse;
|
|
2174
|
+
/**
|
|
2175
|
+
* The mock error to use for the query.
|
|
2176
|
+
*/
|
|
2177
|
+
error?: RequestError;
|
|
2178
|
+
/**
|
|
2179
|
+
* The delay in milliseconds to wait before resolving the mock.
|
|
2180
|
+
* If progress is enabled, the delay will be used for each progress event.
|
|
2181
|
+
* @default 200
|
|
2182
|
+
*/
|
|
2183
|
+
delay?: number;
|
|
2184
|
+
/**
|
|
2185
|
+
* Whether to report progress for the mock.
|
|
2186
|
+
* For testing e.g. file uploads.
|
|
2187
|
+
*/
|
|
2188
|
+
progress?: {
|
|
2189
|
+
/**
|
|
2190
|
+
* The number of progress events to report.
|
|
2191
|
+
* @default 5
|
|
2192
|
+
*/
|
|
2193
|
+
eventCount?: number;
|
|
2194
|
+
/**
|
|
2195
|
+
* The type of progress event to report.
|
|
2196
|
+
* @default 'upload'
|
|
2197
|
+
*/
|
|
2198
|
+
eventType?: 'download' | 'upload';
|
|
2199
|
+
/**
|
|
2200
|
+
* The total size of the file to report progress for in bytes.
|
|
2201
|
+
* @default 1_000_000 (1MB)
|
|
2202
|
+
*/
|
|
2203
|
+
fileSize?: number;
|
|
2204
|
+
/**
|
|
2205
|
+
* If true, the total size of the file will be omitted from the progress event.
|
|
2206
|
+
* Useful for testing e.g. download progress when the server does not provide a total size.
|
|
2207
|
+
*/
|
|
2208
|
+
omitTotal?: boolean;
|
|
2209
|
+
/**
|
|
2210
|
+
* If true, the partial text will be omitted from the progress event.
|
|
2211
|
+
* Useful for testing e.g. download progress when the server does not provide a partial text.
|
|
2212
|
+
*/
|
|
2213
|
+
omitPartialText?: boolean;
|
|
2214
|
+
};
|
|
2215
|
+
/**
|
|
2216
|
+
* This will mock the request failing and getting retried 3 times. After, the request will succeed with the provided response.
|
|
2217
|
+
* Can not be used with `progress` enabled.
|
|
2218
|
+
* @default false
|
|
2219
|
+
*/
|
|
2220
|
+
retryIntoResponse?: boolean;
|
|
2221
|
+
}
|
|
2222
|
+
export interface WithMock<MockResponse> {
|
|
2223
|
+
mock?: QueryMockConfig<MockResponse>;
|
|
2224
|
+
}
|
|
2225
|
+
export interface QueryConfig {
|
|
2226
|
+
/**
|
|
2227
|
+
* Whether this query should be added to the internal query store.
|
|
2228
|
+
*
|
|
2229
|
+
* Generally this should be left on `false` unless you know what you are doing.
|
|
2230
|
+
* @default false
|
|
2231
|
+
*/
|
|
2232
|
+
skipQueryStore?: boolean;
|
|
2233
|
+
/**
|
|
2234
|
+
* The cache key to use for this query.
|
|
2235
|
+
* Useful for queries that are equal but should be stored separately.
|
|
2236
|
+
* Will be generated automatically if not provided.
|
|
2237
|
+
*
|
|
2238
|
+
* Generally this should be left on `undefined` unless you know what you are doing.
|
|
2239
|
+
*/
|
|
2240
|
+
queryStoreCacheKey?: string;
|
|
2241
|
+
}
|
|
2242
|
+
export interface WithConfig {
|
|
2243
|
+
/**
|
|
2244
|
+
* Additional configuration for this query.
|
|
2245
|
+
*/
|
|
2246
|
+
config?: QueryConfig;
|
|
2247
|
+
}
|
|
2248
|
+
export interface WithInjector {
|
|
2249
|
+
injector?: Injector;
|
|
2250
|
+
}
|
|
2251
|
+
export interface WithVariables {
|
|
2252
|
+
/**
|
|
2253
|
+
* The variables for the query. (graphql only)
|
|
2254
|
+
*/
|
|
2255
|
+
variables?: Record<string, unknown>;
|
|
2256
|
+
}
|
|
2257
|
+
export interface WithBody {
|
|
2258
|
+
/**
|
|
2259
|
+
* The body for the query. Unavailable for GET, HEAD and OPTIONS requests.
|
|
2260
|
+
*/
|
|
2261
|
+
body?: unknown;
|
|
2262
|
+
}
|
|
2263
|
+
export interface WithQueryParams {
|
|
2264
|
+
/**
|
|
2265
|
+
* The query parameters for the query. (after the ? in the url)
|
|
2266
|
+
*/
|
|
2267
|
+
queryParams?: QueryParams;
|
|
2268
|
+
}
|
|
2269
|
+
export interface WithPathParams {
|
|
2270
|
+
/**
|
|
2271
|
+
* The path parameters for the query. (in front of the ? in the url)
|
|
2272
|
+
*/
|
|
2273
|
+
pathParams?: PathParams;
|
|
2274
|
+
}
|
|
2275
|
+
export type QueryTrigger = 'program' | 'poll' | 'auto';
|
|
2276
|
+
export type EmptyObject = {};
|
|
2277
|
+
export interface ExecuteQueryOptions {
|
|
2278
|
+
/**
|
|
2279
|
+
* Whether to skip the cache for this query. This will force the query to be executed. It might still be caught by the native browser cache.
|
|
2280
|
+
* @default false
|
|
2281
|
+
*/
|
|
2282
|
+
skipCache?: boolean;
|
|
2283
|
+
/**
|
|
2284
|
+
* Whether to cancel the previous request if it is still loading.
|
|
2285
|
+
* @default false
|
|
2286
|
+
*/
|
|
2287
|
+
cancelPrevious?: boolean;
|
|
2288
|
+
}
|
|
2289
|
+
export type RouteType<Arguments extends BaseArguments | undefined> = Arguments extends {
|
|
2290
|
+
pathParams: infer PathParams;
|
|
2291
|
+
} ? (p: PathParams) => RouteString : RouteString;
|
|
2292
|
+
export type RouteString = `/${string}`;
|
|
2293
|
+
export type AnyRoute = ((p: PathParams) => string) | RouteString;
|
|
2294
|
+
export interface PollConfig {
|
|
2295
|
+
/**
|
|
2296
|
+
* The interval in milliseconds to poll the query.
|
|
2297
|
+
*/
|
|
2298
|
+
interval: number;
|
|
2299
|
+
/**
|
|
2300
|
+
* A observable that will stop the polling when it emits.
|
|
2301
|
+
*/
|
|
2302
|
+
takeUntil: Observable<unknown>;
|
|
2303
|
+
/**
|
|
2304
|
+
* Whether to trigger the query immediately after polling starts.
|
|
2305
|
+
*/
|
|
2306
|
+
triggerImmediately?: boolean;
|
|
2307
|
+
}
|
|
2308
|
+
export declare const enum QueryStateType {
|
|
2309
|
+
Prepared = "PREPARED",
|
|
2310
|
+
Loading = "LOADING",
|
|
2311
|
+
Success = "SUCCESS",
|
|
2312
|
+
Failure = "FAILURE",
|
|
2313
|
+
Cancelled = "CANCELLED"
|
|
2314
|
+
}
|
|
2315
|
+
export interface Prepared {
|
|
2316
|
+
type: QueryStateType.Prepared;
|
|
2317
|
+
meta: QueryStateMeta;
|
|
2318
|
+
}
|
|
2319
|
+
export interface Success<Response = unknown> {
|
|
2320
|
+
type: QueryStateType.Success;
|
|
2321
|
+
response: Response;
|
|
2322
|
+
headers: RequestHeaders;
|
|
2323
|
+
meta: QueryStateSuccessMeta;
|
|
2324
|
+
}
|
|
2325
|
+
export interface Failure {
|
|
2326
|
+
type: QueryStateType.Failure;
|
|
2327
|
+
error: RequestError;
|
|
2328
|
+
meta: QueryStateMeta;
|
|
2329
|
+
}
|
|
2330
|
+
export interface Loading {
|
|
2331
|
+
type: QueryStateType.Loading;
|
|
2332
|
+
meta: QueryStateMeta;
|
|
2333
|
+
partialText?: string;
|
|
2334
|
+
progress?: RequestProgress;
|
|
2335
|
+
}
|
|
2336
|
+
export interface Cancelled {
|
|
2337
|
+
type: QueryStateType.Cancelled;
|
|
2338
|
+
meta: QueryStateMeta;
|
|
2339
|
+
}
|
|
2340
|
+
export interface QueryStateMeta {
|
|
2341
|
+
id: number;
|
|
2342
|
+
triggeredVia: QueryTrigger;
|
|
2343
|
+
isWaitingForRetry?: boolean;
|
|
2344
|
+
retryNumber?: number;
|
|
2345
|
+
retryDelay?: number;
|
|
2346
|
+
}
|
|
2347
|
+
export interface QueryStateSuccessMeta extends QueryStateMeta {
|
|
2348
|
+
expiresAt?: number;
|
|
2349
|
+
}
|
|
2350
|
+
export type QueryState<Response = unknown> = Loading | Success<Response> | Failure | Cancelled | Prepared;
|
|
2351
|
+
export type QueryStateResponseOf<T extends QueryState = QueryState> = T extends Success<infer Response> ? Response : never;
|
|
2352
|
+
export type AnyQuery = Query<any, any, any, any, any, any>;
|
|
2353
|
+
export type AnyQueryCreatorCollection = {
|
|
2354
|
+
[name: string]: AnyQueryCreator | AnyLegacyQueryCreator;
|
|
2355
|
+
};
|
|
2356
|
+
export type QueryCollectionOf<T extends {
|
|
2357
|
+
[name: string]: AnyQueryCreator | AnyLegacyQueryCreator;
|
|
2358
|
+
}> = { [K in keyof T]: {
|
|
2359
|
+
type: K;
|
|
2360
|
+
query: ConstructQuery<T[K]>;
|
|
2361
|
+
}; }[keyof T];
|
|
2362
|
+
export type AnyQueryCollection = QueryCollectionOf<AnyQueryCreatorCollection>;
|
|
2363
|
+
export type QueryOf<T extends AnyQueryCollection | AnyLegacyQuery | AnyQuery | null> = T extends AnyQuery ? T : T extends AnyLegacyQuery ? T : T extends AnyQueryCollection ? T['query'] : never;
|
|
2364
|
+
export type AnyQueryCollectionResponse<T extends AnyQueryCollection> = QueryResponseOf<T['query']>;
|
|
2365
|
+
export type AnyQueryCollectionData<T extends AnyQueryCollection> = QueryDataOf<T['query']>;
|
|
2366
|
+
export type QueryCollectionKeysOf<T extends AnyQueryCollection | AnyLegacyQuery | AnyQuery | null> = T extends AnyQueryCollection ? T['type'] : never;
|
|
2367
|
+
export type QueryCollectionWithNullableQuery<T extends AnyQueryCollection | null> = T extends null ? never : { [K in keyof T]: T[K] extends string ? T[K] : T[K] | null; };
|
|
2368
|
+
export interface ResetPageOnErrorOperatorConfig<J extends QueryForm<any>> {
|
|
2369
|
+
/**
|
|
2370
|
+
* The query form to reset the page of.
|
|
2371
|
+
*/
|
|
2372
|
+
queryForm: J;
|
|
2373
|
+
/**
|
|
2374
|
+
* The key of the page control in the query form.
|
|
2375
|
+
* @default 'page'
|
|
2376
|
+
*/
|
|
2377
|
+
pageControlKey?: string;
|
|
2378
|
+
}
|
|
2379
|
+
export declare class Query<Response, Arguments extends BaseArguments | undefined, Route extends RouteType<Arguments>, Store extends EntityStore<unknown>, Data, Id> {
|
|
2380
|
+
private readonly _client;
|
|
2381
|
+
readonly _id: number;
|
|
2382
|
+
private _currentLocalId;
|
|
2383
|
+
private _pollingSubscription;
|
|
2384
|
+
private _onAbort$;
|
|
2385
|
+
private _currentPollConfig;
|
|
2386
|
+
private _memoizedState$;
|
|
2387
|
+
private readonly _state$;
|
|
2388
|
+
private get _nextId();
|
|
2389
|
+
get state$(): Observable<QueryState<Data>>;
|
|
2390
|
+
/**
|
|
2391
|
+
* The current state of the query.
|
|
2392
|
+
*
|
|
2393
|
+
* **Warning!** This differs from the `state$` observable in that it does not use the query store. Thus, the response data might be outdated.
|
|
2394
|
+
* Use `state$` (or `firstValueFrom(state$)`) the most up-to-date data.
|
|
2395
|
+
*/
|
|
2396
|
+
get rawState(): QueryState<Response>;
|
|
2397
|
+
get isExpired(): boolean;
|
|
2398
|
+
get isInUse(): boolean;
|
|
2399
|
+
get isPolling(): boolean;
|
|
2400
|
+
get autoRefreshOnConfig(): Readonly<QueryAutoRefreshConfig>;
|
|
2401
|
+
get store(): Store | null;
|
|
2402
|
+
get canBeCached(): boolean;
|
|
2403
|
+
get _isInMockMode(): boolean;
|
|
2404
|
+
constructor(_client: QueryClient,
|
|
2405
|
+
/**
|
|
2406
|
+
* @internal
|
|
2407
|
+
*/
|
|
2408
|
+
_queryConfig: RestQueryConfig<Route, Response, Arguments, Store, Data, Id> | GqlQueryConfig<Route, Response, Arguments, Store, Data, Id>,
|
|
2409
|
+
/**
|
|
2410
|
+
* @internal
|
|
2411
|
+
*/
|
|
2412
|
+
_routeWithParams: Route,
|
|
2413
|
+
/**
|
|
2414
|
+
* @internal
|
|
2415
|
+
*/
|
|
2416
|
+
_arguments: Arguments,
|
|
2417
|
+
/**
|
|
2418
|
+
* @internal
|
|
2419
|
+
*/
|
|
2420
|
+
_queryStoreKey: string);
|
|
2421
|
+
execute(options?: ExecuteQueryOptions): this;
|
|
2422
|
+
abort(): this;
|
|
2423
|
+
poll(config: PollConfig): this;
|
|
2424
|
+
stopPolling(): this;
|
|
2425
|
+
pausePolling(): this;
|
|
2426
|
+
resumePolling(): this;
|
|
2427
|
+
onSuccess(callback: (response: Data) => void): this;
|
|
2428
|
+
onFailure(callback: (error: RequestError<unknown>) => void): this;
|
|
2429
|
+
private _getBearerAuthProvider;
|
|
2430
|
+
private _updateEntityState;
|
|
2431
|
+
private _transformState;
|
|
2432
|
+
private _updateState;
|
|
2433
|
+
private _mockRequest;
|
|
2434
|
+
}
|
|
2435
|
+
type OmitNull<T> = T extends null ? never : T;
|
|
2436
|
+
export declare function filterSuccess(): <T extends QueryState | null, Response extends QueryStateResponseOf<OmitNull<T>>>(source: Observable<T>) => Observable<Success<Response>>;
|
|
2437
|
+
export declare function ignoreAutoRefresh(): <T extends QueryState | null>(source: Observable<T>) => Observable<T>;
|
|
2438
|
+
export declare function filterFailure(): <T extends QueryState | null>(source: Observable<T>) => Observable<Failure>;
|
|
2439
|
+
export declare function filterQueryStates(allowedStates: QueryStateType[]): <T extends QueryState | null>(source: Observable<T>) => Observable<T>;
|
|
2440
|
+
export declare function takeUntilResponse(config?: {
|
|
2441
|
+
excludeNull?: boolean;
|
|
2442
|
+
}): <T extends QueryState | null>(source: Observable<T>) => Observable<T>;
|
|
2443
|
+
export declare function filterNull(): <T>(source: Observable<T>) => Observable<OmitNull<T>>;
|
|
2444
|
+
export declare function switchQueryState(): <T extends AnyQuery | AnyLegacyQuery | null, Data extends QueryDataOf<T>>(source: Observable<T>) => Observable<QueryState<Data> | null>;
|
|
2445
|
+
export declare function switchQueryCollectionState(): <T extends AnyQueryCollection | null, Data extends AnyQueryCollectionData<OmitNull<T>>>(source: Observable<T>) => Observable<QueryState<Data> | null>;
|
|
2446
|
+
export declare const resetPageOnError: <T extends AnyQuery | AnyLegacyQuery | null | undefined, J extends QueryForm<any>>(config: ResetPageOnErrorOperatorConfig<J>) => (source: Observable<T>) => Observable<QueryState<any> | T>;
|
|
2447
|
+
export declare const isQueryStateLoading: (state: QueryState | null | undefined) => state is Loading;
|
|
2448
|
+
export declare const isQueryStateSuccess: (state: QueryState | null | undefined) => state is Success;
|
|
2449
|
+
export declare const isQueryStateFailure: (state: QueryState | null | undefined) => state is Failure;
|
|
2450
|
+
export declare const isQueryStateCancelled: (state: QueryState | null | undefined) => state is Cancelled;
|
|
2451
|
+
export declare const isQueryStatePrepared: (state: QueryState | null | undefined) => state is Prepared;
|
|
2452
|
+
export declare const isAutoRefresh: (state: QueryState | null | undefined) => boolean;
|
|
2453
|
+
export declare const mergeHeaders: (...headers: Array<RequestHeaders | null | undefined>) => RequestHeaders | null | undefined;
|
|
2454
|
+
export declare const isGqlQueryConfig: <Response, Arguments extends BaseArguments | undefined, Route extends RouteType<Arguments> | undefined, Store extends EntityStore<unknown>, Data, Id>(config: unknown) => config is GqlQueryConfig<Route, Response, Arguments, Store, Data, Id>;
|
|
2455
|
+
export declare const isQuery: <T extends AnyQuery | AnyLegacyQuery>(query: unknown) => query is T;
|
|
2456
|
+
export declare const isQueryCollection: <T extends AnyQueryCollection>(query: unknown) => query is T;
|
|
2457
|
+
/**
|
|
2458
|
+
* @deprecated Use `createQueryCollectionSubject` instead. Will be removed in v6.
|
|
2459
|
+
*/
|
|
2460
|
+
export declare const createQueryCollection: <T extends AnyQueryCreatorCollection, R extends QueryCollectionOf<T>>(queryMap: T) => BehaviorSubject<R | null>;
|
|
2461
|
+
export declare const createQueryCollectionSubject: <T extends AnyQueryCreatorCollection, R extends QueryCollectionOf<T>>(queryMap: T, config?: QueryContainerConfig) => BehaviorSubject<R | null>;
|
|
2462
|
+
export declare const createQueryCollectionSignal: <T extends AnyQueryCreatorCollection, R extends QueryCollectionOf<T>>(queryMap: T, config?: QueryContainerConfig) => import("@angular/core").WritableSignal<R | null>;
|
|
2463
|
+
export declare const extractQuery: <T extends AnyQuery | AnyLegacyQuery | AnyQueryCollection | null>(v: T) => import("@ethlete/query").Query<any, any, any, any, any, any> | (T & AnyLegacyQuery) | LegacyQuery<any, LegacyArgumentsOfQueryArgs<any>, `/${string}`, any, any, any, Query$1<any>> | null;
|
|
2464
|
+
export declare const getDefaultHeaders: (headers: RequestHeaders | RequestHeadersMethodMap | null | undefined, method: Method) => RequestHeaders;
|
|
2465
|
+
export declare const castQueryCreatorTypes: <QC extends AnyQueryCreator, Arguments extends QueryArgsOf<QC>, Response extends QueryResponseOf<QC>, Store extends QueryStoreOf<QC>, Data extends QueryDataOf<QC>, Route extends RouteType<Arguments>, Id extends QueryStoreIdOf<QC>, OverrideArguments extends BaseArguments | undefined, OverrideResponse extends Response | undefined>(config: {
|
|
2466
|
+
creator: QC;
|
|
2467
|
+
args?: OverrideArguments;
|
|
2468
|
+
response?: OverrideResponse;
|
|
2469
|
+
}) => QueryCreator<OverrideArguments, OverrideResponse, Route, Store, Data, Id>;
|
|
2470
|
+
export declare const computeQueryMethod: (config: {
|
|
2471
|
+
config: AnyRestQueryConfig | AnyGqlQueryConfig;
|
|
2472
|
+
client: QueryClient;
|
|
2473
|
+
}) => "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT" | "PURGE" | "LINK" | "UNLINK" | "CUSTOM";
|
|
2474
|
+
export declare const computeQueryBody: (config: {
|
|
2475
|
+
config: AnyRestQueryConfig | AnyGqlQueryConfig;
|
|
2476
|
+
client: QueryClient;
|
|
2477
|
+
method: Method;
|
|
2478
|
+
args?: BaseArguments;
|
|
2479
|
+
}) => unknown;
|
|
2480
|
+
export declare const computeQueryAuthHeader: (config: {
|
|
2481
|
+
config: AnyRestQueryConfig | AnyGqlQueryConfig;
|
|
2482
|
+
client: QueryClient;
|
|
2483
|
+
}) => Record<string, string> | null;
|
|
2484
|
+
export declare const computeQueryHeaders: (config: {
|
|
2485
|
+
config: AnyRestQueryConfig | AnyGqlQueryConfig;
|
|
2486
|
+
client: QueryClient;
|
|
2487
|
+
args?: BaseArguments;
|
|
2488
|
+
}) => RequestHeaders | undefined;
|
|
2489
|
+
export declare const computeQueryQueryParams: (config: {
|
|
2490
|
+
config: AnyRestQueryConfig | AnyGqlQueryConfig;
|
|
2491
|
+
client: QueryClient;
|
|
2492
|
+
args?: BaseArguments;
|
|
2493
|
+
}) => object | undefined;
|
|
2494
|
+
export declare const paginatedEntityValueUpdater: <T extends Paginated<unknown>, Args extends BaseArguments, Entity, J extends T extends Paginated<infer X> ? X : never>(findFn: (val: J, entity: Entity) => boolean) => ({ response, rawResponse, entity }: {
|
|
2495
|
+
rawResponse: T;
|
|
2496
|
+
response: T;
|
|
2497
|
+
args: Args;
|
|
2498
|
+
entity: Entity;
|
|
2499
|
+
}) => {
|
|
2500
|
+
response: T & {
|
|
2501
|
+
items: unknown[];
|
|
2502
|
+
};
|
|
2503
|
+
rawResponse: T & {
|
|
2504
|
+
items: unknown[];
|
|
2505
|
+
};
|
|
2506
|
+
} | null;
|
|
2507
|
+
export interface QueryClientConfig {
|
|
2508
|
+
/**
|
|
2509
|
+
* The api base route. Should **not** end with a trailing slash.
|
|
2510
|
+
* @example 'https://api.example.com'
|
|
2511
|
+
*/
|
|
2512
|
+
baseRoute: string;
|
|
2513
|
+
/**
|
|
2514
|
+
* Logging configuration for debugging.
|
|
2515
|
+
*/
|
|
2516
|
+
logging?: {
|
|
2517
|
+
/**
|
|
2518
|
+
* Log all query state changes.
|
|
2519
|
+
*/
|
|
2520
|
+
queryStateChanges?: boolean;
|
|
2521
|
+
/**
|
|
2522
|
+
* Log query state garbage collector runs.
|
|
2523
|
+
*/
|
|
2524
|
+
queryStateGarbageCollector?: boolean;
|
|
2525
|
+
/**
|
|
2526
|
+
* Log if subscriptions are made to queries that are in the `prepared` state.
|
|
2527
|
+
* This usually indicates that the `.execute()` method was forgotten.
|
|
2528
|
+
*/
|
|
2529
|
+
preparedQuerySubscriptions?: boolean;
|
|
2530
|
+
};
|
|
2531
|
+
/**
|
|
2532
|
+
* Request options.
|
|
2533
|
+
*/
|
|
2534
|
+
request?: {
|
|
2535
|
+
/**
|
|
2536
|
+
* Adapter function used for extracting the time until the response is invalid.
|
|
2537
|
+
* The default uses the `cache-control` (`max-age` & `s-maxage`), `age` and `expires` headers.
|
|
2538
|
+
* Should return a number in seconds.
|
|
2539
|
+
*/
|
|
2540
|
+
cacheAdapter?: CacheAdapterFn;
|
|
2541
|
+
/**
|
|
2542
|
+
* Default headers to be sent with every request.
|
|
2543
|
+
* Will be overridden by headers passed to the query.
|
|
2544
|
+
* Do not include the `Authorization` header here. Use an `AuthProvider` instead.
|
|
2545
|
+
*/
|
|
2546
|
+
headers?: RequestHeaders | RequestHeadersMethodMap;
|
|
2547
|
+
/**
|
|
2548
|
+
* Whether to automatically refresh expired queries when the window regains focus.
|
|
2549
|
+
* @default true
|
|
2550
|
+
*/
|
|
2551
|
+
autoRefreshQueriesOnWindowFocus?: boolean;
|
|
2552
|
+
/**
|
|
2553
|
+
* Whether to automatically stop polling queries when the window loses focus.
|
|
2554
|
+
* Polling will resume when the window regains focus.
|
|
2555
|
+
* @default true
|
|
2556
|
+
*/
|
|
2557
|
+
enableSmartPolling?: boolean;
|
|
2558
|
+
/**
|
|
2559
|
+
* A retry function to be used for all queries.
|
|
2560
|
+
* @default shouldRetryRequest()
|
|
2561
|
+
*/
|
|
2562
|
+
retryFn?: RequestRetryFn;
|
|
2563
|
+
/**
|
|
2564
|
+
* Configuration options for all graphql queries.
|
|
2565
|
+
*/
|
|
2566
|
+
gql?: {
|
|
2567
|
+
/**
|
|
2568
|
+
* Determines if the query should be sent via GET or POST.
|
|
2569
|
+
* - `GET`: The query will be sent via query parameters.
|
|
2570
|
+
* - `POST`: The query will be sent via the body.
|
|
2571
|
+
* @default 'POST'
|
|
2572
|
+
*/
|
|
2573
|
+
transferVia?: GqlTransferOption;
|
|
2574
|
+
};
|
|
2575
|
+
/**
|
|
2576
|
+
* Configuration options for all query strings.
|
|
2577
|
+
*/
|
|
2578
|
+
queryParams?: BuildQueryStringConfig;
|
|
2579
|
+
};
|
|
2580
|
+
/**
|
|
2581
|
+
* Parent query client.
|
|
2582
|
+
* Used for sharing the same auth provider.
|
|
2583
|
+
*/
|
|
2584
|
+
parent?: QueryClient;
|
|
2585
|
+
}
|
|
2586
|
+
export declare class QueryClient {
|
|
2587
|
+
private _clientConfig;
|
|
2588
|
+
get config(): QueryClientConfig;
|
|
2589
|
+
get authProvider(): AuthProvider | null;
|
|
2590
|
+
get authProvider$(): import("rxjs").Observable<AuthProvider | null>;
|
|
2591
|
+
private readonly _authProvider$;
|
|
2592
|
+
constructor(_clientConfig: QueryClientConfig);
|
|
2593
|
+
get: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: QueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2594
|
+
post: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: QueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2595
|
+
put: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: QueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2596
|
+
patch: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: QueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2597
|
+
delete: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: QueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2598
|
+
gqlQuery: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: GqlQueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2599
|
+
gqlMutate: <Route extends RouteType<Arguments>, Response, Id, Data = Response, Arguments extends BaseArguments | undefined = undefined, Store extends EntityStore<unknown> = EntityStore<unknown>>(queryConfig: GqlQueryConfigWithoutMethod<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2600
|
+
fetch: <Route extends RouteType<Arguments>, Response, Arguments extends BaseArguments | undefined, Id, Store extends EntityStore<unknown> = EntityStore<unknown>, Data = Response>(queryConfig: RestQueryConfig<Route, Response, Arguments, Store, Data, Id> | GqlQueryConfig<Route, Response, Arguments, Store, Data, Id>) => QueryCreator<Arguments, Response, Route, Store, Data, Id>;
|
|
2601
|
+
setAuthProvider: (authProvider: AuthProvider) => void;
|
|
2602
|
+
setDefaultHeaders: (config: {
|
|
2603
|
+
headers: RequestHeaders | RequestHeadersMethodMap | null;
|
|
2604
|
+
refreshQueriesInUse?: boolean;
|
|
2605
|
+
}) => void;
|
|
2606
|
+
clearAuthProvider: () => void;
|
|
2607
|
+
_updateBaseRoute: (route: string) => void;
|
|
2608
|
+
}
|
|
2609
|
+
export declare const shouldCacheQuery: (method: Method) => method is "GET" | "HEAD" | "OPTIONS" | "GQL_QUERY";
|
|
2610
|
+
export declare const buildQueryCacheKey: (route: string, args: BaseArguments | undefined) => string;
|
|
2611
|
+
export declare class QueryStore {
|
|
2612
|
+
private _config?;
|
|
2613
|
+
private _garbageCollector;
|
|
2614
|
+
private _isInLowResourceMode;
|
|
2615
|
+
private _lastBlurTimestamp;
|
|
2616
|
+
private _storeChange$;
|
|
2617
|
+
private _queryCreated$;
|
|
2618
|
+
readonly storeChange$: import("rxjs").Observable<string>;
|
|
2619
|
+
readonly queryCreated$: import("rxjs").Observable<AnyQuery>;
|
|
2620
|
+
constructor(_config?: {
|
|
2621
|
+
enableChangeLogging?: boolean;
|
|
2622
|
+
enableGarbageCollectorLogging?: boolean;
|
|
2623
|
+
autoRefreshQueriesOnWindowFocus?: boolean;
|
|
2624
|
+
enableSmartPolling?: boolean;
|
|
2625
|
+
} | undefined);
|
|
2626
|
+
add(id: string, query: AnyQuery): void;
|
|
2627
|
+
get<T extends AnyQuery>(id: string): T | null;
|
|
2628
|
+
remove(id: string): void;
|
|
2629
|
+
forEach(callback: (value: AnyQuery, key: string) => void): void;
|
|
2630
|
+
refreshQueriesInUse(config?: {
|
|
2631
|
+
ignoreCacheValidity?: boolean;
|
|
2632
|
+
purgeUnused?: boolean;
|
|
2633
|
+
}): void;
|
|
2634
|
+
private _initSmartQueryHandling;
|
|
2635
|
+
private _logState;
|
|
2636
|
+
private _initGarbageCollector;
|
|
2637
|
+
private _stopGarbageCollector;
|
|
2638
|
+
private _runGarbageCollector;
|
|
2639
|
+
private _logGarbageCollector;
|
|
2640
|
+
}
|
|
2641
|
+
export type QueryPrepareFn<Arguments extends BaseArguments | undefined, Response, Route extends RouteType<Arguments>, Store extends EntityStore<unknown>, Data, Id> = Arguments extends BaseArguments ? (args: Arguments & WithHeaders & WithConfig & WithMock<Response>) => Query<Response, Arguments, Route, Store, Data, Id> : (args?: (Arguments extends EmptyObject ? Arguments : EmptyObject) & WithHeaders & WithConfig & WithMock<Response>) => Query<Response, Arguments, Route, Store, Data, Id>;
|
|
2642
|
+
export type AnyQueryCreator = QueryCreator<any, any, any, any, any, any>;
|
|
2643
|
+
export type QueryArgsOf<T extends AnyQueryCreator | AnyQuery | AnyLegacyQuery | AnyLegacyQueryCreator | null> = T extends QueryCreator<infer Args, any, any, any, any, any> ? Args : T extends Query<any, infer Args, any, any, any, any> ? Args : T extends LegacyQuery<any, infer Args, any, any, any, any, any> ? Args : T extends LegacyQueryCreator<infer Args, any, any, any, any> ? LegacyArgumentsOfQueryArgs<Args> : never;
|
|
2644
|
+
export type QueryResponseOf<T extends AnyQueryCreator | AnyQuery | AnyLegacyQuery | AnyLegacyQueryCreator | null> = T extends QueryCreator<any, infer Response, any, any, any, any> ? Response : T extends Query<infer Response, any, any, any, any, any> ? Response : T extends LegacyQuery<infer Response, any, any, any, any, any, any> ? Response : T extends LegacyQueryCreator<any, infer Response, any, any, any> ? Response : never;
|
|
2645
|
+
export type QueryRouteOf<T extends AnyQueryCreator | AnyQuery | AnyLegacyQuery | AnyLegacyQueryCreator | null> = T extends QueryCreator<any, any, infer Route, any, any, any> ? Route : T extends Query<any, any, infer Route, any, any, any> ? Route : T extends LegacyQuery<any, any, infer Route, any, any, any, any> ? Route : T extends LegacyQueryCreator<infer Args, any, any, any, any> ? RouteType<LegacyArgumentsOfQueryArgs<Args>> : never;
|
|
2646
|
+
export type QueryStoreOf<T extends AnyQueryCreator | AnyQuery | AnyLegacyQuery | AnyLegacyQueryCreator | null> = T extends QueryCreator<any, any, any, infer Store, any, any> ? Store : T extends Query<any, any, any, infer Store, any, any> ? Store : T extends LegacyQuery<any, any, any, infer Store, any, any, any> ? Store : T extends LegacyQueryCreator<any, any, infer Store, any, any> ? Store : never;
|
|
2647
|
+
export type QueryDataOf<T extends AnyQueryCreator | AnyLegacyQuery | AnyLegacyQueryCreator | AnyQuery | null> = T extends QueryCreator<any, any, any, any, infer Data, any> ? Data : T extends Query<any, any, any, any, infer Data, any> ? Data : T extends LegacyQuery<any, any, any, any, infer Data, any, any> ? Data : T extends LegacyQueryCreator<any, any, any, any, infer Data> ? Data : never;
|
|
2648
|
+
export type QueryStoreIdOf<T extends AnyQueryCreator | AnyQuery | AnyLegacyQuery | AnyLegacyQueryCreator | null> = T extends QueryCreator<any, any, any, any, any, infer StoreId> ? StoreId : T extends Query<any, any, any, any, any, infer StoreId> ? StoreId : T extends LegacyQuery<any, any, any, any, any, infer StoreId, any> ? StoreId : T extends LegacyQueryCreator<any, any, any, infer StoreId, any> ? StoreId : never;
|
|
2649
|
+
export type ConstructQuery<T extends AnyQueryCreator | AnyLegacyQueryCreator> = ReturnType<T['prepare']>;
|
|
2650
|
+
export declare class QueryCreator<Arguments extends BaseArguments | undefined, Response, Route extends RouteType<Arguments>, Store extends EntityStore<unknown>, Data, Id> {
|
|
2651
|
+
private _queryConfig;
|
|
2652
|
+
private _client;
|
|
2653
|
+
private _store;
|
|
2654
|
+
constructor(_queryConfig: RestQueryConfig<Route, Response, Arguments, Store, Data, Id> | GqlQueryConfig<Route, Response, Arguments, Store, Data, Id>, _client: QueryClient, _store: QueryStore);
|
|
2655
|
+
prepare: QueryPrepareFn<Arguments, Response, Route, Store, Data, Id>;
|
|
2656
|
+
createSubject: (initialValue?: ReturnType<typeof this.prepare> | null, config?: QueryContainerConfig) => BehaviorSubject<ReturnType<QueryPrepareFn<Arguments, Response, Route, Store, Data, Id>> | null>;
|
|
2657
|
+
createSignal: (initialValue?: ReturnType<typeof this.prepare> | null, config?: QueryContainerConfig) => import("@angular/core").WritableSignal<ReturnType<QueryPrepareFn<Arguments, Response, Route, Store, Data, Id>> | null>;
|
|
2658
|
+
/**
|
|
2659
|
+
* @deprecated Use `myQuery.createSubject()` or `myQuery.createSignal()` instead. Will be removed in v6.
|
|
2660
|
+
*/
|
|
2661
|
+
behaviorSubject: (initialValue?: ReturnType<typeof this.prepare> | null) => BehaviorSubject<ReturnType<QueryPrepareFn<Arguments, Response, Route, Store, Data, Id>> | null>;
|
|
2662
|
+
}
|
|
2663
|
+
export interface AuthProvider {
|
|
2664
|
+
/**
|
|
2665
|
+
* The up to date auth header.
|
|
2666
|
+
* This will automatically get injected into every query that has the `secure` property set to `true`.
|
|
2667
|
+
*/
|
|
2668
|
+
header: Record<string, string>;
|
|
2669
|
+
}
|
|
2670
|
+
export interface AuthProviderBasicConfig {
|
|
2671
|
+
/**
|
|
2672
|
+
* Basic auth username
|
|
2673
|
+
*/
|
|
2674
|
+
username: string;
|
|
2675
|
+
/**
|
|
2676
|
+
* Basic auth password
|
|
2677
|
+
*/
|
|
2678
|
+
password: string;
|
|
2679
|
+
}
|
|
2680
|
+
export interface AuthProviderCustomHeaderConfig {
|
|
2681
|
+
/**
|
|
2682
|
+
* The custom header name
|
|
2683
|
+
* @example `X-Api-Key`
|
|
2684
|
+
*/
|
|
2685
|
+
name: string;
|
|
2686
|
+
/**
|
|
2687
|
+
* The custom header value
|
|
2688
|
+
* @example `myApiKey`
|
|
2689
|
+
*/
|
|
2690
|
+
value: string;
|
|
2691
|
+
}
|
|
2692
|
+
export interface AuthProviderBearerConfig<T extends AnyQueryCreator> {
|
|
2693
|
+
/**
|
|
2694
|
+
* The initial jwt
|
|
2695
|
+
*/
|
|
2696
|
+
token?: string;
|
|
2697
|
+
/**
|
|
2698
|
+
* Refresh token configuration
|
|
2699
|
+
*/
|
|
2700
|
+
refreshConfig?: BearerRefreshConfig<T>;
|
|
2701
|
+
}
|
|
2702
|
+
export interface BearerRefreshConfig<T extends AnyQueryCreator> {
|
|
2703
|
+
/**
|
|
2704
|
+
* The query used to trade the refresh token for a new token response.
|
|
2705
|
+
*/
|
|
2706
|
+
queryCreator: T;
|
|
2707
|
+
/**
|
|
2708
|
+
* Determines if the token should be refreshed if **any** query returns a 401 response.
|
|
2709
|
+
* @default true
|
|
2710
|
+
*/
|
|
2711
|
+
refreshOnUnauthorizedResponse?: boolean;
|
|
2712
|
+
/**
|
|
2713
|
+
* The initial refresh token
|
|
2714
|
+
*/
|
|
2715
|
+
token?: string;
|
|
2716
|
+
/**
|
|
2717
|
+
* The cookie name where the refresh token is stored
|
|
2718
|
+
*/
|
|
2719
|
+
cookieName?: string;
|
|
2720
|
+
/**
|
|
2721
|
+
* The domain of the cookie. If not set, the current origin will be used.
|
|
2722
|
+
*
|
|
2723
|
+
* @example
|
|
2724
|
+
* "https://example.com" -> "example.com"
|
|
2725
|
+
* "https://sub.example.com" -> "example.com"
|
|
2726
|
+
*/
|
|
2727
|
+
cookieDomain?: string;
|
|
2728
|
+
/**
|
|
2729
|
+
* The days until the cookie expires
|
|
2730
|
+
* @default 30
|
|
2731
|
+
*/
|
|
2732
|
+
cookieExpiresInDays?: number;
|
|
2733
|
+
/**
|
|
2734
|
+
* The path of the cookie
|
|
2735
|
+
* @default '/'
|
|
2736
|
+
*/
|
|
2737
|
+
cookiePath?: string;
|
|
2738
|
+
/**
|
|
2739
|
+
* Enable or disable the cookie
|
|
2740
|
+
* @default true
|
|
2741
|
+
*/
|
|
2742
|
+
cookieEnabled?: boolean;
|
|
2743
|
+
/**
|
|
2744
|
+
* The same site property of the cookie
|
|
2745
|
+
* @default 'lax'
|
|
2746
|
+
*/
|
|
2747
|
+
cookieSameSite?: 'strict' | 'none' | 'lax';
|
|
2748
|
+
/**
|
|
2749
|
+
* The time in milliseconds before the token expires when the refresh should be triggered.
|
|
2750
|
+
* @default 300000 (5 minutes)
|
|
2751
|
+
*/
|
|
2752
|
+
refreshBuffer?: number;
|
|
2753
|
+
/**
|
|
2754
|
+
* The expires in property name inside the jwt body
|
|
2755
|
+
* @default 'exp'
|
|
2756
|
+
*/
|
|
2757
|
+
expiresInPropertyName?: string;
|
|
2758
|
+
/**
|
|
2759
|
+
* Determines when the token should be refreshed.
|
|
2760
|
+
* @default AuthBearerRefreshStrategy.BeforeExpiration
|
|
2761
|
+
*/
|
|
2762
|
+
strategy?: AuthBearerRefreshStrategy;
|
|
2763
|
+
/**
|
|
2764
|
+
* Adapter function used to build the request body for the refresh request.
|
|
2765
|
+
* @default { body: { refreshToken: "refreshToken" } }
|
|
2766
|
+
*/
|
|
2767
|
+
requestArgsAdapter?: (tokens: {
|
|
2768
|
+
token: string | null;
|
|
2769
|
+
refreshToken: string;
|
|
2770
|
+
}) => QueryArgsOf<T>;
|
|
2771
|
+
/**
|
|
2772
|
+
* Adapter function used to extract the token and refreshToken from the response.
|
|
2773
|
+
* @default { token: "token", refreshToken: "refreshToken" }
|
|
2774
|
+
*/
|
|
2775
|
+
responseAdapter?: (response: NonNullable<QueryResponseOf<T>>) => TokenResponse;
|
|
2776
|
+
}
|
|
2777
|
+
export declare const enum AuthBearerRefreshStrategy {
|
|
2778
|
+
/**
|
|
2779
|
+
* Automatically refresh the token 5 minutes before expiration.
|
|
2780
|
+
* The time can be configured with the `refreshBuffer` property.
|
|
2781
|
+
*/
|
|
2782
|
+
BeforeExpiration = "beforeExpiration"
|
|
2783
|
+
}
|
|
2784
|
+
export interface TokenResponse {
|
|
2785
|
+
/**
|
|
2786
|
+
* The access token used inside the authorization http header.
|
|
2787
|
+
*/
|
|
2788
|
+
token: string | null;
|
|
2789
|
+
/**
|
|
2790
|
+
* The refresh token used for requesting a new token response once the current tokes is expired.
|
|
2791
|
+
* This property is required if the bearer refresh config is set.
|
|
2792
|
+
*/
|
|
2793
|
+
refreshToken: string | null;
|
|
2794
|
+
}
|
|
2795
|
+
export declare class CustomHeaderAuthProvider implements AuthProvider {
|
|
2796
|
+
_config: AuthProviderCustomHeaderConfig;
|
|
2797
|
+
get header(): {
|
|
2798
|
+
[x: string]: string;
|
|
2799
|
+
};
|
|
2800
|
+
constructor(_config: AuthProviderCustomHeaderConfig);
|
|
2801
|
+
cleanUp(): void;
|
|
2802
|
+
}
|
|
2803
|
+
export declare class BasicAuthProvider implements AuthProvider {
|
|
2804
|
+
_config: AuthProviderBasicConfig;
|
|
2805
|
+
get header(): {
|
|
2806
|
+
Authorization: string;
|
|
2807
|
+
};
|
|
2808
|
+
private get _basicAuthString();
|
|
2809
|
+
constructor(_config: AuthProviderBasicConfig);
|
|
2810
|
+
cleanUp(): void;
|
|
2811
|
+
}
|
|
2812
|
+
export declare class BearerAuthProvider<T extends AnyQueryCreator> implements AuthProvider {
|
|
2813
|
+
_config: AuthProviderBearerConfig<T>;
|
|
2814
|
+
private readonly _destroy$;
|
|
2815
|
+
private readonly _currentRefreshQuery$;
|
|
2816
|
+
private readonly _tokens$;
|
|
2817
|
+
get header(): {
|
|
2818
|
+
Authorization: string;
|
|
2819
|
+
};
|
|
2820
|
+
get tokens$(): import("rxjs").Observable<TokenResponse>;
|
|
2821
|
+
get tokens(): TokenResponse;
|
|
2822
|
+
get currentRefreshQuery$(): import("rxjs").Observable<ConstructQuery<T> | null>;
|
|
2823
|
+
get currentRefreshQuery(): ConstructQuery<T> | null;
|
|
2824
|
+
get shouldRefreshOnUnauthorizedResponse(): boolean;
|
|
2825
|
+
constructor(_config: AuthProviderBearerConfig<T>);
|
|
2826
|
+
cleanUp(): void;
|
|
2827
|
+
enableCookie(): void;
|
|
2828
|
+
disableCookie(): void;
|
|
2829
|
+
forceRefresh(): import("@ethlete/query").Query<any, any, any, any, any, any> | undefined;
|
|
2830
|
+
private _setCookie;
|
|
2831
|
+
private _deleteCookie;
|
|
2832
|
+
private _prepareForRefresh;
|
|
2833
|
+
}
|
|
2834
|
+
export declare const isBasicAuthProvider: (authProvider: AuthProvider) => authProvider is BasicAuthProvider;
|
|
2835
|
+
export declare const isBearerAuthProvider: <T extends AnyQueryCreator>(authProvider: AuthProvider) => authProvider is BearerAuthProvider<T>;
|
|
2836
|
+
export declare const isCustomHeaderAuthProvider: (authProvider: AuthProvider) => authProvider is CustomHeaderAuthProvider;
|
|
2837
|
+
export declare const decryptBearer: <Result = Record<string, unknown>>(token: string) => Result | null;
|
|
2838
|
+
export interface ClassValidatorError {
|
|
2839
|
+
statusCode: HttpStatusCode;
|
|
2840
|
+
message: string[];
|
|
2841
|
+
error: string;
|
|
2842
|
+
}
|
|
2843
|
+
export declare const isClassValidatorError: (error: unknown) => error is ClassValidatorError;
|
|
2844
|
+
export interface QueryClientDevtoolsOptions {
|
|
2845
|
+
displayName?: string;
|
|
2846
|
+
client: QueryClient;
|
|
2847
|
+
}
|
|
2848
|
+
export declare const QUERY_CLIENT_DEVTOOLS_TOKEN: InjectionToken<QueryClientDevtoolsOptions[]>;
|
|
2849
|
+
export declare const provideQueryClientForDevtools: (queryClient: QueryClientDevtoolsOptions) => {
|
|
2850
|
+
provide: InjectionToken<QueryClientDevtoolsOptions[]>;
|
|
2851
|
+
useValue: QueryClientDevtoolsOptions;
|
|
2852
|
+
multi: boolean;
|
|
2853
|
+
};
|
|
2854
|
+
type QueryDevtoolsSnapLayout = 'full' | 'left' | 'right' | 'bottom' | 'top';
|
|
2855
|
+
type QueryListMode = 'live' | 'history';
|
|
2856
|
+
type QueryViewMode = 'query' | 'authProvider';
|
|
2857
|
+
export declare class QueryDevtoolsComponent {
|
|
2858
|
+
private readonly _cdr;
|
|
2859
|
+
protected readonly _destroy$: import("rxjs").Observable<boolean>;
|
|
2860
|
+
protected readonly queryClientConfigs: QueryClientDevtoolsOptions[];
|
|
2861
|
+
protected readonly isOpen: import("@angular/core").WritableSignal<boolean>;
|
|
2862
|
+
protected readonly isTranslucent: import("@angular/core").WritableSignal<boolean>;
|
|
2863
|
+
protected readonly snapLayout: import("@angular/core").WritableSignal<QueryDevtoolsSnapLayout>;
|
|
2864
|
+
protected readonly queryListMode: import("@angular/core").WritableSignal<QueryListMode>;
|
|
2865
|
+
protected readonly viewMode: import("@angular/core").WritableSignal<QueryViewMode>;
|
|
2866
|
+
protected showResponse: import("@angular/core").WritableSignal<boolean>;
|
|
2867
|
+
protected showRawResponse: import("@angular/core").WritableSignal<boolean>;
|
|
2868
|
+
protected showQueryConfig: import("@angular/core").WritableSignal<boolean>;
|
|
2869
|
+
protected showEntityStoreValue: import("@angular/core").WritableSignal<boolean>;
|
|
2870
|
+
protected showArguments: import("@angular/core").WritableSignal<boolean>;
|
|
2871
|
+
protected selectedClientIdCtrl: FormControl<number | null>;
|
|
2872
|
+
protected readonly selectedClientId: import("@angular/core").Signal<number | null | undefined>;
|
|
2873
|
+
protected readonly selectedQueryId: import("@angular/core").WritableSignal<number | null>;
|
|
2874
|
+
protected readonly selectedClientConfig: import("@angular/core").Signal<QueryClientDevtoolsOptions>;
|
|
2875
|
+
protected readonly queryStore: import("@angular/core").Signal<import("@ethlete/query").QueryStore>;
|
|
2876
|
+
protected readonly queryStore$: import("rxjs").Observable<import("@ethlete/query").QueryStore>;
|
|
2877
|
+
private readonly _queries$;
|
|
2878
|
+
protected readonly queries: import("@angular/core").Signal<AnyQuery[] | undefined>;
|
|
2879
|
+
protected readonly selectedQuery: import("@angular/core").Signal<AnyQuery | null>;
|
|
2880
|
+
protected readonly selectedQuery$: import("rxjs").Observable<AnyQuery | null>;
|
|
2881
|
+
protected selectedQueryEntityStore: import("@angular/core").Signal<EntityStore<unknown> | null>;
|
|
2882
|
+
protected readonly selectedQueryEntityStore$: import("rxjs").Observable<EntityStore<unknown> | null>;
|
|
2883
|
+
protected readonly selectedQueryEntityStoreValue$: import("rxjs").Observable<Record<string, unknown> | null>;
|
|
2884
|
+
protected readonly queryHistory$: BehaviorSubject<AnyQuery[]>;
|
|
2885
|
+
protected readonly stringifiedQueryConfig: import("@angular/core").Signal<{
|
|
2886
|
+
query: string;
|
|
2887
|
+
transferVia: import("@ethlete/query").GqlTransferOption | undefined;
|
|
2888
|
+
method: import("@ethlete/query").Method;
|
|
2889
|
+
secure: boolean | undefined;
|
|
2890
|
+
route: any;
|
|
2891
|
+
reportProgress: boolean | undefined;
|
|
2892
|
+
responseType: "arraybuffer" | "blob" | "json" | "text" | undefined;
|
|
2893
|
+
withCredentials: boolean | undefined;
|
|
2894
|
+
autoRefreshOn: import("@ethlete/query").QueryAutoRefreshConfig | undefined;
|
|
2895
|
+
enableSmartPolling: boolean | undefined;
|
|
2896
|
+
hasEntityStore: boolean;
|
|
2897
|
+
} | {
|
|
2898
|
+
method: import("@ethlete/query").Method;
|
|
2899
|
+
secure: boolean | undefined;
|
|
2900
|
+
route: any;
|
|
2901
|
+
reportProgress: boolean | undefined;
|
|
2902
|
+
responseType: "arraybuffer" | "blob" | "json" | "text" | undefined;
|
|
2903
|
+
withCredentials: boolean | undefined;
|
|
2904
|
+
autoRefreshOn: import("@ethlete/query").QueryAutoRefreshConfig | undefined;
|
|
2905
|
+
enableSmartPolling: boolean | undefined;
|
|
2906
|
+
hasEntityStore: boolean;
|
|
2907
|
+
} | null>;
|
|
2908
|
+
protected readonly authProvider: import("@angular/core").Signal<import("@ethlete/query").AuthProvider | null | undefined>;
|
|
2909
|
+
protected readonly authProviderDetails: import("@angular/core").Signal<{
|
|
2910
|
+
readonly type: "CustomHeaderAuthProvider";
|
|
2911
|
+
readonly header: () => {
|
|
2912
|
+
[x: string]: string;
|
|
2913
|
+
};
|
|
2914
|
+
readonly provider: CustomHeaderAuthProvider;
|
|
2915
|
+
readonly config: {
|
|
2916
|
+
readonly name: string;
|
|
2917
|
+
readonly value: string;
|
|
2918
|
+
readonly username?: undefined;
|
|
2919
|
+
readonly password?: undefined;
|
|
2920
|
+
readonly token?: undefined;
|
|
2921
|
+
readonly refreshConfig?: undefined;
|
|
2922
|
+
};
|
|
2923
|
+
} | {
|
|
2924
|
+
readonly type: "BasicAuthProvider";
|
|
2925
|
+
readonly header: () => {
|
|
2926
|
+
Authorization: string;
|
|
2927
|
+
};
|
|
2928
|
+
readonly provider: BasicAuthProvider;
|
|
2929
|
+
readonly config: {
|
|
2930
|
+
readonly username: string;
|
|
2931
|
+
readonly password: string;
|
|
2932
|
+
readonly name?: undefined;
|
|
2933
|
+
readonly value?: undefined;
|
|
2934
|
+
readonly token?: undefined;
|
|
2935
|
+
readonly refreshConfig?: undefined;
|
|
2936
|
+
};
|
|
2937
|
+
} | {
|
|
2938
|
+
readonly type: "BearerAuthProvider";
|
|
2939
|
+
readonly header: () => {
|
|
2940
|
+
Authorization: string;
|
|
2941
|
+
};
|
|
2942
|
+
readonly provider: import("@ethlete/query").BearerAuthProvider<import("@ethlete/query").AnyQueryCreator>;
|
|
2943
|
+
readonly config: {
|
|
2944
|
+
readonly token: string | undefined;
|
|
2945
|
+
readonly refreshConfig: {
|
|
2946
|
+
readonly refreshOnUnauthorizedResponse: boolean | "true (default)";
|
|
2947
|
+
readonly token: string | undefined;
|
|
2948
|
+
readonly cookieName: string | undefined;
|
|
2949
|
+
readonly cookieDomain: string;
|
|
2950
|
+
readonly cookieExpiresInDays: number | "30 (default)";
|
|
2951
|
+
readonly cookiePath: string;
|
|
2952
|
+
readonly cookieEnabled: boolean | "true (default)";
|
|
2953
|
+
readonly cookieSameSite: "strict" | "none" | "lax" | "lax (default)";
|
|
2954
|
+
readonly refreshBuffer: number | "30000 (default)";
|
|
2955
|
+
readonly expiresInPropertyName: string;
|
|
2956
|
+
readonly strategy: import("@ethlete/query").AuthBearerRefreshStrategy | "AuthBearerRefreshStrategy.BeforeExpiration (default)";
|
|
2957
|
+
readonly requestArgsAdapter: "default" | "custom";
|
|
2958
|
+
readonly responseAdapter: "default" | "custom";
|
|
2959
|
+
};
|
|
2960
|
+
readonly name?: undefined;
|
|
2961
|
+
readonly value?: undefined;
|
|
2962
|
+
readonly username?: undefined;
|
|
2963
|
+
readonly password?: undefined;
|
|
2964
|
+
};
|
|
2965
|
+
} | {
|
|
2966
|
+
readonly type: "UnknownAuthProvider";
|
|
2967
|
+
readonly header: () => Record<string, string>;
|
|
2968
|
+
readonly provider: import("@ethlete/query").AuthProvider;
|
|
2969
|
+
readonly config: {
|
|
2970
|
+
readonly name?: undefined;
|
|
2971
|
+
readonly value?: undefined;
|
|
2972
|
+
readonly username?: undefined;
|
|
2973
|
+
readonly password?: undefined;
|
|
2974
|
+
readonly token?: undefined;
|
|
2975
|
+
readonly refreshConfig?: undefined;
|
|
2976
|
+
};
|
|
2977
|
+
} | null>;
|
|
2978
|
+
constructor();
|
|
2979
|
+
protected trackByClient: TrackByFunction<QueryClientDevtoolsOptions>;
|
|
2980
|
+
protected trackByQuery: TrackByFunction<AnyQuery>;
|
|
2981
|
+
protected toggleOpen(): void;
|
|
2982
|
+
protected toggleTranslucent(): void;
|
|
2983
|
+
protected toggleShowResponse(): void;
|
|
2984
|
+
protected toggleShowQueryConfig(): void;
|
|
2985
|
+
protected toggleShowRawResponse(): void;
|
|
2986
|
+
protected toggleShowEntityStoreValue(): void;
|
|
2987
|
+
protected toggleShowArguments(): void;
|
|
2988
|
+
protected selectSnapLayout(layout: QueryDevtoolsSnapLayout): void;
|
|
2989
|
+
protected selectQueryListMode(mode: QueryListMode): void;
|
|
2990
|
+
protected selectViewMode(mode: QueryViewMode): void;
|
|
2991
|
+
protected selectQuery(query: AnyQuery): void;
|
|
2992
|
+
protected clearQueryHistory(): void;
|
|
2993
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<QueryDevtoolsComponent, never>;
|
|
2994
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<QueryDevtoolsComponent, "et-query-devtools", never, {}, {}, never, never, true, never>;
|
|
2995
|
+
}
|
|
2996
|
+
export declare class QueryShortNamePipe implements PipeTransform {
|
|
2997
|
+
transform(value: AnyQuery): string;
|
|
2998
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<QueryShortNamePipe, never>;
|
|
2999
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<QueryShortNamePipe, "queryShortName", true>;
|
|
3000
|
+
}
|
|
3001
|
+
export type QueryDirectiveContext<Q extends QueryDirectiveType | null> = {
|
|
3002
|
+
/**
|
|
3003
|
+
* The queries's response data.
|
|
3004
|
+
*/
|
|
3005
|
+
$implicit: QueryDataOf<QueryOf<Q>> | null;
|
|
3006
|
+
/**
|
|
3007
|
+
* The queries's response data.
|
|
3008
|
+
*/
|
|
3009
|
+
etQuery: QueryDataOf<QueryOf<Q>> | null;
|
|
3010
|
+
/**
|
|
3011
|
+
* The query used inside this directive. Useful if for instance the query gets unwrapped via async pipe inside the directive.
|
|
3012
|
+
*/
|
|
3013
|
+
query: QueryOf<Q> | null;
|
|
3014
|
+
/**
|
|
3015
|
+
* Is true when the query is triggered by user interaction.
|
|
3016
|
+
*/
|
|
3017
|
+
loading: boolean;
|
|
3018
|
+
/**
|
|
3019
|
+
* Is true when the query is triggered by either polling or auto refresh event.
|
|
3020
|
+
*/
|
|
3021
|
+
refreshing: boolean;
|
|
3022
|
+
/**
|
|
3023
|
+
* The query's progress state.
|
|
3024
|
+
*/
|
|
3025
|
+
progress: RequestProgress | null;
|
|
3026
|
+
/**
|
|
3027
|
+
* The query's error state.
|
|
3028
|
+
*/
|
|
3029
|
+
error: RequestError<unknown> | null;
|
|
3030
|
+
/**
|
|
3031
|
+
* The query's scope (only available when the query is a collection)
|
|
3032
|
+
*/
|
|
3033
|
+
scope: QueryCollectionKeysOf<Q> | null;
|
|
3034
|
+
};
|
|
3035
|
+
export type QueryDirectiveType = AnyQuery | AnyLegacyQuery | AnyQueryCollection;
|
|
3036
|
+
export declare class QueryDirective<Q extends QueryDirectiveType | null> {
|
|
3037
|
+
private errorHandler;
|
|
3038
|
+
private cdr;
|
|
3039
|
+
private readonly _viewContext;
|
|
3040
|
+
query: import("@angular/core").InputSignal<Q>;
|
|
3041
|
+
cache: import("@angular/core").InputSignal<boolean>;
|
|
3042
|
+
queryState: import("@angular/core").WritableSignal<import("@ethlete/query").QueryState<QueryDataOf<QueryOf<Q>>> | null>;
|
|
3043
|
+
static ngTemplateContextGuard<Q extends QueryDirectiveType | null>(dir: QueryDirective<Q>, ctx: unknown): ctx is QueryDirectiveContext<Q>;
|
|
3044
|
+
constructor();
|
|
3045
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<QueryDirective<any>, never>;
|
|
3046
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<QueryDirective<any>, "[etQuery]", never, {
|
|
3047
|
+
"query": {
|
|
3048
|
+
"alias": "etQuery";
|
|
3049
|
+
"required": true;
|
|
3050
|
+
"isSignal": true;
|
|
3051
|
+
};
|
|
3052
|
+
"cache": {
|
|
3053
|
+
"alias": "etQueryCache";
|
|
3054
|
+
"required": false;
|
|
3055
|
+
"isSignal": true;
|
|
3056
|
+
};
|
|
3057
|
+
}, {}, never, never, true, never>;
|
|
3058
|
+
}
|
|
3059
|
+
export type InfinityQueryParamLocation = 'path' | 'query' | 'body' | 'header' | 'variable';
|
|
3060
|
+
export type AppendItemsLocation = 'start' | 'end';
|
|
3061
|
+
export interface PageParamCalculatorOptions {
|
|
3062
|
+
page: number;
|
|
3063
|
+
totalPages: number | null;
|
|
3064
|
+
itemsPerPage: number;
|
|
3065
|
+
}
|
|
3066
|
+
export interface TotalPagesExtractorOptions<Arguments extends BaseArguments | undefined, QueryResponse> {
|
|
3067
|
+
response: QueryResponse;
|
|
3068
|
+
itemsPerPage: number;
|
|
3069
|
+
args: Arguments;
|
|
3070
|
+
}
|
|
3071
|
+
export interface InfinityQueryConfig<QueryCreator extends AnyQueryCreator | AnyLegacyQueryCreator, Arguments extends BaseArguments | undefined, QueryResponse, InfinityResponse extends unknown[]> {
|
|
3072
|
+
/**
|
|
3073
|
+
* The query creator to use for fetching pages.
|
|
3074
|
+
*/
|
|
3075
|
+
queryCreator: QueryCreator;
|
|
3076
|
+
/**
|
|
3077
|
+
* The interval in milliseconds to poll on. If not provided, polling will be disabled.
|
|
3078
|
+
* @default undefined
|
|
3079
|
+
*/
|
|
3080
|
+
pollingInterval?: number;
|
|
3081
|
+
/**
|
|
3082
|
+
* The args that will be merged with the page arg.
|
|
3083
|
+
*/
|
|
3084
|
+
defaultArgs?: Arguments & WithHeaders;
|
|
3085
|
+
/**
|
|
3086
|
+
* Enables or disables the infinite query functionality.
|
|
3087
|
+
* @default true
|
|
3088
|
+
*/
|
|
3089
|
+
enabled?: boolean;
|
|
3090
|
+
pageParam?: {
|
|
3091
|
+
/**
|
|
3092
|
+
* The location where the page param is in request.
|
|
3093
|
+
*
|
|
3094
|
+
* @default "query"
|
|
3095
|
+
*/
|
|
3096
|
+
location?: InfinityQueryParamLocation;
|
|
3097
|
+
/**
|
|
3098
|
+
* Used as page param name.
|
|
3099
|
+
*
|
|
3100
|
+
* @default "page"
|
|
3101
|
+
*/
|
|
3102
|
+
key?: string;
|
|
3103
|
+
/**
|
|
3104
|
+
* A function that calculates the page value for the next request.
|
|
3105
|
+
* E.g. if the pagination is done with a `skip` param, the `pageParamName` should be `skip` and this function should return the correct value.
|
|
3106
|
+
*/
|
|
3107
|
+
valueCalculator?: (data: PageParamCalculatorOptions) => number;
|
|
3108
|
+
};
|
|
3109
|
+
limitParam?: {
|
|
3110
|
+
/**
|
|
3111
|
+
* The location where the limit param is in request.
|
|
3112
|
+
*
|
|
3113
|
+
* @default "query"
|
|
3114
|
+
*/
|
|
3115
|
+
location?: InfinityQueryParamLocation;
|
|
3116
|
+
/**
|
|
3117
|
+
* Used as limit param name.
|
|
3118
|
+
*
|
|
3119
|
+
* @default "limit"
|
|
3120
|
+
*/
|
|
3121
|
+
key?: string;
|
|
3122
|
+
/**
|
|
3123
|
+
* The value of the limit param.
|
|
3124
|
+
*
|
|
3125
|
+
* @default 10
|
|
3126
|
+
*/
|
|
3127
|
+
value?: number;
|
|
3128
|
+
};
|
|
3129
|
+
response: {
|
|
3130
|
+
/**
|
|
3131
|
+
* Determines if the response should get reversed before appending to the data array.
|
|
3132
|
+
*
|
|
3133
|
+
* @default false
|
|
3134
|
+
*/
|
|
3135
|
+
reverse?: boolean;
|
|
3136
|
+
/**
|
|
3137
|
+
* Determines where to put the new items in the data array.
|
|
3138
|
+
*
|
|
3139
|
+
* @default "end"
|
|
3140
|
+
*/
|
|
3141
|
+
appendItemsTo?: AppendItemsLocation;
|
|
3142
|
+
/**
|
|
3143
|
+
* The type of the array that will be created by the infinite query.
|
|
3144
|
+
*/
|
|
3145
|
+
arrayType: InfinityResponse;
|
|
3146
|
+
/**
|
|
3147
|
+
* A function that returns the data array from the response.
|
|
3148
|
+
* This function should return the type provided in `responseArrayType`.
|
|
3149
|
+
*/
|
|
3150
|
+
valueExtractor?: (response: QueryResponse) => InfinityResponse;
|
|
3151
|
+
/**
|
|
3152
|
+
* The property in the response that contains the total page count.
|
|
3153
|
+
*
|
|
3154
|
+
* @default "totalPages"
|
|
3155
|
+
*/
|
|
3156
|
+
totalPagesExtractor?: (data: TotalPagesExtractorOptions<QueryArgsOf<QueryCreator> & WithHeaders, QueryResponse>) => number;
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
type OmitUndefined<T> = T extends undefined ? never : T;
|
|
3160
|
+
export type AnyInfinityQueryConfig = InfinityQueryConfig<any, any, any, any>;
|
|
3161
|
+
export type AnyInfinityQuery = InfinityQuery<any, any, any, any, any>;
|
|
3162
|
+
export type InfinityQueryConfigType<QueryCreator extends AnyQueryCreator | AnyLegacyQueryCreator, InfinityResponse extends unknown[]> = InfinityQueryConfig<QueryCreator, OmitUndefined<QueryArgsOf<QueryCreator>>, QueryDataOf<QueryCreator>, InfinityResponse>;
|
|
3163
|
+
export type InfinityQueryOf<Cfg extends AnyInfinityQueryConfig | null> = InfinityQuery<NonNullable<Cfg>['queryCreator'], ConstructQuery<NonNullable<Cfg>['queryCreator']>, QueryArgsOf<NonNullable<Cfg>['queryCreator']>, QueryDataOf<NonNullable<Cfg>['queryCreator']>, NonNullable<Cfg>['response']['arrayType']>;
|
|
3164
|
+
export declare class InfinityQuery<QueryCreator extends AnyQueryCreator | AnyLegacyQueryCreator, Query extends ConstructQuery<QueryCreator>, Args extends QueryArgsOf<QueryCreator>, QueryResponse extends QueryDataOf<QueryCreator>, InfinityResponse extends unknown[]> {
|
|
3165
|
+
private _config;
|
|
3166
|
+
private _destroy$;
|
|
3167
|
+
private readonly _queries$;
|
|
3168
|
+
private readonly _currentPage$;
|
|
3169
|
+
private readonly _currentCalculatedPage$;
|
|
3170
|
+
private readonly _totalPages$;
|
|
3171
|
+
private readonly _itemsPerPage$;
|
|
3172
|
+
private readonly _data$;
|
|
3173
|
+
private readonly _lastQuery$;
|
|
3174
|
+
get currentPage$(): Observable<number | null>;
|
|
3175
|
+
get currentPage(): number | null;
|
|
3176
|
+
get currentCalculatedPage$(): Observable<number | null>;
|
|
3177
|
+
get currentCalculatedPage(): number | null;
|
|
3178
|
+
get totalPages$(): Observable<number | null>;
|
|
3179
|
+
get totalPages(): number | null;
|
|
3180
|
+
get itemsPerPage$(): Observable<number>;
|
|
3181
|
+
get itemsPerPage(): number;
|
|
3182
|
+
get data$(): Observable<InfinityResponse | null>;
|
|
3183
|
+
get currentQuery$(): Observable<Query | null>;
|
|
3184
|
+
constructor(_config: InfinityQueryConfig<QueryCreator, Args, QueryResponse, InfinityResponse>, _destroy$: Observable<boolean>);
|
|
3185
|
+
nextPage(): void;
|
|
3186
|
+
reset(newConfig?: Omit<InfinityQueryConfig<QueryCreator, Args, QueryResponse, InfinityResponse>, 'queryCreator' | 'response'>): void;
|
|
3187
|
+
private _prepareArgs;
|
|
3188
|
+
private _getPageParamLocation;
|
|
3189
|
+
}
|
|
3190
|
+
export declare const createInfinityQueryConfig: <QueryCreator extends AnyQueryCreator | AnyLegacyQueryCreator, Args extends QueryArgsOf<QueryCreator>, QueryResponse extends QueryDataOf<QueryCreator>, InfinityResponse extends unknown[]>(config: InfinityQueryConfig<QueryCreator, Args, QueryResponse, InfinityResponse>) => InfinityQueryConfig<QueryCreator, Args, QueryResponse, InfinityResponse>;
|
|
3191
|
+
export declare const skipPaginationPageParamCalculator: ({ page, itemsPerPage }: PageParamCalculatorOptions) => number;
|
|
3192
|
+
interface InfinityQueryContext<Q extends InfinityQueryConfig<DirectiveQueryCreator, BaseArguments | undefined, any, unknown[]>> {
|
|
3193
|
+
$implicit: Q['response']['arrayType'] | null;
|
|
3194
|
+
etInfinityQuery: Q['response']['arrayType'] | null;
|
|
3195
|
+
loading: boolean;
|
|
3196
|
+
error: RequestError<unknown> | null;
|
|
3197
|
+
isFirstLoad: boolean;
|
|
3198
|
+
canLoadMore: boolean;
|
|
3199
|
+
currentPage: number | null;
|
|
3200
|
+
currentCalculatedPage: number | null;
|
|
3201
|
+
totalPages: number | null;
|
|
3202
|
+
itemsPerPage: number | null;
|
|
3203
|
+
currentQuery: ConstructQuery<Q['queryCreator']> | null;
|
|
3204
|
+
}
|
|
3205
|
+
export declare const INFINITY_QUERY_TOKEN: InjectionToken<InfinityQueryDirective<any>>;
|
|
3206
|
+
type DirectiveQueryCreator = AnyQueryCreator | AnyLegacyQueryCreator;
|
|
3207
|
+
export declare class InfinityQueryDirective<Q extends InfinityQueryConfig<DirectiveQueryCreator, BaseArguments | undefined, any, unknown[]>> {
|
|
3208
|
+
private readonly _queryConfigChanged$;
|
|
3209
|
+
private readonly _viewContext;
|
|
3210
|
+
private _infinityQueryInstance;
|
|
3211
|
+
private readonly _destroy$;
|
|
3212
|
+
private readonly _cdr;
|
|
3213
|
+
private readonly _viewContainerRef;
|
|
3214
|
+
private readonly _mainTemplateRef;
|
|
3215
|
+
private readonly _errorHandler;
|
|
3216
|
+
private readonly _delayable;
|
|
3217
|
+
private readonly _data$;
|
|
3218
|
+
get infinityQuery(): Q;
|
|
3219
|
+
set infinityQuery(v: Q);
|
|
3220
|
+
private _infinityQuery;
|
|
3221
|
+
get context(): InfinityQueryContext<Q>;
|
|
3222
|
+
get instance(): InfinityQueryOf<Q> | null;
|
|
3223
|
+
get data$(): import("rxjs").Observable<Q["response"]["arrayType"]>;
|
|
3224
|
+
data: import("@angular/core").Signal<Q["response"]["arrayType"]>;
|
|
3225
|
+
static ngTemplateContextGuard<Q extends InfinityQueryConfig<DirectiveQueryCreator, BaseArguments | undefined, any, unknown[]>>(dir: InfinityQueryDirective<Q>, ctx: unknown): ctx is InfinityQueryContext<Q>;
|
|
3226
|
+
constructor();
|
|
3227
|
+
private _setupInfinityQuery;
|
|
3228
|
+
loadNextPage(): void;
|
|
3229
|
+
reset(newConfig?: Omit<Q, 'queryCreator' | 'response'>): void;
|
|
3230
|
+
private _cleanup;
|
|
3231
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<InfinityQueryDirective<any>, never>;
|
|
3232
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<InfinityQueryDirective<any>, "[etInfinityQuery]", ["etInfinityQuery"], {
|
|
3233
|
+
"infinityQuery": {
|
|
3234
|
+
"alias": "etInfinityQuery";
|
|
3235
|
+
"required": false;
|
|
3236
|
+
};
|
|
3237
|
+
}, {}, never, never, true, [{
|
|
3238
|
+
directive: typeof i1.DelayableDirective;
|
|
3239
|
+
inputs: {};
|
|
3240
|
+
outputs: {};
|
|
3241
|
+
}]>;
|
|
3242
|
+
}
|
|
3243
|
+
export declare class InfinityQueryTriggerDirective implements OnInit, OnDestroy {
|
|
3244
|
+
private _elementRef;
|
|
3245
|
+
private _infinityQuery;
|
|
3246
|
+
private _destroy;
|
|
3247
|
+
private _observer;
|
|
3248
|
+
click$: import("rxjs").Observable<unknown>;
|
|
3249
|
+
scrollContainerSelector: string | null;
|
|
3250
|
+
infinityQueryOverride: import("@angular/core").InputSignal<InfinityQueryDirective<any> | null>;
|
|
3251
|
+
infinityQuery: import("@angular/core").Signal<InfinityQueryDirective<any>>;
|
|
3252
|
+
ngOnInit(): void;
|
|
3253
|
+
ngOnDestroy(): void;
|
|
3254
|
+
private _setupIntersectionObserver;
|
|
3255
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<InfinityQueryTriggerDirective, never>;
|
|
3256
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<InfinityQueryTriggerDirective, "[etInfinityQueryTrigger], et-infinity-query-trigger", never, {
|
|
3257
|
+
"scrollContainerSelector": {
|
|
3258
|
+
"alias": "scrollContainerSelector";
|
|
3259
|
+
"required": false;
|
|
3260
|
+
};
|
|
3261
|
+
"infinityQueryOverride": {
|
|
3262
|
+
"alias": "infinityQueryOverride";
|
|
3263
|
+
"required": false;
|
|
3264
|
+
"isSignal": true;
|
|
3265
|
+
};
|
|
3266
|
+
}, {}, never, never, true, never>;
|
|
3267
|
+
}
|
|
3268
|
+
export declare const buildErrorMessage: (code: string, message: string) => string;
|
|
3269
|
+
export declare class QueryError extends Error {
|
|
3270
|
+
data?: unknown;
|
|
3271
|
+
constructor(code: string, message: string, data?: unknown);
|
|
3272
|
+
}
|
|
3273
|
+
export declare const invalidBaseRouteError: (data: unknown) => QueryError;
|
|
3274
|
+
export declare const invalidRouteError: (data: unknown) => QueryError;
|
|
3275
|
+
export declare const pathParamsMissingInRouteFunctionError: (data: unknown) => QueryError;
|
|
3276
|
+
export declare const queryStateAlreadyHasKeyError: (data: unknown) => QueryError;
|
|
3277
|
+
export declare const queryStateDoesNotContainKeyError: (data: unknown) => QueryError;
|
|
3278
|
+
export declare const queryStateCannotTransformError: (data: unknown) => QueryError;
|
|
3279
|
+
export declare const invalidBodyError: (data: unknown) => QueryError;
|
|
3280
|
+
export interface SymfonyErrorTrace {
|
|
3281
|
+
args: string[];
|
|
3282
|
+
class: string;
|
|
3283
|
+
file: string;
|
|
3284
|
+
function: string;
|
|
3285
|
+
line: number;
|
|
3286
|
+
namespace: string;
|
|
3287
|
+
short_class: string;
|
|
3288
|
+
type: string;
|
|
3289
|
+
}
|
|
3290
|
+
export interface SymfonyError {
|
|
3291
|
+
class: string;
|
|
3292
|
+
detail: string;
|
|
3293
|
+
status: HttpStatusCode;
|
|
3294
|
+
title: string;
|
|
3295
|
+
trace: SymfonyErrorTrace[];
|
|
3296
|
+
type: string;
|
|
3297
|
+
}
|
|
3298
|
+
export declare const isSymfonyError: (error: unknown) => error is SymfonyError;
|
|
3299
|
+
export declare const isSymfonyPagerfantaOutOfRangeError: (error: unknown) => error is SymfonyError;
|
|
3300
|
+
export declare const isSymfonyFormViolationListError: (error: unknown) => error is FormViolationListView;
|
|
3301
|
+
export declare const isSymfonyListError: (error: unknown) => error is FormViolationView[];
|
|
3302
|
+
export { index_d_exports as ExperimentalQuery };
|