@nocobase/plugin-multi-app-share-collection 0.11.1-alpha.4 → 0.12.0-alpha.1
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,514 +0,0 @@
|
|
|
1
|
-
import { BelongsToManyRepository, Database } from '@nocobase/database';
|
|
2
|
-
import { MockServer, mockServer, pgOnly } from '@nocobase/test';
|
|
3
|
-
import * as process from 'process';
|
|
4
|
-
|
|
5
|
-
pgOnly()('enable plugin', () => {
|
|
6
|
-
let mainDb: Database;
|
|
7
|
-
let mainApp: MockServer;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
const app = mockServer({
|
|
11
|
-
acl: false,
|
|
12
|
-
plugins: ['nocobase'],
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
await app.load();
|
|
16
|
-
|
|
17
|
-
await app.install({
|
|
18
|
-
clean: true,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
mainApp = app;
|
|
22
|
-
|
|
23
|
-
mainDb = mainApp.db;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
afterEach(async () => {
|
|
27
|
-
await mainApp.destroy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should throw error when enable plugin, when multi-app plugin is not enabled', async () => {
|
|
31
|
-
console.log('enable share collection plugin');
|
|
32
|
-
let error;
|
|
33
|
-
try {
|
|
34
|
-
await mainApp.pm.enable('multi-app-share-collection');
|
|
35
|
-
} catch (e) {
|
|
36
|
-
error = e;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
expect(error.message).toBe('multi-app-share-collection plugin need multi-app-manager plugin enabled');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
pgOnly()('collection sync', () => {
|
|
44
|
-
let mainDb: Database;
|
|
45
|
-
let mainApp: MockServer;
|
|
46
|
-
|
|
47
|
-
beforeEach(async () => {
|
|
48
|
-
const app = mockServer({
|
|
49
|
-
acl: false,
|
|
50
|
-
plugins: ['nocobase'],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
await app.load();
|
|
54
|
-
|
|
55
|
-
await app.db.sequelize.query(`DROP SCHEMA IF EXISTS sub1 CASCADE`);
|
|
56
|
-
await app.db.sequelize.query(`DROP SCHEMA IF EXISTS sub2 CASCADE`);
|
|
57
|
-
await app.install({
|
|
58
|
-
clean: true,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
await app.pm.enable('multi-app-manager');
|
|
62
|
-
await app.pm.enable('multi-app-share-collection');
|
|
63
|
-
|
|
64
|
-
await app.start();
|
|
65
|
-
|
|
66
|
-
mainApp = app;
|
|
67
|
-
|
|
68
|
-
mainDb = mainApp.db;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
afterEach(async () => {
|
|
72
|
-
await mainApp.destroy();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should set user role in sub app when user created at main app', async () => {
|
|
76
|
-
await mainApp.db.getRepository('applications').create({
|
|
77
|
-
values: {
|
|
78
|
-
name: 'sub1',
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const sub1 = await mainApp.appManager.getApplication('sub1');
|
|
83
|
-
|
|
84
|
-
await mainApp.db.getRepository('users').create({
|
|
85
|
-
values: {
|
|
86
|
-
email: 'test@qq.com',
|
|
87
|
-
password: 'test123',
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const defaultRole = await sub1.db.getRepository('roles').findOne({
|
|
92
|
-
filter: {
|
|
93
|
-
default: true,
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const user = await sub1.db.getRepository('users').findOne({
|
|
98
|
-
filter: {
|
|
99
|
-
email: 'test@qq.com',
|
|
100
|
-
},
|
|
101
|
-
appends: ['roles'],
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
expect(user.get('roles').map((item) => item.name)).toEqual([defaultRole.name]);
|
|
105
|
-
|
|
106
|
-
await mainApp.db.getRepository('applications').create({
|
|
107
|
-
values: {
|
|
108
|
-
name: 'sub2',
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const sub2 = await mainApp.appManager.getApplication('sub2');
|
|
113
|
-
|
|
114
|
-
const defaultRoleInSub2 = await sub2.db.getRepository('roles').findOne({
|
|
115
|
-
filter: {
|
|
116
|
-
default: true,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const userInSub2 = await sub2.db.getRepository('users').findOne({
|
|
121
|
-
filter: {
|
|
122
|
-
email: 'test@qq.com',
|
|
123
|
-
},
|
|
124
|
-
appends: ['roles'],
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
expect(userInSub2.get('roles').map((item) => item.name)).toContain(defaultRoleInSub2.name);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('should in sub app schema when sub app lazy load', async () => {
|
|
131
|
-
await mainApp.db.getRepository('applications').create({
|
|
132
|
-
values: {
|
|
133
|
-
name: 'sub1',
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
await mainApp.appManager.removeApplication('sub1');
|
|
138
|
-
|
|
139
|
-
const sub1 = await mainApp.appManager.getApplication('sub1');
|
|
140
|
-
|
|
141
|
-
expect(sub1.db.options.schema).toBe('sub1');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('should sync plugin status into lazy load sub app', async () => {
|
|
145
|
-
await mainApp.db.getRepository('applications').create({
|
|
146
|
-
values: {
|
|
147
|
-
name: 'sub1',
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
await mainApp.appManager.removeApplication('sub1');
|
|
152
|
-
|
|
153
|
-
await mainApp.pm.enable('map');
|
|
154
|
-
|
|
155
|
-
const sub1 = await mainApp.appManager.getApplication('sub1');
|
|
156
|
-
|
|
157
|
-
await sub1.reload();
|
|
158
|
-
|
|
159
|
-
console.log(sub1.pm.plugins);
|
|
160
|
-
expect(sub1.pm.plugins.get('map').options.enabled).toBeTruthy();
|
|
161
|
-
|
|
162
|
-
const sub1MapPlugin = await sub1.db.getRepository('applicationPlugins').findOne({
|
|
163
|
-
filter: {
|
|
164
|
-
name: 'map',
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
expect(sub1MapPlugin.get('enabled')).toBeTruthy();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should sync plugin status between apps', async () => {
|
|
172
|
-
await mainApp.db.getRepository('applications').create({
|
|
173
|
-
values: {
|
|
174
|
-
name: 'sub1',
|
|
175
|
-
},
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const sub1 = await mainApp.appManager.getApplication('sub1');
|
|
179
|
-
|
|
180
|
-
const getSubAppMapRecord = async (app) => {
|
|
181
|
-
return await app.db.getRepository('applicationPlugins').findOne({
|
|
182
|
-
filter: {
|
|
183
|
-
name: 'map',
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
expect((await getSubAppMapRecord(sub1)).get('enabled')).toBeFalsy();
|
|
189
|
-
await mainApp.pm.enable('map');
|
|
190
|
-
expect((await getSubAppMapRecord(sub1)).get('enabled')).toBeTruthy();
|
|
191
|
-
|
|
192
|
-
// create new app sub2
|
|
193
|
-
await mainApp.db.getRepository('applications').create({
|
|
194
|
-
values: {
|
|
195
|
-
name: 'sub2',
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
const sub2 = await mainApp.appManager.getApplication('sub2');
|
|
200
|
-
expect((await getSubAppMapRecord(sub2)).get('enabled')).toBeTruthy();
|
|
201
|
-
expect(sub2.pm.plugins.get('map').options.enabled).toBeTruthy();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('should not sync roles in sub app', async () => {
|
|
205
|
-
await mainDb.getRepository('applications').create({
|
|
206
|
-
values: {
|
|
207
|
-
name: 'sub1',
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
const subApp1 = await mainApp.appManager.getApplication('sub1');
|
|
212
|
-
|
|
213
|
-
await mainDb.getRepository('roles').create({
|
|
214
|
-
values: {
|
|
215
|
-
name: 'role1',
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(
|
|
220
|
-
await subApp1.db.getRepository('roles').findOne({
|
|
221
|
-
filter: {
|
|
222
|
-
name: 'role1',
|
|
223
|
-
},
|
|
224
|
-
}),
|
|
225
|
-
).toBeFalsy();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should sync user collections', async () => {
|
|
229
|
-
const subApp1Record = await mainDb.getRepository('applications').create({
|
|
230
|
-
values: {
|
|
231
|
-
name: 'sub1',
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
const subApp1 = await mainApp.appManager.getApplication(subApp1Record.name);
|
|
236
|
-
|
|
237
|
-
expect(subApp1.db.getCollection('users').options.schema).toBe(mainDb.options.schema || 'public');
|
|
238
|
-
|
|
239
|
-
const userCollectionRecord = await subApp1.db.getRepository('collections').findOne({
|
|
240
|
-
filter: {
|
|
241
|
-
name: 'users',
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
expect(userCollectionRecord).toBeTruthy();
|
|
245
|
-
await mainApp.db.getRepository('users').create({
|
|
246
|
-
values: {
|
|
247
|
-
email: 'test@qq.com',
|
|
248
|
-
password: '123456',
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
const user = await subApp1.db.getRepository('users').find({
|
|
252
|
-
filter: {
|
|
253
|
-
email: 'test@qq.com',
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
expect(user).toBeTruthy();
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it('should sync custom collections', async () => {
|
|
260
|
-
const subApp1Record = await mainDb.getRepository('applications').create({
|
|
261
|
-
values: {
|
|
262
|
-
name: 'sub1',
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
const subApp1 = await mainApp.appManager.getApplication(subApp1Record.name);
|
|
267
|
-
|
|
268
|
-
await mainApp.db.getRepository('collections').create({
|
|
269
|
-
values: {
|
|
270
|
-
name: 'posts',
|
|
271
|
-
fields: [{ type: 'string', title: 'title' }],
|
|
272
|
-
},
|
|
273
|
-
context: {},
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
const postCollection = subApp1.db.getCollection('posts');
|
|
277
|
-
|
|
278
|
-
expect(postCollection.options.schema).toBe(
|
|
279
|
-
process.env.COLLECTION_MANAGER_SCHEMA || mainDb.options.schema || 'public',
|
|
280
|
-
);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('should support syncToApps with wildcard value', async () => {
|
|
284
|
-
const subApp1Record = await mainDb.getRepository('applications').create({
|
|
285
|
-
values: {
|
|
286
|
-
name: 'sub1',
|
|
287
|
-
},
|
|
288
|
-
});
|
|
289
|
-
const subApp1 = await mainApp.appManager.getApplication(subApp1Record.name);
|
|
290
|
-
|
|
291
|
-
const subApp2Record = await mainDb.getRepository('applications').create({
|
|
292
|
-
values: {
|
|
293
|
-
name: 'sub2',
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
const subApp2 = await mainApp.appManager.getApplication(subApp2Record.name);
|
|
297
|
-
|
|
298
|
-
const mainCollection = await mainDb.getRepository('collections').create({
|
|
299
|
-
values: {
|
|
300
|
-
name: 'mainCollection',
|
|
301
|
-
syncToApps: '*',
|
|
302
|
-
},
|
|
303
|
-
context: {},
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const subApp1MainCollectionRecord = await subApp1.db.getRepository('collections').findOne({
|
|
307
|
-
filter: {
|
|
308
|
-
name: 'mainCollection',
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
expect(subApp1MainCollectionRecord).toBeTruthy();
|
|
313
|
-
|
|
314
|
-
const subApp2MainCollectionRecord = await subApp2.db.getRepository('collections').findOne({
|
|
315
|
-
filter: {
|
|
316
|
-
name: 'mainCollection',
|
|
317
|
-
},
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
expect(subApp2MainCollectionRecord).toBeTruthy();
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it('should sync collections in sub apps', async () => {
|
|
324
|
-
const subApp1Record = await mainDb.getRepository('applications').create({
|
|
325
|
-
values: {
|
|
326
|
-
name: 'sub1',
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
const subApp1 = await mainApp.appManager.getApplication(subApp1Record.name);
|
|
331
|
-
|
|
332
|
-
const mainCollection = await mainDb.getRepository('collections').create({
|
|
333
|
-
values: {
|
|
334
|
-
name: 'mainCollection',
|
|
335
|
-
fields: [
|
|
336
|
-
{
|
|
337
|
-
name: 'field0',
|
|
338
|
-
type: 'string',
|
|
339
|
-
},
|
|
340
|
-
],
|
|
341
|
-
},
|
|
342
|
-
context: {},
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
const subAppMainCollectionRecord = await subApp1.db.getRepository('collections').findOne({
|
|
346
|
-
filter: {
|
|
347
|
-
name: 'mainCollection',
|
|
348
|
-
},
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
expect(subAppMainCollectionRecord).toBeTruthy();
|
|
352
|
-
|
|
353
|
-
const subAppMainCollection = subApp1.db.getCollection('mainCollection');
|
|
354
|
-
|
|
355
|
-
expect(subAppMainCollection).toBeTruthy();
|
|
356
|
-
expect(subAppMainCollection.options.schema).toBe(mainCollection.options.schema || 'public');
|
|
357
|
-
|
|
358
|
-
await mainApp.db.getRepository('fields').create({
|
|
359
|
-
values: {
|
|
360
|
-
collectionName: 'mainCollection',
|
|
361
|
-
name: 'title',
|
|
362
|
-
type: 'string',
|
|
363
|
-
uiSchema: {
|
|
364
|
-
type: 'string',
|
|
365
|
-
'x-component': 'Input',
|
|
366
|
-
title: 'field1',
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
context: {},
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
const mainCollectionTitleField = await subApp1.db.getRepository('fields').findOne({
|
|
373
|
-
filter: {
|
|
374
|
-
collectionName: 'mainCollection',
|
|
375
|
-
name: 'title',
|
|
376
|
-
},
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
expect(mainCollectionTitleField).toBeTruthy();
|
|
380
|
-
|
|
381
|
-
await mainApp.db.getRepository('mainCollection').create({
|
|
382
|
-
values: {
|
|
383
|
-
title: 'test',
|
|
384
|
-
},
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
const subRecord = await subApp1.db.getRepository('mainCollection').findOne({});
|
|
388
|
-
expect(subRecord.get('title')).toBe('test');
|
|
389
|
-
|
|
390
|
-
await mainApp.db.getRepository('fields').update({
|
|
391
|
-
values: {
|
|
392
|
-
unique: true,
|
|
393
|
-
},
|
|
394
|
-
filter: {
|
|
395
|
-
collectionName: 'mainCollection',
|
|
396
|
-
name: 'title',
|
|
397
|
-
},
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
const mainCollectionTitleField2 = await subApp1.db.getRepository('fields').findOne({
|
|
401
|
-
filter: {
|
|
402
|
-
collectionName: 'mainCollection',
|
|
403
|
-
name: 'title',
|
|
404
|
-
},
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
expect(mainCollectionTitleField2.get('unique')).toBe(true);
|
|
408
|
-
|
|
409
|
-
expect(subAppMainCollection.getField('title')).toBeTruthy();
|
|
410
|
-
|
|
411
|
-
await mainApp.db.getRepository('fields').destroy({
|
|
412
|
-
filter: {
|
|
413
|
-
collectionName: 'mainCollection',
|
|
414
|
-
name: 'title',
|
|
415
|
-
},
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
expect(
|
|
419
|
-
await subApp1.db.getRepository('fields').findOne({
|
|
420
|
-
filter: {
|
|
421
|
-
collectionName: 'mainCollection',
|
|
422
|
-
name: 'title',
|
|
423
|
-
},
|
|
424
|
-
}),
|
|
425
|
-
).toBeFalsy();
|
|
426
|
-
|
|
427
|
-
expect(subAppMainCollection.getField('title')).toBeFalsy();
|
|
428
|
-
|
|
429
|
-
await mainApp.db.getRepository('collections').destroy({
|
|
430
|
-
filter: {
|
|
431
|
-
name: 'mainCollection',
|
|
432
|
-
},
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
expect(
|
|
436
|
-
await subApp1.db.getRepository('collections').findOne({
|
|
437
|
-
filter: {
|
|
438
|
-
name: 'mainCollection',
|
|
439
|
-
},
|
|
440
|
-
}),
|
|
441
|
-
).toBeFalsy();
|
|
442
|
-
|
|
443
|
-
expect(subApp1.db.getCollection('mainCollection')).toBeFalsy();
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
it('should update syncToApp options', async () => {
|
|
447
|
-
await mainApp.db.getRepository('applications').create({
|
|
448
|
-
values: {
|
|
449
|
-
name: 'sub1',
|
|
450
|
-
},
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
const sub1 = await mainApp.appManager.getApplication('sub1');
|
|
454
|
-
|
|
455
|
-
await mainApp.db.getRepository('collections').create({
|
|
456
|
-
values: {
|
|
457
|
-
name: 'testCollection',
|
|
458
|
-
fields: [
|
|
459
|
-
{
|
|
460
|
-
type: 'string',
|
|
461
|
-
name: 'title',
|
|
462
|
-
},
|
|
463
|
-
],
|
|
464
|
-
},
|
|
465
|
-
context: {},
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
const sub1CollectionsRecord = await sub1.db.getRepository('collections').findOne({
|
|
469
|
-
filter: {
|
|
470
|
-
name: 'testCollection',
|
|
471
|
-
},
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
expect(sub1CollectionsRecord).toBeTruthy();
|
|
475
|
-
|
|
476
|
-
const mainTestCollection = await mainDb.getCollection('testCollection');
|
|
477
|
-
const sub1TestCollection = await sub1.db.getCollection('testCollection');
|
|
478
|
-
expect(sub1TestCollection.collectionSchema()).toEqual(mainTestCollection.collectionSchema());
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
it('should set collection black list', async () => {
|
|
482
|
-
await mainApp.db.getRepository('applications').create({
|
|
483
|
-
values: {
|
|
484
|
-
name: 'sub1',
|
|
485
|
-
},
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
await mainApp.db.getRepository('collections').create({
|
|
489
|
-
values: {
|
|
490
|
-
name: 'testCollection',
|
|
491
|
-
fields: [
|
|
492
|
-
{
|
|
493
|
-
name: 'testField',
|
|
494
|
-
type: 'string',
|
|
495
|
-
},
|
|
496
|
-
],
|
|
497
|
-
},
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
const BlackListRepository = await mainApp.db
|
|
501
|
-
.getCollection('applications')
|
|
502
|
-
.repository.relation<BelongsToManyRepository>('collectionBlacklist')
|
|
503
|
-
.of('sub1');
|
|
504
|
-
|
|
505
|
-
const blackList = await BlackListRepository.find();
|
|
506
|
-
|
|
507
|
-
expect(blackList.length).toBe(0);
|
|
508
|
-
|
|
509
|
-
await BlackListRepository.toggle('testCollection');
|
|
510
|
-
const blackList1 = await BlackListRepository.find();
|
|
511
|
-
|
|
512
|
-
expect(blackList1.length).toBe(1);
|
|
513
|
-
});
|
|
514
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { mockServer } from '@nocobase/test';
|
|
2
|
-
import PluginCollectionManager from '@nocobase/plugin-collection-manager';
|
|
3
|
-
import PluginMultiAppManager from '@nocobase/plugin-multi-app-manager';
|
|
4
|
-
import PluginErrorHandler from '@nocobase/plugin-error-handler';
|
|
5
|
-
import PluginUser from '@nocobase/plugin-users';
|
|
6
|
-
import Plugin from '..';
|
|
7
|
-
|
|
8
|
-
export async function createApp(options = {}) {
|
|
9
|
-
const app = mockServer({
|
|
10
|
-
acl: false,
|
|
11
|
-
...options,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
app.plugin(PluginUser, { name: 'users' });
|
|
15
|
-
app.plugin(PluginErrorHandler, { name: 'error-handler' });
|
|
16
|
-
app.plugin(PluginCollectionManager, { name: 'collection-manager' });
|
|
17
|
-
await app.loadAndInstall({ clean: true });
|
|
18
|
-
app.plugin(PluginMultiAppManager, { name: 'multi-app-manager' });
|
|
19
|
-
app.plugin(Plugin, { name: 'multi-app-share-collection' });
|
|
20
|
-
|
|
21
|
-
await app.reload();
|
|
22
|
-
await app.install();
|
|
23
|
-
await app.start();
|
|
24
|
-
return app;
|
|
25
|
-
}
|
|
File without changes
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { extendCollection } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default extendCollection({
|
|
4
|
-
name: 'applications',
|
|
5
|
-
fields: [
|
|
6
|
-
{
|
|
7
|
-
type: 'belongsToMany',
|
|
8
|
-
name: 'collectionBlacklist',
|
|
9
|
-
through: 'appCollectionBlacklist',
|
|
10
|
-
target: 'collections',
|
|
11
|
-
targetKey: 'name',
|
|
12
|
-
otherKey: 'collectionName',
|
|
13
|
-
sourceKey: 'name',
|
|
14
|
-
foreignKey: 'applicationName',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { extendCollection } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
export default extendCollection({
|
|
4
|
-
name: 'collections',
|
|
5
|
-
fields: [
|
|
6
|
-
{
|
|
7
|
-
type: 'belongsToMany',
|
|
8
|
-
name: 'collectionBlacklist',
|
|
9
|
-
through: 'appCollectionBlacklist',
|
|
10
|
-
target: 'applications',
|
|
11
|
-
targetKey: 'name',
|
|
12
|
-
otherKey: 'applicationName',
|
|
13
|
-
sourceKey: 'name',
|
|
14
|
-
foreignKey: 'collectionName',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
});
|
package/src/server/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './plugin';
|