@nocobase/plugin-multi-app-share-collection 0.11.1-alpha.5 → 0.12.0-alpha.2
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/client.d.ts +2 -3
- package/client.js +1 -1
- package/dist/client/index.js +510 -0
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/es-ES.js +16 -0
- package/dist/locale/pt-BR.js +16 -0
- package/dist/locale/zh-CN.js +16 -0
- package/dist/server/collections/applications.js +21 -0
- package/dist/server/collections/collections.js +21 -0
- package/dist/server/index.js +11 -0
- package/{src/server/migrations/20230319111111-update-apps-collections.ts → dist/server/migrations/20230319111111-update-apps-collections.js} +26 -33
- package/dist/server/plugin.js +278 -0
- package/package.json +16 -25
- package/server.d.ts +2 -3
- package/server.js +1 -1
- package/lib/client/MultiAppShareCollectionProvider.js +0 -122
- package/lib/client/TableTransfer.js +0 -487
- package/lib/client/index.js +0 -27
- package/lib/client/utils.js +0 -25
- package/lib/index.js +0 -13
- package/lib/locale/es-ES.js +0 -19
- package/lib/locale/pt-BR.js +0 -19
- package/lib/locale/zh-CN.js +0 -19
- package/lib/server/collections/applications.js +0 -27
- package/lib/server/collections/collections.js +0 -27
- package/lib/server/index.js +0 -13
- package/lib/server/migrations/20230319111111-update-apps-collections.js +0 -110
- package/lib/server/plugin.js +0 -408
- package/src/client/MultiAppShareCollectionProvider.tsx +0 -86
- package/src/client/TableTransfer.tsx +0 -398
- package/src/client/index.tsx +0 -10
- package/src/client/utils.tsx +0 -11
- package/src/index.ts +0 -1
- package/src/locale/es-ES.ts +0 -12
- package/src/locale/pt-BR.ts +0 -12
- package/src/locale/zh-CN.ts +0 -12
- package/src/server/__tests__/collection-sync.test.ts +0 -514
- package/src/server/__tests__/index.ts +0 -25
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/applications.ts +0 -17
- package/src/server/collections/collections.ts +0 -17
- package/src/server/index.ts +0 -1
- package/src/server/plugin.ts +0 -332
- /package/{lib → dist}/client/MultiAppShareCollectionProvider.d.ts +0 -0
- /package/{lib → dist}/client/TableTransfer.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/utils.d.ts +0 -0
- /package/{lib → dist}/locale/es-ES.d.ts +0 -0
- /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/collections/applications.d.ts +0 -0
- /package/{lib → dist}/server/collections/collections.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230319111111-update-apps-collections.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
|
@@ -1,73 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
import { CollectionsGraph } from '@nocobase/utils';
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const result = await this.app.version.satisfies('<0.9.3-alpha.1');
|
|
3
|
+
var server = require('@nocobase/server');
|
|
4
|
+
var utils = require('@nocobase/utils');
|
|
7
5
|
|
|
6
|
+
class update_apps_collections_default extends server.Migration {
|
|
7
|
+
async up() {
|
|
8
|
+
const result = await this.app.version.satisfies("<0.9.3-alpha.1");
|
|
8
9
|
if (!result) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
await this.app.db.getCollection('collections').repository.destroy({
|
|
12
|
+
if (!this.app.db.getCollection("applications"))
|
|
13
|
+
return;
|
|
14
|
+
await this.app.db.getCollection("collections").repository.destroy({
|
|
15
15
|
where: {
|
|
16
|
-
name:
|
|
17
|
-
}
|
|
16
|
+
name: "applications"
|
|
17
|
+
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const collections = await this.app.db.getCollection('collections').repository.find();
|
|
19
|
+
const appSyncedCollections = /* @__PURE__ */ new Map();
|
|
20
|
+
const collections = await this.app.db.getCollection("collections").repository.find();
|
|
23
21
|
const collectionsData = collections.map((collection) => collection.toJSON());
|
|
24
|
-
|
|
25
22
|
for (const collection of collections) {
|
|
26
|
-
const collectionSyncToApps = collection.get(
|
|
23
|
+
const collectionSyncToApps = collection.get("syncToApps");
|
|
27
24
|
if (collectionSyncToApps) {
|
|
28
25
|
for (const app of collectionSyncToApps) {
|
|
29
26
|
if (!appSyncedCollections.has(app)) {
|
|
30
|
-
appSyncedCollections.set(app, new Set());
|
|
27
|
+
appSyncedCollections.set(app, /* @__PURE__ */ new Set());
|
|
31
28
|
}
|
|
32
29
|
appSyncedCollections.get(app).add(collection.name);
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
const allCollections = collections.map((collection) => collection.name);
|
|
38
|
-
|
|
39
|
-
const appCollectionBlacklist = this.app.db.getCollection('appCollectionBlacklist');
|
|
40
|
-
|
|
34
|
+
const appCollectionBlacklist = this.app.db.getCollection("appCollectionBlacklist");
|
|
41
35
|
for (const [app, syncedCollections] of appSyncedCollections) {
|
|
42
36
|
const blackListCollections = allCollections.filter(
|
|
43
|
-
(collection) => !syncedCollections.has(collection) && ![
|
|
37
|
+
(collection) => !syncedCollections.has(collection) && !["users", "roles"].includes(collection)
|
|
44
38
|
);
|
|
45
|
-
|
|
46
|
-
const connectedCollections = CollectionsGraph.connectedNodes({
|
|
39
|
+
const connectedCollections = utils.CollectionsGraph.connectedNodes({
|
|
47
40
|
collections: collectionsData,
|
|
48
41
|
nodes: blackListCollections,
|
|
49
|
-
direction:
|
|
42
|
+
direction: "reverse"
|
|
50
43
|
});
|
|
51
|
-
|
|
52
44
|
console.log(
|
|
53
45
|
JSON.stringify(
|
|
54
46
|
{
|
|
55
47
|
app,
|
|
56
|
-
connectedCollections
|
|
48
|
+
connectedCollections
|
|
57
49
|
},
|
|
58
50
|
null,
|
|
59
|
-
2
|
|
60
|
-
)
|
|
51
|
+
2
|
|
52
|
+
)
|
|
61
53
|
);
|
|
62
|
-
|
|
63
54
|
await appCollectionBlacklist.model.bulkCreate(
|
|
64
55
|
connectedCollections.map((collection) => {
|
|
65
56
|
return {
|
|
66
57
|
applicationName: app,
|
|
67
|
-
collectionName: collection
|
|
58
|
+
collectionName: collection
|
|
68
59
|
};
|
|
69
|
-
})
|
|
60
|
+
})
|
|
70
61
|
);
|
|
71
62
|
}
|
|
72
63
|
}
|
|
73
64
|
}
|
|
65
|
+
|
|
66
|
+
module.exports = update_apps_collections_default;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var PluginMultiAppManager = require('@nocobase/plugin-multi-app-manager');
|
|
6
|
+
var server = require('@nocobase/server');
|
|
7
|
+
var lodash = require('lodash');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var PluginMultiAppManager__default = /*#__PURE__*/_interopDefault(PluginMultiAppManager);
|
|
13
|
+
var lodash__default = /*#__PURE__*/_interopDefault(lodash);
|
|
14
|
+
|
|
15
|
+
const subAppFilteredPlugins = ["multi-app-share-collection", "multi-app-manager"];
|
|
16
|
+
class SubAppPlugin extends server.Plugin {
|
|
17
|
+
beforeLoad() {
|
|
18
|
+
const mainApp = this.options.mainApp;
|
|
19
|
+
const subApp = this.app;
|
|
20
|
+
const sharedCollectionGroups = [
|
|
21
|
+
"audit-logs",
|
|
22
|
+
"workflow",
|
|
23
|
+
"charts",
|
|
24
|
+
"collection-manager",
|
|
25
|
+
"file-manager",
|
|
26
|
+
"graph-collection-manager",
|
|
27
|
+
"map",
|
|
28
|
+
"sequence-field",
|
|
29
|
+
"snapshot-field",
|
|
30
|
+
"verification",
|
|
31
|
+
"localization-management"
|
|
32
|
+
];
|
|
33
|
+
const collectionGroups = mainApp.db.collectionGroupManager.getGroups();
|
|
34
|
+
const sharedCollectionGroupsCollections = [];
|
|
35
|
+
for (const group of collectionGroups) {
|
|
36
|
+
if (sharedCollectionGroups.includes(group.namespace)) {
|
|
37
|
+
sharedCollectionGroupsCollections.push(...group.collections);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const sharedCollections = [...sharedCollectionGroupsCollections.flat(), "users", "users_jobs"];
|
|
41
|
+
subApp.db.on("beforeDefineCollection", (options) => {
|
|
42
|
+
const name = options.name;
|
|
43
|
+
if (sharedCollections.includes(name)) {
|
|
44
|
+
options.schema = mainApp.db.options.schema || "public";
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
subApp.db.on("beforeUpdateCollection", (collection, newOptions) => {
|
|
48
|
+
if (collection.name === "roles") {
|
|
49
|
+
newOptions.schema = subApp.db.options.schema;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.app.resourcer.use(async (ctx, next) => {
|
|
53
|
+
const { actionName, resourceName } = ctx.action;
|
|
54
|
+
if (actionName === "list" && resourceName === "applicationPlugins") {
|
|
55
|
+
ctx.action.mergeParams({
|
|
56
|
+
filter: {
|
|
57
|
+
"name.$notIn": subAppFilteredPlugins
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (actionName === "list" && resourceName === "collections") {
|
|
62
|
+
const appCollectionBlacklistCollection = mainApp.db.getCollection("appCollectionBlacklist");
|
|
63
|
+
const blackList = await appCollectionBlacklistCollection.model.findAll({
|
|
64
|
+
where: {
|
|
65
|
+
applicationName: subApp.name
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (blackList.length > 0) {
|
|
69
|
+
ctx.action.mergeParams({
|
|
70
|
+
filter: {
|
|
71
|
+
"name.$notIn": blackList.map((item) => item.get("collectionName"))
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
await next();
|
|
77
|
+
});
|
|
78
|
+
subApp.on("beforeInstall", async () => {
|
|
79
|
+
const subAppPluginsCollection = subApp.db.getCollection("applicationPlugins");
|
|
80
|
+
const mainAppPluginsCollection = mainApp.db.getCollection("applicationPlugins");
|
|
81
|
+
await subApp.db.sequelize.query(`TRUNCATE ${subAppPluginsCollection.quotedTableName()}`);
|
|
82
|
+
await subApp.db.sequelize.query(`
|
|
83
|
+
INSERT INTO ${subAppPluginsCollection.quotedTableName()}
|
|
84
|
+
SELECT *
|
|
85
|
+
FROM ${mainAppPluginsCollection.quotedTableName()}
|
|
86
|
+
WHERE "name" not in ('multi-app-manager', 'multi-app-share-collection');
|
|
87
|
+
`);
|
|
88
|
+
const sequenceNameSql = `SELECT pg_get_serial_sequence('"${subAppPluginsCollection.collectionSchema()}"."${subAppPluginsCollection.model.tableName}"', 'id')`;
|
|
89
|
+
const sequenceName = await subApp.db.sequelize.query(sequenceNameSql, { type: "SELECT" });
|
|
90
|
+
await subApp.db.sequelize.query(`
|
|
91
|
+
SELECT setval('${sequenceName[0]["pg_get_serial_sequence"]}', (SELECT max("id") FROM ${subAppPluginsCollection.quotedTableName()}));
|
|
92
|
+
`);
|
|
93
|
+
console.log(`sync plugins from ${mainApp.name} app to sub app ${subApp.name}`);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class MultiAppShareCollectionPlugin extends server.Plugin {
|
|
98
|
+
afterAdd() {
|
|
99
|
+
}
|
|
100
|
+
async beforeEnable() {
|
|
101
|
+
if (!this.db.inDialect("postgres")) {
|
|
102
|
+
throw new Error("multi-app-share-collection plugin only support postgres");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async beforeLoad() {
|
|
106
|
+
if (!this.db.inDialect("postgres")) {
|
|
107
|
+
throw new Error("multi-app-share-collection plugin only support postgres");
|
|
108
|
+
}
|
|
109
|
+
const traverseSubApps = async (callback, options) => {
|
|
110
|
+
if (lodash__default.default.get(options, "loadFromDatabase")) {
|
|
111
|
+
for (const application of await this.app.db.getCollection("applications").repository.find()) {
|
|
112
|
+
const appName = application.get("name");
|
|
113
|
+
const subApp = await this.app.appManager.getApplication(appName);
|
|
114
|
+
await callback(subApp);
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const subApps = [...this.app.appManager.applications.values()];
|
|
119
|
+
for (const subApp of subApps) {
|
|
120
|
+
await callback(subApp);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
this.app.on("afterSubAppAdded", (subApp) => {
|
|
124
|
+
subApp.plugin(SubAppPlugin, { name: "sub-app", mainApp: this.app });
|
|
125
|
+
});
|
|
126
|
+
this.app.db.on("users.afterCreateWithAssociations", async (model, options) => {
|
|
127
|
+
await traverseSubApps(async (subApp) => {
|
|
128
|
+
const { transaction } = options;
|
|
129
|
+
const repository = subApp.db.getRepository("roles");
|
|
130
|
+
const subAppModel = await subApp.db.getCollection("users").repository.findOne({
|
|
131
|
+
filter: {
|
|
132
|
+
id: model.get("id")
|
|
133
|
+
},
|
|
134
|
+
transaction
|
|
135
|
+
});
|
|
136
|
+
const defaultRole = await repository.findOne({
|
|
137
|
+
filter: {
|
|
138
|
+
default: true
|
|
139
|
+
},
|
|
140
|
+
transaction
|
|
141
|
+
});
|
|
142
|
+
if (defaultRole && await subAppModel.countRoles({ transaction }) == 0) {
|
|
143
|
+
await subAppModel.addRoles(defaultRole, { transaction });
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
this.app.db.on("collection:loaded", async ({ transaction, collection }) => {
|
|
148
|
+
await traverseSubApps(async (subApp) => {
|
|
149
|
+
const name = collection.name;
|
|
150
|
+
const collectionRecord = await subApp.db.getRepository("collections").findOne({
|
|
151
|
+
filter: {
|
|
152
|
+
name
|
|
153
|
+
},
|
|
154
|
+
transaction
|
|
155
|
+
});
|
|
156
|
+
await collectionRecord.load({ transaction });
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
this.app.db.on("field:loaded", async ({ transaction, fieldKey }) => {
|
|
160
|
+
await traverseSubApps(async (subApp) => {
|
|
161
|
+
const fieldRecord = await subApp.db.getRepository("fields").findOne({
|
|
162
|
+
filterByTk: fieldKey,
|
|
163
|
+
transaction
|
|
164
|
+
});
|
|
165
|
+
if (fieldRecord) {
|
|
166
|
+
await fieldRecord.load({ transaction });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
this.app.on("afterEnablePlugin", async (pluginName) => {
|
|
171
|
+
await traverseSubApps(
|
|
172
|
+
async (subApp) => {
|
|
173
|
+
if (subAppFilteredPlugins.includes(pluginName))
|
|
174
|
+
return;
|
|
175
|
+
await subApp.pm.enable(pluginName);
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
loadFromDatabase: true
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
this.app.on("afterDisablePlugin", async (pluginName) => {
|
|
183
|
+
await traverseSubApps(
|
|
184
|
+
async (subApp) => {
|
|
185
|
+
if (subAppFilteredPlugins.includes(pluginName))
|
|
186
|
+
return;
|
|
187
|
+
await subApp.pm.disable(pluginName);
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
loadFromDatabase: true
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
this.app.db.on("field.afterRemove", (removedField) => {
|
|
195
|
+
const subApps = [...this.app.appManager.applications.values()];
|
|
196
|
+
for (const subApp of subApps) {
|
|
197
|
+
const collectionName = removedField.collection.name;
|
|
198
|
+
const collection = subApp.db.getCollection(collectionName);
|
|
199
|
+
if (!collection) {
|
|
200
|
+
subApp.log.warn(`collection ${collectionName} not found in ${subApp.name}`);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
collection.removeField(removedField.name);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
this.app.db.on(`afterRemoveCollection`, (collection) => {
|
|
207
|
+
const subApps = [...this.app.appManager.applications.values()];
|
|
208
|
+
for (const subApp of subApps) {
|
|
209
|
+
subApp.db.removeCollection(collection.name);
|
|
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
|
+
await this.db.import({
|
|
220
|
+
directory: path.resolve(__dirname, "collections")
|
|
221
|
+
});
|
|
222
|
+
this.app.resourcer.registerActionHandlers({
|
|
223
|
+
"applications:shareCollections": async (ctx, next) => {
|
|
224
|
+
const { filterByTk, values } = ctx.action.params;
|
|
225
|
+
ctx.body = {
|
|
226
|
+
filterByTk,
|
|
227
|
+
values
|
|
228
|
+
};
|
|
229
|
+
await next();
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
multiAppManager.setAppOptionsFactory((appName, mainApp) => {
|
|
233
|
+
const mainAppDbConfig = PluginMultiAppManager__default.default.getDatabaseConfig(mainApp);
|
|
234
|
+
const databaseOptions = {
|
|
235
|
+
...mainAppDbConfig,
|
|
236
|
+
schema: appName
|
|
237
|
+
};
|
|
238
|
+
const plugins = [...mainApp.pm.getPlugins().keys()].filter(
|
|
239
|
+
(name) => name !== "multi-app-manager" && name !== "multi-app-share-collection"
|
|
240
|
+
);
|
|
241
|
+
return {
|
|
242
|
+
database: lodash__default.default.merge(databaseOptions, {
|
|
243
|
+
dialectOptions: {
|
|
244
|
+
application_name: `nocobase.${appName}`
|
|
245
|
+
}
|
|
246
|
+
}),
|
|
247
|
+
plugins: plugins.includes("nocobase") ? ["nocobase"] : plugins,
|
|
248
|
+
resourcer: {
|
|
249
|
+
prefix: "/api"
|
|
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
|
+
requiredPlugins() {
|
|
272
|
+
return ["multi-app-manager"];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
var plugin_default = MultiAppShareCollectionPlugin;
|
|
276
|
+
|
|
277
|
+
exports.MultiAppShareCollectionPlugin = MultiAppShareCollectionPlugin;
|
|
278
|
+
exports.default = plugin_default;
|
package/package.json
CHANGED
|
@@ -4,33 +4,24 @@
|
|
|
4
4
|
"displayName.zh-CN": "多应用数据共享",
|
|
5
5
|
"description": "multi app share collection",
|
|
6
6
|
"description.zh-CN": "多应用数据共享",
|
|
7
|
-
"version": "0.
|
|
8
|
-
"main": "./
|
|
9
|
-
"files": [
|
|
10
|
-
"lib",
|
|
11
|
-
"src",
|
|
12
|
-
"README.md",
|
|
13
|
-
"README.zh-CN.md",
|
|
14
|
-
"CHANGELOG.md",
|
|
15
|
-
"server.js",
|
|
16
|
-
"server.d.ts",
|
|
17
|
-
"client.js",
|
|
18
|
-
"client.d.ts"
|
|
19
|
-
],
|
|
7
|
+
"version": "0.12.0-alpha.2",
|
|
8
|
+
"main": "./dist/server/index.js",
|
|
20
9
|
"devDependencies": {
|
|
21
|
-
"@formily/react": "
|
|
22
|
-
"
|
|
23
|
-
"@nocobase/database": "0.11.1-alpha.5",
|
|
24
|
-
"@nocobase/plugin-collection-manager": "0.11.1-alpha.5",
|
|
25
|
-
"@nocobase/plugin-error-handler": "0.11.1-alpha.5",
|
|
26
|
-
"@nocobase/plugin-multi-app-manager": "0.11.1-alpha.5",
|
|
27
|
-
"@nocobase/plugin-users": "0.11.1-alpha.5",
|
|
28
|
-
"@nocobase/server": "0.11.1-alpha.5",
|
|
29
|
-
"@nocobase/test": "0.11.1-alpha.5",
|
|
30
|
-
"@nocobase/utils": "0.11.1-alpha.5",
|
|
31
|
-
"antd": "^5.6.4",
|
|
10
|
+
"@formily/react": "2.x",
|
|
11
|
+
"antd": "5.x",
|
|
32
12
|
"react": "18.x",
|
|
33
13
|
"react-i18next": "^11.15.1"
|
|
34
14
|
},
|
|
35
|
-
"
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@nocobase/client": "0.x",
|
|
17
|
+
"@nocobase/database": "0.x",
|
|
18
|
+
"@nocobase/plugin-collection-manager": "0.x",
|
|
19
|
+
"@nocobase/plugin-error-handler": "0.x",
|
|
20
|
+
"@nocobase/plugin-multi-app-manager": "0.x",
|
|
21
|
+
"@nocobase/plugin-users": "0.x",
|
|
22
|
+
"@nocobase/server": "0.x",
|
|
23
|
+
"@nocobase/test": "0.x",
|
|
24
|
+
"@nocobase/utils": "0.x"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "a95e9e2666f0318c955113a4735bc005a2c9a767"
|
|
36
27
|
}
|
package/server.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { default } from './
|
|
3
|
-
|
|
1
|
+
export * from './dist/server';
|
|
2
|
+
export { default } from './dist/server';
|
package/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MultiAppShareCollectionProvider = void 0;
|
|
7
|
-
function _react() {
|
|
8
|
-
const data = require("@formily/react");
|
|
9
|
-
_react = function _react() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _client() {
|
|
15
|
-
const data = require("@nocobase/client");
|
|
16
|
-
_client = function _client() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _client2() {
|
|
22
|
-
const data = require("@nocobase/plugin-multi-app-manager/client");
|
|
23
|
-
_client2 = function _client2() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _antd() {
|
|
29
|
-
const data = require("antd");
|
|
30
|
-
_antd = function _antd() {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _react2() {
|
|
36
|
-
const data = _interopRequireDefault(require("react"));
|
|
37
|
-
_react2 = function _react2() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
var _TableTransfer = require("./TableTransfer");
|
|
43
|
-
var _utils = require("./utils");
|
|
44
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
46
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
47
|
-
const useShareCollectionAction = () => {
|
|
48
|
-
const form = (0, _react().useForm)();
|
|
49
|
-
const ctx = (0, _client().useActionContext)();
|
|
50
|
-
const api = (0, _client().useAPIClient)();
|
|
51
|
-
const record = (0, _client().useRecord)();
|
|
52
|
-
return {
|
|
53
|
-
run() {
|
|
54
|
-
return _asyncToGenerator(function* () {
|
|
55
|
-
console.log(form.values.names);
|
|
56
|
-
yield api.request({
|
|
57
|
-
url: `applications/${record.name}/collectionBlacklist`,
|
|
58
|
-
data: form.values.names,
|
|
59
|
-
method: 'post'
|
|
60
|
-
});
|
|
61
|
-
ctx.setVisible(false);
|
|
62
|
-
form.reset();
|
|
63
|
-
_antd().message.success('Saved successfully');
|
|
64
|
-
})();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const updateSchema = _client2().tableActionColumnSchema.properties.update;
|
|
69
|
-
const deleteSchema = _client2().tableActionColumnSchema.properties.delete;
|
|
70
|
-
delete _client2().tableActionColumnSchema.properties.update;
|
|
71
|
-
delete _client2().tableActionColumnSchema.properties.delete;
|
|
72
|
-
_client2().tableActionColumnSchema.properties['collection'] = {
|
|
73
|
-
type: 'void',
|
|
74
|
-
title: (0, _utils.i18nText)('Share collections'),
|
|
75
|
-
'x-component': 'Action.Link',
|
|
76
|
-
'x-component-props': {},
|
|
77
|
-
properties: {
|
|
78
|
-
drawer: {
|
|
79
|
-
type: 'void',
|
|
80
|
-
'x-component': 'Action.Drawer',
|
|
81
|
-
'x-component-props': {
|
|
82
|
-
width: '95vw'
|
|
83
|
-
},
|
|
84
|
-
'x-decorator': 'Form',
|
|
85
|
-
title: (0, _utils.i18nText)('Share collections'),
|
|
86
|
-
properties: {
|
|
87
|
-
names: {
|
|
88
|
-
type: 'array',
|
|
89
|
-
'x-component': _TableTransfer.TableTransfer,
|
|
90
|
-
'x-decorator': 'FormItem'
|
|
91
|
-
},
|
|
92
|
-
footer: {
|
|
93
|
-
type: 'void',
|
|
94
|
-
'x-component': 'Action.Drawer.Footer',
|
|
95
|
-
properties: {
|
|
96
|
-
cancel: {
|
|
97
|
-
title: '{{t("Cancel")}}',
|
|
98
|
-
'x-component': 'Action',
|
|
99
|
-
'x-component-props': {
|
|
100
|
-
useAction: '{{ cm.useCancelAction }}'
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
submit: {
|
|
104
|
-
title: '{{t("Submit")}}',
|
|
105
|
-
'x-component': 'Action',
|
|
106
|
-
'x-component-props': {
|
|
107
|
-
type: 'primary',
|
|
108
|
-
useAction: useShareCollectionAction
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
_client2().tableActionColumnSchema.properties.update = updateSchema;
|
|
118
|
-
_client2().tableActionColumnSchema.properties.delete = deleteSchema;
|
|
119
|
-
const MultiAppShareCollectionProvider = props => {
|
|
120
|
-
return _react2().default.createElement(_react2().default.Fragment, null, props.children);
|
|
121
|
-
};
|
|
122
|
-
exports.MultiAppShareCollectionProvider = MultiAppShareCollectionProvider;
|