@roc-db/test-utils 0.1.0-pre.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 (47) hide show
  1. package/dist/index.js +456 -0
  2. package/dist/roc-db-test-utils-0.1.0-pre.1.tgz +0 -0
  3. package/dist/roc-db-test-utils-0.1.0-pre.2.tgz +0 -0
  4. package/dist/setup/index.js +7 -0
  5. package/dist/types/inMemoryAdapter.d.ts +1 -0
  6. package/dist/types/index.d.ts +4 -0
  7. package/dist/types/operations/createBlockImage.d.ts +15 -0
  8. package/dist/types/operations/createBlockParagraph.d.ts +15 -0
  9. package/dist/types/operations/createBlockRow.d.ts +15 -0
  10. package/dist/types/operations/createBlockTitle.d.ts +15 -0
  11. package/dist/types/operations/createDraft.d.ts +15 -0
  12. package/dist/types/operations/createPost.d.ts +19 -0
  13. package/dist/types/operations/deleteBlock.d.ts +11 -0
  14. package/dist/types/operations/deletePost.d.ts +9 -0
  15. package/dist/types/operations/index.d.ts +157 -0
  16. package/dist/types/operations/readEntity.d.ts +1 -0
  17. package/dist/types/operations/readPost.d.ts +1 -0
  18. package/dist/types/operations/updateBlockParagraph.d.ts +15 -0
  19. package/dist/types/operations/updatePost.d.ts +21 -0
  20. package/dist/types/operations/updatePostTitle.d.ts +17 -0
  21. package/dist/types/schemas/BlockImageRefSchema.d.ts +1 -0
  22. package/dist/types/schemas/BlockImageSchema.d.ts +32 -0
  23. package/dist/types/schemas/BlockParagraphRefSchema.d.ts +1 -0
  24. package/dist/types/schemas/BlockParagraphSchema.d.ts +32 -0
  25. package/dist/types/schemas/BlockRowRefSchema.d.ts +1 -0
  26. package/dist/types/schemas/BlockTitleRefSchema.d.ts +1 -0
  27. package/dist/types/schemas/BlockTitleSchema.d.ts +32 -0
  28. package/dist/types/schemas/CreateBlockImageMutationSchema.d.ts +40 -0
  29. package/dist/types/schemas/CreateBlockParagraphMutationSchema.d.ts +40 -0
  30. package/dist/types/schemas/CreateBlockRowMutationSchema.d.ts +40 -0
  31. package/dist/types/schemas/CreateBlockTitleMutationSchema.d.ts +40 -0
  32. package/dist/types/schemas/CreateDraftMutationSchema.d.ts +40 -0
  33. package/dist/types/schemas/CreatePostMutationSchema.d.ts +50 -0
  34. package/dist/types/schemas/CreateUserMutationSchema.d.ts +40 -0
  35. package/dist/types/schemas/DeleteBlockMutationSchema.d.ts +30 -0
  36. package/dist/types/schemas/DeletePostMutationSchema.d.ts +29 -0
  37. package/dist/types/schemas/DraftRefSchema.d.ts +1 -0
  38. package/dist/types/schemas/DraftSchema.d.ts +32 -0
  39. package/dist/types/schemas/PostRefSchema.d.ts +1 -0
  40. package/dist/types/schemas/PostSchema.d.ts +32 -0
  41. package/dist/types/schemas/UpdateBlockParagraphMutationSchema.d.ts +45 -0
  42. package/dist/types/schemas/UpdatePostMutationSchema.d.ts +55 -0
  43. package/dist/types/schemas/UpdatePostTitleMutationSchema.d.ts +45 -0
  44. package/dist/types/schemas/UserRefSchema.d.ts +1 -0
  45. package/dist/types/schemas/index.d.ts +44 -0
  46. package/dist/types/testAdapterImplementation.d.ts +1 -0
  47. package/package.json +37 -0
package/dist/index.js ADDED
@@ -0,0 +1,456 @@
1
+ // src/schemas/BlockImageSchema.ts
2
+ import { entitySchemaGenerator } from "roc-db";
3
+ import { z } from "zod";
4
+
5
+ // src/schemas/BlockImageRefSchema.ts
6
+ import { refSchemaGenerator } from "roc-db";
7
+ var BlockImageRefSchema = refSchemaGenerator("BlockImage");
8
+
9
+ // src/schemas/PostRefSchema.ts
10
+ import { refSchemaGenerator as refSchemaGenerator2 } from "roc-db";
11
+ var PostRefSchema = refSchemaGenerator2("Post");
12
+
13
+ // src/schemas/BlockImageSchema.ts
14
+ var BlockImageSchema = entitySchemaGenerator("BlockImage", {
15
+ ref: BlockImageRefSchema,
16
+ data: z.object({
17
+ url: z.string().url()
18
+ }),
19
+ parents: z.object({
20
+ post: PostRefSchema
21
+ })
22
+ });
23
+
24
+ // src/schemas/BlockParagraphSchema.ts
25
+ import { entitySchemaGenerator as entitySchemaGenerator2 } from "roc-db";
26
+ import { z as z2 } from "zod";
27
+
28
+ // src/schemas/BlockParagraphRefSchema.ts
29
+ import { refSchemaGenerator as refSchemaGenerator3 } from "roc-db";
30
+ var BlockParagraphRefSchema = refSchemaGenerator3("BlockParagraph");
31
+
32
+ // src/schemas/BlockParagraphSchema.ts
33
+ var BlockParagraphSchema = entitySchemaGenerator2("BlockParagraph", {
34
+ ref: BlockParagraphRefSchema,
35
+ data: z2.object({
36
+ content: z2.string().optional()
37
+ }),
38
+ parents: z2.object({
39
+ parent: PostRefSchema
40
+ })
41
+ });
42
+
43
+ // src/schemas/BlockTitleSchema.ts
44
+ import { entitySchemaGenerator as entitySchemaGenerator3 } from "roc-db";
45
+ import { z as z3 } from "zod";
46
+
47
+ // src/schemas/BlockTitleRefSchema.ts
48
+ import { refSchemaGenerator as refSchemaGenerator4 } from "roc-db";
49
+ var BlockTitleRefSchema = refSchemaGenerator4("BlockTitle");
50
+
51
+ // src/schemas/BlockTitleSchema.ts
52
+ var BlockTitleSchema = entitySchemaGenerator3("BlockTitle", {
53
+ ref: BlockTitleRefSchema,
54
+ data: z3.object({
55
+ content: z3.string()
56
+ }),
57
+ parents: z3.object({
58
+ post: PostRefSchema
59
+ })
60
+ });
61
+
62
+ // src/schemas/DraftSchema.ts
63
+ import { entitySchemaGenerator as entitySchemaGenerator4 } from "roc-db";
64
+ import { z as z4 } from "zod";
65
+
66
+ // src/schemas/DraftRefSchema.ts
67
+ import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
68
+ var DraftRefSchema = refSchemaGenerator5("Draft");
69
+
70
+ // src/schemas/DraftSchema.ts
71
+ var DraftSchema = entitySchemaGenerator4("Draft", {
72
+ ref: DraftRefSchema,
73
+ data: z4.object({
74
+ postRef: PostRefSchema
75
+ })
76
+ });
77
+
78
+ // src/schemas/PostSchema.ts
79
+ import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
80
+ import { z as z5 } from "zod";
81
+
82
+ // src/schemas/UserRefSchema.ts
83
+ import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
84
+ var UserRefSchema = refSchemaGenerator6("User");
85
+
86
+ // src/schemas/PostSchema.ts
87
+ var PostSchema = entitySchemaGenerator5("Post", {
88
+ ref: PostRefSchema,
89
+ data: z5.object({
90
+ title: z5.string(),
91
+ text: z5.string().optional(),
92
+ tags: z5.array(z5.string()),
93
+ slug: z5.string().optional()
94
+ }),
95
+ parents: z5.object({ author: UserRefSchema.optional() }),
96
+ children: z5.object({ blocks: z5.array(z5.string()) })
97
+ });
98
+ // src/schemas/CreatePostMutationSchema.ts
99
+ import { mutationSchemaGenerator } from "roc-db";
100
+ import { z as z6 } from "zod";
101
+ var CreatePostMutationSchema = mutationSchemaGenerator("createPost", z6.object({
102
+ title: z6.string(),
103
+ slug: z6.string().optional(),
104
+ tags: z6.array(z6.string()).default([])
105
+ }).strict());
106
+ // src/schemas/CreateUserMutationSchema.ts
107
+ import { mutationSchemaGenerator as mutationSchemaGenerator2 } from "roc-db";
108
+ import { z as z7 } from "zod";
109
+ var CreateUserMutationSchema = mutationSchemaGenerator2("createUser", z7.object({ email: z7.string() }));
110
+ // src/schemas/UpdatePostMutationSchema.ts
111
+ import { mutationSchemaGenerator as mutationSchemaGenerator3 } from "roc-db";
112
+ import { z as z8 } from "zod";
113
+ var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z8.object({
114
+ ref: PostRefSchema,
115
+ title: z8.string().optional(),
116
+ tags: z8.array(z8.string()).optional().default([]),
117
+ authorRef: UserRefSchema.optional().optional()
118
+ }));
119
+ // src/schemas/UpdatePostTitleMutationSchema.ts
120
+ import { mutationSchemaGenerator as mutationSchemaGenerator4 } from "roc-db";
121
+ import { z as z9 } from "zod";
122
+ var UpdatePostTitleMutationSchema = mutationSchemaGenerator4("updatePostTitle", z9.object({ ref: PostRefSchema, title: z9.string() }));
123
+ // src/schemas/index.ts
124
+ var entities = [
125
+ BlockImageSchema,
126
+ BlockParagraphSchema,
127
+ BlockTitleSchema,
128
+ DraftSchema,
129
+ PostSchema
130
+ ];
131
+ // src/operations/createBlockImage.ts
132
+ import { Query, writeOperation } from "roc-db";
133
+
134
+ // src/schemas/CreateBlockImageMutationSchema.ts
135
+ import { mutationSchemaGenerator as mutationSchemaGenerator5 } from "roc-db";
136
+ import { z as z10 } from "zod";
137
+ var CreateBlockImageMutationSchema = mutationSchemaGenerator5("createBlockImage", z10.object({ postRef: PostRefSchema }).strict(), undefined, true);
138
+
139
+ // src/operations/createBlockImage.ts
140
+ var createBlockImage = writeOperation(CreateBlockImageMutationSchema, BlockImageSchema, (txn) => {
141
+ const ref = txn.createRef("BlockImage");
142
+ const { postRef } = txn.payload;
143
+ return Query(() => txn.createEntity(ref, { parents: { post: postRef } }));
144
+ }, { changeSetOnly: true });
145
+
146
+ // src/operations/createBlockParagraph.ts
147
+ import { Query as Query2, QueryChain, writeOperation as writeOperation2 } from "roc-db";
148
+
149
+ // src/schemas/CreateBlockParagraphMutationSchema.ts
150
+ import { mutationSchemaGenerator as mutationSchemaGenerator6 } from "roc-db";
151
+ import { z as z11 } from "zod";
152
+
153
+ // src/schemas/BlockRowRefSchema.ts
154
+ import { refSchemaGenerator as refSchemaGenerator7 } from "roc-db";
155
+ var BlockRowRefSchema = refSchemaGenerator7("BlockRow");
156
+
157
+ // src/schemas/CreateBlockParagraphMutationSchema.ts
158
+ var CreateBlockParagraphMutationSchema = mutationSchemaGenerator6("createBlockParagraph", z11.object({ parentRef: z11.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
159
+
160
+ // src/operations/createBlockParagraph.ts
161
+ var createBlockParagrah = writeOperation2(CreateBlockParagraphMutationSchema, BlockParagraphSchema, (txn) => {
162
+ const ref = txn.createRef("BlockParagraph");
163
+ const { parentRef } = txn.payload;
164
+ return QueryChain(Query2(() => txn.readEntity(parentRef, true)), Query2((parent) => txn.patchEntity(parentRef, {
165
+ children: { blocks: [...parent.children.blocks, ref] }
166
+ })), Query2(() => txn.createEntity(ref, { parents: { parent: parentRef } })), Query2((block, updatedParent) => ({ block, updatedParent })));
167
+ }, { changeSetOnly: true });
168
+
169
+ // src/operations/createBlockRow.ts
170
+ import { Query as Query3, QueryChain as QueryChain2, writeOperation as writeOperation3 } from "roc-db";
171
+
172
+ // src/schemas/CreateBlockRowMutationSchema.ts
173
+ import { mutationSchemaGenerator as mutationSchemaGenerator7 } from "roc-db";
174
+ import { z as z12 } from "zod";
175
+ var CreateBlockRowMutationSchema = mutationSchemaGenerator7("createBlockRow", z12.object({ parentRef: z12.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
176
+
177
+ // src/operations/createBlockRow.ts
178
+ var createBlockRow = writeOperation3(CreateBlockRowMutationSchema, BlockParagraphSchema, (txn) => {
179
+ const ref = txn.createRef("BlockRow");
180
+ const { parentRef } = txn.payload;
181
+ return QueryChain2(Query3(() => txn.readEntity(parentRef)), Query3((parent) => {
182
+ console.log("asdfasfd", parent);
183
+ return txn.patchEntity(parentRef, {
184
+ children: { blocks: [...parent.children.blocks, ref] }
185
+ });
186
+ }), Query3(() => txn.createEntity(ref, {
187
+ children: { blocks: [] },
188
+ parents: { parent: parentRef }
189
+ })), Query3((block, updatedParent) => ({ block, updatedParent })));
190
+ }, { changeSetOnly: true });
191
+
192
+ // src/operations/createBlockTitle.ts
193
+ import { Query as Query4, writeOperation as writeOperation4 } from "roc-db";
194
+
195
+ // src/schemas/CreateBlockTitleMutationSchema.ts
196
+ import { mutationSchemaGenerator as mutationSchemaGenerator8 } from "roc-db";
197
+ import { z as z13 } from "zod";
198
+ var CreateBlockTitleMutationSchema = mutationSchemaGenerator8("createBlockTitle", z13.object({ parentRef: z13.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
199
+
200
+ // src/operations/createBlockTitle.ts
201
+ var createBlockTitle = writeOperation4(CreateBlockTitleMutationSchema, BlockTitleSchema, (txn) => {
202
+ const ref = txn.createRef("BlockTitle");
203
+ const { postRef } = txn.payload;
204
+ return Query4(() => txn.createEntity(ref, { parents: { post: postRef } }));
205
+ }, { changeSetOnly: true });
206
+
207
+ // src/operations/createDraft.ts
208
+ import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
209
+
210
+ // src/schemas/CreateDraftMutationSchema.ts
211
+ import { mutationSchemaGenerator as mutationSchemaGenerator9 } from "roc-db";
212
+ import { z as z14 } from "zod";
213
+ var CreateDraftMutationSchema = mutationSchemaGenerator9("createDraft", z14.object({ postRef: PostRefSchema }).strict());
214
+
215
+ // src/operations/createDraft.ts
216
+ var createDraft = writeOperation5(CreateDraftMutationSchema, DraftSchema, (txn) => {
217
+ const ref = txn.createRef("Draft");
218
+ const { postRef } = txn.payload;
219
+ return Query5(() => txn.createEntity(ref, {
220
+ parents: {
221
+ post: postRef
222
+ }
223
+ }));
224
+ });
225
+
226
+ // src/operations/createPost.ts
227
+ import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
228
+ var createPost = writeOperation6(CreatePostMutationSchema, PostSchema, (txn) => {
229
+ const ref = txn.createRef("Post");
230
+ const { title, slug, tags } = txn.payload;
231
+ return Query6(() => txn.createEntity(ref, {
232
+ data: { title, tags, slug },
233
+ children: { blocks: [] }
234
+ }));
235
+ });
236
+
237
+ // src/operations/deleteBlock.ts
238
+ import { Query as Query7, QueryChain as QueryChain3, writeOperation as writeOperation7 } from "roc-db";
239
+
240
+ // src/schemas/DeleteBlockMutationSchema.ts
241
+ import { mutationSchemaGenerator as mutationSchemaGenerator10 } from "roc-db";
242
+ import { z as z15 } from "zod";
243
+ var DeleteBlockMutationSchema = mutationSchemaGenerator10("deleteBlock", z15.union([BlockParagraphRefSchema, BlockImageRefSchema]));
244
+
245
+ // src/operations/deleteBlock.ts
246
+ var deleteBlock = writeOperation7(DeleteBlockMutationSchema, PostSchema, (txn) => {
247
+ const blockRef = txn.payload;
248
+ return QueryChain3(Query7(() => txn.readEntity(blockRef, true)), Query7((block) => txn.readEntity(block.parents.post, true)), Query7((post) => {
249
+ return txn.patchEntity(post.ref, {
250
+ data: {
251
+ blockRefs: post.data.blockRefs.filter((ref) => ref !== blockRef)
252
+ }
253
+ });
254
+ }), Query7(() => txn.deleteEntity(blockRef)), Query7((_, updatedPost) => {
255
+ return updatedPost;
256
+ }));
257
+ }, { changeSetOnly: true });
258
+
259
+ // src/operations/deletePost.ts
260
+ import { Query as Query8, writeOperation as writeOperation8 } from "roc-db";
261
+
262
+ // src/schemas/DeletePostMutationSchema.ts
263
+ import { mutationSchemaGenerator as mutationSchemaGenerator11 } from "roc-db";
264
+ var DeletePostMutationSchema = mutationSchemaGenerator11("deletePost", PostRefSchema);
265
+
266
+ // src/operations/deletePost.ts
267
+ var deletePost = writeOperation8(DeletePostMutationSchema, undefined, (txn) => {
268
+ const ref = txn.payload;
269
+ return Query8(() => txn.deleteEntity(ref, true));
270
+ });
271
+
272
+ // src/operations/readEntity.ts
273
+ import { NotFoundError, Query as Query9, QueryChain as QueryChain4, readOperation } from "roc-db";
274
+ import { z as z16 } from "zod";
275
+ var readEntity = readOperation("readEntity", z16.string(), z16.union([PostSchema, BlockImageSchema, BlockParagraphSchema]), (txn) => {
276
+ const ref = txn.payload;
277
+ return QueryChain4(Query9(() => txn.readEntity(ref)), Query9((entity) => {
278
+ if (!entity) {
279
+ throw new NotFoundError(ref);
280
+ }
281
+ return entity;
282
+ }));
283
+ });
284
+
285
+ // src/operations/readPost.ts
286
+ import { Query as Query10, readOperation as readOperation2 } from "roc-db";
287
+ var readPost = readOperation2("readPost", PostRefSchema, PostSchema, (txn) => {
288
+ const ref = txn.payload;
289
+ return Query10(() => txn.readEntity(ref));
290
+ });
291
+
292
+ // src/operations/updateBlockParagraph.ts
293
+ import { Query as Query11, writeOperation as writeOperation9 } from "roc-db";
294
+
295
+ // src/schemas/UpdateBlockParagraphMutationSchema.ts
296
+ import { mutationSchemaGenerator as mutationSchemaGenerator12 } from "roc-db";
297
+ import { z as z17 } from "zod";
298
+ var UpdateBlockParagraphMutationSchema = mutationSchemaGenerator12("updateBlockParagraph", z17.object({
299
+ ref: BlockParagraphRefSchema,
300
+ content: z17.string()
301
+ }));
302
+
303
+ // src/operations/updateBlockParagraph.ts
304
+ var updateBlockParagraph = writeOperation9(UpdateBlockParagraphMutationSchema, BlockParagraphRefSchema, (txn) => {
305
+ const { ref, content } = txn.payload;
306
+ return Query11(() => txn.patchEntity(ref, {
307
+ data: { content }
308
+ }));
309
+ });
310
+
311
+ // src/operations/updatePost.ts
312
+ import { Query as Query12, writeOperation as writeOperation10 } from "roc-db";
313
+ var updatePost = writeOperation10(UpdatePostMutationSchema, PostSchema, (txn) => {
314
+ const { ref, authorRef, ...data } = txn.payload;
315
+ return Query12(() => txn.updateEntity(ref, {
316
+ data,
317
+ parents: { author: authorRef },
318
+ children: { blocks: [] }
319
+ }));
320
+ });
321
+
322
+ // src/operations/updatePostTitle.ts
323
+ import { Query as Query13, writeOperation as writeOperation11 } from "roc-db";
324
+ var updatePostTitle = writeOperation11(UpdatePostTitleMutationSchema, PostSchema, (txn) => {
325
+ const { ref, title } = txn.payload;
326
+ return Query13(() => txn.patchEntity(ref, { data: { title } }));
327
+ }, { debounce: 10 });
328
+
329
+ // src/operations/index.ts
330
+ var operations = [
331
+ createBlockImage,
332
+ createBlockTitle,
333
+ createBlockParagrah,
334
+ createBlockRow,
335
+ createDraft,
336
+ createPost,
337
+ deleteBlock,
338
+ deletePost,
339
+ readEntity,
340
+ readPost,
341
+ updateBlockParagraph,
342
+ updatePost,
343
+ updatePostTitle
344
+ ];
345
+ // src/testAdapterImplementation.ts
346
+ import { beforeAll, describe, expect, test } from "bun:test";
347
+ import { NotFoundError as NotFoundError2 } from "roc-db";
348
+ var prepareChangeSetTest = async (adapter) => {
349
+ const [post] = await adapter.createPost({
350
+ title: "Title 1",
351
+ slug: "title-1",
352
+ tags: ["Foo", "Bar"]
353
+ });
354
+ const [draft] = await adapter.createDraft({
355
+ postRef: post.ref
356
+ });
357
+ const changeSetAdapter = adapter.changeSet(draft.ref);
358
+ const [{ block: blockParagraph1 }] = await changeSetAdapter.createBlockParagraph({
359
+ parentRef: post.ref
360
+ });
361
+ const [{ block: blockRow, updatedParent }] = await changeSetAdapter.createBlockRow({
362
+ parentRef: post.ref
363
+ });
364
+ const [{ block: blockParagraph2 }] = await changeSetAdapter.createBlockParagraph({
365
+ parentRef: blockRow.ref
366
+ });
367
+ return {
368
+ postRef: post.ref,
369
+ draftRef: draft.ref,
370
+ changeSetAdapter,
371
+ blockParagraph1,
372
+ blockParagraph2,
373
+ blockRow,
374
+ post: updatedParent
375
+ };
376
+ };
377
+ var testAdapterImplementation = (adapterConstructor, engineArgsAdapter1 = {}, engineArgsAdapter2 = {}) => {
378
+ return async () => {
379
+ const adapter1 = adapterConstructor({ operations, entities, ...engineArgsAdapter1 });
380
+ const adapter2 = adapterConstructor({ operations, entities, ...engineArgsAdapter2 });
381
+ describe("changeSet", async () => {
382
+ let postRef, draftRef, changeSetAdapter, block, post, blockRow, blockParagraph2;
383
+ beforeAll(async () => {
384
+ const res = await prepareChangeSetTest(adapter1);
385
+ postRef = res.postRef;
386
+ draftRef = res.draftRef;
387
+ changeSetAdapter = res.changeSetAdapter;
388
+ block = res.blockParagraph1;
389
+ blockRow = res.blockRow;
390
+ blockParagraph2 = res.blockParagraph2;
391
+ post = res.post;
392
+ });
393
+ test("create (createEntity function w/changeSetRef)", async () => {
394
+ expect(block).toMatchZodSchema(BlockParagraphSchema);
395
+ expect(post).toMatchZodSchema(PostSchema);
396
+ });
397
+ test("read (readEntity function w/changeSetRef)", async () => {
398
+ const read = await changeSetAdapter.readEntity(block.ref);
399
+ expect(read).toMatchZodSchema(BlockParagraphSchema);
400
+ });
401
+ test("delete (with cascade delete)", async () => {
402
+ const [count, mutation] = await changeSetAdapter.deletePost(postRef);
403
+ expect(count).toBe(4);
404
+ expect(mutation.log).toStrictEqual([
405
+ [block.ref, "delete", draftRef],
406
+ [blockRow.ref, "delete", draftRef],
407
+ [blockParagraph2.ref, "delete", draftRef],
408
+ [postRef, "delete", draftRef]
409
+ ]);
410
+ });
411
+ test("update (patchEntity function w/changeSetRef)", async () => {
412
+ const [updatedBlock] = await changeSetAdapter.updateBlockParagraph({
413
+ ref: block.ref,
414
+ content: "Hello, world!"
415
+ });
416
+ expect(updatedBlock).toMatchZodSchema(BlockParagraphSchema);
417
+ });
418
+ test.skip("delete (deleteEntity function w/changeSetRef)", async () => {
419
+ const [updatedBlock, deleteMutation] = await changeSetAdapter.deleteBlock(block.ref);
420
+ expect(deleteMutation.log).toStrictEqual([
421
+ [postRef, "update", draftRef],
422
+ [block.ref, "delete", draftRef]
423
+ ]);
424
+ expect(() => changeSetAdapter.readEntity(block.ref)).toThrow(NotFoundError2);
425
+ expect(() => changeSetAdapter.updateBlockParagraph({
426
+ ref: block.ref,
427
+ content: "Foo"
428
+ })).toThrow(NotFoundError2);
429
+ });
430
+ });
431
+ };
432
+ };
433
+ // src/inMemoryAdapter.ts
434
+ import { createInMemoryAdapter } from "@roc-db/in-memory";
435
+ var inMemoryAdapter = createInMemoryAdapter({
436
+ operations,
437
+ entities
438
+ });
439
+ export {
440
+ testAdapterImplementation,
441
+ operations,
442
+ inMemoryAdapter,
443
+ entities,
444
+ UserRefSchema,
445
+ UpdatePostTitleMutationSchema,
446
+ UpdatePostMutationSchema,
447
+ PostSchema,
448
+ PostRefSchema,
449
+ DraftSchema,
450
+ DraftRefSchema,
451
+ CreateUserMutationSchema,
452
+ CreatePostMutationSchema,
453
+ BlockTitleSchema,
454
+ BlockParagraphSchema,
455
+ BlockImageSchema
456
+ };
@@ -0,0 +1,7 @@
1
+ // src/setup/index.ts
2
+ import { expect } from "bun:test";
3
+ var toMatchZodSchema = (received, schema) => {
4
+ const res = schema.safeParse(received);
5
+ return { pass: res.success, message: () => res.error?.message };
6
+ };
7
+ expect.extend({ toMatchZodSchema });
@@ -0,0 +1 @@
1
+ export declare const inMemoryAdapter: any;
@@ -0,0 +1,4 @@
1
+ export * from "./schemas";
2
+ export * from "./operations";
3
+ export { testAdapterImplementation } from "./testAdapterImplementation";
4
+ export { inMemoryAdapter } from "./inMemoryAdapter";
@@ -0,0 +1,15 @@
1
+ export declare const createBlockImage: import("roc-db").WriteOperation<"createBlockImage", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: {
6
+ postRef: `Post/${string}`;
7
+ };
8
+ log: [never, string, null][];
9
+ debounceCount: number;
10
+ name: "createBlockImage";
11
+ }, {
12
+ postRef: `Post/${string}`;
13
+ }, {
14
+ [x: string]: any;
15
+ }>;
@@ -0,0 +1,15 @@
1
+ export declare const createBlockParagrah: import("roc-db").WriteOperation<"createBlockParagraph", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: {
6
+ parentRef: `Post/${string}` | `BlockRow/${string}`;
7
+ };
8
+ log: [never, string, null][];
9
+ debounceCount: number;
10
+ name: "createBlockParagraph";
11
+ }, {
12
+ parentRef: `Post/${string}` | `BlockRow/${string}`;
13
+ }, {
14
+ [x: string]: any;
15
+ }>;
@@ -0,0 +1,15 @@
1
+ export declare const createBlockRow: import("roc-db").WriteOperation<"createBlockRow", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: {
6
+ parentRef: `Post/${string}` | `BlockRow/${string}`;
7
+ };
8
+ log: [never, string, null][];
9
+ debounceCount: number;
10
+ name: "createBlockRow";
11
+ }, {
12
+ parentRef: `Post/${string}` | `BlockRow/${string}`;
13
+ }, {
14
+ [x: string]: any;
15
+ }>;
@@ -0,0 +1,15 @@
1
+ export declare const createBlockTitle: import("roc-db").WriteOperation<"createBlockTitle", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: {
6
+ parentRef: `Post/${string}` | `BlockRow/${string}`;
7
+ };
8
+ log: [never, string, null][];
9
+ debounceCount: number;
10
+ name: "createBlockTitle";
11
+ }, {
12
+ parentRef: `Post/${string}` | `BlockRow/${string}`;
13
+ }, {
14
+ [x: string]: any;
15
+ }>;
@@ -0,0 +1,15 @@
1
+ export declare const createDraft: import("roc-db").WriteOperation<"createDraft", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: {
6
+ postRef: `Post/${string}`;
7
+ };
8
+ log: [never, string, null][];
9
+ debounceCount: number;
10
+ name: "createDraft";
11
+ }, {
12
+ postRef: `Post/${string}`;
13
+ }, {
14
+ [x: string]: any;
15
+ }>;
@@ -0,0 +1,19 @@
1
+ export declare const createPost: import("roc-db").WriteOperation<"createPost", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: {
6
+ title: string;
7
+ tags: string[];
8
+ slug?: string | undefined;
9
+ };
10
+ log: [never, string, null][];
11
+ debounceCount: number;
12
+ name: "createPost";
13
+ }, {
14
+ title: string;
15
+ tags: string[];
16
+ slug?: string | undefined;
17
+ }, {
18
+ [x: string]: any;
19
+ }>;
@@ -0,0 +1,11 @@
1
+ export declare const deleteBlock: import("roc-db").WriteOperation<"deleteBlock", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: `BlockImage/${string}` | `BlockParagraph/${string}`;
6
+ log: [never, string, null][];
7
+ debounceCount: number;
8
+ name: "deleteBlock";
9
+ }, `BlockImage/${string}` | `BlockParagraph/${string}`, {
10
+ [x: string]: any;
11
+ }>;
@@ -0,0 +1,9 @@
1
+ export declare const deletePost: import("roc-db").WriteOperation<"deletePost", {
2
+ ref: `Mutation/${string}`;
3
+ timestamp: string;
4
+ changeSetRef: null;
5
+ payload: `Post/${string}`;
6
+ log: [never, string, null][];
7
+ debounceCount: number;
8
+ name: "deletePost";
9
+ }, `Post/${string}`, any>;