@boringparts/lioni 0.0.0-stage → 0.4.2
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/dist/cli.d.ts +1 -0
- package/dist/cli.js +959 -0
- package/dist/dist-BjI3h4o3.js +3797 -0
- package/dist/index.d.ts +724 -0
- package/dist/index.js +3862 -0
- package/dist/node-Bb9WsnGu.js +233 -0
- package/dist/node.d.ts +26 -0
- package/dist/node.js +108 -0
- package/dist/report-EsWS84c0.js +93 -0
- package/dist/yaml-DX1EEaWD.js +331 -0
- package/dist/yaml-Dn7jqV-s.d.ts +1027 -0
- package/package.json +72 -3
- package/README.md +0 -3
|
@@ -0,0 +1,1027 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { StandardSchemaV1, StandardTypedV1 } from "@standard-schema/spec";
|
|
3
|
+
/**
|
|
4
|
+
* 框架阶段、检查项准备及候选处理子阶段;同名阶段按所在层级解释。
|
|
5
|
+
* 运行级 snapshot 记录资源读取和关联耗时,checks 包含公共准备、检查计算和豁免汇总。
|
|
6
|
+
* prepareInput 包含逐候选输入准备与验证;fingerprint 仅为摘要与缓存键计算。
|
|
7
|
+
* 检查对象的 snapshot 记录复制结果的耗时,results 记录归集诊断和执行记录的耗时。
|
|
8
|
+
*/
|
|
9
|
+
type QualityProfileStage = "configuration" | "suppressions" | "snapshot" | "load" | "candidates" | "checks" | "cleanup" | "prepareInput" | "fingerprint" | "cacheRead" | "execute" | "cacheWrite" | "results";
|
|
10
|
+
/** 候选中断独立于规则结果。 */
|
|
11
|
+
type QualityProfileCandidateStatus = "complete" | "failed" | "not-run" | "interrupted";
|
|
12
|
+
type CacheReads = Record<"hit" | "miss" | "invalid" | "error", number>;
|
|
13
|
+
type CacheWrites = Record<"completed" | "error", number>;
|
|
14
|
+
/** 缓存接口可见证据;适配器内部吞掉的错误不计入 error。 */
|
|
15
|
+
type QualityProfileCache = {
|
|
16
|
+
readonly enabled: boolean;
|
|
17
|
+
/** miss 仅表示 get 返回 undefined,不能证明底层存储不存在。 */
|
|
18
|
+
readonly reads: Readonly<CacheReads>;
|
|
19
|
+
/** completed 仅表示 set 正常返回,不保证已落盘。 */
|
|
20
|
+
readonly writes: Readonly<CacheWrites>;
|
|
21
|
+
};
|
|
22
|
+
/** 性能证据只描述毫秒经过时间,包含异步等待;父阶段包含子阶段,不可跨层相加。 */
|
|
23
|
+
type QualityProfileTiming = {
|
|
24
|
+
readonly stage: QualityProfileStage;
|
|
25
|
+
readonly durationMs: number;
|
|
26
|
+
readonly calls: number;
|
|
27
|
+
};
|
|
28
|
+
type QualityProfileCandidate = {
|
|
29
|
+
readonly subjectIndex: number;
|
|
30
|
+
readonly sourceKey: string;
|
|
31
|
+
readonly language: string;
|
|
32
|
+
readonly status: QualityProfileCandidateStatus;
|
|
33
|
+
readonly completed: boolean;
|
|
34
|
+
readonly durationMs: number;
|
|
35
|
+
readonly timings: readonly QualityProfileTiming[];
|
|
36
|
+
};
|
|
37
|
+
type QualityProfileCheck = {
|
|
38
|
+
readonly checkId: string;
|
|
39
|
+
/** 只累计本检查项自身片段;共享计算成本归于首次实际使用的位置。 */
|
|
40
|
+
readonly durationMs: number;
|
|
41
|
+
readonly candidateCount: number;
|
|
42
|
+
readonly executedRules: number;
|
|
43
|
+
/** candidates 汇总包含准备、指纹、缓存、执行及结果整理;其子项不可重复相加。 */
|
|
44
|
+
readonly timings: readonly QualityProfileTiming[];
|
|
45
|
+
/** 已进入处理的候选结果计数;缺少的状态表示 0,含中断候选。 */
|
|
46
|
+
readonly outcomes: Readonly<Partial<Record<QualityProfileCandidateStatus, number>>>;
|
|
47
|
+
readonly cache: QualityProfileCache;
|
|
48
|
+
readonly slowestCandidates: readonly QualityProfileCandidate[];
|
|
49
|
+
};
|
|
50
|
+
type QualityProfileReport = {
|
|
51
|
+
readonly schemaVersion: 1;
|
|
52
|
+
/** completed 表示调用正常返回(包括 QA 失败);interrupted 表示调用抛错。 */
|
|
53
|
+
readonly status: "completed" | "interrupted";
|
|
54
|
+
readonly totalMs: number;
|
|
55
|
+
readonly stages: readonly QualityProfileTiming[];
|
|
56
|
+
readonly checks: readonly QualityProfileCheck[];
|
|
57
|
+
};
|
|
58
|
+
type QualityProfilerOptions = {
|
|
59
|
+
/** 每项检查保留的慢候选上限,默认为 10;0 只保留汇总。 */
|
|
60
|
+
readonly slowestCandidates?: number;
|
|
61
|
+
};
|
|
62
|
+
type QualityProfiler = {
|
|
63
|
+
/** 仅在绑定的调用结束后读取;返回独立 JSON 数据,不输出解释或建议。 */
|
|
64
|
+
readonly report: () => QualityProfileReport;
|
|
65
|
+
};
|
|
66
|
+
/** 创建单次检查运行专用的采集器;不得重置、复用或在运行中读取。 */
|
|
67
|
+
declare function createQualityProfiler(options?: QualityProfilerOptions): QualityProfiler;
|
|
68
|
+
/** 键函数只描述计算的实际依赖,不读取或修改外部可变状态。 */
|
|
69
|
+
type MemoOptions<TArguments extends readonly unknown[]> = {
|
|
70
|
+
readonly key?: (...args: TArguments) => readonly unknown[];
|
|
71
|
+
};
|
|
72
|
+
type MemoScope = {
|
|
73
|
+
/** 同一函数与键函数共享缓存;返回值及失败保持原样。 */
|
|
74
|
+
readonly memo: <TArguments extends readonly unknown[], TResult>(operation: (...args: TArguments) => TResult, options?: MemoOptions<TArguments>) => (...args: TArguments) => TResult;
|
|
75
|
+
/** 释放缓存;不取消已经返回的 Promise。 */
|
|
76
|
+
readonly dispose: () => void;
|
|
77
|
+
};
|
|
78
|
+
declare class MemoScopeClosedError extends Error {
|
|
79
|
+
constructor();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 创建一个显式拥有的计算复用范围。
|
|
83
|
+
* 参数按 Object.is 比较,对象按身份;输入、策略和复用结果须保持不可变。
|
|
84
|
+
* 同步异常和拒绝的 Promise 也保留到范围结束,不隐式重试。
|
|
85
|
+
*/
|
|
86
|
+
declare function createMemoScope(): MemoScope;
|
|
87
|
+
type CompareInput<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
88
|
+
readonly previous: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable> | undefined;
|
|
89
|
+
readonly current: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
90
|
+
};
|
|
91
|
+
type ComparisonStatus = "historyMissing" | "historyInsufficient" | "currentInsufficient" | "bothInsufficient" | "added" | "removed" | "modified" | "unchanged";
|
|
92
|
+
type SourceChange<TUnit extends TranslationUnitInput> = {
|
|
93
|
+
readonly key: string;
|
|
94
|
+
readonly status: ComparisonStatus;
|
|
95
|
+
readonly previous: SourceUnit<TUnit> | undefined;
|
|
96
|
+
readonly current: SourceUnit<TUnit> | undefined;
|
|
97
|
+
};
|
|
98
|
+
type TranslationChange<TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
99
|
+
readonly identity: TranslationIdentity;
|
|
100
|
+
readonly status: ComparisonStatus;
|
|
101
|
+
readonly previous: Translation<TTranslation, TBody, TUnavailable> | undefined;
|
|
102
|
+
readonly current: Translation<TTranslation, TBody, TUnavailable> | undefined;
|
|
103
|
+
};
|
|
104
|
+
type SnapshotReadEvidence = {
|
|
105
|
+
readonly source: SourceReadCoverage;
|
|
106
|
+
readonly translations: readonly TranslationReadCoverage[];
|
|
107
|
+
};
|
|
108
|
+
type ComparisonResult<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
109
|
+
readonly sourceChanges: readonly SourceChange<TUnit>[];
|
|
110
|
+
readonly translationChanges: readonly TranslationChange<TTranslation, TBody, TUnavailable>[];
|
|
111
|
+
readonly reads: {
|
|
112
|
+
readonly previous: SnapshotReadEvidence | undefined;
|
|
113
|
+
readonly current: SnapshotReadEvidence;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
type Compare<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = (input: CompareInput<TUnit, TTranslation, TBody, TUnavailable>) => Awaitable<ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
117
|
+
type ComparisonContractErrorReason = "invalid-input" | "invalid-result";
|
|
118
|
+
declare class ComparisonContractError extends TypeError {
|
|
119
|
+
readonly reason: ComparisonContractErrorReason;
|
|
120
|
+
constructor(reason: ComparisonContractErrorReason, message: string);
|
|
121
|
+
}
|
|
122
|
+
declare function validateComparisonInput<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never>(value: unknown): asserts value is CompareInput<TUnit, TTranslation, TBody, TUnavailable>;
|
|
123
|
+
declare function validateComparisonResult<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never>(input: CompareInput<TUnit, TTranslation, TBody, TUnavailable>, value: unknown): asserts value is ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>;
|
|
124
|
+
declare function defaultCompare<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never>(input: CompareInput<TUnit, TTranslation, TBody, TUnavailable>): ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>;
|
|
125
|
+
declare function compareSnapshots<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never>(input: CompareInput<TUnit, TTranslation, TBody, TUnavailable>, compare?: Compare<TUnit, TTranslation, TBody, TUnavailable>): Promise<ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
126
|
+
/** 本次执行的目标语言范围;不会修改配置中声明的语言集合。 */
|
|
127
|
+
type LanguageSelectionOptions = {
|
|
128
|
+
/**
|
|
129
|
+
* 省略时处理全部已声明语言。显式选择必须非空且全部已声明;
|
|
130
|
+
* 重复语言只处理一次,执行顺序沿用配置顺序。未选语言不会被读取。
|
|
131
|
+
*/
|
|
132
|
+
readonly languages?: readonly string[];
|
|
133
|
+
};
|
|
134
|
+
type JsonValue$1 = string | number | boolean | null | readonly JsonValue$1[] | {
|
|
135
|
+
readonly [key: string]: JsonValue$1;
|
|
136
|
+
};
|
|
137
|
+
type OfficialValidation<TOutput> = ReturnType<StandardSchemaV1<unknown, TOutput>["~standard"]["validate"]>;
|
|
138
|
+
/** 核心 schema 契约遵循官方类型,并继续接受现有消费者使用的 PromiseLike 校验器。 */
|
|
139
|
+
type StandardSchemaV1$1<Input = unknown, Output = Input> = Omit<StandardSchemaV1<Input, Output>, "~standard"> & {
|
|
140
|
+
readonly "~standard": Omit<StandardSchemaV1<Input, Output>["~standard"], "validate"> & {
|
|
141
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options) => OfficialValidation<Output> | PromiseLike<Awaited<OfficialValidation<Output>>>;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
type StandardSchemaV1Issue = StandardSchemaV1.Issue;
|
|
145
|
+
type StandardSchemaV1Result<Output> = StandardSchemaV1.Result<Output>;
|
|
146
|
+
type StandardSchemaTypes<TSchema> = TSchema extends StandardTypedV1 ? {
|
|
147
|
+
readonly input: StandardTypedV1.InferInput<TSchema>;
|
|
148
|
+
readonly output: StandardTypedV1.InferOutput<TSchema>;
|
|
149
|
+
} : never;
|
|
150
|
+
type IsSameType<TLeft, TRight> = (<TCandidate>() => TCandidate extends TLeft ? 1 : 2) extends (<TCandidate>() => (TCandidate extends TRight ? 1 : 2)) ? (<TCandidate>() => TCandidate extends TRight ? 1 : 2) extends (<TCandidate>() => (TCandidate extends TLeft ? 1 : 2)) ? true : false : false;
|
|
151
|
+
type PreservingStandardSchema<TValue, TSchema> = StandardSchemaTypes<TSchema> extends {
|
|
152
|
+
readonly input: infer TInput;
|
|
153
|
+
readonly output: infer TOutput;
|
|
154
|
+
} ? IsSameType<TInput, TOutput> extends true ? IsSameType<TOutput, TValue> extends true ? unknown : never : never : never;
|
|
155
|
+
type StandardSchemaFailureKind = "invalid-json" | "invalid-schema-result" | "schema-mismatch" | "schema-threw" | "input-mutated" | "output-changed";
|
|
156
|
+
declare class StandardSchemaContractError extends TypeError {
|
|
157
|
+
readonly valueDescription: string;
|
|
158
|
+
readonly kind: StandardSchemaFailureKind;
|
|
159
|
+
readonly issues: readonly StandardSchemaV1Issue[] | undefined;
|
|
160
|
+
constructor(valueDescription: string, kind: StandardSchemaFailureKind, message: string, issues?: readonly StandardSchemaV1Issue[], options?: ErrorOptions);
|
|
161
|
+
}
|
|
162
|
+
type TranslationWriteTarget = {
|
|
163
|
+
readonly sourceKey: string;
|
|
164
|
+
readonly language: string;
|
|
165
|
+
} | {
|
|
166
|
+
readonly identity: TranslationIdentity;
|
|
167
|
+
};
|
|
168
|
+
type TranslationCandidate<TBody = JsonValue$1> = {
|
|
169
|
+
readonly sourceKey: string;
|
|
170
|
+
readonly language: string;
|
|
171
|
+
readonly content: TBody;
|
|
172
|
+
};
|
|
173
|
+
type TranslationWriteSourceExpectation<TUnit = JsonValue$1> = {
|
|
174
|
+
readonly presence: "present";
|
|
175
|
+
readonly key: string;
|
|
176
|
+
readonly range: JsonValue$1;
|
|
177
|
+
readonly unit: TUnit;
|
|
178
|
+
readonly content: JsonValue$1;
|
|
179
|
+
} | {
|
|
180
|
+
readonly presence: "absent";
|
|
181
|
+
readonly key: string;
|
|
182
|
+
readonly range: JsonValue$1;
|
|
183
|
+
};
|
|
184
|
+
type TranslationWriteTargetExpectation<TBody = JsonValue$1> = {
|
|
185
|
+
readonly status: "missing";
|
|
186
|
+
} | {
|
|
187
|
+
readonly status: "present";
|
|
188
|
+
readonly identity: TranslationIdentity;
|
|
189
|
+
readonly content: TBody;
|
|
190
|
+
readonly range?: JsonValue$1;
|
|
191
|
+
/** 可选地锁定宿主原始目标记录中的关联字段等写入依据。 */
|
|
192
|
+
readonly record?: JsonValue$1;
|
|
193
|
+
};
|
|
194
|
+
type TranslationWriteRequest<TBody = JsonValue$1, TUnit extends TranslationUnitInput = TranslationUnitInput> = {
|
|
195
|
+
readonly operation: "write";
|
|
196
|
+
readonly target: TranslationWriteTarget;
|
|
197
|
+
readonly content: TBody;
|
|
198
|
+
readonly expectedSource?: TranslationWriteSourceExpectation<TUnit>;
|
|
199
|
+
readonly expectedTarget: TranslationWriteTargetExpectation<TBody>;
|
|
200
|
+
} | {
|
|
201
|
+
readonly operation: "delete";
|
|
202
|
+
readonly target: {
|
|
203
|
+
readonly identity: TranslationIdentity;
|
|
204
|
+
};
|
|
205
|
+
readonly expectedSource?: TranslationWriteSourceExpectation<TUnit>;
|
|
206
|
+
readonly expectedTarget: Extract<TranslationWriteTargetExpectation<TBody>, {
|
|
207
|
+
readonly status: "present";
|
|
208
|
+
}>;
|
|
209
|
+
};
|
|
210
|
+
type TranslationWritebackTarget = {
|
|
211
|
+
readonly kind: "existing" | "create";
|
|
212
|
+
readonly locator: JsonValue$1;
|
|
213
|
+
};
|
|
214
|
+
type TranslationWritebackResolution = {
|
|
215
|
+
readonly status: "located";
|
|
216
|
+
readonly locator: JsonValue$1;
|
|
217
|
+
} | {
|
|
218
|
+
readonly status: "notWritable";
|
|
219
|
+
readonly reason: string;
|
|
220
|
+
};
|
|
221
|
+
type AvailableTranslation<TTranslation, TBody, TUnavailable> = Extract<Translation<TTranslation, TBody, TUnavailable>, {
|
|
222
|
+
readonly bodyAvailability: "available";
|
|
223
|
+
}>;
|
|
224
|
+
type TranslationWritebackInput<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
225
|
+
readonly request: TranslationWriteRequest<TBody, TUnit>;
|
|
226
|
+
readonly target: TranslationWritebackTarget;
|
|
227
|
+
readonly sourceUnit?: SourceUnit<TUnit>;
|
|
228
|
+
readonly currentTranslation?: AvailableTranslation<TTranslation, TBody, TUnavailable>;
|
|
229
|
+
};
|
|
230
|
+
type TranslationWritebackAdapter<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
231
|
+
readonly locateExistingTarget?: (input: {
|
|
232
|
+
readonly identity: TranslationIdentity;
|
|
233
|
+
readonly translation: AvailableTranslation<TTranslation, TBody, TUnavailable>;
|
|
234
|
+
}) => Awaitable<TranslationWritebackResolution>;
|
|
235
|
+
readonly locateNewTarget?: (input: {
|
|
236
|
+
readonly sourceKey: string;
|
|
237
|
+
readonly sourceUnit: SourceUnit<TUnit>;
|
|
238
|
+
readonly language: string;
|
|
239
|
+
}) => Awaitable<TranslationWritebackResolution>;
|
|
240
|
+
/** 单目标写回;未配置 writeBatch 时按物理目标组调用。 */
|
|
241
|
+
readonly write?: (input: TranslationWritebackInput<TUnit, TTranslation, TBody, TUnavailable>) => Awaitable<void>;
|
|
242
|
+
/**
|
|
243
|
+
* 配置后优先使用。一次接收同一份初始事实下完成预检的独立请求;
|
|
244
|
+
* 同一物理目标的兼容请求只传一个代表项,但回读仍逐项确认。批次不承诺执行顺序或事务;
|
|
245
|
+
* 返回或抛错后,框架会统一回读资源并逐项确认实际结果。
|
|
246
|
+
*/
|
|
247
|
+
readonly writeBatch?: (input: {
|
|
248
|
+
readonly requests: readonly TranslationWritebackInput<TUnit, TTranslation, TBody, TUnavailable>[];
|
|
249
|
+
}) => Awaitable<void>;
|
|
250
|
+
};
|
|
251
|
+
type TranslationWriteConditionInput<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = {
|
|
252
|
+
readonly request: TranslationWriteRequest<TBody, TUnit>;
|
|
253
|
+
readonly current: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
254
|
+
readonly target: TranslationWritebackTarget;
|
|
255
|
+
readonly sourceUnit?: SourceUnit<TUnit>;
|
|
256
|
+
readonly currentTranslation?: AvailableTranslation<TTranslation, TBody, TUnavailable>;
|
|
257
|
+
};
|
|
258
|
+
type TranslationWriteConditionResult = boolean | {
|
|
259
|
+
readonly status: "allowed";
|
|
260
|
+
} | {
|
|
261
|
+
readonly status: "rejected";
|
|
262
|
+
readonly reason: string;
|
|
263
|
+
};
|
|
264
|
+
/** 消费者可在默认输入核对外,再组合基线、QA 或其他明确条件。 */
|
|
265
|
+
type TranslationWriteCondition<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = (input: TranslationWriteConditionInput<TUnit, TTranslation, TBody, TUnavailable>) => Awaitable<TranslationWriteConditionResult>;
|
|
266
|
+
type TranslationWriteStatus = "written" | "writeUnconfirmed" | "conflict" | "notWritable" | "writeFailed";
|
|
267
|
+
type TranslationWriteResult<TBody = JsonValue$1, TUnit extends TranslationUnitInput = TranslationUnitInput> = {
|
|
268
|
+
readonly request: TranslationWriteRequest<TBody, TUnit>;
|
|
269
|
+
readonly status: TranslationWriteStatus;
|
|
270
|
+
readonly reason?: string;
|
|
271
|
+
};
|
|
272
|
+
type TranslationWriteBatchResult<TBody = JsonValue$1, TUnit extends TranslationUnitInput = TranslationUnitInput> = {
|
|
273
|
+
readonly results: readonly TranslationWriteResult<TBody, TUnit>[];
|
|
274
|
+
/** 批量适配器抛出的原始异常;逐项回读结果仍然有效且单独表达。 */
|
|
275
|
+
readonly batchError?: unknown;
|
|
276
|
+
};
|
|
277
|
+
/** 校验候选正文数据;是否检查或写入由调用者另外组合。 */
|
|
278
|
+
declare function validateTranslationCandidate<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(value: unknown, config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>): Promise<TranslationCandidate<TBody>>;
|
|
279
|
+
/** 校验可保存的写入请求,保留宿主提供的 JSON 正文与完整原文。 */
|
|
280
|
+
declare function validateTranslationWriteRequest<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(value: unknown, config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>): Promise<TranslationWriteRequest<TBody, TUnit>>;
|
|
281
|
+
/**
|
|
282
|
+
* 直接执行人工或外部工具提供的写入候选与删除决定。
|
|
283
|
+
* 显式选择语言时,越界请求整批拒绝,写入前后只读取所选语言。
|
|
284
|
+
*/
|
|
285
|
+
declare function writeTranslationRequests<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(requests: readonly TranslationWriteRequest<TBody, TUnit>[], config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, condition?: TranslationWriteCondition<TUnit, TTranslation, TBody, TUnavailable>, options?: LanguageSelectionOptions): Promise<TranslationWriteBatchResult<TBody, TUnit>>;
|
|
286
|
+
declare const UPDATE_PLAN_FORMAT: "lioni.update-plan/v2";
|
|
287
|
+
type UpdatePlanAction = "write" | "delete" | "retain" | "review" | "blocked";
|
|
288
|
+
type UpdateSourceExpectation<TUnit extends TranslationUnitInput> = TranslationWriteSourceExpectation<TUnit>;
|
|
289
|
+
type UpdateTargetExpectation<TBody> = TranslationWriteTargetExpectation<TBody>;
|
|
290
|
+
/** 供写入器直接消费的候选;不包含文件定位、准备阶段或策略门禁。 */
|
|
291
|
+
type UpdatePlanWriteRequest<TUnit extends TranslationUnitInput, TBody> = TranslationWriteRequest<TBody, TUnit>;
|
|
292
|
+
type UpdatePlanSourceChange<TUnit extends TranslationUnitInput> = {
|
|
293
|
+
readonly key: string;
|
|
294
|
+
readonly status: ComparisonStatus;
|
|
295
|
+
readonly previous?: SourceUnit<TUnit>;
|
|
296
|
+
readonly current?: SourceUnit<TUnit>;
|
|
297
|
+
};
|
|
298
|
+
type UpdatePlanTranslationChange<TTranslation, TBody, TUnavailable> = {
|
|
299
|
+
readonly identity: TranslationIdentity;
|
|
300
|
+
readonly status: ComparisonStatus;
|
|
301
|
+
readonly previous?: Translation<TTranslation, TBody, TUnavailable>;
|
|
302
|
+
readonly current?: Translation<TTranslation, TBody, TUnavailable>;
|
|
303
|
+
};
|
|
304
|
+
type UpdatePlanItemBase<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = JsonValue$1, TUnavailable = never> = {
|
|
305
|
+
/** 原文身份只在该决定确实针对某个原文时出现。 */
|
|
306
|
+
readonly sourceKey?: string;
|
|
307
|
+
readonly language: string;
|
|
308
|
+
/** 已有译文按语言与消息键定位;缺译决定只引用原文身份。 */
|
|
309
|
+
readonly target?: TranslationIdentity;
|
|
310
|
+
readonly changes: {
|
|
311
|
+
readonly source?: SourceChange<TUnit> | UpdatePlanSourceChange<TUnit>;
|
|
312
|
+
readonly translations: readonly UpdatePlanTranslationChange<TTranslation, TBody, TUnavailable>[];
|
|
313
|
+
};
|
|
314
|
+
readonly reason: string;
|
|
315
|
+
};
|
|
316
|
+
type UpdatePlanItem<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = JsonValue$1, TUnavailable = never> = UpdatePlanItemBase<TUnit, TTranslation, TBody, TUnavailable> & ({
|
|
317
|
+
readonly action: "write";
|
|
318
|
+
readonly after: {
|
|
319
|
+
readonly content: TBody;
|
|
320
|
+
};
|
|
321
|
+
readonly request: Extract<UpdatePlanWriteRequest<TUnit, TBody>, {
|
|
322
|
+
readonly operation: "write";
|
|
323
|
+
}>;
|
|
324
|
+
} | {
|
|
325
|
+
readonly action: "delete";
|
|
326
|
+
readonly request: Extract<UpdatePlanWriteRequest<TUnit, TBody>, {
|
|
327
|
+
readonly operation: "delete";
|
|
328
|
+
}>;
|
|
329
|
+
readonly after?: never;
|
|
330
|
+
} | {
|
|
331
|
+
readonly action: "retain" | "review" | "blocked";
|
|
332
|
+
readonly request?: never;
|
|
333
|
+
readonly after?: never;
|
|
334
|
+
});
|
|
335
|
+
type UpdatePlanComparisons<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = {
|
|
336
|
+
readonly sourceChanges: readonly UpdatePlanSourceChange<TUnit>[];
|
|
337
|
+
readonly translationChanges: readonly UpdatePlanTranslationChange<TTranslation, TBody, TUnavailable>[];
|
|
338
|
+
readonly reads: {
|
|
339
|
+
readonly previous?: ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>["reads"]["previous"];
|
|
340
|
+
readonly current: ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>["reads"]["current"];
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
/** 计划内只保留计算结果,不含适配器、函数、undefined 或宿主对象原型。 */
|
|
344
|
+
type UpdatePlan<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = JsonValue$1, TUnavailable = never> = {
|
|
345
|
+
readonly format: typeof UPDATE_PLAN_FORMAT;
|
|
346
|
+
readonly previous?: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
347
|
+
readonly current: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
348
|
+
readonly comparisons: UpdatePlanComparisons<TUnit, TTranslation, TBody, TUnavailable>;
|
|
349
|
+
readonly associations: UpdatePlanAssociations;
|
|
350
|
+
readonly items: readonly UpdatePlanItem<TUnit, TTranslation, TBody, TUnavailable>[];
|
|
351
|
+
};
|
|
352
|
+
type UpdatePlanData = UpdatePlan;
|
|
353
|
+
type UpdatePlanAssociations = {
|
|
354
|
+
readonly previous: readonly TranslationAssociation[];
|
|
355
|
+
readonly current: readonly TranslationAssociation[];
|
|
356
|
+
};
|
|
357
|
+
type UpdatePlanInput<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = {
|
|
358
|
+
readonly previous?: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
359
|
+
readonly current: ProjectSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
360
|
+
readonly comparisons: ComparisonResult<TUnit, TTranslation, TBody, TUnavailable>;
|
|
361
|
+
readonly associations: UpdatePlanAssociations;
|
|
362
|
+
/** 默认直接复制原文正文;自定义函数仅接收正文,不接收目标语言或读取包装。 */
|
|
363
|
+
readonly createPlaceholderContent?: (source: TUnit["source"]) => TBody;
|
|
364
|
+
readonly contentSchema?: StandardSchemaV1$1<TBody, TBody>;
|
|
365
|
+
};
|
|
366
|
+
/** 一次消费本次业务相关的事实、关联与比较集合,返回完整决定集合。 */
|
|
367
|
+
type UpdatePolicy<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = (input: UpdatePlanInput<TUnit, TTranslation, TBody, TUnavailable>) => Awaitable<readonly UpdatePlanItem<TUnit, TTranslation, TBody, TUnavailable>[]>;
|
|
368
|
+
type UpdatePlanStore = {
|
|
369
|
+
load(): Promise<UpdatePlanData | undefined>;
|
|
370
|
+
save(plan: UpdatePlanData): Promise<void>;
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* 纯业务规划入口。比较结果、两侧快照与关联均为显式输入;策略只调用一次,
|
|
374
|
+
* 计划可 JSON 序列化后交给另一阶段消费。
|
|
375
|
+
*/
|
|
376
|
+
declare function createUpdatePlan<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(options: UpdatePlanInput<TUnit, TTranslation, TBody, TUnavailable> & {
|
|
377
|
+
readonly updatePolicy?: UpdatePolicy<TUnit, TTranslation, TBody, TUnavailable>;
|
|
378
|
+
}): Promise<UpdatePlan<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
379
|
+
/** 默认策略保留现有译文;仅为完整读取的缺译补占位,并删除有历史依据的未改目标。 */
|
|
380
|
+
declare function defaultUpdatePolicy<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(input: UpdatePlanInput<TUnit, TTranslation, TBody, TUnavailable>): Promise<readonly UpdatePlanItem<TUnit, TTranslation, TBody, TUnavailable>[]>;
|
|
381
|
+
/**
|
|
382
|
+
* 读取当前事实、选用配置比较器并生成业务计划;不写资源或推进基线。
|
|
383
|
+
* 显式选择语言时,历史事实、比较器和策略均限定在该范围,策略不得扩大范围。
|
|
384
|
+
*/
|
|
385
|
+
declare function previewUpdate<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, store?: ComparisonBaselineStore<TUnit, TTranslation, TBody, TUnavailable>, options?: LanguageSelectionOptions): Promise<UpdatePlan<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
386
|
+
/** 验证保存后的 JSON 计划;兼容读取升级前 v2 译文字段,不会重新比较、关联或调用策略。 */
|
|
387
|
+
declare function validateUpdatePlan(value: unknown): asserts value is UpdatePlanData;
|
|
388
|
+
declare const QA_SUPPRESSION_FORMAT: "lioni.qa-suppressions/v1";
|
|
389
|
+
type QaSuppressionFingerprintSummary = {
|
|
390
|
+
readonly version: string;
|
|
391
|
+
readonly inputFingerprint: string;
|
|
392
|
+
};
|
|
393
|
+
type QaSuppression = {
|
|
394
|
+
readonly id: string;
|
|
395
|
+
readonly reason: string;
|
|
396
|
+
readonly checkId: string;
|
|
397
|
+
readonly sourceKey: string;
|
|
398
|
+
readonly language: string;
|
|
399
|
+
readonly inputFingerprint: string;
|
|
400
|
+
readonly fingerprintSummary: QaSuppressionFingerprintSummary;
|
|
401
|
+
};
|
|
402
|
+
type QaSuppressionFile = {
|
|
403
|
+
readonly format: typeof QA_SUPPRESSION_FORMAT;
|
|
404
|
+
readonly suppressions: readonly QaSuppression[];
|
|
405
|
+
};
|
|
406
|
+
type QaSuppressionExecution = {
|
|
407
|
+
readonly executionId?: number;
|
|
408
|
+
readonly candidateIndex?: number;
|
|
409
|
+
readonly checkId: string;
|
|
410
|
+
readonly sourceKey: string;
|
|
411
|
+
readonly language: string;
|
|
412
|
+
readonly inputFingerprint?: string;
|
|
413
|
+
readonly fingerprintSummary?: QaSuppressionFingerprintSummary;
|
|
414
|
+
};
|
|
415
|
+
type CreateQaSuppressionInput = {
|
|
416
|
+
readonly id: string;
|
|
417
|
+
readonly reason: string;
|
|
418
|
+
readonly execution: QaSuppressionExecution;
|
|
419
|
+
};
|
|
420
|
+
type UpsertQaSuppressionFromReportInput = {
|
|
421
|
+
readonly report: unknown;
|
|
422
|
+
readonly checkId: string;
|
|
423
|
+
readonly executionId: number;
|
|
424
|
+
readonly id: string;
|
|
425
|
+
readonly reason: string;
|
|
426
|
+
readonly store: QaSuppressionStore;
|
|
427
|
+
};
|
|
428
|
+
type QaSuppressionFormatErrorReason = "unsupported" | "invalid";
|
|
429
|
+
declare class QaSuppressionFormatError extends TypeError {
|
|
430
|
+
readonly reason: QaSuppressionFormatErrorReason;
|
|
431
|
+
constructor(reason: QaSuppressionFormatErrorReason, message: string, options?: ErrorOptions);
|
|
432
|
+
}
|
|
433
|
+
type QaSuppressionStore = {
|
|
434
|
+
load(): Promise<readonly QaSuppression[]>;
|
|
435
|
+
upsert(suppression: QaSuppression): Promise<void>;
|
|
436
|
+
};
|
|
437
|
+
/** 从正式报告的一条执行记录创建可手工维护的豁免绑定。 */
|
|
438
|
+
declare function createQaSuppression(input: CreateQaSuppressionInput): QaSuppression;
|
|
439
|
+
/** 从 SDK 报告或 CLI 结构化报告中选择执行记录并写入豁免存储。 */
|
|
440
|
+
declare function upsertQaSuppressionFromReport(input: UpsertQaSuppressionFromReportInput): Promise<QaSuppression>;
|
|
441
|
+
/** 验证单条豁免;手写 YAML、SDK 与命令共用此契约。 */
|
|
442
|
+
declare function validateQaSuppression(value: unknown): asserts value is QaSuppression;
|
|
443
|
+
/** 验证版本化豁免文件及其身份唯一性。 */
|
|
444
|
+
declare function validateQaSuppressionFile(value: unknown): asserts value is QaSuppressionFile;
|
|
445
|
+
/** 验证由自定义存储或低层 QA 请求提供的豁免列表。 */
|
|
446
|
+
declare function validateQaSuppressions(value: unknown): asserts value is readonly QaSuppression[];
|
|
447
|
+
type CachedQualityFindings<TObject extends QualityObject = QualityObject> = readonly QualityFinding<TObject>[];
|
|
448
|
+
/** 缓存成功执行的原始诊断。空数组可复用,豁免按本次配置重新应用。 */
|
|
449
|
+
type QualityCheckResultCache<TObject extends QualityObject = QualityObject> = {
|
|
450
|
+
get(key: string): Promise<CachedQualityFindings<TObject> | undefined>;
|
|
451
|
+
set(key: string, findings: CachedQualityFindings<TObject>): Promise<void>;
|
|
452
|
+
};
|
|
453
|
+
type QualityObject = {
|
|
454
|
+
readonly kind: string;
|
|
455
|
+
readonly key: string;
|
|
456
|
+
readonly language?: string;
|
|
457
|
+
readonly [field: string]: unknown;
|
|
458
|
+
};
|
|
459
|
+
type QualityLocation = {
|
|
460
|
+
readonly language: string | null;
|
|
461
|
+
/** 宿主提供的资源范围;具体含义由相应适配器决定。 */
|
|
462
|
+
readonly range: unknown;
|
|
463
|
+
/** 宿主定义的资源内定位键,与逻辑对象身份分开提供。 */
|
|
464
|
+
readonly key?: string;
|
|
465
|
+
readonly [field: string]: unknown;
|
|
466
|
+
};
|
|
467
|
+
type QualitySubject = {
|
|
468
|
+
readonly key: string;
|
|
469
|
+
readonly language: string;
|
|
470
|
+
};
|
|
471
|
+
type QualityRelationship = {
|
|
472
|
+
readonly kind: string;
|
|
473
|
+
readonly key: string;
|
|
474
|
+
readonly members: readonly QualitySubject[];
|
|
475
|
+
readonly [field: string]: unknown;
|
|
476
|
+
};
|
|
477
|
+
type QualityDiagnosticHandling = {
|
|
478
|
+
readonly status: "active";
|
|
479
|
+
} | {
|
|
480
|
+
readonly status: "suppressed";
|
|
481
|
+
readonly suppressionId: string;
|
|
482
|
+
readonly reason: string;
|
|
483
|
+
};
|
|
484
|
+
type QualityEvidence<TObject extends QualityObject = QualityObject> = {
|
|
485
|
+
readonly role: string;
|
|
486
|
+
readonly object: TObject;
|
|
487
|
+
readonly location: QualityLocation;
|
|
488
|
+
readonly value: unknown;
|
|
489
|
+
};
|
|
490
|
+
type QualityDiagnostic<TObject extends QualityObject = QualityObject> = ReadonlyQualityValue<{
|
|
491
|
+
readonly checkId: string;
|
|
492
|
+
readonly executionId: number;
|
|
493
|
+
readonly severity: "error" | "warning" | "info";
|
|
494
|
+
readonly object: TObject;
|
|
495
|
+
readonly location: QualityLocation;
|
|
496
|
+
readonly message: string;
|
|
497
|
+
readonly evidence: readonly QualityEvidence<TObject>[];
|
|
498
|
+
readonly handling: QualityDiagnosticHandling;
|
|
499
|
+
}>;
|
|
500
|
+
type QualityFinding<TObject extends QualityObject = QualityObject> = Omit<QualityDiagnostic<TObject>, "checkId" | "executionId" | "handling">;
|
|
501
|
+
type QualityCoverage = {
|
|
502
|
+
readonly selected: number;
|
|
503
|
+
readonly evaluated: number;
|
|
504
|
+
};
|
|
505
|
+
/** JsonValue 联合本身已递归只读;普通可赋值对象仍须逐层变为只读。 */
|
|
506
|
+
type ReadonlyQualityValue<TValue> = IsSameType<TValue, JsonValue$1> extends true ? TValue : TValue extends object ? { readonly [TKey in keyof TValue]: ReadonlyQualityValue<TValue[TKey]>; } : TValue;
|
|
507
|
+
/** 同一次 QA 的明确共享读取器;同一函数对象与同一参数共享结果及失败。 */
|
|
508
|
+
type QualityDataReader = {
|
|
509
|
+
readonly read: <TArguments extends readonly unknown[], TValue>(reader: (...args: TArguments) => Awaitable<TValue>, ...args: TArguments) => Promise<TValue>;
|
|
510
|
+
};
|
|
511
|
+
/** 动态接入未提供有效读取函数时直接报告的契约错误。 */
|
|
512
|
+
declare class QualityDataReaderContractError extends TypeError {
|
|
513
|
+
constructor();
|
|
514
|
+
}
|
|
515
|
+
type QualityDataLoadInput<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = {
|
|
516
|
+
readonly snapshot: ProjectSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
517
|
+
/** 纯计算可跨本次检查运行复用;不用于缓存动态检查资料。 */
|
|
518
|
+
readonly memo: MemoScope;
|
|
519
|
+
readonly qualityData: QualityDataReader;
|
|
520
|
+
};
|
|
521
|
+
/** 一次加载所需的上下文。项目快照、候选和关系由本次运行共享,按只读约定使用。 */
|
|
522
|
+
type CheckerLoadInput<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = unknown, TUnavailable = unknown> = QualityDataLoadInput<TUnit, TTranslation, TBody, TUnavailable> & {
|
|
523
|
+
readonly candidates: readonly TranslationCandidate<TBody>[];
|
|
524
|
+
readonly relationships: readonly QualityRelationship[];
|
|
525
|
+
};
|
|
526
|
+
/** 为当前检查对象准备规则消费的完整业务输入。 */
|
|
527
|
+
type CheckerPrepareInput<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = unknown, TUnavailable = unknown, TLoaded = undefined> = Omit<CheckerLoadInput<TUnit, TTranslation, TBody, TUnavailable>, "qualityData"> & {
|
|
528
|
+
readonly candidate: TranslationCandidate<TBody> | null;
|
|
529
|
+
readonly sourceUnit: SourceUnit<TUnit>;
|
|
530
|
+
/** 同键同语言的现存记录。空值的读取依据见 association。 */
|
|
531
|
+
readonly translation: Translation<TTranslation, TBody, TUnavailable> | null;
|
|
532
|
+
readonly association: TranslationAssociation;
|
|
533
|
+
/** 只读使用。其生命周期为当前运行,未声明 load 时为 undefined。 */
|
|
534
|
+
readonly loaded: TLoaded;
|
|
535
|
+
};
|
|
536
|
+
type CheckerDefinition<TSchema extends StandardSchemaV1$1<unknown, unknown>, TLoaded = undefined, TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = unknown, TUnavailable = unknown, TObject extends QualityObject = QualityObject, TId extends string = string> = {
|
|
537
|
+
readonly id: TId;
|
|
538
|
+
readonly version: string;
|
|
539
|
+
readonly inputSchema: TSchema & PreservingStandardSchema<StandardSchemaOutput<TSchema>, NoInfer<TSchema>>;
|
|
540
|
+
/** 已选中且有检查对象时调用一次。动态资料可通过 qualityData.read 显式共享。 */
|
|
541
|
+
readonly load?: (input: CheckerLoadInput<TUnit, TTranslation, TBody, TUnavailable>) => Awaitable<TLoaded>;
|
|
542
|
+
readonly prepare: (input: CheckerPrepareInput<TUnit, TTranslation, TBody, TUnavailable, NoInfer<TLoaded>>) => Awaitable<NoInfer<StandardSchemaInput<TSchema>>>;
|
|
543
|
+
/** 只消费已校验并固定的输入。缓存命中时不调用。 */
|
|
544
|
+
readonly check: (input: ReadonlyQualityValue<NoInfer<StandardSchemaOutput<TSchema>>>) => Awaitable<readonly QualityFinding<TObject>[]>;
|
|
545
|
+
} & (undefined extends NoInfer<TLoaded> ? unknown : {
|
|
546
|
+
readonly load: unknown;
|
|
547
|
+
});
|
|
548
|
+
/** 检查器声明或阶段返回结构不符合正式检查契约。 */
|
|
549
|
+
declare class QualityCheckerContractError extends TypeError {
|
|
550
|
+
readonly checkId: string;
|
|
551
|
+
readonly stage: "definition" | "prepare" | "check";
|
|
552
|
+
constructor(checkId: string, stage: "definition" | "prepare" | "check", message: string);
|
|
553
|
+
}
|
|
554
|
+
type QualityInputFingerprintSummary = {
|
|
555
|
+
readonly version: string;
|
|
556
|
+
readonly inputFingerprint: string;
|
|
557
|
+
};
|
|
558
|
+
type QualityCheckExecution = {
|
|
559
|
+
readonly executionId: number;
|
|
560
|
+
readonly candidateIndex?: number;
|
|
561
|
+
readonly checkId: string;
|
|
562
|
+
readonly sourceKey: string;
|
|
563
|
+
readonly language: string;
|
|
564
|
+
readonly inputFingerprint?: string;
|
|
565
|
+
readonly fingerprintSummary?: QualityInputFingerprintSummary;
|
|
566
|
+
};
|
|
567
|
+
type StandardSchemaInput<TSchema extends StandardSchemaV1$1<unknown, unknown>> = NonNullable<TSchema["~standard"]["types"]>["input"];
|
|
568
|
+
type StandardSchemaOutput<TSchema extends StandardSchemaV1$1<unknown, unknown>> = NonNullable<TSchema["~standard"]["types"]>["output"];
|
|
569
|
+
declare const qualityCheckDefinitionBrand: unique symbol;
|
|
570
|
+
/** 不透明的检查器契约;私有函数类型仅保留宿主与检查输入的类型关系。 */
|
|
571
|
+
type QualityCheckDefinition<TUnit extends TranslationUnitInput, TTranslation, TObject extends QualityObject = QualityObject, TBody = unknown, TUnavailable = never, TId extends string = string> = {
|
|
572
|
+
readonly [qualityCheckDefinitionBrand]: (input: CheckerPrepareInput<TUnit, TTranslation, TBody, TUnavailable, unknown>) => readonly QualityFinding<TObject>[];
|
|
573
|
+
readonly id: TId;
|
|
574
|
+
readonly version: string;
|
|
575
|
+
};
|
|
576
|
+
declare function defineCheckerFor<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = unknown, TUnavailable = unknown>(): <TSchema extends StandardSchemaV1$1<unknown, unknown>, TObject extends QualityObject = QualityObject, const TId extends string = string, TLoaded = undefined>(definition: CheckerDefinition<TSchema, TLoaded, TUnit, TTranslation, TBody, TUnavailable, TObject, TId>) => QualityCheckDefinition<TUnit, TTranslation, TObject, TBody, TUnavailable, TId>;
|
|
577
|
+
/**
|
|
578
|
+
* 声明一次共享加载、逐对象准备及规则计算。规则所需的全部业务依据
|
|
579
|
+
* 必须进入准备结果,框架用同一份固定输入计算指纹并执行规则。
|
|
580
|
+
* 相同输入下规则语义变化时应更新 version。
|
|
581
|
+
* 需要明确宿主类型时,可先调用 withTypes,schema、加载结果和 ID 仍由声明推导。
|
|
582
|
+
*/
|
|
583
|
+
declare const defineChecker: (<TSchema extends StandardSchemaV1$1<unknown, unknown>, TObject extends QualityObject = QualityObject, const TId extends string = string, TLoaded = undefined>(definition: CheckerDefinition<TSchema, TLoaded, TranslationUnitInput, unknown, unknown, unknown, TObject, TId>) => QualityCheckDefinition<TranslationUnitInput, unknown, TObject, unknown, unknown, TId>) & {
|
|
584
|
+
withTypes: typeof defineCheckerFor;
|
|
585
|
+
};
|
|
586
|
+
type QualityCheckResult<TObject extends QualityObject = QualityObject> = {
|
|
587
|
+
readonly checkId: string;
|
|
588
|
+
readonly version: string;
|
|
589
|
+
readonly diagnostics: readonly QualityDiagnostic<TObject>[];
|
|
590
|
+
readonly coverage: QualityCoverage;
|
|
591
|
+
readonly executions: readonly QualityCheckExecution[];
|
|
592
|
+
};
|
|
593
|
+
type QualityCheckScope = {
|
|
594
|
+
readonly configuredCount: number;
|
|
595
|
+
readonly selectedIds: readonly string[];
|
|
596
|
+
/** 至少评估过一个检查对象的不同检查项数量(含缓存命中与无诊断返回)。 */
|
|
597
|
+
readonly evaluatedCount: number;
|
|
598
|
+
};
|
|
599
|
+
type QualityReadCoverage = {
|
|
600
|
+
readonly source: SourceReadCoverage;
|
|
601
|
+
readonly translations: readonly TranslationReadCoverage[];
|
|
602
|
+
readonly associations: readonly (TranslationAssociation & {
|
|
603
|
+
readonly subjectSelected: boolean;
|
|
604
|
+
})[];
|
|
605
|
+
};
|
|
606
|
+
type TranslationProgress = {
|
|
607
|
+
readonly language: string;
|
|
608
|
+
readonly completed: number;
|
|
609
|
+
readonly total: number;
|
|
610
|
+
readonly percentage?: number;
|
|
611
|
+
};
|
|
612
|
+
type QualityRunResult<TObject extends QualityObject = QualityObject, TBody = JsonValue$1> = {
|
|
613
|
+
readonly version: string;
|
|
614
|
+
readonly candidates: readonly TranslationCandidate<TBody>[];
|
|
615
|
+
readonly readCoverage: QualityReadCoverage;
|
|
616
|
+
readonly checkScope: QualityCheckScope;
|
|
617
|
+
readonly relationships: readonly QualityRelationship[];
|
|
618
|
+
readonly suppressions: readonly QaSuppression[];
|
|
619
|
+
readonly progress?: readonly TranslationProgress[];
|
|
620
|
+
readonly diagnostics: readonly QualityDiagnostic<TObject>[];
|
|
621
|
+
readonly checks: readonly QualityCheckResult<TObject>[];
|
|
622
|
+
};
|
|
623
|
+
declare class TranslationIdentityContractError extends TypeError {
|
|
624
|
+
readonly reason: "missing" | "duplicate";
|
|
625
|
+
readonly identity?: TranslationIdentity;
|
|
626
|
+
readonly firstIndex?: number;
|
|
627
|
+
readonly duplicateIndex?: number;
|
|
628
|
+
constructor(reason: "missing" | "duplicate", details?: {
|
|
629
|
+
readonly identity?: TranslationIdentity;
|
|
630
|
+
readonly firstIndex?: number;
|
|
631
|
+
readonly duplicateIndex?: number;
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
type QualityReport = QualityRunResult<QualityObject, unknown>;
|
|
635
|
+
type QualityReportDecisionStatus = "passed" | "failed" | "no-candidates" | "no-checks";
|
|
636
|
+
type QualityReportDecision = {
|
|
637
|
+
readonly status: QualityReportDecisionStatus;
|
|
638
|
+
readonly passed: boolean;
|
|
639
|
+
readonly activeErrorCount: number;
|
|
640
|
+
};
|
|
641
|
+
/** 终端质量报告文本呈现的筛选与折叠选项,只影响问题明细展示。 */
|
|
642
|
+
type QualityReportFormatOptions = {
|
|
643
|
+
readonly severities?: readonly ("error" | "warning" | "info")[];
|
|
644
|
+
readonly maxPerCheck?: number;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* 判断本次质量检查是否足以通过。
|
|
648
|
+
* 完整空项目可正常结束;有检查对象时仍须运行检查并通过现有错误门禁。
|
|
649
|
+
*/
|
|
650
|
+
declare function isQualityReportPassing(report: QualityReport): boolean;
|
|
651
|
+
/** 返回可供脚本按报告结果分支处理的结论。 */
|
|
652
|
+
declare function decideQualityReport(report: QualityReport): QualityReportDecision;
|
|
653
|
+
/** 生成可供 CLI 与 SDK 脚本共用的简体中文质量报告。 */
|
|
654
|
+
declare function formatQualityReport(report: QualityReport, options?: QualityReportFormatOptions): string;
|
|
655
|
+
declare const COMPARISON_BASELINE_FORMAT: "lioni.comparison-baseline/v2";
|
|
656
|
+
type ComparisonBaseline<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = JsonValue$1, TUnavailable = never> = {
|
|
657
|
+
readonly format: typeof COMPARISON_BASELINE_FORMAT;
|
|
658
|
+
readonly snapshot: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
659
|
+
};
|
|
660
|
+
type ComparisonBaselineStore<TUnit extends TranslationUnitInput = TranslationUnitInput, TTranslation = unknown, TBody = JsonValue$1, TUnavailable = never> = {
|
|
661
|
+
load(): Promise<ComparisonBaseline<TUnit, TTranslation, TBody, TUnavailable> | undefined>;
|
|
662
|
+
save(baseline: ComparisonBaseline<TUnit, TTranslation, TBody, TUnavailable>): Promise<void>;
|
|
663
|
+
};
|
|
664
|
+
type ComparisonBaselineSelection = {
|
|
665
|
+
readonly sourceRanges: readonly unknown[];
|
|
666
|
+
readonly translationRanges: readonly {
|
|
667
|
+
readonly language: string;
|
|
668
|
+
readonly range: unknown;
|
|
669
|
+
}[];
|
|
670
|
+
};
|
|
671
|
+
type RecordComparisonBaselineResult<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
672
|
+
readonly outcome: "saved" | "unchanged";
|
|
673
|
+
readonly baseline: ComparisonBaseline<TUnit, TTranslation, TBody, TUnavailable>;
|
|
674
|
+
};
|
|
675
|
+
declare class ComparisonBaselineFormatError extends TypeError {
|
|
676
|
+
readonly reason: "unsupported" | "invalid";
|
|
677
|
+
constructor(reason: "unsupported" | "invalid", message: string);
|
|
678
|
+
}
|
|
679
|
+
declare class ComparisonBaselineIncompleteSnapshotError extends Error {
|
|
680
|
+
readonly language?: string;
|
|
681
|
+
constructor(message: string, language?: string);
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* 替换明确选择的快照范围并保留其余历史。未提供选择时,采用当前快照中观察到的全部范围。
|
|
685
|
+
*/
|
|
686
|
+
declare function replaceComparisonBaseline<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never>(options: {
|
|
687
|
+
readonly previous?: ComparisonBaseline<TUnit, TTranslation, TBody, TUnavailable>;
|
|
688
|
+
readonly current: ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>;
|
|
689
|
+
readonly selection?: ComparisonBaselineSelection;
|
|
690
|
+
}): ComparisonBaseline<TUnit, TTranslation, TBody, TUnavailable>;
|
|
691
|
+
/** 读取配置的源译事实并显式记录为基线;此入口不计算关联、比较、策略或 QA。 */
|
|
692
|
+
declare function recordComparisonBaseline<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, store: ComparisonBaselineStore<TUnit, TTranslation, TBody, TUnavailable>): Promise<RecordComparisonBaselineResult<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
693
|
+
/** 验证比较基线数据;兼容读取升级前保存的 v2 快照字段,旧处理基线不会转换为新格式。 */
|
|
694
|
+
declare function validateComparisonBaseline(value: unknown): asserts value is ComparisonBaseline;
|
|
695
|
+
type UpdatePlanExecutionStatus = TranslationWriteStatus | "retained" | "review" | "blocked";
|
|
696
|
+
type UpdatePlanExecutionItemResult<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = {
|
|
697
|
+
readonly index: number;
|
|
698
|
+
readonly action: UpdatePlanAction;
|
|
699
|
+
readonly status: UpdatePlanExecutionStatus;
|
|
700
|
+
readonly reason?: string;
|
|
701
|
+
readonly request?: UpdatePlanItem<TUnit, TTranslation, TBody, TUnavailable>["request"];
|
|
702
|
+
};
|
|
703
|
+
type UpdatePlanApplyResult<TUnit extends TranslationUnitInput, TTranslation, TBody = unknown, TUnavailable = never> = {
|
|
704
|
+
readonly status: "completed" | "failed";
|
|
705
|
+
readonly results: readonly UpdatePlanExecutionItemResult<TUnit, TTranslation, TBody, TUnavailable>[];
|
|
706
|
+
/** 批量写回抛出的原始异常;逐项结果仍保留回读确认的实际状态。 */
|
|
707
|
+
readonly batchError?: unknown;
|
|
708
|
+
};
|
|
709
|
+
type UpdateResult<TUnit extends TranslationUnitInput, TTranslation, TBody = unknown, TUnavailable = never> = UpdatePlanApplyResult<TUnit, TTranslation, TBody, TUnavailable> & {
|
|
710
|
+
readonly plan: UpdatePlan<TUnit, TTranslation, TBody, TUnavailable>;
|
|
711
|
+
readonly baseline?: UpdateBaselineResult;
|
|
712
|
+
};
|
|
713
|
+
type UpdateBaselineResult = {
|
|
714
|
+
readonly outcome: "saved" | "unchanged";
|
|
715
|
+
} | {
|
|
716
|
+
readonly outcome: "notAdvanced";
|
|
717
|
+
readonly message: string;
|
|
718
|
+
} | {
|
|
719
|
+
readonly outcome: "failed";
|
|
720
|
+
readonly message: string;
|
|
721
|
+
};
|
|
722
|
+
type UpdateOptions<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable> = LanguageSelectionOptions & {
|
|
723
|
+
readonly condition?: TranslationWriteCondition<TUnit, TTranslation, TBody, TUnavailable>;
|
|
724
|
+
/** 仅在全语言更新完整处理、回读并核对后记录比较基线。 */
|
|
725
|
+
readonly recordBaseline?: boolean;
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* 直接消费已保存的决定;不读取基线、不比较、不运行策略。
|
|
729
|
+
* 显式选择语言时,越界计划整批拒绝;写入前后的复查也限定在所选语言。
|
|
730
|
+
*/
|
|
731
|
+
declare function applyUpdatePlan<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(plan: unknown, config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, condition?: TranslationWriteCondition<TUnit, TTranslation, TBody, TUnavailable>, options?: LanguageSelectionOptions): Promise<UpdatePlanApplyResult<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
732
|
+
/**
|
|
733
|
+
* 正式更新入口默认只规划并执行资源修改;recordBaseline 显式组合全语言完整更新与基线记录。
|
|
734
|
+
* options.condition 可为每次写入追加业务条件。
|
|
735
|
+
*/
|
|
736
|
+
declare function update<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, store?: ComparisonBaselineStore<TUnit, TTranslation, TBody, TUnavailable>, options?: UpdateOptions<TUnit, TTranslation, TBody, TUnavailable>): Promise<UpdateResult<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
737
|
+
type Awaitable<T> = T | Promise<T>;
|
|
738
|
+
type TranslationUnitInput = {
|
|
739
|
+
readonly source: unknown;
|
|
740
|
+
readonly context?: unknown;
|
|
741
|
+
};
|
|
742
|
+
type BodyAvailability = "available" | "unavailable";
|
|
743
|
+
type EnumerationCompleteness = "complete" | "partial" | "failed";
|
|
744
|
+
type ReadRecord<TValue, TUnavailable = TValue> = {
|
|
745
|
+
readonly value: TValue;
|
|
746
|
+
readonly bodyAvailability: "available";
|
|
747
|
+
} | {
|
|
748
|
+
readonly value: TUnavailable;
|
|
749
|
+
readonly bodyAvailability: "unavailable";
|
|
750
|
+
};
|
|
751
|
+
type ReadScope<TValue, TUnavailable = TValue> = {
|
|
752
|
+
readonly range: unknown;
|
|
753
|
+
readonly enumeration: EnumerationCompleteness;
|
|
754
|
+
readonly records: readonly ReadRecord<TValue, TUnavailable>[];
|
|
755
|
+
readonly error?: string;
|
|
756
|
+
};
|
|
757
|
+
type SourceRead<TUnit extends TranslationUnitInput> = {
|
|
758
|
+
readonly scopes: readonly ReadScope<TUnit>[];
|
|
759
|
+
};
|
|
760
|
+
type SourceAdapter<TUnit extends TranslationUnitInput> = {
|
|
761
|
+
readonly schema: StandardSchemaV1$1<TUnit, TUnit>;
|
|
762
|
+
read(): Awaitable<SourceRead<TUnit>>;
|
|
763
|
+
};
|
|
764
|
+
type TranslationReadScope<TTranslation, TUnavailable = never> = ReadScope<TTranslation, TUnavailable> & {
|
|
765
|
+
readonly covers: readonly string[];
|
|
766
|
+
};
|
|
767
|
+
type TranslationRead<TTranslation, TUnavailable = never> = {
|
|
768
|
+
readonly scopes: readonly TranslationReadScope<TTranslation, TUnavailable>[];
|
|
769
|
+
};
|
|
770
|
+
type TranslationAdapter<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never, TTranslationSchema = StandardSchemaV1$1<TTranslation, TTranslation>, TUnavailableSchema = StandardSchemaV1$1<TUnavailable, TUnavailable>, TContentSchema = StandardSchemaV1$1<TBody, TBody>> = {
|
|
771
|
+
readonly languages: readonly string[];
|
|
772
|
+
readonly schema: TTranslationSchema & StandardSchemaV1$1<TTranslation, TTranslation> & PreservingStandardSchema<TTranslation, TTranslationSchema>;
|
|
773
|
+
readonly unavailableSchema?: TUnavailableSchema & StandardSchemaV1$1<TUnavailable, TUnavailable> & PreservingStandardSchema<TUnavailable, TUnavailableSchema>;
|
|
774
|
+
readonly contentSchema: TContentSchema & StandardSchemaV1$1<TBody, TBody> & PreservingStandardSchema<TBody, TContentSchema>;
|
|
775
|
+
readonly contentOf: (translation: NoInfer<TTranslation>) => NoInfer<TBody>;
|
|
776
|
+
/** 返回与原文相同键空间中的消息键;同一语言内唯一,语言由框架补入译文身份。 */
|
|
777
|
+
readonly keyOf: (translation: NoInfer<TTranslation | TUnavailable>, language: string) => string;
|
|
778
|
+
read(language: string, sourceUnits: readonly SourceUnit<TUnit>[]): Awaitable<TranslationRead<TTranslation, TUnavailable>>;
|
|
779
|
+
};
|
|
780
|
+
type FrameworkConfig<TUnit extends TranslationUnitInput, TTranslation = unknown, TBody = JsonValue$1, TUnavailable = never, TCheckId extends string = string, TGroups extends Readonly<Record<string, readonly NoInfer<TCheckId>[]>> = Readonly<Record<string, readonly TCheckId[]>>> = {
|
|
781
|
+
readonly source: SourceAdapter<TUnit>;
|
|
782
|
+
/** 返回非空、唯一的消息键;每种目标语言通过相同键与原文唯一关联。 */
|
|
783
|
+
readonly keyOf: (unit: TUnit) => string;
|
|
784
|
+
readonly translations?: TranslationAdapter<TUnit, TTranslation, TBody, TUnavailable>;
|
|
785
|
+
readonly compare?: Compare<TUnit, TTranslation, TBody, TUnavailable>;
|
|
786
|
+
readonly translationWriteback?: TranslationWritebackAdapter<TUnit, TTranslation, TBody, TUnavailable>;
|
|
787
|
+
/**
|
|
788
|
+
* 同步纯填充函数:仅接收原文正文并返回目标正文。默认直接使用已读取的原文正文;
|
|
789
|
+
* 默认值与自定义结果都会按 contentSchema 保值验证。
|
|
790
|
+
*/
|
|
791
|
+
readonly createPlaceholderContent?: (source: NoInfer<TUnit["source"]>) => NoInfer<TBody>;
|
|
792
|
+
readonly updatePolicy?: UpdatePolicy<TUnit, TTranslation, TBody, TUnavailable>;
|
|
793
|
+
readonly quality?: QualityConfiguration<TUnit, TTranslation, TBody, TUnavailable, TCheckId, TGroups>;
|
|
794
|
+
};
|
|
795
|
+
type QualityGroupMap<TCheckId extends string> = Readonly<Record<string, readonly NoInfer<TCheckId>[]>>;
|
|
796
|
+
type QualityRunSelectionOptions<TCheckId extends string, TGroupName extends string> = {
|
|
797
|
+
readonly checkIds?: undefined;
|
|
798
|
+
readonly groups?: undefined;
|
|
799
|
+
} | {
|
|
800
|
+
readonly checkIds: readonly NoInfer<TCheckId>[];
|
|
801
|
+
readonly groups?: never;
|
|
802
|
+
} | {
|
|
803
|
+
readonly checkIds?: never;
|
|
804
|
+
readonly groups: readonly NoInfer<TGroupName>[];
|
|
805
|
+
};
|
|
806
|
+
type QualityConfiguration<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never, TCheckId extends string = string, TGroups extends QualityGroupMap<TCheckId> = QualityGroupMap<TCheckId>> = {
|
|
807
|
+
/** 直接声明本次运行使用的检查器;检查器的校验与执行由 SDK 管理。 */
|
|
808
|
+
readonly checks?: readonly QualityCheckDefinition<NoInfer<TUnit>, NoInfer<TTranslation>, QualityObject, NoInfer<TBody>, NoInfer<TUnavailable>, TCheckId>[];
|
|
809
|
+
/** 项目自定义分组;每个成员只能引用 checks 中声明的检查项 ID。 */
|
|
810
|
+
readonly groups?: TGroups;
|
|
811
|
+
/** 关系上下文不随候选筛选裁剪。 */
|
|
812
|
+
readonly relationships?: readonly QualityRelationship[];
|
|
813
|
+
/** 显式启用原始结果缓存;命中后仍应用当前 QA 豁免,存储故障不阻断检查。 */
|
|
814
|
+
readonly resultCache?: QualityCheckResultCache;
|
|
815
|
+
readonly suppressionStore?: QaSuppressionStore;
|
|
816
|
+
};
|
|
817
|
+
type DefineConfigInput<TUnit extends TranslationUnitInput, TSchema, TTranslationSchema, TUnavailableSchema, TContentSchema, TCheckId extends string, TGroups extends QualityGroupMap<TCheckId>> = Omit<FrameworkConfig<NoInfer<TUnit>, NoInfer<SchemaOutput<TTranslationSchema>>, NoInfer<SchemaOutput<TContentSchema>>, NoInfer<SchemaOutput<TUnavailableSchema>>, TCheckId, TGroups>, "source" | "translations"> & {
|
|
818
|
+
readonly source: {
|
|
819
|
+
readonly schema: TSchema & StandardSchemaV1$1<TUnit, TUnit> & PreservingStandardSchema<TUnit, TSchema>;
|
|
820
|
+
read(): Awaitable<SourceRead<NoInfer<TUnit>>>;
|
|
821
|
+
};
|
|
822
|
+
readonly translations?: TranslationAdapterInput<NoInfer<TUnit>, TTranslationSchema, TUnavailableSchema, TContentSchema>;
|
|
823
|
+
};
|
|
824
|
+
type TranslationAdapterInput<TUnit extends TranslationUnitInput, TTranslationSchema, TUnavailableSchema, TContentSchema> = {
|
|
825
|
+
readonly languages: readonly string[];
|
|
826
|
+
readonly schema: TTranslationSchema & StandardSchemaV1$1<SchemaOutput<TTranslationSchema>, SchemaOutput<TTranslationSchema>> & PreservingStandardSchema<SchemaOutput<TTranslationSchema>, TTranslationSchema>;
|
|
827
|
+
readonly unavailableSchema?: TUnavailableSchema & StandardSchemaV1$1<SchemaOutput<TUnavailableSchema>, SchemaOutput<TUnavailableSchema>> & PreservingStandardSchema<SchemaOutput<TUnavailableSchema>, TUnavailableSchema>;
|
|
828
|
+
readonly contentSchema: TContentSchema & StandardSchemaV1$1<SchemaOutput<TContentSchema>, SchemaOutput<TContentSchema>> & PreservingStandardSchema<SchemaOutput<TContentSchema>, TContentSchema>;
|
|
829
|
+
readonly contentOf: (translation: NoInfer<SchemaOutput<TTranslationSchema>>) => NoInfer<SchemaOutput<TContentSchema>>;
|
|
830
|
+
readonly keyOf: (translation: NoInfer<SchemaOutput<TTranslationSchema> | SchemaOutput<TUnavailableSchema>>, language: string) => string;
|
|
831
|
+
read(language: string, sourceUnits: readonly SourceUnit<NoInfer<TUnit>>[]): Awaitable<TranslationRead<NoInfer<SchemaOutput<TTranslationSchema>>, NoInfer<SchemaOutput<TUnavailableSchema>>>>;
|
|
832
|
+
};
|
|
833
|
+
type SchemaOutput<TSchema> = TSchema extends never ? never : StandardSchemaTypes<TSchema> extends {
|
|
834
|
+
readonly output: infer TOutput;
|
|
835
|
+
} ? TOutput : never;
|
|
836
|
+
type SourceUnit<TUnit extends TranslationUnitInput> = {
|
|
837
|
+
readonly key: string;
|
|
838
|
+
readonly unit: TUnit;
|
|
839
|
+
readonly bodyAvailability: BodyAvailability;
|
|
840
|
+
readonly scopeIndex: number;
|
|
841
|
+
};
|
|
842
|
+
type SourceReadCoverage = {
|
|
843
|
+
readonly status: CoverageStatus;
|
|
844
|
+
readonly scopes: readonly {
|
|
845
|
+
readonly range: unknown;
|
|
846
|
+
readonly enumeration: EnumerationCompleteness;
|
|
847
|
+
readonly recordCount: number;
|
|
848
|
+
readonly error?: string;
|
|
849
|
+
}[];
|
|
850
|
+
readonly error?: string;
|
|
851
|
+
};
|
|
852
|
+
type SourceSnapshot<TUnit extends TranslationUnitInput> = {
|
|
853
|
+
readonly version: string;
|
|
854
|
+
readonly read: SourceReadCoverage;
|
|
855
|
+
readonly totalUnitCount: number | null;
|
|
856
|
+
readonly units: readonly SourceUnit<TUnit>[];
|
|
857
|
+
};
|
|
858
|
+
type TranslationAssociationStatus = "matched" | "missing" | "unavailable" | "unknown";
|
|
859
|
+
type CoverageStatus = "complete" | "incomplete" | "failed" | "notRead";
|
|
860
|
+
type TranslationReadScopeCoverage = {
|
|
861
|
+
readonly range: unknown;
|
|
862
|
+
readonly covers: readonly string[];
|
|
863
|
+
readonly enumeration: EnumerationCompleteness;
|
|
864
|
+
readonly translationIndexes: readonly number[];
|
|
865
|
+
readonly error?: string;
|
|
866
|
+
};
|
|
867
|
+
type TranslationReadCoverage = {
|
|
868
|
+
readonly language: string;
|
|
869
|
+
readonly status: CoverageStatus;
|
|
870
|
+
readonly scopes: readonly TranslationReadScopeCoverage[];
|
|
871
|
+
readonly error?: string;
|
|
872
|
+
};
|
|
873
|
+
type TranslationBase = {
|
|
874
|
+
readonly index: number;
|
|
875
|
+
readonly language: string;
|
|
876
|
+
readonly scopeIndex: number;
|
|
877
|
+
readonly range: unknown;
|
|
878
|
+
};
|
|
879
|
+
type Translation<TTranslation, TBody = JsonValue$1, TUnavailable = never> = (TranslationBase & {
|
|
880
|
+
readonly record: TTranslation;
|
|
881
|
+
readonly identity: TranslationIdentity;
|
|
882
|
+
readonly content: TBody;
|
|
883
|
+
readonly bodyAvailability: "available";
|
|
884
|
+
}) | (TranslationBase & {
|
|
885
|
+
readonly record: TUnavailable;
|
|
886
|
+
readonly identity: TranslationIdentity;
|
|
887
|
+
readonly content?: never;
|
|
888
|
+
readonly bodyAvailability: "unavailable";
|
|
889
|
+
});
|
|
890
|
+
type TranslationAssociation = {
|
|
891
|
+
readonly sourceKey: string;
|
|
892
|
+
readonly language: string;
|
|
893
|
+
readonly status: TranslationAssociationStatus;
|
|
894
|
+
readonly coverageStatus: CoverageStatus;
|
|
895
|
+
readonly scopeIndexes: readonly number[];
|
|
896
|
+
/** 对应同键译文的索引,至多一项;空数组的含义由读取完整性决定。 */
|
|
897
|
+
readonly translationIndexes: readonly number[];
|
|
898
|
+
};
|
|
899
|
+
/** 语言与消息键共同构成译文身份;消息键同时用于和原文唯一关联。 */
|
|
900
|
+
type TranslationIdentity = {
|
|
901
|
+
readonly language: string;
|
|
902
|
+
readonly key: string;
|
|
903
|
+
};
|
|
904
|
+
type ComparisonSnapshot<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = {
|
|
905
|
+
readonly version: string;
|
|
906
|
+
readonly source: SourceSnapshot<TUnit>;
|
|
907
|
+
readonly translations: {
|
|
908
|
+
readonly reads: readonly TranslationReadCoverage[];
|
|
909
|
+
readonly records: readonly Translation<TTranslation, TBody, TUnavailable>[];
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
type ProjectSnapshot<TUnit extends TranslationUnitInput, TTranslation, TBody = JsonValue$1, TUnavailable = never> = ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable> & {
|
|
913
|
+
readonly associations: readonly TranslationAssociation[];
|
|
914
|
+
};
|
|
915
|
+
declare class DuplicateTranslationUnitKeyError extends Error {
|
|
916
|
+
readonly key: string;
|
|
917
|
+
readonly firstIndex: number;
|
|
918
|
+
readonly duplicateIndex: number;
|
|
919
|
+
constructor(key: string, firstIndex: number, duplicateIndex: number);
|
|
920
|
+
}
|
|
921
|
+
declare function defineConfigImplementation<TUnit extends TranslationUnitInput, TSchema = StandardSchemaV1$1<TUnit, TUnit>, TTranslationSchema = StandardSchemaV1$1<unknown, unknown>, TUnavailableSchema = never, TContentSchema = StandardSchemaV1$1<JsonValue$1, JsonValue$1>, TCheckId extends string = never, const TGroups extends QualityGroupMap<TCheckId> = {}>(config: DefineConfigInput<TUnit, TSchema, TTranslationSchema, TUnavailableSchema, TContentSchema, TCheckId, TGroups>): FrameworkConfig<TUnit, SchemaOutput<TTranslationSchema>, SchemaOutput<TContentSchema>, SchemaOutput<TUnavailableSchema>, TCheckId, TGroups>;
|
|
922
|
+
/**
|
|
923
|
+
* 声明宿主配置。显式业务泛型通过 withTypes 预先绑定,以便从配置内容推断检查项与分组。
|
|
924
|
+
* 静态字面量 ID 保留精确选择类型;混入普通 string ID 会使检查项联合退化为 string,
|
|
925
|
+
* 此时检查项、分组成员和运行选项依赖 QA 入口的运行时目录校验。
|
|
926
|
+
*/
|
|
927
|
+
declare const defineConfig: typeof defineConfigImplementation & {
|
|
928
|
+
withTypes<TUnit extends TranslationUnitInput, TSchema = StandardSchemaV1$1<TUnit, TUnit>, TTranslationSchema = StandardSchemaV1$1<unknown, unknown>, TUnavailableSchema = never, TContentSchema = StandardSchemaV1$1<JsonValue$1, JsonValue$1>>(): <TCheckId extends string = never, const TGroups extends QualityGroupMap<TCheckId> = {}>(config: DefineConfigInput<TUnit, TSchema, TTranslationSchema, TUnavailableSchema, TContentSchema, TCheckId, TGroups>) => FrameworkConfig<TUnit, SchemaOutput<TTranslationSchema>, SchemaOutput<TContentSchema>, SchemaOutput<TUnavailableSchema>, TCheckId, TGroups>;
|
|
929
|
+
};
|
|
930
|
+
declare function readSourceSnapshot<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>): Promise<SourceSnapshot<TUnit>>;
|
|
931
|
+
/** 读取源、目标事实及读取依据,不计算源译关联或运行 QA。 */
|
|
932
|
+
declare function readComparisonSnapshot<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, options?: LanguageSelectionOptions): Promise<ComparisonSnapshot<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
933
|
+
declare function readProjectSnapshot<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable>, options?: LanguageSelectionOptions): Promise<ProjectSnapshot<TUnit, TTranslation, TBody, TUnavailable>>;
|
|
934
|
+
declare function runQa<TUnit extends TranslationUnitInput, TTranslation, TBody, TUnavailable, TCheckId extends string, TGroups extends QualityGroupMap<TCheckId>>(config: FrameworkConfig<TUnit, TTranslation, TBody, TUnavailable, TCheckId, TGroups>, options?: LanguageSelectionOptions & QualityRunSelectionOptions<NoInfer<TCheckId>, NoInfer<keyof TGroups & string>> & {
|
|
935
|
+
/** 在 QA 前构造候选;身份必须引用本次读取到的原文键和译文语言。 */
|
|
936
|
+
readonly candidates?: readonly TranslationCandidate<TBody>[];
|
|
937
|
+
/** 仅筛选或重排传入的候选;返回项必须来自传入集合且身份不能重复。 */
|
|
938
|
+
readonly selectCandidates?: (candidates: readonly TranslationCandidate<TBody>[]) => readonly TranslationCandidate<TBody>[];
|
|
939
|
+
readonly memo?: MemoScope;
|
|
940
|
+
readonly profiler?: QualityProfiler;
|
|
941
|
+
/** 按需包含零诊断执行归属与指纹;默认仅保留产生了实际原始诊断的执行记录。 */
|
|
942
|
+
readonly includeCleanExecutions?: boolean;
|
|
943
|
+
}): Promise<QualityRunResult<QualityObject, TBody>>;
|
|
944
|
+
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
945
|
+
readonly [key: string]: JsonValue;
|
|
946
|
+
};
|
|
947
|
+
type TermUsage = "preferred" | "allowed" | "forbidden";
|
|
948
|
+
type TermType = "fullForm" | "abbreviation" | "acronym" | "shortForm" | "variant" | "phrase";
|
|
949
|
+
type TermMetadata = {
|
|
950
|
+
readonly note?: string;
|
|
951
|
+
readonly metadata?: JsonValue;
|
|
952
|
+
readonly sourceRefs?: readonly JsonValue[];
|
|
953
|
+
};
|
|
954
|
+
type TermExpressionData = TermMetadata & {
|
|
955
|
+
readonly id: string;
|
|
956
|
+
readonly text: string;
|
|
957
|
+
readonly usage: TermUsage;
|
|
958
|
+
readonly termType?: TermType;
|
|
959
|
+
};
|
|
960
|
+
type TermLanguageData = TermMetadata & {
|
|
961
|
+
readonly language: string;
|
|
962
|
+
readonly definition?: {
|
|
963
|
+
readonly text: string;
|
|
964
|
+
readonly sourceRefs?: readonly JsonValue[];
|
|
965
|
+
};
|
|
966
|
+
readonly expressions: readonly TermExpressionData[];
|
|
967
|
+
};
|
|
968
|
+
type TermConceptData = TermMetadata & {
|
|
969
|
+
readonly id: string;
|
|
970
|
+
readonly languages: readonly TermLanguageData[];
|
|
971
|
+
readonly subjectFields?: readonly string[];
|
|
972
|
+
};
|
|
973
|
+
type TermbaseData = TermMetadata & {
|
|
974
|
+
readonly concepts: readonly TermConceptData[];
|
|
975
|
+
};
|
|
976
|
+
/** 查询用的平面视图;规范资料仍保留概念、语言和表达三层。 */
|
|
977
|
+
type TermExpression = {
|
|
978
|
+
readonly conceptId: string;
|
|
979
|
+
readonly expressionId: string;
|
|
980
|
+
readonly language: string;
|
|
981
|
+
readonly concept: TermConceptData;
|
|
982
|
+
readonly languageData: TermLanguageData;
|
|
983
|
+
readonly expression: TermExpressionData;
|
|
984
|
+
};
|
|
985
|
+
type Termbase = {
|
|
986
|
+
readonly data: TermbaseData;
|
|
987
|
+
readonly concepts: readonly TermConceptData[];
|
|
988
|
+
readonly expressions: readonly TermExpression[];
|
|
989
|
+
readonly getConcept: (id: string) => TermConceptData | undefined;
|
|
990
|
+
readonly getExpression: (conceptId: string, expressionId: string) => TermExpression | undefined;
|
|
991
|
+
};
|
|
992
|
+
type TermContractIssue = {
|
|
993
|
+
readonly code: string;
|
|
994
|
+
readonly message: string;
|
|
995
|
+
readonly path: readonly (string | number)[];
|
|
996
|
+
readonly conceptId?: string;
|
|
997
|
+
readonly expressionId?: string;
|
|
998
|
+
};
|
|
999
|
+
declare class TermContractError extends TypeError {
|
|
1000
|
+
readonly stage: "create" | "select" | "compile" | "input";
|
|
1001
|
+
readonly issues: readonly TermContractIssue[];
|
|
1002
|
+
constructor(stage: TermContractError["stage"], issues: readonly TermContractIssue[]);
|
|
1003
|
+
}
|
|
1004
|
+
/** 创建独立、不可改写的资料快照;使用地位冲突在有效选择之后检查。 */
|
|
1005
|
+
declare function createTermbase(value: unknown): Termbase;
|
|
1006
|
+
type TermSelection = {
|
|
1007
|
+
readonly concept?: (concept: TermConceptData) => boolean;
|
|
1008
|
+
readonly expression?: (expression: TermExpression) => boolean;
|
|
1009
|
+
};
|
|
1010
|
+
declare function selectTerms(termbase: Termbase, selection?: TermSelection): Termbase;
|
|
1011
|
+
type TermbaseYamlFiles = {
|
|
1012
|
+
readonly concepts: string;
|
|
1013
|
+
readonly languages: Readonly<Record<string, string>>;
|
|
1014
|
+
};
|
|
1015
|
+
type TermbaseYamlIssue = {
|
|
1016
|
+
readonly code: string;
|
|
1017
|
+
readonly file: string;
|
|
1018
|
+
readonly message: string;
|
|
1019
|
+
};
|
|
1020
|
+
declare class TermbaseYamlError extends TypeError {
|
|
1021
|
+
readonly stage: "parse" | "validation";
|
|
1022
|
+
readonly issues: readonly TermbaseYamlIssue[];
|
|
1023
|
+
constructor(stage: TermbaseYamlError["stage"], issues: readonly TermbaseYamlIssue[], options?: ErrorOptions);
|
|
1024
|
+
}
|
|
1025
|
+
/** 在内存中解析概念与语言 YAML,并返回经过领域校验的术语库。 */
|
|
1026
|
+
declare function parseTermbaseYaml(files: TermbaseYamlFiles): Termbase;
|
|
1027
|
+
export { UpdateResult as $, defaultCompare as $n, validateQaSuppressionFile as $t, SourceAdapter as A, TranslationWritebackAdapter as An, QualityDiagnostic as At, TranslationRead as B, StandardSchemaV1$1 as Bn, defineChecker as Bt, DuplicateTranslationUnitKeyError as C, TranslationWriteConditionResult as Cn, QualityCheckResult as Ct, QualityConfiguration as D, TranslationWriteStatus as Dn, QualityDataLoadInput as Dt, ProjectSnapshot as E, TranslationWriteSourceExpectation as En, QualityCoverage as Et, Translation as F, validateTranslationWriteRequest as Fn, QualityReadCoverage as Ft, defineConfig as G, CompareInput as Gn, QaSuppressionFile as Gt, TranslationReadScope as H, StandardSchemaV1Result as Hn, CreateQaSuppressionInput as Ht, TranslationAdapter as I, writeTranslationRequests as In, QualityRelationship as It, readSourceSnapshot as J, ComparisonStatus as Jn, QaSuppressionFormatErrorReason as Jt, readComparisonSnapshot as K, ComparisonContractError as Kn, QaSuppressionFingerprintSummary as Kt, TranslationAssociation as L, JsonValue$1 as Ln, QualityRunResult as Lt, SourceReadCoverage as M, TranslationWritebackResolution as Mn, QualityFinding as Mt, SourceSnapshot as N, TranslationWritebackTarget as Nn, QualityLocation as Nt, ReadRecord as O, TranslationWriteTarget as On, QualityDataReader as Ot, SourceUnit as P, validateTranslationCandidate as Pn, QualityObject as Pt, UpdatePlanExecutionStatus as Q, compareSnapshots as Qn, validateQaSuppression as Qt, TranslationAssociationStatus as R, StandardSchemaContractError as Rn, QualitySubject as Rt, CoverageStatus as S, TranslationWriteConditionInput as Sn, QualityCheckExecution as St, FrameworkConfig as T, TranslationWriteResult as Tn, QualityCheckerContractError as Tt, TranslationReadScopeCoverage as U, LanguageSelectionOptions as Un, QaSuppression as Ut, TranslationReadCoverage as V, StandardSchemaV1Issue as Vn, QualityCheckResultCache as Vt, TranslationUnitInput as W, Compare as Wn, QaSuppressionExecution as Wt, UpdatePlanApplyResult as X, SourceChange as Xn, createQaSuppression as Xt, runQa as Y, SnapshotReadEvidence as Yn, QaSuppressionStore as Yt, UpdatePlanExecutionItemResult as Z, TranslationChange as Zn, upsertQaSuppressionFromReport as Zt, createTermbase as _, previewUpdate as _n, TranslationIdentityContractError as _t, JsonValue as a, UpdatePlanData as an, createMemoScope as ar, ComparisonBaselineSelection as at, BodyAvailability as b, TranslationWriteBatchResult as bn, CheckerPrepareInput as bt, TermContractIssue as c, UpdatePlanSourceChange as cn, QualityProfileCandidateStatus as cr, recordComparisonBaseline as ct, TermLanguageData as d, UpdatePlanWriteRequest as dn, QualityProfileStage as dr, QualityReportDecision as dt, validateQaSuppressions as en, validateComparisonInput as er, applyUpdatePlan as et, TermSelection as f, UpdatePolicy as fn, QualityProfileTiming as fr, QualityReportDecisionStatus as ft, TermbaseData as g, defaultUpdatePolicy as gn, isQualityReportPassing as gt, Termbase as h, createUpdatePlan as hn, createQualityProfiler as hr, formatQualityReport as ht, parseTermbaseYaml as i, UpdatePlanComparisons as in, MemoScopeClosedError as ir, ComparisonBaselineIncompleteSnapshotError as it, SourceRead as j, TranslationWritebackInput as jn, QualityEvidence as jt, ReadScope as k, TranslationWriteTargetExpectation as kn, QualityDataReaderContractError as kt, TermExpression as l, UpdatePlanStore as ln, QualityProfileCheck as lr, replaceComparisonBaseline as lt, TermUsage as m, UpdateTargetExpectation as mn, QualityProfilerOptions as mr, decideQualityReport as mt, TermbaseYamlFiles as n, UpdatePlanAction as nn, MemoOptions as nr, ComparisonBaseline as nt, TermConceptData as o, UpdatePlanInput as on, QualityProfileCache as or, ComparisonBaselineStore as ot, TermType as p, UpdateSourceExpectation as pn, QualityProfiler as pr, QualityReportFormatOptions as pt, readProjectSnapshot as q, ComparisonResult as qn, QaSuppressionFormatError as qt, TermbaseYamlIssue as r, UpdatePlanAssociations as rn, MemoScope as rr, ComparisonBaselineFormatError as rt, TermContractError as s, UpdatePlanItem as sn, QualityProfileCandidate as sr, RecordComparisonBaselineResult as st, TermbaseYamlError as t, UpdatePlan as tn, validateComparisonResult as tr, update as tt, TermExpressionData as u, UpdatePlanTranslationChange as un, QualityProfileReport as ur, validateComparisonBaseline as ut, selectTerms as v, validateUpdatePlan as vn, CheckerDefinition as vt, EnumerationCompleteness as w, TranslationWriteRequest as wn, QualityCheckScope as wt, ComparisonSnapshot as x, TranslationWriteCondition as xn, QualityCheckDefinition as xt, Awaitable as y, TranslationCandidate as yn, CheckerLoadInput as yt, TranslationIdentity as z, StandardSchemaFailureKind as zn, TranslationProgress as zt };
|