@tstdl/base 0.92.116 → 0.92.119
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/authentication/authentication.api.d.ts +8 -8
- package/authentication/authentication.api.js +2 -4
- package/formats.d.ts +18 -12
- package/formats.js +10 -9
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiDefinition } from '../api/types.js';
|
|
1
|
+
import { type ApiDefinition, type ApiEndpointsDefinition } from '../api/types.js';
|
|
2
2
|
import { type ObjectSchema, type ObjectSchemaOrType } from '../schema/index.js';
|
|
3
3
|
import type { SchemaTestable } from '../schema/schema.js';
|
|
4
4
|
import type { Record } from '../types.js';
|
|
@@ -17,7 +17,7 @@ export declare const authenticationApiDefinition: {
|
|
|
17
17
|
parameters: ObjectSchema<{
|
|
18
18
|
readonly subject: string;
|
|
19
19
|
readonly secret: string;
|
|
20
|
-
readonly data:
|
|
20
|
+
readonly data: undefined;
|
|
21
21
|
}>;
|
|
22
22
|
result: ObjectSchema<TokenPayload<import("type-fest").EmptyObject>>;
|
|
23
23
|
credentials: true;
|
|
@@ -29,7 +29,7 @@ export declare const authenticationApiDefinition: {
|
|
|
29
29
|
resource: string;
|
|
30
30
|
method: "POST";
|
|
31
31
|
parameters: ObjectSchema<{
|
|
32
|
-
readonly data:
|
|
32
|
+
readonly data: undefined;
|
|
33
33
|
}>;
|
|
34
34
|
result: ObjectSchema<TokenPayload<import("type-fest").EmptyObject>>;
|
|
35
35
|
credentials: true;
|
|
@@ -42,7 +42,7 @@ export declare const authenticationApiDefinition: {
|
|
|
42
42
|
method: "POST";
|
|
43
43
|
parameters: ObjectSchema<{
|
|
44
44
|
readonly subject: string;
|
|
45
|
-
readonly data:
|
|
45
|
+
readonly data: undefined;
|
|
46
46
|
}>;
|
|
47
47
|
result: ObjectSchema<TokenPayload<import("type-fest").EmptyObject>>;
|
|
48
48
|
credentials: true;
|
|
@@ -54,7 +54,7 @@ export declare const authenticationApiDefinition: {
|
|
|
54
54
|
resource: string;
|
|
55
55
|
method: "POST";
|
|
56
56
|
parameters: ObjectSchema<{
|
|
57
|
-
readonly data:
|
|
57
|
+
readonly data: undefined;
|
|
58
58
|
}>;
|
|
59
59
|
result: ObjectSchema<TokenPayload<import("type-fest").EmptyObject>>;
|
|
60
60
|
credentials: true;
|
|
@@ -76,7 +76,7 @@ export declare const authenticationApiDefinition: {
|
|
|
76
76
|
method: "POST";
|
|
77
77
|
parameters: ObjectSchema<{
|
|
78
78
|
readonly subject: string;
|
|
79
|
-
readonly data:
|
|
79
|
+
readonly data: undefined;
|
|
80
80
|
}>;
|
|
81
81
|
result: import("../schema/index.js").LiteralSchema<"ok">;
|
|
82
82
|
};
|
|
@@ -103,7 +103,7 @@ export declare const authenticationApiDefinition: {
|
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
|
-
export declare function getAuthenticationApiDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData extends
|
|
106
|
+
export declare function getAuthenticationApiDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData, AdditionalEndpoints extends ApiEndpointsDefinition>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, initSecretResetDataSchema: SchemaTestable<AdditionalInitSecretResetData>, resource?: string, additionalEndpoints?: AdditionalEndpoints): {
|
|
107
107
|
resource: string;
|
|
108
108
|
endpoints: {
|
|
109
109
|
getToken: {
|
|
@@ -198,7 +198,7 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload ex
|
|
|
198
198
|
};
|
|
199
199
|
};
|
|
200
200
|
};
|
|
201
|
-
export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData
|
|
201
|
+
export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, additionalInitSecretResetDataSchema: SchemaTestable<AdditionalInitSecretResetData>): {
|
|
202
202
|
getToken: {
|
|
203
203
|
resource: string;
|
|
204
204
|
method: "POST";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { defineApi } from '../api/types.js';
|
|
2
|
-
import { assign, emptyObjectSchema, explicitObject, literal, number, object,
|
|
2
|
+
import { assign, emptyObjectSchema, explicitObject, literal, never, number, object, optional, string } from '../schema/index.js';
|
|
3
3
|
import { SecretCheckResult } from './models/secret-check-result.model.js';
|
|
4
4
|
import { TokenPayloadBase } from './models/token-payload-base.model.js';
|
|
5
5
|
export const dontWaitForValidToken = Symbol('dontWaitForValidToken');
|
|
6
|
-
export const authenticationApiDefinition = getAuthenticationApiDefinition(emptyObjectSchema,
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
6
|
+
export const authenticationApiDefinition = getAuthenticationApiDefinition(emptyObjectSchema, optional(never()), optional(never()));
|
|
8
7
|
export function getAuthenticationApiDefinition(additionalTokenPayloadSchema, authenticationDataSchema, initSecretResetDataSchema, resource, additionalEndpoints) {
|
|
9
8
|
return defineApi({
|
|
10
9
|
resource: resource ?? 'auth',
|
|
@@ -14,7 +13,6 @@ export function getAuthenticationApiDefinition(additionalTokenPayloadSchema, aut
|
|
|
14
13
|
}
|
|
15
14
|
});
|
|
16
15
|
}
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
18
16
|
export function getAuthenticationApiEndpointsDefinition(additionalTokenPayloadSchema, authenticationDataSchema, additionalInitSecretResetDataSchema) {
|
|
19
17
|
const tokenResultSchema = assign(TokenPayloadBase, additionalTokenPayloadSchema);
|
|
20
18
|
return {
|
package/formats.d.ts
CHANGED
|
@@ -26,17 +26,23 @@ export declare function formatDate(dateOrTimestamp: number | Date): string;
|
|
|
26
26
|
export declare function formatNumericDate(numericDate: number): string;
|
|
27
27
|
export declare function formatEuro(value: number): string;
|
|
28
28
|
export declare function formatPercent(value: number): string;
|
|
29
|
-
export type
|
|
29
|
+
export type FormatPersonNameOptions<F = unknown> = {
|
|
30
30
|
lastNameFirst?: boolean;
|
|
31
|
-
|
|
31
|
+
fallback?: F;
|
|
32
32
|
};
|
|
33
|
-
export declare function
|
|
34
|
-
firstName
|
|
35
|
-
lastName
|
|
36
|
-
} | null | undefined, options:
|
|
37
|
-
|
|
38
|
-
}): string |
|
|
39
|
-
export declare function
|
|
40
|
-
firstName
|
|
41
|
-
lastName
|
|
42
|
-
} | null | undefined, options?:
|
|
33
|
+
export declare function formatPersonName<F>(person: {
|
|
34
|
+
firstName?: string | null;
|
|
35
|
+
lastName?: string | null;
|
|
36
|
+
} | null | undefined, options: FormatPersonNameOptions<F> & {
|
|
37
|
+
fallback: F;
|
|
38
|
+
}): string | F;
|
|
39
|
+
export declare function formatPersonName(person: {
|
|
40
|
+
firstName?: string | null;
|
|
41
|
+
lastName?: string | null;
|
|
42
|
+
} | null | undefined, options?: FormatPersonNameOptions & {
|
|
43
|
+
fallback?: undefined;
|
|
44
|
+
}): string;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use {@link formatPersonName} instead
|
|
47
|
+
*/
|
|
48
|
+
export declare const formatUserName: typeof formatPersonName;
|
package/formats.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { numericDateToTimestamp } from './utils/date-time.js';
|
|
2
2
|
import { memoize, memoizeSingle } from './utils/function/memoize.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isNullOrUndefined, isUndefined } from './utils/type-guards.js';
|
|
4
4
|
export let locale = 'de-DE';
|
|
5
5
|
export function configureFormats(options) {
|
|
6
6
|
locale = options.locale ?? locale;
|
|
@@ -120,18 +120,19 @@ export function formatEuro(value) {
|
|
|
120
120
|
export function formatPercent(value) {
|
|
121
121
|
return percentFormatter(locale).format(value);
|
|
122
122
|
}
|
|
123
|
-
export function
|
|
124
|
-
if (isNullOrUndefined(
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
if (isNull(user.lastName)) {
|
|
128
|
-
return user.firstName;
|
|
123
|
+
export function formatPersonName(person, { lastNameFirst = false, fallback = '-' } = {}) {
|
|
124
|
+
if (isNullOrUndefined(person?.firstName) || isNullOrUndefined(person.lastName)) {
|
|
125
|
+
return person?.firstName ?? person?.lastName ?? fallback;
|
|
129
126
|
}
|
|
130
127
|
if (lastNameFirst) {
|
|
131
|
-
return `${
|
|
128
|
+
return `${person.lastName}, ${person.firstName}`;
|
|
132
129
|
}
|
|
133
|
-
return `${
|
|
130
|
+
return `${person.firstName} ${person.lastName}`;
|
|
134
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated use {@link formatPersonName} instead
|
|
134
|
+
*/
|
|
135
|
+
export const formatUserName = formatPersonName;
|
|
135
136
|
function _getDecimalFormatter(minimumFractionDigits = 2, maximumFractionDigits = 2) {
|
|
136
137
|
return Intl.NumberFormat(locale, {
|
|
137
138
|
useGrouping: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.119",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"./utils/string": "./utils/string/index.js"
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@google-cloud/storage": "^7.
|
|
134
|
+
"@google-cloud/storage": "^7.16",
|
|
135
135
|
"@google-cloud/vertexai": "^1.9",
|
|
136
136
|
"disposablestack": "^1.1",
|
|
137
137
|
"luxon": "^3.6",
|
|
@@ -145,13 +145,13 @@
|
|
|
145
145
|
"@stylistic/eslint-plugin": "4.2",
|
|
146
146
|
"@types/chroma-js": "2.4",
|
|
147
147
|
"@types/koa__router": "12.0",
|
|
148
|
-
"@types/luxon": "3.
|
|
148
|
+
"@types/luxon": "3.6",
|
|
149
149
|
"@types/minio": "7.1",
|
|
150
150
|
"@types/mjml": "4.7",
|
|
151
151
|
"@types/node": "22",
|
|
152
152
|
"@types/nodemailer": "6.4",
|
|
153
153
|
"@types/pg": "8.11",
|
|
154
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
154
|
+
"@typescript-eslint/eslint-plugin": "8.29",
|
|
155
155
|
"concurrently": "9.1",
|
|
156
156
|
"drizzle-kit": "0.30",
|
|
157
157
|
"eslint": "9.23",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"playwright": "^1.51",
|
|
179
179
|
"preact": "^10.26",
|
|
180
180
|
"preact-render-to-string": "^6.5",
|
|
181
|
-
"undici": "^7.
|
|
181
|
+
"undici": "^7.7",
|
|
182
182
|
"urlpattern-polyfill": "^10.0"
|
|
183
183
|
},
|
|
184
184
|
"peerDependenciesMeta": {
|