@roc-db/test-utils 0.2.0-pre.72 → 0.2.0-pre.73

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 CHANGED
@@ -86,149 +86,137 @@ var DraftSchema = entitySchemaGenerator4("Draft", {
86
86
  })
87
87
  });
88
88
 
89
- // src/schemas/ImageSchema.ts
89
+ // src/schemas/PostSchema.ts
90
90
  import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
91
91
  import { z as z6 } from "zod";
92
- var ImageSchema = entitySchemaGenerator5("Image", {
93
- data: z6.object({
94
- title: z6.string(),
95
- text: z6.string().optional(),
96
- tags: z6.array(z6.string()),
97
- slug: z6.string().optional()
98
- })
99
- });
100
-
101
- // src/schemas/PostSchema.ts
102
- import { entitySchemaGenerator as entitySchemaGenerator6 } from "roc-db";
103
- import { z as z7 } from "zod";
104
92
 
105
93
  // src/schemas/UserRefSchema.ts
106
94
  import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
107
95
  var UserRefSchema = refSchemaGenerator5("User");
108
96
 
109
97
  // src/schemas/PostSchema.ts
110
- var PostSchema = entitySchemaGenerator6("Post", {
98
+ var PostSchema = entitySchemaGenerator5("Post", {
111
99
  ref: PostRefSchema,
112
- data: z7.object({
113
- title: z7.string(),
114
- text: z7.string().optional(),
115
- tags: z7.array(z7.string()),
116
- slug: z7.string().optional()
100
+ data: z6.object({
101
+ title: z6.string(),
102
+ text: z6.string().optional(),
103
+ tags: z6.array(z6.string()),
104
+ slug: z6.string().optional()
117
105
  }),
118
- parents: z7.object({ author: UserRefSchema.optional() }),
119
- children: z7.object({ blocks: z7.array(z7.string()) })
106
+ parents: z6.object({ author: UserRefSchema.optional() }),
107
+ children: z6.object({ blocks: z6.array(z6.string()) })
120
108
  });
121
109
  // src/schemas/CreatePostMutationSchema.ts
122
110
  import { mutationSchemaGenerator } from "roc-db";
123
- import { z as z8 } from "zod";
124
- var CreatePostMutationSchema = mutationSchemaGenerator("createPost", z8.object({
125
- title: z8.string(),
126
- slug: z8.string().optional(),
127
- tags: z8.array(z8.string()).default([])
111
+ import { z as z7 } from "zod";
112
+ var CreatePostMutationSchema = mutationSchemaGenerator("createPost", z7.object({
113
+ title: z7.string(),
114
+ slug: z7.string().optional(),
115
+ tags: z7.array(z7.string()).default([])
128
116
  }).strict());
129
117
  // src/schemas/CreateUserMutationSchema.ts
130
118
  import { mutationSchemaGenerator as mutationSchemaGenerator2 } from "roc-db";
131
- import { z as z9 } from "zod";
132
- var CreateUserMutationSchema = mutationSchemaGenerator2("createUser", z9.object({ email: z9.string() }));
119
+ import { z as z8 } from "zod";
120
+ var CreateUserMutationSchema = mutationSchemaGenerator2("createUser", z8.object({ email: z8.string() }));
133
121
  // src/schemas/UpdatePostMutationSchema.ts
134
122
  import { mutationSchemaGenerator as mutationSchemaGenerator3 } from "roc-db";
135
- import { z as z10 } from "zod";
136
- var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z10.object({
123
+ import { z as z9 } from "zod";
124
+ var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z9.object({
137
125
  ref: PostRefSchema,
138
- title: z10.string().optional(),
139
- tags: z10.array(z10.string()).optional().default([]),
126
+ title: z9.string().optional(),
127
+ tags: z9.array(z9.string()).optional().default([]),
140
128
  authorRef: UserRefSchema.optional()
141
129
  }));
142
130
  // src/schemas/UpdatePostTitleMutationSchema.ts
143
131
  import { mutationSchemaGenerator as mutationSchemaGenerator4 } from "roc-db";
144
- import { z as z11 } from "zod";
145
- var UpdatePostTitleMutationSchema = mutationSchemaGenerator4("updatePostTitle", z11.object({ ref: PostRefSchema, title: z11.string() }));
132
+ import { z as z10 } from "zod";
133
+ var UpdatePostTitleMutationSchema = mutationSchemaGenerator4("updatePostTitle", z10.object({ ref: PostRefSchema, title: z10.string() }));
146
134
  // src/entities/BlockImageEntity.ts
147
135
  import { Entity as Entity2 } from "roc-db";
148
- import { z as z12 } from "zod";
136
+ import { z as z11 } from "zod";
149
137
  var BlockImageEntity = new Entity2("BlockImage", {
150
- data: z12.object({
151
- url: z12.string().url()
138
+ data: z11.object({
139
+ url: z11.string().url()
152
140
  }),
153
- parents: z12.object({
141
+ parents: z11.object({
154
142
  parent: PostRefSchema
155
143
  })
156
144
  });
157
145
 
158
146
  // src/entities/BlockParagraph.ts
159
147
  import { Entity as Entity4 } from "roc-db";
160
- import { z as z15 } from "zod";
148
+ import { z as z14 } from "zod";
161
149
 
162
150
  // src/entities/PostEntity.ts
163
151
  import { Entity as Entity3 } from "roc-db";
164
- import { z as z13 } from "zod";
152
+ import { z as z12 } from "zod";
165
153
  var PostEntity = new Entity3("Post", {
166
- data: z13.object({
167
- title: z13.string(),
168
- text: z13.string().optional(),
169
- tags: z13.array(z13.string()),
170
- slug: z13.string().optional()
154
+ data: z12.object({
155
+ title: z12.string(),
156
+ text: z12.string().optional(),
157
+ tags: z12.array(z12.string()),
158
+ slug: z12.string().optional()
171
159
  }),
172
- parents: z13.object({ author: UserRefSchema.optional() }),
173
- children: z13.object({ blocks: z13.array(z13.string()) }),
160
+ parents: z12.object({ author: UserRefSchema.optional() }),
161
+ children: z12.object({ blocks: z12.array(z12.string()) }),
174
162
  indexedDataKeys: ["tags", "slug"],
175
163
  uniqueDataKeys: ["slug"]
176
164
  });
177
165
 
178
166
  // src/schemas/BlockRefSchema.ts
179
- import { z as z14 } from "zod";
167
+ import { z as z13 } from "zod";
180
168
 
181
169
  // src/schemas/BlockRowRefSchema.ts
182
170
  import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
183
171
  var BlockRowRefSchema = refSchemaGenerator6("BlockRow");
184
172
 
185
173
  // src/schemas/BlockRefSchema.ts
186
- var BlockRefSchema = z14.union([
174
+ var BlockRefSchema = z13.union([
187
175
  BlockParagraphRefSchema,
188
176
  BlockRowRefSchema
189
177
  ]);
190
178
 
191
179
  // src/entities/BlockParagraph.ts
192
180
  var BlockParagraph = new Entity4("BlockParagraph", {
193
- data: z15.object({
194
- content: z15.string().optional()
181
+ data: z14.object({
182
+ content: z14.string().optional()
195
183
  }),
196
- parents: z15.object({
197
- parent: z15.union([PostEntity.refSchema, BlockRefSchema])
184
+ parents: z14.object({
185
+ parent: z14.union([PostEntity.refSchema, BlockRefSchema])
198
186
  })
199
187
  });
200
188
 
201
189
  // src/entities/BlockRow.ts
202
190
  import { Entity as Entity5 } from "roc-db";
203
- import { z as z16 } from "zod";
191
+ import { z as z15 } from "zod";
204
192
  var BlockRow = new Entity5("BlockRow", {
205
- children: z16.object({
206
- blocks: z16.array(BlockRefSchema)
193
+ children: z15.object({
194
+ blocks: z15.array(BlockRefSchema)
207
195
  }),
208
- parents: z16.object({
209
- parent: z16.union([PostEntity.refSchema, BlockRefSchema])
196
+ parents: z15.object({
197
+ parent: z15.union([PostEntity.refSchema, BlockRefSchema])
210
198
  })
211
199
  });
212
200
 
213
201
  // src/entities/PostVersion.ts
214
202
  import { Entity as Entity6 } from "roc-db";
215
- import { z as z17 } from "zod";
203
+ import { z as z16 } from "zod";
216
204
  var PostVersion = new Entity6("PostVersion", {
217
- data: z17.object({
218
- version: z17.number(),
219
- snapshot: z17.array(z17.any())
205
+ data: z16.object({
206
+ version: z16.number(),
207
+ snapshot: z16.array(z16.any())
220
208
  }),
221
- parents: z17.object({ post: PostRefSchema }),
209
+ parents: z16.object({ post: PostRefSchema }),
222
210
  indexedDataKeys: ["version"],
223
211
  uniqueDataKeys: ["slug"]
224
212
  });
225
213
 
226
214
  // src/entities/UserEntity.ts
227
215
  import { Entity as Entity7 } from "roc-db";
228
- import { z as z18 } from "zod";
216
+ import { z as z17 } from "zod";
229
217
  var UserEntity = new Entity7("User", {
230
- data: z18.object({
231
- email: z18.string().email()
218
+ data: z17.object({
219
+ email: z17.string().email()
232
220
  }),
233
221
  uniqueDataKeys: ["email"]
234
222
  });
@@ -263,8 +251,8 @@ var applyDraft = writeOperation("applyDraft", DraftRefSchema, (txn) => {
263
251
 
264
252
  // src/operations/createBlockImage.ts
265
253
  import { Query as Query2, writeOperation as writeOperation2 } from "roc-db";
266
- import { z as z19 } from "zod";
267
- var createBlockImage = writeOperation2("createBlockImage", z19.object({ parentRef: PostRefSchema, url: z19.string().url() }).strict(), (txn) => {
254
+ import { z as z18 } from "zod";
255
+ var createBlockImage = writeOperation2("createBlockImage", z18.object({ parentRef: PostRefSchema, url: z18.string().url() }).strict(), (txn) => {
268
256
  const ref = txn.createRef("BlockImage");
269
257
  const { parentRef, url } = txn.payload;
270
258
  return Query2(() => txn.createEntity(ref, {
@@ -275,8 +263,8 @@ var createBlockImage = writeOperation2("createBlockImage", z19.object({ parentRe
275
263
 
276
264
  // src/operations/createBlockParagraph.ts
277
265
  import { Query as Query3, QueryChain as QueryChain2, writeOperation as writeOperation3 } from "roc-db";
278
- import { z as z20 } from "zod";
279
- var createBlockParagrah = writeOperation3("createBlockParagraph", z20.object({ parentRef: z20.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
266
+ import { z as z19 } from "zod";
267
+ var createBlockParagrah = writeOperation3("createBlockParagraph", z19.object({ parentRef: z19.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
280
268
  const ref = txn.createRef("BlockParagraph");
281
269
  const { parentRef } = txn.payload;
282
270
  return QueryChain2(Query3(() => txn.readEntity(parentRef, true)), Query3((parent) => txn.patchEntity(parentRef, {
@@ -284,16 +272,16 @@ var createBlockParagrah = writeOperation3("createBlockParagraph", z20.object({ p
284
272
  })), Query3(() => txn.createEntity(ref, { parents: { parent: parentRef } })), Query3((block, updatedParent) => ({ block, updatedParent })));
285
273
  }, {
286
274
  changeSetOnly: true,
287
- outputSchema: z20.object({
288
- block: z20.any(),
289
- updatedParent: z20.any()
275
+ outputSchema: z19.object({
276
+ block: z19.any(),
277
+ updatedParent: z19.any()
290
278
  })
291
279
  });
292
280
 
293
281
  // src/operations/createBlockRow.ts
294
282
  import { Query as Query4, QueryChain as QueryChain3, writeOperation as writeOperation4 } from "roc-db";
295
- import { z as z21 } from "zod";
296
- var createBlockRow = writeOperation4("createBlockRow", z21.object({ parentRef: z21.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
283
+ import { z as z20 } from "zod";
284
+ var createBlockRow = writeOperation4("createBlockRow", z20.object({ parentRef: z20.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
297
285
  const ref = txn.createRef("BlockRow");
298
286
  const { parentRef } = txn.payload;
299
287
  return QueryChain3(Query4(() => txn.readEntity(parentRef)), Query4((parent) => {
@@ -306,16 +294,16 @@ var createBlockRow = writeOperation4("createBlockRow", z21.object({ parentRef: z
306
294
  })), Query4((block, updatedParent) => ({ block, updatedParent })));
307
295
  }, {
308
296
  changeSetOnly: true,
309
- outputSchema: z21.object({
310
- block: z21.any(),
311
- updatedParent: z21.any()
297
+ outputSchema: z20.object({
298
+ block: z20.any(),
299
+ updatedParent: z20.any()
312
300
  })
313
301
  });
314
302
 
315
303
  // src/operations/createBlockTitle.ts
316
304
  import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
317
- import { z as z22 } from "zod";
318
- var PayloadSchema = z22.object({ parentRef: z22.union([PostRefSchema, BlockRowRefSchema]) }).strict();
305
+ import { z as z21 } from "zod";
306
+ var PayloadSchema = z21.object({ parentRef: z21.union([PostRefSchema, BlockRowRefSchema]) }).strict();
319
307
  var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn) => {
320
308
  const ref = txn.createRef("BlockTitle");
321
309
  const { postRef } = txn.payload;
@@ -324,8 +312,8 @@ var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn)
324
312
 
325
313
  // src/operations/createDraft.ts
326
314
  import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
327
- import { z as z23 } from "zod";
328
- var createDraft = writeOperation6("createDraft", z23.object({ postRef: PostRefSchema }).strict(), (txn) => {
315
+ import { z as z22 } from "zod";
316
+ var createDraft = writeOperation6("createDraft", z22.object({ postRef: PostRefSchema }).strict(), (txn) => {
329
317
  const ref = txn.createRef("Draft");
330
318
  const { postRef } = txn.payload;
331
319
  return Query6(() => txn.createEntity(ref, {
@@ -335,63 +323,47 @@ var createDraft = writeOperation6("createDraft", z23.object({ postRef: PostRefSc
335
323
  }));
336
324
  }, { outputSchema: DraftSchema });
337
325
 
338
- // src/operations/createImage.ts
339
- import { Query as Query7, writeOperation as writeOperation7 } from "roc-db";
340
- import { z as z24 } from "zod";
341
- var PayloadSchema2 = z24.object({
342
- title: z24.string(),
343
- file: z24.string().optional()
344
- }).strict();
345
- var createImage = writeOperation7("createImage", PayloadSchema2, (txn) => {
346
- const ref = txn.createRef("Image");
347
- const { title, file } = txn.payload;
348
- return Query7(() => txn.createEntity(ref, {
349
- data: { title, file },
350
- children: { blocks: [] }
351
- }));
352
- });
353
-
354
326
  // src/operations/createPost.ts
355
- import { Query as Query8, writeOperation as writeOperation8 } from "roc-db";
356
- import { z as z25 } from "zod";
357
- var PayloadSchema3 = z25.object({
358
- title: z25.string(),
359
- slug: z25.string().optional(),
360
- tags: z25.array(z25.string()).default([])
327
+ import { Query as Query7, writeOperation as writeOperation7 } from "roc-db";
328
+ import { z as z23 } from "zod";
329
+ var PayloadSchema2 = z23.object({
330
+ title: z23.string(),
331
+ slug: z23.string().optional(),
332
+ tags: z23.array(z23.string()).default([])
361
333
  }).strict();
362
- var createPost = writeOperation8("createPost", PayloadSchema3, (txn) => {
334
+ var createPost = writeOperation7("createPost", PayloadSchema2, (txn) => {
363
335
  const ref = txn.createRef("Post");
364
336
  const { title, slug, tags } = txn.payload;
365
- return Query8(() => txn.createEntity(ref, {
337
+ return Query7(() => txn.createEntity(ref, {
366
338
  data: { title, tags, slug },
367
339
  children: { blocks: [] }
368
340
  }));
369
341
  });
370
342
 
371
343
  // src/operations/createUser.ts
372
- import { Query as Query9, writeOperation as writeOperation9 } from "roc-db";
373
- import { z as z26 } from "zod";
374
- var createUser = writeOperation9("createUser", z26.object({ email: z26.string() }), (txn) => {
344
+ import { Query as Query8, writeOperation as writeOperation8 } from "roc-db";
345
+ import { z as z24 } from "zod";
346
+ var createUser = writeOperation8("createUser", z24.object({ email: z24.string() }), (txn) => {
375
347
  const ref = txn.createRef("User");
376
348
  const { email } = txn.payload;
377
- return Query9(() => txn.createEntity(ref, { data: { email } }));
349
+ return Query8(() => txn.createEntity(ref, { data: { email } }));
378
350
  });
379
351
 
380
352
  // src/operations/deleteBlocks.ts
381
- import { Query as Query10, QueryChain as QueryChain4, writeOperation as writeOperation10 } from "roc-db";
382
- import { z as z27 } from "zod";
353
+ import { Query as Query9, QueryChain as QueryChain4, writeOperation as writeOperation9 } from "roc-db";
354
+ import { z as z25 } from "zod";
383
355
  var DeleteBlockQuery = (txn, blockRef) => {
384
- return QueryChain4(Query10(() => txn.readEntity(blockRef)), Query10((block) => {
356
+ return QueryChain4(Query9(() => txn.readEntity(blockRef)), Query9((block) => {
385
357
  return txn.readEntity(block.parents.parent, true);
386
- }), Query10((post) => {
358
+ }), Query9((post) => {
387
359
  return txn.patchEntity(post.ref, {
388
360
  children: {
389
361
  blocks: post.children.blocks.filter((ref) => ref !== blockRef)
390
362
  }
391
363
  });
392
- }), Query10(() => txn.deleteEntity(blockRef)));
364
+ }), Query9(() => txn.deleteEntity(blockRef)));
393
365
  };
394
- var deleteBlocks = writeOperation10("deleteBlocks", z27.array(z27.union([
366
+ var deleteBlocks = writeOperation9("deleteBlocks", z25.array(z25.union([
395
367
  BlockParagraphRefSchema,
396
368
  BlockImageRefSchema,
397
369
  BlockRowRefSchema
@@ -401,42 +373,42 @@ var deleteBlocks = writeOperation10("deleteBlocks", z27.array(z27.union([
401
373
  }, { changeSetOnly: true });
402
374
 
403
375
  // src/operations/deleteDraft.ts
404
- import { Query as Query11, QueryChain as QueryChain5, writeOperation as writeOperation11 } from "roc-db";
405
- var deleteDraft = writeOperation11("deleteDraft", DraftRefSchema, (txn) => {
376
+ import { Query as Query10, QueryChain as QueryChain5, writeOperation as writeOperation10 } from "roc-db";
377
+ var deleteDraft = writeOperation10("deleteDraft", DraftRefSchema, (txn) => {
406
378
  const ref = txn.payload;
407
- return QueryChain5(Query11(() => txn.deleteEntity(ref, true)), Query11(() => txn.deleteChangeSet(ref)));
379
+ return QueryChain5(Query10(() => txn.deleteEntity(ref, true)), Query10(() => txn.deleteChangeSet(ref)));
408
380
  });
409
381
 
410
382
  // src/operations/deletePost.ts
411
- import { Query as Query12, writeOperation as writeOperation12 } from "roc-db";
412
- var deletePost = writeOperation12("deletePost", PostRefSchema, (txn) => {
383
+ import { Query as Query11, writeOperation as writeOperation11 } from "roc-db";
384
+ var deletePost = writeOperation11("deletePost", PostRefSchema, (txn) => {
413
385
  const ref = txn.payload;
414
- return Query12(() => txn.deleteEntity(ref, true));
386
+ return Query11(() => txn.deleteEntity(ref, true));
415
387
  });
416
388
 
417
389
  // src/operations/moveBlocks.ts
418
- import { Query as Query13, QueryChain as QueryChain6, writeOperation as writeOperation13 } from "roc-db";
419
- import { z as z28 } from "zod";
420
- var PayloadSchema4 = z28.object({
421
- refs: z28.array(z28.union([BlockParagraphRefSchema, BlockRowRefSchema])),
422
- targetPosition: z28.number().min(0)
390
+ import { Query as Query12, QueryChain as QueryChain6, writeOperation as writeOperation12 } from "roc-db";
391
+ import { z as z26 } from "zod";
392
+ var PayloadSchema3 = z26.object({
393
+ refs: z26.array(z26.union([BlockParagraphRefSchema, BlockRowRefSchema])),
394
+ targetPosition: z26.number().min(0)
423
395
  }).strict();
424
- var moveBlocks = writeOperation13("moveBlocks", PayloadSchema4, (txn) => {
396
+ var moveBlocks = writeOperation12("moveBlocks", PayloadSchema3, (txn) => {
425
397
  const { refs } = txn.payload;
426
- return QueryChain6(Query13(() => txn.batchReadEntities(refs)), Query13((items) => {
398
+ return QueryChain6(Query12(() => txn.batchReadEntities(refs)), Query12((items) => {
427
399
  return "todo";
428
400
  }));
429
401
  });
430
402
 
431
403
  // src/operations/pageBlocks.ts
432
- import { Query as Query14, readOperation } from "roc-db";
433
- import { z as z29 } from "zod";
434
- var pageBlocks = readOperation("pageBlocks", z29.object({
435
- size: z29.number().default(100),
436
- parentRef: z29.string().optional()
404
+ import { Query as Query13, readOperation } from "roc-db";
405
+ import { z as z27 } from "zod";
406
+ var pageBlocks = readOperation("pageBlocks", z27.object({
407
+ size: z27.number().default(100),
408
+ parentRef: z27.string().optional()
437
409
  }), (txn) => {
438
410
  const { size, parentRef } = txn.payload;
439
- return Query14(() => txn.pageEntities({
411
+ return Query13(() => txn.pageEntities({
440
412
  entities: ["BlockImage", "BlockParagraph"],
441
413
  size,
442
414
  childrenOf: parentRef ? [parentRef] : []
@@ -444,50 +416,50 @@ var pageBlocks = readOperation("pageBlocks", z29.object({
444
416
  });
445
417
 
446
418
  // src/operations/pageEmptyEntitiesArray.ts
447
- import { Query as Query15, readOperation as readOperation2 } from "roc-db";
448
- import { z as z30 } from "zod";
449
- var pageEmptyEntitiesArray = readOperation2("pageEmptyEntitiesArray", z30.object({ size: z30.number().default(100) }), (txn) => {
419
+ import { Query as Query14, readOperation as readOperation2 } from "roc-db";
420
+ import { z as z28 } from "zod";
421
+ var pageEmptyEntitiesArray = readOperation2("pageEmptyEntitiesArray", z28.object({ size: z28.number().default(100) }), (txn) => {
450
422
  const { size } = txn.payload;
451
- return Query15(() => txn.pageEntities({ entities: [], size }));
423
+ return Query14(() => txn.pageEntities({ entities: [], size }));
452
424
  });
453
425
 
454
426
  // src/operations/pagePosts.ts
455
- import { Query as Query16, readOperation as readOperation3 } from "roc-db";
456
- import { z as z31 } from "zod";
457
- var pagePosts = readOperation3("pagePosts", z31.object({ size: z31.number().default(100) }).default({}), (txn) => {
427
+ import { Query as Query15, readOperation as readOperation3 } from "roc-db";
428
+ import { z as z29 } from "zod";
429
+ var pagePosts = readOperation3("pagePosts", z29.object({ size: z29.number().default(100) }).default({}), (txn) => {
458
430
  const { size } = txn.payload;
459
- return Query16(() => txn.pageEntities({ entities: ["Post"], size }));
431
+ return Query15(() => txn.pageEntities({ entities: ["Post"], size }));
460
432
  });
461
433
 
462
434
  // src/operations/pageSplat.ts
463
- import { Query as Query17, readOperation as readOperation4 } from "roc-db";
464
- import { z as z32 } from "zod";
465
- var pageSplat = readOperation4("pageSplat", z32.object({ size: z32.number().default(100) }), (txn) => {
435
+ import { Query as Query16, readOperation as readOperation4 } from "roc-db";
436
+ import { z as z30 } from "zod";
437
+ var pageSplat = readOperation4("pageSplat", z30.object({ size: z30.number().default(100) }), (txn) => {
466
438
  const { size } = txn.payload;
467
- return Query17(() => txn.pageEntities({ entities: "*", size }));
439
+ return Query16(() => txn.pageEntities({ entities: "*", size }));
468
440
  });
469
441
 
470
442
  // src/operations/pagePostsByTag.ts
471
- import { Query as Query18, readOperation as readOperation5 } from "roc-db";
472
- import { z as z33 } from "zod";
473
- var pagePostsByTag = readOperation5("pagePostsByTag", z33.string(), (txn) => {
443
+ import { Query as Query17, readOperation as readOperation5 } from "roc-db";
444
+ import { z as z31 } from "zod";
445
+ var pagePostsByTag = readOperation5("pagePostsByTag", z31.string(), (txn) => {
474
446
  const tag = txn.payload;
475
- return Query18(() => txn.pageEntitiesByIndex("Post", "tags", tag));
447
+ return Query17(() => txn.pageEntitiesByIndex("Post", "tags", tag));
476
448
  });
477
449
 
478
450
  // src/operations/readEntity.ts
479
- import { NotFoundError, Query as Query19, QueryChain as QueryChain7, readOperation as readOperation6 } from "roc-db";
480
- import { z as z34 } from "zod";
481
- var readEntity = readOperation6("readEntity", z34.string(), (txn) => {
451
+ import { NotFoundError, Query as Query18, QueryChain as QueryChain7, readOperation as readOperation6 } from "roc-db";
452
+ import { z as z32 } from "zod";
453
+ var readEntity = readOperation6("readEntity", z32.string(), (txn) => {
482
454
  const ref = txn.payload;
483
- return QueryChain7(Query19(() => txn.readEntity(ref)), Query19((entity) => {
455
+ return QueryChain7(Query18(() => txn.readEntity(ref)), Query18((entity) => {
484
456
  if (!entity) {
485
457
  throw new NotFoundError(ref);
486
458
  }
487
459
  return entity;
488
460
  }));
489
461
  }, {
490
- outputSchema: z34.union([
462
+ outputSchema: z32.union([
491
463
  PostSchema,
492
464
  BlockImageSchema,
493
465
  BlockParagraphSchema
@@ -495,11 +467,11 @@ var readEntity = readOperation6("readEntity", z34.string(), (txn) => {
495
467
  });
496
468
 
497
469
  // src/operations/readMutation.ts
498
- import { NotFoundError as NotFoundError2, Query as Query20, QueryChain as QueryChain8, readOperation as readOperation7 } from "roc-db";
499
- import { z as z35 } from "zod";
500
- var readMutation = readOperation7("readMutation", z35.string(), (txn) => {
470
+ import { NotFoundError as NotFoundError2, Query as Query19, QueryChain as QueryChain8, readOperation as readOperation7 } from "roc-db";
471
+ import { z as z33 } from "zod";
472
+ var readMutation = readOperation7("readMutation", z33.string(), (txn) => {
501
473
  const ref = txn.payload;
502
- return QueryChain8(Query20(() => txn.readMutation(ref)), Query20((entity) => {
474
+ return QueryChain8(Query19(() => txn.readMutation(ref)), Query19((entity) => {
503
475
  if (!entity) {
504
476
  throw new NotFoundError2(ref);
505
477
  }
@@ -508,52 +480,52 @@ var readMutation = readOperation7("readMutation", z35.string(), (txn) => {
508
480
  });
509
481
 
510
482
  // src/operations/readPost.ts
511
- import { Query as Query21, readOperation as readOperation8 } from "roc-db";
483
+ import { Query as Query20, readOperation as readOperation8 } from "roc-db";
512
484
  var readPost = readOperation8("readPost", PostRefSchema, (txn) => {
513
485
  const ref = txn.payload;
514
- return Query21(() => txn.readEntity(ref, true));
486
+ return Query20(() => txn.readEntity(ref, true));
515
487
  }, { outputSchema: PostSchema });
516
488
 
517
489
  // src/operations/readPostBySlug.ts
518
- import { Query as Query22, readOperation as readOperation9 } from "roc-db";
519
- import { z as z36 } from "zod";
520
- var readPostBySlug = readOperation9("readPostBySlug", z36.string(), (txn) => {
490
+ import { Query as Query21, readOperation as readOperation9 } from "roc-db";
491
+ import { z as z34 } from "zod";
492
+ var readPostBySlug = readOperation9("readPostBySlug", z34.string(), (txn) => {
521
493
  const slug = txn.payload;
522
- return Query22(() => txn.readEntityByUniqueField("Post", "slug", slug));
494
+ return Query21(() => txn.readEntityByUniqueField("Post", "slug", slug));
523
495
  }, { outputSchema: PostSchema });
524
496
 
525
497
  // src/operations/testTransactionalEdits.ts
526
498
  import { expect } from "bun:test";
527
- import { Query as Query23, QueryChain as QueryChain9, writeOperation as writeOperation14 } from "roc-db";
528
- import { z as z37 } from "zod";
499
+ import { Query as Query22, QueryChain as QueryChain9, writeOperation as writeOperation13 } from "roc-db";
500
+ import { z as z35 } from "zod";
529
501
  var TestCreatePatchDeleteInSameTransaction = (txn, title) => {
530
502
  const postRef = txn.createRef("Post");
531
- return QueryChain9(Query23(() => txn.createEntity(postRef, {
503
+ return QueryChain9(Query22(() => txn.createEntity(postRef, {
532
504
  data: { title, tags: [] },
533
505
  children: { blocks: [] }
534
- })), Query23(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query23((post) => {
506
+ })), Query22(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query22((post) => {
535
507
  expect(post.data.title).toBe(title);
536
508
  expect(post.data.foo).toBe("bar");
537
- }), Query23(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query23((post) => {
509
+ }), Query22(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query22((post) => {
538
510
  expect(post.data.title).toBe(title);
539
511
  expect(post.data.foo).toBeUndefined();
540
512
  expect(post.data.bar).toBe("foo");
541
513
  expect(txn.log).toHaveLength(1);
542
514
  expect(txn.log.get(postRef)[0]).toBe("create");
543
- }), Query23((post) => txn.deleteEntity(postRef)), Query23((res) => {
515
+ }), Query22((post) => txn.deleteEntity(postRef)), Query22((res) => {
544
516
  expect(res).toBe(1);
545
517
  expect(txn.log).toHaveLength(0);
546
518
  }));
547
519
  };
548
520
  var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
549
- return QueryChain9(Query23(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query23((post) => {
521
+ return QueryChain9(Query22(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query22((post) => {
550
522
  expect(post.data.foo).toBe("bar");
551
- }), Query23(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query23((post) => {
523
+ }), Query22(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query22((post) => {
552
524
  expect(post.data.foo).toBeUndefined();
553
525
  expect(post.data.bar).toBe("foo");
554
526
  expect(txn.log).toHaveLength(1);
555
527
  expect(txn.log.get(ref)[0]).toBe("update");
556
- }), Query23((post) => txn.deleteEntity(ref)), Query23((res) => {
528
+ }), Query22((post) => txn.deleteEntity(ref)), Query22((res) => {
557
529
  expect(res).toBe(1);
558
530
  expect(txn.log).toHaveLength(1);
559
531
  expect(txn.log.get(ref)[0]).toBe("delete");
@@ -561,14 +533,14 @@ var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
561
533
  };
562
534
  var TestCreateOnExistingRef = (txn) => {
563
535
  const ref = txn.createRef("Post");
564
- return QueryChain9(Query23(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query23(() => txn.createEntity(ref, { data: { foo: "bar" } })));
536
+ return QueryChain9(Query22(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query22(() => txn.createEntity(ref, { data: { foo: "bar" } })));
565
537
  };
566
- var PayloadSchema5 = z37.object({
567
- name: z37.string().optional(),
538
+ var PayloadSchema4 = z35.object({
539
+ name: z35.string().optional(),
568
540
  post1ref: PostRefSchema.optional(),
569
541
  post2ref: PostRefSchema.optional()
570
542
  }).strict();
571
- var testTransactionalEdits = writeOperation14("testTransactionalEdits", PayloadSchema5, (txn) => {
543
+ var testTransactionalEdits = writeOperation13("testTransactionalEdits", PayloadSchema4, (txn) => {
572
544
  const { name, post1ref, post2ref } = txn.payload;
573
545
  if (name)
574
546
  return TestCreatePatchDeleteInSameTransaction(txn, name);
@@ -579,30 +551,30 @@ var testTransactionalEdits = writeOperation14("testTransactionalEdits", PayloadS
579
551
  }, {});
580
552
 
581
553
  // src/operations/updateBlockParagraph.ts
582
- import { Query as Query24, writeOperation as writeOperation15 } from "roc-db";
583
- import { z as z38 } from "zod";
584
- var updateBlockParagraph = writeOperation15("updateBlockParagraph", z38.object({
554
+ import { Query as Query23, writeOperation as writeOperation14 } from "roc-db";
555
+ import { z as z36 } from "zod";
556
+ var updateBlockParagraph = writeOperation14("updateBlockParagraph", z36.object({
585
557
  ref: BlockParagraphRefSchema,
586
- content: z38.string()
558
+ content: z36.string()
587
559
  }), (txn) => {
588
560
  const { ref, content } = txn.payload;
589
- return Query24(() => txn.patchEntity(ref, {
561
+ return Query23(() => txn.patchEntity(ref, {
590
562
  data: { content }
591
563
  }));
592
564
  }, { outputSchema: BlockParagraphSchema });
593
565
 
594
566
  // src/operations/updatePost.ts
595
- import { Query as Query25, writeOperation as writeOperation16 } from "roc-db";
596
- import { z as z39 } from "zod";
597
- var PayloadSchema6 = z39.object({
567
+ import { Query as Query24, writeOperation as writeOperation15 } from "roc-db";
568
+ import { z as z37 } from "zod";
569
+ var PayloadSchema5 = z37.object({
598
570
  ref: PostRefSchema,
599
- title: z39.string().optional(),
600
- tags: z39.array(z39.string()).optional().default([]),
571
+ title: z37.string().optional(),
572
+ tags: z37.array(z37.string()).optional().default([]),
601
573
  authorRef: UserRefSchema.optional()
602
574
  });
603
- var updatePost = writeOperation16("updatePost", PayloadSchema6, (txn) => {
575
+ var updatePost = writeOperation15("updatePost", PayloadSchema5, (txn) => {
604
576
  const { ref, authorRef, ...data } = txn.payload;
605
- return Query25(() => txn.updateEntity(ref, {
577
+ return Query24(() => txn.updateEntity(ref, {
606
578
  data,
607
579
  parents: { author: authorRef },
608
580
  children: { blocks: [] }
@@ -610,43 +582,43 @@ var updatePost = writeOperation16("updatePost", PayloadSchema6, (txn) => {
610
582
  }, { outputSchema: PostSchema });
611
583
 
612
584
  // src/operations/updatePostDescription.ts
613
- import { Query as Query26, writeOperation as writeOperation17 } from "roc-db";
614
- import { z as z40 } from "zod";
615
- var updatePostDescription = writeOperation17("updatePostDescription", z40.object({ ref: PostRefSchema, description: z40.string() }), (txn) => {
585
+ import { Query as Query25, writeOperation as writeOperation16 } from "roc-db";
586
+ import { z as z38 } from "zod";
587
+ var updatePostDescription = writeOperation16("updatePostDescription", z38.object({ ref: PostRefSchema, description: z38.string() }), (txn) => {
616
588
  const { ref, description } = txn.payload;
617
- return Query26(() => txn.patchEntity(ref, { data: { description } }));
589
+ return Query25(() => txn.patchEntity(ref, { data: { description } }));
618
590
  }, { debounce: 10, changeSetOnly: true, outputSchema: PostSchema });
619
591
 
620
592
  // src/operations/updatePostSlug.ts
621
- import { Query as Query27, writeOperation as writeOperation18 } from "roc-db";
622
- import { z as z41 } from "zod";
623
- var updatePostSlug = writeOperation18("updatePostSlug", z41.object({ ref: PostRefSchema, slug: z41.string() }), (txn) => {
593
+ import { Query as Query26, writeOperation as writeOperation17 } from "roc-db";
594
+ import { z as z39 } from "zod";
595
+ var updatePostSlug = writeOperation17("updatePostSlug", z39.object({ ref: PostRefSchema, slug: z39.string() }), (txn) => {
624
596
  const { ref, slug } = txn.payload;
625
- return Query27(() => txn.patchEntity(ref, { data: { slug } }));
597
+ return Query26(() => txn.patchEntity(ref, { data: { slug } }));
626
598
  }, { debounce: 10, outputSchema: PostSchema });
627
599
 
628
600
  // src/operations/updatePostTags.ts
629
- import { Query as Query28, writeOperation as writeOperation19 } from "roc-db";
630
- import { z as z42 } from "zod";
631
- var updatePostTags = writeOperation19("updatePostTags", z42.object({ ref: PostRefSchema, tags: z42.array(z42.string()) }), (txn) => {
601
+ import { Query as Query27, writeOperation as writeOperation18 } from "roc-db";
602
+ import { z as z40 } from "zod";
603
+ var updatePostTags = writeOperation18("updatePostTags", z40.object({ ref: PostRefSchema, tags: z40.array(z40.string()) }), (txn) => {
632
604
  const { ref, tags } = txn.payload;
633
- return Query28(() => txn.patchEntity(ref, { data: { tags } }));
605
+ return Query27(() => txn.patchEntity(ref, { data: { tags } }));
634
606
  }, { debounce: 10, outputSchema: PostSchema });
635
607
 
636
608
  // src/operations/updatePostTitle.ts
637
- import { Query as Query29, writeOperation as writeOperation20 } from "roc-db";
638
- import { z as z43 } from "zod";
639
- var updatePostTitle = writeOperation20("updatePostTitle", z43.object({ ref: PostRefSchema, title: z43.string() }), (txn) => {
609
+ import { Query as Query28, writeOperation as writeOperation19 } from "roc-db";
610
+ import { z as z41 } from "zod";
611
+ var updatePostTitle = writeOperation19("updatePostTitle", z41.object({ ref: PostRefSchema, title: z41.string() }), (txn) => {
640
612
  const { ref, title } = txn.payload;
641
- return Query29(() => txn.patchEntity(ref, { data: { title } }));
613
+ return Query28(() => txn.patchEntity(ref, { data: { title } }));
642
614
  }, { debounce: 10, outputSchema: PostSchema });
643
615
 
644
616
  // src/operations/crudBySlug.ts
645
- import { Query as Query30, QueryChain as QueryChain10, writeOperation as writeOperation21 } from "roc-db";
646
- import { z as z44 } from "zod";
647
- var crudBySlug = writeOperation21("crudBySlug", z44.object({ slug: z44.string(), newSlug: z44.string() }), (txn) => {
617
+ import { Query as Query29, QueryChain as QueryChain10, writeOperation as writeOperation20 } from "roc-db";
618
+ import { z as z42 } from "zod";
619
+ var crudBySlug = writeOperation20("crudBySlug", z42.object({ slug: z42.string(), newSlug: z42.string() }), (txn) => {
648
620
  const { slug, newSlug } = txn.payload;
649
- return QueryChain10(Query30(() => txn.readEntityByUniqueField("Post", "slug", slug)), Query30((post) => txn.patchEntity(post.ref, { data: { slug: newSlug } })), Query30(() => txn.readEntityByUniqueField("Post", "slug", newSlug)), Query30((post) => txn.deleteEntity(post.ref)), Query30(() => {
621
+ return QueryChain10(Query29(() => txn.readEntityByUniqueField("Post", "slug", slug)), Query29((post) => txn.patchEntity(post.ref, { data: { slug: newSlug } })), Query29(() => txn.readEntityByUniqueField("Post", "slug", newSlug)), Query29((post) => txn.deleteEntity(post.ref)), Query29(() => {
650
622
  return [
651
623
  txn.readEntityByUniqueField("Post", "slug", slug, false),
652
624
  txn.readEntityByUniqueField("Post", "slug", newSlug, false)
@@ -662,7 +634,6 @@ var operations = [
662
634
  createBlockParagrah,
663
635
  createBlockRow,
664
636
  createDraft,
665
- createImage,
666
637
  createPost,
667
638
  createUser,
668
639
  crudBySlug,
@@ -1183,7 +1154,6 @@ export {
1183
1154
  UpdatePostMutationSchema,
1184
1155
  PostSchema,
1185
1156
  PostRefSchema,
1186
- ImageSchema,
1187
1157
  DraftSchema,
1188
1158
  DraftRefSchema,
1189
1159
  CreateUserMutationSchema,
@@ -2,9 +2,8 @@ import { BlockImageSchema } from "./BlockImageSchema";
2
2
  import { BlockParagraphSchema } from "./BlockParagraphSchema";
3
3
  import { BlockTitleSchema } from "./BlockTitleSchema";
4
4
  import { DraftSchema } from "./DraftSchema";
5
- import { ImageSchema } from "./ImageSchema";
6
5
  import { PostSchema } from "./PostSchema";
7
- export { BlockImageSchema, BlockParagraphSchema, BlockTitleSchema, DraftSchema, ImageSchema, PostSchema, };
6
+ export { BlockImageSchema, BlockParagraphSchema, BlockTitleSchema, DraftSchema, PostSchema, };
8
7
  export { DraftRefSchema } from "./DraftRefSchema";
9
8
  export { PostRefSchema } from "./PostRefSchema";
10
9
  export { UserRefSchema } from "./UserRefSchema";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roc-db/test-utils",
3
- "version": "0.2.0-pre.72",
3
+ "version": "0.2.0-pre.73",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "sideEffects": false,
19
19
  "peerDependencies": {
20
- "roc-db": "0.2.0-pre.72",
20
+ "roc-db": "0.2.0-pre.73",
21
21
  "zod": "^4.0.0"
22
22
  },
23
23
  "keywords": [],
@@ -1,5 +0,0 @@
1
- import { z } from "zod";
2
- export declare const createImage: import("roc-db").WriteOperation<"createImage", z.ZodObject<{
3
- title: z.ZodString;
4
- file: z.ZodOptional<z.ZodString>;
5
- }, z.core.$strict>>;
@@ -1,23 +0,0 @@
1
- import { z } from "zod";
2
- export declare const ImageSchema: z.ZodObject<{
3
- ref: z.ZodNonOptional<z.ZodTemplateLiteral<`Image/${number}`>>;
4
- entity: z.ZodNonOptional<z.ZodLiteral<"Image">>;
5
- created: z.ZodNonOptional<z.ZodObject<{
6
- mutationRef: z.ZodNonOptional<z.ZodTemplateLiteral<`Mutation/${number}`>>;
7
- timestamp: z.ZodNonOptional<z.ZodString>;
8
- }, z.core.$strict>>;
9
- updated: z.ZodNonOptional<z.ZodObject<{
10
- mutationRef: z.ZodNonOptional<z.ZodTemplateLiteral<`Mutation/${number}`>>;
11
- timestamp: z.ZodNonOptional<z.ZodString>;
12
- }, z.core.$strict>>;
13
- data: z.ZodNonOptional<z.ZodObject<{
14
- title: z.ZodString;
15
- text: z.ZodOptional<z.ZodString>;
16
- tags: z.ZodArray<z.ZodString>;
17
- slug: z.ZodOptional<z.ZodString>;
18
- }, z.core.$strip>>;
19
- children: z.ZodNonOptional<z.ZodObject<{}, z.core.$strip>>;
20
- parents: z.ZodNonOptional<z.ZodObject<{}, z.core.$strip>>;
21
- ancestors: z.ZodNonOptional<z.ZodObject<{}, z.core.$strip>>;
22
- }, z.core.$strict>;
23
- export type Image = z.infer<typeof ImageSchema>;