zova-module-a-interceptor 5.1.31 → 5.1.32

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,14 +1,14 @@
1
1
  /** interceptor: begin */
2
- export * from '../bean/interceptor.body.js';
3
- export * from '../bean/interceptor.headers.js';
4
- export * from '../bean/interceptor.jwt.js';
5
- export * from '../bean/interceptor.mock.js';
6
- export * from '../bean/interceptor.performAction.js';
7
- import { IInterceptorOptionsBody } from '../bean/interceptor.body.js';
8
- import { IInterceptorOptionsHeaders } from '../bean/interceptor.headers.js';
9
- import { IInterceptorOptionsJwt } from '../bean/interceptor.jwt.js';
10
- import { IInterceptorOptionsMock } from '../bean/interceptor.mock.js';
11
- import { IInterceptorOptionsPerformAction } from '../bean/interceptor.performAction.js';
2
+ export * from '../bean/interceptor.body.ts';
3
+ export * from '../bean/interceptor.headers.ts';
4
+ export * from '../bean/interceptor.jwt.ts';
5
+ export * from '../bean/interceptor.mock.ts';
6
+ export * from '../bean/interceptor.performAction.ts';
7
+ import { IInterceptorOptionsBody } from '../bean/interceptor.body.ts';
8
+ import { IInterceptorOptionsHeaders } from '../bean/interceptor.headers.ts';
9
+ import { IInterceptorOptionsJwt } from '../bean/interceptor.jwt.ts';
10
+ import { IInterceptorOptionsMock } from '../bean/interceptor.mock.ts';
11
+ import { IInterceptorOptionsPerformAction } from '../bean/interceptor.performAction.ts';
12
12
  import 'zova-module-a-fetch';
13
13
  declare module 'zova-module-a-fetch' {
14
14
  interface IInterceptorRecord {
@@ -58,11 +58,11 @@ declare module 'zova-module-a-interceptor' {
58
58
  }
59
59
  /** interceptor: end */
60
60
  /** interceptor: begin */
61
- import { InterceptorBody } from '../bean/interceptor.body.js';
62
- import { InterceptorHeaders } from '../bean/interceptor.headers.js';
63
- import { InterceptorJwt } from '../bean/interceptor.jwt.js';
64
- import { InterceptorMock } from '../bean/interceptor.mock.js';
65
- import { InterceptorPerformAction } from '../bean/interceptor.performAction.js';
61
+ import type { InterceptorBody } from '../bean/interceptor.body.ts';
62
+ import type { InterceptorHeaders } from '../bean/interceptor.headers.ts';
63
+ import type { InterceptorJwt } from '../bean/interceptor.jwt.ts';
64
+ import type { InterceptorMock } from '../bean/interceptor.mock.ts';
65
+ import type { InterceptorPerformAction } from '../bean/interceptor.performAction.ts';
66
66
  import 'zova';
67
67
  declare module 'zova' {
68
68
  interface IBeanRecordLocal {
@@ -75,8 +75,8 @@ declare module 'zova' {
75
75
  }
76
76
  /** interceptor: end */
77
77
  /** config: begin */
78
- export * from '../config/config.js';
79
- import { config } from '../config/config.js';
78
+ export * from '../config/config.ts';
79
+ import { config } from '../config/config.ts';
80
80
  /** config: end */
81
81
  /** scope: begin */
82
82
  import { BeanScopeBase, type BeanScopeUtil, TypeModuleConfig } from 'zova';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/.metadata/index.ts"],"names":[],"mappings":"AACA,yBAAyB;AACzB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,qBAAqB,CAAC;AAC7B,OAAO,QAAQ,qBAAqB,CAAC;IAEjC,UAAiB,kBAAkB;QACjC,oBAAoB,EAAE,uBAAuB,CAAC;QACpD,uBAAuB,EAAE,0BAA0B,CAAC;QACpD,mBAAmB,EAAE,sBAAsB,CAAC;QAC5C,oBAAoB,EAAE,uBAAuB,CAAC;QAC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-interceptor";
2
- export { ScopeModuleAInterceptor as ScopeModule } from './index.js';
2
+ export { ScopeModuleAInterceptor as ScopeModule } from './index.ts';
3
3
  //# sourceMappingURL=this.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './.metadata/index.js';
2
- export * from './types/index.js';
1
+ export * from './.metadata/index.ts';
2
+ export * from './types/index.ts';
3
3
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -3,7 +3,9 @@ import { BeanInterceptorBase, Interceptor, SymbolInterceptorBodyResponseFlag } f
3
3
  import { catchError } from "@cabloy/utils";
4
4
  import { Scope } from "zova-module-a-bean";
5
5
  //#region src/bean/interceptor.body.ts
6
- var _dec$5, _dec2$5, _class$5;
6
+ var _dec$5;
7
+ var _dec2$5;
8
+ var _class$5;
7
9
  var InterceptorBody = (_dec$5 = Interceptor({ dependencies: "a-interceptor:performAction" }), _dec2$5 = BeanInfo({ module: "a-interceptor" }), _dec$5(_class$5 = _dec2$5(_class$5 = class InterceptorBody extends BeanInterceptorBase {
8
10
  async onResponse(response, _options, next) {
9
11
  response = await next();
@@ -32,7 +34,9 @@ var InterceptorBody = (_dec$5 = Interceptor({ dependencies: "a-interceptor:perfo
32
34
  }) || _class$5) || _class$5);
33
35
  //#endregion
34
36
  //#region src/bean/interceptor.headers.ts
35
- var _dec$4, _dec2$4, _class$4;
37
+ var _dec$4;
38
+ var _dec2$4;
39
+ var _class$4;
36
40
  var InterceptorHeaders = (_dec$4 = Interceptor({ dependencies: "a-interceptor:mock" }), _dec2$4 = BeanInfo({ module: "a-interceptor" }), _dec$4(_class$4 = _dec2$4(_class$4 = class InterceptorHeaders extends BeanInterceptorBase {
37
41
  async onRequest(config, options, next) {
38
42
  const keyLocale = this.sys.env.APP_LOCALE_HEADER_KEY;
@@ -45,7 +49,9 @@ var InterceptorHeaders = (_dec$4 = Interceptor({ dependencies: "a-interceptor:mo
45
49
  }) || _class$4) || _class$4);
46
50
  //#endregion
47
51
  //#region src/bean/interceptor.jwt.ts
48
- var _dec$3, _dec2$3, _class$3;
52
+ var _dec$3;
53
+ var _dec2$3;
54
+ var _class$3;
49
55
  var InterceptorJwt = (_dec$3 = Interceptor({ dependencies: "a-interceptor:headers" }), _dec2$3 = BeanInfo({ module: "a-interceptor" }), _dec$3(_class$3 = _dec2$3(_class$3 = class InterceptorJwt extends BeanInterceptorBase {
50
56
  constructor(...args) {
51
57
  super(...args);
@@ -107,7 +113,9 @@ var InterceptorJwt = (_dec$3 = Interceptor({ dependencies: "a-interceptor:header
107
113
  }) || _class$3) || _class$3);
108
114
  //#endregion
109
115
  //#region src/bean/interceptor.mock.ts
110
- var _dec$2, _dec2$2, _class$2;
116
+ var _dec$2;
117
+ var _dec2$2;
118
+ var _class$2;
111
119
  var __ErrorsShouldBeMocked = [
112
120
  "ECONNREFUSED",
113
121
  "ERR_NETWORK",
@@ -137,7 +145,9 @@ var InterceptorMock = (_dec$2 = Interceptor(), _dec2$2 = BeanInfo({ module: "a-i
137
145
  }) || _class$2) || _class$2);
138
146
  //#endregion
139
147
  //#region src/bean/interceptor.performAction.ts
140
- var _dec$1, _dec2$1, _class$1;
148
+ var _dec$1;
149
+ var _dec2$1;
150
+ var _class$1;
141
151
  var InterceptorPerformAction = (_dec$1 = Interceptor({ dependencies: "a-interceptor:jwt" }), _dec2$1 = BeanInfo({ module: "a-interceptor" }), _dec$1(_class$1 = _dec2$1(_class$1 = class InterceptorPerformAction extends BeanInterceptorBase {
142
152
  async onRequest(config, _options, next) {
143
153
  if (process.env.CLIENT) return next();
@@ -170,9 +180,9 @@ var config = (_sys) => {
170
180
  };
171
181
  //#endregion
172
182
  //#region src/.metadata/index.ts
173
- /** config: end */
174
- /** scope: begin */
175
- var _dec, _dec2, _class;
183
+ var _dec;
184
+ var _dec2;
185
+ var _class;
176
186
  var ScopeModuleAInterceptor = (_dec = Scope(), _dec2 = BeanInfo({ module: "a-interceptor" }), _dec(_class = _dec2(_class = class ScopeModuleAInterceptor extends BeanScopeBase {}) || _class) || _class);
177
187
  /** scope: end */
178
188
  //#endregion
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/bean/interceptor.body.ts","../src/bean/interceptor.headers.ts","../src/bean/interceptor.jwt.ts","../src/bean/interceptor.mock.ts","../src/bean/interceptor.performAction.ts","../src/config/config.ts","../src/.metadata/index.ts"],"sourcesContent":["var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { cast } from 'zova';\nimport { BeanInterceptorBase, Interceptor, SymbolInterceptorBodyResponseFlag } from 'zova-module-a-fetch';\nexport let InterceptorBody = (_dec = Interceptor({\n dependencies: 'a-interceptor:performAction'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorBody extends BeanInterceptorBase {\n async onResponse(response, _options, next) {\n response = await next();\n const contentType = response.headers['content-type'];\n if (!contentType || typeof contentType !== 'string' || !contentType.includes('application/json')) {\n response[SymbolInterceptorBodyResponseFlag] = true;\n return response;\n }\n if (response.data.code !== 0) {\n const error = new Error();\n error.code = response.data.code;\n error.message = response.data.message;\n throw error;\n }\n // return data\n return response.data.data ?? null;\n }\n async onResponseError(error, _options, next) {\n error = await next();\n if (!(error instanceof Error)) return error;\n if (error.response) {\n error.code = cast(error.response.data)?.code ?? error.response.status;\n error.message = cast(error.response.data)?.message ?? error.response.statusText;\n }\n return error;\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { $protocolKey } from 'zova';\nimport { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';\nexport let InterceptorHeaders = (_dec = Interceptor({\n dependencies: 'a-interceptor:mock'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorHeaders extends BeanInterceptorBase {\n async onRequest(config, options, next) {\n // locale\n const keyLocale = this.sys.env.APP_LOCALE_HEADER_KEY;\n if (keyLocale && !config.headers[keyLocale]) {\n config.headers[keyLocale] = this.app.meta.locale.current;\n }\n // tz\n const keyTz = this.sys.env.APP_TZ_HEADER_KEY;\n if (keyTz && !config.headers[keyTz]) {\n config.headers[keyTz] = this.app.meta.locale.tz;\n }\n // openapi schema\n if (options.openapiSchema) {\n config.headers[$protocolKey('x-vona-openapi-schema')] = true;\n }\n // next\n return next(config);\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { $protocolKey } from 'zova';\nimport { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';\nexport let InterceptorJwt = (_dec = Interceptor({\n dependencies: 'a-interceptor:headers'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorJwt extends BeanInterceptorBase {\n constructor(...args) {\n super(...args);\n this._beanJwtAdapter = void 0;\n this._refreshAuthTokenPromise = void 0;\n }\n async __init__(_beanFetch, options) {\n const jwtAdapter = options.jwtAdapter || this.scope.config.jwtAdapter;\n const beanFullName = jwtAdapter.replace(':', '.service.');\n // singleton\n this._beanJwtAdapter = await this.app.bean._getBean(beanFullName, true);\n }\n async onRequest(config, options, next) {\n try {\n const accessToken = await this.prepareAccessToken(config, options.authToken);\n if (accessToken) {\n config.headers.Authorization = `Bearer ${accessToken}`;\n }\n } catch (error) {\n error.config = config;\n error.request = undefined;\n error.response = undefined;\n throw error;\n }\n return next(config);\n }\n async prepareAccessToken(config, authToken) {\n if (!this.sys.config.api.jwt) return;\n if (this.$ssr.cookieDisabledOnServer) return;\n // use default in scope.config rather than IInterceptorOptionsJwt.options\n const authTokenCurrent = authToken ?? this.scope.config.authToken.default;\n // authToken = authToken ?? this.scope.config.authToken.default;\n if (process.env.SERVER) {\n config.headers[$protocolKey('x-vona-jwt-authtoken')] = typeof authTokenCurrent === 'string' ? true : authTokenCurrent;\n }\n // // authToken: false\n // if (authTokenCurrent === false) return;\n // authToken: string\n if (typeof authTokenCurrent === 'string') return authTokenCurrent;\n // if (typeof authToken === 'string') return authToken;\n // authToken: true\n let jwtInfo = await this._beanJwtAdapter.getJwtInfo();\n if (!jwtInfo) {\n if (authToken === true) {\n this.app.throw(401); // 401 rather than 403\n }\n return;\n }\n // accessToken\n if (process.env.SERVER || !jwtInfo.expireTime || jwtInfo.expireTime > Date.now()) {\n if (!jwtInfo.accessToken) {\n if (authToken === true) this.app.throw(401);\n return;\n }\n return jwtInfo.accessToken;\n }\n // refreshToken\n if (!jwtInfo.refreshToken) {\n if (authToken === true) this.app.throw(401);\n return;\n } else {\n if (authToken === false) {\n // need not refreshAuthToken, such as captcha.create\n return;\n }\n }\n jwtInfo = await this._refreshAuthToken(jwtInfo.refreshToken);\n return jwtInfo.accessToken;\n }\n async _refreshAuthToken(refreshToken) {\n if (!this._refreshAuthTokenPromise) {\n this._refreshAuthTokenPromise = this._refreshAuthTokenInner(refreshToken);\n }\n return await this._refreshAuthTokenPromise;\n }\n async _refreshAuthTokenInner(refreshToken) {\n try {\n return await this._beanJwtAdapter.refreshAuthToken(refreshToken);\n } finally {\n this._refreshAuthTokenPromise = undefined;\n }\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { BeanInterceptorBase, Interceptor, SymbolInterceptorBodyResponseFlag } from 'zova-module-a-fetch';\n// not include: ERR_BAD_RESPONSE\nconst __ErrorsShouldBeMocked = ['ECONNREFUSED', 'ERR_NETWORK', '404'];\nexport let InterceptorMock = (_dec = Interceptor(), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorMock extends BeanInterceptorBase {\n async onResponseError(error, _options, next) {\n if (!(error instanceof Error)) return next();\n if (this.sys.env.MOCK_ENABLED === 'true') {\n if (process.env.DEV || process.env.PROD && this.sys.env.MOCK_BUILD === 'true') {\n if (__ErrorsShouldBeMocked.includes(String(error.code)) || error.status === 404) {\n const config = error.config;\n if (config.baseURL) {\n const port = process.env.DEV ? this.sys.env.DEV_SERVER_PORT : this.sys.env.MOCK_BUILD_PORT;\n let baseURL = `http://localhost:${port}`;\n if (config.baseURL.endsWith(this.sys.env.API_PREFIX)) {\n baseURL = `${baseURL}${this.sys.env.API_PREFIX}`;\n }\n if (config.baseURL !== baseURL && config.baseURL !== this.sys.env.API_PREFIX) {\n const response = await this.$fetch.request(Object.assign({}, config, {\n baseURL\n }));\n if (response && response[SymbolInterceptorBodyResponseFlag]) {\n return response.data;\n } else {\n return response;\n }\n }\n }\n }\n }\n }\n return next();\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { catchError } from '@cabloy/utils';\nimport { cast } from 'zova';\nimport { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';\nexport let InterceptorPerformAction = (_dec = Interceptor({\n dependencies: 'a-interceptor:jwt'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorPerformAction extends BeanInterceptorBase {\n async onRequest(config, _options, next) {\n if (process.env.CLIENT) return next();\n const performAction = this.ctx.meta.$ssr.getPerformAction(config.baseURL);\n if (!performAction) return next();\n const data = {\n method: config.method,\n path: config.url,\n query: config.params,\n body: config.data,\n headers: config.headers\n };\n const [result, error] = await catchError(() => {\n return performAction(data);\n });\n if (error) {\n cast(error).config = config;\n throw error;\n }\n throw result;\n }\n}) || _class) || _class);","export const config = _sys => {\n return {\n jwtAdapter: 'home-api:jwtAdapter',\n authToken: {\n default: true\n }\n };\n};","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** interceptor: begin */\nexport * from '../bean/interceptor.body.js';\nexport * from '../bean/interceptor.headers.js';\nexport * from '../bean/interceptor.jwt.js';\nexport * from '../bean/interceptor.mock.js';\nexport * from '../bean/interceptor.performAction.js';\nimport 'zova-module-a-fetch';\n/** interceptor: end */\n/** interceptor: begin */\nimport { InterceptorBody } from '../bean/interceptor.body.js';\nimport { InterceptorHeaders } from '../bean/interceptor.headers.js';\nimport { InterceptorJwt } from '../bean/interceptor.jwt.js';\nimport { InterceptorMock } from '../bean/interceptor.mock.js';\nimport { InterceptorPerformAction } from '../bean/interceptor.performAction.js';\nimport 'zova';\n/** interceptor: end */\n/** config: begin */\nexport * from '../config/config.js';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleAInterceptor = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class ScopeModuleAInterceptor extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */"],"mappings":";;;;;AAAA,IAAI,QAAM,SAAO;AAIjB,IAAW,mBAAmB,SAAO,YAAY,EAC/C,cAAc,8BAChB,CAAC,GAAG,UAAQ,SAAa,EACvB,QAAQ,gBACV,CAAC,GAAG,OAAK,WAAS,QAAM,WAAS,MAAM,wBAAwB,oBAAoB;CACjF,MAAM,WAAW,UAAU,UAAU,MAAM;EACzC,WAAW,MAAM,KAAK;EACtB,MAAM,cAAc,SAAS,QAAQ;EACrC,IAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY,CAAC,YAAY,SAAS,kBAAkB,GAAG;GAChG,SAAS,qCAAqC;GAC9C,OAAO;EACT;EACA,IAAI,SAAS,KAAK,SAAS,GAAG;GAC5B,MAAM,wBAAQ,IAAI,MAAM;GACxB,MAAM,OAAO,SAAS,KAAK;GAC3B,MAAM,UAAU,SAAS,KAAK;GAC9B,MAAM;EACR;EAEA,OAAO,SAAS,KAAK,QAAQ;CAC/B;CACA,MAAM,gBAAgB,OAAO,UAAU,MAAM;EAC3C,QAAQ,MAAM,KAAK;EACnB,IAAI,EAAE,iBAAiB,QAAQ,OAAO;EACtC,IAAI,MAAM,UAAU;G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Y,EACxD,cAAc,oBAChB,CAAC,GAAG,UAAQ,SAAa,EACvB,QAAQ,gBACV,CAAC,GAAG,OAAK,WAAS,QAAM,WAAS,MAAM,iCAAiC,oBAAoB;CAC1F,MAAM,UAAU,QAAQ,UAAU,MAAM;EACtC,IAAI,QAAQ,IAAI,QAAQ,OAAO,KAAK;EACpC,MAAM,gBAAgB,KAAK,IAAI,KAAK,KAAK,iBAAiB,OAAO,OAAO;EACxE,IAAI,CAAC,eAAe,OAAO,KAAK;EAChC,MAAM,OAAO;GACX,QAAQ,OAAO;GACf,MAAM,OAAO;GACb,OAAO,OAAO;GACd,MAAM,OAAO;GACb,SAAS,OAAO;EAClB;EACA,MAAM,CAAC,QAAQ,SAAS,MAAM,iBAAiB;GAC7C,OAAO,cAAc,IAAI;EAC3B,CAAC;EACD,IAAI,OAAO;GACT,KAAK,KAAK,CAAC,CAAC,SAAS;GACrB,MAAM;EACR;EACA,MAAM;CACR;AACF,CAAC,KAAK,QAAM,KAAK;;;AC9BjB,IAAa,UAAS,SAAQ;CAC5B,OAAO;EACL,YAAY;EACZ,WAAW,EACT,SAAS,KACX;CACF;AACF;;;;;ACPA,IAAI,MAAM,OAAO;AAyBjB,IAAW,2BAA2B,OAAO,MAAM,GAAG,QAAQ,SAAa,EACzE,QAAQ,gBACV,CAAC,GAAG,KAAK,SAAS,MAAM,SAAS,MAAM,gCAAgC,cAAc,CAAC,CAAC,KAAK,MAAM,KAAK"}
1
+ {"version":3,"file":"index.js","names":["_dec","_dec2","_class","__z_BeanInfo","_dec","_dec2","_class","__z_BeanInfo","_dec","_dec2","_class","__z_BeanInfo","_dec","_dec2","_class","__z_BeanInfo","_dec","_dec2","_class","__z_BeanInfo","__z_BeanInfo"],"sources":["../src/bean/interceptor.body.ts","../src/bean/interceptor.headers.ts","../src/bean/interceptor.jwt.ts","../src/bean/interceptor.mock.ts","../src/bean/interceptor.performAction.ts","../src/config/config.ts","../src/.metadata/index.ts"],"sourcesContent":["var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { cast } from 'zova';\nimport { BeanInterceptorBase, Interceptor, SymbolInterceptorBodyResponseFlag } from 'zova-module-a-fetch';\nexport let InterceptorBody = (_dec = Interceptor({\n dependencies: 'a-interceptor:performAction'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorBody extends BeanInterceptorBase {\n async onResponse(response, _options, next) {\n response = await next();\n const contentType = response.headers['content-type'];\n if (!contentType || typeof contentType !== 'string' || !contentType.includes('application/json')) {\n response[SymbolInterceptorBodyResponseFlag] = true;\n return response;\n }\n if (response.data.code !== 0) {\n const error = new Error();\n error.code = response.data.code;\n error.message = response.data.message;\n throw error;\n }\n // return data\n return response.data.data ?? null;\n }\n async onResponseError(error, _options, next) {\n error = await next();\n if (!(error instanceof Error)) return error;\n if (error.response) {\n error.code = cast(error.response.data)?.code ?? error.response.status;\n error.message = cast(error.response.data)?.message ?? error.response.statusText;\n }\n return error;\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { $protocolKey } from 'zova';\nimport { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';\nexport let InterceptorHeaders = (_dec = Interceptor({\n dependencies: 'a-interceptor:mock'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorHeaders extends BeanInterceptorBase {\n async onRequest(config, options, next) {\n // locale\n const keyLocale = this.sys.env.APP_LOCALE_HEADER_KEY;\n if (keyLocale && !config.headers[keyLocale]) {\n config.headers[keyLocale] = this.app.meta.locale.current;\n }\n // tz\n const keyTz = this.sys.env.APP_TZ_HEADER_KEY;\n if (keyTz && !config.headers[keyTz]) {\n config.headers[keyTz] = this.app.meta.locale.tz;\n }\n // openapi schema\n if (options.openapiSchema) {\n config.headers[$protocolKey('x-vona-openapi-schema')] = true;\n }\n // next\n return next(config);\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { $protocolKey } from 'zova';\nimport { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';\nexport let InterceptorJwt = (_dec = Interceptor({\n dependencies: 'a-interceptor:headers'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorJwt extends BeanInterceptorBase {\n constructor(...args) {\n super(...args);\n this._beanJwtAdapter = void 0;\n this._refreshAuthTokenPromise = void 0;\n }\n async __init__(_beanFetch, options) {\n const jwtAdapter = options.jwtAdapter || this.scope.config.jwtAdapter;\n const beanFullName = jwtAdapter.replace(':', '.service.');\n // singleton\n this._beanJwtAdapter = await this.app.bean._getBean(beanFullName, true);\n }\n async onRequest(config, options, next) {\n try {\n const accessToken = await this.prepareAccessToken(config, options.authToken);\n if (accessToken) {\n config.headers.Authorization = `Bearer ${accessToken}`;\n }\n } catch (error) {\n error.config = config;\n error.request = undefined;\n error.response = undefined;\n throw error;\n }\n return next(config);\n }\n async prepareAccessToken(config, authToken) {\n if (!this.sys.config.api.jwt) return;\n if (this.$ssr.cookieDisabledOnServer) return;\n // use default in scope.config rather than IInterceptorOptionsJwt.options\n const authTokenCurrent = authToken ?? this.scope.config.authToken.default;\n // authToken = authToken ?? this.scope.config.authToken.default;\n if (process.env.SERVER) {\n config.headers[$protocolKey('x-vona-jwt-authtoken')] = typeof authTokenCurrent === 'string' ? true : authTokenCurrent;\n }\n // // authToken: false\n // if (authTokenCurrent === false) return;\n // authToken: string\n if (typeof authTokenCurrent === 'string') return authTokenCurrent;\n // if (typeof authToken === 'string') return authToken;\n // authToken: true\n let jwtInfo = await this._beanJwtAdapter.getJwtInfo();\n if (!jwtInfo) {\n if (authToken === true) {\n this.app.throw(401); // 401 rather than 403\n }\n return;\n }\n // accessToken\n if (process.env.SERVER || !jwtInfo.expireTime || jwtInfo.expireTime > Date.now()) {\n if (!jwtInfo.accessToken) {\n if (authToken === true) this.app.throw(401);\n return;\n }\n return jwtInfo.accessToken;\n }\n // refreshToken\n if (!jwtInfo.refreshToken) {\n if (authToken === true) this.app.throw(401);\n return;\n } else {\n if (authToken === false) {\n // need not refreshAuthToken, such as captcha.create\n return;\n }\n }\n jwtInfo = await this._refreshAuthToken(jwtInfo.refreshToken);\n return jwtInfo.accessToken;\n }\n async _refreshAuthToken(refreshToken) {\n if (!this._refreshAuthTokenPromise) {\n this._refreshAuthTokenPromise = this._refreshAuthTokenInner(refreshToken);\n }\n return await this._refreshAuthTokenPromise;\n }\n async _refreshAuthTokenInner(refreshToken) {\n try {\n return await this._beanJwtAdapter.refreshAuthToken(refreshToken);\n } finally {\n this._refreshAuthTokenPromise = undefined;\n }\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { BeanInterceptorBase, Interceptor, SymbolInterceptorBodyResponseFlag } from 'zova-module-a-fetch';\n// not include: ERR_BAD_RESPONSE\nconst __ErrorsShouldBeMocked = ['ECONNREFUSED', 'ERR_NETWORK', '404'];\nexport let InterceptorMock = (_dec = Interceptor(), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorMock extends BeanInterceptorBase {\n async onResponseError(error, _options, next) {\n if (!(error instanceof Error)) return next();\n if (this.sys.env.MOCK_ENABLED === 'true') {\n if (process.env.DEV || process.env.PROD && this.sys.env.MOCK_BUILD === 'true') {\n if (__ErrorsShouldBeMocked.includes(String(error.code)) || error.status === 404) {\n const config = error.config;\n if (config.baseURL) {\n const port = process.env.DEV ? this.sys.env.DEV_SERVER_PORT : this.sys.env.MOCK_BUILD_PORT;\n let baseURL = `http://localhost:${port}`;\n if (config.baseURL.endsWith(this.sys.env.API_PREFIX)) {\n baseURL = `${baseURL}${this.sys.env.API_PREFIX}`;\n }\n if (config.baseURL !== baseURL && config.baseURL !== this.sys.env.API_PREFIX) {\n const response = await this.$fetch.request(Object.assign({}, config, {\n baseURL\n }));\n if (response && response[SymbolInterceptorBodyResponseFlag]) {\n return response.data;\n } else {\n return response;\n }\n }\n }\n }\n }\n }\n return next();\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { catchError } from '@cabloy/utils';\nimport { cast } from 'zova';\nimport { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';\nexport let InterceptorPerformAction = (_dec = Interceptor({\n dependencies: 'a-interceptor:jwt'\n}), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class InterceptorPerformAction extends BeanInterceptorBase {\n async onRequest(config, _options, next) {\n if (process.env.CLIENT) return next();\n const performAction = this.ctx.meta.$ssr.getPerformAction(config.baseURL);\n if (!performAction) return next();\n const data = {\n method: config.method,\n path: config.url,\n query: config.params,\n body: config.data,\n headers: config.headers\n };\n const [result, error] = await catchError(() => {\n return performAction(data);\n });\n if (error) {\n cast(error).config = config;\n throw error;\n }\n throw result;\n }\n}) || _class) || _class);","export const config = _sys => {\n return {\n jwtAdapter: 'home-api:jwtAdapter',\n authToken: {\n default: true\n }\n };\n};","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** interceptor: begin */\nexport * from '../bean/interceptor.body.ts';\nexport * from '../bean/interceptor.headers.ts';\nexport * from '../bean/interceptor.jwt.ts';\nexport * from '../bean/interceptor.mock.ts';\nexport * from '../bean/interceptor.performAction.ts';\nimport 'zova-module-a-fetch';\n/** interceptor: end */\n/** interceptor: begin */\n\nimport 'zova';\n/** interceptor: end */\n/** config: begin */\nexport * from '../config/config.ts';\n/** config: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleAInterceptor = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-interceptor\"\n}), _dec(_class = _dec2(_class = class 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QAAQ,OAAO;GACf,MAAM,OAAO;GACb,OAAO,OAAO;GACd,MAAM,OAAO;GACb,SAAS,OAAO;EAClB;EACA,MAAM,CAAC,QAAQ,SAAS,MAAM,iBAAiB;GAC7C,OAAO,cAAc,IAAI;EAC3B,CAAC;EACD,IAAI,OAAO;GACT,KAAK,KAAK,CAAC,CAAC,SAAS;GACrB,MAAM;EACR;EACA,MAAM;CACR;AACF,CAAC,KAAKC,QAAM,KAAKA;;;AC9BjB,IAAa,UAAS,SAAQ;CAC5B,OAAO;EACL,YAAY;EACZ,WAAW,EACT,SAAS,KACX;CACF;AACF;;;ACPA,IAAI;AAAM,IAAA;AAAO,IAAA;AAqBjB,IAAW,2BAA2B,OAAO,MAAM,GAAG,QAAQE,SAAa,EACzE,QAAQ,gBACV,CAAC,GAAG,KAAK,SAAS,MAAM,SAAS,MAAM,gCAAgC,cAAc,CAAC,CAAC,KAAK,MAAM,KAAK"}
@@ -1,2 +1,2 @@
1
- export * from './jwt.js';
1
+ export * from './jwt.ts';
2
2
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-module-a-interceptor",
3
- "version": "5.1.31",
4
- "gitHead": "eb85d771ef75776a439e56df3af8be6a3a36c1c2",
3
+ "version": "5.1.32",
4
+ "gitHead": "c27fb3b5f3566b676b7d635e2e26545c6d389ad7",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -1,15 +1,15 @@
1
1
  // eslint-disable
2
2
  /** interceptor: begin */
3
- export * from '../bean/interceptor.body.js';
4
- export * from '../bean/interceptor.headers.js';
5
- export * from '../bean/interceptor.jwt.js';
6
- export * from '../bean/interceptor.mock.js';
7
- export * from '../bean/interceptor.performAction.js';
8
- import { IInterceptorOptionsBody } from '../bean/interceptor.body.js';
9
- import { IInterceptorOptionsHeaders } from '../bean/interceptor.headers.js';
10
- import { IInterceptorOptionsJwt } from '../bean/interceptor.jwt.js';
11
- import { IInterceptorOptionsMock } from '../bean/interceptor.mock.js';
12
- import { IInterceptorOptionsPerformAction } from '../bean/interceptor.performAction.js';
3
+ export * from '../bean/interceptor.body.ts';
4
+ export * from '../bean/interceptor.headers.ts';
5
+ export * from '../bean/interceptor.jwt.ts';
6
+ export * from '../bean/interceptor.mock.ts';
7
+ export * from '../bean/interceptor.performAction.ts';
8
+ import { IInterceptorOptionsBody } from '../bean/interceptor.body.ts';
9
+ import { IInterceptorOptionsHeaders } from '../bean/interceptor.headers.ts';
10
+ import { IInterceptorOptionsJwt } from '../bean/interceptor.jwt.ts';
11
+ import { IInterceptorOptionsMock } from '../bean/interceptor.mock.ts';
12
+ import { IInterceptorOptionsPerformAction } from '../bean/interceptor.performAction.ts';
13
13
  import 'zova-module-a-fetch';
14
14
  declare module 'zova-module-a-fetch' {
15
15
 
@@ -82,11 +82,11 @@ declare module 'zova-module-a-interceptor' {
82
82
  }
83
83
  /** interceptor: end */
84
84
  /** interceptor: begin */
85
- import { InterceptorBody } from '../bean/interceptor.body.js';
86
- import { InterceptorHeaders } from '../bean/interceptor.headers.js';
87
- import { InterceptorJwt } from '../bean/interceptor.jwt.js';
88
- import { InterceptorMock } from '../bean/interceptor.mock.js';
89
- import { InterceptorPerformAction } from '../bean/interceptor.performAction.js';
85
+ import type { InterceptorBody } from '../bean/interceptor.body.ts';
86
+ import type { InterceptorHeaders } from '../bean/interceptor.headers.ts';
87
+ import type { InterceptorJwt } from '../bean/interceptor.jwt.ts';
88
+ import type { InterceptorMock } from '../bean/interceptor.mock.ts';
89
+ import type { InterceptorPerformAction } from '../bean/interceptor.performAction.ts';
90
90
  import 'zova';
91
91
  declare module 'zova' {
92
92
  export interface IBeanRecordLocal {
@@ -99,8 +99,8 @@ declare module 'zova' {
99
99
  }
100
100
  /** interceptor: end */
101
101
  /** config: begin */
102
- export * from '../config/config.js';
103
- import { config } from '../config/config.js';
102
+ export * from '../config/config.ts';
103
+ import { config } from '../config/config.ts';
104
104
  /** config: end */
105
105
  /** scope: begin */
106
106
  import { BeanScopeBase, type BeanScopeUtil, TypeModuleConfig } from 'zova';
@@ -1,2 +1,2 @@
1
1
  export const __ThisModule__ = 'a-interceptor';
2
- export { ScopeModuleAInterceptor as ScopeModule } from './index.js';
2
+ export { ScopeModuleAInterceptor as ScopeModule } from './index.ts';
@@ -9,7 +9,7 @@ import type {
9
9
  import { $protocolKey } from 'zova';
10
10
  import { BeanInterceptorBase, Interceptor } from 'zova-module-a-fetch';
11
11
 
12
- import type { IJwtAdapter, IJwtInfo } from '../types/jwt.js';
12
+ import type { IJwtAdapter, IJwtInfo } from '../types/jwt.ts';
13
13
 
14
14
  export interface IInterceptorOptionsJwt extends IDecoratorInterceptorOptions {
15
15
  jwtAdapter?: string;
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './.metadata/index.js';
2
- export * from './types/index.js';
1
+ export * from './.metadata/index.ts';
2
+ export * from './types/index.ts';
@@ -1 +1 @@
1
- export * from './jwt.js';
1
+ export * from './jwt.ts';