@roc-db/test-utils 0.2.0-pre.45 → 0.2.0-pre.47

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 (41) hide show
  1. package/dist/index.js +181 -114
  2. package/dist/types/operations/createBlockImage.d.ts +1 -1
  3. package/dist/types/operations/createBlockParagraph.d.ts +1 -1
  4. package/dist/types/operations/createBlockRow.d.ts +1 -1
  5. package/dist/types/operations/createBlockTitle.d.ts +1 -1
  6. package/dist/types/operations/createDraft.d.ts +1 -1
  7. package/dist/types/operations/createPost.d.ts +1 -1
  8. package/dist/types/operations/deleteBlocks.d.ts +1 -1
  9. package/dist/types/operations/deleteDraft.d.ts +5 -0
  10. package/dist/types/operations/index.d.ts +15 -11
  11. package/dist/types/operations/testTransactionalEdits.d.ts +1 -1
  12. package/dist/types/operations/updatePost.d.ts +1 -1
  13. package/dist/types/operations/updatePostDescription.d.ts +1 -1
  14. package/dist/types/operations/updatePostTitle.d.ts +1 -1
  15. package/dist/types/schemas/ApplyDraftMutationSchema.d.ts +2 -2
  16. package/dist/types/schemas/BlockImageSchema.d.ts +3 -3
  17. package/dist/types/schemas/BlockParagraphSchema.d.ts +3 -3
  18. package/dist/types/schemas/BlockRowSchema.d.ts +3 -3
  19. package/dist/types/schemas/BlockTitleSchema.d.ts +3 -3
  20. package/dist/types/schemas/CreateBlockImageMutationSchema.d.ts +2 -2
  21. package/dist/types/schemas/CreateBlockParagraphMutationSchema.d.ts +2 -2
  22. package/dist/types/schemas/CreateBlockRowMutationSchema.d.ts +2 -2
  23. package/dist/types/schemas/CreateBlockTitleMutationSchema.d.ts +2 -2
  24. package/dist/types/schemas/CreateDraftMutationSchema.d.ts +2 -2
  25. package/dist/types/schemas/CreatePostMutationSchema.d.ts +2 -2
  26. package/dist/types/schemas/CreateUserMutationSchema.d.ts +2 -2
  27. package/dist/types/schemas/DeleteBlocksMutationSchema.d.ts +2 -2
  28. package/dist/types/schemas/DeleteDraftMutationSchema.d.ts +53 -0
  29. package/dist/types/schemas/DeletePostMutationSchema.d.ts +2 -2
  30. package/dist/types/schemas/DraftSchema.d.ts +3 -3
  31. package/dist/types/schemas/MoveBlocksMutationSchema.d.ts +2 -2
  32. package/dist/types/schemas/PostSchema.d.ts +3 -3
  33. package/dist/types/schemas/PostVersionRefSchema.d.ts +1 -0
  34. package/dist/types/schemas/PostVersionSchema.d.ts +85 -0
  35. package/dist/types/schemas/TestTransactionalEditsMutationSchema.d.ts +2 -2
  36. package/dist/types/schemas/UpdateBlockParagraphMutationSchema.d.ts +2 -2
  37. package/dist/types/schemas/UpdatePostDescriptionMutationSchema.d.ts +2 -2
  38. package/dist/types/schemas/UpdatePostMutationSchema.d.ts +2 -2
  39. package/dist/types/schemas/UpdatePostTitleMutationSchema.d.ts +2 -2
  40. package/dist/types/schemas/index.d.ts +179 -15
  41. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -40,101 +40,148 @@ var BlockParagraphSchema = entitySchemaGenerator2("BlockParagraph", {
40
40
  })
41
41
  });
42
42
 
43
- // src/schemas/BlockTitleSchema.ts
43
+ // src/schemas/BlockRowSchema.ts
44
44
  import { entitySchemaGenerator as entitySchemaGenerator3 } from "roc-db";
45
+ import { z as z4 } from "zod";
46
+
47
+ // src/schemas/BlockRowRefSchema.ts
48
+ import { refSchemaGenerator as refSchemaGenerator4 } from "roc-db";
49
+ var BlockRowRefSchema = refSchemaGenerator4("BlockRow");
50
+
51
+ // src/schemas/BlockRefSchema.ts
45
52
  import { z as z3 } from "zod";
53
+ var BlockRefSchema = z3.union([
54
+ BlockParagraphRefSchema,
55
+ BlockRowRefSchema
56
+ ]);
57
+
58
+ // src/schemas/BlockRowSchema.ts
59
+ var BlockRowSchema = entitySchemaGenerator3("BlockRow", {
60
+ ref: BlockRowRefSchema,
61
+ children: z4.object({
62
+ blocks: z4.array(BlockRefSchema)
63
+ }),
64
+ parents: z4.object({
65
+ post: PostRefSchema,
66
+ block: BlockRefSchema
67
+ })
68
+ });
69
+
70
+ // src/schemas/BlockTitleSchema.ts
71
+ import { entitySchemaGenerator as entitySchemaGenerator4 } from "roc-db";
72
+ import { z as z5 } from "zod";
46
73
 
47
74
  // src/schemas/BlockTitleRefSchema.ts
48
- import { refSchemaGenerator as refSchemaGenerator4 } from "roc-db";
49
- var BlockTitleRefSchema = refSchemaGenerator4("BlockTitle");
75
+ import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
76
+ var BlockTitleRefSchema = refSchemaGenerator5("BlockTitle");
50
77
 
51
78
  // src/schemas/BlockTitleSchema.ts
52
- var BlockTitleSchema = entitySchemaGenerator3("BlockTitle", {
79
+ var BlockTitleSchema = entitySchemaGenerator4("BlockTitle", {
53
80
  ref: BlockTitleRefSchema,
54
- data: z3.object({
55
- content: z3.string()
81
+ data: z5.object({
82
+ content: z5.string()
56
83
  }),
57
- parents: z3.object({
84
+ parents: z5.object({
58
85
  post: PostRefSchema
59
86
  })
60
87
  });
61
88
 
62
89
  // src/schemas/DraftSchema.ts
63
- import { entitySchemaGenerator as entitySchemaGenerator4 } from "roc-db";
64
- import { z as z4 } from "zod";
90
+ import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
91
+ import { z as z6 } from "zod";
65
92
 
66
93
  // src/schemas/DraftRefSchema.ts
67
- import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
68
- var DraftRefSchema = refSchemaGenerator5("Draft");
94
+ import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
95
+ var DraftRefSchema = refSchemaGenerator6("Draft");
69
96
 
70
97
  // src/schemas/DraftSchema.ts
71
- var DraftSchema = entitySchemaGenerator4("Draft", {
98
+ var DraftSchema = entitySchemaGenerator5("Draft", {
72
99
  ref: DraftRefSchema,
73
- data: z4.object({
100
+ data: z6.object({
74
101
  postRef: PostRefSchema
75
102
  })
76
103
  });
77
104
 
78
105
  // src/schemas/PostSchema.ts
79
- import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
80
- import { z as z5 } from "zod";
106
+ import { entitySchemaGenerator as entitySchemaGenerator6 } from "roc-db";
107
+ import { z as z7 } from "zod";
81
108
 
82
109
  // src/schemas/UserRefSchema.ts
83
- import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
84
- var UserRefSchema = refSchemaGenerator6("User");
110
+ import { refSchemaGenerator as refSchemaGenerator7 } from "roc-db";
111
+ var UserRefSchema = refSchemaGenerator7("User");
85
112
 
86
113
  // src/schemas/PostSchema.ts
87
- var PostSchema = entitySchemaGenerator5("Post", {
114
+ var PostSchema = entitySchemaGenerator6("Post", {
88
115
  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()
116
+ data: z7.object({
117
+ title: z7.string(),
118
+ text: z7.string().optional(),
119
+ tags: z7.array(z7.string()),
120
+ slug: z7.string().optional()
94
121
  }),
95
- parents: z5.object({ author: UserRefSchema.optional() }),
96
- children: z5.object({ blocks: z5.array(z5.string()) })
122
+ parents: z7.object({ author: UserRefSchema.optional() }),
123
+ children: z7.object({ blocks: z7.array(z7.string()) })
124
+ });
125
+
126
+ // src/schemas/PostVersionSchema.ts
127
+ import { entitySchemaGenerator as entitySchemaGenerator7 } from "roc-db";
128
+ import { z as z8 } from "zod";
129
+
130
+ // src/schemas/PostVersionRefSchema.ts
131
+ import { refSchemaGenerator as refSchemaGenerator8 } from "roc-db";
132
+ var PostVersionRefSchema = refSchemaGenerator8("PostVersion");
133
+
134
+ // src/schemas/PostVersionSchema.ts
135
+ var PostVersionSchema = entitySchemaGenerator7("PostVersion", {
136
+ ref: PostVersionRefSchema,
137
+ data: z8.object({
138
+ version: z8.number(),
139
+ snapshot: z8.array(z8.any())
140
+ }),
141
+ parents: z8.object({ post: PostRefSchema })
97
142
  });
98
143
  // src/schemas/CreatePostMutationSchema.ts
99
144
  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([])
145
+ import { z as z9 } from "zod";
146
+ var CreatePostMutationSchema = mutationSchemaGenerator("createPost", z9.object({
147
+ title: z9.string(),
148
+ slug: z9.string().optional(),
149
+ tags: z9.array(z9.string()).default([])
105
150
  }).strict());
106
151
  // src/schemas/CreateUserMutationSchema.ts
107
152
  import { mutationSchemaGenerator as mutationSchemaGenerator2 } from "roc-db";
108
- import { z as z7 } from "zod";
109
- var CreateUserMutationSchema = mutationSchemaGenerator2("createUser", z7.object({ email: z7.string() }));
153
+ import { z as z10 } from "zod";
154
+ var CreateUserMutationSchema = mutationSchemaGenerator2("createUser", z10.object({ email: z10.string() }));
110
155
  // src/schemas/UpdatePostMutationSchema.ts
111
156
  import { mutationSchemaGenerator as mutationSchemaGenerator3 } from "roc-db";
112
- import { z as z8 } from "zod";
113
- var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z8.object({
157
+ import { z as z11 } from "zod";
158
+ var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z11.object({
114
159
  ref: PostRefSchema,
115
- title: z8.string().optional(),
116
- tags: z8.array(z8.string()).optional().default([]),
160
+ title: z11.string().optional(),
161
+ tags: z11.array(z11.string()).optional().default([]),
117
162
  authorRef: UserRefSchema.optional()
118
163
  }));
119
164
  // src/schemas/UpdatePostTitleMutationSchema.ts
120
165
  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() }));
166
+ import { z as z12 } from "zod";
167
+ var UpdatePostTitleMutationSchema = mutationSchemaGenerator4("updatePostTitle", z12.object({ ref: PostRefSchema, title: z12.string() }));
123
168
  // src/schemas/index.ts
124
169
  var entities = [
170
+ BlockRowSchema,
125
171
  BlockImageSchema,
126
172
  BlockParagraphSchema,
127
173
  BlockTitleSchema,
128
174
  DraftSchema,
129
- PostSchema
175
+ PostSchema,
176
+ PostVersionSchema
130
177
  ];
131
178
  // src/operations/applyDraft.ts
132
179
  import { Query, QueryChain, writeOperation } from "roc-db";
133
180
 
134
181
  // src/schemas/ApplyDraftMutationSchema.ts
135
182
  import { mutationSchemaGenerator as mutationSchemaGenerator5 } from "roc-db";
136
- import { z as z10 } from "zod";
137
- var ApplyDraftMutationSchema = mutationSchemaGenerator5("applyDraft", z10.object({ ref: DraftRefSchema }).strict());
183
+ import { z as z13 } from "zod";
184
+ var ApplyDraftMutationSchema = mutationSchemaGenerator5("applyDraft", z13.object({ ref: DraftRefSchema }).strict());
138
185
 
139
186
  // src/operations/applyDraft.ts
140
187
  var applyDraft = writeOperation(ApplyDraftMutationSchema, undefined, (txn) => {
@@ -154,8 +201,8 @@ import { Query as Query2, writeOperation as writeOperation2 } from "roc-db";
154
201
 
155
202
  // src/schemas/CreateBlockImageMutationSchema.ts
156
203
  import { mutationSchemaGenerator as mutationSchemaGenerator6 } from "roc-db";
157
- import { z as z11 } from "zod";
158
- var CreateBlockImageMutationSchema = mutationSchemaGenerator6("createBlockImage", z11.object({ postRef: PostRefSchema }).strict(), undefined, true);
204
+ import { z as z14 } from "zod";
205
+ var CreateBlockImageMutationSchema = mutationSchemaGenerator6("createBlockImage", z14.object({ postRef: PostRefSchema }).strict(), undefined, true);
159
206
 
160
207
  // src/operations/createBlockImage.ts
161
208
  var createBlockImage = writeOperation2(CreateBlockImageMutationSchema, BlockImageSchema, (txn) => {
@@ -169,14 +216,8 @@ import { Query as Query3, QueryChain as QueryChain2, writeOperation as writeOper
169
216
 
170
217
  // src/schemas/CreateBlockParagraphMutationSchema.ts
171
218
  import { mutationSchemaGenerator as mutationSchemaGenerator7 } from "roc-db";
172
- import { z as z12 } from "zod";
173
-
174
- // src/schemas/BlockRowRefSchema.ts
175
- import { refSchemaGenerator as refSchemaGenerator7 } from "roc-db";
176
- var BlockRowRefSchema = refSchemaGenerator7("BlockRow");
177
-
178
- // src/schemas/CreateBlockParagraphMutationSchema.ts
179
- var CreateBlockParagraphMutationSchema = mutationSchemaGenerator7("createBlockParagraph", z12.object({ parentRef: z12.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
219
+ import { z as z15 } from "zod";
220
+ var CreateBlockParagraphMutationSchema = mutationSchemaGenerator7("createBlockParagraph", z15.object({ parentRef: z15.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
180
221
 
181
222
  // src/operations/createBlockParagraph.ts
182
223
  var createBlockParagrah = writeOperation3(CreateBlockParagraphMutationSchema, BlockParagraphSchema, (txn) => {
@@ -192,8 +233,8 @@ import { Query as Query4, QueryChain as QueryChain3, writeOperation as writeOper
192
233
 
193
234
  // src/schemas/CreateBlockRowMutationSchema.ts
194
235
  import { mutationSchemaGenerator as mutationSchemaGenerator8 } from "roc-db";
195
- import { z as z13 } from "zod";
196
- var CreateBlockRowMutationSchema = mutationSchemaGenerator8("createBlockRow", z13.object({ parentRef: z13.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
236
+ import { z as z16 } from "zod";
237
+ var CreateBlockRowMutationSchema = mutationSchemaGenerator8("createBlockRow", z16.object({ parentRef: z16.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
197
238
 
198
239
  // src/operations/createBlockRow.ts
199
240
  var createBlockRow = writeOperation4(CreateBlockRowMutationSchema, BlockParagraphSchema, (txn) => {
@@ -214,8 +255,8 @@ import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
214
255
 
215
256
  // src/schemas/CreateBlockTitleMutationSchema.ts
216
257
  import { mutationSchemaGenerator as mutationSchemaGenerator9 } from "roc-db";
217
- import { z as z14 } from "zod";
218
- var CreateBlockTitleMutationSchema = mutationSchemaGenerator9("createBlockTitle", z14.object({ parentRef: z14.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
258
+ import { z as z17 } from "zod";
259
+ var CreateBlockTitleMutationSchema = mutationSchemaGenerator9("createBlockTitle", z17.object({ parentRef: z17.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
219
260
 
220
261
  // src/operations/createBlockTitle.ts
221
262
  var createBlockTitle = writeOperation5(CreateBlockTitleMutationSchema, BlockTitleSchema, (txn) => {
@@ -229,8 +270,8 @@ import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
229
270
 
230
271
  // src/schemas/CreateDraftMutationSchema.ts
231
272
  import { mutationSchemaGenerator as mutationSchemaGenerator10 } from "roc-db";
232
- import { z as z15 } from "zod";
233
- var CreateDraftMutationSchema = mutationSchemaGenerator10("createDraft", z15.object({ postRef: PostRefSchema }).strict());
273
+ import { z as z18 } from "zod";
274
+ var CreateDraftMutationSchema = mutationSchemaGenerator10("createDraft", z18.object({ postRef: PostRefSchema }).strict());
234
275
 
235
276
  // src/operations/createDraft.ts
236
277
  var createDraft = writeOperation6(CreateDraftMutationSchema, DraftSchema, (txn) => {
@@ -259,8 +300,8 @@ import { Query as Query8, QueryChain as QueryChain4, writeOperation as writeOper
259
300
 
260
301
  // src/schemas/DeleteBlocksMutationSchema.ts
261
302
  import { mutationSchemaGenerator as mutationSchemaGenerator11 } from "roc-db";
262
- import { z as z16 } from "zod";
263
- var DeleteBlocksMutationSchema = mutationSchemaGenerator11("deleteBlocks", z16.array(z16.union([
303
+ import { z as z19 } from "zod";
304
+ var DeleteBlocksMutationSchema = mutationSchemaGenerator11("deleteBlocks", z19.array(z19.union([
264
305
  BlockParagraphRefSchema,
265
306
  BlockImageRefSchema,
266
307
  BlockRowRefSchema
@@ -283,44 +324,57 @@ var deleteBlocks = writeOperation8(DeleteBlocksMutationSchema, PostSchema, (txn)
283
324
  return QueryChain4(...refs.map((ref) => DeleteBlockQuery(txn, ref)));
284
325
  }, { changeSetOnly: true });
285
326
 
327
+ // src/operations/deleteDraft.ts
328
+ import { Query as Query9, QueryChain as QueryChain5, writeOperation as writeOperation9 } from "roc-db";
329
+
330
+ // src/schemas/DeleteDraftMutationSchema.ts
331
+ import { mutationSchemaGenerator as mutationSchemaGenerator12 } from "roc-db";
332
+ var DeleteDraftMutationSchema = mutationSchemaGenerator12("deleteDraft", DraftRefSchema);
333
+
334
+ // src/operations/deleteDraft.ts
335
+ var deleteDraft = writeOperation9(DeleteDraftMutationSchema, undefined, (txn) => {
336
+ const ref = txn.payload;
337
+ return QueryChain5(Query9(() => txn.deleteEntity(ref, true)), Query9(() => txn.deleteChangeSet(ref)));
338
+ });
339
+
286
340
  // src/operations/deletePost.ts
287
- import { Query as Query9, writeOperation as writeOperation9 } from "roc-db";
341
+ import { Query as Query10, writeOperation as writeOperation10 } from "roc-db";
288
342
 
289
343
  // src/schemas/DeletePostMutationSchema.ts
290
- import { mutationSchemaGenerator as mutationSchemaGenerator12 } from "roc-db";
291
- var DeletePostMutationSchema = mutationSchemaGenerator12("deletePost", PostRefSchema);
344
+ import { mutationSchemaGenerator as mutationSchemaGenerator13 } from "roc-db";
345
+ var DeletePostMutationSchema = mutationSchemaGenerator13("deletePost", PostRefSchema);
292
346
 
293
347
  // src/operations/deletePost.ts
294
- var deletePost = writeOperation9(DeletePostMutationSchema, undefined, (txn) => {
348
+ var deletePost = writeOperation10(DeletePostMutationSchema, undefined, (txn) => {
295
349
  const ref = txn.payload;
296
- return Query9(() => txn.deleteEntity(ref, true));
350
+ return Query10(() => txn.deleteEntity(ref, true));
297
351
  });
298
352
 
299
353
  // src/operations/moveBlocks.ts
300
- import { Query as Query10, QueryChain as QueryChain5, writeOperation as writeOperation10 } from "roc-db";
354
+ import { Query as Query11, QueryChain as QueryChain6, writeOperation as writeOperation11 } from "roc-db";
301
355
 
302
356
  // src/schemas/MoveBlocksMutationSchema.ts
303
- import { mutationSchemaGenerator as mutationSchemaGenerator13 } from "roc-db";
304
- import { z as z17 } from "zod";
305
- var MoveBlocksMutationSchema = mutationSchemaGenerator13("moveBlocks", z17.object({
306
- refs: z17.array(z17.union([BlockParagraphRefSchema, BlockRowRefSchema])),
307
- targetPosition: z17.number().min(0)
357
+ import { mutationSchemaGenerator as mutationSchemaGenerator14 } from "roc-db";
358
+ import { z as z20 } from "zod";
359
+ var MoveBlocksMutationSchema = mutationSchemaGenerator14("moveBlocks", z20.object({
360
+ refs: z20.array(z20.union([BlockParagraphRefSchema, BlockRowRefSchema])),
361
+ targetPosition: z20.number().min(0)
308
362
  }).strict(), undefined, true);
309
363
 
310
364
  // src/operations/moveBlocks.ts
311
- var moveBlocks = writeOperation10(MoveBlocksMutationSchema, undefined, (txn) => {
365
+ var moveBlocks = writeOperation11(MoveBlocksMutationSchema, undefined, (txn) => {
312
366
  const { refs } = txn.payload;
313
- return QueryChain5(Query10(() => txn.batchReadEntities(refs)), Query10((items) => {
367
+ return QueryChain6(Query11(() => txn.batchReadEntities(refs)), Query11((items) => {
314
368
  return "todo";
315
369
  }));
316
370
  });
317
371
 
318
372
  // src/operations/readEntity.ts
319
- import { NotFoundError, Query as Query11, QueryChain as QueryChain6, readOperation } from "roc-db";
320
- import { z as z18 } from "zod";
321
- var readEntity = readOperation("readEntity", z18.string(), z18.union([PostSchema, BlockImageSchema, BlockParagraphSchema]), (txn) => {
373
+ import { NotFoundError, Query as Query12, QueryChain as QueryChain7, readOperation } from "roc-db";
374
+ import { z as z21 } from "zod";
375
+ var readEntity = readOperation("readEntity", z21.string(), z21.union([PostSchema, BlockImageSchema, BlockParagraphSchema]), (txn) => {
322
376
  const ref = txn.payload;
323
- return QueryChain6(Query11(() => txn.readEntity(ref)), Query11((entity) => {
377
+ return QueryChain7(Query12(() => txn.readEntity(ref)), Query12((entity) => {
324
378
  if (!entity) {
325
379
  throw new NotFoundError(ref);
326
380
  }
@@ -329,11 +383,11 @@ var readEntity = readOperation("readEntity", z18.string(), z18.union([PostSchema
329
383
  });
330
384
 
331
385
  // src/operations/readMutation.ts
332
- import { NotFoundError as NotFoundError2, Query as Query12, QueryChain as QueryChain7, readOperation as readOperation2 } from "roc-db";
333
- import { z as z19 } from "zod";
334
- var readMutation = readOperation2("readMutation", z19.string(), z19.any(), (txn) => {
386
+ import { NotFoundError as NotFoundError2, Query as Query13, QueryChain as QueryChain8, readOperation as readOperation2 } from "roc-db";
387
+ import { z as z22 } from "zod";
388
+ var readMutation = readOperation2("readMutation", z22.string(), z22.any(), (txn) => {
335
389
  const ref = txn.payload;
336
- return QueryChain7(Query12(() => txn.readMutation(ref)), Query12((entity) => {
390
+ return QueryChain8(Query13(() => txn.readMutation(ref)), Query13((entity) => {
337
391
  if (!entity) {
338
392
  throw new NotFoundError2(ref);
339
393
  }
@@ -342,20 +396,20 @@ var readMutation = readOperation2("readMutation", z19.string(), z19.any(), (txn)
342
396
  });
343
397
 
344
398
  // src/operations/readPost.ts
345
- import { Query as Query13, readOperation as readOperation3 } from "roc-db";
399
+ import { Query as Query14, readOperation as readOperation3 } from "roc-db";
346
400
  var readPost = readOperation3("readPost", PostRefSchema, PostSchema, (txn) => {
347
401
  const ref = txn.payload;
348
- return Query13(() => txn.readEntity(ref, true));
402
+ return Query14(() => txn.readEntity(ref, true));
349
403
  });
350
404
 
351
405
  // src/operations/testTransactionalEdits.ts
352
- import { Query as Query14, QueryChain as QueryChain8, writeOperation as writeOperation11 } from "roc-db";
406
+ import { Query as Query15, QueryChain as QueryChain9, writeOperation as writeOperation12 } from "roc-db";
353
407
 
354
408
  // src/schemas/TestTransactionalEditsMutationSchema.ts
355
- import { mutationSchemaGenerator as mutationSchemaGenerator14 } from "roc-db";
356
- import { z as z20 } from "zod";
357
- var TestTransactionalEditsMutationSchema = mutationSchemaGenerator14("testTransactionalEdits", z20.object({
358
- name: z20.string().optional(),
409
+ import { mutationSchemaGenerator as mutationSchemaGenerator15 } from "roc-db";
410
+ import { z as z23 } from "zod";
411
+ var TestTransactionalEditsMutationSchema = mutationSchemaGenerator15("testTransactionalEdits", z23.object({
412
+ name: z23.string().optional(),
359
413
  post1ref: PostRefSchema.optional(),
360
414
  post2ref: PostRefSchema.optional()
361
415
  }).strict());
@@ -364,29 +418,29 @@ var TestTransactionalEditsMutationSchema = mutationSchemaGenerator14("testTransa
364
418
  import { expect } from "bun:test";
365
419
  var TestCreatePatchDeleteInSameTransaction = (txn, name) => {
366
420
  const postRef = txn.createRef("Post");
367
- QueryChain8(Query14(() => txn.createEntity(postRef, { data: { name } })), Query14(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query14((post) => {
421
+ QueryChain9(Query15(() => txn.createEntity(postRef, { data: { name } })), Query15(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query15((post) => {
368
422
  expect(post.data.name).toBe(name);
369
423
  expect(post.data.foo).toBe("bar");
370
- }), Query14(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query14((post) => {
424
+ }), Query15(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query15((post) => {
371
425
  expect(post.data.name).toBe(name);
372
426
  expect(post.data.foo).toBeUndefined();
373
427
  expect(post.data.bar).toBe("foo");
374
428
  expect(txn.log).toHaveLength(1);
375
429
  expect(txn.log.get(postRef)[0]).toBe("create");
376
- }), Query14((post) => txn.deleteEntity(postRef)), Query14((res) => {
430
+ }), Query15((post) => txn.deleteEntity(postRef)), Query15((res) => {
377
431
  expect(res).toBe(1);
378
432
  expect(txn.log).toHaveLength(0);
379
433
  }));
380
434
  };
381
435
  var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
382
- return QueryChain8(Query14(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query14((post) => {
436
+ return QueryChain9(Query15(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query15((post) => {
383
437
  expect(post.data.foo).toBe("bar");
384
- }), Query14(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query14((post) => {
438
+ }), Query15(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query15((post) => {
385
439
  expect(post.data.foo).toBeUndefined();
386
440
  expect(post.data.bar).toBe("foo");
387
441
  expect(txn.log).toHaveLength(1);
388
442
  expect(txn.log.get(ref)[0]).toBe("update");
389
- }), Query14((post) => txn.deleteEntity(ref)), Query14((res) => {
443
+ }), Query15((post) => txn.deleteEntity(ref)), Query15((res) => {
390
444
  expect(res).toBe(1);
391
445
  expect(txn.log).toHaveLength(1);
392
446
  expect(txn.log.get(ref)[0]).toBe("delete");
@@ -394,9 +448,9 @@ var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
394
448
  };
395
449
  var TestCreateOnExistingRef = (txn) => {
396
450
  const ref = txn.createRef("Post");
397
- return QueryChain8(Query14(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query14(() => txn.createEntity(ref, { data: { foo: "bar" } })));
451
+ return QueryChain9(Query15(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query15(() => txn.createEntity(ref, { data: { foo: "bar" } })));
398
452
  };
399
- var testTransactionalEdits = writeOperation11(TestTransactionalEditsMutationSchema, PostSchema, (txn) => {
453
+ var testTransactionalEdits = writeOperation12(TestTransactionalEditsMutationSchema, PostSchema, (txn) => {
400
454
  const { name, post1ref, post2ref } = txn.payload;
401
455
  if (name)
402
456
  return TestCreatePatchDeleteInSameTransaction(txn, name);
@@ -407,29 +461,29 @@ var testTransactionalEdits = writeOperation11(TestTransactionalEditsMutationSche
407
461
  }, {});
408
462
 
409
463
  // src/operations/updateBlockParagraph.ts
410
- import { Query as Query15, writeOperation as writeOperation12 } from "roc-db";
464
+ import { Query as Query16, writeOperation as writeOperation13 } from "roc-db";
411
465
 
412
466
  // src/schemas/UpdateBlockParagraphMutationSchema.ts
413
- import { mutationSchemaGenerator as mutationSchemaGenerator15 } from "roc-db";
414
- import { z as z21 } from "zod";
415
- var UpdateBlockParagraphMutationSchema = mutationSchemaGenerator15("updateBlockParagraph", z21.object({
467
+ import { mutationSchemaGenerator as mutationSchemaGenerator16 } from "roc-db";
468
+ import { z as z24 } from "zod";
469
+ var UpdateBlockParagraphMutationSchema = mutationSchemaGenerator16("updateBlockParagraph", z24.object({
416
470
  ref: BlockParagraphRefSchema,
417
- content: z21.string()
471
+ content: z24.string()
418
472
  }));
419
473
 
420
474
  // src/operations/updateBlockParagraph.ts
421
- var updateBlockParagraph = writeOperation12(UpdateBlockParagraphMutationSchema, BlockParagraphRefSchema, (txn) => {
475
+ var updateBlockParagraph = writeOperation13(UpdateBlockParagraphMutationSchema, BlockParagraphRefSchema, (txn) => {
422
476
  const { ref, content } = txn.payload;
423
- return Query15(() => txn.patchEntity(ref, {
477
+ return Query16(() => txn.patchEntity(ref, {
424
478
  data: { content }
425
479
  }));
426
480
  });
427
481
 
428
482
  // src/operations/updatePost.ts
429
- import { Query as Query16, writeOperation as writeOperation13 } from "roc-db";
430
- var updatePost = writeOperation13(UpdatePostMutationSchema, PostSchema, (txn) => {
483
+ import { Query as Query17, writeOperation as writeOperation14 } from "roc-db";
484
+ var updatePost = writeOperation14(UpdatePostMutationSchema, PostSchema, (txn) => {
431
485
  const { ref, authorRef, ...data } = txn.payload;
432
- return Query16(() => txn.updateEntity(ref, {
486
+ return Query17(() => txn.updateEntity(ref, {
433
487
  data,
434
488
  parents: { author: authorRef },
435
489
  children: { blocks: [] }
@@ -437,24 +491,24 @@ var updatePost = writeOperation13(UpdatePostMutationSchema, PostSchema, (txn) =>
437
491
  });
438
492
 
439
493
  // src/operations/updatePostDescription.ts
440
- import { Query as Query17, writeOperation as writeOperation14 } from "roc-db";
494
+ import { Query as Query18, writeOperation as writeOperation15 } from "roc-db";
441
495
 
442
496
  // src/schemas/UpdatePostDescriptionMutationSchema.ts
443
- import { mutationSchemaGenerator as mutationSchemaGenerator16 } from "roc-db";
444
- import { z as z22 } from "zod";
445
- var UpdatePostDescriptionMutationSchema = mutationSchemaGenerator16("updatePostDescription", z22.object({ ref: PostRefSchema, description: z22.string() }));
497
+ import { mutationSchemaGenerator as mutationSchemaGenerator17 } from "roc-db";
498
+ import { z as z25 } from "zod";
499
+ var UpdatePostDescriptionMutationSchema = mutationSchemaGenerator17("updatePostDescription", z25.object({ ref: PostRefSchema, description: z25.string() }));
446
500
 
447
501
  // src/operations/updatePostDescription.ts
448
- var updatePostDescription = writeOperation14(UpdatePostDescriptionMutationSchema, PostSchema, (txn) => {
502
+ var updatePostDescription = writeOperation15(UpdatePostDescriptionMutationSchema, PostSchema, (txn) => {
449
503
  const { ref, description } = txn.payload;
450
- return Query17(() => txn.patchEntity(ref, { data: { description } }));
504
+ return Query18(() => txn.patchEntity(ref, { data: { description } }));
451
505
  }, { debounce: 10, changeSetOnly: true });
452
506
 
453
507
  // src/operations/updatePostTitle.ts
454
- import { Query as Query18, writeOperation as writeOperation15 } from "roc-db";
455
- var updatePostTitle = writeOperation15(UpdatePostTitleMutationSchema, PostSchema, (txn) => {
508
+ import { Query as Query19, writeOperation as writeOperation16 } from "roc-db";
509
+ var updatePostTitle = writeOperation16(UpdatePostTitleMutationSchema, PostSchema, (txn) => {
456
510
  const { ref, title } = txn.payload;
457
- return Query18(() => txn.patchEntity(ref, { data: { title } }));
511
+ return Query19(() => txn.patchEntity(ref, { data: { title } }));
458
512
  }, { debounce: 10 });
459
513
 
460
514
  // src/operations/index.ts
@@ -467,6 +521,7 @@ var operations = [
467
521
  createDraft,
468
522
  createPost,
469
523
  deleteBlocks,
524
+ deleteDraft,
470
525
  deletePost,
471
526
  moveBlocks,
472
527
  readEntity,
@@ -745,6 +800,18 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
745
800
  ref: draftRef2
746
801
  });
747
802
  });
803
+ test("deleteDraft", async () => {
804
+ const { draftRef: draftRef2 } = await prepareChangeSetTest(adapter1);
805
+ const mutationsBefore = await adapter1.pageMutations({
806
+ changeSetRef: draftRef2
807
+ });
808
+ const [, mutation] = await adapter1.deleteDraft(draftRef2);
809
+ expect2(mutation.log).toHaveLength(mutationsBefore.length + 1);
810
+ const mutationsAfter = await adapter1.pageMutations({
811
+ changeSetRef: draftRef2
812
+ });
813
+ expect2(mutationsAfter).toHaveLength(0);
814
+ });
748
815
  test("init adapter2", async () => {
749
816
  const adapterA = await createAdapter({ optimistic: true });
750
817
  const adapterB = await createAdapter({ optimistic: true });
@@ -10,7 +10,7 @@ export declare const createBlockImage: import("roc-db").WriteOperation<string, {
10
10
  parents: {
11
11
  post: `Post/${string}`;
12
12
  };
13
- entity: string;
13
+ entity: "BlockImage";
14
14
  created: {
15
15
  mutationRef: `Mutation/${string}`;
16
16
  timestamp: string;
@@ -10,7 +10,7 @@ export declare const createBlockParagrah: import("roc-db").WriteOperation<string
10
10
  parents: {
11
11
  parent: `Post/${string}`;
12
12
  };
13
- entity: string;
13
+ entity: "BlockParagraph";
14
14
  created: {
15
15
  mutationRef: `Mutation/${string}`;
16
16
  timestamp: string;
@@ -10,7 +10,7 @@ export declare const createBlockRow: import("roc-db").WriteOperation<string, {
10
10
  parents: {
11
11
  parent: `Post/${string}`;
12
12
  };
13
- entity: string;
13
+ entity: "BlockParagraph";
14
14
  created: {
15
15
  mutationRef: `Mutation/${string}`;
16
16
  timestamp: string;
@@ -10,7 +10,7 @@ export declare const createBlockTitle: import("roc-db").WriteOperation<string, {
10
10
  parents: {
11
11
  post: `Post/${string}`;
12
12
  };
13
- entity: string;
13
+ entity: "BlockTitle";
14
14
  created: {
15
15
  mutationRef: `Mutation/${string}`;
16
16
  timestamp: string;
@@ -8,7 +8,7 @@ export declare const createDraft: import("roc-db").WriteOperation<string, {
8
8
  postRef: `Post/${string}`;
9
9
  };
10
10
  parents: {};
11
- entity: string;
11
+ entity: "Draft";
12
12
  created: {
13
13
  mutationRef: `Mutation/${string}`;
14
14
  timestamp: string;
@@ -13,7 +13,7 @@ export declare const createPost: import("roc-db").WriteOperation<string, {
13
13
  parents: {
14
14
  author?: `User/${string}` | undefined;
15
15
  };
16
- entity: string;
16
+ entity: "Post";
17
17
  created: {
18
18
  mutationRef: `Mutation/${string}`;
19
19
  timestamp: string;
@@ -13,7 +13,7 @@ export declare const deleteBlocks: import("roc-db").WriteOperation<string, {
13
13
  parents: {
14
14
  author?: `User/${string}` | undefined;
15
15
  };
16
- entity: string;
16
+ entity: "Post";
17
17
  created: {
18
18
  mutationRef: `Mutation/${string}`;
19
19
  timestamp: string;
@@ -0,0 +1,5 @@
1
+ export declare const deleteDraft: import("roc-db").WriteOperation<string, {
2
+ debounceCount: number;
3
+ name: string;
4
+ payload?: any;
5
+ }, any, any>;