@databricks/sdk-core 0.1.0-dev.5 → 0.1.0-dev.7
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/dist/apierror/apierror.d.ts +3 -2
- package/dist/apierror/apierror.d.ts.map +1 -1
- package/dist/apierror/apierror.js +18 -59
- package/dist/apierror/apierror.js.map +1 -1
- package/dist/apierror/codes/codes.d.ts +25 -47
- package/dist/apierror/codes/codes.d.ts.map +1 -1
- package/dist/apierror/codes/codes.js +25 -74
- package/dist/apierror/codes/codes.js.map +1 -1
- package/dist/apierror/codes/index.d.ts +1 -1
- package/dist/apierror/codes/index.d.ts.map +1 -1
- package/dist/apierror/codes/index.js +1 -1
- package/dist/apierror/codes/index.js.map +1 -1
- package/dist/clientinfo/agent.d.ts +6 -8
- package/dist/clientinfo/agent.d.ts.map +1 -1
- package/dist/clientinfo/agent.js +31 -18
- package/dist/clientinfo/agent.js.map +1 -1
- package/dist/profiles/errors.d.ts +1 -1
- package/dist/profiles/errors.d.ts.map +1 -1
- package/dist/profiles/errors.js.map +1 -1
- package/dist/profiles/index.browser.d.ts +1 -1
- package/dist/profiles/index.d.ts +1 -1
- package/dist/profiles/profile.d.ts +22 -61
- package/dist/profiles/profile.d.ts.map +1 -1
- package/dist/profiles/profile.js +0 -218
- package/dist/profiles/profile.js.map +1 -1
- package/dist/profiles/resolve.d.ts +8 -7
- package/dist/profiles/resolve.d.ts.map +1 -1
- package/dist/profiles/resolve.js +14 -12
- package/dist/profiles/resolve.js.map +1 -1
- package/package.json +1 -2
- package/src/apierror/apierror.ts +0 -253
- package/src/apierror/codes/codes.ts +0 -189
- package/src/apierror/codes/index.ts +0 -7
- package/src/apierror/details.ts +0 -459
- package/src/apierror/index.ts +0 -24
- package/src/clientinfo/agent.ts +0 -125
- package/src/clientinfo/base.ts +0 -73
- package/src/clientinfo/clientinfo.ts +0 -129
- package/src/clientinfo/default.browser.ts +0 -24
- package/src/clientinfo/default.ts +0 -128
- package/src/clientinfo/index.browser.ts +0 -4
- package/src/clientinfo/index.ts +0 -4
- package/src/http/http.ts +0 -75
- package/src/http/index.ts +0 -8
- package/src/index.ts +0 -5
- package/src/logger/index.ts +0 -8
- package/src/logger/logger.ts +0 -99
- package/src/ops/execute.ts +0 -99
- package/src/ops/index.ts +0 -12
- package/src/ops/limiter.ts +0 -8
- package/src/ops/options.ts +0 -22
- package/src/ops/retrier.ts +0 -108
- package/src/profiles/errors.ts +0 -28
- package/src/profiles/index.browser.ts +0 -10
- package/src/profiles/index.ts +0 -15
- package/src/profiles/ini.ts +0 -126
- package/src/profiles/profile.ts +0 -467
- package/src/profiles/resolve.ts +0 -251
- package/src/profiles/secret.ts +0 -40
- package/src/wkt/fieldmask.ts +0 -89
- package/src/wkt/index.ts +0 -3
- package/src/wkt/value.ts +0 -19
package/src/ops/retrier.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/** Options for configuring a {@link BackoffPolicy}. */
|
|
2
|
-
export interface BackoffPolicyOptions {
|
|
3
|
-
/** Initial delay in milliseconds; defaults to 1000. */
|
|
4
|
-
initial?: number;
|
|
5
|
-
|
|
6
|
-
/** Maximum delay in milliseconds; defaults to 60000. */
|
|
7
|
-
maximum?: number;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Factor by which the delay is multiplied after each retry. The value must
|
|
11
|
-
* be greater or equal to 1. If not, it defaults to 2.
|
|
12
|
-
*/
|
|
13
|
-
factor?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Random number generation, wrapped in an object for testability.
|
|
17
|
-
export const rand = {
|
|
18
|
-
// Returns a random integer in [0, n).
|
|
19
|
-
int(n: number): number {
|
|
20
|
-
return Math.floor(Math.random() * n);
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* BackoffPolicy implements an exponential backoff policy. The delay between
|
|
26
|
-
* retries is randomly computed between 0 and the "exponential delay" as
|
|
27
|
-
* recommended in [Exponential Backoff And Jitter]. The retry delay starts from
|
|
28
|
-
* initial and grows exponentially by factor at every retry. The maximum retry
|
|
29
|
-
* delay is capped by maximum.
|
|
30
|
-
*
|
|
31
|
-
* There is no parameter to limit the number of retries. This is intended as
|
|
32
|
-
* such logic should be implemented upstream (e.g. in a Retrier).
|
|
33
|
-
*
|
|
34
|
-
* [Exponential Backoff And Jitter]: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
35
|
-
*/
|
|
36
|
-
export class BackoffPolicy {
|
|
37
|
-
/** Initial delay in milliseconds. */
|
|
38
|
-
readonly initial: number;
|
|
39
|
-
|
|
40
|
-
/** Maximum delay in milliseconds. */
|
|
41
|
-
readonly maximum: number;
|
|
42
|
-
|
|
43
|
-
/** Factor by which the delay is multiplied after each retry. */
|
|
44
|
-
readonly factor: number;
|
|
45
|
-
|
|
46
|
-
// Current delay before the next retry.
|
|
47
|
-
private current: number;
|
|
48
|
-
|
|
49
|
-
constructor(options?: BackoffPolicyOptions) {
|
|
50
|
-
let initial = options?.initial ?? 1000; // Default initial delay of 1 second.
|
|
51
|
-
const maximum = options?.maximum ?? 60000; // Default maximum delay of 60 seconds.
|
|
52
|
-
|
|
53
|
-
if (initial > maximum) {
|
|
54
|
-
// Initial cannot be greater than maximum.
|
|
55
|
-
initial = maximum;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this.initial = initial;
|
|
59
|
-
this.maximum = maximum;
|
|
60
|
-
this.factor =
|
|
61
|
-
options?.factor !== undefined && options.factor >= 1 ? options.factor : 2;
|
|
62
|
-
this.current = this.initial;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Returns a random delay in [0, current] and grows the current delay. */
|
|
66
|
-
delay(): number {
|
|
67
|
-
// Random duration in the range [0, this.current].
|
|
68
|
-
const d = rand.int(this.current + 1);
|
|
69
|
-
|
|
70
|
-
// Grow delay for the next call.
|
|
71
|
-
this.current = Math.min(this.current * this.factor, this.maximum);
|
|
72
|
-
|
|
73
|
-
return d;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Retrier defines a retry behavior. */
|
|
78
|
-
export interface Retrier {
|
|
79
|
-
/**
|
|
80
|
-
* Returns the delay in milliseconds before the next retry, or undefined if
|
|
81
|
-
* the error is not retriable. Implementations should assume that the given
|
|
82
|
-
* error is never undefined.
|
|
83
|
-
*/
|
|
84
|
-
isRetriable(err: Error): number | undefined;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Returns a Retrier that retries based on the isRetriable predicate and relies
|
|
89
|
-
* on an internal backoff policy to decide how long to wait between retries.
|
|
90
|
-
*
|
|
91
|
-
* Important: the retrier has its own backoff policy which cannot be trivially
|
|
92
|
-
* reset by design. Users who need to reset the backoff policy should rather
|
|
93
|
-
* create a new retrier.
|
|
94
|
-
*/
|
|
95
|
-
export function retryOn(
|
|
96
|
-
options: BackoffPolicyOptions,
|
|
97
|
-
isRetriable: (err: Error) => boolean
|
|
98
|
-
): Retrier {
|
|
99
|
-
const bp = new BackoffPolicy(options);
|
|
100
|
-
return {
|
|
101
|
-
isRetriable(err: Error): number | undefined {
|
|
102
|
-
if (!isRetriable(err)) {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
return bp.delay();
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
package/src/profiles/errors.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error types for Databricks configuration profile operations.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Discriminant codes for {@link ProfileError}. */
|
|
8
|
-
export type ProfileErrorCode =
|
|
9
|
-
| 'CONFIG_FILE_NOT_FOUND'
|
|
10
|
-
| 'PROFILE_NOT_FOUND'
|
|
11
|
-
| 'EMPTY_PATH'
|
|
12
|
-
| 'EMPTY_PROFILE'
|
|
13
|
-
| 'INVALID_PROFILE_NAME';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Error thrown by profile operations.
|
|
17
|
-
*
|
|
18
|
-
* Use the {@link ProfileError.code} field to distinguish between error causes.
|
|
19
|
-
*/
|
|
20
|
-
export class ProfileError extends Error {
|
|
21
|
-
readonly code: ProfileErrorCode;
|
|
22
|
-
|
|
23
|
-
constructor(code: ProfileErrorCode, message: string) {
|
|
24
|
-
super(message);
|
|
25
|
-
this.name = 'ProfileError';
|
|
26
|
-
this.code = code;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser entry point for the profiles module.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export {ProfileError} from './errors';
|
|
8
|
-
export type {ProfileErrorCode} from './errors';
|
|
9
|
-
export type {Profile, ResolveOptions} from './profile';
|
|
10
|
-
export {Secret} from './secret';
|
package/src/profiles/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility to resolve Databricks configuration profiles.
|
|
3
|
-
*
|
|
4
|
-
* A profile is a named collection of configuration values. It is typically
|
|
5
|
-
* stored in a file called ~/.databrickscfg. Profiles can be resolved from the
|
|
6
|
-
* file and/or environment variables using the {@link resolve} function.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export {ProfileError} from './errors';
|
|
12
|
-
export type {ProfileErrorCode} from './errors';
|
|
13
|
-
export type {Profile, ResolveOptions} from './profile';
|
|
14
|
-
export {defaultConfigFile, listProfiles, resolve} from './resolve';
|
|
15
|
-
export {Secret} from './secret';
|
package/src/profiles/ini.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal INI parser and writer for the Databricks config file format.
|
|
3
|
-
*
|
|
4
|
-
* This matches the behavior of {@link https://pkg.go.dev/gopkg.in/ini.v1 | go-ini}
|
|
5
|
-
* with `SpaceBeforeInlineComment: true`, which is how the Go SDK loads
|
|
6
|
-
* databrickscfg files. Key behavioral details:
|
|
7
|
-
*
|
|
8
|
-
* - Inline comments are only recognized when `#` or `;` is preceded by a
|
|
9
|
-
* space. The parser checks for `" #"` first; only if absent does it check
|
|
10
|
-
* for `" ;"`. This matches Go's `strings.Index` precedence.
|
|
11
|
-
* - Both `=` and `:` are key-value delimiters (Go default). Only the first
|
|
12
|
-
* delimiter on a line splits key from value.
|
|
13
|
-
* - Section names are the raw text between `[` and the last `]` on the line,
|
|
14
|
-
* with no trimming.
|
|
15
|
-
* - Keys and values are trimmed of surrounding whitespace.
|
|
16
|
-
* - Lines without a delimiter throw an error (matching go-ini default).
|
|
17
|
-
*
|
|
18
|
-
* @module
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/** Parsed INI data as an ordered map of section names to key-value maps. */
|
|
22
|
-
export type IniData = Map<string, Map<string, string>>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Parses an INI-formatted string into structured data.
|
|
26
|
-
*
|
|
27
|
-
* Keys before any section header are assigned to the "DEFAULT" section.
|
|
28
|
-
*/
|
|
29
|
-
export function parseIni(content: string): IniData {
|
|
30
|
-
const result: IniData = new Map();
|
|
31
|
-
let currentSection = 'DEFAULT';
|
|
32
|
-
result.set(currentSection, new Map());
|
|
33
|
-
|
|
34
|
-
for (const rawLine of content.split(/\r?\n/)) {
|
|
35
|
-
const line = rawLine.trim();
|
|
36
|
-
|
|
37
|
-
// Skip empty lines and full-line comments.
|
|
38
|
-
if (line === '' || line.startsWith('#') || line.startsWith(';')) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Section header: text between '[' and the last ']'.
|
|
43
|
-
if (line.startsWith('[')) {
|
|
44
|
-
const closeIdx = line.lastIndexOf(']');
|
|
45
|
-
if (closeIdx === -1) {
|
|
46
|
-
throw new Error(`unclosed section: ${line}`);
|
|
47
|
-
}
|
|
48
|
-
const name = line.slice(1, closeIdx);
|
|
49
|
-
if (name === '') {
|
|
50
|
-
throw new Error('empty section name');
|
|
51
|
-
}
|
|
52
|
-
currentSection = name;
|
|
53
|
-
if (!result.has(currentSection)) {
|
|
54
|
-
result.set(currentSection, new Map());
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Key-value pair: first '=' or ':' splits key from value.
|
|
60
|
-
const eqIdx = line.indexOf('=');
|
|
61
|
-
const colonIdx = line.indexOf(':');
|
|
62
|
-
let delimIdx: number;
|
|
63
|
-
if (eqIdx === -1 && colonIdx === -1) {
|
|
64
|
-
throw new Error(`key-value delimiter not found: ${line}`);
|
|
65
|
-
} else if (eqIdx === -1) {
|
|
66
|
-
delimIdx = colonIdx;
|
|
67
|
-
} else if (colonIdx === -1) {
|
|
68
|
-
delimIdx = eqIdx;
|
|
69
|
-
} else {
|
|
70
|
-
delimIdx = Math.min(eqIdx, colonIdx);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const key = line.slice(0, delimIdx).trim();
|
|
74
|
-
if (key === '') {
|
|
75
|
-
throw new Error(`empty key name: ${line}`);
|
|
76
|
-
}
|
|
77
|
-
let value = line.slice(delimIdx + 1).trim();
|
|
78
|
-
|
|
79
|
-
// Strip inline comments matching go-ini's SpaceBeforeInlineComment
|
|
80
|
-
// precedence: try " #" first, then " ;" only if " #" is absent.
|
|
81
|
-
let commentIdx = value.indexOf(' #');
|
|
82
|
-
if (commentIdx === -1) {
|
|
83
|
-
commentIdx = value.indexOf(' ;');
|
|
84
|
-
}
|
|
85
|
-
if (commentIdx !== -1) {
|
|
86
|
-
value = value.slice(0, commentIdx).trimEnd();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!result.has(currentSection)) {
|
|
90
|
-
result.set(currentSection, new Map());
|
|
91
|
-
}
|
|
92
|
-
const section = result.get(currentSection);
|
|
93
|
-
if (section !== undefined) {
|
|
94
|
-
section.set(key, value);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Formats structured INI data back into a string.
|
|
103
|
-
*
|
|
104
|
-
* Each section's keys are aligned so that all `=` signs appear in the same
|
|
105
|
-
* column, matching the output format of go-ini's `PrettyFormat` default.
|
|
106
|
-
* Sections are separated by blank lines (`PrettySection` default).
|
|
107
|
-
*/
|
|
108
|
-
export function formatIni(data: IniData): string {
|
|
109
|
-
const sections: string[] = [];
|
|
110
|
-
|
|
111
|
-
for (const [name, keys] of data) {
|
|
112
|
-
const lines: string[] = [];
|
|
113
|
-
lines.push(`[${name}]`);
|
|
114
|
-
|
|
115
|
-
if (keys.size > 0) {
|
|
116
|
-
const maxKeyLen = Math.max(...[...keys.keys()].map(k => k.length));
|
|
117
|
-
for (const [key, value] of keys) {
|
|
118
|
-
lines.push(`${key.padEnd(maxKeyLen)} = ${value}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
sections.push(lines.join('\n'));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return sections.join('\n\n') + '\n';
|
|
126
|
-
}
|