@unito/integration-sdk 3.0.1 → 4.1.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/dist/src/handler.js +6 -0
- package/dist/src/index.cjs +6 -0
- package/dist/test/handler.test.js +3 -1
- package/package.json +2 -2
- package/src/handler.ts +6 -0
- package/test/handler.test.ts +3 -1
package/dist/src/handler.js
CHANGED
|
@@ -33,11 +33,17 @@ function assertCreateItemRequestPayload(body) {
|
|
|
33
33
|
if (typeof body !== 'object' || body === null) {
|
|
34
34
|
throw new BadRequestError('Invalid CreateItemRequestPayload');
|
|
35
35
|
}
|
|
36
|
+
if (Object.keys(body).length === 0) {
|
|
37
|
+
throw new BadRequestError('Empty CreateItemRequestPayload');
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
function assertUpdateItemRequestPayload(body) {
|
|
38
41
|
if (typeof body !== 'object' || body === null) {
|
|
39
42
|
throw new BadRequestError('Invalid UpdateItemRequestPayload');
|
|
40
43
|
}
|
|
44
|
+
if (Object.keys(body).length === 0) {
|
|
45
|
+
throw new BadRequestError('Empty UpdateItemRequestPayload');
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
function assertWebhookParseRequestPayload(body) {
|
|
43
49
|
if (typeof body !== 'object' || body === null) {
|
package/dist/src/index.cjs
CHANGED
|
@@ -481,11 +481,17 @@ function assertCreateItemRequestPayload(body) {
|
|
|
481
481
|
if (typeof body !== 'object' || body === null) {
|
|
482
482
|
throw new BadRequestError('Invalid CreateItemRequestPayload');
|
|
483
483
|
}
|
|
484
|
+
if (Object.keys(body).length === 0) {
|
|
485
|
+
throw new BadRequestError('Empty CreateItemRequestPayload');
|
|
486
|
+
}
|
|
484
487
|
}
|
|
485
488
|
function assertUpdateItemRequestPayload(body) {
|
|
486
489
|
if (typeof body !== 'object' || body === null) {
|
|
487
490
|
throw new BadRequestError('Invalid UpdateItemRequestPayload');
|
|
488
491
|
}
|
|
492
|
+
if (Object.keys(body).length === 0) {
|
|
493
|
+
throw new BadRequestError('Empty UpdateItemRequestPayload');
|
|
494
|
+
}
|
|
489
495
|
}
|
|
490
496
|
function assertWebhookParseRequestPayload(body) {
|
|
491
497
|
if (typeof body !== 'object' || body === null) {
|
|
@@ -160,11 +160,13 @@ describe('Handler', () => {
|
|
|
160
160
|
await assert.doesNotReject(async () => await executeHandler(createHandler, { body: { foo: 'bar' } }));
|
|
161
161
|
await assert.rejects(async () => await executeHandler(createHandler, { body: null }), BadRequestError);
|
|
162
162
|
await assert.rejects(async () => await executeHandler(createHandler, { body: 'not json' }), BadRequestError);
|
|
163
|
+
await assert.rejects(async () => await executeHandler(createHandler, { body: {} }), BadRequestError);
|
|
163
164
|
// UpdateItemRequestPayload.
|
|
164
|
-
const updateHandler = routes[
|
|
165
|
+
const updateHandler = routes[1].route.stack[0].handle;
|
|
165
166
|
await assert.doesNotReject(async () => await executeHandler(updateHandler, { body: { foo: 'bar' } }));
|
|
166
167
|
await assert.rejects(async () => await executeHandler(updateHandler, { body: null }), BadRequestError);
|
|
167
168
|
await assert.rejects(async () => await executeHandler(updateHandler, { body: 'not json' }), BadRequestError);
|
|
169
|
+
await assert.rejects(async () => await executeHandler(updateHandler, { body: {} }), BadRequestError);
|
|
168
170
|
});
|
|
169
171
|
});
|
|
170
172
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unito/integration-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Integration SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@types/express": "5.x",
|
|
56
|
-
"@unito/integration-api": "
|
|
56
|
+
"@unito/integration-api": "5.x",
|
|
57
57
|
"busboy": "^1.6.0",
|
|
58
58
|
"cachette": "4.x",
|
|
59
59
|
"express": "^5.1",
|
package/src/handler.ts
CHANGED
|
@@ -216,12 +216,18 @@ function assertCreateItemRequestPayload(body: unknown): asserts body is API.Crea
|
|
|
216
216
|
if (typeof body !== 'object' || body === null) {
|
|
217
217
|
throw new BadRequestError('Invalid CreateItemRequestPayload');
|
|
218
218
|
}
|
|
219
|
+
if (Object.keys(body).length === 0) {
|
|
220
|
+
throw new BadRequestError('Empty CreateItemRequestPayload');
|
|
221
|
+
}
|
|
219
222
|
}
|
|
220
223
|
|
|
221
224
|
function assertUpdateItemRequestPayload(body: unknown): asserts body is API.UpdateItemRequestPayload {
|
|
222
225
|
if (typeof body !== 'object' || body === null) {
|
|
223
226
|
throw new BadRequestError('Invalid UpdateItemRequestPayload');
|
|
224
227
|
}
|
|
228
|
+
if (Object.keys(body).length === 0) {
|
|
229
|
+
throw new BadRequestError('Empty UpdateItemRequestPayload');
|
|
230
|
+
}
|
|
225
231
|
}
|
|
226
232
|
|
|
227
233
|
function assertWebhookParseRequestPayload(body: unknown): asserts body is API.WebhookParseRequestPayload {
|
package/test/handler.test.ts
CHANGED
|
@@ -201,12 +201,14 @@ describe('Handler', () => {
|
|
|
201
201
|
await assert.doesNotReject(async () => await executeHandler(createHandler, { body: { foo: 'bar' } }));
|
|
202
202
|
await assert.rejects(async () => await executeHandler(createHandler, { body: null }), BadRequestError);
|
|
203
203
|
await assert.rejects(async () => await executeHandler(createHandler, { body: 'not json' }), BadRequestError);
|
|
204
|
+
await assert.rejects(async () => await executeHandler(createHandler, { body: {} }), BadRequestError);
|
|
204
205
|
|
|
205
206
|
// UpdateItemRequestPayload.
|
|
206
|
-
const updateHandler = routes[
|
|
207
|
+
const updateHandler = routes[1]!.route!.stack[0]!.handle;
|
|
207
208
|
await assert.doesNotReject(async () => await executeHandler(updateHandler, { body: { foo: 'bar' } }));
|
|
208
209
|
await assert.rejects(async () => await executeHandler(updateHandler, { body: null }), BadRequestError);
|
|
209
210
|
await assert.rejects(async () => await executeHandler(updateHandler, { body: 'not json' }), BadRequestError);
|
|
211
|
+
await assert.rejects(async () => await executeHandler(updateHandler, { body: {} }), BadRequestError);
|
|
210
212
|
});
|
|
211
213
|
});
|
|
212
214
|
});
|