@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.
Files changed (168) hide show
  1. package/index.ts +1 -0
  2. package/package.json +12 -13
  3. package/src/entify/Entify.ts +365 -0
  4. package/{dist/entify/index.d.ts → src/entify/index.ts} +4 -4
  5. package/src/entify/lib/createEntifyClient.ts +23 -0
  6. package/{dist/entify/lib/index.d.ts → src/entify/lib/index.ts} +29 -29
  7. package/src/entify/lib/langFields.ts +12 -0
  8. package/src/entify/lib/newAvatarQueryOptions.ts +5 -0
  9. package/src/entify/lib/newOgImageQueryOptions.ts +6 -0
  10. package/src/entify/lib/newPageMetaOptions.ts +20 -0
  11. package/src/entify/lib/newQueryPostOptions.ts +41 -0
  12. package/src/entify/lib/newQueryProductOptions.ts +90 -0
  13. package/src/entify/lib/newQueryProductsMediaOptions.ts +26 -0
  14. package/src/entify/lib/queryAllProducts.ts +27 -0
  15. package/src/entify/lib/queryEntityList.ts +44 -0
  16. package/src/entify/lib/queryFeaturedProducts.ts +47 -0
  17. package/src/entify/lib/queryLangs.ts +47 -0
  18. package/src/entify/lib/queryLatestPosts.ts +65 -0
  19. package/src/entify/lib/queryOneEntity.ts +67 -0
  20. package/src/entify/lib/queryOnePostById.ts +21 -0
  21. package/src/entify/lib/queryOnePostBySlug.ts +21 -0
  22. package/src/entify/lib/queryOnePostCategoryBySlug.ts +30 -0
  23. package/src/entify/lib/queryOneProductById.ts +20 -0
  24. package/src/entify/lib/queryOneProductBySlug.ts +21 -0
  25. package/src/entify/lib/queryOneProductCategoryBySlug.ts +30 -0
  26. package/src/entify/lib/queryOneTheme.ts +76 -0
  27. package/src/entify/lib/queryOneUser.ts +38 -0
  28. package/src/entify/lib/queryPostCategories.ts +48 -0
  29. package/src/entify/lib/queryPostSlugs.ts +32 -0
  30. package/src/entify/lib/queryPosts.ts +92 -0
  31. package/src/entify/lib/queryProductCategories.ts +44 -0
  32. package/src/entify/lib/queryProducts.ts +69 -0
  33. package/src/entify/lib/queryProductsInMenu.ts +31 -0
  34. package/src/entify/lib/queryUserIds.ts +24 -0
  35. package/src/entify/lib/queryUserPosts.ts +74 -0
  36. package/src/entify/lib/queryWebSiteSettings.ts +29 -0
  37. package/src/entify/lib/searchProducts.ts +70 -0
  38. package/src/entify/lib/sendEmail.ts +8 -0
  39. package/src/entify/lib/toQueryOptions.ts +20 -0
  40. package/src/entify/lib/upsertEntity.ts +9 -0
  41. package/src/entify/types/index.ts +2 -0
  42. package/src/entify/types/utils.ts +4 -0
  43. package/src/entify/types/variables.ts +7 -0
  44. package/src/entify/view-model/funcs.ts +271 -0
  45. package/src/entify/view-model/index.ts +2 -0
  46. package/src/entify/view-model/models.ts +143 -0
  47. package/{dist/index.d.ts → src/index.ts} +5 -5
  48. package/src/motion/consts.ts +598 -0
  49. package/{dist/motion/index.d.ts → src/motion/index.ts} +2 -2
  50. package/src/motion/types.ts +46 -0
  51. package/src/react/components/EnquiryForm/Input.tsx +52 -0
  52. package/src/react/components/EnquiryForm/Submit.tsx +30 -0
  53. package/src/react/components/EnquiryForm/Textarea.tsx +51 -0
  54. package/src/react/components/EnquiryForm/index.tsx +334 -0
  55. package/src/react/components/GoogleConsent/CookieItemPanel.tsx +81 -0
  56. package/src/react/components/GoogleConsent/CumtomizedModal.tsx +149 -0
  57. package/src/react/components/GoogleConsent/GoogleConsent.tsx +101 -0
  58. package/src/react/components/GoogleConsent/README.md +1 -0
  59. package/src/react/components/GoogleConsent/gtags.ts +68 -0
  60. package/src/react/components/GoogleConsent/index.ts +3 -0
  61. package/src/react/components/GoogleConsent/types.ts +18 -0
  62. package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -0
  63. package/src/react/components/Medias/index.tsx +347 -0
  64. package/src/react/components/ProductCard/ProductCard.tsx +23 -0
  65. package/src/react/components/ProductCard/ProductCardPreview.tsx +12 -0
  66. package/src/react/components/ProductCard/ProductCta/index.tsx +41 -0
  67. package/src/react/components/ProductCard/ProductCta/style.css +4 -0
  68. package/src/react/components/ProductCard/ProductDescription/index.tsx +13 -0
  69. package/src/react/components/ProductCard/ProductDescription/style.css +6 -0
  70. package/src/react/components/ProductCard/ProductMedia/index.tsx +34 -0
  71. package/src/react/components/ProductCard/ProductMedia/style.css +6 -0
  72. package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -0
  73. package/src/react/components/ProductCard/ProductTitle/style.css +4 -0
  74. package/src/react/components/ProductCard/ProductView.tsx +35 -0
  75. package/{dist/react/components/ProductCard/index.d.ts → src/react/components/ProductCard/index.ts} +6 -6
  76. package/src/react/components/ProductCard/useQueryProduct.ts +32 -0
  77. package/src/react/components/RichTextOutline/index.tsx +76 -0
  78. package/src/react/components/RichTextOutline/useAcitviedHeading.ts +54 -0
  79. package/src/react/components/RichTextOutline/useAnchorScroll.ts +24 -0
  80. package/src/react/components/Scroller.tsx +7 -0
  81. package/src/react/components/SearchInput.tsx +34 -0
  82. package/src/react/components/Share/index.tsx +69 -0
  83. package/src/react/components/Share/socials.tsx +79 -0
  84. package/src/react/components/Share//350/265/204/346/226/231.md +7 -0
  85. package/src/react/components/ToTop/index.tsx +33 -0
  86. package/src/react/components/ToTop.tsx +33 -0
  87. package/{dist/react/components/index.d.ts → src/react/components/index.ts} +8 -8
  88. package/src/react/hooks/index.ts +1 -0
  89. package/src/react/hooks/useScroll.ts +23 -0
  90. package/{dist/react/index.d.ts → src/react/index.ts} +2 -2
  91. package/src/robots.ts +4 -0
  92. package/src/scripts/actions.ts +304 -0
  93. package/src/scripts/consts.ts +32 -0
  94. package/src/scripts/events.ts +33 -0
  95. package/{dist/scripts/index.d.ts → src/scripts/index.ts} +3 -3
  96. package/dist/entify/Entify.d.ts +0 -138
  97. package/dist/entify/lib/createEntifyClient.d.ts +0 -3
  98. package/dist/entify/lib/langFields.d.ts +0 -2
  99. package/dist/entify/lib/newAvatarQueryOptions.d.ts +0 -2
  100. package/dist/entify/lib/newOgImageQueryOptions.d.ts +0 -2
  101. package/dist/entify/lib/newPageMetaOptions.d.ts +0 -2
  102. package/dist/entify/lib/newQueryPostOptions.d.ts +0 -3
  103. package/dist/entify/lib/newQueryProductOptions.d.ts +0 -3
  104. package/dist/entify/lib/newQueryProductsMediaOptions.d.ts +0 -3
  105. package/dist/entify/lib/queryAllProducts.d.ts +0 -4
  106. package/dist/entify/lib/queryEntityList.d.ts +0 -3
  107. package/dist/entify/lib/queryFeaturedProducts.d.ts +0 -4
  108. package/dist/entify/lib/queryLangs.d.ts +0 -4
  109. package/dist/entify/lib/queryLatestPosts.d.ts +0 -4
  110. package/dist/entify/lib/queryOneEntity.d.ts +0 -5
  111. package/dist/entify/lib/queryOnePostById.d.ts +0 -3
  112. package/dist/entify/lib/queryOnePostBySlug.d.ts +0 -3
  113. package/dist/entify/lib/queryOnePostCategoryBySlug.d.ts +0 -3
  114. package/dist/entify/lib/queryOneProductById.d.ts +0 -3
  115. package/dist/entify/lib/queryOneProductBySlug.d.ts +0 -3
  116. package/dist/entify/lib/queryOneProductCategoryBySlug.d.ts +0 -3
  117. package/dist/entify/lib/queryOneTheme.d.ts +0 -3
  118. package/dist/entify/lib/queryOneUser.d.ts +0 -3
  119. package/dist/entify/lib/queryPostCategories.d.ts +0 -4
  120. package/dist/entify/lib/queryPostSlugs.d.ts +0 -4
  121. package/dist/entify/lib/queryPosts.d.ts +0 -10
  122. package/dist/entify/lib/queryProductCategories.d.ts +0 -4
  123. package/dist/entify/lib/queryProducts.d.ts +0 -6
  124. package/dist/entify/lib/queryProductsInMenu.d.ts +0 -2
  125. package/dist/entify/lib/queryUserIds.d.ts +0 -4
  126. package/dist/entify/lib/queryUserPosts.d.ts +0 -9
  127. package/dist/entify/lib/queryWebSiteSettings.d.ts +0 -3
  128. package/dist/entify/lib/searchProducts.d.ts +0 -4
  129. package/dist/entify/lib/sendEmail.d.ts +0 -3
  130. package/dist/entify/lib/toQueryOptions.d.ts +0 -3
  131. package/dist/entify/lib/upsertEntity.d.ts +0 -2
  132. package/dist/entify/types/index.d.ts +0 -2
  133. package/dist/entify/types/utils.d.ts +0 -4
  134. package/dist/entify/types/variables.d.ts +0 -7
  135. package/dist/entify/view-model/funcs.d.ts +0 -20
  136. package/dist/entify/view-model/index.d.ts +0 -2
  137. package/dist/entify/view-model/models.d.ts +0 -119
  138. package/dist/index.mjs +0 -40514
  139. package/dist/index.mjs.map +0 -1
  140. package/dist/motion/consts.d.ts +0 -77
  141. package/dist/motion/types.d.ts +0 -26
  142. package/dist/react/components/EnquiryForm/Input.d.ts +0 -15
  143. package/dist/react/components/EnquiryForm/Submit.d.ts +0 -8
  144. package/dist/react/components/EnquiryForm/Textarea.d.ts +0 -13
  145. package/dist/react/components/EnquiryForm/index.d.ts +0 -22
  146. package/dist/react/components/Medias/index.d.ts +0 -8
  147. package/dist/react/components/ProductCard/ProductCard.d.ts +0 -15
  148. package/dist/react/components/ProductCard/ProductCardPreview.d.ts +0 -2
  149. package/dist/react/components/ProductCard/ProductCta/index.d.ts +0 -5
  150. package/dist/react/components/ProductCard/ProductDescription/index.d.ts +0 -2
  151. package/dist/react/components/ProductCard/ProductMedia/index.d.ts +0 -7
  152. package/dist/react/components/ProductCard/ProductTitle/index.d.ts +0 -2
  153. package/dist/react/components/ProductCard/ProductView.d.ts +0 -5
  154. package/dist/react/components/ProductCard/useQueryProduct.d.ts +0 -2
  155. package/dist/react/components/RichTextOutline/index.d.ts +0 -8
  156. package/dist/react/components/RichTextOutline/useAcitviedHeading.d.ts +0 -1
  157. package/dist/react/components/Scroller.d.ts +0 -3
  158. package/dist/react/components/SearchInput.d.ts +0 -2
  159. package/dist/react/components/Share/index.d.ts +0 -6
  160. package/dist/react/components/Share/socials.d.ts +0 -10
  161. package/dist/react/components/ToTop.d.ts +0 -5
  162. package/dist/react/hooks/index.d.ts +0 -1
  163. package/dist/react/hooks/useScroll.d.ts +0 -2
  164. package/dist/robots.d.ts +0 -2
  165. package/dist/scripts/actions.d.ts +0 -85
  166. package/dist/scripts/consts.d.ts +0 -21
  167. package/dist/scripts/events.d.ts +0 -11
  168. package/dist/style.css +0 -98
@@ -0,0 +1,26 @@
1
+ import { OrderBy } from "@rxdrag/entify-hooks";
2
+ import { MediaOnProductQueryOptions, MediaOnProductFields, MediaQueryOptions } from "@rxdrag/rxcms-models";
3
+ import { TSize } from "../types";
4
+
5
+ export function newQueryProductsMediaOptions(imageSize?: TSize | undefined,) {
6
+ return new MediaOnProductQueryOptions(
7
+ [
8
+ MediaOnProductFields.seqValue,
9
+ MediaOnProductFields.altText,
10
+ ],
11
+ {
12
+ orderBy: [
13
+ {
14
+ [MediaOnProductFields.seqValue]: OrderBy.asc,
15
+ }
16
+ ]
17
+ }
18
+ ).media(
19
+ new MediaQueryOptions().file(
20
+ ["thumbnail(width:400, height:320)",
21
+ "url",
22
+ imageSize ? `resize(width:${imageSize.width}, height:${imageSize.height})` : "resize(width:500, height:400)"
23
+ ]
24
+ )
25
+ )
26
+ }
@@ -0,0 +1,27 @@
1
+ import { Product, ProductBoolExp, ProductDistinctExp, ProductFields, ProductOrderBy, ProductQueryOptions, PublishableStatus } from "@rxdrag/rxcms-models";
2
+ import { EnvVariables } from "../types";
3
+ import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
4
+ import { TProduct } from "../view-model";
5
+ import { queryEntityList } from "./queryEntityList";
6
+
7
+ export async function queryAllProducts(envVariables: EnvVariables) {
8
+ const queryOptions = new ProductQueryOptions(
9
+ [ProductFields.id, ProductFields.slug],
10
+ {
11
+ where: {
12
+ [ProductFields.status]: {
13
+ _eq: PublishableStatus.published,
14
+ },
15
+ },
16
+ orderBy: [{ [ProductFields.seqValue]: OrderBy.asc }],
17
+ }
18
+ );
19
+
20
+ const result = await queryEntityList<
21
+ Product,
22
+ ProductBoolExp,
23
+ ProductOrderBy,
24
+ ProductDistinctExp
25
+ >(queryOptions, envVariables);
26
+ return result as ListResult<TProduct> | undefined;
27
+ }
@@ -0,0 +1,44 @@
1
+ import { IQueryOptions, ListResult } from "@rxdrag/entify-hooks";
2
+ import { createEntifyClient } from "./createEntifyClient";
3
+ import { EnvVariables } from "../types";
4
+ import { MediaEntityName, Post, PostCategoryEntityName, PostEntityName, Product, ProductCategoryEntityName, ProductEntityName, UserEntityName } from "@rxdrag/rxcms-models";
5
+ import { mediaListToViewModel, postCategoriesToViewModel, postListToViewModel, productCategoriesToViewModel, productListToViewModel, userListToViewModel } from "../view-model";
6
+
7
+ export async function queryEntityList<T, WhereExp = unknown, OrderBy = unknown, DistinctExp = unknown>(
8
+ options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>,
9
+ envVariables: EnvVariables,
10
+ ) {
11
+ const client = createEntifyClient(envVariables);
12
+
13
+ const result = await client.enityList<T, WhereExp, OrderBy, DistinctExp>(
14
+ !envVariables.websiteId
15
+ ? options
16
+ : options.setQueryArgs(
17
+ {
18
+ ...options.getQueryArgs(),
19
+ where: {
20
+ website: {
21
+ id: { "_eq": envVariables.websiteId }
22
+ },
23
+ ...options.getQueryArgs()?.where
24
+ } as WhereExp
25
+ }
26
+ )
27
+ );
28
+
29
+ switch (options.entityName) {
30
+ case ProductEntityName:
31
+ return productListToViewModel(result as ListResult<Product> | undefined);
32
+ case PostEntityName:
33
+ return postListToViewModel(result as ListResult<Post> | undefined);
34
+ case ProductCategoryEntityName:
35
+ return productCategoriesToViewModel(result as ListResult<Product> | undefined);
36
+ case PostCategoryEntityName:
37
+ return postCategoriesToViewModel(result as ListResult<Post> | undefined);
38
+ case UserEntityName:
39
+ return userListToViewModel(result as ListResult<Post> | undefined);
40
+ case MediaEntityName:
41
+ return mediaListToViewModel(result as ListResult<Post> | undefined);
42
+ }
43
+ return result;
44
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ Product,
3
+ ProductBoolExp,
4
+ ProductOrderBy,
5
+ ProductDistinctExp,
6
+ ProductFields,
7
+ ProductQueryOptions,
8
+ } from "@rxdrag/rxcms-models";
9
+ import { queryEntityList } from "./queryEntityList";
10
+ import { newQueryProductsMediaOptions } from "./newQueryProductsMediaOptions";
11
+ import { EnvVariables } from "../types";
12
+ import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
13
+ import { TProduct } from "../view-model";
14
+
15
+ export async function queryFeaturedProducts(
16
+ count: number = 8,
17
+ envVariables: EnvVariables
18
+ ) {
19
+ const result = await queryEntityList<
20
+ Product,
21
+ ProductBoolExp,
22
+ ProductOrderBy,
23
+ ProductDistinctExp
24
+ >(
25
+ new ProductQueryOptions(
26
+ [
27
+ ProductFields.id,
28
+ ProductFields.slug,
29
+ ProductFields.title,
30
+ ProductFields.shortTitle,
31
+ ProductFields.description,
32
+ ],
33
+ {
34
+ offset: 0,
35
+ limit: count,
36
+ where: {
37
+ featured: {
38
+ _eq: true,
39
+ },
40
+ },
41
+ orderBy: [{ [ProductFields.seqValue]: OrderBy.asc }],
42
+ }
43
+ ).mediaPivots(newQueryProductsMediaOptions()),
44
+ envVariables
45
+ );
46
+ return result as ListResult<TProduct> | undefined;
47
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ Lang,
3
+ LangBoolExp,
4
+ LangDistinctExp,
5
+ LangOrderBy,
6
+ LangQueryOptions,
7
+ LangFields,
8
+ LangAssciations,
9
+ } from "@rxdrag/rxcms-models";
10
+ import { ListResult } from "@rxdrag/entify-hooks";
11
+ import { EnvVariables } from "../types";
12
+ import { createEntifyClient } from "./createEntifyClient";
13
+
14
+ export async function queryLangs(envVariables: EnvVariables) {
15
+ const client = createEntifyClient(envVariables);
16
+
17
+ const result = await client.enityList<
18
+ Lang,
19
+ LangBoolExp,
20
+ LangOrderBy,
21
+ LangDistinctExp
22
+ >(
23
+ new LangQueryOptions(
24
+ [
25
+ LangFields.id,
26
+ LangFields.abbr,
27
+ LangFields.circleIcon,
28
+ LangFields.cnName,
29
+ LangFields.enName,
30
+ LangFields.localName,
31
+ LangFields.icon,
32
+ LangFields.htmlLang,
33
+ ],
34
+ {
35
+ where: {
36
+ [LangAssciations.websites]: {
37
+ id: {
38
+ _eq: envVariables.websiteId,
39
+ },
40
+ },
41
+ },
42
+ }
43
+ ).setNoQuery(!envVariables.websiteId)
44
+ );
45
+
46
+ return result as ListResult<Lang> | undefined;
47
+ }
@@ -0,0 +1,65 @@
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
+ UserQueryOptions,
11
+ UserFields,
12
+ PublishableStatus,
13
+ } from "@rxdrag/rxcms-models";
14
+ import { queryEntityList } from "./queryEntityList";
15
+ import { EnvVariables } from "../types";
16
+ import { TPost } from "../view-model";
17
+
18
+ export async function queryLatestPosts(
19
+ count: number = 2,
20
+ envVariables: EnvVariables
21
+ ) {
22
+ const result = await queryEntityList<
23
+ Post,
24
+ PostBoolExp,
25
+ PostOrderBy,
26
+ PostDistinctExp
27
+ >(
28
+ new PostQueryOptions(
29
+ [
30
+ PostFields.id,
31
+ PostFields.slug,
32
+ PostFields.title,
33
+ PostFields.description,
34
+ ],
35
+ {
36
+ offset: 0,
37
+ limit: count,
38
+ orderBy: [
39
+ {
40
+ //暂时按照更新时间排序
41
+ updatedAt: OrderBy.desc,
42
+ },
43
+ ],
44
+ where: {
45
+ [PostFields.status]: {
46
+ _eq: PublishableStatus.published,
47
+ },
48
+ },
49
+ }
50
+ )
51
+ .cover(
52
+ new MediaQueryOptions().file([
53
+ "thumbnail",
54
+ "resize(width:480, height:180)",
55
+ ])
56
+ )
57
+ .author(
58
+ new UserQueryOptions([UserFields.id, UserFields.name]).avatar(
59
+ new MediaQueryOptions().file(["thumbnail"])
60
+ )
61
+ ),
62
+ envVariables
63
+ );
64
+ return result as ListResult<TPost> | undefined;
65
+ }
@@ -0,0 +1,67 @@
1
+ import { IQueryOptions } from "@rxdrag/entify-hooks";
2
+ import { createEntifyClient } from "./createEntifyClient";
3
+ import {
4
+ MediaEntityName,
5
+ PostCategoryEntityName,
6
+ PostEntityName,
7
+ ProductCategoryEntityName,
8
+ ProductEntityName,
9
+ UserEntityName,
10
+ WebsitePart,
11
+ WebsiteSettingsEntityName,
12
+ } from "@rxdrag/rxcms-models";
13
+ import { WebsitePartBoolExp } from "@rxdrag/rxcms-models/";
14
+ import { EnvVariables } from "../types";
15
+ import {
16
+ mediaToViewModel,
17
+ postCategoryToViewModel,
18
+ postToViewModel,
19
+ productCategoryToViewModel,
20
+ productToViewModel,
21
+ userToViewModel,
22
+ websiteSettingsToViewModel,
23
+ } from "../view-model";
24
+
25
+ export async function queryOneEntity<
26
+ T extends WebsitePart = WebsitePart,
27
+ WhereExp extends WebsitePartBoolExp = WebsitePartBoolExp,
28
+ OrderBy = unknown,
29
+ DistinctExp = unknown
30
+ >(
31
+ options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>,
32
+ envVariables: EnvVariables
33
+ ) {
34
+ const client = createEntifyClient(envVariables);
35
+ const result = await client.oneEntity<T, WhereExp, OrderBy, DistinctExp>(
36
+ !envVariables.websiteId
37
+ ? options
38
+ : options.setQueryArgs({
39
+ ...options.getQueryArgs(),
40
+ where: {
41
+ website: {
42
+ id: { _eq: envVariables.websiteId },
43
+ },
44
+ ...options.getQueryArgs()?.where,
45
+ } as unknown as WhereExp,
46
+ })
47
+ );
48
+
49
+ switch (options.entityName) {
50
+ case ProductEntityName:
51
+ return productToViewModel(result) as T | undefined;
52
+ case PostEntityName:
53
+ return postToViewModel(result) as T | undefined;
54
+ case ProductCategoryEntityName:
55
+ return productCategoryToViewModel(result) as T | undefined;
56
+ case PostCategoryEntityName:
57
+ return postCategoryToViewModel(result) as T | undefined;
58
+ case UserEntityName:
59
+ return userToViewModel(result) as T | undefined;
60
+ case MediaEntityName:
61
+ return mediaToViewModel(result) as T | undefined;
62
+ case WebsiteSettingsEntityName:
63
+ return websiteSettingsToViewModel(result) as T | undefined;
64
+ }
65
+
66
+ return result as T | undefined;
67
+ }
@@ -0,0 +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
+ }
@@ -0,0 +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, TSize } from "../types";
5
+ import { TPost } from "../view-model";
6
+
7
+ export async function queryOnePostBySlug(slug: string, coverSize: TSize | undefined, envVariables: EnvVariables) {
8
+
9
+ const post = await queryOneEntity<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
10
+ newQueryOnePostOptions(coverSize)
11
+ .setQueryArgs({
12
+ where: {
13
+ slug: {
14
+ "_eq": slug
15
+ },
16
+ },
17
+ }),
18
+ envVariables
19
+ );
20
+ return post as TPost | undefined;
21
+ }
@@ -0,0 +1,30 @@
1
+ import { ProductCategoryFields, PostCategory, PostCategoryBoolExp, PostCategoryDistinctExp, PostCategoryOrderBy, PostCategoryQueryOptions } from "@rxdrag/rxcms-models";
2
+ import { queryOneEntity } from "./queryOneEntity";
3
+ import { EnvVariables } from "../types";
4
+ import { TPostCategory } from "../view-model";
5
+
6
+ export async function queryOnePostCategoryBySlug(slug: string, envVariables: EnvVariables) {
7
+
8
+ const postCategory = await queryOneEntity<PostCategory, PostCategoryBoolExp, PostCategoryOrderBy, PostCategoryDistinctExp>(
9
+ new PostCategoryQueryOptions(
10
+ [
11
+ ProductCategoryFields.id,
12
+ ProductCategoryFields.slug,
13
+ ProductCategoryFields.name,
14
+ ProductCategoryFields.seqValue,
15
+ ProductCategoryFields.description,
16
+ ProductCategoryFields.createdAt,
17
+ ],
18
+ {
19
+ where: {
20
+ slug: {
21
+ "_eq": slug
22
+ },
23
+ },
24
+ }
25
+ ),
26
+ envVariables
27
+ );
28
+
29
+ return postCategory as TPostCategory | undefined;
30
+ }
@@ -0,0 +1,20 @@
1
+ import { Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp } from "@rxdrag/rxcms-models";
2
+ import { newQueryProductOptions } from "./newQueryProductOptions";
3
+ import { queryOneEntity } from "./queryOneEntity";
4
+ import { EnvVariables } from "../types";
5
+
6
+ export async function queryOneProductById(id: string, envVariables: EnvVariables) {
7
+
8
+ const product = await queryOneEntity<Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp>(
9
+ newQueryProductOptions()
10
+ .setQueryArgs({
11
+ where: {
12
+ id: {
13
+ "_eq": id
14
+ }
15
+ }
16
+ }),
17
+ envVariables
18
+ );
19
+ return product;
20
+ }
@@ -0,0 +1,21 @@
1
+ import { Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp } from "@rxdrag/rxcms-models";
2
+ import { newQueryProductOptions } from "./newQueryProductOptions";
3
+ import { queryOneEntity } from "./queryOneEntity";
4
+ import { EnvVariables, TSize } from "../types";
5
+ import { TProduct } from "../view-model";
6
+
7
+ export async function queryOneProductBySlug(slug: string, imageSize: TSize | undefined, envVariables: EnvVariables) {
8
+
9
+ const product = await queryOneEntity<Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp>(
10
+ newQueryProductOptions(imageSize)
11
+ .setQueryArgs({
12
+ where: {
13
+ slug: {
14
+ "_eq": slug
15
+ },
16
+ },
17
+ }),
18
+ envVariables
19
+ );
20
+ return product as TProduct | undefined;
21
+ }
@@ -0,0 +1,30 @@
1
+ import { ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp, ProductCategoryQueryOptions, ProductCategoryFields } from "@rxdrag/rxcms-models";
2
+ import { queryOneEntity } from "./queryOneEntity";
3
+ import { EnvVariables } from "../types";
4
+ import { TProductCategory } from "../view-model";
5
+
6
+ export async function queryOneProductCategoryBySlug(slug: string, envVariables: EnvVariables) {
7
+
8
+ const productCategory = await queryOneEntity<ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp>(
9
+ new ProductCategoryQueryOptions(
10
+ [
11
+ ProductCategoryFields.id,
12
+ ProductCategoryFields.slug,
13
+ ProductCategoryFields.name,
14
+ ProductCategoryFields.seqValue,
15
+ ProductCategoryFields.description,
16
+ ProductCategoryFields.createdAt,
17
+ ],
18
+ {
19
+ where: {
20
+ slug: {
21
+ "_eq": slug
22
+ },
23
+ },
24
+ }
25
+ ),
26
+ envVariables
27
+ );
28
+
29
+ return productCategory as TProductCategory | undefined;
30
+ }
@@ -0,0 +1,76 @@
1
+ import {
2
+ Theme,
3
+ ThemeBoolExp,
4
+ ThemeOrderBy,
5
+ ThemeDistinctExp,
6
+ ThemeQueryOptions,
7
+ ThemeFields,
8
+ ThemeConfigQueryOptions,
9
+ ThemeConfigFields,
10
+ MediaQueryOptions,
11
+ } from "@rxdrag/rxcms-models";
12
+ import { EnvVariables } from "../types";
13
+ import { langFields } from "./langFields";
14
+ import { queryOneEntity } from "./queryOneEntity";
15
+
16
+ export async function queryOneTheme(envVariables: EnvVariables) {
17
+ return await queryOneEntity<
18
+ Theme,
19
+ ThemeBoolExp,
20
+ ThemeOrderBy,
21
+ ThemeDistinctExp
22
+ >(
23
+ new ThemeQueryOptions(
24
+ [
25
+ ThemeFields.id,
26
+ ThemeFields.name,
27
+ ThemeFields.css,
28
+ ThemeFields.settings,
29
+ ThemeFields.tailwindConfig,
30
+ ],
31
+ {
32
+ where: {
33
+ lang: {
34
+ abbr: {
35
+ _eq: envVariables.language,
36
+ },
37
+ },
38
+ },
39
+ }
40
+ )
41
+ // .frame([
42
+ // WebsiteFrameFields.id,
43
+ // WebsiteFrameFields.content,
44
+ // WebsiteFrameFields.settings,
45
+ // WebsiteFrameFields.updatedAt,
46
+ // WebsiteFrameFields.dataSource,
47
+ // ])
48
+ // .components([
49
+ // FrontComponentFields.id,
50
+ // FrontComponentFields.name,
51
+ // FrontComponentFields.content,
52
+ // FrontComponentFields.droppable,
53
+ // FrontComponentFields.props,
54
+ // FrontComponentFields.seqValue,
55
+ // FrontComponentFields.slots,
56
+ // FrontComponentFields.testConfig,
57
+ // FrontComponentFields.title,
58
+ // ])
59
+ .config(
60
+ new ThemeConfigQueryOptions([
61
+ ThemeConfigFields.id,
62
+ ThemeConfigFields.address,
63
+ ThemeConfigFields.contact,
64
+ ThemeConfigFields.email,
65
+ ThemeConfigFields.fax,
66
+ ThemeConfigFields.mobile,
67
+ ThemeConfigFields.tel,
68
+ ThemeConfigFields.wechat,
69
+ ThemeConfigFields.websiteName,
70
+ ]).contactAvatar(new MediaQueryOptions().file(["thumbnail"]))
71
+ )
72
+ .lang(langFields)
73
+ .setNoQuery(!envVariables.websiteId || !envVariables.language),
74
+ envVariables
75
+ );
76
+ }
@@ -0,0 +1,38 @@
1
+ import { User, UserFields, UserQueryOptions, UserBoolExp, UserOrderBy, UserDistinctExp } from "@rxdrag/rxcms-models";
2
+ import { queryOneEntity } from "./queryOneEntity";
3
+ import { newAvatarQueryOptions } from "./newAvatarQueryOptions";
4
+ import { EnvVariables } from "../types";
5
+ import { TUser } from "../view-model";
6
+
7
+ export async function queryOneUser(id: string, envVariables: EnvVariables) {
8
+
9
+ const user = await queryOneEntity<User, UserBoolExp, UserOrderBy, UserDistinctExp>(
10
+ new UserQueryOptions(
11
+ [
12
+ UserFields.id,
13
+ UserFields.name,
14
+ UserFields.position,
15
+ UserFields.email,
16
+ UserFields.summary,
17
+ UserFields.linkedIn,
18
+ UserFields.twitter,
19
+ UserFields.facebook,
20
+ UserFields.profile,
21
+ ],
22
+ {
23
+ where: {
24
+ id: {
25
+ "_eq": id
26
+ },
27
+ },
28
+ }
29
+ )
30
+ .avatar(
31
+ newAvatarQueryOptions()
32
+ )
33
+ .setNoQuery(!id),
34
+ { ...envVariables, websiteId: undefined }
35
+ );
36
+
37
+ return user as TUser | undefined;
38
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ PostCategory,
3
+ PostCategoryBoolExp,
4
+ PostCategoryOrderBy,
5
+ PostCategoryDistinctExp,
6
+ PostCategoryFields,
7
+ PostCategoryQueryOptions,
8
+ ProductFields,
9
+ PublishableStatus,
10
+ PostQueryOptions,
11
+ PostFields,
12
+ } from "@rxdrag/rxcms-models";
13
+ import { queryEntityList } from "./queryEntityList";
14
+ import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
15
+ import { EnvVariables } from "../types";
16
+ import { TPostCategory } from "../view-model";
17
+
18
+ export async function queryPostCategories(envVariables: EnvVariables) {
19
+ const result = await queryEntityList<
20
+ PostCategory,
21
+ PostCategoryBoolExp,
22
+ PostCategoryOrderBy,
23
+ PostCategoryDistinctExp
24
+ >(
25
+ new PostCategoryQueryOptions(
26
+ [
27
+ PostCategoryFields.id,
28
+ PostCategoryFields.name,
29
+ PostCategoryFields.slug,
30
+ PostCategoryFields.description,
31
+ ],
32
+ {
33
+ orderBy: [{ [PostCategoryFields.seqValue]: OrderBy.asc }],
34
+ }
35
+ ).posts(
36
+ new PostQueryOptions([PostFields.id, PostFields.title, PostFields.slug], {
37
+ where: {
38
+ [PostFields.status]: {
39
+ _eq: PublishableStatus.published,
40
+ },
41
+ },
42
+ orderBy: [{ [ProductFields.seqValue]: OrderBy.asc }],
43
+ })
44
+ ),
45
+ envVariables
46
+ );
47
+ return result as ListResult<TPostCategory> | undefined;
48
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ Post,
3
+ PostBoolExp,
4
+ PostDistinctExp,
5
+ PostFields,
6
+ PostOrderBy,
7
+ PostQueryOptions,
8
+ PublishableStatus,
9
+ } from "@rxdrag/rxcms-models";
10
+ import { EnvVariables } from "../types";
11
+ import { OrderBy, ListResult } from "@rxdrag/entify-hooks";
12
+ import { TPost } from "../view-model";
13
+ import { queryEntityList } from "./queryEntityList";
14
+
15
+ export async function queryPostSlugs(envVariables: EnvVariables) {
16
+ const queryOptions = new PostQueryOptions([PostFields.id, PostFields.slug], {
17
+ where: {
18
+ [PostFields.status]: {
19
+ _eq: PublishableStatus.published,
20
+ },
21
+ },
22
+ orderBy: [{ [PostFields.seqValue]: OrderBy.asc }],
23
+ });
24
+
25
+ const result = await queryEntityList<
26
+ Post,
27
+ PostBoolExp,
28
+ PostOrderBy,
29
+ PostDistinctExp
30
+ >(queryOptions, envVariables);
31
+ return result as ListResult<TPost> | undefined;
32
+ }