apostrophe 3.16.0 → 3.16.1-alpha.20210331
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/.eslintignore +3 -1
- package/CHANGELOG.md +23 -1
- package/index.js +5 -4
- package/lib/moog.js +14 -1
- package/modules/@apostrophecms/area/ui/apos/components/AposAreaEditor.vue +3 -1
- package/modules/@apostrophecms/asset/index.js +213 -101
- package/modules/@apostrophecms/asset/lib/webpack/apos/webpack.config.js +3 -3
- package/modules/@apostrophecms/asset/lib/webpack/src/webpack.config.js +30 -12
- package/modules/@apostrophecms/asset/lib/webpack/src/webpack.es5.js +1 -1
- package/modules/@apostrophecms/asset/lib/webpack/src/webpack.scss.js +6 -2
- package/modules/@apostrophecms/asset/lib/webpack/utils.js +266 -0
- package/modules/@apostrophecms/asset/views/scripts.html +1 -0
- package/modules/@apostrophecms/asset/views/stylesheets.html +1 -0
- package/modules/@apostrophecms/doc/index.js +64 -0
- package/modules/@apostrophecms/doc-type/index.js +35 -0
- package/modules/@apostrophecms/i18n/i18n/en.json +2 -0
- package/modules/@apostrophecms/i18n/ui/apos/components/AposI18nLocalize.vue +7 -0
- package/modules/@apostrophecms/login/index.js +4 -0
- package/modules/@apostrophecms/schema/index.js +40 -49
- package/modules/@apostrophecms/schema/ui/apos/components/AposInputObject.vue +67 -0
- package/modules/@apostrophecms/template/index.js +14 -5
- package/modules/@apostrophecms/template/lib/bundlesLoader.js +158 -0
- package/modules/@apostrophecms/template/views/outerLayoutBase.html +6 -0
- package/modules/@apostrophecms/widget-type/index.js +21 -0
- package/package.json +2 -2
- package/test/areas.js +2 -1
- package/test/assets.js +307 -3
- package/test/docs.js +67 -2
- package/test/modules/bundle/index.js +7 -0
- package/test/modules/bundle-page/index.js +32 -0
- package/test/modules/bundle-page/ui/src/extra.js +1 -0
- package/test/modules/bundle-page/ui/src/extra.scss +0 -0
- package/test/modules/bundle-page/views/index.html +9 -0
- package/test/modules/bundle-page/views/show.html +10 -0
- package/test/modules/bundle-widget/index.js +27 -0
- package/test/modules/bundle-widget/ui/src/extra2.js +1 -0
- package/test/modules/bundle-widget/views/widget.html +1 -0
- package/test/pieces.js +38 -12
- package/test/package.json +0 -11
- package/test/public/static-test.txt +0 -1
package/test/docs.js
CHANGED
|
@@ -299,6 +299,40 @@ describe('Docs', function() {
|
|
|
299
299
|
assert(doc.slug.match(/^one\d+$/));
|
|
300
300
|
});
|
|
301
301
|
|
|
302
|
+
it('should add the aposDocId to the related documents\' relatedReverseIds field', async () => {
|
|
303
|
+
const object = {
|
|
304
|
+
aposDocId: 'paul',
|
|
305
|
+
aposLocale: 'en:published',
|
|
306
|
+
slug: 'paul',
|
|
307
|
+
visibility: 'public',
|
|
308
|
+
type: 'test-people',
|
|
309
|
+
firstName: 'Paul',
|
|
310
|
+
lastName: 'McCartney',
|
|
311
|
+
age: 24,
|
|
312
|
+
alive: false,
|
|
313
|
+
friendsIds: [ 'carl', 'larry' ],
|
|
314
|
+
_friends: [ { _id: 'carl:en:published' }, { _id: 'larry:en:published' } ]
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
await apos.doc.insert(apos.task.getReq(), object);
|
|
318
|
+
|
|
319
|
+
const carlDoc = await apos.doc.db.findOne({
|
|
320
|
+
slug: 'carl',
|
|
321
|
+
aposLocale: 'en:published'
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const larryDoc = await apos.doc.db.findOne({
|
|
325
|
+
slug: 'larry',
|
|
326
|
+
aposLocale: 'en:published'
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
assert(carlDoc.relatedReverseIds.length === 1);
|
|
330
|
+
assert(carlDoc.relatedReverseIds[0] === 'paul');
|
|
331
|
+
|
|
332
|
+
assert(larryDoc.relatedReverseIds.length === 1);
|
|
333
|
+
assert(larryDoc.relatedReverseIds[0] === 'paul');
|
|
334
|
+
});
|
|
335
|
+
|
|
302
336
|
it('should not allow you to call the insert method if you are not an admin', async function() {
|
|
303
337
|
const object = {
|
|
304
338
|
slug: 'not-for-you',
|
|
@@ -364,7 +398,7 @@ describe('Docs', function() {
|
|
|
364
398
|
}).toDistinct('firstName');
|
|
365
399
|
|
|
366
400
|
assert(Array.isArray(firstNames));
|
|
367
|
-
assert(firstNames.length ===
|
|
401
|
+
assert(firstNames.length === 5);
|
|
368
402
|
assert(_.includes(firstNames, 'Larry'));
|
|
369
403
|
});
|
|
370
404
|
|
|
@@ -376,7 +410,7 @@ describe('Docs', function() {
|
|
|
376
410
|
const firstNames = await cursor.toDistinct('firstName');
|
|
377
411
|
|
|
378
412
|
assert(Array.isArray(firstNames));
|
|
379
|
-
assert(firstNames.length ===
|
|
413
|
+
assert(firstNames.length === 5);
|
|
380
414
|
assert(_.includes(firstNames, 'Larry'));
|
|
381
415
|
|
|
382
416
|
const counts = await cursor.get('distinctCounts');
|
|
@@ -385,6 +419,37 @@ describe('Docs', function() {
|
|
|
385
419
|
assert(counts.Lori === 2);
|
|
386
420
|
});
|
|
387
421
|
|
|
422
|
+
it('should remove the aposDocId from the related documents\' relatedReverseIds field', async () => {
|
|
423
|
+
const paulDoc = await apos.doc.db.findOne({
|
|
424
|
+
slug: 'paul',
|
|
425
|
+
aposLocale: 'en:published'
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// carl removed from paul's related friends, only larry remains
|
|
429
|
+
const object = {
|
|
430
|
+
...paulDoc,
|
|
431
|
+
friendsIds: [ 'larry' ],
|
|
432
|
+
_friends: [ { _id: 'larry:en:published' } ]
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
await apos.doc.update(apos.task.getReq(), object);
|
|
436
|
+
|
|
437
|
+
const carlDoc = await apos.doc.db.findOne({
|
|
438
|
+
slug: 'carl',
|
|
439
|
+
aposLocale: 'en:published'
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
const larryDoc = await apos.doc.db.findOne({
|
|
443
|
+
slug: 'larry',
|
|
444
|
+
aposLocale: 'en:published'
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
assert(carlDoc.relatedReverseIds.length === 0);
|
|
448
|
+
|
|
449
|
+
assert(larryDoc.relatedReverseIds.length === 1);
|
|
450
|
+
assert(larryDoc.relatedReverseIds[0] === 'paul');
|
|
451
|
+
});
|
|
452
|
+
|
|
388
453
|
it('should not allow you to call the update method if you are not an admin', async function() {
|
|
389
454
|
const cursor = apos.doc.find(apos.task.getAnonReq(), {
|
|
390
455
|
type: 'test-people',
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extend: '@apostrophecms/piece-page-type',
|
|
3
|
+
webpack: {
|
|
4
|
+
bundles: {
|
|
5
|
+
extra: {
|
|
6
|
+
templates: [ 'show' ]
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
extensions: {
|
|
10
|
+
ext1: {
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
ext1: 'foo-path'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
fields: {
|
|
20
|
+
add: {
|
|
21
|
+
main: {
|
|
22
|
+
type: 'area',
|
|
23
|
+
contextual: true,
|
|
24
|
+
options: {
|
|
25
|
+
widgets: {
|
|
26
|
+
bundle: {}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => {};
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extend: '@apostrophecms/widget-type',
|
|
3
|
+
options: {
|
|
4
|
+
label: 'Bundle Widget'
|
|
5
|
+
},
|
|
6
|
+
webpack: {
|
|
7
|
+
bundles: {
|
|
8
|
+
extra2: {}
|
|
9
|
+
},
|
|
10
|
+
extensions: {
|
|
11
|
+
ext1: {
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
ext1Overriden: 'bar-path'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
ext2: {
|
|
19
|
+
resolve: {
|
|
20
|
+
alias: {
|
|
21
|
+
ext2: 'ext2-path'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h3>Bundle Widget</h3>
|
package/test/pieces.js
CHANGED
|
@@ -92,7 +92,9 @@ describe('Pieces', function() {
|
|
|
92
92
|
publicApiProjection: {
|
|
93
93
|
title: 1,
|
|
94
94
|
_url: 1,
|
|
95
|
-
_articles: 1
|
|
95
|
+
_articles: 1,
|
|
96
|
+
relationshipsInArray: 1,
|
|
97
|
+
relationshipsInObject: 1
|
|
96
98
|
}
|
|
97
99
|
},
|
|
98
100
|
fields: {
|
|
@@ -123,16 +125,6 @@ describe('Pieces', function() {
|
|
|
123
125
|
type: 'attachment',
|
|
124
126
|
group: 'images'
|
|
125
127
|
},
|
|
126
|
-
addresses: {
|
|
127
|
-
type: 'array',
|
|
128
|
-
fields: {
|
|
129
|
-
add: {
|
|
130
|
-
street: {
|
|
131
|
-
type: 'string'
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
128
|
_articles: {
|
|
137
129
|
type: 'relationship',
|
|
138
130
|
withType: 'article',
|
|
@@ -151,6 +143,28 @@ describe('Pieces', function() {
|
|
|
151
143
|
}
|
|
152
144
|
}
|
|
153
145
|
}
|
|
146
|
+
},
|
|
147
|
+
relationshipsInArray: {
|
|
148
|
+
type: 'array',
|
|
149
|
+
fields: {
|
|
150
|
+
add: {
|
|
151
|
+
_articles: {
|
|
152
|
+
type: 'relationship',
|
|
153
|
+
withType: 'article'
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
relationshipsInObject: {
|
|
159
|
+
type: 'object',
|
|
160
|
+
fields: {
|
|
161
|
+
add: {
|
|
162
|
+
_articles: {
|
|
163
|
+
type: 'relationship',
|
|
164
|
+
withType: 'article'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
154
168
|
}
|
|
155
169
|
}
|
|
156
170
|
}
|
|
@@ -737,13 +751,23 @@ describe('Pieces', function() {
|
|
|
737
751
|
}
|
|
738
752
|
]
|
|
739
753
|
},
|
|
740
|
-
_articles: [ article ]
|
|
754
|
+
_articles: [ article ],
|
|
755
|
+
relationshipsInArray: [
|
|
756
|
+
{
|
|
757
|
+
_articles: [ article ]
|
|
758
|
+
}
|
|
759
|
+
],
|
|
760
|
+
relationshipsInObject: {
|
|
761
|
+
_articles: [ article ]
|
|
762
|
+
}
|
|
741
763
|
},
|
|
742
764
|
jar
|
|
743
765
|
});
|
|
744
766
|
assert(response._id);
|
|
745
767
|
assert(response.articlesIds[0] === article.aposDocId);
|
|
746
768
|
assert(response.articlesFields[article.aposDocId].relevance === 'The very first article that was ever published about this product');
|
|
769
|
+
assert(response.relationshipsInArray[0].articlesIds[0] === article.aposDocId);
|
|
770
|
+
assert(response.relationshipsInObject.articlesIds[0] === article.aposDocId);
|
|
747
771
|
relatedProductId = response._id;
|
|
748
772
|
});
|
|
749
773
|
|
|
@@ -756,6 +780,8 @@ describe('Pieces', function() {
|
|
|
756
780
|
assert(product._articles.length === 1);
|
|
757
781
|
assert(product._articles[0]._fields);
|
|
758
782
|
assert.strictEqual(product._articles[0]._fields.relevance, 'The very first article that was ever published about this product');
|
|
783
|
+
assert(product.relationshipsInArray[0]._articles[0].title === 'First Article');
|
|
784
|
+
assert(product.relationshipsInObject._articles[0].title === 'First Article');
|
|
759
785
|
});
|
|
760
786
|
|
|
761
787
|
let relatedArticleId;
|
package/test/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
served
|