mpserverless-sdk-core
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -8,2 +8,5 @@ export default class Client { | ||
}>; | ||
invokeWithPageExea(openApiName: string, params: { | ||
[key: string]: any; | ||
}): Promise<string>; | ||
invokePre(preFunctionName: string, openApiName: string, params: { | ||
@@ -10,0 +13,0 @@ [key: string]: any; |
@@ -9,2 +9,5 @@ "use strict"; | ||
} | ||
async invokeWithPageExea(openApiName, params) { | ||
throw new Error('Un-implemented!'); | ||
} | ||
async invokePre(preFunctionName, openApiName, params) { | ||
@@ -11,0 +14,0 @@ throw new Error('Un-implemented!'); |
@@ -40,2 +40,7 @@ import Client from './client'; | ||
init(mpserverless: Serverless, config?: Config): void; | ||
getInvokeArgs(method: string, params: { | ||
[key: string]: any; | ||
}): FunctionRequest<{ | ||
[key: string]: any; | ||
}>; | ||
invoke(openApiName: string, params: { | ||
@@ -46,2 +51,5 @@ [key: string]: any; | ||
}>; | ||
invokeWithPageExe(openApiName: string, params: { | ||
[key: string]: any; | ||
}): Promise<string>; | ||
invokePre(preFunctionName: string, openApiName: string, params: { | ||
@@ -48,0 +56,0 @@ [key: string]: any; |
@@ -12,3 +12,3 @@ "use strict"; | ||
} | ||
async invoke(openApiName, params) { | ||
getInvokeArgs(method, params) { | ||
// TODO: 补全出错信息 | ||
@@ -20,3 +20,3 @@ if (!this.invoker) { | ||
const args = { | ||
method: openApiName, | ||
method, | ||
params: Object.assign({ $config: {} }, params) | ||
@@ -30,14 +30,16 @@ }; | ||
} | ||
return args; | ||
} | ||
async invoke(openApiName, params) { | ||
const args = this.getInvokeArgs(openApiName, params); | ||
const response = await this.invoker.function.invoke('alipay-openapi', args); | ||
return response.result; | ||
} | ||
async invokeWithPageExe(openApiName, params) { | ||
const args = this.getInvokeArgs(openApiName, params); | ||
const response = await this.invoker.function.invoke('alipay-openapi', args); | ||
return response.result; | ||
} | ||
async invokePre(preFunctionName, openApiName, params) { | ||
// TODO: 预置云函数支持 $config 吗? | ||
if (!this.invoker) { | ||
throw new Error('invoker is not set, please call init(mpserverless: Serverless, config: Config) first.'); | ||
} | ||
const args = { | ||
method: openApiName, | ||
params, | ||
}; | ||
const args = this.getInvokeArgs(openApiName, params); | ||
const response = await this.invoker.function.invoke(preFunctionName, args); | ||
@@ -44,0 +46,0 @@ return response.result; |
{ | ||
"name": "mpserverless-sdk-core", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Alipay mini program Serverless SDK Core", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -16,2 +16,6 @@ // This file is auto-generated, don't edit it | ||
async invokeWithPageExea(openApiName: string, params: {[key: string]: any}): Promise<string> { | ||
throw new Error('Un-implemented!'); | ||
} | ||
async invokePre(preFunctionName: string, openApiName: string, params: {[key: string]: any}): Promise<{[key: string]: any}> { | ||
@@ -18,0 +22,0 @@ throw new Error('Un-implemented!'); |
@@ -55,3 +55,3 @@ import Client from './client'; | ||
async invoke(openApiName: string, params: {[key: string]: any}): Promise<{[key: string]: any}> { | ||
getInvokeArgs(method: string, params: {[key: string]: any}): FunctionRequest<{[key: string]: any}> { | ||
// TODO: 补全出错信息 | ||
@@ -66,3 +66,3 @@ if (!this.invoker) { | ||
const args = { | ||
method: openApiName, | ||
method, | ||
params: { | ||
@@ -81,2 +81,7 @@ $config: <Config>{}, // openapi 的私有参数,默认值 {} | ||
} | ||
return args; | ||
} | ||
async invoke(openApiName: string, params: {[key: string]: any}): Promise<{[key: string]: any}> { | ||
const args = this.getInvokeArgs(openApiName, params); | ||
const response = await this.invoker.function.invoke('alipay-openapi', args); | ||
@@ -86,11 +91,11 @@ return response.result; | ||
async invokeWithPageExe(openApiName: string, params: {[key: string]: any}): Promise<string> { | ||
const args = this.getInvokeArgs(openApiName, params); | ||
const response = await this.invoker.function.invoke('alipay-openapi', args); | ||
return <string> response.result; | ||
} | ||
async invokePre(preFunctionName: string, openApiName: string, params: { [key: string]: any }): Promise<{[key: string]: any }> { | ||
// TODO: 预置云函数支持 $config 吗? | ||
if (!this.invoker) { | ||
throw new Error('invoker is not set, please call init(mpserverless: Serverless, config: Config) first.'); | ||
} | ||
const args = { | ||
method: openApiName, | ||
params, | ||
}; | ||
const args = this.getInvokeArgs(openApiName, params); | ||
const response = await this.invoker.function.invoke(preFunctionName, args); | ||
@@ -97,0 +102,0 @@ return response.result; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9838
236