zova-module-a-api 5.1.7 → 5.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bean.apiBase.d.ts","sourceRoot":"","sources":["../../src/bean/bean.apiBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAW,MAAM,MAAM,CAAC;AAGxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,qBAEa,WAAY,SAAQ,QAAQ;IACvC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAI1E,cAAc,
|
|
1
|
+
{"version":3,"file":"bean.apiBase.d.ts","sourceRoot":"","sources":["../../src/bean/bean.apiBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAW,MAAM,MAAM,CAAC;AAGxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,qBAEa,WAAY,SAAQ,QAAQ;IACvC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAI1E,cAAc,CACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,EAC3B,SAAS,CAAC,EAAE,aAAa,GACxB,kBAAkB;IAIrB,SAAS,CAAC,IAAI,EAAE,MAAM;CAcvB"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/bean/bean.apiBase.ts","../src/config/config.ts","../src/.metadata/this.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/api.ts"],"sourcesContent":["import type { AxiosRequestConfig } from 'axios';\n\nimport { BeanBase, TypeAuthToken, Virtual } from 'zova';\nimport { Bean } from 'zova-module-a-bean';\n\nimport type { IApiActionOptions } from '../types/api.js';\n\n@Bean()\n@Virtual()\nexport class BeanApiBase extends BeanBase {\n $pathTranslate(pathName: string, pathParams?: Record<string, any>): string {\n return this.sys.util.apiActionPathTranslate(pathName, pathParams);\n }\n\n $configPrepare(baseURL?: string
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/bean/bean.apiBase.ts","../src/config/config.ts","../src/.metadata/this.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/api.ts"],"sourcesContent":["import type { AxiosRequestConfig } from 'axios';\n\nimport { BeanBase, TypeAuthToken, Virtual } from 'zova';\nimport { Bean } from 'zova-module-a-bean';\n\nimport type { IApiActionOptions } from '../types/api.js';\n\n@Bean()\n@Virtual()\nexport class BeanApiBase extends BeanBase {\n $pathTranslate(pathName: string, pathParams?: Record<string, any>): string {\n return this.sys.util.apiActionPathTranslate(pathName, pathParams);\n }\n\n $configPrepare(\n baseURL?: string,\n options?: IApiActionOptions,\n authToken?: TypeAuthToken,\n ): AxiosRequestConfig {\n return this.sys.util.apiActionConfigPrepare(baseURL, options, authToken);\n }\n\n $formData(body: object) {\n const formData = new FormData();\n for (const key in body) {\n const value = body[key];\n if (Array.isArray(value)) {\n for (const item of value) {\n formData.append(key, item);\n }\n } else {\n formData.append(key, value);\n }\n }\n return formData;\n }\n}\n","import type { IBeanScopeRecord, ZovaSys } from 'zova';\n\nexport const config = (_sys: ZovaSys) => {\n return {\n defaultModuleApi: 'home-api' as keyof IBeanScopeRecord,\n };\n};\n","export const __ThisModule__ = 'a-api';\nexport { ScopeModuleAApi as ScopeModule } from './index.js';\n","import type { IModule } from '@cabloy/module-info';\nimport type {\n BeanBase,\n BeanContainer,\n IBeanScopeRecord,\n IMonkeyBeanInit,\n IMonkeyModule,\n} from 'zova';\n\nimport { appResource, BeanSimple, cast } from 'zova';\n\nimport type { ScopeModule } from './.metadata/this.js';\n\nimport { __ThisModule__ } from './.metadata/this.js';\n\nexport class Monkey extends BeanSimple implements IMonkeyModule, IMonkeyBeanInit {\n private _moduleSelf: IModule;\n private _defaultModuleApi: keyof IBeanScopeRecord;\n\n constructor(moduleSelf: IModule) {\n super();\n this._moduleSelf = moduleSelf;\n }\n\n async moduleLoading(_module: IModule) {}\n async moduleLoaded(module: IModule) {\n // load apis\n const promises: Promise<any>[] = [];\n promises.push(this._loadApis(module, 'api'));\n promises.push(this._loadApis(module, 'apiSchema'));\n await Promise.all(promises);\n // self\n if (this._moduleSelf === module) {\n const scopeSelf: ScopeModule = await this.bean.getScope(__ThisModule__);\n this._defaultModuleApi = scopeSelf.config.defaultModuleApi;\n await this.app.meta.module.use(this._defaultModuleApi);\n }\n }\n\n async beanInit(bean: BeanContainer, beanInstance: BeanBase) {\n const self = this;\n for (const sceneName of ['api', 'apiSchema']) {\n bean.defineProperty(beanInstance, `$${sceneName}`, {\n enumerable: false,\n configurable: true,\n get() {\n return cast(self.app.bean.scope(self._defaultModuleApi))[sceneName];\n },\n });\n }\n }\n\n private async _loadApis(module: IModule, sceneName: 'api' | 'apiSchema') {\n const onions = appResource.scenes[sceneName]?.[module.info.relativeName];\n if (!onions) return;\n const scope = this.bean.scope(module.info.relativeName as any) as any;\n const beanFullNames = Object.keys(onions);\n const promises: Promise<any>[] = [];\n for (const beanFullName of beanFullNames) {\n promises.push(this.bean._getBean(beanFullName as any, true));\n }\n const values = await Promise.all(promises);\n for (let index = 0; index < beanFullNames.length; index++) {\n const beanFullName = beanFullNames[index];\n const beanOptions = onions[beanFullName];\n scope[sceneName][beanOptions.name] = values[index];\n }\n }\n}\n","// eslint-disable\n/** bean: begin */\nexport * from '../bean/bean.apiBase.js';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-api' {\n \n}\n/** bean: end */\n/** bean: begin */\nimport { BeanApiBase } from '../bean/bean.apiBase.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-api.bean.apiBase': BeanApiBase;\n }\n}\n/** bean: end */\n/** config: begin */\nexport * from '../config/config.js';\nimport { config } from '../config/config.js';\n/** config: end */\n/** monkey: begin */\nexport * from '../monkey.js';\n/** monkey: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil, TypeModuleConfig } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleAApi extends BeanScopeBase {}\n\nexport interface ScopeModuleAApi {\n util: BeanScopeUtil;\nconfig: TypeModuleConfig<typeof config>;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-api': ScopeModuleAApi;\n }\n \n export interface IBeanScopeConfig {\n 'a-api': ReturnType<typeof config>;\n }\n\n \n\n \n}\n \n/** scope: end */\n","import { createBeanDecorator } from 'zova';\n\nexport function Api(): ClassDecorator {\n return createBeanDecorator('api', 'app');\n}\n\nexport function ApiMeta(): ClassDecorator {\n return createBeanDecorator('apiMeta', 'app');\n}\n\nexport function ApiSchema(): ClassDecorator {\n return createBeanDecorator('apiSchema', 'app');\n}\n"],"mappings":";;;AAAA,IAAA,QAAO,SAAO,OAAA;4EAKd,QAAO,SAAA,CAAA,EAAA,OAAA,WAAA,QAAA,WAAA,MAAA,WAAA,MAAA,oBAAA,SAAA;CAEN,eAAK,UAAA,YAAA;AACL,SAAQ,KAAA,IAAA,KAAA,uBAAA,UAAA,WAAA;;CAEP,eAAe,SAAS,SAAS,WAAW;AAC1C,SAAO,KAAK,IAAI,KAAK,uBAAuB,SAAS,SAAC,UAAW;;;EAGlE,MAAA,WAAa,IAAA,UAAA;AACZ,OAAA,MAAU,OAAM,MAAA;GAChB,MAAQ,QAAE,KAAA;AACV,OAAA,MAAY,QAAA,MAAa,C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;AChDR,IAAG,MAAO,OAAA;AAoBV,IAAA,mBAAA,OAAA,OAAA,EAAA,QAAA,SAAA,EACE,QAAQ,SACT,CAAC,EAAE,KAAA,SAAc,MAAC,SAAA,MAAA,wBAAA,cAAA,GAAA,IAAA,OAAA,IAAA;;;;;ACpBnB,QAAO,oBAAgB,OAAA,MAAe;;AAEtC,SAAA,UAAA;;;AAGA,SAAS,YAAmB;AAC5B,QAAA,oBAAA,aAAA,MAAA"}
|
package/dist/monkey.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monkey.d.ts","sourceRoot":"","sources":["../src/monkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"monkey.d.ts","sourceRoot":"","sources":["../src/monkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EAEb,eAAe,EACf,aAAa,EACd,MAAM,MAAM,CAAC;AAEd,OAAO,EAAe,UAAU,EAAQ,MAAM,MAAM,CAAC;AAMrD,qBAAa,MAAO,SAAQ,UAAW,YAAW,aAAa,EAAE,eAAe;IAC9E,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,iBAAiB,CAAyB;gBAEtC,UAAU,EAAE,OAAO;IAKzB,aAAa,CAAC,OAAO,EAAE,OAAO;IAC9B,YAAY,CAAC,MAAM,EAAE,OAAO;IAc5B,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ;YAa5C,SAAS;CAgBxB"}
|
package/package.json
CHANGED
package/src/bean/bean.apiBase.ts
CHANGED
|
@@ -12,7 +12,11 @@ export class BeanApiBase extends BeanBase {
|
|
|
12
12
|
return this.sys.util.apiActionPathTranslate(pathName, pathParams);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
$configPrepare(
|
|
15
|
+
$configPrepare(
|
|
16
|
+
baseURL?: string,
|
|
17
|
+
options?: IApiActionOptions,
|
|
18
|
+
authToken?: TypeAuthToken,
|
|
19
|
+
): AxiosRequestConfig {
|
|
16
20
|
return this.sys.util.apiActionConfigPrepare(baseURL, options, authToken);
|
|
17
21
|
}
|
|
18
22
|
|
package/src/monkey.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { IModule } from '@cabloy/module-info';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
BeanBase,
|
|
4
|
+
BeanContainer,
|
|
5
|
+
IBeanScopeRecord,
|
|
6
|
+
IMonkeyBeanInit,
|
|
7
|
+
IMonkeyModule,
|
|
8
|
+
} from 'zova';
|
|
3
9
|
|
|
4
10
|
import { appResource, BeanSimple, cast } from 'zova';
|
|
5
11
|
|