@onivoro/server-aws-redshift 22.0.4 → 22.0.6
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/dist/cjs/lib/services/redshift.service.d.ts +6 -2
- package/dist/cjs/lib/services/redshift.service.js +37 -3
- package/dist/esm/lib/services/redshift.service.d.ts +6 -2
- package/dist/esm/lib/services/redshift.service.js +37 -3
- package/dist/types/lib/services/redshift.service.d.ts +6 -2
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ export declare class RedshiftDataService {
|
|
|
4
4
|
private redshiftDataClient;
|
|
5
5
|
private redshiftServerlessClient;
|
|
6
6
|
constructor(redshiftDataClient: RedshiftDataClient, redshiftServerlessClient: RedshiftServerlessClient);
|
|
7
|
-
waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<
|
|
7
|
+
waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<number>;
|
|
8
8
|
verifyEndpointAccess(workgroupName: string): Promise<import("@aws-sdk/client-redshift-serverless").GetWorkgroupCommandOutput>;
|
|
9
9
|
addIamUserToDatabaseGroup(_: {
|
|
10
10
|
database: string;
|
|
@@ -28,8 +28,12 @@ export declare class RedshiftDataService {
|
|
|
28
28
|
database: string;
|
|
29
29
|
workgroupName: string;
|
|
30
30
|
}): Promise<any>;
|
|
31
|
+
queryV1(_: {
|
|
32
|
+
database: string;
|
|
33
|
+
workgroupName: string;
|
|
34
|
+
}, Sql: string): Promise<number>;
|
|
31
35
|
query(_: {
|
|
32
36
|
database: string;
|
|
33
37
|
workgroupName: string;
|
|
34
|
-
}, Sql: string): Promise<
|
|
38
|
+
}, Sql: string): Promise<(string | number)[][]>;
|
|
35
39
|
}
|
|
@@ -29,7 +29,7 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
29
29
|
});
|
|
30
30
|
const status = await this.redshiftDataClient.send(describeStatementCommand);
|
|
31
31
|
if (status.Status === 'FINISHED') {
|
|
32
|
-
return;
|
|
32
|
+
return status.ResultRows;
|
|
33
33
|
}
|
|
34
34
|
if (status.Status === 'FAILED') {
|
|
35
35
|
throw new Error(`SQL statement failed: ${status.Error}`);
|
|
@@ -150,14 +150,48 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
150
150
|
throw error;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
async
|
|
153
|
+
async queryV1(_, Sql) {
|
|
154
154
|
const result = await this.redshiftDataClient.send(new client_redshift_data_1.ExecuteStatementCommand({
|
|
155
155
|
Database: _.database,
|
|
156
156
|
Sql,
|
|
157
157
|
WorkgroupName: _.workgroupName
|
|
158
158
|
}));
|
|
159
159
|
return await this.waitForStatement(result.Id);
|
|
160
|
-
|
|
160
|
+
}
|
|
161
|
+
async query(_, Sql) {
|
|
162
|
+
try {
|
|
163
|
+
const executeCommand = new client_redshift_data_1.ExecuteStatementCommand({
|
|
164
|
+
Database: _.database,
|
|
165
|
+
Sql,
|
|
166
|
+
WorkgroupName: _.workgroupName
|
|
167
|
+
});
|
|
168
|
+
const { Id } = await this.redshiftDataClient.send(executeCommand);
|
|
169
|
+
if (!Id) {
|
|
170
|
+
throw new Error("Failed to get statement ID");
|
|
171
|
+
}
|
|
172
|
+
let status = "";
|
|
173
|
+
do {
|
|
174
|
+
const describeCommand = new client_redshift_data_1.DescribeStatementCommand({ Id });
|
|
175
|
+
const { Status } = await this.redshiftDataClient.send(describeCommand);
|
|
176
|
+
status = Status || "";
|
|
177
|
+
if (status === "FAILED") {
|
|
178
|
+
throw new Error("Query execution failed");
|
|
179
|
+
}
|
|
180
|
+
if (status !== "FINISHED") {
|
|
181
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
182
|
+
}
|
|
183
|
+
} while (status !== "FINISHED");
|
|
184
|
+
const getResultsCommand = new client_redshift_data_1.GetStatementResultCommand({ Id });
|
|
185
|
+
const results = await this.redshiftDataClient.send(getResultsCommand);
|
|
186
|
+
const records = results.Records || [];
|
|
187
|
+
return records.map(record => {
|
|
188
|
+
return record.map(field => field.stringValue || field.longValue || field.doubleValue);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error({ detail: "Error executing query:", error });
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
161
195
|
}
|
|
162
196
|
};
|
|
163
197
|
exports.RedshiftDataService = RedshiftDataService;
|
|
@@ -4,7 +4,7 @@ export declare class RedshiftDataService {
|
|
|
4
4
|
private redshiftDataClient;
|
|
5
5
|
private redshiftServerlessClient;
|
|
6
6
|
constructor(redshiftDataClient: RedshiftDataClient, redshiftServerlessClient: RedshiftServerlessClient);
|
|
7
|
-
waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<
|
|
7
|
+
waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<number>;
|
|
8
8
|
verifyEndpointAccess(workgroupName: string): Promise<import("@aws-sdk/client-redshift-serverless").GetWorkgroupCommandOutput>;
|
|
9
9
|
addIamUserToDatabaseGroup(_: {
|
|
10
10
|
database: string;
|
|
@@ -28,8 +28,12 @@ export declare class RedshiftDataService {
|
|
|
28
28
|
database: string;
|
|
29
29
|
workgroupName: string;
|
|
30
30
|
}): Promise<any>;
|
|
31
|
+
queryV1(_: {
|
|
32
|
+
database: string;
|
|
33
|
+
workgroupName: string;
|
|
34
|
+
}, Sql: string): Promise<number>;
|
|
31
35
|
query(_: {
|
|
32
36
|
database: string;
|
|
33
37
|
workgroupName: string;
|
|
34
|
-
}, Sql: string): Promise<
|
|
38
|
+
}, Sql: string): Promise<(string | number)[][]>;
|
|
35
39
|
}
|
|
@@ -29,7 +29,7 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
29
29
|
});
|
|
30
30
|
const status = await this.redshiftDataClient.send(describeStatementCommand);
|
|
31
31
|
if (status.Status === 'FINISHED') {
|
|
32
|
-
return;
|
|
32
|
+
return status.ResultRows;
|
|
33
33
|
}
|
|
34
34
|
if (status.Status === 'FAILED') {
|
|
35
35
|
throw new Error(`SQL statement failed: ${status.Error}`);
|
|
@@ -150,14 +150,48 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
150
150
|
throw error;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
async
|
|
153
|
+
async queryV1(_, Sql) {
|
|
154
154
|
const result = await this.redshiftDataClient.send(new client_redshift_data_1.ExecuteStatementCommand({
|
|
155
155
|
Database: _.database,
|
|
156
156
|
Sql,
|
|
157
157
|
WorkgroupName: _.workgroupName
|
|
158
158
|
}));
|
|
159
159
|
return await this.waitForStatement(result.Id);
|
|
160
|
-
|
|
160
|
+
}
|
|
161
|
+
async query(_, Sql) {
|
|
162
|
+
try {
|
|
163
|
+
const executeCommand = new client_redshift_data_1.ExecuteStatementCommand({
|
|
164
|
+
Database: _.database,
|
|
165
|
+
Sql,
|
|
166
|
+
WorkgroupName: _.workgroupName
|
|
167
|
+
});
|
|
168
|
+
const { Id } = await this.redshiftDataClient.send(executeCommand);
|
|
169
|
+
if (!Id) {
|
|
170
|
+
throw new Error("Failed to get statement ID");
|
|
171
|
+
}
|
|
172
|
+
let status = "";
|
|
173
|
+
do {
|
|
174
|
+
const describeCommand = new client_redshift_data_1.DescribeStatementCommand({ Id });
|
|
175
|
+
const { Status } = await this.redshiftDataClient.send(describeCommand);
|
|
176
|
+
status = Status || "";
|
|
177
|
+
if (status === "FAILED") {
|
|
178
|
+
throw new Error("Query execution failed");
|
|
179
|
+
}
|
|
180
|
+
if (status !== "FINISHED") {
|
|
181
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
182
|
+
}
|
|
183
|
+
} while (status !== "FINISHED");
|
|
184
|
+
const getResultsCommand = new client_redshift_data_1.GetStatementResultCommand({ Id });
|
|
185
|
+
const results = await this.redshiftDataClient.send(getResultsCommand);
|
|
186
|
+
const records = results.Records || [];
|
|
187
|
+
return records.map(record => {
|
|
188
|
+
return record.map(field => field.stringValue || field.longValue || field.doubleValue);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error({ detail: "Error executing query:", error });
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
161
195
|
}
|
|
162
196
|
};
|
|
163
197
|
exports.RedshiftDataService = RedshiftDataService;
|
|
@@ -4,7 +4,7 @@ export declare class RedshiftDataService {
|
|
|
4
4
|
private redshiftDataClient;
|
|
5
5
|
private redshiftServerlessClient;
|
|
6
6
|
constructor(redshiftDataClient: RedshiftDataClient, redshiftServerlessClient: RedshiftServerlessClient);
|
|
7
|
-
waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<
|
|
7
|
+
waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<number>;
|
|
8
8
|
verifyEndpointAccess(workgroupName: string): Promise<import("@aws-sdk/client-redshift-serverless").GetWorkgroupCommandOutput>;
|
|
9
9
|
addIamUserToDatabaseGroup(_: {
|
|
10
10
|
database: string;
|
|
@@ -28,8 +28,12 @@ export declare class RedshiftDataService {
|
|
|
28
28
|
database: string;
|
|
29
29
|
workgroupName: string;
|
|
30
30
|
}): Promise<any>;
|
|
31
|
+
queryV1(_: {
|
|
32
|
+
database: string;
|
|
33
|
+
workgroupName: string;
|
|
34
|
+
}, Sql: string): Promise<number>;
|
|
31
35
|
query(_: {
|
|
32
36
|
database: string;
|
|
33
37
|
workgroupName: string;
|
|
34
|
-
}, Sql: string): Promise<
|
|
38
|
+
}, Sql: string): Promise<(string | number)[][]>;
|
|
35
39
|
}
|