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