@aidc-toolkit/app-extension 1.0.32-beta → 1.0.33-beta
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/dist/index.cjs +1 -6528
- package/dist/index.d.cts +105 -106
- package/dist/index.d.ts +105 -106
- package/dist/index.js +1 -6508
- package/package.json +12 -12
- package/src/app-extension.ts +26 -47
- package/src/{app-utility-proxy.ts → app-helper-proxy.ts} +21 -19
- package/src/descriptor.ts +43 -2
- package/src/generator/generator.ts +116 -91
- package/src/generator/locale-resources-generator.ts +26 -14
- package/src/gs1/check-proxy.ts +12 -11
- package/src/gs1/gtin-creator-proxy.ts +2 -3
- package/src/gs1/gtin-descriptor.ts +2 -2
- package/src/gs1/gtin-validator-proxy.ts +12 -14
- package/src/gs1/identifier-creator-proxy.ts +19 -21
- package/src/gs1/identifier-descriptor.ts +3 -3
- package/src/gs1/identifier-validator-proxy.ts +15 -16
- package/src/gs1/non-gtin-creator-proxy.ts +0 -11
- package/src/gs1/non-gtin-validator-proxy.ts +0 -11
- package/src/gs1/prefix-definition-descriptor.ts +2 -2
- package/src/gs1/prefix-manager-proxy.ts +80 -120
- package/src/gs1/service-proxy.ts +6 -5
- package/src/gs1/variable-measure-proxy.ts +9 -8
- package/src/index.ts +1 -2
- package/src/locale/en/locale-resources.ts +28 -15
- package/src/locale/fr/locale-resources.ts +28 -15
- package/src/locale/i18n.ts +10 -9
- package/src/locale/i18next.d.ts +2 -0
- package/src/proxy.ts +64 -40
- package/src/utility/character-set-descriptor.ts +2 -2
- package/src/utility/character-set-proxy.ts +7 -7
- package/src/utility/reg-exp-proxy.ts +5 -5
- package/src/utility/string-descriptor.ts +2 -2
- package/src/utility/string-proxy.ts +4 -0
- package/src/utility/transformer-descriptor.ts +5 -5
- package/src/utility/transformer-proxy.ts +6 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/app-data.ts +0 -94
package/src/locale/i18n.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type I18nEnvironment,
|
|
2
|
-
import {
|
|
3
|
-
import { i18nUtilityInit
|
|
1
|
+
import { i18nCoreInit, type I18nEnvironment, i18nInit } from "@aidc-toolkit/core";
|
|
2
|
+
import { i18nGS1Init } from "@aidc-toolkit/gs1";
|
|
3
|
+
import { i18nUtilityInit } from "@aidc-toolkit/utility";
|
|
4
4
|
import i18next, { type i18n, type Resource } from "i18next";
|
|
5
5
|
import enLocaleResources from "./en/locale-resources.js";
|
|
6
6
|
import frLocaleResources from "./fr/locale-resources.js";
|
|
@@ -13,9 +13,9 @@ export const appExtensionNS = "aidct_app_extension";
|
|
|
13
13
|
export type AppExtensionLocaleResources = typeof enLocaleResources;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* App extension
|
|
16
|
+
* App extension resource bundle.
|
|
17
17
|
*/
|
|
18
|
-
export const
|
|
18
|
+
export const appExtensionResourceBundle: Resource = {
|
|
19
19
|
en: {
|
|
20
20
|
aidct_app_extension: enLocaleResources
|
|
21
21
|
},
|
|
@@ -35,9 +35,10 @@ export const i18nextAppExtension: i18n = i18next.createInstance();
|
|
|
35
35
|
*
|
|
36
36
|
* @param debug
|
|
37
37
|
* Debug setting.
|
|
38
|
+
*
|
|
39
|
+
* @returns
|
|
40
|
+
* App extension resource bundle.
|
|
38
41
|
*/
|
|
39
|
-
export async function i18nAppExtensionInit(environment: I18nEnvironment, debug = false): Promise<
|
|
40
|
-
|
|
41
|
-
await i18nGS1Init(environment, debug);
|
|
42
|
-
await i18nFinalizeInit(i18nextAppExtension, environment, debug, appExtensionNS, utilityResources, gs1Resources, appExtensionResources);
|
|
42
|
+
export async function i18nAppExtensionInit(environment: I18nEnvironment, debug = false): Promise<Resource> {
|
|
43
|
+
return i18nInit(i18nextAppExtension, environment, debug, appExtensionNS, appExtensionResourceBundle, i18nCoreInit, i18nUtilityInit, i18nGS1Init);
|
|
43
44
|
}
|
package/src/locale/i18next.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CoreLocaleResources } from "@aidc-toolkit/core";
|
|
1
2
|
import type { GS1LocaleResources } from "@aidc-toolkit/gs1";
|
|
2
3
|
import type { UtilityLocaleResources } from "@aidc-toolkit/utility";
|
|
3
4
|
import type { AppExtensionLocaleResources } from "./i18n.js";
|
|
@@ -12,6 +13,7 @@ declare module "i18next" {
|
|
|
12
13
|
interface CustomTypeOptions {
|
|
13
14
|
defaultNS: "aidct_app_extension";
|
|
14
15
|
resources: {
|
|
16
|
+
aidct_core: CoreLocaleResources;
|
|
15
17
|
aidct_utility: UtilityLocaleResources;
|
|
16
18
|
aidct_gs1: GS1LocaleResources;
|
|
17
19
|
aidct_app_extension: AppExtensionLocaleResources;
|
package/src/proxy.ts
CHANGED
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
} from "@aidc-toolkit/core";
|
|
8
8
|
import type { Logger } from "tslog";
|
|
9
9
|
import type { AppExtension } from "./app-extension.js";
|
|
10
|
-
import
|
|
11
|
-
ClassDescriptor,
|
|
12
|
-
ExtendsParameterDescriptor,
|
|
13
|
-
MethodDescriptor,
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import {
|
|
11
|
+
type ClassDescriptor,
|
|
12
|
+
type ExtendsParameterDescriptor,
|
|
13
|
+
type MethodDescriptor,
|
|
14
|
+
Multiplicities,
|
|
15
|
+
type ParameterDescriptor,
|
|
16
|
+
type ReplacementParameterDescriptor
|
|
16
17
|
} from "./descriptor.js";
|
|
17
18
|
import { LibProxy } from "./lib-proxy.js";
|
|
18
19
|
import type { ErrorExtends } from "./type.js";
|
|
@@ -94,8 +95,9 @@ interface DecoratorMethodDescriptor extends Omit<InterimMethodDescriptor, "name"
|
|
|
94
95
|
/**
|
|
95
96
|
* Subset of class descriptor used during decoration process.
|
|
96
97
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
interface InterimClassDescriptor extends Omit<ClassDescriptor, "name" | "category" | "namespaceClassName" | "objectName" | "methodDescriptors"> {
|
|
99
|
+
readonly category?: string;
|
|
100
|
+
}
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
103
|
* Subset of class descriptor used in call to decorator.
|
|
@@ -168,15 +170,20 @@ interface TargetLogger {
|
|
|
168
170
|
*/
|
|
169
171
|
export class Proxy {
|
|
170
172
|
/**
|
|
171
|
-
* Abstract class descriptors map, keyed on declaration class
|
|
173
|
+
* Abstract class descriptors map, keyed on declaration class. Abstract classes are not used directly by target
|
|
172
174
|
* applications.
|
|
173
175
|
*/
|
|
174
|
-
readonly #abstractClassDescriptorsMap = new Map<
|
|
176
|
+
readonly #abstractClassDescriptorsMap = new Map<typeof LibProxy, ClassDescriptor>();
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
|
-
* Concrete class descriptors map, keyed on declaration class
|
|
179
|
+
* Concrete class descriptors map, keyed on declaration class.
|
|
178
180
|
*/
|
|
179
|
-
readonly #concreteClassDescriptorsMap = new Map<
|
|
181
|
+
readonly #concreteClassDescriptorsMap = new Map<typeof LibProxy, ClassDescriptor>();
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Namespace class names set for duplicate detection.
|
|
185
|
+
*/
|
|
186
|
+
readonly #namespaceClassNamesSet = new Set<string>();
|
|
180
187
|
|
|
181
188
|
/**
|
|
182
189
|
* Interim object.
|
|
@@ -232,42 +239,39 @@ export class Proxy {
|
|
|
232
239
|
this.#interim = interim;
|
|
233
240
|
|
|
234
241
|
return (Target: TProxyClassConstructor, context: ClassDecoratorContext<TProxyClassConstructor>) => {
|
|
235
|
-
const
|
|
242
|
+
const className = context.name;
|
|
236
243
|
|
|
237
244
|
// Validate that class descriptor is applied within an appropriate class.
|
|
238
|
-
if (
|
|
239
|
-
throw new Error(
|
|
245
|
+
if (className === undefined) {
|
|
246
|
+
throw new Error("Class has no name");
|
|
240
247
|
}
|
|
241
248
|
|
|
242
|
-
const namespacePrefix = decoratorClassDescriptor.namespace === undefined ? "" : `${decoratorClassDescriptor.namespace}.`;
|
|
243
|
-
const namespaceClassName = `${namespacePrefix}${name}`;
|
|
244
|
-
|
|
245
249
|
const abstractClassDescriptorsMap = this.#abstractClassDescriptorsMap;
|
|
246
250
|
const concreteClassDescriptorsMap = this.#concreteClassDescriptorsMap;
|
|
247
251
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Class hierarchy is known.
|
|
253
|
-
let baseClassType: typeof LibProxy = Target as unknown as typeof LibProxy;
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Target is known to be of type LibProxy.
|
|
253
|
+
const targetClassType = Target as unknown as typeof LibProxy;
|
|
254
|
+
let baseClassType = targetClassType;
|
|
254
255
|
let baseClassDescriptor: ClassDescriptor | undefined;
|
|
255
256
|
|
|
256
257
|
do {
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Class hierarchy is known.
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Class hierarchy is known to stop at LibProxy.
|
|
258
259
|
baseClassType = Object.getPrototypeOf(baseClassType) as typeof LibProxy;
|
|
259
260
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
// Look first within the namespace and then in no namespace, in both abstract class descriptors map and concrete class descriptors map.
|
|
263
|
-
baseClassDescriptor =
|
|
264
|
-
abstractClassDescriptorsMap.get(namespaceBaseClassName) ?? abstractClassDescriptorsMap.get(baseClassType.name) ??
|
|
265
|
-
concreteClassDescriptorsMap.get(namespaceBaseClassName) ?? concreteClassDescriptorsMap.get(baseClassType.name);
|
|
261
|
+
// Look in both abstract class descriptors map and concrete class descriptors map.
|
|
262
|
+
baseClassDescriptor = abstractClassDescriptorsMap.get(baseClassType) ?? concreteClassDescriptorsMap.get(baseClassType);
|
|
266
263
|
} while (baseClassType !== LibProxy && baseClassDescriptor === undefined);
|
|
267
264
|
|
|
265
|
+
let namespace = interimClassDescriptor.namespace;
|
|
266
|
+
let category = interimClassDescriptor.category;
|
|
267
|
+
|
|
268
268
|
let interimMethodDescriptors: InterimMethodDescriptor[];
|
|
269
269
|
|
|
270
270
|
if (baseClassDescriptor !== undefined) {
|
|
271
|
+
// Inherit namespace and category from base class if not explicitly defined.
|
|
272
|
+
namespace ??= baseClassDescriptor.namespace;
|
|
273
|
+
category ??= baseClassDescriptor.category;
|
|
274
|
+
|
|
271
275
|
const baseClassMethodDescriptors = baseClassDescriptor.methodDescriptors;
|
|
272
276
|
const replaceParameterDescriptors = decoratorClassDescriptor.replacementParameterDescriptors;
|
|
273
277
|
|
|
@@ -286,6 +290,19 @@ export class Proxy {
|
|
|
286
290
|
interimMethodDescriptors = [];
|
|
287
291
|
}
|
|
288
292
|
|
|
293
|
+
const namespacePrefix = namespace === undefined ? "" : `${namespace}.`;
|
|
294
|
+
const namespaceClassName = `${namespacePrefix}${className}`;
|
|
295
|
+
|
|
296
|
+
if (this.#namespaceClassNamesSet.has(namespaceClassName)) {
|
|
297
|
+
throw new Error(`Duplicate class ${namespaceClassName}`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (category === undefined) {
|
|
301
|
+
throw new Error(`Missing category for ${namespaceClassName}`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
this.#namespaceClassNamesSet.add(namespaceClassName);
|
|
305
|
+
|
|
289
306
|
// Replace base class method descriptors with matching names or append new method descriptor.
|
|
290
307
|
for (const classInterimMethodDescriptor of interim.methodDescriptors) {
|
|
291
308
|
const existingIndex = interimMethodDescriptors.findIndex(interimMethodDescriptor => interimMethodDescriptor.name === classInterimMethodDescriptor.name);
|
|
@@ -353,14 +370,16 @@ export class Proxy {
|
|
|
353
370
|
}
|
|
354
371
|
|
|
355
372
|
const classDescriptor: ClassDescriptor = {
|
|
356
|
-
name,
|
|
357
373
|
...interimClassDescriptor,
|
|
374
|
+
name: className,
|
|
375
|
+
namespace,
|
|
376
|
+
category,
|
|
358
377
|
namespaceClassName,
|
|
359
378
|
objectName: `${objectNameGroups["namespaceFirstWord"].toLowerCase()}${objectNameGroups["namespaceRemaining"]}${objectNameGroups["className"]}`,
|
|
360
379
|
methodDescriptors
|
|
361
380
|
};
|
|
362
381
|
|
|
363
|
-
(isAbstract ? abstractClassDescriptorsMap : concreteClassDescriptorsMap).set(
|
|
382
|
+
(isAbstract ? abstractClassDescriptorsMap : concreteClassDescriptorsMap).set(targetClassType, classDescriptor);
|
|
364
383
|
|
|
365
384
|
const methodDescriptorsMap = new Map<string, MethodDescriptor>();
|
|
366
385
|
|
|
@@ -388,8 +407,8 @@ export class Proxy {
|
|
|
388
407
|
const methodDescriptor = methodDescriptorsMap.get(methodName)!;
|
|
389
408
|
|
|
390
409
|
return {
|
|
391
|
-
namespace
|
|
392
|
-
className
|
|
410
|
+
namespace,
|
|
411
|
+
className,
|
|
393
412
|
methodName,
|
|
394
413
|
functionName: methodDescriptor.functionName,
|
|
395
414
|
parameters: methodDescriptor.parameterDescriptors.map((parameterDescriptor, index) => ({
|
|
@@ -435,19 +454,24 @@ export class Proxy {
|
|
|
435
454
|
// Expand all parameter descriptors.
|
|
436
455
|
const parameterDescriptors = decoratorMethodDescriptor.parameterDescriptors.map((decoratorParameterDescriptor) => {
|
|
437
456
|
const parameterDescriptor = expandParameterDescriptor(decoratorParameterDescriptor);
|
|
457
|
+
const parameterName = parameterDescriptor.name;
|
|
438
458
|
|
|
439
459
|
if (!parameterDescriptor.isRequired) {
|
|
440
460
|
anyOptional = true;
|
|
441
461
|
} else if (anyOptional) {
|
|
442
|
-
throw new Error(`Parameter ${
|
|
462
|
+
throw new Error(`Parameter ${parameterName} descriptor of method ${name} is required but prior parameter descriptor is optional`);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if ((parameterDescriptor.multiplicity === Multiplicities.Array || parameterDescriptor.multiplicity === Multiplicities.Matrix) && decoratorMethodDescriptor.multiplicity !== Multiplicities.Matrix) {
|
|
466
|
+
throw new Error(`Parameter ${parameterName} descriptor of method ${name} is array or matrix but method descriptor is not matrix`);
|
|
443
467
|
}
|
|
444
468
|
|
|
445
469
|
return parameterDescriptor;
|
|
446
470
|
});
|
|
447
471
|
|
|
448
472
|
this.#interim.methodDescriptors.push({
|
|
449
|
-
name,
|
|
450
473
|
...decoratorMethodDescriptor,
|
|
474
|
+
name,
|
|
451
475
|
parameterDescriptors
|
|
452
476
|
});
|
|
453
477
|
|
|
@@ -489,10 +513,10 @@ export class Proxy {
|
|
|
489
513
|
}
|
|
490
514
|
|
|
491
515
|
/**
|
|
492
|
-
* Get the class descriptors
|
|
516
|
+
* Get the class descriptors.
|
|
493
517
|
*/
|
|
494
|
-
get
|
|
495
|
-
return this.#concreteClassDescriptorsMap;
|
|
518
|
+
get classDescriptors(): MapIterator<ClassDescriptor> {
|
|
519
|
+
return this.#concreteClassDescriptorsMap.values();
|
|
496
520
|
}
|
|
497
521
|
}
|
|
498
522
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
1
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
2
2
|
|
|
3
3
|
const exclusionParameterDescriptor: ParameterDescriptor = {
|
|
4
4
|
name: "exclusion",
|
|
5
5
|
type: Types.Number,
|
|
6
|
-
|
|
6
|
+
multiplicity: Multiplicities.Singleton,
|
|
7
7
|
isRequired: false
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
Sequence
|
|
12
12
|
} from "@aidc-toolkit/utility";
|
|
13
13
|
import type { AppExtension } from "../app-extension.js";
|
|
14
|
-
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
14
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
15
15
|
import { expandParameterDescriptor, proxy } from "../proxy.js";
|
|
16
16
|
import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
|
|
17
17
|
import {
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
const lengthParameterDescriptor: ParameterDescriptor = {
|
|
32
32
|
name: "length",
|
|
33
33
|
type: Types.Number,
|
|
34
|
-
|
|
34
|
+
multiplicity: Multiplicities.Singleton,
|
|
35
35
|
isRequired: true
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -52,7 +52,7 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
52
52
|
|
|
53
53
|
@proxy.describeMethod({
|
|
54
54
|
type: Types.String,
|
|
55
|
-
|
|
55
|
+
multiplicity: Multiplicities.Matrix,
|
|
56
56
|
parameterDescriptors: [validateSParameterDescriptor, exclusionNoneParameterDescriptor]
|
|
57
57
|
})
|
|
58
58
|
validate(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>): Matrix<string> {
|
|
@@ -63,7 +63,7 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
63
63
|
|
|
64
64
|
@proxy.describeMethod({
|
|
65
65
|
type: Types.Boolean,
|
|
66
|
-
|
|
66
|
+
multiplicity: Multiplicities.Matrix,
|
|
67
67
|
parameterDescriptors: [validateSParameterDescriptor, exclusionNoneParameterDescriptor]
|
|
68
68
|
})
|
|
69
69
|
isValid(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>): Matrix<boolean> {
|
|
@@ -83,7 +83,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
83
83
|
|
|
84
84
|
@proxy.describeMethod({
|
|
85
85
|
type: Types.String,
|
|
86
|
-
|
|
86
|
+
multiplicity: Multiplicities.Matrix,
|
|
87
87
|
parameterDescriptors: [lengthParameterDescriptor, valueParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
88
88
|
})
|
|
89
89
|
create(length: number, matrixValues: Matrix<number | bigint>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string, ThrowError, TError> {
|
|
@@ -98,7 +98,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
98
98
|
@proxy.describeMethod({
|
|
99
99
|
infixBefore: "Sequence",
|
|
100
100
|
type: Types.String,
|
|
101
|
-
|
|
101
|
+
multiplicity: Multiplicities.Array,
|
|
102
102
|
parameterDescriptors: [lengthParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
103
103
|
})
|
|
104
104
|
createSequence(length: number, startValue: number, count: number, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string, ThrowError, TError> {
|
|
@@ -114,7 +114,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
114
114
|
|
|
115
115
|
@proxy.describeMethod({
|
|
116
116
|
type: Types.Number,
|
|
117
|
-
|
|
117
|
+
multiplicity: Multiplicities.Matrix,
|
|
118
118
|
parameterDescriptors: [valueForSParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
119
119
|
})
|
|
120
120
|
valueFor(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Nullishable } from "@aidc-toolkit/core";
|
|
2
2
|
import { RegExpValidator } from "@aidc-toolkit/utility";
|
|
3
|
-
import { type ParameterDescriptor, Types } from "../descriptor.js";
|
|
3
|
+
import { Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
4
4
|
import { proxy } from "../proxy.js";
|
|
5
5
|
import type { ErrorExtends, Matrix } from "../type.js";
|
|
6
6
|
import { validateSParameterDescriptor } from "./string-descriptor.js";
|
|
@@ -9,14 +9,14 @@ import { StringProxy } from "./string-proxy.js";
|
|
|
9
9
|
const regExpParameterDescriptor: ParameterDescriptor = {
|
|
10
10
|
name: "regExp",
|
|
11
11
|
type: Types.String,
|
|
12
|
-
|
|
12
|
+
multiplicity: Multiplicities.Singleton,
|
|
13
13
|
isRequired: true
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const errorMessageParameterDescriptor: ParameterDescriptor = {
|
|
17
17
|
name: "errorMessage",
|
|
18
18
|
type: Types.String,
|
|
19
|
-
|
|
19
|
+
multiplicity: Multiplicities.Singleton,
|
|
20
20
|
isRequired: false
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ const errorMessageParameterDescriptor: ParameterDescriptor = {
|
|
|
26
26
|
export class RegExpProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
27
27
|
@proxy.describeMethod({
|
|
28
28
|
type: Types.String,
|
|
29
|
-
|
|
29
|
+
multiplicity: Multiplicities.Matrix,
|
|
30
30
|
parameterDescriptors: [regExpParameterDescriptor, validateSParameterDescriptor, errorMessageParameterDescriptor]
|
|
31
31
|
})
|
|
32
32
|
validate(regExp: string, matrixSs: Matrix<string>, errorMessage: Nullishable<string>): Matrix<string> {
|
|
@@ -40,7 +40,7 @@ export class RegExpProxy<ThrowError extends boolean, TError extends ErrorExtends
|
|
|
40
40
|
|
|
41
41
|
@proxy.describeMethod({
|
|
42
42
|
type: Types.Boolean,
|
|
43
|
-
|
|
43
|
+
multiplicity: Multiplicities.Matrix,
|
|
44
44
|
parameterDescriptors: [regExpParameterDescriptor, validateSParameterDescriptor]
|
|
45
45
|
})
|
|
46
46
|
isValid(regExp: string, matrixSs: Matrix<string>): Matrix<boolean> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
1
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
2
2
|
|
|
3
3
|
export const sParameterDescriptor: ParameterDescriptor = {
|
|
4
4
|
name: "s",
|
|
5
5
|
type: Types.String,
|
|
6
|
-
|
|
6
|
+
multiplicity: Multiplicities.Matrix,
|
|
7
7
|
isRequired: true
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { StringValidation, StringValidator } from "@aidc-toolkit/utility";
|
|
2
2
|
import { LibProxy } from "../lib-proxy.js";
|
|
3
|
+
import { proxy } from "../proxy.js";
|
|
3
4
|
import type { ErrorExtends, Matrix } from "../type.js";
|
|
4
5
|
|
|
6
|
+
@proxy.describeClass(true, {
|
|
7
|
+
category: "string"
|
|
8
|
+
})
|
|
5
9
|
export abstract class StringProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
6
10
|
protected validateString<TStringValidation extends StringValidation>(validator: StringValidator<TStringValidation>, matrixSs: Matrix<string>, validation?: TStringValidation): Matrix<string> {
|
|
7
11
|
return this.matrixErrorResult(matrixSs, (s) => {
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
1
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
2
2
|
|
|
3
3
|
export const valueParameterDescriptor: ParameterDescriptor = {
|
|
4
4
|
name: "value",
|
|
5
5
|
type: Types.Number,
|
|
6
|
-
|
|
6
|
+
multiplicity: Multiplicities.Matrix,
|
|
7
7
|
isRequired: true
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const startValueParameterDescriptor: ExtendsParameterDescriptor = {
|
|
11
11
|
extendsDescriptor: valueParameterDescriptor,
|
|
12
12
|
name: "startValue",
|
|
13
|
-
|
|
13
|
+
multiplicity: Multiplicities.Singleton
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const countParameterDescriptor: ExtendsParameterDescriptor = {
|
|
17
17
|
extendsDescriptor: valueParameterDescriptor,
|
|
18
18
|
name: "count",
|
|
19
|
-
|
|
19
|
+
multiplicity: Multiplicities.Singleton
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const tweakParameterDescriptor: ParameterDescriptor = {
|
|
23
23
|
name: "tweak",
|
|
24
24
|
type: Types.Number,
|
|
25
|
-
|
|
25
|
+
multiplicity: Multiplicities.Singleton,
|
|
26
26
|
isRequired: false
|
|
27
27
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Nullishable } from "@aidc-toolkit/core";
|
|
2
2
|
import { mapIterable, Sequence, Transformer } from "@aidc-toolkit/utility";
|
|
3
|
-
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
3
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
4
4
|
import { LibProxy } from "../lib-proxy.js";
|
|
5
5
|
import { proxy } from "../proxy.js";
|
|
6
6
|
import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
const domainParameterDescriptor: ParameterDescriptor = {
|
|
15
15
|
name: "domain",
|
|
16
16
|
type: Types.Number,
|
|
17
|
-
|
|
17
|
+
multiplicity: Multiplicities.Singleton,
|
|
18
18
|
isRequired: true
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -24,12 +24,13 @@ const transformedValueParameterDescriptor: ExtendsParameterDescriptor = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
@proxy.describeClass(false, {
|
|
27
|
+
category: "transformation",
|
|
27
28
|
methodInfix: "Transform"
|
|
28
29
|
})
|
|
29
30
|
export class TransformerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
30
31
|
@proxy.describeMethod({
|
|
31
32
|
type: Types.Number,
|
|
32
|
-
|
|
33
|
+
multiplicity: Multiplicities.Matrix,
|
|
33
34
|
parameterDescriptors: [domainParameterDescriptor, valueParameterDescriptor, tweakParameterDescriptor]
|
|
34
35
|
})
|
|
35
36
|
forward(domain: number | bigint, matrixValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
@@ -43,7 +44,7 @@ export class TransformerProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
43
44
|
@proxy.describeMethod({
|
|
44
45
|
infixBefore: "Sequence",
|
|
45
46
|
type: Types.Number,
|
|
46
|
-
|
|
47
|
+
multiplicity: Multiplicities.Array,
|
|
47
48
|
parameterDescriptors: [domainParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, tweakParameterDescriptor]
|
|
48
49
|
})
|
|
49
50
|
forwardSequence(domain: number | bigint, startValue: number, count: number, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
@@ -56,7 +57,7 @@ export class TransformerProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
56
57
|
|
|
57
58
|
@proxy.describeMethod({
|
|
58
59
|
type: Types.Number,
|
|
59
|
-
|
|
60
|
+
multiplicity: Multiplicities.Matrix,
|
|
60
61
|
parameterDescriptors: [domainParameterDescriptor, transformedValueParameterDescriptor, tweakParameterDescriptor]
|
|
61
62
|
})
|
|
62
63
|
reverse(domain: number | bigint, matrixTransformedValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|