@roc-db/test-utils 0.2.0-pre.47 → 0.2.0-pre.49
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 +85 -131
- package/dist/types/operations/applyDraft.d.ts +1 -5
- package/dist/types/operations/createBlockImage.d.ts +8 -24
- package/dist/types/operations/createBlockParagraph.d.ts +8 -24
- package/dist/types/operations/createBlockRow.d.ts +8 -24
- package/dist/types/operations/createBlockTitle.d.ts +8 -24
- package/dist/types/operations/createDraft.d.ts +8 -22
- package/dist/types/operations/createPost.d.ts +14 -29
- package/dist/types/operations/deleteBlocks.d.ts +2 -29
- package/dist/types/operations/deleteDraft.d.ts +1 -5
- package/dist/types/operations/deletePost.d.ts +1 -5
- package/dist/types/operations/index.d.ts +98 -294
- package/dist/types/operations/moveBlocks.d.ts +11 -5
- package/dist/types/operations/testTransactionalEdits.d.ts +14 -29
- package/dist/types/operations/updateBlockParagraph.d.ts +11 -5
- package/dist/types/operations/updatePost.d.ts +16 -28
- package/dist/types/operations/updatePostDescription.d.ts +10 -28
- package/dist/types/operations/updatePostTitle.d.ts +10 -28
- package/dist/types/schemas/DraftSchema.d.ts +12 -12
- package/dist/types/schemas/index.d.ts +12 -12
- package/package.json +2 -2
- package/dist/types/schemas/ApplyDraftMutationSchema.d.ts +0 -64
- package/dist/types/schemas/CreateBlockImageMutationSchema.d.ts +0 -64
- package/dist/types/schemas/CreateBlockParagraphMutationSchema.d.ts +0 -64
- package/dist/types/schemas/CreateBlockRowMutationSchema.d.ts +0 -64
- package/dist/types/schemas/CreateBlockTitleMutationSchema.d.ts +0 -64
- package/dist/types/schemas/CreateDraftMutationSchema.d.ts +0 -64
- package/dist/types/schemas/DeleteBlocksMutationSchema.d.ts +0 -54
- package/dist/types/schemas/DeleteDraftMutationSchema.d.ts +0 -53
- package/dist/types/schemas/DeletePostMutationSchema.d.ts +0 -53
- package/dist/types/schemas/MoveBlocksMutationSchema.d.ts +0 -69
- package/dist/types/schemas/TestTransactionalEditsMutationSchema.d.ts +0 -74
- package/dist/types/schemas/UpdateBlockParagraphMutationSchema.d.ts +0 -69
- package/dist/types/schemas/UpdatePostDescriptionMutationSchema.d.ts +0 -69
package/dist/index.js
CHANGED
|
@@ -97,8 +97,8 @@ var DraftRefSchema = refSchemaGenerator6("Draft");
|
|
|
97
97
|
// src/schemas/DraftSchema.ts
|
|
98
98
|
var DraftSchema = entitySchemaGenerator5("Draft", {
|
|
99
99
|
ref: DraftRefSchema,
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
parents: z6.object({
|
|
101
|
+
post: PostRefSchema
|
|
102
102
|
})
|
|
103
103
|
});
|
|
104
104
|
|
|
@@ -177,15 +177,8 @@ var entities = [
|
|
|
177
177
|
];
|
|
178
178
|
// src/operations/applyDraft.ts
|
|
179
179
|
import { Query, QueryChain, writeOperation } from "roc-db";
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator5 } from "roc-db";
|
|
183
|
-
import { z as z13 } from "zod";
|
|
184
|
-
var ApplyDraftMutationSchema = mutationSchemaGenerator5("applyDraft", z13.object({ ref: DraftRefSchema }).strict());
|
|
185
|
-
|
|
186
|
-
// src/operations/applyDraft.ts
|
|
187
|
-
var applyDraft = writeOperation(ApplyDraftMutationSchema, undefined, (txn) => {
|
|
188
|
-
const { ref } = txn.payload;
|
|
180
|
+
var applyDraft = writeOperation("applyDraft", DraftRefSchema, (txn) => {
|
|
181
|
+
const ref = txn.payload;
|
|
189
182
|
const versionRef = txn.createRef("PostVersion");
|
|
190
183
|
return QueryChain(Query(() => txn.applyChangeSet(ref)), Query(() => txn.patchEntity(ref, {
|
|
191
184
|
data: { appliedAt: txn.timestamp }
|
|
@@ -198,46 +191,34 @@ var applyDraft = writeOperation(ApplyDraftMutationSchema, undefined, (txn) => {
|
|
|
198
191
|
|
|
199
192
|
// src/operations/createBlockImage.ts
|
|
200
193
|
import { Query as Query2, writeOperation as writeOperation2 } from "roc-db";
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator6 } from "roc-db";
|
|
204
|
-
import { z as z14 } from "zod";
|
|
205
|
-
var CreateBlockImageMutationSchema = mutationSchemaGenerator6("createBlockImage", z14.object({ postRef: PostRefSchema }).strict(), undefined, true);
|
|
206
|
-
|
|
207
|
-
// src/operations/createBlockImage.ts
|
|
208
|
-
var createBlockImage = writeOperation2(CreateBlockImageMutationSchema, BlockImageSchema, (txn) => {
|
|
194
|
+
import { z as z13 } from "zod";
|
|
195
|
+
var createBlockImage = writeOperation2("createBlockImage", z13.object({ postRef: PostRefSchema }).strict(), (txn) => {
|
|
209
196
|
const ref = txn.createRef("BlockImage");
|
|
210
197
|
const { postRef } = txn.payload;
|
|
211
198
|
return Query2(() => txn.createEntity(ref, { parents: { post: postRef } }));
|
|
212
|
-
}, { changeSetOnly: true });
|
|
199
|
+
}, { changeSetOnly: true, outputSchema: BlockImageSchema });
|
|
213
200
|
|
|
214
201
|
// src/operations/createBlockParagraph.ts
|
|
215
202
|
import { Query as Query3, QueryChain as QueryChain2, writeOperation as writeOperation3 } from "roc-db";
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator7 } from "roc-db";
|
|
219
|
-
import { z as z15 } from "zod";
|
|
220
|
-
var CreateBlockParagraphMutationSchema = mutationSchemaGenerator7("createBlockParagraph", z15.object({ parentRef: z15.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
|
|
221
|
-
|
|
222
|
-
// src/operations/createBlockParagraph.ts
|
|
223
|
-
var createBlockParagrah = writeOperation3(CreateBlockParagraphMutationSchema, BlockParagraphSchema, (txn) => {
|
|
203
|
+
import { z as z14 } from "zod";
|
|
204
|
+
var createBlockParagrah = writeOperation3("createBlockParagraph", z14.object({ parentRef: z14.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
|
|
224
205
|
const ref = txn.createRef("BlockParagraph");
|
|
225
206
|
const { parentRef } = txn.payload;
|
|
226
207
|
return QueryChain2(Query3(() => txn.readEntity(parentRef, true)), Query3((parent) => txn.patchEntity(parentRef, {
|
|
227
208
|
children: { blocks: [...parent.children.blocks, ref] }
|
|
228
209
|
})), Query3(() => txn.createEntity(ref, { parents: { parent: parentRef } })), Query3((block, updatedParent) => ({ block, updatedParent })));
|
|
229
|
-
}, {
|
|
210
|
+
}, {
|
|
211
|
+
changeSetOnly: true,
|
|
212
|
+
outputSchema: z14.object({
|
|
213
|
+
block: z14.any(),
|
|
214
|
+
updatedParent: z14.any()
|
|
215
|
+
})
|
|
216
|
+
});
|
|
230
217
|
|
|
231
218
|
// src/operations/createBlockRow.ts
|
|
232
219
|
import { Query as Query4, QueryChain as QueryChain3, writeOperation as writeOperation4 } from "roc-db";
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator8 } from "roc-db";
|
|
236
|
-
import { z as z16 } from "zod";
|
|
237
|
-
var CreateBlockRowMutationSchema = mutationSchemaGenerator8("createBlockRow", z16.object({ parentRef: z16.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
|
|
238
|
-
|
|
239
|
-
// src/operations/createBlockRow.ts
|
|
240
|
-
var createBlockRow = writeOperation4(CreateBlockRowMutationSchema, BlockParagraphSchema, (txn) => {
|
|
220
|
+
import { z as z15 } from "zod";
|
|
221
|
+
var createBlockRow = writeOperation4("createBlockRow", z15.object({ parentRef: z15.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
|
|
241
222
|
const ref = txn.createRef("BlockRow");
|
|
242
223
|
const { parentRef } = txn.payload;
|
|
243
224
|
return QueryChain3(Query4(() => txn.readEntity(parentRef)), Query4((parent) => {
|
|
@@ -248,33 +229,28 @@ var createBlockRow = writeOperation4(CreateBlockRowMutationSchema, BlockParagrap
|
|
|
248
229
|
children: { blocks: [] },
|
|
249
230
|
parents: { parent: parentRef }
|
|
250
231
|
})), Query4((block, updatedParent) => ({ block, updatedParent })));
|
|
251
|
-
}, {
|
|
232
|
+
}, {
|
|
233
|
+
changeSetOnly: true,
|
|
234
|
+
outputSchema: z15.object({
|
|
235
|
+
block: z15.any(),
|
|
236
|
+
updatedParent: z15.any()
|
|
237
|
+
})
|
|
238
|
+
});
|
|
252
239
|
|
|
253
240
|
// src/operations/createBlockTitle.ts
|
|
254
241
|
import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
import { z as z17 } from "zod";
|
|
259
|
-
var CreateBlockTitleMutationSchema = mutationSchemaGenerator9("createBlockTitle", z17.object({ parentRef: z17.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
|
|
260
|
-
|
|
261
|
-
// src/operations/createBlockTitle.ts
|
|
262
|
-
var createBlockTitle = writeOperation5(CreateBlockTitleMutationSchema, BlockTitleSchema, (txn) => {
|
|
242
|
+
import { z as z16 } from "zod";
|
|
243
|
+
var PayloadSchema = z16.object({ parentRef: z16.union([PostRefSchema, BlockRowRefSchema]) }).strict();
|
|
244
|
+
var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn) => {
|
|
263
245
|
const ref = txn.createRef("BlockTitle");
|
|
264
246
|
const { postRef } = txn.payload;
|
|
265
247
|
return Query5(() => txn.createEntity(ref, { parents: { post: postRef } }));
|
|
266
|
-
}, { changeSetOnly: true });
|
|
248
|
+
}, { changeSetOnly: true, outputSchema: BlockTitleSchema });
|
|
267
249
|
|
|
268
250
|
// src/operations/createDraft.ts
|
|
269
251
|
import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator10 } from "roc-db";
|
|
273
|
-
import { z as z18 } from "zod";
|
|
274
|
-
var CreateDraftMutationSchema = mutationSchemaGenerator10("createDraft", z18.object({ postRef: PostRefSchema }).strict());
|
|
275
|
-
|
|
276
|
-
// src/operations/createDraft.ts
|
|
277
|
-
var createDraft = writeOperation6(CreateDraftMutationSchema, DraftSchema, (txn) => {
|
|
252
|
+
import { z as z17 } from "zod";
|
|
253
|
+
var createDraft = writeOperation6("createDraft", z17.object({ postRef: PostRefSchema }).strict(), (txn) => {
|
|
278
254
|
const ref = txn.createRef("Draft");
|
|
279
255
|
const { postRef } = txn.payload;
|
|
280
256
|
return Query6(() => txn.createEntity(ref, {
|
|
@@ -282,11 +258,17 @@ var createDraft = writeOperation6(CreateDraftMutationSchema, DraftSchema, (txn)
|
|
|
282
258
|
post: postRef
|
|
283
259
|
}
|
|
284
260
|
}));
|
|
285
|
-
});
|
|
261
|
+
}, { outputSchema: DraftSchema });
|
|
286
262
|
|
|
287
263
|
// src/operations/createPost.ts
|
|
288
264
|
import { Query as Query7, writeOperation as writeOperation7 } from "roc-db";
|
|
289
|
-
|
|
265
|
+
import { z as z18 } from "zod";
|
|
266
|
+
var PayloadSchema2 = z18.object({
|
|
267
|
+
title: z18.string(),
|
|
268
|
+
slug: z18.string().optional(),
|
|
269
|
+
tags: z18.array(z18.string()).default([])
|
|
270
|
+
}).strict();
|
|
271
|
+
var createPost = writeOperation7("createPost", PayloadSchema2, (txn) => {
|
|
290
272
|
const ref = txn.createRef("Post");
|
|
291
273
|
const { title, slug, tags } = txn.payload;
|
|
292
274
|
return Query7(() => txn.createEntity(ref, {
|
|
@@ -297,17 +279,7 @@ var createPost = writeOperation7(CreatePostMutationSchema, PostSchema, (txn) =>
|
|
|
297
279
|
|
|
298
280
|
// src/operations/deleteBlocks.ts
|
|
299
281
|
import { Query as Query8, QueryChain as QueryChain4, writeOperation as writeOperation8 } from "roc-db";
|
|
300
|
-
|
|
301
|
-
// src/schemas/DeleteBlocksMutationSchema.ts
|
|
302
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator11 } from "roc-db";
|
|
303
282
|
import { z as z19 } from "zod";
|
|
304
|
-
var DeleteBlocksMutationSchema = mutationSchemaGenerator11("deleteBlocks", z19.array(z19.union([
|
|
305
|
-
BlockParagraphRefSchema,
|
|
306
|
-
BlockImageRefSchema,
|
|
307
|
-
BlockRowRefSchema
|
|
308
|
-
])));
|
|
309
|
-
|
|
310
|
-
// src/operations/deleteBlocks.ts
|
|
311
283
|
var DeleteBlockQuery = (txn, blockRef) => {
|
|
312
284
|
return QueryChain4(Query8(() => txn.readEntity(blockRef)), Query8((block) => {
|
|
313
285
|
return txn.readEntity(block.parents.parent, true);
|
|
@@ -319,50 +291,37 @@ var DeleteBlockQuery = (txn, blockRef) => {
|
|
|
319
291
|
});
|
|
320
292
|
}), Query8(() => txn.deleteEntity(blockRef)));
|
|
321
293
|
};
|
|
322
|
-
var deleteBlocks = writeOperation8(
|
|
294
|
+
var deleteBlocks = writeOperation8("deleteBlocks", z19.array(z19.union([
|
|
295
|
+
BlockParagraphRefSchema,
|
|
296
|
+
BlockImageRefSchema,
|
|
297
|
+
BlockRowRefSchema
|
|
298
|
+
])), (txn) => {
|
|
323
299
|
const refs = txn.payload;
|
|
324
300
|
return QueryChain4(...refs.map((ref) => DeleteBlockQuery(txn, ref)));
|
|
325
301
|
}, { changeSetOnly: true });
|
|
326
302
|
|
|
327
303
|
// src/operations/deleteDraft.ts
|
|
328
304
|
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) => {
|
|
305
|
+
var deleteDraft = writeOperation9("deleteDraft", DraftRefSchema, (txn) => {
|
|
336
306
|
const ref = txn.payload;
|
|
337
307
|
return QueryChain5(Query9(() => txn.deleteEntity(ref, true)), Query9(() => txn.deleteChangeSet(ref)));
|
|
338
308
|
});
|
|
339
309
|
|
|
340
310
|
// src/operations/deletePost.ts
|
|
341
311
|
import { Query as Query10, writeOperation as writeOperation10 } from "roc-db";
|
|
342
|
-
|
|
343
|
-
// src/schemas/DeletePostMutationSchema.ts
|
|
344
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator13 } from "roc-db";
|
|
345
|
-
var DeletePostMutationSchema = mutationSchemaGenerator13("deletePost", PostRefSchema);
|
|
346
|
-
|
|
347
|
-
// src/operations/deletePost.ts
|
|
348
|
-
var deletePost = writeOperation10(DeletePostMutationSchema, undefined, (txn) => {
|
|
312
|
+
var deletePost = writeOperation10("deletePost", PostRefSchema, (txn) => {
|
|
349
313
|
const ref = txn.payload;
|
|
350
314
|
return Query10(() => txn.deleteEntity(ref, true));
|
|
351
315
|
});
|
|
352
316
|
|
|
353
317
|
// src/operations/moveBlocks.ts
|
|
354
318
|
import { Query as Query11, QueryChain as QueryChain6, writeOperation as writeOperation11 } from "roc-db";
|
|
355
|
-
|
|
356
|
-
// src/schemas/MoveBlocksMutationSchema.ts
|
|
357
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator14 } from "roc-db";
|
|
358
319
|
import { z as z20 } from "zod";
|
|
359
|
-
var
|
|
320
|
+
var PayloadSchema3 = z20.object({
|
|
360
321
|
refs: z20.array(z20.union([BlockParagraphRefSchema, BlockRowRefSchema])),
|
|
361
322
|
targetPosition: z20.number().min(0)
|
|
362
|
-
}).strict()
|
|
363
|
-
|
|
364
|
-
// src/operations/moveBlocks.ts
|
|
365
|
-
var moveBlocks = writeOperation11(MoveBlocksMutationSchema, undefined, (txn) => {
|
|
323
|
+
}).strict();
|
|
324
|
+
var moveBlocks = writeOperation11("moveBlocks", PayloadSchema3, (txn) => {
|
|
366
325
|
const { refs } = txn.payload;
|
|
367
326
|
return QueryChain6(Query11(() => txn.batchReadEntities(refs)), Query11((items) => {
|
|
368
327
|
return "todo";
|
|
@@ -372,7 +331,7 @@ var moveBlocks = writeOperation11(MoveBlocksMutationSchema, undefined, (txn) =>
|
|
|
372
331
|
// src/operations/readEntity.ts
|
|
373
332
|
import { NotFoundError, Query as Query12, QueryChain as QueryChain7, readOperation } from "roc-db";
|
|
374
333
|
import { z as z21 } from "zod";
|
|
375
|
-
var readEntity = readOperation("readEntity", z21.string(),
|
|
334
|
+
var readEntity = readOperation("readEntity", z21.string(), (txn) => {
|
|
376
335
|
const ref = txn.payload;
|
|
377
336
|
return QueryChain7(Query12(() => txn.readEntity(ref)), Query12((entity) => {
|
|
378
337
|
if (!entity) {
|
|
@@ -380,12 +339,18 @@ var readEntity = readOperation("readEntity", z21.string(), z21.union([PostSchema
|
|
|
380
339
|
}
|
|
381
340
|
return entity;
|
|
382
341
|
}));
|
|
342
|
+
}, {
|
|
343
|
+
outputSchema: z21.union([
|
|
344
|
+
PostSchema,
|
|
345
|
+
BlockImageSchema,
|
|
346
|
+
BlockParagraphSchema
|
|
347
|
+
])
|
|
383
348
|
});
|
|
384
349
|
|
|
385
350
|
// src/operations/readMutation.ts
|
|
386
351
|
import { NotFoundError as NotFoundError2, Query as Query13, QueryChain as QueryChain8, readOperation as readOperation2 } from "roc-db";
|
|
387
352
|
import { z as z22 } from "zod";
|
|
388
|
-
var readMutation = readOperation2("readMutation", z22.string(),
|
|
353
|
+
var readMutation = readOperation2("readMutation", z22.string(), (txn) => {
|
|
389
354
|
const ref = txn.payload;
|
|
390
355
|
return QueryChain8(Query13(() => txn.readMutation(ref)), Query13((entity) => {
|
|
391
356
|
if (!entity) {
|
|
@@ -397,25 +362,15 @@ var readMutation = readOperation2("readMutation", z22.string(), z22.any(), (txn)
|
|
|
397
362
|
|
|
398
363
|
// src/operations/readPost.ts
|
|
399
364
|
import { Query as Query14, readOperation as readOperation3 } from "roc-db";
|
|
400
|
-
var readPost = readOperation3("readPost", PostRefSchema,
|
|
365
|
+
var readPost = readOperation3("readPost", PostRefSchema, (txn) => {
|
|
401
366
|
const ref = txn.payload;
|
|
402
367
|
return Query14(() => txn.readEntity(ref, true));
|
|
403
|
-
});
|
|
368
|
+
}, { outputSchema: PostSchema });
|
|
404
369
|
|
|
405
370
|
// src/operations/testTransactionalEdits.ts
|
|
371
|
+
import { expect } from "bun:test";
|
|
406
372
|
import { Query as Query15, QueryChain as QueryChain9, writeOperation as writeOperation12 } from "roc-db";
|
|
407
|
-
|
|
408
|
-
// src/schemas/TestTransactionalEditsMutationSchema.ts
|
|
409
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator15 } from "roc-db";
|
|
410
373
|
import { z as z23 } from "zod";
|
|
411
|
-
var TestTransactionalEditsMutationSchema = mutationSchemaGenerator15("testTransactionalEdits", z23.object({
|
|
412
|
-
name: z23.string().optional(),
|
|
413
|
-
post1ref: PostRefSchema.optional(),
|
|
414
|
-
post2ref: PostRefSchema.optional()
|
|
415
|
-
}).strict());
|
|
416
|
-
|
|
417
|
-
// src/operations/testTransactionalEdits.ts
|
|
418
|
-
import { expect } from "bun:test";
|
|
419
374
|
var TestCreatePatchDeleteInSameTransaction = (txn, name) => {
|
|
420
375
|
const postRef = txn.createRef("Post");
|
|
421
376
|
QueryChain9(Query15(() => txn.createEntity(postRef, { data: { name } })), Query15(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query15((post) => {
|
|
@@ -450,7 +405,12 @@ var TestCreateOnExistingRef = (txn) => {
|
|
|
450
405
|
const ref = txn.createRef("Post");
|
|
451
406
|
return QueryChain9(Query15(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query15(() => txn.createEntity(ref, { data: { foo: "bar" } })));
|
|
452
407
|
};
|
|
453
|
-
var
|
|
408
|
+
var PayloadSchema4 = z23.object({
|
|
409
|
+
name: z23.string().optional(),
|
|
410
|
+
post1ref: PostRefSchema.optional(),
|
|
411
|
+
post2ref: PostRefSchema.optional()
|
|
412
|
+
}).strict();
|
|
413
|
+
var testTransactionalEdits = writeOperation12("testTransactionalEdits", PayloadSchema4, (txn) => {
|
|
454
414
|
const { name, post1ref, post2ref } = txn.payload;
|
|
455
415
|
if (name)
|
|
456
416
|
return TestCreatePatchDeleteInSameTransaction(txn, name);
|
|
@@ -462,54 +422,50 @@ var testTransactionalEdits = writeOperation12(TestTransactionalEditsMutationSche
|
|
|
462
422
|
|
|
463
423
|
// src/operations/updateBlockParagraph.ts
|
|
464
424
|
import { Query as Query16, writeOperation as writeOperation13 } from "roc-db";
|
|
465
|
-
|
|
466
|
-
// src/schemas/UpdateBlockParagraphMutationSchema.ts
|
|
467
|
-
import { mutationSchemaGenerator as mutationSchemaGenerator16 } from "roc-db";
|
|
468
425
|
import { z as z24 } from "zod";
|
|
469
|
-
var
|
|
426
|
+
var updateBlockParagraph = writeOperation13("updateBlockParagraph", z24.object({
|
|
470
427
|
ref: BlockParagraphRefSchema,
|
|
471
428
|
content: z24.string()
|
|
472
|
-
}))
|
|
473
|
-
|
|
474
|
-
// src/operations/updateBlockParagraph.ts
|
|
475
|
-
var updateBlockParagraph = writeOperation13(UpdateBlockParagraphMutationSchema, BlockParagraphRefSchema, (txn) => {
|
|
429
|
+
}), (txn) => {
|
|
476
430
|
const { ref, content } = txn.payload;
|
|
477
431
|
return Query16(() => txn.patchEntity(ref, {
|
|
478
432
|
data: { content }
|
|
479
433
|
}));
|
|
480
|
-
});
|
|
434
|
+
}, { outputSchema: BlockParagraphSchema });
|
|
481
435
|
|
|
482
436
|
// src/operations/updatePost.ts
|
|
483
437
|
import { Query as Query17, writeOperation as writeOperation14 } from "roc-db";
|
|
484
|
-
|
|
438
|
+
import { z as z25 } from "zod";
|
|
439
|
+
var PayloadSchema5 = z25.object({
|
|
440
|
+
ref: PostRefSchema,
|
|
441
|
+
title: z25.string().optional(),
|
|
442
|
+
tags: z25.array(z25.string()).optional().default([]),
|
|
443
|
+
authorRef: UserRefSchema.optional()
|
|
444
|
+
});
|
|
445
|
+
var updatePost = writeOperation14("updatePost", PayloadSchema5, (txn) => {
|
|
485
446
|
const { ref, authorRef, ...data } = txn.payload;
|
|
486
447
|
return Query17(() => txn.updateEntity(ref, {
|
|
487
448
|
data,
|
|
488
449
|
parents: { author: authorRef },
|
|
489
450
|
children: { blocks: [] }
|
|
490
451
|
}));
|
|
491
|
-
});
|
|
452
|
+
}, { outputSchema: PostSchema });
|
|
492
453
|
|
|
493
454
|
// src/operations/updatePostDescription.ts
|
|
494
455
|
import { Query as Query18, writeOperation as writeOperation15 } from "roc-db";
|
|
495
|
-
|
|
496
|
-
|
|
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() }));
|
|
500
|
-
|
|
501
|
-
// src/operations/updatePostDescription.ts
|
|
502
|
-
var updatePostDescription = writeOperation15(UpdatePostDescriptionMutationSchema, PostSchema, (txn) => {
|
|
456
|
+
import { z as z26 } from "zod";
|
|
457
|
+
var updatePostDescription = writeOperation15("updatePostDescription", z26.object({ ref: PostRefSchema, description: z26.string() }), (txn) => {
|
|
503
458
|
const { ref, description } = txn.payload;
|
|
504
459
|
return Query18(() => txn.patchEntity(ref, { data: { description } }));
|
|
505
|
-
}, { debounce: 10, changeSetOnly: true });
|
|
460
|
+
}, { debounce: 10, changeSetOnly: true, outputSchema: PostSchema });
|
|
506
461
|
|
|
507
462
|
// src/operations/updatePostTitle.ts
|
|
508
463
|
import { Query as Query19, writeOperation as writeOperation16 } from "roc-db";
|
|
509
|
-
|
|
464
|
+
import { z as z27 } from "zod";
|
|
465
|
+
var updatePostTitle = writeOperation16("updatePostTitle", z27.object({ ref: PostRefSchema, title: z27.string() }), (txn) => {
|
|
510
466
|
const { ref, title } = txn.payload;
|
|
511
467
|
return Query19(() => txn.patchEntity(ref, { data: { title } }));
|
|
512
|
-
}, { debounce: 10 });
|
|
468
|
+
}, { debounce: 10, outputSchema: PostSchema });
|
|
513
469
|
|
|
514
470
|
// src/operations/index.ts
|
|
515
471
|
var operations = [
|
|
@@ -796,9 +752,7 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
796
752
|
});
|
|
797
753
|
test("applyDraft", async () => {
|
|
798
754
|
const { draftRef: draftRef2 } = await prepareChangeSetTest(adapter1);
|
|
799
|
-
const [version, mutation] = await adapter1.applyDraft(
|
|
800
|
-
ref: draftRef2
|
|
801
|
-
});
|
|
755
|
+
const [version, mutation] = await adapter1.applyDraft(draftRef2);
|
|
802
756
|
});
|
|
803
757
|
test("deleteDraft", async () => {
|
|
804
758
|
const { draftRef: draftRef2 } = await prepareChangeSetTest(adapter1);
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export declare const applyDraft: import("roc-db").WriteOperation<string, {
|
|
2
|
-
debounceCount: number;
|
|
3
|
-
name: string;
|
|
4
|
-
payload?: any;
|
|
5
|
-
}, any, any>;
|
|
1
|
+
export declare const applyDraft: import("roc-db").WriteOperation<"applyDraft", import("zod").ZodType<`Draft/${string}`, import("zod").ZodTypeDef, `Draft/${string}`>>;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
parents: {
|
|
11
|
-
post: `Post/${string}`;
|
|
12
|
-
};
|
|
13
|
-
entity: "BlockImage";
|
|
14
|
-
created: {
|
|
15
|
-
mutationRef: `Mutation/${string}`;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
};
|
|
18
|
-
updated: {
|
|
19
|
-
mutationRef: `Mutation/${string}`;
|
|
20
|
-
timestamp: string;
|
|
21
|
-
};
|
|
22
|
-
children: {};
|
|
23
|
-
ancestors: {};
|
|
24
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const createBlockImage: import("roc-db").WriteOperation<"createBlockImage", z.ZodObject<{
|
|
3
|
+
postRef: z.ZodType<`Post/${string}`, z.ZodTypeDef, `Post/${string}`>;
|
|
4
|
+
}, "strict", z.ZodTypeAny, {
|
|
5
|
+
postRef: `Post/${string}`;
|
|
6
|
+
}, {
|
|
7
|
+
postRef: `Post/${string}`;
|
|
8
|
+
}>>;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
parents: {
|
|
11
|
-
parent: `Post/${string}`;
|
|
12
|
-
};
|
|
13
|
-
entity: "BlockParagraph";
|
|
14
|
-
created: {
|
|
15
|
-
mutationRef: `Mutation/${string}`;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
};
|
|
18
|
-
updated: {
|
|
19
|
-
mutationRef: `Mutation/${string}`;
|
|
20
|
-
timestamp: string;
|
|
21
|
-
};
|
|
22
|
-
children: {};
|
|
23
|
-
ancestors: {};
|
|
24
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const createBlockParagrah: import("roc-db").WriteOperation<"createBlockParagraph", z.ZodObject<{
|
|
3
|
+
parentRef: z.ZodUnion<[z.ZodType<`Post/${string}`, z.ZodTypeDef, `Post/${string}`>, z.ZodType<`BlockRow/${string}`, z.ZodTypeDef, `BlockRow/${string}`>]>;
|
|
4
|
+
}, "strict", z.ZodTypeAny, {
|
|
5
|
+
parentRef: `Post/${string}` | `BlockRow/${string}`;
|
|
6
|
+
}, {
|
|
7
|
+
parentRef: `Post/${string}` | `BlockRow/${string}`;
|
|
8
|
+
}>>;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
parents: {
|
|
11
|
-
parent: `Post/${string}`;
|
|
12
|
-
};
|
|
13
|
-
entity: "BlockParagraph";
|
|
14
|
-
created: {
|
|
15
|
-
mutationRef: `Mutation/${string}`;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
};
|
|
18
|
-
updated: {
|
|
19
|
-
mutationRef: `Mutation/${string}`;
|
|
20
|
-
timestamp: string;
|
|
21
|
-
};
|
|
22
|
-
children: {};
|
|
23
|
-
ancestors: {};
|
|
24
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const createBlockRow: import("roc-db").WriteOperation<"createBlockRow", z.ZodObject<{
|
|
3
|
+
parentRef: z.ZodUnion<[z.ZodType<`Post/${string}`, z.ZodTypeDef, `Post/${string}`>, z.ZodType<`BlockRow/${string}`, z.ZodTypeDef, `BlockRow/${string}`>]>;
|
|
4
|
+
}, "strict", z.ZodTypeAny, {
|
|
5
|
+
parentRef: `Post/${string}` | `BlockRow/${string}`;
|
|
6
|
+
}, {
|
|
7
|
+
parentRef: `Post/${string}` | `BlockRow/${string}`;
|
|
8
|
+
}>>;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
parents: {
|
|
11
|
-
post: `Post/${string}`;
|
|
12
|
-
};
|
|
13
|
-
entity: "BlockTitle";
|
|
14
|
-
created: {
|
|
15
|
-
mutationRef: `Mutation/${string}`;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
};
|
|
18
|
-
updated: {
|
|
19
|
-
mutationRef: `Mutation/${string}`;
|
|
20
|
-
timestamp: string;
|
|
21
|
-
};
|
|
22
|
-
children: {};
|
|
23
|
-
ancestors: {};
|
|
24
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const createBlockTitle: import("roc-db").WriteOperation<"createBlockTitle", z.ZodObject<{
|
|
3
|
+
parentRef: z.ZodUnion<[z.ZodType<`Post/${string}`, z.ZodTypeDef, `Post/${string}`>, z.ZodType<`BlockRow/${string}`, z.ZodTypeDef, `BlockRow/${string}`>]>;
|
|
4
|
+
}, "strict", z.ZodTypeAny, {
|
|
5
|
+
parentRef: `Post/${string}` | `BlockRow/${string}`;
|
|
6
|
+
}, {
|
|
7
|
+
parentRef: `Post/${string}` | `BlockRow/${string}`;
|
|
8
|
+
}>>;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
parents: {};
|
|
11
|
-
entity: "Draft";
|
|
12
|
-
created: {
|
|
13
|
-
mutationRef: `Mutation/${string}`;
|
|
14
|
-
timestamp: string;
|
|
15
|
-
};
|
|
16
|
-
updated: {
|
|
17
|
-
mutationRef: `Mutation/${string}`;
|
|
18
|
-
timestamp: string;
|
|
19
|
-
};
|
|
20
|
-
children: {};
|
|
21
|
-
ancestors: {};
|
|
22
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const createDraft: import("roc-db").WriteOperation<"createDraft", z.ZodObject<{
|
|
3
|
+
postRef: z.ZodType<`Post/${string}`, z.ZodTypeDef, `Post/${string}`>;
|
|
4
|
+
}, "strict", z.ZodTypeAny, {
|
|
5
|
+
postRef: `Post/${string}`;
|
|
6
|
+
}, {
|
|
7
|
+
postRef: `Post/${string}`;
|
|
8
|
+
}>>;
|
|
@@ -1,29 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
entity: "Post";
|
|
17
|
-
created: {
|
|
18
|
-
mutationRef: `Mutation/${string}`;
|
|
19
|
-
timestamp: string;
|
|
20
|
-
};
|
|
21
|
-
updated: {
|
|
22
|
-
mutationRef: `Mutation/${string}`;
|
|
23
|
-
timestamp: string;
|
|
24
|
-
};
|
|
25
|
-
children: {
|
|
26
|
-
blocks: string[];
|
|
27
|
-
};
|
|
28
|
-
ancestors: {};
|
|
29
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const createPost: import("roc-db").WriteOperation<"createPost", z.ZodObject<{
|
|
3
|
+
title: z.ZodString;
|
|
4
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
5
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
|
+
title: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
slug?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
title: string;
|
|
12
|
+
tags?: string[] | undefined;
|
|
13
|
+
slug?: string | undefined;
|
|
14
|
+
}>>;
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
payload?: any;
|
|
5
|
-
}, any, {
|
|
6
|
-
ref: `Post/${string}`;
|
|
7
|
-
data: {
|
|
8
|
-
title: string;
|
|
9
|
-
tags: string[];
|
|
10
|
-
text?: string | undefined;
|
|
11
|
-
slug?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
parents: {
|
|
14
|
-
author?: `User/${string}` | undefined;
|
|
15
|
-
};
|
|
16
|
-
entity: "Post";
|
|
17
|
-
created: {
|
|
18
|
-
mutationRef: `Mutation/${string}`;
|
|
19
|
-
timestamp: string;
|
|
20
|
-
};
|
|
21
|
-
updated: {
|
|
22
|
-
mutationRef: `Mutation/${string}`;
|
|
23
|
-
timestamp: string;
|
|
24
|
-
};
|
|
25
|
-
children: {
|
|
26
|
-
blocks: string[];
|
|
27
|
-
};
|
|
28
|
-
ancestors: {};
|
|
29
|
-
}>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const deleteBlocks: import("roc-db").WriteOperation<"deleteBlocks", z.ZodArray<z.ZodUnion<[z.ZodType<`BlockParagraph/${string}`, z.ZodTypeDef, `BlockParagraph/${string}`>, z.ZodType<`BlockImage/${string}`, z.ZodTypeDef, `BlockImage/${string}`>, z.ZodType<`BlockRow/${string}`, z.ZodTypeDef, `BlockRow/${string}`>]>, "many">>;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export declare const deleteDraft: import("roc-db").WriteOperation<string, {
|
|
2
|
-
debounceCount: number;
|
|
3
|
-
name: string;
|
|
4
|
-
payload?: any;
|
|
5
|
-
}, any, any>;
|
|
1
|
+
export declare const deleteDraft: import("roc-db").WriteOperation<"deleteDraft", import("zod").ZodType<`Draft/${string}`, import("zod").ZodTypeDef, `Draft/${string}`>>;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export declare const deletePost: import("roc-db").WriteOperation<string, {
|
|
2
|
-
debounceCount: number;
|
|
3
|
-
name: string;
|
|
4
|
-
payload?: any;
|
|
5
|
-
}, any, any>;
|
|
1
|
+
export declare const deletePost: import("roc-db").WriteOperation<"deletePost", import("zod").ZodType<`Post/${string}`, import("zod").ZodTypeDef, `Post/${string}`>>;
|