@databricks/sdk-repos 0.0.0-dev → 0.1.0-dev.1
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/LICENSE +203 -0
- package/dist/v1/client.d.ts +33 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +195 -0
- package/dist/v1/client.js.map +1 -0
- package/dist/v1/index.d.ts +3 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +3 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/model.d.ts +165 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +132 -0
- package/dist/v1/model.js.map +1 -0
- package/dist/v1/transport.d.ts +5 -0
- package/dist/v1/transport.d.ts.map +1 -0
- package/dist/v1/transport.js +57 -0
- package/dist/v1/transport.js.map +1 -0
- package/dist/v1/utils.d.ts +22 -0
- package/dist/v1/utils.d.ts.map +1 -0
- package/dist/v1/utils.js +113 -0
- package/dist/v1/utils.js.map +1 -0
- package/package.json +38 -4
- package/src/v1/client.ts +257 -0
- package/src/v1/index.ts +19 -0
- package/src/v1/model.ts +316 -0
- package/src/v1/transport.ts +73 -0
- package/src/v1/utils.ts +156 -0
- package/README.md +0 -1
- package/index.js +0 -1
package/dist/v1/model.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
4
|
+
export const unmarshalCreateRepoRequest_ResponseSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
id: z
|
|
7
|
+
.union([z.number(), z.bigint()])
|
|
8
|
+
.transform(v => BigInt(v))
|
|
9
|
+
.optional(),
|
|
10
|
+
path: z.string().optional(),
|
|
11
|
+
url: z.string().optional(),
|
|
12
|
+
provider: z.string().optional(),
|
|
13
|
+
branch: z.string().optional(),
|
|
14
|
+
head_commit_id: z.string().optional(),
|
|
15
|
+
sparse_checkout: z.lazy(() => unmarshalSparseCheckoutSchema).optional(),
|
|
16
|
+
})
|
|
17
|
+
.transform(d => ({
|
|
18
|
+
id: d.id,
|
|
19
|
+
path: d.path,
|
|
20
|
+
url: d.url,
|
|
21
|
+
provider: d.provider,
|
|
22
|
+
branch: d.branch,
|
|
23
|
+
headCommitId: d.head_commit_id,
|
|
24
|
+
sparseCheckout: d.sparse_checkout,
|
|
25
|
+
}));
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
27
|
+
export const unmarshalDeleteProjectRequest_ResponseSchema = z.object({});
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
29
|
+
export const unmarshalGetRepoRequest_ResponseSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
id: z
|
|
32
|
+
.union([z.number(), z.bigint()])
|
|
33
|
+
.transform(v => BigInt(v))
|
|
34
|
+
.optional(),
|
|
35
|
+
path: z.string().optional(),
|
|
36
|
+
url: z.string().optional(),
|
|
37
|
+
provider: z.string().optional(),
|
|
38
|
+
branch: z.string().optional(),
|
|
39
|
+
head_commit_id: z.string().optional(),
|
|
40
|
+
sparse_checkout: z.lazy(() => unmarshalSparseCheckoutSchema).optional(),
|
|
41
|
+
})
|
|
42
|
+
.transform(d => ({
|
|
43
|
+
id: d.id,
|
|
44
|
+
path: d.path,
|
|
45
|
+
url: d.url,
|
|
46
|
+
provider: d.provider,
|
|
47
|
+
branch: d.branch,
|
|
48
|
+
headCommitId: d.head_commit_id,
|
|
49
|
+
sparseCheckout: d.sparse_checkout,
|
|
50
|
+
}));
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
52
|
+
export const unmarshalListReposRequest_ResponseSchema = z
|
|
53
|
+
.object({
|
|
54
|
+
repos: z.array(z.lazy(() => unmarshalRepoInfoSchema)).optional(),
|
|
55
|
+
next_page_token: z.string().optional(),
|
|
56
|
+
})
|
|
57
|
+
.transform(d => ({
|
|
58
|
+
repos: d.repos,
|
|
59
|
+
nextPageToken: d.next_page_token,
|
|
60
|
+
}));
|
|
61
|
+
export const unmarshalRepoInfoSchema = z
|
|
62
|
+
.object({
|
|
63
|
+
id: z
|
|
64
|
+
.union([z.number(), z.bigint()])
|
|
65
|
+
.transform(v => BigInt(v))
|
|
66
|
+
.optional(),
|
|
67
|
+
path: z.string().optional(),
|
|
68
|
+
url: z.string().optional(),
|
|
69
|
+
provider: z.string().optional(),
|
|
70
|
+
branch: z.string().optional(),
|
|
71
|
+
head_commit_id: z.string().optional(),
|
|
72
|
+
sparse_checkout: z.lazy(() => unmarshalSparseCheckoutSchema).optional(),
|
|
73
|
+
})
|
|
74
|
+
.transform(d => ({
|
|
75
|
+
id: d.id,
|
|
76
|
+
path: d.path,
|
|
77
|
+
url: d.url,
|
|
78
|
+
provider: d.provider,
|
|
79
|
+
branch: d.branch,
|
|
80
|
+
headCommitId: d.head_commit_id,
|
|
81
|
+
sparseCheckout: d.sparse_checkout,
|
|
82
|
+
}));
|
|
83
|
+
export const unmarshalSparseCheckoutSchema = z
|
|
84
|
+
.object({
|
|
85
|
+
patterns: z.array(z.string()).optional(),
|
|
86
|
+
})
|
|
87
|
+
.transform(d => ({
|
|
88
|
+
patterns: d.patterns,
|
|
89
|
+
}));
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
91
|
+
export const unmarshalUpdateRepoRequest_ResponseSchema = z.object({});
|
|
92
|
+
export const marshalCreateRepoRequestSchema = z
|
|
93
|
+
.object({
|
|
94
|
+
url: z.string().optional(),
|
|
95
|
+
provider: z.string().optional(),
|
|
96
|
+
path: z.string().optional(),
|
|
97
|
+
sparseCheckout: z.lazy(() => marshalSparseCheckoutSchema).optional(),
|
|
98
|
+
})
|
|
99
|
+
.transform(d => ({
|
|
100
|
+
url: d.url,
|
|
101
|
+
provider: d.provider,
|
|
102
|
+
path: d.path,
|
|
103
|
+
sparse_checkout: d.sparseCheckout,
|
|
104
|
+
}));
|
|
105
|
+
export const marshalSparseCheckoutSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
patterns: z.array(z.string()).optional(),
|
|
108
|
+
})
|
|
109
|
+
.transform(d => ({
|
|
110
|
+
patterns: d.patterns,
|
|
111
|
+
}));
|
|
112
|
+
export const marshalSparseCheckoutUpdateSchema = z
|
|
113
|
+
.object({
|
|
114
|
+
patterns: z.array(z.string()).optional(),
|
|
115
|
+
})
|
|
116
|
+
.transform(d => ({
|
|
117
|
+
patterns: d.patterns,
|
|
118
|
+
}));
|
|
119
|
+
export const marshalUpdateRepoRequestSchema = z
|
|
120
|
+
.object({
|
|
121
|
+
id: z.bigint().optional(),
|
|
122
|
+
branch: z.string().optional(),
|
|
123
|
+
tag: z.string().optional(),
|
|
124
|
+
sparseCheckout: z.lazy(() => marshalSparseCheckoutUpdateSchema).optional(),
|
|
125
|
+
})
|
|
126
|
+
.transform(d => ({
|
|
127
|
+
id: d.id,
|
|
128
|
+
branch: d.branch,
|
|
129
|
+
tag: d.tag,
|
|
130
|
+
sparse_checkout: d.sparseCheckout,
|
|
131
|
+
}));
|
|
132
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AA0KtB,oGAAoG;AACpG,MAAM,CAAC,MAAM,yCAAyC,GACpD,CAAC;KACE,MAAM,CAAC;IACN,EAAE,EAAE,CAAC;SACF,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;SAC/B,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACzB,QAAQ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,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,iCAAiC,CAAC,CAAC,QAAQ,EAAE;CAC3E,CAAC;KACD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACf,EAAE,EAAE,CAAC,CAAC,EAAE;IACR,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,GAAG,EAAE,CAAC,CAAC,GAAG;IACV,eAAe,EAAE,CAAC,CAAC,cAAc;CAClC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HttpClient } from '@databricks/sdk-core/http';
|
|
2
|
+
import type { ClientOptions } from '@databricks/sdk-options/client';
|
|
3
|
+
/** Creates a new HTTP client with the given options. */
|
|
4
|
+
export declare function newHttpClient(options?: ClientOptions): HttpClient;
|
|
5
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/v1/transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAElE,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,UAAU,CAwBjE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { defaultCredentials } from '@databricks/sdk-auth/credentials';
|
|
3
|
+
import { newFetchHttpClient } from '@databricks/sdk-core/http';
|
|
4
|
+
/** Creates a new HTTP client with the given options. */
|
|
5
|
+
export function newHttpClient(options) {
|
|
6
|
+
const opts = options ?? {};
|
|
7
|
+
// If an HTTP client is provided, use it as-is. Throw if other options are
|
|
8
|
+
// also set, since they would be silently ignored.
|
|
9
|
+
if (opts.httpClient !== undefined) {
|
|
10
|
+
if (opts.credentials !== undefined || opts.timeout !== undefined) {
|
|
11
|
+
throw new Error('httpClient cannot be combined with credentials or timeout');
|
|
12
|
+
}
|
|
13
|
+
return opts.httpClient;
|
|
14
|
+
}
|
|
15
|
+
const credentials = opts.credentials ?? defaultCredentials();
|
|
16
|
+
const base = newFetchHttpClient();
|
|
17
|
+
let client = new AuthHttpClient(base, credentials);
|
|
18
|
+
if (opts.timeout !== undefined) {
|
|
19
|
+
client = new TimeoutHttpClient(client, opts.timeout);
|
|
20
|
+
}
|
|
21
|
+
return client;
|
|
22
|
+
}
|
|
23
|
+
/** Wraps an HttpClient and adds authentication headers to requests. */
|
|
24
|
+
class AuthHttpClient {
|
|
25
|
+
base;
|
|
26
|
+
credentials;
|
|
27
|
+
constructor(base, credentials) {
|
|
28
|
+
this.base = base;
|
|
29
|
+
this.credentials = credentials;
|
|
30
|
+
}
|
|
31
|
+
async send(request) {
|
|
32
|
+
const authHeaders = await this.credentials.authHeaders();
|
|
33
|
+
// Do not modify the original request.
|
|
34
|
+
const headers = new Headers(request.headers);
|
|
35
|
+
for (const h of authHeaders) {
|
|
36
|
+
headers.set(h.key, h.value);
|
|
37
|
+
}
|
|
38
|
+
return this.base.send({ ...request, headers });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Wraps an HttpClient and applies a default timeout to requests. */
|
|
42
|
+
class TimeoutHttpClient {
|
|
43
|
+
base;
|
|
44
|
+
timeout;
|
|
45
|
+
constructor(base, timeout) {
|
|
46
|
+
this.base = base;
|
|
47
|
+
this.timeout = timeout;
|
|
48
|
+
}
|
|
49
|
+
async send(request) {
|
|
50
|
+
const timeoutSignal = AbortSignal.timeout(this.timeout);
|
|
51
|
+
const signal = request.signal !== undefined
|
|
52
|
+
? AbortSignal.any([request.signal, timeoutSignal])
|
|
53
|
+
: timeoutSignal;
|
|
54
|
+
return this.base.send({ ...request, signal });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/v1/transport.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAMpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAG7D,wDAAwD;AACxD,MAAM,UAAU,aAAa,CAAC,OAAuB;IACnD,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC;IAE3B,0EAA0E;IAC1E,kDAAkD;IAClD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACjE,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,kBAAkB,EAAE,CAAC;IAE7D,MAAM,IAAI,GAAG,kBAAkB,EAAE,CAAC;IAClC,IAAI,MAAM,GAAe,IAAI,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAE/D,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,GAAG,IAAI,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uEAAuE;AACvE,MAAM,cAAc;IAEC;IACA;IAFnB,YACmB,IAAgB,EAChB,WAAwB;QADxB,SAAI,GAAJ,IAAI,CAAY;QAChB,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QACzD,sCAAsC;QACtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,OAAO,EAAE,OAAO,EAAC,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,qEAAqE;AACrE,MAAM,iBAAiB;IAEF;IACA;IAFnB,YACmB,IAAgB,EAChB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,KAAK,SAAS;YAC1B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;YAClD,CAAC,CAAC,aAAa,CAAC;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,OAAO,EAAE,MAAM,EAAC,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Call } from '@databricks/sdk-core/api';
|
|
2
|
+
import type { HttpClient, HttpRequest } from '@databricks/sdk-core/http';
|
|
3
|
+
import type { Logger } from '@databricks/sdk-core/logger';
|
|
4
|
+
import type { CallOptions } from '@databricks/sdk-options/call';
|
|
5
|
+
import type { z } from 'zod';
|
|
6
|
+
export interface HttpCallOptions {
|
|
7
|
+
readonly request: HttpRequest;
|
|
8
|
+
readonly httpClient: HttpClient;
|
|
9
|
+
readonly logger: Logger;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Translates public CallOptions to the internal Options shape accepted by
|
|
13
|
+
* execute(). Even though the shapes match today, this isolates the public
|
|
14
|
+
* API from the executor's internal type so they can diverge.
|
|
15
|
+
*/
|
|
16
|
+
export declare function executeCall(call: Call, options?: CallOptions): Promise<void>;
|
|
17
|
+
export declare function executeHttpCall(opts: HttpCallOptions): Promise<Uint8Array>;
|
|
18
|
+
export declare function buildHttpRequest(method: string, url: string, headers: Headers, signal?: AbortSignal, body?: string | ReadableStream<Uint8Array>): HttpRequest;
|
|
19
|
+
export declare function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T;
|
|
20
|
+
export declare function marshalRequest(data: unknown, schema: z.ZodType): string;
|
|
21
|
+
export declare function flattenQueryParams(prefix: string, value: unknown, params: URLSearchParams): void;
|
|
22
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAU,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAEZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAO3B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CASf;AA2BD,wBAAsB,eAAe,CACnC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,UAAU,CAAC,CA2BrB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,GACzC,WAAW,CASb;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAI1E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,MAAM,CAEvE;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,eAAe,GACtB,IAAI,CAuBN"}
|
package/dist/v1/utils.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { execute } from '@databricks/sdk-core/api';
|
|
3
|
+
import { ApiError } from '@databricks/sdk-core/apierror';
|
|
4
|
+
import JSONBig from 'json-bigint';
|
|
5
|
+
// JSON codec that preserves int64 precision. On the way in, large integer
|
|
6
|
+
// literals come back as bigint instead of being rounded to JS Number. On the
|
|
7
|
+
// way out, bigint values are emitted as raw JSON number digits.
|
|
8
|
+
const jsonBigint = JSONBig({ useNativeBigInt: true });
|
|
9
|
+
/**
|
|
10
|
+
* Translates public CallOptions to the internal Options shape accepted by
|
|
11
|
+
* execute(). Even though the shapes match today, this isolates the public
|
|
12
|
+
* API from the executor's internal type so they can diverge.
|
|
13
|
+
*/
|
|
14
|
+
export async function executeCall(call, options) {
|
|
15
|
+
const opts = {
|
|
16
|
+
...(options?.retrier !== undefined && { retrier: options.retrier }),
|
|
17
|
+
...(options?.rateLimiter !== undefined && {
|
|
18
|
+
rateLimiter: options.rateLimiter,
|
|
19
|
+
}),
|
|
20
|
+
...(options?.timeout !== undefined && { timeout: options.timeout }),
|
|
21
|
+
};
|
|
22
|
+
return execute(options?.signal, call, opts);
|
|
23
|
+
}
|
|
24
|
+
async function readAll(body) {
|
|
25
|
+
if (body === null) {
|
|
26
|
+
return new Uint8Array(0);
|
|
27
|
+
}
|
|
28
|
+
const reader = body.getReader();
|
|
29
|
+
const chunks = [];
|
|
30
|
+
for (;;) {
|
|
31
|
+
const { done, value } = await reader.read();
|
|
32
|
+
if (done) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
chunks.push(value);
|
|
36
|
+
}
|
|
37
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
38
|
+
const result = new Uint8Array(totalLength);
|
|
39
|
+
let offset = 0;
|
|
40
|
+
for (const chunk of chunks) {
|
|
41
|
+
result.set(chunk, offset);
|
|
42
|
+
offset += chunk.length;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
export async function executeHttpCall(opts) {
|
|
47
|
+
opts.logger.debug('HTTP request', {
|
|
48
|
+
method: opts.request.method,
|
|
49
|
+
url: opts.request.url,
|
|
50
|
+
});
|
|
51
|
+
let resp;
|
|
52
|
+
try {
|
|
53
|
+
resp = await opts.httpClient.send(opts.request);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
opts.logger.debug('HTTP request failed');
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
59
|
+
const body = await readAll(resp.body);
|
|
60
|
+
opts.logger.debug('HTTP response', {
|
|
61
|
+
statusCode: resp.statusCode,
|
|
62
|
+
body: new TextDecoder().decode(body),
|
|
63
|
+
});
|
|
64
|
+
const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
|
|
65
|
+
if (apiErr !== undefined) {
|
|
66
|
+
throw apiErr;
|
|
67
|
+
}
|
|
68
|
+
return body;
|
|
69
|
+
}
|
|
70
|
+
export function buildHttpRequest(method, url, headers, signal, body) {
|
|
71
|
+
const req = { url, method, headers };
|
|
72
|
+
if (body !== undefined) {
|
|
73
|
+
req.body = body;
|
|
74
|
+
}
|
|
75
|
+
if (signal !== undefined) {
|
|
76
|
+
req.signal = signal;
|
|
77
|
+
}
|
|
78
|
+
return req;
|
|
79
|
+
}
|
|
80
|
+
export function parseResponse(body, schema) {
|
|
81
|
+
const text = new TextDecoder().decode(body);
|
|
82
|
+
const parsed = jsonBigint.parse(text);
|
|
83
|
+
return schema.parse(parsed);
|
|
84
|
+
}
|
|
85
|
+
export function marshalRequest(data, schema) {
|
|
86
|
+
return jsonBigint.stringify(schema.parse(data));
|
|
87
|
+
}
|
|
88
|
+
export function flattenQueryParams(prefix, value, params) {
|
|
89
|
+
if (value === null || value === undefined) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
// arrays of objects are not yet supported
|
|
94
|
+
for (const item of value) {
|
|
95
|
+
params.append(prefix, String(item));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (typeof value === 'object') {
|
|
99
|
+
for (const [key, val] of Object.entries(value)) {
|
|
100
|
+
flattenQueryParams(`${prefix}.${key}`, val, params);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (typeof value === 'string' ||
|
|
104
|
+
typeof value === 'number' ||
|
|
105
|
+
typeof value === 'boolean' ||
|
|
106
|
+
typeof value === 'bigint') {
|
|
107
|
+
params.append(prefix, String(value));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new Error(`Unsupported query parameter type: ${typeof value}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|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C,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,0CAA0C;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/sdk-repos",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.1.0-dev.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./v1": {
|
|
8
|
+
"types": "./dist/v1/index.d.ts",
|
|
9
|
+
"import": "./dist/v1/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -b",
|
|
19
|
+
"lint": "eslint src --ext .ts",
|
|
20
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
21
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
22
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
25
|
+
"test": "echo 'no tests'",
|
|
26
|
+
"test:browser": "echo 'no tests'"
|
|
27
|
+
},
|
|
28
|
+
"author": "Databricks",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@databricks/sdk-auth": ">=0.1.0-dev.2 <1.0.0",
|
|
32
|
+
"@databricks/sdk-core": ">=0.1.0-dev.3 <1.0.0",
|
|
33
|
+
"@databricks/sdk-options": ">=0.1.0-dev.2 <1.0.0",
|
|
34
|
+
"@js-temporal/polyfill": "^0.5.0",
|
|
35
|
+
"json-bigint": "^1.0.0",
|
|
36
|
+
"zod": "^4.3.6"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.0.0"
|
|
40
|
+
}
|
|
7
41
|
}
|
package/src/v1/client.ts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
|
|
4
|
+
import type {Call} from '@databricks/sdk-core/api';
|
|
5
|
+
import {createDefault} from '@databricks/sdk-core/clientinfo';
|
|
6
|
+
import type {Logger} from '@databricks/sdk-core/logger';
|
|
7
|
+
import {NoOpLogger} from '@databricks/sdk-core/logger';
|
|
8
|
+
import type {CallOptions} from '@databricks/sdk-options/call';
|
|
9
|
+
import type {ClientOptions} from '@databricks/sdk-options/client';
|
|
10
|
+
import type {HttpClient} from '@databricks/sdk-core/http';
|
|
11
|
+
import {newHttpClient} from './transport';
|
|
12
|
+
import {
|
|
13
|
+
buildHttpRequest,
|
|
14
|
+
executeCall,
|
|
15
|
+
executeHttpCall,
|
|
16
|
+
marshalRequest,
|
|
17
|
+
parseResponse,
|
|
18
|
+
} from './utils';
|
|
19
|
+
import pkgJson from '../../package.json' with {type: 'json'};
|
|
20
|
+
import type {
|
|
21
|
+
CreateRepoRequest,
|
|
22
|
+
CreateRepoRequest_Response,
|
|
23
|
+
DeleteProjectRequest,
|
|
24
|
+
DeleteProjectRequest_Response,
|
|
25
|
+
GetRepoRequest,
|
|
26
|
+
GetRepoRequest_Response,
|
|
27
|
+
ListReposRequest,
|
|
28
|
+
ListReposRequest_Response,
|
|
29
|
+
RepoInfo,
|
|
30
|
+
UpdateRepoRequest,
|
|
31
|
+
UpdateRepoRequest_Response,
|
|
32
|
+
} from './model';
|
|
33
|
+
import {
|
|
34
|
+
marshalCreateRepoRequestSchema,
|
|
35
|
+
marshalUpdateRepoRequestSchema,
|
|
36
|
+
unmarshalCreateRepoRequest_ResponseSchema,
|
|
37
|
+
unmarshalDeleteProjectRequest_ResponseSchema,
|
|
38
|
+
unmarshalGetRepoRequest_ResponseSchema,
|
|
39
|
+
unmarshalListReposRequest_ResponseSchema,
|
|
40
|
+
unmarshalUpdateRepoRequest_ResponseSchema,
|
|
41
|
+
} from './model';
|
|
42
|
+
|
|
43
|
+
// Package identity segment for this client to be used in the User-Agent header.
|
|
44
|
+
const PACKAGE_SEGMENT = {
|
|
45
|
+
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
46
|
+
value: pkgJson.version,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export class ReposClient {
|
|
50
|
+
private readonly host: string;
|
|
51
|
+
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
52
|
+
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
53
|
+
// request.
|
|
54
|
+
private readonly workspaceId: string | undefined;
|
|
55
|
+
private readonly httpClient: HttpClient;
|
|
56
|
+
private readonly logger: Logger;
|
|
57
|
+
// User-Agent header value. Composed once at construction from
|
|
58
|
+
// createDefault() merged with this package's identity and the active
|
|
59
|
+
// credential's name.
|
|
60
|
+
private readonly userAgent: string;
|
|
61
|
+
|
|
62
|
+
constructor(options: ClientOptions) {
|
|
63
|
+
if (options.host === undefined) {
|
|
64
|
+
throw new Error('Host is required.');
|
|
65
|
+
}
|
|
66
|
+
this.host = options.host.replace(/\/$/, '');
|
|
67
|
+
this.workspaceId = options.workspaceId;
|
|
68
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
69
|
+
const info = createDefault()
|
|
70
|
+
.with(PACKAGE_SEGMENT)
|
|
71
|
+
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
72
|
+
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
73
|
+
this.userAgent = info.toString();
|
|
74
|
+
this.httpClient = newHttpClient(options);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a repo in the workspace and links it to the remote Git repo specified.
|
|
79
|
+
* Note that repos created programmatically must be linked to a remote Git repo, unlike repos
|
|
80
|
+
* created in the browser.
|
|
81
|
+
*/
|
|
82
|
+
async createRepo(
|
|
83
|
+
req: CreateRepoRequest,
|
|
84
|
+
options?: CallOptions
|
|
85
|
+
): Promise<CreateRepoRequest_Response> {
|
|
86
|
+
const url = `${this.host}/api/2.0/repos`;
|
|
87
|
+
const body = marshalRequest(req, marshalCreateRepoRequestSchema);
|
|
88
|
+
let resp: CreateRepoRequest_Response | undefined;
|
|
89
|
+
const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
90
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
91
|
+
if (this.workspaceId !== undefined) {
|
|
92
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
93
|
+
}
|
|
94
|
+
headers.set('User-Agent', this.userAgent);
|
|
95
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
96
|
+
const respBody = await executeHttpCall({
|
|
97
|
+
request: httpReq,
|
|
98
|
+
httpClient: this.httpClient,
|
|
99
|
+
logger: this.logger,
|
|
100
|
+
});
|
|
101
|
+
resp = parseResponse(respBody, unmarshalCreateRepoRequest_ResponseSchema);
|
|
102
|
+
};
|
|
103
|
+
await executeCall(call, options);
|
|
104
|
+
if (resp === undefined) {
|
|
105
|
+
throw new Error('API call completed without a result.');
|
|
106
|
+
}
|
|
107
|
+
return resp;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Deletes the specified repo. */
|
|
111
|
+
async deleteProject(
|
|
112
|
+
req: DeleteProjectRequest,
|
|
113
|
+
options?: CallOptions
|
|
114
|
+
): Promise<DeleteProjectRequest_Response> {
|
|
115
|
+
const url = `${this.host}/api/2.0/repos/${String(req.id ?? '')}`;
|
|
116
|
+
let resp: DeleteProjectRequest_Response | undefined;
|
|
117
|
+
const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
118
|
+
const headers = new Headers();
|
|
119
|
+
if (this.workspaceId !== undefined) {
|
|
120
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
121
|
+
}
|
|
122
|
+
headers.set('User-Agent', this.userAgent);
|
|
123
|
+
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
124
|
+
const respBody = await executeHttpCall({
|
|
125
|
+
request: httpReq,
|
|
126
|
+
httpClient: this.httpClient,
|
|
127
|
+
logger: this.logger,
|
|
128
|
+
});
|
|
129
|
+
resp = parseResponse(
|
|
130
|
+
respBody,
|
|
131
|
+
unmarshalDeleteProjectRequest_ResponseSchema
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
await executeCall(call, options);
|
|
135
|
+
if (resp === undefined) {
|
|
136
|
+
throw new Error('API call completed without a result.');
|
|
137
|
+
}
|
|
138
|
+
return resp;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Returns the repo with the given repo ID. */
|
|
142
|
+
async getRepo(
|
|
143
|
+
req: GetRepoRequest,
|
|
144
|
+
options?: CallOptions
|
|
145
|
+
): Promise<GetRepoRequest_Response> {
|
|
146
|
+
const url = `${this.host}/api/2.0/repos/${String(req.id ?? '')}`;
|
|
147
|
+
let resp: GetRepoRequest_Response | undefined;
|
|
148
|
+
const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
149
|
+
const headers = new Headers();
|
|
150
|
+
if (this.workspaceId !== undefined) {
|
|
151
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
152
|
+
}
|
|
153
|
+
headers.set('User-Agent', this.userAgent);
|
|
154
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
155
|
+
const respBody = await executeHttpCall({
|
|
156
|
+
request: httpReq,
|
|
157
|
+
httpClient: this.httpClient,
|
|
158
|
+
logger: this.logger,
|
|
159
|
+
});
|
|
160
|
+
resp = parseResponse(respBody, unmarshalGetRepoRequest_ResponseSchema);
|
|
161
|
+
};
|
|
162
|
+
await executeCall(call, options);
|
|
163
|
+
if (resp === undefined) {
|
|
164
|
+
throw new Error('API call completed without a result.');
|
|
165
|
+
}
|
|
166
|
+
return resp;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Returns repos that the calling user has Manage permissions on.
|
|
171
|
+
* Use `next_page_token` to iterate through additional pages.
|
|
172
|
+
*/
|
|
173
|
+
async listRepos(
|
|
174
|
+
req: ListReposRequest,
|
|
175
|
+
options?: CallOptions
|
|
176
|
+
): Promise<ListReposRequest_Response> {
|
|
177
|
+
const url = `${this.host}/api/2.0/repos`;
|
|
178
|
+
const params = new URLSearchParams();
|
|
179
|
+
if (req.pathPrefix !== undefined) {
|
|
180
|
+
params.append('path_prefix', req.pathPrefix);
|
|
181
|
+
}
|
|
182
|
+
if (req.nextPageToken !== undefined) {
|
|
183
|
+
params.append('next_page_token', req.nextPageToken);
|
|
184
|
+
}
|
|
185
|
+
const query = params.toString();
|
|
186
|
+
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
187
|
+
let resp: ListReposRequest_Response | undefined;
|
|
188
|
+
const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
189
|
+
const headers = new Headers();
|
|
190
|
+
if (this.workspaceId !== undefined) {
|
|
191
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
192
|
+
}
|
|
193
|
+
headers.set('User-Agent', this.userAgent);
|
|
194
|
+
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
195
|
+
const respBody = await executeHttpCall({
|
|
196
|
+
request: httpReq,
|
|
197
|
+
httpClient: this.httpClient,
|
|
198
|
+
logger: this.logger,
|
|
199
|
+
});
|
|
200
|
+
resp = parseResponse(respBody, unmarshalListReposRequest_ResponseSchema);
|
|
201
|
+
};
|
|
202
|
+
await executeCall(call, options);
|
|
203
|
+
if (resp === undefined) {
|
|
204
|
+
throw new Error('API call completed without a result.');
|
|
205
|
+
}
|
|
206
|
+
return resp;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async *listReposIter(
|
|
210
|
+
req: ListReposRequest,
|
|
211
|
+
options?: CallOptions
|
|
212
|
+
): AsyncGenerator<RepoInfo> {
|
|
213
|
+
const pageReq: ListReposRequest = {...req};
|
|
214
|
+
for (;;) {
|
|
215
|
+
const resp = await this.listRepos(pageReq, options);
|
|
216
|
+
for (const item of resp.repos ?? []) {
|
|
217
|
+
yield item;
|
|
218
|
+
}
|
|
219
|
+
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
pageReq.nextPageToken = resp.nextPageToken;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Updates the repo to a different branch or tag, or updates the repo to the latest commit on
|
|
228
|
+
* the same branch.
|
|
229
|
+
*/
|
|
230
|
+
async updateRepo(
|
|
231
|
+
req: UpdateRepoRequest,
|
|
232
|
+
options?: CallOptions
|
|
233
|
+
): Promise<UpdateRepoRequest_Response> {
|
|
234
|
+
const url = `${this.host}/api/2.0/repos/${String(req.id ?? '')}`;
|
|
235
|
+
const body = marshalRequest(req, marshalUpdateRepoRequestSchema);
|
|
236
|
+
let resp: UpdateRepoRequest_Response | undefined;
|
|
237
|
+
const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
238
|
+
const headers = new Headers({'Content-Type': 'application/json'});
|
|
239
|
+
if (this.workspaceId !== undefined) {
|
|
240
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
241
|
+
}
|
|
242
|
+
headers.set('User-Agent', this.userAgent);
|
|
243
|
+
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
244
|
+
const respBody = await executeHttpCall({
|
|
245
|
+
request: httpReq,
|
|
246
|
+
httpClient: this.httpClient,
|
|
247
|
+
logger: this.logger,
|
|
248
|
+
});
|
|
249
|
+
resp = parseResponse(respBody, unmarshalUpdateRepoRequest_ResponseSchema);
|
|
250
|
+
};
|
|
251
|
+
await executeCall(call, options);
|
|
252
|
+
if (resp === undefined) {
|
|
253
|
+
throw new Error('API call completed without a result.');
|
|
254
|
+
}
|
|
255
|
+
return resp;
|
|
256
|
+
}
|
|
257
|
+
}
|