@nocobase/plugin-multi-app-share-collection 1.2.13-alpha → 1.3.0-alpha.20240710084543
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/package.json +2 -2
- package/dist/client/MultiAppShareCollectionProvider.d.ts +0 -10
- package/dist/client/TableTransfer.d.ts +0 -11
- package/dist/client/index.d.ts +0 -13
- package/dist/client/index.js +0 -27
- package/dist/client/utils.d.ts +0 -12
- package/dist/externalVersion.js +0 -21
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -48
- package/dist/locale/en-US.json +0 -12
- package/dist/locale/es-ES.json +0 -12
- package/dist/locale/ko_KR.json +0 -12
- package/dist/locale/pt-BR.json +0 -12
- package/dist/locale/zh-CN.json +0 -12
- package/dist/server/collections/applications.d.ts +0 -14
- package/dist/server/collections/applications.js +0 -47
- package/dist/server/collections/collections.d.ts +0 -14
- package/dist/server/collections/collections.js +0 -47
- package/dist/server/index.d.ts +0 -9
- package/dist/server/index.js +0 -42
- package/dist/server/migrations/20230319111111-update-apps-collections.d.ts +0 -13
- package/dist/server/migrations/20230319111111-update-apps-collections.js +0 -93
- package/dist/server/plugin.d.ts +0 -16
- package/dist/server/plugin.js +0 -276
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "多应用数据表共享",
|
|
5
5
|
"description": "",
|
|
6
6
|
"description.zh-CN": "",
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.3.0-alpha.20240710084543",
|
|
8
8
|
"main": "./dist/server/index.js",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@formily/react": "2.x",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@nocobase/test": "1.x",
|
|
24
24
|
"@nocobase/utils": "1.x"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4",
|
|
27
27
|
"keywords": [
|
|
28
28
|
"System management"
|
|
29
29
|
]
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
export declare const MultiAppShareCollectionProvider: (props: any) => React.JSX.Element;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
export declare const TableTransfer: React.ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
11
|
-
export default TableTransfer;
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from '@nocobase/client';
|
|
10
|
-
export declare class PluginMultiAppShareCollectionClient extends Plugin {
|
|
11
|
-
load(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export default PluginMultiAppShareCollectionClient;
|
package/dist/client/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
(function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("@nocobase/plugin-multi-app-manager/client"),require("antd"),require("@nocobase/utils/client"),require("react"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","@nocobase/plugin-multi-app-manager/client","antd","@nocobase/utils/client","react","react-i18next"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o["@nocobase/plugin-multi-app-share-collection"]={},o["@nocobase/client"],o.jsxRuntime,o["@formily/react"],o["@nocobase/plugin-multi-app-manager"],o.antd,o["@nocobase/utils"],o.react,o["react-i18next"]))})(this,function(o,t,e,M,y,r,C,d,S){"use strict";var R=Object.defineProperty,$=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var _=(o,t,e)=>t in o?R(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,k=(o,t)=>{for(var e in t||(t={}))te.call(t,e)&&_(o,e,t[e]);if(O)for(var e of O(t))oe.call(t,e)&&_(o,e,t[e]);return o},q=(o,t)=>$(o,ee(t));var G=(o,t,e)=>new Promise((M,y)=>{var r=S=>{try{d(e.next(S))}catch(v){y(v)}},C=S=>{try{d(e.throw(S))}catch(v){y(v)}},d=S=>S.done?M(S.value):Promise.resolve(S.value).then(r,C);d((e=e.apply(o,t)).next())});const v=["users","roles","applications"],B=({removed:n=[]})=>{const{collections:a}=t.useCollectionManager_deprecated(),s=d.useCallback(m=>C.CollectionsGraph.connectedNodes({collections:a,nodes:[m],excludes:v}).filter(c=>n.includes(c)),[n]),i=d.useCallback(m=>C.CollectionsGraph.connectedNodes({collections:a,nodes:[m],excludes:v,direction:"reverse"}).filter(c=>!n.includes(c)),[n]);return{findAddable:s,findRemovable:i}},E=()=>{var l,b;const n=t.useRecord(),[a,s]=d.useState([]),i=t.useRequest({url:`applications/${n.name}/collectionBlacklist:list`,params:{paginate:!1,params:{fields:["name"]}}},{onSuccess(h){var w;s((w=h.data)==null?void 0:w.map(f=>f.name))}}),m=t.useRequest({url:"collections",params:{fields:["name","title","hidden","category.name","category.color","category.sort"],sort:"sort",paginate:!1}}),c=t.useRequest({url:"collectionCategories",params:{sort:"sort",paginate:!1}});return{loading:i.loading||m.loading||c.loading,collections:(((l=m.data)==null?void 0:l.data)||[]).filter(h=>!h.hidden&&!v.includes(h.name)),removed:a,setSelected:s,categories:(((b=c.data)==null?void 0:b.data)||[]).map(h=>({label:h.name,value:h.name}))}},F=(n,a)=>{const s=Array.isArray(a)?a:[a];for(const i of s)if(n.toLowerCase().includes(i))return!0;return!1},W=({collections:n,removed:a})=>{const[s,i]=d.useState({name:"",category:[]}),m=d.useMemo(()=>n.filter(l=>{const{name:b,title:h,category:w=[]}=l,f=[a.includes(l.name)];return s.name&&f.push(F(b,s.name)||F(h,s.name)),s.category.length>0&&f.push(w.some(T=>F(T.name,s.category))),!f.includes(!1)}),[n,a,s]),c=d.useMemo(()=>C.lodash.debounce(l=>{i(q(k({},s),{name:l}))},300),[]);return{dataSource:m,setNameFilter:c,setCategoryFilter:l=>{i(q(k({},s),{category:l}))}}},U=({collections:n,removed:a})=>{const[s,i]=d.useState({name:"",category:[]}),m=n.filter(l=>{const{name:b,title:h,category:w=[]}=l,f=[!a.includes(l.name)];return s.name&&f.push(F(b,s.name)||F(h,s.name)),s.category.length>0&&f.push(w.some(T=>F(T.name,s.category))),!f.includes(!1)}),c=d.useMemo(()=>C.lodash.debounce(l=>{i(q(k({},s),{name:l}))},300),[]);return{dataSource:m,setNameFilter:c,setCategoryFilter:l=>{i(q(k({},s),{category:l}))}}},V=M.connect(n=>{const{onChange:a}=n,{loading:s,collections:i,categories:m,removed:c,setSelected:l}=E(),[b,h]=d.useState([]),[w,f]=d.useState([]),{findAddable:T,findRemovable:Y}=B({removed:c}),K=U({collections:i,removed:c}),j=W({collections:i,removed:c}),{t:g}=S.useTranslation("multi-app-share-collection"),{modal:L}=r.App.useApp(),{token:z}=t.useToken(),I=d.useMemo(()=>[{title:g("Collection display name"),dataIndex:"title"},{title:g("Collection name"),dataIndex:"name"},{title:g("Collection category"),dataIndex:"category",render:u=>u.map(p=>e.jsx(r.Tag,{color:p.color,children:p.name},p.name))}],[]);return s?e.jsx(r.Spin,{}):e.jsx("div",{children:e.jsxs(r.Row,{gutter:24,className:t.css`
|
|
11
|
-
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
12
|
-
background: #e6f7ff;
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
}
|
|
15
|
-
`,children:[e.jsxs(r.Col,{span:12,children:[e.jsxs("div",{className:t.css`
|
|
16
|
-
display: flex;
|
|
17
|
-
justify-content: space-between;
|
|
18
|
-
align-items: center;
|
|
19
|
-
width: 100%;
|
|
20
|
-
margin-bottom: 8px;
|
|
21
|
-
`,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:g("Unshared collections")}),e.jsxs(r.Input.Group,{compact:!0,style:{width:360},children:[e.jsx(r.Select,{popupMatchSelectWidth:!1,onChange:u=>{j.setCategoryFilter(u)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:g("All categories"),options:m,allowClear:!0}),e.jsx(r.Input,{onChange:u=>j.setNameFilter(u.target.value),style:{width:"65%"},placeholder:g("Enter name or title..."),allowClear:!0})]})]}),e.jsx(r.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:b,onChange(u){const p=c.filter(x=>!u.includes(x));l(p),a(p),h([])}},pagination:!1,size:"small",columns:I,dataSource:j.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:u,disabled:p})=>({onClick:()=>{if(p)return;const x=T(u),A=()=>{const N=c.filter(Z=>!x.includes(Z));l(N),a(N)};if(x.length===1)return A();L.confirm({title:g("Are you sure to add the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(r.Table,{size:"small",columns:I,dataSource:i.filter(N=>x.includes(N.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){A()}})}})})]}),e.jsxs(r.Col,{span:12,children:[e.jsxs("div",{className:t.css`
|
|
22
|
-
display: flex;
|
|
23
|
-
justify-content: space-between;
|
|
24
|
-
align-items: center;
|
|
25
|
-
width: 100%;
|
|
26
|
-
margin-bottom: 8px;
|
|
27
|
-
`,children:[e.jsx("strong",{style:{fontSize:z.fontSizeLG,color:z.colorText},children:g("Shared collections")}),e.jsxs(r.Input.Group,{compact:!0,style:{width:360},children:[e.jsx(r.Select,{popupMatchSelectWidth:!1,onChange:u=>{K.setCategoryFilter(u)},mode:"multiple",style:{width:"35%"},size:"middle",placeholder:g("All categories"),options:m,allowClear:!0}),e.jsx(r.Input,{onChange:u=>K.setNameFilter(u.target.value),style:{width:"65%"},placeholder:g("Enter name or title..."),allowClear:!0})]})]}),e.jsx(r.Table,{bordered:!0,rowKey:"name",rowSelection:{type:"checkbox",selectedRowKeys:w,onChange(u){const p=C.lodash.uniq(c.concat(u));l(p),a(p),f([])}},pagination:!1,size:"small",columns:I,dataSource:K.dataSource,scroll:{y:"calc(100vh - 260px)"},onRow:({name:u})=>({onClick:()=>{const p=Y(u),x=()=>{c.push(...p);const A=C.lodash.uniq([...c]);l(A),a(A)};if(p.length===1)return x();L.confirm({title:g("Are you sure to remove the following collections?"),width:"60%",content:e.jsx("div",{children:e.jsx(r.Table,{size:"small",columns:I,dataSource:i.filter(A=>p.includes(A.name)),pagination:!1,scroll:{y:"60vh"}})}),onOk(){x()}})}})})]})]})})}),D=n=>`{{t("${n}", { ns: 'multi-app-share-collection' })}}`,H=()=>{const n=M.useForm(),a=t.useActionContext(),s=t.useAPIClient(),i=t.useRecord();return{run(){return G(this,null,function*(){console.log(n.values.names),yield s.request({url:`applications/${i.name}/collectionBlacklist`,data:n.values.names,method:"post"}),a.setVisible(!1),n.reset(),r.message.success("Saved successfully")})}}},J=y.tableActionColumnSchema.properties.update,Q=y.tableActionColumnSchema.properties.delete;delete y.tableActionColumnSchema.properties.update,delete y.tableActionColumnSchema.properties.delete,y.tableActionColumnSchema.properties.collection={type:"void",title:D("Share collections"),"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{width:"95vw"},"x-decorator":"Form",title:D("Share collections"),properties:{names:{type:"array","x-component":V,"x-decorator":"FormItem"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:H}}}}}}}},y.tableActionColumnSchema.properties.update=J,y.tableActionColumnSchema.properties.delete=Q;const X=n=>e.jsx(e.Fragment,{children:n.children});class P extends t.Plugin{load(){return G(this,null,function*(){this.app.use(X)})}}o.PluginMultiAppShareCollectionClient=P,o.default=P,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/client/utils.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export declare const usePluginUtils: () => {
|
|
10
|
-
t: import("react-i18next").TFunction<"multi-app-share-collection", undefined>;
|
|
11
|
-
};
|
|
12
|
-
export declare const i18nText: (text: any) => string;
|
package/dist/externalVersion.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
"@formily/react": "2.3.0",
|
|
12
|
-
"@nocobase/client": "1.2.13-alpha",
|
|
13
|
-
"@nocobase/plugin-multi-app-manager": "1.2.13-alpha",
|
|
14
|
-
"antd": "5.12.8",
|
|
15
|
-
"react": "18.2.0",
|
|
16
|
-
"@nocobase/utils": "1.2.13-alpha",
|
|
17
|
-
"react-i18next": "11.18.6",
|
|
18
|
-
"@nocobase/database": "1.2.13-alpha",
|
|
19
|
-
"@nocobase/server": "1.2.13-alpha",
|
|
20
|
-
"lodash": "4.17.21"
|
|
21
|
-
};
|
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export * from './server';
|
|
10
|
-
export { default } from './server';
|
package/dist/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var src_exports = {};
|
|
39
|
-
__export(src_exports, {
|
|
40
|
-
default: () => import_server.default
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(src_exports);
|
|
43
|
-
__reExport(src_exports, require("./server"), module.exports);
|
|
44
|
-
var import_server = __toESM(require("./server"));
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
...require("./server")
|
|
48
|
-
});
|
package/dist/locale/en-US.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Share collections": "Share collections",
|
|
3
|
-
"Unshared collections": "Unshared collections",
|
|
4
|
-
"Shared collections": "Shared collections",
|
|
5
|
-
"All categories": "All categories",
|
|
6
|
-
"Enter name or title...": "Enter name or title...",
|
|
7
|
-
"Are you sure to add the following collections?": "Are you sure to add the following collections?",
|
|
8
|
-
"Are you sure to remove the following collections?": "Are you sure to remove the following collections?",
|
|
9
|
-
"Collection display name": "Collection display name",
|
|
10
|
-
"Collection name": "Collection name",
|
|
11
|
-
"Collection category": "Collection category"
|
|
12
|
-
}
|
package/dist/locale/es-ES.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Share collections": "Tablas compartidas",
|
|
3
|
-
"Unshared collections": "Tablas no compartidas",
|
|
4
|
-
"Shared collections": "Tablas compartidas",
|
|
5
|
-
"All categories": "Todas las categorías",
|
|
6
|
-
"Enter name or title...": "Introducir nombre o título...",
|
|
7
|
-
"Are you sure to add the following collections?": "¿Está seguro de que desea añadir las siguientes tablas?",
|
|
8
|
-
"Are you sure to remove the following collections?": "¿Está seguro de que desea eliminar las siguientes tablas?",
|
|
9
|
-
"Collection display name": "Mostrar nombre de la tabla",
|
|
10
|
-
"Collection name": "Nombre de la tabla",
|
|
11
|
-
"Collection category": "Categoría de tabla"
|
|
12
|
-
}
|
package/dist/locale/ko_KR.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Share collections": "데이터 테이블 공유",
|
|
3
|
-
"Unshared collections": "공유되지 않은 데이터 테이블",
|
|
4
|
-
"Shared collections": "공유된 데이터 테이블",
|
|
5
|
-
"All categories": "모든 카테고리",
|
|
6
|
-
"Enter name or title...": "이름 또는 제목 입력...",
|
|
7
|
-
"Are you sure to add the following collections?": "다음 데이터 테이블을 추가하시겠습니까?",
|
|
8
|
-
"Are you sure to remove the following collections?": "다음 데이터 테이블을 제거하시겠습니까?",
|
|
9
|
-
"Collection display name": "제목",
|
|
10
|
-
"Collection name": "식별자",
|
|
11
|
-
"Collection category": "카테고리"
|
|
12
|
-
}
|
package/dist/locale/pt-BR.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Share collections": "Compartilhar tabelas",
|
|
3
|
-
"Unshared collections": "Tabelas não compartilhadas",
|
|
4
|
-
"Shared collections": "Tabelas compartilhadas",
|
|
5
|
-
"All categories": "Todas as categorias",
|
|
6
|
-
"Enter name or title...": "Digite o nome ou título...",
|
|
7
|
-
"Are you sure to add the following collections?": "Tem certeza de que deseja adicionar as seguintes tabelas?",
|
|
8
|
-
"Are you sure to remove the following collections?": "Tem certeza de que deseja remover as seguintes tabelas?",
|
|
9
|
-
"Collection display name": "Nome de exibição da tabela",
|
|
10
|
-
"Collection name": "Nome da tabela",
|
|
11
|
-
"Collection category": "Categoria da tabela"
|
|
12
|
-
}
|
package/dist/locale/zh-CN.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Share collections": "共享数据表",
|
|
3
|
-
"Unshared collections": "未共享的数据表",
|
|
4
|
-
"Shared collections": "已共享的数据表",
|
|
5
|
-
"All categories": "所有分类",
|
|
6
|
-
"Enter name or title...": "输入数据表标题或标识",
|
|
7
|
-
"Are you sure to add the following collections?": "确定添加以下数据表?",
|
|
8
|
-
"Are you sure to remove the following collections?": "确定移除以下数据表?",
|
|
9
|
-
"Collection display name": "标题",
|
|
10
|
-
"Collection name": "标识",
|
|
11
|
-
"Collection category": "分类"
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
collectionOptions: import("@nocobase/database").CollectionOptions;
|
|
11
|
-
mergeOptions: import("deepmerge").Options;
|
|
12
|
-
extend: boolean;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var applications_exports = {};
|
|
28
|
-
__export(applications_exports, {
|
|
29
|
-
default: () => applications_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(applications_exports);
|
|
32
|
-
var import_database = require("@nocobase/database");
|
|
33
|
-
var applications_default = (0, import_database.extendCollection)({
|
|
34
|
-
name: "applications",
|
|
35
|
-
fields: [
|
|
36
|
-
{
|
|
37
|
-
type: "belongsToMany",
|
|
38
|
-
name: "collectionBlacklist",
|
|
39
|
-
through: "appCollectionBlacklist",
|
|
40
|
-
target: "collections",
|
|
41
|
-
targetKey: "name",
|
|
42
|
-
otherKey: "collectionName",
|
|
43
|
-
sourceKey: "name",
|
|
44
|
-
foreignKey: "applicationName"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
collectionOptions: import("@nocobase/database").CollectionOptions;
|
|
11
|
-
mergeOptions: import("deepmerge").Options;
|
|
12
|
-
extend: boolean;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var collections_exports = {};
|
|
28
|
-
__export(collections_exports, {
|
|
29
|
-
default: () => collections_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(collections_exports);
|
|
32
|
-
var import_database = require("@nocobase/database");
|
|
33
|
-
var collections_default = (0, import_database.extendCollection)({
|
|
34
|
-
name: "collections",
|
|
35
|
-
fields: [
|
|
36
|
-
{
|
|
37
|
-
type: "belongsToMany",
|
|
38
|
-
name: "collectionBlacklist",
|
|
39
|
-
through: "appCollectionBlacklist",
|
|
40
|
-
target: "applications",
|
|
41
|
-
targetKey: "name",
|
|
42
|
-
otherKey: "applicationName",
|
|
43
|
-
sourceKey: "name",
|
|
44
|
-
foreignKey: "collectionName"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
});
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export { default } from './plugin';
|
package/dist/server/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var server_exports = {};
|
|
38
|
-
__export(server_exports, {
|
|
39
|
-
default: () => import_plugin.default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(server_exports);
|
|
42
|
-
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Migration } from '@nocobase/server';
|
|
10
|
-
export default class extends Migration {
|
|
11
|
-
appVersion: string;
|
|
12
|
-
up(): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var update_apps_collections_exports = {};
|
|
28
|
-
__export(update_apps_collections_exports, {
|
|
29
|
-
default: () => update_apps_collections_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(update_apps_collections_exports);
|
|
32
|
-
var import_server = require("@nocobase/server");
|
|
33
|
-
var import_utils = require("@nocobase/utils");
|
|
34
|
-
class update_apps_collections_default extends import_server.Migration {
|
|
35
|
-
appVersion = "<0.9.3-alpha.1";
|
|
36
|
-
async up() {
|
|
37
|
-
const result = await this.app.version.satisfies("<0.9.3-alpha.1");
|
|
38
|
-
if (!result) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!this.app.db.getCollection("applications"))
|
|
42
|
-
return;
|
|
43
|
-
await this.app.db.getCollection("collections").repository.destroy({
|
|
44
|
-
where: {
|
|
45
|
-
name: "applications"
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const appSyncedCollections = /* @__PURE__ */ new Map();
|
|
49
|
-
const collections = await this.app.db.getCollection("collections").repository.find();
|
|
50
|
-
const collectionsData = collections.map((collection) => collection.toJSON());
|
|
51
|
-
for (const collection of collections) {
|
|
52
|
-
const collectionSyncToApps = collection.get("syncToApps");
|
|
53
|
-
if (collectionSyncToApps) {
|
|
54
|
-
for (const app of collectionSyncToApps) {
|
|
55
|
-
if (!appSyncedCollections.has(app)) {
|
|
56
|
-
appSyncedCollections.set(app, /* @__PURE__ */ new Set());
|
|
57
|
-
}
|
|
58
|
-
appSyncedCollections.get(app).add(collection.name);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const allCollections = collections.map((collection) => collection.name);
|
|
63
|
-
const appCollectionBlacklist = this.app.db.getCollection("appCollectionBlacklist");
|
|
64
|
-
for (const [app, syncedCollections] of appSyncedCollections) {
|
|
65
|
-
const blackListCollections = allCollections.filter(
|
|
66
|
-
(collection) => !syncedCollections.has(collection) && !["users", "roles"].includes(collection)
|
|
67
|
-
);
|
|
68
|
-
const connectedCollections = import_utils.CollectionsGraph.connectedNodes({
|
|
69
|
-
collections: collectionsData,
|
|
70
|
-
nodes: blackListCollections,
|
|
71
|
-
direction: "reverse"
|
|
72
|
-
});
|
|
73
|
-
console.log(
|
|
74
|
-
JSON.stringify(
|
|
75
|
-
{
|
|
76
|
-
app,
|
|
77
|
-
connectedCollections
|
|
78
|
-
},
|
|
79
|
-
null,
|
|
80
|
-
2
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
await appCollectionBlacklist.model.bulkCreate(
|
|
84
|
-
connectedCollections.map((collection) => {
|
|
85
|
-
return {
|
|
86
|
-
applicationName: app,
|
|
87
|
-
collectionName: collection
|
|
88
|
-
};
|
|
89
|
-
})
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
package/dist/server/plugin.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from '@nocobase/server';
|
|
10
|
-
export declare class MultiAppShareCollectionPlugin extends Plugin {
|
|
11
|
-
afterAdd(): void;
|
|
12
|
-
beforeEnable(): Promise<void>;
|
|
13
|
-
beforeLoad(): Promise<void>;
|
|
14
|
-
load(): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
export default MultiAppShareCollectionPlugin;
|
package/dist/server/plugin.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var plugin_exports = {};
|
|
38
|
-
__export(plugin_exports, {
|
|
39
|
-
MultiAppShareCollectionPlugin: () => MultiAppShareCollectionPlugin,
|
|
40
|
-
default: () => plugin_default
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(plugin_exports);
|
|
43
|
-
var import_plugin_multi_app_manager = __toESM(require("@nocobase/plugin-multi-app-manager"));
|
|
44
|
-
var import_server = require("@nocobase/server");
|
|
45
|
-
var import_lodash = __toESM(require("lodash"));
|
|
46
|
-
const subAppFilteredPlugins = ["multi-app-share-collection", "multi-app-manager"];
|
|
47
|
-
const unSyncPlugins = ["localization"];
|
|
48
|
-
class SubAppPlugin extends import_server.Plugin {
|
|
49
|
-
beforeLoad() {
|
|
50
|
-
const mainApp = this.options.mainApp;
|
|
51
|
-
const subApp = this.app;
|
|
52
|
-
const sharedCollections = [];
|
|
53
|
-
for (const collection of mainApp.db.collections.values()) {
|
|
54
|
-
if (collection.options.shared) {
|
|
55
|
-
sharedCollections.push(collection.name);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
subApp.on("beforeLoadPlugin", (plugin) => {
|
|
59
|
-
if (plugin.name === "data-source-main") {
|
|
60
|
-
plugin.setLoadFilter({
|
|
61
|
-
"name.$ne": "roles"
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
subApp.db.on("beforeDefineCollection", (options) => {
|
|
66
|
-
const name = options.name;
|
|
67
|
-
if (sharedCollections.includes(name)) {
|
|
68
|
-
options.schema = mainApp.db.options.schema || "public";
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
this.app.resourcer.use(async (ctx, next) => {
|
|
72
|
-
const { actionName, resourceName } = ctx.action;
|
|
73
|
-
if (actionName === "list" && resourceName === "applicationPlugins") {
|
|
74
|
-
ctx.action.mergeParams({
|
|
75
|
-
filter: {
|
|
76
|
-
"name.$notIn": subAppFilteredPlugins
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
if (actionName === "list" && resourceName === "collections") {
|
|
81
|
-
const appCollectionBlacklistCollection = mainApp.db.getCollection("appCollectionBlacklist");
|
|
82
|
-
const blackList = await appCollectionBlacklistCollection.model.findAll({
|
|
83
|
-
where: {
|
|
84
|
-
applicationName: subApp.name
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
if (blackList.length > 0) {
|
|
88
|
-
ctx.action.mergeParams({
|
|
89
|
-
filter: {
|
|
90
|
-
"name.$notIn": blackList.map((item) => item.get("collectionName"))
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
await next();
|
|
96
|
-
});
|
|
97
|
-
subApp.on("beforeInstall", async () => {
|
|
98
|
-
await subApp.db.sync();
|
|
99
|
-
const subAppPluginsCollection = subApp.db.getCollection("applicationPlugins");
|
|
100
|
-
const mainAppPluginsCollection = mainApp.db.getCollection("applicationPlugins");
|
|
101
|
-
await subApp.db.sequelize.query(`TRUNCATE ${subAppPluginsCollection.quotedTableName()}`);
|
|
102
|
-
const columnsInfo = await subApp.db.sequelize.getQueryInterface().describeTable(subAppPluginsCollection.getTableNameWithSchema());
|
|
103
|
-
const columns = Object.keys(columnsInfo).sort();
|
|
104
|
-
const columnsInSql = columns.map((column) => `"${column}"`).join(", ");
|
|
105
|
-
await subApp.db.sequelize.query(`
|
|
106
|
-
INSERT INTO ${subAppPluginsCollection.quotedTableName()} (${columnsInSql})
|
|
107
|
-
SELECT ${columnsInSql}
|
|
108
|
-
FROM ${mainAppPluginsCollection.quotedTableName()}
|
|
109
|
-
WHERE "name" not in ('multi-app-manager', 'multi-app-share-collection');
|
|
110
|
-
`);
|
|
111
|
-
const sequenceNameSql = `SELECT pg_get_serial_sequence('"${subAppPluginsCollection.collectionSchema()}"."${subAppPluginsCollection.model.tableName}"', 'id')`;
|
|
112
|
-
const sequenceName = await subApp.db.sequelize.query(sequenceNameSql, { type: "SELECT" });
|
|
113
|
-
await subApp.db.sequelize.query(`
|
|
114
|
-
SELECT setval('${sequenceName[0]["pg_get_serial_sequence"]}', (SELECT max("id") FROM ${subAppPluginsCollection.quotedTableName()}));
|
|
115
|
-
`);
|
|
116
|
-
await subApp.reload();
|
|
117
|
-
console.log(`sync plugins from ${mainApp.name} app to sub app ${subApp.name}`);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
class MultiAppShareCollectionPlugin extends import_server.Plugin {
|
|
122
|
-
afterAdd() {
|
|
123
|
-
}
|
|
124
|
-
async beforeEnable() {
|
|
125
|
-
if (!this.db.inDialect("postgres")) {
|
|
126
|
-
throw new Error("multi-app-share-collection plugin only support postgres");
|
|
127
|
-
}
|
|
128
|
-
const plugin = this.pm.get("multi-app-manager");
|
|
129
|
-
if (!plugin.enabled) {
|
|
130
|
-
throw new Error(`${this.name} plugin need multi-app-manager plugin enabled`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async beforeLoad() {
|
|
134
|
-
if (!this.db.inDialect("postgres")) {
|
|
135
|
-
throw new Error("multi-app-share-collection plugin only support postgres");
|
|
136
|
-
}
|
|
137
|
-
const traverseSubApps = async (callback, options) => {
|
|
138
|
-
if (import_lodash.default.get(options, "loadFromDatabase")) {
|
|
139
|
-
for (const application of await this.app.db.getCollection("applications").repository.find()) {
|
|
140
|
-
const appName = application.get("name");
|
|
141
|
-
const subApp = await import_server.AppSupervisor.getInstance().getApp(appName);
|
|
142
|
-
await callback(subApp);
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const subApps = [...import_server.AppSupervisor.getInstance().subApps()];
|
|
147
|
-
for (const subApp of subApps) {
|
|
148
|
-
await callback(subApp);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const mainApp = this.app;
|
|
152
|
-
function addPluginToSubApp(app) {
|
|
153
|
-
if (app.name !== "main") {
|
|
154
|
-
app.plugin(SubAppPlugin, { name: "sub-app", mainApp });
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (import_server.AppSupervisor.getInstance().listeners("afterAppAdded").filter((f) => f.name == addPluginToSubApp.name).length == 0) {
|
|
158
|
-
import_server.AppSupervisor.getInstance().on("afterAppAdded", addPluginToSubApp);
|
|
159
|
-
}
|
|
160
|
-
this.app.db.on("users.afterCreateWithAssociations", async (model, options) => {
|
|
161
|
-
await traverseSubApps(async (subApp) => {
|
|
162
|
-
const { transaction } = options;
|
|
163
|
-
const repository = subApp.db.getRepository("roles");
|
|
164
|
-
const subAppUserModel = await subApp.db.getCollection("users").repository.findOne({
|
|
165
|
-
filter: {
|
|
166
|
-
id: model.get("id")
|
|
167
|
-
},
|
|
168
|
-
transaction
|
|
169
|
-
});
|
|
170
|
-
const defaultRole = await repository.findOne({
|
|
171
|
-
filter: {
|
|
172
|
-
default: true
|
|
173
|
-
},
|
|
174
|
-
transaction
|
|
175
|
-
});
|
|
176
|
-
if (defaultRole && await subAppUserModel.countRoles({ transaction }) == 0) {
|
|
177
|
-
await subAppUserModel.addRoles(defaultRole, { transaction });
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
this.app.on("__restarted", () => {
|
|
182
|
-
traverseSubApps((subApp) => {
|
|
183
|
-
subApp.runCommand("restart");
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
this.app.on("afterEnablePlugin", (pluginNames) => {
|
|
187
|
-
traverseSubApps((subApp) => {
|
|
188
|
-
for (const pluginName of import_lodash.default.castArray(pluginNames)) {
|
|
189
|
-
if (subAppFilteredPlugins.includes(pluginName))
|
|
190
|
-
return;
|
|
191
|
-
subApp.runAsCLI(["pm", "enable", pluginName], { from: "user" });
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
this.app.on("afterDisablePlugin", (pluginNames) => {
|
|
196
|
-
traverseSubApps((subApp) => {
|
|
197
|
-
for (const pluginName of import_lodash.default.castArray(pluginNames)) {
|
|
198
|
-
if (subAppFilteredPlugins.includes(pluginName))
|
|
199
|
-
return;
|
|
200
|
-
subApp.runAsCLI(["pm", "disable", pluginName], { from: "user" });
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
this.app.db.on(`afterRemoveCollection`, (collection) => {
|
|
205
|
-
const subApps = [...import_server.AppSupervisor.getInstance().subApps()];
|
|
206
|
-
for (const subApp of subApps) {
|
|
207
|
-
if (subApp.db.hasCollection(collection.name)) {
|
|
208
|
-
subApp.db.removeCollection(collection.name);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
async load() {
|
|
214
|
-
const multiAppManager = this.app.getPlugin("multi-app-manager");
|
|
215
|
-
if (!multiAppManager) {
|
|
216
|
-
this.app.log.warn("multi-app-share-collection plugin need multi-app-manager plugin enabled");
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
this.app.resourcer.registerActionHandlers({
|
|
220
|
-
"applications:shareCollections": async (ctx, next) => {
|
|
221
|
-
const { filterByTk, values } = ctx.action.params;
|
|
222
|
-
ctx.body = {
|
|
223
|
-
filterByTk,
|
|
224
|
-
values
|
|
225
|
-
};
|
|
226
|
-
await next();
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
multiAppManager.setAppOptionsFactory((appName, mainApp) => {
|
|
230
|
-
const mainAppDbConfig = import_plugin_multi_app_manager.default.getDatabaseConfig(mainApp);
|
|
231
|
-
const databaseOptions = {
|
|
232
|
-
...mainAppDbConfig,
|
|
233
|
-
schema: appName
|
|
234
|
-
};
|
|
235
|
-
const plugins = [...mainApp.pm.getPlugins().values()].filter(
|
|
236
|
-
(plugin) => {
|
|
237
|
-
var _a, _b;
|
|
238
|
-
return ((_a = plugin == null ? void 0 : plugin.options) == null ? void 0 : _a.packageName) !== "@nocobase/plugin-multi-app-manager" && ((_b = plugin == null ? void 0 : plugin.options) == null ? void 0 : _b.packageName) !== "@nocobase/plugin-multi-app-share-collection";
|
|
239
|
-
}
|
|
240
|
-
).map((plugin) => plugin.name);
|
|
241
|
-
return {
|
|
242
|
-
database: import_lodash.default.merge(databaseOptions, {
|
|
243
|
-
dialectOptions: {
|
|
244
|
-
application_name: `nocobase.${appName}`
|
|
245
|
-
}
|
|
246
|
-
}),
|
|
247
|
-
plugins: plugins.includes("nocobase") ? ["nocobase"] : plugins,
|
|
248
|
-
resourcer: {
|
|
249
|
-
prefix: process.env.API_BASE_PATH
|
|
250
|
-
},
|
|
251
|
-
logger: {
|
|
252
|
-
...mainApp.options.logger,
|
|
253
|
-
requestWhitelist: [
|
|
254
|
-
"action",
|
|
255
|
-
"header.x-role",
|
|
256
|
-
"header.x-hostname",
|
|
257
|
-
"header.x-timezone",
|
|
258
|
-
"header.x-locale",
|
|
259
|
-
"referer",
|
|
260
|
-
"header.x-app"
|
|
261
|
-
]
|
|
262
|
-
}
|
|
263
|
-
// pmSock: resolve(process.cwd(), 'storage', `${appName}.sock`),
|
|
264
|
-
};
|
|
265
|
-
});
|
|
266
|
-
multiAppManager.setAppDbCreator(async (app) => {
|
|
267
|
-
const schema = app.options.database.schema;
|
|
268
|
-
await this.app.db.sequelize.query(`CREATE SCHEMA IF NOT EXISTS ${schema}`);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
var plugin_default = MultiAppShareCollectionPlugin;
|
|
273
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
274
|
-
0 && (module.exports = {
|
|
275
|
-
MultiAppShareCollectionPlugin
|
|
276
|
-
});
|