@localazy/strapi-plugin 0.1.7 → 0.1.10
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/.github/workflows/.build.yml +2 -13
- package/.nvmrc +1 -1
- package/admin/src/modules/@common/components/PluginPageLoader/index.js +22 -0
- package/admin/src/modules/@common/services/product-analytics-service.js +67 -0
- package/admin/src/modules/@common/utils/format-number.js +1 -0
- package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +33 -22
- package/admin/src/modules/plugin-settings/components/ContentTransferSetupEmpty/index.js +86 -0
- package/admin/src/modules/plugin-settings/components/Tree/index.js +10 -1
- package/admin/src/modules/plugin-settings/locale/en.js +7 -0
- package/admin/src/modules/plugin-settings/services/plugin-settings-service.js +23 -0
- package/admin/src/pages/App/index.js +4 -2
- package/admin/src/pages/Download/index.js +16 -1
- package/admin/src/pages/Login/index.js +8 -1
- package/admin/src/pages/Settings/index.js +17 -3
- package/admin/src/pages/Upload/index.js +17 -1
- package/admin/src/plugins/analytics-service.js +14 -0
- package/admin/src/utils/createPluginConnectorAxiosInstance.js +45 -0
- package/package.json +4 -4
- package/server/config/index.js +10 -5
- package/server/config/local/index.js +15 -0
- package/server/controllers/localazy-transfer-controller.js +5 -2
- package/server/controllers/plugin-settings-controller.js +14 -0
- package/server/db/model/plugin-settings.js +13 -0
- package/server/routes/plugin-settings.js +16 -0
- package/server/services/plugin-settings-service.js +28 -7
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +58 -88
- package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +79 -132
- package/server/utils/parsed-localazy-entry-to-create-entry.js +23 -6
- package/server/utils/parsed-localazy-entry-to-update-entry.js +5 -1
- package/server/utils/pick-entries.js +2 -1
- package/server/utils/reset-array-keys-deep.js +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localazy/strapi-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "The official Strapi Plugin by Localazy.",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"name": "localazy",
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@localazy/ts-api": "^1.0.6",
|
|
31
|
-
"@strapi/design-system": "^1.0.0",
|
|
32
|
-
"@strapi/icons": "^1.0.0",
|
|
33
31
|
"deep-keys": "^0.5.0",
|
|
34
32
|
"i18next": "^21.6.13",
|
|
35
33
|
"isomorphic-fetch": "^3.0.0",
|
|
@@ -41,7 +39,9 @@
|
|
|
41
39
|
"styled-components": "^5.3.3"
|
|
42
40
|
},
|
|
43
41
|
"peerDependencies": {
|
|
44
|
-
"@strapi/strapi": "^4.0.0"
|
|
42
|
+
"@strapi/strapi": "^4.0.0",
|
|
43
|
+
"@strapi/design-system": "^1.0.0",
|
|
44
|
+
"@strapi/icons": "^1.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/plugin-transform-modules-commonjs": "^7.17.7",
|
package/server/config/index.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// depending on the STRAPI_ADMIN_LOCALAZY_ENV, use the correct config
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
let config = require("./production/index");
|
|
5
|
+
|
|
6
|
+
if (process.env.STRAPI_ADMIN_LOCALAZY_ENV === "local") {
|
|
7
|
+
config = require("./local/index");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (process.env.STRAPI_ADMIN_LOCALAZY_ENV === "development") {
|
|
11
|
+
config = require("./development/index");
|
|
12
|
+
}
|
|
8
13
|
|
|
9
14
|
module.exports = {
|
|
10
15
|
default: {
|
|
11
16
|
// Default plugin configuration, merged with the user configuration
|
|
12
17
|
...(config || {}),
|
|
13
18
|
},
|
|
14
|
-
validator() {},
|
|
19
|
+
validator() { },
|
|
15
20
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
LOCALAZY_OAUTH_URL: "https://testing.localazy.com/oauth/authorize",
|
|
5
|
+
LOCALAZY_OAUTH_APP_CLIENT_ID: "18503917571895066465",
|
|
6
|
+
LOCALAZY_PLUGIN_CONNECTOR_API_URL: "http://localhost:3000",
|
|
7
|
+
LOCALAZY_PUBLIC_API_URL: "https://testing.localazy.com/pubapi",
|
|
8
|
+
LOCALAZY_PLUGIN_ID: "1",
|
|
9
|
+
LOCALAZY_DEFAULT_FILE_NAME: "strapi.json",
|
|
10
|
+
LOCALAZY_DEFAULT_FILE_PATH: "",
|
|
11
|
+
LOCALAZY_DEFAULT_FILE_EXTENSION: "json",
|
|
12
|
+
LOCALAZY_DEFAULT_LOCALE: "en",
|
|
13
|
+
LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
|
|
14
|
+
LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
|
|
15
|
+
};
|
|
@@ -17,6 +17,7 @@ const parsedLocalazyEntryToCreateEntry = require("../utils/parsed-localazy-entry
|
|
|
17
17
|
const parsedLocalazyEntryToUpdateEntry = require("../utils/parsed-localazy-entry-to-update-entry");
|
|
18
18
|
const set = require("lodash/set");
|
|
19
19
|
const merge = require("lodash/merge");
|
|
20
|
+
const isEmpty = require("lodash/isEmpty");
|
|
20
21
|
|
|
21
22
|
module.exports = {
|
|
22
23
|
async upload(ctx) {
|
|
@@ -367,7 +368,7 @@ module.exports = {
|
|
|
367
368
|
});
|
|
368
369
|
baseEntry = merge(baseEntry, baseEntryDeep);
|
|
369
370
|
|
|
370
|
-
if (
|
|
371
|
+
if (isEmpty(baseEntry)) {
|
|
371
372
|
const message = `Source language entry ${uid}[${id}] does not exist anymore, skipping...`;
|
|
372
373
|
throw new Error(message);
|
|
373
374
|
}
|
|
@@ -394,6 +395,7 @@ module.exports = {
|
|
|
394
395
|
const createEntry = parsedLocalazyEntryToCreateEntry(
|
|
395
396
|
strapiContentTypesModels,
|
|
396
397
|
translatedModel,
|
|
398
|
+
baseEntry,
|
|
397
399
|
uid,
|
|
398
400
|
isoStrapi
|
|
399
401
|
);
|
|
@@ -419,7 +421,7 @@ module.exports = {
|
|
|
419
421
|
try {
|
|
420
422
|
const localizedEntryId =
|
|
421
423
|
baseEntryCurrentLanguageLocalizationInfo.id;
|
|
422
|
-
const populate = await StrapiService.getPopulateObject(uid);
|
|
424
|
+
const populate = await StrapiService.getPopulateObject(uid);
|
|
423
425
|
const localizedEntry = await strapi.entityService.findOne(
|
|
424
426
|
uid,
|
|
425
427
|
localizedEntryId,
|
|
@@ -432,6 +434,7 @@ module.exports = {
|
|
|
432
434
|
strapiContentTypesModels,
|
|
433
435
|
translatedModel,
|
|
434
436
|
localizedEntry,
|
|
437
|
+
baseEntry,
|
|
435
438
|
uid
|
|
436
439
|
);
|
|
437
440
|
|
|
@@ -14,4 +14,18 @@ module.exports = {
|
|
|
14
14
|
.service("pluginSettingsService")
|
|
15
15
|
.updateContentTransferSetup(ctx.request.body);
|
|
16
16
|
},
|
|
17
|
+
|
|
18
|
+
async getPluginSettings(ctx) {
|
|
19
|
+
ctx.body = await strapi
|
|
20
|
+
.plugin("localazy")
|
|
21
|
+
.service("pluginSettingsService")
|
|
22
|
+
.getPluginSettings();
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
async updatePluginSettings(ctx) {
|
|
26
|
+
ctx.body = await strapi
|
|
27
|
+
.plugin("localazy")
|
|
28
|
+
.service("pluginSettingsService")
|
|
29
|
+
.updatePluginSettings(ctx.request.body);
|
|
30
|
+
}
|
|
17
31
|
};
|
|
@@ -19,4 +19,20 @@ module.exports = [
|
|
|
19
19
|
policies: [],
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: `${ROUTE_PREFIX}/plugin-settings`,
|
|
25
|
+
handler: "pluginSettingsController.getPluginSettings",
|
|
26
|
+
config: {
|
|
27
|
+
policies: [],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
method: "PUT",
|
|
32
|
+
path: `${ROUTE_PREFIX}/plugin-settings`,
|
|
33
|
+
handler: "pluginSettingsController.updatePluginSettings",
|
|
34
|
+
config: {
|
|
35
|
+
policies: [],
|
|
36
|
+
},
|
|
37
|
+
}
|
|
22
38
|
];
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const contentTransferSetupModel = require("../db/model/content-transfer-setup");
|
|
4
|
+
|
|
5
|
+
const pluginSettingsModel = require("../db/model/plugin-settings");
|
|
6
|
+
// {
|
|
7
|
+
// KEY,
|
|
8
|
+
// emptyPluginSettings,
|
|
9
|
+
// } = require("../db/model/plugin-settings");
|
|
7
10
|
const getStrapiStore = require("../db/model/utils/get-strapi-store");
|
|
8
11
|
|
|
9
12
|
module.exports = ({ strapi }) => ({
|
|
10
13
|
async getContentTransferSetup() {
|
|
11
14
|
const pluginStore = getStrapiStore(strapi);
|
|
12
|
-
const setup = await pluginStore.get({ key: KEY });
|
|
15
|
+
const setup = await pluginStore.get({ key: contentTransferSetupModel.KEY });
|
|
13
16
|
|
|
14
|
-
return setup || emptyContentTransferSetup;
|
|
17
|
+
return setup || contentTransferSetupModel.emptyContentTransferSetup;
|
|
15
18
|
},
|
|
16
19
|
|
|
17
20
|
async updateContentTransferSetup(setup) {
|
|
@@ -21,10 +24,28 @@ module.exports = ({ strapi }) => ({
|
|
|
21
24
|
};
|
|
22
25
|
const pluginStore = getStrapiStore(strapi);
|
|
23
26
|
await pluginStore.set({
|
|
24
|
-
key: KEY,
|
|
27
|
+
key: contentTransferSetupModel.KEY,
|
|
25
28
|
value: newSetup,
|
|
26
29
|
});
|
|
27
30
|
|
|
28
31
|
return newSetup;
|
|
29
32
|
},
|
|
33
|
+
|
|
34
|
+
async getPluginSettings() {
|
|
35
|
+
const pluginStore = getStrapiStore(strapi);
|
|
36
|
+
const settings = await pluginStore.get({ key: pluginSettingsModel.KEY });
|
|
37
|
+
|
|
38
|
+
return settings || pluginSettingsModel.emptyPluginSettings;
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async updatePluginSettings(settings) {
|
|
42
|
+
const newSettings = settings;
|
|
43
|
+
const pluginStore = getStrapiStore(strapi);
|
|
44
|
+
await pluginStore.set({
|
|
45
|
+
key: pluginSettingsModel.KEY,
|
|
46
|
+
value: newSettings,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return newSettings;
|
|
50
|
+
},
|
|
30
51
|
});
|
|
@@ -15,105 +15,74 @@ describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
|
15
15
|
|
|
16
16
|
// EXECUTE
|
|
17
17
|
const result = parsedLocalazyEntryToCreateEntry(
|
|
18
|
-
allModels,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
JSON.parse("[{\"kind\":\"singleType\",\"collectionName\":\"a_first_positioned_some_test_single_types\",\"info\":{\"singularName\":\"a-first-positioned-some-test-single-type\",\"pluralName\":\"a-first-positioned-some-test-single-types\",\"displayName\":\"a_first_positioned_some_test_single_type\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"label\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::a-first-positioned-some-test-single-type.a-first-positioned-some-test-single-type\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"a_first_positioned_some_test_single_types\",\"info\":{\"singularName\":\"a-first-positioned-some-test-single-type\",\"pluralName\":\"a-first-positioned-some-test-single-types\",\"displayName\":\"a_first_positioned_some_test_single_type\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"label\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"singleType\"},\"modelType\":\"contentType\",\"modelName\":\"a-first-positioned-some-test-single-type\",\"connection\":\"default\",\"uid\":\"api::a-first-positioned-some-test-single-type.a-first-positioned-some-test-single-type\",\"apiName\":\"a-first-positioned-some-test-single-type\",\"globalId\":\"AFirstPositionedSomeTestSingleType\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"a-first-positioned-some-test-single-type\",\"tableName\":\"a_first_positioned_some_test_single_types\"},{\"kind\":\"collectionType\",\"collectionName\":\"books\",\"info\":{\"singularName\":\"book\",\"pluralName\":\"books\",\"displayName\":\"Book\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"Title\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Author\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Pages\":{\"type\":\"integer\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"additional_info\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.pub-component-1\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"cover\":{\"type\":\"relation\",\"relation\":\"morphOne\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"presentations\":{\"type\":\"relation\",\"relation\":\"morphMany\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"seo_setup\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"seo.gallery\"},\"non_localizable_name\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"books\",\"info\":{\"singularName\":\"book\",\"pluralName\":\"books\",\"displayName\":\"Book\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"Title\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Author\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Pages\":{\"type\":\"integer\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"additional_info\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.pub-component-1\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"cover\":{\"type\":\"media\",\"multiple\":false,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"],\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"presentations\":{\"type\":\"media\",\"multiple\":true,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"],\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"seo_setup\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"seo.gallery\"},\"non_localizable_name\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"book\",\"connection\":\"default\",\"uid\":\"api::book.book\",\"apiName\":\"book\",\"globalId\":\"Book\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"book\",\"tableName\":\"books\"},{\"kind\":\"collectionType\",\"collectionName\":\"loc_5087s\",\"info\":{\"singularName\":\"loc-5087\",\"pluralName\":\"loc-5087s\",\"displayName\":\"LOC-5087\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::loc-5087.loc-5087\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"loc_5087s\",\"info\":{\"singularName\":\"loc-5087\",\"pluralName\":\"loc-5087s\",\"displayName\":\"LOC-5087\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"loc-5087\",\"connection\":\"default\",\"uid\":\"api::loc-5087.loc-5087\",\"apiName\":\"loc-5087\",\"globalId\":\"Loc5087\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"loc-5087\",\"tableName\":\"loc_5087s\"},{\"kind\":\"collectionType\",\"collectionName\":\"restaurants\",\"info\":{\"singularName\":\"restaurant\",\"pluralName\":\"restaurants\",\"displayName\":\"Restaurant\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"title\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\",\"required\":true},\"description\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"text\"},\"books\":{\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"recipes\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.recipe\"},\"descs\":{\"type\":\"component\",\"repeatable\":false,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.pub-component-1\"},\"street\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"city\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"country\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"Motto\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"motto_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":false}},\"type\":\"string\"},\"title_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::restaurant.restaurant\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"restaurants\",\"info\":{\"singularName\":\"restaurant\",\"pluralName\":\"restaurants\",\"displayName\":\"Restaurant\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"title\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\",\"required\":true},\"description\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"text\"},\"books\":{\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"recipes\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.recipe\"},\"descs\":{\"type\":\"component\",\"repeatable\":false,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.pub-component-1\"},\"street\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"city\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"country\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"Motto\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"motto_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":false}},\"type\":\"string\"},\"title_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"restaurant\",\"connection\":\"default\",\"uid\":\"api::restaurant.restaurant\",\"apiName\":\"restaurant\",\"globalId\":\"Restaurant\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"restaurant\",\"tableName\":\"restaurants\"},{\"collectionName\":\"components_food_ingredient_variants\",\"info\":{\"displayName\":\"ingredient_variants\",\"icon\":\"atlas\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\"}},\"__filename__\":\"ingredient-variants.json\",\"__schema__\":{\"collectionName\":\"components_food_ingredient_variants\",\"info\":{\"displayName\":\"ingredient_variants\",\"icon\":\"atlas\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\"}},\"__filename__\":\"ingredient-variants.json\"},\"uid\":\"food.ingredient-variants\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"ingredient-variants\",\"globalId\":\"ComponentFoodIngredientVariants\",\"singularName\":\"ingredient-variants\",\"tableName\":\"components_food_ingredient_variants\"},{\"collectionName\":\"components_food_ingredients\",\"info\":{\"displayName\":\"ingredients\",\"icon\":\"atom\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"pcs\":{\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"}},\"__filename__\":\"ingredients.json\",\"__schema__\":{\"collectionName\":\"components_food_ingredients\",\"info\":{\"displayName\":\"ingredients\",\"icon\":\"atom\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"pcs\":{\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"}},\"__filename__\":\"ingredients.json\"},\"uid\":\"food.ingredients\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"ingredients\",\"globalId\":\"ComponentFoodIngredients\",\"singularName\":\"ingredients\",\"tableName\":\"components_food_ingredients\"},{\"collectionName\":\"components_food_pub_component_1s\",\"info\":{\"displayName\":\"Pub Component 1\",\"icon\":\"american-sign-language-interpreting\",\"description\":\"\"},\"options\":{},\"attributes\":{\"rich_description\":{\"type\":\"richtext\"},\"history\":{\"type\":\"text\"},\"excerpt\":{\"type\":\"string\"},\"test_variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"pub-component-1.json\",\"__schema__\":{\"collectionName\":\"components_food_pub_component_1s\",\"info\":{\"displayName\":\"Pub Component 1\",\"icon\":\"american-sign-language-interpreting\",\"description\":\"\"},\"options\":{},\"attributes\":{\"rich_description\":{\"type\":\"richtext\"},\"history\":{\"type\":\"text\"},\"excerpt\":{\"type\":\"string\"},\"test_variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"pub-component-1.json\"},\"uid\":\"food.pub-component-1\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"pub-component-1\",\"globalId\":\"ComponentFoodPubComponent1\",\"singularName\":\"pub-component-1\",\"tableName\":\"components_food_pub_component_1s\"},{\"collectionName\":\"components_food_recipes\",\"info\":{\"displayName\":\"recipe\",\"icon\":\"ad\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\"},\"variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"recipe.json\",\"__schema__\":{\"collectionName\":\"components_food_recipes\",\"info\":{\"displayName\":\"recipe\",\"icon\":\"ad\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\"},\"variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"recipe.json\"},\"uid\":\"food.recipe\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"recipe\",\"globalId\":\"ComponentFoodRecipe\",\"singularName\":\"recipe\",\"tableName\":\"components_food_recipes\"},{\"collectionName\":\"components_seo_galleries\",\"info\":{\"displayName\":\"Gallery\",\"icon\":\"address-card\",\"description\":\"\"},\"options\":{},\"attributes\":{\"main_image\":{\"type\":\"relation\",\"relation\":\"morphOne\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"rest\":{\"type\":\"relation\",\"relation\":\"morphMany\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"seo_desc\":{\"type\":\"string\"}},\"__filename__\":\"gallery.json\",\"__schema__\":{\"collectionName\":\"components_seo_galleries\",\"info\":{\"displayName\":\"Gallery\",\"icon\":\"address-card\",\"description\":\"\"},\"options\":{},\"attributes\":{\"main_image\":{\"type\":\"media\",\"multiple\":false,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"]},\"rest\":{\"type\":\"media\",\"multiple\":true,\"required\":false,\"allowedTypes\":[\"images\",\"videos\",\"audios\",\"files\"]},\"seo_desc\":{\"type\":\"string\"}},\"__filename__\":\"gallery.json\"},\"uid\":\"seo.gallery\",\"category\":\"seo\",\"modelType\":\"component\",\"modelName\":\"gallery\",\"globalId\":\"ComponentSeoGallery\",\"singularName\":\"gallery\",\"tableName\":\"components_seo_galleries\"}]"),
|
|
19
|
+
JSON.parse("{\"ingredients\":[null,{\"name\":\"první\"},{\"name\":\"druhý\"},{\"name\":\"třetí\"},{\"name\":\"čtvrtý\"},{\"name\":\"pátý\"},{\"name\":\"šestý\"},{\"name\":\"sedmý\"},{\"name\":\"osmý\"},{\"name\":\"devátý\"},{\"name\":\"desátý\"},null,null,null,null,null,null,null,null,null,null,{\"name\":\"jedenáctý\"},null,{\"name\":\"dvanáctý\"},{\"name\":\"třináctý\"},null,{\"name\":\"čtrnáctý\"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,{\"Name\":\"první\"},{\"Name\":\"druhý\"},{\"Name\":\"třetina\"},{\"Name\":\"čtvrtý\"},{\"Name\":\"pátý\"},{\"Name\":\"šestý\"},{\"Name\":\"sedmý\"},{\"Name\":\"osmý\"},{\"Name\":\"devátý\"},{\"Name\":\"desátý\"}]}"),
|
|
20
|
+
JSON.parse("{\"id\":1,\"createdAt\":\"2022-08-30T09:21:23.903Z\",\"updatedAt\":\"2022-08-30T15:09:19.107Z\",\"publishedAt\":null,\"locale\":\"en\",\"ingredients\":[{\"id\":23,\"name\":\"twelveth\",\"pcs\":12,\"required\":null},{\"id\":1,\"name\":\"first\",\"pcs\":1,\"required\":null},{\"id\":2,\"name\":\"second\",\"pcs\":2,\"required\":null},{\"id\":21,\"name\":\"eleventh\",\"pcs\":11,\"required\":null},{\"id\":3,\"name\":\"third\",\"pcs\":3,\"required\":null},{\"id\":4,\"name\":\"fourth\",\"pcs\":4,\"required\":null},{\"id\":5,\"name\":\"fifth\",\"pcs\":5,\"required\":null},{\"id\":6,\"name\":\"sixth\",\"pcs\":6,\"required\":null},{\"id\":26,\"name\":\"fourteenth\",\"pcs\":14,\"required\":null},{\"id\":7,\"name\":\"seventh\",\"pcs\":7,\"required\":null},{\"id\":8,\"name\":\"eighth\",\"pcs\":8,\"required\":null},{\"id\":9,\"name\":\"nineth\",\"pcs\":9,\"required\":null},{\"id\":10,\"name\":\"tenth\",\"pcs\":10,\"required\":null},{\"id\":24,\"name\":\"thirteenth\",\"pcs\":13,\"required\":null}],\"createdBy\":{\"id\":1,\"firstname\":\"David\",\"lastname\":\"Vaclavek\",\"username\":null,\"email\":\"david@localazy.com\",\"password\":\"$2a$10$pRWPPnTWp8HFWPR7aD4Pju2nNBD9vyNPt.QaMpU9IA6pMoGFl7eVC\",\"resetPasswordToken\":null,\"registrationToken\":null,\"isActive\":true,\"blocked\":false,\"preferedLanguage\":null,\"createdAt\":\"2022-07-11T11:58:02.016Z\",\"updatedAt\":\"2022-07-11T12:56:16.558Z\"},\"updatedBy\":{\"id\":1,\"firstname\":\"David\",\"lastname\":\"Vaclavek\",\"username\":null,\"email\":\"david@localazy.com\",\"password\":\"$2a$10$pRWPPnTWp8HFWPR7aD4Pju2nNBD9vyNPt.QaMpU9IA6pMoGFl7eVC\",\"resetPasswordToken\":null,\"registrationToken\":null,\"isActive\":true,\"blocked\":false,\"preferedLanguage\":null,\"createdAt\":\"2022-07-11T11:58:02.016Z\",\"updatedAt\":\"2022-07-11T12:56:16.558Z\"},\"localizations\":[{\"id\":3,\"createdAt\":\"2022-08-30T15:08:02.889Z\",\"updatedAt\":\"2022-08-30T20:49:14.959Z\",\"publishedAt\":null,\"locale\":\"cs\"}]}"),
|
|
21
|
+
"api::loc-5087.loc-5087",
|
|
22
|
+
""
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
// VERIFY
|
|
25
26
|
const expected = {
|
|
26
|
-
|
|
27
|
-
title: "Plná restaurace",
|
|
28
|
-
description: "S nějakým skvělým popisem",
|
|
29
|
-
recipes: [
|
|
30
|
-
// is repeatable - array
|
|
27
|
+
ingredients: [
|
|
31
28
|
{
|
|
32
|
-
|
|
33
|
-
__component: "food.
|
|
34
|
-
name: "Hovězí vývar",
|
|
35
|
-
ingredients: [
|
|
36
|
-
// is repeatable - array
|
|
37
|
-
{
|
|
38
|
-
// id: 4,
|
|
39
|
-
__component: "food.ingredients",
|
|
40
|
-
name: "Hovězí",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
// id: 5,
|
|
44
|
-
__component: "food.ingredients",
|
|
45
|
-
name: "Voda",
|
|
46
|
-
},
|
|
47
|
-
],
|
|
29
|
+
name: "dvanáctý",
|
|
30
|
+
__component: "food.ingredients",
|
|
48
31
|
},
|
|
49
32
|
{
|
|
50
|
-
|
|
51
|
-
__component: "food.
|
|
52
|
-
name: "Rajčatová polévka",
|
|
53
|
-
ingredients: [
|
|
54
|
-
// is repeatable - array
|
|
55
|
-
{
|
|
56
|
-
// id: 2,
|
|
57
|
-
__component: "food.ingredients",
|
|
58
|
-
name: "rajče",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
// id: 3,
|
|
62
|
-
__component: "food.ingredients",
|
|
63
|
-
name: "Polévka",
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
variants: {
|
|
67
|
-
// is not repeatable - object
|
|
68
|
-
// id: 4,
|
|
69
|
-
__component: "food.ingredient-variants",
|
|
70
|
-
name: "Červená, žlutá, zelená",
|
|
71
|
-
},
|
|
33
|
+
name: "první",
|
|
34
|
+
__component: "food.ingredients",
|
|
72
35
|
},
|
|
73
36
|
{
|
|
74
|
-
|
|
75
|
-
__component: "food.
|
|
76
|
-
name: "Guláš",
|
|
77
|
-
ingredients: [
|
|
78
|
-
// is repeatable - array
|
|
79
|
-
{
|
|
80
|
-
// id: 6,
|
|
81
|
-
__component: "food.ingredients",
|
|
82
|
-
name: "Hovězí maso",
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
// id: 7,
|
|
86
|
-
__component: "food.ingredients",
|
|
87
|
-
name: "Pepř",
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
// id: 8,
|
|
91
|
-
__component: "food.ingredients",
|
|
92
|
-
name: "pepř, koření",
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
// id: 9,
|
|
96
|
-
__component: "food.ingredients",
|
|
97
|
-
name: "Voda",
|
|
98
|
-
},
|
|
99
|
-
],
|
|
37
|
+
name: "druhý",
|
|
38
|
+
__component: "food.ingredients",
|
|
100
39
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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...",
|
|
40
|
+
{
|
|
41
|
+
name: "jedenáctý",
|
|
42
|
+
__component: "food.ingredients",
|
|
114
43
|
},
|
|
115
|
-
|
|
116
|
-
|
|
44
|
+
{
|
|
45
|
+
name: "třetí",
|
|
46
|
+
__component: "food.ingredients",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "čtvrtý",
|
|
50
|
+
__component: "food.ingredients",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "pátý",
|
|
54
|
+
__component: "food.ingredients",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "šestý",
|
|
58
|
+
__component: "food.ingredients",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "čtrnáctý",
|
|
62
|
+
__component: "food.ingredients",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "sedmý",
|
|
66
|
+
__component: "food.ingredients",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "osmý",
|
|
70
|
+
__component: "food.ingredients",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "devátý",
|
|
74
|
+
__component: "food.ingredients",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "desátý",
|
|
78
|
+
__component: "food.ingredients",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "třináctý",
|
|
82
|
+
__component: "food.ingredients",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
}
|
|
117
86
|
expect(result).toEqual(expected);
|
|
118
87
|
});
|
|
119
88
|
it("should return transformed book entry to strapi create entry structure", () => {
|
|
@@ -127,6 +96,7 @@ describe("parsed-localazy-entry-to-create-entry.js", () => {
|
|
|
127
96
|
const result = parsedLocalazyEntryToCreateEntry(
|
|
128
97
|
allModels,
|
|
129
98
|
entry,
|
|
99
|
+
entry,
|
|
130
100
|
uid,
|
|
131
101
|
locale
|
|
132
102
|
);
|