windmill-client 1.591.4 → 1.592.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +98 -0
- package/dist/client.js +98 -17
- package/dist/core/OpenAPI.js +1 -1
- package/dist/s3Types.d.ts +22 -0
- package/dist/sqlUtils.d.ts +24 -0
- package/dist/sqlUtils.js +6 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export type Email = string;
|
|
|
7
7
|
export type Base64 = string;
|
|
8
8
|
export type Resource<S extends string> = any;
|
|
9
9
|
export declare const SHARED_FOLDER = "/shared";
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the Windmill client with authentication token and base URL
|
|
12
|
+
* @param token - Authentication token (defaults to WM_TOKEN env variable)
|
|
13
|
+
* @param baseUrl - API base URL (defaults to BASE_INTERNAL_URL or BASE_URL env variable)
|
|
14
|
+
*/
|
|
10
15
|
export declare function setClient(token?: string, baseUrl?: string): void;
|
|
11
16
|
/**
|
|
12
17
|
* Create a client configuration from env variables
|
|
@@ -30,7 +35,21 @@ export declare function getRootJobId(jobId?: string): Promise<string>;
|
|
|
30
35
|
* @deprecated Use runScriptByPath or runScriptByHash instead
|
|
31
36
|
*/
|
|
32
37
|
export declare function runScript(path?: string | null, hash_?: string | null, args?: Record<string, any> | null, verbose?: boolean): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Run a script synchronously by its path and wait for the result
|
|
40
|
+
* @param path - Script path in Windmill
|
|
41
|
+
* @param args - Arguments to pass to the script
|
|
42
|
+
* @param verbose - Enable verbose logging
|
|
43
|
+
* @returns Script execution result
|
|
44
|
+
*/
|
|
33
45
|
export declare function runScriptByPath(path: string, args?: Record<string, any> | null, verbose?: boolean): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* Run a script synchronously by its hash and wait for the result
|
|
48
|
+
* @param hash_ - Script hash in Windmill
|
|
49
|
+
* @param args - Arguments to pass to the script
|
|
50
|
+
* @param verbose - Enable verbose logging
|
|
51
|
+
* @returns Script execution result
|
|
52
|
+
*/
|
|
34
53
|
export declare function runScriptByHash(hash_: string, args?: Record<string, any> | null, verbose?: boolean): Promise<any>;
|
|
35
54
|
/**
|
|
36
55
|
* Append a text to the result stream
|
|
@@ -42,17 +61,67 @@ export declare function appendToResultStream(text: string): void;
|
|
|
42
61
|
* @param stream stream to stream to the result stream
|
|
43
62
|
*/
|
|
44
63
|
export declare function streamResult(stream: AsyncIterable<string>): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Run a flow synchronously by its path and wait for the result
|
|
66
|
+
* @param path - Flow path in Windmill
|
|
67
|
+
* @param args - Arguments to pass to the flow
|
|
68
|
+
* @param verbose - Enable verbose logging
|
|
69
|
+
* @returns Flow execution result
|
|
70
|
+
*/
|
|
45
71
|
export declare function runFlow(path?: string | null, args?: Record<string, any> | null, verbose?: boolean): Promise<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Wait for a job to complete and return its result
|
|
74
|
+
* @param jobId - ID of the job to wait for
|
|
75
|
+
* @param verbose - Enable verbose logging
|
|
76
|
+
* @returns Job result when completed
|
|
77
|
+
*/
|
|
46
78
|
export declare function waitJob(jobId: string, verbose?: boolean): Promise<any>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the result of a completed job
|
|
81
|
+
* @param jobId - ID of the completed job
|
|
82
|
+
* @returns Job result
|
|
83
|
+
*/
|
|
47
84
|
export declare function getResult(jobId: string): Promise<any>;
|
|
85
|
+
/**
|
|
86
|
+
* Get the result of a job if completed, or its current status
|
|
87
|
+
* @param jobId - ID of the job
|
|
88
|
+
* @returns Object with started, completed, success, and result properties
|
|
89
|
+
*/
|
|
48
90
|
export declare function getResultMaybe(jobId: string): Promise<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Wrap a function to execute as a Windmill task within a flow context
|
|
93
|
+
* @param f - Function to wrap as a task
|
|
94
|
+
* @returns Async wrapper function that executes as a Windmill job
|
|
95
|
+
*/
|
|
49
96
|
export declare function task<P, T>(f: (_: P) => T): (_: P) => Promise<T>;
|
|
50
97
|
/**
|
|
51
98
|
* @deprecated Use runScriptByPathAsync or runScriptByHashAsync instead
|
|
52
99
|
*/
|
|
53
100
|
export declare function runScriptAsync(path: string | null, hash_: string | null, args: Record<string, any> | null, scheduledInSeconds?: number | null): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Run a script asynchronously by its path
|
|
103
|
+
* @param path - Script path in Windmill
|
|
104
|
+
* @param args - Arguments to pass to the script
|
|
105
|
+
* @param scheduledInSeconds - Schedule execution for a future time (in seconds)
|
|
106
|
+
* @returns Job ID of the created job
|
|
107
|
+
*/
|
|
54
108
|
export declare function runScriptByPathAsync(path: string, args?: Record<string, any> | null, scheduledInSeconds?: number | null): Promise<string>;
|
|
109
|
+
/**
|
|
110
|
+
* Run a script asynchronously by its hash
|
|
111
|
+
* @param hash_ - Script hash in Windmill
|
|
112
|
+
* @param args - Arguments to pass to the script
|
|
113
|
+
* @param scheduledInSeconds - Schedule execution for a future time (in seconds)
|
|
114
|
+
* @returns Job ID of the created job
|
|
115
|
+
*/
|
|
55
116
|
export declare function runScriptByHashAsync(hash_: string, args?: Record<string, any> | null, scheduledInSeconds?: number | null): Promise<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Run a flow asynchronously by its path
|
|
119
|
+
* @param path - Flow path in Windmill
|
|
120
|
+
* @param args - Arguments to pass to the flow
|
|
121
|
+
* @param scheduledInSeconds - Schedule execution for a future time (in seconds)
|
|
122
|
+
* @param doNotTrackInParent - If false, tracks state in parent job (only use when fully awaiting the job)
|
|
123
|
+
* @returns Job ID of the created job
|
|
124
|
+
*/
|
|
56
125
|
export declare function runFlowAsync(path: string | null, args: Record<string, any> | null, scheduledInSeconds?: number | null, doNotTrackInParent?: boolean): Promise<string>;
|
|
57
126
|
/**
|
|
58
127
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
@@ -60,6 +129,10 @@ export declare function runFlowAsync(path: string | null, args: Record<string, a
|
|
|
60
129
|
* @returns resource value
|
|
61
130
|
*/
|
|
62
131
|
export declare function resolveDefaultResource(obj: any): Promise<any>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the state file path from environment variables
|
|
134
|
+
* @returns State path string
|
|
135
|
+
*/
|
|
63
136
|
export declare function getStatePath(): string;
|
|
64
137
|
/**
|
|
65
138
|
* Set a resource value by path
|
|
@@ -128,7 +201,17 @@ export declare function getVariable(path: string): Promise<string>;
|
|
|
128
201
|
* @param descriptionIfNotExist if the variable does not exist, create it with this description (default: "")
|
|
129
202
|
*/
|
|
130
203
|
export declare function setVariable(path: string, value: string, isSecretIfNotExist?: boolean, descriptionIfNotExist?: string): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Build a PostgreSQL connection URL from a database resource
|
|
206
|
+
* @param path - Path to the database resource
|
|
207
|
+
* @returns PostgreSQL connection URL string
|
|
208
|
+
*/
|
|
131
209
|
export declare function databaseUrlFromResource(path: string): Promise<string>;
|
|
210
|
+
/**
|
|
211
|
+
* Get S3 client settings from a resource or workspace default
|
|
212
|
+
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
|
|
213
|
+
* @returns S3 client configuration settings
|
|
214
|
+
*/
|
|
132
215
|
export declare function denoS3LightClientSettings(s3_resource_path: string | undefined): Promise<DenoS3LightClientSettings>;
|
|
133
216
|
/**
|
|
134
217
|
* Load the content of a file stored in S3. If the s3ResourcePath is undefined, it will default to the workspace S3 resource.
|
|
@@ -215,7 +298,17 @@ export declare function getResumeEndpoints(approver?: string): Promise<{
|
|
|
215
298
|
* @returns jwt token
|
|
216
299
|
*/
|
|
217
300
|
export declare function getIdToken(audience: string, expiresIn?: number): Promise<string>;
|
|
301
|
+
/**
|
|
302
|
+
* Convert a base64-encoded string to Uint8Array
|
|
303
|
+
* @param data - Base64-encoded string
|
|
304
|
+
* @returns Decoded Uint8Array
|
|
305
|
+
*/
|
|
218
306
|
export declare function base64ToUint8Array(data: string): Uint8Array;
|
|
307
|
+
/**
|
|
308
|
+
* Convert a Uint8Array to base64-encoded string
|
|
309
|
+
* @param arrayBuffer - Uint8Array to encode
|
|
310
|
+
* @returns Base64-encoded string
|
|
311
|
+
*/
|
|
219
312
|
export declare function uint8ArrayToBase64(arrayBuffer: Uint8Array): string;
|
|
220
313
|
/**
|
|
221
314
|
* Get email from workspace username
|
|
@@ -309,4 +402,9 @@ export declare function requestInteractiveSlackApproval({ slackResourcePath, cha
|
|
|
309
402
|
* **Note:** This function requires execution within a Windmill flow or flow preview.
|
|
310
403
|
*/
|
|
311
404
|
export declare function requestInteractiveTeamsApproval({ teamName, channelName, message, approver, defaultArgsJson, dynamicEnumsJson, }: TeamsApprovalOptions): Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Parse an S3 object from URI string or record format
|
|
407
|
+
* @param s3Object - S3 object as URI string (s3://storage/key) or record
|
|
408
|
+
* @returns S3 object record with storage and s3 key
|
|
409
|
+
*/
|
|
312
410
|
export declare function parseS3Object(s3Object: S3Object): S3ObjectRecord;
|
package/dist/client.js
CHANGED
|
@@ -88,6 +88,11 @@ Object.defineProperty(exports, "WorkspaceService", { enumerable: true, get: func
|
|
|
88
88
|
Object.defineProperty(exports, "TeamsService", { enumerable: true, get: function () { return index_3.TeamsService; } });
|
|
89
89
|
exports.SHARED_FOLDER = "/shared";
|
|
90
90
|
let mockedApi = undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Initialize the Windmill client with authentication token and base URL
|
|
93
|
+
* @param token - Authentication token (defaults to WM_TOKEN env variable)
|
|
94
|
+
* @param baseUrl - API base URL (defaults to BASE_INTERNAL_URL or BASE_URL env variable)
|
|
95
|
+
*/
|
|
91
96
|
function setClient(token, baseUrl) {
|
|
92
97
|
var _a, _b, _c;
|
|
93
98
|
if (baseUrl === undefined) {
|
|
@@ -200,11 +205,25 @@ function _runScriptInternal() {
|
|
|
200
205
|
return yield waitJob(jobId, verbose);
|
|
201
206
|
});
|
|
202
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Run a script synchronously by its path and wait for the result
|
|
210
|
+
* @param path - Script path in Windmill
|
|
211
|
+
* @param args - Arguments to pass to the script
|
|
212
|
+
* @param verbose - Enable verbose logging
|
|
213
|
+
* @returns Script execution result
|
|
214
|
+
*/
|
|
203
215
|
function runScriptByPath(path_1) {
|
|
204
216
|
return __awaiter(this, arguments, void 0, function* (path, args = null, verbose = false) {
|
|
205
217
|
return _runScriptInternal(path, null, args, verbose);
|
|
206
218
|
});
|
|
207
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Run a script synchronously by its hash and wait for the result
|
|
222
|
+
* @param hash_ - Script hash in Windmill
|
|
223
|
+
* @param args - Arguments to pass to the script
|
|
224
|
+
* @param verbose - Enable verbose logging
|
|
225
|
+
* @returns Script execution result
|
|
226
|
+
*/
|
|
208
227
|
function runScriptByHash(hash_1) {
|
|
209
228
|
return __awaiter(this, arguments, void 0, function* (hash_, args = null, verbose = false) {
|
|
210
229
|
return _runScriptInternal(null, hash_, args, verbose);
|
|
@@ -242,6 +261,13 @@ function streamResult(stream) {
|
|
|
242
261
|
}
|
|
243
262
|
});
|
|
244
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Run a flow synchronously by its path and wait for the result
|
|
266
|
+
* @param path - Flow path in Windmill
|
|
267
|
+
* @param args - Arguments to pass to the flow
|
|
268
|
+
* @param verbose - Enable verbose logging
|
|
269
|
+
* @returns Flow execution result
|
|
270
|
+
*/
|
|
245
271
|
function runFlow() {
|
|
246
272
|
return __awaiter(this, arguments, void 0, function* (path = null, args = null, verbose = false) {
|
|
247
273
|
args = args || {};
|
|
@@ -252,6 +278,12 @@ function runFlow() {
|
|
|
252
278
|
return yield waitJob(jobId, verbose);
|
|
253
279
|
});
|
|
254
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Wait for a job to complete and return its result
|
|
283
|
+
* @param jobId - ID of the job to wait for
|
|
284
|
+
* @param verbose - Enable verbose logging
|
|
285
|
+
* @returns Job result when completed
|
|
286
|
+
*/
|
|
255
287
|
function waitJob(jobId_1) {
|
|
256
288
|
return __awaiter(this, arguments, void 0, function* (jobId, verbose = false) {
|
|
257
289
|
while (true) {
|
|
@@ -280,12 +312,22 @@ function waitJob(jobId_1) {
|
|
|
280
312
|
}
|
|
281
313
|
});
|
|
282
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Get the result of a completed job
|
|
317
|
+
* @param jobId - ID of the completed job
|
|
318
|
+
* @returns Job result
|
|
319
|
+
*/
|
|
283
320
|
function getResult(jobId) {
|
|
284
321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
322
|
const workspace = getWorkspace();
|
|
286
323
|
return yield index_1.JobService.getCompletedJobResult({ workspace, id: jobId });
|
|
287
324
|
});
|
|
288
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Get the result of a job if completed, or its current status
|
|
328
|
+
* @param jobId - ID of the job
|
|
329
|
+
* @returns Object with started, completed, success, and result properties
|
|
330
|
+
*/
|
|
289
331
|
function getResultMaybe(jobId) {
|
|
290
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
333
|
const workspace = getWorkspace();
|
|
@@ -303,6 +345,11 @@ function getParamNames(func) {
|
|
|
303
345
|
result = [];
|
|
304
346
|
return result;
|
|
305
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Wrap a function to execute as a Windmill task within a flow context
|
|
350
|
+
* @param f - Function to wrap as a task
|
|
351
|
+
* @returns Async wrapper function that executes as a Windmill job
|
|
352
|
+
*/
|
|
306
353
|
function task(f) {
|
|
307
354
|
return (...y) => __awaiter(this, void 0, void 0, function* () {
|
|
308
355
|
const args = {};
|
|
@@ -374,16 +421,38 @@ function _runScriptAsyncInternal() {
|
|
|
374
421
|
}).then((res) => res.text());
|
|
375
422
|
});
|
|
376
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Run a script asynchronously by its path
|
|
426
|
+
* @param path - Script path in Windmill
|
|
427
|
+
* @param args - Arguments to pass to the script
|
|
428
|
+
* @param scheduledInSeconds - Schedule execution for a future time (in seconds)
|
|
429
|
+
* @returns Job ID of the created job
|
|
430
|
+
*/
|
|
377
431
|
function runScriptByPathAsync(path_1) {
|
|
378
432
|
return __awaiter(this, arguments, void 0, function* (path, args = null, scheduledInSeconds = null) {
|
|
379
433
|
return _runScriptAsyncInternal(path, null, args, scheduledInSeconds);
|
|
380
434
|
});
|
|
381
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Run a script asynchronously by its hash
|
|
438
|
+
* @param hash_ - Script hash in Windmill
|
|
439
|
+
* @param args - Arguments to pass to the script
|
|
440
|
+
* @param scheduledInSeconds - Schedule execution for a future time (in seconds)
|
|
441
|
+
* @returns Job ID of the created job
|
|
442
|
+
*/
|
|
382
443
|
function runScriptByHashAsync(hash_1) {
|
|
383
444
|
return __awaiter(this, arguments, void 0, function* (hash_, args = null, scheduledInSeconds = null) {
|
|
384
445
|
return _runScriptAsyncInternal(null, hash_, args, scheduledInSeconds);
|
|
385
446
|
});
|
|
386
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* Run a flow asynchronously by its path
|
|
450
|
+
* @param path - Flow path in Windmill
|
|
451
|
+
* @param args - Arguments to pass to the flow
|
|
452
|
+
* @param scheduledInSeconds - Schedule execution for a future time (in seconds)
|
|
453
|
+
* @param doNotTrackInParent - If false, tracks state in parent job (only use when fully awaiting the job)
|
|
454
|
+
* @returns Job ID of the created job
|
|
455
|
+
*/
|
|
387
456
|
function runFlowAsync(path_1, args_1) {
|
|
388
457
|
return __awaiter(this, arguments, void 0, function* (path, args, scheduledInSeconds = null,
|
|
389
458
|
// can only be set to false if this the job will be fully await and not concurrent with any other job
|
|
@@ -440,6 +509,10 @@ function resolveDefaultResource(obj) {
|
|
|
440
509
|
}
|
|
441
510
|
});
|
|
442
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* Get the state file path from environment variables
|
|
514
|
+
* @returns State path string
|
|
515
|
+
*/
|
|
443
516
|
function getStatePath() {
|
|
444
517
|
var _a;
|
|
445
518
|
const state_path = (_a = getEnv("WM_STATE_PATH_NEW")) !== null && _a !== void 0 ? _a : getEnv("WM_STATE_PATH");
|
|
@@ -603,23 +676,6 @@ function getFlowUserState(key, errorIfNotPossible) {
|
|
|
603
676
|
}
|
|
604
677
|
});
|
|
605
678
|
}
|
|
606
|
-
// /**
|
|
607
|
-
// * Set the shared state
|
|
608
|
-
// * @param state state to set
|
|
609
|
-
// */
|
|
610
|
-
// export async function setSharedState(
|
|
611
|
-
// state: any,
|
|
612
|
-
// path = "state.json"
|
|
613
|
-
// ): Promise<void> {
|
|
614
|
-
// await Deno.writeTextFile(SHARED_FOLDER + "/" + path, JSON.stringify(state));
|
|
615
|
-
// }
|
|
616
|
-
// /**
|
|
617
|
-
// * Get the shared state
|
|
618
|
-
// * @param state state to set
|
|
619
|
-
// */
|
|
620
|
-
// export async function getSharedState(path = "state.json"): Promise<any> {
|
|
621
|
-
// return JSON.parse(await Deno.readTextFile(SHARED_FOLDER + "/" + path));
|
|
622
|
-
// }
|
|
623
679
|
/**
|
|
624
680
|
* Get the internal state
|
|
625
681
|
* @deprecated use getState instead
|
|
@@ -701,6 +757,11 @@ function setVariable(path, value, isSecretIfNotExist, descriptionIfNotExist) {
|
|
|
701
757
|
}
|
|
702
758
|
});
|
|
703
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* Build a PostgreSQL connection URL from a database resource
|
|
762
|
+
* @param path - Path to the database resource
|
|
763
|
+
* @returns PostgreSQL connection URL string
|
|
764
|
+
*/
|
|
704
765
|
function databaseUrlFromResource(path) {
|
|
705
766
|
return __awaiter(this, void 0, void 0, function* () {
|
|
706
767
|
const resource = yield getResource(path);
|
|
@@ -726,6 +787,11 @@ function databaseUrlFromResource(path) {
|
|
|
726
787
|
// }
|
|
727
788
|
// });
|
|
728
789
|
// }
|
|
790
|
+
/**
|
|
791
|
+
* Get S3 client settings from a resource or workspace default
|
|
792
|
+
* @param s3_resource_path - Path to S3 resource (uses workspace default if undefined)
|
|
793
|
+
* @returns S3 client configuration settings
|
|
794
|
+
*/
|
|
729
795
|
function denoS3LightClientSettings(s3_resource_path) {
|
|
730
796
|
return __awaiter(this, void 0, void 0, function* () {
|
|
731
797
|
var _a;
|
|
@@ -959,9 +1025,19 @@ function getIdToken(audience, expiresIn) {
|
|
|
959
1025
|
});
|
|
960
1026
|
});
|
|
961
1027
|
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Convert a base64-encoded string to Uint8Array
|
|
1030
|
+
* @param data - Base64-encoded string
|
|
1031
|
+
* @returns Decoded Uint8Array
|
|
1032
|
+
*/
|
|
962
1033
|
function base64ToUint8Array(data) {
|
|
963
1034
|
return Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
|
|
964
1035
|
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Convert a Uint8Array to base64-encoded string
|
|
1038
|
+
* @param arrayBuffer - Uint8Array to encode
|
|
1039
|
+
* @returns Base64-encoded string
|
|
1040
|
+
*/
|
|
965
1041
|
function uint8ArrayToBase64(arrayBuffer) {
|
|
966
1042
|
let base64 = "";
|
|
967
1043
|
const encodings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -1194,6 +1270,11 @@ function parseResourceSyntax(s) {
|
|
|
1194
1270
|
if (s === null || s === void 0 ? void 0 : s.startsWith("res://"))
|
|
1195
1271
|
return s.substring(6);
|
|
1196
1272
|
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Parse an S3 object from URI string or record format
|
|
1275
|
+
* @param s3Object - S3 object as URI string (s3://storage/key) or record
|
|
1276
|
+
* @returns S3 object record with storage and s3 key
|
|
1277
|
+
*/
|
|
1197
1278
|
function parseS3Object(s3Object) {
|
|
1198
1279
|
var _a;
|
|
1199
1280
|
if (typeof s3Object === "object")
|
package/dist/core/OpenAPI.js
CHANGED
package/dist/s3Types.d.ts
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3 object representation, either as a URI string or a record object
|
|
3
|
+
*/
|
|
1
4
|
export type S3Object = S3ObjectURI | S3ObjectRecord;
|
|
5
|
+
/**
|
|
6
|
+
* S3 object URI in the format `s3://storage/key`
|
|
7
|
+
*/
|
|
2
8
|
export type S3ObjectURI = `s3://${string}/${string}`;
|
|
9
|
+
/**
|
|
10
|
+
* S3 object record with file key, optional storage identifier, and optional presigned token
|
|
11
|
+
*/
|
|
3
12
|
export type S3ObjectRecord = {
|
|
13
|
+
/** File key/path in S3 bucket */
|
|
4
14
|
s3: string;
|
|
15
|
+
/** Storage backend identifier */
|
|
5
16
|
storage?: string;
|
|
17
|
+
/** Presigned URL query string for public access */
|
|
6
18
|
presigned?: string;
|
|
7
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* S3 client configuration settings for Deno S3 light client
|
|
22
|
+
*/
|
|
8
23
|
export type DenoS3LightClientSettings = {
|
|
24
|
+
/** S3 endpoint URL */
|
|
9
25
|
endPoint: string;
|
|
26
|
+
/** AWS region */
|
|
10
27
|
region: string;
|
|
28
|
+
/** Bucket name */
|
|
11
29
|
bucket?: string;
|
|
30
|
+
/** Use HTTPS connection */
|
|
12
31
|
useSSL?: boolean;
|
|
32
|
+
/** AWS access key */
|
|
13
33
|
accessKey?: string;
|
|
34
|
+
/** AWS secret key */
|
|
14
35
|
secretKey?: string;
|
|
36
|
+
/** Use path-style URLs instead of virtual-hosted style */
|
|
15
37
|
pathStyle?: boolean;
|
|
16
38
|
};
|
package/dist/sqlUtils.d.ts
CHANGED
|
@@ -3,16 +3,37 @@ type FetchParams<ResultCollectionT extends ResultCollection> = {
|
|
|
3
3
|
resultCollection?: ResultCollectionT;
|
|
4
4
|
};
|
|
5
5
|
type SqlResult<ResultCollectionT extends ResultCollection> = ResultCollectionT extends "last_statement_first_row" ? object : ResultCollectionT extends "all_statements_first_row" ? object[] : ResultCollectionT extends "last_statement_all_rows" ? object[] : ResultCollectionT extends "all_statements_all_rows" ? object[][] : ResultCollectionT extends "last_statement_all_rows_scalar" ? any[] : ResultCollectionT extends "all_statements_all_rows_scalar" ? any[][] : ResultCollectionT extends "last_statement_first_row_scalar" ? any : ResultCollectionT extends "all_statements_first_row_scalar" ? any[] : unknown;
|
|
6
|
+
/**
|
|
7
|
+
* SQL statement object with query content, arguments, and execution methods
|
|
8
|
+
*/
|
|
6
9
|
export type SqlStatement = {
|
|
10
|
+
/** Raw SQL content with formatted arguments */
|
|
7
11
|
content: string;
|
|
12
|
+
/** Argument values keyed by parameter name */
|
|
8
13
|
args: Record<string, any>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute the SQL query and return results
|
|
16
|
+
* @param params - Optional parameters including result collection mode
|
|
17
|
+
* @returns Query results based on the result collection mode
|
|
18
|
+
*/
|
|
9
19
|
fetch<ResultCollectionT extends ResultCollection = "last_statement_all_rows">(params?: FetchParams<ResultCollectionT | ResultCollection>): Promise<SqlResult<ResultCollectionT>>;
|
|
20
|
+
/**
|
|
21
|
+
* Execute the SQL query and return only the first row
|
|
22
|
+
* @param params - Optional parameters
|
|
23
|
+
* @returns First row of the query result
|
|
24
|
+
*/
|
|
10
25
|
fetchOne(params?: Omit<FetchParams<"last_statement_first_row">, "resultCollection">): Promise<SqlResult<"last_statement_first_row">>;
|
|
11
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Template tag function for creating SQL statements with parameterized values
|
|
29
|
+
*/
|
|
12
30
|
export interface SqlTemplateFunction {
|
|
13
31
|
(strings: TemplateStringsArray, ...values: any[]): SqlStatement;
|
|
14
32
|
}
|
|
15
33
|
/**
|
|
34
|
+
* Create a SQL template function for PostgreSQL/datatable queries
|
|
35
|
+
* @param name - Database/datatable name (default: "main")
|
|
36
|
+
* @returns SQL template function for building parameterized queries
|
|
16
37
|
* @example
|
|
17
38
|
* let sql = wmill.datatable()
|
|
18
39
|
* let name = 'Robin'
|
|
@@ -24,6 +45,9 @@ export interface SqlTemplateFunction {
|
|
|
24
45
|
*/
|
|
25
46
|
export declare function datatable(name?: string): SqlTemplateFunction;
|
|
26
47
|
/**
|
|
48
|
+
* Create a SQL template function for DuckDB/ducklake queries
|
|
49
|
+
* @param name - DuckDB database name (default: "main")
|
|
50
|
+
* @returns SQL template function for building parameterized queries
|
|
27
51
|
* @example
|
|
28
52
|
* let sql = wmill.ducklake()
|
|
29
53
|
* let name = 'Robin'
|
package/dist/sqlUtils.js
CHANGED
|
@@ -13,6 +13,9 @@ exports.datatable = datatable;
|
|
|
13
13
|
exports.ducklake = ducklake;
|
|
14
14
|
const client_1 = require("./client");
|
|
15
15
|
/**
|
|
16
|
+
* Create a SQL template function for PostgreSQL/datatable queries
|
|
17
|
+
* @param name - Database/datatable name (default: "main")
|
|
18
|
+
* @returns SQL template function for building parameterized queries
|
|
16
19
|
* @example
|
|
17
20
|
* let sql = wmill.datatable()
|
|
18
21
|
* let name = 'Robin'
|
|
@@ -26,6 +29,9 @@ function datatable(name = "main") {
|
|
|
26
29
|
return sqlProviderImpl(name, "datatable");
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
32
|
+
* Create a SQL template function for DuckDB/ducklake queries
|
|
33
|
+
* @param name - DuckDB database name (default: "main")
|
|
34
|
+
* @returns SQL template function for building parameterized queries
|
|
29
35
|
* @example
|
|
30
36
|
* let sql = wmill.ducklake()
|
|
31
37
|
* let name = 'Robin'
|