@datapos/datapos-shared 0.3.156 → 0.3.158

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.
@@ -1,3 +1,3 @@
1
1
  /**
2
- * Document composables, constants, types/interfaces, errors and utilities..
2
+ * Document composables, constants, errors, types/interfaces and utilities.
3
3
  */
@@ -12,6 +12,8 @@ export type { EngineModuleConfig } from './module';
12
12
  export type { InformerModuleConfig, InformerModuleOperation } from './module';
13
13
  export type { PresenterModuleConfig, PresenterModuleOperation } from './module';
14
14
  export { CONNECTOR_DESTINATION_OPERATIONS, CONNECTOR_SOURCE_OPERATIONS } from './module';
15
+ export type { ModuleConfigZ } from './module/configSchema';
16
+ export { moduleConfigSchema, partialLocalisedStringSchema } from './module/configSchema';
15
17
  export type { ComponentConfig, ComponentRef, ComponentStatus, ComponentStatusId, ComponentTypeId } from './component';
16
18
  export type { AuditContentResult, AuditContentSettings } from './component/connector';
17
19
  export type { Connector, ConnectorCallbackData, ConnectorConfig, ConnectorImplementation, ConnectorOperationSettings, ConnectorLocalisedConfig, ConnectorTools } from './component/connector';
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export declare const partialLocalisedStringSchema: z.ZodObject<{
3
+ 'en-au': z.ZodOptional<z.ZodString>;
4
+ 'en-gb': z.ZodOptional<z.ZodString>;
5
+ 'en-us': z.ZodOptional<z.ZodString>;
6
+ 'es-es': z.ZodOptional<z.ZodString>;
7
+ }, z.core.$strip>;
8
+ export declare const moduleConfigSchema: z.ZodObject<{
9
+ id: z.ZodString;
10
+ label: z.ZodObject<{
11
+ 'en-au': z.ZodOptional<z.ZodString>;
12
+ 'en-gb': z.ZodOptional<z.ZodString>;
13
+ 'en-us': z.ZodOptional<z.ZodString>;
14
+ 'es-es': z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ description: z.ZodObject<{
17
+ 'en-au': z.ZodOptional<z.ZodString>;
18
+ 'en-gb': z.ZodOptional<z.ZodString>;
19
+ 'en-us': z.ZodOptional<z.ZodString>;
20
+ 'es-es': z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>;
22
+ statusId: z.ZodUnknown;
23
+ typeId: z.ZodEnum<{
24
+ connector: "connector";
25
+ context: "context";
26
+ presenter: "presenter";
27
+ informer: "informer";
28
+ app: "app";
29
+ engine: "engine";
30
+ }>;
31
+ version: z.ZodString;
32
+ }, z.core.$strip>;
33
+ export type ModuleConfigZ = z.infer<typeof moduleConfigSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-shared",
3
- "version": "0.3.156",
3
+ "version": "0.3.158",
4
4
  "description": "A TypeScript library containing common declarations and utilities used across other Data Positioning repositories.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -45,7 +45,8 @@
45
45
  "retire": "^5.3.0",
46
46
  "typescript": "^5.9.3",
47
47
  "vite": "^7.2.2",
48
- "vite-plugin-dts": "^4.5.4"
48
+ "vite-plugin-dts": "^4.5.4",
49
+ "zod": "^4.1.12"
49
50
  },
50
51
  "scripts": {
51
52
  "audit": "npm audit",
@@ -1,361 +0,0 @@
1
- const C = ["createObject", "dropObject", "removeRecords", "upsertRecords"], $ = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"];
2
- function _() {
3
- function e(t, a, r) {
4
- r.textContent = "Cytoscape.js diagram goes here...";
5
- }
6
- return { render: e };
7
- }
8
- function L() {
9
- function e(t, a, r) {
10
- r.textContent = "values table goes here...";
11
- }
12
- return { render: e };
13
- }
14
- const v = "https://cdn.jsdelivr.net/npm/highcharts@11.4.3/es-modules/masters/", x = "highcharts";
15
- let b, T = !1;
16
- function F() {
17
- async function e(n, s, u, h) {
18
- await r();
19
- const l = [];
20
- for (const c of s.data.measures)
21
- l.push({ type: n.options.highchartsType, name: c.name, data: c.data });
22
- const g = {
23
- chart: { type: n.options.highchartsType },
24
- plotOptions: { series: { borderColor: "#333" } },
25
- series: l,
26
- title: { text: s.title.text },
27
- xAxis: { categories: s.data.categoryLabels },
28
- yAxis: { title: { text: s.data.name } }
29
- }, m = b.chart(u, g, h);
30
- return { chart: m, resize: () => m.reflow(), vendorId: x };
31
- }
32
- async function t(n, s, u, h) {
33
- await Promise.all([r(), o()]);
34
- const l = [];
35
- for (const c of s.data.measures)
36
- l.push({ type: n.options.highchartsType, name: c.name, data: c.data });
37
- const g = {
38
- chart: { polar: !0 },
39
- plotOptions: { series: { borderColor: "#333" } },
40
- series: l,
41
- title: { text: s.title.text },
42
- xAxis: { categories: s.data.categoryLabels },
43
- yAxis: { title: { text: s.data.name } }
44
- }, m = b.chart(u, g, h);
45
- return { chart: m, resize: () => m.reflow(), vendorId: x };
46
- }
47
- async function a(n, s, u, h) {
48
- await Promise.all([r(), o()]);
49
- const l = [], g = [];
50
- for (let f = 0; f < s.data.measures[0].data.length; f++)
51
- g.push([s.data.measures[0].data[f][0], s.data.measures[1].data[f][0]]);
52
- l.push({ type: n.options.highchartsType, name: "Unknown", data: g });
53
- const m = {
54
- chart: { type: n.options.highchartsType, inverted: n.options.inverted },
55
- plotOptions: { series: { borderColor: "#333" } },
56
- series: l,
57
- title: { text: s.title.text },
58
- xAxis: { categories: s.data.categoryLabels },
59
- yAxis: { title: { text: s.data.name } }
60
- }, c = b.chart(u, m, h);
61
- return { chart: c, resize: () => c.reflow(), vendorId: x };
62
- }
63
- async function r() {
64
- if (b) return;
65
- const n = "https://cdn.jsdelivr.net/npm/highcharts@11.4.3/es-modules/masters/", s = `${n}highcharts.src.js`, u = `${n}modules/accessibility.src.js`;
66
- b = (await import(
67
- /* @vite-ignore */
68
- s
69
- )).default, await import(
70
- /* @vite-ignore */
71
- u
72
- );
73
- }
74
- async function o() {
75
- if (T) return;
76
- await import(`${v}highcharts-more.src.js`), T = !0;
77
- }
78
- return { renderCartesianChart: e, renderPolarChart: t, renderRangeChart: a };
79
- }
80
- const k = 0, M = (e) => e, U = () => Date.now(), j = {
81
- cartesian_areaLine: { categoryId: "cartesian", typeId: "areaLine", label: { "en-gb": "Area Line" }, options: { highchartsType: "area" } },
82
- cartesian_areaSpline: { categoryId: "cartesian", typeId: "areaSpline", label: { "en-gb": "Area Spline" }, options: { highchartsType: "area" } },
83
- cartesian_bar: { categoryId: "cartesian", typeId: "bar", label: { "en-gb": "Bar" }, options: { highchartsType: "bar" } },
84
- cartesian_column: { categoryId: "cartesian", typeId: "column", label: { "en-gb": "Column" }, options: { highchartsType: "column" } },
85
- cartesian_line: { categoryId: "cartesian", typeId: "line", label: { "en-gb": "Line" }, options: { highchartsType: "line" } },
86
- cartesian_pyramid: { categoryId: "cartesian", typeId: "line", label: { "en-gb": "Pyramid" }, options: { highchartsType: "line" } },
87
- cartesian_spline: { categoryId: "cartesian", typeId: "line", label: { "en-gb": "Spline" }, options: { highchartsType: "line" } },
88
- chordDiagram: { categoryId: "chordDiagram", label: { "en-gb": "Chord Diagram" }, options: {} },
89
- polar_area: { categoryId: "polar", typeId: "area", label: { "en-gb": "Radar (Area)" }, options: { highchartsType: "area" } },
90
- polar_column: { categoryId: "polar", typeId: "column", label: { "en-gb": "Radar (Column)" }, options: { highchartsType: "column" } },
91
- polar_line: { categoryId: "polar", typeId: "line", label: { "en-gb": "Radar (Line)" }, options: { highchartsType: "line" } },
92
- range_area: { categoryId: "range", typeId: "area", label: { "en-gb": "Range (Area)" }, options: { highchartsType: "arearange" } },
93
- range_bar: { categoryId: "range", typeId: "bar", label: { "en-gb": "Range (Bar)" }, options: { highchartsType: "columnrange", inverted: !0 } },
94
- range_column: { categoryId: "range", typeId: "column", label: { "en-gb": "Range (Column)" }, options: { highchartsType: "columnrange" } },
95
- sankeyDiagram: { categoryId: "sankeyDiagram", label: { "en-gb": "Sankey Diagram" }, options: {} },
96
- streamgraph: { categoryId: "streamgraph", label: { "en-gb": "Streamgraph" }, options: {} },
97
- values: { categoryId: "values", label: { "en-gb": "Values" }, options: {} }
98
- };
99
- class I extends Error {
100
- locator;
101
- constructor(t, a, r) {
102
- super(t, r), this.name = "DataPosError", this.locator = a, Error.captureStackTrace?.(this, new.target);
103
- }
104
- }
105
- class p extends I {
106
- constructor(t, a, r) {
107
- super(t, a, r), this.name = "ApplicationError";
108
- }
109
- }
110
- class B extends p {
111
- constructor(t, a, r) {
112
- super(t, a, r), this.name = "APIError";
113
- }
114
- }
115
- class H extends p {
116
- constructor(t, a, r) {
117
- super(t, a, r), this.name = "EngineError";
118
- }
119
- }
120
- class w extends p {
121
- body;
122
- constructor(t, a, r, o) {
123
- super(t, a, o), this.name = "FetchError", this.body = r;
124
- }
125
- }
126
- class S extends p {
127
- componentName;
128
- info;
129
- constructor(t, a, r, o, n) {
130
- super(t, a, n), this.name = "VueHandledError", this.info = r, this.componentName = o;
131
- }
132
- }
133
- class P extends p {
134
- constructor(t, a, r) {
135
- super(t, a, r), this.name = "WindowHandledRuntimeError";
136
- }
137
- }
138
- class W extends p {
139
- constructor(t, a, r) {
140
- super(t, a, r), this.name = "WindowHandledPromiseRejectionError";
141
- }
142
- }
143
- class z extends I {
144
- constructor(t, a, r) {
145
- super(t, a, r), this.name = "OperationalError";
146
- }
147
- }
148
- async function V(e, t, a) {
149
- const r = `${t} Response status '${e.status}${e.statusText ? ` - ${e.statusText}` : ""}' received.`, o = await e.text();
150
- return new w(r, a, o);
151
- }
152
- function X(e) {
153
- return e.map((t) => t.message).join(" ");
154
- }
155
- function G(e, t = "Unknown error.") {
156
- if (e instanceof Error) return e;
157
- if (typeof e == "string") return new Error(e);
158
- try {
159
- return new Error(JSON.stringify(e ?? t));
160
- } catch {
161
- return new Error(t);
162
- }
163
- }
164
- function J(e) {
165
- const t = /* @__PURE__ */ new Set(), a = [];
166
- let r = e;
167
- for (; r && !t.has(r); ) {
168
- t.add(r);
169
- let o;
170
- if (r instanceof w)
171
- o = { body: r.body, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
172
- else if (r instanceof S)
173
- o = { componentName: r.componentName, info: r.info, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
174
- else if (r instanceof I)
175
- o = { locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
176
- else if (r instanceof Error) {
177
- const n = r;
178
- o = { locator: "", message: n.message, name: n.name, stack: n.stack }, r = n.cause;
179
- } else r ? (o = { locator: "", message: String(r), name: "Error" }, r = void 0) : (o = { locator: "", message: "Unknown error.", name: "Error" }, r = void 0);
180
- /(?:\.{3}|[.!?])$/.test(o.message) || (o.message += "."), a.push(o);
181
- }
182
- return a;
183
- }
184
- const D = "en-US", y = {}, K = (e) => {
185
- switch (e) {
186
- case "Edm.Binary":
187
- return "unknown";
188
- // Binary...
189
- case "Edm.Boolean":
190
- return "boolean";
191
- case "Edm.Byte":
192
- return "wholeNumber";
193
- case "Edm.DateTime":
194
- return "moment";
195
- // DateTime...
196
- case "Edm.DateTimeOffset":
197
- return "moment";
198
- // DateTimeOffset...
199
- case "Edm.Decimal":
200
- return "decimalNumber";
201
- case "Edm.Double":
202
- return "decimalNumber";
203
- case "Edm.Guid":
204
- return "string";
205
- case "Edm.Int16":
206
- return "wholeNumber";
207
- case "Edm.Int32":
208
- return "wholeNumber";
209
- case "Edm.Int64":
210
- return "wholeNumber";
211
- case "Edm.SByte":
212
- return "wholeNumber";
213
- case "Edm.Single":
214
- return "decimalNumber";
215
- case "Edm.String":
216
- return "string";
217
- case "Edm.Time":
218
- return "momentTime";
219
- // Time...
220
- default:
221
- return "unknown";
222
- }
223
- }, q = (e) => {
224
- if (e) {
225
- const t = e.lastIndexOf("/"), a = e.lastIndexOf(".", t > -1 ? t : e.length);
226
- return a > -1 ? e.substring(0, a) : e;
227
- }
228
- }, Q = (e) => {
229
- if (e) {
230
- const t = e.lastIndexOf(".");
231
- if (t > -1) return e.substring(t + 1);
232
- }
233
- }, i = (e, t = 2, a = t, r = D) => {
234
- if (e == null) return "";
235
- const o = `${r}decimal${t}.${a}`;
236
- let n = y[o];
237
- return n || (n = new Intl.NumberFormat(r, {
238
- localeMatcher: "best fit",
239
- maximumFractionDigits: t,
240
- minimumFractionDigits: a,
241
- minimumIntegerDigits: 1,
242
- style: "decimal",
243
- useGrouping: !0
244
- }), y[o] = n), n.format(e);
245
- }, Y = (e) => e == null ? "" : e < 1e3 ? E(e) : e < 1e6 ? `${i(e / 1e3, 2, 0)}K` : e < 1e9 ? `${i(e / 1e6, 2, 0)}M` : e < 1e12 ? `${i(e / 1e9, 2, 0)}B` : `${i(e / 1e12, 2, 0)}T`, Z = (e) => e == null ? "" : e === 1 ? "1 byte" : e < 1024 ? `${E(e)} bytes` : e < 1048576 ? `${i(e / 1024, 2, 0)} KB` : e < 1073741824 ? `${i(e / 1048576, 2, 0)} MB` : e < 1099511627776 ? `${i(e / 1073741824, 2, 0)} GB` : `${i(e / 1099511627776, 2, 0)} TB`, ee = (e) => e == null ? "" : e < 1e3 ? `${E(e)} ms` : e === 1e3 ? `${E(e)} sec` : e < 6e4 ? `${i(e / 1e3, 2, 0)} secs` : e === 6e4 ? "1 min" : e < 36e5 ? `${i(e / 6e4, 2, 0)} mins` : e === 36e5 ? "1 hr" : e < 864e5 ? `${i(e / 36e5, 2, 0)} hrs` : e === 864e5 ? "1 day" : `${i(e / 864e5, 2, 0)} days`, E = (e, t = D) => {
246
- if (e == null) return "";
247
- const a = `${t}decimal0.0`;
248
- let r = y[a];
249
- return r || (r = new Intl.NumberFormat(t, {
250
- localeMatcher: "best fit",
251
- maximumFractionDigits: 0,
252
- minimumFractionDigits: 0,
253
- minimumIntegerDigits: 1,
254
- style: "decimal",
255
- useGrouping: !0
256
- }), y[a] = r), r.format(e);
257
- }, re = (e) => {
258
- switch (e) {
259
- case "csv":
260
- return "text/csv";
261
- case "tab":
262
- case "tsv":
263
- return "text/tab-separated-values";
264
- case "xls":
265
- return "application/vnd.ms-excel";
266
- case "xlsx":
267
- return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
268
- default:
269
- return "application/octet-stream";
270
- }
271
- }, N = [
272
- { id: "dtv", label: { "en-gb": "Delimited Text" } },
273
- { id: "e/e", label: { "en-gb": "Entity/Event" } },
274
- { id: "jsonArray", label: { "en-gb": "JSON Array" } },
275
- { id: "spss", label: { "en-gb": "SPSS" } },
276
- { id: "xls", label: { "en-gb": "XLS" } },
277
- { id: "xlsx", label: { "en-gb": "XLSX" } },
278
- { id: "xml", label: { "en-gb": "XML" } }
279
- ], te = (e = d) => {
280
- const t = [];
281
- for (const a of N) t.push({ ...a, label: a.label[e] || a.label[d] || a.id });
282
- return t;
283
- }, R = [
284
- { id: `
285
- `, label: { "en-gb": "Newline" } },
286
- { id: "\r", label: { "en-gb": "Carriage Return" } },
287
- { id: `\r
288
- `, label: { "en-gb": "Carriage Return/Newline" } }
289
- ], ae = (e = d) => {
290
- const t = [];
291
- for (const a of R)
292
- t.push({ ...a, label: a.label[e] || a.label[d] || a.id });
293
- return t;
294
- }, A = [
295
- { id: ":", label: { "en-gb": "Colon" } },
296
- { id: ",", label: { "en-gb": "Comma" } },
297
- { id: "!", label: { "en-gb": "Exclamation Mark" } },
298
- // { id: '', label: { 'en-gb': 'Other' } }, // TODO: Maybe set this to a 'not printing' or special ascii character when there is a user supplied delimited, rather than ''?
299
- { id: "0x1E", label: { "en-gb": "Record Separator" } },
300
- { id: ";", label: { "en-gb": "Semicolon" } },
301
- { id: " ", label: { "en-gb": "Space" } },
302
- { id: " ", label: { "en-gb": "Tab" } },
303
- { id: "_", label: { "en-gb": "Underscore" } },
304
- { id: "0x1F", label: { "en-gb": "Unit Separator" } },
305
- { id: "|", label: { "en-gb": "Vertical Bar" } }
306
- ], ne = (e = d) => {
307
- const t = [];
308
- for (const a of A)
309
- t.push({ ...a, label: a.label[e] || a.label[d] || a.id });
310
- return t;
311
- }, O = [
312
- { id: "alpha", color: "red", label: { "en-gb": "alpha" } },
313
- { id: "beta", color: "amber", label: { "en-gb": "beta" } },
314
- { id: "generalAvailability", color: "green", label: { "en-gb": "" } },
315
- { id: "notApplicable", color: "green", label: { "en-gb": "not-applicable" } },
316
- { id: "preAlpha", color: "red", label: { "en-gb": "pre-alpha" } },
317
- { id: "proposed", color: "other", label: { "en-gb": "proposed" } },
318
- { id: "releaseCandidate", color: "green", label: { "en-gb": "release-candidate" } },
319
- { id: "unavailable", color: "other", label: { "en-gb": "unavailable" } },
320
- { id: "underReview", color: "other", label: { "en-gb": "under-review" } }
321
- ], oe = (e, t = d) => {
322
- const a = O.find((r) => r.id === e);
323
- return a ? { ...a, label: a.label[t] || a.label[d] || e } : { id: e, color: "other", label: e };
324
- }, d = "en-gb";
325
- export {
326
- B as APIError,
327
- p as ApplicationError,
328
- C as CONNECTOR_DESTINATION_OPERATIONS,
329
- $ as CONNECTOR_SOURCE_OPERATIONS,
330
- d as DEFAULT_LOCALE_CODE,
331
- k as DefaultTimestamp,
332
- H as EngineError,
333
- w as FetchError,
334
- z as OperationalError,
335
- S as VueError,
336
- W as WindowPromiseRejectionError,
337
- P as WindowRuntimeError,
338
- V as buildFetchError,
339
- X as concatenateSerialisedErrorMessages,
340
- M as convertMillisecondsToTimestamp,
341
- K as convertODataTypeIdToUsageTypeId,
342
- Q as extractExtensionFromPath,
343
- q as extractNameFromPath,
344
- i as formatNumberAsDecimalNumber,
345
- ee as formatNumberAsDuration,
346
- Y as formatNumberAsSize,
347
- Z as formatNumberAsStorageSize,
348
- E as formatNumberAsWholeNumber,
349
- oe as getComponentStatus,
350
- U as getCurrentTimestamp,
351
- te as getDataFormats,
352
- ae as getRecordDelimiters,
353
- ne as getValueDelimiters,
354
- re as lookupMimeTypeForExtension,
355
- G as normalizeToError,
356
- j as presentationViewTypeMap,
357
- J as serialiseError,
358
- _ as useCytoscapeJS,
359
- L as useDataTable,
360
- F as useHighcharts
361
- };