node-red-contrib-i3x 0.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 (2026-03-03)
4
+
5
+ Initial pre-alpha release targeting the [i3X API Prototype v0.0.1](https://i3x.cesmii.net/docs).
6
+
7
+ ### Nodes
8
+
9
+ - **i3x-server** – Config node for shared connection settings (URL, auth, TLS, timeout)
10
+ - **i3x-browse** – Explore namespaces, object types, relationship types, objects, and related objects
11
+ - **i3x-read** – Read last known values (`POST /objects/value`)
12
+ - **i3x-write** – Write current values (`PUT /objects/{id}/value`) or historical data (`PUT /objects/{id}/history`)
13
+ - **i3x-history** – Query historical time-series data with absolute or relative time ranges
14
+ - **i3x-subscribe** – Subscribe to value changes via SSE streaming with automatic polling fallback
15
+
16
+ ### Features
17
+
18
+ - Full coverage of all 20 i3X API endpoints
19
+ - Shared HTTP client (`lib/i3x-client.js`) with retry logic, error wrapping, and SSE reconnection
20
+ - Dynamic configuration via `msg` properties (all node settings can be overridden at runtime)
21
+ - Example flow demonstrating all features against the public CESMII demo server
22
+ - Unit tests (63 tests) and integration tests against the live API
23
+ - Docker Compose setup for testing and local Node-RED development
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 blanpa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,218 @@
1
+ # node-red-contrib-i3x
2
+
3
+ Node-RED nodes for the **i3X** (Industrial Information Interoperability eXchange) API by [CESMII](https://www.cesmii.org).
4
+
5
+ i3X is an open, vendor-agnostic REST API specification for standardised access to contextualised manufacturing information platforms (Historians, MES, MOM, etc.).
6
+
7
+ > **Note:** The i3X API is currently in **pre-alpha (v0)**. Response structures may change as the specification evolves.
8
+
9
+ ## Installation
10
+
11
+ Install from within Node-RED via **Manage palette → Install**, or from the command line:
12
+
13
+ ```bash
14
+ cd ~/.node-red
15
+ npm install node-red-contrib-i3x
16
+ ```
17
+
18
+ For development / local testing:
19
+
20
+ ```bash
21
+ cd ~/.node-red
22
+ npm install /path/to/node-red-contrib-i3x
23
+ ```
24
+
25
+ ## Nodes
26
+
27
+ All nodes share the category **i3x** and use the same green colour scheme (`#5DB87C`).
28
+
29
+ ### i3x-server (Config Node)
30
+
31
+ Shared connection configuration used by all other nodes.
32
+
33
+ | Property | Description |
34
+ | ----------- | ------------------------------------------------------------ |
35
+ | Base URL | Root URL of the i3X API server (e.g. `https://i3x.cesmii.net`) |
36
+ | API Version | Optional path prefix (e.g. `v0`) |
37
+ | Auth Type | `none`, `basic`, `bearer`, or `apikey` |
38
+ | TLS | Optional TLS configuration (Node-RED TLS Config Node) |
39
+ | Timeout | HTTP timeout in milliseconds (default 10 000) |
40
+
41
+ ### i3x-browse
42
+
43
+ Explore the i3X information model – namespaces, object types, relationship types, objects, and related objects.
44
+
45
+ **Browse targets:**
46
+
47
+ | Target | API Endpoint | Description |
48
+ | ------------------- | ------------------------------------- | ------------------------------------- |
49
+ | `namespaces` | `GET /namespaces` | All available namespaces |
50
+ | `objecttypes` | `GET /objecttypes` or `POST /objecttypes/query` | Type schemas |
51
+ | `relationshiptypes` | `GET /relationshiptypes` or `POST /relationshiptypes/query` | Relationship type definitions |
52
+ | `objects` | `GET /objects` or `POST /objects/list` | Object instances |
53
+ | `related` | `POST /objects/related` | Graph traversal – related objects |
54
+
55
+ ### i3x-read
56
+
57
+ Read the last known values for one or more objects.
58
+
59
+ - **Input:** `msg.elementIds` (string, comma-separated, or array)
60
+ - **Output:** `msg.payload` – value data from `POST /objects/value`
61
+ - **Option:** `maxDepth` – controls recursion into child components (0 = infinite, 1 = no recursion)
62
+
63
+ ### i3x-write
64
+
65
+ Write a current value or historical data to an i3X object.
66
+
67
+ - **Input:** `msg.payload` (value to write), `msg.elementId` (target)
68
+ - **Target:** `value` (default) or `history` – selectable via dropdown or `msg.writeTarget`
69
+ - **Output:** `msg.payload` – write confirmation from the API
70
+
71
+ | Target | API Endpoint | Payload format |
72
+ | --------- | ------------------------------------- | ------------------------------------- |
73
+ | `value` | `PUT /objects/{elementId}/value` | Depends on type schema (number, object, …) |
74
+ | `history` | `PUT /objects/{elementId}/history` | Array of VQT records `[{value, quality, timestamp}, …]` |
75
+
76
+ ### i3x-history
77
+
78
+ Query historical time-series data.
79
+
80
+ - **Input:** `msg.elementIds`, `msg.startTime`, `msg.endTime`
81
+ - **Output:** `msg.payload` – historical data from `POST /objects/history`
82
+ - **Time formats:** ISO 8601 (`2025-01-01T00:00:00Z`) or relative (`-1h`, `-7d`, `-30m`, `-2w`)
83
+
84
+ ### i3x-subscribe
85
+
86
+ Subscribe to value changes via SSE streaming or polling.
87
+
88
+ - **SSE mode:** Opens a persistent Server-Sent Events stream (`GET /subscriptions/{id}/stream`)
89
+ - **Polling mode:** Periodically calls `POST /subscriptions/{id}/sync`
90
+ - **Fallback:** If SSE fails, the node automatically falls back to polling
91
+ - **Lifecycle:** Subscriptions are created on deploy and deleted on stop/re-deploy
92
+
93
+ ## API Endpoints Used
94
+
95
+ This package targets the [i3X API Prototype v0.0.1](https://i3x.cesmii.net/docs):
96
+
97
+ | Category | Method | Endpoint |
98
+ | --------- | ------ | -------------------------------------------- |
99
+ | Explore | GET | `/namespaces` |
100
+ | Explore | GET | `/objecttypes` |
101
+ | Explore | POST | `/objecttypes/query` |
102
+ | Explore | GET | `/relationshiptypes` |
103
+ | Explore | POST | `/relationshiptypes/query` |
104
+ | Explore | GET | `/objects` |
105
+ | Explore | POST | `/objects/list` |
106
+ | Explore | POST | `/objects/related` |
107
+ | Query | POST | `/objects/value` |
108
+ | Query | POST | `/objects/history` |
109
+ | Update | PUT | `/objects/{elementId}/value` |
110
+ | Update | PUT | `/objects/{elementId}/history` |
111
+ | Subscribe | GET | `/subscriptions` |
112
+ | Subscribe | POST | `/subscriptions` |
113
+ | Subscribe | GET | `/subscriptions/{subscriptionId}` |
114
+ | Subscribe | DELETE | `/subscriptions/{subscriptionId}` |
115
+ | Subscribe | POST | `/subscriptions/{subscriptionId}/register` |
116
+ | Subscribe | POST | `/subscriptions/{subscriptionId}/unregister` |
117
+ | Subscribe | GET | `/subscriptions/{subscriptionId}/stream` |
118
+ | Subscribe | POST | `/subscriptions/{subscriptionId}/sync` |
119
+
120
+ ## Example Flows
121
+
122
+ ### Read values from the demo server
123
+
124
+ ```json
125
+ [
126
+ {
127
+ "id": "flow1",
128
+ "type": "tab",
129
+ "label": "i3X Demo"
130
+ },
131
+ {
132
+ "id": "server1",
133
+ "type": "i3x-server",
134
+ "name": "CESMII Demo",
135
+ "baseUrl": "https://i3x.cesmii.net",
136
+ "apiVersion": "",
137
+ "authType": "none",
138
+ "timeout": "10000"
139
+ },
140
+ {
141
+ "id": "inject1",
142
+ "type": "inject",
143
+ "name": "Trigger",
144
+ "props": [],
145
+ "repeat": "",
146
+ "once": false,
147
+ "wires": [["browse1"]]
148
+ },
149
+ {
150
+ "id": "browse1",
151
+ "type": "i3x-browse",
152
+ "name": "List Namespaces",
153
+ "server": "server1",
154
+ "browseTarget": "namespaces",
155
+ "wires": [["debug1"]]
156
+ },
157
+ {
158
+ "id": "debug1",
159
+ "type": "debug",
160
+ "name": "Output",
161
+ "active": true
162
+ }
163
+ ]
164
+ ```
165
+
166
+ ## Testing
167
+
168
+ ```bash
169
+ # Run all tests (unit + integration)
170
+ npm test
171
+
172
+ # Unit tests only (offline, uses HTTP mocks)
173
+ npm run test:unit
174
+
175
+ # Integration tests only (requires network access to demo server)
176
+ npm run test:integration
177
+
178
+ # Run all tests in Docker
179
+ npm run test:docker
180
+ ```
181
+
182
+ ## Docker
183
+
184
+ ```bash
185
+ # Start Node-RED with the i3x nodes pre-installed and the demo flow loaded
186
+ docker compose up node-red
187
+
188
+ # Open http://localhost:18880 in your browser
189
+
190
+ # Run tests in a container
191
+ docker compose run --rm test
192
+ ```
193
+
194
+ ## Development
195
+
196
+ ```bash
197
+ git clone <repo-url>
198
+ cd node-red-contrib-i3x
199
+ npm install
200
+
201
+ # Link into Node-RED for development
202
+ cd ~/.node-red
203
+ npm install /path/to/node-red-contrib-i3x
204
+
205
+ # Restart Node-RED
206
+ node-red
207
+ ```
208
+
209
+ ## References
210
+
211
+ - [i3X API Documentation](https://i3x.cesmii.net/docs)
212
+ - [i3X Specification & RFC](https://github.com/cesmii/i3X)
213
+ - [i3X SDK Documentation](https://www.i3x.dev/sdk)
214
+ - [CESMII](https://www.cesmii.org)
215
+
216
+ ## License
217
+
218
+ MIT – see [LICENSE](LICENSE).