@ethlete/query 5.16.0 → 5.16.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 +6 -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 +428 -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 +3287 -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 +91 -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 +19 -2
- 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
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { deleteCookie, getCookie, setCookie } from '@ethlete/core';
|
|
2
|
-
import { BehaviorSubject, Subject, takeUntil, tap, timer } from 'rxjs';
|
|
3
|
-
import {
|
|
4
|
-
isQueryStateFailure,
|
|
5
|
-
isQueryStateLoading,
|
|
6
|
-
isQueryStateSuccess,
|
|
7
|
-
switchQueryState,
|
|
8
|
-
takeUntilResponse,
|
|
9
|
-
} from '../query';
|
|
10
|
-
import { AnyQueryCreator, ConstructQuery, QueryResponseOf } from '../query-creator';
|
|
11
|
-
import {
|
|
12
|
-
AuthBearerRefreshStrategy,
|
|
13
|
-
AuthProvider,
|
|
14
|
-
AuthProviderBearerConfig,
|
|
15
|
-
TokenResponse,
|
|
16
|
-
} from './auth-provider.types';
|
|
17
|
-
import { decryptBearer } from './auth-provider.utils';
|
|
18
|
-
|
|
19
|
-
export class BearerAuthProvider<T extends AnyQueryCreator> implements AuthProvider {
|
|
20
|
-
private readonly _destroy$ = new Subject<boolean>();
|
|
21
|
-
private readonly _currentRefreshQuery$ = new BehaviorSubject<ConstructQuery<T> | null>(null);
|
|
22
|
-
|
|
23
|
-
private readonly _tokens$ = new BehaviorSubject<TokenResponse>({
|
|
24
|
-
token: null,
|
|
25
|
-
refreshToken: null,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
get header() {
|
|
29
|
-
return { Authorization: `Bearer ${this._tokens$.getValue().token}` };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get tokens$() {
|
|
33
|
-
return this._tokens$.asObservable();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get tokens() {
|
|
37
|
-
return this._tokens$.getValue();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get currentRefreshQuery$() {
|
|
41
|
-
return this._currentRefreshQuery$.asObservable();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get currentRefreshQuery() {
|
|
45
|
-
return this._currentRefreshQuery$.getValue();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get shouldRefreshOnUnauthorizedResponse() {
|
|
49
|
-
return (
|
|
50
|
-
!!this._config.refreshConfig &&
|
|
51
|
-
(this._config.refreshConfig.refreshOnUnauthorizedResponse === undefined ||
|
|
52
|
-
this._config.refreshConfig.refreshOnUnauthorizedResponse)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
constructor(public _config: AuthProviderBearerConfig<T>) {
|
|
57
|
-
const cookieEnabled = _config.refreshConfig?.cookieEnabled ?? true;
|
|
58
|
-
const cookieToken =
|
|
59
|
-
_config.refreshConfig?.cookieName && cookieEnabled ? getCookie(_config.refreshConfig.cookieName) ?? null : null;
|
|
60
|
-
|
|
61
|
-
this._tokens$.next({
|
|
62
|
-
token: _config.token || null,
|
|
63
|
-
refreshToken: _config.refreshConfig?.token || cookieToken || null,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
if (!this.tokens.token && !this.tokens.refreshToken) {
|
|
67
|
-
if (!_config.refreshConfig?.cookieName) {
|
|
68
|
-
console.error(
|
|
69
|
-
'A BearerAuthProvider was created without token or refresh token. You should provide at least a cookieName where the refresh token might be stored.',
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (this.tokens.token) {
|
|
77
|
-
this._prepareForRefresh();
|
|
78
|
-
|
|
79
|
-
if (this.tokens.refreshToken && this._config.refreshConfig?.cookieName && cookieEnabled) {
|
|
80
|
-
this._setCookie();
|
|
81
|
-
}
|
|
82
|
-
} else if (this.tokens.refreshToken) {
|
|
83
|
-
this._refreshQuery();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
cleanUp(): void {
|
|
88
|
-
this._destroy$.next(true);
|
|
89
|
-
this._destroy$.unsubscribe();
|
|
90
|
-
this._currentRefreshQuery$.next(null);
|
|
91
|
-
|
|
92
|
-
if (this._config.refreshConfig?.cookieName) {
|
|
93
|
-
this._deleteCookie();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
enableCookie() {
|
|
98
|
-
if (!this._config.refreshConfig?.cookieName) {
|
|
99
|
-
throw new Error('No cookie name was provided');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (!this.tokens.refreshToken) {
|
|
103
|
-
throw new Error('No refresh token was provided');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this._config.refreshConfig.cookieEnabled = true;
|
|
107
|
-
|
|
108
|
-
this._setCookie();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
disableCookie() {
|
|
112
|
-
if (!this._config.refreshConfig?.cookieName) {
|
|
113
|
-
throw new Error('No cookie name was provided');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
this._config.refreshConfig.cookieEnabled = false;
|
|
117
|
-
|
|
118
|
-
this._deleteCookie();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
private _setCookie() {
|
|
122
|
-
if (!this._config.refreshConfig?.cookieName || !this.tokens.refreshToken) return;
|
|
123
|
-
|
|
124
|
-
setCookie(
|
|
125
|
-
this._config.refreshConfig.cookieName,
|
|
126
|
-
this.tokens.refreshToken,
|
|
127
|
-
this._config.refreshConfig.cookieExpiresInDays,
|
|
128
|
-
this._config.refreshConfig.cookieDomain,
|
|
129
|
-
this._config.refreshConfig.cookiePath,
|
|
130
|
-
this._config.refreshConfig.cookieSameSite,
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private _deleteCookie() {
|
|
135
|
-
if (!this._config.refreshConfig?.cookieName) return;
|
|
136
|
-
|
|
137
|
-
deleteCookie(
|
|
138
|
-
this._config.refreshConfig.cookieName,
|
|
139
|
-
this._config.refreshConfig.cookiePath,
|
|
140
|
-
this._config.refreshConfig.cookieDomain,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
private _prepareForRefresh() {
|
|
145
|
-
if (!this.tokens.token || !this._config.refreshConfig) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const bearer = decryptBearer(this.tokens.token);
|
|
150
|
-
|
|
151
|
-
if (!bearer) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const expiresInPropertyName = this._config.refreshConfig.expiresInPropertyName || 'exp';
|
|
156
|
-
const expiresIn = bearer[expiresInPropertyName] as number | undefined;
|
|
157
|
-
const fiveMinutes = 5 * 60 * 1000;
|
|
158
|
-
const refreshBuffer = this._config.refreshConfig.refreshBuffer ?? fiveMinutes;
|
|
159
|
-
|
|
160
|
-
if (expiresIn === undefined) {
|
|
161
|
-
throw new Error(`Bearer token does not contain an '${expiresInPropertyName}' property`);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const remainingTime = new Date(expiresIn * 1000).getTime() - refreshBuffer - new Date().getTime();
|
|
165
|
-
|
|
166
|
-
const strategy = this._config.refreshConfig.strategy ?? AuthBearerRefreshStrategy.BeforeExpiration;
|
|
167
|
-
|
|
168
|
-
switch (strategy) {
|
|
169
|
-
case AuthBearerRefreshStrategy.BeforeExpiration:
|
|
170
|
-
timer(remainingTime)
|
|
171
|
-
.pipe(takeUntil(this._destroy$))
|
|
172
|
-
.subscribe(() => this._refreshQuery());
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @internal
|
|
179
|
-
*/
|
|
180
|
-
_refreshQuery() {
|
|
181
|
-
const currentQuery = this._currentRefreshQuery$.getValue();
|
|
182
|
-
|
|
183
|
-
if (isQueryStateLoading(currentQuery?.rawState)) {
|
|
184
|
-
return currentQuery;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const currentRefreshToken = this.tokens.refreshToken;
|
|
188
|
-
|
|
189
|
-
if (!currentRefreshToken || !this._config.refreshConfig) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const args = this._config.refreshConfig.requestArgsAdapter?.({
|
|
194
|
-
token: this.tokens.token,
|
|
195
|
-
refreshToken: currentRefreshToken,
|
|
196
|
-
}) ?? {
|
|
197
|
-
body: { refreshToken: currentRefreshToken },
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const query = this._config.refreshConfig.queryCreator.prepare(args).execute({ skipCache: true });
|
|
201
|
-
|
|
202
|
-
this._currentRefreshQuery$.next(query as ConstructQuery<T>);
|
|
203
|
-
|
|
204
|
-
this._currentRefreshQuery$
|
|
205
|
-
.pipe(
|
|
206
|
-
switchQueryState(),
|
|
207
|
-
tap((state) => {
|
|
208
|
-
if (isQueryStateSuccess(state)) {
|
|
209
|
-
if (this._config.refreshConfig?.responseAdapter) {
|
|
210
|
-
const tokens = this._config.refreshConfig.responseAdapter(state.response as QueryResponseOf<T>);
|
|
211
|
-
|
|
212
|
-
this._tokens$.next(tokens);
|
|
213
|
-
} else {
|
|
214
|
-
this._tokens$.next({
|
|
215
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
-
token: (state.response as any)['token'],
|
|
217
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
|
-
refreshToken: (state.response as any)['refreshToken'],
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
const cookieEnabled = this._config.refreshConfig?.cookieEnabled ?? true;
|
|
222
|
-
|
|
223
|
-
if (this._config.refreshConfig?.cookieName && this.tokens.refreshToken && cookieEnabled) {
|
|
224
|
-
this._setCookie();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
this._prepareForRefresh();
|
|
228
|
-
} else if (isQueryStateFailure(state)) {
|
|
229
|
-
this._tokens$.next({ token: null, refreshToken: null });
|
|
230
|
-
|
|
231
|
-
if (this._config.refreshConfig?.cookieName) {
|
|
232
|
-
this._deleteCookie();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}),
|
|
236
|
-
takeUntilResponse(),
|
|
237
|
-
takeUntil(this._destroy$),
|
|
238
|
-
)
|
|
239
|
-
.subscribe();
|
|
240
|
-
|
|
241
|
-
return query;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AuthProvider, AuthProviderCustomHeaderConfig } from './auth-provider.types';
|
|
2
|
-
|
|
3
|
-
export class CustomHeaderAuthProvider implements AuthProvider {
|
|
4
|
-
get header() {
|
|
5
|
-
return { [this._config.name]: this._config.value };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
constructor(public _config: AuthProviderCustomHeaderConfig) {}
|
|
9
|
-
|
|
10
|
-
cleanUp(): void {
|
|
11
|
-
// noop
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ClassValidatorError } from './class-validator.types';
|
|
2
|
-
|
|
3
|
-
export const isClassValidatorError = (error: unknown): error is ClassValidatorError => {
|
|
4
|
-
return typeof error === 'object' && error !== null && 'statusCode' in error && 'message' in error && 'error' in error;
|
|
5
|
-
};
|
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
@if (!isOpen()) {
|
|
2
|
-
<button (click)="toggleOpen()" class="et-query-devtools-open-btn et-qd-chip">Query Devtools</button>
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
@if (isOpen()) {
|
|
6
|
-
<div
|
|
7
|
-
[class.et-query-devtools-container--transparent]="isTranslucent()"
|
|
8
|
-
class="et-query-devtools-container et-query-devtools-container--snap-{{ snapLayout() }}"
|
|
9
|
-
>
|
|
10
|
-
<header class="et-qd-header">
|
|
11
|
-
<h3 class="et-qd-header__title">Query Devtools</h3>
|
|
12
|
-
|
|
13
|
-
<div class="et-qd-header__select">
|
|
14
|
-
<label for="et-query-client-instance">Client instance</label>
|
|
15
|
-
<select [formControl]="selectedClientIdCtrl" id="et-query-client-instance">
|
|
16
|
-
@for (clientConfig of queryClientConfigs; track trackByClient(i, clientConfig); let i = $index) {
|
|
17
|
-
<option [value]="i">
|
|
18
|
-
{{ clientConfig.displayName ?? clientConfig.client.config.baseRoute }}
|
|
19
|
-
</option>
|
|
20
|
-
}
|
|
21
|
-
</select>
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<button (click)="toggleOpen()" class="et-qd-btn et-qd-btn-secondary">Close</button>
|
|
25
|
-
</header>
|
|
26
|
-
|
|
27
|
-
<div class="et-qd-sub-header">
|
|
28
|
-
<button
|
|
29
|
-
[ngClass]="{ 'et-qd-chip-secondary': !isTranslucent() }"
|
|
30
|
-
(click)="toggleTranslucent()"
|
|
31
|
-
class="et-qd-chip et-qd-translucent-clickable"
|
|
32
|
-
>
|
|
33
|
-
Translucent
|
|
34
|
-
</button>
|
|
35
|
-
<div class="et-qd-sub-header__divider"></div>
|
|
36
|
-
<button
|
|
37
|
-
[ngClass]="{ 'et-qd-chip-secondary': snapLayout() !== 'full' }"
|
|
38
|
-
(click)="selectSnapLayout('full')"
|
|
39
|
-
class="et-qd-chip"
|
|
40
|
-
>
|
|
41
|
-
Fullscreen
|
|
42
|
-
</button>
|
|
43
|
-
<button
|
|
44
|
-
[ngClass]="{ 'et-qd-chip-secondary': snapLayout() !== 'top' }"
|
|
45
|
-
(click)="selectSnapLayout('top')"
|
|
46
|
-
class="et-qd-chip"
|
|
47
|
-
>
|
|
48
|
-
Top
|
|
49
|
-
</button>
|
|
50
|
-
<button
|
|
51
|
-
[ngClass]="{ 'et-qd-chip-secondary': snapLayout() !== 'bottom' }"
|
|
52
|
-
(click)="selectSnapLayout('bottom')"
|
|
53
|
-
class="et-qd-chip"
|
|
54
|
-
>
|
|
55
|
-
Bottom
|
|
56
|
-
</button>
|
|
57
|
-
<button
|
|
58
|
-
[ngClass]="{ 'et-qd-chip-secondary': snapLayout() !== 'left' }"
|
|
59
|
-
(click)="selectSnapLayout('left')"
|
|
60
|
-
class="et-qd-chip"
|
|
61
|
-
>
|
|
62
|
-
Left
|
|
63
|
-
</button>
|
|
64
|
-
<button
|
|
65
|
-
[ngClass]="{ 'et-qd-chip-secondary': snapLayout() !== 'right' }"
|
|
66
|
-
(click)="selectSnapLayout('right')"
|
|
67
|
-
class="et-qd-chip"
|
|
68
|
-
>
|
|
69
|
-
Right
|
|
70
|
-
</button>
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
@if (selectedClientConfig(); as cfg) {
|
|
74
|
-
<div class="et-qd-client">
|
|
75
|
-
<p class="et-qd-client__title">{{ cfg.displayName ?? cfg.client.config.baseRoute }}</p>
|
|
76
|
-
|
|
77
|
-
<div class="et-qd-client__actions">
|
|
78
|
-
<button (click)="cfg.client._store.refreshQueriesInUse()" class="et-qd-chip">Refresh all</button>
|
|
79
|
-
<button (click)="cfg.client._store.refreshQueriesInUse({ ignoreCacheValidity: true })" class="et-qd-chip">
|
|
80
|
-
Refresh all (ignore caches)
|
|
81
|
-
</button>
|
|
82
|
-
<button
|
|
83
|
-
(click)="cfg.client._store.refreshQueriesInUse({ ignoreCacheValidity: true, purgeUnused: true })"
|
|
84
|
-
class="et-qd-chip"
|
|
85
|
-
>
|
|
86
|
-
Refresh all (ignore caches & purge unused)
|
|
87
|
-
</button>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@if (selectedClientConfig(); as cfg) {
|
|
93
|
-
<div class="et-qd-queries">
|
|
94
|
-
<p class="et-qd-queries__title">Inspector</p>
|
|
95
|
-
<div class="et-qd-queries__actions">
|
|
96
|
-
<button
|
|
97
|
-
[ngClass]="{ 'et-qd-chip-secondary': queryListMode() !== 'live' || viewMode() !== 'query' }"
|
|
98
|
-
(click)="selectQueryListMode('live'); selectViewMode('query')"
|
|
99
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
100
|
-
>
|
|
101
|
-
Live Queries ({{ queries()?.length ?? 0 }})
|
|
102
|
-
</button>
|
|
103
|
-
<button
|
|
104
|
-
[ngClass]="{ 'et-qd-chip-secondary': queryListMode() !== 'history' || viewMode() !== 'query' }"
|
|
105
|
-
(click)="selectQueryListMode('history'); selectViewMode('query')"
|
|
106
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
107
|
-
>
|
|
108
|
-
Query History ({{ (queryHistory$ | async)?.length ?? 0 }}/50)
|
|
109
|
-
</button>
|
|
110
|
-
@if (queryListMode() === 'history' && viewMode() === 'query') {
|
|
111
|
-
<div class="et-qd-queries__divider"></div>
|
|
112
|
-
<button (click)="clearQueryHistory()" class="et-qd-chip et-qd-chip-bordered">Clear history</button>
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
<div class="et-qd-queries__divider"></div>
|
|
116
|
-
<button
|
|
117
|
-
[ngClass]="{ 'et-qd-chip-secondary': viewMode() !== 'authProvider' }"
|
|
118
|
-
(click)="selectViewMode('authProvider')"
|
|
119
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
120
|
-
>
|
|
121
|
-
Auth Provider
|
|
122
|
-
</button>
|
|
123
|
-
</div>
|
|
124
|
-
|
|
125
|
-
@if (viewMode() === 'query') {
|
|
126
|
-
<div class="et-qd-queries__browser">
|
|
127
|
-
@if (queryListMode() === 'live') {
|
|
128
|
-
<ul class="et-qd-queries__browser-list">
|
|
129
|
-
@for (query of queries(); track trackByQuery($index, query)) {
|
|
130
|
-
<li>
|
|
131
|
-
<button
|
|
132
|
-
[class.et-qd-query--active]="selectedQuery()?._id === query._id"
|
|
133
|
-
(click)="selectQuery(query)"
|
|
134
|
-
>
|
|
135
|
-
<span> {{ query._queryConfig.method }}</span>
|
|
136
|
-
<span> {{ query | queryShortName }}</span>
|
|
137
|
-
</button>
|
|
138
|
-
</li>
|
|
139
|
-
}
|
|
140
|
-
</ul>
|
|
141
|
-
}
|
|
142
|
-
@if (queryListMode() === 'history') {
|
|
143
|
-
<ul class="et-qd-queries__browser-list">
|
|
144
|
-
@for (query of queryHistory$ | async; track trackByQuery($index, query)) {
|
|
145
|
-
<li>
|
|
146
|
-
<button
|
|
147
|
-
[class.et-qd-query--active]="selectedQuery()?._id === query._id"
|
|
148
|
-
(click)="selectQuery(query)"
|
|
149
|
-
>
|
|
150
|
-
<span> {{ query._queryConfig.method }}</span>
|
|
151
|
-
<span> {{ query | queryShortName }}</span>
|
|
152
|
-
</button>
|
|
153
|
-
</li>
|
|
154
|
-
}
|
|
155
|
-
</ul>
|
|
156
|
-
}
|
|
157
|
-
<div class="et-qd-queries__browser-detail">
|
|
158
|
-
@if (selectedQuery(); as query) {
|
|
159
|
-
<p class="et-qd-queries__browser-detail__title">
|
|
160
|
-
{{ query._queryConfig.method }} {{ query._routeWithParams }}
|
|
161
|
-
</p>
|
|
162
|
-
|
|
163
|
-
<div class="et-qd-queries__actions">
|
|
164
|
-
<button (click)="query.execute()" class="et-qd-chip et-qd-chip-bordered">Execute</button>
|
|
165
|
-
<button (click)="query.execute({ skipCache: true })" class="et-qd-chip et-qd-chip-bordered">
|
|
166
|
-
Execute (ignore cache)
|
|
167
|
-
</button>
|
|
168
|
-
|
|
169
|
-
<button (click)="query.abort()" class="et-qd-chip et-qd-chip-bordered">Abort</button>
|
|
170
|
-
<div class="et-qd-queries__divider"></div>
|
|
171
|
-
<button
|
|
172
|
-
[ngClass]="{ 'et-qd-chip-secondary': !query.isPolling }"
|
|
173
|
-
(click)="query.poll({ interval: 5000, takeUntil: _destroy$ })"
|
|
174
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
175
|
-
>
|
|
176
|
-
Poll
|
|
177
|
-
</button>
|
|
178
|
-
|
|
179
|
-
<button
|
|
180
|
-
[ngClass]="{ 'et-qd-chip-secondary': query.isPolling }"
|
|
181
|
-
(click)="query.stopPolling()"
|
|
182
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
183
|
-
>
|
|
184
|
-
Stop polling
|
|
185
|
-
</button>
|
|
186
|
-
@if (query.isPolling || query._isPollingPaused) {
|
|
187
|
-
<button (click)="query.pausePolling()" class="et-qd-chip et-qd-chip-secondary et-qd-chip-bordered">
|
|
188
|
-
Pause polling
|
|
189
|
-
</button>
|
|
190
|
-
<button (click)="query.resumePolling()" class="et-qd-chip et-qd-chip-secondary et-qd-chip-bordered">
|
|
191
|
-
Resume polling
|
|
192
|
-
</button>
|
|
193
|
-
}
|
|
194
|
-
</div>
|
|
195
|
-
|
|
196
|
-
<div class="et-qd-list">
|
|
197
|
-
<div class="et-qd-list-item">
|
|
198
|
-
<p>State type</p>
|
|
199
|
-
<pre>{{ query.rawState.type }}</pre>
|
|
200
|
-
</div>
|
|
201
|
-
|
|
202
|
-
<div class="et-qd-list-item">
|
|
203
|
-
<p>Dependents</p>
|
|
204
|
-
<pre>{{ query._dependents | json }}</pre>
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
<div class="et-qd-list-item">
|
|
208
|
-
<p>Is expired</p>
|
|
209
|
-
<pre>{{ query.isExpired }}</pre>
|
|
210
|
-
</div>
|
|
211
|
-
|
|
212
|
-
<div class="et-qd-list-item">
|
|
213
|
-
<p>Is in use</p>
|
|
214
|
-
<pre>{{ query.isInUse }}</pre>
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
<div class="et-qd-list-item">
|
|
218
|
-
<p>Subscriber count</p>
|
|
219
|
-
<pre>{{ query._subscriberCount }}</pre>
|
|
220
|
-
</div>
|
|
221
|
-
|
|
222
|
-
<div class="et-qd-list-item">
|
|
223
|
-
<p>Is polling</p>
|
|
224
|
-
<pre>{{ query.isPolling }}</pre>
|
|
225
|
-
</div>
|
|
226
|
-
|
|
227
|
-
<div class="et-qd-list-item">
|
|
228
|
-
<p>Is polling paused</p>
|
|
229
|
-
<pre>{{ query._isPollingPaused }}</pre>
|
|
230
|
-
</div>
|
|
231
|
-
|
|
232
|
-
<div class="et-qd-list-item">
|
|
233
|
-
<p>Enable smart polling</p>
|
|
234
|
-
<pre>{{ query._enableSmartPolling }}</pre>
|
|
235
|
-
</div>
|
|
236
|
-
|
|
237
|
-
<div class="et-qd-list-item">
|
|
238
|
-
<p>Query store key</p>
|
|
239
|
-
<pre>{{ query._queryStoreKey }}</pre>
|
|
240
|
-
</div>
|
|
241
|
-
|
|
242
|
-
<div class="et-qd-list-item">
|
|
243
|
-
<p>Arguments</p>
|
|
244
|
-
|
|
245
|
-
<div>
|
|
246
|
-
<button
|
|
247
|
-
[ngClass]="{ 'et-qd-chip-secondary': !showArguments() }"
|
|
248
|
-
(click)="toggleShowArguments()"
|
|
249
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
250
|
-
>
|
|
251
|
-
Toggle
|
|
252
|
-
</button>
|
|
253
|
-
</div>
|
|
254
|
-
@if (showArguments()) {
|
|
255
|
-
<pre>{{ query._arguments | json }}</pre>
|
|
256
|
-
}
|
|
257
|
-
</div>
|
|
258
|
-
|
|
259
|
-
<div class="et-qd-list-item">
|
|
260
|
-
<p>State</p>
|
|
261
|
-
<p><i> Warning, this will cause a subscription if shown!</i></p>
|
|
262
|
-
<div>
|
|
263
|
-
<button
|
|
264
|
-
[ngClass]="{ 'et-qd-chip-secondary': !showResponse() }"
|
|
265
|
-
(click)="toggleShowResponse()"
|
|
266
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
267
|
-
>
|
|
268
|
-
Toggle
|
|
269
|
-
</button>
|
|
270
|
-
</div>
|
|
271
|
-
@if (showResponse()) {
|
|
272
|
-
<pre>{{ query.state$ | async | json }}</pre>
|
|
273
|
-
}
|
|
274
|
-
</div>
|
|
275
|
-
|
|
276
|
-
<div class="et-qd-list-item">
|
|
277
|
-
<p>Raw state</p>
|
|
278
|
-
<p><i> The query state unaffected by entity stores</i></p>
|
|
279
|
-
|
|
280
|
-
<div>
|
|
281
|
-
<button
|
|
282
|
-
[ngClass]="{ 'et-qd-chip-secondary': !showRawResponse() }"
|
|
283
|
-
(click)="toggleShowRawResponse()"
|
|
284
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
285
|
-
>
|
|
286
|
-
Toggle
|
|
287
|
-
</button>
|
|
288
|
-
</div>
|
|
289
|
-
@if (showRawResponse()) {
|
|
290
|
-
<pre>{{ query.rawState | json }}</pre>
|
|
291
|
-
}
|
|
292
|
-
</div>
|
|
293
|
-
|
|
294
|
-
<div class="et-qd-list-item">
|
|
295
|
-
<p>Query config</p>
|
|
296
|
-
|
|
297
|
-
<div>
|
|
298
|
-
<button
|
|
299
|
-
[ngClass]="{ 'et-qd-chip-secondary': !showQueryConfig() }"
|
|
300
|
-
(click)="toggleShowQueryConfig()"
|
|
301
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
302
|
-
>
|
|
303
|
-
Toggle
|
|
304
|
-
</button>
|
|
305
|
-
</div>
|
|
306
|
-
@if (showQueryConfig()) {
|
|
307
|
-
<pre>{{ stringifiedQueryConfig() | json }}</pre>
|
|
308
|
-
}
|
|
309
|
-
</div>
|
|
310
|
-
|
|
311
|
-
@if (!!query._queryConfig.entity) {
|
|
312
|
-
<div class="et-qd-list-item">
|
|
313
|
-
<p>Entity store value</p>
|
|
314
|
-
|
|
315
|
-
<div>
|
|
316
|
-
<button
|
|
317
|
-
[ngClass]="{ 'et-qd-chip-secondary': !showEntityStoreValue() }"
|
|
318
|
-
(click)="toggleShowEntityStoreValue()"
|
|
319
|
-
class="et-qd-chip et-qd-chip-bordered"
|
|
320
|
-
>
|
|
321
|
-
Toggle
|
|
322
|
-
</button>
|
|
323
|
-
</div>
|
|
324
|
-
@if (showEntityStoreValue()) {
|
|
325
|
-
<pre>{{ selectedQueryEntityStoreValue$ | async | json }}</pre>
|
|
326
|
-
}
|
|
327
|
-
</div>
|
|
328
|
-
}
|
|
329
|
-
</div>
|
|
330
|
-
}
|
|
331
|
-
</div>
|
|
332
|
-
</div>
|
|
333
|
-
} @else if (viewMode() === 'authProvider') {
|
|
334
|
-
<div class="et-qd-auth-provider__viewer">
|
|
335
|
-
@if (authProviderDetails(); as details) {
|
|
336
|
-
<div class="et-qd-list">
|
|
337
|
-
<div class="et-qd-list-item">
|
|
338
|
-
<p>Type</p>
|
|
339
|
-
<pre>{{ details.type }}</pre>
|
|
340
|
-
</div>
|
|
341
|
-
<div class="et-qd-list-item">
|
|
342
|
-
<p>Header value</p>
|
|
343
|
-
<pre>{{ details.header() | json }}</pre>
|
|
344
|
-
</div>
|
|
345
|
-
<div class="et-qd-list-item">
|
|
346
|
-
<p>Config</p>
|
|
347
|
-
<pre>{{ details.config | json }}</pre>
|
|
348
|
-
</div>
|
|
349
|
-
|
|
350
|
-
@if (details.type === 'BearerAuthProvider') {
|
|
351
|
-
<div class="et-qd-list-item">
|
|
352
|
-
<p>Tokens</p>
|
|
353
|
-
<pre>{{ details.provider.tokens$ | async | json }}</pre>
|
|
354
|
-
</div>
|
|
355
|
-
|
|
356
|
-
<div class="et-qd-list-item">
|
|
357
|
-
<p>Should refresh on unauthorized response</p>
|
|
358
|
-
<pre>{{ details.provider.shouldRefreshOnUnauthorizedResponse }}</pre>
|
|
359
|
-
</div>
|
|
360
|
-
|
|
361
|
-
<ng-container
|
|
362
|
-
*etQuery="
|
|
363
|
-
details.provider.currentRefreshQuery$ | async as response;
|
|
364
|
-
loading as loading;
|
|
365
|
-
error as error;
|
|
366
|
-
query as query
|
|
367
|
-
"
|
|
368
|
-
>
|
|
369
|
-
<div class="et-qd-list-item">
|
|
370
|
-
<p>Refresh query response</p>
|
|
371
|
-
|
|
372
|
-
<div>
|
|
373
|
-
<button (click)="details.provider._refreshQuery()" class="et-qd-chip et-qd-chip-bordered">
|
|
374
|
-
Refresh
|
|
375
|
-
</button>
|
|
376
|
-
</div>
|
|
377
|
-
<pre>{{ response | json }}</pre>
|
|
378
|
-
</div>
|
|
379
|
-
<div class="et-qd-list-item">
|
|
380
|
-
<p>Refresh query loading</p>
|
|
381
|
-
<pre>{{ loading }}</pre>
|
|
382
|
-
</div>
|
|
383
|
-
<div class="et-qd-list-item">
|
|
384
|
-
<p>Refresh query error</p>
|
|
385
|
-
<pre>{{ error ?? 'null' }}</pre>
|
|
386
|
-
</div>
|
|
387
|
-
<div class="et-qd-list-item">
|
|
388
|
-
<p>State</p>
|
|
389
|
-
<pre>{{ query?.state$ | async | json }}</pre>
|
|
390
|
-
</div>
|
|
391
|
-
</ng-container>
|
|
392
|
-
}
|
|
393
|
-
</div>
|
|
394
|
-
} @else {
|
|
395
|
-
<p>No auth provider set</p>
|
|
396
|
-
}
|
|
397
|
-
</div>
|
|
398
|
-
}
|
|
399
|
-
</div>
|
|
400
|
-
}
|
|
401
|
-
</div>
|
|
402
|
-
}
|