dalux-build-api 2.4.0 → 2.5.0

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.
Files changed (2) hide show
  1. package/README.md +52 -0
  2. package/package.json +37 -8
package/README.md CHANGED
@@ -202,6 +202,58 @@ const result = await dalux.fileUpload.finishUpload(
202
202
  console.log("New file ID:", result.fileId);
203
203
  ```
204
204
 
205
+ ## Browser and plugin hosts (`/web`)
206
+
207
+ When the API key legitimately lives where the code runs — a desktop app, an extension, a plugin
208
+ host that already proxies Dalux — `dalux-build-api/web` gives you every endpoint group over a
209
+ `fetch` you supply:
210
+
211
+ ```ts
212
+ import { createWebClient } from "dalux-build-api/web";
213
+
214
+ const dalux = createWebClient({
215
+ baseUrl: "https://node1.field.dalux.com/service/api",
216
+ apiKey,
217
+ fetch: ctx.fetch, // the host's own fetch
218
+ defaultParams: { daluxNode: "node2" }, // base-origin requests only
219
+ });
220
+
221
+ const sets = await dalux.versionSets.getVersionSets(projectId);
222
+ ```
223
+
224
+ `fetch` is required and never falls back to `globalThis.fetch`. A sandboxed host hands its own
225
+ fetch down because that wrapper is where the outbound-host allow-list, the same-origin relay for
226
+ an API that sends no CORS headers, redirect refusal and credential omission are enforced; silently
227
+ using the global would take all of that off without the caller noticing. `defaultParams` are added
228
+ only to requests on the configured base URL, and never override a parameter the caller or the URL
229
+ already set — a `downloadLink` can carry a signature computed over its query string.
230
+
231
+ This entry reaches no Axios, no `fs`/`path`/`readline`, no `process.env` — enforced by a test over
232
+ the module graph, not by a build flag. The one omission is `FilesApi`: its bulk-download and
233
+ interactive-selection helpers stream to disk and read stdin. Its pure HTTP reads, including
234
+ `downloadFileBytes`, are on `FilesReadApi` and exposed as `dalux.files`.
235
+
236
+ ### Bringing your own HTTP client
237
+
238
+ If your host already has a Dalux client — with its own relay, retries, logging or pagination rules
239
+ — implement `DaluxHttpClient` over it and keep all of that while still getting the endpoint
240
+ catalogue and its zod models:
241
+
242
+ ```ts
243
+ import { createWebClientFrom, type DaluxHttpClient } from "dalux-build-api/web";
244
+
245
+ const http: DaluxHttpClient = {
246
+ configuration: { baseUrl, apiKey },
247
+ get: (path, params, config) => host.get(path, params, config?.signal),
248
+ post: (path, body, params) => host.post(path, body, params),
249
+ patch: (path, body, params) => host.patch(path, body, params),
250
+ delete: (path, params) => host.delete(path, params),
251
+ binary: async (url, config) => ({ bytes: await host.getBinary(url, config?.signal) }),
252
+ };
253
+
254
+ const dalux = createWebClientFrom(http);
255
+ ```
256
+
205
257
  ## Authentication
206
258
 
207
259
  Every request automatically includes the `X-API-KEY` header with the API key supplied to `createClient`. No additional configuration is required.
package/package.json CHANGED
@@ -1,21 +1,49 @@
1
1
  {
2
2
  "name": "dalux-build-api",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Node.js client for the Dalux Build API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "types": "./dist/index.d.ts",
10
- "require": "./dist/index.js"
9
+ "import": {
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
11
17
  },
12
18
  "./browser": {
13
- "types": "./dist/browser.d.ts",
14
- "require": "./dist/browser.js"
19
+ "import": {
20
+ "types": "./dist/browser.d.mts",
21
+ "default": "./dist/browser.mjs"
22
+ },
23
+ "require": {
24
+ "types": "./dist/browser.d.ts",
25
+ "default": "./dist/browser.js"
26
+ }
15
27
  },
16
28
  "./next": {
17
- "types": "./dist/next.d.ts",
18
- "require": "./dist/next.js"
29
+ "import": {
30
+ "types": "./dist/next.d.mts",
31
+ "default": "./dist/next.mjs"
32
+ },
33
+ "require": {
34
+ "types": "./dist/next.d.ts",
35
+ "default": "./dist/next.js"
36
+ }
37
+ },
38
+ "./web": {
39
+ "import": {
40
+ "types": "./dist/web.d.mts",
41
+ "default": "./dist/web.mjs"
42
+ },
43
+ "require": {
44
+ "types": "./dist/web.d.ts",
45
+ "default": "./dist/web.js"
46
+ }
19
47
  }
20
48
  },
21
49
  "files": [
@@ -69,5 +97,6 @@
69
97
  "testMatch": [
70
98
  "**/test/**/*.test.ts"
71
99
  ]
72
- }
100
+ },
101
+ "module": "dist/index.mjs"
73
102
  }