@ethlete/query 5.20.1 → 5.21.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/esm2022/lib/experimental/http-request.mjs +3 -3
- package/esm2022/lib/experimental/index.mjs +2 -1
- package/esm2022/lib/experimental/paged-query.mjs +194 -0
- package/esm2022/lib/experimental/query-errors.mjs +10 -1
- package/esm2022/lib/experimental/query-execute.mjs +3 -3
- package/esm2022/lib/experimental/query-repository.mjs +2 -2
- package/esm2022/lib/experimental/query-stack.mjs +4 -4
- package/esm2022/lib/query-form/query-form.mjs +4 -1
- package/esm2022/lib/query-form/query-form.types.mjs +1 -1
- package/fesm2022/ethlete-query.mjs +402 -192
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/lib/experimental/http-request.d.ts +3 -1
- package/lib/experimental/index.d.ts +1 -0
- package/lib/experimental/paged-query.d.ts +35 -0
- package/lib/experimental/query-errors.d.ts +7 -1
- package/lib/experimental/query-stack.d.ts +4 -2
- package/lib/query-form/query-form.types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -91,7 +91,9 @@ export type HttpRequestLoadingProgressState = {
|
|
|
91
91
|
};
|
|
92
92
|
export type HttpRequest<TArgs extends QueryArgs> = {
|
|
93
93
|
/** Executes the request */
|
|
94
|
-
execute: (
|
|
94
|
+
execute: (options?: {
|
|
95
|
+
skipCache?: boolean;
|
|
96
|
+
}) => boolean;
|
|
95
97
|
/** Destroys the request (cancels it if in progress) */
|
|
96
98
|
destroy: () => boolean;
|
|
97
99
|
/** The loading state of the request */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ContentfulGqlLikePaginated, DynLikePaginated, GgLikePaginated, NormalizedPagination, Paginated } from '@ethlete/types';
|
|
2
|
+
import { Query, QueryArgs, RequestArgs, ResponseType } from './query';
|
|
3
|
+
import { QueryCreator } from './query-creator';
|
|
4
|
+
export declare const ethletePaginationAdapter: <T>(response: Paginated<T>) => NormalizedPagination<T>;
|
|
5
|
+
export declare const ggLikePaginationAdapter: <T>(response: GgLikePaginated<T>) => NormalizedPagination<T>;
|
|
6
|
+
export declare const dynLikePaginationAdapter: <T>(response: DynLikePaginated<T>) => NormalizedPagination<T>;
|
|
7
|
+
export declare const contentfulGqlLikePaginationAdapter: <T>(response: ContentfulGqlLikePaginated<T>) => NormalizedPagination<T>;
|
|
8
|
+
export type CreatePagedQueryOptions<TArgs extends QueryArgs> = {
|
|
9
|
+
responseNormalizer: (response: ResponseType<TArgs>) => NormalizedPagination<ResponseType<TArgs>>;
|
|
10
|
+
queryCreator: QueryCreator<TArgs>;
|
|
11
|
+
args: (page: number) => RequestArgs<TArgs>;
|
|
12
|
+
initialPage?: number;
|
|
13
|
+
};
|
|
14
|
+
export type PagedQueryResetOptions = {
|
|
15
|
+
initialPage?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const createPagedQuery: <TArgs extends QueryArgs>(options: CreatePagedQueryOptions<TArgs>) => {
|
|
18
|
+
pagination: import("@angular/core").Signal<NormalizedPagination<ResponseType<TArgs>> | null>;
|
|
19
|
+
fetchPreviousPage: () => void;
|
|
20
|
+
fetchNextPage: () => void;
|
|
21
|
+
canFetchPreviousPage: import("@angular/core").Signal<boolean>;
|
|
22
|
+
canFetchNextPage: import("@angular/core").Signal<boolean>;
|
|
23
|
+
items: import("@angular/core").Signal<ResponseType<TArgs>[]>;
|
|
24
|
+
direction: import("@angular/core").Signal<"next" | "previous">;
|
|
25
|
+
loading: import("@angular/core").Signal<boolean>;
|
|
26
|
+
error: import("@angular/core").Signal<import("@angular/common/http").HttpErrorResponse | null>;
|
|
27
|
+
lastQuery: import("@angular/core").Signal<Query<TArgs> | null>;
|
|
28
|
+
isFirstLoad: import("@angular/core").Signal<boolean>;
|
|
29
|
+
queries: Query<TArgs>[];
|
|
30
|
+
reset: (resetOptions?: PagedQueryResetOptions) => void;
|
|
31
|
+
execute: (options?: {
|
|
32
|
+
where?: (items: ResponseType<TArgs>) => boolean;
|
|
33
|
+
skipCache?: boolean;
|
|
34
|
+
}) => void;
|
|
35
|
+
};
|
|
@@ -20,7 +20,10 @@ export declare const enum RuntimeErrorCode {
|
|
|
20
20
|
UNABLE_TO_DECRYPT_BEARER_TOKEN = 210,
|
|
21
21
|
BEARER_EXPIRES_IN_PROPERTY_NOT_NUMBER = 211,
|
|
22
22
|
UNCACHEABLE_REQUEST_HAS_CACHE_KEY_PARAM = 300,
|
|
23
|
-
UNCACHEABLE_REQUEST_HAS_SKIP_CACHE_PARAM = 301
|
|
23
|
+
UNCACHEABLE_REQUEST_HAS_SKIP_CACHE_PARAM = 301,
|
|
24
|
+
PAGED_QUERY_PAGE_BIGGER_THAN_TOTAL_PAGES = 400,
|
|
25
|
+
PAGED_QUERY_NEXT_PAGE_CALLED_WITHOUT_PREVIOUS_PAGE = 401,
|
|
26
|
+
PAGED_QUERY_PREVIOUS_PAGE_CALLED_BUT_ALREADY_AT_FIRST_PAGE = 402
|
|
24
27
|
}
|
|
25
28
|
export declare const queryFeatureUsedMultipleTimes: (type: QueryFeatureType) => RuntimeError<RuntimeErrorCode.QUERY_FEATURE_USED_MULTIPLE_TIMES>;
|
|
26
29
|
export declare const withArgsQueryFeatureMissingButRouteIsFunction: () => RuntimeError<RuntimeErrorCode.WITH_ARGS_QUERY_FEATURE_MISSING_BUT_ROUTE_IS_FUNCTION>;
|
|
@@ -41,3 +44,6 @@ export declare const unableToDecryptBearerToken: (token: string) => RuntimeError
|
|
|
41
44
|
export declare const bearerExpiresInPropertyNotNumber: (expiresIn: unknown) => RuntimeError<RuntimeErrorCode.BEARER_EXPIRES_IN_PROPERTY_NOT_NUMBER>;
|
|
42
45
|
export declare const uncacheableRequestHasCacheKeyParam: (key: string) => RuntimeError<RuntimeErrorCode.UNCACHEABLE_REQUEST_HAS_CACHE_KEY_PARAM>;
|
|
43
46
|
export declare const uncacheableRequestHasSkipCacheParam: () => RuntimeError<RuntimeErrorCode.UNCACHEABLE_REQUEST_HAS_SKIP_CACHE_PARAM>;
|
|
47
|
+
export declare const pagedQueryPageBiggerThanTotalPages: (page: number, totalPages: number) => RuntimeError<RuntimeErrorCode.PAGED_QUERY_PAGE_BIGGER_THAN_TOTAL_PAGES>;
|
|
48
|
+
export declare const pagedQueryNextPageCalledWithoutPreviousPage: () => RuntimeError<RuntimeErrorCode.PAGED_QUERY_NEXT_PAGE_CALLED_WITHOUT_PREVIOUS_PAGE>;
|
|
49
|
+
export declare const pagedQueryPreviousPageCalledButAlreadyAtFirstPage: () => RuntimeError<RuntimeErrorCode.PAGED_QUERY_PREVIOUS_PAGE_CALLED_BUT_ALREADY_AT_FIRST_PAGE>;
|
|
@@ -13,7 +13,9 @@ export type QueryStack<T extends AnyQuery, J = ReturnType<T['response']>[]> = {
|
|
|
13
13
|
/** Contains the responses of all queries in the stack. Will be `null` for queries that are loading or errored. */
|
|
14
14
|
response: Signal<J>;
|
|
15
15
|
/** Executes all queries in the stack. */
|
|
16
|
-
execute: (
|
|
16
|
+
execute: (options?: {
|
|
17
|
+
skipCache?: boolean;
|
|
18
|
+
}) => void;
|
|
17
19
|
/** Destroys all queries in the stack and empties it. This should only be used if `append` is true. */
|
|
18
20
|
clear: () => void;
|
|
19
21
|
};
|
|
@@ -43,4 +45,4 @@ export declare const transformArrayResponse: <T extends (unknown | null)[]>(resp
|
|
|
43
45
|
export declare const transformPaginatedResponse: <T extends ({
|
|
44
46
|
items: unknown[];
|
|
45
47
|
} | null)[]>(responses: T) => NonNullable<NonNullable<T[0]>["items"]>;
|
|
46
|
-
export declare const createQueryStack: <T extends AnyQuery, J = ReturnType<T["response"]>[]>(computation: () => T | T[], options?: CreateQueryStackOptions<T, J>) => QueryStack<T, J>;
|
|
48
|
+
export declare const createQueryStack: <T extends AnyQuery, J = ReturnType<T["response"]>[]>(computation: () => T | T[] | null, options?: CreateQueryStackOptions<T, J>) => QueryStack<T, J>;
|
|
@@ -4,8 +4,9 @@ export interface QueryFieldOptions<T = unknown> {
|
|
|
4
4
|
/**
|
|
5
5
|
* The default value of the field.
|
|
6
6
|
* Will be set to the initial value of the form control if not specified.
|
|
7
|
+
* If a function is provided, it will be called to get the default value.
|
|
7
8
|
*/
|
|
8
|
-
defaultValue?: T | null;
|
|
9
|
+
defaultValue?: T | (() => T) | null;
|
|
9
10
|
/**
|
|
10
11
|
* Debounce time in milliseconds.
|
|
11
12
|
*/
|