@retter/rio-generator
Advanced tools
Comparing version 1.2.11 to 1.2.12
@@ -13,3 +13,3 @@ const generator = require('./dist/index').generator | ||
'preAuthorizer: index.preAuthorizer\ninit: \n inputModel: GetMsisdnAuthInput\n handler: index.init\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: sendOtp\n tag: otp\n sync: true\n steps:\n - id: default\n handler: index.sendOtp\n\n - method: validateOtp\n inputModel: ValidateOtpInput\n outputModel: ValidateOtpOutput\n tag: otp\n sync: true\n steps:\n - id: default\n handler: index.validateOtp\n\n - method: signup\n tag: signup\n inputModel: SignUpInput\n sync: true\n steps:\n - id: default\n handler: index.signup\n', | ||
Places: 'getInstanceId: index.getInstanceId\nmethods:\n - method: getPlaces\n sync: true\n readonly: true\n steps:\n - id: default\n handler: index.getPlaces\n', | ||
Places: 'getInstanceId: index.getInstanceId\nmethods:\n - method: getPlaces\n sync: true\n queryStringModel: Address\n steps:\n - id: default\n handler: index.getPlaces\n', | ||
Product: | ||
@@ -551,5 +551,5 @@ 'preAuthorizer: index.preAuthorizer\ninit: product.upsert\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: get\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: product.getProduct\n - method: update\n tag: update\n sync: true\n steps:\n - id: default\n handler: product.upsert\n - method: uploadImage\n input: UploadImageInput\n tag: test\n sync: true\n steps:\n - id: default\n handler: product.uploadImage\n inputModel: UploadImageInput\n - method: getImage\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: product.getImage\n', | ||
}, | ||
'typescript-client', | ||
'typescript', | ||
) | ||
console.log(code) | ||
})() |
@@ -16,3 +16,5 @@ "use strict"; | ||
var description = method.description || 'calls ' + methodName + ' on ' + classId; | ||
methods.push(("\n/**\n * " + description + "\n * @param {" + utils_1.capitalizeFirstLetter(method.inputModel) + "} body - payload\n * @param {RDKOptions} options - other method call parameters\n * @returns {Promise<RetterResponse<" + utils_1.capitalizeFirstLetter(method.outputModel) + ">>}\n */\npublic async " + methodName + "(body?: " + utils_1.capitalizeFirstLetter(method.inputModel) + ", options?: RDKOptions): Promise<RetterResponse<" + utils_1.capitalizeFirstLetter(method.outputModel) + "> | undefined> {\n return await this._rdk.methodCall({\n ...options,\n classId: '" + classId + "',\n instanceId: this.instanceId,\n lookupKey: this.lookupKey,\n methodName: '" + methodName + "',\n body,\n })\n}\n ").trim()); | ||
var queryStringModel = utils_1.capitalizeFirstLetter(method.queryStringModel); | ||
queryStringModel = queryStringModel !== 'any' ? "<" + queryStringModel + ">" : ''; | ||
methods.push(("\n/**\n * " + description + "\n * @param {" + utils_1.capitalizeFirstLetter(method.inputModel) + "} body - payload\n * @param {RDKOptions} options - other method call parameters\n * @returns {Promise<RetterResponse<" + utils_1.capitalizeFirstLetter(method.outputModel) + ">>}\n */\npublic async " + methodName + "(body?: " + utils_1.capitalizeFirstLetter(method.inputModel) + ", options?: RDKOptions" + queryStringModel + "): Promise<RetterResponse<" + utils_1.capitalizeFirstLetter(method.outputModel) + "> | undefined> {\n return await this._rdk.methodCall({\n ...options,\n classId: '" + classId + "',\n instanceId: this.instanceId,\n lookupKey: this.lookupKey,\n methodName: '" + methodName + "',\n body,\n })\n}\n ").trim()); | ||
} | ||
@@ -28,3 +30,3 @@ var getInstanceInputType = template.init && typeof template.init !== 'string' ? template.init.inputModel : 'any'; | ||
var blocks = Object.keys(classes).map(function (classId) { return renderClass(classId, classes[classId]); }); | ||
return "\n// This is an auto generated file!\n\nimport RDK, { KeyValueString, GetInstance, CloudObjectResponse } from '@retter/rdk'\n\ninterface RetterRequest<T> extends Omit<GetInstance, 'classId'|'body'> {\n body?: T\n}\n\ninterface RetterResponse<T> extends CloudObjectResponse {\n body?: T\n}\n\n" + interfaces.trim() + "\n\nexport interface RDKOptions {\n httpMethod?: string\n queryStringParams?: KeyValueString\n headers?: KeyValueString\n}\n\nexport namespace Classes {\n " + blocks.reduce(function (f, i) { | ||
return "\n// This is an auto generated file!\n\nimport RDK, { KeyValueString, GetInstance, CloudObjectResponse } from '@retter/rdk'\n\ninterface RetterRequest<T> extends Omit<GetInstance, 'classId'|'body'> {\n body?: T\n}\n\ninterface RetterResponse<T> extends CloudObjectResponse {\n body?: T\n}\n\n" + interfaces.trim() + "\n\nexport interface RDKOptions<T = KeyValueString> {\n httpMethod?: string\n queryStringParams?: T\n headers?: KeyValueString\n}\n\nexport namespace Classes {\n " + blocks.reduce(function (f, i) { | ||
f = f + '\n\n' + i; | ||
@@ -31,0 +33,0 @@ return f.trim(); |
{ | ||
"name": "@retter/rio-generator", | ||
"version": "1.2.11", | ||
"version": "1.2.12", | ||
"description": "retter io proxy class helper generator", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -10,2 +10,4 @@ import YAML from 'yaml' | ||
const description = method.description || 'calls ' + methodName + ' on ' + classId | ||
let queryStringModel = capitalizeFirstLetter(method.queryStringModel) | ||
queryStringModel = queryStringModel !== 'any' ? `<${queryStringModel}>` : '' | ||
methods.push( | ||
@@ -19,3 +21,3 @@ ` | ||
*/ | ||
public async ${methodName}(body?: ${capitalizeFirstLetter(method.inputModel)}, options?: RDKOptions): Promise<RetterResponse<${capitalizeFirstLetter(method.outputModel)}> | undefined> { | ||
public async ${methodName}(body?: ${capitalizeFirstLetter(method.inputModel)}, options?: RDKOptions${queryStringModel}): Promise<RetterResponse<${capitalizeFirstLetter(method.outputModel)}> | undefined> { | ||
return await this._rdk.methodCall({ | ||
@@ -114,5 +116,5 @@ ...options, | ||
export interface RDKOptions { | ||
export interface RDKOptions<T = KeyValueString> { | ||
httpMethod?: string | ||
queryStringParams?: KeyValueString | ||
queryStringParams?: T | ||
headers?: KeyValueString | ||
@@ -119,0 +121,0 @@ } |
Sorry, the diff of this file is not supported yet
105801
1578