@aidc-toolkit/app-extension 1.0.49 → 1.0.50-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/app-extension-options.d.ts +52 -0
- package/dist/app-extension-options.d.ts.map +1 -0
- package/dist/app-extension-options.js +2 -0
- package/dist/app-extension-options.js.map +1 -0
- package/dist/app-extension.d.ts +194 -0
- package/dist/app-extension.d.ts.map +1 -0
- package/dist/app-extension.js +141 -0
- package/dist/app-extension.js.map +1 -0
- package/dist/app-helper-proxy.d.ts +57 -0
- package/dist/app-helper-proxy.d.ts.map +1 -0
- package/dist/app-helper-proxy.js +369 -0
- package/dist/app-helper-proxy.js.map +1 -0
- package/dist/{descriptor-D6tZH-vc.d.cts → descriptor.d.ts} +13 -13
- package/dist/descriptor.d.ts.map +1 -0
- package/dist/descriptor.js +44 -0
- package/dist/descriptor.js.map +1 -0
- package/dist/generator/functions-generator.d.ts +103 -0
- package/dist/generator/functions-generator.d.ts.map +1 -0
- package/dist/generator/functions-generator.js +179 -0
- package/dist/generator/functions-generator.js.map +1 -0
- package/dist/generator/generator.d.ts +121 -0
- package/dist/generator/generator.d.ts.map +1 -0
- package/dist/generator/generator.js +186 -0
- package/dist/generator/generator.js.map +1 -0
- package/dist/generator/index.d.ts +18 -239
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +3 -1
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/locale-resources-generator.d.ts +2 -0
- package/dist/generator/locale-resources-generator.d.ts.map +1 -0
- package/dist/generator/locale-resources-generator.js +333 -0
- package/dist/generator/locale-resources-generator.js.map +1 -0
- package/dist/gs1/character-set-proxy.d.ts +12 -0
- package/dist/gs1/character-set-proxy.d.ts.map +1 -0
- package/dist/gs1/character-set-proxy.js +126 -0
- package/dist/gs1/character-set-proxy.js.map +1 -0
- package/dist/gs1/check-proxy.d.ts +11 -0
- package/dist/gs1/check-proxy.d.ts.map +1 -0
- package/dist/gs1/check-proxy.js +163 -0
- package/dist/gs1/check-proxy.js.map +1 -0
- package/dist/gs1/gcp-length-proxy.d.ts +11 -0
- package/dist/gs1/gcp-length-proxy.d.ts.map +1 -0
- package/dist/gs1/gcp-length-proxy.js +187 -0
- package/dist/gs1/gcp-length-proxy.js.map +1 -0
- package/dist/gs1/gtin-creator-proxy.d.ts +10 -0
- package/dist/gs1/gtin-creator-proxy.d.ts.map +1 -0
- package/dist/gs1/gtin-creator-proxy.js +85 -0
- package/dist/gs1/gtin-creator-proxy.js.map +1 -0
- package/dist/gs1/gtin-descriptor.d.ts +3 -0
- package/dist/gs1/gtin-descriptor.d.ts.map +1 -0
- package/dist/gs1/gtin-descriptor.js +8 -0
- package/dist/gs1/gtin-descriptor.js.map +1 -0
- package/dist/gs1/gtin-validator-proxy.d.ts +26 -0
- package/dist/gs1/gtin-validator-proxy.d.ts.map +1 -0
- package/dist/gs1/gtin-validator-proxy.js +256 -0
- package/dist/gs1/gtin-validator-proxy.js.map +1 -0
- package/dist/gs1/identifier-creator-proxy.d.ts +30 -0
- package/dist/gs1/identifier-creator-proxy.d.ts.map +1 -0
- package/dist/gs1/identifier-creator-proxy.js +318 -0
- package/dist/gs1/identifier-creator-proxy.js.map +1 -0
- package/dist/gs1/identifier-descriptor.d.ts +4 -0
- package/dist/gs1/identifier-descriptor.d.ts.map +1 -0
- package/dist/gs1/identifier-descriptor.js +14 -0
- package/dist/gs1/identifier-descriptor.js.map +1 -0
- package/dist/gs1/identifier-type.d.ts +22 -0
- package/dist/gs1/identifier-type.d.ts.map +1 -0
- package/dist/gs1/identifier-type.js +34 -0
- package/dist/gs1/identifier-type.js.map +1 -0
- package/dist/gs1/identifier-validator-proxy.d.ts +29 -0
- package/dist/gs1/identifier-validator-proxy.d.ts.map +1 -0
- package/dist/gs1/identifier-validator-proxy.js +212 -0
- package/dist/gs1/identifier-validator-proxy.js.map +1 -0
- package/dist/gs1/index.d.ts +11 -185
- package/dist/gs1/index.d.ts.map +1 -0
- package/dist/gs1/index.js +11 -1
- package/dist/gs1/index.js.map +1 -0
- package/dist/gs1/non-gtin-creator-proxy.d.ts +37 -0
- package/dist/gs1/non-gtin-creator-proxy.d.ts.map +1 -0
- package/dist/gs1/non-gtin-creator-proxy.js +301 -0
- package/dist/gs1/non-gtin-creator-proxy.js.map +1 -0
- package/dist/gs1/non-gtin-validator-proxy.d.ts +36 -0
- package/dist/gs1/non-gtin-validator-proxy.d.ts.map +1 -0
- package/dist/gs1/non-gtin-validator-proxy.js +302 -0
- package/dist/gs1/non-gtin-validator-proxy.js.map +1 -0
- package/dist/gs1/prefix-definition-descriptor.d.ts +4 -0
- package/dist/gs1/prefix-definition-descriptor.d.ts.map +1 -0
- package/dist/gs1/prefix-definition-descriptor.js +16 -0
- package/dist/gs1/prefix-definition-descriptor.js.map +1 -0
- package/dist/gs1/prefix-manager-proxy.d.ts +8 -0
- package/dist/gs1/prefix-manager-proxy.d.ts.map +1 -0
- package/dist/gs1/prefix-manager-proxy.js +94 -0
- package/dist/gs1/prefix-manager-proxy.js.map +1 -0
- package/dist/gs1/variable-measure-proxy.d.ts +7 -0
- package/dist/gs1/variable-measure-proxy.d.ts.map +1 -0
- package/dist/gs1/variable-measure-proxy.js +114 -0
- package/dist/gs1/variable-measure-proxy.js.map +1 -0
- package/dist/gs1/verified-by-gs1-proxy.d.ts +7 -0
- package/dist/gs1/verified-by-gs1-proxy.d.ts.map +1 -0
- package/dist/gs1/verified-by-gs1-proxy.js +100 -0
- package/dist/gs1/verified-by-gs1-proxy.js.map +1 -0
- package/dist/index.d.ts +22 -862
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -0
- package/dist/lib-proxy.d.ts +121 -0
- package/dist/lib-proxy.d.ts.map +1 -0
- package/dist/lib-proxy.js +259 -0
- package/dist/lib-proxy.js.map +1 -0
- package/dist/{index.d.cts → locale/en/locale-resources.d.ts} +2 -113
- package/dist/locale/en/locale-resources.d.ts.map +1 -0
- package/dist/locale/en/locale-resources.js +754 -0
- package/dist/locale/en/locale-resources.js.map +1 -0
- package/dist/locale/fr/locale-resources.d.ts +755 -0
- package/dist/locale/fr/locale-resources.d.ts.map +1 -0
- package/dist/locale/fr/locale-resources.js +754 -0
- package/dist/locale/fr/locale-resources.js.map +1 -0
- package/dist/locale/i18n.d.ts +27 -0
- package/dist/locale/i18n.d.ts.map +1 -0
- package/dist/locale/i18n.js +36 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/proxy.d.ts +135 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +291 -0
- package/dist/proxy.js.map +1 -0
- package/dist/streaming.d.ts +10 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +2 -0
- package/dist/streaming.js.map +1 -0
- package/dist/type.d.ts +72 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -0
- package/dist/utility/character-set-descriptor.d.ts +6 -0
- package/dist/utility/character-set-descriptor.d.ts.map +1 -0
- package/dist/utility/character-set-descriptor.js +28 -0
- package/dist/utility/character-set-descriptor.js.map +1 -0
- package/dist/utility/character-set-proxy.d.ts +32 -0
- package/dist/utility/character-set-proxy.d.ts.map +1 -0
- package/dist/utility/character-set-proxy.js +278 -0
- package/dist/utility/character-set-proxy.js.map +1 -0
- package/dist/utility/index.d.ts +4 -0
- package/dist/utility/index.d.ts.map +1 -0
- package/dist/utility/index.js +4 -0
- package/dist/utility/index.js.map +1 -0
- package/dist/utility/reg-exp-proxy.d.ts +8 -0
- package/dist/utility/reg-exp-proxy.d.ts.map +1 -0
- package/dist/utility/reg-exp-proxy.js +103 -0
- package/dist/utility/reg-exp-proxy.js.map +1 -0
- package/dist/utility/string-descriptor.d.ts +4 -0
- package/dist/utility/string-descriptor.d.ts.map +1 -0
- package/dist/utility/string-descriptor.js +12 -0
- package/dist/utility/string-descriptor.js.map +1 -0
- package/dist/utility/string-proxy.d.ts +7 -0
- package/dist/utility/string-proxy.d.ts.map +1 -0
- package/dist/utility/string-proxy.js +63 -0
- package/dist/utility/string-proxy.js.map +1 -0
- package/dist/utility/transformer-descriptor.d.ts +6 -0
- package/dist/utility/transformer-descriptor.d.ts.map +1 -0
- package/dist/utility/transformer-descriptor.js +24 -0
- package/dist/utility/transformer-descriptor.js.map +1 -0
- package/dist/utility/transformer-proxy.d.ts +10 -0
- package/dist/utility/transformer-proxy.d.ts.map +1 -0
- package/dist/utility/transformer-proxy.js +111 -0
- package/dist/utility/transformer-proxy.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +5 -5
- package/src/app-extension-options.ts +61 -0
- package/src/app-extension.ts +22 -32
- package/src/app-helper-proxy.ts +21 -33
- package/src/generator/functions-generator.ts +14 -45
- package/src/generator/generator.ts +28 -18
- package/src/generator/locale-resources-generator.ts +79 -52
- package/src/gs1/character-set-proxy.ts +6 -7
- package/src/gs1/check-proxy.ts +8 -8
- package/src/gs1/gcp-length-proxy.ts +8 -8
- package/src/gs1/gtin-creator-proxy.ts +4 -4
- package/src/gs1/gtin-validator-proxy.ts +12 -12
- package/src/gs1/identifier-creator-proxy.ts +14 -14
- package/src/gs1/identifier-validator-proxy.ts +10 -10
- package/src/gs1/non-gtin-creator-proxy.ts +22 -23
- package/src/gs1/non-gtin-validator-proxy.ts +22 -23
- package/src/gs1/prefix-manager-proxy.ts +2 -2
- package/src/gs1/variable-measure-proxy.ts +4 -4
- package/src/gs1/verified-by-gs1-proxy.ts +5 -11
- package/src/index.ts +1 -0
- package/src/lib-proxy.ts +27 -43
- package/src/locale/en/locale-resources.ts +1 -1
- package/src/proxy.ts +12 -15
- package/src/streaming.ts +3 -3
- package/src/type.ts +3 -22
- package/src/utility/character-set-proxy.ts +17 -16
- package/src/utility/reg-exp-proxy.ts +2 -2
- package/src/utility/string-proxy.ts +2 -2
- package/src/utility/transformer-proxy.ts +6 -5
- package/src/version.ts +1 -1
- package/tsconfig-src.tsbuildinfo +1 -1
- package/dist/character-set-proxy-BOW94WCe.d.cts +0 -473
- package/dist/character-set-proxy-BOW94WCe.d.ts +0 -473
- package/dist/chunk-22IRLVWO.js +0 -1
- package/dist/chunk-MR63TJ3B.js +0 -1
- package/dist/chunk-TWX7TPRC.js +0 -1
- package/dist/descriptor-D6tZH-vc.d.ts +0 -185
- package/dist/generator/index.cjs +0 -17
- package/dist/generator/index.d.cts +0 -240
- package/dist/gs1/index.cjs +0 -1
- package/dist/gs1/index.d.cts +0 -185
- package/dist/index.cjs +0 -17
package/src/lib-proxy.ts
CHANGED
|
@@ -1,31 +1,17 @@
|
|
|
1
1
|
import { mapIterable } from "@aidc-toolkit/utility";
|
|
2
|
+
import type { BigInteger } from "./app-extension-options.js";
|
|
2
3
|
import type { AppExtension } from "./app-extension.js";
|
|
3
4
|
import { i18nextAppExtension } from "./locale/i18n.js";
|
|
4
|
-
import type {
|
|
5
|
+
import type { Matrix, MatrixResult, SingletonResult } from "./type.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Library proxy.
|
|
8
|
-
*
|
|
9
|
-
* @template ThrowError
|
|
10
|
-
* If true, errors are reported through the throw/catch mechanism.
|
|
11
|
-
*
|
|
12
|
-
* @template TError
|
|
13
|
-
* Error type.
|
|
14
|
-
*
|
|
15
|
-
* @template TInvocationContext
|
|
16
|
-
* Application-specific invocation context type.
|
|
17
|
-
*
|
|
18
|
-
* @template TStreamingInvocationContext
|
|
19
|
-
* Application-specific streaming invocation context type.
|
|
20
|
-
*
|
|
21
|
-
* @template TBigInt
|
|
22
|
-
* Type to which big integer is mapped.
|
|
23
9
|
*/
|
|
24
|
-
export abstract class LibProxy
|
|
10
|
+
export abstract class LibProxy {
|
|
25
11
|
/**
|
|
26
12
|
* Application extension.
|
|
27
13
|
*/
|
|
28
|
-
readonly #appExtension: AppExtension
|
|
14
|
+
readonly #appExtension: AppExtension;
|
|
29
15
|
|
|
30
16
|
/**
|
|
31
17
|
* Constructor.
|
|
@@ -33,14 +19,14 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
33
19
|
* @param appExtension
|
|
34
20
|
* Application extension.
|
|
35
21
|
*/
|
|
36
|
-
constructor(appExtension: AppExtension
|
|
22
|
+
constructor(appExtension: AppExtension) {
|
|
37
23
|
this.#appExtension = appExtension;
|
|
38
24
|
}
|
|
39
25
|
|
|
40
26
|
/**
|
|
41
27
|
* Get the application extension.
|
|
42
28
|
*/
|
|
43
|
-
get appExtension(): AppExtension
|
|
29
|
+
get appExtension(): AppExtension {
|
|
44
30
|
return this.#appExtension;
|
|
45
31
|
}
|
|
46
32
|
|
|
@@ -53,7 +39,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
53
39
|
* @returns
|
|
54
40
|
* Mapped big integer value.
|
|
55
41
|
*/
|
|
56
|
-
mapBigInt(value: bigint): SingletonResult<
|
|
42
|
+
mapBigInt(value: bigint): SingletonResult<BigInteger> {
|
|
57
43
|
return this.#appExtension.mapBigInt(value);
|
|
58
44
|
}
|
|
59
45
|
|
|
@@ -67,19 +53,18 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
67
53
|
* @returns
|
|
68
54
|
* Error if errors are not thrown.
|
|
69
55
|
*/
|
|
70
|
-
#handleError<TResult>(e: unknown): SingletonResult<TResult
|
|
71
|
-
let result
|
|
56
|
+
#handleError<TResult>(e: unknown): SingletonResult<TResult> {
|
|
57
|
+
let result;
|
|
72
58
|
|
|
73
59
|
if (e instanceof RangeError) {
|
|
74
60
|
const error = this.#appExtension.mapRangeError(e);
|
|
75
61
|
|
|
76
62
|
if (this.#appExtension.throwError) {
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
78
|
-
throw error
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error -- Type is determined by application.
|
|
64
|
+
throw error;
|
|
79
65
|
}
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
result = error as SingletonResult<TResult, ThrowError, TError>;
|
|
67
|
+
result = error as SingletonResult<TResult>;
|
|
83
68
|
} else {
|
|
84
69
|
// Unknown error; pass on to application extension.
|
|
85
70
|
result = this.appExtension.handleError(e instanceof Error ? e.message : String(e));
|
|
@@ -97,13 +82,13 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
97
82
|
* @returns
|
|
98
83
|
* Callback return or error if errors are not thrown.
|
|
99
84
|
*/
|
|
100
|
-
singletonResult<TResult>(callback: () => SingletonResult<TResult
|
|
101
|
-
let result
|
|
85
|
+
singletonResult<TResult>(callback: () => SingletonResult<TResult>): SingletonResult<TResult> {
|
|
86
|
+
let result;
|
|
102
87
|
|
|
103
88
|
try {
|
|
104
89
|
result = callback();
|
|
105
90
|
} catch (e: unknown) {
|
|
106
|
-
result = this.#handleError(e);
|
|
91
|
+
result = this.#handleError<TResult>(e);
|
|
107
92
|
}
|
|
108
93
|
|
|
109
94
|
return result;
|
|
@@ -121,7 +106,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
121
106
|
* @returns
|
|
122
107
|
* Matrix of callback results and errors if errors are not thrown.
|
|
123
108
|
*/
|
|
124
|
-
protected matrixResult<TValue, TResult>(matrixValues: Matrix<TValue>, valueCallback: (value: TValue) => SingletonResult<TResult
|
|
109
|
+
protected matrixResult<TValue, TResult>(matrixValues: Matrix<TValue>, valueCallback: (value: TValue) => SingletonResult<TResult>): MatrixResult<TResult> {
|
|
125
110
|
return matrixValues.map(rowValues => rowValues.map(value => this.singletonResult(() => valueCallback(value))));
|
|
126
111
|
}
|
|
127
112
|
|
|
@@ -135,7 +120,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
135
120
|
* @returns
|
|
136
121
|
* Matrix of boolean values, true if corresponding string is empty.
|
|
137
122
|
*/
|
|
138
|
-
protected isValidString(matrixValidateResults: MatrixResult<string
|
|
123
|
+
protected isValidString(matrixValidateResults: MatrixResult<string>): Matrix<boolean> {
|
|
139
124
|
return matrixValidateResults.map(rowValues => rowValues.map(value => (validateResult => validateResult === "")(value)));
|
|
140
125
|
}
|
|
141
126
|
|
|
@@ -154,8 +139,8 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
154
139
|
* @returns
|
|
155
140
|
* Matrix of callback results and errors if errors are not thrown.
|
|
156
141
|
*/
|
|
157
|
-
protected setUpMatrixResult<TSetup, TValue, TResult>(setUpCallback: () => TSetup, matrixValues: Matrix<TValue>, valueCallback: (setup: TSetup, value: TValue) => SingletonResult<TResult
|
|
158
|
-
let result: MatrixResult<TResult
|
|
142
|
+
protected setUpMatrixResult<TSetup, TValue, TResult>(setUpCallback: () => TSetup, matrixValues: Matrix<TValue>, valueCallback: (setup: TSetup, value: TValue) => SingletonResult<TResult>): MatrixResult<TResult> {
|
|
143
|
+
let result: MatrixResult<TResult>;
|
|
159
144
|
|
|
160
145
|
try {
|
|
161
146
|
result = matrixValues.map(rowValues => rowValues.map(value => this.singletonResult(() => valueCallback(setUpCallback(), value))));
|
|
@@ -178,11 +163,10 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
178
163
|
* @returns
|
|
179
164
|
* Callback result or error as array if errors are not thrown.
|
|
180
165
|
*/
|
|
181
|
-
#arrayCallback<TValue, TResult>(value: TValue, callback: (value: TValue) => Array<SingletonResult<TResult
|
|
166
|
+
#arrayCallback<TValue, TResult>(value: TValue, callback: (value: TValue) => Array<SingletonResult<TResult>>): Array<SingletonResult<TResult>> {
|
|
182
167
|
const result = this.singletonResult(() => callback(value));
|
|
183
168
|
|
|
184
|
-
|
|
185
|
-
return result instanceof Array ? result : [result as SingletonResult<TResult, ThrowError, TError>];
|
|
169
|
+
return result instanceof Array ? result : [result];
|
|
186
170
|
}
|
|
187
171
|
|
|
188
172
|
/**
|
|
@@ -197,8 +181,8 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
197
181
|
* @returns
|
|
198
182
|
* Matrix of callback results and errors if errors are not thrown.
|
|
199
183
|
*/
|
|
200
|
-
protected arrayResult<TValue, TResult>(matrixValues: Matrix<TValue>, callback: (value: TValue) => Array<SingletonResult<TResult
|
|
201
|
-
let result: MatrixResult<TResult
|
|
184
|
+
protected arrayResult<TValue, TResult>(matrixValues: Matrix<TValue>, callback: (value: TValue) => Array<SingletonResult<TResult>>): MatrixResult<TResult> {
|
|
185
|
+
let result: MatrixResult<TResult>;
|
|
202
186
|
|
|
203
187
|
if (matrixValues.length === 0) {
|
|
204
188
|
// Special case; unlikely to occur.
|
|
@@ -221,7 +205,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
221
205
|
});
|
|
222
206
|
} else {
|
|
223
207
|
result = matrixValues.map((rowValue) => {
|
|
224
|
-
let arrayResult: Array<SingletonResult<TResult
|
|
208
|
+
let arrayResult: Array<SingletonResult<TResult>>;
|
|
225
209
|
|
|
226
210
|
if (rowValue.length === 0) {
|
|
227
211
|
// Special case; unlikely to occur.
|
|
@@ -254,7 +238,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
254
238
|
*/
|
|
255
239
|
protected matrixErrorResult<TValue>(matrixValues: Matrix<TValue>, callback: (value: TValue) => void): Matrix<string> {
|
|
256
240
|
return matrixValues.map(rowValues => rowValues.map((value) => {
|
|
257
|
-
let result
|
|
241
|
+
let result;
|
|
258
242
|
|
|
259
243
|
try {
|
|
260
244
|
callback(value);
|
|
@@ -287,8 +271,8 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
287
271
|
* @returns
|
|
288
272
|
* Matrix of callback results.
|
|
289
273
|
*/
|
|
290
|
-
protected iterableResult<TResult>(iterableCallback: () => Iterable<SingletonResult<TResult
|
|
291
|
-
let result: MatrixResult<TResult
|
|
274
|
+
protected iterableResult<TResult>(iterableCallback: () => Iterable<SingletonResult<TResult>>): MatrixResult<TResult> {
|
|
275
|
+
let result: MatrixResult<TResult>;
|
|
292
276
|
|
|
293
277
|
try {
|
|
294
278
|
result = Array.from(mapIterable(iterableCallback(), result => [result]));
|
|
@@ -200,7 +200,7 @@ export default {
|
|
|
200
200
|
},
|
|
201
201
|
sparse: {
|
|
202
202
|
name: "sparse",
|
|
203
|
-
description: "If true, value is mapped to a sparse sequence resistant to discovery.
|
|
203
|
+
description: "If true, value is mapped to a sparse sequence resistant to discovery."
|
|
204
204
|
},
|
|
205
205
|
serialComponent: {
|
|
206
206
|
name: "serialComponent",
|
package/src/proxy.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
type ReplacementParameterDescriptor
|
|
17
17
|
} from "./descriptor.js";
|
|
18
18
|
import { LibProxy } from "./lib-proxy.js";
|
|
19
|
-
import type { ErrorExtends } from "./type.js";
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Remaining parameters past first parameter in constructor.
|
|
@@ -38,13 +37,12 @@ type RemainingConstructorParameters<TConstructor extends TypedAbstractConstructo
|
|
|
38
37
|
* Proxy class constructor type.
|
|
39
38
|
*/
|
|
40
39
|
type ProxyClassConstructor<
|
|
41
|
-
|
|
42
|
-
T extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>,
|
|
40
|
+
T extends LibProxy,
|
|
43
41
|
IsAbstract extends boolean,
|
|
44
42
|
TConstructor extends TypedAbstractConstructor<TConstructor>
|
|
45
43
|
> = IsAbstract extends true ?
|
|
46
|
-
AbstractConstructor<[appExtension: AppExtension
|
|
47
|
-
Constructor<[appExtension: AppExtension
|
|
44
|
+
AbstractConstructor<[appExtension: AppExtension, ...args: RemainingConstructorParameters<TConstructor>], T> :
|
|
45
|
+
Constructor<[appExtension: AppExtension], T>;
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* Class decorator type. Defines the parameters passed to a class decorator function and the return type as identical to
|
|
@@ -63,11 +61,10 @@ type ProxyClassConstructor<
|
|
|
63
61
|
* Narrowed proxy class constructor type.
|
|
64
62
|
*/
|
|
65
63
|
type ClassDecorator<
|
|
66
|
-
|
|
67
|
-
T extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>,
|
|
64
|
+
T extends LibProxy,
|
|
68
65
|
IsAbstract extends boolean,
|
|
69
66
|
TConstructor extends TypedAbstractConstructor<TConstructor>,
|
|
70
|
-
TProxyClassConstructor extends ProxyClassConstructor<
|
|
67
|
+
TProxyClassConstructor extends ProxyClassConstructor<T, IsAbstract, TConstructor>
|
|
71
68
|
> = (Target: TProxyClassConstructor, context: ClassDecoratorContext<TProxyClassConstructor>) => TProxyClassConstructor;
|
|
72
69
|
|
|
73
70
|
/**
|
|
@@ -210,12 +207,11 @@ export class Proxy {
|
|
|
210
207
|
* Function with which to decorate the class.
|
|
211
208
|
*/
|
|
212
209
|
describeClass<
|
|
213
|
-
|
|
214
|
-
T extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>,
|
|
210
|
+
T extends LibProxy,
|
|
215
211
|
IsAbstract extends boolean,
|
|
216
212
|
TConstructor extends TypedAbstractConstructor<TConstructor>,
|
|
217
|
-
TProxyClassConstructor extends ProxyClassConstructor<
|
|
218
|
-
>(isAbstract: IsAbstract, decoratorClassDescriptor: DecoratorClassDescriptor = {}): ClassDecorator<
|
|
213
|
+
TProxyClassConstructor extends ProxyClassConstructor<T, IsAbstract, TConstructor>
|
|
214
|
+
>(isAbstract: IsAbstract, decoratorClassDescriptor: DecoratorClassDescriptor = {}): ClassDecorator<T, IsAbstract, TConstructor, TProxyClassConstructor> {
|
|
219
215
|
const interimClassDescriptor: InterimClassDescriptor = decoratorClassDescriptor.replacementParameterDescriptors === undefined ?
|
|
220
216
|
omit(decoratorClassDescriptor, "replacementParameterDescriptors") :
|
|
221
217
|
{
|
|
@@ -246,8 +242,9 @@ export class Proxy {
|
|
|
246
242
|
|
|
247
243
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Target is known to be of type LibProxy.
|
|
248
244
|
const targetClassType = Target as unknown as typeof LibProxy;
|
|
245
|
+
|
|
249
246
|
let baseClassType = targetClassType;
|
|
250
|
-
let baseClassDescriptor
|
|
247
|
+
let baseClassDescriptor;
|
|
251
248
|
|
|
252
249
|
do {
|
|
253
250
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Class hierarchy is known to stop at LibProxy.
|
|
@@ -311,7 +308,7 @@ export class Proxy {
|
|
|
311
308
|
const methodName = interimMethodDescriptor.name;
|
|
312
309
|
const infixBefore = interimMethodDescriptor.infixBefore;
|
|
313
310
|
|
|
314
|
-
let functionName
|
|
311
|
+
let functionName;
|
|
315
312
|
|
|
316
313
|
if (methodInfix === undefined || interimMethodDescriptor.ignoreInfix === true) {
|
|
317
314
|
// No other classes in the hierarchy or no infix required.
|
|
@@ -444,7 +441,7 @@ export class Proxy {
|
|
|
444
441
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Class has been modified to add log method.
|
|
445
442
|
const targetLogger = this as TargetLogger;
|
|
446
443
|
|
|
447
|
-
let result
|
|
444
|
+
let result;
|
|
448
445
|
|
|
449
446
|
try {
|
|
450
447
|
result = target.call(this, ...args);
|
package/src/streaming.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MatrixResult } from "./type.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Streaming consumer callback, returned by application extension implementation.
|
|
5
5
|
*/
|
|
6
|
-
export type StreamingConsumerCallback<TResult
|
|
7
|
-
(result: MatrixResult<TResult
|
|
6
|
+
export type StreamingConsumerCallback<TResult> =
|
|
7
|
+
(result: MatrixResult<TResult>) => void;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Streaming cancelled callback, passed to application extension implementation.
|
package/src/type.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Type that error type is expected to extend. If the application framework reports errors through the throw/catch
|
|
3
|
-
* mechanism, the error type is expected to extend {@linkcode Error}. Otherwise, it may extend any object type.
|
|
4
|
-
*
|
|
5
|
-
* @template ThrowError
|
|
6
|
-
* If true, errors are reported through the throw/catch mechanism.
|
|
7
|
-
*/
|
|
8
|
-
export type ErrorExtends<ThrowError extends boolean> = ThrowError extends true ? Error : object;
|
|
1
|
+
import type { ApplicationError, ThrowError } from "./app-extension-options.js";
|
|
9
2
|
|
|
10
3
|
/**
|
|
11
4
|
* Sheet.
|
|
@@ -74,14 +67,8 @@ export type Matrix<T> = T[][];
|
|
|
74
67
|
*
|
|
75
68
|
* @template TResult
|
|
76
69
|
* Result type.
|
|
77
|
-
*
|
|
78
|
-
* @template ThrowError
|
|
79
|
-
* If true, errors are reported through the throw/catch mechanism.
|
|
80
|
-
*
|
|
81
|
-
* @template TError
|
|
82
|
-
* Error type.
|
|
83
70
|
*/
|
|
84
|
-
export type SingletonResult<TResult
|
|
71
|
+
export type SingletonResult<TResult> = ThrowError extends true ? TResult : TResult | ApplicationError;
|
|
85
72
|
|
|
86
73
|
/**
|
|
87
74
|
* Function matrix return, possibly including an error return in each element. If the application extension reports
|
|
@@ -90,11 +77,5 @@ export type SingletonResult<TResult, ThrowError extends boolean, TError extends
|
|
|
90
77
|
*
|
|
91
78
|
* @template TResult
|
|
92
79
|
* Result type.
|
|
93
|
-
*
|
|
94
|
-
* @template ThrowError
|
|
95
|
-
* If true, errors are reported through the throw/catch mechanism.
|
|
96
|
-
*
|
|
97
|
-
* @template TError
|
|
98
|
-
* Error type.
|
|
99
80
|
*/
|
|
100
|
-
export type MatrixResult<TResult
|
|
81
|
+
export type MatrixResult<TResult> = Matrix<SingletonResult<TResult>>;
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
NUMERIC_CREATOR,
|
|
11
11
|
Sequence
|
|
12
12
|
} from "@aidc-toolkit/utility";
|
|
13
|
+
import type { BigInteger } from "../app-extension-options.js";
|
|
13
14
|
import type { AppExtension } from "../app-extension.js";
|
|
14
15
|
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
15
16
|
import { expandParameterDescriptor, proxy } from "../proxy.js";
|
|
16
|
-
import type {
|
|
17
|
+
import type { Matrix, MatrixResult } from "../type.js";
|
|
17
18
|
import {
|
|
18
19
|
exclusionAnyParameterDescriptor,
|
|
19
20
|
exclusionFirstZeroParameterDescriptor,
|
|
@@ -41,10 +42,10 @@ const valueForSParameterDescriptor: ExtendsParameterDescriptor = {
|
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
@proxy.describeClass(true)
|
|
44
|
-
export abstract class CharacterSetValidatorProxy
|
|
45
|
+
export abstract class CharacterSetValidatorProxy extends StringProxy {
|
|
45
46
|
readonly #characterSetValidator: CharacterSetValidator;
|
|
46
47
|
|
|
47
|
-
constructor(appExtension: AppExtension
|
|
48
|
+
constructor(appExtension: AppExtension, characterSetValidator: CharacterSetValidator) {
|
|
48
49
|
super(appExtension);
|
|
49
50
|
|
|
50
51
|
this.#characterSetValidator = characterSetValidator;
|
|
@@ -72,10 +73,10 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
@proxy.describeClass(true)
|
|
75
|
-
export abstract class CharacterSetCreatorProxy
|
|
76
|
+
export abstract class CharacterSetCreatorProxy extends CharacterSetValidatorProxy {
|
|
76
77
|
readonly #characterSetCreator: CharacterSetCreator;
|
|
77
78
|
|
|
78
|
-
constructor(appExtension: AppExtension
|
|
79
|
+
constructor(appExtension: AppExtension, characterSetCreator: CharacterSetCreator) {
|
|
79
80
|
super(appExtension, characterSetCreator);
|
|
80
81
|
|
|
81
82
|
this.#characterSetCreator = characterSetCreator;
|
|
@@ -86,7 +87,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
86
87
|
multiplicity: Multiplicities.Matrix,
|
|
87
88
|
parameterDescriptors: [lengthParameterDescriptor, valueParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
88
89
|
})
|
|
89
|
-
create(length: number, matrixValues: Matrix<number | bigint>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string
|
|
90
|
+
create(length: number, matrixValues: Matrix<number | bigint>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string> {
|
|
90
91
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
91
92
|
const tweakOrUndefined = tweak ?? undefined;
|
|
92
93
|
|
|
@@ -101,7 +102,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
101
102
|
multiplicity: Multiplicities.Array,
|
|
102
103
|
parameterDescriptors: [lengthParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
103
104
|
})
|
|
104
|
-
createSequence(length: number, startValue: number, count: number, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string
|
|
105
|
+
createSequence(length: number, startValue: number, count: number, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<string> {
|
|
105
106
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
106
107
|
const tweakOrUndefined = tweak ?? undefined;
|
|
107
108
|
|
|
@@ -117,7 +118,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
117
118
|
multiplicity: Multiplicities.Matrix,
|
|
118
119
|
parameterDescriptors: [valueForSParameterDescriptor, exclusionNoneParameterDescriptor, tweakParameterDescriptor]
|
|
119
120
|
})
|
|
120
|
-
valueFor(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<
|
|
121
|
+
valueFor(matrixSs: Matrix<string>, exclusion: Nullishable<Exclusion>, tweak: Nullishable<number | bigint>): MatrixResult<BigInteger> {
|
|
121
122
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
122
123
|
const tweakOrUndefined = tweak ?? undefined;
|
|
123
124
|
|
|
@@ -136,8 +137,8 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
136
137
|
}
|
|
137
138
|
]
|
|
138
139
|
})
|
|
139
|
-
export class NumericProxy
|
|
140
|
-
constructor(appExtension: AppExtension
|
|
140
|
+
export class NumericProxy extends CharacterSetCreatorProxy {
|
|
141
|
+
constructor(appExtension: AppExtension) {
|
|
141
142
|
super(appExtension, NUMERIC_CREATOR);
|
|
142
143
|
}
|
|
143
144
|
}
|
|
@@ -151,8 +152,8 @@ export class NumericProxy<ThrowError extends boolean, TError extends ErrorExtend
|
|
|
151
152
|
}
|
|
152
153
|
]
|
|
153
154
|
})
|
|
154
|
-
export class HexadecimalProxy
|
|
155
|
-
constructor(appExtension: AppExtension
|
|
155
|
+
export class HexadecimalProxy extends CharacterSetCreatorProxy {
|
|
156
|
+
constructor(appExtension: AppExtension) {
|
|
156
157
|
super(appExtension, HEXADECIMAL_CREATOR);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
@@ -160,8 +161,8 @@ export class HexadecimalProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
160
161
|
@proxy.describeClass(false, {
|
|
161
162
|
methodInfix: "Alphabetic"
|
|
162
163
|
})
|
|
163
|
-
export class AlphabeticProxy
|
|
164
|
-
constructor(appExtension: AppExtension
|
|
164
|
+
export class AlphabeticProxy extends CharacterSetCreatorProxy {
|
|
165
|
+
constructor(appExtension: AppExtension) {
|
|
165
166
|
super(appExtension, ALPHABETIC_CREATOR);
|
|
166
167
|
}
|
|
167
168
|
}
|
|
@@ -175,8 +176,8 @@ export class AlphabeticProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
175
176
|
}
|
|
176
177
|
]
|
|
177
178
|
})
|
|
178
|
-
export class AlphanumericProxy
|
|
179
|
-
constructor(appExtension: AppExtension
|
|
179
|
+
export class AlphanumericProxy extends CharacterSetCreatorProxy {
|
|
180
|
+
constructor(appExtension: AppExtension) {
|
|
180
181
|
super(appExtension, ALPHANUMERIC_CREATOR);
|
|
181
182
|
}
|
|
182
183
|
}
|
|
@@ -2,7 +2,7 @@ import type { Nullishable } from "@aidc-toolkit/core";
|
|
|
2
2
|
import { RegExpValidator } from "@aidc-toolkit/utility";
|
|
3
3
|
import { Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
4
4
|
import { proxy } from "../proxy.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Matrix } from "../type.js";
|
|
6
6
|
import { validateSParameterDescriptor } from "./string-descriptor.js";
|
|
7
7
|
import { StringProxy } from "./string-proxy.js";
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ const errorMessageParameterDescriptor: ParameterDescriptor = {
|
|
|
23
23
|
@proxy.describeClass(false, {
|
|
24
24
|
methodInfix: "RegExp"
|
|
25
25
|
})
|
|
26
|
-
export class RegExpProxy
|
|
26
|
+
export class RegExpProxy extends StringProxy {
|
|
27
27
|
@proxy.describeMethod({
|
|
28
28
|
type: Types.String,
|
|
29
29
|
multiplicity: Multiplicities.Matrix,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { StringValidation, StringValidator } from "@aidc-toolkit/utility";
|
|
2
2
|
import { LibProxy } from "../lib-proxy.js";
|
|
3
3
|
import { proxy } from "../proxy.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Matrix } from "../type.js";
|
|
5
5
|
|
|
6
6
|
@proxy.describeClass(true, {
|
|
7
7
|
category: "string"
|
|
8
8
|
})
|
|
9
|
-
export abstract class StringProxy
|
|
9
|
+
export abstract class StringProxy extends LibProxy {
|
|
10
10
|
protected validateString<TStringValidation extends StringValidation>(validator: StringValidator<TStringValidation>, matrixSs: Matrix<string>, validation?: TStringValidation): Matrix<string> {
|
|
11
11
|
return this.matrixErrorResult(matrixSs, (s) => {
|
|
12
12
|
validator.validate(s, validation);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Nullishable } from "@aidc-toolkit/core";
|
|
2
2
|
import { mapIterable, Sequence, Transformer } from "@aidc-toolkit/utility";
|
|
3
|
+
import type { BigInteger } from "../app-extension-options.js";
|
|
3
4
|
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
4
5
|
import { LibProxy } from "../lib-proxy.js";
|
|
5
6
|
import { proxy } from "../proxy.js";
|
|
6
|
-
import type {
|
|
7
|
+
import type { Matrix, MatrixResult } from "../type.js";
|
|
7
8
|
import {
|
|
8
9
|
countParameterDescriptor,
|
|
9
10
|
startValueParameterDescriptor,
|
|
@@ -27,13 +28,13 @@ const transformedValueParameterDescriptor: ExtendsParameterDescriptor = {
|
|
|
27
28
|
category: "transformation",
|
|
28
29
|
methodInfix: "Transform"
|
|
29
30
|
})
|
|
30
|
-
export class TransformerProxy
|
|
31
|
+
export class TransformerProxy extends LibProxy {
|
|
31
32
|
@proxy.describeMethod({
|
|
32
33
|
type: Types.Number,
|
|
33
34
|
multiplicity: Multiplicities.Matrix,
|
|
34
35
|
parameterDescriptors: [domainParameterDescriptor, valueParameterDescriptor, tweakParameterDescriptor]
|
|
35
36
|
})
|
|
36
|
-
forward(domain: number | bigint, matrixValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<
|
|
37
|
+
forward(domain: number | bigint, matrixValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<BigInteger> {
|
|
37
38
|
return this.setUpMatrixResult(() =>
|
|
38
39
|
Transformer.get(domain, tweak ?? undefined),
|
|
39
40
|
matrixValues, (transformer, value) =>
|
|
@@ -47,7 +48,7 @@ export class TransformerProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
47
48
|
multiplicity: Multiplicities.Array,
|
|
48
49
|
parameterDescriptors: [domainParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, tweakParameterDescriptor]
|
|
49
50
|
})
|
|
50
|
-
forwardSequence(domain: number | bigint, startValue: number, count: number, tweak: Nullishable<number | bigint>): MatrixResult<
|
|
51
|
+
forwardSequence(domain: number | bigint, startValue: number, count: number, tweak: Nullishable<number | bigint>): MatrixResult<BigInteger> {
|
|
51
52
|
return this.iterableResult(() => {
|
|
52
53
|
this.appExtension.validateSequenceCount(count);
|
|
53
54
|
|
|
@@ -60,7 +61,7 @@ export class TransformerProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
60
61
|
multiplicity: Multiplicities.Matrix,
|
|
61
62
|
parameterDescriptors: [domainParameterDescriptor, transformedValueParameterDescriptor, tweakParameterDescriptor]
|
|
62
63
|
})
|
|
63
|
-
reverse(domain: number | bigint, matrixTransformedValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<
|
|
64
|
+
reverse(domain: number | bigint, matrixTransformedValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResult<BigInteger> {
|
|
64
65
|
return this.setUpMatrixResult(() =>
|
|
65
66
|
Transformer.get(domain, tweak ?? undefined),
|
|
66
67
|
matrixTransformedValues, (transformer, transformedValue) =>
|
package/src/version.ts
CHANGED