@yimingliao/cms 0.0.11 → 0.0.13
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/server/index.d.ts +28 -11
- package/dist/server/index.js +68 -14
- package/package.json +1 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
2
|
import { BinaryLike } from 'node:crypto';
|
|
3
3
|
import { cookies } from 'next/headers';
|
|
4
|
-
import { e as AdminRole, v as SingleItem, B as BaseTranslation, a as Admin, c as AdminFull, f as AdminSafe, D as DeviceInfo, d as AdminRefreshToken, k as File, m as FileFull, o as FileType, p as Folder, F as FolderFull, u as PostType, M as MultiItems, E as ExternalLink, j as Faq, T as TocItem, q as Post, s as PostListCard, t as PostTranslation, r as PostFull, S as SeoMetadata, n as FileTranslation, h as Alternate } from '../base-DbGnfZr6.js';
|
|
4
|
+
import { e as AdminRole, v as SingleItem, B as BaseTranslation, a as Admin, c as AdminFull, f as AdminSafe, D as DeviceInfo, d as AdminRefreshToken, k as File, m as FileFull, o as FileType, p as Folder, F as FolderFull, u as PostType, M as MultiItems, E as ExternalLink, j as Faq, T as TocItem, q as Post, s as PostListCard, t as PostTranslation, r as PostFull, S as SeoMetadata, g as AdminTranslation, n as FileTranslation, h as Alternate } from '../base-DbGnfZr6.js';
|
|
5
5
|
|
|
6
6
|
interface JwtServiceConfig {
|
|
7
7
|
defaultSecret: string;
|
|
@@ -460,22 +460,37 @@ declare function createPostCommandRepository(prisma: any): {
|
|
|
460
460
|
|
|
461
461
|
interface FindListCardsParams {
|
|
462
462
|
locale: string;
|
|
463
|
-
type: PostType | null;
|
|
464
|
-
page?: number;
|
|
465
|
-
pageSize?: number;
|
|
466
463
|
searchString?: string;
|
|
467
|
-
|
|
468
|
-
postIds?: string[];
|
|
464
|
+
type: PostType | null;
|
|
469
465
|
isActive?: boolean;
|
|
470
466
|
isIndexActive?: boolean;
|
|
471
467
|
isSlugActive?: boolean;
|
|
472
468
|
isFeatured?: boolean;
|
|
473
469
|
isShownOnHome?: boolean;
|
|
470
|
+
state1?: boolean;
|
|
471
|
+
state2?: boolean;
|
|
472
|
+
state3?: boolean;
|
|
473
|
+
state4?: boolean;
|
|
474
|
+
state5?: boolean;
|
|
475
|
+
state6?: boolean;
|
|
476
|
+
state7?: boolean;
|
|
477
|
+
state8?: boolean;
|
|
478
|
+
state9?: boolean;
|
|
479
|
+
state10?: boolean;
|
|
480
|
+
topicId?: string;
|
|
481
|
+
topicSlug?: string;
|
|
482
|
+
categoryId?: string;
|
|
483
|
+
categorySlug?: string;
|
|
484
|
+
postIds?: string[];
|
|
485
|
+
excludeIds?: string[];
|
|
486
|
+
page?: number;
|
|
487
|
+
pageSize?: number;
|
|
474
488
|
}
|
|
475
489
|
interface FindParams {
|
|
476
490
|
id?: string;
|
|
477
491
|
type?: PostType;
|
|
478
492
|
slug?: string;
|
|
493
|
+
isActive?: boolean;
|
|
479
494
|
}
|
|
480
495
|
interface FindManyParams {
|
|
481
496
|
type: PostType;
|
|
@@ -483,21 +498,23 @@ interface FindManyParams {
|
|
|
483
498
|
}
|
|
484
499
|
|
|
485
500
|
declare function createPostQueryRepository(prisma: any): {
|
|
486
|
-
findListCards: ({ locale, searchString, type,
|
|
501
|
+
findListCards: ({ locale, searchString, type, isActive, isIndexActive, isSlugActive, isFeatured, isShownOnHome, state1, state2, state3, state4, state5, state6, state7, state8, state9, state10, topicId, topicSlug, categoryId, categorySlug, postIds, excludeIds, page, pageSize, }: FindListCardsParams) => Promise<{
|
|
487
502
|
items: PostListCard[];
|
|
488
503
|
total: number;
|
|
489
504
|
}>;
|
|
490
505
|
findMany: ({ type, topicId, }: FindManyParams) => Promise<(Post & {
|
|
491
506
|
translations: PostTranslation[];
|
|
492
507
|
})[]>;
|
|
493
|
-
find: (
|
|
508
|
+
find: ({ isActive, ...rest }: FindParams) => Promise<(Post & {
|
|
494
509
|
translations: PostTranslation[];
|
|
495
510
|
}) | null>;
|
|
496
|
-
findFull: (
|
|
497
|
-
findWithSeoMetadata: (
|
|
511
|
+
findFull: ({ isActive, ...rest }: FindParams) => Promise<PostFull | null>;
|
|
512
|
+
findWithSeoMetadata: ({ isActive, ...rest }: FindParams) => Promise<(Post & {
|
|
498
513
|
translations: PostTranslation[];
|
|
499
514
|
seoMetadatas: SeoMetadata[];
|
|
500
|
-
author:
|
|
515
|
+
author: AdminSafe & {
|
|
516
|
+
translations: AdminTranslation[];
|
|
517
|
+
};
|
|
501
518
|
coverImage: File & {
|
|
502
519
|
translations: FileTranslation[];
|
|
503
520
|
};
|
package/dist/server/index.js
CHANGED
|
@@ -1121,14 +1121,32 @@ function createPostQueryRepository(prisma) {
|
|
|
1121
1121
|
locale,
|
|
1122
1122
|
// search
|
|
1123
1123
|
searchString,
|
|
1124
|
+
// type
|
|
1124
1125
|
type,
|
|
1125
|
-
|
|
1126
|
-
postIds,
|
|
1126
|
+
// states
|
|
1127
1127
|
isActive,
|
|
1128
1128
|
isIndexActive,
|
|
1129
1129
|
isSlugActive,
|
|
1130
1130
|
isFeatured,
|
|
1131
1131
|
isShownOnHome,
|
|
1132
|
+
state1,
|
|
1133
|
+
state2,
|
|
1134
|
+
state3,
|
|
1135
|
+
state4,
|
|
1136
|
+
state5,
|
|
1137
|
+
state6,
|
|
1138
|
+
state7,
|
|
1139
|
+
state8,
|
|
1140
|
+
state9,
|
|
1141
|
+
state10,
|
|
1142
|
+
// relations
|
|
1143
|
+
topicId,
|
|
1144
|
+
topicSlug,
|
|
1145
|
+
categoryId,
|
|
1146
|
+
categorySlug,
|
|
1147
|
+
// specified ids
|
|
1148
|
+
postIds,
|
|
1149
|
+
excludeIds,
|
|
1132
1150
|
// pagination
|
|
1133
1151
|
page,
|
|
1134
1152
|
pageSize
|
|
@@ -1139,7 +1157,13 @@ function createPostQueryRepository(prisma) {
|
|
|
1139
1157
|
...searchString ? { searchString } : {},
|
|
1140
1158
|
locale,
|
|
1141
1159
|
rootFields: ["slug"],
|
|
1142
|
-
translationFields: [
|
|
1160
|
+
translationFields: [
|
|
1161
|
+
"title",
|
|
1162
|
+
"subtitle",
|
|
1163
|
+
"summary",
|
|
1164
|
+
"description",
|
|
1165
|
+
"content"
|
|
1166
|
+
]
|
|
1143
1167
|
}),
|
|
1144
1168
|
// type
|
|
1145
1169
|
...type ? { type } : {},
|
|
@@ -1149,10 +1173,28 @@ function createPostQueryRepository(prisma) {
|
|
|
1149
1173
|
...isSlugActive ? { isSlugActive: true } : {},
|
|
1150
1174
|
...isFeatured ? { isFeatured: true } : {},
|
|
1151
1175
|
...isShownOnHome ? { isShownOnHome: true } : {},
|
|
1176
|
+
...state1 ? { state1: true } : {},
|
|
1177
|
+
...state2 ? { state2: true } : {},
|
|
1178
|
+
...state3 ? { state3: true } : {},
|
|
1179
|
+
...state4 ? { state4: true } : {},
|
|
1180
|
+
...state5 ? { state5: true } : {},
|
|
1181
|
+
...state6 ? { state6: true } : {},
|
|
1182
|
+
...state7 ? { state7: true } : {},
|
|
1183
|
+
...state8 ? { state8: true } : {},
|
|
1184
|
+
...state9 ? { state9: true } : {},
|
|
1185
|
+
...state10 ? { state10: true } : {},
|
|
1152
1186
|
// relations: Post
|
|
1153
1187
|
...topicId ? { topicId } : {},
|
|
1188
|
+
...topicSlug ? { topic: { slug: topicSlug } } : {},
|
|
1189
|
+
...categoryId ? { parents: { some: { id: categoryId } } } : {},
|
|
1190
|
+
...categorySlug ? { parents: { some: { slug: categorySlug } } } : {},
|
|
1154
1191
|
// Specified ids
|
|
1155
|
-
...postIds
|
|
1192
|
+
...postIds?.length || excludeIds?.length ? {
|
|
1193
|
+
id: {
|
|
1194
|
+
...postIds ? { in: postIds } : {},
|
|
1195
|
+
...excludeIds ? { notIn: excludeIds } : {}
|
|
1196
|
+
}
|
|
1197
|
+
} : {}
|
|
1156
1198
|
};
|
|
1157
1199
|
const [items, total] = await prisma.$transaction([
|
|
1158
1200
|
prisma.post.findMany({
|
|
@@ -1165,11 +1207,14 @@ function createPostQueryRepository(prisma) {
|
|
|
1165
1207
|
]);
|
|
1166
1208
|
return { items, total };
|
|
1167
1209
|
}
|
|
1168
|
-
async function find(
|
|
1169
|
-
|
|
1210
|
+
async function find({
|
|
1211
|
+
isActive,
|
|
1212
|
+
...rest
|
|
1213
|
+
}) {
|
|
1214
|
+
const where = buildWhere3(rest);
|
|
1170
1215
|
if (!where) return null;
|
|
1171
1216
|
return prisma.post.findFirst({
|
|
1172
|
-
where,
|
|
1217
|
+
where: { ...where, ...isActive ? { isActive } : {} },
|
|
1173
1218
|
include: { translations: true }
|
|
1174
1219
|
});
|
|
1175
1220
|
}
|
|
@@ -1183,23 +1228,32 @@ function createPostQueryRepository(prisma) {
|
|
|
1183
1228
|
include: { translations: true }
|
|
1184
1229
|
});
|
|
1185
1230
|
}
|
|
1186
|
-
async function findFull(
|
|
1187
|
-
|
|
1231
|
+
async function findFull({
|
|
1232
|
+
isActive,
|
|
1233
|
+
...rest
|
|
1234
|
+
}) {
|
|
1235
|
+
const where = buildWhere3(rest);
|
|
1188
1236
|
if (!where) return null;
|
|
1189
1237
|
return prisma.post.findFirst({
|
|
1190
|
-
where,
|
|
1238
|
+
where: { ...where, ...isActive ? { isActive } : {} },
|
|
1191
1239
|
include: POST_FULL_INCLUDE
|
|
1192
1240
|
});
|
|
1193
1241
|
}
|
|
1194
|
-
async function findWithSeoMetadata(
|
|
1195
|
-
|
|
1242
|
+
async function findWithSeoMetadata({
|
|
1243
|
+
isActive,
|
|
1244
|
+
...rest
|
|
1245
|
+
}) {
|
|
1246
|
+
const where = buildWhere3(rest);
|
|
1196
1247
|
if (!where) return null;
|
|
1197
1248
|
return prisma.post.findFirst({
|
|
1198
|
-
where,
|
|
1249
|
+
where: { ...where, ...isActive ? { isActive } : {} },
|
|
1199
1250
|
include: {
|
|
1200
1251
|
translations: true,
|
|
1201
1252
|
seoMetadatas: true,
|
|
1202
|
-
author:
|
|
1253
|
+
author: {
|
|
1254
|
+
include: { translations: true },
|
|
1255
|
+
omit: { passwordHash: true }
|
|
1256
|
+
},
|
|
1203
1257
|
coverImage: { include: { translations: true } }
|
|
1204
1258
|
}
|
|
1205
1259
|
});
|