@tbox.cn/app-toolkit 0.8.1 → 0.8.3

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.
@@ -0,0 +1,99 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ APP_INTEGRATION_NODE_KEYS,
4
+ MODULE_INTEGRATION_NODE_KEYS,
5
+ SERVICE_INTEGRATION_NODE_KEYS,
6
+ SERVICE_INSTANCE_NODE_KEYS,
7
+ } from '../src/dto.js';
8
+
9
+ /**
10
+ * 键集-zod 锁步(0.8.2 降级写批——assertNodeKeys 白名单 ⊆ contracts zod 键集的行为锁):
11
+ * 以真实 @tbox.cn/app-contracts(devDep workspace 态)parseIntegrationsConfig 逐键验证——
12
+ * 常数键全过 zod(证明白名单不隐性收窄 ok 态行为)+ 未知键恰被 zod 拒(证明静态防线与
13
+ * 严格面收敛、降级态无隐性放行)。contracts zod 键集演进(additive)时本测试即锁步哨兵:
14
+ * 常数漏跟 = 红。
15
+ */
16
+
17
+ // dist 在场才锁步(contracts dist 为 gitignore——fresh clone / CI verify 无 build 步骤时 import 必败;
18
+ // 无 contracts 代码 = 无锁步对象,skip 可接受。本地有 dist 或发布链 prepack build 后自动激活)。
19
+ let parseIntegrationsConfig: ((raw: unknown) => unknown) | undefined;
20
+ try {
21
+ parseIntegrationsConfig = ((await import('@tbox.cn/app-contracts')) as {
22
+ parseIntegrationsConfig: (raw: unknown) => unknown;
23
+ }).parseIntegrationsConfig;
24
+ } catch {
25
+ // skip:contracts 未构建
26
+ }
27
+ const expectZodPass = (doc: unknown): void => expect(() => parseIntegrationsConfig!(doc)).not.toThrow();
28
+ const expectZodReject = (doc: unknown): void => expect(() => parseIntegrationsConfig!(doc)).toThrow();
29
+
30
+ describe.skipIf(parseIntegrationsConfig === undefined)('键集-zod 锁步(assertNodeKeys 白名单 ⊆ contracts zod)', () => {
31
+ it('app 节点:APP_INTEGRATION_NODE_KEYS 全键过 zod;未知键被 zod 拒', () => {
32
+ const full: Record<string, unknown> = { services: {} };
33
+ for (const k of APP_INTEGRATION_NODE_KEYS) {
34
+ full[k] =
35
+ k === 'instances'
36
+ ? [{ id: 'mall-bj-01', name: 'bj' }]
37
+ : k === 'defaultInstanceId'
38
+ ? 'mall-bj-01'
39
+ : k === 'provider'
40
+ ? 'mock'
41
+ : k === 'credentialRef'
42
+ ? 'secret://a-b-0'
43
+ : k === 'credentialRefByInstance'
44
+ ? { 'mall-bj-01': 'secret://a-b-0' }
45
+ : k === 'configByInstance'
46
+ ? { 'mall-bj-01': {} }
47
+ : k === '$comment'
48
+ ? 'meta'
49
+ : k === '$schema'
50
+ ? 'https://example.com/schema.json'
51
+ : {};
52
+ }
53
+ expectZodPass(full);
54
+ expectZodReject({ services: {}, unknownKey: 1 });
55
+ });
56
+
57
+ it('service 节点:SERVICE_INTEGRATION_NODE_KEYS 全键过 zod;未知键被 zod 拒', () => {
58
+ const slot: Record<string, unknown> = {};
59
+ for (const k of SERVICE_INTEGRATION_NODE_KEYS) {
60
+ slot[k] =
61
+ k === 'provider'
62
+ ? 'mock'
63
+ : k === 'implementation'
64
+ ? 'mock.impl'
65
+ : k === 'credentialRef'
66
+ ? 'secret://a-b-0'
67
+ : {};
68
+ }
69
+ expectZodPass({ services: { 'x.y': slot } });
70
+ expectZodReject({ services: { 'x.y': { ...slot, unknownKey: 1 } } });
71
+ });
72
+
73
+ it('instance 节点:SERVICE_INSTANCE_NODE_KEYS 全键过 zod;未知键被 zod 拒', () => {
74
+ const inst: Record<string, unknown> = {};
75
+ for (const k of SERVICE_INSTANCE_NODE_KEYS) {
76
+ inst[k] =
77
+ k === 'provider'
78
+ ? 'mock'
79
+ : k === 'implementation'
80
+ ? 'mock.impl'
81
+ : k === 'credentialRef'
82
+ ? 'secret://a-b-0'
83
+ : k === 'enabled'
84
+ ? true
85
+ : {};
86
+ }
87
+ expectZodPass({ services: { 'x.y': { instances: { 'mall-bj-01': inst } } } });
88
+ expectZodReject({ services: { 'x.y': { instances: { 'mall-bj-01': { ...inst, unknownKey: 1 } } } } });
89
+ });
90
+
91
+ it('module 节点:MODULE_INTEGRATION_NODE_KEYS 全键过 zod;未知键被 zod 拒', () => {
92
+ const mod: Record<string, unknown> = {};
93
+ for (const k of MODULE_INTEGRATION_NODE_KEYS) {
94
+ mod[k] = k === 'provider' ? 'mock' : {};
95
+ }
96
+ expectZodPass({ services: {}, modules: { 'module-x': mod } });
97
+ expectZodReject({ services: {}, modules: { 'module-x': { ...mod, unknownKey: 1 } } });
98
+ });
99
+ });
@@ -197,3 +197,15 @@ describe('module-schema(descriptor zod 单源)', () => {
197
197
  }
198
198
  });
199
199
  });
200
+
201
+
202
+ describe('manifest 元键($comment / $schema)', () => {
203
+ it('元键两形态通过(行为惰性)', () => {
204
+ expect(parseModuleDescriptor({ ...BASE_MANIFEST, $comment: '形状: npx --yes @tbox.cn/app-cli schema tbox.module.json' }).ok).toBe(true);
205
+ expect(parseModuleDescriptor({ ...BASE_MANIFEST, $schema: 'x', $comment: { declare: '声明面' } }).ok).toBe(true);
206
+ });
207
+
208
+ it('拼错元键仍被 strict 拒', () => {
209
+ expect(parseModuleDescriptor({ ...BASE_MANIFEST, $coment: 'typo' }).ok).toBe(false);
210
+ });
211
+ });
@@ -467,6 +467,8 @@ describe('views/工厂(O 矩阵核心族)', () => {
467
467
  // 正例:≥0.9 求值可用(harness 默认)
468
468
  const batch = await h.tk.loadServiceResolutions();
469
469
  expect(batch.contracts.strictValidation).toBe(true);
470
+ // 0.8.2 降级写批:echo 投影 obv6 判据(toContractsResolution 单点——前端降级判定镜像源)
471
+ expect(batch.contracts.ownershipBindingV6).toBe(true);
470
472
  h.app.dispose();
471
473
 
472
474
  // 反例:缺 zod 面(0.8.2)→ 读求值轴降级骨架 + N1 升级指引入 statusMessage;静态照常
@@ -481,7 +483,8 @@ describe('views/工厂(O 矩阵核心族)', () => {
481
483
  // 静态永不 503
482
484
  const appView = await low.tk.loadApp();
483
485
  expect(appView.services).toBeInstanceOf(Array);
484
- // 写端点 503 门控保留(policy at edge 收窄至写/迁移面)
486
+ // 写端点 blocked 503 保留(0.8.2 降级写批——version '0.8.2' 非空 = 旧代码在场:503 升级指引不变;
487
+ // version null 态(未装/未构建)降级放行见 write-core 降级写批 describe)
485
488
  await expect(
486
489
  low.tk.writeServiceIntegration('parking.query', { provider: 'mock' }),
487
490
  ).rejects.toMatchObject({ code: 'CONTRACTS_NOT_RESOLVED', httpStatus: 503 });
@@ -1180,7 +1183,7 @@ describe('v6 所有权族(D34 多域钉死退役 → ownedServices/binding 单
1180
1183
  }));
1181
1184
  writeAppFile(app.appDir, 'config/integrations.json', JSON.stringify({ provider: 'mock', services: { 'parking.query': {} } }));
1182
1185
  const tk = createAppToolkit(app.appDir);
1183
- // 写路径门控保留(assertContractsUsable——policy at edge 收窄至写/迁移面)
1186
+ // 写路径 blocked 门控保留(assertWritableContracts——contractsTier 判据单源,偏斜 503 不变)
1184
1187
  await expect(tk.writeModuleIntegration('module-parking', { provider: 'wanda' })).rejects.toMatchObject({
1185
1188
  code: 'CONTRACTS_NOT_RESOLVED',
1186
1189
  httpStatus: 503,
@@ -1189,6 +1192,8 @@ describe('v6 所有权族(D34 多域钉死退役 → ownedServices/binding 单
1189
1192
  // 读求值轴降级(503 退役):statusMessage 与写门控同源(N1 标记分支单源)
1190
1193
  const degraded = await tk.loadServiceResolutions();
1191
1194
  expect(degraded.contracts.strictValidation).toBe(true);
1195
+ // 偏斜态 echo 投影 obv6 = false(三绿假象破除——前端 blocked 判据唯一信号源)
1196
+ expect(degraded.contracts.ownershipBindingV6).toBe(false);
1192
1197
  const entry = degraded.resolutions['parking.query'];
1193
1198
  expect(entry.status).toBe('evaluation-unavailable');
1194
1199
  expect(entry.statusMessage).toMatch(/OWNERSHIP_BINDING_V6 标记缺席/);
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
- import { existsSync, readFileSync } from 'node:fs';
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { createAppToolkit, type AppToolkit } from '../src/factory.js';
5
5
  import { AppToolkitError } from '../src/core/errors.js';
@@ -53,6 +53,25 @@ describe('写核心管线(FX-1c)', () => {
53
53
  h.app.dispose();
54
54
  });
55
55
 
56
+ it('元键保活:种子 $comment 在写路径存活(noDiff 天然相等;根级单点)', async () => {
57
+ writeAppFile(h.app.appDir, INTEGRATIONS_FILE, JSON.stringify({
58
+ $comment: '形状: npx --yes @tbox.cn/app-cli schema config/integrations.json',
59
+ services: {},
60
+ }, null, 2));
61
+ const r = await h.tk.writeAppIntegration({ provider: 'mock-x' } as never);
62
+ expect(r.written).toBe(true);
63
+ const cfg = h.readConfig();
64
+ expect(cfg.$comment).toContain('schema');
65
+ expect(cfg.provider).toBe('mock-x');
66
+ // 同节点重放 → noDiff(元键不参与 diff)
67
+ const r2 = await h.tk.writeAppIntegration({ provider: 'mock-x' } as never);
68
+ expect(r2.written).toBe(false);
69
+ // 仅注释变化的 PUT → 也不写(注释由 current 保全)
70
+ const r3 = await h.tk.writeAppIntegration({ provider: 'mock-x', $comment: '新注释' } as never);
71
+ expect(r3.written).toBe(false);
72
+ expect(h.readConfig().$comment).toContain('schema');
73
+ });
74
+
56
75
  it('T1 writeAppIntegration 节点合并(B1 钉死):node 生效 + dryRun 无 dryRun 键注入 + 回读等价', async () => {
57
76
  const node = {
58
77
  provider: 'mock-x',
@@ -153,8 +172,10 @@ describe('写核心管线(FX-1c)', () => {
153
172
  it('T5 严格校验失败次序(A1):400 VALIDATION_FAILED + message 直通 + 凭据零落盘 + integrations 零变更', async () => {
154
173
  h.app.dispose();
155
174
  h = harness({ rejectMarker: '__reject__' });
175
+ // marker 藏 config 值位(zod 放行内层自由键、由 zod 本体拦截——节点顶层未知键已被
176
+ // assertNodeKeys 静态防线前置 400,见 D4;本用例锁定 zod 拒绝发生于凭据落盘之前)
156
177
  await expect(
157
- h.tk.writeServiceIntegration('parking.query', { provider: 'joycity', __reject__: true } as never, {
178
+ h.tk.writeServiceIntegration('parking.query', { provider: 'joycity', config: { __reject__: true } }, {
158
179
  credentials: { type: 'api-key', values: { apiKey: 'X' } },
159
180
  }),
160
181
  ).rejects.toMatchObject({
@@ -402,3 +423,140 @@ describe('孤儿凭据写后对账(PUT 路径追平——finalize 单点)',
402
423
  expect(nodiff.issues.some((i) => i.code === 'ORPHANED_CREDENTIAL')).toBe(false);
403
424
  });
404
425
  });
426
+
427
+ describe('降级写批(0.8.2 contractsTier——version null 放行 / blocked 保持 503)', () => {
428
+ /** 未安装态模块声明(declare.owns 归属键——服务身份判据命中) */
429
+ const moduleManifest = JSON.stringify({
430
+ schemaVersion: 1,
431
+ id: 'module-parking',
432
+ version: '0.1.0',
433
+ kind: 'business',
434
+ declare: { owns: [{ service: 'parking.query' }] },
435
+ });
436
+
437
+ it('D1 未安装:三 PUT + DELETE 降级成功——STRICT_VALIDATION_SKIPPED warning 随行 + 落盘正确', async () => {
438
+ const app = createTempApp('tbox-degrade-a-');
439
+ writeAppFile(app.appDir, 'packages/module-parking/tbox.module.json', moduleManifest);
440
+ const tk = createAppToolkit(app.appDir);
441
+ // 服务写(身份判据归属键命中;骨架物化 + 降级双 warning 并存)
442
+ const putSvc = await tk.writeServiceIntegration('parking.query', { provider: 'mock' });
443
+ expect(putSvc.written).toBe(true);
444
+ const skip = putSvc.issues.find((i) => i.code === 'STRICT_VALIDATION_SKIPPED');
445
+ expect(skip?.severity).toBe('warning');
446
+ expect(skip?.message).toMatch(/未安装/);
447
+ expect(putSvc.issues.some((i) => i.code === 'SKELETON_MATERIALIZED')).toBe(true);
448
+ expect(JSON.parse(readFileSync(join(app.appDir, INTEGRATIONS_FILE), 'utf8'))).toMatchObject({
449
+ services: { 'parking.query': { provider: 'mock' } },
450
+ });
451
+ // 模块写(v6 modules[owner] 键降级落盘——装 v6 contracts 后语义生效)
452
+ const putMod = await tk.writeModuleIntegration('module-parking', { provider: 'wanda' });
453
+ expect(putMod.written).toBe(true);
454
+ expect(putMod.issues.some((i) => i.code === 'STRICT_VALIDATION_SKIPPED')).toBe(true);
455
+ expect(JSON.parse(readFileSync(join(app.appDir, INTEGRATIONS_FILE), 'utf8'))).toMatchObject({
456
+ modules: { 'module-parking': { provider: 'wanda' } },
457
+ });
458
+ // root 写
459
+ const putApp = await tk.writeAppIntegration({ provider: 'mock' });
460
+ expect(putApp.written).toBe(true);
461
+ expect(putApp.issues.some((i) => i.code === 'STRICT_VALIDATION_SKIPPED')).toBe(true);
462
+ // DELETE 降级
463
+ const del = await tk.deleteServiceIntegration('parking.query');
464
+ expect(del.written).toBe(true);
465
+ app.dispose();
466
+ });
467
+
468
+ it('D2 源码态未构建(候选在场无产物):降级放行 + message 构建指引', async () => {
469
+ const app = createTempApp('tbox-degrade-b-');
470
+ // 手动候选:package.json 在场、dist/src 双缺(writeFakeContractsPackage withDist:false 落
471
+ // src/runtime.ts——vitest TS-host 可导入不构成未构建态,故手动构造 'none' 产物态)
472
+ const cand = join(app.appDir, 'apps', 'server', 'node_modules', '@tbox.cn', 'app-contracts');
473
+ mkdirSync(cand, { recursive: true });
474
+ writeFileSync(
475
+ join(cand, 'package.json'),
476
+ `${JSON.stringify({ name: '@tbox.cn/app-contracts', version: '0.13.0', type: 'module' }, null, 2)}\n`,
477
+ );
478
+ writeAppFile(app.appDir, 'packages/module-parking/tbox.module.json', moduleManifest);
479
+ const tk = createAppToolkit(app.appDir);
480
+ const put = await tk.writeServiceIntegration('parking.query', { provider: 'mock' });
481
+ expect(put.written).toBe(true);
482
+ const skip = put.issues.find((i) => i.code === 'STRICT_VALIDATION_SKIPPED');
483
+ expect(skip?.message).toMatch(/build 后重试/);
484
+ app.dispose();
485
+ });
486
+
487
+ it('D3 dryRun 对称(降级态彩排):零落盘 + files 预览 + warning 随行', async () => {
488
+ const app = createTempApp('tbox-degrade-c-');
489
+ writeAppFile(app.appDir, 'packages/module-parking/tbox.module.json', moduleManifest);
490
+ const tk = createAppToolkit(app.appDir);
491
+ const dry = await tk.writeServiceIntegration('parking.query', { provider: 'mock' }, { dryRun: true });
492
+ expect(dry.written).toBe(false);
493
+ expect(dry.files).toContain(INTEGRATIONS_FILE);
494
+ expect(existsSync(join(app.appDir, INTEGRATIONS_FILE))).toBe(false);
495
+ expect(dry.issues.some((i) => i.code === 'STRICT_VALIDATION_SKIPPED')).toBe(true);
496
+ app.dispose();
497
+ });
498
+
499
+ it('D4 键集纪律两态一致(assertNodeKeys 单点):降级态未知键 400 唯一防线;ok 态同码先行', async () => {
500
+ // 降级态(未安装)
501
+ const app = createTempApp('tbox-degrade-d-');
502
+ writeAppFile(app.appDir, 'packages/module-parking/tbox.module.json', moduleManifest);
503
+ const tk = createAppToolkit(app.appDir);
504
+ // 服务节点未知键(fields 单键粒度——原 applyModule 行为保持)
505
+ await expect(tk.writeServiceIntegration('parking.query', { provider: 'mock', typoKey: 1 } as never))
506
+ .rejects.toMatchObject({ code: 'VALIDATION_FAILED', httpStatus: 400, fields: ['typoKey'] });
507
+ // 实例位未知键
508
+ await expect(tk.writeServiceIntegration('parking.query', { instances: { '*': { typoKey: 1 } } } as never))
509
+ .rejects.toMatchObject({ code: 'VALIDATION_FAILED', fields: ['typoKey'] });
510
+ // root 未知键
511
+ await expect(tk.writeAppIntegration({ typoKey: 1 } as never))
512
+ .rejects.toMatchObject({ code: 'VALIDATION_FAILED', fields: ['typoKey'] });
513
+ // 模块位未知键(既有纪律迁移 assertNodeKeys——同码保持)
514
+ await expect(tk.writeModuleIntegration('module-parking', { typoKey: 1 } as never))
515
+ .rejects.toMatchObject({ code: 'VALIDATION_FAILED', fields: ['typoKey'] });
516
+ app.dispose();
517
+ // ok 态:静态防线先于 zod(同码 400)
518
+ const h2 = harness();
519
+ await expect(h2.tk.writeServiceIntegration('parking.query', { typoKey: 1 } as never))
520
+ .rejects.toMatchObject({ code: 'VALIDATION_FAILED', httpStatus: 400 });
521
+ h2.app.dispose();
522
+ });
523
+
524
+ it('D5 evaluate 门控严选保持(tier !== \'ok\' → 503):未安装态 evaluateIntegrationServices 拒绝(求值产物即求值结果,无降级语义)', async () => {
525
+ const app = createTempApp('tbox-degrade-e-');
526
+ writeAppFile(app.appDir, 'packages/module-parking/tbox.module.json', moduleManifest);
527
+ const tk = createAppToolkit(app.appDir);
528
+ await expect(
529
+ tk.evaluateIntegrationServices({
530
+ integrations: { services: {} },
531
+ suppliedProviders: {},
532
+ demandedServices: [],
533
+ } as never),
534
+ ).rejects.toMatchObject({ code: 'CONTRACTS_NOT_RESOLVED', httpStatus: 503 });
535
+ app.dispose();
536
+ });
537
+
538
+ it('I1 两 internals 写面摘门(行为不随 contracts 状态分叉):未安装态 ensureMockBindings 物化 + writeIntegrationsConfig 透传成功', async () => {
539
+ const app = createTempApp('tbox-degrade-f-');
540
+ // local:true 槽(ensureMockBindings 派生源——单厂商 terse 形态)
541
+ writeAppFile(app.appDir, 'packages/module-x/tbox.module.json', JSON.stringify({
542
+ schemaVersion: 1,
543
+ id: 'module-x',
544
+ version: '0.1.0',
545
+ kind: 'business',
546
+ declare: {
547
+ owns: [{ service: 'ghost.owned' }],
548
+ consumes: [],
549
+ providers: { slots: [{ service: 'ghost.owned', provider: 'mock', implementation: 'mock.ghost', credentialType: '-', local: true }] },
550
+ },
551
+ }));
552
+ const tk = createAppToolkit(app.appDir);
553
+ // ensureMockBindings:integrations.json 缺席 + local 槽 → 物化 mock 绑定(原 blanket 503 门已摘)
554
+ const mb = await tk.ensureMockBindings();
555
+ expect(mb).toMatchObject({ generated: true, reason: 'generated', services: ['ghost.owned'] });
556
+ expect(existsSync(join(app.appDir, INTEGRATIONS_FILE))).toBe(true);
557
+ // writeIntegrationsConfig:文件级整写透传(零校验零门——形状兼容性责任在调用方)
558
+ await tk.writeIntegrationsConfig({ provider: 'mock', services: {} });
559
+ expect(JSON.parse(readFileSync(join(app.appDir, INTEGRATIONS_FILE), 'utf8'))).toMatchObject({ provider: 'mock' });
560
+ app.dispose();
561
+ });
562
+ });
@@ -1 +0,0 @@
1
- import{existsSync as l,readdirSync as x,realpathSync as m}from"fs";import{join as c}from"path";import{pathToFileURL as F}from"url";import{existsSync as T,readFileSync as k,statSync as M}from"fs";function p(){let n=new Map,e=0;function r(t){if(!T(t))return null;let i=M(t);return`${i.mtimeMs}:${i.size}`}return{read(t,i){let o=r(t);if(o===null){n.delete(t);return}let s=n.get(t);if(s&&s.fingerprint===o)return s.value;e+=1;let a=i(k(t,"utf8"));return n.set(t,{fingerprint:o,value:a}),a},invalidate(t){if(t===void 0){n.clear();return}for(let i of t)n.delete(i)},get parseCount(){return e}}}var g=["resolveEffectiveService","buildSupplyLookup","moduleDomainOf","normalizeInstances","RESOURCE_TYPE_IDS"],N="parseIntegrationsConfig",O="OWNERSHIP_BINDING_V6",v={version:null,evaluation:!1,strictValidation:!1,ownershipBindingV6:!1,module:{},notes:[]};function C(n){let e=[n];for(let r of["apps","packages"]){let t=c(n,r);if(!l(t))continue;let i=x(t,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);r==="apps"?i.sort((o,s)=>o==="server"?-1:s==="server"?1:o.localeCompare(s)):i.sort((o,s)=>o.localeCompare(s));for(let o of i)e.push(c(t,o))}return e}var d=new Map,h=p();function y(n){return h.read(n,e=>{let r=JSON.parse(e);return typeof r.version=="string"?r.version:null})??null}function b(n){if(!l(n))return"gone";let e;try{e=m(n)}catch{e=n}return l(c(e,"dist","runtime.js"))?"dist":l(c(e,"src","runtime.ts"))?"src":"none"}function R(n){let e=c(n,"package.json");return{pkgPath:e,candidateDir:n,version:y(e),artifact:b(n)}}function E(n){for(let e of C(n)){let r=c(e,"node_modules","@tbox.cn","app-contracts"),t=c(r,"package.json");if(l(t))return{pkgPath:t,candidateDir:r,version:y(t),artifact:b(r)}}return null}function u(n){return n===null?"none":`${n.pkgPath}|${n.version??"null"}|${n.artifact}`}function _(n,e){let r=E(n);if(u(r)!==u(e.first))return!1;if(e.resolved===null)return!0;let t=r!==null&&r.candidateDir===e.resolved.candidateDir?r:R(e.resolved.candidateDir);return u(t)===u(e.resolved)}async function $(n,e){if(!l(n))return null;let r;try{r=m(n)}catch{return null}let i=[c(r,"dist","runtime.js"),c(r,"src","runtime.ts")].find(s=>l(s)),o=h.read(c(n,"package.json"),s=>{let a=JSON.parse(s);return typeof a.version=="string"?a.version:null})??null;if(i===void 0)return e.push(`contracts ${o??"(版本未知)"} 探测命中但无构建产物(dist/runtime.js 缺失)——workspace 源码态未构建:执行 pnpm --filter @tbox.cn/app-contracts build 后重试`),null;try{let s=o!==null?`?v=${encodeURIComponent(o)}`:"",a=await import(F(i).href+s),f=g.every(w=>a[w]!==void 0),P=a[N]!==void 0,S=a[O]===!0;return{version:o,evaluation:f,strictValidation:P,ownershipBindingV6:S,module:a,notes:f?[]:[`${i} 命中但求值面具名导出缺席(${g.join("/")})——契约包形态异常`]}}catch(s){return e.push(`contracts ${o??"(版本未知)"} 构建产物导入失败(${s instanceof Error?s.message:String(s)})——workspace 源码态未构建或产物损坏:执行 pnpm --filter @tbox.cn/app-contracts build 后重试`),null}}function L(n){let e=d.get(n);if(e&&_(n,e))return e.promise;let r=E(n),t={promise:Promise.resolve({...v}),first:r,resolved:r};return t.promise=(async()=>{let i=[];for(let o of C(n)){let s=c(o,"node_modules","@tbox.cn","app-contracts"),a=await $(s,i);if(a)return a.version!==null&&!a.strictValidation&&a.notes.push(`contracts ${a.version} 无严格校验面(需 ≥0.9.0)——升级应用 @tbox.cn/app-contracts 依赖后可用`),t.resolved=R(s),a}return t.resolved=null,i.length===0&&i.push("contracts 不可解析(未安装)——检查应用依赖安装后重试"),{...v,notes:i}})(),d.set(n,t),t.promise}function H(n){n===void 0?d.clear():d.delete(n)}export{p as a,L as b,H as c};
@@ -1 +0,0 @@
1
- import{b as a,c as b}from"./chunk-WUULQDOV.js";export{b as invalidateContractsResolver,a as resolveContractsForApp};