@roc-db/test-utils 0.2.0-pre.50 → 0.2.0-pre.52
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 +298 -171
- package/dist/types/entities/BlockParagraph.d.ts +15 -0
- package/dist/types/entities/BlockRow.d.ts +15 -0
- package/dist/types/entities/Draft.d.ts +15 -0
- package/dist/types/entities/PostEntity.d.ts +30 -0
- package/dist/types/entities/PostVersion.d.ts +18 -0
- package/dist/types/entities/index.d.ts +79 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/operations/index.d.ts +20 -2
- package/dist/types/operations/pagePostsByTag.d.ts +1 -0
- package/dist/types/operations/readPostBySlug.d.ts +1 -0
- package/dist/types/operations/updatePostSlug.d.ts +11 -0
- package/dist/types/operations/updatePostTags.d.ts +11 -0
- package/dist/types/schemas/CreatePostMutationSchema.d.ts +2 -2
- package/dist/types/schemas/CreateUserMutationSchema.d.ts +2 -2
- package/dist/types/schemas/UpdatePostMutationSchema.d.ts +2 -2
- package/dist/types/schemas/UpdatePostTitleMutationSchema.d.ts +2 -2
- package/dist/types/schemas/index.d.ts +0 -565
- package/package.json +2 -2
- package/dist/types/schemas/PostVersionRefSchema.d.ts +0 -1
- package/dist/types/schemas/PostVersionSchema.d.ts +0 -85
package/dist/index.js
CHANGED
|
@@ -40,140 +40,172 @@ var BlockParagraphSchema = entitySchemaGenerator2("BlockParagraph", {
|
|
|
40
40
|
})
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// src/schemas/
|
|
43
|
+
// src/schemas/BlockTitleSchema.ts
|
|
44
44
|
import { entitySchemaGenerator as entitySchemaGenerator3 } from "roc-db";
|
|
45
|
-
import { z as
|
|
45
|
+
import { z as z3 } from "zod";
|
|
46
46
|
|
|
47
|
-
// src/schemas/
|
|
47
|
+
// src/schemas/BlockTitleRefSchema.ts
|
|
48
48
|
import { refSchemaGenerator as refSchemaGenerator4 } from "roc-db";
|
|
49
|
-
var
|
|
49
|
+
var BlockTitleRefSchema = refSchemaGenerator4("BlockTitle");
|
|
50
50
|
|
|
51
|
-
// src/schemas/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
|
-
// src/schemas/BlockRowSchema.ts
|
|
59
|
-
var BlockRowSchema = entitySchemaGenerator3("BlockRow", {
|
|
60
|
-
ref: BlockRowRefSchema,
|
|
61
|
-
children: z4.object({
|
|
62
|
-
blocks: z4.array(BlockRefSchema)
|
|
51
|
+
// src/schemas/BlockTitleSchema.ts
|
|
52
|
+
var BlockTitleSchema = entitySchemaGenerator3("BlockTitle", {
|
|
53
|
+
ref: BlockTitleRefSchema,
|
|
54
|
+
data: z3.object({
|
|
55
|
+
content: z3.string()
|
|
63
56
|
}),
|
|
64
|
-
parents:
|
|
65
|
-
post: PostRefSchema
|
|
66
|
-
block: BlockRefSchema
|
|
57
|
+
parents: z3.object({
|
|
58
|
+
post: PostRefSchema
|
|
67
59
|
})
|
|
68
60
|
});
|
|
69
61
|
|
|
70
|
-
// src/schemas/
|
|
62
|
+
// src/schemas/DraftSchema.ts
|
|
71
63
|
import { entitySchemaGenerator as entitySchemaGenerator4 } from "roc-db";
|
|
72
64
|
import { z as z5 } from "zod";
|
|
73
65
|
|
|
74
|
-
// src/
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
ref: BlockTitleRefSchema,
|
|
81
|
-
data: z5.object({
|
|
82
|
-
content: z5.string()
|
|
66
|
+
// src/entities/Draft.ts
|
|
67
|
+
import { Entity } from "roc-db";
|
|
68
|
+
import { z as z4 } from "zod";
|
|
69
|
+
var Draft = new Entity("Draft", {
|
|
70
|
+
data: z4.object({
|
|
71
|
+
appliedAt: z4.string().optional()
|
|
83
72
|
}),
|
|
84
|
-
parents:
|
|
73
|
+
parents: z4.object({
|
|
85
74
|
post: PostRefSchema
|
|
86
75
|
})
|
|
87
76
|
});
|
|
88
77
|
|
|
89
|
-
// src/schemas/DraftSchema.ts
|
|
90
|
-
import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
|
|
91
|
-
import { z as z6 } from "zod";
|
|
92
|
-
|
|
93
78
|
// src/schemas/DraftRefSchema.ts
|
|
94
|
-
|
|
95
|
-
var DraftRefSchema = refSchemaGenerator6("Draft");
|
|
79
|
+
var DraftRefSchema = Draft.refSchema;
|
|
96
80
|
|
|
97
81
|
// src/schemas/DraftSchema.ts
|
|
98
|
-
var DraftSchema =
|
|
82
|
+
var DraftSchema = entitySchemaGenerator4("Draft", {
|
|
99
83
|
ref: DraftRefSchema,
|
|
100
|
-
parents:
|
|
84
|
+
parents: z5.object({
|
|
101
85
|
post: PostRefSchema
|
|
102
86
|
})
|
|
103
87
|
});
|
|
104
88
|
|
|
105
89
|
// src/schemas/PostSchema.ts
|
|
106
|
-
import { entitySchemaGenerator as
|
|
107
|
-
import { z as
|
|
90
|
+
import { entitySchemaGenerator as entitySchemaGenerator5 } from "roc-db";
|
|
91
|
+
import { z as z6 } from "zod";
|
|
108
92
|
|
|
109
93
|
// src/schemas/UserRefSchema.ts
|
|
110
|
-
import { refSchemaGenerator as
|
|
111
|
-
var UserRefSchema =
|
|
94
|
+
import { refSchemaGenerator as refSchemaGenerator5 } from "roc-db";
|
|
95
|
+
var UserRefSchema = refSchemaGenerator5("User");
|
|
112
96
|
|
|
113
97
|
// src/schemas/PostSchema.ts
|
|
114
|
-
var PostSchema =
|
|
98
|
+
var PostSchema = entitySchemaGenerator5("Post", {
|
|
115
99
|
ref: PostRefSchema,
|
|
116
|
-
data:
|
|
117
|
-
title:
|
|
118
|
-
text:
|
|
119
|
-
tags:
|
|
120
|
-
slug:
|
|
100
|
+
data: z6.object({
|
|
101
|
+
title: z6.string(),
|
|
102
|
+
text: z6.string().optional(),
|
|
103
|
+
tags: z6.array(z6.string()),
|
|
104
|
+
slug: z6.string().optional()
|
|
121
105
|
}),
|
|
122
|
-
parents:
|
|
123
|
-
children:
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// src/schemas/PostVersionSchema.ts
|
|
127
|
-
import { entitySchemaGenerator as entitySchemaGenerator7 } from "roc-db";
|
|
128
|
-
import { z as z8 } from "zod";
|
|
129
|
-
|
|
130
|
-
// src/schemas/PostVersionRefSchema.ts
|
|
131
|
-
import { refSchemaGenerator as refSchemaGenerator8 } from "roc-db";
|
|
132
|
-
var PostVersionRefSchema = refSchemaGenerator8("PostVersion");
|
|
133
|
-
|
|
134
|
-
// src/schemas/PostVersionSchema.ts
|
|
135
|
-
var PostVersionSchema = entitySchemaGenerator7("PostVersion", {
|
|
136
|
-
ref: PostVersionRefSchema,
|
|
137
|
-
data: z8.object({
|
|
138
|
-
version: z8.number(),
|
|
139
|
-
snapshot: z8.array(z8.any())
|
|
140
|
-
}),
|
|
141
|
-
parents: z8.object({ post: PostRefSchema })
|
|
106
|
+
parents: z6.object({ author: UserRefSchema.optional() }),
|
|
107
|
+
children: z6.object({ blocks: z6.array(z6.string()) })
|
|
142
108
|
});
|
|
143
109
|
// src/schemas/CreatePostMutationSchema.ts
|
|
144
110
|
import { mutationSchemaGenerator } from "roc-db";
|
|
145
|
-
import { z as
|
|
146
|
-
var CreatePostMutationSchema = mutationSchemaGenerator("createPost",
|
|
147
|
-
title:
|
|
148
|
-
slug:
|
|
149
|
-
tags:
|
|
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([])
|
|
150
116
|
}).strict());
|
|
151
117
|
// src/schemas/CreateUserMutationSchema.ts
|
|
152
118
|
import { mutationSchemaGenerator as mutationSchemaGenerator2 } from "roc-db";
|
|
153
|
-
import { z as
|
|
154
|
-
var CreateUserMutationSchema = mutationSchemaGenerator2("createUser",
|
|
119
|
+
import { z as z8 } from "zod";
|
|
120
|
+
var CreateUserMutationSchema = mutationSchemaGenerator2("createUser", z8.object({ email: z8.string() }));
|
|
155
121
|
// src/schemas/UpdatePostMutationSchema.ts
|
|
156
122
|
import { mutationSchemaGenerator as mutationSchemaGenerator3 } from "roc-db";
|
|
157
|
-
import { z as
|
|
158
|
-
var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost",
|
|
123
|
+
import { z as z9 } from "zod";
|
|
124
|
+
var UpdatePostMutationSchema = mutationSchemaGenerator3("updatePost", z9.object({
|
|
159
125
|
ref: PostRefSchema,
|
|
160
|
-
title:
|
|
161
|
-
tags:
|
|
126
|
+
title: z9.string().optional(),
|
|
127
|
+
tags: z9.array(z9.string()).optional().default([]),
|
|
162
128
|
authorRef: UserRefSchema.optional()
|
|
163
129
|
}));
|
|
164
130
|
// src/schemas/UpdatePostTitleMutationSchema.ts
|
|
165
131
|
import { mutationSchemaGenerator as mutationSchemaGenerator4 } from "roc-db";
|
|
132
|
+
import { z as z10 } from "zod";
|
|
133
|
+
var UpdatePostTitleMutationSchema = mutationSchemaGenerator4("updatePostTitle", z10.object({ ref: PostRefSchema, title: z10.string() }));
|
|
134
|
+
// src/entities/BlockParagraph.ts
|
|
135
|
+
import { Entity as Entity3 } from "roc-db";
|
|
136
|
+
import { z as z13 } from "zod";
|
|
137
|
+
|
|
138
|
+
// src/entities/PostEntity.ts
|
|
139
|
+
import { Entity as Entity2 } from "roc-db";
|
|
140
|
+
import { z as z11 } from "zod";
|
|
141
|
+
var PostEntity = new Entity2("Post", {
|
|
142
|
+
data: z11.object({
|
|
143
|
+
title: z11.string(),
|
|
144
|
+
text: z11.string().optional(),
|
|
145
|
+
tags: z11.array(z11.string()),
|
|
146
|
+
slug: z11.string().optional()
|
|
147
|
+
}),
|
|
148
|
+
parents: z11.object({ author: UserRefSchema.optional() }),
|
|
149
|
+
children: z11.object({ blocks: z11.array(z11.string()) }),
|
|
150
|
+
indexedDataKeys: ["tags", "slug"],
|
|
151
|
+
uniqueDataKeys: ["slug"]
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// src/schemas/BlockRefSchema.ts
|
|
166
155
|
import { z as z12 } from "zod";
|
|
167
|
-
|
|
168
|
-
// src/schemas/
|
|
156
|
+
|
|
157
|
+
// src/schemas/BlockRowRefSchema.ts
|
|
158
|
+
import { refSchemaGenerator as refSchemaGenerator6 } from "roc-db";
|
|
159
|
+
var BlockRowRefSchema = refSchemaGenerator6("BlockRow");
|
|
160
|
+
|
|
161
|
+
// src/schemas/BlockRefSchema.ts
|
|
162
|
+
var BlockRefSchema = z12.union([
|
|
163
|
+
BlockParagraphRefSchema,
|
|
164
|
+
BlockRowRefSchema
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
// src/entities/BlockParagraph.ts
|
|
168
|
+
var BlockParagraph = new Entity3("BlockParagraph", {
|
|
169
|
+
data: z13.object({
|
|
170
|
+
content: z13.string().optional()
|
|
171
|
+
}),
|
|
172
|
+
parents: z13.object({
|
|
173
|
+
parent: z13.union([PostEntity.refSchema, BlockRefSchema])
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// src/entities/BlockRow.ts
|
|
178
|
+
import { Entity as Entity4 } from "roc-db";
|
|
179
|
+
import { z as z14 } from "zod";
|
|
180
|
+
var BlockRow = new Entity4("BlockRow", {
|
|
181
|
+
children: z14.object({
|
|
182
|
+
blocks: z14.array(BlockRefSchema)
|
|
183
|
+
}),
|
|
184
|
+
parents: z14.object({
|
|
185
|
+
parent: z14.union([PostEntity.refSchema, BlockRefSchema])
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// src/entities/PostVersion.ts
|
|
190
|
+
import { Entity as Entity5 } from "roc-db";
|
|
191
|
+
import { z as z15 } from "zod";
|
|
192
|
+
var PostVersion = new Entity5("PostVersion", {
|
|
193
|
+
data: z15.object({
|
|
194
|
+
version: z15.number(),
|
|
195
|
+
snapshot: z15.array(z15.any())
|
|
196
|
+
}),
|
|
197
|
+
parents: z15.object({ post: PostRefSchema }),
|
|
198
|
+
indexedDataKeys: ["version"],
|
|
199
|
+
uniqueDataKeys: ["slug"]
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// src/entities/index.ts
|
|
169
203
|
var entities = [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
PostSchema,
|
|
176
|
-
PostVersionSchema
|
|
204
|
+
BlockParagraph,
|
|
205
|
+
BlockRow,
|
|
206
|
+
Draft,
|
|
207
|
+
PostEntity,
|
|
208
|
+
PostVersion
|
|
177
209
|
];
|
|
178
210
|
// src/operations/applyDraft.ts
|
|
179
211
|
import { Query, QueryChain, writeOperation } from "roc-db";
|
|
@@ -182,17 +214,21 @@ var applyDraft = writeOperation("applyDraft", DraftRefSchema, (txn) => {
|
|
|
182
214
|
const versionRef = txn.createRef("PostVersion");
|
|
183
215
|
return QueryChain(Query(() => txn.applyChangeSet(ref)), Query(() => txn.patchEntity(ref, {
|
|
184
216
|
data: { appliedAt: txn.timestamp }
|
|
185
|
-
})), Query((draft) => txn.childRefsOf(draft.parents.post, true)), Query((childRefs, draft) => txn.batchReadEntities([draft.parents.post, ...childRefs])), Query((childEntities) => txn.createEntity(versionRef, {
|
|
217
|
+
})), Query((draft) => txn.childRefsOf(draft.parents.post, true)), Query((childRefs, draft) => txn.batchReadEntities([draft.parents.post, ...childRefs])), Query((childEntities, _, draft) => txn.createEntity(versionRef, {
|
|
186
218
|
data: {
|
|
219
|
+
version: 1,
|
|
187
220
|
snapshot: childEntities
|
|
221
|
+
},
|
|
222
|
+
parents: {
|
|
223
|
+
post: draft.parents.post
|
|
188
224
|
}
|
|
189
225
|
})));
|
|
190
226
|
});
|
|
191
227
|
|
|
192
228
|
// src/operations/createBlockImage.ts
|
|
193
229
|
import { Query as Query2, writeOperation as writeOperation2 } from "roc-db";
|
|
194
|
-
import { z as
|
|
195
|
-
var createBlockImage = writeOperation2("createBlockImage",
|
|
230
|
+
import { z as z16 } from "zod";
|
|
231
|
+
var createBlockImage = writeOperation2("createBlockImage", z16.object({ postRef: PostRefSchema }).strict(), (txn) => {
|
|
196
232
|
const ref = txn.createRef("BlockImage");
|
|
197
233
|
const { postRef } = txn.payload;
|
|
198
234
|
return Query2(() => txn.createEntity(ref, { parents: { post: postRef } }));
|
|
@@ -200,8 +236,8 @@ var createBlockImage = writeOperation2("createBlockImage", z13.object({ postRef:
|
|
|
200
236
|
|
|
201
237
|
// src/operations/createBlockParagraph.ts
|
|
202
238
|
import { Query as Query3, QueryChain as QueryChain2, writeOperation as writeOperation3 } from "roc-db";
|
|
203
|
-
import { z as
|
|
204
|
-
var createBlockParagrah = writeOperation3("createBlockParagraph",
|
|
239
|
+
import { z as z17 } from "zod";
|
|
240
|
+
var createBlockParagrah = writeOperation3("createBlockParagraph", z17.object({ parentRef: z17.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
|
|
205
241
|
const ref = txn.createRef("BlockParagraph");
|
|
206
242
|
const { parentRef } = txn.payload;
|
|
207
243
|
return QueryChain2(Query3(() => txn.readEntity(parentRef, true)), Query3((parent) => txn.patchEntity(parentRef, {
|
|
@@ -209,16 +245,16 @@ var createBlockParagrah = writeOperation3("createBlockParagraph", z14.object({ p
|
|
|
209
245
|
})), Query3(() => txn.createEntity(ref, { parents: { parent: parentRef } })), Query3((block, updatedParent) => ({ block, updatedParent })));
|
|
210
246
|
}, {
|
|
211
247
|
changeSetOnly: true,
|
|
212
|
-
outputSchema:
|
|
213
|
-
block:
|
|
214
|
-
updatedParent:
|
|
248
|
+
outputSchema: z17.object({
|
|
249
|
+
block: z17.any(),
|
|
250
|
+
updatedParent: z17.any()
|
|
215
251
|
})
|
|
216
252
|
});
|
|
217
253
|
|
|
218
254
|
// src/operations/createBlockRow.ts
|
|
219
255
|
import { Query as Query4, QueryChain as QueryChain3, writeOperation as writeOperation4 } from "roc-db";
|
|
220
|
-
import { z as
|
|
221
|
-
var createBlockRow = writeOperation4("createBlockRow",
|
|
256
|
+
import { z as z18 } from "zod";
|
|
257
|
+
var createBlockRow = writeOperation4("createBlockRow", z18.object({ parentRef: z18.union([PostRefSchema, BlockRowRefSchema]) }).strict(), (txn) => {
|
|
222
258
|
const ref = txn.createRef("BlockRow");
|
|
223
259
|
const { parentRef } = txn.payload;
|
|
224
260
|
return QueryChain3(Query4(() => txn.readEntity(parentRef)), Query4((parent) => {
|
|
@@ -231,16 +267,16 @@ var createBlockRow = writeOperation4("createBlockRow", z15.object({ parentRef: z
|
|
|
231
267
|
})), Query4((block, updatedParent) => ({ block, updatedParent })));
|
|
232
268
|
}, {
|
|
233
269
|
changeSetOnly: true,
|
|
234
|
-
outputSchema:
|
|
235
|
-
block:
|
|
236
|
-
updatedParent:
|
|
270
|
+
outputSchema: z18.object({
|
|
271
|
+
block: z18.any(),
|
|
272
|
+
updatedParent: z18.any()
|
|
237
273
|
})
|
|
238
274
|
});
|
|
239
275
|
|
|
240
276
|
// src/operations/createBlockTitle.ts
|
|
241
277
|
import { Query as Query5, writeOperation as writeOperation5 } from "roc-db";
|
|
242
|
-
import { z as
|
|
243
|
-
var PayloadSchema =
|
|
278
|
+
import { z as z19 } from "zod";
|
|
279
|
+
var PayloadSchema = z19.object({ parentRef: z19.union([PostRefSchema, BlockRowRefSchema]) }).strict();
|
|
244
280
|
var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn) => {
|
|
245
281
|
const ref = txn.createRef("BlockTitle");
|
|
246
282
|
const { postRef } = txn.payload;
|
|
@@ -249,8 +285,8 @@ var createBlockTitle = writeOperation5("createBlockTitle", PayloadSchema, (txn)
|
|
|
249
285
|
|
|
250
286
|
// src/operations/createDraft.ts
|
|
251
287
|
import { Query as Query6, writeOperation as writeOperation6 } from "roc-db";
|
|
252
|
-
import { z as
|
|
253
|
-
var createDraft = writeOperation6("createDraft",
|
|
288
|
+
import { z as z20 } from "zod";
|
|
289
|
+
var createDraft = writeOperation6("createDraft", z20.object({ postRef: PostRefSchema }).strict(), (txn) => {
|
|
254
290
|
const ref = txn.createRef("Draft");
|
|
255
291
|
const { postRef } = txn.payload;
|
|
256
292
|
return Query6(() => txn.createEntity(ref, {
|
|
@@ -262,11 +298,11 @@ var createDraft = writeOperation6("createDraft", z17.object({ postRef: PostRefSc
|
|
|
262
298
|
|
|
263
299
|
// src/operations/createPost.ts
|
|
264
300
|
import { Query as Query7, writeOperation as writeOperation7 } from "roc-db";
|
|
265
|
-
import { z as
|
|
266
|
-
var PayloadSchema2 =
|
|
267
|
-
title:
|
|
268
|
-
slug:
|
|
269
|
-
tags:
|
|
301
|
+
import { z as z21 } from "zod";
|
|
302
|
+
var PayloadSchema2 = z21.object({
|
|
303
|
+
title: z21.string(),
|
|
304
|
+
slug: z21.string().optional(),
|
|
305
|
+
tags: z21.array(z21.string()).default([])
|
|
270
306
|
}).strict();
|
|
271
307
|
var createPost = writeOperation7("createPost", PayloadSchema2, (txn) => {
|
|
272
308
|
const ref = txn.createRef("Post");
|
|
@@ -279,7 +315,7 @@ var createPost = writeOperation7("createPost", PayloadSchema2, (txn) => {
|
|
|
279
315
|
|
|
280
316
|
// src/operations/deleteBlocks.ts
|
|
281
317
|
import { Query as Query8, QueryChain as QueryChain4, writeOperation as writeOperation8 } from "roc-db";
|
|
282
|
-
import { z as
|
|
318
|
+
import { z as z22 } from "zod";
|
|
283
319
|
var DeleteBlockQuery = (txn, blockRef) => {
|
|
284
320
|
return QueryChain4(Query8(() => txn.readEntity(blockRef)), Query8((block) => {
|
|
285
321
|
return txn.readEntity(block.parents.parent, true);
|
|
@@ -291,7 +327,7 @@ var DeleteBlockQuery = (txn, blockRef) => {
|
|
|
291
327
|
});
|
|
292
328
|
}), Query8(() => txn.deleteEntity(blockRef)));
|
|
293
329
|
};
|
|
294
|
-
var deleteBlocks = writeOperation8("deleteBlocks",
|
|
330
|
+
var deleteBlocks = writeOperation8("deleteBlocks", z22.array(z22.union([
|
|
295
331
|
BlockParagraphRefSchema,
|
|
296
332
|
BlockImageRefSchema,
|
|
297
333
|
BlockRowRefSchema
|
|
@@ -316,10 +352,10 @@ var deletePost = writeOperation10("deletePost", PostRefSchema, (txn) => {
|
|
|
316
352
|
|
|
317
353
|
// src/operations/moveBlocks.ts
|
|
318
354
|
import { Query as Query11, QueryChain as QueryChain6, writeOperation as writeOperation11 } from "roc-db";
|
|
319
|
-
import { z as
|
|
320
|
-
var PayloadSchema3 =
|
|
321
|
-
refs:
|
|
322
|
-
targetPosition:
|
|
355
|
+
import { z as z23 } from "zod";
|
|
356
|
+
var PayloadSchema3 = z23.object({
|
|
357
|
+
refs: z23.array(z23.union([BlockParagraphRefSchema, BlockRowRefSchema])),
|
|
358
|
+
targetPosition: z23.number().min(0)
|
|
323
359
|
}).strict();
|
|
324
360
|
var moveBlocks = writeOperation11("moveBlocks", PayloadSchema3, (txn) => {
|
|
325
361
|
const { refs } = txn.payload;
|
|
@@ -328,19 +364,27 @@ var moveBlocks = writeOperation11("moveBlocks", PayloadSchema3, (txn) => {
|
|
|
328
364
|
}));
|
|
329
365
|
});
|
|
330
366
|
|
|
367
|
+
// src/operations/pagePostsByTag.ts
|
|
368
|
+
import { Query as Query12, readOperation } from "roc-db";
|
|
369
|
+
import { z as z24 } from "zod";
|
|
370
|
+
var pagePostsByTag = readOperation("pagePostsByTag", z24.string(), (txn) => {
|
|
371
|
+
const tag = txn.payload;
|
|
372
|
+
return Query12(() => txn.pageEntitiesByIndex("Post", "tags", tag));
|
|
373
|
+
});
|
|
374
|
+
|
|
331
375
|
// src/operations/readEntity.ts
|
|
332
|
-
import { NotFoundError, Query as
|
|
333
|
-
import { z as
|
|
334
|
-
var readEntity =
|
|
376
|
+
import { NotFoundError, Query as Query13, QueryChain as QueryChain7, readOperation as readOperation2 } from "roc-db";
|
|
377
|
+
import { z as z25 } from "zod";
|
|
378
|
+
var readEntity = readOperation2("readEntity", z25.string(), (txn) => {
|
|
335
379
|
const ref = txn.payload;
|
|
336
|
-
return QueryChain7(
|
|
380
|
+
return QueryChain7(Query13(() => txn.readEntity(ref)), Query13((entity) => {
|
|
337
381
|
if (!entity) {
|
|
338
382
|
throw new NotFoundError(ref);
|
|
339
383
|
}
|
|
340
384
|
return entity;
|
|
341
385
|
}));
|
|
342
386
|
}, {
|
|
343
|
-
outputSchema:
|
|
387
|
+
outputSchema: z25.union([
|
|
344
388
|
PostSchema,
|
|
345
389
|
BlockImageSchema,
|
|
346
390
|
BlockParagraphSchema
|
|
@@ -348,11 +392,11 @@ var readEntity = readOperation("readEntity", z21.string(), (txn) => {
|
|
|
348
392
|
});
|
|
349
393
|
|
|
350
394
|
// src/operations/readMutation.ts
|
|
351
|
-
import { NotFoundError as NotFoundError2, Query as
|
|
352
|
-
import { z as
|
|
353
|
-
var readMutation =
|
|
395
|
+
import { NotFoundError as NotFoundError2, Query as Query14, QueryChain as QueryChain8, readOperation as readOperation3 } from "roc-db";
|
|
396
|
+
import { z as z26 } from "zod";
|
|
397
|
+
var readMutation = readOperation3("readMutation", z26.string(), (txn) => {
|
|
354
398
|
const ref = txn.payload;
|
|
355
|
-
return QueryChain8(
|
|
399
|
+
return QueryChain8(Query14(() => txn.readMutation(ref)), Query14((entity) => {
|
|
356
400
|
if (!entity) {
|
|
357
401
|
throw new NotFoundError2(ref);
|
|
358
402
|
}
|
|
@@ -361,41 +405,49 @@ var readMutation = readOperation2("readMutation", z22.string(), (txn) => {
|
|
|
361
405
|
});
|
|
362
406
|
|
|
363
407
|
// src/operations/readPost.ts
|
|
364
|
-
import { Query as
|
|
365
|
-
var readPost =
|
|
408
|
+
import { Query as Query15, readOperation as readOperation4 } from "roc-db";
|
|
409
|
+
var readPost = readOperation4("readPost", PostRefSchema, (txn) => {
|
|
366
410
|
const ref = txn.payload;
|
|
367
|
-
return
|
|
411
|
+
return Query15(() => txn.readEntity(ref, true));
|
|
412
|
+
}, { outputSchema: PostSchema });
|
|
413
|
+
|
|
414
|
+
// src/operations/readPostBySlug.ts
|
|
415
|
+
import { Query as Query16, readOperation as readOperation5 } from "roc-db";
|
|
416
|
+
import { z as z27 } from "zod";
|
|
417
|
+
var readPostBySlug = readOperation5("readPostBySlug", z27.string(), (txn) => {
|
|
418
|
+
const slug = txn.payload;
|
|
419
|
+
return Query16(() => txn.readEntityByUniqueField("Post", "slug", slug));
|
|
368
420
|
}, { outputSchema: PostSchema });
|
|
369
421
|
|
|
370
422
|
// src/operations/testTransactionalEdits.ts
|
|
371
423
|
import { expect } from "bun:test";
|
|
372
|
-
import { Query as
|
|
373
|
-
import { z as
|
|
424
|
+
import { Query as Query17, QueryChain as QueryChain9, writeOperation as writeOperation12 } from "roc-db";
|
|
425
|
+
import { z as z28 } from "zod";
|
|
374
426
|
var TestCreatePatchDeleteInSameTransaction = (txn, name) => {
|
|
375
427
|
const postRef = txn.createRef("Post");
|
|
376
|
-
QueryChain9(
|
|
428
|
+
QueryChain9(Query17(() => txn.createEntity(postRef, { data: { name } })), Query17(() => txn.patchEntity(postRef, { data: { foo: "bar" } })), Query17((post) => {
|
|
377
429
|
expect(post.data.name).toBe(name);
|
|
378
430
|
expect(post.data.foo).toBe("bar");
|
|
379
|
-
}),
|
|
431
|
+
}), Query17(() => txn.patchEntity(postRef, { data: { foo: null, bar: "foo" } })), Query17((post) => {
|
|
380
432
|
expect(post.data.name).toBe(name);
|
|
381
433
|
expect(post.data.foo).toBeUndefined();
|
|
382
434
|
expect(post.data.bar).toBe("foo");
|
|
383
435
|
expect(txn.log).toHaveLength(1);
|
|
384
436
|
expect(txn.log.get(postRef)[0]).toBe("create");
|
|
385
|
-
}),
|
|
437
|
+
}), Query17((post) => txn.deleteEntity(postRef)), Query17((res) => {
|
|
386
438
|
expect(res).toBe(1);
|
|
387
439
|
expect(txn.log).toHaveLength(0);
|
|
388
440
|
}));
|
|
389
441
|
};
|
|
390
442
|
var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
|
|
391
|
-
return QueryChain9(
|
|
443
|
+
return QueryChain9(Query17(() => txn.patchEntity(ref, { data: { foo: "bar" } })), Query17((post) => {
|
|
392
444
|
expect(post.data.foo).toBe("bar");
|
|
393
|
-
}),
|
|
445
|
+
}), Query17(() => txn.patchEntity(ref, { data: { foo: null, bar: "foo" } })), Query17((post) => {
|
|
394
446
|
expect(post.data.foo).toBeUndefined();
|
|
395
447
|
expect(post.data.bar).toBe("foo");
|
|
396
448
|
expect(txn.log).toHaveLength(1);
|
|
397
449
|
expect(txn.log.get(ref)[0]).toBe("update");
|
|
398
|
-
}),
|
|
450
|
+
}), Query17((post) => txn.deleteEntity(ref)), Query17((res) => {
|
|
399
451
|
expect(res).toBe(1);
|
|
400
452
|
expect(txn.log).toHaveLength(1);
|
|
401
453
|
expect(txn.log.get(ref)[0]).toBe("delete");
|
|
@@ -403,10 +455,10 @@ var TestUpdateAndDeleteInSameTransaction = (txn, ref) => {
|
|
|
403
455
|
};
|
|
404
456
|
var TestCreateOnExistingRef = (txn) => {
|
|
405
457
|
const ref = txn.createRef("Post");
|
|
406
|
-
return QueryChain9(
|
|
458
|
+
return QueryChain9(Query17(() => txn.createEntity(ref, { data: { foo: "bar" } })), Query17(() => txn.createEntity(ref, { data: { foo: "bar" } })));
|
|
407
459
|
};
|
|
408
|
-
var PayloadSchema4 =
|
|
409
|
-
name:
|
|
460
|
+
var PayloadSchema4 = z28.object({
|
|
461
|
+
name: z28.string().optional(),
|
|
410
462
|
post1ref: PostRefSchema.optional(),
|
|
411
463
|
post2ref: PostRefSchema.optional()
|
|
412
464
|
}).strict();
|
|
@@ -421,30 +473,30 @@ var testTransactionalEdits = writeOperation12("testTransactionalEdits", PayloadS
|
|
|
421
473
|
}, {});
|
|
422
474
|
|
|
423
475
|
// src/operations/updateBlockParagraph.ts
|
|
424
|
-
import { Query as
|
|
425
|
-
import { z as
|
|
426
|
-
var updateBlockParagraph = writeOperation13("updateBlockParagraph",
|
|
476
|
+
import { Query as Query18, writeOperation as writeOperation13 } from "roc-db";
|
|
477
|
+
import { z as z29 } from "zod";
|
|
478
|
+
var updateBlockParagraph = writeOperation13("updateBlockParagraph", z29.object({
|
|
427
479
|
ref: BlockParagraphRefSchema,
|
|
428
|
-
content:
|
|
480
|
+
content: z29.string()
|
|
429
481
|
}), (txn) => {
|
|
430
482
|
const { ref, content } = txn.payload;
|
|
431
|
-
return
|
|
483
|
+
return Query18(() => txn.patchEntity(ref, {
|
|
432
484
|
data: { content }
|
|
433
485
|
}));
|
|
434
486
|
}, { outputSchema: BlockParagraphSchema });
|
|
435
487
|
|
|
436
488
|
// src/operations/updatePost.ts
|
|
437
|
-
import { Query as
|
|
438
|
-
import { z as
|
|
439
|
-
var PayloadSchema5 =
|
|
489
|
+
import { Query as Query19, writeOperation as writeOperation14 } from "roc-db";
|
|
490
|
+
import { z as z30 } from "zod";
|
|
491
|
+
var PayloadSchema5 = z30.object({
|
|
440
492
|
ref: PostRefSchema,
|
|
441
|
-
title:
|
|
442
|
-
tags:
|
|
493
|
+
title: z30.string().optional(),
|
|
494
|
+
tags: z30.array(z30.string()).optional().default([]),
|
|
443
495
|
authorRef: UserRefSchema.optional()
|
|
444
496
|
});
|
|
445
497
|
var updatePost = writeOperation14("updatePost", PayloadSchema5, (txn) => {
|
|
446
498
|
const { ref, authorRef, ...data } = txn.payload;
|
|
447
|
-
return
|
|
499
|
+
return Query19(() => txn.updateEntity(ref, {
|
|
448
500
|
data,
|
|
449
501
|
parents: { author: authorRef },
|
|
450
502
|
children: { blocks: [] }
|
|
@@ -452,19 +504,35 @@ var updatePost = writeOperation14("updatePost", PayloadSchema5, (txn) => {
|
|
|
452
504
|
}, { outputSchema: PostSchema });
|
|
453
505
|
|
|
454
506
|
// src/operations/updatePostDescription.ts
|
|
455
|
-
import { Query as
|
|
456
|
-
import { z as
|
|
457
|
-
var updatePostDescription = writeOperation15("updatePostDescription",
|
|
507
|
+
import { Query as Query20, writeOperation as writeOperation15 } from "roc-db";
|
|
508
|
+
import { z as z31 } from "zod";
|
|
509
|
+
var updatePostDescription = writeOperation15("updatePostDescription", z31.object({ ref: PostRefSchema, description: z31.string() }), (txn) => {
|
|
458
510
|
const { ref, description } = txn.payload;
|
|
459
|
-
return
|
|
511
|
+
return Query20(() => txn.patchEntity(ref, { data: { description } }));
|
|
460
512
|
}, { debounce: 10, changeSetOnly: true, outputSchema: PostSchema });
|
|
461
513
|
|
|
514
|
+
// src/operations/updatePostSlug.ts
|
|
515
|
+
import { Query as Query21, writeOperation as writeOperation16 } from "roc-db";
|
|
516
|
+
import { z as z32 } from "zod";
|
|
517
|
+
var updatePostSlug = writeOperation16("updatePostSlug", z32.object({ ref: PostRefSchema, slug: z32.string() }), (txn) => {
|
|
518
|
+
const { ref, slug } = txn.payload;
|
|
519
|
+
return Query21(() => txn.patchEntity(ref, { data: { slug } }));
|
|
520
|
+
}, { debounce: 10, outputSchema: PostSchema });
|
|
521
|
+
|
|
522
|
+
// src/operations/updatePostTags.ts
|
|
523
|
+
import { Query as Query22, writeOperation as writeOperation17 } from "roc-db";
|
|
524
|
+
import { z as z33 } from "zod";
|
|
525
|
+
var updatePostTags = writeOperation17("updatePostTags", z33.object({ ref: PostRefSchema, tags: z33.array(z33.string()) }), (txn) => {
|
|
526
|
+
const { ref, tags } = txn.payload;
|
|
527
|
+
return Query22(() => txn.patchEntity(ref, { data: { tags } }));
|
|
528
|
+
}, { debounce: 10, outputSchema: PostSchema });
|
|
529
|
+
|
|
462
530
|
// src/operations/updatePostTitle.ts
|
|
463
|
-
import { Query as
|
|
464
|
-
import { z as
|
|
465
|
-
var updatePostTitle =
|
|
531
|
+
import { Query as Query23, writeOperation as writeOperation18 } from "roc-db";
|
|
532
|
+
import { z as z34 } from "zod";
|
|
533
|
+
var updatePostTitle = writeOperation18("updatePostTitle", z34.object({ ref: PostRefSchema, title: z34.string() }), (txn) => {
|
|
466
534
|
const { ref, title } = txn.payload;
|
|
467
|
-
return
|
|
535
|
+
return Query23(() => txn.patchEntity(ref, { data: { title } }));
|
|
468
536
|
}, { debounce: 10, outputSchema: PostSchema });
|
|
469
537
|
|
|
470
538
|
// src/operations/index.ts
|
|
@@ -479,7 +547,9 @@ var operations = [
|
|
|
479
547
|
deleteBlocks,
|
|
480
548
|
deleteDraft,
|
|
481
549
|
deletePost,
|
|
550
|
+
readPostBySlug,
|
|
482
551
|
moveBlocks,
|
|
552
|
+
pagePostsByTag,
|
|
483
553
|
readEntity,
|
|
484
554
|
readMutation,
|
|
485
555
|
readPost,
|
|
@@ -487,16 +557,24 @@ var operations = [
|
|
|
487
557
|
updateBlockParagraph,
|
|
488
558
|
updatePost,
|
|
489
559
|
updatePostDescription,
|
|
560
|
+
updatePostSlug,
|
|
561
|
+
updatePostTags,
|
|
490
562
|
updatePostTitle
|
|
491
563
|
];
|
|
492
564
|
// src/testAdapterImplementation.ts
|
|
493
565
|
import { beforeAll, describe, expect as expect2, test } from "bun:test";
|
|
494
|
-
import {
|
|
566
|
+
import {
|
|
567
|
+
BadRequestError,
|
|
568
|
+
ConflictError,
|
|
569
|
+
NotFoundError as NotFoundError3,
|
|
570
|
+
Snowflake
|
|
571
|
+
} from "roc-db";
|
|
572
|
+
import { faker } from "@faker-js/faker";
|
|
495
573
|
var snowflake = new Snowflake(10, 10);
|
|
496
574
|
var prepareChangeSetTest = async (adapter, adapter2) => {
|
|
497
575
|
const [post, createPostMutation] = await adapter.createPost({
|
|
498
576
|
title: "Title 1",
|
|
499
|
-
slug:
|
|
577
|
+
slug: faker.lorem.slug(5),
|
|
500
578
|
tags: ["Foo", "Bar"]
|
|
501
579
|
});
|
|
502
580
|
expect2(createPostMutation.log).toStrictEqual([[post.ref, "create"]]);
|
|
@@ -561,7 +639,7 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
561
639
|
beforeAll(async () => {
|
|
562
640
|
const createPostRes = await adapter1.createPost({
|
|
563
641
|
title: "Title 1",
|
|
564
|
-
slug:
|
|
642
|
+
slug: faker.lorem.slug(5),
|
|
565
643
|
tags: ["Foo", "Bar"]
|
|
566
644
|
});
|
|
567
645
|
post = createPostRes[0];
|
|
@@ -569,7 +647,7 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
569
647
|
createPostMutation = createPostRes[1];
|
|
570
648
|
});
|
|
571
649
|
test("create (createEntity function)", async () => {
|
|
572
|
-
expect2(post).toMatchZodSchema(
|
|
650
|
+
expect2(post).toMatchZodSchema(PostEntity.schema);
|
|
573
651
|
expect2(post.data.title).toBe("Title 1");
|
|
574
652
|
expect2(post.data.tags).toStrictEqual(["Foo", "Bar"]);
|
|
575
653
|
expect2(createPostMutation).toMatchZodSchema(CreatePostMutationSchema);
|
|
@@ -578,7 +656,55 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
578
656
|
const readPostRes = await adapter1.readPost(postRef);
|
|
579
657
|
expect2(readPostRes.data.title).toStrictEqual("Title 1");
|
|
580
658
|
expect2(readPostRes.data.tags).toStrictEqual(["Foo", "Bar"]);
|
|
581
|
-
expect2(readPostRes).toMatchZodSchema(
|
|
659
|
+
expect2(readPostRes).toMatchZodSchema(PostEntity.schema);
|
|
660
|
+
});
|
|
661
|
+
test("read by unique", async () => {
|
|
662
|
+
const readPostRes = await adapter1.readPostBySlug(post.data.slug);
|
|
663
|
+
expect2(readPostRes.data.title).toStrictEqual("Title 1");
|
|
664
|
+
expect2(readPostRes.data.tags).toStrictEqual(["Foo", "Bar"]);
|
|
665
|
+
expect2(readPostRes.data.slug).toStrictEqual(post.data.slug);
|
|
666
|
+
});
|
|
667
|
+
test("create with same slug", async () => {
|
|
668
|
+
expect2(() => adapter1.createPost({
|
|
669
|
+
title: "Title 2",
|
|
670
|
+
slug: post.data.slug,
|
|
671
|
+
tags: ["Foo", "Bar"]
|
|
672
|
+
})).toThrow(ConflictError);
|
|
673
|
+
});
|
|
674
|
+
test("update unique slug", async () => {
|
|
675
|
+
const slug1 = faker.lorem.slug(5);
|
|
676
|
+
const slug2 = faker.lorem.slug(5);
|
|
677
|
+
const [post2] = await adapter1.createPost({
|
|
678
|
+
title: "Title 1",
|
|
679
|
+
slug: slug1
|
|
680
|
+
});
|
|
681
|
+
const readPostRes1 = await adapter1.readPostBySlug(slug1);
|
|
682
|
+
expect2(readPostRes1.data.slug).toStrictEqual(slug1);
|
|
683
|
+
const [updateRes] = await adapter1.updatePostSlug({
|
|
684
|
+
ref: post2.ref,
|
|
685
|
+
slug: slug2
|
|
686
|
+
});
|
|
687
|
+
expect2(updateRes.data.slug).toStrictEqual(slug2);
|
|
688
|
+
expect2(() => adapter1.readPostBySlug(slug1)).toThrow(NotFoundError3);
|
|
689
|
+
const readPostRes2 = await adapter1.readPostBySlug(slug2);
|
|
690
|
+
expect2(readPostRes2.data.slug).toStrictEqual(slug2);
|
|
691
|
+
});
|
|
692
|
+
test("update index entries", async () => {
|
|
693
|
+
const [post2] = await adapter1.createPost({
|
|
694
|
+
title: "Title 1",
|
|
695
|
+
tags: ["foo"]
|
|
696
|
+
});
|
|
697
|
+
const pageTagFoo1 = await adapter1.pagePostsByTag("foo");
|
|
698
|
+
expect2(pageTagFoo1.length).toBe(1);
|
|
699
|
+
expect2(pageTagFoo1[0].ref).toBe(post2.ref);
|
|
700
|
+
const [updatedRes] = await adapter1.updatePostTags({
|
|
701
|
+
ref: post2.ref,
|
|
702
|
+
tags: ["bar"]
|
|
703
|
+
});
|
|
704
|
+
const pageTagFoo2 = await adapter1.pagePostsByTag("foo");
|
|
705
|
+
expect2(pageTagFoo2.length).toBe(0);
|
|
706
|
+
const pageTagBar = await adapter1.pagePostsByTag("bar");
|
|
707
|
+
expect2(pageTagBar.length).toBe(1);
|
|
582
708
|
});
|
|
583
709
|
test("read not found (readEntity function)", async () => {
|
|
584
710
|
expect2(() => adapter1.readPost("Post/999")).toThrow(NotFoundError3);
|
|
@@ -591,20 +717,20 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
591
717
|
});
|
|
592
718
|
expect2(post2.data.tags).toStrictEqual(["Foo"]);
|
|
593
719
|
expect2(post2.data.title).toBe("Title 2");
|
|
594
|
-
expect2(post2).toMatchZodSchema(
|
|
720
|
+
expect2(post2).toMatchZodSchema(PostEntity.schema);
|
|
595
721
|
});
|
|
596
722
|
test("updateTitle (patchEntity function + debounce)", async () => {
|
|
597
723
|
const [update1, mutation1] = await adapter1.updatePostTitle({
|
|
598
724
|
ref: postRef,
|
|
599
725
|
title: "Title 3"
|
|
600
726
|
});
|
|
601
|
-
expect2(update1).toMatchZodSchema(
|
|
727
|
+
expect2(update1).toMatchZodSchema(PostEntity.schema);
|
|
602
728
|
expect2(mutation1).toMatchZodSchema(UpdatePostTitleMutationSchema);
|
|
603
729
|
const [update2, mutation2] = await adapter1.updatePostTitle({
|
|
604
730
|
ref: postRef,
|
|
605
731
|
title: "Title 4"
|
|
606
732
|
});
|
|
607
|
-
expect2(update2).toMatchZodSchema(
|
|
733
|
+
expect2(update2).toMatchZodSchema(PostEntity.schema);
|
|
608
734
|
expect2(mutation2).toMatchZodSchema(UpdatePostTitleMutationSchema);
|
|
609
735
|
expect2(mutation1.ref).toBe(mutation2.ref);
|
|
610
736
|
expect2(mutation2.timestamp >= mutation1.timestamp).toBeTrue();
|
|
@@ -661,19 +787,19 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
661
787
|
} = await prepareChangeSetTest(adapter1, adapter2));
|
|
662
788
|
});
|
|
663
789
|
test("create (createEntity function w/changeSetRef)", async () => {
|
|
664
|
-
expect2(blockParagraph1).toMatchZodSchema(
|
|
665
|
-
expect2(post).toMatchZodSchema(
|
|
790
|
+
expect2(blockParagraph1).toMatchZodSchema(BlockParagraph.schema);
|
|
791
|
+
expect2(post).toMatchZodSchema(PostEntity.schema);
|
|
666
792
|
});
|
|
667
793
|
test("read (readEntity function w/changeSetRef)", async () => {
|
|
668
794
|
const read = await changeSetAdapter.readEntity(blockParagraph1.ref);
|
|
669
|
-
expect2(read).toMatchZodSchema(
|
|
795
|
+
expect2(read).toMatchZodSchema(BlockParagraph.schema);
|
|
670
796
|
});
|
|
671
797
|
test("update (patchEntity function w/changeSetRef)", async () => {
|
|
672
798
|
const [updatedBlock] = await changeSetAdapter.updateBlockParagraph({
|
|
673
799
|
ref: blockParagraph1.ref,
|
|
674
800
|
content: "Hello, world!"
|
|
675
801
|
});
|
|
676
|
-
expect2(updatedBlock).toMatchZodSchema(
|
|
802
|
+
expect2(updatedBlock).toMatchZodSchema(BlockParagraph.schema);
|
|
677
803
|
});
|
|
678
804
|
test("move (batchReadEntities function)", async () => {
|
|
679
805
|
const res = await changeSetAdapter.moveBlocks({
|
|
@@ -720,7 +846,7 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
720
846
|
test("deleteBlocks (patch running 2 times removing on array element every time)", async () => {
|
|
721
847
|
const [post2, createPostMutation] = await adapter1.createPost({
|
|
722
848
|
title: "Title 1",
|
|
723
|
-
slug:
|
|
849
|
+
slug: faker.lorem.slug(5),
|
|
724
850
|
tags: ["Foo", "Bar"]
|
|
725
851
|
});
|
|
726
852
|
const [draft2, createDraftMutation] = await adapter1.createDraft({
|
|
@@ -789,6 +915,7 @@ var testAdapterImplementation = async (adapterConstructor, generateArgs) => {
|
|
|
789
915
|
expect2(optimisticAdapter.loadMutations).toBeDefined();
|
|
790
916
|
const [post2, createPostMutation] = await optimisticAdapter.createPost({
|
|
791
917
|
title: "Foo",
|
|
918
|
+
slug: faker.lorem.slug(5),
|
|
792
919
|
tags: []
|
|
793
920
|
});
|
|
794
921
|
const [persistCratePostMutation] = await persistedAdapter.persistOptimisticMutations([
|