@ethlete/query 5.40.1 → 5.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/fesm2022/ethlete-query.mjs +114 -138
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/index.d.ts +3591 -20
- package/package.json +5 -5
- package/lib/auth/auth-provider.types.d.ts +0 -133
- package/lib/auth/auth-provider.utils.d.ts +0 -9
- package/lib/auth/basic-auth-provider.d.ts +0 -10
- package/lib/auth/bearer-auth-provider.d.ts +0 -23
- package/lib/auth/custom-header-auth-provider.d.ts +0 -9
- package/lib/auth/index.d.ts +0 -5
- package/lib/class-validator/class-validator.types.d.ts +0 -6
- package/lib/class-validator/class-validator.utils.d.ts +0 -2
- package/lib/class-validator/index.d.ts +0 -2
- package/lib/devtools/components/query-devtools/index.d.ts +0 -1
- package/lib/devtools/components/query-devtools/query-devtools.component.d.ts +0 -151
- package/lib/devtools/pipes/index.d.ts +0 -1
- package/lib/devtools/pipes/query-short-name.pipe.d.ts +0 -8
- package/lib/devtools/utils/index.d.ts +0 -1
- package/lib/devtools/utils/query-client.utils.d.ts +0 -12
- package/lib/directives/index.d.ts +0 -3
- package/lib/directives/infinity-query-trigger.directive.d.ts +0 -15
- package/lib/directives/infinity-query.directive.d.ts +0 -49
- package/lib/directives/query.directive.d.ts +0 -64
- package/lib/entity/entity-store.d.ts +0 -25
- package/lib/entity/entity.types.d.ts +0 -25
- package/lib/entity/entity.utils.d.ts +0 -12
- package/lib/entity/index.d.ts +0 -3
- package/lib/experimental/auth/bearer-auth-provider-config.d.ts +0 -123
- package/lib/experimental/auth/bearer-auth-provider.d.ts +0 -69
- package/lib/experimental/auth/index.d.ts +0 -2
- package/lib/experimental/gql/gql-query-creator-templates.d.ts +0 -12
- package/lib/experimental/gql/gql-query-creator.d.ts +0 -14
- package/lib/experimental/gql/gql-query-execute.d.ts +0 -11
- package/lib/experimental/gql/gql-query.d.ts +0 -12
- package/lib/experimental/gql/index.d.ts +0 -4
- package/lib/experimental/http/http-request.d.ts +0 -119
- package/lib/experimental/http/index.d.ts +0 -21
- package/lib/experimental/http/paged-query-stack.d.ts +0 -172
- package/lib/experimental/http/query-client-config.d.ts +0 -45
- package/lib/experimental/http/query-client.d.ts +0 -10
- package/lib/experimental/http/query-creator-templates.d.ts +0 -24
- package/lib/experimental/http/query-creator.d.ts +0 -82
- package/lib/experimental/http/query-dependencies.d.ts +0 -26
- package/lib/experimental/http/query-error-response.d.ts +0 -19
- package/lib/experimental/http/query-errors.d.ts +0 -56
- package/lib/experimental/http/query-execute-utils.d.ts +0 -42
- package/lib/experimental/http/query-execute.d.ts +0 -25
- package/lib/experimental/http/query-features.d.ts +0 -121
- package/lib/experimental/http/query-repository.d.ts +0 -69
- package/lib/experimental/http/query-snapshot.d.ts +0 -10
- package/lib/experimental/http/query-stack.d.ts +0 -109
- package/lib/experimental/http/query-state.d.ts +0 -41
- package/lib/experimental/http/query-utils.d.ts +0 -61
- package/lib/experimental/http/query.d.ts +0 -75
- package/lib/experimental/http/secure-query-creator.d.ts +0 -7
- package/lib/experimental/http/secure-query-execute.d.ts +0 -7
- package/lib/experimental/http/secure-query.d.ts +0 -6
- package/lib/experimental/index.d.ts +0 -6
- package/lib/experimental/interop/index.d.ts +0 -2
- package/lib/experimental/interop/legacy-query-creator.d.ts +0 -45
- package/lib/experimental/interop/legacy-query.d.ts +0 -38
- package/lib/experimental/pipes/index.d.ts +0 -4
- package/lib/experimental/pipes/parse-http-error-code-de.d.ts +0 -3
- package/lib/experimental/pipes/parse-http-error-code-de.pipe.d.ts +0 -12
- package/lib/experimental/pipes/parse-http-error-code-en.d.ts +0 -3
- package/lib/experimental/pipes/parse-http-error-code-en.pipe.d.ts +0 -12
- package/lib/experimental/ws/index.d.ts +0 -2
- package/lib/experimental/ws/web-socket-client-config.d.ts +0 -17
- package/lib/experimental/ws/web-socket-client.d.ts +0 -37
- package/lib/experimental/ws/web-socket-errors.d.ts +0 -7
- package/lib/gql/gql.d.ts +0 -10
- package/lib/gql/index.d.ts +0 -1
- package/lib/infinite-query/index.d.ts +0 -3
- package/lib/infinite-query/infinity-query.d.ts +0 -30
- package/lib/infinite-query/infinity-query.types.d.ts +0 -105
- package/lib/infinite-query/infinity-query.utils.d.ts +0 -5
- package/lib/logger/index.d.ts +0 -1
- package/lib/logger/logger.d.ts +0 -12
- package/lib/query/index.d.ts +0 -3
- package/lib/query/query.d.ts +0 -60
- package/lib/query/query.types.d.ts +0 -397
- package/lib/query/query.utils.d.ts +0 -83
- package/lib/query-client/index.d.ts +0 -3
- package/lib/query-client/query-client.d.ts +0 -29
- package/lib/query-client/query-client.types.d.ts +0 -82
- package/lib/query-client/query-client.utils.d.ts +0 -4
- package/lib/query-creator/index.d.ts +0 -2
- package/lib/query-creator/query-creator.d.ts +0 -20
- package/lib/query-creator/query-creator.types.d.ts +0 -14
- package/lib/query-form/index.d.ts +0 -3
- package/lib/query-form/query-form.d.ts +0 -136
- package/lib/query-form/query-form.types.d.ts +0 -155
- package/lib/query-form/query-form.utils.d.ts +0 -15
- package/lib/query-store/index.d.ts +0 -1
- package/lib/query-store/query-store.d.ts +0 -31
- package/lib/request/index.d.ts +0 -3
- package/lib/request/request.d.ts +0 -3
- package/lib/request/request.types.d.ts +0 -131
- package/lib/request/request.util.d.ts +0 -26
- package/lib/symfony/index.d.ts +0 -2
- package/lib/symfony/symfony.types.d.ts +0 -19
- package/lib/symfony/symfony.utils.d.ts +0 -6
- package/lib/utils/data.utils.d.ts +0 -64
- package/lib/utils/deep-freeze.util.d.ts +0 -1
- package/lib/utils/def.util.d.ts +0 -7
- package/lib/utils/index.d.ts +0 -3
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Injector } from '@angular/core';
|
|
2
|
-
import { HttpRequestResponseType, HttpRequestTransferCacheConfig } from './http-request';
|
|
3
|
-
import { AnyQuery, PathParamsType, Query, QueryArgs } from './query';
|
|
4
|
-
import { QueryClientConfig } from './query-client-config';
|
|
5
|
-
import { QueryFeature } from './query-features';
|
|
6
|
-
export type RouteType<TArgs extends QueryArgs> = PathParamsType<TArgs> extends {
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
} ? (args: TArgs['pathParams']) => RouteString : RouteString;
|
|
9
|
-
export type RouteString = `/${string}`;
|
|
10
|
-
export type CreateQueryCreatorOptions = {
|
|
11
|
-
/**
|
|
12
|
-
* If true, the query loading state will include progress information.
|
|
13
|
-
* This is useful for file uploads and downloads.
|
|
14
|
-
*
|
|
15
|
-
* **Warning**: Upload progress events are not supported by browsers when using the fetch API, such as with `provideHttpClient(withFetch())`.
|
|
16
|
-
* 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.
|
|
17
|
-
*
|
|
18
|
-
* @see https://angular.dev/guide/http/making-requests#receiving-raw-progress-events
|
|
19
|
-
*
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
reportProgress?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The response type of the query.
|
|
25
|
-
* @default 'json'
|
|
26
|
-
*/
|
|
27
|
-
responseType?: HttpRequestResponseType;
|
|
28
|
-
/**
|
|
29
|
-
* Whether to include credentials (cookies) in the request or not.
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
withCredentials?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* This property accepts either a boolean to enable/disable transferring cache for eligible
|
|
35
|
-
* requests performed using `HttpClient`, or an object, which allows to configure cache
|
|
36
|
-
* parameters, such as which headers should be included (no headers are included by default).
|
|
37
|
-
*
|
|
38
|
-
* Setting this property will override the options passed to `provideClientHydration()` for this
|
|
39
|
-
* particular request
|
|
40
|
-
*/
|
|
41
|
-
transferCache?: HttpRequestTransferCacheConfig;
|
|
42
|
-
};
|
|
43
|
-
export type QueryCreator<TArgs extends QueryArgs> = {
|
|
44
|
-
(...features: QueryFeature<TArgs>[]): Query<TArgs>;
|
|
45
|
-
(queryConfig: QueryConfig, ...features: QueryFeature<TArgs>[]): Query<TArgs>;
|
|
46
|
-
};
|
|
47
|
-
export type AnyQueryCreator = QueryCreator<any>;
|
|
48
|
-
export type QueryArgsOf<T extends AnyQueryCreator | AnyQuery> = T extends QueryCreator<infer TArgs> ? TArgs : T extends Query<infer TArgs> ? TArgs : never;
|
|
49
|
-
export type RunQueryCreator<TCreator extends AnyQueryCreator> = ReturnType<TCreator>;
|
|
50
|
-
export type QueryMethod = 'GET' | 'OPTIONS' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'TRACE' | 'CONNECT';
|
|
51
|
-
export type InternalCreateQueryCreatorOptions<TArgs extends QueryArgs> = {
|
|
52
|
-
/**
|
|
53
|
-
* The route of the query.
|
|
54
|
-
* If the query has path params, the route should be a function that takes the path params as an argument.
|
|
55
|
-
* Otherwise, it should be a string.
|
|
56
|
-
*/
|
|
57
|
-
route: RouteType<TArgs>;
|
|
58
|
-
method: QueryMethod;
|
|
59
|
-
client: QueryClientConfig;
|
|
60
|
-
};
|
|
61
|
-
export type QueryConfig = {
|
|
62
|
-
/** A custom id to use for this query. Only affects queries that can be cached. */
|
|
63
|
-
key?: string;
|
|
64
|
-
/**
|
|
65
|
-
* If true, the query will not be executed automatically.
|
|
66
|
-
* Does not affect mutations such as POST, PUT etc. since those are never executed automatically.
|
|
67
|
-
*/
|
|
68
|
-
onlyManualExecution?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* If true, the query will not throw an error because a "withArgs()" feature is missing.
|
|
71
|
-
*/
|
|
72
|
-
silenceMissingWithArgsFeatureError?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* A custom injector to use for this query.
|
|
75
|
-
*/
|
|
76
|
-
injector?: Injector;
|
|
77
|
-
};
|
|
78
|
-
export declare const splitQueryConfig: <TArgs extends QueryArgs>(args: (QueryFeature<TArgs> | QueryConfig)[]) => {
|
|
79
|
-
features: QueryFeature<TArgs>[];
|
|
80
|
-
queryConfig: QueryConfig;
|
|
81
|
-
};
|
|
82
|
-
export declare const createQueryCreator: <TArgs extends QueryArgs>(options: CreateQueryCreatorOptions | undefined, internals: InternalCreateQueryCreatorOptions<TArgs>) => QueryCreator<TArgs>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '@angular/common/http';
|
|
2
|
-
import { DestroyRef, EnvironmentInjector, ErrorHandler, ɵEffectScheduler } from '@angular/core';
|
|
3
|
-
import { QueryClient } from './query-client';
|
|
4
|
-
import { QueryClientConfig } from './query-client-config';
|
|
5
|
-
import { QueryConfig } from './query-creator';
|
|
6
|
-
export type SetupQueryDependenciesOptions = {
|
|
7
|
-
clientConfig: QueryClientConfig;
|
|
8
|
-
queryConfig: QueryConfig | undefined;
|
|
9
|
-
};
|
|
10
|
-
export type QueryDependencies = {
|
|
11
|
-
/** The destroy ref of the query. */
|
|
12
|
-
destroyRef: DestroyRef;
|
|
13
|
-
/** The destroy ref of the scope the query is in (e.g. a component) */
|
|
14
|
-
scopeDestroyRef: DestroyRef;
|
|
15
|
-
/** The query client */
|
|
16
|
-
client: QueryClient;
|
|
17
|
-
/** The injector of the query */
|
|
18
|
-
injector: EnvironmentInjector;
|
|
19
|
-
/** The effect scheduler */
|
|
20
|
-
effectScheduler: ɵEffectScheduler;
|
|
21
|
-
/** The error handler */
|
|
22
|
-
ngErrorHandler: ErrorHandler;
|
|
23
|
-
/** The http client */
|
|
24
|
-
httpClient: HttpClient;
|
|
25
|
-
};
|
|
26
|
-
export declare const setupQueryDependencies: (options: SetupQueryDependenciesOptions) => QueryDependencies;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
|
|
2
|
-
import { ShouldRetryRequestResult } from './query-utils';
|
|
3
|
-
export type QueryErrorResponseList = {
|
|
4
|
-
isList: true;
|
|
5
|
-
errors: QueryErrorResponseItem[];
|
|
6
|
-
};
|
|
7
|
-
export type QueryErrorResponseSingle = {
|
|
8
|
-
isList: false;
|
|
9
|
-
error: QueryErrorResponseItem;
|
|
10
|
-
};
|
|
11
|
-
export type QueryErrorResponse = {
|
|
12
|
-
raw: HttpErrorResponse;
|
|
13
|
-
retryState: ShouldRetryRequestResult;
|
|
14
|
-
code: HttpStatusCode;
|
|
15
|
-
} & (QueryErrorResponseList | QueryErrorResponseSingle);
|
|
16
|
-
export interface QueryErrorResponseItem {
|
|
17
|
-
message: string;
|
|
18
|
-
}
|
|
19
|
-
export declare const createQueryErrorResponse: (error: unknown) => QueryErrorResponse;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { RuntimeError } from '@ethlete/core';
|
|
2
|
-
import { QueryFeatureType } from './query-features';
|
|
3
|
-
export declare const enum QueryRuntimeErrorCode {
|
|
4
|
-
QUERY_FEATURE_USED_MULTIPLE_TIMES = 0,
|
|
5
|
-
WITH_ARGS_QUERY_FEATURE_MISSING_BUT_ROUTE_IS_FUNCTION = 100,
|
|
6
|
-
WITH_POLLING_USED_ON_UNSUPPORTED_HTTP_METHOD = 101,
|
|
7
|
-
WITH_AUTO_REFRESH_USED_ON_UNSUPPORTED_HTTP_METHOD = 102,
|
|
8
|
-
WITH_AUTO_REFRESH_USED_IN_MANUAL_QUERY = 103,
|
|
9
|
-
SILENCE_MISSING_WITH_ARGS_FEATURE_ERROR_USED_BUT_WITH_ARGS_PRESENT = 104,
|
|
10
|
-
COOKIE_LOGIN_TRIED_BUT_COOKIE_DISABLED = 200,
|
|
11
|
-
ENABLE_COOKIE_CALLED_WITHOUT_COOKIE_CONFIG = 201,
|
|
12
|
-
DISABLE_COOKIE_CALLED_WITHOUT_COOKIE_CONFIG = 202,
|
|
13
|
-
LOGIN_CALLED_WITHOUT_CONFIG = 203,
|
|
14
|
-
LOGIN_WITH_TOKEN_CALLED_WITHOUT_CONFIG = 204,
|
|
15
|
-
REFRESH_TOKEN_CALLED_WITHOUT_CONFIG = 205,
|
|
16
|
-
SELECT_ROLE_CALLED_WITHOUT_CONFIG = 206,
|
|
17
|
-
DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_OBJECT = 207,
|
|
18
|
-
DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_CONTAINING_ACCESS_TOKEN = 208,
|
|
19
|
-
DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_CONTAINING_REFRESH_TOKEN = 209,
|
|
20
|
-
UNABLE_TO_DECRYPT_BEARER_TOKEN = 210,
|
|
21
|
-
BEARER_EXPIRES_IN_PROPERTY_NOT_NUMBER = 211,
|
|
22
|
-
UNCACHEABLE_REQUEST_HAS_CACHE_KEY_PARAM = 300,
|
|
23
|
-
UNCACHEABLE_REQUEST_HAS_ALLOW_CACHE_PARAM = 301,
|
|
24
|
-
PAGED_QUERY_STACK_PAGE_BIGGER_THAN_TOTAL_PAGES = 400,
|
|
25
|
-
PAGED_QUERY_STACK_NEXT_PAGE_CALLED_WITHOUT_PREVIOUS_PAGE = 401,
|
|
26
|
-
PAGED_QUERY_STACK_PREVIOUS_PAGE_CALLED_BUT_ALREADY_AT_FIRST_PAGE = 402,
|
|
27
|
-
QUERY_STACK_WITH_ARGS_USED = 500,
|
|
28
|
-
QUERY_STACK_WITH_RESPONSE_UPDATE_USED = 501,
|
|
29
|
-
QUERY_STACK_TOTAL_QUERIES_AND_EXPECTED_QUERIES_MISMATCH = 502
|
|
30
|
-
}
|
|
31
|
-
export declare const queryFeatureUsedMultipleTimes: (type: QueryFeatureType) => RuntimeError<QueryRuntimeErrorCode.QUERY_FEATURE_USED_MULTIPLE_TIMES>;
|
|
32
|
-
export declare const withArgsQueryFeatureMissingButRouteIsFunction: () => RuntimeError<QueryRuntimeErrorCode.WITH_ARGS_QUERY_FEATURE_MISSING_BUT_ROUTE_IS_FUNCTION>;
|
|
33
|
-
export declare const withPollingUsedOnUnsupportedHttpMethod: (method: string) => RuntimeError<QueryRuntimeErrorCode.WITH_POLLING_USED_ON_UNSUPPORTED_HTTP_METHOD>;
|
|
34
|
-
export declare const withAutoRefreshUsedOnUnsupportedHttpMethod: (method: string) => RuntimeError<QueryRuntimeErrorCode.WITH_AUTO_REFRESH_USED_ON_UNSUPPORTED_HTTP_METHOD>;
|
|
35
|
-
export declare const withAutoRefreshUsedInManualQuery: () => RuntimeError<QueryRuntimeErrorCode.WITH_AUTO_REFRESH_USED_IN_MANUAL_QUERY>;
|
|
36
|
-
export declare const silenceMissingWithArgsFeatureErrorUsedButWithArgsPresent: () => RuntimeError<QueryRuntimeErrorCode.SILENCE_MISSING_WITH_ARGS_FEATURE_ERROR_USED_BUT_WITH_ARGS_PRESENT>;
|
|
37
|
-
export declare const cookieLoginTriedButCookieDisabled: () => RuntimeError<QueryRuntimeErrorCode.COOKIE_LOGIN_TRIED_BUT_COOKIE_DISABLED>;
|
|
38
|
-
export declare const enableCookieCalledWithoutCookieConfig: () => RuntimeError<QueryRuntimeErrorCode.ENABLE_COOKIE_CALLED_WITHOUT_COOKIE_CONFIG>;
|
|
39
|
-
export declare const disableCookieCalledWithoutCookieConfig: () => RuntimeError<QueryRuntimeErrorCode.DISABLE_COOKIE_CALLED_WITHOUT_COOKIE_CONFIG>;
|
|
40
|
-
export declare const loginCalledWithoutConfig: () => RuntimeError<QueryRuntimeErrorCode.LOGIN_CALLED_WITHOUT_CONFIG>;
|
|
41
|
-
export declare const loginWithTokenCalledWithoutConfig: () => RuntimeError<QueryRuntimeErrorCode.LOGIN_WITH_TOKEN_CALLED_WITHOUT_CONFIG>;
|
|
42
|
-
export declare const refreshTokenCalledWithoutConfig: () => RuntimeError<QueryRuntimeErrorCode.REFRESH_TOKEN_CALLED_WITHOUT_CONFIG>;
|
|
43
|
-
export declare const selectRoleCalledWithoutConfig: () => RuntimeError<QueryRuntimeErrorCode.SELECT_ROLE_CALLED_WITHOUT_CONFIG>;
|
|
44
|
-
export declare const defaultResponseTransformerResponseNotObject: (currentType: string) => RuntimeError<QueryRuntimeErrorCode.DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_OBJECT>;
|
|
45
|
-
export declare const defaultResponseTransformerResponseNotContainingAccessToken: () => RuntimeError<QueryRuntimeErrorCode.DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_CONTAINING_ACCESS_TOKEN>;
|
|
46
|
-
export declare const defaultResponseTransformerResponseNotContainingRefreshToken: () => RuntimeError<QueryRuntimeErrorCode.DEFAULT_RESPONSE_TRANSFORMER_RESPONSE_NOT_CONTAINING_REFRESH_TOKEN>;
|
|
47
|
-
export declare const unableToDecryptBearerToken: (token: string) => RuntimeError<QueryRuntimeErrorCode.UNABLE_TO_DECRYPT_BEARER_TOKEN>;
|
|
48
|
-
export declare const bearerExpiresInPropertyNotNumber: (expiresIn: unknown) => RuntimeError<QueryRuntimeErrorCode.BEARER_EXPIRES_IN_PROPERTY_NOT_NUMBER>;
|
|
49
|
-
export declare const uncacheableRequestHasCacheKeyParam: (key: string) => RuntimeError<QueryRuntimeErrorCode.UNCACHEABLE_REQUEST_HAS_CACHE_KEY_PARAM>;
|
|
50
|
-
export declare const uncacheableRequestHasAllowCacheParam: () => RuntimeError<QueryRuntimeErrorCode.UNCACHEABLE_REQUEST_HAS_ALLOW_CACHE_PARAM>;
|
|
51
|
-
export declare const pagedQueryStackPageBiggerThanTotalPages: (page: number, totalPages: number) => RuntimeError<QueryRuntimeErrorCode.PAGED_QUERY_STACK_PAGE_BIGGER_THAN_TOTAL_PAGES>;
|
|
52
|
-
export declare const pagedQueryStackNextPageCalledWithoutPreviousPage: () => RuntimeError<QueryRuntimeErrorCode.PAGED_QUERY_STACK_NEXT_PAGE_CALLED_WITHOUT_PREVIOUS_PAGE>;
|
|
53
|
-
export declare const pagedQueryStackPreviousPageCalledButAlreadyAtFirstPage: () => RuntimeError<QueryRuntimeErrorCode.PAGED_QUERY_STACK_PREVIOUS_PAGE_CALLED_BUT_ALREADY_AT_FIRST_PAGE>;
|
|
54
|
-
export declare const queryStackWithArgsUsed: () => RuntimeError<QueryRuntimeErrorCode.QUERY_STACK_WITH_ARGS_USED>;
|
|
55
|
-
export declare const queryStackWithResponseUpdateUsed: () => RuntimeError<QueryRuntimeErrorCode.QUERY_STACK_WITH_RESPONSE_UPDATE_USED>;
|
|
56
|
-
export declare const queryStackTotalQueriesAndExpectedQueriesMismatch: (totalQueries: number, expectedQueries: number) => RuntimeError<QueryRuntimeErrorCode.QUERY_STACK_TOTAL_QUERIES_AND_EXPECTED_QUERIES_MISMATCH>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { EffectRef, WritableSignal } from '@angular/core';
|
|
2
|
-
import { QueryArgs, RequestArgs } from './query';
|
|
3
|
-
import { CreateQueryExecuteOptions } from './query-execute';
|
|
4
|
-
export type ResetExecuteStateOptions<TArgs extends QueryArgs> = {
|
|
5
|
-
executeOptions: Pick<CreateQueryExecuteOptions<TArgs>, 'state' | 'deps'>;
|
|
6
|
-
executeState: QueryExecuteState;
|
|
7
|
-
};
|
|
8
|
-
export declare const resetExecuteState: <TArgs extends QueryArgs>(options: ResetExecuteStateOptions<TArgs>) => void;
|
|
9
|
-
export type QueryExecuteState = {
|
|
10
|
-
effectRefs: EffectRef[];
|
|
11
|
-
previousKey: WritableSignal<string | false>;
|
|
12
|
-
};
|
|
13
|
-
export declare const setupQueryExecuteState: () => QueryExecuteState;
|
|
14
|
-
export type RunQueryExecuteOptions = {
|
|
15
|
-
allowCache?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export type InternalRunQueryExecuteOptions = {
|
|
18
|
-
/**
|
|
19
|
-
* If true, the request will be forced to be cached (saved inside the query repository).
|
|
20
|
-
* Can be used to e.g. cache GQL queries transported via POST
|
|
21
|
-
*
|
|
22
|
-
* - `true` means the request will always be cached
|
|
23
|
-
* - `false` means the request will never be cached
|
|
24
|
-
* - `undefined` means the request will be cached if the method is GET, OPTIONS or HEAD
|
|
25
|
-
*/
|
|
26
|
-
useQueryRepositoryCache?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export type QueryExecuteOptions<TArgs extends QueryArgs> = {
|
|
29
|
-
executeOptions: CreateQueryExecuteOptions<TArgs>;
|
|
30
|
-
executeState: QueryExecuteState;
|
|
31
|
-
args: RequestArgs<TArgs> | null;
|
|
32
|
-
options?: RunQueryExecuteOptions;
|
|
33
|
-
internalOptions?: InternalRunQueryExecuteOptions;
|
|
34
|
-
transformResponse?: (response: any) => any;
|
|
35
|
-
isSecure?: boolean;
|
|
36
|
-
};
|
|
37
|
-
export declare const queryExecute: <TArgs extends QueryArgs>(options: QueryExecuteOptions<TArgs>) => void;
|
|
38
|
-
export type CleanupPreviousExecuteOptions<TArgs extends QueryArgs> = {
|
|
39
|
-
executeOptions: Pick<CreateQueryExecuteOptions<TArgs>, 'state'>;
|
|
40
|
-
executeState: QueryExecuteState;
|
|
41
|
-
};
|
|
42
|
-
export declare const cleanupPreviousExecute: <TArgs extends QueryArgs>(options: CleanupPreviousExecuteOptions<TArgs>) => void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import { QueryArgs, RequestArgs } from './query';
|
|
3
|
-
import { CreateQueryCreatorOptions, InternalCreateQueryCreatorOptions, QueryConfig } from './query-creator';
|
|
4
|
-
import { QueryDependencies } from './query-dependencies';
|
|
5
|
-
import { RunQueryExecuteOptions } from './query-execute-utils';
|
|
6
|
-
import { QueryKeyOrNone } from './query-repository';
|
|
7
|
-
import { QueryState } from './query-state';
|
|
8
|
-
export type CreateQueryExecuteOptions<TArgs extends QueryArgs> = {
|
|
9
|
-
deps: QueryDependencies;
|
|
10
|
-
state: QueryState<TArgs>;
|
|
11
|
-
creator?: CreateQueryCreatorOptions;
|
|
12
|
-
creatorInternals: InternalCreateQueryCreatorOptions<TArgs>;
|
|
13
|
-
queryConfig: QueryConfig;
|
|
14
|
-
};
|
|
15
|
-
export type QueryExecuteArgs<TArgs extends QueryArgs> = {
|
|
16
|
-
args?: RequestArgs<TArgs> | null;
|
|
17
|
-
options?: RunQueryExecuteOptions;
|
|
18
|
-
};
|
|
19
|
-
export type InternalQueryExecute<TArgs extends QueryArgs> = {
|
|
20
|
-
(executeArgs?: QueryExecuteArgs<TArgs>): void;
|
|
21
|
-
reset: () => void;
|
|
22
|
-
currentRepositoryKey: Signal<QueryKeyOrNone>;
|
|
23
|
-
};
|
|
24
|
-
export type QueryExecute<TArgs extends QueryArgs> = (executeArgs?: QueryExecuteArgs<TArgs>) => void;
|
|
25
|
-
export declare const createExecuteFn: <TArgs extends QueryArgs>(executeOptions: CreateQueryExecuteOptions<TArgs>) => InternalQueryExecute<TArgs>;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { HttpEvent } from '@angular/common/http';
|
|
2
|
-
import { Signal } from '@angular/core';
|
|
3
|
-
import { QueryArgs, RequestArgs, ResponseType } from './query';
|
|
4
|
-
import { QueryDependencies } from './query-dependencies';
|
|
5
|
-
import { QueryErrorResponse } from './query-error-response';
|
|
6
|
-
import { InternalQueryExecute } from './query-execute';
|
|
7
|
-
import { QueryState } from './query-state';
|
|
8
|
-
import { ClearQueryArgs, QueryFeatureFlags } from './query-utils';
|
|
9
|
-
export declare const enum QueryFeatureType {
|
|
10
|
-
WithArgs = "withArgs",
|
|
11
|
-
WithLogging = "withLogging",
|
|
12
|
-
WithErrorHandling = "withErrorHandling",
|
|
13
|
-
WithSuccessHandling = "withSuccessHandling",
|
|
14
|
-
WithPolling = "withPolling",
|
|
15
|
-
WithAutoRefresh = "withAutoRefresh",
|
|
16
|
-
WithResponseUpdate = "withResponseUpdate"
|
|
17
|
-
}
|
|
18
|
-
export type QueryFeatureContext<TArgs extends QueryArgs> = {
|
|
19
|
-
state: QueryState<TArgs>;
|
|
20
|
-
execute: InternalQueryExecute<TArgs>;
|
|
21
|
-
deps: QueryDependencies;
|
|
22
|
-
flags: QueryFeatureFlags;
|
|
23
|
-
};
|
|
24
|
-
export type QueryFeatureFn<TArgs extends QueryArgs> = (context: QueryFeatureContext<TArgs>) => void;
|
|
25
|
-
export type QueryFeature<TArgs extends QueryArgs> = {
|
|
26
|
-
type: QueryFeatureType;
|
|
27
|
-
fn: (context: QueryFeatureContext<TArgs>) => void;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* A query feature that allows you to set the arguments of the query.
|
|
31
|
-
* The arguments are read within a computed function, so you can use reactive values.
|
|
32
|
-
*
|
|
33
|
-
* To set the arguments to `null`, return the symbol `CLEAR_QUERY_ARGS`.
|
|
34
|
-
* If you instead return `null`, the arguments won't change.
|
|
35
|
-
*
|
|
36
|
-
* Changing arguments will automatically trigger a new execution of the query if it is eligible for auto execution (e.g. a GET request).
|
|
37
|
-
*/
|
|
38
|
-
export declare const withArgs: <TArgs extends QueryArgs>(args: () => NoInfer<RequestArgs<TArgs>> | ClearQueryArgs | null) => QueryFeature<TArgs>;
|
|
39
|
-
export type WithPollingFeatureOptions = {
|
|
40
|
-
/** The interval in milliseconds at which the query should be executed */
|
|
41
|
-
interval: number;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the query should be executed initially.
|
|
44
|
-
* By default, the query will be executed after the first interval.
|
|
45
|
-
* @default false
|
|
46
|
-
*/
|
|
47
|
-
executeInitially?: boolean;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* A query feature that will automatically execute the query at a given interval.
|
|
51
|
-
* The interval will be cleared when the query is destroyed.
|
|
52
|
-
* The interval will be reset when the arguments of the query change.
|
|
53
|
-
*
|
|
54
|
-
* @throws If the query is not eligible for auto execution (e.g. a POST request)
|
|
55
|
-
*/
|
|
56
|
-
export declare const withPolling: <TArgs extends QueryArgs>(options: WithPollingFeatureOptions) => QueryFeature<TArgs>;
|
|
57
|
-
export type WithLoggingFeatureOptions<TArgs extends QueryArgs> = {
|
|
58
|
-
/** A function that will be called with the latest http event */
|
|
59
|
-
logFn: (v: HttpEvent<ResponseType<TArgs>> | null) => void;
|
|
60
|
-
};
|
|
61
|
-
/** A query feature that can be used to log the latest http event */
|
|
62
|
-
export declare const withLogging: <TArgs extends QueryArgs>(options: WithLoggingFeatureOptions<TArgs>) => QueryFeature<TArgs>;
|
|
63
|
-
export type WithErrorHandlingFeatureOptions = {
|
|
64
|
-
/** A function that will be called with the latest error */
|
|
65
|
-
handler: (e: QueryErrorResponse) => void;
|
|
66
|
-
};
|
|
67
|
-
/** A query feature that can be used to handle errors */
|
|
68
|
-
export declare const withErrorHandling: <TArgs extends QueryArgs>(options: WithErrorHandlingFeatureOptions) => QueryFeature<TArgs>;
|
|
69
|
-
type WithSuccessHandlingFeatureOptions<TArgs extends QueryArgs> = {
|
|
70
|
-
/** A function that will be called with the latest response */
|
|
71
|
-
handler: (data: NonNullable<ResponseType<TArgs>>) => void;
|
|
72
|
-
};
|
|
73
|
-
/** A query feature that can be used to handle successful responses */
|
|
74
|
-
export declare const withSuccessHandling: <TArgs extends QueryArgs>(options: WithSuccessHandlingFeatureOptions<TArgs>) => QueryFeature<TArgs>;
|
|
75
|
-
export type WithAutoRefreshFeatureOptions = {
|
|
76
|
-
/** The signals that should trigger a refresh of the query */
|
|
77
|
-
onSignalChanges: Signal<unknown>[];
|
|
78
|
-
/** Whether to ignore the `onlyManualExecution` query config flag */
|
|
79
|
-
ignoreOnlyManualExecution?: boolean;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* A query feature that will automatically execute the query when any of the provided signals change
|
|
83
|
-
* @throws If the query is not eligible for auto execution (e.g. a POST request)
|
|
84
|
-
* @throws If the query has the `onlyManualExecution` query config flag set and `ignoreOnlyManualExecution` is not set
|
|
85
|
-
*/
|
|
86
|
-
export declare const withAutoRefresh: <TArgs extends QueryArgs>(options: WithAutoRefreshFeatureOptions) => QueryFeature<TArgs>;
|
|
87
|
-
export type WithResponseUpdateFeatureFnData<TArgs extends QueryArgs> = {
|
|
88
|
-
/** The current response of the query */
|
|
89
|
-
currentResponse: ResponseType<TArgs> | null;
|
|
90
|
-
};
|
|
91
|
-
export type WithResponseUpdateFeatureOptions<TArgs extends QueryArgs> = {
|
|
92
|
-
/**
|
|
93
|
-
* A function that will be called with the latest response
|
|
94
|
-
* If the function returns `null`, the response will not be updated.
|
|
95
|
-
* Otherwise, the response will be updated with the returned value.
|
|
96
|
-
* The function will be called in a reactive signal context.
|
|
97
|
-
* If the query get's executed after the response was updated, the response will be set the the fresh data received from the server.
|
|
98
|
-
*
|
|
99
|
-
* 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.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* const matchEvents = mySocket.joinRoom('match-events');
|
|
103
|
-
*
|
|
104
|
-
* const myMatchQuery = getMatch(
|
|
105
|
-
* withArgs(() => ({ matchId: 1 })),
|
|
106
|
-
* withResponseUpdate(({ currentResponse }) => {
|
|
107
|
-
* const matchEvent = matchEvents();
|
|
108
|
-
*
|
|
109
|
-
* if (!matchEvent) return null;
|
|
110
|
-
*
|
|
111
|
-
* // Do some checks here. This is just a very simple example.
|
|
112
|
-
* // To apply partial updates, you can use the spread operator in combination with the current response.
|
|
113
|
-
*
|
|
114
|
-
* return matchEvent;
|
|
115
|
-
* })
|
|
116
|
-
* )
|
|
117
|
-
*/
|
|
118
|
-
updater: (data: WithResponseUpdateFeatureFnData<TArgs>) => ResponseType<TArgs> | null;
|
|
119
|
-
};
|
|
120
|
-
export declare const withResponseUpdate: <TArgs extends QueryArgs>(options: WithResponseUpdateFeatureOptions<TArgs>) => QueryFeature<TArgs>;
|
|
121
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '@angular/common/http';
|
|
2
|
-
import { DestroyRef, ErrorHandler } from '@angular/core';
|
|
3
|
-
import { CreateHttpRequestClientOptions, HttpRequest } from './http-request';
|
|
4
|
-
import { QueryArgs, RequestArgs } from './query';
|
|
5
|
-
import { QueryClientConfig } from './query-client-config';
|
|
6
|
-
import { QueryMethod, RouteType } from './query-creator';
|
|
7
|
-
import { InternalRunQueryExecuteOptions, RunQueryExecuteOptions } from './query-execute-utils';
|
|
8
|
-
export type QueryRepositoryRequestOptions<TArgs extends QueryArgs> = {
|
|
9
|
-
/**
|
|
10
|
-
* The route of the request.
|
|
11
|
-
* @example '/users'
|
|
12
|
-
* @example (args) => `/users/${args.userId}`
|
|
13
|
-
*/
|
|
14
|
-
route: RouteType<TArgs>;
|
|
15
|
-
/** The HTTP method of the request */
|
|
16
|
-
method: QueryMethod;
|
|
17
|
-
/** If the request is secure (needs authentication) */
|
|
18
|
-
isSecure?: boolean;
|
|
19
|
-
/** The data of the request */
|
|
20
|
-
args?: RequestArgs<TArgs> | null;
|
|
21
|
-
/** The client options of the request */
|
|
22
|
-
clientOptions?: CreateHttpRequestClientOptions;
|
|
23
|
-
/** If set, this request's cache key will be prefixed with this key */
|
|
24
|
-
key?: string;
|
|
25
|
-
/** The previous cache key of the request */
|
|
26
|
-
previousKey?: string | false;
|
|
27
|
-
/** The destroy ref to bind the request to. If the destroy ref is destroyed, the request will be destroyed as well. */
|
|
28
|
-
consumerDestroyRef: DestroyRef;
|
|
29
|
-
/** Configuration on how to run the query */
|
|
30
|
-
runQueryOptions?: RunQueryExecuteOptions;
|
|
31
|
-
/** Internal options for running the query */
|
|
32
|
-
internalRunQueryOptions?: InternalRunQueryExecuteOptions;
|
|
33
|
-
};
|
|
34
|
-
export type QueryRepositoryItem<TArgs extends QueryArgs> = {
|
|
35
|
-
/** The key of the request. If the key is `false`, the request is not cached, otherwise it is. */
|
|
36
|
-
key: QueryKeyOrNone;
|
|
37
|
-
/** The request object */
|
|
38
|
-
request: HttpRequest<TArgs>;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* The query repository is responsible for managing all requests and their consumers.
|
|
42
|
-
* It will cache requests if they can be cached and reuse them if they are already cached.
|
|
43
|
-
* It will also destroy requests if there are no more consumers left.
|
|
44
|
-
*/
|
|
45
|
-
export type QueryRepository = {
|
|
46
|
-
/** Creates a new request. If the request is already cached, it will be reused. */
|
|
47
|
-
request: <TArgs extends QueryArgs>(options: QueryRepositoryRequestOptions<TArgs>) => QueryRepositoryItem<TArgs>;
|
|
48
|
-
/** Removes a consumer from a request by its key. Destroys the request if there are no more consumers left. */
|
|
49
|
-
unbind: (key: QueryKeyOrNone, consumerDestroyRef: DestroyRef) => boolean;
|
|
50
|
-
/** Removes all secure requests and their consumers */
|
|
51
|
-
unbindAllSecure: () => void;
|
|
52
|
-
};
|
|
53
|
-
/** The key of a query */
|
|
54
|
-
export type QueryKey = string;
|
|
55
|
-
/** A key that will not be cached */
|
|
56
|
-
export type QueryKeyNoCache = false;
|
|
57
|
-
/** A key that may or may not be cached */
|
|
58
|
-
export type QueryKeyOrNone = QueryKey | QueryKeyNoCache;
|
|
59
|
-
export type QueryRepositoryDependencies = {
|
|
60
|
-
/** The HTTP client to use for the requests */
|
|
61
|
-
httpClient: HttpClient;
|
|
62
|
-
/** The error handler to use for the requests */
|
|
63
|
-
ngErrorHandler: ErrorHandler;
|
|
64
|
-
};
|
|
65
|
-
export type CreateQueryRepositoryConfig = QueryClientConfig & {
|
|
66
|
-
/** The dependencies of the query repository */
|
|
67
|
-
dependencies: QueryRepositoryDependencies;
|
|
68
|
-
};
|
|
69
|
-
export declare const createQueryRepository: (config: CreateQueryRepositoryConfig) => QueryRepository;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { QueryArgs, QuerySnapshot } from './query';
|
|
2
|
-
import { QueryDependencies } from './query-dependencies';
|
|
3
|
-
import { InternalQueryExecute } from './query-execute';
|
|
4
|
-
import { QueryState } from './query-state';
|
|
5
|
-
export type CreateQuerySnapshotOptions<TArgs extends QueryArgs> = {
|
|
6
|
-
state: QueryState<TArgs>;
|
|
7
|
-
deps: QueryDependencies;
|
|
8
|
-
execute: InternalQueryExecute<TArgs>;
|
|
9
|
-
};
|
|
10
|
-
export declare const createQuerySnapshotFn: <TArgs extends QueryArgs>(options: CreateQuerySnapshotOptions<TArgs>) => () => QuerySnapshot<TArgs>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import { AnyQuery, RequestArgs, ResponseType } from './query';
|
|
3
|
-
import { AnyQueryCreator, QueryArgsOf, RunQueryCreator } from './query-creator';
|
|
4
|
-
import { QueryErrorResponse } from './query-error-response';
|
|
5
|
-
import { QueryFeature } from './query-features';
|
|
6
|
-
export type QueryStackSubtle<TCreator extends AnyQueryCreator, TQuery extends AnyQuery> = {
|
|
7
|
-
/** Create a new query with the given arguments. You should always prefer the `args` option instead of this. */
|
|
8
|
-
runWithArgs: (args: RequestArgs<QueryArgsOf<TCreator>> | RequestArgs<QueryArgsOf<TCreator>>[] | null) => TQuery | null;
|
|
9
|
-
};
|
|
10
|
-
export type QueryStack<TQuery extends AnyQuery, TCreator extends AnyQueryCreator, TTransform> = {
|
|
11
|
-
/** Contains all queries in the stack. */
|
|
12
|
-
queries: Signal<TQuery[]>;
|
|
13
|
-
/** Contains the first query in the stack. */
|
|
14
|
-
firstQuery: Signal<TQuery | null>;
|
|
15
|
-
/** Contains the last query in the stack. Useful for getting current pagination values. */
|
|
16
|
-
lastQuery: Signal<TQuery | null>;
|
|
17
|
-
/** True if any query in the stack is loading. */
|
|
18
|
-
loading: Signal<boolean>;
|
|
19
|
-
/** Contains the first error that occurred in the stack. */
|
|
20
|
-
error: Signal<QueryErrorResponse | null>;
|
|
21
|
-
/** Contains the responses of all queries in the stack. Will be `null` for queries that are loading or errored. */
|
|
22
|
-
response: Signal<TTransform>;
|
|
23
|
-
/** Executes all queries in the stack. */
|
|
24
|
-
execute: (options?: {
|
|
25
|
-
allowCache?: boolean;
|
|
26
|
-
}) => void;
|
|
27
|
-
/** Destroys all queries in the stack and empties it. This should only be used if `append` is true. */
|
|
28
|
-
clear: () => void;
|
|
29
|
-
/** Advanced query stack features. **WARNING!** Incorrectly using these features will likely **BREAK** your application. You have been warned! */
|
|
30
|
-
subtle: QueryStackSubtle<TCreator, TQuery>;
|
|
31
|
-
};
|
|
32
|
-
export type AnyQueryStack = QueryStack<AnyQuery, AnyQueryCreator, any>;
|
|
33
|
-
export type CreateQueryStackOptions<TCreator extends AnyQueryCreator, TDeps extends () => any, TTransform = (ResponseType<QueryArgsOf<TCreator>> | null)[]> = {
|
|
34
|
-
/**
|
|
35
|
-
* The query creator function that will be used to create the query stack.
|
|
36
|
-
*/
|
|
37
|
-
queryCreator: TCreator;
|
|
38
|
-
/**
|
|
39
|
-
* The dependencies that should trigger a new query stack creation.
|
|
40
|
-
* This function can be treated like a computed function. It reacts to signal changes.
|
|
41
|
-
* The return value of this function will be passed to the `args` function.
|
|
42
|
-
*
|
|
43
|
-
* This option can be ignored if `append` is false.
|
|
44
|
-
*/
|
|
45
|
-
dependencies?: TDeps;
|
|
46
|
-
/**
|
|
47
|
-
* The features that should be used for all queries in the stack.
|
|
48
|
-
*
|
|
49
|
-
* @throws If the `withArgs` feature is used. This feature is internally used.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* // Due to limitations in TypeScript, you have to manually add the needed generic types if needed.
|
|
53
|
-
* features: [E.withSuccessHandling<GetPostQueryArgs>({ handler: (post) => console.log(post.title) })]
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* // If typings are not needed, you can use the feature without generics.
|
|
57
|
-
* features: [E.withPolling({ interval: 5000 })]
|
|
58
|
-
*/
|
|
59
|
-
features?: QueryFeature<any>[];
|
|
60
|
-
/**
|
|
61
|
-
* The arguments to create queries with.
|
|
62
|
-
* This function can be treated like a computed function. It reacts to signal changes.
|
|
63
|
-
* If a signal changes, a new query will be created (and appended to the existing ones if `append` is true).
|
|
64
|
-
* If this function returns `null`, the args will be ignored.
|
|
65
|
-
* If this function returns an array, multiple queries will be created.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // One query
|
|
69
|
-
* () => ({ queryParams: { postId: myId() } }),
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* // Multiple queries (these can of cause also be created using a loop)
|
|
73
|
-
* () => [
|
|
74
|
-
* { queryParams: { postId: myId() } },
|
|
75
|
-
* { queryParams: { postId: myOtherId() } },
|
|
76
|
-
* ],
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* // One query with dependencies
|
|
80
|
-
* (deps) => ({ queryParams: { postId: myId(), limit: deps.limit } }),
|
|
81
|
-
*/
|
|
82
|
-
args: (deps: ReturnType<TDeps>) => RequestArgs<QueryArgsOf<TCreator>> | RequestArgs<QueryArgsOf<TCreator>>[] | null;
|
|
83
|
-
/**
|
|
84
|
-
* If true, new queries will be appended to the existing ones. Otherwise, existing queries will be destroyed.
|
|
85
|
-
* This should be used for things like infinite scrolling where already fetched queries should not be destroyed.
|
|
86
|
-
*/
|
|
87
|
-
append?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* If append is true, this function will be called to merge the old and new queries.
|
|
90
|
-
* Useful if you want to append the new queries in a specific order (e.g. at the beginning).
|
|
91
|
-
*/
|
|
92
|
-
appendFn?: (oldQueries: RunQueryCreator<TCreator>[], newQueries: RunQueryCreator<TCreator>[]) => {
|
|
93
|
-
/** The new queries merged with the old ones. */
|
|
94
|
-
queries: RunQueryCreator<TCreator>[];
|
|
95
|
-
/** The last query in the new queries. */
|
|
96
|
-
lastQuery: RunQueryCreator<TCreator> | null;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Transforms the responses of all queries in the stack. Useful for merging or filtering responses.
|
|
100
|
-
*/
|
|
101
|
-
transform?: (responses: ResponseType<QueryArgsOf<TCreator>>[]) => TTransform;
|
|
102
|
-
};
|
|
103
|
-
/** Transforms an array of arrays into a single array and filters out `null` values. */
|
|
104
|
-
export declare const transformArrayResponse: <T extends (unknown | null)[]>(responses: T) => NonNullable<T[0]>[];
|
|
105
|
-
/** Transforms an array of paginated responses into a single array and filters out `null` values. */
|
|
106
|
-
export declare const transformPaginatedResponse: <T extends ({
|
|
107
|
-
items: unknown[];
|
|
108
|
-
} | null)[]>(responses: T) => NonNullable<NonNullable<T[0]>["items"]>;
|
|
109
|
-
export declare const createQueryStack: <TCreator extends AnyQueryCreator, TArgs extends QueryArgsOf<TCreator>, TDeps extends () => any, TTransform = (ResponseType<TArgs> | null)[]>(options: CreateQueryStackOptions<TCreator, TDeps, TTransform>) => QueryStack<RunQueryCreator<TCreator>, TCreator, TTransform>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { HttpEvent } from '@angular/common/http';
|
|
2
|
-
import { Signal, WritableSignal } from '@angular/core';
|
|
3
|
-
import { HttpRequest, HttpRequestLoadingState } from './http-request';
|
|
4
|
-
import { QueryArgs, RequestArgs, ResponseType } from './query';
|
|
5
|
-
import { QueryErrorResponse } from './query-error-response';
|
|
6
|
-
export type SetupQueryStateOptions = {};
|
|
7
|
-
export type QueryStateSubtle<TArgs extends QueryArgs> = {
|
|
8
|
-
request: WritableSignal<HttpRequest<TArgs> | null>;
|
|
9
|
-
};
|
|
10
|
-
export type QueryState<TArgs extends QueryArgs> = {
|
|
11
|
-
response: WritableSignal<ResponseType<TArgs> | null>;
|
|
12
|
-
args: WritableSignal<RequestArgs<TArgs> | null>;
|
|
13
|
-
latestHttpEvent: WritableSignal<HttpEvent<ResponseType<TArgs>> | null>;
|
|
14
|
-
loading: WritableSignal<HttpRequestLoadingState | null>;
|
|
15
|
-
error: WritableSignal<QueryErrorResponse | null>;
|
|
16
|
-
lastTimeExecutedAt: WritableSignal<number | null>;
|
|
17
|
-
executionState: Signal<QueryExecutionState<TArgs> | null>;
|
|
18
|
-
subtle: QueryStateSubtle<TArgs>;
|
|
19
|
-
};
|
|
20
|
-
export type QueryExecutionStateSuccess<TArgs extends QueryArgs> = {
|
|
21
|
-
type: 'success';
|
|
22
|
-
response: ResponseType<TArgs>;
|
|
23
|
-
};
|
|
24
|
-
export type QueryExecutionStateFailure = {
|
|
25
|
-
type: 'failure';
|
|
26
|
-
error: QueryErrorResponse;
|
|
27
|
-
};
|
|
28
|
-
export type QueryExecutionStateLoadingWithNoResponse = {
|
|
29
|
-
type: 'loading';
|
|
30
|
-
hasCachedResponse: false;
|
|
31
|
-
loading: HttpRequestLoadingState;
|
|
32
|
-
};
|
|
33
|
-
export type QueryExecutionStateLoadingWithCachedResponse<TArgs extends QueryArgs> = {
|
|
34
|
-
type: 'loading';
|
|
35
|
-
hasCachedResponse: true;
|
|
36
|
-
loading: HttpRequestLoadingState;
|
|
37
|
-
cachedResponse: ResponseType<TArgs>;
|
|
38
|
-
};
|
|
39
|
-
export type QueryExecutionStateLoading<TArgs extends QueryArgs> = QueryExecutionStateLoadingWithNoResponse | QueryExecutionStateLoadingWithCachedResponse<TArgs>;
|
|
40
|
-
export type QueryExecutionState<TArgs extends QueryArgs> = QueryExecutionStateSuccess<TArgs> | QueryExecutionStateFailure | QueryExecutionStateLoading<TArgs>;
|
|
41
|
-
export declare const setupQueryState: <TArgs extends QueryArgs>(options: SetupQueryStateOptions) => QueryState<TArgs>;
|