@retter/rio-generator
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -24,3 +24,3 @@ "use strict"; | ||
var getInstanceOutputType = getInstanceOutputTypeA || getInstanceOutputTypeB || 'any'; | ||
return ("\n/** " + (template.description || classId + ' Class') + " */\nexport class " + classId + " {\n private readonly _rdk: RDK\n private readonly lookupKey?: { name: string; value: string }\n public readonly instanceId?: string\n public isNewInstance?: boolean\n public _response?: " + getInstanceOutputType + "\n\n /**\n * use this constructor if you know the instance id.\n * @param {string} instanceId - instance id\n * @returns {" + classId + "}\n */\n public constructor(instanceId: string);\n /**\n * use this constructor if you know only the look up key.\n * @param {string} name - look up key name\n * @param {string} value - look up key value\n * @returns {" + classId + "}\n */\n public constructor(name: string, value: string);\n public constructor(...args: string[]) {\n this.isNewInstance = false\n this._rdk = new RDK()\n if (args.length === 0 || args.length > 2) {\n throw new Error('Invalid number of arguments.');\n }\n if (args.length === 2) this.lookupKey = { name: args[0], value: args[1] }\n else this.instanceId = args[0]\n }\n\n get rdk() { return this._rdk }\n\n /**\n * Gets a cloud object instance or creates new one\n * @param {RetterRequest<" + utils_1.capitalizeFirstLetter(getInstanceInputType) + ">} options - instance options\n * @returns {Promise<" + classId + ">}\n */\n public static async getInstance(options?: RetterRequest<" + utils_1.capitalizeFirstLetter(getInstanceInputType) + ">): Promise<" + classId + "> {\n const rdk = new RDK()\n const result = await rdk.getInstance({\n ...options,\n classId: '" + classId + "',\n })\n if (result && 200 <= result.statusCode && result.statusCode < 300) {\n const _instance = new " + classId + "(result.body.instanceId)\n _instance.isNewInstance = !!result.body.newInstance\n _instance._response = result.body.response\n return _instance\n }\n\n throw new Error(result?.body?.message || 'failed')\n }\n\n " + methods.join('\n\n') + "\n}\n ").trim(); | ||
return ("\n/** " + (template.description || classId + ' Class') + " */\nexport class " + classId + " {\n private readonly _rdk: RDK\n private readonly lookupKey?: { name: string; value: string }\n public readonly instanceId?: string\n public isNewInstance?: boolean\n public _response?: " + getInstanceOutputType + "\n\n /**\n * use this constructor if you know the instance id.\n * @param {string} instanceId - instance id\n * @returns {" + classId + "}\n */\n public constructor(instanceId: string);\n /**\n * use this constructor if you know only the look up key.\n * @param {string} name - look up key name\n * @param {string} value - look up key value\n * @returns {" + classId + "}\n */\n public constructor(name: string, value: string);\n public constructor(...args: string[]) {\n this.isNewInstance = false\n this._rdk = new RDK()\n if (args.length === 0 || args.length > 2) {\n throw new Error('Invalid number of arguments.');\n }\n if (args.length === 2) this.lookupKey = { name: args[0], value: args[1] }\n else this.instanceId = args[0]\n }\n\n get rdk() { return this._rdk }\n\n /**\n * Gets a cloud object instance or creates new one\n * @param {RetterRequest<" + utils_1.capitalizeFirstLetter(getInstanceInputType) + ">} options - instance options\n * @returns {Promise<" + classId + ">}\n */\n public static async getInstance(options?: RetterRequest<" + utils_1.capitalizeFirstLetter(getInstanceInputType) + ">): Promise<" + classId + "> {\n const rdk = new RDK()\n const result = await rdk.getInstance({\n ...options,\n classId: '" + classId + "',\n })\n if (result && 200 <= result.statusCode && result.statusCode < 300) {\n const _instance = new " + classId + "(result.body.instanceId)\n _instance.isNewInstance = !!result.body.newInstance\n _instance._response = result.body.response\n return _instance\n }\n\n throw new Error(result?.body?.message || (typeof result?.body?.error === 'string' ? result?.body?.error : undefined) || 'failed')\n }\n\n " + methods.join('\n\n') + "\n}\n ").trim(); | ||
} | ||
@@ -27,0 +27,0 @@ exports.renderClass = renderClass; |
{ | ||
"name": "@retter/rio-generator", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "retter io proxy class helper generator", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -89,3 +89,3 @@ import YAML from 'yaml' | ||
throw new Error(result?.body?.message || 'failed') | ||
throw new Error(result?.body?.message || (typeof result?.body?.error === 'string' ? result?.body?.error : undefined) || 'failed') | ||
} | ||
@@ -92,0 +92,0 @@ |
Sorry, the diff of this file is not supported yet
107671