@localazy/strapi-plugin 0.1.9 → 0.1.11-rc.0
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/.eslintrc +6 -2
- package/.nvmrc +1 -1
- package/admin/src/modules/@common/models/supported-content-type-fields.js +8 -0
- package/admin/src/modules/plugin-settings/components/Tree/index.js +2 -0
- package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +4 -4
- package/admin/src/modules/plugin-settings/utils/get-models-tree.js +3 -1
- package/package.json +1 -1
- package/server/bootstrap.js +15 -1
- package/server/controllers/localazy-transfer-controller.js +45 -47
- package/server/functions/should-set-downloaded-property.js +16 -0
- package/server/models/supported-content-type-fields.js +8 -0
- package/server/services/index.js +2 -0
- package/server/services/strapi-i18n-service.js +4 -3
- package/server/services/strapi-localazy-i18n-service.js +104 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +5761 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +536 -0
- package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +35157 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +202 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +2700 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +47 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +169 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +3003 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +2057 -0
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +46 -0
- package/server/tests/fixtures/{all-models-with-multimedia.js → strapi-plugin-all-models.js} +717 -540
- package/server/utils/__tests__/get-models-tree.test.js +1 -1
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +74 -107
- package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +396 -133
- package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +852 -0
- package/server/utils/get-full-populate-object.js +56 -0
- package/server/utils/get-models-tree.js +3 -1
- package/server/utils/model-utils.js +38 -0
- package/server/utils/parsed-localazy-entry-to-create-entry.js +24 -24
- package/server/utils/parsed-localazy-entry-to-update-entry.js +43 -4
- package/server/utils/pick-entries.js +2 -1
- package/server/utils/populate-create-update-entry-with-base-entry.js +222 -0
- package/server/utils/reset-array-keys-deep.js +19 -0
- package/server/utils/transfer-setup-utils.js +14 -0
- package/server/tests/fixtures/restaurant-model.js +0 -230
- package/server/tests/fixtures/restaurants-entries.js +0 -152
- package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +0 -31
- package/server/tests/fixtures/stringified-book-cs.js +0 -3
- package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +0 -3
- package/server/tests/fixtures/stringified-restaurant-cs.js +0 -3
- package/server/tests/fixtures/stringified-restaurant-de.js +0 -5
|
@@ -1,151 +1,118 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const parsedLocalazyEntryToCreateEntry = require("../parsed-localazy-entry-to-create-entry");
|
|
4
|
-
const allModels = require("../../tests/fixtures/all-models");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const allModels = require("../../tests/fixtures/strapi-plugin-all-models");
|
|
5
|
+
const simpleMenuWithMediaModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu");
|
|
6
|
+
const cookbookModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook");
|
|
7
7
|
|
|
8
8
|
describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
9
|
-
it("should return transformed restaurant entry to strapi create entry structure", () => {
|
|
9
|
+
it("should return transformed 'restaurant-simple-menu' entry to strapi create entry structure", () => {
|
|
10
|
+
// EXECUTE
|
|
11
|
+
const result = parsedLocalazyEntryToCreateEntry(
|
|
12
|
+
allModels,
|
|
13
|
+
simpleMenuWithMediaModel.parsedLocalazyEntry,
|
|
14
|
+
simpleMenuWithMediaModel.baseEntry,
|
|
15
|
+
simpleMenuWithMediaModel.uid,
|
|
16
|
+
simpleMenuWithMediaModel.locale
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// VERIFY
|
|
20
|
+
const expected = {
|
|
21
|
+
name: "hlad, okno",
|
|
22
|
+
description: "Orientální pouliční jídlo v ústech rychlé a snadné!",
|
|
23
|
+
locale: "cs",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
expect(result).toEqual(expected);
|
|
27
|
+
});
|
|
28
|
+
it("should return transformed 'cookbook' entry to strapi create entry structure", () => {
|
|
10
29
|
// SETUP
|
|
11
|
-
const uid = "api::restaurant.restaurant";
|
|
12
|
-
const entry = JSON.parse(stringifiedRestaurantCs);
|
|
13
30
|
|
|
14
|
-
const locale = "cs";
|
|
15
31
|
|
|
16
32
|
// EXECUTE
|
|
17
33
|
const result = parsedLocalazyEntryToCreateEntry(
|
|
18
34
|
allModels,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
cookbookModel.parsedLocalazyEntry,
|
|
36
|
+
cookbookModel.baseEntry,
|
|
37
|
+
cookbookModel.uid,
|
|
38
|
+
cookbookModel.locale
|
|
22
39
|
);
|
|
23
40
|
|
|
24
41
|
// VERIFY
|
|
25
42
|
const expected = {
|
|
26
|
-
|
|
27
|
-
title: "Plná restaurace",
|
|
28
|
-
description: "S nějakým skvělým popisem",
|
|
43
|
+
title: "Pro každý den v roce",
|
|
29
44
|
recipes: [
|
|
30
|
-
// is repeatable - array
|
|
31
45
|
{
|
|
32
|
-
|
|
33
|
-
__component: "food.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
name: "Bramborový salát",
|
|
47
|
+
__component: "food.cookbook-item",
|
|
48
|
+
recipe: "Oloupejte brambory, smíchejte je se všemi ingrediencemi a máte hotovo. Bon apetit!",
|
|
49
|
+
author_name: "Mr. Bramborová hlava",
|
|
50
|
+
gallery: [
|
|
37
51
|
{
|
|
38
|
-
|
|
39
|
-
__component: "food.
|
|
40
|
-
|
|
52
|
+
image_title: "Syrové brambory",
|
|
53
|
+
__component: "food.gallery-item",
|
|
54
|
+
image_description: "Čerstvý!",
|
|
41
55
|
},
|
|
42
56
|
{
|
|
43
|
-
|
|
44
|
-
__component: "food.
|
|
45
|
-
|
|
57
|
+
image_title: "Salát",
|
|
58
|
+
__component: "food.gallery-item",
|
|
59
|
+
image_description: "Mňam!",
|
|
46
60
|
},
|
|
47
61
|
],
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
// id: 3,
|
|
51
|
-
__component: "food.recipe",
|
|
52
|
-
name: "Rajčatová polévka",
|
|
53
62
|
ingredients: [
|
|
54
|
-
// is repeatable - array
|
|
55
63
|
{
|
|
56
|
-
|
|
57
|
-
__component: "food.
|
|
58
|
-
|
|
64
|
+
name: "Brambory",
|
|
65
|
+
__component: "food.recipe-ingredient",
|
|
66
|
+
unit: "kg",
|
|
59
67
|
},
|
|
60
68
|
{
|
|
61
|
-
|
|
62
|
-
__component: "food.
|
|
63
|
-
|
|
69
|
+
name: "Hrášek",
|
|
70
|
+
__component: "food.recipe-ingredient",
|
|
71
|
+
unit: "plechovka",
|
|
64
72
|
},
|
|
65
|
-
],
|
|
66
|
-
variants: {
|
|
67
|
-
// is not repeatable - object
|
|
68
|
-
// id: 4,
|
|
69
|
-
__component: "food.ingredient-variants",
|
|
70
|
-
name: "Červená, žlutá, zelená",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
// id: 4,
|
|
75
|
-
__component: "food.recipe",
|
|
76
|
-
name: "Guláš",
|
|
77
|
-
ingredients: [
|
|
78
|
-
// is repeatable - array
|
|
79
73
|
{
|
|
80
|
-
|
|
81
|
-
__component: "food.
|
|
82
|
-
|
|
74
|
+
name: "Kukuřice",
|
|
75
|
+
__component: "food.recipe-ingredient",
|
|
76
|
+
unit: "plechovka",
|
|
83
77
|
},
|
|
84
78
|
{
|
|
85
|
-
|
|
86
|
-
__component: "food.
|
|
87
|
-
|
|
79
|
+
name: "Mayo",
|
|
80
|
+
__component: "food.recipe-ingredient",
|
|
81
|
+
unit: "lžíce",
|
|
88
82
|
},
|
|
89
83
|
{
|
|
90
|
-
|
|
91
|
-
__component: "food.
|
|
92
|
-
|
|
84
|
+
name: "Sýr",
|
|
85
|
+
__component: "food.recipe-ingredient",
|
|
86
|
+
unit: "blok",
|
|
93
87
|
},
|
|
94
88
|
{
|
|
95
|
-
|
|
96
|
-
__component: "food.
|
|
97
|
-
|
|
89
|
+
name: "Apple",
|
|
90
|
+
__component: "food.recipe-ingredient",
|
|
91
|
+
unit: "ks",
|
|
98
92
|
},
|
|
99
93
|
],
|
|
100
94
|
},
|
|
101
95
|
],
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
test_variants: {
|
|
110
|
-
// is not repeatable - object
|
|
111
|
-
// id: 5,
|
|
112
|
-
__component: "food.ingredient-variants",
|
|
113
|
-
name: "nic takového...",
|
|
96
|
+
gallery: {
|
|
97
|
+
__component: "food.gallery",
|
|
98
|
+
annotation: "Podívejte se na naše chutné jídlo, pak čtěte dál a ponořte se do kulinářského nebe!",
|
|
99
|
+
main_image: {
|
|
100
|
+
__component: "food.gallery-item",
|
|
101
|
+
image_title: "Kuchařka",
|
|
102
|
+
image_description: "Brožura II",
|
|
114
103
|
},
|
|
104
|
+
gallery: [
|
|
105
|
+
{
|
|
106
|
+
image_description: "Brožura a listy a vidlice.",
|
|
107
|
+
__component: "food.gallery-item",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
image_title: "Koření",
|
|
111
|
+
__component: "food.gallery-item",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
115
114
|
},
|
|
116
|
-
};
|
|
117
|
-
expect(result).toEqual(expected);
|
|
118
|
-
});
|
|
119
|
-
it("should return transformed book entry to strapi create entry structure", () => {
|
|
120
|
-
// SETUP
|
|
121
|
-
const uid = "api::book.book";
|
|
122
|
-
const entry = JSON.parse(stringifiedBookCs);
|
|
123
|
-
|
|
124
|
-
const locale = "cs";
|
|
125
|
-
|
|
126
|
-
// EXECUTE
|
|
127
|
-
const result = parsedLocalazyEntryToCreateEntry(
|
|
128
|
-
allModels,
|
|
129
|
-
entry,
|
|
130
|
-
uid,
|
|
131
|
-
locale
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
// VERIFY
|
|
135
|
-
const expected = {
|
|
136
115
|
locale: "cs",
|
|
137
|
-
Title: "Moje první dětská kniha",
|
|
138
|
-
additional_info: {
|
|
139
|
-
__component: "food.pub-component-1",
|
|
140
|
-
rich_description:
|
|
141
|
-
"# H1\n## H2\n#### H4\n\n** Jedna** _dva_ <u>tři</u>... a možná ještě více pohádek...",
|
|
142
|
-
history: "Není tu žádný...",
|
|
143
|
-
excerpt: "Krátký výňatek",
|
|
144
|
-
test_variants: {
|
|
145
|
-
__component: "food.ingredient-variants",
|
|
146
|
-
name: "toto je finální verze",
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
116
|
};
|
|
150
117
|
|
|
151
118
|
expect(result).toEqual(expected);
|