@forge/events 0.0.0-experimental-d18f8dd → 0.0.0-experimental-416047f
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 +94 -4
- package/out/__test__/invocationError.test.d.ts +2 -0
- package/out/__test__/invocationError.test.d.ts.map +1 -0
- package/out/__test__/invocationError.test.js +21 -0
- package/out/__test__/jobProgress.test.js +25 -1
- package/out/__test__/queue.test.js +5 -5
- package/out/__test__/retryOptions.test.d.ts +2 -0
- package/out/__test__/retryOptions.test.d.ts.map +1 -0
- package/out/__test__/retryOptions.test.js +14 -0
- package/out/errors.d.ts +1 -1
- package/out/errors.d.ts.map +1 -1
- package/out/errors.js +2 -2
- package/out/index.d.ts +3 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +6 -0
- package/out/invocationError.d.ts +7 -0
- package/out/invocationError.d.ts.map +1 -0
- package/out/invocationError.js +12 -0
- package/out/invocationErrorCode.d.ts +9 -0
- package/out/invocationErrorCode.d.ts.map +1 -0
- package/out/invocationErrorCode.js +12 -0
- package/out/jobProgress.d.ts +1 -0
- package/out/jobProgress.d.ts.map +1 -1
- package/out/jobProgress.js +12 -0
- package/out/queries.d.ts +1 -0
- package/out/queries.d.ts.map +1 -1
- package/out/queries.js +2 -1
- package/out/queueResponse.d.ts +5 -1
- package/out/queueResponse.d.ts.map +1 -1
- package/out/queueResponse.js +9 -3
- package/out/retryOptions.d.ts +9 -0
- package/out/retryOptions.d.ts.map +1 -0
- package/out/retryOptions.js +20 -0
- package/out/text.d.ts +1 -0
- package/out/text.d.ts.map +1 -1
- package/out/text.js +3 -2
- package/out/types.d.ts +1 -0
- package/out/types.d.ts.map +1 -1
- package/out/validators.d.ts +3 -1
- package/out/validators.d.ts.map +1 -1
- package/out/validators.js +15 -3
- package/package.json +5 -5
- package/src/__test__/invocationError.test.ts +23 -0
- package/src/__test__/jobProgress.test.ts +32 -1
- package/src/__test__/queue.test.ts +8 -6
- package/src/__test__/retryOptions.test.ts +14 -0
- package/src/errors.ts +2 -2
- package/src/index.ts +3 -0
- package/src/invocationError.ts +8 -0
- package/src/invocationErrorCode.ts +8 -0
- package/src/jobProgress.ts +23 -3
- package/src/queries.ts +1 -0
- package/src/queueResponse.ts +8 -2
- package/src/retryOptions.ts +26 -0
- package/src/text.ts +3 -2
- package/src/types.ts +1 -0
- package/src/validators.ts +18 -3
- package/tsconfig.tsbuildinfo +253 -231
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,102 @@
|
|
|
1
1
|
# @forge/events
|
|
2
2
|
|
|
3
|
-
## 0.0.0-experimental-
|
|
3
|
+
## 0.0.0-experimental-416047f
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0859c97: Allow app developers to return InvocationError on error from lambda function
|
|
8
|
+
|
|
9
|
+
## 0.6.0-next.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 0859c971: Allow app developers to return InvocationError on error from lambda function
|
|
14
|
+
|
|
15
|
+
## 0.5.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @forge/api@2.6.1
|
|
20
|
+
|
|
21
|
+
## 0.5.3-next.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- @forge/api@2.6.1-next.0
|
|
26
|
+
|
|
27
|
+
## 0.5.2
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [8571c05]
|
|
32
|
+
- @forge/api@2.6.0
|
|
33
|
+
|
|
34
|
+
## 0.5.2-next.0
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [8571c05]
|
|
39
|
+
- @forge/api@2.6.0-next.0
|
|
40
|
+
|
|
41
|
+
## 0.5.1
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [70e9c8c]
|
|
46
|
+
- Updated dependencies [32d11d1]
|
|
47
|
+
- @forge/api@2.5.0
|
|
48
|
+
|
|
49
|
+
## 0.5.1-next.0
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [df2cd2f]
|
|
54
|
+
- @forge/api@2.5.0-next.0
|
|
55
|
+
|
|
56
|
+
## 0.5.0
|
|
57
|
+
|
|
58
|
+
### Minor Changes
|
|
59
|
+
|
|
60
|
+
- 53e3fda: Create new API jobProgress.cancel() in forge-events package
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- @forge/api@2.4.0
|
|
65
|
+
|
|
66
|
+
## 0.5.0-next.1
|
|
67
|
+
|
|
68
|
+
### Minor Changes
|
|
69
|
+
|
|
70
|
+
- 53e3fda: Create new API jobProgress.cancel() in forge-events package
|
|
71
|
+
|
|
72
|
+
## 0.4.1-next.0
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [de02d45]
|
|
77
|
+
- @forge/api@2.4.0-next.0
|
|
78
|
+
|
|
79
|
+
## 0.4.0
|
|
80
|
+
|
|
81
|
+
### Minor Changes
|
|
82
|
+
|
|
83
|
+
- d32350b: allow sending up to 50 events per queue.push()
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- 8a8dccc: Update error messages
|
|
88
|
+
|
|
89
|
+
## 0.4.0-next.1
|
|
90
|
+
|
|
91
|
+
### Minor Changes
|
|
92
|
+
|
|
93
|
+
- d32350b: allow sending up to 50 events per queue.push()
|
|
94
|
+
|
|
95
|
+
## 0.3.1-next.0
|
|
4
96
|
|
|
5
97
|
### Patch Changes
|
|
6
98
|
|
|
7
|
-
-
|
|
8
|
-
- Updated dependencies [d18f8dd]
|
|
9
|
-
- @forge/api@0.0.0-experimental-d18f8dd
|
|
99
|
+
- 8a8dccc: Update error messages
|
|
10
100
|
|
|
11
101
|
## 0.3.0
|
|
12
102
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocationError.test.d.ts","sourceRoot":"","sources":["../../src/__test__/invocationError.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const retryOptions_1 = require("../retryOptions");
|
|
4
|
+
const invocationError_1 = require("../invocationError");
|
|
5
|
+
const invocationErrorCode_1 = require("../invocationErrorCode");
|
|
6
|
+
describe('InvocationError tests', () => {
|
|
7
|
+
const defaultRetryOption = new retryOptions_1.RetryOptions();
|
|
8
|
+
let target = new invocationError_1.InvocationError();
|
|
9
|
+
it('Populate invocationError with default retryOptions and expect default retry option', async () => {
|
|
10
|
+
expect(target.retryOptions.retryAfter).toEqual(defaultRetryOption.retryAfter);
|
|
11
|
+
expect(target.retryOptions.retryReason).toEqual(invocationErrorCode_1.InvocationErrorCode.FUNCTION_RETRY_REQUEST);
|
|
12
|
+
expect(target.hasOwnProperty('_retry')).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
it('Populate InvocationError with custom RetryOptions and expect the custom value to set.', () => {
|
|
15
|
+
defaultRetryOption.retryAfter = 10;
|
|
16
|
+
defaultRetryOption.retryReason = invocationErrorCode_1.InvocationErrorCode.FUNCTION_OUT_OF_MEMORY;
|
|
17
|
+
target = new invocationError_1.InvocationError(defaultRetryOption);
|
|
18
|
+
expect(target.retryOptions).toEqual(defaultRetryOption);
|
|
19
|
+
expect(target.hasOwnProperty('_retry')).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -29,7 +29,7 @@ describe('JobProgress methods', () => {
|
|
|
29
29
|
code: 404
|
|
30
30
|
}, 404);
|
|
31
31
|
const jobProgress = getJobProgress(apiClientMock, 'test-queue-name#test-job-id');
|
|
32
|
-
await expect(jobProgress.getStats()).rejects.toThrow(new errors_1.JobDoesNotExistError(`The job test-job-id
|
|
32
|
+
await expect(jobProgress.getStats()).rejects.toThrow(new errors_1.JobDoesNotExistError(`The job test-job-id was not found for the queue test-queue-name.`));
|
|
33
33
|
utils_1.verifyApiClientCalledWith(apiClientMock, '/webhook/queue/stats/{cloudId}/{environmentId}/{appId}/{appVersion}', {
|
|
34
34
|
queueName: 'test-queue-name',
|
|
35
35
|
jobId: 'test-job-id'
|
|
@@ -58,6 +58,30 @@ describe('JobProgress methods', () => {
|
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
+
describe('cancel', () => {
|
|
62
|
+
it('should call the queue/cancel endpoint', async () => {
|
|
63
|
+
const apiClientMock = utils_1.getApiClientMock({}, 204);
|
|
64
|
+
const jobProgress = getJobProgress(apiClientMock, 'test-queue-name#test-job-id');
|
|
65
|
+
const response = await jobProgress.cancel();
|
|
66
|
+
utils_1.verifyApiClientCalledWith(apiClientMock, '/webhook/queue/cancel/{cloudId}/{environmentId}/{appId}/{appVersion}', {
|
|
67
|
+
queueName: 'test-queue-name',
|
|
68
|
+
jobId: 'test-job-id'
|
|
69
|
+
});
|
|
70
|
+
expect(response.status).toEqual(204);
|
|
71
|
+
});
|
|
72
|
+
it('should throw JobDoesNotExistError', async () => {
|
|
73
|
+
const apiClientMock = utils_1.getApiClientMock({
|
|
74
|
+
message: 'Job Not Found',
|
|
75
|
+
code: 404
|
|
76
|
+
}, 404);
|
|
77
|
+
const jobProgress = getJobProgress(apiClientMock, 'test-queue-name#test-job-id');
|
|
78
|
+
await expect(jobProgress.cancel()).rejects.toThrow(new errors_1.JobDoesNotExistError(`The job test-job-id was not found for the queue test-queue-name.`));
|
|
79
|
+
utils_1.verifyApiClientCalledWith(apiClientMock, '/webhook/queue/cancel/{cloudId}/{environmentId}/{appId}/{appVersion}', {
|
|
80
|
+
queueName: 'test-queue-name',
|
|
81
|
+
jobId: 'test-job-id'
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
61
85
|
it('should throw InternalServerError when WHP returns 422 response', async () => {
|
|
62
86
|
const apiClientMock = utils_1.getApiClientMock({
|
|
63
87
|
errors: ['jobId must not be null', 'queueName must not be null']
|
|
@@ -37,7 +37,7 @@ describe('Queue methods', () => {
|
|
|
37
37
|
it('should throw TooManyEventsError', async () => {
|
|
38
38
|
const apiClientMock = utils_1.getApiClientMock();
|
|
39
39
|
const queue = getQueue(apiClientMock, 'name');
|
|
40
|
-
await expect(queue.push([
|
|
40
|
+
await expect(queue.push([...Array(51).keys()])).rejects.toThrow(new errors_1.TooManyEventsError(`This push contains more than the 50 events allowed.`));
|
|
41
41
|
expect(apiClientMock).toHaveBeenCalledTimes(0);
|
|
42
42
|
});
|
|
43
43
|
it('should throw PayloadTooBigError', async () => {
|
|
@@ -49,15 +49,15 @@ describe('Queue methods', () => {
|
|
|
49
49
|
it('should throw RateLimitError', async () => {
|
|
50
50
|
const apiClientMock = utils_1.getApiClientMock({}, 429);
|
|
51
51
|
const queue = getQueue(apiClientMock, 'name');
|
|
52
|
-
const payload = [
|
|
52
|
+
const payload = [...Array(10).keys()];
|
|
53
53
|
await expect(queue.push(payload)).rejects.toThrow(new errors_1.RateLimitError(`Too many requests.`));
|
|
54
54
|
utils_1.verifyApiClientCalledPushPathWith(apiClientMock, payload, 'name');
|
|
55
55
|
});
|
|
56
56
|
it('should throw InvocationLimitReachedError', async () => {
|
|
57
57
|
const apiClientMock = utils_1.getApiClientMock({}, 405);
|
|
58
58
|
const queue = getQueue(apiClientMock, 'name');
|
|
59
|
-
const payload = [
|
|
60
|
-
await expect(queue.push(payload)).rejects.toThrow(new errors_1.InvocationLimitReachedError());
|
|
59
|
+
const payload = [...Array(5).keys()];
|
|
60
|
+
await expect(queue.push(payload)).rejects.toThrow(new errors_1.InvocationLimitReachedError(`The limit on cyclic invocation has been reached.`));
|
|
61
61
|
utils_1.verifyApiClientCalledPushPathWith(apiClientMock, payload, 'name');
|
|
62
62
|
});
|
|
63
63
|
it('should throw PartialSuccessError when there are failed events', async () => {
|
|
@@ -156,7 +156,7 @@ describe('Queue methods', () => {
|
|
|
156
156
|
details: 'The request processing has failed because of an unknown error, exception or failure'
|
|
157
157
|
}, 500);
|
|
158
158
|
const queue = getQueue(apiClientMock, 'name');
|
|
159
|
-
const payload = [
|
|
159
|
+
const payload = [...Array(9).keys()];
|
|
160
160
|
await expect(queue.push(payload)).rejects.toThrow(new errors_1.InternalServerError(`500 Status Text: AWS SQS timed out`, 500, 'The request processing has failed because of an unknown error, exception or failure'));
|
|
161
161
|
utils_1.verifyApiClientCalledPushPathWith(apiClientMock, payload, 'name');
|
|
162
162
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryOptions.test.d.ts","sourceRoot":"","sources":["../../src/__test__/retryOptions.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const retryOptions_1 = require("../retryOptions");
|
|
4
|
+
describe('RetryOptions tests', () => {
|
|
5
|
+
const target = new retryOptions_1.RetryOptions();
|
|
6
|
+
it.each([
|
|
7
|
+
[retryOptions_1.RetryOptions.MIN_RETRY_AFTER, retryOptions_1.RetryOptions.MIN_RETRY_AFTER],
|
|
8
|
+
[retryOptions_1.RetryOptions.MIN_RETRY_AFTER - 1, retryOptions_1.RetryOptions.MIN_RETRY_AFTER],
|
|
9
|
+
[retryOptions_1.RetryOptions.MIN_RETRY_AFTER + 1, retryOptions_1.RetryOptions.MIN_RETRY_AFTER + 1]
|
|
10
|
+
])('try to set retryAfter to %p, expect retryAfter to be %p', (value, result) => {
|
|
11
|
+
target.retryAfter = value;
|
|
12
|
+
expect(target.retryAfter).toEqual(result);
|
|
13
|
+
});
|
|
14
|
+
});
|
package/out/errors.d.ts
CHANGED
package/out/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE;IAKxD,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAMjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,2BAA4B,SAAQ,KAAK
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE;IAKxD,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAMjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAG5B"}
|
package/out/errors.js
CHANGED
|
@@ -59,8 +59,8 @@ class JobDoesNotExistError extends Error {
|
|
|
59
59
|
}
|
|
60
60
|
exports.JobDoesNotExistError = JobDoesNotExistError;
|
|
61
61
|
class InvocationLimitReachedError extends Error {
|
|
62
|
-
constructor() {
|
|
63
|
-
super();
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super(message);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
exports.InvocationLimitReachedError = InvocationLimitReachedError;
|
package/out/index.d.ts
CHANGED
|
@@ -2,4 +2,7 @@ export { Queue } from './queue';
|
|
|
2
2
|
export { InvalidQueueNameError, TooManyEventsError, PayloadTooBigError, NoEventsToPushError, RateLimitError, PartialSuccessError, InternalServerError, JobDoesNotExistError, InvalidPushSettingsError, InvocationLimitReachedError } from './errors';
|
|
3
3
|
export { JobProgress } from './jobProgress';
|
|
4
4
|
export { QueueResponse } from './queueResponse';
|
|
5
|
+
export { InvocationError } from './invocationError';
|
|
6
|
+
export { InvocationErrorCode } from './invocationErrorCode';
|
|
7
|
+
export { RetryOptions } from './retryOptions';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -17,3 +17,9 @@ var jobProgress_1 = require("./jobProgress");
|
|
|
17
17
|
Object.defineProperty(exports, "JobProgress", { enumerable: true, get: function () { return jobProgress_1.JobProgress; } });
|
|
18
18
|
var queueResponse_1 = require("./queueResponse");
|
|
19
19
|
Object.defineProperty(exports, "QueueResponse", { enumerable: true, get: function () { return queueResponse_1.QueueResponse; } });
|
|
20
|
+
var invocationError_1 = require("./invocationError");
|
|
21
|
+
Object.defineProperty(exports, "InvocationError", { enumerable: true, get: function () { return invocationError_1.InvocationError; } });
|
|
22
|
+
var invocationErrorCode_1 = require("./invocationErrorCode");
|
|
23
|
+
Object.defineProperty(exports, "InvocationErrorCode", { enumerable: true, get: function () { return invocationErrorCode_1.InvocationErrorCode; } });
|
|
24
|
+
var retryOptions_1 = require("./retryOptions");
|
|
25
|
+
Object.defineProperty(exports, "RetryOptions", { enumerable: true, get: function () { return retryOptions_1.RetryOptions; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RetryOptions } from './retryOptions';
|
|
2
|
+
import { Response } from './queueResponse';
|
|
3
|
+
export declare class InvocationError extends Response {
|
|
4
|
+
retryOptions: RetryOptions;
|
|
5
|
+
constructor(retryOptions?: RetryOptions);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=invocationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocationError.d.ts","sourceRoot":"","sources":["../src/invocationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBAAa,eAAgB,SAAQ,QAAQ;IACxB,YAAY,EAAE,YAAY;gBAA1B,YAAY,GAAE,YAAiC;CAGnE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvocationError = void 0;
|
|
4
|
+
const retryOptions_1 = require("./retryOptions");
|
|
5
|
+
const queueResponse_1 = require("./queueResponse");
|
|
6
|
+
class InvocationError extends queueResponse_1.Response {
|
|
7
|
+
constructor(retryOptions = new retryOptions_1.RetryOptions()) {
|
|
8
|
+
super(true);
|
|
9
|
+
this.retryOptions = retryOptions;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.InvocationError = InvocationError;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum InvocationErrorCode {
|
|
2
|
+
FUNCTION_OUT_OF_MEMORY = 0,
|
|
3
|
+
FUNCTION_TIME_OUT = 1,
|
|
4
|
+
FUNCTION_PLATFORM_UNKNOWN_ERROR = 2,
|
|
5
|
+
FUNCTION_PLATFORM_RATE_LIMITED = 3,
|
|
6
|
+
FUNCTION_UPSTREAM_RATE_LIMITED = 4,
|
|
7
|
+
FUNCTION_RETRY_REQUEST = 5
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=invocationErrorCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocationErrorCode.d.ts","sourceRoot":"","sources":["../src/invocationErrorCode.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB;IAC7B,sBAAsB,IAAA;IACtB,iBAAiB,IAAA;IACjB,+BAA+B,IAAA;IAC/B,8BAA8B,IAAA;IAC9B,8BAA8B,IAAA;IAC9B,sBAAsB,IAAA;CACvB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvocationErrorCode = void 0;
|
|
4
|
+
var InvocationErrorCode;
|
|
5
|
+
(function (InvocationErrorCode) {
|
|
6
|
+
InvocationErrorCode[InvocationErrorCode["FUNCTION_OUT_OF_MEMORY"] = 0] = "FUNCTION_OUT_OF_MEMORY";
|
|
7
|
+
InvocationErrorCode[InvocationErrorCode["FUNCTION_TIME_OUT"] = 1] = "FUNCTION_TIME_OUT";
|
|
8
|
+
InvocationErrorCode[InvocationErrorCode["FUNCTION_PLATFORM_UNKNOWN_ERROR"] = 2] = "FUNCTION_PLATFORM_UNKNOWN_ERROR";
|
|
9
|
+
InvocationErrorCode[InvocationErrorCode["FUNCTION_PLATFORM_RATE_LIMITED"] = 3] = "FUNCTION_PLATFORM_RATE_LIMITED";
|
|
10
|
+
InvocationErrorCode[InvocationErrorCode["FUNCTION_UPSTREAM_RATE_LIMITED"] = 4] = "FUNCTION_UPSTREAM_RATE_LIMITED";
|
|
11
|
+
InvocationErrorCode[InvocationErrorCode["FUNCTION_RETRY_REQUEST"] = 5] = "FUNCTION_RETRY_REQUEST";
|
|
12
|
+
})(InvocationErrorCode = exports.InvocationErrorCode || (exports.InvocationErrorCode = {}));
|
package/out/jobProgress.d.ts
CHANGED
package/out/jobProgress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobProgress.d.ts","sourceRoot":"","sources":["../src/jobProgress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jobProgress.d.ts","sourceRoot":"","sources":["../src/jobProgress.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAoB,WAAW,EAAmB,MAAM,SAAS,CAAC;AAEtF,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,EAAE,CAAS;gBAEP,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,WAAW;IAKzC,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAehC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC;CAcrC"}
|
package/out/jobProgress.js
CHANGED
|
@@ -20,5 +20,17 @@ class JobProgress {
|
|
|
20
20
|
await validators_1.validateGetStatsAPIResponse(response, getStatsRequest);
|
|
21
21
|
return response;
|
|
22
22
|
}
|
|
23
|
+
async cancel() {
|
|
24
|
+
const [queueName, jobId] = this.id.split('#');
|
|
25
|
+
const cancelJobRequest = {
|
|
26
|
+
queueName: queueName,
|
|
27
|
+
jobId: jobId,
|
|
28
|
+
time: new Date().toISOString()
|
|
29
|
+
};
|
|
30
|
+
validators_1.validateCancelJobRequest(cancelJobRequest);
|
|
31
|
+
const response = await queries_1.post(queries_1.CANCEL_JOB_PATH, cancelJobRequest, this.apiClient);
|
|
32
|
+
await validators_1.validateCancelJobAPIResponse(response, cancelJobRequest);
|
|
33
|
+
return response;
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
36
|
exports.JobProgress = JobProgress;
|
package/out/queries.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { APIRequest, APIResponse, FetchMethod } from './types';
|
|
2
2
|
export declare const PUSH_PATH = "/webhook/queue/publish/{cloudId}/{environmentId}/{appId}/{appVersion}";
|
|
3
3
|
export declare const GET_STATS_PATH = "/webhook/queue/stats/{cloudId}/{environmentId}/{appId}/{appVersion}";
|
|
4
|
+
export declare const CANCEL_JOB_PATH = "/webhook/queue/cancel/{cloudId}/{environmentId}/{appId}/{appVersion}";
|
|
4
5
|
export declare const post: (endpoint: string, body: APIRequest, apiClient: FetchMethod) => Promise<APIResponse>;
|
|
5
6
|
//# sourceMappingURL=queries.d.ts.map
|
package/out/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,SAAS,0EAA0E,CAAC;AACjG,eAAO,MAAM,cAAc,wEAAwE,CAAC;
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,SAAS,0EAA0E,CAAC;AACjG,eAAO,MAAM,cAAc,wEAAwE,CAAC;AACpG,eAAO,MAAM,eAAe,yEAAyE,CAAC;AAEtG,eAAO,MAAM,IAAI,aAAoB,MAAM,QAAQ,UAAU,aAAa,WAAW,KAAG,OAAO,CAAC,WAAW,CAU1G,CAAC"}
|
package/out/queries.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.post = exports.GET_STATS_PATH = exports.PUSH_PATH = void 0;
|
|
3
|
+
exports.post = exports.CANCEL_JOB_PATH = exports.GET_STATS_PATH = exports.PUSH_PATH = void 0;
|
|
4
4
|
exports.PUSH_PATH = '/webhook/queue/publish/{cloudId}/{environmentId}/{appId}/{appVersion}';
|
|
5
5
|
exports.GET_STATS_PATH = '/webhook/queue/stats/{cloudId}/{environmentId}/{appId}/{appVersion}';
|
|
6
|
+
exports.CANCEL_JOB_PATH = '/webhook/queue/cancel/{cloudId}/{environmentId}/{appId}/{appVersion}';
|
|
6
7
|
exports.post = async (endpoint, body, apiClient) => {
|
|
7
8
|
const request = {
|
|
8
9
|
method: 'POST',
|
package/out/queueResponse.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class Response {
|
|
2
2
|
protected _retry: boolean;
|
|
3
|
+
constructor(_retry: boolean);
|
|
4
|
+
}
|
|
5
|
+
export declare class QueueResponse extends Response {
|
|
6
|
+
constructor();
|
|
3
7
|
retry(): void;
|
|
4
8
|
}
|
|
5
9
|
//# sourceMappingURL=queueResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queueResponse.d.ts","sourceRoot":"","sources":["../src/queueResponse.ts"],"names":[],"mappings":"AAAA,qBAAa,
|
|
1
|
+
{"version":3,"file":"queueResponse.d.ts","sourceRoot":"","sources":["../src/queueResponse.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACP,SAAS,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;CACtC;AAED,qBAAa,aAAc,SAAQ,QAAQ;;IAKzC,KAAK,IAAI,IAAI;CAGd"}
|
package/out/queueResponse.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueueResponse = void 0;
|
|
4
|
-
class
|
|
3
|
+
exports.QueueResponse = exports.Response = void 0;
|
|
4
|
+
class Response {
|
|
5
|
+
constructor(_retry) {
|
|
6
|
+
this._retry = _retry;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.Response = Response;
|
|
10
|
+
class QueueResponse extends Response {
|
|
5
11
|
constructor() {
|
|
6
|
-
|
|
12
|
+
super(false);
|
|
7
13
|
}
|
|
8
14
|
retry() {
|
|
9
15
|
this._retry = true;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InvocationErrorCode } from './invocationErrorCode';
|
|
2
|
+
export declare class RetryOptions {
|
|
3
|
+
static readonly MIN_RETRY_AFTER = 1;
|
|
4
|
+
private _retryAfter;
|
|
5
|
+
retryReason: InvocationErrorCode;
|
|
6
|
+
set retryAfter(valueInSeconds: number);
|
|
7
|
+
get retryAfter(): number;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=retryOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryOptions.d.ts","sourceRoot":"","sources":["../src/retryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,eAAe,KAAK;IAEpC,OAAO,CAAC,WAAW,CAAgC;IAE5C,WAAW,EAAE,mBAAmB,CAA8C;IAMrF,IAAI,UAAU,CAAC,cAAc,EAAE,MAAM,EAIpC;IAKD,IAAI,UAAU,IAAI,MAAM,CAEvB;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RetryOptions = void 0;
|
|
4
|
+
const invocationErrorCode_1 = require("./invocationErrorCode");
|
|
5
|
+
class RetryOptions {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._retryAfter = RetryOptions.MIN_RETRY_AFTER;
|
|
8
|
+
this.retryReason = invocationErrorCode_1.InvocationErrorCode.FUNCTION_RETRY_REQUEST;
|
|
9
|
+
}
|
|
10
|
+
set retryAfter(valueInSeconds) {
|
|
11
|
+
if (valueInSeconds >= RetryOptions.MIN_RETRY_AFTER) {
|
|
12
|
+
this._retryAfter = valueInSeconds;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
get retryAfter() {
|
|
16
|
+
return this._retryAfter;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.RetryOptions = RetryOptions;
|
|
20
|
+
RetryOptions.MIN_RETRY_AFTER = 1;
|
package/out/text.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const Text: {
|
|
|
6
6
|
maxPayloadAllowed: (maxPayloadSize: number) => string;
|
|
7
7
|
noEventsPushed: string;
|
|
8
8
|
rateLimitError: string;
|
|
9
|
+
invocationLimitReachedError: string;
|
|
9
10
|
jobIdEmpty: string;
|
|
10
11
|
jobDoesNotExit: (jobId: string, queueName: string) => string;
|
|
11
12
|
};
|
package/out/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;2CAIsB,MAAM,KAAG,MAAM;4CAEd,MAAM,KAAG,MAAM
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;2CAIsB,MAAM,KAAG,MAAM;4CAEd,MAAM,KAAG,MAAM;;;;;gCAK3B,MAAM,aAAa,MAAM,KAAG,MAAM;;CAG7D,CAAC"}
|
package/out/text.js
CHANGED
|
@@ -5,11 +5,12 @@ exports.Text = {
|
|
|
5
5
|
error: {
|
|
6
6
|
invalidQueueName: `Queue names can only contain alphanumeric characters, dashes and underscores.`,
|
|
7
7
|
invalidDelayInSecondsSetting: `The delayInSeconds setting must be between 0 and 900.`,
|
|
8
|
-
maxEventsAllowed: (maxEventsCount) => `
|
|
8
|
+
maxEventsAllowed: (maxEventsCount) => `This push contains more than the ${maxEventsCount} events allowed.`,
|
|
9
9
|
maxPayloadAllowed: (maxPayloadSize) => `The maximum payload size is ${maxPayloadSize}KB.`,
|
|
10
10
|
noEventsPushed: `No events pushed.`,
|
|
11
11
|
rateLimitError: `Too many requests.`,
|
|
12
|
+
invocationLimitReachedError: `The limit on cyclic invocation has been reached.`,
|
|
12
13
|
jobIdEmpty: `jobId cannot be empty.`,
|
|
13
|
-
jobDoesNotExit: (jobId, queueName) => `The job ${jobId}
|
|
14
|
+
jobDoesNotExit: (jobId, queueName) => `The job ${jobId} was not found for the queue ${queueName}.`
|
|
14
15
|
}
|
|
15
16
|
};
|
package/out/types.d.ts
CHANGED
package/out/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD,oBAAY,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAC;AAC3G,oBAAY,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AACnF,oBAAY,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE7E,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB;AACD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,oBAAY,eAAe,GAAG,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD,oBAAY,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,IAAI,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAC;AAC3G,oBAAY,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AACnF,oBAAY,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE7E,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB;AACD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,oBAAY,eAAe,GAAG,UAAU,CAAC;AACzC,oBAAY,gBAAgB,GAAG,UAAU,CAAC"}
|
package/out/validators.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { APIResponse, GetStatsRequest, Payload, PushRequest, PushSettings } from './types';
|
|
1
|
+
import { APIResponse, CancelJobRequest, GetStatsRequest, Payload, PushRequest, PushSettings } from './types';
|
|
2
2
|
export declare const validateQueueKey: (queueName: string) => void;
|
|
3
3
|
export declare const validatePushSettings: (settings: PushSettings) => void;
|
|
4
4
|
export declare const validatePushPayloads: (payloads: Payload | Payload[]) => void;
|
|
5
5
|
export declare const validateGetStatsPayload: (getStatsRequest: GetStatsRequest) => void;
|
|
6
|
+
export declare const validateCancelJobRequest: (cancelJobRequest: CancelJobRequest) => void;
|
|
6
7
|
export declare const validateAPIResponse: (response: APIResponse, expectedSuccessStatus: number) => Promise<void>;
|
|
7
8
|
export declare const validatePushAPIResponse: (response: APIResponse, requestBody: PushRequest) => Promise<void>;
|
|
8
9
|
export declare const validateGetStatsAPIResponse: (response: APIResponse, getStatsRequest: GetStatsRequest) => Promise<void>;
|
|
10
|
+
export declare const validateCancelJobAPIResponse: (response: APIResponse, cancelJobRequest: GetStatsRequest) => Promise<void>;
|
|
9
11
|
//# sourceMappingURL=validators.d.ts.map
|
package/out/validators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM7G,eAAO,MAAM,gBAAgB,cAAe,MAAM,SAIjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAAc,YAAY,SAI1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAAc,OAAO,GAAG,OAAO,EAAE,SAajE,CAAC;AAEF,eAAO,MAAM,uBAAuB,oBAAqB,eAAe,SAKvE,CAAC;AAEF,eAAO,MAAM,wBAAwB,qBAAsB,gBAAgB,SAK1E,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAAoB,WAAW,yBAAyB,MAAM,kBA6B7F,CAAC;AAEF,eAAO,MAAM,uBAAuB,aAAoB,WAAW,eAAe,WAAW,kBAkC5F,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAAoB,WAAW,mBAAmB,eAAe,kBAMxG,CAAC;AAEF,eAAO,MAAM,4BAA4B,aAAoB,WAAW,oBAAoB,eAAe,kBAM1G,CAAC"}
|
package/out/validators.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateGetStatsAPIResponse = exports.validatePushAPIResponse = exports.validateAPIResponse = exports.validateGetStatsPayload = exports.validatePushPayloads = exports.validatePushSettings = exports.validateQueueKey = void 0;
|
|
3
|
+
exports.validateCancelJobAPIResponse = exports.validateGetStatsAPIResponse = exports.validatePushAPIResponse = exports.validateAPIResponse = exports.validateCancelJobRequest = exports.validateGetStatsPayload = exports.validatePushPayloads = exports.validatePushSettings = exports.validateQueueKey = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
const text_1 = require("./text");
|
|
6
6
|
const VALID_QUEUE_NAME_PATTERN = /^[a-zA-Z0-9-_]+$/;
|
|
7
|
-
const MAXIMUM_EVENTS =
|
|
7
|
+
const MAXIMUM_EVENTS = 50;
|
|
8
8
|
const MAXIMUM_PAYLOAD_SIZE_KB = 200;
|
|
9
9
|
exports.validateQueueKey = (queueName) => {
|
|
10
10
|
if (!queueName || !VALID_QUEUE_NAME_PATTERN.test(queueName)) {
|
|
@@ -34,12 +34,18 @@ exports.validateGetStatsPayload = (getStatsRequest) => {
|
|
|
34
34
|
}
|
|
35
35
|
exports.validateQueueKey(getStatsRequest.queueName);
|
|
36
36
|
};
|
|
37
|
+
exports.validateCancelJobRequest = (cancelJobRequest) => {
|
|
38
|
+
if (!cancelJobRequest.jobId) {
|
|
39
|
+
throw new errors_1.JobDoesNotExistError(text_1.Text.error.jobIdEmpty);
|
|
40
|
+
}
|
|
41
|
+
exports.validateQueueKey(cancelJobRequest.queueName);
|
|
42
|
+
};
|
|
37
43
|
exports.validateAPIResponse = async (response, expectedSuccessStatus) => {
|
|
38
44
|
if (response.status === 429) {
|
|
39
45
|
throw new errors_1.RateLimitError(text_1.Text.error.rateLimitError);
|
|
40
46
|
}
|
|
41
47
|
if (response.status === 405) {
|
|
42
|
-
throw new errors_1.InvocationLimitReachedError();
|
|
48
|
+
throw new errors_1.InvocationLimitReachedError(text_1.Text.error.invocationLimitReachedError);
|
|
43
49
|
}
|
|
44
50
|
if (response.status != expectedSuccessStatus && response.status) {
|
|
45
51
|
let internalServerError;
|
|
@@ -89,3 +95,9 @@ exports.validateGetStatsAPIResponse = async (response, getStatsRequest) => {
|
|
|
89
95
|
}
|
|
90
96
|
await exports.validateAPIResponse(response, 200);
|
|
91
97
|
};
|
|
98
|
+
exports.validateCancelJobAPIResponse = async (response, cancelJobRequest) => {
|
|
99
|
+
if (response.status === 404) {
|
|
100
|
+
throw new errors_1.JobDoesNotExistError(text_1.Text.error.jobDoesNotExit(cancelJobRequest.jobId, cancelJobRequest.queueName));
|
|
101
|
+
}
|
|
102
|
+
await exports.validateAPIResponse(response, 204);
|
|
103
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/events",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-416047f",
|
|
4
4
|
"description": "Forge Async Event methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"compile": "tsc -b -v"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/
|
|
16
|
-
"@types/
|
|
15
|
+
"@types/node": "^12.12.63",
|
|
16
|
+
"@types/uuid": "^3.4.7"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"@forge/api": "^2.6.1",
|
|
20
|
+
"uuid": "^3.4.0"
|
|
21
21
|
}
|
|
22
22
|
}
|