@aidc-toolkit/app-extension 1.0.24-beta → 1.0.26-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/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/app-extension",
3
- "version": "1.0.24-beta",
3
+ "version": "1.0.26-beta",
4
4
  "description": "Application extension framework for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "homepage": "https://aidc-toolkit.com/",
8
- "repository": "aidc-toolkit/app-extension",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/aidc-toolkit/app-extension.git"
11
+ },
9
12
  "bugs": {
10
13
  "url": "https://github.com/aidc-toolkit/app-extension/issues"
11
14
  },
@@ -16,19 +19,21 @@
16
19
  "url": "https://www.linkedin.com/in/kdean"
17
20
  },
18
21
  "scripts": {
22
+ "locale-resources-generator": "tsx src/generator/locale-resources-generator.ts",
19
23
  "lint": "eslint",
24
+ "tsc:core": "tsc --project tsconfig-src.json",
25
+ "build:devx": "rimraf dist && npm run tsc:core -- --declarationMap --sourceMap",
20
26
  "build:dev": "tsup --define.mode=dev",
21
- "build:release": "tsup",
27
+ "build:release": "npm run tsc:core -- --noEmit && tsup",
22
28
  "build:doc": "npm run build:dev"
23
29
  },
24
30
  "devDependencies": {
25
- "@aidc-toolkit/dev": "beta",
26
- "@types/node": "^24.10.1"
31
+ "@aidc-toolkit/dev": "1.0.26-beta"
27
32
  },
28
33
  "dependencies": {
29
- "@aidc-toolkit/core": "beta",
30
- "@aidc-toolkit/gs1": "beta",
31
- "@aidc-toolkit/utility": "beta",
32
- "i18next": "^25.7.0"
34
+ "@aidc-toolkit/core": "1.0.26-beta",
35
+ "@aidc-toolkit/gs1": "1.0.26-beta",
36
+ "@aidc-toolkit/utility": "1.0.26-beta",
37
+ "i18next": "^25.7.1"
33
38
  }
34
39
  }
@@ -1,6 +1,6 @@
1
1
  import type { TypedAsyncFunction, TypedFunction, TypedSyncFunction } from "@aidc-toolkit/core";
2
- import { i18nextAppExtension } from "./locale/i18n";
3
- import type { ErrorExtends, ResultError, SheetAddress, SheetRange } from "./type";
2
+ import { i18nextAppExtension } from "./locale/i18n.js";
3
+ import type { ErrorExtends, ResultError, SheetAddress, SheetRange } from "./type.js";
4
4
 
5
5
  /**
6
6
  * Application extension.
@@ -1,8 +1,8 @@
1
1
  import { isNullish, type NonNullishable, type Nullishable } from "@aidc-toolkit/core";
2
- import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "./descriptor";
3
- import { LibProxy } from "./lib-proxy";
4
- import { i18nextAppExtension } from "./locale/i18n";
5
- import type { ErrorExtends, Matrix } from "./type";
2
+ import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "./descriptor.js";
3
+ import { LibProxy } from "./lib-proxy.js";
4
+ import { i18nextAppExtension } from "./locale/i18n.js";
5
+ import type { ErrorExtends, Matrix } from "./type.js";
6
6
 
7
7
  const spillMatrix: ParameterDescriptor = {
8
8
  name: "spillMatrix",
package/src/descriptor.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { TypedFunction } from "@aidc-toolkit/core";
2
- import type { AppExtension } from "./app-extension";
3
- import { LibProxy } from "./lib-proxy";
4
- import type { ErrorExtends } from "./type";
2
+ import type { AppExtension } from "./app-extension.js";
3
+ import { LibProxy } from "./lib-proxy.js";
4
+ import type { ErrorExtends } from "./type.js";
5
5
 
6
6
  /**
7
7
  * Core descriptor.
@@ -38,10 +38,15 @@ export const Types = {
38
38
  Any: 3
39
39
  } as const;
40
40
 
41
+ /**
42
+ * Type key.
43
+ */
44
+ export type TypeKey = keyof typeof Types;
45
+
41
46
  /**
42
47
  * Type.
43
48
  */
44
- export type Type = typeof Types[keyof typeof Types];
49
+ export type Type = typeof Types[TypeKey];
45
50
 
46
51
  /**
47
52
  * Type descriptor.
@@ -1,4 +1,4 @@
1
- import type { BaseParameterDescriptor, ClassDescriptor, MethodDescriptor } from "../descriptor";
1
+ import type { BaseParameterDescriptor, ClassDescriptor, MethodDescriptor } from "../descriptor.js";
2
2
 
3
3
  /**
4
4
  * Localization.
@@ -1,14 +1,28 @@
1
1
  import { I18nEnvironments } from "@aidc-toolkit/core";
2
2
  import type { ParseKeys } from "i18next";
3
- import { expandParameterDescriptor, getClassDescriptorsMap } from "../descriptor";
4
- import { appExtensionResources, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n";
3
+ import { AppUtilityProxy } from "../app-utility-proxy.js";
4
+ import { expandParameterDescriptor, getClassDescriptorsMap } from "../descriptor.js";
5
+ import * as GS1 from "../gs1/index.js";
6
+ import { appExtensionResources, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n.js";
7
+ import * as Utility from "../utility/index.js";
5
8
  import type {
6
9
  FunctionLocalization,
7
10
  Localization,
8
11
  ParameterLocalization,
9
12
  ProxyFunctionDescriptor,
10
13
  ProxyObjectDescriptor
11
- } from "./descriptor";
14
+ } from "./descriptor.js";
15
+
16
+ /**
17
+ * Dummy method to force proxies to register their decorators.
18
+ *
19
+ * @param _proxies
20
+ * Proxies.
21
+ */
22
+ function registerProxies(..._proxies: unknown[]): void {
23
+ }
24
+
25
+ registerProxies(AppUtilityProxy, Utility, GS1);
12
26
 
13
27
  /**
14
28
  * Abstract generator.
@@ -89,7 +103,7 @@ export abstract class Generator {
89
103
  const functionLocalization = this._functionLocalizationsMapsMap.get(namespaceFunctionName)?.get(locale);
90
104
 
91
105
  if (functionLocalization === undefined) {
92
- throw new Error(`Localization for function "${namespaceFunctionName}", locale "${locale}" not found`);
106
+ throw new Error(`${locale} localization for function ${namespaceFunctionName} not found`);
93
107
  }
94
108
 
95
109
  return functionLocalization;
@@ -114,7 +128,7 @@ export abstract class Generator {
114
128
  const parameterLocalization = this._parameterLocalizationsMapsMap.get(`${namespaceFunctionName}.${parameterName}`)?.get(locale);
115
129
 
116
130
  if (parameterLocalization === undefined) {
117
- throw new Error(`Localization for function "${namespaceFunctionName}", parameter "${parameterName}", locale "${locale}" not found`);
131
+ throw new Error(`${locale} localization for function ${namespaceFunctionName} parameter ${parameterName} not found`);
118
132
  }
119
133
 
120
134
  return parameterLocalization;
@@ -184,6 +198,10 @@ export abstract class Generator {
184
198
 
185
199
  await i18nAppExtensionInit(I18nEnvironments.CLI);
186
200
 
201
+ // const LocaleResourcesSource = path.resolve(LocaleResourcesGenerator.IMPORT_PATH, entry.name, "locale-resources.ts");
202
+ //
203
+ // await import(LocaleResourcesSource).then((module) => {
204
+
187
205
  this.initialize();
188
206
 
189
207
  try {
@@ -237,7 +255,7 @@ export abstract class Generator {
237
255
  const insertIndex = methodName.indexOf(infixBefore);
238
256
 
239
257
  if (insertIndex === -1) {
240
- throw new Error(`Cannot find "${infixBefore}" in method name ${methodName}`);
258
+ throw new Error(`Cannot find "${infixBefore}" in method ${methodName}`);
241
259
  }
242
260
 
243
261
  // Other classes in the hierarchy and infix is in the middle of the string.
@@ -1,2 +1,2 @@
1
- export type * from "./descriptor";
2
- export * from "./generator";
1
+ export type * from "./descriptor.js";
2
+ export * from "./generator.js";
@@ -1,9 +1,9 @@
1
1
  import { getLogger, type LocaleResources } from "@aidc-toolkit/core";
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
- import { expandParameterDescriptor, type ParameterDescriptor } from "../descriptor";
5
- import type { ProxyFunctionDescriptor } from "./descriptor";
6
- import { Generator } from "./generator";
4
+ import { expandParameterDescriptor, type ParameterDescriptor } from "../descriptor.js";
5
+ import type { ProxyFunctionDescriptor } from "./descriptor.js";
6
+ import { Generator } from "./generator.js";
7
7
 
8
8
  /**
9
9
  * Parameters sequencer entry.
@@ -37,7 +37,7 @@ interface LocaleResourcesModule {
37
37
  /**
38
38
  * Locale resources.
39
39
  */
40
- LocaleResources: LocaleResources;
40
+ default: LocaleResources;
41
41
  }
42
42
 
43
43
  /**
@@ -188,7 +188,7 @@ class LocaleResourcesGenerator extends Generator {
188
188
  }
189
189
 
190
190
  if (functionName in functionsLocaleResources) {
191
- throw new Error(`Duplicate function "${functionName}"`);
191
+ throw new Error(`Duplicate function ${functionName}`);
192
192
  }
193
193
 
194
194
  // Add function.
@@ -346,13 +346,13 @@ class LocaleResourcesGenerator extends Generator {
346
346
  await Promise.all(fs.readdirSync(LocaleResourcesGenerator.IMPORT_PATH, {
347
347
  withFileTypes: true
348
348
  }).filter(entry => entry.isDirectory()).map(async (entry) => {
349
- const LocaleResourcesSource = path.resolve(LocaleResourcesGenerator.IMPORT_PATH, entry.name, "locale-resources.ts");
349
+ const localeResourcesSource = path.resolve(LocaleResourcesGenerator.IMPORT_PATH, entry.name, "locale-resources.ts");
350
350
 
351
- await import(LocaleResourcesSource).then((module) => {
351
+ await import(localeResourcesSource).then((module) => {
352
352
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Module format is known.
353
- const LocaleResources = this.merge(entry.name === "en", "", this._LocaleResources, (module as LocaleResourcesModule).LocaleResources, !entry.name.includes("-"));
353
+ const localeResources = this.merge(entry.name === "en", "", this._LocaleResources, (module as LocaleResourcesModule).default, !entry.name.includes("-"));
354
354
 
355
- fs.writeFileSync(LocaleResourcesSource, `${LocaleResourcesGenerator.buildOutput("export default", LocaleResources, 0)};\n`);
355
+ fs.writeFileSync(localeResourcesSource, `${LocaleResourcesGenerator.buildOutput("export default", localeResources, 0)};\n`);
356
356
  });
357
357
  }));
358
358
  }
@@ -1,12 +1,12 @@
1
- import { AI39_CREATOR, AI82_CREATOR } from "@aidc-toolkit/gs1";
2
- import type { AppExtension } from "../app-extension";
3
- import { expandParameterDescriptor, ProxyClass } from "../descriptor";
4
- import type { ErrorExtends } from "../type";
1
+ import { AI39_CREATOR, AI64_VALIDATOR, AI82_CREATOR } from "@aidc-toolkit/gs1";
2
+ import type { AppExtension } from "../app-extension.js";
3
+ import { expandParameterDescriptor, ProxyClass } from "../descriptor.js";
4
+ import type { ErrorExtends } from "../type.js";
5
+ import { CharacterSetCreatorProxy, CharacterSetValidatorProxy } from "../utility/index.js";
5
6
  import {
6
7
  exclusionAllNumericParameterDescriptor,
7
8
  exclusionNoneParameterDescriptor
8
- } from "../utility/character-set-descriptor";
9
- import { CharacterSetProxy } from "../utility";
9
+ } from "../utility/character-set-descriptor.js";
10
10
 
11
11
  @ProxyClass({
12
12
  namespace: "GS1",
@@ -18,7 +18,7 @@ import { CharacterSetProxy } from "../utility";
18
18
  }
19
19
  ]
20
20
  })
21
- export class AI82Proxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetProxy<ThrowError, TError, TInvocationContext, TBigInt> {
21
+ export class AI82Proxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
22
22
  constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
23
23
  super(appExtension, AI82_CREATOR);
24
24
  }
@@ -34,8 +34,18 @@ export class AI82Proxy<ThrowError extends boolean, TError extends ErrorExtends<T
34
34
  }
35
35
  ]
36
36
  })
37
- export class AI39Proxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetProxy<ThrowError, TError, TInvocationContext, TBigInt> {
37
+ export class AI39Proxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
38
38
  constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
39
39
  super(appExtension, AI39_CREATOR);
40
40
  }
41
41
  }
42
+
43
+ @ProxyClass({
44
+ namespace: "GS1",
45
+ methodInfix: "AI64"
46
+ })
47
+ export class AI64Proxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
48
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
49
+ super(appExtension, AI64_VALIDATOR);
50
+ }
51
+ }
@@ -6,9 +6,9 @@ import {
6
6
  isValidPriceOrWeightCheckDigit,
7
7
  priceOrWeightCheckDigit
8
8
  } from "@aidc-toolkit/gs1";
9
- import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "../descriptor";
10
- import { LibProxy } from "../lib-proxy";
11
- import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "../type";
9
+ import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "../descriptor.js";
10
+ import { LibProxy } from "../lib-proxy.js";
11
+ import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "../type.js";
12
12
 
13
13
  const checkSParameterDescriptor: ParameterDescriptor = {
14
14
  name: "checkS",