@roc-db/test-utils 0.2.0-pre.97 → 0.2.0-pre.99

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
@@ -66,12 +66,20 @@ import { z as z5 } from "zod";
66
66
  // src/entities/Draft.ts
67
67
  import { Entity } from "roc-db";
68
68
  import { z as z4 } from "zod";
69
+
70
+ // src/schemas/PostVersionRefSchema.ts
71
+ import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
72
+ var PostVersionRefSchema = refSchemaGenerator5("PostVersion");
73
+
74
+ // src/entities/Draft.ts
69
75
  var Draft = new Entity("Draft", {
76
+ changeSet: true,
70
77
  data: z4.object({
71
78
  appliedAt: z4.string().optional()
72
79
  }),
73
80
  parents: z4.object({
74
- post: PostRefSchema
81
+ post: PostRefSchema,
82
+ version: PostVersionRefSchema.optional()
75
83
  })
76
84
  });
77
85
 
@@ -91,8 +99,8 @@ import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
91
99
  import { z as z6 } from "zod";
92
100
 
93
101
  // src/schemas/UserRefSchema.ts
94
- import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
95
- var UserRefSchema = refSchemaGenerator5("User");
102
+ import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
103
+ var UserRefSchema = refSchemaGenerator6("User");
96
104
 
97
105
  // src/schemas/PostSchema.ts
98
106
  var PostSchema = entitySchemaGenerator5("Post", {
@@ -167,8 +175,8 @@ var PostEntity = new Entity3("Post", {
167
175
  import { z as z13 } from "zod";
168
176
 
169
177
  // src/schemas/BlockRowRefSchema.ts
170
- import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
171
- var BlockRowRefSchema = refSchemaGenerator6("BlockRow");
178
+ import { refSchemaGenerator as refSchemaGenerator7 } from "roc-db";
179
+ var BlockRowRefSchema = refSchemaGenerator7("BlockRow");
172
180
 
173
181
  // src/schemas/BlockRefSchema.ts
174
182
  var BlockRefSchema = z13.union([
@@ -198,25 +206,39 @@ var BlockRow = new Entity5("BlockRow", {
198
206
  })
199
207
  });
200
208
 
201
- // src/entities/PostVersion.ts
209
+ // src/entities/OrgSettingsEntity.ts
202
210
  import { Entity as Entity6 } from "roc-db";
203
211
  import { z as z16 } from "zod";
204
- var PostVersion = new Entity6("PostVersion", {
212
+ var OrgSettingsEntity = new Entity6("OrgSettings", {
213
+ singleton: true,
205
214
  data: z16.object({
206
- version: z16.number(),
207
- snapshot: z16.array(z16.any())
215
+ name: z16.string(),
216
+ theme: z16.string().optional()
208
217
  }),
209
- parents: z16.object({ post: PostRefSchema }),
210
- indexedDataKeys: ["version"],
211
- uniqueDataKeys: ["slug"]
218
+ parents: z16.object({ primaryAdmin: UserRefSchema.optional() }),
219
+ children: z16.object({ featuredPosts: z16.array(z16.string()) })
212
220
  });
213
221
 
214
- // src/entities/UserEntity.ts
222
+ // src/entities/PostVersion.ts
215
223
  import { Entity as Entity7 } from "roc-db";
216
224
  import { z as z17 } from "zod";
217
- var UserEntity = new Entity7("User", {
225
+ var PostVersion = new Entity7("PostVersion", {
226
+ version: true,
218
227
  data: z17.object({
219
- email: z17.string().email()
228
+ version: z17.number(),
229
+ snapshot: z17.array(z17.any())
230
+ }),
231
+ parents: z17.object({ post: PostRefSchema }),
232
+ indexedDataKeys: ["version"],
233
+ uniqueDataKeys: ["slug"]
234
+ });
235
+
236
+ // src/entities/UserEntity.ts
237
+ import { Entity as Entity8 } from "roc-db";
238
+ import { z as z18 } from "zod";
239
+ var UserEntity = new Entity8("User", {
240
+ data: z18.object({
241
+ email: z18.string().email()
220
242
  }),
221
243
  uniqueDataKeys: ["email"]
222
244
  });
@@ -227,6 +249,7 @@ var entities = [
227
249
  BlockParagraph,
228
250
  BlockRow,
229
251
  Draft,
252
+ OrgSettingsEntity,
230
253
  PostEntity,
231
254
  PostVersion,
232
255
  UserEntity
@@ -251,8 +274,8 @@ var applyDraft = writeOperation("applyDraft", DraftRefSchema, (txn) => {
251
274
 
252
275
  // src/operations/createBlockImage.ts
253
276
  import { Query as Query2, writeOperation as writeOperation2 } from "roc-db";
254
- import { z as z18 } from "zod";
255
- var createBlockImage = writeOperation2("createBlockImage", z18.object({ parentRef: PostRefSchema, url: z18.string().url() }).strict(), (txn) => {
277
+ import { z as z19 } from "zod";
278
+ var createBlockImage = writeOperation2("createBlockImage", z19.object({ parentRef: PostRefSchema, url: z19.string().url() }).strict(), (txn) => {
256
279
  const ref = txn.createRef("BlockImage");
257
280
  const { parentRef, url } = txn.payload;
258
281
  return Query2(() => txn.createEntity(ref, {
@@ -263,10 +286,10 @@ var createBlockImage = writeOperation2("createBlockImage", z18.object({ parentRe
263
286
 
264
287
  // src/operations/createBlockParagraph.ts
265
288
  import { Query as Query3, QueryChain as QueryChain2, writeOperation as writeOperation3 } from "roc-db";
266
- import { z as z19 } from "zod";
267
- var createBlockParagrah = writeOperation3("createBlockParagraph", z19.object({
268
- parentRef: z19.union([PostRefSchema, BlockRowRefSchema]),
269
- content: z19.string().optional()
289
+ import { z as z20 } from "zod";
290
+ var createBlockParagrah = writeOperation3("createBlockParagraph", z20.object({
291
+ parentRef: z20.union([PostRefSchema, BlockRowRefSchema]),
292
+ content: z20.string().optional()
270
293
  }).strict(), (txn) => {
271
294
  const ref = txn.createRef("BlockParagraph");
272
295
  const { parentRef, content } = txn.payload;
@@ -278,16 +301,16 @@ var createBlockParagrah = writeOperation3("createBlockParagraph", z19.object({
278
301
  })), Query3((block, updatedParent) => ({ block, updatedParent })));
279
302
  }, {
280
303
  changeSetOnly: true,
281
- outputSchema: z19.object({
282
- block: z19.any(),
283
- updatedParent: z19.any()
304
+ outputSchema: z20.object({
305
+ block: z20.any(),
306
+ updatedParent: z20.any()
284
307
  })
285
308
  });
286
309
 
287
310
  // src/operations/createBlockRow.ts
288
311
  import { Query as Query4, QueryChain as QueryChain3, writeOperation as writeOperation4 } from "roc-db";
289
- import { z as z20 } from "zod";
290
- var createBlockRow = writeOperation4("createBlockRow", z20.object({ parentRef: z20.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
312
+ import { z as z21 } from "zod";
313
+ var createBlockRow = writeOperation4("createBlockRow", z21.object({ parentRef: z21.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
291
314
  const ref = txn.createRef("BlockRow");
292
315
  const { parentRef } = txn.payload;
293
316
  return QueryChain3(Query4(() => txn.readEntity(parentRef)), Query4((parent) => {
@@ -300,16 +323,16 @@ var createBlockRow = writeOperation4("createBlockRow", z20.object({ parentRef: z
300
323
  })), Query4((block, updatedParent) => ({ block, updatedParent })));
301
324
  }, {
302
325
  changeSetOnly: true,
303
- outputSchema: z20.object({
304
- block: z20.any(),
305
- updatedParent: z20.any()
326
+ outputSchema: z21.object({
327
+ block: z21.any(),
328
+ updatedParent: z21.any()
306
329
  })
307
330
  });
308
331
 
309
332
  // src/operations/createBlockTitle.ts
310
333
  import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
311
- import { z as z21 } from "zod";
312
- var PayloadSchema = z21.object({ parentRef: z21.union([PostRefSchema, BlockRowRefSchema]) }).strict();
334
+ import { z as z22 } from "zod";
335
+ var PayloadSchema = z22.object({ parentRef: z22.union([PostRefSchema, BlockRowRefSchema]) }).strict();
313
336
  var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn) => {
314
337
  const ref = txn.createRef("BlockTitle");
315
338
  const { postRef } = txn.payload;
@@ -318,8 +341,8 @@ var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn)
318
341
 
319
342
  // src/operations/createDraft.ts
320
343
  import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
321
- import { z as z22 } from "zod";
322
- var createDraft = writeOperation6("createDraft", z22.object({ postRef: PostRefSchema }).strict(), (txn) => {
344
+ import { z as z23 } from "zod";
345
+ var createDraft = writeOperation6("createDraft", z23.object({ postRef: PostRefSchema }).strict(), (txn) => {
323
346
  const ref = txn.createRef("Draft");
324
347
  const { postRef } = txn.payload;
325
348
  return Query6(() => txn.createEntity(ref, {
@@ -329,47 +352,69 @@ var createDraft = writeOperation6("createDraft", z22.object({ postRef: PostRefSc
329
352
  }));
330
353
  }, { outputSchema: DraftSchema });
331
354
 
332
- // src/operations/createPost.ts
355
+ // src/operations/createOrgSettings.ts
333
356
  import { Query as Query7, writeOperation as writeOperation7 } from "roc-db";
334
- import { z as z23 } from "zod";
335
- var PayloadSchema2 = z23.object({
336
- title: z23.string(),
337
- slug: z23.string().optional(),
338
- tags: z23.array(z23.string()).default([])
357
+ import { z as z24 } from "zod";
358
+ var createOrgSettings = writeOperation7("createOrgSettings", z24.object({
359
+ name: z24.string(),
360
+ theme: z24.string().optional(),
361
+ primaryAdmin: UserRefSchema.optional()
362
+ }), (txn) => {
363
+ const ref = txn.createRef("OrgSettings");
364
+ const { name, theme, primaryAdmin } = txn.payload;
365
+ return Query7(() => txn.createEntity(ref, {
366
+ data: { name, theme },
367
+ parents: { primaryAdmin },
368
+ children: { featuredPosts: [] }
369
+ }));
370
+ });
371
+
372
+ // src/operations/createPost.ts
373
+ import { Query as Query8, writeOperation as writeOperation8 } from "roc-db";
374
+ import { z as z25 } from "zod";
375
+ var PayloadSchema2 = z25.object({
376
+ title: z25.string(),
377
+ slug: z25.string().optional(),
378
+ tags: z25.array(z25.string()).default([])
339
379
  }).strict();
340
- var createPost = writeOperation7("createPost", PayloadSchema2, (txn) => {
380
+ var createPost = writeOperation8("createPost", PayloadSchema2, (txn) => {
341
381
  const ref = txn.createRef("Post");
342
382
  const { title, slug, tags } = txn.payload;
343
- return Query7(() => txn.createEntity(ref, {
383
+ return Query8(() => txn.createEntity(ref, {
344
384
  data: { title, tags, slug },
345
385
  children: { blocks: [] }
346
386
  }));
347
387
  });
348
388
 
389
+ // src/operations/createUnknownRef.ts
390
+ import { Query as Query9, writeOperation as writeOperation9 } from "roc-db";
391
+ import { z as z26 } from "zod";
392
+ var createUnknownRef = writeOperation9("createUnknownRef", z26.object({}).optional(), (txn) => Query9(() => txn.createRef("NotARegisteredEntity")));
393
+
349
394
  // src/operations/createUser.ts
350
- import { Query as Query8, writeOperation as writeOperation8 } from "roc-db";
351
- import { z as z24 } from "zod";
352
- var createUser = writeOperation8("createUser", z24.object({ email: z24.string() }), (txn) => {
395
+ import { Query as Query10, writeOperation as writeOperation10 } from "roc-db";
396
+ import { z as z27 } from "zod";
397
+ var createUser = writeOperation10("createUser", z27.object({ email: z27.string() }), (txn) => {
353
398
  const ref = txn.createRef("User");
354
399
  const { email } = txn.payload;
355
- return Query8(() => txn.createEntity(ref, { data: { email } }));
400
+ return Query10(() => txn.createEntity(ref, { data: { email } }));
356
401
  });
357
402
 
358
403
  // src/operations/deleteBlocks.ts
359
- import { Query as Query9, QueryChain as QueryChain4, writeOperation as writeOperation9 } from "roc-db";
360
- import { z as z25 } from "zod";
404
+ import { Query as Query11, QueryChain as QueryChain4, writeOperation as writeOperation11 } from "roc-db";
405
+ import { z as z28 } from "zod";
361
406
  var DeleteBlockQuery = (txn, blockRef) => {
362
- return QueryChain4(Query9(() => txn.readEntity(blockRef)), Query9((block) => {
407
+ return QueryChain4(Query11(() => txn.readEntity(blockRef)), Query11((block) => {
363
408
  return txn.readEntity(block.parents.parent, true);
364
- }), Query9((post) => {
409
+ }), Query11((post) => {
365
410
  return txn.patchEntity(post.ref, {
366
411
  children: {
367
412
  blocks: post.children.blocks.filter((ref) => ref !== blockRef)
368
413
  }
369
414
  });
370
- }), Query9(() => txn.deleteEntity(blockRef)));
415
+ }), Query11(() => txn.deleteEntity(blockRef)));
371
416
  };
372
- var deleteBlocks = writeOperation9("deleteBlocks", z25.array(z25.union([
417
+ var deleteBlocks = writeOperation11("deleteBlocks", z28.array(z28.union([
373
418
  BlockParagraphRefSchema,
374
419
  BlockImageRefSchema,
375
420
  BlockRowRefSchema
@@ -379,42 +424,60 @@ var deleteBlocks = writeOperation9("deleteBlocks", z25.array(z25.union([
379
424
  }, { changeSetOnly: true });
380
425
 
381
426
  // src/operations/deleteDraft.ts
382
- import { Query as Query10, QueryChain as QueryChain5, writeOperation as writeOperation10 } from "roc-db";
383
- var deleteDraft = writeOperation10("deleteDraft", DraftRefSchema, (txn) => {
427
+ import { Query as Query12, QueryChain as QueryChain5, writeOperation as writeOperation12 } from "roc-db";
428
+ var deleteDraft = writeOperation12("deleteDraft", DraftRefSchema, (txn) => {
384
429
  const ref = txn.payload;
385
- return QueryChain5(Query10(() => txn.deleteEntity(ref, true)), Query10(() => txn.deleteChangeSet(ref)));
430
+ return QueryChain5(Query12(() => txn.deleteEntity(ref, true)), Query12(() => txn.deleteChangeSet(ref)));
386
431
  });
387
432
 
433
+ // src/operations/deleteOrgSettings.ts
434
+ import { Query as Query13, writeOperation as writeOperation13 } from "roc-db";
435
+ import { z as z29 } from "zod";
436
+ var deleteOrgSettings = writeOperation13("deleteOrgSettings", z29.object({}).optional(), (txn) => Query13(() => txn.deleteEntity("OrgSettings")));
437
+
388
438
  // src/operations/deletePost.ts
389
- import { Query as Query11, writeOperation as writeOperation11 } from "roc-db";
390
- var deletePost = writeOperation11("deletePost", PostRefSchema, (txn) => {
439
+ import { Query as Query14, writeOperation as writeOperation14 } from "roc-db";
440
+ var deletePost = writeOperation14("deletePost", PostRefSchema, (txn) => {
391
441
  const ref = txn.payload;
392
- return Query11(() => txn.deleteEntity(ref, true));
442
+ return Query14(() => txn.deleteEntity(ref, true));
443
+ });
444
+
445
+ // src/operations/duplicateDraft.ts
446
+ import { Query as Query15, QueryChain as QueryChain6, writeOperation as writeOperation15 } from "roc-db";
447
+ import { z as z30 } from "zod";
448
+ var duplicateDraft = writeOperation15("duplicateDraft", z30.object({ sourceRef: DraftRefSchema, postRef: PostRefSchema }).strict(), (txn) => {
449
+ const newDraftRef = txn.createRef("Draft");
450
+ const { sourceRef, postRef } = txn.payload;
451
+ return QueryChain6(Query15(() => txn.createEntity(newDraftRef, { parents: { post: postRef } })), Query15(() => txn.duplicateChangeSetMutations(sourceRef, newDraftRef)), Query15((dup) => ({
452
+ draftRef: newDraftRef,
453
+ mutations: dup.mutations,
454
+ refMap: dup.refMap
455
+ })));
393
456
  });
394
457
 
395
458
  // src/operations/moveBlocks.ts
396
- import { Query as Query12, QueryChain as QueryChain6, writeOperation as writeOperation12 } from "roc-db";
397
- import { z as z26 } from "zod";
398
- var PayloadSchema3 = z26.object({
399
- refs: z26.array(z26.union([BlockParagraphRefSchema, BlockRowRefSchema])),
400
- targetPosition: z26.number().min(0)
459
+ import { Query as Query16, QueryChain as QueryChain7, writeOperation as writeOperation16 } from "roc-db";
460
+ import { z as z31 } from "zod";
461
+ var PayloadSchema3 = z31.object({
462
+ refs: z31.array(z31.union([BlockParagraphRefSchema, BlockRowRefSchema])),
463
+ targetPosition: z31.number().min(0)
401
464
  }).strict();
402
- var moveBlocks = writeOperation12("moveBlocks", PayloadSchema3, (txn) => {
465
+ var moveBlocks = writeOperation16("moveBlocks", PayloadSchema3, (txn) => {
403
466
  const { refs } = txn.payload;
404
- return QueryChain6(Query12(() => txn.batchReadEntities(refs)), Query12((items) => {
467
+ return QueryChain7(Query16(() => txn.batchReadEntities(refs)), Query16((items) => {
405
468
  return "todo";
406
469
  }));
407
470
  });
408
471
 
409
472
  // src/operations/pageBlocks.ts
410
- import { Query as Query13, readOperation } from "roc-db";
411
- import { z as z27 } from "zod";
412
- var pageBlocks = readOperation("pageBlocks", z27.object({
413
- size: z27.number().default(100),
414
- parentRef: z27.string().optional()
473
+ import { Query as Query17, readOperation } from "roc-db";
474
+ import { z as z32 } from "zod";
475
+ var pageBlocks = readOperation("pageBlocks", z32.object({
476
+ size: z32.number().default(100),
477
+ parentRef: z32.string().optional()
415
478
  }), (txn) => {
416
479
  const { size, parentRef } = txn.payload;
417
- return Query13(() => txn.pageEntities({
480
+ return Query17(() => txn.pageEntities({
418
481
  entities: ["BlockImage", "BlockParagraph"],
419
482
  size,
420
483
  childrenOf: parentRef ? [parentRef] : []
@@ -422,50 +485,50 @@ var pageBlocks = readOperation("pageBlocks", z27.object({
422
485
  });
423
486
 
424
487
  // src/operations/pageEmptyEntitiesArray.ts
425
- import { Query as Query14, readOperation as readOperation2 } from "roc-db";
426
- import { z as z28 } from "zod";
427
- var pageEmptyEntitiesArray = readOperation2("pageEmptyEntitiesArray", z28.object({ size: z28.number().default(100) }), (txn) => {
488
+ import { Query as Query18, readOperation as readOperation2 } from "roc-db";
489
+ import { z as z33 } from "zod";
490
+ var pageEmptyEntitiesArray = readOperation2("pageEmptyEntitiesArray", z33.object({ size: z33.number().default(100) }), (txn) => {
428
491
  const { size } = txn.payload;
429
- return Query14(() => txn.pageEntities({ entities: [], size }));
492
+ return Query18(() => txn.pageEntities({ entities: [], size }));
430
493
  });
431
494
 
432
495
  // src/operations/pagePosts.ts
433
- import { Query as Query15, readOperation as readOperation3 } from "roc-db";
434
- import { z as z29 } from "zod";
435
- var pagePosts = readOperation3("pagePosts", z29.object({ size: z29.number().default(100) }).default({}), (txn) => {
496
+ import { Query as Query19, readOperation as readOperation3 } from "roc-db";
497
+ import { z as z34 } from "zod";
498
+ var pagePosts = readOperation3("pagePosts", z34.object({ size: z34.number().default(100) }).default({}), (txn) => {
436
499
  const { size } = txn.payload;
437
- return Query15(() => txn.pageEntities({ entities: ["Post"], size }));
500
+ return Query19(() => txn.pageEntities({ entities: ["Post"], size }));
438
501
  });
439
502
 
440
503
  // src/operations/pageSplat.ts
441
- import { Query as Query16, readOperation as readOperation4 } from "roc-db";
442
- import { z as z30 } from "zod";
443
- var pageSplat = readOperation4("pageSplat", z30.object({ size: z30.number().default(100) }), (txn) => {
504
+ import { Query as Query20, readOperation as readOperation4 } from "roc-db";
505
+ import { z as z35 } from "zod";
506
+ var pageSplat = readOperation4("pageSplat", z35.object({ size: z35.number().default(100) }), (txn) => {
444
507
  const { size } = txn.payload;
445
- return Query16(() => txn.pageEntities({ entities: "*", size }));
508
+ return Query20(() => txn.pageEntities({ entities: "*", size }));
446
509
  });
447
510
 
448
511
  // src/operations/pagePostsByTag.ts
449
- import { Query as Query17, readOperation as readOperation5 } from "roc-db";
450
- import { z as z31 } from "zod";
451
- var pagePostsByTag = readOperation5("pagePostsByTag", z31.string(), (txn) => {
512
+ import { Query as Query21, readOperation as readOperation5 } from "roc-db";
513
+ import { z as z36 } from "zod";
514
+ var pagePostsByTag = readOperation5("pagePostsByTag", z36.string(), (txn) => {
452
515
  const tag = txn.payload;
453
- return Query17(() => txn.pageEntitiesByIndex("Post", "tags", tag));
516
+ return Query21(() => txn.pageEntitiesByIndex("Post", "tags", tag));
454
517
  });
455
518
 
456
519
  // src/operations/readEntity.ts
457
- import { NotFoundError, Query as Query18, QueryChain as QueryChain7, readOperation as readOperation6 } from "roc-db";
458
- import { z as z32 } from "zod";
459
- var readEntity = readOperation6("readEntity", z32.string(), (txn) => {
520
+ import { NotFoundError, Query as Query22, QueryChain as QueryChain8, readOperation as readOperation6 } from "roc-db";
521
+ import { z as z37 } from "zod";
522
+ var readEntity = readOperation6("readEntity", z37.string(), (txn) => {
460
523
  const ref = txn.payload;
461
- return QueryChain7(Query18(() => txn.readEntity(ref)), Query18((entity) => {
524
+ return QueryChain8(Query22(() => txn.readEntity(ref)), Query22((entity) => {
462
525
  if (!entity) {
463
526
  throw new NotFoundError(ref);
464
527
  }
465
528
  return entity;
466
529
  }));
467
530
  }, {
468
- outputSchema: z32.union([
531
+ outputSchema: z37.union([
469
532
  PostSchema,
470
533
  BlockImageSchema,
471
534
  BlockParagraphSchema
@@ -473,11 +536,11 @@ var readEntity = readOperation6("readEntity", z32.string(), (txn) => {
473
536
  });
474
537
 
475
538
  // src/operations/readMutation.ts
476
- import { NotFoundError as NotFoundError2, Query as Query19, QueryChain as QueryChain8, readOperation as readOperation7 } from "roc-db";
477
- import { z as z33 } from "zod";
478
- var readMutation = readOperation7("readMutation", z33.string(), (txn) => {
539
+ import { NotFoundError as NotFoundError2, Query as Query23, QueryChain as QueryChain9, readOperation as readOperation7 } from "roc-db";
540
+ import { z as z38 } from "zod";
541
+ var readMutation = readOperation7("readMutation", z38.string(), (txn) => {
479
542
  const ref = txn.payload;
480
- return QueryChain8(Query19(() => txn.readMutation(ref)), Query19((entity) => {
543
+ return QueryChain9(Query23(() => txn.readMutation(ref)), Query23((entity) => {
481
544
  if (!entity) {
482
545
  throw new NotFoundError2(ref);
483
546
  }
@@ -485,53 +548,58 @@ var readMutation = readOperation7("readMutation", z33.string(), (txn) => {
485
548
  }));
486
549
  });
487
550
 
551
+ // src/operations/readOrgSettings.ts
552
+ import { Query as Query24, readOperation as readOperation8 } from "roc-db";
553
+ import { z as z39 } from "zod";
554
+ var readOrgSettings = readOperation8("readOrgSettings", z39.object({}).optional(), (txn) => Query24(() => txn.readEntity("OrgSettings", true)));
555
+
488
556
  // src/operations/readPost.ts
489
- import { Query as Query20, readOperation as readOperation8 } from "roc-db";
490
- var readPost = readOperation8("readPost", PostRefSchema, (txn) => {
557
+ import { Query as Query25, readOperation as readOperation9 } from "roc-db";
558
+ var readPost = readOperation9("readPost", PostRefSchema, (txn) => {
491
559
  const ref = txn.payload;
492
- return Query20(() => txn.readEntity(ref, true));
560
+ return Query25(() => txn.readEntity(ref, true));
493
561
  }, { outputSchema: PostSchema });
494
562
 
495
563
  // src/operations/readPostBySlug.ts
496
- import { Query as Query21, readOperation as readOperation9 } from "roc-db";
497
- import { z as z34 } from "zod";
498
- var readPostBySlug = readOperation9("readPostBySlug", z34.string(), (txn) => {
564
+ import { Query as Query26, readOperation as readOperation10 } from "roc-db";
565
+ import { z as z40 } from "zod";
566
+ var readPostBySlug = readOperation10("readPostBySlug", z40.string(), (txn) => {
499
567
  const slug = txn.payload;
500
- return Query21(() => txn.readEntityByUniqueField("Post", "slug", slug));
568
+ return Query26(() => txn.readEntityByUniqueField("Post", "slug", slug));
501
569
  }, { outputSchema: PostSchema });
502
570
 
503
571
  // src/operations/testTransactionalEdits.ts
504
572
  import { expect } from "bun:test";
505
- import { Query as Query22, QueryChain as QueryChain9, writeOperation as writeOperation13 } from "roc-db";
506
- import { z as z35 } from "zod";
573
+ import { Query as Query27, QueryChain as QueryChain10, writeOperation as writeOperation17 } from "roc-db";
574
+ import { z as z41 } from "zod";
507
575
  var TestCreatePatchDeleteInSameTransaction = (txn, title) => {
508
576
  const postRef = txn.createRef("Post");
509
- return QueryChain9(Query22(() => txn.createEntity(postRef, {
577
+ return QueryChain10(Query27(() => txn.createEntity(postRef, {
510
578
  data: { title, tags: [] },
511
579
  children: { blocks: [] }
512
- })), Query22(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query22((post) => {
580
+ })), Query27(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query27((post) => {
513
581
  expect(post.data.title).toBe(title);
514
582
  expect(post.data.foo).toBe("bar");
515
- }), Query22(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query22((post) => {
583
+ }), Query27(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query27((post) => {
516
584
  expect(post.data.title).toBe(title);
517
585
  expect(post.data.foo).toBeUndefined();
518
586
  expect(post.data.bar).toBe("foo");
519
587
  expect(txn.log).toHaveLength(1);
520
588
  expect(txn.log.get(postRef)[0]).toBe("create");
521
- }), Query22((post) => txn.deleteEntity(postRef)), Query22((res) => {
589
+ }), Query27((post) => txn.deleteEntity(postRef)), Query27((res) => {
522
590
  expect(res).toBe(1);
523
591
  expect(txn.log).toHaveLength(0);
524
592
  }));
525
593
  };
526
594
  var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
527
- return QueryChain9(Query22(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query22((post) => {
595
+ return QueryChain10(Query27(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query27((post) => {
528
596
  expect(post.data.foo).toBe("bar");
529
- }), Query22(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query22((post) => {
597
+ }), Query27(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query27((post) => {
530
598
  expect(post.data.foo).toBeUndefined();
531
599
  expect(post.data.bar).toBe("foo");
532
600
  expect(txn.log).toHaveLength(1);
533
601
  expect(txn.log.get(ref)[0]).toBe("update");
534
- }), Query22((post) => txn.deleteEntity(ref)), Query22((res) => {
602
+ }), Query27((post) => txn.deleteEntity(ref)), Query27((res) => {
535
603
  expect(res).toBe(1);
536
604
  expect(txn.log).toHaveLength(1);
537
605
  expect(txn.log.get(ref)[0]).toBe("delete");
@@ -539,14 +607,14 @@ var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
539
607
  };
540
608
  var TestCreateOnExistingRef = (txn) => {
541
609
  const ref = txn.createRef("Post");
542
- return QueryChain9(Query22(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query22(() => txn.createEntity(ref, { data: { foo: "bar" } })));
610
+ return QueryChain10(Query27(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query27(() => txn.createEntity(ref, { data: { foo: "bar" } })));
543
611
  };
544
- var PayloadSchema4 = z35.object({
545
- name: z35.string().optional(),
612
+ var PayloadSchema4 = z41.object({
613
+ name: z41.string().optional(),
546
614
  post1ref: PostRefSchema.optional(),
547
615
  post2ref: PostRefSchema.optional()
548
616
  }).strict();
549
- var testTransactionalEdits = writeOperation13("testTransactionalEdits", PayloadSchema4, (txn) => {
617
+ var testTransactionalEdits = writeOperation17("testTransactionalEdits", PayloadSchema4, (txn) => {
550
618
  const { name, post1ref, post2ref } = txn.payload;
551
619
  if (name)
552
620
  return TestCreatePatchDeleteInSameTransaction(txn, name);
@@ -557,30 +625,38 @@ var testTransactionalEdits = writeOperation13("testTransactionalEdits", PayloadS
557
625
  }, {});
558
626
 
559
627
  // src/operations/updateBlockParagraph.ts
560
- import { Query as Query23, writeOperation as writeOperation14 } from "roc-db";
561
- import { z as z36 } from "zod";
562
- var updateBlockParagraph = writeOperation14("updateBlockParagraph", z36.object({
628
+ import { Query as Query28, writeOperation as writeOperation18 } from "roc-db";
629
+ import { z as z42 } from "zod";
630
+ var updateBlockParagraph = writeOperation18("updateBlockParagraph", z42.object({
563
631
  ref: BlockParagraphRefSchema,
564
- content: z36.string()
632
+ content: z42.string()
565
633
  }), (txn) => {
566
634
  const { ref, content } = txn.payload;
567
- return Query23(() => txn.patchEntity(ref, {
635
+ return Query28(() => txn.patchEntity(ref, {
568
636
  data: { content }
569
637
  }));
570
638
  }, { outputSchema: BlockParagraphSchema });
571
639
 
640
+ // src/operations/updateOrgSettingsName.ts
641
+ import { Query as Query29, writeOperation as writeOperation19 } from "roc-db";
642
+ import { z as z43 } from "zod";
643
+ var updateOrgSettingsName = writeOperation19("updateOrgSettingsName", z43.object({ name: z43.string() }), (txn) => {
644
+ const { name } = txn.payload;
645
+ return Query29(() => txn.patchEntity("OrgSettings", { data: { name } }));
646
+ }, { debounce: 10 });
647
+
572
648
  // src/operations/updatePost.ts
573
- import { Query as Query24, writeOperation as writeOperation15 } from "roc-db";
574
- import { z as z37 } from "zod";
575
- var PayloadSchema5 = z37.object({
649
+ import { Query as Query30, writeOperation as writeOperation20 } from "roc-db";
650
+ import { z as z44 } from "zod";
651
+ var PayloadSchema5 = z44.object({
576
652
  ref: PostRefSchema,
577
- title: z37.string().optional(),
578
- tags: z37.array(z37.string()).optional().default([]),
653
+ title: z44.string().optional(),
654
+ tags: z44.array(z44.string()).optional().default([]),
579
655
  authorRef: UserRefSchema.optional()
580
656
  });
581
- var updatePost = writeOperation15("updatePost", PayloadSchema5, (txn) => {
657
+ var updatePost = writeOperation20("updatePost", PayloadSchema5, (txn) => {
582
658
  const { ref, authorRef, ...data } = txn.payload;
583
- return Query24(() => txn.updateEntity(ref, {
659
+ return Query30(() => txn.updateEntity(ref, {
584
660
  data,
585
661
  parents: { author: authorRef },
586
662
  children: { blocks: [] }
@@ -588,43 +664,43 @@ var updatePost = writeOperation15("updatePost", PayloadSchema5, (txn) => {
588
664
  }, { outputSchema: PostSchema });
589
665
 
590
666
  // src/operations/updatePostDescription.ts
591
- import { Query as Query25, writeOperation as writeOperation16 } from "roc-db";
592
- import { z as z38 } from "zod";
593
- var updatePostDescription = writeOperation16("updatePostDescription", z38.object({ ref: PostRefSchema, description: z38.string() }), (txn) => {
667
+ import { Query as Query31, writeOperation as writeOperation21 } from "roc-db";
668
+ import { z as z45 } from "zod";
669
+ var updatePostDescription = writeOperation21("updatePostDescription", z45.object({ ref: PostRefSchema, description: z45.string() }), (txn) => {
594
670
  const { ref, description } = txn.payload;
595
- return Query25(() => txn.patchEntity(ref, { data: { description } }));
671
+ return Query31(() => txn.patchEntity(ref, { data: { description } }));
596
672
  }, { debounce: 10, changeSetOnly: true, outputSchema: PostSchema });
597
673
 
598
674
  // src/operations/updatePostSlug.ts
599
- import { Query as Query26, writeOperation as writeOperation17 } from "roc-db";
600
- import { z as z39 } from "zod";
601
- var updatePostSlug = writeOperation17("updatePostSlug", z39.object({ ref: PostRefSchema, slug: z39.string() }), (txn) => {
675
+ import { Query as Query32, writeOperation as writeOperation22 } from "roc-db";
676
+ import { z as z46 } from "zod";
677
+ var updatePostSlug = writeOperation22("updatePostSlug", z46.object({ ref: PostRefSchema, slug: z46.string() }), (txn) => {
602
678
  const { ref, slug } = txn.payload;
603
- return Query26(() => txn.patchEntity(ref, { data: { slug } }));
679
+ return Query32(() => txn.patchEntity(ref, { data: { slug } }));
604
680
  }, { debounce: 10, outputSchema: PostSchema });
605
681
 
606
682
  // src/operations/updatePostTags.ts
607
- import { Query as Query27, writeOperation as writeOperation18 } from "roc-db";
608
- import { z as z40 } from "zod";
609
- var updatePostTags = writeOperation18("updatePostTags", z40.object({ ref: PostRefSchema, tags: z40.array(z40.string()) }), (txn) => {
683
+ import { Query as Query33, writeOperation as writeOperation23 } from "roc-db";
684
+ import { z as z47 } from "zod";
685
+ var updatePostTags = writeOperation23("updatePostTags", z47.object({ ref: PostRefSchema, tags: z47.array(z47.string()) }), (txn) => {
610
686
  const { ref, tags } = txn.payload;
611
- return Query27(() => txn.patchEntity(ref, { data: { tags } }));
687
+ return Query33(() => txn.patchEntity(ref, { data: { tags } }));
612
688
  }, { debounce: 10, outputSchema: PostSchema });
613
689
 
614
690
  // src/operations/updatePostTitle.ts
615
- import { Query as Query28, writeOperation as writeOperation19 } from "roc-db";
616
- import { z as z41 } from "zod";
617
- var updatePostTitle = writeOperation19("updatePostTitle", z41.object({ ref: PostRefSchema, title: z41.string() }), (txn) => {
691
+ import { Query as Query34, writeOperation as writeOperation24 } from "roc-db";
692
+ import { z as z48 } from "zod";
693
+ var updatePostTitle = writeOperation24("updatePostTitle", z48.object({ ref: PostRefSchema, title: z48.string() }), (txn) => {
618
694
  const { ref, title } = txn.payload;
619
- return Query28(() => txn.patchEntity(ref, { data: { title } }));
695
+ return Query34(() => txn.patchEntity(ref, { data: { title } }));
620
696
  }, { debounce: 10, outputSchema: PostSchema });
621
697
 
622
698
  // src/operations/crudBySlug.ts
623
- import { Query as Query29, QueryChain as QueryChain10, writeOperation as writeOperation20 } from "roc-db";
624
- import { z as z42 } from "zod";
625
- var crudBySlug = writeOperation20("crudBySlug", z42.object({ slug: z42.string(), newSlug: z42.string() }), (txn) => {
699
+ import { Query as Query35, QueryChain as QueryChain11, writeOperation as writeOperation25 } from "roc-db";
700
+ import { z as z49 } from "zod";
701
+ var crudBySlug = writeOperation25("crudBySlug", z49.object({ slug: z49.string(), newSlug: z49.string() }), (txn) => {
626
702
  const { slug, newSlug } = txn.payload;
627
- 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(() => {
703
+ return QueryChain11(Query35(() => txn.readEntityByUniqueField("Post", "slug", slug)), Query35((post) => txn.patchEntity(post.ref, { data: { slug: newSlug } })), Query35(() => txn.readEntityByUniqueField("Post", "slug", newSlug)), Query35((post) => txn.deleteEntity(post.ref)), Query35(() => {
628
704
  return [
629
705
  txn.readEntityByUniqueField("Post", "slug", slug, false),
630
706
  txn.readEntityByUniqueField("Post", "slug", newSlug, false)
@@ -640,24 +716,30 @@ var operations = [
640
716
  createBlockParagrah,
641
717
  createBlockRow,
642
718
  createDraft,
719
+ createOrgSettings,
643
720
  createPost,
721
+ createUnknownRef,
644
722
  createUser,
645
723
  crudBySlug,
646
724
  deleteBlocks,
647
725
  deleteDraft,
726
+ deleteOrgSettings,
648
727
  deletePost,
728
+ duplicateDraft,
649
729
  readPostBySlug,
650
730
  moveBlocks,
651
731
  pagePostsByTag,
652
732
  pageBlocks,
653
733
  readEntity,
654
734
  readMutation,
735
+ readOrgSettings,
655
736
  readPost,
656
737
  pageEmptyEntitiesArray,
657
738
  pagePosts,
658
739
  pageSplat,
659
740
  testTransactionalEdits,
660
741
  updateBlockParagraph,
742
+ updateOrgSettingsName,
661
743
  updatePost,
662
744
  updatePostDescription,
663
745
  updatePostSlug,
@@ -669,9 +751,11 @@ import { beforeAll, describe, expect as expect2, test } from "bun:test";
669
751
  import {
670
752
  BadRequestError,
671
753
  ConflictError,
754
+ Entity as Entity9,
672
755
  NotFoundError as NotFoundError3,
673
756
  Snowflake
674
757
  } from "roc-db";
758
+ import { z as z50 } from "zod";
675
759
  import { faker } from "@faker-js/faker";
676
760
  var snowflake = new Snowflake(10, 10);
677
761
  var prepareChangeSetTest = async (adapter, adapter2) => {
@@ -720,14 +804,18 @@ var prepareChangeSetTest = async (adapter, adapter2) => {
720
804
  };
721
805
  };
722
806
  var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
723
- let createAdapter = async ({ optimistic = false } = {}) => {
807
+ let createAdapter = async ({
808
+ optimistic = false,
809
+ session = { identityRef: "User/42" },
810
+ engineArgs
811
+ } = {}) => {
724
812
  return adapterConstructor({
725
813
  operations,
726
814
  entities,
727
- session: { identityRef: "User/42" },
815
+ session,
728
816
  snowflake,
729
817
  optimistic,
730
- ...await generateArgs()
818
+ ...engineArgs ?? await generateArgs()
731
819
  });
732
820
  };
733
821
  let adapter1, adapter2;
@@ -918,6 +1006,87 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
918
1006
  })).toThrow(BadRequestError);
919
1007
  });
920
1008
  });
1009
+ describe("OrgSettings singleton", () => {
1010
+ let adapter;
1011
+ beforeAll(async () => {
1012
+ adapter = await createAdapter();
1013
+ });
1014
+ test("create returns bare-name ref", async () => {
1015
+ const [orgSettings] = await adapter.createOrgSettings({
1016
+ name: "Acme",
1017
+ theme: "dark",
1018
+ primaryAdmin: "User/42"
1019
+ });
1020
+ expect2(orgSettings.ref).toBe("OrgSettings");
1021
+ expect2(orgSettings.entity).toBe("OrgSettings");
1022
+ expect2(orgSettings.data.name).toBe("Acme");
1023
+ expect2(orgSettings.parents.primaryAdmin).toBe("User/42");
1024
+ expect2(orgSettings.children.featuredPosts).toStrictEqual([]);
1025
+ });
1026
+ test("read by bare-name ref", async () => {
1027
+ const orgSettings = await adapter.readOrgSettings();
1028
+ expect2(orgSettings.ref).toBe("OrgSettings");
1029
+ expect2(orgSettings.data.name).toBe("Acme");
1030
+ });
1031
+ test("second create throws ConflictError", async () => {
1032
+ expect2(() => adapter.createOrgSettings({ name: "Other" })).toThrow(ConflictError);
1033
+ });
1034
+ test("patch + debounce collapses mutations", async () => {
1035
+ const [, mutation1] = await adapter.updateOrgSettingsName({
1036
+ name: "Acme Co"
1037
+ });
1038
+ const [updated, mutation2] = await adapter.updateOrgSettingsName({
1039
+ name: "Acme Inc"
1040
+ });
1041
+ expect2(updated.data.name).toBe("Acme Inc");
1042
+ expect2(mutation1.ref).toBe(mutation2.ref);
1043
+ expect2(mutation2.debounceCount).toBeGreaterThanOrEqual(1);
1044
+ });
1045
+ test("debounce does not collapse across identities", async () => {
1046
+ const sharedEngineArgs = await generateArgs();
1047
+ const adapterA = await createAdapter({
1048
+ session: { identityRef: "User/A" },
1049
+ engineArgs: sharedEngineArgs
1050
+ });
1051
+ const adapterB = await createAdapter({
1052
+ session: { identityRef: "User/B" },
1053
+ engineArgs: sharedEngineArgs
1054
+ });
1055
+ await adapterA.createOrgSettings({ name: "Acme" });
1056
+ const [, mutationA] = await adapterA.updateOrgSettingsName({
1057
+ name: "From A"
1058
+ });
1059
+ const [, mutationB] = await adapterB.updateOrgSettingsName({
1060
+ name: "From B"
1061
+ });
1062
+ expect2(mutationA.ref).not.toBe(mutationB.ref);
1063
+ expect2(mutationA.identityRef).toBe("User/A");
1064
+ expect2(mutationB.identityRef).toBe("User/B");
1065
+ await adapterA.deleteOrgSettings();
1066
+ });
1067
+ test("delete removes the singleton", async () => {
1068
+ const [count] = await adapter.deleteOrgSettings();
1069
+ expect2(count).toBe(1);
1070
+ expect2(() => adapter.readOrgSettings()).toThrow(NotFoundError3);
1071
+ });
1072
+ test("recreate after delete works", async () => {
1073
+ const [orgSettings] = await adapter.createOrgSettings({
1074
+ name: "NewOrg"
1075
+ });
1076
+ expect2(orgSettings.ref).toBe("OrgSettings");
1077
+ expect2(orgSettings.data.name).toBe("NewOrg");
1078
+ });
1079
+ test("constructor rejects singleton + uniqueDataKeys", () => {
1080
+ expect2(() => new Entity9("Bad", {
1081
+ singleton: true,
1082
+ data: z50.object({ name: z50.string() }),
1083
+ uniqueDataKeys: ["name"]
1084
+ })).toThrow(/singleton/);
1085
+ });
1086
+ test("createRef throws on unregistered entity", async () => {
1087
+ expect2(() => adapter.createUnknownRef()).toThrow(BadRequestError);
1088
+ });
1089
+ });
921
1090
  describe("paging", () => {
922
1091
  let adapter;
923
1092
  let post1ref;
@@ -1050,6 +1219,40 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
1050
1219
  const changeSetAdapter2 = adapter1.changeSet("Draft/123");
1051
1220
  expect2(() => changeSetAdapter2.createPost({ title: "Title 1" })).toThrow(BadRequestError);
1052
1221
  });
1222
+ test("duplicateDraft (txn.duplicateChangeSetMutations) produces an independent copy with remapped refs", async () => {
1223
+ const [post2] = await adapter1.createPost({
1224
+ title: "Title 1",
1225
+ slug: faker.lorem.slug(5)
1226
+ });
1227
+ const [sourceDraft] = await adapter1.createDraft({
1228
+ postRef: post2.ref
1229
+ });
1230
+ const sourceCs = adapter1.changeSet(sourceDraft.ref);
1231
+ const [{ block: row }] = await sourceCs.createBlockRow({
1232
+ parentRef: post2.ref
1233
+ });
1234
+ const [{ block: para }] = await sourceCs.createBlockParagraph({
1235
+ parentRef: row.ref,
1236
+ content: "Hello"
1237
+ });
1238
+ const [{ draftRef: newDraftRef, mutations, refMap }] = await adapter1.duplicateDraft({
1239
+ sourceRef: sourceDraft.ref,
1240
+ postRef: post2.ref
1241
+ });
1242
+ expect2(mutations).toHaveLength(2);
1243
+ const newRow = refMap.get(row.ref);
1244
+ const newPara = refMap.get(para.ref);
1245
+ expect2(newRow).toBeDefined();
1246
+ expect2(newPara).toBeDefined();
1247
+ expect2(newRow).not.toBe(row.ref);
1248
+ expect2(newPara).not.toBe(para.ref);
1249
+ expect2([...refMap.values()]).not.toContain(row.ref);
1250
+ expect2([...refMap.values()]).not.toContain(para.ref);
1251
+ const targetCs = adapter1.changeSet(newDraftRef);
1252
+ expect2((await targetCs.readEntity(newRow)).ref).toBe(newRow);
1253
+ expect2((await targetCs.readEntity(newPara)).parents.parent).toBe(newRow);
1254
+ expect2((await sourceCs.readEntity(para.ref)).parents.parent).toBe(row.ref);
1255
+ });
1053
1256
  test("deleteBlocks (patch running 2 times removing on array element every time)", async () => {
1054
1257
  const [post2, createPostMutation] = await adapter1.createPost({
1055
1258
  title: "Title 1",
@@ -4,4 +4,4 @@ export declare const BlockImageEntity: Entity<"BlockImage", z.ZodObject<{
4
4
  url: z.ZodString;
5
5
  }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
6
6
  parent: z.ZodTemplateLiteral<`Post/${number}`>;
7
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
7
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -4,4 +4,4 @@ export declare const BlockParagraph: Entity<"BlockParagraph", z.ZodObject<{
4
4
  content: z.ZodOptional<z.ZodString>;
5
5
  }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
6
6
  parent: z.ZodUnion<readonly [z.ZodType<`Post/${number}`, `Post/${number}`, z.core.$ZodTypeInternals<`Post/${number}`, `Post/${number}`>>, z.ZodUnion<readonly [z.ZodTemplateLiteral<`BlockParagraph/${number}`>, z.ZodTemplateLiteral<`BlockRow/${number}`>]>]>;
7
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
7
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -4,4 +4,4 @@ export declare const BlockRow: Entity<"BlockRow", z.ZodObject<{}, z.core.$strip>
4
4
  blocks: z.ZodArray<z.ZodUnion<readonly [z.ZodTemplateLiteral<`BlockParagraph/${number}`>, z.ZodTemplateLiteral<`BlockRow/${number}`>]>>;
5
5
  }, z.core.$strip>, z.ZodObject<{
6
6
  parent: z.ZodUnion<readonly [z.ZodType<`Post/${number}`, `Post/${number}`, z.core.$ZodTypeInternals<`Post/${number}`, `Post/${number}`>>, z.ZodUnion<readonly [z.ZodTemplateLiteral<`BlockParagraph/${number}`>, z.ZodTemplateLiteral<`BlockRow/${number}`>]>]>;
7
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
7
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -4,4 +4,5 @@ export declare const Draft: Entity<"Draft", z.ZodObject<{
4
4
  appliedAt: z.ZodOptional<z.ZodString>;
5
5
  }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
6
6
  post: z.ZodTemplateLiteral<`Post/${number}`>;
7
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
7
+ version: z.ZodOptional<z.ZodTemplateLiteral<`PostVersion/${number}`>>;
8
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -0,0 +1,10 @@
1
+ import { Entity } from "roc-db";
2
+ import { z } from "zod";
3
+ export declare const OrgSettingsEntity: Entity<"OrgSettings", z.ZodObject<{
4
+ name: z.ZodString;
5
+ theme: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>, z.ZodObject<{
7
+ featuredPosts: z.ZodArray<z.ZodString>;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ primaryAdmin: z.ZodOptional<z.ZodTemplateLiteral<`User/${number}`>>;
10
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, true>;
@@ -9,4 +9,4 @@ export declare const PostEntity: Entity<"Post", z.ZodObject<{
9
9
  blocks: z.ZodArray<z.ZodString>;
10
10
  }, z.core.$strip>, z.ZodObject<{
11
11
  author: z.ZodOptional<z.ZodTemplateLiteral<`User/${number}`>>;
12
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
12
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -5,4 +5,4 @@ export declare const PostVersion: Entity<"PostVersion", z.ZodObject<{
5
5
  snapshot: z.ZodArray<z.ZodAny>;
6
6
  }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
7
7
  post: z.ZodTemplateLiteral<`Post/${number}`>;
8
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
8
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -2,4 +2,4 @@ import { Entity } from "roc-db";
2
2
  import { z } from "zod";
3
3
  export declare const UserEntity: Entity<"User", z.ZodObject<{
4
4
  email: z.ZodString;
5
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
5
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, false>;
@@ -2,11 +2,12 @@ export declare const entities: (import("roc-db").Entity<"Draft", import("zod").Z
2
2
  appliedAt: import("zod").ZodOptional<import("zod").ZodString>;
3
3
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
4
4
  post: import("zod").ZodTemplateLiteral<`Post/${number}`>;
5
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>> | import("roc-db").Entity<"BlockImage", import("zod").ZodObject<{
5
+ version: import("zod").ZodOptional<import("zod").ZodTemplateLiteral<`PostVersion/${number}`>>;
6
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false> | import("roc-db").Entity<"BlockImage", import("zod").ZodObject<{
6
7
  url: import("zod").ZodString;
7
8
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
8
9
  parent: import("zod").ZodTemplateLiteral<`Post/${number}`>;
9
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>> | import("roc-db").Entity<"Post", import("zod").ZodObject<{
10
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false> | import("roc-db").Entity<"Post", import("zod").ZodObject<{
10
11
  title: import("zod").ZodString;
11
12
  text: import("zod").ZodOptional<import("zod").ZodString>;
12
13
  tags: import("zod").ZodArray<import("zod").ZodString>;
@@ -15,19 +16,26 @@ export declare const entities: (import("roc-db").Entity<"Draft", import("zod").Z
15
16
  blocks: import("zod").ZodArray<import("zod").ZodString>;
16
17
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
17
18
  author: import("zod").ZodOptional<import("zod").ZodTemplateLiteral<`User/${number}`>>;
18
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>> | import("roc-db").Entity<"BlockParagraph", import("zod").ZodObject<{
19
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false> | import("roc-db").Entity<"BlockParagraph", import("zod").ZodObject<{
19
20
  content: import("zod").ZodOptional<import("zod").ZodString>;
20
21
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
21
22
  parent: import("zod").ZodUnion<readonly [import("zod").ZodType<`Post/${number}`, `Post/${number}`, import("zod/v4/core").$ZodTypeInternals<`Post/${number}`, `Post/${number}`>>, import("zod").ZodUnion<readonly [import("zod").ZodTemplateLiteral<`BlockParagraph/${number}`>, import("zod").ZodTemplateLiteral<`BlockRow/${number}`>]>]>;
22
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>> | import("roc-db").Entity<"BlockRow", import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
23
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false> | import("roc-db").Entity<"BlockRow", import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
23
24
  blocks: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodTemplateLiteral<`BlockParagraph/${number}`>, import("zod").ZodTemplateLiteral<`BlockRow/${number}`>]>>;
24
25
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
25
26
  parent: import("zod").ZodUnion<readonly [import("zod").ZodType<`Post/${number}`, `Post/${number}`, import("zod/v4/core").$ZodTypeInternals<`Post/${number}`, `Post/${number}`>>, import("zod").ZodUnion<readonly [import("zod").ZodTemplateLiteral<`BlockParagraph/${number}`>, import("zod").ZodTemplateLiteral<`BlockRow/${number}`>]>]>;
26
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>> | import("roc-db").Entity<"PostVersion", import("zod").ZodObject<{
27
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false> | import("roc-db").Entity<"OrgSettings", import("zod").ZodObject<{
28
+ name: import("zod").ZodString;
29
+ theme: import("zod").ZodOptional<import("zod").ZodString>;
30
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
31
+ featuredPosts: import("zod").ZodArray<import("zod").ZodString>;
32
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
33
+ primaryAdmin: import("zod").ZodOptional<import("zod").ZodTemplateLiteral<`User/${number}`>>;
34
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, true> | import("roc-db").Entity<"PostVersion", import("zod").ZodObject<{
27
35
  version: import("zod").ZodNumber;
28
36
  snapshot: import("zod").ZodArray<import("zod").ZodAny>;
29
37
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
30
38
  post: import("zod").ZodTemplateLiteral<`Post/${number}`>;
31
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>> | import("roc-db").Entity<"User", import("zod").ZodObject<{
39
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false> | import("roc-db").Entity<"User", import("zod").ZodObject<{
32
40
  email: import("zod").ZodString;
33
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>>)[];
41
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{}, import("zod/v4/core").$strip>, false>)[];
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ export declare const createOrgSettings: import("roc-db").WriteOperation<"createOrgSettings", z.ZodObject<{
3
+ name: z.ZodString;
4
+ theme: z.ZodOptional<z.ZodString>;
5
+ primaryAdmin: z.ZodOptional<z.ZodTemplateLiteral<`User/${number}`>>;
6
+ }, z.core.$strip>>;
@@ -0,0 +1,2 @@
1
+ import { z } from "zod";
2
+ export declare const createUnknownRef: import("roc-db").WriteOperation<"createUnknownRef", z.ZodOptional<z.ZodObject<{}, z.core.$strip>>>;
@@ -0,0 +1,2 @@
1
+ import { z } from "zod";
2
+ export declare const deleteOrgSettings: import("roc-db").WriteOperation<"deleteOrgSettings", z.ZodOptional<z.ZodObject<{}, z.core.$strip>>>;
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Canonical consumer usage of the `txn.duplicateChangeSetMutations` primitive:
4
+ * create the new draft and copy the source draft's pending mutations into it,
5
+ * all in one transaction.
6
+ */
7
+ export declare const duplicateDraft: import("roc-db").WriteOperation<"duplicateDraft", z.ZodObject<{
8
+ sourceRef: z.ZodType<`Draft/${number}`, `Draft/${number}`, z.core.$ZodTypeInternals<`Draft/${number}`, `Draft/${number}`>>;
9
+ postRef: z.ZodTemplateLiteral<`Post/${number}`>;
10
+ }, z.core.$strict>>;
@@ -0,0 +1,2 @@
1
+ import { z } from "zod";
2
+ export declare const readOrgSettings: import("roc-db").ReadOperation<"readOrgSettings", z.ZodOptional<z.ZodObject<{}, z.core.$strip>>>;
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+ export declare const updateOrgSettingsName: import("roc-db").WriteOperation<"updateOrgSettingsName", z.ZodObject<{
3
+ name: z.ZodString;
4
+ }, z.core.$strip>>;
@@ -10,7 +10,7 @@ export declare const CreatePostMutationSchema: z.ZodObject<{
10
10
  name: z.ZodLiteral<"createPost">;
11
11
  version: z.ZodDefault<z.ZodNumber>;
12
12
  }, z.core.$strip>;
13
- changeSetRef: z.ZodTemplateLiteral<`${string}/${number}`> | z.ZodNullable<z.ZodTemplateLiteral<`${string}/${number}`>>;
13
+ changeSetRef: z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]> | z.ZodTemplateLiteral<never> | z.ZodNullable<z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]>> | z.ZodNullable<z.ZodTemplateLiteral<never>>;
14
14
  payload: z.ZodObject<{
15
15
  title: z.ZodString;
16
16
  slug: z.ZodOptional<z.ZodString>;
@@ -10,7 +10,7 @@ export declare const CreateUserMutationSchema: z.ZodObject<{
10
10
  name: z.ZodLiteral<"createUser">;
11
11
  version: z.ZodDefault<z.ZodNumber>;
12
12
  }, z.core.$strip>;
13
- changeSetRef: z.ZodTemplateLiteral<`${string}/${number}`> | z.ZodNullable<z.ZodTemplateLiteral<`${string}/${number}`>>;
13
+ changeSetRef: z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]> | z.ZodTemplateLiteral<never> | z.ZodNullable<z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]>> | z.ZodNullable<z.ZodTemplateLiteral<never>>;
14
14
  payload: z.ZodObject<{
15
15
  email: z.ZodString;
16
16
  }, z.core.$strip>;
@@ -0,0 +1 @@
1
+ export declare const PostVersionRefSchema: import("zod").ZodTemplateLiteral<`PostVersion/${number}`>;
@@ -10,7 +10,7 @@ export declare const UpdatePostMutationSchema: z.ZodObject<{
10
10
  name: z.ZodLiteral<"updatePost">;
11
11
  version: z.ZodDefault<z.ZodNumber>;
12
12
  }, z.core.$strip>;
13
- changeSetRef: z.ZodTemplateLiteral<`${string}/${number}`> | z.ZodNullable<z.ZodTemplateLiteral<`${string}/${number}`>>;
13
+ changeSetRef: z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]> | z.ZodTemplateLiteral<never> | z.ZodNullable<z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]>> | z.ZodNullable<z.ZodTemplateLiteral<never>>;
14
14
  payload: z.ZodObject<{
15
15
  ref: z.ZodTemplateLiteral<`Post/${number}`>;
16
16
  title: z.ZodOptional<z.ZodString>;
@@ -10,7 +10,7 @@ export declare const UpdatePostTitleMutationSchema: z.ZodObject<{
10
10
  name: z.ZodLiteral<"updatePostTitle">;
11
11
  version: z.ZodDefault<z.ZodNumber>;
12
12
  }, z.core.$strip>;
13
- changeSetRef: z.ZodTemplateLiteral<`${string}/${number}`> | z.ZodNullable<z.ZodTemplateLiteral<`${string}/${number}`>>;
13
+ changeSetRef: z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]> | z.ZodTemplateLiteral<never> | z.ZodNullable<z.ZodUnion<readonly [z.ZodTemplateLiteral<`${string}/${number}`>, z.ZodString]>> | z.ZodNullable<z.ZodTemplateLiteral<never>>;
14
14
  payload: z.ZodObject<{
15
15
  ref: z.ZodTemplateLiteral<`Post/${number}`>;
16
16
  title: z.ZodString;
@@ -0,0 +1,11 @@
1
+ import type { ZodSchema } from "zod";
2
+ interface CustomMatchers {
3
+ toMatchZodSchema(schema: ZodSchema): any;
4
+ }
5
+ declare module "bun:test" {
6
+ interface Matchers<T> extends CustomMatchers {
7
+ }
8
+ interface AsymmetricMatchers extends CustomMatchers {
9
+ }
10
+ }
11
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roc-db/test-utils",
3
- "version": "0.2.0-pre.97",
3
+ "version": "0.2.0-pre.99",
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.97",
20
+ "roc-db": ">=0.2.0-pre.98 <1.0.0",
21
21
  "zod": ">=4.0.0"
22
22
  },
23
23
  "keywords": [],
@@ -26,5 +26,9 @@
26
26
  "type": "git",
27
27
  "url": "git+https://github.com/eigilsagafos/roc-db.git"
28
28
  },
29
- "license": "MIT"
29
+ "license": "MIT",
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org/"
33
+ }
30
34
  }