@aidc-toolkit/utility 1.0.45 → 1.0.46-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 (59) hide show
  1. package/dist/character-set.d.ts +242 -0
  2. package/dist/character-set.d.ts.map +1 -0
  3. package/dist/character-set.js +542 -0
  4. package/dist/character-set.js.map +1 -0
  5. package/dist/exclusion.d.ts +26 -0
  6. package/dist/exclusion.d.ts.map +1 -0
  7. package/dist/exclusion.js +18 -0
  8. package/dist/exclusion.js.map +1 -0
  9. package/dist/index.d.ts +26 -683
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +9 -1
  12. package/dist/index.js.map +1 -0
  13. package/dist/iterable-utility.d.ts +39 -0
  14. package/dist/iterable-utility.d.ts.map +1 -0
  15. package/dist/iterable-utility.js +35 -0
  16. package/dist/iterable-utility.js.map +1 -0
  17. package/dist/locale/en/locale-resources.d.ts +33 -0
  18. package/dist/locale/en/locale-resources.d.ts.map +1 -0
  19. package/dist/locale/en/locale-resources.js +32 -0
  20. package/dist/locale/en/locale-resources.js.map +1 -0
  21. package/dist/locale/fr/locale-resources.d.ts +33 -0
  22. package/dist/locale/fr/locale-resources.d.ts.map +1 -0
  23. package/dist/locale/fr/locale-resources.js +32 -0
  24. package/dist/locale/fr/locale-resources.js.map +1 -0
  25. package/dist/locale/i18n.d.ts +27 -0
  26. package/dist/locale/i18n.d.ts.map +1 -0
  27. package/dist/locale/i18n.js +34 -0
  28. package/dist/locale/i18n.js.map +1 -0
  29. package/dist/record.d.ts +37 -0
  30. package/dist/record.d.ts.map +1 -0
  31. package/dist/record.js +58 -0
  32. package/dist/record.js.map +1 -0
  33. package/dist/reg-exp.d.ts +40 -0
  34. package/dist/reg-exp.d.ts.map +1 -0
  35. package/dist/reg-exp.js +55 -0
  36. package/dist/reg-exp.js.map +1 -0
  37. package/dist/sequence.d.ts +45 -0
  38. package/dist/sequence.d.ts.map +1 -0
  39. package/dist/sequence.js +96 -0
  40. package/dist/sequence.js.map +1 -0
  41. package/dist/string.d.ts +25 -0
  42. package/dist/string.d.ts.map +1 -0
  43. package/dist/string.js +2 -0
  44. package/dist/string.js.map +1 -0
  45. package/dist/transformer.d.ts +191 -0
  46. package/dist/transformer.d.ts.map +1 -0
  47. package/dist/transformer.js +459 -0
  48. package/dist/transformer.js.map +1 -0
  49. package/dist/version.d.ts +5 -0
  50. package/dist/version.d.ts.map +1 -0
  51. package/dist/version.js +5 -0
  52. package/dist/version.js.map +1 -0
  53. package/package.json +3 -3
  54. package/src/character-set.ts +47 -20
  55. package/src/transformer.ts +57 -56
  56. package/src/version.ts +1 -1
  57. package/tsconfig-src.tsbuildinfo +1 -1
  58. package/dist/index.cjs +0 -17
  59. package/dist/index.d.cts +0 -683
@@ -0,0 +1,242 @@
1
+ import { type Exclusion } from "./exclusion.js";
2
+ import type { IndexedCallback } from "./iterable-utility.js";
3
+ import type { StringValidation, StringValidator } from "./string.js";
4
+ /**
5
+ * Character set validation parameters.
6
+ */
7
+ export interface CharacterSetValidation extends StringValidation {
8
+ /**
9
+ * Minimum length. If defined and the string is less than this length, an error is thrown.
10
+ */
11
+ minimumLength?: number | undefined;
12
+ /**
13
+ * Maximum length. If defined and the string is greater than this length, an error is thrown.
14
+ */
15
+ maximumLength?: number | undefined;
16
+ /**
17
+ * Exclusion from the string. If defined and the string is within the exclusion range, an error is thrown.
18
+ */
19
+ exclusion?: Exclusion | undefined;
20
+ /**
21
+ * Position offset within a larger string. Strings are sometimes composed of multiple substrings; this parameter
22
+ * ensures that the error notes the proper position in the string.
23
+ */
24
+ positionOffset?: number | undefined;
25
+ /**
26
+ * Name of component, typically but not exclusively within a larger string. This parameter ensure that the
27
+ * error notes the component that triggered it. Value may be a string or a callback that returns a string, the
28
+ * latter allowing for localization changes.
29
+ */
30
+ component?: string | (() => string) | undefined;
31
+ }
32
+ /**
33
+ * Character set validator. Validates a string against a specified character set.
34
+ */
35
+ export declare class CharacterSetValidator implements StringValidator<CharacterSetValidation> {
36
+ #private;
37
+ /**
38
+ * Constructor.
39
+ *
40
+ * @param characterSet
41
+ * Character set. Each element is a single-character string, unique within the array, that defines the character
42
+ * set.
43
+ *
44
+ * @param exclusionSupport
45
+ * Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
46
+ */
47
+ constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]);
48
+ /**
49
+ * Get the character set.
50
+ */
51
+ get characterSet(): readonly string[];
52
+ /**
53
+ * Get the character set size.
54
+ */
55
+ get characterSetSize(): number;
56
+ /**
57
+ * Get the exclusions supported by the character set.
58
+ */
59
+ get exclusionSupport(): readonly Exclusion[];
60
+ /**
61
+ * Get the character at an index.
62
+ *
63
+ * @param index
64
+ * Index into the character set.
65
+ *
66
+ * @returns
67
+ * Character at the index.
68
+ */
69
+ character(index: number): string;
70
+ /**
71
+ * Get the index for a character.
72
+ *
73
+ * @param c
74
+ * Character.
75
+ *
76
+ * @returns
77
+ * Index for the character or undefined if the character is not in the character set.
78
+ */
79
+ characterIndex(c: string): number | undefined;
80
+ /**
81
+ * Get the indexes for all characters in a string.
82
+ *
83
+ * @param s
84
+ * String.
85
+ *
86
+ * @returns
87
+ * Array of indexes for each character or undefined if the character is not in the character set.
88
+ */
89
+ characterIndexes(s: string): ReadonlyArray<number | undefined>;
90
+ /**
91
+ * Validate that an exclusion is supported. If not, an error is thrown.
92
+ *
93
+ * @param exclusion
94
+ * Exclusion.
95
+ */
96
+ protected validateExclusion(exclusion: Exclusion | undefined): void;
97
+ /**
98
+ * Validate a string. If the string violates the character set or any of the character set validation parameters, an
99
+ * error is thrown.
100
+ *
101
+ * @param s
102
+ * String.
103
+ *
104
+ * @param validation
105
+ * Character set validation parameters.
106
+ */
107
+ validate(s: string, validation?: CharacterSetValidation): void;
108
+ }
109
+ /**
110
+ * Character set creator. Maps numeric values to strings using the character set as digits.
111
+ */
112
+ export declare class CharacterSetCreator extends CharacterSetValidator {
113
+ #private;
114
+ /**
115
+ * Maximum string length supported.
116
+ */
117
+ static readonly MAXIMUM_STRING_LENGTH = 40;
118
+ /**
119
+ * Get a power of 10.
120
+ *
121
+ * @param power
122
+ * Power.
123
+ *
124
+ * @returns
125
+ * `10**power`.
126
+ */
127
+ static powerOf10(power: number): bigint;
128
+ /**
129
+ * Constructor.
130
+ *
131
+ * @param characterSet
132
+ * Character set. Each element is a single-character string, unique within the array, that defines the character
133
+ * set.
134
+ *
135
+ * @param exclusionSupport
136
+ * Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
137
+ */
138
+ constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]);
139
+ /**
140
+ * Create a string by mapping a value to the equivalent characters in the character set across the required string
141
+ * length.
142
+ *
143
+ * @param length
144
+ * Required string length.
145
+ *
146
+ * @param value
147
+ * Numeric value of the string.
148
+ *
149
+ * @param exclusion
150
+ * Strings to be excluded from the output range. See {@linkcode Exclusions} for possible values and their meanings.
151
+ *
152
+ * @param tweak
153
+ * If provided, the numeric value of the string is "tweaked" using an {@link EncryptionTransformer | encryption
154
+ * transformer}.
155
+ *
156
+ * @param creatorCallback
157
+ * Called after the string is constructed to create the final value.
158
+ *
159
+ * @returns
160
+ * String created from the value.
161
+ */
162
+ create(length: number, value: number | bigint, exclusion?: Exclusion, tweak?: number | bigint, creatorCallback?: IndexedCallback<string, string>): string;
163
+ /**
164
+ * Create strings by mapping values to the equivalent characters in the character set across the required string
165
+ * length.
166
+ *
167
+ * @param length
168
+ * Required string length.
169
+ *
170
+ * @param values
171
+ * Numeric values of the string.
172
+ *
173
+ * @param exclusion
174
+ * Strings to be excluded from the output range. See {@linkcode Exclusions} for possible values and their meanings.
175
+ *
176
+ * @param tweak
177
+ * If provided, the numeric value of each string is "tweaked" using an {@link EncryptionTransformer | encryption
178
+ * transformer}.
179
+ *
180
+ * @param creatorCallback
181
+ * Called after each string is constructed to create the final value.
182
+ *
183
+ * @returns
184
+ * Strings created from the values.
185
+ */
186
+ create(length: number, values: Iterable<number | bigint>, exclusion?: Exclusion, tweak?: number | bigint, creatorCallback?: IndexedCallback<string, string>): Iterable<string>;
187
+ create<TInput extends number | bigint | Iterable<number | bigint>>(length: number, valueOrValues: TInput extends Iterable<number | bigint> ? TInput : number | bigint, exclusion?: Exclusion, tweak?: number | bigint, creatorCallback?: IndexedCallback<string, string>): TInput extends Iterable<number | bigint> ? Iterable<string> : string;
188
+ /**
189
+ * Determine the value for a string.
190
+ *
191
+ * @param s
192
+ * String.
193
+ *
194
+ * @param exclusion
195
+ * Strings excluded from the input domain. See {@linkcode Exclusions} for possible values and their meanings.
196
+ *
197
+ * @param tweak
198
+ * If provided, the numerical value of the string was "tweaked" using an {@link EncryptionTransformer | encryption
199
+ * transformer}.
200
+ *
201
+ * @returns
202
+ * Numeric value of the string.
203
+ */
204
+ valueFor(s: string, exclusion?: Exclusion, tweak?: number | bigint): bigint;
205
+ }
206
+ /**
207
+ * Numeric creator. Character set is 0-9. Supports {@linkcode Exclusions.FirstZero}.
208
+ */
209
+ export declare const NUMERIC_CREATOR: CharacterSetCreator;
210
+ /**
211
+ * Numeric validator. Character set is 0-9. Supports {@linkcode Exclusions.FirstZero}.
212
+ */
213
+ export declare const NUMERIC_VALIDATOR: CharacterSetValidator;
214
+ /**
215
+ * Hexadecimal creator. Character set is 0-9, A-F. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
216
+ * Exclusions.AllNumeric}.
217
+ */
218
+ export declare const HEXADECIMAL_CREATOR: CharacterSetCreator;
219
+ /**
220
+ * Hexadecimal validator. Character set is 0-9, A-F. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
221
+ * Exclusions.AllNumeric}.
222
+ */
223
+ export declare const HEXADECIMAL_VALIDATOR: CharacterSetValidator;
224
+ /**
225
+ * Alphabetic creator. Character set is A-Z.
226
+ */
227
+ export declare const ALPHABETIC_CREATOR: CharacterSetCreator;
228
+ /**
229
+ * Alphabetic validator. Character set is A-Z.
230
+ */
231
+ export declare const ALPHABETIC_VALIDATOR: CharacterSetValidator;
232
+ /**
233
+ * Alphanumeric creator. Character set is 0-9, A-Z. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
234
+ * Exclusions.AllNumeric}.
235
+ */
236
+ export declare const ALPHANUMERIC_CREATOR: CharacterSetCreator;
237
+ /**
238
+ * Alphanumeric validator. Character set is 0-9, A-Z. Supports {@linkcode Exclusions.FirstZero} and {@linkcode
239
+ * Exclusions.AllNumeric}.
240
+ */
241
+ export declare const ALPHANUMERIC_VALIDATOR: CharacterSetValidator;
242
+ //# sourceMappingURL=character-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"character-set.d.ts","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC5D;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;CACnD;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,eAAe,CAAC,sBAAsB,CAAC;;IAgCjF;;;;;;;;;OASG;gBACS,YAAY,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,gBAAgB,EAAE,SAAS,SAAS,EAAE;IActF;;OAEG;IACH,IAAI,YAA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