@hestia-earth/pipeline-utils 0.9.0 → 0.9.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.
- package/CHANGELOG.md +12 -0
- package/dist/progress.d.ts +2 -2
- package/dist/progress.js +4 -4
- package/dist/progress.js.map +1 -1
- package/package.json +2 -1
- package/src/progress.ts +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
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.1](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.9.0...v0.9.1) (2023-04-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **progress:** log time since datetime ([1dc6664](https://gitlab.com/hestia-earth/hestia-pipeline-utils/commit/1dc66648da05cbb4049b5c6cf46796c206e18870))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **progress:** fix wrong step name ([2f17942](https://gitlab.com/hestia-earth/hestia-pipeline-utils/commit/2f179425fd682f8850f01e0683d24b7a9737848a))
|
|
16
|
+
|
|
5
17
|
## [0.9.0](https://gitlab.com/hestia-earth/hestia-pipeline-utils/compare/v0.8.2...v0.9.0) (2023-04-18)
|
|
6
18
|
|
|
7
19
|
|
package/dist/progress.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export declare class HestiaError extends Error {
|
|
|
16
16
|
stack: string;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export declare const handleError: (step: FileProgress, params: IFunctionParam,
|
|
20
|
-
export declare const handleSuccess: (step: FileProgress, params: IFunctionParam,
|
|
19
|
+
export declare const handleError: (step: FileProgress, params: IFunctionParam, since?: Date, 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, since?: Date, Bucket?: string) => (details?: any) => import("rxjs").Observable<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/sns").PublishResponse, import("aws-sdk").AWSError>>;
|
|
21
21
|
export declare const defaultErrorHandler: (key: string) => (err: Error) => import("rxjs").Observable<never>;
|
package/dist/progress.js
CHANGED
|
@@ -29,19 +29,19 @@ 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,
|
|
32
|
+
const uploadProgress = (step, path, Bucket, since, 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)(filepath, {
|
|
33
33
|
step,
|
|
34
34
|
success: !err,
|
|
35
35
|
time: {
|
|
36
36
|
...(data.time || {}),
|
|
37
|
-
step:
|
|
37
|
+
...(since ? { [step]: (0, exports.timeSpent)(since) } : {})
|
|
38
38
|
},
|
|
39
39
|
details,
|
|
40
40
|
error: err ? err.toString() : null
|
|
41
41
|
}, 'application/json', Bucket)))));
|
|
42
|
-
const handleError = (step, params,
|
|
42
|
+
const handleError = (step, params, since, Bucket = s3_1.bucket) => (err) => uploadProgress(step, params.key, Bucket, since, err).pipe((0, operators_1.mergeMap)(() => (0, sns_1.publish)(`${step}${publishFunctionSuffix.Error}`, params)));
|
|
43
43
|
exports.handleError = handleError;
|
|
44
|
-
const handleSuccess = (step, params,
|
|
44
|
+
const handleSuccess = (step, params, since, Bucket = s3_1.bucket) => (details) => uploadProgress(step, params.key, Bucket, since, null, details).pipe((0, operators_1.mergeMap)(() => (0, sns_1.publish)(`${step}${publishFunctionSuffix.Success}`, params)));
|
|
45
45
|
exports.handleSuccess = handleSuccess;
|
|
46
46
|
const defaultErrorHandler = (key) => (err) => (0, rxjs_1.throwError)(new HestiaError(err.message, key, err.stack));
|
|
47
47
|
exports.defaultErrorHandler = defaultErrorHandler;
|
package/dist/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,E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AAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CACpF,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.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Utilities for running pipelines",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@hestia-earth/eslint-config": "^0.0.5",
|
|
50
50
|
"@hestia-earth/json-schema": "^15.0.0",
|
|
51
51
|
"@hestia-earth/schema": "^15.0.0",
|
|
52
|
+
"@hestia-earth/utils": "^0.11.0",
|
|
52
53
|
"@types/aws-lambda": "^8.10.109",
|
|
53
54
|
"@types/aws-sdk": "^2.7.0",
|
|
54
55
|
"@types/chai": "^4.3.4",
|
package/src/progress.ts
CHANGED
|
@@ -44,16 +44,16 @@ export class HestiaError extends Error {
|
|
|
44
44
|
|
|
45
45
|
const fileToProgress = (path: string) => `${path.split('.')[0]}.progress`;
|
|
46
46
|
|
|
47
|
-
const uploadProgress = (step: string, path: string, Bucket: string,
|
|
47
|
+
const uploadProgress = (step: string, path: string, Bucket: string, since?: Date, err?: HestiaError, details?: any) =>
|
|
48
48
|
of(fileToProgress(path)).pipe(
|
|
49
49
|
mergeMap(filepath => loadJSONFile<Partial<IFileProgress>>(filepath, Bucket).pipe(
|
|
50
50
|
catchError(() => of({} as Partial<IFileProgress>)),
|
|
51
|
-
mergeMap(data => uploadJSON(
|
|
51
|
+
mergeMap(data => uploadJSON(filepath, {
|
|
52
52
|
step,
|
|
53
53
|
success: !err,
|
|
54
54
|
time: {
|
|
55
55
|
...(data.time || {}),
|
|
56
|
-
step:
|
|
56
|
+
...(since ? { [step]: timeSpent(since) } : {})
|
|
57
57
|
},
|
|
58
58
|
details,
|
|
59
59
|
error: err ? err.toString() : null
|
|
@@ -61,13 +61,13 @@ const uploadProgress = (step: string, path: string, Bucket: string, time: number
|
|
|
61
61
|
))
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
export const handleError = (step: FileProgress, params: IFunctionParam,
|
|
65
|
-
(err: HestiaError) => uploadProgress(step, params.key, Bucket,
|
|
64
|
+
export const handleError = (step: FileProgress, params: IFunctionParam, since?: Date, Bucket = bucket) =>
|
|
65
|
+
(err: HestiaError) => uploadProgress(step, params.key, Bucket, since, err).pipe(
|
|
66
66
|
mergeMap(() => publish(`${step}${publishFunctionSuffix.Error}`, params))
|
|
67
67
|
);
|
|
68
68
|
|
|
69
|
-
export const handleSuccess = (step: FileProgress, params: IFunctionParam,
|
|
70
|
-
(details?: any) => uploadProgress(step, params.key, Bucket,
|
|
69
|
+
export const handleSuccess = (step: FileProgress, params: IFunctionParam, since?: Date, Bucket = bucket) =>
|
|
70
|
+
(details?: any) => uploadProgress(step, params.key, Bucket, since, null, details).pipe(
|
|
71
71
|
mergeMap(() => publish(`${step}${publishFunctionSuffix.Success}`, params))
|
|
72
72
|
);
|
|
73
73
|
|