@done-coding/schema-api 0.0.1-alpha.0 → 0.0.1-alpha.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.
@@ -0,0 +1,469 @@
1
+ const n = {
2
+ INVALID_REQUEST: "INVALID_REQUEST",
3
+ UNAUTHENTICATED: "UNAUTHENTICATED",
4
+ FORBIDDEN: "FORBIDDEN",
5
+ NOT_FOUND: "NOT_FOUND",
6
+ ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND",
7
+ METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
8
+ CONFLICT: "CONFLICT",
9
+ RATE_LIMITED: "RATE_LIMITED",
10
+ INTERNAL_ERROR: "INTERNAL_ERROR",
11
+ LIST_LIMIT_EXCEEDED: "LIST_LIMIT_EXCEEDED",
12
+ SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE"
13
+ }, E = {
14
+ INVALID_REQUEST: {
15
+ httpStatus: 400,
16
+ retryable: !1,
17
+ outcome: "not_executed",
18
+ meaning: "请求不符合接口契约"
19
+ },
20
+ UNAUTHENTICATED: {
21
+ httpStatus: 401,
22
+ retryable: !1,
23
+ outcome: "not_executed",
24
+ meaning: "未登录,或令牌无效、过期"
25
+ },
26
+ FORBIDDEN: {
27
+ httpStatus: 403,
28
+ retryable: !1,
29
+ outcome: "not_executed",
30
+ meaning: "已认证但无权执行"
31
+ },
32
+ NOT_FOUND: {
33
+ httpStatus: 404,
34
+ retryable: !1,
35
+ outcome: "not_executed",
36
+ meaning: "资源不存在,或调用方无权得知其存在"
37
+ },
38
+ ROUTE_NOT_FOUND: {
39
+ httpStatus: 404,
40
+ retryable: !1,
41
+ outcome: "not_executed",
42
+ meaning: "接口路径不存在"
43
+ },
44
+ METHOD_NOT_ALLOWED: {
45
+ httpStatus: 405,
46
+ retryable: !1,
47
+ outcome: "not_executed",
48
+ meaning: "接口不支持该 HTTP 方法"
49
+ },
50
+ CONFLICT: {
51
+ httpStatus: 409,
52
+ retryable: !1,
53
+ outcome: "not_executed",
54
+ meaning: "资源状态冲突"
55
+ },
56
+ RATE_LIMITED: {
57
+ httpStatus: 429,
58
+ retryable: !0,
59
+ outcome: "not_executed",
60
+ meaning: "请求过于频繁,可稍后重试"
61
+ },
62
+ INTERNAL_ERROR: {
63
+ httpStatus: 500,
64
+ retryable: !1,
65
+ outcome: "unknown",
66
+ meaning: "服务内部错误,可能已产生副作用"
67
+ },
68
+ LIST_LIMIT_EXCEEDED: {
69
+ httpStatus: 500,
70
+ retryable: !1,
71
+ outcome: "unknown",
72
+ meaning: "一次性列表的结果超出接口声明的上限"
73
+ },
74
+ SERVICE_UNAVAILABLE: {
75
+ httpStatus: 503,
76
+ retryable: !0,
77
+ outcome: "unknown",
78
+ meaning: "服务或其依赖暂不可用"
79
+ }
80
+ }, i = {
81
+ items: "items"
82
+ }, p = {
83
+ after: "cursor.after",
84
+ limit: "cursor.limit"
85
+ }, u = {
86
+ items: "items",
87
+ next: "cursor.next",
88
+ hasMore: "cursor.hasMore"
89
+ }, _ = {
90
+ prefix: "filter.",
91
+ operators: {
92
+ eq: "eq"
93
+ }
94
+ }, T = {
95
+ page: "page.page",
96
+ pageSize: "page.pageSize",
97
+ query: "page.query",
98
+ orderBy: "page.orderBy"
99
+ }, l = {
100
+ items: "items",
101
+ totalRecord: "page.totalRecord",
102
+ pageSize: "page.pageSize",
103
+ totalPage: "page.totalPage"
104
+ }, S = {
105
+ page: 1,
106
+ pageSize: 10,
107
+ maxPageSize: 100
108
+ }, d = {
109
+ maxLimit: 100
110
+ }, a = {
111
+ $schema: "https://json-schema.org/draft/2020-12/schema",
112
+ $id: "common-error-codes.schema.json",
113
+ title: "CommonErrorCodes",
114
+ description: "通用失败码表(参考资源):每个码给出 HTTP 状态(x-httpStatus),以及能否重试与是否已执行的参考值(x-referenceValue)。本表不约束任何结构:错误体不引用它,包不替使用方填写;使用方可显式引用表中值。$defs/code 列出全部通用失败码,须与 allOf 各项一一对应。",
115
+ "x-referenceResource": !0,
116
+ $defs: {
117
+ code: {
118
+ description: "通用失败码。",
119
+ enum: [
120
+ "INVALID_REQUEST",
121
+ "UNAUTHENTICATED",
122
+ "FORBIDDEN",
123
+ "NOT_FOUND",
124
+ "ROUTE_NOT_FOUND",
125
+ "METHOD_NOT_ALLOWED",
126
+ "CONFLICT",
127
+ "RATE_LIMITED",
128
+ "INTERNAL_ERROR",
129
+ "LIST_LIMIT_EXCEEDED",
130
+ "SERVICE_UNAVAILABLE"
131
+ ]
132
+ }
133
+ },
134
+ allOf: [
135
+ {
136
+ description: "请求不符合接口契约",
137
+ "x-httpStatus": 400,
138
+ if: {
139
+ properties: {
140
+ code: {
141
+ const: "INVALID_REQUEST"
142
+ }
143
+ },
144
+ required: ["code"]
145
+ },
146
+ then: {
147
+ properties: {
148
+ error: {
149
+ properties: {
150
+ retryable: {
151
+ "x-referenceValue": !1
152
+ },
153
+ outcome: {
154
+ "x-referenceValue": "not_executed"
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ },
161
+ {
162
+ description: "未登录,或令牌无效、过期",
163
+ "x-httpStatus": 401,
164
+ if: {
165
+ properties: {
166
+ code: {
167
+ const: "UNAUTHENTICATED"
168
+ }
169
+ },
170
+ required: ["code"]
171
+ },
172
+ then: {
173
+ properties: {
174
+ error: {
175
+ properties: {
176
+ retryable: {
177
+ "x-referenceValue": !1
178
+ },
179
+ outcome: {
180
+ "x-referenceValue": "not_executed"
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ },
187
+ {
188
+ description: "已认证但无权执行",
189
+ "x-httpStatus": 403,
190
+ if: {
191
+ properties: {
192
+ code: {
193
+ const: "FORBIDDEN"
194
+ }
195
+ },
196
+ required: ["code"]
197
+ },
198
+ then: {
199
+ properties: {
200
+ error: {
201
+ properties: {
202
+ retryable: {
203
+ "x-referenceValue": !1
204
+ },
205
+ outcome: {
206
+ "x-referenceValue": "not_executed"
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ },
213
+ {
214
+ description: "资源不存在,或调用方无权得知其存在",
215
+ "x-httpStatus": 404,
216
+ if: {
217
+ properties: {
218
+ code: {
219
+ const: "NOT_FOUND"
220
+ }
221
+ },
222
+ required: ["code"]
223
+ },
224
+ then: {
225
+ properties: {
226
+ error: {
227
+ properties: {
228
+ retryable: {
229
+ "x-referenceValue": !1
230
+ },
231
+ outcome: {
232
+ "x-referenceValue": "not_executed"
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+ },
239
+ {
240
+ description: "接口路径不存在",
241
+ "x-httpStatus": 404,
242
+ if: {
243
+ properties: {
244
+ code: {
245
+ const: "ROUTE_NOT_FOUND"
246
+ }
247
+ },
248
+ required: ["code"]
249
+ },
250
+ then: {
251
+ properties: {
252
+ error: {
253
+ properties: {
254
+ retryable: {
255
+ "x-referenceValue": !1
256
+ },
257
+ outcome: {
258
+ "x-referenceValue": "not_executed"
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ },
265
+ {
266
+ description: "接口不支持该 HTTP 方法",
267
+ "x-httpStatus": 405,
268
+ if: {
269
+ properties: {
270
+ code: {
271
+ const: "METHOD_NOT_ALLOWED"
272
+ }
273
+ },
274
+ required: ["code"]
275
+ },
276
+ then: {
277
+ properties: {
278
+ error: {
279
+ properties: {
280
+ retryable: {
281
+ "x-referenceValue": !1
282
+ },
283
+ outcome: {
284
+ "x-referenceValue": "not_executed"
285
+ }
286
+ }
287
+ }
288
+ }
289
+ }
290
+ },
291
+ {
292
+ description: "资源状态冲突",
293
+ "x-httpStatus": 409,
294
+ if: {
295
+ properties: {
296
+ code: {
297
+ const: "CONFLICT"
298
+ }
299
+ },
300
+ required: ["code"]
301
+ },
302
+ then: {
303
+ properties: {
304
+ error: {
305
+ properties: {
306
+ retryable: {
307
+ "x-referenceValue": !1
308
+ },
309
+ outcome: {
310
+ "x-referenceValue": "not_executed"
311
+ }
312
+ }
313
+ }
314
+ }
315
+ }
316
+ },
317
+ {
318
+ description: "请求过于频繁,可稍后重试",
319
+ "x-httpStatus": 429,
320
+ if: {
321
+ properties: {
322
+ code: {
323
+ const: "RATE_LIMITED"
324
+ }
325
+ },
326
+ required: ["code"]
327
+ },
328
+ then: {
329
+ properties: {
330
+ error: {
331
+ properties: {
332
+ retryable: {
333
+ "x-referenceValue": !0
334
+ },
335
+ outcome: {
336
+ "x-referenceValue": "not_executed"
337
+ }
338
+ }
339
+ }
340
+ }
341
+ }
342
+ },
343
+ {
344
+ description: "服务内部错误,可能已产生副作用",
345
+ "x-httpStatus": 500,
346
+ if: {
347
+ properties: {
348
+ code: {
349
+ const: "INTERNAL_ERROR"
350
+ }
351
+ },
352
+ required: ["code"]
353
+ },
354
+ then: {
355
+ properties: {
356
+ error: {
357
+ properties: {
358
+ retryable: {
359
+ "x-referenceValue": !1
360
+ },
361
+ outcome: {
362
+ "x-referenceValue": "unknown"
363
+ }
364
+ }
365
+ }
366
+ }
367
+ }
368
+ },
369
+ {
370
+ description: "一次性列表的结果超出接口声明的上限",
371
+ "x-httpStatus": 500,
372
+ if: {
373
+ properties: {
374
+ code: {
375
+ const: "LIST_LIMIT_EXCEEDED"
376
+ }
377
+ },
378
+ required: ["code"]
379
+ },
380
+ then: {
381
+ properties: {
382
+ error: {
383
+ properties: {
384
+ retryable: {
385
+ "x-referenceValue": !1
386
+ },
387
+ outcome: {
388
+ "x-referenceValue": "unknown"
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }
394
+ },
395
+ {
396
+ description: "服务或其依赖暂不可用",
397
+ "x-httpStatus": 503,
398
+ if: {
399
+ properties: {
400
+ code: {
401
+ const: "SERVICE_UNAVAILABLE"
402
+ }
403
+ },
404
+ required: ["code"]
405
+ },
406
+ then: {
407
+ properties: {
408
+ error: {
409
+ properties: {
410
+ retryable: {
411
+ "x-referenceValue": !0
412
+ },
413
+ outcome: {
414
+ "x-referenceValue": "unknown"
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+ }
421
+ ]
422
+ }, c = {
423
+ $schema: "https://json-schema.org/draft/2020-12/schema",
424
+ $id: "list-reference-values.schema.json",
425
+ title: "ListReferenceValues",
426
+ description: "列表的参考数值(参考资源):只是参考,不约束任何结构。结构定义里页码、每页条数、每批条数都没有默认值和上限,包不替使用方填写;要用这些数值须在自己的代码里显式引用,或声明自己的值。",
427
+ "x-referenceResource": !0,
428
+ "x-referenceValues": {
429
+ PAGED_LIST_REFERENCE_VALUES: {
430
+ description: "页码式列表的参考数值:page 是请求不带页码时可参考的页码,pageSize 是请求不带每页条数时可参考的条数,maxPageSize 是每页条数可参考的上限。",
431
+ value: {
432
+ page: 1,
433
+ pageSize: 10,
434
+ maxPageSize: 100
435
+ }
436
+ },
437
+ CURSOR_LIST_REFERENCE_VALUES: {
438
+ description: "游标式列表的参考数值:maxLimit 是每批条数可参考的上限。",
439
+ value: {
440
+ maxLimit: 100
441
+ }
442
+ }
443
+ }
444
+ }, R = {
445
+ "common-error-codes.schema.json": a,
446
+ "list-reference-values.schema.json": c
447
+ };
448
+ function I(t, r) {
449
+ const o = new Set(r);
450
+ return t.codes.flatMap(
451
+ ({ code: e }, s) => o.has(e) ? [{ index: s, code: e }] : []
452
+ );
453
+ }
454
+ export {
455
+ i as BOUNDED_LIST_RESPONSE_PATHS,
456
+ n as COMMON_ERROR_CODES,
457
+ E as COMMON_ERROR_CODE_TABLE,
458
+ d as CURSOR_LIST_REFERENCE_VALUES,
459
+ p as CURSOR_LIST_REQUEST_PARAMS,
460
+ u as CURSOR_LIST_RESPONSE_PATHS,
461
+ _ as LIST_FILTER_PARAMS,
462
+ S as PAGED_LIST_REFERENCE_VALUES,
463
+ T as PAGED_LIST_REQUEST_PARAMS,
464
+ l as PAGED_LIST_RESPONSE_PATHS,
465
+ a as commonErrorCodesSchema,
466
+ I as findReservedCodes,
467
+ c as listReferenceValuesSchema,
468
+ R as referenceSchemas
469
+ };
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d={OK:"OK"},m={INVALID_REQUEST:"INVALID_REQUEST",UNAUTHENTICATED:"UNAUTHENTICATED",FORBIDDEN:"FORBIDDEN",NOT_FOUND:"NOT_FOUND",ROUTE_NOT_FOUND:"ROUTE_NOT_FOUND",METHOD_NOT_ALLOWED:"METHOD_NOT_ALLOWED",CONFLICT:"CONFLICT",RATE_LIMITED:"RATE_LIMITED",INTERNAL_ERROR:"INTERNAL_ERROR",LIST_LIMIT_EXCEEDED:"LIST_LIMIT_EXCEEDED",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE"},u={INVALID_REQUEST:{httpStatus:400,retryable:!1,outcome:"not_executed",meaning:"请求不符合接口契约"},UNAUTHENTICATED:{httpStatus:401,retryable:!1,outcome:"not_executed",meaning:"未登录,或令牌无效、过期"},FORBIDDEN:{httpStatus:403,retryable:!1,outcome:"not_executed",meaning:"已认证但无权执行"},NOT_FOUND:{httpStatus:404,retryable:!1,outcome:"not_executed",meaning:"资源不存在,或调用方无权得知其存在"},ROUTE_NOT_FOUND:{httpStatus:404,retryable:!1,outcome:"not_executed",meaning:"接口路径不存在"},METHOD_NOT_ALLOWED:{httpStatus:405,retryable:!1,outcome:"not_executed",meaning:"接口不支持该 HTTP 方法"},CONFLICT:{httpStatus:409,retryable:!1,outcome:"not_executed",meaning:"资源状态冲突"},RATE_LIMITED:{httpStatus:429,retryable:!0,outcome:"not_executed",meaning:"请求过于频繁,可稍后重试"},INTERNAL_ERROR:{httpStatus:500,retryable:!1,outcome:"unknown",meaning:"服务内部错误,可能已产生副作用"},LIST_LIMIT_EXCEEDED:{httpStatus:500,retryable:!1,outcome:"unknown",meaning:"一次性列表的结果超出接口声明的上限"},SERVICE_UNAVAILABLE:{httpStatus:503,retryable:!0,outcome:"unknown",meaning:"服务或其依赖暂不可用"}},l={items:"items"},E={after:"cursor.after",limit:"cursor.limit"},S={items:"items",next:"cursor.next",hasMore:"cursor.hasMore"},h={prefix:"filter.",operators:{eq:"eq"}},_={page:"page.page",pageSize:"page.pageSize",query:"page.query",orderBy:"page.orderBy"},T={items:"items",totalRecord:"page.totalRecord",pageSize:"page.pageSize",totalPage:"page.totalPage"},e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"bounded-list.schema.json",title:"BoundedList",description:"一次性列表,作成功外壳的 data。只用于条数有一个由定义决定、不随业务数据增长的上限的结果(如下拉选项);上限由各接口在自己的契约里声明,超过上限报 LIST_LIMIT_EXCEEDED,不截断。顶层允许接口自己声明的附带字段,但不得带翻页信息。","x-pathConstants":"BOUNDED_LIST_RESPONSE_PATHS",type:"object",properties:{items:{description:"列表数据。",type:"array"},page:!1,cursor:!1},required:["items"]},t={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"common-error-codes.schema.json",title:"CommonErrorCodes",description:"通用失败码表:每个码固定 HTTP 状态(x-httpStatus)、能否重试与是否已执行。作为约束使用时(错误体引用它):code 是通用失败码时,error.retryable 与 error.outcome 必须与本表一致。$defs/code 列出全部通用失败码,须与 allOf 各项一一对应。",$defs:{code:{description:"通用失败码。",enum:["INVALID_REQUEST","UNAUTHENTICATED","FORBIDDEN","NOT_FOUND","ROUTE_NOT_FOUND","METHOD_NOT_ALLOWED","CONFLICT","RATE_LIMITED","INTERNAL_ERROR","LIST_LIMIT_EXCEEDED","SERVICE_UNAVAILABLE"]}},allOf:[{description:"请求不符合接口契约","x-httpStatus":400,if:{properties:{code:{const:"INVALID_REQUEST"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"未登录,或令牌无效、过期","x-httpStatus":401,if:{properties:{code:{const:"UNAUTHENTICATED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"已认证但无权执行","x-httpStatus":403,if:{properties:{code:{const:"FORBIDDEN"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"资源不存在,或调用方无权得知其存在","x-httpStatus":404,if:{properties:{code:{const:"NOT_FOUND"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"接口路径不存在","x-httpStatus":404,if:{properties:{code:{const:"ROUTE_NOT_FOUND"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"接口不支持该 HTTP 方法","x-httpStatus":405,if:{properties:{code:{const:"METHOD_NOT_ALLOWED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"资源状态冲突","x-httpStatus":409,if:{properties:{code:{const:"CONFLICT"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"not_executed"}}}}}},{description:"请求过于频繁,可稍后重试","x-httpStatus":429,if:{properties:{code:{const:"RATE_LIMITED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!0},outcome:{const:"not_executed"}}}}}},{description:"服务内部错误,可能已产生副作用","x-httpStatus":500,if:{properties:{code:{const:"INTERNAL_ERROR"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"unknown"}}}}}},{description:"一次性列表的结果超出接口声明的上限","x-httpStatus":500,if:{properties:{code:{const:"LIST_LIMIT_EXCEEDED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!1},outcome:{const:"unknown"}}}}}},{description:"服务或其依赖暂不可用","x-httpStatus":503,if:{properties:{code:{const:"SERVICE_UNAVAILABLE"}},required:["code"]},then:{properties:{error:{properties:{retryable:{const:!0},outcome:{const:"unknown"}}}}}}]},r={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"cursor-list-request.schema.json",title:"CursorListRequest",description:"游标式列表的请求参数。线上以 cursor. 前缀的查询参数传递(如 cursor.limit=20),本定义约束解码后的对象;前缀下未声明的参数不合法。","x-paramPrefix":"cursor","x-pathConstants":"CURSOR_LIST_REQUEST_PARAMS",type:"object",properties:{after:{description:"上一批返回的 next,1–1024 个字符;首批不带。",type:"string",minLength:1,maxLength:1024},limit:{description:"本批最多取多少条;缺省值由各接口自定。",type:"integer",minimum:1,maximum:100}},additionalProperties:!1},o={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"cursor-list.schema.json",title:"CursorList",description:"游标式列表,作成功外壳的 data:消息流这类接着往下取的列表,不带总数。取数方向由各接口声明。顶层允许接口自己声明的附带字段,但不得重复表达翻页信息;不带 page。","x-pathConstants":"CURSOR_LIST_RESPONSE_PATHS",type:"object",properties:{items:{description:"本批数据。",type:"array"},cursor:{$ref:"#/$defs/cursor"},page:!1},required:["items","cursor"],$defs:{cursor:{title:"CursorListCursor",description:"接着取的位置。hasMore 为 true 时必须给 next。",type:"object",properties:{next:{description:"下一批的游标,对调用方不透明,1–1024 个字符;没有更多时可省略。",type:"string",minLength:1,maxLength:1024},hasMore:{description:"是否还有更多。",type:"boolean"}},required:["hasMore"],additionalProperties:!1,if:{properties:{hasMore:{const:!0}},required:["hasMore"]},then:{required:["next"]}}}},s={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"error-body.schema.json",title:"ErrorBody",description:"错误体。HTTP 状态表达大类,包体带业务码、说明、能否重试、是否已执行与出错字段定位。code 是通用失败码时,retryable 与 outcome 必须与通用失败码表一致。",type:"object",properties:{code:{description:"业务码,开放字符串:字母开头,只含字母、数字、下划线,1–128 个字符;不能是 OK。使用方遇到不认识的码按 HTTP 状态归类处理。",type:"string",pattern:"^[A-Za-z][A-Za-z0-9_]{0,127}$",not:{const:"OK"}},message:{description:"说明,不能是纯空白。",type:"string",maxLength:1e3,pattern:"\\S"},data:{description:"错误体恒为 null。",type:"null"},error:{$ref:"#/$defs/errorDetail"},requestId:{description:"请求标识,1–128 个字符,不含空白字符。",type:"string",pattern:"^\\S{1,128}$"},detail:{description:"补充说明,可选,不限长。",type:"string"}},required:["code","message","data","error","requestId"],additionalProperties:!1,allOf:[{$ref:"common-error-codes.schema.json"}],$defs:{errorDetail:{title:"ErrorDetail",description:"错误的处置信息。",type:"object",properties:{retryable:{description:"原样重试是否可能成功。",type:"boolean"},outcome:{description:"not_executed:确定没有执行;unknown:可能已产生副作用。",enum:["not_executed","unknown"]},fields:{description:"逐项指出出错的输入;可以是空数组。",type:"array",items:{$ref:"#/$defs/errorField"}}},required:["retryable","outcome"],additionalProperties:!1},errorField:{title:"ErrorField",description:"一项出错的输入。in 为 body 时用 pointer 定位、不能有 parameter;其他位置用 parameter 定位、不能有 pointer。",type:"object",properties:{in:{description:"出错输入所在的位置。",enum:["body","query","path","header","cookie"]},code:{description:"字段级错误码:字母开头,只含字母、数字、下划线、点、短横线,1–128 个字符。",type:"string",pattern:"^[A-Za-z][A-Za-z0-9_.\\-]{0,127}$"},message:{description:"说明,不能是纯空白。",type:"string",maxLength:1e3,pattern:"\\S"},pointer:{description:"请求体内的位置,RFC 6901 JSON Pointer。",type:"string",pattern:"^(?:(?:/(?:[^~/]|~[01])*)*/(?:(?:[^~/]|~[01])*(?:[^~/\\n]|~[01]))?)?$"},parameter:{description:"参数名,1–256 个字符。",type:"string",minLength:1,maxLength:256}},required:["in","code","message"],additionalProperties:!1,if:{properties:{in:{const:"body"}},required:["in"]},then:{required:["pointer"],properties:{parameter:!1}},else:{required:["parameter"],properties:{pointer:!1}}}}},i={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"list-filter.schema.json",title:"ListFilter",description:"列表的筛选参数。线上写作 filter.<字段>.<操作>(如 filter.status.eq=active),本定义约束解码后的对象 {<字段>: {<操作>: 值}};字段为小驼峰,可筛选哪些字段由接口自己声明。首版操作只有 eq。前缀下未声明的参数不合法。","x-paramPrefix":"filter","x-pathConstants":"LIST_FILTER_PARAMS",type:"object",patternProperties:{"^[a-z][a-zA-Z0-9]*$":{$ref:"#/$defs/condition"}},additionalProperties:!1,$defs:{condition:{title:"ListFilterCondition",description:"一个字段上的筛选条件,至少一个操作。",type:"object",properties:{eq:{description:"等于;值为标量。",type:["string","number","boolean"]}},minProperties:1,additionalProperties:!1}}},a={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"paged-list-request.schema.json",title:"PagedListRequest",description:"页码式列表的请求参数。线上以 page. 前缀的查询参数传递(如 page.pageSize=20),本定义约束解码后的对象;前缀下未声明的参数不合法。","x-paramPrefix":"page","x-pathConstants":"PAGED_LIST_REQUEST_PARAMS",type:"object",properties:{page:{description:"页码,从 1 开始。",type:"integer",minimum:1,default:1},pageSize:{description:"每页条数。",type:"integer",minimum:1,maximum:100,default:10},query:{description:"模糊搜索词,最多 200 个字符。",type:"string",maxLength:200},orderBy:{description:"排序:逗号分隔,每段是小驼峰字段名,后面可跟一个空格加 asc 或 desc(缺省 asc);逗号后可有一个空格;最多 200 个字符。",type:"string",maxLength:200,pattern:"^[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?(?:, ?[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?)*$"}},additionalProperties:!1},n={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"paged-list.schema.json",title:"PagedList",description:"页码式列表,作成功外壳的 data:给人翻页的表格,能跳页、有总数。顶层允许接口自己声明的附带字段,但不得重复表达翻页信息;不带 cursor。","x-pathConstants":"PAGED_LIST_RESPONSE_PATHS",type:"object",properties:{items:{description:"当前页的数据。",type:"array"},page:{$ref:"#/$defs/page"},cursor:!1},required:["items","page"],$defs:{page:{title:"PagedListPage",description:"翻页信息。不回传当前页码。totalPage 等于 ceil(totalRecord / pageSize),总数为 0 时为 0(x-totalPageEqualsCeil)。",type:"object",properties:{totalRecord:{description:"总条数。",type:"integer",minimum:0},pageSize:{description:"每页条数,回显请求值。",type:"integer",minimum:1,maximum:100},totalPage:{description:"总页数。",type:"integer",minimum:0}},required:["totalRecord","pageSize","totalPage"],additionalProperties:!1,if:{properties:{totalRecord:{const:0}},required:["totalRecord"]},then:{properties:{totalPage:{const:0}}},"x-totalPageEqualsCeil":!0}}},c={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"service-error-codes.schema.json",title:"ServiceErrorCodes",description:"一个服务的专有业务码清单。不得重新定义通用码;OK 与 HTTP_<数字> 形式的码保留,不得使用;比较按字节精确进行,不做大小写归一。",type:"object",properties:{service:{description:"服务标识:小写字母开头,只含小写字母、数字、短横线,最长 64 个字符。",type:"string",pattern:"^[a-z][a-z0-9\\-]{0,63}$"},codes:{description:"专有码,至少 1 项;code 在清单内不重复(x-uniqueItemsBy)。",type:"array",minItems:1,items:{$ref:"#/$defs/code"},"x-uniqueItemsBy":"code"}},required:["service","codes"],additionalProperties:!1,$defs:{code:{title:"ServiceErrorCode",description:"一个专有码。stage 为 execute 时不得有 httpStatus 与 additionalHttpStatuses;为 accept 或 both 时必须有 httpStatus。additionalHttpStatuses 不含主状态(x-arrayExcludesProperty)。",type:"object",properties:{code:{description:"码:整体大写下划线或整体小写下划线写法,字母开头,不以下划线结尾,不含连续下划线,最长 128 个字符。",type:"string",maxLength:128,pattern:"^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$",allOf:[{not:{const:"OK"}},{not:{type:"string",pattern:"^HTTP_[0-9]+$"}},{not:{$ref:"common-error-codes.schema.json#/$defs/code"}}]},stage:{description:"accept:受理时同步返回;execute:异步执行阶段产生;both:两者都有。",enum:["accept","execute","both"]},httpStatus:{description:"主 HTTP 状态,4xx 或 5xx。",type:"integer",minimum:400,maximum:599},additionalHttpStatuses:{description:"同一个码在不同情形下的其他 HTTP 状态:至少 1 项、不重复、不含主状态。",type:"array",minItems:1,uniqueItems:!0,items:{type:"integer",minimum:400,maximum:599}},retryable:{description:"原样重试是否可能成功。",type:"boolean"},outcome:{description:"not_executed:确定没有执行;unknown:可能已产生副作用。",enum:["not_executed","unknown"]},meaning:{description:"一句话含义,1–1000 个字符。",type:"string",minLength:1,maxLength:1e3}},required:["code","stage","retryable","outcome","meaning"],additionalProperties:!1,if:{properties:{stage:{const:"execute"}},required:["stage"]},then:{properties:{httpStatus:!1,additionalHttpStatuses:!1}},else:{required:["httpStatus"]},"x-arrayExcludesProperty":{array:"additionalHttpStatuses",property:"httpStatus"}}}},p={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"success-envelope.schema.json",title:"SuccessEnvelope",description:"成功外壳。成功与否、新建还是已受理以 HTTP 状态码为准,code 不随 200 / 201 / 202 变化。",type:"object",properties:{code:{description:"成功码,恒为 OK。",const:"OK"},message:{description:"说明,可以为空串。",type:"string",maxLength:1e3},data:{description:'结果对象或 null;标量结果也包成对象(如 {"count": 3})。',type:["object","null"],additionalProperties:!0}},required:["code","message","data"],additionalProperties:!1},g={"bounded-list.schema.json":e,"common-error-codes.schema.json":t,"cursor-list-request.schema.json":r,"cursor-list.schema.json":o,"error-body.schema.json":s,"list-filter.schema.json":i,"paged-list-request.schema.json":a,"paged-list.schema.json":n,"service-error-codes.schema.json":c,"success-envelope.schema.json":p};exports.BOUNDED_LIST_RESPONSE_PATHS=l;exports.COMMON_ERROR_CODES=m;exports.COMMON_ERROR_CODE_TABLE=u;exports.CURSOR_LIST_REQUEST_PARAMS=E;exports.CURSOR_LIST_RESPONSE_PATHS=S;exports.LIST_FILTER_PARAMS=h;exports.PAGED_LIST_REQUEST_PARAMS=_;exports.PAGED_LIST_RESPONSE_PATHS=T;exports.SUCCESS_CODES=d;exports.boundedListSchema=e;exports.commonErrorCodesSchema=t;exports.cursorListRequestSchema=r;exports.cursorListSchema=o;exports.errorBodySchema=s;exports.listFilterSchema=i;exports.pagedListRequestSchema=a;exports.pagedListSchema=n;exports.schemas=g;exports.serviceErrorCodesSchema=c;exports.successEnvelopeSchema=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={OK:"OK"},e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"bounded-list.schema.json",title:"BoundedList",description:"一次性列表,作成功外壳的 data。只用于条数有一个由定义决定、不随业务数据增长的上限的结果(如下拉选项);上限由各接口在自己的契约里声明,超过上限报 LIST_LIMIT_EXCEEDED,不截断。顶层允许接口自己声明的附带字段,但不得带翻页信息。","x-pathConstants":"BOUNDED_LIST_RESPONSE_PATHS",type:"object",properties:{items:{description:"列表数据。",type:"array"},page:!1,cursor:!1},required:["items"]},t={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"cursor-list-request.schema.json",title:"CursorListRequest",description:"游标式列表的请求参数。线上以 cursor. 前缀的查询参数传递(如 cursor.limit=20),本定义约束解码后的对象;前缀下未声明的参数不合法。","x-paramPrefix":"cursor","x-pathConstants":"CURSOR_LIST_REQUEST_PARAMS",type:"object",properties:{after:{description:"上一批返回的 next,1–1024 个字符;首批不带。",type:"string",minLength:1,maxLength:1024},limit:{description:"本批最多取多少条,至少 1;不带时取多少条、上限多少由接口自己声明。",type:"integer",minimum:1}},additionalProperties:!1},r={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"cursor-list.schema.json",title:"CursorList",description:"游标式列表,作成功外壳的 data:消息流这类接着往下取的列表,不带总数。取数方向由各接口声明。顶层允许接口自己声明的附带字段,但不得重复表达翻页信息;不带 page。","x-pathConstants":"CURSOR_LIST_RESPONSE_PATHS",type:"object",properties:{items:{description:"本批数据。",type:"array"},cursor:{$ref:"#/$defs/cursor"},page:!1},required:["items","cursor"],$defs:{cursor:{title:"CursorListCursor",description:"接着取的位置。hasMore 为 true 时必须给 next。",type:"object",properties:{next:{description:"下一批的游标,对调用方不透明,1–1024 个字符;没有更多时可省略。",type:"string",minLength:1,maxLength:1024},hasMore:{description:"是否还有更多。",type:"boolean"}},required:["hasMore"],additionalProperties:!1,if:{properties:{hasMore:{const:!0}},required:["hasMore"]},then:{required:["next"]}}}},s={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"error-body.schema.json",title:"ErrorBody",description:"错误体。HTTP 状态表达大类,包体带业务码、说明、能否重试、是否已执行与出错字段定位。retryable 与 outcome 由服务按实际情形填写,包不替使用方填写;通用失败码表给了一组参考值,使用方可显式引用。",type:"object",properties:{code:{description:"业务码,开放字符串:字母开头,只含字母、数字、下划线,1–128 个字符;不能是 OK。使用方遇到不认识的码按 HTTP 状态归类处理。",type:"string",pattern:"^[A-Za-z][A-Za-z0-9_]{0,127}$",not:{const:"OK"}},message:{description:"说明,不能是纯空白。",type:"string",maxLength:1e3,pattern:"\\S"},data:{description:"错误体恒为 null。",type:"null"},error:{$ref:"#/$defs/errorDetail"},requestId:{description:"请求标识,1–128 个字符,不含空白字符。",type:"string",pattern:"^\\S{1,128}$"},detail:{description:"补充说明,可选,不限长。",type:"string"}},required:["code","message","data","error","requestId"],additionalProperties:!1,$defs:{errorDetail:{title:"ErrorDetail",description:"错误的处置信息。",type:"object",properties:{retryable:{description:"原样重试是否可能成功。",type:"boolean"},outcome:{description:"not_executed:确定没有执行;unknown:可能已产生副作用。",enum:["not_executed","unknown"]},fields:{description:"逐项指出出错的输入;可以是空数组。",type:"array",items:{$ref:"#/$defs/errorField"}}},required:["retryable","outcome"],additionalProperties:!1},errorField:{title:"ErrorField",description:"一项出错的输入。in 为 body 时用 pointer 定位、不能有 parameter;其他位置用 parameter 定位、不能有 pointer。",type:"object",properties:{in:{description:"出错输入所在的位置。",enum:["body","query","path","header","cookie"]},code:{description:"字段级错误码:字母开头,只含字母、数字、下划线、点、短横线,1–128 个字符。",type:"string",pattern:"^[A-Za-z][A-Za-z0-9_.\\-]{0,127}$"},message:{description:"说明,不能是纯空白。",type:"string",maxLength:1e3,pattern:"\\S"},pointer:{description:"请求体内的位置,RFC 6901 JSON Pointer。",type:"string",pattern:"^(?:(?:/(?:[^~/]|~[01])*)*/(?:(?:[^~/]|~[01])*(?:[^~/\\n]|~[01]))?)?$"},parameter:{description:"参数名,1–256 个字符。",type:"string",minLength:1,maxLength:256}},required:["in","code","message"],additionalProperties:!1,if:{properties:{in:{const:"body"}},required:["in"]},then:{required:["pointer"],properties:{parameter:!1}},else:{required:["parameter"],properties:{pointer:!1}}}}},i={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"list-filter.schema.json",title:"ListFilter",description:"列表的筛选参数。线上写作 filter.<字段>.<操作>(如 filter.status.eq=active),本定义约束解码后的对象 {<字段>: {<操作>: 值}};字段为小驼峰,可筛选哪些字段由接口自己声明。首版操作只有 eq。前缀下未声明的参数不合法。","x-paramPrefix":"filter","x-pathConstants":"LIST_FILTER_PARAMS",type:"object",patternProperties:{"^[a-z][a-zA-Z0-9]*$":{$ref:"#/$defs/condition"}},additionalProperties:!1,$defs:{condition:{title:"ListFilterCondition",description:"一个字段上的筛选条件,至少一个操作。",type:"object",properties:{eq:{description:"等于;值为标量。",type:["string","number","boolean"]}},minProperties:1,additionalProperties:!1}}},o={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"paged-list-request.schema.json",title:"PagedListRequest",description:"页码式列表的请求参数。线上以 page. 前缀的查询参数传递(如 page.pageSize=20),本定义约束解码后的对象;前缀下未声明的参数不合法。","x-paramPrefix":"page","x-pathConstants":"PAGED_LIST_REQUEST_PARAMS",type:"object",properties:{page:{description:"页码,从 1 开始;不带时的含义由接口自己声明。",type:"integer",minimum:1},pageSize:{description:"每页条数,至少 1;不带时的含义与上限由接口自己声明。",type:"integer",minimum:1},query:{description:"模糊搜索词,最多 200 个字符。",type:"string",maxLength:200},orderBy:{description:"排序:逗号分隔,每段是小驼峰字段名,后面可跟一个空格加 asc 或 desc(缺省 asc);逗号后可有一个空格;最多 200 个字符。",type:"string",maxLength:200,pattern:"^[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?(?:, ?[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?)*$"}},additionalProperties:!1},a={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"paged-list.schema.json",title:"PagedList",description:"页码式列表,作成功外壳的 data:给人翻页的表格,能跳页、有总数。顶层允许接口自己声明的附带字段,但不得重复表达翻页信息;不带 cursor。items 的条数不超过 page.pageSize,也不超过 page.totalRecord(x-itemsWithinPage)。","x-pathConstants":"PAGED_LIST_RESPONSE_PATHS",type:"object",properties:{items:{description:"当前页的数据。",type:"array"},page:{$ref:"#/$defs/page"},cursor:!1},required:["items","page"],"x-itemsWithinPage":!0,$defs:{page:{title:"PagedListPage",description:"翻页信息。不回传当前页码。totalPage 等于 ceil(totalRecord / pageSize),总数为 0 时为 0(x-totalPageEqualsCeil)。",type:"object",properties:{totalRecord:{description:"总条数。",type:"integer",minimum:0},pageSize:{description:"每页条数,回显请求值,至少 1。",type:"integer",minimum:1},totalPage:{description:"总页数。",type:"integer",minimum:0}},required:["totalRecord","pageSize","totalPage"],additionalProperties:!1,if:{properties:{totalRecord:{const:0}},required:["totalRecord"]},then:{properties:{totalPage:{const:0}}},"x-totalPageEqualsCeil":!0}}},n={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"service-error-codes.schema.json",title:"ServiceErrorCodes",description:"一个服务的专有业务码清单。OK 与 HTTP_<数字> 形式的码是结构保留字,不得使用;比较按字节精确进行,不做大小写归一。专有码是否要避开某组通用码由使用方显式检查:把那组码传给参考资源出口的检查函数,不传就不比。",type:"object",properties:{service:{description:"服务标识:小写字母开头,只含小写字母、数字、短横线,最长 64 个字符。",type:"string",pattern:"^[a-z][a-z0-9\\-]{0,63}$"},codes:{description:"专有码,至少 1 项;code 在清单内不重复(x-uniqueItemsBy)。",type:"array",minItems:1,items:{$ref:"#/$defs/code"},"x-uniqueItemsBy":"code"}},required:["service","codes"],additionalProperties:!1,$defs:{code:{title:"ServiceErrorCode",description:"一个专有码。stage 为 execute 时不得有 httpStatus 与 additionalHttpStatuses;为 accept 或 both 时必须有 httpStatus。additionalHttpStatuses 不含主状态(x-arrayExcludesProperty)。",type:"object",properties:{code:{description:"码:整体大写下划线或整体小写下划线写法,字母开头,不以下划线结尾,不含连续下划线,最长 128 个字符。",type:"string",maxLength:128,pattern:"^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$",allOf:[{not:{const:"OK"}},{not:{type:"string",pattern:"^HTTP_[0-9]+$"}}]},stage:{description:"accept:受理时同步返回;execute:异步执行阶段产生;both:两者都有。",enum:["accept","execute","both"]},httpStatus:{description:"主 HTTP 状态,4xx 或 5xx。",type:"integer",minimum:400,maximum:599},additionalHttpStatuses:{description:"同一个码在不同情形下的其他 HTTP 状态:至少 1 项、不重复、不含主状态。",type:"array",minItems:1,uniqueItems:!0,items:{type:"integer",minimum:400,maximum:599}},retryable:{description:"原样重试是否可能成功。",type:"boolean"},outcome:{description:"not_executed:确定没有执行;unknown:可能已产生副作用。",enum:["not_executed","unknown"]},meaning:{description:"一句话含义,1–1000 个字符。",type:"string",minLength:1,maxLength:1e3}},required:["code","stage","retryable","outcome","meaning"],additionalProperties:!1,if:{properties:{stage:{const:"execute"}},required:["stage"]},then:{properties:{httpStatus:!1,additionalHttpStatuses:!1}},else:{required:["httpStatus"]},"x-arrayExcludesProperty":{array:"additionalHttpStatuses",property:"httpStatus"}}}},p={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"success-envelope.schema.json",title:"SuccessEnvelope",description:"成功外壳。成功与否、新建还是已受理以 HTTP 状态码为准,code 不随 200 / 201 / 202 变化。",type:"object",properties:{code:{description:"成功码,恒为 OK。",const:"OK"},message:{description:"说明,可以为空串。",type:"string",maxLength:1e3},data:{description:'结果对象或 null;标量结果也包成对象(如 {"count": 3})。',type:["object","null"],additionalProperties:!0}},required:["code","message","data"],additionalProperties:!1},d={"bounded-list.schema.json":e,"cursor-list-request.schema.json":t,"cursor-list.schema.json":r,"error-body.schema.json":s,"list-filter.schema.json":i,"paged-list-request.schema.json":o,"paged-list.schema.json":a,"service-error-codes.schema.json":n,"success-envelope.schema.json":p};exports.SUCCESS_CODES=c;exports.boundedListSchema=e;exports.cursorListRequestSchema=t;exports.cursorListSchema=r;exports.errorBodySchema=s;exports.listFilterSchema=i;exports.pagedListRequestSchema=o;exports.pagedListSchema=a;exports.schemas=d;exports.serviceErrorCodesSchema=n;exports.successEnvelopeSchema=p;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E={INVALID_REQUEST:"INVALID_REQUEST",UNAUTHENTICATED:"UNAUTHENTICATED",FORBIDDEN:"FORBIDDEN",NOT_FOUND:"NOT_FOUND",ROUTE_NOT_FOUND:"ROUTE_NOT_FOUND",METHOD_NOT_ALLOWED:"METHOD_NOT_ALLOWED",CONFLICT:"CONFLICT",RATE_LIMITED:"RATE_LIMITED",INTERNAL_ERROR:"INTERNAL_ERROR",LIST_LIMIT_EXCEEDED:"LIST_LIMIT_EXCEEDED",SERVICE_UNAVAILABLE:"SERVICE_UNAVAILABLE"},n={INVALID_REQUEST:{httpStatus:400,retryable:!1,outcome:"not_executed",meaning:"请求不符合接口契约"},UNAUTHENTICATED:{httpStatus:401,retryable:!1,outcome:"not_executed",meaning:"未登录,或令牌无效、过期"},FORBIDDEN:{httpStatus:403,retryable:!1,outcome:"not_executed",meaning:"已认证但无权执行"},NOT_FOUND:{httpStatus:404,retryable:!1,outcome:"not_executed",meaning:"资源不存在,或调用方无权得知其存在"},ROUTE_NOT_FOUND:{httpStatus:404,retryable:!1,outcome:"not_executed",meaning:"接口路径不存在"},METHOD_NOT_ALLOWED:{httpStatus:405,retryable:!1,outcome:"not_executed",meaning:"接口不支持该 HTTP 方法"},CONFLICT:{httpStatus:409,retryable:!1,outcome:"not_executed",meaning:"资源状态冲突"},RATE_LIMITED:{httpStatus:429,retryable:!0,outcome:"not_executed",meaning:"请求过于频繁,可稍后重试"},INTERNAL_ERROR:{httpStatus:500,retryable:!1,outcome:"unknown",meaning:"服务内部错误,可能已产生副作用"},LIST_LIMIT_EXCEEDED:{httpStatus:500,retryable:!1,outcome:"unknown",meaning:"一次性列表的结果超出接口声明的上限"},SERVICE_UNAVAILABLE:{httpStatus:503,retryable:!0,outcome:"unknown",meaning:"服务或其依赖暂不可用"}},i={items:"items"},_={after:"cursor.after",limit:"cursor.limit"},p={items:"items",next:"cursor.next",hasMore:"cursor.hasMore"},u={prefix:"filter.",operators:{eq:"eq"}},S={page:"page.page",pageSize:"page.pageSize",query:"page.query",orderBy:"page.orderBy"},T={items:"items",totalRecord:"page.totalRecord",pageSize:"page.pageSize",totalPage:"page.totalPage"},R={page:1,pageSize:10,maxPageSize:100},l={maxLimit:100},t={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"common-error-codes.schema.json",title:"CommonErrorCodes",description:"通用失败码表(参考资源):每个码给出 HTTP 状态(x-httpStatus),以及能否重试与是否已执行的参考值(x-referenceValue)。本表不约束任何结构:错误体不引用它,包不替使用方填写;使用方可显式引用表中值。$defs/code 列出全部通用失败码,须与 allOf 各项一一对应。","x-referenceResource":!0,$defs:{code:{description:"通用失败码。",enum:["INVALID_REQUEST","UNAUTHENTICATED","FORBIDDEN","NOT_FOUND","ROUTE_NOT_FOUND","METHOD_NOT_ALLOWED","CONFLICT","RATE_LIMITED","INTERNAL_ERROR","LIST_LIMIT_EXCEEDED","SERVICE_UNAVAILABLE"]}},allOf:[{description:"请求不符合接口契约","x-httpStatus":400,if:{properties:{code:{const:"INVALID_REQUEST"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"未登录,或令牌无效、过期","x-httpStatus":401,if:{properties:{code:{const:"UNAUTHENTICATED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"已认证但无权执行","x-httpStatus":403,if:{properties:{code:{const:"FORBIDDEN"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"资源不存在,或调用方无权得知其存在","x-httpStatus":404,if:{properties:{code:{const:"NOT_FOUND"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"接口路径不存在","x-httpStatus":404,if:{properties:{code:{const:"ROUTE_NOT_FOUND"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"接口不支持该 HTTP 方法","x-httpStatus":405,if:{properties:{code:{const:"METHOD_NOT_ALLOWED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"资源状态冲突","x-httpStatus":409,if:{properties:{code:{const:"CONFLICT"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"请求过于频繁,可稍后重试","x-httpStatus":429,if:{properties:{code:{const:"RATE_LIMITED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!0},outcome:{"x-referenceValue":"not_executed"}}}}}},{description:"服务内部错误,可能已产生副作用","x-httpStatus":500,if:{properties:{code:{const:"INTERNAL_ERROR"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"unknown"}}}}}},{description:"一次性列表的结果超出接口声明的上限","x-httpStatus":500,if:{properties:{code:{const:"LIST_LIMIT_EXCEEDED"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!1},outcome:{"x-referenceValue":"unknown"}}}}}},{description:"服务或其依赖暂不可用","x-httpStatus":503,if:{properties:{code:{const:"SERVICE_UNAVAILABLE"}},required:["code"]},then:{properties:{error:{properties:{retryable:{"x-referenceValue":!0},outcome:{"x-referenceValue":"unknown"}}}}}}]},r={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"list-reference-values.schema.json",title:"ListReferenceValues",description:"列表的参考数值(参考资源):只是参考,不约束任何结构。结构定义里页码、每页条数、每批条数都没有默认值和上限,包不替使用方填写;要用这些数值须在自己的代码里显式引用,或声明自己的值。","x-referenceResource":!0,"x-referenceValues":{PAGED_LIST_REFERENCE_VALUES:{description:"页码式列表的参考数值:page 是请求不带页码时可参考的页码,pageSize 是请求不带每页条数时可参考的条数,maxPageSize 是每页条数可参考的上限。",value:{page:1,pageSize:10,maxPageSize:100}},CURSOR_LIST_REFERENCE_VALUES:{description:"游标式列表的参考数值:maxLimit 是每批条数可参考的上限。",value:{maxLimit:100}}}},d={"common-error-codes.schema.json":t,"list-reference-values.schema.json":r};function O(o,s){const a=new Set(s);return o.codes.flatMap(({code:e},c)=>a.has(e)?[{index:c,code:e}]:[])}exports.BOUNDED_LIST_RESPONSE_PATHS=i;exports.COMMON_ERROR_CODES=E;exports.COMMON_ERROR_CODE_TABLE=n;exports.CURSOR_LIST_REFERENCE_VALUES=l;exports.CURSOR_LIST_REQUEST_PARAMS=_;exports.CURSOR_LIST_RESPONSE_PATHS=p;exports.LIST_FILTER_PARAMS=u;exports.PAGED_LIST_REFERENCE_VALUES=R;exports.PAGED_LIST_REQUEST_PARAMS=S;exports.PAGED_LIST_RESPONSE_PATHS=T;exports.commonErrorCodesSchema=t;exports.findReservedCodes=O;exports.listReferenceValuesSchema=r;exports.referenceSchemas=d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/schema-api",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1-alpha.2",
4
4
  "description": "跨前后端通用接口结构的类型、常量与定义文件",
5
5
  "private": false,
6
6
  "main": "lib/index.cjs",
@@ -13,6 +13,11 @@
13
13
  "import": "./es/index.mjs",
14
14
  "require": "./lib/index.cjs"
15
15
  },
16
+ "./reference": {
17
+ "types": "./types/reference.d.ts",
18
+ "import": "./es/reference.mjs",
19
+ "require": "./lib/reference.cjs"
20
+ },
16
21
  "./schemas/*": "./schemas/*",
17
22
  "./package.json": "./package.json"
18
23
  },