@cooperco/cooper-component-library 0.1.126 → 0.1.128
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/cms/0094-add-anchor-to-page-modules.cjs +114 -0
- package/dist/cms/0095-tabmodule-inline-body-copy.cjs +566 -0
- package/dist/cms/0096-delete-body-copy-content-type.cjs +151 -0
- package/dist/cms/carousel.query.ts +1 -0
- package/dist/cms/chartModule.query.ts +1 -0
- package/dist/cms/containerCollectionModule.query.ts +1 -0
- package/dist/cms/containerModule.query.ts +1 -0
- package/dist/cms/contentModule.query.ts +1 -0
- package/dist/cms/contentful/migrations/scripts/0094-add-anchor-to-page-modules.cjs +114 -0
- package/dist/cms/contentful/migrations/scripts/0095-tabmodule-inline-body-copy.cjs +566 -0
- package/dist/cms/contentful/migrations/scripts/0096-delete-body-copy-content-type.cjs +151 -0
- package/dist/cms/contentful/queries/carousel.query.js +1 -0
- package/dist/cms/contentful/queries/carousel.query.ts +1 -0
- package/dist/cms/contentful/queries/chartModule.query.js +1 -0
- package/dist/cms/contentful/queries/chartModule.query.ts +1 -0
- package/dist/cms/contentful/queries/containerCollectionModule.query.js +1 -0
- package/dist/cms/contentful/queries/containerCollectionModule.query.ts +1 -0
- package/dist/cms/contentful/queries/containerModule.query.js +1 -0
- package/dist/cms/contentful/queries/containerModule.query.ts +1 -0
- package/dist/cms/contentful/queries/contentModule.query.js +1 -0
- package/dist/cms/contentful/queries/contentModule.query.ts +1 -0
- package/dist/cms/contentful/queries/logoCollection.query.js +1 -0
- package/dist/cms/contentful/queries/logoCollection.query.ts +1 -0
- package/dist/cms/contentful/queries/page.query.js +11 -0
- package/dist/cms/contentful/queries/page.query.ts +11 -0
- package/dist/cms/contentful/queries/placeholderModule.query.js +2 -0
- package/dist/cms/contentful/queries/placeholderModule.query.ts +2 -0
- package/dist/cms/contentful/queries/productModule.query.js +14 -3
- package/dist/cms/contentful/queries/productModule.query.ts +14 -3
- package/dist/cms/contentful/queries/splitModule.query.js +2 -0
- package/dist/cms/contentful/queries/splitModule.query.ts +2 -0
- package/dist/cms/contentful/queries/testimonial.query.js +1 -0
- package/dist/cms/contentful/queries/testimonial.query.ts +1 -0
- package/dist/cms/contentful/queries/tileCollection.query.js +1 -0
- package/dist/cms/contentful/queries/tileCollection.query.ts +1 -0
- package/dist/cms/logoCollection.query.ts +1 -0
- package/dist/cms/migrations/scripts/0094-add-anchor-to-page-modules.cjs +114 -0
- package/dist/cms/migrations/scripts/0095-tabmodule-inline-body-copy.cjs +566 -0
- package/dist/cms/migrations/scripts/0096-delete-body-copy-content-type.cjs +151 -0
- package/dist/cms/page.query.ts +11 -0
- package/dist/cms/placeholderModule.query.ts +2 -0
- package/dist/cms/productModule.query.ts +14 -3
- package/dist/cms/queries/carousel.query.ts +1 -0
- package/dist/cms/queries/chartModule.query.ts +1 -0
- package/dist/cms/queries/containerCollectionModule.query.ts +1 -0
- package/dist/cms/queries/containerModule.query.ts +1 -0
- package/dist/cms/queries/contentModule.query.ts +1 -0
- package/dist/cms/queries/logoCollection.query.ts +1 -0
- package/dist/cms/queries/page.query.ts +11 -0
- package/dist/cms/queries/placeholderModule.query.ts +2 -0
- package/dist/cms/queries/productModule.query.ts +14 -3
- package/dist/cms/queries/splitModule.query.ts +2 -0
- package/dist/cms/queries/testimonial.query.ts +1 -0
- package/dist/cms/queries/tileCollection.query.ts +1 -0
- package/dist/cms/scripts/0094-add-anchor-to-page-modules.cjs +114 -0
- package/dist/cms/scripts/0095-tabmodule-inline-body-copy.cjs +566 -0
- package/dist/cms/scripts/0096-delete-body-copy-content-type.cjs +151 -0
- package/dist/cms/splitModule.query.ts +2 -0
- package/dist/cms/testimonial.query.ts +1 -0
- package/dist/cms/tileCollection.query.ts +1 -0
- package/dist/lib/component-lib.js +3886 -3848
- package/dist/lib/component-lib.umd.cjs +23 -23
- package/dist/lib/style.css +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/types.d.ts +1 -0
- package/dist/types/src/utils/normalizeAnchor.d.ts +12 -0
- package/package.json +1 -9
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const addEntryNameField = require('../helpers/addEntryNameField.cjs')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delete the obsolete bodyCopy content type after 0095 inlined its RichText
|
|
5
|
+
* onto tabModule.
|
|
6
|
+
*
|
|
7
|
+
* Only tabModule referenced bodyCopy (0048-create-tab-module.cjs). After 0095
|
|
8
|
+
* removed that Link field, nothing else links to it — safe to wipe entries and
|
|
9
|
+
* delete the content type.
|
|
10
|
+
*
|
|
11
|
+
* Entry deletion uses makeRequest at migration start (execution of 0096), which
|
|
12
|
+
* is valid here because 0095 has already been applied to the environment.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const BODY_COPY_RICH_TEXT_VALIDATIONS = [
|
|
16
|
+
{
|
|
17
|
+
enabledMarks: ['bold', 'italic', 'underline'],
|
|
18
|
+
message: 'Only bold, italic, and underline marks are allowed',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
enabledNodeTypes: [
|
|
22
|
+
'ordered-list',
|
|
23
|
+
'unordered-list',
|
|
24
|
+
'hr',
|
|
25
|
+
'hyperlink',
|
|
26
|
+
'embedded-entry-inline',
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
nodes: {
|
|
31
|
+
'embedded-entry-inline': [
|
|
32
|
+
{
|
|
33
|
+
linkContentType: ['highlightedText'],
|
|
34
|
+
message: 'You can only embedd Higlighted Text.',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Unpublish (if needed) and delete a single entry via the CMA.
|
|
43
|
+
* Ignores 404 so retries / races are safe.
|
|
44
|
+
*
|
|
45
|
+
* @param {Function} makeRequest
|
|
46
|
+
* @param {string} entryId
|
|
47
|
+
*/
|
|
48
|
+
async function deleteEntry(makeRequest, entryId) {
|
|
49
|
+
let entry
|
|
50
|
+
try {
|
|
51
|
+
entry = await makeRequest({
|
|
52
|
+
method: 'GET',
|
|
53
|
+
url: `/entries/${entryId}`,
|
|
54
|
+
})
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error?.status === 404 || error?.response?.status === 404) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
throw error
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (entry.sys.publishedVersion) {
|
|
63
|
+
try {
|
|
64
|
+
await makeRequest({
|
|
65
|
+
method: 'DELETE',
|
|
66
|
+
url: `/entries/${entryId}/published`,
|
|
67
|
+
headers: {
|
|
68
|
+
'X-Contentful-Version': String(entry.sys.version),
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
entry = await makeRequest({
|
|
72
|
+
method: 'GET',
|
|
73
|
+
url: `/entries/${entryId}`,
|
|
74
|
+
})
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error?.status !== 404 && error?.response?.status !== 404) {
|
|
77
|
+
throw error
|
|
78
|
+
}
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
await makeRequest({
|
|
85
|
+
method: 'DELETE',
|
|
86
|
+
url: `/entries/${entryId}`,
|
|
87
|
+
headers: {
|
|
88
|
+
'X-Contentful-Version': String(entry.sys.version),
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error?.status !== 404 && error?.response?.status !== 404) {
|
|
93
|
+
throw error
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Delete every entry of the given content type (paginated).
|
|
100
|
+
*
|
|
101
|
+
* @param {Function} makeRequest
|
|
102
|
+
* @param {string} contentTypeId
|
|
103
|
+
*/
|
|
104
|
+
async function deleteAllEntriesOfContentType(makeRequest, contentTypeId) {
|
|
105
|
+
const limit = 100
|
|
106
|
+
|
|
107
|
+
// Re-query from skip 0 after each page of deletes — indexes shift as
|
|
108
|
+
// entries drop, so a single ascending skip walk would miss rows.
|
|
109
|
+
for (;;) {
|
|
110
|
+
const page = await makeRequest({
|
|
111
|
+
method: 'GET',
|
|
112
|
+
url: `/entries?content_type=${contentTypeId}&limit=${limit}&skip=0&sys.archivedAt[exists]=false`,
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const items = page.items ?? []
|
|
116
|
+
if (items.length === 0) {
|
|
117
|
+
break
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
for (const item of items) {
|
|
121
|
+
await deleteEntry(makeRequest, item.sys.id)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
// @ts-check
|
|
128
|
+
/** @type { import('contentful-migration').MigrationFunction } */
|
|
129
|
+
up: async function (migration, { makeRequest }) {
|
|
130
|
+
await deleteAllEntriesOfContentType(makeRequest, 'bodyCopy')
|
|
131
|
+
migration.deleteContentType('bodyCopy')
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/** @type { import('contentful-migration').MigrationFunction } */
|
|
135
|
+
down: function (migration) {
|
|
136
|
+
const bodyCopy = migration.createContentType('bodyCopy', {
|
|
137
|
+
name: 'Body Copy',
|
|
138
|
+
displayField: 'entryName',
|
|
139
|
+
description: 'Manage the body copy module',
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
addEntryNameField(bodyCopy)
|
|
143
|
+
|
|
144
|
+
bodyCopy
|
|
145
|
+
.createField('bodyCopy')
|
|
146
|
+
.name('Body Copy')
|
|
147
|
+
.type('RichText')
|
|
148
|
+
.required(true)
|
|
149
|
+
.validations(BODY_COPY_RICH_TEXT_VALIDATIONS)
|
|
150
|
+
},
|
|
151
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/** @type { import('contentful-migration').MigrationFunction } */
|
|
3
|
+
up: function (migration) {
|
|
4
|
+
const carouselModule = migration.editContentType('carouselModule')
|
|
5
|
+
carouselModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
6
|
+
carouselModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
7
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const chartModule = migration.editContentType('chartModule')
|
|
11
|
+
chartModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
12
|
+
chartModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
13
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const containerCollectionModule = migration.editContentType('containerCollectionModule')
|
|
17
|
+
containerCollectionModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
18
|
+
containerCollectionModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
19
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const containerModule = migration.editContentType('containerModule')
|
|
23
|
+
containerModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
24
|
+
containerModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
25
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const contentModule = migration.editContentType('contentModule')
|
|
29
|
+
contentModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
30
|
+
contentModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
31
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const logoCollectionModule = migration.editContentType('logoCollectionModule')
|
|
35
|
+
logoCollectionModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
36
|
+
logoCollectionModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
37
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const placeholderModule = migration.editContentType('placeholderModule')
|
|
41
|
+
placeholderModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
42
|
+
placeholderModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
43
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const productModule = migration.editContentType('productModule')
|
|
47
|
+
productModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
48
|
+
productModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
49
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const splitModule = migration.editContentType('splitModule')
|
|
53
|
+
splitModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
54
|
+
splitModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
55
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const tabModule = migration.editContentType('tabModule')
|
|
59
|
+
tabModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
60
|
+
tabModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
61
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const testimonialModule = migration.editContentType('testimonialModule')
|
|
65
|
+
testimonialModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
66
|
+
testimonialModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
67
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const tileCollectionModule = migration.editContentType('tileCollectionModule')
|
|
71
|
+
tileCollectionModule.createField('anchor', { name: 'Anchor', type: 'Symbol', localized: true, })
|
|
72
|
+
tileCollectionModule.changeFieldControl('anchor', 'builtin', 'singleLine', {
|
|
73
|
+
helpText: 'Set the anchor (#) for the page module.',
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
down: function (migration) {
|
|
78
|
+
const carouselModule = migration.editContentType('carouselModule')
|
|
79
|
+
carouselModule.deleteField('anchor')
|
|
80
|
+
|
|
81
|
+
const chartModule = migration.editContentType('chartModule')
|
|
82
|
+
chartModule.deleteField('anchor')
|
|
83
|
+
|
|
84
|
+
const containerCollectionModule = migration.editContentType('containerCollectionModule')
|
|
85
|
+
containerCollectionModule.deleteField('anchor')
|
|
86
|
+
|
|
87
|
+
const containerModule = migration.editContentType('containerModule')
|
|
88
|
+
containerModule.deleteField('anchor')
|
|
89
|
+
|
|
90
|
+
const contentModule = migration.editContentType('contentModule')
|
|
91
|
+
contentModule.deleteField('anchor')
|
|
92
|
+
|
|
93
|
+
const logoCollectionModule = migration.editContentType('logoCollectionModule')
|
|
94
|
+
logoCollectionModule.deleteField('anchor')
|
|
95
|
+
|
|
96
|
+
const placeholderModule = migration.editContentType('placeholderModule')
|
|
97
|
+
placeholderModule.deleteField('anchor')
|
|
98
|
+
|
|
99
|
+
const productModule = migration.editContentType('productModule')
|
|
100
|
+
productModule.deleteField('anchor')
|
|
101
|
+
|
|
102
|
+
const splitModule = migration.editContentType('splitModule')
|
|
103
|
+
splitModule.deleteField('anchor')
|
|
104
|
+
|
|
105
|
+
const tabModule = migration.editContentType('tabModule')
|
|
106
|
+
tabModule.deleteField('anchor')
|
|
107
|
+
|
|
108
|
+
const testimonialModule = migration.editContentType('testimonialModule')
|
|
109
|
+
testimonialModule.deleteField('anchor')
|
|
110
|
+
|
|
111
|
+
const tileCollectionModule = migration.editContentType('tileCollectionModule')
|
|
112
|
+
tileCollectionModule.deleteField('anchor')
|
|
113
|
+
},
|
|
114
|
+
}
|