@rxdrag/website-lib-core 0.0.4 → 0.0.7
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/index.ts +1 -0
- package/package.json +12 -13
- package/src/entify/Entify.ts +365 -0
- package/{dist/entify/index.d.ts → src/entify/index.ts} +4 -4
- package/src/entify/lib/createEntifyClient.ts +23 -0
- package/{dist/entify/lib/index.d.ts → src/entify/lib/index.ts} +29 -29
- package/src/entify/lib/langFields.ts +12 -0
- package/src/entify/lib/newAvatarQueryOptions.ts +5 -0
- package/src/entify/lib/newOgImageQueryOptions.ts +6 -0
- package/src/entify/lib/newPageMetaOptions.ts +20 -0
- package/src/entify/lib/newQueryPostOptions.ts +41 -0
- package/src/entify/lib/newQueryProductOptions.ts +90 -0
- package/src/entify/lib/newQueryProductsMediaOptions.ts +26 -0
- package/src/entify/lib/queryAllProducts.ts +27 -0
- package/src/entify/lib/queryEntityList.ts +44 -0
- package/src/entify/lib/queryFeaturedProducts.ts +47 -0
- package/src/entify/lib/queryLangs.ts +47 -0
- package/src/entify/lib/queryLatestPosts.ts +65 -0
- package/src/entify/lib/queryOneEntity.ts +67 -0
- package/src/entify/lib/queryOnePostById.ts +21 -0
- package/src/entify/lib/queryOnePostBySlug.ts +21 -0
- package/src/entify/lib/queryOnePostCategoryBySlug.ts +30 -0
- package/src/entify/lib/queryOneProductById.ts +20 -0
- package/src/entify/lib/queryOneProductBySlug.ts +21 -0
- package/src/entify/lib/queryOneProductCategoryBySlug.ts +30 -0
- package/src/entify/lib/queryOneTheme.ts +76 -0
- package/src/entify/lib/queryOneUser.ts +38 -0
- package/src/entify/lib/queryPostCategories.ts +48 -0
- package/src/entify/lib/queryPostSlugs.ts +32 -0
- package/src/entify/lib/queryPosts.ts +92 -0
- package/src/entify/lib/queryProductCategories.ts +44 -0
- package/src/entify/lib/queryProducts.ts +69 -0
- package/src/entify/lib/queryProductsInMenu.ts +31 -0
- package/src/entify/lib/queryUserIds.ts +24 -0
- package/src/entify/lib/queryUserPosts.ts +74 -0
- package/src/entify/lib/queryWebSiteSettings.ts +29 -0
- package/src/entify/lib/searchProducts.ts +70 -0
- package/src/entify/lib/sendEmail.ts +8 -0
- package/src/entify/lib/toQueryOptions.ts +20 -0
- package/src/entify/lib/upsertEntity.ts +9 -0
- package/src/entify/types/index.ts +2 -0
- package/src/entify/types/utils.ts +4 -0
- package/src/entify/types/variables.ts +7 -0
- package/src/entify/view-model/funcs.ts +271 -0
- package/src/entify/view-model/index.ts +2 -0
- package/src/entify/view-model/models.ts +143 -0
- package/{dist/index.d.ts → src/index.ts} +5 -5
- package/src/motion/consts.ts +598 -0
- package/{dist/motion/index.d.ts → src/motion/index.ts} +2 -2
- package/src/motion/types.ts +46 -0
- package/src/react/components/EnquiryForm/Input.tsx +52 -0
- package/src/react/components/EnquiryForm/Submit.tsx +30 -0
- package/src/react/components/EnquiryForm/Textarea.tsx +51 -0
- package/src/react/components/EnquiryForm/index.tsx +334 -0
- package/src/react/components/GoogleConsent/CookieItemPanel.tsx +81 -0
- package/src/react/components/GoogleConsent/CumtomizedModal.tsx +149 -0
- package/src/react/components/GoogleConsent/GoogleConsent.tsx +101 -0
- package/src/react/components/GoogleConsent/README.md +1 -0
- package/src/react/components/GoogleConsent/gtags.ts +68 -0
- package/src/react/components/GoogleConsent/index.ts +3 -0
- package/src/react/components/GoogleConsent/types.ts +18 -0
- package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -0
- package/src/react/components/Medias/index.tsx +347 -0
- package/src/react/components/ProductCard/ProductCard.tsx +23 -0
- package/src/react/components/ProductCard/ProductCardPreview.tsx +12 -0
- package/src/react/components/ProductCard/ProductCta/index.tsx +41 -0
- package/src/react/components/ProductCard/ProductCta/style.css +4 -0
- package/src/react/components/ProductCard/ProductDescription/index.tsx +13 -0
- package/src/react/components/ProductCard/ProductDescription/style.css +6 -0
- package/src/react/components/ProductCard/ProductMedia/index.tsx +34 -0
- package/src/react/components/ProductCard/ProductMedia/style.css +6 -0
- package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -0
- package/src/react/components/ProductCard/ProductTitle/style.css +4 -0
- package/src/react/components/ProductCard/ProductView.tsx +35 -0
- package/{dist/react/components/ProductCard/index.d.ts → src/react/components/ProductCard/index.ts} +6 -6
- package/src/react/components/ProductCard/useQueryProduct.ts +32 -0
- package/src/react/components/RichTextOutline/index.tsx +76 -0
- package/src/react/components/RichTextOutline/useAcitviedHeading.ts +54 -0
- package/src/react/components/RichTextOutline/useAnchorScroll.ts +24 -0
- package/src/react/components/Scroller.tsx +7 -0
- package/src/react/components/SearchInput.tsx +34 -0
- package/src/react/components/Share/index.tsx +69 -0
- package/src/react/components/Share/socials.tsx +79 -0
- package/src/react/components/Share//350/265/204/346/226/231.md +7 -0
- package/src/react/components/ToTop/index.tsx +33 -0
- package/src/react/components/ToTop.tsx +33 -0
- package/{dist/react/components/index.d.ts → src/react/components/index.ts} +8 -8
- package/src/react/hooks/index.ts +1 -0
- package/src/react/hooks/useScroll.ts +23 -0
- package/{dist/react/index.d.ts → src/react/index.ts} +2 -2
- package/src/robots.ts +4 -0
- package/src/scripts/actions.ts +304 -0
- package/src/scripts/consts.ts +32 -0
- package/src/scripts/events.ts +33 -0
- package/{dist/scripts/index.d.ts → src/scripts/index.ts} +3 -3
- package/dist/entify/Entify.d.ts +0 -138
- package/dist/entify/lib/createEntifyClient.d.ts +0 -3
- package/dist/entify/lib/langFields.d.ts +0 -2
- package/dist/entify/lib/newAvatarQueryOptions.d.ts +0 -2
- package/dist/entify/lib/newOgImageQueryOptions.d.ts +0 -2
- package/dist/entify/lib/newPageMetaOptions.d.ts +0 -2
- package/dist/entify/lib/newQueryPostOptions.d.ts +0 -3
- package/dist/entify/lib/newQueryProductOptions.d.ts +0 -3
- package/dist/entify/lib/newQueryProductsMediaOptions.d.ts +0 -3
- package/dist/entify/lib/queryAllProducts.d.ts +0 -4
- package/dist/entify/lib/queryEntityList.d.ts +0 -3
- package/dist/entify/lib/queryFeaturedProducts.d.ts +0 -4
- package/dist/entify/lib/queryLangs.d.ts +0 -4
- package/dist/entify/lib/queryLatestPosts.d.ts +0 -4
- package/dist/entify/lib/queryOneEntity.d.ts +0 -5
- package/dist/entify/lib/queryOnePostById.d.ts +0 -3
- package/dist/entify/lib/queryOnePostBySlug.d.ts +0 -3
- package/dist/entify/lib/queryOnePostCategoryBySlug.d.ts +0 -3
- package/dist/entify/lib/queryOneProductById.d.ts +0 -3
- package/dist/entify/lib/queryOneProductBySlug.d.ts +0 -3
- package/dist/entify/lib/queryOneProductCategoryBySlug.d.ts +0 -3
- package/dist/entify/lib/queryOneTheme.d.ts +0 -3
- package/dist/entify/lib/queryOneUser.d.ts +0 -3
- package/dist/entify/lib/queryPostCategories.d.ts +0 -4
- package/dist/entify/lib/queryPostSlugs.d.ts +0 -4
- package/dist/entify/lib/queryPosts.d.ts +0 -10
- package/dist/entify/lib/queryProductCategories.d.ts +0 -4
- package/dist/entify/lib/queryProducts.d.ts +0 -6
- package/dist/entify/lib/queryProductsInMenu.d.ts +0 -2
- package/dist/entify/lib/queryUserIds.d.ts +0 -4
- package/dist/entify/lib/queryUserPosts.d.ts +0 -9
- package/dist/entify/lib/queryWebSiteSettings.d.ts +0 -3
- package/dist/entify/lib/searchProducts.d.ts +0 -4
- package/dist/entify/lib/sendEmail.d.ts +0 -3
- package/dist/entify/lib/toQueryOptions.d.ts +0 -3
- package/dist/entify/lib/upsertEntity.d.ts +0 -2
- package/dist/entify/types/index.d.ts +0 -2
- package/dist/entify/types/utils.d.ts +0 -4
- package/dist/entify/types/variables.d.ts +0 -7
- package/dist/entify/view-model/funcs.d.ts +0 -20
- package/dist/entify/view-model/index.d.ts +0 -2
- package/dist/entify/view-model/models.d.ts +0 -119
- package/dist/index.mjs +0 -40514
- package/dist/index.mjs.map +0 -1
- package/dist/motion/consts.d.ts +0 -77
- package/dist/motion/types.d.ts +0 -26
- package/dist/react/components/EnquiryForm/Input.d.ts +0 -15
- package/dist/react/components/EnquiryForm/Submit.d.ts +0 -8
- package/dist/react/components/EnquiryForm/Textarea.d.ts +0 -13
- package/dist/react/components/EnquiryForm/index.d.ts +0 -22
- package/dist/react/components/Medias/index.d.ts +0 -8
- package/dist/react/components/ProductCard/ProductCard.d.ts +0 -15
- package/dist/react/components/ProductCard/ProductCardPreview.d.ts +0 -2
- package/dist/react/components/ProductCard/ProductCta/index.d.ts +0 -5
- package/dist/react/components/ProductCard/ProductDescription/index.d.ts +0 -2
- package/dist/react/components/ProductCard/ProductMedia/index.d.ts +0 -7
- package/dist/react/components/ProductCard/ProductTitle/index.d.ts +0 -2
- package/dist/react/components/ProductCard/ProductView.d.ts +0 -5
- package/dist/react/components/ProductCard/useQueryProduct.d.ts +0 -2
- package/dist/react/components/RichTextOutline/index.d.ts +0 -8
- package/dist/react/components/RichTextOutline/useAcitviedHeading.d.ts +0 -1
- package/dist/react/components/Scroller.d.ts +0 -3
- package/dist/react/components/SearchInput.d.ts +0 -2
- package/dist/react/components/Share/index.d.ts +0 -6
- package/dist/react/components/Share/socials.d.ts +0 -10
- package/dist/react/components/ToTop.d.ts +0 -5
- package/dist/react/hooks/index.d.ts +0 -1
- package/dist/react/hooks/useScroll.d.ts +0 -2
- package/dist/robots.d.ts +0 -2
- package/dist/scripts/actions.d.ts +0 -85
- package/dist/scripts/consts.d.ts +0 -21
- package/dist/scripts/events.d.ts +0 -11
- package/dist/style.css +0 -98
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Post, PostBoolExp, PostOrderBy, PostDistinctExp, PostFields, PublishableStatus, PostAssciations, PostQueryOptions, MediaQueryOptions, UserQueryOptions, UserFields } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { queryEntityList } from "./queryEntityList";
|
|
3
|
+
import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
|
|
4
|
+
import { EnvVariables, TSize } from "../types";
|
|
5
|
+
import { TPost } from "../view-model";
|
|
6
|
+
|
|
7
|
+
export interface ListConditions {
|
|
8
|
+
category?: string;//category slug
|
|
9
|
+
page?: number;
|
|
10
|
+
pageSize: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function queryPosts(
|
|
14
|
+
conditions: ListConditions,
|
|
15
|
+
coverSize: TSize | undefined,
|
|
16
|
+
envVariables: EnvVariables,
|
|
17
|
+
selectFields?: (keyof Post)[]
|
|
18
|
+
) {
|
|
19
|
+
const { category: categorySlug, page = 1, pageSize } = conditions;
|
|
20
|
+
|
|
21
|
+
let where = {}
|
|
22
|
+
if (categorySlug) {
|
|
23
|
+
where = {
|
|
24
|
+
[PostAssciations.category]: {
|
|
25
|
+
slug: {
|
|
26
|
+
"_eq": categorySlug
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 默认查询字段
|
|
33
|
+
const defaultFields = [
|
|
34
|
+
PostFields.id,
|
|
35
|
+
PostFields.title,
|
|
36
|
+
PostFields.slug,
|
|
37
|
+
PostFields.description,
|
|
38
|
+
PostFields.status,
|
|
39
|
+
PostFields.updatedAt,
|
|
40
|
+
PostFields.createdAt,
|
|
41
|
+
PostFields.publishedAt,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
// 使用指定的字段或默认字段
|
|
45
|
+
const fields = selectFields || defaultFields;
|
|
46
|
+
|
|
47
|
+
const queryOptions = new PostQueryOptions(
|
|
48
|
+
fields,
|
|
49
|
+
{
|
|
50
|
+
offset: (page - 1) * pageSize,
|
|
51
|
+
limit: pageSize,
|
|
52
|
+
where: {
|
|
53
|
+
[PostFields.status]: {
|
|
54
|
+
"_eq": PublishableStatus.published
|
|
55
|
+
},
|
|
56
|
+
...where,
|
|
57
|
+
},
|
|
58
|
+
orderBy: [
|
|
59
|
+
{
|
|
60
|
+
[PostFields.createdAt]: OrderBy.desc
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// 只有在需要查询封面图时才添加封面图查询
|
|
67
|
+
if (!selectFields || selectFields.includes('cover' as keyof Post)) {
|
|
68
|
+
queryOptions.cover(
|
|
69
|
+
new MediaQueryOptions().file(
|
|
70
|
+
[
|
|
71
|
+
"thumbnail",
|
|
72
|
+
coverSize ? `resize(width:${coverSize.width}, height:${coverSize.height})` : "resize(width:480, height:180)"
|
|
73
|
+
]
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 只有在需要查询作者时才添加作者查询
|
|
79
|
+
if (!selectFields || selectFields.includes('author' as keyof Post)) {
|
|
80
|
+
queryOptions.author(
|
|
81
|
+
new UserQueryOptions([UserFields.id, UserFields.name])
|
|
82
|
+
.avatar(new MediaQueryOptions().file(["thumbnail"]))
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const result = await queryEntityList<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
|
|
87
|
+
queryOptions,
|
|
88
|
+
envVariables
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return result as ListResult<TPost> | undefined;
|
|
92
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp, ProductCategoryFields, ProductCategoryQueryOptions, ProductFields, ProductQueryOptions, PublishableStatus } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { queryEntityList } from "./queryEntityList";
|
|
3
|
+
import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
|
|
4
|
+
import { EnvVariables } from "../types";
|
|
5
|
+
import { TProductCategory } from "../view-model";
|
|
6
|
+
|
|
7
|
+
export async function queryProductCategories(envVariables: EnvVariables) {
|
|
8
|
+
|
|
9
|
+
const result = await queryEntityList<ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp>(
|
|
10
|
+
new ProductCategoryQueryOptions(
|
|
11
|
+
[
|
|
12
|
+
ProductCategoryFields.id,
|
|
13
|
+
ProductCategoryFields.name,
|
|
14
|
+
ProductCategoryFields.slug,
|
|
15
|
+
ProductCategoryFields.description,
|
|
16
|
+
],
|
|
17
|
+
{
|
|
18
|
+
orderBy: [
|
|
19
|
+
{ [ProductCategoryFields.seqValue]: OrderBy.asc }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
.products(
|
|
24
|
+
new ProductQueryOptions(
|
|
25
|
+
[ProductFields.id, ProductFields.title, ProductFields.slug],
|
|
26
|
+
{
|
|
27
|
+
where: {
|
|
28
|
+
showInNavMenu: {
|
|
29
|
+
"_eq": true
|
|
30
|
+
},
|
|
31
|
+
[ProductFields.status]: {
|
|
32
|
+
"_eq": PublishableStatus.published
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
orderBy: [
|
|
36
|
+
{ [ProductFields.seqValue]: OrderBy.asc }
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
),
|
|
41
|
+
envVariables
|
|
42
|
+
);
|
|
43
|
+
return result as ListResult<TProductCategory> | undefined;
|
|
44
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp, ProductFields, ProductQueryOptions, PublishableStatus, ProductAssciations } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { ListConditions } from "./queryPosts";
|
|
3
|
+
import { queryEntityList } from "./queryEntityList";
|
|
4
|
+
import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
|
|
5
|
+
import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
|
|
6
|
+
import { EnvVariables, TSize } from "../types";
|
|
7
|
+
import { TProduct } from "../view-model";
|
|
8
|
+
|
|
9
|
+
export async function queryProducts(
|
|
10
|
+
conditions: ListConditions,
|
|
11
|
+
imageSize: TSize | undefined,
|
|
12
|
+
envVariables: EnvVariables,
|
|
13
|
+
selectFields?: (keyof Product)[]
|
|
14
|
+
) {
|
|
15
|
+
const { category: categorySlug, page = 1, pageSize = 10 } = conditions;
|
|
16
|
+
|
|
17
|
+
let where = {}
|
|
18
|
+
if (categorySlug) {
|
|
19
|
+
where = {
|
|
20
|
+
[ProductAssciations.category]: {
|
|
21
|
+
slug: {
|
|
22
|
+
"_eq": categorySlug
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 默认查询字段
|
|
29
|
+
const defaultFields = [
|
|
30
|
+
ProductFields.id,
|
|
31
|
+
ProductFields.slug,
|
|
32
|
+
ProductFields.title,
|
|
33
|
+
ProductFields.shortTitle,
|
|
34
|
+
ProductFields.description,
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
// 使用指定的字段或默认字段
|
|
38
|
+
const fields = selectFields || defaultFields;
|
|
39
|
+
|
|
40
|
+
const queryOptions = new ProductQueryOptions(
|
|
41
|
+
fields,
|
|
42
|
+
{
|
|
43
|
+
offset: (page - 1) * pageSize,
|
|
44
|
+
limit: pageSize,
|
|
45
|
+
where: {
|
|
46
|
+
[ProductFields.status]: {
|
|
47
|
+
"_eq": PublishableStatus.published
|
|
48
|
+
},
|
|
49
|
+
...where,
|
|
50
|
+
},
|
|
51
|
+
orderBy: [
|
|
52
|
+
{ [ProductFields.seqValue]: OrderBy.asc }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// 只有在不指定字段或需要查询媒体时才添加媒体查询
|
|
58
|
+
if (!selectFields || !selectFields.includes('slug' as keyof Product)) {
|
|
59
|
+
queryOptions.mediaPivots(
|
|
60
|
+
newQueryProductsMediaOptions(imageSize)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = await queryEntityList<Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp>(
|
|
65
|
+
queryOptions,
|
|
66
|
+
envVariables
|
|
67
|
+
);
|
|
68
|
+
return result as ListResult<TProduct> | undefined;
|
|
69
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProductFields, ProductQueryOptions, PublishableStatus } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { queryEntityList } from "./queryEntityList";
|
|
3
|
+
import { EnvVariables } from "../types";
|
|
4
|
+
import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
|
|
5
|
+
|
|
6
|
+
export async function queryProductsInMenu(envVariables: EnvVariables) {
|
|
7
|
+
const result = await queryEntityList(
|
|
8
|
+
new ProductQueryOptions(
|
|
9
|
+
[
|
|
10
|
+
ProductFields.id,
|
|
11
|
+
ProductFields.slug,
|
|
12
|
+
ProductFields.title,
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
where: {
|
|
16
|
+
showInNavMenu: {
|
|
17
|
+
"_eq": true
|
|
18
|
+
},
|
|
19
|
+
[ProductFields.status]: {
|
|
20
|
+
"_eq": PublishableStatus.published
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
.mediaPivots(
|
|
26
|
+
newQueryProductsMediaOptions()
|
|
27
|
+
),
|
|
28
|
+
envVariables
|
|
29
|
+
);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ListResult } from "@rxdrag/entify-hooks";
|
|
2
|
+
import {
|
|
3
|
+
User,
|
|
4
|
+
UserBoolExp,
|
|
5
|
+
UserDistinctExp,
|
|
6
|
+
UserFields,
|
|
7
|
+
UserOrderBy,
|
|
8
|
+
UserQueryOptions,
|
|
9
|
+
} from "@rxdrag/rxcms-models";
|
|
10
|
+
import { EnvVariables } from "../types";
|
|
11
|
+
import { TUser } from "../view-model";
|
|
12
|
+
import { queryEntityList } from "./queryEntityList";
|
|
13
|
+
|
|
14
|
+
export async function queryUserIds(envVariables: EnvVariables) {
|
|
15
|
+
const queryOptions = new UserQueryOptions([UserFields.id]);
|
|
16
|
+
|
|
17
|
+
const result = await queryEntityList<
|
|
18
|
+
User,
|
|
19
|
+
UserBoolExp,
|
|
20
|
+
UserOrderBy,
|
|
21
|
+
UserDistinctExp
|
|
22
|
+
>(queryOptions, envVariables);
|
|
23
|
+
return result as ListResult<TUser> | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
|
|
2
|
+
import {
|
|
3
|
+
PostBoolExp,
|
|
4
|
+
PostOrderBy,
|
|
5
|
+
PostDistinctExp,
|
|
6
|
+
PostFields,
|
|
7
|
+
Post,
|
|
8
|
+
PostQueryOptions,
|
|
9
|
+
MediaQueryOptions,
|
|
10
|
+
PublishableStatus,
|
|
11
|
+
PostAssciations,
|
|
12
|
+
} from "@rxdrag/rxcms-models";
|
|
13
|
+
import { queryEntityList } from "./queryEntityList";
|
|
14
|
+
import { EnvVariables } from "../types";
|
|
15
|
+
import { TPost } from "../view-model";
|
|
16
|
+
|
|
17
|
+
export type UserPostsCondition = {
|
|
18
|
+
userId: string;
|
|
19
|
+
page?: number;
|
|
20
|
+
pageSize?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export async function queryUserPosts(
|
|
24
|
+
pagination: UserPostsCondition,
|
|
25
|
+
envVariables: EnvVariables
|
|
26
|
+
) {
|
|
27
|
+
const { userId, page = 1, pageSize = 1000 } = pagination;
|
|
28
|
+
const result = await queryEntityList<
|
|
29
|
+
Post,
|
|
30
|
+
PostBoolExp,
|
|
31
|
+
PostOrderBy,
|
|
32
|
+
PostDistinctExp
|
|
33
|
+
>(
|
|
34
|
+
new PostQueryOptions(
|
|
35
|
+
[
|
|
36
|
+
PostFields.id,
|
|
37
|
+
PostFields.slug,
|
|
38
|
+
PostFields.title,
|
|
39
|
+
PostFields.description,
|
|
40
|
+
PostFields.createdAt,
|
|
41
|
+
PostFields.updatedAt,
|
|
42
|
+
],
|
|
43
|
+
{
|
|
44
|
+
offset: (page - 1) * pageSize,
|
|
45
|
+
limit: pageSize,
|
|
46
|
+
orderBy: [
|
|
47
|
+
{
|
|
48
|
+
//暂时按照更新时间排序
|
|
49
|
+
updatedAt: OrderBy.desc,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
where: {
|
|
53
|
+
[PostFields.status]: {
|
|
54
|
+
_eq: PublishableStatus.published,
|
|
55
|
+
},
|
|
56
|
+
[PostAssciations.author]: {
|
|
57
|
+
id: {
|
|
58
|
+
_eq: userId,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
.cover(
|
|
65
|
+
new MediaQueryOptions().file([
|
|
66
|
+
"thumbnail",
|
|
67
|
+
"resize(width:480, height:180)",
|
|
68
|
+
])
|
|
69
|
+
)
|
|
70
|
+
.setNoQuery(!userId),
|
|
71
|
+
envVariables
|
|
72
|
+
);
|
|
73
|
+
return result as ListResult<TPost> | undefined;
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WebsiteSettings,
|
|
3
|
+
WebsiteSettingsBoolExp,
|
|
4
|
+
WebsiteSettingsOrderBy,
|
|
5
|
+
WebsiteSettingsDistinctExp,
|
|
6
|
+
WebsiteSettingsFields,
|
|
7
|
+
WebsiteSettingsQueryOptions,
|
|
8
|
+
} from "@rxdrag/rxcms-models";
|
|
9
|
+
import { queryOneEntity } from "./queryOneEntity";
|
|
10
|
+
import { EnvVariables } from "../types";
|
|
11
|
+
|
|
12
|
+
export async function queryWebSiteSettings(envVariables: EnvVariables) {
|
|
13
|
+
const result = await queryOneEntity<
|
|
14
|
+
WebsiteSettings,
|
|
15
|
+
WebsiteSettingsBoolExp,
|
|
16
|
+
WebsiteSettingsOrderBy,
|
|
17
|
+
WebsiteSettingsDistinctExp
|
|
18
|
+
>(
|
|
19
|
+
new WebsiteSettingsQueryOptions([
|
|
20
|
+
WebsiteSettingsFields.footerCode,
|
|
21
|
+
WebsiteSettingsFields.headerCode,
|
|
22
|
+
WebsiteSettingsFields.gaTrackingId,
|
|
23
|
+
WebsiteSettingsFields.noticeEmail,
|
|
24
|
+
WebsiteSettingsFields.smtpConfig,
|
|
25
|
+
]),
|
|
26
|
+
envVariables
|
|
27
|
+
);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Product,
|
|
3
|
+
ProductBoolExp,
|
|
4
|
+
ProductOrderBy,
|
|
5
|
+
ProductDistinctExp,
|
|
6
|
+
ProductFields,
|
|
7
|
+
ProductQueryOptions,
|
|
8
|
+
PublishableStatus,
|
|
9
|
+
} from "@rxdrag/rxcms-models";
|
|
10
|
+
import { queryEntityList } from "./queryEntityList";
|
|
11
|
+
import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
|
|
12
|
+
import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
|
|
13
|
+
import { EnvVariables } from "../types";
|
|
14
|
+
import { TProduct } from "../view-model";
|
|
15
|
+
|
|
16
|
+
export async function searchProducts(
|
|
17
|
+
keyword: string,
|
|
18
|
+
envVariables: EnvVariables
|
|
19
|
+
) {
|
|
20
|
+
const keyExp = keyword
|
|
21
|
+
? {
|
|
22
|
+
_or: [
|
|
23
|
+
{
|
|
24
|
+
title: {
|
|
25
|
+
_like: `%${keyword}%`,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
[ProductFields.description]: {
|
|
30
|
+
_like: `%${keyword}%`,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
}
|
|
35
|
+
: undefined;
|
|
36
|
+
|
|
37
|
+
const keyArray = keyExp ? [keyExp] : [];
|
|
38
|
+
|
|
39
|
+
const queryOptions = new ProductQueryOptions(
|
|
40
|
+
[
|
|
41
|
+
ProductFields.id,
|
|
42
|
+
ProductFields.slug,
|
|
43
|
+
ProductFields.title,
|
|
44
|
+
ProductFields.shortTitle,
|
|
45
|
+
ProductFields.description,
|
|
46
|
+
],
|
|
47
|
+
{
|
|
48
|
+
limit: 100,
|
|
49
|
+
where: {
|
|
50
|
+
_and: [
|
|
51
|
+
{
|
|
52
|
+
[ProductFields.status]: {
|
|
53
|
+
_eq: PublishableStatus.published,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
...keyArray,
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
orderBy: [{ [ProductFields.seqValue]: OrderBy.asc }],
|
|
60
|
+
}
|
|
61
|
+
).mediaPivots(newQueryProductsMediaOptions());
|
|
62
|
+
|
|
63
|
+
const result = await queryEntityList<
|
|
64
|
+
Product,
|
|
65
|
+
ProductBoolExp,
|
|
66
|
+
ProductOrderBy,
|
|
67
|
+
ProductDistinctExp
|
|
68
|
+
>(queryOptions, envVariables);
|
|
69
|
+
return result as ListResult<TProduct> | undefined;
|
|
70
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IEmail } from "@rxdrag/entify-hooks";
|
|
2
|
+
import { createEntifyClient } from "./createEntifyClient";
|
|
3
|
+
import { EnvVariables } from "../types";
|
|
4
|
+
|
|
5
|
+
export async function sendEmail(email: IEmail, envVariables: EnvVariables) {
|
|
6
|
+
const client = createEntifyClient(envVariables);
|
|
7
|
+
return await client.sendEmail(email);
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IEntity, IQueryOptions } from "@rxdrag/entify-hooks";
|
|
2
|
+
import { ICustomizedDataSource } from "../types";
|
|
3
|
+
import { QueryOptions } from "@rxdrag/rxcms-models";
|
|
4
|
+
|
|
5
|
+
export function toQueryOptions(dataSource: ICustomizedDataSource): IQueryOptions<IEntity> {
|
|
6
|
+
const { entity, pageSize, where, orderBy, fields } = dataSource;
|
|
7
|
+
if (!entity) {
|
|
8
|
+
throw new Error("entity is required in dataSource");
|
|
9
|
+
}
|
|
10
|
+
const queryOptions = new QueryOptions(
|
|
11
|
+
entity,
|
|
12
|
+
fields ? ["id", fields] : ["id"],
|
|
13
|
+
{
|
|
14
|
+
where,
|
|
15
|
+
orderBy,
|
|
16
|
+
limit: pageSize,
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
return queryOptions as unknown as IQueryOptions<IEntity>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EnvVariables } from "../types";
|
|
2
|
+
import { createEntifyClient } from "./createEntifyClient";
|
|
3
|
+
|
|
4
|
+
export async function upsertEntity<Input = object>(entityName: string, object: Input, envVariables: EnvVariables) {
|
|
5
|
+
const client = createEntifyClient(envVariables);
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
return await client.upsertEntity(entityName, object);
|
|
9
|
+
}
|