@activepieces/piece-snowflake 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/package.json +19 -0
- package/src/index.d.ts +16 -0
- package/src/index.js +52 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/run-query.d.ts +13 -0
- package/src/lib/actions/run-query.js +78 -0
- package/src/lib/actions/run-query.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-snowflake",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"axios": "^1.6.3",
|
|
7
|
+
"dayjs": "1.11.9",
|
|
8
|
+
"is-base64": "1.1.0",
|
|
9
|
+
"lodash": "4.17.21",
|
|
10
|
+
"nanoid": "3.3.6",
|
|
11
|
+
"semver": "7.6.0",
|
|
12
|
+
"snowflake-sdk": "1.9.3",
|
|
13
|
+
"@activepieces/pieces-framework": "0.7.16",
|
|
14
|
+
"@activepieces/shared": "0.10.73",
|
|
15
|
+
"tslib": "2.6.1"
|
|
16
|
+
},
|
|
17
|
+
"main": "./src/index.js",
|
|
18
|
+
"type": "commonjs"
|
|
19
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const snowflakeAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const snowflake: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
11
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
12
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
13
|
+
database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
15
|
+
warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snowflake = exports.snowflakeAuth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const run_query_1 = require("./lib/actions/run-query");
|
|
6
|
+
const shared_1 = require("@activepieces/shared");
|
|
7
|
+
exports.snowflakeAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
8
|
+
props: {
|
|
9
|
+
account: pieces_framework_1.Property.ShortText({
|
|
10
|
+
displayName: 'Account',
|
|
11
|
+
required: true,
|
|
12
|
+
description: 'A string indicating the Snowflake account identifier.',
|
|
13
|
+
}),
|
|
14
|
+
username: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Username',
|
|
16
|
+
required: true,
|
|
17
|
+
description: 'The login name for your Snowflake user.',
|
|
18
|
+
}),
|
|
19
|
+
password: pieces_framework_1.PieceAuth.SecretText({
|
|
20
|
+
displayName: 'Password',
|
|
21
|
+
description: 'Password for the user.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
database: pieces_framework_1.Property.ShortText({
|
|
25
|
+
displayName: 'Database',
|
|
26
|
+
description: 'The default database to use for the session after connecting.',
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
role: pieces_framework_1.Property.ShortText({
|
|
30
|
+
displayName: 'Role',
|
|
31
|
+
description: 'The default security role to use for the session after connecting.',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
warehouse: pieces_framework_1.Property.ShortText({
|
|
35
|
+
displayName: 'Warehouse',
|
|
36
|
+
description: 'The default virtual warehouse to use for the session after connecting. Used for performing queries, loading data, etc.',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
required: true,
|
|
41
|
+
});
|
|
42
|
+
exports.snowflake = (0, pieces_framework_1.createPiece)({
|
|
43
|
+
displayName: 'Snowflake',
|
|
44
|
+
auth: exports.snowflakeAuth,
|
|
45
|
+
minimumSupportedRelease: '0.9.0',
|
|
46
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/snowflake.png',
|
|
47
|
+
categories: [shared_1.PieceCategory.DEVELOPER_TOOLS],
|
|
48
|
+
authors: ['AdamSelene'],
|
|
49
|
+
actions: [run_query_1.runQuery],
|
|
50
|
+
triggers: [],
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/snowflake/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAIwC;AACxC,uDAAmD;AACnD,iDAAqD;AAExC,QAAA,aAAa,GAAG,4BAAS,CAAC,UAAU,CAAC;IAChD,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,uDAAuD;SACrE,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,yCAAyC;SACvD,CAAC;QACF,QAAQ,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC7B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,wBAAwB;YACrC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EACT,+DAA+D;YACjE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EACT,oEAAoE;YACtE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EACT,wHAAwH;YAC1H,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AACU,QAAA,SAAS,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,qBAAa;IACnB,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,mDAAmD;IAC5D,UAAU,EAAE,CAAC,sBAAa,CAAC,eAAe,CAAC;IAC3C,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,OAAO,EAAE,CAAC,oBAAQ,CAAC;IACnB,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const runQuery: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>, {
|
|
9
|
+
sqlText: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
binds: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
11
|
+
timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
12
|
+
application: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const snowflake_sdk_1 = tslib_1.__importDefault(require("snowflake-sdk"));
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const DEFAULT_APPLICATION_NAME = 'ActivePieces';
|
|
9
|
+
const DEFAULT_QUERY_TIMEOUT = 30000;
|
|
10
|
+
exports.runQuery = (0, pieces_framework_1.createAction)({
|
|
11
|
+
name: 'runQuery',
|
|
12
|
+
displayName: 'Run Query',
|
|
13
|
+
description: 'Run Query',
|
|
14
|
+
auth: index_1.snowflakeAuth,
|
|
15
|
+
props: {
|
|
16
|
+
sqlText: pieces_framework_1.Property.ShortText({
|
|
17
|
+
displayName: 'SQL query',
|
|
18
|
+
description: 'Use :1, :2… or ? placeholders to use binding parameters.',
|
|
19
|
+
required: true,
|
|
20
|
+
}),
|
|
21
|
+
binds: pieces_framework_1.Property.Array({
|
|
22
|
+
displayName: 'Parameters',
|
|
23
|
+
description: 'Binding parameters for the SQL query (to prevent SQL injection attacks)',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
timeout: pieces_framework_1.Property.Number({
|
|
27
|
+
displayName: 'Query timeout (ms)',
|
|
28
|
+
description: 'An integer indicating the maximum number of milliseconds to wait for a query to complete before timing out.',
|
|
29
|
+
required: false,
|
|
30
|
+
defaultValue: DEFAULT_QUERY_TIMEOUT,
|
|
31
|
+
}),
|
|
32
|
+
application: pieces_framework_1.Property.ShortText({
|
|
33
|
+
displayName: 'Application name',
|
|
34
|
+
description: 'A string indicating the name of the client application connecting to the server.',
|
|
35
|
+
required: false,
|
|
36
|
+
defaultValue: DEFAULT_APPLICATION_NAME,
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
run(context) {
|
|
40
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const { username, password, role, database, warehouse, account } = context.auth;
|
|
42
|
+
const connection = snowflake_sdk_1.default.createConnection({
|
|
43
|
+
application: context.propsValue.application,
|
|
44
|
+
timeout: context.propsValue.timeout,
|
|
45
|
+
username,
|
|
46
|
+
password,
|
|
47
|
+
role,
|
|
48
|
+
database,
|
|
49
|
+
warehouse,
|
|
50
|
+
account,
|
|
51
|
+
});
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
connection.connect(function (err, conn) {
|
|
54
|
+
if (err) {
|
|
55
|
+
reject(err);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const { sqlText, binds } = context.propsValue;
|
|
59
|
+
connection.execute({
|
|
60
|
+
sqlText,
|
|
61
|
+
binds: binds,
|
|
62
|
+
complete: (err, stmt, rows) => {
|
|
63
|
+
if (err) {
|
|
64
|
+
reject(err);
|
|
65
|
+
}
|
|
66
|
+
connection.destroy((err, conn) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
reject(err);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
resolve(rows);
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=run-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-query.js","sourceRoot":"","sources":["../../../../../../../../packages/p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