@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.
Files changed (79) hide show
  1. package/CHANGELOG.md +2 -43
  2. package/LICENSE +21 -202
  3. package/dist/actions.js +17 -8
  4. package/dist/actions.openApi.test.js +1 -3
  5. package/dist/actions.test.js +8 -5
  6. package/dist/api.arrayOperations.test.js +16 -8
  7. package/dist/api.coverage.test.js +2 -3
  8. package/dist/api.d.ts +3 -2
  9. package/dist/api.errorPaths.test.js +608 -1
  10. package/dist/api.errors.test.js +9 -0
  11. package/dist/api.js +137 -170
  12. package/dist/api.query.test.js +20 -8
  13. package/dist/api.test.js +12 -6
  14. package/dist/auth.coverage.test.d.ts +1 -0
  15. package/dist/auth.coverage.test.js +202 -0
  16. package/dist/auth.test.js +159 -0
  17. package/dist/betterAuthSetup.d.ts +15 -1
  18. package/dist/betterAuthSetup.js +4 -6
  19. package/dist/configurationPlugin.js +2 -2
  20. package/dist/consentApp.test.js +1 -5
  21. package/dist/docLoader.js +5 -1
  22. package/dist/envConfigurationPlugin.d.ts +1 -1
  23. package/dist/envConfigurationPlugin.js +0 -2
  24. package/dist/errors.d.ts +14 -0
  25. package/dist/errors.js +24 -2
  26. package/dist/errors.test.js +137 -0
  27. package/dist/expressServer.js +11 -5
  28. package/dist/githubAuth.js +1 -4
  29. package/dist/httpClient.js +5 -1
  30. package/dist/openApiBuilder.test.js +0 -2
  31. package/dist/openApiValidator.test.js +34 -0
  32. package/dist/plugins.d.ts +6 -5
  33. package/dist/plugins.js +56 -10
  34. package/dist/plugins.test.js +73 -17
  35. package/dist/populate.test.js +9 -12
  36. package/dist/realtime/realtime.test.js +231 -0
  37. package/dist/realtime/realtimeApp.d.ts +1 -1
  38. package/dist/realtime/realtimeApp.js +6 -2
  39. package/dist/realtime/realtimeAppSetup.test.d.ts +1 -0
  40. package/dist/realtime/realtimeAppSetup.test.js +213 -0
  41. package/dist/realtime/registry.d.ts +3 -2
  42. package/dist/tests/models.d.ts +27 -11
  43. package/dist/tests/models.js +5 -3
  44. package/dist/tests/testHelper.d.ts +9 -3
  45. package/package.json +4 -5
  46. package/src/actions.openApi.test.ts +7 -10
  47. package/src/actions.test.ts +27 -15
  48. package/src/actions.ts +21 -12
  49. package/src/api.arrayOperations.test.ts +16 -8
  50. package/src/api.coverage.test.ts +9 -10
  51. package/src/api.errorPaths.test.ts +360 -4
  52. package/src/api.errors.test.ts +12 -0
  53. package/src/api.query.test.ts +20 -8
  54. package/src/api.test.ts +12 -6
  55. package/src/api.ts +162 -171
  56. package/src/auth.coverage.test.ts +101 -0
  57. package/src/auth.test.ts +125 -2
  58. package/src/betterAuthSetup.ts +7 -7
  59. package/src/configurationPlugin.ts +2 -2
  60. package/src/consentApp.test.ts +12 -12
  61. package/src/docLoader.ts +6 -2
  62. package/src/envConfigurationPlugin.ts +2 -6
  63. package/src/errors.test.ts +106 -1
  64. package/src/errors.ts +25 -1
  65. package/src/expressServer.ts +11 -5
  66. package/src/githubAuth.ts +1 -3
  67. package/src/httpClient.ts +6 -2
  68. package/src/models/versionConfig.ts +1 -1
  69. package/src/openApiBuilder.test.ts +24 -9
  70. package/src/openApiValidator.test.ts +41 -0
  71. package/src/plugins.test.ts +59 -9
  72. package/src/plugins.ts +81 -39
  73. package/src/populate.test.ts +25 -16
  74. package/src/realtime/changeStreamWatcher.ts +8 -1
  75. package/src/realtime/realtime.test.ts +239 -0
  76. package/src/realtime/realtimeApp.ts +8 -5
  77. package/src/realtime/realtimeAppSetup.test.ts +161 -0
  78. package/src/realtime/registry.ts +3 -4
  79. 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).toContain("calories is not allowed as a query param");
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("Create error");
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).toContain("Access to PATCH");
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).toContain("Could not find document to PATCH");
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).toContain("Patch not allowed");
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("Create error");
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 () => {