@hestia-earth/pipeline-utils 0.8.2 → 0.9.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/CHANGELOG.md +11 -0
- package/dist/progress.d.ts +3 -2
- package/dist/progress.js +6 -3
- package/dist/progress.js.map +1 -1
- package/package.json +3 -1
- package/src/progress.ts +34 -15
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.9.0](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.8.2...v0.9.0) (2023-04-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* **progress:** `@hestia-earth/api` required above version `0.18.0`
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **progress:** log time for each step ([51bf21b](https://gitlab.com/hestia-earth/hestia-pipeline-utils/commit/51bf21be9cd1cfa2124ff480da9c31a228632e60))
|
|
15
|
+
|
|
5
16
|
### [0.8.2](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.8.1...v0.8.2) (2023-04-06)
|
|
6
17
|
|
|
7
18
|
|
package/dist/progress.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FileProgress } from '@hestia-earth/api';
|
|
1
2
|
import { IFunctionParam } from './s3';
|
|
2
3
|
export declare enum publishFunctionSuffix {
|
|
3
4
|
Success = "Done",
|
|
@@ -15,6 +16,6 @@ export declare class HestiaError extends Error {
|
|
|
15
16
|
stack: string;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
export declare const handleError: (step:
|
|
19
|
-
export declare const handleSuccess: (step:
|
|
19
|
+
export declare const handleError: (step: FileProgress, params: IFunctionParam, time?: number, Bucket?: string) => (err: HestiaError) => import("rxjs").Observable<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/sns").PublishResponse, import("aws-sdk").AWSError>>;
|
|
20
|
+
export declare const handleSuccess: (step: FileProgress, params: IFunctionParam, time?: number, Bucket?: string) => (details?: any) => import("rxjs").Observable<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/sns").PublishResponse, import("aws-sdk").AWSError>>;
|
|
20
21
|
export declare const defaultErrorHandler: (key: string) => (err: Error) => import("rxjs").Observable<never>;
|
package/dist/progress.js
CHANGED
|
@@ -29,13 +29,16 @@ class HestiaError extends Error {
|
|
|
29
29
|
}
|
|
30
30
|
exports.HestiaError = HestiaError;
|
|
31
31
|
const fileToProgress = (path) => `${path.split('.')[0]}.progress`;
|
|
32
|
-
const uploadProgress = (step, path, Bucket, time, err, details) => (0, s3_1.uploadJSON)(fileToProgress(path), {
|
|
32
|
+
const uploadProgress = (step, path, Bucket, time, err, details) => (0, rxjs_1.of)(fileToProgress(path)).pipe((0, operators_1.mergeMap)(filepath => (0, s3_1.loadJSONFile)(filepath, Bucket).pipe((0, operators_1.catchError)(() => (0, rxjs_1.of)({})), (0, operators_1.mergeMap)(data => (0, s3_1.uploadJSON)(fileToProgress(path), {
|
|
33
33
|
step,
|
|
34
34
|
success: !err,
|
|
35
|
-
time
|
|
35
|
+
time: {
|
|
36
|
+
...(data.time || {}),
|
|
37
|
+
step: time
|
|
38
|
+
},
|
|
36
39
|
details,
|
|
37
40
|
error: err ? err.toString() : null
|
|
38
|
-
}, 'application/json', Bucket);
|
|
41
|
+
}, 'application/json', Bucket)))));
|
|
39
42
|
const handleError = (step, params, time = 0, Bucket = s3_1.bucket) => (err) => uploadProgress(step, params.key, Bucket, time, err).pipe((0, operators_1.mergeMap)(() => (0, sns_1.publish)(`${step}${publishFunctionSuffix.Error}`, params)));
|
|
40
43
|
exports.handleError = handleError;
|
|
41
44
|
const handleSuccess = (step, params, time = 0, Bucket = s3_1.bucket) => (details) => uploadProgress(step, params.key, Bucket, time, null, details).pipe((0, operators_1.mergeMap)(() => (0, sns_1.publish)(`${step}${publishFunctionSuffix.Success}`, params)));
|
package/dist/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":";;;AAAA,8CAAsD;AACtD,+BAAsC;AAGtC,6BAAwE;AACxE,+BAAgC;AAYhC,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,yCAAgB,CAAA;IAChB,wCAAe,CAAA;AACjB,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC;AAEM,MAAM,SAAS,GAAG,CAAC,KAAW,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;AAApE,QAAA,SAAS,aAA2D;AAEjF,MAAa,WAAY,SAAQ,KAAK;IAOpC,YAAmB,OAAO,EAAS,GAAW,EAAS,SAAc,EAAE;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAA;QAAS,QAAG,GAAH,GAAG,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAU;IAEvE,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF;AAlBD,kCAkBC;AAED,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AAE1E,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,MAAc,EAAE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AAE,CACrG,CAAC,OAAa,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CACnF,IAAA,oBAAQ,EAAC,GAAG,EAAE,CAAC,IAAA,aAAO,EAAC,GAAG,IAAI,GAAG,qBAAqB,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC,CAC3E,CAAC;AAHS,QAAA,aAAa,iBAGtB;AAEG,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,GAAU,EAAE,EAAE,CACjE,IAAA,iBAAU,EAAC,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAD9C,QAAA,mBAAmB,uBAC2B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hestia-earth/pipeline-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Utilities for running pipelines",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -38,12 +38,14 @@
|
|
|
38
38
|
"rxjs": "^6.6.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
+
"@hestia-earth/api": ">=0.18.0",
|
|
41
42
|
"@hestia-earth/json-schema": ">=15.0.0",
|
|
42
43
|
"@hestia-earth/schema": ">=15.0.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@commitlint/cli": "^17.4.2",
|
|
46
47
|
"@commitlint/config-conventional": "^17.4.2",
|
|
48
|
+
"@hestia-earth/api": "^0.18.0",
|
|
47
49
|
"@hestia-earth/eslint-config": "^0.0.5",
|
|
48
50
|
"@hestia-earth/json-schema": "^15.0.0",
|
|
49
51
|
"@hestia-earth/schema": "^15.0.0",
|
package/src/progress.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { mergeMap } from 'rxjs/operators';
|
|
2
|
-
import { throwError } from 'rxjs';
|
|
1
|
+
import { catchError, mergeMap } from 'rxjs/operators';
|
|
2
|
+
import { of, throwError } from 'rxjs';
|
|
3
|
+
import { FileProgress } from '@hestia-earth/api';
|
|
3
4
|
|
|
4
|
-
import { IFunctionParam, uploadJSON, bucket } from './s3';
|
|
5
|
+
import { IFunctionParam, uploadJSON, bucket, loadJSONFile } from './s3';
|
|
5
6
|
import { publish } from './sns';
|
|
6
7
|
|
|
8
|
+
interface IFileProgress {
|
|
9
|
+
step: FileProgress;
|
|
10
|
+
success: boolean;
|
|
11
|
+
time: {
|
|
12
|
+
[step in FileProgress]?: number;
|
|
13
|
+
};
|
|
14
|
+
details?: any;
|
|
15
|
+
error?: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export enum publishFunctionSuffix {
|
|
8
19
|
Success = 'Done',
|
|
9
20
|
Error = 'Error'
|
|
@@ -34,21 +45,29 @@ export class HestiaError extends Error {
|
|
|
34
45
|
const fileToProgress = (path: string) => `${path.split('.')[0]}.progress`;
|
|
35
46
|
|
|
36
47
|
const uploadProgress = (step: string, path: string, Bucket: string, time: number, err?: HestiaError, details?: any) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
of(fileToProgress(path)).pipe(
|
|
49
|
+
mergeMap(filepath => loadJSONFile<Partial<IFileProgress>>(filepath, Bucket).pipe(
|
|
50
|
+
catchError(() => of({} as Partial<IFileProgress>)),
|
|
51
|
+
mergeMap(data => uploadJSON(fileToProgress(path), {
|
|
52
|
+
step,
|
|
53
|
+
success: !err,
|
|
54
|
+
time: {
|
|
55
|
+
...(data.time || {}),
|
|
56
|
+
step: time
|
|
57
|
+
},
|
|
58
|
+
details,
|
|
59
|
+
error: err ? err.toString() : null
|
|
60
|
+
}, 'application/json', Bucket))
|
|
61
|
+
))
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
export const handleError = (step: FileProgress, params: IFunctionParam, time = 0, Bucket = bucket) =>
|
|
65
|
+
(err: HestiaError) => uploadProgress(step, params.key, Bucket, time, err).pipe(
|
|
47
66
|
mergeMap(() => publish(`${step}${publishFunctionSuffix.Error}`, params))
|
|
48
67
|
);
|
|
49
68
|
|
|
50
|
-
export const handleSuccess = (step:
|
|
51
|
-
uploadProgress(step, params.key, Bucket, time, null, details).pipe(
|
|
69
|
+
export const handleSuccess = (step: FileProgress, params: IFunctionParam, time = 0, Bucket = bucket) =>
|
|
70
|
+
(details?: any) => uploadProgress(step, params.key, Bucket, time, null, details).pipe(
|
|
52
71
|
mergeMap(() => publish(`${step}${publishFunctionSuffix.Success}`, params))
|
|
53
72
|
);
|
|
54
73
|
|