@keystrokehq/snowflake 0.0.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/README.md +247 -0
- package/dist/_official/index.d.mts +2 -0
- package/dist/_official/index.mjs +3 -0
- package/dist/_runtime/index.d.mts +1 -0
- package/dist/_runtime/index.mjs +1 -0
- package/dist/accounts.d.mts +40 -0
- package/dist/accounts.mjs +51 -0
- package/dist/bulk.d.mts +71 -0
- package/dist/bulk.mjs +65 -0
- package/dist/catalog.d.mts +144 -0
- package/dist/catalog.mjs +158 -0
- package/dist/client.d.mts +44 -0
- package/dist/client.mjs +273 -0
- package/dist/common-BnKTPQXc.mjs +92 -0
- package/dist/connection.d.mts +2 -0
- package/dist/connection.mjs +3 -0
- package/dist/databases.d.mts +2 -0
- package/dist/databases.mjs +3 -0
- package/dist/errors-DKnc9o_a.mjs +95 -0
- package/dist/events.d.mts +382 -0
- package/dist/events.mjs +291 -0
- package/dist/file-formats.d.mts +39 -0
- package/dist/file-formats.mjs +48 -0
- package/dist/functions.d.mts +53 -0
- package/dist/functions.mjs +56 -0
- package/dist/grants.d.mts +93 -0
- package/dist/grants.mjs +102 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/integration-CCWMSTlO.d.mts +170 -0
- package/dist/integration-Dptv8L0L.mjs +207 -0
- package/dist/org-admin.d.mts +80 -0
- package/dist/org-admin.mjs +79 -0
- package/dist/pipes.d.mts +119 -0
- package/dist/pipes.mjs +106 -0
- package/dist/procedures.d.mts +61 -0
- package/dist/procedures.mjs +79 -0
- package/dist/results.d.mts +16 -0
- package/dist/results.mjs +64 -0
- package/dist/retry-0hMfb8cC.mjs +164 -0
- package/dist/retry-w7cTp1QL.d.mts +10 -0
- package/dist/roles.d.mts +60 -0
- package/dist/roles.mjs +74 -0
- package/dist/rows.d.mts +106 -0
- package/dist/rows.mjs +223 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +4 -0
- package/dist/schemas-catalog.d.mts +2 -0
- package/dist/schemas-catalog.mjs +3 -0
- package/dist/shares.d.mts +56 -0
- package/dist/shares.mjs +77 -0
- package/dist/sql-options-2k5xQ-oS.d.mts +32 -0
- package/dist/sql-options-DI-OmLU6.mjs +79 -0
- package/dist/sql-safety-CywdR3EP.mjs +56 -0
- package/dist/sql.d.mts +84 -0
- package/dist/sql.mjs +209 -0
- package/dist/stages.d.mts +64 -0
- package/dist/stages.mjs +81 -0
- package/dist/statements-B2ThF_4b.mjs +81 -0
- package/dist/statements-DJL0qVNA.d.mts +238 -0
- package/dist/status-page.d.mts +510 -0
- package/dist/status-page.mjs +261 -0
- package/dist/streaming.d.mts +70 -0
- package/dist/streaming.mjs +56 -0
- package/dist/streams.d.mts +71 -0
- package/dist/streams.mjs +78 -0
- package/dist/tables.d.mts +2 -0
- package/dist/tables.mjs +3 -0
- package/dist/tasks.d.mts +79 -0
- package/dist/tasks.mjs +104 -0
- package/dist/triggers.d.mts +578 -0
- package/dist/triggers.mjs +1363 -0
- package/dist/users.d.mts +61 -0
- package/dist/users.mjs +67 -0
- package/dist/verification.d.mts +201 -0
- package/dist/verification.mjs +512 -0
- package/dist/views.d.mts +2 -0
- package/dist/views.mjs +3 -0
- package/dist/warehouses.d.mts +68 -0
- package/dist/warehouses.mjs +101 -0
- package/package.json +190 -0
package/dist/tasks.mjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { executeSql } from "./sql.mjs";
|
|
2
|
+
import { a as quoteLiteral, t as buildFqn } from "./sql-safety-CywdR3EP.mjs";
|
|
3
|
+
import { t as formatOptions } from "./sql-options-DI-OmLU6.mjs";
|
|
4
|
+
import { showTasks } from "./catalog.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/tasks.ts
|
|
7
|
+
function taskFqn(ref) {
|
|
8
|
+
return buildFqn(ref.database, ref.schema, ref.name);
|
|
9
|
+
}
|
|
10
|
+
async function createTask(client, options) {
|
|
11
|
+
const prefix = `CREATE${options.orReplace ? " OR REPLACE" : ""} TASK${options.ifNotExists ? " IF NOT EXISTS" : ""}`;
|
|
12
|
+
const copyGrants = options.copyGrants ? " COPY GRANTS" : "";
|
|
13
|
+
const body = options.options && Object.keys(options.options).length > 0 ? ` ${formatOptions(options.options)}` : "";
|
|
14
|
+
const after = options.after && options.after.length > 0 ? ` AFTER ${options.after.map(taskFqn).join(", ")}` : "";
|
|
15
|
+
const when = options.when ? ` WHEN ${options.when}` : "";
|
|
16
|
+
const comment = options.comment ? ` COMMENT = ${quoteLiteral(options.comment)}` : "";
|
|
17
|
+
await executeSql(client, {
|
|
18
|
+
statement: `${prefix} ${taskFqn(options)}${copyGrants}${body}${after}${when}${comment} AS ${options.as}`,
|
|
19
|
+
warehouse: options.warehouse,
|
|
20
|
+
role: options.role
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function alterTask(client, options) {
|
|
24
|
+
let tail;
|
|
25
|
+
if (options.rename) tail = `RENAME TO ${taskFqn(options.rename)}`;
|
|
26
|
+
else if (options.addAfter && options.addAfter.length > 0) tail = `ADD AFTER ${options.addAfter.map(taskFqn).join(", ")}`;
|
|
27
|
+
else if (options.removeAfter && options.removeAfter.length > 0) tail = `REMOVE AFTER ${options.removeAfter.map(taskFqn).join(", ")}`;
|
|
28
|
+
else if (options.modifyAs !== void 0) tail = `MODIFY AS ${options.modifyAs}`;
|
|
29
|
+
else if (options.modifyWhen !== void 0) tail = `MODIFY WHEN ${options.modifyWhen}`;
|
|
30
|
+
else if (options.set && Object.keys(options.set).length > 0) tail = `SET ${formatOptions(options.set)}`;
|
|
31
|
+
else if (options.unset && options.unset.length > 0) tail = `UNSET ${options.unset.map((k) => k.toUpperCase()).join(", ")}`;
|
|
32
|
+
else if (options.comment !== void 0) tail = `SET COMMENT = ${quoteLiteral(options.comment)}`;
|
|
33
|
+
else throw new Error("alterTask requires one of: rename / addAfter / removeAfter / modifyAs / modifyWhen / set / unset / comment");
|
|
34
|
+
await executeSql(client, {
|
|
35
|
+
statement: `ALTER TASK${options.ifExists ? " IF EXISTS" : ""} ${taskFqn(options)} ${tail}`,
|
|
36
|
+
warehouse: options.warehouse,
|
|
37
|
+
role: options.role
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function dropTask(client, options) {
|
|
41
|
+
await executeSql(client, {
|
|
42
|
+
statement: `DROP TASK${options.ifExists ? " IF EXISTS" : ""} ${taskFqn(options)}`,
|
|
43
|
+
warehouse: options.warehouse,
|
|
44
|
+
role: options.role
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function describeTask(client, options) {
|
|
48
|
+
return (await executeSql(client, {
|
|
49
|
+
statement: `DESCRIBE TASK ${taskFqn(options)}`,
|
|
50
|
+
warehouse: options.warehouse,
|
|
51
|
+
role: options.role
|
|
52
|
+
})).rows;
|
|
53
|
+
}
|
|
54
|
+
async function executeTask(client, options) {
|
|
55
|
+
const suffix = options.retryLast ? " RETRY LAST" : "";
|
|
56
|
+
await executeSql(client, {
|
|
57
|
+
statement: `EXECUTE TASK ${taskFqn(options)}${suffix}`,
|
|
58
|
+
warehouse: options.warehouse,
|
|
59
|
+
role: options.role
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function resumeTask(client, options) {
|
|
63
|
+
await executeSql(client, {
|
|
64
|
+
statement: `ALTER TASK${options.ifExists ? " IF EXISTS" : ""} ${taskFqn(options)} RESUME`,
|
|
65
|
+
warehouse: options.warehouse,
|
|
66
|
+
role: options.role
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function suspendTask(client, options) {
|
|
70
|
+
await executeSql(client, {
|
|
71
|
+
statement: `ALTER TASK${options.ifExists ? " IF EXISTS" : ""} ${taskFqn(options)} SUSPEND`,
|
|
72
|
+
warehouse: options.warehouse,
|
|
73
|
+
role: options.role
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function renderTimestampArg(value) {
|
|
77
|
+
return value ? `TO_TIMESTAMP_LTZ(${quoteLiteral(value)})` : "NULL";
|
|
78
|
+
}
|
|
79
|
+
async function showTaskHistory(client, options = {}) {
|
|
80
|
+
const args = [];
|
|
81
|
+
if (options.scheduledTimeRangeStart !== void 0) args.push(`SCHEDULED_TIME_RANGE_START => ${renderTimestampArg(options.scheduledTimeRangeStart)}`);
|
|
82
|
+
if (options.scheduledTimeRangeEnd !== void 0) args.push(`SCHEDULED_TIME_RANGE_END => ${renderTimestampArg(options.scheduledTimeRangeEnd)}`);
|
|
83
|
+
if (options.resultLimit !== void 0) args.push(`RESULT_LIMIT => ${options.resultLimit}`);
|
|
84
|
+
if (options.taskName) args.push(`TASK_NAME => ${quoteLiteral(taskFqn(options.taskName))}`);
|
|
85
|
+
if (options.rootTaskName) args.push(`ROOT_TASK_NAME => ${quoteLiteral(taskFqn(options.rootTaskName))}`);
|
|
86
|
+
if (options.errorOnly !== void 0) args.push(`ERROR_ONLY => ${options.errorOnly ? "TRUE" : "FALSE"}`);
|
|
87
|
+
return (await executeSql(client, {
|
|
88
|
+
statement: `SELECT * FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY(${args.join(", ")}))`,
|
|
89
|
+
warehouse: options.warehouse,
|
|
90
|
+
role: options.role
|
|
91
|
+
})).rows;
|
|
92
|
+
}
|
|
93
|
+
async function showTaskDependents(client, options) {
|
|
94
|
+
const args = [`TASK_NAME => ${quoteLiteral(taskFqn(options))}`];
|
|
95
|
+
if (options.recursive !== void 0) args.push(`RECURSIVE => ${options.recursive ? "TRUE" : "FALSE"}`);
|
|
96
|
+
return (await executeSql(client, {
|
|
97
|
+
statement: `SELECT * FROM TABLE(INFORMATION_SCHEMA.TASK_DEPENDENTS(${args.join(", ")}))`,
|
|
98
|
+
warehouse: options.warehouse,
|
|
99
|
+
role: options.role
|
|
100
|
+
})).rows;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { alterTask, createTask, describeTask, dropTask, executeTask, resumeTask, showTaskDependents, showTaskHistory, showTasks, suspendTask };
|