@aomex/internal-tools 4.4.0 → 4.4.1-alpha.c1419fd5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +270 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18n } from "@i18nx/node";
|
|
2
2
|
import rawBytes from "bytes";
|
|
3
|
-
import { OpenAPIV3 as OpenAPI } from "openapi-types";
|
|
3
|
+
import { OpenAPIV3, OpenAPIV3 as OpenAPI } from "openapi-types";
|
|
4
4
|
export * from "@i18nx/node";
|
|
5
5
|
/**
|
|
6
6
|
* 返回数组,如果传入非数组,则会包装成只有一个元素的数组
|
|
@@ -113,4 +113,272 @@ type DurationInput = number | DurationString;
|
|
|
113
113
|
*/
|
|
114
114
|
export declare function parseDuration(value: DurationInput): number;
|
|
115
115
|
export declare function parseDuration(value?: DurationInput): number | undefined;
|
|
116
|
-
|
|
116
|
+
/**
|
|
117
|
+
* AsyncAPI 3.x TypeScript 类型(自研,对齐规范 3.0.0 / 3.1.0 核心对象)。
|
|
118
|
+
*
|
|
119
|
+
* - Schema 复用 OpenAPI Schema(与 `@aomex/common` 校验器 `toDocument` 同形)
|
|
120
|
+
* - 协议 Bindings 仅保留协议键占位,不展开各 binding 版本细节
|
|
121
|
+
* - 规范扩展 `x-*` 未强制建模(避免与 OpenAPI Reference/Schema 赋值不兼容);写入时允许任意多余键
|
|
122
|
+
*/
|
|
123
|
+
declare namespace AsyncAPI {
|
|
124
|
+
/** 复用校验器产出的 JSON Schema(与 OpenAPI Schema 同形) */
|
|
125
|
+
type SchemaObject = OpenAPIV3.SchemaObject;
|
|
126
|
+
interface ReferenceObject {
|
|
127
|
+
$ref: string;
|
|
128
|
+
}
|
|
129
|
+
type Referable<T> = T | ReferenceObject;
|
|
130
|
+
interface ContactObject {
|
|
131
|
+
name?: string;
|
|
132
|
+
url?: string;
|
|
133
|
+
email?: string;
|
|
134
|
+
}
|
|
135
|
+
interface LicenseObject {
|
|
136
|
+
name: string;
|
|
137
|
+
url?: string;
|
|
138
|
+
}
|
|
139
|
+
interface ExternalDocumentationObject {
|
|
140
|
+
url: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
}
|
|
143
|
+
interface TagObject {
|
|
144
|
+
name: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
externalDocs?: Referable<ExternalDocumentationObject>;
|
|
147
|
+
}
|
|
148
|
+
interface InfoObject {
|
|
149
|
+
title: string;
|
|
150
|
+
version: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
termsOfService?: string;
|
|
153
|
+
contact?: ContactObject;
|
|
154
|
+
license?: LicenseObject;
|
|
155
|
+
tags?: Array<Referable<TagObject>>;
|
|
156
|
+
externalDocs?: Referable<ExternalDocumentationObject>;
|
|
157
|
+
}
|
|
158
|
+
interface ServerVariableObject {
|
|
159
|
+
enum?: string[];
|
|
160
|
+
default?: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
examples?: string[];
|
|
163
|
+
}
|
|
164
|
+
/** 协议绑定:仅协议键,值为不透明对象 */
|
|
165
|
+
type BindingMap = {
|
|
166
|
+
[protocol: string]: object | undefined;
|
|
167
|
+
};
|
|
168
|
+
type ServerBindingsObject = BindingMap;
|
|
169
|
+
type ChannelBindingsObject = BindingMap;
|
|
170
|
+
type OperationBindingsObject = BindingMap;
|
|
171
|
+
type MessageBindingsObject = BindingMap;
|
|
172
|
+
interface ServerObject {
|
|
173
|
+
host: string;
|
|
174
|
+
protocol: string;
|
|
175
|
+
protocolVersion?: string;
|
|
176
|
+
pathname?: string;
|
|
177
|
+
title?: string;
|
|
178
|
+
summary?: string;
|
|
179
|
+
description?: string;
|
|
180
|
+
variables?: Record<string, Referable<ServerVariableObject>>;
|
|
181
|
+
security?: SecurityRequirements;
|
|
182
|
+
tags?: Array<Referable<TagObject>>;
|
|
183
|
+
externalDocs?: Referable<ExternalDocumentationObject>;
|
|
184
|
+
bindings?: Referable<ServerBindingsObject>;
|
|
185
|
+
}
|
|
186
|
+
interface ParameterObject {
|
|
187
|
+
description?: string;
|
|
188
|
+
enum?: string[];
|
|
189
|
+
default?: string;
|
|
190
|
+
examples?: string[];
|
|
191
|
+
/** Runtime Expression,定位参数取值位置 */
|
|
192
|
+
location?: string;
|
|
193
|
+
}
|
|
194
|
+
interface CorrelationIdObject {
|
|
195
|
+
location: string;
|
|
196
|
+
description?: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Multi Format Schema:显式声明 schema 语言时使用。
|
|
200
|
+
* @see https://www.asyncapi.com/docs/reference/specification/v3.1.0#multiFormatSchemaObject
|
|
201
|
+
*/
|
|
202
|
+
interface MultiFormatSchemaObject {
|
|
203
|
+
schemaFormat?: string;
|
|
204
|
+
schema: SchemaObject | boolean | unknown;
|
|
205
|
+
}
|
|
206
|
+
/** Message / Trait 的 payload、headers:Schema、`$ref` 或 Multi Format Schema */
|
|
207
|
+
type AnySchemaObject = SchemaObject | ReferenceObject | MultiFormatSchemaObject | boolean;
|
|
208
|
+
interface MessageExampleObject {
|
|
209
|
+
name?: string;
|
|
210
|
+
summary?: string;
|
|
211
|
+
headers?: Record<string, unknown>;
|
|
212
|
+
payload?: unknown;
|
|
213
|
+
}
|
|
214
|
+
interface MessageTraitObject {
|
|
215
|
+
name?: string;
|
|
216
|
+
title?: string;
|
|
217
|
+
summary?: string;
|
|
218
|
+
description?: string;
|
|
219
|
+
deprecated?: boolean;
|
|
220
|
+
contentType?: string;
|
|
221
|
+
headers?: AnySchemaObject;
|
|
222
|
+
correlationId?: Referable<CorrelationIdObject>;
|
|
223
|
+
tags?: Array<Referable<TagObject>>;
|
|
224
|
+
externalDocs?: Referable<ExternalDocumentationObject>;
|
|
225
|
+
bindings?: Referable<MessageBindingsObject>;
|
|
226
|
+
examples?: MessageExampleObject[];
|
|
227
|
+
}
|
|
228
|
+
interface MessageObject extends MessageTraitObject {
|
|
229
|
+
payload?: AnySchemaObject;
|
|
230
|
+
traits?: Array<Referable<MessageTraitObject>>;
|
|
231
|
+
}
|
|
232
|
+
interface ChannelObject {
|
|
233
|
+
/** 通道地址;`null` 表示地址未定义(由绑定等决定) */
|
|
234
|
+
address?: string | null;
|
|
235
|
+
title?: string;
|
|
236
|
+
summary?: string;
|
|
237
|
+
description?: string;
|
|
238
|
+
parameters?: Record<string, Referable<ParameterObject>>;
|
|
239
|
+
messages?: Record<string, Referable<MessageObject>>;
|
|
240
|
+
/** 引用本 Channel 可用的 Server(`$ref` → `#/servers/{name}`) */
|
|
241
|
+
servers?: ReferenceObject[];
|
|
242
|
+
tags?: Array<Referable<TagObject>>;
|
|
243
|
+
externalDocs?: Referable<ExternalDocumentationObject>;
|
|
244
|
+
bindings?: Referable<ChannelBindingsObject>;
|
|
245
|
+
}
|
|
246
|
+
interface OperationReplyAddressObject {
|
|
247
|
+
location: string;
|
|
248
|
+
description?: string;
|
|
249
|
+
}
|
|
250
|
+
interface OperationReplyObject {
|
|
251
|
+
address?: Referable<OperationReplyAddressObject>;
|
|
252
|
+
channel?: ReferenceObject;
|
|
253
|
+
messages?: ReferenceObject[];
|
|
254
|
+
}
|
|
255
|
+
interface OperationTraitObject {
|
|
256
|
+
title?: string;
|
|
257
|
+
summary?: string;
|
|
258
|
+
description?: string;
|
|
259
|
+
security?: SecurityRequirements;
|
|
260
|
+
tags?: Array<Referable<TagObject>>;
|
|
261
|
+
externalDocs?: Referable<ExternalDocumentationObject>;
|
|
262
|
+
bindings?: Referable<OperationBindingsObject>;
|
|
263
|
+
}
|
|
264
|
+
interface OperationObject extends OperationTraitObject {
|
|
265
|
+
action: 'send' | 'receive';
|
|
266
|
+
channel: ReferenceObject;
|
|
267
|
+
messages?: ReferenceObject[];
|
|
268
|
+
reply?: Referable<OperationReplyObject>;
|
|
269
|
+
traits?: Array<Referable<OperationTraitObject>>;
|
|
270
|
+
}
|
|
271
|
+
interface UserPasswordSecurityScheme {
|
|
272
|
+
type: 'userPassword';
|
|
273
|
+
description?: string;
|
|
274
|
+
}
|
|
275
|
+
interface ApiKeySecurityScheme {
|
|
276
|
+
type: 'apiKey';
|
|
277
|
+
in: 'user' | 'password';
|
|
278
|
+
description?: string;
|
|
279
|
+
}
|
|
280
|
+
interface X509SecurityScheme {
|
|
281
|
+
type: 'X509';
|
|
282
|
+
description?: string;
|
|
283
|
+
}
|
|
284
|
+
interface SymmetricEncryptionSecurityScheme {
|
|
285
|
+
type: 'symmetricEncryption';
|
|
286
|
+
description?: string;
|
|
287
|
+
}
|
|
288
|
+
interface AsymmetricEncryptionSecurityScheme {
|
|
289
|
+
type: 'asymmetricEncryption';
|
|
290
|
+
description?: string;
|
|
291
|
+
}
|
|
292
|
+
interface HttpBearerSecurityScheme {
|
|
293
|
+
type: 'http';
|
|
294
|
+
scheme: 'bearer';
|
|
295
|
+
bearerFormat?: string;
|
|
296
|
+
description?: string;
|
|
297
|
+
}
|
|
298
|
+
interface HttpSecurityScheme {
|
|
299
|
+
type: 'http';
|
|
300
|
+
scheme: string;
|
|
301
|
+
description?: string;
|
|
302
|
+
}
|
|
303
|
+
interface HttpApiKeySecurityScheme {
|
|
304
|
+
type: 'httpApiKey';
|
|
305
|
+
name: string;
|
|
306
|
+
in: 'header' | 'query' | 'cookie';
|
|
307
|
+
description?: string;
|
|
308
|
+
}
|
|
309
|
+
type HttpSecuritySchemeObject = HttpBearerSecurityScheme | HttpSecurityScheme | HttpApiKeySecurityScheme;
|
|
310
|
+
interface OAuth2ScopesObject {
|
|
311
|
+
[scope: string]: string;
|
|
312
|
+
}
|
|
313
|
+
interface OAuth2FlowObject {
|
|
314
|
+
authorizationUrl?: string;
|
|
315
|
+
tokenUrl?: string;
|
|
316
|
+
refreshUrl?: string;
|
|
317
|
+
availableScopes?: OAuth2ScopesObject;
|
|
318
|
+
}
|
|
319
|
+
interface OAuth2SecurityScheme {
|
|
320
|
+
type: 'oauth2';
|
|
321
|
+
description?: string;
|
|
322
|
+
flows: {
|
|
323
|
+
authorizationCode?: OAuth2FlowObject;
|
|
324
|
+
clientCredentials?: OAuth2FlowObject;
|
|
325
|
+
implicit?: OAuth2FlowObject;
|
|
326
|
+
password?: OAuth2FlowObject;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
interface OpenIdConnectSecurityScheme {
|
|
330
|
+
type: 'openIdConnect';
|
|
331
|
+
openIdConnectUrl: string;
|
|
332
|
+
description?: string;
|
|
333
|
+
scopes?: string[];
|
|
334
|
+
}
|
|
335
|
+
interface SaslPlainSecurityScheme {
|
|
336
|
+
type: 'plain';
|
|
337
|
+
description?: string;
|
|
338
|
+
}
|
|
339
|
+
interface SaslScramSecurityScheme {
|
|
340
|
+
type: 'scramSha256' | 'scramSha512';
|
|
341
|
+
description?: string;
|
|
342
|
+
}
|
|
343
|
+
interface SaslGssapiSecurityScheme {
|
|
344
|
+
type: 'gssapi';
|
|
345
|
+
description?: string;
|
|
346
|
+
}
|
|
347
|
+
type SaslSecurityScheme = SaslPlainSecurityScheme | SaslScramSecurityScheme | SaslGssapiSecurityScheme;
|
|
348
|
+
type SecuritySchemeObject = UserPasswordSecurityScheme | ApiKeySecurityScheme | X509SecurityScheme | SymmetricEncryptionSecurityScheme | AsymmetricEncryptionSecurityScheme | HttpSecuritySchemeObject | OAuth2SecurityScheme | OpenIdConnectSecurityScheme | SaslSecurityScheme;
|
|
349
|
+
/** 规范中 security 为 Scheme / Reference 数组(3.x) */
|
|
350
|
+
type SecurityRequirements = Array<Referable<SecuritySchemeObject>>;
|
|
351
|
+
interface ComponentsObject {
|
|
352
|
+
schemas?: Record<string, Referable<SchemaObject>>;
|
|
353
|
+
servers?: Record<string, Referable<ServerObject>>;
|
|
354
|
+
channels?: Record<string, Referable<ChannelObject>>;
|
|
355
|
+
operations?: Record<string, Referable<OperationObject>>;
|
|
356
|
+
messages?: Record<string, Referable<MessageObject>>;
|
|
357
|
+
securitySchemes?: Record<string, Referable<SecuritySchemeObject>>;
|
|
358
|
+
serverVariables?: Record<string, Referable<ServerVariableObject>>;
|
|
359
|
+
parameters?: Record<string, Referable<ParameterObject>>;
|
|
360
|
+
correlationIds?: Record<string, Referable<CorrelationIdObject>>;
|
|
361
|
+
replies?: Record<string, Referable<OperationReplyObject>>;
|
|
362
|
+
replyAddresses?: Record<string, Referable<OperationReplyAddressObject>>;
|
|
363
|
+
externalDocs?: Record<string, Referable<ExternalDocumentationObject>>;
|
|
364
|
+
tags?: Record<string, Referable<TagObject>>;
|
|
365
|
+
operationTraits?: Record<string, Referable<OperationTraitObject>>;
|
|
366
|
+
messageTraits?: Record<string, Referable<MessageTraitObject>>;
|
|
367
|
+
serverBindings?: Record<string, Referable<ServerBindingsObject>>;
|
|
368
|
+
channelBindings?: Record<string, Referable<ChannelBindingsObject>>;
|
|
369
|
+
operationBindings?: Record<string, Referable<OperationBindingsObject>>;
|
|
370
|
+
messageBindings?: Record<string, Referable<MessageBindingsObject>>;
|
|
371
|
+
}
|
|
372
|
+
interface Document {
|
|
373
|
+
asyncapi: '3.0.0' | '3.1.0';
|
|
374
|
+
/** 应用标识(URI) */
|
|
375
|
+
id?: string;
|
|
376
|
+
info: InfoObject;
|
|
377
|
+
defaultContentType?: string;
|
|
378
|
+
servers?: Record<string, Referable<ServerObject>>;
|
|
379
|
+
channels?: Record<string, Referable<ChannelObject>>;
|
|
380
|
+
operations?: Record<string, Referable<OperationObject>>;
|
|
381
|
+
components?: ComponentsObject;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
export { type AsyncAPI, type BytesOptions, type DurationInput, type DurationString, type DurationUnit, OpenAPI };
|