@tbox.cn/app-module-parking 0.9.3 → 0.10.0
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/dist/{chunk-QHLX6WXM.js → chunk-O4W4A6TQ.js} +30 -1
- package/dist/{chunk-KEUD5YHH.js → chunk-QSHINO4B.js} +22 -36
- package/dist/client/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{parking-2S2UPCOF.css → parking-BC2TJ5GU.css} +10 -10
- package/dist/server/index.js +1 -1
- package/package.json +4 -4
- package/src/client/cards/parking-payment/index.tsx +0 -7
- package/src/client/styles/parking.css +10 -10
- package/src/server/handler.ts +21 -3
- package/src/server/index.ts +24 -2
- package/tbox.module.json +2 -0
- package/tests/cards-render.test.tsx +3 -1
- package/tests/dispatcher-flow.test.ts +1 -1
- package/tests/payment-flow.test.ts +1 -1
- package/tests/ports-resolve.test.ts +1 -1
- package/tests/snapshot-service.test.ts +87 -0
- package/tests/tools-gate.test.ts +2 -2
- package/tests/tools-membership.test.ts +1 -1
- package/dist/parking-guide-hero-pea-v2-X2O44LPQ.jpg +0 -0
- package/src/client/assets/parking-guide-hero-pea-v2.jpg +0 -0
- package/src/client/assets/parking-guide-hero.jpg +0 -0
- package/src/client/assets.d.ts +0 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/server/index.ts
|
|
2
2
|
import { definePreTool, loadModuleSkills } from "@tbox.cn/app-sdk/server";
|
|
3
|
+
import { PARKING_SNAPSHOT_SERVICE } from "@tbox.cn/app-contracts-mall";
|
|
3
4
|
|
|
4
5
|
// src/server/ports.ts
|
|
5
6
|
import {
|
|
@@ -2550,15 +2551,31 @@ function toIntentQueryContext(reqCtx) {
|
|
|
2550
2551
|
}
|
|
2551
2552
|
|
|
2552
2553
|
// src/server/handler.ts
|
|
2554
|
+
var PARKING_PAY_PHRASES = [
|
|
2555
|
+
"\u505C\u8F66\u7F34\u8D39",
|
|
2556
|
+
"\u7F34\u505C\u8F66\u8D39",
|
|
2557
|
+
"\u4EA4\u505C\u8F66\u8D39",
|
|
2558
|
+
"\u5E2E\u6211\u4EA4\u505C\u8F66\u8D39",
|
|
2559
|
+
"\u5E2E\u6211\u7F34\u505C\u8F66\u8D39",
|
|
2560
|
+
"\u5E2E\u6211\u67E5\u4E00\u4E0B\u505C\u8F66\u7F34\u8D39",
|
|
2561
|
+
"\u67E5\u505C\u8F66\u7F34\u8D39",
|
|
2562
|
+
"\u67E5\u8BE2\u505C\u8F66\u7F34\u8D39",
|
|
2563
|
+
"\u505C\u8F66\u7F34\u8D39\u591A\u5C11",
|
|
2564
|
+
"\u505C\u8F66\u8D39\u591A\u5C11\u94B1"
|
|
2565
|
+
];
|
|
2553
2566
|
function createParkingIntentHandler(ctx) {
|
|
2554
2567
|
return {
|
|
2555
2568
|
id: "parking",
|
|
2569
|
+
intents: [{ patterns: [...PARKING_PAY_PHRASES], match: "exact" }],
|
|
2556
2570
|
handle: async (action, payload, _ctx, reqCtx) => {
|
|
2557
2571
|
const c = toIntentQueryContext(reqCtx);
|
|
2558
2572
|
if (!c) return { cards: [], text: "\u505C\u8F66\u670D\u52A1\u4E0D\u53EF\u7528\uFF08\u7F3A\u5C11\u8FD0\u884C\u4E0A\u4E0B\u6587\uFF09" };
|
|
2559
2573
|
const service = await resolveParkingQueryPort(c.reqCtx, ctx);
|
|
2560
2574
|
switch (action) {
|
|
2561
|
-
|
|
2575
|
+
// intent(collectIntentRoutes 恒置 action:'intent')与 query-fee(显式路由兼容态)
|
|
2576
|
+
// 同实现:防御性门禁保住「模块内属人路径全拦」不变式,出 parking-payment 报价卡。
|
|
2577
|
+
case "query-fee":
|
|
2578
|
+
case "intent": {
|
|
2562
2579
|
const gate = await parkingMembershipGate(ctx, c.reqCtx, c.q, service);
|
|
2563
2580
|
if (gate) return { cards: gate.card ? [gate.card] : [], text: gate.notice };
|
|
2564
2581
|
const quotes = await service.queryFee(c.q, { plateNo: payload?.plateNo });
|
|
@@ -2642,6 +2659,18 @@ var serverModule = {
|
|
|
2642
2659
|
register(ctx) {
|
|
2643
2660
|
serverCtx = ctx;
|
|
2644
2661
|
ctx.services.register("parking", inMemoryParking);
|
|
2662
|
+
ctx.services.register(
|
|
2663
|
+
PARKING_SNAPSHOT_SERVICE,
|
|
2664
|
+
async (reqCtx) => {
|
|
2665
|
+
const service = await resolveParkingQueryPort(reqCtx, ctx);
|
|
2666
|
+
return {
|
|
2667
|
+
listVehicles: (q) => service.listVehicles(q),
|
|
2668
|
+
...service.probeParkedVehicles ? {
|
|
2669
|
+
probeParkedVehicles: (q, plateNos) => service.probeParkedVehicles(q, plateNos)
|
|
2670
|
+
} : {}
|
|
2671
|
+
};
|
|
2672
|
+
}
|
|
2673
|
+
);
|
|
2645
2674
|
for (const tool of Object.values(tools)) {
|
|
2646
2675
|
ctx.tools.register(tool);
|
|
2647
2676
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
// src/client/index.ts
|
|
2
|
-
import "./parking-
|
|
2
|
+
import "./parking-BC2TJ5GU.css";
|
|
3
3
|
|
|
4
4
|
// src/client/cards/parking-payment/index.tsx
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
6
6
|
import { Car, Check, CheckCircle, Clock, CurrencyCircleDollar, ShieldCheck, Sparkle } from "@phosphor-icons/react";
|
|
7
7
|
import { callCapability, markSelfRendering, sendCardAction } from "@tbox.cn/app-sdk/client";
|
|
8
8
|
|
|
9
|
-
// src/client/assets/parking-guide-hero-pea-v2.jpg
|
|
10
|
-
var parking_guide_hero_pea_v2_default = "./parking-guide-hero-pea-v2-X2O44LPQ.jpg";
|
|
11
|
-
|
|
12
9
|
// src/client/cards/parking-payment/benefit-selection.ts
|
|
13
10
|
function conflicts(a, b) {
|
|
14
11
|
const aBlocksB = !!(b.kind && a.exclusiveWithKinds?.includes(b.kind));
|
|
@@ -163,40 +160,29 @@ function ParkingPaymentCard(props) {
|
|
|
163
160
|
data.durationText ? `\u5DF2\u505C ${data.durationText}` : void 0
|
|
164
161
|
].filter(Boolean).join(" \xB7 ");
|
|
165
162
|
return /* @__PURE__ */ jsxs("section", { className: "parking-payment", children: [
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
"
|
|
163
|
+
/* @__PURE__ */ jsx("header", { className: "parking-payment__hero", children: /* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-content", children: [
|
|
164
|
+
/* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-eyebrow", children: [
|
|
165
|
+
/* @__PURE__ */ jsx("span", { children: "\u5546\u573A\u505C\u8F66\u670D\u52A1" }),
|
|
166
|
+
isHistory && /* @__PURE__ */ jsx("span", { className: "parking-payment__status", children: "\u5386\u53F2\u62A5\u4EF7" })
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-main", children: [
|
|
169
|
+
/* @__PURE__ */ jsx("strong", { children: data.plateNo }),
|
|
170
|
+
/* @__PURE__ */ jsx("span", { children: parkingMeta || "\u505C\u8F66\u8D39\u7528\u4EE5\u5546\u573A\u7CFB\u7EDF\u5B9E\u65F6\u7ED3\u679C\u4E3A\u51C6" })
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ jsx("div", { className: "parking-payment__hero-actions", children: /* @__PURE__ */ jsxs(
|
|
173
|
+
"button",
|
|
169
174
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"
|
|
175
|
+
type: "button",
|
|
176
|
+
className: "parking-payment__hero-action",
|
|
177
|
+
disabled: isHistory,
|
|
178
|
+
onClick: () => sendCardAction(cardId, { type: "sendMessage", value: VEHICLE_MANAGE_QUERY }),
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ jsx(Car, { size: 16, weight: "fill" }),
|
|
181
|
+
"\u8F66\u8F86\u7BA1\u7406"
|
|
182
|
+
]
|
|
174
183
|
}
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
/* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-eyebrow", children: [
|
|
178
|
-
/* @__PURE__ */ jsx("span", { children: "\u5546\u573A\u505C\u8F66\u670D\u52A1" }),
|
|
179
|
-
isHistory && /* @__PURE__ */ jsx("span", { className: "parking-payment__status", children: "\u5386\u53F2\u62A5\u4EF7" })
|
|
180
|
-
] }),
|
|
181
|
-
/* @__PURE__ */ jsxs("div", { className: "parking-payment__hero-main", children: [
|
|
182
|
-
/* @__PURE__ */ jsx("strong", { children: data.plateNo }),
|
|
183
|
-
/* @__PURE__ */ jsx("span", { children: parkingMeta || "\u505C\u8F66\u8D39\u7528\u4EE5\u5546\u573A\u7CFB\u7EDF\u5B9E\u65F6\u7ED3\u679C\u4E3A\u51C6" })
|
|
184
|
-
] }),
|
|
185
|
-
/* @__PURE__ */ jsx("div", { className: "parking-payment__hero-actions", children: /* @__PURE__ */ jsxs(
|
|
186
|
-
"button",
|
|
187
|
-
{
|
|
188
|
-
type: "button",
|
|
189
|
-
className: "parking-payment__hero-action",
|
|
190
|
-
disabled: isHistory,
|
|
191
|
-
onClick: () => sendCardAction(cardId, { type: "sendMessage", value: VEHICLE_MANAGE_QUERY }),
|
|
192
|
-
children: [
|
|
193
|
-
/* @__PURE__ */ jsx(Car, { size: 16, weight: "fill" }),
|
|
194
|
-
"\u8F66\u8F86\u7BA1\u7406"
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
) })
|
|
198
|
-
] })
|
|
199
|
-
] }),
|
|
184
|
+
) })
|
|
185
|
+
] }) }),
|
|
200
186
|
/* @__PURE__ */ jsxs("div", { className: "parking-payment__summary", children: [
|
|
201
187
|
/* @__PURE__ */ jsxs("div", { className: "parking-payment__summary-item", children: [
|
|
202
188
|
/* @__PURE__ */ jsx("small", { children: "\u5DF2\u505C\u65F6\u957F" }),
|
package/dist/client/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
resolveParkingQueryPort,
|
|
7
7
|
resolveParkingVehiclePort,
|
|
8
8
|
serverModule
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-O4W4A6TQ.js";
|
|
10
10
|
import {
|
|
11
11
|
cards,
|
|
12
12
|
clientModule
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QSHINO4B.js";
|
|
14
14
|
export {
|
|
15
15
|
InMemoryParkingService,
|
|
16
16
|
clientModule,
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
.parking-records,
|
|
9
9
|
.parking-vm,
|
|
10
10
|
.parking-info {
|
|
11
|
-
--parking-primary: #2368ec;
|
|
11
|
+
--parking-primary: var(--tbox-domain-parking-accent, #2368ec);
|
|
12
12
|
--parking-primary-deep: #2368ec;
|
|
13
|
-
--parking-primary-light: #f2f7ff;
|
|
13
|
+
--parking-primary-light: var(--tbox-domain-parking-surface, #f2f7ff);
|
|
14
14
|
--parking-primary-border: rgba(35, 104, 236, 0.24);
|
|
15
15
|
--parking-primary-ring: rgba(35, 104, 236, 0.12);
|
|
16
16
|
--parking-navy: #062a65;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
--parking-text: var(--tbox-text-primary, #182235);
|
|
24
24
|
--parking-text-2: var(--tbox-text-secondary, #6f7c8f);
|
|
25
25
|
--parking-text-3: var(--tbox-text-muted, #9aa4b4);
|
|
26
|
-
--parking-border: var(--tbox-border, #dfe6f1);
|
|
26
|
+
--parking-border: var(--tbox-domain-parking-border, var(--tbox-border, #dfe6f1));
|
|
27
27
|
--parking-bg-subtle: var(--tbox-bg-subtle, #f7f9fc);
|
|
28
28
|
box-sizing: border-box;
|
|
29
29
|
width: 100%;
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
position: relative;
|
|
119
119
|
height: 332px;
|
|
120
120
|
overflow: hidden;
|
|
121
|
-
background: #f9f0df;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
background-color: #f9f0df;
|
|
122
|
+
/* 素材变量链(主题品牌资产轨 A1 级联修复):装饰主视觉走 CSS background;
|
|
123
|
+
元素只消费不声明——声明形态会截断 html[data-theme] 祖先覆写的继承(主题覆写失效)。
|
|
124
|
+
兜底 = 中立渐变(零品牌资产——B2;品牌 IP 由主题包承载),主题包经 html[data-theme] 段覆写 --tbox-asset-parking-hero。 */
|
|
125
|
+
background-image: var(--tbox-asset-parking-hero, linear-gradient(135deg, #f2f7ff, #e7ebf3));
|
|
126
|
+
background-size: cover;
|
|
127
|
+
background-position: center;
|
|
128
128
|
}
|
|
129
129
|
.parking-payment__hero-content {
|
|
130
130
|
position: absolute;
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-parking",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "商圈停车模块:计费支付、车辆寻车、缴费记录与开票(codegen 源)。",
|
|
6
6
|
"exports": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tbox.cn/app-sdk": "0.
|
|
22
|
-
"@tbox.cn/app-contracts": "0.
|
|
23
|
-
"@tbox.cn/app-contracts-mall": "0.
|
|
21
|
+
"@tbox.cn/app-sdk": "0.20.0",
|
|
22
|
+
"@tbox.cn/app-contracts": "0.11.0",
|
|
23
|
+
"@tbox.cn/app-contracts-mall": "0.11.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"zod": "3.25.76",
|
|
@@ -8,7 +8,6 @@ import { useEffect, useState } from 'react';
|
|
|
8
8
|
import { Car, Check, CheckCircle, Clock, CurrencyCircleDollar, ShieldCheck, Sparkle } from '@phosphor-icons/react';
|
|
9
9
|
import { callCapability, markSelfRendering, sendCardAction } from '@tbox.cn/app-sdk/client';
|
|
10
10
|
import type { ParkingPaymentCardData } from '@tbox.cn/app-contracts-mall';
|
|
11
|
-
import parkingHeroUrl from '../../assets/parking-guide-hero-pea-v2.jpg';
|
|
12
11
|
|
|
13
12
|
/** 重算超时兜底(ms):避免重算失败时勾选被永久锁死 */
|
|
14
13
|
/** 唤起车辆管理卡片的自然语言 query——与首页「车辆绑定」入口同句,走同一条分发链。 */
|
|
@@ -230,12 +229,6 @@ export function ParkingPaymentCard(props: {
|
|
|
230
229
|
return (
|
|
231
230
|
<section className="parking-payment">
|
|
232
231
|
<header className="parking-payment__hero">
|
|
233
|
-
<img
|
|
234
|
-
className="parking-payment__hero-image"
|
|
235
|
-
src={parkingHeroUrl}
|
|
236
|
-
alt=""
|
|
237
|
-
aria-hidden="true"
|
|
238
|
-
/>
|
|
239
232
|
<div className="parking-payment__hero-content">
|
|
240
233
|
<div className="parking-payment__hero-eyebrow">
|
|
241
234
|
<span>商场停车服务</span>
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
.parking-records,
|
|
9
9
|
.parking-vm,
|
|
10
10
|
.parking-info {
|
|
11
|
-
--parking-primary: #2368ec;
|
|
11
|
+
--parking-primary: var(--tbox-domain-parking-accent, #2368ec);
|
|
12
12
|
--parking-primary-deep: #2368ec;
|
|
13
|
-
--parking-primary-light: #f2f7ff;
|
|
13
|
+
--parking-primary-light: var(--tbox-domain-parking-surface, #f2f7ff);
|
|
14
14
|
--parking-primary-border: rgba(35, 104, 236, 0.24);
|
|
15
15
|
--parking-primary-ring: rgba(35, 104, 236, 0.12);
|
|
16
16
|
--parking-navy: #062a65;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
--parking-text: var(--tbox-text-primary, #182235);
|
|
24
24
|
--parking-text-2: var(--tbox-text-secondary, #6f7c8f);
|
|
25
25
|
--parking-text-3: var(--tbox-text-muted, #9aa4b4);
|
|
26
|
-
--parking-border: var(--tbox-border, #dfe6f1);
|
|
26
|
+
--parking-border: var(--tbox-domain-parking-border, var(--tbox-border, #dfe6f1));
|
|
27
27
|
--parking-bg-subtle: var(--tbox-bg-subtle, #f7f9fc);
|
|
28
28
|
box-sizing: border-box;
|
|
29
29
|
width: 100%;
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
position: relative;
|
|
119
119
|
height: 332px;
|
|
120
120
|
overflow: hidden;
|
|
121
|
-
background: #f9f0df;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
background-color: #f9f0df;
|
|
122
|
+
/* 素材变量链(主题品牌资产轨 A1 级联修复):装饰主视觉走 CSS background;
|
|
123
|
+
元素只消费不声明——声明形态会截断 html[data-theme] 祖先覆写的继承(主题覆写失效)。
|
|
124
|
+
兜底 = 中立渐变(零品牌资产——B2;品牌 IP 由主题包承载),主题包经 html[data-theme] 段覆写 --tbox-asset-parking-hero。 */
|
|
125
|
+
background-image: var(--tbox-asset-parking-hero, linear-gradient(135deg, #f2f7ff, #e7ebf3));
|
|
126
|
+
background-size: cover;
|
|
127
|
+
background-position: center;
|
|
128
128
|
}
|
|
129
129
|
.parking-payment__hero-content {
|
|
130
130
|
position: absolute;
|
package/src/server/handler.ts
CHANGED
|
@@ -8,18 +8,36 @@ import { toIntentQueryContext } from './intent-context';
|
|
|
8
8
|
import { buildParkingPaymentFacts, parkingMembershipGate } from './tools';
|
|
9
9
|
import type { StoreLike } from './domain';
|
|
10
10
|
|
|
11
|
+
/** 停车缴费硬路由关键词(W3-3 自模板 intent-routes.ts 迁入——意图与处理器同处定义,011 D7):
|
|
12
|
+
* 整句全等命中(match:'exact',不入 BM25 词袋)绕过 LLM 工具选择;intent action 与
|
|
13
|
+
* 显式路由 query-fee 分支同实现出报价卡。queryFee 无车牌时走扫描绑定车队逻辑(不追问车牌)。 */
|
|
14
|
+
const PARKING_PAY_PHRASES = [
|
|
15
|
+
'停车缴费',
|
|
16
|
+
'缴停车费',
|
|
17
|
+
'交停车费',
|
|
18
|
+
'帮我交停车费',
|
|
19
|
+
'帮我缴停车费',
|
|
20
|
+
'帮我查一下停车缴费',
|
|
21
|
+
'查停车缴费',
|
|
22
|
+
'查询停车缴费',
|
|
23
|
+
'停车缴费多少',
|
|
24
|
+
'停车费多少钱',
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
11
27
|
export function createParkingIntentHandler(ctx: ServerContext): HandlerDefinition {
|
|
12
28
|
return {
|
|
13
29
|
id: 'parking',
|
|
30
|
+
intents: [{ patterns: [...PARKING_PAY_PHRASES], match: 'exact' }],
|
|
14
31
|
handle: async (action, payload, _ctx, reqCtx) => {
|
|
15
32
|
const c = toIntentQueryContext(reqCtx);
|
|
16
33
|
if (!c) return { cards: [], text: '停车服务不可用(缺少运行上下文)' };
|
|
17
34
|
const service = await resolveParkingQueryPort(c.reqCtx, ctx);
|
|
18
35
|
|
|
19
36
|
switch (action) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
// intent(collectIntentRoutes 恒置 action:'intent')与 query-fee(显式路由兼容态)
|
|
38
|
+
// 同实现:防御性门禁保住「模块内属人路径全拦」不变式,出 parking-payment 报价卡。
|
|
39
|
+
case 'query-fee':
|
|
40
|
+
case 'intent': {
|
|
23
41
|
const gate = await parkingMembershipGate(ctx, c.reqCtx as never, c.q, service);
|
|
24
42
|
if (gate) return { cards: gate.card ? [gate.card] : [], text: gate.notice };
|
|
25
43
|
const quotes = await service.queryFee(c.q, { plateNo: (payload as { plateNo?: string })?.plateNo });
|
package/src/server/index.ts
CHANGED
|
@@ -4,9 +4,11 @@ import type {
|
|
|
4
4
|
TypedBus,
|
|
5
5
|
PreToolDef,
|
|
6
6
|
} from '@tbox.cn/app-sdk/server';
|
|
7
|
+
import type { RequestContext } from '@tbox.cn/app-contracts';
|
|
7
8
|
import { definePreTool, loadModuleSkills } from '@tbox.cn/app-sdk/server';
|
|
8
|
-
import type { MallEventMap } from '@tbox.cn/app-contracts-mall';
|
|
9
|
-
import {
|
|
9
|
+
import type { MallEventMap, ParkingQueryContext, ParkingSnapshotPort } from '@tbox.cn/app-contracts-mall';
|
|
10
|
+
import { PARKING_SNAPSHOT_SERVICE } from '@tbox.cn/app-contracts-mall';
|
|
11
|
+
import { inMemoryParking, resolveParkingQueryPort } from './ports';
|
|
10
12
|
import parkingPaymentMeta from './cards/parking-payment/meta';
|
|
11
13
|
import parkingPaymentResultMeta from './cards/parking-payment-result/meta';
|
|
12
14
|
import parkingPaymentRecordsMeta from './cards/parking-payment-records/meta';
|
|
@@ -95,6 +97,26 @@ export const serverModule = {
|
|
|
95
97
|
serverCtx = ctx;
|
|
96
98
|
// InMemory 单例恒注册(跨模块消费方 resolveService 兼容;真实供给经三槽 resolver(query/payment/vehicle)槽位轴)
|
|
97
99
|
ctx.services.register('parking', inMemoryParking);
|
|
100
|
+
|
|
101
|
+
// 停车快览工厂(parking.snapshot,W3-3):首页联单面板跨模块消费面
|
|
102
|
+
// (绑定车辆列表 + 在场探测)。query 槽 Pick 子集——可选能力口(probeParkedVehicles)
|
|
103
|
+
// 缺席性透传;工厂运行期执行(注册期纯净铁律)。
|
|
104
|
+
ctx.services.register(
|
|
105
|
+
PARKING_SNAPSHOT_SERVICE,
|
|
106
|
+
async (reqCtx: RequestContext): Promise<ParkingSnapshotPort> => {
|
|
107
|
+
const service = await resolveParkingQueryPort(reqCtx, ctx);
|
|
108
|
+
return {
|
|
109
|
+
listVehicles: (q: ParkingQueryContext) => service.listVehicles(q),
|
|
110
|
+
...(service.probeParkedVehicles
|
|
111
|
+
? {
|
|
112
|
+
probeParkedVehicles: (q: ParkingQueryContext, plateNos: readonly string[]) =>
|
|
113
|
+
service.probeParkedVehicles!(q, plateNos),
|
|
114
|
+
}
|
|
115
|
+
: {}),
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
|
|
98
120
|
for (const tool of Object.values(tools)) {
|
|
99
121
|
ctx.tools.register(tool);
|
|
100
122
|
}
|
package/tbox.module.json
CHANGED
|
@@ -74,7 +74,9 @@ describe('ParkingPaymentCard(范式卡)', () => {
|
|
|
74
74
|
}}
|
|
75
75
|
/>,
|
|
76
76
|
);
|
|
77
|
-
|
|
77
|
+
// 素材变量链(主题轨 T-2.3):装饰主视觉 img → CSS background(--tbox-asset-parking-hero),容器保留、img 不再渲染
|
|
78
|
+
expect(host.querySelector('.parking-payment__hero')).not.toBeNull();
|
|
79
|
+
expect(host.querySelector('.parking-payment__hero-image')).toBeNull();
|
|
78
80
|
expect(host.querySelector('.parking-payment__hero-main')?.textContent).toContain('浙A12345');
|
|
79
81
|
expect(host.querySelector('.parking-payment__summary')?.textContent).toContain('2 小时 15 分');
|
|
80
82
|
expect(host.querySelector('.parking-payment__billing')?.textContent).toContain('¥13.50');
|
|
@@ -31,7 +31,7 @@ const SECRET = new TextEncoder().encode('test-secret-0123456789-0123456789-01234
|
|
|
31
31
|
|
|
32
32
|
const makeReqCtx = (mallId = 'mall-1') =>
|
|
33
33
|
({
|
|
34
|
-
identity: { userId: 'u_1', source: '
|
|
34
|
+
identity: { userId: 'u_1', source: 'local' },
|
|
35
35
|
conversationId: 'conv_it',
|
|
36
36
|
attributes: { mall: { miniAppId: 'app', mallId } },
|
|
37
37
|
}) as never;
|
|
@@ -330,7 +330,7 @@ describe('P1:confirm-payment 签名空串防御', () => {
|
|
|
330
330
|
/** 动作上下文(execute 第二参——分发期注入语义,与 SDK 集成测试同基准) */
|
|
331
331
|
const makeReqCtx = () =>
|
|
332
332
|
({
|
|
333
|
-
identity: { userId: 'u_1', source: '
|
|
333
|
+
identity: { userId: 'u_1', source: 'local' },
|
|
334
334
|
attributes: { mall: { miniAppId: 'app', mallId: 'mall-1' } },
|
|
335
335
|
}) as never;
|
|
336
336
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parking.snapshot 快览服务 + intents 声明回归(W3-3 单一模板统一化):
|
|
3
|
+
* - intents 归位锁:模板显式路由迁 handler 声明后,collectIntentRoutes 汇集面
|
|
4
|
+
* (关键词族 / exact 确定性档 / action 恒 'intent')不漂移;
|
|
5
|
+
* - 快览工厂锁:query 槽 Pick 子集透传 + probeParkedVehicles 可选能力口缺席性保留。
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
8
|
+
|
|
9
|
+
vi.mock('../src/server/ports', async (importOriginal) => {
|
|
10
|
+
const actual = await importOriginal<typeof import('../src/server/ports')>();
|
|
11
|
+
return { ...actual, resolveParkingQueryPort: vi.fn() };
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
import type { RequestContext } from '@tbox.cn/app-contracts';
|
|
15
|
+
import type { ParkingSnapshotPort } from '@tbox.cn/app-contracts-mall';
|
|
16
|
+
import { PARKING_SNAPSHOT_SERVICE } from '@tbox.cn/app-contracts-mall';
|
|
17
|
+
import { createServerContext } from '@tbox.cn/app-sdk/server';
|
|
18
|
+
import { serverModule } from '../src/server/index';
|
|
19
|
+
import { createParkingIntentHandler } from '../src/server/handler';
|
|
20
|
+
import { resolveParkingQueryPort } from '../src/server/ports';
|
|
21
|
+
|
|
22
|
+
/** 模板 intent-routes.ts 迁入的停车缴费硬路由关键词族(迁移即冻结——漂移即断言失败) */
|
|
23
|
+
const PARKING_PAY_PHRASES = [
|
|
24
|
+
'停车缴费',
|
|
25
|
+
'缴停车费',
|
|
26
|
+
'交停车费',
|
|
27
|
+
'帮我交停车费',
|
|
28
|
+
'帮我缴停车费',
|
|
29
|
+
'帮我查一下停车缴费',
|
|
30
|
+
'查停车缴费',
|
|
31
|
+
'查询停车缴费',
|
|
32
|
+
'停车缴费多少',
|
|
33
|
+
'停车费多少钱',
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
36
|
+
const makeReqCtx = () =>
|
|
37
|
+
({
|
|
38
|
+
identity: { userId: 'u_1', source: 'local' },
|
|
39
|
+
conversationId: 'conv_snapshot',
|
|
40
|
+
attributes: { mall: { miniAppId: 'app', mallId: 'mall-1' } },
|
|
41
|
+
}) as unknown as RequestContext;
|
|
42
|
+
|
|
43
|
+
describe('parking handler intents 声明(W3-3 自模板迁入)', () => {
|
|
44
|
+
it('声明面:10 关键词 / exact 确定性档(collectIntentRoutes 装配端汇集 action 恒 intent)', () => {
|
|
45
|
+
const ctx = createServerContext();
|
|
46
|
+
const def = createParkingIntentHandler(ctx);
|
|
47
|
+
expect(def.intents).toEqual([{ patterns: [...PARKING_PAY_PHRASES], match: 'exact' }]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('parking.snapshot 快览工厂(register 注册,运行期解析)', () => {
|
|
52
|
+
it('register 注册工厂;query 槽 listVehicles 透传', async () => {
|
|
53
|
+
const ctx = createServerContext();
|
|
54
|
+
serverModule.register(ctx);
|
|
55
|
+
const factory = ctx.resolveService<(reqCtx: RequestContext) => Promise<ParkingSnapshotPort>>(
|
|
56
|
+
PARKING_SNAPSHOT_SERVICE,
|
|
57
|
+
);
|
|
58
|
+
expect(factory).toBeTypeOf('function');
|
|
59
|
+
|
|
60
|
+
const listVehicles = vi.fn(async () => ({ bound: [] }));
|
|
61
|
+
vi.mocked(resolveParkingQueryPort).mockResolvedValue({ listVehicles } as never);
|
|
62
|
+
|
|
63
|
+
const port = await factory!(makeReqCtx());
|
|
64
|
+
expect('probeParkedVehicles' in port).toBe(false); // 可选能力口缺席性透传
|
|
65
|
+
await port.listVehicles({} as never);
|
|
66
|
+
expect(listVehicles).toHaveBeenCalledOnce();
|
|
67
|
+
expect(resolveParkingQueryPort).toHaveBeenCalledWith(makeReqCtx(), ctx);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('provider 有入场探测能力口 → probeParkedVehicles 透传', async () => {
|
|
71
|
+
const ctx = createServerContext();
|
|
72
|
+
serverModule.register(ctx);
|
|
73
|
+
const factory = ctx.resolveService<(reqCtx: RequestContext) => Promise<ParkingSnapshotPort>>(
|
|
74
|
+
PARKING_SNAPSHOT_SERVICE,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const probeParkedVehicles = vi.fn(async () => []);
|
|
78
|
+
vi.mocked(resolveParkingQueryPort).mockResolvedValue({
|
|
79
|
+
listVehicles: vi.fn(async () => ({ bound: [] })),
|
|
80
|
+
probeParkedVehicles,
|
|
81
|
+
} as never);
|
|
82
|
+
|
|
83
|
+
const port = await factory!(makeReqCtx());
|
|
84
|
+
await port.probeParkedVehicles!({} as never, ['浙A12345']);
|
|
85
|
+
expect(probeParkedVehicles).toHaveBeenCalledOnce();
|
|
86
|
+
});
|
|
87
|
+
});
|
package/tests/tools-gate.test.ts
CHANGED
|
@@ -16,12 +16,12 @@ import { InMemoryParkingService } from '../src/server/service';
|
|
|
16
16
|
import { resolveParkingQueryPort, resolveParkingPaymentPort, resolveParkingVehiclePort } from '../src/server/ports';
|
|
17
17
|
import { createServerContext, createToolExecContext } from '@tbox.cn/app-sdk/server';
|
|
18
18
|
|
|
19
|
-
const reqCtx = (source: '
|
|
19
|
+
const reqCtx = (source: 'local' | 'anonymous' = 'local', userId = 'u_1') => ({
|
|
20
20
|
identity: { userId, source },
|
|
21
21
|
attributes: { mall: { miniAppId: 'app', mallId: 'mall-1' } },
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
const execCtx = (source: '
|
|
24
|
+
const execCtx = (source: 'local' | 'anonymous' = 'local') => createToolExecContext(reqCtx(source)) as never;
|
|
25
25
|
|
|
26
26
|
/** 声明 requiresMembership 能力口的 provider 壳(真实厂商语义:未登录未入会 → true) */
|
|
27
27
|
function gatedService(requires: boolean) {
|
|
@@ -7,7 +7,7 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
7
7
|
import { projectMembership } from '../src/server/tools';
|
|
8
8
|
|
|
9
9
|
const reqCtx = {
|
|
10
|
-
identity: { userId: 'u_1', source: '
|
|
10
|
+
identity: { userId: 'u_1', source: 'local' as const },
|
|
11
11
|
attributes: { mall: { miniAppId: 'app', mallId: 'mall-1' } },
|
|
12
12
|
} as never;
|
|
13
13
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|