@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Type } from "../descriptor.js";
|
|
2
|
+
export const valueParameterDescriptor = {
|
|
3
|
+
name: "value",
|
|
4
|
+
type: Type.Number,
|
|
5
|
+
isMatrix: true,
|
|
6
|
+
isRequired: true
|
|
7
|
+
};
|
|
8
|
+
export const startValueParameterDescriptor = {
|
|
9
|
+
extendsDescriptor: valueParameterDescriptor,
|
|
10
|
+
name: "startValue",
|
|
11
|
+
isMatrix: false
|
|
12
|
+
};
|
|
13
|
+
export const countParameterDescriptor = {
|
|
14
|
+
extendsDescriptor: valueParameterDescriptor,
|
|
15
|
+
name: "count",
|
|
16
|
+
isMatrix: false
|
|
17
|
+
};
|
|
18
|
+
export const tweakParameterDescriptor = {
|
|
19
|
+
name: "tweak",
|
|
20
|
+
type: Type.Number,
|
|
21
|
+
isMatrix: false,
|
|
22
|
+
isRequired: false
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=transformer-descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer-descriptor.js","sourceRoot":"","sources":["../../src/utility/transformer-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,CAAC,MAAM,wBAAwB,GAAwB;IACzD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,IAAI,CAAC,MAAM;IACjB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAC9D,iBAAiB,EAAE,wBAAwB;IAC3C,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAwB;IACzD,iBAAiB,EAAE,wBAAwB;IAC3C,IAAI,EAAE,OAAO;IACb,QAAQ,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAwB;IACzD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,IAAI,CAAC,MAAM;IACjB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,KAAK;CACpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
2
|
+
import type { ErrorExtends, Matrix, MatrixResultError, Nullishable, ResultError } from "../types.js";
|
|
3
|
+
export declare class TransformerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
4
|
+
forward(domain: number | bigint, matrixValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResultError<ResultError<TBigInt, ThrowError, TError>, ThrowError, TError>;
|
|
5
|
+
forwardSequence(domain: number | bigint, startValue: number, count: number, tweak: Nullishable<number | bigint>): Matrix<ResultError<TBigInt, ThrowError, TError>>;
|
|
6
|
+
reverse(domain: number | bigint, matrixTransformedValues: Matrix<number | bigint>, tweak: Nullishable<number | bigint>): MatrixResultError<ResultError<TBigInt, ThrowError, TError>, ThrowError, TError>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=transformer-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer-proxy.d.ts","sourceRoot":"","sources":["../../src/utility/transformer-proxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAqBrG,qBAGa,gBAAgB,CAAC,UAAU,SAAS,OAAO,EAAE,MAAM,SAAS,YAAY,CAAC,UAAU,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAE,SAAQ,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,CAAC;IAK7L,OAAO,CACwC,MAAM,EAAE,MAAM,GAAG,MAAM,EACxB,YAAY,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,EACrC,KAAK,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GAC9E,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC;IAWlF,eAAe,CACgC,MAAM,EAAE,MAAM,GAAG,MAAM,EACnB,UAAU,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GAC9E,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAUnD,OAAO,CACwC,MAAM,EAAE,MAAM,GAAG,MAAM,EACb,uBAAuB,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,EAC3D,KAAK,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GAC9E,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC;CAKrF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Sequence, Transformer, mapIterable } from "@aidc-toolkit/utility";
|
|
11
|
+
import { ProxyClass, ProxyMethod, ProxyParameter, Type } from "../descriptor.js";
|
|
12
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
13
|
+
import { countParameterDescriptor, startValueParameterDescriptor, tweakParameterDescriptor, valueParameterDescriptor } from "./transformer-descriptor.js";
|
|
14
|
+
const domainParameterDescriptor = {
|
|
15
|
+
name: "domain",
|
|
16
|
+
type: Type.Number,
|
|
17
|
+
isMatrix: false,
|
|
18
|
+
isRequired: true
|
|
19
|
+
};
|
|
20
|
+
// eslint-disable-next-line no-useless-assignment -- ESLint bug.
|
|
21
|
+
const transformedValueParameterDescriptor = {
|
|
22
|
+
extendsDescriptor: valueParameterDescriptor,
|
|
23
|
+
name: "transformedValue"
|
|
24
|
+
};
|
|
25
|
+
let TransformerProxy = class TransformerProxy extends LibProxy {
|
|
26
|
+
forward(domain, matrixValues, tweak) {
|
|
27
|
+
const transformer = Transformer.get(domain, tweak ?? undefined);
|
|
28
|
+
return this.mapMatrix(matrixValues, value => this.mapBigInt(transformer.forward(value)));
|
|
29
|
+
}
|
|
30
|
+
forwardSequence(domain, startValue, count, tweak) {
|
|
31
|
+
this.appExtension.validateSequenceCount(count);
|
|
32
|
+
return LibProxy.matrixResult(mapIterable(Transformer.get(domain, tweak ?? undefined).forward(new Sequence(startValue, count)), value => this.mapBigInt(value)));
|
|
33
|
+
}
|
|
34
|
+
reverse(domain, matrixTransformedValues, tweak) {
|
|
35
|
+
const transformer = Transformer.get(domain, tweak ?? undefined);
|
|
36
|
+
return this.mapMatrix(matrixTransformedValues, transformedValue => this.mapBigInt(transformer.reverse(transformedValue)));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
__decorate([
|
|
40
|
+
ProxyMethod({
|
|
41
|
+
type: Type.Number,
|
|
42
|
+
isMatrix: true
|
|
43
|
+
}),
|
|
44
|
+
__param(0, ProxyParameter(domainParameterDescriptor)),
|
|
45
|
+
__param(1, ProxyParameter(valueParameterDescriptor)),
|
|
46
|
+
__param(2, ProxyParameter(tweakParameterDescriptor))
|
|
47
|
+
], TransformerProxy.prototype, "forward", null);
|
|
48
|
+
__decorate([
|
|
49
|
+
ProxyMethod({
|
|
50
|
+
infixBefore: "Sequence",
|
|
51
|
+
type: Type.Number,
|
|
52
|
+
isMatrix: true
|
|
53
|
+
}),
|
|
54
|
+
__param(0, ProxyParameter(domainParameterDescriptor)),
|
|
55
|
+
__param(1, ProxyParameter(startValueParameterDescriptor)),
|
|
56
|
+
__param(2, ProxyParameter(countParameterDescriptor)),
|
|
57
|
+
__param(3, ProxyParameter(tweakParameterDescriptor))
|
|
58
|
+
], TransformerProxy.prototype, "forwardSequence", null);
|
|
59
|
+
__decorate([
|
|
60
|
+
ProxyMethod({
|
|
61
|
+
type: Type.Number,
|
|
62
|
+
isMatrix: true
|
|
63
|
+
}),
|
|
64
|
+
__param(0, ProxyParameter(domainParameterDescriptor)),
|
|
65
|
+
__param(1, ProxyParameter(transformedValueParameterDescriptor)),
|
|
66
|
+
__param(2, ProxyParameter(tweakParameterDescriptor))
|
|
67
|
+
], TransformerProxy.prototype, "reverse", null);
|
|
68
|
+
TransformerProxy = __decorate([
|
|
69
|
+
ProxyClass({
|
|
70
|
+
methodInfix: "Transform"
|
|
71
|
+
})
|
|
72
|
+
], TransformerProxy);
|
|
73
|
+
export { TransformerProxy };
|
|
74
|
+
//# sourceMappingURL=transformer-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer-proxy.js","sourceRoot":"","sources":["../../src/utility/transformer-proxy.ts"],"names":[],"mappings":"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"}
|
package/eslint.config.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { esLintConfigAIDCToolkit } from "@aidc-toolkit/dev";
|
|
2
|
+
import { defineConfig } from "eslint/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
...esLintConfigAIDCToolkit,
|
|
6
|
+
{
|
|
7
|
+
files: [
|
|
8
|
+
"src/*/**/*-proxy.ts"
|
|
9
|
+
],
|
|
10
|
+
rules: {
|
|
11
|
+
// Same rule minus ClassDeclaration, ClassProperty, and MethodDefinition contexts.
|
|
12
|
+
"jsdoc/require-description": ["warn", {
|
|
13
|
+
contexts: ["FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSModuleDeclaration", "TSTypeAliasDeclaration"]
|
|
14
|
+
}],
|
|
15
|
+
// Same rule minus ClassDeclaration, ClassProperty, and MethodDefinition contexts.
|
|
16
|
+
"jsdoc/require-jsdoc": ["warn", {
|
|
17
|
+
contexts: ["FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSModuleDeclaration", "TSTypeAliasDeclaration"]
|
|
18
|
+
}]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aidc-toolkit/app-extension",
|
|
3
|
+
"version": "0.9.19-beta",
|
|
4
|
+
"description": "Application extension framework for AIDC Toolkit",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"homepage": "https://aidc-toolkit.com/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/aidc-toolkit/app-extension.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/aidc-toolkit/app-extension/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Kevin Dean",
|
|
18
|
+
"email": "Kevin.Dean@datadevelopment.com",
|
|
19
|
+
"url": "https://www.linkedin.com/in/kdean"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"lint": "eslint",
|
|
23
|
+
"build:core": "rimraf dist && tsc --project",
|
|
24
|
+
"build:dev": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build-dev.json",
|
|
25
|
+
"build:release": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build.json",
|
|
26
|
+
"build:doc": "npm run build:dev"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@aidc-toolkit/dev": "beta"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aidc-toolkit/core": "beta",
|
|
33
|
+
"@aidc-toolkit/gs1": "beta",
|
|
34
|
+
"@aidc-toolkit/utility": "beta",
|
|
35
|
+
"i18next": "^25.6.3"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { i18nextAppExtension } from "./locale/i18n.js";
|
|
2
|
+
import type {
|
|
3
|
+
ErrorExtends,
|
|
4
|
+
ResultError,
|
|
5
|
+
SheetAddress,
|
|
6
|
+
SheetRange,
|
|
7
|
+
TypedAsyncFunction,
|
|
8
|
+
TypedFunction,
|
|
9
|
+
TypedSyncFunction
|
|
10
|
+
} from "./types.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Application extension.
|
|
14
|
+
*
|
|
15
|
+
* @template TBigInt
|
|
16
|
+
* Type to which big integer is mapped.
|
|
17
|
+
*
|
|
18
|
+
* @template ThrowError
|
|
19
|
+
* If true, errors are reported through the throw/catch mechanism.
|
|
20
|
+
*
|
|
21
|
+
* @template TError
|
|
22
|
+
* Error type.
|
|
23
|
+
*/
|
|
24
|
+
export abstract class AppExtension<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> {
|
|
25
|
+
/**
|
|
26
|
+
* Application version.
|
|
27
|
+
*/
|
|
28
|
+
private readonly _version: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Maximum sequence count supported by application.
|
|
32
|
+
*/
|
|
33
|
+
private readonly _maximumSequenceCount: number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* If true, errors are reported through the throw/catch mechanism.
|
|
37
|
+
*/
|
|
38
|
+
private readonly _throwError: ThrowError;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Maximum width supported by application.
|
|
42
|
+
*/
|
|
43
|
+
private _maximumWidth?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Maximum height supported by application.
|
|
47
|
+
*/
|
|
48
|
+
private _maximumHeight?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Constructor.
|
|
52
|
+
*
|
|
53
|
+
* @param version
|
|
54
|
+
* Application version.
|
|
55
|
+
*
|
|
56
|
+
* @param maximumSequenceCount
|
|
57
|
+
* Maximum sequence count supported by application.
|
|
58
|
+
*
|
|
59
|
+
* @param throwError
|
|
60
|
+
* If true, errors are reported through the throw/catch mechanism.
|
|
61
|
+
*/
|
|
62
|
+
protected constructor(version: string, maximumSequenceCount: number, throwError: ThrowError) {
|
|
63
|
+
this._version = version;
|
|
64
|
+
this._maximumSequenceCount = maximumSequenceCount;
|
|
65
|
+
this._throwError = throwError;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get the version.
|
|
70
|
+
*
|
|
71
|
+
* @returns
|
|
72
|
+
* Version.
|
|
73
|
+
*/
|
|
74
|
+
get version(): string {
|
|
75
|
+
return this._version;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Determine if errors are reported through the throw/catch mechanism.
|
|
80
|
+
*/
|
|
81
|
+
get throwError(): ThrowError {
|
|
82
|
+
return this._throwError;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get the maximum width supported by the application.
|
|
87
|
+
*
|
|
88
|
+
* @returns
|
|
89
|
+
* Maximum width supported by the application.
|
|
90
|
+
*/
|
|
91
|
+
async maximumWidth(): Promise<number> {
|
|
92
|
+
this._maximumWidth ??= await this.getMaximumWidth();
|
|
93
|
+
|
|
94
|
+
return this._maximumWidth;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get the maximum width supported by the application.
|
|
99
|
+
*
|
|
100
|
+
* @returns
|
|
101
|
+
* Maximum width supported by the application.
|
|
102
|
+
*/
|
|
103
|
+
protected abstract getMaximumWidth(): Promise<number>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the maximum height supported by the application.
|
|
107
|
+
*
|
|
108
|
+
* @returns
|
|
109
|
+
* Maximum height supported by the application.
|
|
110
|
+
*/
|
|
111
|
+
async maximumHeight(): Promise<number> {
|
|
112
|
+
this._maximumHeight ??= await this.getMaximumHeight();
|
|
113
|
+
|
|
114
|
+
return this._maximumHeight;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get the maximum height supported by the application.
|
|
119
|
+
*
|
|
120
|
+
* @returns
|
|
121
|
+
* Maximum height supported by the application.
|
|
122
|
+
*/
|
|
123
|
+
protected abstract getMaximumHeight(): Promise<number>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the sheet address from an invocation context.
|
|
127
|
+
*
|
|
128
|
+
* @param invocationContext
|
|
129
|
+
* Invocation context.
|
|
130
|
+
*
|
|
131
|
+
* @returns
|
|
132
|
+
* Sheet address.
|
|
133
|
+
*/
|
|
134
|
+
abstract getSheetAddress(invocationContext: TInvocationContext): Promise<SheetAddress>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get a parameter range from an invocation context.
|
|
138
|
+
*
|
|
139
|
+
* @param invocationContext
|
|
140
|
+
* Invocation context.
|
|
141
|
+
*
|
|
142
|
+
* @param parameterNumber
|
|
143
|
+
* Parameter number.
|
|
144
|
+
*
|
|
145
|
+
* @returns
|
|
146
|
+
* Sheet range or null if parameter is not a range.
|
|
147
|
+
*/
|
|
148
|
+
abstract getParameterSheetRange(invocationContext: TInvocationContext, parameterNumber: number): Promise<SheetRange | null>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Validate a sequence count against the maximum supported by application.
|
|
152
|
+
*
|
|
153
|
+
* @param sequenceCount
|
|
154
|
+
* Sequence count.
|
|
155
|
+
*/
|
|
156
|
+
validateSequenceCount(sequenceCount: number): void {
|
|
157
|
+
const absoluteSequenceCount = Math.abs(sequenceCount);
|
|
158
|
+
|
|
159
|
+
if (absoluteSequenceCount > this._maximumSequenceCount) {
|
|
160
|
+
throw new RangeError(i18nextAppExtension.t("AppExtension.sequenceCountMustBeLessThanOrEqualTo", {
|
|
161
|
+
sequenceCount: absoluteSequenceCount,
|
|
162
|
+
maximumSequenceCount: this._maximumSequenceCount
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Map big integer to another type if necessary.
|
|
169
|
+
*
|
|
170
|
+
* @param value
|
|
171
|
+
* Big integer value to map.
|
|
172
|
+
*
|
|
173
|
+
* @returns
|
|
174
|
+
* Mapped big integer value.
|
|
175
|
+
*/
|
|
176
|
+
abstract mapBigInt(value: bigint): ResultError<TBigInt, ThrowError, TError>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Map a range error (thrown by the library) to an application-specific error. If errors are reported through the
|
|
180
|
+
* throw/catch mechanism, the implementation may return the range error unmodified if that is supported.
|
|
181
|
+
*
|
|
182
|
+
* @param rangeError
|
|
183
|
+
*/
|
|
184
|
+
abstract mapRangeError(rangeError: RangeError): TError;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Handle an error with a message; called when an exception occurs outside the control of the AIDC Toolkit library.
|
|
188
|
+
* Implementation must not return, most likely by throwing the message wrapped in an error type.
|
|
189
|
+
*
|
|
190
|
+
* @param message
|
|
191
|
+
* Message to include in the error.
|
|
192
|
+
*/
|
|
193
|
+
abstract handleError(message: string): never;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Bind a synchronous method and wrap it in a try/catch for comprehensive error handling.
|
|
197
|
+
*
|
|
198
|
+
* @param thisArg
|
|
199
|
+
* The value to be passed as the `this` parameter to the method.
|
|
200
|
+
*
|
|
201
|
+
* @param method
|
|
202
|
+
* Method to call.
|
|
203
|
+
*
|
|
204
|
+
* @returns
|
|
205
|
+
* Function wrapped around the method.
|
|
206
|
+
*/
|
|
207
|
+
bindSync<TMethod extends TypedSyncFunction<TMethod>>(thisArg: ThisParameterType<TMethod>, method: TMethod): TypedFunction<TMethod> {
|
|
208
|
+
const boundMethod = method.bind(thisArg);
|
|
209
|
+
|
|
210
|
+
return (...args: Parameters<TMethod>): ReturnType<TMethod> => {
|
|
211
|
+
try {
|
|
212
|
+
return boundMethod(...args);
|
|
213
|
+
} catch (e: unknown) {
|
|
214
|
+
// eslint-disable-next-line no-console -- Necessary for diagnostics.
|
|
215
|
+
console.error(e);
|
|
216
|
+
|
|
217
|
+
this.handleError(e instanceof Error ? e.message : String(e));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Bind an asynchronous method and wrap it in a try/catch for comprehensive error handling.
|
|
224
|
+
*
|
|
225
|
+
* @param thisArg
|
|
226
|
+
* The value to be passed as the `this` parameter to the method.
|
|
227
|
+
*
|
|
228
|
+
* @param method
|
|
229
|
+
* Method to call.
|
|
230
|
+
*
|
|
231
|
+
* @returns
|
|
232
|
+
* Function wrapped around the method.
|
|
233
|
+
*/
|
|
234
|
+
bindAsync<TMethod extends TypedAsyncFunction<TMethod>>(thisArg: ThisParameterType<TMethod>, method: TMethod): TypedAsyncFunction<TMethod> {
|
|
235
|
+
const boundMethod = method.bind(thisArg);
|
|
236
|
+
|
|
237
|
+
return async (...args: Parameters<TMethod>) => await boundMethod(...args).catch((e: unknown) => {
|
|
238
|
+
// eslint-disable-next-line no-console -- Necessary for diagnostics.
|
|
239
|
+
console.error(e);
|
|
240
|
+
|
|
241
|
+
this.handleError(e instanceof Error ? e.message : String(e));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|