@23blocks/block-content 3.3.3 → 3.3.4
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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @23blocks/block-content
|
|
2
2
|
|
|
3
|
-
Content block for the 23blocks SDK - blog posts, comments, categories, and
|
|
3
|
+
Content block for the 23blocks SDK - blog posts, comments, categories, tags, series, and more.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@23blocks/block-content)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -13,12 +13,16 @@ npm install @23blocks/block-content @23blocks/transport-http
|
|
|
13
13
|
|
|
14
14
|
## Overview
|
|
15
15
|
|
|
16
|
-
This package provides content management functionality
|
|
16
|
+
This package provides comprehensive content management functionality:
|
|
17
17
|
|
|
18
|
-
- **Posts** - Blog posts and articles
|
|
18
|
+
- **Posts** - Blog posts and articles with versioning
|
|
19
|
+
- **Series** - Collections of ordered posts (tutorials, courses)
|
|
19
20
|
- **Comments** - User comments on posts
|
|
20
|
-
- **Categories** -
|
|
21
|
+
- **Categories** - Hierarchical content categorization
|
|
21
22
|
- **Tags** - Content tagging
|
|
23
|
+
- **Users** - Content-specific user profiles
|
|
24
|
+
- **Moderation** - Content moderation and flagging
|
|
25
|
+
- **Activity** - Activity feeds and engagement tracking
|
|
22
26
|
|
|
23
27
|
## Quick Start
|
|
24
28
|
|
|
@@ -27,26 +31,22 @@ import { createHttpTransport } from '@23blocks/transport-http';
|
|
|
27
31
|
import { createContentBlock } from '@23blocks/block-content';
|
|
28
32
|
|
|
29
33
|
const transport = createHttpTransport({
|
|
30
|
-
baseUrl: 'https://
|
|
31
|
-
headers: () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
34
|
+
baseUrl: 'https://content.yourapp.com',
|
|
35
|
+
headers: () => ({
|
|
36
|
+
'x-api-key': 'your-api-key',
|
|
37
|
+
Authorization: `Bearer ${localStorage.getItem('access_token')}`,
|
|
38
|
+
}),
|
|
35
39
|
});
|
|
36
40
|
|
|
37
41
|
const content = createContentBlock(transport, {
|
|
38
|
-
|
|
42
|
+
appId: 'your-app-id',
|
|
39
43
|
});
|
|
40
44
|
|
|
41
45
|
// List published posts
|
|
42
|
-
const { data: posts } = await content.posts.list({
|
|
43
|
-
status: 'published',
|
|
44
|
-
limit: 10,
|
|
45
|
-
});
|
|
46
|
+
const { data: posts } = await content.posts.list({ page: 1, perPage: 10 });
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
48
|
+
// List series
|
|
49
|
+
const { data: series } = await content.series.list({ page: 1, perPage: 10 });
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## Services
|
|
@@ -54,68 +54,165 @@ posts.forEach((post) => {
|
|
|
54
54
|
### posts - Post Management
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
// List posts
|
|
57
|
+
// List posts with pagination
|
|
58
58
|
const { data: posts, meta } = await content.posts.list({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
status: 'published',
|
|
59
|
+
page: 1,
|
|
60
|
+
perPage: 20,
|
|
62
61
|
});
|
|
63
62
|
|
|
64
|
-
// Get post by ID
|
|
65
|
-
const post = await content.posts.get('post-id');
|
|
66
|
-
|
|
67
|
-
// Get post by slug
|
|
68
|
-
const post = await content.posts.getBySlug('my-post-slug');
|
|
63
|
+
// Get post by unique ID
|
|
64
|
+
const post = await content.posts.get('post-unique-id');
|
|
69
65
|
|
|
70
66
|
// Create post
|
|
71
67
|
const newPost = await content.posts.create({
|
|
72
68
|
title: 'My New Post',
|
|
73
|
-
|
|
69
|
+
body: 'Post content here...',
|
|
74
70
|
excerpt: 'Short summary',
|
|
75
71
|
slug: 'my-new-post',
|
|
76
|
-
categoryId: 'category-id',
|
|
77
|
-
tagIds: ['tag-1', 'tag-2'],
|
|
78
72
|
status: 'draft',
|
|
79
73
|
});
|
|
80
74
|
|
|
81
75
|
// Update post
|
|
82
|
-
const updated = await content.posts.update('post-id', {
|
|
76
|
+
const updated = await content.posts.update('post-unique-id', {
|
|
83
77
|
title: 'Updated Title',
|
|
84
78
|
status: 'published',
|
|
85
|
-
publishedAt: new Date().toISOString(),
|
|
86
79
|
});
|
|
87
80
|
|
|
88
|
-
// Delete post
|
|
89
|
-
await content.posts.delete('post-id');
|
|
81
|
+
// Delete post (soft delete)
|
|
82
|
+
await content.posts.delete('post-unique-id');
|
|
83
|
+
|
|
84
|
+
// Recover deleted post
|
|
85
|
+
await content.posts.recover('post-unique-id');
|
|
86
|
+
|
|
87
|
+
// Search posts
|
|
88
|
+
const { data: results } = await content.posts.search('typescript', { page: 1 });
|
|
89
|
+
|
|
90
|
+
// List deleted posts
|
|
91
|
+
const { data: deleted } = await content.posts.listDeleted({ page: 1 });
|
|
92
|
+
|
|
93
|
+
// Social actions
|
|
94
|
+
await content.posts.like('post-unique-id');
|
|
95
|
+
await content.posts.dislike('post-unique-id');
|
|
96
|
+
await content.posts.save('post-unique-id');
|
|
97
|
+
await content.posts.follow('post-unique-id');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### series - Series Management
|
|
101
|
+
|
|
102
|
+
Series allow you to group posts into ordered collections (e.g., tutorials, courses, article series).
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// List all series
|
|
106
|
+
const { data: seriesList, meta } = await content.series.list({
|
|
107
|
+
page: 1,
|
|
108
|
+
perPage: 20,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Query series with filters
|
|
112
|
+
const { data: filtered } = await content.series.query({
|
|
113
|
+
visibility: 'public',
|
|
114
|
+
completionStatus: 'ongoing',
|
|
115
|
+
search: 'typescript',
|
|
116
|
+
userUniqueId: 'author-id',
|
|
117
|
+
page: 1,
|
|
118
|
+
perPage: 20,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Get series by unique ID
|
|
122
|
+
const series = await content.series.get('series-unique-id');
|
|
123
|
+
|
|
124
|
+
// Create series
|
|
125
|
+
const newSeries = await content.series.create({
|
|
126
|
+
title: 'TypeScript Fundamentals',
|
|
127
|
+
description: 'A complete guide to TypeScript',
|
|
128
|
+
slug: 'typescript-fundamentals',
|
|
129
|
+
thumbnailUrl: 'https://example.com/thumb.jpg',
|
|
130
|
+
imageUrl: 'https://example.com/cover.jpg',
|
|
131
|
+
visibility: 'public', // 'public' | 'private' | 'unlisted'
|
|
132
|
+
completionStatus: 'ongoing', // 'ongoing' | 'completed' | 'hiatus' | 'cancelled'
|
|
133
|
+
payload: { difficulty: 'beginner' },
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Update series
|
|
137
|
+
const updated = await content.series.update('series-unique-id', {
|
|
138
|
+
title: 'TypeScript Masterclass',
|
|
139
|
+
completionStatus: 'completed',
|
|
140
|
+
enabled: true,
|
|
141
|
+
status: 'active',
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Delete series
|
|
145
|
+
await content.series.delete('series-unique-id');
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Series Social Actions
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// Like/dislike
|
|
152
|
+
const liked = await content.series.like('series-unique-id');
|
|
153
|
+
const disliked = await content.series.dislike('series-unique-id');
|
|
154
|
+
|
|
155
|
+
// Follow/unfollow
|
|
156
|
+
const followed = await content.series.follow('series-unique-id');
|
|
157
|
+
await content.series.unfollow('series-unique-id');
|
|
158
|
+
|
|
159
|
+
// Save/unsave (bookmarking)
|
|
160
|
+
const saved = await content.series.save('series-unique-id');
|
|
161
|
+
await content.series.unsave('series-unique-id');
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Series Post Management
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// Get all posts in a series (ordered)
|
|
168
|
+
const posts = await content.series.getPosts('series-unique-id');
|
|
169
|
+
|
|
170
|
+
// Add a post to a series with optional sequence number
|
|
171
|
+
await content.series.addPost('series-unique-id', 'post-unique-id', 1);
|
|
172
|
+
|
|
173
|
+
// Remove a post from a series
|
|
174
|
+
await content.series.removePost('series-unique-id', 'post-unique-id');
|
|
175
|
+
|
|
176
|
+
// Reorder posts in a series
|
|
177
|
+
const reordered = await content.series.reorderPosts('series-unique-id', {
|
|
178
|
+
posts: [
|
|
179
|
+
{ postUniqueId: 'post-1', sequence: 1 },
|
|
180
|
+
{ postUniqueId: 'post-2', sequence: 2 },
|
|
181
|
+
{ postUniqueId: 'post-3', sequence: 3 },
|
|
182
|
+
],
|
|
183
|
+
});
|
|
90
184
|
```
|
|
91
185
|
|
|
92
186
|
### comments - Comment Management
|
|
93
187
|
|
|
94
188
|
```typescript
|
|
95
|
-
// List comments
|
|
189
|
+
// List comments
|
|
96
190
|
const { data: comments } = await content.comments.list({
|
|
97
|
-
|
|
98
|
-
|
|
191
|
+
page: 1,
|
|
192
|
+
perPage: 50,
|
|
99
193
|
});
|
|
100
194
|
|
|
101
195
|
// Get comment by ID
|
|
102
|
-
const comment = await content.comments.get('comment-id');
|
|
196
|
+
const comment = await content.comments.get('comment-unique-id');
|
|
103
197
|
|
|
104
198
|
// Create comment
|
|
105
199
|
const newComment = await content.comments.create({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
authorEmail: 'john@example.com',
|
|
200
|
+
postUniqueId: 'post-unique-id',
|
|
201
|
+
body: 'Great article!',
|
|
202
|
+
parentUniqueId: null, // For replies, set parent comment ID
|
|
110
203
|
});
|
|
111
204
|
|
|
112
205
|
// Update comment
|
|
113
|
-
const updated = await content.comments.update('comment-id', {
|
|
114
|
-
|
|
206
|
+
const updated = await content.comments.update('comment-unique-id', {
|
|
207
|
+
body: 'Updated comment content',
|
|
115
208
|
});
|
|
116
209
|
|
|
117
210
|
// Delete comment
|
|
118
|
-
await content.comments.delete('comment-id');
|
|
211
|
+
await content.comments.delete('comment-unique-id');
|
|
212
|
+
|
|
213
|
+
// Like/dislike comments
|
|
214
|
+
await content.comments.like('comment-unique-id');
|
|
215
|
+
await content.comments.dislike('comment-unique-id');
|
|
119
216
|
```
|
|
120
217
|
|
|
121
218
|
### categories - Category Management
|
|
@@ -125,23 +222,29 @@ await content.comments.delete('comment-id');
|
|
|
125
222
|
const { data: categories } = await content.categories.list();
|
|
126
223
|
|
|
127
224
|
// Get category by ID
|
|
128
|
-
const category = await content.categories.get('category-id');
|
|
225
|
+
const category = await content.categories.get('category-unique-id');
|
|
129
226
|
|
|
130
227
|
// Create category
|
|
131
228
|
const newCategory = await content.categories.create({
|
|
132
229
|
name: 'Technology',
|
|
133
230
|
slug: 'technology',
|
|
134
231
|
description: 'Technology related posts',
|
|
135
|
-
|
|
232
|
+
parentUniqueId: null, // For subcategories
|
|
136
233
|
});
|
|
137
234
|
|
|
138
235
|
// Update category
|
|
139
|
-
const updated = await content.categories.update('category-id', {
|
|
236
|
+
const updated = await content.categories.update('category-unique-id', {
|
|
140
237
|
description: 'Updated description',
|
|
141
238
|
});
|
|
142
239
|
|
|
143
240
|
// Delete category
|
|
144
|
-
await content.categories.delete('category-id');
|
|
241
|
+
await content.categories.delete('category-unique-id');
|
|
242
|
+
|
|
243
|
+
// Recover deleted category
|
|
244
|
+
await content.categories.recover('category-unique-id');
|
|
245
|
+
|
|
246
|
+
// Get child categories
|
|
247
|
+
const children = await content.categories.getChildren('parent-category-id');
|
|
145
248
|
```
|
|
146
249
|
|
|
147
250
|
### tags - Tag Management
|
|
@@ -151,7 +254,7 @@ await content.categories.delete('category-id');
|
|
|
151
254
|
const { data: tags } = await content.tags.list();
|
|
152
255
|
|
|
153
256
|
// Get tag by ID
|
|
154
|
-
const tag = await content.tags.get('tag-id');
|
|
257
|
+
const tag = await content.tags.get('tag-unique-id');
|
|
155
258
|
|
|
156
259
|
// Create tag
|
|
157
260
|
const newTag = await content.tags.create({
|
|
@@ -160,59 +263,205 @@ const newTag = await content.tags.create({
|
|
|
160
263
|
});
|
|
161
264
|
|
|
162
265
|
// Update tag
|
|
163
|
-
const updated = await content.tags.update('tag-id', {
|
|
266
|
+
const updated = await content.tags.update('tag-unique-id', {
|
|
164
267
|
name: 'TypeScript',
|
|
165
268
|
slug: 'typescript',
|
|
166
269
|
});
|
|
167
270
|
|
|
168
271
|
// Delete tag
|
|
169
|
-
await content.tags.delete('tag-id');
|
|
272
|
+
await content.tags.delete('tag-unique-id');
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### users - Content User Management
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// List content users
|
|
279
|
+
const { data: users } = await content.users.list({ page: 1 });
|
|
280
|
+
|
|
281
|
+
// Get user profile
|
|
282
|
+
const user = await content.users.get('user-unique-id');
|
|
283
|
+
|
|
284
|
+
// Register user for content
|
|
285
|
+
const registered = await content.users.register('user-unique-id', {
|
|
286
|
+
alias: 'johndoe',
|
|
287
|
+
bio: 'Tech writer',
|
|
288
|
+
avatarUrl: 'https://example.com/avatar.jpg',
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// Update user profile
|
|
292
|
+
const updated = await content.users.update('user-unique-id', {
|
|
293
|
+
bio: 'Senior tech writer',
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// Get user's posts
|
|
297
|
+
const posts = await content.users.getPosts('user-unique-id');
|
|
298
|
+
|
|
299
|
+
// Get user's drafts
|
|
300
|
+
const drafts = await content.users.getDrafts('user-unique-id');
|
|
301
|
+
|
|
302
|
+
// Get user's comments
|
|
303
|
+
const comments = await content.users.getComments('user-unique-id');
|
|
304
|
+
|
|
305
|
+
// Get user's activities
|
|
306
|
+
const activities = await content.users.getActivities('user-unique-id');
|
|
307
|
+
|
|
308
|
+
// User tags (interests)
|
|
309
|
+
await content.users.addTag('user-unique-id', 'tag-unique-id');
|
|
310
|
+
await content.users.removeTag('user-unique-id', 'tag-unique-id');
|
|
311
|
+
|
|
312
|
+
// User following
|
|
313
|
+
const followers = await content.users.getFollowers('user-unique-id');
|
|
314
|
+
const following = await content.users.getFollowing('user-unique-id');
|
|
315
|
+
await content.users.followUser('user-unique-id', 'target-user-id');
|
|
316
|
+
await content.users.unfollowUser('user-unique-id', 'target-user-id');
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### moderation - Content Moderation
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
// Moderate a post
|
|
323
|
+
const result = await content.moderation.moderatePost('post-unique-id', {
|
|
324
|
+
action: 'approve', // 'approve' | 'reject' | 'flag'
|
|
325
|
+
reason: 'Content meets guidelines',
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Moderate a comment
|
|
329
|
+
const result = await content.moderation.moderateComment('comment-unique-id', {
|
|
330
|
+
action: 'reject',
|
|
331
|
+
reason: 'Spam content',
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// List content flags
|
|
335
|
+
const { data: flags } = await content.moderation.listFlags({ page: 1 });
|
|
336
|
+
|
|
337
|
+
// Create a flag
|
|
338
|
+
const flag = await content.moderation.createFlag({
|
|
339
|
+
entityType: 'post',
|
|
340
|
+
entityUniqueId: 'post-unique-id',
|
|
341
|
+
reason: 'inappropriate',
|
|
342
|
+
description: 'Contains offensive language',
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Resolve a flag
|
|
346
|
+
const resolved = await content.moderation.resolveFlag('flag-unique-id', 'removed');
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### activities - Activity Feed
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
// Get activities
|
|
353
|
+
const { data: activities } = await content.activities.getActivities({
|
|
354
|
+
page: 1,
|
|
355
|
+
perPage: 50,
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// Get comment activities for a post
|
|
359
|
+
const commentActivities = await content.activities.getComments('post-unique-id');
|
|
360
|
+
|
|
361
|
+
// Get activity feed for a user
|
|
362
|
+
const { data: feed } = await content.activities.getFeed('user-unique-id', {
|
|
363
|
+
page: 1,
|
|
364
|
+
perPage: 20,
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### postVersions - Post Version History
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
// List versions of a post
|
|
372
|
+
const { data: versions } = await content.postVersions.list('post-unique-id');
|
|
373
|
+
|
|
374
|
+
// Get specific version
|
|
375
|
+
const version = await content.postVersions.get('post-unique-id', 'version-unique-id');
|
|
376
|
+
|
|
377
|
+
// Restore a version
|
|
378
|
+
const restored = await content.postVersions.restore('post-unique-id', 'version-unique-id');
|
|
170
379
|
```
|
|
171
380
|
|
|
172
381
|
## Types
|
|
173
382
|
|
|
174
383
|
```typescript
|
|
175
384
|
import type {
|
|
385
|
+
// Posts
|
|
176
386
|
Post,
|
|
177
|
-
Comment,
|
|
178
|
-
Category,
|
|
179
|
-
Tag,
|
|
180
387
|
CreatePostRequest,
|
|
181
388
|
UpdatePostRequest,
|
|
389
|
+
ListPostsParams,
|
|
390
|
+
|
|
391
|
+
// Series
|
|
392
|
+
Series,
|
|
393
|
+
CreateSeriesRequest,
|
|
394
|
+
UpdateSeriesRequest,
|
|
395
|
+
ListSeriesParams,
|
|
396
|
+
QuerySeriesParams,
|
|
397
|
+
ReorderPostsRequest,
|
|
398
|
+
SeriesVisibility, // 'public' | 'private' | 'unlisted'
|
|
399
|
+
SeriesCompletionStatus, // 'ongoing' | 'completed' | 'hiatus' | 'cancelled'
|
|
400
|
+
|
|
401
|
+
// Comments
|
|
402
|
+
Comment,
|
|
182
403
|
CreateCommentRequest,
|
|
404
|
+
UpdateCommentRequest,
|
|
405
|
+
ListCommentsParams,
|
|
406
|
+
|
|
407
|
+
// Categories
|
|
408
|
+
Category,
|
|
183
409
|
CreateCategoryRequest,
|
|
410
|
+
UpdateCategoryRequest,
|
|
411
|
+
ListCategoriesParams,
|
|
412
|
+
|
|
413
|
+
// Tags
|
|
414
|
+
Tag,
|
|
184
415
|
CreateTagRequest,
|
|
185
|
-
|
|
416
|
+
UpdateTagRequest,
|
|
417
|
+
ListTagsParams,
|
|
418
|
+
|
|
419
|
+
// Users
|
|
420
|
+
ContentUser,
|
|
421
|
+
RegisterContentUserRequest,
|
|
422
|
+
UpdateContentUserRequest,
|
|
423
|
+
ListContentUsersParams,
|
|
424
|
+
UserActivity,
|
|
425
|
+
|
|
426
|
+
// Moderation
|
|
427
|
+
ModerationResult,
|
|
428
|
+
ModerateContentRequest,
|
|
429
|
+
ContentFlag,
|
|
430
|
+
CreateContentFlagRequest,
|
|
431
|
+
ListContentFlagsParams,
|
|
432
|
+
|
|
433
|
+
// Activity
|
|
434
|
+
Activity,
|
|
435
|
+
ListActivitiesParams,
|
|
436
|
+
|
|
437
|
+
// Post Versions
|
|
438
|
+
PostVersion,
|
|
186
439
|
} from '@23blocks/block-content';
|
|
187
440
|
```
|
|
188
441
|
|
|
189
|
-
###
|
|
442
|
+
### Series Type
|
|
190
443
|
|
|
191
444
|
| Property | Type | Description |
|
|
192
445
|
|----------|------|-------------|
|
|
193
|
-
| `id` | `string` | Post ID |
|
|
194
446
|
| `uniqueId` | `string` | Unique identifier |
|
|
195
|
-
| `title` | `string` |
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `authorEmail` | `string` | Author email |
|
|
214
|
-
| `status` | `string` | pending, approved, spam |
|
|
215
|
-
| `parentId` | `string` | Parent comment ID (for replies) |
|
|
447
|
+
| `title` | `string` | Series title |
|
|
448
|
+
| `description` | `string?` | Series description |
|
|
449
|
+
| `slug` | `string?` | URL-friendly slug |
|
|
450
|
+
| `thumbnailUrl` | `string?` | Thumbnail image URL |
|
|
451
|
+
| `imageUrl` | `string?` | Cover image URL |
|
|
452
|
+
| `status` | `EntityStatus` | active, inactive, deleted |
|
|
453
|
+
| `enabled` | `boolean` | Whether series is enabled |
|
|
454
|
+
| `visibility` | `SeriesVisibility` | public, private, unlisted |
|
|
455
|
+
| `completionStatus` | `SeriesCompletionStatus` | ongoing, completed, hiatus, cancelled |
|
|
456
|
+
| `userUniqueId` | `string?` | Author's unique ID |
|
|
457
|
+
| `userName` | `string?` | Author's name |
|
|
458
|
+
| `userAlias` | `string?` | Author's alias |
|
|
459
|
+
| `postsCount` | `number?` | Number of posts in series |
|
|
460
|
+
| `likes` | `number?` | Like count |
|
|
461
|
+
| `dislikes` | `number?` | Dislike count |
|
|
462
|
+
| `followers` | `number?` | Follower count |
|
|
463
|
+
| `savers` | `number?` | Save/bookmark count |
|
|
464
|
+
| `payload` | `Record<string, unknown>?` | Custom metadata |
|
|
216
465
|
|
|
217
466
|
## Error Handling
|
|
218
467
|
|
|
@@ -220,15 +469,22 @@ import type {
|
|
|
220
469
|
import { isBlockErrorException, ErrorCodes } from '@23blocks/contracts';
|
|
221
470
|
|
|
222
471
|
try {
|
|
223
|
-
await content.
|
|
472
|
+
await content.series.get('invalid-id');
|
|
224
473
|
} catch (error) {
|
|
225
474
|
if (isBlockErrorException(error)) {
|
|
475
|
+
// Request tracing
|
|
476
|
+
console.log('Request ID:', error.requestId);
|
|
477
|
+
console.log('Duration:', error.duration);
|
|
478
|
+
|
|
226
479
|
switch (error.code) {
|
|
227
480
|
case ErrorCodes.NOT_FOUND:
|
|
228
|
-
console.log('
|
|
481
|
+
console.log('Series not found');
|
|
229
482
|
break;
|
|
230
483
|
case ErrorCodes.UNAUTHORIZED:
|
|
231
|
-
console.log('Not authorized
|
|
484
|
+
console.log('Not authorized');
|
|
485
|
+
break;
|
|
486
|
+
case ErrorCodes.VALIDATION_ERROR:
|
|
487
|
+
console.log('Validation failed:', error.message);
|
|
232
488
|
break;
|
|
233
489
|
}
|
|
234
490
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -219,7 +219,9 @@ function createPostsService(transport, _config) {
|
|
|
219
219
|
is_public: data.isPublic,
|
|
220
220
|
publish_at: data.publishAt,
|
|
221
221
|
publish_until: data.publishUntil,
|
|
222
|
-
payload: data.payload
|
|
222
|
+
payload: data.payload,
|
|
223
|
+
series_unique_id: data.seriesUniqueId,
|
|
224
|
+
series_sequence: data.seriesSequence
|
|
223
225
|
}
|
|
224
226
|
});
|
|
225
227
|
return decodeOne(response, postMapper);
|
|
@@ -241,7 +243,9 @@ function createPostsService(transport, _config) {
|
|
|
241
243
|
publish_until: data.publishUntil,
|
|
242
244
|
enabled: data.enabled,
|
|
243
245
|
status: data.status,
|
|
244
|
-
payload: data.payload
|
|
246
|
+
payload: data.payload,
|
|
247
|
+
series_unique_id: data.seriesUniqueId,
|
|
248
|
+
series_sequence: data.seriesSequence
|
|
245
249
|
}
|
|
246
250
|
});
|
|
247
251
|
return decodeOne(response, postMapper);
|
|
@@ -263,7 +267,9 @@ function createPostsService(transport, _config) {
|
|
|
263
267
|
publish_until: data.publishUntil,
|
|
264
268
|
enabled: data.enabled,
|
|
265
269
|
status: data.status,
|
|
266
|
-
payload: data.payload
|
|
270
|
+
payload: data.payload,
|
|
271
|
+
series_unique_id: data.seriesUniqueId,
|
|
272
|
+
series_sequence: data.seriesSequence
|
|
267
273
|
}
|
|
268
274
|
});
|
|
269
275
|
return decodeOne(response, postMapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posts.service.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/posts.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EACV,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,YAAY;IAE3B,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,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,CAAC;IACxC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,WAAW,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAGjE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGvE,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGzE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAqLjG"}
|
|
@@ -51,6 +51,10 @@ export interface CreatePostRequest {
|
|
|
51
51
|
publishAt?: Date;
|
|
52
52
|
publishUntil?: Date;
|
|
53
53
|
payload?: Record<string, unknown>;
|
|
54
|
+
/** Associate post with a series. Use empty string to remove from series. */
|
|
55
|
+
seriesUniqueId?: string;
|
|
56
|
+
/** Position within the series. Auto-increments if not provided. */
|
|
57
|
+
seriesSequence?: number;
|
|
54
58
|
}
|
|
55
59
|
export interface UpdatePostRequest {
|
|
56
60
|
title?: string;
|
|
@@ -68,6 +72,10 @@ export interface UpdatePostRequest {
|
|
|
68
72
|
enabled?: boolean;
|
|
69
73
|
status?: EntityStatus;
|
|
70
74
|
payload?: Record<string, unknown>;
|
|
75
|
+
/** Associate post with a series. Use empty string to remove from series. */
|
|
76
|
+
seriesUniqueId?: string;
|
|
77
|
+
/** Position within the series. Auto-increments if not provided. */
|
|
78
|
+
seriesSequence?: number;
|
|
71
79
|
}
|
|
72
80
|
export interface ListPostsParams {
|
|
73
81
|
page?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/post.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEtE,MAAM,WAAW,IAAK,SAAQ,YAAY;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,YAAY,CAAC,EAAE,IAAI,CAAC;IAGpB,YAAY,CAAC,EAAE,MAAM,CAAC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