@aidc-toolkit/app-extension 1.0.32-beta → 1.0.34-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 (191) hide show
  1. package/README.md +1 -5
  2. package/dist/app-extension.d.ts +194 -0
  3. package/dist/app-extension.d.ts.map +1 -0
  4. package/dist/app-extension.js +133 -0
  5. package/dist/app-extension.js.map +1 -0
  6. package/dist/app-helper-proxy.d.ts +61 -0
  7. package/dist/app-helper-proxy.d.ts.map +1 -0
  8. package/dist/app-helper-proxy.js +332 -0
  9. package/dist/app-helper-proxy.js.map +1 -0
  10. package/dist/descriptor.d.ts +193 -0
  11. package/dist/descriptor.d.ts.map +1 -0
  12. package/dist/descriptor.js +44 -0
  13. package/dist/descriptor.js.map +1 -0
  14. package/dist/generator/generator.d.ts +114 -0
  15. package/dist/generator/generator.d.ts.map +1 -0
  16. package/dist/generator/generator.js +160 -0
  17. package/dist/generator/generator.js.map +1 -0
  18. package/dist/generator/index.d.ts +2 -0
  19. package/dist/generator/index.d.ts.map +1 -0
  20. package/dist/generator/index.js +2 -0
  21. package/dist/generator/index.js.map +1 -0
  22. package/dist/generator/locale-resources-generator.d.ts +2 -0
  23. package/dist/generator/locale-resources-generator.d.ts.map +1 -0
  24. package/dist/generator/locale-resources-generator.js +311 -0
  25. package/dist/generator/locale-resources-generator.js.map +1 -0
  26. package/dist/gs1/character-set-proxy.d.ts +13 -0
  27. package/dist/gs1/character-set-proxy.d.ts.map +1 -0
  28. package/dist/gs1/character-set-proxy.js +126 -0
  29. package/dist/gs1/character-set-proxy.js.map +1 -0
  30. package/dist/gs1/check-proxy.d.ts +11 -0
  31. package/dist/gs1/check-proxy.d.ts.map +1 -0
  32. package/dist/gs1/check-proxy.js +163 -0
  33. package/dist/gs1/check-proxy.js.map +1 -0
  34. package/dist/gs1/gtin-creator-proxy.d.ts +10 -0
  35. package/dist/gs1/gtin-creator-proxy.d.ts.map +1 -0
  36. package/dist/gs1/gtin-creator-proxy.js +85 -0
  37. package/dist/gs1/gtin-creator-proxy.js.map +1 -0
  38. package/dist/gs1/gtin-descriptor.d.ts +3 -0
  39. package/dist/gs1/gtin-descriptor.d.ts.map +1 -0
  40. package/dist/gs1/gtin-descriptor.js +8 -0
  41. package/dist/gs1/gtin-descriptor.js.map +1 -0
  42. package/dist/gs1/gtin-validator-proxy.d.ts +26 -0
  43. package/dist/gs1/gtin-validator-proxy.d.ts.map +1 -0
  44. package/dist/gs1/gtin-validator-proxy.js +256 -0
  45. package/dist/gs1/gtin-validator-proxy.js.map +1 -0
  46. package/dist/gs1/identifier-creator-proxy.d.ts +30 -0
  47. package/dist/gs1/identifier-creator-proxy.d.ts.map +1 -0
  48. package/dist/gs1/identifier-creator-proxy.js +302 -0
  49. package/dist/gs1/identifier-creator-proxy.js.map +1 -0
  50. package/dist/gs1/identifier-descriptor.d.ts +4 -0
  51. package/dist/gs1/identifier-descriptor.d.ts.map +1 -0
  52. package/dist/gs1/identifier-descriptor.js +14 -0
  53. package/dist/gs1/identifier-descriptor.js.map +1 -0
  54. package/dist/gs1/identifier-type.d.ts +22 -0
  55. package/dist/gs1/identifier-type.d.ts.map +1 -0
  56. package/dist/gs1/identifier-type.js +34 -0
  57. package/dist/gs1/identifier-type.js.map +1 -0
  58. package/dist/gs1/identifier-validator-proxy.d.ts +29 -0
  59. package/dist/gs1/identifier-validator-proxy.d.ts.map +1 -0
  60. package/dist/gs1/identifier-validator-proxy.js +212 -0
  61. package/dist/gs1/identifier-validator-proxy.js.map +1 -0
  62. package/dist/gs1/index.d.ts +10 -0
  63. package/dist/gs1/index.d.ts.map +1 -0
  64. package/dist/gs1/index.js +10 -0
  65. package/dist/gs1/index.js.map +1 -0
  66. package/dist/gs1/non-gtin-creator-proxy.d.ts +38 -0
  67. package/dist/gs1/non-gtin-creator-proxy.d.ts.map +1 -0
  68. package/dist/gs1/non-gtin-creator-proxy.js +301 -0
  69. package/dist/gs1/non-gtin-creator-proxy.js.map +1 -0
  70. package/dist/gs1/non-gtin-validator-proxy.d.ts +37 -0
  71. package/dist/gs1/non-gtin-validator-proxy.d.ts.map +1 -0
  72. package/dist/gs1/non-gtin-validator-proxy.js +302 -0
  73. package/dist/gs1/non-gtin-validator-proxy.js.map +1 -0
  74. package/dist/gs1/prefix-definition-descriptor.d.ts +4 -0
  75. package/dist/gs1/prefix-definition-descriptor.d.ts.map +1 -0
  76. package/dist/gs1/prefix-definition-descriptor.js +16 -0
  77. package/dist/gs1/prefix-definition-descriptor.js.map +1 -0
  78. package/dist/gs1/prefix-manager-proxy.d.ts +14 -0
  79. package/dist/gs1/prefix-manager-proxy.d.ts.map +1 -0
  80. package/dist/gs1/prefix-manager-proxy.js +213 -0
  81. package/dist/gs1/prefix-manager-proxy.js.map +1 -0
  82. package/dist/gs1/service-proxy.d.ts +7 -0
  83. package/dist/gs1/service-proxy.d.ts.map +1 -0
  84. package/dist/gs1/service-proxy.js +105 -0
  85. package/dist/gs1/service-proxy.js.map +1 -0
  86. package/dist/gs1/variable-measure-proxy.d.ts +7 -0
  87. package/dist/gs1/variable-measure-proxy.d.ts.map +1 -0
  88. package/dist/gs1/variable-measure-proxy.js +114 -0
  89. package/dist/gs1/variable-measure-proxy.js.map +1 -0
  90. package/dist/index.d.ts +28 -1866
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +10 -6508
  93. package/dist/index.js.map +1 -1
  94. package/dist/lib-proxy.d.ts +135 -0
  95. package/dist/lib-proxy.d.ts.map +1 -0
  96. package/dist/lib-proxy.js +276 -0
  97. package/dist/lib-proxy.js.map +1 -0
  98. package/dist/locale/en/locale-resources.d.ts +752 -0
  99. package/dist/locale/en/locale-resources.d.ts.map +1 -0
  100. package/dist/locale/en/locale-resources.js +751 -0
  101. package/dist/locale/en/locale-resources.js.map +1 -0
  102. package/dist/locale/fr/locale-resources.d.ts +752 -0
  103. package/dist/locale/fr/locale-resources.d.ts.map +1 -0
  104. package/dist/locale/fr/locale-resources.js +751 -0
  105. package/dist/locale/fr/locale-resources.js.map +1 -0
  106. package/dist/locale/i18n.d.ts +27 -0
  107. package/dist/locale/i18n.d.ts.map +1 -0
  108. package/dist/locale/i18n.js +36 -0
  109. package/dist/locale/i18n.js.map +1 -0
  110. package/dist/proxy.d.ts +136 -0
  111. package/dist/proxy.d.ts.map +1 -0
  112. package/dist/proxy.js +319 -0
  113. package/dist/proxy.js.map +1 -0
  114. package/dist/streaming.d.ts +10 -0
  115. package/dist/streaming.d.ts.map +1 -0
  116. package/dist/streaming.js +2 -0
  117. package/dist/streaming.js.map +1 -0
  118. package/dist/type.d.ts +91 -0
  119. package/dist/type.d.ts.map +1 -0
  120. package/dist/type.js +2 -0
  121. package/dist/type.js.map +1 -0
  122. package/dist/utility/character-set-descriptor.d.ts +6 -0
  123. package/dist/utility/character-set-descriptor.d.ts.map +1 -0
  124. package/dist/utility/character-set-descriptor.js +28 -0
  125. package/dist/utility/character-set-descriptor.js.map +1 -0
  126. package/dist/utility/character-set-proxy.d.ts +31 -0
  127. package/dist/utility/character-set-proxy.d.ts.map +1 -0
  128. package/dist/utility/character-set-proxy.js +278 -0
  129. package/dist/utility/character-set-proxy.js.map +1 -0
  130. package/dist/utility/index.d.ts +4 -0
  131. package/dist/utility/index.d.ts.map +1 -0
  132. package/dist/utility/index.js +4 -0
  133. package/dist/utility/index.js.map +1 -0
  134. package/dist/utility/reg-exp-proxy.d.ts +8 -0
  135. package/dist/utility/reg-exp-proxy.d.ts.map +1 -0
  136. package/dist/utility/reg-exp-proxy.js +103 -0
  137. package/dist/utility/reg-exp-proxy.js.map +1 -0
  138. package/dist/utility/string-descriptor.d.ts +4 -0
  139. package/dist/utility/string-descriptor.d.ts.map +1 -0
  140. package/dist/utility/string-descriptor.js +12 -0
  141. package/dist/utility/string-descriptor.js.map +1 -0
  142. package/dist/utility/string-proxy.d.ts +7 -0
  143. package/dist/utility/string-proxy.d.ts.map +1 -0
  144. package/dist/utility/string-proxy.js +63 -0
  145. package/dist/utility/string-proxy.js.map +1 -0
  146. package/dist/utility/transformer-descriptor.d.ts +6 -0
  147. package/dist/utility/transformer-descriptor.d.ts.map +1 -0
  148. package/dist/utility/transformer-descriptor.js +24 -0
  149. package/dist/utility/transformer-descriptor.js.map +1 -0
  150. package/dist/utility/transformer-proxy.d.ts +9 -0
  151. package/dist/utility/transformer-proxy.d.ts.map +1 -0
  152. package/dist/utility/transformer-proxy.js +111 -0
  153. package/dist/utility/transformer-proxy.js.map +1 -0
  154. package/package.json +13 -12
  155. package/src/app-extension.ts +26 -47
  156. package/src/{app-utility-proxy.ts → app-helper-proxy.ts} +21 -19
  157. package/src/descriptor.ts +43 -2
  158. package/src/generator/generator.ts +122 -95
  159. package/src/generator/locale-resources-generator.ts +26 -14
  160. package/src/gs1/check-proxy.ts +12 -11
  161. package/src/gs1/gtin-creator-proxy.ts +2 -3
  162. package/src/gs1/gtin-descriptor.ts +2 -2
  163. package/src/gs1/gtin-validator-proxy.ts +12 -14
  164. package/src/gs1/identifier-creator-proxy.ts +19 -21
  165. package/src/gs1/identifier-descriptor.ts +3 -3
  166. package/src/gs1/identifier-validator-proxy.ts +15 -16
  167. package/src/gs1/non-gtin-creator-proxy.ts +0 -11
  168. package/src/gs1/non-gtin-validator-proxy.ts +0 -11
  169. package/src/gs1/prefix-definition-descriptor.ts +2 -2
  170. package/src/gs1/prefix-manager-proxy.ts +80 -120
  171. package/src/gs1/service-proxy.ts +6 -5
  172. package/src/gs1/variable-measure-proxy.ts +9 -8
  173. package/src/index.ts +3 -3
  174. package/src/locale/en/locale-resources.ts +28 -15
  175. package/src/locale/fr/locale-resources.ts +28 -15
  176. package/src/locale/i18n.ts +10 -9
  177. package/src/locale/i18next.d.ts +2 -0
  178. package/src/proxy.ts +64 -40
  179. package/src/utility/character-set-descriptor.ts +2 -2
  180. package/src/utility/character-set-proxy.ts +7 -7
  181. package/src/utility/reg-exp-proxy.ts +5 -5
  182. package/src/utility/string-descriptor.ts +2 -2
  183. package/src/utility/string-proxy.ts +4 -0
  184. package/src/utility/transformer-descriptor.ts +5 -5
  185. package/src/utility/transformer-proxy.ts +6 -5
  186. package/tsconfig-src.json +7 -1
  187. package/tsconfig-src.tsbuildinfo +1 -0
  188. package/dist/index.cjs +0 -6544
  189. package/dist/index.cjs.map +0 -1
  190. package/dist/index.d.cts +0 -1866
  191. package/src/app-data.ts +0 -94
@@ -0,0 +1,135 @@
1
+ import type { AppExtension } from "./app-extension.js";
2
+ import type { ErrorExtends, Matrix, MatrixResult, SingletonResult } from "./type.js";
3
+ /**
4
+ * Library proxy.
5
+ *
6
+ * @template ThrowError
7
+ * If true, errors are reported through the throw/catch mechanism.
8
+ *
9
+ * @template TError
10
+ * Error type.
11
+ *
12
+ * @template TInvocationContext
13
+ * Application-specific invocation context type.
14
+ *
15
+ * @template TStreamingInvocationContext
16
+ * Application-specific streaming invocation context type.
17
+ *
18
+ * @template TBigInt
19
+ * Type to which big integer is mapped.
20
+ */
21
+ export declare abstract class LibProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> {
22
+ #private;
23
+ /**
24
+ * Constructor.
25
+ *
26
+ * @param appExtension
27
+ * Application extension.
28
+ */
29
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>);
30
+ /**
31
+ * Get the application extension.
32
+ */
33
+ get appExtension(): AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>;
34
+ /**
35
+ * Map big integer to another type if necessary.
36
+ *
37
+ * @param value
38
+ * Big integer value to map.
39
+ *
40
+ * @returns
41
+ * Mapped big integer value.
42
+ */
43
+ mapBigInt(value: bigint): SingletonResult<TBigInt, ThrowError, TError>;
44
+ /**
45
+ * Call a singleton result function with error handling.
46
+ *
47
+ * @param callback
48
+ * Callback.
49
+ *
50
+ * @returns
51
+ * Callback return or error if errors are not thrown.
52
+ */
53
+ singletonResult<TResult>(callback: () => SingletonResult<TResult, ThrowError, TError>): SingletonResult<TResult, ThrowError, TError>;
54
+ /**
55
+ * Call a matrix result function with error handling.
56
+ *
57
+ * @param matrixValues
58
+ * Matrix of values.
59
+ *
60
+ * @param valueCallback
61
+ * Callback to process value.
62
+ *
63
+ * @returns
64
+ * Matrix of callback results and errors if errors are not thrown.
65
+ */
66
+ protected matrixResult<TValue, TResult>(matrixValues: Matrix<TValue>, valueCallback: (value: TValue) => SingletonResult<TResult, ThrowError, TError>): MatrixResult<TResult, ThrowError, TError>;
67
+ /**
68
+ * Map a matrix of validate string results to boolean. If the string is empty, the result is true, indicating that
69
+ * there is no error.
70
+ *
71
+ * @param matrixValidateResults
72
+ * Matrix of results from a call to a validate function.
73
+ *
74
+ * @returns
75
+ * Matrix of boolean values, true if corresponding string is empty.
76
+ */
77
+ protected isValidString(matrixValidateResults: MatrixResult<string, ThrowError, TError>): Matrix<boolean>;
78
+ /**
79
+ * Set up a mapping and call a matrix result function with error handling.
80
+ *
81
+ * @param setUpCallback
82
+ * Callback to set up the mapping.
83
+ *
84
+ * @param matrixValues
85
+ * Matrix of values.
86
+ *
87
+ * @param valueCallback
88
+ * Callback to process value.
89
+ *
90
+ * @returns
91
+ * Matrix of callback results and errors if errors are not thrown.
92
+ */
93
+ protected setUpMatrixResult<TSetup, TValue, TResult>(setUpCallback: () => TSetup, matrixValues: Matrix<TValue>, valueCallback: (setup: TSetup, value: TValue) => SingletonResult<TResult, ThrowError, TError>): MatrixResult<TResult, ThrowError, TError>;
94
+ /**
95
+ * Call an array result function with error handling and map to a matrix.
96
+ *
97
+ * @param matrixValues
98
+ * Matrix of values.
99
+ *
100
+ * @param callback
101
+ * Callback.
102
+ *
103
+ * @returns
104
+ * Matrix of callback results and errors if errors are not thrown.
105
+ */
106
+ protected arrayResult<TValue, TResult>(matrixValues: Matrix<TValue>, callback: (value: TValue) => Array<SingletonResult<TResult, ThrowError, TError>>): MatrixResult<TResult, ThrowError, TError>;
107
+ /**
108
+ * Call a matrix result function with error handling and map a non-error result to an empty string and {@linkcode
109
+ * RangeError} to the string error message.
110
+ *
111
+ * @param matrixValues
112
+ * Matrix of values.
113
+ *
114
+ * @param callback
115
+ * Callback that either returns or throws an exception.
116
+ *
117
+ * @returns
118
+ * Matrix of strings.
119
+ */
120
+ protected matrixErrorResult<TValue>(matrixValues: Matrix<TValue>, callback: (value: TValue) => void): Matrix<string>;
121
+ /**
122
+ * Call an iterable result function with error handling and map to a matrix. Although the natural approach would be
123
+ * to map to a single-element array containing an array of *N* results (i.e., [[r0, r1, r2, ..., r*N*]]), this is
124
+ * rendered visually as a single row. The more readable approach is as a single column, so the mapping is to an
125
+ * *N*-element array of single-element result arrays (i.e., [[r0], [r1], [r2], ..., [r*N*]]).
126
+ *
127
+ * @param iterableCallback
128
+ * Iterable callback.
129
+ *
130
+ * @returns
131
+ * Matrix of callback results.
132
+ */
133
+ protected iterableResult<TResult>(iterableCallback: () => Iterable<SingletonResult<TResult, ThrowError, TError>>): MatrixResult<TResult, ThrowError, TError>;
134
+ }
135
+ //# sourceMappingURL=lib-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib-proxy.d.ts","sourceRoot":"","sources":["../src/lib-proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAErF;;;;;;;;;;;;;;;;;GAiBG;AACH,8BAAsB,QAAQ,CAAC,UAAU,SAAS,OAAO,EAAE,MAAM,SAAS,YAAY,CAAC,UAAU,CAAC,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,OAAO;;IAMxJ;;;;;OAKG;gBACS,YAAY,EAAE,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,OAAO,CAAC;IAIpH;;OAEG;IACH,IAAI,YAAY,IAAI,YAAY,CAAC,UAAU,EAAE,MAAM,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,MAAM,KAAK,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC;IA0CjM;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAuBpH;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC;CAW/J"}
@@ -0,0 +1,276 @@
1
+ import { mapIterable } from "@aidc-toolkit/utility";
2
+ import { i18nextAppExtension } from "./locale/i18n.js";
3
+ /**
4
+ * Library proxy.
5
+ *
6
+ * @template ThrowError
7
+ * If true, errors are reported through the throw/catch mechanism.
8
+ *
9
+ * @template TError
10
+ * Error type.
11
+ *
12
+ * @template TInvocationContext
13
+ * Application-specific invocation context type.
14
+ *
15
+ * @template TStreamingInvocationContext
16
+ * Application-specific streaming invocation context type.
17
+ *
18
+ * @template TBigInt
19
+ * Type to which big integer is mapped.
20
+ */
21
+ export class LibProxy {
22
+ /**
23
+ * Application extension.
24
+ */
25
+ #appExtension;
26
+ /**
27
+ * Constructor.
28
+ *
29
+ * @param appExtension
30
+ * Application extension.
31
+ */
32
+ constructor(appExtension) {
33
+ this.#appExtension = appExtension;
34
+ }
35
+ /**
36
+ * Get the application extension.
37
+ */
38
+ get appExtension() {
39
+ return this.#appExtension;
40
+ }
41
+ /**
42
+ * Map big integer to another type if necessary.
43
+ *
44
+ * @param value
45
+ * Big integer value to map.
46
+ *
47
+ * @returns
48
+ * Mapped big integer value.
49
+ */
50
+ mapBigInt(value) {
51
+ return this.#appExtension.mapBigInt(value);
52
+ }
53
+ /**
54
+ * Handle an error thrown by a function call. Return type is {@linkcode SingletonResult} to ensure assignment
55
+ * compatibility.
56
+ *
57
+ * @param e
58
+ * Error.
59
+ *
60
+ * @returns
61
+ * Error if errors are not thrown.
62
+ */
63
+ #handleError(e) {
64
+ let result;
65
+ if (e instanceof RangeError) {
66
+ const error = this.#appExtension.mapRangeError(e);
67
+ if (this.#appExtension.throwError) {
68
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is determined by application mapping.
69
+ throw error;
70
+ }
71
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Won't get here if ThrowError is false so result is TError.
72
+ result = error;
73
+ }
74
+ else {
75
+ // Unknown error; pass on to application extension.
76
+ result = this.appExtension.handleError(e instanceof Error ? e.message : String(e));
77
+ }
78
+ return result;
79
+ }
80
+ /**
81
+ * Call a singleton result function with error handling.
82
+ *
83
+ * @param callback
84
+ * Callback.
85
+ *
86
+ * @returns
87
+ * Callback return or error if errors are not thrown.
88
+ */
89
+ singletonResult(callback) {
90
+ let result;
91
+ try {
92
+ result = callback();
93
+ }
94
+ catch (e) {
95
+ result = this.#handleError(e);
96
+ }
97
+ return result;
98
+ }
99
+ /**
100
+ * Call a matrix result function with error handling.
101
+ *
102
+ * @param matrixValues
103
+ * Matrix of values.
104
+ *
105
+ * @param valueCallback
106
+ * Callback to process value.
107
+ *
108
+ * @returns
109
+ * Matrix of callback results and errors if errors are not thrown.
110
+ */
111
+ matrixResult(matrixValues, valueCallback) {
112
+ return matrixValues.map(rowValues => rowValues.map(value => this.singletonResult(() => valueCallback(value))));
113
+ }
114
+ /**
115
+ * Map a matrix of validate string results to boolean. If the string is empty, the result is true, indicating that
116
+ * there is no error.
117
+ *
118
+ * @param matrixValidateResults
119
+ * Matrix of results from a call to a validate function.
120
+ *
121
+ * @returns
122
+ * Matrix of boolean values, true if corresponding string is empty.
123
+ */
124
+ isValidString(matrixValidateResults) {
125
+ return matrixValidateResults.map(rowValues => rowValues.map(value => (validateResult => validateResult === "")(value)));
126
+ }
127
+ /**
128
+ * Set up a mapping and call a matrix result function with error handling.
129
+ *
130
+ * @param setUpCallback
131
+ * Callback to set up the mapping.
132
+ *
133
+ * @param matrixValues
134
+ * Matrix of values.
135
+ *
136
+ * @param valueCallback
137
+ * Callback to process value.
138
+ *
139
+ * @returns
140
+ * Matrix of callback results and errors if errors are not thrown.
141
+ */
142
+ setUpMatrixResult(setUpCallback, matrixValues, valueCallback) {
143
+ let result;
144
+ try {
145
+ result = matrixValues.map(rowValues => rowValues.map(value => this.singletonResult(() => valueCallback(setUpCallback(), value))));
146
+ }
147
+ catch (e) {
148
+ result = [[this.#handleError(e)]];
149
+ }
150
+ return result;
151
+ }
152
+ /**
153
+ * Do the callback for an array return.
154
+ *
155
+ * @param value
156
+ * Value.
157
+ *
158
+ * @param callback
159
+ * Callback.
160
+ *
161
+ * @returns
162
+ * Callback result or error as array if errors are not thrown.
163
+ */
164
+ #arrayCallback(value, callback) {
165
+ const result = this.singletonResult(() => callback(value));
166
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- If result is not an array, it must be an error.
167
+ return result instanceof Array ? result : [result];
168
+ }
169
+ /**
170
+ * Call an array result function with error handling and map to a matrix.
171
+ *
172
+ * @param matrixValues
173
+ * Matrix of values.
174
+ *
175
+ * @param callback
176
+ * Callback.
177
+ *
178
+ * @returns
179
+ * Matrix of callback results and errors if errors are not thrown.
180
+ */
181
+ arrayResult(matrixValues, callback) {
182
+ let result;
183
+ if (matrixValues.length === 0) {
184
+ // Special case; unlikely to occur.
185
+ result = [[]];
186
+ }
187
+ else if (matrixValues.length === 1) {
188
+ result = [];
189
+ matrixValues[0].forEach((value, columnIndex) => {
190
+ const arrayResult = this.#arrayCallback(value, callback);
191
+ arrayResult.forEach((resultError, rowIndex) => {
192
+ // Append a row if necessary.
193
+ if (result.length <= rowIndex) {
194
+ result.push([]);
195
+ }
196
+ // Assignment will automatically expand row to the number of columns in the matrix.
197
+ result[rowIndex][columnIndex] = resultError;
198
+ });
199
+ });
200
+ }
201
+ else {
202
+ result = matrixValues.map((rowValue) => {
203
+ let arrayResult;
204
+ if (rowValue.length === 0) {
205
+ // Special case; unlikely to occur.
206
+ arrayResult = [];
207
+ }
208
+ else if (rowValue.length === 1) {
209
+ arrayResult = this.#arrayCallback(rowValue[0], callback);
210
+ }
211
+ else {
212
+ arrayResult = [this.#handleError(new RangeError(i18nextAppExtension.t("Proxy.matrixMustBeArray")))];
213
+ }
214
+ return arrayResult;
215
+ });
216
+ }
217
+ return result;
218
+ }
219
+ /**
220
+ * Call a matrix result function with error handling and map a non-error result to an empty string and {@linkcode
221
+ * RangeError} to the string error message.
222
+ *
223
+ * @param matrixValues
224
+ * Matrix of values.
225
+ *
226
+ * @param callback
227
+ * Callback that either returns or throws an exception.
228
+ *
229
+ * @returns
230
+ * Matrix of strings.
231
+ */
232
+ matrixErrorResult(matrixValues, callback) {
233
+ return matrixValues.map(rowValues => rowValues.map((value) => {
234
+ let result;
235
+ try {
236
+ callback(value);
237
+ // No error; return empty string.
238
+ result = "";
239
+ }
240
+ catch (e) {
241
+ if (e instanceof RangeError) {
242
+ // Library error; return error message.
243
+ result = e.message;
244
+ }
245
+ else {
246
+ // Unknown error; pass up the stack.
247
+ throw e;
248
+ }
249
+ }
250
+ return result;
251
+ }));
252
+ }
253
+ /**
254
+ * Call an iterable result function with error handling and map to a matrix. Although the natural approach would be
255
+ * to map to a single-element array containing an array of *N* results (i.e., [[r0, r1, r2, ..., r*N*]]), this is
256
+ * rendered visually as a single row. The more readable approach is as a single column, so the mapping is to an
257
+ * *N*-element array of single-element result arrays (i.e., [[r0], [r1], [r2], ..., [r*N*]]).
258
+ *
259
+ * @param iterableCallback
260
+ * Iterable callback.
261
+ *
262
+ * @returns
263
+ * Matrix of callback results.
264
+ */
265
+ iterableResult(iterableCallback) {
266
+ let result;
267
+ try {
268
+ result = Array.from(mapIterable(iterableCallback(), result => [result]));
269
+ }
270
+ catch (e) {
271
+ result = [[this.#handleError(e)]];
272
+ }
273
+ return result;
274
+ }
275
+ }
276
+ //# sourceMappingURL=lib-proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib-proxy.js","sourceRoot":"","sources":["../src/lib-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,QAAQ;IAC1B;;OAEG;IACM,aAAa,CAA6F;IAEnH;;;;;OAKG;IACH,YAAY,YAAwG;QAChH,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,KAAa;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;OASG;IACH,YAAY,CAAU,CAAU;QAC5B,IAAI,MAAoD,CAAC;QAEzD,IAAI,CAAC,YAAY,UAAU,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAElD,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;gBAChC,qHAAqH;gBACrH,MAAM,KAAc,CAAC;YACzB,CAAC;YAED,qIAAqI;YACrI,MAAM,GAAG,KAAqD,CAAC;QACnE,CAAC;aAAM,CAAC;YACJ,mDAAmD;YACnD,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM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