anymock-openapi
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -6,10 +6,6 @@ import { IAnymockConfigUpdate } from 'anymock-include'; | ||
export default class Base { | ||
protected ctx: MockCtx; | ||
constructor(ctx: MockCtx); | ||
request<T extends object>( | ||
path: string, | ||
payload: IRequestOption<T>, | ||
options: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<any>>; | ||
protected ctx: MockCtx; | ||
constructor(ctx: MockCtx); | ||
request<T extends object>(path: string, payload: IRequestOption<T>, options: IAnymockConfigUpdate): Promise<IAnymockResponse<any>>; | ||
} | ||
//# sourceMappingURL=base.d.ts.map | ||
//# sourceMappingURL=base.d.ts.map |
@@ -7,12 +7,12 @@ import { IAnymockConfigUpdate, IRequestPipe } from 'anymock-include'; | ||
export default class AnymockOpenapi { | ||
mock: Mock; | ||
project: Project; | ||
interface: Interface; | ||
request: Request; | ||
anymockConfig: IAnymockConfigUpdate; | ||
requestPipe: IRequestPipe; | ||
constructor(anymockConfig: IAnymockConfigUpdate, requestPipe?: IRequestPipe); | ||
setProjectToken(projectToken: string): AnymockOpenapi; | ||
mock: Mock; | ||
project: Project; | ||
interface: Interface; | ||
request: Request; | ||
anymockConfig: IAnymockConfigUpdate; | ||
requestPipe: IRequestPipe; | ||
constructor(anymockConfig: IAnymockConfigUpdate, requestPipe?: IRequestPipe); | ||
setProjectToken(projectToken: string): AnymockOpenapi; | ||
} | ||
export * from './types'; | ||
//# sourceMappingURL=index.d.ts.map | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,46 +8,39 @@ /** | ||
interface IQuery { | ||
[key: string]: any; | ||
[key: string]: any; | ||
} | ||
interface IInterfaceModifiableParams { | ||
type: string; | ||
matching: string; | ||
name?: string; | ||
subType?: string; | ||
description?: string; | ||
type: string; | ||
matching: string; | ||
name?: string; | ||
subType?: string; | ||
description?: string; | ||
} | ||
export default class Interface extends Base { | ||
/** | ||
* 获取接口列表 | ||
* 根据项目 Token 解析出 project id,从而返回该项目下的所有接口 | ||
*/ | ||
list(options?: IAnymockConfigUpdate, payload?: IQuery): Promise<IAnymockResponse<IInterface[]>>; | ||
/** | ||
* 创建接口 | ||
* 根据项目 Token 解析出 project id,从而在该项目创建一个接口 | ||
*/ | ||
create( | ||
payload: IInterfaceModifiableParams, | ||
config?: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<number>>; | ||
/** | ||
* 获取接口详情 | ||
* 根据项目 Token 解析出 project id,结合 interfaceId 获取到对应接口的详情 | ||
*/ | ||
get(interfaceId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<IInterface>>; | ||
/** | ||
* 更新接口 | ||
* 根据项目 Token 解析出 project id,从而在该项目更新一个目标接口 | ||
*/ | ||
update( | ||
interfaceId: ID, | ||
payload: IInterfaceModifiableParams, | ||
config?: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<null>>; | ||
/** | ||
* 删除接口 | ||
* 根据项目 Token 解析出 project id,从而在该项目删除该接口 | ||
*/ | ||
delete(interfaceId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<null>>; | ||
/** | ||
* 获取接口列表 | ||
* 根据项目 Token 解析出 project id,从而返回该项目下的所有接口 | ||
*/ | ||
list(options?: IAnymockConfigUpdate, payload?: IQuery): Promise<IAnymockResponse<IInterface[]>>; | ||
/** | ||
* 创建接口 | ||
* 根据项目 Token 解析出 project id,从而在该项目创建一个接口 | ||
*/ | ||
create(payload: IInterfaceModifiableParams, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<number>>; | ||
/** | ||
* 获取接口详情 | ||
* 根据项目 Token 解析出 project id,结合 interfaceId 获取到对应接口的详情 | ||
*/ | ||
get(interfaceId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<IInterface>>; | ||
/** | ||
* 更新接口 | ||
* 根据项目 Token 解析出 project id,从而在该项目更新一个目标接口 | ||
*/ | ||
update(interfaceId: ID, payload: IInterfaceModifiableParams, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<null>>; | ||
/** | ||
* 删除接口 | ||
* 根据项目 Token 解析出 project id,从而在该项目删除该接口 | ||
*/ | ||
delete(interfaceId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<null>>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=interface.d.ts.map | ||
//# sourceMappingURL=interface.d.ts.map |
@@ -5,24 +5,16 @@ import { IAnymockConfigUpdate, IMockQueryPayload } from 'anymock-include'; | ||
interface IMockResp { | ||
mock: { | ||
data: string; | ||
}; | ||
mock: { | ||
data: string; | ||
}; | ||
} | ||
export default class Mock extends Base { | ||
query( | ||
payload: IMockQueryPayload, | ||
options?: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<IMockResp>>; | ||
/** | ||
* 更新 Mock | ||
* 仅允许更新 Mock 数据和入参过滤器 | ||
* 根据项目 Token 解析出 project id,从而在该项目更新一个目标接口 | ||
*/ | ||
update( | ||
requestId: ID, | ||
mockId: ID, | ||
payload: Pick<IMock, 'data'>, | ||
config?: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<any>>; | ||
query(payload: IMockQueryPayload, options?: IAnymockConfigUpdate): Promise<IAnymockResponse<IMockResp>>; | ||
/** | ||
* 更新 Mock | ||
* 仅允许更新 Mock 数据和入参过滤器 | ||
* 根据项目 Token 解析出 project id,从而在该项目更新一个目标接口 | ||
*/ | ||
update(requestId: ID, mockId: ID, payload: IMock, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<any>>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=mock.d.ts.map | ||
//# sourceMappingURL=mock.d.ts.map |
@@ -12,4 +12,8 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var DEFAULTS; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request('/mock/query', payload, options)]; | ||
DEFAULTS = { | ||
subType: '', | ||
}; | ||
return [2 /*return*/, this.request('/mock/query', tslib_1.__assign({}, DEFAULTS, payload), options)]; | ||
}); | ||
@@ -16,0 +20,0 @@ }); |
@@ -8,16 +8,13 @@ /** | ||
interface IGetProjectPayload { | ||
[key: string]: any; | ||
[key: string]: any; | ||
} | ||
export default class Project extends Base { | ||
/** | ||
* 获取项目详情 | ||
* @param options | ||
* @param payload | ||
*/ | ||
get( | ||
options?: IAnymockConfigUpdate, | ||
payload?: IGetProjectPayload | ||
): Promise<IAnymockResponse<IProject>>; | ||
/** | ||
* 获取项目详情 | ||
* @param options | ||
* @param payload | ||
*/ | ||
get(options?: IAnymockConfigUpdate, payload?: IGetProjectPayload): Promise<IAnymockResponse<IProject>>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=project.d.ts.map | ||
//# sourceMappingURL=project.d.ts.map |
@@ -8,68 +8,54 @@ /** | ||
interface IAddRequestParam { | ||
/** | ||
* 若有则通过 interfaceId 唯一定位一个 interface | ||
* 否则通过三要素唯一定位(性能相对较差,但是为了客户端方便) | ||
*/ | ||
interfaceId?: ID; | ||
type: string; | ||
matching: string; | ||
subType: string; | ||
description?: string; | ||
name?: string; | ||
request: { | ||
cname: string; | ||
mock: { | ||
data: string; | ||
/** | ||
* 若有则通过 interfaceId 唯一定位一个 interface | ||
* 否则通过三要素唯一定位(性能相对较差,但是为了客户端方便) | ||
*/ | ||
interfaceId?: ID; | ||
type: string; | ||
matching: string; | ||
subType: string; | ||
description?: string; | ||
name?: string; | ||
request: { | ||
cname: string; | ||
mock: { | ||
data: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
export default class Request extends Base { | ||
/** | ||
* 创建 request | ||
* 根据项目 Token 解析出 project id,从而在该项目下创建一个 request | ||
*/ | ||
create( | ||
interfaceId: ID, | ||
payload: Partial<IRequest>, | ||
config?: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<object>>; | ||
/** | ||
* 获取 request 详情 | ||
* 根据项目 Token 解析出 project id,结合 interfaceId 获取到对应 request 的详情 | ||
*/ | ||
get(requestId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<IRequest>>; | ||
/** | ||
* 更新 request | ||
* 根据项目 Token 解析出 project id,从而在该项目下更新一个目标 request | ||
*/ | ||
update( | ||
interfaceId: ID, | ||
requestId: ID, | ||
payload: Partial<IRequest>, | ||
config?: IAnymockConfigUpdate | ||
): Promise<IAnymockResponse<object>>; | ||
/** | ||
* 删除 request | ||
* 根据项目 Token 解析出 project id,从而在该项目删除该 request | ||
*/ | ||
delete(requestId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<null>>; | ||
/** | ||
* 复合接口,有可能会先创建一个接口。 | ||
* 当接口存在则在接口下创建一个 request,否则先创建接口然后在其下新增一个 request | ||
* 根据项目 Token 解析出 project id,并且唯一定位到一个 interface。然后在其下新增一个 request | ||
* 定位规则:优先通过 interfaceId 或通过三要素(type / subType / matching) | ||
*/ | ||
addRequest( | ||
payload: IAddRequestParam, | ||
config?: IAnymockConfigUpdate | ||
): Promise< | ||
IAnymockResponse<{ | ||
interface: { | ||
id: ID; | ||
}; | ||
request: any; | ||
}> | ||
>; | ||
/** | ||
* 创建 request | ||
* 根据项目 Token 解析出 project id,从而在该项目下创建一个 request | ||
*/ | ||
create(interfaceId: ID, payload: Partial<IRequest>, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<object>>; | ||
/** | ||
* 获取 request 详情 | ||
* 根据项目 Token 解析出 project id,结合 interfaceId 获取到对应 request 的详情 | ||
*/ | ||
get(requestId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<IRequest>>; | ||
/** | ||
* 更新 request | ||
* 根据项目 Token 解析出 project id,从而在该项目下更新一个目标 request | ||
*/ | ||
update(interfaceId: ID, requestId: ID, payload: Partial<IRequest>, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<object>>; | ||
/** | ||
* 删除 request | ||
* 根据项目 Token 解析出 project id,从而在该项目删除该 request | ||
*/ | ||
delete(requestId: ID, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<null>>; | ||
/** | ||
* 复合接口,有可能会先创建一个接口。 | ||
* 当接口存在则在接口下创建一个 request,否则先创建接口然后在其下新增一个 request | ||
* 根据项目 Token 解析出 project id,并且唯一定位到一个 interface。然后在其下新增一个 request | ||
* 定位规则:优先通过 interfaceId 或通过三要素(type / subType / matching) | ||
*/ | ||
addRequest(payload: IAddRequestParam, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<{ | ||
interface: { | ||
id: ID; | ||
}; | ||
request: any; | ||
}>>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=request.d.ts.map | ||
//# sourceMappingURL=request.d.ts.map |
@@ -6,68 +6,68 @@ /** | ||
export interface IProject { | ||
id: number; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
name: string; | ||
cname: string; | ||
avatar?: any; | ||
description: string; | ||
spaceId: number; | ||
status: number; | ||
token: string; | ||
members: IMember[]; | ||
id: number; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
name: string; | ||
cname: string; | ||
avatar?: any; | ||
description: string; | ||
spaceId: number; | ||
status: number; | ||
token: string; | ||
members: IMember[]; | ||
} | ||
export interface IMember { | ||
id: number; | ||
anymockId: string; | ||
userId: string; | ||
userName: string; | ||
nickName: string; | ||
avatar: string; | ||
id: number; | ||
anymockId: string; | ||
userId: string; | ||
userName: string; | ||
nickName: string; | ||
avatar: string; | ||
} | ||
export interface IInterface { | ||
cname?: any; | ||
description?: any; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
id: number; | ||
matching: string; | ||
matchingType: string; | ||
name: string; | ||
projectId: number; | ||
request: IRequest[]; | ||
subType: string; | ||
type: string; | ||
cname?: any; | ||
description?: any; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
id: number; | ||
matching: string; | ||
matchingType: string; | ||
name: string; | ||
projectId: number; | ||
request: IRequest[]; | ||
subType: string; | ||
type: string; | ||
} | ||
export interface IRequest { | ||
cname: string; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
id: number; | ||
interfaceId: number; | ||
isActive: boolean; | ||
mock: IMock[]; | ||
status: number; | ||
cname: string; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
id: number; | ||
interfaceId: number; | ||
isActive: boolean; | ||
mock: IMock[]; | ||
status: number; | ||
} | ||
export interface IMock { | ||
data: string; | ||
dataType: number; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
id: number; | ||
mockType: MockTypeEnum; | ||
requestId: number; | ||
data: string; | ||
dataType: number; | ||
gmtCreate: string; | ||
gmtModified: string; | ||
id: number; | ||
mockType: MockTypeEnum; | ||
requestId: number; | ||
} | ||
export declare enum MockTypeEnum { | ||
ResponseBody = 1, | ||
ResponseHeader = 2, | ||
RequestBody = 3, | ||
RequestHeader = 4, | ||
ResponseBody = 1, | ||
ResponseHeader = 2, | ||
RequestBody = 3, | ||
RequestHeader = 4 | ||
} | ||
export interface IAnymockResponse<T = null> { | ||
success: boolean; | ||
data: T; | ||
errorMessage: string; | ||
errorCode: string; | ||
errorExtra: any; | ||
success: boolean; | ||
data: T; | ||
errorMessage: string; | ||
errorCode: string; | ||
errorExtra: any; | ||
} | ||
//# sourceMappingURL=types.d.ts.map | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "anymock-openapi", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "lib/index.js", | ||
@@ -15,2 +15,3 @@ "types": "./lib/index.d.ts", | ||
"prepub": "npm run build", | ||
"prepublish": "npm run build", | ||
"pub": "npm publish" | ||
@@ -17,0 +18,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35979
0
534