@venizia/ardor-kernel 0.4.8-15 → 0.4.8-16
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
CHANGED
|
@@ -26,7 +26,7 @@ which re-exports this package.
|
|
|
26
26
|
| Constants | `RequestMethods`, `RequestTypes`, `RequestBodyTypes`, `RequestCountData`, `HeaderConstants`, `Environments`, `App`, `Authentication`, `StorageAreas`, `RequestChannel` |
|
|
27
27
|
| Network | `NetworkHeaders`, `RequestBodyEncoder`, `ResponseReader`, `AuthRecovery`, `AuthTokenStore` (the fetch transport is IGNIS's `NodeFetchNetworkRequest`) |
|
|
28
28
|
| Utilities | `ValueUtility` (`isDefined`, `isString`, `isNumber`, `isObject`, `isValidDate`), `BrowserUtility.isBrowser`, `FileUtility.toDataUrl`, `RuntimeConfig.get` (with `RUNTIME_CONFIG_GLOBAL` and `RUNTIME_CONFIG_REQUIRED_CODE`), `BrowserStorage`, `BrowserClipboard`, `StorageCodecs`; the earlier bare names are removed (`bun run ardor codemod namespace` moves your code) |
|
|
29
|
-
| Types | `IdType`, `
|
|
29
|
+
| Types | `IdType`, `IAuthUser`, `ValueOrPromise`, `ValueOf`, `TConstValue`, `TPaths`, `TFullPaths`, `ISendParams`, `IRestDataProviderOptions`, `IApplicationInfo`, ... |
|
|
30
30
|
|
|
31
31
|
## License
|
|
32
32
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IApplicationInfo, type IAuthTokenRecord, type IAuthUser, type IdType, type IScopedKeys } from '../../common/index.js';
|
|
2
2
|
import { BaseService } from './base.js';
|
|
3
3
|
/**
|
|
4
4
|
* Keeps the signed-in session (token, identity, roles) in `localStorage`, everything under
|
|
@@ -23,7 +23,9 @@ export declare class DefaultAuthService extends BaseService {
|
|
|
23
23
|
*/
|
|
24
24
|
private parseStored;
|
|
25
25
|
/** The stored identity; `{}` when nothing usable is stored, also outside a browser. */
|
|
26
|
-
getUser():
|
|
26
|
+
getUser(): IAuthUser;
|
|
27
|
+
/** A stored identity is data from the browser: an object whose known fields, when present, have their type. */
|
|
28
|
+
private isAuthUser;
|
|
27
29
|
/**
|
|
28
30
|
* The stored roles; empty when nothing usable is stored, also outside a browser. They are data in
|
|
29
31
|
* the browser, so whoever controls the browser can change them: use them to show or hide interface,
|
|
@@ -70,8 +70,20 @@ let DefaultAuthService = DefaultAuthService_1 = class DefaultAuthService extends
|
|
|
70
70
|
key: this.keys.identity,
|
|
71
71
|
method: 'getUser',
|
|
72
72
|
});
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
return this.isAuthUser(identity) ? identity : {};
|
|
74
|
+
}
|
|
75
|
+
/** A stored identity is data from the browser: an object whose known fields, when present, have their type. */
|
|
76
|
+
isAuthUser(value) {
|
|
77
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const userId = 'userId' in value ? value.userId : undefined;
|
|
81
|
+
const username = 'username' in value ? value.username : undefined;
|
|
82
|
+
const referenceId = 'referenceId' in value ? value.referenceId : undefined;
|
|
83
|
+
const provider = 'provider' in value ? value.provider : undefined;
|
|
84
|
+
const isId = (field) => field === undefined || ['string', 'number'].includes(typeof field);
|
|
85
|
+
const isText = (field) => field === undefined || typeof field === 'string';
|
|
86
|
+
return isId(userId) && isText(username) && isId(referenceId) && isText(provider);
|
|
75
87
|
}
|
|
76
88
|
/**
|
|
77
89
|
* The stored roles; empty when nothing usable is stored, also outside a browser. They are data in
|
|
@@ -171,7 +171,7 @@ export declare class DefaultNetworkRequestService extends BaseService {
|
|
|
171
171
|
doRequest<TResult = unknown>(opts: IGetRequestPropsResult & {
|
|
172
172
|
/** @default this.baseUrl */
|
|
173
173
|
baseUrl?: string;
|
|
174
|
-
query?:
|
|
174
|
+
query?: Record<string, unknown>;
|
|
175
175
|
type: TRequestType;
|
|
176
176
|
method: TRequestMethod;
|
|
177
177
|
paths: string[];
|
package/dist/common/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TConstValue, TNumberConstValue, TPrettify, TStringConstValue, ValueOf, ValueOptional, ValueOptionalExcept, ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
2
2
|
import type { TBuildInfoRecord } from '@venizia/ignis-helpers/core';
|
|
3
3
|
import type { TClass } from '@venizia/ignis-inversion';
|
|
4
4
|
import type { TExtraRequest } from '@venizia/ignis-kernel/repository';
|
|
5
5
|
import type { Environments, RequestBodyTypes, RequestCountData, RequestMethods, RequestTypes, StorageAreas } from './constants.js';
|
|
6
6
|
/** A record id: a string or a number. */
|
|
7
7
|
export type IdType = string | number;
|
|
8
|
-
export type {
|
|
8
|
+
export type { TConstValue, TNumberConstValue, TPrettify, TStringConstValue, ValueOf, ValueOptional, ValueOptionalExcept, ValueOrPromise, };
|
|
9
9
|
/** One of the `RequestMethods` values. */
|
|
10
10
|
export type TRequestMethod = TStringConstValue<typeof RequestMethods>;
|
|
11
11
|
/** One of the `Environments` values. */
|
|
@@ -66,10 +66,23 @@ export interface IGetRequestPropsResult {
|
|
|
66
66
|
headers?: HeadersInit;
|
|
67
67
|
body?: unknown;
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Keys react-admin does not know ride on its params and become filter keys. A react-admin param type
|
|
71
|
+
* is an interface, which has no index signature: spread it (`{ ...params }`) where this is expected.
|
|
72
|
+
*/
|
|
70
73
|
export interface ICustomParams {
|
|
71
|
-
params?: Record<string,
|
|
72
|
-
[key: string]:
|
|
74
|
+
params?: Record<string, unknown>;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The identity `saveAuth` stores and `getUser` reads back: every field is absent when nothing is
|
|
79
|
+
* stored. It has no index signature, so an interface of your own that has these fields fits it.
|
|
80
|
+
*/
|
|
81
|
+
export interface IAuthUser {
|
|
82
|
+
userId?: IdType;
|
|
83
|
+
username?: string;
|
|
84
|
+
referenceId?: IdType;
|
|
85
|
+
provider?: string;
|
|
73
86
|
}
|
|
74
87
|
/** What `login` read from the sign-in response. `roles` are names. */
|
|
75
88
|
export interface ISignInSession {
|
|
@@ -261,18 +274,18 @@ export interface IArdorApplication {
|
|
|
261
274
|
}
|
|
262
275
|
type TDeepPath = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
263
276
|
/** Values a path stops at: their members are not state. */
|
|
264
|
-
type TPathLeaf = Date | RegExp | ReadonlySet<
|
|
277
|
+
type TPathLeaf = Date | RegExp | ReadonlySet<unknown> | ReadonlyMap<unknown, unknown> | Promise<unknown> | ((...args: never[]) => unknown);
|
|
265
278
|
type TIsAny<TValue> = 0 extends 1 & TValue ? true : false;
|
|
266
279
|
/**
|
|
267
280
|
* The dotted paths of an object type, to `DeepLevel` levels (10 by default). An array, a `Date`, a
|
|
268
281
|
* `Set`, a `Map`, a `Promise`, a function and an `any` field are leaves: the path stops at them.
|
|
269
282
|
*/
|
|
270
|
-
export type TPaths<T, DeepLevel extends number = 10> = DeepLevel extends 0 ? never : T extends Array<
|
|
271
|
-
[K in keyof T]-?: K extends string | number ? TIsAny<T[K]> extends true ? `${K}` : NonNullable<T[K]> extends Array<
|
|
283
|
+
export type TPaths<T, DeepLevel extends number = 10> = DeepLevel extends 0 ? never : T extends Array<unknown> | TPathLeaf ? never : T extends object ? {
|
|
284
|
+
[K in keyof T]-?: K extends string | number ? TIsAny<T[K]> extends true ? `${K}` : NonNullable<T[K]> extends Array<unknown> | TPathLeaf ? `${K}` : NonNullable<T[K]> extends object ? `${K}` | `${K}.${TPaths<NonNullable<T[K]>, TDeepPath[DeepLevel]>}` : `${K}` : never;
|
|
272
285
|
}[keyof T] : never;
|
|
273
286
|
/** The dotted paths of an object type, to `DeepLevel` levels (10 by default); unlike `TPaths`, only the paths down to a leaf value. */
|
|
274
287
|
export type TFullPaths<T, DeepLevel extends number = 10> = DeepLevel extends never ? never : T extends Array<infer U> ? TFullPaths<U> : T extends object ? {
|
|
275
|
-
[K in keyof T]-?: K extends string | number ? T[K] extends
|
|
288
|
+
[K in keyof T]-?: K extends string | number ? T[K] extends object ? `${K}.${TFullPaths<T[K], TDeepPath[DeepLevel]>}` : `${K}` : never;
|
|
276
289
|
}[keyof T] : never;
|
|
277
290
|
/** What an application is: bound under `CoreBindings.APPLICATION_INFO`, and the name a tracing id starts with. */
|
|
278
291
|
export interface IApplicationInfo {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ardor-kernel",
|
|
3
|
-
"version": "0.4.8-
|
|
3
|
+
"version": "0.4.8-16",
|
|
4
4
|
"description": "ARDOR kernel - the isomorphic core of the ARDOR frontend framework: application base on IGNIS inversion, service and provider bases, request/auth constants, binding keys, the network request service, runtime config and the HTTP repository (from IGNIS). No React and no react-admin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ardor",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@size-limit/preset-small-lib": "^14.2.0",
|
|
74
74
|
"@types/bun": "^1.4.3",
|
|
75
|
-
"@venizia/dev-configs": "^0.4.8-
|
|
76
|
-
"@venizia/ignis-connectors": "^0.4.8-
|
|
77
|
-
"@venizia/ignis-filter": "^0.4.7-
|
|
78
|
-
"@venizia/ignis-helpers": "^0.4.8-
|
|
79
|
-
"@venizia/ignis-inversion": "^0.4.7-
|
|
80
|
-
"@venizia/ignis-kernel": "^0.4.8-
|
|
75
|
+
"@venizia/dev-configs": "^0.4.8-10",
|
|
76
|
+
"@venizia/ignis-connectors": "^0.4.8-16",
|
|
77
|
+
"@venizia/ignis-filter": "^0.4.7-6",
|
|
78
|
+
"@venizia/ignis-helpers": "^0.4.8-14",
|
|
79
|
+
"@venizia/ignis-inversion": "^0.4.7-5",
|
|
80
|
+
"@venizia/ignis-kernel": "^0.4.8-16",
|
|
81
81
|
"eslint": "^10.13.0",
|
|
82
82
|
"oxlint": "1.89.0",
|
|
83
83
|
"oxlint-tsgolint": "7.0.2004",
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"typescript": "^6.0.3"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@venizia/ignis-connectors": "^0.4.8-
|
|
91
|
-
"@venizia/ignis-filter": "^0.4.7-
|
|
92
|
-
"@venizia/ignis-helpers": "^0.4.8-
|
|
93
|
-
"@venizia/ignis-inversion": "^0.4.7-
|
|
94
|
-
"@venizia/ignis-kernel": "^0.4.8-
|
|
90
|
+
"@venizia/ignis-connectors": "^0.4.8-16",
|
|
91
|
+
"@venizia/ignis-filter": "^0.4.7-6",
|
|
92
|
+
"@venizia/ignis-helpers": "^0.4.8-14",
|
|
93
|
+
"@venizia/ignis-inversion": "^0.4.7-5",
|
|
94
|
+
"@venizia/ignis-kernel": "^0.4.8-16",
|
|
95
95
|
"reflect-metadata": ">=0.2.2"
|
|
96
96
|
},
|
|
97
97
|
"peerDependenciesMeta": {
|