@databricks/sdk-core 0.33.0 → 0.35.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 (135) hide show
  1. package/dist/apierror/apierror.d.ts +52 -49
  2. package/dist/apierror/apierror.d.ts.map +1 -1
  3. package/dist/apierror/apierror.js +124 -172
  4. package/dist/apierror/apierror.js.map +1 -1
  5. package/dist/apierror/codes/codes.d.ts +113 -113
  6. package/dist/apierror/codes/codes.d.ts.map +1 -1
  7. package/dist/apierror/codes/codes.js +24 -115
  8. package/dist/apierror/codes/codes.js.map +1 -1
  9. package/dist/apierror/codes/index.d.ts +2 -7
  10. package/dist/apierror/codes/index.js +3 -7
  11. package/dist/apierror/details.d.ts +104 -101
  12. package/dist/apierror/details.d.ts.map +1 -1
  13. package/dist/apierror/details.js +151 -226
  14. package/dist/apierror/details.js.map +1 -1
  15. package/dist/apierror/index.d.ts +3 -8
  16. package/dist/apierror/index.js +3 -7
  17. package/dist/clientinfo/agent.d.ts +6 -3
  18. package/dist/clientinfo/agent.d.ts.map +1 -1
  19. package/dist/clientinfo/agent.js +134 -112
  20. package/dist/clientinfo/agent.js.map +1 -1
  21. package/dist/clientinfo/base.d.ts +13 -15
  22. package/dist/clientinfo/base.d.ts.map +1 -1
  23. package/dist/clientinfo/base.js +50 -50
  24. package/dist/clientinfo/base.js.map +1 -1
  25. package/dist/clientinfo/clientinfo.d.ts +40 -38
  26. package/dist/clientinfo/clientinfo.d.ts.map +1 -1
  27. package/dist/clientinfo/clientinfo.js +78 -88
  28. package/dist/clientinfo/clientinfo.js.map +1 -1
  29. package/dist/clientinfo/default.browser.d.ts +6 -10
  30. package/dist/clientinfo/default.browser.d.ts.map +1 -1
  31. package/dist/clientinfo/default.browser.js +24 -16
  32. package/dist/clientinfo/default.browser.js.map +1 -1
  33. package/dist/clientinfo/default.d.ts +8 -4
  34. package/dist/clientinfo/default.d.ts.map +1 -1
  35. package/dist/clientinfo/default.js +157 -102
  36. package/dist/clientinfo/default.js.map +1 -1
  37. package/dist/clientinfo/index.browser.d.ts +4 -5
  38. package/dist/clientinfo/index.browser.js +5 -4
  39. package/dist/clientinfo/index.d.ts +4 -5
  40. package/dist/clientinfo/index.js +5 -4
  41. package/dist/clientinfo/meta-harness.d.ts +6 -3
  42. package/dist/clientinfo/meta-harness.d.ts.map +1 -1
  43. package/dist/clientinfo/meta-harness.js +30 -46
  44. package/dist/clientinfo/meta-harness.js.map +1 -1
  45. package/dist/http/http.d.ts +25 -22
  46. package/dist/http/http.d.ts.map +1 -1
  47. package/dist/http/http.js +24 -34
  48. package/dist/http/http.js.map +1 -1
  49. package/dist/http/index.d.ts +2 -8
  50. package/dist/http/index.js +3 -7
  51. package/dist/index.d.ts +1 -6
  52. package/dist/index.js +7 -5
  53. package/dist/index.js.map +1 -1
  54. package/dist/logger/index.d.ts +2 -8
  55. package/dist/logger/index.js +3 -7
  56. package/dist/logger/logger.d.ts +26 -23
  57. package/dist/logger/logger.d.ts.map +1 -1
  58. package/dist/logger/logger.js +46 -60
  59. package/dist/logger/logger.js.map +1 -1
  60. package/dist/ops/execute.d.ts +7 -3
  61. package/dist/ops/execute.d.ts.map +1 -1
  62. package/dist/ops/execute.js +55 -67
  63. package/dist/ops/execute.js.map +1 -1
  64. package/dist/ops/index.d.ts +5 -12
  65. package/dist/ops/index.js +4 -9
  66. package/dist/ops/limiter.d.ts +5 -2
  67. package/dist/ops/limiter.d.ts.map +1 -1
  68. package/dist/ops/limiter.js +0 -2
  69. package/dist/ops/options.d.ts +23 -19
  70. package/dist/ops/options.d.ts.map +1 -1
  71. package/dist/ops/options.js +0 -2
  72. package/dist/ops/retrier.d.ts +34 -31
  73. package/dist/ops/retrier.d.ts.map +1 -1
  74. package/dist/ops/retrier.js +55 -66
  75. package/dist/ops/retrier.js.map +1 -1
  76. package/dist/package.js +6 -0
  77. package/dist/package.js.map +1 -0
  78. package/dist/profiles/errors.d.ts +7 -4
  79. package/dist/profiles/errors.d.ts.map +1 -1
  80. package/dist/profiles/errors.js +16 -17
  81. package/dist/profiles/errors.js.map +1 -1
  82. package/dist/profiles/index.browser.d.ts +4 -10
  83. package/dist/profiles/index.browser.js +4 -8
  84. package/dist/profiles/index.d.ts +5 -15
  85. package/dist/profiles/index.js +5 -13
  86. package/dist/profiles/ini.d.ts +6 -3
  87. package/dist/profiles/ini.d.ts.map +1 -1
  88. package/dist/profiles/ini.js +60 -108
  89. package/dist/profiles/ini.js.map +1 -1
  90. package/dist/profiles/profile.d.ts +66 -67
  91. package/dist/profiles/profile.d.ts.map +1 -1
  92. package/dist/profiles/profile.js +89 -84
  93. package/dist/profiles/profile.js.map +1 -1
  94. package/dist/profiles/resolve.d.ts +8 -9
  95. package/dist/profiles/resolve.d.ts.map +1 -1
  96. package/dist/profiles/resolve.js +140 -185
  97. package/dist/profiles/resolve.js.map +1 -1
  98. package/dist/profiles/secret.d.ts +15 -12
  99. package/dist/profiles/secret.d.ts.map +1 -1
  100. package/dist/profiles/secret.js +38 -35
  101. package/dist/profiles/secret.js.map +1 -1
  102. package/dist/wkt/fieldmask.d.ts +23 -20
  103. package/dist/wkt/fieldmask.d.ts.map +1 -1
  104. package/dist/wkt/fieldmask.js +53 -62
  105. package/dist/wkt/fieldmask.js.map +1 -1
  106. package/dist/wkt/index.d.ts +3 -4
  107. package/dist/wkt/index.js +3 -2
  108. package/dist/wkt/value.d.ts +6 -3
  109. package/dist/wkt/value.d.ts.map +1 -1
  110. package/dist/wkt/value.js +0 -2
  111. package/package.json +2 -2
  112. package/dist/apierror/codes/index.d.ts.map +0 -1
  113. package/dist/apierror/codes/index.js.map +0 -1
  114. package/dist/apierror/index.d.ts.map +0 -1
  115. package/dist/apierror/index.js.map +0 -1
  116. package/dist/clientinfo/index.browser.d.ts.map +0 -1
  117. package/dist/clientinfo/index.browser.js.map +0 -1
  118. package/dist/clientinfo/index.d.ts.map +0 -1
  119. package/dist/clientinfo/index.js.map +0 -1
  120. package/dist/http/index.d.ts.map +0 -1
  121. package/dist/http/index.js.map +0 -1
  122. package/dist/index.d.ts.map +0 -1
  123. package/dist/logger/index.d.ts.map +0 -1
  124. package/dist/logger/index.js.map +0 -1
  125. package/dist/ops/index.d.ts.map +0 -1
  126. package/dist/ops/index.js.map +0 -1
  127. package/dist/ops/limiter.js.map +0 -1
  128. package/dist/ops/options.js.map +0 -1
  129. package/dist/profiles/index.browser.d.ts.map +0 -1
  130. package/dist/profiles/index.browser.js.map +0 -1
  131. package/dist/profiles/index.d.ts.map +0 -1
  132. package/dist/profiles/index.js.map +0 -1
  133. package/dist/wkt/index.d.ts.map +0 -1
  134. package/dist/wkt/index.js.map +0 -1
  135. package/dist/wkt/value.js.map +0 -1
@@ -1,89 +1,94 @@
1
+ import { Secret } from "./secret.js";
2
+
3
+ //#region src/profiles/profile.ts
1
4
  /**
2
- * Profile interface and property mapping for Databricks configuration.
3
- *
4
- * @module
5
- */
6
- import { Secret } from './secret';
5
+ * Profile interface and property mapping for Databricks configuration.
6
+ *
7
+ * @module
8
+ */
7
9
  /**
8
- * Reserved INI section name for SDK settings. It is never treated as a
9
- * profile.
10
- */
11
- export const SETTINGS_SECTION = '__settings__';
10
+ * Reserved INI section name for SDK settings. It is never treated as a
11
+ * profile.
12
+ */
13
+ const SETTINGS_SECTION = "__settings__";
12
14
  /**
13
- * Declarative property mapping table for all known profile fields.
14
- */
15
- export const PROPERTY_DEFS = [
16
- {
17
- field: 'host',
18
- envVar: 'DATABRICKS_HOST',
19
- iniKey: 'host',
20
- set: (p, v) => {
21
- p.host = v;
22
- },
23
- get: (p) => p.host,
24
- },
25
- {
26
- field: 'workspaceId',
27
- envVar: 'DATABRICKS_WORKSPACE_ID',
28
- iniKey: 'workspace_id',
29
- set: (p, v) => {
30
- p.workspaceId = v;
31
- },
32
- get: (p) => p.workspaceId,
33
- },
34
- {
35
- field: 'accountId',
36
- envVar: 'DATABRICKS_ACCOUNT_ID',
37
- iniKey: 'account_id',
38
- set: (p, v) => {
39
- p.accountId = v;
40
- },
41
- get: (p) => p.accountId,
42
- },
43
- {
44
- field: 'token',
45
- envVar: 'DATABRICKS_TOKEN',
46
- iniKey: 'token',
47
- set: (p, v) => {
48
- p.token = new Secret(v);
49
- },
50
- get: (p) => p.token?.value,
51
- },
52
- {
53
- field: 'authType',
54
- envVar: 'DATABRICKS_AUTH_TYPE',
55
- iniKey: 'auth_type',
56
- set: (p, v) => {
57
- p.authType = v;
58
- },
59
- get: (p) => p.authType,
60
- },
61
- {
62
- field: 'clientId',
63
- envVar: 'DATABRICKS_CLIENT_ID',
64
- iniKey: 'client_id',
65
- set: (p, v) => {
66
- p.clientId = v;
67
- },
68
- get: (p) => p.clientId,
69
- },
70
- {
71
- field: 'clientSecret',
72
- envVar: 'DATABRICKS_CLIENT_SECRET',
73
- iniKey: 'client_secret',
74
- set: (p, v) => {
75
- p.clientSecret = new Secret(v);
76
- },
77
- get: (p) => p.clientSecret?.value,
78
- },
79
- {
80
- field: 'databricksCliPath',
81
- envVar: 'DATABRICKS_CLI_PATH',
82
- iniKey: 'databricks_cli_path',
83
- set: (p, v) => {
84
- p.databricksCliPath = v;
85
- },
86
- get: (p) => p.databricksCliPath,
87
- },
15
+ * Declarative property mapping table for all known profile fields.
16
+ */
17
+ const PROPERTY_DEFS = [
18
+ {
19
+ field: "host",
20
+ envVar: "DATABRICKS_HOST",
21
+ iniKey: "host",
22
+ set: (p, v) => {
23
+ p.host = v;
24
+ },
25
+ get: (p) => p.host
26
+ },
27
+ {
28
+ field: "workspaceId",
29
+ envVar: "DATABRICKS_WORKSPACE_ID",
30
+ iniKey: "workspace_id",
31
+ set: (p, v) => {
32
+ p.workspaceId = v;
33
+ },
34
+ get: (p) => p.workspaceId
35
+ },
36
+ {
37
+ field: "accountId",
38
+ envVar: "DATABRICKS_ACCOUNT_ID",
39
+ iniKey: "account_id",
40
+ set: (p, v) => {
41
+ p.accountId = v;
42
+ },
43
+ get: (p) => p.accountId
44
+ },
45
+ {
46
+ field: "token",
47
+ envVar: "DATABRICKS_TOKEN",
48
+ iniKey: "token",
49
+ set: (p, v) => {
50
+ p.token = new Secret(v);
51
+ },
52
+ get: (p) => p.token?.value
53
+ },
54
+ {
55
+ field: "authType",
56
+ envVar: "DATABRICKS_AUTH_TYPE",
57
+ iniKey: "auth_type",
58
+ set: (p, v) => {
59
+ p.authType = v;
60
+ },
61
+ get: (p) => p.authType
62
+ },
63
+ {
64
+ field: "clientId",
65
+ envVar: "DATABRICKS_CLIENT_ID",
66
+ iniKey: "client_id",
67
+ set: (p, v) => {
68
+ p.clientId = v;
69
+ },
70
+ get: (p) => p.clientId
71
+ },
72
+ {
73
+ field: "clientSecret",
74
+ envVar: "DATABRICKS_CLIENT_SECRET",
75
+ iniKey: "client_secret",
76
+ set: (p, v) => {
77
+ p.clientSecret = new Secret(v);
78
+ },
79
+ get: (p) => p.clientSecret?.value
80
+ },
81
+ {
82
+ field: "databricksCliPath",
83
+ envVar: "DATABRICKS_CLI_PATH",
84
+ iniKey: "databricks_cli_path",
85
+ set: (p, v) => {
86
+ p.databricksCliPath = v;
87
+ },
88
+ get: (p) => p.databricksCliPath
89
+ }
88
90
  ];
91
+
92
+ //#endregion
93
+ export { PROPERTY_DEFS, SETTINGS_SECTION };
89
94
  //# sourceMappingURL=profile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/profiles/profile.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"profile.js","names":[],"sources":["../../src/profiles/profile.ts"],"sourcesContent":["/**\n * Profile interface and property mapping for Databricks configuration.\n *\n * @module\n */\n\nimport {Secret} from './secret';\n\n/**\n * Holds configuration values resolved from a databrickscfg file and/or\n * environment variables. All fields are optional; an absent field means the\n * value was not configured.\n */\nexport interface Profile {\n /** Profile name (INI section name). */\n name?: string;\n\n /** Databricks workspace or Accounts API endpoint URL. */\n host?: string;\n\n /**\n * Databricks Workspace ID, used with unified hosts. Accepts either a classic\n * numeric workspace ID or another workspace identifier format that the server\n * understands.\n */\n workspaceId?: string;\n\n /** Databricks Account ID for Accounts API. */\n accountId?: string;\n\n /** Personal access token for PAT authentication. */\n token?: Secret;\n\n /** Selects a specific auth method when multiple credentials are available. */\n authType?: string;\n\n /** OAuth client ID for M2M authentication. */\n clientId?: string;\n\n /** OAuth client secret for M2M authentication. */\n clientSecret?: Secret;\n\n /** Path to the Databricks CLI binary (>= 0.100.0) for CLI-based auth. */\n databricksCliPath?: string;\n\n /**\n * INI keys not mapped to a known field. Only populated when loading from a\n * config file; environment variables do not contribute to extra.\n */\n extra?: Record<string, string>;\n}\n\n/**\n * Configures how a profile is resolved by {@link resolve}.\n *\n * Resolution is enabled by default: with no options, {@link resolve} reads the\n * config file and overlays DATABRICKS_* environment variables on top. Each\n * source can be disabled independently with {@link ProfileOptions.noProfile}\n * and {@link ProfileOptions.disableEnv}.\n */\nexport interface ProfileOptions {\n /**\n * Profile name (INI section) to load. If not set, resolves from the\n * DATABRICKS_CONFIG_PROFILE environment variable, then the default_profile\n * key in the __settings__ section, then falls back to the DEFAULT section.\n */\n profile?: string;\n\n /**\n * Path to the databrickscfg file. If not set, reads DATABRICKS_CONFIG_FILE\n * from the environment, falling back to ~/.databrickscfg.\n */\n configFile?: string;\n\n /**\n * Disable reading the config file. Cannot be combined with\n * {@link ProfileOptions.profile} or {@link ProfileOptions.configFile},\n * which would have nothing to read.\n */\n noProfile?: boolean;\n\n /**\n * Disable overlaying DATABRICKS_* environment variables.\n */\n disableEnv?: boolean;\n}\n\n/**\n * Reserved INI section name for SDK settings. It is never treated as a\n * profile.\n */\nexport const SETTINGS_SECTION = '__settings__';\n\n// ---------------------------------------------------------------------------\n// Declarative property mapping\n// ---------------------------------------------------------------------------\n\n/**\n * Maps a {@link Profile} field to its environment variable and INI key,\n * with typed getter and setter closures. This avoids reflection while\n * keeping the mapping declarative, matching the Go SDK's approach.\n */\nexport interface PropertyDef {\n /** The Profile field name this property maps to. */\n readonly field: keyof Profile;\n readonly envVar: string;\n readonly iniKey: string;\n /** Sets the profile field from a raw INI/env string value. */\n readonly set: (profile: Profile, raw: string) => void;\n /** Returns the profile field as a string, or undefined if unset. */\n readonly get: (profile: Profile) => string | undefined;\n}\n\n/**\n * Declarative property mapping table for all known profile fields.\n */\nexport const PROPERTY_DEFS: readonly PropertyDef[] = [\n {\n field: 'host',\n envVar: 'DATABRICKS_HOST',\n iniKey: 'host',\n set: (p: Profile, v: string): void => {\n p.host = v;\n },\n get: (p: Profile): string | undefined => p.host,\n },\n {\n field: 'workspaceId',\n envVar: 'DATABRICKS_WORKSPACE_ID',\n iniKey: 'workspace_id',\n set: (p: Profile, v: string): void => {\n p.workspaceId = v;\n },\n get: (p: Profile): string | undefined => p.workspaceId,\n },\n {\n field: 'accountId',\n envVar: 'DATABRICKS_ACCOUNT_ID',\n iniKey: 'account_id',\n set: (p: Profile, v: string): void => {\n p.accountId = v;\n },\n get: (p: Profile): string | undefined => p.accountId,\n },\n {\n field: 'token',\n envVar: 'DATABRICKS_TOKEN',\n iniKey: 'token',\n set: (p: Profile, v: string): void => {\n p.token = new Secret(v);\n },\n get: (p: Profile): string | undefined => p.token?.value,\n },\n {\n field: 'authType',\n envVar: 'DATABRICKS_AUTH_TYPE',\n iniKey: 'auth_type',\n set: (p: Profile, v: string): void => {\n p.authType = v;\n },\n get: (p: Profile): string | undefined => p.authType,\n },\n {\n field: 'clientId',\n envVar: 'DATABRICKS_CLIENT_ID',\n iniKey: 'client_id',\n set: (p: Profile, v: string): void => {\n p.clientId = v;\n },\n get: (p: Profile): string | undefined => p.clientId,\n },\n {\n field: 'clientSecret',\n envVar: 'DATABRICKS_CLIENT_SECRET',\n iniKey: 'client_secret',\n set: (p: Profile, v: string): void => {\n p.clientSecret = new Secret(v);\n },\n get: (p: Profile): string | undefined => p.clientSecret?.value,\n },\n {\n field: 'databricksCliPath',\n envVar: 'DATABRICKS_CLI_PATH',\n iniKey: 'databricks_cli_path',\n set: (p: Profile, v: string): void => {\n p.databricksCliPath = v;\n },\n get: (p: Profile): string | undefined => p.databricksCliPath,\n },\n];\n"],"mappings":";;;;;;;;;;;;AA2FA,MAAa,mBAAmB;;;;AAyBhC,MAAa,gBAAwC;CACnD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,OAAO;;EAEX,MAAM,MAAmC,EAAE;EAC5C;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,cAAc;;EAElB,MAAM,MAAmC,EAAE;EAC5C;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,YAAY;;EAEhB,MAAM,MAAmC,EAAE;EAC5C;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,QAAQ,IAAI,OAAO,EAAE;;EAEzB,MAAM,MAAmC,EAAE,OAAO;EACnD;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,WAAW;;EAEf,MAAM,MAAmC,EAAE;EAC5C;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,WAAW;;EAEf,MAAM,MAAmC,EAAE;EAC5C;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,eAAe,IAAI,OAAO,EAAE;;EAEhC,MAAM,MAAmC,EAAE,cAAc;EAC1D;CACD;EACE,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,MAAM,GAAY,MAAoB;AACpC,KAAE,oBAAoB;;EAExB,MAAM,MAAmC,EAAE;EAC5C;CACF"}
@@ -1,9 +1,6 @@
1
- /**
2
- * Node.js implementation of profile resolution.
3
- *
4
- * @module
5
- */
6
- import type { Profile, ProfileOptions } from './profile';
1
+ import { Profile, ProfileOptions } from "./profile.js";
2
+
3
+ //#region src/profiles/resolve.d.ts
7
4
  /**
8
5
  * Creates a {@link Profile} from a databrickscfg file and/or environment
9
6
  * variables.
@@ -15,16 +12,18 @@ import type { Profile, ProfileOptions } from './profile';
15
12
  * {@link ProfileOptions.noProfile} and the environment overlay with
16
13
  * {@link ProfileOptions.disableEnv}.
17
14
  */
18
- export declare function resolve(options?: ProfileOptions): Promise<Profile>;
15
+ declare function resolve(options?: ProfileOptions): Promise<Profile>;
19
16
  /**
20
17
  * Returns the path to the default databrickscfg file. Reads
21
18
  * DATABRICKS_CONFIG_FILE from the environment, falling back to
22
19
  * ~/.databrickscfg.
23
20
  */
24
- export declare function defaultConfigFile(): string;
21
+ declare function defaultConfigFile(): string;
25
22
  /**
26
23
  * Returns the names of all profiles (INI sections) in the given config
27
24
  * file. The DEFAULT section is included only if it has keys.
28
25
  */
29
- export declare function listProfiles(path: string): Promise<string[]>;
26
+ declare function listProfiles(path: string): Promise<string[]>;
27
+ //#endregion
28
+ export { defaultConfigFile, listProfiles, resolve };
30
29
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/profiles/resolve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,WAAW,CAAC;AA8JvD;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BxE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA8BlE"}
1
+ {"version":3,"file":"resolve.d.ts","names":[],"sources":["../../src/profiles/resolve.ts"],"mappings":";;;;;;;;;;;;;;iBAqLsB,OAAA,CAAQ,OAAA,GAAU,cAAA,GAAiB,OAAA,CAAQ,OAAA;;;;;AA6CjE;iBAZgB,iBAAA,CAAA;;;;;iBAYM,YAAA,CAAa,IAAA,WAAe,OAAA"}
@@ -1,208 +1,163 @@
1
+ import { ProfileError } from "./errors.js";
2
+ import { parseIni } from "./ini.js";
3
+ import { PROPERTY_DEFS, SETTINGS_SECTION } from "./profile.js";
4
+ import { access, readFile } from "node:fs/promises";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
7
+
8
+ //#region src/profiles/resolve.ts
1
9
  /**
2
- * Node.js implementation of profile resolution.
3
- *
4
- * @module
5
- */
6
- import { access, readFile } from 'node:fs/promises';
7
- import { homedir } from 'node:os';
8
- import { join } from 'node:path';
9
- import { ProfileError } from './errors';
10
- import { parseIni } from './ini';
11
- import { PROPERTY_DEFS, SETTINGS_SECTION } from './profile';
10
+ * Node.js implementation of profile resolution.
11
+ *
12
+ * @module
13
+ */
12
14
  /**
13
- * Reports whether a section is an empty DEFAULT section that should be
14
- * treated as non-existent.
15
- *
16
- * In the INI format, DEFAULT is typically a special fallback section, not a
17
- * regular section. Databricks historically treats DEFAULT as a regular
18
- * profile name. An intentionally empty [DEFAULT] section is silently ignored.
19
- */
15
+ * Reports whether a section is an empty DEFAULT section that should be
16
+ * treated as non-existent.
17
+ *
18
+ * In the INI format, DEFAULT is typically a special fallback section, not a
19
+ * regular section. Databricks historically treats DEFAULT as a regular
20
+ * profile name. An intentionally empty [DEFAULT] section is silently ignored.
21
+ */
20
22
  function isPhantomDefault(name, section) {
21
- return name === 'DEFAULT' && section.size === 0;
23
+ return name === "DEFAULT" && section.size === 0;
22
24
  }
23
25
  /**
24
- * Returns ~/.databrickscfg without checking environment variables.
25
- */
26
+ * Returns ~/.databrickscfg without checking environment variables.
27
+ */
26
28
  function defaultConfigFilePath() {
27
- try {
28
- return join(homedir(), '.databrickscfg');
29
- }
30
- catch {
31
- return '';
32
- }
29
+ try {
30
+ return join(homedir(), ".databrickscfg");
31
+ } catch {
32
+ return "";
33
+ }
33
34
  }
34
35
  /** Returns true if the file at the given path exists. */
35
36
  async function fileExists(path) {
36
- try {
37
- await access(path);
38
- return true;
39
- }
40
- catch {
41
- return false;
42
- }
37
+ try {
38
+ await access(path);
39
+ return true;
40
+ } catch {
41
+ return false;
42
+ }
43
43
  }
44
44
  /**
45
- * Loads a profile from a databrickscfg file. If filePath is undefined,
46
- * reads DATABRICKS_CONFIG_FILE from the environment, falling back to
47
- * ~/.databrickscfg.
48
- */
45
+ * Loads a profile from a databrickscfg file. If filePath is undefined,
46
+ * reads DATABRICKS_CONFIG_FILE from the environment, falling back to
47
+ * ~/.databrickscfg.
48
+ */
49
49
  async function loadFile(filePath, profileName) {
50
- // Determine file path.
51
- let explicitFile = filePath !== undefined;
52
- let path;
53
- if (filePath !== undefined) {
54
- path = filePath;
55
- }
56
- else {
57
- const envPath = process.env.DATABRICKS_CONFIG_FILE ?? '';
58
- if (envPath !== '') {
59
- path = envPath;
60
- explicitFile = true;
61
- }
62
- else {
63
- path = defaultConfigFilePath();
64
- }
65
- }
66
- // A missing default file is silently skipped.
67
- if (!(await fileExists(path))) {
68
- if (explicitFile) {
69
- throw new ProfileError('CONFIG_FILE_NOT_FOUND', `config file not found: ${path}`);
70
- }
71
- return {};
72
- }
73
- const content = await readFile(path, 'utf8');
74
- const data = parseIni(content);
75
- // Profile name resolution chain:
76
- // 1. Explicit profile name (from option).
77
- // 2. DATABRICKS_CONFIG_PROFILE environment variable.
78
- // 3. default_profile key in __settings__ section.
79
- // 4. DEFAULT section (fallback).
80
- let resolved = profileName;
81
- if (resolved === undefined) {
82
- const envProfile = process.env.DATABRICKS_CONFIG_PROFILE ?? '';
83
- if (envProfile !== '') {
84
- resolved = envProfile;
85
- }
86
- }
87
- if (resolved === undefined) {
88
- const settings = data.get(SETTINGS_SECTION);
89
- if (settings !== undefined) {
90
- const dp = settings.get('default_profile') ?? '';
91
- if (dp !== '') {
92
- resolved = dp;
93
- }
94
- }
95
- }
96
- if (resolved === SETTINGS_SECTION) {
97
- throw new ProfileError('INVALID_PROFILE_NAME', `invalid profile name: "${resolved}" is a reserved section`);
98
- }
99
- const explicitProfile = resolved !== undefined;
100
- resolved ??= 'DEFAULT';
101
- const section = data.get(resolved);
102
- if (section === undefined || isPhantomDefault(resolved, section)) {
103
- if (explicitProfile) {
104
- throw new ProfileError('PROFILE_NOT_FOUND', `profile not found: "${resolved}" in ${path}`);
105
- }
106
- return {};
107
- }
108
- // Build profile from section values.
109
- const profile = { name: resolved };
110
- const knownKeys = new Set();
111
- for (const def of PROPERTY_DEFS) {
112
- knownKeys.add(def.iniKey);
113
- const value = section.get(def.iniKey);
114
- if (value !== undefined) {
115
- def.set(profile, value);
116
- }
117
- }
118
- // Collect extra keys that are not in the property mapping.
119
- for (const [key, value] of section) {
120
- if (!knownKeys.has(key)) {
121
- profile.extra ??= {};
122
- profile.extra[key] = value;
123
- }
124
- }
125
- return profile;
50
+ let explicitFile = filePath !== void 0;
51
+ let path;
52
+ if (filePath !== void 0) path = filePath;
53
+ else {
54
+ const envPath = process.env.DATABRICKS_CONFIG_FILE ?? "";
55
+ if (envPath !== "") {
56
+ path = envPath;
57
+ explicitFile = true;
58
+ } else path = defaultConfigFilePath();
59
+ }
60
+ if (!await fileExists(path)) {
61
+ if (explicitFile) throw new ProfileError("CONFIG_FILE_NOT_FOUND", `config file not found: ${path}`);
62
+ return {};
63
+ }
64
+ const data = parseIni(await readFile(path, "utf8"));
65
+ let resolved = profileName;
66
+ if (resolved === void 0) {
67
+ const envProfile = process.env.DATABRICKS_CONFIG_PROFILE ?? "";
68
+ if (envProfile !== "") resolved = envProfile;
69
+ }
70
+ if (resolved === void 0) {
71
+ const settings = data.get(SETTINGS_SECTION);
72
+ if (settings !== void 0) {
73
+ const dp = settings.get("default_profile") ?? "";
74
+ if (dp !== "") resolved = dp;
75
+ }
76
+ }
77
+ if (resolved === SETTINGS_SECTION) throw new ProfileError("INVALID_PROFILE_NAME", `invalid profile name: "${resolved}" is a reserved section`);
78
+ const explicitProfile = resolved !== void 0;
79
+ resolved ??= "DEFAULT";
80
+ const section = data.get(resolved);
81
+ if (section === void 0 || isPhantomDefault(resolved, section)) {
82
+ if (explicitProfile) throw new ProfileError("PROFILE_NOT_FOUND", `profile not found: "${resolved}" in ${path}`);
83
+ return {};
84
+ }
85
+ const profile = { name: resolved };
86
+ const knownKeys = /* @__PURE__ */ new Set();
87
+ for (const def of PROPERTY_DEFS) {
88
+ knownKeys.add(def.iniKey);
89
+ const value = section.get(def.iniKey);
90
+ if (value !== void 0) def.set(profile, value);
91
+ }
92
+ for (const [key, value] of section) if (!knownKeys.has(key)) {
93
+ profile.extra ??= {};
94
+ profile.extra[key] = value;
95
+ }
96
+ return profile;
126
97
  }
127
98
  /**
128
- * Builds a profile from environment variables. Empty environment variables
129
- * are treated as unset. Returns only the fields that were found.
130
- */
99
+ * Builds a profile from environment variables. Empty environment variables
100
+ * are treated as unset. Returns only the fields that were found.
101
+ */
131
102
  function loadEnv() {
132
- const profile = {};
133
- for (const def of PROPERTY_DEFS) {
134
- const value = process.env[def.envVar] ?? '';
135
- if (value !== '') {
136
- def.set(profile, value);
137
- }
138
- }
139
- return profile;
103
+ const profile = {};
104
+ for (const def of PROPERTY_DEFS) {
105
+ const value = process.env[def.envVar] ?? "";
106
+ if (value !== "") def.set(profile, value);
107
+ }
108
+ return profile;
140
109
  }
141
110
  /**
142
- * Creates a {@link Profile} from a databrickscfg file and/or environment
143
- * variables.
144
- *
145
- * Both sources are read by default: the config file is loaded and DATABRICKS_*
146
- * environment variables are overlaid on top (env takes precedence). This holds
147
- * whether or not a specific {@link ProfileOptions.profile} or
148
- * {@link ProfileOptions.configFile} is given. Disable the config file with
149
- * {@link ProfileOptions.noProfile} and the environment overlay with
150
- * {@link ProfileOptions.disableEnv}.
151
- */
152
- export async function resolve(options) {
153
- if (options?.configFile === '') {
154
- throw new ProfileError('EMPTY_PATH', 'empty path');
155
- }
156
- if (options?.profile === '') {
157
- throw new ProfileError('EMPTY_PROFILE', 'empty profile');
158
- }
159
- if (options?.noProfile === true &&
160
- (options.profile !== undefined || options.configFile !== undefined)) {
161
- throw new ProfileError('CONFLICTING_OPTIONS', 'noProfile cannot be combined with profile or configFile');
162
- }
163
- const shouldReadFile = options?.noProfile !== true;
164
- const shouldReadEnv = options?.disableEnv !== true;
165
- const fileProfile = shouldReadFile
166
- ? await loadFile(options?.configFile, options?.profile)
167
- : {};
168
- const envProfile = shouldReadEnv ? loadEnv() : {};
169
- return { ...fileProfile, ...envProfile };
111
+ * Creates a {@link Profile} from a databrickscfg file and/or environment
112
+ * variables.
113
+ *
114
+ * Both sources are read by default: the config file is loaded and DATABRICKS_*
115
+ * environment variables are overlaid on top (env takes precedence). This holds
116
+ * whether or not a specific {@link ProfileOptions.profile} or
117
+ * {@link ProfileOptions.configFile} is given. Disable the config file with
118
+ * {@link ProfileOptions.noProfile} and the environment overlay with
119
+ * {@link ProfileOptions.disableEnv}.
120
+ */
121
+ async function resolve(options) {
122
+ if (options?.configFile === "") throw new ProfileError("EMPTY_PATH", "empty path");
123
+ if (options?.profile === "") throw new ProfileError("EMPTY_PROFILE", "empty profile");
124
+ if (options?.noProfile === true && (options.profile !== void 0 || options.configFile !== void 0)) throw new ProfileError("CONFLICTING_OPTIONS", "noProfile cannot be combined with profile or configFile");
125
+ const shouldReadFile = options?.noProfile !== true;
126
+ const shouldReadEnv = options?.disableEnv !== true;
127
+ const fileProfile = shouldReadFile ? await loadFile(options?.configFile, options?.profile) : {};
128
+ const envProfile = shouldReadEnv ? loadEnv() : {};
129
+ return {
130
+ ...fileProfile,
131
+ ...envProfile
132
+ };
170
133
  }
171
134
  /**
172
- * Returns the path to the default databrickscfg file. Reads
173
- * DATABRICKS_CONFIG_FILE from the environment, falling back to
174
- * ~/.databrickscfg.
175
- */
176
- export function defaultConfigFile() {
177
- const envPath = process.env.DATABRICKS_CONFIG_FILE ?? '';
178
- if (envPath !== '') {
179
- return envPath;
180
- }
181
- return defaultConfigFilePath();
135
+ * Returns the path to the default databrickscfg file. Reads
136
+ * DATABRICKS_CONFIG_FILE from the environment, falling back to
137
+ * ~/.databrickscfg.
138
+ */
139
+ function defaultConfigFile() {
140
+ const envPath = process.env.DATABRICKS_CONFIG_FILE ?? "";
141
+ if (envPath !== "") return envPath;
142
+ return defaultConfigFilePath();
182
143
  }
183
144
  /**
184
- * Returns the names of all profiles (INI sections) in the given config
185
- * file. The DEFAULT section is included only if it has keys.
186
- */
187
- export async function listProfiles(path) {
188
- if (path === '') {
189
- throw new ProfileError('CONFIG_FILE_NOT_FOUND', 'config file not found: empty path');
190
- }
191
- if (!(await fileExists(path))) {
192
- throw new ProfileError('CONFIG_FILE_NOT_FOUND', `config file not found: ${path}`);
193
- }
194
- const content = await readFile(path, 'utf8');
195
- const data = parseIni(content);
196
- const names = [];
197
- for (const [name, keys] of data) {
198
- if (name === SETTINGS_SECTION) {
199
- continue;
200
- }
201
- if (isPhantomDefault(name, keys)) {
202
- continue;
203
- }
204
- names.push(name);
205
- }
206
- return names;
145
+ * Returns the names of all profiles (INI sections) in the given config
146
+ * file. The DEFAULT section is included only if it has keys.
147
+ */
148
+ async function listProfiles(path) {
149
+ if (path === "") throw new ProfileError("CONFIG_FILE_NOT_FOUND", "config file not found: empty path");
150
+ if (!await fileExists(path)) throw new ProfileError("CONFIG_FILE_NOT_FOUND", `config file not found: ${path}`);
151
+ const data = parseIni(await readFile(path, "utf8"));
152
+ const names = [];
153
+ for (const [name, keys] of data) {
154
+ if (name === SETTINGS_SECTION) continue;
155
+ if (isPhantomDefault(name, keys)) continue;
156
+ names.push(name);
157
+ }
158
+ return names;
207
159
  }
160
+
161
+ //#endregion
162
+ export { defaultConfigFile, listProfiles, resolve };
208
163
  //# sourceMappingURL=resolve.js.map