@localazy/strapi-plugin 0.1.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 (150) hide show
  1. package/.babelrc +7 -0
  2. package/.eslintrc +7 -0
  3. package/.github/workflows/.build.yml +39 -0
  4. package/.nvmrc +1 -0
  5. package/LICENSE +21 -0
  6. package/README.md +40 -0
  7. package/admin/src/.eslintrc +3 -0
  8. package/admin/src/components/Initializer/index.js +26 -0
  9. package/admin/src/components/PluginIcon/index.js +14 -0
  10. package/admin/src/i18n.js +37 -0
  11. package/admin/src/index.js +106 -0
  12. package/admin/src/modules/@common/components/Icons/Localazy/index.js +12 -0
  13. package/admin/src/modules/@common/components/SideNav/index.js +46 -0
  14. package/admin/src/modules/@common/components/TransferReport/index.js +54 -0
  15. package/admin/src/modules/@common/locale/en.js +13 -0
  16. package/admin/src/modules/@common/services/i18n-service.js +15 -0
  17. package/admin/src/modules/@common/services/project-service.js +15 -0
  18. package/admin/src/modules/@common/services/user-service.js +38 -0
  19. package/admin/src/modules/@common/utils/are-locales-compatible.js +42 -0
  20. package/admin/src/modules/@common/utils/functions/flatten-deep.js +23 -0
  21. package/admin/src/modules/@common/utils/get-default-locale.js +32 -0
  22. package/admin/src/modules/@common/utils/get-header-subtitle.js +21 -0
  23. package/admin/src/modules/@common/utils/get-header-title.js +24 -0
  24. package/admin/src/modules/@common/utils/get-nav.js +35 -0
  25. package/admin/src/modules/@common/utils/history.js +6 -0
  26. package/admin/src/modules/@common/utils/is-plugin-route.js +15 -0
  27. package/admin/src/modules/@common/utils/iso-locales-utils.js +15 -0
  28. package/admin/src/modules/@common/utils/redirect-to-plugin-route.js +22 -0
  29. package/admin/src/modules/@common/utils/sort-by-model-name.js +10 -0
  30. package/admin/src/modules/localazy-download/locale/en.js +20 -0
  31. package/admin/src/modules/localazy-download/services/localazy-download-service.js +16 -0
  32. package/admin/src/modules/localazy-upload/components/ReadDocsButton.js +21 -0
  33. package/admin/src/modules/localazy-upload/locale/en.js +18 -0
  34. package/admin/src/modules/localazy-upload/services/localazy-upload-service.js +16 -0
  35. package/admin/src/modules/login/components/LoginButton/index.js +56 -0
  36. package/admin/src/modules/login/components/LogoutButton/index.js +50 -0
  37. package/admin/src/modules/login/locale/en.js +7 -0
  38. package/admin/src/modules/login/services/localazy-login-service.js +29 -0
  39. package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +292 -0
  40. package/admin/src/modules/plugin-settings/components/Tree/index.js +120 -0
  41. package/admin/src/modules/plugin-settings/components/TreeItem/index.js +48 -0
  42. package/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.js +71 -0
  43. package/admin/src/modules/plugin-settings/functions/has-model-changed.js +85 -0
  44. package/admin/src/modules/plugin-settings/locale/en.js +19 -0
  45. package/admin/src/modules/plugin-settings/services/plugin-settings-service.js +32 -0
  46. package/admin/src/modules/plugin-settings/services/strapi-model-service.js +26 -0
  47. package/admin/src/modules/plugin-settings/utils/__tests__/get-models-tree.test.js +135 -0
  48. package/admin/src/modules/plugin-settings/utils/array-of-models-to-object.js +6 -0
  49. package/admin/src/modules/plugin-settings/utils/find-model-value-by-key.js +8 -0
  50. package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +34 -0
  51. package/admin/src/modules/plugin-settings/utils/get-models-tree.js +73 -0
  52. package/admin/src/modules/settings/components/OverviewItem/index.js +44 -0
  53. package/admin/src/modules/settings/components/OverviewItemLink/index.js +34 -0
  54. package/admin/src/modules/settings/components/PrerequisitiesInfo/index.js +30 -0
  55. package/admin/src/modules/settings/locale/en.js +13 -0
  56. package/admin/src/modules/user/model/localazy-identity.js +14 -0
  57. package/admin/src/modules/user/services/localazy-user-service.js +38 -0
  58. package/admin/src/pages/App/index.js +152 -0
  59. package/admin/src/pages/Download/index.js +179 -0
  60. package/admin/src/pages/Index/index.js +8 -0
  61. package/admin/src/pages/Login/index.js +94 -0
  62. package/admin/src/pages/PluginSettings/index.js +42 -0
  63. package/admin/src/pages/Settings/index.js +120 -0
  64. package/admin/src/pages/Upload/index.js +187 -0
  65. package/admin/src/pluginId.js +5 -0
  66. package/admin/src/plugins/apolloClient.js +33 -0
  67. package/admin/src/state/localazy-identity.js +29 -0
  68. package/admin/src/tests/fixtures/all-models.js +877 -0
  69. package/admin/src/tests/fixtures/restaurant-model.js +230 -0
  70. package/admin/src/translations/en.json +4 -0
  71. package/admin/src/translations/fr.json +1 -0
  72. package/admin/src/utils/createAxiosInstance.js +52 -0
  73. package/admin/src/utils/getTrad.js +5 -0
  74. package/jest.config.js +0 -0
  75. package/package.json +60 -0
  76. package/server/bootstrap.js +5 -0
  77. package/server/config/development/index.js +15 -0
  78. package/server/config/example/index.js +15 -0
  79. package/server/config/index.js +15 -0
  80. package/server/config/production/index.js +16 -0
  81. package/server/config/schema.graphql.js +21 -0
  82. package/server/content-types/index.js +3 -0
  83. package/server/controllers/index.js +19 -0
  84. package/server/controllers/localazy-auth-controller.js +46 -0
  85. package/server/controllers/localazy-project-controller.js +21 -0
  86. package/server/controllers/localazy-transfer-controller.js +469 -0
  87. package/server/controllers/localazy-user-controller.js +24 -0
  88. package/server/controllers/my-controller.js +10 -0
  89. package/server/controllers/plugin-settings-controller.js +17 -0
  90. package/server/controllers/strapi-controller.js +16 -0
  91. package/server/db/model/content-transfer-setup.js +13 -0
  92. package/server/db/model/localazy-user.js +23 -0
  93. package/server/db/model/utils/get-strapi-store.js +9 -0
  94. package/server/destroy.js +5 -0
  95. package/server/index.js +25 -0
  96. package/server/middlewares/index.js +3 -0
  97. package/server/policies/index.js +3 -0
  98. package/server/register.js +5 -0
  99. package/server/routes/index.js +26 -0
  100. package/server/routes/localazy-auth.js +22 -0
  101. package/server/routes/localazy-project.js +14 -0
  102. package/server/routes/localazy-transfer.js +22 -0
  103. package/server/routes/localazy-user.js +30 -0
  104. package/server/routes/plugin-settings.js +22 -0
  105. package/server/routes/strapi.js +22 -0
  106. package/server/services/index.js +21 -0
  107. package/server/services/localazy-auth-service.js +38 -0
  108. package/server/services/localazy-download-service.js +54 -0
  109. package/server/services/localazy-pubapi-service.js +47 -0
  110. package/server/services/localazy-upload-service.js +95 -0
  111. package/server/services/localazy-user-service.js +29 -0
  112. package/server/services/plugin-settings-service.js +30 -0
  113. package/server/services/strapi-i18n-service.js +132 -0
  114. package/server/services/strapi-service.js +23 -0
  115. package/server/tests/fixtures/all-models-with-multimedia.js +1064 -0
  116. package/server/tests/fixtures/all-models.js +869 -0
  117. package/server/tests/fixtures/collection-flattened.js +76 -0
  118. package/server/tests/fixtures/restaurant-flattened.js +46 -0
  119. package/server/tests/fixtures/restaurant-model.js +230 -0
  120. package/server/tests/fixtures/restaurants-entries.js +152 -0
  121. package/server/tests/fixtures/restaurants-pick-paths.js +15 -0
  122. package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +31 -0
  123. package/server/tests/fixtures/stringified-book-cs.js +3 -0
  124. package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +3 -0
  125. package/server/tests/fixtures/stringified-restaurant-cs.js +3 -0
  126. package/server/tests/fixtures/stringified-restaurant-de.js +5 -0
  127. package/server/utils/__tests__/build-populate.test.js +85 -0
  128. package/server/utils/__tests__/flatten-object.test.js +171 -0
  129. package/server/utils/__tests__/get-models-tree.test.js +170 -0
  130. package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +153 -0
  131. package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +172 -0
  132. package/server/utils/__tests__/pick-entries.test.js +83 -0
  133. package/server/utils/build-populate.js +43 -0
  134. package/server/utils/delay.js +6 -0
  135. package/server/utils/flatten-object.js +52 -0
  136. package/server/utils/get-localazy-api.js +22 -0
  137. package/server/utils/get-main-keys-of-nested-array-objects.js +5 -0
  138. package/server/utils/get-models-tree.js +43 -0
  139. package/server/utils/intl-display-name.js +7 -0
  140. package/server/utils/is-generally-applicable-content-type.js +33 -0
  141. package/server/utils/is-localazy-applicable-content-type.js +36 -0
  142. package/server/utils/iso-locales-utils.js +22 -0
  143. package/server/utils/objectivise-entry.js +41 -0
  144. package/server/utils/omit-deep.js +17 -0
  145. package/server/utils/parsed-localazy-entry-to-create-entry.js +115 -0
  146. package/server/utils/parsed-localazy-entry-to-update-entry.js +31 -0
  147. package/server/utils/pick-entries.js +14 -0
  148. package/server/utils/transfer-setup-utils.js +39 -0
  149. package/strapi-admin.js +14 -0
  150. package/strapi-server.js +5 -0
@@ -0,0 +1,76 @@
1
+ module.exports = {
2
+ "plugin::localazy.token[1].access_token": "some access token",
3
+ "plugin::localazy.token[1].createdAt": "2022-04-07T14:50:44.905Z",
4
+ "plugin::localazy.token[1].updatedAt": "2022-04-07T14:50:44.905Z",
5
+ "api::book.book[1].Title": "My First Child Book",
6
+ "api::book.book[1].Author": "David V.",
7
+ "api::book.book[1].Pages": 48,
8
+ "api::book.book[1].createdAt": "2022-03-24T13:26:59.757Z",
9
+ "api::book.book[1].updatedAt": "2022-04-07T19:12:48.481Z",
10
+ "api::book.book[1].publishedAt": "2022-03-24T13:32:20.570Z",
11
+ "api::book.book[1].locale": "en",
12
+ "api::book.book[1].additional_info[2].rich_description":
13
+ "# H1\n## H2\n#### H4\n\n**One** _two_ <u>three</u>... and maybe even more fairytales...",
14
+ "api::book.book[1].additional_info[2].history": "There's no...",
15
+ "api::book.book[1].additional_info[2].excerpt": "Short excerpt",
16
+ "api::book.book[1].additional_info[2].test_variants[3].name":
17
+ "this is a final version",
18
+ "api::restaurant.restaurant[1].title": "Restaurant 1",
19
+ "api::restaurant.restaurant[1].description": "Restaurant 1 description",
20
+ "api::restaurant.restaurant[1].createdAt": "2022-03-10T14:45:51.764Z",
21
+ "api::restaurant.restaurant[1].updatedAt": "2022-04-07T18:34:34.132Z",
22
+ "api::restaurant.restaurant[1].publishedAt": "2022-03-23T11:57:05.812Z",
23
+ "api::restaurant.restaurant[1].locale": "en",
24
+ "api::restaurant.restaurant[1].descs[1].rich_description":
25
+ "restaurant 1 rich_desc",
26
+ "api::restaurant.restaurant[2].title": "Restaurant 2",
27
+ "api::restaurant.restaurant[2].description": "Restaurant 2 description",
28
+ "api::restaurant.restaurant[2].createdAt": "2022-03-14T10:35:27.187Z",
29
+ "api::restaurant.restaurant[2].updatedAt": "2022-04-07T18:34:34.154Z",
30
+ "api::restaurant.restaurant[2].publishedAt": "2022-03-24T13:32:31.066Z",
31
+ "api::restaurant.restaurant[2].locale": "en",
32
+ "api::restaurant.restaurant[3].title": "Full Restaurant",
33
+ "api::restaurant.restaurant[3].description": "With some great description",
34
+ "api::restaurant.restaurant[3].createdAt": "2022-03-24T13:17:22.161Z",
35
+ "api::restaurant.restaurant[3].updatedAt": "2022-04-07T18:34:34.168Z",
36
+ "api::restaurant.restaurant[3].publishedAt": "2022-03-24T13:37:31.870Z",
37
+ "api::restaurant.restaurant[3].locale": "en",
38
+ "api::restaurant.restaurant[3].street": "Testowa",
39
+ "api::restaurant.restaurant[3].city": "Testow",
40
+ "api::restaurant.restaurant[3].country": "Test Rep.",
41
+ "api::restaurant.restaurant[3].recipes[3].name": "Tomato Soup",
42
+ "api::restaurant.restaurant[3].recipes[3].ingredients[2].name": "Tomato",
43
+ "api::restaurant.restaurant[3].recipes[3].ingredients[2].pcs": 4,
44
+ "api::restaurant.restaurant[3].recipes[3].ingredients[2].required": false,
45
+ "api::restaurant.restaurant[3].recipes[3].ingredients[3].name": "Soup",
46
+ "api::restaurant.restaurant[3].recipes[3].ingredients[3].pcs": 1,
47
+ "api::restaurant.restaurant[3].recipes[3].ingredients[3].required": true,
48
+ "api::restaurant.restaurant[3].recipes[3].variants[4].name":
49
+ "Red, yellow, green",
50
+ "api::restaurant.restaurant[3].recipes[2].name": "Beef Broth",
51
+ "api::restaurant.restaurant[3].recipes[2].ingredients[4].name": "Beef",
52
+ "api::restaurant.restaurant[3].recipes[2].ingredients[4].pcs": 1,
53
+ "api::restaurant.restaurant[3].recipes[2].ingredients[4].required": true,
54
+ "api::restaurant.restaurant[3].recipes[2].ingredients[5].name": "Water",
55
+ "api::restaurant.restaurant[3].recipes[2].ingredients[5].pcs": 2,
56
+ "api::restaurant.restaurant[3].recipes[2].ingredients[5].required": true,
57
+ "api::restaurant.restaurant[3].recipes[4].name": "Goulash",
58
+ "api::restaurant.restaurant[3].recipes[4].ingredients[6].name": "Beef meat",
59
+ "api::restaurant.restaurant[3].recipes[4].ingredients[6].pcs": 1,
60
+ "api::restaurant.restaurant[3].recipes[4].ingredients[6].required": true,
61
+ "api::restaurant.restaurant[3].recipes[4].ingredients[7].name": "Pepper",
62
+ "api::restaurant.restaurant[3].recipes[4].ingredients[7].pcs": 4,
63
+ "api::restaurant.restaurant[3].recipes[4].ingredients[8].name":
64
+ "Pepper spices",
65
+ "api::restaurant.restaurant[3].recipes[4].ingredients[8].pcs": 1,
66
+ "api::restaurant.restaurant[3].recipes[4].ingredients[8].required": true,
67
+ "api::restaurant.restaurant[3].recipes[4].ingredients[9].name": "Water",
68
+ "api::restaurant.restaurant[3].recipes[4].ingredients[9].pcs": 1,
69
+ "api::restaurant.restaurant[3].descs[3].rich_description":
70
+ "Another restaurant desc",
71
+ "api::restaurant.restaurant[3].descs[3].history":
72
+ "Est. 2022, based in NY, NY",
73
+ "api::restaurant.restaurant[3].descs[3].excerpt": "Est. 2022",
74
+ "api::restaurant.restaurant[3].descs[3].test_variants[5].name":
75
+ "no such thing...",
76
+ };
@@ -0,0 +1,46 @@
1
+ module.exports = {
2
+ "api::restaurant.restaurant[3].title": "Full Restaurant",
3
+ "api::restaurant.restaurant[3].description": "With some great description",
4
+ "api::restaurant.restaurant[3].createdAt": "2022-03-24T13:17:22.161Z",
5
+ "api::restaurant.restaurant[3].updatedAt": "2022-04-07T18:34:34.168Z",
6
+ "api::restaurant.restaurant[3].publishedAt": "2022-03-24T13:37:31.870Z",
7
+ "api::restaurant.restaurant[3].locale": "en",
8
+ "api::restaurant.restaurant[3].street": "Testowa",
9
+ "api::restaurant.restaurant[3].city": "Testow",
10
+ "api::restaurant.restaurant[3].country": "Test Rep.",
11
+ "api::restaurant.restaurant[3].recipes[2].name": "Beef Broth",
12
+ "api::restaurant.restaurant[3].recipes[2].ingredients[4].name": "Beef",
13
+ "api::restaurant.restaurant[3].recipes[2].ingredients[4].pcs": 1,
14
+ "api::restaurant.restaurant[3].recipes[2].ingredients[4].required": true,
15
+ "api::restaurant.restaurant[3].recipes[2].ingredients[5].name": "Water",
16
+ "api::restaurant.restaurant[3].recipes[2].ingredients[5].pcs": 2,
17
+ "api::restaurant.restaurant[3].recipes[2].ingredients[5].required": true,
18
+ "api::restaurant.restaurant[3].recipes[3].name": "Tomato Soup",
19
+ "api::restaurant.restaurant[3].recipes[3].ingredients[2].name": "Tomato",
20
+ "api::restaurant.restaurant[3].recipes[3].ingredients[2].pcs": 4,
21
+ "api::restaurant.restaurant[3].recipes[3].ingredients[2].required": false,
22
+ "api::restaurant.restaurant[3].recipes[3].ingredients[3].name": "Soup",
23
+ "api::restaurant.restaurant[3].recipes[3].ingredients[3].pcs": 1,
24
+ "api::restaurant.restaurant[3].recipes[3].ingredients[3].required": true,
25
+ "api::restaurant.restaurant[3].recipes[3].variants[4].name":
26
+ "Red, yellow, green",
27
+ "api::restaurant.restaurant[3].recipes[4].name": "Goulash",
28
+ "api::restaurant.restaurant[3].recipes[4].ingredients[6].name": "Beef meat",
29
+ "api::restaurant.restaurant[3].recipes[4].ingredients[6].pcs": 1,
30
+ "api::restaurant.restaurant[3].recipes[4].ingredients[6].required": true,
31
+ "api::restaurant.restaurant[3].recipes[4].ingredients[7].name": "Pepper",
32
+ "api::restaurant.restaurant[3].recipes[4].ingredients[7].pcs": 4,
33
+ "api::restaurant.restaurant[3].recipes[4].ingredients[8].name":
34
+ "Pepper spices",
35
+ "api::restaurant.restaurant[3].recipes[4].ingredients[8].pcs": 1,
36
+ "api::restaurant.restaurant[3].recipes[4].ingredients[8].required": true,
37
+ "api::restaurant.restaurant[3].recipes[4].ingredients[9].name": "Water",
38
+ "api::restaurant.restaurant[3].recipes[4].ingredients[9].pcs": 1,
39
+ "api::restaurant.restaurant[3].descs[3].rich_description":
40
+ "Another restaurant desc",
41
+ "api::restaurant.restaurant[3].descs[3].history":
42
+ "Est. 2022, based in NY, NY",
43
+ "api::restaurant.restaurant[3].descs[3].excerpt": "Est. 2022",
44
+ "api::restaurant.restaurant[3].descs[3].test_variants[5].name":
45
+ "no such thing...",
46
+ };
@@ -0,0 +1,230 @@
1
+ module.exports = {
2
+ kind: "collectionType",
3
+ collectionName: "restaurants",
4
+ info: {
5
+ singularName: "restaurant",
6
+ pluralName: "restaurants",
7
+ displayName: "Restaurant",
8
+ description: "",
9
+ },
10
+ options: {
11
+ draftAndPublish: true,
12
+ },
13
+ pluginOptions: {
14
+ i18n: {
15
+ localized: true,
16
+ },
17
+ },
18
+ attributes: {
19
+ title: {
20
+ pluginOptions: {
21
+ i18n: {
22
+ localized: true,
23
+ },
24
+ },
25
+ type: "string",
26
+ required: true,
27
+ },
28
+ description: {
29
+ pluginOptions: {
30
+ i18n: {
31
+ localized: true,
32
+ },
33
+ },
34
+ type: "text",
35
+ },
36
+ books: {
37
+ type: "relation",
38
+ relation: "oneToMany",
39
+ target: "api::book.book",
40
+ },
41
+ recipes: {
42
+ type: "component",
43
+ repeatable: true,
44
+ pluginOptions: {
45
+ i18n: {
46
+ localized: true,
47
+ },
48
+ },
49
+ component: "food.recipe",
50
+ },
51
+ descs: {
52
+ type: "component",
53
+ repeatable: false,
54
+ pluginOptions: {
55
+ i18n: {
56
+ localized: true,
57
+ },
58
+ },
59
+ component: "food.pub-component-1",
60
+ },
61
+ street: {
62
+ pluginOptions: {
63
+ i18n: {
64
+ localized: true,
65
+ },
66
+ },
67
+ type: "string",
68
+ },
69
+ city: {
70
+ pluginOptions: {
71
+ i18n: {
72
+ localized: true,
73
+ },
74
+ },
75
+ type: "string",
76
+ },
77
+ country: {
78
+ pluginOptions: {
79
+ i18n: {
80
+ localized: true,
81
+ },
82
+ },
83
+ type: "string",
84
+ },
85
+ createdAt: {
86
+ type: "datetime",
87
+ },
88
+ updatedAt: {
89
+ type: "datetime",
90
+ },
91
+ publishedAt: {
92
+ type: "datetime",
93
+ configurable: false,
94
+ writable: true,
95
+ visible: false,
96
+ },
97
+ createdBy: {
98
+ type: "relation",
99
+ relation: "oneToOne",
100
+ target: "admin::user",
101
+ configurable: false,
102
+ writable: false,
103
+ visible: false,
104
+ useJoinTable: false,
105
+ private: true,
106
+ },
107
+ updatedBy: {
108
+ type: "relation",
109
+ relation: "oneToOne",
110
+ target: "admin::user",
111
+ configurable: false,
112
+ writable: false,
113
+ visible: false,
114
+ useJoinTable: false,
115
+ private: true,
116
+ },
117
+ localizations: {
118
+ writable: true,
119
+ private: false,
120
+ configurable: false,
121
+ visible: false,
122
+ type: "relation",
123
+ relation: "oneToMany",
124
+ target: "api::restaurant.restaurant",
125
+ },
126
+ locale: {
127
+ writable: true,
128
+ private: false,
129
+ configurable: false,
130
+ visible: false,
131
+ type: "string",
132
+ },
133
+ },
134
+ __schema__: {
135
+ collectionName: "restaurants",
136
+ info: {
137
+ singularName: "restaurant",
138
+ pluralName: "restaurants",
139
+ displayName: "Restaurant",
140
+ description: "",
141
+ },
142
+ options: {
143
+ draftAndPublish: true,
144
+ },
145
+ pluginOptions: {
146
+ i18n: {
147
+ localized: true,
148
+ },
149
+ },
150
+ attributes: {
151
+ title: {
152
+ pluginOptions: {
153
+ i18n: {
154
+ localized: true,
155
+ },
156
+ },
157
+ type: "string",
158
+ required: true,
159
+ },
160
+ description: {
161
+ pluginOptions: {
162
+ i18n: {
163
+ localized: true,
164
+ },
165
+ },
166
+ type: "text",
167
+ },
168
+ books: {
169
+ type: "relation",
170
+ relation: "oneToMany",
171
+ target: "api::book.book",
172
+ },
173
+ recipes: {
174
+ type: "component",
175
+ repeatable: true,
176
+ pluginOptions: {
177
+ i18n: {
178
+ localized: true,
179
+ },
180
+ },
181
+ component: "food.recipe",
182
+ },
183
+ descs: {
184
+ type: "component",
185
+ repeatable: false,
186
+ pluginOptions: {
187
+ i18n: {
188
+ localized: true,
189
+ },
190
+ },
191
+ component: "food.pub-component-1",
192
+ },
193
+ street: {
194
+ pluginOptions: {
195
+ i18n: {
196
+ localized: true,
197
+ },
198
+ },
199
+ type: "string",
200
+ },
201
+ city: {
202
+ pluginOptions: {
203
+ i18n: {
204
+ localized: true,
205
+ },
206
+ },
207
+ type: "string",
208
+ },
209
+ country: {
210
+ pluginOptions: {
211
+ i18n: {
212
+ localized: true,
213
+ },
214
+ },
215
+ type: "string",
216
+ },
217
+ },
218
+ kind: "collectionType",
219
+ },
220
+ modelType: "contentType",
221
+ modelName: "restaurant",
222
+ connection: "default",
223
+ uid: "api::restaurant.restaurant",
224
+ apiName: "restaurant",
225
+ globalId: "Restaurant",
226
+ actions: {},
227
+ lifecycles: {},
228
+ singularName: "restaurant",
229
+ tableName: "restaurants",
230
+ };
@@ -0,0 +1,152 @@
1
+ module.exports = [
2
+ {
3
+ id: 1,
4
+ title: "Restaurant 1",
5
+ description: "Restaurant 1 description",
6
+ createdAt: "2022-03-10T14:45:51.764Z",
7
+ updatedAt: "2022-04-07T18:34:34.132Z",
8
+ publishedAt: "2022-03-23T11:57:05.812Z",
9
+ locale: "en",
10
+ street: null,
11
+ city: null,
12
+ country: null,
13
+ recipes: [
14
+ {
15
+ id: 1,
16
+ name: null,
17
+ ingredients: [
18
+ {
19
+ id: 1,
20
+ name: null,
21
+ pcs: null,
22
+ required: null,
23
+ },
24
+ ],
25
+ variants: {
26
+ id: 1,
27
+ name: null,
28
+ },
29
+ },
30
+ ],
31
+ descs: {
32
+ id: 1,
33
+ rich_description: "restaurant 1 rich_desc",
34
+ history: null,
35
+ excerpt: null,
36
+ test_variants: {
37
+ id: 2,
38
+ name: null,
39
+ },
40
+ },
41
+ },
42
+ {
43
+ id: 2,
44
+ title: "Restaurant 2",
45
+ description: "Restaurant 2 description",
46
+ createdAt: "2022-03-14T10:35:27.187Z",
47
+ updatedAt: "2022-04-07T18:34:34.154Z",
48
+ publishedAt: "2022-03-24T13:32:31.066Z",
49
+ locale: "en",
50
+ street: null,
51
+ city: null,
52
+ country: null,
53
+ recipes: [],
54
+ descs: null,
55
+ },
56
+ {
57
+ id: 3,
58
+ title: "Full Restaurant",
59
+ description: "With some great description",
60
+ createdAt: "2022-03-24T13:17:22.161Z",
61
+ updatedAt: "2022-04-07T18:34:34.168Z",
62
+ publishedAt: "2022-03-24T13:37:31.870Z",
63
+ locale: "en",
64
+ street: "Testowa",
65
+ city: "Testow",
66
+ country: "Test Rep.",
67
+ recipes: [
68
+ {
69
+ id: 3,
70
+ name: "Tomato Soup",
71
+ ingredients: [
72
+ {
73
+ id: 2,
74
+ name: "Tomato",
75
+ pcs: 4,
76
+ required: false,
77
+ },
78
+ {
79
+ id: 3,
80
+ name: "Soup",
81
+ pcs: 1,
82
+ required: true,
83
+ },
84
+ ],
85
+ variants: {
86
+ id: 4,
87
+ name: "Red, yellow, green",
88
+ },
89
+ },
90
+ {
91
+ id: 2,
92
+ name: "Beef Broth",
93
+ ingredients: [
94
+ {
95
+ id: 4,
96
+ name: "Beef",
97
+ pcs: 1,
98
+ required: true,
99
+ },
100
+ {
101
+ id: 5,
102
+ name: "Water",
103
+ pcs: 2,
104
+ required: true,
105
+ },
106
+ ],
107
+ variants: null,
108
+ },
109
+ {
110
+ id: 4,
111
+ name: "Goulash",
112
+ ingredients: [
113
+ {
114
+ id: 6,
115
+ name: "Beef meat",
116
+ pcs: 1,
117
+ required: true,
118
+ },
119
+ {
120
+ id: 7,
121
+ name: "Pepper",
122
+ pcs: 4,
123
+ required: null,
124
+ },
125
+ {
126
+ id: 8,
127
+ name: "Pepper spices",
128
+ pcs: 1,
129
+ required: true,
130
+ },
131
+ {
132
+ id: 9,
133
+ name: "Water",
134
+ pcs: 1,
135
+ required: null,
136
+ },
137
+ ],
138
+ variants: null,
139
+ },
140
+ ],
141
+ descs: {
142
+ id: 3,
143
+ rich_description: "Another restaurant desc",
144
+ history: "Est. 2022, based in NY, NY",
145
+ excerpt: "Est. 2022",
146
+ test_variants: {
147
+ id: 5,
148
+ name: "no such thing...",
149
+ },
150
+ },
151
+ },
152
+ ];
@@ -0,0 +1,15 @@
1
+ module.exports = (uidPrefix = "") => [
2
+ `${uidPrefix}.title`,
3
+ `${uidPrefix}.description`,
4
+ `${uidPrefix}.recipes.name`,
5
+ `${uidPrefix}.recipes.ingredients.name`,
6
+ `${uidPrefix}.recipes.variants.name`,
7
+ `${uidPrefix}.descs.rich_description`,
8
+ `${uidPrefix}.descs.history`,
9
+ `${uidPrefix}.descs.excerpt`,
10
+ `${uidPrefix}.descs.test_variants.name`,
11
+ `${uidPrefix}.street`,
12
+ `${uidPrefix}.city`,
13
+ `${uidPrefix}.country`,
14
+ `${uidPrefix}.id`,
15
+ ];
@@ -0,0 +1,31 @@
1
+ module.exports = {
2
+ id: 29,
3
+ Title: "Kniha s obálkou 2",
4
+ Author: null,
5
+ Pages: null,
6
+ non_localizable_name: "Non localizable book for kids",
7
+ additional_info: {
8
+ id: 38,
9
+ rich_description: "RD",
10
+ history: "H",
11
+ excerpt: "E",
12
+ test_variants: {
13
+ id: 38,
14
+ name: "Nejsou k dispozici žádné varianty",
15
+ },
16
+ },
17
+ seo_setup: [
18
+ {
19
+ id: 21,
20
+ seo_desc: "nastavení 1",
21
+ main_image: null,
22
+ rest: null,
23
+ },
24
+ {
25
+ id: 22,
26
+ seo_desc: "nastavení 2",
27
+ main_image: null,
28
+ rest: null,
29
+ },
30
+ ],
31
+ };
@@ -0,0 +1,3 @@
1
+ module.exports =
2
+ // eslint-disable-next-line quotes
3
+ '{"Title":"Moje první dětská kniha","additional_info":[null,null,{"rich_description":"# H1\\n## H2\\n#### H4\\n\\n** Jedna** _dva_ <u>tři</u>... a možná ještě více pohádek...","history":"Není tu žádný...","excerpt":"Krátký výňatek","test_variants":[null,null,null,{"name":"toto je finální verze"}]}]}';
@@ -0,0 +1,3 @@
1
+ module.exports =
2
+ // eslint-disable-next-line quotes
3
+ '{"seo_setup":[null,{"seo_desc":"nastavení 1"},{"seo_desc":"nastavení 2"}],"Title":"Kniha s obálkou 2","additional_info":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,{"rich_description":"RD","history":"H 2","excerpt":"E","test_variants":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,{"name":"Nejsou k dispozici žádné varianty, proč?"}]}]}';
@@ -0,0 +1,3 @@
1
+ module.exports =
2
+ // eslint-disable-next-line quotes
3
+ '{"title":"Plná restaurace","description":"S nějakým skvělým popisem","recipes":[null,null,{"name":"Hovězí vývar","ingredients":[null,null,null,null,{"name":"Hovězí"},{"name":"Voda"}]},{"name":"Rajčatová polévka","ingredients":[null,null,{"name":"rajče"},{"name":"Polévka"}],"variants":[null,null,null,null,{"name":"Červená, žlutá, zelená"}]},{"name":"Guláš","ingredients":[null,null,null,null,null,null,{"name":"Hovězí maso"},{"name":"Pepř"},{"name":"pepř, koření"},{"name":"Voda"}]}],"descs":[null,null,null,{"rich_description":"Další restaurace desc","history":"Est. 2022, se sídlem v NY, NY","excerpt":"Est. 2022","test_variants":[null,null,null,null,null,{"name":"nic takového..."}]}]}';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ module.exports =
4
+ // eslint-disable-next-line quotes
5
+ '{"title":"Volles Restaurant","description":"Mit einer großartigen Beschreibung","recipes":[null,null,{"name":"Rinderbrühe","ingredients":[null,null,null,null,{"name":"Rindfleisch"},{"name":"Wasser"}]},{"name":"Tomatensuppe","ingredients":[null,null,{"name":"Tomate"},{"name":"Suppe"}],"variants":[null,null,null,null,{"name":"Rot, gelb, grün"}]},{"name":"Gulasch","ingredients":[null,null,null,null,null,null,{"name":"Rindfleisch"},{"name":"Pfeffer"},{"name":"Pfeffer-Gewürze"},{"name":"Wasser"}]}],"descs":[null,null,null,{"rich_description":"Ein weiteres Restaurant desc","history":"Est. 2022, mit Sitz in NY, NY","excerpt":"Est. 2022","test_variants":[null,null,null,null,null,{"name":"so etwas nicht..."}]}]}';
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ const buildPopulate = require("../build-populate");
4
+ const allModels = require("../../tests/fixtures/all-models");
5
+
6
+ it("should return basic populate if model does not exist", () => {
7
+ // SETUP
8
+ const models = allModels;
9
+
10
+ // EXECUTE
11
+ const modelUid = "some-non-existing-model";
12
+ const result = buildPopulate(models, modelUid);
13
+
14
+ // VERIFY
15
+ const expected = {
16
+ populate: "*",
17
+ };
18
+ expect(result).toEqual(expected);
19
+ });
20
+
21
+ it("should populate restaurant model correctly", () => {
22
+ // SETUP
23
+ const models = allModels;
24
+
25
+ // EXECUTE
26
+ const modelUid = "api::restaurant.restaurant";
27
+ const result = buildPopulate(models, modelUid);
28
+
29
+ // VERIFY
30
+ const expected = {
31
+ populate: "*",
32
+ recipes: {
33
+ populate: "*",
34
+ ingredients: {
35
+ populate: "*",
36
+ },
37
+ variants: {
38
+ populate: "*",
39
+ },
40
+ },
41
+ descs: {
42
+ populate: "*",
43
+ test_variants: {
44
+ populate: "*",
45
+ },
46
+ },
47
+ };
48
+ expect(result).toEqual(expected);
49
+ });
50
+
51
+ it("should populate single type types model correctly", () => {
52
+ // SETUP
53
+ const models = allModels;
54
+
55
+ // EXECUTE
56
+ const modelUid = "plugin::localazy.token";
57
+ const result = buildPopulate(models, modelUid);
58
+
59
+ // VERIFY
60
+ const expected = {
61
+ populate: "*",
62
+ };
63
+ expect(result).toEqual(expected);
64
+ });
65
+
66
+ it("should populate book model correctly", () => {
67
+ // SETUP
68
+ const models = allModels;
69
+
70
+ // EXECUTE
71
+ const modelUid = "api::book.book";
72
+ const result = buildPopulate(models, modelUid);
73
+
74
+ // VERIFY
75
+ const expected = {
76
+ populate: "*",
77
+ additional_info: {
78
+ populate: "*",
79
+ test_variants: {
80
+ populate: "*",
81
+ },
82
+ },
83
+ };
84
+ expect(result).toEqual(expected);
85
+ });