@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,39 +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, showFileFormats } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/file-formats/index.d.ts
|
|
7
|
-
interface FileFormatRef {
|
|
8
|
-
readonly database?: string;
|
|
9
|
-
readonly schema?: string;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
}
|
|
12
|
-
interface FileFormatContext {
|
|
13
|
-
readonly warehouse?: string;
|
|
14
|
-
readonly role?: string;
|
|
15
|
-
}
|
|
16
|
-
interface CreateFileFormatOptions extends FileFormatRef, FileFormatContext {
|
|
17
|
-
readonly orReplace?: boolean;
|
|
18
|
-
readonly ifNotExists?: boolean;
|
|
19
|
-
readonly temporary?: boolean;
|
|
20
|
-
/** `TYPE = 'CSV'`, `FIELD_DELIMITER = '|'`, `SKIP_HEADER = 1`, etc. */
|
|
21
|
-
readonly options: OptionMap;
|
|
22
|
-
readonly comment?: string;
|
|
23
|
-
}
|
|
24
|
-
declare function createFileFormat(client: SnowflakeClient, options: CreateFileFormatOptions): Promise<void>;
|
|
25
|
-
interface AlterFileFormatOptions extends FileFormatRef, FileFormatContext {
|
|
26
|
-
readonly rename?: FileFormatRef;
|
|
27
|
-
readonly set?: OptionMap;
|
|
28
|
-
readonly unset?: readonly string[];
|
|
29
|
-
readonly comment?: string;
|
|
30
|
-
}
|
|
31
|
-
declare function alterFileFormat(client: SnowflakeClient, options: AlterFileFormatOptions): Promise<void>;
|
|
32
|
-
interface DropFileFormatOptions extends FileFormatRef, FileFormatContext {
|
|
33
|
-
readonly ifExists?: boolean;
|
|
34
|
-
}
|
|
35
|
-
declare function dropFileFormat(client: SnowflakeClient, options: DropFileFormatOptions): Promise<void>;
|
|
36
|
-
interface DescribeFileFormatOptions extends FileFormatRef, FileFormatContext {}
|
|
37
|
-
declare function describeFileFormat(client: SnowflakeClient, options: DescribeFileFormatOptions): Promise<readonly HydratedRow[]>;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { AlterFileFormatOptions, type CatalogResult, CreateFileFormatOptions, DescribeFileFormatOptions, DropFileFormatOptions, FileFormatContext, FileFormatRef, type ShowScopedOptions, alterFileFormat, createFileFormat, describeFileFormat, dropFileFormat, showFileFormats };
|
|
@@ -1,48 +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 { showFileFormats } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/file-formats/index.ts
|
|
7
|
-
function fileFormatFqn(ref) {
|
|
8
|
-
return buildFqn(ref.database, ref.schema, ref.name);
|
|
9
|
-
}
|
|
10
|
-
async function createFileFormat(client, options) {
|
|
11
|
-
const prefix = `CREATE${options.orReplace ? " OR REPLACE" : ""}${options.temporary ? " TEMPORARY" : ""} FILE FORMAT${options.ifNotExists ? " IF NOT EXISTS" : ""}`;
|
|
12
|
-
const body = formatOptions(options.options);
|
|
13
|
-
await executeSql(client, {
|
|
14
|
-
statement: `${prefix} ${fileFormatFqn(options)} ${body}` + (options.comment ? ` COMMENT = ${quoteLiteral(options.comment)}` : ""),
|
|
15
|
-
warehouse: options.warehouse,
|
|
16
|
-
role: options.role
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async function alterFileFormat(client, options) {
|
|
20
|
-
let tail;
|
|
21
|
-
if (options.rename) tail = `RENAME TO ${fileFormatFqn(options.rename)}`;
|
|
22
|
-
else if (options.set && Object.keys(options.set).length > 0) tail = `SET ${formatOptions(options.set)}`;
|
|
23
|
-
else if (options.unset && options.unset.length > 0) tail = `UNSET ${options.unset.map((k) => k.toUpperCase()).join(", ")}`;
|
|
24
|
-
else if (options.comment !== void 0) tail = `SET COMMENT = ${quoteLiteral(options.comment)}`;
|
|
25
|
-
else throw new Error("alterFileFormat requires one of: rename / set / unset / comment");
|
|
26
|
-
await executeSql(client, {
|
|
27
|
-
statement: `ALTER FILE FORMAT ${fileFormatFqn(options)} ${tail}`,
|
|
28
|
-
warehouse: options.warehouse,
|
|
29
|
-
role: options.role
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
async function dropFileFormat(client, options) {
|
|
33
|
-
await executeSql(client, {
|
|
34
|
-
statement: `DROP FILE FORMAT${options.ifExists ? " IF EXISTS" : ""} ${fileFormatFqn(options)}`,
|
|
35
|
-
warehouse: options.warehouse,
|
|
36
|
-
role: options.role
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async function describeFileFormat(client, options) {
|
|
40
|
-
return (await executeSql(client, {
|
|
41
|
-
statement: `DESCRIBE FILE FORMAT ${fileFormatFqn(options)}`,
|
|
42
|
-
warehouse: options.warehouse,
|
|
43
|
-
role: options.role
|
|
44
|
-
})).rows;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { alterFileFormat, createFileFormat, describeFileFormat, dropFileFormat, showFileFormats };
|
|
@@ -1,53 +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, showFunctions } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/functions/index.d.ts
|
|
7
|
-
interface FunctionRef {
|
|
8
|
-
readonly database?: string;
|
|
9
|
-
readonly schema?: string;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
}
|
|
12
|
-
interface FunctionContext {
|
|
13
|
-
readonly warehouse?: string;
|
|
14
|
-
readonly role?: string;
|
|
15
|
-
}
|
|
16
|
-
interface FunctionArgument {
|
|
17
|
-
readonly name: string;
|
|
18
|
-
/** Snowflake type keyword (NUMBER, VARCHAR, DATE, VARIANT, ...). */
|
|
19
|
-
readonly type: string;
|
|
20
|
-
readonly defaultExpression?: string;
|
|
21
|
-
}
|
|
22
|
-
type FunctionLanguage = 'SQL' | 'JAVASCRIPT' | 'PYTHON' | 'JAVA' | 'SCALA';
|
|
23
|
-
interface CreateFunctionOptions extends FunctionRef, FunctionContext {
|
|
24
|
-
readonly orReplace?: boolean;
|
|
25
|
-
readonly ifNotExists?: boolean;
|
|
26
|
-
readonly secure?: boolean;
|
|
27
|
-
readonly temporary?: boolean;
|
|
28
|
-
readonly arguments?: readonly FunctionArgument[];
|
|
29
|
-
/** Return type keyword, e.g. `NUMBER`, `VARCHAR`, `TABLE (col1 NUMBER, col2 VARCHAR)`. */
|
|
30
|
-
readonly returns: string;
|
|
31
|
-
readonly language?: FunctionLanguage;
|
|
32
|
-
/** `STRICT`, `IMMUTABLE`, `VOLATILE`, `MEMOIZABLE`, `RETURNS NULL ON NULL INPUT`. Raw keywords joined with spaces. */
|
|
33
|
-
readonly modifiers?: readonly string[];
|
|
34
|
-
/** Language-specific options: `RUNTIME_VERSION = '3.10'`, `PACKAGES = ('snowflake-snowpark-python')`, `HANDLER = 'main'`, `IMPORTS = (@STG/pkg.zip)`. */
|
|
35
|
-
readonly options?: OptionMap;
|
|
36
|
-
readonly comment?: string;
|
|
37
|
-
/** Function body (SQL expression, JS, Python, Java). `$$...$$` wrapping is applied automatically for non-SQL languages. */
|
|
38
|
-
readonly as: string;
|
|
39
|
-
/** Force `$$...$$` (dollar-quoted) body delimiter even for SQL. */
|
|
40
|
-
readonly dollarQuotedBody?: boolean;
|
|
41
|
-
}
|
|
42
|
-
declare function createFunction(client: SnowflakeClient, options: CreateFunctionOptions): Promise<void>;
|
|
43
|
-
interface DropFunctionOptions extends FunctionRef, FunctionContext {
|
|
44
|
-
readonly ifExists?: boolean;
|
|
45
|
-
readonly arguments?: readonly FunctionArgument[];
|
|
46
|
-
}
|
|
47
|
-
declare function dropFunction(client: SnowflakeClient, options: DropFunctionOptions): Promise<void>;
|
|
48
|
-
interface DescribeFunctionOptions extends FunctionRef, FunctionContext {
|
|
49
|
-
readonly arguments?: readonly FunctionArgument[];
|
|
50
|
-
}
|
|
51
|
-
declare function describeFunction(client: SnowflakeClient, options: DescribeFunctionOptions): Promise<readonly HydratedRow[]>;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { type CatalogResult, CreateFunctionOptions, DescribeFunctionOptions, DropFunctionOptions, FunctionArgument, FunctionContext, FunctionLanguage, FunctionRef, type ShowScopedOptions, createFunction, describeFunction, dropFunction, showFunctions };
|
package/dist/functions/index.mjs
DELETED
|
@@ -1,56 +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 { showFunctions } from "../catalog/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/functions/index.ts
|
|
7
|
-
function renderArguments(args) {
|
|
8
|
-
if (!args || args.length === 0) return "()";
|
|
9
|
-
return `(${args.map((a) => {
|
|
10
|
-
const suffix = a.defaultExpression ? ` DEFAULT ${a.defaultExpression}` : "";
|
|
11
|
-
return `${a.name} ${a.type.toUpperCase()}${suffix}`;
|
|
12
|
-
}).join(", ")})`;
|
|
13
|
-
}
|
|
14
|
-
function renderArgumentTypes(args) {
|
|
15
|
-
if (!args || args.length === 0) return "()";
|
|
16
|
-
return `(${args.map((a) => a.type.toUpperCase()).join(", ")})`;
|
|
17
|
-
}
|
|
18
|
-
function renderBody(body, forceDollarQuoted, language) {
|
|
19
|
-
if (forceDollarQuoted ?? (language !== void 0 && language !== "SQL")) {
|
|
20
|
-
if (body.includes("$$")) throw new Error("Function body contains \"$$\"; cannot safely dollar-quote. Use quoteLiteral-style body or a custom delimiter.");
|
|
21
|
-
return `$$${body}$$`;
|
|
22
|
-
}
|
|
23
|
-
return body;
|
|
24
|
-
}
|
|
25
|
-
async function createFunction(client, options) {
|
|
26
|
-
const prefix = `CREATE${options.orReplace ? " OR REPLACE" : ""}${options.secure ? " SECURE" : ""}${options.temporary ? " TEMPORARY" : ""} FUNCTION${options.ifNotExists ? " IF NOT EXISTS" : ""}`;
|
|
27
|
-
const args = renderArguments(options.arguments);
|
|
28
|
-
const language = options.language ? ` LANGUAGE ${options.language}` : "";
|
|
29
|
-
const modifiers = options.modifiers && options.modifiers.length > 0 ? ` ${options.modifiers.map((m) => m.toUpperCase()).join(" ")}` : "";
|
|
30
|
-
const body = options.options && Object.keys(options.options).length > 0 ? ` ${formatOptions(options.options)}` : "";
|
|
31
|
-
const comment = options.comment ? ` COMMENT = ${quoteLiteral(options.comment)}` : "";
|
|
32
|
-
const rendered = renderBody(options.as, options.dollarQuotedBody, options.language);
|
|
33
|
-
await executeSql(client, {
|
|
34
|
-
statement: `${prefix} ${buildFqn(options.database, options.schema, options.name)}${args} RETURNS ${options.returns}${language}${modifiers}${body}${comment} AS ${rendered}`,
|
|
35
|
-
warehouse: options.warehouse,
|
|
36
|
-
role: options.role
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async function dropFunction(client, options) {
|
|
40
|
-
const fqn = buildFqn(options.database, options.schema, options.name);
|
|
41
|
-
await executeSql(client, {
|
|
42
|
-
statement: `DROP FUNCTION${options.ifExists ? " IF EXISTS" : ""} ${fqn}${renderArgumentTypes(options.arguments)}`,
|
|
43
|
-
warehouse: options.warehouse,
|
|
44
|
-
role: options.role
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async function describeFunction(client, options) {
|
|
48
|
-
return (await executeSql(client, {
|
|
49
|
-
statement: `DESCRIBE FUNCTION ${buildFqn(options.database, options.schema, options.name)}${renderArgumentTypes(options.arguments)}`,
|
|
50
|
-
warehouse: options.warehouse,
|
|
51
|
-
role: options.role
|
|
52
|
-
})).rows;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { createFunction, describeFunction, dropFunction, showFunctions };
|
package/dist/grants/index.d.mts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { SnowflakeClient } from "../client/index.mjs";
|
|
2
|
-
import { CatalogResult, ShowOptions, showGrants } from "../catalog/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/grants/index.d.ts
|
|
5
|
-
interface GrantContext {
|
|
6
|
-
readonly warehouse?: string;
|
|
7
|
-
readonly role?: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* What a privilege is being granted on. `kind: 'object'` covers the
|
|
11
|
-
* vast majority of cases (TABLE / VIEW / STAGE / FILE FORMAT / FUNCTION /
|
|
12
|
-
* PROCEDURE / STREAM / TASK / PIPE / ...). Scope-level variants
|
|
13
|
-
* (`database` / `schema` / `warehouse` / `role` / `integration` / `account`)
|
|
14
|
-
* cover grants that apply to whole containers. `allIn` / `futureIn`
|
|
15
|
-
* produce `GRANT ... ON ALL|FUTURE <PLURAL> IN ...` statements.
|
|
16
|
-
*/
|
|
17
|
-
type GrantOn = {
|
|
18
|
-
readonly kind: 'object'; /** Snowflake object keyword, e.g., `TABLE`, `VIEW`, `STAGE`. */
|
|
19
|
-
readonly objectType: string;
|
|
20
|
-
readonly database?: string;
|
|
21
|
-
readonly schema?: string;
|
|
22
|
-
readonly name: string;
|
|
23
|
-
} | {
|
|
24
|
-
readonly kind: 'database' | 'warehouse' | 'role' | 'integration';
|
|
25
|
-
readonly name: string;
|
|
26
|
-
} | {
|
|
27
|
-
readonly kind: 'schema';
|
|
28
|
-
readonly database?: string;
|
|
29
|
-
readonly name: string;
|
|
30
|
-
} | {
|
|
31
|
-
readonly kind: 'account';
|
|
32
|
-
} | {
|
|
33
|
-
readonly kind: 'allIn' | 'futureIn'; /** Plural keyword, e.g., `TABLES`, `VIEWS`, `SCHEMAS`. */
|
|
34
|
-
readonly pluralType: string;
|
|
35
|
-
readonly inDatabase?: string;
|
|
36
|
-
readonly inSchema?: {
|
|
37
|
-
readonly database?: string;
|
|
38
|
-
readonly name: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
type GrantTarget = {
|
|
42
|
-
readonly role: string;
|
|
43
|
-
} | {
|
|
44
|
-
readonly user: string;
|
|
45
|
-
} | {
|
|
46
|
-
readonly share: string;
|
|
47
|
-
};
|
|
48
|
-
interface GrantPrivilegesOptions extends GrantContext {
|
|
49
|
-
readonly privileges: 'ALL' | 'ALL PRIVILEGES' | readonly string[];
|
|
50
|
-
readonly on: GrantOn;
|
|
51
|
-
readonly to: GrantTarget;
|
|
52
|
-
readonly withGrantOption?: boolean;
|
|
53
|
-
}
|
|
54
|
-
declare function grantPrivileges(client: SnowflakeClient, options: GrantPrivilegesOptions): Promise<void>;
|
|
55
|
-
interface RevokePrivilegesOptions extends GrantContext {
|
|
56
|
-
readonly privileges: 'ALL' | 'ALL PRIVILEGES' | readonly string[];
|
|
57
|
-
readonly on: GrantOn;
|
|
58
|
-
readonly from: GrantTarget;
|
|
59
|
-
/** Only revoke the grant option, not the underlying privilege. */
|
|
60
|
-
readonly grantOptionFor?: boolean;
|
|
61
|
-
readonly cascade?: boolean;
|
|
62
|
-
readonly restrict?: boolean;
|
|
63
|
-
}
|
|
64
|
-
declare function revokePrivileges(client: SnowflakeClient, options: RevokePrivilegesOptions): Promise<void>;
|
|
65
|
-
interface ShowGrantsToRoleOptions extends ShowOptions {
|
|
66
|
-
readonly role: string;
|
|
67
|
-
}
|
|
68
|
-
declare function showGrantsToRole(client: SnowflakeClient, options: ShowGrantsToRoleOptions): Promise<CatalogResult>;
|
|
69
|
-
interface ShowGrantsToUserOptions extends ShowOptions {
|
|
70
|
-
readonly user: string;
|
|
71
|
-
}
|
|
72
|
-
declare function showGrantsToUser(client: SnowflakeClient, options: ShowGrantsToUserOptions): Promise<CatalogResult>;
|
|
73
|
-
interface ShowGrantsOnObjectOptions extends ShowOptions {
|
|
74
|
-
readonly objectType: string;
|
|
75
|
-
readonly database?: string;
|
|
76
|
-
readonly schema?: string;
|
|
77
|
-
readonly name: string;
|
|
78
|
-
}
|
|
79
|
-
declare function showGrantsOnObject(client: SnowflakeClient, options: ShowGrantsOnObjectOptions): Promise<CatalogResult>;
|
|
80
|
-
interface ShowGrantsOfRoleOptions extends ShowOptions {
|
|
81
|
-
readonly role: string;
|
|
82
|
-
}
|
|
83
|
-
declare function showGrantsOfRole(client: SnowflakeClient, options: ShowGrantsOfRoleOptions): Promise<CatalogResult>;
|
|
84
|
-
interface ShowFutureGrantsOptions extends ShowOptions {
|
|
85
|
-
readonly inDatabase?: string;
|
|
86
|
-
readonly inSchema?: {
|
|
87
|
-
readonly database?: string;
|
|
88
|
-
readonly name: string;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
declare function showFutureGrants(client: SnowflakeClient, options: ShowFutureGrantsOptions): Promise<CatalogResult>;
|
|
92
|
-
//#endregion
|
|
93
|
-
export { type CatalogResult, GrantContext, GrantOn, GrantPrivilegesOptions, GrantTarget, RevokePrivilegesOptions, ShowFutureGrantsOptions, ShowGrantsOfRoleOptions, ShowGrantsOnObjectOptions, ShowGrantsToRoleOptions, ShowGrantsToUserOptions, grantPrivileges, revokePrivileges, showFutureGrants, showGrants, showGrantsOfRole, showGrantsOnObject, showGrantsToRole, showGrantsToUser };
|
package/dist/grants/index.mjs
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { executeSql } from "../sql/index.mjs";
|
|
2
|
-
import { i as quoteIdentifier, t as buildFqn } from "../sql-safety-BZpAPsq6.mjs";
|
|
3
|
-
import { showGrants } from "../catalog/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/grants/index.ts
|
|
6
|
-
/**
|
|
7
|
-
* Grants / privileges: GRANT, REVOKE, and five SHOW GRANTS convenience
|
|
8
|
-
* wrappers plus SHOW FUTURE GRANTS.
|
|
9
|
-
*
|
|
10
|
-
* Covers PLAN §6.15 (7 actions).
|
|
11
|
-
*/
|
|
12
|
-
function renderScope(on) {
|
|
13
|
-
switch (on.kind) {
|
|
14
|
-
case "object": return `${on.objectType.toUpperCase()} ${buildFqn(on.database, on.schema, on.name)}`;
|
|
15
|
-
case "schema": return `SCHEMA ${buildFqn(on.database, on.name)}`;
|
|
16
|
-
case "database": return `DATABASE ${quoteIdentifier(on.name)}`;
|
|
17
|
-
case "warehouse": return `WAREHOUSE ${quoteIdentifier(on.name)}`;
|
|
18
|
-
case "role": return `ROLE ${quoteIdentifier(on.name)}`;
|
|
19
|
-
case "integration": return `INTEGRATION ${quoteIdentifier(on.name)}`;
|
|
20
|
-
case "account": return "ACCOUNT";
|
|
21
|
-
case "allIn":
|
|
22
|
-
case "futureIn": {
|
|
23
|
-
const modifier = on.kind === "allIn" ? "ALL" : "FUTURE";
|
|
24
|
-
const plural = on.pluralType.toUpperCase();
|
|
25
|
-
if (on.inDatabase) return `${modifier} ${plural} IN DATABASE ${quoteIdentifier(on.inDatabase)}`;
|
|
26
|
-
if (on.inSchema) return `${modifier} ${plural} IN SCHEMA ${buildFqn(on.inSchema.database, on.inSchema.name)}`;
|
|
27
|
-
throw new Error(`${on.kind} requires inDatabase or inSchema`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function renderTarget(target) {
|
|
32
|
-
if ("role" in target) return `ROLE ${quoteIdentifier(target.role)}`;
|
|
33
|
-
if ("user" in target) return `USER ${quoteIdentifier(target.user)}`;
|
|
34
|
-
return `SHARE ${quoteIdentifier(target.share)}`;
|
|
35
|
-
}
|
|
36
|
-
function renderPrivileges(privileges) {
|
|
37
|
-
if (privileges === "ALL" || privileges === "ALL PRIVILEGES") return "ALL PRIVILEGES";
|
|
38
|
-
if (privileges.length === 0) throw new Error("privileges must be non-empty (or \"ALL\" / \"ALL PRIVILEGES\")");
|
|
39
|
-
return privileges.map((p) => p.toUpperCase()).join(", ");
|
|
40
|
-
}
|
|
41
|
-
async function grantPrivileges(client, options) {
|
|
42
|
-
await executeSql(client, {
|
|
43
|
-
statement: `GRANT ${renderPrivileges(options.privileges)} ON ${renderScope(options.on)} TO ${renderTarget(options.to)}${options.withGrantOption ? " WITH GRANT OPTION" : ""}`,
|
|
44
|
-
warehouse: options.warehouse,
|
|
45
|
-
role: options.role
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async function revokePrivileges(client, options) {
|
|
49
|
-
if (options.cascade && options.restrict) throw new Error("revokePrivileges: cascade and restrict are mutually exclusive");
|
|
50
|
-
await executeSql(client, {
|
|
51
|
-
statement: `${options.grantOptionFor ? "REVOKE GRANT OPTION FOR" : "REVOKE"} ${renderPrivileges(options.privileges)} ON ${renderScope(options.on)} FROM ${renderTarget(options.from)}${options.cascade ? " CASCADE" : options.restrict ? " RESTRICT" : ""}`,
|
|
52
|
-
warehouse: options.warehouse,
|
|
53
|
-
role: options.role
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
async function showGrantsToRole(client, options) {
|
|
57
|
-
return showGrants(client, {
|
|
58
|
-
...options,
|
|
59
|
-
toRole: options.role
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async function showGrantsToUser(client, options) {
|
|
63
|
-
return showGrants(client, {
|
|
64
|
-
...options,
|
|
65
|
-
toUser: options.user
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
async function showGrantsOnObject(client, options) {
|
|
69
|
-
return showGrants(client, {
|
|
70
|
-
...options,
|
|
71
|
-
on: {
|
|
72
|
-
objectType: options.objectType,
|
|
73
|
-
database: options.database,
|
|
74
|
-
schema: options.schema,
|
|
75
|
-
name: options.name
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
async function showGrantsOfRole(client, options) {
|
|
80
|
-
return showGrants(client, {
|
|
81
|
-
...options,
|
|
82
|
-
ofRole: options.role
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async function showFutureGrants(client, options) {
|
|
86
|
-
let scope;
|
|
87
|
-
if (options.inDatabase) scope = `DATABASE ${quoteIdentifier(options.inDatabase)}`;
|
|
88
|
-
else if (options.inSchema) scope = `SCHEMA ${buildFqn(options.inSchema.database, options.inSchema.name)}`;
|
|
89
|
-
else throw new Error("showFutureGrants requires inDatabase or inSchema");
|
|
90
|
-
const result = await executeSql(client, {
|
|
91
|
-
statement: `SHOW FUTURE GRANTS IN ${scope}`,
|
|
92
|
-
warehouse: options.warehouse,
|
|
93
|
-
role: options.role
|
|
94
|
-
});
|
|
95
|
-
return {
|
|
96
|
-
rows: result.rows,
|
|
97
|
-
columns: result.columns
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
//#endregion
|
|
102
|
-
export { grantPrivileges, revokePrivileges, showFutureGrants, showGrants, showGrantsOfRole, showGrantsOnObject, showGrantsToRole, showGrantsToUser };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { SnowflakeClient } from "../client/index.mjs";
|
|
2
|
-
import { d as HydratedRow, m as ColumnMeta } from "../statements-DJL0qVNA.mjs";
|
|
3
|
-
import { t as OptionMap } from "../sql-options-2k5xQ-oS.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/org-admin/index.d.ts
|
|
6
|
-
interface OrgAdminContext {
|
|
7
|
-
readonly warehouse?: string;
|
|
8
|
-
readonly role?: string;
|
|
9
|
-
}
|
|
10
|
-
interface ListOrganizationAccountsOptions extends OrgAdminContext {
|
|
11
|
-
readonly like?: string;
|
|
12
|
-
}
|
|
13
|
-
interface ListOrganizationAccountsResult {
|
|
14
|
-
readonly columns: readonly ColumnMeta[];
|
|
15
|
-
readonly rows: readonly HydratedRow[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* `SHOW ORGANIZATION ACCOUNTS`. Lists every account in the org (ORGADMIN
|
|
19
|
-
* only).
|
|
20
|
-
*/
|
|
21
|
-
declare function listOrganizationAccounts(client: SnowflakeClient, options?: ListOrganizationAccountsOptions): Promise<ListOrganizationAccountsResult>;
|
|
22
|
-
interface CreateOrganizationAccountOptions extends OrgAdminContext {
|
|
23
|
-
readonly name: string;
|
|
24
|
-
readonly adminName: string;
|
|
25
|
-
readonly adminPassword: string;
|
|
26
|
-
readonly email: string;
|
|
27
|
-
/** `STANDARD`, `ENTERPRISE`, `BUSINESS_CRITICAL`, `VPS`. */
|
|
28
|
-
readonly edition: 'STANDARD' | 'ENTERPRISE' | 'BUSINESS_CRITICAL' | 'VPS';
|
|
29
|
-
/** Snowflake region identifier, e.g. `AWS_US_WEST_2`. */
|
|
30
|
-
readonly region?: string;
|
|
31
|
-
readonly regionGroup?: string;
|
|
32
|
-
readonly firstName?: string;
|
|
33
|
-
readonly lastName?: string;
|
|
34
|
-
readonly mustChangePassword?: boolean;
|
|
35
|
-
readonly comment?: string;
|
|
36
|
-
/** Any other `KEY = value` options the org admin wants to forward. */
|
|
37
|
-
readonly options?: OptionMap;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* `CREATE ORGANIZATION ACCOUNT <name>
|
|
41
|
-
* ADMIN_NAME = '...' ADMIN_PASSWORD = '...' EMAIL = '...'
|
|
42
|
-
* EDITION = '...' [REGION = '...'] [REGION_GROUP = '...']
|
|
43
|
-
* [FIRST_NAME = '...'] [LAST_NAME = '...']
|
|
44
|
-
* [MUST_CHANGE_PASSWORD = TRUE|FALSE]
|
|
45
|
-
* [COMMENT = '...']`
|
|
46
|
-
*/
|
|
47
|
-
declare function createOrganizationAccount(client: SnowflakeClient, options: CreateOrganizationAccountOptions): Promise<void>;
|
|
48
|
-
interface AlterAccountOptions extends OrgAdminContext {
|
|
49
|
-
/**
|
|
50
|
-
* Target account name — if omitted, the statement targets the current
|
|
51
|
-
* account (`ALTER ACCOUNT SET ...`). When provided, Snowflake runs it as
|
|
52
|
-
* `ALTER ACCOUNT <name> SET ...` (ORGADMIN scope).
|
|
53
|
-
*/
|
|
54
|
-
readonly name?: string;
|
|
55
|
-
readonly ifExists?: boolean;
|
|
56
|
-
readonly set?: OptionMap;
|
|
57
|
-
readonly unset?: readonly string[];
|
|
58
|
-
readonly setResourceMonitor?: string;
|
|
59
|
-
readonly unsetResourceMonitor?: boolean;
|
|
60
|
-
readonly comment?: string;
|
|
61
|
-
}
|
|
62
|
-
declare function alterAccount(client: SnowflakeClient, options: AlterAccountOptions): Promise<void>;
|
|
63
|
-
interface EnableAccountFeatureOptions extends OrgAdminContext {
|
|
64
|
-
/** Feature parameter name, e.g. `ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR`. */
|
|
65
|
-
readonly feature: string;
|
|
66
|
-
/** When `false`, emits `SET <FEATURE> = FALSE` (i.e., disables it). */
|
|
67
|
-
readonly enabled?: boolean;
|
|
68
|
-
readonly ifExists?: boolean;
|
|
69
|
-
/** Scope the change to a specific account (requires ORGADMIN). */
|
|
70
|
-
readonly name?: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Generic `ALTER ACCOUNT SET <FEATURE> = TRUE|FALSE` wrapper. Snowflake
|
|
74
|
-
* exposes a growing set of account-level boolean parameters; this helper
|
|
75
|
-
* keeps the pattern uniform for workflow authors without embedding the
|
|
76
|
-
* full (ever-changing) feature catalogue in the package.
|
|
77
|
-
*/
|
|
78
|
-
declare function enableAccountFeature(client: SnowflakeClient, options: EnableAccountFeatureOptions): Promise<void>;
|
|
79
|
-
//#endregion
|
|
80
|
-
export { AlterAccountOptions, CreateOrganizationAccountOptions, EnableAccountFeatureOptions, ListOrganizationAccountsOptions, ListOrganizationAccountsResult, OrgAdminContext, alterAccount, createOrganizationAccount, enableAccountFeature, listOrganizationAccounts };
|
package/dist/org-admin/index.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { executeSql } from "../sql/index.mjs";
|
|
2
|
-
import { a as quoteLiteral, i as quoteIdentifier, r as likeClause } from "../sql-safety-BZpAPsq6.mjs";
|
|
3
|
-
import { t as formatOptions } from "../sql-options-D6GEa21F.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/org-admin/index.ts
|
|
6
|
-
/**
|
|
7
|
-
* `SHOW ORGANIZATION ACCOUNTS`. Lists every account in the org (ORGADMIN
|
|
8
|
-
* only).
|
|
9
|
-
*/
|
|
10
|
-
async function listOrganizationAccounts(client, options = {}) {
|
|
11
|
-
const result = await executeSql(client, {
|
|
12
|
-
statement: `SHOW ORGANIZATION ACCOUNTS${likeClause(options.like)}`,
|
|
13
|
-
warehouse: options.warehouse,
|
|
14
|
-
role: options.role
|
|
15
|
-
});
|
|
16
|
-
return {
|
|
17
|
-
columns: result.columns,
|
|
18
|
-
rows: result.rows
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* `CREATE ORGANIZATION ACCOUNT <name>
|
|
23
|
-
* ADMIN_NAME = '...' ADMIN_PASSWORD = '...' EMAIL = '...'
|
|
24
|
-
* EDITION = '...' [REGION = '...'] [REGION_GROUP = '...']
|
|
25
|
-
* [FIRST_NAME = '...'] [LAST_NAME = '...']
|
|
26
|
-
* [MUST_CHANGE_PASSWORD = TRUE|FALSE]
|
|
27
|
-
* [COMMENT = '...']`
|
|
28
|
-
*/
|
|
29
|
-
async function createOrganizationAccount(client, options) {
|
|
30
|
-
const parts = [
|
|
31
|
-
`ADMIN_NAME = ${quoteLiteral(options.adminName)}`,
|
|
32
|
-
`ADMIN_PASSWORD = ${quoteLiteral(options.adminPassword)}`,
|
|
33
|
-
`EMAIL = ${quoteLiteral(options.email)}`,
|
|
34
|
-
`EDITION = ${quoteLiteral(options.edition)}`
|
|
35
|
-
];
|
|
36
|
-
if (options.region) parts.push(`REGION = ${quoteLiteral(options.region)}`);
|
|
37
|
-
if (options.regionGroup) parts.push(`REGION_GROUP = ${quoteLiteral(options.regionGroup)}`);
|
|
38
|
-
if (options.firstName) parts.push(`FIRST_NAME = ${quoteLiteral(options.firstName)}`);
|
|
39
|
-
if (options.lastName) parts.push(`LAST_NAME = ${quoteLiteral(options.lastName)}`);
|
|
40
|
-
if (options.mustChangePassword !== void 0) parts.push(`MUST_CHANGE_PASSWORD = ${options.mustChangePassword ? "TRUE" : "FALSE"}`);
|
|
41
|
-
if (options.comment) parts.push(`COMMENT = ${quoteLiteral(options.comment)}`);
|
|
42
|
-
if (options.options && Object.keys(options.options).length > 0) parts.push(formatOptions(options.options));
|
|
43
|
-
await executeSql(client, {
|
|
44
|
-
statement: `CREATE ORGANIZATION ACCOUNT ${quoteIdentifier(options.name)} ${parts.join(" ")}`,
|
|
45
|
-
warehouse: options.warehouse,
|
|
46
|
-
role: options.role
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async function alterAccount(client, options) {
|
|
50
|
-
let tail;
|
|
51
|
-
if (options.setResourceMonitor !== void 0) tail = `SET RESOURCE_MONITOR = ${quoteIdentifier(options.setResourceMonitor)}`;
|
|
52
|
-
else if (options.unsetResourceMonitor) tail = "UNSET RESOURCE_MONITOR";
|
|
53
|
-
else if (options.set && Object.keys(options.set).length > 0) tail = `SET ${formatOptions(options.set)}`;
|
|
54
|
-
else if (options.unset && options.unset.length > 0) tail = `UNSET ${options.unset.map((k) => k.toUpperCase()).join(", ")}`;
|
|
55
|
-
else if (options.comment !== void 0) tail = `SET COMMENT = ${quoteLiteral(options.comment)}`;
|
|
56
|
-
else throw new Error("alterAccount requires one of: set / unset / setResourceMonitor / unsetResourceMonitor / comment");
|
|
57
|
-
await executeSql(client, {
|
|
58
|
-
statement: `ALTER ACCOUNT${options.ifExists ? " IF EXISTS" : ""}${options.name ? ` ${quoteIdentifier(options.name)}` : ""} ${tail}`,
|
|
59
|
-
warehouse: options.warehouse,
|
|
60
|
-
role: options.role
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Generic `ALTER ACCOUNT SET <FEATURE> = TRUE|FALSE` wrapper. Snowflake
|
|
65
|
-
* exposes a growing set of account-level boolean parameters; this helper
|
|
66
|
-
* keeps the pattern uniform for workflow authors without embedding the
|
|
67
|
-
* full (ever-changing) feature catalogue in the package.
|
|
68
|
-
*/
|
|
69
|
-
async function enableAccountFeature(client, options) {
|
|
70
|
-
const enabled = options.enabled !== false;
|
|
71
|
-
await executeSql(client, {
|
|
72
|
-
statement: `ALTER ACCOUNT${options.ifExists ? " IF EXISTS" : ""}${options.name ? ` ${quoteIdentifier(options.name)}` : ""} SET ${options.feature.toUpperCase()} = ${enabled ? "TRUE" : "FALSE"}`,
|
|
73
|
-
warehouse: options.warehouse,
|
|
74
|
-
role: options.role
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
export { alterAccount, createOrganizationAccount, enableAccountFeature, listOrganizationAccounts };
|