@keystrokehq/snowflake 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +9 -233
- package/package.json +39 -171
- package/dist/accounts/index.d.mts +0 -40
- package/dist/accounts/index.mjs +0 -51
- package/dist/bulk/index.d.mts +0 -71
- package/dist/bulk/index.mjs +0 -65
- package/dist/catalog/index.d.mts +0 -144
- package/dist/catalog/index.mjs +0 -158
- package/dist/client/index.d.mts +0 -44
- package/dist/client/index.mjs +0 -273
- package/dist/common-DfpCwJx5.mjs +0 -92
- package/dist/credential-sets/index.d.mts +0 -3
- package/dist/credential-sets/index.mjs +0 -4
- package/dist/databases/index.d.mts +0 -2
- package/dist/databases/index.mjs +0 -3
- package/dist/errors-60AsF7Su.mjs +0 -95
- package/dist/events/index.d.mts +0 -382
- package/dist/events/index.mjs +0 -291
- package/dist/file-formats/index.d.mts +0 -39
- package/dist/file-formats/index.mjs +0 -48
- package/dist/functions/index.d.mts +0 -53
- package/dist/functions/index.mjs +0 -56
- package/dist/grants/index.d.mts +0 -93
- package/dist/grants/index.mjs +0 -102
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +0 -6
- package/dist/operations/index.d.mts +0 -1
- package/dist/operations/index.mjs +0 -1
- package/dist/org-admin/index.d.mts +0 -80
- package/dist/org-admin/index.mjs +0 -79
- package/dist/pipes/index.d.mts +0 -119
- package/dist/pipes/index.mjs +0 -106
- package/dist/procedures/index.d.mts +0 -61
- package/dist/procedures/index.mjs +0 -79
- package/dist/results/index.d.mts +0 -16
- package/dist/results/index.mjs +0 -64
- package/dist/retry-B4-9MZIp.mjs +0 -164
- package/dist/retry-w7cTp1QL.d.mts +0 -10
- package/dist/roles/index.d.mts +0 -60
- package/dist/roles/index.mjs +0 -74
- package/dist/rows/index.d.mts +0 -106
- package/dist/rows/index.mjs +0 -223
- package/dist/schemas/index.d.mts +0 -2
- package/dist/schemas/index.mjs +0 -4
- package/dist/schemas-catalog/index.d.mts +0 -2
- package/dist/schemas-catalog/index.mjs +0 -3
- package/dist/shares/index.d.mts +0 -56
- package/dist/shares/index.mjs +0 -77
- package/dist/snowflake-s3-sns-webhook.credential-set-D6bLAWy5.d.mts +0 -50
- package/dist/snowflake-s3-sns-webhook.credential-set-DzR7oWNK.mjs +0 -44
- package/dist/snowflake.credential-set-BxT7Gf3A.d.mts +0 -114
- package/dist/snowflake.credential-set-DE3gXf-a.mjs +0 -106
- package/dist/sql/index.d.mts +0 -84
- package/dist/sql/index.mjs +0 -209
- package/dist/sql-options-2k5xQ-oS.d.mts +0 -32
- package/dist/sql-options-D6GEa21F.mjs +0 -79
- package/dist/sql-safety-BZpAPsq6.mjs +0 -56
- package/dist/stages/index.d.mts +0 -64
- package/dist/stages/index.mjs +0 -81
- package/dist/statements-BumhMhN4.mjs +0 -81
- package/dist/statements-DJL0qVNA.d.mts +0 -238
- package/dist/status-page/index.d.mts +0 -510
- package/dist/status-page/index.mjs +0 -261
- package/dist/streaming/index.d.mts +0 -70
- package/dist/streaming/index.mjs +0 -56
- package/dist/streams/index.d.mts +0 -71
- package/dist/streams/index.mjs +0 -78
- package/dist/tables/index.d.mts +0 -2
- package/dist/tables/index.mjs +0 -3
- package/dist/tasks/index.d.mts +0 -79
- package/dist/tasks/index.mjs +0 -104
- package/dist/triggers/index.d.mts +0 -381
- package/dist/triggers/index.mjs +0 -1100
- package/dist/users/index.d.mts +0 -61
- package/dist/users/index.mjs +0 -67
- package/dist/verification/index.d.mts +0 -201
- package/dist/verification/index.mjs +0 -512
- package/dist/views/index.d.mts +0 -2
- package/dist/views/index.mjs +0 -3
- package/dist/warehouses/index.d.mts +0 -68
- package/dist/warehouses/index.mjs +0 -101
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
//#region src/status-page/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* Snowflake status-page client (status.snowflake.com — Statuspage.io surface).
|
|
6
|
-
*
|
|
7
|
-
* Covers PLAN §6.20 (7 actions). These endpoints are public, require no
|
|
8
|
-
* credentials, and live on a completely different host from the SQL API,
|
|
9
|
-
* so the helpers are independent of `SnowflakeClient`. Every function
|
|
10
|
-
* takes a standalone options bag (`fetchImpl`, `baseUrl`, `timeoutMs`)
|
|
11
|
-
* so callers can point the integration at a mirror, a fixture, or a
|
|
12
|
-
* proxy without rebuilding a full Snowflake client.
|
|
13
|
-
*
|
|
14
|
-
* Response shapes are validated with Zod against the documented
|
|
15
|
-
* Statuspage.io JSON contract; extra fields are allowed (via `catchall`)
|
|
16
|
-
* so new optional metadata does not break the client.
|
|
17
|
-
*/
|
|
18
|
-
const DEFAULT_BASE_URL = "https://status.snowflake.com";
|
|
19
|
-
const DEFAULT_TIMEOUT_MS = 15e3;
|
|
20
|
-
const statusPagePageSchema = z.object({
|
|
21
|
-
id: z.string(),
|
|
22
|
-
name: z.string(),
|
|
23
|
-
url: z.string(),
|
|
24
|
-
time_zone: z.string().optional(),
|
|
25
|
-
updated_at: z.string()
|
|
26
|
-
}).catchall(z.unknown());
|
|
27
|
-
const statusPageIndicatorSchema = z.enum([
|
|
28
|
-
"none",
|
|
29
|
-
"minor",
|
|
30
|
-
"major",
|
|
31
|
-
"critical",
|
|
32
|
-
"maintenance"
|
|
33
|
-
]);
|
|
34
|
-
const statusPageOverallStatusSchema = z.object({
|
|
35
|
-
indicator: statusPageIndicatorSchema,
|
|
36
|
-
description: z.string()
|
|
37
|
-
}).catchall(z.unknown());
|
|
38
|
-
const statusPageComponentStatusSchema = z.enum([
|
|
39
|
-
"operational",
|
|
40
|
-
"degraded_performance",
|
|
41
|
-
"partial_outage",
|
|
42
|
-
"major_outage",
|
|
43
|
-
"under_maintenance"
|
|
44
|
-
]);
|
|
45
|
-
const statusPageComponentSchema = z.object({
|
|
46
|
-
id: z.string(),
|
|
47
|
-
name: z.string(),
|
|
48
|
-
status: statusPageComponentStatusSchema,
|
|
49
|
-
created_at: z.string(),
|
|
50
|
-
updated_at: z.string(),
|
|
51
|
-
position: z.number().optional(),
|
|
52
|
-
description: z.string().nullable().optional(),
|
|
53
|
-
showcase: z.boolean().optional(),
|
|
54
|
-
group_id: z.string().nullable().optional(),
|
|
55
|
-
page_id: z.string().optional(),
|
|
56
|
-
group: z.boolean().optional(),
|
|
57
|
-
only_show_if_degraded: z.boolean().optional(),
|
|
58
|
-
components: z.array(z.string()).optional()
|
|
59
|
-
}).catchall(z.unknown());
|
|
60
|
-
const statusPageIncidentUpdateSchema = z.object({
|
|
61
|
-
id: z.string(),
|
|
62
|
-
status: z.string(),
|
|
63
|
-
body: z.string(),
|
|
64
|
-
created_at: z.string(),
|
|
65
|
-
updated_at: z.string(),
|
|
66
|
-
display_at: z.string().optional(),
|
|
67
|
-
affected_components: z.array(z.object({
|
|
68
|
-
code: z.string().optional(),
|
|
69
|
-
name: z.string().optional(),
|
|
70
|
-
old_status: z.string().optional(),
|
|
71
|
-
new_status: z.string().optional()
|
|
72
|
-
}).catchall(z.unknown())).optional()
|
|
73
|
-
}).catchall(z.unknown());
|
|
74
|
-
const statusPageIncidentSchema = z.object({
|
|
75
|
-
id: z.string(),
|
|
76
|
-
name: z.string(),
|
|
77
|
-
status: z.string(),
|
|
78
|
-
impact: z.string().optional(),
|
|
79
|
-
created_at: z.string(),
|
|
80
|
-
updated_at: z.string(),
|
|
81
|
-
monitoring_at: z.string().nullable().optional(),
|
|
82
|
-
resolved_at: z.string().nullable().optional(),
|
|
83
|
-
shortlink: z.string().optional(),
|
|
84
|
-
started_at: z.string().optional(),
|
|
85
|
-
page_id: z.string().optional(),
|
|
86
|
-
incident_updates: z.array(statusPageIncidentUpdateSchema).optional(),
|
|
87
|
-
components: z.array(statusPageComponentSchema).optional()
|
|
88
|
-
}).catchall(z.unknown());
|
|
89
|
-
const statusPageScheduledMaintenanceSchema = z.object({
|
|
90
|
-
id: z.string(),
|
|
91
|
-
name: z.string(),
|
|
92
|
-
status: z.string(),
|
|
93
|
-
impact: z.string().optional(),
|
|
94
|
-
created_at: z.string(),
|
|
95
|
-
updated_at: z.string(),
|
|
96
|
-
monitoring_at: z.string().nullable().optional(),
|
|
97
|
-
resolved_at: z.string().nullable().optional(),
|
|
98
|
-
scheduled_for: z.string(),
|
|
99
|
-
scheduled_until: z.string(),
|
|
100
|
-
shortlink: z.string().optional(),
|
|
101
|
-
started_at: z.string().nullable().optional(),
|
|
102
|
-
page_id: z.string().optional(),
|
|
103
|
-
incident_updates: z.array(statusPageIncidentUpdateSchema).optional(),
|
|
104
|
-
components: z.array(statusPageComponentSchema).optional()
|
|
105
|
-
}).catchall(z.unknown());
|
|
106
|
-
const summaryResponseSchema = z.object({
|
|
107
|
-
page: statusPagePageSchema,
|
|
108
|
-
status: statusPageOverallStatusSchema,
|
|
109
|
-
components: z.array(statusPageComponentSchema),
|
|
110
|
-
incidents: z.array(statusPageIncidentSchema),
|
|
111
|
-
scheduled_maintenances: z.array(statusPageScheduledMaintenanceSchema)
|
|
112
|
-
}).catchall(z.unknown());
|
|
113
|
-
const rollupResponseSchema = z.object({
|
|
114
|
-
page: statusPagePageSchema,
|
|
115
|
-
status: statusPageOverallStatusSchema
|
|
116
|
-
}).catchall(z.unknown());
|
|
117
|
-
const componentsResponseSchema = z.object({
|
|
118
|
-
page: statusPagePageSchema,
|
|
119
|
-
components: z.array(statusPageComponentSchema)
|
|
120
|
-
}).catchall(z.unknown());
|
|
121
|
-
const incidentsResponseSchema = z.object({
|
|
122
|
-
page: statusPagePageSchema,
|
|
123
|
-
incidents: z.array(statusPageIncidentSchema)
|
|
124
|
-
}).catchall(z.unknown());
|
|
125
|
-
const maintenancesResponseSchema = z.object({
|
|
126
|
-
page: statusPagePageSchema,
|
|
127
|
-
scheduled_maintenances: z.array(statusPageScheduledMaintenanceSchema)
|
|
128
|
-
}).catchall(z.unknown());
|
|
129
|
-
/**
|
|
130
|
-
* Error thrown when the status-page endpoint returns a non-2xx response or
|
|
131
|
-
* a body that fails Zod validation.
|
|
132
|
-
*/
|
|
133
|
-
var SnowflakeStatusPageError = class extends Error {
|
|
134
|
-
name = "SnowflakeStatusPageError";
|
|
135
|
-
status;
|
|
136
|
-
url;
|
|
137
|
-
body;
|
|
138
|
-
constructor(input) {
|
|
139
|
-
super(input.message, input.cause !== void 0 ? { cause: input.cause } : void 0);
|
|
140
|
-
this.status = input.status;
|
|
141
|
-
this.url = input.url;
|
|
142
|
-
this.body = input.body;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
function joinPath(baseUrl, path) {
|
|
146
|
-
return `${baseUrl.replace(/\/+$/u, "")}${path.startsWith("/") ? path : `/${path}`}`;
|
|
147
|
-
}
|
|
148
|
-
function composeSignal(timeoutMs, external) {
|
|
149
|
-
const controller = new AbortController();
|
|
150
|
-
const onExternalAbort = () => controller.abort(external?.reason);
|
|
151
|
-
if (external) if (external.aborted) controller.abort(external.reason);
|
|
152
|
-
else external.addEventListener("abort", onExternalAbort, { once: true });
|
|
153
|
-
const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error(`status-page request timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
154
|
-
return {
|
|
155
|
-
signal: controller.signal,
|
|
156
|
-
cleanup: () => {
|
|
157
|
-
clearTimeout(timer);
|
|
158
|
-
if (external) external.removeEventListener("abort", onExternalAbort);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
async function fetchJson(path, schema, options) {
|
|
163
|
-
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
164
|
-
const fetchImpl = options.fetchImpl ?? fetch;
|
|
165
|
-
const url = joinPath(baseUrl, path);
|
|
166
|
-
const { signal, cleanup } = composeSignal(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, options.signal);
|
|
167
|
-
let response;
|
|
168
|
-
try {
|
|
169
|
-
response = await fetchImpl(url, {
|
|
170
|
-
method: "GET",
|
|
171
|
-
headers: {
|
|
172
|
-
Accept: "application/json",
|
|
173
|
-
...options.headers
|
|
174
|
-
},
|
|
175
|
-
signal
|
|
176
|
-
});
|
|
177
|
-
} catch (cause) {
|
|
178
|
-
throw new SnowflakeStatusPageError({
|
|
179
|
-
message: `status-page GET ${url} failed before reading a response`,
|
|
180
|
-
status: 0,
|
|
181
|
-
url,
|
|
182
|
-
cause
|
|
183
|
-
});
|
|
184
|
-
} finally {
|
|
185
|
-
cleanup();
|
|
186
|
-
}
|
|
187
|
-
if (!response.ok) {
|
|
188
|
-
const body = await response.text().catch(() => void 0);
|
|
189
|
-
throw new SnowflakeStatusPageError({
|
|
190
|
-
message: `status-page GET ${url} returned HTTP ${response.status}`,
|
|
191
|
-
status: response.status,
|
|
192
|
-
url,
|
|
193
|
-
body
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
let payload;
|
|
197
|
-
try {
|
|
198
|
-
payload = await response.json();
|
|
199
|
-
} catch (cause) {
|
|
200
|
-
throw new SnowflakeStatusPageError({
|
|
201
|
-
message: `status-page GET ${url} returned non-JSON body`,
|
|
202
|
-
status: response.status,
|
|
203
|
-
url,
|
|
204
|
-
cause
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
const parsed = schema.safeParse(payload);
|
|
208
|
-
if (!parsed.success) throw new SnowflakeStatusPageError({
|
|
209
|
-
message: `status-page GET ${url} response failed validation: ${parsed.error.message}`,
|
|
210
|
-
status: response.status,
|
|
211
|
-
url,
|
|
212
|
-
cause: parsed.error
|
|
213
|
-
});
|
|
214
|
-
return parsed.data;
|
|
215
|
-
}
|
|
216
|
-
/** `GET /api/v2/summary.json` — overall page, components, active incidents, maintenances. */
|
|
217
|
-
async function getStatusSummary(options = {}) {
|
|
218
|
-
return fetchJson("/api/v2/summary.json", summaryResponseSchema, options);
|
|
219
|
-
}
|
|
220
|
-
/** `GET /api/v2/status.json` — top-level indicator + description only. */
|
|
221
|
-
async function getStatusRollup(options = {}) {
|
|
222
|
-
return fetchJson("/api/v2/status.json", rollupResponseSchema, options);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* `GET /api/v2/components.json` — returns every component. When `componentId`
|
|
226
|
-
* or `name` are provided, the result is filtered client-side because the
|
|
227
|
-
* Statuspage.io public endpoint does not expose a server-side filter.
|
|
228
|
-
*/
|
|
229
|
-
async function getComponentStatus(options = {}) {
|
|
230
|
-
const response = await fetchJson("/api/v2/components.json", componentsResponseSchema, options);
|
|
231
|
-
const { componentId, name } = options;
|
|
232
|
-
let components = response.components;
|
|
233
|
-
if (componentId) components = components.filter((c) => c.id === componentId);
|
|
234
|
-
if (name) {
|
|
235
|
-
const target = name.toLowerCase();
|
|
236
|
-
components = components.filter((c) => c.name.toLowerCase() === target);
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
page: response.page,
|
|
240
|
-
components
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
/** `GET /api/v2/incidents/unresolved.json` — active, non-resolved incidents. */
|
|
244
|
-
async function getUnresolvedIncidents(options = {}) {
|
|
245
|
-
return fetchJson("/api/v2/incidents/unresolved.json", incidentsResponseSchema, options);
|
|
246
|
-
}
|
|
247
|
-
/** `GET /api/v2/scheduled-maintenances/active.json` — maintenances currently in progress. */
|
|
248
|
-
async function getActiveScheduledMaintenances(options = {}) {
|
|
249
|
-
return fetchJson("/api/v2/scheduled-maintenances/active.json", maintenancesResponseSchema, options);
|
|
250
|
-
}
|
|
251
|
-
/** `GET /api/v2/scheduled-maintenances.json` — every scheduled maintenance on record. */
|
|
252
|
-
async function getAllScheduledMaintenances(options = {}) {
|
|
253
|
-
return fetchJson("/api/v2/scheduled-maintenances.json", maintenancesResponseSchema, options);
|
|
254
|
-
}
|
|
255
|
-
/** `GET /api/v2/scheduled-maintenances/upcoming.json` — maintenances not yet started. */
|
|
256
|
-
async function getUpcomingScheduledMaintenances(options = {}) {
|
|
257
|
-
return fetchJson("/api/v2/scheduled-maintenances/upcoming.json", maintenancesResponseSchema, options);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
//#endregion
|
|
261
|
-
export { SnowflakeStatusPageError, getActiveScheduledMaintenances, getAllScheduledMaintenances, getComponentStatus, getStatusRollup, getStatusSummary, getUnresolvedIncidents, getUpcomingScheduledMaintenances, statusPageComponentSchema, statusPageComponentStatusSchema, statusPageIncidentSchema, statusPageIncidentUpdateSchema, statusPageIndicatorSchema, statusPageOverallStatusSchema, statusPagePageSchema, statusPageScheduledMaintenanceSchema };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { SnowflakeClient } from "../client/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/streaming/index.d.ts
|
|
4
|
-
interface StreamingChannelRef {
|
|
5
|
-
readonly database: string;
|
|
6
|
-
readonly schema: string;
|
|
7
|
-
readonly table: string;
|
|
8
|
-
readonly channel: string;
|
|
9
|
-
/** Override the base REST path prefix. */
|
|
10
|
-
readonly pathPrefix?: string;
|
|
11
|
-
}
|
|
12
|
-
interface OpenChannelOptions extends StreamingChannelRef {
|
|
13
|
-
readonly role?: string;
|
|
14
|
-
readonly offsetToken?: string;
|
|
15
|
-
readonly clientSequencer?: number;
|
|
16
|
-
readonly rowSequencer?: number;
|
|
17
|
-
readonly requestId?: string;
|
|
18
|
-
}
|
|
19
|
-
interface OpenChannelResponse {
|
|
20
|
-
readonly channel?: string;
|
|
21
|
-
readonly continuationToken?: string;
|
|
22
|
-
readonly clientSequencer?: number;
|
|
23
|
-
readonly rowSequencer?: number;
|
|
24
|
-
readonly offsetToken?: string;
|
|
25
|
-
/** Echo of the server-side Arrow / column schema descriptor. */
|
|
26
|
-
readonly tableColumns?: readonly {
|
|
27
|
-
readonly name: string;
|
|
28
|
-
readonly type?: string;
|
|
29
|
-
readonly nullable?: boolean;
|
|
30
|
-
readonly scale?: number;
|
|
31
|
-
readonly precision?: number;
|
|
32
|
-
}[];
|
|
33
|
-
}
|
|
34
|
-
declare function openChannel(client: SnowflakeClient, options: OpenChannelOptions): Promise<OpenChannelResponse>;
|
|
35
|
-
interface AppendRowsOptions extends StreamingChannelRef {
|
|
36
|
-
readonly rows: readonly Readonly<Record<string, unknown>>[];
|
|
37
|
-
readonly continuationToken: string;
|
|
38
|
-
readonly offsetToken?: string;
|
|
39
|
-
readonly requestId?: string;
|
|
40
|
-
}
|
|
41
|
-
interface AppendRowsResponse {
|
|
42
|
-
readonly nextContinuationToken?: string;
|
|
43
|
-
readonly offsetToken?: string;
|
|
44
|
-
readonly rowSequencer?: number;
|
|
45
|
-
readonly invalidRows?: readonly {
|
|
46
|
-
readonly rowIndex: number;
|
|
47
|
-
readonly message: string;
|
|
48
|
-
}[];
|
|
49
|
-
}
|
|
50
|
-
declare function appendRows(client: SnowflakeClient, options: AppendRowsOptions): Promise<AppendRowsResponse>;
|
|
51
|
-
interface GetChannelStatusOptions extends StreamingChannelRef {
|
|
52
|
-
readonly continuationToken?: string;
|
|
53
|
-
readonly requestId?: string;
|
|
54
|
-
}
|
|
55
|
-
interface GetChannelStatusResponse {
|
|
56
|
-
readonly channel?: string;
|
|
57
|
-
readonly continuationToken?: string;
|
|
58
|
-
readonly lastCommittedOffsetToken?: string;
|
|
59
|
-
readonly committedClientSequencer?: number;
|
|
60
|
-
readonly committedRowSequencer?: number;
|
|
61
|
-
readonly status?: 'OPEN' | 'CLOSED' | 'INVALID' | string;
|
|
62
|
-
}
|
|
63
|
-
declare function getChannelStatus(client: SnowflakeClient, options: GetChannelStatusOptions): Promise<GetChannelStatusResponse>;
|
|
64
|
-
interface CloseChannelOptions extends StreamingChannelRef {
|
|
65
|
-
readonly continuationToken?: string;
|
|
66
|
-
readonly requestId?: string;
|
|
67
|
-
}
|
|
68
|
-
declare function closeChannel(client: SnowflakeClient, options: CloseChannelOptions): Promise<void>;
|
|
69
|
-
//#endregion
|
|
70
|
-
export { AppendRowsOptions, AppendRowsResponse, CloseChannelOptions, GetChannelStatusOptions, GetChannelStatusResponse, OpenChannelOptions, OpenChannelResponse, StreamingChannelRef, appendRows, closeChannel, getChannelStatus, openChannel };
|
package/dist/streaming/index.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//#region src/streaming/index.ts
|
|
2
|
-
const DEFAULT_PATH_PREFIX = "/v1/streaming";
|
|
3
|
-
function channelPath(ref) {
|
|
4
|
-
const prefix = ref.pathPrefix ?? DEFAULT_PATH_PREFIX;
|
|
5
|
-
const encode = (segment) => encodeURIComponent(segment);
|
|
6
|
-
return `${prefix}/databases/${encode(ref.database)}/schemas/${encode(ref.schema)}/tables/${encode(ref.table)}/channels/${encode(ref.channel)}`;
|
|
7
|
-
}
|
|
8
|
-
async function openChannel(client, options) {
|
|
9
|
-
const body = {
|
|
10
|
-
role: options.role,
|
|
11
|
-
offsetToken: options.offsetToken,
|
|
12
|
-
clientSequencer: options.clientSequencer,
|
|
13
|
-
rowSequencer: options.rowSequencer
|
|
14
|
-
};
|
|
15
|
-
return client.request(channelPath(options), {
|
|
16
|
-
method: "POST",
|
|
17
|
-
body,
|
|
18
|
-
requestId: options.requestId,
|
|
19
|
-
query: options.requestId ? { requestId: options.requestId } : void 0
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
async function appendRows(client, options) {
|
|
23
|
-
if (options.rows.length === 0) throw new Error("appendRows requires at least one row");
|
|
24
|
-
const query = { continuationToken: options.continuationToken };
|
|
25
|
-
if (options.offsetToken !== void 0) query.offsetToken = options.offsetToken;
|
|
26
|
-
if (options.requestId) query.requestId = options.requestId;
|
|
27
|
-
return client.request(`${channelPath(options)}/rows`, {
|
|
28
|
-
method: "POST",
|
|
29
|
-
body: { rows: options.rows },
|
|
30
|
-
requestId: options.requestId,
|
|
31
|
-
query
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async function getChannelStatus(client, options) {
|
|
35
|
-
const query = {};
|
|
36
|
-
if (options.continuationToken) query.continuationToken = options.continuationToken;
|
|
37
|
-
if (options.requestId) query.requestId = options.requestId;
|
|
38
|
-
return client.request(`${channelPath(options)}/status`, {
|
|
39
|
-
method: "GET",
|
|
40
|
-
query
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async function closeChannel(client, options) {
|
|
44
|
-
const query = { action: "close" };
|
|
45
|
-
if (options.continuationToken) query.continuationToken = options.continuationToken;
|
|
46
|
-
if (options.requestId) query.requestId = options.requestId;
|
|
47
|
-
await client.request(channelPath(options), {
|
|
48
|
-
method: "POST",
|
|
49
|
-
body: {},
|
|
50
|
-
query,
|
|
51
|
-
requestId: options.requestId
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { appendRows, closeChannel, getChannelStatus, openChannel };
|
package/dist/streams/index.d.mts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { SnowflakeClient } from "../client/index.mjs";
|
|
2
|
-
import { d as HydratedRow } from "../statements-DJL0qVNA.mjs";
|
|
3
|
-
import { t as OptionMap } from "../sql-options-2k5xQ-oS.mjs";
|
|
4
|
-
import { CatalogResult, ShowScopedOptions, showStreams } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/streams/index.d.ts
|
|
7
|
-
interface StreamRef {
|
|
8
|
-
readonly database?: string;
|
|
9
|
-
readonly schema?: string;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
}
|
|
12
|
-
interface StreamContext {
|
|
13
|
-
readonly warehouse?: string;
|
|
14
|
-
readonly role?: string;
|
|
15
|
-
}
|
|
16
|
-
type StreamSource = {
|
|
17
|
-
readonly kind: 'table';
|
|
18
|
-
readonly database?: string;
|
|
19
|
-
readonly schema?: string;
|
|
20
|
-
readonly name: string;
|
|
21
|
-
} | {
|
|
22
|
-
readonly kind: 'view';
|
|
23
|
-
readonly database?: string;
|
|
24
|
-
readonly schema?: string;
|
|
25
|
-
readonly name: string;
|
|
26
|
-
} | {
|
|
27
|
-
readonly kind: 'externalTable';
|
|
28
|
-
readonly database?: string;
|
|
29
|
-
readonly schema?: string;
|
|
30
|
-
readonly name: string;
|
|
31
|
-
} | {
|
|
32
|
-
readonly kind: 'stage';
|
|
33
|
-
readonly database?: string;
|
|
34
|
-
readonly schema?: string;
|
|
35
|
-
readonly name: string;
|
|
36
|
-
};
|
|
37
|
-
interface CreateStreamOptions extends StreamRef, StreamContext {
|
|
38
|
-
readonly orReplace?: boolean;
|
|
39
|
-
readonly ifNotExists?: boolean;
|
|
40
|
-
readonly copyGrants?: boolean;
|
|
41
|
-
readonly source: StreamSource;
|
|
42
|
-
/** `APPEND_ONLY = TRUE`, `SHOW_INITIAL_ROWS = TRUE`, etc. */
|
|
43
|
-
readonly options?: OptionMap;
|
|
44
|
-
readonly comment?: string;
|
|
45
|
-
/** `AT(OFFSET => -60*5)`, `AT(STATEMENT => '<uuid>')`, `BEFORE(STATEMENT => '...')`, etc. */
|
|
46
|
-
readonly atBeforeClause?: string;
|
|
47
|
-
}
|
|
48
|
-
declare function createStream(client: SnowflakeClient, options: CreateStreamOptions): Promise<void>;
|
|
49
|
-
interface AlterStreamOptions extends StreamRef, StreamContext {
|
|
50
|
-
readonly rename?: StreamRef;
|
|
51
|
-
readonly set?: OptionMap;
|
|
52
|
-
readonly unset?: readonly string[];
|
|
53
|
-
readonly comment?: string;
|
|
54
|
-
readonly ifExists?: boolean;
|
|
55
|
-
}
|
|
56
|
-
declare function alterStream(client: SnowflakeClient, options: AlterStreamOptions): Promise<void>;
|
|
57
|
-
interface DropStreamOptions extends StreamRef, StreamContext {
|
|
58
|
-
readonly ifExists?: boolean;
|
|
59
|
-
}
|
|
60
|
-
declare function dropStream(client: SnowflakeClient, options: DropStreamOptions): Promise<void>;
|
|
61
|
-
interface DescribeStreamOptions extends StreamRef, StreamContext {}
|
|
62
|
-
declare function describeStream(client: SnowflakeClient, options: DescribeStreamOptions): Promise<readonly HydratedRow[]>;
|
|
63
|
-
interface StreamHasDataOptions extends StreamRef, StreamContext {}
|
|
64
|
-
/**
|
|
65
|
-
* Wraps `SELECT SYSTEM$STREAM_HAS_DATA('<fqn>')`. Returns the normalised
|
|
66
|
-
* boolean value (Snowflake returns the column as "true"/"false" strings
|
|
67
|
-
* for a BOOLEAN selector).
|
|
68
|
-
*/
|
|
69
|
-
declare function streamHasData(client: SnowflakeClient, options: StreamHasDataOptions): Promise<boolean>;
|
|
70
|
-
//#endregion
|
|
71
|
-
export { AlterStreamOptions, type CatalogResult, CreateStreamOptions, DescribeStreamOptions, DropStreamOptions, type ShowScopedOptions, StreamContext, StreamHasDataOptions, StreamRef, StreamSource, alterStream, createStream, describeStream, dropStream, showStreams, streamHasData };
|
package/dist/streams/index.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { executeSql } from "../sql/index.mjs";
|
|
2
|
-
import { a as quoteLiteral, t as buildFqn } from "../sql-safety-BZpAPsq6.mjs";
|
|
3
|
-
import { t as formatOptions } from "../sql-options-D6GEa21F.mjs";
|
|
4
|
-
import { showStreams } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/streams/index.ts
|
|
7
|
-
function streamFqn(ref) {
|
|
8
|
-
return buildFqn(ref.database, ref.schema, ref.name);
|
|
9
|
-
}
|
|
10
|
-
function renderStreamSource(source) {
|
|
11
|
-
const fqn = buildFqn(source.database, source.schema, source.name);
|
|
12
|
-
switch (source.kind) {
|
|
13
|
-
case "table": return `ON TABLE ${fqn}`;
|
|
14
|
-
case "view": return `ON VIEW ${fqn}`;
|
|
15
|
-
case "externalTable": return `ON EXTERNAL TABLE ${fqn}`;
|
|
16
|
-
case "stage": return `ON STAGE ${fqn}`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function createStream(client, options) {
|
|
20
|
-
const prefix = `CREATE${options.orReplace ? " OR REPLACE" : ""} STREAM${options.ifNotExists ? " IF NOT EXISTS" : ""}`;
|
|
21
|
-
const copyGrants = options.copyGrants ? " COPY GRANTS" : "";
|
|
22
|
-
const source = renderStreamSource(options.source);
|
|
23
|
-
const atBefore = options.atBeforeClause ? ` ${options.atBeforeClause}` : "";
|
|
24
|
-
const body = options.options && Object.keys(options.options).length > 0 ? ` ${formatOptions(options.options)}` : "";
|
|
25
|
-
const comment = options.comment ? ` COMMENT = ${quoteLiteral(options.comment)}` : "";
|
|
26
|
-
await executeSql(client, {
|
|
27
|
-
statement: `${prefix} ${streamFqn(options)}${copyGrants} ${source}${atBefore}${body}${comment}`,
|
|
28
|
-
warehouse: options.warehouse,
|
|
29
|
-
role: options.role
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
async function alterStream(client, options) {
|
|
33
|
-
let tail;
|
|
34
|
-
if (options.rename) tail = `RENAME TO ${streamFqn(options.rename)}`;
|
|
35
|
-
else if (options.set && Object.keys(options.set).length > 0) tail = `SET ${formatOptions(options.set)}`;
|
|
36
|
-
else if (options.unset && options.unset.length > 0) tail = `UNSET ${options.unset.map((k) => k.toUpperCase()).join(", ")}`;
|
|
37
|
-
else if (options.comment !== void 0) tail = `SET COMMENT = ${quoteLiteral(options.comment)}`;
|
|
38
|
-
else throw new Error("alterStream requires one of: rename / set / unset / comment");
|
|
39
|
-
await executeSql(client, {
|
|
40
|
-
statement: `ALTER STREAM${options.ifExists ? " IF EXISTS" : ""} ${streamFqn(options)} ${tail}`,
|
|
41
|
-
warehouse: options.warehouse,
|
|
42
|
-
role: options.role
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
async function dropStream(client, options) {
|
|
46
|
-
await executeSql(client, {
|
|
47
|
-
statement: `DROP STREAM${options.ifExists ? " IF EXISTS" : ""} ${streamFqn(options)}`,
|
|
48
|
-
warehouse: options.warehouse,
|
|
49
|
-
role: options.role
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async function describeStream(client, options) {
|
|
53
|
-
return (await executeSql(client, {
|
|
54
|
-
statement: `DESCRIBE STREAM ${streamFqn(options)}`,
|
|
55
|
-
warehouse: options.warehouse,
|
|
56
|
-
role: options.role
|
|
57
|
-
})).rows;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Wraps `SELECT SYSTEM$STREAM_HAS_DATA('<fqn>')`. Returns the normalised
|
|
61
|
-
* boolean value (Snowflake returns the column as "true"/"false" strings
|
|
62
|
-
* for a BOOLEAN selector).
|
|
63
|
-
*/
|
|
64
|
-
async function streamHasData(client, options) {
|
|
65
|
-
const row = (await executeSql(client, {
|
|
66
|
-
statement: `SELECT SYSTEM$STREAM_HAS_DATA(${quoteLiteral(streamFqn(options))}) AS HAS_DATA`,
|
|
67
|
-
warehouse: options.warehouse,
|
|
68
|
-
role: options.role
|
|
69
|
-
})).rows[0];
|
|
70
|
-
if (!row) return false;
|
|
71
|
-
const value = Array.isArray(row) ? row[0] : row.HAS_DATA ?? row.has_data;
|
|
72
|
-
if (typeof value === "boolean") return value;
|
|
73
|
-
if (typeof value === "string") return value.toLowerCase() === "true";
|
|
74
|
-
return Boolean(value);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
export { alterStream, createStream, describeStream, dropStream, showStreams, streamHasData };
|
package/dist/tables/index.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { CatalogResult, DescribeTableOptions, ExploreColumnsOptions, ExploreColumnsResult, FindTablesOptions, ShowColumnsOptions, ShowTablesOptions, describeTable, exploreColumns, findTables, showColumns, showTables } from "../catalog/index.mjs";
|
|
2
|
-
export { type CatalogResult, type DescribeTableOptions, type ExploreColumnsOptions, type ExploreColumnsResult, type FindTablesOptions, type ShowColumnsOptions, type ShowTablesOptions, describeTable, exploreColumns, findTables, showColumns, showTables };
|
package/dist/tables/index.mjs
DELETED
package/dist/tasks/index.d.mts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { SnowflakeClient } from "../client/index.mjs";
|
|
2
|
-
import { d as HydratedRow } from "../statements-DJL0qVNA.mjs";
|
|
3
|
-
import { t as OptionMap } from "../sql-options-2k5xQ-oS.mjs";
|
|
4
|
-
import { CatalogResult, ShowScopedOptions, showTasks } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/tasks/index.d.ts
|
|
7
|
-
interface TaskRef {
|
|
8
|
-
readonly database?: string;
|
|
9
|
-
readonly schema?: string;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
}
|
|
12
|
-
interface TaskContext {
|
|
13
|
-
readonly warehouse?: string;
|
|
14
|
-
readonly role?: string;
|
|
15
|
-
}
|
|
16
|
-
interface CreateTaskOptions extends TaskRef, TaskContext {
|
|
17
|
-
readonly orReplace?: boolean;
|
|
18
|
-
readonly ifNotExists?: boolean;
|
|
19
|
-
readonly copyGrants?: boolean;
|
|
20
|
-
/** Task options: `SCHEDULE = '...'`, `WAREHOUSE = '...'`, `USER_TASK_TIMEOUT_MS = 60000`, etc. */
|
|
21
|
-
readonly options?: OptionMap;
|
|
22
|
-
/** `AFTER <predecessorFqn>[, ...]`. */
|
|
23
|
-
readonly after?: readonly TaskRef[];
|
|
24
|
-
/** `WHEN <boolean expression>`. */
|
|
25
|
-
readonly when?: string;
|
|
26
|
-
readonly comment?: string;
|
|
27
|
-
/** The SQL body the task executes (required). */
|
|
28
|
-
readonly as: string;
|
|
29
|
-
}
|
|
30
|
-
declare function createTask(client: SnowflakeClient, options: CreateTaskOptions): Promise<void>;
|
|
31
|
-
interface AlterTaskOptions extends TaskRef, TaskContext {
|
|
32
|
-
readonly ifExists?: boolean;
|
|
33
|
-
readonly rename?: TaskRef;
|
|
34
|
-
readonly set?: OptionMap;
|
|
35
|
-
readonly unset?: readonly string[];
|
|
36
|
-
readonly addAfter?: readonly TaskRef[];
|
|
37
|
-
readonly removeAfter?: readonly TaskRef[];
|
|
38
|
-
readonly modifyAs?: string;
|
|
39
|
-
readonly modifyWhen?: string;
|
|
40
|
-
readonly comment?: string;
|
|
41
|
-
}
|
|
42
|
-
declare function alterTask(client: SnowflakeClient, options: AlterTaskOptions): Promise<void>;
|
|
43
|
-
interface DropTaskOptions extends TaskRef, TaskContext {
|
|
44
|
-
readonly ifExists?: boolean;
|
|
45
|
-
}
|
|
46
|
-
declare function dropTask(client: SnowflakeClient, options: DropTaskOptions): Promise<void>;
|
|
47
|
-
interface DescribeTaskOptions extends TaskRef, TaskContext {}
|
|
48
|
-
declare function describeTask(client: SnowflakeClient, options: DescribeTaskOptions): Promise<readonly HydratedRow[]>;
|
|
49
|
-
interface ExecuteTaskOptions extends TaskRef, TaskContext {
|
|
50
|
-
readonly retryLast?: boolean;
|
|
51
|
-
}
|
|
52
|
-
declare function executeTask(client: SnowflakeClient, options: ExecuteTaskOptions): Promise<void>;
|
|
53
|
-
interface ResumeTaskOptions extends TaskRef, TaskContext {
|
|
54
|
-
readonly ifExists?: boolean;
|
|
55
|
-
}
|
|
56
|
-
declare function resumeTask(client: SnowflakeClient, options: ResumeTaskOptions): Promise<void>;
|
|
57
|
-
interface SuspendTaskOptions extends TaskRef, TaskContext {
|
|
58
|
-
readonly ifExists?: boolean;
|
|
59
|
-
}
|
|
60
|
-
declare function suspendTask(client: SnowflakeClient, options: SuspendTaskOptions): Promise<void>;
|
|
61
|
-
interface TaskHistoryOptions extends TaskContext {
|
|
62
|
-
readonly taskName?: TaskRef;
|
|
63
|
-
readonly rootTaskName?: TaskRef;
|
|
64
|
-
/** ISO-8601 timestamp. */
|
|
65
|
-
readonly scheduledTimeRangeStart?: string;
|
|
66
|
-
/** ISO-8601 timestamp. */
|
|
67
|
-
readonly scheduledTimeRangeEnd?: string;
|
|
68
|
-
/** Max rows returned (Snowflake default: 10,000). */
|
|
69
|
-
readonly resultLimit?: number;
|
|
70
|
-
/** `ERROR_ONLY => TRUE` filters to failed runs. */
|
|
71
|
-
readonly errorOnly?: boolean;
|
|
72
|
-
}
|
|
73
|
-
declare function showTaskHistory(client: SnowflakeClient, options?: TaskHistoryOptions): Promise<readonly HydratedRow[]>;
|
|
74
|
-
interface TaskDependentsOptions extends TaskRef, TaskContext {
|
|
75
|
-
readonly recursive?: boolean;
|
|
76
|
-
}
|
|
77
|
-
declare function showTaskDependents(client: SnowflakeClient, options: TaskDependentsOptions): Promise<readonly HydratedRow[]>;
|
|
78
|
-
//#endregion
|
|
79
|
-
export { AlterTaskOptions, type CatalogResult, CreateTaskOptions, DescribeTaskOptions, DropTaskOptions, ExecuteTaskOptions, ResumeTaskOptions, type ShowScopedOptions, SuspendTaskOptions, TaskContext, TaskDependentsOptions, TaskHistoryOptions, TaskRef, alterTask, createTask, describeTask, dropTask, executeTask, resumeTask, showTaskDependents, showTaskHistory, showTasks, suspendTask };
|