Comparing version 0.13.0 to 0.14.0
@@ -23,7 +23,7 @@ "use strict"; | ||
var isOptionRequired = (typeInfo.query && !typeInfo.query.hasQuestion) || | ||
(typeInfo.reqData && !typeInfo.reqData.hasQuestion) || | ||
(typeInfo.reqBody && !typeInfo.reqBody.hasQuestion) || | ||
(typeInfo.reqHeaders && !typeInfo.reqHeaders.hasQuestion); | ||
var reqData = function (method) { | ||
return typeInfo.reqData | ||
? " data" + (typeInfo.reqData.hasQuestion ? '?' : '') + ": " + importName + "['" + method + "']['reqData']," | ||
var reqBody = function (method) { | ||
return typeInfo.reqBody | ||
? " data" + (typeInfo.reqBody.hasQuestion ? '?' : '') + ": " + importName + "['" + method + "']['reqBody']," | ||
: ''; | ||
@@ -45,20 +45,20 @@ }; | ||
var option = function (method) { | ||
return "option" + (isOptionRequired ? '' : '?') + ": {" + reqData(method) + query(method) + reqHeaders(method) + " config?: T }"; | ||
return "option" + (isOptionRequired ? '' : '?') + ": {" + reqBody(method) + query(method) + reqHeaders(method) + " config?: T }"; | ||
}; | ||
var request = function () { | ||
return ", option" + (!typeInfo.reqData | ||
return ", option" + (!typeInfo.reqBody | ||
? '' | ||
: typeInfo.reqType | ||
? ", '" + typeInfo.reqType.value + "'" | ||
: typeInfo.reqData && /^(ArrayBuffer|Blob|string)$/.test(typeInfo.reqData.value) | ||
? ", '" + typeInfo.reqData.value + "'" | ||
: typeInfo.reqFormat | ||
? ", '" + typeInfo.reqFormat.value + "'" | ||
: typeInfo.reqBody && /^(ArrayBuffer|Blob|string)$/.test(typeInfo.reqBody.value) | ||
? ", '" + typeInfo.reqBody.value + "'" | ||
: ''); | ||
}; | ||
var resData = function (method) { | ||
return "" + (typeInfo.resData ? importName + "['" + method + "']['resData']" : 'void'); | ||
var resBody = function (method) { | ||
return "" + (typeInfo.resBody ? importName + "['" + method + "']['resBody']" : 'void'); | ||
}; | ||
var resMethodName = function () { | ||
return !typeInfo.resData | ||
return !typeInfo.resBody | ||
? 'send' | ||
: { ArrayBuffer: 'arrayBuffer', Blob: 'blob', string: 'text', FormData: 'formData' }[typeInfo.resData.value] || 'json'; | ||
: { ArrayBuffer: 'arrayBuffer', Blob: 'blob', string: 'text', FormData: 'formData' }[typeInfo.resBody.value] || 'json'; | ||
}; | ||
@@ -68,3 +68,3 @@ var quotation = newUrl.includes('${') ? '`' : "'"; | ||
"(" + option(methodName) + ") =>", | ||
"client.fetch<" + resData(methodName) + resHeaders(methodName) + ">(prefix, " + quotation + newUrl + (trailingSlash ? '/' : '') + quotation + ", '" + methodName.toUpperCase() + "'" + request() + ")." + resMethodName() + "()" | ||
"client.fetch<" + resBody(methodName) + resHeaders(methodName) + ">(prefix, " + quotation + newUrl + (trailingSlash ? '/' : '') + quotation + ", '" + methodName.toUpperCase() + "'" + request() + ")." + resMethodName() + "()" | ||
]; | ||
@@ -71,0 +71,0 @@ chanks.push(indent + " " + methodName + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + methodName + ": async " + tmpChanks[0] + "\n" + indent + " (await " + tmpChanks[1] + ").data"); |
@@ -41,6 +41,6 @@ export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH' | 'OPTIONS'; | ||
reqHeaders?: any; | ||
reqType?: FormData | URLSearchParams | ArrayBuffer | Blob | string | any; | ||
reqData?: any; | ||
reqFormat?: FormData | URLSearchParams | ArrayBuffer | Blob | string | any; | ||
reqBody?: any; | ||
resHeaders?: any; | ||
resData?: any; | ||
resBody?: any; | ||
} | ||
@@ -47,0 +47,0 @@ export declare type AspidaMethods = { |
@@ -8,4 +8,4 @@ "use strict"; | ||
exports.default = (function (input, callback) { | ||
chokidar_1.default.watch(input, { ignoreInitial: true, ignored: /\/\$[^/]+\.(js|ts)$/ }).on('all', callback); | ||
chokidar_1.default.watch(input, { ignoreInitial: true, ignored: /\/\$[^/]+\.ts$/ }).on('all', callback); | ||
}); | ||
//# sourceMappingURL=watchInputDir.js.map |
{ | ||
"name": "aspida", | ||
"version": "0.13.0", | ||
"description": "Type safe HTTP client wrapper for the browser and node.js", | ||
"version": "0.14.0", | ||
"description": "TypeScript friendly HTTP client wrapper for the browser and node.js", | ||
"author": "m-mitsuhide <m.mitsuhide@amatelus.com>", | ||
@@ -29,4 +29,4 @@ "license": "MIT", | ||
"minimist": "^1.2.0", | ||
"ts-morph": "^6.0.2" | ||
"ts-morph": "^6.0.3" | ||
} | ||
} |
@@ -37,3 +37,3 @@ | aspida | [aspida-mock] | [openapi2aspida] | [pathpida] | [@aspida/axios] | [@aspida/ky] | [@aspida/fetch] | | ||
<br /> | ||
<p align="center">Type safe HTTP client wrapper for the browser and node.js.</p> | ||
<p align="center">TypeScript friendly HTTP client wrapper for the browser and node.js.</p> | ||
<div align="center"> | ||
@@ -48,4 +48,4 @@ <a href="https://github.com/aspidajs/aspida/tree/master/packages/aspida#readme">🇺🇸English</a> | | ||
- Path, URL query, header, body, and response can all be type safe | ||
- FormData / URLSearchParams content can also be type safe | ||
- Path, URL query, header, body, and response can all specify the type | ||
- FormData / URLSearchParams content can also specify the type | ||
- HTTP client supports axios / ky / ky-universal / fetch | ||
@@ -106,11 +106,11 @@ - Path definition is the same naming convention as Nuxt.js pages | ||
resData: User[] | ||
resBody: User[] | ||
} | ||
post: { | ||
reqData: { | ||
reqBody: { | ||
name: string | ||
} | ||
resData: User | ||
resBody: User | ||
} | ||
@@ -136,11 +136,11 @@ } | ||
get: { | ||
resData: User | ||
resBody: User | ||
} | ||
put: { | ||
reqData: { | ||
reqBody: { | ||
name: string | ||
} | ||
resData: User | ||
resBody: User | ||
} | ||
@@ -231,5 +231,5 @@ } | ||
post: { | ||
reqType: FormData | ||
reqFormat: FormData | ||
reqData: { | ||
reqBody: { | ||
name: string | ||
@@ -239,3 +239,3 @@ icon: ArrayBuffer | ||
resData: { | ||
resBody: { | ||
id: number | ||
@@ -278,9 +278,9 @@ name: string | ||
post: { | ||
reqType: URLSearchParams | ||
reqFormat: URLSearchParams | ||
reqData: { | ||
reqBody: { | ||
name: string | ||
} | ||
resData: { | ||
resBody: { | ||
id: number | ||
@@ -321,3 +321,3 @@ name: string | ||
resData: ArrayBuffer | ||
resBody: ArrayBuffer | ||
} | ||
@@ -324,0 +324,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51140
Updatedts-morph@^6.0.3