@tstdl/base 0.83.8 → 0.83.10

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/.eslintrc.cjs CHANGED
@@ -68,7 +68,7 @@ module.exports = {
68
68
  'import/no-duplicates': ['warn', { 'prefer-inline': true }],
69
69
  'import/no-cycle': ['off', { ignoreExternal: true }],
70
70
  'import/no-self-import': ['error'],
71
- 'import/no-extraneous-dependencies': ['error', { devDependencies: false, includeTypes: true }],
71
+ 'import/no-extraneous-dependencies': ['off', { devDependencies: false, includeTypes: true }],
72
72
  'import/no-empty-named-blocks': ['error'],
73
73
  'import/no-mutable-exports': ['error'],
74
74
  'import/no-nodejs-modules': ['error'],
@@ -211,70 +211,59 @@ module.exports = {
211
211
 
212
212
  'field',
213
213
 
214
- // Getters
214
+ // Getters / Setters
215
215
  '#private-static-get',
216
- 'private-static-get',
217
- 'protected-static-get',
218
- 'public-static-get',
219
-
220
- /*
221
- 'private-decorated-get',
222
- 'protected-decorated-get',
223
- 'public-decorated-get',
224
- */
225
-
226
- '#private-instance-get',
227
- 'private-instance-get',
228
- 'protected-instance-get',
229
- 'public-instance-get',
230
-
231
- 'protected-abstract-get',
232
- 'public-abstract-get',
233
-
234
- '#private-get',
235
- 'private-get',
236
- 'protected-get',
237
- 'public-get',
238
-
239
- 'static-get',
240
- 'instance-get',
241
- 'abstract-get',
242
-
243
- // 'decorated-get',
244
-
245
- 'get',
246
-
247
- // Setters
248
216
  '#private-static-set',
217
+ 'private-static-get',
249
218
  'private-static-set',
219
+ 'protected-static-get',
250
220
  'protected-static-set',
221
+ 'public-static-get',
251
222
  'public-static-set',
252
223
 
253
224
  /*
225
+ 'private-decorated-get',
254
226
  'private-decorated-set',
227
+ 'protected-decorated-get',
255
228
  'protected-decorated-set',
229
+ 'public-decorated-get',
256
230
  'public-decorated-set',
257
231
  */
258
232
 
233
+ '#private-instance-get',
259
234
  '#private-instance-set',
235
+ 'private-instance-get',
260
236
  'private-instance-set',
237
+ 'protected-instance-get',
261
238
  'protected-instance-set',
239
+ 'public-instance-get',
262
240
  'public-instance-set',
263
241
 
242
+ 'protected-abstract-get',
264
243
  'protected-abstract-set',
244
+ 'public-abstract-get',
265
245
  'public-abstract-set',
266
246
 
247
+ '#private-get',
267
248
  '#private-set',
249
+ 'private-get',
268
250
  'private-set',
251
+ 'protected-get',
269
252
  'protected-set',
253
+ 'public-get',
270
254
  'public-set',
271
255
 
256
+ 'static-get',
272
257
  'static-set',
258
+ 'instance-get',
273
259
  'instance-set',
260
+ 'abstract-get',
274
261
  'abstract-set',
275
262
 
276
- // 'decorated-set',
263
+ 'decorated-get',
264
+ 'decorated-set',
277
265
 
266
+ 'get',
278
267
  'set',
279
268
 
280
269
  // Static initialization
@@ -1,32 +1,26 @@
1
1
  import type { ApiDefinition } from '../api/types.js';
2
2
  import type { SchemaTestable } from '../schema/schema.js';
3
- import type { ObjectSchemaOrType } from '../schema/types/types.js';
3
+ import type { ObjectSchema, ObjectSchemaOrType } from '../schema/types/types.js';
4
4
  import type { Record } from '../types.js';
5
+ import type { TokenPayload } from './index.js';
5
6
  import { SecretCheckResult } from './models/secret-check-result.model.js';
6
7
  import { TokenPayloadBase } from './models/token-payload-base.model.js';
7
8
  export declare const dontWaitForValidToken: unique symbol;
8
- type GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload = Record<never>, AuthenticationData = void> = typeof getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>;
9
- type AuthenticationApiEndpointsDefinition<AdditionalTokenPayload = Record<never>, AuthenticationData = void> = ReturnType<GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>>;
10
- export type AuthenticationApiDefinition<AdditionalTokenPayload = Record<never>, AuthenticationData = void> = ApiDefinition<string, AuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>>;
9
+ type GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> = typeof getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>;
10
+ type AuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> = ReturnType<GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>>;
11
+ export type AuthenticationApiDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> = ApiDefinition<string, AuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>>;
11
12
  export declare const authenticationApiDefinition: {
12
13
  resource: string;
13
14
  endpoints: {
14
15
  token: {
15
16
  resource: string;
16
17
  method: "POST";
17
- parameters: import("../schema/types/types.js").ObjectSchema<{
18
+ parameters: ObjectSchema<{
18
19
  subject: string;
19
20
  secret: string;
20
21
  data: unknown;
21
22
  }>;
22
- result: import("../schema/types/types.js").ObjectSchema<{
23
- jti: string;
24
- iat: number;
25
- exp: number;
26
- refreshTokenExp: number;
27
- sessionId: string;
28
- subject: string;
29
- }>;
23
+ result: ObjectSchema<TokenPayloadBase>;
30
24
  credentials: true;
31
25
  data: {
32
26
  [dontWaitForValidToken]: boolean;
@@ -35,17 +29,10 @@ export declare const authenticationApiDefinition: {
35
29
  refresh: {
36
30
  resource: string;
37
31
  method: "POST";
38
- parameters: import("../schema/types/types.js").ObjectSchema<{
32
+ parameters: ObjectSchema<{
39
33
  data: unknown;
40
34
  }>;
41
- result: import("../schema/types/types.js").ObjectSchema<{
42
- jti: string;
43
- iat: number;
44
- exp: number;
45
- refreshTokenExp: number;
46
- sessionId: string;
47
- subject: string;
48
- }>;
35
+ result: ObjectSchema<TokenPayloadBase>;
49
36
  credentials: true;
50
37
  data: {
51
38
  [dontWaitForValidToken]: boolean;
@@ -63,7 +50,7 @@ export declare const authenticationApiDefinition: {
63
50
  initResetSecret: {
64
51
  resource: string;
65
52
  method: "POST";
66
- parameters: import("../schema/types/types.js").ObjectSchema<{
53
+ parameters: ObjectSchema<{
67
54
  subject: string;
68
55
  }>;
69
56
  result: import("../schema/types/types.js").ValueSchema<"ok">;
@@ -71,7 +58,7 @@ export declare const authenticationApiDefinition: {
71
58
  resetSecret: {
72
59
  resource: string;
73
60
  method: "POST";
74
- parameters: import("../schema/types/types.js").ObjectSchema<{
61
+ parameters: ObjectSchema<{
75
62
  token: string;
76
63
  newSecret: string;
77
64
  }>;
@@ -80,7 +67,7 @@ export declare const authenticationApiDefinition: {
80
67
  checkSecret: {
81
68
  resource: string;
82
69
  method: "POST";
83
- parameters: import("../schema/types/types.js").ObjectSchema<{
70
+ parameters: ObjectSchema<{
84
71
  secret: string;
85
72
  }>;
86
73
  result: typeof SecretCheckResult;
@@ -91,18 +78,18 @@ export declare const authenticationApiDefinition: {
91
78
  };
92
79
  };
93
80
  };
94
- export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalEndpoints>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, resource?: string, additionalEndpoints?: AdditionalEndpoints): {
81
+ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalEndpoints>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, resource?: string, additionalEndpoints?: AdditionalEndpoints): {
95
82
  resource: string;
96
83
  endpoints: {
97
84
  token: {
98
85
  resource: string;
99
86
  method: "POST";
100
- parameters: import("../schema/types/types.js").ObjectSchema<{
87
+ parameters: ObjectSchema<{
101
88
  subject: string;
102
89
  secret: string;
103
90
  data: AuthenticationData;
104
91
  }>;
105
- result: import("../schema/types/types.js").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge.js").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
92
+ result: ObjectSchema<TokenPayload<AdditionalTokenPayload>>;
106
93
  credentials: true;
107
94
  data: {
108
95
  [dontWaitForValidToken]: boolean;
@@ -111,10 +98,10 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, A
111
98
  refresh: {
112
99
  resource: string;
113
100
  method: "POST";
114
- parameters: import("../schema/types/types.js").ObjectSchema<{
101
+ parameters: ObjectSchema<{
115
102
  data: AuthenticationData;
116
103
  }>;
117
- result: import("../schema/types/types.js").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge.js").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
104
+ result: ObjectSchema<TokenPayload<AdditionalTokenPayload>>;
118
105
  credentials: true;
119
106
  data: {
120
107
  [dontWaitForValidToken]: boolean;
@@ -132,7 +119,7 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, A
132
119
  initResetSecret: {
133
120
  resource: string;
134
121
  method: "POST";
135
- parameters: import("../schema/types/types.js").ObjectSchema<{
122
+ parameters: ObjectSchema<{
136
123
  subject: string;
137
124
  }>;
138
125
  result: import("../schema/types/types.js").ValueSchema<"ok">;
@@ -140,7 +127,7 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, A
140
127
  resetSecret: {
141
128
  resource: string;
142
129
  method: "POST";
143
- parameters: import("../schema/types/types.js").ObjectSchema<{
130
+ parameters: ObjectSchema<{
144
131
  token: string;
145
132
  newSecret: string;
146
133
  }>;
@@ -149,7 +136,7 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, A
149
136
  checkSecret: {
150
137
  resource: string;
151
138
  method: "POST";
152
- parameters: import("../schema/types/types.js").ObjectSchema<{
139
+ parameters: ObjectSchema<{
153
140
  secret: string;
154
141
  }>;
155
142
  result: typeof SecretCheckResult;
@@ -160,16 +147,16 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, A
160
147
  };
161
148
  };
162
149
  };
163
- export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>): {
150
+ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record, AuthenticationData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>): {
164
151
  token: {
165
152
  resource: string;
166
153
  method: "POST";
167
- parameters: import("../schema/types/types.js").ObjectSchema<{
154
+ parameters: ObjectSchema<{
168
155
  subject: string;
169
156
  secret: string;
170
157
  data: AuthenticationData;
171
158
  }>;
172
- result: import("../schema/types/types.js").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge.js").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
159
+ result: ObjectSchema<TokenPayload<AdditionalTokenPayload>>;
173
160
  credentials: true;
174
161
  data: {
175
162
  [dontWaitForValidToken]: boolean;
@@ -178,10 +165,10 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
178
165
  refresh: {
179
166
  resource: string;
180
167
  method: "POST";
181
- parameters: import("../schema/types/types.js").ObjectSchema<{
168
+ parameters: ObjectSchema<{
182
169
  data: AuthenticationData;
183
170
  }>;
184
- result: import("../schema/types/types.js").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge.js").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
171
+ result: ObjectSchema<TokenPayload<AdditionalTokenPayload>>;
185
172
  credentials: true;
186
173
  data: {
187
174
  [dontWaitForValidToken]: boolean;
@@ -199,7 +186,7 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
199
186
  initResetSecret: {
200
187
  resource: string;
201
188
  method: "POST";
202
- parameters: import("../schema/types/types.js").ObjectSchema<{
189
+ parameters: ObjectSchema<{
203
190
  subject: string;
204
191
  }>;
205
192
  result: import("../schema/types/types.js").ValueSchema<"ok">;
@@ -207,7 +194,7 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
207
194
  resetSecret: {
208
195
  resource: string;
209
196
  method: "POST";
210
- parameters: import("../schema/types/types.js").ObjectSchema<{
197
+ parameters: ObjectSchema<{
211
198
  token: string;
212
199
  newSecret: string;
213
200
  }>;
@@ -216,7 +203,7 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
216
203
  checkSecret: {
217
204
  resource: string;
218
205
  method: "POST";
219
- parameters: import("../schema/types/types.js").ObjectSchema<{
206
+ parameters: ObjectSchema<{
220
207
  secret: string;
221
208
  }>;
222
209
  result: typeof SecretCheckResult;
@@ -1,8 +1,9 @@
1
1
  import type { ApiClient } from '../../api/client/index.js';
2
2
  import type { SchemaTestable } from '../../schema/schema.js';
3
3
  import type { ObjectSchemaOrType } from '../../schema/types/types.js';
4
+ import type { Record } from '../../types.js';
4
5
  import type { AuthenticationApiDefinition } from '../authentication.api.js';
5
- export declare function getAuthenticationApiClient<AdditionalTokenPayload, AuthenticationData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>): ApiClient<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData>>;
6
+ export declare function getAuthenticationApiClient<AdditionalTokenPayload extends Record, AuthenticationData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>): ApiClient<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData>>;
6
7
  declare const defaultAuthenticationApiClient: ApiClient<AuthenticationApiDefinition<{}, unknown>>;
7
8
  export declare class AuthenticationApiClient extends defaultAuthenticationApiClient {
8
9
  }
@@ -10,7 +10,7 @@ import type { Record } from '../../types.js';
10
10
  import type { Observable } from 'rxjs';
11
11
  import type { AuthenticationApiDefinition } from '../authentication.api.js';
12
12
  import type { SecretCheckResult, TokenPayload } from '../models/index.js';
13
- export declare class AuthenticationService<AdditionalTokenPayload = Record<never>, AuthenticationData = void> implements AfterResolve, AsyncDisposable {
13
+ export declare class AuthenticationService<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> implements AfterResolve, AsyncDisposable {
14
14
  private readonly client;
15
15
  private readonly errorSubject;
16
16
  private readonly tokenSubject;
@@ -20,8 +20,6 @@ export declare class AuthenticationService<AdditionalTokenPayload = Record<never
20
20
  private readonly refreshLock;
21
21
  private readonly logger;
22
22
  private readonly disposeToken;
23
- private set authenticationData(value);
24
- private get authenticationData();
25
23
  readonly error$: Observable<Error>;
26
24
  readonly token$: Observable<TokenPayload<AdditionalTokenPayload> | undefined>;
27
25
  readonly definedToken$: Observable<TokenPayload<AdditionalTokenPayload>>;
@@ -32,6 +30,8 @@ export declare class AuthenticationService<AdditionalTokenPayload = Record<never
32
30
  readonly definedSessionId$: Observable<string>;
33
31
  readonly isLoggedIn$: Observable<boolean>;
34
32
  readonly loggedOut$: Observable<void>;
33
+ private get authenticationData();
34
+ private set authenticationData(value);
35
35
  get isLoggedIn(): boolean;
36
36
  get token(): TokenPayload<AdditionalTokenPayload> | undefined;
37
37
  get definedToken(): TokenPayload<AdditionalTokenPayload>;
@@ -69,22 +69,6 @@ let AuthenticationService = class AuthenticationService2 {
69
69
  refreshLock;
70
70
  logger;
71
71
  disposeToken;
72
- set authenticationData(data) {
73
- if ((0, import_type_guards.isUndefined)(data)) {
74
- localStorage.removeItem(authenticationDataStorageKey);
75
- } else {
76
- const json = JSON.stringify(data);
77
- localStorage.setItem(authenticationDataStorageKey, json);
78
- }
79
- }
80
- get authenticationData() {
81
- try {
82
- const data = localStorage.getItem(authenticationDataStorageKey);
83
- return (0, import_type_guards.isNull)(data) ? void 0 : JSON.parse(data);
84
- } catch {
85
- return void 0;
86
- }
87
- }
88
72
  error$;
89
73
  token$;
90
74
  definedToken$;
@@ -95,6 +79,22 @@ let AuthenticationService = class AuthenticationService2 {
95
79
  definedSessionId$;
96
80
  isLoggedIn$;
97
81
  loggedOut$;
82
+ get authenticationData() {
83
+ try {
84
+ const data = localStorage.getItem(authenticationDataStorageKey);
85
+ return (0, import_type_guards.isNull)(data) ? void 0 : JSON.parse(data);
86
+ } catch {
87
+ return void 0;
88
+ }
89
+ }
90
+ set authenticationData(data) {
91
+ if ((0, import_type_guards.isUndefined)(data)) {
92
+ localStorage.removeItem(authenticationDataStorageKey);
93
+ } else {
94
+ const json = JSON.stringify(data);
95
+ localStorage.setItem(authenticationDataStorageKey, json);
96
+ }
97
+ }
98
98
  get isLoggedIn() {
99
99
  return (0, import_type_guards.isDefined)(this.tokenSubject.value);
100
100
  }
@@ -1,5 +1,5 @@
1
1
  import type { HttpClientMiddleware } from '../../http/client/http-client.js';
2
2
  import { AuthenticationService } from './authentication.service.js';
3
3
  export type AuthenticationServiceProvider = () => (AuthenticationService<any, any> | Promise<AuthenticationService<any, any>>);
4
- export declare const defaultAuthenticationServiceProvider: () => Promise<AuthenticationService<unknown, unknown>>;
4
+ export declare const defaultAuthenticationServiceProvider: () => Promise<AuthenticationService<import("../../types.js").Record, unknown>>;
5
5
  export declare function waitForAuthenticationCredentialsMiddleware(authenticationService?: AuthenticationService | AuthenticationServiceProvider): HttpClientMiddleware;
@@ -1,11 +1,11 @@
1
1
  import type { Record } from '../../types.js';
2
2
  import type { JwtToken, JwtTokenHeader } from '../../utils/jwt.js';
3
- import type { TokenPayloadBase } from '../models/token-payload-base.model.js';
3
+ import type { TokenPayloadBase } from './token-payload-base.model.js';
4
4
  export type TokenHeader = {
5
5
  v: number;
6
6
  };
7
- export type Token<AdditionalTokenPayload = Record<never>> = JwtToken<TokenPayload<AdditionalTokenPayload>, JwtTokenHeader<TokenHeader>>;
8
- export type TokenPayload<T = Record<never>> = T & TokenPayloadBase;
7
+ export type Token<AdditionalTokenPayload extends Record = Record<never>> = JwtToken<TokenPayload<AdditionalTokenPayload>, JwtTokenHeader<TokenHeader>>;
8
+ export type TokenPayload<T extends Record = Record<never>> = T & TokenPayloadBase;
9
9
  export type RefreshToken = JwtToken<{
10
10
  /** expiration timestamp in seconds */
11
11
  exp: number;
@@ -2,7 +2,7 @@ import type { ApiController, ApiRequestContext, ApiServerResult } from '../../ap
2
2
  import type { Record } from '../../types.js';
3
3
  import type { AuthenticationApiDefinition } from '../authentication.api.js';
4
4
  import { AuthenticationService } from './authentication.service.js';
5
- export declare class AuthenticationApiController<AdditionalTokenPayload = Record<never>, AuthenticationData = void> implements ApiController<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData>> {
5
+ export declare class AuthenticationApiController<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> implements ApiController<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData>> {
6
6
  readonly authenticationService: AuthenticationService<AdditionalTokenPayload, AuthenticationData>;
7
7
  constructor(authenticationService: AuthenticationService<AdditionalTokenPayload, AuthenticationData>);
8
8
  token({ parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData>, 'token'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData>, 'token'>>;
@@ -34,12 +34,12 @@ export type AuthenticationResult = {
34
34
  success: false;
35
35
  subject?: undefined;
36
36
  };
37
- export type TokenResult<AdditionalTokenPayload = Record<never>> = {
37
+ export type TokenResult<AdditionalTokenPayload extends Record = Record<never>> = {
38
38
  token: string;
39
39
  jsonToken: Token<AdditionalTokenPayload>;
40
40
  refreshToken: string;
41
41
  };
42
- export declare class AuthenticationService<AdditionalTokenPayload = Record<never>, AuthenticationData = void> implements AfterResolve {
42
+ export declare class AuthenticationService<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void> implements AfterResolve {
43
43
  private readonly credentialsRepository;
44
44
  private readonly sessionRepository;
45
45
  private readonly authenticationSecretRequirementsValidator;
@@ -1,6 +1,6 @@
1
1
  import type { HttpServerRequest } from '../../http/server/index.js';
2
2
  import type { Record } from '../../types.js';
3
- import type { SecretResetToken, RefreshToken, Token } from '../models/index.js';
3
+ import type { RefreshToken, SecretResetToken, Token } from '../models/index.js';
4
4
  /**
5
5
  *
6
6
  * @param request
@@ -8,8 +8,8 @@ import type { SecretResetToken, RefreshToken, Token } from '../models/index.js';
8
8
  * @returns token string
9
9
  */
10
10
  export declare function tryGetAuthorizationTokenStringFromRequest(request: HttpServerRequest, cookieName?: string, forceCookie?: boolean): string | undefined;
11
- export declare function tryGetTokenFromRequest<AdditionalTokenPayload = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload> | undefined>;
12
- export declare function getTokenFromRequest<AdditionalTokenPayload = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
13
- export declare function getTokenFromString<AdditionalTokenPayload = Record<never>>(tokenString: string, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
11
+ export declare function tryGetTokenFromRequest<AdditionalTokenPayload extends Record = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload> | undefined>;
12
+ export declare function getTokenFromRequest<AdditionalTokenPayload extends Record = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
13
+ export declare function getTokenFromString<AdditionalTokenPayload extends Record = Record<never>>(tokenString: string, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
14
14
  export declare function getRefreshTokenFromString(tokenString: string, secret: string | BinaryData): Promise<RefreshToken>;
15
15
  export declare function getSecretResetTokenFromString(tokenString: string, secret: string | BinaryData): Promise<SecretResetToken>;
@@ -1,6 +1,6 @@
1
1
  import type { Decorator } from '../reflection/index.js';
2
- import type { Constructor, OneOrMany, Simplify, TypedExtract, TypedOmit } from '../types.js';
3
- import type { Lifecycle, RegistrationOptions } from './container.js';
2
+ import type { Constructor, OneOrMany, Simplify, TypedOmit } from '../types.js';
3
+ import type { RegistrationOptions } from './container.js';
4
4
  import type { Provider } from './provider.js';
5
5
  import type { InjectionToken } from './token.js';
6
6
  import type { ArgumentProvider, ForwardRefInjectionToken, Mapper } from './types.js';
@@ -32,7 +32,7 @@ export declare function singleton<T = any, A = any>(options?: InjectableOptionsW
32
32
  * registers the class in the global container with scoped lifecycle. Decorated class is not modified in any way
33
33
  * @param options registration options
34
34
  */
35
- export declare function scoped<T = any, A = any>(lifecycle: Simplify<TypedExtract<Lifecycle, 'resolution'>>, options?: InjectableOptionsWithoutLifecycle<T, A>): ClassDecorator;
35
+ export declare function scoped<T = any, A = any>(lifecycle: 'resolution', options?: InjectableOptionsWithoutLifecycle<T, A>): ClassDecorator;
36
36
  /**
37
37
  * sets the token used to resolve the parameter
38
38
  * @param token token used for resolving
@@ -2,8 +2,7 @@ import { Dictionary } from './dictionary.js';
2
2
  type Node = {
3
3
  nodeKey: any;
4
4
  parentNode: Node | undefined;
5
- hasInnerMap: boolean;
6
- children: Map<any, Node>;
5
+ children: Map<any, Node> | undefined;
7
6
  hasValue: boolean;
8
7
  value: any;
9
8
  };
@@ -21,7 +21,6 @@ __export(multi_key_map_exports, {
21
21
  MultiKeyMap: () => MultiKeyMap
22
22
  });
23
23
  module.exports = __toCommonJS(multi_key_map_exports);
24
- var import_lazy_property = require("../utils/object/lazy-property.js");
25
24
  var import_type_guards = require("../utils/type-guards.js");
26
25
  var import_circular_buffer = require("./circular-buffer.js");
27
26
  var import_dictionary = require("./dictionary.js");
@@ -32,7 +31,7 @@ class MultiKeyMap extends import_dictionary.Dictionary {
32
31
  constructor(newMapProvider = () => /* @__PURE__ */ new Map()) {
33
32
  super();
34
33
  this.newMapProvider = newMapProvider;
35
- this.rootNode = createNode(void 0, void 0, this.newMapProvider);
34
+ this.rootNode = createNode(void 0, void 0);
36
35
  }
37
36
  includes([key, value]) {
38
37
  if (!this.has(key)) {
@@ -54,10 +53,9 @@ class MultiKeyMap extends import_dictionary.Dictionary {
54
53
  }
55
54
  set(key, value) {
56
55
  const node = this.getNode(key, true);
57
- const hasValue = node.hasValue;
58
- node.hasValue = true;
59
56
  node.value = value;
60
- if (!hasValue) {
57
+ if (!node.hasValue) {
58
+ node.hasValue = true;
61
59
  this.incrementSize();
62
60
  }
63
61
  }
@@ -65,14 +63,14 @@ class MultiKeyMap extends import_dictionary.Dictionary {
65
63
  return this.has(key);
66
64
  }
67
65
  has(key) {
68
- const node = this.getNode(key, false);
66
+ const node = this.getNode(key);
69
67
  return (0, import_type_guards.isDefined)(node) && node.hasValue;
70
68
  }
71
69
  getFlat(...key) {
72
70
  return this.get(key);
73
71
  }
74
72
  get(key) {
75
- const node = this.getNode(key, false);
73
+ const node = this.getNode(key);
76
74
  if ((0, import_type_guards.isUndefined)(node)) {
77
75
  return void 0;
78
76
  }
@@ -82,7 +80,7 @@ class MultiKeyMap extends import_dictionary.Dictionary {
82
80
  return this.delete(key);
83
81
  }
84
82
  delete(key) {
85
- const node = this.getNode(key, false);
83
+ const node = this.getNode(key);
86
84
  if ((0, import_type_guards.isUndefined)(node)) {
87
85
  return false;
88
86
  }
@@ -118,7 +116,7 @@ class MultiKeyMap extends import_dictionary.Dictionary {
118
116
  if (node.hasValue) {
119
117
  yield [key, node.value];
120
118
  }
121
- if (node.hasInnerMap) {
119
+ if ((0, import_type_guards.isDefined)(node.children)) {
122
120
  for (const innerNode of node.children.values()) {
123
121
  queue.add([[...key, innerNode.nodeKey], innerNode]);
124
122
  }
@@ -126,48 +124,44 @@ class MultiKeyMap extends import_dictionary.Dictionary {
126
124
  }
127
125
  }
128
126
  _clear() {
129
- this.rootNode = createNode(void 0, void 0, this.newMapProvider);
130
- }
131
- getNode(key, create) {
132
- let node = getOrCreateChildNode(this.rootNode, key[0], this.newMapProvider);
133
- for (let i = 1; i < key.length; i++) {
134
- if (!node.hasInnerMap && !create) {
135
- return void 0;
127
+ this.rootNode = createNode(void 0, void 0);
128
+ this.setSize(0);
129
+ }
130
+ getNode(key, create = false) {
131
+ let node = this.rootNode;
132
+ for (const nodeKey of key) {
133
+ if ((0, import_type_guards.isUndefined)(node.children)) {
134
+ if (!create) {
135
+ return void 0;
136
+ }
137
+ node.children = this.newMapProvider();
138
+ }
139
+ let childNode = node.children.get(nodeKey);
140
+ if ((0, import_type_guards.isUndefined)(childNode)) {
141
+ if (!create) {
142
+ return void 0;
143
+ }
144
+ childNode = createNode(nodeKey, node);
145
+ node.children.set(nodeKey, childNode);
136
146
  }
137
- node = getOrCreateChildNode(this.rootNode, key[i], this.newMapProvider);
147
+ node = childNode;
138
148
  }
139
149
  return node;
140
150
  }
141
151
  deleteNodeIfEmpty(node) {
142
- if (node.hasValue || node.hasInnerMap && node.children.size > 0 || (0, import_type_guards.isUndefined)(node.parentNode)) {
152
+ if (node.hasValue || (0, import_type_guards.isDefined)(node.children) && node.children.size > 0 || (0, import_type_guards.isUndefined)(node.parentNode)) {
143
153
  return;
144
154
  }
145
155
  node.parentNode.children.delete(node.nodeKey);
146
156
  this.deleteNodeIfEmpty(node.parentNode);
147
157
  }
148
158
  }
149
- function getOrCreateChildNode(node, key, newMapProvider) {
150
- const childNode = node.children.get(key);
151
- if ((0, import_type_guards.isDefined)(childNode)) {
152
- return childNode;
153
- }
154
- const newNode = createNode(key, node, newMapProvider);
155
- node.children.set(key, newNode);
156
- return newNode;
157
- }
158
- function createNode(nodeKey, parentNode, newMapProvider) {
159
- return (0, import_lazy_property.lazyObject)({
160
- nodeKey: { value: nodeKey },
161
- parentNode: { value: parentNode },
162
- hasInnerMap: false,
163
- children() {
164
- return getChildren(this, newMapProvider);
165
- },
159
+ function createNode(nodeKey, parentNode) {
160
+ return {
161
+ nodeKey,
162
+ parentNode,
163
+ children: void 0,
166
164
  hasValue: false,
167
- value: { value: void 0 }
168
- });
169
- }
170
- function getChildren(node, newMapProvider) {
171
- node.hasInnerMap = true;
172
- return newMapProvider();
165
+ value: void 0
166
+ };
173
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.83.8",
3
+ "version": "0.83.10",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,7 +21,7 @@
21
21
  "luxon": "^3.3",
22
22
  "reflect-metadata": "^0.1",
23
23
  "rxjs": "^7.8",
24
- "type-fest": "^2.19"
24
+ "type-fest": "^3.7"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/chroma-js": "2.4",
@@ -59,7 +59,7 @@
59
59
  "nodemailer": "^6.9",
60
60
  "preact": "^10.13",
61
61
  "preact-render-to-string": "^5.2",
62
- "puppeteer": "^19.7",
62
+ "puppeteer": "^19.8",
63
63
  "undici": "^5.21",
64
64
  "urlpattern-polyfill": "^6.0"
65
65
  },
@@ -47,7 +47,7 @@ export declare function localizationData<T>(data: LocalizationData<T>): Localiza
47
47
  * @param localization
48
48
  * @returns
49
49
  */
50
- export declare function getLocalizationKeys<T extends Localization<any, any>>(_localization?: T): ProxyLocalizationKeys<T['keys']>;
50
+ export declare function getLocalizationKeys<T extends Localization>(_localization?: T): ProxyLocalizationKeys<T['keys']>;
51
51
  export declare const autoEnumerationLocalization: typeof _autoEnumerationLocalization;
52
52
  export declare class LocalizationService {
53
53
  private readonly logger;
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { UnionToIntersection } from 'type-fest';
1
+ import type { Except, UnionToIntersection } from 'type-fest';
2
2
  export type ObjectLiteral = {};
3
3
  export type PrimitiveTypeMap = {
4
4
  'string': string;
@@ -113,16 +113,19 @@ export type OmitBy<T, V> = Omit<T, {
113
113
  */
114
114
  export type Optionalize<T extends object> = OmitBy<T, undefined> & Partial<PickBy<T, undefined>>;
115
115
  export type SimplifiedOptionalize<T extends object> = Simplify<Optionalize<T>>;
116
- /**
117
- * remove nested type information
118
- */
119
- export type Simplify<T> = T extends (Primitive | Function | Date | RegExp) ? T : T extends (infer AT)[] ? Simplify<AT>[] : T extends readonly (infer AT)[] ? readonly Simplify<AT>[] : T extends Record ? SimplifyObject<T> : T;
120
- /**
121
- * remove type information on object
122
- */
116
+ export type Merge<T1, T2> = SimplifyObject<Except<T1, Extract<keyof T1, keyof T2>> & T2>;
117
+ export type Simplify<T> = T extends BuiltIn ? T : T extends readonly any[] ? SimplifyArray<T> : T extends Record ? SimplifyObject<T> : T;
123
118
  export type SimplifyObject<T extends Record> = {
124
119
  [K in keyof T]: T[K];
125
120
  } & {};
121
+ export type SimplifyArray<T extends readonly any[]> = {
122
+ [I in keyof T]: Simplify<T[I]>;
123
+ };
124
+ export type SimplifyDeep<T> = T extends BuiltIn ? T : T extends readonly any[] ? {
125
+ [K in keyof T]: SimplifyDeep<T[K]>;
126
+ } : T extends Record ? {
127
+ [K in keyof T]: SimplifyDeep<T[K]>;
128
+ } & {} : T;
126
129
  export type UnionToTuple<T, Tuple extends any[] = []> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? UnionToTuple<Exclude<T, R>, [R, ...Tuple]> : Tuple;
127
130
  export type UndefinableObject<T extends Record> = {
128
131
  [K in keyof T]: T[K] | undefined;