@tachybase/module-backup 1.0.18 → 1.1.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.
- package/dist/client/AutoBackup.d.ts +1 -0
- package/dist/client/collections/autoBackup.d.ts +3 -0
- package/dist/client/components/RepeatField.d.ts +4 -0
- package/dist/client/components/locale/Cron.zh-CN.d.ts +34 -0
- package/dist/client/cron-jobs-table/AutoBackupTable.d.ts +1 -0
- package/dist/client/cron-jobs-table/AutoBackupTable.schema.d.ts +629 -0
- package/dist/client/index.js +30 -1
- package/dist/client/locale/index.d.ts +4 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +27 -0
- package/dist/externalVersion.js +7 -6
- package/dist/locale/zh-CN.json +29 -0
- package/dist/node_modules/@hapi/topo/package.json +1 -1
- package/dist/node_modules/archiver/package.json +1 -1
- package/dist/node_modules/cron-parser/LICENSE +21 -0
- package/dist/node_modules/cron-parser/lib/date.js +252 -0
- package/dist/node_modules/cron-parser/lib/expression.js +1002 -0
- package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
- package/dist/node_modules/cron-parser/lib/field_stringify.js +58 -0
- package/dist/node_modules/cron-parser/lib/parser.js +1 -0
- package/dist/node_modules/cron-parser/package.json +1 -0
- package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
- package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
- package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/semver/package.json +1 -1
- package/dist/node_modules/yauzl/package.json +1 -1
- package/dist/server/collections/autoBackup.d.ts +2 -0
- package/dist/server/collections/autoBackup.js +64 -0
- package/dist/server/commands/backup-command.d.ts +2 -0
- package/dist/server/commands/backup-command.js +78 -0
- package/dist/server/dumper.d.ts +1 -1
- package/dist/server/dumper.js +1 -0
- package/dist/server/model/AutoBackupModel.d.ts +15 -0
- package/dist/server/model/AutoBackupModel.js +29 -0
- package/dist/server/server.d.ts +9 -0
- package/dist/server/server.js +182 -3
- package/dist/server/utils/files.d.ts +6 -0
- package/dist/server/utils/files.js +59 -0
- package/package.json +14 -9
package/dist/client/index.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
(function(p,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/components"),require("@ant-design/icons"),require("antd"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/components","@ant-design/icons","antd","react-i18next"],r):(p=typeof globalThis!="undefined"?globalThis:p||self,r(p["@tachybase/module-backup"]={},p["@tachybase/client"],p.jsxRuntime,p.react,p["@tachybase/components"],p["@ant-design/icons"],p.antd,p["react-i18next"]))})(this,function(p,r,e,k,L,x,l,P){"use strict";var Z=Object.defineProperty,R=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var W=(p,r,e)=>r in p?Z(p,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[r]=e,E=(p,r)=>{for(var e in r||(r={}))te.call(r,e)&&W(p,e,r[e]);if($)for(var e of $(r))oe.call(r,e)&&W(p,e,r[e]);return p},q=(p,r)=>R(p,ee(r));var T=(p,r,e)=>new Promise((k,L)=>{var x=m=>{try{P(e.next(m))}catch(A){L(A)}},l=m=>{try{P(e.throw(m))}catch(A){L(A)}},P=m=>m.done?k(m.value):Promise.resolve(m.value).then(x,l);P((e=e.apply(p,r)).next())});var m=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},A={exports:{}};(function(a,b){(function(i,c){c()})(m,function(){function i(t,s){return typeof s=="undefined"?s={autoBom:!1}:typeof s!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),s={autoBom:!s}),s.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\uFEFF",t],{type:t.type}):t}function c(t,s,g){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){v(n.response,s,g)},n.onerror=function(){console.error("could not download file")},n.send()}function u(t){var s=new XMLHttpRequest;s.open("HEAD",t,!1);try{s.send()}catch(g){}return 200<=s.status&&299>=s.status}function h(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(g){var s=document.createEvent("MouseEvents");s.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(s)}}var f=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof m=="object"&&m.global===m?m:void 0,w=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),v=f.saveAs||(typeof window!="object"||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!w?function(t,s,g){var n=f.URL||f.webkitURL,d=document.createElement("a");s=s||t.name||"download",d.download=s,d.rel="noopener",typeof t=="string"?(d.href=t,d.origin===location.origin?h(d):u(d.href)?c(t,s,g):h(d,d.target="_blank")):(d.href=n.createObjectURL(t),setTimeout(function(){n.revokeObjectURL(d.href)},4e4),setTimeout(function(){h(d)},0))}:"msSaveOrOpenBlob"in navigator?function(t,s,g){if(s=s||t.name||"download",typeof t!="string")navigator.msSaveOrOpenBlob(i(t,g),s);else if(u(t))c(t,s,g);else{var n=document.createElement("a");n.href=t,n.target="_blank",setTimeout(function(){h(n)})}}:function(t,s,g,n){if(n=n||open("","_blank"),n&&(n.document.title=n.document.body.innerText="downloading..."),typeof t=="string")return c(t,s,g);var d=t.type==="application/octet-stream",C=/constructor/i.test(f.HTMLElement)||f.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||d&&C||w)&&typeof FileReader!="undefined"){var y=new FileReader;y.onloadend=function(){var S=y.result;S=o?S:S.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=S:location=S,n=null},y.readAsDataURL(t)}else{var B=f.URL||f.webkitURL,O=B.createObjectURL(t);n?n.location=O:location.href=O,n=null,setTimeout(function(){B.revokeObjectURL(O)},4e4)}});f.saveAs=v.saveAs=v,a.exports=v})})(A);var K=A.exports;const I="backup";function F(){return P.useTranslation(I,{nsMode:"fallback"})}const{Dragger:X}=l.Upload;function J(a){const b=c=>{var u;(u=a.onChange)==null||u.call(a,c)},i=r.useAPIClient();return q(E({},a),{customRequest({action:c,data:u,file:h,filename:f,headers:w,onError:v,onProgress:t,onSuccess:s,withCredentials:g}){const n=new FormData;return u&&Object.keys(u).forEach(d=>{n.append(d,u[d])}),n.append(f,h),i.axios.post(c,n,{withCredentials:g,headers:w,onUploadProgress:({total:d,loaded:C})=>{t({percent:Math.round(C/d*100).toFixed(2)},h)}}).then(({data:d})=>{s(d,h)}).catch(v).finally(()=>{}),{abort(){console.log("upload progress is aborted.")}}},onChange:b})}const U=a=>{const{collectionsData:b}=a,{t:i}=F(),[c,u]=k.useState(!1),[h,f]=k.useState(b);k.useEffect(()=>{f(b)},[b]);const w=r.useAPIClient(),v=r.useCompile(),t=k.useMemo(()=>w.resource("backupFiles"),[w]),s=()=>T(this,null,function*(){if(a.isBackup){const o=yield t.dumpableCollections();f(o==null?void 0:o.data),u(!0)}u(!0)}),g=()=>{u(!1)},n=()=>{u(!1)},d=[{title:i("Collection"),dataIndex:"collection",key:"collection",render:(o,y)=>{const B=v(y.title);return y.name===B?B:e.jsxs("div",{children:[y.name," ",e.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.3)",fontSize:"0.9em"},children:["(",v(y.title),")"]})]})}},{title:i("Origin"),dataIndex:"origin",key:"origin",width:"50%"}],C=Object.keys(h||{}).map(o=>({key:o,label:i(`${o}.title`),children:e.jsxs(e.Fragment,{children:[e.jsx(l.Alert,{style:{marginBottom:16},message:i(`${o}.description`)}),e.jsx(l.Table,{pagination:{pageSize:100},bordered:!0,size:"small",dataSource:h[o],columns:d,scroll:{y:400}})]})}));return e.jsxs(e.Fragment,{children:[e.jsx("a",{onClick:s,children:i("Learn more")}),e.jsx(l.Modal,{title:i("Backup instructions"),width:"80vw",open:c,footer:null,onOk:g,onCancel:n,children:e.jsx(l.Tabs,{defaultActiveKey:"required",items:C})})]})},G=({ButtonComponent:a=l.Button,title:b,upload:i=!1,fileData:c})=>{const{t:u}=F(),[h,f]=k.useState(["required"]),[w,v]=k.useState(!1),[t,s]=k.useState(null),[g,n]=k.useState(!1),d=r.useAPIClient(),C=k.useMemo(()=>d.resource("backupFiles"),[d]),[o,y]=k.useState([]);k.useEffect(()=>{y(Object.keys((t==null?void 0:t.dumpableCollectionsGroupByGroup)||[]).map(M=>({value:M,label:u(`${M}.title`),disabled:["required","skipped"].includes(M)})))},[t]);const B=()=>T(this,null,function*(){var M,z,H;if(v(!0),!i){n(!0);const{data:D}=yield C.get({filterByTk:c.name});y(Object.keys(((z=(M=D==null?void 0:D.data)==null?void 0:M.meta)==null?void 0:z.dumpableCollectionsGroupByGroup)||[]).map(j=>({value:j,label:u(`${j}.title`),disabled:["required","skipped"].includes(j)}))),s((H=D==null?void 0:D.data)==null?void 0:H.meta),n(!1)}}),O=()=>{C.restore({values:{dataTypes:h,filterByTk:c==null?void 0:c.name,key:t==null?void 0:t.key}}),v(!1)},S=()=>{v(!1),s(null),f(["required"])};return e.jsxs(e.Fragment,{children:[e.jsx(a,{onClick:B,children:b}),e.jsx(l.Modal,{title:u("Restore"),width:800,footer:i&&!t?null:void 0,open:w,onOk:O,onCancel:S,children:e.jsxs(l.Spin,{spinning:g,children:[i&&!t&&e.jsx(V,{setRestoreData:s}),(!i||t)&&[e.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[u("Select the data to be restored")," (",e.jsx(U,{collectionsData:t==null?void 0:t.dumpableCollectionsGroupByGroup}),"):"]},"info"),e.jsx("div",{style:{lineHeight:2,marginBottom:8},children:e.jsx(L.FormItem,{children:e.jsx(r.Checkbox.Group,{options:o,style:{flexDirection:"column"},value:h,onChange:M=>f(M)})})},"dataType")]]})})]})},Q=({ButtonComponent:a=l.Button,refresh:b})=>{const{t:i}=F(),[c,u]=k.useState(!1),[h,f]=k.useState(["required"]),w=r.useAPIClient(),{notification:v}=l.App.useApp(),[t,s]=k.useState([]),g=()=>T(this,null,function*(){const{data:C}=yield w.resource("backupFiles").dumpableCollections();s(Object.keys(C||[]).map(o=>({value:o,label:i(`${o}.title`),disabled:["required","skipped"].includes(o)}))),u(!0)}),n=C=>{w.request({url:"backupFiles:create",method:"post",data:{dataTypes:h,method:C}}),v.info({key:"backup",message:e.jsxs("span",{children:[i("Processing...")," ",e.jsx(l.Spin,{indicator:e.jsx(x.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0}),u(!1),f(["required"]),setTimeout(()=>{b()},500)},d=()=>{u(!1),f(["required"])};return e.jsxs(e.Fragment,{children:[e.jsx(a,{icon:e.jsx(x.PlusOutlined,{}),type:"primary",onClick:g,children:i("New backup")}),e.jsxs(l.Modal,{title:i("New backup"),width:800,open:c,onCancel:d,footer:[e.jsxs(l.Row,{gutter:16,justify:"end",align:"middle",children:[e.jsx(l.Col,{children:e.jsx(l.Button,{onClick:d,children:i("Cancel")},"cancel")}),e.jsx(l.Col,{children:e.jsx(l.Dropdown.Button,{type:"primary",onClick:()=>n("priority"),overlay:e.jsxs(l.Menu,{children:[e.jsx(l.Menu.Item,{onClick:()=>n("main"),children:i("Self backup")},"main"),e.jsx(l.Menu.Item,{onClick:()=>n("worker"),children:i("Worker backup")},"worker")]}),children:i("Backup")},"submit")})]})],children:[e.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[i("Select the data to be backed up")," (",e.jsx(U,{isBackup:!0}),"):"]}),e.jsx("div",{style:{lineHeight:2,marginBottom:8},children:e.jsx(r.Checkbox.Group,{options:t,style:{flexDirection:"column"},onChange:C=>f(C),value:h})})]})]})},V=a=>{const{t:b}=F(),i={multiple:!1,action:"/backupFiles:upload",onChange(c){var h,f,w;c.fileList.length>1&&c.fileList.splice(0,c.fileList.length-1);const{status:u}=c.file;u==="done"?(l.message.success(`${c.file.name} `+b("file uploaded successfully")),a.setRestoreData(q(E({},(f=(h=c.file.response)==null?void 0:h.data)==null?void 0:f.meta),{key:(w=c.file.response)==null?void 0:w.data.key}))):u==="error"&&l.message.error(`${c.file.name} `+b("file upload failed"))},onDrop(c){console.log("Dropped files",c.dataTransfer.files)}};return e.jsxs(X,q(E({},J(i)),{children:[e.jsx("p",{className:"ant-upload-drag-icon",children:e.jsx(x.InboxOutlined,{})}),e.jsxs("p",{className:"ant-upload-text",children:[" ",b("Click or drag file to this area to upload")]})]}))},Y=()=>{const{t:a}=F(),b=r.useAPIClient(),[i,c]=k.useState([]),[u,h]=k.useState(!1),[f,w]=k.useState(!1),{modal:v,notification:t}=l.App.useApp(),s=k.useMemo(()=>b.resource("backupFiles"),[b]),g=k.useCallback(()=>T(this,null,function*(){yield n()}),[]);r.useNoticeSub("backup",o=>{(t[o.level]||t.info)({key:"backup",message:o.msg}),g()}),k.useEffect(()=>{n()},[]);const n=()=>T(this,null,function*(){h(!0);const{data:o}=yield s.list();c(o.data),h(!1)}),d=o=>T(this,null,function*(){w(o.name);const y=yield b.request({url:"backupFiles:download",method:"get",params:{filterByTk:o.name},responseType:"blob",onDownloadProgress:O=>{const S=Math.round(O.loaded*100/O.total);S>=100?t.success({key:"downloadBackup",message:e.jsx("span",{children:a("Downloaded success!")}),duration:1}):t.info({key:"downloadBackup",message:e.jsxs("span",{children:[a("Downloading ")+S+"%"," ",e.jsx(l.Spin,{indicator:e.jsx(x.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0})}});w(!1);const B=new Blob([y.data]);K.saveAs(B,o.name)}),C=o=>{v.confirm({title:a("Delete record",{ns:"core"}),content:a("Are you sure you want to delete it?",{ns:"core"}),onOk:()=>T(this,null,function*(){yield s.destroy({filterByTk:o.name}),yield n(),l.message.success(a("Deleted successfully"))})})};return e.jsx("div",{children:e.jsxs(l.Card,{bordered:!1,children:[e.jsxs(l.Space,{style:{float:"right",marginBottom:16},children:[e.jsx(l.Button,{onClick:g,icon:e.jsx(x.ReloadOutlined,{}),children:a("Refresh")}),e.jsx(G,{upload:!0,title:e.jsxs(e.Fragment,{children:[e.jsx(x.UploadOutlined,{})," ",a("Restore backup from local")]})}),e.jsx(Q,{refresh:g})]}),e.jsx(l.Table,{dataSource:i,loading:u,columns:[{title:a("Backup file"),dataIndex:"name",width:400,onCell:o=>o.inProgress?{colSpan:4}:{},render:(o,y)=>y.inProgress?e.jsxs("div",{style:{color:"rgba(0, 0, 0, 0.88)"},children:[o,"(",a("Backing up"),"...)"]}):y.status==="error"?e.jsxs("div",{style:{color:"red"},children:[o,"(",a("Error"),")"]}):e.jsx("div",{children:o})},{title:a("File size"),dataIndex:"fileSize",onCell:o=>o.inProgress?{colSpan:0}:{}},{title:a("Created at",{ns:"core"}),dataIndex:"createdAt",onCell:o=>o.inProgress?{colSpan:0}:{},render:o=>e.jsx(r.DatePicker.ReadPretty,{value:o,showTime:!0})},{title:a("Actions",{ns:"core"}),dataIndex:"actions",onCell:o=>o.inProgress?{colSpan:0}:{},render:(o,y)=>e.jsxs(l.Space,{split:e.jsx(l.Divider,{type:"vertical"}),children:[y.status!=="error"&&e.jsx(G,{ButtonComponent:"a",title:a("Restore"),fileData:y}),y.status!=="error"&&e.jsx("a",{type:"link",onClick:()=>d(y),children:a("Download")}),e.jsx("a",{onClick:()=>C(y),children:a("Delete")})]})}]})]})})},_=function(a){return e.jsx(r.SchemaComponentOptions,{children:a.children})};_.displayName="DuplicatorProvider";class N extends r.Plugin{load(){return T(this,null,function*(){this.app.use(_),this.app.systemSettingsManager.add("system-services."+I,{title:this.t("Backup & Restore"),icon:"CloudServerOutlined",Component:Y,aclSnippet:"pm.backup.restore"})})}}p.PluginBackupRestoreClient=N,p.default=N,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(M,g){typeof exports=="object"&&typeof module!="undefined"?g(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/components"),require("@ant-design/icons"),require("antd"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/components","@ant-design/icons","antd","react-i18next"],g):(M=typeof globalThis!="undefined"?globalThis:M||self,g(M["@tachybase/module-backup"]={},M["@tachybase/client"],M.jsxRuntime,M.react,M["@tachybase/components"],M["@ant-design/icons"],M.antd,M["react-i18next"]))})(this,function(M,g,n,h,me,Q,k,ie){"use strict";var Wo=Object.defineProperty,zo=Object.defineProperties;var Jo=Object.getOwnPropertyDescriptors;var uo=Object.getOwnPropertySymbols;var Zo=Object.prototype.hasOwnProperty,Go=Object.prototype.propertyIsEnumerable;var po=(M,g,n)=>g in M?Wo(M,g,{enumerable:!0,configurable:!0,writable:!0,value:n}):M[g]=n,ae=(M,g)=>{for(var n in g||(g={}))Zo.call(g,n)&&po(M,n,g[n]);if(uo)for(var n of uo(g))Go.call(g,n)&&po(M,n,g[n]);return M},De=(M,g)=>zo(M,Jo(g));var Y=(M,g,n)=>new Promise((h,me)=>{var Q=z=>{try{ie(n.next(z))}catch(oe){me(oe)}},k=z=>{try{ie(n.throw(z))}catch(oe){me(oe)}},ie=z=>z.done?h(z.value):Promise.resolve(z.value).then(Q,k);ie((n=n.apply(M,g)).next())});var z=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},oe={exports:{}};(function(e,t){(function(a,o){o()})(z,function(){function a(i,l){return typeof l=="undefined"?l={autoBom:!1}:typeof l!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),l={autoBom:!l}),l.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(i.type)?new Blob(["\uFEFF",i],{type:i.type}):i}function o(i,l,v){var c=new XMLHttpRequest;c.open("GET",i),c.responseType="blob",c.onload=function(){u(c.response,l,v)},c.onerror=function(){console.error("could not download file")},c.send()}function r(i){var l=new XMLHttpRequest;l.open("HEAD",i,!1);try{l.send()}catch(v){}return 200<=l.status&&299>=l.status}function m(i){try{i.dispatchEvent(new MouseEvent("click"))}catch(v){var l=document.createEvent("MouseEvents");l.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),i.dispatchEvent(l)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof z=="object"&&z.global===z?z:void 0,d=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!d?function(i,l,v){var c=s.URL||s.webkitURL,y=document.createElement("a");l=l||i.name||"download",y.download=l,y.rel="noopener",typeof i=="string"?(y.href=i,y.origin===location.origin?m(y):r(y.href)?o(i,l,v):m(y,y.target="_blank")):(y.href=c.createObjectURL(i),setTimeout(function(){c.revokeObjectURL(y.href)},4e4),setTimeout(function(){m(y)},0))}:"msSaveOrOpenBlob"in navigator?function(i,l,v){if(l=l||i.name||"download",typeof i!="string")navigator.msSaveOrOpenBlob(a(i,v),l);else if(r(i))o(i,l,v);else{var c=document.createElement("a");c.href=i,c.target="_blank",setTimeout(function(){m(c)})}}:function(i,l,v,c){if(c=c||open("","_blank"),c&&(c.document.title=c.document.body.innerText="downloading..."),typeof i=="string")return o(i,l,v);var y=i.type==="application/octet-stream",f=/constructor/i.test(s.HTMLElement)||s.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||y&&f||d)&&typeof FileReader!="undefined"){var x=new FileReader;x.onloadend=function(){var D=x.result;D=p?D:D.replace(/^data:[^;]*;/,"data:attachment/file;"),c?c.location.href=D:location=D,c=null},x.readAsDataURL(i)}else{var T=s.URL||s.webkitURL,O=T.createObjectURL(i);c?c.location=O:location.href=O,c=null,setTimeout(function(){T.revokeObjectURL(O)},4e4)}});s.saveAs=u.saveAs=u,e.exports=u})})(oe);var mo=oe.exports;const le="backup";function R(){return ie.useTranslation([le,"core"],{nsMode:"fallback"})}const fo=e=>g.tval(e,{ns:le}),{Dragger:yo}=k.Upload;function ho(e){const t=o=>{var r;(r=e.onChange)==null||r.call(e,o)},a=g.useAPIClient();return De(ae({},e),{customRequest({action:o,data:r,file:m,filename:s,headers:d,onError:u,onProgress:i,onSuccess:l,withCredentials:v}){const c=new FormData;return r&&Object.keys(r).forEach(y=>{c.append(y,r[y])}),c.append(s,m),a.axios.post(o,c,{withCredentials:v,headers:d,onUploadProgress:({total:y,loaded:f})=>{i({percent:Math.round(f/y*100).toFixed(2)},m)}}).then(({data:y})=>{l(y,m)}).catch(u).finally(()=>{}),{abort(){console.log("upload progress is aborted.")}}},onChange:t})}const Pe=e=>{const{collectionsData:t}=e,{t:a}=R(),[o,r]=h.useState(!1),[m,s]=h.useState(t);h.useEffect(()=>{s(t)},[t]);const d=g.useAPIClient(),u=g.useCompile(),i=h.useMemo(()=>d.resource("backupFiles"),[d]),l=()=>Y(this,null,function*(){if(e.isBackup){const p=yield i.dumpableCollections();s(p==null?void 0:p.data),r(!0)}r(!0)}),v=()=>{r(!1)},c=()=>{r(!1)},y=[{title:a("Collection"),dataIndex:"collection",key:"collection",render:(p,x)=>{const T=u(x.title);return x.name===T?T:n.jsxs("div",{children:[x.name," ",n.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.3)",fontSize:"0.9em"},children:["(",u(x.title),")"]})]})}},{title:a("Origin"),dataIndex:"origin",key:"origin",width:"50%"}],f=Object.keys(m||{}).map(p=>({key:p,label:a(`${p}.title`),children:n.jsxs(n.Fragment,{children:[n.jsx(k.Alert,{style:{marginBottom:16},message:a(`${p}.description`)}),n.jsx(k.Table,{pagination:{pageSize:100},bordered:!0,size:"small",dataSource:m[p],columns:y,scroll:{y:400}})]})}));return n.jsxs(n.Fragment,{children:[n.jsx("a",{onClick:l,children:a("Learn more")}),n.jsx(k.Modal,{title:a("Backup instructions"),width:"80vw",open:o,footer:null,onOk:v,onCancel:c,children:n.jsx(k.Tabs,{defaultActiveKey:"required",items:f})})]})},Fe=({ButtonComponent:e=k.Button,title:t,upload:a=!1,fileData:o})=>{const{t:r}=R(),[m,s]=h.useState(["required"]),[d,u]=h.useState(!1),[i,l]=h.useState(null),[v,c]=h.useState(!1),y=g.useAPIClient(),f=h.useMemo(()=>y.resource("backupFiles"),[y]),[p,x]=h.useState([]);h.useEffect(()=>{x(Object.keys((i==null?void 0:i.dumpableCollectionsGroupByGroup)||[]).map(E=>({value:E,label:r(`${E}.title`),disabled:["required","skipped"].includes(E)})))},[i]);const T=()=>Y(this,null,function*(){var E,K,U;if(u(!0),!a){c(!0);const{data:A}=yield f.get({filterByTk:o.name});x(Object.keys(((K=(E=A==null?void 0:A.data)==null?void 0:E.meta)==null?void 0:K.dumpableCollectionsGroupByGroup)||[]).map(q=>({value:q,label:r(`${q}.title`),disabled:["required","skipped"].includes(q)}))),l((U=A==null?void 0:A.data)==null?void 0:U.meta),c(!1)}}),O=()=>{f.restore({values:{dataTypes:m,filterByTk:o==null?void 0:o.name,key:i==null?void 0:i.key}}),u(!1)},D=()=>{u(!1),l(null),s(["required"])};return n.jsxs(n.Fragment,{children:[n.jsx(e,{onClick:T,children:t}),n.jsx(k.Modal,{title:r("Restore"),width:800,footer:a&&!i?null:void 0,open:d,onOk:O,onCancel:D,children:n.jsxs(k.Spin,{spinning:v,children:[a&&!i&&n.jsx(bo,{setRestoreData:l}),(!a||i)&&[n.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[r("Select the data to be restored")," (",n.jsx(Pe,{collectionsData:i==null?void 0:i.dumpableCollectionsGroupByGroup}),"):"]},"info"),n.jsx("div",{style:{lineHeight:2,marginBottom:8},children:n.jsx(me.FormItem,{children:n.jsx(g.Checkbox.Group,{options:p,style:{flexDirection:"column"},value:m,onChange:E=>s(E)})})},"dataType")]]})})]})},vo=({ButtonComponent:e=k.Button,refresh:t})=>{const{t:a}=R(),[o,r]=h.useState(!1),[m,s]=h.useState(["required"]),d=g.useAPIClient(),{notification:u}=k.App.useApp(),[i,l]=h.useState([]),v=()=>Y(this,null,function*(){const{data:f}=yield d.resource("backupFiles").dumpableCollections();l(Object.keys(f||[]).map(p=>({value:p,label:a(`${p}.title`),disabled:["required","skipped"].includes(p)}))),r(!0)}),c=f=>{d.request({url:"backupFiles:create",method:"post",data:{dataTypes:m,method:f}}),u.info({key:"backup",message:n.jsxs("span",{children:[a("Processing...")," ",n.jsx(k.Spin,{indicator:n.jsx(Q.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0}),r(!1),s(["required"]),setTimeout(()=>{t()},500)},y=()=>{r(!1),s(["required"])};return n.jsxs(n.Fragment,{children:[n.jsx(e,{icon:n.jsx(Q.PlusOutlined,{}),type:"primary",onClick:v,children:a("New backup")}),n.jsxs(k.Modal,{title:a("New backup"),width:800,open:o,onCancel:y,footer:[n.jsxs(k.Row,{gutter:16,justify:"end",align:"middle",children:[n.jsx(k.Col,{children:n.jsx(k.Button,{onClick:y,children:a("Cancel")},"cancel")}),n.jsx(k.Col,{children:n.jsx(k.Dropdown.Button,{type:"primary",onClick:()=>c("priority"),overlay:n.jsxs(k.Menu,{children:[n.jsx(k.Menu.Item,{onClick:()=>c("main"),children:a("Self backup")},"main"),n.jsx(k.Menu.Item,{onClick:()=>c("worker"),children:a("Worker backup")},"worker")]}),children:a("Backup")},"submit")})]})],children:[n.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[a("Select the data to be backed up")," (",n.jsx(Pe,{isBackup:!0}),"):"]}),n.jsx("div",{style:{lineHeight:2,marginBottom:8},children:n.jsx(g.Checkbox.Group,{options:i,style:{flexDirection:"column"},onChange:f=>s(f),value:m})})]})]})},bo=e=>{const{t}=R(),a={multiple:!1,action:"/backupFiles:upload",onChange(o){var m,s,d;o.fileList.length>1&&o.fileList.splice(0,o.fileList.length-1);const{status:r}=o.file;r==="done"?(k.message.success(`${o.file.name} `+t("file uploaded successfully")),e.setRestoreData(De(ae({},(s=(m=o.file.response)==null?void 0:m.data)==null?void 0:s.meta),{key:(d=o.file.response)==null?void 0:d.data.key}))):r==="error"&&k.message.error(`${o.file.name} `+t("file upload failed"))},onDrop(o){console.log("Dropped files",o.dataTransfer.files)}};return n.jsxs(yo,De(ae({},ho(a)),{children:[n.jsx("p",{className:"ant-upload-drag-icon",children:n.jsx(Q.InboxOutlined,{})}),n.jsxs("p",{className:"ant-upload-text",children:[" ",t("Click or drag file to this area to upload")]})]}))},xo=()=>{const{t:e}=R(),t=g.useAPIClient(),[a,o]=h.useState([]),[r,m]=h.useState(!1),[s,d]=h.useState(!1),{modal:u,notification:i}=k.App.useApp(),l=h.useMemo(()=>t.resource("backupFiles"),[t]),v=h.useCallback(()=>Y(this,null,function*(){yield c()}),[]);g.useNoticeSub("backup",p=>{(i[p.level]||i.info)({key:"backup",message:p.msg}),v()}),h.useEffect(()=>{c()},[]);const c=()=>Y(this,null,function*(){m(!0);const{data:p}=yield l.list();o(p.data),m(!1)}),y=p=>Y(this,null,function*(){d(p.name);const x=yield t.request({url:"backupFiles:download",method:"get",params:{filterByTk:p.name},responseType:"blob",onDownloadProgress:O=>{const D=Math.round(O.loaded*100/O.total);D>=100?i.success({key:"downloadBackup",message:n.jsx("span",{children:e("Downloaded success!")}),duration:1}):i.info({key:"downloadBackup",message:n.jsxs("span",{children:[e("Downloading ")+D+"%"," ",n.jsx(k.Spin,{indicator:n.jsx(Q.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0})}});d(!1);const T=new Blob([x.data]);mo.saveAs(T,p.name)}),f=p=>{u.confirm({title:e("Delete record",{ns:"core"}),content:e("Are you sure you want to delete it?",{ns:"core"}),onOk:()=>Y(this,null,function*(){yield l.destroy({filterByTk:p.name}),yield c(),k.message.success(e("Deleted successfully"))})})};return n.jsx("div",{children:n.jsxs(k.Card,{bordered:!1,children:[n.jsxs(k.Space,{style:{float:"right",marginBottom:16},children:[n.jsx(k.Button,{onClick:v,icon:n.jsx(Q.ReloadOutlined,{}),children:e("Refresh")}),n.jsx(Fe,{upload:!0,title:n.jsxs(n.Fragment,{children:[n.jsx(Q.UploadOutlined,{})," ",e("Restore backup from local")]})}),n.jsx(vo,{refresh:v})]}),n.jsx(k.Table,{dataSource:a,loading:r,columns:[{title:e("Backup file"),dataIndex:"name",width:400,onCell:p=>p.inProgress?{colSpan:4}:{},render:(p,x)=>x.inProgress?n.jsxs("div",{style:{color:"rgba(0, 0, 0, 0.88)"},children:[p,"(",e("Backing up"),"...)"]}):x.status==="error"?n.jsxs("div",{style:{color:"red"},children:[p,"(",e("Error"),")"]}):n.jsx("div",{children:p})},{title:e("File size"),dataIndex:"fileSize",onCell:p=>p.inProgress?{colSpan:0}:{}},{title:e("Created at",{ns:"core"}),dataIndex:"createdAt",onCell:p=>p.inProgress?{colSpan:0}:{},render:p=>n.jsx(g.DatePicker.ReadPretty,{value:p,showTime:!0})},{title:e("Actions",{ns:"core"}),dataIndex:"actions",onCell:p=>p.inProgress?{colSpan:0}:{},render:(p,x)=>n.jsxs(k.Space,{split:n.jsx(k.Divider,{type:"vertical"}),children:[x.status!=="error"&&n.jsx(Fe,{ButtonComponent:"a",title:e("Restore"),fileData:x}),x.status!=="error"&&n.jsx("a",{type:"link",onClick:()=>y(x),children:e("Download")}),n.jsx("a",{onClick:()=>f(x),children:e("Delete")})]})}]})]})})},go={dumpRules:"required",name:"autoBackup",shared:!0,createdAt:!0,updatedAt:!0,createdBy:!0,updatedBy:!0,fields:[{type:"string",name:"title",required:!0,uiSchema:{title:'{{ t("Title") }}',type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",defaultValue:!1,uiSchema:{title:'{{ t("Enabled") }}',type:"boolean","x-component":"Checkbox",required:!0}},{type:"array",name:"dumpRules",uiSchema:{title:'{{ t("Dump rules") }}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"repeat",required:!0,uiSchema:{title:'{{t("Repeat mode")}}',type:"string","x-component":"RepeatField"}},{type:"integer",name:"maxNumber",uiSchema:{title:'{{ t("Max number") }}',type:"integer","x-component":"Input",required:!0}},{type:"encryption",name:"password",interface:"encryption",iv:"welljzlyq2p2439v",uiSchema:{title:'{{ t("Password") }}',type:"encryption","x-component":"Input",required:!0}}]};var H=function(){return H=Object.assign||function(e){for(var t,a=1,o=arguments.length;a<o;a++)for(var r in t=arguments[a])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},H.apply(this,arguments)};function Te(e,t){var a={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(a[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(a[o[r]]=e[o[r]])}return a}function fe(e,t,a){if(a||arguments.length===2)for(var o,r=0,m=t.length;r<m;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var ko=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],ee=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],w={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function je(e,t){for(var a=[],o=e;o<=t;o++)a.push(o);return a}function ye(e){return e.sort(function(t,a){return t-a}),e}function Ee(e){var t=[];return e.forEach(function(a){t.indexOf(a)<0&&t.push(a)}),t}function J(e){return Object.entries(e).filter(function(t){var a=t[0],o=t[1];return a&&o}).map(function(t){return t[0]}).join(" ")}function Ie(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||w.errorInvalidCron})}function he(e){var t=parseInt(e,10),a=Number(e);return t===a?a:NaN}function Le(e,t,a,o,r,m,s,d,u,i,l,v,c,y){a&&a(void 0),t(!1);var f=!1;if(!e){if(o==="always"||m&&o==="for-default-value")return;f=!0}if(!f){if(d&&(d===!0||d.includes(e))){if(e==="@reboot")return void y("reboot");var p=ko.find(function(O){return O.name===e});p&&(e=p.value)}try{var x=function(O){if(typeof O!="string")throw new Error("Invalid cron string");var D=O.replace(/\s+/g," ").trim().split(" ");if(D.length===5)return D.map(function(E,K){return function(U,A){if(U==="*"||U==="*/1")return[];var q=ye(Ee(qe(function(Z,F,G){if(G){Z=Z.toUpperCase();for(var b=0;b<G.length;b++)Z=Z.replace(G[b],"".concat(b+F))}return Z}(U,A.min,A.alt).split(",").map(function(Z){var F,G=Z.split("/");if(G.length>2)throw new Error('Invalid value "'.concat(U,' for "').concat(A.type,'"'));var b=G[0],C=G[1];F=b==="*"?je(A.min,A.max):function(B,N,I){var L=B.split("-");if(L.length===1){var ce=he(L[0]);if(isNaN(ce))throw new Error('Invalid value "'.concat(N,'" for ').concat(I.type));return[ce]}if(L.length===2){var _=he(L[0]),ne=he(L[1]);if(isNaN(_)||isNaN(ne))throw new Error('Invalid value "'.concat(N,'" for ').concat(I.type));if(ne<_)throw new Error('Max range is less than min range in "'.concat(B,'" for ').concat(I.type));return je(_,ne)}throw new Error('Invalid value "'.concat(B,'" for ').concat(I.type))}(b,U,A);var S=function(B,N){if(B!==void 0){var I=he(B);if(isNaN(I)||I<1)throw new Error('Invalid interval step value "'.concat(B,'" for ').concat(N.type));return I}}(C,A),W=function(B,N){if(N){var I=B[0];B=B.filter(function(L){return L%N==I%N||L===I})}return B}(F,S);return W}).flat(),A))),j=We(q,A);if(j!==void 0)throw new Error('Value "'.concat(j,'" out of range for ').concat(A.type));return q.length===A.total?[]:q}(E,ee[K])});throw new Error("Invalid cron string format")}(e),T=function(O){return O[3].length>0?"year":O[2].length>0?"month":O[4].length>0?"week":O[1].length>0?"day":O[0].length>0?"hour":"minute"}(x);y(T),u(x[0]),i(x[1]),l(x[2]),v(x[3]),c(x[4])}catch(O){f=!0}}f&&(r.current=e,t(!0),Ie(a,s))}function Ve(e,t,a,o,r,m,s){if(e==="reboot")return"@reboot";var d=function(u,i){return u.map(function(l,v){var c=ee[v];return He(Ue(l,c),c,i)})}([e!=="minute"&&m?m:[],e!=="minute"&&e!=="hour"&&r?r:[],e!=="year"&&e!=="month"||!a?[]:a,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!o?[]:o],s);return d.join(" ")}function He(e,t,a,o,r){var m="";if(function(d,u){return d.length===u.max-u.min+1}(e,t)||e.length===0)m="*";else{var s=function(d){if(d.length>2){var u=d[1]-d[0];if(u>1)return u}}(e);m=s&&function(d,u){for(var i=1;i<d.length;i++){var l=d[i-1];if(d[i]-l!==u)return!1}return!0}(e,s)?function(d,u,i){var l=ze(d),v=Je(d),c=d.length===(v-l)/i+1;return!!(l===u.min&&v+i>u.max&&c)}(e,t,s)?"*/".concat(s):"".concat(te(ze(e),t,a,o,r),"-").concat(te(Je(e),t,a,o,r),"/").concat(s):function(d){var u=[],i=null;return d.forEach(function(l,v,c){l!==c[v+1]-1?i!==null?(u.push([i,l]),i=null):u.push(l):i===null&&(i=l)}),u}(e).map(function(d){return Array.isArray(d)?"".concat(te(d[0],t,a,o,r),"-").concat(te(d[1],t,a,o,r)):te(d,t,a,o,r)}).join(",")}return m}function te(e,t,a,o,r){var m=e.toString(),s=t.type,d=t.alt,u=t.min,i=o&&(o===!0||o.includes(s)),l=r==="24-hour-clock"&&(s==="hours"||s==="minutes");if(a&&s==="week-days"||a&&s==="months"?m=d[e-u]:e<10&&(i||l)&&(m=m.padStart(2,"0")),s==="hours"&&r==="12-hour-clock"){var v=e>=12?"PM":"AM",c=e%12||12;c<10&&i&&(c=c.toString().padStart(2,"0")),m="".concat(c).concat(v)}return m}function Ue(e,t){var a=ye(Ee(qe(e,t)));if(a.length===0)return a;var o=We(a,t);if(o!==void 0)throw new Error('Value "'.concat(o,'" out of range for ').concat(t.type));return a}function qe(e,t){return t.type==="week-days"&&(e=e.map(function(a){return a===7?0:a})),e}function We(e,t){var a=e[0],o=e[e.length-1];return a<t.min?a:o>t.max?o:void 0}function ze(e){return e[0]}function Je(e){return e[e.length-1]}function se(e){var t=e.value,a=e.grid,o=a===void 0||a,r=e.optionsList,m=e.setValue,s=e.locale,d=e.className,u=e.humanizeLabels,i=e.disabled,l=e.readOnly,v=e.leadingZero,c=e.clockFormat,y=e.period,f=e.unit,p=e.periodicityOnDoubleClick,x=e.mode,T=Te(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),O=h.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(b){return b.toString()})},[t]),D=h.useMemo(function(){return r?r.map(function(b,C){return{value:(f.min===0?C:C+1).toString(),label:b}}):fe([],Array(f.total),!0).map(function(b,C){var S=f.min===0?C:C+1;return{value:S.toString(),label:te(S,f,u,v,c)}})},[r,v,u,c]),E=JSON.stringify(s),K=h.useCallback(function(b){var C=b.value;if(!t||t[0]!==Number(C))return n.jsx(n.Fragment,{});var S=He(Ue(t,f),f,u,v,c),W=S.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:W[1]?"".concat(s.everyText||w.everyText," ").concat(W[1]):S})},[t,E,u,v,c]),U=h.useCallback(function(b){var C=Array.isArray(b)?ye(b):[b],S=C;t&&(S=x==="single"?[]:fe([],t,!0),C.forEach(function(W){var B=Number(W);S=t.some(function(N){return N===B})?S.filter(function(N){return N!==B}):ye(fe(fe([],S,!0),[B],!1))})),S.length===f.total?m([]):m(S)},[m,t]),A=h.useCallback(function(b){if(b!==0&&b!==1){for(var C=f.total+f.min,S=[],W=f.min;W<C;W++)W%b==0&&S.push(W);var B=t&&S&&t.length===S.length&&t.every(function(I,L){return I===S[L]}),N=S.length===D.length;m(N||B?[]:S)}else m([])},[t,D,m]),q=h.useRef([]),j=h.useCallback(function(b){if(!l){var C=q.current;C.push({time:new Date().getTime(),value:Number(b)});var S=window.setTimeout(function(){p&&C.length>1&&C[C.length-1].time-C[C.length-2].time<300?C[C.length-1].value===C[C.length-2].value?A(Number(b)):U([C[C.length-2].value,C[C.length-1].value]):U(Number(b)),q.current=[]},300);return function(){window.clearTimeout(S)}}},[q,U,A,l,p]),Z=h.useCallback(function(){l||m([])},[m,l]),F=h.useMemo(function(){var b;return J(((b={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(d,"-select")]=!!d,b))},[d]),G=h.useMemo(function(){var b;return J(((b={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(f.type)]=!0,b["react-js-cron-custom-select-dropdown"]=!0,b["react-js-cron-custom-select-dropdown-".concat(f.type)]=!0,b["react-js-cron-custom-select-dropdown-minutes-large"]=f.type==="minutes"&&y!=="hour"&&y!=="day",b["react-js-cron-custom-select-dropdown-minutes-medium"]=f.type==="minutes"&&(y==="day"||y==="hour"),b["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=f.type==="hours"&&c==="12-hour-clock",b["react-js-cron-custom-select-dropdown-grid"]=!!o,b["".concat(d,"-select-dropdown")]=!!d,b["".concat(d,"-select-dropdown-").concat(f.type)]=!!d,b))},[d,o,c,y]);return n.jsx(k.Select,H({mode:x!=="single"||p?"multiple":void 0,allowClear:!l,virtual:!1,open:!l&&void 0,value:O,onClear:Z,tagRender:K,className:F,popupClassName:G,options:D,showSearch:!1,showArrow:!l,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:j,onDeselect:j,disabled:i,dropdownAlign:f.type!=="minutes"&&f.type!=="hours"||y==="day"||y==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(f.type)},T))}function wo(e){var t=e.value,a=e.setValue,o=e.locale,r=e.className,m=e.disabled,s=e.readOnly,d=e.leadingZero,u=e.clockFormat,i=e.period,l=e.periodicityOnDoubleClick,v=e.mode,c=h.useMemo(function(){var y;return J(((y={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(r,"-field")]=!!r,y["".concat(r,"-hours")]=!!r,y))},[r]);return n.jsxs("div",H({className:c},{children:[o.prefixHours!==""&&n.jsx("span",{children:o.prefixHours||w.prefixHours}),n.jsx(se,{placeholder:o.emptyHours||w.emptyHours,value:t,unit:ee[1],setValue:a,locale:o,className:r,disabled:m,readOnly:s,leadingZero:d,clockFormat:u,period:i,periodicityOnDoubleClick:l,mode:v})]}))}function Co(e){var t=e.value,a=e.setValue,o=e.locale,r=e.className,m=e.disabled,s=e.readOnly,d=e.leadingZero,u=e.clockFormat,i=e.period,l=e.periodicityOnDoubleClick,v=e.mode,c=h.useMemo(function(){var y;return J(((y={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(r,"-field")]=!!r,y["".concat(r,"-minutes")]=!!r,y))},[r]);return n.jsxs("div",H({className:c},{children:[i==="hour"?o.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:o.prefixMinutesForHourPeriod||w.prefixMinutesForHourPeriod}):o.prefixMinutes!==""&&n.jsx("span",{children:o.prefixMinutes||w.prefixMinutes}),n.jsx(se,{placeholder:i==="hour"?o.emptyMinutesForHourPeriod||w.emptyMinutesForHourPeriod:o.emptyMinutes||w.emptyMinutes,value:t,unit:ee[0],setValue:a,locale:o,className:r,disabled:m,readOnly:s,leadingZero:d,clockFormat:u,period:i,periodicityOnDoubleClick:l,mode:v}),i==="hour"&&o.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:o.suffixMinutesForHourPeriod||w.suffixMinutesForHourPeriod})]}))}function Oo(e){var t=e.value,a=e.setValue,o=e.locale,r=e.className,m=e.weekDays,s=e.disabled,d=e.readOnly,u=e.leadingZero,i=e.period,l=e.periodicityOnDoubleClick,v=e.mode,c=!m||m.length===0,y=h.useMemo(function(){var x;return J(((x={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!c})["".concat(r,"-field")]=!!r,x["".concat(r,"-month-days")]=!!r,x))},[r,c]),f=JSON.stringify(o),p=h.useMemo(function(){return c?o.emptyMonthDays||w.emptyMonthDays:o.emptyMonthDaysShort||w.emptyMonthDaysShort},[c,f]);return!d||t&&t.length>0||(!t||t.length===0)&&(!m||m.length===0)?n.jsxs("div",H({className:y},{children:[o.prefixMonthDays!==""&&n.jsx("span",{children:o.prefixMonthDays||w.prefixMonthDays}),n.jsx(se,{placeholder:p,value:t,setValue:a,unit:ee[2],locale:o,className:r,disabled:s,readOnly:d,leadingZero:u,period:i,periodicityOnDoubleClick:l,mode:v})]})):null}function So(e){var t=e.value,a=e.setValue,o=e.locale,r=e.className,m=e.humanizeLabels,s=e.disabled,d=e.readOnly,u=e.period,i=e.periodicityOnDoubleClick,l=e.mode,v=o.months||w.months,c=h.useMemo(function(){var y;return J(((y={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(r,"-field")]=!!r,y["".concat(r,"-months")]=!!r,y))},[r]);return n.jsxs("div",H({className:c},{children:[o.prefixMonths!==""&&n.jsx("span",{children:o.prefixMonths||w.prefixMonths}),n.jsx(se,{placeholder:o.emptyMonths||w.emptyMonths,optionsList:v,grid:!1,value:t,unit:H(H({},ee[3]),{alt:o.altMonths||w.altMonths}),setValue:a,locale:o,className:r,humanizeLabels:m,disabled:s,readOnly:d,period:u,periodicityOnDoubleClick:i,mode:l})]}))}function Mo(e){var t=e.value,a=e.setValue,o=e.locale,r=e.className,m=e.disabled,s=e.readOnly,d=e.shortcuts,u=e.allowedPeriods,i=[];u.includes("year")&&i.push({value:"year",label:o.yearOption||w.yearOption}),u.includes("month")&&i.push({value:"month",label:o.monthOption||w.monthOption}),u.includes("week")&&i.push({value:"week",label:o.weekOption||w.weekOption}),u.includes("day")&&i.push({value:"day",label:o.dayOption||w.dayOption}),u.includes("hour")&&i.push({value:"hour",label:o.hourOption||w.hourOption}),u.includes("minute")&&i.push({value:"minute",label:o.minuteOption||w.minuteOption}),u.includes("reboot")&&d&&(d===!0||d.includes("@reboot"))&&i.push({value:"reboot",label:o.rebootOption||w.rebootOption});var l=h.useCallback(function(f){s||a(f)},[a,s]),v=h.useMemo(function(){var f;return J(((f={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(r,"-field")]=!!r,f["".concat(r,"-period")]=!!r,f))},[r]),c=h.useMemo(function(){var f;return J(((f={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":o.prefixPeriod===""})["".concat(r,"-select")]=!!r,f))},[r,o.prefixPeriod]),y=h.useMemo(function(){var f;return J(((f={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(r,"-select-dropdown")]=!!r,f["".concat(r,"-select-dropdown-period")]=!!r,f))},[r]);return n.jsxs("div",H({className:v},{children:[o.prefixPeriod!==""&&n.jsx("span",{children:o.prefixPeriod||w.prefixPeriod}),n.jsx(k.Select,{defaultValue:t,value:t,onChange:l,options:i,className:c,popupClassName:y,disabled:m,showArrow:!s,open:!s&&void 0,"data-testid":"select-period"},JSON.stringify(o))]}))}function Do(e){var t=e.value,a=e.setValue,o=e.locale,r=e.className,m=e.humanizeLabels,s=e.monthDays,d=e.disabled,u=e.readOnly,i=e.period,l=e.periodicityOnDoubleClick,v=e.mode,c=o.weekDays||w.weekDays,y=i==="week"||!s||s.length===0,f=h.useMemo(function(){var D;return J(((D={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!y})["".concat(r,"-field")]=!!r,D["".concat(r,"-week-days")]=!!r,D))},[r,y]),p=JSON.stringify(o),x=h.useMemo(function(){return y?o.emptyWeekDays||w.emptyWeekDays:o.emptyWeekDaysShort||w.emptyWeekDaysShort},[y,p]),T=i==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!s||s.length===0),O=!u||s&&s.length>0||(!s||s.length===0)&&(!t||t.length===0);return T?n.jsxs("div",H({className:f},{children:[o.prefixWeekDays!==""&&(i==="week"||!O)&&n.jsx("span",{children:o.prefixWeekDays||w.prefixWeekDays}),o.prefixWeekDaysForMonthAndYearPeriod!==""&&i!=="week"&&O&&n.jsx("span",{children:o.prefixWeekDaysForMonthAndYearPeriod||w.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(se,{placeholder:x,optionsList:c,grid:!1,value:t,unit:H(H({},ee[4]),{alt:o.altWeekDays||w.altWeekDays}),setValue:a,locale:o,className:r,humanizeLabels:m,disabled:d,readOnly:u,period:i,periodicityOnDoubleClick:l,mode:v})]})):null}function Ao(e){var t=e.clearButton,a=t===void 0||t,o=e.clearButtonProps,r=o===void 0?{}:o,m=e.clearButtonAction,s=m===void 0?"fill-with-every":m,d=e.locale,u=d===void 0?w:d,i=e.value,l=i===void 0?"":i,v=e.setValue,c=e.displayError,y=c===void 0||c,f=e.onError,p=e.className,x=e.defaultPeriod,T=x===void 0?"day":x,O=e.allowEmpty,D=O===void 0?"for-default-value":O,E=e.humanizeLabels,K=E===void 0||E,U=e.humanizeValue,A=U!==void 0&&U,q=e.disabled,j=q!==void 0&&q,Z=e.readOnly,F=Z!==void 0&&Z,G=e.leadingZero,b=G!==void 0&&G,C=e.shortcuts,S=C===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:C,W=e.clockFormat,B=e.periodicityOnDoubleClick,N=B===void 0||B,I=e.mode,L=I===void 0?"multiple":I,ce=e.allowedDropdowns,_=ce===void 0?["period","months","month-days","week-days","hours","minutes"]:ce,ne=e.allowedPeriods,Vo=ne===void 0?["year","month","week","day","hour","minute","reboot"]:ne,re=h.useRef(l),Ae=h.useRef(T),Ke=h.useState(),X=Ke[0],ve=Ke[1],Xe=h.useState(),ue=Xe[0],be=Xe[1],Qe=h.useState(),xe=Qe[0],ge=Qe[1],Re=h.useState(),de=Re[0],ke=Re[1],eo=h.useState(),we=eo[0],Ce=eo[1],oo=h.useState(),Oe=oo[0],Se=oo[1],to=h.useState(!1),Be=to[0],pe=to[1],no=h.useState(!1),Me=no[0],ro=no[1],Ho=function(P){var $=h.useRef(P);return h.useEffect(function(){$.current=P},[P]),$.current}(Me),ao=JSON.stringify(u);h.useEffect(function(){Le(l,pe,f,D,re,!0,u,S,Se,Ce,be,ge,ke,ve)},[]),h.useEffect(function(){l!==re.current&&Le(l,pe,f,D,re,!1,u,S,Se,Ce,be,ge,ke,ve)},[l,re,ao,D,S]),h.useEffect(function(){if(!(X||Oe||xe||ue||de||we)||Me||Ho)Me&&ro(!1);else{var P=X||Ae.current,$=Ve(P,xe,ue,de,we,Oe,A);v($,{selectedPeriod:P}),re.current=$,f&&f(void 0),pe(!1)}},[X,ue,xe,de,we,Oe,A,Me]);var io=h.useCallback(function(){be(void 0),ge(void 0),ke(void 0),Ce(void 0),Se(void 0);var P="",$=X!=="reboot"&&X?X:Ae.current;$!==X&&ve($),s==="fill-with-every"&&(P=Ve($,void 0,void 0,void 0,void 0,void 0)),v(P,{selectedPeriod:$}),re.current=P,ro(!0),D==="never"&&s==="empty"?(pe(!0),Ie(f,u)):(f&&f(void 0),pe(!1))},[X,v,f,s]),Uo=h.useMemo(function(){var P;return J(((P={"react-js-cron":!0,"react-js-cron-error":Be&&y,"react-js-cron-disabled":j,"react-js-cron-read-only":F})["".concat(p)]=!!p,P["".concat(p,"-error")]=Be&&y&&!!p,P["".concat(p,"-disabled")]=j&&!!p,P["".concat(p,"-read-only")]=F&&!!p,P))},[p,Be,y,j,F]),Ne=r.className,lo=Te(r,["className"]),so=h.useMemo(function(){var P;return J(((P={"react-js-cron-clear-button":!0})["".concat(p,"-clear-button")]=!!p,P["".concat(Ne)]=!!Ne,P))},[p,Ne]),qo=JSON.stringify(lo),co=h.useMemo(function(){return a&&!F?n.jsx(k.Button,H({className:so,danger:!0,type:"primary",disabled:j},lo,{onClick:io},{children:u.clearButtonText||w.clearButtonText})):null},[a,F,ao,so,j,qo,io]),V=X||Ae.current;return n.jsxs("div",H({className:Uo},{children:[_.includes("period")&&n.jsx(Mo,{value:V,setValue:ve,locale:u,className:p,disabled:j,readOnly:F,shortcuts:S,allowedPeriods:Vo}),V==="reboot"?co:n.jsxs(n.Fragment,{children:[V==="year"&&_.includes("months")&&n.jsx(So,{value:xe,setValue:ge,locale:u,className:p,humanizeLabels:K,disabled:j,readOnly:F,period:V,periodicityOnDoubleClick:N,mode:L}),(V==="year"||V==="month")&&_.includes("month-days")&&n.jsx(Oo,{value:ue,setValue:be,locale:u,className:p,weekDays:de,disabled:j,readOnly:F,leadingZero:b,period:V,periodicityOnDoubleClick:N,mode:L}),(V==="year"||V==="month"||V==="week")&&_.includes("week-days")&&n.jsx(Do,{value:de,setValue:ke,locale:u,className:p,humanizeLabels:K,monthDays:ue,disabled:j,readOnly:F,period:V,periodicityOnDoubleClick:N,mode:L}),n.jsxs("div",{children:[V!=="minute"&&V!=="hour"&&_.includes("hours")&&n.jsx(wo,{value:we,setValue:Ce,locale:u,className:p,disabled:j,readOnly:F,leadingZero:b,clockFormat:W,period:V,periodicityOnDoubleClick:N,mode:L}),V!=="minute"&&_.includes("minutes")&&n.jsx(Co,{value:Oe,setValue:Se,locale:u,period:V,className:p,disabled:j,readOnly:F,leadingZero:b,clockFormat:W,periodicityOnDoubleClick:N,mode:L}),co]})]})]}))}const Bo={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},Ze=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function Ge(e){return Ze.filter(a=>!isNaN(+a.value)).reverse().find(a=>!(e%a.value))}function No(e){if(!e)return"none";if(e&&!isNaN(+e)){const t=Ge(e);return t?t.value:"none"}if(typeof e=="string")return"cron"}function Po({value:e,onChange:t}){const{t:a}=R(),o=Ge(e);return n.jsx(k.InputNumber,{value:e/o.value,onChange:r=>t(r*o.value),min:1,addonBefore:a("Every"),addonAfter:a(o.unitText),className:"auto-width"})}function Fo({value:e=null,onChange:t}){const{t:a}=R(),o=No(e),r=h.useCallback(s=>{if(s==="none"){t(null);return}if(s==="cron"){t("0 * * * * *");return}t(s)},[t]),m=Bo[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return n.jsxs("fieldset",{className:g.css`
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: ${o==="cron"?"column":"row"};
|
|
4
|
+
align-items: flex-start;
|
|
5
|
+
gap: 0.5em;
|
|
6
|
+
|
|
7
|
+
.react-js-cron {
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 0.5em 0.5em 0 0.5em;
|
|
10
|
+
border: 1px dashed #ccc;
|
|
11
|
+
|
|
12
|
+
.react-js-cron-field {
|
|
13
|
+
margin-bottom: 0.5em;
|
|
14
|
+
|
|
15
|
+
> span {
|
|
16
|
+
margin: 0 0.5em 0 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
> .react-js-cron-select {
|
|
20
|
+
margin: 0 0.5em 0 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.react-js-cron-week-days {
|
|
25
|
+
> span {
|
|
26
|
+
min-width: 2em;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`,children:[n.jsx(k.Select,{value:o,onChange:r,className:"auto-width",options:Ze.map(s=>({value:s.value,label:a(s.text)}))}),o&&!isNaN(+o)?n.jsx(Po,{value:e,onChange:t}):null,o==="cron"?n.jsx(Ao,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:s=>t(`0 ${s}`),clearButton:!1,locale:m}):null]})}const _e={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"autoBackup.name","x-component-props":{}},title:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"autoBackup.title","x-component-props":{}},enabled:{type:"boolean","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"autoBackup.enabled","x-component-props":{}},repeat:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"autoBackup.repeat","x-component-props":{}},dumpRules:{title:'{{ t("Dump rules") }}',type:"array","x-component":"Checkbox.Group","x-decorator":"FormItem","x-component-props":{style:{display:"flex",flexDirection:"column"},options:"{{ dumpRuleTypes }}"},"x-reactions":e=>{const t=new Set(e.value||[]);t.add("required"),e.value=Array.from(t)}},maxNumber:{title:'{{ t("Max number") }}',description:'{{ t("Keep only the maximum number and delete the oldest versions with redundant time.") }}',type:"number","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"autoBackup.maxNumber","x-component-props":{}}},To={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"autoBackup:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:"autoBackup"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:ae({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},_e)}}},jo={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:To}}}},Eo={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"autoBackup:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:"autoBackup"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:ae({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},_e)}}}}}}},Io={type:"void",properties:{autoBackupTable:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"autoBackup:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{collection:"autoBackup",dataSource:"main",action:"list",params:{pageSize:20},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},create:jo}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{"x-collection-field":"autoBackup.title","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{enabled:{"x-collection-field":"autoBackup.enabled","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},maxNumber:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{maxNumber:{"x-collection-field":"autoBackup.maxNumber","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:100,fixed:"right"},properties:{actions:{type:"void","x-component":"Space",properties:{editAction:Eo,delete:{type:"void",title:"Delete","x-action":"destroy","x-component":"Action.Link","x-component-props":{confirm:{title:"Delete",content:"Are you sure you want to delete it?"}},"x-decorator":"ACLActionProvider","x-use-component-props":"useDestroyActionProps"},clear:{type:"void",title:fo("Clear current times"),"x-action":"clearLimit","x-component":"Action.Link","x-component-props":{confirm:{title:"Clear",content:"Are you sure you want to clear current times?"}},"x-decorator":"ACLActionProvider","x-use-component-props":()=>{const{refresh:e}=g.useDataBlockRequest(),t=g.useDataBlockResource(),a=g.useRecord();return{onClick(){return Y(this,null,function*(){yield t.clearLimitExecuted({id:a.id}),e()})}}}}}}}}}}}}}},Lo=()=>{const{t:e}=R(),{data:t,loading:a,refresh:o}=g.useRequest({url:"backupFiles:dumpableCollections"}),r=h.useMemo(()=>t?Object.keys(t).map(m=>({value:m,label:e(`${m}.title`),disabled:["required","skipped"].includes(m)})):[],[t]);return n.jsx(g.ExtendCollectionsProvider,{collections:[go],children:n.jsx(g.SchemaComponent,{schema:Io,name:"auto-backup-table",components:{RepeatField:Fo},scope:{t:e,dumpRuleTypes:r}})})},$e=function(e){return n.jsx(g.SchemaComponentOptions,{children:e.children})};$e.displayName="DuplicatorProvider";class Ye extends g.Plugin{load(){return Y(this,null,function*(){this.app.use($e),this.app.systemSettingsManager.add("system-services."+le,{title:this.t("Backup & Restore"),icon:"CloudServerOutlined",sort:-50}),this.app.systemSettingsManager.add("system-services."+le+".files",{title:this.t("Backup file"),icon:"CloudServerOutlined",Component:xo,aclSnippet:"pm.backup.restore"}),this.app.systemSettingsManager.add("system-services."+le+".auto",{title:this.t("Auto backup"),icon:"CloudServerOutlined",Component:Lo,aclSnippet:"pm.backup.auto",sort:20})})}}M.PluginBackupRestoreClient=Ye,M.default=Ye,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
1
2
|
export declare const NAMESPACE = "backup";
|
|
2
3
|
export declare function lang(key: string): string;
|
|
3
4
|
export declare function generateNTemplate(key: string): string;
|
|
4
|
-
export declare function useDuplicatorTranslation(): import("react-i18next").UseTranslationResponse<
|
|
5
|
+
export declare function useDuplicatorTranslation(): import("react-i18next").UseTranslationResponse<[string, string], undefined>;
|
|
6
|
+
export declare const tval: (key: string) => string;
|
|
7
|
+
export { useTranslation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const COLLECTION_AUTOBACKUP = "autoBackup";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
COLLECTION_AUTOBACKUP: () => COLLECTION_AUTOBACKUP
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(constants_exports);
|
|
23
|
+
const COLLECTION_AUTOBACKUP = "autoBackup";
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
COLLECTION_AUTOBACKUP
|
|
27
|
+
});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.0
|
|
4
|
-
"@tachybase/components": "1.0
|
|
3
|
+
"@tachybase/client": "1.1.0",
|
|
4
|
+
"@tachybase/components": "1.1.0",
|
|
5
5
|
"@ant-design/icons": "5.5.2",
|
|
6
6
|
"antd": "5.22.5",
|
|
7
|
-
"@tachybase/server": "1.0
|
|
8
|
-
"@tachybase/utils": "1.0
|
|
9
|
-
"@tachybase/database": "1.0
|
|
7
|
+
"@tachybase/server": "1.1.0",
|
|
8
|
+
"@tachybase/utils": "1.1.0",
|
|
9
|
+
"@tachybase/database": "1.1.0",
|
|
10
10
|
"dayjs": "1.11.13",
|
|
11
11
|
"lodash": "4.17.21",
|
|
12
|
+
"@tachybase/schema": "1.1.0",
|
|
12
13
|
"react-i18next": "15.2.0",
|
|
13
|
-
"@tachybase/actions": "1.0
|
|
14
|
+
"@tachybase/actions": "1.1.0"
|
|
14
15
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"Advanced": "高级模式",
|
|
3
|
+
"Auto backup": "自动备份",
|
|
2
4
|
"Backed up successfully": "备份成功",
|
|
3
5
|
"Backing up": "备份中",
|
|
4
6
|
"Backup": "备份",
|
|
@@ -7,22 +9,47 @@
|
|
|
7
9
|
"Backup instructions": "备份说明",
|
|
8
10
|
"Basic Data": "基础数据",
|
|
9
11
|
"Business data": "业务数据",
|
|
12
|
+
"By custom date": "自定义时间",
|
|
13
|
+
"By day": "按天",
|
|
14
|
+
"By field": "数据表字段",
|
|
15
|
+
"By hour": "按小时",
|
|
16
|
+
"By minute": "按分钟",
|
|
17
|
+
"By month": "按月",
|
|
18
|
+
"By week": "按周",
|
|
10
19
|
"Cancel": "取消",
|
|
11
20
|
"Click or drag file to this area to upload": "点击或拖拽文件至此区域即可上传",
|
|
12
21
|
"Configuration": "配置",
|
|
22
|
+
"Days": "天",
|
|
13
23
|
"Delete": "删除",
|
|
14
24
|
"Deleted successfully": "删除成功",
|
|
15
25
|
"Done": "完成",
|
|
16
26
|
"Download": "下载",
|
|
27
|
+
"Dump rules": "备份规则",
|
|
28
|
+
"End": "结束",
|
|
29
|
+
"Ends on": "结束于",
|
|
30
|
+
"Every": "每",
|
|
31
|
+
"Exactly at": "当时",
|
|
17
32
|
"File size": "文件大小",
|
|
33
|
+
"Hours": "小时",
|
|
34
|
+
"Keep only the maximum number and delete the oldest versions with redundant time.": "仅保留最大数量,删除多余的时间最旧的版本",
|
|
35
|
+
"Last time": "上次执行时间",
|
|
18
36
|
"Learn more": "了解更多",
|
|
37
|
+
"Max number": "最大数量",
|
|
38
|
+
"Minutes": "分钟",
|
|
39
|
+
"Months": "月",
|
|
19
40
|
"New backup": "新建备份",
|
|
41
|
+
"No end": "不结束",
|
|
42
|
+
"No limit": "不限",
|
|
43
|
+
"No repeat": "不重复",
|
|
20
44
|
"Optional Data": "可选数据",
|
|
21
45
|
"Origin": "来源",
|
|
22
46
|
"Plugin": "插件",
|
|
23
47
|
"Refresh": "刷新",
|
|
48
|
+
"Repeat limit": "重复次数",
|
|
49
|
+
"Repeat mode": "重复模式",
|
|
24
50
|
"Restore": "还原",
|
|
25
51
|
"Restore backup from local": "从本地恢复备份",
|
|
52
|
+
"Seconds": "秒",
|
|
26
53
|
"Select Import Plugins": "请选择导入插件",
|
|
27
54
|
"Select Import data": "请选择导入数据",
|
|
28
55
|
"Select User Collections": "请选择用户数据",
|
|
@@ -31,9 +58,11 @@
|
|
|
31
58
|
"Self backup": "本线程备份",
|
|
32
59
|
"Start backup": "开始备份",
|
|
33
60
|
"Start restore": "开始还原",
|
|
61
|
+
"Starts on": "开始于",
|
|
34
62
|
"System config": "系统配置",
|
|
35
63
|
"System metadata": "系统元数据",
|
|
36
64
|
"User Data": "用户数据",
|
|
65
|
+
"Weeks": "周",
|
|
37
66
|
"Worker backup": "工作线程备份",
|
|
38
67
|
"custom.description": "自建表数据",
|
|
39
68
|
"custom.title": "自建表数据",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@hapi/topo","description":"Topological sorting with grouping support","version":"6.0.2","repository":"git://github.com/hapijs/topo","main":"lib/index.js","types":"lib/index.d.ts","files":["lib"],"keywords":["topological","sort","toposort","topsort"],"eslintConfig":{"extends":["plugin:@hapi/module"]},"dependencies":{"@hapi/hoek":"^11.0.2"},"devDependencies":{"@hapi/code":"^9.0.3","@hapi/eslint-plugin":"*","@hapi/lab":"^25.1.2","@types/node":"^17.0.31","typescript":"~4.6.4"},"scripts":{"test":"lab -a @hapi/code -t 100 -L -Y","test-cov-html":"lab -a @hapi/code -t 100 -L -r html -o coverage.html"},"license":"BSD-3-Clause","_lastModified":"2025-
|
|
1
|
+
{"name":"@hapi/topo","description":"Topological sorting with grouping support","version":"6.0.2","repository":"git://github.com/hapijs/topo","main":"lib/index.js","types":"lib/index.d.ts","files":["lib"],"keywords":["topological","sort","toposort","topsort"],"eslintConfig":{"extends":["plugin:@hapi/module"]},"dependencies":{"@hapi/hoek":"^11.0.2"},"devDependencies":{"@hapi/code":"^9.0.3","@hapi/eslint-plugin":"*","@hapi/lab":"^25.1.2","@types/node":"^17.0.31","typescript":"~4.6.4"},"scripts":{"test":"lab -a @hapi/code -t 100 -L -Y","test-cov-html":"lab -a @hapi/code -t 100 -L -r html -o coverage.html"},"license":"BSD-3-Clause","_lastModified":"2025-05-22T16:29:04.246Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2025-
|
|
1
|
+
{"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2025-05-22T16:29:04.051Z"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2016 Harri Siirak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var luxon = require('luxon');
|
|
4
|
+
|
|
5
|
+
CronDate.prototype.addYear = function() {
|
|
6
|
+
this._date = this._date.plus({ years: 1 });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
CronDate.prototype.addMonth = function() {
|
|
10
|
+
this._date = this._date.plus({ months: 1 }).startOf('month');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
CronDate.prototype.addDay = function() {
|
|
14
|
+
this._date = this._date.plus({ days: 1 }).startOf('day');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
CronDate.prototype.addHour = function() {
|
|
18
|
+
var prev = this._date;
|
|
19
|
+
this._date = this._date.plus({ hours: 1 }).startOf('hour');
|
|
20
|
+
if (this._date <= prev) {
|
|
21
|
+
this._date = this._date.plus({ hours: 1 });
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
CronDate.prototype.addMinute = function() {
|
|
26
|
+
var prev = this._date;
|
|
27
|
+
this._date = this._date.plus({ minutes: 1 }).startOf('minute');
|
|
28
|
+
if (this._date < prev) {
|
|
29
|
+
this._date = this._date.plus({ hours: 1 });
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
CronDate.prototype.addSecond = function() {
|
|
34
|
+
var prev = this._date;
|
|
35
|
+
this._date = this._date.plus({ seconds: 1 }).startOf('second');
|
|
36
|
+
if (this._date < prev) {
|
|
37
|
+
this._date = this._date.plus({ hours: 1 });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
CronDate.prototype.subtractYear = function() {
|
|
42
|
+
this._date = this._date.minus({ years: 1 });
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
CronDate.prototype.subtractMonth = function() {
|
|
46
|
+
this._date = this._date
|
|
47
|
+
.minus({ months: 1 })
|
|
48
|
+
.endOf('month')
|
|
49
|
+
.startOf('second');
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
CronDate.prototype.subtractDay = function() {
|
|
53
|
+
this._date = this._date
|
|
54
|
+
.minus({ days: 1 })
|
|
55
|
+
.endOf('day')
|
|
56
|
+
.startOf('second');
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
CronDate.prototype.subtractHour = function() {
|
|
60
|
+
var prev = this._date;
|
|
61
|
+
this._date = this._date
|
|
62
|
+
.minus({ hours: 1 })
|
|
63
|
+
.endOf('hour')
|
|
64
|
+
.startOf('second');
|
|
65
|
+
if (this._date >= prev) {
|
|
66
|
+
this._date = this._date.minus({ hours: 1 });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
CronDate.prototype.subtractMinute = function() {
|
|
71
|
+
var prev = this._date;
|
|
72
|
+
this._date = this._date.minus({ minutes: 1 })
|
|
73
|
+
.endOf('minute')
|
|
74
|
+
.startOf('second');
|
|
75
|
+
if (this._date > prev) {
|
|
76
|
+
this._date = this._date.minus({ hours: 1 });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
CronDate.prototype.subtractSecond = function() {
|
|
81
|
+
var prev = this._date;
|
|
82
|
+
this._date = this._date
|
|
83
|
+
.minus({ seconds: 1 })
|
|
84
|
+
.startOf('second');
|
|
85
|
+
if (this._date > prev) {
|
|
86
|
+
this._date = this._date.minus({ hours: 1 });
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
CronDate.prototype.getDate = function() {
|
|
91
|
+
return this._date.day;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
CronDate.prototype.getFullYear = function() {
|
|
95
|
+
return this._date.year;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
CronDate.prototype.getDay = function() {
|
|
99
|
+
var weekday = this._date.weekday;
|
|
100
|
+
return weekday == 7 ? 0 : weekday;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
CronDate.prototype.getMonth = function() {
|
|
104
|
+
return this._date.month - 1;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
CronDate.prototype.getHours = function() {
|
|
108
|
+
return this._date.hour;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
CronDate.prototype.getMinutes = function() {
|
|
112
|
+
return this._date.minute;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
CronDate.prototype.getSeconds = function() {
|
|
116
|
+
return this._date.second;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
CronDate.prototype.getMilliseconds = function() {
|
|
120
|
+
return this._date.millisecond;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
CronDate.prototype.getTime = function() {
|
|
124
|
+
return this._date.valueOf();
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
CronDate.prototype.getUTCDate = function() {
|
|
128
|
+
return this._getUTC().day;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
CronDate.prototype.getUTCFullYear = function() {
|
|
132
|
+
return this._getUTC().year;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
CronDate.prototype.getUTCDay = function() {
|
|
136
|
+
var weekday = this._getUTC().weekday;
|
|
137
|
+
return weekday == 7 ? 0 : weekday;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
CronDate.prototype.getUTCMonth = function() {
|
|
141
|
+
return this._getUTC().month - 1;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
CronDate.prototype.getUTCHours = function() {
|
|
145
|
+
return this._getUTC().hour;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
CronDate.prototype.getUTCMinutes = function() {
|
|
149
|
+
return this._getUTC().minute;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
CronDate.prototype.getUTCSeconds = function() {
|
|
153
|
+
return this._getUTC().second;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
CronDate.prototype.toISOString = function() {
|
|
157
|
+
return this._date.toUTC().toISO();
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
CronDate.prototype.toJSON = function() {
|
|
161
|
+
return this._date.toJSON();
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
CronDate.prototype.setDate = function(d) {
|
|
165
|
+
this._date = this._date.set({ day: d });
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
CronDate.prototype.setFullYear = function(y) {
|
|
169
|
+
this._date = this._date.set({ year: y });
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
CronDate.prototype.setDay = function(d) {
|
|
173
|
+
this._date = this._date.set({ weekday: d });
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
CronDate.prototype.setMonth = function(m) {
|
|
177
|
+
this._date = this._date.set({ month: m + 1 });
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
CronDate.prototype.setHours = function(h) {
|
|
181
|
+
this._date = this._date.set({ hour: h });
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
CronDate.prototype.setMinutes = function(m) {
|
|
185
|
+
this._date = this._date.set({ minute: m });
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
CronDate.prototype.setSeconds = function(s) {
|
|
189
|
+
this._date = this._date.set({ second: s });
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
CronDate.prototype.setMilliseconds = function(s) {
|
|
193
|
+
this._date = this._date.set({ millisecond: s });
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
CronDate.prototype._getUTC = function() {
|
|
197
|
+
return this._date.toUTC();
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
CronDate.prototype.toString = function() {
|
|
201
|
+
return this.toDate().toString();
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
CronDate.prototype.toDate = function() {
|
|
205
|
+
return this._date.toJSDate();
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
CronDate.prototype.isLastDayOfMonth = function() {
|
|
209
|
+
//next day
|
|
210
|
+
var newDate = this._date.plus({ days: 1 }).startOf('day');
|
|
211
|
+
return this._date.month !== newDate.month;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Returns true when the current weekday is the last occurrence of this weekday
|
|
216
|
+
* for the present month.
|
|
217
|
+
*/
|
|
218
|
+
CronDate.prototype.isLastWeekdayOfMonth = function() {
|
|
219
|
+
// Check this by adding 7 days to the current date and seeing if it's
|
|
220
|
+
// a different month
|
|
221
|
+
var newDate = this._date.plus({ days: 7 }).startOf('day');
|
|
222
|
+
return this._date.month !== newDate.month;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
function CronDate (timestamp, tz) {
|
|
226
|
+
var dateOpts = { zone: tz };
|
|
227
|
+
if (!timestamp) {
|
|
228
|
+
this._date = luxon.DateTime.local();
|
|
229
|
+
} else if (timestamp instanceof CronDate) {
|
|
230
|
+
this._date = timestamp._date;
|
|
231
|
+
} else if (timestamp instanceof Date) {
|
|
232
|
+
this._date = luxon.DateTime.fromJSDate(timestamp, dateOpts);
|
|
233
|
+
} else if (typeof timestamp === 'number') {
|
|
234
|
+
this._date = luxon.DateTime.fromMillis(timestamp, dateOpts);
|
|
235
|
+
} else if (typeof timestamp === 'string') {
|
|
236
|
+
this._date = luxon.DateTime.fromISO(timestamp, dateOpts);
|
|
237
|
+
this._date.isValid || (this._date = luxon.DateTime.fromRFC2822(timestamp, dateOpts));
|
|
238
|
+
this._date.isValid || (this._date = luxon.DateTime.fromSQL(timestamp, dateOpts));
|
|
239
|
+
// RFC2822-like format without the required timezone offset (used in tests)
|
|
240
|
+
this._date.isValid || (this._date = luxon.DateTime.fromFormat(timestamp, 'EEE, d MMM yyyy HH:mm:ss', dateOpts));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!this._date || !this._date.isValid) {
|
|
244
|
+
throw new Error('CronDate: unhandled timestamp: ' + JSON.stringify(timestamp));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (tz && tz !== this._date.zoneName) {
|
|
248
|
+
this._date = this._date.setZone(tz);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
module.exports = CronDate;
|