anl 26.514.0 → 26.601.0

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,4 +1,4 @@
1
- import type { AxiosInstance } from 'axios'; // 默认 axios 可以替换成 fetch
1
+ import type { AxiosError, AxiosInstance } from 'axios'; // 默认 axios 可以替换成 fetch
2
2
 
3
3
  import axios from 'axios'; // 默认 axios 可以替换成 fetch
4
4
 
@@ -16,38 +16,8 @@ export const dio: AxiosInstance = axios.create({
16
16
  headers: {
17
17
  'Content-Type': 'application/json',
18
18
  },
19
- // 配置请求超时时间
20
- timeout: 30000,
21
- // http 状态码判断
22
- validateStatus(status: number) {
23
- switch (status) {
24
- case 200:
25
- return true;
26
- case 400:
27
- message.error({ type: 'error', content: '请求无效或格式错误!' });
28
- break;
29
- case 401:
30
- message.error({ type: 'error', content: '登录过期,请重新登陆!' });
31
- break;
32
- case 403:
33
- message.error({ type: 'error', content: '服务器拒绝请求!' });
34
- break;
35
- case 404:
36
- message.error({ type: 'error', content: '资源未找到' });
37
- break;
38
- case 500:
39
- message.error({ type: 'error', content: '服务器内部错误' });
40
- break;
41
- case 502:
42
- message.error({ type: 'error', content: '网关或代理服务器收到无效响应' });
43
- break;
44
- case 503:
45
- message.error({ type: 'error', content: '服务器暂时无法处理请求' });
46
- break;
47
- }
48
-
49
- return true;
50
- },
19
+ // 1 分钟等于 60000 毫秒,超时设置为10分钟
20
+ timeout: 600000,
51
21
  });
52
22
 
53
23
  /**
@@ -70,14 +40,64 @@ dio.interceptors.request.use(
70
40
  * @param response 响应数据
71
41
  * @returns 响应数据
72
42
  */
43
+ // 响应拦截 —— 成功(2xx)
73
44
  dio.interceptors.response.use(
74
- (response) => {
75
- // 对响应数据做处理,例如只返回data部分
76
- if (response.data.code === 4001) {
77
- // 退出登录逻辑 自己写
78
- // window.location.href = + 'login';
45
+ (response) => response,
46
+ (error: AxiosError<{ message?: string; data?: unknown }>) => {
47
+ // 网络错误或请求取消等,无 response
48
+ if (!error.response) {
49
+ message.error('网络异常,请检查网络连接');
50
+ return Promise.reject(error);
79
51
  }
80
- return response;
52
+
53
+ const { status, data } = error.response;
54
+
55
+ switch (status) {
56
+ case 400: {
57
+ const respData = data ?? {};
58
+ const payload = (respData as { data?: unknown }).data;
59
+ let errorMsg = (respData as { message?: string }).message ?? '请求参数错误';
60
+
61
+ if (typeof payload === 'string') {
62
+ errorMsg = payload;
63
+ } else if (payload && typeof payload === 'object' && 'errors' in payload) {
64
+ const errors = (payload as { errors?: { message?: string }[] }).errors;
65
+ if (Array.isArray(errors)) {
66
+ const collected = errors.map((item) => item?.message).filter((msg): msg is string => Boolean(msg));
67
+ if (collected.length) {
68
+ errorMsg = collected.join(';');
69
+ }
70
+ }
71
+ }
72
+
73
+ message.error(errorMsg);
74
+ break;
75
+ }
76
+ case 401:
77
+ message.error('登录过期,请重新登录');
78
+ if (window.location.pathname !== '/login') {
79
+ window.location.href = '/login';
80
+ }
81
+ break;
82
+ case 403:
83
+ message.error('服务器拒绝请求');
84
+ break;
85
+ case 404:
86
+ message.error('资源未找到');
87
+ break;
88
+ case 500:
89
+ message.error('服务器内部错误');
90
+ break;
91
+ case 502:
92
+ message.error('网关或代理服务器收到无效响应');
93
+ break;
94
+ case 503:
95
+ message.error('服务器暂时无法处理请求');
96
+ break;
97
+ default:
98
+ message.error(data?.message ?? '请求失败,请稍后重试');
99
+ }
100
+
101
+ return Promise.reject(error);
81
102
  },
82
- (error) => Promise.reject(error),
83
103
  );
package/lib/package.cjs CHANGED
@@ -1 +1 @@
1
- var e=`26.514.0`;Object.defineProperty(exports,`version`,{enumerable:!0,get:function(){return e}});
1
+ var e=`26.601.0`;Object.defineProperty(exports,`version`,{enumerable:!0,get:function(){return e}});
@@ -1,7 +1,7 @@
1
1
  const e=require(`../../utils/logger.cjs`);require(`../../utils/index.cjs`);const t=require(`../shared/format.cjs`),n=require(`../shared/naming.cjs`),r=require(`../shared/http.cjs`),i=require(`./naming.cjs`),a=require(`./schema-resolver.cjs`),o=require(`./writer.cjs`);var s=function(e){return e.GET=`get`,e.PUT=`put`,e.POST=`post`,e.DELETE=`delete`,e.OPTIONS=`options`,e.HEAD=`head`,e.PATCH=`patch`,e.TRACE=`trace`,e}(s||{});const c={typeMapping:new Map([[`integer`,`number`],[`string`,`string`],[`boolean`,`boolean`],[`binary`,`File`],[`number`,`number`],[`null`,`null`],[`undefined`,`undefined`],[`date`,`Date`],[`time`,`Date`],[`datetime`,`Date`],[`timestamp`,`Date`]]),errorHandling:{throwOnError:!1,logErrors:!0}};var l=class{pathsObject={};nonArrayType=[`boolean`,`object`,`number`,`string`,`integer`];pathKey=``;contentBody={payload:{path:[],query:[],header:[],body:[]},response:``,_response:``,fileName:``,method:``,requestPath:``,summary:``,apiName:``,typeName:``,deprecated:!1,contentType:`application/json`};Map=new Map;config;errors=[];parameters={};schemas={};schemaResolver;writer;apiListFileContent=[];allowedInterfaceKeys=new Set;allInterfaceKeys=new Set;constructor(e,n,r,i){this.pathsObject=e,this.parameters=n??{},this.schemas=r??{},this.config=t.applyFormattingDefaults({...c,...i,typeMapping:new Map([...c.typeMapping??[],...i.typeMapping??[]])}),this.schemaResolver=new a.SchemaResolver(this.config,this.schemas,this.parameters,this.handleError.bind(this)),this.writer=new o.PathWriter(this.config)}handleError(t){if(!t.path&&this.contentBody.requestPath&&(t.path=this.contentBody.requestPath),!t.method&&this.contentBody.method&&(t.method=this.contentBody.method),this.errors.push(t),this.config.errorHandling?.logErrors&&e.log.error(e.formatParseError(t)),this.config.errorHandling?.throwOnError)throw Error(`${t.type}: ${t.message}`)}getIndentation(){return t.getIndentation(this.config)}getDoubleIndentation(){let e=this.getIndentation();return e+e}generateParamComment(e,t){let n=[],r=[];if(e.description&&r.push(e.description),e.deprecated&&r.push(`@deprecated`),e.schema&&typeof e.schema==`object`&&`example`in e.schema){let t=e.schema.example,n=typeof t==`string`?t:JSON.stringify(t);r.push(`@example ${n}`)}if(e.schema&&typeof e.schema==`object`&&`default`in e.schema){let t=e.schema.default,n=typeof t==`string`?t:JSON.stringify(t);r.push(`@default ${n}`)}return r.length>0&&(r.length===1&&!r[0].includes(`
2
2
  `)?n.push(`${t}/** ${r[0]} */`):(n.push(`${t}/**`),r.forEach(e=>{e.includes(`
3
3
  `)?e.split(`
4
- `).forEach(e=>{n.push(`${t} * ${e}`)}):n.push(`${t} * ${e}`)}),n.push(`${t} */`))),n}parametersItemHandle(t,r,i,a){let o=this.getDoubleIndentation(),s=`$ref`in t?t:null,c=`name`in t?t:null;if(s?.$ref&&s.$ref.startsWith(`#/components/parameters/`)&&this.parameters){let e=s.$ref.replace(`#/components/parameters/`,``),t=this.parameters[e];this.parametersItemHandle(t,r,i,a)}if(c){if(!c.schema){this.handleError({type:`PARAMETERS`,message:`Parameter "${c.name}" has no schema defined, skipping`});return}let t=this.schemaResolver.main(c.schema);if(!t||typeof t!=`string`){this.handleError({type:`PARAMETERS`,message:`Failed to parse schema for parameter "${c.name}"`,details:t});return}if(c.in===`path`){this.generateParamComment(c,o).forEach(e=>r.push(e));let e=n.sanitizeIdentifierName(c.name);r.push(`${o}${e}: ${t};`),this.contentBody.payload._path?this.contentBody.payload._path[e]=t:this.contentBody.payload._path={[e]:t}}else if(c.in===`query`){this.generateParamComment(c,o).forEach(e=>i.push(e));let e=c.required===!0?``:`?`,r=n.formatPropertyName(c.name);i.push(`${o}${r}${e}: ${t};`),this.contentBody.payload._query?this.contentBody.payload._query[c.name]=t:this.contentBody.payload._query={[c.name]:t}}else if(c.in===`header`){this.generateParamComment(c,o).forEach(e=>a.push(e));let e=c.required===!0?``:`?`,r=n.formatPropertyName(c.name);a.push(`${o}${r}${e}: ${t};`),this.contentBody.payload._header?this.contentBody.payload._header[c.name]=t:this.contentBody.payload._header={[c.name]:t}}else c.in===`cookie`?e.log.verbose(`Cookie parameter "${c.name}" detected but not added to type definition`):this.handleError({type:`PARAMETERS`,message:`Unknown parameter location "${c.in}" for parameter "${c.name}"`})}}requestParametersParse(e){let t=this.getIndentation(),n=[],r=[],i=[];e?.map(e=>this.parametersItemHandle(e,n,r,i)),n.length!==0&&(n.unshift(`${t}namespace Path {`),n.push(`${t}}`)),r.length!==0&&(r.unshift(`${t}interface Query {`),r.push(`${t}}`)),i.length!==0&&(i.unshift(`${t}interface Header {`),i.push(`${t}}`)),this.contentBody.payload.path=n,this.contentBody.payload.query=r,this.contentBody.payload.header=i}pickRequestBodyContent(e){let t=e.content;if(!t||typeof t!=`object`)return{schema:null};for(let e of[`multipart/form-data`,`application/x-www-form-urlencoded`]){let n=t[e];if(n&&typeof n==`object`&&n.schema)return{schema:n.schema}}let n=Object.keys(t)[0],r=n?t[n]:null;return{schema:r&&typeof r==`object`&&r.schema?r.schema:null}}requestBodyObjectParse(e){let t=this.getIndentation(),{schema:n}=this.pickRequestBodyContent(e);if(n){let e=n?.type,r=`$ref`in n?n:null,i=e===`array`?n:null,a=e&&this.nonArrayType.includes(e)?n:null;if(r)return`${t}type Body = ${this.schemaResolver.referenceObjectParse(r)}`;if(i)return`${t}type Body = ${this.schemaResolver.arraySchemaObjectParse(i)}`;if(a){let e=this.schemaResolver.nonArraySchemaObjectParse(a);return Array.isArray(e)?e.length===0?[`${t}type Body = ${a.type};`]:[`${t}interface Body {`,...e,`}`]:[`${t}type Body = ${e}`]}}}requestBodyParse(e){if(!e)return`{}`;let t=`$ref`in e?e:null,n=`content`in e?e:null;if(t){let e=this.schemaResolver.referenceObjectParse(t);return`${this.getIndentation()}type Body = ${e}`}return n&&Object.keys(e).length!==0?this.requestBodyObjectParse(n):`{}`}normalizemodulePrefix(e){if(!e||e.trim()===``)return``;let t=e.trim();return t=t.replace(/\/+$/g,``),t.startsWith(`/`)||(t=`/`+t),t}apiRequestItemHandle(e){let{payload:t,requestPath:n,_response:i,method:a,typeName:o,apiName:s,contentType:c}=e,{_path:l,_query:u,body:d}=t,f=e.dataLevel??this.config.dataLevel??`serve`,p=this.normalizemodulePrefix(this.config.modulePrefix),m=()=>{let e=[],t=Object.keys(l??{}).sort();for(let n of t)e.push(`${n}: ${o}.Path.${n}`);let n=e.join(e.length>1?`,`:``);return n===``?n:n+`,`},h=()=>{let e=u?`query: ${o}.Query,`:``;return e===``?``:`${e}`},g=()=>{let e=d.length>0?`body: ${o}.Body,`:``;return e===``?``:`${e}`},_=m(),v=h(),y=g(),b=()=>{let e=r.SUPPORTED_REQUEST_UPLOAD_TYPES.includes(c)?`headers: { 'Content-Type': '${c}' }`:void 0;return[`{`,e?`${e},`:``,`...params, `,v===``?``:`query,`,y===``?``:`body,`,`},`].join(``)},x=(_+v+y).replace(/,$/,``);return[`export const ${s} = `,`(`,x,x===``?`params?: IRequestFnParams`:`, params?: IRequestFnParams`,`)`,` => `,a,`${i?`<${o}.Response>`:``}`,`(`,`\`${p}${n}\`,`,b(),`'${f}'`,`);`].join(``)}responseHandle(e){let t=e[200];if(!t)return;let n=`content`in t?t:null,r=`$ref`in t?t:null;if(n===null&&r===null&&(this.contentBody.response=`type Response = unknown`,this.contentBody._response=`unknown`),r){let e=this.schemaResolver.referenceObjectParse(r);this.config.responseModelTransform&&(e=this.schemaResolver.transformResponseModel(e,this.config.responseModelTransform)),this.contentBody.response=`type Response = ${e}`,this.contentBody._response=e}if(n){let e=this.schemaResolver.responseObjectParse(n);if(this.config.responseModelTransform&&(e=this.schemaResolver.transformResponseModel(e,this.config.responseModelTransform)),Array.isArray(e)){if(e.length===1&&e[0]===`unknown`)this.contentBody.response=`type Response = ${e.join(`
4
+ `).forEach(e=>{n.push(`${t} * ${e}`)}):n.push(`${t} * ${e}`)}),n.push(`${t} */`))),n}parametersItemHandle(t,r,i,a){let o=this.getDoubleIndentation(),s=`$ref`in t?t:null,c=`name`in t?t:null;if(s?.$ref&&s.$ref.startsWith(`#/components/parameters/`)&&this.parameters){let e=s.$ref.replace(`#/components/parameters/`,``),t=this.parameters[e];this.parametersItemHandle(t,r,i,a)}if(c){if(!c.schema){this.handleError({type:`PARAMETERS`,message:`Parameter "${c.name}" has no schema defined, skipping`});return}let t=this.schemaResolver.main(c.schema);if(!t||typeof t!=`string`){this.handleError({type:`PARAMETERS`,message:`Failed to parse schema for parameter "${c.name}"`,details:t});return}if(c.in===`path`){this.generateParamComment(c,o).forEach(e=>r.push(e));let e=n.sanitizeIdentifierName(c.name);r.push(`${o}type ${e} = ${t};`),this.contentBody.payload._path?this.contentBody.payload._path[e]=t:this.contentBody.payload._path={[e]:t}}else if(c.in===`query`){this.generateParamComment(c,o).forEach(e=>i.push(e));let e=c.required===!0?``:`?`,r=n.formatPropertyName(c.name);i.push(`${o}${r}${e}: ${t};`),this.contentBody.payload._query?this.contentBody.payload._query[c.name]=t:this.contentBody.payload._query={[c.name]:t}}else if(c.in===`header`){this.generateParamComment(c,o).forEach(e=>a.push(e));let e=c.required===!0?``:`?`,r=n.formatPropertyName(c.name);a.push(`${o}${r}${e}: ${t};`),this.contentBody.payload._header?this.contentBody.payload._header[c.name]=t:this.contentBody.payload._header={[c.name]:t}}else c.in===`cookie`?e.log.verbose(`Cookie parameter "${c.name}" detected but not added to type definition`):this.handleError({type:`PARAMETERS`,message:`Unknown parameter location "${c.in}" for parameter "${c.name}"`})}}requestParametersParse(e){let t=this.getIndentation(),n=[],r=[],i=[];e?.map(e=>this.parametersItemHandle(e,n,r,i)),n.length!==0&&(n.unshift(`${t}namespace Path {`),n.push(`${t}}`)),r.length!==0&&(r.unshift(`${t}interface Query {`),r.push(`${t}}`)),i.length!==0&&(i.unshift(`${t}interface Header {`),i.push(`${t}}`)),this.contentBody.payload.path=n,this.contentBody.payload.query=r,this.contentBody.payload.header=i}pickRequestBodyContent(e){let t=e.content;if(!t||typeof t!=`object`)return{schema:null};for(let e of[`multipart/form-data`,`application/x-www-form-urlencoded`]){let n=t[e];if(n&&typeof n==`object`&&n.schema)return{schema:n.schema}}let n=Object.keys(t)[0],r=n?t[n]:null;return{schema:r&&typeof r==`object`&&r.schema?r.schema:null}}requestBodyObjectParse(e){let t=this.getIndentation(),{schema:n}=this.pickRequestBodyContent(e);if(n){let e=n?.type,r=`$ref`in n?n:null,i=e===`array`?n:null,a=e&&this.nonArrayType.includes(e)?n:null;if(r)return`${t}type Body = ${this.schemaResolver.referenceObjectParse(r)}`;if(i)return`${t}type Body = ${this.schemaResolver.arraySchemaObjectParse(i)}`;if(a){let e=this.schemaResolver.nonArraySchemaObjectParse(a);return Array.isArray(e)?e.length===0?[`${t}type Body = ${a.type};`]:[`${t}interface Body {`,...e,`}`]:[`${t}type Body = ${e}`]}}}requestBodyParse(e){if(!e)return`{}`;let t=`$ref`in e?e:null,n=`content`in e?e:null;if(t){let e=this.schemaResolver.referenceObjectParse(t);return`${this.getIndentation()}type Body = ${e}`}return n&&Object.keys(e).length!==0?this.requestBodyObjectParse(n):`{}`}normalizemodulePrefix(e){if(!e||e.trim()===``)return``;let t=e.trim();return t=t.replace(/\/+$/g,``),t.startsWith(`/`)||(t=`/`+t),t}apiRequestItemHandle(e){let{payload:t,requestPath:n,_response:i,method:a,typeName:o,apiName:s,contentType:c}=e,{_path:l,_query:u,body:d}=t,f=e.dataLevel??this.config.dataLevel??`serve`,p=this.normalizemodulePrefix(this.config.modulePrefix),m=()=>{let e=[],t=Object.keys(l??{}).sort();for(let n of t)e.push(`${n}: ${o}.Path.${n}`);let n=e.join(e.length>1?`,`:``);return n===``?n:n+`,`},h=()=>{let e=u?`query: ${o}.Query,`:``;return e===``?``:`${e}`},g=()=>{let e=d.length>0?`body: ${o}.Body,`:``;return e===``?``:`${e}`},_=m(),v=h(),y=g(),b=()=>{let e=r.SUPPORTED_REQUEST_UPLOAD_TYPES.includes(c)?`headers: { 'Content-Type': '${c}' }`:void 0;return[`{`,e?`${e},`:``,`...params, `,v===``?``:`query,`,y===``?``:`body,`,`},`].join(``)},x=(_+v+y).replace(/,$/,``);return[`export const ${s} = `,`(`,x,x===``?`params?: IRequestFnParams`:`, params?: IRequestFnParams`,`)`,` => `,a,`${i?`<${o}.Response>`:``}`,`(`,`\`${p}${n}\`,`,b(),`'${f}'`,`);`].join(``)}responseHandle(e){let t=e[200];if(!t)return;let n=`content`in t?t:null,r=`$ref`in t?t:null;if(n===null&&r===null&&(this.contentBody.response=`type Response = unknown`,this.contentBody._response=`unknown`),r){let e=this.schemaResolver.referenceObjectParse(r);this.config.responseModelTransform&&(e=this.schemaResolver.transformResponseModel(e,this.config.responseModelTransform)),this.contentBody.response=`type Response = ${e}`,this.contentBody._response=e}if(n){let e=this.schemaResolver.responseObjectParse(n);if(this.config.responseModelTransform&&(e=this.schemaResolver.transformResponseModel(e,this.config.responseModelTransform)),Array.isArray(e)){if(e.length===1&&e[0]===`unknown`)this.contentBody.response=`type Response = ${e.join(`
5
5
  `)};`;else{let t=this.config.formatting?.lineEnding,n=this.config.formatting?.indentation;this.contentBody.response=`interface Response {${t}${e.join(`
6
6
  `)}${t}${n}};`}this.contentBody._response=`${e.join(`
7
7
  `)}`}else this.contentBody.response=`type Response = ${e}`,this.contentBody._response=`${e}`}}requestHandle(e){if(e.parameters&&this.requestParametersParse(e.parameters),e.requestBody){let t=this.requestBodyParse(e.requestBody);if(Array.isArray(t))this.contentBody.payload.body=t;else if(t){let e=t?.split(`
@@ -1 +1 @@
1
- const e=require(`../shared/naming.cjs`);function t(e){let t=e.replace(/^[0-9]+/,``);return t?(t=t.replace(/[^a-zA-Z0-9_.-]/g,``),t):`num`+e}function n(e,n=!1){let r=t(e).split(/[-_.]+/).filter(e=>e.length>0);return r.length===0?``:r.map((e,t)=>t===0&&n?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function r(e){let n=t(e).split(/[-_.]+/).filter(e=>e.length>0);return n.length===0?``:n.map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function i(e){return e?e.replace(/^\/+|\/+$/g,``):``}function a(e,t){let n=t.replace(/^\/+/,``),r=i(e.publicPrefix);if(r&&n.startsWith(r+`/`))n=n.slice(r.length+1);else if(r&&n===r)n=``;else if(r&&n.startsWith(r)){let e=n.slice(r.length);(e.startsWith(`/`)||e===``)&&(n=e.replace(/^\/+/,``))}return n}function o(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];i.type===`normal`&&a?.type===`param`&&t(i.normalized).toLowerCase().replace(/[-_.]/g,``)===t(a.normalized).toLowerCase().replace(/[-_.]/g,``)||n.push(i)}return n}function s(i,s){let c=i;i.startsWith(`/`)||(c=`/`+i);let[l,u]=c.split(`|`),d=a(s,l),f=d?d.split(`/`).filter(e=>e):[],p=o(f.map(e=>e.startsWith(`{`)&&e.endsWith(`}`)?{type:`param`,original:e,normalized:e.slice(1,-1)}:{type:`normal`,original:e,normalized:e})),m=s.parameterSeparator??`_`,h=``,g=[],_=e=>{if(g.length>0){let t=g.map((t,r)=>n(t,e&&r===0)).join(``);h+=(h&&g.length>0?m:``)+t,g=[]}};for(let e of p)if(e.type===`normal`)g.push(e.normalized);else{_(h===``);let n=t(e.normalized);h+=(h?m:``)+n}_(h===``);let v=``;g=[];let y=()=>{if(g.length>0){let e=g.map(e=>r(e)).join(``);v+=(v&&g.length>0?m:``)+e,g=[]}};for(let e of p)if(e.type===`normal`)g.push(e.normalized);else{y();let t=r(e.normalized);v+=(v?m:``)+t}y();let b=``;f.length>0?(b=f.map(e=>e.replace(/[{}]/g,``)).join(`-`),b=`${b}-${u}`.toLowerCase()):b=`${u}`.toLowerCase();let x=`/`+d;d||(x=`/`),x=x.replace(/\{(\w+)\}/g,(e,t)=>`\${${t}}`);let S=v?`${v}_${u}`:u,C=e.getNamespacePrefix(s),w=C?`${C}_${S}`:S;return{apiName:h?`${h}_${u}`:u,fileName:b,typeName:w,path:x}}exports.convertEndpointString=s;
1
+ const e=require(`../shared/naming.cjs`);function t(e){let t=e.replace(/^[0-9]+/,``);return t?(t=t.replace(/[^a-zA-Z0-9_.-]/g,``),t):`num`+e}function n(e,n=!1){let r=t(e).split(/[-_.]+/).filter(e=>e.length>0);return r.length===0?``:r.map((e,t)=>t===0&&n?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function r(e){let n=t(e).split(/[-_.]+/).filter(e=>e.length>0);return n.length===0?``:n.map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function i(e){return e?e.replace(/^\/+|\/+$/g,``):``}function a(e,t){let n=t.replace(/^\/+/,``),r=i(e.publicPrefix);if(r&&n.startsWith(r+`/`))n=n.slice(r.length+1);else if(r&&n===r)n=``;else if(r&&n.startsWith(r)){let e=n.slice(r.length);(e.startsWith(`/`)||e===``)&&(n=e.replace(/^\/+/,``))}return n}function o(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];i.type===`normal`&&a?.type===`param`&&t(i.normalized).toLowerCase().replace(/[-_.]/g,``)===t(a.normalized).toLowerCase().replace(/[-_.]/g,``)||n.push(i)}return n}function s(i,s){let c=i;i.startsWith(`/`)||(c=`/`+i);let[l,u]=c.split(`|`),d=a(s,l),f=d?d.split(`/`).filter(e=>e):[],p=o(f.map(e=>e.startsWith(`{`)&&e.endsWith(`}`)?{type:`param`,original:e,normalized:e.slice(1,-1)}:{type:`normal`,original:e,normalized:e})),m=s.parameterSeparator??`_`,h=``,g=[],_=e=>{if(g.length>0){let t=g.map((t,r)=>n(t,e&&r===0)).join(``);h+=(h&&g.length>0?m:``)+t,g=[]}};for(let e of p)if(e.type===`normal`)g.push(e.normalized);else{_(h===``);let n=t(e.normalized);h+=(h?m:``)+n}_(h===``);let v=``;g=[];let y=()=>{if(g.length>0){let e=g.map(e=>r(e)).join(``);v+=(v&&g.length>0?m:``)+e,g=[]}};for(let e of p)if(e.type===`normal`)g.push(e.normalized);else{y();let t=r(e.normalized);v+=(v?m:``)+t}y();let b=``;f.length>0?(b=f.map(e=>e.replace(/[{}]/g,``)).join(`-`),b=`${b}-${u}`.toLowerCase()):b=`${u}`.toLowerCase();let x=`/`+d;d||(x=`/`),x=x.replace(/\{([\w-]+)\}/g,(e,t)=>`\${${t.replace(/-/g,`_`)}}`);let S=v?`${v}_${u}`:u,C=e.getNamespacePrefix(s),w=C?`${C}_${S}`:S;return{apiName:h?`${h}_${u}`:u,fileName:b,typeName:w,path:x}}exports.convertEndpointString=s;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anl",
3
- "version": "26.514.0",
3
+ "version": "26.601.0",
4
4
  "description": "FE command line tool",
5
5
  "main": "bin/an-cli.js",
6
6
  "exports": {