@hestia-earth/pipeline-utils 0.10.0 → 0.10.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.10.2](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.10.1...v0.10.2) (2023-06-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * add extra attributes to SNS and SQS ([e981692](https://gitlab.com/hestia-earth/hestia-pipeline-utils/commit/e98169230a9c41ac8a2ad85104275f3c8913dc0c))
11
+
12
+ ### [0.10.1](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.10.0...v0.10.1) (2023-06-08)
13
+
14
+
15
+ ### Features
16
+
17
+ * **ec2:** add `startInstances` function ([0ee1283](https://gitlab.com/hestia-earth/hestia-pipeline-utils/commit/0ee128334b9fe2a174aafd96e40e61fc83bcda26))
18
+
5
19
  ## [0.10.0](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.9.6...v0.10.0) (2023-06-08)
6
20
 
7
21
 
package/dist/ec2.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const startInstances: (functionName: string, instanceIds?: string[]) => import("rxjs").Observable<any>;
package/dist/ec2.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startInstances = void 0;
4
+ const AWS = require("aws-sdk");
5
+ const rxjs_1 = require("rxjs");
6
+ const operators_1 = require("rxjs/operators");
7
+ const log_1 = require("./log");
8
+ const s3_1 = require("./s3");
9
+ const defaultInstanceIds = (process.env.START_INSTANCE_ID || '').split(',');
10
+ const startInstances = (functionName, instanceIds = defaultInstanceIds) => s3_1.isS3Mode
11
+ ? (0, rxjs_1.from)(new AWS.EC2().startInstances({
12
+ InstanceIds: instanceIds
13
+ }).promise()).pipe((0, operators_1.take)(1), (0, operators_1.map)(res => {
14
+ (0, log_1.debug)(`EC2 start instances ${functionName}`, res);
15
+ return res;
16
+ }))
17
+ : (0, rxjs_1.of)(null);
18
+ exports.startInstances = startInstances;
19
+ //# sourceMappingURL=ec2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ec2.js","sourceRoot":"","sources":["../src/ec2.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+BAAgC;AAChC,8CAA2C;AAE3C,+BAA8B;AAC9B,6BAAgC;AAEhC,MAAM,kBAAkB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAErE,MAAM,cAAc,GAAG,CAAC,YAAoB,EAAE,WAAW,GAAG,kBAAkB,EAAE,EAAE,CAAC,aAAQ;IAChG,CAAC,CAAC,IAAA,WAAI,EACJ,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC;QAC3B,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC,OAAO,EAAE,CACb,CAAC,IAAI,CACJ,IAAA,gBAAI,EAAC,CAAC,CAAC,EACP,IAAA,eAAG,EAAC,GAAG,CAAC,EAAE;QACR,IAAA,WAAK,EAAC,uBAAuB,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;QAClD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CACH;IACD,CAAC,CAAC,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC;AAZA,QAAA,cAAc,kBAYd"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './ec2';
1
2
  export * from './lambda';
2
3
  export * from './log';
3
4
  export * from './progress';
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ec2"), exports);
17
18
  __exportStar(require("./lambda"), exports);
18
19
  __exportStar(require("./log"), exports);
19
20
  __exportStar(require("./progress"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wCAAsB;AACtB,6CAA2B;AAC3B,6CAA2B;AAC3B,uCAAqB;AACrB,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,wCAAsB;AACtB,6CAA2B;AAC3B,6CAA2B;AAC3B,uCAAqB;AACrB,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB"}
package/dist/sns.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import { IFunctionParam } from './s3';
2
- export declare const publish: (functionName: string, params: IFunctionParam, topicArn?: string) => import("rxjs").Observable<any>;
2
+ declare type attributes = {
3
+ [key: string]: string;
4
+ };
5
+ export declare const publish: (functionName: string, params: IFunctionParam, topicArn?: string, extras?: attributes) => import("rxjs").Observable<any>;
6
+ export {};
package/dist/sns.js CHANGED
@@ -6,7 +6,7 @@ const rxjs_1 = require("rxjs");
6
6
  const operators_1 = require("rxjs/operators");
7
7
  const log_1 = require("./log");
8
8
  const s3_1 = require("./s3");
9
- const publish = (functionName, params, topicArn = process.env.SNS_TOPIC) => s3_1.isS3Mode
9
+ const publish = (functionName, params, topicArn = process.env.SNS_TOPIC, extras = {}) => s3_1.isS3Mode
10
10
  ? (0, rxjs_1.from)(new AWS.SNS().publish({
11
11
  TopicArn: topicArn,
12
12
  Message: JSON.stringify(params),
@@ -14,7 +14,14 @@ const publish = (functionName, params, topicArn = process.env.SNS_TOPIC) => s3_1
14
14
  functionName: {
15
15
  DataType: 'String',
16
16
  StringValue: functionName
17
- }
17
+ },
18
+ ...(Object.fromEntries(Object.entries(extras || {}).map(([key, value]) => [
19
+ key,
20
+ {
21
+ DataType: 'String',
22
+ StringValue: value
23
+ }
24
+ ])))
18
25
  }
19
26
  }).promise()).pipe((0, operators_1.take)(1), (0, operators_1.map)(res => {
20
27
  (0, log_1.debug)(`SNS publish ${functionName}`, res);
package/dist/sns.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sns.js","sourceRoot":"","sources":["../src/sns.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+BAAgC;AAChC,8CAA2C;AAE3C,+BAA8B;AAC9B,6BAAgD;AAEzC,MAAM,OAAO,GAAG,CAAC,YAAoB,EAAE,MAAsB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,aAAQ;IACjH,CAAC,CAAC,IAAA,WAAI,EACJ,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;QACpB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC/B,iBAAiB,EAAE;YACjB,YAAY,EAAE;gBACZ,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,YAAY;aAC1B;SACF;KACF,CAAC,CAAC,OAAO,EAAE,CACb,CAAC,IAAI,CACJ,IAAA,gBAAI,EAAC,CAAC,CAAC,EACP,IAAA,eAAG,EAAC,GAAG,CAAC,EAAE;QACR,IAAA,WAAK,EAAC,eAAe,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;QAC1C,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CACH;IACD,CAAC,CAAC,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC;AAnBA,QAAA,OAAO,WAmBP"}
1
+ {"version":3,"file":"sns.js","sourceRoot":"","sources":["../src/sns.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+BAAgC;AAChC,8CAA2C;AAE3C,+BAA8B;AAC9B,6BAAgD;AAMzC,MAAM,OAAO,GAAG,CACrB,YAAoB,EAAE,MAAsB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,SAAqB,EAAE,EACvG,EAAE,CAAC,aAAQ;IACX,CAAC,CAAC,IAAA,WAAI,EACJ,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;QACpB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC/B,iBAAiB,EAAE;YACjB,YAAY,EAAE;gBACZ,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,YAAY;aAC1B;YACD,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;gBACxE,GAAG;gBACH;oBACE,QAAQ,EAAE,QAAQ;oBAClB,WAAW,EAAE,KAAK;iBACnB;aACF,CAAC,CAAC,CAAC;SACL;KACF,CAAC,CAAC,OAAO,EAAE,CACb,CAAC,IAAI,CACJ,IAAA,gBAAI,EAAC,CAAC,CAAC,EACP,IAAA,eAAG,EAAC,GAAG,CAAC,EAAE;QACR,IAAA,WAAK,EAAC,eAAe,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;QAC1C,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CACH;IACD,CAAC,CAAC,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC;AA5BA,QAAA,OAAO,WA4BP"}
package/dist/sqs.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import { IFunctionParam } from './s3';
2
- export declare const sendMessage: (functionName: string, params: IFunctionParam, queueUrl?: string) => import("rxjs").Observable<any>;
2
+ declare type attributes = {
3
+ [key: string]: string;
4
+ };
5
+ export declare const sendMessage: (functionName: string, params: IFunctionParam, queueUrl?: string, extras?: attributes) => import("rxjs").Observable<any>;
6
+ export {};
package/dist/sqs.js CHANGED
@@ -6,7 +6,7 @@ const rxjs_1 = require("rxjs");
6
6
  const operators_1 = require("rxjs/operators");
7
7
  const log_1 = require("./log");
8
8
  const s3_1 = require("./s3");
9
- const sendMessage = (functionName, params, queueUrl = process.env.SQS_URL) => s3_1.isS3Mode
9
+ const sendMessage = (functionName, params, queueUrl = process.env.SQS_URL, extras = {}) => s3_1.isS3Mode
10
10
  ? (0, rxjs_1.from)(new AWS.SQS({ region: s3_1.region }).sendMessage({
11
11
  QueueUrl: queueUrl,
12
12
  MessageBody: JSON.stringify(params),
@@ -14,7 +14,14 @@ const sendMessage = (functionName, params, queueUrl = process.env.SQS_URL) => s3
14
14
  functionName: {
15
15
  DataType: 'String',
16
16
  StringValue: functionName
17
- }
17
+ },
18
+ ...(Object.fromEntries(Object.entries(extras || {}).map(([key, value]) => [
19
+ key,
20
+ {
21
+ DataType: 'String',
22
+ StringValue: value
23
+ }
24
+ ])))
18
25
  }
19
26
  }).promise()).pipe((0, operators_1.take)(1), (0, operators_1.map)(res => {
20
27
  (0, log_1.debug)(`SQS send message ${functionName}`, res);
package/dist/sqs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sqs.js","sourceRoot":"","sources":["../src/sqs.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+BAAgC;AAChC,8CAA2C;AAE3C,+BAA8B;AAC9B,6BAAwD;AAEjD,MAAM,WAAW,GAAG,CAAC,YAAoB,EAAE,MAAsB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,aAAQ;IACnH,CAAC,CAAC,IAAA,WAAI,EACJ,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAN,WAAM,EAAE,CAAC,CAAC,WAAW,CAAC;QAClC,QAAQ,EAAE,QAAQ;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E,GAAG;gBACH;oBACE,QAAQ,EAAE,QAAQ;oBAClB,WAAW,EAAE,KAAK;iBACnB;aACF,CAAC,CAAC,CAAC;SACL;KACF,CAAC,CAAC,OAAO,EAAE,CACb,CAAC,IAAI,CACJ,IAAA,gBAAI,EAAC,CAAC,CAAC,EACP,IAAA,eAAG,EAAC,GAAG,CAAC,EAAE;QACR,IAAA,WAAK,EAAC,oBAAoB,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CACH;IACD,CAAC,CAAC,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC;AA5BA,QAAA,WAAW,eA4BX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/pipeline-utils",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Utilities for running pipelines",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/ec2.ts ADDED
@@ -0,0 +1,22 @@
1
+ import * as AWS from 'aws-sdk';
2
+ import { from, of } from 'rxjs';
3
+ import { take, map } from 'rxjs/operators';
4
+
5
+ import { debug } from './log';
6
+ import { isS3Mode } from './s3';
7
+
8
+ const defaultInstanceIds = (process.env.START_INSTANCE_ID || '').split(',');
9
+
10
+ export const startInstances = (functionName: string, instanceIds = defaultInstanceIds) => isS3Mode
11
+ ? from(
12
+ new AWS.EC2().startInstances({
13
+ InstanceIds: instanceIds
14
+ }).promise()
15
+ ).pipe(
16
+ take(1),
17
+ map(res => {
18
+ debug(`EC2 start instances ${functionName}`, res);
19
+ return res;
20
+ })
21
+ )
22
+ : of(null);
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './ec2';
1
2
  export * from './lambda';
2
3
  export * from './log';
3
4
  export * from './progress';
package/src/sns.ts CHANGED
@@ -5,7 +5,13 @@ import { take, map } from 'rxjs/operators';
5
5
  import { debug } from './log';
6
6
  import { IFunctionParam, isS3Mode } from './s3';
7
7
 
8
- export const publish = (functionName: string, params: IFunctionParam, topicArn = process.env.SNS_TOPIC) => isS3Mode
8
+ type attributes = {
9
+ [key: string]: string;
10
+ };
11
+
12
+ export const publish = (
13
+ functionName: string, params: IFunctionParam, topicArn = process.env.SNS_TOPIC, extras: attributes = {}
14
+ ) => isS3Mode
9
15
  ? from(
10
16
  new AWS.SNS().publish({
11
17
  TopicArn: topicArn,
@@ -14,7 +20,14 @@ export const publish = (functionName: string, params: IFunctionParam, topicArn =
14
20
  functionName: {
15
21
  DataType: 'String',
16
22
  StringValue: functionName
17
- }
23
+ },
24
+ ...(Object.fromEntries(Object.entries(extras || {}).map(([key, value]) => [
25
+ key,
26
+ {
27
+ DataType: 'String',
28
+ StringValue: value
29
+ }
30
+ ])))
18
31
  }
19
32
  }).promise()
20
33
  ).pipe(
package/src/sqs.ts CHANGED
@@ -5,7 +5,13 @@ import { take, map } from 'rxjs/operators';
5
5
  import { debug } from './log';
6
6
  import { IFunctionParam, isS3Mode, region } from './s3';
7
7
 
8
- export const sendMessage = (functionName: string, params: IFunctionParam, queueUrl = process.env.SQS_URL) => isS3Mode
8
+ type attributes = {
9
+ [key: string]: string;
10
+ };
11
+
12
+ export const sendMessage = (
13
+ functionName: string, params: IFunctionParam, queueUrl = process.env.SQS_URL, extras: attributes = {}
14
+ ) => isS3Mode
9
15
  ? from(
10
16
  new AWS.SQS({ region }).sendMessage({
11
17
  QueueUrl: queueUrl,
@@ -14,7 +20,14 @@ export const sendMessage = (functionName: string, params: IFunctionParam, queueU
14
20
  functionName: {
15
21
  DataType: 'String',
16
22
  StringValue: functionName
17
- }
23
+ },
24
+ ...(Object.fromEntries(Object.entries(extras || {}).map(([key, value]) => [
25
+ key,
26
+ {
27
+ DataType: 'String',
28
+ StringValue: value
29
+ }
30
+ ])))
18
31
  }
19
32
  }).promise()
20
33
  ).pipe(