@jettacargo/activity-handler 1.0.0-alpha.16 → 1.0.0-alpha.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/package.json CHANGED
@@ -1,27 +1,17 @@
1
1
  {
2
2
  "name": "@jettacargo/activity-handler",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
- "types": "build/index.d.ts",
7
- "files": [
8
- "build"
9
- ],
10
- "type": "module",
11
6
  "scripts": {
12
- "build": "rm -rf dist/* && tsc",
13
7
  "test": "tsx ./node_modules/mocha/bin/mocha \"test/**/*.ts\"",
14
8
  "lint": "eslint src --ext .ts",
15
- "lint:fix": "eslint src/**/*.{js,ts} --fix",
9
+ "lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
16
10
  "audit": "npm audit --omit=dev",
17
- "preversion": "git fetch --prune --tags",
18
- "version": "npm run build",
19
- "postversion": "git push origin HEAD --follow-tags && rm -rf dist/",
20
- "publish:alpha": "npm version --tag-version-prefix=alpha-v",
21
- "publish:stable": "npm version",
22
- "prerelease:alpha": "npm version prerelease --tag-version-prefix=alpha-v",
11
+ "publish": "rm -rf ./build && ./scripts/publish.sh",
23
12
  "coverage": "c8 --reporter=html --reporter=text node --loader=./node_modules/ts-node/esm.mjs --experimental-specifier-resolution=node ./node_modules/mocha/bin/mocha.js 'test/**/test_*.ts'"
24
13
  },
14
+ "type": "module",
25
15
  "repository": {
26
16
  "type": "git",
27
17
  "url": "git+ssh://git@bitbucket.org/jettasoft_dev/activity-handler.git"
@@ -38,10 +28,9 @@
38
28
  },
39
29
  "homepage": "https://bitbucket.org/jettasoft_dev/activity-handler#readme",
40
30
  "dependencies": {
41
- "@jettacargo/load-models": "^0.4.3-alpha.22",
31
+ "@jettacargo/load-models": "^0.4.0-alpha.4",
42
32
  "@jettacargo/s3": "0.0.4",
43
- "@temporalio/worker": "1.13.2",
44
- "@temporalio/workflow": "^1.13.2"
33
+ "@temporalio/worker": "1.13.2"
45
34
  },
46
35
  "devDependencies": {
47
36
  "@types/chai": "5.2.2",
@@ -1,2 +0,0 @@
1
- declare const DEFAULT_BUCKET = "tmp-daily";
2
- export { DEFAULT_BUCKET };
@@ -1,3 +0,0 @@
1
- const DEFAULT_BUCKET = 'tmp-daily';
2
- export { DEFAULT_BUCKET };
3
- //# sourceMappingURL=Constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/constants/Constants.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,WAAW,CAAA;AAElC,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,3 +0,0 @@
1
- export declare class FatalError extends Error {
2
- constructor(message: string);
3
- }
@@ -1,7 +0,0 @@
1
- export class FatalError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'FatalError';
5
- }
6
- }
7
- //# sourceMappingURL=Fatal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Fatal.js","sourceRoot":"","sources":["../../src/error/Fatal.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAEjC,YAAY,OAAe;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;IAC5B,CAAC;CACJ"}
@@ -1 +0,0 @@
1
- export declare function handle_workflow_error_signal(err: Error): void;
@@ -1,19 +0,0 @@
1
- import { ApplicationFailure } from '@temporalio/workflow';
2
- import { FatalError } from './Fatal.js';
3
- import { TemporaryError } from './Temporary.js';
4
- function check_non_retryable(err, target_type, label) {
5
- if (err instanceof target_type) {
6
- throw ApplicationFailure.nonRetryable(err.message, label, undefined, err);
7
- }
8
- }
9
- function check_retryable(err, target_type, label) {
10
- if (err instanceof target_type) {
11
- throw ApplicationFailure.retryable(err.message, label, undefined, err);
12
- }
13
- }
14
- export function handle_workflow_error_signal(err) {
15
- check_non_retryable(err, FatalError, 'FatalError');
16
- check_retryable(err, TemporaryError, 'TemporaryError');
17
- check_non_retryable(err, Error, 'UnkownError');
18
- }
19
- //# sourceMappingURL=HandleWorkflowErrorSignal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HandleWorkflowErrorSignal.js","sourceRoot":"","sources":["../../src/error/HandleWorkflowErrorSignal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,SAAS,mBAAmB,CAAC,GAAO,EAAE,WAAe,EAAE,KAAY;IAE/D,IAAI,GAAG,YAAY,WAAW,EAC9B,CAAC;QACG,MAAM,kBAAkB,CAAC,YAAY,CACjC,GAAG,CAAC,OAAO,EACX,KAAK,EACL,SAAS,EACT,GAAG,CACN,CAAA;IACL,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAC,GAAO,EAAE,WAAe,EAAE,KAAY;IAE3D,IAAI,GAAG,YAAY,WAAW,EAC9B,CAAC;QACG,MAAM,kBAAkB,CAAC,SAAS,CAC9B,GAAG,CAAC,OAAO,EACX,KAAK,EACL,SAAS,EACT,GAAG,CACN,CAAA;IACL,CAAC;AACL,CAAC;AACD,MAAM,UAAU,4BAA4B,CAAC,GAAW;IAEpD,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,CAAA;IAClD,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAA;IACtD,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,aAAa,CAAC,CAAA;AAClD,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare class TemporaryError extends Error {
2
- constructor(message: string);
3
- }
@@ -1,7 +0,0 @@
1
- export class TemporaryError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = 'TemporaryError';
5
- }
6
- }
7
- //# sourceMappingURL=Temporary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Temporary.js","sourceRoot":"","sources":["../../src/error/Temporary.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAErC,YAAY,OAAe;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAChC,CAAC;CACJ"}
@@ -1,4 +0,0 @@
1
- import { FatalError } from '../error/Fatal.js';
2
- export default class ErrorTypeMismatch extends FatalError {
3
- constructor();
4
- }
@@ -1,7 +0,0 @@
1
- import { FatalError } from '../error/Fatal.js';
2
- export default class ErrorTypeMismatch extends FatalError {
3
- constructor() {
4
- super('Only supports Error type for exception.');
5
- }
6
- }
7
- //# sourceMappingURL=ErrorTypeMismatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorTypeMismatch.js","sourceRoot":"","sources":["../../src/exceptions/ErrorTypeMismatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU;IAErD;QAEI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IACpD,CAAC;CACJ"}
@@ -1,4 +0,0 @@
1
- import { FatalError } from '../error/Fatal.js';
2
- export default class FailedRetrievingFileFromS3Exception extends FatalError {
3
- constructor(message: string);
4
- }
@@ -1,7 +0,0 @@
1
- import { FatalError } from '../error/Fatal.js';
2
- export default class FailedRetrievingFileFromS3Exception extends FatalError {
3
- constructor(message) {
4
- super(message);
5
- }
6
- }
7
- //# sourceMappingURL=FailedRetrievingFileFromS3Exception.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FailedRetrievingFileFromS3Exception.js","sourceRoot":"","sources":["../../src/exceptions/FailedRetrievingFileFromS3Exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,MAAM,CAAC,OAAO,OAAO,mCAAoC,SAAQ,UAAU;IAEvE,YAAY,OAAe;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;CACJ"}
@@ -1,2 +0,0 @@
1
- import { ActivityCallback, EventMetadata } from '@jettacargo/load-models';
2
- export default function handle_activity(event_metadata: EventMetadata, source: string, callback: ActivityCallback): Promise<EventMetadata>;
@@ -1,40 +0,0 @@
1
- import { EventStatus } from '@jettacargo/load-models';
2
- import read_input from './InputReader.js';
3
- import write_output from './OutputWriter.js';
4
- import ErrorTypeMismatch from '../exceptions/ErrorTypeMismatch.js';
5
- import { handle_workflow_error_signal } from '../error/HandleWorkflowErrorSignal.js';
6
- export default async function handle_activity(event_metadata, source, callback) {
7
- try {
8
- const input_data = await read_input(event_metadata.data);
9
- const output = await callback(input_data);
10
- const uri = await write_output(output.data);
11
- return build_workflow_response(output.status, uri, source);
12
- }
13
- catch (err) {
14
- if (err instanceof Error) {
15
- return await handle_error(err, source);
16
- }
17
- throw new ErrorTypeMismatch();
18
- }
19
- }
20
- async function handle_error(err, source) {
21
- handle_workflow_error_signal(err);
22
- const error_data = {
23
- message: err.message,
24
- stack: err.stack
25
- };
26
- const output = {
27
- status: EventStatus.FAILURE,
28
- data: JSON.stringify(error_data)
29
- };
30
- const uri = await write_output(output);
31
- return build_workflow_response(EventStatus.FAILURE, uri, source);
32
- }
33
- function build_workflow_response(status, uri, source) {
34
- return {
35
- type: status,
36
- data: uri,
37
- source: source
38
- };
39
- }
40
- //# sourceMappingURL=ActivityHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ActivityHandler.js","sourceRoot":"","sources":["../../src/handler/ActivityHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,WAAW,EAEd,MAAM,yBAAyB,CAAA;AAChC,OAAO,UAAU,MAAM,kBAAkB,CAAA;AACzC,OAAO,YAAY,MAAM,mBAAmB,CAAA;AAC5C,OAAO,iBAAiB,MAAM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AAE,MAAM;QACZ,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,MAAM;KACjB,CAAA;AACL,CAAC"}
@@ -1,2 +0,0 @@
1
- import { CommonInput } from '@jettacargo/load-models';
2
- export default function read_input(uri: string | undefined): Promise<CommonInput>;
@@ -1,32 +0,0 @@
1
- import { Object_Store_Driver } from '@jettacargo/s3';
2
- import FailedRetrievingFileFromS3Exception from '../exceptions/FailedRetrievingFileFromS3Exception.js';
3
- function split_uri(uri) {
4
- const splitted = uri.match(/^s3:\/\/([^\/]+)\/(.+)$/);
5
- if (!splitted || splitted.length < 3) {
6
- throw new FailedRetrievingFileFromS3Exception('S3 URI invalid.');
7
- }
8
- const bucket = splitted[1];
9
- const key = splitted[2];
10
- return { bucket, key };
11
- }
12
- export default async function read_input(uri) {
13
- if (uri === undefined) {
14
- const message = `Failed retrieving data from s3 at address: ${uri}`;
15
- throw new FailedRetrievingFileFromS3Exception(message);
16
- }
17
- const { bucket, key } = split_uri(uri);
18
- const raw_input = await Object_Store_Driver.get_object(bucket, key);
19
- if (raw_input === undefined) {
20
- const message = `Failed whe retrieving data from s3: undefined uri.`;
21
- throw new FailedRetrievingFileFromS3Exception(message);
22
- }
23
- try {
24
- const input_data = JSON.parse(raw_input);
25
- return input_data;
26
- }
27
- catch {
28
- const message = `JSON retrieved from s3 is in invalid format.`;
29
- throw new FailedRetrievingFileFromS3Exception(message);
30
- }
31
- }
32
- //# sourceMappingURL=InputReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputReader.js","sourceRoot":"","sources":["../../src/handler/InputReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,mCAAmC,MAAM,sDAAsD,CAAA;AAGtG,SAAS,SAAS,CAAC,GAAY;IAE3B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;IACrD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EACpC,CAAC;QACG,MAAM,IAAI,mCAAmC,CAAC,iBAAiB,CAAC,CAAA;IACpE,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC1B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACvB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;AAC1B,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,UAAU,CAAC,GAAuB;IAE5D,IAAI,GAAG,KAAK,SAAS,EACrB,CAAC;QACG,MAAM,OAAO,GAAG,8CAA8C,GAAG,EAAE,CAAA;QACnE,MAAM,IAAI,mCAAmC,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IACtC,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAEnE,IAAI,SAAS,KAAK,SAAS,EAC3B,CAAC;QACG,MAAM,OAAO,GAAG,oDAAoD,CAAA;QACpE,MAAM,IAAI,mCAAmC,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;IAED,IACA,CAAC;QACG,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAgB,CAAA;QACvD,OAAO,UAAU,CAAA;IACrB,CAAC;IACD,MACA,CAAC;QACG,MAAM,OAAO,GAAG,8CAA8C,CAAA;QAC9D,MAAM,IAAI,mCAAmC,CAAC,OAAO,CAAC,CAAA;IAC1D,CAAC;AACL,CAAC"}
@@ -1,2 +0,0 @@
1
- import { CommonOutput } from '@jettacargo/load-models';
2
- export default function write_output(output: CommonOutput): Promise<string>;
@@ -1,10 +0,0 @@
1
- import { Object_Store_Driver } from '@jettacargo/s3';
2
- import { randomUUID } from 'crypto';
3
- import { DEFAULT_BUCKET } from '../constants/Constants.js';
4
- export default async function write_output(output) {
5
- const payload = JSON.stringify(output);
6
- const key = `${randomUUID()}.json`;
7
- await Object_Store_Driver.put_object(DEFAULT_BUCKET, key, payload);
8
- return `s3://${DEFAULT_BUCKET}/${key}`;
9
- }
10
- //# sourceMappingURL=OutputWriter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OutputWriter.js","sourceRoot":"","sources":["../../src/handler/OutputWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,MAAoB;IAE3D,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACtC,MAAM,GAAG,GAAO,GAAG,UAAU,EAAE,OAAO,CAAA;IACtC,MAAM,mBAAmB,CAAC,UAAU,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;IAClE,OAAO,QAAQ,cAAc,IAAI,GAAG,EAAE,CAAA;AAC1C,CAAC"}
package/build/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { default as handle_activity } from './handler/ActivityHandler.js';
2
- export { FatalError } from './error/Fatal.js';
3
- export { TemporaryError } from './error/Temporary.js';
4
- export { handle_workflow_error_signal } from './error/HandleWorkflowErrorSignal.js';
package/build/index.js DELETED
@@ -1,5 +0,0 @@
1
- export { default as handle_activity } from './handler/ActivityHandler.js';
2
- export { FatalError } from './error/Fatal.js';
3
- export { TemporaryError } from './error/Temporary.js';
4
- export { handle_workflow_error_signal } from './error/HandleWorkflowErrorSignal.js';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA"}