@activepieces/piece-snowflake 0.1.4 → 0.2.0

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 (79) hide show
  1. package/package.json +4 -4
  2. package/src/i18n/de.json +37 -0
  3. package/src/i18n/es.json +37 -0
  4. package/src/i18n/fr.json +37 -0
  5. package/src/i18n/ja.json +37 -0
  6. package/src/i18n/nl.json +37 -0
  7. package/src/i18n/pt.json +37 -0
  8. package/src/i18n/ru.json +36 -0
  9. package/src/i18n/translation.json +37 -0
  10. package/src/i18n/vi.json +36 -0
  11. package/src/i18n/zh.json +37 -0
  12. package/src/index.d.ts +4 -2
  13. package/src/index.d.ts.map +1 -0
  14. package/src/index.js +33 -2
  15. package/src/index.js.map +1 -1
  16. package/src/lib/actions/create-dynamic-table.d.ts +36 -0
  17. package/src/lib/actions/create-dynamic-table.d.ts.map +1 -0
  18. package/src/lib/actions/create-dynamic-table.js +81 -0
  19. package/src/lib/actions/create-dynamic-table.js.map +1 -0
  20. package/src/lib/actions/delete-row.d.ts +43 -0
  21. package/src/lib/actions/delete-row.d.ts.map +1 -0
  22. package/src/lib/actions/delete-row.js +45 -0
  23. package/src/lib/actions/delete-row.js.map +1 -0
  24. package/src/lib/actions/execute-stored-procedure.d.ts +43 -0
  25. package/src/lib/actions/execute-stored-procedure.d.ts.map +1 -0
  26. package/src/lib/actions/execute-stored-procedure.js +92 -0
  27. package/src/lib/actions/execute-stored-procedure.js.map +1 -0
  28. package/src/lib/actions/get-row-by-id.d.ts +53 -0
  29. package/src/lib/actions/get-row-by-id.d.ts.map +1 -0
  30. package/src/lib/actions/get-row-by-id.js +67 -0
  31. package/src/lib/actions/get-row-by-id.js.map +1 -0
  32. package/src/lib/actions/get-table-schema.d.ts +42 -0
  33. package/src/lib/actions/get-table-schema.d.ts.map +1 -0
  34. package/src/lib/actions/get-table-schema.js +49 -0
  35. package/src/lib/actions/get-table-schema.js.map +1 -0
  36. package/src/lib/actions/insert-multiple-rows.d.ts +43 -0
  37. package/src/lib/actions/insert-multiple-rows.d.ts.map +1 -0
  38. package/src/lib/actions/insert-multiple-rows.js +81 -0
  39. package/src/lib/actions/insert-multiple-rows.js.map +1 -0
  40. package/src/lib/actions/insert-row.d.ts +16 -10
  41. package/src/lib/actions/insert-row.d.ts.map +1 -0
  42. package/src/lib/actions/insert-row.js +1 -1
  43. package/src/lib/actions/insert-row.js.map +1 -1
  44. package/src/lib/actions/list-tables.d.ts +32 -0
  45. package/src/lib/actions/list-tables.d.ts.map +1 -0
  46. package/src/lib/actions/list-tables.js +47 -0
  47. package/src/lib/actions/list-tables.js.map +1 -0
  48. package/src/lib/actions/load-data-from-stage.d.ts +48 -0
  49. package/src/lib/actions/load-data-from-stage.d.ts.map +1 -0
  50. package/src/lib/actions/load-data-from-stage.js +117 -0
  51. package/src/lib/actions/load-data-from-stage.js.map +1 -0
  52. package/src/lib/actions/run-multiple-queries.d.ts +4 -2
  53. package/src/lib/actions/run-multiple-queries.d.ts.map +1 -0
  54. package/src/lib/actions/run-multiple-queries.js +1 -1
  55. package/src/lib/actions/run-multiple-queries.js.map +1 -1
  56. package/src/lib/actions/run-query.d.ts +4 -2
  57. package/src/lib/actions/run-query.d.ts.map +1 -0
  58. package/src/lib/actions/run-query.js +1 -1
  59. package/src/lib/actions/run-query.js.map +1 -1
  60. package/src/lib/actions/search-rows.d.ts +45 -0
  61. package/src/lib/actions/search-rows.d.ts.map +1 -0
  62. package/src/lib/actions/search-rows.js +58 -0
  63. package/src/lib/actions/search-rows.js.map +1 -0
  64. package/src/lib/actions/update-row.d.ts +53 -0
  65. package/src/lib/actions/update-row.d.ts.map +1 -0
  66. package/src/lib/actions/update-row.js +54 -0
  67. package/src/lib/actions/update-row.js.map +1 -0
  68. package/src/lib/actions/upsert-row.d.ts +62 -0
  69. package/src/lib/actions/upsert-row.d.ts.map +1 -0
  70. package/src/lib/actions/upsert-row.js +93 -0
  71. package/src/lib/actions/upsert-row.js.map +1 -0
  72. package/src/lib/auth.d.ts +14 -1
  73. package/src/lib/auth.d.ts.map +1 -0
  74. package/src/lib/auth.js +203 -17
  75. package/src/lib/auth.js.map +1 -1
  76. package/src/lib/common/index.d.ts +49 -11
  77. package/src/lib/common/index.d.ts.map +1 -0
  78. package/src/lib/common/index.js +88 -36
  79. package/src/lib/common/index.js.map +1 -1
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchRowsAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../auth");
7
+ const common_1 = require("../common");
8
+ exports.searchRowsAction = (0, pieces_framework_1.createAction)({
9
+ name: 'search_rows',
10
+ displayName: 'Search Rows',
11
+ description: 'Search for rows in a Snowflake table using an optional WHERE condition, ordering, and row limit.',
12
+ auth: auth_1.snowflakeAuth,
13
+ props: {
14
+ database: common_1.snowflakeCommonProps.database,
15
+ schema: common_1.snowflakeCommonProps.schema,
16
+ table: common_1.snowflakeCommonProps.table,
17
+ where_clause: pieces_framework_1.Property.ShortText({
18
+ displayName: 'WHERE Condition',
19
+ description: "Optional SQL condition to filter results (e.g. `status = 'active' AND age > 18`). " +
20
+ 'Leave empty to return all rows (subject to the row limit). ' +
21
+ '**Security note:** this value is embedded directly in SQL. Only use static values or data from trusted, internal steps — never pass unvalidated end-user input here.',
22
+ required: false,
23
+ }),
24
+ order_by: pieces_framework_1.Property.ShortText({
25
+ displayName: 'ORDER BY',
26
+ description: 'Optional column(s) to sort by (e.g. `created_at DESC` or `name ASC, age DESC`). ' +
27
+ '**Security note:** this value is embedded directly in SQL. Only use static values or data from trusted, internal steps — never pass unvalidated end-user input here.',
28
+ required: false,
29
+ }),
30
+ limit: pieces_framework_1.Property.Number({
31
+ displayName: 'Row Limit',
32
+ description: 'Maximum number of rows to return. Defaults to 100.',
33
+ required: false,
34
+ defaultValue: 100,
35
+ }),
36
+ },
37
+ run(context) {
38
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
39
+ const { table, where_clause, order_by, limit } = context.propsValue;
40
+ let sql = `SELECT * FROM ${table}`;
41
+ if (where_clause)
42
+ sql += ` WHERE ${where_clause}`;
43
+ if (order_by)
44
+ sql += ` ORDER BY ${order_by}`;
45
+ sql += ` LIMIT ${Math.trunc(limit !== null && limit !== void 0 ? limit : 100)}`;
46
+ const connection = (0, common_1.configureConnection)(context.auth);
47
+ yield (0, common_1.connect)(connection);
48
+ try {
49
+ const result = yield (0, common_1.execute)(connection, sql, []);
50
+ return result !== null && result !== void 0 ? result : [];
51
+ }
52
+ finally {
53
+ yield (0, common_1.destroy)(connection);
54
+ }
55
+ });
56
+ },
57
+ });
58
+ //# sourceMappingURL=search-rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-rows.js","sourceRoot":"","sources":["../../../../src/lib/actions/search-rows.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAAwC;AACxC,sCAOmB;AAEN,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EACT,kGAAkG;IACpG,IAAI,EAAE,oBAAa;IACnB,KAAK,EAAE;QACL,QAAQ,EAAE,6BAAoB,CAAC,QAAQ;QACvC,MAAM,EAAE,6BAAoB,CAAC,MAAM;QACnC,KAAK,EAAE,6BAAoB,CAAC,KAAK;QACjC,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EACT,oFAAoF;gBACpF,6DAA6D;gBAC7D,sKAAsK;YACxK,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EACT,kFAAkF;gBAClF,sKAAsK;YACxK,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,oDAAoD;YACjE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,GAAG;SAClB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEpE,IAAI,GAAG,GAAG,iBAAiB,KAAK,EAAE,CAAC;YACnC,IAAI,YAAY;gBAAE,GAAG,IAAI,UAAU,YAAY,EAAE,CAAC;YAClD,IAAI,QAAQ;gBAAE,GAAG,IAAI,aAAa,QAAQ,EAAE,CAAC;YAC7C,GAAG,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,GAAG,CAAC,EAAE,CAAC;YAE5C,MAAM,UAAU,GAAG,IAAA,4BAAmB,EAAC,OAAO,CAAC,IAA0B,CAAC,CAAC;YAC3E,MAAM,IAAA,gBAAO,EAAC,UAAU,CAAC,CAAC;YAC1B,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,gBAAO,EAAC,UAAU,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;gBAClD,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,gBAAO,EAAC,UAAU,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ export declare const updateRowAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | 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<false>;
5
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
7
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
+ }>)[], {
11
+ database: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
12
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
13
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
14
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
15
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
16
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
17
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
18
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
19
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
20
+ }>)[]>;
21
+ schema: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
22
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
23
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
24
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
25
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
26
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
27
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
28
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
29
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
30
+ }>)[]>;
31
+ table: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
32
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
33
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
34
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
35
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
36
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
37
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
38
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
39
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
40
+ }>)[]>;
41
+ table_update_values: import("@activepieces/pieces-framework").DynamicProperties<true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
42
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
43
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
44
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
45
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
46
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
47
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
48
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
49
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
50
+ }>)[]>;
51
+ where_clause: import("@activepieces/pieces-framework").ShortTextProperty<false>;
52
+ }>;
53
+ //# sourceMappingURL=update-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-row.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/update-row.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsD1B,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateRowAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../auth");
7
+ const common_1 = require("../common");
8
+ exports.updateRowAction = (0, pieces_framework_1.createAction)({
9
+ name: 'update_row',
10
+ displayName: 'Update Row',
11
+ description: 'Update one or more rows in a Snowflake table that match a WHERE condition.',
12
+ auth: auth_1.snowflakeAuth,
13
+ props: {
14
+ database: common_1.snowflakeCommonProps.database,
15
+ schema: common_1.snowflakeCommonProps.schema,
16
+ table: common_1.snowflakeCommonProps.table,
17
+ table_update_values: common_1.snowflakeCommonProps.table_update_values,
18
+ where_clause: pieces_framework_1.Property.ShortText({
19
+ displayName: 'WHERE Condition',
20
+ description: "A SQL condition to filter which rows to update (e.g. `id = 42` or `status = 'active'`). " +
21
+ 'Leave empty to update ALL rows in the table (use with caution). ' +
22
+ '**Security note:** this value is embedded directly in SQL. Only use static values or data from trusted, internal steps — never pass unvalidated end-user input here.',
23
+ required: false,
24
+ }),
25
+ },
26
+ run(context) {
27
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
28
+ var _a, _b;
29
+ const { table, table_update_values: columnValues, where_clause, } = context.propsValue;
30
+ const setEntries = Object.entries(columnValues).filter(([, v]) => v !== null && v !== undefined && v !== '');
31
+ if (setEntries.length === 0) {
32
+ throw new Error('At least one column value must be provided to update.');
33
+ }
34
+ const setClauses = setEntries.map(([col]) => `${col} = ?`).join(', ');
35
+ const binds = setEntries.map(([, v]) => v);
36
+ const sql = where_clause
37
+ ? `UPDATE ${table} SET ${setClauses} WHERE ${where_clause}`
38
+ : `UPDATE ${table} SET ${setClauses}`;
39
+ const connection = (0, common_1.configureConnection)(context.auth);
40
+ yield (0, common_1.connect)(connection);
41
+ try {
42
+ const result = yield (0, common_1.execute)(connection, sql, binds);
43
+ return {
44
+ success: true,
45
+ rows_updated: (_b = (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a['number of rows updated']) !== null && _b !== void 0 ? _b : null,
46
+ };
47
+ }
48
+ finally {
49
+ yield (0, common_1.destroy)(connection);
50
+ }
51
+ });
52
+ },
53
+ });
54
+ //# sourceMappingURL=update-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-row.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-row.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAAwC;AACxC,sCAOmB;AAEN,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EACT,4EAA4E;IAC9E,IAAI,EAAE,oBAAa;IACnB,KAAK,EAAE;QACL,QAAQ,EAAE,6BAAoB,CAAC,QAAQ;QACvC,MAAM,EAAE,6BAAoB,CAAC,MAAM;QACnC,KAAK,EAAE,6BAAoB,CAAC,KAAK;QACjC,mBAAmB,EAAE,6BAAoB,CAAC,mBAAmB;QAC7D,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EACT,0FAA0F;gBAC1F,kEAAkE;gBAClE,sKAAsK;YACxK,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,EACJ,KAAK,EACL,mBAAmB,EAAE,YAAY,EACjC,YAAY,GACb,GAAG,OAAO,CAAC,UAAU,CAAC;YAEvB,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CACpD,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,CACrD,CAAC;YAEF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtE,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAa,CAAC;YAEvD,MAAM,GAAG,GAAG,YAAY;gBACtB,CAAC,CAAC,UAAU,KAAK,QAAQ,UAAU,UAAU,YAAY,EAAE;gBAC3D,CAAC,CAAC,UAAU,KAAK,QAAQ,UAAU,EAAE,CAAC;YAExC,MAAM,UAAU,GAAG,IAAA,4BAAmB,EAAC,OAAO,CAAC,IAA0B,CAAC,CAAC;YAC3E,MAAM,IAAA,gBAAO,EAAC,UAAU,CAAC,CAAC;YAC1B,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,gBAAO,EAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,YAAY,EAAE,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,CAAC,0CAAG,wBAAwB,CAAC,mCAAI,IAAI;iBAC9D,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,gBAAO,EAAC,UAAU,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ export declare const upsertRowAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | 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<false>;
5
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
7
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
+ }>)[], {
11
+ database: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
12
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
13
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
14
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
15
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
16
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
17
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
18
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
19
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
20
+ }>)[]>;
21
+ schema: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
22
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
23
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
24
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
25
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
26
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
27
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
28
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
29
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
30
+ }>)[]>;
31
+ table: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
32
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
33
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
34
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
35
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
36
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
37
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
38
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
39
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
40
+ }>)[]>;
41
+ match_column: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
42
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
43
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
44
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
45
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
46
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
47
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
48
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
49
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
50
+ }>)[]>;
51
+ table_column_values: import("@activepieces/pieces-framework").DynamicProperties<true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
52
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
53
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
54
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
55
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
56
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
57
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
58
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
59
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
60
+ }>)[]>;
61
+ }>;
62
+ //# sourceMappingURL=upsert-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upsert-row.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/upsert-row.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmG1B,CAAC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.upsertRowAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../auth");
7
+ const common_1 = require("../common");
8
+ exports.upsertRowAction = (0, pieces_framework_1.createAction)({
9
+ name: 'upsert_row',
10
+ displayName: 'Upsert Row',
11
+ description: 'Insert a new row or update an existing one if a row with the same match column value already exists (MERGE INTO).',
12
+ auth: auth_1.snowflakeAuth,
13
+ props: {
14
+ database: common_1.snowflakeCommonProps.database,
15
+ schema: common_1.snowflakeCommonProps.schema,
16
+ table: common_1.snowflakeCommonProps.table,
17
+ match_column: pieces_framework_1.Property.Dropdown({
18
+ auth: auth_1.snowflakeAuth,
19
+ displayName: 'Match Column',
20
+ description: 'The column used to identify whether a row already exists (e.g. the primary key or a unique identifier column).',
21
+ refreshers: ['table'],
22
+ required: true,
23
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, table }) {
24
+ if (!auth) {
25
+ return {
26
+ disabled: true,
27
+ options: [],
28
+ placeholder: 'Please connect your account first',
29
+ };
30
+ }
31
+ if (!table) {
32
+ return {
33
+ disabled: true,
34
+ options: [],
35
+ placeholder: 'Please select a table first',
36
+ };
37
+ }
38
+ return (0, common_1.getTableColumnOptions)(auth, table);
39
+ }),
40
+ }),
41
+ table_column_values: common_1.snowflakeCommonProps.table_column_values,
42
+ },
43
+ run(context) {
44
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
45
+ var _a, _b, _c, _d;
46
+ const { table, match_column, table_column_values: columnValues, } = context.propsValue;
47
+ const columns = Object.keys(columnValues);
48
+ if (columns.length === 0) {
49
+ throw new Error('At least one column value must be provided.');
50
+ }
51
+ if (!columns.includes(match_column)) {
52
+ throw new Error(`Match column "${match_column}" must be included in the column values. ` +
53
+ `Please add a value for "${match_column}" in the columns to upsert.`);
54
+ }
55
+ // Build MERGE INTO statement
56
+ // source: SELECT ? AS col1, ? AS col2, ...
57
+ const sourceSelects = columns.map((col) => `? AS ${col}`).join(', ');
58
+ const updateEntries = columns.filter((col) => col !== match_column);
59
+ if (updateEntries.length === 0) {
60
+ throw new Error('At least one column other than the match column must be provided to update.');
61
+ }
62
+ const updateSets = updateEntries
63
+ .map((col) => `target.${col} = source.${col}`)
64
+ .join(', ');
65
+ const insertCols = columns.join(', ');
66
+ const insertVals = columns.map((col) => `source.${col}`).join(', ');
67
+ const sql = `
68
+ MERGE INTO ${table} AS target
69
+ USING (SELECT ${sourceSelects}) AS source
70
+ ON target.${match_column} = source.${match_column}
71
+ WHEN MATCHED THEN
72
+ UPDATE SET ${updateSets}
73
+ WHEN NOT MATCHED THEN
74
+ INSERT (${insertCols}) VALUES (${insertVals})
75
+ `.trim();
76
+ const binds = Object.values(columnValues);
77
+ const connection = (0, common_1.configureConnection)(context.auth);
78
+ yield (0, common_1.connect)(connection);
79
+ try {
80
+ const result = yield (0, common_1.execute)(connection, sql, binds);
81
+ return {
82
+ success: true,
83
+ rows_inserted: (_b = (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a['number of rows inserted']) !== null && _b !== void 0 ? _b : null,
84
+ rows_updated: (_d = (_c = result === null || result === void 0 ? void 0 : result[0]) === null || _c === void 0 ? void 0 : _c['number of rows updated']) !== null && _d !== void 0 ? _d : null,
85
+ };
86
+ }
87
+ finally {
88
+ yield (0, common_1.destroy)(connection);
89
+ }
90
+ });
91
+ },
92
+ });
93
+ //# sourceMappingURL=upsert-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upsert-row.js","sourceRoot":"","sources":["../../../../src/lib/actions/upsert-row.ts"],"names":[],"mappings":"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"}
package/src/lib/auth.d.ts CHANGED
@@ -1,9 +1,22 @@
1
- export declare const snowflakeAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
1
+ export declare const snowflakeOAuth2Auth: import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>;
2
+ export declare const snowflakeCustomAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
3
  account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
4
  username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
5
  password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
5
6
  privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
7
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
6
8
  database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
9
  role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
10
  warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
11
  }>;
12
+ export declare const snowflakeAuth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
13
+ account: import("@activepieces/pieces-framework").ShortTextProperty<true>;
14
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
15
+ password: import("@activepieces/pieces-framework").SecretTextProperty<false>;
16
+ privateKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
17
+ privateKeyPassphrase: import("@activepieces/pieces-framework").SecretTextProperty<false>;
18
+ database: import("@activepieces/pieces-framework").ShortTextProperty<false>;
19
+ role: import("@activepieces/pieces-framework").ShortTextProperty<false>;
20
+ warehouse: import("@activepieces/pieces-framework").ShortTextProperty<false>;
21
+ }>)[];
22
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,mBAAmB,+GAkG9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;EA4H9B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;KAA6C,CAAC"}