@aidc-toolkit/app-extension 1.0.45 → 1.0.46

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.
@@ -0,0 +1,126 @@
1
+ import { Promisable } from '@aidc-toolkit/core';
2
+ import { Logger } from 'tslog';
3
+ import { C as ClassDescriptor, e as MethodDescriptor } from '../descriptor-FJHoLlYK.cjs';
4
+
5
+ /**
6
+ * Localization.
7
+ */
8
+ interface Localization {
9
+ /**
10
+ * Name.
11
+ */
12
+ readonly name: string;
13
+ /**
14
+ * Description.
15
+ */
16
+ readonly description: string;
17
+ }
18
+ /**
19
+ * Function localization.
20
+ */
21
+ interface FunctionLocalization extends Localization {
22
+ /**
23
+ * Namespace function name.
24
+ */
25
+ readonly namespaceFunctionName: string;
26
+ /**
27
+ * Documentation URL.
28
+ */
29
+ readonly documentationURL: string;
30
+ /**
31
+ * Parameters map.
32
+ */
33
+ readonly parametersMap: ReadonlyMap<string, Localization>;
34
+ }
35
+ /**
36
+ * Abstract generator.
37
+ */
38
+ declare abstract class Generator {
39
+ #private;
40
+ /**
41
+ * Constructor.
42
+ *
43
+ * @param version
44
+ * Package version.
45
+ *
46
+ * @param includeLocalizations
47
+ * Include localizations if true.
48
+ */
49
+ constructor(version: string, includeLocalizations?: boolean);
50
+ /**
51
+ * Get the logger.
52
+ */
53
+ get logger(): Logger<object>;
54
+ /**
55
+ * Get the package version.
56
+ */
57
+ get version(): string;
58
+ /**
59
+ * Get the locales.
60
+ */
61
+ protected get locales(): readonly string[];
62
+ /**
63
+ * Get the default locale.
64
+ */
65
+ protected get defaultLocale(): string;
66
+ /**
67
+ * Initialize the generation of the output.
68
+ */
69
+ protected abstract initialize(): Promisable<void>;
70
+ /**
71
+ * Create a namespace.
72
+ *
73
+ * @param namespace
74
+ * Namespace.
75
+ */
76
+ protected abstract createNamespace(namespace: string | undefined): void;
77
+ /**
78
+ * Create a category.
79
+ *
80
+ * @param namespace
81
+ * Namespace.
82
+ *
83
+ * @param category
84
+ * Category.
85
+ *
86
+ * @param categoryLocalizationsMap
87
+ * Category localizations map.
88
+ */
89
+ protected abstract createCategory(namespace: string | undefined, category: string, categoryLocalizationsMap: ReadonlyMap<string, string>): void;
90
+ /**
91
+ * Create a proxy object for a class.
92
+ *
93
+ * @param objectName
94
+ * Object name, derived from namespace and class name.
95
+ *
96
+ * @param classDescriptor
97
+ * Class descriptor.
98
+ */
99
+ protected abstract createProxyObject(objectName: string, classDescriptor: ClassDescriptor): void;
100
+ /**
101
+ * Create a proxy function for a class and method.
102
+ *
103
+ * @param classDescriptor
104
+ * Class descriptor.
105
+ *
106
+ * @param methodDescriptor
107
+ * Method descriptor.
108
+ *
109
+ * @param functionLocalizationsMap
110
+ * Function localizations map.
111
+ */
112
+ protected abstract createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor, functionLocalizationsMap: ReadonlyMap<string, FunctionLocalization>): void;
113
+ /**
114
+ * Finalize the generation of the output.
115
+ *
116
+ * @param success
117
+ * True if successful.
118
+ */
119
+ protected abstract finalize(success: boolean): Promisable<void>;
120
+ /**
121
+ * Generate by processing individual imports.
122
+ */
123
+ generate(): Promise<void>;
124
+ }
125
+
126
+ export { type FunctionLocalization, Generator, type Localization };
@@ -0,0 +1,126 @@
1
+ import { Promisable } from '@aidc-toolkit/core';
2
+ import { Logger } from 'tslog';
3
+ import { C as ClassDescriptor, e as MethodDescriptor } from '../descriptor-FJHoLlYK.js';
4
+
5
+ /**
6
+ * Localization.
7
+ */
8
+ interface Localization {
9
+ /**
10
+ * Name.
11
+ */
12
+ readonly name: string;
13
+ /**
14
+ * Description.
15
+ */
16
+ readonly description: string;
17
+ }
18
+ /**
19
+ * Function localization.
20
+ */
21
+ interface FunctionLocalization extends Localization {
22
+ /**
23
+ * Namespace function name.
24
+ */
25
+ readonly namespaceFunctionName: string;
26
+ /**
27
+ * Documentation URL.
28
+ */
29
+ readonly documentationURL: string;
30
+ /**
31
+ * Parameters map.
32
+ */
33
+ readonly parametersMap: ReadonlyMap<string, Localization>;
34
+ }
35
+ /**
36
+ * Abstract generator.
37
+ */
38
+ declare abstract class Generator {
39
+ #private;
40
+ /**
41
+ * Constructor.
42
+ *
43
+ * @param version
44
+ * Package version.
45
+ *
46
+ * @param includeLocalizations
47
+ * Include localizations if true.
48
+ */
49
+ constructor(version: string, includeLocalizations?: boolean);
50
+ /**
51
+ * Get the logger.
52
+ */
53
+ get logger(): Logger<object>;
54
+ /**
55
+ * Get the package version.
56
+ */
57
+ get version(): string;
58
+ /**
59
+ * Get the locales.
60
+ */
61
+ protected get locales(): readonly string[];
62
+ /**
63
+ * Get the default locale.
64
+ */
65
+ protected get defaultLocale(): string;
66
+ /**
67
+ * Initialize the generation of the output.
68
+ */
69
+ protected abstract initialize(): Promisable<void>;
70
+ /**
71
+ * Create a namespace.
72
+ *
73
+ * @param namespace
74
+ * Namespace.
75
+ */
76
+ protected abstract createNamespace(namespace: string | undefined): void;
77
+ /**
78
+ * Create a category.
79
+ *
80
+ * @param namespace
81
+ * Namespace.
82
+ *
83
+ * @param category
84
+ * Category.
85
+ *
86
+ * @param categoryLocalizationsMap
87
+ * Category localizations map.
88
+ */
89
+ protected abstract createCategory(namespace: string | undefined, category: string, categoryLocalizationsMap: ReadonlyMap<string, string>): void;
90
+ /**
91
+ * Create a proxy object for a class.
92
+ *
93
+ * @param objectName
94
+ * Object name, derived from namespace and class name.
95
+ *
96
+ * @param classDescriptor
97
+ * Class descriptor.
98
+ */
99
+ protected abstract createProxyObject(objectName: string, classDescriptor: ClassDescriptor): void;
100
+ /**
101
+ * Create a proxy function for a class and method.
102
+ *
103
+ * @param classDescriptor
104
+ * Class descriptor.
105
+ *
106
+ * @param methodDescriptor
107
+ * Method descriptor.
108
+ *
109
+ * @param functionLocalizationsMap
110
+ * Function localizations map.
111
+ */
112
+ protected abstract createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor, functionLocalizationsMap: ReadonlyMap<string, FunctionLocalization>): void;
113
+ /**
114
+ * Finalize the generation of the output.
115
+ *
116
+ * @param success
117
+ * True if successful.
118
+ */
119
+ protected abstract finalize(success: boolean): Promisable<void>;
120
+ /**
121
+ * Generate by processing individual imports.
122
+ */
123
+ generate(): Promise<void>;
124
+ }
125
+
126
+ export { type FunctionLocalization, Generator, type Localization };
@@ -0,0 +1,17 @@
1
+ import{b as $,c as d,d as b,h as z,i as D,r as M,s as P}from"../chunk-FAD3UX6B.js";import{ALPHA_URL as O,getLogger as j,I18nEnvironments as E,websiteURL as U}from"@aidc-toolkit/core";function H(...p){}H(D,M,P);var w=class p{static#o="app-extension/";#n=j();#t;#e;#a;constructor(s,r=!0){this.#t=s,this.#e=r?Object.keys($):[],this.#a=this.#e[0]??""}get logger(){return this.#n}get version(){return this.#t}get locales(){return this.#e}get defaultLocale(){return this.#a}static#s(s,r,i){let e={lng:s,returnObjects:!0};return i(s,d.t(r,e))}async generate(){let s=!1;await b(E.CLI);let r=U(this.version,!0,await O);await this.initialize();let i=new Map;for(let e of z.classDescriptors){let l=e.namespace,c=e.category,o=i.get(l);o===void 0&&(o=new Map,i.set(l,o));let t=o.get(c);t===void 0&&(t=[],o.set(c,t)),t.push(e)}try{for(let[e,l]of i){let c=e===void 0?"":`${e}.`,o=e===void 0?"":`${e}/`;this.createNamespace(e);for(let[t,C]of l){let N=`${c}${t}`,v=`Categories.${t}`,f=`Categories.${N}`,R=new Map(this.locales.map(n=>{let a={lng:n};return[n,d.t(d.exists(f,a)?f:v,a)]}));this.createCategory(e,t,R);let h=new Set;for(let n of C){let a=n.namespaceClassName;if(h.has(a))throw new Error(`Duplicate class ${a}`);h.add(a);let m=/^(?<namespaceFirstWord>[A-Z]+[0-9]*|[A-Z][^A-Z.]*)(?<namespaceRemaining>[A-Z][^.]*|)\.?(?<className>[A-Z].*|)$/u.exec(a)?.groups;if(m===void 0)throw new Error(`${a} is not a valid namespace-qualified class name`);this.createProxyObject(`${m.namespaceFirstWord.toLowerCase()}${m.namespaceRemaining}${m.className}`,n);for(let g of n.methodDescriptors){let A=new Map(this.locales.map(L=>[L,p.#s(L,`Functions.${g.namespaceFunctionName}`,(u,y)=>({...y,namespaceFunctionName:`${c}${y.name}`,documentationURL:`${r}/${u===this.defaultLocale?"":`${u}/`}${p.#o}${o}${y.name}.html`,parametersMap:new Map(g.parameterDescriptors.map(x=>[x.name,p.#s(u,`Parameters.${x.name}`,(T,F)=>F)]))}))]));this.createProxyFunction(n,g,A)}}}}s=!0}finally{await this.finalize(s)}}};export{w as Generator};
2
+ /*!
3
+ * Copyright © 2024-2026 Dolphin Data Development Ltd. and AIDC Toolkit
4
+ * contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { I18nEnvironment, MemoryTransport, Promisable, AppDataStorage, Hyperlink, Nullishable } from '@aidc-toolkit/core';
2
2
  import { Resource, i18n } from 'i18next';
3
3
  import { Logger } from 'tslog';
4
+ export { C as ClassDescriptor, E as ExtendsParameterDescriptor, e as MethodDescriptor, M as Multiplicities, d as Multiplicity, c as MultiplicityKey, P as ParameterDescriptor, R as ReplacementParameterDescriptor, b as Type, a as TypeKey, T as Types } from './descriptor-FJHoLlYK.cjs';
4
5
  import { StringValidation, StringValidator, CharacterSetValidator, Exclusion, CharacterSetCreator } from '@aidc-toolkit/utility';
5
6
  import { NumericIdentifierType, IdentifierType, IdentifierTypeValidator, GTINType, NonGTINNumericIdentifierType, NonSerializableNumericIdentifierType, SerializableNumericIdentifierType, NonNumericIdentifierType, NonNumericIdentifierValidation, GTINLevel, PrefixType, NumericIdentifierCreator, IdentifierValidation, IdentifierCreator, PrefixManager, NumericIdentifierValidation, NonGTINNumericIdentifierCreator, SerializableNumericIdentifierCreator, NonNumericIdentifierCreator, GTINCreator } from '@aidc-toolkit/gs1';
6
7
 
@@ -1202,202 +1203,6 @@ declare abstract class LibProxy<ThrowError extends boolean, TError extends Error
1202
1203
  protected iterableResult<TResult>(iterableCallback: () => Iterable<SingletonResult<TResult, ThrowError, TError>>): MatrixResult<TResult, ThrowError, TError>;
1203
1204
  }
1204
1205
 
1205
- /**
1206
- * Core descriptor.
1207
- */
1208
- interface Descriptor {
1209
- /**
1210
- * Name.
1211
- */
1212
- readonly name: string;
1213
- }
1214
- /**
1215
- * Types supported by proxy methods.
1216
- */
1217
- declare const Types: {
1218
- /**
1219
- * String.
1220
- */
1221
- readonly String: 0;
1222
- /**
1223
- * Number or enumeration.
1224
- */
1225
- readonly Number: 1;
1226
- /**
1227
- * Boolean.
1228
- */
1229
- readonly Boolean: 2;
1230
- /**
1231
- * Any.
1232
- */
1233
- readonly Any: 3;
1234
- };
1235
- /**
1236
- * Type key.
1237
- */
1238
- type TypeKey = keyof typeof Types;
1239
- /**
1240
- * Type.
1241
- */
1242
- type Type = typeof Types[TypeKey];
1243
- /**
1244
- * Multiplicities supported by proxy methods.
1245
- */
1246
- declare const Multiplicities: {
1247
- /**
1248
- * Parameter or return value is a singleton.
1249
- */
1250
- readonly Singleton: 0;
1251
- /**
1252
- * Parameter or return value is a singleton or an array.
1253
- */
1254
- readonly Array: 1;
1255
- /**
1256
- * Parameter or return value is a singleton, an array, or a matrix.
1257
- */
1258
- readonly Matrix: 2;
1259
- /**
1260
- * Parameter value is a singleton or array but is treated as a singleton internally and doesn't drive multiplicity
1261
- * of the return value. Return value is an array for use as a singleton array parameter.
1262
- */
1263
- readonly SingletonArray: 3;
1264
- };
1265
- /**
1266
- * Multiplicity key.
1267
- */
1268
- type MultiplicityKey = keyof typeof Multiplicities;
1269
- /**
1270
- * Multiplicity.
1271
- */
1272
- type Multiplicity = typeof Multiplicities[MultiplicityKey];
1273
- /**
1274
- * Type descriptor.
1275
- */
1276
- interface TypeDescriptor extends Descriptor {
1277
- /**
1278
- * Type.
1279
- */
1280
- readonly type: Type;
1281
- /**
1282
- * Multiplicity.
1283
- */
1284
- readonly multiplicity: Multiplicity;
1285
- }
1286
- /**
1287
- * Parameter descriptor.
1288
- */
1289
- interface ParameterDescriptor extends TypeDescriptor {
1290
- /**
1291
- * True if required.
1292
- */
1293
- readonly isRequired: boolean;
1294
- }
1295
- /**
1296
- * Extends parameter descriptor.
1297
- */
1298
- interface ExtendsParameterDescriptor extends Partial<ParameterDescriptor> {
1299
- /**
1300
- * Parameter descriptor that this one extends.
1301
- */
1302
- readonly extendsDescriptor: ParameterDescriptor | ExtendsParameterDescriptor;
1303
- /**
1304
- * Sort order within extended parameter descriptor.
1305
- */
1306
- readonly sortOrder?: number;
1307
- }
1308
- /**
1309
- * Replacement parameter descriptor.
1310
- */
1311
- interface ReplacementParameterDescriptor {
1312
- /**
1313
- * Name to replace.
1314
- */
1315
- readonly name: string;
1316
- /**
1317
- * Replacement parameter descriptor.
1318
- */
1319
- readonly replacement: ParameterDescriptor;
1320
- }
1321
- /**
1322
- * Method descriptor.
1323
- */
1324
- interface MethodDescriptor extends TypeDescriptor {
1325
- /**
1326
- * If true, method is asynchronous.
1327
- */
1328
- readonly isAsync?: true;
1329
- /**
1330
- * If true, function is hidden from user interface.
1331
- */
1332
- readonly isHidden?: true;
1333
- /**
1334
- * If true, application-specific invocation context is required.
1335
- */
1336
- readonly requiresContext?: true;
1337
- /**
1338
- * If true, function is volatile and should be reevaluated regularly.
1339
- */
1340
- readonly isVolatile?: true;
1341
- /**
1342
- * If true, function opens a stream that updates asynchronously.
1343
- */
1344
- readonly isStream?: true;
1345
- /**
1346
- * Number of characters to capitalize at the start of the method name for title case; defaults to 1.
1347
- */
1348
- readonly titleCaseStart?: number;
1349
- /**
1350
- * If true, method infix is ignored.
1351
- */
1352
- readonly ignoreInfix?: true;
1353
- /**
1354
- * String before which method infix appears. If undefined, infix is appended to the method name. Ignored if
1355
- * `ignoreInfix` is true.
1356
- */
1357
- readonly infixBefore?: string;
1358
- /**
1359
- * Parameter descriptors.
1360
- */
1361
- readonly parameterDescriptors: readonly ParameterDescriptor[];
1362
- /**
1363
- * Function name with optional infix.
1364
- */
1365
- readonly functionName: string;
1366
- /**
1367
- * Function name in optional namespace with optional infix.
1368
- */
1369
- readonly namespaceFunctionName: string;
1370
- }
1371
- /**
1372
- * Class descriptor.
1373
- */
1374
- interface ClassDescriptor extends Descriptor {
1375
- /**
1376
- * Class namespace. If not provided, class is at the top level.
1377
- */
1378
- readonly namespace?: string | undefined;
1379
- /**
1380
- * Category.
1381
- */
1382
- readonly category: string;
1383
- /**
1384
- * Method infix. If undefined, method name is generated verbatim.
1385
- */
1386
- readonly methodInfix?: string | undefined;
1387
- /**
1388
- * Replacement parameter descriptors for class hierarchies where parameter types can narrow
1389
- */
1390
- readonly replacementParameterDescriptors?: ReplacementParameterDescriptor[];
1391
- /**
1392
- * Class name in optional namespace.
1393
- */
1394
- readonly namespaceClassName: string;
1395
- /**
1396
- * Method descriptors.
1397
- */
1398
- readonly methodDescriptors: readonly MethodDescriptor[];
1399
- }
1400
-
1401
1206
  /**
1402
1207
  * Application utilities.
1403
1208
  *
@@ -1749,4 +1554,4 @@ declare namespace index {
1749
1554
  export { index_AI39Proxy as AI39Proxy, index_AI64Proxy as AI64Proxy, index_AI82Proxy as AI82Proxy, index_CPIDCreatorProxy as CPIDCreatorProxy, index_CPIDValidatorProxy as CPIDValidatorProxy, index_CheckProxy as CheckProxy, index_GCNCreatorProxy as GCNCreatorProxy, index_GCNValidatorProxy as GCNValidatorProxy, index_GCPLengthProxy as GCPLengthProxy, index_GDTICreatorProxy as GDTICreatorProxy, index_GDTIValidatorProxy as GDTIValidatorProxy, index_GIAICreatorProxy as GIAICreatorProxy, index_GIAIValidatorProxy as GIAIValidatorProxy, index_GINCCreatorProxy as GINCCreatorProxy, index_GINCValidatorProxy as GINCValidatorProxy, index_GLNCreatorProxy as GLNCreatorProxy, index_GLNValidatorProxy as GLNValidatorProxy, index_GMNCreatorProxy as GMNCreatorProxy, index_GMNValidatorProxy as GMNValidatorProxy, index_GRAICreatorProxy as GRAICreatorProxy, index_GRAIValidatorProxy as GRAIValidatorProxy, index_GSINCreatorProxy as GSINCreatorProxy, index_GSINValidatorProxy as GSINValidatorProxy, index_GSRNCreatorProxy as GSRNCreatorProxy, index_GSRNValidatorProxy as GSRNValidatorProxy, index_GTIN12ValidatorProxy as GTIN12ValidatorProxy, index_GTIN13ValidatorProxy as GTIN13ValidatorProxy, index_GTIN8ValidatorProxy as GTIN8ValidatorProxy, index_GTINCreatorProxy as GTINCreatorProxy, index_GTINValidatorStaticProxy as GTINValidatorStaticProxy, index_PrefixManagerProxy as PrefixManagerProxy, index_SSCCCreatorProxy as SSCCCreatorProxy, index_SSCCValidatorProxy as SSCCValidatorProxy, index_VariableMeasureProxy as VariableMeasureProxy, index_VerifiedByGS1Proxy as VerifiedByGS1Proxy };
1750
1555
  }
1751
1556
 
1752
- export { type Address, AlphabeticProxy, AlphanumericProxy, AppExtension, type AppExtensionLocaleResources, AppHelperProxy, CharacterSetCreatorProxy, CharacterSetValidatorProxy, type ClassDescriptor, type ErrorExtends, type ExtendsParameterDescriptor, index as GS1, HexadecimalProxy, LibProxy, type Matrix, type MatrixResult, type MethodDescriptor, Multiplicities, type Multiplicity, type MultiplicityKey, NumericProxy, type ParameterDescriptor, type Range, RegExpProxy, type ReplacementParameterDescriptor, type Sheet, type SheetAddress, type SheetRange, type SingletonResult, type StreamingCancelledCallback, type StreamingConsumerCallback, TransformerProxy, type Type, type TypeKey, Types, appExtensionNS, appExtensionResourceBundle, i18nAppExtensionInit, i18nextAppExtension };
1557
+ export { type Address, AlphabeticProxy, AlphanumericProxy, AppExtension, type AppExtensionLocaleResources, AppHelperProxy, CharacterSetCreatorProxy, CharacterSetValidatorProxy, type ErrorExtends, index as GS1, HexadecimalProxy, LibProxy, type Matrix, type MatrixResult, NumericProxy, type Range, RegExpProxy, type Sheet, type SheetAddress, type SheetRange, type SingletonResult, type StreamingCancelledCallback, type StreamingConsumerCallback, TransformerProxy, appExtensionNS, appExtensionResourceBundle, i18nAppExtensionInit, i18nextAppExtension };