@tbox.cn/app-module-shopping-guide 0.2.1
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/LICENSE +21 -0
- package/dist/chunk-AGBLC6XI.js +1294 -0
- package/dist/chunk-U4WDS5PQ.js +173 -0
- package/dist/client/index.d.ts +25 -0
- package/dist/client/index.js +6 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +22 -0
- package/dist/server/index.d.ts +4098 -0
- package/dist/server/index.js +18 -0
- package/package.json +62 -0
- package/skills/shopping-guide/SKILL.md +36 -0
- package/skills/shopping-guide/references/comparison-format.md +5 -0
- package/skills/shopping-guide/references/faq-answers.md +5 -0
- package/skills/shopping-guide/references/floor-directory.md +4 -0
- package/skills/shopping-guide/references/intent-patterns.md +5 -0
- package/skills/shopping-guide/references/location-format.md +5 -0
- package/skills/shopping-guide/references/policy-lookup.md +5 -0
- package/skills/shopping-guide/references/product-search-tips.md +6 -0
- package/skills/shopping-guide/references/recommendation-style.md +5 -0
- package/src/client/cards/index.tsx +267 -0
- package/src/client/index.ts +39 -0
- package/src/index.ts +6 -0
- package/src/server/cards/category-list/meta.ts +19 -0
- package/src/server/cards/customer-service-faq/meta.ts +18 -0
- package/src/server/cards/human-guide-list/meta.ts +19 -0
- package/src/server/cards/index.ts +43 -0
- package/src/server/cards/location-handoff/meta.ts +20 -0
- package/src/server/cards/mall-directory/meta.ts +27 -0
- package/src/server/cards/merchant-detail/meta.ts +27 -0
- package/src/server/cards/merchant-list/meta.ts +31 -0
- package/src/server/cards/nearby-mall-list/meta.ts +17 -0
- package/src/server/cards/product-comparison/meta.ts +29 -0
- package/src/server/cards/product-detail/meta.ts +29 -0
- package/src/server/cards/product-list/meta.ts +32 -0
- package/src/server/domain/value-objects.ts +49 -0
- package/src/server/index.ts +180 -0
- package/src/server/integrations/joycity/adapter.ts +226 -0
- package/src/server/integrations/joycity/auth-strategy.ts +38 -0
- package/src/server/integrations/joycity/gateway.ts +128 -0
- package/src/server/ports/index.ts +151 -0
- package/src/server/ports/local-adapters.ts +90 -0
- package/src/server/projections/index.ts +253 -0
- package/src/server/tools/index.ts +407 -0
- package/tbox.component.json +48 -0
- package/tests/shopping-guide.test.ts +290 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +29 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// src/client/cards/index.tsx
|
|
2
|
+
import { CardFrame, ValueText, StatusPill } from "@tbox.cn/app-sdk/client";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var listStyle = { listStyle: "none", margin: 0, padding: 0 };
|
|
5
|
+
var itemStyle = {
|
|
6
|
+
padding: "8px 0",
|
|
7
|
+
borderBottom: "1px solid var(--tbox-divider, #f0f0f0)"
|
|
8
|
+
};
|
|
9
|
+
function ProductListCard(props) {
|
|
10
|
+
const { data } = props;
|
|
11
|
+
if (data.items.length === 0) {
|
|
12
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u5546\u54C1\u5217\u8868", children: data.noResultsReason ?? "\u6682\u65E0\u5546\u54C1" });
|
|
13
|
+
}
|
|
14
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u5546\u54C1\u5217\u8868", subtitle: data.summary, children: /* @__PURE__ */ jsx("ul", { style: listStyle, children: data.items.map((item) => /* @__PURE__ */ jsxs("li", { style: itemStyle, children: [
|
|
15
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [
|
|
16
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: item.name }),
|
|
17
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, color: "var(--tbox-primary, #e93b3d)" }, children: item.price.sale?.display ?? "" })
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { style: { marginTop: 4, display: "flex", gap: 6, alignItems: "center", flexWrap: "wrap" }, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
StatusPill,
|
|
22
|
+
{
|
|
23
|
+
tone: item.availability.marketable ? "success" : "neutral",
|
|
24
|
+
text: item.availability.label
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
item.badges.map((b) => /* @__PURE__ */ jsx(StatusPill, { tone: "neutral", text: b }, b))
|
|
28
|
+
] }),
|
|
29
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u95E8\u5E97", value: `${item.merchant.name}${item.merchant.location ? ` \xB7 ${item.merchant.location.displayText}` : ""}` })
|
|
30
|
+
] }, item.productId)) }) });
|
|
31
|
+
}
|
|
32
|
+
function ProductDetailCard(props) {
|
|
33
|
+
const { data } = props;
|
|
34
|
+
return /* @__PURE__ */ jsxs(CardFrame, { title: data.name, subtitle: data.brand, children: [
|
|
35
|
+
data.imageUrls[0] && /* @__PURE__ */ jsx("img", { src: data.imageUrls[0], alt: data.name, style: { width: "100%", borderRadius: 8, marginBottom: 8 } }),
|
|
36
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u4EF7\u683C", value: data.price.sale?.display ?? "\u2014" }),
|
|
37
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u5E93\u5B58", value: data.availability.label }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
ValueText,
|
|
40
|
+
{
|
|
41
|
+
label: "\u95E8\u5E97",
|
|
42
|
+
value: `${data.merchant.name}${data.merchant.location ? ` \xB7 ${data.merchant.location.displayText}` : ""}`
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
data.attributes.map((a) => /* @__PURE__ */ jsx(ValueText, { label: a.name, value: a.value }, a.name)),
|
|
46
|
+
data.promotionFacts.map((p) => /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--tbox-primary, #e93b3d)", marginTop: 4 }, children: p }, p))
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
function MerchantListCard(props) {
|
|
50
|
+
const { data } = props;
|
|
51
|
+
if (data.items.length === 0) {
|
|
52
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u95E8\u5E97\u5217\u8868", children: data.noResultsReason ?? "\u6682\u65E0\u95E8\u5E97" });
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u95E8\u5E97\u5217\u8868", subtitle: data.summary, children: /* @__PURE__ */ jsx("ul", { style: listStyle, children: data.items.map((item) => /* @__PURE__ */ jsxs("li", { style: itemStyle, children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [
|
|
56
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: item.name }),
|
|
57
|
+
/* @__PURE__ */ jsx(StatusPill, { tone: item.status.code === "enabled" ? "success" : "warning", text: item.status.label })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u4F4D\u7F6E", value: item.location.displayText }),
|
|
60
|
+
item.promotionFacts.length > 0 && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--tbox-primary, #e93b3d)" }, children: item.promotionFacts.join(" \xB7 ") })
|
|
61
|
+
] }, item.merchantId)) }) });
|
|
62
|
+
}
|
|
63
|
+
function MerchantDetailCard(props) {
|
|
64
|
+
const { data } = props;
|
|
65
|
+
return /* @__PURE__ */ jsxs(CardFrame, { title: data.name, subtitle: data.brand, children: [
|
|
66
|
+
/* @__PURE__ */ jsx(StatusPill, { tone: data.status.code === "enabled" ? "success" : "warning", text: data.status.label }),
|
|
67
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u4F4D\u7F6E", value: data.location.displayText }),
|
|
68
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u4E1A\u6001", value: data.businessCategories.join(" / ") }),
|
|
69
|
+
data.description && /* @__PURE__ */ jsx("div", { style: { fontSize: 13, marginTop: 6 }, children: data.description }),
|
|
70
|
+
data.contactInfo?.map((c, i) => /* @__PURE__ */ jsx(ValueText, { label: c.channel, value: c.value }, i)),
|
|
71
|
+
data.promotionFacts.map((p) => /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--tbox-primary, #e93b3d)", marginTop: 4 }, children: p }, p))
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
function CategoryListCard(props) {
|
|
75
|
+
const { data } = props;
|
|
76
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u4E1A\u6001\u5206\u7C7B", children: /* @__PURE__ */ jsx("ul", { style: listStyle, children: data.categories.map((c) => /* @__PURE__ */ jsxs("li", { style: itemStyle, children: [
|
|
77
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [
|
|
78
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: c.name }),
|
|
79
|
+
/* @__PURE__ */ jsxs("span", { style: { fontSize: 12, color: "var(--tbox-text-secondary, #888)" }, children: [
|
|
80
|
+
c.merchantCount,
|
|
81
|
+
" \u5BB6"
|
|
82
|
+
] })
|
|
83
|
+
] }),
|
|
84
|
+
c.subCategories && c.subCategories.length > 0 && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--tbox-text-secondary, #888)", marginTop: 2 }, children: c.subCategories.map((s) => s.name).join(" / ") })
|
|
85
|
+
] }, c.code)) }) });
|
|
86
|
+
}
|
|
87
|
+
function ProductComparisonCard(props) {
|
|
88
|
+
const { data } = props;
|
|
89
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u5546\u54C1\u5BF9\u6BD4", children: data.products.map((p) => /* @__PURE__ */ jsxs("div", { style: itemStyle, children: [
|
|
90
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [
|
|
91
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: p.name }),
|
|
92
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, color: "var(--tbox-primary, #e93b3d)" }, children: p.price.sale?.display ?? "\u2014" })
|
|
93
|
+
] }),
|
|
94
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u5E93\u5B58", value: p.availability.label }),
|
|
95
|
+
p.attributes.map((a) => /* @__PURE__ */ jsx(ValueText, { label: a.name, value: a.value }, a.name))
|
|
96
|
+
] }, p.productId)) });
|
|
97
|
+
}
|
|
98
|
+
function MallDirectoryCard(props) {
|
|
99
|
+
const { data } = props;
|
|
100
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: `${data.mallName} \xB7 \u697C\u5C42\u76EE\u5F55`, children: data.buildings.map((b) => /* @__PURE__ */ jsxs("div", { style: { marginBottom: 8 }, children: [
|
|
101
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 14, fontWeight: 600, marginBottom: 4 }, children: b.buildingName }),
|
|
102
|
+
b.floors.map((f) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", padding: "3px 0" }, children: [
|
|
103
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 13 }, children: f.floorName }),
|
|
104
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "var(--tbox-text-secondary, #888)" }, children: f.businessCategories.join(" / ") || `${f.merchantCount} \u5BB6` })
|
|
105
|
+
] }, f.floorCode))
|
|
106
|
+
] }, b.buildingCode)) });
|
|
107
|
+
}
|
|
108
|
+
function NearbyMallListCard(props) {
|
|
109
|
+
const { data } = props;
|
|
110
|
+
if (data.malls.length === 0) return /* @__PURE__ */ jsx(CardFrame, { title: "\u9644\u8FD1\u5546\u573A", children: "\u6682\u65E0\u9644\u8FD1\u5546\u573A" });
|
|
111
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u9644\u8FD1\u5546\u573A", children: data.malls.map((m) => /* @__PURE__ */ jsxs("div", { style: itemStyle, children: [
|
|
112
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [
|
|
113
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: m.name }),
|
|
114
|
+
/* @__PURE__ */ jsx(StatusPill, { tone: m.status.code === "open" ? "success" : "neutral", text: m.status.label })
|
|
115
|
+
] }),
|
|
116
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u5730\u5740", value: m.address }),
|
|
117
|
+
m.distanceKm !== void 0 && /* @__PURE__ */ jsx(ValueText, { label: "\u8DDD\u79BB", value: `${m.distanceKm.toFixed(1)} km` })
|
|
118
|
+
] }, m.mallId)) });
|
|
119
|
+
}
|
|
120
|
+
function CustomerServiceFaqCard(props) {
|
|
121
|
+
const { data } = props;
|
|
122
|
+
if (data.faqs.length === 0) {
|
|
123
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u5BA2\u670DFAQ", children: data.noResultsReason ?? "\u672A\u627E\u5230\u76F8\u5173\u5E38\u89C1\u95EE\u9898" });
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: "\u76F8\u5173\u5E38\u89C1\u95EE\u9898", children: data.faqs.map((f, i) => /* @__PURE__ */ jsxs("div", { style: itemStyle, children: [
|
|
126
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 13, fontWeight: 600 }, children: f.question }),
|
|
127
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 13, marginTop: 4 }, children: f.answer })
|
|
128
|
+
] }, i)) });
|
|
129
|
+
}
|
|
130
|
+
function HumanGuideListCard(props) {
|
|
131
|
+
const { data } = props;
|
|
132
|
+
return /* @__PURE__ */ jsx(CardFrame, { title: `${data.merchantName} \xB7 \u4EBA\u5DE5\u5BFC\u8D2D`, children: data.guides.length === 0 ? /* @__PURE__ */ jsx("div", { style: { fontSize: 13 }, children: "\u6682\u65E0\u5BFC\u8D2D\u5458\u4FE1\u606F" }) : data.guides.map((g) => /* @__PURE__ */ jsxs("div", { style: itemStyle, children: [
|
|
133
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [
|
|
134
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 600 }, children: g.name }),
|
|
135
|
+
/* @__PURE__ */ jsx(StatusPill, { tone: g.available ? "success" : "neutral", text: g.available ? "\u5728\u7EBF" : "\u79BB\u7EBF" })
|
|
136
|
+
] }),
|
|
137
|
+
g.title && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--tbox-text-secondary, #888)" }, children: g.title })
|
|
138
|
+
] }, g.guideId)) });
|
|
139
|
+
}
|
|
140
|
+
function LocationHandoffCard(props) {
|
|
141
|
+
const { data } = props;
|
|
142
|
+
return /* @__PURE__ */ jsxs(CardFrame, { title: `${data.merchantName} \xB7 \u4F4D\u7F6E`, children: [
|
|
143
|
+
/* @__PURE__ */ jsx(ValueText, { label: "\u4F4D\u7F6E", value: data.location.displayText }),
|
|
144
|
+
data.location.buildingName && /* @__PURE__ */ jsx(ValueText, { label: "\u697C\u680B", value: data.location.buildingName }),
|
|
145
|
+
data.location.floorName && /* @__PURE__ */ jsx(ValueText, { label: "\u697C\u5C42", value: data.location.floorName }),
|
|
146
|
+
data.location.unitName && /* @__PURE__ */ jsx(ValueText, { label: "\u94FA\u4F4D", value: data.location.unitName })
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/client/index.ts
|
|
151
|
+
var cards = {
|
|
152
|
+
"product-list": ProductListCard,
|
|
153
|
+
"product-detail": ProductDetailCard,
|
|
154
|
+
"merchant-list": MerchantListCard,
|
|
155
|
+
"merchant-detail": MerchantDetailCard,
|
|
156
|
+
"category-list": CategoryListCard,
|
|
157
|
+
"product-comparison": ProductComparisonCard,
|
|
158
|
+
"mall-directory": MallDirectoryCard,
|
|
159
|
+
"nearby-mall-list": NearbyMallListCard,
|
|
160
|
+
"customer-service-faq": CustomerServiceFaqCard,
|
|
161
|
+
"human-guide-list": HumanGuideListCard,
|
|
162
|
+
"location-handoff": LocationHandoffCard
|
|
163
|
+
};
|
|
164
|
+
var clientModule = {
|
|
165
|
+
cards,
|
|
166
|
+
register(ctx) {
|
|
167
|
+
ctx.cards.registerMap(cards);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
clientModule
|
|
173
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CardComponent } from '@tbox.cn/app-contracts';
|
|
2
|
+
import { ClientContext } from '@tbox.cn/app-sdk/client';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* module-shopping-guide 客户端入口(与服务端 serverModule 对称)。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare const clientModule: {
|
|
9
|
+
cards: {
|
|
10
|
+
readonly 'product-list': CardComponent;
|
|
11
|
+
readonly 'product-detail': CardComponent;
|
|
12
|
+
readonly 'merchant-list': CardComponent;
|
|
13
|
+
readonly 'merchant-detail': CardComponent;
|
|
14
|
+
readonly 'category-list': CardComponent;
|
|
15
|
+
readonly 'product-comparison': CardComponent;
|
|
16
|
+
readonly 'mall-directory': CardComponent;
|
|
17
|
+
readonly 'nearby-mall-list': CardComponent;
|
|
18
|
+
readonly 'customer-service-faq': CardComponent;
|
|
19
|
+
readonly 'human-guide-list': CardComponent;
|
|
20
|
+
readonly 'location-handoff': CardComponent;
|
|
21
|
+
};
|
|
22
|
+
register(ctx: ClientContext): void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { clientModule };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SHOPPING_GUIDE_PROVIDER_TEMPLATE_ID, ShoppingGuideToolIds, ShoppingGuideTools, computeJoyCityCSign, createShoppingGuideTools, joycityCSignedAuthStrategy, resolveShoppingGuidePorts, serverModule, shoppingGuideCards } from './server/index.js';
|
|
2
|
+
export { clientModule } from './client/index.js';
|
|
3
|
+
import '@mastra/core/tools';
|
|
4
|
+
import '@tbox.cn/app-sdk/server';
|
|
5
|
+
import '@tbox.cn/app-contracts';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import '@tbox.cn/app-contracts-mall';
|
|
8
|
+
import '@tbox.cn/app-sdk/client';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SHOPPING_GUIDE_PROVIDER_TEMPLATE_ID,
|
|
3
|
+
computeJoyCityCSign,
|
|
4
|
+
createShoppingGuideTools,
|
|
5
|
+
joycityCSignedAuthStrategy,
|
|
6
|
+
resolveShoppingGuidePorts,
|
|
7
|
+
serverModule,
|
|
8
|
+
shoppingGuideCards
|
|
9
|
+
} from "./chunk-AGBLC6XI.js";
|
|
10
|
+
import {
|
|
11
|
+
clientModule
|
|
12
|
+
} from "./chunk-U4WDS5PQ.js";
|
|
13
|
+
export {
|
|
14
|
+
SHOPPING_GUIDE_PROVIDER_TEMPLATE_ID,
|
|
15
|
+
clientModule,
|
|
16
|
+
computeJoyCityCSign,
|
|
17
|
+
createShoppingGuideTools,
|
|
18
|
+
joycityCSignedAuthStrategy,
|
|
19
|
+
resolveShoppingGuidePorts,
|
|
20
|
+
serverModule,
|
|
21
|
+
shoppingGuideCards
|
|
22
|
+
};
|