@nascentdigital/funnel-cms 4.5.6 → 4.6.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/api/CollectionClient.d.ts +5 -5
- package/dist/api/PageClient.d.ts +8 -5
- package/dist/strapi/StrapiCollectionClient.js +39 -39
- package/dist/strapi/StrapiPageClient.d.ts +1 -1
- package/dist/strapi/StrapiPageClient.js +29 -24
- package/dist/strapi/serialization/CollectionData.d.ts +5 -2
- package/dist/strapi/serialization/CollectionData.js +114 -3
- package/dist/strapi/serialization/PageData.d.ts +4 -1
- package/dist/strapi/serialization/PageData.js +130 -4
- package/package.json +2 -2
|
@@ -96,11 +96,11 @@ export declare namespace CollectionClient {
|
|
|
96
96
|
};
|
|
97
97
|
namespace Replace {
|
|
98
98
|
type Args = {
|
|
99
|
-
updatedCollection: Schema.Collection.
|
|
99
|
+
updatedCollection: Schema.Collection.LegacyData;
|
|
100
100
|
version: Environment;
|
|
101
101
|
skipSync?: boolean;
|
|
102
102
|
};
|
|
103
|
-
type Result = Schema.Collection.
|
|
103
|
+
type Result = Schema.Collection.LegacyData;
|
|
104
104
|
}
|
|
105
105
|
namespace GetOverview {
|
|
106
106
|
type Args = Query.ByBrand;
|
|
@@ -127,7 +127,7 @@ export declare namespace CollectionClient {
|
|
|
127
127
|
}
|
|
128
128
|
namespace Find {
|
|
129
129
|
type Args = Query.Paginated;
|
|
130
|
-
type Result = Pagination.Paginated<Schema.Collection.
|
|
130
|
+
type Result = Pagination.Paginated<Schema.Collection.LegacyData>;
|
|
131
131
|
}
|
|
132
132
|
namespace GetGroup {
|
|
133
133
|
type Args = Query.ByGroupId & {
|
|
@@ -139,7 +139,7 @@ export declare namespace CollectionClient {
|
|
|
139
139
|
}
|
|
140
140
|
namespace Get {
|
|
141
141
|
type Args = Query.ById;
|
|
142
|
-
type Result = Schema.Collection.
|
|
142
|
+
type Result = Schema.Collection.FlattenedData | undefined;
|
|
143
143
|
}
|
|
144
144
|
namespace Create {
|
|
145
145
|
type Args = NewArgs | NewLanguageArgs;
|
|
@@ -162,7 +162,7 @@ export declare namespace CollectionClient {
|
|
|
162
162
|
type Result = {
|
|
163
163
|
updatedOn: number;
|
|
164
164
|
changeSetId: Schema.ChangeSet.Id;
|
|
165
|
-
collection?: Schema.Collection.
|
|
165
|
+
collection?: Schema.Collection.FlattenedData;
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
namespace Unpublish {
|
package/dist/api/PageClient.d.ts
CHANGED
|
@@ -119,6 +119,9 @@ export declare namespace PageClient {
|
|
|
119
119
|
export namespace Criteria {
|
|
120
120
|
type Key = keyof Criteria;
|
|
121
121
|
}
|
|
122
|
+
export type Select = {
|
|
123
|
+
select?: 'all' | 'content';
|
|
124
|
+
};
|
|
122
125
|
export {};
|
|
123
126
|
}
|
|
124
127
|
namespace GetOverview {
|
|
@@ -162,12 +165,12 @@ export declare namespace PageClient {
|
|
|
162
165
|
type Result = Pagination.Paginated<Schema.Page.Data>;
|
|
163
166
|
}
|
|
164
167
|
namespace GetGroup {
|
|
165
|
-
type Args = Query.ByDetails;
|
|
168
|
+
type Args = Query.ByDetails & Query.Select;
|
|
166
169
|
type Result = Schema.Page.Data.AsGroup;
|
|
167
170
|
}
|
|
168
171
|
namespace Get {
|
|
169
|
-
type Args = Query.ById | Query.ByDetails;
|
|
170
|
-
type Result = Schema.Page.
|
|
172
|
+
type Args = (Query.ById | Query.ByDetails) & Query.Select;
|
|
173
|
+
type Result = Schema.Page.FlattenedData | undefined;
|
|
171
174
|
}
|
|
172
175
|
namespace Create {
|
|
173
176
|
type Args = NewArgs | NewLanguageArgs;
|
|
@@ -207,12 +210,12 @@ export declare namespace PageClient {
|
|
|
207
210
|
type Result = {
|
|
208
211
|
updatedOn: number;
|
|
209
212
|
changeSetId: Schema.ChangeSet.Id;
|
|
210
|
-
page?: Schema.Page.
|
|
213
|
+
page?: Schema.Page.FlattenedData;
|
|
211
214
|
};
|
|
212
215
|
}
|
|
213
216
|
namespace Replace {
|
|
214
217
|
type Args = {
|
|
215
|
-
page: Schema.Page.
|
|
218
|
+
page: Schema.Page.LegacyData;
|
|
216
219
|
version: Environment;
|
|
217
220
|
skipSync?: boolean;
|
|
218
221
|
};
|
|
@@ -65,7 +65,7 @@ class StrapiCollectionClient {
|
|
|
65
65
|
? ['publishedOn:desc', 'updatedAt:desc']
|
|
66
66
|
: ['updatedAt:desc'], populate: serialization_1.CollectionData.populate }, getCollectionQueryParams(args))), { items } = _b, paginated = __rest(_b, ["items"]);
|
|
67
67
|
// transform to DTOs
|
|
68
|
-
return Object.assign({ items: items.map(item => serialization_1.CollectionData.
|
|
68
|
+
return Object.assign({ items: items.map(item => serialization_1.CollectionData.deserializeLegacy(item, strapiUrl, resultProps)) }, paginated);
|
|
69
69
|
}
|
|
70
70
|
async getGroup({ version, type, brand, groupId, language }) {
|
|
71
71
|
var _a, _b;
|
|
@@ -96,7 +96,7 @@ class StrapiCollectionClient {
|
|
|
96
96
|
result.collection = await this.get({ version, id: target.id });
|
|
97
97
|
// sync name if collection was found
|
|
98
98
|
if (result.collection) {
|
|
99
|
-
result.group.name = result.collection.name;
|
|
99
|
+
result.group.name = result.collection.data.name;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
// return result
|
|
@@ -113,7 +113,7 @@ class StrapiCollectionClient {
|
|
|
113
113
|
});
|
|
114
114
|
// deserialize and return
|
|
115
115
|
return data
|
|
116
|
-
? serialization_1.CollectionData.
|
|
116
|
+
? serialization_1.CollectionData.deserializeFlattened(data, client.baseURL, resultProps)
|
|
117
117
|
: undefined;
|
|
118
118
|
}
|
|
119
119
|
async create(args) {
|
|
@@ -163,7 +163,7 @@ class StrapiCollectionClient {
|
|
|
163
163
|
populate: serialization_1.CollectionData.populate
|
|
164
164
|
});
|
|
165
165
|
// transform the deserialized entry
|
|
166
|
-
const collection = serialization_1.CollectionData.
|
|
166
|
+
const collection = serialization_1.CollectionData.deserializeFlattened(data, strapiUrl, funnel_core_1.Schema.Collection.Data.Props.all);
|
|
167
167
|
// add collection to changeset
|
|
168
168
|
await provider.changeSets.update({
|
|
169
169
|
id: changeSet.id,
|
|
@@ -172,12 +172,12 @@ class StrapiCollectionClient {
|
|
|
172
172
|
{
|
|
173
173
|
__type: 'collection',
|
|
174
174
|
type: 'create',
|
|
175
|
-
schema: collection.type,
|
|
176
|
-
id: collection.id,
|
|
177
|
-
groupId: collection.groupId,
|
|
178
|
-
name: collection.name,
|
|
179
|
-
language: collection.language,
|
|
180
|
-
errors: collection.errors,
|
|
175
|
+
schema: collection.data.type,
|
|
176
|
+
id: collection.data.id,
|
|
177
|
+
groupId: collection.data.groupId,
|
|
178
|
+
name: collection.data.name,
|
|
179
|
+
language: collection.data.language,
|
|
180
|
+
errors: collection.data.errors,
|
|
181
181
|
attribution: [
|
|
182
182
|
{ userId: user.id, updatedOn: Date.now() }
|
|
183
183
|
]
|
|
@@ -186,10 +186,10 @@ class StrapiCollectionClient {
|
|
|
186
186
|
});
|
|
187
187
|
// add collection to group
|
|
188
188
|
group.instances.push({
|
|
189
|
-
id: collection.id,
|
|
190
|
-
language: collection.language,
|
|
191
|
-
version: collection.version,
|
|
192
|
-
tags: collection.tags
|
|
189
|
+
id: collection.data.id,
|
|
190
|
+
language: collection.data.language,
|
|
191
|
+
version: collection.data.version,
|
|
192
|
+
tags: collection.data.tags
|
|
193
193
|
});
|
|
194
194
|
// return updated group
|
|
195
195
|
return {
|
|
@@ -227,7 +227,7 @@ class StrapiCollectionClient {
|
|
|
227
227
|
populate: serialization_1.CollectionData.populate
|
|
228
228
|
});
|
|
229
229
|
// transform the deserialized entry
|
|
230
|
-
const collection = serialization_1.CollectionData.
|
|
230
|
+
const collection = serialization_1.CollectionData.deserializeFlattened(data, strapiUrl, funnel_core_1.Schema.Collection.Data.Props.all);
|
|
231
231
|
// add collection to changeset
|
|
232
232
|
await provider.changeSets.update({
|
|
233
233
|
id: changeSet.id,
|
|
@@ -236,12 +236,12 @@ class StrapiCollectionClient {
|
|
|
236
236
|
{
|
|
237
237
|
__type: 'collection',
|
|
238
238
|
type: 'create',
|
|
239
|
-
schema: collection.type,
|
|
240
|
-
id: collection.id,
|
|
241
|
-
groupId: collection.groupId,
|
|
242
|
-
name: collection.name,
|
|
243
|
-
language: collection.language,
|
|
244
|
-
errors: collection.errors,
|
|
239
|
+
schema: collection.data.type,
|
|
240
|
+
id: collection.data.id,
|
|
241
|
+
groupId: collection.data.groupId,
|
|
242
|
+
name: collection.data.name,
|
|
243
|
+
language: collection.data.language,
|
|
244
|
+
errors: collection.data.errors,
|
|
245
245
|
attribution: [
|
|
246
246
|
{ userId: user.id, updatedOn: Date.now() }
|
|
247
247
|
]
|
|
@@ -251,15 +251,15 @@ class StrapiCollectionClient {
|
|
|
251
251
|
// return collection
|
|
252
252
|
return {
|
|
253
253
|
group: {
|
|
254
|
-
groupId: collection.groupId,
|
|
255
|
-
brand: collection.brand,
|
|
256
|
-
type: collection.type,
|
|
257
|
-
name: collection.name,
|
|
254
|
+
groupId: collection.data.groupId,
|
|
255
|
+
brand: collection.data.brand,
|
|
256
|
+
type: collection.data.type,
|
|
257
|
+
name: collection.data.name,
|
|
258
258
|
instances: [{
|
|
259
|
-
id: collection.id,
|
|
260
|
-
language: collection.language,
|
|
261
|
-
version: collection.version,
|
|
262
|
-
tags: collection.tags
|
|
259
|
+
id: collection.data.id,
|
|
260
|
+
language: collection.data.language,
|
|
261
|
+
version: collection.data.version,
|
|
262
|
+
tags: collection.data.tags
|
|
263
263
|
}]
|
|
264
264
|
},
|
|
265
265
|
collection
|
|
@@ -342,7 +342,7 @@ class StrapiCollectionClient {
|
|
|
342
342
|
const dupCollectionData = dupData;
|
|
343
343
|
console.debug('[StrapiCollectionClient] duplicate: created duplicate collection', { dupCollectionData });
|
|
344
344
|
// touch new duplicated collection
|
|
345
|
-
let dupCollection = serialization_1.CollectionData.
|
|
345
|
+
let dupCollection = serialization_1.CollectionData.deserializeLegacy(dupCollectionData, strapiUrl, funnel_core_1.Schema.Collection.Data.Props.all);
|
|
346
346
|
const dupCollectionModel = funnel_core_1.Schema.CollectionModel.from(dupCollection);
|
|
347
347
|
dupCollectionModel.sync();
|
|
348
348
|
// connect collection to changeset
|
|
@@ -350,7 +350,7 @@ class StrapiCollectionClient {
|
|
|
350
350
|
// update duplicate collection with updated data from sync
|
|
351
351
|
const update = serialization_1.CollectionData.serialize(dupCollection);
|
|
352
352
|
const { data: updatedData } = await collectionCollection.update(dupCollection.id, update, { status: 'draft' });
|
|
353
|
-
dupCollection = serialization_1.CollectionData.
|
|
353
|
+
dupCollection = serialization_1.CollectionData.deserializeLegacy(updatedData, strapiUrl, funnel_core_1.Schema.Collection.Data.Props.all);
|
|
354
354
|
console.debug('[StrapiCollectionClient] duplicate: touched duplicated collection');
|
|
355
355
|
// add collection to changeset
|
|
356
356
|
await provider.changeSets.update({
|
|
@@ -423,7 +423,7 @@ class StrapiCollectionClient {
|
|
|
423
423
|
});
|
|
424
424
|
console.debug(`[StrapiCollectionClient/replace] returning final collection`);
|
|
425
425
|
// return collection
|
|
426
|
-
return serialization_1.CollectionData.
|
|
426
|
+
return serialization_1.CollectionData.deserializeLegacy(updatedData, strapiUrl);
|
|
427
427
|
}
|
|
428
428
|
async unpublish(collectionId) {
|
|
429
429
|
// get collection
|
|
@@ -433,7 +433,7 @@ class StrapiCollectionClient {
|
|
|
433
433
|
throw new funnel_core_1.NotFoundError('Unable to resolve collection');
|
|
434
434
|
}
|
|
435
435
|
// or throw if it's already draft
|
|
436
|
-
else if (!collection.publishedOn) {
|
|
436
|
+
else if (!collection.data.publishedOn) {
|
|
437
437
|
throw new funnel_core_1.InvalidOperationError('Collection is not published');
|
|
438
438
|
}
|
|
439
439
|
// unpublish the document
|
|
@@ -442,7 +442,7 @@ class StrapiCollectionClient {
|
|
|
442
442
|
command: 'unpublish',
|
|
443
443
|
data: JSON.stringify({
|
|
444
444
|
collection: 'collection',
|
|
445
|
-
documentId: collection.id
|
|
445
|
+
documentId: collection.data.id
|
|
446
446
|
}),
|
|
447
447
|
onError: ({ pageRefs, collectionRefs }) => {
|
|
448
448
|
// throw dependants error if we got any refs
|
|
@@ -451,8 +451,8 @@ class StrapiCollectionClient {
|
|
|
451
451
|
const strapiUrl = client.baseURL;
|
|
452
452
|
throw new errors_1.LinkedDependantsError({
|
|
453
453
|
message: 'This collection cannot be unpublished because it would break dependencies',
|
|
454
|
-
pages: pageRefs.map(data => serialization_1.PageData.
|
|
455
|
-
collections: collectionRefs.map(data => serialization_1.CollectionData.
|
|
454
|
+
pages: pageRefs.map(data => serialization_1.PageData.deserializeLegacy(data, strapiUrl, funnel_core_1.Schema.Page.Data.AsLink.props)),
|
|
455
|
+
collections: collectionRefs.map(data => serialization_1.CollectionData.deserializeLegacy(data, strapiUrl, funnel_core_1.Schema.Collection.Data.AsLink.props))
|
|
456
456
|
});
|
|
457
457
|
}
|
|
458
458
|
// or assume the page isn't published
|
|
@@ -486,8 +486,8 @@ class StrapiCollectionClient {
|
|
|
486
486
|
]);
|
|
487
487
|
// return
|
|
488
488
|
return {
|
|
489
|
-
pages: pages.map(page => serialization_1.PageData.
|
|
490
|
-
collections: collections.map(collection => serialization_1.CollectionData.
|
|
489
|
+
pages: pages.map(page => serialization_1.PageData.deserializeLegacy(page, strapiUrl, funnel_core_1.Schema.Page.Data.AsRef.props)),
|
|
490
|
+
collections: collections.map(collection => serialization_1.CollectionData.deserializeLegacy(collection, strapiUrl, funnel_core_1.Schema.Collection.Data.AsRef.props))
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
493
|
async getDependencies({ id: collectionId, version }) {
|
|
@@ -506,7 +506,7 @@ class StrapiCollectionClient {
|
|
|
506
506
|
}
|
|
507
507
|
// return
|
|
508
508
|
return {
|
|
509
|
-
collections: collectionData.collectionRefs.map(collectionRef => serialization_1.CollectionData.
|
|
509
|
+
collections: collectionData.collectionRefs.map(collectionRef => serialization_1.CollectionData.deserializeLegacy(collectionRef, strapiUrl, funnel_core_1.Schema.Collection.Data.AsRef.props))
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
512
|
}
|
|
@@ -9,7 +9,7 @@ export declare class StrapiPageClient implements PageClient {
|
|
|
9
9
|
search({ pagination, ...args }: PageClient.Search.Args): Promise<PageClient.Search.Result>;
|
|
10
10
|
query({ pagination, ...args }: PageClient.Query.Args): Promise<PageClient.Query.Result>;
|
|
11
11
|
find({ pagination, ...args }: PageClient.Find.Args): Promise<PageClient.Find.Result>;
|
|
12
|
-
getGroup({ brand, groupId, type, slug, region, language, version }: PageClient.GetGroup.Args): Promise<PageClient.GetGroup.Result>;
|
|
12
|
+
getGroup({ brand, groupId, type, slug, region, language, version, select }: PageClient.GetGroup.Args): Promise<PageClient.GetGroup.Result>;
|
|
13
13
|
get(args: PageClient.Get.Args): Promise<PageClient.Get.Result>;
|
|
14
14
|
create(args: PageClient.Create.Args): Promise<PageClient.Create.Result>;
|
|
15
15
|
duplicate({ source: pageId, targetPage, targetLanguage, targetSlug }: PageClient.Duplicate.Args): Promise<PageClient.Duplicate.Result>;
|
|
@@ -50,7 +50,7 @@ class StrapiPageClient {
|
|
|
50
50
|
? ['type', 'publishedOn:desc', 'updatedAt:desc']
|
|
51
51
|
: ['type', 'updatedAt:desc'] }, getPageQueryParams(args)));
|
|
52
52
|
// transform to dtos
|
|
53
|
-
return entries.items.map(item => serialization_1.PageData.
|
|
53
|
+
return entries.items.map(item => serialization_1.PageData.deserializeLegacy(item, strapiUrl, resultProps));
|
|
54
54
|
}
|
|
55
55
|
async getPreviews(_a) {
|
|
56
56
|
var { pagination } = _a, args = __rest(_a, ["pagination"]);
|
|
@@ -77,7 +77,7 @@ class StrapiPageClient {
|
|
|
77
77
|
status
|
|
78
78
|
}), { items } = _b, paginated = __rest(_b, ["items"]);
|
|
79
79
|
// transform and return items
|
|
80
|
-
return Object.assign({ items: items.map(item => serialization_1.PageData.
|
|
80
|
+
return Object.assign({ items: items.map(item => serialization_1.PageData.deserializeLegacy(item, strapiUrl, resultProps)) }, paginated);
|
|
81
81
|
}
|
|
82
82
|
async search(_a) {
|
|
83
83
|
var { pagination } = _a, args = __rest(_a, ["pagination"]);
|
|
@@ -91,7 +91,7 @@ class StrapiPageClient {
|
|
|
91
91
|
? ['publishedOn:desc', 'updatedAt:desc']
|
|
92
92
|
: ['updatedAt:desc'] }, getPageQueryParams(args))), { items } = _b, paginated = __rest(_b, ["items"]);
|
|
93
93
|
// transform and return items
|
|
94
|
-
return Object.assign({ items: items.map(item => serialization_1.PageData.
|
|
94
|
+
return Object.assign({ items: items.map(item => serialization_1.PageData.deserializeLegacy(item, strapiUrl, resultProps)) }, paginated);
|
|
95
95
|
}
|
|
96
96
|
async query(_a) {
|
|
97
97
|
var { pagination } = _a, args = __rest(_a, ["pagination"]);
|
|
@@ -127,7 +127,7 @@ class StrapiPageClient {
|
|
|
127
127
|
});
|
|
128
128
|
// deserialize pages and return
|
|
129
129
|
return {
|
|
130
|
-
items: rankedPages.map(page => serialization_1.PageData.
|
|
130
|
+
items: rankedPages.map(page => serialization_1.PageData.deserializeLegacy(page, strapiUrl, resultProps)),
|
|
131
131
|
page: pagination === 'all' ? 1 : pagination.page,
|
|
132
132
|
pageCount: pagination === 'all' ? 1 : Math.ceil(filteredRankedPageIds.length / pagination.pageSize),
|
|
133
133
|
totalItemCount: filteredRankedPageIds.length
|
|
@@ -145,9 +145,9 @@ class StrapiPageClient {
|
|
|
145
145
|
? ['publishedOn:desc', 'updatedAt:desc']
|
|
146
146
|
: ['updatedAt:desc'], populate: serialization_1.PageData.Populate.full }, getPageQueryParams(args))), { items } = _b, paginated = __rest(_b, ["items"]);
|
|
147
147
|
// transform to DTOs
|
|
148
|
-
return Object.assign({ items: items.map(item => serialization_1.PageData.
|
|
148
|
+
return Object.assign({ items: items.map(item => serialization_1.PageData.deserializeLegacy(item, strapiUrl, resultProps)) }, paginated);
|
|
149
149
|
}
|
|
150
|
-
async getGroup({ brand, groupId, type, slug, region, language, version }) {
|
|
150
|
+
async getGroup({ brand, groupId, type, slug, region, language, version, select }) {
|
|
151
151
|
// create base result
|
|
152
152
|
const result = {
|
|
153
153
|
group: { groupId: groupId !== null && groupId !== void 0 ? groupId : funnel_core_1.Schema.Page.GroupId.empty, brand, type, slug, region, instances: [] }
|
|
@@ -169,11 +169,11 @@ class StrapiPageClient {
|
|
|
169
169
|
// connect groupId + preset (should all be the same, so it's ok to pave over)
|
|
170
170
|
group.groupId = item.groupId;
|
|
171
171
|
// add instance
|
|
172
|
-
const instance = serialization_1.PageData.
|
|
172
|
+
const instance = serialization_1.PageData.deserializeLegacy(item, client.baseURL, funnel_core_1.Schema.Page.Data.AsGroup.Instance.props);
|
|
173
173
|
group.instances.push(instance);
|
|
174
174
|
// set page if language matches
|
|
175
175
|
if (instance.language === language) {
|
|
176
|
-
result.page = await this.get({ id: instance.id, version });
|
|
176
|
+
result.page = await this.get({ id: instance.id, version, select });
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
// return result
|
|
@@ -184,7 +184,9 @@ class StrapiPageClient {
|
|
|
184
184
|
const client = this.provider.client;
|
|
185
185
|
const strapiUrl = client.baseURL;
|
|
186
186
|
const collection = client.collection('pages');
|
|
187
|
-
const resultProps =
|
|
187
|
+
const resultProps = args.select === 'content'
|
|
188
|
+
? funnel_core_1.Schema.Page.Data.AsContent.props
|
|
189
|
+
: funnel_core_1.Schema.Page.Data.Props.all;
|
|
188
190
|
let data;
|
|
189
191
|
if ('id' in args) {
|
|
190
192
|
// find entry by document id
|
|
@@ -214,7 +216,7 @@ class StrapiPageClient {
|
|
|
214
216
|
data = rawData[0];
|
|
215
217
|
}
|
|
216
218
|
// convert and return
|
|
217
|
-
return serialization_1.PageData.
|
|
219
|
+
return serialization_1.PageData.deserializeFlattened(data, strapiUrl, resultProps);
|
|
218
220
|
}
|
|
219
221
|
async create(args) {
|
|
220
222
|
// resolve current user (or throw)
|
|
@@ -259,7 +261,8 @@ class StrapiPageClient {
|
|
|
259
261
|
populate: serialization_1.PageData.Populate.full
|
|
260
262
|
});
|
|
261
263
|
// transform the deserialized entry
|
|
262
|
-
const
|
|
264
|
+
const flattenedPage = serialization_1.PageData.deserializeFlattened(data, strapiUrl, funnel_core_1.Schema.Page.Data.Props.all);
|
|
265
|
+
const page = flattenedPage.data;
|
|
263
266
|
// add page to changeset
|
|
264
267
|
await provider.changeSets.update({
|
|
265
268
|
id: changeSet.id,
|
|
@@ -306,7 +309,7 @@ class StrapiPageClient {
|
|
|
306
309
|
}
|
|
307
310
|
]
|
|
308
311
|
},
|
|
309
|
-
page
|
|
312
|
+
page: flattenedPage
|
|
310
313
|
};
|
|
311
314
|
}
|
|
312
315
|
// remove
|
|
@@ -368,7 +371,8 @@ class StrapiPageClient {
|
|
|
368
371
|
populate: serialization_1.PageData.Populate.full
|
|
369
372
|
});
|
|
370
373
|
// transform the deserialized entry
|
|
371
|
-
const
|
|
374
|
+
const flattenedPage = serialization_1.PageData.deserializeFlattened(data, strapiUrl, funnel_core_1.Schema.Page.Data.Props.all);
|
|
375
|
+
const page = flattenedPage.data;
|
|
372
376
|
// add page to changeset
|
|
373
377
|
await provider.changeSets.update({
|
|
374
378
|
id: changeSet.id,
|
|
@@ -415,7 +419,7 @@ class StrapiPageClient {
|
|
|
415
419
|
}
|
|
416
420
|
]
|
|
417
421
|
},
|
|
418
|
-
page
|
|
422
|
+
page: flattenedPage
|
|
419
423
|
};
|
|
420
424
|
}
|
|
421
425
|
// remove
|
|
@@ -533,7 +537,7 @@ class StrapiPageClient {
|
|
|
533
537
|
const dupPageData = dupData;
|
|
534
538
|
console.debug('[StrapiPageClient] duplicate: created duplicate page', { dupPageData });
|
|
535
539
|
// touch new duplicated page to update url/name
|
|
536
|
-
let dupPage = serialization_1.PageData.
|
|
540
|
+
let dupPage = serialization_1.PageData.deserializeLegacy(dupPageData, strapiUrl, funnel_core_1.Schema.Page.Data.Props.all);
|
|
537
541
|
const dupPageModel = funnel_core_1.Schema.PageModel.from(dupPage);
|
|
538
542
|
dupPageModel.sync();
|
|
539
543
|
// connect page to changeset
|
|
@@ -541,7 +545,7 @@ class StrapiPageClient {
|
|
|
541
545
|
// update duplicate page with updated url/name
|
|
542
546
|
const update = serialization_1.PageData.serialize(dupPage);
|
|
543
547
|
const { data: updatedData } = await pageCollection.update(dupPage.id, update, { status: 'draft' });
|
|
544
|
-
dupPage = serialization_1.PageData.
|
|
548
|
+
dupPage = serialization_1.PageData.deserializeLegacy(updatedData, strapiUrl, funnel_core_1.Schema.Page.Data.Props.all);
|
|
545
549
|
console.debug('[StrapiPageClient] duplicate: touched duplicated page');
|
|
546
550
|
// add page to changeset
|
|
547
551
|
await provider.changeSets.update({
|
|
@@ -601,7 +605,7 @@ class StrapiPageClient {
|
|
|
601
605
|
throw new funnel_core_1.NotFoundError();
|
|
602
606
|
}
|
|
603
607
|
// deserialize page (we'll be updating this version)
|
|
604
|
-
const page = serialization_1.PageData.
|
|
608
|
+
const page = serialization_1.PageData.deserializeLegacy(currentData, strapiUrl, resultProps);
|
|
605
609
|
// merge changes (the original page will have changed)
|
|
606
610
|
const model = funnel_core_1.Schema.PageModel.from(page);
|
|
607
611
|
model.sync();
|
|
@@ -642,11 +646,12 @@ class StrapiPageClient {
|
|
|
642
646
|
});
|
|
643
647
|
console.debug(`[StrapiPageClient/replace] returning final page`);
|
|
644
648
|
// return page
|
|
645
|
-
return serialization_1.PageData.
|
|
649
|
+
return serialization_1.PageData.deserializeLegacy(updatedData, strapiUrl);
|
|
646
650
|
}
|
|
647
651
|
async unpublish(pageId) {
|
|
648
652
|
// get page
|
|
649
|
-
const
|
|
653
|
+
const flattenedPage = await this.get({ id: pageId, version: 'draft' });
|
|
654
|
+
const page = flattenedPage === null || flattenedPage === void 0 ? void 0 : flattenedPage.data;
|
|
650
655
|
// throw if there's no page
|
|
651
656
|
if (!page) {
|
|
652
657
|
throw new funnel_core_1.NotFoundError('Unable to resolve page');
|
|
@@ -670,8 +675,8 @@ class StrapiPageClient {
|
|
|
670
675
|
const strapiUrl = client.baseURL;
|
|
671
676
|
throw new errors_1.LinkedDependantsError({
|
|
672
677
|
message: 'This collection cannot be unpublished because it would break dependencies',
|
|
673
|
-
pages: pageRefs.map(data => serialization_1.PageData.
|
|
674
|
-
collections: collectionRefs.map(data => serialization_1.CollectionData.
|
|
678
|
+
pages: pageRefs.map(data => serialization_1.PageData.deserializeLegacy(data, strapiUrl, funnel_core_1.Schema.Page.Data.AsLink.props)),
|
|
679
|
+
collections: collectionRefs.map(data => serialization_1.CollectionData.deserializeLegacy(data, strapiUrl, funnel_core_1.Schema.Collection.Data.AsLink.props))
|
|
675
680
|
});
|
|
676
681
|
}
|
|
677
682
|
// or assume the page isn't published
|
|
@@ -701,7 +706,7 @@ class StrapiPageClient {
|
|
|
701
706
|
});
|
|
702
707
|
// return
|
|
703
708
|
return {
|
|
704
|
-
pages: pages.map(page => serialization_1.PageData.
|
|
709
|
+
pages: pages.map(page => serialization_1.PageData.deserializeLegacy(page, strapiUrl, funnel_core_1.Schema.Page.Data.AsLink.props))
|
|
705
710
|
};
|
|
706
711
|
}
|
|
707
712
|
async getDependencies({ id: pageId, version }) {
|
|
@@ -720,8 +725,8 @@ class StrapiPageClient {
|
|
|
720
725
|
}
|
|
721
726
|
// return
|
|
722
727
|
return {
|
|
723
|
-
pages: page.pageRefs.map(pageRef => serialization_1.PageData.
|
|
724
|
-
collections: page.collectionRefs.map(collectionRef => serialization_1.CollectionData.
|
|
728
|
+
pages: page.pageRefs.map(pageRef => serialization_1.PageData.deserializeLegacy(pageRef, strapiUrl, funnel_core_1.Schema.Page.Data.AsLink.props)),
|
|
729
|
+
collections: page.collectionRefs.map(collectionRef => serialization_1.CollectionData.deserializeLegacy(collectionRef, strapiUrl, funnel_core_1.Schema.Collection.Data.AsLink.props))
|
|
725
730
|
};
|
|
726
731
|
}
|
|
727
732
|
async validateSlug({ brand, type, region, slug, groupId }) {
|
|
@@ -43,7 +43,10 @@ export declare namespace CollectionData {
|
|
|
43
43
|
function getStrapiFields(props: ReadonlyArray<Schema.Collection.Data.Props.All>): Array<keyof CollectionData>;
|
|
44
44
|
function getStrapiFilter(props: ReadonlyArray<Schema.Collection.Data.Props.All>): Array<keyof CollectionData>;
|
|
45
45
|
type Potential = RequiredBy<Partial<CollectionData>, StrapiData.Keys>;
|
|
46
|
-
function deserialize<TCollection extends Schema.Collection.Data>(data: Potential,
|
|
46
|
+
function deserialize<TCollection extends Schema.Collection.Data>(data: Potential, props?: ReadonlyArray<Schema.Collection.Data.Props.All>): TCollection;
|
|
47
|
+
function deserializeRefs(data: Potential, strapiUrl: string): Schema.Collection.References;
|
|
48
|
+
function deserializeFlattened<TCollection extends Schema.Collection>(data: Potential, strapiUrl: string, props?: ReadonlyArray<Schema.Collection.Data.Props.All>): Schema.Collection.FlattenedData<TCollection>;
|
|
49
|
+
function deserializeLegacy<TCollection extends Schema.Collection.LegacyData>(data: Potential, strapiUrl: string, props?: ReadonlyArray<Schema.Collection.Data.Props.All>): TCollection;
|
|
47
50
|
function deserializeRef(data: Ref): Schema.Collection.Data.AsRef;
|
|
48
51
|
type Update = Omit<CollectionData, StrapiData.Keys | 'assetRefs' | 'collectionRefs'> & {
|
|
49
52
|
assetRefs?: {
|
|
@@ -53,5 +56,5 @@ export declare namespace CollectionData {
|
|
|
53
56
|
set: Schema.Collection.Id[];
|
|
54
57
|
};
|
|
55
58
|
};
|
|
56
|
-
function serialize(collection: Schema.Collection.Data.AsDraft | Schema.Collection.
|
|
59
|
+
function serialize(collection: Schema.Collection.Data.AsDraft | Schema.Collection.LegacyData): Update;
|
|
57
60
|
}
|
|
@@ -79,14 +79,125 @@ var CollectionData;
|
|
|
79
79
|
return Array.from(filters);
|
|
80
80
|
}
|
|
81
81
|
CollectionData.getStrapiFilter = getStrapiFilter;
|
|
82
|
-
function deserialize(data,
|
|
82
|
+
function deserialize(data, props = funnel_core_1.Schema.Collection.Data.Props.all) {
|
|
83
|
+
// create output
|
|
84
|
+
const collection = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
85
|
+
const createdOn = Date.parse(data.createdAt);
|
|
86
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
87
|
+
// add root if there's any content props
|
|
88
|
+
if (funnel_core_1.Schema.Collection.Data.Props.content.some(prop => props.includes(prop))) {
|
|
89
|
+
collection.__root = 'collection';
|
|
90
|
+
}
|
|
91
|
+
// helper
|
|
92
|
+
const bindProp = (prop, target, transform) => {
|
|
93
|
+
if (prop in data) {
|
|
94
|
+
collection[target] = transform(data[prop]);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// bind required props to page
|
|
98
|
+
for (const prop of props) {
|
|
99
|
+
switch (prop) {
|
|
100
|
+
// handled by base
|
|
101
|
+
case 'id':
|
|
102
|
+
break;
|
|
103
|
+
// language
|
|
104
|
+
case 'language':
|
|
105
|
+
bindProp('lang', prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
106
|
+
break;
|
|
107
|
+
// direct transforms
|
|
108
|
+
case 'groupId':
|
|
109
|
+
case 'type':
|
|
110
|
+
case 'brand':
|
|
111
|
+
case 'version':
|
|
112
|
+
case 'name':
|
|
113
|
+
case 'state':
|
|
114
|
+
case 'changeSetId':
|
|
115
|
+
case 'snapshot':
|
|
116
|
+
case 'errors':
|
|
117
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
118
|
+
break;
|
|
119
|
+
// snapshot
|
|
120
|
+
case 'snapshotId':
|
|
121
|
+
if ('snapshot' in data && data.snapshot) {
|
|
122
|
+
collection.snapshotId = data.snapshot.id;
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
// tags
|
|
126
|
+
case 'tags':
|
|
127
|
+
bindProp(prop, prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
128
|
+
break;
|
|
129
|
+
// content
|
|
130
|
+
case 'fields':
|
|
131
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : {});
|
|
132
|
+
break;
|
|
133
|
+
// links
|
|
134
|
+
case 'pageIds':
|
|
135
|
+
bindProp('pageRefIds', prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
136
|
+
break;
|
|
137
|
+
// timestamps
|
|
138
|
+
case 'createdOn':
|
|
139
|
+
bindProp('createdAt', prop, () => createdOn);
|
|
140
|
+
break;
|
|
141
|
+
case 'updatedOn':
|
|
142
|
+
bindProp('updatedAt', prop, value => updatedOn);
|
|
143
|
+
break;
|
|
144
|
+
case 'publishedOn':
|
|
145
|
+
bindProp(prop, prop, value => value ? parseInt(value) : undefined);
|
|
146
|
+
break;
|
|
147
|
+
// ignore
|
|
148
|
+
case 'files':
|
|
149
|
+
case 'collections':
|
|
150
|
+
break;
|
|
151
|
+
// unhandled
|
|
152
|
+
default:
|
|
153
|
+
throw new funnel_core_1.NotImplementedError(`Missing support for transforming Collection "${prop}" prop`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// return collection
|
|
157
|
+
return collection;
|
|
158
|
+
}
|
|
159
|
+
CollectionData.deserialize = deserialize;
|
|
160
|
+
function deserializeRefs(data, strapiUrl) {
|
|
161
|
+
// extract reference fields
|
|
162
|
+
const { assetRefs = [], collectionRefs = [] } = data;
|
|
163
|
+
// files
|
|
164
|
+
let files = assetRefs
|
|
165
|
+
.map(data => StrapiAssetData_1.StrapiAssetData.deserialize(data, strapiUrl))
|
|
166
|
+
.reduce((files, asset) => {
|
|
167
|
+
files[asset.value.id] = asset;
|
|
168
|
+
return files;
|
|
169
|
+
}, {});
|
|
170
|
+
// collections
|
|
171
|
+
let collections = {};
|
|
172
|
+
for (const collectionRef of collectionRefs) {
|
|
173
|
+
// deserialize collection refs
|
|
174
|
+
const deserializedCollection = deserialize(collectionRef, funnel_core_1.Schema.Collection.Data.AsLink.props);
|
|
175
|
+
collections[deserializedCollection.id] = deserializedCollection;
|
|
176
|
+
// extract and combine this ref's refs
|
|
177
|
+
const collectionRefs = deserializeRefs(collectionRef, strapiUrl);
|
|
178
|
+
files = Object.assign(Object.assign({}, files), collectionRefs.files);
|
|
179
|
+
collections = Object.assign(Object.assign({}, collections), collectionRefs.collections);
|
|
180
|
+
}
|
|
181
|
+
// return
|
|
182
|
+
return {
|
|
183
|
+
files,
|
|
184
|
+
collections
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
CollectionData.deserializeRefs = deserializeRefs;
|
|
188
|
+
function deserializeFlattened(data, strapiUrl, props = funnel_core_1.Schema.Collection.Data.Props.all) {
|
|
189
|
+
// return flattened
|
|
190
|
+
return Object.assign({ data: deserialize(data, props) }, deserializeRefs(data, strapiUrl));
|
|
191
|
+
}
|
|
192
|
+
CollectionData.deserializeFlattened = deserializeFlattened;
|
|
193
|
+
function deserializeLegacy(data, strapiUrl, props = funnel_core_1.Schema.Collection.Data.Props.all) {
|
|
83
194
|
var _a, _b;
|
|
84
195
|
// create output
|
|
85
196
|
const collection = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
86
197
|
const createdOn = Date.parse(data.createdAt);
|
|
87
198
|
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
88
199
|
const files = ((_a = data.assetRefs) !== null && _a !== void 0 ? _a : []).map(data => StrapiAssetData_1.StrapiAssetData.deserialize(data, strapiUrl)).filter(funnel_core_1.Value.isDefined);
|
|
89
|
-
const collections = ((_b = data.collectionRefs) !== null && _b !== void 0 ? _b : []).map(collectionRef =>
|
|
200
|
+
const collections = ((_b = data.collectionRefs) !== null && _b !== void 0 ? _b : []).map(collectionRef => deserializeLegacy(collectionRef, strapiUrl, funnel_core_1.Schema.Collection.Data.Props.all));
|
|
90
201
|
// add root if there's any content props
|
|
91
202
|
if (funnel_core_1.Schema.Collection.Data.Props.content.some(prop => props.includes(prop))) {
|
|
92
203
|
collection.__root = 'collection';
|
|
@@ -161,7 +272,7 @@ var CollectionData;
|
|
|
161
272
|
// return collection
|
|
162
273
|
return collection;
|
|
163
274
|
}
|
|
164
|
-
CollectionData.
|
|
275
|
+
CollectionData.deserializeLegacy = deserializeLegacy;
|
|
165
276
|
// deserialize ref
|
|
166
277
|
function deserializeRef(data) {
|
|
167
278
|
var _a, _b, _c;
|
|
@@ -109,7 +109,10 @@ export declare namespace PageData {
|
|
|
109
109
|
function getStrapiFields(props: ReadonlyArray<Schema.Page.Data.Props.All>): Array<keyof PageData>;
|
|
110
110
|
function getStrapiFilter(props: ReadonlyArray<Schema.Page.Data.Props.All>): Array<keyof PageData>;
|
|
111
111
|
type Potential = RequiredBy<Partial<PageData>, StrapiData.Keys>;
|
|
112
|
-
function deserialize<TPage extends Schema.Page.Data>(data: Potential,
|
|
112
|
+
function deserialize<TPage extends Schema.Page.Data>(data: Potential, props?: ReadonlyArray<Schema.Page.Data.Props.All>): TPage;
|
|
113
|
+
function deserializeRefs(data: Potential, strapiUrl: string): Schema.Page.References;
|
|
114
|
+
function deserializeFlattened<TPage extends Schema.Page>(data: Potential, strapiUrl: string, props?: ReadonlyArray<Schema.Page.Data.Props.All>): Schema.Page.FlattenedData<TPage>;
|
|
115
|
+
function deserializeLegacy<TPage extends Schema.Page.LegacyData>(data: Potential, strapiUrl: string, props?: ReadonlyArray<Schema.Page.Data.Props.All>): TPage;
|
|
113
116
|
function deserializeRef(data: Ref): Schema.Page.Data.AsLink;
|
|
114
117
|
type Update = Omit<PageData, StrapiData.Keys | 'assetRefs' | 'pageRefs' | 'collectionRefs'> & {
|
|
115
118
|
assetRefs?: {
|
|
@@ -125,7 +125,133 @@ var PageData;
|
|
|
125
125
|
return Array.from(filters);
|
|
126
126
|
}
|
|
127
127
|
PageData.getStrapiFilter = getStrapiFilter;
|
|
128
|
-
function deserialize(data,
|
|
128
|
+
function deserialize(data, props = funnel_core_1.Schema.Page.Data.Props.all) {
|
|
129
|
+
// create output
|
|
130
|
+
const page = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
131
|
+
const createdOn = Date.parse(data.createdAt);
|
|
132
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
133
|
+
// add root if there's any content props
|
|
134
|
+
if (funnel_core_1.Schema.Page.Data.Props.content.some(prop => props.includes(prop))) {
|
|
135
|
+
page.__root = 'page';
|
|
136
|
+
}
|
|
137
|
+
// helper
|
|
138
|
+
const bindProp = (prop, target, transform) => {
|
|
139
|
+
if (prop in data) {
|
|
140
|
+
page[target] = transform(data[prop]);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
// bind required props to page
|
|
144
|
+
for (const prop of props) {
|
|
145
|
+
switch (prop) {
|
|
146
|
+
// handled by base
|
|
147
|
+
case 'id':
|
|
148
|
+
break;
|
|
149
|
+
// language
|
|
150
|
+
case 'language':
|
|
151
|
+
bindProp('lang', prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
152
|
+
break;
|
|
153
|
+
// direct transforms
|
|
154
|
+
case 'groupId':
|
|
155
|
+
case 'brand':
|
|
156
|
+
case 'region':
|
|
157
|
+
case 'type':
|
|
158
|
+
case 'slug':
|
|
159
|
+
case 'url':
|
|
160
|
+
case 'name':
|
|
161
|
+
case 'preview':
|
|
162
|
+
case 'state':
|
|
163
|
+
case 'changeSetId':
|
|
164
|
+
case 'snapshot':
|
|
165
|
+
case 'errors':
|
|
166
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
167
|
+
break;
|
|
168
|
+
// snapshot
|
|
169
|
+
case 'snapshotId':
|
|
170
|
+
if ('snapshot' in data && data.snapshot) {
|
|
171
|
+
page.snapshotId = data.snapshot.id;
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
// tags
|
|
175
|
+
case 'tags':
|
|
176
|
+
bindProp(prop, prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
177
|
+
break;
|
|
178
|
+
// content
|
|
179
|
+
case 'discover':
|
|
180
|
+
case 'content':
|
|
181
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : {});
|
|
182
|
+
break;
|
|
183
|
+
// timestamps
|
|
184
|
+
case 'createdOn':
|
|
185
|
+
bindProp('createdAt', prop, () => createdOn);
|
|
186
|
+
break;
|
|
187
|
+
case 'updatedOn':
|
|
188
|
+
bindProp('updatedAt', prop, () => updatedOn);
|
|
189
|
+
break;
|
|
190
|
+
case 'publishedOn':
|
|
191
|
+
case 'publication':
|
|
192
|
+
bindProp(prop, prop, value => value ? parseInt(value) : undefined);
|
|
193
|
+
break;
|
|
194
|
+
// ignore
|
|
195
|
+
case 'files':
|
|
196
|
+
case 'pages':
|
|
197
|
+
case 'collections':
|
|
198
|
+
break;
|
|
199
|
+
// unhandled
|
|
200
|
+
default:
|
|
201
|
+
throw new funnel_core_1.NotImplementedError(`Missing support for transforming page "${prop}" prop`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// return page
|
|
205
|
+
return page;
|
|
206
|
+
}
|
|
207
|
+
PageData.deserialize = deserialize;
|
|
208
|
+
function deserializeRefs(data, strapiUrl) {
|
|
209
|
+
// extract reference fields
|
|
210
|
+
const { assetRefs = [], pageRefs = [], collectionRefs = [] } = data;
|
|
211
|
+
// files
|
|
212
|
+
let files = assetRefs
|
|
213
|
+
.map(data => StrapiAssetData_1.StrapiAssetData.deserialize(data, strapiUrl))
|
|
214
|
+
.reduce((files, asset) => {
|
|
215
|
+
files[asset.value.id] = asset;
|
|
216
|
+
return files;
|
|
217
|
+
}, {});
|
|
218
|
+
// pages
|
|
219
|
+
let pages = {};
|
|
220
|
+
let collections = {};
|
|
221
|
+
for (const pageRef of pageRefs) {
|
|
222
|
+
// deserialize page refs
|
|
223
|
+
const deserializedPage = deserialize(pageRef, funnel_core_1.Schema.Page.Data.AsPreview.props);
|
|
224
|
+
pages[deserializedPage.id] = deserializedPage;
|
|
225
|
+
// extract and combine this ref's refs
|
|
226
|
+
const pageRefs = deserializeRefs(pageRef, strapiUrl);
|
|
227
|
+
files = Object.assign(Object.assign({}, files), pageRefs.files);
|
|
228
|
+
pages = Object.assign(Object.assign({}, pages), pageRefs.pages);
|
|
229
|
+
collections = Object.assign(Object.assign({}, collections), pageRefs.collections);
|
|
230
|
+
}
|
|
231
|
+
// collections
|
|
232
|
+
for (const collectionRef of collectionRefs) {
|
|
233
|
+
// deserialize collection refs
|
|
234
|
+
const deserializedCollection = CollectionData_1.CollectionData.deserialize(collectionRef, funnel_core_1.Schema.Collection.Data.AsLink.props);
|
|
235
|
+
collections[deserializedCollection.id] = deserializedCollection;
|
|
236
|
+
// extract and combine this ref's refs
|
|
237
|
+
const collectionRefs = CollectionData_1.CollectionData.deserializeRefs(collectionRef, strapiUrl);
|
|
238
|
+
files = Object.assign(Object.assign({}, files), collectionRefs.files);
|
|
239
|
+
collections = Object.assign(Object.assign({}, collections), collectionRefs.collections);
|
|
240
|
+
}
|
|
241
|
+
// return
|
|
242
|
+
return {
|
|
243
|
+
files,
|
|
244
|
+
pages,
|
|
245
|
+
collections
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
PageData.deserializeRefs = deserializeRefs;
|
|
249
|
+
function deserializeFlattened(data, strapiUrl, props = funnel_core_1.Schema.Page.Data.Props.all) {
|
|
250
|
+
// return flattened
|
|
251
|
+
return Object.assign({ data: deserialize(data, props) }, deserializeRefs(data, strapiUrl));
|
|
252
|
+
}
|
|
253
|
+
PageData.deserializeFlattened = deserializeFlattened;
|
|
254
|
+
function deserializeLegacy(data, strapiUrl, props = funnel_core_1.Schema.Page.Data.Props.all) {
|
|
129
255
|
var _a, _b, _c;
|
|
130
256
|
// create output
|
|
131
257
|
const page = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
@@ -135,10 +261,10 @@ var PageData;
|
|
|
135
261
|
.map(data => StrapiAssetData_1.StrapiAssetData.deserialize(data, strapiUrl))
|
|
136
262
|
.filter(funnel_core_1.Value.isDefined);
|
|
137
263
|
const pages = ((_b = data.pageRefs) !== null && _b !== void 0 ? _b : [])
|
|
138
|
-
.map(data =>
|
|
264
|
+
.map(data => deserializeLegacy(data, strapiUrl))
|
|
139
265
|
.filter(funnel_core_1.Value.isDefined);
|
|
140
266
|
const collections = ((_c = data.collectionRefs) !== null && _c !== void 0 ? _c : [])
|
|
141
|
-
.map(data => CollectionData_1.CollectionData.
|
|
267
|
+
.map(data => CollectionData_1.CollectionData.deserializeLegacy(data, strapiUrl))
|
|
142
268
|
.filter(funnel_core_1.Value.isDefined);
|
|
143
269
|
// add root if there's any content props
|
|
144
270
|
if (funnel_core_1.Schema.Page.Data.Props.content.some(prop => props.includes(prop))) {
|
|
@@ -219,7 +345,7 @@ var PageData;
|
|
|
219
345
|
// return page
|
|
220
346
|
return page;
|
|
221
347
|
}
|
|
222
|
-
PageData.
|
|
348
|
+
PageData.deserializeLegacy = deserializeLegacy;
|
|
223
349
|
// deserialize ref
|
|
224
350
|
function deserializeRef(data) {
|
|
225
351
|
var _a, _b, _c, _d;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-cms",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/cms"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"ts-jest": "^29",
|
|
43
43
|
"type-fest": "^4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "7fba18243bc79f94b3bd665db21f37bc7f3afd4c"
|
|
46
46
|
}
|