@nocobase/plugin-action-import 1.5.0-beta.2 → 1.5.0-beta.3
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/client/index.js +6 -6
- package/dist/externalVersion.js +6 -6
- package/dist/node_modules/xlsx/package.json +1 -1
- package/dist/server/actions/import-xlsx.js +2 -1
- package/dist/server/services/xlsx-importer.d.ts +2 -0
- package/dist/server/services/xlsx-importer.js +3 -1
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,27 +7,27 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(
|
|
10
|
+
(function(p,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("react/jsx-runtime"),require("@formily/shared"),require("@nocobase/client"),require("antd"),require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("react"),require("react-dom"),require("@ant-design/icons"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/shared","@nocobase/client","antd","react-i18next","@formily/antd-v5","@formily/react","react","react-dom","@ant-design/icons","lodash"],a):(p=typeof globalThis!="undefined"?globalThis:p||self,a(p["@nocobase/plugin-action-import"]={},p.jsxRuntime,p["@formily/shared"],p["@nocobase/client"],p.antd,p["react-i18next"],p["@formily/antd-v5"],p["@formily/react"],p.react,p["react-dom"],p["@ant-design/icons"],p.lodash))})(this,function(p,a,y,s,E,F,N,M,g,j,$,V){"use strict";var we=Object.defineProperty,Te=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var xe=(p,a,y)=>a in p?we(p,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[a]=y,O=(p,a)=>{for(var y in a||(a={}))Ee.call(a,y)&&xe(p,y,a[y]);if(ue)for(var y of ue(a))Me.call(a,y)&&xe(p,y,a[y]);return p},he=(p,a)=>Te(p,Ce(a));var R=(p,a,y)=>new Promise((s,E)=>{var F=g=>{try{M(y.next(g))}catch(j){E(j)}},N=g=>{try{M(y.throw(g))}catch(j){E(j)}},M=g=>g.done?s(g.value):Promise.resolve(g.value).then(F,N);M((y=y.apply(p,a)).next())});const T="action-import",fe="action-import";function X(){return F.useTranslation([fe,"client"],{nsMode:"fallback"})}const ge=["id","createdAt","createdBy","updatedAt","updatedBy"],G=t=>{const{getCollectionFields:e}=s.useCollectionManager_deprecated(),l=e(t),c=(i,r)=>{var f;if(!i.interface||ge.includes(i.interface))return;const u={name:i.name,title:((f=i==null?void 0:i.uiSchema)==null?void 0:f.title)||i.name,schema:i==null?void 0:i.uiSchema};if(!i.target||r>=2)return u;if(i.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(i.type)){const o=e(i.target),n=x(o,r+1).filter(Boolean);u.children=u.children||[],u.children.push(...n)}return u},x=(i,r)=>{const u=[];return i.forEach(f=>{const o=c(f,r);o&&u.push(o)}),u};return x(l,1)},ye=t=>({importColumns:t==null?void 0:t.filter(l=>!l.children).map(l=>({dataIndex:[l.name]})),explain:""}),W=()=>{const{t}=X();return a.jsx(E.Alert,{type:"warning",style:{marginBottom:"10px"},message:t("Import warnings",{limit:2e3})})},J=()=>{const{t}=X();return a.jsx(E.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:t("Download tips")})},K=()=>{const t=s.useSchemaInitializerItem(),{insert:e}=s.useSchemaInitializer(),{name:l}=s.useCollection_deprecated(),c=G(l),x={type:"void",title:'{{ t("Import") }}',"x-action":"importXlsx","x-action-settings":{importSettings:{importColumns:[],explain:""}},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:import","x-component":"Action","x-component-props":{icon:"CloudUploadOutlined",openMode:"modal"},properties:{modal:{type:"void",title:`{{ t("Import Data", {ns: "${T}" }) }}`,"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:s.css`
|
|
11
11
|
.ant-formily-item-label {
|
|
12
12
|
height: var(--controlHeightLG);
|
|
13
13
|
}
|
|
14
|
-
`},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:`{{ t("Step 1: Download template", {ns: "${
|
|
14
|
+
`},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:`{{ t("Step 1: Download template", {ns: "${T}" }) }}`,"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:`{{ t("Download template", {ns: "${T}" }) }}`,"x-component":"Action","x-component-props":{className:s.css`
|
|
15
15
|
margin-top: 5px;
|
|
16
|
-
`,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${
|
|
16
|
+
`,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${T}" }) }}`,"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:`{{ t("Upload placeholder", {ns: "${T}" }) }}`,beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:`{{ t("Start import", {ns: "${T}" }) }}`,"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}}}};return a.jsx(s.SchemaInitializerItem,{title:t.title,onClick:()=>{var r;x["x-action-settings"].importSettings=ye(c);const i=y.merge(x||{},t.schema||{});(r=t==null?void 0:t.schemaInitialize)==null||r.call(t,i),e(i)}})},Ie=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],z=()=>{const{t}=F.useTranslation(T),{name:e}=s.useCollection_deprecated(),l=G(e);return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:`{{ t("Import explain", {ns: "${T}"}) }}`,"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:s.css`
|
|
17
17
|
width: 100%;
|
|
18
18
|
& .ant-space-item:nth-child(2) {
|
|
19
19
|
flex: 1;
|
|
20
20
|
}
|
|
21
|
-
`},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":
|
|
21
|
+
`},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":s.Cascader,required:!0,enum:l,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{ t("Add importable field", {ns: "${T}"}) }}`,"x-component":"ArrayItems.Addition","x-component-props":{className:s.css`
|
|
22
22
|
border-color: var(--colorSettings);
|
|
23
23
|
color: var(--colorSettings);
|
|
24
24
|
&.ant-btn-dashed:hover {
|
|
25
25
|
border-color: var(--colorSettings);
|
|
26
26
|
color: var(--colorSettings);
|
|
27
27
|
}
|
|
28
|
-
`}}}}}},beforeUploadHandler(){return!1},uploadValidator(
|
|
28
|
+
`}}}}}},beforeUploadHandler(){return!1},uploadValidator(c,x){var r;if(c.length>1)return{type:"error",message:t("Only one file is allowed to be uploaded")};const i=(r=c[0])!=null?r:{};return i.size>10*1024*1024?{type:"error",message:t("File size cannot exceed 10M")}:Ie.includes(i.type)?"":{type:"error",message:t("Please upload the file of Excel")}},validateUpload(c,x,i){var u;const[r]=i;x.disabled=(r==null?void 0:r.length)===0,x.componentProps=he(O({},x.componentProps),{disabled:(r==null?void 0:r.length)===0||((u=c.errors)==null?void 0:u.length)>0})}}},Y=()=>{var u,f,o,n,h,m;const t=M.useField(),e=M.useFieldSchema(),{t:l}=F.useTranslation(),{dn:c}=s.useDesignable(),[x,i]=g.useState(),{importSettingsSchema:r}=z();return g.useEffect(()=>{i(r)},[t.address,(u=e==null?void 0:e["x-action-settings"])==null?void 0:u.importSettings]),a.jsxs(s.GeneralSchemaDesigner,{disableInitializer:!0,children:[a.jsx(s.SchemaSettingsModalItem,{title:l("Edit button"),schema:{type:"object",title:l("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:l("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:l("Button icon"),default:(f=e==null?void 0:e["x-component-props"])==null?void 0:f.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:l("Button background color"),default:(o=e==null?void 0:e["x-component-props"])!=null&&o.danger?"danger":((n=e==null?void 0:e["x-component-props"])==null?void 0:n.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:({title:d,icon:I,type:A})=>{e.title=d,t.title=d,t.componentProps.icon=I,t.componentProps.danger=A==="danger",t.componentProps.type=A,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=I,e["x-component-props"].danger=A==="danger",e["x-component-props"].type=A,c.emit("patch",{schema:{"x-uid":e["x-uid"],title:d,"x-component-props":O({},e["x-component-props"])}}),c.refresh()}}),a.jsx(s.SchemaSettingsActionModalItem,{title:l("Importable fields"),schema:x,initialValues:O({},(m=(h=e==null?void 0:e["x-action-settings"])==null?void 0:h.importSettings)!=null?m:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:d,explain:I})=>{const A=d==null?void 0:d.filter(v=>{var b;return(b=v==null?void 0:v.dataIndex)==null?void 0:b.length}).map(v=>({dataIndex:v.dataIndex.map(b=>{var S;return(S=b.name)!=null?S:b}),title:v.title}));e["x-action-settings"].importSettings={importColumns:A,explain:I},c.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),c.refresh()}}),a.jsx(s.SchemaSettingsDivider,{}),a.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:d=>d["x-component"]==="Space"||d["x-component"].endsWith("ActionBar"),confirm:{title:l("Delete action")}})]})},H=g.createContext(null);H.displayName="ImportContext";const Q=()=>g.useContext(H);var k=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Z={exports:{}};(function(t,e){(function(l,c){c()})(k,function(){function l(o,n){return typeof n=="undefined"?n={autoBom:!1}:typeof n!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),n={autoBom:!n}),n.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o}function c(o,n,h){var m=new XMLHttpRequest;m.open("GET",o),m.responseType="blob",m.onload=function(){f(m.response,n,h)},m.onerror=function(){console.error("could not download file")},m.send()}function x(o){var n=new XMLHttpRequest;n.open("HEAD",o,!1);try{n.send()}catch(h){}return 200<=n.status&&299>=n.status}function i(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(h){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(n)}}var r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof k=="object"&&k.global===k?k:void 0,u=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),f=r.saveAs||(typeof window!="object"||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!u?function(o,n,h){var m=r.URL||r.webkitURL,d=document.createElement("a");n=n||o.name||"download",d.download=n,d.rel="noopener",typeof o=="string"?(d.href=o,d.origin===location.origin?i(d):x(d.href)?c(o,n,h):i(d,d.target="_blank")):(d.href=m.createObjectURL(o),setTimeout(function(){m.revokeObjectURL(d.href)},4e4),setTimeout(function(){i(d)},0))}:"msSaveOrOpenBlob"in navigator?function(o,n,h){if(n=n||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(l(o,h),n);else if(x(o))c(o,n,h);else{var m=document.createElement("a");m.href=o,m.target="_blank",setTimeout(function(){i(m)})}}:function(o,n,h,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof o=="string")return c(o,n,h);var d=o.type==="application/octet-stream",I=/constructor/i.test(r.HTMLElement)||r.safari,A=/CriOS\/[\d]+/.test(navigator.userAgent);if((A||d&&I||u)&&typeof FileReader!="undefined"){var v=new FileReader;v.onloadend=function(){var C=v.result;C=A?C:C.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=C:location=C,m=null},v.readAsDataURL(o)}else{var b=r.URL||r.webkitURL,S=b.createObjectURL(o);m?m.location=S:location.href=S,m=null,setTimeout(function(){b.revokeObjectURL(S)},4e4)}});r.saveAs=f.saveAs=f,t.exports=f})})(Z);var ee=Z.exports;const D={IMPORTING:1,IMPORTED:2},ve=t=>{const{t:e}=F.useTranslation(T),{importModalVisible:l,importStatus:c,importResult:x,setImportModalVisible:i}=Q(),{data:r,meta:u}=x!=null?x:{},f=()=>{i(!1)},o=()=>{const n=new Int8Array(r==null?void 0:r.data),h=new Blob([n],{type:"application/x-xls"});ee.saveAs(h,"fail.xlsx")};return a.jsx(E.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:l,footer:null,closable:c===D.IMPORTED,onCancel:f,children:a.jsxs("div",{className:s.css`
|
|
29
29
|
display: flex;
|
|
30
30
|
justify-content: center;
|
|
31
31
|
align-items: center;
|
|
32
32
|
height: 100%;
|
|
33
|
-
`,children:[
|
|
33
|
+
`,children:[c===D.IMPORTING&&a.jsx(E.Spin,{indicator:a.jsx($.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),c===D.IMPORTED&&a.jsxs(E.Space,{direction:"vertical",align:"center",children:[a.jsx($.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),a.jsx("p",{children:e("{{successCount}} records have been successfully imported",O({},u!=null?u:{}))}),a.jsxs(E.Space,{children:[(u==null?void 0:u.failureCount)>0&&a.jsx(E.Button,{onClick:o,children:e("To download the failure data")}),a.jsx(E.Button,{type:"primary",onClick:f,children:e("Done")})]})]})]})})},te=t=>{let e=t;for(;e&&e["x-action"]!=="importXlsx";)e=e.parent;return{schema:e}},oe=t=>!t||!Array.isArray(t)?[]:t,ne=()=>{const{service:t,resource:e}=s.useBlockRequestContext();s.useAPIClient();const l=M.useFieldSchema(),c=s.useCompile(),{getCollectionJoinField:x,getCollectionField:i}=s.useCollectionManager_deprecated(),{name:r,title:u,getField:f}=s.useCollection_deprecated();F.useTranslation(T);const{schema:o}=te(l);return{run(){return R(this,null,function*(){var v,b;const{importColumns:h,explain:m}=V.cloneDeep((b=(v=o==null?void 0:o["x-action-settings"])==null?void 0:v.importSettings)!=null?b:{}),d=oe(h).map(S=>{var U,_;const C=i(`${r}.${S.dataIndex[0]}`);if(C){if(S.defaultTitle=c((U=C==null?void 0:C.uiSchema)==null?void 0:U.title)||C.name,S.dataIndex.length>1){const P=x(`${r}.${S.dataIndex.join(".")}`);if(!P)return;S.defaultTitle=S.defaultTitle+"/"+c((_=P==null?void 0:P.uiSchema)==null?void 0:_.title)||P.name}return C.interface==="chinaRegion"&&S.dataIndex.push("name"),S}}).filter(Boolean),{data:I}=yield e.downloadXlsxTemplate({values:{title:c(u),explain:m,columns:c(d)}},{method:"post",responseType:"blob"}),A=new Blob([I],{type:"application/x-xls"});ee.saveAs(A,`${c(u)}.xlsx`)})}}},re=()=>{var U;const{service:t,resource:e}=s.useBlockRequestContext();s.useAPIClient();const l=M.useFieldSchema(),c=s.useCompile(),{getCollectionJoinField:x,getCollectionField:i}=s.useCollectionManager_deprecated(),{name:r,title:u,getField:f}=s.useCollection_deprecated();F.useTranslation(T);const{schema:o}=te(l),n=M.useForm(),{setVisible:h,fieldSchema:m}=s.useActionContext(),{setImportModalVisible:d,setImportStatus:I,setImportResult:A}=Q(),{upload:v}=n.values,b=s.useDataBlockProps()||{};s.useDataSourceHeaders(b.dataSource);const S=s.useDataBlockResource();return g.useEffect(()=>{n.reset()},[]),{run(){return R(this,null,function*(){var ce,pe,le;const{importColumns:_,explain:P}=V.cloneDeep((pe=(ce=o==null?void 0:o["x-action-settings"])==null?void 0:ce.importSettings)!=null?pe:{}),Ae=oe(_).map(w=>{var de,me;const B=i(`${r}.${w.dataIndex[0]}`);if(B){if(w.defaultTitle=c((de=B==null?void 0:B.uiSchema)==null?void 0:de.title)||B.name,w.dataIndex.length>1){const L=x(`${r}.${w.dataIndex.join(".")}`);if(!L)return;w.defaultTitle=w.defaultTitle+"/"+c((me=L==null?void 0:L.uiSchema)==null?void 0:me.title)||L.name}return B.interface==="chinaRegion"&&w.dataIndex.push("name"),w}}).filter(Boolean),q=new FormData,be=n.values.upload.map(w=>w.originFileObj);q.append("file",be[0]),q.append("columns",JSON.stringify(Ae)),q.append("explain",P),h(!1),d(!0),I(D.IMPORTING);try{const{data:w}=yield S.importXlsx({values:q},{timeout:6e5});A(w),n.reset(),yield(le=t==null?void 0:t.refresh)==null?void 0:le.call(t),I(D.IMPORTED)}catch(w){d(!1),h(!0)}})},disabled:(v==null?void 0:v.length)===0||((U=n.errors)==null?void 0:U.length)>0}},ae=t=>{const{uploadValidator:e,beforeUploadHandler:l,validateUpload:c}=z();return a.jsx(s.SchemaComponentOptions,{components:{ImportActionInitializer:K,ImportDesigner:Y,ImportWarning:W,DownloadTips:J},scope:{uploadValidator:e,validateUpload:c,beforeUploadHandler:l,useDownloadXlsxTemplateAction:ne,useImportStartAction:re},children:a.jsx(se,{children:t.children})})},se=t=>{const[e,l]=g.useState(!1),[c,x]=g.useState(D.IMPORTING),[i,r]=g.useState(null);return a.jsxs(H.Provider,{value:{importModalVisible:e,setImportModalVisible:l,importStatus:c,setImportStatus:x,importResult:i,setImportResult:r},children:[j.createPortal(a.jsx(ve,{}),document.body),t.children]})},Se=new s.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=s.useSchemaToolbar();return t}},{name:"importableFields",type:"actionModal",useComponentProps(){var u,f,o;const t=M.useField(),e=M.useFieldSchema(),{t:l}=F.useTranslation(),{dn:c}=s.useDesignable(),[x,i]=g.useState(),{importSettingsSchema:r}=z();return g.useEffect(()=>{i(r)},[t.address,(u=e==null?void 0:e["x-action-settings"])==null?void 0:u.importSettings]),{title:l("Importable fields"),schema:x,initialValues:O({},(o=(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.importSettings)!=null?o:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:n,explain:h})=>{const m=n==null?void 0:n.filter(d=>{var I;return(I=d==null?void 0:d.dataIndex)==null?void 0:I.length}).map(d=>({dataIndex:d.dataIndex.map(I=>{var A;return(A=I.name)!=null?A:I}),title:d.title}));e["x-action-settings"].importSettings={importColumns:m,explain:h},c.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),c.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t}=F.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:t("Delete action")}}}}]});class ie extends s.Plugin{load(){return R(this,null,function*(){this.app.use(ae);const e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>s.useActionAvailable("import")},l=this.app.schemaInitializerManager.get("table:configureActions");l==null||l.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(Se)})}}p.DownloadTips=J,p.ImportActionInitializer=K,p.ImportContextProvider=se,p.ImportDesigner=Y,p.ImportPluginProvider=ae,p.ImportWarning=W,p.PluginActionImportClient=ie,p.default=ie,p.useDownloadXlsxTemplateAction=ne,p.useImportStartAction=re,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
12
|
"@formily/shared": "2.3.2",
|
|
13
|
-
"@nocobase/client": "1.5.0-beta.
|
|
13
|
+
"@nocobase/client": "1.5.0-beta.3",
|
|
14
14
|
"antd": "5.12.8",
|
|
15
15
|
"react": "18.2.0",
|
|
16
16
|
"@formily/antd-v5": "1.1.9",
|
|
@@ -19,12 +19,12 @@ module.exports = {
|
|
|
19
19
|
"react-dom": "18.2.0",
|
|
20
20
|
"lodash": "4.17.21",
|
|
21
21
|
"@formily/core": "2.3.0",
|
|
22
|
-
"@nocobase/server": "1.5.0-beta.
|
|
23
|
-
"@nocobase/actions": "1.5.0-beta.
|
|
24
|
-
"@nocobase/database": "1.5.0-beta.
|
|
22
|
+
"@nocobase/server": "1.5.0-beta.3",
|
|
23
|
+
"@nocobase/actions": "1.5.0-beta.3",
|
|
24
|
+
"@nocobase/database": "1.5.0-beta.3",
|
|
25
25
|
"async-mutex": "0.3.2",
|
|
26
|
-
"@nocobase/data-source-manager": "1.5.0-beta.
|
|
27
|
-
"@nocobase/utils": "1.5.0-beta.
|
|
26
|
+
"@nocobase/data-source-manager": "1.5.0-beta.3",
|
|
27
|
+
"@nocobase/utils": "1.5.0-beta.3",
|
|
28
28
|
"sequelize": "6.35.2",
|
|
29
29
|
"mathjs": "10.6.4"
|
|
30
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"xlsx","version":"0.20.2","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2024-12-
|
|
1
|
+
{"name":"xlsx","version":"0.20.2","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2024-12-10T07:14:31.544Z"}
|
|
@@ -22,6 +22,7 @@ type ImporterOptions = {
|
|
|
22
22
|
workbook: WorkBook;
|
|
23
23
|
chunkSize?: number;
|
|
24
24
|
explain?: string;
|
|
25
|
+
repository?: any;
|
|
25
26
|
};
|
|
26
27
|
type RunOptions = {
|
|
27
28
|
transaction?: Transaction;
|
|
@@ -29,6 +30,7 @@ type RunOptions = {
|
|
|
29
30
|
};
|
|
30
31
|
export declare class XlsxImporter extends EventEmitter {
|
|
31
32
|
private options;
|
|
33
|
+
private repository;
|
|
32
34
|
constructor(options: ImporterOptions);
|
|
33
35
|
run(options?: RunOptions): Promise<number>;
|
|
34
36
|
resetSeq(options?: RunOptions): Promise<void>;
|
|
@@ -49,7 +49,9 @@ class XlsxImporter extends import_events.default {
|
|
|
49
49
|
if (options.columns.length == 0) {
|
|
50
50
|
throw new Error(`columns is empty`);
|
|
51
51
|
}
|
|
52
|
+
this.repository = options.repository ? options.repository : options.collection.repository;
|
|
52
53
|
}
|
|
54
|
+
repository;
|
|
53
55
|
async run(options = {}) {
|
|
54
56
|
let transaction = options.transaction;
|
|
55
57
|
if (!transaction && this.options.collectionManager.db) {
|
|
@@ -148,7 +150,7 @@ class XlsxImporter extends import_events.default {
|
|
|
148
150
|
}
|
|
149
151
|
rowValues[dataKey] = await interfaceInstance.toValue(this.trimString(str), ctx);
|
|
150
152
|
}
|
|
151
|
-
await this.
|
|
153
|
+
await this.repository.create({
|
|
152
154
|
values: rowValues,
|
|
153
155
|
context: options == null ? void 0 : options.context,
|
|
154
156
|
transaction
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "操作:导入记录",
|
|
5
5
|
"description": "Import records using excel templates. You can configure which fields to import and templates will be generated automatically.",
|
|
6
6
|
"description.zh-CN": "使用 Excel 模板导入数据,可以配置导入哪些字段,自动生成模板。",
|
|
7
|
-
"version": "1.5.0-beta.
|
|
7
|
+
"version": "1.5.0-beta.3",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/action-import",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@nocobase/test": "1.x",
|
|
35
35
|
"@nocobase/utils": "1.x"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "81afcf4affdb652faf4636e6d9351828ce8906be",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"Actions"
|
|
40
40
|
]
|