@aidc-toolkit/app-extension 1.0.32-beta → 1.0.33-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -6528
- package/dist/index.d.cts +105 -106
- package/dist/index.d.ts +105 -106
- package/dist/index.js +1 -6508
- package/package.json +12 -12
- package/src/app-extension.ts +26 -47
- package/src/{app-utility-proxy.ts → app-helper-proxy.ts} +21 -19
- package/src/descriptor.ts +43 -2
- package/src/generator/generator.ts +116 -91
- package/src/generator/locale-resources-generator.ts +26 -14
- package/src/gs1/check-proxy.ts +12 -11
- package/src/gs1/gtin-creator-proxy.ts +2 -3
- package/src/gs1/gtin-descriptor.ts +2 -2
- package/src/gs1/gtin-validator-proxy.ts +12 -14
- package/src/gs1/identifier-creator-proxy.ts +19 -21
- package/src/gs1/identifier-descriptor.ts +3 -3
- package/src/gs1/identifier-validator-proxy.ts +15 -16
- package/src/gs1/non-gtin-creator-proxy.ts +0 -11
- package/src/gs1/non-gtin-validator-proxy.ts +0 -11
- package/src/gs1/prefix-definition-descriptor.ts +2 -2
- package/src/gs1/prefix-manager-proxy.ts +80 -120
- package/src/gs1/service-proxy.ts +6 -5
- package/src/gs1/variable-measure-proxy.ts +9 -8
- package/src/index.ts +1 -2
- package/src/locale/en/locale-resources.ts +28 -15
- package/src/locale/fr/locale-resources.ts +28 -15
- package/src/locale/i18n.ts +10 -9
- package/src/locale/i18next.d.ts +2 -0
- package/src/proxy.ts +64 -40
- package/src/utility/character-set-descriptor.ts +2 -2
- package/src/utility/character-set-proxy.ts +7 -7
- package/src/utility/reg-exp-proxy.ts +5 -5
- package/src/utility/string-descriptor.ts +2 -2
- package/src/utility/string-proxy.ts +4 -0
- package/src/utility/transformer-descriptor.ts +5 -5
- package/src/utility/transformer-proxy.ts +6 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/app-data.ts +0 -94
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/app-extension",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33-beta",
|
|
4
4
|
"description": "Application extension framework for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
-
"homepage": "https://aidc-toolkit.com
|
|
7
|
+
"homepage": "https://aidc-toolkit.com",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/aidc-toolkit/app-extension.git"
|
|
@@ -19,20 +19,20 @@
|
|
|
19
19
|
"url": "https://www.linkedin.com/in/kdean"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"generate-locale-resources": "tsx src/generator/locale-resources-generator.ts",
|
|
23
22
|
"lint": "eslint",
|
|
24
|
-
"
|
|
25
|
-
"build:
|
|
26
|
-
"build:
|
|
27
|
-
"build:
|
|
23
|
+
"build:base": "tsc --project tsconfig-src.json --noEmit && tsup",
|
|
24
|
+
"build:alpha": "npm run build:base -- --define.mode=alpha",
|
|
25
|
+
"build:beta": "npm run build:base -- --define.mode=beta",
|
|
26
|
+
"build:prod": "npm run build:base",
|
|
27
|
+
"build:doc": "npm run build:alpha",
|
|
28
|
+
"generate-locale-resources": "tsx src/generator/locale-resources-generator.ts"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@aidc-toolkit/dev": "1.0.
|
|
31
|
+
"@aidc-toolkit/dev": "1.0.33-beta"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@aidc-toolkit/core": "1.0.
|
|
34
|
-
"@aidc-toolkit/gs1": "1.0.
|
|
35
|
-
"@aidc-toolkit/utility": "1.0.
|
|
36
|
-
"base64-js": "^1.5.1"
|
|
34
|
+
"@aidc-toolkit/core": "1.0.33-beta",
|
|
35
|
+
"@aidc-toolkit/gs1": "1.0.33-beta",
|
|
36
|
+
"@aidc-toolkit/utility": "1.0.33-beta"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/app-extension.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type AppDataStorage,
|
|
3
|
+
getLogger,
|
|
4
|
+
type Hyperlink,
|
|
5
|
+
LogLevels,
|
|
6
|
+
MemoryTransport,
|
|
7
|
+
type Promisable
|
|
8
|
+
} from "@aidc-toolkit/core";
|
|
2
9
|
import type { Logger } from "tslog";
|
|
3
|
-
import type { AppData } from "./app-data.js";
|
|
4
10
|
import { i18nextAppExtension } from "./locale/i18n.js";
|
|
5
11
|
import type { StreamingCancelledCallback, StreamingConsumerCallback } from "./streaming.js";
|
|
6
12
|
import type { ErrorExtends, MatrixResult, SheetAddress, SheetRange, SingletonResult } from "./type.js";
|
|
@@ -25,14 +31,14 @@ import type { ErrorExtends, MatrixResult, SheetAddress, SheetRange, SingletonRes
|
|
|
25
31
|
*/
|
|
26
32
|
export abstract class AppExtension<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
27
33
|
/**
|
|
28
|
-
* Application name
|
|
34
|
+
* Application name.
|
|
29
35
|
*/
|
|
30
|
-
static readonly
|
|
36
|
+
static readonly APPLICATION_NAME = "AIDCToolkit";
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
39
|
* Version property name.
|
|
34
40
|
*/
|
|
35
|
-
static readonly VERSION_NAME = `${AppExtension.
|
|
41
|
+
static readonly VERSION_NAME = `${AppExtension.APPLICATION_NAME}.version`;
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Maximum logger messages length.
|
|
@@ -90,8 +96,7 @@ export abstract class AppExtension<ThrowError extends boolean, TError extends Er
|
|
|
90
96
|
const isProduction = !version.includes("-");
|
|
91
97
|
|
|
92
98
|
this.#logger = getLogger(isProduction ? LogLevels.Info : LogLevels.Debug, {
|
|
93
|
-
type: isProduction ? "hidden" : "pretty"
|
|
94
|
-
hideLogPositionForProduction: isProduction
|
|
99
|
+
type: isProduction ? "hidden" : "pretty"
|
|
95
100
|
});
|
|
96
101
|
|
|
97
102
|
this.#memoryTransport = new MemoryTransport(this.#logger, AppExtension.#MAXIMUM_LOGGER_MESSAGES_LENGTH, AppExtension.#TRUNCATE_LOGGER_MESSAGES_LENGTH);
|
|
@@ -101,10 +106,10 @@ export abstract class AppExtension<ThrowError extends boolean, TError extends Er
|
|
|
101
106
|
* Initialize the application extension.
|
|
102
107
|
*/
|
|
103
108
|
async initialize(): Promise<void> {
|
|
104
|
-
const fileVersion = await this.
|
|
109
|
+
const fileVersion = await this.getDocumentProperty(AppExtension.VERSION_NAME);
|
|
105
110
|
|
|
106
111
|
if (fileVersion !== this.#version) {
|
|
107
|
-
await this.
|
|
112
|
+
await this.setDocumentProperty(AppExtension.VERSION_NAME, this.#version);
|
|
108
113
|
}
|
|
109
114
|
}
|
|
110
115
|
|
|
@@ -189,7 +194,7 @@ export abstract class AppExtension<ThrowError extends boolean, TError extends Er
|
|
|
189
194
|
abstract setUpStreaming<TResult>(streamingInvocationContext: TStreamingInvocationContext, streamingCancelledCallback: StreamingCancelledCallback): StreamingConsumerCallback<TResult, ThrowError, TError>;
|
|
190
195
|
|
|
191
196
|
/**
|
|
192
|
-
* Get a property stored within the active
|
|
197
|
+
* Get a property stored within the active document.
|
|
193
198
|
*
|
|
194
199
|
* @param name
|
|
195
200
|
* Property name.
|
|
@@ -197,62 +202,36 @@ export abstract class AppExtension<ThrowError extends boolean, TError extends Er
|
|
|
197
202
|
* @returns
|
|
198
203
|
* Property value or undefined if no value is stored under the given name.
|
|
199
204
|
*/
|
|
200
|
-
abstract
|
|
205
|
+
abstract getDocumentProperty(name: string): Promisable<string | undefined>;
|
|
201
206
|
|
|
202
207
|
/**
|
|
203
|
-
* Set a property to be stored within the active
|
|
208
|
+
* Set a property to be stored within the active document.
|
|
204
209
|
*
|
|
205
210
|
* @param name
|
|
206
211
|
* Property name.
|
|
207
212
|
*
|
|
208
213
|
* @param value
|
|
209
|
-
* Property value
|
|
214
|
+
* Property value.
|
|
210
215
|
*/
|
|
211
|
-
abstract
|
|
216
|
+
abstract setDocumentProperty(name: string, value: string): Promisable<void>;
|
|
212
217
|
|
|
213
218
|
/**
|
|
214
|
-
*
|
|
219
|
+
* Delete a property from the active document.
|
|
215
220
|
*
|
|
216
221
|
* @param name
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* @returns
|
|
220
|
-
* Application data or undefined if no data is stored under the given name.
|
|
221
|
-
*/
|
|
222
|
-
abstract getFileData(name: string): Promisable<AppData | undefined>;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Set application data to be stored within the active file.
|
|
226
|
-
*
|
|
227
|
-
* @param name
|
|
228
|
-
* Name under which to store data.
|
|
229
|
-
*
|
|
230
|
-
* @param appData
|
|
231
|
-
* Application data or null to remove.
|
|
222
|
+
* Property name.
|
|
232
223
|
*/
|
|
233
|
-
abstract
|
|
224
|
+
abstract deleteDocumentProperty(name: string): Promisable<void>;
|
|
234
225
|
|
|
235
226
|
/**
|
|
236
|
-
* Get application data
|
|
237
|
-
*
|
|
238
|
-
* @param name
|
|
239
|
-
* Name under which data is stored.
|
|
240
|
-
*
|
|
241
|
-
* @returns
|
|
242
|
-
* Application ata or undefined if no data is stored under the given name.
|
|
227
|
+
* Get application data storage for the current document.
|
|
243
228
|
*/
|
|
244
|
-
abstract
|
|
229
|
+
abstract get documentAppDataStorage(): AppDataStorage<boolean>;
|
|
245
230
|
|
|
246
231
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* @param name
|
|
250
|
-
* Name under which to store data.
|
|
251
|
-
*
|
|
252
|
-
* @param appData
|
|
253
|
-
* Application data or null to remove.
|
|
232
|
+
* Get application data storage shared across multiple documents.
|
|
254
233
|
*/
|
|
255
|
-
abstract
|
|
234
|
+
abstract get sharedAppDataStorage(): AppDataStorage<boolean>;
|
|
256
235
|
|
|
257
236
|
/**
|
|
258
237
|
* Validate a sequence count against the maximum supported by application.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { isNullish, type LogLevel, logLevelOf, type NonNullishable, type Nullishable } from "@aidc-toolkit/core";
|
|
2
|
-
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "./descriptor.js";
|
|
2
|
+
import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "./descriptor.js";
|
|
3
3
|
import { LibProxy } from "./lib-proxy.js";
|
|
4
4
|
import { i18nextAppExtension } from "./locale/i18n.js";
|
|
5
5
|
import { proxy } from "./proxy.js";
|
|
6
6
|
import type { ErrorExtends, Matrix, MatrixResult } from "./type.js";
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
name: "
|
|
8
|
+
const spillArrayParameterDescriptor: ParameterDescriptor = {
|
|
9
|
+
name: "spillArray",
|
|
10
10
|
type: Types.Any,
|
|
11
|
-
|
|
11
|
+
multiplicity: Multiplicities.Array,
|
|
12
12
|
isRequired: true
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const spillMaximumParameterDescriptor: ParameterDescriptor = {
|
|
16
16
|
name: "spillMaximum",
|
|
17
17
|
type: Types.Number,
|
|
18
|
-
|
|
18
|
+
multiplicity: Multiplicities.Singleton,
|
|
19
19
|
isRequired: false
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -64,8 +64,10 @@ interface MaximumDimensions {
|
|
|
64
64
|
* @template TBigInt
|
|
65
65
|
* Type to which big integer is mapped.
|
|
66
66
|
*/
|
|
67
|
-
@proxy.describeClass(false
|
|
68
|
-
|
|
67
|
+
@proxy.describeClass(false, {
|
|
68
|
+
category: "helper"
|
|
69
|
+
})
|
|
70
|
+
export class AppHelperProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
69
71
|
/**
|
|
70
72
|
* Get the version.
|
|
71
73
|
*
|
|
@@ -74,7 +76,7 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
74
76
|
*/
|
|
75
77
|
@proxy.describeMethod({
|
|
76
78
|
type: Types.String,
|
|
77
|
-
|
|
79
|
+
multiplicity: Multiplicities.Singleton,
|
|
78
80
|
parameterDescriptors: []
|
|
79
81
|
})
|
|
80
82
|
version(): string {
|
|
@@ -125,7 +127,7 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
125
127
|
/**
|
|
126
128
|
* Spill a one-dimensional matrix to fit a rectangle within a given maximum height and width.
|
|
127
129
|
*
|
|
128
|
-
* @param
|
|
130
|
+
* @param arrayValues
|
|
129
131
|
* Matrix values. Matrix is length 1 or contains arrays of length 1 with the values.
|
|
130
132
|
*
|
|
131
133
|
* @param maximumHeight
|
|
@@ -143,15 +145,15 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
143
145
|
@proxy.describeMethod({
|
|
144
146
|
requiresContext: true,
|
|
145
147
|
type: Types.Any,
|
|
146
|
-
|
|
147
|
-
parameterDescriptors: [
|
|
148
|
+
multiplicity: Multiplicities.Matrix,
|
|
149
|
+
parameterDescriptors: [spillArrayParameterDescriptor, spillMaximumHeightParameterDescriptor, spillMaximumWidthParameterDescriptor]
|
|
148
150
|
})
|
|
149
|
-
async spill(
|
|
151
|
+
async spill(arrayValues: Matrix<unknown>, maximumHeight: Nullishable<number>, maximumWidth: Nullishable<number>, invocationContext: Nullishable<TInvocationContext>): Promise<MatrixResult<unknown, ThrowError, TError>> {
|
|
150
152
|
let result: MatrixResult<unknown, ThrowError, TError>;
|
|
151
153
|
|
|
152
154
|
// Assume matrix is uniformly two-dimensional.
|
|
153
|
-
const height =
|
|
154
|
-
const width = height !== 0 ?
|
|
155
|
+
const height = arrayValues.length;
|
|
156
|
+
const width = height !== 0 ? arrayValues[0].length : 0;
|
|
155
157
|
|
|
156
158
|
const isArrayOrError = this.singletonResult(() => {
|
|
157
159
|
if (height > 1 && width > 1) {
|
|
@@ -209,7 +211,7 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
209
211
|
const endIndex = startIndex + spillParallel;
|
|
210
212
|
|
|
211
213
|
// Each row is a slice of the original single row.
|
|
212
|
-
const row =
|
|
214
|
+
const row = arrayValues[0].slice(startIndex, endIndex);
|
|
213
215
|
|
|
214
216
|
// Row length will be anywhere from 1 to spillParallel.
|
|
215
217
|
if (row.length < spillParallel) {
|
|
@@ -231,7 +233,7 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
231
233
|
|
|
232
234
|
// Each column is a slice of the original single column.
|
|
233
235
|
for (let valueIndex = rowIndex; valueIndex < length; valueIndex += spillParallel) {
|
|
234
|
-
row.push(
|
|
236
|
+
row.push(arrayValues[valueIndex][0]);
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
// Row length will always be spillPerpendicular or spillPerpendicular - 1.
|
|
@@ -244,7 +246,7 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
244
246
|
}
|
|
245
247
|
} else {
|
|
246
248
|
// Return matrix unmodified and let application handle spill error if any.
|
|
247
|
-
result =
|
|
249
|
+
result = arrayValues;
|
|
248
250
|
}
|
|
249
251
|
} else {
|
|
250
252
|
// Return error as only element in matrix.
|
|
@@ -267,11 +269,11 @@ export class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
267
269
|
type: Types.String,
|
|
268
270
|
isHidden: true,
|
|
269
271
|
isStream: true,
|
|
270
|
-
|
|
272
|
+
multiplicity: Multiplicities.Array,
|
|
271
273
|
parameterDescriptors: [{
|
|
272
274
|
name: "logLevel",
|
|
273
275
|
type: Types.String,
|
|
274
|
-
|
|
276
|
+
multiplicity: Multiplicities.Singleton,
|
|
275
277
|
isRequired: false
|
|
276
278
|
}]
|
|
277
279
|
})
|
package/src/descriptor.ts
CHANGED
|
@@ -43,6 +43,42 @@ export type TypeKey = keyof typeof Types;
|
|
|
43
43
|
*/
|
|
44
44
|
export type Type = typeof Types[TypeKey];
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Multiplicities supported by proxy methods.
|
|
48
|
+
*/
|
|
49
|
+
export const Multiplicities = {
|
|
50
|
+
/**
|
|
51
|
+
* Parameter or return value is a singleton.
|
|
52
|
+
*/
|
|
53
|
+
Singleton: 0,
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parameter or return value is a singleton or an array.
|
|
57
|
+
*/
|
|
58
|
+
Array: 1,
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Parameter or return value is a singleton, an array, or a matrix.
|
|
62
|
+
*/
|
|
63
|
+
Matrix: 2,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Parameter value is a singleton or array but is treated as a singleton internally and doesn't drive multiplicity
|
|
67
|
+
* of the return value. Return value is an array for use as a singleton array parameter.
|
|
68
|
+
*/
|
|
69
|
+
SingletonArray: 3
|
|
70
|
+
} as const;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Multiplicity key.
|
|
74
|
+
*/
|
|
75
|
+
export type MultiplicityKey = keyof typeof Multiplicities;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Multiplicity.
|
|
79
|
+
*/
|
|
80
|
+
export type Multiplicity = typeof Multiplicities[MultiplicityKey];
|
|
81
|
+
|
|
46
82
|
/**
|
|
47
83
|
* Type descriptor.
|
|
48
84
|
*/
|
|
@@ -53,9 +89,9 @@ interface TypeDescriptor extends Descriptor {
|
|
|
53
89
|
readonly type: Type;
|
|
54
90
|
|
|
55
91
|
/**
|
|
56
|
-
*
|
|
92
|
+
* Multiplicity.
|
|
57
93
|
*/
|
|
58
|
-
readonly
|
|
94
|
+
readonly multiplicity: Multiplicity;
|
|
59
95
|
}
|
|
60
96
|
|
|
61
97
|
/**
|
|
@@ -158,6 +194,11 @@ export interface ClassDescriptor extends Descriptor {
|
|
|
158
194
|
*/
|
|
159
195
|
readonly namespace?: string | undefined;
|
|
160
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Category.
|
|
199
|
+
*/
|
|
200
|
+
readonly category: string;
|
|
201
|
+
|
|
161
202
|
/**
|
|
162
203
|
* Method infix. If undefined, method name is generated verbatim.
|
|
163
204
|
*/
|