@ethlete/query 5.16.0 → 5.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/esm2022/ethlete-query.mjs +5 -0
- package/esm2022/index.mjs +20 -0
- package/esm2022/lib/auth/auth-provider.types.mjs +2 -0
- package/esm2022/lib/auth/auth-provider.utils.mjs +25 -0
- package/esm2022/lib/auth/basic-auth-provider.mjs +15 -0
- package/esm2022/lib/auth/bearer-auth-provider.mjs +168 -0
- package/esm2022/lib/auth/custom-header-auth-provider.mjs +12 -0
- package/esm2022/lib/auth/index.mjs +6 -0
- package/esm2022/lib/class-validator/class-validator.types.mjs +2 -0
- package/esm2022/lib/class-validator/class-validator.utils.mjs +4 -0
- package/esm2022/lib/class-validator/index.mjs +3 -0
- package/esm2022/lib/devtools/components/query-devtools/index.mjs +2 -0
- package/esm2022/lib/devtools/components/query-devtools/query-devtools.component.mjs +297 -0
- package/esm2022/lib/devtools/pipes/index.mjs +2 -0
- package/esm2022/lib/devtools/pipes/query-short-name.pipe.mjs +24 -0
- package/esm2022/lib/devtools/utils/index.mjs +2 -0
- package/esm2022/lib/devtools/utils/query-client.utils.mjs +13 -0
- package/esm2022/lib/directives/index.mjs +4 -0
- package/esm2022/lib/directives/infinity-query-trigger.directive.mjs +56 -0
- package/esm2022/lib/directives/infinity-query.directive.mjs +147 -0
- package/esm2022/lib/directives/query.directive.mjs +123 -0
- package/esm2022/lib/entity/entity-store.mjs +127 -0
- package/esm2022/lib/entity/entity.types.mjs +2 -0
- package/esm2022/lib/entity/entity.utils.mjs +29 -0
- package/esm2022/lib/entity/index.mjs +4 -0
- package/esm2022/lib/gql/gql.mjs +23 -0
- package/esm2022/lib/gql/index.mjs +2 -0
- package/esm2022/lib/infinite-query/index.mjs +4 -0
- package/esm2022/lib/infinite-query/infinity-query.mjs +171 -0
- package/esm2022/lib/infinite-query/infinity-query.types.mjs +2 -0
- package/esm2022/lib/infinite-query/infinity-query.utils.mjs +3 -0
- package/esm2022/lib/logger/index.mjs +2 -0
- package/esm2022/lib/logger/logger.mjs +16 -0
- package/esm2022/lib/query/index.mjs +4 -0
- package/esm2022/lib/query/query.mjs +430 -0
- package/esm2022/lib/query/query.types.mjs +2 -0
- package/esm2022/lib/query/query.utils.mjs +253 -0
- package/esm2022/lib/query-client/index.mjs +4 -0
- package/esm2022/lib/query-client/query-client.mjs +80 -0
- package/esm2022/lib/query-client/query-client.types.mjs +2 -0
- package/esm2022/lib/query-client/query-client.utils.mjs +20 -0
- package/esm2022/lib/query-creator/index.mjs +3 -0
- package/esm2022/lib/query-creator/query-creator.mjs +55 -0
- package/esm2022/lib/query-creator/query-creator.types.mjs +2 -0
- package/esm2022/lib/query-form/index.mjs +4 -0
- package/esm2022/lib/query-form/query-form.mjs +379 -0
- package/esm2022/lib/query-form/query-form.types.mjs +2 -0
- package/esm2022/lib/query-form/query-form.utils.mjs +97 -0
- package/esm2022/lib/query-store/index.mjs +2 -0
- package/esm2022/lib/query-store/query-store.mjs +144 -0
- package/esm2022/lib/request/index.mjs +4 -0
- package/esm2022/lib/request/request.mjs +196 -0
- package/esm2022/lib/request/request.types.mjs +2 -0
- package/esm2022/lib/request/request.util.mjs +252 -0
- package/esm2022/lib/symfony/index.mjs +3 -0
- package/esm2022/lib/symfony/symfony.types.mjs +2 -0
- package/esm2022/lib/symfony/symfony.utils.mjs +31 -0
- package/esm2022/lib/utils/data.utils.mjs +138 -0
- package/esm2022/lib/utils/deep-freeze.util.mjs +17 -0
- package/esm2022/lib/utils/def.util.mjs +8 -0
- package/esm2022/lib/utils/index.mjs +4 -0
- package/fesm2022/ethlete-query.mjs +3289 -0
- package/fesm2022/ethlete-query.mjs.map +1 -0
- package/{src/index.ts → index.d.ts} +0 -2
- package/lib/auth/auth-provider.types.d.ts +133 -0
- package/lib/auth/auth-provider.utils.d.ts +9 -0
- package/lib/auth/basic-auth-provider.d.ts +10 -0
- package/lib/auth/bearer-auth-provider.d.ts +23 -0
- package/lib/auth/custom-header-auth-provider.d.ts +9 -0
- package/{src/lib/class-validator/class-validator.types.ts → lib/class-validator/class-validator.types.d.ts} +3 -4
- package/lib/class-validator/class-validator.utils.d.ts +2 -0
- package/lib/devtools/components/query-devtools/query-devtools.component.d.ts +151 -0
- package/lib/devtools/pipes/query-short-name.pipe.d.ts +8 -0
- package/lib/devtools/utils/query-client.utils.d.ts +12 -0
- package/lib/directives/infinity-query-trigger.directive.d.ts +15 -0
- package/lib/directives/infinity-query.directive.d.ts +49 -0
- package/lib/directives/query.directive.d.ts +63 -0
- package/lib/entity/entity-store.d.ts +25 -0
- package/lib/entity/entity.types.d.ts +25 -0
- package/lib/entity/entity.utils.d.ts +12 -0
- package/lib/gql/gql.d.ts +6 -0
- package/lib/infinite-query/infinity-query.d.ts +29 -0
- package/lib/infinite-query/infinity-query.types.d.ts +104 -0
- package/lib/infinite-query/infinity-query.utils.d.ts +4 -0
- package/lib/logger/logger.d.ts +12 -0
- package/lib/query/query.d.ts +60 -0
- package/lib/query/query.types.d.ts +388 -0
- package/lib/query/query.utils.d.ts +82 -0
- package/lib/query-client/query-client.d.ts +29 -0
- package/lib/query-client/query-client.types.d.ts +82 -0
- package/lib/query-client/query-client.utils.d.ts +4 -0
- package/lib/query-creator/query-creator.d.ts +20 -0
- package/lib/query-creator/query-creator.types.d.ts +13 -0
- package/lib/query-form/query-form.d.ts +91 -0
- package/lib/query-form/query-form.types.d.ts +145 -0
- package/lib/query-form/query-form.utils.d.ts +13 -0
- package/lib/query-store/query-store.d.ts +31 -0
- package/lib/request/request.d.ts +3 -0
- package/lib/request/request.types.d.ts +126 -0
- package/lib/request/request.util.d.ts +92 -0
- package/lib/symfony/symfony.types.d.ts +19 -0
- package/lib/symfony/symfony.utils.d.ts +6 -0
- package/lib/utils/data.utils.d.ts +59 -0
- package/lib/utils/deep-freeze.util.d.ts +1 -0
- package/{src/lib/utils/def.util.ts → lib/utils/def.util.d.ts} +1 -1
- package/package.json +23 -6
- package/.eslintrc.json +0 -40
- package/jest.config.ts +0 -23
- package/ng-package.json +0 -8
- package/project.json +0 -37
- package/src/lib/auth/auth-provider.types.ts +0 -160
- package/src/lib/auth/auth-provider.utils.ts +0 -39
- package/src/lib/auth/basic-auth-provider.ts +0 -17
- package/src/lib/auth/bearer-auth-provider.ts +0 -243
- package/src/lib/auth/custom-header-auth-provider.ts +0 -13
- package/src/lib/class-validator/class-validator.utils.ts +0 -5
- package/src/lib/devtools/components/query-devtools/query-devtools.component.html +0 -402
- package/src/lib/devtools/components/query-devtools/query-devtools.component.scss +0 -360
- package/src/lib/devtools/components/query-devtools/query-devtools.component.ts +0 -427
- package/src/lib/devtools/pipes/query-short-name.pipe.ts +0 -24
- package/src/lib/devtools/utils/query-client.utils.ts +0 -25
- package/src/lib/directives/infinity-query-trigger.directive.ts +0 -58
- package/src/lib/directives/infinity-query.directive.ts +0 -208
- package/src/lib/directives/query.directive.ts +0 -201
- package/src/lib/entity/entity-store.ts +0 -180
- package/src/lib/entity/entity.types.ts +0 -34
- package/src/lib/entity/entity.utils.ts +0 -51
- package/src/lib/gql/gql.ts +0 -22
- package/src/lib/infinite-query/infinity-query.ts +0 -245
- package/src/lib/infinite-query/infinity-query.types.ts +0 -149
- package/src/lib/infinite-query/infinity-query.utils.ts +0 -14
- package/src/lib/logger/logger.ts +0 -30
- package/src/lib/query/query.ts +0 -631
- package/src/lib/query/query.types.ts +0 -532
- package/src/lib/query/query.utils.spec.ts +0 -92
- package/src/lib/query/query.utils.ts +0 -450
- package/src/lib/query-client/query-client.spec.ts +0 -77
- package/src/lib/query-client/query-client.ts +0 -195
- package/src/lib/query-client/query-client.types.ts +0 -101
- package/src/lib/query-client/query-client.utils.spec.ts +0 -61
- package/src/lib/query-client/query-client.utils.ts +0 -28
- package/src/lib/query-creator/query-creator.ts +0 -103
- package/src/lib/query-creator/query-creator.types.ts +0 -74
- package/src/lib/query-form/query-form.ts +0 -526
- package/src/lib/query-form/query-form.types.ts +0 -169
- package/src/lib/query-form/query-form.utils.ts +0 -116
- package/src/lib/query-store/query-store.ts +0 -192
- package/src/lib/request/request.ts +0 -253
- package/src/lib/request/request.types.ts +0 -164
- package/src/lib/request/request.util.spec.ts +0 -177
- package/src/lib/request/request.util.ts +0 -399
- package/src/lib/stories/angular-example-page.mdx +0 -85
- package/src/lib/stories/authentication-page.mdx +0 -35
- package/src/lib/stories/changelog-page.mdx +0 -9
- package/src/lib/stories/client-page.mdx +0 -100
- package/src/lib/stories/queries-page.mdx +0 -117
- package/src/lib/symfony/symfony.types.ts +0 -21
- package/src/lib/symfony/symfony.utils.ts +0 -43
- package/src/lib/utils/data.utils.ts +0 -280
- package/src/lib/utils/deep-freeze.util.ts +0 -21
- package/src/test-setup.ts +0 -1
- package/tsconfig.json +0 -29
- package/tsconfig.lib.json +0 -12
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -11
- /package/{src/lib/auth/index.ts → lib/auth/index.d.ts} +0 -0
- /package/{src/lib/class-validator/index.ts → lib/class-validator/index.d.ts} +0 -0
- /package/{src/lib/devtools/components/query-devtools/index.ts → lib/devtools/components/query-devtools/index.d.ts} +0 -0
- /package/{src/lib/devtools/pipes/index.ts → lib/devtools/pipes/index.d.ts} +0 -0
- /package/{src/lib/devtools/utils/index.ts → lib/devtools/utils/index.d.ts} +0 -0
- /package/{src/lib/directives/index.ts → lib/directives/index.d.ts} +0 -0
- /package/{src/lib/entity/index.ts → lib/entity/index.d.ts} +0 -0
- /package/{src/lib/gql/index.ts → lib/gql/index.d.ts} +0 -0
- /package/{src/lib/infinite-query/index.ts → lib/infinite-query/index.d.ts} +0 -0
- /package/{src/lib/logger/index.ts → lib/logger/index.d.ts} +0 -0
- /package/{src/lib/query/index.ts → lib/query/index.d.ts} +0 -0
- /package/{src/lib/query-client/index.ts → lib/query-client/index.d.ts} +0 -0
- /package/{src/lib/query-creator/index.ts → lib/query-creator/index.d.ts} +0 -0
- /package/{src/lib/query-form/index.ts → lib/query-form/index.d.ts} +0 -0
- /package/{src/lib/query-store/index.ts → lib/query-store/index.d.ts} +0 -0
- /package/{src/lib/request/index.ts → lib/request/index.d.ts} +0 -0
- /package/{src/lib/symfony/index.ts → lib/symfony/index.d.ts} +0 -0
- /package/{src/lib/utils/index.ts → lib/utils/index.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpStatusCode } from '../request';
|
|
2
|
+
export interface SymfonyErrorTrace {
|
|
3
|
+
args: string[];
|
|
4
|
+
class: string;
|
|
5
|
+
file: string;
|
|
6
|
+
function: string;
|
|
7
|
+
line: number;
|
|
8
|
+
namespace: string;
|
|
9
|
+
short_class: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SymfonyError {
|
|
13
|
+
class: string;
|
|
14
|
+
detail: string;
|
|
15
|
+
status: HttpStatusCode;
|
|
16
|
+
title: string;
|
|
17
|
+
trace: SymfonyErrorTrace[];
|
|
18
|
+
type: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormViolationListView, FormViolationView } from '@ethlete/types';
|
|
2
|
+
import { SymfonyError } from './symfony.types';
|
|
3
|
+
export declare const isSymfonyError: (error: unknown) => error is SymfonyError;
|
|
4
|
+
export declare const isSymfonyPagerfantaOutOfRangeError: (error: unknown) => error is SymfonyError;
|
|
5
|
+
export declare const isSymfonyFormViolationListError: (error: unknown) => error is FormViolationListView;
|
|
6
|
+
export declare const isSymfonyListError: (error: unknown) => error is FormViolationView[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CreateComputedOptions, Signal } from '@angular/core';
|
|
2
|
+
import { ToObservableOptions, ToSignalOptions } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { Observable, Subscribable } from 'rxjs';
|
|
4
|
+
import { AnyQuery, AnyQueryCollection, QueryOf, QueryState } from '../query';
|
|
5
|
+
import { QueryDataOf } from '../query-creator';
|
|
6
|
+
export interface QueryContainerConfig {
|
|
7
|
+
/**
|
|
8
|
+
* If `true`, the previous query will be aborted when a new query is pushed into the container.
|
|
9
|
+
* @default true // Only if the request can be cached (GET, OPTIONS, HEAD and GQL_QUERY). Otherwise false.
|
|
10
|
+
*/
|
|
11
|
+
abortPrevious?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* If `true`, the query will be aborted when the container is destroyed.
|
|
14
|
+
* @default true // Only if the request can be cached (GET, OPTIONS, HEAD and GQL_QUERY). Otherwise false.
|
|
15
|
+
*/
|
|
16
|
+
abortOnDestroy?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If `true`, the previous polling will be stopped when a new query is pushed into the container.
|
|
19
|
+
* @default true // Only if the query has no other dependents and the request can be cached (GET, OPTIONS, HEAD and GQL_QUERY). Otherwise false.
|
|
20
|
+
*/
|
|
21
|
+
stopPreviousPolling?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface QueryFilterConfig {
|
|
24
|
+
/**
|
|
25
|
+
* If `true`, the response will be cached until the next response is received or the query fails.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
cacheResponse?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const addQueryContainerHandling: (obs: Observable<AnyQuery | AnyQuery[] | null>, valueFn: () => AnyQuery | AnyQuery[] | null | undefined, config?: QueryContainerConfig) => void;
|
|
31
|
+
export declare function toQuerySignal<T extends AnyQuery | null>(source: Observable<T> | Subscribable<T>): Signal<T | undefined>;
|
|
32
|
+
export declare function toQuerySignal<T extends AnyQuery | null>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T | undefined>> & {
|
|
33
|
+
initialValue?: undefined;
|
|
34
|
+
requireSync?: false;
|
|
35
|
+
} & QueryContainerConfig): Signal<T | undefined>;
|
|
36
|
+
export declare function toQuerySignal<T extends AnyQuery | null>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T | null>> & {
|
|
37
|
+
initialValue?: null;
|
|
38
|
+
requireSync?: false;
|
|
39
|
+
} & QueryContainerConfig): Signal<T | null>;
|
|
40
|
+
export declare function toQuerySignal<T extends AnyQuery | null>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T>> & {
|
|
41
|
+
initialValue?: undefined;
|
|
42
|
+
requireSync: true;
|
|
43
|
+
} & QueryContainerConfig): Signal<T>;
|
|
44
|
+
export declare function toQuerySignal<T extends AnyQuery | null, const U extends T>(source: Observable<T> | Subscribable<T>, options: NoInfer<ToSignalOptions<T | U>> & {
|
|
45
|
+
initialValue: U;
|
|
46
|
+
requireSync?: false;
|
|
47
|
+
} & QueryContainerConfig): Signal<T | U>;
|
|
48
|
+
export declare function queryComputed<T extends AnyQuery | null>(computation: () => T, options?: CreateComputedOptions<T> & QueryContainerConfig & ToObservableOptions): Signal<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a signal that will only be reactive until the first query is created.
|
|
51
|
+
* All subsequent changes inside the computation will be ignored.
|
|
52
|
+
*/
|
|
53
|
+
export declare function queryComputedTillTruthy<T extends AnyQuery | null>(computation: () => T, options?: CreateComputedOptions<T> & QueryContainerConfig & ToObservableOptions): Signal<T | null>;
|
|
54
|
+
export declare function queryArrayComputed<T extends AnyQuery[] | null>(computation: () => T, options?: CreateComputedOptions<T> & QueryContainerConfig & ToObservableOptions): Signal<T>;
|
|
55
|
+
export declare function toQuerySubject<T extends AnyQuery | null>(source: Signal<T>, options?: ToObservableOptions & QueryContainerConfig): Observable<T>;
|
|
56
|
+
export declare function queryStateSignal<T extends Signal<AnyQuery | AnyQueryCollection | null>>(source: T, options?: QueryFilterConfig): Signal<QueryState<QueryDataOf<QueryOf<ReturnType<T>>>> | null>;
|
|
57
|
+
export declare function queryStateResponseSignal<T extends Signal<AnyQuery | AnyQueryCollection | null>>(source: T, options?: QueryFilterConfig): Signal<QueryDataOf<QueryOf<ReturnType<T>>> | null>;
|
|
58
|
+
export declare function queryStateErrorSignal<T extends Signal<AnyQuery | AnyQueryCollection | null>>(source: T): Signal<import("@ethlete/query").RequestError<unknown> | null>;
|
|
59
|
+
export declare function queryStateLoadingSignal<T extends Signal<AnyQuery | AnyQueryCollection | null>>(source: T): Signal<import("../query").Loading | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deepFreeze: <T extends Record<string, unknown>>(object: T) => T;
|
package/package.json
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethlete/query",
|
|
3
|
-
"version": "5.16.
|
|
3
|
+
"version": "5.16.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@angular/common": "18.0
|
|
6
|
-
"@angular/core": "18.0
|
|
7
|
-
"@angular/forms": "18.0
|
|
8
|
-
"@angular/router": "18.0
|
|
5
|
+
"@angular/common": "^18.1.0",
|
|
6
|
+
"@angular/core": "^18.1.0",
|
|
7
|
+
"@angular/forms": "^18.1.0",
|
|
8
|
+
"@angular/router": "^18.1.0",
|
|
9
9
|
"@ethlete/core": "^4.0.3",
|
|
10
10
|
"@ethlete/types": "^1.6.2",
|
|
11
11
|
"rxjs": "^7.8.1"
|
|
12
|
+
},
|
|
13
|
+
"module": "fesm2022/ethlete-query.mjs",
|
|
14
|
+
"typings": "index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./package.json": {
|
|
17
|
+
"default": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./index.d.ts",
|
|
21
|
+
"esm2022": "./esm2022/ethlete-query.mjs",
|
|
22
|
+
"esm": "./esm2022/ethlete-query.mjs",
|
|
23
|
+
"default": "./fesm2022/ethlete-query.mjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"tslib": "^2.3.0"
|
|
12
29
|
}
|
|
13
|
-
}
|
|
30
|
+
}
|
package/.eslintrc.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["../../.eslintrc.json"],
|
|
3
|
-
"ignorePatterns": ["!**/*"],
|
|
4
|
-
"overrides": [
|
|
5
|
-
{
|
|
6
|
-
"files": ["*.ts"],
|
|
7
|
-
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
|
|
8
|
-
"rules": {
|
|
9
|
-
"@angular-eslint/directive-selector": [
|
|
10
|
-
"error",
|
|
11
|
-
{
|
|
12
|
-
"type": "attribute",
|
|
13
|
-
"prefix": "et"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"@angular-eslint/component-selector": [
|
|
17
|
-
"error",
|
|
18
|
-
{
|
|
19
|
-
"type": ["element", "attribute"],
|
|
20
|
-
"prefix": "et",
|
|
21
|
-
"style": "kebab-case"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"@angular-eslint/no-host-metadata-property": "off"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"files": ["*.html"],
|
|
29
|
-
"extends": ["plugin:@nx/angular-template"],
|
|
30
|
-
"rules": {}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"files": ["*.json"],
|
|
34
|
-
"parser": "jsonc-eslint-parser",
|
|
35
|
-
"rules": {
|
|
36
|
-
"@nx/dependency-checks": "off"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
package/jest.config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
export default {
|
|
3
|
-
displayName: 'query',
|
|
4
|
-
preset: '../../jest.preset.js',
|
|
5
|
-
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
|
6
|
-
globals: {},
|
|
7
|
-
coverageDirectory: '../../coverage/libs/query',
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.(ts|mjs|js|html)$': [
|
|
10
|
-
'jest-preset-angular',
|
|
11
|
-
{
|
|
12
|
-
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
13
|
-
stringifyContentPathRegex: '\\.(html|svg)$',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
|
|
18
|
-
snapshotSerializers: [
|
|
19
|
-
'jest-preset-angular/build/serializers/no-ng-attributes',
|
|
20
|
-
'jest-preset-angular/build/serializers/ng-snapshot',
|
|
21
|
-
'jest-preset-angular/build/serializers/html-comment',
|
|
22
|
-
],
|
|
23
|
-
};
|
package/ng-package.json
DELETED
package/project.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "query",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "libs/query/src",
|
|
5
|
-
"prefix": "et",
|
|
6
|
-
"tags": [],
|
|
7
|
-
"projectType": "library",
|
|
8
|
-
"targets": {
|
|
9
|
-
"build": {
|
|
10
|
-
"executor": "@nx/angular:package",
|
|
11
|
-
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
|
|
12
|
-
"options": {
|
|
13
|
-
"project": "libs/query/ng-package.json"
|
|
14
|
-
},
|
|
15
|
-
"configurations": {
|
|
16
|
-
"production": {
|
|
17
|
-
"tsConfig": "libs/query/tsconfig.lib.prod.json"
|
|
18
|
-
},
|
|
19
|
-
"development": {
|
|
20
|
-
"tsConfig": "libs/query/tsconfig.lib.json"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"defaultConfiguration": "production"
|
|
24
|
-
},
|
|
25
|
-
"test": {
|
|
26
|
-
"executor": "@nx/jest:jest",
|
|
27
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
28
|
-
"options": {
|
|
29
|
-
"jestConfig": "libs/query/jest.config.ts"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"lint": {
|
|
33
|
-
"executor": "@nx/eslint:lint",
|
|
34
|
-
"outputs": ["{options.outputFile}"]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { AnyQueryCreator, QueryArgsOf, QueryResponseOf } from '../query-creator';
|
|
2
|
-
|
|
3
|
-
export interface AuthProvider {
|
|
4
|
-
/**
|
|
5
|
-
* The up to date auth header.
|
|
6
|
-
* This will automatically get injected into every query that has the `secure` property set to `true`.
|
|
7
|
-
*/
|
|
8
|
-
header: Record<string, string>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Cleanup function that gets called once the auth provider gets destroyed.
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
cleanUp(): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AuthProviderBasicConfig {
|
|
18
|
-
/**
|
|
19
|
-
* Basic auth username
|
|
20
|
-
*/
|
|
21
|
-
username: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Basic auth password
|
|
25
|
-
*/
|
|
26
|
-
password: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface AuthProviderCustomHeaderConfig {
|
|
30
|
-
/**
|
|
31
|
-
* The custom header name
|
|
32
|
-
* @example `X-Api-Key`
|
|
33
|
-
*/
|
|
34
|
-
name: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The custom header value
|
|
38
|
-
* @example `myApiKey`
|
|
39
|
-
*/
|
|
40
|
-
value: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface AuthProviderBearerConfig<T extends AnyQueryCreator> {
|
|
44
|
-
/**
|
|
45
|
-
* The initial jwt
|
|
46
|
-
*/
|
|
47
|
-
token?: string;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Refresh token configuration
|
|
51
|
-
*/
|
|
52
|
-
refreshConfig?: BearerRefreshConfig<T>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface BearerRefreshConfig<T extends AnyQueryCreator> {
|
|
56
|
-
/**
|
|
57
|
-
* The query used to trade the refresh token for a new token response.
|
|
58
|
-
*/
|
|
59
|
-
queryCreator: T;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Determines if the token should be refreshed if **any** query returns a 401 response.
|
|
63
|
-
* @default true
|
|
64
|
-
*/
|
|
65
|
-
refreshOnUnauthorizedResponse?: boolean;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The initial refresh token
|
|
69
|
-
*/
|
|
70
|
-
token?: string;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The cookie name where the refresh token is stored
|
|
74
|
-
*/
|
|
75
|
-
cookieName?: string;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The domain of the cookie. If not set, the current origin will be used.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* "https://example.com" -> "example.com"
|
|
82
|
-
* "https://sub.example.com" -> "example.com"
|
|
83
|
-
*/
|
|
84
|
-
cookieDomain?: string;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The days until the cookie expires
|
|
88
|
-
* @default 30
|
|
89
|
-
*/
|
|
90
|
-
cookieExpiresInDays?: number;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* The path of the cookie
|
|
94
|
-
* @default '/'
|
|
95
|
-
*/
|
|
96
|
-
cookiePath?: string;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Enable or disable the cookie
|
|
100
|
-
* @default true
|
|
101
|
-
*/
|
|
102
|
-
cookieEnabled?: boolean;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The same site property of the cookie
|
|
106
|
-
* @default 'lax'
|
|
107
|
-
*/
|
|
108
|
-
cookieSameSite?: 'strict' | 'none' | 'lax';
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* The time in milliseconds before the token expires when the refresh should be triggered.
|
|
112
|
-
* @default 300000 (5 minutes)
|
|
113
|
-
*/
|
|
114
|
-
refreshBuffer?: number;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The expires in property name inside the jwt body
|
|
118
|
-
* @default 'exp'
|
|
119
|
-
*/
|
|
120
|
-
expiresInPropertyName?: string;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Determines when the token should be refreshed.
|
|
124
|
-
* @default AuthBearerRefreshStrategy.BeforeExpiration
|
|
125
|
-
*/
|
|
126
|
-
strategy?: AuthBearerRefreshStrategy;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Adapter function used to build the request body for the refresh request.
|
|
130
|
-
* @default { body: { refreshToken: "refreshToken" } }
|
|
131
|
-
*/
|
|
132
|
-
requestArgsAdapter?: (tokens: { token: string | null; refreshToken: string }) => QueryArgsOf<T>;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Adapter function used to extract the token and refreshToken from the response.
|
|
136
|
-
* @default { token: "token", refreshToken: "refreshToken" }
|
|
137
|
-
*/
|
|
138
|
-
responseAdapter?: (response: NonNullable<QueryResponseOf<T>>) => TokenResponse;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export const enum AuthBearerRefreshStrategy {
|
|
142
|
-
/**
|
|
143
|
-
* Automatically refresh the token 5 minutes before expiration.
|
|
144
|
-
* The time can be configured with the `refreshBuffer` property.
|
|
145
|
-
*/
|
|
146
|
-
BeforeExpiration = 'beforeExpiration',
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export interface TokenResponse {
|
|
150
|
-
/**
|
|
151
|
-
* The access token used inside the authorization http header.
|
|
152
|
-
*/
|
|
153
|
-
token: string | null;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* The refresh token used for requesting a new token response once the current tokes is expired.
|
|
157
|
-
* This property is required if the bearer refresh config is set.
|
|
158
|
-
*/
|
|
159
|
-
refreshToken: string | null;
|
|
160
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AnyQueryCreator } from '../query-creator';
|
|
2
|
-
import { AuthProvider } from './auth-provider.types';
|
|
3
|
-
import { BasicAuthProvider } from './basic-auth-provider';
|
|
4
|
-
import { BearerAuthProvider } from './bearer-auth-provider';
|
|
5
|
-
import { CustomHeaderAuthProvider } from './custom-header-auth-provider';
|
|
6
|
-
|
|
7
|
-
export const isBasicAuthProvider = (authProvider: AuthProvider): authProvider is BasicAuthProvider =>
|
|
8
|
-
authProvider instanceof BasicAuthProvider;
|
|
9
|
-
|
|
10
|
-
export const isBearerAuthProvider = <T extends AnyQueryCreator>(
|
|
11
|
-
authProvider: AuthProvider,
|
|
12
|
-
): authProvider is BearerAuthProvider<T> => authProvider instanceof BearerAuthProvider;
|
|
13
|
-
|
|
14
|
-
export const isCustomHeaderAuthProvider = (authProvider: AuthProvider): authProvider is CustomHeaderAuthProvider =>
|
|
15
|
-
authProvider instanceof CustomHeaderAuthProvider;
|
|
16
|
-
|
|
17
|
-
export const decryptBearer = <Result = Record<string, unknown>>(token: string) => {
|
|
18
|
-
try {
|
|
19
|
-
const base64Url = token.split('.')[1];
|
|
20
|
-
|
|
21
|
-
if (!base64Url) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
26
|
-
const jsonPayload = decodeURIComponent(
|
|
27
|
-
atob(base64)
|
|
28
|
-
.split('')
|
|
29
|
-
.map((c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
|
|
30
|
-
.join(''),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return JSON.parse(jsonPayload) as Result;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error(`Invalid bearer token: ${token}`, error);
|
|
36
|
-
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AuthProvider, AuthProviderBasicConfig } from './auth-provider.types';
|
|
2
|
-
|
|
3
|
-
export class BasicAuthProvider implements AuthProvider {
|
|
4
|
-
get header() {
|
|
5
|
-
return { Authorization: `Basic ${this._basicAuthString}` };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
private get _basicAuthString() {
|
|
9
|
-
return btoa(`${this._config.username}:${this._config.password}`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
constructor(public _config: AuthProviderBasicConfig) {}
|
|
13
|
-
|
|
14
|
-
cleanUp(): void {
|
|
15
|
-
// noop
|
|
16
|
-
}
|
|
17
|
-
}
|