@tbox.cn/app-toolkit 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 +21 -0
- package/README.md +50 -0
- package/dist/chunk-VV3ERZXS.js +1 -0
- package/dist/contracts-resolver-QM4FBQQV.js +1 -0
- package/dist/index.d.ts +1909 -0
- package/dist/index.js +8 -0
- package/package.json +47 -0
- package/src/assembly/app-manifest.ts +132 -0
- package/src/assembly/provider-catalog.ts +167 -0
- package/src/assembly/walk-manifests.ts +461 -0
- package/src/core/contracts-expected.ts +31 -0
- package/src/core/contracts-resolver.ts +274 -0
- package/src/core/credential-format.ts +98 -0
- package/src/core/credential-mask.ts +19 -0
- package/src/core/env-expansion.ts +51 -0
- package/src/core/errors.ts +46 -0
- package/src/core/file-cache.ts +65 -0
- package/src/core/fskit.ts +21 -0
- package/src/core/module-schema.ts +139 -0
- package/src/dto.ts +298 -0
- package/src/factory.ts +297 -0
- package/src/index.ts +137 -0
- package/src/integrations/credentials.ts +153 -0
- package/src/integrations/mock-bindings.ts +55 -0
- package/src/integrations/predicate-io.ts +199 -0
- package/src/integrations/predicate.ts +598 -0
- package/src/integrations/read.ts +53 -0
- package/src/integrations/write.ts +448 -0
- package/src/views/app.ts +28 -0
- package/src/views/context.ts +70 -0
- package/src/views/modules.ts +48 -0
- package/src/views/providers.ts +165 -0
- package/src/views/service-detail.ts +32 -0
- package/src/views/service-resolutions.ts +323 -0
- package/tests/contracts-resolver.test.ts +203 -0
- package/tests/demo-app.ts +146 -0
- package/tests/dev-manifest-catalog.test.ts +114 -0
- package/tests/error-name-safety.test.ts +26 -0
- package/tests/file-cache.test.ts +242 -0
- package/tests/import-layers.test.ts +111 -0
- package/tests/module-schema.test.ts +84 -0
- package/tests/naming-alignment.test.ts +50 -0
- package/tests/views.test.ts +427 -0
- package/tests/write-core.test.ts +188 -0
- package/tsconfig.json +11 -0
- package/tsup.config.ts +29 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1909 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* tbox.module.json schema v1(001 §3.6 字段名,003 §4.1 schema v1 定版)。
|
|
5
|
+
* app-toolkit 单一校验源(自 CLI module-schema.ts 迁入;CLI 经 re-export 消费)。
|
|
6
|
+
*
|
|
7
|
+
* 迁移改造(ai-build C2-5):
|
|
8
|
+
* - resourceNeedContribSchema 的 type 由 `z.enum(RESOURCE_TYPE_IDS)` 放宽为 `z.string()`——
|
|
9
|
+
* 词汇校验移谓词、经 contracts 动态解析取 RESOURCE_TYPE_IDS(比静态 enum 更忠实应用版本);
|
|
10
|
+
* - demand meta additive:serviceNeedContribSchema 增 title?/description?(服务展示元数据,
|
|
11
|
+
* manifest demand 侧 additive 扩展,catalog 聚合顺带携带——api.md ServiceDemand 对齐);
|
|
12
|
+
* - 安全钉子(H9b):provider 名与 instance id 进凭据 stem 派生,字符集 pattern
|
|
13
|
+
* `/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/` 为第一道防线(stem 派生处另有断言防线——纵深防御)。
|
|
14
|
+
*/
|
|
15
|
+
/** 输入字符集(安全钉子①):provider 名 / instanceId 恒经此 pattern(进凭据 stem 派生的输入) */
|
|
16
|
+
declare const SAFE_NAME_PATTERN: RegExp;
|
|
17
|
+
declare const cardContribSchema: z.ZodObject<{
|
|
18
|
+
cardType: z.ZodString;
|
|
19
|
+
schemaVersion: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
cardType: string;
|
|
22
|
+
schemaVersion?: number | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
cardType: string;
|
|
25
|
+
schemaVersion?: number | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
declare const pageContribSchema: z.ZodObject<{
|
|
28
|
+
route: z.ZodString;
|
|
29
|
+
component: z.ZodString;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
route: string;
|
|
32
|
+
component: string;
|
|
33
|
+
}, {
|
|
34
|
+
route: string;
|
|
35
|
+
component: string;
|
|
36
|
+
}>;
|
|
37
|
+
declare const tabContribSchema: z.ZodObject<{
|
|
38
|
+
route: z.ZodString;
|
|
39
|
+
label: z.ZodOptional<z.ZodString>;
|
|
40
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
41
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
route: string;
|
|
44
|
+
label?: string | undefined;
|
|
45
|
+
icon?: string | undefined;
|
|
46
|
+
order?: number | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
route: string;
|
|
49
|
+
label?: string | undefined;
|
|
50
|
+
icon?: string | undefined;
|
|
51
|
+
order?: number | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
declare const moduleDependencySchema: z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
range: z.ZodOptional<z.ZodString>;
|
|
56
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
id: string;
|
|
59
|
+
required: boolean;
|
|
60
|
+
range?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
id: string;
|
|
63
|
+
range?: string | undefined;
|
|
64
|
+
required?: boolean | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
/** provider 供给槽声明(integrations v2:contributes.providers.slots 元素;
|
|
67
|
+
* provider = 厂商名(catalog 嵌套第一轴)、implementation = 'id@version'(第二轴)) */
|
|
68
|
+
declare const providerSlotContribSchema: z.ZodObject<{
|
|
69
|
+
service: z.ZodString;
|
|
70
|
+
provider: z.ZodString;
|
|
71
|
+
implementation: z.ZodString;
|
|
72
|
+
credentialType: z.ZodString;
|
|
73
|
+
local: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
configSchema: z.ZodOptional<z.ZodString>;
|
|
75
|
+
credentialSchema: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
service: string;
|
|
78
|
+
provider: string;
|
|
79
|
+
implementation: string;
|
|
80
|
+
credentialType: string;
|
|
81
|
+
local?: boolean | undefined;
|
|
82
|
+
configSchema?: string | undefined;
|
|
83
|
+
credentialSchema?: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
service: string;
|
|
86
|
+
provider: string;
|
|
87
|
+
implementation: string;
|
|
88
|
+
credentialType: string;
|
|
89
|
+
local?: boolean | undefined;
|
|
90
|
+
configSchema?: string | undefined;
|
|
91
|
+
credentialSchema?: string | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
/** 服务需求槽声明(contributes.services 元素;业务模块声明消费——catalog 需求侧聚合源) */
|
|
94
|
+
declare const serviceNeedContribSchema: z.ZodObject<{
|
|
95
|
+
service: z.ZodString;
|
|
96
|
+
optional: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
defaults: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
98
|
+
provider: z.ZodString;
|
|
99
|
+
implementation: z.ZodString;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
provider: string;
|
|
102
|
+
implementation: string;
|
|
103
|
+
}, {
|
|
104
|
+
provider: string;
|
|
105
|
+
implementation: string;
|
|
106
|
+
}>, "many">>;
|
|
107
|
+
title: z.ZodOptional<z.ZodString>;
|
|
108
|
+
description: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
service: string;
|
|
111
|
+
optional: boolean;
|
|
112
|
+
defaults: {
|
|
113
|
+
provider: string;
|
|
114
|
+
implementation: string;
|
|
115
|
+
}[];
|
|
116
|
+
title?: string | undefined;
|
|
117
|
+
description?: string | undefined;
|
|
118
|
+
}, {
|
|
119
|
+
service: string;
|
|
120
|
+
optional?: boolean | undefined;
|
|
121
|
+
defaults?: {
|
|
122
|
+
provider: string;
|
|
123
|
+
implementation: string;
|
|
124
|
+
}[] | undefined;
|
|
125
|
+
title?: string | undefined;
|
|
126
|
+
description?: string | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
/** 资源需求声明(contributes.resources 元素;type 放宽为 string——词汇校验移谓词经 resolver 取词表) */
|
|
129
|
+
declare const resourceNeedContribSchema: z.ZodObject<{
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
type: z.ZodString;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
type: string;
|
|
134
|
+
id: string;
|
|
135
|
+
}, {
|
|
136
|
+
type: string;
|
|
137
|
+
id: string;
|
|
138
|
+
}>;
|
|
139
|
+
declare const moduleDescriptorSchema: z.ZodObject<{
|
|
140
|
+
schemaVersion: z.ZodDefault<z.ZodNumber>;
|
|
141
|
+
name: z.ZodString;
|
|
142
|
+
version: z.ZodDefault<z.ZodString>;
|
|
143
|
+
kind: z.ZodDefault<z.ZodEnum<["platform", "business", "third-party"]>>;
|
|
144
|
+
risk: z.ZodDefault<z.ZodObject<{
|
|
145
|
+
level: z.ZodDefault<z.ZodEnum<["high", "medium", "low"]>>;
|
|
146
|
+
writeBoundary: z.ZodDefault<z.ZodEnum<["sdk-enforced", "source"]>>;
|
|
147
|
+
}, "strip", z.ZodTypeAny, {
|
|
148
|
+
level: "high" | "medium" | "low";
|
|
149
|
+
writeBoundary: "sdk-enforced" | "source";
|
|
150
|
+
}, {
|
|
151
|
+
level?: "high" | "medium" | "low" | undefined;
|
|
152
|
+
writeBoundary?: "sdk-enforced" | "source" | undefined;
|
|
153
|
+
}>>;
|
|
154
|
+
distribution: z.ZodDefault<z.ZodObject<{
|
|
155
|
+
defaultMode: z.ZodDefault<z.ZodEnum<["hybrid", "sdk", "codegen", "local"]>>;
|
|
156
|
+
}, "strip", z.ZodTypeAny, {
|
|
157
|
+
defaultMode: "local" | "hybrid" | "sdk" | "codegen";
|
|
158
|
+
}, {
|
|
159
|
+
defaultMode?: "local" | "hybrid" | "sdk" | "codegen" | undefined;
|
|
160
|
+
}>>;
|
|
161
|
+
contributes: z.ZodDefault<z.ZodObject<{
|
|
162
|
+
handlers: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
163
|
+
tools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
164
|
+
cards: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
165
|
+
cardType: z.ZodString;
|
|
166
|
+
schemaVersion: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
cardType: string;
|
|
169
|
+
schemaVersion?: number | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
cardType: string;
|
|
172
|
+
schemaVersion?: number | undefined;
|
|
173
|
+
}>, "many">>;
|
|
174
|
+
routes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
175
|
+
pages: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
176
|
+
route: z.ZodString;
|
|
177
|
+
component: z.ZodString;
|
|
178
|
+
}, "strip", z.ZodTypeAny, {
|
|
179
|
+
route: string;
|
|
180
|
+
component: string;
|
|
181
|
+
}, {
|
|
182
|
+
route: string;
|
|
183
|
+
component: string;
|
|
184
|
+
}>, "many">>;
|
|
185
|
+
tabs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
186
|
+
route: z.ZodString;
|
|
187
|
+
label: z.ZodOptional<z.ZodString>;
|
|
188
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
189
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
190
|
+
}, "strip", z.ZodTypeAny, {
|
|
191
|
+
route: string;
|
|
192
|
+
label?: string | undefined;
|
|
193
|
+
icon?: string | undefined;
|
|
194
|
+
order?: number | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
route: string;
|
|
197
|
+
label?: string | undefined;
|
|
198
|
+
icon?: string | undefined;
|
|
199
|
+
order?: number | undefined;
|
|
200
|
+
}>, "many">>;
|
|
201
|
+
providers: z.ZodDefault<z.ZodObject<{
|
|
202
|
+
slots: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
203
|
+
service: z.ZodString;
|
|
204
|
+
provider: z.ZodString;
|
|
205
|
+
implementation: z.ZodString;
|
|
206
|
+
credentialType: z.ZodString;
|
|
207
|
+
local: z.ZodOptional<z.ZodBoolean>;
|
|
208
|
+
configSchema: z.ZodOptional<z.ZodString>;
|
|
209
|
+
credentialSchema: z.ZodOptional<z.ZodString>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
service: string;
|
|
212
|
+
provider: string;
|
|
213
|
+
implementation: string;
|
|
214
|
+
credentialType: string;
|
|
215
|
+
local?: boolean | undefined;
|
|
216
|
+
configSchema?: string | undefined;
|
|
217
|
+
credentialSchema?: string | undefined;
|
|
218
|
+
}, {
|
|
219
|
+
service: string;
|
|
220
|
+
provider: string;
|
|
221
|
+
implementation: string;
|
|
222
|
+
credentialType: string;
|
|
223
|
+
local?: boolean | undefined;
|
|
224
|
+
configSchema?: string | undefined;
|
|
225
|
+
credentialSchema?: string | undefined;
|
|
226
|
+
}>, "many">>;
|
|
227
|
+
}, "strip", z.ZodTypeAny, {
|
|
228
|
+
slots: {
|
|
229
|
+
service: string;
|
|
230
|
+
provider: string;
|
|
231
|
+
implementation: string;
|
|
232
|
+
credentialType: string;
|
|
233
|
+
local?: boolean | undefined;
|
|
234
|
+
configSchema?: string | undefined;
|
|
235
|
+
credentialSchema?: string | undefined;
|
|
236
|
+
}[];
|
|
237
|
+
}, {
|
|
238
|
+
slots?: {
|
|
239
|
+
service: string;
|
|
240
|
+
provider: string;
|
|
241
|
+
implementation: string;
|
|
242
|
+
credentialType: string;
|
|
243
|
+
local?: boolean | undefined;
|
|
244
|
+
configSchema?: string | undefined;
|
|
245
|
+
credentialSchema?: string | undefined;
|
|
246
|
+
}[] | undefined;
|
|
247
|
+
}>>;
|
|
248
|
+
services: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
249
|
+
service: z.ZodString;
|
|
250
|
+
optional: z.ZodDefault<z.ZodBoolean>;
|
|
251
|
+
defaults: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
252
|
+
provider: z.ZodString;
|
|
253
|
+
implementation: z.ZodString;
|
|
254
|
+
}, "strip", z.ZodTypeAny, {
|
|
255
|
+
provider: string;
|
|
256
|
+
implementation: string;
|
|
257
|
+
}, {
|
|
258
|
+
provider: string;
|
|
259
|
+
implementation: string;
|
|
260
|
+
}>, "many">>;
|
|
261
|
+
title: z.ZodOptional<z.ZodString>;
|
|
262
|
+
description: z.ZodOptional<z.ZodString>;
|
|
263
|
+
}, "strip", z.ZodTypeAny, {
|
|
264
|
+
service: string;
|
|
265
|
+
optional: boolean;
|
|
266
|
+
defaults: {
|
|
267
|
+
provider: string;
|
|
268
|
+
implementation: string;
|
|
269
|
+
}[];
|
|
270
|
+
title?: string | undefined;
|
|
271
|
+
description?: string | undefined;
|
|
272
|
+
}, {
|
|
273
|
+
service: string;
|
|
274
|
+
optional?: boolean | undefined;
|
|
275
|
+
defaults?: {
|
|
276
|
+
provider: string;
|
|
277
|
+
implementation: string;
|
|
278
|
+
}[] | undefined;
|
|
279
|
+
title?: string | undefined;
|
|
280
|
+
description?: string | undefined;
|
|
281
|
+
}>, "many">>;
|
|
282
|
+
resources: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
283
|
+
id: z.ZodString;
|
|
284
|
+
type: z.ZodString;
|
|
285
|
+
}, "strip", z.ZodTypeAny, {
|
|
286
|
+
type: string;
|
|
287
|
+
id: string;
|
|
288
|
+
}, {
|
|
289
|
+
type: string;
|
|
290
|
+
id: string;
|
|
291
|
+
}>, "many">>;
|
|
292
|
+
}, "strip", z.ZodTypeAny, {
|
|
293
|
+
handlers: string[];
|
|
294
|
+
tools: string[];
|
|
295
|
+
cards: {
|
|
296
|
+
cardType: string;
|
|
297
|
+
schemaVersion?: number | undefined;
|
|
298
|
+
}[];
|
|
299
|
+
routes: string[];
|
|
300
|
+
pages: {
|
|
301
|
+
route: string;
|
|
302
|
+
component: string;
|
|
303
|
+
}[];
|
|
304
|
+
tabs: {
|
|
305
|
+
route: string;
|
|
306
|
+
label?: string | undefined;
|
|
307
|
+
icon?: string | undefined;
|
|
308
|
+
order?: number | undefined;
|
|
309
|
+
}[];
|
|
310
|
+
providers: {
|
|
311
|
+
slots: {
|
|
312
|
+
service: string;
|
|
313
|
+
provider: string;
|
|
314
|
+
implementation: string;
|
|
315
|
+
credentialType: string;
|
|
316
|
+
local?: boolean | undefined;
|
|
317
|
+
configSchema?: string | undefined;
|
|
318
|
+
credentialSchema?: string | undefined;
|
|
319
|
+
}[];
|
|
320
|
+
};
|
|
321
|
+
services: {
|
|
322
|
+
service: string;
|
|
323
|
+
optional: boolean;
|
|
324
|
+
defaults: {
|
|
325
|
+
provider: string;
|
|
326
|
+
implementation: string;
|
|
327
|
+
}[];
|
|
328
|
+
title?: string | undefined;
|
|
329
|
+
description?: string | undefined;
|
|
330
|
+
}[];
|
|
331
|
+
resources: {
|
|
332
|
+
type: string;
|
|
333
|
+
id: string;
|
|
334
|
+
}[];
|
|
335
|
+
}, {
|
|
336
|
+
handlers?: string[] | undefined;
|
|
337
|
+
tools?: string[] | undefined;
|
|
338
|
+
cards?: {
|
|
339
|
+
cardType: string;
|
|
340
|
+
schemaVersion?: number | undefined;
|
|
341
|
+
}[] | undefined;
|
|
342
|
+
routes?: string[] | undefined;
|
|
343
|
+
pages?: {
|
|
344
|
+
route: string;
|
|
345
|
+
component: string;
|
|
346
|
+
}[] | undefined;
|
|
347
|
+
tabs?: {
|
|
348
|
+
route: string;
|
|
349
|
+
label?: string | undefined;
|
|
350
|
+
icon?: string | undefined;
|
|
351
|
+
order?: number | undefined;
|
|
352
|
+
}[] | undefined;
|
|
353
|
+
providers?: {
|
|
354
|
+
slots?: {
|
|
355
|
+
service: string;
|
|
356
|
+
provider: string;
|
|
357
|
+
implementation: string;
|
|
358
|
+
credentialType: string;
|
|
359
|
+
local?: boolean | undefined;
|
|
360
|
+
configSchema?: string | undefined;
|
|
361
|
+
credentialSchema?: string | undefined;
|
|
362
|
+
}[] | undefined;
|
|
363
|
+
} | undefined;
|
|
364
|
+
services?: {
|
|
365
|
+
service: string;
|
|
366
|
+
optional?: boolean | undefined;
|
|
367
|
+
defaults?: {
|
|
368
|
+
provider: string;
|
|
369
|
+
implementation: string;
|
|
370
|
+
}[] | undefined;
|
|
371
|
+
title?: string | undefined;
|
|
372
|
+
description?: string | undefined;
|
|
373
|
+
}[] | undefined;
|
|
374
|
+
resources?: {
|
|
375
|
+
type: string;
|
|
376
|
+
id: string;
|
|
377
|
+
}[] | undefined;
|
|
378
|
+
}>>;
|
|
379
|
+
dependencies: z.ZodDefault<z.ZodObject<{
|
|
380
|
+
modules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
381
|
+
id: z.ZodString;
|
|
382
|
+
range: z.ZodOptional<z.ZodString>;
|
|
383
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
384
|
+
}, "strip", z.ZodTypeAny, {
|
|
385
|
+
id: string;
|
|
386
|
+
required: boolean;
|
|
387
|
+
range?: string | undefined;
|
|
388
|
+
}, {
|
|
389
|
+
id: string;
|
|
390
|
+
range?: string | undefined;
|
|
391
|
+
required?: boolean | undefined;
|
|
392
|
+
}>, "many">>;
|
|
393
|
+
}, "strip", z.ZodTypeAny, {
|
|
394
|
+
modules: {
|
|
395
|
+
id: string;
|
|
396
|
+
required: boolean;
|
|
397
|
+
range?: string | undefined;
|
|
398
|
+
}[];
|
|
399
|
+
}, {
|
|
400
|
+
modules?: {
|
|
401
|
+
id: string;
|
|
402
|
+
range?: string | undefined;
|
|
403
|
+
required?: boolean | undefined;
|
|
404
|
+
}[] | undefined;
|
|
405
|
+
}>>;
|
|
406
|
+
env: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
407
|
+
}, "strict", z.ZodTypeAny, {
|
|
408
|
+
schemaVersion: number;
|
|
409
|
+
name: string;
|
|
410
|
+
version: string;
|
|
411
|
+
kind: "platform" | "business" | "third-party";
|
|
412
|
+
risk: {
|
|
413
|
+
level: "high" | "medium" | "low";
|
|
414
|
+
writeBoundary: "sdk-enforced" | "source";
|
|
415
|
+
};
|
|
416
|
+
distribution: {
|
|
417
|
+
defaultMode: "local" | "hybrid" | "sdk" | "codegen";
|
|
418
|
+
};
|
|
419
|
+
contributes: {
|
|
420
|
+
handlers: string[];
|
|
421
|
+
tools: string[];
|
|
422
|
+
cards: {
|
|
423
|
+
cardType: string;
|
|
424
|
+
schemaVersion?: number | undefined;
|
|
425
|
+
}[];
|
|
426
|
+
routes: string[];
|
|
427
|
+
pages: {
|
|
428
|
+
route: string;
|
|
429
|
+
component: string;
|
|
430
|
+
}[];
|
|
431
|
+
tabs: {
|
|
432
|
+
route: string;
|
|
433
|
+
label?: string | undefined;
|
|
434
|
+
icon?: string | undefined;
|
|
435
|
+
order?: number | undefined;
|
|
436
|
+
}[];
|
|
437
|
+
providers: {
|
|
438
|
+
slots: {
|
|
439
|
+
service: string;
|
|
440
|
+
provider: string;
|
|
441
|
+
implementation: string;
|
|
442
|
+
credentialType: string;
|
|
443
|
+
local?: boolean | undefined;
|
|
444
|
+
configSchema?: string | undefined;
|
|
445
|
+
credentialSchema?: string | undefined;
|
|
446
|
+
}[];
|
|
447
|
+
};
|
|
448
|
+
services: {
|
|
449
|
+
service: string;
|
|
450
|
+
optional: boolean;
|
|
451
|
+
defaults: {
|
|
452
|
+
provider: string;
|
|
453
|
+
implementation: string;
|
|
454
|
+
}[];
|
|
455
|
+
title?: string | undefined;
|
|
456
|
+
description?: string | undefined;
|
|
457
|
+
}[];
|
|
458
|
+
resources: {
|
|
459
|
+
type: string;
|
|
460
|
+
id: string;
|
|
461
|
+
}[];
|
|
462
|
+
};
|
|
463
|
+
dependencies: {
|
|
464
|
+
modules: {
|
|
465
|
+
id: string;
|
|
466
|
+
required: boolean;
|
|
467
|
+
range?: string | undefined;
|
|
468
|
+
}[];
|
|
469
|
+
};
|
|
470
|
+
env: string[];
|
|
471
|
+
}, {
|
|
472
|
+
name: string;
|
|
473
|
+
schemaVersion?: number | undefined;
|
|
474
|
+
version?: string | undefined;
|
|
475
|
+
kind?: "platform" | "business" | "third-party" | undefined;
|
|
476
|
+
risk?: {
|
|
477
|
+
level?: "high" | "medium" | "low" | undefined;
|
|
478
|
+
writeBoundary?: "sdk-enforced" | "source" | undefined;
|
|
479
|
+
} | undefined;
|
|
480
|
+
distribution?: {
|
|
481
|
+
defaultMode?: "local" | "hybrid" | "sdk" | "codegen" | undefined;
|
|
482
|
+
} | undefined;
|
|
483
|
+
contributes?: {
|
|
484
|
+
handlers?: string[] | undefined;
|
|
485
|
+
tools?: string[] | undefined;
|
|
486
|
+
cards?: {
|
|
487
|
+
cardType: string;
|
|
488
|
+
schemaVersion?: number | undefined;
|
|
489
|
+
}[] | undefined;
|
|
490
|
+
routes?: string[] | undefined;
|
|
491
|
+
pages?: {
|
|
492
|
+
route: string;
|
|
493
|
+
component: string;
|
|
494
|
+
}[] | undefined;
|
|
495
|
+
tabs?: {
|
|
496
|
+
route: string;
|
|
497
|
+
label?: string | undefined;
|
|
498
|
+
icon?: string | undefined;
|
|
499
|
+
order?: number | undefined;
|
|
500
|
+
}[] | undefined;
|
|
501
|
+
providers?: {
|
|
502
|
+
slots?: {
|
|
503
|
+
service: string;
|
|
504
|
+
provider: string;
|
|
505
|
+
implementation: string;
|
|
506
|
+
credentialType: string;
|
|
507
|
+
local?: boolean | undefined;
|
|
508
|
+
configSchema?: string | undefined;
|
|
509
|
+
credentialSchema?: string | undefined;
|
|
510
|
+
}[] | undefined;
|
|
511
|
+
} | undefined;
|
|
512
|
+
services?: {
|
|
513
|
+
service: string;
|
|
514
|
+
optional?: boolean | undefined;
|
|
515
|
+
defaults?: {
|
|
516
|
+
provider: string;
|
|
517
|
+
implementation: string;
|
|
518
|
+
}[] | undefined;
|
|
519
|
+
title?: string | undefined;
|
|
520
|
+
description?: string | undefined;
|
|
521
|
+
}[] | undefined;
|
|
522
|
+
resources?: {
|
|
523
|
+
type: string;
|
|
524
|
+
id: string;
|
|
525
|
+
}[] | undefined;
|
|
526
|
+
} | undefined;
|
|
527
|
+
dependencies?: {
|
|
528
|
+
modules?: {
|
|
529
|
+
id: string;
|
|
530
|
+
range?: string | undefined;
|
|
531
|
+
required?: boolean | undefined;
|
|
532
|
+
}[] | undefined;
|
|
533
|
+
} | undefined;
|
|
534
|
+
env?: string[] | undefined;
|
|
535
|
+
}>;
|
|
536
|
+
type ModuleDescriptor = z.infer<typeof moduleDescriptorSchema>;
|
|
537
|
+
type CardContrib = z.infer<typeof cardContribSchema>;
|
|
538
|
+
type ProviderSlotContrib = z.infer<typeof providerSlotContribSchema>;
|
|
539
|
+
type ServiceNeedContrib = z.infer<typeof serviceNeedContribSchema>;
|
|
540
|
+
type ResourceNeedContrib = z.infer<typeof resourceNeedContribSchema>;
|
|
541
|
+
type ParseModuleResult = {
|
|
542
|
+
ok: true;
|
|
543
|
+
value: ModuleDescriptor;
|
|
544
|
+
} | {
|
|
545
|
+
ok: false;
|
|
546
|
+
errors: string[];
|
|
547
|
+
};
|
|
548
|
+
declare function parseModuleDescriptor(raw: unknown): ParseModuleResult;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* 配置 JSON 环境变量占位展开(纯数据形态——自 app-sdk env-expansion.ts 迁入改造)。
|
|
552
|
+
*
|
|
553
|
+
* 语法(与 SDK 版语义逐字一致,共享向量 test-fixtures/env-expansion-cases.json 防漂移):
|
|
554
|
+
* ${NAME} 占位引用;NAME 限定 [A-Z][A-Z0-9_]*(UPPER_SNAKE,最小化与正文 `${...}` 误碰)
|
|
555
|
+
* $${NAME} 转义为字面量 ${NAME}(原样保留一次 $)
|
|
556
|
+
*
|
|
557
|
+
* 语义(评审 N1 钉死,壳层各自包装 throw/report):
|
|
558
|
+
* - 单遍非递归:env 值内若含 `${OTHER}` 不被二次展开(注入防线);String.replace 回调形态天然单遍。
|
|
559
|
+
* - 值经 JSON 字符串转义注入;不做数值/布尔强制转换。
|
|
560
|
+
* - **本版为纯数据返回形态** `{ text?: string; missing: string[] }`——缺变量不 throw,
|
|
561
|
+
* 由壳层(CLI doctor 壳 / app-sdk 桥 throw 壳 / 沙箱宿主)决定 fail-fast 还是降级:
|
|
562
|
+
* SDK 桥壳 missing 非空即 throw(错误文案逐字等价 SDK 旧版);CLI 壳同款。
|
|
563
|
+
* - 无 ${ 的文本快速路径:text 原文返回,零替换零开销。
|
|
564
|
+
*/
|
|
565
|
+
interface EnvExpansionResult {
|
|
566
|
+
/** 展开后文本;存在缺失变量时缺席(调用方按 missing 处理,正文不半展开) */
|
|
567
|
+
text?: string;
|
|
568
|
+
/** 缺失变量清单(不回显 env 值——机密不进日志) */
|
|
569
|
+
missing: string[];
|
|
570
|
+
}
|
|
571
|
+
/** 展开配置文本(纯数据);缺失变量 → `{ missing }`(text 缺席),由壳层决定 throw/降级 */
|
|
572
|
+
declare function expandEnvVars(text: string, env?: Readonly<Record<string, string | undefined>>): EnvExpansionResult;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* 凭据掩码算法(GET 路径永无真值——CredentialEcho.masked 单源)。
|
|
576
|
+
* 独立小模块:integrations/credentials.ts(读端掩码)与测试共用,避免 credential-format
|
|
577
|
+
* 的写端 fs 依赖被读端连带拉起(views 层零 fs 依赖约束的前置拆分)。
|
|
578
|
+
*/
|
|
579
|
+
/** 掩码规则:每字段前 2 字符 + '****';≤4 字符退化全 '****';缺字段 → null。
|
|
580
|
+
* 序列化后零真值断言由测试 O4 钉死。 */
|
|
581
|
+
declare function maskCredentialValues(values: Record<string, string>): Record<string, string | null>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* 凭据双工件·文件格式与 stem 派生(写端/读端共用格式单源)。
|
|
585
|
+
*
|
|
586
|
+
* 凭据文件 `config/credentials/<stem>.json` = `{ type, ...values }`(真值工件);
|
|
587
|
+
* integrations.json 恒持 `secret://<stem>` 引用(ref),任何 GET 路径无真值。
|
|
588
|
+
*
|
|
589
|
+
* stem 三形(服务端单源派生;与既有自由 stem 兼容):
|
|
590
|
+
* 服务级 `${provider}-${service}`
|
|
591
|
+
* 实例级 `${provider}-${instanceId}-${domain}`(domain = service 首点段)
|
|
592
|
+
* 应用级 `${provider}-global` / `${provider}-${instanceId}-global`
|
|
593
|
+
*
|
|
594
|
+
* 安全(纵深防御第二道):deriveStem 对任一输入含 `/`、`\`、`..` 直接 throw——
|
|
595
|
+
* 第一道为 descriptor/节点 zod 的字符集 pattern(module-schema SAFE_NAME_PATTERN)。
|
|
596
|
+
*/
|
|
597
|
+
|
|
598
|
+
interface CredentialFile {
|
|
599
|
+
type: string;
|
|
600
|
+
values: Record<string, string>;
|
|
601
|
+
}
|
|
602
|
+
/** 凭据 stem 派生输入(service 级 / instance 级 / app 级三形由调用方按层选择字段) */
|
|
603
|
+
interface StemInput {
|
|
604
|
+
provider: string;
|
|
605
|
+
service?: string;
|
|
606
|
+
instanceId?: string;
|
|
607
|
+
domain?: string;
|
|
608
|
+
}
|
|
609
|
+
/** stem 单源派生(三形;输入含 / \ .. → throw——断言防线) */
|
|
610
|
+
declare function deriveStem(input: StemInput): string;
|
|
611
|
+
/** stem → ref('secret://<stem>') */
|
|
612
|
+
declare function stemToRef(stem: string): string;
|
|
613
|
+
/** stem → 凭据文件相对路径('config/credentials/<stem>.json') */
|
|
614
|
+
declare function stemToFilePath(stem: string): string;
|
|
615
|
+
/** 读凭据文件(真值工件;缺席 → null) */
|
|
616
|
+
declare function readCredentialFile(appDir: string, stem: string): CredentialFile | null;
|
|
617
|
+
/** 写凭据工件(真值;写前 ensureDir 物化父目录——credentials 目录首次写物化)。
|
|
618
|
+
* 返回 overwrote(同 stem 已在场 = 重写)。调用方负责先跑凭据校验链(type 匹配 + ajv 字段级)。 */
|
|
619
|
+
declare function writeCredentialFile(appDir: string, stem: string, file: CredentialFile): boolean;
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* 原子写原语(自 CLI dev.ts 私有 writeAtomic 提升为导出——CLI/写核心/凭据工件三消费方单源)。
|
|
623
|
+
* temp+rename:rename 在同文件系统内原子;半写状态只会停留在 tmp(孤儿 tmp 无害)。
|
|
624
|
+
* 写前 ensureDir(递归 mkdir -p)——credentials 等目录首次写物化(H5)。
|
|
625
|
+
*/
|
|
626
|
+
/** 原子写文本文件:写前 ensureDir 父目录 + temp(pid+ts 后缀防碰撞)+ rename */
|
|
627
|
+
declare function writeAtomic(file: string, content: string): void;
|
|
628
|
+
/** 递归物化目录(mkdir -p 语义;已存在静默) */
|
|
629
|
+
declare function ensureDir(dir: string): void;
|
|
630
|
+
|
|
631
|
+
interface FileCache {
|
|
632
|
+
/** 读文件并 parse(指纹命中返回缓存产物;miss 重读)。文件缺席 → undefined(不缓存缺席态) */
|
|
633
|
+
read<T>(absolutePath: string, parse: (raw: string) => T): T | undefined;
|
|
634
|
+
/** 写后失效协议:paths 缺省全失效;指定路径仅失效对应条目 */
|
|
635
|
+
invalidate(paths?: readonly string[]): void;
|
|
636
|
+
/** 测试观测:parse 执行计数(W6 缓存命中不重 parse 断言用) */
|
|
637
|
+
readonly parseCount: number;
|
|
638
|
+
}
|
|
639
|
+
declare function createFileCache(): FileCache;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* 内联厂商声明(仅槽级 provider 字段可用;实例级 provider 恒字符串)。
|
|
643
|
+
* integrations.json 内直接声明供给,不经 provider 包 manifest。
|
|
644
|
+
* 未实施态语义:catalog/adapter 均无对应实现 → doctor warning + resolve 抛 PROVIDER_NOT_IMPLEMENTED
|
|
645
|
+
* (F5 交互化的「先声明后实施」闭环)。
|
|
646
|
+
*/
|
|
647
|
+
interface InlineVendorDeclaration$1 {
|
|
648
|
+
/** 厂商名(= 档位名 = provider 包轴,如 'wanda') */
|
|
649
|
+
provider: string;
|
|
650
|
+
/** 认证类型('-' 表示无凭据) */
|
|
651
|
+
credentialType: string;
|
|
652
|
+
/** config schema 引用(可选;相对应用 config/;受控子集校验归 doctor 谓词) */
|
|
653
|
+
configSchema?: string;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* 槽实例(instances 键 = instanceId,mall 场景 = mallId;per-instance 唯一写位)。
|
|
657
|
+
* 激活不变式(v4):service 在 scope k 生效 ⟺ instances[k] 在场(或 instances['*'] 通配在场,
|
|
658
|
+
* **或 instances 键整体缺席 = 通配激活**——对任意 instanceId 含 '' 命中);任意生效点的
|
|
659
|
+
* per-instance 凭据均可写 instances[k].credentialRef(root ByInstance 是唯一例外层)。
|
|
660
|
+
* 通配边界:仅 instances 查找层生效——configByInstance/credentialRefByInstance 保持精确键语义。
|
|
661
|
+
*/
|
|
662
|
+
interface ServiceInstanceConfig {
|
|
663
|
+
/** 实例级厂商覆盖(绑定组头;恒字符串。impl-only 非法——implementation 需伴随 provider) */
|
|
664
|
+
provider?: string;
|
|
665
|
+
/** 实例级实现覆盖('id@version';缺席 = 绑定组内派生(SupplyLookup 唯一命中)) */
|
|
666
|
+
implementation?: string;
|
|
667
|
+
/** 连接参数(非机密项;configSchema 校验) */
|
|
668
|
+
config?: Record<string, unknown>;
|
|
669
|
+
/** 机密引用:'secret://{ref}'(local provider 免) */
|
|
670
|
+
credentialRef?: string;
|
|
671
|
+
/** 缺省 true;false → resolve → INSTANCE_DISABLED */
|
|
672
|
+
enabled?: boolean;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* 槽级配置(v3:provider/implementation 可选——双双缺席回落 domain/root 继承;
|
|
676
|
+
* 显式在场 = 显式即真值(不派生——存量全显式文件零影响)。impl-only 非法:
|
|
677
|
+
* implementation 需伴随 provider(provider 是绑定组头)。内联声明仍仅槽级且必带
|
|
678
|
+
* implementation(内联无派生源)。
|
|
679
|
+
* config/credentialRef = 服务级 scope-free 默认。
|
|
680
|
+
*/
|
|
681
|
+
interface ConfiguredService {
|
|
682
|
+
/** 绑定组头(字符串厂商 = 派生位;内联声明 = 显式供给,必带 implementation) */
|
|
683
|
+
provider?: string | InlineVendorDeclaration$1;
|
|
684
|
+
/** 绑定组尾('id@version';缺席 = 派生(SupplyLookup 唯一命中)) */
|
|
685
|
+
implementation?: string;
|
|
686
|
+
config?: Record<string, unknown>;
|
|
687
|
+
credentialRef?: string;
|
|
688
|
+
/** 实例激活表(v4 可选:键缺席 = 通配激活 ≡ {"*":{}};显式空集 = 显式零激活) */
|
|
689
|
+
instances?: Record<string, ServiceInstanceConfig>;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* 模块域全局配置(键 = 槽位域前缀,moduleDomainOf 派生;域 ≠ 模块名——auth 域由登录链消费)。
|
|
693
|
+
* 域 ≠ 部署边界:单应用单厂商部署门禁不因 domains 表达力放开(混绑 die 原样)。
|
|
694
|
+
*/
|
|
695
|
+
interface DomainConfig {
|
|
696
|
+
/** 域级默认厂商(implementation 恒派生——域层无精确绑定语义) */
|
|
697
|
+
provider?: string;
|
|
698
|
+
/** 域级共享配置(该域全部槽合并进 config 级联,与绑定来源层无关) */
|
|
699
|
+
config?: Record<string, unknown>;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* 部署实例(业务主体拓扑条目;root instances 注册表元素——v4 参考表)。
|
|
703
|
+
* 域属性经 attributes 由 TIER1 赋义(mall 场景:miniAppId/contactPhone/location)——
|
|
704
|
+
* TIER0 全程 opaque;本表纯元数据(展示/默认解析),永不充当解析闸门
|
|
705
|
+
* (闸门唯一表达位 = 槽 instances 激活表形态,见 ServiceInstanceConfig)。
|
|
706
|
+
*/
|
|
707
|
+
interface DeploymentInstance {
|
|
708
|
+
/** 实例 id = instanceId 注册来源(槽激活表/ByInstance 键引用它);禁 '*'(通配保留字) */
|
|
709
|
+
id: string;
|
|
710
|
+
/** 展示名(品牌区回显等域消费) */
|
|
711
|
+
name: string;
|
|
712
|
+
/** 域属性袋(TIER0 opaque;TIER1 投影 zod 赋义) */
|
|
713
|
+
attributes?: Record<string, unknown>;
|
|
714
|
+
}
|
|
715
|
+
/** normalizeInstances 产物(模板装配 / CLI doctor / 根脚本共用消费形态) */
|
|
716
|
+
interface NormalizedInstances {
|
|
717
|
+
instances: readonly DeploymentInstance[];
|
|
718
|
+
/** 显式 ?? 单候选唯一解;null = 无默认(多实例无显式默认 = 合法,doctor warning) */
|
|
719
|
+
defaultInstanceId: string | null;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* integrations.json 根形状(loadIntegrations 产物 zod 目标)。
|
|
723
|
+
* 全链唯一 ByInstance 层 = root 四字段(configByInstance/credentialRefByInstance);约束域 = provider
|
|
724
|
+
* 解析链(services/domains/instances);modules 资源轴正交不受此限。
|
|
725
|
+
* service/instance 层级内 per-instance 语义由 instances 键承载。
|
|
726
|
+
* v3 绑定继承:绑定组从最特异层整组取(inst > slot > domains[d] > root)。
|
|
727
|
+
* v4 部署实例注册表:instances = 参考表(纯元数据);defaultInstanceId = 默认实例
|
|
728
|
+
* (无 scope 参数访问兜底;单实例免填——唯一解;无参考表时独立在场 = env 注入动态默认形态)。
|
|
729
|
+
*/
|
|
730
|
+
interface IntegrationsConfig {
|
|
731
|
+
/** 应用全局默认厂商(root 继承层;implementation 恒派生) */
|
|
732
|
+
provider?: string;
|
|
733
|
+
/** 部署级 scope-free 默认配置 */
|
|
734
|
+
config?: Record<string, unknown>;
|
|
735
|
+
/** 部署级 per-instance 默认配置(键 = instanceId) */
|
|
736
|
+
configByInstance?: Record<string, Record<string, unknown>>;
|
|
737
|
+
/** 部署级 scope-free 默认凭据(文件必须 scope:{}) */
|
|
738
|
+
credentialRef?: string;
|
|
739
|
+
/** 部署级 per-instance 默认凭据表(键 = instanceId;商户级凭据主写位) */
|
|
740
|
+
credentialRefByInstance?: Record<string, string>;
|
|
741
|
+
/** 模块域全局层(键 = moduleDomainOf(service);无 ByInstance——全链唯一 ByInstance 层恒 root) */
|
|
742
|
+
domains?: Record<string, DomainConfig>;
|
|
743
|
+
/** 部署实例注册表(参考表);缺席 = 无参考表;空数组非法(zod 拒——无表 = 键缺席唯一写法) */
|
|
744
|
+
instances?: DeploymentInstance[];
|
|
745
|
+
/** 默认实例 id(单实例免填;∈instances ids;无表时独立在场 = 动态默认形态) */
|
|
746
|
+
defaultInstanceId?: string | null;
|
|
747
|
+
/** 模块资源绑定(v5 新轴——与 domains 正交:domains = provider 绑定默认,modules = 资源绑定;
|
|
748
|
+
* 键 = install id(.tbox/app.json entry.id / packages/ 目录名;仓内家族包恒等 manifest name 属规约);
|
|
749
|
+
* 无 per-instance 层(扩展位词汇预选 resourcesByInstance——instances 词恒属 services 激活语义) */
|
|
750
|
+
modules?: Record<string, ModuleConfig>;
|
|
751
|
+
services: Record<string, ConfiguredService>;
|
|
752
|
+
}
|
|
753
|
+
/** 级联求值产物(ok 态) */
|
|
754
|
+
interface EffectiveService {
|
|
755
|
+
provider: string | InlineVendorDeclaration$1;
|
|
756
|
+
implementation: string;
|
|
757
|
+
/** 五层浅合并一层:root.config → root.configByInstance[k] → domain.config → slot.config → inst.config */
|
|
758
|
+
config: Readonly<Record<string, unknown>>;
|
|
759
|
+
credentialRef?: string;
|
|
760
|
+
}
|
|
761
|
+
type EffectiveServiceResolution = {
|
|
762
|
+
status: 'ok';
|
|
763
|
+
effective: EffectiveService;
|
|
764
|
+
} | {
|
|
765
|
+
status: 'service-not-configured';
|
|
766
|
+
} | {
|
|
767
|
+
status: 'instance-not-found';
|
|
768
|
+
} | {
|
|
769
|
+
status: 'instance-disabled';
|
|
770
|
+
} | {
|
|
771
|
+
status: 'binding-unresolved';
|
|
772
|
+
message: string;
|
|
773
|
+
};
|
|
774
|
+
/** 槽位域前缀(domains 键控轴):首个点号前段;无点号取整串。域 ≠ 模块名(auth 域由登录链消费)。 */
|
|
775
|
+
declare function moduleDomainOf(service: string): string;
|
|
776
|
+
/** 派生查表(buildSupplyLookup 产物):键 `${provider}\u0000${service}` → implementation 清单('id@version')。 */
|
|
777
|
+
type SupplyLookup$1 = Record<string, readonly string[]>;
|
|
778
|
+
/**
|
|
779
|
+
* 级联细则(一句话:层序优先于 scope 特异度;层内 per-instance 胜标量):
|
|
780
|
+
* - 绑定组(provider + implementation):最特异层整组取(inst > slot > domain > root)——
|
|
781
|
+
* 独立 `??` 继承会产生跨层非法组合(inst.provider=wanda + 继承 slot 的 joycity impl),
|
|
782
|
+
* 故组不可拆;组内 implementation 缺席 → supplies 派生(唯一命中;
|
|
783
|
+
* 零命中/歧义/未注入查表 → binding-unresolved);双字段显式在场 = 显式即真值(不派生,
|
|
784
|
+
* 存量全显式文件零影响)。内联声明仅槽级且必带 implementation(防御分支兜底)。
|
|
785
|
+
* - config 五层浅合并:root.config → root.configByInstance[k] → domain.config → slot.config →
|
|
786
|
+
* inst.config(service 标量胜 root ByInstance[k]——层序优先于 scope 特异度;
|
|
787
|
+
* domain.config 恒参与该域全部槽,与绑定来源层无关)
|
|
788
|
+
* - credentialRef:inst ?? slot ?? root.credentialRefByInstance[k] ?? root.credentialRef(v3 零改动;
|
|
789
|
+
* domain 层无 credentialRef——链位预留 slot 后、root ByInstance 前)
|
|
790
|
+
* 不抛领域错误;status 由 SDK registry 映射 PROVIDER_* 错误码
|
|
791
|
+
* (binding-unresolved → PROVIDER_BINDING_UNRESOLVED;hasProviderBinding 点查 status !== 'ok' → false)。
|
|
792
|
+
*/
|
|
793
|
+
declare function resolveEffectiveService(integrations: IntegrationsConfig, service: string, instanceId: string, supplies?: SupplyLookup$1): EffectiveServiceResolution;
|
|
794
|
+
/**
|
|
795
|
+
* root 部署实例注册表归一化(v4 wire → 消费形态单源):
|
|
796
|
+
* - instances 缺席 = 空表(无参考表——wanda 动态形态;空数组已在 zod 拒,此处纯防御);
|
|
797
|
+
* - defaultInstanceId 解析:undefined(未填)→ 单候选唯一解(instances 恰一项);
|
|
798
|
+
* 显式 null = 显式无默认(不派生——「显式即真值」原则同 v3 绑定组);无默认 → null。
|
|
799
|
+
* 调用方:TIER1 控制平面投影(mallControlPlaneOf)、CLI doctor(多实例无默认 warning)、
|
|
800
|
+
* 根脚本(real-env-plan 默认实例探测)——禁止各自重写解析逻辑。
|
|
801
|
+
*/
|
|
802
|
+
declare function normalizeInstances(config: Pick<IntegrationsConfig, 'instances' | 'defaultInstanceId'>): NormalizedInstances;
|
|
803
|
+
/** catalog provider 聚合条目(providers[vendor][implementation] 两跳可达;自描述双字段) */
|
|
804
|
+
interface CatalogProviderEntry {
|
|
805
|
+
/** 厂商名(嵌套第一轴;与条目键一致便于透传) */
|
|
806
|
+
provider: string;
|
|
807
|
+
/** 实现标识(嵌套第二轴;'id@version') */
|
|
808
|
+
implementation: string;
|
|
809
|
+
/** 认证类型(authStrategies 匹配键;'-' 无凭据) */
|
|
810
|
+
credentialType: string;
|
|
811
|
+
/** 宿主 npm 包名(诊断归属;多槽同包同 owner) */
|
|
812
|
+
owner: string;
|
|
813
|
+
/** local 供给(mock 形态) */
|
|
814
|
+
local?: boolean;
|
|
815
|
+
/** config schema 引用 */
|
|
816
|
+
configSchema?: string;
|
|
817
|
+
/** credential schema 引用 */
|
|
818
|
+
credentialSchema?: string;
|
|
819
|
+
/** 供给槽清单(service id) */
|
|
820
|
+
services: string[];
|
|
821
|
+
}
|
|
822
|
+
/** catalog 需求侧聚合条目(模块 manifest contributes.services 元素聚合;services 键 = service id) */
|
|
823
|
+
interface CatalogServiceEntry {
|
|
824
|
+
/** 可选槽(未配置不 error——doctor warning 级) */
|
|
825
|
+
optional: boolean;
|
|
826
|
+
/** manifest defaults(F5 页面预填缺省供给) */
|
|
827
|
+
defaults: Array<{
|
|
828
|
+
provider: string;
|
|
829
|
+
implementation: string;
|
|
830
|
+
}>;
|
|
831
|
+
/** 声明方模块(moduleId 清单) */
|
|
832
|
+
owners: string[];
|
|
833
|
+
}
|
|
834
|
+
/** loadProviderCatalog 产物:全应用 provider 供给与需求聚合(.tbox/app.json npmModules 真源) */
|
|
835
|
+
interface ProviderCatalog {
|
|
836
|
+
/** 嵌套形态:厂商级语义一跳、F5 厂商→实现级联枚举天然序;migrate 反查表 = 本表自身 */
|
|
837
|
+
providers: Record<string, Record<string, CatalogProviderEntry>>;
|
|
838
|
+
services: Record<string, CatalogServiceEntry>;
|
|
839
|
+
/** credentialType 直达索引(F5/doctor 单跳;同名共享单例先例) */
|
|
840
|
+
credentialTypes: Record<string, {
|
|
841
|
+
owner: string;
|
|
842
|
+
credentialSchema?: string;
|
|
843
|
+
}>;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* catalog → 派生查表(展开 providers[vendor][impl].services 为
|
|
847
|
+
* `${provider}\u0000${service}` → implementation 清单)。
|
|
848
|
+
* 调用方在工厂构造期构建一次(SDK registry / CLI doctor 谓词 / F5 页面 state),求值期 O(1) 查表。
|
|
849
|
+
*/
|
|
850
|
+
declare function buildSupplyLookup(catalog: ProviderCatalog): SupplyLookup$1;
|
|
851
|
+
/** knowledge 资源声明(wire 形态;datasetId/ref 至少其一,并存时 datasetId 优先——resolver 层裁决) */
|
|
852
|
+
interface KnowledgeResourceSpec {
|
|
853
|
+
type: 'knowledge';
|
|
854
|
+
/** datasetId 直填(免台账) */
|
|
855
|
+
datasetId?: string;
|
|
856
|
+
/** knowledge.json 台账条目名(展开锚 = integrations.json 所在目录——与数据同源旅行) */
|
|
857
|
+
ref?: string;
|
|
858
|
+
topK?: number;
|
|
859
|
+
scoreThreshold?: number;
|
|
860
|
+
}
|
|
861
|
+
/** 资源声明(discriminated by type;SDK zod / CLI doctor / 未来 app-toolkit 共用 wire 形状) */
|
|
862
|
+
type ResourceSpec = KnowledgeResourceSpec;
|
|
863
|
+
/** 模块资源配置(modules 节元素;strict 单字段——provider/config/instances 进 modules 即非法,防与 domains 双写位) */
|
|
864
|
+
interface ModuleConfig {
|
|
865
|
+
/** resourceId → 类型化资源声明(resourceId 词汇真源 = 模块 manifest contributes.resources) */
|
|
866
|
+
resources: Record<string, ResourceSpec>;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* contracts 期望面编译期锁(satisfies 语义防接口漂移——contracts 加名/改签名即编译红)。
|
|
871
|
+
* resolver 运行时产物按本接口逐命名导出存在性检查(evaluation/strictValidation 按在场降级)。
|
|
872
|
+
* contracts 恒 devDep 且限 import type——运行时全经 resolver 动态 import(版本解耦,D3)。
|
|
873
|
+
*/
|
|
874
|
+
interface EvaluationExports {
|
|
875
|
+
/** 求值单源(TIER0;v3 显式激活 vs v4 通配语义随应用版本) */
|
|
876
|
+
resolveEffectiveService: typeof resolveEffectiveService;
|
|
877
|
+
/** 供给查表派生(谓词 #12 与视图供给轴共用输入) */
|
|
878
|
+
buildSupplyLookup: typeof buildSupplyLookup;
|
|
879
|
+
/** service → 首点段域前缀(谓词 #14 域键匹配) */
|
|
880
|
+
moduleDomainOf: typeof moduleDomainOf;
|
|
881
|
+
/** 部署实例注册表归一(默认实例委托——null → '*' 通配口径) */
|
|
882
|
+
normalizeInstances: typeof normalizeInstances;
|
|
883
|
+
/** 模块资源类型词汇表(v5;descriptor type 校验经 resolver 取词表) */
|
|
884
|
+
RESOURCE_TYPE_IDS: readonly string[];
|
|
885
|
+
/** 严格 zod 面(0.9+ 可选)——strictValidation 门控判据;缺席 = 求值/写 503 */
|
|
886
|
+
parseIntegrationsConfig?: (raw: unknown) => IntegrationsConfig;
|
|
887
|
+
}
|
|
888
|
+
/** resolver 运行时产物类型(动态 import 的命名导出子集) */
|
|
889
|
+
type ResolvedModule = Partial<EvaluationExports>;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* contracts 动态解析器(方案心脏,D3):`resolveContractsForApp(appDir)`——
|
|
893
|
+
* 成员扫描 + 包根定位。沙箱内 toolkit 与目标应用版本解耦:求值与校验双面由
|
|
894
|
+
* 应用自己的 @tbox.cn/app-contracts 版本驱动。
|
|
895
|
+
*
|
|
896
|
+
* 解析算法:
|
|
897
|
+
* 候选目录序(越靠前越优):
|
|
898
|
+
* 1. appDir/node_modules/@tbox.cn/app-contracts (npm 平铺 / 应用根直装)
|
|
899
|
+
* 2. appDir/apps/server/node_modules/… (pnpm 成员级——运行时消费方优先)
|
|
900
|
+
* 3. appDir/apps/<各成员>/node_modules/…(其余成员,字母序去重)
|
|
901
|
+
* 4. appDir/packages/<各包>/node_modules/…(codegen 模块包)
|
|
902
|
+
* 每候选:existsSync → realpathSync(解 pnpm symlink 至 store 真实路径)
|
|
903
|
+
* → 探测 <根>/dist/runtime.js(构建/发布/验证态)|<根>/src/runtime.ts(workspace link 态,TS-host 前提)
|
|
904
|
+
* → 读 **候选路径**(symlink 原路径)package.json version——版本轻探测:pnpm 升级换 store 目标
|
|
905
|
+
* 可觉察(realpath 缓存路径旧 version 恒旧,读候选路径修正——真 bug 候选防线)
|
|
906
|
+
* → await import(探测命中文件) → 逐命名导出存在性检查(contracts-expected EvaluationExports)
|
|
907
|
+
* 首个命中即返回(候选序即优先级);全候选缺席/导入拒绝 → 未解析(**绝不 throw**)。
|
|
908
|
+
*
|
|
909
|
+
* **红线**:禁 createRequire().resolve(contracts 发布面 exports 仅 types+import 双条件、
|
|
910
|
+
* 无 require/default——必抛 ERR_PACKAGE_PATH_NOT_EXPORTED);动态 import 路径运行时计算
|
|
911
|
+
* (pathToFileURL——打包器不得字面量折叠,README 打包纪律)。
|
|
912
|
+
*
|
|
913
|
+
* memoize:per appDir 记忆 { promise, version };每次 resolve 轻探测候选路径 version——
|
|
914
|
+
* 变更 → 重走候选链 + 动态 import(Node import 缓存按路径天然去重;升级契约自动生效,
|
|
915
|
+
* 不依赖事件广播——node_modules 被 FileWatcher IGNORED_DIRS 过滤,自愈设计不依赖广播)。
|
|
916
|
+
*/
|
|
917
|
+
interface ResolvedContracts {
|
|
918
|
+
/** 候选包 package.json version(未安装 → null) */
|
|
919
|
+
version: string | null;
|
|
920
|
+
/** 求值面可用(resolveEffectiveService 等命名导出在场) */
|
|
921
|
+
evaluation: boolean;
|
|
922
|
+
/** 严格 zod 面可用(parseIntegrationsConfig 在场——≥0.9 门控判据) */
|
|
923
|
+
strictValidation: boolean;
|
|
924
|
+
/** 动态 import 产物(命名导出子集——Partial<EvaluationExports>) */
|
|
925
|
+
module: ResolvedModule;
|
|
926
|
+
/** 解析诊断(N1 构建指引 message 三分支的输入:未安装 / 版本 <0.9 / 源码态未构建) */
|
|
927
|
+
notes: string[];
|
|
928
|
+
}
|
|
929
|
+
/** 解析应用自己的 contracts(memoize + 轻探测指纹;绝不 throw——全缺席 → 未解析产物)。
|
|
930
|
+
* F9:命中判定 = 首个在册候选 + 命中候选双指纹(版本变更 / dist 物化 / 候选序变化 / 候选消失
|
|
931
|
+
* 全面可觉察——覆盖「build 后重试」长生命周期宿主与多候选走位两处 stale 边缘)。 */
|
|
932
|
+
declare function resolveContractsForApp(appDir: string): Promise<ResolvedContracts>;
|
|
933
|
+
/** 逃生舱(测试/宿主特殊场景——正常路径无需调用,Freshness Contract 自动;invalidate 逃生舱标注) */
|
|
934
|
+
declare function invalidateContractsResolver(appDir?: string): void;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* integration-services 谓词单源(integrations v4;自 CLI doctor/integration-services.ts 迁入——
|
|
938
|
+
* doctor 第 19 条与 toolkit 工厂 evaluateIntegrationServices 共用此函数,单源不变)。
|
|
939
|
+
* 纯函数、零副作用、零 I/O——contracts 经 input.contracts 注入(resolver 装配,版本解耦 D3)。
|
|
940
|
+
*
|
|
941
|
+
* 结构化输出(H7 v4.3):IntegrationIssue { severity, code, message, service?, module?, instance? }——
|
|
942
|
+
* 检查逻辑零改动(~24 处 push 机械加 code/定位字段;level→severity 字段同名随 D22 班车,
|
|
943
|
+
* severity 取值恒等旧 level——doctor 门控行为等价)。
|
|
944
|
+
* **code 枚举单源 = 本文件头映射表(additive-only;api.md §5 表与本表同步)**:
|
|
945
|
+
* CREDENTIAL_FILE_MISSING #1 error effective credentialRef 引用凭据文件不在场
|
|
946
|
+
* CREDENTIAL_TYPE_MISMATCH #2 error 凭据文件 .type 与绑定 credentialType 不一致
|
|
947
|
+
* SLOT_NOT_DECLARED #3 warning 服务槽无消费方声明(拼写/需求方未安装/旧槽位词汇)
|
|
948
|
+
* SLOT_NOT_CONFIGURED #4 warning 需求方缺口(服务槽未配置)
|
|
949
|
+
* INSTANCE_SUPPLY_UNMATCHED #5 error 绑定未命中已装供给(槽级/实例级覆盖)
|
|
950
|
+
* IMPL_WITHOUT_PROVIDER #5/#13 error impl-only(implementation 缺 provider 绑定组头)
|
|
951
|
+
* INLINE_PROVIDER_INVALID #5 error 内联厂商声明超受控形状(槽级/实例级)
|
|
952
|
+
* SCHEMA_FILE_MISSING #6 error credentialType schema 引用不存在
|
|
953
|
+
* DOMAIN_CONFIG_INVALID #7 error root/domains 死配置(键 ∉ 引用厂商 schema properties;
|
|
954
|
+
* api.md DOMAIN_CONFIG_UNUSED 行预留 warning 级,
|
|
955
|
+
* 现行为 error 恒等旧谓词——doctor 门控等价)
|
|
956
|
+
* INSTANCE_KEY_NOT_REGISTERED #8 error ByInstance 键/实例键 ∉ 注册表白名单
|
|
957
|
+
* REALM_SWITCH_HINT #9 warning 实现覆盖跨厂商(凭据域切换确认)
|
|
958
|
+
* WILDCARD_ALIGNMENT #10 warning 通配形态齐步提示
|
|
959
|
+
* MULTI_INSTANCE_NO_DEFAULT v4 warning 多实例无 defaultInstanceId(无 scope 访问落全局会话)
|
|
960
|
+
* VENDOR_NOT_INSTALLED #11 error root/domains 厂商未命中已装供给
|
|
961
|
+
* BINDING_UNRESOLVED #12 error 绑定不可解析(resolveEffectiveService 求值失败)
|
|
962
|
+
* DOMAIN_KEY_UNMATCHED #14 warning domains 键 ∉ 匹配域集(typo)
|
|
963
|
+
* RESOURCE_TYPE_UNKNOWN #15 error modules 资源节 type ∉ 词汇表
|
|
964
|
+
* RESOURCE_NOT_DECLARED #16 warning 资源键/资源 id ∉ 模块声明集
|
|
965
|
+
* ORPHANED_CREDENTIAL 写后对账 warning 凭据文件不再被引用(toolkit 写路径产出,非本谓词)
|
|
966
|
+
*
|
|
967
|
+
* 输入形状(调用方负责装载):
|
|
968
|
+
* - integrations:config/integrations.json 解析产物(宽松 Record 透传——严格 zod 校验归模板 loader)
|
|
969
|
+
* - suppliedProviders:已声明供给(`${vendor}\u0000${implementation}` 拼接键 → 槽集合;同源聚合)
|
|
970
|
+
* - demandedServices:已声明需求(service → { optional, owners })
|
|
971
|
+
* - supplies:派生查表(contracts buildSupplyLookup 产物;缺席 → #12 跳过,M3 降级兼容)
|
|
972
|
+
* - malls:可选实例 id 白名单(v4 源 = root instances 注册表 ids;缺席 → ByInstance 键检查跳过)
|
|
973
|
+
* - credentialSchemas:可选(credentialType → schema 文件引用路径;manifest 声明聚合)
|
|
974
|
+
* - configSchemas:可选(service/slot → schema 文件引用路径)
|
|
975
|
+
*
|
|
976
|
+
* 检查族(v3):
|
|
977
|
+
* #1 effective credentialRef → 档内凭据文件在场
|
|
978
|
+
* #2 凭据文件 .type 与绑定 credentialType 对齐(错配 = transport 期「未知认证类型」前置暴露;
|
|
979
|
+
* 继承绑定(槽级 provider 缺席)经 effective 求值取厂商——supplies 在场时)
|
|
980
|
+
* #5 实例 impl-only 禁止 + 覆盖命中供给(含槽级内联形状;provider-only = 派生位,合法)
|
|
981
|
+
* #6 manifest configSchema/credentialSchema 引用文件存在性(内联与 manifest 绑定同查)
|
|
982
|
+
* #7 root/domains 死配置:root.config/configByInstance/domains[d].config 键 ⊆ 引用厂商(并集)
|
|
983
|
+
* 各槽 schema properties——引用面 = root.provider ∪ domains.*.provider ∪ 槽级(terse 化防退化)
|
|
984
|
+
* #8 ByInstance/实例键 ∈ malls 白名单(v4:源 = root instances 注册表 ids——参考表在场时
|
|
985
|
+
* 激活;'**' 通配键豁免;注册表缺席 → 跳过;domains 键 = 域前缀非 instanceId,不适用)
|
|
986
|
+
* #9 实现覆盖跨厂商提示(realm switch——凭据域切换确认)
|
|
987
|
+
* #11 root/domains 厂商未命中已装供给(vendor 集合 = suppliedProviders 键前缀展开)
|
|
988
|
+
* #12 绑定可解析性:逐 (service, instanceId) 经 contracts resolveEffectiveService 求值
|
|
989
|
+
* (级联单源复用,谓词零级联实现),binding-unresolved → error(supplies 缺席 → 跳过)
|
|
990
|
+
* #13 槽级/实例级 impl-only(implementation 需伴随 provider——provider 是绑定组头;
|
|
991
|
+
* zod 之外的第二道防线——doctor 读裸 JSON)
|
|
992
|
+
* #14 domains 键 ∈ 匹配域集(已配置槽 ∪ 需求声明的 moduleDomainOf 并集;typo → warning)
|
|
993
|
+
* #15-#16 modules 资源节对账(v5):type ∉ RESOURCE_TYPE_IDS → error(裸 JSON 预启动反馈);
|
|
994
|
+
* 键 ∉ 已装模块 id 集 / 资源 id ∉ 模块 manifest contributes.resources 声明集(声明非空时)
|
|
995
|
+
* → warning(moduleResourceNeeds 缺席 → 需求面检查跳过,M3 降级先例)
|
|
996
|
+
*/
|
|
997
|
+
|
|
998
|
+
/** contracts 注入面(resolver 装配产物运行时视图 = EvaluationExports 求值子集) */
|
|
999
|
+
type PredicateContracts = Pick<EvaluationExports, 'resolveEffectiveService' | 'buildSupplyLookup' | 'moduleDomainOf' | 'normalizeInstances' | 'RESOURCE_TYPE_IDS'>;
|
|
1000
|
+
/** 派生查表形状(contracts buildSupplyLookup 产物;结构等价 TIER0 SupplyLookup——谓词零 contracts 静态依赖) */
|
|
1001
|
+
type SupplyLookup = Record<string, readonly string[]>;
|
|
1002
|
+
interface IntegrationServicePredicateInput {
|
|
1003
|
+
integrations: {
|
|
1004
|
+
provider?: string;
|
|
1005
|
+
domains?: Record<string, {
|
|
1006
|
+
provider?: string;
|
|
1007
|
+
config?: Record<string, unknown>;
|
|
1008
|
+
}>;
|
|
1009
|
+
config?: Record<string, unknown>;
|
|
1010
|
+
configByInstance?: Record<string, Record<string, unknown>>;
|
|
1011
|
+
credentialRef?: string;
|
|
1012
|
+
credentialRefByInstance?: Record<string, string>;
|
|
1013
|
+
services: Record<string, {
|
|
1014
|
+
provider?: string | Record<string, unknown>;
|
|
1015
|
+
implementation?: string;
|
|
1016
|
+
config?: Record<string, unknown>;
|
|
1017
|
+
credentialRef?: string;
|
|
1018
|
+
instances?: Record<string, {
|
|
1019
|
+
enabled?: boolean;
|
|
1020
|
+
provider?: unknown;
|
|
1021
|
+
implementation?: unknown;
|
|
1022
|
+
credentialRef?: string;
|
|
1023
|
+
}>;
|
|
1024
|
+
}>;
|
|
1025
|
+
/** v4 部署实例注册表(参考表——#8 白名单源 + 多实例无默认 warning) */
|
|
1026
|
+
instances?: Array<{
|
|
1027
|
+
id: string;
|
|
1028
|
+
name?: string;
|
|
1029
|
+
attributes?: Record<string, unknown>;
|
|
1030
|
+
}>;
|
|
1031
|
+
/** v4 默认实例(normalizeInstances 解析语义:显式 ?? 单候选唯一解) */
|
|
1032
|
+
defaultInstanceId?: string | null;
|
|
1033
|
+
/** v5 模块资源绑定(modules 节——宽松透传;严格 zod 归模板 loader) */
|
|
1034
|
+
modules?: Record<string, {
|
|
1035
|
+
resources?: Record<string, {
|
|
1036
|
+
type?: unknown;
|
|
1037
|
+
}>;
|
|
1038
|
+
}>;
|
|
1039
|
+
};
|
|
1040
|
+
/** 已声明供给(`${vendor}\u0000${implementation}` → 槽集合;credentialType 供 #2/#6 绑定侧对齐) */
|
|
1041
|
+
suppliedProviders: Record<string, {
|
|
1042
|
+
services: string[];
|
|
1043
|
+
owner: string;
|
|
1044
|
+
credentialType?: string;
|
|
1045
|
+
}>;
|
|
1046
|
+
/** 已声明需求(service → { optional, owners }) */
|
|
1047
|
+
demandedServices: Record<string, {
|
|
1048
|
+
optional: boolean;
|
|
1049
|
+
owners: string[];
|
|
1050
|
+
}>;
|
|
1051
|
+
/** 派生查表(buildSupplyLookup 产物;缺席 → #12 跳过 + #2 继承绑定不查 credentialType) */
|
|
1052
|
+
supplies?: SupplyLookup;
|
|
1053
|
+
/** malls 白名单(deployments 控制面 extract;缺席 → ByInstance 键检查跳过) */
|
|
1054
|
+
malls?: string[];
|
|
1055
|
+
/** credentialType → schema 文件引用缺失(manifest 声明指向缺失文件;#6) */
|
|
1056
|
+
credentialSchemaMissing?: Record<string, boolean>;
|
|
1057
|
+
/** 厂商 → 槽 schema properties 键集(#7 用;调用方从 manifest configSchema 引用解析) */
|
|
1058
|
+
vendorConfigKeys?: Record<string, Set<string>>;
|
|
1059
|
+
/** 厂商 → configSchema 引用文件缺失(#7 跳过该厂商——无 schema 不能判死配置) */
|
|
1060
|
+
vendorConfigSchemaMissing?: Record<string, boolean>;
|
|
1061
|
+
/** 凭据文件缺失(#1:credentialRef stem → 档内 credentials/<stem>.json 在场;域中立注入) */
|
|
1062
|
+
credentialFileMissing?: Record<string, boolean>;
|
|
1063
|
+
/** 凭据文件 .type(stem → type;#2 对齐判定——文件无 type 则缺键,跳过) */
|
|
1064
|
+
credentialFileType?: Record<string, string | undefined>;
|
|
1065
|
+
/** #9:实现覆盖跨厂商提示位(CLI 侧组装) */
|
|
1066
|
+
realmSwitchHints?: string[];
|
|
1067
|
+
/** v5:已装模块 id → manifest contributes.resources 声明 id 集(值空集 = 无声明,资源级跳过;
|
|
1068
|
+
* 缺席 = 无需求面信息——键未知/资源未声明检查跳过,type 检查恒跑) */
|
|
1069
|
+
moduleResourceNeeds?: Record<string, ReadonlySet<string>>;
|
|
1070
|
+
}
|
|
1071
|
+
/** 结构化 issue(H7 v4.3):code 枚举单源 = 本文件头映射表(additive-only) */
|
|
1072
|
+
interface IntegrationServiceIssue {
|
|
1073
|
+
severity: 'error' | 'warning';
|
|
1074
|
+
code: string;
|
|
1075
|
+
message: string;
|
|
1076
|
+
service?: string;
|
|
1077
|
+
module?: string;
|
|
1078
|
+
instance?: string;
|
|
1079
|
+
}
|
|
1080
|
+
/** 内联厂商声明受控形状(v2:provider/credentialType/configSchema) */
|
|
1081
|
+
declare function isControlledInlineProvider(raw: unknown): boolean;
|
|
1082
|
+
/** #8 检查族导出(FX-2b 单源):toolkit 写路径轻量复查(registryCheck)消费——
|
|
1083
|
+
* 覆盖 configByInstance / credentialRefByInstance / services[s].instances 三键位;
|
|
1084
|
+
* malls = root instances 注册表 ids(参考表缺席 → 消费方跳过,勿传空集)。 */
|
|
1085
|
+
declare function checkInstanceKeys(integrations: {
|
|
1086
|
+
configByInstance?: Record<string, unknown>;
|
|
1087
|
+
credentialRefByInstance?: Record<string, unknown>;
|
|
1088
|
+
services?: Record<string, {
|
|
1089
|
+
instances?: Record<string, unknown>;
|
|
1090
|
+
}>;
|
|
1091
|
+
}, malls: readonly string[]): IntegrationServiceIssue[];
|
|
1092
|
+
/** 谓词主体:integrations 配置 × catalog 声明 交叉校验(error/warning 分级;contracts 注入) */
|
|
1093
|
+
declare function evaluateIntegrationServices(input: IntegrationServicePredicateInput & {
|
|
1094
|
+
contracts: PredicateContracts;
|
|
1095
|
+
}): IntegrationServiceIssue[];
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* walkManifests(appDir)——单次遍历四产物(D24/D26;ai-build C3-1)。
|
|
1099
|
+
*
|
|
1100
|
+
* manifest 候选路径探测(packages/<id>/tbox.module.json 优先 → node_modules/<pkg>/tbox.module.json;
|
|
1101
|
+
* tbox-app dev 真身经 .tbox-dev.local/dev-manifest.json redirects 独立 catalog 通道直达)一次遍历同时产出:
|
|
1102
|
+
* 1. modules:已装模块清单(declared;demand meta title/description 透传)
|
|
1103
|
+
* 2. catalog(富形态):providers 嵌套(vendor→impl→entry,per-service {implementation, credentialType}
|
|
1104
|
+
* 保真——同厂商异构/多实现合法,D25/H1)+ 需求侧聚合
|
|
1105
|
+
* 3. serviceSchemas:per-service schema 复合键表——键 `${provider}\u0000${service}`(H2,同一服务
|
|
1106
|
+
* 多厂商供给各自 schema 零碰撞);多 impl 同 (provider, service) 异 schema → 声明序首个
|
|
1107
|
+
* 4. vocabulary:所有携带 service-slots.json 的已装契约包该文件 `.slots` 键并集(fs 直读、
|
|
1108
|
+
* `$comment` 忽略;探测链 = readdir(<候选>/node_modules/@tbox.cn) 过滤携带该文件的包——
|
|
1109
|
+
* 零缓存枚举,与 manifest 探测同机制;多行业 contracts-* 天然扩展 F8);缺席 → [](退化 demanded ∪ configured)
|
|
1110
|
+
* 5. domainKeyIssues:跨模块域键冲突 issue(两模块派生同一 domains 键——P13)
|
|
1111
|
+
*
|
|
1112
|
+
* **约束(D26;FX-3/F7 边界)**:目录枚举零缓存——readdir / node_modules 候选探测 / `.tbox/app.json` 读取 /
|
|
1113
|
+
* dev-manifest 读取每次执行(枚举输入保持 fresh——agent 装卸模块下一笔即见);manifest/service-slots
|
|
1114
|
+
* **文件内容**经 file-cache(`cache` 可选参——工厂/写内核传本实例 cache(stat 指纹自愈 + 写后失效);
|
|
1115
|
+
* CLI 传 undefined 即全 fresh)。
|
|
1116
|
+
* 宽松解析语义(坏文件静默 + 重复键首声明保留)零改动。
|
|
1117
|
+
*/
|
|
1118
|
+
interface WalkManifestsResult {
|
|
1119
|
+
/** declared 产物(install id + descriptor;demand meta 透传) */
|
|
1120
|
+
modules: WalkModuleInfo[];
|
|
1121
|
+
/** 富形态 catalog(providers 嵌套保真 + 需求聚合 + credentialTypes) */
|
|
1122
|
+
catalog: WalkCatalog;
|
|
1123
|
+
/** per-service schema 复合键表:`${provider}\u0000${service}` → schema 引用 + 包根 */
|
|
1124
|
+
serviceSchemas: Record<string, {
|
|
1125
|
+
configSchema?: string;
|
|
1126
|
+
credentialSchema?: string;
|
|
1127
|
+
packageDir: string;
|
|
1128
|
+
}>;
|
|
1129
|
+
/** 服务词汇 = 所有携带 service-slots.json 的已装契约包 `.slots` 键并集(缺席 → []) */
|
|
1130
|
+
vocabulary: string[];
|
|
1131
|
+
/** 跨模块域键冲突(P13——两模块的 service 集派生同一 domains 键) */
|
|
1132
|
+
domainKeyIssues: Array<{
|
|
1133
|
+
severity: 'warning';
|
|
1134
|
+
code: 'DOMAIN_KEY_CONFLICT';
|
|
1135
|
+
message: string;
|
|
1136
|
+
module?: string;
|
|
1137
|
+
}>;
|
|
1138
|
+
}
|
|
1139
|
+
interface WalkModuleInfo {
|
|
1140
|
+
/** install id(packages/ 目录名 / npmModules entry.id) */
|
|
1141
|
+
id: string;
|
|
1142
|
+
/** 模块目录(本地 packages/<id> 优先;sdk 包 = node_modules 解析位) */
|
|
1143
|
+
dir: string;
|
|
1144
|
+
/** 发布源包名 */
|
|
1145
|
+
pkg: string;
|
|
1146
|
+
descriptor: ModuleDescriptor;
|
|
1147
|
+
}
|
|
1148
|
+
/** 富形态供给条目:per-service {implementation, credentialType} 恒数组保真(H1) */
|
|
1149
|
+
interface WalkProviderEntry {
|
|
1150
|
+
provider: string;
|
|
1151
|
+
implementation: string;
|
|
1152
|
+
credentialType: string;
|
|
1153
|
+
owner: string;
|
|
1154
|
+
local?: boolean;
|
|
1155
|
+
configSchema?: string;
|
|
1156
|
+
credentialSchema?: string;
|
|
1157
|
+
services: string[];
|
|
1158
|
+
}
|
|
1159
|
+
interface WalkCatalog {
|
|
1160
|
+
providers: Record<string, Record<string, WalkProviderEntry>>;
|
|
1161
|
+
services: Record<string, {
|
|
1162
|
+
optional: boolean;
|
|
1163
|
+
defaults: Array<{
|
|
1164
|
+
provider: string;
|
|
1165
|
+
implementation: string;
|
|
1166
|
+
}>;
|
|
1167
|
+
/** demand meta(title/description 首声明保留——模块 manifest demand 侧 additive) */
|
|
1168
|
+
title?: string;
|
|
1169
|
+
description?: string;
|
|
1170
|
+
owners: string[];
|
|
1171
|
+
}>;
|
|
1172
|
+
credentialTypes: Record<string, {
|
|
1173
|
+
owner: string;
|
|
1174
|
+
credentialSchema?: string;
|
|
1175
|
+
}>;
|
|
1176
|
+
}
|
|
1177
|
+
/** walkManifests 主体(单次遍历四产物;目录枚举零缓存——每次调用执行) */
|
|
1178
|
+
declare function walkManifests(appDir: string, cache?: FileCache): WalkManifestsResult;
|
|
1179
|
+
interface DeclaredModuleInfo {
|
|
1180
|
+
id: string;
|
|
1181
|
+
/** 装配包名(codegen/local = @app/<id>;sdk = 发布包名) */
|
|
1182
|
+
pkg: string;
|
|
1183
|
+
mode: 'local' | 'sdk' | 'codegen';
|
|
1184
|
+
hasServerEntry: boolean;
|
|
1185
|
+
hasClientEntry: boolean;
|
|
1186
|
+
hasCards: boolean;
|
|
1187
|
+
/** declaration.moduleId(deployment 对账真源;老模块无 declaration → undefined) */
|
|
1188
|
+
moduleId?: string;
|
|
1189
|
+
}
|
|
1190
|
+
/** 提取 declaration.moduleId(宽松正则——容忍任意嵌套/注释;未声明 → undefined) */
|
|
1191
|
+
declare function extractModuleIdFromSource(source: string): string | undefined;
|
|
1192
|
+
/**
|
|
1193
|
+
* 计算声明集合(含 npm 清单 + 本地模块约定发现)。
|
|
1194
|
+
* hasServerEntry/hasClientEntry 决定模块参与哪些装配文件(入口探测,非 post-hoc 修复)。
|
|
1195
|
+
* 单源 = walkManifests(npmModules 登记 + packages/* 约定发现双通道;strict 形态进清单)。
|
|
1196
|
+
*/
|
|
1197
|
+
declare function collectDeclaredModules(appDir: string): DeclaredModuleInfo[];
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* 谓词装配单源(FX-2b/F1):CLI doctor 规则 与 toolkit 工厂(求值轴 / SaveResult.issues)
|
|
1201
|
+
* 共用同一 I/O 装配与供给/需求聚合——「面板 issues ≡ doctor issues」的机制保证。
|
|
1202
|
+
*
|
|
1203
|
+
* 迁移源:cli/src/doctor/schema-reader.ts(collectVendorSchemaProfiles,105 行)
|
|
1204
|
+
* + doctor 规则壳内联段(#1 effective stem 收集含 root ByInstance/标量兜底 + env 通道 +
|
|
1205
|
+
* #9 realmSwitchHints + malls 注册表 + moduleResourceNeeds)。
|
|
1206
|
+
*
|
|
1207
|
+
* **装配源 = walkManifests 双通道产物**(声明性改进:sdk 模式模块(npmModules 登记、
|
|
1208
|
+
* node_modules 消费)从 doctor 原单通道(listLocalModules = packages/* 本地扫描)的静默
|
|
1209
|
+
* 忽略,转纳入检查面——与 toolkit 求值轴同源)。
|
|
1210
|
+
*
|
|
1211
|
+
* env 参数注入(默认 process.env——工厂边缘):#1 的 env 通道兜底(wanda env 化形态:
|
|
1212
|
+
* stem kebab → UPPER_SNAKE,env 键在场即视为已供给,不算缺文件)。
|
|
1213
|
+
*/
|
|
1214
|
+
interface PredicateIoInputs {
|
|
1215
|
+
/** #1:effective 候选 stem → 缺文件(env 通道在场不算缺失) */
|
|
1216
|
+
credentialFileMissing: Record<string, boolean>;
|
|
1217
|
+
/** #2:凭据文件 stem → .type(无 type 则缺键) */
|
|
1218
|
+
credentialFileType: Record<string, string | undefined>;
|
|
1219
|
+
/** #6:credentialType → schema 引用文件缺失 */
|
|
1220
|
+
credentialSchemaMissing: Record<string, boolean>;
|
|
1221
|
+
/** #7:厂商 → configSchema properties 键集并集 */
|
|
1222
|
+
vendorConfigKeys: Record<string, Set<string>>;
|
|
1223
|
+
/** #7:厂商 → configSchema 引用缺失(跳过该厂商死配置判定) */
|
|
1224
|
+
vendorConfigSchemaMissing: Record<string, boolean>;
|
|
1225
|
+
/** #9:实现覆盖跨厂商提示文案(已成形——谓词直投) */
|
|
1226
|
+
realmSwitchHints: string[];
|
|
1227
|
+
/** #8:root instances 注册表 ids(在场才传;缺席 → 键检查跳过) */
|
|
1228
|
+
malls?: string[];
|
|
1229
|
+
/** #15-#16:已装模块 id → manifest contributes.resources 声明 id 集 */
|
|
1230
|
+
moduleResourceNeeds: Record<string, ReadonlySet<string>>;
|
|
1231
|
+
}
|
|
1232
|
+
/** 装配全产物(= PredicateIoInputs + 供给/需求聚合——喂 evaluateIntegrationServices 的
|
|
1233
|
+
* 非 contracts/integrations 入参全集,两消费方 spread 直投,零各自组装) */
|
|
1234
|
+
interface PredicateAssembly extends PredicateIoInputs {
|
|
1235
|
+
suppliedProviders: Record<string, {
|
|
1236
|
+
services: string[];
|
|
1237
|
+
owner: string;
|
|
1238
|
+
credentialType?: string;
|
|
1239
|
+
}>;
|
|
1240
|
+
demandedServices: Record<string, {
|
|
1241
|
+
optional: boolean;
|
|
1242
|
+
owners: string[];
|
|
1243
|
+
}>;
|
|
1244
|
+
}
|
|
1245
|
+
/** stem → env 键(kebab → UPPER_SNAKE;与 SDK/provider-secret env 兜底同公式) */
|
|
1246
|
+
declare function refToEnvKey(stem: string): string;
|
|
1247
|
+
/**
|
|
1248
|
+
* 装配谓词输入全集(供给/需求聚合 + I/O 档案)。
|
|
1249
|
+
* @param walk 调用方已执行的 walkManifests 产物(目录枚举零缓存——每方法调用独立)
|
|
1250
|
+
*/
|
|
1251
|
+
declare function buildPredicateAssembly(appDir: string, walk: WalkManifestsResult, integrations: Record<string, unknown>, env?: Readonly<Record<string, string | undefined>>): PredicateAssembly;
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* .tbox/app.json npmModules 读写(自 CLI manifest.ts 迁入——assembly 层目录知识单源)。
|
|
1255
|
+
* npmModules 登记 = sdk 包双语义磁盘足迹之一(业务包 = packages/<id>/ 目录,sdk 包 = 本清单登记)。
|
|
1256
|
+
* 本地模块(packages/module-*)不在 npmModules 登记——靠 tbox.module.json 约定发现。
|
|
1257
|
+
*/
|
|
1258
|
+
type ModuleMode = 'local' | 'sdk' | 'codegen';
|
|
1259
|
+
interface NpmModuleEntry {
|
|
1260
|
+
/** 模块短 id(如 "module-member"),装配别名来源 */
|
|
1261
|
+
id: string;
|
|
1262
|
+
/** 发布源包名;codegen 的应用内身份由 id 派生为 @app/<id>,sdk 保持该包名 */
|
|
1263
|
+
package: string;
|
|
1264
|
+
/** 安装版本 */
|
|
1265
|
+
version: string;
|
|
1266
|
+
/** 分发模式 */
|
|
1267
|
+
mode: ModuleMode;
|
|
1268
|
+
/** 3-way merge 基线(codegen 模式) */
|
|
1269
|
+
baseVersion?: string;
|
|
1270
|
+
}
|
|
1271
|
+
interface AppManifest {
|
|
1272
|
+
templateVersion: string;
|
|
1273
|
+
npmModules: NpmModuleEntry[];
|
|
1274
|
+
}
|
|
1275
|
+
declare function manifestPath(appDir: string): string;
|
|
1276
|
+
/** 读应用 manifest(缺席 → null;损坏/版本非法 → null——宽松解析与 CLI 语义一致) */
|
|
1277
|
+
declare function readAppManifest(appDir: string): AppManifest | null;
|
|
1278
|
+
/** 写应用 manifest(目录缺席物化;同步——写核心串行队列内使用) */
|
|
1279
|
+
declare function writeAppManifest(appDir: string, manifest: AppManifest): void;
|
|
1280
|
+
/** 小程序容器登记项(miniapp-container init 写入;与 npmModules 正交,不参与装配/doctor) */
|
|
1281
|
+
interface MiniappContainerEntry {
|
|
1282
|
+
/** 平台 id:'alipay' / 'weapp'(= CLI platform 参数,展开目录名后缀) */
|
|
1283
|
+
id: string;
|
|
1284
|
+
/** 源包名(@tbox.cn/app-miniapp-container-*) */
|
|
1285
|
+
package: string;
|
|
1286
|
+
version: string;
|
|
1287
|
+
/** 展开目录(相对应用根,如 'apps/miniapp-container-alipay') */
|
|
1288
|
+
dir: string;
|
|
1289
|
+
}
|
|
1290
|
+
interface AppManifestFull extends AppManifest {
|
|
1291
|
+
/** 已初始化的小程序容器(可选——旧 manifest 无此字段,读侧归一为 []) */
|
|
1292
|
+
miniappContainers?: MiniappContainerEntry[];
|
|
1293
|
+
}
|
|
1294
|
+
/** 读应用 manifest(完整面——miniappContainers 归一) */
|
|
1295
|
+
declare function readAppManifestFull(appDir: string): AppManifestFull | null;
|
|
1296
|
+
declare function upsertNpmModule(manifest: AppManifest, entry: NpmModuleEntry): AppManifest;
|
|
1297
|
+
declare function removeNpmModule(manifest: AppManifest, id: string): AppManifest;
|
|
1298
|
+
/** 登记小程序容器(按 id 去重替换;miniapp-container init 用) */
|
|
1299
|
+
declare function upsertMiniappContainer(manifest: AppManifestFull, entry: MiniappContainerEntry): AppManifestFull;
|
|
1300
|
+
/** 更新某模块的元数据(update 命令用:version / baseVersion) */
|
|
1301
|
+
declare function updateNpmModule(manifest: AppManifest, id: string, patch: Partial<Pick<NpmModuleEntry, 'version' | 'baseVersion'>>): AppManifest;
|
|
1302
|
+
/**
|
|
1303
|
+
* 模块 id 合法性:小写字母/数字开头,单词段以单个中划线分隔(无连续/尾部中划线),
|
|
1304
|
+
* 防路径穿越/目录注入,并保证 camelCaseId 派生别名唯一(a-b 与 a--b 不允许共存碰撞)。
|
|
1305
|
+
*/
|
|
1306
|
+
declare function isValidModuleId(id: string): boolean;
|
|
1307
|
+
/** 校验失败抛出(统一错误信息) */
|
|
1308
|
+
declare function assertValidModuleId(id: string, source: string): void;
|
|
1309
|
+
|
|
1310
|
+
/** 桥源形态冻结:ProviderCatalog = contracts TIER0 形状(providers/services/credentialTypes) */
|
|
1311
|
+
interface BridgeProviderCatalog {
|
|
1312
|
+
providers: Record<string, Record<string, {
|
|
1313
|
+
provider: string;
|
|
1314
|
+
implementation: string;
|
|
1315
|
+
credentialType: string;
|
|
1316
|
+
owner: string;
|
|
1317
|
+
local?: boolean;
|
|
1318
|
+
configSchema?: string;
|
|
1319
|
+
credentialSchema?: string;
|
|
1320
|
+
services: string[];
|
|
1321
|
+
}>>;
|
|
1322
|
+
services: Record<string, {
|
|
1323
|
+
optional: boolean;
|
|
1324
|
+
defaults: Array<{
|
|
1325
|
+
provider: string;
|
|
1326
|
+
implementation: string;
|
|
1327
|
+
}>;
|
|
1328
|
+
owners: string[];
|
|
1329
|
+
}>;
|
|
1330
|
+
credentialTypes: Record<string, {
|
|
1331
|
+
owner: string;
|
|
1332
|
+
credentialSchema?: string;
|
|
1333
|
+
}>;
|
|
1334
|
+
}
|
|
1335
|
+
/** 富形态(工厂迁移面):walkManifests 产物直通 */
|
|
1336
|
+
declare function loadProviderCatalogRaw(appDir: string): WalkCatalog;
|
|
1337
|
+
/** 桥源(形态冻结):富形态 → 桥形状投影(demand meta title/description 剥离——桥面无此字段,
|
|
1338
|
+
* additive 差异声明见 app-sdk 桥 golden) */
|
|
1339
|
+
declare function loadProviderCatalog(appDir: string): BridgeProviderCatalog;
|
|
1340
|
+
interface ProviderServiceSchemas {
|
|
1341
|
+
provider: string;
|
|
1342
|
+
service: string;
|
|
1343
|
+
/** 恒数组(H1——通常 1;多 impl = 升级窗口) */
|
|
1344
|
+
implementations: Array<{
|
|
1345
|
+
implementation: string;
|
|
1346
|
+
credentialType: string;
|
|
1347
|
+
}>;
|
|
1348
|
+
integrationSchemas: {
|
|
1349
|
+
configSchema: object | null;
|
|
1350
|
+
credentialSchema: object | null;
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
type ProviderServiceSchemasResult = {
|
|
1354
|
+
found: true;
|
|
1355
|
+
detail: ProviderServiceSchemas;
|
|
1356
|
+
} | {
|
|
1357
|
+
found: false;
|
|
1358
|
+
reason: 'provider-not-found' | 'supply-not-found';
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* integrations.json 文件级读(C3-4 read)。
|
|
1363
|
+
* 严格校验面(≥0.9)在场 → contracts parseIntegrationsConfig(assertNoInlineSecrets →
|
|
1364
|
+
* 旧键直切防线 → zod strict);缺席/降级 → 原文 JSON 透传(谓词宽松透传语义——
|
|
1365
|
+
* doctor 读裸 JSON 先例;写路径门控在工厂边缘,读不阻断静态面)。
|
|
1366
|
+
*/
|
|
1367
|
+
interface ReadIntegrationsResult {
|
|
1368
|
+
/** 解析产物(严格 zod 产物或原文 JSON;文件缺席 → null) */
|
|
1369
|
+
config: Record<string, unknown> | null;
|
|
1370
|
+
/** 严格校验是否已应用(false = 原文透传——<0.9 或未解析降级态) */
|
|
1371
|
+
strict: boolean;
|
|
1372
|
+
contracts: ResolvedContracts;
|
|
1373
|
+
}
|
|
1374
|
+
/** 文件级读(cache 注入优先;无 cache 直读——目录枚举零缓存约束不涉文件内容) */
|
|
1375
|
+
declare function readIntegrationsConfig(appDir: string, cache?: FileCache): Record<string, unknown> | null;
|
|
1376
|
+
/** 带严格校验的读(求值/写路径用——门控由工厂边缘断言,本函数按 strictValidation 分派) */
|
|
1377
|
+
declare function readIntegrationsStrict(appDir: string, cache?: FileCache): Promise<ReadIntegrationsResult>;
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* 凭据双工件·写端(C3-4 credentials;FX-1c 拆分——F3 定序):
|
|
1381
|
+
* credentials / credentialsByInstance(body 唯一非文件字段)→ **纯派生 plan(零 I/O)**
|
|
1382
|
+
* → 消费方(write.ts)ref 回填节点(先于 no-diff 判定)→ 严格校验通过后 `writeCredentialArtifacts`
|
|
1383
|
+
* 落盘(dryRun → 零写盘 + existsSync 预览)。同 stem 已在场 → 重写 + overwrote:true。
|
|
1384
|
+
* 孤儿凭据 = **写后对账**(扫描文件全量 credentialRef 引用 vs 凭据目录全集 →
|
|
1385
|
+
* ORPHANED_CREDENTIAL warning——统一覆盖 DELETE 与 PUT 替换两类来源,只报告不自动清理,D9)。
|
|
1386
|
+
*/
|
|
1387
|
+
interface CredentialInput {
|
|
1388
|
+
type: string;
|
|
1389
|
+
values: Record<string, string>;
|
|
1390
|
+
}
|
|
1391
|
+
interface AppliedCredential {
|
|
1392
|
+
stem: string;
|
|
1393
|
+
ref: string;
|
|
1394
|
+
overwrote: boolean;
|
|
1395
|
+
}
|
|
1396
|
+
/** 凭据工件计划项(纯派生产物——stem/ref 确定性;input 供落盘/校验消费) */
|
|
1397
|
+
interface PlannedCredential {
|
|
1398
|
+
/** 实例级(credentialsByInstance)时在场;应用/服务级根凭据缺席 */
|
|
1399
|
+
instanceId?: string;
|
|
1400
|
+
stem: string;
|
|
1401
|
+
ref: string;
|
|
1402
|
+
input: CredentialInput;
|
|
1403
|
+
}
|
|
1404
|
+
interface OrphanIssue {
|
|
1405
|
+
severity: 'warning';
|
|
1406
|
+
code: 'ORPHANED_CREDENTIAL';
|
|
1407
|
+
service?: string;
|
|
1408
|
+
instance?: string;
|
|
1409
|
+
message: string;
|
|
1410
|
+
}
|
|
1411
|
+
/** 凭据工件在场探测(dryRun 预览与对账共用) */
|
|
1412
|
+
declare function credentialArtifactExists(appDir: string, stem: string): boolean;
|
|
1413
|
+
/** 孤儿凭据写后对账(D9):凭据目录全集 − integrations.json 全量引用 = 孤儿(只报告不清理) */
|
|
1414
|
+
declare function reconcileOrphanCredentials(appDir: string): OrphanIssue[];
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* 写核心(C3-4 write;FX-1c 管线重排——F3 九步定序 + D-B2 语义 + F4 输入扩位):
|
|
1418
|
+
* PUT = 节点全量替换(三同构——body ≡ 文件节点;三 PUT 端点无例外)。
|
|
1419
|
+
*
|
|
1420
|
+
* 九步定序(applyApp / applyService 同构):
|
|
1421
|
+
* 1 输入约束(assertSafeNames 值位 + assertSafeInstanceKeys map 键位——F4)
|
|
1422
|
+
* 2 合并 node → next;文件缺席 → 骨架物化(R13 语义翻转提示入 issues)
|
|
1423
|
+
* 3 凭据校验链(type 匹配 400 + credentialSchema ajv 字段级——schema 缺席宽松;dryRun 也跑)
|
|
1424
|
+
* 4 凭据 stem/ref **纯派生**(plan*——零 I/O)+ ref 回填节点(**先于 no-diff**:
|
|
1425
|
+
* node 缺 ref + 带 credentials → 节点变化 → 全量写;node 已含同 ref → 节点不变 → 纯凭据写)
|
|
1426
|
+
* 5 noDiff(**深度结构等价**,非 stringify);hasCredentialInput
|
|
1427
|
+
* 6 noDiff && 无凭据输入 → 短路 written:false
|
|
1428
|
+
* 7 严格整文档校验(contracts parseIntegrationsConfig——触发 = !noDiff ∥ 有凭据输入)
|
|
1429
|
+
* 8 凭据工件落盘(**后置于校验通过**——防「凭据已写 + zod 拒绝」不一致态;
|
|
1430
|
+
* dryRun → writeCredentialArtifacts 零写盘 + existsSync 预览)
|
|
1431
|
+
* 9 finalize:written = integrations 实写 ∥ 凭据实写(**D-B2**);files 分列两类路径;
|
|
1432
|
+
* restartScheduled = written && onApplied(凭据影响 boot 装配——重启正当);写后缓存失效
|
|
1433
|
+
* 归一化:N1 模块节点 {} → 删 domains[键];N3 服务节点 {} 不归一化(显式通配激活 = 合法 TIER0 态);
|
|
1434
|
+
* N2 已随 ?instance= 退役。dryRun(PUT only):复读完整管线不落盘不排程。
|
|
1435
|
+
* DELETE:节点移除 + 孤儿凭据写后对账(覆盖 DELETE 与 PUT 替换两类来源,只报告不清理——D9)。
|
|
1436
|
+
* 并发:进程内串行(per-factory promise chain 由工厂持有——本模块假设单飞调用)。
|
|
1437
|
+
*/
|
|
1438
|
+
interface SaveResult {
|
|
1439
|
+
written: boolean;
|
|
1440
|
+
restartScheduled: boolean;
|
|
1441
|
+
files: string[];
|
|
1442
|
+
credentials: Array<{
|
|
1443
|
+
stem: string;
|
|
1444
|
+
ref: string;
|
|
1445
|
+
overwrote: boolean;
|
|
1446
|
+
}>;
|
|
1447
|
+
issues: IntegrationServiceIssue[];
|
|
1448
|
+
}
|
|
1449
|
+
interface WriteOptions {
|
|
1450
|
+
dryRun?: boolean;
|
|
1451
|
+
/** body 唯一非文件字段(真值直落 config/credentials/,派生 ref 回填本节点) */
|
|
1452
|
+
credentials?: CredentialInput;
|
|
1453
|
+
credentialsByInstance?: Record<string, CredentialInput>;
|
|
1454
|
+
}
|
|
1455
|
+
interface WriteCoreOptions {
|
|
1456
|
+
onApplied?: () => void;
|
|
1457
|
+
cache?: FileCache;
|
|
1458
|
+
}
|
|
1459
|
+
/** 深度结构等价(非 stringify——键序陷阱误判 diff 防线) */
|
|
1460
|
+
declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
1461
|
+
interface WriteCore {
|
|
1462
|
+
/** 预热(工厂创建/写前调用——严格校验缓存就绪;memoized resolver 后续 1 stat 级) */
|
|
1463
|
+
warmup(): Promise<void>;
|
|
1464
|
+
/** PUT /app/integration(root 节点全集) */
|
|
1465
|
+
applyApp(node: Record<string, unknown>, opts?: WriteOptions): SaveResult;
|
|
1466
|
+
/** PUT /modules/:module/integration(domains 换算;N1 {} 删域键) */
|
|
1467
|
+
applyModule(moduleId: string, node: Record<string, unknown>, opts?: WriteOptions): SaveResult;
|
|
1468
|
+
/** PUT /services/:service/integration(整节点含 instances map;N3 {} 不归一化) */
|
|
1469
|
+
applyService(service: string, node: Record<string, unknown>, opts?: WriteOptions): SaveResult;
|
|
1470
|
+
/** DELETE /services/:service/integration(恒整节点;幂等;无预演) */
|
|
1471
|
+
deleteService(service: string): SaveResult;
|
|
1472
|
+
/** 模块服务域键(module → domains 键 = 服务集派生域键集 upsert 位) */
|
|
1473
|
+
moduleDomainKey(moduleId: string): string | undefined;
|
|
1474
|
+
}
|
|
1475
|
+
declare function createWriteCore(appDir: string, opts?: WriteCoreOptions): WriteCore;
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* mock 槽绑定生成器(自 CLI mock-bindings.ts 迁入;provider 拆包 F3 收敛 · B 方案;integrations v4 零拓扑形态):
|
|
1479
|
+
* 应用内 config/integrations.json 缺席时,从已装模块 manifest 的 local:true 槽派生全槽 mock 绑定。
|
|
1480
|
+
*
|
|
1481
|
+
* 语义边界(零改动迁移):
|
|
1482
|
+
* - 缺席即跳过、永不覆盖(在场文件 = 用户/素材真源,生成器零侵入);
|
|
1483
|
+
* - 只绑 local:true 槽(真厂商 provider 永不自动绑定);
|
|
1484
|
+
* - sync 不触发(add = 新事实进入体系,sync = 状态重放)。
|
|
1485
|
+
* 迁移顺带修复:writeFileSync → writeAtomic(原子写;H5)。
|
|
1486
|
+
* 模块发现改 walkManifests(单源——CLI listLocalModules 并入)。
|
|
1487
|
+
*/
|
|
1488
|
+
interface MockBindingsResult {
|
|
1489
|
+
generated: boolean;
|
|
1490
|
+
reason: 'in-place' | 'no-local-slots' | 'generated';
|
|
1491
|
+
/** 本次生成(或在场文件阻断时的空集)涉及的 local 槽服务名 */
|
|
1492
|
+
services: string[];
|
|
1493
|
+
}
|
|
1494
|
+
declare function ensureMockBindings(appDir: string): MockBindingsResult;
|
|
1495
|
+
|
|
1496
|
+
/**
|
|
1497
|
+
* AppToolkitError(领域 6 码 + 壳层 2 码分界——toolkit 只产领域码):
|
|
1498
|
+
* VALIDATION_FAILED(400) / SERVICE_NOT_FOUND(404) / MODULE_NOT_FOUND(404) /
|
|
1499
|
+
* PROVIDER_NOT_FOUND(404) / SUPPLY_NOT_FOUND(404) / CONTRACTS_NOT_RESOLVED(503)。
|
|
1500
|
+
* AUTH_REQUIRED / ROUTE_NOT_FOUND 为 HTTP 层事实(壳层产生)——6 + 2 = 8(api.md §5)。
|
|
1501
|
+
*
|
|
1502
|
+
* **name 约定(仓规约束①——mangle 安全真源 process note 2026-09-11-publish-dist-minify)**:
|
|
1503
|
+
* 构造器必须字符串字面量赋值 `this.name = 'AppToolkitError'`(禁 `this.name = X.name` binding
|
|
1504
|
+
* 形态——src 态守卫不可见、mangle 后静默漂移);守卫 = tests/error-name-safety.test.ts(C4)。
|
|
1505
|
+
* 消费面属性分发(.httpStatus/.code/.fields——比 err.name 分发更宽裕)。
|
|
1506
|
+
*/
|
|
1507
|
+
type AppToolkitErrorCode = 'VALIDATION_FAILED' | 'SERVICE_NOT_FOUND' | 'MODULE_NOT_FOUND' | 'PROVIDER_NOT_FOUND' | 'SUPPLY_NOT_FOUND' | 'CONTRACTS_NOT_RESOLVED';
|
|
1508
|
+
declare class AppToolkitError extends Error {
|
|
1509
|
+
readonly code: AppToolkitErrorCode;
|
|
1510
|
+
readonly httpStatus: number;
|
|
1511
|
+
readonly fields?: string[];
|
|
1512
|
+
constructor(code: AppToolkitErrorCode, httpStatus: number, message: string, fields?: string[]);
|
|
1513
|
+
}
|
|
1514
|
+
/** CONTRACTS_NOT_RESOLVED 三分支 message(N1 构建指引——api.md 错误信封示例) */
|
|
1515
|
+
declare function contractsNotResolvedMessage(contracts: {
|
|
1516
|
+
version: string | null;
|
|
1517
|
+
strictValidation: boolean;
|
|
1518
|
+
notes: readonly string[];
|
|
1519
|
+
}): string;
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* DTO 全量(api.md §3 字段级单源落源——28 类型;演进 additive-only,铁律 #8)。
|
|
1523
|
+
* agtcodingbox / tbox-ai-coding 经 `import type` 消费(L2 DTO 单源——API 层零类型镜像)。
|
|
1524
|
+
* 词汇七概念:app / module / service / instance / provider / integration / resolution。
|
|
1525
|
+
* 弃用词汇清单见 api.md §3 尾(component/slot/scope/configMode/…——防复活)。
|
|
1526
|
+
*/
|
|
1527
|
+
/** contracts 求值五态原样(EffectiveServiceResolution.status) */
|
|
1528
|
+
type ServiceStatus = 'ok' | 'service-not-configured' | 'instance-not-found' | 'instance-disabled' | 'binding-unresolved';
|
|
1529
|
+
/** 四配置层(instance 为 map 字段层) */
|
|
1530
|
+
type BindingLayer = 'app' | 'module' | 'service' | 'instance';
|
|
1531
|
+
/** 纯模块清单(无 services——卡片展开走 /modules/:m) */
|
|
1532
|
+
interface ModulesView {
|
|
1533
|
+
modules: ModuleDeclaration[];
|
|
1534
|
+
}
|
|
1535
|
+
interface ModuleDeclaration {
|
|
1536
|
+
/** install id(packages/ 目录名 / .tbox/app.json entry.id) */
|
|
1537
|
+
id: string;
|
|
1538
|
+
/** 包名 */
|
|
1539
|
+
name: string;
|
|
1540
|
+
title: string;
|
|
1541
|
+
description: string;
|
|
1542
|
+
}
|
|
1543
|
+
/** 服务需求声明(模块 demand 单元;defaults 唯一落位 ServiceDetail) */
|
|
1544
|
+
interface ServiceDemand {
|
|
1545
|
+
service: string;
|
|
1546
|
+
/** manifest demand meta;缺席 UI 回退 service id */
|
|
1547
|
+
title?: string;
|
|
1548
|
+
description?: string;
|
|
1549
|
+
/** demand optional !== false(多模块 OR 聚合见 resolution echo) */
|
|
1550
|
+
required: boolean;
|
|
1551
|
+
}
|
|
1552
|
+
/** GET /modules/:module(模块静态一站式 · PUT 读对偶) */
|
|
1553
|
+
interface ModuleDetailView {
|
|
1554
|
+
/** domains[换算键] 节点原值;未配置 = null */
|
|
1555
|
+
integration: ModuleIntegrationNode | null;
|
|
1556
|
+
/** 本模块 demand(卡片展开 + 编辑器静态上下文自足) */
|
|
1557
|
+
services: ServiceDemand[];
|
|
1558
|
+
}
|
|
1559
|
+
/** GET /app(应用静态视图:平台服务 + root 原值) */
|
|
1560
|
+
interface AppView {
|
|
1561
|
+
/** 平台服务 id(服务词汇 − 模块占用;owner/标题 UI 按首点段派生) */
|
|
1562
|
+
services: string[];
|
|
1563
|
+
/** root 节点原值;文件缺席 = null */
|
|
1564
|
+
integration: AppIntegrationNode | null;
|
|
1565
|
+
}
|
|
1566
|
+
/** GET /services/:service(服务静态单体) */
|
|
1567
|
+
interface ServiceDetail extends ServiceDemand {
|
|
1568
|
+
/** manifest 预填(唯一落位) */
|
|
1569
|
+
defaults: Array<{
|
|
1570
|
+
provider: string;
|
|
1571
|
+
implementation: string;
|
|
1572
|
+
}>;
|
|
1573
|
+
/** 文件 services[s] 逐字原值(编辑预填源);无声明 = null */
|
|
1574
|
+
integration: ServiceIntegrationNode | null;
|
|
1575
|
+
/** 供给该服务的厂商名单(catalog 静态切片——picker 数据源) */
|
|
1576
|
+
suppliedBy: string[];
|
|
1577
|
+
}
|
|
1578
|
+
/** GET /service-resolutions(批量求值 · 唯一求值集合面) */
|
|
1579
|
+
interface ServiceResolutionsView {
|
|
1580
|
+
/** P6 contracts echo(仅求值轴两端点携带) */
|
|
1581
|
+
contracts: ContractsResolution;
|
|
1582
|
+
/** 键集 = 服务词汇 ∪ 已配置(模块/平台/孤儿全量) */
|
|
1583
|
+
resolutions: Record<string, ServiceResolutionEntry>;
|
|
1584
|
+
/** 谓词全量(doctor 同源;恒全量——subset 消费方客户端过滤) */
|
|
1585
|
+
issues: IntegrationIssue[];
|
|
1586
|
+
}
|
|
1587
|
+
/** 求值摘要单元(行内嵌;P14 单一形状) */
|
|
1588
|
+
interface ServiceResolutionEntry {
|
|
1589
|
+
/** 默认实例口径(normalizeInstances 委托) */
|
|
1590
|
+
status: ServiceStatus;
|
|
1591
|
+
statusMessage?: string;
|
|
1592
|
+
/** 最特异声明层厂商名(跨层事实) */
|
|
1593
|
+
provider?: string;
|
|
1594
|
+
/** provider 在场时在场:(provider, service) ∈ 供给关系 */
|
|
1595
|
+
supplied?: boolean;
|
|
1596
|
+
/** owner 模块 install id;平台服务/孤儿缺席 */
|
|
1597
|
+
module?: string;
|
|
1598
|
+
/** demand echo(OR 聚合);平台/孤儿恒 false;集成就绪判定单源(§7) */
|
|
1599
|
+
required?: boolean;
|
|
1600
|
+
}
|
|
1601
|
+
/** 求值完整结构(extends = 列表项 ⊂ 单体的编译期保证——P14) */
|
|
1602
|
+
interface ServiceResolution extends ServiceResolutionEntry {
|
|
1603
|
+
/** P4 枚举规则(全实例逐一;默认实例求值 = 摘要基,不重复头部) */
|
|
1604
|
+
instances: ResolvedInstance[];
|
|
1605
|
+
inheritance: Array<{
|
|
1606
|
+
layer: BindingLayer;
|
|
1607
|
+
provider?: string;
|
|
1608
|
+
implementation?: string;
|
|
1609
|
+
}>;
|
|
1610
|
+
}
|
|
1611
|
+
/** GET /service-resolutions/:service(求值单体) */
|
|
1612
|
+
interface ServiceResolutionDetail {
|
|
1613
|
+
contracts: ContractsResolution;
|
|
1614
|
+
resolution: ServiceResolution;
|
|
1615
|
+
/** service === :service 过滤子集 */
|
|
1616
|
+
issues: IntegrationIssue[];
|
|
1617
|
+
}
|
|
1618
|
+
/** root 节点 */
|
|
1619
|
+
interface AppIntegrationNode {
|
|
1620
|
+
/** 恒字符串(app/module 级无内联形态) */
|
|
1621
|
+
provider?: string;
|
|
1622
|
+
config?: Record<string, unknown>;
|
|
1623
|
+
configByInstance?: Record<string, Record<string, unknown>>;
|
|
1624
|
+
credentialRef?: string;
|
|
1625
|
+
credentialRefByInstance?: Record<string, string>;
|
|
1626
|
+
/** 整组替换(id 字符集受输入约束①) */
|
|
1627
|
+
instances?: Array<{
|
|
1628
|
+
id: string;
|
|
1629
|
+
name: string;
|
|
1630
|
+
attributes?: Record<string, unknown>;
|
|
1631
|
+
}>;
|
|
1632
|
+
defaultInstanceId?: string | null;
|
|
1633
|
+
}
|
|
1634
|
+
/** AppIntegrationNode 键集单源(runtime const——write applyApp 全量替换白名单
|
|
1635
|
+
* (缺席根键删除;services/domains/modules 域不在其中)+ views/app 投影(GET 预填 ≡ PUT body,
|
|
1636
|
+
* D21/L1——文件含 services/domains 但 root 节点投影只含本键集)) */
|
|
1637
|
+
declare const APP_INTEGRATION_NODE_KEYS: readonly ["provider", "config", "configByInstance", "credentialRef", "credentialRefByInstance", "instances", "defaultInstanceId"];
|
|
1638
|
+
/** 模块域节点(恒字符串 provider——域层无凭据位,契约事实) */
|
|
1639
|
+
interface ModuleIntegrationNode {
|
|
1640
|
+
provider?: string;
|
|
1641
|
+
config?: Record<string, unknown>;
|
|
1642
|
+
}
|
|
1643
|
+
/** services[s] 整节点 */
|
|
1644
|
+
interface ServiceIntegrationNode {
|
|
1645
|
+
/** 对象 = 自定义 API(仅槽级,P2) */
|
|
1646
|
+
provider?: string | InlineVendorDeclaration;
|
|
1647
|
+
/** 内联 provider 时必填 */
|
|
1648
|
+
implementation?: string;
|
|
1649
|
+
config?: Record<string, unknown>;
|
|
1650
|
+
credentialRef?: string;
|
|
1651
|
+
/** 键 = instanceId / '*'(随节点全量替换) */
|
|
1652
|
+
instances?: Record<string, ServiceInstanceNode>;
|
|
1653
|
+
}
|
|
1654
|
+
/** services[s].instances[k] 节点 */
|
|
1655
|
+
interface ServiceInstanceNode {
|
|
1656
|
+
/** provider 恒字符串(内联仅槽级合法) */
|
|
1657
|
+
provider?: string;
|
|
1658
|
+
implementation?: string;
|
|
1659
|
+
config?: Record<string, unknown>;
|
|
1660
|
+
credentialRef?: string;
|
|
1661
|
+
/** 缺省 true;false → instance-disabled */
|
|
1662
|
+
enabled?: boolean;
|
|
1663
|
+
}
|
|
1664
|
+
interface InlineVendorDeclaration {
|
|
1665
|
+
provider: string;
|
|
1666
|
+
credentialType: string;
|
|
1667
|
+
configSchema?: string;
|
|
1668
|
+
}
|
|
1669
|
+
interface CredentialValues {
|
|
1670
|
+
type: string;
|
|
1671
|
+
values: Record<string, string>;
|
|
1672
|
+
}
|
|
1673
|
+
interface ResolvedInstance {
|
|
1674
|
+
/** 注册表 id;'*' = 通配 */
|
|
1675
|
+
instanceId: string;
|
|
1676
|
+
status: ServiceStatus;
|
|
1677
|
+
/** 逐实例诊断(binding-unresolved 等直投) */
|
|
1678
|
+
statusMessage?: string;
|
|
1679
|
+
/** 该实例合并结果 */
|
|
1680
|
+
effective?: EffectiveBinding;
|
|
1681
|
+
/** 掩码回显 */
|
|
1682
|
+
credential?: CredentialEcho;
|
|
1683
|
+
}
|
|
1684
|
+
/** GET /providers:厂商基本信息 */
|
|
1685
|
+
interface ProvidersView {
|
|
1686
|
+
providers: ProviderEntry[];
|
|
1687
|
+
}
|
|
1688
|
+
interface ProviderEntry {
|
|
1689
|
+
provider: string;
|
|
1690
|
+
/** Mock 旗标(provider 级聚合) */
|
|
1691
|
+
local: boolean;
|
|
1692
|
+
/** 供给声明来源包名 */
|
|
1693
|
+
owner: string;
|
|
1694
|
+
}
|
|
1695
|
+
/** GET /providers/:provider:供给足迹 */
|
|
1696
|
+
interface ProviderDetail {
|
|
1697
|
+
provider: string;
|
|
1698
|
+
local: boolean;
|
|
1699
|
+
owner: string;
|
|
1700
|
+
/** per (provider, service) 保真,同厂商异构合法;★ implementations 恒数组(H1——
|
|
1701
|
+
* 多元素 = 升级窗口,UI 出 impl 选择器,PUT 显式钉版) */
|
|
1702
|
+
services: Record<string, {
|
|
1703
|
+
implementations: Array<{
|
|
1704
|
+
implementation: string;
|
|
1705
|
+
credentialType: string;
|
|
1706
|
+
}>;
|
|
1707
|
+
}>;
|
|
1708
|
+
}
|
|
1709
|
+
/** GET /providers/:p/services/:s:表单 schema 唯一暴露面 */
|
|
1710
|
+
interface ProviderServiceDetail {
|
|
1711
|
+
provider: string;
|
|
1712
|
+
service: string;
|
|
1713
|
+
/** ★ 恒数组(通常 1) */
|
|
1714
|
+
implementations: Array<{
|
|
1715
|
+
implementation: string;
|
|
1716
|
+
credentialType: string;
|
|
1717
|
+
}>;
|
|
1718
|
+
/** 厂商集成该服务的表单 schema(integration 域专属) */
|
|
1719
|
+
integrationSchemas: {
|
|
1720
|
+
/** raw draft 2020-12 原文零转换;供给在场未声明 = null(mock 合法);解析自默认 impl */
|
|
1721
|
+
configSchema: object | null;
|
|
1722
|
+
credentialSchema: object | null;
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
interface EffectiveBinding {
|
|
1726
|
+
/** custom 时 provider = 内联声明厂商名 */
|
|
1727
|
+
provider: string;
|
|
1728
|
+
implementation: string;
|
|
1729
|
+
config?: Record<string, unknown>;
|
|
1730
|
+
/** 'secret://{stem}' */
|
|
1731
|
+
credentialRef?: string;
|
|
1732
|
+
layer: BindingLayer;
|
|
1733
|
+
}
|
|
1734
|
+
/** GET 永无真值 */
|
|
1735
|
+
interface CredentialEcho {
|
|
1736
|
+
/** credentialType(manifest 对齐) */
|
|
1737
|
+
type: string;
|
|
1738
|
+
/** 'secret://{stem}' */
|
|
1739
|
+
ref: string;
|
|
1740
|
+
/** 'config/credentials/{stem}.json' */
|
|
1741
|
+
file: string;
|
|
1742
|
+
/** 前 2 字符 + '****';≤4 字符全掩码;null = 缺字段 */
|
|
1743
|
+
masked: Record<string, string | null>;
|
|
1744
|
+
}
|
|
1745
|
+
interface ContractsResolution {
|
|
1746
|
+
version: string | null;
|
|
1747
|
+
evaluation: boolean;
|
|
1748
|
+
strictValidation: boolean;
|
|
1749
|
+
notes: string[];
|
|
1750
|
+
}
|
|
1751
|
+
/** 字段级真源 = 谓词结构化输出(H7) */
|
|
1752
|
+
interface IntegrationIssue {
|
|
1753
|
+
severity: 'error' | 'warning';
|
|
1754
|
+
/** 枚举单源 = 谓词文件头检查族编号映射(additive-only) */
|
|
1755
|
+
code: string;
|
|
1756
|
+
message: string;
|
|
1757
|
+
service?: string;
|
|
1758
|
+
module?: string;
|
|
1759
|
+
instance?: string;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* 视图装配共享上下文(五投影共用;目录枚举零缓存——walkManifests 每次调用执行)。
|
|
1764
|
+
* 域前缀换算(service → 首点段)= 本地一行 helper(文件格式词汇,静态面零 contracts 依赖)。
|
|
1765
|
+
*/
|
|
1766
|
+
interface ViewContext {
|
|
1767
|
+
appDir: string;
|
|
1768
|
+
cache?: FileCache;
|
|
1769
|
+
}
|
|
1770
|
+
interface ViewSnapshot {
|
|
1771
|
+
appDir: string;
|
|
1772
|
+
walk: WalkManifestsResult;
|
|
1773
|
+
catalog: WalkCatalog;
|
|
1774
|
+
integrations: Record<string, unknown> | null;
|
|
1775
|
+
contracts: ResolvedContracts;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* 需求轴/模块静态投影(views/modules;C4)。静态端点结构性零求值(铁律 #3——
|
|
1780
|
+
* 无 resolution/issues/contracts 键,永不 503)。
|
|
1781
|
+
*/
|
|
1782
|
+
/** GET /modules:纯模块清单(demand 不在——卡片展开 = GET /modules/:m) */
|
|
1783
|
+
declare function loadModulesView(snapshot: ViewSnapshot): {
|
|
1784
|
+
modules: ModuleDeclaration[];
|
|
1785
|
+
};
|
|
1786
|
+
/** 域键换算(模块服务集派生域键集;单域 = 该域,多域/零域 = 模块 id——与 write.moduleDomainKey 同约定) */
|
|
1787
|
+
declare function moduleDomainKeyOf(services: ServiceDemand[], moduleId: string): string;
|
|
1788
|
+
/** GET /modules/:module:模块静态一站式(integration 节点原值 + demand;PUT 读对偶) */
|
|
1789
|
+
declare function loadModuleDetailView(snapshot: ViewSnapshot, moduleId: string): ModuleDetailView;
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* 应用静态投影(views/app;C4;FX-1c B10——root 节点投影修)。
|
|
1793
|
+
* /app = 平台服务 + root 节点原值(纯静态,D12):
|
|
1794
|
+
* services = 服务词汇 − 模块占用(裸 string[]——owner/标题 UI 按首点段派生,F2);
|
|
1795
|
+
* 平台服务状态不在此(→ /service-resolutions);模块服务不在此(→ /modules/:m)。
|
|
1796
|
+
* integration = **root 节点投影**(APP_INTEGRATION_NODE_KEYS——D21/L1:GET 预填 ≡ PUT body;
|
|
1797
|
+
* 文件另含 services/domains/modules 域键,不进 root 节点投影——原实现整文件透传,
|
|
1798
|
+
* PUT 回会级联写回域键);文件缺席 = null,文件在场 → 投影对象(可为空)。
|
|
1799
|
+
*/
|
|
1800
|
+
declare function loadAppView(snapshot: ViewSnapshot): AppView;
|
|
1801
|
+
|
|
1802
|
+
/**
|
|
1803
|
+
* 服务静态单体投影(views/service-detail;C4)。求值数据不在此(→ /service-resolutions/:service)。
|
|
1804
|
+
* SERVICE_NOT_FOUND 判据 = 服务词汇 ∪ 已配置(P9——词汇成员零 demand/供给/config 仍 200)。
|
|
1805
|
+
*/
|
|
1806
|
+
declare function loadServiceDetailView(snapshot: ViewSnapshot, service: string): ServiceDetail;
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* 供给轴投影(views/providers;C4)。供给关系三切片(P5):
|
|
1810
|
+
* 名单 = /providers(基本信息)· 足迹 = /providers/:p(implementations[] 保真)·
|
|
1811
|
+
* 表单 = /providers/:p/services/:s(组合单体——schema 唯一暴露面 P10)。
|
|
1812
|
+
* 静态端点零求值(铁律 #3)。
|
|
1813
|
+
*/
|
|
1814
|
+
/** GET /providers:厂商基本信息(供给足迹不在本端点 → /providers/:p) */
|
|
1815
|
+
declare function loadProvidersView(snapshot: ViewSnapshot): ProvidersView;
|
|
1816
|
+
/** GET /providers/:provider:供给足迹(implementations 恒数组——H1 多实现钉版数据源) */
|
|
1817
|
+
declare function loadProviderDetailView(snapshot: ViewSnapshot, provider: string): ProviderDetail;
|
|
1818
|
+
/** 组合单体(GET /providers/:p/services/:s):catalog 供给与槽级内联声明统一解析(P10/P11) */
|
|
1819
|
+
declare function loadProviderServiceDetailView(snapshot: ViewSnapshot, provider: string, service: string): ProviderServiceDetail;
|
|
1820
|
+
|
|
1821
|
+
/** P14 单源摘要函数:/service-resolutions map 值 ≡ /service-resolutions/:s 的 resolution 摘要基 */
|
|
1822
|
+
declare function resolveServiceSummary(service: string, snapshot: ViewSnapshot): ServiceResolutionEntry;
|
|
1823
|
+
/** 批量求值(键集 = 服务词汇 ∪ 已配置;?service= 过滤语义——未知键缺席;issues 恒全量) */
|
|
1824
|
+
declare function loadServiceResolutionsView(snapshot: ViewSnapshot, issues: IntegrationIssue[], filter?: string[]): ServiceResolutionsView;
|
|
1825
|
+
/** 求值单体(完整结构 instances + inheritance + 过滤 issues;P14 extends 结构保证) */
|
|
1826
|
+
declare function loadServiceResolutionDetail(service: string, snapshot: ViewSnapshot, allIssues: IntegrationIssue[]): ServiceResolutionDetail;
|
|
1827
|
+
|
|
1828
|
+
/**
|
|
1829
|
+
* createAppToolkit(C4 工厂):22 方法 = 9 读(HTTP 直通)+ 4 写(HTTP 直通)+ 9 迁移面(Internals)。
|
|
1830
|
+
* AppToolkit = AppToolkitRead & AppToolkitWrite & AppToolkitInternals——
|
|
1831
|
+
* Read+Write = HTTP 直通面 additive 冻结(L1 端点↔方法 1:1,L3 命名镜像:Integration=节点级 /
|
|
1832
|
+
* Config=文件级);Internals = CLI/doctor/桥消费(自由演进)。
|
|
1833
|
+
*
|
|
1834
|
+
* **门控断言单点(policy at edge)**:求值(2)+ 写(4)+ ensureMockBindings / writeIntegrationsConfig /
|
|
1835
|
+
* evaluateIntegrationServices 入口 assertContractsUsable——strictValidation === false → 503
|
|
1836
|
+
* CONTRACTS_NOT_RESOLVED(message 三分支);静态方法不门控(永不 503——铁律 #3);
|
|
1837
|
+
* integrations/ views/ 机制层保持纯函数。
|
|
1838
|
+
*
|
|
1839
|
+
* 并发:进程内写串行(per-factory promise chain)+ 原子写 + 写后本实例缓存即刻失效(D26)。
|
|
1840
|
+
* onApplied(D7):toolkit 判定「需要重启」(实际落盘且非 dryRun/no-diff)→ 调用一次 +
|
|
1841
|
+
* restartScheduled 回填——通知闭包非控制,执行者恒为宿主 RunManager;CLI 不传恒 false。
|
|
1842
|
+
*/
|
|
1843
|
+
interface AppToolkitOptions {
|
|
1844
|
+
/** 写成功(实际落盘且非 dryRun/no-diff)→ 调用一次(宿主闭包内防抖/守卫);CLI 不传恒 false */
|
|
1845
|
+
onApplied?: () => void;
|
|
1846
|
+
}
|
|
1847
|
+
/** ── HTTP 直通面(9 读;L1 镜像律:方法名 = load + URL 资源段)── */
|
|
1848
|
+
interface AppToolkitRead {
|
|
1849
|
+
loadModules(): Promise<ModulesView>;
|
|
1850
|
+
loadModule(moduleId: string): Promise<ModuleDetailView>;
|
|
1851
|
+
loadApp(): Promise<AppView>;
|
|
1852
|
+
loadService(service: string): Promise<ServiceDetail>;
|
|
1853
|
+
loadServiceResolutions(services?: string[]): Promise<ServiceResolutionsView>;
|
|
1854
|
+
loadServiceResolution(service: string): Promise<ServiceResolutionDetail>;
|
|
1855
|
+
loadProviders(): Promise<ProvidersView>;
|
|
1856
|
+
loadProvider(provider: string): Promise<ProviderDetail>;
|
|
1857
|
+
loadProviderService(provider: string, service: string): Promise<ProviderServiceDetail>;
|
|
1858
|
+
}
|
|
1859
|
+
/** ── HTTP 直通面(4 写;body ≡ 文件节点全量替换;DELETE 无 dryRun/无 options)── */
|
|
1860
|
+
interface AppToolkitWrite {
|
|
1861
|
+
writeAppIntegration(node: AppIntegrationNode, o?: {
|
|
1862
|
+
dryRun?: boolean;
|
|
1863
|
+
credentials?: {
|
|
1864
|
+
type: string;
|
|
1865
|
+
values: Record<string, string>;
|
|
1866
|
+
};
|
|
1867
|
+
credentialsByInstance?: Record<string, {
|
|
1868
|
+
type: string;
|
|
1869
|
+
values: Record<string, string>;
|
|
1870
|
+
}>;
|
|
1871
|
+
}): Promise<SaveResult>;
|
|
1872
|
+
writeModuleIntegration(moduleId: string, node: ModuleIntegrationNode, o?: {
|
|
1873
|
+
dryRun?: boolean;
|
|
1874
|
+
}): Promise<SaveResult>;
|
|
1875
|
+
writeServiceIntegration(service: string, node: ServiceIntegrationNode, o?: {
|
|
1876
|
+
dryRun?: boolean;
|
|
1877
|
+
credentials?: {
|
|
1878
|
+
type: string;
|
|
1879
|
+
values: Record<string, string>;
|
|
1880
|
+
};
|
|
1881
|
+
credentialsByInstance?: Record<string, {
|
|
1882
|
+
type: string;
|
|
1883
|
+
values: Record<string, string>;
|
|
1884
|
+
}>;
|
|
1885
|
+
}): Promise<SaveResult>;
|
|
1886
|
+
deleteServiceIntegration(service: string): Promise<SaveResult>;
|
|
1887
|
+
}
|
|
1888
|
+
/** ── Internals(9,非 HTTP 面;L3 宾语消歧:Integration=节点级 / Config=文件级)── */
|
|
1889
|
+
interface AppToolkitInternals {
|
|
1890
|
+
/** 逃生舱:正常路径无需调用(Freshness Contract 自动);测试/宿主特殊场景 */
|
|
1891
|
+
invalidate(): void;
|
|
1892
|
+
resolveContracts(): Promise<ResolvedContracts>;
|
|
1893
|
+
/** 四产物(枚举零缓存——契约机制载体) */
|
|
1894
|
+
walkManifests(): WalkManifestsResult;
|
|
1895
|
+
parseModuleDescriptor(raw: unknown): ReturnType<typeof parseModuleDescriptor>;
|
|
1896
|
+
/** 富形态(≠ 包级桥源 loadProviderCatalog,双形态有意) */
|
|
1897
|
+
loadProviderCatalogRaw(): ReturnType<typeof loadProviderCatalogRaw>;
|
|
1898
|
+
/** 文件级读(doctor/migrate;宽松透传——strict 校验归门控面) */
|
|
1899
|
+
readIntegrationsConfig(): Promise<Record<string, unknown> | null>;
|
|
1900
|
+
/** 文件级整写(provider-migrate;门控同款) */
|
|
1901
|
+
writeIntegrationsConfig(config: Record<string, unknown>): Promise<void>;
|
|
1902
|
+
ensureMockBindings(): Promise<ReturnType<typeof ensureMockBindings>>;
|
|
1903
|
+
/** 谓词单源(contracts 注入签名;结构化输出) */
|
|
1904
|
+
evaluateIntegrationServices(input: Omit<Parameters<typeof evaluateIntegrationServices>[0], 'contracts'>): Promise<IntegrationServiceIssue[]>;
|
|
1905
|
+
}
|
|
1906
|
+
type AppToolkit = AppToolkitRead & AppToolkitWrite & AppToolkitInternals;
|
|
1907
|
+
declare function createAppToolkit(appDir: string, options?: AppToolkitOptions): AppToolkit;
|
|
1908
|
+
|
|
1909
|
+
export { APP_INTEGRATION_NODE_KEYS, type AppIntegrationNode, type AppManifest, type AppManifestFull, type AppToolkit, AppToolkitError, type AppToolkitErrorCode, type AppToolkitInternals, type AppToolkitOptions, type AppToolkitRead, type AppToolkitWrite, type AppView, type AppliedCredential, type BindingLayer, type BridgeProviderCatalog, type CardContrib, type ContractsResolution, type CredentialEcho, type CredentialFile, type CredentialInput, type CredentialValues, type DeclaredModuleInfo, type EffectiveBinding, type EnvExpansionResult, type EvaluationExports, type FileCache, type InlineVendorDeclaration, type IntegrationIssue, type IntegrationServiceIssue, type IntegrationServicePredicateInput, type MiniappContainerEntry, type MockBindingsResult, type ModuleDeclaration, type ModuleDescriptor, type ModuleDetailView, type ModuleIntegrationNode, type ModuleMode, type ModulesView, type NpmModuleEntry, type OrphanIssue, type ParseModuleResult, type PlannedCredential, type PredicateAssembly, type PredicateContracts, type PredicateIoInputs, type ProviderDetail, type ProviderEntry, type ProviderServiceDetail, type ProviderServiceSchemas, type ProviderServiceSchemasResult, type ProviderSlotContrib, type ProvidersView, type ReadIntegrationsResult, type ResolvedContracts, type ResolvedInstance, type ResolvedModule, type ResourceNeedContrib, SAFE_NAME_PATTERN, type SaveResult, type ServiceDemand, type ServiceDetail, type ServiceInstanceNode, type ServiceIntegrationNode, type ServiceNeedContrib, type ServiceResolution, type ServiceResolutionDetail, type ServiceResolutionEntry, type ServiceResolutionsView, type ServiceStatus, type StemInput, type SupplyLookup, type ViewContext, type ViewSnapshot, type WalkCatalog, type WalkManifestsResult, type WalkModuleInfo, type WalkProviderEntry, type WriteCore, type WriteCoreOptions, type WriteOptions, assertValidModuleId, buildPredicateAssembly, checkInstanceKeys, collectDeclaredModules, contractsNotResolvedMessage, createAppToolkit, createFileCache, createWriteCore, credentialArtifactExists, deepEqual, deriveStem, ensureDir, ensureMockBindings, evaluateIntegrationServices, expandEnvVars, extractModuleIdFromSource, invalidateContractsResolver, isControlledInlineProvider, isValidModuleId, loadAppView, loadModuleDetailView, loadModulesView, loadProviderCatalog, loadProviderCatalogRaw, loadProviderDetailView, loadProviderServiceDetailView, loadProvidersView, loadServiceDetailView, loadServiceResolutionDetail, loadServiceResolutionsView, manifestPath, maskCredentialValues, moduleDependencySchema, moduleDescriptorSchema, moduleDomainKeyOf, pageContribSchema, parseModuleDescriptor, providerSlotContribSchema, readAppManifest, readAppManifestFull, readCredentialFile, readIntegrationsConfig, readIntegrationsStrict, reconcileOrphanCredentials, refToEnvKey, removeNpmModule, resolveContractsForApp, resolveContractsForApp as resolveContractsForAppExport, resolveServiceSummary, resourceNeedContribSchema, serviceNeedContribSchema, stemToFilePath, stemToRef, tabContribSchema, updateNpmModule, upsertMiniappContainer, upsertNpmModule, walkManifests, writeAppManifest, writeAtomic, writeCredentialFile };
|