@dbx-tools/appkit 0.1.17 → 0.1.19

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 (3) hide show
  1. package/README.md +10 -10
  2. package/package.json +6 -3
  3. package/src/config.ts +24 -18
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @dbx-tools/node-appkit
1
+ # @dbx-tools/appkit
2
2
 
3
3
  Node-side helpers for Databricks AppKit apps.
4
4
 
@@ -47,7 +47,7 @@ environment variables before plugin setup runs.
47
47
 
48
48
  ```ts
49
49
  import { lakebase, server } from "@databricks/appkit";
50
- import { createApp } from "@dbx-tools/node-appkit";
50
+ import { createApp } from "@dbx-tools/appkit";
51
51
 
52
52
  await createApp.createApp({
53
53
  plugins: [server(), lakebase()],
@@ -67,7 +67,7 @@ Databricks Asset Bundle validation, and deployed Apps.
67
67
  Use the lower-level functions when you need to inspect or customize the result:
68
68
 
69
69
  ```ts
70
- import { lakebaseResolver } from "@dbx-tools/node-appkit";
70
+ import { lakebaseResolver } from "@dbx-tools/appkit";
71
71
 
72
72
  const resolved = await lakebaseResolver.resolveLakebaseConnection({
73
73
  endpoint: process.env.LAKEBASE_ENDPOINT,
@@ -83,7 +83,7 @@ lakebaseResolver.applyLakebaseToEnv(resolved);
83
83
  Databricks Asset Bundle validation output, and `app.yaml` env entries.
84
84
 
85
85
  ```ts
86
- import { config } from "@dbx-tools/node-appkit";
86
+ import { config } from "@dbx-tools/appkit";
87
87
 
88
88
  const warehouseId = await config.resolveConfigValue("SQL_WAREHOUSE_ID", {
89
89
  cli: { SQL_WAREHOUSE_ID: flags.warehouse },
@@ -102,7 +102,7 @@ Lakebase hosts, and partial inputs. It gives the resolver a common shape without
102
102
  requiring users to remember one canonical format.
103
103
 
104
104
  ```ts
105
- import { pgaddress } from "@dbx-tools/node-appkit";
105
+ import { pgaddress } from "@dbx-tools/appkit";
106
106
 
107
107
  pgaddress.parseAddress(
108
108
  "postgresql://user@ep-foo.database.azuredatabricks.net/databricks_postgres?sslmode=require",
@@ -119,7 +119,7 @@ code is running under AppKit, and `undefined` elsewhere. That lets libraries
119
119
  preserve OBO auth in apps while still working from scripts.
120
120
 
121
121
  ```ts
122
- import { appkit } from "@dbx-tools/node-appkit";
122
+ import { appkit } from "@dbx-tools/appkit";
123
123
  import { WorkspaceClient } from "@databricks/sdk-experimental";
124
124
 
125
125
  const client = appkit.tryGetExecutionContext()?.client ?? new WorkspaceClient({});
@@ -134,7 +134,7 @@ Databricks SDK calls accept a `Context`. Many app and web APIs use
134
134
  `AbortSignal`. `databricks.toContext()` bridges the two.
135
135
 
136
136
  ```ts
137
- import { databricks } from "@dbx-tools/node-appkit";
137
+ import { databricks } from "@dbx-tools/appkit";
138
138
 
139
139
  const context = databricks.toContext(request.signal);
140
140
  await client.apiClient.request({
@@ -157,7 +157,7 @@ errors when a required plugin is missing.
157
157
 
158
158
  ```ts
159
159
  import { lakebase } from "@databricks/appkit";
160
- import { plugin } from "@dbx-tools/node-appkit";
160
+ import { plugin } from "@dbx-tools/appkit";
161
161
 
162
162
  const lake = plugin.instance(this.context, lakebase);
163
163
  const pool = lake?.exports().pool;
@@ -175,7 +175,7 @@ the Postgres role that will run the app. Use it after Lakebase connection env ha
175
175
  been resolved and before AppKit initializes its persistent cache.
176
176
 
177
177
  ```ts
178
- import { provision } from "@dbx-tools/node-appkit";
178
+ import { provision } from "@dbx-tools/appkit";
179
179
  import { log } from "@dbx-tools/shared-core";
180
180
 
181
181
  await provision.provisionCacheSchema(
@@ -198,4 +198,4 @@ await provision.provisionCacheSchema(
198
198
 
199
199
  The shell-facing wrapper for auto-config is
200
200
  [`@dbx-tools/appkit-env`](../../cli/appkit-env). Higher-level agent composition
201
- is in [`@dbx-tools/node-appkit-mastra`](../appkit-mastra).
201
+ is in [`@dbx-tools/appkit-mastra`](../appkit-mastra).
package/package.json CHANGED
@@ -18,12 +18,15 @@
18
18
  "@databricks/sdk-experimental": "^0.17.0",
19
19
  "yaml": "^2.9.0",
20
20
  "zod": "^4.3.6",
21
- "@dbx-tools/core": "0.1.17",
22
- "@dbx-tools/shared-core": "0.1.17"
21
+ "@dbx-tools/shared-core": "0.1.19",
22
+ "@dbx-tools/core": "0.1.19"
23
23
  },
24
24
  "main": "index.ts",
25
25
  "license": "UNLICENSED",
26
- "version": "0.1.17",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "version": "0.1.19",
27
30
  "types": "index.ts",
28
31
  "type": "module",
29
32
  "exports": {
package/src/config.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  import { readFile } from "node:fs/promises";
14
14
  import { spawnSync } from "node:child_process";
15
15
  import { dirname, resolve } from "node:path";
16
- import { functionModule, iterable, log, string } from "@dbx-tools/shared-core";
16
+ import { functionModule, object, log, string } from "@dbx-tools/shared-core";
17
17
  import { file, project } from "@dbx-tools/core";
18
18
  import { parse as parseYamlText } from "yaml";
19
19
  import { z } from "zod";
@@ -122,10 +122,10 @@ export interface ResolveConfigValueOptions {
122
122
  const bundleDefault = functionModule.memoize(() => loadBundle(process.cwd()));
123
123
  const appYamlDefault = functionModule.memoize(() => loadAppYaml(process.cwd()));
124
124
 
125
- function envKeysForName(name: string): iterable.Sequence<string> {
125
+ function envKeysForName(name: string): object.Sequence<string> {
126
126
  const trimmed = name.trim();
127
127
  if (!trimmed) {
128
- return iterable.sequence();
128
+ return object.sequence();
129
129
  }
130
130
  const keys = (function* () {
131
131
  const modifiers: (((value: string) => string) | null)[] = [
@@ -137,7 +137,7 @@ function envKeysForName(name: string): iterable.Sequence<string> {
137
137
  yield modifier ? modifier(trimmed) : trimmed;
138
138
  }
139
139
  })();
140
- return iterable.sequence(keys).cache().filter(Boolean).distinct();
140
+ return object.sequence(keys).cache().filter(Boolean).distinct();
141
141
  }
142
142
 
143
143
  function readEnv(keys: Iterable<string>): string | undefined {
@@ -190,6 +190,24 @@ function pickAppResourceId(apps: Record<string, BundleApp>): string | undefined
190
190
  return keys.length === 1 ? keys[0] : undefined;
191
191
  }
192
192
 
193
+ /**
194
+ * Resolve the effective value a `value_from`/`valueFrom` entry points at:
195
+ * the first present of the warehouse id, Genie space id, or Postgres
196
+ * endpoint/database/branch on the named resource. Shared by both the
197
+ * `app.yaml` and `bundle validate` flatteners, whose resource shapes match.
198
+ */
199
+ function resolveResourceValue(
200
+ resource: z.infer<typeof bundleAppResourceSchema> | undefined,
201
+ ): string | undefined {
202
+ return (
203
+ resource?.sql_warehouse?.id ??
204
+ resource?.genie_space?.space_id ??
205
+ resource?.postgres?.endpoint ??
206
+ resource?.postgres?.database ??
207
+ resource?.postgres?.branch
208
+ );
209
+ }
210
+
193
211
  /**
194
212
  * Flatten `env` entries from parsed `app.yaml` content. Literal `value` entries
195
213
  * are returned as-is; `valueFrom` entries resolve against the sibling
@@ -212,13 +230,7 @@ export function flattenAppYamlEnv(data: unknown): Record<string, string> {
212
230
  continue;
213
231
  }
214
232
  if (!entry.valueFrom) continue;
215
- const resource = resourceByName.get(entry.valueFrom);
216
- const resolved =
217
- resource?.sql_warehouse?.id ??
218
- resource?.genie_space?.space_id ??
219
- resource?.postgres?.endpoint ??
220
- resource?.postgres?.database ??
221
- resource?.postgres?.branch;
233
+ const resolved = resolveResourceValue(resourceByName.get(entry.valueFrom));
222
234
  if (resolved) out[entry.name] = resolved;
223
235
  }
224
236
  return out;
@@ -255,13 +267,7 @@ export function flattenAppEnv(data: unknown): Record<string, string> {
255
267
  continue;
256
268
  }
257
269
  if (!entry.value_from) continue;
258
- const resource = resourceByName.get(entry.value_from);
259
- const resolved =
260
- resource?.sql_warehouse?.id ??
261
- resource?.genie_space?.space_id ??
262
- resource?.postgres?.endpoint ??
263
- resource?.postgres?.database ??
264
- resource?.postgres?.branch;
270
+ const resolved = resolveResourceValue(resourceByName.get(entry.value_from));
265
271
  if (resolved) out[entry.name] = resolved;
266
272
  }
267
273
  return out;