@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.
Files changed (82) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -233
  3. package/package.json +39 -171
  4. package/dist/accounts/index.d.mts +0 -40
  5. package/dist/accounts/index.mjs +0 -51
  6. package/dist/bulk/index.d.mts +0 -71
  7. package/dist/bulk/index.mjs +0 -65
  8. package/dist/catalog/index.d.mts +0 -144
  9. package/dist/catalog/index.mjs +0 -158
  10. package/dist/client/index.d.mts +0 -44
  11. package/dist/client/index.mjs +0 -273
  12. package/dist/common-DfpCwJx5.mjs +0 -92
  13. package/dist/credential-sets/index.d.mts +0 -3
  14. package/dist/credential-sets/index.mjs +0 -4
  15. package/dist/databases/index.d.mts +0 -2
  16. package/dist/databases/index.mjs +0 -3
  17. package/dist/errors-60AsF7Su.mjs +0 -95
  18. package/dist/events/index.d.mts +0 -382
  19. package/dist/events/index.mjs +0 -291
  20. package/dist/file-formats/index.d.mts +0 -39
  21. package/dist/file-formats/index.mjs +0 -48
  22. package/dist/functions/index.d.mts +0 -53
  23. package/dist/functions/index.mjs +0 -56
  24. package/dist/grants/index.d.mts +0 -93
  25. package/dist/grants/index.mjs +0 -102
  26. package/dist/index.d.mts +0 -4
  27. package/dist/index.mjs +0 -6
  28. package/dist/operations/index.d.mts +0 -1
  29. package/dist/operations/index.mjs +0 -1
  30. package/dist/org-admin/index.d.mts +0 -80
  31. package/dist/org-admin/index.mjs +0 -79
  32. package/dist/pipes/index.d.mts +0 -119
  33. package/dist/pipes/index.mjs +0 -106
  34. package/dist/procedures/index.d.mts +0 -61
  35. package/dist/procedures/index.mjs +0 -79
  36. package/dist/results/index.d.mts +0 -16
  37. package/dist/results/index.mjs +0 -64
  38. package/dist/retry-B4-9MZIp.mjs +0 -164
  39. package/dist/retry-w7cTp1QL.d.mts +0 -10
  40. package/dist/roles/index.d.mts +0 -60
  41. package/dist/roles/index.mjs +0 -74
  42. package/dist/rows/index.d.mts +0 -106
  43. package/dist/rows/index.mjs +0 -223
  44. package/dist/schemas/index.d.mts +0 -2
  45. package/dist/schemas/index.mjs +0 -4
  46. package/dist/schemas-catalog/index.d.mts +0 -2
  47. package/dist/schemas-catalog/index.mjs +0 -3
  48. package/dist/shares/index.d.mts +0 -56
  49. package/dist/shares/index.mjs +0 -77
  50. package/dist/snowflake-s3-sns-webhook.credential-set-D6bLAWy5.d.mts +0 -50
  51. package/dist/snowflake-s3-sns-webhook.credential-set-DzR7oWNK.mjs +0 -44
  52. package/dist/snowflake.credential-set-BxT7Gf3A.d.mts +0 -114
  53. package/dist/snowflake.credential-set-DE3gXf-a.mjs +0 -106
  54. package/dist/sql/index.d.mts +0 -84
  55. package/dist/sql/index.mjs +0 -209
  56. package/dist/sql-options-2k5xQ-oS.d.mts +0 -32
  57. package/dist/sql-options-D6GEa21F.mjs +0 -79
  58. package/dist/sql-safety-BZpAPsq6.mjs +0 -56
  59. package/dist/stages/index.d.mts +0 -64
  60. package/dist/stages/index.mjs +0 -81
  61. package/dist/statements-BumhMhN4.mjs +0 -81
  62. package/dist/statements-DJL0qVNA.d.mts +0 -238
  63. package/dist/status-page/index.d.mts +0 -510
  64. package/dist/status-page/index.mjs +0 -261
  65. package/dist/streaming/index.d.mts +0 -70
  66. package/dist/streaming/index.mjs +0 -56
  67. package/dist/streams/index.d.mts +0 -71
  68. package/dist/streams/index.mjs +0 -78
  69. package/dist/tables/index.d.mts +0 -2
  70. package/dist/tables/index.mjs +0 -3
  71. package/dist/tasks/index.d.mts +0 -79
  72. package/dist/tasks/index.mjs +0 -104
  73. package/dist/triggers/index.d.mts +0 -381
  74. package/dist/triggers/index.mjs +0 -1100
  75. package/dist/users/index.d.mts +0 -61
  76. package/dist/users/index.mjs +0 -67
  77. package/dist/verification/index.d.mts +0 -201
  78. package/dist/verification/index.mjs +0 -512
  79. package/dist/views/index.d.mts +0 -2
  80. package/dist/views/index.mjs +0 -3
  81. package/dist/warehouses/index.d.mts +0 -68
  82. package/dist/warehouses/index.mjs +0 -101
@@ -1,61 +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, ShowOptions, showUsers } from "../catalog/index.mjs";
5
-
6
- //#region src/users/index.d.ts
7
- interface UserContext {
8
- readonly warehouse?: string;
9
- readonly role?: string;
10
- }
11
- interface CreateUserOptions extends UserContext {
12
- readonly name: string;
13
- readonly orReplace?: boolean;
14
- readonly ifNotExists?: boolean;
15
- /** `PASSWORD = '...'`, `LOGIN_NAME = '...'`, `DEFAULT_ROLE = 'ANALYST'`, etc. */
16
- readonly options?: OptionMap;
17
- readonly comment?: string;
18
- }
19
- declare function createUser(client: SnowflakeClient, options: CreateUserOptions): Promise<void>;
20
- interface AlterUserOptions extends UserContext {
21
- readonly name: string;
22
- readonly rename?: string;
23
- readonly set?: OptionMap;
24
- readonly unset?: readonly string[];
25
- readonly comment?: string;
26
- readonly ifExists?: boolean;
27
- }
28
- declare function alterUser(client: SnowflakeClient, options: AlterUserOptions): Promise<void>;
29
- interface DropUserOptions extends UserContext {
30
- readonly name: string;
31
- readonly ifExists?: boolean;
32
- }
33
- declare function dropUser(client: SnowflakeClient, options: DropUserOptions): Promise<void>;
34
- interface DescribeUserOptions extends UserContext {
35
- readonly name: string;
36
- }
37
- declare function describeUser(client: SnowflakeClient, options: DescribeUserOptions): Promise<readonly HydratedRow[]>;
38
- interface ResetUserPasswordOptions extends UserContext {
39
- readonly name: string;
40
- readonly ifExists?: boolean;
41
- /**
42
- * When provided, the new password is set explicitly via
43
- * `ALTER USER name SET PASSWORD = '...'`. When omitted, the command is
44
- * `ALTER USER name RESET PASSWORD`, which tells Snowflake to email the
45
- * user a one-time password link (per docs/sql-reference/sql/alter-user).
46
- */
47
- readonly password?: string;
48
- }
49
- declare function resetUserPassword(client: SnowflakeClient, options: ResetUserPasswordOptions): Promise<void>;
50
- interface UnlockUserOptions extends UserContext {
51
- readonly name: string;
52
- readonly ifExists?: boolean;
53
- }
54
- /**
55
- * `ALTER USER name SET MINS_TO_UNLOCK = 0` — immediately releases a lockout
56
- * caused by `MINS_TO_BYPASS_NETWORK_POLICY`, `LOCK_UNTIL`, or repeated
57
- * failed-password attempts. No-op if the user is not locked.
58
- */
59
- declare function unlockUser(client: SnowflakeClient, options: UnlockUserOptions): Promise<void>;
60
- //#endregion
61
- export { AlterUserOptions, type CatalogResult, CreateUserOptions, DescribeUserOptions, DropUserOptions, ResetUserPasswordOptions, type ShowOptions, UnlockUserOptions, UserContext, alterUser, createUser, describeUser, dropUser, resetUserPassword, showUsers, unlockUser };
@@ -1,67 +0,0 @@
1
- import { executeSql } from "../sql/index.mjs";
2
- import { a as quoteLiteral, i as quoteIdentifier } from "../sql-safety-BZpAPsq6.mjs";
3
- import { t as formatOptions } from "../sql-options-D6GEa21F.mjs";
4
- import { showUsers } from "../catalog/index.mjs";
5
-
6
- //#region src/users/index.ts
7
- async function createUser(client, options) {
8
- const prefix = `CREATE${options.orReplace ? " OR REPLACE" : ""} USER${options.ifNotExists ? " IF NOT EXISTS" : ""}`;
9
- const body = options.options && Object.keys(options.options).length > 0 ? ` ${formatOptions(options.options)}` : "";
10
- const comment = options.comment ? ` COMMENT = ${quoteLiteral(options.comment)}` : "";
11
- await executeSql(client, {
12
- statement: `${prefix} ${quoteIdentifier(options.name)}${body}${comment}`,
13
- warehouse: options.warehouse,
14
- role: options.role
15
- });
16
- }
17
- async function alterUser(client, options) {
18
- let tail;
19
- if (options.rename) tail = `RENAME TO ${quoteIdentifier(options.rename)}`;
20
- else if (options.set && Object.keys(options.set).length > 0) tail = `SET ${formatOptions(options.set)}`;
21
- else if (options.unset && options.unset.length > 0) tail = `UNSET ${options.unset.map((k) => k.toUpperCase()).join(", ")}`;
22
- else if (options.comment !== void 0) tail = `SET COMMENT = ${quoteLiteral(options.comment)}`;
23
- else throw new Error("alterUser requires one of: rename / set / unset / comment");
24
- await executeSql(client, {
25
- statement: `ALTER USER${options.ifExists ? " IF EXISTS" : ""} ${quoteIdentifier(options.name)} ${tail}`,
26
- warehouse: options.warehouse,
27
- role: options.role
28
- });
29
- }
30
- async function dropUser(client, options) {
31
- await executeSql(client, {
32
- statement: `DROP USER${options.ifExists ? " IF EXISTS" : ""} ${quoteIdentifier(options.name)}`,
33
- warehouse: options.warehouse,
34
- role: options.role
35
- });
36
- }
37
- async function describeUser(client, options) {
38
- return (await executeSql(client, {
39
- statement: `DESCRIBE USER ${quoteIdentifier(options.name)}`,
40
- warehouse: options.warehouse,
41
- role: options.role
42
- })).rows;
43
- }
44
- async function resetUserPassword(client, options) {
45
- const ifExists = options.ifExists ? " IF EXISTS" : "";
46
- const tail = options.password === void 0 ? "RESET PASSWORD" : `SET PASSWORD = ${quoteLiteral(options.password)}`;
47
- await executeSql(client, {
48
- statement: `ALTER USER${ifExists} ${quoteIdentifier(options.name)} ${tail}`,
49
- warehouse: options.warehouse,
50
- role: options.role
51
- });
52
- }
53
- /**
54
- * `ALTER USER name SET MINS_TO_UNLOCK = 0` — immediately releases a lockout
55
- * caused by `MINS_TO_BYPASS_NETWORK_POLICY`, `LOCK_UNTIL`, or repeated
56
- * failed-password attempts. No-op if the user is not locked.
57
- */
58
- async function unlockUser(client, options) {
59
- await executeSql(client, {
60
- statement: `ALTER USER${options.ifExists ? " IF EXISTS" : ""} ${quoteIdentifier(options.name)} SET MINS_TO_UNLOCK = 0`,
61
- warehouse: options.warehouse,
62
- role: options.role
63
- });
64
- }
65
-
66
- //#endregion
67
- export { alterUser, createUser, describeUser, dropUser, resetUserPassword, showUsers, unlockUser };
@@ -1,201 +0,0 @@
1
- import { AzureEventGridEvent, GcsPubSubPush, SnsNotification } from "../events/index.mjs";
2
- import { z } from "zod";
3
-
4
- //#region src/verification/index.d.ts
5
- /**
6
- * Thrown whenever a webhook verifier rejects a request. Includes a
7
- * compact `reason` code so callers can distinguish transport problems
8
- * (signature mismatch) from policy problems (wrong audience).
9
- */
10
- declare class SnowflakeWebhookVerificationError extends Error {
11
- readonly name = "SnowflakeWebhookVerificationError";
12
- readonly reason: string;
13
- readonly provider: 'aws-s3' | 'gcp-gcs' | 'azure-blob' | 'unknown';
14
- constructor(input: {
15
- message: string;
16
- reason: string;
17
- provider?: 'aws-s3' | 'gcp-gcs' | 'azure-blob';
18
- cause?: unknown;
19
- });
20
- }
21
- type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
22
- interface VerifySnsMessageOptions {
23
- /** Expected SNS topic ARN. Mismatch ⇒ verification error. */
24
- readonly expectedTopicArn?: string;
25
- /** Regex string (compiled with `u` flag). Defaults to AWS SNS hosts. */
26
- readonly allowedSigningCertHostPattern?: string;
27
- /** Test seam — override the default global fetch. */
28
- readonly fetchImpl?: FetchLike;
29
- /**
30
- * Test seam — bypass network + return the cert PEM directly.
31
- * Takes precedence over `fetchImpl`.
32
- */
33
- readonly resolveCert?: (signingCertUrl: string) => Promise<string> | string;
34
- }
35
- /**
36
- * Parse an SNS HTTP(S) notification body into a typed envelope. Throws
37
- * if the body is not valid JSON or doesn't match the SNS schema.
38
- */
39
- declare function parseSnsNotification(rawBody: string): SnsNotification;
40
- /**
41
- * Build the canonical string that SNS signs. The SNS spec fixes the
42
- * field order per message type — do not re-order keys.
43
- *
44
- * @see https://docs.aws.amazon.com/sns/latest/dg/sns-verify-signature-of-message.html
45
- */
46
- declare function canonicalSnsString(message: SnsNotification): string;
47
- /**
48
- * Verify an SNS notification. Performs:
49
- * 1. Topic-ARN pinning (if provided).
50
- * 2. SigningCertURL host allowlist (default: AWS SNS hosts only —
51
- * prevents SSRF against arbitrary URLs).
52
- * 3. Cert fetch + signature verification (SHA1 or SHA256 per
53
- * `SignatureVersion`).
54
- *
55
- * Returns the parsed notification on success.
56
- */
57
- declare function verifySnsMessage(rawBody: string, options?: VerifySnsMessageOptions): Promise<SnsNotification>;
58
- declare const googleJwksKeySchema: z.ZodObject<{
59
- kid: z.ZodString;
60
- kty: z.ZodString;
61
- alg: z.ZodOptional<z.ZodString>;
62
- use: z.ZodOptional<z.ZodString>;
63
- n: z.ZodString;
64
- e: z.ZodString;
65
- }, z.core.$catchall<z.ZodUnknown>>;
66
- declare const googleOidcClaimsSchema: z.ZodObject<{
67
- iss: z.ZodString;
68
- aud: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
69
- sub: z.ZodOptional<z.ZodString>;
70
- email: z.ZodOptional<z.ZodString>;
71
- email_verified: z.ZodOptional<z.ZodBoolean>;
72
- exp: z.ZodNumber;
73
- iat: z.ZodOptional<z.ZodNumber>;
74
- nbf: z.ZodOptional<z.ZodNumber>;
75
- }, z.core.$catchall<z.ZodUnknown>>;
76
- type GoogleOidcClaims = z.infer<typeof googleOidcClaimsSchema>;
77
- interface VerifyPubSubPushOptions {
78
- readonly expectedAudience: string;
79
- readonly expectedServiceAccount: string;
80
- readonly issuer?: string;
81
- readonly jwksUri?: string;
82
- readonly fetchImpl?: FetchLike;
83
- /** Override "now" for deterministic tests. */
84
- readonly now?: () => number;
85
- /** Test seam: supply JWKS directly, bypassing the HTTP fetch + cache. */
86
- readonly resolveJwks?: (jwksUri: string) => Promise<z.infer<typeof googleJwksKeySchema>[]> | z.infer<typeof googleJwksKeySchema>[];
87
- /** Disable the in-process cache. Useful for tests. */
88
- readonly disableCache?: boolean;
89
- }
90
- /**
91
- * Verify the OIDC JWT that GCP Pub/Sub push sends in `Authorization:
92
- * Bearer <token>`. Returns the decoded claims on success.
93
- */
94
- declare function verifyPubSubPushAuthorization(authorizationHeader: string | undefined, options: VerifyPubSubPushOptions): Promise<GoogleOidcClaims>;
95
- /** Parse a Pub/Sub push envelope. Does not verify anything. */
96
- declare function parsePubSubPush(rawBody: string): GcsPubSubPush;
97
- /**
98
- * Event Grid sends its validation request as a single-event array with
99
- * `eventType: 'Microsoft.EventGrid.SubscriptionValidationEvent'`. The
100
- * Keystroke webhook primitive does not support dynamic responses, so
101
- * operators must use **manual validation** (VSCode extension, portal
102
- * click-through, or a curl to `validationUrl`) rather than relying on
103
- * synchronous `validationResponse`.
104
- */
105
- declare const EVENT_GRID_VALIDATION_EVENT_TYPE = "Microsoft.EventGrid.SubscriptionValidationEvent";
106
- interface EventGridValidationEventData {
107
- readonly validationCode: string;
108
- readonly validationUrl?: string;
109
- }
110
- interface ParsedEventGridBatch {
111
- readonly events: readonly AzureEventGridEvent[];
112
- readonly validationEvents: readonly {
113
- readonly event: AzureEventGridEvent;
114
- readonly data: EventGridValidationEventData;
115
- }[];
116
- }
117
- interface VerifyEventGridRequestOptions {
118
- readonly sharedSecret?: string;
119
- readonly sharedSecretHeader?: string;
120
- readonly expectedTopic?: string;
121
- }
122
- /** Parse an Event Grid batch. Validates each envelope with Zod. */
123
- declare function parseEventGridBatch(rawBody: string): ParsedEventGridBatch;
124
- /**
125
- * Verify an Event Grid request. Event Grid's trust model is
126
- * primarily the delivery handshake + network ACLs, but operators can
127
- * wire a shared secret into a custom header. This verifier:
128
- *
129
- * - Checks the shared secret (if configured on both ends).
130
- * - Parses + schema-validates the event batch.
131
- * - Optionally enforces a topic-ARN pin.
132
- */
133
- declare function verifyEventGridRequest(input: {
134
- readonly rawBody: string;
135
- readonly headers: Readonly<Record<string, string | undefined>>;
136
- }, options?: VerifyEventGridRequestOptions): ParsedEventGridBatch;
137
- declare const s3EventRecordSchema: z.ZodObject<{
138
- eventTime: z.ZodOptional<z.ZodString>;
139
- eventName: z.ZodOptional<z.ZodString>;
140
- awsRegion: z.ZodOptional<z.ZodString>;
141
- requestParameters: z.ZodOptional<z.ZodObject<{
142
- sourceIPAddress: z.ZodOptional<z.ZodString>;
143
- }, z.core.$catchall<z.ZodUnknown>>>;
144
- s3: z.ZodOptional<z.ZodObject<{
145
- bucket: z.ZodOptional<z.ZodObject<{
146
- name: z.ZodString;
147
- }, z.core.$catchall<z.ZodUnknown>>>;
148
- object: z.ZodOptional<z.ZodObject<{
149
- key: z.ZodOptional<z.ZodString>;
150
- size: z.ZodOptional<z.ZodNumber>;
151
- eTag: z.ZodOptional<z.ZodString>;
152
- sequencer: z.ZodOptional<z.ZodString>;
153
- }, z.core.$catchall<z.ZodUnknown>>>;
154
- }, z.core.$catchall<z.ZodUnknown>>>;
155
- }, z.core.$catchall<z.ZodUnknown>>;
156
- type S3EventRecord = z.infer<typeof s3EventRecordSchema>;
157
- /**
158
- * Extract S3 object events out of the inner {@link SnsNotification}
159
- * message body. SNS forwards the verbatim S3 notification JSON in
160
- * `Message`.
161
- */
162
- declare function extractS3Records(snsMessage: SnsNotification): readonly S3EventRecord[];
163
- declare const gcsObjectPayloadSchema: z.ZodObject<{
164
- bucket: z.ZodOptional<z.ZodString>;
165
- name: z.ZodOptional<z.ZodString>;
166
- size: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
167
- etag: z.ZodOptional<z.ZodString>;
168
- generation: z.ZodOptional<z.ZodString>;
169
- timeCreated: z.ZodOptional<z.ZodString>;
170
- updated: z.ZodOptional<z.ZodString>;
171
- }, z.core.$catchall<z.ZodUnknown>>;
172
- type GcsObjectPayload = z.infer<typeof gcsObjectPayloadSchema>;
173
- /**
174
- * Decode + validate the inner GCS object payload from a Pub/Sub push.
175
- * Returns `undefined` if the `message.data` field is missing or the
176
- * decoded body does not shape-match a GCS Object Change notification.
177
- */
178
- declare function extractGcsObjectPayload(push: GcsPubSubPush): GcsObjectPayload | undefined;
179
- declare const azureBlobDataSchema: z.ZodObject<{
180
- api: z.ZodOptional<z.ZodString>;
181
- blobType: z.ZodOptional<z.ZodString>;
182
- contentLength: z.ZodOptional<z.ZodNumber>;
183
- contentType: z.ZodOptional<z.ZodString>;
184
- eTag: z.ZodOptional<z.ZodString>;
185
- url: z.ZodOptional<z.ZodString>;
186
- sequencer: z.ZodOptional<z.ZodString>;
187
- storageDiagnostics: z.ZodOptional<z.ZodUnknown>;
188
- }, z.core.$catchall<z.ZodUnknown>>;
189
- type AzureBlobEventData = z.infer<typeof azureBlobDataSchema>;
190
- /**
191
- * Extract `bucket` + `key` from the `url` or `subject` fields of an
192
- * Event Grid blob event. Event Grid populates `subject` as
193
- * `/blobServices/default/containers/<container>/blobs/<key>` so we can
194
- * parse either.
195
- */
196
- declare function parseAzureBlobLocation(event: AzureEventGridEvent): {
197
- readonly bucket: string;
198
- readonly key: string;
199
- };
200
- //#endregion
201
- export { AzureBlobEventData, EVENT_GRID_VALIDATION_EVENT_TYPE, EventGridValidationEventData, GcsObjectPayload, GoogleOidcClaims, ParsedEventGridBatch, S3EventRecord, SnowflakeWebhookVerificationError, VerifyEventGridRequestOptions, VerifyPubSubPushOptions, VerifySnsMessageOptions, canonicalSnsString, extractGcsObjectPayload, extractS3Records, parseAzureBlobLocation, parseEventGridBatch, parsePubSubPush, parseSnsNotification, verifyEventGridRequest, verifyPubSubPushAuthorization, verifySnsMessage };