@roc-db/test-utils 0.2.0-pre.45 → 0.2.0-pre.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +181 -114
- package/dist/types/operations/createBlockImage.d.ts +1 -1
- package/dist/types/operations/createBlockParagraph.d.ts +1 -1
- package/dist/types/operations/createBlockRow.d.ts +1 -1
- package/dist/types/operations/createBlockTitle.d.ts +1 -1
- package/dist/types/operations/createDraft.d.ts +1 -1
- package/dist/types/operations/createPost.d.ts +1 -1
- package/dist/types/operations/deleteBlocks.d.ts +1 -1
- package/dist/types/operations/deleteDraft.d.ts +5 -0
- package/dist/types/operations/index.d.ts +15 -11
- package/dist/types/operations/testTransactionalEdits.d.ts +1 -1
- package/dist/types/operations/updatePost.d.ts +1 -1
- package/dist/types/operations/updatePostDescription.d.ts +1 -1
- package/dist/types/operations/updatePostTitle.d.ts +1 -1
- package/dist/types/schemas/ApplyDraftMutationSchema.d.ts +2 -2
- package/dist/types/schemas/BlockImageSchema.d.ts +3 -3
- package/dist/types/schemas/BlockParagraphSchema.d.ts +3 -3
- package/dist/types/schemas/BlockRowSchema.d.ts +3 -3
- package/dist/types/schemas/BlockTitleSchema.d.ts +3 -3
- package/dist/types/schemas/CreateBlockImageMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreateBlockParagraphMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreateBlockRowMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreateBlockTitleMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreateDraftMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreatePostMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreateUserMutationSchema.d.ts +2 -2
- package/dist/types/schemas/DeleteBlocksMutationSchema.d.ts +2 -2
- package/dist/types/schemas/DeleteDraftMutationSchema.d.ts +53 -0
- package/dist/types/schemas/DeletePostMutationSchema.d.ts +2 -2
- package/dist/types/schemas/DraftSchema.d.ts +3 -3
- package/dist/types/schemas/MoveBlocksMutationSchema.d.ts +2 -2
- package/dist/types/schemas/PostSchema.d.ts +3 -3
- package/dist/types/schemas/PostVersionRefSchema.d.ts +1 -0
- package/dist/types/schemas/PostVersionSchema.d.ts +85 -0
- package/dist/types/schemas/TestTransactionalEditsMutationSchema.d.ts +2 -2
- package/dist/types/schemas/UpdateBlockParagraphMutationSchema.d.ts +2 -2
- package/dist/types/schemas/UpdatePostDescriptionMutationSchema.d.ts +2 -2
- package/dist/types/schemas/UpdatePostMutationSchema.d.ts +2 -2
- package/dist/types/schemas/UpdatePostTitleMutationSchema.d.ts +2 -2
- package/dist/types/schemas/index.d.ts +179 -15
- 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/
|
|
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
|
|
49
|
-
var BlockTitleRefSchema =
|
|
75
|
+
import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
|
|
76
|
+
var BlockTitleRefSchema = refSchemaGenerator5("BlockTitle");
|
|
50
77
|
|
|
51
78
|
// src/schemas/BlockTitleSchema.ts
|
|
52
|
-
var BlockTitleSchema =
|
|
79
|
+
var BlockTitleSchema = entitySchemaGenerator4("BlockTitle", {
|
|
53
80
|
ref: BlockTitleRefSchema,
|
|
54
|
-
data:
|
|
55
|
-
content:
|
|
81
|
+
data: z5.object({
|
|
82
|
+
content: z5.string()
|
|
56
83
|
}),
|
|
57
|
-
parents:
|
|
84
|
+
parents: z5.object({
|
|
58
85
|
post: PostRefSchema
|
|
59
86
|
})
|
|
60
87
|
});
|
|
61
88
|
|
|
62
89
|
// src/schemas/DraftSchema.ts
|
|
63
|
-
import { entitySchemaGenerator as
|
|
64
|
-
import { z as
|
|
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
|
|
68
|
-
var DraftRefSchema =
|
|
94
|
+
import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
|
|
95
|
+
var DraftRefSchema = refSchemaGenerator6("Draft");
|
|
69
96
|
|
|
70
97
|
// src/schemas/DraftSchema.ts
|
|
71
|
-
var DraftSchema =
|
|
98
|
+
var DraftSchema = entitySchemaGenerator5("Draft", {
|
|
72
99
|
ref: DraftRefSchema,
|
|
73
|
-
data:
|
|
100
|
+
data: z6.object({
|
|
74
101
|
postRef: PostRefSchema
|
|
75
102
|
})
|
|
76
103
|
});
|
|
77
104
|
|
|
78
105
|
// src/schemas/PostSchema.ts
|
|
79
|
-
import { entitySchemaGenerator as
|
|
80
|
-
import { z as
|
|
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
|
|
84
|
-
var UserRefSchema =
|
|
110
|
+
import { refSchemaGenerator as refSchemaGenerator7 } from "roc-db";
|
|
111
|
+
var UserRefSchema = refSchemaGenerator7("User");
|
|
85
112
|
|
|
86
113
|
// src/schemas/PostSchema.ts
|
|
87
|
-
var PostSchema =
|
|
114
|
+
var PostSchema = entitySchemaGenerator6("Post", {
|
|
88
115
|
ref: PostRefSchema,
|
|
89
|
-
data:
|
|
90
|
-
title:
|
|
91
|
-
text:
|
|
92
|
-
tags:
|
|
93
|
-
slug:
|
|
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:
|
|
96
|
-
children:
|
|
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
|
|
101
|
-
var CreatePostMutationSchema = mutationSchemaGenerator("createPost",
|
|
102
|
-
title:
|
|
103
|
-
slug:
|
|
104
|
-
tags:
|
|
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
|
|
109
|
-
var CreateUserMutationSchema = mutationSchemaGenerator2("createUser",
|
|
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
|
|
113
|
-
var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost",
|
|
157
|
+
import { z as z11 } from "zod";
|
|
158
|
+
var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z11.object({
|
|
114
159
|
ref: PostRefSchema,
|
|
115
|
-
title:
|
|
116
|
-
tags:
|
|
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
|
|
122
|
-
var UpdatePostTitleMutationSchema = mutationSchemaGenerator4("updatePostTitle",
|
|
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
|
|
137
|
-
var ApplyDraftMutationSchema = mutationSchemaGenerator5("applyDraft",
|
|
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
|
|
158
|
-
var CreateBlockImageMutationSchema = mutationSchemaGenerator6("createBlockImage",
|
|
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
|
|
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
|
|
196
|
-
var CreateBlockRowMutationSchema = mutationSchemaGenerator8("createBlockRow",
|
|
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
|
|
218
|
-
var CreateBlockTitleMutationSchema = mutationSchemaGenerator9("createBlockTitle",
|
|
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
|
|
233
|
-
var CreateDraftMutationSchema = mutationSchemaGenerator10("createDraft",
|
|
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
|
|
263
|
-
var DeleteBlocksMutationSchema = mutationSchemaGenerator11("deleteBlocks",
|
|
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
|
|
341
|
+
import { Query as Query10, writeOperation as writeOperation10 } from "roc-db";
|
|
288
342
|
|
|
289
343
|
// src/schemas/DeletePostMutationSchema.ts
|
|
290
|
-
import { mutationSchemaGenerator as
|
|
291
|
-
var DeletePostMutationSchema =
|
|
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 =
|
|
348
|
+
var deletePost = writeOperation10(DeletePostMutationSchema, undefined, (txn) => {
|
|
295
349
|
const ref = txn.payload;
|
|
296
|
-
return
|
|
350
|
+
return Query10(() => txn.deleteEntity(ref, true));
|
|
297
351
|
});
|
|
298
352
|
|
|
299
353
|
// src/operations/moveBlocks.ts
|
|
300
|
-
import { Query as
|
|
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
|
|
304
|
-
import { z as
|
|
305
|
-
var MoveBlocksMutationSchema =
|
|
306
|
-
refs:
|
|
307
|
-
targetPosition:
|
|
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 =
|
|
365
|
+
var moveBlocks = writeOperation11(MoveBlocksMutationSchema, undefined, (txn) => {
|
|
312
366
|
const { refs } = txn.payload;
|
|
313
|
-
return
|
|
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
|
|
320
|
-
import { z as
|
|
321
|
-
var readEntity = readOperation("readEntity",
|
|
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
|
|
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
|
|
333
|
-
import { z as
|
|
334
|
-
var readMutation = readOperation2("readMutation",
|
|
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
|
|
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
|
|
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
|
|
402
|
+
return Query14(() => txn.readEntity(ref, true));
|
|
349
403
|
});
|
|
350
404
|
|
|
351
405
|
// src/operations/testTransactionalEdits.ts
|
|
352
|
-
import { Query as
|
|
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
|
|
356
|
-
import { z as
|
|
357
|
-
var TestTransactionalEditsMutationSchema =
|
|
358
|
-
name:
|
|
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
|
-
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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
|
|
436
|
+
return QueryChain9(Query15(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query15((post) => {
|
|
383
437
|
expect(post.data.foo).toBe("bar");
|
|
384
|
-
}),
|
|
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
|
-
}),
|
|
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
|
|
451
|
+
return QueryChain9(Query15(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query15(() => txn.createEntity(ref, { data: { foo: "bar" } })));
|
|
398
452
|
};
|
|
399
|
-
var testTransactionalEdits =
|
|
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
|
|
464
|
+
import { Query as Query16, writeOperation as writeOperation13 } from "roc-db";
|
|
411
465
|
|
|
412
466
|
// src/schemas/UpdateBlockParagraphMutationSchema.ts
|
|
413
|
-
import { mutationSchemaGenerator as
|
|
414
|
-
import { z as
|
|
415
|
-
var UpdateBlockParagraphMutationSchema =
|
|
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:
|
|
471
|
+
content: z24.string()
|
|
418
472
|
}));
|
|
419
473
|
|
|
420
474
|
// src/operations/updateBlockParagraph.ts
|
|
421
|
-
var updateBlockParagraph =
|
|
475
|
+
var updateBlockParagraph = writeOperation13(UpdateBlockParagraphMutationSchema, BlockParagraphRefSchema, (txn) => {
|
|
422
476
|
const { ref, content } = txn.payload;
|
|
423
|
-
return
|
|
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
|
|
430
|
-
var updatePost =
|
|
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
|
|
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
|
|
494
|
+
import { Query as Query18, writeOperation as writeOperation15 } from "roc-db";
|
|
441
495
|
|
|
442
496
|
// src/schemas/UpdatePostDescriptionMutationSchema.ts
|
|
443
|
-
import { mutationSchemaGenerator as
|
|
444
|
-
import { z as
|
|
445
|
-
var UpdatePostDescriptionMutationSchema =
|
|
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 =
|
|
502
|
+
var updatePostDescription = writeOperation15(UpdatePostDescriptionMutationSchema, PostSchema, (txn) => {
|
|
449
503
|
const { ref, description } = txn.payload;
|
|
450
|
-
return
|
|
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
|
|
455
|
-
var updatePostTitle =
|
|
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
|
|
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 });
|