@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.
- package/dist/api.js +9 -8
- package/dist/betterAuthSetup.js +1 -1
- package/dist/configuration.test.d.ts +1 -0
- package/dist/configuration.test.js +699 -0
- package/dist/configurationApp.d.ts +91 -0
- package/dist/configurationApp.js +407 -0
- package/dist/configurationPlugin.d.ts +102 -0
- package/dist/configurationPlugin.js +285 -0
- package/dist/configurationPlugin.test.d.ts +1 -0
- package/dist/configurationPlugin.test.js +509 -0
- package/dist/example.js +1 -1
- package/dist/expressServer.js +5 -1
- package/dist/githubAuth.js +2 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/openApiCompat.d.ts +23 -0
- package/dist/openApiCompat.js +198 -0
- package/dist/scriptRunner.d.ts +52 -0
- package/dist/scriptRunner.js +231 -0
- package/dist/secretProviders.d.ts +47 -0
- package/dist/secretProviders.js +214 -0
- package/dist/terrenoApp.d.ts +25 -0
- package/dist/terrenoApp.js +49 -2
- package/dist/tests.d.ts +27 -9
- package/dist/tests.js +10 -1
- package/package.json +13 -13
- package/src/api.ts +9 -8
- package/src/betterAuthSetup.ts +2 -2
- package/src/configuration.test.ts +398 -0
- package/src/configurationApp.ts +359 -0
- package/src/configurationPlugin.test.ts +299 -0
- package/src/configurationPlugin.ts +288 -0
- package/src/example.ts +1 -1
- package/src/expressServer.ts +6 -1
- package/src/githubAuth.ts +4 -4
- package/src/index.ts +5 -0
- package/src/openApiCompat.ts +147 -0
- package/src/permissions.ts +1 -1
- package/src/scriptRunner.ts +219 -0
- package/src/secretProviders.ts +109 -0
- package/src/terrenoApp.ts +44 -2
- 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[
|
|
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)(
|
|
930
|
-
index = array.findIndex(function (x) { return x.id ===
|
|
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 ===
|
|
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(
|
|
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)(
|
|
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") {
|
package/dist/betterAuthSetup.js
CHANGED
|
@@ -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 {};
|