@rebasepro/server-core 0.0.1-canary.4d4fb3e → 0.0.1-canary.ca2cb6e

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 (176) hide show
  1. package/dist/common/src/collections/CollectionRegistry.d.ts +8 -0
  2. package/dist/common/src/util/entities.d.ts +22 -0
  3. package/dist/common/src/util/relations.d.ts +14 -4
  4. package/dist/common/src/util/resolutions.d.ts +1 -1
  5. package/dist/index-DXVBFp5V.js +37 -0
  6. package/dist/index-DXVBFp5V.js.map +1 -0
  7. package/dist/index.es.js +49931 -55
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/index.umd.js +28475 -34569
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/server-core/src/api/openapi-generator.d.ts +15 -1
  12. package/dist/server-core/src/api/types.d.ts +1 -1
  13. package/dist/server-core/src/auth/admin-routes.d.ts +10 -1
  14. package/dist/server-core/src/auth/apple-oauth.d.ts +30 -0
  15. package/dist/server-core/src/auth/bitbucket-oauth.d.ts +11 -0
  16. package/dist/server-core/src/auth/discord-oauth.d.ts +14 -0
  17. package/dist/server-core/src/auth/facebook-oauth.d.ts +14 -0
  18. package/dist/server-core/src/auth/github-oauth.d.ts +15 -0
  19. package/dist/server-core/src/auth/gitlab-oauth.d.ts +13 -0
  20. package/dist/server-core/src/auth/google-oauth.d.ts +5 -11
  21. package/dist/server-core/src/auth/index.d.ts +13 -2
  22. package/dist/server-core/src/auth/interfaces.d.ts +45 -6
  23. package/dist/server-core/src/auth/jwt.d.ts +1 -0
  24. package/dist/server-core/src/auth/linkedin-oauth.d.ts +18 -0
  25. package/dist/server-core/src/auth/microsoft-oauth.d.ts +16 -0
  26. package/dist/server-core/src/auth/middleware.d.ts +36 -11
  27. package/dist/server-core/src/auth/rate-limiter.d.ts +2 -2
  28. package/dist/server-core/src/auth/routes.d.ts +13 -3
  29. package/dist/server-core/src/auth/slack-oauth.d.ts +12 -0
  30. package/dist/server-core/src/auth/spotify-oauth.d.ts +12 -0
  31. package/dist/server-core/src/auth/twitter-oauth.d.ts +18 -0
  32. package/dist/server-core/src/cron/cron-loader.d.ts +17 -0
  33. package/dist/server-core/src/cron/cron-routes.d.ts +14 -0
  34. package/dist/server-core/src/cron/cron-scheduler.d.ts +61 -0
  35. package/dist/server-core/src/cron/cron-store.d.ts +32 -0
  36. package/dist/server-core/src/cron/index.d.ts +6 -0
  37. package/dist/server-core/src/email/index.d.ts +2 -2
  38. package/dist/server-core/src/email/templates.d.ts +9 -0
  39. package/dist/server-core/src/email/types.d.ts +20 -23
  40. package/dist/server-core/src/history/history-routes.d.ts +2 -2
  41. package/dist/server-core/src/index.d.ts +5 -0
  42. package/dist/server-core/src/init.d.ts +112 -2
  43. package/dist/server-core/src/singleton.d.ts +35 -0
  44. package/dist/server-core/src/storage/LocalStorageController.d.ts +9 -9
  45. package/dist/server-core/src/storage/S3StorageController.d.ts +8 -8
  46. package/dist/server-core/src/storage/index.d.ts +18 -11
  47. package/dist/server-core/src/storage/routes.d.ts +3 -3
  48. package/dist/server-core/src/storage/types.d.ts +28 -16
  49. package/dist/server-core/src/utils/dev-port.d.ts +35 -0
  50. package/dist/server-core/src/utils/logger.d.ts +31 -0
  51. package/dist/server-core/src/utils/request-logger.d.ts +19 -0
  52. package/dist/types/src/controllers/auth.d.ts +2 -0
  53. package/dist/types/src/controllers/client.d.ts +119 -7
  54. package/dist/types/src/controllers/collection_registry.d.ts +4 -3
  55. package/dist/types/src/controllers/customization_controller.d.ts +7 -1
  56. package/dist/types/src/controllers/data.d.ts +34 -7
  57. package/dist/types/src/controllers/data_driver.d.ts +20 -28
  58. package/dist/types/src/controllers/database_admin.d.ts +2 -2
  59. package/dist/types/src/controllers/email.d.ts +34 -0
  60. package/dist/types/src/controllers/index.d.ts +1 -0
  61. package/dist/types/src/controllers/local_config_persistence.d.ts +4 -4
  62. package/dist/types/src/controllers/navigation.d.ts +5 -5
  63. package/dist/types/src/controllers/registry.d.ts +6 -3
  64. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -6
  65. package/dist/types/src/controllers/storage.d.ts +24 -26
  66. package/dist/types/src/rebase_context.d.ts +8 -4
  67. package/dist/types/src/types/backend.d.ts +4 -1
  68. package/dist/types/src/types/builders.d.ts +5 -4
  69. package/dist/types/src/types/chips.d.ts +1 -1
  70. package/dist/types/src/types/collections.d.ts +169 -125
  71. package/dist/types/src/types/cron.d.ts +102 -0
  72. package/dist/types/src/types/data_source.d.ts +1 -1
  73. package/dist/types/src/types/entity_actions.d.ts +8 -8
  74. package/dist/types/src/types/entity_callbacks.d.ts +15 -15
  75. package/dist/types/src/types/entity_link_builder.d.ts +1 -1
  76. package/dist/types/src/types/entity_overrides.d.ts +2 -1
  77. package/dist/types/src/types/entity_views.d.ts +8 -8
  78. package/dist/types/src/types/export_import.d.ts +3 -3
  79. package/dist/types/src/types/index.d.ts +1 -0
  80. package/dist/types/src/types/plugins.d.ts +72 -18
  81. package/dist/types/src/types/properties.d.ts +118 -33
  82. package/dist/types/src/types/relations.d.ts +1 -1
  83. package/dist/types/src/types/slots.d.ts +30 -6
  84. package/dist/types/src/types/translations.d.ts +44 -0
  85. package/dist/types/src/types/user_management_delegate.d.ts +1 -0
  86. package/package.json +84 -84
  87. package/scratch.ts +6 -5
  88. package/src/api/ast-schema-editor.ts +11 -11
  89. package/src/api/collections_for_test/callbacks_test_collection.ts +5 -2
  90. package/src/api/errors.ts +38 -14
  91. package/src/api/graphql/graphql-schema-generator.ts +5 -3
  92. package/src/api/openapi-generator.ts +613 -58
  93. package/src/api/rest/api-generator.ts +17 -11
  94. package/src/api/rest/query-parser.ts +1 -1
  95. package/src/api/schema-editor-routes.ts +2 -0
  96. package/src/api/server.ts +8 -5
  97. package/src/api/types.ts +1 -1
  98. package/src/auth/admin-routes.ts +58 -17
  99. package/src/auth/apple-oauth.ts +130 -0
  100. package/src/auth/bitbucket-oauth.ts +82 -0
  101. package/src/auth/discord-oauth.ts +83 -0
  102. package/src/auth/facebook-oauth.ts +72 -0
  103. package/src/auth/github-oauth.ts +110 -0
  104. package/src/auth/gitlab-oauth.ts +70 -0
  105. package/src/auth/google-oauth.ts +34 -46
  106. package/src/auth/index.ts +15 -2
  107. package/src/auth/interfaces.ts +54 -7
  108. package/src/auth/jwt.ts +22 -5
  109. package/src/auth/linkedin-oauth.ts +81 -0
  110. package/src/auth/microsoft-oauth.ts +88 -0
  111. package/src/auth/middleware.ts +194 -45
  112. package/src/auth/password.ts +3 -1
  113. package/src/auth/rate-limiter.ts +4 -4
  114. package/src/auth/routes.ts +197 -139
  115. package/src/auth/slack-oauth.ts +71 -0
  116. package/src/auth/spotify-oauth.ts +67 -0
  117. package/src/auth/twitter-oauth.ts +120 -0
  118. package/src/collections/loader.ts +6 -6
  119. package/src/cron/cron-loader.ts +89 -0
  120. package/src/cron/cron-routes.test.ts +265 -0
  121. package/src/cron/cron-routes.ts +85 -0
  122. package/src/cron/cron-scheduler.test.ts +421 -0
  123. package/src/cron/cron-scheduler.ts +413 -0
  124. package/src/cron/cron-store.ts +163 -0
  125. package/src/cron/index.ts +6 -0
  126. package/src/db/interfaces.ts +2 -2
  127. package/src/email/index.ts +3 -2
  128. package/src/email/smtp-email-service.ts +5 -2
  129. package/src/email/templates.ts +93 -6
  130. package/src/email/types.ts +17 -24
  131. package/src/functions/function-loader.ts +34 -6
  132. package/src/functions/function-routes.ts +2 -2
  133. package/src/history/history-routes.ts +4 -3
  134. package/src/index.ts +10 -0
  135. package/src/init.ts +475 -57
  136. package/src/services/driver-registry.ts +1 -1
  137. package/src/singleton.test.ts +28 -0
  138. package/src/singleton.ts +70 -0
  139. package/src/storage/LocalStorageController.ts +50 -53
  140. package/src/storage/S3StorageController.ts +49 -46
  141. package/src/storage/index.ts +27 -16
  142. package/src/storage/routes.ts +76 -59
  143. package/src/storage/storage-registry.ts +5 -5
  144. package/src/storage/types.ts +44 -32
  145. package/src/types/index.ts +4 -4
  146. package/src/utils/dev-port.ts +176 -0
  147. package/src/utils/logger.ts +143 -0
  148. package/src/utils/logging.ts +5 -2
  149. package/src/utils/request-logger.ts +66 -0
  150. package/test/admin-routes.test.ts +114 -65
  151. package/test/api-generator.test.ts +73 -30
  152. package/test/ast-schema-editor.test.ts +5 -3
  153. package/test/auth-middleware-hono.test.ts +268 -33
  154. package/test/auth-routes.test.ts +325 -146
  155. package/test/driver-registry.test.ts +4 -2
  156. package/test/error-propagation.test.ts +226 -0
  157. package/test/errors.test.ts +12 -7
  158. package/test/jwt-security.test.ts +18 -9
  159. package/test/jwt.test.ts +26 -13
  160. package/test/middleware.test.ts +13 -8
  161. package/test/query-parser.test.ts +13 -8
  162. package/test/rate-limiter.test.ts +7 -7
  163. package/test/safe-compare.test.ts +66 -0
  164. package/test/singleton.test.ts +59 -0
  165. package/test/storage-local.test.ts +36 -43
  166. package/test/storage-registry.test.ts +38 -36
  167. package/test/storage-routes.test.ts +9 -5
  168. package/test/storage-s3.test.ts +51 -48
  169. package/test.ts +6 -0
  170. package/tsconfig.json +1 -1
  171. package/vite.config.ts +7 -5
  172. package/dist/index-BeMqpmfQ.js +0 -239
  173. package/dist/index-BeMqpmfQ.js.map +0 -1
  174. package/dist/index-bl4J3lNb.js +0 -55823
  175. package/dist/index-bl4J3lNb.js.map +0 -1
  176. package/vite.config.ts.timestamp-1775065397568-8a853255edf6e.mjs +0 -46
@@ -1,8 +1,8 @@
1
1
  import { Hono } from "hono";
2
- import { RestApiGenerator } from "../src/api/rest/api-generator.js";
3
- import { errorHandler } from "../src/api/errors.js";
4
- import { DataDriver } from "../../types/src/controllers/data_driver.js";
5
- import { EntityCollection } from "../../types/src/types/collections.js";
2
+ import { RestApiGenerator } from "../src/api/rest/api-generator";
3
+ import { errorHandler } from "../src/api/errors";
4
+ import { DataDriver } from "../../types/src/controllers/data_driver";
5
+ import { EntityCollection } from "../../types/src/types/collections";
6
6
 
7
7
  describe("RestApiGenerator", () => {
8
8
  let mockDriver: jest.Mocked<DataDriver>;
@@ -66,7 +66,9 @@ describe("RestApiGenerator", () => {
66
66
  it("list entities - GET /api/users", async () => {
67
67
  const app = createApp();
68
68
  mockDriver.fetchCollection.mockResolvedValue([
69
- { id: "1", path: "users", values: { name: "Alice" } } as any
69
+ { id: "1",
70
+ path: "users",
71
+ values: { name: "Alice" } } as any
70
72
  ]);
71
73
  mockDriver.countEntities!.mockResolvedValue(1);
72
74
 
@@ -74,16 +76,20 @@ describe("RestApiGenerator", () => {
74
76
  expect(res.status).toBe(200);
75
77
 
76
78
  const body = await res.json() as any;
77
- expect(body.data).toEqual([{ id: "1", name: "Alice" }]);
79
+ expect(body.data).toEqual([{ id: "1",
80
+ name: "Alice" }]);
78
81
  expect(mockDriver.fetchCollection).toHaveBeenCalledWith(
79
- expect.objectContaining({ path: "users", limit: 10 })
82
+ expect.objectContaining({ path: "users",
83
+ limit: 10 })
80
84
  );
81
85
  });
82
86
 
83
87
  it("get entity - GET /api/users/123", async () => {
84
88
  const app = createApp();
85
89
  mockDriver.fetchEntity.mockResolvedValue(
86
- { id: "123", path: "users", values: { name: "Alice" } } as any
90
+ { id: "123",
91
+ path: "users",
92
+ values: { name: "Alice" } } as any
87
93
  );
88
94
 
89
95
  const res = await app.request("/api/users/123");
@@ -93,14 +99,17 @@ describe("RestApiGenerator", () => {
93
99
  expect(body.id).toBe("123");
94
100
  expect(body.name).toBe("Alice");
95
101
  expect(mockDriver.fetchEntity).toHaveBeenCalledWith(
96
- expect.objectContaining({ path: "users", entityId: "123" })
102
+ expect.objectContaining({ path: "users",
103
+ entityId: "123" })
97
104
  );
98
105
  });
99
106
 
100
107
  it("create entity - POST /api/users", async () => {
101
108
  const app = createApp();
102
109
  mockDriver.saveEntity.mockResolvedValue(
103
- { id: "new-1", path: "users", values: { name: "Bob" } } as any
110
+ { id: "new-1",
111
+ path: "users",
112
+ values: { name: "Bob" } } as any
104
113
  );
105
114
 
106
115
  const res = await app.request("/api/users", {
@@ -111,15 +120,21 @@ describe("RestApiGenerator", () => {
111
120
 
112
121
  expect(res.status).toBe(201);
113
122
  expect(mockDriver.saveEntity).toHaveBeenCalledWith(
114
- expect.objectContaining({ path: "users", values: { name: "Bob" }, status: "new" })
123
+ expect.objectContaining({ path: "users",
124
+ values: { name: "Bob" },
125
+ status: "new" })
115
126
  );
116
127
  });
117
128
 
118
129
  it("update entity - PUT /api/users/123", async () => {
119
130
  const app = createApp();
120
- mockDriver.fetchEntity.mockResolvedValue({ id: "123", path: "users", values: {} } as any);
131
+ mockDriver.fetchEntity.mockResolvedValue({ id: "123",
132
+ path: "users",
133
+ values: {} } as any);
121
134
  mockDriver.saveEntity.mockResolvedValue(
122
- { id: "123", path: "users", values: { name: "Bob Jr" } } as any
135
+ { id: "123",
136
+ path: "users",
137
+ values: { name: "Bob Jr" } } as any
123
138
  );
124
139
 
125
140
  const res = await app.request("/api/users/123", {
@@ -130,13 +145,18 @@ describe("RestApiGenerator", () => {
130
145
 
131
146
  expect(res.status).toBe(200);
132
147
  expect(mockDriver.saveEntity).toHaveBeenCalledWith(
133
- expect.objectContaining({ path: "users", entityId: "123", values: { name: "Bob Jr" }, status: "existing" })
148
+ expect.objectContaining({ path: "users",
149
+ entityId: "123",
150
+ values: { name: "Bob Jr" },
151
+ status: "existing" })
134
152
  );
135
153
  });
136
154
 
137
155
  it("delete entity - DELETE /api/users/123", async () => {
138
156
  const app = createApp();
139
- const existingEntity = { id: "123", path: "users", values: {} } as any;
157
+ const existingEntity = { id: "123",
158
+ path: "users",
159
+ values: {} } as any;
140
160
  mockDriver.fetchEntity.mockResolvedValue(existingEntity);
141
161
  mockDriver.deleteEntity.mockResolvedValue();
142
162
 
@@ -154,7 +174,7 @@ describe("RestApiGenerator", () => {
154
174
  * These tests use the flat app (no prefix nesting) to avoid
155
175
  * Hono sub-router routing quirks where `/:slug/:id` eats the request
156
176
  * before the `/:parent/:parentId/*` wildcard gets a chance.
157
- *
177
+ *
158
178
  * We use "authors" as the parent slug since it's NOT a registered
159
179
  * collection, so it can only match the wildcard catch-all.
160
180
  */
@@ -162,14 +182,17 @@ describe("RestApiGenerator", () => {
162
182
  it("list subcollection - GET /authors/123/posts", async () => {
163
183
  const app = createFlatApp();
164
184
  mockDriver.fetchCollection.mockResolvedValue([
165
- { id: "post-1", path: "authors/123/posts", values: { title: "Hello" } } as any
185
+ { id: "post-1",
186
+ path: "authors/123/posts",
187
+ values: { title: "Hello" } } as any
166
188
  ]);
167
189
 
168
190
  const res = await app.request("/authors/123/posts");
169
191
  expect(res.status).toBe(200);
170
192
 
171
193
  const body = await res.json() as any;
172
- expect(body.data).toEqual([{ id: "post-1", title: "Hello" }]);
194
+ expect(body.data).toEqual([{ id: "post-1",
195
+ title: "Hello" }]);
173
196
  expect(mockDriver.fetchCollection).toHaveBeenCalledWith(
174
197
  expect.objectContaining({ path: "authors/123/posts" })
175
198
  );
@@ -178,7 +201,9 @@ describe("RestApiGenerator", () => {
178
201
  it("get subcollection entity - GET /authors/123/posts/456", async () => {
179
202
  const app = createFlatApp();
180
203
  mockDriver.fetchEntity.mockResolvedValue(
181
- { id: "456", path: "authors/123/posts", values: { title: "Hello" } } as any
204
+ { id: "456",
205
+ path: "authors/123/posts",
206
+ values: { title: "Hello" } } as any
182
207
  );
183
208
 
184
209
  const res = await app.request("/authors/123/posts/456");
@@ -188,14 +213,17 @@ describe("RestApiGenerator", () => {
188
213
  expect(body.id).toBe("456");
189
214
  expect(body.title).toBe("Hello");
190
215
  expect(mockDriver.fetchEntity).toHaveBeenCalledWith(
191
- expect.objectContaining({ path: "authors/123/posts", entityId: "456" })
216
+ expect.objectContaining({ path: "authors/123/posts",
217
+ entityId: "456" })
192
218
  );
193
219
  });
194
220
 
195
221
  it("create subcollection entity - POST /authors/123/posts", async () => {
196
222
  const app = createFlatApp();
197
223
  mockDriver.saveEntity.mockResolvedValue(
198
- { id: "new-post", path: "authors/123/posts", values: { title: "New" } } as any
224
+ { id: "new-post",
225
+ path: "authors/123/posts",
226
+ values: { title: "New" } } as any
199
227
  );
200
228
 
201
229
  const res = await app.request("/authors/123/posts", {
@@ -206,14 +234,17 @@ describe("RestApiGenerator", () => {
206
234
 
207
235
  expect(res.status).toBe(201);
208
236
  expect(mockDriver.saveEntity).toHaveBeenCalledWith(
209
- expect.objectContaining({ path: "authors/123/posts", status: "new" })
237
+ expect.objectContaining({ path: "authors/123/posts",
238
+ status: "new" })
210
239
  );
211
240
  });
212
241
 
213
242
  it("update subcollection entity - PUT /authors/123/posts/456", async () => {
214
243
  const app = createFlatApp();
215
244
  mockDriver.saveEntity.mockResolvedValue(
216
- { id: "456", path: "authors/123/posts", values: { title: "Updated" } } as any
245
+ { id: "456",
246
+ path: "authors/123/posts",
247
+ values: { title: "Updated" } } as any
217
248
  );
218
249
 
219
250
  const res = await app.request("/authors/123/posts/456", {
@@ -234,7 +265,9 @@ describe("RestApiGenerator", () => {
234
265
 
235
266
  it("delete subcollection entity - DELETE /authors/123/posts/456", async () => {
236
267
  const app = createFlatApp();
237
- const existingEntity = { id: "456", path: "authors/123/posts", values: {} } as any;
268
+ const existingEntity = { id: "456",
269
+ path: "authors/123/posts",
270
+ values: {} } as any;
238
271
  mockDriver.fetchEntity.mockResolvedValue(existingEntity);
239
272
  mockDriver.deleteEntity.mockResolvedValue();
240
273
 
@@ -249,14 +282,17 @@ describe("RestApiGenerator", () => {
249
282
  it("deeply nested subcollection list - GET /authors/123/posts/456/comments", async () => {
250
283
  const app = createFlatApp();
251
284
  mockDriver.fetchCollection.mockResolvedValue([
252
- { id: "c-1", path: "authors/123/posts/456/comments", values: { text: "Wow" } } as any
285
+ { id: "c-1",
286
+ path: "authors/123/posts/456/comments",
287
+ values: { text: "Wow" } } as any
253
288
  ]);
254
289
 
255
290
  const res = await app.request("/authors/123/posts/456/comments");
256
291
  expect(res.status).toBe(200);
257
292
 
258
293
  const body = await res.json() as any;
259
- expect(body.data).toEqual([{ id: "c-1", text: "Wow" }]);
294
+ expect(body.data).toEqual([{ id: "c-1",
295
+ text: "Wow" }]);
260
296
  expect(mockDriver.fetchCollection).toHaveBeenCalledWith(
261
297
  expect.objectContaining({ path: "authors/123/posts/456/comments" })
262
298
  );
@@ -265,7 +301,9 @@ describe("RestApiGenerator", () => {
265
301
  it("deeply nested entity - GET /authors/123/posts/456/comments/789", async () => {
266
302
  const app = createFlatApp();
267
303
  mockDriver.fetchEntity.mockResolvedValue(
268
- { id: "789", path: "authors/123/posts/456/comments", values: { text: "Wow" } } as any
304
+ { id: "789",
305
+ path: "authors/123/posts/456/comments",
306
+ values: { text: "Wow" } } as any
269
307
  );
270
308
 
271
309
  const res = await app.request("/authors/123/posts/456/comments/789");
@@ -378,13 +416,16 @@ describe("RestApiGenerator", () => {
378
416
  it("numeric IDs are correctly parsed as entityId", async () => {
379
417
  const app = createFlatApp();
380
418
  mockDriver.fetchEntity.mockResolvedValue(
381
- { id: "999", path: "authors/42/books", values: { title: "Test" } } as any
419
+ { id: "999",
420
+ path: "authors/42/books",
421
+ values: { title: "Test" } } as any
382
422
  );
383
423
 
384
424
  const res = await app.request("/authors/42/books/999");
385
425
  expect(res.status).toBe(200);
386
426
  expect(mockDriver.fetchEntity).toHaveBeenCalledWith(
387
- expect.objectContaining({ path: "authors/42/books", entityId: "999" })
427
+ expect.objectContaining({ path: "authors/42/books",
428
+ entityId: "999" })
388
429
  );
389
430
  });
390
431
 
@@ -393,7 +434,9 @@ describe("RestApiGenerator", () => {
393
434
  const uuid1 = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
394
435
  const uuid2 = "ffffffff-ffff-ffff-ffff-ffffffffffff";
395
436
  mockDriver.fetchEntity.mockResolvedValue(
396
- { id: uuid2, path: `authors/${uuid1}/posts`, values: { title: "UUID" } } as any
437
+ { id: uuid2,
438
+ path: `authors/${uuid1}/posts`,
439
+ values: { title: "UUID" } } as any
397
440
  );
398
441
 
399
442
  const res = await app.request(`/authors/${uuid1}/posts/${uuid2}`);
@@ -13,7 +13,8 @@ describe("AstSchemaEditor", () => {
13
13
  });
14
14
 
15
15
  afterEach(() => {
16
- fs.rmSync(testDir, { recursive: true, force: true });
16
+ fs.rmSync(testDir, { recursive: true,
17
+ force: true });
17
18
  });
18
19
 
19
20
  it("should merge properties while preserving existing functions when saving a collection", async () => {
@@ -43,7 +44,8 @@ export default productsCollection;
43
44
  slug: "products",
44
45
  properties: {
45
46
  id: { type: "string" },
46
- name: { type: "string", description: "Product name" },
47
+ name: { type: "string",
48
+ description: "Product name" },
47
49
  category: {
48
50
  type: "reference"
49
51
  // Notice target is dropped since the frontend REST payload wouldn't have it serialized
@@ -55,7 +57,7 @@ export default productsCollection;
55
57
 
56
58
  const newContent = fs.readFileSync(path.join(testDir, "products.ts"), "utf-8");
57
59
  expect(newContent).toContain('name: "Updated Products"');
58
- expect(newContent).toContain('target: () => categoriesCollection');
60
+ expect(newContent).toContain("target: () => categoriesCollection");
59
61
  expect(newContent).toContain('description: "Product name"');
60
62
  });
61
63
  });