@dpuse/dpuse-shared 0.3.677 → 0.3.684

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
@@ -1,81 +1,108 @@
1
- # Data Positioning Shared Library
1
+ # DPUse Shared Library
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
4
4
  [![npm version](https://img.shields.io/npm/v/@dpuse/dpuse-shared.svg)](https://www.npmjs.com/package/@dpuse/dpuse-shared)
5
+ [![CodeQL](https://github.com/dpuse/dpuse-shared/actions/workflows/codeql.yml/badge.svg)](https://github.com/dpuse/dpuse-shared/actions/workflows/codeql.yml)
6
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dpuse_dpuse-shared&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dpuse_dpuse-shared)
7
+ [![CI](https://github.com/dpuse/dpuse-shared/actions/workflows/ci.yml/badge.svg)](https://github.com/dpuse/dpuse-shared/actions/workflows/ci.yml)
5
8
 
6
- A library containing common constants, types and utilities used across all Data Positioning projects.
9
+ ## Introduction
7
10
 
8
- ## Installation
11
+ @dpuse/dpuse-shared is the foundational library for the [DPUse](https://www.dpuse.app/) ecosystem. It provides the common constants, types, errors, and utilities that are shared across all DPUse modules — including the App, API, Engine, Connectors, Contexts, Presenters and Recipes.
9
12
 
10
- Install as a production dependency:
13
+ The library is written in TypeScript and designed to be consumed exclusively by TypeScript projects. All configuration types are schema-validated using [Valibot](https://valibot.dev/), giving consumers both compile-time safety and runtime validation from a single source of truth.
11
14
 
12
- ```bash
13
- npm install @dpuse/dpuse-shared
14
- ```
15
+ ## Table of Contents
15
16
 
16
- > See the Data Positioning security documentation for additional initialization requirements.
17
+ ## Prerequisites
17
18
 
18
- ## Declarations
19
+ The following are required to use this library:
19
20
 
20
- This package provides constants, errors, types/interfaces and utilities used by Data Positioning modules.
21
+ | Prerequisite | Version |
22
+ | --------------------------------------------- | :-----: |
23
+ | [Node.js](https://nodejs.org/) | ≥ 22.0 |
24
+ | [npm](https://www.npmjs.com/) | ≥ 11.0 |
25
+ | [TypeScript](https://www.typescriptlang.org/) | ≥ 6.0 |
26
+
27
+ ## Installation
21
28
 
22
- [Documentation](https://dpuse.github.io/dpuse-shared/docs/typedoc/index.html)
29
+ `@dpuse/dpuse-shared` is published to the [public npm registry](https://www.npmjs.com/package/@dpuse/dpuse-shared). Install it using your preferred package manager:
23
30
 
24
- ### Modules
31
+ ```bash
32
+ # npm
33
+ npm install @dpuse/dpuse-shared
25
34
 
26
- The Data Positioning solution consists of the following modules. All modules, except `App`, extend the base type `Module`.
35
+ # yarn
36
+ yarn add @dpuse/dpuse-shared
27
37
 
28
- | Type | Dynamic | Notes |
29
- | --------- | :-----: | --------------------------------------------------------------- |
30
- | App | | Implements the data positioning web application. |
31
- | Engine | ✔ | Implements the data positioning engine. |
32
- | Connector | ✔ | Implements a connector which handles one or more connections. |
33
- | Context | ✔ | Implements a context which defines one or more models. |
34
- | Presenter | ✔ | Implements a presenter which renders one or more presentations. |
35
- | Tool | ✔ | Implements... |
38
+ # pnpm
39
+ pnpm add @dpuse/dpuse-shared
40
+ ```
36
41
 
37
- ### Components
42
+ This package has no peer dependencies.
38
43
 
39
- Each module implements a set of components. All module component types extend the base component types.
44
+ ## Usage
45
+
46
+ This package uses [sub-path exports](https://nodejs.org/api/packages.html#subpath-exports). Import only the entry points you need:
47
+
48
+ ```ts
49
+ import { getComponentStatus } from '@dpuse/dpuse-shared/component';
50
+ import type { ConnectorConfig } from '@dpuse/dpuse-shared/component/module/connector';
51
+ import { ConnectorError, serialiseError } from '@dpuse/dpuse-shared/errors';
52
+ import { formatNumberAsDuration } from '@dpuse/dpuse-shared/utilities';
53
+
54
+ try {
55
+ // The locator argument follows the convention 'project.file.function'
56
+ throw new ConnectorError('Connection failed.', 'connector.connection.read');
57
+ } catch (error) {
58
+ const serialised = serialiseError(error);
59
+ }
60
+ ```
40
61
 
41
- | Types | Notes |
42
- | ------------------------------- | ------------------------------------------------------------ |
43
- | [Component](./src/component.ts) | The Component type serves as a base type for all components. |
44
- | ComponentReference | |
45
- | ComponentStatus | |
46
- | ComponentStatusId | |
47
- | ComponentTypeId | |
48
- | ComponentStatusColorId | |
62
+ ## Architecture
49
63
 
50
- #### Connector Module Components
64
+ ### Domain Model
51
65
 
52
- | Item | Notes |
53
- | --------------------------------------- | ----------------------------------------------------------------- |
54
- | [Connector Types](./src/connector.ts) | Connector types. The Connector type extends the Component type. |
55
- | [Connection Types](./src/connection.ts) | Connection types. The Connection type extends the Component type. |
66
+ `Component` is the foundational base type for all DPUse domain objects. All component types extend `ComponentConfig` and are logically grouped in the following hierarchy. `Module` is a component type whose implementations are dynamically loaded by the host modules (App and API):
56
67
 
57
- #### Context Module Components
68
+ ```
69
+ Component
70
+ ├── Module
71
+ │ ├── Connector
72
+ │ │ └── Connection
73
+ │ ├── Context
74
+ │ │ └── Model
75
+ │ │ ├── Dimension
76
+ │ │ │ └── DimensionHierarchy
77
+ │ │ ├── Entity
78
+ │ │ │ ├── DataItem
79
+ │ │ │ ├── Event
80
+ │ │ │ └── PrimaryMeasure
81
+ │ │ └── SecondaryMeasure
82
+ │ ├── Engine
83
+ │ ├── Presenter
84
+ │ │ └── Presentation
85
+ │ ├── Recipe
86
+ │ └── Tool
87
+ ├── DataView
88
+ ├── Dimension
89
+ └── EventQuery
90
+ ```
58
91
 
59
- | Item | Notes |
60
- | ---------------------------------------- | ------------------------------------------------------------------- |
61
- | [Context Types](./src/context.ts) | Context types. The Context type extends the Component type. |
62
- | [Data View Types](./src/dataView.ts) | DataView types. The DataView type extends the Component type. |
63
- | [Dimension Types](./src/dimension.ts) | Dimension types. The Dimension type extends the Component type. |
64
- | [Engine Types](./src/dimension.ts) | Engine types. |
65
- | [Event Query Types](./src/eventQuery.ts) | Event Query types. The Event Query type extends the Component type. |
92
+ ### Cross-cutting Concerns
66
93
 
67
- #### Engine Module Components
94
+ The following are shared across all modules and are not part of the domain model:
68
95
 
69
- | Item | Notes |
70
- | ---------------------------------- | ------------- |
71
- | [Engine Types](./src/dimension.ts) | Engine types. |
96
+ | Concern | Description |
97
+ | --------- | -------------------------------------------------------------------------------------------------------------------------------- |
98
+ | Errors | A typed error hierarchy with serialisation and deserialisation support for transporting errors across API and worker boundaries. |
99
+ | Utilities | Common conversion, extraction, formatting and lookup functions. |
100
+ | Encoding | Encoding configuration and format support. |
101
+ | Locale | Locale identifiers and label types used for internationalisation. |
72
102
 
73
- #### Presenter Module Components
103
+ ## API Reference
74
104
 
75
- | Item | Notes |
76
- | ------------------------------------------- | --------------------------------------------------------------------- |
77
- | [Presenter Types](./src/presenter.ts) | Presenter types. The Presenter type extends the Component type. |
78
- | [Presentation Types](./src/presentation.ts) | Presentation types. The Presentation type extends the Component type. |
105
+ This package provides constants, errors, types/interfaces and utilities used by Data Positioning modules.
79
106
 
80
107
  ### Composables
81
108
 
@@ -85,43 +112,32 @@ Each module implements a set of components. All module component types extend th
85
112
 
86
113
  ### Utilities
87
114
 
88
- ## Usage
89
-
90
- Import the library in your TypeScript project:
91
-
92
- ```ts
93
- import { type ConnectorConfig, getComponentStatus } from '@dpuse/dpuse-shared';
115
+ Implements the common Data Positioning repository management command set. For more information see [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).
94
116
 
95
- // Example type usage.
96
- let connectorConfig: ConnectorConfig;
117
+ ## Contributing
97
118
 
98
- // Example function usage.
99
- getComponentStatus('alpha');
100
- ```
119
+ ## Changelog
101
120
 
102
- Implements the common Data Positioning repository management command set. For more information see [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development).
121
+ ## Project Health
103
122
 
104
- ## Bundle Analysis Reports
123
+ ### Bundle Analysis Reports
105
124
 
106
125
  The Bundle Analysis Report provides a detailed breakdown of the bundle's composition and module sizes, helping to identify which modules contribute most to the final build. It is generated automatically on each release using the npm package `rollup-plugin-visualizer`.
107
126
 
108
127
  [View the Bundle Analysis Report](https://dpuse.github.io/dpuse-shared/stats.html)
109
128
 
110
- ## Dependency Check Report
129
+ ### Dependency Check Report
111
130
 
112
- The OWASP Dependency Check Report identifies known vulnerabilities in project dependencies. It is generated automatically on each release using the npm package [owasp-dependency-check](https://dependency-check.github.io/DependencyCheck/index.html). We also rely on GitHub Dependabot to continuously check for vulnerabilities across all dependencies.
113
-
114
- [View the OWASP Dependency Check Report](https://dpuse.github.io/dpuse-shared/dependency-check-reports/dependency-check-report.html)
115
-
116
- ## Dependency Licenses
131
+ ### Dependency Licenses
117
132
 
118
133
  The following table lists top-level production and peer dependencies. All these dependencies (including transitive ones) have been recursively verified to use Apache-2.0, BSD-2-Clause, CC0-1.0, or MIT—commercially friendly licenses with minimal restrictions. Developers cloning this repository should independently verify dev and optional dependencies; users of the uploaded library are covered by these checks. We do not include unlicensed dependencies. Used to support development activity and not released as part of the production release. Check if you clone. We use the `npm` packages [license-report](https://www.npmjs.com/package/license-report), [license-report-check](https://www.npmjs.com/package/license-report-check) and [license-report-recursive](https://www.npmjs.com/package/license-report-recursive) to identify dependency licenses.
119
134
 
120
135
  The following table lists top-level production and peer dependencies. All these dependencies (including transitive ones) have been recursively verified to use Apache-2.0, BSD-2-Clause, CC0-1.0, or MIT—commercially friendly licenses with minimal restrictions. Developers cloning this repository should independently verify dev and optional dependencies; users of the published library are covered by these checks. We do not include unlicensed dependencies. Used to support development activity and not released as part of the production release. Check if you clone. We use the `npm` packages [license-report](https://www.npmjs.com/package/license-report), [license-report-check](https://www.npmjs.com/package/license-report-check) and [license-report-recursive](https://www.npmjs.com/package/license-report-recursive) to identify dependency licenses.
121
136
 
122
137
  <!-- DEPENDENCY_LICENSES_START -->
123
- |Name|Version|License(s)|Document|
124
- |-|:-:|-|-|
138
+
139
+ | Name | Version | License(s) | Document |
140
+ | ---- | :-----: | ---------- | -------- |
125
141
 
126
142
  <!-- DEPENDENCY_LICENSES_END -->
127
143
  <!-- DEPENDENCY_TREE_START -->
@@ -27,13 +27,13 @@ var e = 2048, t = class extends Error {
27
27
  }
28
28
  };
29
29
  async function s(e, t, n) {
30
- let r = ` - ${e.statusText}`, i = `${t} Response status '${e.status}${e.statusText ? r : ""}' received.`, a;
30
+ let r = ` - ${e.statusText}`, i = `${t} Response status '${String(e.status)}${e.statusText ? r : ""}' received.`, a;
31
31
  try {
32
32
  a = await e.text();
33
33
  } catch (e) {
34
34
  a = `<body unavailable: ${u(e).message}>`;
35
35
  }
36
- return new o(i, n, { body: m(a) });
36
+ return new o(i, n, { body: h(a) });
37
37
  }
38
38
  function c(e) {
39
39
  return e.map((e) => e.message).join(" ");
@@ -59,84 +59,36 @@ function d(e) {
59
59
  let t = /* @__PURE__ */ new Set(), n = [], r = u(e);
60
60
  for (; r != null && !t.has(r);) {
61
61
  t.add(r);
62
- let e;
63
- switch (r.name) {
64
- case "APIError": {
65
- let t = r;
66
- e = {
67
- data: t.data,
68
- locator: t.locator,
69
- message: r.message,
70
- name: "APIError",
71
- stack: r.stack
72
- }, r = r.cause == null ? null : u(r.cause);
73
- break;
74
- }
75
- case "AppError": {
76
- let t = r;
77
- e = {
78
- data: t.data,
79
- locator: t.locator,
80
- message: r.message,
81
- name: "AppError",
82
- stack: r.stack
83
- }, r = r.cause == null ? null : u(r.cause);
84
- break;
85
- }
86
- case "ConnectorError": {
87
- let t = r;
88
- e = {
89
- data: t.data,
90
- locator: t.locator,
91
- message: r.message,
92
- name: "ConnectorError",
93
- stack: r.stack
94
- }, r = r.cause == null ? null : u(r.cause);
95
- break;
96
- }
97
- case "EngineError": {
98
- let t = r;
99
- e = {
100
- data: t.data,
101
- locator: t.locator,
102
- message: r.message,
103
- name: "EngineError",
104
- stack: r.stack
105
- }, r = r.cause == null ? null : u(r.cause);
106
- break;
107
- }
108
- case "FetchError": {
109
- let t = r;
110
- e = {
111
- data: t.data,
112
- locator: t.locator,
113
- message: r.message,
114
- name: "FetchError",
115
- stack: r.stack
116
- }, r = r.cause == null ? null : u(r.cause);
117
- break;
118
- }
119
- default:
120
- let { cause: t, ...n } = Object.fromEntries(Object.entries(r));
121
- r.name ? (e = {
122
- data: n,
123
- locator: "",
124
- message: r.message,
125
- name: r.name,
126
- stack: r.stack
127
- }, r = r.cause == null ? null : u(r.cause)) : (e = {
128
- data: n,
129
- locator: "",
130
- message: p(r),
131
- name: "Error",
132
- stack: void 0
133
- }, r = null);
134
- }
135
- /(?:\.{3}|[.!?])$/.test(e.message) || (e.message += "."), n.push(e);
62
+ let [e, i] = f(r);
63
+ /(?:\.{3}|[.!?])$/.test(e.message) || (e.message += "."), n.push(e), r = i;
136
64
  }
137
65
  return n;
138
66
  }
139
67
  function f(e) {
68
+ let n = e.cause == null ? null : u(e.cause);
69
+ if (e instanceof t) return [{
70
+ data: e.data,
71
+ locator: e.locator,
72
+ message: e.message,
73
+ name: e.name,
74
+ stack: e.stack
75
+ }, n];
76
+ let r = Object.fromEntries(Object.entries(e).filter(([e]) => e !== "cause"));
77
+ return e.name ? [{
78
+ data: r,
79
+ locator: "",
80
+ message: e.message,
81
+ name: e.name,
82
+ stack: e.stack
83
+ }, n] : [{
84
+ data: r,
85
+ locator: "",
86
+ message: m(e),
87
+ name: "Error",
88
+ stack: void 0
89
+ }, null];
90
+ }
91
+ function p(e) {
140
92
  if (e.length === 0) return;
141
93
  let t;
142
94
  for (let s of e.toReversed()) {
@@ -165,7 +117,7 @@ function f(e) {
165
117
  }
166
118
  return t;
167
119
  }
168
- function p(e) {
120
+ function m(e) {
169
121
  let t;
170
122
  try {
171
123
  t = JSON.stringify(e);
@@ -174,8 +126,8 @@ function p(e) {
174
126
  }
175
127
  return t === "" && (t = "Unknown error"), t;
176
128
  }
177
- function m(t) {
129
+ function h(t) {
178
130
  if (!(t == null || t === "")) return t.length > e ? `${t.slice(0, e)}... [truncated]` : t;
179
131
  }
180
132
  //#endregion
181
- export { r as APIError, n as AppError, a as ConnectorError, t as DPUseError, i as EngineError, o as FetchError, s as buildFetchError, c as concatenateSerialisedErrorMessages, l as ignoreErrors, u as normalizeToError, d as serialiseError, f as unserialiseError };
133
+ export { r as APIError, n as AppError, a as ConnectorError, t as DPUseError, i as EngineError, o as FetchError, s as buildFetchError, c as concatenateSerialisedErrorMessages, l as ignoreErrors, u as normalizeToError, d as serialiseError, p as unserialiseError };
@@ -35,7 +35,7 @@ function i(e) {
35
35
  }
36
36
  function a(n, r = 2, i = r, a = e) {
37
37
  if (n == null) return "";
38
- let o = `${a}decimal${r}.${i}`, s = t.get(o);
38
+ let o = `${a}decimal${String(r)}.${String(i)}`, s = t.get(o);
39
39
  return s || (s = new Intl.NumberFormat(a, {
40
40
  localeMatcher: "best fit",
41
41
  maximumFractionDigits: r,
@@ -1,6 +1,6 @@
1
1
  import { InferOutput } from 'valibot';
2
2
  import { Component } from '../..';
3
- import { EngineConnectorActionOptions } from '../../../engine';
3
+ import { EngineConnectorActionOptions } from '../engine';
4
4
  import { ToolConfig } from '../tool';
5
5
  import { ConnectionDescriptionConfig, ConnectionNodeConfig, ObjectColumnConfig } from '../../connection';
6
6
  import { connectorCategoryConfigSchema, connectorConfigSchema, connectorOperationNameSchema } from './connectorConfig.schema';
@@ -1,5 +1,5 @@
1
1
  import { InferOutput } from 'valibot';
2
- import { EngineContextActionOptions } from '../../../engine';
2
+ import { EngineContextActionOptions } from '../engine';
3
3
  import { Component, ComponentConfig, ComponentReference } from '../..';
4
4
  import { contextConfigSchema, contextOperationNameSchema } from './contextConfig.schema';
5
5
  export { contextConfigSchema } from './contextConfig.schema';
@@ -1,8 +1,8 @@
1
- import { ComponentConfig } from '../component';
2
- import { EncodingTypeConfig } from '../encoding';
3
- import { LocalisedConfig } from '../locale';
4
- import { ModuleConfig } from '../component/module';
5
- import { ToolConfig } from '../component/module/tool';
1
+ import { ComponentConfig } from '../..';
2
+ import { EncodingTypeConfig } from '../../../encoding';
3
+ import { LocalisedConfig } from '../../../locale';
4
+ import { ModuleConfig } from '..';
5
+ import { ToolConfig } from '../tool';
6
6
  export interface EngineRuntime {
7
7
  getEncodingTypeConfigs: (localeId: string) => EncodingTypeConfig[];
8
8
  invokeWorker(errorEventCallback: (errorEvent: ErrorEvent) => void): EngineWorker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpuse/dpuse-shared",
3
- "version": "0.3.677",
3
+ "version": "0.3.684",
4
4
  "private": false,
5
5
  "description": "Common constants, types and utilities used across all DPUse projects.",
6
6
  "license": "MIT",
@@ -9,11 +9,11 @@
9
9
  "sideEffects": false,
10
10
  "homepage": "https://www.dpuse.app",
11
11
  "bugs": {
12
- "url": "https://github.com/data-positioning/dpuse-shared/issues"
12
+ "url": "https://github.com/dpuse/dpuse-shared/issues"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://github.com/data-positioning/dpuse-shared.git"
16
+ "url": "git+https://github.com/dpuse/dpuse-shared.git"
17
17
  },
18
18
  "module": "./dist/dpuse-shared.es.js",
19
19
  "types": "./dist/types/src/index.d.ts",
@@ -78,6 +78,10 @@
78
78
  "import": "./dist/dpuse-shared-componentModuleContextModelSecondaryMeasure.es.js",
79
79
  "types": "./dist/types/src/component/module/context/model/secondaryMeasure/index.d.ts"
80
80
  },
81
+ "./component/module/engine": {
82
+ "import": "./dist/dpuse-shared-componentModuleEngine.es.js",
83
+ "types": "./dist/types/src/component/module/engine/index.d.ts"
84
+ },
81
85
  "./component/module/presenter": {
82
86
  "import": "./dist/dpuse-shared-componentModulePresenter.es.js",
83
87
  "types": "./dist/types/src/component/module/presenter/index.d.ts"
@@ -94,10 +98,6 @@
94
98
  "import": "./dist/dpuse-shared-encoding.es.js",
95
99
  "types": "./dist/types/src/encoding/index.d.ts"
96
100
  },
97
- "./engine": {
98
- "import": "./dist/dpuse-shared-engine.es.js",
99
- "types": "./dist/types/src/engine/index.d.ts"
100
- },
101
101
  "./errors": {
102
102
  "import": "./dist/dpuse-shared-errors.es.js",
103
103
  "types": "./dist/types/src/errors/index.d.ts"
@@ -130,7 +130,7 @@
130
130
  "document": "node -e \"import('@dpuse/dpuse-development').then(m => m.documentDependencies(['MIT']))\"",
131
131
  "format": "node -e \"import('@dpuse/dpuse-development').then(m => m.formatCode())\"",
132
132
  "lint": "node -e \"import('@dpuse/dpuse-development').then(m => m.lintCode())\"",
133
- "release": "op run --env-file=.env -- node -e \"import('@dpuse/dpuse-development').then(m => m.releaseProject())\"",
133
+ "release": "npm run build && npm run sync && gh release create \"v$(npm pkg get version | tr -d '\"')\" --generate-notes --latest",
134
134
  "sync": "node -e \"import('@dpuse/dpuse-development').then(m => m.syncProjectWithGitHub())\"",
135
135
  "test": "node -e \"import('@dpuse/dpuse-development').then(m => m.testProject())\""
136
136
  },