@roc-db/test-utils 0.2.0-pre.12 → 0.2.0-pre.14
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
|
@@ -128,94 +128,108 @@ var entities = [
|
|
|
128
128
|
DraftSchema,
|
|
129
129
|
PostSchema
|
|
130
130
|
];
|
|
131
|
-
// src/operations/
|
|
131
|
+
// src/operations/applyDraft.ts
|
|
132
132
|
import { Query, writeOperation } from "roc-db";
|
|
133
133
|
|
|
134
|
-
// src/schemas/
|
|
134
|
+
// src/schemas/ApplyDraftMutationSchema.ts
|
|
135
135
|
import { mutationSchemaGenerator as mutationSchemaGenerator5 } from "roc-db";
|
|
136
136
|
import { z as z10 } from "zod";
|
|
137
|
-
var
|
|
137
|
+
var ApplyDraftMutationSchema = mutationSchemaGenerator5("applyDraft", z10.object({ ref: DraftRefSchema }).strict());
|
|
138
|
+
|
|
139
|
+
// src/operations/applyDraft.ts
|
|
140
|
+
var applyDraft = writeOperation(ApplyDraftMutationSchema, undefined, (txn) => {
|
|
141
|
+
const { ref } = txn.payload;
|
|
142
|
+
return Query(() => txn.applyChangeSet(ref));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// src/operations/createBlockImage.ts
|
|
146
|
+
import { Query as Query2, writeOperation as writeOperation2 } from "roc-db";
|
|
147
|
+
|
|
148
|
+
// src/schemas/CreateBlockImageMutationSchema.ts
|
|
149
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator6 } from "roc-db";
|
|
150
|
+
import { z as z11 } from "zod";
|
|
151
|
+
var CreateBlockImageMutationSchema = mutationSchemaGenerator6("createBlockImage", z11.object({ postRef: PostRefSchema }).strict(), undefined, true);
|
|
138
152
|
|
|
139
153
|
// src/operations/createBlockImage.ts
|
|
140
|
-
var createBlockImage =
|
|
154
|
+
var createBlockImage = writeOperation2(CreateBlockImageMutationSchema, BlockImageSchema, (txn) => {
|
|
141
155
|
const ref = txn.createRef("BlockImage");
|
|
142
156
|
const { postRef } = txn.payload;
|
|
143
|
-
return
|
|
157
|
+
return Query2(() => txn.createEntity(ref, { parents: { post: postRef } }));
|
|
144
158
|
}, { changeSetOnly: true });
|
|
145
159
|
|
|
146
160
|
// src/operations/createBlockParagraph.ts
|
|
147
|
-
import { Query as
|
|
161
|
+
import { Query as Query3, QueryChain, writeOperation as writeOperation3 } from "roc-db";
|
|
148
162
|
|
|
149
163
|
// src/schemas/CreateBlockParagraphMutationSchema.ts
|
|
150
|
-
import { mutationSchemaGenerator as
|
|
151
|
-
import { z as
|
|
164
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator7 } from "roc-db";
|
|
165
|
+
import { z as z12 } from "zod";
|
|
152
166
|
|
|
153
167
|
// src/schemas/BlockRowRefSchema.ts
|
|
154
168
|
import { refSchemaGenerator as refSchemaGenerator7 } from "roc-db";
|
|
155
169
|
var BlockRowRefSchema = refSchemaGenerator7("BlockRow");
|
|
156
170
|
|
|
157
171
|
// src/schemas/CreateBlockParagraphMutationSchema.ts
|
|
158
|
-
var CreateBlockParagraphMutationSchema =
|
|
172
|
+
var CreateBlockParagraphMutationSchema = mutationSchemaGenerator7("createBlockParagraph", z12.object({ parentRef: z12.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
|
|
159
173
|
|
|
160
174
|
// src/operations/createBlockParagraph.ts
|
|
161
|
-
var createBlockParagrah =
|
|
175
|
+
var createBlockParagrah = writeOperation3(CreateBlockParagraphMutationSchema, BlockParagraphSchema, (txn) => {
|
|
162
176
|
const ref = txn.createRef("BlockParagraph");
|
|
163
177
|
const { parentRef } = txn.payload;
|
|
164
|
-
return QueryChain(
|
|
178
|
+
return QueryChain(Query3(() => txn.readEntity(parentRef, true)), Query3((parent) => txn.patchEntity(parentRef, {
|
|
165
179
|
children: { blocks: [...parent.children.blocks, ref] }
|
|
166
|
-
})),
|
|
180
|
+
})), Query3(() => txn.createEntity(ref, { parents: { parent: parentRef } })), Query3((block, updatedParent) => ({ block, updatedParent })));
|
|
167
181
|
}, { changeSetOnly: true });
|
|
168
182
|
|
|
169
183
|
// src/operations/createBlockRow.ts
|
|
170
|
-
import { Query as
|
|
184
|
+
import { Query as Query4, QueryChain as QueryChain2, writeOperation as writeOperation4 } from "roc-db";
|
|
171
185
|
|
|
172
186
|
// src/schemas/CreateBlockRowMutationSchema.ts
|
|
173
|
-
import { mutationSchemaGenerator as
|
|
174
|
-
import { z as
|
|
175
|
-
var CreateBlockRowMutationSchema =
|
|
187
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator8 } from "roc-db";
|
|
188
|
+
import { z as z13 } from "zod";
|
|
189
|
+
var CreateBlockRowMutationSchema = mutationSchemaGenerator8("createBlockRow", z13.object({ parentRef: z13.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
|
|
176
190
|
|
|
177
191
|
// src/operations/createBlockRow.ts
|
|
178
|
-
var createBlockRow =
|
|
192
|
+
var createBlockRow = writeOperation4(CreateBlockRowMutationSchema, BlockParagraphSchema, (txn) => {
|
|
179
193
|
const ref = txn.createRef("BlockRow");
|
|
180
194
|
const { parentRef } = txn.payload;
|
|
181
|
-
return QueryChain2(
|
|
195
|
+
return QueryChain2(Query4(() => txn.readEntity(parentRef)), Query4((parent) => {
|
|
182
196
|
return txn.patchEntity(parentRef, {
|
|
183
197
|
children: { blocks: [...parent.children.blocks, ref] }
|
|
184
198
|
});
|
|
185
|
-
}),
|
|
199
|
+
}), Query4(() => txn.createEntity(ref, {
|
|
186
200
|
children: { blocks: [] },
|
|
187
201
|
parents: { parent: parentRef }
|
|
188
|
-
})),
|
|
202
|
+
})), Query4((block, updatedParent) => ({ block, updatedParent })));
|
|
189
203
|
}, { changeSetOnly: true });
|
|
190
204
|
|
|
191
205
|
// src/operations/createBlockTitle.ts
|
|
192
|
-
import { Query as
|
|
206
|
+
import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
|
|
193
207
|
|
|
194
208
|
// src/schemas/CreateBlockTitleMutationSchema.ts
|
|
195
|
-
import { mutationSchemaGenerator as
|
|
196
|
-
import { z as
|
|
197
|
-
var CreateBlockTitleMutationSchema =
|
|
209
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator9 } from "roc-db";
|
|
210
|
+
import { z as z14 } from "zod";
|
|
211
|
+
var CreateBlockTitleMutationSchema = mutationSchemaGenerator9("createBlockTitle", z14.object({ parentRef: z14.union([PostRefSchema, BlockRowRefSchema]) }).strict(), undefined, true);
|
|
198
212
|
|
|
199
213
|
// src/operations/createBlockTitle.ts
|
|
200
|
-
var createBlockTitle =
|
|
214
|
+
var createBlockTitle = writeOperation5(CreateBlockTitleMutationSchema, BlockTitleSchema, (txn) => {
|
|
201
215
|
const ref = txn.createRef("BlockTitle");
|
|
202
216
|
const { postRef } = txn.payload;
|
|
203
|
-
return
|
|
217
|
+
return Query5(() => txn.createEntity(ref, { parents: { post: postRef } }));
|
|
204
218
|
}, { changeSetOnly: true });
|
|
205
219
|
|
|
206
220
|
// src/operations/createDraft.ts
|
|
207
|
-
import { Query as
|
|
221
|
+
import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
|
|
208
222
|
|
|
209
223
|
// src/schemas/CreateDraftMutationSchema.ts
|
|
210
|
-
import { mutationSchemaGenerator as
|
|
211
|
-
import { z as
|
|
212
|
-
var CreateDraftMutationSchema =
|
|
224
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator10 } from "roc-db";
|
|
225
|
+
import { z as z15 } from "zod";
|
|
226
|
+
var CreateDraftMutationSchema = mutationSchemaGenerator10("createDraft", z15.object({ postRef: PostRefSchema }).strict());
|
|
213
227
|
|
|
214
228
|
// src/operations/createDraft.ts
|
|
215
|
-
var createDraft =
|
|
229
|
+
var createDraft = writeOperation6(CreateDraftMutationSchema, DraftSchema, (txn) => {
|
|
216
230
|
const ref = txn.createRef("Draft");
|
|
217
231
|
const { postRef } = txn.payload;
|
|
218
|
-
return
|
|
232
|
+
return Query6(() => txn.createEntity(ref, {
|
|
219
233
|
parents: {
|
|
220
234
|
post: postRef
|
|
221
235
|
}
|
|
@@ -223,57 +237,57 @@ var createDraft = writeOperation5(CreateDraftMutationSchema, DraftSchema, (txn)
|
|
|
223
237
|
});
|
|
224
238
|
|
|
225
239
|
// src/operations/createPost.ts
|
|
226
|
-
import { Query as
|
|
227
|
-
var createPost =
|
|
240
|
+
import { Query as Query7, writeOperation as writeOperation7 } from "roc-db";
|
|
241
|
+
var createPost = writeOperation7(CreatePostMutationSchema, PostSchema, (txn) => {
|
|
228
242
|
const ref = txn.createRef("Post");
|
|
229
243
|
const { title, slug, tags } = txn.payload;
|
|
230
|
-
return
|
|
244
|
+
return Query7(() => txn.createEntity(ref, {
|
|
231
245
|
data: { title, tags, slug },
|
|
232
246
|
children: { blocks: [] }
|
|
233
247
|
}));
|
|
234
248
|
});
|
|
235
249
|
|
|
236
250
|
// src/operations/deleteBlock.ts
|
|
237
|
-
import { Query as
|
|
251
|
+
import { Query as Query8, QueryChain as QueryChain3, writeOperation as writeOperation8 } from "roc-db";
|
|
238
252
|
|
|
239
253
|
// src/schemas/DeleteBlockMutationSchema.ts
|
|
240
|
-
import { mutationSchemaGenerator as
|
|
241
|
-
import { z as
|
|
242
|
-
var DeleteBlockMutationSchema =
|
|
254
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator11 } from "roc-db";
|
|
255
|
+
import { z as z16 } from "zod";
|
|
256
|
+
var DeleteBlockMutationSchema = mutationSchemaGenerator11("deleteBlock", z16.union([BlockParagraphRefSchema, BlockImageRefSchema]));
|
|
243
257
|
|
|
244
258
|
// src/operations/deleteBlock.ts
|
|
245
|
-
var deleteBlock =
|
|
259
|
+
var deleteBlock = writeOperation8(DeleteBlockMutationSchema, PostSchema, (txn) => {
|
|
246
260
|
const blockRef = txn.payload;
|
|
247
|
-
return QueryChain3(
|
|
261
|
+
return QueryChain3(Query8(() => txn.readEntity(blockRef, true)), Query8((block) => txn.readEntity(block.parents.post, true)), Query8((post) => {
|
|
248
262
|
return txn.patchEntity(post.ref, {
|
|
249
263
|
data: {
|
|
250
264
|
blockRefs: post.data.blockRefs.filter((ref) => ref !== blockRef)
|
|
251
265
|
}
|
|
252
266
|
});
|
|
253
|
-
}),
|
|
267
|
+
}), Query8(() => txn.deleteEntity(blockRef)), Query8((_, updatedPost) => {
|
|
254
268
|
return updatedPost;
|
|
255
269
|
}));
|
|
256
270
|
}, { changeSetOnly: true });
|
|
257
271
|
|
|
258
272
|
// src/operations/deletePost.ts
|
|
259
|
-
import { Query as
|
|
273
|
+
import { Query as Query9, writeOperation as writeOperation9 } from "roc-db";
|
|
260
274
|
|
|
261
275
|
// src/schemas/DeletePostMutationSchema.ts
|
|
262
|
-
import { mutationSchemaGenerator as
|
|
263
|
-
var DeletePostMutationSchema =
|
|
276
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator12 } from "roc-db";
|
|
277
|
+
var DeletePostMutationSchema = mutationSchemaGenerator12("deletePost", PostRefSchema);
|
|
264
278
|
|
|
265
279
|
// src/operations/deletePost.ts
|
|
266
|
-
var deletePost =
|
|
280
|
+
var deletePost = writeOperation9(DeletePostMutationSchema, undefined, (txn) => {
|
|
267
281
|
const ref = txn.payload;
|
|
268
|
-
return
|
|
282
|
+
return Query9(() => txn.deleteEntity(ref, true));
|
|
269
283
|
});
|
|
270
284
|
|
|
271
285
|
// src/operations/readEntity.ts
|
|
272
|
-
import { NotFoundError, Query as
|
|
273
|
-
import { z as
|
|
274
|
-
var readEntity = readOperation("readEntity",
|
|
286
|
+
import { NotFoundError, Query as Query10, QueryChain as QueryChain4, readOperation } from "roc-db";
|
|
287
|
+
import { z as z17 } from "zod";
|
|
288
|
+
var readEntity = readOperation("readEntity", z17.string(), z17.union([PostSchema, BlockImageSchema, BlockParagraphSchema]), (txn) => {
|
|
275
289
|
const ref = txn.payload;
|
|
276
|
-
return QueryChain4(
|
|
290
|
+
return QueryChain4(Query10(() => txn.readEntity(ref)), Query10((entity) => {
|
|
277
291
|
if (!entity) {
|
|
278
292
|
throw new NotFoundError(ref);
|
|
279
293
|
}
|
|
@@ -282,36 +296,36 @@ var readEntity = readOperation("readEntity", z16.string(), z16.union([PostSchema
|
|
|
282
296
|
});
|
|
283
297
|
|
|
284
298
|
// src/operations/readPost.ts
|
|
285
|
-
import { Query as
|
|
299
|
+
import { Query as Query11, readOperation as readOperation2 } from "roc-db";
|
|
286
300
|
var readPost = readOperation2("readPost", PostRefSchema, PostSchema, (txn) => {
|
|
287
301
|
const ref = txn.payload;
|
|
288
|
-
return
|
|
302
|
+
return Query11(() => txn.readEntity(ref));
|
|
289
303
|
});
|
|
290
304
|
|
|
291
305
|
// src/operations/updateBlockParagraph.ts
|
|
292
|
-
import { Query as
|
|
306
|
+
import { Query as Query12, writeOperation as writeOperation10 } from "roc-db";
|
|
293
307
|
|
|
294
308
|
// src/schemas/UpdateBlockParagraphMutationSchema.ts
|
|
295
|
-
import { mutationSchemaGenerator as
|
|
296
|
-
import { z as
|
|
297
|
-
var UpdateBlockParagraphMutationSchema =
|
|
309
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator13 } from "roc-db";
|
|
310
|
+
import { z as z18 } from "zod";
|
|
311
|
+
var UpdateBlockParagraphMutationSchema = mutationSchemaGenerator13("updateBlockParagraph", z18.object({
|
|
298
312
|
ref: BlockParagraphRefSchema,
|
|
299
|
-
content:
|
|
313
|
+
content: z18.string()
|
|
300
314
|
}));
|
|
301
315
|
|
|
302
316
|
// src/operations/updateBlockParagraph.ts
|
|
303
|
-
var updateBlockParagraph =
|
|
317
|
+
var updateBlockParagraph = writeOperation10(UpdateBlockParagraphMutationSchema, BlockParagraphRefSchema, (txn) => {
|
|
304
318
|
const { ref, content } = txn.payload;
|
|
305
|
-
return
|
|
319
|
+
return Query12(() => txn.patchEntity(ref, {
|
|
306
320
|
data: { content }
|
|
307
321
|
}));
|
|
308
322
|
});
|
|
309
323
|
|
|
310
324
|
// src/operations/updatePost.ts
|
|
311
|
-
import { Query as
|
|
312
|
-
var updatePost =
|
|
325
|
+
import { Query as Query13, writeOperation as writeOperation11 } from "roc-db";
|
|
326
|
+
var updatePost = writeOperation11(UpdatePostMutationSchema, PostSchema, (txn) => {
|
|
313
327
|
const { ref, authorRef, ...data } = txn.payload;
|
|
314
|
-
return
|
|
328
|
+
return Query13(() => txn.updateEntity(ref, {
|
|
315
329
|
data,
|
|
316
330
|
parents: { author: authorRef },
|
|
317
331
|
children: { blocks: [] }
|
|
@@ -319,14 +333,15 @@ var updatePost = writeOperation10(UpdatePostMutationSchema, PostSchema, (txn) =>
|
|
|
319
333
|
});
|
|
320
334
|
|
|
321
335
|
// src/operations/updatePostTitle.ts
|
|
322
|
-
import { Query as
|
|
323
|
-
var updatePostTitle =
|
|
336
|
+
import { Query as Query14, writeOperation as writeOperation12 } from "roc-db";
|
|
337
|
+
var updatePostTitle = writeOperation12(UpdatePostTitleMutationSchema, PostSchema, (txn) => {
|
|
324
338
|
const { ref, title } = txn.payload;
|
|
325
|
-
return
|
|
339
|
+
return Query14(() => txn.patchEntity(ref, { data: { title } }));
|
|
326
340
|
}, { debounce: 10 });
|
|
327
341
|
|
|
328
342
|
// src/operations/index.ts
|
|
329
343
|
var operations = [
|
|
344
|
+
applyDraft,
|
|
330
345
|
createBlockImage,
|
|
331
346
|
createBlockTitle,
|
|
332
347
|
createBlockParagrah,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const applyDraft: import("roc-db").WriteOperation<"applyDraft", {
|
|
2
|
+
ref: `Mutation/${string}`;
|
|
3
|
+
timestamp: string;
|
|
4
|
+
changeSetRef: null;
|
|
5
|
+
payload: {
|
|
6
|
+
ref: `Draft/${string}`;
|
|
7
|
+
};
|
|
8
|
+
log: [never, string, null][];
|
|
9
|
+
debounceCount: number;
|
|
10
|
+
name: "applyDraft";
|
|
11
|
+
}, {
|
|
12
|
+
ref: `Draft/${string}`;
|
|
13
|
+
}, any>;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
export declare const operations: readonly [import("roc-db").WriteOperation<"
|
|
1
|
+
export declare const operations: readonly [import("roc-db").WriteOperation<"applyDraft", {
|
|
2
|
+
ref: `Mutation/${string}`;
|
|
3
|
+
timestamp: string;
|
|
4
|
+
changeSetRef: null;
|
|
5
|
+
payload: {
|
|
6
|
+
ref: `Draft/${string}`;
|
|
7
|
+
};
|
|
8
|
+
log: [never, string, null][];
|
|
9
|
+
debounceCount: number;
|
|
10
|
+
name: "applyDraft";
|
|
11
|
+
}, {
|
|
12
|
+
ref: `Draft/${string}`;
|
|
13
|
+
}, any>, import("roc-db").WriteOperation<"createBlockImage", {
|
|
2
14
|
ref: `Mutation/${string}`;
|
|
3
15
|
timestamp: string;
|
|
4
16
|
changeSetRef: null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ApplyDraftMutationSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
ref: z.ZodType<`Mutation/${string}`, z.ZodTypeDef, `Mutation/${string}`>;
|
|
4
|
+
timestamp: z.ZodString;
|
|
5
|
+
changeSetRef: z.ZodNullable<z.ZodType<never, z.ZodTypeDef, never>>;
|
|
6
|
+
payload: z.ZodAny;
|
|
7
|
+
log: z.ZodArray<z.ZodTuple<[z.ZodType<never, z.ZodTypeDef, never>, z.ZodString, z.ZodNullable<z.ZodType<never, z.ZodTypeDef, never>>], null>, "many">;
|
|
8
|
+
debounceCount: z.ZodNumber;
|
|
9
|
+
}, {
|
|
10
|
+
name: z.ZodLiteral<"applyDraft">;
|
|
11
|
+
changeSetRef: z.ZodType<never, z.ZodTypeDef, never> | z.ZodNullable<z.ZodType<never, z.ZodTypeDef, never>>;
|
|
12
|
+
payload: z.ZodObject<{
|
|
13
|
+
ref: z.ZodType<`Draft/${string}`, z.ZodTypeDef, `Draft/${string}`>;
|
|
14
|
+
}, "strict", z.ZodTypeAny, {
|
|
15
|
+
ref: `Draft/${string}`;
|
|
16
|
+
}, {
|
|
17
|
+
ref: `Draft/${string}`;
|
|
18
|
+
}>;
|
|
19
|
+
log: z.ZodType<[never, string, null][], z.ZodTypeDef, [never, string, null][]>;
|
|
20
|
+
}>, "strict", z.ZodTypeAny, {
|
|
21
|
+
ref: `Mutation/${string}`;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
changeSetRef: null;
|
|
24
|
+
payload: {
|
|
25
|
+
ref: `Draft/${string}`;
|
|
26
|
+
};
|
|
27
|
+
log: [never, string, null][];
|
|
28
|
+
debounceCount: number;
|
|
29
|
+
name: "applyDraft";
|
|
30
|
+
}, {
|
|
31
|
+
ref: `Mutation/${string}`;
|
|
32
|
+
timestamp: string;
|
|
33
|
+
changeSetRef: null;
|
|
34
|
+
payload: {
|
|
35
|
+
ref: `Draft/${string}`;
|
|
36
|
+
};
|
|
37
|
+
log: [never, string, null][];
|
|
38
|
+
debounceCount: number;
|
|
39
|
+
name: "applyDraft";
|
|
40
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roc-db/test-utils",
|
|
3
|
-
"version": "0.2.0-pre.
|
|
3
|
+
"version": "0.2.0-pre.14",
|
|
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.
|
|
20
|
+
"roc-db": "0.2.0-pre.14",
|
|
21
21
|
"zod": "3.24.2"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [],
|