@terreno/api 0.26.0 → 0.28.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/__tests__/openApiCompat.test.js +8 -2
- package/dist/actions.openApi.test.js +1 -0
- package/dist/actions.test.js +3 -1
- package/dist/api.arrayOperations.test.js +1 -0
- package/dist/api.coverage.test.d.ts +1 -0
- package/dist/api.coverage.test.js +193 -0
- package/dist/api.errorPaths.test.d.ts +1 -0
- package/dist/api.errorPaths.test.js +280 -0
- package/dist/api.errors.test.js +7 -7
- package/dist/api.hooks.test.js +66 -8
- package/dist/api.js +245 -206
- package/dist/api.query.test.js +1 -0
- package/dist/api.test.js +11 -4
- package/dist/auth.js +1 -0
- package/dist/auth.test.js +123 -1
- package/dist/betterAuthSetup.js +1 -0
- package/dist/betterAuthSetup.test.js +1 -0
- package/dist/config.js +7 -4
- package/dist/config.test.js +28 -3
- package/dist/configuration.test.js +1 -0
- package/dist/configurationApp.js +1 -0
- package/dist/configurationPlugin.test.js +80 -0
- package/dist/consentApp.test.js +1 -0
- package/dist/docLoader.js +16 -54
- package/dist/docLoader.test.js +2 -1
- package/dist/envConfigurationPlugin.js +1 -0
- package/dist/errors.d.ts +72 -5
- package/dist/errors.js +265 -67
- package/dist/errors.test.js +163 -13
- package/dist/example.js +3 -2
- package/dist/expressServer.test.js +1 -0
- package/dist/githubAuth.js +2 -0
- package/dist/githubAuth.test.js +1 -0
- package/dist/httpClient.d.ts +2 -3
- package/dist/httpClient.js +4 -4
- package/dist/httpClient.test.js +3 -2
- package/dist/logger.test.js +107 -0
- package/dist/notifiers/googleChatNotifier.test.js +2 -1
- package/dist/notifiers/slackNotifier.test.js +1 -1
- package/dist/notifiers/zoomNotifier.test.js +2 -1
- package/dist/openApi.test.js +1 -0
- package/dist/openApiBuilder.js +2 -1
- package/dist/openApiBuilder.test.js +3 -2
- package/dist/openApiValidator.js +1 -0
- package/dist/openApiValidator.test.js +41 -0
- package/dist/permissions.js +0 -2
- package/dist/permissions.middleware.test.js +8 -42
- package/dist/permissions.test.js +1 -0
- package/dist/plugins.js +8 -0
- package/dist/plugins.test.js +5 -2
- package/dist/populate.js +4 -2
- package/dist/populate.test.js +1 -0
- package/dist/realtime/realtime.test.js +13 -3
- package/dist/realtime/types.d.ts +1 -1
- package/dist/requestContext.test.js +28 -0
- package/dist/terrenoApp.js +1 -0
- package/dist/tests/createTestData.js +11 -6
- package/dist/tests/models.js +1 -0
- package/dist/transformers.js +4 -2
- package/dist/vendor/wesleytodd-openapi/lib/generate-doc.js +3 -1
- package/package.json +7 -7
- package/src/__tests__/openApiCompat.test.ts +8 -2
- package/src/actions.openApi.test.ts +1 -0
- package/src/actions.test.ts +3 -1
- package/src/api.arrayOperations.test.ts +1 -0
- package/src/api.coverage.test.ts +123 -0
- package/src/api.errorPaths.test.ts +173 -0
- package/src/api.errors.test.ts +7 -7
- package/src/api.hooks.test.ts +25 -1
- package/src/api.query.test.ts +1 -0
- package/src/api.test.ts +11 -4
- package/src/api.ts +106 -57
- package/src/auth.test.ts +92 -3
- package/src/auth.ts +6 -0
- package/src/betterAuthSetup.test.ts +1 -0
- package/src/betterAuthSetup.ts +3 -0
- package/src/config.test.ts +25 -3
- package/src/config.ts +7 -4
- package/src/configuration.test.ts +1 -0
- package/src/configurationApp.ts +2 -0
- package/src/configurationPlugin.test.ts +46 -1
- package/src/consentApp.test.ts +1 -0
- package/src/docLoader.test.ts +2 -1
- package/src/docLoader.ts +17 -20
- package/src/envConfigurationPlugin.ts +2 -0
- package/src/errors.test.ts +178 -13
- package/src/errors.ts +278 -79
- package/src/example.ts +3 -2
- package/src/expressServer.test.ts +1 -0
- package/src/expressServer.ts +4 -2
- package/src/githubAuth.test.ts +1 -0
- package/src/githubAuth.ts +2 -0
- package/src/httpClient.test.ts +3 -2
- package/src/httpClient.ts +4 -4
- package/src/logger.test.ts +78 -0
- package/src/notifiers/googleChatNotifier.test.ts +2 -2
- package/src/notifiers/slackNotifier.test.ts +2 -2
- package/src/notifiers/zoomNotifier.test.ts +2 -2
- package/src/openApi.test.ts +1 -0
- package/src/openApiBuilder.test.ts +7 -6
- package/src/openApiBuilder.ts +2 -1
- package/src/openApiValidator.test.ts +64 -0
- package/src/openApiValidator.ts +1 -0
- package/src/permissions.middleware.test.ts +8 -11
- package/src/permissions.test.ts +1 -0
- package/src/permissions.ts +0 -2
- package/src/plugins.test.ts +5 -2
- package/src/plugins.ts +9 -0
- package/src/populate.test.ts +1 -0
- package/src/populate.ts +4 -2
- package/src/realtime/realtime.test.ts +13 -3
- package/src/realtime/realtimeApp.ts +1 -0
- package/src/realtime/registry.ts +1 -0
- package/src/realtime/types.ts +1 -2
- package/src/requestContext.test.ts +32 -0
- package/src/terrenoApp.ts +1 -0
- package/src/tests/createTestData.ts +11 -6
- package/src/tests/models.ts +1 -0
- package/src/transformers.ts +4 -2
- package/src/vendor/wesleytodd-openapi/lib/generate-doc.js +4 -1
- package/tsconfig.json +4 -4
- /package/{types.d.ts → src/types.d.ts} +0 -0
package/dist/api.hooks.test.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -55,30 +88,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
55
88
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56
89
|
};
|
|
57
90
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
+
// noExplicitAny: test mock typing
|
|
58
92
|
// biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
|
|
59
93
|
var bun_test_1 = require("bun:test");
|
|
94
|
+
var Sentry = __importStar(require("@sentry/bun"));
|
|
60
95
|
var supertest_1 = __importDefault(require("supertest"));
|
|
61
96
|
var api_1 = require("./api");
|
|
62
97
|
var auth_1 = require("./auth");
|
|
63
98
|
var errors_1 = require("./errors");
|
|
64
99
|
var permissions_1 = require("./permissions");
|
|
65
100
|
var tests_1 = require("./tests");
|
|
101
|
+
var captureExceptionMock = Sentry.captureException;
|
|
66
102
|
(0, bun_test_1.describe)("pre and post hooks", function () {
|
|
67
103
|
var server;
|
|
68
104
|
var app;
|
|
69
105
|
var agent;
|
|
70
106
|
(0, bun_test_1.beforeEach)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
|
|
72
|
-
|
|
107
|
+
var _a;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
73
110
|
case 0: return [4 /*yield*/, (0, tests_1.setupDb)()];
|
|
74
111
|
case 1:
|
|
75
|
-
|
|
112
|
+
_b.sent();
|
|
76
113
|
app = (0, tests_1.getBaseServer)();
|
|
77
114
|
(0, auth_1.setupAuth)(app, tests_1.UserModel);
|
|
78
115
|
(0, auth_1.addAuthRoutes)(app, tests_1.UserModel);
|
|
79
116
|
return [4 /*yield*/, (0, tests_1.authAsUser)(app, "notAdmin")];
|
|
80
117
|
case 2:
|
|
81
|
-
agent =
|
|
118
|
+
agent = _b.sent();
|
|
119
|
+
(_a = captureExceptionMock.mockClear) === null || _a === void 0 ? void 0 : _a.call(captureExceptionMock);
|
|
82
120
|
return [2 /*return*/];
|
|
83
121
|
}
|
|
84
122
|
});
|
|
@@ -333,7 +371,10 @@ var tests_1 = require("./tests");
|
|
|
333
371
|
case 1:
|
|
334
372
|
res = _a.sent();
|
|
335
373
|
(0, bun_test_1.expect)(res.body.title).toBe("Custom preCreate error");
|
|
374
|
+
// Serialized when true so the frontend can suppress duplicate Sentry reporting; also
|
|
375
|
+
// suppresses Sentry capture in apiErrorMiddleware.
|
|
336
376
|
(0, bun_test_1.expect)(res.body.disableExternalErrorTracking).toBe(true);
|
|
377
|
+
(0, bun_test_1.expect)(captureExceptionMock).not.toHaveBeenCalled();
|
|
337
378
|
return [2 /*return*/];
|
|
338
379
|
}
|
|
339
380
|
});
|
|
@@ -369,7 +410,10 @@ var tests_1 = require("./tests");
|
|
|
369
410
|
case 1:
|
|
370
411
|
res = _a.sent();
|
|
371
412
|
(0, bun_test_1.expect)(res.body.title).toContain("preCreate hook error");
|
|
413
|
+
// Serialized when true so the frontend can suppress duplicate Sentry reporting; also
|
|
414
|
+
// suppresses Sentry capture in apiErrorMiddleware.
|
|
372
415
|
(0, bun_test_1.expect)(res.body.disableExternalErrorTracking).toBe(true);
|
|
416
|
+
(0, bun_test_1.expect)(captureExceptionMock).not.toHaveBeenCalled();
|
|
373
417
|
return [2 /*return*/];
|
|
374
418
|
}
|
|
375
419
|
});
|
|
@@ -422,7 +466,10 @@ var tests_1 = require("./tests");
|
|
|
422
466
|
case 3:
|
|
423
467
|
res = _a.sent();
|
|
424
468
|
(0, bun_test_1.expect)(res.body.title).toBe("Custom preUpdate error");
|
|
469
|
+
// Serialized when true so the frontend can suppress duplicate Sentry reporting; also
|
|
470
|
+
// suppresses Sentry capture in apiErrorMiddleware.
|
|
425
471
|
(0, bun_test_1.expect)(res.body.disableExternalErrorTracking).toBe(true);
|
|
472
|
+
(0, bun_test_1.expect)(captureExceptionMock).not.toHaveBeenCalled();
|
|
426
473
|
return [2 /*return*/];
|
|
427
474
|
}
|
|
428
475
|
});
|
|
@@ -473,7 +520,10 @@ var tests_1 = require("./tests");
|
|
|
473
520
|
case 3:
|
|
474
521
|
res = _a.sent();
|
|
475
522
|
(0, bun_test_1.expect)(res.body.title).toContain("preUpdate hook error");
|
|
523
|
+
// Serialized when true so the frontend can suppress duplicate Sentry reporting; also
|
|
524
|
+
// suppresses Sentry capture in apiErrorMiddleware.
|
|
476
525
|
(0, bun_test_1.expect)(res.body.disableExternalErrorTracking).toBe(true);
|
|
526
|
+
(0, bun_test_1.expect)(captureExceptionMock).not.toHaveBeenCalled();
|
|
477
527
|
return [2 /*return*/];
|
|
478
528
|
}
|
|
479
529
|
});
|
|
@@ -519,7 +569,10 @@ var tests_1 = require("./tests");
|
|
|
519
569
|
case 3:
|
|
520
570
|
res = _a.sent();
|
|
521
571
|
(0, bun_test_1.expect)(res.body.title).toContain("preDelete hook error");
|
|
572
|
+
// Serialized when true so the frontend can suppress duplicate Sentry reporting; also
|
|
573
|
+
// suppresses Sentry capture in apiErrorMiddleware.
|
|
522
574
|
(0, bun_test_1.expect)(res.body.disableExternalErrorTracking).toBe(true);
|
|
575
|
+
(0, bun_test_1.expect)(captureExceptionMock).not.toHaveBeenCalled();
|
|
523
576
|
return [2 /*return*/];
|
|
524
577
|
}
|
|
525
578
|
});
|
|
@@ -533,11 +586,12 @@ var tests_1 = require("./tests");
|
|
|
533
586
|
var spinach;
|
|
534
587
|
(0, bun_test_1.beforeEach)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
535
588
|
var _a;
|
|
536
|
-
|
|
537
|
-
|
|
589
|
+
var _b;
|
|
590
|
+
return __generator(this, function (_c) {
|
|
591
|
+
switch (_c.label) {
|
|
538
592
|
case 0: return [4 /*yield*/, (0, tests_1.setupDb)()];
|
|
539
593
|
case 1:
|
|
540
|
-
_a = __read.apply(void 0, [
|
|
594
|
+
_a = __read.apply(void 0, [_c.sent(), 1]), admin = _a[0];
|
|
541
595
|
return [4 /*yield*/, tests_1.FoodModel.create({
|
|
542
596
|
calories: 1,
|
|
543
597
|
created: new Date("2021-12-03T00:00:20.000Z"),
|
|
@@ -549,10 +603,11 @@ var tests_1 = require("./tests");
|
|
|
549
603
|
},
|
|
550
604
|
})];
|
|
551
605
|
case 2:
|
|
552
|
-
spinach =
|
|
606
|
+
spinach = _c.sent();
|
|
553
607
|
app = (0, tests_1.getBaseServer)();
|
|
554
608
|
(0, auth_1.setupAuth)(app, tests_1.UserModel);
|
|
555
609
|
(0, auth_1.addAuthRoutes)(app, tests_1.UserModel);
|
|
610
|
+
(_b = captureExceptionMock.mockClear) === null || _b === void 0 ? void 0 : _b.call(captureExceptionMock);
|
|
556
611
|
return [2 /*return*/];
|
|
557
612
|
}
|
|
558
613
|
});
|
|
@@ -884,7 +939,10 @@ var tests_1 = require("./tests");
|
|
|
884
939
|
case 2:
|
|
885
940
|
res = _a.sent();
|
|
886
941
|
(0, bun_test_1.expect)(res.body.title).toBe("Custom preDelete APIError");
|
|
942
|
+
// Serialized when true so the frontend can suppress duplicate Sentry reporting; also
|
|
943
|
+
// suppresses Sentry capture in apiErrorMiddleware.
|
|
887
944
|
(0, bun_test_1.expect)(res.body.disableExternalErrorTracking).toBe(true);
|
|
945
|
+
(0, bun_test_1.expect)(captureExceptionMock).not.toHaveBeenCalled();
|
|
888
946
|
return [2 /*return*/];
|
|
889
947
|
}
|
|
890
948
|
});
|