@roc-db/test-utils 0.2.0-pre.25 → 0.2.0-pre.26
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
|
@@ -339,11 +339,25 @@ var updatePost = writeOperation11(UpdatePostMutationSchema, PostSchema, (txn) =>
|
|
|
339
339
|
}));
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
-
// src/operations/
|
|
342
|
+
// src/operations/updatePostDescription.ts
|
|
343
343
|
import { Query as Query14, writeOperation as writeOperation12 } from "roc-db";
|
|
344
|
-
|
|
344
|
+
|
|
345
|
+
// src/schemas/UpdatePostDescriptionMutationSchema.ts
|
|
346
|
+
import { mutationSchemaGenerator as mutationSchemaGenerator14 } from "roc-db";
|
|
347
|
+
import { z as z19 } from "zod";
|
|
348
|
+
var UpdatePostDescriptionMutationSchema = mutationSchemaGenerator14("updatePostDescription", z19.object({ ref: PostRefSchema, description: z19.string() }));
|
|
349
|
+
|
|
350
|
+
// src/operations/updatePostDescription.ts
|
|
351
|
+
var updatePostDescription = writeOperation12(UpdatePostDescriptionMutationSchema, PostSchema, (txn) => {
|
|
352
|
+
const { ref, description } = txn.payload;
|
|
353
|
+
return Query14(() => txn.patchEntity(ref, { data: { description } }));
|
|
354
|
+
}, { debounce: 10, changeSetOnly: true });
|
|
355
|
+
|
|
356
|
+
// src/operations/updatePostTitle.ts
|
|
357
|
+
import { Query as Query15, writeOperation as writeOperation13 } from "roc-db";
|
|
358
|
+
var updatePostTitle = writeOperation13(UpdatePostTitleMutationSchema, PostSchema, (txn) => {
|
|
345
359
|
const { ref, title } = txn.payload;
|
|
346
|
-
return
|
|
360
|
+
return Query15(() => txn.patchEntity(ref, { data: { title } }));
|
|
347
361
|
}, { debounce: 10 });
|
|
348
362
|
|
|
349
363
|
// src/operations/index.ts
|
|
@@ -361,6 +375,7 @@ var operations = [
|
|
|
361
375
|
readPost,
|
|
362
376
|
updateBlockParagraph,
|
|
363
377
|
updatePost,
|
|
378
|
+
updatePostDescription,
|
|
364
379
|
updatePostTitle
|
|
365
380
|
];
|
|
366
381
|
// src/testAdapterImplementation.ts
|
|
@@ -464,6 +479,12 @@ var testAdapterImplementation = (adapterConstructor, engineArgsAdapter1 = {}, en
|
|
|
464
479
|
expect(mutation1.ref).toBe(mutation2.ref);
|
|
465
480
|
expect(mutation2.timestamp >= mutation1.timestamp).toBeTrue();
|
|
466
481
|
});
|
|
482
|
+
test("updatePostDescription without changeSetAdapter fails with BadRequestError", async () => {
|
|
483
|
+
expect(() => adapter1.updatePostDescription({
|
|
484
|
+
ref: postRef,
|
|
485
|
+
description: "Description 1"
|
|
486
|
+
})).toThrow(BadRequestError);
|
|
487
|
+
});
|
|
467
488
|
test("delete (deleteEntity function)", async () => {
|
|
468
489
|
const [count, mutation] = await adapter1.deletePost(postRef);
|
|
469
490
|
expect(count).toBe(1);
|
|
@@ -172,6 +172,24 @@ export declare const operations: readonly [import("roc-db").WriteOperation<"appl
|
|
|
172
172
|
authorRef?: `User/${string}` | undefined;
|
|
173
173
|
}, {
|
|
174
174
|
[x: string]: any;
|
|
175
|
+
}>, import("roc-db").WriteOperation<"updatePostDescription", {
|
|
176
|
+
ref: `Mutation/${string}`;
|
|
177
|
+
timestamp: string;
|
|
178
|
+
changeSetRef: null;
|
|
179
|
+
payload: {
|
|
180
|
+
ref: `Post/${string}`;
|
|
181
|
+
description: string;
|
|
182
|
+
};
|
|
183
|
+
log: [never, string, null][];
|
|
184
|
+
debounceCount: number;
|
|
185
|
+
identityRef: string;
|
|
186
|
+
name: "updatePostDescription";
|
|
187
|
+
sessionRef?: string | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
ref: `Post/${string}`;
|
|
190
|
+
description: string;
|
|
191
|
+
}, {
|
|
192
|
+
[x: string]: any;
|
|
175
193
|
}>, import("roc-db").WriteOperation<"updatePostTitle", {
|
|
176
194
|
ref: `Mutation/${string}`;
|
|
177
195
|
timestamp: string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const updatePostDescription: import("roc-db").WriteOperation<"updatePostDescription", {
|
|
2
|
+
ref: `Mutation/${string}`;
|
|
3
|
+
timestamp: string;
|
|
4
|
+
changeSetRef: null;
|
|
5
|
+
payload: {
|
|
6
|
+
ref: `Post/${string}`;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
log: [never, string, null][];
|
|
10
|
+
debounceCount: number;
|
|
11
|
+
identityRef: string;
|
|
12
|
+
name: "updatePostDescription";
|
|
13
|
+
sessionRef?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
ref: `Post/${string}`;
|
|
16
|
+
description: string;
|
|
17
|
+
}, {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const UpdatePostDescriptionMutationSchema: 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
|
+
identityRef: z.ZodString;
|
|
10
|
+
sessionRef: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, {
|
|
12
|
+
name: z.ZodLiteral<"updatePostDescription">;
|
|
13
|
+
changeSetRef: z.ZodType<never, z.ZodTypeDef, never> | z.ZodNullable<z.ZodType<never, z.ZodTypeDef, never>>;
|
|
14
|
+
payload: z.ZodObject<{
|
|
15
|
+
ref: z.ZodType<`Post/${string}`, z.ZodTypeDef, `Post/${string}`>;
|
|
16
|
+
description: z.ZodString;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
ref: `Post/${string}`;
|
|
19
|
+
description: string;
|
|
20
|
+
}, {
|
|
21
|
+
ref: `Post/${string}`;
|
|
22
|
+
description: string;
|
|
23
|
+
}>;
|
|
24
|
+
log: z.ZodType<[never, string, null][], z.ZodTypeDef, [never, string, null][]>;
|
|
25
|
+
}>, "strict", z.ZodTypeAny, {
|
|
26
|
+
ref: `Mutation/${string}`;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
changeSetRef: null;
|
|
29
|
+
payload: {
|
|
30
|
+
ref: `Post/${string}`;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
log: [never, string, null][];
|
|
34
|
+
debounceCount: number;
|
|
35
|
+
identityRef: string;
|
|
36
|
+
name: "updatePostDescription";
|
|
37
|
+
sessionRef?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
ref: `Mutation/${string}`;
|
|
40
|
+
timestamp: string;
|
|
41
|
+
changeSetRef: null;
|
|
42
|
+
payload: {
|
|
43
|
+
ref: `Post/${string}`;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
log: [never, string, null][];
|
|
47
|
+
debounceCount: number;
|
|
48
|
+
identityRef: string;
|
|
49
|
+
name: "updatePostDescription";
|
|
50
|
+
sessionRef?: string | undefined;
|
|
51
|
+
}>;
|
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.26",
|
|
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.26",
|
|
21
21
|
"zod": "3.24.2"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [],
|