@onivoro/server-aws-redshift 22.11.0 → 24.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.
Files changed (29) hide show
  1. package/README.md +787 -0
  2. package/{dist/cjs/index.d.ts → index.ts} +2 -0
  3. package/jest.config.ts +11 -0
  4. package/package.json +10 -47
  5. package/project.json +23 -0
  6. package/{dist/esm/index.d.ts → src/index.ts} +2 -0
  7. package/src/lib/classes/server-aws-redshift-config.class.ts +4 -0
  8. package/src/lib/server-aws-redshift.module.ts +56 -0
  9. package/{dist/cjs/lib/services/redshift.service.js → src/lib/services/redshift.service.ts} +141 -84
  10. package/tsconfig.json +16 -0
  11. package/tsconfig.lib.json +8 -0
  12. package/tsconfig.spec.json +21 -0
  13. package/dist/cjs/index.js +0 -19
  14. package/dist/cjs/lib/classes/server-aws-redshift-config.class.d.ts +0 -6
  15. package/dist/cjs/lib/classes/server-aws-redshift-config.class.js +0 -10
  16. package/dist/cjs/lib/server-aws-redshift.module.d.ts +0 -4
  17. package/dist/cjs/lib/server-aws-redshift.module.js +0 -65
  18. package/dist/cjs/lib/services/redshift.service.d.ts +0 -43
  19. package/dist/esm/index.js +0 -19
  20. package/dist/esm/lib/classes/server-aws-redshift-config.class.d.ts +0 -6
  21. package/dist/esm/lib/classes/server-aws-redshift-config.class.js +0 -10
  22. package/dist/esm/lib/server-aws-redshift.module.d.ts +0 -4
  23. package/dist/esm/lib/server-aws-redshift.module.js +0 -65
  24. package/dist/esm/lib/services/redshift.service.d.ts +0 -43
  25. package/dist/esm/lib/services/redshift.service.js +0 -236
  26. package/dist/types/index.d.ts +0 -3
  27. package/dist/types/lib/classes/server-aws-redshift-config.class.d.ts +0 -6
  28. package/dist/types/lib/server-aws-redshift.module.d.ts +0 -4
  29. package/dist/types/lib/services/redshift.service.d.ts +0 -43
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var ServerAwsRedshiftDataModule_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ServerAwsRedshiftDataModule = void 0;
11
- const common_1 = require("@nestjs/common");
12
- const server_common_1 = require("@onivoro/server-common");
13
- const client_redshift_data_1 = require("@aws-sdk/client-redshift-data");
14
- const redshift_service_1 = require("./services/redshift.service");
15
- const server_aws_redshift_config_class_1 = require("./classes/server-aws-redshift-config.class");
16
- const client_redshift_serverless_1 = require("@aws-sdk/client-redshift-serverless");
17
- const client_redshift_1 = require("@aws-sdk/client-redshift");
18
- let redshiftClient = null;
19
- let redshiftDataClient = null;
20
- let redshiftServerlessClient = null;
21
- let ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule_1 = class ServerAwsRedshiftDataModule {
22
- static configure(config) {
23
- return (0, server_common_1.moduleFactory)({
24
- module: ServerAwsRedshiftDataModule_1,
25
- providers: [
26
- {
27
- provide: client_redshift_data_1.RedshiftDataClient,
28
- useFactory: () => redshiftDataClient
29
- ? redshiftDataClient
30
- : redshiftDataClient = new client_redshift_data_1.RedshiftDataClient(from(config))
31
- },
32
- {
33
- provide: client_redshift_serverless_1.RedshiftServerlessClient,
34
- useFactory: () => redshiftServerlessClient
35
- ? redshiftServerlessClient
36
- : redshiftServerlessClient = new client_redshift_serverless_1.RedshiftServerlessClient(from(config))
37
- },
38
- {
39
- provide: client_redshift_1.RedshiftClient,
40
- useFactory: () => redshiftClient
41
- ? redshiftClient
42
- : redshiftClient = new client_redshift_1.RedshiftClient(from(config))
43
- },
44
- { provide: server_aws_redshift_config_class_1.ServerAwsRedshiftDataConfig, useValue: config },
45
- redshift_service_1.RedshiftDataService
46
- ]
47
- });
48
- }
49
- };
50
- exports.ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule;
51
- exports.ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule_1 = __decorate([
52
- (0, common_1.Module)({})
53
- ], ServerAwsRedshiftDataModule);
54
- function from(config) {
55
- return {
56
- region: config.AWS_REGION,
57
- logger: console,
58
- credentials: config.NODE_ENV === 'production'
59
- ? undefined
60
- : {
61
- accessKeyId: config.AWS_ACCESS_KEY_ID,
62
- secretAccessKey: config.AWS_SECRET_ACCESS_KEY
63
- }
64
- };
65
- }
@@ -1,43 +0,0 @@
1
- import { RedshiftDataClient } from "@aws-sdk/client-redshift-data";
2
- import { RedshiftServerlessClient } from '@aws-sdk/client-redshift-serverless';
3
- export declare class RedshiftDataService {
4
- private redshiftDataClient;
5
- private redshiftServerlessClient;
6
- constructor(redshiftDataClient: RedshiftDataClient, redshiftServerlessClient: RedshiftServerlessClient);
7
- waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<number>;
8
- verifyEndpointAccess(workgroupName: string): Promise<import("@aws-sdk/client-redshift-serverless").GetWorkgroupCommandOutput>;
9
- addIamUserToDatabaseGroup(_: {
10
- database: string;
11
- workgroupName: string;
12
- user: string;
13
- group: string;
14
- }): Promise<void>;
15
- createDatabaseUser(_: {
16
- database: string;
17
- workgroupName: string;
18
- user: string;
19
- }): Promise<string>;
20
- grantUsageOnSchema(_: {
21
- database: string;
22
- workgroupName: string;
23
- schema: string;
24
- group: string;
25
- }): Promise<void>;
26
- createDbGroupFromIamGroupIfNotExists(_: {
27
- iamGroup: string;
28
- database: string;
29
- workgroupName: string;
30
- }): Promise<any>;
31
- queryV1(_: {
32
- database: string;
33
- workgroupName: string;
34
- }, Sql: string): Promise<number>;
35
- query(_: {
36
- database: string;
37
- workgroupName: string;
38
- }, Sql: string): Promise<(string | number)[][]>;
39
- getAssociatedIAmRolesByWorkgroup(_: {
40
- database: string;
41
- workgroupName: string;
42
- }): Promise<(string | number)[][]>;
43
- }
package/dist/esm/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./lib/classes/server-aws-redshift-config.class"), exports);
18
- __exportStar(require("./lib/services/redshift.service"), exports);
19
- __exportStar(require("./lib/server-aws-redshift.module"), exports);
@@ -1,6 +0,0 @@
1
- export declare class ServerAwsRedshiftDataConfig {
2
- AWS_ACCESS_KEY_ID?: string;
3
- AWS_REGION: string;
4
- AWS_SECRET_ACCESS_KEY?: string;
5
- NODE_ENV: string;
6
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerAwsRedshiftDataConfig = void 0;
4
- class ServerAwsRedshiftDataConfig {
5
- AWS_ACCESS_KEY_ID;
6
- AWS_REGION;
7
- AWS_SECRET_ACCESS_KEY;
8
- NODE_ENV;
9
- }
10
- exports.ServerAwsRedshiftDataConfig = ServerAwsRedshiftDataConfig;
@@ -1,4 +0,0 @@
1
- import { ServerAwsRedshiftDataConfig } from './classes/server-aws-redshift-config.class';
2
- export declare class ServerAwsRedshiftDataModule {
3
- static configure(config: ServerAwsRedshiftDataConfig): any;
4
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var ServerAwsRedshiftDataModule_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ServerAwsRedshiftDataModule = void 0;
11
- const common_1 = require("@nestjs/common");
12
- const server_common_1 = require("@onivoro/server-common");
13
- const client_redshift_data_1 = require("@aws-sdk/client-redshift-data");
14
- const redshift_service_1 = require("./services/redshift.service");
15
- const server_aws_redshift_config_class_1 = require("./classes/server-aws-redshift-config.class");
16
- const client_redshift_serverless_1 = require("@aws-sdk/client-redshift-serverless");
17
- const client_redshift_1 = require("@aws-sdk/client-redshift");
18
- let redshiftClient = null;
19
- let redshiftDataClient = null;
20
- let redshiftServerlessClient = null;
21
- let ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule_1 = class ServerAwsRedshiftDataModule {
22
- static configure(config) {
23
- return (0, server_common_1.moduleFactory)({
24
- module: ServerAwsRedshiftDataModule_1,
25
- providers: [
26
- {
27
- provide: client_redshift_data_1.RedshiftDataClient,
28
- useFactory: () => redshiftDataClient
29
- ? redshiftDataClient
30
- : redshiftDataClient = new client_redshift_data_1.RedshiftDataClient(from(config))
31
- },
32
- {
33
- provide: client_redshift_serverless_1.RedshiftServerlessClient,
34
- useFactory: () => redshiftServerlessClient
35
- ? redshiftServerlessClient
36
- : redshiftServerlessClient = new client_redshift_serverless_1.RedshiftServerlessClient(from(config))
37
- },
38
- {
39
- provide: client_redshift_1.RedshiftClient,
40
- useFactory: () => redshiftClient
41
- ? redshiftClient
42
- : redshiftClient = new client_redshift_1.RedshiftClient(from(config))
43
- },
44
- { provide: server_aws_redshift_config_class_1.ServerAwsRedshiftDataConfig, useValue: config },
45
- redshift_service_1.RedshiftDataService
46
- ]
47
- });
48
- }
49
- };
50
- exports.ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule;
51
- exports.ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule = ServerAwsRedshiftDataModule_1 = __decorate([
52
- (0, common_1.Module)({})
53
- ], ServerAwsRedshiftDataModule);
54
- function from(config) {
55
- return {
56
- region: config.AWS_REGION,
57
- logger: console,
58
- credentials: config.NODE_ENV === 'production'
59
- ? undefined
60
- : {
61
- accessKeyId: config.AWS_ACCESS_KEY_ID,
62
- secretAccessKey: config.AWS_SECRET_ACCESS_KEY
63
- }
64
- };
65
- }
@@ -1,43 +0,0 @@
1
- import { RedshiftDataClient } from "@aws-sdk/client-redshift-data";
2
- import { RedshiftServerlessClient } from '@aws-sdk/client-redshift-serverless';
3
- export declare class RedshiftDataService {
4
- private redshiftDataClient;
5
- private redshiftServerlessClient;
6
- constructor(redshiftDataClient: RedshiftDataClient, redshiftServerlessClient: RedshiftServerlessClient);
7
- waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<number>;
8
- verifyEndpointAccess(workgroupName: string): Promise<import("@aws-sdk/client-redshift-serverless").GetWorkgroupCommandOutput>;
9
- addIamUserToDatabaseGroup(_: {
10
- database: string;
11
- workgroupName: string;
12
- user: string;
13
- group: string;
14
- }): Promise<void>;
15
- createDatabaseUser(_: {
16
- database: string;
17
- workgroupName: string;
18
- user: string;
19
- }): Promise<string>;
20
- grantUsageOnSchema(_: {
21
- database: string;
22
- workgroupName: string;
23
- schema: string;
24
- group: string;
25
- }): Promise<void>;
26
- createDbGroupFromIamGroupIfNotExists(_: {
27
- iamGroup: string;
28
- database: string;
29
- workgroupName: string;
30
- }): Promise<any>;
31
- queryV1(_: {
32
- database: string;
33
- workgroupName: string;
34
- }, Sql: string): Promise<number>;
35
- query(_: {
36
- database: string;
37
- workgroupName: string;
38
- }, Sql: string): Promise<(string | number)[][]>;
39
- getAssociatedIAmRolesByWorkgroup(_: {
40
- database: string;
41
- workgroupName: string;
42
- }): Promise<(string | number)[][]>;
43
- }
@@ -1,236 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RedshiftDataService = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const client_redshift_data_1 = require("@aws-sdk/client-redshift-data");
15
- const client_redshift_serverless_1 = require("@aws-sdk/client-redshift-serverless");
16
- const crypto_1 = require("crypto");
17
- let RedshiftDataService = class RedshiftDataService {
18
- redshiftDataClient;
19
- redshiftServerlessClient;
20
- constructor(redshiftDataClient, redshiftServerlessClient) {
21
- this.redshiftDataClient = redshiftDataClient;
22
- this.redshiftServerlessClient = redshiftServerlessClient;
23
- }
24
- async waitForStatement(statementId, maxAttempts = 10, delay = 1000) {
25
- let attempts = 0;
26
- while (attempts < maxAttempts) {
27
- const describeStatementCommand = new client_redshift_data_1.DescribeStatementCommand({
28
- Id: statementId
29
- });
30
- const status = await this.redshiftDataClient.send(describeStatementCommand);
31
- if (status.Status === 'FINISHED') {
32
- return status.ResultRows;
33
- }
34
- if (status.Status === 'FAILED') {
35
- throw new Error(`SQL statement failed: ${status.Error}`);
36
- }
37
- attempts++;
38
- await new Promise(resolve => setTimeout(resolve, delay));
39
- }
40
- throw new Error('Timeout waiting for SQL statement to complete');
41
- }
42
- async verifyEndpointAccess(workgroupName) {
43
- const workgroupResponse = await this.redshiftServerlessClient.send(new client_redshift_serverless_1.GetWorkgroupCommand({ workgroupName }));
44
- if (!workgroupResponse?.workgroup?.endpoint?.address) {
45
- console.error(`Could not retrieve endpoint for workgroupName "${workgroupName}"`);
46
- return;
47
- }
48
- return workgroupResponse;
49
- }
50
- async addIamUserToDatabaseGroup(_) {
51
- try {
52
- const groupResult = await this.redshiftDataClient.send(new client_redshift_data_1.ExecuteStatementCommand({
53
- Database: _.database,
54
- Sql: `ALTER GROUP ${_.group} ADD USER "${_.user}";`,
55
- WorkgroupName: _.workgroupName
56
- }));
57
- await this.waitForStatement(groupResult.Id);
58
- console.log(`Added user "${_.user}" to group "${_.group}`);
59
- }
60
- catch (error) {
61
- console.warn({ detail: `Warning adding ${_.user} to group:`, error });
62
- }
63
- }
64
- async createDatabaseUser(_) {
65
- try {
66
- const checkResult = await this.redshiftDataClient.send(new client_redshift_data_1.ExecuteStatementCommand({
67
- Database: _.database,
68
- Sql: `SELECT u.usename as username FROM pg_user u;`,
69
- WorkgroupName: _.workgroupName
70
- }));
71
- await this.waitForStatement(checkResult.Id);
72
- const describeCommand = new client_redshift_data_1.DescribeStatementCommand({ Id: checkResult.Id });
73
- const checkStatus = await this.redshiftDataClient.send(describeCommand);
74
- if (!checkStatus.ResultRows) {
75
- const placeholderPassword = `IAM_${(0, crypto_1.randomUUID)().replace(/-/g, '_')}`;
76
- const createUserCommand = new client_redshift_data_1.ExecuteStatementCommand({
77
- Database: _.database,
78
- Sql: `CREATE USER ${_.user} PASSWORD '${placeholderPassword}';`,
79
- WorkgroupName: _.workgroupName
80
- });
81
- const createResult = await this.redshiftDataClient.send(createUserCommand);
82
- await this.waitForStatement(createResult.Id);
83
- console.log(`Created user: ${_.user}`);
84
- return placeholderPassword;
85
- }
86
- else {
87
- console.log(`User "${_.user} already exists`);
88
- return '';
89
- }
90
- }
91
- catch (error) {
92
- console.warn({ detail: `Warning creating user ${_.user}`, error });
93
- throw error;
94
- }
95
- }
96
- async grantUsageOnSchema(_) {
97
- try {
98
- const setupStatements = [
99
- `GRANT USAGE ON SCHEMA ${_.schema} TO GROUP ${_.group};`,
100
- `GRANT SELECT ON ALL TABLES IN SCHEMA ${_.schema} TO GROUP ${_.group};`,
101
- `ALTER DEFAULT PRIVILEGES IN SCHEMA ${_.schema} GRANT SELECT ON TABLES TO GROUP ${_.group};`,
102
- ];
103
- for (const Sql of setupStatements) {
104
- const executeStatementCommand = new client_redshift_data_1.ExecuteStatementCommand({
105
- Database: _.database,
106
- Sql,
107
- WorkgroupName: _.workgroupName
108
- });
109
- try {
110
- const result = await this.redshiftDataClient.send(executeStatementCommand);
111
- await this.waitForStatement(result.Id);
112
- console.log(Sql);
113
- }
114
- catch (error) {
115
- console.warn({ Sql, error });
116
- }
117
- }
118
- }
119
- catch (error) {
120
- console.error({ error });
121
- throw error;
122
- }
123
- }
124
- async createDbGroupFromIamGroupIfNotExists(_) {
125
- try {
126
- const checkResult = await this.redshiftDataClient.send(new client_redshift_data_1.ExecuteStatementCommand({
127
- Database: _.database,
128
- Sql: `SELECT 1 FROM pg_group WHERE groname = '${_.iamGroup}';`,
129
- WorkgroupName: _.workgroupName
130
- }));
131
- await this.waitForStatement(checkResult.Id);
132
- const describeCommand = new client_redshift_data_1.DescribeStatementCommand({ Id: checkResult.Id });
133
- const checkStatus = await this.redshiftDataClient.send(describeCommand);
134
- if (!checkStatus.ResultRows) {
135
- const createGroupCommand = new client_redshift_data_1.ExecuteStatementCommand({
136
- Database: _.database,
137
- Sql: `CREATE GROUP ${_.iamGroup};`,
138
- WorkgroupName: _.workgroupName
139
- });
140
- const createResult = await this.redshiftDataClient.send(createGroupCommand);
141
- await this.waitForStatement(createResult.Id);
142
- console.log(`Created "${_.iamGroup}" group`);
143
- }
144
- else {
145
- console.log(`"${_.iamGroup}" group already exists`);
146
- }
147
- }
148
- catch (error) {
149
- console.error({ error });
150
- throw error;
151
- }
152
- }
153
- async queryV1(_, Sql) {
154
- const result = await this.redshiftDataClient.send(new client_redshift_data_1.ExecuteStatementCommand({
155
- Database: _.database,
156
- Sql,
157
- WorkgroupName: _.workgroupName
158
- }));
159
- return await this.waitForStatement(result.Id);
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, Error: err } = await this.redshiftDataClient.send(describeCommand);
176
- status = Status || "";
177
- if (status === "FAILED") {
178
- throw new Error(err);
179
- }
180
- if (status !== "FINISHED") {
181
- await new Promise(resolve => setTimeout(resolve, 1000));
182
- }
183
- } while (status !== "FINISHED");
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
- }
195
- }
196
- catch (error) {
197
- console.error({ detail: "Error executing query:", error });
198
- throw error;
199
- }
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
- }
230
- };
231
- exports.RedshiftDataService = RedshiftDataService;
232
- exports.RedshiftDataService = RedshiftDataService = __decorate([
233
- (0, common_1.Injectable)(),
234
- __metadata("design:paramtypes", [client_redshift_data_1.RedshiftDataClient,
235
- client_redshift_serverless_1.RedshiftServerlessClient])
236
- ], RedshiftDataService);
@@ -1,3 +0,0 @@
1
- export * from './lib/classes/server-aws-redshift-config.class';
2
- export * from './lib/services/redshift.service';
3
- export * from './lib/server-aws-redshift.module';
@@ -1,6 +0,0 @@
1
- export declare class ServerAwsRedshiftDataConfig {
2
- AWS_ACCESS_KEY_ID?: string;
3
- AWS_REGION: string;
4
- AWS_SECRET_ACCESS_KEY?: string;
5
- NODE_ENV: string;
6
- }
@@ -1,4 +0,0 @@
1
- import { ServerAwsRedshiftDataConfig } from './classes/server-aws-redshift-config.class';
2
- export declare class ServerAwsRedshiftDataModule {
3
- static configure(config: ServerAwsRedshiftDataConfig): any;
4
- }
@@ -1,43 +0,0 @@
1
- import { RedshiftDataClient } from "@aws-sdk/client-redshift-data";
2
- import { RedshiftServerlessClient } from '@aws-sdk/client-redshift-serverless';
3
- export declare class RedshiftDataService {
4
- private redshiftDataClient;
5
- private redshiftServerlessClient;
6
- constructor(redshiftDataClient: RedshiftDataClient, redshiftServerlessClient: RedshiftServerlessClient);
7
- waitForStatement(statementId: string, maxAttempts?: number, delay?: number): Promise<number>;
8
- verifyEndpointAccess(workgroupName: string): Promise<import("@aws-sdk/client-redshift-serverless").GetWorkgroupCommandOutput>;
9
- addIamUserToDatabaseGroup(_: {
10
- database: string;
11
- workgroupName: string;
12
- user: string;
13
- group: string;
14
- }): Promise<void>;
15
- createDatabaseUser(_: {
16
- database: string;
17
- workgroupName: string;
18
- user: string;
19
- }): Promise<string>;
20
- grantUsageOnSchema(_: {
21
- database: string;
22
- workgroupName: string;
23
- schema: string;
24
- group: string;
25
- }): Promise<void>;
26
- createDbGroupFromIamGroupIfNotExists(_: {
27
- iamGroup: string;
28
- database: string;
29
- workgroupName: string;
30
- }): Promise<any>;
31
- queryV1(_: {
32
- database: string;
33
- workgroupName: string;
34
- }, Sql: string): Promise<number>;
35
- query(_: {
36
- database: string;
37
- workgroupName: string;
38
- }, Sql: string): Promise<(string | number)[][]>;
39
- getAssociatedIAmRolesByWorkgroup(_: {
40
- database: string;
41
- workgroupName: string;
42
- }): Promise<(string | number)[][]>;
43
- }