@terreno/api 0.29.0 → 0.31.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 +2 -43
- package/LICENSE +21 -202
- package/dist/actions.js +17 -8
- package/dist/actions.openApi.test.js +1 -3
- package/dist/actions.test.js +8 -5
- package/dist/api.arrayOperations.test.js +16 -8
- package/dist/api.coverage.test.js +2 -3
- package/dist/api.d.ts +3 -2
- package/dist/api.errorPaths.test.js +608 -1
- package/dist/api.errors.test.js +9 -0
- package/dist/api.js +137 -170
- package/dist/api.query.test.js +20 -8
- package/dist/api.test.js +12 -6
- package/dist/auth.coverage.test.d.ts +1 -0
- package/dist/auth.coverage.test.js +202 -0
- package/dist/auth.test.js +159 -0
- package/dist/betterAuthSetup.d.ts +15 -1
- package/dist/betterAuthSetup.js +4 -6
- package/dist/configurationPlugin.js +2 -2
- package/dist/consentApp.test.js +1 -5
- package/dist/docLoader.js +5 -1
- package/dist/envConfigurationPlugin.d.ts +1 -1
- package/dist/envConfigurationPlugin.js +0 -2
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +24 -2
- package/dist/errors.test.js +137 -0
- package/dist/expressServer.js +11 -5
- package/dist/githubAuth.js +1 -4
- package/dist/httpClient.js +5 -1
- package/dist/openApiBuilder.test.js +0 -2
- package/dist/openApiValidator.test.js +34 -0
- package/dist/plugins.d.ts +6 -5
- package/dist/plugins.js +56 -10
- package/dist/plugins.test.js +73 -17
- package/dist/populate.test.js +9 -12
- package/dist/realtime/realtime.test.js +231 -0
- package/dist/realtime/realtimeApp.d.ts +1 -1
- package/dist/realtime/realtimeApp.js +6 -2
- package/dist/realtime/realtimeAppSetup.test.d.ts +1 -0
- package/dist/realtime/realtimeAppSetup.test.js +213 -0
- package/dist/realtime/registry.d.ts +3 -2
- package/dist/tests/models.d.ts +27 -11
- package/dist/tests/models.js +5 -3
- package/dist/tests/testHelper.d.ts +9 -3
- package/package.json +4 -5
- package/src/actions.openApi.test.ts +7 -10
- package/src/actions.test.ts +27 -15
- package/src/actions.ts +21 -12
- package/src/api.arrayOperations.test.ts +16 -8
- package/src/api.coverage.test.ts +9 -10
- package/src/api.errorPaths.test.ts +360 -4
- package/src/api.errors.test.ts +12 -0
- package/src/api.query.test.ts +20 -8
- package/src/api.test.ts +12 -6
- package/src/api.ts +162 -171
- package/src/auth.coverage.test.ts +101 -0
- package/src/auth.test.ts +125 -2
- package/src/betterAuthSetup.ts +7 -7
- package/src/configurationPlugin.ts +2 -2
- package/src/consentApp.test.ts +12 -12
- package/src/docLoader.ts +6 -2
- package/src/envConfigurationPlugin.ts +2 -6
- package/src/errors.test.ts +106 -1
- package/src/errors.ts +25 -1
- package/src/expressServer.ts +11 -5
- package/src/githubAuth.ts +1 -3
- package/src/httpClient.ts +6 -2
- package/src/models/versionConfig.ts +1 -1
- package/src/openApiBuilder.test.ts +24 -9
- package/src/openApiValidator.test.ts +41 -0
- package/src/plugins.test.ts +59 -9
- package/src/plugins.ts +81 -39
- package/src/populate.test.ts +25 -16
- package/src/realtime/changeStreamWatcher.ts +8 -1
- package/src/realtime/realtime.test.ts +239 -0
- package/src/realtime/realtimeApp.ts +8 -5
- package/src/realtime/realtimeAppSetup.test.ts +161 -0
- package/src/realtime/registry.ts +3 -4
- package/src/tests/models.ts +8 -6
package/src/api.test.ts
CHANGED
|
@@ -514,7 +514,8 @@ describe("@terreno/api", () => {
|
|
|
514
514
|
server = supertest(app);
|
|
515
515
|
|
|
516
516
|
const res = await server.get("/food?calories=100").expect(400);
|
|
517
|
-
expect(res.body.title).
|
|
517
|
+
expect(res.body.title).toBe("Query parameter not allowed");
|
|
518
|
+
expect(res.body.detail).toContain("calories is not allowed as a query param");
|
|
518
519
|
});
|
|
519
520
|
|
|
520
521
|
it("queryFilter returning null returns empty array", async () => {
|
|
@@ -626,8 +627,9 @@ describe("@terreno/api", () => {
|
|
|
626
627
|
server = supertest(app);
|
|
627
628
|
|
|
628
629
|
const res = await server.post("/required").send({about: "test"}).expect(400);
|
|
629
|
-
expect(res.body.title).toBe("
|
|
630
|
+
expect(res.body.title).toBe("Validation failed");
|
|
630
631
|
expect(res.body.detail).toContain("Required");
|
|
632
|
+
expect(res.body.meta.fields.name).toContain("required");
|
|
631
633
|
});
|
|
632
634
|
|
|
633
635
|
it("preDelete hook throwing APIError is re-thrown", async () => {
|
|
@@ -1214,7 +1216,8 @@ describe("@terreno/api", () => {
|
|
|
1214
1216
|
agent = await authAsUser(app, "notAdmin");
|
|
1215
1217
|
|
|
1216
1218
|
const res = await agent.post(`/food/${apple._id}/tags`).send({tags: "organic"}).expect(405);
|
|
1217
|
-
expect(res.body.title).
|
|
1219
|
+
expect(res.body.title).toBe("Access denied");
|
|
1220
|
+
expect(res.body.detail).toContain("Access to PATCH");
|
|
1218
1221
|
});
|
|
1219
1222
|
|
|
1220
1223
|
it("array operation on non-existent document returns 404", async () => {
|
|
@@ -1236,7 +1239,8 @@ describe("@terreno/api", () => {
|
|
|
1236
1239
|
|
|
1237
1240
|
const fakeId = "000000000000000000000000";
|
|
1238
1241
|
const res = await agent.post(`/food/${fakeId}/tags`).send({tags: "organic"}).expect(404);
|
|
1239
|
-
expect(res.body.title).
|
|
1242
|
+
expect(res.body.title).toBe("Document not found");
|
|
1243
|
+
expect(res.body.detail).toContain("Could not find document to PATCH");
|
|
1240
1244
|
});
|
|
1241
1245
|
|
|
1242
1246
|
it("array operation denied when user cannot update specific doc", async () => {
|
|
@@ -1259,7 +1263,8 @@ describe("@terreno/api", () => {
|
|
|
1259
1263
|
agent = await authAsUser(app, "notAdmin");
|
|
1260
1264
|
|
|
1261
1265
|
const res = await agent.post(`/food/${apple._id}/tags`).send({tags: "organic"}).expect(403);
|
|
1262
|
-
expect(res.body.title).
|
|
1266
|
+
expect(res.body.title).toBe("Update not allowed");
|
|
1267
|
+
expect(res.body.detail).toContain("Patch not allowed");
|
|
1263
1268
|
});
|
|
1264
1269
|
|
|
1265
1270
|
it("array operation transform error is handled", async () => {
|
|
@@ -1381,8 +1386,9 @@ describe("@terreno/api", () => {
|
|
|
1381
1386
|
|
|
1382
1387
|
// Send without required 'name' field
|
|
1383
1388
|
const res = await server.post("/required").send({about: "test"}).expect(400);
|
|
1384
|
-
expect(res.body.title).toBe("
|
|
1389
|
+
expect(res.body.title).toBe("Validation failed");
|
|
1385
1390
|
expect(res.body.detail).toContain("Required");
|
|
1391
|
+
expect(res.body.meta.fields.name).toContain("required");
|
|
1386
1392
|
});
|
|
1387
1393
|
|
|
1388
1394
|
it("preDelete hook throwing APIError is re-thrown", async () => {
|