@dbx-tools/databricks 0.6.182 → 0.6.183
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 +4 -22
- package/index.ts +1 -2
- package/lib/index.d.ts +15 -0
- package/lib/index.js +15 -1033
- package/lib/src/cloud.d.ts +80 -0
- package/lib/src/cloud.js +240 -0
- package/lib/src/databricks-fs.d.ts +93 -0
- package/lib/src/databricks-fs.js +327 -0
- package/lib/src/databricks-path.d.ts +67 -0
- package/lib/src/databricks-path.js +113 -0
- package/lib/src/net.d.ts +29 -0
- package/lib/src/net.js +68 -0
- package/lib/src/workspace.d.ts +43 -0
- package/lib/src/workspace.js +110 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +38 -20
- package/src/_bindings-ffi.ts +0 -396
- package/src/_bindings.ts +0 -102
- package/src/bindings.ts +0 -11
package/lib/index.js
CHANGED
|
@@ -1,1033 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/_bindings-ffi.ts
|
|
17
|
-
import lib from "@ubjs/node";
|
|
18
|
-
var { UniffiNativeModule, FfiType, resolveLibPath } = lib;
|
|
19
|
-
var DEFINITIONS = {
|
|
20
|
-
symbols: {
|
|
21
|
-
rustbuffer_alloc: "ffi_dbx_tools_databricks_rustbuffer_alloc",
|
|
22
|
-
rustbuffer_free: "ffi_dbx_tools_databricks_rustbuffer_free",
|
|
23
|
-
rustbuffer_from_bytes: "ffi_dbx_tools_databricks_rustbuffer_from_bytes"
|
|
24
|
-
},
|
|
25
|
-
functions: {
|
|
26
|
-
ffi_dbx_tools_databricks_rust_future_poll_u8: {
|
|
27
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
28
|
-
ret: FfiType.Void,
|
|
29
|
-
hasRustCallStatus: false
|
|
30
|
-
},
|
|
31
|
-
ffi_dbx_tools_databricks_rust_future_cancel_u8: {
|
|
32
|
-
args: [FfiType.Handle],
|
|
33
|
-
ret: FfiType.Void,
|
|
34
|
-
hasRustCallStatus: false
|
|
35
|
-
},
|
|
36
|
-
ffi_dbx_tools_databricks_rust_future_complete_u8: {
|
|
37
|
-
args: [FfiType.Handle],
|
|
38
|
-
ret: FfiType.UInt8,
|
|
39
|
-
hasRustCallStatus: true
|
|
40
|
-
},
|
|
41
|
-
ffi_dbx_tools_databricks_rust_future_free_u8: {
|
|
42
|
-
args: [FfiType.Handle],
|
|
43
|
-
ret: FfiType.Void,
|
|
44
|
-
hasRustCallStatus: false
|
|
45
|
-
},
|
|
46
|
-
ffi_dbx_tools_databricks_rust_future_poll_i8: {
|
|
47
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
48
|
-
ret: FfiType.Void,
|
|
49
|
-
hasRustCallStatus: false
|
|
50
|
-
},
|
|
51
|
-
ffi_dbx_tools_databricks_rust_future_cancel_i8: {
|
|
52
|
-
args: [FfiType.Handle],
|
|
53
|
-
ret: FfiType.Void,
|
|
54
|
-
hasRustCallStatus: false
|
|
55
|
-
},
|
|
56
|
-
ffi_dbx_tools_databricks_rust_future_complete_i8: {
|
|
57
|
-
args: [FfiType.Handle],
|
|
58
|
-
ret: FfiType.Int8,
|
|
59
|
-
hasRustCallStatus: true
|
|
60
|
-
},
|
|
61
|
-
ffi_dbx_tools_databricks_rust_future_free_i8: {
|
|
62
|
-
args: [FfiType.Handle],
|
|
63
|
-
ret: FfiType.Void,
|
|
64
|
-
hasRustCallStatus: false
|
|
65
|
-
},
|
|
66
|
-
ffi_dbx_tools_databricks_rust_future_poll_u16: {
|
|
67
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
68
|
-
ret: FfiType.Void,
|
|
69
|
-
hasRustCallStatus: false
|
|
70
|
-
},
|
|
71
|
-
ffi_dbx_tools_databricks_rust_future_cancel_u16: {
|
|
72
|
-
args: [FfiType.Handle],
|
|
73
|
-
ret: FfiType.Void,
|
|
74
|
-
hasRustCallStatus: false
|
|
75
|
-
},
|
|
76
|
-
ffi_dbx_tools_databricks_rust_future_complete_u16: {
|
|
77
|
-
args: [FfiType.Handle],
|
|
78
|
-
ret: FfiType.UInt16,
|
|
79
|
-
hasRustCallStatus: true
|
|
80
|
-
},
|
|
81
|
-
ffi_dbx_tools_databricks_rust_future_free_u16: {
|
|
82
|
-
args: [FfiType.Handle],
|
|
83
|
-
ret: FfiType.Void,
|
|
84
|
-
hasRustCallStatus: false
|
|
85
|
-
},
|
|
86
|
-
ffi_dbx_tools_databricks_rust_future_poll_i16: {
|
|
87
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
88
|
-
ret: FfiType.Void,
|
|
89
|
-
hasRustCallStatus: false
|
|
90
|
-
},
|
|
91
|
-
ffi_dbx_tools_databricks_rust_future_cancel_i16: {
|
|
92
|
-
args: [FfiType.Handle],
|
|
93
|
-
ret: FfiType.Void,
|
|
94
|
-
hasRustCallStatus: false
|
|
95
|
-
},
|
|
96
|
-
ffi_dbx_tools_databricks_rust_future_complete_i16: {
|
|
97
|
-
args: [FfiType.Handle],
|
|
98
|
-
ret: FfiType.Int16,
|
|
99
|
-
hasRustCallStatus: true
|
|
100
|
-
},
|
|
101
|
-
ffi_dbx_tools_databricks_rust_future_free_i16: {
|
|
102
|
-
args: [FfiType.Handle],
|
|
103
|
-
ret: FfiType.Void,
|
|
104
|
-
hasRustCallStatus: false
|
|
105
|
-
},
|
|
106
|
-
ffi_dbx_tools_databricks_rust_future_poll_u32: {
|
|
107
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
108
|
-
ret: FfiType.Void,
|
|
109
|
-
hasRustCallStatus: false
|
|
110
|
-
},
|
|
111
|
-
ffi_dbx_tools_databricks_rust_future_cancel_u32: {
|
|
112
|
-
args: [FfiType.Handle],
|
|
113
|
-
ret: FfiType.Void,
|
|
114
|
-
hasRustCallStatus: false
|
|
115
|
-
},
|
|
116
|
-
ffi_dbx_tools_databricks_rust_future_complete_u32: {
|
|
117
|
-
args: [FfiType.Handle],
|
|
118
|
-
ret: FfiType.UInt32,
|
|
119
|
-
hasRustCallStatus: true
|
|
120
|
-
},
|
|
121
|
-
ffi_dbx_tools_databricks_rust_future_free_u32: {
|
|
122
|
-
args: [FfiType.Handle],
|
|
123
|
-
ret: FfiType.Void,
|
|
124
|
-
hasRustCallStatus: false
|
|
125
|
-
},
|
|
126
|
-
ffi_dbx_tools_databricks_rust_future_poll_i32: {
|
|
127
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
128
|
-
ret: FfiType.Void,
|
|
129
|
-
hasRustCallStatus: false
|
|
130
|
-
},
|
|
131
|
-
ffi_dbx_tools_databricks_rust_future_cancel_i32: {
|
|
132
|
-
args: [FfiType.Handle],
|
|
133
|
-
ret: FfiType.Void,
|
|
134
|
-
hasRustCallStatus: false
|
|
135
|
-
},
|
|
136
|
-
ffi_dbx_tools_databricks_rust_future_complete_i32: {
|
|
137
|
-
args: [FfiType.Handle],
|
|
138
|
-
ret: FfiType.Int32,
|
|
139
|
-
hasRustCallStatus: true
|
|
140
|
-
},
|
|
141
|
-
ffi_dbx_tools_databricks_rust_future_free_i32: {
|
|
142
|
-
args: [FfiType.Handle],
|
|
143
|
-
ret: FfiType.Void,
|
|
144
|
-
hasRustCallStatus: false
|
|
145
|
-
},
|
|
146
|
-
ffi_dbx_tools_databricks_rust_future_poll_u64: {
|
|
147
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
148
|
-
ret: FfiType.Void,
|
|
149
|
-
hasRustCallStatus: false
|
|
150
|
-
},
|
|
151
|
-
ffi_dbx_tools_databricks_rust_future_cancel_u64: {
|
|
152
|
-
args: [FfiType.Handle],
|
|
153
|
-
ret: FfiType.Void,
|
|
154
|
-
hasRustCallStatus: false
|
|
155
|
-
},
|
|
156
|
-
ffi_dbx_tools_databricks_rust_future_complete_u64: {
|
|
157
|
-
args: [FfiType.Handle],
|
|
158
|
-
ret: FfiType.Handle,
|
|
159
|
-
hasRustCallStatus: true
|
|
160
|
-
},
|
|
161
|
-
ffi_dbx_tools_databricks_rust_future_free_u64: {
|
|
162
|
-
args: [FfiType.Handle],
|
|
163
|
-
ret: FfiType.Void,
|
|
164
|
-
hasRustCallStatus: false
|
|
165
|
-
},
|
|
166
|
-
ffi_dbx_tools_databricks_rust_future_poll_i64: {
|
|
167
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
168
|
-
ret: FfiType.Void,
|
|
169
|
-
hasRustCallStatus: false
|
|
170
|
-
},
|
|
171
|
-
ffi_dbx_tools_databricks_rust_future_cancel_i64: {
|
|
172
|
-
args: [FfiType.Handle],
|
|
173
|
-
ret: FfiType.Void,
|
|
174
|
-
hasRustCallStatus: false
|
|
175
|
-
},
|
|
176
|
-
ffi_dbx_tools_databricks_rust_future_complete_i64: {
|
|
177
|
-
args: [FfiType.Handle],
|
|
178
|
-
ret: FfiType.Int64,
|
|
179
|
-
hasRustCallStatus: true
|
|
180
|
-
},
|
|
181
|
-
ffi_dbx_tools_databricks_rust_future_free_i64: {
|
|
182
|
-
args: [FfiType.Handle],
|
|
183
|
-
ret: FfiType.Void,
|
|
184
|
-
hasRustCallStatus: false
|
|
185
|
-
},
|
|
186
|
-
ffi_dbx_tools_databricks_rust_future_poll_f32: {
|
|
187
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
188
|
-
ret: FfiType.Void,
|
|
189
|
-
hasRustCallStatus: false
|
|
190
|
-
},
|
|
191
|
-
ffi_dbx_tools_databricks_rust_future_cancel_f32: {
|
|
192
|
-
args: [FfiType.Handle],
|
|
193
|
-
ret: FfiType.Void,
|
|
194
|
-
hasRustCallStatus: false
|
|
195
|
-
},
|
|
196
|
-
ffi_dbx_tools_databricks_rust_future_complete_f32: {
|
|
197
|
-
args: [FfiType.Handle],
|
|
198
|
-
ret: FfiType.Float32,
|
|
199
|
-
hasRustCallStatus: true
|
|
200
|
-
},
|
|
201
|
-
ffi_dbx_tools_databricks_rust_future_free_f32: {
|
|
202
|
-
args: [FfiType.Handle],
|
|
203
|
-
ret: FfiType.Void,
|
|
204
|
-
hasRustCallStatus: false
|
|
205
|
-
},
|
|
206
|
-
ffi_dbx_tools_databricks_rust_future_poll_f64: {
|
|
207
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
208
|
-
ret: FfiType.Void,
|
|
209
|
-
hasRustCallStatus: false
|
|
210
|
-
},
|
|
211
|
-
ffi_dbx_tools_databricks_rust_future_cancel_f64: {
|
|
212
|
-
args: [FfiType.Handle],
|
|
213
|
-
ret: FfiType.Void,
|
|
214
|
-
hasRustCallStatus: false
|
|
215
|
-
},
|
|
216
|
-
ffi_dbx_tools_databricks_rust_future_complete_f64: {
|
|
217
|
-
args: [FfiType.Handle],
|
|
218
|
-
ret: FfiType.Float64,
|
|
219
|
-
hasRustCallStatus: true
|
|
220
|
-
},
|
|
221
|
-
ffi_dbx_tools_databricks_rust_future_free_f64: {
|
|
222
|
-
args: [FfiType.Handle],
|
|
223
|
-
ret: FfiType.Void,
|
|
224
|
-
hasRustCallStatus: false
|
|
225
|
-
},
|
|
226
|
-
ffi_dbx_tools_databricks_rust_future_poll_rust_buffer: {
|
|
227
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
228
|
-
ret: FfiType.Void,
|
|
229
|
-
hasRustCallStatus: false
|
|
230
|
-
},
|
|
231
|
-
ffi_dbx_tools_databricks_rust_future_cancel_rust_buffer: {
|
|
232
|
-
args: [FfiType.Handle],
|
|
233
|
-
ret: FfiType.Void,
|
|
234
|
-
hasRustCallStatus: false
|
|
235
|
-
},
|
|
236
|
-
ffi_dbx_tools_databricks_rust_future_complete_rust_buffer: {
|
|
237
|
-
args: [FfiType.Handle],
|
|
238
|
-
ret: FfiType.RustBuffer,
|
|
239
|
-
hasRustCallStatus: true
|
|
240
|
-
},
|
|
241
|
-
ffi_dbx_tools_databricks_rust_future_free_rust_buffer: {
|
|
242
|
-
args: [FfiType.Handle],
|
|
243
|
-
ret: FfiType.Void,
|
|
244
|
-
hasRustCallStatus: false
|
|
245
|
-
},
|
|
246
|
-
ffi_dbx_tools_databricks_rust_future_poll_void: {
|
|
247
|
-
args: [FfiType.Handle, FfiType.Callback("RustFutureContinuationCallback"), FfiType.Handle],
|
|
248
|
-
ret: FfiType.Void,
|
|
249
|
-
hasRustCallStatus: false
|
|
250
|
-
},
|
|
251
|
-
ffi_dbx_tools_databricks_rust_future_cancel_void: {
|
|
252
|
-
args: [FfiType.Handle],
|
|
253
|
-
ret: FfiType.Void,
|
|
254
|
-
hasRustCallStatus: false
|
|
255
|
-
},
|
|
256
|
-
ffi_dbx_tools_databricks_rust_future_complete_void: {
|
|
257
|
-
args: [FfiType.Handle],
|
|
258
|
-
ret: FfiType.Void,
|
|
259
|
-
hasRustCallStatus: true
|
|
260
|
-
},
|
|
261
|
-
ffi_dbx_tools_databricks_rust_future_free_void: {
|
|
262
|
-
args: [FfiType.Handle],
|
|
263
|
-
ret: FfiType.Void,
|
|
264
|
-
hasRustCallStatus: false
|
|
265
|
-
},
|
|
266
|
-
uniffi_dbx_tools_databricks_fn_func_databricks_cli_available: {
|
|
267
|
-
args: [],
|
|
268
|
-
ret: FfiType.Int8,
|
|
269
|
-
hasRustCallStatus: true
|
|
270
|
-
},
|
|
271
|
-
uniffi_dbx_tools_databricks_fn_func_is_databricks_app: {
|
|
272
|
-
args: [],
|
|
273
|
-
ret: FfiType.Int8,
|
|
274
|
-
hasRustCallStatus: true
|
|
275
|
-
},
|
|
276
|
-
ffi_dbx_tools_databricks_uniffi_contract_version: {
|
|
277
|
-
args: [],
|
|
278
|
-
ret: FfiType.UInt32,
|
|
279
|
-
hasRustCallStatus: false
|
|
280
|
-
},
|
|
281
|
-
uniffi_dbx_tools_databricks_checksum_func_databricks_cli_available: {
|
|
282
|
-
args: [],
|
|
283
|
-
ret: FfiType.UInt16,
|
|
284
|
-
hasRustCallStatus: false
|
|
285
|
-
},
|
|
286
|
-
uniffi_dbx_tools_databricks_checksum_func_is_databricks_app: {
|
|
287
|
-
args: [],
|
|
288
|
-
ret: FfiType.UInt16,
|
|
289
|
-
hasRustCallStatus: false
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
callbacks: {
|
|
293
|
-
RustFutureContinuationCallback: {
|
|
294
|
-
args: [FfiType.Handle, FfiType.Int8],
|
|
295
|
-
ret: FfiType.Void,
|
|
296
|
-
hasRustCallStatus: false
|
|
297
|
-
},
|
|
298
|
-
ForeignFutureDroppedCallback: {
|
|
299
|
-
args: [FfiType.Handle],
|
|
300
|
-
ret: FfiType.Void,
|
|
301
|
-
hasRustCallStatus: false
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
structs: {
|
|
305
|
-
ForeignFutureDroppedCallbackStruct: [
|
|
306
|
-
{ name: "handle", type: FfiType.Handle },
|
|
307
|
-
{ name: "free", type: FfiType.Callback("ForeignFutureDroppedCallback") }
|
|
308
|
-
]
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
var _nativeModule;
|
|
312
|
-
var getter = () => {
|
|
313
|
-
if (!_nativeModule) {
|
|
314
|
-
const libPath = resolveLibPath({
|
|
315
|
-
crateName: "dbx_tools_databricks",
|
|
316
|
-
callerUrl: import.meta.url,
|
|
317
|
-
npmPackageBase: "@dbx-tools/databricks-",
|
|
318
|
-
tripleStyle: "node"
|
|
319
|
-
});
|
|
320
|
-
const mod_ = UniffiNativeModule.open(libPath);
|
|
321
|
-
_nativeModule = mod_.register(DEFINITIONS);
|
|
322
|
-
}
|
|
323
|
-
return _nativeModule;
|
|
324
|
-
};
|
|
325
|
-
var _bindings_ffi_default = getter;
|
|
326
|
-
|
|
327
|
-
// src/_bindings.ts
|
|
328
|
-
import {
|
|
329
|
-
FfiConverterBool,
|
|
330
|
-
UniffiInternalError,
|
|
331
|
-
UniffiRustCaller,
|
|
332
|
-
uniffiCreateFfiConverterString
|
|
333
|
-
} from "@ubjs/core";
|
|
334
|
-
var uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
|
|
335
|
-
var uniffiIsDebug = typeof process !== "object" || process?.env?.NODE_ENV !== "production" || false;
|
|
336
|
-
function databricksCliAvailable() {
|
|
337
|
-
return FfiConverterBool.lift(uniffiCaller.rustCall((callStatus) => {
|
|
338
|
-
return _bindings_ffi_default().uniffi_dbx_tools_databricks_fn_func_databricks_cli_available(callStatus);
|
|
339
|
-
}, FfiConverterString.lift.bind(FfiConverterString)));
|
|
340
|
-
}
|
|
341
|
-
function isDatabricksApp() {
|
|
342
|
-
return FfiConverterBool.lift(uniffiCaller.rustCall((callStatus) => {
|
|
343
|
-
return _bindings_ffi_default().uniffi_dbx_tools_databricks_fn_func_is_databricks_app(callStatus);
|
|
344
|
-
}, FfiConverterString.lift.bind(FfiConverterString)));
|
|
345
|
-
}
|
|
346
|
-
var stringConverter = (() => {
|
|
347
|
-
const encoder = new TextEncoder;
|
|
348
|
-
const decoder = new TextDecoder;
|
|
349
|
-
return {
|
|
350
|
-
stringToBytes: (s) => encoder.encode(s),
|
|
351
|
-
bytesToString: (ab) => decoder.decode(ab),
|
|
352
|
-
stringByteLength: (s) => encoder.encode(s).byteLength,
|
|
353
|
-
writeStringIntoBuffer: (s, buf, offset) => {
|
|
354
|
-
const view = new Uint8Array(buf.arrayBuffer, offset, buf.arrayBuffer.byteLength - offset);
|
|
355
|
-
return encoder.encodeInto(s, view).written;
|
|
356
|
-
},
|
|
357
|
-
readStringFromBuffer: (buf, offset, length) => decoder.decode(new Uint8Array(buf.arrayBuffer, offset, length))
|
|
358
|
-
};
|
|
359
|
-
})();
|
|
360
|
-
var FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
361
|
-
function uniffiEnsureInitialized() {
|
|
362
|
-
const bindingsContractVersion = 30;
|
|
363
|
-
const scaffoldingContractVersion = _bindings_ffi_default().ffi_dbx_tools_databricks_uniffi_contract_version();
|
|
364
|
-
if (bindingsContractVersion !== scaffoldingContractVersion) {
|
|
365
|
-
throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
|
|
366
|
-
}
|
|
367
|
-
if (_bindings_ffi_default().uniffi_dbx_tools_databricks_checksum_func_databricks_cli_available() !== 19375) {
|
|
368
|
-
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_databricks_checksum_func_databricks_cli_available");
|
|
369
|
-
}
|
|
370
|
-
if (_bindings_ffi_default().uniffi_dbx_tools_databricks_checksum_func_is_databricks_app() !== 27360) {
|
|
371
|
-
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_databricks_checksum_func_is_databricks_app");
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
var _bindings_default = Object.freeze({
|
|
375
|
-
initialize: uniffiEnsureInitialized
|
|
376
|
-
});
|
|
377
|
-
// src/bindings.ts
|
|
378
|
-
_bindings_default.initialize();
|
|
379
|
-
async function uniffiInitAsync() {}
|
|
380
|
-
// src/cloud.ts
|
|
381
|
-
var exports_cloud = {};
|
|
382
|
-
__export(exports_cloud, {
|
|
383
|
-
resolveCloudLocation: () => resolveCloudLocation,
|
|
384
|
-
loadProviderRanges: () => loadProviderRanges,
|
|
385
|
-
RANGE_CACHE_TTL_MS: () => RANGE_CACHE_TTL_MS,
|
|
386
|
-
CloudProvider: () => CloudProvider
|
|
387
|
-
});
|
|
388
|
-
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
389
|
-
import { tmpdir } from "node:os";
|
|
390
|
-
import { dirname, join } from "node:path";
|
|
391
|
-
import { file } from "@dbx-tools/core";
|
|
392
|
-
import { error, functionModule as functionModule2, hash, http as http2, json, log, net as net2 } from "@dbx-tools/shared-core";
|
|
393
|
-
|
|
394
|
-
// src/net.ts
|
|
395
|
-
var exports_net = {};
|
|
396
|
-
__export(exports_net, {
|
|
397
|
-
resolveHostIps: () => resolveHostIps,
|
|
398
|
-
getPublicIp: () => getPublicIp
|
|
399
|
-
});
|
|
400
|
-
import { lookup } from "node:dns/promises";
|
|
401
|
-
import { functionModule, http, net } from "@dbx-tools/shared-core";
|
|
402
|
-
var getPublicIp = functionModule.memoize(async () => {
|
|
403
|
-
const cloudflareResponse = await fetch("https://cloudflare.com/cdn-cgi/trace");
|
|
404
|
-
if (cloudflareResponse.ok) {
|
|
405
|
-
const trace = await cloudflareResponse.text();
|
|
406
|
-
const ipKey = "ip=";
|
|
407
|
-
const ip2 = trace.split(`
|
|
408
|
-
`).map((line) => line.trim()).find((line) => line.startsWith(ipKey))?.slice(ipKey.length);
|
|
409
|
-
if (ip2)
|
|
410
|
-
return ip2;
|
|
411
|
-
}
|
|
412
|
-
const ipifyResponse = await fetch("https://api.ipify.org?format=json");
|
|
413
|
-
if (!ipifyResponse.ok) {
|
|
414
|
-
throw await http.createFetchError(ipifyResponse);
|
|
415
|
-
}
|
|
416
|
-
const ipifyData = await ipifyResponse.json();
|
|
417
|
-
const ip = ipifyData?.ip;
|
|
418
|
-
if (ip)
|
|
419
|
-
return ip;
|
|
420
|
-
throw new Error("Could not determine public IP");
|
|
421
|
-
}, { ttlMs: 1000 * 60 * 5 });
|
|
422
|
-
async function resolveHostIps(input) {
|
|
423
|
-
const host = net.urlBuilder(input)?.hostname;
|
|
424
|
-
if (!host)
|
|
425
|
-
return [];
|
|
426
|
-
const literal = net.parseIp(host.replace(/^\[|\]$/g, ""));
|
|
427
|
-
if (literal)
|
|
428
|
-
return [host.replace(/^\[|\]$/g, "")];
|
|
429
|
-
try {
|
|
430
|
-
const results = await lookup(host, { all: true });
|
|
431
|
-
return [...new Set(results.map((r) => r.address))];
|
|
432
|
-
} catch {
|
|
433
|
-
return [];
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// src/cloud.ts
|
|
438
|
-
var logger = log.logger("cloud");
|
|
439
|
-
var RANGE_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
440
|
-
var AWS_RANGES_URL = "https://ip-ranges.amazonaws.com/ip-ranges.json";
|
|
441
|
-
var GCP_RANGES_URL = "https://www.gstatic.com/ipranges/cloud.json";
|
|
442
|
-
var AZURE_DOWNLOAD_PAGE = "https://www.microsoft.com/en-us/download/details.aspx?id=56519";
|
|
443
|
-
var AZURE_JSON_LINK = /https:\/\/download\.microsoft\.com\/download\/[^"']*ServiceTags_Public_\d+\.json/;
|
|
444
|
-
var CloudProvider;
|
|
445
|
-
((CloudProvider2) => {
|
|
446
|
-
CloudProvider2["Aws"] = "aws";
|
|
447
|
-
CloudProvider2["Azure"] = "azure";
|
|
448
|
-
CloudProvider2["Gcp"] = "gcp";
|
|
449
|
-
})(CloudProvider ||= {});
|
|
450
|
-
async function resolveCloudLocation(input) {
|
|
451
|
-
const ips = await resolveHostIps(input);
|
|
452
|
-
if (ips.length === 0) {
|
|
453
|
-
logger.debug("no ips resolved", { input: String(input) });
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
const providers = await loadProviderRanges();
|
|
457
|
-
for (const ip of ips) {
|
|
458
|
-
const parsed = net2.parseIp(ip);
|
|
459
|
-
if (!parsed)
|
|
460
|
-
continue;
|
|
461
|
-
for (const { provider, ranges } of providers) {
|
|
462
|
-
const match = net2.findContainingCidr(parsed, ranges);
|
|
463
|
-
if (match) {
|
|
464
|
-
return { provider, region: match.region, ip, cidr: match.cidr };
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
logger.debug("no cloud range matched", { ips });
|
|
469
|
-
return null;
|
|
470
|
-
}
|
|
471
|
-
async function loadProviderRanges() {
|
|
472
|
-
const settled = await Promise.allSettled([loadAwsRanges(), loadAzureRanges(), loadGcpRanges()]);
|
|
473
|
-
const out = [];
|
|
474
|
-
for (const result of settled) {
|
|
475
|
-
if (result.status === "fulfilled")
|
|
476
|
-
out.push(result.value);
|
|
477
|
-
else
|
|
478
|
-
logger.warn("provider range load failed", { error: error.errorMessage(result.reason) });
|
|
479
|
-
}
|
|
480
|
-
return out;
|
|
481
|
-
}
|
|
482
|
-
var loadAwsRanges = functionModule2.memoize(fetchAwsRanges, { ttlMs: RANGE_CACHE_TTL_MS });
|
|
483
|
-
var loadAzureRanges = functionModule2.memoize(fetchAzureRanges, { ttlMs: RANGE_CACHE_TTL_MS });
|
|
484
|
-
var loadGcpRanges = functionModule2.memoize(fetchGcpRanges, { ttlMs: RANGE_CACHE_TTL_MS });
|
|
485
|
-
async function fetchAwsRanges() {
|
|
486
|
-
const feed = await fetchJson(AWS_RANGES_URL);
|
|
487
|
-
const ranges = [];
|
|
488
|
-
for (const entry of feed.prefixes ?? []) {
|
|
489
|
-
addRange(ranges, entry.ip_prefix, entry.region);
|
|
490
|
-
}
|
|
491
|
-
for (const entry of feed.ipv6_prefixes ?? []) {
|
|
492
|
-
addRange(ranges, entry.ipv6_prefix, entry.region);
|
|
493
|
-
}
|
|
494
|
-
logger.debug("loaded aws ranges", { count: ranges.length });
|
|
495
|
-
return { provider: "aws" /* Aws */, ranges };
|
|
496
|
-
}
|
|
497
|
-
async function fetchGcpRanges() {
|
|
498
|
-
const feed = await fetchJson(GCP_RANGES_URL);
|
|
499
|
-
const ranges = [];
|
|
500
|
-
for (const entry of feed.prefixes ?? []) {
|
|
501
|
-
addRange(ranges, entry.ipv4Prefix ?? entry.ipv6Prefix, entry.scope);
|
|
502
|
-
}
|
|
503
|
-
logger.debug("loaded gcp ranges", { count: ranges.length });
|
|
504
|
-
return { provider: "gcp" /* Gcp */, ranges };
|
|
505
|
-
}
|
|
506
|
-
async function fetchAzureRanges() {
|
|
507
|
-
const page = await fetchText(AZURE_DOWNLOAD_PAGE);
|
|
508
|
-
const jsonUrl = page.match(AZURE_JSON_LINK)?.[0];
|
|
509
|
-
if (!jsonUrl) {
|
|
510
|
-
throw new Error("could not find ServiceTags JSON link on Azure download page");
|
|
511
|
-
}
|
|
512
|
-
const feed = await fetchJson(jsonUrl);
|
|
513
|
-
const ranges = [];
|
|
514
|
-
for (const value of feed.values ?? []) {
|
|
515
|
-
const region = value.properties?.region;
|
|
516
|
-
if (!region || !value.name?.startsWith("AzureCloud."))
|
|
517
|
-
continue;
|
|
518
|
-
for (const prefix of value.properties?.addressPrefixes ?? []) {
|
|
519
|
-
addRange(ranges, prefix, region);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
logger.debug("loaded azure ranges", { count: ranges.length });
|
|
523
|
-
return { provider: "azure" /* Azure */, ranges };
|
|
524
|
-
}
|
|
525
|
-
function addRange(ranges, cidr, region) {
|
|
526
|
-
if (!cidr || !region)
|
|
527
|
-
return;
|
|
528
|
-
const parsed = net2.parseCidr(cidr);
|
|
529
|
-
if (parsed)
|
|
530
|
-
ranges.push({ ...parsed, region });
|
|
531
|
-
}
|
|
532
|
-
async function fetchJson(url) {
|
|
533
|
-
const text = await fetchText(url);
|
|
534
|
-
const parsed = json.parse(text);
|
|
535
|
-
if (parsed === undefined) {
|
|
536
|
-
throw new Error(`range feed returned non-JSON content: ${url}`);
|
|
537
|
-
}
|
|
538
|
-
return parsed;
|
|
539
|
-
}
|
|
540
|
-
async function fetchText(url) {
|
|
541
|
-
const cacheDir = join(tmpdir(), "dbx-tools", "shared", "cloud");
|
|
542
|
-
const cacheDirCreated = await mkdir(cacheDir, { recursive: true });
|
|
543
|
-
const cachePath = join(cacheDir, `fetch-${hash.fnvHash(url)}.txt`);
|
|
544
|
-
const createdAt = cacheDirCreated ? undefined : await getCreated(cachePath);
|
|
545
|
-
if (createdAt) {
|
|
546
|
-
const expiresAt = new Date(createdAt.getTime() + RANGE_CACHE_TTL_MS);
|
|
547
|
-
if (expiresAt > new Date) {
|
|
548
|
-
logger.debug("cached fetch hit", { url, cachePath });
|
|
549
|
-
return readFile(cachePath, "utf8");
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
let tempPath = join(cacheDir, `${hash.id()}.txt`);
|
|
553
|
-
try {
|
|
554
|
-
const response = await fetch(url);
|
|
555
|
-
if (!response.ok) {
|
|
556
|
-
throw await http2.createFetchError(response, url);
|
|
557
|
-
}
|
|
558
|
-
const responseText = await response.text();
|
|
559
|
-
await mkdir(dirname(tempPath), { recursive: true });
|
|
560
|
-
await writeFile(tempPath, responseText);
|
|
561
|
-
await rename(tempPath, cachePath);
|
|
562
|
-
logger.debug("cached fetch load", { url, cachePath });
|
|
563
|
-
tempPath = null;
|
|
564
|
-
return responseText;
|
|
565
|
-
} finally {
|
|
566
|
-
if (tempPath) {
|
|
567
|
-
await unlink(tempPath);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
async function getCreated(path) {
|
|
572
|
-
return (await file.statSync(path))?.birthtime;
|
|
573
|
-
}
|
|
574
|
-
// src/databricks-fs.ts
|
|
575
|
-
var exports_databricks_fs = {};
|
|
576
|
-
__export(exports_databricks_fs, {
|
|
577
|
-
DatabricksFileSystem: () => DatabricksFileSystem
|
|
578
|
-
});
|
|
579
|
-
import { hash as hash2, object } from "@dbx-tools/shared-core";
|
|
580
|
-
import {
|
|
581
|
-
BaseFileSystem,
|
|
582
|
-
baseFS,
|
|
583
|
-
FileSystemError,
|
|
584
|
-
posixPath as posixPath2
|
|
585
|
-
} from "@dbx-tools/shared-fs";
|
|
586
|
-
|
|
587
|
-
// src/databricks-path.ts
|
|
588
|
-
var exports_databricks_path = {};
|
|
589
|
-
__export(exports_databricks_path, {
|
|
590
|
-
resolveDatabricksRoot: () => resolveDatabricksRoot,
|
|
591
|
-
resolveDatabricksFilesBackend: () => resolveDatabricksFilesBackend,
|
|
592
|
-
normalizeDatabricksRoot: () => normalizeDatabricksRoot,
|
|
593
|
-
isWorkspaceFilesPath: () => isWorkspaceFilesPath,
|
|
594
|
-
isVolumesPath: () => isVolumesPath,
|
|
595
|
-
isHomeRelativePath: () => isHomeRelativePath,
|
|
596
|
-
isDbfsPath: () => isDbfsPath,
|
|
597
|
-
expandHomePath: () => expandHomePath
|
|
598
|
-
});
|
|
599
|
-
import { posixPath } from "@dbx-tools/shared-fs";
|
|
600
|
-
|
|
601
|
-
// src/workspace.ts
|
|
602
|
-
var exports_workspace = {};
|
|
603
|
-
__export(exports_workspace, {
|
|
604
|
-
tryGetWorkspaceClient: () => tryGetWorkspaceClient,
|
|
605
|
-
toLegacyWorkspaceClient: () => toLegacyWorkspaceClient,
|
|
606
|
-
getWorkspaceUrl: () => getWorkspaceUrl,
|
|
607
|
-
getWorkspaceId: () => getWorkspaceId,
|
|
608
|
-
getWorkspaceClient: () => getWorkspaceClient,
|
|
609
|
-
getCurrentUserName: () => getCurrentUserName
|
|
610
|
-
});
|
|
611
|
-
import {
|
|
612
|
-
createWorkspaceClient
|
|
613
|
-
} from "@databricks/appkit";
|
|
614
|
-
import { appkit } from "@dbx-tools/appkit";
|
|
615
|
-
import { functionModule as functionModule3, net as net3 } from "@dbx-tools/shared-core";
|
|
616
|
-
var WORKSPACE_ID_REGEX = /\d{10,20}/;
|
|
617
|
-
function toLegacyWorkspaceClient(client) {
|
|
618
|
-
return "toLegacyWorkspaceClient" in client ? client.toLegacyWorkspaceClient() : client;
|
|
619
|
-
}
|
|
620
|
-
var getDefaultWorkspaceClient = functionModule3.memoize(async () => createWorkspaceClient().toLegacyWorkspaceClient());
|
|
621
|
-
function tryGetWorkspaceClient() {
|
|
622
|
-
return appkit.tryGetExecutionContext()?.client.toLegacyWorkspaceClient();
|
|
623
|
-
}
|
|
624
|
-
async function getWorkspaceClient() {
|
|
625
|
-
return tryGetWorkspaceClient() ?? await getDefaultWorkspaceClient();
|
|
626
|
-
}
|
|
627
|
-
async function getWorkspaceConfig() {
|
|
628
|
-
try {
|
|
629
|
-
return (await getWorkspaceClient()).config;
|
|
630
|
-
} catch {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
async function getCurrentUserName(client) {
|
|
635
|
-
const contextUser = readContextUserName(appkit.tryGetExecutionContext());
|
|
636
|
-
if (contextUser)
|
|
637
|
-
return contextUser;
|
|
638
|
-
const resolved = client ?? await getWorkspaceClient();
|
|
639
|
-
const me = await resolved.currentUser.me();
|
|
640
|
-
const userName = me.userName?.trim();
|
|
641
|
-
if (!userName) {
|
|
642
|
-
throw new Error("Databricks currentUser.me() did not return a userName");
|
|
643
|
-
}
|
|
644
|
-
return userName;
|
|
645
|
-
}
|
|
646
|
-
function readContextUserName(ctx) {
|
|
647
|
-
if (typeof ctx !== "object" || ctx === null || !("userName" in ctx))
|
|
648
|
-
return;
|
|
649
|
-
const value = ctx.userName;
|
|
650
|
-
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
651
|
-
}
|
|
652
|
-
async function getWorkspaceUrl() {
|
|
653
|
-
const config = await getWorkspaceConfig();
|
|
654
|
-
if (config) {
|
|
655
|
-
const configHost = net3.urlBuilder(await config.getHost());
|
|
656
|
-
if (configHost)
|
|
657
|
-
return configHost;
|
|
658
|
-
}
|
|
659
|
-
const databricksHost = net3.urlBuilder(process.env.DATABRICKS_HOST);
|
|
660
|
-
if (databricksHost)
|
|
661
|
-
return databricksHost;
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
async function getWorkspaceId(workspaceHost) {
|
|
665
|
-
const workspaceId = (await getWorkspaceConfig())?.workspaceId;
|
|
666
|
-
if (workspaceId)
|
|
667
|
-
return workspaceId;
|
|
668
|
-
workspaceHost = workspaceHost ?? (await getWorkspaceUrl())?.host;
|
|
669
|
-
if (workspaceHost) {
|
|
670
|
-
const match = workspaceHost.match(WORKSPACE_ID_REGEX)?.[0];
|
|
671
|
-
if (match)
|
|
672
|
-
return match;
|
|
673
|
-
}
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// src/databricks-path.ts
|
|
678
|
-
var VOLUME_THREE_PART = /^([^.\/\s]+)\.([^.\/\s]+)\.([^.\/\s]+)$/;
|
|
679
|
-
var isHomeRelativePath = posixPath.isHomeRelativePath;
|
|
680
|
-
function expandHomePath(input, userName) {
|
|
681
|
-
const name = userName.trim();
|
|
682
|
-
if (!name) {
|
|
683
|
-
throw new TypeError("Databricks home expansion requires a non-empty userName");
|
|
684
|
-
}
|
|
685
|
-
if (!isHomeRelativePath(input)) {
|
|
686
|
-
return posixPath.toPosix(input.trim());
|
|
687
|
-
}
|
|
688
|
-
return posixPath.expandHome(input, `/Workspace/Users/${name}`);
|
|
689
|
-
}
|
|
690
|
-
function normalizeDatabricksRoot(root, options = {}) {
|
|
691
|
-
const trimmed = root.trim();
|
|
692
|
-
if (!trimmed) {
|
|
693
|
-
throw new TypeError("Databricks filesystem root cannot be empty");
|
|
694
|
-
}
|
|
695
|
-
if (isHomeRelativePath(trimmed)) {
|
|
696
|
-
if (!options.userName?.trim()) {
|
|
697
|
-
throw new TypeError(`Databricks home path "${root}" requires userName; use resolveDatabricksRoot() or pass userName`);
|
|
698
|
-
}
|
|
699
|
-
return posixPath.normalizeRoot(expandHomePath(trimmed, options.userName));
|
|
700
|
-
}
|
|
701
|
-
const threePart = VOLUME_THREE_PART.exec(trimmed);
|
|
702
|
-
if (threePart) {
|
|
703
|
-
return posixPath.normalizeRoot(`/Volumes/${threePart[1]}/${threePart[2]}/${threePart[3]}`);
|
|
704
|
-
}
|
|
705
|
-
let posix = posixPath.toPosix(trimmed);
|
|
706
|
-
if (posix === "/Volume" || posix.startsWith("/Volume/")) {
|
|
707
|
-
posix = `/Volumes${posix.slice("/Volume".length)}`;
|
|
708
|
-
}
|
|
709
|
-
if (!posixPath.isAbsolute(posix)) {
|
|
710
|
-
throw new TypeError(`Databricks filesystem root must be absolute, catalog.schema.volume, or ~, got: ${root}`);
|
|
711
|
-
}
|
|
712
|
-
return posixPath.normalizeRoot(posix);
|
|
713
|
-
}
|
|
714
|
-
async function resolveDatabricksRoot(root, options = {}) {
|
|
715
|
-
if (!isHomeRelativePath(root)) {
|
|
716
|
-
return normalizeDatabricksRoot(root);
|
|
717
|
-
}
|
|
718
|
-
const userName = await getCurrentUserName(options.client);
|
|
719
|
-
return normalizeDatabricksRoot(root, { userName });
|
|
720
|
-
}
|
|
721
|
-
function isWorkspaceFilesPath(absolutePath) {
|
|
722
|
-
const p = posixPath.toPosix(absolutePath);
|
|
723
|
-
return p === "/Workspace" || p.startsWith("/Workspace/") || p.startsWith("/Users/") || p.startsWith("/Repos/") || p.startsWith("/Shared/");
|
|
724
|
-
}
|
|
725
|
-
function isVolumesPath(absolutePath) {
|
|
726
|
-
const p = posixPath.toPosix(absolutePath);
|
|
727
|
-
return p === "/Volumes" || p.startsWith("/Volumes/");
|
|
728
|
-
}
|
|
729
|
-
function isDbfsPath(absolutePath) {
|
|
730
|
-
const p = posixPath.toPosix(absolutePath);
|
|
731
|
-
return p === "/dbfs" || p.startsWith("/dbfs/");
|
|
732
|
-
}
|
|
733
|
-
function resolveDatabricksFilesBackend(absolutePath) {
|
|
734
|
-
if (isDbfsPath(absolutePath))
|
|
735
|
-
return "dbfs";
|
|
736
|
-
if (isWorkspaceFilesPath(absolutePath))
|
|
737
|
-
return "workspace";
|
|
738
|
-
if (isVolumesPath(absolutePath))
|
|
739
|
-
return "volumes";
|
|
740
|
-
return "volumes";
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// src/databricks-fs.ts
|
|
744
|
-
var DBFS_READ_CHUNK_BYTES = 1024 * 1024;
|
|
745
|
-
var DBFS_PUT_MAX_BYTES = 1024 * 1024;
|
|
746
|
-
var VOLUME_ROOT_DEPTH = 4;
|
|
747
|
-
|
|
748
|
-
class DatabricksFileSystem extends BaseFileSystem {
|
|
749
|
-
client;
|
|
750
|
-
clientOption;
|
|
751
|
-
constructor(options) {
|
|
752
|
-
const root = normalizeDatabricksRoot(options.root, { userName: options.userName });
|
|
753
|
-
super({
|
|
754
|
-
id: options.id ?? `databricks-${hash2.fnvHash(root)}`,
|
|
755
|
-
backend: "databricks",
|
|
756
|
-
root,
|
|
757
|
-
readOnly: options.readOnly,
|
|
758
|
-
createRoot: options.createRoot ?? false
|
|
759
|
-
});
|
|
760
|
-
this.clientOption = options.client;
|
|
761
|
-
this.client = options.client;
|
|
762
|
-
}
|
|
763
|
-
static async create(options) {
|
|
764
|
-
if (!isHomeRelativePath(options.root) || options.userName?.trim()) {
|
|
765
|
-
return new DatabricksFileSystem(options);
|
|
766
|
-
}
|
|
767
|
-
const client = options.client ?? await getWorkspaceClient();
|
|
768
|
-
const root = await resolveDatabricksRoot(options.root, { client });
|
|
769
|
-
return new DatabricksFileSystem({ ...options, root, client });
|
|
770
|
-
}
|
|
771
|
-
async onInit() {
|
|
772
|
-
this.client = this.clientOption ?? await getWorkspaceClient();
|
|
773
|
-
}
|
|
774
|
-
dispatch(absolutePath, handlers) {
|
|
775
|
-
if (!this.client) {
|
|
776
|
-
throw new FileSystemError("IO_ERROR", "Databricks filesystem is not initialized (no WorkspaceClient)", absolutePath);
|
|
777
|
-
}
|
|
778
|
-
return handlers[resolveDatabricksFilesBackend(absolutePath)](this.client);
|
|
779
|
-
}
|
|
780
|
-
async createRootDirectory() {
|
|
781
|
-
await this.createDirectoryAt(this.root);
|
|
782
|
-
}
|
|
783
|
-
async readBytesAt(resolvedPath) {
|
|
784
|
-
const buffer = await this.dispatch(resolvedPath, {
|
|
785
|
-
dbfs: (client) => this.readDbfsFile(client, resolvedPath),
|
|
786
|
-
workspace: async (client) => {
|
|
787
|
-
const response = await client.workspace.export({ path: resolvedPath, format: "AUTO" });
|
|
788
|
-
return decodeBase64(response.content);
|
|
789
|
-
},
|
|
790
|
-
volumes: async (client) => {
|
|
791
|
-
const response = await client.files.download({ file_path: resolvedPath });
|
|
792
|
-
return readResponseBody(response.contents);
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
796
|
-
}
|
|
797
|
-
async writeBytesAt(resolvedPath, content, options) {
|
|
798
|
-
const buffer = Buffer.from(content);
|
|
799
|
-
const overwrite = options.overwrite;
|
|
800
|
-
await this.dispatch(resolvedPath, {
|
|
801
|
-
dbfs: (client) => this.writeDbfsFile(client, resolvedPath, buffer, overwrite),
|
|
802
|
-
workspace: (client) => client.workspace.import({
|
|
803
|
-
path: resolvedPath,
|
|
804
|
-
format: "AUTO",
|
|
805
|
-
content: buffer.toString("base64"),
|
|
806
|
-
overwrite
|
|
807
|
-
}),
|
|
808
|
-
volumes: (client) => client.files.upload({
|
|
809
|
-
file_path: resolvedPath,
|
|
810
|
-
contents: bufferToReadableStream(buffer),
|
|
811
|
-
overwrite
|
|
812
|
-
})
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
async deleteFileAt(resolvedPath) {
|
|
816
|
-
await this.dispatch(resolvedPath, {
|
|
817
|
-
dbfs: (client) => client.dbfs.delete({ path: resolvedPath, recursive: false }),
|
|
818
|
-
workspace: (client) => client.workspace.delete({ path: resolvedPath, recursive: false }),
|
|
819
|
-
volumes: (client) => client.files.delete({ file_path: resolvedPath })
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
async createDirectoryAt(resolvedPath) {
|
|
823
|
-
await this.dispatch(resolvedPath, {
|
|
824
|
-
dbfs: (client) => client.dbfs.mkdirs({ path: resolvedPath }),
|
|
825
|
-
workspace: (client) => client.workspace.mkdirs({ path: resolvedPath }),
|
|
826
|
-
volumes: (client) => this.createVolumeDirectories(client, resolvedPath)
|
|
827
|
-
});
|
|
828
|
-
}
|
|
829
|
-
async removeDirectoryAt(resolvedPath) {
|
|
830
|
-
await this.dispatch(resolvedPath, {
|
|
831
|
-
dbfs: (client) => client.dbfs.delete({ path: resolvedPath, recursive: false }),
|
|
832
|
-
workspace: (client) => client.workspace.delete({ path: resolvedPath, recursive: false }),
|
|
833
|
-
volumes: (client) => client.files.deleteDirectory({ directory_path: resolvedPath })
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
async listDirectoryAt(resolvedPath) {
|
|
837
|
-
return this.dispatch(resolvedPath, {
|
|
838
|
-
dbfs: (client) => collect(client.dbfs.list({ path: resolvedPath }), (info) => ({
|
|
839
|
-
name: posixPath2.basename(info.path ?? ""),
|
|
840
|
-
type: info.is_dir ? "directory" : "file",
|
|
841
|
-
size: info.file_size
|
|
842
|
-
})),
|
|
843
|
-
workspace: (client) => collect(client.workspace.list({ path: resolvedPath }), (info) => ({
|
|
844
|
-
name: posixPath2.basename(info.path ?? ""),
|
|
845
|
-
type: info.object_type === "DIRECTORY" ? "directory" : "file"
|
|
846
|
-
})),
|
|
847
|
-
volumes: (client) => collect(client.files.listDirectoryContents({ directory_path: resolvedPath }), (entry) => ({
|
|
848
|
-
name: entry.name ?? posixPath2.basename(entry.path ?? ""),
|
|
849
|
-
type: entry.is_directory ? "directory" : "file",
|
|
850
|
-
size: entry.file_size
|
|
851
|
-
}))
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
async statAt(resolvedPath) {
|
|
855
|
-
const fallbackName = posixPath2.basename(resolvedPath) || posixPath2.basename(this.root);
|
|
856
|
-
return this.dispatch(resolvedPath, {
|
|
857
|
-
dbfs: async (client) => {
|
|
858
|
-
const info = await client.dbfs.getStatus({ path: resolvedPath });
|
|
859
|
-
const modified = object.toDate(info.modification_time);
|
|
860
|
-
return {
|
|
861
|
-
name: posixPath2.basename(info.path ?? resolvedPath) || fallbackName,
|
|
862
|
-
type: info.is_dir ? "directory" : "file",
|
|
863
|
-
size: info.file_size,
|
|
864
|
-
createdAt: modified,
|
|
865
|
-
modifiedAt: modified
|
|
866
|
-
};
|
|
867
|
-
},
|
|
868
|
-
workspace: async (client) => {
|
|
869
|
-
const info = await client.workspace.getStatus({ path: resolvedPath });
|
|
870
|
-
return {
|
|
871
|
-
name: posixPath2.basename(info.path ?? resolvedPath) || fallbackName,
|
|
872
|
-
type: info.object_type === "DIRECTORY" ? "directory" : "file",
|
|
873
|
-
createdAt: object.toDate(info.created_at),
|
|
874
|
-
modifiedAt: object.toDate(info.modified_at)
|
|
875
|
-
};
|
|
876
|
-
},
|
|
877
|
-
volumes: (client) => this.statVolumePath(client, resolvedPath, fallbackName)
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
async tryMoveFileAt(sourcePath, destinationPath, _options) {
|
|
881
|
-
if (resolveDatabricksFilesBackend(sourcePath) !== "dbfs" || resolveDatabricksFilesBackend(destinationPath) !== "dbfs") {
|
|
882
|
-
return false;
|
|
883
|
-
}
|
|
884
|
-
await this.dispatch(sourcePath, {
|
|
885
|
-
dbfs: (client) => client.dbfs.move({ source_path: sourcePath, destination_path: destinationPath }),
|
|
886
|
-
workspace: unreachableBackend,
|
|
887
|
-
volumes: unreachableBackend
|
|
888
|
-
});
|
|
889
|
-
return true;
|
|
890
|
-
}
|
|
891
|
-
async createVolumeDirectories(client, absolutePath) {
|
|
892
|
-
const parts = absolutePath.split("/").filter(Boolean);
|
|
893
|
-
let current = "";
|
|
894
|
-
for (let i = 0;i < parts.length; i++) {
|
|
895
|
-
current = `${current}/${parts[i]}`;
|
|
896
|
-
if (i < VOLUME_ROOT_DEPTH)
|
|
897
|
-
continue;
|
|
898
|
-
try {
|
|
899
|
-
await client.files.createDirectory({ directory_path: current });
|
|
900
|
-
} catch (err) {
|
|
901
|
-
try {
|
|
902
|
-
await client.files.getDirectoryMetadata({ directory_path: current });
|
|
903
|
-
} catch {
|
|
904
|
-
throw err;
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
async statVolumePath(client, absolutePath, fallbackName) {
|
|
910
|
-
try {
|
|
911
|
-
const metadata = await client.files.getMetadata({ file_path: absolutePath });
|
|
912
|
-
const modified = object.toDate(metadata["last-modified"]);
|
|
913
|
-
return {
|
|
914
|
-
name: fallbackName,
|
|
915
|
-
type: "file",
|
|
916
|
-
size: Number(metadata["content-length"] ?? 0),
|
|
917
|
-
createdAt: modified,
|
|
918
|
-
modifiedAt: modified,
|
|
919
|
-
mimeType: metadata["content-type"]
|
|
920
|
-
};
|
|
921
|
-
} catch (fileErr) {
|
|
922
|
-
const code = baseFS.mapFileSystemError(fileErr, absolutePath).code;
|
|
923
|
-
if (code !== "NOT_FOUND" && code !== "PERMISSION_DENIED")
|
|
924
|
-
throw fileErr;
|
|
925
|
-
await client.files.getDirectoryMetadata({ directory_path: absolutePath });
|
|
926
|
-
return { name: fallbackName, type: "directory" };
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
async readDbfsFile(client, absolutePath) {
|
|
930
|
-
const chunks = [];
|
|
931
|
-
let offset = 0;
|
|
932
|
-
while (true) {
|
|
933
|
-
const response = await client.dbfs.read({
|
|
934
|
-
path: absolutePath,
|
|
935
|
-
offset,
|
|
936
|
-
length: DBFS_READ_CHUNK_BYTES
|
|
937
|
-
});
|
|
938
|
-
const chunk = decodeBase64(response.data);
|
|
939
|
-
if (chunk.length === 0)
|
|
940
|
-
break;
|
|
941
|
-
chunks.push(chunk);
|
|
942
|
-
offset += chunk.length;
|
|
943
|
-
if (chunk.length < DBFS_READ_CHUNK_BYTES)
|
|
944
|
-
break;
|
|
945
|
-
}
|
|
946
|
-
return Buffer.concat(chunks);
|
|
947
|
-
}
|
|
948
|
-
async writeDbfsFile(client, absolutePath, buffer, overwrite) {
|
|
949
|
-
if (buffer.length <= DBFS_PUT_MAX_BYTES) {
|
|
950
|
-
await client.dbfs.put({
|
|
951
|
-
path: absolutePath,
|
|
952
|
-
contents: buffer.toString("base64"),
|
|
953
|
-
overwrite
|
|
954
|
-
});
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
const created = await client.dbfs.create({ path: absolutePath, overwrite });
|
|
958
|
-
const handle = created.handle;
|
|
959
|
-
if (handle === undefined) {
|
|
960
|
-
throw new FileSystemError("IO_ERROR", "DBFS upload handle missing", absolutePath);
|
|
961
|
-
}
|
|
962
|
-
try {
|
|
963
|
-
for (let offset = 0;offset < buffer.length; offset += DBFS_PUT_MAX_BYTES) {
|
|
964
|
-
const slice = buffer.subarray(offset, offset + DBFS_PUT_MAX_BYTES);
|
|
965
|
-
await client.dbfs.addBlock({ handle, data: slice.toString("base64") });
|
|
966
|
-
}
|
|
967
|
-
} catch (err) {
|
|
968
|
-
await client.dbfs.close({ handle }).catch(() => {
|
|
969
|
-
return;
|
|
970
|
-
});
|
|
971
|
-
throw err;
|
|
972
|
-
}
|
|
973
|
-
await client.dbfs.close({ handle });
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
async function collect(source, map) {
|
|
977
|
-
const items = [];
|
|
978
|
-
for await (const item of source)
|
|
979
|
-
items.push(map(item));
|
|
980
|
-
return items;
|
|
981
|
-
}
|
|
982
|
-
function unreachableBackend() {
|
|
983
|
-
throw new FileSystemError("NOT_SUPPORTED", "Unsupported Databricks backend for this operation");
|
|
984
|
-
}
|
|
985
|
-
function decodeBase64(data) {
|
|
986
|
-
if (!data)
|
|
987
|
-
return Buffer.alloc(0);
|
|
988
|
-
return Buffer.from(data, "base64");
|
|
989
|
-
}
|
|
990
|
-
async function readResponseBody(contents) {
|
|
991
|
-
if (!contents)
|
|
992
|
-
return Buffer.alloc(0);
|
|
993
|
-
const reader = contents.getReader();
|
|
994
|
-
const chunks = [];
|
|
995
|
-
while (true) {
|
|
996
|
-
const { done, value } = await reader.read();
|
|
997
|
-
if (done)
|
|
998
|
-
break;
|
|
999
|
-
if (value)
|
|
1000
|
-
chunks.push(value);
|
|
1001
|
-
}
|
|
1002
|
-
return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)));
|
|
1003
|
-
}
|
|
1004
|
-
function bufferToReadableStream(buffer) {
|
|
1005
|
-
return new ReadableStream({
|
|
1006
|
-
start(controller) {
|
|
1007
|
-
controller.enqueue(new Uint8Array(buffer));
|
|
1008
|
-
controller.close();
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// index.ts
|
|
1014
|
-
var PACKAGE_IDENTIFIER = "@dbx-tools/databricks";
|
|
1015
|
-
var PACKAGE_VERSION = "0.6.182";
|
|
1016
|
-
export {
|
|
1017
|
-
exports_workspace as workspace,
|
|
1018
|
-
_bindings_default as uniffiModule,
|
|
1019
|
-
uniffiInitAsync,
|
|
1020
|
-
exports_net as net,
|
|
1021
|
-
isHomeRelativePath,
|
|
1022
|
-
isDatabricksApp,
|
|
1023
|
-
getPublicIp,
|
|
1024
|
-
exports_databricks_path as databricksPath,
|
|
1025
|
-
exports_databricks_fs as databricksFS,
|
|
1026
|
-
databricksCliAvailable,
|
|
1027
|
-
exports_cloud as cloud,
|
|
1028
|
-
RANGE_CACHE_TTL_MS,
|
|
1029
|
-
PACKAGE_VERSION,
|
|
1030
|
-
PACKAGE_IDENTIFIER,
|
|
1031
|
-
DatabricksFileSystem,
|
|
1032
|
-
CloudProvider
|
|
1033
|
-
};
|
|
1
|
+
// GENERATED by projen watch - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the exporting modules in ./src.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
export const PACKAGE_IDENTIFIER = "@dbx-tools/databricks";
|
|
5
|
+
export const PACKAGE_VERSION = "0.6.183";
|
|
6
|
+
export * as cloud from "./src/cloud.js";
|
|
7
|
+
export * as databricksFS from "./src/databricks-fs.js";
|
|
8
|
+
export * as databricksPath from "./src/databricks-path.js";
|
|
9
|
+
export * as net from "./src/net.js";
|
|
10
|
+
export * as workspace from "./src/workspace.js";
|
|
11
|
+
export { RANGE_CACHE_TTL_MS, CloudProvider } from "./src/cloud.js";
|
|
12
|
+
export { DatabricksFileSystem } from "./src/databricks-fs.js";
|
|
13
|
+
export { isHomeRelativePath } from "./src/databricks-path.js";
|
|
14
|
+
export { getPublicIp } from "./src/net.js";
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7QUFDM0MsbURBQW1EO0FBQ25ELHdFQUF3RTtBQUV4RSxNQUFNLENBQUMsTUFBTSxrQkFBa0IsR0FBRyx1QkFBdUIsQ0FBQztBQUMxRCxNQUFNLENBQUMsTUFBTSxlQUFlLEdBQUcsU0FBUyxDQUFDO0FBQ3pDLE9BQU8sS0FBSyxLQUFLLE1BQU0sZ0JBQWdCLENBQUM7QUFDeEMsT0FBTyxLQUFLLFlBQVksTUFBTSx3QkFBd0IsQ0FBQztBQUN2RCxPQUFPLEtBQUssY0FBYyxNQUFNLDBCQUEwQixDQUFDO0FBQzNELE9BQU8sS0FBSyxHQUFHLE1BQU0sY0FBYyxDQUFDO0FBQ3BDLE9BQU8sS0FBSyxTQUFTLE1BQU0sb0JBQW9CLENBQUM7QUFDaEQsT0FBTyxFQUFFLGtCQUFrQixFQUFFLGFBQWEsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBRW5FLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTlELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRTlELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBHRU5FUkFURUQgYnkgcHJvamVuIHdhdGNoIC0gRE8gTk9UIEVESVQuXG4vLyBSZWdlbmVyYXRlZCBmcm9tIHRoZSBleHBvcnRpbmcgbW9kdWxlcyBpbiAuL3NyYy5cbi8vIEhhbmQgZWRpdHMgYXJlIG92ZXJ3cml0dGVuIG9uIHRoZSBuZXh0IHdhdGNoOyB0aGlzIGZpbGUgaXMgcmVhZC1vbmx5LlxuXG5leHBvcnQgY29uc3QgUEFDS0FHRV9JREVOVElGSUVSID0gXCJAZGJ4LXRvb2xzL2RhdGFicmlja3NcIjtcbmV4cG9ydCBjb25zdCBQQUNLQUdFX1ZFUlNJT04gPSBcIjAuNi4xODNcIjtcbmV4cG9ydCAqIGFzIGNsb3VkIGZyb20gXCIuL3NyYy9jbG91ZC50c1wiO1xuZXhwb3J0ICogYXMgZGF0YWJyaWNrc0ZTIGZyb20gXCIuL3NyYy9kYXRhYnJpY2tzLWZzLnRzXCI7XG5leHBvcnQgKiBhcyBkYXRhYnJpY2tzUGF0aCBmcm9tIFwiLi9zcmMvZGF0YWJyaWNrcy1wYXRoLnRzXCI7XG5leHBvcnQgKiBhcyBuZXQgZnJvbSBcIi4vc3JjL25ldC50c1wiO1xuZXhwb3J0ICogYXMgd29ya3NwYWNlIGZyb20gXCIuL3NyYy93b3Jrc3BhY2UudHNcIjtcbmV4cG9ydCB7IFJBTkdFX0NBQ0hFX1RUTF9NUywgQ2xvdWRQcm92aWRlciB9IGZyb20gXCIuL3NyYy9jbG91ZC50c1wiO1xuZXhwb3J0IHR5cGUgeyBDbG91ZExvY2F0aW9uIH0gZnJvbSBcIi4vc3JjL2Nsb3VkLnRzXCI7XG5leHBvcnQgeyBEYXRhYnJpY2tzRmlsZVN5c3RlbSB9IGZyb20gXCIuL3NyYy9kYXRhYnJpY2tzLWZzLnRzXCI7XG5leHBvcnQgdHlwZSB7IERhdGFicmlja3NGaWxlU3lzdGVtT3B0aW9ucyB9IGZyb20gXCIuL3NyYy9kYXRhYnJpY2tzLWZzLnRzXCI7XG5leHBvcnQgeyBpc0hvbWVSZWxhdGl2ZVBhdGggfSBmcm9tIFwiLi9zcmMvZGF0YWJyaWNrcy1wYXRoLnRzXCI7XG5leHBvcnQgdHlwZSB7IERhdGFicmlja3NGaWxlc0JhY2tlbmQsIE5vcm1hbGl6ZURhdGFicmlja3NSb290T3B0aW9ucywgUmVzb2x2ZURhdGFicmlja3NSb290T3B0aW9ucyB9IGZyb20gXCIuL3NyYy9kYXRhYnJpY2tzLXBhdGgudHNcIjtcbmV4cG9ydCB7IGdldFB1YmxpY0lwIH0gZnJvbSBcIi4vc3JjL25ldC50c1wiO1xuZXhwb3J0IHR5cGUgeyBXb3Jrc3BhY2VDbGllbnQgfSBmcm9tIFwiLi9zcmMvd29ya3NwYWNlLnRzXCI7XG4iXX0=
|