@tbox.cn/app-module-promotion 0.10.0 → 0.10.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/AGENTS.md +1 -1
- package/dist/{chunk-QOTX4XDS.js → chunk-AI3K2MST.js} +4 -4
- package/dist/{chunk-S7CVFCML.js → chunk-DP2XDOBN.js} +6 -6
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/server/index.d.ts +10 -4
- package/dist/server/index.js +1 -1
- package/package.json +6 -5
- package/src/client/cards/promotion-activity-category-list/index.tsx +1 -1
- package/src/client/cards/promotion-activity-detail/index.tsx +1 -1
- package/src/client/cards/promotion-activity-list/index.tsx +1 -1
- package/src/client/cards/promotion-entitlement-list/index.tsx +1 -1
- package/src/client/cards/promotion-offer-detail/index.tsx +1 -1
- package/src/client/cards/promotion-offer-list/index.tsx +1 -1
- package/src/client/index.ts +1 -1
- package/src/server/actions.ts +1 -1
- package/src/server/handler.ts +3 -3
- package/src/server/index.ts +2 -2
- package/src/server/ports.ts +1 -1
- package/src/server/tools.ts +3 -3
- package/tbox.module.json +26 -12
- package/tests/cards-render.test.tsx +3 -3
- package/tests/ports-resolve.test.ts +2 -2
- package/tests/pretool-coupons.test.ts +1 -1
- package/tests/promotion.test.ts +2 -2
- package/tests/samples.test.ts +1 -1
- package/tsup.config.ts +2 -1
package/AGENTS.md
CHANGED
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
|
|
13
13
|
## 真实厂商接入
|
|
14
14
|
|
|
15
|
-
官方 provider 包形态(manifest 槽声明 + 独立包发布)参照 `modules/provider-mock`
|
|
15
|
+
官方 provider 包形态(manifest 槽声明 + 独立包发布)参照 `modules/provider-mock`(极简形态)/ `modules/provider-mocktest`(带 configSchema 形态)结构样例与
|
|
16
16
|
docs/reference/providers.md;厂商中立措辞纪律见该参考(本文件受 vendor-neutrality 门禁扫描)。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/server/index.ts
|
|
2
|
-
import { definePreTool, getRequestContext, loadModuleSkills } from "@tbox.cn/app-sdk
|
|
2
|
+
import { definePreTool, getRequestContext, loadModuleSkills } from "@tbox.cn/app-agent-sdk-server";
|
|
3
3
|
import { Router } from "express";
|
|
4
4
|
import { toMallQueryContext as toMallQueryContext4, withMallScopeFromQuery } from "@tbox.cn/app-contracts-mall";
|
|
5
5
|
|
|
@@ -513,8 +513,8 @@ var meta7 = {
|
|
|
513
513
|
var meta_default7 = meta7;
|
|
514
514
|
|
|
515
515
|
// src/server/tools.ts
|
|
516
|
-
import { createTool, coerceStringifiedFields, withCardEmissionHint } from "@tbox.cn/app-sdk
|
|
517
|
-
import { requireToolRequestContext } from "@tbox.cn/app-sdk
|
|
516
|
+
import { createTool, coerceStringifiedFields, withCardEmissionHint } from "@tbox.cn/app-agent-sdk-server";
|
|
517
|
+
import { requireToolRequestContext } from "@tbox.cn/app-agent-sdk-server";
|
|
518
518
|
import { resolveMemberGate, toMallQueryContext } from "@tbox.cn/app-contracts-mall";
|
|
519
519
|
import { z } from "zod";
|
|
520
520
|
|
|
@@ -1331,7 +1331,7 @@ function logText(value) {
|
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
1333
|
// src/server/handler.ts
|
|
1334
|
-
import { matchIntent } from "@tbox.cn/app-sdk
|
|
1334
|
+
import { matchIntent } from "@tbox.cn/app-agent-sdk-server";
|
|
1335
1335
|
import { resolveMemberGate as resolveMemberGate2, toMallQueryContext as toMallQueryContext3 } from "@tbox.cn/app-contracts-mall";
|
|
1336
1336
|
var PROMOTION_INTENTS = {
|
|
1337
1337
|
"list-entitlements": {
|
|
@@ -4,7 +4,7 @@ import "./promotion-6L7HLRC2.css";
|
|
|
4
4
|
// src/client/cards/promotion-offer-list/index.tsx
|
|
5
5
|
import { CalendarBlank, CalendarDots, CaretDown, Lightbulb, MapPin, Sparkle, Ticket } from "@phosphor-icons/react";
|
|
6
6
|
import { useEffect as useEffect2, useLayoutEffect, useRef as useRef2, useState as useState3 } from "react";
|
|
7
|
-
import { ItemActionsRow, markSelfRendering, navigateToAlipayPage, sendCardAction } from "@tbox.cn/app-sdk
|
|
7
|
+
import { ItemActionsRow, markSelfRendering, navigateToAlipayPage, sendCardAction } from "@tbox.cn/app-agent-sdk-client";
|
|
8
8
|
|
|
9
9
|
// src/client/components/CouponSheet.tsx
|
|
10
10
|
import { X } from "@phosphor-icons/react";
|
|
@@ -525,7 +525,7 @@ var promotion_offer_list_default = PromotionOfferListCard;
|
|
|
525
525
|
// src/client/cards/promotion-offer-detail/index.tsx
|
|
526
526
|
import { CalendarBlank as CalendarBlank2, CheckCircle, Clock, Gift, Info, ListChecks, MapPin as MapPin2, SealCheck, Ticket as Ticket2 } from "@phosphor-icons/react";
|
|
527
527
|
import { useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
528
|
-
import { markSelfRendering as markSelfRendering2, navigateToAlipayPage as navigateToAlipayPage2, sendCardAction as sendCardAction2 } from "@tbox.cn/app-sdk
|
|
528
|
+
import { markSelfRendering as markSelfRendering2, navigateToAlipayPage as navigateToAlipayPage2, sendCardAction as sendCardAction2 } from "@tbox.cn/app-agent-sdk-client";
|
|
529
529
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
530
530
|
var modeText = {
|
|
531
531
|
AUTOMATIC_DISCOUNT: "\u7ED3\u7B97\u65F6\u81EA\u52A8\u4F18\u60E0",
|
|
@@ -733,7 +733,7 @@ markSelfRendering2(PromotionOfferDetailCard);
|
|
|
733
733
|
// src/client/cards/promotion-entitlement-list/index.tsx
|
|
734
734
|
import { CalendarBlank as CalendarBlank3, CaretDown as CaretDown2, Copy, MapPinLine, NavigationArrow, ShieldCheck, Ticket as Ticket3 } from "@phosphor-icons/react";
|
|
735
735
|
import { useEffect as useEffect5, useLayoutEffect as useLayoutEffect2, useRef as useRef5, useState as useState6 } from "react";
|
|
736
|
-
import { callJsapi, httpGet } from "@tbox.cn/app-sdk
|
|
736
|
+
import { callJsapi, httpGet } from "@tbox.cn/app-agent-sdk-client";
|
|
737
737
|
|
|
738
738
|
// src/client/components/CouponQrCode.tsx
|
|
739
739
|
import QRCode from "qrcode";
|
|
@@ -978,7 +978,7 @@ var promotion_entitlement_list_default = PromotionEntitlementListCard;
|
|
|
978
978
|
|
|
979
979
|
// src/client/cards/promotion-activity-list/index.tsx
|
|
980
980
|
import { CalendarDots as CalendarDots2, Sparkle as Sparkle2, Ticket as Ticket4 } from "@phosphor-icons/react";
|
|
981
|
-
import { sendCardAction as sendCardAction3 } from "@tbox.cn/app-sdk
|
|
981
|
+
import { sendCardAction as sendCardAction3 } from "@tbox.cn/app-agent-sdk-client";
|
|
982
982
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
983
983
|
var statusText2 = { AVAILABLE: "\u53EF\u62A5\u540D", FULL: "\u5DF2\u6EE1", ENDED: "\u5DF2\u7ED3\u675F", UPCOMING: "\u5373\u5C06\u5F00\u59CB", UNKNOWN: "\u5F85\u786E\u8BA4" };
|
|
984
984
|
function PromotionActivityListCard(props) {
|
|
@@ -1046,7 +1046,7 @@ var promotion_activity_list_default = PromotionActivityListCard;
|
|
|
1046
1046
|
|
|
1047
1047
|
// src/client/cards/promotion-activity-detail/index.tsx
|
|
1048
1048
|
import { ArrowSquareOut, CalendarDots as CalendarDots3, CheckCircle as CheckCircle2, Clock as Clock2, Crown, ListChecks as ListChecks2, MapPin as MapPin3, Sparkle as Sparkle3, Users } from "@phosphor-icons/react";
|
|
1049
|
-
import { sendCardAction as sendCardAction4 } from "@tbox.cn/app-sdk
|
|
1049
|
+
import { sendCardAction as sendCardAction4 } from "@tbox.cn/app-agent-sdk-client";
|
|
1050
1050
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1051
1051
|
var sessionText = { OPEN: "\u53EF\u9009", FULL: "\u5DF2\u6EE1", CLOSED: "\u5DF2\u7ED3\u675F", UNKNOWN: "\u5F85\u786E\u8BA4" };
|
|
1052
1052
|
function PromotionActivityDetailCard({ data, cardId = "", isHistory = false }) {
|
|
@@ -1215,7 +1215,7 @@ var promotion_activity_detail_default = PromotionActivityDetailCard;
|
|
|
1215
1215
|
|
|
1216
1216
|
// src/client/cards/promotion-activity-category-list/index.tsx
|
|
1217
1217
|
import { GameController, Palette, Sparkle as Sparkle4, Storefront } from "@phosphor-icons/react";
|
|
1218
|
-
import { ItemActionsRow as ItemActionsRow2 } from "@tbox.cn/app-sdk
|
|
1218
|
+
import { ItemActionsRow as ItemActionsRow2 } from "@tbox.cn/app-agent-sdk-client";
|
|
1219
1219
|
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1220
1220
|
var icons = [GameController, Storefront, Palette, Sparkle4];
|
|
1221
1221
|
function PromotionActivityCategoryListCard(props) {
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { InMemoryPromotionService, inMemoryPromotion, promotionCards, resolvePromotionAcquisitionPort, resolvePromotionActivitiesPort, resolvePromotionEntitlementsPort, resolvePromotionOffersPort, serverModule } from './server/index.js';
|
|
2
2
|
export { clientModule, promotionClientCards } from './client/index.js';
|
|
3
|
+
import '@tbox.cn/app-agent-sdk-server';
|
|
3
4
|
import '@mastra/core/tools';
|
|
4
|
-
import '@tbox.cn/app-sdk
|
|
5
|
+
import '@tbox.cn/app-sdk-server';
|
|
5
6
|
import '@tbox.cn/app-contracts';
|
|
6
7
|
import 'zod';
|
|
7
8
|
import '@tbox.cn/app-contracts-mall';
|
|
8
|
-
import '@tbox.cn/app-sdk
|
|
9
|
+
import '@tbox.cn/app-agent-sdk-client';
|
package/dist/index.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
resolvePromotionEntitlementsPort,
|
|
8
8
|
resolvePromotionOffersPort,
|
|
9
9
|
serverModule
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AI3K2MST.js";
|
|
11
11
|
import {
|
|
12
12
|
cards,
|
|
13
13
|
clientModule
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DP2XDOBN.js";
|
|
15
15
|
export {
|
|
16
16
|
InMemoryPromotionService,
|
|
17
17
|
clientModule,
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as _tbox_cn_app_agent_sdk_server from '@tbox.cn/app-agent-sdk-server';
|
|
2
|
+
import { ServerContext, PreToolDef } from '@tbox.cn/app-agent-sdk-server';
|
|
1
3
|
import * as _mastra_core_tools from '@mastra/core/tools';
|
|
2
|
-
import * as _tbox_cn_app_sdk_server from '@tbox.cn/app-sdk
|
|
3
|
-
import { ServerContext, PreToolDef } from '@tbox.cn/app-sdk/server';
|
|
4
|
+
import * as _tbox_cn_app_sdk_server from '@tbox.cn/app-sdk-server';
|
|
4
5
|
import * as _tbox_cn_app_contracts from '@tbox.cn/app-contracts';
|
|
5
6
|
import { RequestContext } from '@tbox.cn/app-contracts';
|
|
6
7
|
import * as zod from 'zod';
|
|
@@ -2489,12 +2490,17 @@ declare const serverModule: {
|
|
|
2489
2490
|
[k: string]: _tbox_cn_app_sdk_server.LocalSkill;
|
|
2490
2491
|
};
|
|
2491
2492
|
preTools: {
|
|
2492
|
-
listCoupons: PreToolDef<
|
|
2493
|
+
listCoupons: PreToolDef<_tbox_cn_app_agent_sdk_server.Tool<{
|
|
2493
2494
|
mode: "CLAIMABLE" | "OWNED";
|
|
2494
2495
|
limit?: string | undefined;
|
|
2495
2496
|
keyword?: string | undefined;
|
|
2496
2497
|
cursor?: string | undefined;
|
|
2497
|
-
}, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "listCoupons", unknown
|
|
2498
|
+
}, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "listCoupons", unknown>, {
|
|
2499
|
+
mode: "CLAIMABLE" | "OWNED";
|
|
2500
|
+
limit?: string | undefined;
|
|
2501
|
+
keyword?: string | undefined;
|
|
2502
|
+
cursor?: string | undefined;
|
|
2503
|
+
}>;
|
|
2498
2504
|
};
|
|
2499
2505
|
register(ctx: ServerContext): void;
|
|
2500
2506
|
};
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-promotion",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "商圈营销模块:资格校验、推荐降级链、券卡(codegen 源)。",
|
|
6
6
|
"exports": {
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tbox.cn/app-contracts": "0.
|
|
22
|
-
"@tbox.cn/app-contracts-mall": "0.
|
|
23
|
-
"@tbox.cn/app-sdk": "0.20.0",
|
|
21
|
+
"@tbox.cn/app-contracts": "0.12.0",
|
|
22
|
+
"@tbox.cn/app-contracts-mall": "0.12.0",
|
|
24
23
|
"jsbarcode": "^3.12.3",
|
|
25
|
-
"qrcode": "^1.5.4"
|
|
24
|
+
"qrcode": "^1.5.4",
|
|
25
|
+
"@tbox.cn/app-agent-sdk-client": "0.1.0",
|
|
26
|
+
"@tbox.cn/app-agent-sdk-server": "0.1.0"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"@phosphor-icons/react": "2.1.10",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GameController, Palette, Sparkle, Storefront } from '@phosphor-icons/react';
|
|
2
|
-
import { ItemActionsRow } from '@tbox.cn/app-sdk
|
|
2
|
+
import { ItemActionsRow } from '@tbox.cn/app-agent-sdk-client';
|
|
3
3
|
import type { PromotionActivityCategoryListCardData } from '@tbox.cn/app-contracts-mall';
|
|
4
4
|
|
|
5
5
|
const icons = [GameController, Storefront, Palette, Sparkle] as const;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArrowSquareOut, CalendarDots, CheckCircle, Clock, Crown, ListChecks, MapPin, Sparkle, Users } from '@phosphor-icons/react';
|
|
2
2
|
import type { PromotionActivityDetailCardData } from '@tbox.cn/app-contracts-mall';
|
|
3
|
-
import { sendCardAction } from '@tbox.cn/app-sdk
|
|
3
|
+
import { sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
4
4
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
5
5
|
|
|
6
6
|
const sessionText: Record<string, string> = { OPEN: '可选', FULL: '已满', CLOSED: '已结束', UNKNOWN: '待确认' };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CalendarDots, Sparkle, Ticket } from '@phosphor-icons/react';
|
|
2
|
-
import { sendCardAction } from '@tbox.cn/app-sdk
|
|
2
|
+
import { sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
3
3
|
import type { PromotionActivityListCardData } from '@tbox.cn/app-contracts-mall';
|
|
4
4
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CalendarBlank, CaretDown, Copy, MapPinLine, NavigationArrow, ShieldCheck, Ticket } from '@phosphor-icons/react';
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
-
import { callJsapi, httpGet } from '@tbox.cn/app-sdk
|
|
3
|
+
import { callJsapi, httpGet } from '@tbox.cn/app-agent-sdk-client';
|
|
4
4
|
import type { PromotionEntitlementListCardData } from '@tbox.cn/app-contracts-mall';
|
|
5
5
|
import { CouponSheet } from '../../components/CouponSheet';
|
|
6
6
|
import { CouponBarcode, CouponQrCode } from '../../components/CouponQrCode';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CalendarBlank, CheckCircle, Clock, Gift, Info, ListChecks, MapPin, SealCheck, Ticket } from '@phosphor-icons/react';
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import type { PromotionOfferDetailCardData } from '@tbox.cn/app-contracts-mall';
|
|
4
|
-
import { markSelfRendering, navigateToAlipayPage, sendCardAction } from '@tbox.cn/app-sdk
|
|
4
|
+
import { markSelfRendering, navigateToAlipayPage, sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
5
5
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
6
6
|
import { offerTypeLabel } from '../view';
|
|
7
7
|
import { sanitizeActivityHtml } from '../../utils/sanitize-activity-html';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CalendarBlank, CalendarDots, CaretDown, Lightbulb, MapPin, Sparkle, Ticket } from '@phosphor-icons/react';
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
-
import { ItemActionsRow, markSelfRendering, navigateToAlipayPage, sendCardAction } from '@tbox.cn/app-sdk
|
|
3
|
+
import { ItemActionsRow, markSelfRendering, navigateToAlipayPage, sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
4
4
|
import type { PromotionOfferListCardData } from '@tbox.cn/app-contracts-mall';
|
|
5
5
|
import { CouponSheet } from '../../components/CouponSheet';
|
|
6
6
|
import type { SheetFact } from '../../components/CouponSheet';
|
package/src/client/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import './styles/promotion.css'; // 0.4.0 D1:模块自持 CSS(副作用 import,首行保证先行加载)
|
|
5
5
|
|
|
6
6
|
import type { CardComponent } from '@tbox.cn/app-contracts';
|
|
7
|
-
import type { ClientContext, ClientModule } from '@tbox.cn/app-sdk
|
|
7
|
+
import type { ClientContext, ClientModule } from '@tbox.cn/app-agent-sdk-client';
|
|
8
8
|
import {
|
|
9
9
|
PromotionOfferListCard,
|
|
10
10
|
PromotionOfferDetailCard,
|
package/src/server/actions.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* promotion 写动作(015 S6:唯一写动作 acquire;execute 内预检 R3 + member.status 会员门禁)。
|
|
3
3
|
*/
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
|
-
import type { ServerContext } from '@tbox.cn/app-sdk
|
|
5
|
+
import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
6
6
|
import type { CardActionResult } from '@tbox.cn/app-contracts';
|
|
7
7
|
import { memberGateCardOf, externalMemberRefOf, toMallQueryContext } from '@tbox.cn/app-contracts-mall';
|
|
8
8
|
import type {
|
package/src/server/handler.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* promotion 意图 handler(015 S6:intents patterns 命中出搜索/推荐卡;写走 acquire 动作)。
|
|
3
3
|
*/
|
|
4
|
-
import type { HandlerDefinition, ServerContext } from '@tbox.cn/app-sdk
|
|
5
|
-
import { matchIntent } from '@tbox.cn/app-sdk
|
|
6
|
-
import type { IntentRoute } from '@tbox.cn/app-sdk
|
|
4
|
+
import type { HandlerDefinition, ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
5
|
+
import { matchIntent } from '@tbox.cn/app-agent-sdk-server';
|
|
6
|
+
import type { IntentRoute } from '@tbox.cn/app-agent-sdk-server';
|
|
7
7
|
import { resolveMemberGate, toMallQueryContext } from '@tbox.cn/app-contracts-mall';
|
|
8
8
|
import type { MemberStatusFactory, PromotionActivityPort } from '@tbox.cn/app-contracts-mall';
|
|
9
9
|
import {
|
package/src/server/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServerContext, ServerModule, PreToolDef } from '@tbox.cn/app-sdk
|
|
2
|
-
import { definePreTool, getRequestContext, loadModuleSkills } from '@tbox.cn/app-sdk
|
|
1
|
+
import type { ServerContext, ServerModule, PreToolDef } from '@tbox.cn/app-agent-sdk-server';
|
|
2
|
+
import { definePreTool, getRequestContext, loadModuleSkills } from '@tbox.cn/app-agent-sdk-server';
|
|
3
3
|
import { Router } from 'express';
|
|
4
4
|
import type { Request, Response } from 'express';
|
|
5
5
|
import { toMallQueryContext, withMallScopeFromQuery } from '@tbox.cn/app-contracts-mall';
|
package/src/server/ports.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
type PromotionOfferQueryPort,
|
|
20
20
|
} from '@tbox.cn/app-contracts-mall';
|
|
21
21
|
import { isExpectedProviderAbsence, type RequestContext } from '@tbox.cn/app-contracts';
|
|
22
|
-
import type { ServerContext } from '@tbox.cn/app-sdk
|
|
22
|
+
import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
23
23
|
import { InMemoryPromotionService } from './service';
|
|
24
24
|
|
|
25
25
|
/** 缺省 InMemory 单例(模块包顶层,B14;跨模块消费方 resolveService('promotion') 兼容) */
|
package/src/server/tools.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** 营销域完整工具集:业务语义对齐 legacy marketing,传输遵循 tbox-app。
|
|
2
2
|
* 上下文统一化:运行上下文 = 工具 execute 第二参(requireToolRequestContext 显式读取)。 */
|
|
3
|
-
import { createTool, coerceStringifiedFields, withCardEmissionHint } from '@tbox.cn/app-sdk
|
|
4
|
-
import type { ServerContext, ToolExecContextLike } from '@tbox.cn/app-sdk
|
|
5
|
-
import { requireToolRequestContext } from '@tbox.cn/app-sdk
|
|
3
|
+
import { createTool, coerceStringifiedFields, withCardEmissionHint } from '@tbox.cn/app-agent-sdk-server';
|
|
4
|
+
import type { ServerContext, ToolExecContextLike } from '@tbox.cn/app-agent-sdk-server';
|
|
5
|
+
import { requireToolRequestContext } from '@tbox.cn/app-agent-sdk-server';
|
|
6
6
|
import { resolveMemberGate, toMallQueryContext } from '@tbox.cn/app-contracts-mall';
|
|
7
7
|
import type {
|
|
8
8
|
MemberStatusFactory,
|
package/tbox.module.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"id": "module-promotion",
|
|
4
|
+
"name": "营销中心",
|
|
5
5
|
"description": "活动、优惠、权益、套餐查询与券领取,最划算计算",
|
|
6
6
|
"version": "0.3.0",
|
|
7
7
|
"kind": "business",
|
|
@@ -12,7 +12,16 @@
|
|
|
12
12
|
"distribution": {
|
|
13
13
|
"defaultMode": "codegen"
|
|
14
14
|
},
|
|
15
|
-
"
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"modules": [
|
|
17
|
+
{
|
|
18
|
+
"id": "contracts-mall",
|
|
19
|
+
"required": true
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"env": [],
|
|
24
|
+
"declare": {
|
|
16
25
|
"handlers": [
|
|
17
26
|
"promotion"
|
|
18
27
|
],
|
|
@@ -73,7 +82,7 @@
|
|
|
73
82
|
"skills": [
|
|
74
83
|
"promotion"
|
|
75
84
|
],
|
|
76
|
-
"
|
|
85
|
+
"consumes": [
|
|
77
86
|
{
|
|
78
87
|
"service": "promotion.offers",
|
|
79
88
|
"optional": false,
|
|
@@ -114,15 +123,20 @@
|
|
|
114
123
|
}
|
|
115
124
|
]
|
|
116
125
|
}
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
"dependencies": {
|
|
120
|
-
"modules": [
|
|
126
|
+
],
|
|
127
|
+
"owns": [
|
|
121
128
|
{
|
|
122
|
-
"
|
|
123
|
-
|
|
129
|
+
"service": "promotion.offers"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"service": "promotion.entitlements"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"service": "promotion.activities"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"service": "promotion.acquisition"
|
|
124
139
|
}
|
|
125
140
|
]
|
|
126
|
-
}
|
|
127
|
-
"env": []
|
|
141
|
+
}
|
|
128
142
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { act } from 'react';
|
|
3
3
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
import { createRoot } from 'react-dom/client';
|
|
5
|
-
import { navigateToAlipayPage, sendCardAction } from '@tbox.cn/app-sdk
|
|
5
|
+
import { navigateToAlipayPage, sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
6
6
|
import {
|
|
7
7
|
PromotionActivityCategoryListCard,
|
|
8
8
|
PromotionActivityDetailCard,
|
|
@@ -16,8 +16,8 @@ import { sanitizeActivityHtml } from '../src/client/utils/sanitize-activity-html
|
|
|
16
16
|
|
|
17
17
|
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
18
18
|
|
|
19
|
-
vi.mock('@tbox.cn/app-sdk
|
|
20
|
-
const mod = await importOriginal<typeof import('@tbox.cn/app-sdk
|
|
19
|
+
vi.mock('@tbox.cn/app-agent-sdk-client', async (importOriginal) => {
|
|
20
|
+
const mod = await importOriginal<typeof import('@tbox.cn/app-agent-sdk-client')>();
|
|
21
21
|
return { ...mod, navigateToAlipayPage: vi.fn(() => Promise.resolve()), sendCardAction: vi.fn() };
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { describe, expect, it } from 'vitest';
|
|
9
9
|
import type { RequestContext } from '@tbox.cn/app-contracts';
|
|
10
|
-
import { createServerContext } from '@tbox.cn/app-sdk
|
|
11
|
-
import type { ServerContext } from '@tbox.cn/app-sdk
|
|
10
|
+
import { createServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
11
|
+
import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
12
12
|
import {
|
|
13
13
|
inMemoryPromotion,
|
|
14
14
|
resolvePromotionAcquisitionPort,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { describe, expect, it } from 'vitest';
|
|
8
8
|
import { InMemoryPromotionService } from '../src/server/service';
|
|
9
9
|
import { createPromotionTools, offerSummary } from '../src/server/tools';
|
|
10
|
-
import { CARD_EMISSION_HINT_BASE } from '@tbox.cn/app-sdk
|
|
10
|
+
import { CARD_EMISSION_HINT_BASE } from '@tbox.cn/app-agent-sdk-server';
|
|
11
11
|
import type { PromotionQueryContext } from '@tbox.cn/app-contracts-mall';
|
|
12
12
|
|
|
13
13
|
const q = {
|
package/tests/promotion.test.ts
CHANGED
|
@@ -50,8 +50,8 @@ const mockAllSlots = (service: unknown) => {
|
|
|
50
50
|
};
|
|
51
51
|
import { createPromotionTools, offerDetail, offerSummary } from '../src/server/tools';
|
|
52
52
|
import { createPromotionIntentHandler, PROMOTION_INTENTS } from '../src/server/handler';
|
|
53
|
-
import { createServerContext, createToolExecContext, matchIntent } from '@tbox.cn/app-sdk
|
|
54
|
-
import type { IntentRoute } from '@tbox.cn/app-sdk
|
|
53
|
+
import { createServerContext, createToolExecContext, matchIntent } from '@tbox.cn/app-agent-sdk-server';
|
|
54
|
+
import type { IntentRoute } from '@tbox.cn/app-agent-sdk-server';
|
|
55
55
|
|
|
56
56
|
const q = { scope: { miniAppId: 'app', mallId: 'mall-1' }, subjectId: 'u_1' } as never;
|
|
57
57
|
|
package/tests/samples.test.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 全样本 dataSchema.safeParse 通过 + findSampleShapeViolations 无越界键(样本即契约)。
|
|
4
4
|
*/
|
|
5
5
|
import { describe, expect, it } from 'vitest';
|
|
6
|
-
import { findSampleShapeViolations } from '@tbox.cn/app-sdk
|
|
6
|
+
import { findSampleShapeViolations } from '@tbox.cn/app-agent-sdk-server';
|
|
7
7
|
import offerListMeta from '../src/server/cards/promotion-offer-list/meta';
|
|
8
8
|
import entitlementListMeta from '../src/server/cards/promotion-entitlement-list/meta';
|
|
9
9
|
|
package/tsup.config.ts
CHANGED
|
@@ -16,7 +16,8 @@ export default defineConfig({
|
|
|
16
16
|
// 声明产物一次性构建无需增量——仅 dts 关闭,typecheck 的增量缓存不受影响。
|
|
17
17
|
dts: { compilerOptions: { incremental: false } },
|
|
18
18
|
external: [
|
|
19
|
-
'@tbox.cn/app-sdk',
|
|
19
|
+
'@tbox.cn/app-agent-sdk-client',
|
|
20
|
+
'@tbox.cn/app-agent-sdk-server',
|
|
20
21
|
'@tbox.cn/app-contracts',
|
|
21
22
|
'@tbox.cn/app-contracts-mall',
|
|
22
23
|
'react',
|