@tbox.cn/app-module-mall-core 0.1.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/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 ADDED
@@ -0,0 +1,34 @@
1
+ # @tbox.cn/app-module-mall-core
2
+
3
+ 商圈核心模块(无 UI):**scope 域装配注册** + **mall-info 工具/缓存/preTool** + **mall-directory 服务**。
4
+
5
+ ## 贡献面
6
+
7
+ | 能力 | 通道 | 说明 |
8
+ |---|---|---|
9
+ | 域装配 | `ctx.domainAssemblies.register(SCOPE_ASSEMBLY_KIND, assembly)` | register 期以 `ctx.integrations.raw` 构造(投影 = contracts-mall 纯函数);四消费点(validateContext / scopeSessions / scopeDefaults / instanceIdOf)+ WS 双钩(defaultMallContext / enhanceHelloContext)运行期惰性查表 |
10
+ | mall-info 工具 | `ctx.tools.register` + 声明式 `preTools`(always + mallId 入参化 + silent + dedup) | mall.info 槽消费(缓存 → single-flight → 槽拉取;fail-soft) |
11
+ | mall-directory 服务 | `ctx.services.register('mall-directory', ...)` | 控制平面 malls 单一来源(shopping-guide 近场 / customer-service 客服电话消费) |
12
+
13
+ ## 消费方接线(模板装配点)
14
+
15
+ ```ts
16
+ import { resolveMallScopeAssembly } from '@app/module-mall-core/server';
17
+
18
+ // validateContext / instanceIdOf:auth/registry 构造早于 ctx → 闭包运行期查表
19
+ validateContext: (attributes) => resolveMallScopeAssembly(ctx)?.validateScope(attributes) ?? true,
20
+
21
+ // start()(registerAll 之后):WS/scope 会话装点
22
+ const assembly = resolveMallScopeAssembly(ctx);
23
+ const scopeSessions = assembly ? createScopeSessionRegistry({
24
+ extractScopeKey: (c) => assembly.extractScopeKey(c),
25
+ validateScope: (a) => assembly.validateScope(a),
26
+ buildScope: (a) => assembly.buildScopeWithMallName(a),
27
+ }) : undefined;
28
+ ```
29
+
30
+ 无 integrations 配置(raw 缺席)→ 不注册(`resolve` 返回 undefined,装配点按"无控制面"降级)。
31
+
32
+ ## 依赖约束
33
+
34
+ 只 import contracts/sdk 公开入口;register 纯净(零 IO/零 resolveService);域投影计算全走 contracts-mall 纯函数(`mallControlPlaneOf` / `createMallRuntimeAssembly` / `withMallName`)。
@@ -0,0 +1,267 @@
1
+ // src/server/index.ts
2
+ import { SCOPE_ASSEMBLY_KIND as SCOPE_ASSEMBLY_KIND2 } from "@tbox.cn/app-contracts";
3
+ import { MALL_INFO_CACHE_SERVICE } from "@tbox.cn/app-contracts-mall";
4
+
5
+ // src/server/assembly.ts
6
+ import { createLogger } from "@tbox.cn/app-sdk/server";
7
+ import { SCOPE_ASSEMBLY_KIND } from "@tbox.cn/app-contracts";
8
+ import {
9
+ createMallRuntimeAssembly,
10
+ withMallName
11
+ } from "@tbox.cn/app-contracts-mall";
12
+ import { mallControlPlaneOf } from "@tbox.cn/app-contracts-mall/server";
13
+
14
+ // src/server/mall-info-cache.ts
15
+ var CACHE_TTL_MS = 30 * 60 * 1e3;
16
+ var NEGATIVE_TTL_MS = 5 * 60 * 1e3;
17
+ var CACHE_MAX_ENTRIES = 1024;
18
+ var MALL_ID_RE = /^[\w-]{1,32}$/;
19
+ var cache = /* @__PURE__ */ new Map();
20
+ var inFlight = /* @__PURE__ */ new Map();
21
+ var ANON_REQUEST = {
22
+ identity: { userId: "", source: "anonymous" },
23
+ credentials: { provider: "anonymous", token: "" },
24
+ attributes: {}
25
+ };
26
+ function cachedMallName(mallId) {
27
+ const entry = cache.get(mallId);
28
+ if (!entry || entry.expiresAt <= Date.now()) {
29
+ cache.delete(mallId);
30
+ return void 0;
31
+ }
32
+ return entry.negative ? void 0 : entry.mallInfo?.name;
33
+ }
34
+ async function resolveMallInfoService(mallId, integrations) {
35
+ if (!integrations) return null;
36
+ try {
37
+ const svc = await integrations.resolveService({
38
+ service: "mall.info",
39
+ scope: { mallId },
40
+ request: ANON_REQUEST
41
+ });
42
+ return svc ?? null;
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+ async function resolveMallInfo(mallId, integrations) {
48
+ if (!MALL_ID_RE.test(mallId)) return void 0;
49
+ const entry = cache.get(mallId);
50
+ if (entry && entry.expiresAt > Date.now()) {
51
+ return entry.negative ? void 0 : entry.mallInfo;
52
+ }
53
+ if (entry) cache.delete(mallId);
54
+ const existing = inFlight.get(mallId);
55
+ if (existing) return existing;
56
+ const promise = (async () => {
57
+ const service = await resolveMallInfoService(mallId, integrations);
58
+ if (!service) {
59
+ cache.set(mallId, { negative: true, expiresAt: Date.now() + NEGATIVE_TTL_MS });
60
+ trimCache();
61
+ return void 0;
62
+ }
63
+ try {
64
+ const info = await service.getMallInfo(mallId);
65
+ if (!info) {
66
+ cache.set(mallId, { negative: true, expiresAt: Date.now() + NEGATIVE_TTL_MS });
67
+ } else {
68
+ cache.set(mallId, { mallInfo: info, expiresAt: Date.now() + CACHE_TTL_MS });
69
+ }
70
+ trimCache();
71
+ return info;
72
+ } catch {
73
+ cache.set(mallId, { negative: true, expiresAt: Date.now() + NEGATIVE_TTL_MS });
74
+ trimCache();
75
+ return void 0;
76
+ }
77
+ })();
78
+ inFlight.set(mallId, promise);
79
+ try {
80
+ return await promise;
81
+ } finally {
82
+ inFlight.delete(mallId);
83
+ }
84
+ }
85
+ function trimCache() {
86
+ while (cache.size > CACHE_MAX_ENTRIES) {
87
+ const firstKey = cache.keys().next().value;
88
+ if (firstKey === void 0) break;
89
+ cache.delete(firstKey);
90
+ }
91
+ }
92
+
93
+ // src/server/assembly.ts
94
+ var deploymentLogger = createLogger("DEPLOYMENT");
95
+ var WARM_TIMEOUT_MS = 2e3;
96
+ var NO_DECLARATIONS = Object.freeze({});
97
+ function resolveMallScopeAssembly(ctx) {
98
+ return ctx.domainAssemblies.resolve(SCOPE_ASSEMBLY_KIND);
99
+ }
100
+ function createScopeAssembly(raw, ctx) {
101
+ if (!raw) return void 0;
102
+ const rootMiniAppId = typeof raw.config.config?.miniAppId === "string" && raw.config.config.miniAppId ? raw.config.config.miniAppId : void 0;
103
+ let projectionRef;
104
+ let projection;
105
+ const project = () => {
106
+ const declared = ctx.integrations?.providerInstanceDeclarations?.() ?? NO_DECLARATIONS;
107
+ if (!projection || projectionRef !== declared) {
108
+ const controlPlane = mallControlPlaneOf(raw.config, declared);
109
+ const runtime = createMallRuntimeAssembly(controlPlane);
110
+ projection = {
111
+ controlPlane,
112
+ runtime,
113
+ buildScopeWithMallName: withMallName(runtime, controlPlane, cachedMallName)
114
+ };
115
+ projectionRef = declared;
116
+ }
117
+ return projection;
118
+ };
119
+ return {
120
+ // 数据成员 getter:访问期读投影(mall-home routes / mall-directory 闭包自动生效)
121
+ get controlPlane() {
122
+ return project().controlPlane;
123
+ },
124
+ rootMiniAppId,
125
+ // 函数成员稳定包装(register 期定型——消费方捕获引用恒安全;调用时才读投影)
126
+ extractScopeKey: (c) => project().runtime.extractScopeKey(c),
127
+ validateScope: (a) => project().runtime.validateScope(a),
128
+ extractMallScope: (c) => project().runtime.extractMallScope(c),
129
+ buildScope: (a) => project().runtime.buildScope(a),
130
+ buildScopeWithMallName: (a) => project().buildScopeWithMallName(a),
131
+ instanceIdOf: (scope) => scope["mallId"] ?? "",
132
+ get scopeDefaults() {
133
+ const defaultMallId = project().controlPlane.defaultMallId;
134
+ return defaultMallId ? { defaultMallId } : void 0;
135
+ },
136
+ defaultMallContext() {
137
+ return buildDefaultMallContext(project().controlPlane, rootMiniAppId);
138
+ },
139
+ async enhanceHelloContext(context) {
140
+ const mall = context["mall"];
141
+ const mallId = typeof mall?.mallId === "string" && mall.mallId ? mall.mallId : void 0;
142
+ if (!mallId) return context;
143
+ const nextMall = { ...mall };
144
+ if (!nextMall.miniAppId && rootMiniAppId) {
145
+ nextMall.miniAppId = rootMiniAppId;
146
+ deploymentLogger.warn(`[MALL] HELLO context \u7F3A miniAppId\uFF0C\u6309 root config \u56DE\u586B\uFF08mallId=${mallId}\uFF09`);
147
+ }
148
+ if (!project().controlPlane.malls.some((m) => m.mallId === mallId)) {
149
+ const warm = resolveMallInfo(mallId, ctx.integrations);
150
+ await Promise.race([warm, new Promise((r) => setTimeout(r, WARM_TIMEOUT_MS))]).catch(
151
+ () => void 0
152
+ );
153
+ }
154
+ return { ...context, mall: nextMall };
155
+ }
156
+ };
157
+ }
158
+ function buildDefaultMallContext(controlPlane, rootMiniAppId) {
159
+ if (!controlPlane.defaultMallId) return void 0;
160
+ const mall = controlPlane.malls.find((m) => m.mallId === controlPlane.defaultMallId);
161
+ const miniAppId = rootMiniAppId ?? mall?.miniAppId;
162
+ if (!miniAppId) {
163
+ deploymentLogger.warn(
164
+ `defaultMallId=${controlPlane.defaultMallId} \u65E0 miniAppId \u771F\u6E90\uFF08root config \u4E0E\u53C2\u8003\u8868\u53CC\u7F3A\uFF09\u2014\u2014\u6309 mallId-only \u6CE8\u5165\u9ED8\u8BA4\u5546\u5708`
165
+ );
166
+ }
167
+ return { mall: { mallId: controlPlane.defaultMallId, ...miniAppId ? { miniAppId } : {} } };
168
+ }
169
+
170
+ // src/server/mall-info-tool.ts
171
+ import { createTool } from "@tbox.cn/app-sdk/server";
172
+ import { z } from "zod";
173
+ var ctxRef;
174
+ function bindMallInfoContext(ctx) {
175
+ ctxRef = ctx;
176
+ }
177
+ var mallInfoTool = createTool({
178
+ id: "mall-info",
179
+ description: "\u67E5\u8BE2\u5546\u573A\u57FA\u672C\u4FE1\u606F\uFF08\u540D\u79F0/\u5730\u5740/\u7ECF\u7EAC\u5EA6\uFF09\u3002\u7528\u6237\u95EE\u67D0\u5546\u573A\u53EB\u4EC0\u4E48\u3001\u5728\u54EA\u513F\u3001\u5730\u5740\u65F6\u8C03\u7528\uFF1B\u5F53\u524D\u4F1A\u8BDD\u5546\u573A ID \u53EF\u4ECE mall-info \u6CE8\u5165\u5757\u53D6\u3002",
180
+ // D11 参数规范:纯 string(preTool decide 注入 / 模型直传入参)
181
+ inputSchema: z.object({ mallId: z.string().describe("\u5546\u573A ID") }),
182
+ // 无 outputSchema:可选字段动态形状(对齐 mall-context;出卡工具建议省略的约定此处同理由)
183
+ execute: async (input) => {
184
+ const mallId = typeof input.mallId === "string" ? input.mallId.trim() : "";
185
+ if (!mallId) return { found: false, reason: "mallId \u7F3A\u5931" };
186
+ const info = await resolveMallInfo(mallId, ctxRef?.integrations);
187
+ if (!info) {
188
+ return {
189
+ found: false,
190
+ mallId,
191
+ reason: "\u5546\u573A\u4FE1\u606F\u4E0D\u53EF\u7528\uFF08mall.info \u69FD\u672A\u88C5\u914D/\u672A\u914D\u7F6E/\u672A\u77E5 mallId\uFF09"
192
+ };
193
+ }
194
+ return {
195
+ found: true,
196
+ mallId: info.mallId,
197
+ name: info.name,
198
+ ...info.address ? { address: info.address } : {},
199
+ ...info.latitude != null ? { latitude: info.latitude } : {},
200
+ ...info.longitude != null ? { longitude: info.longitude } : {},
201
+ ...info.cityId ? { cityId: info.cityId } : {}
202
+ };
203
+ }
204
+ });
205
+
206
+ // src/server/pre-tools.ts
207
+ import { definePreTool } from "@tbox.cn/app-sdk/server";
208
+ import { mallSlot } from "@tbox.cn/app-contracts-mall";
209
+ var preTools = {
210
+ "mall-info": definePreTool(mallInfoTool, {
211
+ routing: { mode: "always" },
212
+ // 上下文统一化:连接级领域属性经 decide 入参 attributes 判定(与 mall-context 同通道)
213
+ decide: ({ attributes }) => {
214
+ const scope = mallSlot.read(attributes);
215
+ if (!scope) return { decision: "skip", reason: "\u65E0 mall scope\uFF08attributes \u7F3A\u5E2D/\u89E3\u6790\u5931\u8D25\uFF09" };
216
+ return { decision: "run", args: { mallId: scope.mallId } };
217
+ },
218
+ silent: true,
219
+ dedup: {
220
+ accepts: (result) => result?.found === true
221
+ }
222
+ })
223
+ };
224
+
225
+ // src/server/index.ts
226
+ var serverModule = {
227
+ declaration: {
228
+ moduleId: "mall-core"
229
+ },
230
+ cards: {},
231
+ preTools,
232
+ register(ctx) {
233
+ bindMallInfoContext(ctx);
234
+ const assembly = createScopeAssembly(ctx.integrations?.raw, ctx);
235
+ if (assembly) {
236
+ ctx.domainAssemblies.register(SCOPE_ASSEMBLY_KIND2, assembly);
237
+ ctx.services.register("mall-directory", {
238
+ nearbyMalls: () => assembly.controlPlane.malls.map((m) => ({
239
+ mallId: m.mallId,
240
+ name: m.name,
241
+ address: `${m.name}\uFF08deployment \u914D\u7F6E\uFF09`,
242
+ status: { code: "open", label: "\u8425\u4E1A\u4E2D" }
243
+ })),
244
+ contactPhone: (mallId) => assembly.controlPlane.malls.find((m) => m.mallId === mallId)?.contactPhone
245
+ });
246
+ }
247
+ ctx.services.register(MALL_INFO_CACHE_SERVICE, {
248
+ cachedMallName: (mallId) => cachedMallName(mallId),
249
+ resolveMallInfo: (mallId) => resolveMallInfo(mallId, ctx.integrations)
250
+ });
251
+ ctx.tools.register(mallInfoTool);
252
+ }
253
+ };
254
+ var server_default = serverModule;
255
+
256
+ export {
257
+ cachedMallName,
258
+ resolveMallInfo,
259
+ resolveMallScopeAssembly,
260
+ createScopeAssembly,
261
+ buildDefaultMallContext,
262
+ bindMallInfoContext,
263
+ mallInfoTool,
264
+ preTools,
265
+ serverModule,
266
+ server_default
267
+ };
@@ -0,0 +1,4 @@
1
+ export { bindMallInfoContext, buildDefaultMallContext, cachedMallName, createScopeAssembly, mallInfoTool, preTools, resolveMallInfo, resolveMallScopeAssembly, default as serverModule } from './server/index.js';
2
+ export { MallScopeAssembly } from '@tbox.cn/app-contracts-mall';
3
+ import '@tbox.cn/app-sdk/server';
4
+ import '@mastra/core/tools';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ import {
2
+ bindMallInfoContext,
3
+ buildDefaultMallContext,
4
+ cachedMallName,
5
+ createScopeAssembly,
6
+ mallInfoTool,
7
+ preTools,
8
+ resolveMallInfo,
9
+ resolveMallScopeAssembly,
10
+ serverModule
11
+ } from "./chunk-FBL6MHK5.js";
12
+ export {
13
+ bindMallInfoContext,
14
+ buildDefaultMallContext,
15
+ cachedMallName,
16
+ createScopeAssembly,
17
+ mallInfoTool,
18
+ preTools,
19
+ resolveMallInfo,
20
+ resolveMallScopeAssembly,
21
+ serverModule
22
+ };
@@ -0,0 +1,103 @@
1
+ import * as _tbox_cn_app_sdk_server from '@tbox.cn/app-sdk/server';
2
+ import { IntegrationsRaw, ServerContext, IntegrationsRegistry, PreToolDef } from '@tbox.cn/app-sdk/server';
3
+ import * as _mastra_core_tools from '@mastra/core/tools';
4
+ import { MallDeploymentControlPlane, MallScopeAssembly, MallInfo } from '@tbox.cn/app-contracts-mall';
5
+ export { MallScopeAssembly } from '@tbox.cn/app-contracts-mall';
6
+
7
+ /**
8
+ * mall 域装配(单一模板统一化 W3-1):register 期注册于 `ctx.domainAssemblies`
9
+ * (SCOPE_ASSEMBLY_KIND),全部消费点运行期惰性查表——模板 app.ts 域语义清零。
10
+ *
11
+ * 自 mall 模板 app.ts 装配段 + config/deployment.ts 迁入(语义逐字保留):
12
+ * - 输入 = `ctx.integrations.raw`(原始装载产物;投影计算全走 contracts-mall 纯函数);
13
+ * - 成员 = 四消费点(validateContext / scopeSessions / scopeDefaults / instanceIdOf)
14
+ * + WS 双钩(defaultMallContext / enhanceHelloContext)+ mall-directory 服务数据源。
15
+ *
16
+ * 隐式默认单实例(provider 声明融合):provider 包 register 期经
17
+ * ctx.integrations.declareProviderInstances 声明部署实例;本装配 project() 访问期惰性融合
18
+ * (register 顺序无关——mall-core 先注册仍生效;显式拓扑恒赢,融合规则见 contracts-mall)。
19
+ *
20
+ * instanceIdOf 注入 mall 语义(SDK 零领域铁律——mallId 派生归本模块)。
21
+ */
22
+
23
+ /** 域装配 kind 便捷解析(消费点统一入口——类型锚 = MallScopeAssembly)。 */
24
+ declare function resolveMallScopeAssembly(ctx: ServerContext): MallScopeAssembly | undefined;
25
+ /**
26
+ * 从 integrations 原始装载产物构造域装配(register 期调用;零 IO——投影为纯函数计算)。
27
+ * raw 缺席(无 config/integrations.json)→ undefined(装配点按"无控制面"降级,语义对齐旧模板)。
28
+ *
29
+ * 惰性投影契约:controlPlane/scopeDefaults/defaultMallContext/buildScopeWithMallName
30
+ * 访问期经 project() 求值(声明 ref 缓存——registry COW 快照引用变化才重投影;
31
+ * register 顺序无关——provider 声明晚于本装配注册仍生效)。
32
+ * 函数成员 register 期定型(稳定标识——消费方捕获引用恒安全,调用时才读投影)。
33
+ */
34
+ declare function createScopeAssembly(raw: IntegrationsRaw | undefined, ctx: ServerContext): MallScopeAssembly | undefined;
35
+ /**
36
+ * 016:默认商圈 HELLO context(无 URL 参数访问时的服务端兜底)。
37
+ * v4 mallId-only 注入(D8/D9):miniAppId 是尽力回填的展示值,非会话边界——
38
+ * 读源统一 root config.miniAppId 优先、回落参考表 attributes.miniAppId;双缺不再
39
+ * 阻断注入(此前 warn-refuse 会造成默认商圈静默失效),按 mallId-only 注入。
40
+ * 缺省 defaultMallId → undefined(不兜底)。
41
+ */
42
+ declare function buildDefaultMallContext(controlPlane: MallDeploymentControlPlane, rootMiniAppId?: string): Record<string, unknown> | undefined;
43
+
44
+ /**
45
+ * 商场基础信息缓存(mall.info 槽消费方;动态商场信息源)。
46
+ *
47
+ * 自 mall 模板 config/mall-info.ts 迁入(单一模板统一化 W3-1;语义逐字保留)。
48
+ *
49
+ * 职责:
50
+ * - cachedMallName:withMallName 同步回退通道(会话建立后 mallName 直接回显)
51
+ * - resolveMallInfo:缓存 → single-flight → mall.info 槽拉取;失败/未知 → undefined(fail-soft)
52
+ *
53
+ * 缓存纪律(S1 DoS 加固):
54
+ * - 正缓存 TTL 30min(plaza 信息低频变更)
55
+ * - 负缓存 TTL 5min(垃圾/拉取失败 ID 防重复打上游)
56
+ * - LRU 封顶 1024(Map 插入序近似,可接受)
57
+ * - in-flight 去重(single-flight:并发同 ID 只打一次上游)
58
+ *
59
+ * mallId 形状守卫与 provider 侧同则(双保险,防 path 注入类字符进上游 URL)。
60
+ */
61
+
62
+ /** 缓存名读取(withMallName 同步回退通道;过期/负缓存 → undefined) */
63
+ declare function cachedMallName(mallId: string): string | undefined;
64
+ /**
65
+ * 解析商场信息(缓存 → single-flight → mall.info 槽拉取)。
66
+ * 失败/未知/形状非法 → undefined(调用方负责降级)。
67
+ */
68
+ declare function resolveMallInfo(mallId: string, integrations: IntegrationsRegistry | undefined): Promise<MallInfo | undefined>;
69
+
70
+ /** register 期绑定(模块注册面;测试可显式绑定裸上下文) */
71
+ declare function bindMallInfoContext(ctx: ServerContext | undefined): void;
72
+ declare const mallInfoTool: _mastra_core_tools.Tool<{
73
+ mallId: string;
74
+ }, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "mall-info", unknown>;
75
+
76
+ /**
77
+ * 模块前置工具声明(010 声明式通道;自 mall 模板 pre-tools.ts 迁入——单一模板统一化 W3-1)。
78
+ *
79
+ * mall-info —— 商场基本信息每轮背景注入(mall-context 同款三件套,2026-09-14):
80
+ * always + decide 自 mallSlot.read(attributes) 注入 mallId(B3 入参化——dedup 键随
81
+ * mallId 变更自动换键)+ silent + 会话内 dedup(accepts: found===true——
82
+ * not-found 不落键,下轮重试防钉死;缓存服务负缓存 5min 限流上游)。
83
+ */
84
+ declare const preTools: {
85
+ 'mall-info': PreToolDef<_mastra_core_tools.Tool<{
86
+ mallId: string;
87
+ }, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "mall-info", unknown>>;
88
+ };
89
+
90
+ declare const serverModule: {
91
+ declaration: {
92
+ moduleId: string;
93
+ };
94
+ cards: {};
95
+ preTools: {
96
+ 'mall-info': _tbox_cn_app_sdk_server.PreToolDef<_mastra_core_tools.Tool<{
97
+ mallId: string;
98
+ }, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, "mall-info", unknown>>;
99
+ };
100
+ register(ctx: ServerContext): void;
101
+ };
102
+
103
+ export { bindMallInfoContext, buildDefaultMallContext, cachedMallName, createScopeAssembly, serverModule as default, mallInfoTool, preTools, resolveMallInfo, resolveMallScopeAssembly, serverModule };
@@ -0,0 +1,24 @@
1
+ import {
2
+ bindMallInfoContext,
3
+ buildDefaultMallContext,
4
+ cachedMallName,
5
+ createScopeAssembly,
6
+ mallInfoTool,
7
+ preTools,
8
+ resolveMallInfo,
9
+ resolveMallScopeAssembly,
10
+ serverModule,
11
+ server_default
12
+ } from "../chunk-FBL6MHK5.js";
13
+ export {
14
+ bindMallInfoContext,
15
+ buildDefaultMallContext,
16
+ cachedMallName,
17
+ createScopeAssembly,
18
+ server_default as default,
19
+ mallInfoTool,
20
+ preTools,
21
+ resolveMallInfo,
22
+ resolveMallScopeAssembly,
23
+ serverModule
24
+ };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@tbox.cn/app-module-mall-core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "商圈核心模块:scope 域装配注册(ctx.domainAssemblies)+ mall-info 工具/缓存/preTool + mall-directory 服务(无 UI)。",
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
+ "./package.json": "./package.json"
16
+ },
17
+ "dependencies": {
18
+ "@tbox.cn/app-sdk": "0.19.0",
19
+ "@tbox.cn/app-contracts": "0.10.0",
20
+ "@tbox.cn/app-contracts-mall": "0.10.0"
21
+ },
22
+ "peerDependencies": {
23
+ "zod": "3.25.76"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "24.13.3",
27
+ "typescript": "5.9.3",
28
+ "vitest": "4.1.10",
29
+ "zod": "3.25.76",
30
+ "tsup": "8.5.1"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "src",
35
+ "tests",
36
+ "tbox.module.json",
37
+ "tsconfig.json",
38
+ "tsup.config.ts",
39
+ "README.md",
40
+ "LICENSE"
41
+ ],
42
+ "engines": {
43
+ "node": ">=20.0.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "scripts": {
50
+ "typecheck": "tsc --noEmit",
51
+ "test": "vitest run",
52
+ "build": "tsup"
53
+ }
54
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 模块主入口(package.json exports "." 指向)。
3
+ * 消费方通常走 ./server 子路径;主入口聚合导出便于直接引用。
4
+ * mall-core 无客户端贡献面(UI 归 module-mall-home)。
5
+ */
6
+ export * from './server/index.js';