@23blocks/block-content 2.0.0 → 2.1.0
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.esm.js +194 -23
- package/dist/src/lib/content.block.d.ts +2 -1
- package/dist/src/lib/content.block.d.ts.map +1 -1
- package/dist/src/lib/mappers/index.d.ts +1 -0
- package/dist/src/lib/mappers/index.d.ts.map +1 -1
- package/dist/src/lib/mappers/user.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/user.mapper.d.ts.map +1 -0
- package/dist/src/lib/services/index.d.ts +1 -0
- package/dist/src/lib/services/index.d.ts.map +1 -1
- package/dist/src/lib/services/posts.service.d.ts +6 -0
- package/dist/src/lib/services/posts.service.d.ts.map +1 -1
- package/dist/src/lib/services/users.service.d.ts +24 -0
- package/dist/src/lib/services/users.service.d.ts.map +1 -0
- package/dist/src/lib/types/index.d.ts +1 -0
- package/dist/src/lib/types/index.d.ts.map +1 -1
- package/dist/src/lib/types/user.d.ts +42 -0
- package/dist/src/lib/types/user.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -167,28 +167,35 @@ const postMapper = {
|
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
function createPostsService(transport, _config) {
|
|
170
|
+
const buildQueryParams = (params)=>{
|
|
171
|
+
const queryParams = {};
|
|
172
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
173
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
174
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
175
|
+
if (params == null ? void 0 : params.categoryUniqueId) queryParams['category_unique_id'] = params.categoryUniqueId;
|
|
176
|
+
if (params == null ? void 0 : params.tagUniqueId) queryParams['tag_unique_id'] = params.tagUniqueId;
|
|
177
|
+
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
178
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
179
|
+
if ((params == null ? void 0 : params.isPublic) !== undefined) queryParams['is_public'] = String(params.isPublic);
|
|
180
|
+
if (params == null ? void 0 : params.withComments) queryParams['with'] = 'comments';
|
|
181
|
+
if (params == null ? void 0 : params.withCategories) queryParams['with'] = params.withComments ? 'comments,categories' : 'categories';
|
|
182
|
+
if (params == null ? void 0 : params.withTags) {
|
|
183
|
+
queryParams['with'] = queryParams['with'] ? `${queryParams['with']},tags` : 'tags';
|
|
184
|
+
}
|
|
185
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
186
|
+
return queryParams;
|
|
187
|
+
};
|
|
170
188
|
return {
|
|
171
189
|
async list (params) {
|
|
172
|
-
const queryParams = {};
|
|
173
|
-
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
174
|
-
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
175
|
-
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
176
|
-
if (params == null ? void 0 : params.categoryUniqueId) queryParams['category_unique_id'] = params.categoryUniqueId;
|
|
177
|
-
if (params == null ? void 0 : params.tagUniqueId) queryParams['tag_unique_id'] = params.tagUniqueId;
|
|
178
|
-
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
179
|
-
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
180
|
-
if ((params == null ? void 0 : params.isPublic) !== undefined) queryParams['is_public'] = String(params.isPublic);
|
|
181
|
-
if (params == null ? void 0 : params.withComments) queryParams['with'] = 'comments';
|
|
182
|
-
if (params == null ? void 0 : params.withCategories) queryParams['with'] = params.withComments ? 'comments,categories' : 'categories';
|
|
183
|
-
if (params == null ? void 0 : params.withTags) {
|
|
184
|
-
queryParams['with'] = queryParams['with'] ? `${queryParams['with']},tags` : 'tags';
|
|
185
|
-
}
|
|
186
|
-
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
187
190
|
const response = await transport.get('/posts', {
|
|
188
|
-
params:
|
|
191
|
+
params: buildQueryParams(params)
|
|
189
192
|
});
|
|
190
193
|
return decodePageResult(response, postMapper);
|
|
191
194
|
},
|
|
195
|
+
async query (params) {
|
|
196
|
+
const response = await transport.post('/posts/query', buildQueryParams(params));
|
|
197
|
+
return decodePageResult(response, postMapper);
|
|
198
|
+
},
|
|
192
199
|
async get (uniqueId) {
|
|
193
200
|
const response = await transport.get(`/posts/${uniqueId}`);
|
|
194
201
|
return decodeOne(response, postMapper);
|
|
@@ -235,6 +242,28 @@ function createPostsService(transport, _config) {
|
|
|
235
242
|
});
|
|
236
243
|
return decodeOne(response, postMapper);
|
|
237
244
|
},
|
|
245
|
+
async replace (uniqueId, data) {
|
|
246
|
+
const response = await transport.put(`/posts/${uniqueId}/replace`, {
|
|
247
|
+
post: {
|
|
248
|
+
title: data.title,
|
|
249
|
+
abstract: data.abstract,
|
|
250
|
+
keywords: data.keywords,
|
|
251
|
+
content: data.content,
|
|
252
|
+
thumbnail_url: data.thumbnailUrl,
|
|
253
|
+
image_url: data.imageUrl,
|
|
254
|
+
media_url: data.mediaUrl,
|
|
255
|
+
category_unique_ids: data.categoryUniqueIds,
|
|
256
|
+
tag_unique_ids: data.tagUniqueIds,
|
|
257
|
+
is_public: data.isPublic,
|
|
258
|
+
publish_at: data.publishAt,
|
|
259
|
+
publish_until: data.publishUntil,
|
|
260
|
+
enabled: data.enabled,
|
|
261
|
+
status: data.status,
|
|
262
|
+
payload: data.payload
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return decodeOne(response, postMapper);
|
|
266
|
+
},
|
|
238
267
|
async delete (uniqueId) {
|
|
239
268
|
await transport.delete(`/posts/${uniqueId}`);
|
|
240
269
|
},
|
|
@@ -264,21 +293,43 @@ function createPostsService(transport, _config) {
|
|
|
264
293
|
});
|
|
265
294
|
return decodePageResult(response, postMapper);
|
|
266
295
|
},
|
|
296
|
+
// Ownership
|
|
297
|
+
async changeOwner (uniqueId, newOwnerUniqueId) {
|
|
298
|
+
const response = await transport.put(`/posts/${uniqueId}/own`, {
|
|
299
|
+
post: {
|
|
300
|
+
new_owner_unique_id: newOwnerUniqueId
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
return decodeOne(response, postMapper);
|
|
304
|
+
},
|
|
305
|
+
// Versioning
|
|
306
|
+
async publishVersion (uniqueId, versionUniqueId) {
|
|
307
|
+
const response = await transport.post(`/posts/${uniqueId}/versions/${versionUniqueId}/publish`, {});
|
|
308
|
+
return decodeOne(response, postMapper);
|
|
309
|
+
},
|
|
267
310
|
// Engagement
|
|
268
311
|
async like (uniqueId) {
|
|
269
|
-
const response = await transport.
|
|
312
|
+
const response = await transport.put(`/posts/${uniqueId}/like`, {});
|
|
270
313
|
return decodeOne(response, postMapper);
|
|
271
314
|
},
|
|
272
315
|
async dislike (uniqueId) {
|
|
273
|
-
const response = await transport.
|
|
316
|
+
const response = await transport.delete(`/posts/${uniqueId}/dislike`);
|
|
274
317
|
return decodeOne(response, postMapper);
|
|
275
318
|
},
|
|
276
319
|
async save (uniqueId) {
|
|
277
|
-
const response = await transport.
|
|
320
|
+
const response = await transport.put(`/posts/${uniqueId}/save`, {});
|
|
321
|
+
return decodeOne(response, postMapper);
|
|
322
|
+
},
|
|
323
|
+
async unsave (uniqueId) {
|
|
324
|
+
const response = await transport.delete(`/posts/${uniqueId}/unsave`);
|
|
278
325
|
return decodeOne(response, postMapper);
|
|
279
326
|
},
|
|
280
327
|
async follow (uniqueId) {
|
|
281
|
-
const response = await transport.
|
|
328
|
+
const response = await transport.put(`/posts/${uniqueId}/follow`, {});
|
|
329
|
+
return decodeOne(response, postMapper);
|
|
330
|
+
},
|
|
331
|
+
async unfollow (uniqueId) {
|
|
332
|
+
const response = await transport.delete(`/posts/${uniqueId}/unfollow`);
|
|
282
333
|
return decodeOne(response, postMapper);
|
|
283
334
|
}
|
|
284
335
|
};
|
|
@@ -554,23 +605,143 @@ function createTagsService(transport, _config) {
|
|
|
554
605
|
};
|
|
555
606
|
}
|
|
556
607
|
|
|
608
|
+
const contentUserMapper = {
|
|
609
|
+
type: 'user',
|
|
610
|
+
map: (data)=>{
|
|
611
|
+
var _data_id, _data_unique_id, _data_name, _data_email, _data_posts_count, _data_comments_count, _data_followers_count, _data_following_count, _data_status;
|
|
612
|
+
return {
|
|
613
|
+
id: String((_data_id = data['id']) != null ? _data_id : ''),
|
|
614
|
+
uniqueId: String((_data_unique_id = data['unique_id']) != null ? _data_unique_id : ''),
|
|
615
|
+
name: String((_data_name = data['name']) != null ? _data_name : ''),
|
|
616
|
+
email: String((_data_email = data['email']) != null ? _data_email : ''),
|
|
617
|
+
avatarUrl: data['avatar_url'],
|
|
618
|
+
bio: data['bio'],
|
|
619
|
+
postsCount: Number((_data_posts_count = data['posts_count']) != null ? _data_posts_count : 0),
|
|
620
|
+
commentsCount: Number((_data_comments_count = data['comments_count']) != null ? _data_comments_count : 0),
|
|
621
|
+
followersCount: Number((_data_followers_count = data['followers_count']) != null ? _data_followers_count : 0),
|
|
622
|
+
followingCount: Number((_data_following_count = data['following_count']) != null ? _data_following_count : 0),
|
|
623
|
+
status: (_data_status = data['status']) != null ? _data_status : 'active',
|
|
624
|
+
payload: data['payload'],
|
|
625
|
+
createdAt: data['created_at'] ? new Date(data['created_at']) : new Date(),
|
|
626
|
+
updatedAt: data['updated_at'] ? new Date(data['updated_at']) : new Date()
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
function createContentUsersService(transport, _config) {
|
|
632
|
+
return {
|
|
633
|
+
async list (params) {
|
|
634
|
+
const queryParams = {};
|
|
635
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
636
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
637
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
638
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
639
|
+
const response = await transport.get('/identities', {
|
|
640
|
+
params: queryParams
|
|
641
|
+
});
|
|
642
|
+
return decodePageResult(response, contentUserMapper);
|
|
643
|
+
},
|
|
644
|
+
async get (uniqueId) {
|
|
645
|
+
const response = await transport.get(`/identities/${uniqueId}`);
|
|
646
|
+
return decodeOne(response, contentUserMapper);
|
|
647
|
+
},
|
|
648
|
+
async register (uniqueId, data) {
|
|
649
|
+
const response = await transport.post(`/identities/${uniqueId}/register`, {
|
|
650
|
+
user: {
|
|
651
|
+
email: data.email,
|
|
652
|
+
name: data.name,
|
|
653
|
+
avatar_url: data.avatarUrl,
|
|
654
|
+
bio: data.bio,
|
|
655
|
+
payload: data.payload
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
return decodeOne(response, contentUserMapper);
|
|
659
|
+
},
|
|
660
|
+
async update (uniqueId, data) {
|
|
661
|
+
const response = await transport.put(`/identities/${uniqueId}`, {
|
|
662
|
+
user: {
|
|
663
|
+
name: data.name,
|
|
664
|
+
avatar_url: data.avatarUrl,
|
|
665
|
+
bio: data.bio,
|
|
666
|
+
payload: data.payload
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
return decodeOne(response, contentUserMapper);
|
|
670
|
+
},
|
|
671
|
+
async getDrafts (uniqueId) {
|
|
672
|
+
const response = await transport.get(`/identities/${uniqueId}/drafts`);
|
|
673
|
+
return decodeMany(response, postMapper);
|
|
674
|
+
},
|
|
675
|
+
async getPosts (uniqueId) {
|
|
676
|
+
const response = await transport.get(`/identities/${uniqueId}/posts`);
|
|
677
|
+
return decodeMany(response, postMapper);
|
|
678
|
+
},
|
|
679
|
+
async getComments (uniqueId) {
|
|
680
|
+
const response = await transport.get(`/identities/${uniqueId}/comments`);
|
|
681
|
+
return decodeMany(response, commentMapper);
|
|
682
|
+
},
|
|
683
|
+
async getActivities (uniqueId) {
|
|
684
|
+
const response = await transport.get(`/identities/${uniqueId}/activities`);
|
|
685
|
+
return (response.data || []).map((item)=>{
|
|
686
|
+
var _item_unique_id, _item_activity_type, _item_target_type, _item_target_unique_id;
|
|
687
|
+
return {
|
|
688
|
+
uniqueId: String((_item_unique_id = item['unique_id']) != null ? _item_unique_id : ''),
|
|
689
|
+
activityType: String((_item_activity_type = item['activity_type']) != null ? _item_activity_type : ''),
|
|
690
|
+
targetType: String((_item_target_type = item['target_type']) != null ? _item_target_type : ''),
|
|
691
|
+
targetUniqueId: String((_item_target_unique_id = item['target_unique_id']) != null ? _item_target_unique_id : ''),
|
|
692
|
+
description: item['description'],
|
|
693
|
+
createdAt: new Date(item['created_at']),
|
|
694
|
+
payload: item['payload']
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
},
|
|
698
|
+
async addTag (uniqueId, tagUniqueId) {
|
|
699
|
+
const response = await transport.post(`/identities/${uniqueId}/tags`, {
|
|
700
|
+
tag: {
|
|
701
|
+
unique_id: tagUniqueId
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
return decodeOne(response, contentUserMapper);
|
|
705
|
+
},
|
|
706
|
+
async removeTag (uniqueId, tagUniqueId) {
|
|
707
|
+
await transport.delete(`/identities/${uniqueId}/tags/${tagUniqueId}`);
|
|
708
|
+
},
|
|
709
|
+
async getFollowers (uniqueId) {
|
|
710
|
+
const response = await transport.get(`/identities/${uniqueId}/followers`);
|
|
711
|
+
return decodeMany(response, contentUserMapper);
|
|
712
|
+
},
|
|
713
|
+
async getFollowing (uniqueId) {
|
|
714
|
+
const response = await transport.get(`/identities/${uniqueId}/following`);
|
|
715
|
+
return decodeMany(response, contentUserMapper);
|
|
716
|
+
},
|
|
717
|
+
async followUser (uniqueId, targetUserUniqueId) {
|
|
718
|
+
await transport.post(`/identities/${uniqueId}/follows/${targetUserUniqueId}`, {});
|
|
719
|
+
},
|
|
720
|
+
async unfollowUser (uniqueId, targetUserUniqueId) {
|
|
721
|
+
await transport.delete(`/identities/${uniqueId}/unfollows/${targetUserUniqueId}`);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
557
726
|
function createContentBlock(transport, config) {
|
|
558
727
|
return {
|
|
559
728
|
posts: createPostsService(transport),
|
|
560
729
|
comments: createCommentsService(transport),
|
|
561
730
|
categories: createCategoriesService(transport),
|
|
562
|
-
tags: createTagsService(transport)
|
|
731
|
+
tags: createTagsService(transport),
|
|
732
|
+
users: createContentUsersService(transport)
|
|
563
733
|
};
|
|
564
734
|
}
|
|
565
735
|
const contentBlockMetadata = {
|
|
566
736
|
name: 'content',
|
|
567
737
|
version: '0.1.0',
|
|
568
|
-
description: 'Content management for posts, comments, categories, and
|
|
738
|
+
description: 'Content management for posts, comments, categories, tags, and users',
|
|
569
739
|
resourceTypes: [
|
|
570
740
|
'Post',
|
|
571
741
|
'Comment',
|
|
572
742
|
'Category',
|
|
573
|
-
'Tag'
|
|
743
|
+
'Tag',
|
|
744
|
+
'ContentUser'
|
|
574
745
|
]
|
|
575
746
|
};
|
|
576
747
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Transport, BlockConfig, BlockMetadata } from '@23blocks/contracts';
|
|
2
|
-
import { type PostsService, type CommentsService, type CategoriesService, type TagsService } from './services';
|
|
2
|
+
import { type PostsService, type CommentsService, type CategoriesService, type TagsService, type ContentUsersService } from './services';
|
|
3
3
|
export interface ContentBlockConfig extends BlockConfig {
|
|
4
4
|
appId: string;
|
|
5
5
|
tenantId?: string;
|
|
@@ -9,6 +9,7 @@ export interface ContentBlock {
|
|
|
9
9
|
comments: CommentsService;
|
|
10
10
|
categories: CategoriesService;
|
|
11
11
|
tags: TagsService;
|
|
12
|
+
users: ContentUsersService;
|
|
12
13
|
}
|
|
13
14
|
export declare function createContentBlock(transport: Transport, config: ContentBlockConfig): ContentBlock;
|
|
14
15
|
export declare const contentBlockMetadata: BlockMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.block.d.ts","sourceRoot":"","sources":["../../../src/lib/content.block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"content.block.d.ts","sourceRoot":"","sources":["../../../src/lib/content.block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,mBAAmB,CAAC;CAC5B;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,GACzB,YAAY,CAQd;AAED,eAAO,MAAM,oBAAoB,EAAE,aAWlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.mapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/mappers/user.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,WAAW,CAkBhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -2,17 +2,23 @@ import type { Transport, PageResult } from '@23blocks/contracts';
|
|
|
2
2
|
import type { Post, CreatePostRequest, UpdatePostRequest, ListPostsParams } from '../types/post';
|
|
3
3
|
export interface PostsService {
|
|
4
4
|
list(params?: ListPostsParams): Promise<PageResult<Post>>;
|
|
5
|
+
query(params: ListPostsParams): Promise<PageResult<Post>>;
|
|
5
6
|
get(uniqueId: string): Promise<Post>;
|
|
6
7
|
create(data: CreatePostRequest): Promise<Post>;
|
|
7
8
|
update(uniqueId: string, data: UpdatePostRequest): Promise<Post>;
|
|
9
|
+
replace(uniqueId: string, data: UpdatePostRequest): Promise<Post>;
|
|
8
10
|
delete(uniqueId: string): Promise<void>;
|
|
9
11
|
recover(uniqueId: string): Promise<Post>;
|
|
10
12
|
search(query: string, params?: ListPostsParams): Promise<PageResult<Post>>;
|
|
11
13
|
listDeleted(params?: ListPostsParams): Promise<PageResult<Post>>;
|
|
14
|
+
changeOwner(uniqueId: string, newOwnerUniqueId: string): Promise<Post>;
|
|
15
|
+
publishVersion(uniqueId: string, versionUniqueId: string): Promise<Post>;
|
|
12
16
|
like(uniqueId: string): Promise<Post>;
|
|
13
17
|
dislike(uniqueId: string): Promise<Post>;
|
|
14
18
|
save(uniqueId: string): Promise<Post>;
|
|
19
|
+
unsave(uniqueId: string): Promise<Post>;
|
|
15
20
|
follow(uniqueId: string): Promise<Post>;
|
|
21
|
+
unfollow(uniqueId: string): Promise<Post>;
|
|
16
22
|
}
|
|
17
23
|
export declare function createPostsService(transport: Transport, _config: {
|
|
18
24
|
appId: string;
|
|
@@ -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,CAAC,CAAC;IAC1D,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,CAAC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AC;CAC3C;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CA+KjG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Transport, PageResult } from '@23blocks/contracts';
|
|
2
|
+
import type { ContentUser, RegisterContentUserRequest, UpdateContentUserRequest, ListContentUsersParams, UserActivity } from '../types/user';
|
|
3
|
+
import type { Post } from '../types/post';
|
|
4
|
+
import type { Comment } from '../types/comment';
|
|
5
|
+
export interface ContentUsersService {
|
|
6
|
+
list(params?: ListContentUsersParams): Promise<PageResult<ContentUser>>;
|
|
7
|
+
get(uniqueId: string): Promise<ContentUser>;
|
|
8
|
+
register(uniqueId: string, data: RegisterContentUserRequest): Promise<ContentUser>;
|
|
9
|
+
update(uniqueId: string, data: UpdateContentUserRequest): Promise<ContentUser>;
|
|
10
|
+
getDrafts(uniqueId: string): Promise<Post[]>;
|
|
11
|
+
getPosts(uniqueId: string): Promise<Post[]>;
|
|
12
|
+
getComments(uniqueId: string): Promise<Comment[]>;
|
|
13
|
+
getActivities(uniqueId: string): Promise<UserActivity[]>;
|
|
14
|
+
addTag(uniqueId: string, tagUniqueId: string): Promise<ContentUser>;
|
|
15
|
+
removeTag(uniqueId: string, tagUniqueId: string): Promise<void>;
|
|
16
|
+
getFollowers(uniqueId: string): Promise<ContentUser[]>;
|
|
17
|
+
getFollowing(uniqueId: string): Promise<ContentUser[]>;
|
|
18
|
+
followUser(uniqueId: string, targetUserUniqueId: string): Promise<void>;
|
|
19
|
+
unfollowUser(uniqueId: string, targetUserUniqueId: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createContentUsersService(transport: Transport, _config: {
|
|
22
|
+
appId: string;
|
|
23
|
+
}): ContentUsersService;
|
|
24
|
+
//# sourceMappingURL=users.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.service.d.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,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACvD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACvD,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,mBAAmB,CAoG/G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { IdentityCore, EntityStatus } from '@23blocks/contracts';
|
|
2
|
+
export interface ContentUser extends IdentityCore {
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
avatarUrl?: string;
|
|
6
|
+
bio?: string;
|
|
7
|
+
postsCount: number;
|
|
8
|
+
commentsCount: number;
|
|
9
|
+
followersCount: number;
|
|
10
|
+
followingCount: number;
|
|
11
|
+
status: EntityStatus;
|
|
12
|
+
payload?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface RegisterContentUserRequest {
|
|
15
|
+
email: string;
|
|
16
|
+
name: string;
|
|
17
|
+
avatarUrl?: string;
|
|
18
|
+
bio?: string;
|
|
19
|
+
payload?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface UpdateContentUserRequest {
|
|
22
|
+
name?: string;
|
|
23
|
+
avatarUrl?: string;
|
|
24
|
+
bio?: string;
|
|
25
|
+
payload?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface ListContentUsersParams {
|
|
28
|
+
page?: number;
|
|
29
|
+
perPage?: number;
|
|
30
|
+
status?: string;
|
|
31
|
+
search?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface UserActivity {
|
|
34
|
+
uniqueId: string;
|
|
35
|
+
activityType: string;
|
|
36
|
+
targetType: string;
|
|
37
|
+
targetUniqueId: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
payload?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAItE,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,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