pim-import 5.0.1 → 5.0.3
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/clean.js +0 -1
- package/dist/algolia/config.js +0 -1
- package/dist/algolia/downloads.js +0 -1
- package/dist/algolia/families.js +0 -1
- package/dist/algolia/inspirations.js +0 -1
- package/dist/algolia/models.js +0 -1
- package/dist/algolia/news.js +0 -1
- package/dist/algolia/pressRelease.js +0 -1
- package/dist/algolia/pressReview.js +0 -1
- package/dist/algolia/products.js +0 -1
- package/dist/algolia/projects.js +0 -1
- package/dist/algolia/stories.js +0 -1
- package/dist/algolia/subFamilies.js +0 -1
- package/dist/algolia/subModels.js +0 -1
- package/dist/browser.js +0 -1
- package/dist/downloads/classes/manageEntry.js +0 -1
- package/dist/downloads/import.js +0 -1
- package/dist/index.js +0 -1
- package/dist/libs/contentful-cda.js +0 -1
- package/dist/libs/contentful.js +0 -1
- package/dist/libs/imgix.js +0 -1
- package/dist/libs/logs.js +0 -1
- package/dist/libs/netlify.js +0 -1
- package/dist/libs/notifications.js +0 -1
- package/dist/libs/pdf.js +0 -1
- package/dist/libs/s3.js +0 -1
- package/dist/libs/sentry.js +0 -1
- package/dist/pim/config.js +0 -1
- package/dist/pim/endpoints.js +0 -1
- package/dist/pim/methods/bulkPublish.js +0 -1
- package/dist/pim/methods/catalogs.js +0 -1
- package/dist/pim/methods/checkTopicDraftAndPagePublished.js +0 -1
- package/dist/pim/methods/designers.js +0 -1
- package/dist/pim/methods/dictionary.js +0 -1
- package/dist/pim/methods/families.js +0 -1
- package/dist/pim/methods/latestProducts.js +0 -1
- package/dist/pim/methods/migrateEntryFields.js +0 -1
- package/dist/pim/methods/models.js +0 -1
- package/dist/pim/methods/pages/catalogs.js +0 -1
- package/dist/pim/methods/pages/families.js +0 -1
- package/dist/pim/methods/pages/subfamilies.js +0 -1
- package/dist/pim/methods/products.js +0 -1
- package/dist/pim/methods/subfamilies.js +0 -1
- package/dist/pim/methods/submodels.js +0 -1
- package/dist/pim/request.js +0 -1
- package/dist/resources/AllProducts.js +0 -1
- package/dist/resources/Audit.js +0 -1
- package/dist/resources/CatalogDetails.js +0 -1
- package/dist/resources/CollectionModels.js +0 -1
- package/dist/resources/CollectionSubFamilies.js +0 -1
- package/dist/resources/CollectionSubModels.js +0 -1
- package/dist/resources/DProductSubLine.js +0 -1
- package/dist/resources/FamilyDetails.js +0 -1
- package/dist/resources/ProductDetails.js +0 -1
- package/dist/resources/ProductRelation.js +0 -1
- package/dist/resources/cfFields.js +0 -1
- package/dist/types.js +0 -1
- package/dist/utils.js +0 -1
- package/package.json +7 -2
- package/.env.example +0 -45
- package/.nvmrc +0 -1
- package/.vscode/settings.json +0 -21
- package/dist/algolia/clean.js.map +0 -1
- package/dist/algolia/config.js.map +0 -1
- package/dist/algolia/downloads.js.map +0 -1
- package/dist/algolia/families.js.map +0 -1
- package/dist/algolia/inspirations.js.map +0 -1
- package/dist/algolia/models.js.map +0 -1
- package/dist/algolia/news.js.map +0 -1
- package/dist/algolia/pressRelease.js.map +0 -1
- package/dist/algolia/pressReview.js.map +0 -1
- package/dist/algolia/products.js.map +0 -1
- package/dist/algolia/projects.js.map +0 -1
- package/dist/algolia/stories.js.map +0 -1
- package/dist/algolia/subFamilies.js.map +0 -1
- package/dist/algolia/subModels.js.map +0 -1
- package/dist/browser.js.map +0 -1
- package/dist/downloads/classes/manageEntry.js.map +0 -1
- package/dist/downloads/import.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/libs/contentful-cda.js.map +0 -1
- package/dist/libs/contentful.js.map +0 -1
- package/dist/libs/imgix.js.map +0 -1
- package/dist/libs/logs.js.map +0 -1
- package/dist/libs/netlify.js.map +0 -1
- package/dist/libs/notifications.js.map +0 -1
- package/dist/libs/pdf.js.map +0 -1
- package/dist/libs/s3.js.map +0 -1
- package/dist/libs/sentry.js.map +0 -1
- package/dist/pim/config.js.map +0 -1
- package/dist/pim/endpoints.js.map +0 -1
- package/dist/pim/methods/bulkPublish.js.map +0 -1
- package/dist/pim/methods/catalogs.js.map +0 -1
- package/dist/pim/methods/checkTopicDraftAndPagePublished.js.map +0 -1
- package/dist/pim/methods/designers.js.map +0 -1
- package/dist/pim/methods/dictionary.js.map +0 -1
- package/dist/pim/methods/families.js.map +0 -1
- package/dist/pim/methods/latestProducts.js.map +0 -1
- package/dist/pim/methods/migrateEntryFields.js.map +0 -1
- package/dist/pim/methods/models.js.map +0 -1
- package/dist/pim/methods/pages/catalogs.js.map +0 -1
- package/dist/pim/methods/pages/families.js.map +0 -1
- package/dist/pim/methods/pages/subfamilies.js.map +0 -1
- package/dist/pim/methods/products.js.map +0 -1
- package/dist/pim/methods/subfamilies.js.map +0 -1
- package/dist/pim/methods/submodels.js.map +0 -1
- package/dist/pim/request.js.map +0 -1
- package/dist/resources/AllProducts.js.map +0 -1
- package/dist/resources/Audit.js.map +0 -1
- package/dist/resources/CatalogDetails.js.map +0 -1
- package/dist/resources/CollectionModels.js.map +0 -1
- package/dist/resources/CollectionSubFamilies.js.map +0 -1
- package/dist/resources/CollectionSubModels.js.map +0 -1
- package/dist/resources/DProductSubLine.js.map +0 -1
- package/dist/resources/FamilyDetails.js.map +0 -1
- package/dist/resources/ProductDetails.js.map +0 -1
- package/dist/resources/ProductRelation.js.map +0 -1
- package/dist/resources/cfFields.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/docs/import-data-from-the-dictionary.md +0 -83
- package/docs/import-products.md +0 -61
- package/docs/import-taxonomies-from-the-catalog.md +0 -60
- package/docs/settings.md +0 -47
- package/jest.config.js +0 -16
- package/local-fn/reindex.js +0 -182
- package/src/algolia/clean.ts +0 -164
- package/src/algolia/config.ts +0 -390
- package/src/algolia/downloads.ts +0 -346
- package/src/algolia/families.ts +0 -652
- package/src/algolia/inspirations.ts +0 -315
- package/src/algolia/models.ts +0 -589
- package/src/algolia/news.ts +0 -258
- package/src/algolia/pressRelease.ts +0 -255
- package/src/algolia/pressReview.ts +0 -247
- package/src/algolia/products.ts +0 -731
- package/src/algolia/projects.ts +0 -339
- package/src/algolia/stories.ts +0 -347
- package/src/algolia/subFamilies.ts +0 -709
- package/src/algolia/subModels.ts +0 -359
- package/src/browser.ts +0 -122
- package/src/downloads/classes/manageEntry.ts +0 -99
- package/src/downloads/csv/legal.csv +0 -5
- package/src/downloads/csv/products.csv +0 -373
- package/src/downloads/import.ts +0 -381
- package/src/index.ts +0 -140
- package/src/libs/contentful-cda.ts +0 -543
- package/src/libs/contentful.ts +0 -1453
- package/src/libs/imgix.ts +0 -297
- package/src/libs/logs.ts +0 -121
- package/src/libs/netlify.ts +0 -37
- package/src/libs/notifications.ts +0 -104
- package/src/libs/pdf.ts +0 -107
- package/src/libs/s3.ts +0 -305
- package/src/libs/sentry.ts +0 -33
- package/src/pim/config.ts +0 -84
- package/src/pim/data/productFields.json +0 -1178
- package/src/pim/endpoints.ts +0 -364
- package/src/pim/methods/bulkPublish.ts +0 -266
- package/src/pim/methods/catalogs.ts +0 -586
- package/src/pim/methods/checkTopicDraftAndPagePublished.ts +0 -70
- package/src/pim/methods/designers.ts +0 -128
- package/src/pim/methods/dictionary.ts +0 -611
- package/src/pim/methods/families.ts +0 -345
- package/src/pim/methods/latestProducts.ts +0 -70
- package/src/pim/methods/migrateEntryFields.ts +0 -99
- package/src/pim/methods/models.ts +0 -349
- package/src/pim/methods/pages/catalogs.ts +0 -28
- package/src/pim/methods/pages/families.ts +0 -50
- package/src/pim/methods/pages/subfamilies.ts +0 -98
- package/src/pim/methods/products.ts +0 -3297
- package/src/pim/methods/subfamilies.ts +0 -706
- package/src/pim/methods/submodels.ts +0 -262
- package/src/pim/request.ts +0 -61
- package/src/resources/AllProducts.ts +0 -41
- package/src/resources/Audit.ts +0 -24
- package/src/resources/CatalogDetails.ts +0 -51
- package/src/resources/CollectionModels.ts +0 -42
- package/src/resources/CollectionSubFamilies.ts +0 -45
- package/src/resources/CollectionSubModels.ts +0 -36
- package/src/resources/DProductSubLine.ts +0 -34
- package/src/resources/FamilyDetails.ts +0 -31
- package/src/resources/ProductDetails.ts +0 -352
- package/src/resources/ProductRelation.ts +0 -24
- package/src/resources/cfFields.ts +0 -8
- package/src/types.ts +0 -268
- package/src/utils.ts +0 -553
- package/tsconfig.json +0 -93
- package/tslint.json +0 -22
- package/types/libs/puppeteer.d.ts +0 -17
- package/types/pim/methods/checkIp.d.ts +0 -1
- /package/{types → dist}/algolia/clean.d.ts +0 -0
- /package/{types → dist}/algolia/config.d.ts +0 -0
- /package/{types → dist}/algolia/downloads.d.ts +0 -0
- /package/{types → dist}/algolia/families.d.ts +0 -0
- /package/{types → dist}/algolia/inspirations.d.ts +0 -0
- /package/{types → dist}/algolia/models.d.ts +0 -0
- /package/{types → dist}/algolia/news.d.ts +0 -0
- /package/{types → dist}/algolia/pressRelease.d.ts +0 -0
- /package/{types → dist}/algolia/pressReview.d.ts +0 -0
- /package/{types → dist}/algolia/products.d.ts +0 -0
- /package/{types → dist}/algolia/projects.d.ts +0 -0
- /package/{types → dist}/algolia/stories.d.ts +0 -0
- /package/{types → dist}/algolia/subFamilies.d.ts +0 -0
- /package/{types → dist}/algolia/subModels.d.ts +0 -0
- /package/{types → dist}/browser.d.ts +0 -0
- /package/{types → dist}/downloads/classes/manageEntry.d.ts +0 -0
- /package/{types → dist}/downloads/import.d.ts +0 -0
- /package/{types → dist}/index.d.ts +0 -0
- /package/{types → dist}/libs/contentful-cda.d.ts +0 -0
- /package/{types → dist}/libs/contentful.d.ts +0 -0
- /package/{types → dist}/libs/imgix.d.ts +0 -0
- /package/{types → dist}/libs/logs.d.ts +0 -0
- /package/{types → dist}/libs/netlify.d.ts +0 -0
- /package/{types → dist}/libs/notifications.d.ts +0 -0
- /package/{types → dist}/libs/pdf.d.ts +0 -0
- /package/{types → dist}/libs/s3.d.ts +0 -0
- /package/{types → dist}/libs/sentry.d.ts +0 -0
- /package/{types → dist}/pim/config.d.ts +0 -0
- /package/{types → dist}/pim/endpoints.d.ts +0 -0
- /package/{types → dist}/pim/methods/bulkPublish.d.ts +0 -0
- /package/{types → dist}/pim/methods/catalogs.d.ts +0 -0
- /package/{types → dist}/pim/methods/checkTopicDraftAndPagePublished.d.ts +0 -0
- /package/{types → dist}/pim/methods/designers.d.ts +0 -0
- /package/{types → dist}/pim/methods/dictionary.d.ts +0 -0
- /package/{types → dist}/pim/methods/families.d.ts +0 -0
- /package/{types → dist}/pim/methods/latestProducts.d.ts +0 -0
- /package/{types → dist}/pim/methods/migrateEntryFields.d.ts +0 -0
- /package/{types → dist}/pim/methods/models.d.ts +0 -0
- /package/{types → dist}/pim/methods/pages/catalogs.d.ts +0 -0
- /package/{types → dist}/pim/methods/pages/families.d.ts +0 -0
- /package/{types → dist}/pim/methods/pages/subfamilies.d.ts +0 -0
- /package/{types → dist}/pim/methods/products.d.ts +0 -0
- /package/{types → dist}/pim/methods/subfamilies.d.ts +0 -0
- /package/{types → dist}/pim/methods/submodels.d.ts +0 -0
- /package/{types → dist}/pim/request.d.ts +0 -0
- /package/{types → dist}/resources/AllProducts.d.ts +0 -0
- /package/{types → dist}/resources/Audit.d.ts +0 -0
- /package/{types → dist}/resources/CatalogDetails.d.ts +0 -0
- /package/{types → dist}/resources/CollectionModels.d.ts +0 -0
- /package/{types → dist}/resources/CollectionSubFamilies.d.ts +0 -0
- /package/{types → dist}/resources/CollectionSubModels.d.ts +0 -0
- /package/{types → dist}/resources/DProductSubLine.d.ts +0 -0
- /package/{types → dist}/resources/FamilyDetails.d.ts +0 -0
- /package/{types → dist}/resources/ProductDetails.d.ts +0 -0
- /package/{types → dist}/resources/ProductRelation.d.ts +0 -0
- /package/{types → dist}/resources/cfFields.d.ts +0 -0
- /package/{types → dist}/types.d.ts +0 -0
- /package/{types → dist}/utils.d.ts +0 -0
|
@@ -1,706 +0,0 @@
|
|
|
1
|
-
import { getOtherCatalogData } from "../endpoints";
|
|
2
|
-
import {
|
|
3
|
-
updateEntry,
|
|
4
|
-
createEntryWithId,
|
|
5
|
-
getEnvironmentDefaultLocaleCode,
|
|
6
|
-
getEntryByID,
|
|
7
|
-
getEntryByCode,
|
|
8
|
-
getAllEntries,
|
|
9
|
-
cfLocales,
|
|
10
|
-
addToRelationFields,
|
|
11
|
-
addFieldValue,
|
|
12
|
-
} from "../../libs/contentful";
|
|
13
|
-
import { log, serverUtils } from "../../libs/logs";
|
|
14
|
-
import type {
|
|
15
|
-
Entry,
|
|
16
|
-
CreateEntryProps,
|
|
17
|
-
} from "contentful-management/dist/typings/entities/entry";
|
|
18
|
-
import {
|
|
19
|
-
CollectionSubFamilies,
|
|
20
|
-
PagedCollectionEntity,
|
|
21
|
-
} from "../../resources/CollectionSubFamilies";
|
|
22
|
-
import {
|
|
23
|
-
sleep,
|
|
24
|
-
getPimTranslations,
|
|
25
|
-
stringToSlug,
|
|
26
|
-
sanitizeValue,
|
|
27
|
-
getLocalISOTime,
|
|
28
|
-
capitalizeFirstLetter,
|
|
29
|
-
keysToLowerCase,
|
|
30
|
-
} from "../../utils";
|
|
31
|
-
import {
|
|
32
|
-
PaginationResults,
|
|
33
|
-
CfLocalizedEntryField,
|
|
34
|
-
AvailableCatalogs,
|
|
35
|
-
CfSys,
|
|
36
|
-
} from "../../types";
|
|
37
|
-
import { updateSubFamiliesRelToEntry, getCategoryTopicCode } from "./catalogs";
|
|
38
|
-
import { pageResponse } from "../../algolia/families";
|
|
39
|
-
import { addDesignerData } from "./designers";
|
|
40
|
-
import { setHideInRegionField } from "./products";
|
|
41
|
-
|
|
42
|
-
const getComponentModelPagesData = async (
|
|
43
|
-
componentID: string,
|
|
44
|
-
topicSubFamily: Entry,
|
|
45
|
-
componentModule: Entry | null
|
|
46
|
-
) => {
|
|
47
|
-
const componentData: CreateEntryProps = {
|
|
48
|
-
fields: componentModule?.fields || {},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
componentData.fields = await addFieldValue(
|
|
52
|
-
componentData,
|
|
53
|
-
"internalName",
|
|
54
|
-
componentID
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// modelPages relations
|
|
58
|
-
const topicModels = await getAllEntries(
|
|
59
|
-
"topicModel",
|
|
60
|
-
"sys",
|
|
61
|
-
"fields.subFamily.sys.id",
|
|
62
|
-
topicSubFamily.sys.id
|
|
63
|
-
);
|
|
64
|
-
for (const topicModel of topicModels) {
|
|
65
|
-
componentData.fields = await addToRelationFields(
|
|
66
|
-
componentData,
|
|
67
|
-
"modelPages",
|
|
68
|
-
`${topicModel.sys.id}_PAGE`,
|
|
69
|
-
true
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return componentData;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const addComponentModelPages = async (
|
|
77
|
-
topicSubFamily: Entry
|
|
78
|
-
): Promise<Entry> => {
|
|
79
|
-
const componentID = `CC_${topicSubFamily.sys.id}`;
|
|
80
|
-
const componentContentType = "componentModelPages";
|
|
81
|
-
let componentModule = await getEntryByID(componentID, componentContentType);
|
|
82
|
-
|
|
83
|
-
const componentData = await getComponentModelPagesData(
|
|
84
|
-
componentID,
|
|
85
|
-
topicSubFamily,
|
|
86
|
-
componentModule
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
if (componentModule) {
|
|
90
|
-
log(
|
|
91
|
-
`Update ${componentContentType} for the ${topicSubFamily.sys.id} subfamily page`
|
|
92
|
-
);
|
|
93
|
-
componentModule = await updateEntry(
|
|
94
|
-
componentModule,
|
|
95
|
-
componentData,
|
|
96
|
-
componentModule.isPublished()
|
|
97
|
-
);
|
|
98
|
-
} else {
|
|
99
|
-
log(
|
|
100
|
-
`Add ${componentContentType} for the ${topicSubFamily.sys.id} subfamily page`
|
|
101
|
-
);
|
|
102
|
-
componentModule = await createEntryWithId(
|
|
103
|
-
componentContentType,
|
|
104
|
-
componentID,
|
|
105
|
-
componentData
|
|
106
|
-
);
|
|
107
|
-
componentModule = await componentModule.publish();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return componentModule;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const getSubFamilyPageData = async (
|
|
114
|
-
names: CfLocalizedEntryField,
|
|
115
|
-
slugs: CfLocalizedEntryField,
|
|
116
|
-
pageId: string,
|
|
117
|
-
subFamilyEntry: Entry,
|
|
118
|
-
subFamilyPageEntry: Entry
|
|
119
|
-
): Promise<CreateEntryProps> => {
|
|
120
|
-
const defEnvLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
121
|
-
const pageData: CreateEntryProps = {
|
|
122
|
-
fields: subFamilyPageEntry?.fields || {},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
pageData.fields.title = names;
|
|
126
|
-
pageData.fields.slug = slugs;
|
|
127
|
-
|
|
128
|
-
pageData.fields = await addFieldValue(pageData, "internalName", pageId);
|
|
129
|
-
pageData.fields = await addFieldValue(pageData, "type", "CatalogSubFamily");
|
|
130
|
-
|
|
131
|
-
// Topic
|
|
132
|
-
pageData.fields = await addToRelationFields(
|
|
133
|
-
pageData,
|
|
134
|
-
"topic",
|
|
135
|
-
subFamilyEntry.sys.id
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
// Contents - Component Model Pages
|
|
139
|
-
const componentModelPages = await addComponentModelPages(subFamilyEntry);
|
|
140
|
-
pageData.fields = await addToRelationFields(
|
|
141
|
-
pageData,
|
|
142
|
-
"contents",
|
|
143
|
-
componentModelPages.sys.id,
|
|
144
|
-
true
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
const destinations =
|
|
148
|
-
subFamilyEntry?.fields?.destinations?.[defEnvLocaleCode] || [];
|
|
149
|
-
pageData.fields = await setHideInRegionField(destinations, pageData);
|
|
150
|
-
|
|
151
|
-
return pageData;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export const getSubFamilyPageSlugs = async (
|
|
155
|
-
catalogPage: Entry,
|
|
156
|
-
categoryPage: Entry,
|
|
157
|
-
subFamilyEntry: Entry
|
|
158
|
-
): Promise<CfLocalizedEntryField> => {
|
|
159
|
-
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
160
|
-
const slugs: CfLocalizedEntryField = {};
|
|
161
|
-
for (const locale of cfLocales) {
|
|
162
|
-
let slugPrefix = "";
|
|
163
|
-
if (catalogPage?.fields?.slug) {
|
|
164
|
-
slugPrefix +=
|
|
165
|
-
(catalogPage.fields.slug[locale] ||
|
|
166
|
-
catalogPage.fields.slug[defaultEnvironmentLocaleCode]) + "-";
|
|
167
|
-
}
|
|
168
|
-
if (categoryPage?.fields?.slug) {
|
|
169
|
-
slugPrefix +=
|
|
170
|
-
(categoryPage.fields.slug[locale] ||
|
|
171
|
-
categoryPage.fields.slug[defaultEnvironmentLocaleCode]) + "-";
|
|
172
|
-
}
|
|
173
|
-
slugs[locale] = stringToSlug(
|
|
174
|
-
`${slugPrefix}${
|
|
175
|
-
subFamilyEntry.fields.name[locale] ||
|
|
176
|
-
subFamilyEntry.fields.name[defaultEnvironmentLocaleCode]
|
|
177
|
-
}`.toLowerCase()
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return slugs;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Create or update subFamily page
|
|
186
|
-
*
|
|
187
|
-
* create/update page content
|
|
188
|
-
* - internalName
|
|
189
|
-
* - contentModules:
|
|
190
|
-
* -- topicSubFamily
|
|
191
|
-
* - regions
|
|
192
|
-
* - sites
|
|
193
|
-
*
|
|
194
|
-
* create/update page
|
|
195
|
-
* - internalName
|
|
196
|
-
* - type: 'CatalogSubFamily'
|
|
197
|
-
* - content:
|
|
198
|
-
* -- pageContent
|
|
199
|
-
*
|
|
200
|
-
* @param subFamilyEntry
|
|
201
|
-
* @returns
|
|
202
|
-
*/
|
|
203
|
-
export const createOrUpdatePage = async (
|
|
204
|
-
subFamilyEntry: Entry
|
|
205
|
-
): Promise<Entry> => {
|
|
206
|
-
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
207
|
-
const pageId = `${subFamilyEntry.sys.id}_PAGE`;
|
|
208
|
-
const names: CfLocalizedEntryField = {};
|
|
209
|
-
|
|
210
|
-
for (const locale of cfLocales) {
|
|
211
|
-
names[locale] =
|
|
212
|
-
subFamilyEntry.fields.name[locale] ||
|
|
213
|
-
subFamilyEntry.fields.name[defaultEnvironmentLocaleCode];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Catalog page
|
|
217
|
-
let catalogPage: Entry = {} as Entry;
|
|
218
|
-
const catalogEntryId =
|
|
219
|
-
subFamilyEntry?.fields?.catalog?.[defaultEnvironmentLocaleCode]?.sys?.id;
|
|
220
|
-
if (catalogEntryId) {
|
|
221
|
-
log(
|
|
222
|
-
`Add ${catalogEntryId} catalog page slug to ${subFamilyEntry.sys.id} subfamily page slug`
|
|
223
|
-
);
|
|
224
|
-
catalogPage = await getEntryByID(`${catalogEntryId}_PAGE`, "page");
|
|
225
|
-
if (!catalogPage) {
|
|
226
|
-
log(`No catalog page found with page id: ${catalogEntryId}_PAGE`, "WARN");
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
log(`No catalog found with id: ${catalogEntryId}`, "WARN");
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Category page
|
|
233
|
-
let categoryPage: Entry = {} as Entry;
|
|
234
|
-
const categoryEntryId =
|
|
235
|
-
subFamilyEntry?.fields?.category?.[defaultEnvironmentLocaleCode]?.sys?.id;
|
|
236
|
-
if (categoryEntryId) {
|
|
237
|
-
log(
|
|
238
|
-
`Add ${categoryEntryId} category page slug to ${subFamilyEntry.sys.id} subfamily page slug`
|
|
239
|
-
);
|
|
240
|
-
categoryPage = await getEntryByID(`${categoryEntryId}_PAGE`, "page");
|
|
241
|
-
if (!categoryPage) {
|
|
242
|
-
log(
|
|
243
|
-
`No category page found with page id: ${categoryEntryId}_PAGE`,
|
|
244
|
-
"WARN"
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
log(`No category found with id: ${categoryEntryId}`, "WARN");
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const slugs = await getSubFamilyPageSlugs(
|
|
252
|
-
catalogPage,
|
|
253
|
-
categoryPage,
|
|
254
|
-
subFamilyEntry
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
// PAGE
|
|
258
|
-
let subFamilyPageEntry: Entry = await getEntryByID(pageId, "page");
|
|
259
|
-
const pageData: CreateEntryProps = await getSubFamilyPageData(
|
|
260
|
-
names,
|
|
261
|
-
slugs,
|
|
262
|
-
pageId,
|
|
263
|
-
subFamilyEntry,
|
|
264
|
-
subFamilyPageEntry
|
|
265
|
-
);
|
|
266
|
-
if (subFamilyPageEntry) {
|
|
267
|
-
log(`subFamily page ${pageId} already exists. Updating...`);
|
|
268
|
-
subFamilyPageEntry = await updateEntry(
|
|
269
|
-
subFamilyPageEntry,
|
|
270
|
-
pageData,
|
|
271
|
-
subFamilyPageEntry.isPublished()
|
|
272
|
-
);
|
|
273
|
-
} else {
|
|
274
|
-
log(`subFamily page ${pageId} not exists. Create new entry with data`);
|
|
275
|
-
subFamilyPageEntry = await createEntryWithId("page", pageId, pageData);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return subFamilyPageEntry;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
const getTopicSubFamilyData = async (
|
|
282
|
-
subFamily: PagedCollectionEntity,
|
|
283
|
-
catalog: AvailableCatalogs,
|
|
284
|
-
topicSubFamily: Entry
|
|
285
|
-
) => {
|
|
286
|
-
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
287
|
-
const data: CreateEntryProps = {
|
|
288
|
-
fields: topicSubFamily?.fields || {},
|
|
289
|
-
};
|
|
290
|
-
data.fields.name = getPimTranslations(subFamily.data);
|
|
291
|
-
data.fields = await addFieldValue(data, "code", subFamily.data.code);
|
|
292
|
-
data.fields = await addFieldValue(data, "priority", subFamily.priority);
|
|
293
|
-
data.fields.description = getPimTranslations(subFamily, "description1");
|
|
294
|
-
|
|
295
|
-
// Catalog
|
|
296
|
-
const catalogEntry = await getEntryByCode(
|
|
297
|
-
subFamily.catalogCode,
|
|
298
|
-
"topicCatalog",
|
|
299
|
-
"sys,fields.code"
|
|
300
|
-
);
|
|
301
|
-
// Catalogs
|
|
302
|
-
log(`set ${catalogEntry.sys.id} catalog relation with current subfamily`);
|
|
303
|
-
data.fields = await addToRelationFields(
|
|
304
|
-
data,
|
|
305
|
-
"catalog",
|
|
306
|
-
catalogEntry?.sys?.id
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
if (!catalogEntry) {
|
|
310
|
-
log(`catalog with code ${subFamily.catalogCode} not found`, "WARN");
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Category
|
|
314
|
-
const categoryTopicCode = getCategoryTopicCode(
|
|
315
|
-
subFamily.categoryCode,
|
|
316
|
-
catalog
|
|
317
|
-
);
|
|
318
|
-
const categoryEntry = await getEntryByCode(
|
|
319
|
-
categoryTopicCode,
|
|
320
|
-
"topicCategory",
|
|
321
|
-
"sys,fields.code"
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
log(`set ${categoryEntry.sys.id} category relation with current subfamily`);
|
|
325
|
-
data.fields = await addToRelationFields(
|
|
326
|
-
data,
|
|
327
|
-
"category",
|
|
328
|
-
categoryEntry.sys.id
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
if (!categoryEntry) {
|
|
332
|
-
log(`category with code ${categoryTopicCode} not found`, "WARN");
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Parent Families
|
|
336
|
-
if (subFamily?.parentFamily?.data?.code) {
|
|
337
|
-
let familyEntry = await getEntryByCode(
|
|
338
|
-
subFamily.parentFamily.data.code,
|
|
339
|
-
"topicFamily",
|
|
340
|
-
"sys,fields"
|
|
341
|
-
);
|
|
342
|
-
if (familyEntry) {
|
|
343
|
-
log(
|
|
344
|
-
`set ${familyEntry.sys.id} parentFamily relation with current subfamily`
|
|
345
|
-
);
|
|
346
|
-
data.fields = await addToRelationFields(
|
|
347
|
-
data,
|
|
348
|
-
"parentFamily",
|
|
349
|
-
familyEntry.sys.id,
|
|
350
|
-
false
|
|
351
|
-
);
|
|
352
|
-
|
|
353
|
-
// Family catalogs
|
|
354
|
-
log(
|
|
355
|
-
`set ${catalogEntry.sys.id} catalog relation with family ${familyEntry.sys.id}`
|
|
356
|
-
);
|
|
357
|
-
familyEntry.fields = await addToRelationFields(
|
|
358
|
-
familyEntry,
|
|
359
|
-
"catalogs",
|
|
360
|
-
catalogEntry.sys.id,
|
|
361
|
-
true
|
|
362
|
-
);
|
|
363
|
-
// Family categories
|
|
364
|
-
log(
|
|
365
|
-
`set ${categoryEntry.sys.id} category relation with family ${familyEntry.sys.id}`
|
|
366
|
-
);
|
|
367
|
-
familyEntry.fields = await addToRelationFields(
|
|
368
|
-
familyEntry,
|
|
369
|
-
"categories",
|
|
370
|
-
categoryEntry.sys.id,
|
|
371
|
-
true
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
familyEntry = await familyEntry.update();
|
|
375
|
-
} else {
|
|
376
|
-
log(
|
|
377
|
-
`topicFamily with code ${subFamily.parentFamily.data.code} not found`,
|
|
378
|
-
"WARN"
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
} else {
|
|
382
|
-
log(
|
|
383
|
-
`parentFamily of ${subFamily.data.code} subFamily not found on PIM`,
|
|
384
|
-
"WARN"
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// Designer
|
|
389
|
-
if (subFamily?.designers) {
|
|
390
|
-
const designer = subFamily.designers[0];
|
|
391
|
-
if (designer?.code) {
|
|
392
|
-
log(`set ${designer.code} designer relation`);
|
|
393
|
-
data.fields = await addDesignerData(data, designer);
|
|
394
|
-
} else {
|
|
395
|
-
log(`no designer found`, "WARN");
|
|
396
|
-
if (data.fields.designer?.[defaultEnvironmentLocaleCode]) {
|
|
397
|
-
log(
|
|
398
|
-
`remove old designer relation with ${data.fields.designer?.[defaultEnvironmentLocaleCode].sys.id}`
|
|
399
|
-
);
|
|
400
|
-
data.fields.designer = {};
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Destinations
|
|
406
|
-
if (subFamily?.destinations?.length) {
|
|
407
|
-
log(`set destinations`);
|
|
408
|
-
data.fields = await addFieldValue(
|
|
409
|
-
data,
|
|
410
|
-
"destinations",
|
|
411
|
-
subFamily.destinations
|
|
412
|
-
);
|
|
413
|
-
} else {
|
|
414
|
-
log(`destinations not found`, "WARN");
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// lastPimSyncDate
|
|
418
|
-
data.fields = await addFieldValue(data, "lastPimSyncDate", getLocalISOTime());
|
|
419
|
-
|
|
420
|
-
return data;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Import subFamily
|
|
425
|
-
*
|
|
426
|
-
* create/update topicSubFamily
|
|
427
|
-
* - name
|
|
428
|
-
* - code
|
|
429
|
-
* - catalog
|
|
430
|
-
* - parentFamily
|
|
431
|
-
* - lastPimSyncDate
|
|
432
|
-
*
|
|
433
|
-
* @param subFamily
|
|
434
|
-
* @returns
|
|
435
|
-
*/
|
|
436
|
-
const importSubFamily = async (
|
|
437
|
-
subFamily: PagedCollectionEntity,
|
|
438
|
-
catalog: AvailableCatalogs
|
|
439
|
-
) => {
|
|
440
|
-
const code = `${subFamily.data.code}`;
|
|
441
|
-
let topicSubFamily: Entry = await getEntryByID(code, "topicSubFamily");
|
|
442
|
-
log(`importSubFamily ${code} to catalog ${catalog}`, "INFO");
|
|
443
|
-
|
|
444
|
-
const topicSubFamilyData: CreateEntryProps = await getTopicSubFamilyData(
|
|
445
|
-
subFamily,
|
|
446
|
-
catalog,
|
|
447
|
-
topicSubFamily
|
|
448
|
-
);
|
|
449
|
-
if (topicSubFamily) {
|
|
450
|
-
log(`The topicSubFamily ${code} already exists. Updating...`);
|
|
451
|
-
topicSubFamily = await updateEntry(
|
|
452
|
-
topicSubFamily,
|
|
453
|
-
topicSubFamilyData,
|
|
454
|
-
topicSubFamily.isPublished()
|
|
455
|
-
);
|
|
456
|
-
} else {
|
|
457
|
-
log(`The topicSubFamily ${code} not exists. Creating...`);
|
|
458
|
-
topicSubFamily = await createEntryWithId(
|
|
459
|
-
"topicSubFamily",
|
|
460
|
-
code,
|
|
461
|
-
topicSubFamilyData
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// Add subFamily to categoryEntry subFamilies relation field
|
|
466
|
-
if (subFamily.categoryCode) {
|
|
467
|
-
const categoryTopicCode = getCategoryTopicCode(
|
|
468
|
-
subFamily.categoryCode,
|
|
469
|
-
catalog
|
|
470
|
-
);
|
|
471
|
-
const categoryEntry = await getEntryByCode(
|
|
472
|
-
categoryTopicCode,
|
|
473
|
-
"topicCategory"
|
|
474
|
-
);
|
|
475
|
-
if (categoryEntry) {
|
|
476
|
-
log(
|
|
477
|
-
`Add topicSubFamily ${code} to subFamilies relation field of ${subFamily.categoryCode} category`
|
|
478
|
-
);
|
|
479
|
-
const subFamiliesFieldKey =
|
|
480
|
-
"subFamilies" + capitalizeFirstLetter(catalog);
|
|
481
|
-
await updateSubFamiliesRelToEntry(
|
|
482
|
-
categoryEntry,
|
|
483
|
-
[code],
|
|
484
|
-
subFamiliesFieldKey
|
|
485
|
-
);
|
|
486
|
-
} else {
|
|
487
|
-
log(`Category with code ${subFamily.categoryCode} not found`);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
return topicSubFamily;
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Import subfamilies
|
|
496
|
-
*
|
|
497
|
-
* @param {number} offset Default 0
|
|
498
|
-
* @param {number} limit Range 0-50. Default 50
|
|
499
|
-
* @returns {object}
|
|
500
|
-
*/
|
|
501
|
-
export const importSubFamilies = async (
|
|
502
|
-
offset: number = 0,
|
|
503
|
-
limit: number = 50,
|
|
504
|
-
catalog: AvailableCatalogs
|
|
505
|
-
): Promise<PaginationResults> => {
|
|
506
|
-
log(`importSubFamilies - offset: ${offset}, limit: ${limit}`, "INFO");
|
|
507
|
-
const subFamilies = await getOtherCatalogData<CollectionSubFamilies>(
|
|
508
|
-
"subfamilies",
|
|
509
|
-
offset,
|
|
510
|
-
limit
|
|
511
|
-
);
|
|
512
|
-
const total = subFamilies?.pagedCollection?.length || 0;
|
|
513
|
-
|
|
514
|
-
if (subFamilies?.pagedCollection?.length) {
|
|
515
|
-
log(`Import ${total} subFamilies`);
|
|
516
|
-
let count = offset;
|
|
517
|
-
let current: number = 0;
|
|
518
|
-
for (const subFamily of subFamilies.pagedCollection) {
|
|
519
|
-
log(`${++count} of ${subFamilies.totalCount}`);
|
|
520
|
-
|
|
521
|
-
if (subFamily.catalogCode !== catalog) {
|
|
522
|
-
log(
|
|
523
|
-
`The ${subFamily.data.code} subfamily does not belong to the ${catalog} catalog and will not be imported`
|
|
524
|
-
);
|
|
525
|
-
continue;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
if (!sanitizeValue(subFamily.data.code)) {
|
|
529
|
-
log(`The subfamily code ${subFamily.data.code} is not valid`, "WARN");
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
const topicSubFamily = await importSubFamily(subFamily, catalog);
|
|
534
|
-
|
|
535
|
-
await createOrUpdatePage(topicSubFamily);
|
|
536
|
-
|
|
537
|
-
if (serverUtils) {
|
|
538
|
-
serverUtils.log(subFamily.data.code);
|
|
539
|
-
const progress = Math.floor(
|
|
540
|
-
(++current / subFamilies.pagedCollection.length) * 100
|
|
541
|
-
);
|
|
542
|
-
serverUtils.updateProgress(progress);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// Max 7 calls per seconds
|
|
546
|
-
if (count % 2 === 0 && count < subFamilies.totalCount) {
|
|
547
|
-
await sleep(1000);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
} else {
|
|
551
|
-
log(`No subFamilies found`);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
const nextOffset = Number(offset) + Number(limit);
|
|
555
|
-
|
|
556
|
-
if (serverUtils) {
|
|
557
|
-
serverUtils.updateProgress(100);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return {
|
|
561
|
-
offset: nextOffset,
|
|
562
|
-
limit: Number(limit),
|
|
563
|
-
completed: nextOffset >= subFamilies.totalCount,
|
|
564
|
-
total: subFamilies.totalCount,
|
|
565
|
-
};
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
export const getSubFamilyRelatedDetails = async (topicSubFamily: Entry) => {
|
|
569
|
-
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
570
|
-
const catalogEntryId =
|
|
571
|
-
topicSubFamily?.fields?.catalog?.[defaultEnvironmentLocaleCode]?.sys?.id;
|
|
572
|
-
if (!catalogEntryId) {
|
|
573
|
-
log(
|
|
574
|
-
`catalogEntryId not found to ${topicSubFamily.sys.id} subFamilyEntry`,
|
|
575
|
-
"WARN"
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
const parentFamilyEntryId =
|
|
579
|
-
topicSubFamily?.fields?.parentFamily?.[defaultEnvironmentLocaleCode]?.sys
|
|
580
|
-
?.id;
|
|
581
|
-
if (!parentFamilyEntryId) {
|
|
582
|
-
log(
|
|
583
|
-
`parentFamilyEntryId not found to ${topicSubFamily.sys.id} subFamilyEntry`,
|
|
584
|
-
"WARN"
|
|
585
|
-
);
|
|
586
|
-
}
|
|
587
|
-
const categoryEntryId =
|
|
588
|
-
topicSubFamily?.fields?.category?.[defaultEnvironmentLocaleCode]?.sys?.id;
|
|
589
|
-
if (!categoryEntryId) {
|
|
590
|
-
log(
|
|
591
|
-
`categoryEntryId not found to ${topicSubFamily.sys.id} subFamilyEntry`,
|
|
592
|
-
"WARN"
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
const subFamilyCatalogPage: any = catalogEntryId
|
|
596
|
-
? await getEntryByID(`${catalogEntryId}_PAGE`, "page", "fields.slug")
|
|
597
|
-
: {};
|
|
598
|
-
const subFamilyFamilyPage: any = parentFamilyEntryId
|
|
599
|
-
? await getEntryByID(`${parentFamilyEntryId}_PAGE`, "page", "fields.slug")
|
|
600
|
-
: {};
|
|
601
|
-
const subFamilyCategoryPage: any = categoryEntryId
|
|
602
|
-
? await getEntryByID(`${categoryEntryId}_PAGE`, "page", "fields.slug")
|
|
603
|
-
: {};
|
|
604
|
-
|
|
605
|
-
return {
|
|
606
|
-
catalogPageSlugs: keysToLowerCase(subFamilyCatalogPage?.fields?.slug) || {},
|
|
607
|
-
familyPageSlugs: keysToLowerCase(subFamilyFamilyPage?.fields?.slug) || {},
|
|
608
|
-
categoryPageSlugs:
|
|
609
|
-
keysToLowerCase(subFamilyCategoryPage?.fields?.slug) || {},
|
|
610
|
-
};
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
export const getSubFamilyPageSlugWithDetails = async (
|
|
614
|
-
subFamilyEntry: Entry
|
|
615
|
-
): Promise<pageResponse> => {
|
|
616
|
-
const subFamilyEntryId = subFamilyEntry?.sys?.id;
|
|
617
|
-
if (!subFamilyEntryId) {
|
|
618
|
-
log(`Invalid subFamilyEntry`, "ERROR");
|
|
619
|
-
}
|
|
620
|
-
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
621
|
-
const catalogEntryId =
|
|
622
|
-
subFamilyEntry?.fields?.catalog?.[defaultEnvironmentLocaleCode]?.sys?.id;
|
|
623
|
-
if (!catalogEntryId) {
|
|
624
|
-
log(
|
|
625
|
-
`catalogEntryId not found to ${subFamilyEntryId} subFamilyEntry`,
|
|
626
|
-
"WARN"
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
const parentFamilyEntryId =
|
|
630
|
-
subFamilyEntry?.fields?.parentFamily?.[defaultEnvironmentLocaleCode]?.sys
|
|
631
|
-
?.id;
|
|
632
|
-
if (!parentFamilyEntryId) {
|
|
633
|
-
log(
|
|
634
|
-
`parentFamilyEntryId not found to ${subFamilyEntryId} subFamilyEntry`,
|
|
635
|
-
"WARN"
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
const categoryEntryId =
|
|
639
|
-
subFamilyEntry?.fields?.category?.[defaultEnvironmentLocaleCode]?.sys?.id;
|
|
640
|
-
if (!categoryEntryId) {
|
|
641
|
-
log(
|
|
642
|
-
`categoryEntryId not found to ${subFamilyEntryId} subFamilyEntry`,
|
|
643
|
-
"WARN"
|
|
644
|
-
);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
// Return subFamily page slug
|
|
648
|
-
const subFamilyPageId = `${subFamilyEntryId}_PAGE`;
|
|
649
|
-
const subFamilyPage = await getEntryByID(subFamilyPageId, "page");
|
|
650
|
-
const details = await getSubFamilyRelatedDetails(subFamilyEntry);
|
|
651
|
-
if (subFamilyPage) {
|
|
652
|
-
return {
|
|
653
|
-
slugs: subFamilyPage?.fields?.slug,
|
|
654
|
-
type: subFamilyPage?.fields?.type?.[defaultEnvironmentLocaleCode],
|
|
655
|
-
details,
|
|
656
|
-
};
|
|
657
|
-
} else {
|
|
658
|
-
log(`The subFamilyPage with id "${subFamilyPageId}" not found`, "WARN");
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
return null;
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* Update or Create the componentModelPages of specific subFamilyPage by subfamily entry
|
|
666
|
-
* This method is used by models import
|
|
667
|
-
*
|
|
668
|
-
* @param subFamilyEntry
|
|
669
|
-
* @returns
|
|
670
|
-
*/
|
|
671
|
-
export const updateComponentModelPagesToSubFamilyPage = async (
|
|
672
|
-
subFamilyEntry: Entry
|
|
673
|
-
) => {
|
|
674
|
-
const defaultEnvironmentLocaleCode = await getEnvironmentDefaultLocaleCode();
|
|
675
|
-
const pageId = `${subFamilyEntry.sys.id}_PAGE`;
|
|
676
|
-
let subFamilyPageEntry: Entry = await getEntryByID(pageId, "page");
|
|
677
|
-
|
|
678
|
-
if (!subFamilyPageEntry) {
|
|
679
|
-
log(`${pageId} subFamily page not found`);
|
|
680
|
-
} else {
|
|
681
|
-
const componentModelPages = await addComponentModelPages(subFamilyEntry);
|
|
682
|
-
const pageData: CreateEntryProps = {
|
|
683
|
-
fields: subFamilyPageEntry?.fields || {},
|
|
684
|
-
};
|
|
685
|
-
if (
|
|
686
|
-
!pageData.fields.contents ||
|
|
687
|
-
!pageData.fields.contents[defaultEnvironmentLocaleCode].find(
|
|
688
|
-
(item: CfSys) => item.sys.id === componentModelPages.sys.id
|
|
689
|
-
)
|
|
690
|
-
) {
|
|
691
|
-
pageData.fields = await addToRelationFields(
|
|
692
|
-
pageData,
|
|
693
|
-
"contents",
|
|
694
|
-
componentModelPages.sys.id,
|
|
695
|
-
true
|
|
696
|
-
);
|
|
697
|
-
subFamilyPageEntry = await updateEntry(
|
|
698
|
-
subFamilyPageEntry,
|
|
699
|
-
pageData,
|
|
700
|
-
subFamilyPageEntry.isPublished()
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
return subFamilyPageEntry;
|
|
706
|
-
};
|