@localazy/strapi-plugin 0.2.13 → 1.0.0-beta.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/README.md +3 -1
- package/dist/_chunks/App-BSFfgZKU.mjs +5278 -0
- package/dist/_chunks/App-D1QaIMHX.js +5278 -0
- package/dist/_chunks/ContentTransferSetup-DHXJIxAp.js +1552 -0
- package/dist/_chunks/ContentTransferSetup-DtjcF_jM.mjs +1550 -0
- package/dist/_chunks/GlobalSettings-BON3kjHK.js +228 -0
- package/dist/_chunks/GlobalSettings-BcdibqNS.mjs +228 -0
- package/dist/_chunks/LanguagesSelector-BeijBEjg.js +47 -0
- package/dist/_chunks/LanguagesSelector-fyAIUp7M.mjs +48 -0
- package/dist/_chunks/en-BTf8goGM.mjs +8 -0
- package/dist/_chunks/en-CRtsEFtl.js +8 -0
- package/dist/_chunks/fr-C8Qw4iPZ.js +4 -0
- package/dist/_chunks/fr-hkSxFuzl.mjs +4 -0
- package/dist/_chunks/has-model-changed-BMCQX2Dd.js +316 -0
- package/dist/_chunks/has-model-changed-Dvtzpc9v.mjs +317 -0
- package/dist/_chunks/index-BQw2qi2G.js +2679 -0
- package/dist/_chunks/index-CN3Gyh5F.mjs +2678 -0
- package/dist/_chunks/isEqual-B-YVnzrp.js +205 -0
- package/dist/_chunks/isEqual-CEyT97-3.mjs +206 -0
- package/dist/_chunks/set-DUdH3vE5.js +54557 -0
- package/dist/_chunks/set-DulHAQhq.mjs +54542 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +5 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/config/development/index.d.ts +15 -0
- package/dist/admin/src/config/example/index.example.d.ts +15 -0
- package/dist/admin/src/config/index.d.ts +15 -0
- package/dist/admin/src/config/local/index.d.ts +15 -0
- package/dist/admin/src/config/production/index.d.ts +15 -0
- package/dist/admin/src/i18n.d.ts +2 -0
- package/dist/admin/src/index.d.ts +10 -0
- package/dist/admin/src/modules/@common/api/strapi-api-base.d.ts +6 -0
- package/dist/admin/src/modules/@common/components/Icons/House.d.ts +2 -0
- package/dist/admin/src/modules/@common/components/Icons/Localazy.d.ts +2 -0
- package/dist/admin/src/modules/@common/components/LanguagesSelector.d.ts +11 -0
- package/dist/admin/src/modules/@common/components/PluginPageLoader.d.ts +2 -0
- package/dist/admin/src/modules/@common/components/SideNav.d.ts +2 -0
- package/dist/admin/src/modules/@common/components/TransferReport.d.ts +5 -0
- package/dist/admin/src/modules/@common/functions/flatten-deep.d.ts +2 -0
- package/dist/admin/src/modules/@common/locale/en.d.ts +14 -0
- package/dist/admin/src/modules/@common/models/supported-content-type-fields.d.ts +2 -0
- package/dist/admin/src/modules/@common/models/supported-custom-field-plugins.d.ts +2 -0
- package/dist/admin/src/modules/@common/services/i18n-service.d.ts +3 -0
- package/dist/admin/src/modules/@common/services/plugin.service.d.ts +3 -0
- package/dist/admin/src/modules/@common/services/product-analytics-service.d.ts +14 -0
- package/dist/admin/src/modules/@common/services/project-service.d.ts +4 -0
- package/dist/admin/src/modules/@common/services/user-service.d.ts +5 -0
- package/dist/admin/src/modules/@common/utils/are-locales-compatible.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/format-number.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/get-default-locale.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/history.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/is-plugin-route.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/iso-locales-utils.d.ts +3 -0
- package/dist/admin/src/modules/@common/utils/redirect-to-plugin-route.d.ts +13 -0
- package/dist/admin/src/modules/@common/utils/sort-by-model-name.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/use-header-subtitle.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/use-header-title.d.ts +2 -0
- package/dist/admin/src/modules/@common/utils/use-nav.d.ts +11 -0
- package/dist/admin/src/modules/alerts/constants/channels.d.ts +1 -0
- package/dist/admin/src/modules/alerts/constants/events.d.ts +4 -0
- package/dist/admin/src/modules/alerts/services/alerts-service.d.ts +8 -0
- package/dist/admin/src/modules/localazy-download/locale/en.d.ts +24 -0
- package/dist/admin/src/modules/localazy-download/services/download-alerts-service.d.ts +5 -0
- package/dist/admin/src/modules/localazy-download/services/localazy-download-service.d.ts +3 -0
- package/dist/admin/src/modules/localazy-upload/components/ReadDocsButton.d.ts +3 -0
- package/dist/admin/src/modules/localazy-upload/locale/en.d.ts +19 -0
- package/dist/admin/src/modules/localazy-upload/services/localazy-upload-service.d.ts +3 -0
- package/dist/admin/src/modules/localazy-upload/services/upload-alerts-service.d.ts +5 -0
- package/dist/admin/src/modules/login/components/FetchIdentity.d.ts +3 -0
- package/dist/admin/src/modules/login/components/LoginButton.d.ts +12 -0
- package/dist/admin/src/modules/login/components/LogoutButton.d.ts +6 -0
- package/dist/admin/src/modules/login/locale/en.d.ts +8 -0
- package/dist/admin/src/modules/login/services/localazy-login-service.d.ts +4 -0
- package/dist/admin/src/modules/overview/components/OverviewItem.d.ts +7 -0
- package/dist/admin/src/modules/overview/components/OverviewItemLink.d.ts +7 -0
- package/dist/admin/src/modules/overview/components/PrerequisitiesInfo.d.ts +3 -0
- package/dist/admin/src/modules/overview/locale/en.d.ts +14 -0
- package/dist/admin/src/modules/plugin-settings/components/ContentTransferSetupEmpty.d.ts +2 -0
- package/dist/admin/src/modules/plugin-settings/components/Tree.d.ts +8 -0
- package/dist/admin/src/modules/plugin-settings/components/TreeItem.d.ts +10 -0
- package/dist/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.d.ts +2 -0
- package/dist/admin/src/modules/plugin-settings/functions/get-content-transfer-setup-keys-sets.d.ts +8 -0
- package/dist/admin/src/modules/plugin-settings/functions/has-model-changed.d.ts +6 -0
- package/dist/admin/src/modules/plugin-settings/locale/en.d.ts +49 -0
- package/dist/admin/src/modules/plugin-settings/services/plugin-settings-service.d.ts +6 -0
- package/dist/admin/src/modules/plugin-settings/services/strapi-model-service.d.ts +4 -0
- package/dist/admin/src/modules/plugin-settings/services/strapi-users-service.d.ts +3 -0
- package/dist/admin/src/modules/plugin-settings/utils/array-of-models-to-object.d.ts +2 -0
- package/dist/admin/src/modules/plugin-settings/utils/find-model-value-by-key.d.ts +2 -0
- package/dist/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.d.ts +7 -0
- package/dist/admin/src/modules/plugin-settings/utils/get-models-tree.d.ts +5 -0
- package/dist/admin/src/modules/strapi/utils/get-default-theme.d.ts +3 -0
- package/dist/admin/src/modules/user/model/localazy-identity.d.ts +15 -0
- package/dist/admin/src/modules/user/services/localazy-user-service.d.ts +6 -0
- package/dist/admin/src/pages/App.d.ts +3 -0
- package/dist/admin/src/pages/ContentTransferSetup.d.ts +4 -0
- package/dist/admin/src/pages/Download.d.ts +7 -0
- package/dist/admin/src/pages/GlobalSettings.d.ts +4 -0
- package/dist/admin/src/pages/HomePage.d.ts +2 -0
- package/dist/admin/src/pages/Login.d.ts +8 -0
- package/dist/admin/src/pages/Overview.d.ts +8 -0
- package/dist/admin/src/pages/Upload.d.ts +7 -0
- package/dist/admin/src/pluginId.d.ts +2 -0
- package/dist/admin/src/plugins/generic-connector-client.d.ts +3 -0
- package/dist/admin/src/state/localazy-identity.d.ts +13 -0
- package/dist/admin/src/utils/getTranslation.d.ts +2 -0
- package/dist/server/index.js +26000 -0
- package/dist/server/index.mjs +25989 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/core/config.d.ts +1 -0
- package/dist/server/src/config/development/index.d.ts +15 -0
- package/dist/server/src/config/example/index.example.d.ts +15 -0
- package/dist/server/src/config/index.d.ts +18 -0
- package/dist/server/src/config/local/index.d.ts +15 -0
- package/dist/server/src/config/production/index.d.ts +15 -0
- package/dist/server/src/constants/channels.d.ts +3 -0
- package/dist/server/src/constants/events.d.ts +6 -0
- package/dist/server/src/content-types/index.d.ts +2 -0
- package/dist/server/src/controllers/index.d.ts +43 -0
- package/dist/server/src/controllers/localazy-auth-controller.d.ts +8 -0
- package/dist/server/src/controllers/localazy-project-controller.d.ts +7 -0
- package/dist/server/src/controllers/localazy-transfer-controller.d.ts +8 -0
- package/dist/server/src/controllers/localazy-user-controller.d.ts +9 -0
- package/dist/server/src/controllers/plugin-settings-controller.d.ts +10 -0
- package/dist/server/src/controllers/strapi-controller.d.ts +10 -0
- package/dist/server/src/core/index.d.ts +71 -0
- package/dist/server/src/db/model/content-transfer-setup.d.ts +4 -0
- package/dist/server/src/db/model/localazy-user.d.ts +17 -0
- package/dist/server/src/db/model/plugin-settings.d.ts +5 -0
- package/dist/server/src/db/model/utils/get-strapi-store.d.ts +26 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/functions/should-set-downloaded-property.d.ts +12 -0
- package/dist/server/src/index.d.ts +189 -0
- package/dist/server/src/lifecycles/deep-populate-hook.d.ts +20 -0
- package/dist/server/src/lifecycles/deprecate-event-entry-in-localazy-hook.d.ts +4 -0
- package/dist/server/src/lifecycles/upload-event-entry-to-localazy-hook.d.ts +12 -0
- package/dist/server/src/middlewares/index.d.ts +2 -0
- package/dist/server/src/models/plugin/content-transfer-setup.d.ts +13 -0
- package/dist/server/src/models/strapi/locale.d.ts +8 -0
- package/dist/server/src/policies/index.d.ts +2 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/index.d.ts +25 -0
- package/dist/server/src/routes/localazy-auth-routes.d.ts +9 -0
- package/dist/server/src/routes/localazy-project-routes.d.ts +9 -0
- package/dist/server/src/routes/localazy-transfer-routes.d.ts +9 -0
- package/dist/server/src/routes/localazy-user-routes.d.ts +9 -0
- package/dist/server/src/routes/plugin-settings-routes.d.ts +9 -0
- package/dist/server/src/routes/strapi-routes.d.ts +9 -0
- package/dist/server/src/services/helpers/job-notification-service.d.ts +14 -0
- package/dist/server/src/services/helpers/plugin-settings-service-helper.d.ts +16 -0
- package/dist/server/src/services/index.d.ts +92 -0
- package/dist/server/src/services/localazy-pubapi-service.d.ts +12 -0
- package/dist/server/src/services/localazy-transfer-download-service.d.ts +11 -0
- package/dist/server/src/services/localazy-transfer-upload-service.d.ts +11 -0
- package/dist/server/src/services/localazy-upload-service.d.ts +28 -0
- package/dist/server/src/services/localazy-user-service.d.ts +11 -0
- package/dist/server/src/services/plugin-settings-service.d.ts +16 -0
- package/dist/server/src/services/strapi-i18n-service.d.ts +19 -0
- package/dist/server/src/services/strapi-localazy-i18n-service.d.ts +9 -0
- package/dist/server/src/services/strapi-service.d.ts +10 -0
- package/dist/server/src/utils/delay.d.ts +1 -0
- package/dist/server/src/utils/drop-property-deep.d.ts +1 -0
- package/dist/server/src/utils/flatten-object.d.ts +2 -0
- package/dist/server/src/utils/generate-random-id.d.ts +2 -0
- package/dist/server/src/utils/get-full-populate-localazy-download-object.d.ts +17 -0
- package/dist/server/src/utils/get-full-populate-localazy-upload-object.d.ts +9 -0
- package/dist/server/src/utils/get-full-populate-object.d.ts +17 -0
- package/dist/server/src/utils/get-main-keys-of-nested-array-objects.d.ts +2 -0
- package/dist/server/src/utils/get-picked-flatten-keys-for-hook-entry.d.ts +5 -0
- package/dist/server/src/utils/intl-display-name.d.ts +1 -0
- package/dist/server/src/utils/is-generally-applicable-content-type.d.ts +2 -0
- package/dist/server/src/utils/is-localazy-applicable-content-type.d.ts +2 -0
- package/dist/server/src/utils/iso-locales-utils.d.ts +3 -0
- package/dist/server/src/utils/localazy-api-client-factory.d.ts +3 -0
- package/dist/server/src/utils/localazy-generic-connector-client-factory.d.ts +3 -0
- package/dist/server/src/utils/model-utils.d.ts +7 -0
- package/dist/server/src/utils/omit-deep.d.ts +2 -0
- package/dist/server/src/utils/parsed-localazy-entry-to-create-entry.d.ts +7 -0
- package/dist/server/src/utils/parsed-localazy-entry-to-update-entry.d.ts +1 -0
- package/dist/server/src/utils/pick-entries.d.ts +2 -0
- package/dist/server/src/utils/populate-create-update-entry-with-base-entry.d.ts +1 -0
- package/dist/server/src/utils/request-initiator-helper.d.ts +9 -0
- package/dist/server/src/utils/reset-array-keys-deep.d.ts +1 -0
- package/dist/server/src/utils/transfer-setup-utils.d.ts +7 -0
- package/install/index.mjs +88 -34
- package/install/vite.config.example.js +40 -0
- package/install/vite.config.example.ts +41 -0
- package/install/{webpack.example.js → webpack.config.example.js} +2 -2
- package/install/webpack.config.example.ts +30 -0
- package/package.json +93 -55
- package/.babelrc +0 -7
- package/.eslintrc +0 -13
- package/.github/workflows/qa.yml +0 -25
- package/.github/workflows/release.yml +0 -46
- package/.nvmrc +0 -1
- package/.strapi-updater.json +0 -4
- package/CHANGELOG.md +0 -68
- package/LICENSE +0 -21
- package/admin/src/components/Initializer/index.js +0 -26
- package/admin/src/components/PluginIcon/index.js +0 -14
- package/admin/src/config/development/index.js +0 -14
- package/admin/src/config/example/index.js +0 -14
- package/admin/src/config/index.js +0 -19
- package/admin/src/config/local/index.js +0 -14
- package/admin/src/config/production/index.js +0 -15
- package/admin/src/i18n.js +0 -41
- package/admin/src/index.js +0 -138
- package/admin/src/modules/@common/components/Icons/Localazy/index.js +0 -12
- package/admin/src/modules/@common/components/LanguagesSelector/index.js +0 -67
- package/admin/src/modules/@common/components/PluginPageLoader/index.js +0 -20
- package/admin/src/modules/@common/components/SideNav/index.js +0 -46
- package/admin/src/modules/@common/components/TransferReport/index.js +0 -53
- package/admin/src/modules/@common/locale/en.js +0 -14
- package/admin/src/modules/@common/models/supported-content-type-fields.js +0 -9
- package/admin/src/modules/@common/models/supported-custom-field-plugins.js +0 -6
- package/admin/src/modules/@common/services/i18n-service.js +0 -15
- package/admin/src/modules/@common/services/plugin.service.js +0 -16
- package/admin/src/modules/@common/services/product-analytics-service.js +0 -86
- package/admin/src/modules/@common/services/project-service.js +0 -15
- package/admin/src/modules/@common/services/user-service.js +0 -38
- package/admin/src/modules/@common/utils/__tests__/iso-locales-utils.test.js +0 -102
- package/admin/src/modules/@common/utils/are-locales-compatible.js +0 -42
- package/admin/src/modules/@common/utils/format-number.js +0 -1
- package/admin/src/modules/@common/utils/functions/flatten-deep.js +0 -23
- package/admin/src/modules/@common/utils/get-default-locale.js +0 -32
- package/admin/src/modules/@common/utils/get-header-subtitle.js +0 -21
- package/admin/src/modules/@common/utils/get-header-title.js +0 -24
- package/admin/src/modules/@common/utils/get-nav.js +0 -35
- package/admin/src/modules/@common/utils/history.js +0 -6
- package/admin/src/modules/@common/utils/is-plugin-route.js +0 -15
- package/admin/src/modules/@common/utils/iso-locales-utils.js +0 -58
- package/admin/src/modules/@common/utils/redirect-to-plugin-route.js +0 -22
- package/admin/src/modules/@common/utils/sort-by-model-name.js +0 -10
- package/admin/src/modules/alerts/constants/channels.js +0 -1
- package/admin/src/modules/alerts/constants/events.js +0 -4
- package/admin/src/modules/alerts/services/alerts-service.js +0 -41
- package/admin/src/modules/localazy-download/locale/en.js +0 -25
- package/admin/src/modules/localazy-download/services/download-alerts-service.js +0 -12
- package/admin/src/modules/localazy-download/services/localazy-download-service.js +0 -16
- package/admin/src/modules/localazy-upload/components/ReadDocsButton.js +0 -20
- package/admin/src/modules/localazy-upload/locale/en.js +0 -20
- package/admin/src/modules/localazy-upload/services/localazy-upload-service.js +0 -16
- package/admin/src/modules/localazy-upload/services/upload-alerts-service.js +0 -12
- package/admin/src/modules/login/components/LoginButton/index.js +0 -55
- package/admin/src/modules/login/components/LogoutButton/index.js +0 -49
- package/admin/src/modules/login/locale/en.js +0 -7
- package/admin/src/modules/login/services/localazy-login-service.js +0 -29
- package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +0 -308
- package/admin/src/modules/plugin-settings/components/ContentTransferSetupEmpty/index.js +0 -86
- package/admin/src/modules/plugin-settings/components/GlobalSettings/index.js +0 -269
- package/admin/src/modules/plugin-settings/components/Tree/index.js +0 -145
- package/admin/src/modules/plugin-settings/components/TreeItem/index.js +0 -48
- package/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.js +0 -57
- package/admin/src/modules/plugin-settings/functions/get-content-transfer-setup-keys-sets.js +0 -85
- package/admin/src/modules/plugin-settings/functions/has-model-changed.js +0 -75
- package/admin/src/modules/plugin-settings/locale/en.js +0 -61
- package/admin/src/modules/plugin-settings/services/plugin-settings-service.js +0 -55
- package/admin/src/modules/plugin-settings/services/strapi-model-service.js +0 -26
- package/admin/src/modules/plugin-settings/services/strapi-users-service.js +0 -26
- package/admin/src/modules/plugin-settings/utils/__tests__/get-models-tree.test.js +0 -135
- package/admin/src/modules/plugin-settings/utils/array-of-models-to-object.js +0 -6
- package/admin/src/modules/plugin-settings/utils/find-model-value-by-key.js +0 -8
- package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +0 -31
- package/admin/src/modules/plugin-settings/utils/get-models-tree.js +0 -94
- package/admin/src/modules/settings/components/OverviewItem/index.js +0 -44
- package/admin/src/modules/settings/components/OverviewItemLink/index.js +0 -34
- package/admin/src/modules/settings/components/PrerequisitiesInfo/index.js +0 -28
- package/admin/src/modules/settings/locale/en.js +0 -13
- package/admin/src/modules/user/model/localazy-identity.js +0 -14
- package/admin/src/modules/user/services/localazy-user-service.js +0 -38
- package/admin/src/pages/App/index.js +0 -154
- package/admin/src/pages/Download/index.js +0 -280
- package/admin/src/pages/Index/index.js +0 -8
- package/admin/src/pages/Login/index.js +0 -109
- package/admin/src/pages/PluginSettings/index.js +0 -56
- package/admin/src/pages/Settings/index.js +0 -132
- package/admin/src/pages/Upload/index.js +0 -241
- package/admin/src/pluginId.js +0 -5
- package/admin/src/plugins/generic-connector-client.js +0 -9
- package/admin/src/state/localazy-identity.js +0 -29
- package/admin/src/tests/fixtures/all-models.js +0 -877
- package/admin/src/tests/fixtures/restaurant-model.js +0 -230
- package/admin/src/translations/en.json +0 -4
- package/admin/src/translations/fr.json +0 -1
- package/admin/src/utils/createAxiosInstance.js +0 -54
- package/admin/src/utils/getTrad.js +0 -5
- package/jest.config.js +0 -0
- package/server/bootstrap.js +0 -63
- package/server/config/development/index.js +0 -16
- package/server/config/example/index.js +0 -16
- package/server/config/index.js +0 -20
- package/server/config/local/index.js +0 -16
- package/server/config/production/index.js +0 -17
- package/server/config/schema.graphql.js +0 -21
- package/server/constants/channels.js +0 -3
- package/server/constants/events.js +0 -6
- package/server/content-types/index.js +0 -3
- package/server/controllers/index.js +0 -17
- package/server/controllers/localazy-auth-controller.js +0 -22
- package/server/controllers/localazy-project-controller.js +0 -21
- package/server/controllers/localazy-transfer-controller.js +0 -62
- package/server/controllers/localazy-user-controller.js +0 -24
- package/server/controllers/plugin-settings-controller.js +0 -31
- package/server/controllers/strapi-controller.js +0 -27
- package/server/db/model/content-transfer-setup.js +0 -13
- package/server/db/model/localazy-user.js +0 -23
- package/server/db/model/plugin-settings.js +0 -13
- package/server/db/model/utils/get-strapi-store.js +0 -9
- package/server/destroy.js +0 -5
- package/server/functions/should-set-downloaded-property.js +0 -94
- package/server/index.js +0 -25
- package/server/lifecycles/deep-populate-hook.js +0 -12
- package/server/lifecycles/deprecate-event-entry-in-localazy-hook.js +0 -73
- package/server/lifecycles/upload-event-entry-to-localazy-hook.js +0 -36
- package/server/middlewares/index.js +0 -7
- package/server/middlewares/verify-webhook.js +0 -76
- package/server/models/supported-content-type-fields.js +0 -9
- package/server/models/supported-custom-field-plugins.js +0 -6
- package/server/policies/index.js +0 -3
- package/server/register.js +0 -5
- package/server/routes/index.js +0 -28
- package/server/routes/localazy-auth.js +0 -22
- package/server/routes/localazy-project.js +0 -14
- package/server/routes/localazy-public-transfer.js +0 -20
- package/server/routes/localazy-transfer.js +0 -22
- package/server/routes/localazy-user.js +0 -30
- package/server/routes/plugin-settings.js +0 -38
- package/server/routes/strapi.js +0 -38
- package/server/services/helpers/job-notification-service.js +0 -30
- package/server/services/helpers/plugin-settings-service-helper.js +0 -52
- package/server/services/index.js +0 -23
- package/server/services/localazy-pubapi-service.js +0 -53
- package/server/services/localazy-transfer-download-service.js +0 -445
- package/server/services/localazy-transfer-upload-service.js +0 -178
- package/server/services/localazy-upload-service.js +0 -52
- package/server/services/localazy-user-service.js +0 -29
- package/server/services/plugin-settings-service.js +0 -53
- package/server/services/strapi-i18n-service.js +0 -151
- package/server/services/strapi-localazy-i18n-service.js +0 -130
- package/server/services/strapi-service.js +0 -26
- package/server/tests/fixtures/all-models.js +0 -869
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +0 -5761
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz.js +0 -402
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-page-dz.js +0 -658
- package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +0 -536
- package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +0 -35157
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +0 -202
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +0 -2700
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-lesson-dz.js +0 -309
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +0 -47
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +0 -169
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +0 -3003
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +0 -2057
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json-dz.js +0 -884
- package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +0 -46
- package/server/tests/fixtures/strapi-plugin-all-models.js +0 -7000
- package/server/utils/__tests__/build-populate.test.js +0 -85
- package/server/utils/__tests__/flatten-object.test.js +0 -171
- package/server/utils/__tests__/get-models-tree.test.js +0 -170
- package/server/utils/__tests__/iso-locales-utils.test.js +0 -104
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +0 -258
- package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +0 -456
- package/server/utils/__tests__/pick-entries.test.js +0 -963
- package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +0 -1176
- package/server/utils/build-populate.js +0 -48
- package/server/utils/delay.js +0 -6
- package/server/utils/flatten-object.js +0 -61
- package/server/utils/generate-random-id.js +0 -3
- package/server/utils/get-full-populate-object.js +0 -66
- package/server/utils/get-main-keys-of-nested-array-objects.js +0 -5
- package/server/utils/get-models-tree.js +0 -47
- package/server/utils/get-picked-flatten-keys-for-hook-entry.js +0 -270
- package/server/utils/intl-display-name.js +0 -4
- package/server/utils/is-generally-applicable-content-type.js +0 -33
- package/server/utils/is-localazy-applicable-content-type.js +0 -36
- package/server/utils/iso-locales-utils.js +0 -60
- package/server/utils/localazy-api-client-factory.js +0 -22
- package/server/utils/localazy-generic-connector-client-factory.js +0 -15
- package/server/utils/model-utils.js +0 -43
- package/server/utils/objectivise-entry.js +0 -41
- package/server/utils/omit-deep.js +0 -24
- package/server/utils/parsed-localazy-entry-to-create-entry.js +0 -194
- package/server/utils/parsed-localazy-entry-to-update-entry.js +0 -83
- package/server/utils/pick-deep.js +0 -22
- package/server/utils/pick-entries.js +0 -37
- package/server/utils/populate-create-update-entry-with-base-entry.js +0 -264
- package/server/utils/request-initiator-helper.js +0 -36
- package/server/utils/reset-array-keys-deep.js +0 -19
- package/server/utils/transfer-setup-utils.js +0 -93
- package/strapi-admin.js +0 -14
- package/strapi-server.js +0 -5
- package/test/helpers/mocks.js +0 -9
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const flattenObject = require("../utils/flatten-object");
|
|
4
|
-
const {
|
|
5
|
-
getCollectionsNames,
|
|
6
|
-
findSetupModelByCollectionName,
|
|
7
|
-
isCollectionTransferEnabled,
|
|
8
|
-
getPickPathsWithComponents,
|
|
9
|
-
} = require("../utils/transfer-setup-utils");
|
|
10
|
-
const pickEntries = require("../utils/pick-entries");
|
|
11
|
-
const config = require("../config").default;
|
|
12
|
-
const {
|
|
13
|
-
isoStrapiToLocalazy,
|
|
14
|
-
} = require("../utils/iso-locales-utils");
|
|
15
|
-
const omitDeep = require("../utils/omit-deep");
|
|
16
|
-
const { UPLOAD_EVENT, UPLOAD_FINISHED_EVENT } = require('../constants/events');
|
|
17
|
-
|
|
18
|
-
module.exports = ({ strapi }) => ({
|
|
19
|
-
async upload(JobNotificationService, ctx) {
|
|
20
|
-
console.time("upload");
|
|
21
|
-
await JobNotificationService.emit(UPLOAD_EVENT, {
|
|
22
|
-
message: 'Upload started',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
let success = true;
|
|
26
|
-
|
|
27
|
-
// Strapi Service
|
|
28
|
-
const StrapiService = strapi
|
|
29
|
-
.plugin("localazy")
|
|
30
|
-
.service("strapiService");
|
|
31
|
-
|
|
32
|
-
// Strapi i18n Service
|
|
33
|
-
const StrapiI18nService = strapi
|
|
34
|
-
.plugin("localazy")
|
|
35
|
-
.service("strapiI18nService");
|
|
36
|
-
|
|
37
|
-
// Localazy Upload Service
|
|
38
|
-
const LocalazyUploadService = strapi
|
|
39
|
-
.plugin("localazy")
|
|
40
|
-
.service("localazyUploadService");
|
|
41
|
-
|
|
42
|
-
// get content transfer setup
|
|
43
|
-
const contentTransferSetup = await strapi
|
|
44
|
-
.plugin("localazy")
|
|
45
|
-
.service("pluginSettingsService")
|
|
46
|
-
.getContentTransferSetup();
|
|
47
|
-
|
|
48
|
-
if (!contentTransferSetup.has_setup) {
|
|
49
|
-
const message = "Content transfer setup is not set up.";
|
|
50
|
-
success = false;
|
|
51
|
-
await JobNotificationService.emit(UPLOAD_FINISHED_EVENT, {
|
|
52
|
-
success,
|
|
53
|
-
message,
|
|
54
|
-
});
|
|
55
|
-
strapi.log.info(message);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const { setup } = contentTransferSetup;
|
|
60
|
-
const collectionsNames = getCollectionsNames(setup);
|
|
61
|
-
const models = await StrapiService.getModels();
|
|
62
|
-
// flatten Strapi content
|
|
63
|
-
let flattenContent = {};
|
|
64
|
-
|
|
65
|
-
for (const collectionName of collectionsNames) {
|
|
66
|
-
const currentModel = models.find(
|
|
67
|
-
(model) => model.collectionName === collectionName
|
|
68
|
-
);
|
|
69
|
-
const modelUid = currentModel.uid;
|
|
70
|
-
if (!currentModel) {
|
|
71
|
-
strapi.log.warn(`Model with uid ${modelUid} is not found.`);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const transferSetupModel = findSetupModelByCollectionName(
|
|
76
|
-
setup,
|
|
77
|
-
collectionName
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
if (!isCollectionTransferEnabled(setup, collectionName)) {
|
|
81
|
-
const message = `Collection ${collectionName} transfer is disabled.`;
|
|
82
|
-
await JobNotificationService.emit(UPLOAD_EVENT, {
|
|
83
|
-
message,
|
|
84
|
-
});
|
|
85
|
-
strapi.log.info(message);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// get only enabled fields paths
|
|
90
|
-
const currentTransferSetupModel = transferSetupModel[collectionName];
|
|
91
|
-
const pickPaths = getPickPathsWithComponents(currentTransferSetupModel);
|
|
92
|
-
if (!pickPaths.length) {
|
|
93
|
-
const message = `No fields for collection ${collectionName} transfer are enabled.`;
|
|
94
|
-
await JobNotificationService.emit(UPLOAD_EVENT, {
|
|
95
|
-
message,
|
|
96
|
-
});
|
|
97
|
-
strapi.log.warn(message);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const pickPathsWithUid = pickPaths.map(
|
|
101
|
-
(pickPath) => `${modelUid}.${pickPath}`
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
let entries = await strapi.entityService.findMany(modelUid, {
|
|
105
|
-
populate: "deep",
|
|
106
|
-
});
|
|
107
|
-
entries = omitDeep(entries, [
|
|
108
|
-
// "__component",
|
|
109
|
-
"locale",
|
|
110
|
-
"localizations",
|
|
111
|
-
"createdAt",
|
|
112
|
-
"createdBy",
|
|
113
|
-
"updatedAt",
|
|
114
|
-
"updatedBy",
|
|
115
|
-
"publishedAt",
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
if (!entries) {
|
|
119
|
-
strapi.log.info(`No entries found for model ${modelUid}`);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (!Array.isArray(entries)) {
|
|
124
|
-
entries = [entries];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
entries.forEach((entry) => {
|
|
128
|
-
const flatten = flattenObject({
|
|
129
|
-
[modelUid]: entry,
|
|
130
|
-
});
|
|
131
|
-
// get only enabled fields; "__component" will be filtered out inside of the function
|
|
132
|
-
const pickedFlatten = pickEntries(flatten, pickPathsWithUid);
|
|
133
|
-
|
|
134
|
-
flattenContent = {
|
|
135
|
-
...flattenContent,
|
|
136
|
-
...pickedFlatten,
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// get Strapi default language and convert it to Localazy language code
|
|
142
|
-
const strapiLocales = await StrapiI18nService.getLocales(ctx);
|
|
143
|
-
const defaultLocale = strapiLocales.find((locale) => locale.isDefault);
|
|
144
|
-
|
|
145
|
-
const locale = defaultLocale
|
|
146
|
-
? isoStrapiToLocalazy(defaultLocale.code)
|
|
147
|
-
: config.LOCALAZY_DEFAULT_LOCALE;
|
|
148
|
-
|
|
149
|
-
const importFile = LocalazyUploadService.createImportFileRepresentation(
|
|
150
|
-
locale,
|
|
151
|
-
flattenContent
|
|
152
|
-
);
|
|
153
|
-
// Use `deprecate: "file"` if there is one chunk of transferred data only (99900 keys)!
|
|
154
|
-
const uploadConfig = {
|
|
155
|
-
contentOptions: {
|
|
156
|
-
type: config.LOCALAZY_DEFAULT_FILE_EXTENSION,
|
|
157
|
-
},
|
|
158
|
-
i18nOptions: { deprecate: "file" },
|
|
159
|
-
fileOptions: {
|
|
160
|
-
name: config.LOCALAZY_DEFAULT_FILE_NAME,
|
|
161
|
-
path: config.LOCALAZY_DEFAULT_FILE_PATH,
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
await JobNotificationService.emit(UPLOAD_EVENT, {
|
|
165
|
-
message: "Uploading collections to Localazy...",
|
|
166
|
-
});
|
|
167
|
-
await LocalazyUploadService.upload(
|
|
168
|
-
importFile,
|
|
169
|
-
uploadConfig
|
|
170
|
-
);
|
|
171
|
-
strapi.log.info("Upload finished in");
|
|
172
|
-
await JobNotificationService.emit(UPLOAD_FINISHED_EVENT, {
|
|
173
|
-
success,
|
|
174
|
-
message: "Upload finished",
|
|
175
|
-
});
|
|
176
|
-
console.timeEnd("upload");
|
|
177
|
-
},
|
|
178
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-await-in-loop */
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const localazyApiClientFactory = require("../utils/localazy-api-client-factory");
|
|
6
|
-
|
|
7
|
-
module.exports = ({ strapi }) => ({
|
|
8
|
-
/**
|
|
9
|
-
* Upload data to Localazy.
|
|
10
|
-
* Use config to adjust the upload process.
|
|
11
|
-
* Returns status and id of a last chunk
|
|
12
|
-
*/
|
|
13
|
-
async upload(file, config = {}) {
|
|
14
|
-
try {
|
|
15
|
-
const LocalazyApi = await localazyApiClientFactory();
|
|
16
|
-
const user = await strapi
|
|
17
|
-
.plugin("localazy")
|
|
18
|
-
.service("localazyUserService")
|
|
19
|
-
.getUser();
|
|
20
|
-
|
|
21
|
-
const result = await LocalazyApi.import.json({
|
|
22
|
-
project: user.project.id,
|
|
23
|
-
json: file,
|
|
24
|
-
...config,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
success: true,
|
|
29
|
-
result,
|
|
30
|
-
};
|
|
31
|
-
} catch (e) {
|
|
32
|
-
strapi.log.error(e);
|
|
33
|
-
return {
|
|
34
|
-
success: false,
|
|
35
|
-
message: e.message,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
createImportFileRepresentation(
|
|
41
|
-
sourceLang,
|
|
42
|
-
strings
|
|
43
|
-
) {
|
|
44
|
-
const file = {
|
|
45
|
-
[sourceLang]: {
|
|
46
|
-
...strings,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return file;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { KEY, emptyIdentity } = require("../db/model/localazy-user");
|
|
4
|
-
const getStrapiStore = require("../db/model/utils/get-strapi-store");
|
|
5
|
-
|
|
6
|
-
module.exports = ({ strapi }) => ({
|
|
7
|
-
async getUser() {
|
|
8
|
-
const pluginStore = getStrapiStore(strapi);
|
|
9
|
-
const user = await pluginStore.get({ key: KEY });
|
|
10
|
-
|
|
11
|
-
return user;
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
async updateUser(identity) {
|
|
15
|
-
const pluginStore = getStrapiStore(strapi);
|
|
16
|
-
await pluginStore.set({
|
|
17
|
-
key: KEY,
|
|
18
|
-
value: identity,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
return identity;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
async deleteUser() {
|
|
25
|
-
await this.updateUser(emptyIdentity);
|
|
26
|
-
|
|
27
|
-
return emptyIdentity;
|
|
28
|
-
},
|
|
29
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const contentTransferSetupModel = require("../db/model/content-transfer-setup");
|
|
4
|
-
|
|
5
|
-
const pluginSettingsModel = require("../db/model/plugin-settings");
|
|
6
|
-
const getStrapiStore = require("../db/model/utils/get-strapi-store");
|
|
7
|
-
|
|
8
|
-
module.exports = ({ strapi }) => ({
|
|
9
|
-
async getContentTransferSetup() {
|
|
10
|
-
const pluginStore = getStrapiStore(strapi);
|
|
11
|
-
const setup = await pluginStore.get({ key: contentTransferSetupModel.KEY });
|
|
12
|
-
|
|
13
|
-
return setup || contentTransferSetupModel.emptyContentTransferSetup;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
async updateContentTransferSetup(setup) {
|
|
17
|
-
const newSetup = {
|
|
18
|
-
has_setup: true,
|
|
19
|
-
setup,
|
|
20
|
-
};
|
|
21
|
-
const pluginStore = getStrapiStore(strapi);
|
|
22
|
-
await pluginStore.set({
|
|
23
|
-
key: contentTransferSetupModel.KEY,
|
|
24
|
-
value: newSetup,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return newSetup;
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
async getPluginSettings() {
|
|
31
|
-
const pluginStore = getStrapiStore(strapi);
|
|
32
|
-
const settings = await pluginStore.get({ key: pluginSettingsModel.KEY });
|
|
33
|
-
|
|
34
|
-
return settings || pluginSettingsModel.emptyPluginSettings;
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
async updatePluginSettings(settings) {
|
|
38
|
-
const currentSettings = await this.getPluginSettings();
|
|
39
|
-
|
|
40
|
-
// keep the current settings if the new settings are not provided
|
|
41
|
-
const newSettings = {
|
|
42
|
-
...currentSettings,
|
|
43
|
-
...settings,
|
|
44
|
-
};
|
|
45
|
-
const pluginStore = getStrapiStore(strapi);
|
|
46
|
-
await pluginStore.set({
|
|
47
|
-
key: pluginSettingsModel.KEY,
|
|
48
|
-
value: newSettings,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return newSettings;
|
|
52
|
-
},
|
|
53
|
-
});
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { isoLocalazyToStrapi } = require("../utils/iso-locales-utils.js");
|
|
4
|
-
const intlDisplayName = require("../utils/intl-display-name.js");
|
|
5
|
-
const omitDeep = require("../utils/omit-deep.js");
|
|
6
|
-
const { forEach, find } = require("lodash")
|
|
7
|
-
|
|
8
|
-
module.exports = ({ strapi }) => ({
|
|
9
|
-
async getLocales(ctx = {}) {
|
|
10
|
-
await strapi.controller("plugin::i18n.locales").listLocales(ctx);
|
|
11
|
-
return ctx.body;
|
|
12
|
-
},
|
|
13
|
-
async createStrapiLocale(ctx, isoLocalazy) {
|
|
14
|
-
try {
|
|
15
|
-
const isoStrapi = isoLocalazyToStrapi(isoLocalazy);
|
|
16
|
-
let localeName = intlDisplayName(isoStrapi);
|
|
17
|
-
|
|
18
|
-
if (!localeName || !isoStrapi) {
|
|
19
|
-
throw new Error("Invalid locale");
|
|
20
|
-
}
|
|
21
|
-
localeName = `${localeName} (${isoStrapi})`;
|
|
22
|
-
|
|
23
|
-
const newLocaleCtx = { ...ctx };
|
|
24
|
-
newLocaleCtx.request.body = {
|
|
25
|
-
isDefault: false,
|
|
26
|
-
code: isoStrapi,
|
|
27
|
-
name: localeName.substring(0, 50), // limit name to 50 characters (given by Strapi)
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
await strapi
|
|
31
|
-
.controller("plugin::i18n.locales")
|
|
32
|
-
.createLocale(newLocaleCtx);
|
|
33
|
-
|
|
34
|
-
return isoStrapi;
|
|
35
|
-
} catch (e) {
|
|
36
|
-
strapi.log.error(e);
|
|
37
|
-
throw e;
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
parseLocalazyKey(key) {
|
|
41
|
-
const split = key.split(/\.(?![^[]*])|\[|\]/);
|
|
42
|
-
const filteredSplit = split.filter((item) => item !== "");
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
uid: `${filteredSplit[0]}.${filteredSplit[1]}`,
|
|
46
|
-
id: filteredSplit[2],
|
|
47
|
-
rest: filteredSplit.slice(3),
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
async getEntryInLocale(modelUid, baseEntryId, isoStrapi, populate = "*") {
|
|
51
|
-
const StrapiService = strapi.plugin("localazy").service("strapiService");
|
|
52
|
-
const entry = await strapi.entityService.findOne(modelUid, baseEntryId, {
|
|
53
|
-
populate,
|
|
54
|
-
});
|
|
55
|
-
const localizations = entry.localizations;
|
|
56
|
-
if (entry.locale === isoStrapi) {
|
|
57
|
-
return entry;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (Array.isArray(localizations)) {
|
|
61
|
-
const localeEntry = localizations.find(
|
|
62
|
-
(locale) => locale.locale === isoStrapi
|
|
63
|
-
);
|
|
64
|
-
if (localeEntry) {
|
|
65
|
-
const populate = await StrapiService.getPopulateObject(modelUid);
|
|
66
|
-
return this.getEntryInLocale(
|
|
67
|
-
modelUid,
|
|
68
|
-
localeEntry.id,
|
|
69
|
-
isoStrapi,
|
|
70
|
-
populate
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return null;
|
|
76
|
-
},
|
|
77
|
-
async createLocalizationForAnExistingEntry(ctx, uid, baseEntry, newEntry) {
|
|
78
|
-
try {
|
|
79
|
-
// this might not be localizable (then method is missing, skip)
|
|
80
|
-
const contentTypeController = strapi.controller(uid);
|
|
81
|
-
const newLocalizationCtx = { ...ctx };
|
|
82
|
-
newLocalizationCtx.is = () => false; // ! else throws an error in createLocalization
|
|
83
|
-
newLocalizationCtx.params.id = baseEntry.id;
|
|
84
|
-
|
|
85
|
-
const newEntryLocale = newEntry.locale;
|
|
86
|
-
const filteredNewEntry = omitDeep(newEntry, [
|
|
87
|
-
"locale",
|
|
88
|
-
"createdAt",
|
|
89
|
-
"updatedAt",
|
|
90
|
-
]);
|
|
91
|
-
filteredNewEntry.locale = newEntryLocale;
|
|
92
|
-
// * sets as draft (no timestamp)
|
|
93
|
-
// do not completely omit as it won't process the required fields
|
|
94
|
-
filteredNewEntry.publishedAt = null;
|
|
95
|
-
|
|
96
|
-
newLocalizationCtx.request.body = filteredNewEntry;
|
|
97
|
-
|
|
98
|
-
await contentTypeController.createLocalization(newLocalizationCtx);
|
|
99
|
-
|
|
100
|
-
const insertedEntry = await this.getEntryInLocale(
|
|
101
|
-
uid,
|
|
102
|
-
baseEntry.id,
|
|
103
|
-
newEntryLocale
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return insertedEntry
|
|
107
|
-
} catch (e) {
|
|
108
|
-
strapi.log.error(e);
|
|
109
|
-
throw e;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
async updateLocalizationForAnExistingEntry(uid, updateEntryId, data) {
|
|
113
|
-
try {
|
|
114
|
-
|
|
115
|
-
const StrapiService = strapi.plugin("localazy").service("strapiService");
|
|
116
|
-
const strapiContentTypesModels = await StrapiService.getModels();
|
|
117
|
-
const populate = await StrapiService.getPopulateObject(uid);
|
|
118
|
-
|
|
119
|
-
// Bugfix by <emanuele.c@dacoco.io>:
|
|
120
|
-
// Prevents IDs to be appended when updating a localized entry. When IDs are present
|
|
121
|
-
// Strapi attempts to update a not yet existent ID into the DB
|
|
122
|
-
if (strapiContentTypesModels) {
|
|
123
|
-
const filtered = find(strapiContentTypesModels, (model) => model.uid === uid)
|
|
124
|
-
if (filtered?.attributes) {
|
|
125
|
-
for (let attribute in filtered.attributes) {
|
|
126
|
-
if (filtered.attributes[attribute]?.type === 'dynamiczone') {
|
|
127
|
-
if (!populate[attribute] || populate[attribute] !== 'deep') {
|
|
128
|
-
populate[attribute] = 'deep'
|
|
129
|
-
}
|
|
130
|
-
forEach(data[attribute], (prop) => { if (prop?.id) delete prop.id })
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const updatedEntry = await strapi.entityService.update(
|
|
137
|
-
uid,
|
|
138
|
-
updateEntryId,
|
|
139
|
-
{
|
|
140
|
-
data,
|
|
141
|
-
populate,
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
return updatedEntry;
|
|
146
|
-
} catch (e) {
|
|
147
|
-
strapi.log.error(e);
|
|
148
|
-
throw e;
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
});
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const parsedLocalazyEntryToCreateEntry = require("../utils/parsed-localazy-entry-to-create-entry");
|
|
4
|
-
const parsedLocalazyEntryToUpdateEntry = require("../utils/parsed-localazy-entry-to-update-entry");
|
|
5
|
-
const omitDeep = require("../utils/omit-deep");
|
|
6
|
-
const { merge } = require("lodash");
|
|
7
|
-
|
|
8
|
-
module.exports = ({ strapi }) => ({
|
|
9
|
-
async createEntry(
|
|
10
|
-
ctx,
|
|
11
|
-
uid,
|
|
12
|
-
strapiContentTypesModels,
|
|
13
|
-
translatedModel,
|
|
14
|
-
baseEntry,
|
|
15
|
-
isoStrapi,
|
|
16
|
-
) {
|
|
17
|
-
// * The entry will be created and then updated as the structures differ
|
|
18
|
-
// * It's one extra database call, but the amount of recursive code's complexity is reduced
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Strapi i18n Service
|
|
22
|
-
const StrapiI18nService = strapi
|
|
23
|
-
.plugin("localazy")
|
|
24
|
-
.service("strapiI18nService");
|
|
25
|
-
|
|
26
|
-
const { createEntry } = parsedLocalazyEntryToCreateEntry(
|
|
27
|
-
strapiContentTypesModels,
|
|
28
|
-
translatedModel,
|
|
29
|
-
baseEntry,
|
|
30
|
-
uid,
|
|
31
|
-
isoStrapi,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const filteredBaseEntry = omitDeep(baseEntry, [
|
|
35
|
-
"locale",
|
|
36
|
-
"localizations",
|
|
37
|
-
"createdAt",
|
|
38
|
-
"createdBy",
|
|
39
|
-
"updatedAt",
|
|
40
|
-
"updatedBy",
|
|
41
|
-
"publishedAt",
|
|
42
|
-
]);
|
|
43
|
-
|
|
44
|
-
let mergedCreateEntry = {};
|
|
45
|
-
merge(mergedCreateEntry, filteredBaseEntry, createEntry);
|
|
46
|
-
mergedCreateEntry = omitDeep(mergedCreateEntry, [
|
|
47
|
-
"locale",
|
|
48
|
-
"localizations",
|
|
49
|
-
"createdAt",
|
|
50
|
-
"createdBy",
|
|
51
|
-
"updatedAt",
|
|
52
|
-
"updatedBy",
|
|
53
|
-
"publishedAt",
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
mergedCreateEntry.locale = isoStrapi;
|
|
57
|
-
const createdEntry =
|
|
58
|
-
await StrapiI18nService.createLocalizationForAnExistingEntry(
|
|
59
|
-
ctx,
|
|
60
|
-
uid,
|
|
61
|
-
baseEntry,
|
|
62
|
-
mergedCreateEntry,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
await this.updateEntry(
|
|
66
|
-
uid,
|
|
67
|
-
createdEntry.id,
|
|
68
|
-
strapiContentTypesModels,
|
|
69
|
-
translatedModel,
|
|
70
|
-
baseEntry,
|
|
71
|
-
isoStrapi,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
return createdEntry;
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
async updateEntry(
|
|
78
|
-
uid,
|
|
79
|
-
localizedEntryId,
|
|
80
|
-
strapiContentTypesModels,
|
|
81
|
-
translatedModel,
|
|
82
|
-
baseEntry,
|
|
83
|
-
isoStrapi,
|
|
84
|
-
) {
|
|
85
|
-
// Strapi Service
|
|
86
|
-
const StrapiService = strapi
|
|
87
|
-
.plugin("localazy")
|
|
88
|
-
.service("strapiService");
|
|
89
|
-
|
|
90
|
-
// Strapi i18n Service
|
|
91
|
-
const StrapiI18nService = strapi
|
|
92
|
-
.plugin("localazy")
|
|
93
|
-
.service("strapiI18nService");
|
|
94
|
-
|
|
95
|
-
const populate = await StrapiService.getPopulateObject(uid);
|
|
96
|
-
const localizedEntry = await strapi.entityService.findOne(
|
|
97
|
-
uid,
|
|
98
|
-
localizedEntryId,
|
|
99
|
-
{
|
|
100
|
-
populate,
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const fullyPopulatedLocalizedEntry = await strapi.entityService.findOne(
|
|
105
|
-
uid,
|
|
106
|
-
localizedEntryId,
|
|
107
|
-
{
|
|
108
|
-
populate: "deep",
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
const updateEntry = await parsedLocalazyEntryToUpdateEntry(
|
|
113
|
-
strapiContentTypesModels,
|
|
114
|
-
translatedModel,
|
|
115
|
-
fullyPopulatedLocalizedEntry,
|
|
116
|
-
localizedEntry,
|
|
117
|
-
baseEntry,
|
|
118
|
-
uid,
|
|
119
|
-
isoStrapi
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
const updatedEntry = await StrapiI18nService.updateLocalizationForAnExistingEntry(
|
|
123
|
-
uid,
|
|
124
|
-
localizedEntryId,
|
|
125
|
-
updateEntry
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return updatedEntry;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const isLocalazyApplicableContentType = require("../utils/is-localazy-applicable-content-type");
|
|
4
|
-
const isGenerallyApplicableContentType = require("../utils/is-generally-applicable-content-type");
|
|
5
|
-
const buildPopulate = require("../utils/build-populate");
|
|
6
|
-
|
|
7
|
-
module.exports = ({ strapi }) => ({
|
|
8
|
-
// possible help source https://stackoverflow.com/questions/66180042/is-there-a-way-to-get-a-structure-of-a-strapi-cms-content-type
|
|
9
|
-
async getModels() {
|
|
10
|
-
return strapi.db.config.models.filter((model) =>
|
|
11
|
-
isGenerallyApplicableContentType(model)
|
|
12
|
-
);
|
|
13
|
-
},
|
|
14
|
-
async getLocalizableModels() {
|
|
15
|
-
return strapi.db.config.models.filter((model) =>
|
|
16
|
-
isLocalazyApplicableContentType(model)
|
|
17
|
-
);
|
|
18
|
-
},
|
|
19
|
-
async getPopulateObject(modelUid) {
|
|
20
|
-
const models = strapi.db.config.models;
|
|
21
|
-
return buildPopulate(models, modelUid);
|
|
22
|
-
},
|
|
23
|
-
async getPluginVersion() {
|
|
24
|
-
return require("../../package.json").version;
|
|
25
|
-
}
|
|
26
|
-
});
|