@boteteam/utils 0.0.19 → 0.0.20
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.
- package/dist/cjs/formatModule/formatModuleData.js +13 -13
- package/dist/cjs/formatModule/formatModuleData.js.map +2 -2
- package/dist/cjs/http.d.ts +39 -0
- package/dist/cjs/http.js +236 -0
- package/dist/cjs/http.js.map +7 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/formatModule/formatModuleData.js +16 -15
- package/dist/esm/formatModule/formatModuleData.js.map +1 -1
- package/dist/esm/http.d.ts +39 -0
- package/dist/esm/http.js +254 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -92,6 +92,19 @@ var formatModuleData = ({
|
|
|
92
92
|
moduleDataRes.compProps.title = (0, import_helpers.stringPramarsValTransition)(otherCompProps == null ? void 0 : otherCompProps.title, allParametrs);
|
|
93
93
|
}
|
|
94
94
|
moduleDataRes.parentCompProps = (parentModuleData == null ? void 0 : parentModuleData.compProps) || {};
|
|
95
|
+
if (compType === "page") {
|
|
96
|
+
if (events && (events == null ? void 0 : events.length) > 0) {
|
|
97
|
+
const onLoadEvent = events.find(
|
|
98
|
+
(item) => (item == null ? void 0 : item.key) === "pageLoad"
|
|
99
|
+
);
|
|
100
|
+
if (onLoadEvent) {
|
|
101
|
+
moduleDataRes.compProps.onLoad = onLoadEvent == null ? void 0 : onLoadEvent.event;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (eventFlag) {
|
|
105
|
+
moduleDataRes.compProps.eventFlag = { checked: true };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
95
108
|
if (["panel", "div", "page"].indexOf(compType) >= 0 && Array.isArray(children) && children.length > 0) {
|
|
96
109
|
const childs = children.map((item) => {
|
|
97
110
|
return formatModuleData({
|
|
@@ -105,19 +118,6 @@ var formatModuleData = ({
|
|
|
105
118
|
});
|
|
106
119
|
});
|
|
107
120
|
moduleDataRes.children = childs;
|
|
108
|
-
if (compType === "page") {
|
|
109
|
-
if (events && (events == null ? void 0 : events.length) > 0) {
|
|
110
|
-
const onLoadEvent = events.find(
|
|
111
|
-
(item) => (item == null ? void 0 : item.key) === "pageLoad"
|
|
112
|
-
);
|
|
113
|
-
if (onLoadEvent) {
|
|
114
|
-
moduleDataRes.compProps.onLoad = onLoadEvent == null ? void 0 : onLoadEvent.event;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (eventFlag) {
|
|
118
|
-
moduleDataRes.compProps.eventFlag = { checked: true };
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
121
|
} else {
|
|
122
122
|
if (otherCompProps && ((_a = Object == null ? void 0 : Object.keys(otherCompProps)) == null ? void 0 : _a.length) > 0) {
|
|
123
123
|
Object == null ? void 0 : Object.keys(otherCompProps).forEach((compPropKey) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/formatModule/formatModuleData.ts"],
|
|
4
|
-
"sourcesContent": ["import 'ses';\nimport { getDataArr } from '../treeUtils';\nimport {\n urlPrefix,\n formatListProps,\n formatTableProps,\n formatCarouselProps,\n formatImageProps,\n formatFormProps,\n formatHighCodeProps,\n formatDescriptionsProps,\n formatLoopProps,\n formatStyleProps,\n formatEchartLineProps,\n formatEchartPieProps,\n formatChartsProps,\n formatStepsProps,\n staticCodeAssemble,\n stringPramarsValTransition,\n} from './helpers';\n\ntype formatModuleProps = {\n moduleData: { [key: string]: any } | null; // 页面配置数据\n parentModuleData?: { [key: string]: any } | null; // 父级配置数据\n pageData?: { [key: string]: any } | null; // 页面组件数据\n parameters?: any; // 入参上下文\n loopItemData?: any; // 循环体数据\n staticCodeList?: { [key: string]: any } | null; // 静态资源数据\n disabled?: boolean;\n};\n\nconst formatModuleData = ({\n moduleData,\n parentModuleData,\n parameters,\n loopItemData,\n staticCodeList,\n disabled,\n pageData,\n}: formatModuleProps): { [key: string]: any } | null => {\n let moduleDataRes: { [key: string]: any } = { };\n const allParametrs:{ [key: string]: any } = {\n ...(parameters || {}),\n pageData: pageData || {},\n loopItem: loopItemData || {},\n }; // 把页面数据与入参组装到一起\n const {\n staticCodeMap,\n staticOptionsMap,\n } = staticCodeAssemble(staticCodeList);\n\n if (moduleData) {\n const {\n compProps,\n compType,\n children,\n moduleTitle,\n moduleDescribe,\n id,\n } = moduleData;\n // 组装静态数据映射\n moduleDataRes = {\n ...moduleData,\n key: id,\n disabled,\n compProps: {},\n originModule: moduleData, // 配置moduled的信息\n };\n const {\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n columns: compColumns,\n tableBodyHeight,\n fileProps,\n attrs,\n rowSelection,\n hasSelectAll,\n rowKey,\n fieldName,\n column,\n articleContent,\n eventFlag,\n events,\n ...otherCompProps // 无需处理的属性\n } = compProps || {};\n if (moduleTitle) {\n moduleDataRes.moduleTitle = stringPramarsValTransition(moduleTitle, allParametrs);\n }\n if (moduleDescribe) {\n moduleDataRes.moduleDescribe = stringPramarsValTransition(moduleDescribe, allParametrs);\n }\n if (otherCompProps?.title) {\n moduleDataRes.compProps.title = stringPramarsValTransition(otherCompProps?.title, allParametrs);\n }\n \n moduleDataRes.parentCompProps = parentModuleData?.compProps || {};\n if (\n ['panel', 'div', 'page'].indexOf(compType) >= 0 &&\n Array.isArray(children) &&\n children.length > 0\n ) {\n const childs = children.map((item) => {\n return formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n parameters,\n loopItemData,\n staticCodeList,\n disabled,\n pageData,\n });\n });\n moduleDataRes.children = childs;\n if (compType === 'page') {\n if (events && events?.length > 0) {\n const onLoadEvent = events.find(\n (item: any) => item?.key === 'pageLoad',\n );\n if (onLoadEvent) {\n moduleDataRes.compProps.onLoad = onLoadEvent?.event;\n }\n }\n if (eventFlag) {\n moduleDataRes.compProps.eventFlag = { checked: true };\n }\n }\n } else {\n if (otherCompProps && Object?.keys(otherCompProps)?.length > 0) {\n Object?.keys(otherCompProps).forEach(compPropKey => {\n if (otherCompProps?.[compPropKey] || typeof otherCompProps?.[compPropKey] === 'number') {\n moduleDataRes.compProps[compPropKey] = otherCompProps?.[compPropKey];\n }\n });\n }\n if (rowSelection) {\n moduleDataRes.compProps.rowSelection = rowSelection;\n if (hasSelectAll && rowSelection?.type === 'checkbox') {\n moduleDataRes.compProps.hasSelectAll = hasSelectAll;\n } else {\n delete moduleDataRes.compProps.hasSelectAll;\n }\n }\n const rowKeyIndexArr = getDataArr(rowKey);\n\n if (Array.isArray(rowKeyIndexArr) && rowKeyIndexArr.length > 0) {\n moduleDataRes.compProps.rowKey = rowKeyIndexArr.slice(-1)?.[0];\n }\n\n if (compType === 'typography') {\n if (articleContent) {\n moduleDataRes.compProps.articleContent = stringPramarsValTransition(articleContent, allParametrs);\n }\n }\n if (compType === 'iframe') {\n moduleDataRes.compProps.url = stringPramarsValTransition(\n otherCompProps?.url,\n allParametrs,\n );\n }\n\n if (compType === 'carousel' && compDataSource && compDataSource?.dataType) {\n const carouselProps = formatCarouselProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...carouselProps,\n };\n }\n if (compType === 'image' && compDataSource && compDataSource?.dataType) {\n const imageProps = formatImageProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...imageProps,\n };\n }\n\n if (compType === 'highCodeComp') {\n const highCodeCompProps = formatHighCodeProps({\n options: { fileProps },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...highCodeCompProps,\n };\n }\n\n if (compType === 'table') {\n const tableProps = formatTableProps({\n options: {\n ...otherCompProps,\n columns: compColumns,\n dataSource: compDataSource,\n attrs,\n tableBodyHeight,\n },\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...tableProps,\n };\n }\n if (compType === 'form') {\n const formProps = formatFormProps({\n options: {\n column,\n children,\n },\n parameters: allParametrs,\n staticCodeMap,\n staticOptionsMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...formProps,\n };\n }\n if (compType === 'descriptions') {\n const descriptionsProps = formatDescriptionsProps({\n options: {\n column,\n attrs,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...descriptionsProps,\n };\n }\n if (compType === 'loop') {\n const loopProps = formatLoopProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n const loopChilds:({[key:string]:any}|null)[] = [];\n if (\n Array.isArray(loopProps?.dataSource) && loopProps?.dataSource?.length > 0 &&\n Array.isArray(children) && children.length > 0\n ) {\n loopProps?.dataSource.forEach((dataItem) => {\n const dataItemKey = moduleDataRes?.compProps?.rowKey && dataItem?.[moduleDataRes?.compProps?.rowKey] ?\n dataItem?.[moduleDataRes?.compProps?.rowKey] : '';\n loopChilds.push({\n id: dataItemKey,\n key: dataItemKey,\n compType: 'loopItem',\n compProps: {},\n originItem: dataItem,\n children: children.map((item:{[key:string]:any}) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n loopItemData: typeof dataItem === 'object' ? dataItem : { item: dataItem },\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n });\n } else if (Array.isArray(children) && children.length > 0) {\n loopChilds.push({\n id: '1',\n key: '1',\n compType: 'loopItem',\n compProps: {},\n originItem: {},\n children: children.map((item:{[key:string]:any}) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n loopItemData: {},\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n }\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...loopProps,\n column,\n children: loopChilds,\n };\n }\n if (['list', 'card', 'recommendList'].includes(compType)) {\n const resProps = formatListProps({\n options: {\n ...otherCompProps,\n rowKey,\n rowSelection,\n attrs,\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n },\n urlPrefix,\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...resProps,\n };\n }\n if (['echartBar', 'echartLine'].includes(compType)) {\n const echartProps = formatEchartLineProps({\n options: { ...otherCompProps, dataSource: compDataSource },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'echartPie') {\n const echartProps = formatEchartPieProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'charts') {\n const chartsProps = formatChartsProps({\n options: {\n echartsOptions: compProps?.echartsOptions,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...chartsProps,\n };\n }\n }\n if (compType === 'steps') {\n const stepsProps = formatStepsProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...stepsProps,\n };\n }\n moduleDataRes.compProps.style = formatStyleProps(moduleData, parentModuleData);\n // 所有的模版 拼一个组装数据的key值\n if (moduleData?.compProps && fieldName) {\n moduleDataRes.compProps.fieldName =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,YAAY;AAAA,IAChG;AAEA,kBAAc,mBAAkB,qDAAkB,cAAa,CAAC;
|
|
4
|
+
"sourcesContent": ["import 'ses';\nimport { getDataArr } from '../treeUtils';\nimport {\n urlPrefix,\n formatListProps,\n formatTableProps,\n formatCarouselProps,\n formatImageProps,\n formatFormProps,\n formatHighCodeProps,\n formatDescriptionsProps,\n formatLoopProps,\n formatStyleProps,\n formatEchartLineProps,\n formatEchartPieProps,\n formatChartsProps,\n formatStepsProps,\n staticCodeAssemble,\n stringPramarsValTransition,\n} from './helpers';\n\ntype formatModuleProps = {\n moduleData: { [key: string]: any } | null; // 页面配置数据\n parentModuleData?: { [key: string]: any } | null; // 父级配置数据\n pageData?: { [key: string]: any } | null; // 页面组件数据\n parameters?: any; // 入参上下文\n loopItemData?: any; // 循环体数据\n staticCodeList?: { [key: string]: any } | null; // 静态资源数据\n disabled?: boolean;\n};\n\nconst formatModuleData = ({\n moduleData,\n parentModuleData,\n parameters,\n loopItemData,\n staticCodeList,\n disabled,\n pageData,\n}: formatModuleProps): { [key: string]: any } | null => {\n let moduleDataRes: { [key: string]: any } = { };\n const allParametrs:{ [key: string]: any } = {\n ...(parameters || {}),\n pageData: pageData || {},\n loopItem: loopItemData || {},\n }; // 把页面数据与入参组装到一起\n const {\n staticCodeMap,\n staticOptionsMap,\n } = staticCodeAssemble(staticCodeList);\n\n if (moduleData) {\n const {\n compProps,\n compType,\n children,\n moduleTitle,\n moduleDescribe,\n id,\n } = moduleData;\n // 组装静态数据映射\n moduleDataRes = {\n ...moduleData,\n key: id,\n disabled,\n compProps: {},\n originModule: moduleData, // 配置moduled的信息\n };\n const {\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n columns: compColumns,\n tableBodyHeight,\n fileProps,\n attrs,\n rowSelection,\n hasSelectAll,\n rowKey,\n fieldName,\n column,\n articleContent,\n eventFlag,\n events,\n ...otherCompProps // 无需处理的属性\n } = compProps || {};\n if (moduleTitle) {\n moduleDataRes.moduleTitle = stringPramarsValTransition(moduleTitle, allParametrs);\n }\n if (moduleDescribe) {\n moduleDataRes.moduleDescribe = stringPramarsValTransition(moduleDescribe, allParametrs);\n }\n if (otherCompProps?.title) {\n moduleDataRes.compProps.title = stringPramarsValTransition(otherCompProps?.title, allParametrs);\n }\n \n moduleDataRes.parentCompProps = parentModuleData?.compProps || {};\n // 处理page组件的onLoad事件\n if (compType === 'page') {\n if (events && events?.length > 0) {\n const onLoadEvent = events.find(\n (item: any) => item?.key === 'pageLoad',\n );\n if (onLoadEvent) {\n moduleDataRes.compProps.onLoad = onLoadEvent?.event;\n }\n }\n if (eventFlag) {\n moduleDataRes.compProps.eventFlag = { checked: true };\n }\n }\n if (\n ['panel', 'div', 'page'].indexOf(compType) >= 0 &&\n Array.isArray(children) &&\n children.length > 0\n ) {\n const childs = children.map((item) => {\n return formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n parameters,\n loopItemData,\n staticCodeList,\n disabled,\n pageData,\n });\n });\n moduleDataRes.children = childs;\n } else {\n if (otherCompProps && Object?.keys(otherCompProps)?.length > 0) {\n Object?.keys(otherCompProps).forEach(compPropKey => {\n if (otherCompProps?.[compPropKey] || typeof otherCompProps?.[compPropKey] === 'number') {\n moduleDataRes.compProps[compPropKey] = otherCompProps?.[compPropKey];\n }\n });\n }\n if (rowSelection) {\n moduleDataRes.compProps.rowSelection = rowSelection;\n if (hasSelectAll && rowSelection?.type === 'checkbox') {\n moduleDataRes.compProps.hasSelectAll = hasSelectAll;\n } else {\n delete moduleDataRes.compProps.hasSelectAll;\n }\n }\n const rowKeyIndexArr = getDataArr(rowKey);\n\n if (Array.isArray(rowKeyIndexArr) && rowKeyIndexArr.length > 0) {\n moduleDataRes.compProps.rowKey = rowKeyIndexArr.slice(-1)?.[0];\n }\n\n if (compType === 'typography') {\n if (articleContent) {\n moduleDataRes.compProps.articleContent = stringPramarsValTransition(articleContent, allParametrs);\n }\n }\n if (compType === 'iframe') {\n moduleDataRes.compProps.url = stringPramarsValTransition(\n otherCompProps?.url,\n allParametrs,\n );\n }\n\n if (compType === 'carousel' && compDataSource && compDataSource?.dataType) {\n const carouselProps = formatCarouselProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...carouselProps,\n };\n }\n if (compType === 'image' && compDataSource && compDataSource?.dataType) {\n const imageProps = formatImageProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...imageProps,\n };\n }\n\n if (compType === 'highCodeComp') {\n const highCodeCompProps = formatHighCodeProps({\n options: { fileProps },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...highCodeCompProps,\n };\n }\n\n if (compType === 'table') {\n const tableProps = formatTableProps({\n options: {\n ...otherCompProps,\n columns: compColumns,\n dataSource: compDataSource,\n attrs,\n tableBodyHeight,\n },\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...tableProps,\n };\n }\n if (compType === 'form') {\n const formProps = formatFormProps({\n options: {\n column,\n children,\n },\n parameters: allParametrs,\n staticCodeMap,\n staticOptionsMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...formProps,\n };\n }\n if (compType === 'descriptions') {\n const descriptionsProps = formatDescriptionsProps({\n options: {\n column,\n attrs,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...descriptionsProps,\n };\n }\n if (compType === 'loop') {\n const loopProps = formatLoopProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n const loopChilds:({[key:string]:any}|null)[] = [];\n if (\n Array.isArray(loopProps?.dataSource) && loopProps?.dataSource?.length > 0 &&\n Array.isArray(children) && children.length > 0\n ) {\n loopProps?.dataSource.forEach((dataItem) => {\n const dataItemKey = moduleDataRes?.compProps?.rowKey && dataItem?.[moduleDataRes?.compProps?.rowKey] ?\n dataItem?.[moduleDataRes?.compProps?.rowKey] : '';\n loopChilds.push({\n id: dataItemKey,\n key: dataItemKey,\n compType: 'loopItem',\n compProps: {},\n originItem: dataItem,\n children: children.map((item:{[key:string]:any}) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n loopItemData: typeof dataItem === 'object' ? dataItem : { item: dataItem },\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n });\n } else if (Array.isArray(children) && children.length > 0) {\n loopChilds.push({\n id: '1',\n key: '1',\n compType: 'loopItem',\n compProps: {},\n originItem: {},\n children: children.map((item:{[key:string]:any}) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n loopItemData: {},\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n }\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...loopProps,\n column,\n children: loopChilds,\n };\n }\n if (['list', 'card', 'recommendList'].includes(compType)) {\n const resProps = formatListProps({\n options: {\n ...otherCompProps,\n rowKey,\n rowSelection,\n attrs,\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n },\n urlPrefix,\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...resProps,\n };\n }\n if (['echartBar', 'echartLine'].includes(compType)) {\n const echartProps = formatEchartLineProps({\n options: { ...otherCompProps, dataSource: compDataSource },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'echartPie') {\n const echartProps = formatEchartPieProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'charts') {\n const chartsProps = formatChartsProps({\n options: {\n echartsOptions: compProps?.echartsOptions,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...chartsProps,\n };\n }\n }\n if (compType === 'steps') {\n const stepsProps = formatStepsProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...stepsProps,\n };\n }\n moduleDataRes.compProps.style = formatStyleProps(moduleData, parentModuleData);\n // 所有的模版 拼一个组装数据的key值\n if (moduleData?.compProps && fieldName) {\n moduleDataRes.compProps.fieldName = fieldName;\n }\n }\n\n return moduleDataRes;\n};\n\nexport default formatModuleData;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAO;AACP,uBAA2B;AAC3B,qBAiBO;AAYP,IAAM,mBAAmB,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AAvCxD;AAwCE,MAAI,gBAAwC,CAAE;AAC9C,QAAM,eAAsC;AAAA,IAC1C,GAAI,cAAc,CAAC;AAAA,IACnB,UAAU,YAAY,CAAC;AAAA,IACvB,UAAU,gBAAgB,CAAC;AAAA,EAC7B;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,QAAI,mCAAmB,cAAc;AAErC,MAAI,YAAY;AACd,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,oBAAgB;AAAA,MACd,GAAG;AAAA,MACH,KAAK;AAAA,MACL;AAAA,MACA,WAAW,CAAC;AAAA,MACZ,cAAc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AACxB,YAAM,iBAAa,iCAAiB;AAAA,QAClC,SAAS;AAAA,UACP,YAAY;AAAA,UACZ,GAAG;AAAA,QACL;AAAA,QACA,YAAY;AAAA,MACd,CAAC;AACD,oBAAc,YAAY;AAAA,QACxB,GAAI,cAAc,aAAa,CAAC;AAAA,QAChC,GAAG;AAAA,MACL;AAAA,IACF;AACA,kBAAc,UAAU,YAAQ,iCAAiB,YAAY,gBAAgB;AAE7E,SAAI,yCAAY,cAAa,WAAW;AACtC,oBAAc,UAAU,YAAY;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": ["_a", "_b", "_c"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const tenantIdSessionKey: string;
|
|
2
|
+
/**
|
|
3
|
+
* 构造管理平台或机器人工程的完整访问地址
|
|
4
|
+
* @param url 环境变量中配置的地址
|
|
5
|
+
*/
|
|
6
|
+
export declare const getAccessUrl: (url: string | undefined) => string;
|
|
7
|
+
declare const request: {
|
|
8
|
+
getBaseUrl: () => string;
|
|
9
|
+
setUrlPrefix: (prefix: string) => void;
|
|
10
|
+
getManagerUrl: (route?: string | null) => string;
|
|
11
|
+
getBotUrl: (route?: string | null) => string;
|
|
12
|
+
getBotIconUrl: (tenantId?: string, botId?: string, updatedTime?: string) => string | undefined;
|
|
13
|
+
getSceneIconUrl: (tenantId?: string, sceneId?: string, updatedTime?: string) => string | undefined;
|
|
14
|
+
docChain: {
|
|
15
|
+
referenceDocUrl: ({ tenantId, docId, token, }: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
}) => string;
|
|
18
|
+
referenceDocChunkUrl: ({ tenantId, docId, chunkId, token, score, rank, docType, }: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
}) => string;
|
|
21
|
+
downloadDocUrl: ({ tenantId, docId, token, isSecurity }: {
|
|
22
|
+
[key: string]: string | boolean;
|
|
23
|
+
}) => string;
|
|
24
|
+
imageUrl: ({ tenantId, docId, token, path, isSecurity }: {
|
|
25
|
+
[key: string]: string | boolean;
|
|
26
|
+
}) => string;
|
|
27
|
+
};
|
|
28
|
+
tenantKnowledge: {
|
|
29
|
+
referenceDocUrl: ({ tenantId, docId, token, knowledgeType, docName, }: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
}) => string;
|
|
32
|
+
downloadDocUrl: ({ knowledgeType, docId }: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
}) => string;
|
|
35
|
+
};
|
|
36
|
+
get: (url: string, cfg: any) => Promise<unknown>;
|
|
37
|
+
post: (url: string, cfg: any) => Promise<unknown>;
|
|
38
|
+
};
|
|
39
|
+
export { request };
|
package/dist/cjs/http.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/http.ts
|
|
30
|
+
var http_exports = {};
|
|
31
|
+
__export(http_exports, {
|
|
32
|
+
getAccessUrl: () => getAccessUrl,
|
|
33
|
+
request: () => request,
|
|
34
|
+
tenantIdSessionKey: () => tenantIdSessionKey
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(http_exports);
|
|
37
|
+
var import_security = __toESM(require("@lingxiteam/security"));
|
|
38
|
+
var tenantIdSessionKey = "botSelectedTenantID";
|
|
39
|
+
var http = (url, config) => {
|
|
40
|
+
config.headers["content-type"] = "application/json;charset=UTF-8";
|
|
41
|
+
const token = sessionStorage.getItem("token");
|
|
42
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
43
|
+
return new Promise((resolve, rejects) => {
|
|
44
|
+
fetch(url, config).then((response) => {
|
|
45
|
+
const contentType = response.headers.get("content-type");
|
|
46
|
+
if (contentType) {
|
|
47
|
+
if (/application\/octet-stream/.test(contentType) || /application\/zip/.test(contentType) || /application\/vnd\.ms-excel/.test(contentType)) {
|
|
48
|
+
return response.blob();
|
|
49
|
+
}
|
|
50
|
+
if (/application\/json/.test(contentType)) {
|
|
51
|
+
return response.json();
|
|
52
|
+
}
|
|
53
|
+
if (/text\/html/.test(contentType)) {
|
|
54
|
+
return response.text();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return response;
|
|
58
|
+
}).then((data) => {
|
|
59
|
+
if (Object.prototype.toString.call(data) === "[object Blob]") {
|
|
60
|
+
if (typeof data === "object" && Object.hasOwnProperty.call(data, "resultCode") && String(data.resultCode) !== "0") {
|
|
61
|
+
return Promise.reject(data);
|
|
62
|
+
}
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(data))
|
|
66
|
+
return data;
|
|
67
|
+
if (String(data == null ? void 0 : data.resultCode) === "0") {
|
|
68
|
+
resolve(data == null ? void 0 : data.resultObject);
|
|
69
|
+
}
|
|
70
|
+
return data;
|
|
71
|
+
}).catch((err) => {
|
|
72
|
+
rejects(err);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
var baseUrl = `${process.env.REACT_APP_REQ_PREFIX}/bote`;
|
|
77
|
+
var getUrl = (url, params = {}) => {
|
|
78
|
+
let paramsArr = "";
|
|
79
|
+
if (params && Object.keys(params).length > 0) {
|
|
80
|
+
paramsArr = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&");
|
|
81
|
+
}
|
|
82
|
+
return `${baseUrl}${url}${paramsArr ? `?${paramsArr}` : ""}`;
|
|
83
|
+
};
|
|
84
|
+
var getAccessUrl = (url) => {
|
|
85
|
+
if (!url) {
|
|
86
|
+
return new URL("", window.location.href).toString();
|
|
87
|
+
}
|
|
88
|
+
if (/^\d+$/.test(url)) {
|
|
89
|
+
return `http://${window.location.hostname}:${url}/`;
|
|
90
|
+
}
|
|
91
|
+
return new URL(url, window.location.href).toString();
|
|
92
|
+
};
|
|
93
|
+
var managerUrl = getAccessUrl(process.env.BOTE_MANAGER_URL);
|
|
94
|
+
var botUrl = getAccessUrl(process.env.BOTE_BOT_URL);
|
|
95
|
+
var getManagerUrl = (route) => route ? `${managerUrl}#${route}` : managerUrl;
|
|
96
|
+
var getBotUrl = (route) => route ? `${botUrl}#${route}` : botUrl;
|
|
97
|
+
var request = {
|
|
98
|
+
getBaseUrl: () => baseUrl,
|
|
99
|
+
setUrlPrefix: (prefix) => {
|
|
100
|
+
baseUrl = `${prefix}${baseUrl}`;
|
|
101
|
+
},
|
|
102
|
+
getManagerUrl,
|
|
103
|
+
getBotUrl,
|
|
104
|
+
// 获取智能应用图标地址
|
|
105
|
+
getBotIconUrl: (tenantId, botId, updatedTime) => {
|
|
106
|
+
if (tenantId && botId) {
|
|
107
|
+
let url = `${baseUrl}/manager/bot/botIcon?tenantId=${tenantId}&botId=${botId}`;
|
|
108
|
+
if (updatedTime) {
|
|
109
|
+
url += `&_=${updatedTime.replace(/\D/g, "")}`;
|
|
110
|
+
}
|
|
111
|
+
return url;
|
|
112
|
+
}
|
|
113
|
+
return void 0;
|
|
114
|
+
},
|
|
115
|
+
// 获取智能体图标地址
|
|
116
|
+
getSceneIconUrl: (tenantId, sceneId, updatedTime) => {
|
|
117
|
+
if (tenantId && sceneId) {
|
|
118
|
+
let url = `${baseUrl}/manager/scene/sceneIcon?tenantId=${tenantId}&sceneId=${sceneId}`;
|
|
119
|
+
if (updatedTime) {
|
|
120
|
+
url += `&_=${updatedTime.replace(/\D/g, "")}`;
|
|
121
|
+
}
|
|
122
|
+
return url;
|
|
123
|
+
}
|
|
124
|
+
return void 0;
|
|
125
|
+
},
|
|
126
|
+
// 构造 DocChain 相关地址的辅助方法
|
|
127
|
+
docChain: {
|
|
128
|
+
referenceDocUrl: ({
|
|
129
|
+
tenantId,
|
|
130
|
+
docId,
|
|
131
|
+
token
|
|
132
|
+
}) => {
|
|
133
|
+
let url = `${managerUrl}#/referencesDetail?tenantId=${tenantId}&docId=${docId}`;
|
|
134
|
+
if (token) {
|
|
135
|
+
url += `&token=${token}`;
|
|
136
|
+
}
|
|
137
|
+
return url;
|
|
138
|
+
},
|
|
139
|
+
referenceDocChunkUrl: ({
|
|
140
|
+
tenantId,
|
|
141
|
+
docId,
|
|
142
|
+
chunkId,
|
|
143
|
+
token,
|
|
144
|
+
score,
|
|
145
|
+
rank,
|
|
146
|
+
docType
|
|
147
|
+
}) => {
|
|
148
|
+
let url = `${managerUrl}#/documentChunk?tenantId=${tenantId}&docId=${docId}&chunkId=${chunkId}&score=${score}&rank=${rank}&docType=${docType}`;
|
|
149
|
+
if (token) {
|
|
150
|
+
url += `&token=${token}`;
|
|
151
|
+
}
|
|
152
|
+
return url;
|
|
153
|
+
},
|
|
154
|
+
// 下载文档接口地址
|
|
155
|
+
downloadDocUrl: ({ tenantId, docId, token, isSecurity = true }) => {
|
|
156
|
+
let url = `${baseUrl}/docchain/v1/doc/read?tenantId=${tenantId}&read_format=src&doc_id=${docId}`;
|
|
157
|
+
if (token) {
|
|
158
|
+
url += `&token=${token}`;
|
|
159
|
+
}
|
|
160
|
+
if (isSecurity) {
|
|
161
|
+
url = import_security.default.autoSecurityWithUrl(url);
|
|
162
|
+
}
|
|
163
|
+
return url;
|
|
164
|
+
},
|
|
165
|
+
// 图片地址
|
|
166
|
+
imageUrl: ({ tenantId, docId, token, path, isSecurity = true }) => {
|
|
167
|
+
let url = `${baseUrl}/docchain/v1/doc/read?tenantId=${tenantId}&read_format=path&doc_id=${docId}&path=${encodeURIComponent(
|
|
168
|
+
path
|
|
169
|
+
)}`;
|
|
170
|
+
if (token) {
|
|
171
|
+
url += `&token=${token}`;
|
|
172
|
+
}
|
|
173
|
+
if (isSecurity) {
|
|
174
|
+
url = import_security.default.autoSecurityWithUrl(url);
|
|
175
|
+
}
|
|
176
|
+
return url;
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
// 构造 tenantKnowledge 相关地址的辅助方法
|
|
180
|
+
tenantKnowledge: {
|
|
181
|
+
referenceDocUrl: ({
|
|
182
|
+
tenantId,
|
|
183
|
+
docId,
|
|
184
|
+
token,
|
|
185
|
+
knowledgeType,
|
|
186
|
+
docName
|
|
187
|
+
}) => {
|
|
188
|
+
let url = `${managerUrl}#/referencesDetail?tenantId=${tenantId}&docId=${docId}&knowledgeType=${knowledgeType}&casPortal=true&docName=${docName}`;
|
|
189
|
+
if (token) {
|
|
190
|
+
url += `&token=${token}`;
|
|
191
|
+
}
|
|
192
|
+
return url;
|
|
193
|
+
},
|
|
194
|
+
// 下载文档接口地址
|
|
195
|
+
downloadDocUrl: ({ knowledgeType, docId }) => {
|
|
196
|
+
const url = `${baseUrl}/knowledge/access/downloadKnowledgeDoc?knowledgeType=${knowledgeType}&docId=${docId}`;
|
|
197
|
+
return url;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
get: (url, cfg) => {
|
|
201
|
+
const { params, ...rest } = cfg || {};
|
|
202
|
+
const tenantId = sessionStorage.getItem(tenantIdSessionKey) || params.tenantId;
|
|
203
|
+
params.tenantId = tenantId;
|
|
204
|
+
const _url = getUrl(url, params);
|
|
205
|
+
return http(_url, {
|
|
206
|
+
method: "GET",
|
|
207
|
+
headers: {},
|
|
208
|
+
...rest
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
post: (url, cfg) => {
|
|
212
|
+
const { data, params, ...rest } = cfg || {};
|
|
213
|
+
const tenantId = sessionStorage.getItem(tenantIdSessionKey) || data.tenantId;
|
|
214
|
+
let _body;
|
|
215
|
+
if (data instanceof FormData) {
|
|
216
|
+
data.append("tenantId", tenantId);
|
|
217
|
+
_body = data;
|
|
218
|
+
} else {
|
|
219
|
+
_body = JSON.stringify(data || {});
|
|
220
|
+
}
|
|
221
|
+
const _url = getUrl(url, params);
|
|
222
|
+
return http(_url, {
|
|
223
|
+
body: _body,
|
|
224
|
+
method: "POST",
|
|
225
|
+
headers: {},
|
|
226
|
+
...rest
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
getAccessUrl,
|
|
233
|
+
request,
|
|
234
|
+
tenantIdSessionKey
|
|
235
|
+
});
|
|
236
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/http.ts"],
|
|
4
|
+
"sourcesContent": ["// import CookieUtil from './CookieUtils';\nimport security from '@lingxiteam/security';\n\nexport const tenantIdSessionKey: string = 'botSelectedTenantID';\n\nconst http = (url: string, config: any) => {\n // const token = localStorage.getItem('X-Auth-Token');\n // config.headers['X-Auth-Token'] = token;\n config.headers['content-type'] = 'application/json;charset=UTF-8';\n const token = sessionStorage.getItem('token') as string;\n config.headers.Authorization = `Bearer ${token}`;\n\n return new Promise((resolve, rejects) => {\n fetch(url, config)\n .then((response) => {\n const contentType: string | null = response.headers.get('content-type');\n if (contentType) {\n if (\n /application\\/octet-stream/.test(contentType) ||\n /application\\/zip/.test(contentType) ||\n /application\\/vnd\\.ms-excel/.test(contentType)\n ) {\n return response.blob();\n }\n if (/application\\/json/.test(contentType)) {\n return response.json();\n }\n if (/text\\/html/.test(contentType)) {\n return response.text();\n }\n }\n return response;\n })\n .then((data) => {\n if (Object.prototype.toString.call(data) === '[object Blob]') {\n if (\n typeof data === 'object' &&\n Object.hasOwnProperty.call(data, 'resultCode') &&\n String(data.resultCode) !== '0'\n ) {\n return Promise.reject(data);\n }\n return data;\n }\n if (Array.isArray(data)) return data;\n if (String(data?.resultCode) === '0') {\n resolve(data?.resultObject);\n }\n return data;\n })\n .catch((err) => {\n rejects(err);\n });\n });\n};\n\nlet baseUrl = `${process.env.REACT_APP_REQ_PREFIX}/bote`;\nconst getUrl = (url: string, params: any = {}) => {\n let paramsArr = '';\n if (params && Object.keys(params).length > 0) {\n paramsArr = Object.keys(params)\n .map((item) => `${item}=${params[item]}`)\n .join('&');\n }\n return `${baseUrl}${url}${paramsArr ? `?${paramsArr}` : ''}`;\n};\n\n/**\n * 构造管理平台或机器人工程的完整访问地址\n * @param url 环境变量中配置的地址\n */\nexport const getAccessUrl = (url: string | undefined) => {\n // 未配置,表示使用当前工程地址,去掉 hash 部分\n if (!url) {\n return new URL('', window.location.href).toString();\n }\n // 一串数字表示是端口号,与当前工程使用相同的 hostname 以兼容使用不同 IP (回环地址、内网 IP)访问的情况\n if (/^\\d+$/.test(url)) {\n return `http://${window.location.hostname}:${url}/`;\n }\n // 完整地址/相对路径/绝对路径,根据当前工程地址解析\n return new URL(url, window.location.href).toString();\n};\n\n// 管理平台访问地址\nconst managerUrl = getAccessUrl(process.env.BOTE_MANAGER_URL);\n// 机器人工程访问地址\nconst botUrl = getAccessUrl(process.env.BOTE_BOT_URL);\n\n/**\n * 获取管理平台地址\n *\n * @param route 路由(\"#\" 后面的部分),可选\n */\nconst getManagerUrl = (route?: string | null) => route ? `${managerUrl}#${route}` : managerUrl;\n\n/**\n * 获取机器人工程访问地址\n *\n * @param route 路由(\"#\" 后面的部分),可选\n */\nconst getBotUrl = (route?: string | null) => route ? `${botUrl}#${route}` : botUrl;\n\nconst request = {\n getBaseUrl: () => baseUrl,\n setUrlPrefix: (prefix: string) => {\n baseUrl = `${prefix}${baseUrl}`;\n },\n getManagerUrl,\n getBotUrl,\n // 获取智能应用图标地址\n getBotIconUrl: (tenantId?: string, botId?: string, updatedTime?: string) => {\n if (tenantId && botId) {\n let url = `${baseUrl}/manager/bot/botIcon?tenantId=${tenantId}&botId=${botId}`;\n // 管理平台构造图标链接时加上更新时间参数,可以确保修改图标后浏览器能立即请求新图标\n // 浏览器的缓存策略有些激进,不刷新页面不会重新请求图片(单页应用很少会刷新页面),即使后端返回了 Cache-Control: no-cache\n if (updatedTime) {\n url += `&_=${updatedTime.replace(/\\D/g, '')}`;\n }\n return url;\n }\n return undefined;\n },\n // 获取智能体图标地址\n getSceneIconUrl: (tenantId?: string, sceneId?: string, updatedTime?: string) => {\n if (tenantId && sceneId) {\n let url = `${baseUrl}/manager/scene/sceneIcon?tenantId=${tenantId}&sceneId=${sceneId}`;\n if (updatedTime) {\n url += `&_=${updatedTime.replace(/\\D/g, '')}`;\n }\n return url;\n }\n return undefined;\n },\n // 构造 DocChain 相关地址的辅助方法\n docChain: {\n referenceDocUrl: ({\n tenantId,\n docId,\n token,\n }: {\n [key: string]: string;\n }) => {\n let url = `${managerUrl}#/referencesDetail?tenantId=${tenantId}&docId=${docId}`;\n if (token) {\n url += `&token=${token}`;\n }\n return url;\n },\n referenceDocChunkUrl: ({\n tenantId,\n docId,\n chunkId,\n token,\n score,\n rank,\n docType,\n }: {\n [key: string]: string;\n }) => {\n let url = `${managerUrl}#/documentChunk?tenantId=${tenantId}&docId=${docId}&chunkId=${chunkId}&score=${score}&rank=${rank}&docType=${docType}`;\n if (token) {\n url += `&token=${token}`;\n }\n return url;\n },\n // 下载文档接口地址\n downloadDocUrl: ({ tenantId, docId, token, isSecurity = true }: { [key: string]: string | boolean }) => {\n let url = `${baseUrl}/docchain/v1/doc/read?tenantId=${tenantId}&read_format=src&doc_id=${docId}`;\n if (token) {\n url += `&token=${token}`;\n }\n if (isSecurity) {\n url = security.autoSecurityWithUrl(url);\n }\n return url;\n },\n // 图片地址\n imageUrl: ({ tenantId, docId, token, path, isSecurity = true }: { [key: string]: string | boolean }) => {\n let url = `${baseUrl}/docchain/v1/doc/read?tenantId=${tenantId}&read_format=path&doc_id=${docId}&path=${encodeURIComponent(\n path,\n )}`;\n if (token) {\n url += `&token=${token}`;\n }\n if (isSecurity) {\n url = security.autoSecurityWithUrl(url);\n }\n return url;\n },\n },\n // 构造 tenantKnowledge 相关地址的辅助方法\n tenantKnowledge: {\n referenceDocUrl: ({\n tenantId,\n docId,\n token,\n knowledgeType,\n docName,\n }: {\n [key: string]: string;\n }) => {\n let url = `${managerUrl}#/referencesDetail?tenantId=${tenantId}&docId=${docId}&knowledgeType=${knowledgeType}&casPortal=true&docName=${docName}`;\n if (token) {\n url += `&token=${token}`;\n }\n return url;\n },\n // 下载文档接口地址\n downloadDocUrl: ({ knowledgeType, docId }: { [key: string]: string }) => {\n const url = `${baseUrl}/knowledge/access/downloadKnowledgeDoc?knowledgeType=${knowledgeType}&docId=${docId}`;\n\n return url;\n },\n },\n get: (url: string, cfg: any) => {\n const { params, ...rest }: any = cfg || {};\n // 拼租户ID 到参数中\n const tenantId = sessionStorage.getItem(tenantIdSessionKey) as string || params.tenantId;\n params.tenantId = tenantId;\n\n const _url = getUrl(url, params);\n return http(_url, {\n method: 'GET',\n headers: {},\n ...rest,\n });\n },\n post: (url: string, cfg: any) => {\n const { data, params, ...rest }: any = cfg || {};\n // 拼租户ID 到参数中\n const tenantId = (sessionStorage.getItem(tenantIdSessionKey) as string) || data.tenantId;\n let _body;\n if (data instanceof FormData) {\n data.append('tenantId', tenantId);\n _body = data;\n } else {\n _body = JSON.stringify(data || {});\n }\n\n const _url = getUrl(url, params);\n return http(_url, {\n body: _body,\n method: 'POST',\n headers: {},\n ...rest,\n });\n },\n};\n\nexport { request };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AAEd,IAAM,qBAA6B;AAE1C,IAAM,OAAO,CAAC,KAAa,WAAgB;AAGzC,SAAO,QAAQ,cAAc,IAAI;AACjC,QAAM,QAAQ,eAAe,QAAQ,OAAO;AAC5C,SAAO,QAAQ,gBAAgB,UAAU;AAEzC,SAAO,IAAI,QAAQ,CAAC,SAAS,YAAY;AACvC,UAAM,KAAK,MAAM,EACd,KAAK,CAAC,aAAa;AAClB,YAAM,cAA6B,SAAS,QAAQ,IAAI,cAAc;AACtE,UAAI,aAAa;AACf,YACE,4BAA4B,KAAK,WAAW,KAC5C,mBAAmB,KAAK,WAAW,KACnC,6BAA6B,KAAK,WAAW,GAC7C;AACA,iBAAO,SAAS,KAAK;AAAA,QACvB;AACA,YAAI,oBAAoB,KAAK,WAAW,GAAG;AACzC,iBAAO,SAAS,KAAK;AAAA,QACvB;AACA,YAAI,aAAa,KAAK,WAAW,GAAG;AAClC,iBAAO,SAAS,KAAK;AAAA,QACvB;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAC,EACA,KAAK,CAAC,SAAS;AACd,UAAI,OAAO,UAAU,SAAS,KAAK,IAAI,MAAM,iBAAiB;AAC5D,YACE,OAAO,SAAS,YAChB,OAAO,eAAe,KAAK,MAAM,YAAY,KAC7C,OAAO,KAAK,UAAU,MAAM,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AO;AACL,cAAQ,KAAK,UAAU,QAAQ,CAAC,CAAC;AAAA,IACnC;AAEA,UAAM,OAAO,OAAO,KAAK,MAAM;AAC/B,WAAO,KAAK,MAAM;AAAA,MAChB,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS,CAAC;AAAA,MACV,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": ["security"]
|
|
7
|
+
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ import loopPageStaticCodeMap from './loopPageStaticCodeMap';
|
|
|
10
10
|
import scriptExecution, { type scriptExecutionType } from './scriptExecution';
|
|
11
11
|
import { getFileUrlById, getRemoteComponentUrlByCode, getRemoteComponentUrlById } from './file';
|
|
12
12
|
import { isValidUrl, sanitizeRedirectUrl, safeRedirect, sanitizeEventHandler } from './securityUtils';
|
|
13
|
+
import { request, tenantIdSessionKey } from './http';
|
|
13
14
|
export type { fileToBase64Type, asyncLocalStorageType, asyncSessionStorageType, scriptExecutionType, };
|
|
14
|
-
export { fileToBase64, CookieUtils, argsToString, argsToObject, getSearchObj, asyncLocalStorage, asyncSessionStorage, camelToSnake, underscoreToCamelCase, generateRandom18Int, formatModuleData, patternTransitionRegExp, stringPramarsValTransition, loopPageStaticCodeMap, getDataArr, replaceParamsValue, replaceParamsValueForEvent, getParamsContentByParamKeys, getFileUrlById, getRemoteComponentUrlByCode, getRemoteComponentUrlById, stringScriptExecution, scriptExecution, isValidUrl, sanitizeRedirectUrl, safeRedirect, sanitizeEventHandler, };
|
|
15
|
+
export { fileToBase64, CookieUtils, argsToString, argsToObject, getSearchObj, asyncLocalStorage, asyncSessionStorage, camelToSnake, underscoreToCamelCase, generateRandom18Int, formatModuleData, patternTransitionRegExp, stringPramarsValTransition, loopPageStaticCodeMap, getDataArr, replaceParamsValue, replaceParamsValueForEvent, getParamsContentByParamKeys, getFileUrlById, getRemoteComponentUrlByCode, getRemoteComponentUrlById, stringScriptExecution, scriptExecution, isValidUrl, sanitizeRedirectUrl, safeRedirect, sanitizeEventHandler, request, tenantIdSessionKey, };
|
package/dist/cjs/index.js
CHANGED
|
@@ -49,12 +49,14 @@ __export(src_exports, {
|
|
|
49
49
|
patternTransitionRegExp: () => import_helpers.patternTransitionRegExp,
|
|
50
50
|
replaceParamsValue: () => import_treeUtils.replaceParamsValue,
|
|
51
51
|
replaceParamsValueForEvent: () => import_treeUtils.replaceParamsValueForEvent,
|
|
52
|
+
request: () => import_http.request,
|
|
52
53
|
safeRedirect: () => import_securityUtils.safeRedirect,
|
|
53
54
|
sanitizeEventHandler: () => import_securityUtils.sanitizeEventHandler,
|
|
54
55
|
sanitizeRedirectUrl: () => import_securityUtils.sanitizeRedirectUrl,
|
|
55
56
|
scriptExecution: () => import_scriptExecution.default,
|
|
56
57
|
stringPramarsValTransition: () => import_helpers.stringPramarsValTransition,
|
|
57
58
|
stringScriptExecution: () => import_helpers.stringScriptExecution,
|
|
59
|
+
tenantIdSessionKey: () => import_http.tenantIdSessionKey,
|
|
58
60
|
underscoreToCamelCase: () => import_stringUtils.underscoreToCamelCase
|
|
59
61
|
});
|
|
60
62
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -70,6 +72,7 @@ var import_loopPageStaticCodeMap = __toESM(require("./loopPageStaticCodeMap"));
|
|
|
70
72
|
var import_scriptExecution = __toESM(require("./scriptExecution"));
|
|
71
73
|
var import_file = require("./file");
|
|
72
74
|
var import_securityUtils = require("./securityUtils");
|
|
75
|
+
var import_http = require("./http");
|
|
73
76
|
var _ = require("lodash");
|
|
74
77
|
_.noConflict();
|
|
75
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -94,12 +97,14 @@ _.noConflict();
|
|
|
94
97
|
patternTransitionRegExp,
|
|
95
98
|
replaceParamsValue,
|
|
96
99
|
replaceParamsValueForEvent,
|
|
100
|
+
request,
|
|
97
101
|
safeRedirect,
|
|
98
102
|
sanitizeEventHandler,
|
|
99
103
|
sanitizeRedirectUrl,
|
|
100
104
|
scriptExecution,
|
|
101
105
|
stringPramarsValTransition,
|
|
102
106
|
stringScriptExecution,
|
|
107
|
+
tenantIdSessionKey,
|
|
103
108
|
underscoreToCamelCase
|
|
104
109
|
});
|
|
105
110
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import fileToBase64, { type fileToBase64Type } from './fileToBase64';\nimport CookieUtils from './CookieUtils';\nimport { argsToString, argsToObject, getSearchObj } from './pathArgsUtils';\nimport {\n asyncLocalStorage,\n asyncSessionStorage,\n type asyncLocalStorageType,\n type asyncSessionStorageType,\n} from './asyncStorage';\nimport {\n camelToSnake,\n underscoreToCamelCase,\n generateRandom18Int,\n} from './stringUtils';\nimport {\n getDataArr,\n replaceParamsValue,\n getParamsContentByParamKeys,\n replaceParamsValueForEvent,\n} from './treeUtils';\nimport formatModuleData from './formatModule/formatModuleData';\nimport {\n patternTransitionRegExp,\n stringPramarsValTransition,\n stringScriptExecution,\n} from './formatModule/helpers';\nimport loopPageStaticCodeMap from './loopPageStaticCodeMap';\nimport scriptExecution, { type scriptExecutionType } from './scriptExecution';\nimport {\n getFileUrlById,\n getRemoteComponentUrlByCode,\n getRemoteComponentUrlById,\n} from './file';\nimport {\n isValidUrl,\n sanitizeRedirectUrl,\n safeRedirect,\n sanitizeEventHandler,\n} from './securityUtils';\n\n// 避免 _对象 和其他库冲突\nconst _ = require('lodash');\n\n_.noConflict();\n\nexport type {\n fileToBase64Type,\n asyncLocalStorageType,\n asyncSessionStorageType,\n scriptExecutionType,\n};\n\nexport {\n fileToBase64,\n CookieUtils,\n argsToString,\n argsToObject,\n getSearchObj,\n asyncLocalStorage,\n asyncSessionStorage,\n camelToSnake,\n underscoreToCamelCase,\n generateRandom18Int,\n formatModuleData,\n patternTransitionRegExp,\n stringPramarsValTransition,\n loopPageStaticCodeMap,\n getDataArr,\n replaceParamsValue,\n replaceParamsValueForEvent,\n getParamsContentByParamKeys,\n getFileUrlById,\n getRemoteComponentUrlByCode,\n getRemoteComponentUrlById,\n stringScriptExecution,\n scriptExecution,\n isValidUrl,\n sanitizeRedirectUrl,\n safeRedirect,\n sanitizeEventHandler,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wCAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0CAAAC;AAAA,EAAA,gDAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4DAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoD;AACpD,yBAAwB;AACxB,2BAAyD;AACzD,0BAKO;AACP,yBAIO;AACP,uBAKO;AACP,8BAA6B;AAC7B,qBAIO;AACP,mCAAkC;AAClC,6BAA0D;AAC1D,kBAIO;AACP,2BAKO;
|
|
4
|
+
"sourcesContent": ["import fileToBase64, { type fileToBase64Type } from './fileToBase64';\nimport CookieUtils from './CookieUtils';\nimport { argsToString, argsToObject, getSearchObj } from './pathArgsUtils';\nimport {\n asyncLocalStorage,\n asyncSessionStorage,\n type asyncLocalStorageType,\n type asyncSessionStorageType,\n} from './asyncStorage';\nimport {\n camelToSnake,\n underscoreToCamelCase,\n generateRandom18Int,\n} from './stringUtils';\nimport {\n getDataArr,\n replaceParamsValue,\n getParamsContentByParamKeys,\n replaceParamsValueForEvent,\n} from './treeUtils';\nimport formatModuleData from './formatModule/formatModuleData';\nimport {\n patternTransitionRegExp,\n stringPramarsValTransition,\n stringScriptExecution,\n} from './formatModule/helpers';\nimport loopPageStaticCodeMap from './loopPageStaticCodeMap';\nimport scriptExecution, { type scriptExecutionType } from './scriptExecution';\nimport {\n getFileUrlById,\n getRemoteComponentUrlByCode,\n getRemoteComponentUrlById,\n} from './file';\nimport {\n isValidUrl,\n sanitizeRedirectUrl,\n safeRedirect,\n sanitizeEventHandler,\n} from './securityUtils';\n\nimport { request, tenantIdSessionKey } from './http';\n\n// 避免 _对象 和其他库冲突\nconst _ = require('lodash');\n\n_.noConflict();\n\nexport type {\n fileToBase64Type,\n asyncLocalStorageType,\n asyncSessionStorageType,\n scriptExecutionType,\n};\n\nexport {\n fileToBase64,\n CookieUtils,\n argsToString,\n argsToObject,\n getSearchObj,\n asyncLocalStorage,\n asyncSessionStorage,\n camelToSnake,\n underscoreToCamelCase,\n generateRandom18Int,\n formatModuleData,\n patternTransitionRegExp,\n stringPramarsValTransition,\n loopPageStaticCodeMap,\n getDataArr,\n replaceParamsValue,\n replaceParamsValueForEvent,\n getParamsContentByParamKeys,\n getFileUrlById,\n getRemoteComponentUrlByCode,\n getRemoteComponentUrlById,\n stringScriptExecution,\n scriptExecution,\n isValidUrl,\n sanitizeRedirectUrl,\n safeRedirect,\n sanitizeEventHandler,\n request,\n tenantIdSessionKey,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wCAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0CAAAC;AAAA,EAAA,gDAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4DAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoD;AACpD,yBAAwB;AACxB,2BAAyD;AACzD,0BAKO;AACP,yBAIO;AACP,uBAKO;AACP,8BAA6B;AAC7B,qBAIO;AACP,mCAAkC;AAClC,6BAA0D;AAC1D,kBAIO;AACP,2BAKO;AAEP,kBAA4C;AAG5C,IAAM,IAAI,QAAQ,QAAQ;AAE1B,EAAE,WAAW;",
|
|
6
6
|
"names": ["CookieUtils", "fileToBase64", "formatModuleData", "loopPageStaticCodeMap", "scriptExecution"]
|
|
7
7
|
}
|
|
@@ -68,6 +68,22 @@ var formatModuleData = function formatModuleData(_ref) {
|
|
|
68
68
|
moduleDataRes.compProps.title = stringPramarsValTransition(otherCompProps === null || otherCompProps === void 0 ? void 0 : otherCompProps.title, allParametrs);
|
|
69
69
|
}
|
|
70
70
|
moduleDataRes.parentCompProps = (parentModuleData === null || parentModuleData === void 0 ? void 0 : parentModuleData.compProps) || {};
|
|
71
|
+
// 处理page组件的onLoad事件
|
|
72
|
+
if (compType === 'page') {
|
|
73
|
+
if (events && (events === null || events === void 0 ? void 0 : events.length) > 0) {
|
|
74
|
+
var onLoadEvent = events.find(function (item) {
|
|
75
|
+
return (item === null || item === void 0 ? void 0 : item.key) === 'pageLoad';
|
|
76
|
+
});
|
|
77
|
+
if (onLoadEvent) {
|
|
78
|
+
moduleDataRes.compProps.onLoad = onLoadEvent === null || onLoadEvent === void 0 ? void 0 : onLoadEvent.event;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (eventFlag) {
|
|
82
|
+
moduleDataRes.compProps.eventFlag = {
|
|
83
|
+
checked: true
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
71
87
|
if (['panel', 'div', 'page'].indexOf(compType) >= 0 && Array.isArray(children) && children.length > 0) {
|
|
72
88
|
var childs = children.map(function (item) {
|
|
73
89
|
return formatModuleData({
|
|
@@ -81,21 +97,6 @@ var formatModuleData = function formatModuleData(_ref) {
|
|
|
81
97
|
});
|
|
82
98
|
});
|
|
83
99
|
moduleDataRes.children = childs;
|
|
84
|
-
if (compType === 'page') {
|
|
85
|
-
if (events && (events === null || events === void 0 ? void 0 : events.length) > 0) {
|
|
86
|
-
var onLoadEvent = events.find(function (item) {
|
|
87
|
-
return (item === null || item === void 0 ? void 0 : item.key) === 'pageLoad';
|
|
88
|
-
});
|
|
89
|
-
if (onLoadEvent) {
|
|
90
|
-
moduleDataRes.compProps.onLoad = onLoadEvent === null || onLoadEvent === void 0 ? void 0 : onLoadEvent.event;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (eventFlag) {
|
|
94
|
-
moduleDataRes.compProps.eventFlag = {
|
|
95
|
-
checked: true
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
100
|
} else {
|
|
100
101
|
var _Object$keys;
|
|
101
102
|
if (otherCompProps && (Object === null || Object === void 0 || (_Object$keys = Object.keys(otherCompProps)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) > 0) {
|