@dbx-tools/core 0.6.89 → 0.6.90

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
@@ -90,18 +90,39 @@ const timeoutMs = config.positiveInt(undefined, "TIMEOUT_MS", 30_000, {
90
90
  });
91
91
  ```
92
92
 
93
- Resolution is lazy and follows process env, `.env`, then Databricks bundle
94
- configuration. The default `DBX_TOOLS` scope and an optional capability prefix
95
- produce names such as `DBX_TOOLS_TUNNEL_PUBLIC_DOMAIN`, then
93
+ Resolution is lazy and follows constant `data`, process env, `.env`, Databricks
94
+ bundle configuration, then `app.yaml` / `app.yml` env values. The default
95
+ `DBX_TOOLS` scope and an optional capability prefix produce names such as
96
+ `DBX_TOOLS_TUNNEL_PUBLIC_DOMAIN`, then
96
97
  `TUNNEL_PUBLIC_DOMAIN`, then `PUBLIC_DOMAIN`. `.env.production` and `.env.prod`
97
98
  are checked before `.env` when `NODE_ENV=production`; development uses
98
99
  `.env.development` and `.env.dev`.
99
100
 
101
+ Pass one config map or an array of maps through `data`; the first matching value
102
+ wins before environment lookup by default. When a custom `sources` order omits
103
+ `config`, passed data is still read and is appended last. This lets a caller put
104
+ env first without accidentally discarding its fallback config:
105
+
106
+ ```ts
107
+ const endpoint = config.resolveValue("lakebaseEndpoint", {
108
+ data: { LAKEBASE_ENDPOINT: flags.endpoint },
109
+ sources: ["env", "dotenv", "bundle", "app"],
110
+ });
111
+ ```
112
+
113
+ `resolveValue()` tries the exact, uppercase, and tokenized-uppercase forms from
114
+ `environmentKeys()` before applying normal scope and prefix expansion.
115
+
100
116
  Bundle lookup runs `databricks bundle validate --output json` only after earlier
101
117
  sources miss. It reads literal values from the single App's `config.env`, accepts
102
- usable partial JSON from a failed validation, and caches each dotenv file or
103
- validated bundle once per resolved working-directory context. Bundle cache
104
- entries also include the Databricks profile. Root bundle `variables` are NOT a
118
+ usable partial JSON from a failed validation, and honors the active Databricks
119
+ profile. Parsed dotenv records are cached by file path; parsed bundle output is
120
+ cached by bundle path plus profile. App YAML lookup runs only if the bundle did
121
+ not resolve the key and reads `env[].value` entries. Bundle `value_from` and App
122
+ YAML `valueFrom` references resolve supported fields from their named
123
+ `sql_warehouse`, `genie_space`, or `postgres` resource. Config-file discovery and parsed results
124
+ are single-attempt per source key: found paths, missing files, empty records,
125
+ invalid records, and `undefined` results all cache. Root bundle `variables` are NOT a
105
126
  config source: they are authoring inputs interpolated into the bundle's own
106
127
  targets, resources, and paths, so reading one as a process setting resolves names
107
128
  the deployed App never sees. Reference a variable from `config.env` to make it
@@ -113,13 +134,14 @@ contains a bundle, and bundle reads are enabled, validation runs. This keeps
113
134
  pre-boot callers such as `@dbx-tools/appkit` auto-configuration on the same
114
135
  deterministic path as CLIs and ordinary Node consumers.
115
136
 
116
- Deployed Apps skip dotenv and bundle lookup after `isDatabricksAppEnv()`
137
+ Deployed Apps skip dotenv, bundle, and app YAML lookup after `isDatabricksAppEnv()`
117
138
  recognizes the required App name, HTTP(S) host, and valid port. Set
118
139
  `DBX_TOOLS_DATABRICKS_APP_ENV=true` or `false` to force that result; unrecognized
119
140
  values leave automatic detection in place.
120
141
 
121
- `DBX_TOOLS_CONFIG_DOTENV` and `DBX_TOOLS_CONFIG_BUNDLE` independently force
122
- those file sources on or off. A recognized boolean takes precedence over App
142
+ `DBX_TOOLS_CONFIG_DOTENV`, `DBX_TOOLS_CONFIG_BUNDLE`, and
143
+ `DBX_TOOLS_CONFIG_APP` independently force those file sources on or off. A
144
+ recognized boolean takes precedence over App
123
145
  runtime detection, so `true` can enable a local source inside an App and `false`
124
146
  can suppress it during local development. Absent or unrecognized values keep
125
147
  the default: read files outside an App and skip them inside one. Bundle reads
@@ -130,6 +152,8 @@ Use `config.string()`, `boolean()`, `positiveNumber()`, `positiveInt()`,
130
152
  `port()`, and `list()` to normalize typed options and text-based configuration
131
153
  through one rule. `config.port()` accepts only TCP ports from 1 through 65535;
132
154
  `config.ENV_ONLY` disables file fallbacks for exact environment reads.
155
+ `config.flattenBundleEnv()`, `flattenAppEnv()`, and `getBundlePath()` expose the
156
+ same parsing logic for callers that already have parsed configuration data.
133
157
 
134
158
  ## Run Commands
135
159
 
@@ -254,19 +278,25 @@ import { project } from "@dbx-tools/core";
254
278
  const root = project.root();
255
279
  const name = project.name();
256
280
  const origins = [...project.resolveProjectRoots(process.cwd())];
281
+ const cwd = project.resolveWorkingDirectory("");
257
282
  ```
258
283
 
259
284
  `project.root()` checks npm/pnpm workspace roots, git top-level, and cwd.
260
285
  `project.name()` prefers package metadata, then git remote name, then directory
261
- basename. `project.stat()` returns `undefined` instead of throwing.
286
+ basename. `project.resolveWorkingDirectory()` normalizes blank, null, omitted,
287
+ relative, and absolute cwd values for cache decisions. Project subprocess probes
288
+ share a command/argument result cache only when that resolved path is the live
289
+ process cwd; another directory executes directly. Empty command results are
290
+ cached too.
262
291
 
263
292
  ## Modules
264
293
 
265
294
  - `exec` - async/sync process spawning, stdio handling, abort wiring, and shlex.
266
295
  - `bin` - executable download, optional archive extraction, selection, and
267
296
  atomic installation.
268
- - `project` - root discovery, project naming, git-remote parsing, and safe
269
- filesystem stat.
297
+ - `project` - cwd normalization, root discovery, project naming, and git-remote
298
+ parsing.
299
+ - `file` - best-effort stat and parsed-record caching by caller-defined source key.
270
300
  - `brand` - YAML/JSON discovery, parsing, validation, and asset path resolution.
271
301
  - `config` - scoped environment, dotenv, and validated Databricks bundle lookup,
272
302
  including runtime detection and typed coercion helpers.
package/index.ts CHANGED
@@ -13,7 +13,8 @@ export * as project from "./src/project.ts";
13
13
  export type { BinContext, BinSelectionContext, BinSelector, BinVersionOutput, BinVersionParser, BinOptions, BinUrl } from "./src/bin.ts";
14
14
  export { BrandContextSchema, defaultBrandContext, parseBrandContext, brandContextJsonSchema, brandContextPrompt } from "./src/brand.ts";
15
15
  export type { BrandContext, BrandContextInput } from "./src/brand.ts";
16
- export { MAX_TCP_PORT, ENV_ONLY, valueSchema, bundleResourceSchema, bundleEnvEntrySchema, bundleAppSchema } from "./src/config.ts";
16
+ export { MAX_TCP_PORT, ENV_ONLY, valueSchema, bundleResourceSchema, bundleEnvEntrySchema, bundleAppSchema, appEnvEntrySchema, appSchema } from "./src/config.ts";
17
+ export type { ConfigMapValue, ConfigData, ConfigSource, ConfigOptions, ConfigFile } from "./src/config.ts";
17
18
  export { COMMAND_NOT_FOUND_EXIT_CODE } from "./src/exec.ts";
18
19
  export type { ExecStdio, LineHandler, StdioOption, ExecResult, ChildProcessResult, ExecOptions, SyncExecStdio, SyncExecOptions, SpawnArgs } from "./src/exec.ts";
19
20
  export type { FileLockBackend, FileLockAcquisition, FileLockOptions } from "./src/file-lock.ts";
package/lib/index.d.ts CHANGED
@@ -9,7 +9,8 @@ export * as project from "./src/project.ts";
9
9
  export type { BinContext, BinSelectionContext, BinSelector, BinVersionOutput, BinVersionParser, BinOptions, BinUrl } from "./src/bin.ts";
10
10
  export { BrandContextSchema, defaultBrandContext, parseBrandContext, brandContextJsonSchema, brandContextPrompt } from "./src/brand.ts";
11
11
  export type { BrandContext, BrandContextInput } from "./src/brand.ts";
12
- export { MAX_TCP_PORT, ENV_ONLY, valueSchema, bundleResourceSchema, bundleEnvEntrySchema, bundleAppSchema } from "./src/config.ts";
12
+ export { MAX_TCP_PORT, ENV_ONLY, valueSchema, bundleResourceSchema, bundleEnvEntrySchema, bundleAppSchema, appEnvEntrySchema, appSchema } from "./src/config.ts";
13
+ export type { ConfigMapValue, ConfigData, ConfigSource, ConfigOptions, ConfigFile } from "./src/config.ts";
13
14
  export { COMMAND_NOT_FOUND_EXIT_CODE } from "./src/exec.ts";
14
15
  export type { ExecStdio, LineHandler, StdioOption, ExecResult, ChildProcessResult, ExecOptions, SyncExecStdio, SyncExecOptions, SpawnArgs } from "./src/exec.ts";
15
16
  export type { FileLockBackend, FileLockAcquisition, FileLockOptions } from "./src/file-lock.ts";
package/lib/index.js CHANGED
@@ -10,6 +10,6 @@ export * as fileLock from "./src/file-lock.js";
10
10
  export * as processLock from "./src/process-lock.js";
11
11
  export * as project from "./src/project.js";
12
12
  export { BrandContextSchema, defaultBrandContext, parseBrandContext, brandContextJsonSchema, brandContextPrompt } from "./src/brand.js";
13
- export { MAX_TCP_PORT, ENV_ONLY, valueSchema, bundleResourceSchema, bundleEnvEntrySchema, bundleAppSchema } from "./src/config.js";
13
+ export { MAX_TCP_PORT, ENV_ONLY, valueSchema, bundleResourceSchema, bundleEnvEntrySchema, bundleAppSchema, appEnvEntrySchema, appSchema } from "./src/config.js";
14
14
  export { COMMAND_NOT_FOUND_EXIT_CODE } from "./src/exec.js";
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7QUFDM0MsbURBQW1EO0FBQ25ELHdFQUF3RTtBQUV4RSxPQUFPLEtBQUssR0FBRyxNQUFNLGNBQWMsQ0FBQztBQUNwQyxPQUFPLEtBQUssS0FBSyxNQUFNLGdCQUFnQixDQUFDO0FBQ3hDLE9BQU8sS0FBSyxNQUFNLE1BQU0saUJBQWlCLENBQUM7QUFDMUMsT0FBTyxLQUFLLElBQUksTUFBTSxlQUFlLENBQUM7QUFDdEMsT0FBTyxLQUFLLElBQUksTUFBTSxlQUFlLENBQUM7QUFDdEMsT0FBTyxLQUFLLFFBQVEsTUFBTSxvQkFBb0IsQ0FBQztBQUMvQyxPQUFPLEtBQUssV0FBVyxNQUFNLHVCQUF1QixDQUFDO0FBQ3JELE9BQU8sS0FBSyxPQUFPLE1BQU0sa0JBQWtCLENBQUM7QUFFNUMsT0FBTyxFQUFFLGtCQUFrQixFQUFFLG1CQUFtQixFQUFFLGlCQUFpQixFQUFFLHNCQUFzQixFQUFFLGtCQUFrQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFeEksT0FBTyxFQUFFLFlBQV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nJhbmQudHNcIjtcbmV4cG9ydCB7IE1BWF9UQ1BfUE9SVCwgRU5WX09OTFksIHZhbHVlU2NoZW1hLCBidW5kbGVSZXNvdXJjZVNjaGVtYSwgYnVuZGxlRW52RW50cnlTY2hlbWEsIGJ1bmRsZUFwcFNjaGVtYSwgYXBwRW52RW50cnlTY2hlbWEsIGFwcFNjaGVtYSB9IGZyb20gXCIuL3NyYy9jb25maWcudHNcIjtcbmV4cG9ydCB0eXBlIHsgQ29uZmlnTWFwVmFsdWUsIENvbmZpZ0RhdGEsIENvbmZpZ1NvdXJjZSwgQ29uZmlnT3B0aW9ucywgQ29uZmlnRmlsZSB9IGZyb20gXCIuL3NyYy9jb25maWcudHNcIjtcbmV4cG9ydCB7IENPTU1BTkRfTk9UX0ZPVU5EX0VYSVRfQ09ERSB9IGZyb20gXCIuL3NyYy9leGVjLnRzXCI7XG5leHBvcnQgdHlwZSB7IEV4ZWNTdGRpbywgTGluZUhhbmRsZXIsIFN0ZGlvT3B0aW9uLCBFeGVjUmVzdWx0LCBDaGlsZFByb2Nlc3NSZXN1bHQsIEV4ZWNPcHRpb25zLCBTeW5jRXhlY1N0ZGlvLCBTeW5jRXhlY09wdGlvbnMsIFNwYXduQXJncyB9IGZyb20gXCIuL3NyYy9leGVjLnRzXCI7XG5leHBvcnQgdHlwZSB7IEZpbGVMb2NrQmFja2VuZCwgRmlsZUxvY2tBY3F1aXNpdGlvbiwgRmlsZUxvY2tPcHRpb25zIH0gZnJvbSBcIi4vc3JjL2ZpbGUtbG9jay50c1wiO1xuZXhwb3J0IHR5cGUgeyBQcm9qZWN0Q29udGV4dCB9IGZyb20gXCIuL3NyYy9wcm9qZWN0LnRzXCI7XG4iXX0=
@@ -1,29 +1,25 @@
1
1
  /**
2
- * Layered configuration lookup: environment, `.env`, Databricks bundle.
2
+ * Layered configuration lookup: environment, `.env`, bundle, and `app.yaml`.
3
3
  *
4
4
  * Every package resolves settings the same way: take the caller's value, else
5
5
  * an environment variable, else a default. Local development adds two fallback
6
- * locations: `.env` files and one App's `resources.apps.<app>.config.env` in
7
- * `databricks.yml`.
6
+ * locations: `.env` files, one App's `resources.apps.<app>.config.env` in
7
+ * `databricks.yml`, and literal env values in `app.yaml` / `app.yml`.
8
8
  *
9
- * Two things make it cheap to call from a hot path:
9
+ * {@link values} is LAZY (an `object.Sequence`), so `databricks bundle validate`
10
+ * is only spawned when the environment and `.env` both missed; app YAML is only
11
+ * read after the bundle source also missed.
10
12
  *
11
- * - {@link values} is LAZY (an `object.Sequence`), so `databricks bundle
12
- * validate` is only spawned when the environment and `.env` both missed.
13
- * - the parsed `.env` and bundle are cached through {@link context.cached}, so
14
- * the spawn happens once per working directory and a `cwd` change misses
15
- * rather than returning another project's config.
16
- *
17
- * Inside a deployed Databricks App both file sources are skipped by default
13
+ * Inside a deployed Databricks App all three file sources are skipped by default
18
14
  * ({@link isDatabricksAppEnv}): the platform has already turned them into real
19
15
  * environment variables, there is no bundle to validate, and the `databricks`
20
16
  * CLI is not on the image. Boolean environment overrides can force either file
21
17
  * source on or off when a tool needs different behavior.
22
18
  *
23
- * Only the single app's `config.env` is consulted. Root bundle `variables` are
24
- * not: they are authoring inputs for the bundle itself (interpolated into
25
- * targets, resources, and paths), so treating one as a process setting resolves
26
- * names the deployed app never sees.
19
+ * Only the single bundle app's `config.env` and literal app YAML `env[].value`
20
+ * entries are consulted. Root bundle `variables` are not: they are authoring
21
+ * inputs for the bundle itself (interpolated into targets, resources, and paths),
22
+ * so treating one as a process setting resolves names the deployed app never sees.
27
23
  *
28
24
  * Node-only (`child_process`, `fs`, `process`).
29
25
  *
@@ -31,22 +27,30 @@
31
27
  */
32
28
  import { z } from "zod";
33
29
  type ConfigKey = string | readonly string[];
30
+ export type ConfigMapValue = string | readonly string[] | null | undefined;
31
+ export type ConfigData = Readonly<Record<string, ConfigMapValue>>;
34
32
  /** Where a value may come from, consulted in the order given. */
35
- type ConfigSource = "env" | "dotenv" | "bundle";
36
- interface ConfigOptions {
33
+ export type ConfigSource = "config" | "env" | "dotenv" | "bundle" | "app";
34
+ export interface ConfigOptions {
37
35
  /**
38
36
  * Outermost namespaces tried before each key. Defaults to `DBX_TOOLS`.
39
37
  */
40
38
  scope?: string | readonly string[];
41
39
  /** Capability namespaces inserted after the scope and before each key. */
42
40
  prefix?: string | readonly string[];
43
- /** Sources in precedence order. Default: `env`, `dotenv`, `bundle`. */
41
+ /** Constant config maps read by the `config` source. */
42
+ data?: ConfigData | readonly ConfigData[];
43
+ /** Parsed bundle data used instead of loading `databricks.yml`. */
44
+ bundleData?: ConfigFile | Record<string, unknown>;
45
+ /** Parsed app YAML data used instead of loading `app.yaml`. */
46
+ appData?: ConfigFile | Record<string, unknown>;
47
+ /** Sources in precedence order. Default: `config`, `env`, `dotenv`, `bundle`, `app`. */
44
48
  sources?: ConfigSource | readonly ConfigSource[];
45
49
  /** Directory to resolve `.env` and the bundle from. Default: `process.cwd()`. */
46
50
  cwd?: string;
47
51
  }
48
52
  /** A config file found on disk, with its parsed contents. */
49
- interface ConfigFile {
53
+ export interface ConfigFile {
50
54
  path: string;
51
55
  data: Record<string, unknown>;
52
56
  }
@@ -58,13 +62,7 @@ export declare const ENV_ONLY: {
58
62
  sources: "env";
59
63
  };
60
64
  export declare const valueSchema: z.ZodString;
61
- /**
62
- * The GENERIC shape of a bundle resource: a name, and whatever else the resource
63
- * type carries. Deliberately unopinionated and `passthrough()` - the concrete
64
- * resource kinds (`sql_warehouse`, `genie_space`, `postgres`, ...) are
65
- * Databricks-App concepts that belong to the package that resolves them, so
66
- * node-appkit `.extend()`s this rather than this module knowing about them.
67
- */
65
+ /** A named bundle or App resource; concrete resource fields pass through. */
68
66
  export declare const bundleResourceSchema: z.ZodObject<{
69
67
  name: z.ZodOptional<z.ZodString>;
70
68
  }, z.core.$loose>;
@@ -86,6 +84,27 @@ export declare const bundleAppSchema: z.ZodObject<{
86
84
  name: z.ZodOptional<z.ZodString>;
87
85
  }, z.core.$loose>>>;
88
86
  }, z.core.$strip>;
87
+ export declare const appEnvEntrySchema: z.ZodObject<{
88
+ name: z.ZodString;
89
+ value: z.ZodOptional<z.ZodString>;
90
+ valueFrom: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>;
92
+ export declare const appSchema: z.ZodObject<{
93
+ env: z.ZodOptional<z.ZodArray<z.ZodObject<{
94
+ name: z.ZodString;
95
+ value: z.ZodOptional<z.ZodString>;
96
+ valueFrom: z.ZodOptional<z.ZodString>;
97
+ }, z.core.$strip>>>;
98
+ resources: z.ZodOptional<z.ZodArray<z.ZodObject<{
99
+ name: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$loose>>>;
101
+ }, z.core.$strip>;
102
+ /** Flatten the single bundle App's `config.env`, resolving resource references. */
103
+ export declare function flattenBundleEnv(data: unknown): Record<string, string>;
104
+ /** Flatten `app.yaml` env entries, resolving `valueFrom` resource references. */
105
+ export declare function flattenAppEnv(data: unknown): Record<string, string>;
106
+ /** Walk a dot-separated path through parsed bundle data. */
107
+ export declare function getBundlePath(data: Record<string, unknown>, path: string): string | undefined;
89
108
  /**
90
109
  * Detect a Databricks App runtime from its required name, host, and port.
91
110
  *
@@ -95,6 +114,8 @@ export declare const bundleAppSchema: z.ZodObject<{
95
114
  * absent or unrecognized override falls back to structural detection.
96
115
  */
97
116
  export declare function isDatabricksAppEnv(source?: Record<string, string | undefined>): boolean;
117
+ /** Exact, uppercase, and tokenized-uppercase names for a human-friendly key. */
118
+ export declare function environmentKeys(name: string): readonly string[];
98
119
  /**
99
120
  * The first value that resolves for `input`, or `undefined`.
100
121
  *
@@ -102,6 +123,8 @@ export declare function isDatabricksAppEnv(source?: Record<string, string | unde
102
123
  * const domain = config.text(["TUNNEL_PUBLIC_DOMAIN", "PUBLIC_DOMAIN"]);
103
124
  */
104
125
  export declare function text(input: ConfigKey, options?: ConfigOptions): string | undefined;
126
+ /** Resolve a human-friendly name through {@link environmentKeys} and {@link text}. */
127
+ export declare function resolveValue(name: string, options?: ConfigOptions): string | undefined;
105
128
  /**
106
129
  * The PRIMARY (fully-scoped) name for `input` - what to print in a log line or an
107
130
  * error, so the message names the variable a reader should set. Do not index
@@ -156,10 +179,10 @@ export declare function list(configured: string | readonly string[] | undefined
156
179
  * or a deployed App without an explicit override, there is no bundle, or the
157
180
  * CLI produces no JSON.
158
181
  *
159
- * Cached once per resolved working-directory context and
160
- * `DATABRICKS_CONFIG_PROFILE` through {@link context.cached}, so repeated
161
- * lookups do not rerun validation and changing either cannot return another
162
- * context's bundle.
182
+ * Parsed validation output is cached by bundle path and Databricks profile.
183
+ *
163
184
  */
164
185
  export declare function bundleFile(cwd?: string | null): ConfigFile | undefined;
186
+ /** The parsed `app.yaml` / `app.yml` for `cwd`, when local App config reads are enabled. */
187
+ export declare function appFile(cwd?: string | null): ConfigFile | undefined;
165
188
  export {};