@done-coding/schema-api 0.0.0-stage → 0.0.1-alpha.1
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 +33 -2
- package/es/index.mjs +930 -0
- package/lib/index.cjs +1 -0
- package/package.json +60 -3
- package/schemas/bounded-list.schema.json +17 -0
- package/schemas/common-error-codes.schema.json +224 -0
- package/schemas/cursor-list-request.schema.json +24 -0
- package/schemas/cursor-list.schema.json +45 -0
- package/schemas/error-body.schema.json +109 -0
- package/schemas/list-filter.schema.json +28 -0
- package/schemas/paged-list-request.schema.json +36 -0
- package/schemas/paged-list.schema.json +53 -0
- package/schemas/service-error-codes.schema.json +97 -0
- package/schemas/success-envelope.schema.json +25 -0
- package/types/index.d.ts +516 -0
package/es/index.mjs
ADDED
|
@@ -0,0 +1,930 @@
|
|
|
1
|
+
const d = {
|
|
2
|
+
OK: "OK"
|
|
3
|
+
}, u = {
|
|
4
|
+
INVALID_REQUEST: "INVALID_REQUEST",
|
|
5
|
+
UNAUTHENTICATED: "UNAUTHENTICATED",
|
|
6
|
+
FORBIDDEN: "FORBIDDEN",
|
|
7
|
+
NOT_FOUND: "NOT_FOUND",
|
|
8
|
+
ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND",
|
|
9
|
+
METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
|
|
10
|
+
CONFLICT: "CONFLICT",
|
|
11
|
+
RATE_LIMITED: "RATE_LIMITED",
|
|
12
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
13
|
+
LIST_LIMIT_EXCEEDED: "LIST_LIMIT_EXCEEDED",
|
|
14
|
+
SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE"
|
|
15
|
+
}, m = {
|
|
16
|
+
INVALID_REQUEST: {
|
|
17
|
+
httpStatus: 400,
|
|
18
|
+
retryable: !1,
|
|
19
|
+
outcome: "not_executed",
|
|
20
|
+
meaning: "请求不符合接口契约"
|
|
21
|
+
},
|
|
22
|
+
UNAUTHENTICATED: {
|
|
23
|
+
httpStatus: 401,
|
|
24
|
+
retryable: !1,
|
|
25
|
+
outcome: "not_executed",
|
|
26
|
+
meaning: "未登录,或令牌无效、过期"
|
|
27
|
+
},
|
|
28
|
+
FORBIDDEN: {
|
|
29
|
+
httpStatus: 403,
|
|
30
|
+
retryable: !1,
|
|
31
|
+
outcome: "not_executed",
|
|
32
|
+
meaning: "已认证但无权执行"
|
|
33
|
+
},
|
|
34
|
+
NOT_FOUND: {
|
|
35
|
+
httpStatus: 404,
|
|
36
|
+
retryable: !1,
|
|
37
|
+
outcome: "not_executed",
|
|
38
|
+
meaning: "资源不存在,或调用方无权得知其存在"
|
|
39
|
+
},
|
|
40
|
+
ROUTE_NOT_FOUND: {
|
|
41
|
+
httpStatus: 404,
|
|
42
|
+
retryable: !1,
|
|
43
|
+
outcome: "not_executed",
|
|
44
|
+
meaning: "接口路径不存在"
|
|
45
|
+
},
|
|
46
|
+
METHOD_NOT_ALLOWED: {
|
|
47
|
+
httpStatus: 405,
|
|
48
|
+
retryable: !1,
|
|
49
|
+
outcome: "not_executed",
|
|
50
|
+
meaning: "接口不支持该 HTTP 方法"
|
|
51
|
+
},
|
|
52
|
+
CONFLICT: {
|
|
53
|
+
httpStatus: 409,
|
|
54
|
+
retryable: !1,
|
|
55
|
+
outcome: "not_executed",
|
|
56
|
+
meaning: "资源状态冲突"
|
|
57
|
+
},
|
|
58
|
+
RATE_LIMITED: {
|
|
59
|
+
httpStatus: 429,
|
|
60
|
+
retryable: !0,
|
|
61
|
+
outcome: "not_executed",
|
|
62
|
+
meaning: "请求过于频繁,可稍后重试"
|
|
63
|
+
},
|
|
64
|
+
INTERNAL_ERROR: {
|
|
65
|
+
httpStatus: 500,
|
|
66
|
+
retryable: !1,
|
|
67
|
+
outcome: "unknown",
|
|
68
|
+
meaning: "服务内部错误,可能已产生副作用"
|
|
69
|
+
},
|
|
70
|
+
LIST_LIMIT_EXCEEDED: {
|
|
71
|
+
httpStatus: 500,
|
|
72
|
+
retryable: !1,
|
|
73
|
+
outcome: "unknown",
|
|
74
|
+
meaning: "一次性列表的结果超出接口声明的上限"
|
|
75
|
+
},
|
|
76
|
+
SERVICE_UNAVAILABLE: {
|
|
77
|
+
httpStatus: 503,
|
|
78
|
+
retryable: !0,
|
|
79
|
+
outcome: "unknown",
|
|
80
|
+
meaning: "服务或其依赖暂不可用"
|
|
81
|
+
}
|
|
82
|
+
}, l = {
|
|
83
|
+
items: "items"
|
|
84
|
+
}, h = {
|
|
85
|
+
after: "cursor.after",
|
|
86
|
+
limit: "cursor.limit"
|
|
87
|
+
}, E = {
|
|
88
|
+
items: "items",
|
|
89
|
+
next: "cursor.next",
|
|
90
|
+
hasMore: "cursor.hasMore"
|
|
91
|
+
}, f = {
|
|
92
|
+
prefix: "filter.",
|
|
93
|
+
operators: {
|
|
94
|
+
eq: "eq"
|
|
95
|
+
}
|
|
96
|
+
}, g = {
|
|
97
|
+
page: "page.page",
|
|
98
|
+
pageSize: "page.pageSize",
|
|
99
|
+
query: "page.query",
|
|
100
|
+
orderBy: "page.orderBy"
|
|
101
|
+
}, S = {
|
|
102
|
+
items: "items",
|
|
103
|
+
totalRecord: "page.totalRecord",
|
|
104
|
+
pageSize: "page.pageSize",
|
|
105
|
+
totalPage: "page.totalPage"
|
|
106
|
+
}, e = {
|
|
107
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
108
|
+
$id: "bounded-list.schema.json",
|
|
109
|
+
title: "BoundedList",
|
|
110
|
+
description: "一次性列表,作成功外壳的 data。只用于条数有一个由定义决定、不随业务数据增长的上限的结果(如下拉选项);上限由各接口在自己的契约里声明,超过上限报 LIST_LIMIT_EXCEEDED,不截断。顶层允许接口自己声明的附带字段,但不得带翻页信息。",
|
|
111
|
+
"x-pathConstants": "BOUNDED_LIST_RESPONSE_PATHS",
|
|
112
|
+
type: "object",
|
|
113
|
+
properties: {
|
|
114
|
+
items: {
|
|
115
|
+
description: "列表数据。",
|
|
116
|
+
type: "array"
|
|
117
|
+
},
|
|
118
|
+
page: !1,
|
|
119
|
+
cursor: !1
|
|
120
|
+
},
|
|
121
|
+
required: ["items"]
|
|
122
|
+
}, t = {
|
|
123
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
124
|
+
$id: "common-error-codes.schema.json",
|
|
125
|
+
title: "CommonErrorCodes",
|
|
126
|
+
description: "通用失败码表:每个码固定 HTTP 状态(x-httpStatus),并给出能否重试与是否已执行的缺省值(default)。错误体引用本表:code 是通用失败码时,服务未另行指定 error.retryable 与 error.outcome 就取表中值;服务能确定更具体的重试性或执行结局时可以覆盖,任何合法的 retryable 与 outcome 都合法。$defs/code 列出全部通用失败码,须与 allOf 各项一一对应。",
|
|
127
|
+
$defs: {
|
|
128
|
+
code: {
|
|
129
|
+
description: "通用失败码。",
|
|
130
|
+
enum: [
|
|
131
|
+
"INVALID_REQUEST",
|
|
132
|
+
"UNAUTHENTICATED",
|
|
133
|
+
"FORBIDDEN",
|
|
134
|
+
"NOT_FOUND",
|
|
135
|
+
"ROUTE_NOT_FOUND",
|
|
136
|
+
"METHOD_NOT_ALLOWED",
|
|
137
|
+
"CONFLICT",
|
|
138
|
+
"RATE_LIMITED",
|
|
139
|
+
"INTERNAL_ERROR",
|
|
140
|
+
"LIST_LIMIT_EXCEEDED",
|
|
141
|
+
"SERVICE_UNAVAILABLE"
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
allOf: [
|
|
146
|
+
{
|
|
147
|
+
description: "请求不符合接口契约",
|
|
148
|
+
"x-httpStatus": 400,
|
|
149
|
+
if: {
|
|
150
|
+
properties: {
|
|
151
|
+
code: {
|
|
152
|
+
const: "INVALID_REQUEST"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
required: ["code"]
|
|
156
|
+
},
|
|
157
|
+
then: {
|
|
158
|
+
properties: {
|
|
159
|
+
error: {
|
|
160
|
+
properties: {
|
|
161
|
+
retryable: {
|
|
162
|
+
default: !1
|
|
163
|
+
},
|
|
164
|
+
outcome: {
|
|
165
|
+
default: "not_executed"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
description: "未登录,或令牌无效、过期",
|
|
174
|
+
"x-httpStatus": 401,
|
|
175
|
+
if: {
|
|
176
|
+
properties: {
|
|
177
|
+
code: {
|
|
178
|
+
const: "UNAUTHENTICATED"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
required: ["code"]
|
|
182
|
+
},
|
|
183
|
+
then: {
|
|
184
|
+
properties: {
|
|
185
|
+
error: {
|
|
186
|
+
properties: {
|
|
187
|
+
retryable: {
|
|
188
|
+
default: !1
|
|
189
|
+
},
|
|
190
|
+
outcome: {
|
|
191
|
+
default: "not_executed"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
description: "已认证但无权执行",
|
|
200
|
+
"x-httpStatus": 403,
|
|
201
|
+
if: {
|
|
202
|
+
properties: {
|
|
203
|
+
code: {
|
|
204
|
+
const: "FORBIDDEN"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
required: ["code"]
|
|
208
|
+
},
|
|
209
|
+
then: {
|
|
210
|
+
properties: {
|
|
211
|
+
error: {
|
|
212
|
+
properties: {
|
|
213
|
+
retryable: {
|
|
214
|
+
default: !1
|
|
215
|
+
},
|
|
216
|
+
outcome: {
|
|
217
|
+
default: "not_executed"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
description: "资源不存在,或调用方无权得知其存在",
|
|
226
|
+
"x-httpStatus": 404,
|
|
227
|
+
if: {
|
|
228
|
+
properties: {
|
|
229
|
+
code: {
|
|
230
|
+
const: "NOT_FOUND"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
required: ["code"]
|
|
234
|
+
},
|
|
235
|
+
then: {
|
|
236
|
+
properties: {
|
|
237
|
+
error: {
|
|
238
|
+
properties: {
|
|
239
|
+
retryable: {
|
|
240
|
+
default: !1
|
|
241
|
+
},
|
|
242
|
+
outcome: {
|
|
243
|
+
default: "not_executed"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
description: "接口路径不存在",
|
|
252
|
+
"x-httpStatus": 404,
|
|
253
|
+
if: {
|
|
254
|
+
properties: {
|
|
255
|
+
code: {
|
|
256
|
+
const: "ROUTE_NOT_FOUND"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
required: ["code"]
|
|
260
|
+
},
|
|
261
|
+
then: {
|
|
262
|
+
properties: {
|
|
263
|
+
error: {
|
|
264
|
+
properties: {
|
|
265
|
+
retryable: {
|
|
266
|
+
default: !1
|
|
267
|
+
},
|
|
268
|
+
outcome: {
|
|
269
|
+
default: "not_executed"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
description: "接口不支持该 HTTP 方法",
|
|
278
|
+
"x-httpStatus": 405,
|
|
279
|
+
if: {
|
|
280
|
+
properties: {
|
|
281
|
+
code: {
|
|
282
|
+
const: "METHOD_NOT_ALLOWED"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
required: ["code"]
|
|
286
|
+
},
|
|
287
|
+
then: {
|
|
288
|
+
properties: {
|
|
289
|
+
error: {
|
|
290
|
+
properties: {
|
|
291
|
+
retryable: {
|
|
292
|
+
default: !1
|
|
293
|
+
},
|
|
294
|
+
outcome: {
|
|
295
|
+
default: "not_executed"
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
description: "资源状态冲突",
|
|
304
|
+
"x-httpStatus": 409,
|
|
305
|
+
if: {
|
|
306
|
+
properties: {
|
|
307
|
+
code: {
|
|
308
|
+
const: "CONFLICT"
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
required: ["code"]
|
|
312
|
+
},
|
|
313
|
+
then: {
|
|
314
|
+
properties: {
|
|
315
|
+
error: {
|
|
316
|
+
properties: {
|
|
317
|
+
retryable: {
|
|
318
|
+
default: !1
|
|
319
|
+
},
|
|
320
|
+
outcome: {
|
|
321
|
+
default: "not_executed"
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
description: "请求过于频繁,可稍后重试",
|
|
330
|
+
"x-httpStatus": 429,
|
|
331
|
+
if: {
|
|
332
|
+
properties: {
|
|
333
|
+
code: {
|
|
334
|
+
const: "RATE_LIMITED"
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
required: ["code"]
|
|
338
|
+
},
|
|
339
|
+
then: {
|
|
340
|
+
properties: {
|
|
341
|
+
error: {
|
|
342
|
+
properties: {
|
|
343
|
+
retryable: {
|
|
344
|
+
default: !0
|
|
345
|
+
},
|
|
346
|
+
outcome: {
|
|
347
|
+
default: "not_executed"
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
description: "服务内部错误,可能已产生副作用",
|
|
356
|
+
"x-httpStatus": 500,
|
|
357
|
+
if: {
|
|
358
|
+
properties: {
|
|
359
|
+
code: {
|
|
360
|
+
const: "INTERNAL_ERROR"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
required: ["code"]
|
|
364
|
+
},
|
|
365
|
+
then: {
|
|
366
|
+
properties: {
|
|
367
|
+
error: {
|
|
368
|
+
properties: {
|
|
369
|
+
retryable: {
|
|
370
|
+
default: !1
|
|
371
|
+
},
|
|
372
|
+
outcome: {
|
|
373
|
+
default: "unknown"
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
description: "一次性列表的结果超出接口声明的上限",
|
|
382
|
+
"x-httpStatus": 500,
|
|
383
|
+
if: {
|
|
384
|
+
properties: {
|
|
385
|
+
code: {
|
|
386
|
+
const: "LIST_LIMIT_EXCEEDED"
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
required: ["code"]
|
|
390
|
+
},
|
|
391
|
+
then: {
|
|
392
|
+
properties: {
|
|
393
|
+
error: {
|
|
394
|
+
properties: {
|
|
395
|
+
retryable: {
|
|
396
|
+
default: !1
|
|
397
|
+
},
|
|
398
|
+
outcome: {
|
|
399
|
+
default: "unknown"
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
description: "服务或其依赖暂不可用",
|
|
408
|
+
"x-httpStatus": 503,
|
|
409
|
+
if: {
|
|
410
|
+
properties: {
|
|
411
|
+
code: {
|
|
412
|
+
const: "SERVICE_UNAVAILABLE"
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
required: ["code"]
|
|
416
|
+
},
|
|
417
|
+
then: {
|
|
418
|
+
properties: {
|
|
419
|
+
error: {
|
|
420
|
+
properties: {
|
|
421
|
+
retryable: {
|
|
422
|
+
default: !0
|
|
423
|
+
},
|
|
424
|
+
outcome: {
|
|
425
|
+
default: "unknown"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
]
|
|
433
|
+
}, r = {
|
|
434
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
435
|
+
$id: "cursor-list-request.schema.json",
|
|
436
|
+
title: "CursorListRequest",
|
|
437
|
+
description: "游标式列表的请求参数。线上以 cursor. 前缀的查询参数传递(如 cursor.limit=20),本定义约束解码后的对象;前缀下未声明的参数不合法。",
|
|
438
|
+
"x-paramPrefix": "cursor",
|
|
439
|
+
"x-pathConstants": "CURSOR_LIST_REQUEST_PARAMS",
|
|
440
|
+
type: "object",
|
|
441
|
+
properties: {
|
|
442
|
+
after: {
|
|
443
|
+
description: "上一批返回的 next,1–1024 个字符;首批不带。",
|
|
444
|
+
type: "string",
|
|
445
|
+
minLength: 1,
|
|
446
|
+
maxLength: 1024
|
|
447
|
+
},
|
|
448
|
+
limit: {
|
|
449
|
+
description: "本批最多取多少条;缺省值由各接口自定。",
|
|
450
|
+
type: "integer",
|
|
451
|
+
minimum: 1,
|
|
452
|
+
maximum: 100
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
additionalProperties: !1
|
|
456
|
+
}, o = {
|
|
457
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
458
|
+
$id: "cursor-list.schema.json",
|
|
459
|
+
title: "CursorList",
|
|
460
|
+
description: "游标式列表,作成功外壳的 data:消息流这类接着往下取的列表,不带总数。取数方向由各接口声明。顶层允许接口自己声明的附带字段,但不得重复表达翻页信息;不带 page。",
|
|
461
|
+
"x-pathConstants": "CURSOR_LIST_RESPONSE_PATHS",
|
|
462
|
+
type: "object",
|
|
463
|
+
properties: {
|
|
464
|
+
items: {
|
|
465
|
+
description: "本批数据。",
|
|
466
|
+
type: "array"
|
|
467
|
+
},
|
|
468
|
+
cursor: {
|
|
469
|
+
$ref: "#/$defs/cursor"
|
|
470
|
+
},
|
|
471
|
+
page: !1
|
|
472
|
+
},
|
|
473
|
+
required: ["items", "cursor"],
|
|
474
|
+
$defs: {
|
|
475
|
+
cursor: {
|
|
476
|
+
title: "CursorListCursor",
|
|
477
|
+
description: "接着取的位置。hasMore 为 true 时必须给 next。",
|
|
478
|
+
type: "object",
|
|
479
|
+
properties: {
|
|
480
|
+
next: {
|
|
481
|
+
description: "下一批的游标,对调用方不透明,1–1024 个字符;没有更多时可省略。",
|
|
482
|
+
type: "string",
|
|
483
|
+
minLength: 1,
|
|
484
|
+
maxLength: 1024
|
|
485
|
+
},
|
|
486
|
+
hasMore: {
|
|
487
|
+
description: "是否还有更多。",
|
|
488
|
+
type: "boolean"
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
required: ["hasMore"],
|
|
492
|
+
additionalProperties: !1,
|
|
493
|
+
if: {
|
|
494
|
+
properties: {
|
|
495
|
+
hasMore: {
|
|
496
|
+
const: !0
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
required: ["hasMore"]
|
|
500
|
+
},
|
|
501
|
+
then: {
|
|
502
|
+
required: ["next"]
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}, s = {
|
|
507
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
508
|
+
$id: "error-body.schema.json",
|
|
509
|
+
title: "ErrorBody",
|
|
510
|
+
description: "错误体。HTTP 状态表达大类,包体带业务码、说明、能否重试、是否已执行与出错字段定位。code 是通用失败码时,retryable 与 outcome 的缺省值见通用失败码表,服务能确定更具体的情形时可以覆盖。",
|
|
511
|
+
type: "object",
|
|
512
|
+
properties: {
|
|
513
|
+
code: {
|
|
514
|
+
description: "业务码,开放字符串:字母开头,只含字母、数字、下划线,1–128 个字符;不能是 OK。使用方遇到不认识的码按 HTTP 状态归类处理。",
|
|
515
|
+
type: "string",
|
|
516
|
+
pattern: "^[A-Za-z][A-Za-z0-9_]{0,127}$",
|
|
517
|
+
not: {
|
|
518
|
+
const: "OK"
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
message: {
|
|
522
|
+
description: "说明,不能是纯空白。",
|
|
523
|
+
type: "string",
|
|
524
|
+
maxLength: 1e3,
|
|
525
|
+
pattern: "\\S"
|
|
526
|
+
},
|
|
527
|
+
data: {
|
|
528
|
+
description: "错误体恒为 null。",
|
|
529
|
+
type: "null"
|
|
530
|
+
},
|
|
531
|
+
error: {
|
|
532
|
+
$ref: "#/$defs/errorDetail"
|
|
533
|
+
},
|
|
534
|
+
requestId: {
|
|
535
|
+
description: "请求标识,1–128 个字符,不含空白字符。",
|
|
536
|
+
type: "string",
|
|
537
|
+
pattern: "^\\S{1,128}$"
|
|
538
|
+
},
|
|
539
|
+
detail: {
|
|
540
|
+
description: "补充说明,可选,不限长。",
|
|
541
|
+
type: "string"
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
required: ["code", "message", "data", "error", "requestId"],
|
|
545
|
+
additionalProperties: !1,
|
|
546
|
+
allOf: [
|
|
547
|
+
{
|
|
548
|
+
$ref: "common-error-codes.schema.json"
|
|
549
|
+
}
|
|
550
|
+
],
|
|
551
|
+
$defs: {
|
|
552
|
+
errorDetail: {
|
|
553
|
+
title: "ErrorDetail",
|
|
554
|
+
description: "错误的处置信息。",
|
|
555
|
+
type: "object",
|
|
556
|
+
properties: {
|
|
557
|
+
retryable: {
|
|
558
|
+
description: "原样重试是否可能成功。",
|
|
559
|
+
type: "boolean"
|
|
560
|
+
},
|
|
561
|
+
outcome: {
|
|
562
|
+
description: "not_executed:确定没有执行;unknown:可能已产生副作用。",
|
|
563
|
+
enum: ["not_executed", "unknown"]
|
|
564
|
+
},
|
|
565
|
+
fields: {
|
|
566
|
+
description: "逐项指出出错的输入;可以是空数组。",
|
|
567
|
+
type: "array",
|
|
568
|
+
items: {
|
|
569
|
+
$ref: "#/$defs/errorField"
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
required: ["retryable", "outcome"],
|
|
574
|
+
additionalProperties: !1
|
|
575
|
+
},
|
|
576
|
+
errorField: {
|
|
577
|
+
title: "ErrorField",
|
|
578
|
+
description: "一项出错的输入。in 为 body 时用 pointer 定位、不能有 parameter;其他位置用 parameter 定位、不能有 pointer。",
|
|
579
|
+
type: "object",
|
|
580
|
+
properties: {
|
|
581
|
+
in: {
|
|
582
|
+
description: "出错输入所在的位置。",
|
|
583
|
+
enum: ["body", "query", "path", "header", "cookie"]
|
|
584
|
+
},
|
|
585
|
+
code: {
|
|
586
|
+
description: "字段级错误码:字母开头,只含字母、数字、下划线、点、短横线,1–128 个字符。",
|
|
587
|
+
type: "string",
|
|
588
|
+
pattern: "^[A-Za-z][A-Za-z0-9_.\\-]{0,127}$"
|
|
589
|
+
},
|
|
590
|
+
message: {
|
|
591
|
+
description: "说明,不能是纯空白。",
|
|
592
|
+
type: "string",
|
|
593
|
+
maxLength: 1e3,
|
|
594
|
+
pattern: "\\S"
|
|
595
|
+
},
|
|
596
|
+
pointer: {
|
|
597
|
+
description: "请求体内的位置,RFC 6901 JSON Pointer。",
|
|
598
|
+
type: "string",
|
|
599
|
+
pattern: "^(?:(?:/(?:[^~/]|~[01])*)*/(?:(?:[^~/]|~[01])*(?:[^~/\\n]|~[01]))?)?$"
|
|
600
|
+
},
|
|
601
|
+
parameter: {
|
|
602
|
+
description: "参数名,1–256 个字符。",
|
|
603
|
+
type: "string",
|
|
604
|
+
minLength: 1,
|
|
605
|
+
maxLength: 256
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
required: ["in", "code", "message"],
|
|
609
|
+
additionalProperties: !1,
|
|
610
|
+
if: {
|
|
611
|
+
properties: {
|
|
612
|
+
in: {
|
|
613
|
+
const: "body"
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
required: ["in"]
|
|
617
|
+
},
|
|
618
|
+
then: {
|
|
619
|
+
required: ["pointer"],
|
|
620
|
+
properties: {
|
|
621
|
+
parameter: !1
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
else: {
|
|
625
|
+
required: ["parameter"],
|
|
626
|
+
properties: {
|
|
627
|
+
pointer: !1
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}, i = {
|
|
633
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
634
|
+
$id: "list-filter.schema.json",
|
|
635
|
+
title: "ListFilter",
|
|
636
|
+
description: "列表的筛选参数。线上写作 filter.<字段>.<操作>(如 filter.status.eq=active),本定义约束解码后的对象 {<字段>: {<操作>: 值}};字段为小驼峰,可筛选哪些字段由接口自己声明。首版操作只有 eq。前缀下未声明的参数不合法。",
|
|
637
|
+
"x-paramPrefix": "filter",
|
|
638
|
+
"x-pathConstants": "LIST_FILTER_PARAMS",
|
|
639
|
+
type: "object",
|
|
640
|
+
patternProperties: {
|
|
641
|
+
"^[a-z][a-zA-Z0-9]*$": {
|
|
642
|
+
$ref: "#/$defs/condition"
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
additionalProperties: !1,
|
|
646
|
+
$defs: {
|
|
647
|
+
condition: {
|
|
648
|
+
title: "ListFilterCondition",
|
|
649
|
+
description: "一个字段上的筛选条件,至少一个操作。",
|
|
650
|
+
type: "object",
|
|
651
|
+
properties: {
|
|
652
|
+
eq: {
|
|
653
|
+
description: "等于;值为标量。",
|
|
654
|
+
type: ["string", "number", "boolean"]
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
minProperties: 1,
|
|
658
|
+
additionalProperties: !1
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}, a = {
|
|
662
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
663
|
+
$id: "paged-list-request.schema.json",
|
|
664
|
+
title: "PagedListRequest",
|
|
665
|
+
description: "页码式列表的请求参数。线上以 page. 前缀的查询参数传递(如 page.pageSize=20),本定义约束解码后的对象;前缀下未声明的参数不合法。",
|
|
666
|
+
"x-paramPrefix": "page",
|
|
667
|
+
"x-pathConstants": "PAGED_LIST_REQUEST_PARAMS",
|
|
668
|
+
type: "object",
|
|
669
|
+
properties: {
|
|
670
|
+
page: {
|
|
671
|
+
description: "页码,从 1 开始。",
|
|
672
|
+
type: "integer",
|
|
673
|
+
minimum: 1,
|
|
674
|
+
default: 1
|
|
675
|
+
},
|
|
676
|
+
pageSize: {
|
|
677
|
+
description: "每页条数。",
|
|
678
|
+
type: "integer",
|
|
679
|
+
minimum: 1,
|
|
680
|
+
maximum: 100,
|
|
681
|
+
default: 10
|
|
682
|
+
},
|
|
683
|
+
query: {
|
|
684
|
+
description: "模糊搜索词,最多 200 个字符。",
|
|
685
|
+
type: "string",
|
|
686
|
+
maxLength: 200
|
|
687
|
+
},
|
|
688
|
+
orderBy: {
|
|
689
|
+
description: "排序:逗号分隔,每段是小驼峰字段名,后面可跟一个空格加 asc 或 desc(缺省 asc);逗号后可有一个空格;最多 200 个字符。",
|
|
690
|
+
type: "string",
|
|
691
|
+
maxLength: 200,
|
|
692
|
+
pattern: "^[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?(?:, ?[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?)*$"
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
additionalProperties: !1
|
|
696
|
+
}, n = {
|
|
697
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
698
|
+
$id: "paged-list.schema.json",
|
|
699
|
+
title: "PagedList",
|
|
700
|
+
description: "页码式列表,作成功外壳的 data:给人翻页的表格,能跳页、有总数。顶层允许接口自己声明的附带字段,但不得重复表达翻页信息;不带 cursor。items 的条数不超过 page.pageSize,也不超过 page.totalRecord(x-itemsWithinPage)。",
|
|
701
|
+
"x-pathConstants": "PAGED_LIST_RESPONSE_PATHS",
|
|
702
|
+
type: "object",
|
|
703
|
+
properties: {
|
|
704
|
+
items: {
|
|
705
|
+
description: "当前页的数据。",
|
|
706
|
+
type: "array"
|
|
707
|
+
},
|
|
708
|
+
page: {
|
|
709
|
+
$ref: "#/$defs/page"
|
|
710
|
+
},
|
|
711
|
+
cursor: !1
|
|
712
|
+
},
|
|
713
|
+
required: ["items", "page"],
|
|
714
|
+
"x-itemsWithinPage": !0,
|
|
715
|
+
$defs: {
|
|
716
|
+
page: {
|
|
717
|
+
title: "PagedListPage",
|
|
718
|
+
description: "翻页信息。不回传当前页码。totalPage 等于 ceil(totalRecord / pageSize),总数为 0 时为 0(x-totalPageEqualsCeil)。",
|
|
719
|
+
type: "object",
|
|
720
|
+
properties: {
|
|
721
|
+
totalRecord: {
|
|
722
|
+
description: "总条数。",
|
|
723
|
+
type: "integer",
|
|
724
|
+
minimum: 0
|
|
725
|
+
},
|
|
726
|
+
pageSize: {
|
|
727
|
+
description: "每页条数,回显请求值。",
|
|
728
|
+
type: "integer",
|
|
729
|
+
minimum: 1,
|
|
730
|
+
maximum: 100
|
|
731
|
+
},
|
|
732
|
+
totalPage: {
|
|
733
|
+
description: "总页数。",
|
|
734
|
+
type: "integer",
|
|
735
|
+
minimum: 0
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
required: ["totalRecord", "pageSize", "totalPage"],
|
|
739
|
+
additionalProperties: !1,
|
|
740
|
+
if: {
|
|
741
|
+
properties: {
|
|
742
|
+
totalRecord: {
|
|
743
|
+
const: 0
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
required: ["totalRecord"]
|
|
747
|
+
},
|
|
748
|
+
then: {
|
|
749
|
+
properties: {
|
|
750
|
+
totalPage: {
|
|
751
|
+
const: 0
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
"x-totalPageEqualsCeil": !0
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}, p = {
|
|
759
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
760
|
+
$id: "service-error-codes.schema.json",
|
|
761
|
+
title: "ServiceErrorCodes",
|
|
762
|
+
description: "一个服务的专有业务码清单。不得重新定义通用码;OK 与 HTTP_<数字> 形式的码保留,不得使用;比较按字节精确进行,不做大小写归一。",
|
|
763
|
+
type: "object",
|
|
764
|
+
properties: {
|
|
765
|
+
service: {
|
|
766
|
+
description: "服务标识:小写字母开头,只含小写字母、数字、短横线,最长 64 个字符。",
|
|
767
|
+
type: "string",
|
|
768
|
+
pattern: "^[a-z][a-z0-9\\-]{0,63}$"
|
|
769
|
+
},
|
|
770
|
+
codes: {
|
|
771
|
+
description: "专有码,至少 1 项;code 在清单内不重复(x-uniqueItemsBy)。",
|
|
772
|
+
type: "array",
|
|
773
|
+
minItems: 1,
|
|
774
|
+
items: {
|
|
775
|
+
$ref: "#/$defs/code"
|
|
776
|
+
},
|
|
777
|
+
"x-uniqueItemsBy": "code"
|
|
778
|
+
}
|
|
779
|
+
},
|
|
780
|
+
required: ["service", "codes"],
|
|
781
|
+
additionalProperties: !1,
|
|
782
|
+
$defs: {
|
|
783
|
+
code: {
|
|
784
|
+
title: "ServiceErrorCode",
|
|
785
|
+
description: "一个专有码。stage 为 execute 时不得有 httpStatus 与 additionalHttpStatuses;为 accept 或 both 时必须有 httpStatus。additionalHttpStatuses 不含主状态(x-arrayExcludesProperty)。",
|
|
786
|
+
type: "object",
|
|
787
|
+
properties: {
|
|
788
|
+
code: {
|
|
789
|
+
description: "码:整体大写下划线或整体小写下划线写法,字母开头,不以下划线结尾,不含连续下划线,最长 128 个字符。",
|
|
790
|
+
type: "string",
|
|
791
|
+
maxLength: 128,
|
|
792
|
+
pattern: "^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$",
|
|
793
|
+
allOf: [
|
|
794
|
+
{
|
|
795
|
+
not: {
|
|
796
|
+
const: "OK"
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
not: {
|
|
801
|
+
type: "string",
|
|
802
|
+
pattern: "^HTTP_[0-9]+$"
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
not: {
|
|
807
|
+
$ref: "common-error-codes.schema.json#/$defs/code"
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
]
|
|
811
|
+
},
|
|
812
|
+
stage: {
|
|
813
|
+
description: "accept:受理时同步返回;execute:异步执行阶段产生;both:两者都有。",
|
|
814
|
+
enum: ["accept", "execute", "both"]
|
|
815
|
+
},
|
|
816
|
+
httpStatus: {
|
|
817
|
+
description: "主 HTTP 状态,4xx 或 5xx。",
|
|
818
|
+
type: "integer",
|
|
819
|
+
minimum: 400,
|
|
820
|
+
maximum: 599
|
|
821
|
+
},
|
|
822
|
+
additionalHttpStatuses: {
|
|
823
|
+
description: "同一个码在不同情形下的其他 HTTP 状态:至少 1 项、不重复、不含主状态。",
|
|
824
|
+
type: "array",
|
|
825
|
+
minItems: 1,
|
|
826
|
+
uniqueItems: !0,
|
|
827
|
+
items: {
|
|
828
|
+
type: "integer",
|
|
829
|
+
minimum: 400,
|
|
830
|
+
maximum: 599
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
retryable: {
|
|
834
|
+
description: "原样重试是否可能成功。",
|
|
835
|
+
type: "boolean"
|
|
836
|
+
},
|
|
837
|
+
outcome: {
|
|
838
|
+
description: "not_executed:确定没有执行;unknown:可能已产生副作用。",
|
|
839
|
+
enum: ["not_executed", "unknown"]
|
|
840
|
+
},
|
|
841
|
+
meaning: {
|
|
842
|
+
description: "一句话含义,1–1000 个字符。",
|
|
843
|
+
type: "string",
|
|
844
|
+
minLength: 1,
|
|
845
|
+
maxLength: 1e3
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
required: ["code", "stage", "retryable", "outcome", "meaning"],
|
|
849
|
+
additionalProperties: !1,
|
|
850
|
+
if: {
|
|
851
|
+
properties: {
|
|
852
|
+
stage: {
|
|
853
|
+
const: "execute"
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
required: ["stage"]
|
|
857
|
+
},
|
|
858
|
+
then: {
|
|
859
|
+
properties: {
|
|
860
|
+
httpStatus: !1,
|
|
861
|
+
additionalHttpStatuses: !1
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
else: {
|
|
865
|
+
required: ["httpStatus"]
|
|
866
|
+
},
|
|
867
|
+
"x-arrayExcludesProperty": {
|
|
868
|
+
array: "additionalHttpStatuses",
|
|
869
|
+
property: "httpStatus"
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}, c = {
|
|
874
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
875
|
+
$id: "success-envelope.schema.json",
|
|
876
|
+
title: "SuccessEnvelope",
|
|
877
|
+
description: "成功外壳。成功与否、新建还是已受理以 HTTP 状态码为准,code 不随 200 / 201 / 202 变化。",
|
|
878
|
+
type: "object",
|
|
879
|
+
properties: {
|
|
880
|
+
code: {
|
|
881
|
+
description: "成功码,恒为 OK。",
|
|
882
|
+
const: "OK"
|
|
883
|
+
},
|
|
884
|
+
message: {
|
|
885
|
+
description: "说明,可以为空串。",
|
|
886
|
+
type: "string",
|
|
887
|
+
maxLength: 1e3
|
|
888
|
+
},
|
|
889
|
+
data: {
|
|
890
|
+
description: '结果对象或 null;标量结果也包成对象(如 {"count": 3})。',
|
|
891
|
+
type: ["object", "null"],
|
|
892
|
+
additionalProperties: !0
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
required: ["code", "message", "data"],
|
|
896
|
+
additionalProperties: !1
|
|
897
|
+
}, _ = {
|
|
898
|
+
"bounded-list.schema.json": e,
|
|
899
|
+
"common-error-codes.schema.json": t,
|
|
900
|
+
"cursor-list-request.schema.json": r,
|
|
901
|
+
"cursor-list.schema.json": o,
|
|
902
|
+
"error-body.schema.json": s,
|
|
903
|
+
"list-filter.schema.json": i,
|
|
904
|
+
"paged-list-request.schema.json": a,
|
|
905
|
+
"paged-list.schema.json": n,
|
|
906
|
+
"service-error-codes.schema.json": p,
|
|
907
|
+
"success-envelope.schema.json": c
|
|
908
|
+
};
|
|
909
|
+
export {
|
|
910
|
+
l as BOUNDED_LIST_RESPONSE_PATHS,
|
|
911
|
+
u as COMMON_ERROR_CODES,
|
|
912
|
+
m as COMMON_ERROR_CODE_TABLE,
|
|
913
|
+
h as CURSOR_LIST_REQUEST_PARAMS,
|
|
914
|
+
E as CURSOR_LIST_RESPONSE_PATHS,
|
|
915
|
+
f as LIST_FILTER_PARAMS,
|
|
916
|
+
g as PAGED_LIST_REQUEST_PARAMS,
|
|
917
|
+
S as PAGED_LIST_RESPONSE_PATHS,
|
|
918
|
+
d as SUCCESS_CODES,
|
|
919
|
+
e as boundedListSchema,
|
|
920
|
+
t as commonErrorCodesSchema,
|
|
921
|
+
r as cursorListRequestSchema,
|
|
922
|
+
o as cursorListSchema,
|
|
923
|
+
s as errorBodySchema,
|
|
924
|
+
i as listFilterSchema,
|
|
925
|
+
a as pagedListRequestSchema,
|
|
926
|
+
n as pagedListSchema,
|
|
927
|
+
_ as schemas,
|
|
928
|
+
p as serviceErrorCodesSchema,
|
|
929
|
+
c as successEnvelopeSchema
|
|
930
|
+
};
|