@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.
Files changed (45) hide show
  1. package/.eslintrc +6 -2
  2. package/.nvmrc +1 -1
  3. package/admin/src/modules/@common/models/supported-content-type-fields.js +8 -0
  4. package/admin/src/modules/plugin-settings/components/Tree/index.js +2 -0
  5. package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +4 -4
  6. package/admin/src/modules/plugin-settings/utils/get-models-tree.js +3 -1
  7. package/package.json +1 -1
  8. package/server/bootstrap.js +15 -1
  9. package/server/controllers/localazy-transfer-controller.js +45 -47
  10. package/server/functions/should-set-downloaded-property.js +16 -0
  11. package/server/models/supported-content-type-fields.js +8 -0
  12. package/server/services/index.js +2 -0
  13. package/server/services/strapi-i18n-service.js +4 -3
  14. package/server/services/strapi-localazy-i18n-service.js +104 -0
  15. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +5761 -0
  16. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +536 -0
  17. package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +35157 -0
  18. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +202 -0
  19. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +2700 -0
  20. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +47 -0
  21. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +169 -0
  22. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +3003 -0
  23. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +2057 -0
  24. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +46 -0
  25. package/server/tests/fixtures/{all-models-with-multimedia.js → strapi-plugin-all-models.js} +717 -540
  26. package/server/utils/__tests__/get-models-tree.test.js +1 -1
  27. package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +74 -107
  28. package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +396 -133
  29. package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +852 -0
  30. package/server/utils/get-full-populate-object.js +56 -0
  31. package/server/utils/get-models-tree.js +3 -1
  32. package/server/utils/model-utils.js +38 -0
  33. package/server/utils/parsed-localazy-entry-to-create-entry.js +24 -24
  34. package/server/utils/parsed-localazy-entry-to-update-entry.js +43 -4
  35. package/server/utils/pick-entries.js +2 -1
  36. package/server/utils/populate-create-update-entry-with-base-entry.js +222 -0
  37. package/server/utils/reset-array-keys-deep.js +19 -0
  38. package/server/utils/transfer-setup-utils.js +14 -0
  39. package/server/tests/fixtures/restaurant-model.js +0 -230
  40. package/server/tests/fixtures/restaurants-entries.js +0 -152
  41. package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +0 -31
  42. package/server/tests/fixtures/stringified-book-cs.js +0 -3
  43. package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +0 -3
  44. package/server/tests/fixtures/stringified-restaurant-cs.js +0 -3
  45. package/server/tests/fixtures/stringified-restaurant-de.js +0 -5
@@ -70,7 +70,7 @@ it("should return a tree all all models", () => {
70
70
  up_users: {
71
71
  __model__: true,
72
72
  username: false,
73
- email: null,
73
+ email: false,
74
74
  provider: false,
75
75
  password: null,
76
76
  resetPasswordToken: false,
@@ -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 stringifiedRestaurantCs = require("../../tests/fixtures/stringified-restaurant-cs");
6
- const stringifiedBookCs = require("../../tests/fixtures/stringified-book-cs");
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
- entry,
20
- uid,
21
- locale
35
+ cookbookModel.parsedLocalazyEntry,
36
+ cookbookModel.baseEntry,
37
+ cookbookModel.uid,
38
+ cookbookModel.locale
22
39
  );
23
40
 
24
41
  // VERIFY
25
42
  const expected = {
26
- locale: "cs",
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
- // id: 2,
33
- __component: "food.recipe",
34
- name: "Hovězí vývar",
35
- ingredients: [
36
- // is repeatable - array
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
- // id: 4,
39
- __component: "food.ingredients",
40
- name: "Hovězí",
52
+ image_title: "Syrové brambory",
53
+ __component: "food.gallery-item",
54
+ image_description: "Čerstvý!",
41
55
  },
42
56
  {
43
- // id: 5,
44
- __component: "food.ingredients",
45
- name: "Voda",
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
- // id: 2,
57
- __component: "food.ingredients",
58
- name: "rajče",
64
+ name: "Brambory",
65
+ __component: "food.recipe-ingredient",
66
+ unit: "kg",
59
67
  },
60
68
  {
61
- // id: 3,
62
- __component: "food.ingredients",
63
- name: "Polévka",
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
- // id: 6,
81
- __component: "food.ingredients",
82
- name: "Hovězí maso",
74
+ name: "Kukuřice",
75
+ __component: "food.recipe-ingredient",
76
+ unit: "plechovka",
83
77
  },
84
78
  {
85
- // id: 7,
86
- __component: "food.ingredients",
87
- name: "Pepř",
79
+ name: "Mayo",
80
+ __component: "food.recipe-ingredient",
81
+ unit: "lžíce",
88
82
  },
89
83
  {
90
- // id: 8,
91
- __component: "food.ingredients",
92
- name: "pepř, koření",
84
+ name: "Sýr",
85
+ __component: "food.recipe-ingredient",
86
+ unit: "blok",
93
87
  },
94
88
  {
95
- // id: 9,
96
- __component: "food.ingredients",
97
- name: "Voda",
89
+ name: "Apple",
90
+ __component: "food.recipe-ingredient",
91
+ unit: "ks",
98
92
  },
99
93
  ],
100
94
  },
101
95
  ],
102
- descs: {
103
- // is not repeatable - object
104
- // id: 3,
105
- __component: "food.pub-component-1",
106
- rich_description: "Další restaurace desc",
107
- history: "Est. 2022, se sídlem v NY, NY",
108
- excerpt: "Est. 2022",
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);