@onivoro/server-aws-redshift 22.0.7 → 22.0.9
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/server-aws-redshift.module.js +1 -1
- package/dist/cjs/lib/services/redshift.service.d.ts +4 -0
- package/dist/cjs/lib/services/redshift.service.js +41 -7
- package/dist/esm/lib/server-aws-redshift.module.js +1 -1
- package/dist/esm/lib/services/redshift.service.d.ts +4 -0
- package/dist/esm/lib/services/redshift.service.js +41 -7
- package/dist/types/lib/services/redshift.service.d.ts +4 -0
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ let ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule_1 = class ServerAw
|
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
provide: client_redshift_serverless_1.RedshiftServerlessClient,
|
|
34
|
-
useFactory: () =>
|
|
34
|
+
useFactory: () => redshiftServerlessClient
|
|
35
35
|
? redshiftServerlessClient
|
|
36
36
|
: redshiftServerlessClient = new client_redshift_serverless_1.RedshiftServerlessClient(from(config))
|
|
37
37
|
},
|
|
@@ -36,4 +36,8 @@ export declare class RedshiftDataService {
|
|
|
36
36
|
database: string;
|
|
37
37
|
workgroupName: string;
|
|
38
38
|
}, Sql: string): Promise<(string | number)[][]>;
|
|
39
|
+
getAssociatedIAmRolesByWorkgroup(_: {
|
|
40
|
+
database: string;
|
|
41
|
+
workgroupName: string;
|
|
42
|
+
}): Promise<(string | number)[][]>;
|
|
39
43
|
}
|
|
@@ -172,7 +172,7 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
172
172
|
let status = "";
|
|
173
173
|
do {
|
|
174
174
|
const describeCommand = new client_redshift_data_1.DescribeStatementCommand({ Id });
|
|
175
|
-
const { Status } = await this.redshiftDataClient.send(describeCommand);
|
|
175
|
+
const { Status, } = await this.redshiftDataClient.send(describeCommand);
|
|
176
176
|
status = Status || "";
|
|
177
177
|
if (status === "FAILED") {
|
|
178
178
|
throw new Error("Query execution failed");
|
|
@@ -181,18 +181,52 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
181
181
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
182
182
|
}
|
|
183
183
|
} while (status !== "FINISHED");
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return
|
|
189
|
-
|
|
184
|
+
try {
|
|
185
|
+
const getResultsCommand = new client_redshift_data_1.GetStatementResultCommand({ Id });
|
|
186
|
+
const results = await this.redshiftDataClient.send(getResultsCommand);
|
|
187
|
+
const records = results.Records || [];
|
|
188
|
+
return records.map(record => {
|
|
189
|
+
return record.map(field => field.stringValue || field.longValue || field.doubleValue);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
190
195
|
}
|
|
191
196
|
catch (error) {
|
|
192
197
|
console.error({ detail: "Error executing query:", error });
|
|
193
198
|
throw error;
|
|
194
199
|
}
|
|
195
200
|
}
|
|
201
|
+
async getAssociatedIAmRolesByWorkgroup(_) {
|
|
202
|
+
try {
|
|
203
|
+
const query = `
|
|
204
|
+
SELECT
|
|
205
|
+
g.groname as role_name,
|
|
206
|
+
u.usename as member_name,
|
|
207
|
+
g.grosysid as role_id,
|
|
208
|
+
g.groowner as owner_id,
|
|
209
|
+
CASE WHEN pg_has_role(u.usename, g.groname, 'MEMBER') THEN true ELSE false END as is_member
|
|
210
|
+
FROM pg_group g
|
|
211
|
+
LEFT JOIN pg_user u ON u.usesysid = ANY(g.grolist)
|
|
212
|
+
WHERE EXISTS (
|
|
213
|
+
SELECT 1
|
|
214
|
+
FROM svv_redshift_databases d
|
|
215
|
+
WHERE d.database_name = current_database()
|
|
216
|
+
AND d.workgroup_name = $1
|
|
217
|
+
)
|
|
218
|
+
ORDER BY g.groname, u.usename;
|
|
219
|
+
`;
|
|
220
|
+
return await this.query(_, query);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error instanceof Error) {
|
|
224
|
+
console.error(`Error getting workgroup roles: ${error.message}`);
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
throw new Error('An unknown error occurred');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
196
230
|
};
|
|
197
231
|
exports.RedshiftDataService = RedshiftDataService;
|
|
198
232
|
exports.RedshiftDataService = RedshiftDataService = __decorate([
|
|
@@ -31,7 +31,7 @@ let ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule_1 = class ServerAw
|
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
provide: client_redshift_serverless_1.RedshiftServerlessClient,
|
|
34
|
-
useFactory: () =>
|
|
34
|
+
useFactory: () => redshiftServerlessClient
|
|
35
35
|
? redshiftServerlessClient
|
|
36
36
|
: redshiftServerlessClient = new client_redshift_serverless_1.RedshiftServerlessClient(from(config))
|
|
37
37
|
},
|
|
@@ -36,4 +36,8 @@ export declare class RedshiftDataService {
|
|
|
36
36
|
database: string;
|
|
37
37
|
workgroupName: string;
|
|
38
38
|
}, Sql: string): Promise<(string | number)[][]>;
|
|
39
|
+
getAssociatedIAmRolesByWorkgroup(_: {
|
|
40
|
+
database: string;
|
|
41
|
+
workgroupName: string;
|
|
42
|
+
}): Promise<(string | number)[][]>;
|
|
39
43
|
}
|
|
@@ -172,7 +172,7 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
172
172
|
let status = "";
|
|
173
173
|
do {
|
|
174
174
|
const describeCommand = new client_redshift_data_1.DescribeStatementCommand({ Id });
|
|
175
|
-
const { Status } = await this.redshiftDataClient.send(describeCommand);
|
|
175
|
+
const { Status, } = await this.redshiftDataClient.send(describeCommand);
|
|
176
176
|
status = Status || "";
|
|
177
177
|
if (status === "FAILED") {
|
|
178
178
|
throw new Error("Query execution failed");
|
|
@@ -181,18 +181,52 @@ let RedshiftDataService = class RedshiftDataService {
|
|
|
181
181
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
182
182
|
}
|
|
183
183
|
} while (status !== "FINISHED");
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return
|
|
189
|
-
|
|
184
|
+
try {
|
|
185
|
+
const getResultsCommand = new client_redshift_data_1.GetStatementResultCommand({ Id });
|
|
186
|
+
const results = await this.redshiftDataClient.send(getResultsCommand);
|
|
187
|
+
const records = results.Records || [];
|
|
188
|
+
return records.map(record => {
|
|
189
|
+
return record.map(field => field.stringValue || field.longValue || field.doubleValue);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
190
195
|
}
|
|
191
196
|
catch (error) {
|
|
192
197
|
console.error({ detail: "Error executing query:", error });
|
|
193
198
|
throw error;
|
|
194
199
|
}
|
|
195
200
|
}
|
|
201
|
+
async getAssociatedIAmRolesByWorkgroup(_) {
|
|
202
|
+
try {
|
|
203
|
+
const query = `
|
|
204
|
+
SELECT
|
|
205
|
+
g.groname as role_name,
|
|
206
|
+
u.usename as member_name,
|
|
207
|
+
g.grosysid as role_id,
|
|
208
|
+
g.groowner as owner_id,
|
|
209
|
+
CASE WHEN pg_has_role(u.usename, g.groname, 'MEMBER') THEN true ELSE false END as is_member
|
|
210
|
+
FROM pg_group g
|
|
211
|
+
LEFT JOIN pg_user u ON u.usesysid = ANY(g.grolist)
|
|
212
|
+
WHERE EXISTS (
|
|
213
|
+
SELECT 1
|
|
214
|
+
FROM svv_redshift_databases d
|
|
215
|
+
WHERE d.database_name = current_database()
|
|
216
|
+
AND d.workgroup_name = $1
|
|
217
|
+
)
|
|
218
|
+
ORDER BY g.groname, u.usename;
|
|
219
|
+
`;
|
|
220
|
+
return await this.query(_, query);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error instanceof Error) {
|
|
224
|
+
console.error(`Error getting workgroup roles: ${error.message}`);
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
throw new Error('An unknown error occurred');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
196
230
|
};
|
|
197
231
|
exports.RedshiftDataService = RedshiftDataService;
|
|
198
232
|
exports.RedshiftDataService = RedshiftDataService = __decorate([
|
|
@@ -36,4 +36,8 @@ export declare class RedshiftDataService {
|
|
|
36
36
|
database: string;
|
|
37
37
|
workgroupName: string;
|
|
38
38
|
}, Sql: string): Promise<(string | number)[][]>;
|
|
39
|
+
getAssociatedIAmRolesByWorkgroup(_: {
|
|
40
|
+
database: string;
|
|
41
|
+
workgroupName: string;
|
|
42
|
+
}): Promise<(string | number)[][]>;
|
|
39
43
|
}
|