@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.
Files changed (39) hide show
  1. package/dist/index.cjs +1 -6528
  2. package/dist/index.d.cts +105 -106
  3. package/dist/index.d.ts +105 -106
  4. package/dist/index.js +1 -6508
  5. package/package.json +12 -12
  6. package/src/app-extension.ts +26 -47
  7. package/src/{app-utility-proxy.ts → app-helper-proxy.ts} +21 -19
  8. package/src/descriptor.ts +43 -2
  9. package/src/generator/generator.ts +116 -91
  10. package/src/generator/locale-resources-generator.ts +26 -14
  11. package/src/gs1/check-proxy.ts +12 -11
  12. package/src/gs1/gtin-creator-proxy.ts +2 -3
  13. package/src/gs1/gtin-descriptor.ts +2 -2
  14. package/src/gs1/gtin-validator-proxy.ts +12 -14
  15. package/src/gs1/identifier-creator-proxy.ts +19 -21
  16. package/src/gs1/identifier-descriptor.ts +3 -3
  17. package/src/gs1/identifier-validator-proxy.ts +15 -16
  18. package/src/gs1/non-gtin-creator-proxy.ts +0 -11
  19. package/src/gs1/non-gtin-validator-proxy.ts +0 -11
  20. package/src/gs1/prefix-definition-descriptor.ts +2 -2
  21. package/src/gs1/prefix-manager-proxy.ts +80 -120
  22. package/src/gs1/service-proxy.ts +6 -5
  23. package/src/gs1/variable-measure-proxy.ts +9 -8
  24. package/src/index.ts +1 -2
  25. package/src/locale/en/locale-resources.ts +28 -15
  26. package/src/locale/fr/locale-resources.ts +28 -15
  27. package/src/locale/i18n.ts +10 -9
  28. package/src/locale/i18next.d.ts +2 -0
  29. package/src/proxy.ts +64 -40
  30. package/src/utility/character-set-descriptor.ts +2 -2
  31. package/src/utility/character-set-proxy.ts +7 -7
  32. package/src/utility/reg-exp-proxy.ts +5 -5
  33. package/src/utility/string-descriptor.ts +2 -2
  34. package/src/utility/string-proxy.ts +4 -0
  35. package/src/utility/transformer-descriptor.ts +5 -5
  36. package/src/utility/transformer-proxy.ts +6 -5
  37. package/dist/index.cjs.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/src/app-data.ts +0 -94
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { I18nEnvironment, MemoryTransport, Promisable, Hyperlink, Nullishable } from '@aidc-toolkit/core';
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
4
  import { StringValidation, StringValidator, CharacterSetValidator, Exclusion, CharacterSetCreator } from '@aidc-toolkit/utility';
@@ -11,6 +11,19 @@ declare const _default: {
11
11
  Proxy: {
12
12
  matrixMustBeArray: string;
13
13
  };
14
+ Categories: {
15
+ helper: string;
16
+ transformation: string;
17
+ string: string;
18
+ GS1: {
19
+ checkCharacter: string;
20
+ identifierValidation: string;
21
+ identifierCreation: string;
22
+ variableMeasure: string;
23
+ prefix: string;
24
+ service: string;
25
+ };
26
+ };
14
27
  IdentifierCreatorProxy: {
15
28
  prefixDefinitionMustBeOneDimensional: string;
16
29
  prefixDefinitionMustHaveMaximumThreeElements: string;
@@ -23,7 +36,7 @@ declare const _default: {
23
36
  invalidIdentifierType: string;
24
37
  };
25
38
  Parameters: {
26
- spillMatrix: {
39
+ spillArray: {
27
40
  name: string;
28
41
  description: string;
29
42
  };
@@ -748,9 +761,9 @@ declare const appExtensionNS = "aidct_app_extension";
748
761
  */
749
762
  type AppExtensionLocaleResources = typeof _default;
750
763
  /**
751
- * App extension resources.
764
+ * App extension resource bundle.
752
765
  */
753
- declare const appExtensionResources: Resource;
766
+ declare const appExtensionResourceBundle: Resource;
754
767
  declare const i18nextAppExtension: i18n;
755
768
  /**
756
769
  * Initialize internationalization.
@@ -760,8 +773,11 @@ declare const i18nextAppExtension: i18n;
760
773
  *
761
774
  * @param debug
762
775
  * Debug setting.
776
+ *
777
+ * @returns
778
+ * App extension resource bundle.
763
779
  */
764
- declare function i18nAppExtensionInit(environment: I18nEnvironment, debug?: boolean): Promise<void>;
780
+ declare function i18nAppExtensionInit(environment: I18nEnvironment, debug?: boolean): Promise<Resource>;
765
781
 
766
782
  /**
767
783
  * Type that error type is expected to extend. If the application framework reports errors through the throw/catch
@@ -854,32 +870,6 @@ type SingletonResult<TResult, ThrowError extends boolean, TError extends ErrorEx
854
870
  */
855
871
  type MatrixResult<TResult, ThrowError extends boolean, TError extends ErrorExtends<ThrowError>> = Matrix<SingletonResult<TResult, ThrowError, TError>>;
856
872
 
857
- /**
858
- * Application data.
859
- */
860
- type AppData = string | number | boolean | Date | Uint8Array | object;
861
- /**
862
- * Decode application data from an encoded string.
863
- *
864
- * @param stringData
865
- * String data.
866
- *
867
- * @returns
868
- * Decoded application data.
869
- */
870
- declare function decodeAppData(stringData: string): AppData | undefined;
871
- /**
872
- * Encode application data as a string for storage. Encoded string is in JSON format with date/time and binary data
873
- * converted to identifiable strings for decoding.
874
- *
875
- * @param appData
876
- * Application data.
877
- *
878
- * @returns
879
- * Encoded application data.
880
- */
881
- declare function encodeAppData(appData: AppData): string;
882
-
883
873
  /**
884
874
  * Streaming consumer callback, returned by application extension implementation.
885
875
  */
@@ -910,9 +900,9 @@ type StreamingCancelledCallback = () => void;
910
900
  declare abstract class AppExtension<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> {
911
901
  #private;
912
902
  /**
913
- * Application name prefix for properties and application data.
903
+ * Application name.
914
904
  */
915
- static readonly APPLICATION_NAME_PREFIX = "AIDCToolkit.";
905
+ static readonly APPLICATION_NAME = "AIDCToolkit";
916
906
  /**
917
907
  * Version property name.
918
908
  */
@@ -998,7 +988,7 @@ declare abstract class AppExtension<ThrowError extends boolean, TError extends E
998
988
  */
999
989
  abstract setUpStreaming<TResult>(streamingInvocationContext: TStreamingInvocationContext, streamingCancelledCallback: StreamingCancelledCallback): StreamingConsumerCallback<TResult, ThrowError, TError>;
1000
990
  /**
1001
- * Get a property stored within the active file.
991
+ * Get a property stored within the active document.
1002
992
  *
1003
993
  * @param name
1004
994
  * Property name.
@@ -1006,57 +996,32 @@ declare abstract class AppExtension<ThrowError extends boolean, TError extends E
1006
996
  * @returns
1007
997
  * Property value or undefined if no value is stored under the given name.
1008
998
  */
1009
- abstract getFileProperty(name: string): Promisable<string | undefined>;
999
+ abstract getDocumentProperty(name: string): Promisable<string | undefined>;
1010
1000
  /**
1011
- * Set a property to be stored within the active file.
1001
+ * Set a property to be stored within the active document.
1012
1002
  *
1013
1003
  * @param name
1014
1004
  * Property name.
1015
1005
  *
1016
1006
  * @param value
1017
- * Property value or null to remove.
1018
- */
1019
- abstract setFileProperty(name: string, value: string | null): Promisable<void>;
1020
- /**
1021
- * Get application data stored within the active file.
1022
- *
1023
- * @param name
1024
- * Name under which data is stored.
1025
- *
1026
- * @returns
1027
- * Application data or undefined if no data is stored under the given name.
1007
+ * Property value.
1028
1008
  */
1029
- abstract getFileData(name: string): Promisable<AppData | undefined>;
1009
+ abstract setDocumentProperty(name: string, value: string): Promisable<void>;
1030
1010
  /**
1031
- * Set application data to be stored within the active file.
1011
+ * Delete a property from the active document.
1032
1012
  *
1033
1013
  * @param name
1034
- * Name under which to store data.
1035
- *
1036
- * @param appData
1037
- * Application data or null to remove.
1014
+ * Property name.
1038
1015
  */
1039
- abstract setFileData(name: string, appData: AppData | null): Promisable<void>;
1016
+ abstract deleteDocumentProperty(name: string): Promisable<void>;
1040
1017
  /**
1041
- * Get application data stored and shared across multiple files.
1042
- *
1043
- * @param name
1044
- * Name under which data is stored.
1045
- *
1046
- * @returns
1047
- * Application ata or undefined if no data is stored under the given name.
1018
+ * Get application data storage for the current document.
1048
1019
  */
1049
- abstract getSharedData(name: string): Promisable<AppData | undefined>;
1020
+ abstract get documentAppDataStorage(): AppDataStorage<boolean>;
1050
1021
  /**
1051
- * Set application data to be stored and shared across multiple files.
1052
- *
1053
- * @param name
1054
- * Name under which to store data.
1055
- *
1056
- * @param appData
1057
- * Application data or null to remove.
1022
+ * Get application data storage shared across multiple documents.
1058
1023
  */
1059
- abstract setSharedData(name: string, appData: AppData | null): Promisable<void>;
1024
+ abstract get sharedAppDataStorage(): AppDataStorage<boolean>;
1060
1025
  /**
1061
1026
  * Validate a sequence count against the maximum supported by application.
1062
1027
  *
@@ -1275,6 +1240,36 @@ type TypeKey = keyof typeof Types;
1275
1240
  * Type.
1276
1241
  */
1277
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];
1278
1273
  /**
1279
1274
  * Type descriptor.
1280
1275
  */
@@ -1284,9 +1279,9 @@ interface TypeDescriptor extends Descriptor {
1284
1279
  */
1285
1280
  readonly type: Type;
1286
1281
  /**
1287
- * True if type is a matrix (method accepts or returns, or parameter is, a two-dimensional array).
1282
+ * Multiplicity.
1288
1283
  */
1289
- readonly isMatrix: boolean;
1284
+ readonly multiplicity: Multiplicity;
1290
1285
  }
1291
1286
  /**
1292
1287
  * Parameter descriptor.
@@ -1373,6 +1368,10 @@ interface ClassDescriptor extends Descriptor {
1373
1368
  * Class namespace. If not provided, class is at the top level.
1374
1369
  */
1375
1370
  readonly namespace?: string | undefined;
1371
+ /**
1372
+ * Category.
1373
+ */
1374
+ readonly category: string;
1376
1375
  /**
1377
1376
  * Method infix. If undefined, method name is generated verbatim.
1378
1377
  */
@@ -1413,7 +1412,7 @@ interface ClassDescriptor extends Descriptor {
1413
1412
  * @template TBigInt
1414
1413
  * Type to which big integer is mapped.
1415
1414
  */
1416
- declare class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
1415
+ declare class AppHelperProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
1417
1416
  #private;
1418
1417
  /**
1419
1418
  * Get the version.
@@ -1425,7 +1424,7 @@ declare class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorEx
1425
1424
  /**
1426
1425
  * Spill a one-dimensional matrix to fit a rectangle within a given maximum height and width.
1427
1426
  *
1428
- * @param matrixValues
1427
+ * @param arrayValues
1429
1428
  * Matrix values. Matrix is length 1 or contains arrays of length 1 with the values.
1430
1429
  *
1431
1430
  * @param maximumHeight
@@ -1440,7 +1439,7 @@ declare class AppUtilityProxy<ThrowError extends boolean, TError extends ErrorEx
1440
1439
  * @returns
1441
1440
  * Matrix spilled within maximum height and maximum width.
1442
1441
  */
1443
- spill(matrixValues: Matrix<unknown>, maximumHeight: Nullishable<number>, maximumWidth: Nullishable<number>, invocationContext: Nullishable<TInvocationContext>): Promise<MatrixResult<unknown, ThrowError, TError>>;
1442
+ spill(arrayValues: Matrix<unknown>, maximumHeight: Nullishable<number>, maximumWidth: Nullishable<number>, invocationContext: Nullishable<TInvocationContext>): Promise<MatrixResult<unknown, ThrowError, TError>>;
1444
1443
  /**
1445
1444
  * Get the logger messages as a stream.
1446
1445
  *
@@ -1592,6 +1591,7 @@ declare class GMNValidatorProxy<ThrowError extends boolean, TError extends Error
1592
1591
 
1593
1592
  declare class PrefixManagerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
1594
1593
  #private;
1594
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>);
1595
1595
  definePrefix(prefix: string, prefixType: Nullishable<PrefixType>, tweakFactor: Nullishable<number>): Matrix<unknown>;
1596
1596
  gcpLength(identifierType: string, matrixIdentifiers: Matrix<string>): Promise<MatrixResult<number, ThrowError, TError>>;
1597
1597
  gcpLengthDateTime(): Promise<SingletonResult<string, ThrowError, TError>>;
@@ -1747,24 +1747,28 @@ interface Localization {
1747
1747
  /**
1748
1748
  * Name.
1749
1749
  */
1750
- name: string;
1750
+ readonly name: string;
1751
1751
  /**
1752
1752
  * Description.
1753
1753
  */
1754
- description: string;
1754
+ readonly description: string;
1755
1755
  }
1756
1756
  /**
1757
1757
  * Function localization.
1758
1758
  */
1759
1759
  interface FunctionLocalization extends Localization {
1760
+ /**
1761
+ * Namespace function name.
1762
+ */
1763
+ readonly namespaceFunctionName: string;
1760
1764
  /**
1761
1765
  * Documentation URL.
1762
1766
  */
1763
- documentationURL: string;
1767
+ readonly documentationURL: string;
1764
1768
  /**
1765
1769
  * Parameters map.
1766
1770
  */
1767
- parametersMap: Map<string, Localization>;
1771
+ readonly parametersMap: ReadonlyMap<string, Localization>;
1768
1772
  }
1769
1773
  /**
1770
1774
  * Abstract generator.
@@ -1778,6 +1782,10 @@ declare abstract class Generator {
1778
1782
  * Include localizations if true.
1779
1783
  */
1780
1784
  constructor(includeLocalizations?: boolean);
1785
+ /**
1786
+ * Get the logger.
1787
+ */
1788
+ get logger(): Logger<object>;
1781
1789
  /**
1782
1790
  * Get the locales.
1783
1791
  */
@@ -1787,38 +1795,29 @@ declare abstract class Generator {
1787
1795
  */
1788
1796
  protected get defaultLocale(): string;
1789
1797
  /**
1790
- * Get function localization.
1791
- *
1792
- * @param locale
1793
- * Locale.
1794
- *
1795
- * @param namespaceFunctionName
1796
- * Namespace function name.
1797
- *
1798
- * @returns
1799
- * Function localization.
1798
+ * Initialize the generation of the output.
1800
1799
  */
1801
- protected getFunctionLocalization(locale: string, namespaceFunctionName: string): FunctionLocalization;
1800
+ protected abstract initialize(): void;
1802
1801
  /**
1803
- * Get parameter localization.
1802
+ * Create a namespace.
1804
1803
  *
1805
- * @param locale
1806
- * Locale.
1804
+ * @param namespace
1805
+ * Namespace.
1806
+ */
1807
+ protected abstract createNamespace(namespace: string | undefined): void;
1808
+ /**
1809
+ * Create a category.
1807
1810
  *
1808
- * @param namespaceFunctionName
1809
- * Namespace function name.
1811
+ * @param namespace
1812
+ * Namespace.
1810
1813
  *
1811
- * @param parameterName
1812
- * Parameter name.
1814
+ * @param category
1815
+ * Category.
1813
1816
  *
1814
- * @returns
1815
- * Parameter localization.
1817
+ * @param categoryLocalizationsMap
1818
+ * Category localizations map.
1816
1819
  */
1817
- protected getParameterLocalization(locale: string, namespaceFunctionName: string, parameterName: string): Localization;
1818
- /**
1819
- * Initialize the generation of the output.
1820
- */
1821
- protected abstract initialize(): void;
1820
+ protected abstract createCategory(namespace: string | undefined, category: string, categoryLocalizationsMap: ReadonlyMap<string, string>): void;
1822
1821
  /**
1823
1822
  * Create a proxy object for a class.
1824
1823
  *
@@ -1836,7 +1835,7 @@ declare abstract class Generator {
1836
1835
  * Method descriptor.
1837
1836
  *
1838
1837
  * @param functionLocalizationsMap
1839
- * Localizations map.
1838
+ * Function localizations map.
1840
1839
  */
1841
1840
  protected abstract createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor, functionLocalizationsMap: ReadonlyMap<string, FunctionLocalization>): void;
1842
1841
  /**
@@ -1863,4 +1862,4 @@ declare abstract class Generator {
1863
1862
  */
1864
1863
  declare function expandParameterDescriptor(parameterDescriptor: ParameterDescriptor | ExtendsParameterDescriptor): ParameterDescriptor;
1865
1864
 
1866
- export { type Address, AlphabeticProxy, AlphanumericProxy, type AppData, AppExtension, type AppExtensionLocaleResources, AppUtilityProxy, CharacterSetCreatorProxy, CharacterSetValidatorProxy, type ClassDescriptor, type ErrorExtends, type ExtendsParameterDescriptor, type FunctionLocalization, index as GS1, Generator, HexadecimalProxy, LibProxy, type Localization, type Matrix, type MatrixResult, type MethodDescriptor, 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, appExtensionResources, decodeAppData, encodeAppData, expandParameterDescriptor, i18nAppExtensionInit, i18nextAppExtension };
1865
+ export { type Address, AlphabeticProxy, AlphanumericProxy, AppExtension, type AppExtensionLocaleResources, AppHelperProxy, CharacterSetCreatorProxy, CharacterSetValidatorProxy, type ClassDescriptor, type ErrorExtends, type ExtendsParameterDescriptor, type FunctionLocalization, index as GS1, Generator, HexadecimalProxy, LibProxy, type Localization, 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, expandParameterDescriptor, i18nAppExtensionInit, i18nextAppExtension };