zova-module-a-fetch 5.1.8 → 5.1.10

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.fetch.d.ts","sourceRoot":"","sources":["../../src/bean/bean.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,QAAQ,EAAc,MAAM,MAAM,CAAC;AAG5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,QAAA,MAAM,WAAW,eAAwB,CAAC;AAE1C,MAAM,WAAW,SAAU,SAAQ,aAAa;CAAG;AAEnD,qBACa,SAAU,SAAQ,QAAQ;IACrC,OAAO,CAAC,SAAS,CAAkB;IAEnC,SAAS,CAAC,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;cAEvB,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB;IAWpD,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM;IAI9B,OAAO,CAAC,gBAAgB;CAwBzB"}
1
+ {"version":3,"file":"bean.fetch.d.ts","sourceRoot":"","sources":["../../src/bean/bean.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,QAAQ,EAAc,MAAM,MAAM,CAAC;AAG5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,QAAA,MAAM,WAAW,eAAwB,CAAC;AAE1C,MAAM,WAAW,SAAU,SAAQ,aAAa;CAAG;AAEnD,qBACa,SAAU,SAAQ,QAAQ;IACrC,OAAO,CAAC,SAAS,CAAkB;IAEnC,SAAS,CAAC,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;cAEvB,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB;IAgBpD,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM;IAI9B,OAAO,CAAC,gBAAgB;CAwBzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"bean.interceptorBase.d.ts","sourceRoot":"","sources":["../../src/bean/bean.interceptorBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAW,MAAM,MAAM,CAAC;AAGzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAEa,mBAAmB,CAAC,CAAC,SAAS,4BAA4B,GAAG,4BAA4B,CAAE,SAAQ,QAAQ;IACtH,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAEV,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;CAK7C"}
1
+ {"version":3,"file":"bean.interceptorBase.d.ts","sourceRoot":"","sources":["../../src/bean/bean.interceptorBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAW,MAAM,MAAM,CAAC;AAGzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAEa,mBAAmB,CAC9B,CAAC,SAAS,4BAA4B,GAAG,4BAA4B,CACrE,SAAQ,QAAQ;IAChB,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAEV,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;CAK7C"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/service/composer.ts","../src/bean/bean.fetch.ts","../src/bean/bean.interceptorBase.ts","../src/config/config.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/const.ts","../src/lib/interceptor.ts"],"sourcesContent":["import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';\n\nimport { BeanBase, cast, deepExtend, SymbolErrorInstanceInfo, Use } from 'zova';\nimport { IOnionItem, IOnionSlice, SysOnion, TypeComposer } from 'zova-module-a-bean';\nimport { Service } from 'zova-module-a-bean';\n\nimport type { BeanFetch } from '../bean/bean.fetch.js';\nimport type {\n IDecoratorInterceptorOptions,\n IInterceptorRecord,\n IInterceptorRequest,\n IInterceptorRequestError,\n IInterceptorResponse,\n IInterceptorResponseError,\n} from '../types/interceptor.js';\n\n@Service()\nexport class ServiceComposer extends BeanBase {\n protected $beanFetch: BeanFetch;\n @Use()\n $$sysOnion: SysOnion;\n\n private _composerRequest: TypeComposer;\n private _composerRequestError: TypeComposer;\n private _composerResponse: TypeComposer;\n private _composerResponseError: TypeComposer;\n\n protected async __init__(\n beanFetch: BeanFetch,\n onionItems?:\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>[],\n ) {\n this.$beanFetch = beanFetch;\n await this._createComposer(onionItems);\n }\n\n public executeRequest(config: AxiosRequestConfig) {\n return this._composerRequest(config);\n }\n\n public executeRequestError(error: AxiosError) {\n return this._composerRequestError(error);\n }\n\n public executeResponse(response: AxiosResponse) {\n return this._composerResponse(response);\n }\n\n public async executeResponseError(error: AxiosError) {\n error = await this._composerResponseError(error);\n if (error instanceof Error) {\n error[SymbolErrorInstanceInfo] = {\n instance: this.ctx.instance,\n info: 'executeResponseError',\n };\n }\n return error;\n }\n\n private async _createComposer(\n onionItems?:\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>[],\n ) {\n // onionSlices\n let onionSlices: IOnionSlice<IDecoratorInterceptorOptions, keyof IInterceptorRecord>[];\n if (onionItems) {\n onionSlices = await this.$$sysOnion.interceptor.loadOnions(onionItems);\n } else {\n onionSlices = await this.$$sysOnion.interceptor.loadOnionsFromPackage();\n }\n // create interceptors\n for (const onionSlice of onionSlices) {\n onionSlice.beanInstance = await this.bean._newBean(onionSlice.beanFullName as any, true, this.$beanFetch, onionSlice.options);\n }\n // compose\n this._composerRequest = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, config: AxiosRequestConfig, next) => {\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config.url)) {\n return next(config);\n }\n // execute\n const beanInstance = cast<IInterceptorRequest>(onionSlice.beanInstance);\n if (!beanInstance.onRequest) return next(config);\n return beanInstance.onRequest(config, options, next as any);\n });\n this._composerRequestError = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, error: AxiosError, next) => {\n const config = error.config;\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {\n return next(error);\n }\n // execute\n const beanInstance = cast<IInterceptorRequestError>(onionSlice.beanInstance);\n if (!beanInstance.onRequestError) return next(error);\n return beanInstance.onRequestError(error, options, next as any);\n });\n this._composerResponse = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, response: AxiosResponse, next) => {\n const config = response.config;\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {\n return next(response);\n }\n // execute\n const beanInstance = cast<IInterceptorResponse>(onionSlice.beanInstance);\n if (!beanInstance.onResponse) return next(response);\n return beanInstance.onResponse(response, options, next as any);\n });\n this._composerResponseError = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, error: AxiosError, next) => {\n const config = error.config;\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {\n return next(error);\n }\n // execute\n const beanInstance = cast<IInterceptorResponseError>(onionSlice.beanInstance);\n if (!beanInstance.onResponseError) return next(error);\n return beanInstance.onResponseError(error, options, next as any);\n });\n }\n\n private _combineOnionOptions(item: IOnionSlice<IDecoratorInterceptorOptions, keyof IInterceptorRecord>, config?: AxiosRequestConfig) {\n // options: dynamic\n let optionsDynamic;\n if (config?.interceptors) {\n optionsDynamic = config?.interceptors[item.name];\n }\n // final options\n const options = optionsDynamic ? deepExtend({}, item.options, optionsDynamic) : item.options;\n // ok\n return options;\n }\n}\n","import type { AxiosInstance } from 'axios';\n\nimport axios, { Axios } from 'axios';\nimport { markRaw } from 'vue';\nimport { BeanBase, deepExtend } from 'zova';\nimport { Bean } from 'zova-module-a-bean';\n\nimport type { IBeanFetchOptions } from '../types/interceptor.js';\n\nimport { ServiceComposer } from '../service/composer.js';\n\nconst SymbolFetch = Symbol('SymbolFetch');\n\nexport interface BeanFetch extends AxiosInstance {}\n\n@Bean()\nexport class BeanFetch extends BeanBase {\n private _composer: ServiceComposer;\n\n protected [SymbolFetch]: AxiosInstance;\n\n protected async __init__(options?: IBeanFetchOptions) {\n patchAxios(Axios);\n // axiosConfig\n const axiosConfig = deepExtend({}, { baseURL: this.sys.util.getApiBaseURL() }, this.scope.config.axios.config, options?.axiosConfig);\n // composer\n this._composer = await this.bean._newBean(ServiceComposer, true, this, options?.onionItems);\n // axios\n this[SymbolFetch] = markRaw(axios.create(axiosConfig));\n this._addInterceptors(this[SymbolFetch]);\n }\n\n protected __get__(prop: string) {\n return this[SymbolFetch] && this[SymbolFetch][prop];\n }\n\n private _addInterceptors(api: AxiosInstance) {\n // request\n api.interceptors.request.use(\n async config => {\n return await this._composer.executeRequest(config);\n },\n async (_error: any) => {\n if (!(_error instanceof Error)) return Promise.reject(_error);\n const error = await this._composer.executeRequestError(_error as any);\n return Promise.reject(error);\n },\n );\n // response\n api.interceptors.response.use(\n async response => {\n return await this._composer.executeResponse(response);\n },\n async (_error: any) => {\n if (!(_error instanceof Error)) return Promise.reject(_error);\n const error = await this._composer.executeResponseError(_error as any);\n return Promise.reject(error);\n },\n );\n }\n}\n\nfunction patchAxios(_Axios: any) {\n if (_Axios.__requestPatched) return;\n _Axios.__requestPatched = true;\n const requestPrev: Function = _Axios.prototype.request;\n _Axios.prototype.request = async function (...args: any[]) {\n try {\n return await requestPrev.call(this, ...args);\n } catch (err) {\n if (err instanceof Error) throw err;\n return err;\n }\n };\n}\n","import { BeanBase, Virtual } from 'zova';\nimport { Bean } from 'zova-module-a-bean';\n\nimport type { IDecoratorInterceptorOptions } from '../types/interceptor.js';\nimport type { BeanFetch } from './bean.fetch.js';\n\n@Bean()\n@Virtual()\nexport class BeanInterceptorBase<T extends IDecoratorInterceptorOptions = IDecoratorInterceptorOptions> extends BeanBase {\n protected $beanFetch: BeanFetch;\n protected $options: T;\n\n constructor(beanFetch: BeanFetch, options: T) {\n super();\n this.$beanFetch = beanFetch;\n this.$options = options;\n }\n}\n","import type { CreateAxiosDefaults } from 'axios';\nimport type { ZovaSys } from 'zova';\n\nexport const config = (_sys: ZovaSys) => {\n return {\n axios: {\n config: {} as CreateAxiosDefaults,\n },\n };\n};\n","import type { BeanBase, BeanContainer, IMonkeyAppInitialize, IMonkeyBeanInit } from 'zova';\n\nimport { BeanSimple } from 'zova';\n\nimport { BeanFetch } from './bean/bean.fetch.js';\n\nexport class Monkey extends BeanSimple implements IMonkeyAppInitialize, IMonkeyBeanInit {\n async appInitialize() {\n // $fetch: should in appInitialize, because should init many interceptors\n this.app.meta.$fetch = await this.bean._getBean(BeanFetch, false);\n }\n\n async beanInit(bean: BeanContainer, beanInstance: BeanBase) {\n const self = this;\n // $fetch\n bean.defineProperty(beanInstance, '$fetch', {\n enumerable: false,\n configurable: true,\n get() {\n return self.app.meta.$fetch;\n },\n });\n }\n}\n","// eslint-disable\n/** bean: begin */\nexport * from '../bean/bean.fetch.js';\nexport * from '../bean/bean.interceptorBase.js';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-fetch' {\n \n export interface BeanFetch {\n /** @internal */\n get scope(): ScopeModuleAFetch;\n }\n\n export interface BeanFetch {\n get $beanFullName(): 'a-fetch.bean.fetch';\n get $onionName(): 'a-fetch:fetch';\n \n } \n}\n/** bean: end */\n/** bean: begin */\nimport { BeanFetch } from '../bean/bean.fetch.js';\nimport { BeanInterceptorBase } from '../bean/bean.interceptorBase.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-fetch.bean.fetch': BeanFetch;\n'a-fetch.bean.interceptorBase': BeanInterceptorBase;\n }\n}\n/** bean: end */\n/** service: begin */\nexport * from '../service/composer.js';\n\nimport 'zova-module-a-bean';\ndeclare module 'zova-module-a-bean' {\n \n export interface IServiceRecord {\n 'a-fetch:composer': never;\n }\n\n \n}\ndeclare module 'zova-module-a-fetch' {\n \n export interface ServiceComposer {\n /** @internal */\n get scope(): ScopeModuleAFetch;\n }\n\n export interface ServiceComposer {\n get $beanFullName(): 'a-fetch.service.composer';\n get $onionName(): 'a-fetch:composer';\n \n } \n}\n/** service: end */\n/** service: begin */\nimport { ServiceComposer } from '../service/composer.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-fetch.service.composer': ServiceComposer;\n }\n}\n/** service: 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 ScopeModuleAFetch extends BeanScopeBase {}\n\nexport interface ScopeModuleAFetch {\n util: BeanScopeUtil;\nconfig: TypeModuleConfig<typeof config>;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-fetch': ScopeModuleAFetch;\n }\n \n export interface IBeanScopeConfig {\n 'a-fetch': ReturnType<typeof config>;\n }\n\n \n\n \n}\n \n/** scope: end */\n","export const SymbolInterceptorBodyResponseFlag = Symbol('SymbolInterceptorBodyResponseFlag');\n","import { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorInterceptorOptions } from '../types/interceptor.js';\n\nexport function Interceptor<T extends IDecoratorInterceptorOptions>(options?: T): ClassDecorator {\n return createBeanDecorator('interceptor', 'new', true, options);\n}\n"],"mappings":";;;;;AAAA,IAAA,QAAO,SAAO,SAAU,SAAE,UAAA,SAAoB;;;;;;;;;AAE9C,SAAS,0BAA0B,GAAE,GAAA,GAAA,GAAA,GAAA;CAAA,IAAA,IAAuB,EAAE;AAAA,QAAM,OAAU,KAAC,EAAA,CAAA,QAAA,SAAA,GAAA;AAAA,IAAA,KAAA,EAAA;GAAA,EAAA,EAAA,aAAA,CAAA,CAAA,EAAA,YAAA,EAAA,eAAA,CAAA,CAAA,EAAA,eAAA,WAAA,KAAA,EAAA,iBAAA,EAAA,WAAA,CAAA,IAAA,IAAA,EAAA,OAAA,CAAA,SAAA,CAAA,OAAA,SAAA,GAAA,GAAA;AAAA,SAAA,EAAA,GAAA,GAAA,EAAA,IAAA;IAAA,EAAA,EAAA,KAAA,KAAA,MAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,cAAA,EAAA,YAAA,KAAA,EAAA,GAAA,KAAA,GAAA,EAAA,cAAA,KAAA,IAAA,KAAA,MAAA,EAAA,eAAA,OAAA,eAAA,GAAA,GAAA,EAAA,EAAA,QAAA;;AAK/E,IAAW,mBAAC,SAAA,SAAA,EAAA,UAAA,SAAA,EACV,QAAA,WACD,CAAC,EAAA,UAAA,IAAA,mBAAkB,EAAA,UAAA,QAAA,SAAA,eAAA,OAAA,aAAA,cAAA,SAAA,SAAA,EAAA,OAAA,WAAA,QAAA,YAAA,UAAA,MAAA,wBAAA,SAAA;CAClB,YAAA,GAAA,MAAmB;AACnB,QAAA,GAAA,KAAA;AACA,OAAA,aAAoB,KAAA;AACpB,6BAAyB,MAAA,cAAA,aAAA,KAAA;AACzB,OAAO,mBAAmB,KAAI;;AAE/B,OAAQ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AAA,EAAA,QAAA,QAAA,SAAA,qBAAA,CAAA,OAAA,cAAA,cAAA,SAAA,WAAA,OAAA,MAAA,cAAA,SAAA,EAAA,CAAA,EAAA,OAAA,WAAA,QAAA,WAAA,MAAA,WAAA,MAAA,WAAA,MAAA,WAAA,MAAA,4BAAA,SAAA;CACL,YAAQ,WAAA,SAAA;AACT,SAAO;AACL,OAAA,aAAoB,KAAE;AACtB,OAAA,WAAkB,KAAG;;AAErB,OAAA,WAAY;;EAEZ,IAAE,SAAM,IAAA,SAAY,IAAA,SAAS,IAAA,SAAA,IAAA;;;ACd/B,IAAa,UAAC,SAAA;AACd,QAAO,EAAA,OAAA,EAED,QAAO,EAAA,EACX,EACC;;;;ACHH,IAAS,SAAT,cAA4B,WAAK;;;;CAK/B,MAAM,SAAA,MAAe,cAAC;EACpB,MAAI,OAAO;AAEb,OAAA,eAAA,cAAA,UAAA;;GAEA,cAAe;GACb,MAAM;AACF,WAAA,KAAA,IAAA,KAAA;;GAEH,CAAC;;;;;;;AChBN,IAAG,MAAO,OAAA;AA6BV,IAAS,qBAAU,OAAmB,OAAA,EAAA,QAAA,SAAA,EACpC,QAAK,WACN,CAAC,EAAC,KAAM,SAAK,MAAA,SAAkB,MAAA,0BAAmB,cAAA,GAAA,IAAA,OAAA,IAAA;;;;AC/BnD,IAAa,oCAAoC,OAAO,oCAAoC;;;;ACE5F,QAAO,oBAAO,eAA8B,OAAO,MAAG,QAAM"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/service/composer.ts","../src/bean/bean.fetch.ts","../src/bean/bean.interceptorBase.ts","../src/config/config.ts","../src/monkey.ts","../src/.metadata/index.ts","../src/lib/const.ts","../src/lib/interceptor.ts"],"sourcesContent":["import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';\n\nimport { BeanBase, cast, deepExtend, SymbolErrorInstanceInfo, Use } from 'zova';\nimport { IOnionItem, IOnionSlice, SysOnion, TypeComposer } from 'zova-module-a-bean';\nimport { Service } from 'zova-module-a-bean';\n\nimport type { BeanFetch } from '../bean/bean.fetch.js';\nimport type {\n IDecoratorInterceptorOptions,\n IInterceptorRecord,\n IInterceptorRequest,\n IInterceptorRequestError,\n IInterceptorResponse,\n IInterceptorResponseError,\n} from '../types/interceptor.js';\n\n@Service()\nexport class ServiceComposer extends BeanBase {\n protected $beanFetch: BeanFetch;\n @Use()\n $$sysOnion: SysOnion;\n\n private _composerRequest: TypeComposer;\n private _composerRequestError: TypeComposer;\n private _composerResponse: TypeComposer;\n private _composerResponseError: TypeComposer;\n\n protected async __init__(\n beanFetch: BeanFetch,\n onionItems?:\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>[],\n ) {\n this.$beanFetch = beanFetch;\n await this._createComposer(onionItems);\n }\n\n public executeRequest(config: AxiosRequestConfig) {\n return this._composerRequest(config);\n }\n\n public executeRequestError(error: AxiosError) {\n return this._composerRequestError(error);\n }\n\n public executeResponse(response: AxiosResponse) {\n return this._composerResponse(response);\n }\n\n public async executeResponseError(error: AxiosError) {\n error = await this._composerResponseError(error);\n if (error instanceof Error) {\n error[SymbolErrorInstanceInfo] = {\n instance: this.ctx.instance,\n info: 'executeResponseError',\n };\n }\n return error;\n }\n\n private async _createComposer(\n onionItems?:\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>\n | IOnionItem<IDecoratorInterceptorOptions, keyof IInterceptorRecord>[],\n ) {\n // onionSlices\n let onionSlices: IOnionSlice<IDecoratorInterceptorOptions, keyof IInterceptorRecord>[];\n if (onionItems) {\n onionSlices = await this.$$sysOnion.interceptor.loadOnions(onionItems);\n } else {\n onionSlices = await this.$$sysOnion.interceptor.loadOnionsFromPackage();\n }\n // create interceptors\n for (const onionSlice of onionSlices) {\n onionSlice.beanInstance = await this.bean._newBean(\n onionSlice.beanFullName as any,\n true,\n this.$beanFetch,\n onionSlice.options,\n );\n }\n // compose\n this._composerRequest = this.$$sysOnion.interceptor.compose(\n onionSlices,\n (onionSlice, config: AxiosRequestConfig, next) => {\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config.url)) {\n return next(config);\n }\n // execute\n const beanInstance = cast<IInterceptorRequest>(onionSlice.beanInstance);\n if (!beanInstance.onRequest) return next(config);\n return beanInstance.onRequest(config, options, next as any);\n },\n );\n this._composerRequestError = this.$$sysOnion.interceptor.compose(\n onionSlices,\n (onionSlice, error: AxiosError, next) => {\n const config = error.config;\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {\n return next(error);\n }\n // execute\n const beanInstance = cast<IInterceptorRequestError>(onionSlice.beanInstance);\n if (!beanInstance.onRequestError) return next(error);\n return beanInstance.onRequestError(error, options, next as any);\n },\n );\n this._composerResponse = this.$$sysOnion.interceptor.compose(\n onionSlices,\n (onionSlice, response: AxiosResponse, next) => {\n const config = response.config;\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {\n return next(response);\n }\n // execute\n const beanInstance = cast<IInterceptorResponse>(onionSlice.beanInstance);\n if (!beanInstance.onResponse) return next(response);\n return beanInstance.onResponse(response, options, next as any);\n },\n );\n this._composerResponseError = this.$$sysOnion.interceptor.compose(\n onionSlices,\n (onionSlice, error: AxiosError, next) => {\n const config = error.config;\n // options\n const options = this._combineOnionOptions(onionSlice, config);\n // enable match ignore\n if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {\n return next(error);\n }\n // execute\n const beanInstance = cast<IInterceptorResponseError>(onionSlice.beanInstance);\n if (!beanInstance.onResponseError) return next(error);\n return beanInstance.onResponseError(error, options, next as any);\n },\n );\n }\n\n private _combineOnionOptions(\n item: IOnionSlice<IDecoratorInterceptorOptions, keyof IInterceptorRecord>,\n config?: AxiosRequestConfig,\n ) {\n // options: dynamic\n let optionsDynamic;\n if (config?.interceptors) {\n optionsDynamic = config?.interceptors[item.name];\n }\n // final options\n const options = optionsDynamic ? deepExtend({}, item.options, optionsDynamic) : item.options;\n // ok\n return options;\n }\n}\n","import type { AxiosInstance } from 'axios';\n\nimport axios, { Axios } from 'axios';\nimport { markRaw } from 'vue';\nimport { BeanBase, deepExtend } from 'zova';\nimport { Bean } from 'zova-module-a-bean';\n\nimport type { IBeanFetchOptions } from '../types/interceptor.js';\n\nimport { ServiceComposer } from '../service/composer.js';\n\nconst SymbolFetch = Symbol('SymbolFetch');\n\nexport interface BeanFetch extends AxiosInstance {}\n\n@Bean()\nexport class BeanFetch extends BeanBase {\n private _composer: ServiceComposer;\n\n protected [SymbolFetch]: AxiosInstance;\n\n protected async __init__(options?: IBeanFetchOptions) {\n patchAxios(Axios);\n // axiosConfig\n const axiosConfig = deepExtend(\n {},\n { baseURL: this.sys.util.getApiBaseURL() },\n this.scope.config.axios.config,\n options?.axiosConfig,\n );\n // composer\n this._composer = await this.bean._newBean(ServiceComposer, true, this, options?.onionItems);\n // axios\n this[SymbolFetch] = markRaw(axios.create(axiosConfig));\n this._addInterceptors(this[SymbolFetch]);\n }\n\n protected __get__(prop: string) {\n return this[SymbolFetch] && this[SymbolFetch][prop];\n }\n\n private _addInterceptors(api: AxiosInstance) {\n // request\n api.interceptors.request.use(\n async config => {\n return await this._composer.executeRequest(config);\n },\n async (_error: any) => {\n if (!(_error instanceof Error)) return Promise.reject(_error);\n const error = await this._composer.executeRequestError(_error as any);\n return Promise.reject(error);\n },\n );\n // response\n api.interceptors.response.use(\n async response => {\n return await this._composer.executeResponse(response);\n },\n async (_error: any) => {\n if (!(_error instanceof Error)) return Promise.reject(_error);\n const error = await this._composer.executeResponseError(_error as any);\n return Promise.reject(error);\n },\n );\n }\n}\n\nfunction patchAxios(_Axios: any) {\n if (_Axios.__requestPatched) return;\n _Axios.__requestPatched = true;\n const requestPrev: Function = _Axios.prototype.request;\n _Axios.prototype.request = async function (...args: any[]) {\n try {\n return await requestPrev.call(this, ...args);\n } catch (err) {\n if (err instanceof Error) throw err;\n return err;\n }\n };\n}\n","import { BeanBase, Virtual } from 'zova';\nimport { Bean } from 'zova-module-a-bean';\n\nimport type { IDecoratorInterceptorOptions } from '../types/interceptor.js';\nimport type { BeanFetch } from './bean.fetch.js';\n\n@Bean()\n@Virtual()\nexport class BeanInterceptorBase<\n T extends IDecoratorInterceptorOptions = IDecoratorInterceptorOptions,\n> extends BeanBase {\n protected $beanFetch: BeanFetch;\n protected $options: T;\n\n constructor(beanFetch: BeanFetch, options: T) {\n super();\n this.$beanFetch = beanFetch;\n this.$options = options;\n }\n}\n","import type { CreateAxiosDefaults } from 'axios';\nimport type { ZovaSys } from 'zova';\n\nexport const config = (_sys: ZovaSys) => {\n return {\n axios: {\n config: {} as CreateAxiosDefaults,\n },\n };\n};\n","import type { BeanBase, BeanContainer, IMonkeyAppInitialize, IMonkeyBeanInit } from 'zova';\n\nimport { BeanSimple } from 'zova';\n\nimport { BeanFetch } from './bean/bean.fetch.js';\n\nexport class Monkey extends BeanSimple implements IMonkeyAppInitialize, IMonkeyBeanInit {\n async appInitialize() {\n // $fetch: should in appInitialize, because should init many interceptors\n this.app.meta.$fetch = await this.bean._getBean(BeanFetch, false);\n }\n\n async beanInit(bean: BeanContainer, beanInstance: BeanBase) {\n const self = this;\n // $fetch\n bean.defineProperty(beanInstance, '$fetch', {\n enumerable: false,\n configurable: true,\n get() {\n return self.app.meta.$fetch;\n },\n });\n }\n}\n","// eslint-disable\n/** bean: begin */\nexport * from '../bean/bean.fetch.js';\nexport * from '../bean/bean.interceptorBase.js';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-fetch' {\n \n export interface BeanFetch {\n /** @internal */\n get scope(): ScopeModuleAFetch;\n }\n\n export interface BeanFetch {\n get $beanFullName(): 'a-fetch.bean.fetch';\n get $onionName(): 'a-fetch:fetch';\n \n } \n}\n/** bean: end */\n/** bean: begin */\nimport { BeanFetch } from '../bean/bean.fetch.js';\nimport { BeanInterceptorBase } from '../bean/bean.interceptorBase.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-fetch.bean.fetch': BeanFetch;\n'a-fetch.bean.interceptorBase': BeanInterceptorBase;\n }\n}\n/** bean: end */\n/** service: begin */\nexport * from '../service/composer.js';\n\nimport 'zova-module-a-bean';\ndeclare module 'zova-module-a-bean' {\n \n export interface IServiceRecord {\n 'a-fetch:composer': never;\n }\n\n \n}\ndeclare module 'zova-module-a-fetch' {\n \n export interface ServiceComposer {\n /** @internal */\n get scope(): ScopeModuleAFetch;\n }\n\n export interface ServiceComposer {\n get $beanFullName(): 'a-fetch.service.composer';\n get $onionName(): 'a-fetch:composer';\n \n } \n}\n/** service: end */\n/** service: begin */\nimport { ServiceComposer } from '../service/composer.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-fetch.service.composer': ServiceComposer;\n }\n}\n/** service: 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 ScopeModuleAFetch extends BeanScopeBase {}\n\nexport interface ScopeModuleAFetch {\n util: BeanScopeUtil;\nconfig: TypeModuleConfig<typeof config>;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-fetch': ScopeModuleAFetch;\n }\n \n export interface IBeanScopeConfig {\n 'a-fetch': ReturnType<typeof config>;\n }\n\n \n\n \n}\n \n/** scope: end */\n","export const SymbolInterceptorBodyResponseFlag = Symbol('SymbolInterceptorBodyResponseFlag');\n","import { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorInterceptorOptions } from '../types/interceptor.js';\n\nexport function Interceptor<T extends IDecoratorInterceptorOptions>(options?: T): ClassDecorator {\n return createBeanDecorator('interceptor', 'new', true, options);\n}\n"],"mappings":";;;;;AAAA,IAAA,QAAO,SAAO,SAAU,SAAE,UAAA,SAAoB;;;;;;;;;AAE9C,SAAS,0BAA0B,GAAE,GAAA,GAAA,GAAA,GAAA;CAAA,IAAA,IAAuB,EAAE;AAAA,QAAM,OAAU,KAAC,EAAA,CAAA,QAAA,SAAA,GAAA;AAAA,IAAA,KAAA,EAAA;GAAA,EAAA,EAAA,aAAA,CAAA,CAAA,EAAA,YAAA,EAAA,eAAA,CAAA,CAAA,EAAA,eAAA,WAAA,KAAA,EAAA,iBAAA,EAAA,WAAA,CAAA,IAAA,IAAA,EAAA,OAAA,CAAA,SAAA,CAAA,OAAA,SAAA,GAAA,GAAA;AAAA,SAAA,EAAA,GAAA,GAAA,EAAA,IAAA;IAAA,EAAA,EAAA,KAAA,KAAA,MAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,cAAA,EAAA,YAAA,KAAA,EAAA,GAAA,KAAA,GAAA,EAAA,cAAA,KAAA,IAAA,KAAA,MAAA,EAAA,eAAA,OAAA,eAAA,GAAA,GAAA,EAAA,EAAA,QAAA;;AAK/E,IAAW,mBAAC,SAAA,SAAA,EAAA,UAAA,SAAA,EACV,QAAA,WACD,CAAC,EAAA,UAAA,IAAA,mBAAkB,EAAA,UAAA,QAAA,SAAA,eAAA,OAAA,aAAA,cAAA,SAAA,SAAA,EAAA,OAAA,WAAA,QAAA,YAAA,UAAA,MAAA,wBAAA,SAAA;CAClB,YAAA,GAAA,MAAmB;AACnB,QAAA,GAAA,KAAA;AACA,OAAA,aAAoB,KAAA;AACpB,6BAAyB,MAAA,cAAA,aAAA,KAAA;AACzB,OAAO,mBAAmB,KAAI;;AAE/B,OAAQ,oBAAA,KAAA;AACT,OAAO,yBAAsB,KAAQ;;CAEnC,MAAK,SAAA,WAAA,YAAA;AACH,OAAA,aAAkB;;;CAGpB,eAAQ,QA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kBAAkB;QACjC,YAAY,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,CAAC;KACjD;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-module-a-fetch",
3
- "version": "5.1.8",
4
- "gitHead": "4574f3873b1ad25eb6cdc8c44757a6c14dfc950d",
3
+ "version": "5.1.10",
4
+ "gitHead": "343c61ad189fe3f0fc997ee9f4c710567657e05c",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -13,8 +13,7 @@
13
13
  "mock",
14
14
  "src",
15
15
  "icons",
16
- "assets",
17
- "rest"
16
+ "assets"
18
17
  ],
19
18
  "type": "module",
20
19
  "exports": {
@@ -22,7 +22,12 @@ export class BeanFetch extends BeanBase {
22
22
  protected async __init__(options?: IBeanFetchOptions) {
23
23
  patchAxios(Axios);
24
24
  // axiosConfig
25
- const axiosConfig = deepExtend({}, { baseURL: this.sys.util.getApiBaseURL() }, this.scope.config.axios.config, options?.axiosConfig);
25
+ const axiosConfig = deepExtend(
26
+ {},
27
+ { baseURL: this.sys.util.getApiBaseURL() },
28
+ this.scope.config.axios.config,
29
+ options?.axiosConfig,
30
+ );
26
31
  // composer
27
32
  this._composer = await this.bean._newBean(ServiceComposer, true, this, options?.onionItems);
28
33
  // axios
@@ -6,7 +6,9 @@ import type { BeanFetch } from './bean.fetch.js';
6
6
 
7
7
  @Bean()
8
8
  @Virtual()
9
- export class BeanInterceptorBase<T extends IDecoratorInterceptorOptions = IDecoratorInterceptorOptions> extends BeanBase {
9
+ export class BeanInterceptorBase<
10
+ T extends IDecoratorInterceptorOptions = IDecoratorInterceptorOptions,
11
+ > extends BeanBase {
10
12
  protected $beanFetch: BeanFetch;
11
13
  protected $options: T;
12
14
 
@@ -72,63 +72,83 @@ export class ServiceComposer extends BeanBase {
72
72
  }
73
73
  // create interceptors
74
74
  for (const onionSlice of onionSlices) {
75
- onionSlice.beanInstance = await this.bean._newBean(onionSlice.beanFullName as any, true, this.$beanFetch, onionSlice.options);
75
+ onionSlice.beanInstance = await this.bean._newBean(
76
+ onionSlice.beanFullName as any,
77
+ true,
78
+ this.$beanFetch,
79
+ onionSlice.options,
80
+ );
76
81
  }
77
82
  // compose
78
- this._composerRequest = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, config: AxiosRequestConfig, next) => {
79
- // options
80
- const options = this._combineOnionOptions(onionSlice, config);
81
- // enable match ignore
82
- if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config.url)) {
83
- return next(config);
84
- }
85
- // execute
86
- const beanInstance = cast<IInterceptorRequest>(onionSlice.beanInstance);
87
- if (!beanInstance.onRequest) return next(config);
88
- return beanInstance.onRequest(config, options, next as any);
89
- });
90
- this._composerRequestError = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, error: AxiosError, next) => {
91
- const config = error.config;
92
- // options
93
- const options = this._combineOnionOptions(onionSlice, config);
94
- // enable match ignore
95
- if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {
96
- return next(error);
97
- }
98
- // execute
99
- const beanInstance = cast<IInterceptorRequestError>(onionSlice.beanInstance);
100
- if (!beanInstance.onRequestError) return next(error);
101
- return beanInstance.onRequestError(error, options, next as any);
102
- });
103
- this._composerResponse = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, response: AxiosResponse, next) => {
104
- const config = response.config;
105
- // options
106
- const options = this._combineOnionOptions(onionSlice, config);
107
- // enable match ignore
108
- if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {
109
- return next(response);
110
- }
111
- // execute
112
- const beanInstance = cast<IInterceptorResponse>(onionSlice.beanInstance);
113
- if (!beanInstance.onResponse) return next(response);
114
- return beanInstance.onResponse(response, options, next as any);
115
- });
116
- this._composerResponseError = this.$$sysOnion.interceptor.compose(onionSlices, (onionSlice, error: AxiosError, next) => {
117
- const config = error.config;
118
- // options
119
- const options = this._combineOnionOptions(onionSlice, config);
120
- // enable match ignore
121
- if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {
122
- return next(error);
123
- }
124
- // execute
125
- const beanInstance = cast<IInterceptorResponseError>(onionSlice.beanInstance);
126
- if (!beanInstance.onResponseError) return next(error);
127
- return beanInstance.onResponseError(error, options, next as any);
128
- });
83
+ this._composerRequest = this.$$sysOnion.interceptor.compose(
84
+ onionSlices,
85
+ (onionSlice, config: AxiosRequestConfig, next) => {
86
+ // options
87
+ const options = this._combineOnionOptions(onionSlice, config);
88
+ // enable match ignore
89
+ if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config.url)) {
90
+ return next(config);
91
+ }
92
+ // execute
93
+ const beanInstance = cast<IInterceptorRequest>(onionSlice.beanInstance);
94
+ if (!beanInstance.onRequest) return next(config);
95
+ return beanInstance.onRequest(config, options, next as any);
96
+ },
97
+ );
98
+ this._composerRequestError = this.$$sysOnion.interceptor.compose(
99
+ onionSlices,
100
+ (onionSlice, error: AxiosError, next) => {
101
+ const config = error.config;
102
+ // options
103
+ const options = this._combineOnionOptions(onionSlice, config);
104
+ // enable match ignore
105
+ if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {
106
+ return next(error);
107
+ }
108
+ // execute
109
+ const beanInstance = cast<IInterceptorRequestError>(onionSlice.beanInstance);
110
+ if (!beanInstance.onRequestError) return next(error);
111
+ return beanInstance.onRequestError(error, options, next as any);
112
+ },
113
+ );
114
+ this._composerResponse = this.$$sysOnion.interceptor.compose(
115
+ onionSlices,
116
+ (onionSlice, response: AxiosResponse, next) => {
117
+ const config = response.config;
118
+ // options
119
+ const options = this._combineOnionOptions(onionSlice, config);
120
+ // enable match ignore
121
+ if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {
122
+ return next(response);
123
+ }
124
+ // execute
125
+ const beanInstance = cast<IInterceptorResponse>(onionSlice.beanInstance);
126
+ if (!beanInstance.onResponse) return next(response);
127
+ return beanInstance.onResponse(response, options, next as any);
128
+ },
129
+ );
130
+ this._composerResponseError = this.$$sysOnion.interceptor.compose(
131
+ onionSlices,
132
+ (onionSlice, error: AxiosError, next) => {
133
+ const config = error.config;
134
+ // options
135
+ const options = this._combineOnionOptions(onionSlice, config);
136
+ // enable match ignore
137
+ if (!this.$$sysOnion.checkOnionOptionsEnabled(options, config?.url)) {
138
+ return next(error);
139
+ }
140
+ // execute
141
+ const beanInstance = cast<IInterceptorResponseError>(onionSlice.beanInstance);
142
+ if (!beanInstance.onResponseError) return next(error);
143
+ return beanInstance.onResponseError(error, options, next as any);
144
+ },
145
+ );
129
146
  }
130
147
 
131
- private _combineOnionOptions(item: IOnionSlice<IDecoratorInterceptorOptions, keyof IInterceptorRecord>, config?: AxiosRequestConfig) {
148
+ private _combineOnionOptions(
149
+ item: IOnionSlice<IDecoratorInterceptorOptions, keyof IInterceptorRecord>,
150
+ config?: AxiosRequestConfig,
151
+ ) {
132
152
  // options: dynamic
133
153
  let optionsDynamic;
134
154
  if (config?.interceptors) {
@@ -25,23 +25,42 @@ export interface IBeanFetchOptions {
25
25
  export interface IInterceptorRecord {}
26
26
 
27
27
  export interface IInterceptorRequest {
28
- onRequest(_config: AxiosRequestConfig, _options: IDecoratorInterceptorOptions, _next: NextInterceptorRequest): Promise<AxiosRequestConfig>;
28
+ onRequest(
29
+ _config: AxiosRequestConfig,
30
+ _options: IDecoratorInterceptorOptions,
31
+ _next: NextInterceptorRequest,
32
+ ): Promise<AxiosRequestConfig>;
29
33
  }
30
34
 
31
35
  export interface IInterceptorRequestError {
32
- onRequestError(_error: AxiosError, _options: IDecoratorInterceptorOptions, _next: NextInterceptorError): Promise<AxiosError>;
36
+ onRequestError(
37
+ _error: AxiosError,
38
+ _options: IDecoratorInterceptorOptions,
39
+ _next: NextInterceptorError,
40
+ ): Promise<AxiosError>;
33
41
  }
34
42
 
35
43
  export interface IInterceptorResponse {
36
- onResponse(_response: AxiosResponse, _options: IDecoratorInterceptorOptions, _next: NextInterceptorResponse): Promise<AxiosResponse>;
44
+ onResponse(
45
+ _response: AxiosResponse,
46
+ _options: IDecoratorInterceptorOptions,
47
+ _next: NextInterceptorResponse,
48
+ ): Promise<AxiosResponse>;
37
49
  }
38
50
 
39
51
  export interface IInterceptorResponseError {
40
- onResponseError(_error: AxiosError, _options: IDecoratorInterceptorOptions, _next: NextInterceptorError): Promise<AxiosError>;
52
+ onResponseError(
53
+ _error: AxiosError,
54
+ _options: IDecoratorInterceptorOptions,
55
+ _next: NextInterceptorError,
56
+ ): Promise<AxiosError>;
41
57
  }
42
58
 
43
59
  export interface IDecoratorInterceptorOptions
44
- extends IOnionOptionsEnable, IOnionOptionsMatch<TypeOnionOptionsMatchRule<string>>, IOnionOptionsDeps<keyof IInterceptorRecord> {}
60
+ extends
61
+ IOnionOptionsEnable,
62
+ IOnionOptionsMatch<TypeOnionOptionsMatchRule<string>>,
63
+ IOnionOptionsDeps<keyof IInterceptorRecord> {}
45
64
 
46
65
  declare module 'zova-module-a-bean' {
47
66
  export interface SysOnion {