@onivoro/server-aws-ecs 24.17.0 → 24.20.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onivoro/server-aws-ecs",
3
- "version": "24.17.0",
3
+ "version": "24.20.0",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -9,8 +9,8 @@
9
9
  "url": "https://github.com/onivoro/monorepo.git"
10
10
  },
11
11
  "dependencies": {
12
- "@onivoro/server-aws-credential-providers": "24.17.0",
13
- "@onivoro/server-common": "24.17.0",
12
+ "@onivoro/server-aws-credential-providers": "24.20.0",
13
+ "@onivoro/server-common": "24.20.0",
14
14
  "tslib": "^2.3.0"
15
15
  },
16
16
  "peerDependencies": {
@@ -23,4 +23,4 @@
23
23
  "**/*.js.map",
24
24
  "README.md"
25
25
  ]
26
- }
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './lib/classes/server-aws-ecs-config.class';
2
+ export * from './lib/services/ecs.service';
3
+ export * from './lib/server-aws-ecs.module';
4
+ //# sourceMappingURL=index.d.ts.map
package/src/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/classes/server-aws-ecs-config.class"), exports);
5
+ tslib_1.__exportStar(require("./lib/services/ecs.service"), exports);
6
+ tslib_1.__exportStar(require("./lib/server-aws-ecs.module"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/server/aws-ecs/src/index.ts"],"names":[],"mappings":";;;AAAA,oFAA0D;AAE1D,qEAA2C;AAE3C,sEAA4C"}
@@ -0,0 +1,5 @@
1
+ export declare class ServerAwsEcsConfig {
2
+ AWS_PROFILE?: string;
3
+ AWS_REGION: string;
4
+ }
5
+ //# sourceMappingURL=server-aws-ecs-config.class.d.ts.map
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerAwsEcsConfig = void 0;
4
+ class ServerAwsEcsConfig {
5
+ AWS_PROFILE;
6
+ AWS_REGION;
7
+ }
8
+ exports.ServerAwsEcsConfig = ServerAwsEcsConfig;
9
+ //# sourceMappingURL=server-aws-ecs-config.class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-aws-ecs-config.class.js","sourceRoot":"","sources":["../../../../../../../libs/server/aws-ecs/src/lib/classes/server-aws-ecs-config.class.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAkB;IAC3B,WAAW,CAAU;IACrB,UAAU,CAAS;CACtB;AAHD,gDAGC"}
@@ -0,0 +1,2 @@
1
+ export declare function parseCsvString(value?: string | undefined): string[];
2
+ //# sourceMappingURL=parse-csv-string.function.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCsvString = parseCsvString;
4
+ function parseCsvString(value) {
5
+ return value ? value.split(',').map(_ => _.trim()).filter(Boolean) : [];
6
+ }
7
+ //# sourceMappingURL=parse-csv-string.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-csv-string.function.js","sourceRoot":"","sources":["../../../../../../../libs/server/aws-ecs/src/lib/functions/parse-csv-string.function.ts"],"names":[],"mappings":";;AAAA,wCAEC;AAFD,SAAgB,cAAc,CAAC,KAA0B;IACrD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ServerAwsEcsConfig } from './classes/server-aws-ecs-config.class';
2
+ export declare class ServerAwsEcsModule {
3
+ static configure(config: ServerAwsEcsConfig): any;
4
+ }
5
+ //# sourceMappingURL=server-aws-ecs.module.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var ServerAwsEcsModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ServerAwsEcsModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const server_common_1 = require("@onivoro/server-common");
8
+ const client_ecs_1 = require("@aws-sdk/client-ecs");
9
+ const ecs_service_1 = require("./services/ecs.service");
10
+ const server_aws_ecs_config_class_1 = require("./classes/server-aws-ecs-config.class");
11
+ const server_aws_credential_providers_1 = require("@onivoro/server-aws-credential-providers");
12
+ let ecsClient = null;
13
+ let ServerAwsEcsModule = ServerAwsEcsModule_1 = class ServerAwsEcsModule {
14
+ static configure(config) {
15
+ return (0, server_common_1.moduleFactory)({
16
+ module: ServerAwsEcsModule_1,
17
+ imports: [server_aws_credential_providers_1.ServerAwsCredentialProvidersModule.configure(config)],
18
+ providers: [
19
+ {
20
+ provide: client_ecs_1.ECS,
21
+ useFactory: (credentials) => ecsClient
22
+ ? ecsClient
23
+ : ecsClient = new client_ecs_1.ECS({
24
+ region: config.AWS_REGION,
25
+ logger: console,
26
+ credentials
27
+ }),
28
+ inject: [server_aws_credential_providers_1.AwsCredentials]
29
+ },
30
+ { provide: server_aws_ecs_config_class_1.ServerAwsEcsConfig, useValue: config },
31
+ ecs_service_1.EcsService
32
+ ],
33
+ });
34
+ }
35
+ };
36
+ exports.ServerAwsEcsModule = ServerAwsEcsModule;
37
+ exports.ServerAwsEcsModule = ServerAwsEcsModule = ServerAwsEcsModule_1 = tslib_1.__decorate([
38
+ (0, common_1.Module)({})
39
+ ], ServerAwsEcsModule);
40
+ //# sourceMappingURL=server-aws-ecs.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-aws-ecs.module.js","sourceRoot":"","sources":["../../../../../../libs/server/aws-ecs/src/lib/server-aws-ecs.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAwC;AACxC,0DAAuD;AACvD,oDAA0C;AAC1C,wDAAoD;AACpD,uFAA2E;AAC3E,8FAA8G;AAE9G,IAAI,SAAS,GAAe,IAAI,CAAC;AAG1B,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAC7B,MAAM,CAAC,SAAS,CAAC,MAA0B;QACzC,OAAO,IAAA,6BAAa,EAAC;YACnB,MAAM,EAAE,oBAAkB;YAC1B,OAAO,EAAE,CAAC,oEAAkC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC/D,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,gBAAG;oBACZ,UAAU,EAAE,CAAC,WAA2B,EAAE,EAAE,CAAC,SAAS;wBACpD,CAAC,CAAC,SAAS;wBACX,CAAC,CAAC,SAAS,GAAG,IAAI,gBAAG,CAAC;4BACpB,MAAM,EAAE,MAAM,CAAC,UAAU;4BACzB,MAAM,EAAE,OAAO;4BACf,WAAW;yBACZ,CAAC;oBACF,MAAM,EAAE,CAAC,gDAAc,CAAC;iBAC3B;gBACD,EAAE,OAAO,EAAE,gDAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE;gBACjD,wBAAU;aACX;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAtBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,kBAAkB,CAsB9B"}
@@ -0,0 +1,14 @@
1
+ import { ECS, KeyValuePair, RunTaskCommandInput, RunTaskCommandOutput } from '@aws-sdk/client-ecs';
2
+ export declare class EcsService {
3
+ private ecsClient;
4
+ constructor(ecsClient: ECS);
5
+ runTasks(_: {
6
+ taskDefinition: string;
7
+ subnets: string;
8
+ securityGroups: string;
9
+ taskCount: number;
10
+ cluster: string;
11
+ } & Pick<RunTaskCommandInput, 'overrides'>): Promise<Array<RunTaskCommandOutput>>;
12
+ static mapObjectToEcsEnvironmentArray(_: Record<string, any> | null | undefined): KeyValuePair[];
13
+ }
14
+ //# sourceMappingURL=ecs.service.d.ts.map
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EcsService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const client_ecs_1 = require("@aws-sdk/client-ecs");
7
+ const parse_csv_string_function_1 = require("../functions/parse-csv-string.function");
8
+ let EcsService = class EcsService {
9
+ ecsClient;
10
+ constructor(ecsClient) {
11
+ this.ecsClient = ecsClient;
12
+ }
13
+ runTasks(_) {
14
+ const { taskDefinition, subnets, securityGroups, taskCount, cluster, overrides } = _;
15
+ try {
16
+ const params = {
17
+ cluster,
18
+ taskDefinition,
19
+ launchType: 'FARGATE',
20
+ networkConfiguration: {
21
+ awsvpcConfiguration: {
22
+ assignPublicIp: 'DISABLED',
23
+ subnets: (0, parse_csv_string_function_1.parseCsvString)(subnets),
24
+ securityGroups: (0, parse_csv_string_function_1.parseCsvString)(securityGroups),
25
+ }
26
+ },
27
+ overrides
28
+ };
29
+ const taskPromises = new Array(taskCount)
30
+ .fill(undefined)
31
+ .map(() => this.ecsClient.send(new client_ecs_1.RunTaskCommand(params)));
32
+ return Promise.all(taskPromises);
33
+ }
34
+ catch (error) {
35
+ console.error('Failed to run ECS task:', error);
36
+ throw error;
37
+ }
38
+ }
39
+ static mapObjectToEcsEnvironmentArray(_) {
40
+ return Object.entries(_ || {}).reduce((__, [Name, Value]) => [...__, { Name, Value }], []);
41
+ }
42
+ };
43
+ exports.EcsService = EcsService;
44
+ exports.EcsService = EcsService = tslib_1.__decorate([
45
+ (0, common_1.Injectable)(),
46
+ tslib_1.__metadata("design:paramtypes", [client_ecs_1.ECS])
47
+ ], EcsService);
48
+ //# sourceMappingURL=ecs.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ec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