@yimingliao/cms 0.0.58 → 0.0.60

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.
@@ -1,4 +1,4 @@
1
- import { ADMIN_ROLES, isFileLocked, isFolderLocked, ROOT_FOLDER_ID, ROOT_FOLDER } from '../chunk-FUAJWL2N.js';
1
+ import { ADMIN_ROLES, isFileLocked, isFolderLocked, ROOT_FOLDER_ID, ROOT_FOLDER, POST_TYPES } from '../chunk-FUAJWL2N.js';
2
2
  import { SIZE, result, mimeToExtension, classifyFileType } from '../chunk-YAUBKQVA.js';
3
3
  import jwt from 'jsonwebtoken';
4
4
  import argon2 from 'argon2';
@@ -2076,7 +2076,7 @@ function createSignInAction(ctx) {
2076
2076
  useCases: { authUseCases },
2077
2077
  action: { executeAction, ipRateLimiter },
2078
2078
  http: { headers },
2079
- schemas
2079
+ schemas: { schemas }
2080
2080
  } = ctx;
2081
2081
  return executeAction(
2082
2082
  async () => {
@@ -2186,7 +2186,7 @@ function createChangePasswordAction(ctx) {
2186
2186
  action: { executeAction, ipRateLimiter },
2187
2187
  useCases: { authUseCases },
2188
2188
  middlewares: { authMiddleware },
2189
- schemas
2189
+ schemas: { schemas }
2190
2190
  } = ctx;
2191
2191
  return executeAction(
2192
2192
  async () => {
@@ -2219,7 +2219,7 @@ function createVerifyEmailAction(ctx) {
2219
2219
  repositories: { adminQueryRepository },
2220
2220
  useCases: { authUseCases },
2221
2221
  action: { executeAction, ipRateLimiter },
2222
- schemas
2222
+ schemas: { schemas }
2223
2223
  } = ctx;
2224
2224
  return executeAction(
2225
2225
  async () => {
@@ -2255,7 +2255,7 @@ function createEmailUnverifiedAction(ctx) {
2255
2255
  repositories: { adminQueryRepository },
2256
2256
  action: { executeAction, ipRateLimiter },
2257
2257
  emails: { emailVerificationEmail },
2258
- schemas
2258
+ schemas: { schemas }
2259
2259
  } = ctx;
2260
2260
  return executeAction(
2261
2261
  async (translator) => {
@@ -2291,7 +2291,7 @@ function createForgotPasswordAction(ctx) {
2291
2291
  repositories: { adminQueryRepository },
2292
2292
  action: { executeAction, ipRateLimiter },
2293
2293
  emails: { forgotPasswordEmail },
2294
- schemas
2294
+ schemas: { schemas }
2295
2295
  } = ctx;
2296
2296
  return executeAction(
2297
2297
  async (translator) => {
@@ -2341,7 +2341,7 @@ function createResetPasswordAction(ctx) {
2341
2341
  const {
2342
2342
  useCases: { authUseCases },
2343
2343
  action: { executeAction, ipRateLimiter },
2344
- schemas
2344
+ schemas: { schemas }
2345
2345
  } = ctx;
2346
2346
  return executeAction(
2347
2347
  async () => {
@@ -2406,7 +2406,7 @@ function createAdminCreateAction(ctx) {
2406
2406
  middlewares: { authMiddleware },
2407
2407
  action: { executeAction },
2408
2408
  emails: { emailVerificationEmail },
2409
- schemas
2409
+ schemas: { schemas }
2410
2410
  } = ctx;
2411
2411
  return async function adminCreateAction({
2412
2412
  formData
@@ -2487,7 +2487,7 @@ function createAdminUpdateAction(ctx) {
2487
2487
  middlewares: { authMiddleware },
2488
2488
  action: { executeAction },
2489
2489
  emails: { emailVerificationEmail },
2490
- schemas
2490
+ schemas: { schemas }
2491
2491
  } = ctx;
2492
2492
  return async function adminUpdateAction({
2493
2493
  id,
@@ -2736,7 +2736,7 @@ function createFileCreateAction(ctx) {
2736
2736
  repositories: { folderQueryRepository, fileCommandRepository },
2737
2737
  middlewares: { authMiddleware },
2738
2738
  action: { executeAction },
2739
- schemas
2739
+ schemas: { schemas }
2740
2740
  } = ctx;
2741
2741
  return async function fileCreateAction({
2742
2742
  formData
@@ -2821,7 +2821,7 @@ function createFileUpdateAction(ctx) {
2821
2821
  repositories: { fileQueryRepository, fileCommandRepository },
2822
2822
  middlewares: { authMiddleware },
2823
2823
  action: { executeAction },
2824
- schemas
2824
+ schemas: { schemas }
2825
2825
  } = ctx;
2826
2826
  return async function fileUpdateAction({
2827
2827
  id,
@@ -3052,7 +3052,7 @@ function createFileCreateManyAction(ctx) {
3052
3052
  repositories: { fileCommandRepository },
3053
3053
  middlewares: { authMiddleware },
3054
3054
  action: { executeAction },
3055
- schemas
3055
+ schemas: { schemas }
3056
3056
  } = ctx;
3057
3057
  return async function fileCreateManyAction({
3058
3058
  formData
@@ -3100,7 +3100,7 @@ function createFilePurgeManyAction(ctx) {
3100
3100
  repositories: { fileQueryRepository, fileCommandRepository },
3101
3101
  middlewares: { authMiddleware },
3102
3102
  action: { executeAction },
3103
- schemas
3103
+ schemas: { schemas }
3104
3104
  } = ctx;
3105
3105
  return async function filePurgeManyAction({
3106
3106
  formData
@@ -3143,7 +3143,7 @@ function createFileRestoreManyAction(ctx) {
3143
3143
  repositories: { fileCommandRepository },
3144
3144
  middlewares: { authMiddleware },
3145
3145
  action: { executeAction },
3146
- schemas
3146
+ schemas: { schemas }
3147
3147
  } = ctx;
3148
3148
  return async function fileRestoreManyAction({
3149
3149
  formData
@@ -3199,7 +3199,7 @@ function createFileSoftDeleteManyAction(ctx) {
3199
3199
  repositories: { fileQueryRepository, fileCommandRepository },
3200
3200
  middlewares: { authMiddleware },
3201
3201
  action: { executeAction },
3202
- schemas
3202
+ schemas: { schemas }
3203
3203
  } = ctx;
3204
3204
  return async function fileSoftDeleteManyAction({
3205
3205
  formData
@@ -3304,7 +3304,7 @@ function createFolderCreateAction(ctx) {
3304
3304
  repositories: { folderCommandRepository },
3305
3305
  middlewares: { authMiddleware },
3306
3306
  action: { executeAction },
3307
- schemas
3307
+ schemas: { schemas }
3308
3308
  } = ctx;
3309
3309
  return async function folderCreateAction({
3310
3310
  formData
@@ -3355,7 +3355,7 @@ function createFolderUpdateAction(ctx) {
3355
3355
  repositories: { folderCommandRepository },
3356
3356
  middlewares: { authMiddleware },
3357
3357
  action: { executeAction },
3358
- schemas
3358
+ schemas: { schemas }
3359
3359
  } = ctx;
3360
3360
  return async function folderUpdateAction({
3361
3361
  id,
@@ -3486,6 +3486,532 @@ function createFolderFindListCardsAction(ctx) {
3486
3486
  };
3487
3487
  }
3488
3488
 
3489
+ // src/server/interfaces/actions/resources/post/commands/create/post-create-validator.ts
3490
+ var postCreateValidator = ({
3491
+ type,
3492
+ topicId,
3493
+ schemas,
3494
+ tocItemSchema
3495
+ }) => schemas.z.object({
3496
+ type: schemas.z.enum(POST_TYPES),
3497
+ // ----------------------------------------------------------------------------
3498
+ // states
3499
+ // ----------------------------------------------------------------------------
3500
+ isLocked: schemas.z.boolean(),
3501
+ isActive: schemas.z.boolean(),
3502
+ isIndexActive: schemas.z.boolean(),
3503
+ index: schemas.positiveNumber().nullable(),
3504
+ isSlugActive: schemas.z.boolean(),
3505
+ slug: schemas.slug().unique({
3506
+ table: "posts",
3507
+ column: "slug",
3508
+ scope: [
3509
+ { name: "type", value: type, cast: "PostType" },
3510
+ ...topicId ? [{ name: "topic_id", value: topicId }] : []
3511
+ // Use for: [post], [post:category]
3512
+ ]
3513
+ }).nullable(),
3514
+ isFeatured: schemas.z.boolean(),
3515
+ isShownOnHome: schemas.z.boolean(),
3516
+ // ----------------------------------------------------------------------------
3517
+ // relations
3518
+ // ----------------------------------------------------------------------------
3519
+ // Admin
3520
+ author: schemas.singleItem({ table: "admins", column: "id" }).nullable(),
3521
+ // Picked by modal
3522
+ // Post
3523
+ topicId: schemas.id().exist({ table: "posts", column: "id" }).nullable(),
3524
+ parents: schemas.multiItems({ table: "posts", column: "id" }),
3525
+ // Picked by modal
3526
+ tags: schemas.multiItems({ table: "posts", column: "id" }),
3527
+ // Picked by modal
3528
+ relatedPosts: schemas.multiItems({ table: "posts", column: "id" }),
3529
+ // Picked by modal
3530
+ // File
3531
+ coverImage: schemas.singleItem({ table: "files", column: "id" }),
3532
+ // Picked by modal
3533
+ contentImageIds: schemas.array(
3534
+ schemas.id().exist({ table: "files", column: "id" })
3535
+ ),
3536
+ // -----------------------------------------------------------------------
3537
+ // --- custom fields
3538
+ // -----------------------------------------------------------------------
3539
+ // states
3540
+ state1: schemas.z.boolean(),
3541
+ state2: schemas.z.boolean(),
3542
+ state3: schemas.z.boolean(),
3543
+ state4: schemas.z.boolean(),
3544
+ state5: schemas.z.boolean(),
3545
+ state6: schemas.z.boolean(),
3546
+ state7: schemas.z.boolean(),
3547
+ state8: schemas.z.boolean(),
3548
+ state9: schemas.z.boolean(),
3549
+ state10: schemas.z.boolean(),
3550
+ // multi images
3551
+ images1: schemas.multiItems({ table: "files", column: "id" }),
3552
+ images2: schemas.multiItems({ table: "files", column: "id" }),
3553
+ // single images
3554
+ image1: schemas.singleItem({ table: "files", column: "id" }),
3555
+ image2: schemas.singleItem({ table: "files", column: "id" }),
3556
+ image3: schemas.singleItem({ table: "files", column: "id" }),
3557
+ image4: schemas.singleItem({ table: "files", column: "id" }),
3558
+ // text
3559
+ text1: schemas.text().nullable(),
3560
+ text2: schemas.text().nullable(),
3561
+ text3: schemas.text().nullable(),
3562
+ text4: schemas.text().nullable(),
3563
+ text5: schemas.text().nullable(),
3564
+ text6: schemas.text().nullable(),
3565
+ text7: schemas.text().nullable(),
3566
+ text8: schemas.text().nullable(),
3567
+ text9: schemas.text().nullable(),
3568
+ text10: schemas.text().nullable(),
3569
+ // json array
3570
+ data1: schemas.array(schemas.z.any()),
3571
+ data2: schemas.array(schemas.z.any()),
3572
+ data3: schemas.array(schemas.z.any()),
3573
+ data4: schemas.array(schemas.z.any()),
3574
+ // ----------------------------------------------------------------------------
3575
+ // translation
3576
+ // ----------------------------------------------------------------------------
3577
+ translations: schemas.array(
3578
+ schemas.z.object({
3579
+ locale: schemas.locale(),
3580
+ // text
3581
+ title: schemas.text().nullable(),
3582
+ subtitle: schemas.text().nullable(),
3583
+ summary: schemas.text().nullable(),
3584
+ description: schemas.text().nullable(),
3585
+ content: schemas.text().nullable(),
3586
+ // better seo
3587
+ externalLinks: schemas.array(
3588
+ schemas.z.object({
3589
+ name: schemas.text(),
3590
+ href: schemas.text()
3591
+ })
3592
+ ),
3593
+ faq: schemas.array(
3594
+ schemas.z.object({
3595
+ question: schemas.text(),
3596
+ answer: schemas.text()
3597
+ })
3598
+ ),
3599
+ toc: schemas.array(tocItemSchema),
3600
+ // extra
3601
+ readTime: schemas.positiveNumber().nullable(),
3602
+ wordCount: schemas.positiveNumber(),
3603
+ // -------------------------------------------
3604
+ // --- custom fields
3605
+ // -------------------------------------------
3606
+ // text
3607
+ text1: schemas.text().nullable(),
3608
+ text2: schemas.text().nullable(),
3609
+ text3: schemas.text().nullable(),
3610
+ text4: schemas.text().nullable(),
3611
+ text5: schemas.text().nullable(),
3612
+ text6: schemas.text().nullable(),
3613
+ text7: schemas.text().nullable(),
3614
+ text8: schemas.text().nullable(),
3615
+ text9: schemas.text().nullable(),
3616
+ text10: schemas.text().nullable(),
3617
+ // json array
3618
+ data1: schemas.array(schemas.z.any()),
3619
+ data2: schemas.array(schemas.z.any()),
3620
+ data3: schemas.array(schemas.z.any()),
3621
+ data4: schemas.array(schemas.z.any())
3622
+ })
3623
+ )
3624
+ }).transform((obj) => ({
3625
+ ...obj,
3626
+ // states
3627
+ index: obj.isIndexActive ? obj.index : null,
3628
+ slug: obj.isSlugActive ? obj.slug : null,
3629
+ // translation
3630
+ translations: obj.translations.map((t) => ({
3631
+ ...t,
3632
+ readTime: t.readTime !== 0 ? t.readTime : null
3633
+ }))
3634
+ }));
3635
+
3636
+ // src/server/interfaces/actions/resources/post/commands/create/create-post-create-action.ts
3637
+ function createPostCreateAction(ctx) {
3638
+ const {
3639
+ repositories: { postCommandRepository },
3640
+ middlewares: { authMiddleware },
3641
+ action: { executeAction },
3642
+ schemas: { schemas, tocItemSchema }
3643
+ } = ctx;
3644
+ return async function postCreateAction({
3645
+ formData
3646
+ }) {
3647
+ return executeAction(
3648
+ async () => {
3649
+ await authMiddleware.authenticate();
3650
+ const validatedPayload = await postCreateValidator({
3651
+ schemas,
3652
+ tocItemSchema,
3653
+ type: formData.type,
3654
+ topicId: formData.topicId
3655
+ }).parseAsync(formData);
3656
+ const created = await postCommandRepository.create(validatedPayload);
3657
+ return {
3658
+ i18nKey: "ok.store-ok",
3659
+ data: { post: created }
3660
+ };
3661
+ },
3662
+ { type: "command" }
3663
+ );
3664
+ };
3665
+ }
3666
+
3667
+ // src/server/interfaces/actions/resources/post/commands/update/post-update-validator.ts
3668
+ var postUpdateValidator = ({
3669
+ id,
3670
+ type,
3671
+ topicId,
3672
+ schemas,
3673
+ tocItemSchema
3674
+ }) => schemas.z.object({
3675
+ type: schemas.z.enum(POST_TYPES),
3676
+ // depth: schemas.z.number().nullable(),
3677
+ // ----------------------------------------------------------------------------
3678
+ // states
3679
+ // ----------------------------------------------------------------------------
3680
+ isLocked: schemas.z.boolean(),
3681
+ isActive: schemas.z.boolean(),
3682
+ isIndexActive: schemas.z.boolean(),
3683
+ index: schemas.positiveNumber().nullable(),
3684
+ isSlugActive: schemas.z.boolean(),
3685
+ slug: schemas.slug().unique({
3686
+ table: "posts",
3687
+ column: "slug",
3688
+ scope: [
3689
+ { name: "type", value: type, cast: "PostType" },
3690
+ ...topicId ? [{ name: "topic_id", value: topicId }] : []
3691
+ // Use for: [post], [post:category]
3692
+ ],
3693
+ excludeSelf: { name: "id", value: id }
3694
+ }).nullable(),
3695
+ isFeatured: schemas.z.boolean(),
3696
+ isShownOnHome: schemas.z.boolean(),
3697
+ // ----------------------------------------------------------------------------
3698
+ // relations
3699
+ // ----------------------------------------------------------------------------
3700
+ // Admin
3701
+ author: schemas.singleItem({ table: "admins", column: "id" }),
3702
+ // Picked by modal
3703
+ // Post
3704
+ topicId: schemas.id().exist({ table: "posts", column: "id" }).nullable(),
3705
+ parents: schemas.multiItems({ table: "posts", column: "id" }),
3706
+ // Picked by modal
3707
+ tags: schemas.multiItems({ table: "posts", column: "id" }),
3708
+ // Picked by modal
3709
+ relatedPosts: schemas.multiItems({ table: "posts", column: "id" }),
3710
+ // Picked by modal
3711
+ // File
3712
+ coverImage: schemas.singleItem({ table: "files", column: "id" }),
3713
+ // Picked by modal
3714
+ contentImageIds: schemas.array(
3715
+ schemas.id().exist({ table: "files", column: "id" })
3716
+ ),
3717
+ // -----------------------------------------------------------------------
3718
+ // --- custom fields
3719
+ // -----------------------------------------------------------------------
3720
+ // states
3721
+ state1: schemas.z.boolean(),
3722
+ state2: schemas.z.boolean(),
3723
+ state3: schemas.z.boolean(),
3724
+ state4: schemas.z.boolean(),
3725
+ state5: schemas.z.boolean(),
3726
+ state6: schemas.z.boolean(),
3727
+ state7: schemas.z.boolean(),
3728
+ state8: schemas.z.boolean(),
3729
+ state9: schemas.z.boolean(),
3730
+ state10: schemas.z.boolean(),
3731
+ // multi images
3732
+ images1: schemas.multiItems({ table: "files", column: "id" }),
3733
+ images2: schemas.multiItems({ table: "files", column: "id" }),
3734
+ // single images
3735
+ image1: schemas.singleItem({ table: "files", column: "id" }),
3736
+ image2: schemas.singleItem({ table: "files", column: "id" }),
3737
+ image3: schemas.singleItem({ table: "files", column: "id" }),
3738
+ image4: schemas.singleItem({ table: "files", column: "id" }),
3739
+ // text
3740
+ text1: schemas.text().nullable(),
3741
+ text2: schemas.text().nullable(),
3742
+ text3: schemas.text().nullable(),
3743
+ text4: schemas.text().nullable(),
3744
+ text5: schemas.text().nullable(),
3745
+ text6: schemas.text().nullable(),
3746
+ text7: schemas.text().nullable(),
3747
+ text8: schemas.text().nullable(),
3748
+ text9: schemas.text().nullable(),
3749
+ text10: schemas.text().nullable(),
3750
+ // json array
3751
+ data1: schemas.array(schemas.z.any()),
3752
+ data2: schemas.array(schemas.z.any()),
3753
+ data3: schemas.array(schemas.z.any()),
3754
+ data4: schemas.array(schemas.z.any()),
3755
+ // ----------------------------------------------------------------------------
3756
+ // translation
3757
+ // ----------------------------------------------------------------------------
3758
+ translations: schemas.array(
3759
+ schemas.z.object({
3760
+ locale: schemas.locale(),
3761
+ // text
3762
+ title: schemas.text().nullable(),
3763
+ subtitle: schemas.text().nullable(),
3764
+ summary: schemas.text().nullable(),
3765
+ description: schemas.text().nullable(),
3766
+ content: schemas.text().nullable(),
3767
+ // better seo
3768
+ externalLinks: schemas.array(
3769
+ schemas.z.object({
3770
+ name: schemas.text(),
3771
+ href: schemas.text()
3772
+ })
3773
+ ),
3774
+ faq: schemas.array(
3775
+ schemas.z.object({
3776
+ question: schemas.text(),
3777
+ answer: schemas.text()
3778
+ })
3779
+ ),
3780
+ toc: schemas.array(tocItemSchema),
3781
+ // extra
3782
+ readTime: schemas.positiveNumber().nullable(),
3783
+ wordCount: schemas.positiveNumber(),
3784
+ // -------------------------------------------
3785
+ // --- custom fields
3786
+ // -------------------------------------------
3787
+ // text
3788
+ text1: schemas.text().nullable(),
3789
+ text2: schemas.text().nullable(),
3790
+ text3: schemas.text().nullable(),
3791
+ text4: schemas.text().nullable(),
3792
+ text5: schemas.text().nullable(),
3793
+ text6: schemas.text().nullable(),
3794
+ text7: schemas.text().nullable(),
3795
+ text8: schemas.text().nullable(),
3796
+ text9: schemas.text().nullable(),
3797
+ text10: schemas.text().nullable(),
3798
+ // json array
3799
+ data1: schemas.array(schemas.z.any()),
3800
+ data2: schemas.array(schemas.z.any()),
3801
+ data3: schemas.array(schemas.z.any()),
3802
+ data4: schemas.array(schemas.z.any())
3803
+ })
3804
+ )
3805
+ }).transform((obj) => ({
3806
+ ...obj,
3807
+ // states
3808
+ index: obj.isIndexActive ? obj.index : null,
3809
+ slug: obj.isSlugActive ? obj.slug : null,
3810
+ // translation
3811
+ translations: obj.translations.map((t) => ({
3812
+ ...t,
3813
+ readTime: t.readTime !== 0 ? t.readTime : null
3814
+ }))
3815
+ }));
3816
+
3817
+ // src/server/interfaces/actions/resources/post/commands/update/create-post-update-action.ts
3818
+ function createPostUpdateAction(ctx) {
3819
+ const {
3820
+ repositories: { postCommandRepository },
3821
+ middlewares: { authMiddleware },
3822
+ action: { executeAction },
3823
+ schemas: { schemas, tocItemSchema }
3824
+ } = ctx;
3825
+ return async function postUpdateAction({
3826
+ id,
3827
+ formData
3828
+ }) {
3829
+ return executeAction(
3830
+ async () => {
3831
+ await authMiddleware.authenticate();
3832
+ const validatedPayload = await postUpdateValidator({
3833
+ id,
3834
+ type: formData.type,
3835
+ topicId: formData.topicId,
3836
+ schemas,
3837
+ tocItemSchema
3838
+ }).parseAsync(formData);
3839
+ const updatedPost = await postCommandRepository.update({
3840
+ id,
3841
+ ...validatedPayload
3842
+ });
3843
+ return {
3844
+ i18nKey: "ok.update-ok",
3845
+ data: { post: updatedPost }
3846
+ };
3847
+ },
3848
+ { type: "command" }
3849
+ );
3850
+ };
3851
+ }
3852
+
3853
+ // src/server/interfaces/actions/resources/post/commands/delete/create-post-delete-action.ts
3854
+ function createPostDeleteAction(ctx) {
3855
+ const {
3856
+ repositories: { postQueryRepository, postCommandRepository },
3857
+ middlewares: { authMiddleware },
3858
+ action: { executeAction }
3859
+ } = ctx;
3860
+ return async function postDeleteAction({ id }) {
3861
+ return executeAction(
3862
+ async () => {
3863
+ await authMiddleware.authenticate();
3864
+ const post = await postQueryRepository.find({ id });
3865
+ if (!post) throw ServerError.notFound();
3866
+ await postCommandRepository.delete({ id: post.id });
3867
+ return {
3868
+ i18nKey: "ok.destroy-ok"
3869
+ };
3870
+ },
3871
+ { type: "command" }
3872
+ );
3873
+ };
3874
+ }
3875
+
3876
+ // src/server/interfaces/actions/resources/post/queries/create-post-find-action.ts
3877
+ function createPostFindAction(ctx) {
3878
+ const {
3879
+ repositories: { postQueryRepository },
3880
+ action: { executeAction }
3881
+ } = ctx;
3882
+ return async function postFindAction(params) {
3883
+ return executeAction(
3884
+ async () => {
3885
+ const found = await postQueryRepository.find(params);
3886
+ if (!found) throw ServerError.notFound();
3887
+ return {
3888
+ data: { post: found }
3889
+ };
3890
+ },
3891
+ {
3892
+ type: "query",
3893
+ key: [
3894
+ "post",
3895
+ "findAction",
3896
+ params.id,
3897
+ params.type,
3898
+ params.slug,
3899
+ params.isActive,
3900
+ params.topicSlug
3901
+ ]
3902
+ }
3903
+ );
3904
+ };
3905
+ }
3906
+
3907
+ // src/server/interfaces/actions/resources/post/queries/create-post-find-full-action.ts
3908
+ function createPostFindFullAction(ctx) {
3909
+ const {
3910
+ repositories: { postQueryRepository },
3911
+ action: { executeAction }
3912
+ } = ctx;
3913
+ return async function postFindFullAction(params) {
3914
+ return executeAction(
3915
+ async () => {
3916
+ const found = await postQueryRepository.findFull(params);
3917
+ if (!found) throw ServerError.notFound();
3918
+ return {
3919
+ data: { post: found }
3920
+ };
3921
+ },
3922
+ {
3923
+ type: "query",
3924
+ key: [
3925
+ "post",
3926
+ "findFullAction",
3927
+ params.id,
3928
+ params.type,
3929
+ params.slug,
3930
+ params.isActive,
3931
+ params.topicSlug
3932
+ ]
3933
+ }
3934
+ );
3935
+ };
3936
+ }
3937
+
3938
+ // src/server/interfaces/actions/resources/post/queries/create-post-find-list-cards-action.ts
3939
+ function createPostFindListCardsAction(ctx) {
3940
+ const {
3941
+ repositories: { postQueryRepository },
3942
+ middlewares: { authMiddleware },
3943
+ action: { executeAction }
3944
+ } = ctx;
3945
+ return async function postFindFullAction(params) {
3946
+ return executeAction(
3947
+ async ({ locale }) => {
3948
+ await authMiddleware.authenticate();
3949
+ const { items, total } = await postQueryRepository.findListCards({
3950
+ ...params,
3951
+ locale
3952
+ });
3953
+ return {
3954
+ data: { items, total }
3955
+ };
3956
+ },
3957
+ {
3958
+ type: "query",
3959
+ key: [
3960
+ "post",
3961
+ "findListCardsAction",
3962
+ params.searchString,
3963
+ params.type,
3964
+ params.isActive,
3965
+ params.isIndexActive,
3966
+ params.isSlugActive,
3967
+ params.isFeatured,
3968
+ params.isShownOnHome,
3969
+ params.state1,
3970
+ params.state2,
3971
+ params.state3,
3972
+ params.state4,
3973
+ params.state5,
3974
+ params.state6,
3975
+ params.state7,
3976
+ params.state8,
3977
+ params.state9,
3978
+ params.state10,
3979
+ params.topicId,
3980
+ params.topicSlug,
3981
+ params.categoryId,
3982
+ params.categorySlug,
3983
+ ...params.postIds ?? [],
3984
+ ...params.excludeIds ?? [],
3985
+ params.page,
3986
+ params.pageSize
3987
+ ]
3988
+ }
3989
+ );
3990
+ };
3991
+ }
3992
+
3993
+ // src/server/interfaces/actions/resources/post/queries/create-post-find-many-action.ts
3994
+ function createPostFindManyAction(ctx) {
3995
+ const {
3996
+ repositories: { postQueryRepository },
3997
+ action: { executeAction }
3998
+ } = ctx;
3999
+ return async function postFindManyAction(params) {
4000
+ return executeAction(
4001
+ async () => {
4002
+ const found = await postQueryRepository.findMany(params);
4003
+ return {
4004
+ data: { posts: found }
4005
+ };
4006
+ },
4007
+ {
4008
+ type: "query",
4009
+ key: ["post", "findManyAction", params.type, params.topicId]
4010
+ }
4011
+ );
4012
+ };
4013
+ }
4014
+
3489
4015
  // src/server/applications/auth/create-auth-use-cases.ts
3490
4016
  function createAuthUseCases({
3491
4017
  prisma,
@@ -3665,4 +4191,4 @@ function createForgotPasswordEmail({
3665
4191
  };
3666
4192
  }
3667
4193
 
3668
- export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostQueryRepository, createRenderEmailTemplate, createResetPasswordAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
4194
+ export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostQueryRepository, createPostUpdateAction, createRenderEmailTemplate, createResetPasswordAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",