@dpuse/dpuse-shared 0.3.821 → 0.3.823

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.
package/README.md CHANGED
@@ -32,6 +32,22 @@ DPUse (Data Positioning & Use) is an in-browser application that positions your
32
32
 
33
33
  <!-- OPENING_END -->
34
34
 
35
+ <!-- USAGE_START -->
36
+
37
+ This connector is automatically uploaded to the DPUse Engine cloud once released and becomes instantly available to all new browser app instances, with existing instances notified of the update.
38
+
39
+ You may view or clone this repository for your own purposes, such as building a new, similar connector, though there is currently no process to accept third-party connectors into DPUse at this stage. Cloned or forked code is unsupported and isn't guaranteed to remain compatible with the DPUse Engine as it evolves.
40
+
41
+ ```bash
42
+ git clone https://github.com/dpuse/dpuse-shared.git
43
+ cd dpuse-shared
44
+ npm install
45
+ ```
46
+
47
+ _Requires [Node.js](https://nodejs.org/) 24 or later, [npm](https://www.npmjs.com/) 12 or later, and [TypeScript](https://www.typescriptlang.org/) 6.0.3 or later._
48
+
49
+ <!-- USAGE_END -->
50
+
35
51
  ## Table of Contents
36
52
 
37
53
  ## Prerequisites
@@ -115,10 +131,22 @@ License data is collected automatically on each release using [license-checker](
115
131
 
116
132
  <!-- DEPENDENCY_LICENSES_START -->
117
133
 
118
- License data is collected automatically on each release using [license-checker](https://github.com/RSeidelsohn/license-checker-rseidelsohn). The following table lists all production dependencies. These dependencies (including transitive ones) have been checked and confirmed to use MIT — all permissive, commercially-friendly licenses. Users of the uploaded library are covered by these checks; developers cloning this repository should independently verify development dependencies.
119
-
120
- | Dependency | Version | License(s) | Document |
121
- | :--------- | :-----: | :--------- | :------- |
134
+ License data is collected automatically on each release using [license-checker](https://github.com/RSeidelsohn/license-checker-rseidelsohn). The following table lists all production dependencies. These dependencies (including transitive ones) have been checked and confirmed to use Apache-2.0, BSD-3-Clause, or MIT — all permissive, commercially-friendly licenses. Users of the uploaded library are covered by these checks; developers cloning this repository should independently verify development dependencies.
135
+
136
+ |Dependency|Version|License(s)|Document|
137
+ |:-|:-:|:-|:-|
138
+ |[@borewit/text-codec](https://github.com/Borewit/text-codec)|0.2.2|MIT|[LICENSE](licenses/downloads/@borewit/text-codec@0.2.2-LICENSE.txt)|
139
+ |[@tokenizer/inflate](https://github.com/Borewit/tokenizer-inflate)|0.4.1|MIT|[LICENSE](licenses/downloads/@tokenizer/inflate@0.4.1-LICENSE.txt)|
140
+ |[@tokenizer/token](https://github.com/Borewit/tokenizer-token)|0.3.0|MIT|[LICENSE](licenses/downloads/@tokenizer/token@0.3.0-LICENSE.txt)|
141
+ |[debug](https://github.com/debug-js/debug)|4.4.3|MIT|[LICENSE](licenses/downloads/debug@4.4.3-LICENSE.txt)|
142
+ |[file-type](https://github.com/sindresorhus/file-type)|22.1.1|MIT|[LICENSE](licenses/downloads/file-type@22.1.1-LICENSE.txt)|
143
+ |[ieee754](https://github.com/feross/ieee754)|1.2.1|BSD-3-Clause|[LICENSE](licenses/downloads/ieee754@1.2.1-LICENSE.txt)|
144
+ |[ms](https://github.com/vercel/ms)|2.1.3|MIT|[LICENSE](licenses/downloads/ms@2.1.3-LICENSE.txt)|
145
+ |[strtok3](https://github.com/Borewit/strtok3)|10.3.5|MIT|[LICENSE](licenses/downloads/strtok3@10.3.5-LICENSE.txt)|
146
+ |[token-types](https://github.com/Borewit/token-types)|6.1.2|MIT|[LICENSE](licenses/downloads/token-types@6.1.2-LICENSE.txt)|
147
+ |[typescript](https://github.com/microsoft/TypeScript)|6.0.3|Apache-2.0|[LICENSE](licenses/downloads/typescript@6.0.3-LICENSE.txt)|
148
+ |[uint8array-extras](https://github.com/sindresorhus/uint8array-extras)|1.5.0|MIT|[LICENSE](licenses/downloads/uint8array-extras@1.5.0-LICENSE.txt)|
149
+ |[valibot](https://github.com/open-circle/valibot)|1.5.0|MIT|[LICENSE](licenses/downloads/valibot@1.5.0-LICENSE.txt)|
122
150
 
123
151
  <!-- DEPENDENCY_LICENSES_END -->
124
152
 
@@ -130,6 +158,21 @@ The dependency tree below lists every package in this project — direct and tra
130
158
 
131
159
  The dependency tree below lists every package in this project — direct and transitive — along with its installed version, release date, and update status. Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are simply mature and stable, requiring no active development.
132
160
 
161
+ - **[file-type](https://github.com/sindresorhus/file-type)** 22.1.1 — this month: 2026-09-17
162
+ - **[@tokenizer/inflate](https://github.com/Borewit/tokenizer-inflate)** 0.4.1 — **10 months** ago: 2025-11-18 ⚠️
163
+ - **[debug](https://github.com/debug-js/debug)** 4.4.3 — **12 months** ago: 2025-09-13 ⚠️
164
+ - **[ms](https://github.com/vercel/ms)** 2.1.3 — **69 months** ago: 2020-12-08 ⚠️
165
+ - **[token-types](https://github.com/Borewit/token-types)** 6.1.2 — **8 months** ago: 2026-01-01 ⚠️
166
+ - **[strtok3](https://github.com/Borewit/strtok3)** 10.3.5 — **6 months** ago: 2026-03-21
167
+ - **[@tokenizer/token](https://github.com/Borewit/tokenizer-token)** 0.3.0 — **62 months** ago: 2021-07-12 ⚠️
168
+ - **[token-types](https://github.com/Borewit/token-types)** 6.1.2 — **8 months** ago: 2026-01-01 ⚠️
169
+ - **[@borewit/text-codec](https://github.com/Borewit/text-codec)** 0.2.2 — **6 months** ago: 2026-03-11
170
+ - **[@tokenizer/token](https://github.com/Borewit/tokenizer-token)** 0.3.0 — **62 months** ago: 2021-07-12 ⚠️
171
+ - **[ieee754](https://github.com/feross/ieee754)** 1.2.1 — **70 months** ago: 2020-10-27 ⚠️
172
+ - **[uint8array-extras](https://github.com/sindresorhus/uint8array-extras)** 1.5.0 — **13 months** ago: 2025-08-22 ⚠️
173
+ - **[valibot](https://github.com/open-circle/valibot)** 1.5.0 — this month: 2026-09-09
174
+ - **[typescript](https://github.com/microsoft/TypeScript)** 6.0.3 — **5 months** ago: 2026-04-16 → **latest**: 7.0.2 — **2 months** ago: 2026-07-08 ❗
175
+
133
176
  <!-- DEPENDENCY_TREE_END -->
134
177
 
135
178
  ## Bundle Analysis
@@ -143,16 +186,16 @@ _Note: Sonda's Vite reports currently exclude CSS files, since Vite does not gen
143
186
  |Chunk/Module/File|Composition|
144
187
  |:------ |:-----------|
145
188
  | dist/componentConfig.schema-DT3mO5rS.js | 10.2 kB · brotli 2.3 kB |
146
- | &nbsp;&nbsp;&nbsp;&nbsp;valibot → dist/index.mjs | `████░░░░░░░░░░░░░░░░` 21.4% |
189
+ | &nbsp;&nbsp;&nbsp;&nbsp;valibot → dist/index.mjs | `████░░░░░░░░░░░░░░░░` 21.3% |
147
190
  | &nbsp;&nbsp;&nbsp;&nbsp;(unassigned) → [unassigned] | `█░░░░░░░░░░░░░░░░░░░` 5.4% |
148
191
  | &nbsp;&nbsp;&nbsp;&nbsp;src | `█░░░░░░░░░░░░░░░░░░░` 4.3% |
149
- | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;componentConfig.schema.ts | `█░░░░░░░░░░░░░░░░░░░` 2.8% |
192
+ | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;componentConfig.schema.ts | `█░░░░░░░░░░░░░░░░░░░` 2.7% |
150
193
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locale.schema.ts | `░░░░░░░░░░░░░░░░░░░░` 0.8% |
151
194
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;baseConfig.schema.ts | `░░░░░░░░░░░░░░░░░░░░` 0.6% |
152
195
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;schema.ts | `░░░░░░░░░░░░░░░░░░░░` 0.2% |
153
- | dist/dpuse-shared-encoding.es.js | 7.3 kB · brotli 1.3 kB |
154
- | &nbsp;&nbsp;&nbsp;&nbsp;(unassigned) → [unassigned] | `████░░░░░░░░░░░░░░░░` 20.9% |
155
- | &nbsp;&nbsp;&nbsp;&nbsp;src → index.ts | `░░░░░░░░░░░░░░░░░░░░` 1.3% |
196
+ | dist/dpuse-shared-encoding.es.js | 7.4 kB · brotli 1.3 kB |
197
+ | &nbsp;&nbsp;&nbsp;&nbsp;src → index.ts | `████░░░░░░░░░░░░░░░░` 19.4% |
198
+ | &nbsp;&nbsp;&nbsp;&nbsp;(unassigned) → [unassigned] | `█░░░░░░░░░░░░░░░░░░░` 3.0% |
156
199
  | dist/dpuse-shared-componentModuleConnector.es.js | 3.6 kB · brotli 1.2 kB |
157
200
  | &nbsp;&nbsp;&nbsp;&nbsp;src | `██░░░░░░░░░░░░░░░░░░` 8.6% |
158
201
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index.ts | `█░░░░░░░░░░░░░░░░░░░` 6.2% |
@@ -1,4 +1,5 @@
1
1
  import "./label-DexpXrnC.js";
2
+ //#region src/encoding/index.ts
2
3
  var e = {
3
4
  arabic: {
4
5
  id: "arabic",
@@ -443,21 +444,24 @@ var e = {
443
444
  isDecodable: !0
444
445
  }
445
446
  }, n = e, r = t;
446
- function i(e = "en") {
447
+ function i(e) {
448
+ return Object.hasOwn(r, e);
449
+ }
450
+ function a(e = "en") {
447
451
  return Array.from(Object.values(r), ({ groupId: t, id: n, isDecodable: r, isDetectable: i }) => {
448
- let o = t == null ? "" : a(t, e);
452
+ let a = t == null ? "" : o(t, e);
449
453
  return {
450
454
  id: n,
451
- groupLabel: o,
452
- label: o ? `${o} (${n})` : n,
455
+ groupLabel: a,
456
+ label: a ? `${a} (${n})` : n,
453
457
  isDetectable: i,
454
458
  isDecodable: r
455
459
  };
456
460
  }).toSorted((t, n) => t.groupLabel.localeCompare(n.groupLabel, e) || t.label.localeCompare(n.label, e));
457
461
  }
458
- function a(e, t) {
462
+ function o(e, t) {
459
463
  let r = n[e].label;
460
464
  return r[t] ?? r.en ?? e;
461
465
  }
462
466
  //#endregion
463
- export { n as ENCODING_GROUP_CONFIG_MAP, r as ENCODING_TYPE_CONFIG_MAP, i as getEncodingTypeConfigs };
467
+ export { n as ENCODING_GROUP_CONFIG_MAP, r as ENCODING_TYPE_CONFIG_MAP, a as getEncodingTypeConfigs, i as isEncodingTypeId };
@@ -1 +1 @@
1
- {"version":3,"file":"dpuse-shared-encoding.es.js","names":[],"sources":["../src/encoding/encodingGroupConfigs.json","../src/encoding/encodingTypeConfigs.json","../src/encoding/index.ts"],"sourcesContent":["{\n \"arabic\": { \"id\": \"arabic\", \"label\": { \"en\": \"Arabic\", \"es\": \"Árabe\" } },\n \"baltic\": { \"id\": \"baltic\", \"label\": { \"en\": \"Baltic\", \"es\": \"Báltico\" } },\n \"celtic\": { \"id\": \"celtic\", \"label\": { \"en\": \"Celtic\", \"es\": \"Celta\" } },\n \"centralEuropean\": { \"id\": \"centralEuropean\", \"label\": { \"en\": \"Central European\", \"es\": \"Centroeuropeo\" } },\n \"chineseSimplified\": { \"id\": \"chineseSimplified\", \"label\": { \"en\": \"Chinese Simplified\", \"es\": \"Chino simplificado\" } },\n \"chineseTraditional\": { \"id\": \"chineseTraditional\", \"label\": { \"en\": \"Chinese Traditional\", \"es\": \"Chino tradicional\" } },\n \"cyrillic\": { \"id\": \"cyrillic\", \"label\": { \"en\": \"Cyrillic\", \"es\": \"Cirílico\" } },\n \"greek\": { \"id\": \"greek\", \"label\": { \"en\": \"Greek\", \"es\": \"Griego\" } },\n \"hebrew\": { \"id\": \"hebrew\", \"label\": { \"en\": \"Hebrew\", \"es\": \"Hebreo\" } },\n \"japanese\": { \"id\": \"japanese\", \"label\": { \"en\": \"Japanese\", \"es\": \"Japonés\" } },\n \"korean\": { \"id\": \"korean\", \"label\": { \"en\": \"Korean\", \"es\": \"Coreano\" } },\n \"nordic\": { \"id\": \"nordic\", \"label\": { \"en\": \"Nordic\", \"es\": \"Nórdico\" } },\n \"other\": { \"id\": \"other\", \"label\": { \"en\": \"Other\", \"es\": \"Otro\" } },\n \"romanian\": { \"id\": \"romanian\", \"label\": { \"en\": \"Romanian\", \"es\": \"Rumano\" } },\n \"southernEuropean\": { \"id\": \"southernEuropean\", \"label\": { \"en\": \"Southern European\", \"es\": \"Europeo meridional\" } },\n \"thai\": { \"id\": \"thai\", \"label\": { \"en\": \"Thai\", \"es\": \"Tailandés\" } },\n \"turkish\": { \"id\": \"turkish\", \"label\": { \"en\": \"Turkish\", \"es\": \"Turco\" } },\n \"unicode16\": { \"id\": \"unicode16\", \"label\": { \"en\": \"Unicode 16\", \"es\": \"Unicode 16\" } },\n \"unicode32\": { \"id\": \"unicode32\", \"label\": { \"en\": \"Unicode 32\", \"es\": \"Unicode 32\" } },\n \"vietnamese\": { \"id\": \"vietnamese\", \"label\": { \"en\": \"Vietnamese\", \"es\": \"Vietnamita\" } },\n \"western\": { \"id\": \"western\", \"label\": { \"en\": \"Western\", \"es\": \"Occidental\" } }\n}\n","{\n \"ascii\": { \"id\": \"ascii\", \"groupId\": null, \"isDetectable\": false, \"isDecodable\": true },\n \"big5\": { \"id\": \"big5\", \"groupId\": \"chineseTraditional\", \"isDetectable\": true, \"isDecodable\": true },\n \"euc-jp\": { \"id\": \"euc-jp\", \"groupId\": \"japanese\", \"isDetectable\": true, \"isDecodable\": true },\n \"euc-kr\": { \"id\": \"euc-kr\", \"groupId\": \"korean\", \"isDetectable\": true, \"isDecodable\": true },\n \"gb18030\": { \"id\": \"gb18030\", \"groupId\": \"chineseSimplified\", \"isDetectable\": true, \"isDecodable\": true },\n \"gbk\": { \"id\": \"gbk\", \"groupId\": \"chineseSimplified\", \"isDetectable\": false, \"isDecodable\": true },\n \"ibm866\": { \"id\": \"ibm866\", \"groupId\": \"cyrillic\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-2022-cn\": { \"id\": \"iso-2022-cn\", \"groupId\": \"chineseSimplified\", \"isDetectable\": true, \"isDecodable\": false },\n \"iso-2022-jp\": { \"id\": \"iso-2022-jp\", \"groupId\": \"japanese\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-2022-kr\": { \"id\": \"iso-2022-kr\", \"groupId\": \"korean\", \"isDetectable\": true, \"isDecodable\": false },\n \"iso-8859-1\": { \"id\": \"iso-8859-1\", \"groupId\": \"western\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-2\": { \"id\": \"iso-8859-2\", \"groupId\": \"centralEuropean\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-3\": { \"id\": \"iso-8859-3\", \"groupId\": \"southernEuropean\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-4\": { \"id\": \"iso-8859-4\", \"groupId\": \"baltic\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-5\": { \"id\": \"iso-8859-5\", \"groupId\": \"cyrillic\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-6\": { \"id\": \"iso-8859-6\", \"groupId\": \"arabic\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-7\": { \"id\": \"iso-8859-7\", \"groupId\": \"greek\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-8\": { \"id\": \"iso-8859-8\", \"groupId\": \"hebrew\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-9\": { \"id\": \"iso-8859-9\", \"groupId\": \"turkish\", \"isDetectable\": true, \"isDecodable\": true },\n \"iso-8859-10\": { \"id\": \"iso-8859-10\", \"groupId\": \"nordic\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-11\": { \"id\": \"iso-8859-11\", \"groupId\": \"thai\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-13\": { \"id\": \"iso-8859-13\", \"groupId\": \"baltic\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-14\": { \"id\": \"iso-8859-14\", \"groupId\": \"celtic\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-15\": { \"id\": \"iso-8859-15\", \"groupId\": \"western\", \"isDetectable\": false, \"isDecodable\": true },\n \"iso-8859-16\": { \"id\": \"iso-8859-16\", \"groupId\": \"romanian\", \"isDetectable\": false, \"isDecodable\": true },\n \"koi8-r\": { \"id\": \"koi8-r\", \"groupId\": \"cyrillic\", \"isDetectable\": true, \"isDecodable\": true },\n \"koi8-u\": { \"id\": \"koi8-u\", \"groupId\": \"cyrillic\", \"isDetectable\": false, \"isDecodable\": true },\n \"latin1\": { \"id\": \"latin1\", \"groupId\": \"western\", \"isDetectable\": false, \"isDecodable\": true },\n \"macintosh\": { \"id\": \"macintosh\", \"groupId\": \"western\", \"isDetectable\": false, \"isDecodable\": true },\n \"shift_jis\": { \"id\": \"shift_jis\", \"groupId\": \"japanese\", \"isDetectable\": true, \"isDecodable\": true },\n \"tis-620\": { \"id\": \"tis-620\", \"groupId\": \"thai\", \"isDetectable\": false, \"isDecodable\": true },\n \"utf-16\": { \"id\": \"utf-16\", \"groupId\": \"unicode16\", \"isDetectable\": false, \"isDecodable\": true },\n \"utf-16be\": { \"id\": \"utf-16be\", \"groupId\": \"unicode16\", \"isDetectable\": true, \"isDecodable\": true },\n \"utf-16le\": { \"id\": \"utf-16le\", \"groupId\": \"unicode16\", \"isDetectable\": true, \"isDecodable\": true },\n \"utf-32be\": { \"id\": \"utf-32be\", \"groupId\": \"unicode32\", \"isDetectable\": true, \"isDecodable\": false },\n \"utf-32le\": { \"id\": \"utf-32le\", \"groupId\": \"unicode32\", \"isDetectable\": true, \"isDecodable\": false },\n \"utf-8\": { \"id\": \"utf-8\", \"groupId\": null, \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1250\": { \"id\": \"windows-1250\", \"groupId\": \"centralEuropean\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1251\": { \"id\": \"windows-1251\", \"groupId\": \"cyrillic\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1252\": { \"id\": \"windows-1252\", \"groupId\": \"western\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1253\": { \"id\": \"windows-1253\", \"groupId\": \"greek\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1254\": { \"id\": \"windows-1254\", \"groupId\": \"turkish\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1255\": { \"id\": \"windows-1255\", \"groupId\": \"hebrew\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1256\": { \"id\": \"windows-1256\", \"groupId\": \"arabic\", \"isDetectable\": true, \"isDecodable\": true },\n \"windows-1257\": { \"id\": \"windows-1257\", \"groupId\": \"baltic\", \"isDetectable\": false, \"isDecodable\": true },\n \"windows-1258\": { \"id\": \"windows-1258\", \"groupId\": \"vietnamese\", \"isDetectable\": false, \"isDecodable\": true },\n \"windows-874\": { \"id\": \"windows-874\", \"groupId\": \"thai\", \"isDetectable\": false, \"isDecodable\": true },\n \"x-mac-cyrillic\": { \"id\": \"x-mac-cyrillic\", \"groupId\": \"cyrillic\", \"isDetectable\": false, \"isDecodable\": true },\n \"x-user-defined\": { \"id\": \"x-user-defined\", \"groupId\": \"other\", \"isDetectable\": false, \"isDecodable\": true }\n}\n","// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID, type LocaleId, type LocaleLabel } from '@/locale/label';\n\n// ── Data\nimport encodingGroupConfigData from './encodingGroupConfigs.json';\nimport encodingTypeConfigData from './encodingTypeConfigs.json';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type EncodingGroupId = keyof typeof encodingGroupConfigData;\nexport type EncodingTypeId = keyof typeof encodingTypeConfigData;\n\nexport interface EncodingGroupConfig {\n id: EncodingGroupId;\n label: LocaleLabel;\n}\n\nexport interface EncodingTypeConfig {\n id: EncodingTypeId;\n groupId: EncodingGroupId | null; // Null for encodings that belong to no group, e.g. 'ascii' and 'utf-8'.\n isDetectable: boolean;\n isDecodable: boolean;\n}\nexport interface EncodingTypeConfigLocalised {\n id: EncodingTypeId;\n groupLabel: string;\n label: string;\n isDetectable: boolean;\n isDecodable: boolean;\n}\n\nexport interface EncodingDetectionConfig {\n id: EncodingTypeId;\n confidenceLevel: number | undefined;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport const ENCODING_GROUP_CONFIG_MAP = encodingGroupConfigData as Record<EncodingGroupId, EncodingGroupConfig>;\nexport const ENCODING_TYPE_CONFIG_MAP = encodingTypeConfigData as Record<string, EncodingTypeConfig>; // Keyed by string, not 'EncodingTypeId', because it is looked up with names detected at runtime.\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport function getEncodingTypeConfigs(localeId: LocaleId = DEFAULT_LOCALE_ID): EncodingTypeConfigLocalised[] {\n const encodingTypeConfigs: EncodingTypeConfigLocalised[] = Array.from(Object.values(ENCODING_TYPE_CONFIG_MAP), ({ groupId, id, isDecodable, isDetectable }) => {\n const groupLabel = groupId == null ? '' : resolveGroupLabel(groupId, localeId);\n return { id, groupLabel, label: groupLabel ? `${groupLabel} (${id})` : id, isDetectable, isDecodable };\n });\n return encodingTypeConfigs.toSorted((left, right) => left.groupLabel.localeCompare(right.groupLabel, localeId) || left.label.localeCompare(right.label, localeId));\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nfunction resolveGroupLabel(groupId: EncodingGroupId, localeId: LocaleId): string {\n const labels = ENCODING_GROUP_CONFIG_MAP[groupId].label;\n return labels[localeId] ?? labels[DEFAULT_LOCALE_ID] ?? groupId;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GEsCa,IAA4B,GAC5B,IAA2B;AAIxC,SAAgB,EAAuB,IAAA,MAAuE;CAK1G,OAJ2D,MAAM,KAAK,OAAO,OAAO,CAAwB,IAAI,EAAE,YAAS,OAAI,gBAAa,sBAAmB;EAC3J,IAAM,IAAa,KAAW,OAAO,KAAK,EAAkB,GAAS,CAAQ;EAC7E,OAAO;GAAE;GAAI;GAAY,OAAO,IAAa,GAAG,EAAW,IAAI,EAAG,KAAK;GAAI;GAAc;EAAY;CACzG,CACO,CAAA,CAAoB,UAAU,GAAM,MAAU,EAAK,WAAW,cAAc,EAAM,YAAY,CAAQ,KAAK,EAAK,MAAM,cAAc,EAAM,OAAO,CAAQ,CAAC;AACrK;AAIA,SAAS,EAAkB,GAA0B,GAA4B;CAC7E,IAAM,IAAS,EAA0B,EAAQ,CAAC;CAClD,OAAO,EAAO,MAAa,EAAA,MAA6B;AAC5D"}
1
+ {"version":3,"file":"dpuse-shared-encoding.es.js","names":[],"sources":["../src/encoding/index.ts"],"sourcesContent":["// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID, type LocaleId, type LocaleLabel } from '@/locale/label';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type EncodingGroupId = keyof typeof ENCODING_GROUP_CONFIG_DATA;\nexport type EncodingTypeId = keyof typeof ENCODING_TYPE_CONFIG_DATA;\n\nexport interface EncodingGroupConfig {\n id: EncodingGroupId;\n label: LocaleLabel;\n}\n\nexport interface EncodingTypeConfig {\n id: EncodingTypeId;\n groupId: EncodingGroupId | null; // Null for encodings that belong to no group, e.g. 'ascii' and 'utf-8'.\n isDetectable: boolean;\n isDecodable: boolean;\n}\nexport interface EncodingTypeConfigLocalised {\n id: EncodingTypeId;\n groupLabel: string;\n label: string;\n isDetectable: boolean;\n isDecodable: boolean;\n}\n\nexport interface EncodingDetectionConfig {\n id: EncodingTypeId;\n confidenceLevel: number | undefined;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst ENCODING_GROUP_CONFIG_DATA = {\n arabic: { id: 'arabic', label: { en: 'Arabic', es: 'Árabe' } },\n baltic: { id: 'baltic', label: { en: 'Baltic', es: 'Báltico' } },\n celtic: { id: 'celtic', label: { en: 'Celtic', es: 'Celta' } },\n centralEuropean: { id: 'centralEuropean', label: { en: 'Central European', es: 'Centroeuropeo' } },\n chineseSimplified: { id: 'chineseSimplified', label: { en: 'Chinese Simplified', es: 'Chino simplificado' } },\n chineseTraditional: { id: 'chineseTraditional', label: { en: 'Chinese Traditional', es: 'Chino tradicional' } },\n cyrillic: { id: 'cyrillic', label: { en: 'Cyrillic', es: 'Cirílico' } },\n greek: { id: 'greek', label: { en: 'Greek', es: 'Griego' } },\n hebrew: { id: 'hebrew', label: { en: 'Hebrew', es: 'Hebreo' } },\n japanese: { id: 'japanese', label: { en: 'Japanese', es: 'Japonés' } },\n korean: { id: 'korean', label: { en: 'Korean', es: 'Coreano' } },\n nordic: { id: 'nordic', label: { en: 'Nordic', es: 'Nórdico' } },\n other: { id: 'other', label: { en: 'Other', es: 'Otro' } },\n romanian: { id: 'romanian', label: { en: 'Romanian', es: 'Rumano' } },\n southernEuropean: { id: 'southernEuropean', label: { en: 'Southern European', es: 'Europeo meridional' } },\n thai: { id: 'thai', label: { en: 'Thai', es: 'Tailandés' } },\n turkish: { id: 'turkish', label: { en: 'Turkish', es: 'Turco' } },\n unicode16: { id: 'unicode16', label: { en: 'Unicode 16', es: 'Unicode 16' } },\n unicode32: { id: 'unicode32', label: { en: 'Unicode 32', es: 'Unicode 32' } },\n vietnamese: { id: 'vietnamese', label: { en: 'Vietnamese', es: 'Vietnamita' } },\n western: { id: 'western', label: { en: 'Western', es: 'Occidental' } }\n} as const satisfies Record<string, { id: string; label: LocaleLabel }>;\n\nconst ENCODING_TYPE_CONFIG_DATA = {\n ascii: { id: 'ascii', groupId: null, isDetectable: false, isDecodable: true },\n big5: { id: 'big5', groupId: 'chineseTraditional', isDetectable: true, isDecodable: true },\n 'euc-jp': { id: 'euc-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'euc-kr': { id: 'euc-kr', groupId: 'korean', isDetectable: true, isDecodable: true },\n gb18030: { id: 'gb18030', groupId: 'chineseSimplified', isDetectable: true, isDecodable: true },\n gbk: { id: 'gbk', groupId: 'chineseSimplified', isDetectable: false, isDecodable: true },\n ibm866: { id: 'ibm866', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'iso-2022-cn': { id: 'iso-2022-cn', groupId: 'chineseSimplified', isDetectable: true, isDecodable: false },\n 'iso-2022-jp': { id: 'iso-2022-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'iso-2022-kr': { id: 'iso-2022-kr', groupId: 'korean', isDetectable: true, isDecodable: false },\n 'iso-8859-1': { id: 'iso-8859-1', groupId: 'western', isDetectable: true, isDecodable: true },\n 'iso-8859-2': { id: 'iso-8859-2', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'iso-8859-3': { id: 'iso-8859-3', groupId: 'southernEuropean', isDetectable: false, isDecodable: true },\n 'iso-8859-4': { id: 'iso-8859-4', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-5': { id: 'iso-8859-5', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'iso-8859-6': { id: 'iso-8859-6', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'iso-8859-7': { id: 'iso-8859-7', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'iso-8859-8': { id: 'iso-8859-8', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'iso-8859-9': { id: 'iso-8859-9', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'iso-8859-10': { id: 'iso-8859-10', groupId: 'nordic', isDetectable: false, isDecodable: true },\n 'iso-8859-11': { id: 'iso-8859-11', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'iso-8859-13': { id: 'iso-8859-13', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-14': { id: 'iso-8859-14', groupId: 'celtic', isDetectable: false, isDecodable: true },\n 'iso-8859-15': { id: 'iso-8859-15', groupId: 'western', isDetectable: false, isDecodable: true },\n 'iso-8859-16': { id: 'iso-8859-16', groupId: 'romanian', isDetectable: false, isDecodable: true },\n 'koi8-r': { id: 'koi8-r', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'koi8-u': { id: 'koi8-u', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n latin1: { id: 'latin1', groupId: 'western', isDetectable: false, isDecodable: true },\n macintosh: { id: 'macintosh', groupId: 'western', isDetectable: false, isDecodable: true },\n shift_jis: { id: 'shift_jis', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'tis-620': { id: 'tis-620', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'utf-16': { id: 'utf-16', groupId: 'unicode16', isDetectable: false, isDecodable: true },\n 'utf-16be': { id: 'utf-16be', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-16le': { id: 'utf-16le', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-32be': { id: 'utf-32be', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-32le': { id: 'utf-32le', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-8': { id: 'utf-8', groupId: null, isDetectable: true, isDecodable: true },\n 'windows-1250': { id: 'windows-1250', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'windows-1251': { id: 'windows-1251', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'windows-1252': { id: 'windows-1252', groupId: 'western', isDetectable: true, isDecodable: true },\n 'windows-1253': { id: 'windows-1253', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'windows-1254': { id: 'windows-1254', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'windows-1255': { id: 'windows-1255', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'windows-1256': { id: 'windows-1256', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'windows-1257': { id: 'windows-1257', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'windows-1258': { id: 'windows-1258', groupId: 'vietnamese', isDetectable: false, isDecodable: true },\n 'windows-874': { id: 'windows-874', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'x-mac-cyrillic': { id: 'x-mac-cyrillic', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'x-user-defined': { id: 'x-user-defined', groupId: 'other', isDetectable: false, isDecodable: true }\n} as const satisfies Record<string, { id: string; groupId: keyof typeof ENCODING_GROUP_CONFIG_DATA | null; isDetectable: boolean; isDecodable: boolean }>;\n\nexport const ENCODING_GROUP_CONFIG_MAP = ENCODING_GROUP_CONFIG_DATA as Record<EncodingGroupId, EncodingGroupConfig>;\nexport const ENCODING_TYPE_CONFIG_MAP = ENCODING_TYPE_CONFIG_DATA as Record<EncodingTypeId, EncodingTypeConfig>;\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Narrows a name from outside the app, such as one reported by encoding detection, to a known encoding id. Check with\n// this once where the name arrives, so everything after it works with 'EncodingTypeId'.\nexport function isEncodingTypeId(value: string): value is EncodingTypeId {\n return Object.hasOwn(ENCODING_TYPE_CONFIG_MAP, value);\n}\n\nexport function getEncodingTypeConfigs(localeId: LocaleId = DEFAULT_LOCALE_ID): EncodingTypeConfigLocalised[] {\n const encodingTypeConfigs: EncodingTypeConfigLocalised[] = Array.from(Object.values(ENCODING_TYPE_CONFIG_MAP), ({ groupId, id, isDecodable, isDetectable }) => {\n const groupLabel = groupId == null ? '' : resolveGroupLabel(groupId, localeId);\n return { id, groupLabel, label: groupLabel ? `${groupLabel} (${id})` : id, isDetectable, isDecodable };\n });\n return encodingTypeConfigs.toSorted((left, right) => left.groupLabel.localeCompare(right.groupLabel, localeId) || left.label.localeCompare(right.label, localeId));\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nfunction resolveGroupLabel(groupId: EncodingGroupId, localeId: LocaleId): string {\n const labels = ENCODING_GROUP_CONFIG_MAP[groupId].label;\n return labels[localeId] ?? labels[DEFAULT_LOCALE_ID] ?? groupId;\n}\n"],"mappings":";;AAkCA,IAAM,IAA6B;CAC/B,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAU;CAAE;CAC/D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,iBAAiB;EAAE,IAAI;EAAmB,OAAO;GAAE,IAAI;GAAoB,IAAI;EAAgB;CAAE;CACjG,mBAAmB;EAAE,IAAI;EAAqB,OAAO;GAAE,IAAI;GAAsB,IAAI;EAAqB;CAAE;CAC5G,oBAAoB;EAAE,IAAI;EAAsB,OAAO;GAAE,IAAI;GAAuB,IAAI;EAAoB;CAAE;CAC9G,UAAU;EAAE,IAAI;EAAY,OAAO;GAAE,IAAI;GAAY,IAAI;EAAW;CAAE;CACtE,OAAO;EAAE,IAAI;EAAS,OAAO;GAAE,IAAI;GAAS,IAAI;EAAS;CAAE;CAC3D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAS;CAAE;CAC9D,UAAU;EAAE,IAAI;EAAY,OAAO;GAAE,IAAI;GAAY,IAAI;EAAU;CAAE;CACrE,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAU;CAAE;CAC/D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAU;CAAE;CAC/D,OAAO;EAAE,IAAI;EAAS,OAAO;GAAE,IAAI;GAAS,IAAI;EAAO;CAAE;CACzD,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EAAc,cAAc;EAAO,aAAa;CAAK;CACpG,eAAe;EAAE,IAAI;EAAe,SAAS;EAAQ,cAAc;EAAO,aAAa;CAAK;CAC5F,kBAAkB;EAAE,IAAI;EAAkB,SAAS;EAAY,cAAc;EAAO,aAAa;CAAK;CACtG,kBAAkB;EAAE,IAAI;EAAkB,SAAS;EAAS,cAAc;EAAO,aAAa;CAAK;AACvG,GAEa,IAA4B,GAC5B,IAA2B;AAMxC,SAAgB,EAAiB,GAAwC;CACrE,OAAO,OAAO,OAAO,GAA0B,CAAK;AACxD;AAEA,SAAgB,EAAuB,IAAA,MAAuE;CAK1G,OAJ2D,MAAM,KAAK,OAAO,OAAO,CAAwB,IAAI,EAAE,YAAS,OAAI,gBAAa,sBAAmB;EAC3J,IAAM,IAAa,KAAW,OAAO,KAAK,EAAkB,GAAS,CAAQ;EAC7E,OAAO;GAAE;GAAI;GAAY,OAAO,IAAa,GAAG,EAAW,IAAI,EAAG,KAAK;GAAI;GAAc;EAAY;CACzG,CACO,CAAA,CAAoB,UAAU,GAAM,MAAU,EAAK,WAAW,cAAc,EAAM,YAAY,CAAQ,KAAK,EAAK,MAAM,cAAc,EAAM,OAAO,CAAQ,CAAC;AACrK;AAIA,SAAS,EAAkB,GAA0B,GAA4B;CAC7E,IAAM,IAAS,EAA0B,EAAQ,CAAC;CAClD,OAAO,EAAO,MAAa,EAAA,MAA6B;AAC5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"dpuse-shared-errors.es.js","names":[],"sources":["../src/errors/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Serializable representation of an error; used for transporting errors across api and worker boundaries\nexport interface SerialisedError {\n data: Record<string, unknown> | undefined;\n locator: string; // Error locator 'package.module.method'\n message: string; // Human-readable error message\n name: string; // Error class or type name\n stack: string | undefined; // Stack trace if available\n}\n\n// ── Constants ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst RESPONSE_ERROR_BODY_LIMIT = 2048;\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Base class for all DPUse errors; includes a locator for the error; never thrown directly\nexport class DPUseError extends Error {\n readonly data: Record<string, unknown> | undefined;\n readonly locator: string; // Error locator 'package.module.method'\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, options);\n this.name = 'DPUseError';\n this.data = data;\n this.locator = locator;\n }\n}\n\n// Thrown when an app (studio/assistant) error occurs\nexport class AppError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'AppError';\n }\n}\n\n// Thrown when an API request fails\nexport class APIError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'APIError';\n }\n}\n\n// Thrown when an engine request fails\nexport class EngineError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'EngineError';\n }\n}\n\n// Thrown when an connector operation fails; will always be wrapped in an engine error\nexport class ConnectorError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'ConnectorError';\n }\n}\n\n// Thrown when an HTTP request fails; may include a sanitized portion of the response body for diagnostic purposes\nexport class FetchError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'FetchError';\n }\n}\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fetch error from an HTTP response; includes a text copy of the response body\nexport async function buildFetchError(response: { status: number; statusText: string; text: () => Promise<string> }, message: string, locator: string): Promise<FetchError> {\n const responseStatusStuff = ` - ${response.statusText}`;\n const fetchMessage = `${message} Response status '${String(response.status)}${response.statusText ? responseStatusStuff : ''}' received.`;\n let bodyText: string;\n try {\n bodyText = await response.text();\n } catch (error) {\n const normalised = normalizeToError(error);\n bodyText = `<body unavailable: ${normalised.message}>`;\n }\n return new FetchError(fetchMessage, locator, { body: sanitizeResponseErrorBody(bodyText) });\n}\n\n// Concatenates serialized error messages into a single string\nexport function concatenateSerialisedErrorMessages(serialisedErrors: SerialisedError[]): string {\n return serialisedErrors.map((serialisedError) => serialisedError.message).join(' ');\n}\n\n// Ignore best-effort cleanup errors to keep teardown noise-free\nexport function ignoreErrors(action: () => void): void {\n try {\n action();\n } catch {\n // Intentionally ignore errors\n }\n}\n\n// Normalizes an unknown thrown value into an error\nexport function normalizeToError(value: unknown): Error {\n if (value instanceof Error) return value;\n if (typeof value === 'string') return new Error(value);\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return new Error(String(value));\n if (typeof value === 'symbol') return new Error(value.description ?? 'Unknown error');\n if (typeof value === 'object') {\n try {\n return new Error(JSON.stringify(value));\n } catch {\n return new Error('Unknown error');\n }\n }\n return new Error('Unknown error');\n}\n\n// Serializes an error and its cause chain into a array of serialised error objects;\n// errors are ordered from outermost to root cause;\n// cycles in the cause chain are safely ignored;\n// messages are normalized to end with punctuation\nexport function serialiseError(error?: unknown): SerialisedError[] {\n const seenCauses = new Set();\n const serialisedErrors: SerialisedError[] = [];\n let cause: Error | null = normalizeToError(error);\n while (cause != null && !seenCauses.has(cause)) {\n seenCauses.add(cause);\n const [serialisedError, nextCause] = serialiseSingleError(cause);\n if (!/(?:\\.{3}|[.!?])$/.test(serialisedError.message)) serialisedError.message += '.';\n serialisedErrors.push(serialisedError);\n cause = nextCause;\n }\n return serialisedErrors;\n}\n\n// Unserialises an array of serialised error objects back into an error with a cause chain;\n// reconstructs the appropriate error class based on serialized properties;\n// chains errors from outermost to root cause using the `cause` option;\n// returns a placeholder error if the input array is empty\nexport function unserialiseError(serialisedErrors: SerialisedError[]): Error {\n // Build the error chain from root cause (end) to outermost (start)\n let rebuiltError: Error | undefined;\n for (const serialised of serialisedErrors.toReversed()) {\n const error = reconstructError(serialised, rebuiltError);\n if (serialised.stack !== undefined) error.stack = serialised.stack; // Restore stack trace if available\n rebuiltError = error;\n }\n return rebuiltError ?? new Error('No error to unserialise.');\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fallback message for non-error throwables\nfunction buildFallbackMessage(cause: unknown): string {\n let fallbackMessage: string;\n try {\n fallbackMessage = JSON.stringify(cause);\n } catch {\n if (typeof cause === 'symbol') fallbackMessage = cause.description ?? 'Unknown error';\n else if (typeof cause === 'bigint') fallbackMessage = cause.toString();\n else fallbackMessage = 'Unknown error';\n }\n if (fallbackMessage === '') fallbackMessage = 'Unknown error';\n return fallbackMessage;\n}\n\nfunction reconstructError(serialised: SerialisedError, cause: Error | undefined): Error {\n switch (serialised.name) {\n case 'APIError':\n return new APIError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'AppError':\n return new AppError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'ConnectorError':\n return new ConnectorError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'EngineError':\n return new EngineError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'FetchError':\n return new FetchError(serialised.message, serialised.locator, serialised.data, { cause });\n default: {\n const name = serialised.name;\n return new (class extends Error {\n override name = name;\n })(serialised.message, { cause });\n }\n }\n}\n\n// Sanitizes a response body; limits body size to avoid excessive payloads when logging\nfunction sanitizeResponseErrorBody(body?: string): string | undefined {\n if (body == null || body === '') return undefined;\n return body.length > RESPONSE_ERROR_BODY_LIMIT ? `${body.slice(0, RESPONSE_ERROR_BODY_LIMIT)}... [truncated]` : body;\n}\n\nfunction serialiseSingleError(cause: Error): [SerialisedError, Error | null] {\n const nextCause = cause.cause == null ? null : normalizeToError(cause.cause);\n if (cause instanceof DPUseError) {\n return [{ data: cause.data, locator: cause.locator, message: cause.message, name: cause.name, stack: cause.stack }, nextCause];\n }\n const customProperties = Object.fromEntries(Object.entries(cause).filter(([k]) => k !== 'cause'));\n return cause.name\n ? [{ data: customProperties, locator: '', message: cause.message, name: cause.name, stack: cause.stack }, nextCause]\n : [{ data: customProperties, locator: '', message: buildFallbackMessage(cause), name: 'Error', stack: undefined }, null];\n}\n"],"mappings":";AAaA,IAAM,IAA4B,MAKrB,IAAb,cAAgC,MAAM;CAClC;CACA;CACA,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAIlG,AAHA,MAAM,GAAS,CAAO,GACtB,KAAK,OAAO,cACZ,KAAK,OAAO,GACZ,KAAK,UAAU;CACnB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAAiC,EAAW;CACxC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAAoC,EAAW;CAC3C,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAAgC,EAAW;CACvC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ;AAKA,eAAsB,EAAgB,GAA+E,GAAiB,GAAsC;CACxK,IAAM,IAAsB,MAAM,EAAS,cACrC,IAAe,GAAG,EAAQ,oBAAoB,OAAO,EAAS,MAAM,IAAI,EAAS,aAAa,IAAsB,GAAG,cACzH;CACJ,IAAI;EACA,IAAW,MAAM,EAAS,KAAK;CACnC,SAAS,GAAO;EAEZ,IAAW,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,GACjB,OAAO,CAAC;EAAE,MAAM,EAAM;EAAM,SAAS,EAAM;EAAS,SAAS,EAAM;EAAS,MAAM,EAAM;EAAM,OAAO,EAAM;CAAM,GAAG,CAAS;CAEjI,IAAM,IAAmB,OAAO,YAAY,OAAO,QAAQ,CAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,MAAM,OAAO,CAAC;CAChG,OAAO,EAAM,OACP,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAI,SAAS,EAAM;EAAS,MAAM,EAAM;EAAM,OAAO,EAAM;CAAM,GAAG,CAAS,IACjH,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAI,SAAS,EAAqB,CAAK;EAAG,MAAM;EAAS,OAAO,KAAA;CAAU,GAAG,IAAI;AAC/H"}
1
+ {"version":3,"file":"dpuse-shared-errors.es.js","names":[],"sources":["../src/errors/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Serializable representation of an error; used for transporting errors across api and worker boundaries\nexport interface SerialisedError {\n data: Record<string, unknown> | undefined;\n locator: string; // Error locator 'package.module.method'\n message: string; // Human-readable error message\n name: string; // Error class or type name\n stack: string | undefined; // Stack trace if available\n}\n\n// ── Constants ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst RESPONSE_ERROR_BODY_LIMIT = 2048;\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Base class for all DPUse errors; includes a locator for the error; never thrown directly\nexport class DPUseError extends Error {\n readonly data: Record<string, unknown> | undefined;\n readonly locator: string; // Error locator 'package.module.method'\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, options);\n this.name = 'DPUseError';\n this.data = data;\n this.locator = locator;\n }\n}\n\n// Thrown when an app (studio/assistant) error occurs\nexport class AppError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'AppError';\n }\n}\n\n// Thrown when an API request fails\nexport class APIError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'APIError';\n }\n}\n\n// Thrown when an engine request fails\nexport class EngineError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'EngineError';\n }\n}\n\n// Thrown when an connector operation fails; will always be wrapped in an engine error\nexport class ConnectorError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'ConnectorError';\n }\n}\n\n// Thrown when an HTTP request fails; may include a sanitized portion of the response body for diagnostic purposes\nexport class FetchError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'FetchError';\n }\n}\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fetch error from an HTTP response; includes a text copy of the response body\nexport async function buildFetchError(response: { status: number; statusText: string; text: () => Promise<string> }, message: string, locator: string): Promise<FetchError> {\n const responseStatusStuff = ` - ${response.statusText}`;\n const fetchMessage = `${message} Response status '${String(response.status)}${response.statusText ? responseStatusStuff : ''}' received.`;\n let bodyText: string;\n try {\n bodyText = await response.text();\n } catch (error) {\n const normalised = normalizeToError(error);\n bodyText = `<body unavailable: ${normalised.message}>`;\n }\n return new FetchError(fetchMessage, locator, { body: sanitizeResponseErrorBody(bodyText) });\n}\n\n// Concatenates serialized error messages into a single string\nexport function concatenateSerialisedErrorMessages(serialisedErrors: SerialisedError[]): string {\n return serialisedErrors.map((serialisedError) => serialisedError.message).join(' ');\n}\n\n// Ignore best-effort cleanup errors to keep teardown noise-free\nexport function ignoreErrors(action: () => void): void {\n try {\n action();\n } catch {\n // Intentionally ignore errors\n }\n}\n\n// Normalizes an unknown thrown value into an error\nexport function normalizeToError(value: unknown): Error {\n if (value instanceof Error) return value;\n if (typeof value === 'string') return new Error(value);\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return new Error(String(value));\n if (typeof value === 'symbol') return new Error(value.description ?? 'Unknown error');\n if (typeof value === 'object') {\n try {\n return new Error(JSON.stringify(value));\n } catch {\n return new Error('Unknown error');\n }\n }\n return new Error('Unknown error');\n}\n\n// Serializes an error and its cause chain into a array of serialised error objects;\n// errors are ordered from outermost to root cause;\n// cycles in the cause chain are safely ignored;\n// messages are normalized to end with punctuation\nexport function serialiseError(error?: unknown): SerialisedError[] {\n const seenCauses = new Set();\n const serialisedErrors: SerialisedError[] = [];\n let cause: Error | null = normalizeToError(error);\n while (cause != null && !seenCauses.has(cause)) {\n seenCauses.add(cause);\n const [serialisedError, nextCause] = serialiseSingleError(cause);\n if (!/(?:\\.{3}|[.!?])$/.test(serialisedError.message)) serialisedError.message += '.';\n serialisedErrors.push(serialisedError);\n cause = nextCause;\n }\n return serialisedErrors;\n}\n\n// Unserialises an array of serialised error objects back into an error with a cause chain;\n// reconstructs the appropriate error class based on serialized properties;\n// chains errors from outermost to root cause using the `cause` option;\n// returns a placeholder error if the input array is empty\nexport function unserialiseError(serialisedErrors: SerialisedError[]): Error {\n // Build the error chain from root cause (end) to outermost (start)\n let rebuiltError: Error | undefined;\n for (const serialised of serialisedErrors.toReversed()) {\n const error = reconstructError(serialised, rebuiltError);\n if (serialised.stack !== undefined) error.stack = serialised.stack; // Restore stack trace if available\n rebuiltError = error;\n }\n return rebuiltError ?? new Error('No error to unserialise.');\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fallback message for non-error throwables\nfunction buildFallbackMessage(cause: unknown): string {\n let fallbackMessage: string;\n try {\n fallbackMessage = JSON.stringify(cause);\n } catch {\n if (typeof cause === 'symbol') fallbackMessage = cause.description ?? 'Unknown error';\n else if (typeof cause === 'bigint') fallbackMessage = cause.toString();\n else fallbackMessage = 'Unknown error';\n }\n if (fallbackMessage === '') fallbackMessage = 'Unknown error';\n return fallbackMessage;\n}\n\nfunction reconstructError(serialised: SerialisedError, cause: Error | undefined): Error {\n switch (serialised.name) {\n case 'APIError':\n return new APIError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'AppError':\n return new AppError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'ConnectorError':\n return new ConnectorError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'EngineError':\n return new EngineError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'FetchError':\n return new FetchError(serialised.message, serialised.locator, serialised.data, { cause });\n default: {\n const name = serialised.name;\n return new (class extends Error {\n override name = name;\n })(serialised.message, { cause });\n }\n }\n}\n\n// Sanitizes a response body; limits body size to avoid excessive payloads when logging\nfunction sanitizeResponseErrorBody(body?: string): string | undefined {\n if (body == null || body === '') return undefined;\n return body.length > RESPONSE_ERROR_BODY_LIMIT ? `${body.slice(0, RESPONSE_ERROR_BODY_LIMIT)}... [truncated]` : body;\n}\n\nfunction serialiseSingleError(cause: Error): [SerialisedError, Error | null] {\n const nextCause = cause.cause == null ? null : normalizeToError(cause.cause);\n if (cause instanceof DPUseError) {\n return [{ data: cause.data, locator: cause.locator, message: cause.message, name: cause.name, stack: cause.stack }, nextCause];\n }\n const customProperties = Object.fromEntries(Object.entries(cause).filter(([k]) => k !== 'cause'));\n return cause.name\n ? [{ data: customProperties, locator: '', message: cause.message, name: cause.name, stack: cause.stack }, nextCause]\n : [{ data: customProperties, locator: '', message: buildFallbackMessage(cause), name: 'Error', stack: undefined }, null];\n}\n"],"mappings":";AAaA,IAAM,IAA4B,MAKrB,IAAb,cAAgC,MAAM;CAClC;CACA;CACA,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAIlG,AAHA,MAAM,GAAS,CAAO,GACtB,KAAK,OAAO,cACZ,KAAK,OAAO,GACZ,KAAK,UAAU;CACnB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,G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S,EAAqB,CAAK;EAAG,MAAM;EAAS,OAAO,KAAA;CAAU,GAAG,IAAI;AAC/H"}
@@ -1 +1 @@
1
- {"version":3,"file":"dpuse-shared-utilities.es.js","names":[],"sources":["../src/utilities/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype DurationLevel = 'days' | 'hrs' | 'mins' | 'secs' | 'ms';\ntype DurationLevelTuple = [DurationLevel, number, (n: number) => string];\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst DURATION_LEVELS: DurationLevelTuple[] = [\n ['days', 86_400_000, (n: number): string => (n === 1 ? '1 day' : `${formatNumberAsWholeNumber(n)} days`)],\n ['hrs', 3_600_000, (n: number): string => (n === 1 ? '1 hr' : `${formatNumberAsWholeNumber(n)} hrs`)],\n ['mins', 60_000, (n: number): string => (n === 1 ? '1 min' : `${formatNumberAsWholeNumber(n)} mins`)],\n ['secs', 1000, (n: number): string => (n === 1 ? '1 sec' : `${formatNumberAsWholeNumber(n)} secs`)],\n ['ms', 0, (n: number): string => `${formatNumberAsWholeNumber(n)} ms`]\n];\n\nconst NUMBER_FORMATTER_DEFAULT_LOCALE = 'en';\nconst NUMBER_FORMATTER_MAP = new Map<string, Intl.NumberFormat>();\n\n// ── Actions - Data Type Conversion ───────────────────────────────────────────────────────────────────────────────────\n\n// See: https://www.odata.org/documentation/odata-version-2-0/overview/.\nexport function convertODataTypeIdToUsageTypeId(oDataTypeId: string): string {\n switch (oDataTypeId) {\n case 'Edm.Binary':\n return 'unknown'; // Binary...\n case 'Edm.Boolean':\n return 'boolean';\n case 'Edm.Byte':\n return 'wholeNumber';\n case 'Edm.DateTime':\n return 'moment'; // DateTime...\n case 'Edm.DateTimeOffset':\n return 'moment'; // DateTimeOffset...\n case 'Edm.Decimal':\n return 'decimalNumber';\n case 'Edm.Double':\n return 'decimalNumber';\n case 'Edm.Guid':\n return 'string';\n case 'Edm.Int16':\n return 'wholeNumber';\n case 'Edm.Int32':\n return 'wholeNumber';\n case 'Edm.Int64':\n return 'wholeNumber';\n case 'Edm.SByte':\n return 'wholeNumber';\n case 'Edm.Single':\n return 'decimalNumber';\n case 'Edm.String':\n return 'string';\n case 'Edm.Time':\n return 'momentTime'; // Time...\n default:\n return 'unknown';\n }\n}\n\n// ── Actions - File Path Segment Extraction ───────────────────────────────────────────────────────────────────────────\n\n// Extract the path without its final basename extension.\n// Dots in parent directories are ignored, and leading dots in the basename\n// are treated as part of dotfile names rather than as an extension separator.\nexport function extractNameFromPath(itemPath: string): string | undefined {\n if (itemPath) {\n const lastSeparatorIndex = itemPath.lastIndexOf('/');\n const basenameStartIndex = lastSeparatorIndex + 1;\n const lastExtensionIndex = itemPath.lastIndexOf('.');\n if (lastExtensionIndex <= basenameStartIndex) return itemPath;\n return lastExtensionIndex === -1 ? itemPath : itemPath.slice(0, Math.max(0, lastExtensionIndex));\n }\n return undefined;\n}\n\n// Extract only the final basename extension.\n// Returns undefined when the basename has no extension, including dotfiles such\n// as .gitignore where the only dot is the leading character of the basename.\nexport function extractExtensionFromPath(itemPath: string): string | undefined {\n if (itemPath) {\n const lastSeparatorIndex = itemPath.lastIndexOf('/');\n const basenameStartIndex = lastSeparatorIndex + 1;\n const lastExtensionIndex = itemPath.lastIndexOf('.');\n if (lastExtensionIndex <= basenameStartIndex) return undefined;\n if (lastExtensionIndex !== -1) return itemPath.slice(Math.max(0, lastExtensionIndex + 1));\n }\n return undefined;\n}\n\n// ── Actions - String Formatting ──────────────────────────────────────────────────────────────────────────────────────\n\nexport function formatNumberAsDecimalNumber(number?: number, decimalPlaces = 2, minimumFractionDigits = decimalPlaces, locale = NUMBER_FORMATTER_DEFAULT_LOCALE): string {\n if (number == null) return '';\n const formatterId = `${locale}decimal${String(decimalPlaces)}.${String(minimumFractionDigits)}`;\n let numberFormatter = NUMBER_FORMATTER_MAP.get(formatterId);\n if (!numberFormatter) {\n numberFormatter = new Intl.NumberFormat(locale, {\n localeMatcher: 'best fit',\n maximumFractionDigits: decimalPlaces,\n minimumFractionDigits,\n minimumIntegerDigits: 1,\n style: 'decimal',\n useGrouping: true\n });\n NUMBER_FORMATTER_MAP.set(formatterId, numberFormatter);\n }\n return numberFormatter.format(number);\n}\n\nexport function formatNumberAsSize(number?: number, decimalPlaces = 1): string {\n if (number == null) return '';\n if (number < 1000) return formatNumberAsWholeNumber(number);\n if (number < 1_000_000) return `${formatNumberAsDecimalNumber(number / 1000, decimalPlaces, 0)}K`;\n if (number < 1_000_000_000) return `${formatNumberAsDecimalNumber(number / 1_000_000, decimalPlaces, 0)}M`;\n return number < 1_000_000_000_000\n ? `${formatNumberAsDecimalNumber(number / 1_000_000_000, decimalPlaces, 0)}B`\n : `${formatNumberAsDecimalNumber(number / 1_000_000_000_000, decimalPlaces, 0)}T`;\n}\n\nexport function formatNumberAsStorageSize(number?: number, decimalPlaces = 1): string {\n if (number == null) return '';\n if (number === 1) return '1 byte';\n if (number < 1024) return `${formatNumberAsWholeNumber(number)} bytes`;\n if (number < 1_048_576) return `${formatNumberAsDecimalNumber(number / 1024, decimalPlaces, 0)} KB`;\n if (number < 1_073_741_824) return `${formatNumberAsDecimalNumber(number / 1_048_576, decimalPlaces, 0)} MB`;\n return number < 1_099_511_627_776\n ? `${formatNumberAsDecimalNumber(number / 1_073_741_824, decimalPlaces, 0)} GB`\n : `${formatNumberAsDecimalNumber(number / 1_099_511_627_776, decimalPlaces, 0)} TB`;\n}\n\nexport function formatNumberAsDuration(number?: number, stopAt: DurationLevel = 'ms'): string {\n if (number == null) return '';\n\n // Start at the largest unit the value actually fills, so a value below the requested level still reads sensibly\n // rather than as a run of zeroes.\n const startIndex = DURATION_LEVELS.findIndex(([, threshold]) => number >= threshold);\n const firstIndex = startIndex === -1 ? DURATION_LEVELS.length - 1 : startIndex;\n const stopIndex = DURATION_LEVELS.findIndex(([level]) => level === stopAt);\n\n const durationLevels = DURATION_LEVELS.slice(firstIndex, Math.max(stopIndex, firstIndex) + 1);\n const parts: string[] = [];\n let remaining = number;\n for (const [, threshold, format] of durationLevels) {\n if (remaining < threshold || (remaining === 0 && parts.length > 0)) continue;\n parts.push(format(threshold > 0 ? Math.floor(remaining / threshold) : remaining));\n remaining %= threshold > 0 ? threshold : 1;\n }\n return parts.join(' ');\n}\n\nexport function formatNumberAsWholeNumber(number?: number, locale = NUMBER_FORMATTER_DEFAULT_LOCALE): string {\n if (number == null) return '';\n const formatterId = `${locale}decimal0.0`;\n let numberFormatter = NUMBER_FORMATTER_MAP.get(formatterId);\n if (!numberFormatter) {\n numberFormatter = new Intl.NumberFormat(locale, {\n localeMatcher: 'best fit',\n maximumFractionDigits: 0,\n minimumFractionDigits: 0,\n minimumIntegerDigits: 1,\n style: 'decimal',\n useGrouping: true\n });\n NUMBER_FORMATTER_MAP.set(formatterId, numberFormatter);\n }\n return numberFormatter.format(number);\n}\n\n// ── Actions - Lookup ─────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport function lookupMimeTypeForExtension(extension?: string): string {\n // Extensions arrive from file names as typed, so 'REPORT.CSV' must resolve the same as 'report.csv'.\n switch (extension?.toLowerCase()) {\n case 'csv':\n return 'text/csv';\n case 'tab':\n case 'tsv':\n return 'text/tab-separated-values';\n case 'xls':\n return 'application/vnd.ms-excel';\n case 'xlsx':\n return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n default:\n return 'application/octet-stream';\n }\n}\n\n// TODO: Do we need this?\n// // export const establishVendorAccessToken = async (item: Item, accountId: string, sessionAccessToken: string, vendorRefreshURI: string): Promise<string> => {\n// export const establishVendorAccessToken = async (connectionConfig: ConnectionConfig, settings: ReadSettings, vendorRefreshURI: string): Promise<string> => {\n// let accessToken;\n//\n// // If the current dropbox access token expires within 5 minutes then refresh it and return the new one, otherwise return the current one.\n// if (connectionConfig.authorisation[''].expires_at - Date.now() < 300000) {\n// // TODO: Above is WRONG 'item.authorization!['']'. We need to know what authorisation.\n// const headers: HeadersInit = {\n// 'Account-Id': settings.accountId || '',\n// Authorization: settings.sessionAccessToken || '',\n// 'Connection-Id': connectionConfig.id\n// };\n// const response = await fetch(vendorRefreshURI, { headers });\n// if (!response.ok) {\n// const data = {\n// body: {\n// context: 'establishVendorAccessToken',\n// message: await response.text()\n// },\n// statusCode: response.status,\n// statusText: response.statusText\n// };\n// throw new Error('Unable to establish access token.|' + JSON.stringify(data));\n// }\n// accessToken = await response.text();\n// } else {\n// accessToken = connectionConfig.authorisation[''].access_token; // TODO: This is WRONG 'item.authorization!['']'. We need to know what authorisation.\n// }\n//\n// return accessToken;\n// };\n"],"mappings":";AAOA,IAAM,IAAwC;CAC1C;EAAC;EAAQ;GAAa,MAAuB,MAAM,IAAI,UAAU,GAAG,EAA0B,CAAC,EAAE;CAAO;CACxG;EAAC;EAAO;GAAY,MAAuB,MAAM,IAAI,SAAS,GAAG,EAA0B,CAAC,EAAE;CAAM;CACpG;EAAC;EAAQ;GAAS,MAAuB,MAAM,IAAI,UAAU,GAAG,EAA0B,CAAC,EAAE;CAAO;CACpG;EAAC;EAAQ;GAAO,MAAuB,MAAM,IAAI,UAAU,GAAG,EAA0B,CAAC,EAAE;CAAO;CAClG;EAAC;EAAM;GAAI,MAAsB,GAAG,EAA0B,CAAC,EAAE;CAAI;AACzE,GAEM,IAAkC,MAClC,oBAAuB,IAAI,IAA+B;AAKhE,SAAgB,EAAgC,GAA6B;CACzE,QAAQ,GAAR;EACI,KAAK,cACD,OAAO;EACX,KAAK,eACD,OAAO;EACX,KAAK,YACD,OAAO;EACX,KAAK,gBACD,OAAO;EACX,KAAK,sBACD,OAAO;EACX,KAAK,eACD,OAAO;EACX,KAAK,cACD,OAAO;EACX,KAAK,YACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,cACD,OAAO;EACX,KAAK,cACD,OAAO;EACX,KAAK,YACD,OAAO;EACX,SACI,OAAO;CACf;AACJ;AAOA,SAAgB,EAAoB,GAAs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,GAA4B;CAEnE,QAAQ,GAAW,YAAY,GAA/B;EACI,KAAK,OACD,OAAO;EACX,KAAK;EACL,KAAK,OACD,OAAO;EACX,KAAK,OACD,OAAO;EACX,KAAK,QACD,OAAO;EACX,SACI,OAAO;CACf;AACJ"}
1
+ {"version":3,"file":"dpuse-shared-utilities.es.js","names":[],"sources":["../src/utilities/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype DurationLevel = 'days' | 'hrs' | 'mins' | 'secs' | 'ms';\ntype DurationLevelTuple = [DurationLevel, number, (n: number) => string];\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst DURATION_LEVELS: DurationLevelTuple[] = [\n ['days', 86_400_000, (n: number): string => (n === 1 ? '1 day' : `${formatNumberAsWholeNumber(n)} days`)],\n ['hrs', 3_600_000, (n: number): string => (n === 1 ? '1 hr' : `${formatNumberAsWholeNumber(n)} hrs`)],\n ['mins', 60_000, (n: number): string => (n === 1 ? '1 min' : `${formatNumberAsWholeNumber(n)} mins`)],\n ['secs', 1000, (n: number): string => (n === 1 ? '1 sec' : `${formatNumberAsWholeNumber(n)} secs`)],\n ['ms', 0, (n: number): string => `${formatNumberAsWholeNumber(n)} ms`]\n];\n\nconst NUMBER_FORMATTER_DEFAULT_LOCALE = 'en';\nconst NUMBER_FORMATTER_MAP = new Map<string, Intl.NumberFormat>();\n\n// ── Actions - Data Type Conversion ───────────────────────────────────────────────────────────────────────────────────\n\n// See: https://www.odata.org/documentation/odata-version-2-0/overview/.\nexport function convertODataTypeIdToUsageTypeId(oDataTypeId: string): string {\n switch (oDataTypeId) {\n case 'Edm.Binary':\n return 'unknown'; // Binary...\n case 'Edm.Boolean':\n return 'boolean';\n case 'Edm.Byte':\n return 'wholeNumber';\n case 'Edm.DateTime':\n return 'moment'; // DateTime...\n case 'Edm.DateTimeOffset':\n return 'moment'; // DateTimeOffset...\n case 'Edm.Decimal':\n return 'decimalNumber';\n case 'Edm.Double':\n return 'decimalNumber';\n case 'Edm.Guid':\n return 'string';\n case 'Edm.Int16':\n return 'wholeNumber';\n case 'Edm.Int32':\n return 'wholeNumber';\n case 'Edm.Int64':\n return 'wholeNumber';\n case 'Edm.SByte':\n return 'wholeNumber';\n case 'Edm.Single':\n return 'decimalNumber';\n case 'Edm.String':\n return 'string';\n case 'Edm.Time':\n return 'momentTime'; // Time...\n default:\n return 'unknown';\n }\n}\n\n// ── Actions - File Path Segment Extraction ───────────────────────────────────────────────────────────────────────────\n\n// Extract the path without its final basename extension.\n// Dots in parent directories are ignored, and leading dots in the basename\n// are treated as part of dotfile names rather than as an extension separator.\nexport function extractNameFromPath(itemPath: string): string | undefined {\n if (itemPath) {\n const lastSeparatorIndex = itemPath.lastIndexOf('/');\n const basenameStartIndex = lastSeparatorIndex + 1;\n const lastExtensionIndex = itemPath.lastIndexOf('.');\n if (lastExtensionIndex <= basenameStartIndex) return itemPath;\n return lastExtensionIndex === -1 ? itemPath : itemPath.slice(0, Math.max(0, lastExtensionIndex));\n }\n return undefined;\n}\n\n// Extract only the final basename extension.\n// Returns undefined when the basename has no extension, including dotfiles such\n// as .gitignore where the only dot is the leading character of the basename.\nexport function extractExtensionFromPath(itemPath: string): string | undefined {\n if (itemPath) {\n const lastSeparatorIndex = itemPath.lastIndexOf('/');\n const basenameStartIndex = lastSeparatorIndex + 1;\n const lastExtensionIndex = itemPath.lastIndexOf('.');\n if (lastExtensionIndex <= basenameStartIndex) return undefined;\n if (lastExtensionIndex !== -1) return itemPath.slice(Math.max(0, lastExtensionIndex + 1));\n }\n return undefined;\n}\n\n// ── Actions - String Formatting ──────────────────────────────────────────────────────────────────────────────────────\n\nexport function formatNumberAsDecimalNumber(number?: number, decimalPlaces = 2, minimumFractionDigits = decimalPlaces, locale = NUMBER_FORMATTER_DEFAULT_LOCALE): string {\n if (number == null) return '';\n const formatterId = `${locale}decimal${String(decimalPlaces)}.${String(minimumFractionDigits)}`;\n let numberFormatter = NUMBER_FORMATTER_MAP.get(formatterId);\n if (!numberFormatter) {\n numberFormatter = new Intl.NumberFormat(locale, {\n localeMatcher: 'best fit',\n maximumFractionDigits: decimalPlaces,\n minimumFractionDigits,\n minimumIntegerDigits: 1,\n style: 'decimal',\n useGrouping: true\n });\n NUMBER_FORMATTER_MAP.set(formatterId, numberFormatter);\n }\n return numberFormatter.format(number);\n}\n\nexport function formatNumberAsSize(number?: number, decimalPlaces = 1): string {\n if (number == null) return '';\n if (number < 1000) return formatNumberAsWholeNumber(number);\n if (number < 1_000_000) return `${formatNumberAsDecimalNumber(number / 1000, decimalPlaces, 0)}K`;\n if (number < 1_000_000_000) return `${formatNumberAsDecimalNumber(number / 1_000_000, decimalPlaces, 0)}M`;\n return number < 1_000_000_000_000\n ? `${formatNumberAsDecimalNumber(number / 1_000_000_000, decimalPlaces, 0)}B`\n : `${formatNumberAsDecimalNumber(number / 1_000_000_000_000, decimalPlaces, 0)}T`;\n}\n\nexport function formatNumberAsStorageSize(number?: number, decimalPlaces = 1): string {\n if (number == null) return '';\n if (number === 1) return '1 byte';\n if (number < 1024) return `${formatNumberAsWholeNumber(number)} bytes`;\n if (number < 1_048_576) return `${formatNumberAsDecimalNumber(number / 1024, decimalPlaces, 0)} KB`;\n if (number < 1_073_741_824) return `${formatNumberAsDecimalNumber(number / 1_048_576, decimalPlaces, 0)} MB`;\n return number < 1_099_511_627_776\n ? `${formatNumberAsDecimalNumber(number / 1_073_741_824, decimalPlaces, 0)} GB`\n : `${formatNumberAsDecimalNumber(number / 1_099_511_627_776, decimalPlaces, 0)} TB`;\n}\n\nexport function formatNumberAsDuration(number?: number, stopAt: DurationLevel = 'ms'): string {\n if (number == null) return '';\n\n // Start at the largest unit the value actually fills, so a value below the requested level still reads sensibly\n // rather than as a run of zeroes.\n const startIndex = DURATION_LEVELS.findIndex(([, threshold]) => number >= threshold);\n const firstIndex = startIndex === -1 ? DURATION_LEVELS.length - 1 : startIndex;\n const stopIndex = DURATION_LEVELS.findIndex(([level]) => level === stopAt);\n\n const durationLevels = DURATION_LEVELS.slice(firstIndex, Math.max(stopIndex, firstIndex) + 1);\n const parts: string[] = [];\n let remaining = number;\n for (const [, threshold, format] of durationLevels) {\n if (remaining < threshold || (remaining === 0 && parts.length > 0)) continue;\n parts.push(format(threshold > 0 ? Math.floor(remaining / threshold) : remaining));\n remaining %= threshold > 0 ? threshold : 1;\n }\n return parts.join(' ');\n}\n\nexport function formatNumberAsWholeNumber(number?: number, locale = NUMBER_FORMATTER_DEFAULT_LOCALE): string {\n if (number == null) return '';\n const formatterId = `${locale}decimal0.0`;\n let numberFormatter = NUMBER_FORMATTER_MAP.get(formatterId);\n if (!numberFormatter) {\n numberFormatter = new Intl.NumberFormat(locale, {\n localeMatcher: 'best fit',\n maximumFractionDigits: 0,\n minimumFractionDigits: 0,\n minimumIntegerDigits: 1,\n style: 'decimal',\n useGrouping: true\n });\n NUMBER_FORMATTER_MAP.set(formatterId, numberFormatter);\n }\n return numberFormatter.format(number);\n}\n\n// ── Actions - Lookup ─────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport function lookupMimeTypeForExtension(extension?: string): string {\n // Extensions arrive from file names as typed, so 'REPORT.CSV' must resolve the same as 'report.csv'.\n switch (extension?.toLowerCase()) {\n case 'csv':\n return 'text/csv';\n case 'tab':\n case 'tsv':\n return 'text/tab-separated-values';\n case 'xls':\n return 'application/vnd.ms-excel';\n case 'xlsx':\n return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n default:\n return 'application/octet-stream';\n }\n}\n\n// TODO: Do we need this?\n// // export const establishVendorAccessToken = async (item: Item, accountId: string, sessionAccessToken: string, vendorRefreshURI: string): Promise<string> => {\n// export const establishVendorAccessToken = async (connectionConfig: ConnectionConfig, settings: ReadSettings, vendorRefreshURI: string): Promise<string> => {\n// let accessToken;\n//\n// // If the current dropbox access token expires within 5 minutes then refresh it and return the new one, otherwise return the current one.\n// if (connectionConfig.authorisation[''].expires_at - Date.now() < 300000) {\n// // TODO: Above is WRONG 'item.authorization!['']'. We need to know what authorisation.\n// const headers: HeadersInit = {\n// 'Account-Id': settings.accountId || '',\n// Authorization: settings.sessionAccessToken || '',\n// 'Connection-Id': connectionConfig.id\n// };\n// const response = await fetch(vendorRefreshURI, { headers });\n// if (!response.ok) {\n// const data = {\n// body: {\n// context: 'establishVendorAccessToken',\n// message: await response.text()\n// },\n// statusCode: response.status,\n// statusText: response.statusText\n// };\n// throw new Error('Unable to establish access token.|' + JSON.stringify(data));\n// }\n// accessToken = await response.text();\n// } else {\n// accessToken = connectionConfig.authorisation[''].access_token; // TODO: This is WRONG 'item.authorization!['']'. We need to know what authorisation.\n// }\n//\n// return accessToken;\n// };\n"],"mappings":";AAOA,IAAM,IAAwC;CAC1C;EAAC;EAAQ;GAAa,MAAuB,MAAM,IAAI,UAAU,GAAG,EAA0B,CAAC,EAAE;CAAO;CACxG;EAAC;EAAO;GAAY,MAAuB,MAAM,IAAI,SAAS,GAAG,EAA0B,CAAC,EAAE;CAAM;CACpG;EAAC;EAAQ;GAAS,MAAuB,MAAM,IAAI,UAAU,GAAG,EAA0B,CAAC,EAAE;CAAO;CACpG;EAAC;EAAQ;GAAO,MAAuB,MAAM,IAAI,UAAU,GAAG,EAA0B,CAAC,EAAE;CAAO;CAClG;EAAC;EAAM;GAAI,MAAsB,GAAG,EAA0B,CAAC,EAAE;CAAI;AACzE,GAEM,IAAkC,MAClC,oBAAuB,IAAI,IAA+B;AAKhE,SAAgB,EAAgC,GAA6B;CACzE,QAAQ,GAAR;EACI,KAAK,cACD,OAAO;EACX,KAAK,eACD,OAAO;EACX,KAAK,YACD,OAAO;EACX,KAAK,gBACD,OAAO;EACX,KAAK,sBACD,OAAO;EACX,KAAK,eACD,OAAO;EACX,KAAK,cACD,OAAO;EACX,KAAK,YACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,aACD,OAAO;EACX,KAAK,cACD,OAAO;EACX,KAAK,cAC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CAAC,GACD,EAAqB,IAAI,GAAa,CAAe,IAElD,EAAgB,OAAO,CAAM;AACxC;AAIA,SAAgB,EAA2B,GAA4B;CAEnE,QAAQ,GAAW,YAAY,GAA/B;EACI,KAAK,OACD,OAAO;EACX,KAAK;EACL,KAAK,OACD,OAAO;EACX,KAAK,OACD,OAAO;EACX,KAAK,QACD,OAAO;EACX,SACI,OAAO;CACf;AACJ"}
@@ -1,11 +1,11 @@
1
1
  import { ComponentInstanceConfig } from '../..';
2
- import { LocalisedEncodingTypeConfig } from '../../../encoding';
2
+ import { EncodingTypeConfigLocalised } from '../../../encoding';
3
3
  import { LocaleId } from '../../../locale/label';
4
4
  import { LocalisedConfig } from '../../../locale';
5
5
  import { ModuleConfig } from '..';
6
6
  import { ToolConfig } from '../tool';
7
7
  export interface EngineRuntime {
8
- getEncodingTypeConfigs: (localeId: LocaleId) => LocalisedEncodingTypeConfig[];
8
+ getEncodingTypeConfigs: (localeId: LocaleId) => EncodingTypeConfigLocalised[];
9
9
  invokeWorker(errorEventCallback: (errorEvent: ErrorEvent) => void): EngineWorker;
10
10
  }
11
11
  export interface EngineWorker {
@@ -1,8 +1,6 @@
1
1
  import { LocaleId, LocaleLabel } from '../locale/label';
2
- import { default as encodingGroupConfigData } from './encodingGroupConfigs.json';
3
- import { default as encodingTypeConfigData } from './encodingTypeConfigs.json';
4
- export type EncodingGroupId = keyof typeof encodingGroupConfigData;
5
- export type EncodingTypeId = keyof typeof encodingTypeConfigData;
2
+ export type EncodingGroupId = keyof typeof ENCODING_GROUP_CONFIG_DATA;
3
+ export type EncodingTypeId = keyof typeof ENCODING_TYPE_CONFIG_DATA;
6
4
  export interface EncodingGroupConfig {
7
5
  id: EncodingGroupId;
8
6
  label: LocaleLabel;
@@ -24,6 +22,453 @@ export interface EncodingDetectionConfig {
24
22
  id: EncodingTypeId;
25
23
  confidenceLevel: number | undefined;
26
24
  }
25
+ declare const ENCODING_GROUP_CONFIG_DATA: {
26
+ readonly arabic: {
27
+ readonly id: "arabic";
28
+ readonly label: {
29
+ readonly en: "Arabic";
30
+ readonly es: "Árabe";
31
+ };
32
+ };
33
+ readonly baltic: {
34
+ readonly id: "baltic";
35
+ readonly label: {
36
+ readonly en: "Baltic";
37
+ readonly es: "Báltico";
38
+ };
39
+ };
40
+ readonly celtic: {
41
+ readonly id: "celtic";
42
+ readonly label: {
43
+ readonly en: "Celtic";
44
+ readonly es: "Celta";
45
+ };
46
+ };
47
+ readonly centralEuropean: {
48
+ readonly id: "centralEuropean";
49
+ readonly label: {
50
+ readonly en: "Central European";
51
+ readonly es: "Centroeuropeo";
52
+ };
53
+ };
54
+ readonly chineseSimplified: {
55
+ readonly id: "chineseSimplified";
56
+ readonly label: {
57
+ readonly en: "Chinese Simplified";
58
+ readonly es: "Chino simplificado";
59
+ };
60
+ };
61
+ readonly chineseTraditional: {
62
+ readonly id: "chineseTraditional";
63
+ readonly label: {
64
+ readonly en: "Chinese Traditional";
65
+ readonly es: "Chino tradicional";
66
+ };
67
+ };
68
+ readonly cyrillic: {
69
+ readonly id: "cyrillic";
70
+ readonly label: {
71
+ readonly en: "Cyrillic";
72
+ readonly es: "Cirílico";
73
+ };
74
+ };
75
+ readonly greek: {
76
+ readonly id: "greek";
77
+ readonly label: {
78
+ readonly en: "Greek";
79
+ readonly es: "Griego";
80
+ };
81
+ };
82
+ readonly hebrew: {
83
+ readonly id: "hebrew";
84
+ readonly label: {
85
+ readonly en: "Hebrew";
86
+ readonly es: "Hebreo";
87
+ };
88
+ };
89
+ readonly japanese: {
90
+ readonly id: "japanese";
91
+ readonly label: {
92
+ readonly en: "Japanese";
93
+ readonly es: "Japonés";
94
+ };
95
+ };
96
+ readonly korean: {
97
+ readonly id: "korean";
98
+ readonly label: {
99
+ readonly en: "Korean";
100
+ readonly es: "Coreano";
101
+ };
102
+ };
103
+ readonly nordic: {
104
+ readonly id: "nordic";
105
+ readonly label: {
106
+ readonly en: "Nordic";
107
+ readonly es: "Nórdico";
108
+ };
109
+ };
110
+ readonly other: {
111
+ readonly id: "other";
112
+ readonly label: {
113
+ readonly en: "Other";
114
+ readonly es: "Otro";
115
+ };
116
+ };
117
+ readonly romanian: {
118
+ readonly id: "romanian";
119
+ readonly label: {
120
+ readonly en: "Romanian";
121
+ readonly es: "Rumano";
122
+ };
123
+ };
124
+ readonly southernEuropean: {
125
+ readonly id: "southernEuropean";
126
+ readonly label: {
127
+ readonly en: "Southern European";
128
+ readonly es: "Europeo meridional";
129
+ };
130
+ };
131
+ readonly thai: {
132
+ readonly id: "thai";
133
+ readonly label: {
134
+ readonly en: "Thai";
135
+ readonly es: "Tailandés";
136
+ };
137
+ };
138
+ readonly turkish: {
139
+ readonly id: "turkish";
140
+ readonly label: {
141
+ readonly en: "Turkish";
142
+ readonly es: "Turco";
143
+ };
144
+ };
145
+ readonly unicode16: {
146
+ readonly id: "unicode16";
147
+ readonly label: {
148
+ readonly en: "Unicode 16";
149
+ readonly es: "Unicode 16";
150
+ };
151
+ };
152
+ readonly unicode32: {
153
+ readonly id: "unicode32";
154
+ readonly label: {
155
+ readonly en: "Unicode 32";
156
+ readonly es: "Unicode 32";
157
+ };
158
+ };
159
+ readonly vietnamese: {
160
+ readonly id: "vietnamese";
161
+ readonly label: {
162
+ readonly en: "Vietnamese";
163
+ readonly es: "Vietnamita";
164
+ };
165
+ };
166
+ readonly western: {
167
+ readonly id: "western";
168
+ readonly label: {
169
+ readonly en: "Western";
170
+ readonly es: "Occidental";
171
+ };
172
+ };
173
+ };
174
+ declare const ENCODING_TYPE_CONFIG_DATA: {
175
+ readonly ascii: {
176
+ readonly id: "ascii";
177
+ readonly groupId: null;
178
+ readonly isDetectable: false;
179
+ readonly isDecodable: true;
180
+ };
181
+ readonly big5: {
182
+ readonly id: "big5";
183
+ readonly groupId: "chineseTraditional";
184
+ readonly isDetectable: true;
185
+ readonly isDecodable: true;
186
+ };
187
+ readonly 'euc-jp': {
188
+ readonly id: "euc-jp";
189
+ readonly groupId: "japanese";
190
+ readonly isDetectable: true;
191
+ readonly isDecodable: true;
192
+ };
193
+ readonly 'euc-kr': {
194
+ readonly id: "euc-kr";
195
+ readonly groupId: "korean";
196
+ readonly isDetectable: true;
197
+ readonly isDecodable: true;
198
+ };
199
+ readonly gb18030: {
200
+ readonly id: "gb18030";
201
+ readonly groupId: "chineseSimplified";
202
+ readonly isDetectable: true;
203
+ readonly isDecodable: true;
204
+ };
205
+ readonly gbk: {
206
+ readonly id: "gbk";
207
+ readonly groupId: "chineseSimplified";
208
+ readonly isDetectable: false;
209
+ readonly isDecodable: true;
210
+ };
211
+ readonly ibm866: {
212
+ readonly id: "ibm866";
213
+ readonly groupId: "cyrillic";
214
+ readonly isDetectable: false;
215
+ readonly isDecodable: true;
216
+ };
217
+ readonly 'iso-2022-cn': {
218
+ readonly id: "iso-2022-cn";
219
+ readonly groupId: "chineseSimplified";
220
+ readonly isDetectable: true;
221
+ readonly isDecodable: false;
222
+ };
223
+ readonly 'iso-2022-jp': {
224
+ readonly id: "iso-2022-jp";
225
+ readonly groupId: "japanese";
226
+ readonly isDetectable: true;
227
+ readonly isDecodable: true;
228
+ };
229
+ readonly 'iso-2022-kr': {
230
+ readonly id: "iso-2022-kr";
231
+ readonly groupId: "korean";
232
+ readonly isDetectable: true;
233
+ readonly isDecodable: false;
234
+ };
235
+ readonly 'iso-8859-1': {
236
+ readonly id: "iso-8859-1";
237
+ readonly groupId: "western";
238
+ readonly isDetectable: true;
239
+ readonly isDecodable: true;
240
+ };
241
+ readonly 'iso-8859-2': {
242
+ readonly id: "iso-8859-2";
243
+ readonly groupId: "centralEuropean";
244
+ readonly isDetectable: true;
245
+ readonly isDecodable: true;
246
+ };
247
+ readonly 'iso-8859-3': {
248
+ readonly id: "iso-8859-3";
249
+ readonly groupId: "southernEuropean";
250
+ readonly isDetectable: false;
251
+ readonly isDecodable: true;
252
+ };
253
+ readonly 'iso-8859-4': {
254
+ readonly id: "iso-8859-4";
255
+ readonly groupId: "baltic";
256
+ readonly isDetectable: false;
257
+ readonly isDecodable: true;
258
+ };
259
+ readonly 'iso-8859-5': {
260
+ readonly id: "iso-8859-5";
261
+ readonly groupId: "cyrillic";
262
+ readonly isDetectable: true;
263
+ readonly isDecodable: true;
264
+ };
265
+ readonly 'iso-8859-6': {
266
+ readonly id: "iso-8859-6";
267
+ readonly groupId: "arabic";
268
+ readonly isDetectable: true;
269
+ readonly isDecodable: true;
270
+ };
271
+ readonly 'iso-8859-7': {
272
+ readonly id: "iso-8859-7";
273
+ readonly groupId: "greek";
274
+ readonly isDetectable: true;
275
+ readonly isDecodable: true;
276
+ };
277
+ readonly 'iso-8859-8': {
278
+ readonly id: "iso-8859-8";
279
+ readonly groupId: "hebrew";
280
+ readonly isDetectable: true;
281
+ readonly isDecodable: true;
282
+ };
283
+ readonly 'iso-8859-9': {
284
+ readonly id: "iso-8859-9";
285
+ readonly groupId: "turkish";
286
+ readonly isDetectable: true;
287
+ readonly isDecodable: true;
288
+ };
289
+ readonly 'iso-8859-10': {
290
+ readonly id: "iso-8859-10";
291
+ readonly groupId: "nordic";
292
+ readonly isDetectable: false;
293
+ readonly isDecodable: true;
294
+ };
295
+ readonly 'iso-8859-11': {
296
+ readonly id: "iso-8859-11";
297
+ readonly groupId: "thai";
298
+ readonly isDetectable: false;
299
+ readonly isDecodable: true;
300
+ };
301
+ readonly 'iso-8859-13': {
302
+ readonly id: "iso-8859-13";
303
+ readonly groupId: "baltic";
304
+ readonly isDetectable: false;
305
+ readonly isDecodable: true;
306
+ };
307
+ readonly 'iso-8859-14': {
308
+ readonly id: "iso-8859-14";
309
+ readonly groupId: "celtic";
310
+ readonly isDetectable: false;
311
+ readonly isDecodable: true;
312
+ };
313
+ readonly 'iso-8859-15': {
314
+ readonly id: "iso-8859-15";
315
+ readonly groupId: "western";
316
+ readonly isDetectable: false;
317
+ readonly isDecodable: true;
318
+ };
319
+ readonly 'iso-8859-16': {
320
+ readonly id: "iso-8859-16";
321
+ readonly groupId: "romanian";
322
+ readonly isDetectable: false;
323
+ readonly isDecodable: true;
324
+ };
325
+ readonly 'koi8-r': {
326
+ readonly id: "koi8-r";
327
+ readonly groupId: "cyrillic";
328
+ readonly isDetectable: true;
329
+ readonly isDecodable: true;
330
+ };
331
+ readonly 'koi8-u': {
332
+ readonly id: "koi8-u";
333
+ readonly groupId: "cyrillic";
334
+ readonly isDetectable: false;
335
+ readonly isDecodable: true;
336
+ };
337
+ readonly latin1: {
338
+ readonly id: "latin1";
339
+ readonly groupId: "western";
340
+ readonly isDetectable: false;
341
+ readonly isDecodable: true;
342
+ };
343
+ readonly macintosh: {
344
+ readonly id: "macintosh";
345
+ readonly groupId: "western";
346
+ readonly isDetectable: false;
347
+ readonly isDecodable: true;
348
+ };
349
+ readonly shift_jis: {
350
+ readonly id: "shift_jis";
351
+ readonly groupId: "japanese";
352
+ readonly isDetectable: true;
353
+ readonly isDecodable: true;
354
+ };
355
+ readonly 'tis-620': {
356
+ readonly id: "tis-620";
357
+ readonly groupId: "thai";
358
+ readonly isDetectable: false;
359
+ readonly isDecodable: true;
360
+ };
361
+ readonly 'utf-16': {
362
+ readonly id: "utf-16";
363
+ readonly groupId: "unicode16";
364
+ readonly isDetectable: false;
365
+ readonly isDecodable: true;
366
+ };
367
+ readonly 'utf-16be': {
368
+ readonly id: "utf-16be";
369
+ readonly groupId: "unicode16";
370
+ readonly isDetectable: true;
371
+ readonly isDecodable: true;
372
+ };
373
+ readonly 'utf-16le': {
374
+ readonly id: "utf-16le";
375
+ readonly groupId: "unicode16";
376
+ readonly isDetectable: true;
377
+ readonly isDecodable: true;
378
+ };
379
+ readonly 'utf-32be': {
380
+ readonly id: "utf-32be";
381
+ readonly groupId: "unicode32";
382
+ readonly isDetectable: true;
383
+ readonly isDecodable: false;
384
+ };
385
+ readonly 'utf-32le': {
386
+ readonly id: "utf-32le";
387
+ readonly groupId: "unicode32";
388
+ readonly isDetectable: true;
389
+ readonly isDecodable: false;
390
+ };
391
+ readonly 'utf-8': {
392
+ readonly id: "utf-8";
393
+ readonly groupId: null;
394
+ readonly isDetectable: true;
395
+ readonly isDecodable: true;
396
+ };
397
+ readonly 'windows-1250': {
398
+ readonly id: "windows-1250";
399
+ readonly groupId: "centralEuropean";
400
+ readonly isDetectable: true;
401
+ readonly isDecodable: true;
402
+ };
403
+ readonly 'windows-1251': {
404
+ readonly id: "windows-1251";
405
+ readonly groupId: "cyrillic";
406
+ readonly isDetectable: true;
407
+ readonly isDecodable: true;
408
+ };
409
+ readonly 'windows-1252': {
410
+ readonly id: "windows-1252";
411
+ readonly groupId: "western";
412
+ readonly isDetectable: true;
413
+ readonly isDecodable: true;
414
+ };
415
+ readonly 'windows-1253': {
416
+ readonly id: "windows-1253";
417
+ readonly groupId: "greek";
418
+ readonly isDetectable: true;
419
+ readonly isDecodable: true;
420
+ };
421
+ readonly 'windows-1254': {
422
+ readonly id: "windows-1254";
423
+ readonly groupId: "turkish";
424
+ readonly isDetectable: true;
425
+ readonly isDecodable: true;
426
+ };
427
+ readonly 'windows-1255': {
428
+ readonly id: "windows-1255";
429
+ readonly groupId: "hebrew";
430
+ readonly isDetectable: true;
431
+ readonly isDecodable: true;
432
+ };
433
+ readonly 'windows-1256': {
434
+ readonly id: "windows-1256";
435
+ readonly groupId: "arabic";
436
+ readonly isDetectable: true;
437
+ readonly isDecodable: true;
438
+ };
439
+ readonly 'windows-1257': {
440
+ readonly id: "windows-1257";
441
+ readonly groupId: "baltic";
442
+ readonly isDetectable: false;
443
+ readonly isDecodable: true;
444
+ };
445
+ readonly 'windows-1258': {
446
+ readonly id: "windows-1258";
447
+ readonly groupId: "vietnamese";
448
+ readonly isDetectable: false;
449
+ readonly isDecodable: true;
450
+ };
451
+ readonly 'windows-874': {
452
+ readonly id: "windows-874";
453
+ readonly groupId: "thai";
454
+ readonly isDetectable: false;
455
+ readonly isDecodable: true;
456
+ };
457
+ readonly 'x-mac-cyrillic': {
458
+ readonly id: "x-mac-cyrillic";
459
+ readonly groupId: "cyrillic";
460
+ readonly isDetectable: false;
461
+ readonly isDecodable: true;
462
+ };
463
+ readonly 'x-user-defined': {
464
+ readonly id: "x-user-defined";
465
+ readonly groupId: "other";
466
+ readonly isDetectable: false;
467
+ readonly isDecodable: true;
468
+ };
469
+ };
27
470
  export declare const ENCODING_GROUP_CONFIG_MAP: Record<EncodingGroupId, EncodingGroupConfig>;
28
- export declare const ENCODING_TYPE_CONFIG_MAP: Record<string, EncodingTypeConfig>;
471
+ export declare const ENCODING_TYPE_CONFIG_MAP: Record<EncodingTypeId, EncodingTypeConfig>;
472
+ export declare function isEncodingTypeId(value: string): value is EncodingTypeId;
29
473
  export declare function getEncodingTypeConfigs(localeId?: LocaleId): EncodingTypeConfigLocalised[];
474
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpuse/dpuse-shared",
3
- "version": "0.3.821",
3
+ "version": "0.3.823",
4
4
  "private": false,
5
5
  "description": "Common constants, types and utilities used across all DPUse projects.",
6
6
  "license": "MIT",
@@ -151,11 +151,12 @@
151
151
  "audit": "node -e \"import('@dpuse/dpuse-development').then(m => m.auditDependencies())\"",
152
152
  "build": "node -e \"import('@dpuse/dpuse-development').then(m => m.buildProject())\" && npm run documentBundleSizes",
153
153
  "check": "node -e \"import('@dpuse/dpuse-development').then(m => m.checkConfigFiles())\" && node -e \"import('@dpuse/dpuse-development').then(m => m.checkDependencies())\"",
154
- "document": "npm run documentOpening && npm run documentDependencies && npm run documentGovernance",
154
+ "document": "npm run documentOpening && npm run documentUsage && npm run documentDependencies && npm run documentGovernance",
155
155
  "documentBundleSizes": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentBundleSizes())\"",
156
- "documentDependencies": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentDependencies('MIT'))\"",
156
+ "documentDependencies": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentDependencies('Apache-2.0;BSD-3-Clause;MIT'))\"",
157
157
  "documentGovernance": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentGovernance())\"",
158
158
  "documentOpening": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentOpening())\"",
159
+ "documentUsage": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentUsage())\"",
159
160
  "format": "node -e \"import('@dpuse/dpuse-development').then(m => m.formatCode())\"",
160
161
  "health": "npm run test:coverage && fallow --coverage coverage/coverage-final.json",
161
162
  "lint": "node -e \"import('@dpuse/dpuse-development').then(m => m.lintCode())\"",
@@ -170,7 +171,7 @@
170
171
  },
171
172
  "devDependencies": {
172
173
  "@dpuse/dpuse-development": "^0.3.722",
173
- "@dpuse/eslint-config-dpuse": "^1.0.121",
174
+ "@dpuse/eslint-config-dpuse": "^1.0.122",
174
175
  "@types/node": "^26.6.2",
175
176
  "@vitest/coverage-v8": "^5.0.1",
176
177
  "eslint": "^10.11.0",
@@ -178,7 +179,7 @@
178
179
  "prettier": "^3.9.9",
179
180
  "sonda": "^0.14.0",
180
181
  "typescript": "^6.0.3",
181
- "vite": "^8.3.0",
182
+ "vite": "^8.3.1",
182
183
  "vite-plugin-dts": "^5.1.1",
183
184
  "vitest": "^5.0.1"
184
185
  }