From 3852a6afbc24cb92bae165a1fee10612eea2f738 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 21 Sep 2023 16:01:06 +0900 Subject: [PATCH 1/3] docs: remove module docs --- src/controllers/appController.ts | 44 -------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/controllers/appController.ts b/src/controllers/appController.ts index 8a65579..4fcf85b 100644 --- a/src/controllers/appController.ts +++ b/src/controllers/appController.ts @@ -15,13 +15,6 @@ export default class AppController { return AppController.instance; } - /** - * Create App for your AI Service on AI Network. - * @param {string} appName - The name of app you will create. - * @param {TriggerFunctionUrlMap} functioniUrls - The urls of trigger function you set. - * @param {setDefaultFlag} setDefaultFlag - Set true which you wan to set config as default. - * @returns Result of transaction. - */ async createApp({ appName, serviceUrl, billingConfig }: createAppConfig) { const setRuleOps: SetOperation[] = []; const setFunctionOps: SetOperation[] = []; @@ -54,33 +47,16 @@ export default class AppController { return await this.ain.sendTransaction(txBody); } - /** - * Set billing config to app. - * @param {string} appName - * @param {appBillingConfig} config - The configuration of your app's billing. - * @returns Result of transaction. - */ async setAppBillingConfig(appName: string, config: appBillingConfig) { const setConfigOp = this.buildSetAppBillingConfigOp(appName, config); const txBody = buildTxBody(setConfigOp); return await this.ain.sendTransaction(txBody); } - /** - * Get billing config of app - * @param {string} appName - * @returns {Promise} - */ async getBillingConfig(appName: string): Promise { return await this.ain.getValue(Path.app(appName).billingConfig()); } - /** - * Set trigger function to app. - * @param {string} appName - * @param {setTriggerFunctionParam[]} functions - * @returns Result of transaction. - */ async setTriggerFunctions(appName: string, functions: setTriggerFunctionParm[]) { const setFunctionOps: SetOperation[] = []; for (const param of Object.values(functions)) { @@ -97,12 +73,6 @@ export default class AppController { return await this.ain.sendTransaction(txBody); } - /** - * Set rules to app. - * @param {string} appName - * @param {setRuleParam} rules - * @returns Result of transaction. - */ async setRules(appName: string, rules: setRuleParam[]) { const setRuleOps: SetOperation[] = []; for (const rule of Object.values(rules)) { @@ -133,26 +103,12 @@ export default class AppController { return await this.ain.sendTransaction(txBody); } - /** - * Remove admin on app. - * @param {string} appName - * @param {string} userAddress - * @returns Result of transaction. - */ async deleteAdmin(appName: string, userAddress: string) { const op = this.buildSetAdminOp(appName, userAddress, true); const txBody = buildTxBody(op); return await this.ain.sendTransaction(txBody); } - /** - * Check cost of request and check if account can pay. You should use this function before send or handle request. - * If you don't set address, it will use default account's address. - * @param {string} appName - App name you want to request service to. - * @param {string} prompt - Data you want to request to service . - * @param {string=} userAddress - Address of account you want to check balance. You should set default account if you don't provide address. - * @returns Result cost of service. It throws error when user can't pay. - */ async checkCostAndBalance(appName: string, value: string) { const requesterAddress = this.ain.getAddress(); const billingConfig = (await this.getBillingConfig(appName)); From 852e999532e7dc35bc99be0e71e5bda1d9e03fd5 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 21 Sep 2023 16:06:50 +0900 Subject: [PATCH 2/3] docs: ainize --- src/ainize.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ainize.ts b/src/ainize.ts index 7af0614..b943ab9 100644 --- a/src/ainize.ts +++ b/src/ainize.ts @@ -7,6 +7,7 @@ import Model from "./model"; import { deployConfig } from "./types/type"; import AinModule from "./ain"; import Internal from "./internal"; +import { Account } from "@ainblockchain/ain-util"; export default class Ainize { private cache: NodeCache; @@ -23,16 +24,27 @@ export default class Ainize { this.internal = new Internal(); } - static createAinAccount () { + /** + * Create a new AI Network account. + * @returns {Account} created account. + */ + static createAinAccount (): Account { return AinModule.getInstance().createAccount(); } + /** + * Login of the ainize using AI Network account private key. + * @param {string} privateKey + */ async login(privateKey: string) { this.ain.setDefaultAccount(privateKey); await this.handler.connect(); console.log('login success! address:', this.ain.getAddress()); } + /** + * Logout of the ainize. + */ async logout() { this.ain.removeDefaultAccount(); await this.handler.disconnect(); @@ -48,6 +60,11 @@ export default class Ainize { } // FIXME(yoojin): add config type and change param type. + /** + * Deploy AI model container. + * @param {deployConfig} deployConfig Set configuration for container. modelName, billingConfig, etc. + * @returns {Model} Control object of deployed model. + */ async deploy({modelName, billingConfig, serviceUrl}: deployConfig): Promise { // TODO(yoojin, woojae): Deploy container, advanced. const deployer = this.ain.getAddress(); @@ -66,6 +83,11 @@ export default class Ainize { return this.model(modelName); } + /** + * Get deployed model. + * @param modelName + * @returns {Model} Control object of deployed model. + */ async model(modelName: string): Promise { const modelPath = Path.app(modelName).root(); const modelData = await this.ain.getValue(modelPath); From f43e185d6a3af93e2c1e9cacaba5ae2a310467fc Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 21 Sep 2023 17:08:11 +0900 Subject: [PATCH 3/3] docs: fix expression --- src/ainize.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ainize.ts b/src/ainize.ts index 362c74c..1570f84 100644 --- a/src/ainize.ts +++ b/src/ainize.ts @@ -33,7 +33,7 @@ export default class Ainize { } /** - * Login of the ainize using AI Network account private key. + * Login to ainize using AI Network account private key. * @param {string} privateKey */ async login(privateKey: string) { @@ -43,7 +43,7 @@ export default class Ainize { } /** - * Logout of the ainize. + * Logout from ainize. */ async logout() { this.ain.removeDefaultAccount(); @@ -62,8 +62,8 @@ export default class Ainize { // FIXME(yoojin): add config type and change param type. /** * Deploy AI model container. - * @param {deployConfig} deployConfig Set configuration for container. modelName, billingConfig, etc. - * @returns {Model} Control object of deployed model. + * @param {deployConfig} deployConfig Set configuration for setting container. modelName, billingConfig, etc. + * @returns {Model} Deployed model object. */ // TODO(yoojin, woojae): Deploy container, advanced. async deploy({modelName, billingConfig, serviceUrl}: deployConfig): Promise { @@ -94,7 +94,7 @@ export default class Ainize { /** * Get deployed model. * @param modelName - * @returns {Model} Control object of deployed model. + * @returns {Model} Deployed model object. */ async model(modelName: string): Promise { const modelPath = Path.app(modelName).root();