@keystrokehq/snowflake 0.0.16 → 0.0.17
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/dist/actions/index.cjs +18 -0
- package/dist/actions/index.d.cts +2 -0
- package/dist/actions/index.d.mts +2 -0
- package/dist/actions/index.mjs +2 -0
- package/dist/actions-BGkaZb6a.cjs +801 -0
- package/dist/actions-BGkaZb6a.cjs.map +1 -0
- package/dist/actions-BR_JWhT_.mjs +700 -0
- package/dist/actions-BR_JWhT_.mjs.map +1 -0
- package/dist/index-DUGCZPGQ.d.cts +443 -0
- package/dist/index-DUGCZPGQ.d.cts.map +1 -0
- package/dist/index-RhOmpRxD.d.mts +445 -0
- package/dist/index-RhOmpRxD.d.mts.map +1 -0
- package/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +19 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +15 -5
- package/dist/index.mjs.map +1 -0
- 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/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,56 +0,0 @@
|
|
|
1
|
-
//#region src/sql-safety.ts
|
|
2
|
-
/**
|
|
3
|
-
* SQL identifier + literal escaping utilities.
|
|
4
|
-
*
|
|
5
|
-
* Snowflake follows ANSI rules:
|
|
6
|
-
* - Identifiers: wrap in `"..."`; internal `"` is escaped as `""`.
|
|
7
|
-
* - String literals: wrap in `'...'`; internal `'` is escaped as `''`.
|
|
8
|
-
* - Numeric, boolean, null literals are written raw.
|
|
9
|
-
*
|
|
10
|
-
* Every domain module that composes SQL goes through these helpers — they
|
|
11
|
-
* are the package's sole defense against SQL injection from operation
|
|
12
|
-
* inputs that name identifiers or match patterns.
|
|
13
|
-
*/
|
|
14
|
-
const UNQUOTED_IDENT = /^[A-Z_][A-Z0-9_$]*$/u;
|
|
15
|
-
/**
|
|
16
|
-
* Return a double-quoted form of the identifier, escaping embedded
|
|
17
|
-
* double-quotes. When `allowUnquoted` is true and the input is already a
|
|
18
|
-
* canonical unquoted identifier, return it verbatim so the resulting SQL
|
|
19
|
-
* is more readable.
|
|
20
|
-
*/
|
|
21
|
-
function quoteIdentifier(name, options = {}) {
|
|
22
|
-
if (options.allowUnquoted && UNQUOTED_IDENT.test(name)) return name;
|
|
23
|
-
return `"${name.replaceAll("\"", "\"\"")}"`;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Build a fully-qualified name from up to three segments. Each segment is
|
|
27
|
-
* independently quoted. Missing leading segments are omitted.
|
|
28
|
-
*/
|
|
29
|
-
function buildFqn(...segments) {
|
|
30
|
-
return segments.filter((segment) => segment !== void 0 && segment.length > 0).map((segment) => quoteIdentifier(segment)).join(".");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Quote a Snowflake string literal, doubling embedded single quotes.
|
|
34
|
-
*/
|
|
35
|
-
function quoteLiteral(value) {
|
|
36
|
-
return `'${value.replaceAll("'", "''")}'`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Compose `LIKE '<pattern>'` when `pattern` is provided, empty string
|
|
40
|
-
* otherwise. Pattern is escaped as a SQL literal.
|
|
41
|
-
*/
|
|
42
|
-
function likeClause(pattern) {
|
|
43
|
-
return pattern ? ` LIKE ${quoteLiteral(pattern)}` : "";
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Compose `IN <scopeKeyword> <quoted identifier>` clause (e.g. "IN DATABASE
|
|
47
|
-
* MYDB"). Caller supplies a pre-joined identifier (fqn already built).
|
|
48
|
-
*/
|
|
49
|
-
function inClause(scopeKeyword, target) {
|
|
50
|
-
if (!target) return "";
|
|
51
|
-
if (scopeKeyword === "ACCOUNT") return " IN ACCOUNT";
|
|
52
|
-
return ` IN ${scopeKeyword} ${target}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { quoteLiteral as a, quoteIdentifier as i, inClause as n, likeClause as r, buildFqn as t };
|
package/dist/stages/index.d.mts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { SnowflakeClient } from "../client/index.mjs";
|
|
2
|
-
import { d as HydratedRow } from "../statements-DJL0qVNA.mjs";
|
|
3
|
-
import { ExecuteSqlResult } from "../sql/index.mjs";
|
|
4
|
-
import { t as OptionMap } from "../sql-options-2k5xQ-oS.mjs";
|
|
5
|
-
import { CatalogResult, ShowScopedOptions, showStages } from "../catalog/index.mjs";
|
|
6
|
-
|
|
7
|
-
//#region src/stages/index.d.ts
|
|
8
|
-
interface StageRef {
|
|
9
|
-
readonly database?: string;
|
|
10
|
-
readonly schema?: string;
|
|
11
|
-
readonly name: string;
|
|
12
|
-
}
|
|
13
|
-
interface StageContext {
|
|
14
|
-
readonly warehouse?: string;
|
|
15
|
-
readonly role?: string;
|
|
16
|
-
}
|
|
17
|
-
/** `@<fqn>` form used inside LIST / REMOVE / COPY INTO commands. */
|
|
18
|
-
declare function stagePath(ref: StageRef, pathSuffix?: string): string;
|
|
19
|
-
interface CreateStageOptions extends StageRef, StageContext {
|
|
20
|
-
readonly orReplace?: boolean;
|
|
21
|
-
readonly ifNotExists?: boolean;
|
|
22
|
-
readonly temporary?: boolean;
|
|
23
|
-
/** `URL='...'`, `STORAGE_INTEGRATION='...'`, `CREDENTIALS=(...)`, `ENCRYPTION=(...)`, etc. */
|
|
24
|
-
readonly options?: OptionMap;
|
|
25
|
-
readonly fileFormat?: OptionMap;
|
|
26
|
-
readonly copyOptions?: OptionMap;
|
|
27
|
-
readonly comment?: string;
|
|
28
|
-
}
|
|
29
|
-
declare function createStage(client: SnowflakeClient, options: CreateStageOptions): Promise<void>;
|
|
30
|
-
interface AlterStageOptions extends StageRef, StageContext {
|
|
31
|
-
readonly rename?: StageRef;
|
|
32
|
-
readonly set?: OptionMap;
|
|
33
|
-
readonly unset?: readonly string[];
|
|
34
|
-
readonly refreshSubpath?: string;
|
|
35
|
-
readonly comment?: string;
|
|
36
|
-
}
|
|
37
|
-
declare function alterStage(client: SnowflakeClient, options: AlterStageOptions): Promise<void>;
|
|
38
|
-
interface DropStageOptions extends StageRef, StageContext {
|
|
39
|
-
readonly ifExists?: boolean;
|
|
40
|
-
}
|
|
41
|
-
declare function dropStage(client: SnowflakeClient, options: DropStageOptions): Promise<void>;
|
|
42
|
-
interface DescribeStageOptions extends StageRef, StageContext {}
|
|
43
|
-
declare function describeStage(client: SnowflakeClient, options: DescribeStageOptions): Promise<readonly HydratedRow[]>;
|
|
44
|
-
interface ListStageFilesOptions extends StageRef, StageContext {
|
|
45
|
-
readonly pathSuffix?: string;
|
|
46
|
-
/** Regex pattern matched against file names. */
|
|
47
|
-
readonly pattern?: string;
|
|
48
|
-
}
|
|
49
|
-
declare function listStageFiles(client: SnowflakeClient, options: ListStageFilesOptions): Promise<readonly HydratedRow[]>;
|
|
50
|
-
interface RemoveStageFilesOptions extends StageRef, StageContext {
|
|
51
|
-
readonly pathSuffix?: string;
|
|
52
|
-
readonly pattern?: string;
|
|
53
|
-
}
|
|
54
|
-
declare function removeStageFiles(client: SnowflakeClient, options: RemoveStageFilesOptions): Promise<ExecuteSqlResult<HydratedRow | readonly unknown[]>>;
|
|
55
|
-
/**
|
|
56
|
-
* PUT is not supported by the Snowflake SQL API v2 — the API cannot accept
|
|
57
|
-
* raw file bytes. Callers needing a file upload should use a pre-signed S3
|
|
58
|
-
* URL + external stage, or drive `snowsql`/`snowflake-sdk` from a trusted
|
|
59
|
-
* context.
|
|
60
|
-
*/
|
|
61
|
-
declare function putFile(): never;
|
|
62
|
-
declare function getFile(): never;
|
|
63
|
-
//#endregion
|
|
64
|
-
export { AlterStageOptions, type CatalogResult, CreateStageOptions, DescribeStageOptions, DropStageOptions, ListStageFilesOptions, RemoveStageFilesOptions, type ShowScopedOptions, StageContext, StageRef, alterStage, createStage, describeStage, dropStage, getFile, listStageFiles, putFile, removeStageFiles, showStages, stagePath };
|
package/dist/stages/index.mjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { executeSql } from "../sql/index.mjs";
|
|
2
|
-
import { a as quoteLiteral, t as buildFqn } from "../sql-safety-BZpAPsq6.mjs";
|
|
3
|
-
import { n as renderOptionGroup, t as formatOptions } from "../sql-options-D6GEa21F.mjs";
|
|
4
|
-
import { showStages } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/stages/index.ts
|
|
7
|
-
function stageFqn(ref) {
|
|
8
|
-
return buildFqn(ref.database, ref.schema, ref.name);
|
|
9
|
-
}
|
|
10
|
-
/** `@<fqn>` form used inside LIST / REMOVE / COPY INTO commands. */
|
|
11
|
-
function stagePath(ref, pathSuffix) {
|
|
12
|
-
const fqn = stageFqn(ref);
|
|
13
|
-
if (!pathSuffix) return `@${fqn}`;
|
|
14
|
-
return `@${fqn}${pathSuffix.startsWith("/") ? pathSuffix : `/${pathSuffix}`}`;
|
|
15
|
-
}
|
|
16
|
-
async function createStage(client, options) {
|
|
17
|
-
const prefix = `CREATE${options.orReplace ? " OR REPLACE" : ""}${options.temporary ? " TEMPORARY" : ""} STAGE${options.ifNotExists ? " IF NOT EXISTS" : ""}`;
|
|
18
|
-
const topOptions = options.options ? ` ${formatOptions(options.options)}` : "";
|
|
19
|
-
await executeSql(client, {
|
|
20
|
-
statement: `${prefix} ${stageFqn(options)}${topOptions}` + renderOptionGroup("FILE_FORMAT", options.fileFormat) + renderOptionGroup("COPY_OPTIONS", options.copyOptions) + (options.comment ? ` COMMENT = ${quoteLiteral(options.comment)}` : ""),
|
|
21
|
-
warehouse: options.warehouse,
|
|
22
|
-
role: options.role
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
async function alterStage(client, options) {
|
|
26
|
-
let tail;
|
|
27
|
-
if (options.rename) tail = `RENAME TO ${stageFqn(options.rename)}`;
|
|
28
|
-
else if (options.refreshSubpath !== void 0) tail = `REFRESH${options.refreshSubpath.length > 0 ? ` SUBPATH = ${quoteLiteral(options.refreshSubpath)}` : ""}`;
|
|
29
|
-
else if (options.set && Object.keys(options.set).length > 0) tail = `SET ${formatOptions(options.set)}`;
|
|
30
|
-
else if (options.unset && options.unset.length > 0) tail = `UNSET ${options.unset.map((k) => k.toUpperCase()).join(", ")}`;
|
|
31
|
-
else if (options.comment !== void 0) tail = `SET COMMENT = ${quoteLiteral(options.comment)}`;
|
|
32
|
-
else throw new Error("alterStage requires one of: rename / refreshSubpath / set / unset / comment");
|
|
33
|
-
await executeSql(client, {
|
|
34
|
-
statement: `ALTER STAGE ${stageFqn(options)} ${tail}`,
|
|
35
|
-
warehouse: options.warehouse,
|
|
36
|
-
role: options.role
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async function dropStage(client, options) {
|
|
40
|
-
await executeSql(client, {
|
|
41
|
-
statement: `DROP STAGE${options.ifExists ? " IF EXISTS" : ""} ${stageFqn(options)}`,
|
|
42
|
-
warehouse: options.warehouse,
|
|
43
|
-
role: options.role
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async function describeStage(client, options) {
|
|
47
|
-
return (await executeSql(client, {
|
|
48
|
-
statement: `DESCRIBE STAGE ${stageFqn(options)}`,
|
|
49
|
-
warehouse: options.warehouse,
|
|
50
|
-
role: options.role
|
|
51
|
-
})).rows;
|
|
52
|
-
}
|
|
53
|
-
async function listStageFiles(client, options) {
|
|
54
|
-
return (await executeSql(client, {
|
|
55
|
-
statement: `LIST ${stagePath(options, options.pathSuffix)}${options.pattern ? ` PATTERN = ${quoteLiteral(options.pattern)}` : ""}`,
|
|
56
|
-
warehouse: options.warehouse,
|
|
57
|
-
role: options.role
|
|
58
|
-
})).rows;
|
|
59
|
-
}
|
|
60
|
-
async function removeStageFiles(client, options) {
|
|
61
|
-
return executeSql(client, {
|
|
62
|
-
statement: `REMOVE ${stagePath(options, options.pathSuffix)}${options.pattern ? ` PATTERN = ${quoteLiteral(options.pattern)}` : ""}`,
|
|
63
|
-
warehouse: options.warehouse,
|
|
64
|
-
role: options.role
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* PUT is not supported by the Snowflake SQL API v2 — the API cannot accept
|
|
69
|
-
* raw file bytes. Callers needing a file upload should use a pre-signed S3
|
|
70
|
-
* URL + external stage, or drive `snowsql`/`snowflake-sdk` from a trusted
|
|
71
|
-
* context.
|
|
72
|
-
*/
|
|
73
|
-
function putFile() {
|
|
74
|
-
throw new Error("putFile is not supported by the REST integration — use a pre-signed stage URL or the official Snowflake driver to upload raw file bytes.");
|
|
75
|
-
}
|
|
76
|
-
function getFile() {
|
|
77
|
-
throw new Error("getFile is not supported by the REST integration — use a pre-signed stage URL or the official Snowflake driver to download raw file bytes.");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
export { alterStage, createStage, describeStage, dropStage, getFile, listStageFiles, putFile, removeStageFiles, showStages, stagePath };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { c as sqlBindingsSchema, l as statementContextSchema, r as resultSetMetaDataSchema } from "./common-DfpCwJx5.mjs";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
//#region src/schemas/results.ts
|
|
5
|
-
/**
|
|
6
|
-
* Result-partition + row hydration schemas.
|
|
7
|
-
*
|
|
8
|
-
* A single partition response arrives under `GET /api/v2/statements/{handle}?partition={n}`
|
|
9
|
-
* and uses the same envelope as the submit response — just with `data`
|
|
10
|
-
* populated with the rows for that partition.
|
|
11
|
-
*/
|
|
12
|
-
const partitionResponseSchema = z.object({
|
|
13
|
-
statementHandle: z.string().optional(),
|
|
14
|
-
code: z.string().optional(),
|
|
15
|
-
message: z.string().optional(),
|
|
16
|
-
resultSetMetaData: resultSetMetaDataSchema.optional(),
|
|
17
|
-
data: z.array(z.array(z.unknown())).optional()
|
|
18
|
-
}).catchall(z.unknown());
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/schemas/statements.ts
|
|
22
|
-
/**
|
|
23
|
-
* Schemas for the Snowflake SQL API v2 statement endpoints.
|
|
24
|
-
*
|
|
25
|
-
* https://docs.snowflake.com/en/developer-guide/sql-api/submitting-requests
|
|
26
|
-
* https://docs.snowflake.com/en/developer-guide/sql-api/responses-errors
|
|
27
|
-
*/
|
|
28
|
-
/** Status code reported under `code` / `message` alongside the HTTP status. */
|
|
29
|
-
const statementStatusCodeSchema = z.string();
|
|
30
|
-
/**
|
|
31
|
-
* Input body for `POST /api/v2/statements`.
|
|
32
|
-
* `statement` is required. All other fields fall back to session / account
|
|
33
|
-
* defaults when omitted.
|
|
34
|
-
*/
|
|
35
|
-
const submitStatementInputSchema = z.object({
|
|
36
|
-
statement: z.string().min(1),
|
|
37
|
-
bindings: sqlBindingsSchema.optional()
|
|
38
|
-
}).merge(statementContextSchema).strict();
|
|
39
|
-
/**
|
|
40
|
-
* Response body for a submitted statement — either the inline result (200)
|
|
41
|
-
* or a pending handle (202).
|
|
42
|
-
*/
|
|
43
|
-
const statementResponseSchema = z.object({
|
|
44
|
-
code: statementStatusCodeSchema.optional(),
|
|
45
|
-
sqlState: z.string().optional(),
|
|
46
|
-
message: z.string().optional(),
|
|
47
|
-
statementHandle: z.string(),
|
|
48
|
-
statementStatusUrl: z.string().optional(),
|
|
49
|
-
createdOn: z.number().optional(),
|
|
50
|
-
requestId: z.string().optional(),
|
|
51
|
-
statementHandles: z.array(z.string()).optional(),
|
|
52
|
-
resultSetMetaData: resultSetMetaDataSchema.optional(),
|
|
53
|
-
data: z.array(z.array(z.unknown())).optional()
|
|
54
|
-
}).catchall(z.unknown());
|
|
55
|
-
/**
|
|
56
|
-
* Snowflake code ranges (SQL API v2):
|
|
57
|
-
* - 090002 — success (inline result)
|
|
58
|
-
* - 333333 — statement accepted (async)
|
|
59
|
-
* - 333334 — statement executing (still polling)
|
|
60
|
-
* - 333335 — user-triggered cancel succeeded
|
|
61
|
-
* - 390xxx / 3900xx / 0919xx / ... — SQL-level failures
|
|
62
|
-
*
|
|
63
|
-
* We map explicitly the two non-error status codes; everything else is
|
|
64
|
-
* treated as `failed` when the HTTP status is also an error, otherwise
|
|
65
|
-
* `done`.
|
|
66
|
-
*/
|
|
67
|
-
function statementStatus(input) {
|
|
68
|
-
if (input.httpStatus === 202) return "pending";
|
|
69
|
-
if (input.code === "333334" || input.code === "333333") return "pending";
|
|
70
|
-
if (input.code === "333335") return "cancelled";
|
|
71
|
-
if (input.httpStatus >= 400) return "failed";
|
|
72
|
-
return "done";
|
|
73
|
-
}
|
|
74
|
-
const cancelStatementResponseSchema = z.object({
|
|
75
|
-
code: z.string().optional(),
|
|
76
|
-
message: z.string().optional(),
|
|
77
|
-
statementHandle: z.string().optional()
|
|
78
|
-
}).catchall(z.unknown());
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
export { submitStatementInputSchema as a, statementStatusCodeSchema as i, statementResponseSchema as n, partitionResponseSchema as o, statementStatus as r, cancelStatementResponseSchema as t };
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
//#region src/schemas/common.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Snowflake identifiers are 1-255 chars. Unquoted identifiers are normalized
|
|
6
|
-
* to upper-case; quoted identifiers preserve case. We keep raw validation
|
|
7
|
-
* permissive and let the server reject bad names — a strict regex would
|
|
8
|
-
* forbid unicode-quoted identifiers legitimately used in the wild.
|
|
9
|
-
*/
|
|
10
|
-
declare const snowflakeIdentifier: z.ZodString;
|
|
11
|
-
/**
|
|
12
|
-
* Fully-qualified name: `DATABASE.SCHEMA.NAME` (or subsets). Stored as a
|
|
13
|
-
* single string; we do *not* split/rejoin so callers can pass quoted
|
|
14
|
-
* segments through verbatim.
|
|
15
|
-
*/
|
|
16
|
-
declare const snowflakeFqn: z.ZodString;
|
|
17
|
-
/**
|
|
18
|
-
* Optional context overrides applied per-statement.
|
|
19
|
-
* Every field is optional — absent values fall back to the connection's
|
|
20
|
-
* session defaults and then to account-level defaults.
|
|
21
|
-
*/
|
|
22
|
-
declare const statementContextSchema: z.ZodObject<{
|
|
23
|
-
database: z.ZodOptional<z.ZodString>;
|
|
24
|
-
schema: z.ZodOptional<z.ZodString>;
|
|
25
|
-
warehouse: z.ZodOptional<z.ZodString>;
|
|
26
|
-
role: z.ZodOptional<z.ZodString>;
|
|
27
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
28
|
-
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
-
}, z.core.$strict>;
|
|
30
|
-
type StatementContext = z.infer<typeof statementContextSchema>;
|
|
31
|
-
/**
|
|
32
|
-
* SQL API v2 supports typed bindings: each binding is an object with a
|
|
33
|
-
* `type` and a `value`. We allow the simple positional shape and the
|
|
34
|
-
* keyed-map shape Snowflake accepts.
|
|
35
|
-
*/
|
|
36
|
-
declare const sqlBindingValueSchema: z.ZodObject<{
|
|
37
|
-
type: z.ZodString;
|
|
38
|
-
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
39
|
-
}, z.core.$strip>;
|
|
40
|
-
declare const sqlBindingsSchema: z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
41
|
-
type: z.ZodString;
|
|
42
|
-
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
43
|
-
}, z.core.$strip>>, z.ZodArray<z.ZodObject<{
|
|
44
|
-
type: z.ZodString;
|
|
45
|
-
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
46
|
-
}, z.core.$strip>>]>;
|
|
47
|
-
type SqlBinding = z.infer<typeof sqlBindingValueSchema>;
|
|
48
|
-
type SqlBindings = z.infer<typeof sqlBindingsSchema>;
|
|
49
|
-
/**
|
|
50
|
-
* Loosely-typed record shape for objects returned by `SHOW ...` commands.
|
|
51
|
-
* Snowflake returns positional arrays with a `rowType[]` describing each
|
|
52
|
-
* column — callers either consume the tuple form directly or `hydrateRow`
|
|
53
|
-
* into a `Record<string, unknown>`.
|
|
54
|
-
*/
|
|
55
|
-
declare const snowflakeObjectRowSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
56
|
-
type SnowflakeObjectRow = z.infer<typeof snowflakeObjectRowSchema>;
|
|
57
|
-
/**
|
|
58
|
-
* Column metadata entry as returned under `resultSetMetaData.rowType`.
|
|
59
|
-
*/
|
|
60
|
-
declare const columnMetaSchema: z.ZodObject<{
|
|
61
|
-
name: z.ZodString;
|
|
62
|
-
type: z.ZodString;
|
|
63
|
-
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
-
length: z.ZodOptional<z.ZodNumber>;
|
|
65
|
-
precision: z.ZodOptional<z.ZodNumber>;
|
|
66
|
-
scale: z.ZodOptional<z.ZodNumber>;
|
|
67
|
-
byteLength: z.ZodOptional<z.ZodNumber>;
|
|
68
|
-
collation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
-
database: z.ZodOptional<z.ZodString>;
|
|
70
|
-
schema: z.ZodOptional<z.ZodString>;
|
|
71
|
-
table: z.ZodOptional<z.ZodString>;
|
|
72
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
73
|
-
type ColumnMeta = z.infer<typeof columnMetaSchema>;
|
|
74
|
-
/**
|
|
75
|
-
* Partition entry describing a shard of the total result set.
|
|
76
|
-
*/
|
|
77
|
-
declare const partitionInfoSchema: z.ZodObject<{
|
|
78
|
-
rowCount: z.ZodNumber;
|
|
79
|
-
uncompressedSize: z.ZodOptional<z.ZodNumber>;
|
|
80
|
-
compressedSize: z.ZodOptional<z.ZodNumber>;
|
|
81
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
82
|
-
type PartitionInfo = z.infer<typeof partitionInfoSchema>;
|
|
83
|
-
declare const resultSetMetaDataSchema: z.ZodObject<{
|
|
84
|
-
numRows: z.ZodOptional<z.ZodNumber>;
|
|
85
|
-
format: z.ZodOptional<z.ZodString>;
|
|
86
|
-
partitionInfo: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
87
|
-
rowCount: z.ZodNumber;
|
|
88
|
-
uncompressedSize: z.ZodOptional<z.ZodNumber>;
|
|
89
|
-
compressedSize: z.ZodOptional<z.ZodNumber>;
|
|
90
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
91
|
-
rowType: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
92
|
-
name: z.ZodString;
|
|
93
|
-
type: z.ZodString;
|
|
94
|
-
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
-
length: z.ZodOptional<z.ZodNumber>;
|
|
96
|
-
precision: z.ZodOptional<z.ZodNumber>;
|
|
97
|
-
scale: z.ZodOptional<z.ZodNumber>;
|
|
98
|
-
byteLength: z.ZodOptional<z.ZodNumber>;
|
|
99
|
-
collation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
100
|
-
database: z.ZodOptional<z.ZodString>;
|
|
101
|
-
schema: z.ZodOptional<z.ZodString>;
|
|
102
|
-
table: z.ZodOptional<z.ZodString>;
|
|
103
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
104
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
105
|
-
type ResultSetMetaData = z.infer<typeof resultSetMetaDataSchema>;
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/schemas/results.d.ts
|
|
108
|
-
declare const partitionResponseSchema: z.ZodObject<{
|
|
109
|
-
statementHandle: z.ZodOptional<z.ZodString>;
|
|
110
|
-
code: z.ZodOptional<z.ZodString>;
|
|
111
|
-
message: z.ZodOptional<z.ZodString>;
|
|
112
|
-
resultSetMetaData: z.ZodOptional<z.ZodObject<{
|
|
113
|
-
numRows: z.ZodOptional<z.ZodNumber>;
|
|
114
|
-
format: z.ZodOptional<z.ZodString>;
|
|
115
|
-
partitionInfo: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
116
|
-
rowCount: z.ZodNumber;
|
|
117
|
-
uncompressedSize: z.ZodOptional<z.ZodNumber>;
|
|
118
|
-
compressedSize: z.ZodOptional<z.ZodNumber>;
|
|
119
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
120
|
-
rowType: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
121
|
-
name: z.ZodString;
|
|
122
|
-
type: z.ZodString;
|
|
123
|
-
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
-
length: z.ZodOptional<z.ZodNumber>;
|
|
125
|
-
precision: z.ZodOptional<z.ZodNumber>;
|
|
126
|
-
scale: z.ZodOptional<z.ZodNumber>;
|
|
127
|
-
byteLength: z.ZodOptional<z.ZodNumber>;
|
|
128
|
-
collation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
|
-
database: z.ZodOptional<z.ZodString>;
|
|
130
|
-
schema: z.ZodOptional<z.ZodString>;
|
|
131
|
-
table: z.ZodOptional<z.ZodString>;
|
|
132
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
133
|
-
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
134
|
-
data: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodUnknown>>>;
|
|
135
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
136
|
-
type PartitionResponse = z.infer<typeof partitionResponseSchema>;
|
|
137
|
-
/**
|
|
138
|
-
* A single logical row as hydrated into an object keyed by column name.
|
|
139
|
-
* Values are permissive (`unknown`) because Snowflake types map to many
|
|
140
|
-
* TS shapes — callers coerce further with `hydrateValue` when needed.
|
|
141
|
-
*/
|
|
142
|
-
type HydratedRow = Record<string, unknown>;
|
|
143
|
-
//#endregion
|
|
144
|
-
//#region src/schemas/statements.d.ts
|
|
145
|
-
/** Status code reported under `code` / `message` alongside the HTTP status. */
|
|
146
|
-
declare const statementStatusCodeSchema: z.ZodString;
|
|
147
|
-
/**
|
|
148
|
-
* Input body for `POST /api/v2/statements`.
|
|
149
|
-
* `statement` is required. All other fields fall back to session / account
|
|
150
|
-
* defaults when omitted.
|
|
151
|
-
*/
|
|
152
|
-
declare const submitStatementInputSchema: z.ZodObject<{
|
|
153
|
-
statement: z.ZodString;
|
|
154
|
-
bindings: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
155
|
-
type: z.ZodString;
|
|
156
|
-
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
157
|
-
}, z.core.$strip>>, z.ZodArray<z.ZodObject<{
|
|
158
|
-
type: z.ZodString;
|
|
159
|
-
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
160
|
-
}, z.core.$strip>>]>>;
|
|
161
|
-
database: z.ZodOptional<z.ZodString>;
|
|
162
|
-
schema: z.ZodOptional<z.ZodString>;
|
|
163
|
-
warehouse: z.ZodOptional<z.ZodString>;
|
|
164
|
-
role: z.ZodOptional<z.ZodString>;
|
|
165
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
166
|
-
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
167
|
-
}, z.core.$strict>;
|
|
168
|
-
type SubmitStatementInput = z.infer<typeof submitStatementInputSchema>;
|
|
169
|
-
/**
|
|
170
|
-
* Response body for a submitted statement — either the inline result (200)
|
|
171
|
-
* or a pending handle (202).
|
|
172
|
-
*/
|
|
173
|
-
declare const statementResponseSchema: z.ZodObject<{
|
|
174
|
-
code: z.ZodOptional<z.ZodString>;
|
|
175
|
-
sqlState: z.ZodOptional<z.ZodString>;
|
|
176
|
-
message: z.ZodOptional<z.ZodString>;
|
|
177
|
-
statementHandle: z.ZodString;
|
|
178
|
-
statementStatusUrl: z.ZodOptional<z.ZodString>;
|
|
179
|
-
createdOn: z.ZodOptional<z.ZodNumber>;
|
|
180
|
-
requestId: z.ZodOptional<z.ZodString>;
|
|
181
|
-
statementHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
182
|
-
resultSetMetaData: z.ZodOptional<z.ZodObject<{
|
|
183
|
-
numRows: z.ZodOptional<z.ZodNumber>;
|
|
184
|
-
format: z.ZodOptional<z.ZodString>;
|
|
185
|
-
partitionInfo: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
186
|
-
rowCount: z.ZodNumber;
|
|
187
|
-
uncompressedSize: z.ZodOptional<z.ZodNumber>;
|
|
188
|
-
compressedSize: z.ZodOptional<z.ZodNumber>;
|
|
189
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
190
|
-
rowType: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
191
|
-
name: z.ZodString;
|
|
192
|
-
type: z.ZodString;
|
|
193
|
-
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
194
|
-
length: z.ZodOptional<z.ZodNumber>;
|
|
195
|
-
precision: z.ZodOptional<z.ZodNumber>;
|
|
196
|
-
scale: z.ZodOptional<z.ZodNumber>;
|
|
197
|
-
byteLength: z.ZodOptional<z.ZodNumber>;
|
|
198
|
-
collation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
199
|
-
database: z.ZodOptional<z.ZodString>;
|
|
200
|
-
schema: z.ZodOptional<z.ZodString>;
|
|
201
|
-
table: z.ZodOptional<z.ZodString>;
|
|
202
|
-
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
203
|
-
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
204
|
-
data: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodUnknown>>>;
|
|
205
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
206
|
-
type StatementResponse = z.infer<typeof statementResponseSchema>;
|
|
207
|
-
/**
|
|
208
|
-
* Terminal + transient statuses as exposed through the `code` field. Most
|
|
209
|
-
* callers only care whether the statement is `pending`, `done`, or
|
|
210
|
-
* `failed` — the `statementStatus` helper below compresses the raw `code`
|
|
211
|
-
* into those buckets.
|
|
212
|
-
*/
|
|
213
|
-
type StatementTerminalStatus = 'done' | 'failed' | 'cancelled';
|
|
214
|
-
type StatementStatus = StatementTerminalStatus | 'pending';
|
|
215
|
-
/**
|
|
216
|
-
* Snowflake code ranges (SQL API v2):
|
|
217
|
-
* - 090002 — success (inline result)
|
|
218
|
-
* - 333333 — statement accepted (async)
|
|
219
|
-
* - 333334 — statement executing (still polling)
|
|
220
|
-
* - 333335 — user-triggered cancel succeeded
|
|
221
|
-
* - 390xxx / 3900xx / 0919xx / ... — SQL-level failures
|
|
222
|
-
*
|
|
223
|
-
* We map explicitly the two non-error status codes; everything else is
|
|
224
|
-
* treated as `failed` when the HTTP status is also an error, otherwise
|
|
225
|
-
* `done`.
|
|
226
|
-
*/
|
|
227
|
-
declare function statementStatus(input: {
|
|
228
|
-
httpStatus: number;
|
|
229
|
-
code?: string | undefined;
|
|
230
|
-
}): StatementStatus;
|
|
231
|
-
declare const cancelStatementResponseSchema: z.ZodObject<{
|
|
232
|
-
code: z.ZodOptional<z.ZodString>;
|
|
233
|
-
message: z.ZodOptional<z.ZodString>;
|
|
234
|
-
statementHandle: z.ZodOptional<z.ZodString>;
|
|
235
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
236
|
-
type CancelStatementResponse = z.infer<typeof cancelStatementResponseSchema>;
|
|
237
|
-
//#endregion
|
|
238
|
-
export { resultSetMetaDataSchema as C, sqlBindingValueSchema as D, snowflakeObjectRowSchema as E, sqlBindingsSchema as O, partitionInfoSchema as S, snowflakeIdentifier as T, SnowflakeObjectRow as _, SubmitStatementInput as a, StatementContext as b, statementStatus as c, HydratedRow as d, PartitionResponse as f, ResultSetMetaData as g, PartitionInfo as h, StatementTerminalStatus as i, statementContextSchema as k, statementStatusCodeSchema as l, ColumnMeta as m, StatementResponse as n, cancelStatementResponseSchema as o, partitionResponseSchema as p, StatementStatus as r, statementResponseSchema as s, CancelStatementResponse as t, submitStatementInputSchema as u, SqlBinding as v, snowflakeFqn as w, columnMetaSchema as x, SqlBindings as y };
|