@dbx-tools/shared 0.1.23 → 0.1.25

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 +17 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -21,11 +21,11 @@ import {
21
21
  } from "@dbx-tools/shared";
22
22
  ```
23
23
 
24
- > `apiUtils` and `projectUtils` import Node-only modules (`@databricks/appkit`,
25
- > `node:fs`) and are intentionally **not** re-exported from the browser
26
- > entry. Vite / Webpack / esbuild builds that honor the `browser`
27
- > condition will resolve `@dbx-tools/shared` to a barrel that
28
- > omits both - import them only from server-side code.
24
+ > `apiUtils`, `appkitUtils`, and `projectUtils` import Node-only modules
25
+ > (`@databricks/appkit`, `node:fs`) and are intentionally **not** re-exported
26
+ > from the browser entry. Vite / Webpack / esbuild builds that honor the
27
+ > `browser` condition will resolve `@dbx-tools/shared` to a barrel that
28
+ > omits all three - import them only from server-side code.
29
29
 
30
30
  ## `appkitUtils` - typed sibling-plugin lookup
31
31
 
@@ -106,8 +106,8 @@ const port = await netUtils.getRandomPort();
106
106
 
107
107
  Wraps `fetch` against `https://<workspace-host>/api/2.0/<path>` with the
108
108
  auth header your AppKit execution context already carries, plus an
109
- optional `CacheManager.getOrExecute` hook so per-user TTL'd reads are a
110
- single positional arg:
109
+ optional `cache` field on the init object so per-user TTL'd reads are a
110
+ single property:
111
111
 
112
112
  ```ts
113
113
  import { apiUtils } from "@dbx-tools/shared";
@@ -121,8 +121,7 @@ const data = await apiUtils.fetchApi<{ endpoints?: unknown[] }>(
121
121
  // With a per-user cache (useful for "list everything" calls):
122
122
  const cached = await apiUtils.fetchApi<{ endpoints?: unknown[] }>(
123
123
  "serving-endpoints",
124
- undefined,
125
- { userKey: req.userId, options: { ttl: 300 } },
124
+ { cache: { options: { ttl: 300 } } },
126
125
  );
127
126
 
128
127
  // POST + custom client (e.g. service-account script outside a request).
@@ -131,9 +130,8 @@ await apiUtils.fetchApi<{ id: string }>(
131
130
  {
132
131
  body: JSON.stringify({ inputs }),
133
132
  headers: { "Content-Type": "application/json" },
133
+ workspaceClient: serviceClient,
134
134
  },
135
- undefined,
136
- serviceClient,
137
135
  );
138
136
  ```
139
137
 
@@ -191,8 +189,14 @@ commonUtils.shortId(); // e.g. "a3f1c92b"
191
189
  commonUtils.fnvHash("databricks-claude-sonnet-4-6"); // e.g. "k3p9q7"
192
190
  commonUtils.fnvHashWithOptions({ length: 4 }, "user@example.com");
193
191
 
194
- // Poll an async fn until it returns truthy or the timeout fires.
195
- await commonUtils.poll(() => isReady(), { intervalMs: 250, timeoutMs: 30_000 });
192
+ // Async generator that polls a producer on an interval. Yields each
193
+ // value; stops when `predicate` returns false or the signal aborts.
194
+ for await (const status of commonUtils.poll(
195
+ async ({ signal }) => fetchStatus(signal),
196
+ { intervalMs: 250, predicate: (s) => s !== "ready" },
197
+ )) {
198
+ render(status);
199
+ }
196
200
 
197
201
  // Pull a printable message out of any thrown value. Folds the
198
202
  // `err instanceof Error ? err.message : String(err)` dance into
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "name": "@dbx-tools/shared",
25
- "version": "0.1.23",
25
+ "version": "0.1.25",
26
26
  "dependencies": {
27
27
  "fast-deep-equal": "^3.1.3",
28
28
  "lru-cache": "^11.5.1",