@forge/events 0.3.0-next.4 → 0.4.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 +35 -0
- package/out/__test__/jobProgress.test.js +1 -1
- package/out/__test__/queue.test.js +5 -5
- package/out/errors.d.ts +1 -1
- package/out/errors.d.ts.map +1 -1
- package/out/errors.js +2 -2
- package/out/text.d.ts +1 -0
- package/out/text.d.ts.map +1 -1
- package/out/text.js +3 -2
- package/out/validators.js +2 -2
- package/package.json +1 -1
- package/src/__test__/jobProgress.test.ts +1 -1
- package/src/__test__/queue.test.ts +8 -6
- package/src/errors.ts +2 -2
- package/src/text.ts +3 -2
- package/src/validators.ts +2 -2
- package/tsconfig.tsbuildinfo +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @forge/events
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d32350b: allow sending up to 50 events per queue.push()
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 8a8dccc: Update error messages
|
|
12
|
+
|
|
13
|
+
## 0.4.0-next.1
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- d32350b: allow sending up to 50 events per queue.push()
|
|
18
|
+
|
|
19
|
+
## 0.3.1-next.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 8a8dccc: Update error messages
|
|
24
|
+
|
|
25
|
+
## 0.3.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- 9fe841c: Explicitly add uuid dependency and whitelist WHP getStats endpoint
|
|
30
|
+
- 66b6648: Add errors and validations
|
|
31
|
+
- 9051f1d: Add @forge/api as a dependency of @forge/events
|
|
32
|
+
- 6dbedd8: Add QueueResponse in forge-events package to allow retrying an async event.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- afa9ee0: Update the error messages
|
|
37
|
+
|
|
3
38
|
## 0.3.0-next.4
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -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'
|
|
@@ -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
|
});
|
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,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K;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/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/validators.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.validateGetStatsAPIResponse = exports.validatePushAPIResponse = exports.
|
|
|
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)) {
|
|
@@ -39,7 +39,7 @@ exports.validateAPIResponse = async (response, expectedSuccessStatus) => {
|
|
|
39
39
|
throw new errors_1.RateLimitError(text_1.Text.error.rateLimitError);
|
|
40
40
|
}
|
|
41
41
|
if (response.status === 405) {
|
|
42
|
-
throw new errors_1.InvocationLimitReachedError();
|
|
42
|
+
throw new errors_1.InvocationLimitReachedError(text_1.Text.error.invocationLimitReachedError);
|
|
43
43
|
}
|
|
44
44
|
if (response.status != expectedSuccessStatus && response.status) {
|
|
45
45
|
let internalServerError;
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ describe('JobProgress methods', () => {
|
|
|
37
37
|
);
|
|
38
38
|
const jobProgress = getJobProgress(apiClientMock, 'test-queue-name#test-job-id');
|
|
39
39
|
await expect(jobProgress.getStats()).rejects.toThrow(
|
|
40
|
-
new JobDoesNotExistError(`The job test-job-id
|
|
40
|
+
new JobDoesNotExistError(`The job test-job-id was not found for the queue test-queue-name.`)
|
|
41
41
|
);
|
|
42
42
|
verifyApiClientCalledWith(apiClientMock, '/webhook/queue/stats/{cloudId}/{environmentId}/{appId}/{appVersion}', {
|
|
43
43
|
queueName: 'test-queue-name',
|
|
@@ -55,8 +55,8 @@ describe('Queue methods', () => {
|
|
|
55
55
|
it('should throw TooManyEventsError', async () => {
|
|
56
56
|
const apiClientMock = getApiClientMock();
|
|
57
57
|
const queue = getQueue(apiClientMock, 'name');
|
|
58
|
-
await expect(queue.push([
|
|
59
|
-
new TooManyEventsError(`
|
|
58
|
+
await expect(queue.push([...Array(51).keys()])).rejects.toThrow(
|
|
59
|
+
new TooManyEventsError(`This push contains more than the 50 events allowed.`)
|
|
60
60
|
);
|
|
61
61
|
expect(apiClientMock).toHaveBeenCalledTimes(0);
|
|
62
62
|
});
|
|
@@ -73,7 +73,7 @@ describe('Queue methods', () => {
|
|
|
73
73
|
it('should throw RateLimitError', async () => {
|
|
74
74
|
const apiClientMock = getApiClientMock({}, 429);
|
|
75
75
|
const queue = getQueue(apiClientMock, 'name');
|
|
76
|
-
const payload = [
|
|
76
|
+
const payload = [...Array(10).keys()];
|
|
77
77
|
await expect(queue.push(payload)).rejects.toThrow(new RateLimitError(`Too many requests.`));
|
|
78
78
|
verifyApiClientCalledPushPathWith(apiClientMock, payload, 'name');
|
|
79
79
|
});
|
|
@@ -81,8 +81,10 @@ describe('Queue methods', () => {
|
|
|
81
81
|
it('should throw InvocationLimitReachedError', async () => {
|
|
82
82
|
const apiClientMock = getApiClientMock({}, 405);
|
|
83
83
|
const queue = getQueue(apiClientMock, 'name');
|
|
84
|
-
const payload = [
|
|
85
|
-
await expect(queue.push(payload)).rejects.toThrow(
|
|
84
|
+
const payload = [...Array(5).keys()];
|
|
85
|
+
await expect(queue.push(payload)).rejects.toThrow(
|
|
86
|
+
new InvocationLimitReachedError(`The limit on cyclic invocation has been reached.`)
|
|
87
|
+
);
|
|
86
88
|
verifyApiClientCalledPushPathWith(apiClientMock, payload, 'name');
|
|
87
89
|
});
|
|
88
90
|
|
|
@@ -203,7 +205,7 @@ describe('Queue methods', () => {
|
|
|
203
205
|
500
|
|
204
206
|
);
|
|
205
207
|
const queue = getQueue(apiClientMock, 'name');
|
|
206
|
-
const payload = [
|
|
208
|
+
const payload = [...Array(9).keys()];
|
|
207
209
|
await expect(queue.push(payload)).rejects.toThrow(
|
|
208
210
|
new InternalServerError(
|
|
209
211
|
`500 Status Text: AWS SQS timed out`,
|
package/src/errors.ts
CHANGED
package/src/text.ts
CHANGED
|
@@ -3,12 +3,13 @@ export const Text = {
|
|
|
3
3
|
invalidQueueName: `Queue names can only contain alphanumeric characters, dashes and underscores.`,
|
|
4
4
|
invalidDelayInSecondsSetting: `The delayInSeconds setting must be between 0 and 900.`,
|
|
5
5
|
maxEventsAllowed: (maxEventsCount: number): string =>
|
|
6
|
-
`
|
|
6
|
+
`This push contains more than the ${maxEventsCount} events allowed.`,
|
|
7
7
|
maxPayloadAllowed: (maxPayloadSize: number): string => `The maximum payload size is ${maxPayloadSize}KB.`,
|
|
8
8
|
noEventsPushed: `No events pushed.`,
|
|
9
9
|
rateLimitError: `Too many requests.`,
|
|
10
|
+
invocationLimitReachedError: `The limit on cyclic invocation has been reached.`,
|
|
10
11
|
jobIdEmpty: `jobId cannot be empty.`,
|
|
11
12
|
jobDoesNotExit: (jobId: string, queueName: string): string =>
|
|
12
|
-
`The job ${jobId}
|
|
13
|
+
`The job ${jobId} was not found for the queue ${queueName}.`
|
|
13
14
|
}
|
|
14
15
|
};
|
package/src/validators.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { Text } from './text';
|
|
|
14
14
|
import { APIResponse, GetStatsRequest, Payload, PushRequest, PushSettings } from './types';
|
|
15
15
|
|
|
16
16
|
const VALID_QUEUE_NAME_PATTERN = /^[a-zA-Z0-9-_]+$/;
|
|
17
|
-
const MAXIMUM_EVENTS =
|
|
17
|
+
const MAXIMUM_EVENTS = 50;
|
|
18
18
|
const MAXIMUM_PAYLOAD_SIZE_KB = 200;
|
|
19
19
|
|
|
20
20
|
export const validateQueueKey = (queueName: string) => {
|
|
@@ -57,7 +57,7 @@ export const validateAPIResponse = async (response: APIResponse, expectedSuccess
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (response.status === 405) {
|
|
60
|
-
throw new InvocationLimitReachedError();
|
|
60
|
+
throw new InvocationLimitReachedError(Text.error.invocationLimitReachedError);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (response.status != expectedSuccessStatus && response.status) {
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -397,8 +397,8 @@
|
|
|
397
397
|
"affectsGlobalScope": false
|
|
398
398
|
},
|
|
399
399
|
"./src/errors.ts": {
|
|
400
|
-
"version": "
|
|
401
|
-
"signature": "
|
|
400
|
+
"version": "d851b9c7d9f3221bbef29df8237e3d4156ab8706950d6bdd6c4a57d8e55cc4c1",
|
|
401
|
+
"signature": "dbec5f26319c68d139585561f12341a720ab13880a4c040b438e892ae391d2c9",
|
|
402
402
|
"affectsGlobalScope": false
|
|
403
403
|
},
|
|
404
404
|
"./src/queries.ts": {
|
|
@@ -407,12 +407,12 @@
|
|
|
407
407
|
"affectsGlobalScope": false
|
|
408
408
|
},
|
|
409
409
|
"./src/text.ts": {
|
|
410
|
-
"version": "
|
|
411
|
-
"signature": "
|
|
410
|
+
"version": "0b4ee00634da4bf5aa2fecf99443c7a886fee5619832b35c0e10513deecd3967",
|
|
411
|
+
"signature": "4c846733296e27a117c12a9bdf0311f5790125ddf1e1e01b54869b9c487630ba",
|
|
412
412
|
"affectsGlobalScope": false
|
|
413
413
|
},
|
|
414
414
|
"./src/validators.ts": {
|
|
415
|
-
"version": "
|
|
415
|
+
"version": "46c89feddc0e1906925367a2093130dbaf98798d472df95970f6715b4cd5c5d3",
|
|
416
416
|
"signature": "74384a84caa4d0e5679b15f8e72bad7b657d503e3178ed8b9b87c32f36e3573b",
|
|
417
417
|
"affectsGlobalScope": false
|
|
418
418
|
},
|
|
@@ -452,12 +452,12 @@
|
|
|
452
452
|
"affectsGlobalScope": false
|
|
453
453
|
},
|
|
454
454
|
"./src/__test__/jobProgress.test.ts": {
|
|
455
|
-
"version": "
|
|
455
|
+
"version": "f47b1533e3fa6faf1458a83e25cd26b425e822d01988ec604b7bb2140410d708",
|
|
456
456
|
"signature": "7870ceffd2c069795d2976c13017e1697f28e9a1c994dbd36dc48c21826db61b",
|
|
457
457
|
"affectsGlobalScope": false
|
|
458
458
|
},
|
|
459
459
|
"./src/__test__/queue.test.ts": {
|
|
460
|
-
"version": "
|
|
460
|
+
"version": "23dea05f9460582f60526e93a77111cda92508c785087c54fa05995b9b6dd9df",
|
|
461
461
|
"signature": "1302e8032e32981552bc73b7ef2f99ebf98990a704e26f51e70b1d96a4639fcf",
|
|
462
462
|
"affectsGlobalScope": false
|
|
463
463
|
},
|