@datapos/datapos-shared 0.3.93 → 0.3.94

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,4 +1,4 @@
1
- const E = 0, I = (e) => e, x = () => Date.now(), D = {
1
+ const R = 0, F = (e) => e, L = () => Date.now(), k = {
2
2
  cartesian_area: { categoryId: "cartesian", typeId: "area", label: { "en-gb": "Area" }, options: { highchartsType: "area" } },
3
3
  cartesian_bar: { categoryId: "cartesian", typeId: "bar", label: { "en-gb": "Bar" }, options: { highchartsType: "bar" } },
4
4
  cartesian_column: { categoryId: "cartesian", typeId: "column", label: { "en-gb": "Column" }, options: { highchartsType: "column" } },
@@ -14,63 +14,63 @@ const E = 0, I = (e) => e, x = () => Date.now(), D = {
14
14
  streamgraph: { categoryId: "streamgraph", label: { "en-gb": "Streamgraph" }, options: {} },
15
15
  values: { categoryId: "values", label: { "en-gb": "Values" }, options: {} }
16
16
  };
17
- class m extends Error {
17
+ class I extends Error {
18
18
  locator;
19
19
  constructor(t, a, r) {
20
20
  super(t, r), this.name = "DataPosError", this.locator = a, Error.captureStackTrace?.(this, new.target);
21
21
  }
22
22
  }
23
- class l extends m {
23
+ class m extends I {
24
24
  constructor(t, a, r) {
25
25
  super(t, a, r), this.name = "ApplicationError";
26
26
  }
27
27
  }
28
- class T extends l {
28
+ class O extends m {
29
29
  constructor(t, a, r) {
30
30
  super(t, a, r), this.name = "APIError";
31
31
  }
32
32
  }
33
- class w extends l {
33
+ class _ extends m {
34
34
  constructor(t, a, r) {
35
35
  super(t, a, r), this.name = "EngineError";
36
36
  }
37
37
  }
38
- class u extends l {
38
+ class D extends m {
39
39
  body;
40
- constructor(t, a, r, n) {
41
- super(t, a, n), this.name = "FetchError", this.body = r;
40
+ constructor(t, a, r, o) {
41
+ super(t, a, o), this.name = "FetchError", this.body = r;
42
42
  }
43
43
  }
44
- class p extends l {
44
+ class v extends m {
45
45
  componentName;
46
46
  info;
47
- constructor(t, a, r, n, s) {
48
- super(t, a, s), this.name = "VueHandledError", this.info = r, this.componentName = n;
47
+ constructor(t, a, r, o, n) {
48
+ super(t, a, n), this.name = "VueHandledError", this.info = r, this.componentName = o;
49
49
  }
50
50
  }
51
- class S extends l {
51
+ class M extends m {
52
52
  constructor(t, a, r) {
53
53
  super(t, a, r), this.name = "WindowHandledRuntimeError";
54
54
  }
55
55
  }
56
- class v extends l {
56
+ class U extends m {
57
57
  constructor(t, a, r) {
58
58
  super(t, a, r), this.name = "WindowHandledPromiseRejectionError";
59
59
  }
60
60
  }
61
- class N extends m {
61
+ class B extends I {
62
62
  constructor(t, a, r) {
63
63
  super(t, a, r), this.name = "OperationalError";
64
64
  }
65
65
  }
66
- async function $(e, t, a) {
67
- const r = `${t} Response status '${e.status}${e.statusText ? ` - ${e.statusText}` : ""}' received.`, n = await e.text();
68
- return new u(r, a, n);
66
+ async function j(e, t, a) {
67
+ const r = `${t} Response status '${e.status}${e.statusText ? ` - ${e.statusText}` : ""}' received.`, o = await e.text();
68
+ return new D(r, a, o);
69
69
  }
70
- function A(e) {
70
+ function H(e) {
71
71
  return e.map((t) => t.message).join(" ");
72
72
  }
73
- function F(e, t = "Unknown error.") {
73
+ function W(e, t = "Unknown error.") {
74
74
  if (e instanceof Error) return e;
75
75
  if (typeof e == "string") return new Error(e);
76
76
  try {
@@ -79,27 +79,103 @@ function F(e, t = "Unknown error.") {
79
79
  return new Error(t);
80
80
  }
81
81
  }
82
- function k(e) {
82
+ function z(e) {
83
83
  const t = /* @__PURE__ */ new Set(), a = [];
84
84
  let r = e;
85
85
  for (; r && !t.has(r); ) {
86
86
  t.add(r);
87
- let n;
88
- if (r instanceof u)
89
- n = { body: r.body, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
90
- else if (r instanceof p)
91
- n = { componentName: r.componentName, info: r.info, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
92
- else if (r instanceof m)
93
- n = { locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
87
+ let o;
88
+ if (r instanceof D)
89
+ o = { body: r.body, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
90
+ else if (r instanceof v)
91
+ o = { componentName: r.componentName, info: r.info, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
92
+ else if (r instanceof I)
93
+ o = { locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause;
94
94
  else if (r instanceof Error) {
95
- const s = r;
96
- n = { locator: "", message: s.message, name: s.name, stack: s.stack }, r = s.cause;
97
- } else r ? (n = { locator: "", message: String(r), name: "Error" }, r = void 0) : (n = { locator: "", message: "Unknown error.", name: "Error" }, r = void 0);
98
- /(?:\.{3}|[.!?])$/.test(n.message) || (n.message += "."), a.push(n);
95
+ const n = r;
96
+ o = { locator: "", message: n.message, name: n.name, stack: n.stack }, r = n.cause;
97
+ } else r ? (o = { locator: "", message: String(r), name: "Error" }, r = void 0) : (o = { locator: "", message: "Unknown error.", name: "Error" }, r = void 0);
98
+ /(?:\.{3}|[.!?])$/.test(o.message) || (o.message += "."), a.push(o);
99
99
  }
100
100
  return a;
101
101
  }
102
- const g = "en-US", c = {}, R = (e) => {
102
+ function V() {
103
+ function e(t, a, r) {
104
+ r.textContent = "Cytoscape.js diagram goes here...";
105
+ }
106
+ return { render: e };
107
+ }
108
+ function X() {
109
+ function e(t, a, r) {
110
+ r.textContent = "values table goes here...";
111
+ }
112
+ return { render: e };
113
+ }
114
+ const S = "https://cdn.jsdelivr.net/npm/highcharts@11.4.3/es-modules/masters/", x = "highcharts";
115
+ let b, w = !1;
116
+ function G() {
117
+ async function e(n, s, u, g, p) {
118
+ await r();
119
+ const l = [];
120
+ for (const E of s.data.measures)
121
+ l.push({ type: n.options.highchartsType, name: E.name, data: u });
122
+ const h = {
123
+ chart: { type: n.options.highchartsType },
124
+ plotOptions: { series: { borderColor: "#333" } },
125
+ series: l,
126
+ title: { text: s.title.text },
127
+ xAxis: { categories: s.data.categoryLabels },
128
+ yAxis: { title: { text: s.data.name } }
129
+ }, c = b.chart(g, h, p);
130
+ return { chart: c, resize: () => c.reflow(), vendorId: x };
131
+ }
132
+ async function t(n, s, u, g, p) {
133
+ await Promise.all([r(), o()]);
134
+ const l = [];
135
+ for (const E of s.data.measures)
136
+ l.push({ type: n.options.highchartsType, name: E.name, data: u });
137
+ const h = {
138
+ chart: { polar: !0 },
139
+ plotOptions: { series: { borderColor: "#333" } },
140
+ series: l,
141
+ title: { text: s.title.text },
142
+ xAxis: { categories: s.data.categoryLabels },
143
+ yAxis: { title: { text: s.data.name } }
144
+ }, c = b.chart(g, h, p);
145
+ return { chart: c, resize: () => c.reflow(), vendorId: x };
146
+ }
147
+ async function a(n, s, u, g, p) {
148
+ await Promise.all([r(), o()]);
149
+ const l = [];
150
+ l.push({ type: n.options.highchartsType, name: "Unknown", data: u });
151
+ const h = {
152
+ chart: { type: n.options.highchartsType, inverted: n.options.inverted },
153
+ plotOptions: { series: { borderColor: "#333" } },
154
+ series: l,
155
+ title: { text: s.title.text },
156
+ xAxis: { categories: s.data.categoryLabels },
157
+ yAxis: { title: { text: s.data.name } }
158
+ }, c = b.chart(g, h, p);
159
+ return { chart: c, resize: () => c.reflow(), vendorId: x };
160
+ }
161
+ async function r() {
162
+ if (b) return;
163
+ 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`;
164
+ b = (await import(
165
+ /* @vite-ignore */
166
+ s
167
+ )).default, await import(
168
+ /* @vite-ignore */
169
+ u
170
+ );
171
+ }
172
+ async function o() {
173
+ if (w) return;
174
+ await import(`${S}highcharts-more.src.js`), w = !0;
175
+ }
176
+ return { renderCartesianChart: e, renderPolarChart: t, renderRangeChart: a };
177
+ }
178
+ const T = "en-US", f = {}, P = (e) => {
103
179
  switch (e) {
104
180
  case "Edm.Binary":
105
181
  return "unknown";
@@ -138,32 +214,32 @@ const g = "en-US", c = {}, R = (e) => {
138
214
  default:
139
215
  return "unknown";
140
216
  }
141
- }, C = (e) => {
217
+ }, J = (e) => {
142
218
  if (e) {
143
219
  const t = e.lastIndexOf("/"), a = e.lastIndexOf(".", t > -1 ? t : e.length);
144
220
  return a > -1 ? e.substring(0, a) : e;
145
221
  }
146
- }, _ = (e) => {
222
+ }, K = (e) => {
147
223
  if (e) {
148
224
  const t = e.lastIndexOf(".");
149
225
  if (t > -1) return e.substring(t + 1);
150
226
  }
151
- }, o = (e, t = 2, a = t, r = g) => {
227
+ }, i = (e, t = 2, a = t, r = T) => {
152
228
  if (e == null) return "";
153
- const n = `${r}decimal${t}.${a}`;
154
- let s = c[n];
155
- return s || (s = new Intl.NumberFormat(r, {
229
+ const o = `${r}decimal${t}.${a}`;
230
+ let n = f[o];
231
+ return n || (n = new Intl.NumberFormat(r, {
156
232
  localeMatcher: "best fit",
157
233
  maximumFractionDigits: t,
158
234
  minimumFractionDigits: a,
159
235
  minimumIntegerDigits: 1,
160
236
  style: "decimal",
161
237
  useGrouping: !0
162
- }), c[n] = s), s.format(e);
163
- }, B = (e) => e == null ? "" : e < 1e3 ? d(e) : e < 1e6 ? `${o(e / 1e3, 2, 0)}K` : e < 1e9 ? `${o(e / 1e6, 2, 0)}M` : e < 1e12 ? `${o(e / 1e9, 2, 0)}B` : `${o(e / 1e12, 2, 0)}T`, M = (e) => e == null ? "" : e === 1 ? "1 byte" : e < 1024 ? `${d(e)} bytes` : e < 1048576 ? `${o(e / 1024, 2, 0)} KB` : e < 1073741824 ? `${o(e / 1048576, 2, 0)} MB` : e < 1099511627776 ? `${o(e / 1073741824, 2, 0)} GB` : `${o(e / 1099511627776, 2, 0)} TB`, O = (e) => e == null ? "" : e < 1e3 ? `${d(e)} ms` : e === 1e3 ? `${d(e)} sec` : e < 6e4 ? `${o(e / 1e3, 2, 0)} secs` : e === 6e4 ? "1 min" : e < 36e5 ? `${o(e / 6e4, 2, 0)} mins` : e === 36e5 ? "1 hr" : e < 864e5 ? `${o(e / 36e5, 2, 0)} hrs` : e === 864e5 ? "1 day" : `${o(e / 864e5, 2, 0)} days`, d = (e, t = g) => {
238
+ }), f[o] = n), n.format(e);
239
+ }, q = (e) => e == null ? "" : e < 1e3 ? y(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`, Q = (e) => e == null ? "" : e === 1 ? "1 byte" : e < 1024 ? `${y(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`, Y = (e) => e == null ? "" : e < 1e3 ? `${y(e)} ms` : e === 1e3 ? `${y(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`, y = (e, t = T) => {
164
240
  if (e == null) return "";
165
241
  const a = `${t}decimal0.0`;
166
- let r = c[a];
242
+ let r = f[a];
167
243
  return r || (r = new Intl.NumberFormat(t, {
168
244
  localeMatcher: "best fit",
169
245
  maximumFractionDigits: 0,
@@ -171,8 +247,8 @@ const g = "en-US", c = {}, R = (e) => {
171
247
  minimumIntegerDigits: 1,
172
248
  style: "decimal",
173
249
  useGrouping: !0
174
- }), c[a] = r), r.format(e);
175
- }, L = (e) => {
250
+ }), f[a] = r), r.format(e);
251
+ }, Z = (e) => {
176
252
  switch (e) {
177
253
  case "csv":
178
254
  return "text/csv";
@@ -186,7 +262,7 @@ const g = "en-US", c = {}, R = (e) => {
186
262
  default:
187
263
  return "application/octet-stream";
188
264
  }
189
- }, b = [
265
+ }, A = [
190
266
  { id: "dtv", label: { "en-gb": "Delimited Text" } },
191
267
  { id: "e/e", label: { "en-gb": "Entity/Event" } },
192
268
  { id: "jsonArray", label: { "en-gb": "JSON Array" } },
@@ -194,22 +270,22 @@ const g = "en-US", c = {}, R = (e) => {
194
270
  { id: "xls", label: { "en-gb": "XLS" } },
195
271
  { id: "xlsx", label: { "en-gb": "XLSX" } },
196
272
  { id: "xml", label: { "en-gb": "XML" } }
197
- ], U = (e = i) => {
273
+ ], ee = (e = d) => {
198
274
  const t = [];
199
- for (const a of b) t.push({ ...a, label: a.label[e] || a.label[i] || a.id });
275
+ for (const a of A) t.push({ ...a, label: a.label[e] || a.label[d] || a.id });
200
276
  return t;
201
- }, f = [
277
+ }, N = [
202
278
  { id: `
203
279
  `, label: { "en-gb": "Newline" } },
204
280
  { id: "\r", label: { "en-gb": "Carriage Return" } },
205
281
  { id: `\r
206
282
  `, label: { "en-gb": "Carriage Return/Newline" } }
207
- ], V = (e = i) => {
283
+ ], re = (e = d) => {
208
284
  const t = [];
209
- for (const a of f)
210
- t.push({ ...a, label: a.label[e] || a.label[i] || a.id });
285
+ for (const a of N)
286
+ t.push({ ...a, label: a.label[e] || a.label[d] || a.id });
211
287
  return t;
212
- }, h = [
288
+ }, $ = [
213
289
  { id: ":", label: { "en-gb": "Colon" } },
214
290
  { id: ",", label: { "en-gb": "Comma" } },
215
291
  { id: "!", label: { "en-gb": "Exclamation Mark" } },
@@ -221,12 +297,12 @@ const g = "en-US", c = {}, R = (e) => {
221
297
  { id: "_", label: { "en-gb": "Underscore" } },
222
298
  { id: "0x1F", label: { "en-gb": "Unit Separator" } },
223
299
  { id: "|", label: { "en-gb": "Vertical Bar" } }
224
- ], W = (e = i) => {
300
+ ], te = (e = d) => {
225
301
  const t = [];
226
- for (const a of h)
227
- t.push({ ...a, label: a.label[e] || a.label[i] || a.id });
302
+ for (const a of $)
303
+ t.push({ ...a, label: a.label[e] || a.label[d] || a.id });
228
304
  return t;
229
- }, y = [
305
+ }, C = [
230
306
  { id: "alpha", color: "red", label: { "en-gb": "alpha" } },
231
307
  { id: "beta", color: "amber", label: { "en-gb": "beta" } },
232
308
  { id: "generalAvailability", color: "green", label: { "en-gb": "" } },
@@ -236,39 +312,42 @@ const g = "en-US", c = {}, R = (e) => {
236
312
  { id: "releaseCandidate", color: "green", label: { "en-gb": "release-candidate" } },
237
313
  { id: "unavailable", color: "other", label: { "en-gb": "unavailable" } },
238
314
  { id: "underReview", color: "other", label: { "en-gb": "under-review" } }
239
- ], j = (e, t = i) => {
240
- const a = y.find((r) => r.id === e);
241
- return a ? { ...a, label: a.label[t] || a.label[i] || e } : { id: e, color: "other", label: e };
242
- }, i = "en-gb";
315
+ ], ae = (e, t = d) => {
316
+ const a = C.find((r) => r.id === e);
317
+ return a ? { ...a, label: a.label[t] || a.label[d] || e } : { id: e, color: "other", label: e };
318
+ }, d = "en-gb";
243
319
  export {
244
- T as APIError,
245
- l as ApplicationError,
246
- i as DEFAULT_LOCALE_CODE,
247
- E as DefaultTimestamp,
248
- w as EngineError,
249
- u as FetchError,
250
- N as OperationalError,
251
- p as VueError,
252
- v as WindowPromiseRejectionError,
253
- S as WindowRuntimeError,
254
- $ as buildFetchError,
255
- A as concatenateSerialisedErrorMessages,
256
- I as convertMillisecondsToTimestamp,
257
- R as convertODataTypeIdToUsageTypeId,
258
- _ as extractExtensionFromPath,
259
- C as extractNameFromPath,
260
- o as formatNumberAsDecimalNumber,
261
- O as formatNumberAsDuration,
262
- B as formatNumberAsSize,
263
- M as formatNumberAsStorageSize,
264
- d as formatNumberAsWholeNumber,
265
- j as getComponentStatus,
266
- x as getCurrentTimestamp,
267
- U as getDataFormats,
268
- V as getRecordDelimiters,
269
- W as getValueDelimiters,
270
- L as lookupMimeTypeForExtension,
271
- F as normalizeToError,
272
- D as presentationViewTypeMap,
273
- k as serialiseError
320
+ O as APIError,
321
+ m as ApplicationError,
322
+ d as DEFAULT_LOCALE_CODE,
323
+ R as DefaultTimestamp,
324
+ _ as EngineError,
325
+ D as FetchError,
326
+ B as OperationalError,
327
+ v as VueError,
328
+ U as WindowPromiseRejectionError,
329
+ M as WindowRuntimeError,
330
+ j as buildFetchError,
331
+ H as concatenateSerialisedErrorMessages,
332
+ F as convertMillisecondsToTimestamp,
333
+ P as convertODataTypeIdToUsageTypeId,
334
+ K as extractExtensionFromPath,
335
+ J as extractNameFromPath,
336
+ i as formatNumberAsDecimalNumber,
337
+ Y as formatNumberAsDuration,
338
+ q as formatNumberAsSize,
339
+ Q as formatNumberAsStorageSize,
340
+ y as formatNumberAsWholeNumber,
341
+ ae as getComponentStatus,
342
+ L as getCurrentTimestamp,
343
+ ee as getDataFormats,
344
+ re as getRecordDelimiters,
345
+ te as getValueDelimiters,
346
+ Z as lookupMimeTypeForExtension,
347
+ W as normalizeToError,
348
+ k as presentationViewTypeMap,
349
+ z as serialiseError,
350
+ V as useCytoscapeJS,
351
+ X as useDataTable,
352
+ G as useHighcharts
274
353
  };
@@ -0,0 +1,7 @@
1
+ import { PresentationView, PresentationVisualContentConfig } from '../index';
2
+ export interface CytoscapeJSView extends PresentationView {
3
+ diagram: unknown;
4
+ }
5
+ export declare function useCytoscapeJS(): {
6
+ render: (viewType: unknown, contentConfig: PresentationVisualContentConfig, element: HTMLElement) => void;
7
+ };
@@ -0,0 +1,4 @@
1
+ import { PresentationVisualContentConfig, PresentationVisualValuesViewType } from '../index';
2
+ export declare function useDataTable(): {
3
+ render: (viewType: PresentationVisualValuesViewType, contentConfig: PresentationVisualContentConfig, element: HTMLElement) => void;
4
+ };
@@ -0,0 +1,10 @@
1
+ import { Chart } from 'highcharts';
2
+ import { PresentationView, PresentationVisualCartesianViewType, PresentationVisualContentConfig, PresentationVisualPolarViewType, PresentationVisualRangeViewType } from '../index';
3
+ export interface HighchartsView extends PresentationView {
4
+ chart: Chart;
5
+ }
6
+ export declare function useHighcharts(): {
7
+ renderCartesianChart: (type: PresentationVisualCartesianViewType, contentConfig: PresentationVisualContentConfig, data: number[][], element: HTMLElement, callback?: () => void) => Promise<HighchartsView>;
8
+ renderPolarChart: (type: PresentationVisualPolarViewType, content: PresentationVisualContentConfig, data: number[][], element: HTMLElement, callback?: () => void) => Promise<HighchartsView>;
9
+ renderRangeChart: (type: PresentationVisualRangeViewType, content: PresentationVisualContentConfig, data: number[][], element: HTMLElement, callback?: () => void) => Promise<HighchartsView>;
10
+ };
@@ -37,6 +37,9 @@ export type { StateConfig } from './state';
37
37
  export type { Timestamp } from './timestamp';
38
38
  export type { TutorialConfig } from './tutorial';
39
39
  export { APIError, ApplicationError, EngineError, FetchError, OperationalError, VueError, WindowRuntimeError, WindowPromiseRejectionError } from './errors';
40
+ export { type CytoscapeJSView, useCytoscapeJS } from './composables/useCytoscapeJS';
41
+ export { useDataTable } from './composables/useDataTable';
42
+ export { type HighchartsView, useHighcharts } from './composables/useHighcharts';
40
43
  export { buildFetchError, concatenateSerialisedErrorMessages, normalizeToError, serialiseError } from './errors';
41
44
  export { convertMillisecondsToTimestamp, getCurrentTimestamp } from './timestamp';
42
45
  export { convertODataTypeIdToUsageTypeId } from './utilities';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@datapos/datapos-shared",
3
3
  "license": "MIT",
4
4
  "private": false,
5
- "version": "0.3.93",
5
+ "version": "0.3.94",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"
@@ -25,6 +25,7 @@
25
25
  "date-fns": "^4.1.0",
26
26
  "eslint": "^9.38.0",
27
27
  "eslint-plugin-import": "^2.32.0",
28
+ "highcharts": "^12.4.0",
28
29
  "jiti": "^2.6.1",
29
30
  "license-report": "^6.8.1",
30
31
  "license-report-check": "^0.1.2",