@aidc-toolkit/core 1.0.41 → 1.0.43-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 (83) hide show
  1. package/dist/app-data-storage.d.ts +118 -0
  2. package/dist/app-data-storage.d.ts.map +1 -0
  3. package/dist/app-data-storage.js +117 -0
  4. package/dist/app-data-storage.js.map +1 -0
  5. package/dist/app-data.d.ts +26 -0
  6. package/dist/app-data.d.ts.map +1 -0
  7. package/dist/app-data.js +79 -0
  8. package/dist/app-data.js.map +1 -0
  9. package/dist/browser-app-data-storage.d.ts +26 -0
  10. package/dist/browser-app-data-storage.d.ts.map +1 -0
  11. package/dist/browser-app-data-storage.js +34 -0
  12. package/dist/browser-app-data-storage.js.map +1 -0
  13. package/dist/cache.d.ts +58 -0
  14. package/dist/cache.d.ts.map +1 -0
  15. package/dist/cache.js +12 -0
  16. package/dist/cache.js.map +1 -0
  17. package/dist/file-app-data-storage.d.ts +27 -0
  18. package/dist/file-app-data-storage.d.ts.map +1 -0
  19. package/dist/file-app-data-storage.js +52 -0
  20. package/dist/file-app-data-storage.js.map +1 -0
  21. package/dist/http-fetch.d.ts +45 -0
  22. package/dist/http-fetch.d.ts.map +1 -0
  23. package/dist/http-fetch.js +26 -0
  24. package/dist/http-fetch.js.map +1 -0
  25. package/dist/hyperlink.d.ts +18 -0
  26. package/dist/hyperlink.d.ts.map +1 -0
  27. package/dist/hyperlink.js +2 -0
  28. package/dist/hyperlink.js.map +1 -0
  29. package/dist/index.d.ts +30 -761
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +12 -2
  32. package/dist/index.js.map +1 -0
  33. package/dist/local-app-data-storage.d.ts +8 -0
  34. package/dist/local-app-data-storage.d.ts.map +1 -0
  35. package/dist/local-app-data-storage.js +11 -0
  36. package/dist/local-app-data-storage.js.map +1 -0
  37. package/dist/locale/en/locale-resources.d.ts +10 -0
  38. package/dist/locale/en/locale-resources.d.ts.map +1 -0
  39. package/dist/locale/en/locale-resources.js +9 -0
  40. package/dist/locale/en/locale-resources.js.map +1 -0
  41. package/dist/locale/fr/locale-resources.d.ts +10 -0
  42. package/dist/locale/fr/locale-resources.d.ts.map +1 -0
  43. package/dist/locale/fr/locale-resources.js +9 -0
  44. package/dist/locale/fr/locale-resources.js.map +1 -0
  45. package/dist/locale/i18n.d.ts +83 -0
  46. package/dist/locale/i18n.d.ts.map +1 -0
  47. package/dist/locale/i18n.js +157 -0
  48. package/dist/locale/i18n.js.map +1 -0
  49. package/dist/logger.d.ts +136 -0
  50. package/dist/logger.d.ts.map +1 -0
  51. package/dist/logger.js +256 -0
  52. package/dist/logger.js.map +1 -0
  53. package/dist/parse-version.d.ts +36 -0
  54. package/dist/parse-version.d.ts.map +1 -0
  55. package/dist/parse-version.js +23 -0
  56. package/dist/parse-version.js.map +1 -0
  57. package/dist/remote-app-data-storage.d.ts +23 -0
  58. package/dist/remote-app-data-storage.d.ts.map +1 -0
  59. package/dist/remote-app-data-storage.js +42 -0
  60. package/dist/remote-app-data-storage.js.map +1 -0
  61. package/dist/type-helper.d.ts +115 -0
  62. package/dist/type-helper.d.ts.map +1 -0
  63. package/dist/type-helper.js +163 -0
  64. package/dist/type-helper.js.map +1 -0
  65. package/dist/type.d.ts +111 -0
  66. package/dist/type.d.ts.map +1 -0
  67. package/dist/type.js +2 -0
  68. package/dist/type.js.map +1 -0
  69. package/dist/website-url.d.ts +29 -0
  70. package/dist/website-url.d.ts.map +1 -0
  71. package/dist/website-url.js +60 -0
  72. package/dist/website-url.js.map +1 -0
  73. package/package.json +2 -2
  74. package/src/file-app-data-storage.ts +27 -13
  75. package/src/http-fetch.ts +59 -0
  76. package/src/index.ts +1 -0
  77. package/src/remote-app-data-storage.ts +23 -15
  78. package/tsconfig-src.tsbuildinfo +1 -1
  79. package/dist/browser-app-data-storage-G62WSQ5Z.js +0 -1
  80. package/dist/chunk-FIUBVWNN.js +0 -1
  81. package/dist/file-app-data-storage-Y5AB6YOB.js +0 -1
  82. package/dist/index.cjs +0 -18
  83. package/dist/index.d.cts +0 -761
package/dist/index.d.ts CHANGED
@@ -1,761 +1,30 @@
1
- import { ISettingsParam, Logger } from 'tslog';
2
- import { Resource, i18n } from 'i18next';
3
-
4
- /**
5
- * Typed function, applicable to any function, stricter than {@linkcode Function}.
6
- *
7
- * @template TFunction
8
- * Function type.
9
- */
10
- type TypedFunction<TFunction extends (...args: Parameters<TFunction>) => ReturnType<TFunction>> = (...args: Parameters<TFunction>) => ReturnType<TFunction>;
11
- /**
12
- * Typed synchronous function, applicable to any function that doesn't return a {@linkcode Promise}.
13
- *
14
- * @template TFunction
15
- * Function type.
16
- */
17
- type TypedSyncFunction<TFunction extends TypedFunction<TFunction>> = [ReturnType<TFunction>] extends [PromiseLike<unknown>] ? never : TypedFunction<TFunction>;
18
- /**
19
- * Arbitrary constructor. An arbitrary constructor doesn't have to be an exact match to a constructor; the only
20
- * requirements are that `TConstructorParameters` have compatible types (exact or wider types of the actual constructor
21
- * parameters) and that `TConstructorInstance` be a compatible type (exact or narrower type of the actual constructor
22
- * instance).
23
- *
24
- * @template TConstructorParameters
25
- * Constructor parameters types.
26
- *
27
- * @template TConstructorInstance
28
- * Constructor instance type.
29
- */
30
- type Constructor<TConstructorParameters extends unknown[], TConstructorInstance> = new (...args: TConstructorParameters) => TConstructorInstance;
31
- /**
32
- * Arbitrary abstract constructor. Abstract version of {@linkcode Constructor}.
33
- *
34
- * @template TConstructorParameters
35
- * Constructor parameters types.
36
- *
37
- * @template TConstructorInstance
38
- * Constructor instance type.
39
- */
40
- type AbstractConstructor<TConstructorParameters extends unknown[], TConstructorInstance> = abstract new (...args: TConstructorParameters) => TConstructorInstance;
41
- /**
42
- * Typed constructor, applicable to any constructor.
43
- *
44
- * @template TConstructor
45
- * Constructor type.
46
- */
47
- type TypedConstructor<TConstructor extends abstract new (...args: ConstructorParameters<TConstructor>) => InstanceType<TConstructor>> = Constructor<ConstructorParameters<TConstructor>, InstanceType<TConstructor>>;
48
- /**
49
- * Typed abstract constructor, applicable to any constructor.
50
- *
51
- * @template TConstructor
52
- * Constructor type.
53
- */
54
- type TypedAbstractConstructor<TConstructor extends abstract new (...args: ConstructorParameters<TConstructor>) => InstanceType<TConstructor>> = AbstractConstructor<ConstructorParameters<TConstructor>, InstanceType<TConstructor>>;
55
- /**
56
- * Promisable type. Extends a type by allowing a {@linkcode Promise} of the same type. Typically used in abstract method
57
- * declarations where the implementing class may or may not implement the method as asynchronous.
58
- */
59
- type Promisable<T> = T | Promise<T>;
60
- /**
61
- * Determine the fundamental promised type. This is stricter than `Awaited<Type>` in that it requires a {@linkcode
62
- * Promise}.
63
- *
64
- * @template T
65
- * Promised type.
66
- */
67
- type PromisedType<T> = [T] extends [PromiseLike<infer TPromised>] ? TPromised : never;
68
- /**
69
- * Typed asynchronous function, applicable to any function that returns a {@linkcode Promise}.
70
- *
71
- * @template TFunction
72
- * Function type.
73
- */
74
- type TypedAsyncFunction<TMethod extends (...args: Parameters<TMethod>) => PromiseLike<PromisedType<ReturnType<TMethod>>>> = (...args: Parameters<TMethod>) => Promise<PromisedType<ReturnType<TMethod>>>;
75
- /**
76
- * Nullishable type. Extends a type by allowing `null` and `undefined`.
77
- *
78
- * @template T
79
- * Type.
80
- */
81
- type Nullishable<T> = T | null | undefined;
82
- /**
83
- * Non-nullishable type. If T is an object type, it is spread and attributes within it are made non-nullishable.
84
- * Equivalent to a deep `Required<T>` for an object and `NonNullable<T>` for any other type.
85
- *
86
- * @template T
87
- * Type.
88
- */
89
- type NonNullishable<T> = T extends object ? {
90
- [P in keyof T]-?: NonNullishable<T[P]>;
91
- } : NonNullable<T>;
92
- /**
93
- * Make some keys within a type optional.
94
- *
95
- * @template T
96
- * Object type.
97
- *
98
- * @template K
99
- * Object key type.
100
- */
101
- type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
102
- /**
103
- * Type to restrict property keys to those that are strings and that support a specified type.
104
- *
105
- * @template T
106
- * Object type.
107
- *
108
- * @template P
109
- * Object property type.
110
- */
111
- type PropertyKeys<T, P> = {
112
- [K in keyof T]: K extends string ? T[K] extends P ? K : never : never;
113
- }[keyof T];
114
-
115
- /**
116
- * Create an object with omitted entries.
117
- *
118
- * @template T
119
- * Object type.
120
- *
121
- * @template K
122
- * Object key type.
123
- *
124
- * @param o
125
- * Object.
126
- *
127
- * @param keys
128
- * Keys to omit.
129
- *
130
- * @returns
131
- * Edited object.
132
- */
133
- declare function omit<T extends object, K extends keyof T>(o: T, ...keys: K[]): Omit<T, K>;
134
- /**
135
- * Create an object with picked entries.
136
- *
137
- * @template T
138
- * Object type.
139
- *
140
- * @template K
141
- * Object key type.
142
- *
143
- * @param o
144
- * Object.
145
- *
146
- * @param keys
147
- * Keys to pick.
148
- *
149
- * @returns
150
- * Edited object.
151
- */
152
- declare function pick<T extends object, K extends keyof T>(o: T, ...keys: K[]): Pick<T, K>;
153
- /**
154
- * Create an object from a wide object without entries matching those from a narrow object.
155
- *
156
- * @template TWide
157
- * Wide object type.
158
- *
159
- * @template TNarrow
160
- * Narrow object type.
161
- *
162
- * @template K
163
- * Narrow object key type, subset of wide object key type.
164
- *
165
- * @param wide
166
- * Wide object.
167
- *
168
- * @param narrow
169
- * Narrow object.
170
- *
171
- * @returns
172
- * Edited object.
173
- */
174
- declare function exclude<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Omit<TWide, K>;
175
- /**
176
- * Create an object from a wide object with entries matching those from a narrow object.
177
- *
178
- * @template TWide
179
- * Wide object type.
180
- *
181
- * @template TNarrow
182
- * Narrow object type.
183
- *
184
- * @template K
185
- * Narrow object key type, subset of wide object key type.
186
- *
187
- * @param wide
188
- * Wide object.
189
- *
190
- * @param narrow
191
- * Narrow object.
192
- *
193
- * @returns
194
- * Edited object.
195
- */
196
- declare function include<TWide extends TNarrow, TNarrow extends object, K extends keyof TNarrow>(wide: TWide, narrow: TNarrow): Pick<TWide, K>;
197
- /**
198
- * Cast a property as a more narrow type.
199
- *
200
- * @template T
201
- * Object type.
202
- *
203
- * @template K
204
- * Object key type.
205
- *
206
- * @template TAsType
207
- * Desired type.
208
- *
209
- * @param o
210
- * Object.
211
- *
212
- * @param key
213
- * Key of property to cast.
214
- *
215
- * @returns
216
- * Single-key object with property cast as desired type.
217
- */
218
- declare function propertyAs<T extends object, K extends keyof T, TAsType extends T[K]>(o: T, key: K): Readonly<Omit<T, K> extends T ? Partial<Record<K, TAsType>> : Record<K, TAsType>>;
219
- /**
220
- * Determine if argument is nullish. Application extension may pass `null` or `undefined` to missing parameters.
221
- *
222
- * @param argument
223
- * Argument.
224
- *
225
- * @returns
226
- * True if argument is undefined or null.
227
- */
228
- declare function isNullish(argument: unknown): argument is null | undefined;
229
-
230
- /**
231
- * Log levels.
232
- */
233
- declare const LogLevels: {
234
- readonly Silly: 0;
235
- readonly Trace: 1;
236
- readonly Debug: 2;
237
- readonly Info: 3;
238
- readonly Warn: 4;
239
- readonly Error: 5;
240
- readonly Fatal: 6;
241
- };
242
- /**
243
- * Log level key.
244
- */
245
- type LogLevelKey = keyof typeof LogLevels;
246
- /**
247
- * Log level.
248
- */
249
- type LogLevel = typeof LogLevels[LogLevelKey];
250
- /**
251
- * Get the log level enumeration value corresponding to a string or number.
252
- *
253
- * @param untypedLogLevel
254
- * Untyped log level.
255
- *
256
- * @returns
257
- * Typed log level or default `LogLevels.Info` if untyped log level not provided..
258
- */
259
- declare function logLevelOf(untypedLogLevel?: string | number): LogLevel;
260
- /**
261
- * Get a logger with an optional log level. The underlying implementation is
262
- * [`tslog`](https://tslog.js.org/).
263
- *
264
- * @param logLevel
265
- * Log level as enumeration value or string. Mapped to `minLevel` and sets `hideLogPositionForProduction` to true in
266
- * settings if at {@linkcode LogLevels.Info} or higher. Default is {@linkcode LogLevels.Info}.
267
- *
268
- * @param settings
269
- * Detailed settings. See [`tslog`](https://tslog.js.org/#/?id=settings) documentation for details. The `minLevel` is
270
- * ignored in favour of `logLevel` but `hideLogPositionForProduction` will override the default logic.
271
- *
272
- * @param logObj
273
- * Default log object. See [`tslog`](https://tslog.js.org/#/?id=defining-and-accessing-logobj) documentation for
274
- * details.
275
- *
276
- * @returns
277
- * Logger.
278
- *
279
- * @template T
280
- * Log object type.
281
- */
282
- declare function getLogger<T extends object = object>(logLevel?: string | number, settings?: ISettingsParam<T>, logObj?: T): Logger<T>;
283
- /**
284
- * Get a loggable representation of a value. Values are returned unmodified, except as follows:
285
- *
286
- * - Big integers are converted to whole numbers where possible, otherwise as their decimal string representations.
287
- * - Arrays are limited to a maximum of ten elements. Any array longer than ten elements is replaced with the first four
288
- * elements, a string of three dots, and the last four elements. This may still create large results for
289
- * multidimensional arrays.
290
- * - Errors are converted to objects with `name`, `message`, and `stack` properties.
291
- * - Symbols are converted to their string representations.
292
- * - Functions are converted to strings of the form `Function(name)`.
293
- *
294
- * @param value
295
- * Value.
296
- *
297
- * @returns
298
- * Loggable value.
299
- */
300
- declare function loggableValue(value: unknown): unknown;
301
- /**
302
- * Logger transport that stores messages in memory.
303
- */
304
- declare class MemoryTransport<T extends object> {
305
- #private;
306
- /**
307
- * Constructor.
308
- *
309
- * @param logger
310
- * Logger.
311
- *
312
- * @param maximumLength
313
- * Maximum length of messages array.
314
- *
315
- * @param truncateLength
316
- * Length to which messages array is truncated when maximum is reached. Default is 50% of `maximumLength`, maximum
317
- * is 80% of `maximumLength`.
318
- */
319
- constructor(logger: Logger<T>, maximumLength: number, truncateLength?: number);
320
- /**
321
- * Get the messages.
322
- */
323
- get messages(): string[];
324
- /**
325
- * Get the maximum length of messages array.
326
- */
327
- get maximumLength(): number;
328
- /**
329
- * Get the length to which messages array is truncated when maximum is reached.
330
- */
331
- get truncateLength(): number;
332
- /**
333
- * Add a notification callback. If one already exists under the current name, do nothing.
334
- *
335
- * @param name
336
- * Callback name.
337
- *
338
- * @param notificationCallback
339
- * Callback.
340
- *
341
- * @returns
342
- * True if successfully added.
343
- */
344
- addNotificationCallback(name: string, notificationCallback: (message: string | undefined, messages: readonly string[]) => void): boolean;
345
- /**
346
- * Remove a notification callback.
347
- *
348
- * @param name
349
- * Callback name.
350
- */
351
- removeNotificationCallback(name: string): void;
352
- /**
353
- * Resize the messages array.
354
- *
355
- * @param maximumLength
356
- * Maximum length of messages array.
357
- *
358
- * @param truncateLength
359
- * Length to which messages array is truncated when maximum is reached. Default is 50% of `maximumLength`, maximum
360
- * is 80% of `maximumLength`.
361
- */
362
- resize(maximumLength: number, truncateLength?: number): void;
363
- }
364
-
365
- /**
366
- * Parsed version.
367
- */
368
- interface ParsedVersion {
369
- /**
370
- * Major version.
371
- */
372
- readonly majorVersion: number;
373
- /**
374
- * Minor version.
375
- */
376
- readonly minorVersion: number;
377
- /**
378
- * Patch version.
379
- */
380
- readonly patchVersion: number;
381
- /**
382
- * Pre-release identifier.
383
- */
384
- readonly preReleaseIdentifier: string | undefined;
385
- /**
386
- * Date/time included with pre-release identifier.
387
- */
388
- readonly dateTime: string | undefined;
389
- }
390
- /**
391
- * Parse version.
392
- *
393
- * @param version
394
- * Version, typically from package.json.
395
- *
396
- * @returns
397
- * Parsed version.
398
- */
399
- declare function parseVersion(version: string): ParsedVersion;
400
-
401
- /**
402
- * Alpha URL. Reads from local application storage, path "config", key "resources.local", if present, otherwise defaults
403
- * to Vite development server URL.
404
- */
405
- declare const ALPHA_URL: Promise<string>;
406
- /**
407
- * AIDC Toolkit website base URL.
408
- */
409
- declare const WEBSITE_BASE_URL = "https://aidc-toolkit.com";
410
- /**
411
- * Determine the website URL based on the package version.
412
- *
413
- * @param version
414
- * Package version.
415
- *
416
- * @param includeVersionInProduction
417
- * If true, the version is included in the URL in production.
418
- *
419
- * @param alphaURL
420
- * URL if pre-release identifier is "alpha".
421
- *
422
- * @param nonAlphaRelativeURL
423
- * Non-alpha URL, relative to website base URL plus pre-release identifier (optional) and version.
424
- *
425
- * @returns
426
- * Fully-formed website URL based on the package version.
427
- */
428
- declare function websiteURL(version: string, includeVersionInProduction: boolean, alphaURL: string, nonAlphaRelativeURL?: string): string;
429
-
430
- /**
431
- * Application data.
432
- */
433
- type AppData = string | number | boolean | object;
434
- /**
435
- * Decode application data from an encoded string.
436
- *
437
- * @param stringData
438
- * String data.
439
- *
440
- * @returns
441
- * Decoded application data.
442
- */
443
- declare function decodeAppData(stringData: string): AppData | undefined;
444
- /**
445
- * Encode application data as a string for storage. Encoded string is in JSON format with date/time and binary data
446
- * converted to identifiable strings for decoding.
447
- *
448
- * @param appData
449
- * Application data.
450
- *
451
- * @returns
452
- * Encoded application data.
453
- */
454
- declare function encodeAppData(appData: AppData): string;
455
-
456
- /**
457
- * Generic read-only application data storage.
458
- */
459
- declare abstract class ReadOnlyAppDataStorage<SupportsBinary extends boolean> {
460
- #private;
461
- /**
462
- * Extension to identify binary data.
463
- */
464
- protected static readonly BINARY_EXTENSION = ".bin";
465
- /**
466
- * Extension to identify JSON data.
467
- */
468
- protected static readonly JSON_EXTENSION = ".json";
469
- /**
470
- * Constructor.
471
- *
472
- * @param supportsBinary
473
- * True if binary data is supported.
474
- *
475
- * @param path
476
- * Storage path prepended to each key along with '/' if defined, empty string if not.
477
- */
478
- protected constructor(supportsBinary: SupportsBinary, path?: string);
479
- /**
480
- * Determine if binary data is supported.
481
- */
482
- get supportsBinary(): SupportsBinary;
483
- /**
484
- * Get the storage path, prepended to each key.
485
- */
486
- get path(): string;
487
- /**
488
- * Build the full storage key.
489
- *
490
- * @param pathKey
491
- * Key relative to path.
492
- *
493
- * @param isBinary
494
- * True if key is to binary data, false or undefined if to string data. Ignored if binary data is not supported.
495
- *
496
- * @returns
497
- * Full storage key.
498
- */
499
- protected fullKey(pathKey: string, isBinary: boolean): string;
500
- /**
501
- * Read a string or binary data from persistent storage.
502
- *
503
- * @param key
504
- * Storage key (file path in Node.js, key in localStorage).
505
- *
506
- * @param asBinary
507
- * True if binary data is requested, false or undefined if string data is requested. Ignored if binary data is not
508
- * supported.
509
- *
510
- * @returns
511
- * String or binary data or undefined if not found.
512
- */
513
- protected abstract doRead(key: string, asBinary: boolean | undefined): Promisable<(SupportsBinary extends true ? string | Uint8Array : string) | undefined>;
514
- /**
515
- * Read application data from storage.
516
- *
517
- * @param pathKey
518
- * Key relative to path.
519
- *
520
- * @param asBinary
521
- * True if binary data is requested, false or undefined if string data is requested. Ignored if binary data is not
522
- * supported.
523
- *
524
- * @returns
525
- * Application data or undefined if not found.
526
- */
527
- read(pathKey: string, asBinary?: boolean): Promise<AppData | undefined>;
528
- }
529
- /**
530
- * Generic read/write application data storage.
531
- */
532
- declare abstract class AppDataStorage<SupportsBinary extends boolean> extends ReadOnlyAppDataStorage<SupportsBinary> {
533
- /**
534
- * Write a string or binary data in persistent storage.
535
- *
536
- * @param key
537
- * Storage key (file path in Node.js, key in localStorage).
538
- *
539
- * @param data
540
- * String or binary data.
541
- */
542
- protected abstract doWrite(key: string, data: SupportsBinary extends true ? string | Uint8Array : string): Promisable<void>;
543
- /**
544
- * Write application data to storage.
545
- *
546
- * @param pathKey
547
- * Key relative to path.
548
- *
549
- * @param appData
550
- * Application data to write.
551
- */
552
- write(pathKey: string, appData: AppData): Promise<void>;
553
- /**
554
- * Delete from persistent storage.
555
- *
556
- * @param key
557
- * Storage key (file path in Node.js, key in localStorage).
558
- */
559
- protected abstract doDelete(key: string): Promisable<void>;
560
- /**
561
- * Delete application data from persistent storage.
562
- *
563
- * @param pathKey
564
- * Key relative to path.
565
- *
566
- * @param asBinary
567
- * True if key is to binary data, false or undefined if to string data. Ignored if binary data is not supported.
568
- */
569
- delete(pathKey: string, asBinary?: boolean): Promise<void>;
570
- }
571
-
572
- /**
573
- * Local application data storage class for the current environment. This is a variable representing a `Promise` as the
574
- * implementing class is loaded dynamically to prevent the inclusion of unnecessary node dependencies in a browser
575
- * environment.
576
- */
577
- declare const LocalAppDataStorage: Promise<new (path?: string) => AppDataStorage<boolean>>;
578
-
579
- /**
580
- * Remote application data storage using HTTP. The `store()` and `delete()` methods are not supported.
581
- */
582
- declare class RemoteAppDataStorage extends ReadOnlyAppDataStorage<true> {
583
- /**
584
- * Constructor.
585
- *
586
- * @param baseURL
587
- * Base URL. The URL must not end with a slash.
588
- */
589
- constructor(baseURL: string);
590
- /**
591
- * @inheritDoc
592
- */
593
- protected doRead(key: string, asBinary: boolean | undefined): Promise<string | Uint8Array | undefined>;
594
- }
595
-
596
- /**
597
- * Generic cache. Typically used to manage a local copy of remote data that is not refreshed regularly.
598
- *
599
- * @template TCache
600
- * Type of cached data.
601
- *
602
- * @template TSource
603
- * Type of source data. The type may be different from the cached data type if a transformation is required.
604
- */
605
- declare abstract class Cache<TCache, TSource = TCache> {
606
- /**
607
- * Get the date/time at or after which the source should be checked for updates. If the value is undefined, this is
608
- * the first usage.
609
- */
610
- abstract get nextCheckDateTime(): Promisable<Date | undefined>;
611
- /**
612
- * Get the date/time at which the cache was last updated. This may more accurately reflect the date/time at which
613
- * the last source retrieved was updated. If the value is undefined, there is no data in the cache.
614
- */
615
- abstract get cacheDateTime(): Promisable<Date | undefined>;
616
- /**
617
- * Get the cache data. This should only ever be called if the cache date/time is defined.
618
- */
619
- abstract get cacheData(): Promisable<TCache>;
620
- /**
621
- * Get the date/time at which the source was last updated. This should not be called unless the next check date/time
622
- * has passed, as it may trigger an expensive remote retrieval.
623
- */
624
- abstract get sourceDateTime(): Promisable<Date>;
625
- /**
626
- * Get the source data. This should not be called unless the next check date/time has passed, as it may trigger an
627
- * expensive remote retrieval.
628
- */
629
- abstract get sourceData(): Promisable<TSource>;
630
- /**
631
- * Update the cache with only the next check date/time. The cache date/time and cache data must not be modified.
632
- * This is typically called when the cache is up to date with the source or source retrieval has failed.
633
- *
634
- * @param nextCheckDateTime
635
- * Next check date/time.
636
- */
637
- abstract update(nextCheckDateTime: Date): Promisable<void>;
638
- /**
639
- * Update all cache parameters. This is typically called when the cache is updated from the source.
640
- *
641
- * @param nextCheckDateTime
642
- * Next check date/time.
643
- *
644
- * @param cacheDateTime
645
- * Cache date/time.
646
- *
647
- * @param cacheData
648
- * Cache data.
649
- */
650
- abstract update(nextCheckDateTime: Date, cacheDateTime: Date, cacheData: TCache): Promisable<void>;
651
- }
652
-
653
- /**
654
- * Hyperlink.
655
- */
656
- interface Hyperlink {
657
- /**
658
- * Reference, relative or absolute depending on the application.
659
- */
660
- readonly reference: string;
661
- /**
662
- * Human-readable text.
663
- */
664
- readonly text?: string | undefined;
665
- /**
666
- * Additional details.
667
- */
668
- readonly details?: string | undefined;
669
- }
670
-
671
- declare const _default: {
672
- Logger: {
673
- unknownLogLevel: string;
674
- };
675
- RemoteAppDataStorage: {
676
- httpError: string;
677
- };
678
- };
679
-
680
- /**
681
- * Locale strings type for generic manipulation.
682
- */
683
- interface LocaleResources {
684
- [key: string]: LocaleResources | string;
685
- }
686
- /**
687
- * Internationalization operating environments.
688
- */
689
- declare const I18nEnvironments: {
690
- /**
691
- * Command-line interface (e.g., unit tests).
692
- */
693
- readonly CLI: 0;
694
- /**
695
- * Web server.
696
- */
697
- readonly Server: 1;
698
- /**
699
- * Web browser.
700
- */
701
- readonly Browser: 2;
702
- };
703
- /**
704
- * Internationalization operating environment key.
705
- */
706
- type I18nEnvironmentKey = keyof typeof I18nEnvironments;
707
- /**
708
- * Internationalization operating environment.
709
- */
710
- type I18nEnvironment = typeof I18nEnvironments[I18nEnvironmentKey];
711
- declare const coreNS = "aidct_core";
712
- /**
713
- * Locale resources type is extracted from the English locale resources object.
714
- */
715
- type CoreLocaleResources = typeof _default;
716
- /**
717
- * Core resource bundle.
718
- */
719
- declare const coreResourceBundle: Resource;
720
- declare const i18nextCore: i18n;
721
- /**
722
- * Initialize internationalization.
723
- *
724
- * @param i18next
725
- * Internationalization object. As multiple objects exist, this parameter represents the one for the module for which
726
- * internationalization is being initialized.
727
- *
728
- * @param environment
729
- * Environment in which the application is running.
730
- *
731
- * @param debug
732
- * Debug setting.
733
- *
734
- * @param defaultNS
735
- * Default namespace.
736
- *
737
- * @param defaultResourceBundle
738
- * Default resource bundle.
739
- *
740
- * @param i18nDependencyInits
741
- * Dependency internationalization initialization functions.
742
- *
743
- * @returns
744
- * Default resource bundle.
745
- */
746
- declare function i18nInit(i18next: i18n, environment: I18nEnvironment, debug: boolean, defaultNS: string, defaultResourceBundle: Resource, ...i18nDependencyInits: Array<(environment: I18nEnvironment, debug: boolean) => Promise<Resource>>): Promise<Resource>;
747
- /**
748
- * Initialize internationalization.
749
- *
750
- * @param environment
751
- * Environment in which the application is running.
752
- *
753
- * @param debug
754
- * Debug setting.
755
- *
756
- * @returns
757
- * Core resource bundle.
758
- */
759
- declare function i18nCoreInit(environment: I18nEnvironment, debug?: boolean): Promise<Resource>;
760
-
761
- export { ALPHA_URL, type AbstractConstructor, type AppData, AppDataStorage, Cache, type Constructor, type CoreLocaleResources, type Hyperlink, type I18nEnvironment, type I18nEnvironmentKey, I18nEnvironments, LocalAppDataStorage, type LocaleResources, type LogLevel, type LogLevelKey, LogLevels, MemoryTransport, type NonNullishable, type Nullishable, type Optional, type ParsedVersion, type Promisable, type PromisedType, type PropertyKeys, ReadOnlyAppDataStorage, RemoteAppDataStorage, type TypedAbstractConstructor, type TypedAsyncFunction, type TypedConstructor, type TypedFunction, type TypedSyncFunction, WEBSITE_BASE_URL, coreNS, coreResourceBundle, decodeAppData, encodeAppData, exclude, getLogger, i18nCoreInit, i18nInit, i18nextCore, include, isNullish, logLevelOf, loggableValue, omit, parseVersion, pick, propertyAs, websiteURL };
1
+ /*!
2
+ * Copyright © 2024-2026 Dolphin Data Development Ltd. and AIDC Toolkit
3
+ * contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export type * from "./type.js";
18
+ export * from "./type-helper.js";
19
+ export * from "./logger.js";
20
+ export * from "./parse-version.js";
21
+ export * from "./website-url.js";
22
+ export * from "./app-data.js";
23
+ export * from "./app-data-storage.js";
24
+ export * from "./local-app-data-storage.js";
25
+ export * from "./http-fetch.js";
26
+ export * from "./remote-app-data-storage.js";
27
+ export * from "./cache.js";
28
+ export type * from "./hyperlink.js";
29
+ export * from "./locale/i18n.js";
30
+ //# sourceMappingURL=index.d.ts.map