@localazy/strapi-plugin 1.6.0 → 1.7.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/dist/_chunks/{FetchIdentity-CcEjakiz.js → FetchIdentity-D89DgpbN.js} +1 -1
- package/dist/_chunks/{FetchIdentity-Bm7bc5bS.mjs → FetchIdentity-DkHj24S5.mjs} +1 -1
- package/dist/_chunks/{LanguagesSelector-DejYCwBl.js → LanguagesSelector-638KGQYw.js} +2 -2
- package/dist/_chunks/{LanguagesSelector-B1rwN7-Y.mjs → LanguagesSelector-CR_7I2R1.mjs} +2 -2
- package/dist/_chunks/{LocalazyApp-jPO7Yr1S.js → LocalazyApp-Benn8pkA.js} +5 -5
- package/dist/_chunks/{LocalazyApp-C4kbsnQh.mjs → LocalazyApp-DM3zg5E4.mjs} +5 -5
- package/dist/_chunks/{LocalazyContentTransferSetup-C1wDD9hA.mjs → LocalazyContentTransferSetup-BA_rtSBM.mjs} +4 -4
- package/dist/_chunks/{LocalazyContentTransferSetup-DZh4ZdSi.js → LocalazyContentTransferSetup-CWchyGdD.js} +4 -4
- package/dist/_chunks/{LocalazyGlobalSettings-D76it6rn.js → LocalazyGlobalSettings-88jqQbD4.js} +5 -5
- package/dist/_chunks/{LocalazyGlobalSettings-DOW5rjLn.mjs → LocalazyGlobalSettings-BWF0s9tM.mjs} +5 -5
- package/dist/_chunks/{LocalazyPanel-C_Z4W49T.mjs → LocalazyPanel-4HRa1jNl.mjs} +2 -2
- package/dist/_chunks/{LocalazyPanel-D2LQpqii.js → LocalazyPanel-D0w9JSIS.js} +2 -2
- package/dist/_chunks/{LocalazyStatusColumn-Dy6N4_X6.js → LocalazyStatusColumn-BR3f8rKp.js} +2 -2
- package/dist/_chunks/{LocalazyStatusColumn-C_ZCd_s7.mjs → LocalazyStatusColumn-D4-rZZUK.mjs} +2 -2
- package/dist/_chunks/{RequireLocalazyAuth-BVwF0bRC.js → RequireLocalazyAuth-C442750b.js} +2 -2
- package/dist/_chunks/{RequireLocalazyAuth-DNhTZZ_6.mjs → RequireLocalazyAuth-DbNjEOq-.mjs} +2 -2
- package/dist/_chunks/{entry-exclusion-service-CF_yNCly.mjs → entry-exclusion-service-Bd3mUDde.mjs} +1 -1
- package/dist/_chunks/{entry-exclusion-service-CH3ZoJQN.js → entry-exclusion-service-CAIcybXX.js} +1 -1
- package/dist/_chunks/{has-model-changed-CVJEuGxM.mjs → has-model-changed-BNs3d9q5.mjs} +4 -3
- package/dist/_chunks/{has-model-changed-DdYbyv0v.js → has-model-changed-BrDeyHFt.js} +4 -3
- package/dist/_chunks/{index-DP2ugzc_.mjs → index-C9Px4v-A.mjs} +7 -7
- package/dist/_chunks/{index-CEGaWWh3.js → index-DwFm1TyM.js} +7 -7
- package/dist/_chunks/{strapi-api-base-CCUuu7EY.js → strapi-api-base-BWZYbxxj.js} +1 -1
- package/dist/_chunks/{strapi-api-base-IiMEtDoH.mjs → strapi-api-base-lPo7wq6I.mjs} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/modules/@common/models/supported-content-type-fields.d.ts +1 -1
- package/dist/server/index.js +266 -178
- package/dist/server/index.mjs +266 -178
- package/dist/server/src/utils/blocks-to-translatable.d.ts +34 -0
- package/dist/server/src/utils/model-utils.d.ts +2 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -20534,7 +20534,7 @@ var distExports = dist$1.exports;
|
|
|
20534
20534
|
const io = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
|
|
20535
20535
|
const { Server: Server2, Namespace, Socket: Socket3 } = io;
|
|
20536
20536
|
const name = "@localazy/strapi-plugin";
|
|
20537
|
-
const version = "1.
|
|
20537
|
+
const version = "1.7.0";
|
|
20538
20538
|
const description = "The official Strapi Plugin by Localazy.";
|
|
20539
20539
|
const keywords = [
|
|
20540
20540
|
"strapi",
|
|
@@ -25625,182 +25625,6 @@ const PluginSettingsService = ({ strapi: strapi2 }) => ({
|
|
|
25625
25625
|
return cursor;
|
|
25626
25626
|
}
|
|
25627
25627
|
});
|
|
25628
|
-
const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
25629
|
-
async upload({ notificationService }) {
|
|
25630
|
-
console.time("upload");
|
|
25631
|
-
await notificationService.emit(EventType.UPLOAD, {
|
|
25632
|
-
message: "Upload started"
|
|
25633
|
-
});
|
|
25634
|
-
const activityLogsService = getActivityLogsService();
|
|
25635
|
-
const sessionId = await activityLogsService.startSession("upload", "Strapi User");
|
|
25636
|
-
await activityLogsService.addEntry(sessionId, "Upload started");
|
|
25637
|
-
let success = true;
|
|
25638
|
-
const StrapiService2 = getStrapiService();
|
|
25639
|
-
const StrapiI18nService2 = getStrapiI18nService();
|
|
25640
|
-
const LocalazyUploadService2 = getLocalazyUploadService();
|
|
25641
|
-
const EntryExclusionService2 = getEntryExclusionService();
|
|
25642
|
-
const contentTransferSetup = await getPluginSettingsService().getContentTransferSetup();
|
|
25643
|
-
if (!contentTransferSetup.has_setup) {
|
|
25644
|
-
const message = "Content transfer setup is not set up.";
|
|
25645
|
-
success = false;
|
|
25646
|
-
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
25647
|
-
success,
|
|
25648
|
-
message
|
|
25649
|
-
});
|
|
25650
|
-
await activityLogsService.addEntry(sessionId, message);
|
|
25651
|
-
await activityLogsService.finishSession(sessionId, "failed", message);
|
|
25652
|
-
strapi2.log.info(message);
|
|
25653
|
-
return;
|
|
25654
|
-
}
|
|
25655
|
-
const { setup: setup2 } = contentTransferSetup;
|
|
25656
|
-
const collectionsNames = getCollectionsNames(setup2);
|
|
25657
|
-
const models = await StrapiService2.getModels();
|
|
25658
|
-
const strapiDefaultLocaleCode = await StrapiI18nService2.getDefaultLocaleCode();
|
|
25659
|
-
const attemptedTuples = [];
|
|
25660
|
-
let pickedFlattenStrapiContent = {};
|
|
25661
|
-
for (const collectionName of collectionsNames) {
|
|
25662
|
-
const currentModel = models.find((model) => model.collectionName === collectionName);
|
|
25663
|
-
const modelUid = currentModel.uid;
|
|
25664
|
-
if (!currentModel) {
|
|
25665
|
-
strapi2.log.warn(`Model with uid ${modelUid} is not found.`);
|
|
25666
|
-
continue;
|
|
25667
|
-
}
|
|
25668
|
-
const transferSetupModel = findSetupModelByCollectionName(setup2, collectionName);
|
|
25669
|
-
if (!isCollectionTransferEnabled(setup2, collectionName)) {
|
|
25670
|
-
const message2 = `Collection ${collectionName} transfer is disabled.`;
|
|
25671
|
-
await notificationService.emit(EventType.UPLOAD, {
|
|
25672
|
-
message: message2
|
|
25673
|
-
});
|
|
25674
|
-
await activityLogsService.addEntry(sessionId, message2);
|
|
25675
|
-
strapi2.log.info(message2);
|
|
25676
|
-
continue;
|
|
25677
|
-
}
|
|
25678
|
-
const currentTransferSetupModel = transferSetupModel[collectionName];
|
|
25679
|
-
const pickPaths = getPickPathsWithComponents(currentTransferSetupModel);
|
|
25680
|
-
if (!pickPaths.length) {
|
|
25681
|
-
const message2 = `No fields for collection ${collectionName} transfer are enabled.`;
|
|
25682
|
-
await notificationService.emit(EventType.UPLOAD, {
|
|
25683
|
-
message: message2
|
|
25684
|
-
});
|
|
25685
|
-
await activityLogsService.addEntry(sessionId, message2);
|
|
25686
|
-
strapi2.log.warn(message2);
|
|
25687
|
-
continue;
|
|
25688
|
-
}
|
|
25689
|
-
const pickPathsWithUid = pickPaths.map((pickPath) => `${modelUid}.${pickPath}`);
|
|
25690
|
-
let entries = await strapi2.documents(modelUid).findMany({
|
|
25691
|
-
locUploadPLevel: 6,
|
|
25692
|
-
status: "draft"
|
|
25693
|
-
});
|
|
25694
|
-
if (!entries.length) {
|
|
25695
|
-
strapi2.log.info(`No entries found for model ${modelUid}`);
|
|
25696
|
-
continue;
|
|
25697
|
-
}
|
|
25698
|
-
const excludedEntries = await EntryExclusionService2.getContentTypeExclusions(modelUid);
|
|
25699
|
-
const filteredEntries = [];
|
|
25700
|
-
for (const entry of entries) {
|
|
25701
|
-
const isExcluded = excludedEntries.includes(entry.documentId);
|
|
25702
|
-
if (!isExcluded) {
|
|
25703
|
-
filteredEntries.push(entry);
|
|
25704
|
-
}
|
|
25705
|
-
}
|
|
25706
|
-
entries = filteredEntries;
|
|
25707
|
-
if (!entries.length) {
|
|
25708
|
-
const message2 = `All entries for model ${collectionName} are excluded from translation`;
|
|
25709
|
-
await notificationService.emit(EventType.UPLOAD, {
|
|
25710
|
-
message: message2
|
|
25711
|
-
});
|
|
25712
|
-
await activityLogsService.addEntry(sessionId, message2);
|
|
25713
|
-
strapi2.log.info(message2);
|
|
25714
|
-
continue;
|
|
25715
|
-
}
|
|
25716
|
-
const message = `Excluding ${excludedEntries.length} entries for model ${collectionName} from upload. Entries to translate: ${entries.length}.`;
|
|
25717
|
-
await notificationService.emit(EventType.UPLOAD, {
|
|
25718
|
-
message
|
|
25719
|
-
});
|
|
25720
|
-
await activityLogsService.addEntry(sessionId, message);
|
|
25721
|
-
strapi2.log.info(message);
|
|
25722
|
-
if (strapiDefaultLocaleCode) {
|
|
25723
|
-
for (const entry of entries) {
|
|
25724
|
-
attemptedTuples.push({
|
|
25725
|
-
uid: modelUid,
|
|
25726
|
-
documentId: entry.documentId,
|
|
25727
|
-
locale: strapiDefaultLocaleCode
|
|
25728
|
-
});
|
|
25729
|
-
}
|
|
25730
|
-
}
|
|
25731
|
-
entries = omitDeep(entries, ["locale", "createdAt", "updatedAt", "publishedAt"]);
|
|
25732
|
-
entries.forEach((entry) => {
|
|
25733
|
-
const flatten = flattenObject({
|
|
25734
|
-
[modelUid]: entry
|
|
25735
|
-
});
|
|
25736
|
-
const pickedFlatten = pickEntries(flatten, pickPathsWithUid);
|
|
25737
|
-
pickedFlattenStrapiContent = {
|
|
25738
|
-
...pickedFlattenStrapiContent,
|
|
25739
|
-
...pickedFlatten
|
|
25740
|
-
};
|
|
25741
|
-
});
|
|
25742
|
-
const characterLimitsMetadata = getCharacterLimitsMetadata(pickedFlattenStrapiContent, modelUid);
|
|
25743
|
-
pickedFlattenStrapiContent = {
|
|
25744
|
-
...pickedFlattenStrapiContent,
|
|
25745
|
-
...characterLimitsMetadata
|
|
25746
|
-
};
|
|
25747
|
-
}
|
|
25748
|
-
const localazyLocaleCode = strapiDefaultLocaleCode ? isoStrapiToLocalazy(strapiDefaultLocaleCode) : config.default.LOCALAZY_DEFAULT_LOCALE;
|
|
25749
|
-
const importFile = LocalazyUploadService2.createImportFileRepresentation(
|
|
25750
|
-
localazyLocaleCode,
|
|
25751
|
-
pickedFlattenStrapiContent
|
|
25752
|
-
);
|
|
25753
|
-
const uploadConfig = {
|
|
25754
|
-
contentOptions: {
|
|
25755
|
-
type: config.default.LOCALAZY_DEFAULT_FILE_EXTENSION
|
|
25756
|
-
},
|
|
25757
|
-
i18nOptions: { deprecate: "file" },
|
|
25758
|
-
fileOptions: {
|
|
25759
|
-
name: config.default.LOCALAZY_DEFAULT_FILE_NAME,
|
|
25760
|
-
path: config.default.LOCALAZY_DEFAULT_FILE_PATH
|
|
25761
|
-
}
|
|
25762
|
-
};
|
|
25763
|
-
await notificationService.emit(EventType.UPLOAD, {
|
|
25764
|
-
message: "Uploading collections to Localazy..."
|
|
25765
|
-
});
|
|
25766
|
-
await activityLogsService.addEntry(sessionId, "Uploading collections to Localazy...");
|
|
25767
|
-
try {
|
|
25768
|
-
await LocalazyUploadService2.upload(importFile, uploadConfig);
|
|
25769
|
-
await activityLogsService.recordAttemptedEntries(
|
|
25770
|
-
sessionId,
|
|
25771
|
-
attemptedTuples.map((t3) => ({ ...t3, status: "success" }))
|
|
25772
|
-
);
|
|
25773
|
-
} catch (error) {
|
|
25774
|
-
success = false;
|
|
25775
|
-
const errorMessage = `Upload to Localazy failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
25776
|
-
strapi2.log.error(errorMessage);
|
|
25777
|
-
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
25778
|
-
success,
|
|
25779
|
-
message: errorMessage
|
|
25780
|
-
});
|
|
25781
|
-
await activityLogsService.addEntry(sessionId, errorMessage);
|
|
25782
|
-
await activityLogsService.recordAttemptedEntries(
|
|
25783
|
-
sessionId,
|
|
25784
|
-
attemptedTuples.map((t3) => ({ ...t3, status: "failed", errorMessage }))
|
|
25785
|
-
);
|
|
25786
|
-
await activityLogsService.finishSession(sessionId, "failed", errorMessage);
|
|
25787
|
-
console.timeEnd("upload");
|
|
25788
|
-
return;
|
|
25789
|
-
}
|
|
25790
|
-
strapi2.log.info("Upload finished in");
|
|
25791
|
-
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
25792
|
-
success,
|
|
25793
|
-
message: "Upload finished"
|
|
25794
|
-
});
|
|
25795
|
-
await activityLogsService.addEntry(sessionId, "Upload finished");
|
|
25796
|
-
await activityLogsService.finishSession(
|
|
25797
|
-
sessionId,
|
|
25798
|
-
success ? "completed" : "failed",
|
|
25799
|
-
success ? "Upload completed successfully" : "Upload finished with errors"
|
|
25800
|
-
);
|
|
25801
|
-
console.timeEnd("upload");
|
|
25802
|
-
}
|
|
25803
|
-
});
|
|
25804
25628
|
var symbolTag$2 = "[object Symbol]";
|
|
25805
25629
|
function isSymbol(value) {
|
|
25806
25630
|
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$2;
|
|
@@ -26115,6 +25939,263 @@ function baseSet(object, path, value, customizer) {
|
|
|
26115
25939
|
function set(object, path, value) {
|
|
26116
25940
|
return object == null ? object : baseSet(object, path, value);
|
|
26117
25941
|
}
|
|
25942
|
+
const BLOCKS_ATTRIBUTE_TYPE = "blocks";
|
|
25943
|
+
const projectBlocksFields = (entry, model, getModel) => {
|
|
25944
|
+
const cloned = cloneDeep(entry);
|
|
25945
|
+
walkAndProject(cloned, model, getModel);
|
|
25946
|
+
return cloned;
|
|
25947
|
+
};
|
|
25948
|
+
const walkAndProject = (value, model, getModel) => {
|
|
25949
|
+
if (!value || !model?.attributes) {
|
|
25950
|
+
return;
|
|
25951
|
+
}
|
|
25952
|
+
for (const [attributeName, attribute] of Object.entries(model.attributes)) {
|
|
25953
|
+
const fieldValue = value[attributeName];
|
|
25954
|
+
if (fieldValue === void 0 || fieldValue === null) {
|
|
25955
|
+
continue;
|
|
25956
|
+
}
|
|
25957
|
+
if (attribute.type === BLOCKS_ATTRIBUTE_TYPE) {
|
|
25958
|
+
value[attributeName] = projectBlocksValue(fieldValue);
|
|
25959
|
+
} else if (attribute.type === "component") {
|
|
25960
|
+
const componentModel = getModel(attribute.component);
|
|
25961
|
+
if (attribute.repeatable && Array.isArray(fieldValue)) {
|
|
25962
|
+
fieldValue.forEach((item) => walkAndProject(item, componentModel, getModel));
|
|
25963
|
+
} else if (isPlainObject(fieldValue)) {
|
|
25964
|
+
walkAndProject(fieldValue, componentModel, getModel);
|
|
25965
|
+
}
|
|
25966
|
+
} else if (attribute.type === "dynamiczone" && Array.isArray(fieldValue)) {
|
|
25967
|
+
fieldValue.forEach((item) => {
|
|
25968
|
+
if (item?.__component) {
|
|
25969
|
+
walkAndProject(item, getModel(item.__component), getModel);
|
|
25970
|
+
}
|
|
25971
|
+
});
|
|
25972
|
+
}
|
|
25973
|
+
}
|
|
25974
|
+
};
|
|
25975
|
+
const projectBlocksValue = (nodes) => {
|
|
25976
|
+
if (!Array.isArray(nodes)) {
|
|
25977
|
+
return nodes;
|
|
25978
|
+
}
|
|
25979
|
+
return nodes.map(projectNode);
|
|
25980
|
+
};
|
|
25981
|
+
const projectNode = (node) => {
|
|
25982
|
+
if (!isPlainObject(node)) {
|
|
25983
|
+
return {};
|
|
25984
|
+
}
|
|
25985
|
+
const projected = {};
|
|
25986
|
+
if (typeof node.text === "string") {
|
|
25987
|
+
projected.text = node.text;
|
|
25988
|
+
}
|
|
25989
|
+
if (Array.isArray(node.children)) {
|
|
25990
|
+
projected.children = node.children.map(projectNode);
|
|
25991
|
+
}
|
|
25992
|
+
return projected;
|
|
25993
|
+
};
|
|
25994
|
+
const overlayBlocksTranslation = (sourceAst, translated) => {
|
|
25995
|
+
if (!Array.isArray(sourceAst)) {
|
|
25996
|
+
return void 0;
|
|
25997
|
+
}
|
|
25998
|
+
return sourceAst.map((node, index2) => overlayNode(node, get(translated, [String(index2)])));
|
|
25999
|
+
};
|
|
26000
|
+
const overlayNode = (node, translatedNode) => {
|
|
26001
|
+
if (!isPlainObject(node)) {
|
|
26002
|
+
return cloneDeep(node);
|
|
26003
|
+
}
|
|
26004
|
+
if (typeof node.text === "string") {
|
|
26005
|
+
const translatedText = isPlainObject(translatedNode) ? translatedNode.text : void 0;
|
|
26006
|
+
return typeof translatedText === "string" ? { ...node, text: translatedText } : cloneDeep(node);
|
|
26007
|
+
}
|
|
26008
|
+
if (Array.isArray(node.children)) {
|
|
26009
|
+
return {
|
|
26010
|
+
...node,
|
|
26011
|
+
children: node.children.map(
|
|
26012
|
+
(child, index2) => overlayNode(child, translatedNode ? get(translatedNode, ["children", String(index2)]) : void 0)
|
|
26013
|
+
)
|
|
26014
|
+
};
|
|
26015
|
+
}
|
|
26016
|
+
return cloneDeep(node);
|
|
26017
|
+
};
|
|
26018
|
+
const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
26019
|
+
async upload({ notificationService }) {
|
|
26020
|
+
console.time("upload");
|
|
26021
|
+
await notificationService.emit(EventType.UPLOAD, {
|
|
26022
|
+
message: "Upload started"
|
|
26023
|
+
});
|
|
26024
|
+
const activityLogsService = getActivityLogsService();
|
|
26025
|
+
const sessionId = await activityLogsService.startSession("upload", "Strapi User");
|
|
26026
|
+
await activityLogsService.addEntry(sessionId, "Upload started");
|
|
26027
|
+
let success = true;
|
|
26028
|
+
const StrapiService2 = getStrapiService();
|
|
26029
|
+
const StrapiI18nService2 = getStrapiI18nService();
|
|
26030
|
+
const LocalazyUploadService2 = getLocalazyUploadService();
|
|
26031
|
+
const EntryExclusionService2 = getEntryExclusionService();
|
|
26032
|
+
const contentTransferSetup = await getPluginSettingsService().getContentTransferSetup();
|
|
26033
|
+
if (!contentTransferSetup.has_setup) {
|
|
26034
|
+
const message = "Content transfer setup is not set up.";
|
|
26035
|
+
success = false;
|
|
26036
|
+
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
26037
|
+
success,
|
|
26038
|
+
message
|
|
26039
|
+
});
|
|
26040
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
26041
|
+
await activityLogsService.finishSession(sessionId, "failed", message);
|
|
26042
|
+
strapi2.log.info(message);
|
|
26043
|
+
return;
|
|
26044
|
+
}
|
|
26045
|
+
const { setup: setup2 } = contentTransferSetup;
|
|
26046
|
+
const collectionsNames = getCollectionsNames(setup2);
|
|
26047
|
+
const models = await StrapiService2.getModels();
|
|
26048
|
+
const strapiDefaultLocaleCode = await StrapiI18nService2.getDefaultLocaleCode();
|
|
26049
|
+
const attemptedTuples = [];
|
|
26050
|
+
let pickedFlattenStrapiContent = {};
|
|
26051
|
+
for (const collectionName of collectionsNames) {
|
|
26052
|
+
const currentModel = models.find((model) => model.collectionName === collectionName);
|
|
26053
|
+
const modelUid = currentModel.uid;
|
|
26054
|
+
if (!currentModel) {
|
|
26055
|
+
strapi2.log.warn(`Model with uid ${modelUid} is not found.`);
|
|
26056
|
+
continue;
|
|
26057
|
+
}
|
|
26058
|
+
const transferSetupModel = findSetupModelByCollectionName(setup2, collectionName);
|
|
26059
|
+
if (!isCollectionTransferEnabled(setup2, collectionName)) {
|
|
26060
|
+
const message2 = `Collection ${collectionName} transfer is disabled.`;
|
|
26061
|
+
await notificationService.emit(EventType.UPLOAD, {
|
|
26062
|
+
message: message2
|
|
26063
|
+
});
|
|
26064
|
+
await activityLogsService.addEntry(sessionId, message2);
|
|
26065
|
+
strapi2.log.info(message2);
|
|
26066
|
+
continue;
|
|
26067
|
+
}
|
|
26068
|
+
const currentTransferSetupModel = transferSetupModel[collectionName];
|
|
26069
|
+
const pickPaths = getPickPathsWithComponents(currentTransferSetupModel);
|
|
26070
|
+
if (!pickPaths.length) {
|
|
26071
|
+
const message2 = `No fields for collection ${collectionName} transfer are enabled.`;
|
|
26072
|
+
await notificationService.emit(EventType.UPLOAD, {
|
|
26073
|
+
message: message2
|
|
26074
|
+
});
|
|
26075
|
+
await activityLogsService.addEntry(sessionId, message2);
|
|
26076
|
+
strapi2.log.warn(message2);
|
|
26077
|
+
continue;
|
|
26078
|
+
}
|
|
26079
|
+
const pickPathsWithUid = pickPaths.map((pickPath) => `${modelUid}.${pickPath}`);
|
|
26080
|
+
let entries = await strapi2.documents(modelUid).findMany({
|
|
26081
|
+
locUploadPLevel: 6,
|
|
26082
|
+
status: "draft"
|
|
26083
|
+
});
|
|
26084
|
+
if (!entries.length) {
|
|
26085
|
+
strapi2.log.info(`No entries found for model ${modelUid}`);
|
|
26086
|
+
continue;
|
|
26087
|
+
}
|
|
26088
|
+
const excludedEntries = await EntryExclusionService2.getContentTypeExclusions(modelUid);
|
|
26089
|
+
const filteredEntries = [];
|
|
26090
|
+
for (const entry of entries) {
|
|
26091
|
+
const isExcluded = excludedEntries.includes(entry.documentId);
|
|
26092
|
+
if (!isExcluded) {
|
|
26093
|
+
filteredEntries.push(entry);
|
|
26094
|
+
}
|
|
26095
|
+
}
|
|
26096
|
+
entries = filteredEntries;
|
|
26097
|
+
if (!entries.length) {
|
|
26098
|
+
const message2 = `All entries for model ${collectionName} are excluded from translation`;
|
|
26099
|
+
await notificationService.emit(EventType.UPLOAD, {
|
|
26100
|
+
message: message2
|
|
26101
|
+
});
|
|
26102
|
+
await activityLogsService.addEntry(sessionId, message2);
|
|
26103
|
+
strapi2.log.info(message2);
|
|
26104
|
+
continue;
|
|
26105
|
+
}
|
|
26106
|
+
const message = `Excluding ${excludedEntries.length} entries for model ${collectionName} from upload. Entries to translate: ${entries.length}.`;
|
|
26107
|
+
await notificationService.emit(EventType.UPLOAD, {
|
|
26108
|
+
message
|
|
26109
|
+
});
|
|
26110
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
26111
|
+
strapi2.log.info(message);
|
|
26112
|
+
if (strapiDefaultLocaleCode) {
|
|
26113
|
+
for (const entry of entries) {
|
|
26114
|
+
attemptedTuples.push({
|
|
26115
|
+
uid: modelUid,
|
|
26116
|
+
documentId: entry.documentId,
|
|
26117
|
+
locale: strapiDefaultLocaleCode
|
|
26118
|
+
});
|
|
26119
|
+
}
|
|
26120
|
+
}
|
|
26121
|
+
entries = omitDeep(entries, ["locale", "createdAt", "updatedAt", "publishedAt"]);
|
|
26122
|
+
entries.forEach((entry) => {
|
|
26123
|
+
const projectedEntry = projectBlocksFields(
|
|
26124
|
+
entry,
|
|
26125
|
+
strapi2.getModel(modelUid),
|
|
26126
|
+
(uid) => strapi2.getModel(uid)
|
|
26127
|
+
);
|
|
26128
|
+
const flatten = flattenObject({
|
|
26129
|
+
[modelUid]: projectedEntry
|
|
26130
|
+
});
|
|
26131
|
+
const pickedFlatten = pickEntries(flatten, pickPathsWithUid);
|
|
26132
|
+
pickedFlattenStrapiContent = {
|
|
26133
|
+
...pickedFlattenStrapiContent,
|
|
26134
|
+
...pickedFlatten
|
|
26135
|
+
};
|
|
26136
|
+
});
|
|
26137
|
+
const characterLimitsMetadata = getCharacterLimitsMetadata(pickedFlattenStrapiContent, modelUid);
|
|
26138
|
+
pickedFlattenStrapiContent = {
|
|
26139
|
+
...pickedFlattenStrapiContent,
|
|
26140
|
+
...characterLimitsMetadata
|
|
26141
|
+
};
|
|
26142
|
+
}
|
|
26143
|
+
const localazyLocaleCode = strapiDefaultLocaleCode ? isoStrapiToLocalazy(strapiDefaultLocaleCode) : config.default.LOCALAZY_DEFAULT_LOCALE;
|
|
26144
|
+
const importFile = LocalazyUploadService2.createImportFileRepresentation(
|
|
26145
|
+
localazyLocaleCode,
|
|
26146
|
+
pickedFlattenStrapiContent
|
|
26147
|
+
);
|
|
26148
|
+
const uploadConfig = {
|
|
26149
|
+
contentOptions: {
|
|
26150
|
+
type: config.default.LOCALAZY_DEFAULT_FILE_EXTENSION
|
|
26151
|
+
},
|
|
26152
|
+
i18nOptions: { deprecate: "file" },
|
|
26153
|
+
fileOptions: {
|
|
26154
|
+
name: config.default.LOCALAZY_DEFAULT_FILE_NAME,
|
|
26155
|
+
path: config.default.LOCALAZY_DEFAULT_FILE_PATH
|
|
26156
|
+
}
|
|
26157
|
+
};
|
|
26158
|
+
await notificationService.emit(EventType.UPLOAD, {
|
|
26159
|
+
message: "Uploading collections to Localazy..."
|
|
26160
|
+
});
|
|
26161
|
+
await activityLogsService.addEntry(sessionId, "Uploading collections to Localazy...");
|
|
26162
|
+
try {
|
|
26163
|
+
await LocalazyUploadService2.upload(importFile, uploadConfig);
|
|
26164
|
+
await activityLogsService.recordAttemptedEntries(
|
|
26165
|
+
sessionId,
|
|
26166
|
+
attemptedTuples.map((t3) => ({ ...t3, status: "success" }))
|
|
26167
|
+
);
|
|
26168
|
+
} catch (error) {
|
|
26169
|
+
success = false;
|
|
26170
|
+
const errorMessage = `Upload to Localazy failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
26171
|
+
strapi2.log.error(errorMessage);
|
|
26172
|
+
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
26173
|
+
success,
|
|
26174
|
+
message: errorMessage
|
|
26175
|
+
});
|
|
26176
|
+
await activityLogsService.addEntry(sessionId, errorMessage);
|
|
26177
|
+
await activityLogsService.recordAttemptedEntries(
|
|
26178
|
+
sessionId,
|
|
26179
|
+
attemptedTuples.map((t3) => ({ ...t3, status: "failed", errorMessage }))
|
|
26180
|
+
);
|
|
26181
|
+
await activityLogsService.finishSession(sessionId, "failed", errorMessage);
|
|
26182
|
+
console.timeEnd("upload");
|
|
26183
|
+
return;
|
|
26184
|
+
}
|
|
26185
|
+
strapi2.log.info("Upload finished in");
|
|
26186
|
+
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
26187
|
+
success,
|
|
26188
|
+
message: "Upload finished"
|
|
26189
|
+
});
|
|
26190
|
+
await activityLogsService.addEntry(sessionId, "Upload finished");
|
|
26191
|
+
await activityLogsService.finishSession(
|
|
26192
|
+
sessionId,
|
|
26193
|
+
success ? "completed" : "failed",
|
|
26194
|
+
success ? "Upload completed successfully" : "Upload finished with errors"
|
|
26195
|
+
);
|
|
26196
|
+
console.timeEnd("upload");
|
|
26197
|
+
}
|
|
26198
|
+
});
|
|
26118
26199
|
const hasDynamicZoneKeySegment = (parsedKey) => {
|
|
26119
26200
|
return parsedKey.some((segment) => segment.includes(";"));
|
|
26120
26201
|
};
|
|
@@ -26802,6 +26883,9 @@ const isRepeatable = (attributeObj) => {
|
|
|
26802
26883
|
const isRelation = (attributeObj) => {
|
|
26803
26884
|
return attributeObj.type === "relation" && attributeObj.target !== "plugin::upload.file";
|
|
26804
26885
|
};
|
|
26886
|
+
const isBlocks = (attributeObj) => {
|
|
26887
|
+
return attributeObj.type === BLOCKS_ATTRIBUTE_TYPE;
|
|
26888
|
+
};
|
|
26805
26889
|
const findModel = (models, uid) => {
|
|
26806
26890
|
const model = models.find((model2) => model2.uid === uid);
|
|
26807
26891
|
return model;
|
|
@@ -26945,7 +27029,11 @@ const parsedLocalazyEntryToCreateEntry = (models, parsedLocalazyEntry, baseEntry
|
|
|
26945
27029
|
newPrefixBase = `${dzParamKey}.${baseEntryDZIndex}`;
|
|
26946
27030
|
newPrefix = `${newPrefixBase}.${objectKey}`;
|
|
26947
27031
|
}
|
|
26948
|
-
|
|
27032
|
+
const valueToSet = isBlocks(attribute) ? overlayBlocksTranslation(get(baseEntry, newPrefix), value) : value;
|
|
27033
|
+
if (valueToSet === void 0) {
|
|
27034
|
+
return;
|
|
27035
|
+
}
|
|
27036
|
+
set(createEntry, newPrefix, valueToSet);
|
|
26949
27037
|
if (component) {
|
|
26950
27038
|
const componentKeyToSet = `${newPrefixBase}.__component`;
|
|
26951
27039
|
set(createEntry, componentKeyToSet, component);
|