@aidc-toolkit/app-extension 1.0.31-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 -3709
- package/dist/index.d.cts +607 -333
- package/dist/index.d.ts +607 -333
- package/dist/index.js +1 -3683
- package/package.json +12 -13
- package/src/app-extension.ts +141 -93
- package/src/app-helper-proxy.ts +326 -0
- package/src/descriptor.ts +75 -7
- package/src/generator/generator.ts +118 -96
- package/src/generator/locale-resources-generator.ts +56 -42
- package/src/gs1/character-set-proxy.ts +8 -8
- package/src/gs1/check-proxy.ts +26 -25
- package/src/gs1/gtin-creator-proxy.ts +14 -28
- package/src/gs1/gtin-descriptor.ts +2 -23
- package/src/gs1/gtin-validator-proxy.ts +45 -48
- package/src/gs1/identifier-creator-proxy.ts +63 -53
- package/src/gs1/identifier-descriptor.ts +15 -0
- package/src/gs1/identifier-type.ts +37 -0
- package/src/gs1/identifier-validator-proxy.ts +59 -27
- package/src/gs1/index.ts +8 -0
- package/src/gs1/non-gtin-creator-proxy.ts +22 -33
- package/src/gs1/non-gtin-validator-proxy.ts +22 -33
- package/src/gs1/prefix-definition-descriptor.ts +2 -2
- package/src/gs1/prefix-manager-proxy.ts +164 -9
- package/src/gs1/service-proxy.ts +57 -0
- package/src/gs1/variable-measure-proxy.ts +62 -0
- package/src/index.ts +6 -1
- package/src/lib-proxy.ts +112 -70
- package/src/locale/en/locale-resources.ts +173 -47
- package/src/locale/fr/locale-resources.ts +173 -47
- package/src/locale/i18n.ts +8 -10
- package/src/locale/i18next.d.ts +2 -0
- package/src/proxy.ts +140 -140
- package/src/streaming.ts +13 -0
- package/src/type.ts +8 -7
- package/src/utility/character-set-descriptor.ts +2 -2
- package/src/utility/character-set-proxy.ts +39 -38
- package/src/utility/reg-exp-proxy.ts +12 -11
- package/src/utility/string-descriptor.ts +2 -2
- package/src/utility/string-proxy.ts +7 -7
- package/src/utility/transformer-descriptor.ts +5 -5
- package/src/utility/transformer-proxy.ts +25 -18
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/app-utility-proxy.ts +0 -273
|
@@ -11,14 +11,9 @@ import {
|
|
|
11
11
|
Sequence
|
|
12
12
|
} from "@aidc-toolkit/utility";
|
|
13
13
|
import type { AppExtension } from "../app-extension.js";
|
|
14
|
-
import {
|
|
15
|
-
type ExtendsParameterDescriptor,
|
|
16
|
-
type ParameterDescriptor,
|
|
17
|
-
Types
|
|
18
|
-
} from "../descriptor.js";
|
|
19
|
-
import { LibProxy } from "../lib-proxy.js";
|
|
14
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
20
15
|
import { expandParameterDescriptor, proxy } from "../proxy.js";
|
|
21
|
-
import type { ErrorExtends, Matrix,
|
|
16
|
+
import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
|
|
22
17
|
import {
|
|
23
18
|
exclusionAnyParameterDescriptor,
|
|
24
19
|
exclusionFirstZeroParameterDescriptor,
|
|
@@ -36,7 +31,7 @@ import {
|
|
|
36
31
|
const lengthParameterDescriptor: ParameterDescriptor = {
|
|
37
32
|
name: "length",
|
|
38
33
|
type: Types.Number,
|
|
39
|
-
|
|
34
|
+
multiplicity: Multiplicities.Singleton,
|
|
40
35
|
isRequired: true
|
|
41
36
|
};
|
|
42
37
|
|
|
@@ -46,10 +41,10 @@ const valueForSParameterDescriptor: ExtendsParameterDescriptor = {
|
|
|
46
41
|
};
|
|
47
42
|
|
|
48
43
|
@proxy.describeClass(true)
|
|
49
|
-
export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
44
|
+
export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
50
45
|
readonly #characterSetValidator: CharacterSetValidator;
|
|
51
46
|
|
|
52
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, characterSetValidator: CharacterSetValidator) {
|
|
47
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>, characterSetValidator: CharacterSetValidator) {
|
|
53
48
|
super(appExtension);
|
|
54
49
|
|
|
55
50
|
this.#characterSetValidator = characterSetValidator;
|
|
@@ -57,10 +52,10 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
57
52
|
|
|
58
53
|
@proxy.describeMethod({
|
|
59
54
|
type: Types.String,
|
|
60
|
-
|
|
55
|
+
multiplicity: Multiplicities.Matrix,
|
|
61
56
|
parameterDescriptors: [validateSParameterDescriptor, exclusionNoneParameterDescriptor]
|
|
62
57
|
})
|
|
63
|
-
validate(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>):
|
|
58
|
+
validate(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>): Matrix<string> {
|
|
64
59
|
return this.validateString(this.#characterSetValidator, matrixSs, {
|
|
65
60
|
exclusion: exclusion ?? undefined
|
|
66
61
|
} satisfies CharacterSetValidation);
|
|
@@ -68,19 +63,19 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
68
63
|
|
|
69
64
|
@proxy.describeMethod({
|
|
70
65
|
type: Types.Boolean,
|
|
71
|
-
|
|
66
|
+
multiplicity: Multiplicities.Matrix,
|
|
72
67
|
parameterDescriptors: [validateSParameterDescriptor, exclusionNoneParameterDescriptor]
|
|
73
68
|
})
|
|
74
|
-
isValid(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>):
|
|
69
|
+
isValid(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>): Matrix<boolean> {
|
|
75
70
|
return this.isValidString(this.validate(matrixSs, exclusion));
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
@proxy.describeClass(true)
|
|
80
|
-
export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
75
|
+
export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends CharacterSetValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
81
76
|
readonly #characterSetCreator: CharacterSetCreator;
|
|
82
77
|
|
|
83
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, characterSetCreator: CharacterSetCreator) {
|
|
78
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>, characterSetCreator: CharacterSetCreator) {
|
|
84
79
|
super(appExtension, characterSetCreator);
|
|
85
80
|
|
|
86
81
|
this.#characterSetCreator = characterSetCreator;
|
|
@@ -88,70 +83,76 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
88
83
|
|
|
89
84
|
@proxy.describeMethod({
|
|
90
85
|
type: Types.String,
|
|
91
|
-
|
|
86
|
+
multiplicity: Multiplicities.Matrix,
|
|
92
87
|
parameterDescriptors: [lengthParameterDescriptor, valueParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
93
88
|
})
|
|
94
|
-
create(length: number, matrixValues: Matrix<number | bigint>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>):
|
|
89
|
+
create(length: number, matrixValues: Matrix<number | bigint>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string, ThrowError, TError> {
|
|
95
90
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
96
91
|
const tweakOrUndefined = tweak ?? undefined;
|
|
97
92
|
|
|
98
|
-
return this.
|
|
93
|
+
return this.matrixResult(matrixValues, value =>
|
|
94
|
+
this.#characterSetCreator.create(length, value, exclusionOrUndefined, tweakOrUndefined)
|
|
95
|
+
);
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
@proxy.describeMethod({
|
|
102
99
|
infixBefore: "Sequence",
|
|
103
100
|
type: Types.String,
|
|
104
|
-
|
|
101
|
+
multiplicity: Multiplicities.Array,
|
|
105
102
|
parameterDescriptors: [lengthParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
106
103
|
})
|
|
107
|
-
createSequence(length: number, startValue: number, count: number, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>):
|
|
108
|
-
this.appExtension.validateSequenceCount(count);
|
|
109
|
-
|
|
104
|
+
createSequence(length: number, startValue: number, count: number, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string, ThrowError, TError> {
|
|
110
105
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
111
106
|
const tweakOrUndefined = tweak ?? undefined;
|
|
112
107
|
|
|
113
|
-
return
|
|
108
|
+
return this.iterableResult(() => {
|
|
109
|
+
this.appExtension.validateSequenceCount(count);
|
|
110
|
+
|
|
111
|
+
return this.#characterSetCreator.create(length, new Sequence(startValue, count), exclusionOrUndefined, tweakOrUndefined);
|
|
112
|
+
});
|
|
114
113
|
}
|
|
115
114
|
|
|
116
115
|
@proxy.describeMethod({
|
|
117
116
|
type: Types.Number,
|
|
118
|
-
|
|
117
|
+
multiplicity: Multiplicities.Matrix,
|
|
119
118
|
parameterDescriptors: [valueForSParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
120
119
|
})
|
|
121
|
-
valueFor(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>):
|
|
120
|
+
valueFor(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
122
121
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
123
122
|
const tweakOrUndefined = tweak ?? undefined;
|
|
124
123
|
|
|
125
|
-
return this.
|
|
124
|
+
return this.matrixResult(matrixSs, s =>
|
|
125
|
+
this.mapBigInt(this.#characterSetCreator.valueFor(s, exclusionOrUndefined, tweakOrUndefined))
|
|
126
|
+
);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
@proxy.describeClass(false, {
|
|
130
131
|
methodInfix: "Numeric",
|
|
131
|
-
|
|
132
|
+
replacementParameterDescriptors: [
|
|
132
133
|
{
|
|
133
134
|
name: expandParameterDescriptor(exclusionNoneParameterDescriptor).name,
|
|
134
135
|
replacement: exclusionFirstZeroParameterDescriptor
|
|
135
136
|
}
|
|
136
137
|
]
|
|
137
138
|
})
|
|
138
|
-
export class NumericProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
139
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
139
|
+
export class NumericProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
140
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
140
141
|
super(appExtension, NUMERIC_CREATOR);
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
@proxy.describeClass(false, {
|
|
145
146
|
methodInfix: "Hexadecimal",
|
|
146
|
-
|
|
147
|
+
replacementParameterDescriptors: [
|
|
147
148
|
{
|
|
148
149
|
name: expandParameterDescriptor(exclusionNoneParameterDescriptor).name,
|
|
149
150
|
replacement: exclusionAnyParameterDescriptor
|
|
150
151
|
}
|
|
151
152
|
]
|
|
152
153
|
})
|
|
153
|
-
export class HexadecimalProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
154
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
154
|
+
export class HexadecimalProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
155
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
155
156
|
super(appExtension, HEXADECIMAL_CREATOR);
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -159,23 +160,23 @@ export class HexadecimalProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
159
160
|
@proxy.describeClass(false, {
|
|
160
161
|
methodInfix: "Alphabetic"
|
|
161
162
|
})
|
|
162
|
-
export class AlphabeticProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
163
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
163
|
+
export class AlphabeticProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
164
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
164
165
|
super(appExtension, ALPHABETIC_CREATOR);
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
@proxy.describeClass(false, {
|
|
169
170
|
methodInfix: "Alphanumeric",
|
|
170
|
-
|
|
171
|
+
replacementParameterDescriptors: [
|
|
171
172
|
{
|
|
172
173
|
name: expandParameterDescriptor(exclusionNoneParameterDescriptor).name,
|
|
173
174
|
replacement: exclusionAnyParameterDescriptor
|
|
174
175
|
}
|
|
175
176
|
]
|
|
176
177
|
})
|
|
177
|
-
export class AlphanumericProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
178
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
178
|
+
export class AlphanumericProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
179
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
179
180
|
super(appExtension, ALPHANUMERIC_CREATOR);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
@@ -1,48 +1,49 @@
|
|
|
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
|
-
import type { ErrorExtends, Matrix
|
|
5
|
+
import type { ErrorExtends, Matrix } from "../type.js";
|
|
6
6
|
import { validateSParameterDescriptor } from "./string-descriptor.js";
|
|
7
7
|
import { StringProxy } from "./string-proxy.js";
|
|
8
8
|
|
|
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
|
|
|
23
23
|
@proxy.describeClass(false, {
|
|
24
24
|
methodInfix: "RegExp"
|
|
25
25
|
})
|
|
26
|
-
export class RegExpProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
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
|
-
validate(regExp: string, matrixSs: Matrix<string>, errorMessage: Nullishable<string>):
|
|
32
|
+
validate(regExp: string, matrixSs: Matrix<string>, errorMessage: Nullishable<string>): Matrix<string> {
|
|
33
33
|
return this.validateString(new class extends RegExpValidator {
|
|
34
34
|
protected override createErrorMessage(s: string): string {
|
|
35
|
-
|
|
35
|
+
// Replace {{s}} with the invalid string.
|
|
36
|
+
return errorMessage?.replace(/\{\{s\}\}/ug, s) ?? super.createErrorMessage(s);
|
|
36
37
|
}
|
|
37
|
-
}(new RegExp(regExp)), matrixSs);
|
|
38
|
+
}(new RegExp(regExp, "u")), matrixSs);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
@proxy.describeMethod({
|
|
41
42
|
type: Types.Boolean,
|
|
42
|
-
|
|
43
|
+
multiplicity: Multiplicities.Matrix,
|
|
43
44
|
parameterDescriptors: [regExpParameterDescriptor, validateSParameterDescriptor]
|
|
44
45
|
})
|
|
45
|
-
isValid(regExp: string, matrixSs: Matrix<string>):
|
|
46
|
+
isValid(regExp: string, matrixSs: Matrix<string>): Matrix<boolean> {
|
|
46
47
|
return this.isValidString(this.validate(regExp, matrixSs, undefined));
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -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,15 +1,15 @@
|
|
|
1
1
|
import type { StringValidation, StringValidator } from "@aidc-toolkit/utility";
|
|
2
2
|
import { LibProxy } from "../lib-proxy.js";
|
|
3
|
-
import
|
|
3
|
+
import { proxy } from "../proxy.js";
|
|
4
|
+
import type { ErrorExtends, Matrix } from "../type.js";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
@proxy.describeClass(true, {
|
|
7
|
+
category: "string"
|
|
8
|
+
})
|
|
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
|
-
return
|
|
11
|
+
return this.matrixErrorResult(matrixSs, (s) => {
|
|
8
12
|
validator.validate(s, validation);
|
|
9
13
|
});
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
protected isValidString(matrixValidateResults: MatrixResultError<string, ThrowError, TError>): MatrixResultError<boolean, ThrowError, TError> {
|
|
13
|
-
return this.mapMatrix(matrixValidateResults, validateResult => validateResult === "");
|
|
14
|
-
}
|
|
15
15
|
}
|
|
@@ -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,9 +1,9 @@
|
|
|
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
|
-
import type { ErrorExtends, Matrix,
|
|
6
|
+
import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
|
|
7
7
|
import {
|
|
8
8
|
countParameterDescriptor,
|
|
9
9
|
startValueParameterDescriptor,
|
|
@@ -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,40 +24,47 @@ const transformedValueParameterDescriptor: ExtendsParameterDescriptor = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
@proxy.describeClass(false, {
|
|
27
|
+
category: "transformation",
|
|
27
28
|
methodInfix: "Transform"
|
|
28
29
|
})
|
|
29
|
-
export class TransformerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
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
|
-
forward(domain: number | bigint, matrixValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>):
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
forward(domain: number | bigint, matrixValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
37
|
+
return this.setUpMatrixResult(() =>
|
|
38
|
+
Transformer.get(domain, tweak ?? undefined),
|
|
39
|
+
matrixValues, (transformer, value) =>
|
|
40
|
+
this.mapBigInt(transformer.forward(value))
|
|
41
|
+
);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
@proxy.describeMethod({
|
|
42
45
|
infixBefore: "Sequence",
|
|
43
46
|
type: Types.Number,
|
|
44
|
-
|
|
47
|
+
multiplicity: Multiplicities.Array,
|
|
45
48
|
parameterDescriptors: [domainParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, tweakParameterDescriptor]
|
|
46
49
|
})
|
|
47
|
-
forwardSequence(domain: number | bigint, startValue: number, count: number, tweak: Nullishable<number | bigint>):
|
|
48
|
-
this.
|
|
50
|
+
forwardSequence(domain: number | bigint, startValue: number, count: number, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
51
|
+
return this.iterableResult(() => {
|
|
52
|
+
this.appExtension.validateSequenceCount(count);
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
return mapIterable(Transformer.get(domain, tweak ?? undefined).forward(new Sequence(startValue, count)), value => this.mapBigInt(value));
|
|
55
|
+
});
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
@proxy.describeMethod({
|
|
54
59
|
type: Types.Number,
|
|
55
|
-
|
|
60
|
+
multiplicity: Multiplicities.Matrix,
|
|
56
61
|
parameterDescriptors: [domainParameterDescriptor, transformedValueParameterDescriptor, tweakParameterDescriptor]
|
|
57
62
|
})
|
|
58
|
-
reverse(domain: number | bigint, matrixTransformedValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>):
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
reverse(domain: number | bigint, matrixTransformedValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<TBigInt, ThrowError, TError> {
|
|
64
|
+
return this.setUpMatrixResult(() =>
|
|
65
|
+
Transformer.get(domain, tweak ?? undefined),
|
|
66
|
+
matrixTransformedValues, (transformer, transformedValue) =>
|
|
67
|
+
this.mapBigInt(transformer.reverse(transformedValue))
|
|
68
|
+
);
|
|
62
69
|
}
|
|
63
70
|
}
|