@venizia/ardor-kernel 0.5.0-12 → 0.5.0-13
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/README.md +1 -1
- package/dist/base/applications/abstract.d.ts +12 -24
- package/dist/base/applications/abstract.js +4 -6
- package/dist/base/decorators/api.d.ts +0 -3
- package/dist/base/decorators/api.js +0 -3
- package/dist/base/providers/base.d.ts +0 -3
- package/dist/base/providers/base.js +0 -3
- package/dist/base/providers/role-permission.d.ts +1 -8
- package/dist/base/providers/role-permission.js +0 -3
- package/dist/base/services/auth.d.ts +6 -12
- package/dist/base/services/auth.js +5 -8
- package/dist/base/services/base.d.ts +0 -3
- package/dist/base/services/base.js +0 -3
- package/dist/base/services/network-request-base.d.ts +133 -0
- package/dist/base/services/network-request-base.js +302 -0
- package/dist/base/services/network-request.d.ts +28 -131
- package/dist/base/services/network-request.js +13 -252
- package/dist/common/constants.d.ts +0 -23
- package/dist/common/constants.js +0 -23
- package/dist/common/keys.d.ts +17 -20
- package/dist/common/keys.js +5 -9
- package/dist/common/types.d.ts +45 -45
- package/dist/helpers/networks/auth-recovery.d.ts +0 -3
- package/dist/helpers/networks/auth-recovery.js +0 -3
- package/dist/{testing.d.ts → testing/index.d.ts} +2 -17
- package/dist/{testing.js → testing/index.js} +1 -16
- package/dist/utilities/auth-token-store.d.ts +2 -8
- package/dist/utilities/auth-token-store.js +1 -4
- package/dist/utilities/browser-clipboard.d.ts +1 -3
- package/dist/utilities/browser-clipboard.js +5 -5
- package/dist/utilities/browser-storage.d.ts +16 -10
- package/dist/utilities/browser-storage.js +36 -20
- package/dist/utilities/browser.d.ts +0 -3
- package/dist/utilities/browser.js +0 -3
- package/dist/utilities/file.d.ts +5 -5
- package/dist/utilities/file.js +5 -5
- package/dist/utilities/network-response-reader.d.ts +61 -17
- package/dist/utilities/network-response-reader.js +157 -22
- package/dist/utilities/request-body-encoder.d.ts +35 -15
- package/dist/utilities/request-body-encoder.js +67 -10
- package/dist/utilities/runtime-config.d.ts +8 -9
- package/dist/utilities/runtime-config.js +0 -9
- package/dist/utilities/storage-codecs.d.ts +0 -3
- package/dist/utilities/storage-codecs.js +0 -3
- package/dist/utilities/value.d.ts +0 -3
- package/dist/utilities/value.js +0 -3
- package/package.json +13 -13
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import { getError } from '@venizia/ignis-inversion';
|
|
2
2
|
import { HTTP } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import { HttpHeaders, HttpResponseReader, NativeFetcher, NativeFetchNetworkRequest, } from '@venizia/ignis-helpers/core';
|
|
4
|
-
import {
|
|
5
|
-
import { HttpExtraRequest } from '@venizia/ignis-kernel/repository';
|
|
6
|
-
import { App, LocalStorageKeys, RequestChannel, RequestCountData, RequestMethods, RequestTypes, } from '../../common/index.js';
|
|
4
|
+
import { RequestMethods, RequestTypes, } from '../../common/index.js';
|
|
7
5
|
import { AuthRecoveryHelper } from '../../helpers/index.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { NetworkResponseReader } from '../../utilities/index.js';
|
|
7
|
+
import { AbstractNetworkRequestService } from './network-request-base.js';
|
|
10
8
|
/**
|
|
11
9
|
* The `normalized.code` of the 401 that answers a request whose session is gone: the user who sent it signed out or another user signed in while it was in flight.
|
|
12
|
-
*
|
|
13
|
-
* @useWhen you tell a request that failed because the session changed from any other 401
|
|
14
10
|
*/
|
|
15
11
|
export const SESSION_CHANGED_CODE = 'ardor.network.session_changed';
|
|
16
12
|
/**
|
|
17
13
|
* The `normalized.code` of the 504 a request rejects with when it outlives the configured `timeout`.
|
|
18
|
-
*
|
|
19
|
-
* @useWhen you tell a request that timed out from any other failure
|
|
20
14
|
*/
|
|
21
15
|
export const NETWORK_TIMEOUT_CODE = 'ardor.network.timeout';
|
|
22
16
|
/**
|
|
@@ -28,21 +22,22 @@ export const NETWORK_TIMEOUT_CODE = 'ardor.network.timeout';
|
|
|
28
22
|
*
|
|
29
23
|
* The options hold data (the base URL, headers, the no-auth lists, the refresh path); behaviour is
|
|
30
24
|
* in the protected hooks, each taking one `opts` object, which a subclass overrides.
|
|
31
|
-
*
|
|
32
|
-
* @useWhen the data provider needs to send requests with timeout, auth recovery and normalized errors
|
|
33
|
-
* @insteadOf a hand-written `fetch` wrapper
|
|
34
25
|
*/
|
|
35
|
-
export class DefaultNetworkRequestService extends
|
|
26
|
+
export class DefaultNetworkRequestService extends AbstractNetworkRequestService {
|
|
36
27
|
constructor(opts) {
|
|
37
28
|
super({ scope: DefaultNetworkRequestService.name });
|
|
38
29
|
/** The session each data source request was sent under, keyed by the context object IGNIS hands to both hooks. */
|
|
39
30
|
this.sentSessions = new WeakMap();
|
|
40
|
-
const { name, baseUrl = '', headers = {},
|
|
31
|
+
const { name, baseUrl = '', headers = {}, noAuth = {}, authRecovery, authService, timeout = { use: false }, } = opts;
|
|
32
|
+
DefaultNetworkRequestService.assertNoAuthOptions({
|
|
33
|
+
options: opts,
|
|
34
|
+
owner: new.target.name,
|
|
35
|
+
});
|
|
41
36
|
DefaultNetworkRequestService.assertTimeout({ timeout });
|
|
42
37
|
this.timeout = timeout;
|
|
43
38
|
this.headers = HttpHeaders.merge({ layers: [headers] });
|
|
44
|
-
this.noAuthPaths =
|
|
45
|
-
this.noAuthPathRegexes = this.compileNoAuthPathRegex({ input:
|
|
39
|
+
this.noAuthPaths = noAuth.paths;
|
|
40
|
+
this.noAuthPathRegexes = this.compileNoAuthPathRegex({ input: noAuth.regex });
|
|
46
41
|
this.baseUrl = baseUrl;
|
|
47
42
|
this.authRecovery = authRecovery;
|
|
48
43
|
this.authService = authService;
|
|
@@ -78,76 +73,7 @@ export class DefaultNetworkRequestService extends BaseService {
|
|
|
78
73
|
}
|
|
79
74
|
return sent;
|
|
80
75
|
}
|
|
81
|
-
/**
|
|
82
|
-
* The token under the unscoped session key (`AuthTokenStore.read`), `undefined` outside a browser, for an
|
|
83
|
-
* application with no `id`. With an application `id` the session is under other keys: use
|
|
84
|
-
* `createAuthTokenReader({ id })`, the `HttpDataSource` `getDataSourceAuth()` of the data provider, or `authService.getAuth`.
|
|
85
|
-
*/
|
|
86
|
-
static readAuthTokenFromStorage() {
|
|
87
|
-
return AuthTokenStore.read();
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* A reader of the stored token of the application with this `id` (`IApplicationInfo.id`): the same
|
|
91
|
-
* key `DefaultAuthService.getAuth` reads (`LocalStorageKeys.scoped({ id }).token`). Without an `id` it
|
|
92
|
-
* is `readAuthTokenFromStorage`. Throws for an invalid `id`, when it is created.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* super({ baseUrl: '/api', authTokenResolver: DefaultNetworkRequestService.createAuthTokenReader({ id: 'shop' }) });
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
static createAuthTokenReader(opts = {}) {
|
|
100
|
-
const { token: key } = LocalStorageKeys.scoped({ id: opts.id });
|
|
101
|
-
return () => AuthTokenStore.read({ key });
|
|
102
|
-
}
|
|
103
|
-
/** Throws unless a timeout that is on has a positive integer `milliseconds`. */
|
|
104
|
-
static assertTimeout(opts) {
|
|
105
|
-
const { timeout } = opts;
|
|
106
|
-
if (!timeout?.use) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const { milliseconds } = timeout;
|
|
110
|
-
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) {
|
|
111
|
-
throw getError({
|
|
112
|
-
message: `[DefaultNetworkRequestService] timeout.milliseconds must be a positive integer, got ${milliseconds}`,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
76
|
// --- Hooks -----------------------------------------------------------------------------------
|
|
117
|
-
/**
|
|
118
|
-
* The token this service sends. The one way to supply a token: override it to read another
|
|
119
|
-
* store, or to hold the token in memory.
|
|
120
|
-
*/
|
|
121
|
-
resolveAuthToken() {
|
|
122
|
-
// The auth service knows where this application's session is kept (its `id` scopes the keys).
|
|
123
|
-
return this.authService
|
|
124
|
-
? (this.authService.getAuth() ?? undefined)
|
|
125
|
-
: DefaultNetworkRequestService.readAuthTokenFromStorage();
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Whether a request goes without a token: its `resource` is in `noAuthPaths`, or the resource, or
|
|
129
|
-
* the joined `paths`, matches `noAuthPathRegex`. To send no token at all (an API with no sign-in),
|
|
130
|
-
* set `noAuthPathRegex: /./`.
|
|
131
|
-
*/
|
|
132
|
-
isNoAuthPath(opts) {
|
|
133
|
-
const { resource, paths } = opts;
|
|
134
|
-
if (resource && this.noAuthPaths?.includes(resource)) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
if (!this.noAuthPathRegexes.length) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
const candidates = [resource, paths?.join('/')].filter((item) => !!item);
|
|
141
|
-
if (!candidates.length) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
return this.noAuthPathRegexes.some((regex) => {
|
|
145
|
-
return candidates.some((candidate) => {
|
|
146
|
-
regex.lastIndex = 0;
|
|
147
|
-
return regex.test(candidate);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
77
|
/**
|
|
152
78
|
* Refreshes the session after a 401. `true`: refreshed, the request is retried; `false`: this
|
|
153
79
|
* service has no refresh, or the session changed while the request was in flight (another user
|
|
@@ -215,62 +141,7 @@ export class DefaultNetworkRequestService extends BaseService {
|
|
|
215
141
|
});
|
|
216
142
|
return true;
|
|
217
143
|
}
|
|
218
|
-
/**
|
|
219
|
-
* The new token of a refresh response: `{ token: { value, type } }` or `{ token: '<jwt>' }`. A
|
|
220
|
-
* refresh keeps the same user, so nothing else is read. Override it for another shape. No token is
|
|
221
|
-
* a throw.
|
|
222
|
-
*/
|
|
223
|
-
readRefreshedToken(opts) {
|
|
224
|
-
const body = typeof opts.data === 'object' && opts.data !== null ? opts.data : {};
|
|
225
|
-
const { token } = body;
|
|
226
|
-
let record = {};
|
|
227
|
-
if (typeof token === 'string') {
|
|
228
|
-
record = { value: token };
|
|
229
|
-
}
|
|
230
|
-
else if (typeof token === 'object' && token !== null) {
|
|
231
|
-
record = token;
|
|
232
|
-
}
|
|
233
|
-
const value = 'value' in record ? record.value : undefined;
|
|
234
|
-
const type = 'type' in record ? record.type : undefined;
|
|
235
|
-
if (typeof value !== 'string' || !value) {
|
|
236
|
-
throw getError({ message: '[refreshToken] The refresh response carries no token' });
|
|
237
|
-
}
|
|
238
|
-
return { value, type: typeof type === 'string' ? type : App.TOKEN_TYPE };
|
|
239
|
-
}
|
|
240
|
-
/** Runs once when `refreshToken` threw. The place to send the user back to sign-in. */
|
|
241
|
-
onAuthFailure() {
|
|
242
|
-
return Promise.resolve();
|
|
243
|
-
}
|
|
244
|
-
/** The tracing id of a request, sent in `x-request-id`. Default `<application name>_<uuid>`. */
|
|
245
|
-
buildRequestTracingId(opts) {
|
|
246
|
-
return `${opts.applicationInfo.name}_${UuidV4Generator.generate()}`;
|
|
247
|
-
}
|
|
248
144
|
// --- No-auth and recovery --------------------------------------------------------------------
|
|
249
|
-
/** `noAuthPathRegex` as `RegExp`s; a string is compiled, and an invalid one is logged and dropped. */
|
|
250
|
-
compileNoAuthPathRegex(opts) {
|
|
251
|
-
const { input } = opts;
|
|
252
|
-
if (!input) {
|
|
253
|
-
return [];
|
|
254
|
-
}
|
|
255
|
-
const patterns = Array.isArray(input) ? input : [input];
|
|
256
|
-
const compiled = [];
|
|
257
|
-
for (const pattern of patterns) {
|
|
258
|
-
if (!pattern) {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (pattern instanceof RegExp) {
|
|
262
|
-
compiled.push(pattern);
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
compiled.push(new RegExp(pattern));
|
|
267
|
-
}
|
|
268
|
-
catch (error) {
|
|
269
|
-
this.logger.error('[compileNoAuthPathRegex] Invalid noAuthPathRegex pattern: %s | error: %o', pattern, error);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return compiled;
|
|
273
|
-
}
|
|
274
145
|
/**
|
|
275
146
|
* Refreshes the session, once for every 401 in flight on either transport (see `AuthRecoveryHelper`).
|
|
276
147
|
* Also what `DefaultAuthProvider.refreshToken` calls, so a refresh is made in one place.
|
|
@@ -406,117 +277,6 @@ export class DefaultNetworkRequestService extends BaseService {
|
|
|
406
277
|
errorRootKey: NetworkResponseReader.ERROR_ROOT_KEY,
|
|
407
278
|
};
|
|
408
279
|
}
|
|
409
|
-
/**
|
|
410
|
-
* The `token` (`<type> <value>`, `Bearer` when the type is empty) and `provider` of the stored
|
|
411
|
-
* token. Throws an error with status 401 when there is no token.
|
|
412
|
-
*/
|
|
413
|
-
getRequestAuthorizationHeader() {
|
|
414
|
-
const authToken = this.resolveAuthToken();
|
|
415
|
-
if (!authToken?.value) {
|
|
416
|
-
throw getError({
|
|
417
|
-
message: '[dataProvider][getAuthHeader] Invalid auth token to fetch!',
|
|
418
|
-
statusCode: 401,
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
return {
|
|
422
|
-
provider: authToken?.provider,
|
|
423
|
-
token: `${authToken?.type?.length ? authToken.type : App.TOKEN_TYPE} ${authToken.value}`,
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
/** Adds headers to every request this service sends; a name already set is replaced, in any case. */
|
|
427
|
-
setHeaders(opts) {
|
|
428
|
-
this.headers = HttpHeaders.merge({ layers: [this.headers, opts.headers] });
|
|
429
|
-
}
|
|
430
|
-
/** Removes the headers set by name, in any case. */
|
|
431
|
-
removeHeaders(opts) {
|
|
432
|
-
if (!opts.keys?.length) {
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
for (const key of opts.keys) {
|
|
436
|
-
this.headers.delete(key);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
/** The timezone, then whatever `setHeaders` holds now. Both transports send these. */
|
|
440
|
-
getSessionHeaders() {
|
|
441
|
-
return Object.fromEntries(HttpHeaders.merge({
|
|
442
|
-
layers: [
|
|
443
|
-
{
|
|
444
|
-
[HTTP.Headers.TIMEZONE]: App.TIMEZONE,
|
|
445
|
-
[HTTP.Headers.TIMEZONE_OFFSET]: `${App.TIMEZONE_OFFSET}`,
|
|
446
|
-
},
|
|
447
|
-
this.headers,
|
|
448
|
-
],
|
|
449
|
-
}));
|
|
450
|
-
}
|
|
451
|
-
/** The request channel (`RequestChannel.WEB` unless configured) and a fresh tracing id. */
|
|
452
|
-
getTracingHeaders(opts) {
|
|
453
|
-
const { restDataProviderOptions, applicationInfo } = opts;
|
|
454
|
-
const channel = restDataProviderOptions.requestTracingChannel?.length
|
|
455
|
-
? restDataProviderOptions.requestTracingChannel
|
|
456
|
-
: RequestChannel.WEB;
|
|
457
|
-
return {
|
|
458
|
-
[HTTP.Headers.REQUEST_CHANNEL]: channel,
|
|
459
|
-
[HTTP.Headers.REQUEST_TRACING_ID]: this.buildRequestTracingId({ applicationInfo }),
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* The session headers, plus `authorization` and `x-auth-provider` unless `resource` is a no-auth
|
|
464
|
-
* path. Throws a 401 error for any other resource when there is no token.
|
|
465
|
-
*/
|
|
466
|
-
getRequestHeader(opts) {
|
|
467
|
-
const { resource } = opts;
|
|
468
|
-
const defaultHeaders = this.getSessionHeaders();
|
|
469
|
-
if (this.isNoAuthPath({ resource })) {
|
|
470
|
-
return defaultHeaders;
|
|
471
|
-
}
|
|
472
|
-
const authHeader = this.getRequestAuthorizationHeader();
|
|
473
|
-
return {
|
|
474
|
-
...defaultHeaders,
|
|
475
|
-
// A token need not name a provider; never send the string `undefined`.
|
|
476
|
-
...(authHeader.provider ? { [HTTP.Headers.AUTH_PROVIDER]: authHeader.provider } : {}),
|
|
477
|
-
[HTTP.Headers.AUTHORIZATION]: authHeader.token,
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
/** The body as it is sent and the content type to send it under. Override to encode another way. */
|
|
481
|
-
encodeBody(opts) {
|
|
482
|
-
return RequestBodyEncoder.encode(opts);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* The headers (session, auth, tracing, `x-request-count`, the `extra` header, and the content type
|
|
486
|
-
* of the encoded body) and the encoded body of a request. Throws as `getRequestHeader` does.
|
|
487
|
-
*/
|
|
488
|
-
getRequestProps(params) {
|
|
489
|
-
const { bodyType, body, resource, restDataProviderOptions, applicationInfo, requestCountData = RequestCountData.DATA_ONLY, extra, } = params;
|
|
490
|
-
const extraHeader = HttpExtraRequest.toHeader({ extra });
|
|
491
|
-
// Merged, not spread, so a per-request value replaces a static header in any case.
|
|
492
|
-
const headers = Object.fromEntries(HttpHeaders.merge({
|
|
493
|
-
layers: [
|
|
494
|
-
this.getRequestHeader({ resource }),
|
|
495
|
-
this.getTracingHeaders({ restDataProviderOptions, applicationInfo }),
|
|
496
|
-
{ [HTTP.Headers.REQUEST_COUNT_DATA]: requestCountData },
|
|
497
|
-
extraHeader ? { [HttpExtraRequest.HEADER]: extraHeader } : undefined,
|
|
498
|
-
],
|
|
499
|
-
}));
|
|
500
|
-
const encoded = this.encodeBody({ bodyType, body });
|
|
501
|
-
const props = {
|
|
502
|
-
headers: encoded.contentType
|
|
503
|
-
? { ...headers, [HTTP.Headers.CONTENT_TYPE]: encoded.contentType }
|
|
504
|
-
: headers,
|
|
505
|
-
body: encoded.body,
|
|
506
|
-
};
|
|
507
|
-
return props;
|
|
508
|
-
}
|
|
509
|
-
/** Reads a response by the request type. See `NetworkResponseReader.convert`. */
|
|
510
|
-
convertResponse(opts) {
|
|
511
|
-
return NetworkResponseReader.convert(opts);
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Sends the request and reads the response by `type`. Throws when `baseUrl` (the option, else the
|
|
515
|
-
* service's) is empty. A 401 on a path that can recover triggers `refresh` and, if it refreshed,
|
|
516
|
-
* one retry with the new token. Any other non-2xx response, or a retry that still fails, throws
|
|
517
|
-
* the error read from the response. An aborted `signal` rejects with its reason, and a request
|
|
518
|
-
* that outlives the service's `timeout` rejects with a 504 coded `NETWORK_TIMEOUT_CODE`.
|
|
519
|
-
*/
|
|
520
280
|
async doRequest(opts) {
|
|
521
281
|
const { baseUrl = this.baseUrl, paths, signal } = opts;
|
|
522
282
|
if (!baseUrl) {
|
|
@@ -551,7 +311,7 @@ export class DefaultNetworkRequestService extends BaseService {
|
|
|
551
311
|
}
|
|
552
312
|
/** `doRequest` once the URL is checked: the send, the refresh and retry after a 401, then the read. */
|
|
553
313
|
async sendAndRead(opts) {
|
|
554
|
-
const { url, type, method, paths, body, headers, query, requestCountData, signal } = opts;
|
|
314
|
+
const { url, type, method, paths, body, headers, query, requestCountData, signal, schema } = opts;
|
|
555
315
|
const sendOnce = (retryHeaders) => {
|
|
556
316
|
return this.networkRequest.getNetworkService().send({
|
|
557
317
|
url,
|
|
@@ -626,6 +386,7 @@ export class DefaultNetworkRequestService extends BaseService {
|
|
|
626
386
|
response: fetched,
|
|
627
387
|
type,
|
|
628
388
|
requestCountData,
|
|
389
|
+
schema,
|
|
629
390
|
});
|
|
630
391
|
return response;
|
|
631
392
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ConstClass } from '@venizia/ignis-helpers/common';
|
|
2
2
|
/**
|
|
3
3
|
* Values of the running environment, read once when the module loads.
|
|
4
|
-
*
|
|
5
|
-
* @useWhen you need the runtime timezone, the default debounce time or the default token type
|
|
6
|
-
* @insteadOf a timezone, a debounce number or the string `'Bearer'` written by hand
|
|
7
4
|
*/
|
|
8
5
|
export declare class App {
|
|
9
6
|
/** The IANA name of the timezone of the runtime. */
|
|
@@ -17,9 +14,6 @@ export declare class App {
|
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
16
|
* HTTP methods.
|
|
20
|
-
*
|
|
21
|
-
* @useWhen you name an HTTP method
|
|
22
|
-
* @insteadOf string literals such as `'GET'`
|
|
23
17
|
*/
|
|
24
18
|
export declare class RequestMethods extends ConstClass {
|
|
25
19
|
static readonly HEAD = "HEAD";
|
|
@@ -32,8 +26,6 @@ export declare class RequestMethods extends ConstClass {
|
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
34
28
|
* What a request is for, which decides how its response is read: `SEND`, and react-admin's data provider calls.
|
|
35
|
-
*
|
|
36
|
-
* @useWhen you say what a request is for, which decides how its response is read
|
|
37
29
|
*/
|
|
38
30
|
export declare class RequestTypes extends ConstClass {
|
|
39
31
|
/** A request that is not a react-admin call. */
|
|
@@ -50,9 +42,6 @@ export declare class RequestTypes extends ConstClass {
|
|
|
50
42
|
}
|
|
51
43
|
/**
|
|
52
44
|
* The Web Storage areas `BrowserStorage` reads and writes.
|
|
53
|
-
*
|
|
54
|
-
* @useWhen you pick `localStorage` or `sessionStorage` for `BrowserStorage`
|
|
55
|
-
* @insteadOf the strings `'local'` and `'session'`
|
|
56
45
|
*/
|
|
57
46
|
export declare class StorageAreas {
|
|
58
47
|
/** `localStorage`. */
|
|
@@ -62,9 +51,6 @@ export declare class StorageAreas {
|
|
|
62
51
|
}
|
|
63
52
|
/**
|
|
64
53
|
* How a request body is encoded; see `RequestBodyEncoder`.
|
|
65
|
-
*
|
|
66
|
-
* @useWhen you pick how a request body is encoded
|
|
67
|
-
* @insteadOf setting the `Content-Type` and stringifying by hand
|
|
68
54
|
*/
|
|
69
55
|
export declare class RequestBodyTypes extends ConstClass {
|
|
70
56
|
/** The body goes through as it is. */
|
|
@@ -76,9 +62,6 @@ export declare class RequestBodyTypes extends ConstClass {
|
|
|
76
62
|
}
|
|
77
63
|
/**
|
|
78
64
|
* Names of the build environments.
|
|
79
|
-
*
|
|
80
|
-
* @useWhen you compare the build environment by name
|
|
81
|
-
* @insteadOf string literals such as `'production'`
|
|
82
65
|
*/
|
|
83
66
|
export declare class Environments extends ConstClass {
|
|
84
67
|
static readonly DEVELOPMENT = "development";
|
|
@@ -86,9 +69,6 @@ export declare class Environments extends ConstClass {
|
|
|
86
69
|
}
|
|
87
70
|
/**
|
|
88
71
|
* The channels a request says it comes from, sent in `x-request-channel`.
|
|
89
|
-
*
|
|
90
|
-
* @useWhen you set the `x-request-channel` header of a request
|
|
91
|
-
* @insteadOf a header string written by hand
|
|
92
72
|
*/
|
|
93
73
|
export declare class RequestChannel extends ConstClass {
|
|
94
74
|
/** A browser application; what a request says unless `requestTracingChannel` is set. */
|
|
@@ -96,9 +76,6 @@ export declare class RequestChannel extends ConstClass {
|
|
|
96
76
|
}
|
|
97
77
|
/**
|
|
98
78
|
* Whether a response carries a count, sent in `x-request-count`.
|
|
99
|
-
*
|
|
100
|
-
* @useWhen you ask for or read the `x-request-count` header
|
|
101
|
-
* @insteadOf a header string written by hand
|
|
102
79
|
*/
|
|
103
80
|
export declare class RequestCountData extends ConstClass {
|
|
104
81
|
/**
|
package/dist/common/constants.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ConstClass } from '@venizia/ignis-helpers/common';
|
|
2
2
|
/**
|
|
3
3
|
* Values of the running environment, read once when the module loads.
|
|
4
|
-
*
|
|
5
|
-
* @useWhen you need the runtime timezone, the default debounce time or the default token type
|
|
6
|
-
* @insteadOf a timezone, a debounce number or the string `'Bearer'` written by hand
|
|
7
4
|
*/
|
|
8
5
|
export class App {
|
|
9
6
|
/** The IANA name of the timezone of the runtime. */
|
|
@@ -17,9 +14,6 @@ export class App {
|
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
16
|
* HTTP methods.
|
|
20
|
-
*
|
|
21
|
-
* @useWhen you name an HTTP method
|
|
22
|
-
* @insteadOf string literals such as `'GET'`
|
|
23
17
|
*/
|
|
24
18
|
export class RequestMethods extends ConstClass {
|
|
25
19
|
static { this.HEAD = 'HEAD'; }
|
|
@@ -32,8 +26,6 @@ export class RequestMethods extends ConstClass {
|
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
34
28
|
* What a request is for, which decides how its response is read: `SEND`, and react-admin's data provider calls.
|
|
35
|
-
*
|
|
36
|
-
* @useWhen you say what a request is for, which decides how its response is read
|
|
37
29
|
*/
|
|
38
30
|
export class RequestTypes extends ConstClass {
|
|
39
31
|
/** A request that is not a react-admin call. */
|
|
@@ -51,9 +43,6 @@ export class RequestTypes extends ConstClass {
|
|
|
51
43
|
}
|
|
52
44
|
/**
|
|
53
45
|
* The Web Storage areas `BrowserStorage` reads and writes.
|
|
54
|
-
*
|
|
55
|
-
* @useWhen you pick `localStorage` or `sessionStorage` for `BrowserStorage`
|
|
56
|
-
* @insteadOf the strings `'local'` and `'session'`
|
|
57
46
|
*/
|
|
58
47
|
export class StorageAreas {
|
|
59
48
|
/** `localStorage`. */
|
|
@@ -63,9 +52,6 @@ export class StorageAreas {
|
|
|
63
52
|
}
|
|
64
53
|
/**
|
|
65
54
|
* How a request body is encoded; see `RequestBodyEncoder`.
|
|
66
|
-
*
|
|
67
|
-
* @useWhen you pick how a request body is encoded
|
|
68
|
-
* @insteadOf setting the `Content-Type` and stringifying by hand
|
|
69
55
|
*/
|
|
70
56
|
export class RequestBodyTypes extends ConstClass {
|
|
71
57
|
/** The body goes through as it is. */
|
|
@@ -77,9 +63,6 @@ export class RequestBodyTypes extends ConstClass {
|
|
|
77
63
|
}
|
|
78
64
|
/**
|
|
79
65
|
* Names of the build environments.
|
|
80
|
-
*
|
|
81
|
-
* @useWhen you compare the build environment by name
|
|
82
|
-
* @insteadOf string literals such as `'production'`
|
|
83
66
|
*/
|
|
84
67
|
export class Environments extends ConstClass {
|
|
85
68
|
static { this.DEVELOPMENT = 'development'; }
|
|
@@ -87,9 +70,6 @@ export class Environments extends ConstClass {
|
|
|
87
70
|
}
|
|
88
71
|
/**
|
|
89
72
|
* The channels a request says it comes from, sent in `x-request-channel`.
|
|
90
|
-
*
|
|
91
|
-
* @useWhen you set the `x-request-channel` header of a request
|
|
92
|
-
* @insteadOf a header string written by hand
|
|
93
73
|
*/
|
|
94
74
|
export class RequestChannel extends ConstClass {
|
|
95
75
|
/** A browser application; what a request says unless `requestTracingChannel` is set. */
|
|
@@ -97,9 +77,6 @@ export class RequestChannel extends ConstClass {
|
|
|
97
77
|
}
|
|
98
78
|
/**
|
|
99
79
|
* Whether a response carries a count, sent in `x-request-count`.
|
|
100
|
-
*
|
|
101
|
-
* @useWhen you ask for or read the `x-request-count` header
|
|
102
|
-
* @insteadOf a header string written by hand
|
|
103
80
|
*/
|
|
104
81
|
export class RequestCountData extends ConstClass {
|
|
105
82
|
/**
|
package/dist/common/keys.d.ts
CHANGED
|
@@ -13,9 +13,6 @@ export type TCoreBindingType<TName extends string> = TName extends keyof ICoreBi
|
|
|
13
13
|
/**
|
|
14
14
|
* The container keys the kernel binds and reads, each made by `BindingKeys.build<T>` with the type of
|
|
15
15
|
* its value.
|
|
16
|
-
*
|
|
17
|
-
* @useWhen you read or bind a key the kernel owns in the container
|
|
18
|
-
* @insteadOf a string key written by hand
|
|
19
16
|
*/
|
|
20
17
|
export declare class CoreBindings {
|
|
21
18
|
/** The application itself, bound by `preConfigure`. */
|
|
@@ -45,20 +42,23 @@ export declare class CoreBindings {
|
|
|
45
42
|
}
|
|
46
43
|
/** The session keys and the store prefix of one application, from `LocalStorageKeys.scoped`. */
|
|
47
44
|
export interface IScopedKeys {
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
/** What the keys of this application start with. */
|
|
46
|
+
prefixes: {
|
|
47
|
+
/**
|
|
48
|
+
* The prefix of this application's session keys: `DefaultAuthService.cleanUp` removes them. Without
|
|
49
|
+
* an application `id` it is also the start of every scoped session, and `cleanUp` skips those.
|
|
50
|
+
*/
|
|
51
|
+
auth: string;
|
|
52
|
+
/**
|
|
53
|
+
* The data of this application's signed-in user; sign-out removes every key that starts with it.
|
|
54
|
+
* Without an application `id` it is `@app/store/`, the start of every scoped store prefix, so an
|
|
55
|
+
* application without an `id` removes the data of the applications with one: every application on
|
|
56
|
+
* an origin sets an `id`.
|
|
57
|
+
*/
|
|
58
|
+
store: string;
|
|
59
|
+
/** The preferences of this application's user: they outlive a sign-out. */
|
|
60
|
+
prefs: string;
|
|
61
|
+
};
|
|
62
62
|
/** The stored locale of the i18n provider. */
|
|
63
63
|
locale: string;
|
|
64
64
|
token: string;
|
|
@@ -67,9 +67,6 @@ export interface IScopedKeys {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* The `localStorage` keys the kernel owns.
|
|
70
|
-
*
|
|
71
|
-
* @useWhen you read a `localStorage` key the kernel owns
|
|
72
|
-
* @insteadOf a storage key string written by hand
|
|
73
70
|
*/
|
|
74
71
|
export declare class LocalStorageKeys {
|
|
75
72
|
/**
|
package/dist/common/keys.js
CHANGED
|
@@ -2,9 +2,6 @@ import { BindingKeys, getError } from '@venizia/ignis-inversion';
|
|
|
2
2
|
/**
|
|
3
3
|
* The container keys the kernel binds and reads, each made by `BindingKeys.build<T>` with the type of
|
|
4
4
|
* its value.
|
|
5
|
-
*
|
|
6
|
-
* @useWhen you read or bind a key the kernel owns in the container
|
|
7
|
-
* @insteadOf a string key written by hand
|
|
8
5
|
*/
|
|
9
6
|
export class CoreBindings {
|
|
10
7
|
/** The application itself, bound by `preConfigure`. */
|
|
@@ -58,9 +55,6 @@ export class CoreBindings {
|
|
|
58
55
|
}
|
|
59
56
|
/**
|
|
60
57
|
* The `localStorage` keys the kernel owns.
|
|
61
|
-
*
|
|
62
|
-
* @useWhen you read a `localStorage` key the kernel owns
|
|
63
|
-
* @insteadOf a storage key string written by hand
|
|
64
58
|
*/
|
|
65
59
|
export class LocalStorageKeys {
|
|
66
60
|
/**
|
|
@@ -106,9 +100,11 @@ export class LocalStorageKeys {
|
|
|
106
100
|
}
|
|
107
101
|
const scope = id === undefined ? '' : `${id}/`;
|
|
108
102
|
return {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
prefixes: {
|
|
104
|
+
auth: `${this.PREFIX_AUTH}${scope}`,
|
|
105
|
+
store: `${this.PREFIX_STORE}${scope}`,
|
|
106
|
+
prefs: `${this.PREFIX_PREFS}${scope}`,
|
|
107
|
+
},
|
|
112
108
|
locale: `${this.PREFIX_PREFS}${scope}locale`,
|
|
113
109
|
token: `${this.PREFIX_AUTH}${scope}token`,
|
|
114
110
|
identity: `${this.PREFIX_AUTH}${scope}identity`,
|