@localazy/strapi-plugin 0.1.11-rc.0 → 0.1.11-rc.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/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +5 -0
- package/admin/src/modules/plugin-settings/components/Tree/index.js +21 -6
- package/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.js +1 -1
- package/admin/src/modules/plugin-settings/functions/has-model-changed.js +1 -1
- package/admin/src/modules/plugin-settings/locale/en.js +1 -1
- package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +1 -7
- package/admin/src/modules/plugin-settings/utils/get-models-tree.js +19 -3
- package/package.json +4 -4
- package/server/controllers/localazy-transfer-controller.js +29 -8
- package/server/functions/should-set-downloaded-property.js +48 -3
- package/server/services/strapi-i18n-service.js +1 -1
- package/server/services/strapi-localazy-i18n-service.js +1 -1
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz.js +392 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-sample-json-dz.js +4675 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-lesson-dz.js +309 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json-dz.js +884 -0
- package/server/tests/fixtures/strapi-plugin-all-models.js +844 -37
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +211 -62
- package/server/utils/__tests__/pick-entries.test.js +936 -56
- package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +287 -0
- package/server/utils/build-populate.js +5 -0
- package/server/utils/model-utils.js +5 -0
- package/server/utils/omit-deep.js +7 -0
- package/server/utils/parsed-localazy-entry-to-create-entry.js +58 -4
- package/server/utils/parsed-localazy-entry-to-update-entry.js +6 -1
- package/server/utils/pick-deep.js +22 -0
- package/server/utils/pick-entries.js +90 -5
- package/server/utils/populate-create-update-entry-with-base-entry.js +51 -3
- package/server/tests/fixtures/collection-flattened.js +0 -76
- package/server/tests/fixtures/restaurant-flattened.js +0 -46
- package/server/tests/fixtures/restaurants-pick-paths.js +0 -15
|
@@ -4,6 +4,8 @@ const parsedLocalazyEntryToCreateEntry = require("../parsed-localazy-entry-to-cr
|
|
|
4
4
|
const allModels = require("../../tests/fixtures/strapi-plugin-all-models");
|
|
5
5
|
const simpleMenuWithMediaModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu");
|
|
6
6
|
const cookbookModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook");
|
|
7
|
+
const lessonDZModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz");
|
|
8
|
+
const sampleJSONDZModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-sample-json-dz");
|
|
7
9
|
|
|
8
10
|
describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
9
11
|
it("should return transformed 'restaurant-simple-menu' entry to strapi create entry structure", () => {
|
|
@@ -18,17 +20,17 @@ describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
|
18
20
|
|
|
19
21
|
// VERIFY
|
|
20
22
|
const expected = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
createEntry: {
|
|
24
|
+
name: "hlad, okno",
|
|
25
|
+
description: "Orientální pouliční jídlo v ústech rychlé a snadné!",
|
|
26
|
+
locale: "cs",
|
|
27
|
+
},
|
|
28
|
+
dynamicZoneComponentKeys: []
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
expect(result).toEqual(expected);
|
|
27
32
|
});
|
|
28
33
|
it("should return transformed 'cookbook' entry to strapi create entry structure", () => {
|
|
29
|
-
// SETUP
|
|
30
|
-
|
|
31
|
-
|
|
32
34
|
// EXECUTE
|
|
33
35
|
const result = parsedLocalazyEntryToCreateEntry(
|
|
34
36
|
allModels,
|
|
@@ -40,79 +42,226 @@ describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
|
40
42
|
|
|
41
43
|
// VERIFY
|
|
42
44
|
const expected = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
createEntry: {
|
|
46
|
+
title: "Pro každý den v roce",
|
|
47
|
+
recipes: [
|
|
48
|
+
{
|
|
49
|
+
name: "Bramborový salát",
|
|
50
|
+
__component: "food.cookbook-item",
|
|
51
|
+
recipe: "Oloupejte brambory, smíchejte je se všemi ingrediencemi a máte hotovo. Bon apetit!",
|
|
52
|
+
author_name: "Mr. Bramborová hlava",
|
|
53
|
+
gallery: [
|
|
54
|
+
{
|
|
55
|
+
image_title: "Syrové brambory",
|
|
56
|
+
__component: "food.gallery-item",
|
|
57
|
+
image_description: "Čerstvý!",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
image_title: "Salát",
|
|
61
|
+
__component: "food.gallery-item",
|
|
62
|
+
image_description: "Mňam!",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
ingredients: [
|
|
66
|
+
{
|
|
67
|
+
name: "Brambory",
|
|
68
|
+
__component: "food.recipe-ingredient",
|
|
69
|
+
unit: "kg",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "Hrášek",
|
|
73
|
+
__component: "food.recipe-ingredient",
|
|
74
|
+
unit: "plechovka",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "Kukuřice",
|
|
78
|
+
__component: "food.recipe-ingredient",
|
|
79
|
+
unit: "plechovka",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "Mayo",
|
|
83
|
+
__component: "food.recipe-ingredient",
|
|
84
|
+
unit: "lžíce",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "Sýr",
|
|
88
|
+
__component: "food.recipe-ingredient",
|
|
89
|
+
unit: "blok",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "Apple",
|
|
93
|
+
__component: "food.recipe-ingredient",
|
|
94
|
+
unit: "ks",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
gallery: {
|
|
100
|
+
__component: "food.gallery",
|
|
101
|
+
annotation: "Podívejte se na naše chutné jídlo, pak čtěte dál a ponořte se do kulinářského nebe!",
|
|
102
|
+
main_image: {
|
|
103
|
+
__component: "food.gallery-item",
|
|
104
|
+
image_title: "Kuchařka",
|
|
105
|
+
image_description: "Brožura II",
|
|
106
|
+
},
|
|
50
107
|
gallery: [
|
|
51
108
|
{
|
|
52
|
-
|
|
109
|
+
image_description: "Brožura a listy a vidlice.",
|
|
53
110
|
__component: "food.gallery-item",
|
|
54
|
-
image_description: "Čerstvý!",
|
|
55
111
|
},
|
|
56
112
|
{
|
|
57
|
-
image_title: "
|
|
113
|
+
image_title: "Koření",
|
|
58
114
|
__component: "food.gallery-item",
|
|
59
|
-
image_description: "Mňam!",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
ingredients: [
|
|
63
|
-
{
|
|
64
|
-
name: "Brambory",
|
|
65
|
-
__component: "food.recipe-ingredient",
|
|
66
|
-
unit: "kg",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "Hrášek",
|
|
70
|
-
__component: "food.recipe-ingredient",
|
|
71
|
-
unit: "plechovka",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "Kukuřice",
|
|
75
|
-
__component: "food.recipe-ingredient",
|
|
76
|
-
unit: "plechovka",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "Mayo",
|
|
80
|
-
__component: "food.recipe-ingredient",
|
|
81
|
-
unit: "lžíce",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: "Sýr",
|
|
85
|
-
__component: "food.recipe-ingredient",
|
|
86
|
-
unit: "blok",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "Apple",
|
|
90
|
-
__component: "food.recipe-ingredient",
|
|
91
|
-
unit: "ks",
|
|
92
115
|
},
|
|
93
116
|
],
|
|
94
117
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
locale: "cs",
|
|
119
|
+
},
|
|
120
|
+
dynamicZoneComponentKeys: [],
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
expect(result).toEqual(expected);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("should return transformed 'lesson' entry including Dynamic Zones to strapi create entry structure", () => {
|
|
127
|
+
// EXECUTE
|
|
128
|
+
const result = parsedLocalazyEntryToCreateEntry(
|
|
129
|
+
allModels,
|
|
130
|
+
lessonDZModel.parsedLocalazyEntry,
|
|
131
|
+
lessonDZModel.baseEntry,
|
|
132
|
+
lessonDZModel.uid,
|
|
133
|
+
lessonDZModel.locale
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// VERIFY
|
|
137
|
+
const expected = {
|
|
138
|
+
createEntry: {
|
|
139
|
+
title: "Test: Sčítání",
|
|
140
|
+
description: "Otestujte si své dovednosti, které jsme se naučili v předchozí lekci.",
|
|
141
|
+
lesson_type: [
|
|
142
|
+
{
|
|
143
|
+
title: "Vyberte správnou odpověď",
|
|
144
|
+
__component: "lesson.quiz",
|
|
145
|
+
questions: [
|
|
146
|
+
{
|
|
147
|
+
question: "1 + 1 = ",
|
|
148
|
+
__component: "lesson.survey-question",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
question: "5 + 15 = ",
|
|
152
|
+
__component: "lesson.survey-question",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
question: "Kolik pohárů je na fotce?",
|
|
156
|
+
__component: "lesson.survey-question",
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
answers: [
|
|
160
|
+
{
|
|
161
|
+
correct_answer: "2",
|
|
162
|
+
__component: "lesson.answers",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
correct_answer: "20",
|
|
166
|
+
__component: "lesson.answers",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
correct_answer: "15",
|
|
170
|
+
__component: "lesson.answers",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
locale: "cs",
|
|
176
|
+
},
|
|
177
|
+
dynamicZoneComponentKeys: [
|
|
178
|
+
{
|
|
179
|
+
key: "lesson_type.0.__component",
|
|
180
|
+
component: "lesson.quiz",
|
|
103
181
|
},
|
|
104
|
-
|
|
182
|
+
]
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
expect(result).toEqual(expected);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("should return transformed 'sample-json' entry including Dynamic Zones to strapi create entry structure", () => {
|
|
189
|
+
// EXECUTE
|
|
190
|
+
const result = parsedLocalazyEntryToCreateEntry(
|
|
191
|
+
allModels,
|
|
192
|
+
sampleJSONDZModel.parsedLocalazyEntry,
|
|
193
|
+
sampleJSONDZModel.baseEntry,
|
|
194
|
+
sampleJSONDZModel.uid,
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
// VERIFY
|
|
198
|
+
const expected = {
|
|
199
|
+
createEntry: {
|
|
200
|
+
purpose: "Bar",
|
|
201
|
+
repeatable_component_property: [
|
|
105
202
|
{
|
|
106
|
-
|
|
107
|
-
__component: "
|
|
203
|
+
name: "Položka 1",
|
|
204
|
+
__component: "restaurant.menu-item",
|
|
205
|
+
description: "Nějaký popis",
|
|
108
206
|
},
|
|
109
207
|
{
|
|
110
|
-
|
|
208
|
+
name: "Položka 2",
|
|
209
|
+
__component: "restaurant.menu-item",
|
|
210
|
+
description: "Nějaký další popis",
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
dynamic_property: [
|
|
214
|
+
{
|
|
215
|
+
image_title: "Nějaký název obrázku",
|
|
111
216
|
__component: "food.gallery-item",
|
|
217
|
+
image_description: "Nějaký popis obrázku",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "Přísada I",
|
|
221
|
+
__component: "food.recipe-ingredient",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "První položka CB",
|
|
225
|
+
__component: "food.cookbook-item",
|
|
226
|
+
author_name: "Já",
|
|
227
|
+
ingredients: [
|
|
228
|
+
{
|
|
229
|
+
name: "První Ingr DZ",
|
|
230
|
+
__component: "food.recipe-ingredient",
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
gallery: [
|
|
234
|
+
{
|
|
235
|
+
image_title: "Obrázek G Jedna",
|
|
236
|
+
__component: "food.gallery-item",
|
|
237
|
+
image_description: "Obrázek G Popis Jedna",
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "Druhá přísada",
|
|
243
|
+
__component: "food.recipe-ingredient",
|
|
112
244
|
},
|
|
113
245
|
],
|
|
114
246
|
},
|
|
115
|
-
|
|
247
|
+
dynamicZoneComponentKeys: [
|
|
248
|
+
{
|
|
249
|
+
key: "dynamic_property.2.__component",
|
|
250
|
+
component: "food.cookbook-item",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: "dynamic_property.0.__component",
|
|
254
|
+
component: "food.gallery-item",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
key: "dynamic_property.1.__component",
|
|
258
|
+
component: "food.recipe-ingredient",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
key: "dynamic_property.3.__component",
|
|
262
|
+
component: "food.recipe-ingredient",
|
|
263
|
+
},
|
|
264
|
+
]
|
|
116
265
|
};
|
|
117
266
|
|
|
118
267
|
expect(result).toEqual(expected);
|