@tbox.cn/app-module-indoor-navigation 0.0.0-stage → 1.0.0-alpha.22

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tbox.cn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,70 @@
1
- # Temporary Holding Version
1
+ # module-indoor-navigation 室内导航业务模块
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 室内导航业务组件:B 端按商场配置导航服务(数据来源 + 导航 H5 地址——经通用服务配置
4
+ GET/PUT,写入 `services['indoor-navigation.handoff'].instances[mallId]`);运行时按
5
+ 当前商场配置与本系统门店 `merchantId` 生成完整 HTTPS 跳转目标。
6
+
7
+ > 状态:一期任务 1(2026-11-25)+ 二期统一演示兜底(2026-11-30)。本模块零工具/卡片/
8
+ > 路由注册面;C 端导航按钮归 shopping-guide 详情浮层、承载页归容器 web-host 页
9
+ > (tbox 能力 `app.openWebPage`)——门店详情跳转目标增强仍归门店组件。
10
+
11
+ ## 服务契约
12
+
13
+ - 槽位:`indoor-navigation.handoff`(本模块 `owns`;契约见
14
+ `@tbox.cn/app-contracts-mall` `services/indoor-navigation.ts`)。
15
+ - Port:`IndoorNavigationHandoffPort.resolveHandoffUrl(q, merchantId)` ——
16
+ 输入 = 当前请求的商场范围 + 查到的门店 ID 原字符串;输出 = 完整 HTTPS 跳转地址或
17
+ `undefined`。当前商场未配置、配置无效或门店标识缺失 → `undefined`
18
+ (门店照常展示,无目标即无按钮——**不产出目标不是错误**)。
19
+
20
+ ## 运行时消费配方(任务 2——门店详情 HTTP 与对话出卡两条路径共用)
21
+
22
+ 契约三件(TIER1 单源,`@tbox.cn/app-contracts-mall` services/indoor-navigation):
23
+
24
+ - `INDOOR_NAVIGATION_SERVICE = 'indoor-navigation'`(ctx.services 键——本模块 register
25
+ 期注册本尊,消费方 `ctx.services.resolve?.(INDOOR_NAVIGATION_SERVICE)` 取用);
26
+ - `IndoorNavigationService { resolveJumpUrl(mallId, merchantId) → Promise<string | undefined> }`
27
+ (消费方结构类型子集消费——模块间禁互相 import,键与形状经 TIER1 双钉死);
28
+ - `INDOOR_NAVIGATION_DEMO_TARGET`(固定演示跳转目标——2026-11-30 产品矩阵「已接入
29
+ 组件但无有效配置」行的兜底单源;provider-mock 演示供给同源消费,替换只改这一处);
30
+ - `indoorNavigationUrlSchema`(输出形状约束——完整 HTTPS ≤2048,消费侧 safeParse 同源判定)。
31
+
32
+ ```ts
33
+ import { INDOOR_NAVIGATION_SERVICE, type IndoorNavigationService } from '@tbox.cn/app-contracts-mall';
34
+ const svc = ctx.services.resolve?.(INDOOR_NAVIGATION_SERVICE) as IndoorNavigationService | undefined;
35
+ const url = svc && await svc.resolveJumpUrl(scope.mallId, shop.merchantId);
36
+ // → string | undefined;投影为门店详情数据上的可选字段 indoorNavigation: { url }
37
+ ```
38
+
39
+ 辅助语义(实现收口 `resolveIndoorNavigationTarget`——本模块导出,直接消费方可用):
40
+
41
+ - 无商圈 scope / 门店标识缺失(空串/全空白)→ `undefined`(消费侧短路,零解析成本);
42
+ - 槽级预期缺席(未配置/商场实例缺席/禁用)→ `undefined`(ports 原语语义);
43
+ - 配置无效(供应商 adapter 判定非 HTTPS/缺路由片段等)→ `undefined`;
44
+ - 装配缺口(registry 缺席、绑定不可解析等)→ 原样上抛(fail-visible——不得静默
45
+ 折损成「未配置」)。
46
+
47
+ **统一演示兜底(2026-11-30,服务本尊层)**:`createIndoorNavigationService` 对 ports
48
+ 返回 `undefined` 的一切无有效配置态(槽节点缺席/实例缺席/停用/配置无效)统一落
49
+ `INDOOR_NAVIGATION_DEMO_TARGET`(原样打开、固定演示 `third_id`——不做参数手术);
50
+ 仅缺商场范围、缺门店标识(查询语境问题)与装配事故(上抛)不落兜底。产品裁定:
51
+ 组件接入状态不做细分判定(需求方 2026-11-30 指令)——商圈模板预置、平台可删组件,
52
+ 删除即整链无入口。
53
+
54
+ ## B 端配置协定(交接前端/运营)
55
+
56
+ - 表单沿用动态表单:数据来源(供应商候选只含本组件已供给厂商)+ 导航 H5 地址
57
+ (必填 HTTPS,保留原路径、参数和片段——third_id 之类门店标识参数由后端生成,
58
+ 不在表单填写)。
59
+ - 保存 = 通用服务配置 PUT(**整节点替换**):先把其他商场的 `instances[mallId]` 键
60
+ 原样带回,再写当前商场——编辑 A 不会丢 B 的配置。
61
+ - 未配置的商场:门店照常展示,跳出 **固定演示链接**(服务本尊兜底——2026-11-30
62
+ 产品矩阵;此前「未配置即无目标」的一期语义显式退役)。默认投递档
63
+ (`.real-env/config/mock`)本槽显式零激活(不抢真实供给),未配置商场经服务本尊
64
+ 兜底同出演示链接;显式绑定 mock 供给时 adapter 亦产出同一地址(TIER1 常量单源)。
65
+
66
+ ## 供给商
67
+
68
+ - 真实厂商供给见对应 provider 私有包(厂商连接唯一真源;候选范围
69
+ `selectionScope: 'supplied-services'`——只在本组件选择器可见);演示数据经
70
+ `provider-mock` 同槽供给(默认装配零 503)。
@@ -0,0 +1,78 @@
1
+ // src/server/index.ts
2
+ import { INDOOR_NAVIGATION_SERVICE } from "@tbox.cn/app-contracts-mall";
3
+
4
+ // src/server/service.ts
5
+ import {
6
+ INDOOR_NAVIGATION_DEMO_TARGET,
7
+ isMissingIndoorNavigationMerchantId as isMissingIndoorNavigationMerchantId2
8
+ } from "@tbox.cn/app-contracts-mall";
9
+
10
+ // src/server/ports.ts
11
+ import {
12
+ INDOOR_NAVIGATION_HANDOFF_SERVICE,
13
+ isMissingIndoorNavigationMerchantId,
14
+ mallScopeOf,
15
+ toMallQueryContext
16
+ } from "@tbox.cn/app-contracts-mall";
17
+ import { isExpectedProviderAbsence } from "@tbox.cn/app-contracts";
18
+ async function resolveIndoorNavigationTarget(reqCtx, ctx, merchantId) {
19
+ const scope = mallScopeOf(reqCtx);
20
+ if (!scope.mallId) return void 0;
21
+ if (isMissingIndoorNavigationMerchantId(merchantId)) return void 0;
22
+ if (!ctx.integrations) {
23
+ throw new Error("\u5BA4\u5185\u5BFC\u822A\u89E3\u6790\u5931\u8D25\uFF1A\u672A\u88C5\u914D\u96C6\u6210\u914D\u7F6E\uFF08integrations registry \u7F3A\u5E2D\uFF09");
24
+ }
25
+ let port;
26
+ try {
27
+ port = await ctx.integrations.resolveService({
28
+ service: INDOOR_NAVIGATION_HANDOFF_SERVICE,
29
+ scope,
30
+ request: reqCtx
31
+ });
32
+ } catch (e) {
33
+ if (isExpectedProviderAbsence(e)) return void 0;
34
+ throw e;
35
+ }
36
+ const q = toMallQueryContext(reqCtx);
37
+ return port.resolveHandoffUrl(q, merchantId);
38
+ }
39
+
40
+ // src/server/service.ts
41
+ function scopeRequestOf(mallId) {
42
+ return {
43
+ identity: { userId: "", source: "anonymous" },
44
+ attributes: { mall: { mallId } }
45
+ };
46
+ }
47
+ function createIndoorNavigationService(ctx) {
48
+ return {
49
+ async resolveJumpUrl(mallId, merchantId) {
50
+ if (!mallId || isMissingIndoorNavigationMerchantId2(merchantId)) return void 0;
51
+ const url = await resolveIndoorNavigationTarget(scopeRequestOf(mallId), ctx, merchantId);
52
+ return url ?? INDOOR_NAVIGATION_DEMO_TARGET;
53
+ }
54
+ };
55
+ }
56
+
57
+ // src/server/index.ts
58
+ var cards = {};
59
+ var serverModule = {
60
+ declaration: {
61
+ moduleId: "indoor-navigation"
62
+ },
63
+ cards,
64
+ register(ctx) {
65
+ if (ctx.integrations) {
66
+ ctx.services.register(
67
+ INDOOR_NAVIGATION_SERVICE,
68
+ createIndoorNavigationService(ctx)
69
+ );
70
+ }
71
+ }
72
+ };
73
+
74
+ export {
75
+ resolveIndoorNavigationTarget,
76
+ createIndoorNavigationService,
77
+ serverModule
78
+ };
@@ -0,0 +1,10 @@
1
+ // src/client/index.ts
2
+ var clientModule = {
3
+ cards: {},
4
+ register(_ctx) {
5
+ }
6
+ };
7
+
8
+ export {
9
+ clientModule
10
+ };
@@ -0,0 +1,13 @@
1
+ import { ClientContext } from '@tbox.cn/app-agent-sdk-client';
2
+
3
+ /**
4
+ * 室内导航客户端入口:零卡片组件(C 端门店详情导航按钮由任务 2 前端在宿主接入实现,
5
+ * 不属本模块装配面);cards 恒空 map 保留装配形状(模块单包双端同构)。
6
+ */
7
+
8
+ declare const clientModule: {
9
+ cards: {};
10
+ register(_ctx: ClientContext): void;
11
+ };
12
+
13
+ export { clientModule };
@@ -0,0 +1,6 @@
1
+ import {
2
+ clientModule
3
+ } from "../chunk-SAE553C6.js";
4
+ export {
5
+ clientModule
6
+ };
@@ -0,0 +1,6 @@
1
+ export { createIndoorNavigationService, resolveIndoorNavigationTarget, serverModule } from './server/index.js';
2
+ export { clientModule } from './client/index.js';
3
+ import '@tbox.cn/app-agent-sdk-server';
4
+ import '@tbox.cn/app-contracts';
5
+ import '@tbox.cn/app-contracts-mall';
6
+ import '@tbox.cn/app-agent-sdk-client';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ createIndoorNavigationService,
3
+ resolveIndoorNavigationTarget,
4
+ serverModule
5
+ } from "./chunk-HWWZCIZQ.js";
6
+ import {
7
+ clientModule
8
+ } from "./chunk-SAE553C6.js";
9
+ export {
10
+ clientModule,
11
+ createIndoorNavigationService,
12
+ resolveIndoorNavigationTarget,
13
+ serverModule
14
+ };
@@ -0,0 +1,42 @@
1
+ import { ServerContext } from '@tbox.cn/app-agent-sdk-server';
2
+ import { RequestContext } from '@tbox.cn/app-contracts';
3
+ import { IndoorNavigationService } from '@tbox.cn/app-contracts-mall';
4
+
5
+ /**
6
+ * 室内导航跳转目标合成(任务 2 消费契约的唯一形状——门店详情 HTTP 与对话出卡共用):
7
+ * 输入 = 当前请求的商场范围 + 查到的 merchantId;输出 = 完整 HTTPS 跳转地址或 undefined。
8
+ * 当前商场未配置、配置无效或门店标识缺失 → undefined(门店照常展示,无目标即无按钮)。
9
+ */
10
+ declare function resolveIndoorNavigationTarget(reqCtx: RequestContext, ctx: ServerContext, merchantId: string): Promise<string | undefined>;
11
+
12
+ /**
13
+ * 服务工厂(ctx 闭包注册期绑定——实例分裂免疫;integrations registry 缺席时
14
+ * 由 register 侧决定不注册——消费方 resolve 缺席降级 undefined)。
15
+ * 注册键 = contracts-mall `INDOOR_NAVIGATION_SERVICE`('indoor-navigation')。
16
+ *
17
+ * 统一演示兜底(产品矩阵 2026-11-30 裁定:组件接入状态不做细分判定,统一兜底):
18
+ * 槽解析无有效目标(槽节点缺席/当前商场不在实例表/实例停用/配置无效——ports 原语
19
+ * 均返回 undefined)→ 固定演示链接(INDOOR_NAVIGATION_DEMO_TARGET 契约单源,原样打开——
20
+ * provider-mock 显式绑定供给时同由契约单源出同一演示地址,本模块零供应商判断)。例外仍省略字段:
21
+ * 缺商场范围/缺门店标识(查询语境问题,非配置问题——不以演示链接伪装)、以及
22
+ * BINDING_UNRESOLVED 等装配事故(原样上抛 fail-visible,装配缺口不静默折损成演示态)。
23
+ */
24
+ declare function createIndoorNavigationService(ctx: ServerContext): IndoorNavigationService;
25
+
26
+ /**
27
+ * 室内导航注册:B 端配置面经通用服务编辑器(GET/PUT services/indoor-navigation.handoff);
28
+ * 运行时以 ctx.services 本尊(键 'indoor-navigation'——TIER1 INDOOR_NAVIGATION_SERVICE,
29
+ * 任务 2 门店详情双链路消费缝隙)承载跳转目标解析,内部经槽供给链(provider adapter)
30
+ * 生成链接。本模块零工具/卡片/路由注册面;按钮、承载页与返回交互归前端与宿主(任务 2
31
+ * 前端部分)。服务实例与解析经 ctx 注入,register 只注册不解析。
32
+ */
33
+
34
+ declare const serverModule: {
35
+ declaration: {
36
+ moduleId: string;
37
+ };
38
+ cards: {};
39
+ register(ctx: ServerContext): void;
40
+ };
41
+
42
+ export { createIndoorNavigationService, resolveIndoorNavigationTarget, serverModule };
@@ -0,0 +1,10 @@
1
+ import {
2
+ createIndoorNavigationService,
3
+ resolveIndoorNavigationTarget,
4
+ serverModule
5
+ } from "../chunk-HWWZCIZQ.js";
6
+ export {
7
+ createIndoorNavigationService,
8
+ resolveIndoorNavigationTarget,
9
+ serverModule
10
+ };
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-module-indoor-navigation",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0-alpha.22",
4
+ "type": "module",
5
+ "description": "室内导航业务模块:按商场配置生成本系统门店的室内导航 H5 跳转目标(B 端经通用服务配置面管理;跳转目标解析供给槽 Port)",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ },
11
+ "./server": {
12
+ "types": "./dist/server/index.d.ts",
13
+ "import": "./dist/server/index.js"
14
+ },
15
+ "./client": {
16
+ "types": "./dist/client/index.d.ts",
17
+ "import": "./dist/client/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "dependencies": {
22
+ "@tbox.cn/app-contracts": "1.0.0-alpha.22",
23
+ "@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.22",
24
+ "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.22",
25
+ "@tbox.cn/app-contracts-mall": "1.0.0-alpha.22"
26
+ },
27
+ "peerDependencies": {
28
+ "zod": "3.25.76"
29
+ },
30
+ "devDependencies": {
31
+ "@types/express": "4.17.25",
32
+ "@types/node": "24.13.3",
33
+ "@types/supertest": "7.2.1",
34
+ "typescript": "5.9.3",
35
+ "vitest": "4.1.10",
36
+ "zod": "3.25.76",
37
+ "tsup": "8.5.1",
38
+ "express": "4.22.2",
39
+ "supertest": "7.2.2"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "src",
44
+ "tests",
45
+ "tbox.module.json",
46
+ "tsconfig.json",
47
+ "tsup.config.ts",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ "engines": {
52
+ "node": ">=20.0.0"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "license": "MIT",
58
+ "scripts": {
59
+ "typecheck": "tsc --noEmit",
60
+ "test": "vitest run",
61
+ "build": "tsup"
62
+ }
6
63
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 室内导航客户端入口:零卡片组件(C 端门店详情导航按钮由任务 2 前端在宿主接入实现,
3
+ * 不属本模块装配面);cards 恒空 map 保留装配形状(模块单包双端同构)。
4
+ */
5
+ import type { ClientContext, ClientModule } from '@tbox.cn/app-agent-sdk-client';
6
+
7
+ export const clientModule = {
8
+ cards: {},
9
+ register(_ctx: ClientContext): void {
10
+ // 无注册面(零卡片/零页面;跳转承载归宿主 web-view 承载页)
11
+ },
12
+ } satisfies ClientModule;
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * module-indoor-navigation 主入口(package.json exports "." 指向)。
3
+ * 消费方通常走 ./server / ./client 子路径;主入口聚合导出便于直接引用。
4
+ */
5
+ export * from './server';
6
+ export * from './client';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 室内导航注册:B 端配置面经通用服务编辑器(GET/PUT services/indoor-navigation.handoff);
3
+ * 运行时以 ctx.services 本尊(键 'indoor-navigation'——TIER1 INDOOR_NAVIGATION_SERVICE,
4
+ * 任务 2 门店详情双链路消费缝隙)承载跳转目标解析,内部经槽供给链(provider adapter)
5
+ * 生成链接。本模块零工具/卡片/路由注册面;按钮、承载页与返回交互归前端与宿主(任务 2
6
+ * 前端部分)。服务实例与解析经 ctx 注入,register 只注册不解析。
7
+ */
8
+ import type { ServerContext, ServerModule } from '@tbox.cn/app-agent-sdk-server';
9
+ import { INDOOR_NAVIGATION_SERVICE } from '@tbox.cn/app-contracts-mall';
10
+ import { createIndoorNavigationService } from './service';
11
+
12
+ export { resolveIndoorNavigationTarget } from './ports';
13
+ export { createIndoorNavigationService } from './service';
14
+
15
+ const cards = {} as const;
16
+
17
+ export const serverModule = {
18
+ declaration: {
19
+ moduleId: 'indoor-navigation',
20
+ },
21
+ cards,
22
+ register(ctx: ServerContext): void {
23
+ // 服务本尊注册(register 期一次;integrations registry 缺席 = 无配置面语义 →
24
+ // 不注册——消费方 resolve 缺席降级 undefined,门店照常展示,无逐请求告警噪声)
25
+ if (ctx.integrations) {
26
+ ctx.services.register(
27
+ INDOOR_NAVIGATION_SERVICE,
28
+ createIndoorNavigationService(ctx),
29
+ );
30
+ }
31
+ },
32
+ } satisfies ServerModule;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * indoor-navigation.handoff 槽供给解析 + 跳转目标合成(单消费通道——fail-soft 谱)。
3
+ * 模块零 provider import,经 ctx.integrations registry 解析;实例绑定决定配置范围
4
+ * (services['indoor-navigation.handoff'].instances[mallId])。
5
+ *
6
+ * 与活动玩法域 503/502 二分的有意分歧:跳转目标是可选增强——
7
+ * - 当前商场未配置(槽级预期缺席 SERVICE_NOT_CONFIGURED / INSTANCE_NOT_FOUND /
8
+ * INSTANCE_DISABLED,isExpectedProviderAbsence 单源)→ undefined;
9
+ * - 配置无效、门店标识缺失 → 供给侧 adapter resolveHandoffUrl 结构化返回 undefined;
10
+ * - 其余(BINDING_UNRESOLVED 等装配缺口、registry 缺席)→ 原样上抛 fail-visible
11
+ * (不得把装配事故静默折损成「未配置」)。
12
+ * 无商圈 scope 同样 undefined(无 scope 语境不可判配置范围;非业务错误)。
13
+ */
14
+ import type {
15
+ IndoorNavigationHandoffPort,
16
+ MallQueryContext,
17
+ } from '@tbox.cn/app-contracts-mall';
18
+ import {
19
+ INDOOR_NAVIGATION_HANDOFF_SERVICE,
20
+ isMissingIndoorNavigationMerchantId,
21
+ mallScopeOf,
22
+ toMallQueryContext,
23
+ } from '@tbox.cn/app-contracts-mall';
24
+ import { isExpectedProviderAbsence } from '@tbox.cn/app-contracts';
25
+ import type { RequestContext } from '@tbox.cn/app-contracts';
26
+ import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
27
+
28
+ /**
29
+ * 室内导航跳转目标合成(任务 2 消费契约的唯一形状——门店详情 HTTP 与对话出卡共用):
30
+ * 输入 = 当前请求的商场范围 + 查到的 merchantId;输出 = 完整 HTTPS 跳转地址或 undefined。
31
+ * 当前商场未配置、配置无效或门店标识缺失 → undefined(门店照常展示,无目标即无按钮)。
32
+ */
33
+ export async function resolveIndoorNavigationTarget(
34
+ reqCtx: RequestContext,
35
+ ctx: ServerContext,
36
+ merchantId: string,
37
+ ): Promise<string | undefined> {
38
+ const scope = mallScopeOf(reqCtx);
39
+ if (!scope.mallId) return undefined;
40
+ // 门店标识缺失单源判定(消费侧短路——零解析成本;供给侧 adapter 同判兜底直调方)
41
+ if (isMissingIndoorNavigationMerchantId(merchantId)) return undefined;
42
+ if (!ctx.integrations) {
43
+ // 装配缺口 fail-visible(与「未配置」区分——不静默折损)
44
+ throw new Error('室内导航解析失败:未装配集成配置(integrations registry 缺席)');
45
+ }
46
+ let port: IndoorNavigationHandoffPort;
47
+ try {
48
+ port = (await ctx.integrations.resolveService({
49
+ service: INDOOR_NAVIGATION_HANDOFF_SERVICE,
50
+ scope,
51
+ request: reqCtx,
52
+ })) as IndoorNavigationHandoffPort;
53
+ } catch (e) {
54
+ if (isExpectedProviderAbsence(e)) return undefined;
55
+ throw e;
56
+ }
57
+ const q: MallQueryContext = toMallQueryContext(reqCtx);
58
+ return port.resolveHandoffUrl(q, merchantId);
59
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * 室内导航服务本尊(ctx.services 键 `indoor-navigation`——任务 2 门店详情双链路消费缝隙)。
3
+ * 与 mall-directory 服务同模式(跨模块 Port + ctx 铁律:键与形状经 TIER1 契约单源
4
+ * ——contracts-mall services/indoor-navigation 三件同锁;本模块注册实现超集;
5
+ * 消费方结构类型子集消费,零模块间 import);实现 = 槽供给链收口(resolveIndoorNavigationTarget)
6
+ * + 统一演示兜底(INDOOR_NAVIGATION_DEMO_TARGET——TIER1 契约单源,provider-mock 演示供给同源消费)。
7
+ *
8
+ * mallId 入参是任务 2 从门店查询同一 reqCtx 解析出的商场范围(非任意越权键——
9
+ * 配置查找本地语义);合成请求上下文仅承载该范围(无用户身份语义——跳转目标与用户
10
+ * 无关,门店标识参数仅承载 merchantId)。
11
+ */
12
+ import type { RequestContext } from '@tbox.cn/app-contracts';
13
+ import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
14
+ import type { IndoorNavigationService } from '@tbox.cn/app-contracts-mall';
15
+ import {
16
+ INDOOR_NAVIGATION_DEMO_TARGET,
17
+ isMissingIndoorNavigationMerchantId,
18
+ } from '@tbox.cn/app-contracts-mall';
19
+ import { resolveIndoorNavigationTarget } from './ports';
20
+
21
+ /** 合成请求上下文(仅承载 mallId 范围——无身份/凭据语义;slot scope = { mallId }) */
22
+ function scopeRequestOf(mallId: string): RequestContext {
23
+ return {
24
+ identity: { userId: '', source: 'anonymous' },
25
+ attributes: { mall: { mallId } },
26
+ };
27
+ }
28
+
29
+ /**
30
+ * 服务工厂(ctx 闭包注册期绑定——实例分裂免疫;integrations registry 缺席时
31
+ * 由 register 侧决定不注册——消费方 resolve 缺席降级 undefined)。
32
+ * 注册键 = contracts-mall `INDOOR_NAVIGATION_SERVICE`('indoor-navigation')。
33
+ *
34
+ * 统一演示兜底(产品矩阵 2026-11-30 裁定:组件接入状态不做细分判定,统一兜底):
35
+ * 槽解析无有效目标(槽节点缺席/当前商场不在实例表/实例停用/配置无效——ports 原语
36
+ * 均返回 undefined)→ 固定演示链接(INDOOR_NAVIGATION_DEMO_TARGET 契约单源,原样打开——
37
+ * provider-mock 显式绑定供给时同由契约单源出同一演示地址,本模块零供应商判断)。例外仍省略字段:
38
+ * 缺商场范围/缺门店标识(查询语境问题,非配置问题——不以演示链接伪装)、以及
39
+ * BINDING_UNRESOLVED 等装配事故(原样上抛 fail-visible,装配缺口不静默折损成演示态)。
40
+ */
41
+ export function createIndoorNavigationService(ctx: ServerContext): IndoorNavigationService {
42
+ return {
43
+ async resolveJumpUrl(mallId: string, merchantId: string): Promise<string | undefined> {
44
+ // 查询语境问题先短路(ports 原语同判兜底直调方——此处前置防其 undefined 落入演示兜底)
45
+ if (!mallId || isMissingIndoorNavigationMerchantId(merchantId)) return undefined;
46
+ const url = await resolveIndoorNavigationTarget(scopeRequestOf(mallId), ctx, merchantId);
47
+ return url ?? INDOOR_NAVIGATION_DEMO_TARGET;
48
+ },
49
+ };
50
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "module-indoor-navigation",
4
+ "name": "室内导航",
5
+ "description": "室内导航:B 端按商场配置导航服务地址;运行时按当前商场配置与本系统门店标识生成室内导航 H5 跳转目标(未配置或门店标识缺失不产出目标,门店照常展示);按钮与承载页归前端与宿主",
6
+ "kind": "business",
7
+ "risk": {
8
+ "level": "low",
9
+ "writeBoundary": "source"
10
+ },
11
+ "distribution": {
12
+ "defaultMode": "codegen"
13
+ },
14
+ "dependencies": {
15
+ "modules": [
16
+ {
17
+ "id": "contracts-mall",
18
+ "required": true
19
+ }
20
+ ]
21
+ },
22
+ "env": [],
23
+ "declare": {
24
+ "handlers": [],
25
+ "tools": [],
26
+ "cards": [],
27
+ "routes": [],
28
+ "pages": [],
29
+ "tabs": [],
30
+ "resources": [],
31
+ "consumes": [
32
+ {
33
+ "service": "indoor-navigation.handoff",
34
+ "optional": false
35
+ }
36
+ ],
37
+ "owns": [
38
+ {
39
+ "service": "indoor-navigation.handoff"
40
+ }
41
+ ],
42
+ "skills": []
43
+ }
44
+ }
@@ -0,0 +1,193 @@
1
+ /**
2
+ * 双商场隔离 e2e(真实 createIntegrationsRegistry 求值链 + 槽实例差异化配置):
3
+ * 验收口径——同一应用给两个商场配置不同地址:编辑 A 后 B 的配置仍在,运行时各自解析
4
+ * 正确。两层语义分测:ports 原语层(resolveIndoorNavigationTarget)「未配置 → undefined」
5
+ * 预期缺席映射不变;服务本尊层(createIndoorNavigationService)对同一批「已接入但无
6
+ * 有效配置」态统一落固定演示链接(2026-11-30 产品矩阵——组件接入状态不做细分判定)。
7
+ * 供给 adapter 在测试侧同形 stub(本模块零 provider import——workspace-dag 铁律:
8
+ * 中性 stub 供给名;真实厂商 adapter 的双商场求值归 provider 包同套件覆盖)。
9
+ * fixture 经契约真实 `parseIntegrationsConfig`(zod strictObject——非法节点即拒)。
10
+ */
11
+ import { describe, expect, it } from 'vitest';
12
+ import {
13
+ createAuthStrategyRegistry,
14
+ createEnvironmentSecretProvider,
15
+ createIntegrationsRegistry,
16
+ createServerContext,
17
+ } from '@tbox.cn/app-agent-sdk-server';
18
+ import {
19
+ parseIntegrationsConfig,
20
+ type IntegrationsConfig,
21
+ type RequestContext,
22
+ } from '@tbox.cn/app-contracts';
23
+ import {
24
+ INDOOR_NAVIGATION_DEMO_TARGET,
25
+ INDOOR_NAVIGATION_HANDOFF_SERVICE,
26
+ indoorNavigationUrlSchema,
27
+ } from '@tbox.cn/app-contracts-mall';
28
+ import { resolveIndoorNavigationTarget } from '../src/server/ports';
29
+ import { createIndoorNavigationService } from '../src/server/service';
30
+ import { serverModule } from '../src/server';
31
+
32
+ const SLOT = INDOOR_NAVIGATION_HANDOFF_SERVICE;
33
+ const IMPL = 'stub-indoor-navigation@1'; // 中性 stub 供给键(catalog 供给唯一命中派生——键值形态同真实供给)
34
+
35
+ const URL_BJ = 'https://nav.bj.example.com/universal/#/ar_v4?sdk_version=v4';
36
+ const URL_SH = 'https://nav.sh.example.com/map/#/ar_v4?image_channel=1';
37
+
38
+ /** B 端两商场配置后 integrations.json 服务节点形态(整节点替换——instances 键集 = 白名单) */
39
+ const rawConfig: { services: Record<string, { provider: string; instances: Record<string, { config: Record<string, unknown> }> }> } = {
40
+ services: {
41
+ [SLOT]: {
42
+ provider: 'stub-nav',
43
+ instances: {
44
+ 'mall-bj': { config: { h5Url: URL_BJ } },
45
+ 'mall-sh': { config: { h5Url: URL_SH } },
46
+ },
47
+ },
48
+ },
49
+ };
50
+
51
+ /** 测试侧同形供给 stub:按实例 config 合成目标 URL(形态同真实 adapter——配置→链接) */
52
+ function makeCtx(config: IntegrationsConfig) {
53
+ const registry = createIntegrationsRegistry({
54
+ integrations: config,
55
+ catalog: {
56
+ providers: {
57
+ 'stub-nav': { [IMPL]: { provider: 'stub-nav', implementation: IMPL, credentialType: '-', owner: 'stub-nav-owner', services: [SLOT] } },
58
+ },
59
+ services: {},
60
+ credentialTypes: {},
61
+ },
62
+ ownerOf: { [SLOT]: 'module-indoor-navigation' },
63
+ authStrategies: createAuthStrategyRegistry(),
64
+ secretProvider: createEnvironmentSecretProvider({ source: {}, production: false }),
65
+ instanceIdOf: (scope) => scope['mallId'] ?? '',
66
+ });
67
+ registry.registerAdapter('stub-nav', IMPL, (input) => ({
68
+ resolveHandoffUrl: async (_q: unknown, merchantId: string) =>
69
+ typeof input.config?.['h5Url'] === 'string'
70
+ ? `${input.config['h5Url']}&third_id=${encodeURIComponent(merchantId)}`
71
+ : undefined,
72
+ }));
73
+ return createServerContext({ integrations: registry });
74
+ }
75
+
76
+ const reqCtx = (mallId: string): RequestContext => ({
77
+ identity: { userId: 'u', source: 'local' as const },
78
+ attributes: { mall: { mallId } },
79
+ });
80
+
81
+ describe('双商场隔离(真实 registry 求值链——实例键控配置)', () => {
82
+ it('fixture 经契约真实解析(zod strictObject——非法服务节点即拒)', () => {
83
+ expect(() => parseIntegrationsConfig(rawConfig)).not.toThrow();
84
+ });
85
+
86
+ it('两商场各自解析正确(不同地址、同门店标识互不串)', async () => {
87
+ const ctx = makeCtx(parseIntegrationsConfig(rawConfig));
88
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-bj'), ctx, 'BT0012S125'))
89
+ .resolves.toBe(`${URL_BJ}&third_id=BT0012S125`);
90
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-sh'), ctx, 'BT0012S125'))
91
+ .resolves.toBe(`${URL_SH}&third_id=BT0012S125`);
92
+ });
93
+
94
+ it('未配置的商场 → undefined(INSTANCE_NOT_FOUND 预期缺席映射——非错误)', async () => {
95
+ const ctx = makeCtx(parseIntegrationsConfig(rawConfig));
96
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-gz'), ctx, 'BT0012S125'))
97
+ .resolves.toBeUndefined();
98
+ });
99
+
100
+ it('「编辑 A 不动 B」:PUT 整节点替换后的重读求值——A 改新地址,B 原值仍在', async () => {
101
+ // B 端保存协定:GET 原服务节点 → 改 instances['mall-bj'] → PUT 回整节点(B 键原样带回)
102
+ const edited = structuredClone(rawConfig);
103
+ edited.services[SLOT].instances['mall-bj'] = {
104
+ config: { h5Url: 'https://nav.bj.example.com/v2/#/ar_v4?sdk_version=v4' },
105
+ };
106
+ const ctx = makeCtx(parseIntegrationsConfig(edited));
107
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-bj'), ctx, 'S1'))
108
+ .resolves.toBe('https://nav.bj.example.com/v2/#/ar_v4?sdk_version=v4&third_id=S1');
109
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-sh'), ctx, 'S1'))
110
+ .resolves.toBe(`${URL_SH}&third_id=S1`);
111
+ });
112
+
113
+ it('ctx.services 本尊(键 indoor-navigation——任务 2 缝隙)经真实 registry 双商场求值', async () => {
114
+ const ctx = makeCtx(parseIntegrationsConfig(rawConfig));
115
+ const svc = createIndoorNavigationService(ctx);
116
+ await expect(svc.resolveJumpUrl('mall-bj', 'BT0012S125')).resolves.toBe(`${URL_BJ}&third_id=BT0012S125`);
117
+ await expect(svc.resolveJumpUrl('mall-sh', '001')).resolves.toBe(`${URL_SH}&third_id=001`);
118
+ // 统一演示兜底(2026-11-30 产品矩阵):未配置商场不再省略,落固定演示链接
119
+ await expect(svc.resolveJumpUrl('mall-gz', 'BT0012S125')).resolves.toBe(INDOOR_NAVIGATION_DEMO_TARGET);
120
+ // 查询语境问题(缺门店标识)不落演示兜底——省略字段
121
+ await expect(svc.resolveJumpUrl('mall-bj', '')).resolves.toBeUndefined();
122
+ await expect(svc.resolveJumpUrl('mall-bj', ' ')).resolves.toBeUndefined();
123
+ await expect(svc.resolveJumpUrl('', 'BT0012S125')).resolves.toBeUndefined();
124
+ });
125
+
126
+ it('serverModule.register:integrations 在场才注册本尊(缺席 = 消费方 resolve 缺席降级)', () => {
127
+ const registered: Array<[string, unknown]> = [];
128
+ const regCtx = (integrations: unknown) =>
129
+ ({ integrations, services: { register: (k: string, v: unknown) => registered.push([k, v]) } }) as never;
130
+ serverModule.register(regCtx(makeCtx(parseIntegrationsConfig(rawConfig))));
131
+ expect(registered).toHaveLength(1);
132
+ expect(registered[0][0]).toBe('indoor-navigation');
133
+ serverModule.register(regCtx(undefined));
134
+ expect(registered).toHaveLength(1); // 未重复注册
135
+ });
136
+
137
+ it('实例 config 缺失 → 供给侧 undefined 透传', async () => {
138
+ const broken = structuredClone(rawConfig);
139
+ broken.services[SLOT].instances['mall-bj'] = { config: {} };
140
+ const ctx = makeCtx(parseIntegrationsConfig(broken));
141
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-bj'), ctx, 'S1'))
142
+ .resolves.toBeUndefined();
143
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-sh'), ctx, 'S1'))
144
+ .resolves.toBe(`${URL_SH}&third_id=S1`);
145
+ });
146
+ });
147
+
148
+ describe('统一演示兜底(服务本尊层——2026-11-30 产品矩阵「已接入但无有效配置」行)', () => {
149
+ it('演示目标恒为需求方提供的单源常量(原样打开——固定 third_id 不做参数手术)', async () => {
150
+ expect(INDOOR_NAVIGATION_DEMO_TARGET).toBe('https://ar-activities-test.aibee.cn/universal/#/ar_v4?sdk_version=v4&image_channel=1&third_id=BT0012S125'); // guard-vendor-neutrality: allow——需求方提供的演示地址单值锁定(与契约常量双钉)
151
+ // 固定演示 third_id 原样保留(不被门店参数替换——区别于供给方生成链的 third_id 手术)
152
+ expect(INDOOR_NAVIGATION_DEMO_TARGET).toContain('third_id=BT0012S125');
153
+ // 输出契约三面(契约/写面/运行时)同锁:演示目标必然过消费方校验
154
+ expect(indoorNavigationUrlSchema.safeParse(INDOOR_NAVIGATION_DEMO_TARGET).success).toBe(true);
155
+ // 运行时具名导出面可达(生成应用 registry 消费轴——runtime.ts 漏挂时本断言先红)
156
+ const contracts = await import('@tbox.cn/app-contracts-mall');
157
+ expect(contracts.INDOOR_NAVIGATION_DEMO_TARGET).toBe(INDOOR_NAVIGATION_DEMO_TARGET);
158
+ });
159
+
160
+ it('实例 config 在场但无效(写面合法保存态)→ 演示链接(供给 undefined 不外漏)', async () => {
161
+ const broken = structuredClone(rawConfig);
162
+ broken.services[SLOT].instances['mall-bj'] = { config: {} };
163
+ const ctx = makeCtx(parseIntegrationsConfig(broken));
164
+ const svc = createIndoorNavigationService(ctx);
165
+ await expect(svc.resolveJumpUrl('mall-bj', 'S1')).resolves.toBe(INDOOR_NAVIGATION_DEMO_TARGET);
166
+ // 未破坏商场照常供给真实链接——无效配置不外溢
167
+ await expect(svc.resolveJumpUrl('mall-sh', 'S1')).resolves.toBe(`${URL_SH}&third_id=S1`);
168
+ });
169
+
170
+ it('槽节点全缺(SERVICE_NOT_CONFIGURED——生成应用只装模块未绑供给)→ 演示链接', async () => {
171
+ const ctx = makeCtx(parseIntegrationsConfig({ services: {} }));
172
+ const svc = createIndoorNavigationService(ctx);
173
+ await expect(svc.resolveJumpUrl('mall-1', 'BT0012S125')).resolves.toBe(INDOOR_NAVIGATION_DEMO_TARGET);
174
+ });
175
+
176
+ it('显式零激活实例(instances: {} = 已接供给但未开启任何商场)→ 演示链接', async () => {
177
+ const off = structuredClone(rawConfig);
178
+ off.services[SLOT].instances = {};
179
+ const ctx = makeCtx(parseIntegrationsConfig(off));
180
+ const svc = createIndoorNavigationService(ctx);
181
+ await expect(svc.resolveJumpUrl('mall-bj', 'S1')).resolves.toBe(INDOOR_NAVIGATION_DEMO_TARGET);
182
+ });
183
+
184
+ it('实例停用(enabled: false)→ 演示链接(同「无有效配置」行,不做细分判定)', async () => {
185
+ const off = structuredClone(rawConfig);
186
+ (off.services[SLOT].instances['mall-bj'] as { enabled?: boolean }).enabled = false;
187
+ const ctx = makeCtx(parseIntegrationsConfig(off));
188
+ const svc = createIndoorNavigationService(ctx);
189
+ await expect(svc.resolveJumpUrl('mall-bj', 'S1')).resolves.toBe(INDOOR_NAVIGATION_DEMO_TARGET);
190
+ // 未停用商场照常供给真实链接——停用不外溢
191
+ await expect(svc.resolveJumpUrl('mall-sh', 'S1')).resolves.toBe(`${URL_SH}&third_id=S1`);
192
+ });
193
+ });
@@ -0,0 +1,98 @@
1
+ /**
2
+ * 跳转目标合成单元测试(resolveIndoorNavigationTarget——fail-soft 谱收口):
3
+ * - resolveService 入参契约(service 常量 + flat scope {mallId} + 原样 request);
4
+ * - 预期缺席三码(SERVICE_NOT_CONFIGURED / INSTANCE_NOT_FOUND / INSTANCE_DISABLED)→ undefined;
5
+ * - 无商圈 / 门店标识缺失(供给侧 undefined)→ undefined;
6
+ * - registry 缺席与未知错误 fail-visible 原样上抛(装配事故不得静默折损成「未配置」)。
7
+ * 真链路(registry × 实例差异化配置)见 handoff-malls.test.ts;供给 adapter 属 provider 包
8
+ * (本模块零 provider import——workspace-dag 铁律,测试侧 stub 同形)。
9
+ */
10
+ import { describe, expect, it, vi } from 'vitest';
11
+ import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
12
+ import type { RequestContext } from '@tbox.cn/app-contracts';
13
+ import type { IndoorNavigationHandoffPort } from '@tbox.cn/app-contracts-mall';
14
+ import { INDOOR_NAVIGATION_HANDOFF_SERVICE } from '@tbox.cn/app-contracts-mall';
15
+ import { resolveIndoorNavigationTarget } from '../src/server/ports';
16
+
17
+ const stubCtx = (integrations?: unknown): ServerContext =>
18
+ ({ integrations }) as unknown as ServerContext;
19
+
20
+ const reqCtx = (mallId: string): RequestContext => ({
21
+ identity: { userId: 'u', source: 'guest' as const },
22
+ attributes: { mall: { mallId } },
23
+ });
24
+
25
+ const stubPort = (url: string | undefined): IndoorNavigationHandoffPort => ({
26
+ resolveHandoffUrl: vi.fn(async () => url),
27
+ });
28
+
29
+ describe('resolveIndoorNavigationTarget 消费契约(任务 2 接口形状)', () => {
30
+ it('resolveService 入参契约:service 常量 + flat scope {mallId} + request 原样', async () => {
31
+ const resolveService = vi.fn(async () => stubPort('https://nav.example.cn/#/ar_v4?third_id=M1'));
32
+ const ctx = reqCtx('mall-a');
33
+ const got = await resolveIndoorNavigationTarget(ctx, stubCtx({ resolveService }), 'M1');
34
+ expect(got).toBe('https://nav.example.cn/#/ar_v4?third_id=M1');
35
+ expect(resolveService).toHaveBeenCalledWith({
36
+ service: INDOOR_NAVIGATION_HANDOFF_SERVICE,
37
+ scope: { mallId: 'mall-a' },
38
+ request: ctx,
39
+ });
40
+ });
41
+
42
+ it('门店标识缺失 → undefined(消费侧短路——不解析槽、不调 Port;供给侧同判兜底)', async () => {
43
+ const resolveService = vi.fn();
44
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-a'), stubCtx({ resolveService }), '')).resolves.toBeUndefined();
45
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-a'), stubCtx({ resolveService }), ' ')).resolves.toBeUndefined();
46
+ expect(resolveService).not.toHaveBeenCalled();
47
+ });
48
+
49
+ it('供给侧 resolveHandoffUrl 的 undefined 原样透传(配置无效/标识由供给判定)', async () => {
50
+ await expect(
51
+ resolveIndoorNavigationTarget(reqCtx('mall-a'), stubCtx({ resolveService: async () => stubPort(undefined) }), 'M1'),
52
+ ).resolves.toBeUndefined();
53
+ });
54
+ });
55
+
56
+ describe('预期缺席 → undefined(跳转目标是可选增强,非业务错误)', () => {
57
+ it.each([
58
+ ['槽未配置', 'PROVIDER_SERVICE_NOT_CONFIGURED'],
59
+ ['商场实例缺席', 'PROVIDER_INSTANCE_NOT_FOUND'],
60
+ ['商场实例禁用', 'PROVIDER_INSTANCE_DISABLED'],
61
+ ])('%s → undefined', async (_name, code) => {
62
+ await expect(
63
+ resolveIndoorNavigationTarget(
64
+ reqCtx('mall-a'),
65
+ stubCtx({ resolveService: async () => { throw Object.assign(new Error('x'), { code }); } }),
66
+ 'M1',
67
+ ),
68
+ ).resolves.toBeUndefined();
69
+ });
70
+
71
+ it('无商圈 scope → undefined(非业务错误,不进供给链)', async () => {
72
+ const resolveService = vi.fn();
73
+ await expect(
74
+ resolveIndoorNavigationTarget({ identity: { userId: 'u', source: 'guest' as const } }, stubCtx({ resolveService }), 'M1'),
75
+ ).resolves.toBeUndefined();
76
+ expect(resolveService).not.toHaveBeenCalled();
77
+ });
78
+ });
79
+
80
+ describe('装配缺口 fail-visible(与「未配置」区分)', () => {
81
+ it('integrations registry 缺席 → 原样上抛', async () => {
82
+ await expect(resolveIndoorNavigationTarget(reqCtx('mall-a'), stubCtx(undefined), 'M1')).rejects.toThrow(/未装配集成配置/);
83
+ });
84
+
85
+ it.each([
86
+ ['绑定不可解析', 'PROVIDER_BINDING_UNRESOLVED'],
87
+ ['provider 未命中 catalog', 'PROVIDER_NOT_FOUND'],
88
+ ['供给未实施', 'PROVIDER_NOT_IMPLEMENTED'],
89
+ ])('%s → 原样上抛(不折损 undefined)', async (_name, code) => {
90
+ await expect(
91
+ resolveIndoorNavigationTarget(
92
+ reqCtx('mall-a'),
93
+ stubCtx({ resolveService: async () => { throw Object.assign(new Error('x'), { code }); } }),
94
+ 'M1',
95
+ ),
96
+ ).rejects.toMatchObject({ code });
97
+ });
98
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "types": ["node"]
6
+ },
7
+ "include": ["src", "tests"]
8
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: 'src/index.ts',
6
+ 'server/index': 'src/server/index.ts',
7
+ 'client/index': 'src/client/index.ts',
8
+ },
9
+ format: ['esm'],
10
+ target: 'node20',
11
+ platform: 'node',
12
+ outDir: 'dist',
13
+ clean: true,
14
+ sourcemap: false,
15
+ dts: { compilerOptions: { incremental: false } },
16
+ external: [
17
+ '@tbox.cn/app-agent-sdk-client',
18
+ '@tbox.cn/app-agent-ui-kit',
19
+ '@tbox.cn/app-agent-sdk-server',
20
+ '@tbox.cn/app-contracts',
21
+ '@tbox.cn/app-contracts-mall',
22
+ 'react',
23
+ 'react-dom',
24
+ 'zod',
25
+ '@mastra/core',
26
+ 'express',
27
+ ],
28
+ });