@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.
Files changed (81) hide show
  1. package/README.md +247 -0
  2. package/dist/_official/index.d.mts +2 -0
  3. package/dist/_official/index.mjs +3 -0
  4. package/dist/_runtime/index.d.mts +1 -0
  5. package/dist/_runtime/index.mjs +1 -0
  6. package/dist/accounts.d.mts +40 -0
  7. package/dist/accounts.mjs +51 -0
  8. package/dist/bulk.d.mts +71 -0
  9. package/dist/bulk.mjs +65 -0
  10. package/dist/catalog.d.mts +144 -0
  11. package/dist/catalog.mjs +158 -0
  12. package/dist/client.d.mts +44 -0
  13. package/dist/client.mjs +273 -0
  14. package/dist/common-BnKTPQXc.mjs +92 -0
  15. package/dist/connection.d.mts +2 -0
  16. package/dist/connection.mjs +3 -0
  17. package/dist/databases.d.mts +2 -0
  18. package/dist/databases.mjs +3 -0
  19. package/dist/errors-DKnc9o_a.mjs +95 -0
  20. package/dist/events.d.mts +382 -0
  21. package/dist/events.mjs +291 -0
  22. package/dist/file-formats.d.mts +39 -0
  23. package/dist/file-formats.mjs +48 -0
  24. package/dist/functions.d.mts +53 -0
  25. package/dist/functions.mjs +56 -0
  26. package/dist/grants.d.mts +93 -0
  27. package/dist/grants.mjs +102 -0
  28. package/dist/index.d.mts +1 -0
  29. package/dist/index.mjs +1 -0
  30. package/dist/integration-CCWMSTlO.d.mts +170 -0
  31. package/dist/integration-Dptv8L0L.mjs +207 -0
  32. package/dist/org-admin.d.mts +80 -0
  33. package/dist/org-admin.mjs +79 -0
  34. package/dist/pipes.d.mts +119 -0
  35. package/dist/pipes.mjs +106 -0
  36. package/dist/procedures.d.mts +61 -0
  37. package/dist/procedures.mjs +79 -0
  38. package/dist/results.d.mts +16 -0
  39. package/dist/results.mjs +64 -0
  40. package/dist/retry-0hMfb8cC.mjs +164 -0
  41. package/dist/retry-w7cTp1QL.d.mts +10 -0
  42. package/dist/roles.d.mts +60 -0
  43. package/dist/roles.mjs +74 -0
  44. package/dist/rows.d.mts +106 -0
  45. package/dist/rows.mjs +223 -0
  46. package/dist/schemas/index.d.mts +2 -0
  47. package/dist/schemas/index.mjs +4 -0
  48. package/dist/schemas-catalog.d.mts +2 -0
  49. package/dist/schemas-catalog.mjs +3 -0
  50. package/dist/shares.d.mts +56 -0
  51. package/dist/shares.mjs +77 -0
  52. package/dist/sql-options-2k5xQ-oS.d.mts +32 -0
  53. package/dist/sql-options-DI-OmLU6.mjs +79 -0
  54. package/dist/sql-safety-CywdR3EP.mjs +56 -0
  55. package/dist/sql.d.mts +84 -0
  56. package/dist/sql.mjs +209 -0
  57. package/dist/stages.d.mts +64 -0
  58. package/dist/stages.mjs +81 -0
  59. package/dist/statements-B2ThF_4b.mjs +81 -0
  60. package/dist/statements-DJL0qVNA.d.mts +238 -0
  61. package/dist/status-page.d.mts +510 -0
  62. package/dist/status-page.mjs +261 -0
  63. package/dist/streaming.d.mts +70 -0
  64. package/dist/streaming.mjs +56 -0
  65. package/dist/streams.d.mts +71 -0
  66. package/dist/streams.mjs +78 -0
  67. package/dist/tables.d.mts +2 -0
  68. package/dist/tables.mjs +3 -0
  69. package/dist/tasks.d.mts +79 -0
  70. package/dist/tasks.mjs +104 -0
  71. package/dist/triggers.d.mts +578 -0
  72. package/dist/triggers.mjs +1363 -0
  73. package/dist/users.d.mts +61 -0
  74. package/dist/users.mjs +67 -0
  75. package/dist/verification.d.mts +201 -0
  76. package/dist/verification.mjs +512 -0
  77. package/dist/views.d.mts +2 -0
  78. package/dist/views.mjs +3 -0
  79. package/dist/warehouses.d.mts +68 -0
  80. package/dist/warehouses.mjs +101 -0
  81. 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 };