@terreno/api 0.31.0 → 56.0.0-beta.2

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 (232) hide show
  1. package/dist/api.d.ts +10 -0
  2. package/dist/api.js +110 -361
  3. package/dist/auth.d.ts +26 -0
  4. package/dist/auth.js +121 -26
  5. package/dist/betterAuth.d.ts +5 -0
  6. package/dist/betterAuthSetup.js +23 -4
  7. package/dist/docLoader.js +12 -9
  8. package/dist/errors.d.ts +13 -0
  9. package/dist/errors.js +29 -1
  10. package/dist/index.d.ts +17 -1
  11. package/dist/index.js +29 -1
  12. package/dist/middleware.d.ts +7 -0
  13. package/dist/middleware.js +16 -1
  14. package/dist/openApiCompat.d.ts +10 -1
  15. package/dist/openApiCompat.js +115 -47
  16. package/dist/permissions.d.ts +27 -0
  17. package/dist/permissions.js +42 -1
  18. package/dist/plugins.d.ts +13 -0
  19. package/dist/plugins.js +47 -1
  20. package/dist/realtime/changeStreamWatcher.d.ts +100 -3
  21. package/dist/realtime/changeStreamWatcher.js +542 -137
  22. package/dist/realtime/realtimeApp.d.ts +2 -0
  23. package/dist/realtime/realtimeApp.js +83 -27
  24. package/dist/realtime/sessionRevalidation.d.ts +90 -0
  25. package/dist/realtime/sessionRevalidation.js +438 -0
  26. package/dist/realtime/socketAuth.d.ts +97 -0
  27. package/dist/realtime/socketAuth.js +272 -0
  28. package/dist/realtime/socketUser.d.ts +54 -0
  29. package/dist/realtime/socketUser.js +75 -5
  30. package/dist/realtime/types.d.ts +54 -0
  31. package/dist/secretProviders.d.ts +23 -0
  32. package/dist/secretProviders.js +9 -3
  33. package/dist/sync/executors.d.ts +198 -0
  34. package/dist/sync/executors.js +670 -0
  35. package/dist/sync/loadHarness.js +807 -0
  36. package/dist/sync/models.d.ts +216 -0
  37. package/dist/sync/models.js +644 -0
  38. package/dist/sync/mutationHandler.d.ts +97 -0
  39. package/dist/sync/mutationHandler.js +886 -0
  40. package/dist/sync/registry.d.ts +73 -0
  41. package/dist/sync/registry.js +223 -0
  42. package/dist/sync/routes.d.ts +62 -0
  43. package/dist/sync/routes.js +936 -0
  44. package/dist/sync/scripts/compactTombstones.d.ts +47 -0
  45. package/dist/sync/scripts/compactTombstones.js +270 -0
  46. package/dist/sync/serialize.d.ts +20 -0
  47. package/dist/{tests/bunSetup.js → sync/serialize.js} +35 -68
  48. package/dist/sync/socketHandlers.d.ts +54 -0
  49. package/dist/sync/socketHandlers.js +470 -0
  50. package/dist/sync/streams.d.ts +85 -0
  51. package/dist/sync/streams.js +221 -0
  52. package/dist/sync/syncApp.d.ts +29 -0
  53. package/dist/sync/syncApp.js +44 -0
  54. package/dist/sync/syncBatch.d.ts +71 -0
  55. package/dist/sync/syncBatch.js +252 -0
  56. package/dist/sync/syncSeqPlugin.d.ts +8 -0
  57. package/dist/sync/syncSeqPlugin.js +899 -0
  58. package/dist/sync/types.d.ts +254 -0
  59. package/dist/sync/types.js +9 -0
  60. package/dist/terrenoApp.js +90 -27
  61. package/dist/vendor/wesleytodd-openapi/index.d.ts +1 -1
  62. package/dist/vendor/wesleytodd-openapi/lib/ui.d.ts +2 -1
  63. package/package.json +7 -6
  64. package/src/__tests__/openApiCompat.test.ts +20 -0
  65. package/src/api.errors.test.ts +32 -23
  66. package/src/api.test.ts +12 -0
  67. package/src/api.ts +87 -296
  68. package/src/auth.test.ts +202 -0
  69. package/src/auth.ts +134 -23
  70. package/src/betterAuth.ts +6 -0
  71. package/src/betterAuthSetup.test.ts +34 -0
  72. package/src/betterAuthSetup.ts +20 -1
  73. package/src/configuration.test.ts +59 -38
  74. package/src/configurationPlugin.test.ts +72 -42
  75. package/src/docLoader.ts +3 -1
  76. package/src/errors.ts +33 -0
  77. package/src/expressServer.test.ts +7 -1
  78. package/src/index.ts +42 -0
  79. package/src/middleware.test.ts +56 -1
  80. package/src/middleware.ts +15 -0
  81. package/src/openApiCompat.ts +99 -45
  82. package/src/permissions.test.ts +101 -17
  83. package/src/permissions.ts +49 -0
  84. package/src/plugins.test.ts +64 -0
  85. package/src/plugins.ts +56 -0
  86. package/src/realtime/changeStreamWatcher.ts +552 -114
  87. package/src/realtime/realtime.test.ts +157 -0
  88. package/src/realtime/realtimeApp.ts +82 -14
  89. package/src/realtime/realtimeAppSetup.test.ts +25 -27
  90. package/src/realtime/sessionRevalidation.test.ts +423 -0
  91. package/src/realtime/sessionRevalidation.ts +273 -0
  92. package/src/realtime/socketAuth.test.ts +355 -0
  93. package/src/realtime/socketAuth.ts +228 -0
  94. package/src/realtime/socketUser.ts +69 -0
  95. package/src/realtime/types.ts +54 -0
  96. package/src/secretProviders.test.ts +7 -1
  97. package/src/secretProviders.ts +15 -3
  98. package/src/secretProvidersGcpClient.test.ts +66 -0
  99. package/src/sync/ensureSyncIndexes.test.ts +144 -0
  100. package/src/sync/executors.test.ts +882 -0
  101. package/src/sync/executors.ts +705 -0
  102. package/src/sync/integration.test.ts +1160 -0
  103. package/src/sync/loadHarness.ts +618 -0
  104. package/src/sync/models.ts +641 -0
  105. package/src/sync/mutationHandler.test.ts +1252 -0
  106. package/src/sync/mutationHandler.ts +850 -0
  107. package/src/sync/registry.ts +232 -0
  108. package/src/sync/routes.ts +812 -0
  109. package/src/sync/scripts/compactTombstones.test.ts +249 -0
  110. package/src/sync/scripts/compactTombstones.ts +145 -0
  111. package/src/sync/serialize.ts +48 -0
  112. package/src/sync/sessionRevalidationIntegration.test.ts +281 -0
  113. package/src/sync/socketHandlers.ts +320 -0
  114. package/src/sync/streams.ts +188 -0
  115. package/src/sync/sync.test.ts +582 -0
  116. package/src/sync/syncApp.ts +44 -0
  117. package/src/sync/syncBatch.ts +219 -0
  118. package/src/sync/syncFrontier.test.ts +494 -0
  119. package/src/sync/syncPhaseC.test.ts +718 -0
  120. package/src/sync/syncRoutes.test.ts +865 -0
  121. package/src/sync/syncSeqPlugin.ts +730 -0
  122. package/src/sync/syncSocket.test.ts +1440 -0
  123. package/src/sync/types.ts +270 -0
  124. package/src/terrenoApp.ts +37 -17
  125. package/src/tests/bunSetup.ts +8 -0
  126. package/tsconfig.json +4 -4
  127. package/tsconfig.typedoc.json +7 -1
  128. package/dist/__tests__/openApiCompat.test.js +0 -317
  129. package/dist/__tests__/versionCheckPlugin.test.d.ts +0 -1
  130. package/dist/__tests__/versionCheckPlugin.test.js +0 -597
  131. package/dist/actions.openApi.test.d.ts +0 -1
  132. package/dist/actions.openApi.test.js +0 -253
  133. package/dist/actions.test.d.ts +0 -1
  134. package/dist/actions.test.js +0 -1087
  135. package/dist/api.arrayOperations.test.d.ts +0 -1
  136. package/dist/api.arrayOperations.test.js +0 -878
  137. package/dist/api.asyncHandler.test.d.ts +0 -1
  138. package/dist/api.asyncHandler.test.js +0 -236
  139. package/dist/api.coverage.test.d.ts +0 -1
  140. package/dist/api.coverage.test.js +0 -192
  141. package/dist/api.errorPaths.test.d.ts +0 -1
  142. package/dist/api.errorPaths.test.js +0 -887
  143. package/dist/api.errors.test.d.ts +0 -1
  144. package/dist/api.errors.test.js +0 -185
  145. package/dist/api.hooks.test.d.ts +0 -1
  146. package/dist/api.hooks.test.js +0 -950
  147. package/dist/api.query.test.d.ts +0 -1
  148. package/dist/api.query.test.js +0 -948
  149. package/dist/api.test.d.ts +0 -1
  150. package/dist/api.test.js +0 -2820
  151. package/dist/auth.compile.test.d.ts +0 -1
  152. package/dist/auth.compile.test.js +0 -201
  153. package/dist/auth.coverage.test.d.ts +0 -1
  154. package/dist/auth.coverage.test.js +0 -202
  155. package/dist/auth.test.d.ts +0 -1
  156. package/dist/auth.test.js +0 -2286
  157. package/dist/betterAuth.test.d.ts +0 -1
  158. package/dist/betterAuth.test.js +0 -181
  159. package/dist/betterAuthApp.test.d.ts +0 -1
  160. package/dist/betterAuthApp.test.js +0 -242
  161. package/dist/betterAuthSetup.test.d.ts +0 -1
  162. package/dist/betterAuthSetup.test.js +0 -762
  163. package/dist/config.test.d.ts +0 -1
  164. package/dist/config.test.js +0 -353
  165. package/dist/configuration.test.d.ts +0 -1
  166. package/dist/configuration.test.js +0 -980
  167. package/dist/configurationPlugin.test.d.ts +0 -1
  168. package/dist/configurationPlugin.test.js +0 -827
  169. package/dist/consentApp.test.d.ts +0 -1
  170. package/dist/consentApp.test.js +0 -1411
  171. package/dist/docLoader.test.d.ts +0 -1
  172. package/dist/docLoader.test.js +0 -137
  173. package/dist/envConfigurationPlugin.test.d.ts +0 -1
  174. package/dist/envConfigurationPlugin.test.js +0 -369
  175. package/dist/errors.test.d.ts +0 -1
  176. package/dist/errors.test.js +0 -607
  177. package/dist/expressServer.test.d.ts +0 -1
  178. package/dist/expressServer.test.js +0 -1249
  179. package/dist/githubAuth.test.d.ts +0 -1
  180. package/dist/githubAuth.test.js +0 -1142
  181. package/dist/httpClient.test.d.ts +0 -1
  182. package/dist/httpClient.test.js +0 -1471
  183. package/dist/logger.test.d.ts +0 -1
  184. package/dist/logger.test.js +0 -685
  185. package/dist/middleware.test.d.ts +0 -1
  186. package/dist/middleware.test.js +0 -241
  187. package/dist/notifiers/googleChatNotifier.test.d.ts +0 -1
  188. package/dist/notifiers/googleChatNotifier.test.js +0 -298
  189. package/dist/notifiers/slackNotifier.test.d.ts +0 -1
  190. package/dist/notifiers/slackNotifier.test.js +0 -297
  191. package/dist/notifiers/zoomNotifier.test.d.ts +0 -1
  192. package/dist/notifiers/zoomNotifier.test.js +0 -373
  193. package/dist/openApi.test.d.ts +0 -1
  194. package/dist/openApi.test.js +0 -620
  195. package/dist/openApiBuilder.test.d.ts +0 -1
  196. package/dist/openApiBuilder.test.js +0 -599
  197. package/dist/openApiEtag.test.d.ts +0 -1
  198. package/dist/openApiEtag.test.js +0 -86
  199. package/dist/openApiValidator.test.d.ts +0 -1
  200. package/dist/openApiValidator.test.js +0 -795
  201. package/dist/permissions.middleware.test.d.ts +0 -1
  202. package/dist/permissions.middleware.test.js +0 -308
  203. package/dist/permissions.test.d.ts +0 -1
  204. package/dist/permissions.test.js +0 -439
  205. package/dist/plugins.test.d.ts +0 -1
  206. package/dist/plugins.test.js +0 -902
  207. package/dist/populate.test.d.ts +0 -1
  208. package/dist/populate.test.js +0 -370
  209. package/dist/realtime/realtime.test.d.ts +0 -10
  210. package/dist/realtime/realtime.test.js +0 -4213
  211. package/dist/realtime/realtimeAppSetup.test.d.ts +0 -1
  212. package/dist/realtime/realtimeAppSetup.test.js +0 -213
  213. package/dist/requestContext.test.d.ts +0 -1
  214. package/dist/requestContext.test.js +0 -412
  215. package/dist/scriptRunner.test.d.ts +0 -1
  216. package/dist/scriptRunner.test.js +0 -386
  217. package/dist/secretProviders.test.d.ts +0 -1
  218. package/dist/secretProviders.test.js +0 -726
  219. package/dist/syncConsents.test.d.ts +0 -1
  220. package/dist/syncConsents.test.js +0 -522
  221. package/dist/terrenoApp.test.d.ts +0 -1
  222. package/dist/terrenoApp.test.js +0 -489
  223. package/dist/tests/bunSetup.d.ts +0 -1
  224. package/dist/tests/fixtures/compileAuthEntry.d.ts +0 -1
  225. package/dist/tests/fixtures/compileAuthEntry.js +0 -37
  226. package/dist/tests/testEnv.d.ts +0 -0
  227. package/dist/tests/testEnv.js +0 -6
  228. package/dist/transformers.test.d.ts +0 -1
  229. package/dist/transformers.test.js +0 -423
  230. package/dist/utils.test.d.ts +0 -1
  231. package/dist/utils.test.js +0 -242
  232. /package/dist/{__tests__/openApiCompat.test.d.ts → sync/loadHarness.d.ts} +0 -0
@@ -1 +0,0 @@
1
- export {};
@@ -1,522 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- var bun_test_1 = require("bun:test");
51
- var consentForm_1 = require("./models/consentForm");
52
- var syncConsents_1 = require("./syncConsents");
53
- var testHelper_1 = require("./tests/testHelper");
54
- var baseDef = {
55
- content: { en: "# Terms\nPlease agree." },
56
- order: 1,
57
- required: true,
58
- title: "Terms of Service",
59
- type: "terms",
60
- };
61
- (0, bun_test_1.describe)("syncConsents", function () {
62
- (0, bun_test_1.beforeEach)(function () { return __awaiter(void 0, void 0, void 0, function () {
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0: return [4 /*yield*/, (0, testHelper_1.setupDb)()];
66
- case 1:
67
- _a.sent();
68
- return [4 /*yield*/, consentForm_1.ConsentForm.deleteMany({})];
69
- case 2:
70
- _a.sent();
71
- return [2 /*return*/];
72
- }
73
- });
74
- }); });
75
- (0, bun_test_1.afterEach)(function () { return __awaiter(void 0, void 0, void 0, function () {
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0: return [4 /*yield*/, consentForm_1.ConsentForm.deleteMany({})];
79
- case 1:
80
- _a.sent();
81
- return [2 /*return*/];
82
- }
83
- });
84
- }); });
85
- (0, bun_test_1.it)("creates a new consent form when none exists", function () { return __awaiter(void 0, void 0, void 0, function () {
86
- var result, forms;
87
- return __generator(this, function (_a) {
88
- switch (_a.label) {
89
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
90
- case 1:
91
- result = _a.sent();
92
- (0, bun_test_1.expect)(result.created).toEqual(["terms"]);
93
- (0, bun_test_1.expect)(result.updated).toHaveLength(0);
94
- (0, bun_test_1.expect)(result.unchanged).toHaveLength(0);
95
- return [4 /*yield*/, consentForm_1.ConsentForm.find({ slug: "terms" })];
96
- case 2:
97
- forms = _a.sent();
98
- (0, bun_test_1.expect)(forms).toHaveLength(1);
99
- (0, bun_test_1.expect)(forms[0].active).toBe(true);
100
- (0, bun_test_1.expect)(forms[0].version).toBe(1);
101
- (0, bun_test_1.expect)(forms[0].title).toBe("Terms of Service");
102
- return [2 /*return*/];
103
- }
104
- });
105
- }); });
106
- (0, bun_test_1.it)("leaves unchanged forms alone", function () { return __awaiter(void 0, void 0, void 0, function () {
107
- var result, forms;
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
111
- case 1:
112
- _a.sent();
113
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
114
- case 2:
115
- result = _a.sent();
116
- (0, bun_test_1.expect)(result.unchanged).toEqual(["terms"]);
117
- (0, bun_test_1.expect)(result.created).toHaveLength(0);
118
- (0, bun_test_1.expect)(result.updated).toHaveLength(0);
119
- return [4 /*yield*/, consentForm_1.ConsentForm.find({ slug: "terms" })];
120
- case 3:
121
- forms = _a.sent();
122
- (0, bun_test_1.expect)(forms).toHaveLength(1);
123
- (0, bun_test_1.expect)(forms[0].version).toBe(1);
124
- return [2 /*return*/];
125
- }
126
- });
127
- }); });
128
- (0, bun_test_1.it)("publishes a new version when content changes", function () { return __awaiter(void 0, void 0, void 0, function () {
129
- var updated, result, forms;
130
- return __generator(this, function (_a) {
131
- switch (_a.label) {
132
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
133
- case 1:
134
- _a.sent();
135
- updated = __assign(__assign({}, baseDef), { content: { en: "# Updated Terms\nNew content." } });
136
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
137
- case 2:
138
- result = _a.sent();
139
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
140
- return [4 /*yield*/, consentForm_1.ConsentForm.find({ slug: "terms" }).sort({ version: 1 })];
141
- case 3:
142
- forms = _a.sent();
143
- (0, bun_test_1.expect)(forms).toHaveLength(2);
144
- (0, bun_test_1.expect)(forms[0].active).toBe(false);
145
- (0, bun_test_1.expect)(forms[0].version).toBe(1);
146
- (0, bun_test_1.expect)(forms[1].active).toBe(true);
147
- (0, bun_test_1.expect)(forms[1].version).toBe(2);
148
- return [2 /*return*/];
149
- }
150
- });
151
- }); });
152
- (0, bun_test_1.it)("publishes a new version when title changes", function () { return __awaiter(void 0, void 0, void 0, function () {
153
- var updated, result, active;
154
- return __generator(this, function (_a) {
155
- switch (_a.label) {
156
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
157
- case 1:
158
- _a.sent();
159
- updated = __assign(__assign({}, baseDef), { title: "Updated Terms" });
160
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
161
- case 2:
162
- result = _a.sent();
163
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
164
- return [4 /*yield*/, consentForm_1.ConsentForm.findOne({ active: true, slug: "terms" })];
165
- case 3:
166
- active = _a.sent();
167
- (0, bun_test_1.expect)(active === null || active === void 0 ? void 0 : active.version).toBe(2);
168
- (0, bun_test_1.expect)(active === null || active === void 0 ? void 0 : active.title).toBe("Updated Terms");
169
- return [2 /*return*/];
170
- }
171
- });
172
- }); });
173
- (0, bun_test_1.it)("deactivates removed forms when deactivateRemoved is true", function () { return __awaiter(void 0, void 0, void 0, function () {
174
- var result, privacy;
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ privacy: __assign(__assign({}, baseDef), { title: "Privacy", type: "privacy" }), terms: baseDef })];
178
- case 1:
179
- _a.sent();
180
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef }, { deactivateRemoved: true })];
181
- case 2:
182
- result = _a.sent();
183
- (0, bun_test_1.expect)(result.deactivated).toEqual(["privacy"]);
184
- (0, bun_test_1.expect)(result.unchanged).toEqual(["terms"]);
185
- return [4 /*yield*/, consentForm_1.ConsentForm.findOne({ slug: "privacy" })];
186
- case 3:
187
- privacy = _a.sent();
188
- (0, bun_test_1.expect)(privacy === null || privacy === void 0 ? void 0 : privacy.active).toBe(false);
189
- return [2 /*return*/];
190
- }
191
- });
192
- }); });
193
- (0, bun_test_1.it)("does not deactivate removed forms by default", function () { return __awaiter(void 0, void 0, void 0, function () {
194
- var result, privacy;
195
- return __generator(this, function (_a) {
196
- switch (_a.label) {
197
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ privacy: __assign(__assign({}, baseDef), { title: "Privacy", type: "privacy" }), terms: baseDef })];
198
- case 1:
199
- _a.sent();
200
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
201
- case 2:
202
- result = _a.sent();
203
- (0, bun_test_1.expect)(result.deactivated).toHaveLength(0);
204
- return [4 /*yield*/, consentForm_1.ConsentForm.findOne({ slug: "privacy" })];
205
- case 3:
206
- privacy = _a.sent();
207
- (0, bun_test_1.expect)(privacy === null || privacy === void 0 ? void 0 : privacy.active).toBe(true);
208
- return [2 /*return*/];
209
- }
210
- });
211
- }); });
212
- (0, bun_test_1.it)("does not write to the database in dry run mode", function () { return __awaiter(void 0, void 0, void 0, function () {
213
- var result, forms;
214
- return __generator(this, function (_a) {
215
- switch (_a.label) {
216
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef }, { dryRun: true })];
217
- case 1:
218
- result = _a.sent();
219
- (0, bun_test_1.expect)(result.created).toEqual(["terms"]);
220
- return [4 /*yield*/, consentForm_1.ConsentForm.find({ slug: "terms" })];
221
- case 2:
222
- forms = _a.sent();
223
- (0, bun_test_1.expect)(forms).toHaveLength(0);
224
- return [2 /*return*/];
225
- }
226
- });
227
- }); });
228
- (0, bun_test_1.it)("handles multiple forms in a single sync", function () { return __awaiter(void 0, void 0, void 0, function () {
229
- var result, forms;
230
- return __generator(this, function (_a) {
231
- switch (_a.label) {
232
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({
233
- privacy: __assign(__assign({}, baseDef), { order: 2, title: "Privacy Policy", type: "privacy" }),
234
- terms: baseDef,
235
- })];
236
- case 1:
237
- result = _a.sent();
238
- (0, bun_test_1.expect)(result.created.sort()).toEqual(["privacy", "terms"]);
239
- return [4 /*yield*/, consentForm_1.ConsentForm.find({}).sort({ order: 1 })];
240
- case 2:
241
- forms = _a.sent();
242
- (0, bun_test_1.expect)(forms).toHaveLength(2);
243
- (0, bun_test_1.expect)(forms[0].slug).toBe("terms");
244
- (0, bun_test_1.expect)(forms[1].slug).toBe("privacy");
245
- return [2 /*return*/];
246
- }
247
- });
248
- }); });
249
- (0, bun_test_1.it)("publishes new version when type changes", function () { return __awaiter(void 0, void 0, void 0, function () {
250
- var updated, result;
251
- return __generator(this, function (_a) {
252
- switch (_a.label) {
253
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
254
- case 1:
255
- _a.sent();
256
- updated = __assign(__assign({}, baseDef), { type: "privacy" });
257
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
258
- case 2:
259
- result = _a.sent();
260
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
261
- return [2 /*return*/];
262
- }
263
- });
264
- }); });
265
- (0, bun_test_1.it)("publishes new version when order changes", function () { return __awaiter(void 0, void 0, void 0, function () {
266
- var updated, result;
267
- return __generator(this, function (_a) {
268
- switch (_a.label) {
269
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
270
- case 1:
271
- _a.sent();
272
- updated = __assign(__assign({}, baseDef), { order: 99 });
273
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
274
- case 2:
275
- result = _a.sent();
276
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
277
- return [2 /*return*/];
278
- }
279
- });
280
- }); });
281
- (0, bun_test_1.it)("publishes new version when required changes", function () { return __awaiter(void 0, void 0, void 0, function () {
282
- var updated, result;
283
- return __generator(this, function (_a) {
284
- switch (_a.label) {
285
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
286
- case 1:
287
- _a.sent();
288
- updated = __assign(__assign({}, baseDef), { required: false });
289
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
290
- case 2:
291
- result = _a.sent();
292
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
293
- return [2 /*return*/];
294
- }
295
- });
296
- }); });
297
- (0, bun_test_1.it)("publishes new version when requireScrollToBottom changes", function () { return __awaiter(void 0, void 0, void 0, function () {
298
- var updated, result;
299
- return __generator(this, function (_a) {
300
- switch (_a.label) {
301
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
302
- case 1:
303
- _a.sent();
304
- updated = __assign(__assign({}, baseDef), { requireScrollToBottom: true });
305
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
306
- case 2:
307
- result = _a.sent();
308
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
309
- return [2 /*return*/];
310
- }
311
- });
312
- }); });
313
- (0, bun_test_1.it)("publishes new version when captureSignature changes", function () { return __awaiter(void 0, void 0, void 0, function () {
314
- var updated, result;
315
- return __generator(this, function (_a) {
316
- switch (_a.label) {
317
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
318
- case 1:
319
- _a.sent();
320
- updated = __assign(__assign({}, baseDef), { captureSignature: true });
321
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
322
- case 2:
323
- result = _a.sent();
324
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
325
- return [2 /*return*/];
326
- }
327
- });
328
- }); });
329
- (0, bun_test_1.it)("publishes new version when agreeButtonText changes", function () { return __awaiter(void 0, void 0, void 0, function () {
330
- var updated, result;
331
- return __generator(this, function (_a) {
332
- switch (_a.label) {
333
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
334
- case 1:
335
- _a.sent();
336
- updated = __assign(__assign({}, baseDef), { agreeButtonText: "Consent" });
337
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
338
- case 2:
339
- result = _a.sent();
340
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
341
- return [2 /*return*/];
342
- }
343
- });
344
- }); });
345
- (0, bun_test_1.it)("publishes new version when allowDecline changes", function () { return __awaiter(void 0, void 0, void 0, function () {
346
- var updated, result;
347
- return __generator(this, function (_a) {
348
- switch (_a.label) {
349
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
350
- case 1:
351
- _a.sent();
352
- updated = __assign(__assign({}, baseDef), { allowDecline: true });
353
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
354
- case 2:
355
- result = _a.sent();
356
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
357
- return [2 /*return*/];
358
- }
359
- });
360
- }); });
361
- (0, bun_test_1.it)("publishes new version when declineButtonText changes", function () { return __awaiter(void 0, void 0, void 0, function () {
362
- var updated, result;
363
- return __generator(this, function (_a) {
364
- switch (_a.label) {
365
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
366
- case 1:
367
- _a.sent();
368
- updated = __assign(__assign({}, baseDef), { allowDecline: true, declineButtonText: "No Thanks" });
369
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
370
- case 2:
371
- result = _a.sent();
372
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
373
- return [2 /*return*/];
374
- }
375
- });
376
- }); });
377
- (0, bun_test_1.it)("publishes new version when defaultLocale changes", function () { return __awaiter(void 0, void 0, void 0, function () {
378
- var updated, result;
379
- return __generator(this, function (_a) {
380
- switch (_a.label) {
381
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
382
- case 1:
383
- _a.sent();
384
- updated = __assign(__assign({}, baseDef), { defaultLocale: "es" });
385
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
386
- case 2:
387
- result = _a.sent();
388
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
389
- return [2 /*return*/];
390
- }
391
- });
392
- }); });
393
- (0, bun_test_1.it)("publishes new version when content locale count changes", function () { return __awaiter(void 0, void 0, void 0, function () {
394
- var updated, result;
395
- return __generator(this, function (_a) {
396
- switch (_a.label) {
397
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
398
- case 1:
399
- _a.sent();
400
- updated = __assign(__assign({}, baseDef), { content: { en: baseDef.content.en, es: "# Términos" } });
401
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
402
- case 2:
403
- result = _a.sent();
404
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
405
- return [2 /*return*/];
406
- }
407
- });
408
- }); });
409
- (0, bun_test_1.it)("publishes new version when checkbox count changes", function () { return __awaiter(void 0, void 0, void 0, function () {
410
- var updated, result;
411
- return __generator(this, function (_a) {
412
- switch (_a.label) {
413
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({
414
- terms: __assign(__assign({}, baseDef), { checkboxes: [{ label: "Agree", required: true }] }),
415
- })];
416
- case 1:
417
- _a.sent();
418
- updated = __assign(__assign({}, baseDef), { checkboxes: [
419
- { label: "Agree", required: true },
420
- { label: "Also agree", required: false },
421
- ] });
422
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
423
- case 2:
424
- result = _a.sent();
425
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
426
- return [2 /*return*/];
427
- }
428
- });
429
- }); });
430
- (0, bun_test_1.it)("publishes new version when checkbox label changes", function () { return __awaiter(void 0, void 0, void 0, function () {
431
- var updated, result;
432
- return __generator(this, function (_a) {
433
- switch (_a.label) {
434
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({
435
- terms: __assign(__assign({}, baseDef), { checkboxes: [{ label: "Agree", required: true }] }),
436
- })];
437
- case 1:
438
- _a.sent();
439
- updated = __assign(__assign({}, baseDef), { checkboxes: [{ label: "I Agree", required: true }] });
440
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
441
- case 2:
442
- result = _a.sent();
443
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
444
- return [2 /*return*/];
445
- }
446
- });
447
- }); });
448
- (0, bun_test_1.it)("publishes new version when checkbox confirmationPrompt changes", function () { return __awaiter(void 0, void 0, void 0, function () {
449
- var updated, result;
450
- return __generator(this, function (_a) {
451
- switch (_a.label) {
452
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({
453
- terms: __assign(__assign({}, baseDef), { checkboxes: [{ confirmationPrompt: "Sure?", label: "Agree", required: true }] }),
454
- })];
455
- case 1:
456
- _a.sent();
457
- updated = __assign(__assign({}, baseDef), { checkboxes: [{ confirmationPrompt: "Are you sure?", label: "Agree", required: true }] });
458
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated })];
459
- case 2:
460
- result = _a.sent();
461
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
462
- return [2 /*return*/];
463
- }
464
- });
465
- }); });
466
- (0, bun_test_1.it)("leaves unchanged forms alone with checkboxes present", function () { return __awaiter(void 0, void 0, void 0, function () {
467
- var withCheckboxes, result;
468
- return __generator(this, function (_a) {
469
- switch (_a.label) {
470
- case 0:
471
- withCheckboxes = __assign(__assign({}, baseDef), { checkboxes: [{ confirmationPrompt: "Sure?", label: "Agree", required: true }] });
472
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: withCheckboxes })];
473
- case 1:
474
- _a.sent();
475
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: withCheckboxes })];
476
- case 2:
477
- result = _a.sent();
478
- (0, bun_test_1.expect)(result.unchanged).toEqual(["terms"]);
479
- return [2 /*return*/];
480
- }
481
- });
482
- }); });
483
- (0, bun_test_1.it)("dry run does not create new versions", function () { return __awaiter(void 0, void 0, void 0, function () {
484
- var updated, result, forms;
485
- return __generator(this, function (_a) {
486
- switch (_a.label) {
487
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef })];
488
- case 1:
489
- _a.sent();
490
- updated = __assign(__assign({}, baseDef), { title: "Updated" });
491
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: updated }, { dryRun: true })];
492
- case 2:
493
- result = _a.sent();
494
- (0, bun_test_1.expect)(result.updated).toEqual(["terms"]);
495
- return [4 /*yield*/, consentForm_1.ConsentForm.find({ slug: "terms" })];
496
- case 3:
497
- forms = _a.sent();
498
- (0, bun_test_1.expect)(forms).toHaveLength(1); // No new version created
499
- return [2 /*return*/];
500
- }
501
- });
502
- }); });
503
- (0, bun_test_1.it)("dry run does not deactivate forms", function () { return __awaiter(void 0, void 0, void 0, function () {
504
- var result, privacy;
505
- return __generator(this, function (_a) {
506
- switch (_a.label) {
507
- case 0: return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ privacy: __assign(__assign({}, baseDef), { title: "Privacy", type: "privacy" }), terms: baseDef })];
508
- case 1:
509
- _a.sent();
510
- return [4 /*yield*/, (0, syncConsents_1.syncConsents)({ terms: baseDef }, { deactivateRemoved: true, dryRun: true })];
511
- case 2:
512
- result = _a.sent();
513
- (0, bun_test_1.expect)(result.deactivated).toEqual(["privacy"]);
514
- return [4 /*yield*/, consentForm_1.ConsentForm.findOne({ slug: "privacy" })];
515
- case 3:
516
- privacy = _a.sent();
517
- (0, bun_test_1.expect)(privacy === null || privacy === void 0 ? void 0 : privacy.active).toBe(true); // Still active
518
- return [2 /*return*/];
519
- }
520
- });
521
- }); });
522
- });
@@ -1 +0,0 @@
1
- export {};