@rxdrag/website-lib-core 0.0.126 → 0.0.128
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/README.md +1 -1
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/astro/animation.ts +146 -146
- package/src/astro/background.ts +82 -53
- package/src/astro/base.ts +7 -0
- package/src/astro/business.ts +13 -0
- package/src/astro/grid/consts.ts +80 -80
- package/src/astro/grid/index.ts +2 -2
- package/src/astro/grid/types.ts +35 -35
- package/src/astro/image.ts +239 -239
- package/src/astro/index.ts +12 -9
- package/src/astro/link.ts +20 -0
- package/src/astro/media.ts +123 -123
- package/src/astro/nav.ts +13 -13
- package/src/astro/section/index.ts +7 -12
- package/src/component-logic/index.ts +1 -1
- package/src/component-logic/link-client.ts +32 -32
- package/src/component-logic/link.ts +61 -61
- package/src/design-tokens.ts +160 -160
- package/src/entify/Entify.ts +533 -530
- package/src/entify/IEntify.ts +151 -177
- package/src/entify/index.ts +4 -4
- package/src/entify/lib/collectCategoryIds.ts +20 -20
- package/src/entify/lib/fulltextSearch.ts +63 -62
- package/src/entify/lib/langFields.ts +14 -14
- package/src/entify/lib/listToTree.ts +23 -23
- package/src/entify/lib/newAvatarQueryOptions.ts +4 -4
- package/src/entify/lib/newOgImageQueryOptions.ts +5 -5
- package/src/entify/lib/newQueryPostOptions.ts +42 -45
- package/src/entify/lib/newQueryProductOptions.ts +96 -98
- package/src/entify/lib/newQueryProductsMediaOptions.ts +28 -28
- package/src/entify/lib/queryAllProducts.ts +40 -40
- package/src/entify/lib/queryBulletin.ts +28 -16
- package/src/entify/lib/queryEntityList.ts +41 -41
- package/src/entify/lib/queryFeaturedProducts.ts +69 -68
- package/src/entify/lib/queryLangs.ts +36 -60
- package/src/entify/lib/queryLatestPosts.ts +92 -91
- package/src/entify/lib/queryOneEntity.ts +63 -63
- package/src/entify/lib/queryOneMedia.ts +27 -27
- package/src/entify/lib/queryOnePostById.ts +21 -21
- package/src/entify/lib/queryOnePostBySlug.ts +40 -39
- package/src/entify/lib/queryOnePostCategoryBySlug.ts +35 -35
- package/src/entify/lib/queryOneProductById.ts +20 -20
- package/src/entify/lib/queryOneProductBySlug.ts +53 -52
- package/src/entify/lib/queryOneProductCategoryBySlug.ts +50 -49
- package/src/entify/lib/queryOneTheme.ts +54 -72
- package/src/entify/lib/queryOneUser.ts +38 -38
- package/src/entify/lib/queryPostCategories.ts +67 -67
- package/src/entify/lib/queryPostSlugs.ts +37 -37
- package/src/entify/lib/queryPosts.ts +175 -174
- package/src/entify/lib/queryProductCategories.ts +59 -59
- package/src/entify/lib/queryProducts.ts +145 -144
- package/src/entify/lib/queryProductsInMenu.ts +45 -45
- package/src/entify/lib/queryTagCategories.ts +58 -58
- package/src/entify/lib/queryTags.ts +57 -57
- package/src/entify/lib/queryUserIds.ts +24 -24
- package/src/entify/lib/queryUserPosts.ts +80 -79
- package/src/entify/lib/queryWebSiteSettings.ts +28 -28
- package/src/entify/lib/queryWebsite.ts +43 -43
- package/src/entify/lib/sendEmail.ts +7 -7
- package/src/entify/lib/toQueryOptions.ts +19 -19
- package/src/entify/lib/upsertEntity.ts +8 -8
- package/src/entify/types/index.ts +1 -1
- package/src/entify/types/utils.ts +11 -6
- package/src/entify/types/variables.ts +5 -6
- package/src/entify/view-model/funcs.ts +230 -230
- package/src/entify/view-model/index.ts +1 -1
- package/src/entify/view-model/models.ts +135 -135
- package/src/global.d.ts +7 -7
- package/src/index.ts +8 -8
- package/src/lib/formatDate.ts +15 -15
- package/src/lib/index.ts +3 -3
- package/src/lib/pagination.ts +114 -114
- package/src/lib/utils.ts +135 -135
- package/src/react/components/Analytics/eventHandlers.ts +173 -173
- package/src/react/components/Analytics/index.tsx +21 -21
- package/src/react/components/Analytics/singleton.ts +214 -214
- package/src/react/components/Analytics/tracking.ts +221 -221
- package/src/react/components/Analytics/types.ts +60 -60
- package/src/react/components/Analytics/utils.ts +95 -95
- package/src/react/components/AttachmentIcon/index.tsx +53 -53
- package/src/react/components/BackgroundHlsVideoPlayer.tsx +97 -97
- package/src/react/components/BackgroundVideoPlayer.tsx +32 -32
- package/src/react/components/Bulletin.tsx +30 -30
- package/src/react/components/ContactForm/ContactForm.tsx +289 -289
- package/src/react/components/ContactForm/Input.tsx +48 -48
- package/src/react/components/ContactForm/Input2.tsx +59 -59
- package/src/react/components/ContactForm/Submit.tsx +48 -48
- package/src/react/components/ContactForm/TelInput.tsx +215 -215
- package/src/react/components/ContactForm/Textarea.tsx +48 -48
- package/src/react/components/ContactForm/Textarea2.tsx +89 -89
- package/src/react/components/ContactForm/funcs.ts +64 -64
- package/src/react/components/ContactForm/index.ts +7 -7
- package/src/react/components/ContactForm/types.ts +68 -68
- package/src/react/components/GoogleConsent/CookieItemPanel.tsx +80 -80
- package/src/react/components/GoogleConsent/CumtomizedModal.tsx +148 -148
- package/src/react/components/GoogleConsent/GoogleConsent.tsx +100 -100
- package/src/react/components/GoogleConsent/gtags.ts +67 -67
- package/src/react/components/GoogleConsent/index.ts +2 -2
- package/src/react/components/GoogleConsent/types.ts +18 -18
- package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -4
- package/src/react/components/Icon/index.tsx +19 -19
- package/src/react/components/Medias/MainMedia.tsx +257 -257
- package/src/react/components/Medias/Thumbnail.tsx +62 -62
- package/src/react/components/Medias/VideoPlayer.tsx +114 -114
- package/src/react/components/Medias/index.tsx +271 -271
- package/src/react/components/ProductCard/ProductCard.tsx +24 -24
- package/src/react/components/ProductCard/ProductCta/index.tsx +28 -28
- package/src/react/components/ProductCard/ProductCta/style.css +3 -3
- package/src/react/components/ProductCard/ProductDescription/index.tsx +12 -12
- package/src/react/components/ProductCard/ProductDescription/style.css +5 -5
- package/src/react/components/ProductCard/ProductMedia/index.tsx +35 -35
- package/src/react/components/ProductCard/ProductMedia/style.css +5 -5
- package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -7
- package/src/react/components/ProductCard/ProductTitle/style.css +3 -3
- package/src/react/components/ProductCard/ProductView.tsx +36 -36
- package/src/react/components/ProductCard/index.ts +4 -4
- package/src/react/components/ProductCard/useQueryProduct.ts +32 -32
- package/src/react/components/ReactModalTrigger.tsx +28 -28
- package/src/react/components/ReactVideoPlayer.tsx +29 -52
- package/src/react/components/RichTextOutline/index.tsx +75 -75
- package/src/react/components/RichTextOutline/useAnchorScroll.ts +23 -23
- package/src/react/components/Scroller.tsx +39 -39
- package/src/react/components/SearchInput.tsx +21 -21
- package/src/react/components/Share/index.tsx +86 -86
- package/src/react/components/Share/socials.tsx +79 -77
- package/src/react/components/Share//350/265/204/346/226/231.md +7 -7
- package/src/react/components/ToTop.tsx +72 -72
- package/src/react/components/VideoPlayIcon.tsx +43 -0
- package/src/react/components/all.ts +38 -38
- package/src/react/components/index.ts +16 -16
- package/src/robots.ts +4 -4
- package/src/entify/lib/newPageMetaOptions.ts +0 -18
- package/src/entify/lib/newQueryPageOptions.ts +0 -14
- package/src/entify/lib/queryOneIcon.ts +0 -27
- package/src/entify/lib/queryPageBySlug.ts +0 -43
- package/src/entify/lib/queryPageByType.ts +0 -44
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Product,
|
|
3
|
-
ProductBoolExp,
|
|
4
|
-
ProductOrderBy,
|
|
5
|
-
ProductDistinctExp,
|
|
6
|
-
ProductFields,
|
|
7
|
-
ProductQueryOptions,
|
|
8
|
-
ImageSize,
|
|
9
|
-
} from "@rxdrag/rxcms-models";
|
|
10
|
-
import { queryEntityList } from "./queryEntityList";
|
|
11
|
-
import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
|
|
12
|
-
import { EnvVariables } from "../types";
|
|
13
|
-
import { ListResult } from "@rxdrag/entify-lib";
|
|
14
|
-
import { TProduct } from "../view-model";
|
|
15
|
-
|
|
16
|
-
export async function queryFeaturedProducts(
|
|
17
|
-
count: number =
|
|
18
|
-
imageSize: ImageSize | undefined,
|
|
19
|
-
envVariables: EnvVariables,
|
|
20
|
-
addonFields
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
ProductFields.
|
|
32
|
-
ProductFields.
|
|
33
|
-
ProductFields.
|
|
34
|
-
ProductFields.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
import {
|
|
2
|
+
Product,
|
|
3
|
+
ProductBoolExp,
|
|
4
|
+
ProductOrderBy,
|
|
5
|
+
ProductDistinctExp,
|
|
6
|
+
ProductFields,
|
|
7
|
+
ProductQueryOptions,
|
|
8
|
+
ImageSize,
|
|
9
|
+
} from "@rxdrag/rxcms-models";
|
|
10
|
+
import { queryEntityList } from "./queryEntityList";
|
|
11
|
+
import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
|
|
12
|
+
import { EnvVariables } from "../types";
|
|
13
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
14
|
+
import { TProduct } from "../view-model";
|
|
15
|
+
|
|
16
|
+
export async function queryFeaturedProducts(
|
|
17
|
+
count: number | undefined = 3,
|
|
18
|
+
imageSize: ImageSize | undefined,
|
|
19
|
+
envVariables: EnvVariables,
|
|
20
|
+
addonFields: (keyof Product)[] | undefined,
|
|
21
|
+
langAbbr: string
|
|
22
|
+
) {
|
|
23
|
+
const result = await queryEntityList<
|
|
24
|
+
Product,
|
|
25
|
+
ProductBoolExp,
|
|
26
|
+
ProductOrderBy,
|
|
27
|
+
ProductDistinctExp
|
|
28
|
+
>(
|
|
29
|
+
new ProductQueryOptions(
|
|
30
|
+
[
|
|
31
|
+
ProductFields.id,
|
|
32
|
+
ProductFields.slug,
|
|
33
|
+
ProductFields.title,
|
|
34
|
+
ProductFields.shortTitle,
|
|
35
|
+
ProductFields.description,
|
|
36
|
+
...(addonFields || []),
|
|
37
|
+
],
|
|
38
|
+
{
|
|
39
|
+
offset: 0,
|
|
40
|
+
limit: count,
|
|
41
|
+
where: {
|
|
42
|
+
featured: {
|
|
43
|
+
_eq: true,
|
|
44
|
+
},
|
|
45
|
+
lang: {
|
|
46
|
+
abbr: {
|
|
47
|
+
_eq: langAbbr,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
_or: [
|
|
51
|
+
{
|
|
52
|
+
[ProductFields.isDeleted]: {
|
|
53
|
+
_eq: false,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
[ProductFields.isDeleted]: {
|
|
58
|
+
_isNull: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
orderBy: [{ [ProductFields.seqValue]: "asc" }],
|
|
64
|
+
}
|
|
65
|
+
).mediaPivots(newQueryProductsMediaOptions(imageSize)),
|
|
66
|
+
envVariables
|
|
67
|
+
);
|
|
68
|
+
return (result as ListResult<TProduct> | undefined)?.items;
|
|
69
|
+
}
|
|
@@ -1,60 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Lang,
|
|
3
|
-
LangBoolExp,
|
|
4
|
-
LangDistinctExp,
|
|
5
|
-
LangOrderBy,
|
|
6
|
-
LangQueryOptions,
|
|
7
|
-
LangAssciations,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
new ThemeBranchQueryOptions([ThemeBranchFields.id, ThemeBranchFields.name], {
|
|
38
|
-
where: {
|
|
39
|
-
[ThemeBranchAssciations.website]: {
|
|
40
|
-
id: {
|
|
41
|
-
_eq: envVariables.websiteId,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
}).config([
|
|
46
|
-
ThemeConfigFields.id,
|
|
47
|
-
ThemeConfigFields.address,
|
|
48
|
-
ThemeConfigFields.contact,
|
|
49
|
-
ThemeConfigFields.email,
|
|
50
|
-
ThemeConfigFields.fax,
|
|
51
|
-
ThemeConfigFields.mobile,
|
|
52
|
-
ThemeConfigFields.tel,
|
|
53
|
-
ThemeConfigFields.wechat,
|
|
54
|
-
ThemeConfigFields.domain,
|
|
55
|
-
])
|
|
56
|
-
)
|
|
57
|
-
.setNoQuery(!envVariables.websiteId)
|
|
58
|
-
);
|
|
59
|
-
return result as ListResult<Lang> | undefined;
|
|
60
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Lang,
|
|
3
|
+
LangBoolExp,
|
|
4
|
+
LangDistinctExp,
|
|
5
|
+
LangOrderBy,
|
|
6
|
+
LangQueryOptions,
|
|
7
|
+
LangAssciations,
|
|
8
|
+
} from "@rxdrag/rxcms-models";
|
|
9
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
10
|
+
import { EnvVariables } from "../types";
|
|
11
|
+
import { createEntifyClient } from "./createEntifyClient";
|
|
12
|
+
import { langFields } from "./langFields";
|
|
13
|
+
|
|
14
|
+
export async function queryLangs(envVariables: EnvVariables) {
|
|
15
|
+
const client = createEntifyClient(envVariables);
|
|
16
|
+
|
|
17
|
+
// 新架构:一个 Website 对应一个 ThemeBranch,不再按语言区分
|
|
18
|
+
// Lang 和 ThemeBranch 之间不再有直接关联关系
|
|
19
|
+
const result = await client.enityList<
|
|
20
|
+
Lang,
|
|
21
|
+
LangBoolExp,
|
|
22
|
+
LangOrderBy,
|
|
23
|
+
LangDistinctExp
|
|
24
|
+
>(
|
|
25
|
+
new LangQueryOptions(langFields, {
|
|
26
|
+
where: {
|
|
27
|
+
[LangAssciations.websites]: {
|
|
28
|
+
id: {
|
|
29
|
+
_eq: envVariables.websiteId,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}).setNoQuery(!envVariables.websiteId)
|
|
34
|
+
);
|
|
35
|
+
return result as ListResult<Lang> | undefined;
|
|
36
|
+
}
|
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import { ListResult } from "@rxdrag/entify-lib";
|
|
2
|
-
import {
|
|
3
|
-
PostBoolExp,
|
|
4
|
-
PostOrderBy,
|
|
5
|
-
PostDistinctExp,
|
|
6
|
-
PostFields,
|
|
7
|
-
Post,
|
|
8
|
-
PostQueryOptions,
|
|
9
|
-
MediaQueryOptions,
|
|
10
|
-
UserQueryOptions,
|
|
11
|
-
UserFields,
|
|
12
|
-
PublishableStatus,
|
|
13
|
-
PostCategoryFields,
|
|
14
|
-
} from "@rxdrag/rxcms-models";
|
|
15
|
-
import { queryEntityList } from "./queryEntityList";
|
|
16
|
-
import { EnvVariables } from "../types";
|
|
17
|
-
import { TPost } from "../view-model";
|
|
18
|
-
import { ImageSize } from "@rxdrag/rxcms-models";
|
|
19
|
-
|
|
20
|
-
export async function queryLatestPosts(
|
|
21
|
-
count: number =
|
|
22
|
-
coverSize: ImageSize | undefined,
|
|
23
|
-
envVariables: EnvVariables
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
PostFields.
|
|
35
|
-
PostFields.
|
|
36
|
-
PostFields.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
PostCategoryFields.
|
|
74
|
-
PostCategoryFields.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
2
|
+
import {
|
|
3
|
+
PostBoolExp,
|
|
4
|
+
PostOrderBy,
|
|
5
|
+
PostDistinctExp,
|
|
6
|
+
PostFields,
|
|
7
|
+
Post,
|
|
8
|
+
PostQueryOptions,
|
|
9
|
+
MediaQueryOptions,
|
|
10
|
+
UserQueryOptions,
|
|
11
|
+
UserFields,
|
|
12
|
+
PublishableStatus,
|
|
13
|
+
PostCategoryFields,
|
|
14
|
+
} from "@rxdrag/rxcms-models";
|
|
15
|
+
import { queryEntityList } from "./queryEntityList";
|
|
16
|
+
import { EnvVariables } from "../types";
|
|
17
|
+
import { TPost } from "../view-model";
|
|
18
|
+
import { ImageSize } from "@rxdrag/rxcms-models";
|
|
19
|
+
|
|
20
|
+
export async function queryLatestPosts(
|
|
21
|
+
count: number | undefined = 3,
|
|
22
|
+
coverSize: ImageSize | undefined,
|
|
23
|
+
envVariables: EnvVariables,
|
|
24
|
+
langAbbr: string
|
|
25
|
+
) {
|
|
26
|
+
const result = await queryEntityList<
|
|
27
|
+
Post,
|
|
28
|
+
PostBoolExp,
|
|
29
|
+
PostOrderBy,
|
|
30
|
+
PostDistinctExp
|
|
31
|
+
>(
|
|
32
|
+
new PostQueryOptions(
|
|
33
|
+
[
|
|
34
|
+
PostFields.id,
|
|
35
|
+
PostFields.slug,
|
|
36
|
+
PostFields.title,
|
|
37
|
+
PostFields.description,
|
|
38
|
+
],
|
|
39
|
+
{
|
|
40
|
+
offset: 0,
|
|
41
|
+
limit: count,
|
|
42
|
+
orderBy: [
|
|
43
|
+
{
|
|
44
|
+
//暂时按照更新时间排序
|
|
45
|
+
updatedAt: "desc",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
where: {
|
|
49
|
+
[PostFields.status]: {
|
|
50
|
+
_eq: PublishableStatus.published,
|
|
51
|
+
},
|
|
52
|
+
lang: {
|
|
53
|
+
abbr: {
|
|
54
|
+
_eq: langAbbr,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
_or: [
|
|
58
|
+
{
|
|
59
|
+
[PostFields.isDeleted]: {
|
|
60
|
+
_eq: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
[PostFields.isDeleted]: {
|
|
65
|
+
_isNull: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
.category([
|
|
73
|
+
PostCategoryFields.id,
|
|
74
|
+
PostCategoryFields.slug,
|
|
75
|
+
PostCategoryFields.name,
|
|
76
|
+
])
|
|
77
|
+
.cover(
|
|
78
|
+
new MediaQueryOptions().file([
|
|
79
|
+
"thumbnail",
|
|
80
|
+
`resize(width:${coverSize?.width || 480}, height:${coverSize?.height || 180
|
|
81
|
+
})`,
|
|
82
|
+
])
|
|
83
|
+
)
|
|
84
|
+
.author(
|
|
85
|
+
new UserQueryOptions([UserFields.id, UserFields.name]).avatar(
|
|
86
|
+
new MediaQueryOptions().file(["thumbnail"])
|
|
87
|
+
)
|
|
88
|
+
),
|
|
89
|
+
envVariables
|
|
90
|
+
);
|
|
91
|
+
return (result as ListResult<TPost> | undefined)?.items;
|
|
92
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { IQueryOptions } from "@rxdrag/entify-lib";
|
|
2
|
-
import { createEntifyClient } from "./createEntifyClient";
|
|
3
|
-
import {
|
|
4
|
-
PostCategoryEntityName,
|
|
5
|
-
PostEntityName,
|
|
6
|
-
ProductCategoryEntityName,
|
|
7
|
-
ProductEntityName,
|
|
8
|
-
UserEntityName,
|
|
9
|
-
WebsitePart,
|
|
10
|
-
WebsiteSettingsEntityName,
|
|
11
|
-
} from "@rxdrag/rxcms-models";
|
|
12
|
-
import { WebsitePartBoolExp } from "@rxdrag/rxcms-models/";
|
|
13
|
-
import { EnvVariables } from "../types";
|
|
14
|
-
import {
|
|
15
|
-
postCategoryToViewModel,
|
|
16
|
-
postToViewModel,
|
|
17
|
-
productCategoryToViewModel,
|
|
18
|
-
productToViewModel,
|
|
19
|
-
userToViewModel,
|
|
20
|
-
websiteSettingsToViewModel,
|
|
21
|
-
} from "../view-model";
|
|
22
|
-
|
|
23
|
-
export async function queryOneEntity<
|
|
24
|
-
T extends WebsitePart = WebsitePart,
|
|
25
|
-
WhereExp extends WebsitePartBoolExp = WebsitePartBoolExp,
|
|
26
|
-
OrderBy = unknown,
|
|
27
|
-
DistinctExp = unknown
|
|
28
|
-
>(
|
|
29
|
-
options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>,
|
|
30
|
-
envVariables: EnvVariables
|
|
31
|
-
) {
|
|
32
|
-
const client = createEntifyClient(envVariables);
|
|
33
|
-
const result = await client.oneEntity<T, WhereExp, OrderBy, DistinctExp>(
|
|
34
|
-
!envVariables.websiteId
|
|
35
|
-
? options
|
|
36
|
-
: options.setQueryArgs({
|
|
37
|
-
...options.getQueryArgs(),
|
|
38
|
-
where: {
|
|
39
|
-
website: {
|
|
40
|
-
id: { _eq: envVariables.websiteId },
|
|
41
|
-
},
|
|
42
|
-
...options.getQueryArgs()?.where,
|
|
43
|
-
} as unknown as WhereExp,
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
switch (options.entityName) {
|
|
48
|
-
case ProductEntityName:
|
|
49
|
-
return productToViewModel(result) as T | undefined;
|
|
50
|
-
case PostEntityName:
|
|
51
|
-
return postToViewModel(result) as T | undefined;
|
|
52
|
-
case ProductCategoryEntityName:
|
|
53
|
-
return productCategoryToViewModel(result) as T | undefined;
|
|
54
|
-
case PostCategoryEntityName:
|
|
55
|
-
return postCategoryToViewModel(result) as T | undefined;
|
|
56
|
-
case UserEntityName:
|
|
57
|
-
return userToViewModel(result) as T | undefined;
|
|
58
|
-
case WebsiteSettingsEntityName:
|
|
59
|
-
return websiteSettingsToViewModel(result) as T | undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return result as T | undefined;
|
|
63
|
-
}
|
|
1
|
+
import { IQueryOptions } from "@rxdrag/entify-lib";
|
|
2
|
+
import { createEntifyClient } from "./createEntifyClient";
|
|
3
|
+
import {
|
|
4
|
+
PostCategoryEntityName,
|
|
5
|
+
PostEntityName,
|
|
6
|
+
ProductCategoryEntityName,
|
|
7
|
+
ProductEntityName,
|
|
8
|
+
UserEntityName,
|
|
9
|
+
WebsitePart,
|
|
10
|
+
WebsiteSettingsEntityName,
|
|
11
|
+
} from "@rxdrag/rxcms-models";
|
|
12
|
+
import { WebsitePartBoolExp } from "@rxdrag/rxcms-models/";
|
|
13
|
+
import { EnvVariables } from "../types";
|
|
14
|
+
import {
|
|
15
|
+
postCategoryToViewModel,
|
|
16
|
+
postToViewModel,
|
|
17
|
+
productCategoryToViewModel,
|
|
18
|
+
productToViewModel,
|
|
19
|
+
userToViewModel,
|
|
20
|
+
websiteSettingsToViewModel,
|
|
21
|
+
} from "../view-model";
|
|
22
|
+
|
|
23
|
+
export async function queryOneEntity<
|
|
24
|
+
T extends WebsitePart = WebsitePart,
|
|
25
|
+
WhereExp extends WebsitePartBoolExp = WebsitePartBoolExp,
|
|
26
|
+
OrderBy = unknown,
|
|
27
|
+
DistinctExp = unknown
|
|
28
|
+
>(
|
|
29
|
+
options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>,
|
|
30
|
+
envVariables: EnvVariables
|
|
31
|
+
) {
|
|
32
|
+
const client = createEntifyClient(envVariables);
|
|
33
|
+
const result = await client.oneEntity<T, WhereExp, OrderBy, DistinctExp>(
|
|
34
|
+
!envVariables.websiteId
|
|
35
|
+
? options
|
|
36
|
+
: options.setQueryArgs({
|
|
37
|
+
...options.getQueryArgs(),
|
|
38
|
+
where: {
|
|
39
|
+
website: {
|
|
40
|
+
id: { _eq: envVariables.websiteId },
|
|
41
|
+
},
|
|
42
|
+
...options.getQueryArgs()?.where,
|
|
43
|
+
} as unknown as WhereExp,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
switch (options.entityName) {
|
|
48
|
+
case ProductEntityName:
|
|
49
|
+
return productToViewModel(result) as T | undefined;
|
|
50
|
+
case PostEntityName:
|
|
51
|
+
return postToViewModel(result) as T | undefined;
|
|
52
|
+
case ProductCategoryEntityName:
|
|
53
|
+
return productCategoryToViewModel(result) as T | undefined;
|
|
54
|
+
case PostCategoryEntityName:
|
|
55
|
+
return postCategoryToViewModel(result) as T | undefined;
|
|
56
|
+
case UserEntityName:
|
|
57
|
+
return userToViewModel(result) as T | undefined;
|
|
58
|
+
case WebsiteSettingsEntityName:
|
|
59
|
+
return websiteSettingsToViewModel(result) as T | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result as T | undefined;
|
|
63
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Media, MediaBoolExp, MediaDistinctExp, MediaFields, MediaOrderBy, MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
-
import { EnvVariables } from "../types";
|
|
3
|
-
import { queryOneEntity } from "./queryOneEntity";
|
|
4
|
-
export const queryOneMedia = async (
|
|
5
|
-
ref: string | undefined | null,
|
|
6
|
-
fields: string[] | undefined,
|
|
7
|
-
envVariables: EnvVariables) => {
|
|
8
|
-
|
|
9
|
-
const media = await queryOneEntity<Media, MediaBoolExp, MediaOrderBy, MediaDistinctExp>(
|
|
10
|
-
new MediaQueryOptions([
|
|
11
|
-
MediaFields.id,
|
|
12
|
-
MediaFields.mediaRef,
|
|
13
|
-
MediaFields.mediaType,
|
|
14
|
-
MediaFields.storageType,
|
|
15
|
-
], {
|
|
16
|
-
where: {
|
|
17
|
-
mediaRef: {
|
|
18
|
-
"_eq": ref || ""
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
.file(["original", "thumbnail", ...(fields || [])])
|
|
23
|
-
.setNoQuery(!ref)
|
|
24
|
-
,
|
|
25
|
-
envVariables
|
|
26
|
-
);
|
|
27
|
-
return media;
|
|
1
|
+
import { Media, MediaBoolExp, MediaDistinctExp, MediaFields, MediaOrderBy, MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { EnvVariables } from "../types";
|
|
3
|
+
import { queryOneEntity } from "./queryOneEntity";
|
|
4
|
+
export const queryOneMedia = async (
|
|
5
|
+
ref: string | undefined | null,
|
|
6
|
+
fields: string[] | undefined,
|
|
7
|
+
envVariables: EnvVariables) => {
|
|
8
|
+
|
|
9
|
+
const media = await queryOneEntity<Media, MediaBoolExp, MediaOrderBy, MediaDistinctExp>(
|
|
10
|
+
new MediaQueryOptions([
|
|
11
|
+
MediaFields.id,
|
|
12
|
+
MediaFields.mediaRef,
|
|
13
|
+
MediaFields.mediaType,
|
|
14
|
+
MediaFields.storageType,
|
|
15
|
+
], {
|
|
16
|
+
where: {
|
|
17
|
+
mediaRef: {
|
|
18
|
+
"_eq": ref || ""
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
.file(["original", "thumbnail", ...(fields || [])])
|
|
23
|
+
.setNoQuery(!ref)
|
|
24
|
+
,
|
|
25
|
+
envVariables
|
|
26
|
+
);
|
|
27
|
+
return media;
|
|
28
28
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Post, PostBoolExp, PostOrderBy, PostDistinctExp } from "@rxdrag/rxcms-models";
|
|
2
|
-
import { newQueryOnePostOptions } from "./newQueryPostOptions";
|
|
3
|
-
import { queryOneEntity } from "./queryOneEntity";
|
|
4
|
-
import { EnvVariables } from "../types";
|
|
5
|
-
|
|
6
|
-
export async function queryOnePostById(id: string, envVariables: EnvVariables) {
|
|
7
|
-
|
|
8
|
-
const post = await queryOneEntity<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
|
|
9
|
-
newQueryOnePostOptions()
|
|
10
|
-
.setQueryArgs({
|
|
11
|
-
where: {
|
|
12
|
-
id: {
|
|
13
|
-
"_eq": id
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
,
|
|
18
|
-
envVariables
|
|
19
|
-
);
|
|
20
|
-
return post;
|
|
21
|
-
}
|
|
1
|
+
import { Post, PostBoolExp, PostOrderBy, PostDistinctExp } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { newQueryOnePostOptions } from "./newQueryPostOptions";
|
|
3
|
+
import { queryOneEntity } from "./queryOneEntity";
|
|
4
|
+
import { EnvVariables } from "../types";
|
|
5
|
+
|
|
6
|
+
export async function queryOnePostById(id: string, envVariables: EnvVariables) {
|
|
7
|
+
|
|
8
|
+
const post = await queryOneEntity<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
|
|
9
|
+
newQueryOnePostOptions()
|
|
10
|
+
.setQueryArgs({
|
|
11
|
+
where: {
|
|
12
|
+
id: {
|
|
13
|
+
"_eq": id
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
,
|
|
18
|
+
envVariables
|
|
19
|
+
);
|
|
20
|
+
return post;
|
|
21
|
+
}
|