@aidc-toolkit/app-extension 0.9.19-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/LICENSE +174 -0
- package/README.md +17 -0
- package/app-extension.iml +9 -0
- package/dist/app-extension.d.ts +169 -0
- package/dist/app-extension.d.ts.map +1 -0
- package/dist/app-extension.js +148 -0
- package/dist/app-extension.js.map +1 -0
- package/dist/app-utility-proxy.d.ts +66 -0
- package/dist/app-utility-proxy.d.ts.map +1 -0
- package/dist/app-utility-proxy.js +233 -0
- package/dist/app-utility-proxy.js.map +1 -0
- package/dist/descriptor.d.ts +168 -0
- package/dist/descriptor.d.ts.map +1 -0
- package/dist/descriptor.js +175 -0
- package/dist/descriptor.js.map +1 -0
- package/dist/gs1/character-set-proxy.d.ts +10 -0
- package/dist/gs1/character-set-proxy.d.ts.map +1 -0
- package/dist/gs1/character-set-proxy.js +47 -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 +120 -0
- package/dist/gs1/check-proxy.js.map +1 -0
- package/dist/gs1/idkey-proxy.d.ts +135 -0
- package/dist/gs1/idkey-proxy.d.ts.map +1 -0
- package/dist/gs1/idkey-proxy.js +779 -0
- package/dist/gs1/idkey-proxy.js.map +1 -0
- package/dist/gs1/index.d.ts +4 -0
- package/dist/gs1/index.d.ts.map +1 -0
- package/dist/gs1/index.js +4 -0
- package/dist/gs1/index.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/lib-proxy.d.ts +135 -0
- package/dist/lib-proxy.d.ts.map +1 -0
- package/dist/lib-proxy.js +235 -0
- package/dist/lib-proxy.js.map +1 -0
- package/dist/locale/en/locale-strings.d.ts +616 -0
- package/dist/locale/en/locale-strings.d.ts.map +1 -0
- package/dist/locale/en/locale-strings.js +616 -0
- package/dist/locale/en/locale-strings.js.map +1 -0
- package/dist/locale/fr/locale-strings.d.ts +616 -0
- package/dist/locale/fr/locale-strings.d.ts.map +1 -0
- package/dist/locale/fr/locale-strings.js +616 -0
- package/dist/locale/fr/locale-strings.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 +39 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.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 +26 -0
- package/dist/utility/character-set-proxy.d.ts.map +1 -0
- package/dist/utility/character-set-proxy.js +167 -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 +7 -0
- package/dist/utility/reg-exp-proxy.d.ts.map +1 -0
- package/dist/utility/reg-exp-proxy.js +61 -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 +8 -0
- package/dist/utility/string-proxy.d.ts.map +1 -0
- package/dist/utility/string-proxy.js +12 -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 +8 -0
- package/dist/utility/transformer-proxy.d.ts.map +1 -0
- package/dist/utility/transformer-proxy.js +74 -0
- package/dist/utility/transformer-proxy.js.map +1 -0
- package/eslint.config.ts +21 -0
- package/package.json +37 -0
- package/src/app-extension.ts +244 -0
- package/src/app-utility-proxy.ts +266 -0
- package/src/descriptor.ts +314 -0
- package/src/gs1/character-set-proxy.ts +41 -0
- package/src/gs1/check-proxy.ts +122 -0
- package/src/gs1/idkey-proxy.ts +815 -0
- package/src/gs1/index.ts +3 -0
- package/src/index.ts +24 -0
- package/src/lib-proxy.ts +256 -0
- package/src/locale/en/locale-strings.ts +615 -0
- package/src/locale/fr/locale-strings.ts +615 -0
- package/src/locale/i18n.ts +48 -0
- package/src/locale/i18next.d.ts +20 -0
- package/src/types.ts +144 -0
- package/src/utility/character-set-descriptor.ts +32 -0
- package/src/utility/character-set-proxy.ts +185 -0
- package/src/utility/index.ts +3 -0
- package/src/utility/reg-exp-proxy.ts +51 -0
- package/src/utility/string-descriptor.ts +13 -0
- package/src/utility/string-proxy.ts +15 -0
- package/src/utility/transformer-descriptor.ts +27 -0
- package/src/utility/transformer-proxy.ts +72 -0
- package/tsconfig.json +6 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
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 {@link 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;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sheet.
|
|
12
|
+
*/
|
|
13
|
+
export interface Sheet {
|
|
14
|
+
/**
|
|
15
|
+
* Sheet name.
|
|
16
|
+
*/
|
|
17
|
+
readonly name: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Single cell address.
|
|
22
|
+
*/
|
|
23
|
+
export interface Address {
|
|
24
|
+
/**
|
|
25
|
+
* Zero-indexed row.
|
|
26
|
+
*/
|
|
27
|
+
readonly rowIndex: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Zero-indexed column.
|
|
31
|
+
*/
|
|
32
|
+
readonly columnIndex: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sheet address.
|
|
37
|
+
*/
|
|
38
|
+
export interface SheetAddress extends Sheet, Address {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Range of cells.
|
|
43
|
+
*/
|
|
44
|
+
export interface Range {
|
|
45
|
+
/**
|
|
46
|
+
* Start address, inclusive.
|
|
47
|
+
*/
|
|
48
|
+
readonly startAddress: Address;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* End address, exclusive.
|
|
52
|
+
*/
|
|
53
|
+
readonly endAddress: Address;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Sheet range.
|
|
58
|
+
*/
|
|
59
|
+
export interface SheetRange extends Sheet, Range {
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Matrix type; shorthand for defining a two-dimensional matrix (array of array) of a type.
|
|
64
|
+
*
|
|
65
|
+
* @template T
|
|
66
|
+
* Type.
|
|
67
|
+
*/
|
|
68
|
+
export type Matrix<T> = T[][];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Function result, possibly including an error result. If the application framework reports errors through the return
|
|
72
|
+
* value, the result is the union of the result type and the error type; otherwise, it's just the result type.
|
|
73
|
+
*
|
|
74
|
+
* @template TResult
|
|
75
|
+
* Result type.
|
|
76
|
+
*
|
|
77
|
+
* @template ThrowError
|
|
78
|
+
* If true, errors are reported through the throw/catch mechanism.
|
|
79
|
+
*
|
|
80
|
+
* @template TError
|
|
81
|
+
* Error type.
|
|
82
|
+
*/
|
|
83
|
+
export type ResultError<TResult, ThrowError extends boolean, TError extends ErrorExtends<ThrowError>> = ThrowError extends false ? TResult | TError : TResult;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Function result as matrix, possibly including an error result in each element. If the application framework reports
|
|
87
|
+
* errors through the return value, the individual element result is the union of the result type and the error type;
|
|
88
|
+
* otherwise, it's just the result type.
|
|
89
|
+
*
|
|
90
|
+
* @template TResult
|
|
91
|
+
* Result type.
|
|
92
|
+
*
|
|
93
|
+
* @template ThrowError
|
|
94
|
+
* If true, errors are reported through the throw/catch mechanism.
|
|
95
|
+
*
|
|
96
|
+
* @template TError
|
|
97
|
+
* Error type.
|
|
98
|
+
*/
|
|
99
|
+
export type MatrixResultError<TResult, ThrowError extends boolean, TError extends ErrorExtends<ThrowError>> = Matrix<ResultError<TResult, ThrowError, TError>>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Typed function, applicable to any function, stricter than {@link Function}.
|
|
103
|
+
*/
|
|
104
|
+
export type TypedFunction<TMethod extends (...args: Parameters<TMethod>) => ReturnType<TMethod>> = (...args: Parameters<TMethod>) => ReturnType<TMethod>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Typed synchronous function, applicable to any function that doesn't return a Promise.
|
|
108
|
+
*/
|
|
109
|
+
export type TypedSyncFunction<TMethod extends TypedFunction<TMethod>> = [ReturnType<TMethod>] extends [PromiseLike<unknown>] ? never : TypedFunction<TMethod>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Determine the fundamental promised type. This is stricter than `Awaited\<Type\>` in that it requires a Promise.
|
|
113
|
+
*/
|
|
114
|
+
type PromisedType<T> = [T] extends [PromiseLike<infer TPromised>] ? TPromised : never;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Typed asynchronous function, applicable to any function that returns a Promise.
|
|
118
|
+
*/
|
|
119
|
+
export type TypedAsyncFunction<TMethod extends (...args: Parameters<TMethod>) => PromiseLike<PromisedType<ReturnType<TMethod>>>> = (...args: Parameters<TMethod>) => Promise<PromisedType<ReturnType<TMethod>>>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Nullishable type. Application extension may pass `null` or `undefined` to missing parameters.
|
|
123
|
+
*/
|
|
124
|
+
export type Nullishable<T> = T | null | undefined;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Non-nullishable type. If T is an object type, it is spread and attributes within it are made non-nullishable.
|
|
128
|
+
*/
|
|
129
|
+
export type NonNullishable<T> = T extends object ? {
|
|
130
|
+
[P in keyof T]-?: NonNullishable<T[P]>
|
|
131
|
+
} : NonNullable<T>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Determine if argument is nullish. Application extension may pass `null` or `undefined` to missing parameters.
|
|
135
|
+
*
|
|
136
|
+
* @param argument
|
|
137
|
+
* Argument.
|
|
138
|
+
*
|
|
139
|
+
* @returns
|
|
140
|
+
* True if argument is undefined or null.
|
|
141
|
+
*/
|
|
142
|
+
export function isNullish<T>(argument: T | null | undefined): argument is null | undefined {
|
|
143
|
+
return argument === null || argument === undefined;
|
|
144
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ParameterDescriptor, Type } from "../descriptor.js";
|
|
2
|
+
|
|
3
|
+
const exclusionParameterDescriptor: ParameterDescriptor = {
|
|
4
|
+
name: "exclusion",
|
|
5
|
+
type: Type.Number,
|
|
6
|
+
isMatrix: false,
|
|
7
|
+
isRequired: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const exclusionNoneParameterDescriptor: ParameterDescriptor = {
|
|
11
|
+
extendsDescriptor: exclusionParameterDescriptor,
|
|
12
|
+
sortOrder: 0,
|
|
13
|
+
name: "exclusionNone"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const exclusionFirstZeroParameterDescriptor: ParameterDescriptor = {
|
|
17
|
+
extendsDescriptor: exclusionParameterDescriptor,
|
|
18
|
+
sortOrder: 1,
|
|
19
|
+
name: "exclusionFirstZero"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const exclusionAllNumericParameterDescriptor: ParameterDescriptor = {
|
|
23
|
+
extendsDescriptor: exclusionParameterDescriptor,
|
|
24
|
+
sortOrder: 2,
|
|
25
|
+
name: "exclusionAllNumeric"
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const exclusionAnyParameterDescriptor: ParameterDescriptor = {
|
|
29
|
+
extendsDescriptor: exclusionParameterDescriptor,
|
|
30
|
+
sortOrder: 3,
|
|
31
|
+
name: "exclusionAny"
|
|
32
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ALPHABETIC_CREATOR,
|
|
3
|
+
ALPHANUMERIC_CREATOR,
|
|
4
|
+
type CharacterSetCreator,
|
|
5
|
+
type CharacterSetValidation,
|
|
6
|
+
type Exclusion,
|
|
7
|
+
HEXADECIMAL_CREATOR,
|
|
8
|
+
NUMERIC_CREATOR,
|
|
9
|
+
Sequence
|
|
10
|
+
} from "@aidc-toolkit/utility";
|
|
11
|
+
import type { AppExtension } from "../app-extension.js";
|
|
12
|
+
import {
|
|
13
|
+
expandParameterDescriptor,
|
|
14
|
+
type ParameterDescriptor,
|
|
15
|
+
ProxyClass,
|
|
16
|
+
ProxyMethod,
|
|
17
|
+
ProxyParameter,
|
|
18
|
+
Type
|
|
19
|
+
} from "../descriptor.js";
|
|
20
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
21
|
+
import type { ErrorExtends, Matrix, MatrixResultError, Nullishable, ResultError } from "../types.js";
|
|
22
|
+
import {
|
|
23
|
+
exclusionAnyParameterDescriptor,
|
|
24
|
+
exclusionFirstZeroParameterDescriptor,
|
|
25
|
+
exclusionNoneParameterDescriptor
|
|
26
|
+
} from "./character-set-descriptor.js";
|
|
27
|
+
import { sParameterDescriptor, validateSParameterDescriptor } from "./string-descriptor.js";
|
|
28
|
+
import { StringProxy } from "./string-proxy.js";
|
|
29
|
+
import {
|
|
30
|
+
countParameterDescriptor,
|
|
31
|
+
startValueParameterDescriptor,
|
|
32
|
+
tweakParameterDescriptor,
|
|
33
|
+
valueParameterDescriptor
|
|
34
|
+
} from "./transformer-descriptor.js";
|
|
35
|
+
|
|
36
|
+
const lengthParameterDescriptor: ParameterDescriptor = {
|
|
37
|
+
name: "length",
|
|
38
|
+
type: Type.Number,
|
|
39
|
+
isMatrix: false,
|
|
40
|
+
isRequired: true
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const valueForSParameterDescriptor: ParameterDescriptor = {
|
|
44
|
+
extendsDescriptor: sParameterDescriptor,
|
|
45
|
+
name: "valueForS"
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export abstract class CharacterSetProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
49
|
+
private readonly _characterSetCreator: CharacterSetCreator;
|
|
50
|
+
|
|
51
|
+
protected constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, characterSetCreator: CharacterSetCreator) {
|
|
52
|
+
super(appExtension);
|
|
53
|
+
|
|
54
|
+
this._characterSetCreator = characterSetCreator;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@ProxyMethod({
|
|
58
|
+
type: Type.String,
|
|
59
|
+
isMatrix: true
|
|
60
|
+
})
|
|
61
|
+
validate(
|
|
62
|
+
@ProxyParameter(validateSParameterDescriptor) matrixSs: Matrix<string>,
|
|
63
|
+
@ProxyParameter(exclusionNoneParameterDescriptor) exclusion: Nullishable<Exclusion>
|
|
64
|
+
): MatrixResultError<string, ThrowError, TError> {
|
|
65
|
+
return this.validateString(this._characterSetCreator, matrixSs, {
|
|
66
|
+
exclusion: exclusion ?? undefined
|
|
67
|
+
} satisfies CharacterSetValidation);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@ProxyMethod({
|
|
71
|
+
type: Type.Boolean,
|
|
72
|
+
isMatrix: true
|
|
73
|
+
})
|
|
74
|
+
isValid(
|
|
75
|
+
@ProxyParameter(validateSParameterDescriptor) matrixSs: Matrix<string>,
|
|
76
|
+
@ProxyParameter(exclusionNoneParameterDescriptor) exclusion: Nullishable<Exclusion>
|
|
77
|
+
): MatrixResultError<boolean, ThrowError, TError> {
|
|
78
|
+
return this.isValidString(this.validate(matrixSs, exclusion));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ProxyMethod({
|
|
82
|
+
type: Type.String,
|
|
83
|
+
isMatrix: true
|
|
84
|
+
})
|
|
85
|
+
create(
|
|
86
|
+
@ProxyParameter(lengthParameterDescriptor) length: number,
|
|
87
|
+
@ProxyParameter(valueParameterDescriptor) matrixValues: Matrix<number | bigint>,
|
|
88
|
+
@ProxyParameter(exclusionNoneParameterDescriptor) exclusion: Nullishable<Exclusion>,
|
|
89
|
+
@ProxyParameter(tweakParameterDescriptor) tweak: Nullishable<number | bigint>
|
|
90
|
+
): MatrixResultError<string, ThrowError, TError> {
|
|
91
|
+
const exclusionOrUndefined = exclusion ?? undefined;
|
|
92
|
+
const tweakOrUndefined = tweak ?? undefined;
|
|
93
|
+
|
|
94
|
+
return this.mapMatrix(matrixValues, value => this._characterSetCreator.create(length, value, exclusionOrUndefined, tweakOrUndefined));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@ProxyMethod({
|
|
98
|
+
infixBefore: "Sequence",
|
|
99
|
+
type: Type.String,
|
|
100
|
+
isMatrix: true
|
|
101
|
+
})
|
|
102
|
+
createSequence(
|
|
103
|
+
@ProxyParameter(lengthParameterDescriptor) length: number,
|
|
104
|
+
@ProxyParameter(startValueParameterDescriptor) startValue: number,
|
|
105
|
+
@ProxyParameter(countParameterDescriptor) count: number,
|
|
106
|
+
@ProxyParameter(exclusionNoneParameterDescriptor) exclusion: Nullishable<Exclusion>,
|
|
107
|
+
@ProxyParameter(tweakParameterDescriptor) tweak: Nullishable<number | bigint>
|
|
108
|
+
): Matrix<string> {
|
|
109
|
+
this.appExtension.validateSequenceCount(count);
|
|
110
|
+
|
|
111
|
+
const exclusionOrUndefined = exclusion ?? undefined;
|
|
112
|
+
const tweakOrUndefined = tweak ?? undefined;
|
|
113
|
+
|
|
114
|
+
return LibProxy.matrixResult(this._characterSetCreator.create(length, new Sequence(startValue, count), exclusionOrUndefined, tweakOrUndefined));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@ProxyMethod({
|
|
118
|
+
type: Type.Number,
|
|
119
|
+
isMatrix: true
|
|
120
|
+
})
|
|
121
|
+
valueFor(
|
|
122
|
+
@ProxyParameter(valueForSParameterDescriptor) matrixSs: Matrix<string>,
|
|
123
|
+
@ProxyParameter(exclusionNoneParameterDescriptor) exclusion: Nullishable<Exclusion>,
|
|
124
|
+
@ProxyParameter(tweakParameterDescriptor) tweak: Nullishable<number | bigint>
|
|
125
|
+
): MatrixResultError<ResultError<TBigInt, ThrowError, TError>, ThrowError, TError> {
|
|
126
|
+
const exclusionOrUndefined = exclusion ?? undefined;
|
|
127
|
+
const tweakOrUndefined = tweak ?? undefined;
|
|
128
|
+
|
|
129
|
+
return this.mapMatrix(matrixSs, s => this.mapBigInt(this._characterSetCreator.valueFor(s, exclusionOrUndefined, tweakOrUndefined)));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@ProxyClass({
|
|
134
|
+
methodInfix: "Numeric",
|
|
135
|
+
replaceParameterDescriptors: [
|
|
136
|
+
{
|
|
137
|
+
name: expandParameterDescriptor(exclusionNoneParameterDescriptor).name,
|
|
138
|
+
replacement: exclusionFirstZeroParameterDescriptor
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
})
|
|
142
|
+
export class NumericProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
143
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
144
|
+
super(appExtension, NUMERIC_CREATOR);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@ProxyClass({
|
|
149
|
+
methodInfix: "Hexadecimal",
|
|
150
|
+
replaceParameterDescriptors: [
|
|
151
|
+
{
|
|
152
|
+
name: expandParameterDescriptor(exclusionNoneParameterDescriptor).name,
|
|
153
|
+
replacement: exclusionAnyParameterDescriptor
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
export class HexadecimalProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
158
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
159
|
+
super(appExtension, HEXADECIMAL_CREATOR);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ProxyClass({
|
|
164
|
+
methodInfix: "Alphabetic"
|
|
165
|
+
})
|
|
166
|
+
export class AlphabeticProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
167
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
168
|
+
super(appExtension, ALPHABETIC_CREATOR);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@ProxyClass({
|
|
173
|
+
methodInfix: "Alphanumeric",
|
|
174
|
+
replaceParameterDescriptors: [
|
|
175
|
+
{
|
|
176
|
+
name: expandParameterDescriptor(exclusionNoneParameterDescriptor).name,
|
|
177
|
+
replacement: exclusionAnyParameterDescriptor
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
})
|
|
181
|
+
export class AlphanumericProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
182
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
183
|
+
super(appExtension, ALPHANUMERIC_CREATOR);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RegExpValidator } from "@aidc-toolkit/utility";
|
|
2
|
+
import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Type } from "../descriptor.js";
|
|
3
|
+
import type { ErrorExtends, Matrix, MatrixResultError, Nullishable } from "../types.js";
|
|
4
|
+
import { validateSParameterDescriptor } from "./string-descriptor.js";
|
|
5
|
+
import { StringProxy } from "./string-proxy.js";
|
|
6
|
+
|
|
7
|
+
const regExpParameterDescriptor: ParameterDescriptor = {
|
|
8
|
+
name: "regExp",
|
|
9
|
+
type: Type.String,
|
|
10
|
+
isMatrix: false,
|
|
11
|
+
isRequired: true
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const errorMessageParameterDescriptor: ParameterDescriptor = {
|
|
15
|
+
name: "errorMessage",
|
|
16
|
+
type: Type.String,
|
|
17
|
+
isMatrix: false,
|
|
18
|
+
isRequired: false
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
@ProxyClass({
|
|
22
|
+
methodInfix: "RegExp"
|
|
23
|
+
})
|
|
24
|
+
export class RegExpProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
25
|
+
@ProxyMethod({
|
|
26
|
+
type: Type.String,
|
|
27
|
+
isMatrix: true
|
|
28
|
+
})
|
|
29
|
+
validate(
|
|
30
|
+
@ProxyParameter(regExpParameterDescriptor) regExp: string,
|
|
31
|
+
@ProxyParameter(validateSParameterDescriptor) matrixSs: Matrix<string>,
|
|
32
|
+
@ProxyParameter(errorMessageParameterDescriptor) errorMessage: Nullishable<string>
|
|
33
|
+
): MatrixResultError<string, ThrowError, TError> {
|
|
34
|
+
return this.validateString(new class extends RegExpValidator {
|
|
35
|
+
protected override createErrorMessage(s: string): string {
|
|
36
|
+
return errorMessage ?? super.createErrorMessage(s);
|
|
37
|
+
}
|
|
38
|
+
}(new RegExp(regExp)), matrixSs);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ProxyMethod({
|
|
42
|
+
type: Type.Boolean,
|
|
43
|
+
isMatrix: true
|
|
44
|
+
})
|
|
45
|
+
isValid(
|
|
46
|
+
@ProxyParameter(regExpParameterDescriptor) regExp: string,
|
|
47
|
+
@ProxyParameter(validateSParameterDescriptor) matrixSs: Matrix<string>
|
|
48
|
+
): MatrixResultError<boolean, ThrowError, TError> {
|
|
49
|
+
return this.isValidString(this.validate(regExp, matrixSs, undefined));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ParameterDescriptor, Type } from "../descriptor.js";
|
|
2
|
+
|
|
3
|
+
export const sParameterDescriptor: ParameterDescriptor = {
|
|
4
|
+
name: "s",
|
|
5
|
+
type: Type.String,
|
|
6
|
+
isMatrix: true,
|
|
7
|
+
isRequired: true
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const validateSParameterDescriptor: ParameterDescriptor = {
|
|
11
|
+
extendsDescriptor: sParameterDescriptor,
|
|
12
|
+
name: "validateS"
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StringValidation, StringValidator } from "@aidc-toolkit/utility";
|
|
2
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
3
|
+
import type { ErrorExtends, Matrix, MatrixResultError } from "../types.js";
|
|
4
|
+
|
|
5
|
+
export abstract class StringProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
6
|
+
protected validateString<TStringValidation extends StringValidation>(validator: StringValidator<TStringValidation>, matrixSs: Matrix<string>, validation?: TStringValidation): Matrix<string> {
|
|
7
|
+
return LibProxy.mapMatrixRangeError(matrixSs, (s) => {
|
|
8
|
+
validator.validate(s, validation);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
protected isValidString(matrixValidateResults: MatrixResultError<string, ThrowError, TError>): MatrixResultError<boolean, ThrowError, TError> {
|
|
13
|
+
return this.mapMatrix(matrixValidateResults, validateResult => validateResult === "");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ParameterDescriptor, Type } from "../descriptor.js";
|
|
2
|
+
|
|
3
|
+
export const valueParameterDescriptor: ParameterDescriptor = {
|
|
4
|
+
name: "value",
|
|
5
|
+
type: Type.Number,
|
|
6
|
+
isMatrix: true,
|
|
7
|
+
isRequired: true
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const startValueParameterDescriptor: ParameterDescriptor = {
|
|
11
|
+
extendsDescriptor: valueParameterDescriptor,
|
|
12
|
+
name: "startValue",
|
|
13
|
+
isMatrix: false
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const countParameterDescriptor: ParameterDescriptor = {
|
|
17
|
+
extendsDescriptor: valueParameterDescriptor,
|
|
18
|
+
name: "count",
|
|
19
|
+
isMatrix: false
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const tweakParameterDescriptor: ParameterDescriptor = {
|
|
23
|
+
name: "tweak",
|
|
24
|
+
type: Type.Number,
|
|
25
|
+
isMatrix: false,
|
|
26
|
+
isRequired: false
|
|
27
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Sequence, Transformer, mapIterable } from "@aidc-toolkit/utility";
|
|
2
|
+
import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Type } from "../descriptor.js";
|
|
3
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
4
|
+
import type { ErrorExtends, Matrix, MatrixResultError, Nullishable, ResultError } from "../types.js";
|
|
5
|
+
import {
|
|
6
|
+
countParameterDescriptor,
|
|
7
|
+
startValueParameterDescriptor,
|
|
8
|
+
tweakParameterDescriptor,
|
|
9
|
+
valueParameterDescriptor
|
|
10
|
+
} from "./transformer-descriptor.js";
|
|
11
|
+
|
|
12
|
+
const domainParameterDescriptor: ParameterDescriptor = {
|
|
13
|
+
name: "domain",
|
|
14
|
+
type: Type.Number,
|
|
15
|
+
isMatrix: false,
|
|
16
|
+
isRequired: true
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line no-useless-assignment -- ESLint bug.
|
|
20
|
+
const transformedValueParameterDescriptor: ParameterDescriptor = {
|
|
21
|
+
extendsDescriptor: valueParameterDescriptor,
|
|
22
|
+
name: "transformedValue"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
@ProxyClass({
|
|
26
|
+
methodInfix: "Transform"
|
|
27
|
+
})
|
|
28
|
+
export class TransformerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
29
|
+
@ProxyMethod({
|
|
30
|
+
type: Type.Number,
|
|
31
|
+
isMatrix: true
|
|
32
|
+
})
|
|
33
|
+
forward(
|
|
34
|
+
@ProxyParameter(domainParameterDescriptor) domain: number | bigint,
|
|
35
|
+
@ProxyParameter(valueParameterDescriptor) matrixValues: Matrix<number | bigint>,
|
|
36
|
+
@ProxyParameter(tweakParameterDescriptor) tweak: Nullishable<number | bigint>
|
|
37
|
+
): MatrixResultError<ResultError<TBigInt, ThrowError, TError>, ThrowError, TError> {
|
|
38
|
+
const transformer = Transformer.get(domain, tweak ?? undefined);
|
|
39
|
+
|
|
40
|
+
return this.mapMatrix(matrixValues, value => this.mapBigInt(transformer.forward(value)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@ProxyMethod({
|
|
44
|
+
infixBefore: "Sequence",
|
|
45
|
+
type: Type.Number,
|
|
46
|
+
isMatrix: true
|
|
47
|
+
})
|
|
48
|
+
forwardSequence(
|
|
49
|
+
@ProxyParameter(domainParameterDescriptor) domain: number | bigint,
|
|
50
|
+
@ProxyParameter(startValueParameterDescriptor) startValue: number,
|
|
51
|
+
@ProxyParameter(countParameterDescriptor) count: number,
|
|
52
|
+
@ProxyParameter(tweakParameterDescriptor) tweak: Nullishable<number | bigint>
|
|
53
|
+
): Matrix<ResultError<TBigInt, ThrowError, TError>> {
|
|
54
|
+
this.appExtension.validateSequenceCount(count);
|
|
55
|
+
|
|
56
|
+
return LibProxy.matrixResult(mapIterable(Transformer.get(domain, tweak ?? undefined).forward(new Sequence(startValue, count)), value => this.mapBigInt(value)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ProxyMethod({
|
|
60
|
+
type: Type.Number,
|
|
61
|
+
isMatrix: true
|
|
62
|
+
})
|
|
63
|
+
reverse(
|
|
64
|
+
@ProxyParameter(domainParameterDescriptor) domain: number | bigint,
|
|
65
|
+
@ProxyParameter(transformedValueParameterDescriptor) matrixTransformedValues: Matrix<number | bigint>,
|
|
66
|
+
@ProxyParameter(tweakParameterDescriptor) tweak: Nullishable<number | bigint>
|
|
67
|
+
): MatrixResultError<ResultError<TBigInt, ThrowError, TError>, ThrowError, TError> {
|
|
68
|
+
const transformer = Transformer.get(domain, tweak ?? undefined);
|
|
69
|
+
|
|
70
|
+
return this.mapMatrix(matrixTransformedValues, transformedValue => this.mapBigInt(transformer.reverse(transformedValue)));
|
|
71
|
+
}
|
|
72
|
+
}
|