@terreno/api 0.3.1 → 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.
Files changed (42) hide show
  1. package/dist/api.js +9 -8
  2. package/dist/betterAuthSetup.js +1 -1
  3. package/dist/configuration.test.d.ts +1 -0
  4. package/dist/configuration.test.js +699 -0
  5. package/dist/configurationApp.d.ts +91 -0
  6. package/dist/configurationApp.js +407 -0
  7. package/dist/configurationPlugin.d.ts +102 -0
  8. package/dist/configurationPlugin.js +285 -0
  9. package/dist/configurationPlugin.test.d.ts +1 -0
  10. package/dist/configurationPlugin.test.js +509 -0
  11. package/dist/example.js +1 -1
  12. package/dist/expressServer.js +5 -1
  13. package/dist/githubAuth.js +2 -2
  14. package/dist/index.d.ts +5 -0
  15. package/dist/index.js +5 -0
  16. package/dist/openApiCompat.d.ts +23 -0
  17. package/dist/openApiCompat.js +198 -0
  18. package/dist/scriptRunner.d.ts +52 -0
  19. package/dist/scriptRunner.js +231 -0
  20. package/dist/secretProviders.d.ts +47 -0
  21. package/dist/secretProviders.js +214 -0
  22. package/dist/terrenoApp.d.ts +25 -0
  23. package/dist/terrenoApp.js +49 -2
  24. package/dist/tests.d.ts +27 -9
  25. package/dist/tests.js +10 -1
  26. package/package.json +13 -13
  27. package/src/api.ts +9 -8
  28. package/src/betterAuthSetup.ts +2 -2
  29. package/src/configuration.test.ts +398 -0
  30. package/src/configurationApp.ts +359 -0
  31. package/src/configurationPlugin.test.ts +299 -0
  32. package/src/configurationPlugin.ts +288 -0
  33. package/src/example.ts +1 -1
  34. package/src/expressServer.ts +6 -1
  35. package/src/githubAuth.ts +4 -4
  36. package/src/index.ts +5 -0
  37. package/src/openApiCompat.ts +147 -0
  38. package/src/permissions.ts +1 -1
  39. package/src/scriptRunner.ts +219 -0
  40. package/src/secretProviders.ts +109 -0
  41. package/src/terrenoApp.ts +44 -2
  42. package/src/tests.ts +12 -1
package/dist/api.js CHANGED
@@ -879,7 +879,7 @@ function _buildModelRouter(model, options) {
879
879
  }); }));
880
880
  function arrayOperation(req, res, operation) {
881
881
  return __awaiter(this, void 0, void 0, function () {
882
- var doc, prevDoc, field, array, index, body, error_17, error_18, error_19;
882
+ var doc, prevDoc, field, itemId, array, index, body, error_17, error_18, error_19;
883
883
  var _a;
884
884
  var _b, _c;
885
885
  return __generator(this, function (_d) {
@@ -911,36 +911,37 @@ function _buildModelRouter(model, options) {
911
911
  title: "Patch not allowed for user ".concat((_c = req.user) === null || _c === void 0 ? void 0 : _c.id, " on doc ").concat(doc._id),
912
912
  });
913
913
  }
914
+ field = req.params.field;
915
+ itemId = req.params.itemId;
914
916
  // We apply the operation *before* the hooks. As far as the callers are concerned, this should
915
917
  // be like PATCHing the field and replacing the whole thing.
916
- if (operation !== "DELETE" && req.body[req.params.field] === undefined) {
918
+ if (operation !== "DELETE" && req.body[field] === undefined) {
917
919
  throw new errors_1.APIError({
918
920
  status: 400,
919
921
  title: "Malformed body, array operations should have a single, top level key, got: ".concat(Object.keys(req.body).join(",")),
920
922
  });
921
923
  }
922
- field = req.params.field;
923
924
  array = __spreadArray([], __read(doc[field]), false);
924
925
  if (operation === "POST") {
925
926
  array.push(req.body[field]);
926
927
  }
927
928
  else if (operation === "PATCH" || operation === "DELETE") {
928
929
  index = void 0;
929
- if ((0, utils_1.isValidObjectId)(req.params.itemId)) {
930
- index = array.findIndex(function (x) { return x.id === req.params.itemId; });
930
+ if ((0, utils_1.isValidObjectId)(itemId)) {
931
+ index = array.findIndex(function (x) { return x.id === itemId; });
931
932
  }
932
933
  else {
933
- index = array.findIndex(function (x) { return x === req.params.itemId; });
934
+ index = array.findIndex(function (x) { return x === itemId; });
934
935
  }
935
936
  if (index === -1) {
936
937
  throw new errors_1.APIError({
937
938
  status: 404,
938
- title: "Could not find ".concat(field, "/").concat(req.params.itemId),
939
+ title: "Could not find ".concat(field, "/").concat(itemId),
939
940
  });
940
941
  }
941
942
  // For PATCHing an item by ID, we need to merge the objects so we don't override the _id or
942
943
  // other parts of the subdocument.
943
- if (operation === "PATCH" && (0, utils_1.isValidObjectId)(req.params.itemId)) {
944
+ if (operation === "PATCH" && (0, utils_1.isValidObjectId)(itemId)) {
944
945
  Object.assign(array[index], req.body[field]);
945
946
  }
946
947
  else if (operation === "PATCH") {
@@ -235,7 +235,7 @@ var mountBetterAuthRoutes = function (app, auth, basePath) {
235
235
  if (basePath === void 0) { basePath = "/api/auth"; }
236
236
  var handler = (0, node_1.toNodeHandler)(auth);
237
237
  // Mount at the base path with wildcard
238
- app.all("".concat(basePath, "/*"), function (req, res) {
238
+ app.all("".concat(basePath, "/*path"), function (req, res) {
239
239
  return handler(req, res);
240
240
  });
241
241
  logger_1.logger.info("Better Auth routes mounted at ".concat(basePath, "/*"));
@@ -0,0 +1 @@
1
+ export {};