@23blocks/block-content 3.3.1 → 3.3.3
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 +403 -101
- package/dist/src/lib/content.block.d.ts +3 -1
- package/dist/src/lib/content.block.d.ts.map +1 -1
- package/dist/src/lib/mappers/category.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/index.d.ts +2 -0
- package/dist/src/lib/mappers/index.d.ts.map +1 -1
- package/dist/src/lib/mappers/post-version.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/post-version.mapper.d.ts.map +1 -0
- package/dist/src/lib/mappers/post.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/series.mapper.d.ts +4 -0
- package/dist/src/lib/mappers/series.mapper.d.ts.map +1 -0
- package/dist/src/lib/mappers/user.mapper.d.ts +4 -3
- package/dist/src/lib/mappers/user.mapper.d.ts.map +1 -1
- package/dist/src/lib/services/categories.service.d.ts +11 -5
- package/dist/src/lib/services/categories.service.d.ts.map +1 -1
- package/dist/src/lib/services/comments.service.d.ts +30 -12
- package/dist/src/lib/services/comments.service.d.ts.map +1 -1
- package/dist/src/lib/services/index.d.ts +2 -0
- package/dist/src/lib/services/index.d.ts.map +1 -1
- package/dist/src/lib/services/post-versions.service.d.ts +20 -0
- package/dist/src/lib/services/post-versions.service.d.ts.map +1 -0
- package/dist/src/lib/services/series.service.d.ts +25 -0
- package/dist/src/lib/services/series.service.d.ts.map +1 -0
- package/dist/src/lib/services/users.service.d.ts +3 -3
- package/dist/src/lib/services/users.service.d.ts.map +1 -1
- package/dist/src/lib/types/category.d.ts +11 -16
- package/dist/src/lib/types/category.d.ts.map +1 -1
- package/dist/src/lib/types/comment.d.ts +1 -2
- package/dist/src/lib/types/comment.d.ts.map +1 -1
- package/dist/src/lib/types/index.d.ts +2 -0
- package/dist/src/lib/types/index.d.ts.map +1 -1
- package/dist/src/lib/types/post-version.d.ts +41 -0
- package/dist/src/lib/types/post-version.d.ts.map +1 -0
- package/dist/src/lib/types/post.d.ts +3 -0
- package/dist/src/lib/types/post.d.ts.map +1 -1
- package/dist/src/lib/types/series.d.ts +69 -0
- package/dist/src/lib/types/series.d.ts.map +1 -0
- package/dist/src/lib/types/user.d.ts +57 -8
- package/dist/src/lib/types/user.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '@swc/helpers/_/_extends';
|
|
1
|
+
import { _ } from '@swc/helpers/_/_extends';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Type guard for single resource document
|
|
@@ -162,7 +162,11 @@ const postMapper = {
|
|
|
162
162
|
moderatedBy: parseString(resource.attributes['moderated_by']),
|
|
163
163
|
moderatedAt: parseDate(resource.attributes['moderated_at']),
|
|
164
164
|
moderationReason: parseString(resource.attributes['moderation_reason']),
|
|
165
|
-
moderationDecision: parseString(resource.attributes['moderation_decision'])
|
|
165
|
+
moderationDecision: parseString(resource.attributes['moderation_decision']),
|
|
166
|
+
// Series
|
|
167
|
+
seriesId: parseOptionalNumber(resource.attributes['series_id']),
|
|
168
|
+
seriesUniqueId: parseString(resource.attributes['series_unique_id']),
|
|
169
|
+
seriesSequence: parseOptionalNumber(resource.attributes['series_sequence'])
|
|
166
170
|
})
|
|
167
171
|
};
|
|
168
172
|
|
|
@@ -335,6 +339,115 @@ function createPostsService(transport, _config) {
|
|
|
335
339
|
};
|
|
336
340
|
}
|
|
337
341
|
|
|
342
|
+
const postVersionMapper = {
|
|
343
|
+
type: 'PostVersion',
|
|
344
|
+
map: (resource)=>({
|
|
345
|
+
id: resource.id,
|
|
346
|
+
uniqueId: parseString(resource.attributes['unique_id']),
|
|
347
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
348
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
349
|
+
postUniqueId: parseString(resource.attributes['post_unique_id']) || '',
|
|
350
|
+
// Content
|
|
351
|
+
title: parseString(resource.attributes['title']) || '',
|
|
352
|
+
abstract: parseString(resource.attributes['abstract']),
|
|
353
|
+
keywords: parseString(resource.attributes['keywords']),
|
|
354
|
+
content: parseString(resource.attributes['content']),
|
|
355
|
+
// Media
|
|
356
|
+
thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
|
|
357
|
+
imageUrl: parseString(resource.attributes['image_url']),
|
|
358
|
+
mediaUrl: parseString(resource.attributes['media_url']),
|
|
359
|
+
// Metadata
|
|
360
|
+
payload: resource.attributes['payload'],
|
|
361
|
+
status: parseStatus(resource.attributes['status']),
|
|
362
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
363
|
+
// Publishing
|
|
364
|
+
publishAt: parseDate(resource.attributes['publish_at']),
|
|
365
|
+
publishUntil: parseDate(resource.attributes['publish_until']),
|
|
366
|
+
// Author
|
|
367
|
+
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
368
|
+
userName: parseString(resource.attributes['user_name']),
|
|
369
|
+
userAlias: parseString(resource.attributes['user_alias']),
|
|
370
|
+
userAvatarUrl: parseString(resource.attributes['user_avatar_url']),
|
|
371
|
+
// Visibility
|
|
372
|
+
isPublic: parseBoolean(resource.attributes['is_public']),
|
|
373
|
+
// Versioning
|
|
374
|
+
version: parseOptionalNumber(resource.attributes['version']),
|
|
375
|
+
revision: parseOptionalNumber(resource.attributes['revision']),
|
|
376
|
+
source: parseString(resource.attributes['source']),
|
|
377
|
+
// AI
|
|
378
|
+
aiGenerated: parseBoolean(resource.attributes['ai_generated']),
|
|
379
|
+
aiModel: parseString(resource.attributes['ai_model']),
|
|
380
|
+
// Moderation
|
|
381
|
+
moderated: parseBoolean(resource.attributes['moderated']),
|
|
382
|
+
moderatedBy: parseString(resource.attributes['moderated_by']),
|
|
383
|
+
moderatedAt: parseDate(resource.attributes['moderated_at']),
|
|
384
|
+
moderationReason: parseString(resource.attributes['moderation_reason']),
|
|
385
|
+
moderationDecision: parseString(resource.attributes['moderation_decision'])
|
|
386
|
+
})
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
function createPostVersionsService(transport, _config) {
|
|
390
|
+
return {
|
|
391
|
+
async list (postUniqueId, params) {
|
|
392
|
+
const queryParams = {};
|
|
393
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
394
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
395
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
396
|
+
// Note: The API may not have a dedicated versions list endpoint
|
|
397
|
+
// This uses the post_versions relationship from the post
|
|
398
|
+
const response = await transport.get(`/posts/${postUniqueId}`, {
|
|
399
|
+
params: _({}, queryParams, {
|
|
400
|
+
include: 'post_versions'
|
|
401
|
+
})
|
|
402
|
+
});
|
|
403
|
+
// Extract versions from included relationships
|
|
404
|
+
const data = response;
|
|
405
|
+
if (data.included) {
|
|
406
|
+
const versions = data.included.filter((item)=>{
|
|
407
|
+
const typed = item;
|
|
408
|
+
return typed.type === 'PostVersion' || typed.type === 'post_version';
|
|
409
|
+
});
|
|
410
|
+
return {
|
|
411
|
+
data: versions.map((v)=>postVersionMapper.map(v)),
|
|
412
|
+
meta: {
|
|
413
|
+
total: versions.length,
|
|
414
|
+
page: 1,
|
|
415
|
+
perPage: versions.length
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
data: [],
|
|
421
|
+
meta: {
|
|
422
|
+
total: 0,
|
|
423
|
+
page: 1,
|
|
424
|
+
perPage: 10
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
},
|
|
428
|
+
async get (postUniqueId, versionUniqueId) {
|
|
429
|
+
// Get post with versions included and find the specific one
|
|
430
|
+
const response = await transport.get(`/posts/${postUniqueId}`, {
|
|
431
|
+
params: {
|
|
432
|
+
include: 'post_versions'
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
const data = response;
|
|
436
|
+
if (data.included) {
|
|
437
|
+
const version = data.included.find((item)=>(item.type === 'PostVersion' || item.type === 'post_version') && (item.attributes['unique_id'] === versionUniqueId || item.id === versionUniqueId));
|
|
438
|
+
if (version) {
|
|
439
|
+
return postVersionMapper.map(version);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
throw new Error(`Version ${versionUniqueId} not found for post ${postUniqueId}`);
|
|
443
|
+
},
|
|
444
|
+
async publish (postUniqueId, versionUniqueId) {
|
|
445
|
+
const response = await transport.post(`/posts/${postUniqueId}/versions/${versionUniqueId}/publish`, {});
|
|
446
|
+
return decodeOne(response, postVersionMapper);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
338
451
|
const commentMapper = {
|
|
339
452
|
type: 'Comment',
|
|
340
453
|
map: (resource)=>({
|
|
@@ -378,27 +491,25 @@ const commentMapper = {
|
|
|
378
491
|
|
|
379
492
|
function createCommentsService(transport, _config) {
|
|
380
493
|
return {
|
|
381
|
-
async list (params) {
|
|
494
|
+
async list (postUniqueId, params) {
|
|
382
495
|
const queryParams = {};
|
|
383
496
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
384
497
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
385
|
-
if (params == null ? void 0 : params.postUniqueId) queryParams['post_unique_id'] = params.postUniqueId;
|
|
386
498
|
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
387
499
|
if (params == null ? void 0 : params.parentId) queryParams['parent_id'] = params.parentId;
|
|
388
500
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
389
|
-
const response = await transport.get(
|
|
501
|
+
const response = await transport.get(`/posts/${postUniqueId}/comments`, {
|
|
390
502
|
params: queryParams
|
|
391
503
|
});
|
|
392
504
|
return decodePageResult(response, commentMapper);
|
|
393
505
|
},
|
|
394
|
-
async get (uniqueId) {
|
|
395
|
-
const response = await transport.get(`/comments/${uniqueId}`);
|
|
506
|
+
async get (postUniqueId, uniqueId) {
|
|
507
|
+
const response = await transport.get(`/posts/${postUniqueId}/comments/${uniqueId}`);
|
|
396
508
|
return decodeOne(response, commentMapper);
|
|
397
509
|
},
|
|
398
|
-
async create (data) {
|
|
399
|
-
const response = await transport.post(
|
|
510
|
+
async create (postUniqueId, data) {
|
|
511
|
+
const response = await transport.post(`/posts/${postUniqueId}/comments`, {
|
|
400
512
|
comment: {
|
|
401
|
-
post_unique_id: data.postUniqueId,
|
|
402
513
|
content: data.content,
|
|
403
514
|
thumbnail_url: data.thumbnailUrl,
|
|
404
515
|
image_url: data.imageUrl,
|
|
@@ -410,8 +521,8 @@ function createCommentsService(transport, _config) {
|
|
|
410
521
|
});
|
|
411
522
|
return decodeOne(response, commentMapper);
|
|
412
523
|
},
|
|
413
|
-
async update (uniqueId, data) {
|
|
414
|
-
const response = await transport.put(`/comments/${uniqueId}`, {
|
|
524
|
+
async update (postUniqueId, uniqueId, data) {
|
|
525
|
+
const response = await transport.put(`/posts/${postUniqueId}/comments/${uniqueId}`, {
|
|
415
526
|
comment: {
|
|
416
527
|
content: data.content,
|
|
417
528
|
thumbnail_url: data.thumbnailUrl,
|
|
@@ -425,47 +536,45 @@ function createCommentsService(transport, _config) {
|
|
|
425
536
|
});
|
|
426
537
|
return decodeOne(response, commentMapper);
|
|
427
538
|
},
|
|
428
|
-
async delete (uniqueId) {
|
|
429
|
-
await transport.delete(`/comments/${uniqueId}`);
|
|
539
|
+
async delete (postUniqueId, uniqueId) {
|
|
540
|
+
await transport.delete(`/posts/${postUniqueId}/comments/${uniqueId}`);
|
|
430
541
|
},
|
|
431
|
-
async reply (parentCommentUniqueId, data) {
|
|
432
|
-
const response = await transport.post(
|
|
542
|
+
async reply (postUniqueId, parentCommentUniqueId, data) {
|
|
543
|
+
const response = await transport.post(`/posts/${postUniqueId}/comments/${parentCommentUniqueId}/reply`, {
|
|
433
544
|
comment: {
|
|
434
|
-
post_unique_id: data.postUniqueId,
|
|
435
545
|
content: data.content,
|
|
436
546
|
thumbnail_url: data.thumbnailUrl,
|
|
437
547
|
image_url: data.imageUrl,
|
|
438
548
|
content_url: data.contentUrl,
|
|
439
549
|
media_url: data.mediaUrl,
|
|
440
|
-
parent_id: parentCommentUniqueId,
|
|
441
550
|
payload: data.payload
|
|
442
551
|
}
|
|
443
552
|
});
|
|
444
553
|
return decodeOne(response, commentMapper);
|
|
445
554
|
},
|
|
446
555
|
// Engagement
|
|
447
|
-
async like (uniqueId) {
|
|
448
|
-
const response = await transport.
|
|
556
|
+
async like (postUniqueId, uniqueId) {
|
|
557
|
+
const response = await transport.put(`/posts/${postUniqueId}/comments/${uniqueId}/like`, {});
|
|
449
558
|
return decodeOne(response, commentMapper);
|
|
450
559
|
},
|
|
451
|
-
async dislike (uniqueId) {
|
|
452
|
-
const response = await transport.
|
|
560
|
+
async dislike (postUniqueId, uniqueId) {
|
|
561
|
+
const response = await transport.put(`/posts/${postUniqueId}/comments/${uniqueId}/dislike`, {});
|
|
453
562
|
return decodeOne(response, commentMapper);
|
|
454
563
|
},
|
|
455
|
-
async save (uniqueId) {
|
|
456
|
-
const response = await transport.put(`/comments/${uniqueId}/save`, {});
|
|
564
|
+
async save (postUniqueId, uniqueId) {
|
|
565
|
+
const response = await transport.put(`/posts/${postUniqueId}/comments/${uniqueId}/save`, {});
|
|
457
566
|
return decodeOne(response, commentMapper);
|
|
458
567
|
},
|
|
459
|
-
async unsave (uniqueId) {
|
|
460
|
-
const response = await transport.delete(`/comments/${uniqueId}/unsave`);
|
|
568
|
+
async unsave (postUniqueId, uniqueId) {
|
|
569
|
+
const response = await transport.delete(`/posts/${postUniqueId}/comments/${uniqueId}/unsave`);
|
|
461
570
|
return decodeOne(response, commentMapper);
|
|
462
571
|
},
|
|
463
|
-
async follow (uniqueId) {
|
|
464
|
-
const response = await transport.put(`/comments/${uniqueId}/follow`, {});
|
|
572
|
+
async follow (postUniqueId, uniqueId) {
|
|
573
|
+
const response = await transport.put(`/posts/${postUniqueId}/comments/${uniqueId}/follow`, {});
|
|
465
574
|
return decodeOne(response, commentMapper);
|
|
466
575
|
},
|
|
467
|
-
async unfollow (uniqueId) {
|
|
468
|
-
const response = await transport.delete(`/comments/${uniqueId}/unfollow`);
|
|
576
|
+
async unfollow (postUniqueId, uniqueId) {
|
|
577
|
+
const response = await transport.delete(`/posts/${postUniqueId}/comments/${uniqueId}/unfollow`);
|
|
469
578
|
return decodeOne(response, commentMapper);
|
|
470
579
|
}
|
|
471
580
|
};
|
|
@@ -478,29 +587,19 @@ const categoryMapper = {
|
|
|
478
587
|
uniqueId: parseString(resource.attributes['unique_id']),
|
|
479
588
|
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
480
589
|
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
481
|
-
|
|
590
|
+
// Core fields from API
|
|
591
|
+
code: parseString(resource.attributes['code']),
|
|
482
592
|
name: parseString(resource.attributes['name']) || '',
|
|
483
593
|
description: parseString(resource.attributes['description']),
|
|
594
|
+
// Hierarchy
|
|
484
595
|
parentId: parseString(resource.attributes['parent_id']),
|
|
485
|
-
parentUniqueId: parseString(resource.attributes['parent_unique_id']),
|
|
486
596
|
// Display
|
|
487
597
|
displayOrder: parseOptionalNumber(resource.attributes['display_order']),
|
|
488
|
-
iconUrl: parseString(resource.attributes['icon_url']),
|
|
489
598
|
imageUrl: parseString(resource.attributes['image_url']),
|
|
490
599
|
contentUrl: parseString(resource.attributes['content_url']),
|
|
491
|
-
slug: parseString(resource.attributes['slug']),
|
|
492
600
|
// Business Logic
|
|
493
601
|
status: parseStatus(resource.attributes['status']),
|
|
494
602
|
enabled: parseBoolean(resource.attributes['enabled']),
|
|
495
|
-
// SEO
|
|
496
|
-
metaTitle: parseString(resource.attributes['meta_title']),
|
|
497
|
-
metaDescription: parseString(resource.attributes['meta_description']),
|
|
498
|
-
metaKeywords: parseString(resource.attributes['meta_keywords']),
|
|
499
|
-
// Source
|
|
500
|
-
source: parseString(resource.attributes['source']),
|
|
501
|
-
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
502
|
-
sourceId: parseString(resource.attributes['source_id']),
|
|
503
|
-
sourceType: parseString(resource.attributes['source_type']),
|
|
504
603
|
// Extra
|
|
505
604
|
payload: resource.attributes['payload'],
|
|
506
605
|
postCount: parseOptionalNumber(resource.attributes['post_count'])
|
|
@@ -513,56 +612,34 @@ function createCategoriesService(transport, _config) {
|
|
|
513
612
|
const queryParams = {};
|
|
514
613
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
515
614
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
516
|
-
if (params == null ? void 0 : params.
|
|
615
|
+
if (params == null ? void 0 : params.parentId) queryParams['parent_id'] = params.parentId;
|
|
517
616
|
if (params == null ? void 0 : params.withChildren) queryParams['with'] = 'children';
|
|
518
|
-
if (params == null ? void 0 : params.withPosts)
|
|
519
|
-
|
|
617
|
+
if (params == null ? void 0 : params.withPosts) {
|
|
618
|
+
queryParams['with'] = params.withChildren ? 'children,posts' : 'posts';
|
|
619
|
+
}
|
|
620
|
+
const response = await transport.get('/categories', {
|
|
520
621
|
params: queryParams
|
|
521
622
|
});
|
|
522
623
|
return decodePageResult(response, categoryMapper);
|
|
523
624
|
},
|
|
524
625
|
async get (uniqueId) {
|
|
525
|
-
const response = await transport.get(`/
|
|
626
|
+
const response = await transport.get(`/categories/${uniqueId}`);
|
|
526
627
|
return decodeOne(response, categoryMapper);
|
|
527
628
|
},
|
|
528
629
|
async create (data) {
|
|
529
|
-
const response = await transport.post('/
|
|
630
|
+
const response = await transport.post('/categories', {
|
|
530
631
|
category: {
|
|
632
|
+
code: data.code,
|
|
531
633
|
name: data.name,
|
|
532
634
|
description: data.description,
|
|
533
|
-
|
|
534
|
-
display_order: data.displayOrder,
|
|
535
|
-
image_url: data.imageUrl,
|
|
536
|
-
icon_url: data.iconUrl
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
return decodeOne(response, categoryMapper);
|
|
540
|
-
},
|
|
541
|
-
async update (uniqueId, data) {
|
|
542
|
-
const response = await transport.put(`/content/categories/${uniqueId}`, {
|
|
543
|
-
category: {
|
|
544
|
-
name: data.name,
|
|
545
|
-
description: data.description,
|
|
546
|
-
parent_unique_id: data.parentUniqueId,
|
|
635
|
+
parent_id: data.parentId,
|
|
547
636
|
display_order: data.displayOrder,
|
|
548
637
|
image_url: data.imageUrl,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
status: data.status
|
|
638
|
+
content_url: data.contentUrl,
|
|
639
|
+
payload: data.payload
|
|
552
640
|
}
|
|
553
641
|
});
|
|
554
642
|
return decodeOne(response, categoryMapper);
|
|
555
|
-
},
|
|
556
|
-
async delete (uniqueId) {
|
|
557
|
-
await transport.delete(`/content/categories/${uniqueId}`);
|
|
558
|
-
},
|
|
559
|
-
async recover (uniqueId) {
|
|
560
|
-
const response = await transport.put(`/content/categories/${uniqueId}/recover`, {});
|
|
561
|
-
return decodeOne(response, categoryMapper);
|
|
562
|
-
},
|
|
563
|
-
async getChildren (uniqueId) {
|
|
564
|
-
const response = await transport.get(`/content/categories/${uniqueId}/children`);
|
|
565
|
-
return decodeMany(response, categoryMapper);
|
|
566
643
|
}
|
|
567
644
|
};
|
|
568
645
|
}
|
|
@@ -637,26 +714,69 @@ function createTagsService(transport, _config) {
|
|
|
637
714
|
}
|
|
638
715
|
|
|
639
716
|
const contentUserMapper = {
|
|
640
|
-
type: '
|
|
641
|
-
map: (
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
717
|
+
type: 'UserIdentity',
|
|
718
|
+
map: (resource)=>({
|
|
719
|
+
id: resource.id,
|
|
720
|
+
uniqueId: parseString(resource.attributes['unique_id']),
|
|
721
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
722
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
723
|
+
// Name fields
|
|
724
|
+
firstName: parseString(resource.attributes['first_name']),
|
|
725
|
+
lastName: parseString(resource.attributes['last_name']),
|
|
726
|
+
name: parseString(resource.attributes['user_name']) || parseString(resource.attributes['name']),
|
|
727
|
+
// Contact
|
|
728
|
+
email: parseString(resource.attributes['email']),
|
|
729
|
+
phone: parseString(resource.attributes['phone']),
|
|
730
|
+
// Identity references
|
|
731
|
+
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
732
|
+
userName: parseString(resource.attributes['user_name']),
|
|
733
|
+
avatarUrl: parseString(resource.attributes['avatar_url']),
|
|
734
|
+
// Role
|
|
735
|
+
roleName: parseString(resource.attributes['role_name']),
|
|
736
|
+
roleUniqueId: parseString(resource.attributes['role_unique_id']),
|
|
737
|
+
// Preferences
|
|
738
|
+
timeZone: parseString(resource.attributes['time_zone']),
|
|
739
|
+
preferredLanguage: parseString(resource.attributes['preferred_language']),
|
|
740
|
+
// Integrations
|
|
741
|
+
stripeId: parseString(resource.attributes['stripe_id']),
|
|
742
|
+
walletCode: parseString(resource.attributes['wallet_code']),
|
|
743
|
+
// Notification preferences
|
|
744
|
+
emailNotifications: parseBoolean(resource.attributes['email_notifications']),
|
|
745
|
+
smsNotifications: parseBoolean(resource.attributes['sms_notifications']),
|
|
746
|
+
whatsappNotifications: parseBoolean(resource.attributes['whatsapp_notifications']),
|
|
747
|
+
otherNotifications: parseBoolean(resource.attributes['other_notifications']),
|
|
748
|
+
// Business logic
|
|
749
|
+
status: parseStatus(resource.attributes['status']),
|
|
750
|
+
payload: resource.attributes['payload'],
|
|
751
|
+
// Legacy/computed fields
|
|
752
|
+
bio: parseString(resource.attributes['bio']),
|
|
753
|
+
postsCount: parseOptionalNumber(resource.attributes['posts_count']),
|
|
754
|
+
commentsCount: parseOptionalNumber(resource.attributes['comments_count']),
|
|
755
|
+
followersCount: parseOptionalNumber(resource.attributes['followers_count']),
|
|
756
|
+
followingCount: parseOptionalNumber(resource.attributes['following_count'])
|
|
757
|
+
})
|
|
758
|
+
};
|
|
759
|
+
const followingMapper = {
|
|
760
|
+
type: 'Following',
|
|
761
|
+
map: (resource)=>({
|
|
762
|
+
id: resource.id,
|
|
763
|
+
uniqueId: parseString(resource.attributes['unique_id']),
|
|
764
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
765
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
766
|
+
// The user being followed
|
|
767
|
+
userUniqueId: parseString(resource.attributes['user_unique_id']) || '',
|
|
768
|
+
userName: parseString(resource.attributes['user_name']),
|
|
769
|
+
userAlias: parseString(resource.attributes['user_alias']),
|
|
770
|
+
userAvatarUrl: parseString(resource.attributes['user_avatar_url']),
|
|
771
|
+
// The follower
|
|
772
|
+
followerUniqueId: parseString(resource.attributes['follower_unique_id']) || '',
|
|
773
|
+
followerName: parseString(resource.attributes['follower_name']),
|
|
774
|
+
followerAlias: parseString(resource.attributes['follower_alias']),
|
|
775
|
+
followerAvatarUrl: parseString(resource.attributes['follower_avatar_url']),
|
|
776
|
+
// Metadata
|
|
777
|
+
followingSince: parseDate(resource.attributes['following_since']),
|
|
778
|
+
payload: resource.attributes['payload']
|
|
779
|
+
})
|
|
660
780
|
};
|
|
661
781
|
|
|
662
782
|
function createContentUsersService(transport, _config) {
|
|
@@ -681,8 +801,13 @@ function createContentUsersService(transport, _config) {
|
|
|
681
801
|
user: {
|
|
682
802
|
email: data.email,
|
|
683
803
|
name: data.name,
|
|
804
|
+
first_name: data.firstName,
|
|
805
|
+
last_name: data.lastName,
|
|
684
806
|
avatar_url: data.avatarUrl,
|
|
685
807
|
bio: data.bio,
|
|
808
|
+
phone: data.phone,
|
|
809
|
+
time_zone: data.timeZone,
|
|
810
|
+
preferred_language: data.preferredLanguage,
|
|
686
811
|
payload: data.payload
|
|
687
812
|
}
|
|
688
813
|
});
|
|
@@ -692,8 +817,17 @@ function createContentUsersService(transport, _config) {
|
|
|
692
817
|
const response = await transport.put(`/identities/${uniqueId}`, {
|
|
693
818
|
user: {
|
|
694
819
|
name: data.name,
|
|
820
|
+
first_name: data.firstName,
|
|
821
|
+
last_name: data.lastName,
|
|
695
822
|
avatar_url: data.avatarUrl,
|
|
696
823
|
bio: data.bio,
|
|
824
|
+
phone: data.phone,
|
|
825
|
+
time_zone: data.timeZone,
|
|
826
|
+
preferred_language: data.preferredLanguage,
|
|
827
|
+
email_notifications: data.emailNotifications,
|
|
828
|
+
sms_notifications: data.smsNotifications,
|
|
829
|
+
whatsapp_notifications: data.whatsappNotifications,
|
|
830
|
+
other_notifications: data.otherNotifications,
|
|
697
831
|
payload: data.payload
|
|
698
832
|
}
|
|
699
833
|
});
|
|
@@ -739,11 +873,11 @@ function createContentUsersService(transport, _config) {
|
|
|
739
873
|
},
|
|
740
874
|
async getFollowers (uniqueId) {
|
|
741
875
|
const response = await transport.get(`/identities/${uniqueId}/followers`);
|
|
742
|
-
return decodeMany(response,
|
|
876
|
+
return decodeMany(response, followingMapper);
|
|
743
877
|
},
|
|
744
878
|
async getFollowing (uniqueId) {
|
|
745
879
|
const response = await transport.get(`/identities/${uniqueId}/following`);
|
|
746
|
-
return decodeMany(response,
|
|
880
|
+
return decodeMany(response, followingMapper);
|
|
747
881
|
},
|
|
748
882
|
async followUser (uniqueId, targetUserUniqueId) {
|
|
749
883
|
await transport.post(`/identities/${uniqueId}/follows/${targetUserUniqueId}`, {});
|
|
@@ -926,15 +1060,180 @@ const activityMapper = {
|
|
|
926
1060
|
};
|
|
927
1061
|
}
|
|
928
1062
|
|
|
1063
|
+
function parseVisibility(value) {
|
|
1064
|
+
const str = parseString(value);
|
|
1065
|
+
if (str === 'public' || str === 'private' || str === 'unlisted') {
|
|
1066
|
+
return str;
|
|
1067
|
+
}
|
|
1068
|
+
return undefined;
|
|
1069
|
+
}
|
|
1070
|
+
function parseCompletionStatus(value) {
|
|
1071
|
+
const str = parseString(value);
|
|
1072
|
+
if (str === 'ongoing' || str === 'completed' || str === 'hiatus' || str === 'cancelled') {
|
|
1073
|
+
return str;
|
|
1074
|
+
}
|
|
1075
|
+
return undefined;
|
|
1076
|
+
}
|
|
1077
|
+
const seriesMapper = {
|
|
1078
|
+
type: 'Series',
|
|
1079
|
+
map: (resource)=>({
|
|
1080
|
+
id: resource.id,
|
|
1081
|
+
uniqueId: parseString(resource.attributes['unique_id']),
|
|
1082
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
1083
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
1084
|
+
title: parseString(resource.attributes['title']) || '',
|
|
1085
|
+
description: parseString(resource.attributes['description']),
|
|
1086
|
+
slug: parseString(resource.attributes['slug']),
|
|
1087
|
+
thumbnailUrl: parseString(resource.attributes['thumbnail_url']),
|
|
1088
|
+
imageUrl: parseString(resource.attributes['image_url']),
|
|
1089
|
+
status: parseStatus(resource.attributes['status']),
|
|
1090
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
1091
|
+
visibility: parseVisibility(resource.attributes['visibility']),
|
|
1092
|
+
completionStatus: parseCompletionStatus(resource.attributes['completion_status']),
|
|
1093
|
+
// User
|
|
1094
|
+
userUniqueId: parseString(resource.attributes['user_unique_id']),
|
|
1095
|
+
userName: parseString(resource.attributes['user_name']),
|
|
1096
|
+
userAlias: parseString(resource.attributes['user_alias']),
|
|
1097
|
+
userAvatarUrl: parseString(resource.attributes['user_avatar_url']),
|
|
1098
|
+
// Engagement
|
|
1099
|
+
postsCount: parseOptionalNumber(resource.attributes['posts_count']),
|
|
1100
|
+
likes: parseOptionalNumber(resource.attributes['likes']),
|
|
1101
|
+
dislikes: parseOptionalNumber(resource.attributes['dislikes']),
|
|
1102
|
+
followers: parseOptionalNumber(resource.attributes['followers']),
|
|
1103
|
+
savers: parseOptionalNumber(resource.attributes['savers']),
|
|
1104
|
+
// AI
|
|
1105
|
+
aiGenerated: parseBoolean(resource.attributes['ai_generated']),
|
|
1106
|
+
aiModel: parseString(resource.attributes['ai_model']),
|
|
1107
|
+
// Moderation
|
|
1108
|
+
moderated: parseBoolean(resource.attributes['moderated']),
|
|
1109
|
+
// Metadata
|
|
1110
|
+
payload: resource.attributes['payload']
|
|
1111
|
+
})
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
function createSeriesService(transport, _config) {
|
|
1115
|
+
return {
|
|
1116
|
+
// CRUD Operations
|
|
1117
|
+
async list (params) {
|
|
1118
|
+
const queryParams = {};
|
|
1119
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
1120
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
1121
|
+
const response = await transport.get('/series', {
|
|
1122
|
+
params: queryParams
|
|
1123
|
+
});
|
|
1124
|
+
return decodePageResult(response, seriesMapper);
|
|
1125
|
+
},
|
|
1126
|
+
async query (params) {
|
|
1127
|
+
const queryParams = {};
|
|
1128
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
1129
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
1130
|
+
if (params == null ? void 0 : params.visibility) queryParams['visibility'] = params.visibility;
|
|
1131
|
+
if (params == null ? void 0 : params.completionStatus) queryParams['completion_status'] = params.completionStatus;
|
|
1132
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
1133
|
+
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
1134
|
+
const response = await transport.post('/series/query', queryParams);
|
|
1135
|
+
return decodePageResult(response, seriesMapper);
|
|
1136
|
+
},
|
|
1137
|
+
async get (uniqueId) {
|
|
1138
|
+
const response = await transport.get(`/series/${uniqueId}`);
|
|
1139
|
+
return decodeOne(response, seriesMapper);
|
|
1140
|
+
},
|
|
1141
|
+
async create (data) {
|
|
1142
|
+
const response = await transport.post('/series', {
|
|
1143
|
+
series: {
|
|
1144
|
+
title: data.title,
|
|
1145
|
+
description: data.description,
|
|
1146
|
+
slug: data.slug,
|
|
1147
|
+
thumbnail_url: data.thumbnailUrl,
|
|
1148
|
+
image_url: data.imageUrl,
|
|
1149
|
+
visibility: data.visibility,
|
|
1150
|
+
completion_status: data.completionStatus,
|
|
1151
|
+
payload: data.payload
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
return decodeOne(response, seriesMapper);
|
|
1155
|
+
},
|
|
1156
|
+
async update (uniqueId, data) {
|
|
1157
|
+
const response = await transport.put(`/series/${uniqueId}`, {
|
|
1158
|
+
series: {
|
|
1159
|
+
title: data.title,
|
|
1160
|
+
description: data.description,
|
|
1161
|
+
slug: data.slug,
|
|
1162
|
+
thumbnail_url: data.thumbnailUrl,
|
|
1163
|
+
image_url: data.imageUrl,
|
|
1164
|
+
visibility: data.visibility,
|
|
1165
|
+
completion_status: data.completionStatus,
|
|
1166
|
+
enabled: data.enabled,
|
|
1167
|
+
status: data.status,
|
|
1168
|
+
payload: data.payload
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
return decodeOne(response, seriesMapper);
|
|
1172
|
+
},
|
|
1173
|
+
async delete (uniqueId) {
|
|
1174
|
+
await transport.delete(`/series/${uniqueId}`);
|
|
1175
|
+
},
|
|
1176
|
+
// Social Actions
|
|
1177
|
+
async like (uniqueId) {
|
|
1178
|
+
const response = await transport.put(`/series/${uniqueId}/like`, {});
|
|
1179
|
+
return decodeOne(response, seriesMapper);
|
|
1180
|
+
},
|
|
1181
|
+
async dislike (uniqueId) {
|
|
1182
|
+
const response = await transport.put(`/series/${uniqueId}/dislike`, {});
|
|
1183
|
+
return decodeOne(response, seriesMapper);
|
|
1184
|
+
},
|
|
1185
|
+
async follow (uniqueId) {
|
|
1186
|
+
const response = await transport.put(`/series/${uniqueId}/follow`, {});
|
|
1187
|
+
return decodeOne(response, seriesMapper);
|
|
1188
|
+
},
|
|
1189
|
+
async unfollow (uniqueId) {
|
|
1190
|
+
await transport.delete(`/series/${uniqueId}/unfollow`);
|
|
1191
|
+
},
|
|
1192
|
+
async save (uniqueId) {
|
|
1193
|
+
const response = await transport.put(`/series/${uniqueId}/save`, {});
|
|
1194
|
+
return decodeOne(response, seriesMapper);
|
|
1195
|
+
},
|
|
1196
|
+
async unsave (uniqueId) {
|
|
1197
|
+
await transport.delete(`/series/${uniqueId}/unsave`);
|
|
1198
|
+
},
|
|
1199
|
+
// Post Management
|
|
1200
|
+
async getPosts (uniqueId) {
|
|
1201
|
+
const response = await transport.get(`/series/${uniqueId}/posts`);
|
|
1202
|
+
return decodeMany(response, postMapper);
|
|
1203
|
+
},
|
|
1204
|
+
async addPost (seriesUniqueId, postUniqueId, sequence) {
|
|
1205
|
+
const queryParams = {};
|
|
1206
|
+
if (sequence !== undefined) queryParams['sequence'] = String(sequence);
|
|
1207
|
+
await transport.post(`/series/${seriesUniqueId}/posts/${postUniqueId}`, {}, {
|
|
1208
|
+
params: queryParams
|
|
1209
|
+
});
|
|
1210
|
+
},
|
|
1211
|
+
async removePost (seriesUniqueId, postUniqueId) {
|
|
1212
|
+
await transport.delete(`/series/${seriesUniqueId}/posts/${postUniqueId}`);
|
|
1213
|
+
},
|
|
1214
|
+
async reorderPosts (uniqueId, data) {
|
|
1215
|
+
const response = await transport.put(`/series/${uniqueId}/reorder`, {
|
|
1216
|
+
posts: data.posts.map((p)=>({
|
|
1217
|
+
post_unique_id: p.postUniqueId,
|
|
1218
|
+
sequence: p.sequence
|
|
1219
|
+
}))
|
|
1220
|
+
});
|
|
1221
|
+
return decodeOne(response, seriesMapper);
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
|
|
929
1226
|
function createContentBlock(transport, config) {
|
|
930
1227
|
return {
|
|
931
1228
|
posts: createPostsService(transport),
|
|
1229
|
+
postVersions: createPostVersionsService(transport),
|
|
932
1230
|
comments: createCommentsService(transport),
|
|
933
1231
|
categories: createCategoriesService(transport),
|
|
934
1232
|
tags: createTagsService(transport),
|
|
935
1233
|
users: createContentUsersService(transport),
|
|
936
1234
|
moderation: createModerationService(transport),
|
|
937
|
-
activity: createActivityService(transport)
|
|
1235
|
+
activity: createActivityService(transport),
|
|
1236
|
+
series: createSeriesService(transport)
|
|
938
1237
|
};
|
|
939
1238
|
}
|
|
940
1239
|
const contentBlockMetadata = {
|
|
@@ -943,13 +1242,16 @@ const contentBlockMetadata = {
|
|
|
943
1242
|
description: 'Content management for posts, comments, categories, tags, and users',
|
|
944
1243
|
resourceTypes: [
|
|
945
1244
|
'Post',
|
|
1245
|
+
'PostVersion',
|
|
946
1246
|
'Comment',
|
|
947
1247
|
'Category',
|
|
948
1248
|
'Tag',
|
|
949
1249
|
'ContentUser',
|
|
1250
|
+
'Following',
|
|
950
1251
|
'ContentFlag',
|
|
951
|
-
'Activity'
|
|
1252
|
+
'Activity',
|
|
1253
|
+
'Series'
|
|
952
1254
|
]
|
|
953
1255
|
};
|
|
954
1256
|
|
|
955
|
-
export { activityMapper, categoryMapper, commentMapper, contentBlockMetadata, contentFlagMapper, contentUserMapper, createActivityService, createCategoriesService, createCommentsService, createContentBlock, createContentUsersService, createModerationService, createPostsService, createTagsService, postMapper, tagMapper };
|
|
1257
|
+
export { activityMapper, categoryMapper, commentMapper, contentBlockMetadata, contentFlagMapper, contentUserMapper, createActivityService, createCategoriesService, createCommentsService, createContentBlock, createContentUsersService, createModerationService, createPostVersionsService, createPostsService, createSeriesService, createTagsService, followingMapper, postMapper, postVersionMapper, seriesMapper, tagMapper };
|