@rxdrag/website-lib-core 0.0.60 → 0.0.62
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdrag/website-lib-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.ts"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@types/react-dom": "^19.1.0",
|
|
25
25
|
"eslint": "^7.32.0",
|
|
26
26
|
"typescript": "^5",
|
|
27
|
-
"@rxdrag/eslint-config-custom": "0.2.12",
|
|
28
27
|
"@rxdrag/tsconfig": "0.2.0",
|
|
29
|
-
"@rxdrag/slate-preview": "1.2.58"
|
|
28
|
+
"@rxdrag/slate-preview": "1.2.58",
|
|
29
|
+
"@rxdrag/eslint-config-custom": "0.2.12"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"clsx": "^2.1.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"lodash-es": "^4.17.21",
|
|
36
36
|
"react": "^19.1.0",
|
|
37
37
|
"react-dom": "^19.1.0",
|
|
38
|
-
"@rxdrag/
|
|
39
|
-
"@rxdrag/
|
|
38
|
+
"@rxdrag/rxcms-models": "0.3.88",
|
|
39
|
+
"@rxdrag/entify-lib": "0.0.17"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"astro": "^4.0.0 || ^5.0.0"
|
package/src/entify/Entify.ts
CHANGED
|
@@ -29,6 +29,8 @@ import { queryUserIds } from "./lib/queryUserIds";
|
|
|
29
29
|
import { IEntify, PostPatinateOptions, PostsOptions } from "./IEntify";
|
|
30
30
|
import { queryWebsite } from "./lib/queryWebsite";
|
|
31
31
|
import {
|
|
32
|
+
ImageSizes,
|
|
33
|
+
Media,
|
|
32
34
|
Page,
|
|
33
35
|
PageType,
|
|
34
36
|
Product,
|
|
@@ -37,11 +39,12 @@ import {
|
|
|
37
39
|
} from "@rxdrag/rxcms-models";
|
|
38
40
|
import { queryPageBySlug } from "./lib/queryPageBySlug";
|
|
39
41
|
import { queryPageByType } from "./lib/queryPageByType";
|
|
42
|
+
import { queryOneMedia } from "./lib/queryOneMedia";
|
|
40
43
|
|
|
41
44
|
export class Entify implements IEntify {
|
|
42
45
|
private static instance: Entify | null = null;
|
|
43
46
|
|
|
44
|
-
private constructor(protected envVariables: EnvVariables) {}
|
|
47
|
+
private constructor(protected envVariables: EnvVariables) { }
|
|
45
48
|
|
|
46
49
|
public static getInstance(envVariables: EnvVariables): Entify {
|
|
47
50
|
if (!Entify.instance) {
|
|
@@ -50,6 +53,16 @@ export class Entify implements IEntify {
|
|
|
50
53
|
return Entify.instance;
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
private imageSizes: ImageSizes | undefined;
|
|
57
|
+
|
|
58
|
+
public setImageSizes(imageSizes: ImageSizes | undefined): void {
|
|
59
|
+
this.imageSizes = imageSizes;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public getImageSizes(): ImageSizes | undefined {
|
|
63
|
+
return this.imageSizes;
|
|
64
|
+
}
|
|
65
|
+
|
|
53
66
|
public async queryEntityList<
|
|
54
67
|
T,
|
|
55
68
|
WhereExp = unknown,
|
|
@@ -87,6 +100,10 @@ export class Entify implements IEntify {
|
|
|
87
100
|
return (await queryLangs(this.envVariables))?.items;
|
|
88
101
|
}
|
|
89
102
|
|
|
103
|
+
public async getMedia(ref: string | undefined | null): Promise<Media | undefined> {
|
|
104
|
+
return await queryOneMedia(ref, this.envVariables);
|
|
105
|
+
}
|
|
106
|
+
|
|
90
107
|
public async getFeaturedProducts(
|
|
91
108
|
count?: number,
|
|
92
109
|
imageSize?: TSize,
|
package/src/entify/IEntify.ts
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
TUser,
|
|
10
10
|
} from "./view-model";
|
|
11
11
|
import {
|
|
12
|
+
ImageSizes,
|
|
12
13
|
Lang,
|
|
14
|
+
Media,
|
|
13
15
|
Page,
|
|
14
16
|
PageType,
|
|
15
17
|
Product,
|
|
@@ -33,6 +35,9 @@ export type PostPatinateOptions = {
|
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
export interface IEntify {
|
|
38
|
+
//从配置文件注入到这里面,供组件使用
|
|
39
|
+
setImageSizes(imageSizes: ImageSizes | undefined): void;
|
|
40
|
+
getImageSizes(): ImageSizes | undefined;
|
|
36
41
|
getLang(): string;
|
|
37
42
|
queryEntityList<
|
|
38
43
|
T,
|
|
@@ -53,6 +58,8 @@ export interface IEntify {
|
|
|
53
58
|
|
|
54
59
|
getLangs(): Promise<Lang[] | undefined>;
|
|
55
60
|
|
|
61
|
+
getMedia(ref: string | undefined | null): Promise<Media | undefined>;
|
|
62
|
+
|
|
56
63
|
getFeaturedProducts(
|
|
57
64
|
count?: number,
|
|
58
65
|
imageSize?: TSize,
|
|
@@ -153,4 +160,5 @@ export interface IEntify {
|
|
|
153
160
|
createPagination(totalItems: number, pageSize: number): unknown;
|
|
154
161
|
|
|
155
162
|
createUploadCredentials(options: UploadOptions): Promise<UploadSession | null>;
|
|
163
|
+
|
|
156
164
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { EntifyClient } from "@rxdrag/entify-lib";
|
|
2
|
-
import { EnvVariables } from "../types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function createEntifyClient(
|
|
6
|
-
envVariables: EnvVariables
|
|
7
|
-
) {
|
|
8
|
-
if (!envVariables.entifyServerUrl) {
|
|
9
|
-
console.error('envVariables.entifyServerUrl Not Set');
|
|
10
|
-
throw new Response("envVariables.entifyServerUrl Not Set", { status: 500 });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// if (!envVariables.websiteId) {
|
|
14
|
-
// console.error('envVariables.websiteId Not Set');
|
|
15
|
-
// throw new Response("envVariables.websiteId Not Set", { status: 500 });
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
if (!envVariables.entifyGuestToken) {
|
|
19
|
-
console.error('envVariables.entifyGuestToken Not Set');
|
|
20
|
-
throw new Response("envVariables.entifyGuestToken Not Set", { status: 500 });
|
|
21
|
-
}
|
|
22
|
-
return new EntifyClient(envVariables.entifyServerUrl, envVariables.entifyGuestToken)
|
|
1
|
+
import { EntifyClient } from "@rxdrag/entify-lib";
|
|
2
|
+
import { EnvVariables } from "../types";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function createEntifyClient(
|
|
6
|
+
envVariables: EnvVariables
|
|
7
|
+
) {
|
|
8
|
+
if (!envVariables.entifyServerUrl) {
|
|
9
|
+
console.error('envVariables.entifyServerUrl Not Set');
|
|
10
|
+
throw new Response("envVariables.entifyServerUrl Not Set", { status: 500 });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// if (!envVariables.websiteId) {
|
|
14
|
+
// console.error('envVariables.websiteId Not Set');
|
|
15
|
+
// throw new Response("envVariables.websiteId Not Set", { status: 500 });
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
if (!envVariables.entifyGuestToken) {
|
|
19
|
+
console.error('envVariables.entifyGuestToken Not Set');
|
|
20
|
+
throw new Response("envVariables.entifyGuestToken Not Set", { status: 500 });
|
|
21
|
+
}
|
|
22
|
+
return new EntifyClient(envVariables.entifyServerUrl, envVariables.entifyGuestToken)
|
|
23
23
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Media, MediaBoolExp, MediaDistinctExp, MediaFields, MediaOrderBy, MediaQueryOptions } from "@rxdrag/rxcms-models";
|
|
2
|
+
import { EnvVariables } from "../types";
|
|
3
|
+
import { queryOneEntity } from "./queryOneEntity";
|
|
4
|
+
|
|
5
|
+
export const queryOneMedia = async (ref: string | undefined | null, envVariables: EnvVariables) => {
|
|
6
|
+
const media = await queryOneEntity<Media, MediaBoolExp, MediaOrderBy, MediaDistinctExp>(
|
|
7
|
+
new MediaQueryOptions([
|
|
8
|
+
MediaFields.id,
|
|
9
|
+
MediaFields.mediaRef,
|
|
10
|
+
MediaFields.mediaType,
|
|
11
|
+
MediaFields.storageType,
|
|
12
|
+
], {
|
|
13
|
+
where: {
|
|
14
|
+
mediaRef: {
|
|
15
|
+
"_eq": ref || ""
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
.file(["original", "thumbnail"])
|
|
20
|
+
.setNoQuery(!ref)
|
|
21
|
+
,
|
|
22
|
+
envVariables
|
|
23
|
+
);
|
|
24
|
+
return media;
|
|
25
|
+
};
|