pim-import 5.5.0 → 5.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/algolia/config.d.ts +78 -0
- package/dist/algolia/config.js +27 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/libs/contentful.js +1 -0
- package/dist/pim/methods/catalogs.js +2 -2
- package/dist/pim/methods/families.js +1 -1
- package/dist/pim/methods/models.js +1 -1
- package/dist/pim/methods/products.js +3 -1
- package/dist/pim/methods/subfamilies.js +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +9 -5
- package/package.json +1 -1
package/dist/algolia/config.d.ts
CHANGED
|
@@ -102,4 +102,82 @@ export declare const getIndicesSettings: () => {
|
|
|
102
102
|
export declare const getIndexConfig: (indexKey: AvailableIndicesKey) => any;
|
|
103
103
|
export declare const getIndex: (indexKey: AvailableIndicesKey) => import("algoliasearch").SearchIndex;
|
|
104
104
|
export declare const resetIndexSettings: (indexKey: AvailableIndicesKey) => import("algoliasearch").SearchIndex;
|
|
105
|
+
export declare const cloneIndexSettings: (sourceIndex: string, targetIndex: string) => Promise<{
|
|
106
|
+
sourceIndex: string;
|
|
107
|
+
targetIndex: string;
|
|
108
|
+
clonedSettings: {
|
|
109
|
+
searchableAttributes?: readonly string[] | undefined;
|
|
110
|
+
attributesToIndex?: readonly string[] | undefined;
|
|
111
|
+
attributesForFaceting?: readonly string[] | undefined;
|
|
112
|
+
unretrievableAttributes?: readonly string[] | undefined;
|
|
113
|
+
attributesToRetrieve?: readonly string[] | undefined;
|
|
114
|
+
ranking?: readonly string[] | undefined;
|
|
115
|
+
customRanking?: readonly string[] | undefined;
|
|
116
|
+
replicas?: readonly string[] | undefined;
|
|
117
|
+
slaves?: readonly string[] | undefined;
|
|
118
|
+
primary?: string | undefined;
|
|
119
|
+
maxValuesPerFacet?: number | undefined;
|
|
120
|
+
sortFacetValuesBy?: "count" | "alpha" | undefined;
|
|
121
|
+
attributesToHighlight?: readonly string[] | undefined;
|
|
122
|
+
attributesToSnippet?: readonly string[] | undefined;
|
|
123
|
+
highlightPreTag?: string | undefined;
|
|
124
|
+
highlightPostTag?: string | undefined;
|
|
125
|
+
snippetEllipsisText?: string | undefined;
|
|
126
|
+
restrictHighlightAndSnippetArrays?: boolean | undefined;
|
|
127
|
+
hitsPerPage?: number | undefined;
|
|
128
|
+
paginationLimitedTo?: number | undefined;
|
|
129
|
+
minWordSizefor1Typo?: number | undefined;
|
|
130
|
+
minWordSizefor2Typos?: number | undefined;
|
|
131
|
+
typoTolerance?: string | boolean | undefined;
|
|
132
|
+
allowTyposOnNumericTokens?: boolean | undefined;
|
|
133
|
+
disableTypoToleranceOnAttributes?: readonly string[] | undefined;
|
|
134
|
+
disableTypoToleranceOnWords?: readonly string[] | undefined;
|
|
135
|
+
separatorsToIndex?: string | undefined;
|
|
136
|
+
ignorePlurals?: boolean | readonly string[] | undefined;
|
|
137
|
+
queryLanguages?: readonly string[] | undefined;
|
|
138
|
+
indexLanguages?: readonly string[] | undefined;
|
|
139
|
+
enableRules?: boolean | undefined;
|
|
140
|
+
queryType?: "prefixLast" | "prefixAll" | "prefixNone" | undefined;
|
|
141
|
+
removeWordsIfNoResults?: "none" | "lastWords" | "firstWords" | "allOptional" | undefined;
|
|
142
|
+
advancedSyntax?: boolean | undefined;
|
|
143
|
+
advancedSyntaxFeatures?: readonly ("exactPhrase" | "excludeWords")[] | undefined;
|
|
144
|
+
optionalWords?: readonly string[] | undefined;
|
|
145
|
+
disablePrefixOnAttributes?: readonly string[] | undefined;
|
|
146
|
+
disableExactOnAttributes?: readonly string[] | undefined;
|
|
147
|
+
exactOnSingleWordQuery?: "attribute" | "none" | "word" | undefined;
|
|
148
|
+
alternativesAsExact?: readonly ("ignorePlurals" | "singleWordSynonym" | "multiWordsSynonym")[] | undefined;
|
|
149
|
+
removeStopWords?: boolean | readonly string[] | undefined;
|
|
150
|
+
numericAttributesForFiltering?: readonly string[] | undefined;
|
|
151
|
+
allowCompressionOfIntegerArray?: boolean | undefined;
|
|
152
|
+
attributeForDistinct?: string | undefined;
|
|
153
|
+
distinct?: number | boolean | undefined;
|
|
154
|
+
replaceSynonymsInHighlight?: boolean | undefined;
|
|
155
|
+
attributeCriteriaComputedByMinProximity?: boolean | undefined;
|
|
156
|
+
minProximity?: number | undefined;
|
|
157
|
+
responseFields?: readonly string[] | undefined;
|
|
158
|
+
maxFacetHits?: number | undefined;
|
|
159
|
+
camelCaseAttributes?: readonly string[] | undefined;
|
|
160
|
+
decompoundedAttributes?: Readonly<Record<string, readonly string[]>> | undefined;
|
|
161
|
+
keepDiacriticsOnCharacters?: string | undefined;
|
|
162
|
+
customNormalization?: Readonly<Record<string, Readonly<Record<string, string>>>> | undefined;
|
|
163
|
+
enablePersonalization?: boolean | undefined;
|
|
164
|
+
userData?: any;
|
|
165
|
+
decompoundQuery?: boolean | undefined;
|
|
166
|
+
attributesToTransliterate?: readonly string[] | undefined;
|
|
167
|
+
relevancyStrictness?: number | undefined;
|
|
168
|
+
renderingContent?: {
|
|
169
|
+
readonly facetOrdering?: {
|
|
170
|
+
readonly facets?: {
|
|
171
|
+
readonly order?: readonly string[] | undefined;
|
|
172
|
+
} | undefined;
|
|
173
|
+
readonly values?: {
|
|
174
|
+
readonly [facet: string]: {
|
|
175
|
+
readonly order?: readonly string[] | undefined;
|
|
176
|
+
readonly sortRemainingBy?: "count" | "alpha" | "hidden" | undefined;
|
|
177
|
+
};
|
|
178
|
+
} | undefined;
|
|
179
|
+
} | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
};
|
|
182
|
+
}>;
|
|
105
183
|
export declare const removeIndexObject: (objectId: string, indexKey: AvailableIndicesKey) => Promise<void>;
|
package/dist/algolia/config.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.removeIndexObject = exports.resetIndexSettings = exports.getIndex = exports.getIndexConfig = exports.getIndicesSettings = exports.getClient = void 0;
|
|
6
|
+
exports.removeIndexObject = exports.cloneIndexSettings = exports.resetIndexSettings = exports.getIndex = exports.getIndexConfig = exports.getIndicesSettings = exports.getClient = void 0;
|
|
7
7
|
const algoliasearch_1 = __importDefault(require("algoliasearch"));
|
|
8
8
|
const logs_1 = require("../libs/logs");
|
|
9
9
|
const getClient = () => {
|
|
@@ -290,6 +290,32 @@ const resetIndexSettings = (indexKey) => {
|
|
|
290
290
|
}
|
|
291
291
|
};
|
|
292
292
|
exports.resetIndexSettings = resetIndexSettings;
|
|
293
|
+
const cloneIndexSettings = async (sourceIndex, targetIndex) => {
|
|
294
|
+
try {
|
|
295
|
+
const client = (0, exports.getClient)();
|
|
296
|
+
const sourceAlgoliaIndex = client.initIndex(sourceIndex);
|
|
297
|
+
const targetAlgoliaIndex = client.initIndex(targetIndex);
|
|
298
|
+
console.log(`Copying settings from ${sourceIndex} to ${targetIndex}`);
|
|
299
|
+
const sourceSettings = await sourceAlgoliaIndex.getSettings();
|
|
300
|
+
const settingsToClone = { ...sourceSettings };
|
|
301
|
+
delete settingsToClone.replicas;
|
|
302
|
+
delete settingsToClone.primary;
|
|
303
|
+
delete settingsToClone.slaves;
|
|
304
|
+
await targetAlgoliaIndex.setSettings(settingsToClone);
|
|
305
|
+
(0, logs_1.log)(`Successfully cloned settings from ${sourceIndex} to ${targetIndex}`);
|
|
306
|
+
return {
|
|
307
|
+
sourceIndex,
|
|
308
|
+
targetIndex,
|
|
309
|
+
clonedSettings: settingsToClone,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
const errorMessage = `Error cloning settings from ${sourceIndex} to ${targetIndex}: ${error}`;
|
|
314
|
+
(0, logs_1.log)(errorMessage);
|
|
315
|
+
throw new Error(errorMessage);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
exports.cloneIndexSettings = cloneIndexSettings;
|
|
293
319
|
const removeIndexObject = async (objectId, indexKey) => {
|
|
294
320
|
const index = (0, exports.getIndex)(indexKey);
|
|
295
321
|
await index.deleteObject(objectId);
|
package/dist/browser.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { importSubModels } from "./pim/methods/submodels";
|
|
|
9
9
|
export { importSubFamilies } from "./pim/methods/subfamilies";
|
|
10
10
|
export { importFamilies } from "./pim/methods/families";
|
|
11
11
|
export { importProductByCode, setProductsRelationships, setProductRelationships, getAllProductEntriesByCatalog, audit, generateTechSpecPdf, setProductsAutodescription, getProductAutodescription, setProductAutodescriptionByTopicId, removeProductFromColorVariantsByProductLine, removeAllProductModelProductRelations, } from "./pim/methods/products";
|
|
12
|
-
export { resetIndexSettings } from "./algolia/config";
|
|
12
|
+
export { resetIndexSettings, cloneIndexSettings } from "./algolia/config";
|
|
13
13
|
export { reindexFamilies, reindexFamily, removeFamilyObject, } from "./algolia/families";
|
|
14
14
|
export { reindexSubFamilies, reindexSubFamily, removeSubFamilyObject, } from "./algolia/subFamilies";
|
|
15
15
|
export { reindexProduct, reindexProducts, removeProductObject, } from "./algolia/products";
|
package/dist/browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.netlifyBuild = exports.generatePDFByUrl = exports.removeRecordsByStatus = exports.setLogId = exports.log = exports.getStaticDailyProducts = exports.getLocalISOTime = exports.importDownloads = exports.removePostObject = exports.reindexPosts = exports.reindexPost = exports.removePressReleaseObject = exports.reindexPressReleases = exports.reindexPressRelease = exports.removePressReviewObject = exports.reindexPressReviews = exports.reindexPressReview = exports.removeStoryObject = exports.reindexStories = exports.reindexStory = exports.removeProjectObject = exports.reindexProjects = exports.reindexProject = exports.removeInspirationObject = exports.reindexInspirations = exports.reindexInspiration = exports.removeDownloadObject = exports.reindexDownloads = exports.reindexDownload = void 0;
|
|
3
|
+
exports.reindexModels = exports.reindexModel = exports.removeSubModelObject = exports.reindexSubModels = exports.reindexSubModel = exports.removeProductObject = exports.reindexProducts = exports.reindexProduct = exports.removeSubFamilyObject = exports.reindexSubFamily = exports.reindexSubFamilies = exports.removeFamilyObject = exports.reindexFamily = exports.reindexFamilies = exports.cloneIndexSettings = exports.resetIndexSettings = exports.removeAllProductModelProductRelations = exports.removeProductFromColorVariantsByProductLine = exports.setProductAutodescriptionByTopicId = exports.getProductAutodescription = exports.setProductsAutodescription = exports.generateTechSpecPdf = exports.audit = exports.getAllProductEntriesByCatalog = exports.setProductRelationships = exports.setProductsRelationships = exports.importProductByCode = exports.importFamilies = exports.importSubFamilies = exports.importSubModels = exports.importModels = exports.importLatestProducts = exports.importCategories = exports.importDictionaryProductSubLine = exports.importDictionaryProductLine = exports.importDictionaryData = exports.importDictionaryIcons = exports.importDictionaryFields = exports.savePDFToS3 = exports.getFileFromS3 = exports.saveJsonToS3 = exports.uploadS3 = exports.initS3 = exports.getTopicPage = exports.getEntryByID = exports.deleteEntries = exports.deletePages = exports.initBaseEntries = exports.initContentful = exports.initPim = void 0;
|
|
4
|
+
exports.netlifyBuild = exports.generatePDFByUrl = exports.removeRecordsByStatus = exports.setLogId = exports.log = exports.getStaticDailyProducts = exports.getLocalISOTime = exports.importDownloads = exports.removePostObject = exports.reindexPosts = exports.reindexPost = exports.removePressReleaseObject = exports.reindexPressReleases = exports.reindexPressRelease = exports.removePressReviewObject = exports.reindexPressReviews = exports.reindexPressReview = exports.removeStoryObject = exports.reindexStories = exports.reindexStory = exports.removeProjectObject = exports.reindexProjects = exports.reindexProject = exports.removeInspirationObject = exports.reindexInspirations = exports.reindexInspiration = exports.removeDownloadObject = exports.reindexDownloads = exports.reindexDownload = exports.removeModelObject = void 0;
|
|
5
5
|
var config_1 = require("./pim/config");
|
|
6
6
|
Object.defineProperty(exports, "initPim", { enumerable: true, get: function () { return config_1.init; } });
|
|
7
7
|
var contentful_1 = require("./libs/contentful");
|
|
@@ -49,6 +49,7 @@ Object.defineProperty(exports, "removeProductFromColorVariantsByProductLine", {
|
|
|
49
49
|
Object.defineProperty(exports, "removeAllProductModelProductRelations", { enumerable: true, get: function () { return products_1.removeAllProductModelProductRelations; } });
|
|
50
50
|
var config_2 = require("./algolia/config");
|
|
51
51
|
Object.defineProperty(exports, "resetIndexSettings", { enumerable: true, get: function () { return config_2.resetIndexSettings; } });
|
|
52
|
+
Object.defineProperty(exports, "cloneIndexSettings", { enumerable: true, get: function () { return config_2.cloneIndexSettings; } });
|
|
52
53
|
var families_2 = require("./algolia/families");
|
|
53
54
|
Object.defineProperty(exports, "reindexFamilies", { enumerable: true, get: function () { return families_2.reindexFamilies; } });
|
|
54
55
|
Object.defineProperty(exports, "reindexFamily", { enumerable: true, get: function () { return families_2.reindexFamily; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { importProductByCode, setProductsRelationships, setProductRelationships,
|
|
|
12
12
|
export { publishAllProductDrafts } from "./pim/methods/bulkPublish";
|
|
13
13
|
export { migrateEntryFields } from "./pim/methods/migrateEntryFields";
|
|
14
14
|
export { checkTopicDraftAndPagePublished } from "./pim/methods/checkTopicDraftAndPagePublished";
|
|
15
|
-
export { getIndex } from "./algolia/config";
|
|
15
|
+
export { getIndex, cloneIndexSettings } from "./algolia/config";
|
|
16
16
|
export { reindexFamilies, reindexFamily, removeFamilyObject, } from "./algolia/families";
|
|
17
17
|
export { reindexSubFamilies, reindexSubFamily, removeSubFamilyObject, } from "./algolia/subFamilies";
|
|
18
18
|
export { reindexProduct, reindexProducts, removeProductObject, triggerPDFGenerator, } from "./algolia/products";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.netlifyBuild = exports.notify = exports.importDesigner = exports.importDesigners = exports.generatePDFByUrl = exports.removeRecordsByStatus = exports.getLogFolder = exports.setLogFilename = exports.setLogPath = exports.setLogId = exports.setServerUtils = exports.log = exports.getLatestProducts = exports.getStaticDailyProducts = exports.getLocalISOTime = exports.importDownloads = exports.removePostObject = exports.reindexPosts = exports.reindexPost = exports.removePressReleaseObject = exports.reindexPressReleases = exports.reindexPressRelease = exports.removePressReviewObject = exports.reindexPressReviews = exports.reindexPressReview = exports.removeStoryObject = exports.reindexStories = exports.reindexStory = exports.removeProjectObject = exports.reindexProjects = exports.reindexProject = exports.removeInspirationObject = exports.reindexInspirations = exports.reindexInspiration = exports.removeDownloadObject = exports.reindexDownloads = exports.reindexDownload = exports.removeModelObject = exports.reindexModels = exports.reindexModel = exports.removeSubModelObject = exports.reindexSubModels = exports.reindexSubModel = exports.triggerPDFGenerator = exports.removeProductObject = exports.reindexProducts = void 0;
|
|
3
|
+
exports.removeSubFamilyObject = exports.reindexSubFamily = exports.reindexSubFamilies = exports.removeFamilyObject = exports.reindexFamily = exports.reindexFamilies = exports.cloneIndexSettings = exports.getIndex = exports.checkTopicDraftAndPagePublished = exports.migrateEntryFields = exports.publishAllProductDrafts = exports.purgeProductThumbCacheByProductCodes = exports.populateDestinations = exports.reimportAuditProducts = exports.getProductPageIdByCode = exports.removeAllProductModelProductRelations = exports.removeProductFromColorVariantsByProductLine = exports.setProductAutodescriptionByTopicId = exports.getProductAutodescription = exports.setProductsAutodescription = exports.generateTechSpecPdf = exports.audit = exports.getAllProductEntriesByCatalog = exports.setProductRelationships = exports.setProductsRelationships = exports.importProductByCode = exports.importFamilies = exports.importSubFamilies = exports.importSubModels = exports.importModels = exports.importLatestProducts = exports.importCategories = exports.importDictionaryProductSubLine = exports.importDictionaryProductLine = exports.importDictionaryData = exports.importDictionaryIcons = exports.importDictionaryFields = exports.savePDFToS3 = exports.getFileFromS3 = exports.saveJsonToS3 = exports.uploadS3 = exports.initS3 = exports.getEntries = exports.getTopicPage = exports.getEntryByID = exports.deleteEntries = exports.deletePages = exports.initBaseEntries = exports.initContentful = exports.initPim = void 0;
|
|
4
|
+
exports.netlifyBuild = exports.notify = exports.importDesigner = exports.importDesigners = exports.generatePDFByUrl = exports.removeRecordsByStatus = exports.getLogFolder = exports.setLogFilename = exports.setLogPath = exports.setLogId = exports.setServerUtils = exports.log = exports.getLatestProducts = exports.getStaticDailyProducts = exports.getLocalISOTime = exports.importDownloads = exports.removePostObject = exports.reindexPosts = exports.reindexPost = exports.removePressReleaseObject = exports.reindexPressReleases = exports.reindexPressRelease = exports.removePressReviewObject = exports.reindexPressReviews = exports.reindexPressReview = exports.removeStoryObject = exports.reindexStories = exports.reindexStory = exports.removeProjectObject = exports.reindexProjects = exports.reindexProject = exports.removeInspirationObject = exports.reindexInspirations = exports.reindexInspiration = exports.removeDownloadObject = exports.reindexDownloads = exports.reindexDownload = exports.removeModelObject = exports.reindexModels = exports.reindexModel = exports.removeSubModelObject = exports.reindexSubModels = exports.reindexSubModel = exports.triggerPDFGenerator = exports.removeProductObject = exports.reindexProducts = exports.reindexProduct = void 0;
|
|
5
5
|
var config_1 = require("./pim/config");
|
|
6
6
|
Object.defineProperty(exports, "initPim", { enumerable: true, get: function () { return config_1.init; } });
|
|
7
7
|
var contentful_1 = require("./libs/contentful");
|
|
@@ -60,6 +60,7 @@ var checkTopicDraftAndPagePublished_1 = require("./pim/methods/checkTopicDraftAn
|
|
|
60
60
|
Object.defineProperty(exports, "checkTopicDraftAndPagePublished", { enumerable: true, get: function () { return checkTopicDraftAndPagePublished_1.checkTopicDraftAndPagePublished; } });
|
|
61
61
|
var config_2 = require("./algolia/config");
|
|
62
62
|
Object.defineProperty(exports, "getIndex", { enumerable: true, get: function () { return config_2.getIndex; } });
|
|
63
|
+
Object.defineProperty(exports, "cloneIndexSettings", { enumerable: true, get: function () { return config_2.cloneIndexSettings; } });
|
|
63
64
|
var families_2 = require("./algolia/families");
|
|
64
65
|
Object.defineProperty(exports, "reindexFamilies", { enumerable: true, get: function () { return families_2.reindexFamilies; } });
|
|
65
66
|
Object.defineProperty(exports, "reindexFamily", { enumerable: true, get: function () { return families_2.reindexFamily; } });
|
package/dist/libs/contentful.js
CHANGED
|
@@ -55,7 +55,7 @@ const getCategorySlugs = async (categoryEntry) => {
|
|
|
55
55
|
const defaultEnvironmentLocaleCode = await (0, contentful_1.getEnvironmentDefaultLocaleCode)();
|
|
56
56
|
for (const locale of contentful_1.cfLocales) {
|
|
57
57
|
slugs[locale] = (0, utils_1.stringToSlug)(`${categoryEntry.fields.name[locale] ||
|
|
58
|
-
categoryEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
|
|
58
|
+
categoryEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
|
|
59
59
|
}
|
|
60
60
|
return slugs;
|
|
61
61
|
};
|
|
@@ -149,7 +149,7 @@ const importCatalogPage = async (catalogEntry) => {
|
|
|
149
149
|
const slugs = {};
|
|
150
150
|
for (const locale of contentful_1.cfLocales) {
|
|
151
151
|
slugs[locale] = (0, utils_1.stringToSlug)(`${catalogEntry.fields.name[locale] ||
|
|
152
|
-
catalogEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
|
|
152
|
+
catalogEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
|
|
153
153
|
}
|
|
154
154
|
(0, logs_1.log)(`create/update catalog page ${pageId}...`);
|
|
155
155
|
let catalogPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
|
|
@@ -33,7 +33,7 @@ const createOrUpdatePage = async (familyEntry) => {
|
|
|
33
33
|
}
|
|
34
34
|
for (const locale of contentful_1.cfLocales) {
|
|
35
35
|
slugs[locale] = (0, utils_1.stringToSlug)(`${familyEntry.fields.name[locale] ||
|
|
36
|
-
familyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
|
|
36
|
+
familyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
|
|
37
37
|
}
|
|
38
38
|
let familyPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
|
|
39
39
|
const pageData = await getFamilyPageData(names, slugs, pageId, familyEntry, familyPageEntry);
|
|
@@ -33,7 +33,7 @@ const createOrUpdatePage = async (modelEntry) => {
|
|
|
33
33
|
}
|
|
34
34
|
for (const locale of contentful_1.cfLocales) {
|
|
35
35
|
slugs[locale] = (0, utils_1.stringToSlug)(`${modelEntry.fields.name[locale] ||
|
|
36
|
-
modelEntry.fields.name[defaultEnvironmentLocaleCode]}-${modelEntry.fields.code[defaultEnvironmentLocaleCode]}`.toLowerCase());
|
|
36
|
+
modelEntry.fields.name[defaultEnvironmentLocaleCode]}-${modelEntry.fields.code[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
|
|
37
37
|
}
|
|
38
38
|
let modelPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
|
|
39
39
|
const pageData = await getModelPageData(names, slugs, pageId, modelEntry, modelPageEntry);
|
|
@@ -228,7 +228,9 @@ const createOrUpdateProductPage = async (productEntry, unpublish) => {
|
|
|
228
228
|
const slugs = {};
|
|
229
229
|
const code = productEntry.fields.code["en"];
|
|
230
230
|
for (const name of Object.entries(productEntry.fields.name)) {
|
|
231
|
-
|
|
231
|
+
const locale = name[0];
|
|
232
|
+
const title = `${name[1]}-${code}`;
|
|
233
|
+
slugs[locale] = (0, utils_1.stringToSlug)(title, true, locale).toLowerCase();
|
|
232
234
|
}
|
|
233
235
|
let productPageEntry = await (0, contentful_1.getEntryByID)(pageId, "page");
|
|
234
236
|
const pageData = await getProductPageData(names, slugs, pageId, productEntry, productPageEntry);
|
|
@@ -67,7 +67,7 @@ const getSubFamilyPageSlugs = async (catalogPage, categoryPage, subFamilyEntry)
|
|
|
67
67
|
categoryPage.fields.slug[defaultEnvironmentLocaleCode]) + "-";
|
|
68
68
|
}
|
|
69
69
|
slugs[locale] = (0, utils_1.stringToSlug)(`${slugPrefix}${subFamilyEntry.fields.name[locale] ||
|
|
70
|
-
subFamilyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase());
|
|
70
|
+
subFamilyEntry.fields.name[defaultEnvironmentLocaleCode]}`.toLowerCase(), false, locale);
|
|
71
71
|
}
|
|
72
72
|
return slugs;
|
|
73
73
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export type AvailableEntryStatus = "Published" | "Changed" | "Draft" | "Archived
|
|
|
3
3
|
export type NonEmptyArray<T> = [T, ...T[]];
|
|
4
4
|
export type ObjectPartial = Partial<Record<string, any>>;
|
|
5
5
|
export type { Config as ContentfulConfig } from "./libs/contentful";
|
|
6
|
-
export type PimLocale = "en" | "en_us" | "it" | "es" | "de" | "fr" | "sv" | "no" | "da" | "ru";
|
|
7
|
-
export type ContentfulLocale = "en" | "en-US" | "it" | "es" | "de" | "fr";
|
|
6
|
+
export type PimLocale = "en" | "en_us" | "it" | "es" | "de" | "fr" | "sv" | "no" | "da" | "zh" | "ru";
|
|
7
|
+
export type ContentfulLocale = "en" | "en-US" | "it" | "es" | "de" | "fr" | "zh";
|
|
8
8
|
export type PimValues = {
|
|
9
9
|
value_en: string;
|
|
10
10
|
value_en_US?: string | null;
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const sleep: (ms: number, showLog?: boolean) => Promise<unknown>;
|
|
|
5
5
|
export declare const getBaseURL: (url: string) => string;
|
|
6
6
|
export declare const basename: (path: string) => string;
|
|
7
7
|
export declare const secondBetweenTwoDate: (newDate: Date, oldDate: Date) => number;
|
|
8
|
-
export declare const stringToSlug: (str: string, skipReplaceDots?: boolean) => string;
|
|
8
|
+
export declare const stringToSlug: (str: string, skipReplaceDots?: boolean, locale?: string) => string;
|
|
9
9
|
export declare const pimLocaleMap: Partial<Record<PimLocale, ContentfulLocale>>;
|
|
10
10
|
export declare const getLocale: (pimLocaleCode: PimLocale) => ContentfulLocale | null;
|
|
11
11
|
export declare const getPimTranslations: (values: Partial<PimValues | PimProductDescription | PimProductExcerpt | AssetsEntity>, fieldKey?: "value" | "description" | "description1" | "description2" | "note" | "title" | "webNaming", defaultValue?: string, limit?: number) => CfLocalizedEntryField;
|
package/dist/utils.js
CHANGED
|
@@ -22,7 +22,7 @@ const basename = (path) => {
|
|
|
22
22
|
exports.basename = basename;
|
|
23
23
|
const secondBetweenTwoDate = (newDate, oldDate) => Math.abs((newDate.getTime() - oldDate.getTime()) / 1000);
|
|
24
24
|
exports.secondBetweenTwoDate = secondBetweenTwoDate;
|
|
25
|
-
const stringToSlug = (str, skipReplaceDots = false) => {
|
|
25
|
+
const stringToSlug = (str, skipReplaceDots = false, locale = "en") => {
|
|
26
26
|
str = str.replace(/^\s+|\s+$/g, "");
|
|
27
27
|
str = str.toLowerCase();
|
|
28
28
|
const from = "àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;";
|
|
@@ -30,15 +30,18 @@ const stringToSlug = (str, skipReplaceDots = false) => {
|
|
|
30
30
|
for (let i = 0, l = from.length; i < l; i++) {
|
|
31
31
|
str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
|
|
32
32
|
}
|
|
33
|
+
if (!locale.startsWith("zh")) {
|
|
34
|
+
str = str.replace(/[^a-z0-9. -]/g, "");
|
|
35
|
+
}
|
|
33
36
|
str = str
|
|
34
|
-
.replace(/[^a-z0-9. -]/g, "")
|
|
35
37
|
.replace(/\s+/g, "-")
|
|
36
38
|
.replace(/-+/g, "-")
|
|
37
39
|
.replace(/\//g, "");
|
|
38
40
|
if (!skipReplaceDots) {
|
|
39
|
-
str = str
|
|
40
|
-
|
|
41
|
-
.replace(/[^a-z0-9 -]/g, "");
|
|
41
|
+
str = str.replace(".", "-");
|
|
42
|
+
if (!locale.startsWith("zh")) {
|
|
43
|
+
str = str.replace(/[^a-z0-9. -]/g, "");
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
return str;
|
|
44
47
|
};
|
|
@@ -50,6 +53,7 @@ exports.pimLocaleMap = {
|
|
|
50
53
|
es: "es",
|
|
51
54
|
de: "de",
|
|
52
55
|
fr: "fr",
|
|
56
|
+
zh: "zh",
|
|
53
57
|
};
|
|
54
58
|
const getLocale = (pimLocaleCode) => {
|
|
55
59
|
return exports.pimLocaleMap[pimLocaleCode] || null;
|