Skip to content

Commit 24f1cdd

Browse files
committed
App file changes and other actions.
1 parent 5859582 commit 24f1cdd

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

components/azure_sql/actions/execute-query/execute-query.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Execute Query",
66
description: "Executes a SQL query and returns the results. [See the documentation](https://learn.microsoft.com/en-us/sql/t-sql/queries/select-transact-sql?view=azuresqldb-current)",
77
type: "action",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
props: {
1010
app,
1111
query: {
@@ -20,18 +20,26 @@ export default {
2020
description: "The inputs to the query. These will be available as @input_parameter in the query. For example, if you provide an input named 'id', you can use @id in the query.",
2121
optional: true,
2222
},
23+
requestTimeout: {
24+
propDefinition: [
25+
app,
26+
"requestTimeout",
27+
],
28+
},
2329
},
2430
run({ $ }) {
2531
const {
2632
app,
2733
inputs,
2834
query,
35+
requestTimeout,
2936
} = this;
3037

3138
return app.executeQuery({
3239
$,
3340
query,
3441
inputs,
42+
requestTimeout,
3543
summary: () => "Successfully executed query.",
3644
});
3745
},

components/azure_sql/azure_sql.app.mjs

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export default {
2828
return recordset.map(({ COLUMN_NAME: columnName }) => columnName);
2929
},
3030
},
31+
requestTimeout: {
32+
type: "integer",
33+
label: "Request Timeout",
34+
description: "The timeout for query execution in seconds. Default is 60 seconds if not specified.",
35+
optional: true,
36+
default: 60,
37+
},
3138
},
3239
methods: {
3340
...sqlProxy.methods,
@@ -37,7 +44,7 @@ export default {
3744
},
3845
getConfig() {
3946
const {
40-
host, username, password, port, database,
47+
host, username, password, port, database, requestTimeout,
4148
} = this.$auth;
4249
return {
4350
user: username,
@@ -51,21 +58,13 @@ export default {
5158
options: {
5259
encrypt: true,
5360
port: Number(port),
54-
requestTimeout: 60000,
61+
requestTimeout: (requestTimeout || 60) * 1000, // Convert to milliseconds
5562
},
5663
};
5764
},
5865
getConnection() {
5966
return sql.connect(this.getConfig());
6067
},
61-
/**
62-
* A helper method to get the schema of the database. Used by other features
63-
* (like the `sql` prop) to enrich the code editor and provide the user with
64-
* auto-complete and fields suggestion.
65-
*
66-
* @returns {DbInfo} The schema of the database, which is a
67-
* JSON-serializable object.
68-
*/
6968
async getSchema() {
7069
const sql = `
7170
SELECT t.TABLE_SCHEMA AS tableSchema,
@@ -98,15 +97,6 @@ export default {
9897
return acc;
9998
}, {});
10099
},
101-
/**
102-
* Adapts the arguments to `executeQuery` so that they can be consumed by
103-
* the SQL proxy (when applicable). Note that this method is not intended to
104-
* be used by the component directly.
105-
* @param {object} preparedStatement The prepared statement to be sent to the DB.
106-
* @param {string} preparedStatement.sql The prepared SQL query to be executed.
107-
* @param {string[]} preparedStatement.values The values to replace in the SQL query.
108-
* @returns {object} - The adapted query and parameters.
109-
*/
110100
proxyAdapter(preparedStatement = {}) {
111101
const { query } = preparedStatement;
112102
const inputs = preparedStatement?.inputs || {};
@@ -121,16 +111,6 @@ export default {
121111
params: [],
122112
};
123113
},
124-
/**
125-
* A method that performs the inverse transformation of `proxyAdapter`.
126-
*
127-
* @param {object} proxyArgs - The output of `proxyAdapter`.
128-
* @param {string} proxyArgs.query - The SQL query to be executed.
129-
* @param {string[]} proxyArgs.params - The values to replace in the SQL
130-
* query.
131-
* @returns {object} - The adapted query and parameters, compatible with
132-
* `executeQuery`.
133-
*/
134114
executeQueryAdapter(proxyArgs = {}) {
135115
let { query } = proxyArgs;
136116
const params = proxyArgs?.params || [];
@@ -148,10 +128,16 @@ export default {
148128
},
149129
async executeQuery(preparedStatement = {}) {
150130
let connection;
151-
const { query } = preparedStatement;
131+
const {
132+
query, requestTimeout,
133+
} = preparedStatement;
152134
const inputs = preparedStatement?.inputs || {};
153135
try {
154-
connection = await sql.connect(this.getClientConfiguration());
136+
const config = this.getConfig();
137+
if (requestTimeout) {
138+
config.options.requestTimeout = requestTimeout * 1000; // Convert to milliseconds
139+
}
140+
connection = await sql.connect(config);
155141
const input =
156142
Object.entries(inputs)
157143
.reduce((req, inputArgs) =>

components/azure_sql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/azure_sql",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Pipedream Microsoft Azure SQL Database Components",
55
"main": "azure_sql.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)