@done-coding/schema-api 0.0.1-alpha.1 → 0.0.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/es/index.mjs +43 -480
- package/es/reference.mjs +471 -0
- package/lib/index.cjs +1 -1
- package/lib/reference.cjs +1 -0
- package/package.json +26 -4
- package/schemas/common-error-codes.schema.json +24 -23
- package/schemas/cursor-list-request.schema.json +4 -4
- package/schemas/error-body.schema.json +7 -8
- package/schemas/list-filter.schema.json +1 -1
- package/schemas/list-reference-values.schema.json +23 -0
- package/schemas/paged-list-request.schema.json +7 -9
- package/schemas/paged-list.schema.json +2 -3
- package/schemas/service-error-codes.schema.json +9 -5
- package/types/index.d.cts +365 -0
- package/types/index.d.ts +10 -161
- package/types/reference.d.cts +251 -0
- package/types/reference.d.ts +251 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BoundedList 响应里各字段的路径(由定义 bounded-list.schema.json 生成)。
|
|
3
|
+
*/
|
|
4
|
+
export declare const BOUNDED_LIST_RESPONSE_PATHS: {
|
|
5
|
+
readonly items: "items";
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 通用失败码 → HTTP 状态、能否重试与是否已执行(outcome)的参考值、含义(参考资源)。
|
|
10
|
+
* 包不替使用方填写;使用方可显式引用表中值。
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMMON_ERROR_CODE_TABLE: {
|
|
13
|
+
readonly INVALID_REQUEST: {
|
|
14
|
+
readonly httpStatus: 400;
|
|
15
|
+
readonly retryable: false;
|
|
16
|
+
readonly outcome: "not_executed";
|
|
17
|
+
readonly meaning: "请求不符合接口契约";
|
|
18
|
+
};
|
|
19
|
+
readonly UNAUTHENTICATED: {
|
|
20
|
+
readonly httpStatus: 401;
|
|
21
|
+
readonly retryable: false;
|
|
22
|
+
readonly outcome: "not_executed";
|
|
23
|
+
readonly meaning: "未登录,或令牌无效、过期";
|
|
24
|
+
};
|
|
25
|
+
readonly FORBIDDEN: {
|
|
26
|
+
readonly httpStatus: 403;
|
|
27
|
+
readonly retryable: false;
|
|
28
|
+
readonly outcome: "not_executed";
|
|
29
|
+
readonly meaning: "已认证但无权执行";
|
|
30
|
+
};
|
|
31
|
+
readonly NOT_FOUND: {
|
|
32
|
+
readonly httpStatus: 404;
|
|
33
|
+
readonly retryable: false;
|
|
34
|
+
readonly outcome: "not_executed";
|
|
35
|
+
readonly meaning: "资源不存在,或调用方无权得知其存在";
|
|
36
|
+
};
|
|
37
|
+
readonly ROUTE_NOT_FOUND: {
|
|
38
|
+
readonly httpStatus: 404;
|
|
39
|
+
readonly retryable: false;
|
|
40
|
+
readonly outcome: "not_executed";
|
|
41
|
+
readonly meaning: "接口路径不存在";
|
|
42
|
+
};
|
|
43
|
+
readonly METHOD_NOT_ALLOWED: {
|
|
44
|
+
readonly httpStatus: 405;
|
|
45
|
+
readonly retryable: false;
|
|
46
|
+
readonly outcome: "not_executed";
|
|
47
|
+
readonly meaning: "接口不支持该 HTTP 方法";
|
|
48
|
+
};
|
|
49
|
+
readonly CONFLICT: {
|
|
50
|
+
readonly httpStatus: 409;
|
|
51
|
+
readonly retryable: false;
|
|
52
|
+
readonly outcome: "not_executed";
|
|
53
|
+
readonly meaning: "资源状态冲突";
|
|
54
|
+
};
|
|
55
|
+
readonly RATE_LIMITED: {
|
|
56
|
+
readonly httpStatus: 429;
|
|
57
|
+
readonly retryable: true;
|
|
58
|
+
readonly outcome: "not_executed";
|
|
59
|
+
readonly meaning: "请求过于频繁,可稍后重试";
|
|
60
|
+
};
|
|
61
|
+
readonly INTERNAL_ERROR: {
|
|
62
|
+
readonly httpStatus: 500;
|
|
63
|
+
readonly retryable: false;
|
|
64
|
+
readonly outcome: "unknown";
|
|
65
|
+
readonly meaning: "服务内部错误,可能已产生副作用";
|
|
66
|
+
};
|
|
67
|
+
readonly LIST_LIMIT_EXCEEDED: {
|
|
68
|
+
readonly httpStatus: 500;
|
|
69
|
+
readonly retryable: false;
|
|
70
|
+
readonly outcome: "unknown";
|
|
71
|
+
readonly meaning: "一次性列表的结果超出接口声明的上限";
|
|
72
|
+
};
|
|
73
|
+
readonly SERVICE_UNAVAILABLE: {
|
|
74
|
+
readonly httpStatus: 503;
|
|
75
|
+
readonly retryable: true;
|
|
76
|
+
readonly outcome: "unknown";
|
|
77
|
+
readonly meaning: "服务或其依赖暂不可用";
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 通用失败码(参考资源)。错误体的 code 是开放字符串,这里只列通用的一组;
|
|
83
|
+
* 各服务可以有自己的专有码,遇到不认识的码按 HTTP 状态归类处理。
|
|
84
|
+
*/
|
|
85
|
+
export declare const COMMON_ERROR_CODES: {
|
|
86
|
+
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
87
|
+
readonly UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
88
|
+
readonly FORBIDDEN: "FORBIDDEN";
|
|
89
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
90
|
+
readonly ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND";
|
|
91
|
+
readonly METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED";
|
|
92
|
+
readonly CONFLICT: "CONFLICT";
|
|
93
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
94
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
95
|
+
readonly LIST_LIMIT_EXCEEDED: "LIST_LIMIT_EXCEEDED";
|
|
96
|
+
readonly SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE";
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export declare type CommonErrorCode = (typeof COMMON_ERROR_CODES)[keyof typeof COMMON_ERROR_CODES];
|
|
100
|
+
|
|
101
|
+
/** CommonErrorCodes:common-error-codes.schema.json */
|
|
102
|
+
export declare const commonErrorCodesSchema: SchemaDocument;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 游标式列表的参考数值:maxLimit 是每批条数可参考的上限(由定义 list-reference-values.schema.json 生成)。
|
|
106
|
+
* 只是参考,不随任何结构生效;包不替使用方填写,要用须显式引用。
|
|
107
|
+
*/
|
|
108
|
+
export declare const CURSOR_LIST_REFERENCE_VALUES: {
|
|
109
|
+
readonly maxLimit: 100;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* CursorListRequest 的线上参数名(由定义 cursor-list-request.schema.json 生成)。
|
|
114
|
+
*/
|
|
115
|
+
export declare const CURSOR_LIST_REQUEST_PARAMS: {
|
|
116
|
+
readonly after: "cursor.after";
|
|
117
|
+
readonly limit: "cursor.limit";
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* CursorList 响应里各字段的路径(由定义 cursor-list.schema.json 生成)。
|
|
122
|
+
*/
|
|
123
|
+
export declare const CURSOR_LIST_RESPONSE_PATHS: {
|
|
124
|
+
readonly items: "items";
|
|
125
|
+
readonly next: "cursor.next";
|
|
126
|
+
readonly hasMore: "cursor.hasMore";
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 找出专有码清单里与 reserved 中的码重名的项。结构本身只把 OK 与 HTTP_<数字> 当保留字;
|
|
131
|
+
* 要让专有码避开某组通用码(如包里的 COMMON_ERROR_CODES,或自己的一组),把那组码传进来:
|
|
132
|
+
* 字符串的可迭代集合(数组、Set),或「名字 → 码」的对象(取值,不取键)。
|
|
133
|
+
* 按字节比较,不做大小写归一;reserved 为空就什么也不比。
|
|
134
|
+
*
|
|
135
|
+
* 用法:findReservedCodes(list, COMMON_ERROR_CODES),返回空数组即没有撞码。
|
|
136
|
+
*/
|
|
137
|
+
export declare function findReservedCodes(list: Pick<ServiceErrorCodes, "codes">, reserved: Iterable<string> | Readonly<Record<string, string>>): ReservedCodeHit[];
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* ListFilter 的线上参数名(由定义 list-filter.schema.json 生成)。
|
|
141
|
+
*/
|
|
142
|
+
export declare const LIST_FILTER_PARAMS: {
|
|
143
|
+
readonly prefix: "filter.";
|
|
144
|
+
readonly operators: {
|
|
145
|
+
readonly eq: "eq";
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** ListReferenceValues:list-reference-values.schema.json */
|
|
150
|
+
export declare const listReferenceValuesSchema: SchemaDocument;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 页码式列表的参考数值:page 是请求不带页码时可参考的页码,pageSize 是请求不带每页条数时可参考的条数,maxPageSize 是每页条数可参考的上限(由定义 list-reference-values.schema.json 生成)。
|
|
154
|
+
* 只是参考,不随任何结构生效;包不替使用方填写,要用须显式引用。
|
|
155
|
+
*/
|
|
156
|
+
export declare const PAGED_LIST_REFERENCE_VALUES: {
|
|
157
|
+
readonly page: 1;
|
|
158
|
+
readonly pageSize: 10;
|
|
159
|
+
readonly maxPageSize: 100;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* PagedListRequest 的线上参数名(由定义 paged-list-request.schema.json 生成)。
|
|
164
|
+
*/
|
|
165
|
+
export declare const PAGED_LIST_REQUEST_PARAMS: {
|
|
166
|
+
readonly page: "page.page";
|
|
167
|
+
readonly pageSize: "page.pageSize";
|
|
168
|
+
readonly query: "page.query";
|
|
169
|
+
readonly orderBy: "page.orderBy";
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* PagedList 响应里各字段的路径(由定义 paged-list.schema.json 生成)。
|
|
174
|
+
*/
|
|
175
|
+
export declare const PAGED_LIST_RESPONSE_PATHS: {
|
|
176
|
+
readonly items: "items";
|
|
177
|
+
readonly totalRecord: "page.totalRecord";
|
|
178
|
+
readonly pageSize: "page.pageSize";
|
|
179
|
+
readonly totalPage: "page.totalPage";
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** 全部参考资源定义,键为定义的 $id(即文件名)。 */
|
|
183
|
+
export declare const referenceSchemas: {
|
|
184
|
+
readonly "common-error-codes.schema.json": SchemaDocument;
|
|
185
|
+
readonly "list-reference-values.schema.json": SchemaDocument;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** 专有码清单里撞上保留码集合的一项:index 是它在 codes 里的位置。 */
|
|
189
|
+
export declare interface ReservedCodeHit {
|
|
190
|
+
index: number;
|
|
191
|
+
code: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** 一份 JSON Schema 定义文档。 */
|
|
195
|
+
declare interface SchemaDocument {
|
|
196
|
+
readonly [keyword: string]: unknown;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 一个专有码。stage 为 execute 时不得有 httpStatus 与 additionalHttpStatuses;为 accept 或 both 时必须有 httpStatus。additionalHttpStatuses 不含主状态(x-arrayExcludesProperty)。
|
|
201
|
+
*/
|
|
202
|
+
declare interface ServiceErrorCode {
|
|
203
|
+
/**
|
|
204
|
+
* 码:整体大写下划线或整体小写下划线写法,字母开头,不以下划线结尾,不含连续下划线,最长 128 个字符。
|
|
205
|
+
*/
|
|
206
|
+
code: string;
|
|
207
|
+
/**
|
|
208
|
+
* accept:受理时同步返回;execute:异步执行阶段产生;both:两者都有。
|
|
209
|
+
*/
|
|
210
|
+
stage: "accept" | "execute" | "both";
|
|
211
|
+
/**
|
|
212
|
+
* 主 HTTP 状态,4xx 或 5xx。
|
|
213
|
+
*/
|
|
214
|
+
httpStatus?: number;
|
|
215
|
+
/**
|
|
216
|
+
* 同一个码在不同情形下的其他 HTTP 状态:至少 1 项、不重复、不含主状态。
|
|
217
|
+
*
|
|
218
|
+
* @minItems 1
|
|
219
|
+
*/
|
|
220
|
+
additionalHttpStatuses?: [number, ...number[]];
|
|
221
|
+
/**
|
|
222
|
+
* 原样重试是否可能成功。
|
|
223
|
+
*/
|
|
224
|
+
retryable: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* not_executed:确定没有执行;unknown:可能已产生副作用。
|
|
227
|
+
*/
|
|
228
|
+
outcome: "not_executed" | "unknown";
|
|
229
|
+
/**
|
|
230
|
+
* 一句话含义,1–1000 个字符。
|
|
231
|
+
*/
|
|
232
|
+
meaning: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 一个服务的专有业务码清单。OK 与 HTTP_<数字> 形式的码是结构保留字,不得使用;比较按字节精确进行,不做大小写归一。专有码是否要避开某组通用码由使用方显式检查:把那组码传给参考资源出口的检查函数,不传就不比。
|
|
237
|
+
*/
|
|
238
|
+
declare interface ServiceErrorCodes {
|
|
239
|
+
/**
|
|
240
|
+
* 服务标识:小写字母开头,只含小写字母、数字、短横线,最长 64 个字符。
|
|
241
|
+
*/
|
|
242
|
+
service: string;
|
|
243
|
+
/**
|
|
244
|
+
* 专有码,至少 1 项;code 在清单内不重复(x-uniqueItemsBy)。
|
|
245
|
+
*
|
|
246
|
+
* @minItems 1
|
|
247
|
+
*/
|
|
248
|
+
codes: [ServiceErrorCode, ...ServiceErrorCode[]];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { }
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BoundedList 响应里各字段的路径(由定义 bounded-list.schema.json 生成)。
|
|
3
|
+
*/
|
|
4
|
+
export declare const BOUNDED_LIST_RESPONSE_PATHS: {
|
|
5
|
+
readonly items: "items";
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 通用失败码 → HTTP 状态、能否重试与是否已执行(outcome)的参考值、含义(参考资源)。
|
|
10
|
+
* 包不替使用方填写;使用方可显式引用表中值。
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMMON_ERROR_CODE_TABLE: {
|
|
13
|
+
readonly INVALID_REQUEST: {
|
|
14
|
+
readonly httpStatus: 400;
|
|
15
|
+
readonly retryable: false;
|
|
16
|
+
readonly outcome: "not_executed";
|
|
17
|
+
readonly meaning: "请求不符合接口契约";
|
|
18
|
+
};
|
|
19
|
+
readonly UNAUTHENTICATED: {
|
|
20
|
+
readonly httpStatus: 401;
|
|
21
|
+
readonly retryable: false;
|
|
22
|
+
readonly outcome: "not_executed";
|
|
23
|
+
readonly meaning: "未登录,或令牌无效、过期";
|
|
24
|
+
};
|
|
25
|
+
readonly FORBIDDEN: {
|
|
26
|
+
readonly httpStatus: 403;
|
|
27
|
+
readonly retryable: false;
|
|
28
|
+
readonly outcome: "not_executed";
|
|
29
|
+
readonly meaning: "已认证但无权执行";
|
|
30
|
+
};
|
|
31
|
+
readonly NOT_FOUND: {
|
|
32
|
+
readonly httpStatus: 404;
|
|
33
|
+
readonly retryable: false;
|
|
34
|
+
readonly outcome: "not_executed";
|
|
35
|
+
readonly meaning: "资源不存在,或调用方无权得知其存在";
|
|
36
|
+
};
|
|
37
|
+
readonly ROUTE_NOT_FOUND: {
|
|
38
|
+
readonly httpStatus: 404;
|
|
39
|
+
readonly retryable: false;
|
|
40
|
+
readonly outcome: "not_executed";
|
|
41
|
+
readonly meaning: "接口路径不存在";
|
|
42
|
+
};
|
|
43
|
+
readonly METHOD_NOT_ALLOWED: {
|
|
44
|
+
readonly httpStatus: 405;
|
|
45
|
+
readonly retryable: false;
|
|
46
|
+
readonly outcome: "not_executed";
|
|
47
|
+
readonly meaning: "接口不支持该 HTTP 方法";
|
|
48
|
+
};
|
|
49
|
+
readonly CONFLICT: {
|
|
50
|
+
readonly httpStatus: 409;
|
|
51
|
+
readonly retryable: false;
|
|
52
|
+
readonly outcome: "not_executed";
|
|
53
|
+
readonly meaning: "资源状态冲突";
|
|
54
|
+
};
|
|
55
|
+
readonly RATE_LIMITED: {
|
|
56
|
+
readonly httpStatus: 429;
|
|
57
|
+
readonly retryable: true;
|
|
58
|
+
readonly outcome: "not_executed";
|
|
59
|
+
readonly meaning: "请求过于频繁,可稍后重试";
|
|
60
|
+
};
|
|
61
|
+
readonly INTERNAL_ERROR: {
|
|
62
|
+
readonly httpStatus: 500;
|
|
63
|
+
readonly retryable: false;
|
|
64
|
+
readonly outcome: "unknown";
|
|
65
|
+
readonly meaning: "服务内部错误,可能已产生副作用";
|
|
66
|
+
};
|
|
67
|
+
readonly LIST_LIMIT_EXCEEDED: {
|
|
68
|
+
readonly httpStatus: 500;
|
|
69
|
+
readonly retryable: false;
|
|
70
|
+
readonly outcome: "unknown";
|
|
71
|
+
readonly meaning: "一次性列表的结果超出接口声明的上限";
|
|
72
|
+
};
|
|
73
|
+
readonly SERVICE_UNAVAILABLE: {
|
|
74
|
+
readonly httpStatus: 503;
|
|
75
|
+
readonly retryable: true;
|
|
76
|
+
readonly outcome: "unknown";
|
|
77
|
+
readonly meaning: "服务或其依赖暂不可用";
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 通用失败码(参考资源)。错误体的 code 是开放字符串,这里只列通用的一组;
|
|
83
|
+
* 各服务可以有自己的专有码,遇到不认识的码按 HTTP 状态归类处理。
|
|
84
|
+
*/
|
|
85
|
+
export declare const COMMON_ERROR_CODES: {
|
|
86
|
+
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
87
|
+
readonly UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
88
|
+
readonly FORBIDDEN: "FORBIDDEN";
|
|
89
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
90
|
+
readonly ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND";
|
|
91
|
+
readonly METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED";
|
|
92
|
+
readonly CONFLICT: "CONFLICT";
|
|
93
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
94
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
95
|
+
readonly LIST_LIMIT_EXCEEDED: "LIST_LIMIT_EXCEEDED";
|
|
96
|
+
readonly SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE";
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export declare type CommonErrorCode = (typeof COMMON_ERROR_CODES)[keyof typeof COMMON_ERROR_CODES];
|
|
100
|
+
|
|
101
|
+
/** CommonErrorCodes:common-error-codes.schema.json */
|
|
102
|
+
export declare const commonErrorCodesSchema: SchemaDocument;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 游标式列表的参考数值:maxLimit 是每批条数可参考的上限(由定义 list-reference-values.schema.json 生成)。
|
|
106
|
+
* 只是参考,不随任何结构生效;包不替使用方填写,要用须显式引用。
|
|
107
|
+
*/
|
|
108
|
+
export declare const CURSOR_LIST_REFERENCE_VALUES: {
|
|
109
|
+
readonly maxLimit: 100;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* CursorListRequest 的线上参数名(由定义 cursor-list-request.schema.json 生成)。
|
|
114
|
+
*/
|
|
115
|
+
export declare const CURSOR_LIST_REQUEST_PARAMS: {
|
|
116
|
+
readonly after: "cursor.after";
|
|
117
|
+
readonly limit: "cursor.limit";
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* CursorList 响应里各字段的路径(由定义 cursor-list.schema.json 生成)。
|
|
122
|
+
*/
|
|
123
|
+
export declare const CURSOR_LIST_RESPONSE_PATHS: {
|
|
124
|
+
readonly items: "items";
|
|
125
|
+
readonly next: "cursor.next";
|
|
126
|
+
readonly hasMore: "cursor.hasMore";
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 找出专有码清单里与 reserved 中的码重名的项。结构本身只把 OK 与 HTTP_<数字> 当保留字;
|
|
131
|
+
* 要让专有码避开某组通用码(如包里的 COMMON_ERROR_CODES,或自己的一组),把那组码传进来:
|
|
132
|
+
* 字符串的可迭代集合(数组、Set),或「名字 → 码」的对象(取值,不取键)。
|
|
133
|
+
* 按字节比较,不做大小写归一;reserved 为空就什么也不比。
|
|
134
|
+
*
|
|
135
|
+
* 用法:findReservedCodes(list, COMMON_ERROR_CODES),返回空数组即没有撞码。
|
|
136
|
+
*/
|
|
137
|
+
export declare function findReservedCodes(list: Pick<ServiceErrorCodes, "codes">, reserved: Iterable<string> | Readonly<Record<string, string>>): ReservedCodeHit[];
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* ListFilter 的线上参数名(由定义 list-filter.schema.json 生成)。
|
|
141
|
+
*/
|
|
142
|
+
export declare const LIST_FILTER_PARAMS: {
|
|
143
|
+
readonly prefix: "filter.";
|
|
144
|
+
readonly operators: {
|
|
145
|
+
readonly eq: "eq";
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** ListReferenceValues:list-reference-values.schema.json */
|
|
150
|
+
export declare const listReferenceValuesSchema: SchemaDocument;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 页码式列表的参考数值:page 是请求不带页码时可参考的页码,pageSize 是请求不带每页条数时可参考的条数,maxPageSize 是每页条数可参考的上限(由定义 list-reference-values.schema.json 生成)。
|
|
154
|
+
* 只是参考,不随任何结构生效;包不替使用方填写,要用须显式引用。
|
|
155
|
+
*/
|
|
156
|
+
export declare const PAGED_LIST_REFERENCE_VALUES: {
|
|
157
|
+
readonly page: 1;
|
|
158
|
+
readonly pageSize: 10;
|
|
159
|
+
readonly maxPageSize: 100;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* PagedListRequest 的线上参数名(由定义 paged-list-request.schema.json 生成)。
|
|
164
|
+
*/
|
|
165
|
+
export declare const PAGED_LIST_REQUEST_PARAMS: {
|
|
166
|
+
readonly page: "page.page";
|
|
167
|
+
readonly pageSize: "page.pageSize";
|
|
168
|
+
readonly query: "page.query";
|
|
169
|
+
readonly orderBy: "page.orderBy";
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* PagedList 响应里各字段的路径(由定义 paged-list.schema.json 生成)。
|
|
174
|
+
*/
|
|
175
|
+
export declare const PAGED_LIST_RESPONSE_PATHS: {
|
|
176
|
+
readonly items: "items";
|
|
177
|
+
readonly totalRecord: "page.totalRecord";
|
|
178
|
+
readonly pageSize: "page.pageSize";
|
|
179
|
+
readonly totalPage: "page.totalPage";
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** 全部参考资源定义,键为定义的 $id(即文件名)。 */
|
|
183
|
+
export declare const referenceSchemas: {
|
|
184
|
+
readonly "common-error-codes.schema.json": SchemaDocument;
|
|
185
|
+
readonly "list-reference-values.schema.json": SchemaDocument;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** 专有码清单里撞上保留码集合的一项:index 是它在 codes 里的位置。 */
|
|
189
|
+
export declare interface ReservedCodeHit {
|
|
190
|
+
index: number;
|
|
191
|
+
code: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** 一份 JSON Schema 定义文档。 */
|
|
195
|
+
declare interface SchemaDocument {
|
|
196
|
+
readonly [keyword: string]: unknown;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 一个专有码。stage 为 execute 时不得有 httpStatus 与 additionalHttpStatuses;为 accept 或 both 时必须有 httpStatus。additionalHttpStatuses 不含主状态(x-arrayExcludesProperty)。
|
|
201
|
+
*/
|
|
202
|
+
declare interface ServiceErrorCode {
|
|
203
|
+
/**
|
|
204
|
+
* 码:整体大写下划线或整体小写下划线写法,字母开头,不以下划线结尾,不含连续下划线,最长 128 个字符。
|
|
205
|
+
*/
|
|
206
|
+
code: string;
|
|
207
|
+
/**
|
|
208
|
+
* accept:受理时同步返回;execute:异步执行阶段产生;both:两者都有。
|
|
209
|
+
*/
|
|
210
|
+
stage: "accept" | "execute" | "both";
|
|
211
|
+
/**
|
|
212
|
+
* 主 HTTP 状态,4xx 或 5xx。
|
|
213
|
+
*/
|
|
214
|
+
httpStatus?: number;
|
|
215
|
+
/**
|
|
216
|
+
* 同一个码在不同情形下的其他 HTTP 状态:至少 1 项、不重复、不含主状态。
|
|
217
|
+
*
|
|
218
|
+
* @minItems 1
|
|
219
|
+
*/
|
|
220
|
+
additionalHttpStatuses?: [number, ...number[]];
|
|
221
|
+
/**
|
|
222
|
+
* 原样重试是否可能成功。
|
|
223
|
+
*/
|
|
224
|
+
retryable: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* not_executed:确定没有执行;unknown:可能已产生副作用。
|
|
227
|
+
*/
|
|
228
|
+
outcome: "not_executed" | "unknown";
|
|
229
|
+
/**
|
|
230
|
+
* 一句话含义,1–1000 个字符。
|
|
231
|
+
*/
|
|
232
|
+
meaning: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 一个服务的专有业务码清单。OK 与 HTTP_<数字> 形式的码是结构保留字,不得使用;比较按字节精确进行,不做大小写归一。专有码是否要避开某组通用码由使用方显式检查:把那组码传给参考资源出口的检查函数,不传就不比。
|
|
237
|
+
*/
|
|
238
|
+
declare interface ServiceErrorCodes {
|
|
239
|
+
/**
|
|
240
|
+
* 服务标识:小写字母开头,只含小写字母、数字、短横线,最长 64 个字符。
|
|
241
|
+
*/
|
|
242
|
+
service: string;
|
|
243
|
+
/**
|
|
244
|
+
* 专有码,至少 1 项;code 在清单内不重复(x-uniqueItemsBy)。
|
|
245
|
+
*
|
|
246
|
+
* @minItems 1
|
|
247
|
+
*/
|
|
248
|
+
codes: [ServiceErrorCode, ...ServiceErrorCode[]];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { }
|