@nascentdigital/funnel-cms 4.4.4
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/AssetClient.d.ts +53 -0
- package/dist/api/AssetClient.js +2 -0
- package/dist/api/AssetUploadClient.d.ts +17 -0
- package/dist/api/AssetUploadClient.js +26 -0
- package/dist/api/AuthClient.d.ts +29 -0
- package/dist/api/AuthClient.js +2 -0
- package/dist/api/ChangeSetClient.d.ts +84 -0
- package/dist/api/ChangeSetClient.js +31 -0
- package/dist/api/CollectionClient.d.ts +187 -0
- package/dist/api/CollectionClient.js +2 -0
- package/dist/api/ContentClient.d.ts +43 -0
- package/dist/api/ContentClient.js +34 -0
- package/dist/api/IAssetApiClient.d.ts +9 -0
- package/dist/api/IAssetApiClient.js +2 -0
- package/dist/api/PageClient.d.ts +264 -0
- package/dist/api/PageClient.js +2 -0
- package/dist/api/SiteClient.d.ts +23 -0
- package/dist/api/SiteClient.js +2 -0
- package/dist/api/SiteConfigClient.d.ts +26 -0
- package/dist/api/SiteConfigClient.js +2 -0
- package/dist/api/UpgradeClient.d.ts +16 -0
- package/dist/api/UpgradeClient.js +2 -0
- package/dist/api/UserClient.d.ts +46 -0
- package/dist/api/UserClient.js +2 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.js +27 -0
- package/dist/errors/CMSError.d.ts +8 -0
- package/dist/errors/CMSError.js +17 -0
- package/dist/errors/CMSErrors.d.ts +5 -0
- package/dist/errors/CMSErrors.js +36 -0
- package/dist/errors/LinkedDependantsError.d.ts +21 -0
- package/dist/errors/LinkedDependantsError.js +31 -0
- package/dist/errors/LockdownError.d.ts +4 -0
- package/dist/errors/LockdownError.js +12 -0
- package/dist/errors/SlugValidationError.d.ts +21 -0
- package/dist/errors/SlugValidationError.js +23 -0
- package/dist/errors/TranslateReferencesError.d.ts +21 -0
- package/dist/errors/TranslateReferencesError.js +22 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +25 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/models/Entity.d.ts +14 -0
- package/dist/models/Entity.js +2 -0
- package/dist/models/Environment.d.ts +1 -0
- package/dist/models/Environment.js +2 -0
- package/dist/models/Pagination.d.ts +20 -0
- package/dist/models/Pagination.js +21 -0
- package/dist/models/Privilege.d.ts +57 -0
- package/dist/models/Privilege.js +163 -0
- package/dist/models/Role.d.ts +33 -0
- package/dist/models/Role.js +118 -0
- package/dist/models/SiteConfig.d.ts +14 -0
- package/dist/models/SiteConfig.js +2 -0
- package/dist/models/Upgrade.d.ts +40 -0
- package/dist/models/Upgrade.js +19 -0
- package/dist/models/User.d.ts +41 -0
- package/dist/models/User.js +71 -0
- package/dist/models/Versioned.d.ts +22 -0
- package/dist/models/Versioned.js +45 -0
- package/dist/models/index.d.ts +9 -0
- package/dist/models/index.js +25 -0
- package/dist/strapi/IStrapiContentClient.d.ts +39 -0
- package/dist/strapi/IStrapiContentClient.js +2 -0
- package/dist/strapi/Strapi.d.ts +37 -0
- package/dist/strapi/Strapi.js +156 -0
- package/dist/strapi/StrapiAssetClient.d.ts +11 -0
- package/dist/strapi/StrapiAssetClient.js +143 -0
- package/dist/strapi/StrapiAssetUploadClient.d.ts +6 -0
- package/dist/strapi/StrapiAssetUploadClient.js +109 -0
- package/dist/strapi/StrapiAuthClient.d.ts +9 -0
- package/dist/strapi/StrapiAuthClient.js +64 -0
- package/dist/strapi/StrapiChangeSetClient.d.ts +22 -0
- package/dist/strapi/StrapiChangeSetClient.js +218 -0
- package/dist/strapi/StrapiCollectionClient.d.ts +18 -0
- package/dist/strapi/StrapiCollectionClient.js +610 -0
- package/dist/strapi/StrapiContentClient.d.ts +38 -0
- package/dist/strapi/StrapiContentClient.js +105 -0
- package/dist/strapi/StrapiContentClientFactory.d.ts +13 -0
- package/dist/strapi/StrapiContentClientFactory.js +19 -0
- package/dist/strapi/StrapiPageClient.d.ts +23 -0
- package/dist/strapi/StrapiPageClient.js +882 -0
- package/dist/strapi/StrapiSiteConfigClient.d.ts +8 -0
- package/dist/strapi/StrapiSiteConfigClient.js +50 -0
- package/dist/strapi/StrapiUpgradeClient.d.ts +13 -0
- package/dist/strapi/StrapiUpgradeClient.js +118 -0
- package/dist/strapi/StrapiUserClient.d.ts +17 -0
- package/dist/strapi/StrapiUserClient.js +199 -0
- package/dist/strapi/client.d.ts +1 -0
- package/dist/strapi/client.js +17 -0
- package/dist/strapi/index.d.ts +3 -0
- package/dist/strapi/index.js +19 -0
- package/dist/strapi/models/StrapiAsset.d.ts +10 -0
- package/dist/strapi/models/StrapiAsset.js +16 -0
- package/dist/strapi/models/StrapiData.d.ts +13 -0
- package/dist/strapi/models/StrapiData.js +16 -0
- package/dist/strapi/models/StrapiFile.d.ts +18 -0
- package/dist/strapi/models/StrapiFile.js +2 -0
- package/dist/strapi/models/index.d.ts +3 -0
- package/dist/strapi/models/index.js +19 -0
- package/dist/strapi/serialization/ChangeSetData.d.ts +15 -0
- package/dist/strapi/serialization/ChangeSetData.js +76 -0
- package/dist/strapi/serialization/CollectionData.d.ts +57 -0
- package/dist/strapi/serialization/CollectionData.js +258 -0
- package/dist/strapi/serialization/CollectionSnapshotData.d.ts +16 -0
- package/dist/strapi/serialization/CollectionSnapshotData.js +66 -0
- package/dist/strapi/serialization/PageData.d.ts +126 -0
- package/dist/strapi/serialization/PageData.js +335 -0
- package/dist/strapi/serialization/PageSnapshotData.d.ts +20 -0
- package/dist/strapi/serialization/PageSnapshotData.js +69 -0
- package/dist/strapi/serialization/RoleData.d.ts +5 -0
- package/dist/strapi/serialization/RoleData.js +2 -0
- package/dist/strapi/serialization/SiteConfigData.d.ts +11 -0
- package/dist/strapi/serialization/SiteConfigData.js +23 -0
- package/dist/strapi/serialization/StrapiAssetData.d.ts +17 -0
- package/dist/strapi/serialization/StrapiAssetData.js +39 -0
- package/dist/strapi/serialization/UserData.d.ts +18 -0
- package/dist/strapi/serialization/UserData.js +42 -0
- package/dist/strapi/serialization/VersionData.d.ts +26 -0
- package/dist/strapi/serialization/VersionData.js +88 -0
- package/dist/strapi/serialization/index.d.ts +10 -0
- package/dist/strapi/serialization/index.js +26 -0
- package/dist/strapi/test.d.ts +563 -0
- package/dist/strapi/test.js +1131 -0
- package/package.json +42 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageData = void 0;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const CollectionData_1 = require("./CollectionData");
|
|
7
|
+
const StrapiAssetData_1 = require("./StrapiAssetData");
|
|
8
|
+
// extension
|
|
9
|
+
var PageData;
|
|
10
|
+
(function (PageData) {
|
|
11
|
+
// populate constants
|
|
12
|
+
let Populate;
|
|
13
|
+
(function (Populate) {
|
|
14
|
+
// populating collections doesn't change based on context used
|
|
15
|
+
const pageRefPreviewFields = getStrapiFields(withoutLinks(funnel_core_1.Schema.Page.Data.AsPreview.props));
|
|
16
|
+
const collectionRefFields = CollectionData_1.CollectionData.getStrapiFields(funnel_core_1.Schema.Collection.Data.AsLink.props);
|
|
17
|
+
const populateCollectionRefs = {
|
|
18
|
+
fields: collectionRefFields,
|
|
19
|
+
populate: {
|
|
20
|
+
assetRefs: { populate: '*' },
|
|
21
|
+
collectionRefs: {
|
|
22
|
+
fields: collectionRefFields,
|
|
23
|
+
populate: {
|
|
24
|
+
assetRefs: { populate: '*' }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// full page populate
|
|
30
|
+
Populate.full = {
|
|
31
|
+
assetRefs: { populate: '*' },
|
|
32
|
+
pageRefs: {
|
|
33
|
+
fields: pageRefPreviewFields,
|
|
34
|
+
populate: {
|
|
35
|
+
assetRefs: { populate: '*' },
|
|
36
|
+
pageRefs: {
|
|
37
|
+
fields: pageRefPreviewFields,
|
|
38
|
+
populate: '*'
|
|
39
|
+
},
|
|
40
|
+
collectionRefs: {
|
|
41
|
+
fields: collectionRefFields,
|
|
42
|
+
populate: '*'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
collectionRefs: populateCollectionRefs,
|
|
47
|
+
snapshot: { populate: '*' }
|
|
48
|
+
};
|
|
49
|
+
// preview page populate
|
|
50
|
+
Populate.preview = {
|
|
51
|
+
assetRefs: { populate: '*' },
|
|
52
|
+
pageRefs: {
|
|
53
|
+
fields: pageRefPreviewFields,
|
|
54
|
+
populate: {
|
|
55
|
+
assetRefs: { populate: '*' },
|
|
56
|
+
pageRefs: {
|
|
57
|
+
fields: funnel_core_1.Schema.Page.Data.AsRef.props,
|
|
58
|
+
},
|
|
59
|
+
collectionRefs: {
|
|
60
|
+
fields: collectionRefFields
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
collectionRefs: populateCollectionRefs
|
|
65
|
+
};
|
|
66
|
+
})(Populate = PageData.Populate || (PageData.Populate = {}));
|
|
67
|
+
// strip out any link props (file, page, collection) from props array
|
|
68
|
+
function withoutLinks(props) {
|
|
69
|
+
return props.filter(prop => !funnel_core_1.Schema.Page.Data.Props.links.includes(prop));
|
|
70
|
+
}
|
|
71
|
+
// map props
|
|
72
|
+
function getStrapiFields(props) {
|
|
73
|
+
return props
|
|
74
|
+
.filter(prop => prop !== '__root' && prop !== 'createdOn' && prop !== 'updatedOn' && prop !== 'snapshotId')
|
|
75
|
+
.map(prop => {
|
|
76
|
+
switch (prop) {
|
|
77
|
+
case 'language':
|
|
78
|
+
return 'lang';
|
|
79
|
+
case 'files':
|
|
80
|
+
return 'assetRefs';
|
|
81
|
+
case 'pages':
|
|
82
|
+
return 'pageRefs';
|
|
83
|
+
case 'collections':
|
|
84
|
+
return 'collectionRefs';
|
|
85
|
+
default:
|
|
86
|
+
return prop;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
PageData.getStrapiFields = getStrapiFields;
|
|
91
|
+
function getStrapiFilter(props) {
|
|
92
|
+
// build list
|
|
93
|
+
const filters = new Set(['createdAt', 'updatedAt', 'publishedAt']);
|
|
94
|
+
for (const prop of props) {
|
|
95
|
+
switch (prop) {
|
|
96
|
+
// special handling
|
|
97
|
+
case 'language':
|
|
98
|
+
filters.add('lang');
|
|
99
|
+
break;
|
|
100
|
+
// parity
|
|
101
|
+
case 'groupId':
|
|
102
|
+
case 'brand':
|
|
103
|
+
case 'type':
|
|
104
|
+
case 'slug':
|
|
105
|
+
case 'url':
|
|
106
|
+
case 'region':
|
|
107
|
+
case 'name':
|
|
108
|
+
case 'tags':
|
|
109
|
+
case 'discover':
|
|
110
|
+
case 'preview':
|
|
111
|
+
case 'content':
|
|
112
|
+
case 'state':
|
|
113
|
+
case 'changeSetId':
|
|
114
|
+
case 'errors':
|
|
115
|
+
case 'publishedOn':
|
|
116
|
+
case 'publication':
|
|
117
|
+
filters.add(prop);
|
|
118
|
+
break;
|
|
119
|
+
// ignore the rest
|
|
120
|
+
default:
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// return filters
|
|
125
|
+
return Array.from(filters);
|
|
126
|
+
}
|
|
127
|
+
PageData.getStrapiFilter = getStrapiFilter;
|
|
128
|
+
function deserialize(data, strapiUrl, props = funnel_core_1.Schema.Page.Data.Props.all) {
|
|
129
|
+
var _a, _b, _c;
|
|
130
|
+
// create output
|
|
131
|
+
const page = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
132
|
+
const createdOn = Date.parse(data.createdAt);
|
|
133
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
134
|
+
const files = ((_a = data.assetRefs) !== null && _a !== void 0 ? _a : [])
|
|
135
|
+
.map(data => StrapiAssetData_1.StrapiAssetData.deserialize(data, strapiUrl))
|
|
136
|
+
.filter(funnel_core_1.Value.isDefined);
|
|
137
|
+
const pages = ((_b = data.pageRefs) !== null && _b !== void 0 ? _b : [])
|
|
138
|
+
.map(data => deserialize(data, strapiUrl))
|
|
139
|
+
.filter(funnel_core_1.Value.isDefined);
|
|
140
|
+
const collections = ((_c = data.collectionRefs) !== null && _c !== void 0 ? _c : [])
|
|
141
|
+
.map(data => CollectionData_1.CollectionData.deserialize(data, strapiUrl))
|
|
142
|
+
.filter(funnel_core_1.Value.isDefined);
|
|
143
|
+
// add root if there's any content props
|
|
144
|
+
if (funnel_core_1.Schema.Page.Data.Props.content.some(prop => props.includes(prop))) {
|
|
145
|
+
page.__root = 'page';
|
|
146
|
+
}
|
|
147
|
+
// helper
|
|
148
|
+
const bindProp = (prop, target, transform) => {
|
|
149
|
+
if (prop in data) {
|
|
150
|
+
page[target] = transform(data[prop]);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
// bind required props to page
|
|
154
|
+
for (const prop of props) {
|
|
155
|
+
switch (prop) {
|
|
156
|
+
// handled by base
|
|
157
|
+
case 'id':
|
|
158
|
+
break;
|
|
159
|
+
// language
|
|
160
|
+
case 'language':
|
|
161
|
+
bindProp('lang', prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
162
|
+
break;
|
|
163
|
+
// direct transforms
|
|
164
|
+
case 'groupId':
|
|
165
|
+
case 'brand':
|
|
166
|
+
case 'region':
|
|
167
|
+
case 'type':
|
|
168
|
+
case 'slug':
|
|
169
|
+
case 'url':
|
|
170
|
+
case 'name':
|
|
171
|
+
case 'preview':
|
|
172
|
+
case 'state':
|
|
173
|
+
case 'changeSetId':
|
|
174
|
+
case 'snapshot':
|
|
175
|
+
case 'errors':
|
|
176
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
177
|
+
break;
|
|
178
|
+
// snapshot
|
|
179
|
+
case 'snapshotId':
|
|
180
|
+
if ('snapshot' in data && data.snapshot) {
|
|
181
|
+
page.snapshotId = data.snapshot.id;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
// tags
|
|
185
|
+
case 'tags':
|
|
186
|
+
bindProp(prop, prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
187
|
+
break;
|
|
188
|
+
// content
|
|
189
|
+
case 'discover':
|
|
190
|
+
case 'content':
|
|
191
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : {});
|
|
192
|
+
break;
|
|
193
|
+
// links
|
|
194
|
+
case 'files':
|
|
195
|
+
page.files = files;
|
|
196
|
+
break;
|
|
197
|
+
case 'pages':
|
|
198
|
+
page.pages = pages;
|
|
199
|
+
break;
|
|
200
|
+
case 'collections':
|
|
201
|
+
page.collections = collections;
|
|
202
|
+
break;
|
|
203
|
+
// timestamps
|
|
204
|
+
case 'createdOn':
|
|
205
|
+
bindProp('createdAt', prop, () => createdOn);
|
|
206
|
+
break;
|
|
207
|
+
case 'updatedOn':
|
|
208
|
+
bindProp('updatedAt', prop, () => updatedOn);
|
|
209
|
+
break;
|
|
210
|
+
case 'publishedOn':
|
|
211
|
+
case 'publication':
|
|
212
|
+
bindProp(prop, prop, value => value ? parseInt(value) : undefined);
|
|
213
|
+
break;
|
|
214
|
+
// unhandled
|
|
215
|
+
default:
|
|
216
|
+
throw new funnel_core_1.NotImplementedError(`Missing support for transforming page "${prop}" prop`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// return page
|
|
220
|
+
return page;
|
|
221
|
+
}
|
|
222
|
+
PageData.deserialize = deserialize;
|
|
223
|
+
// deserialize ref
|
|
224
|
+
function deserializeRef(data) {
|
|
225
|
+
var _a, _b, _c, _d;
|
|
226
|
+
// transform directly (easier because we know what we're looking for)
|
|
227
|
+
const createdOn = Date.parse(data.createdAt);
|
|
228
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
229
|
+
return Object.assign(Object.assign({}, models_1.StrapiData.deserialize(data)), { type: data.type, tags: JSON.parse((_a = data.tags) !== null && _a !== void 0 ? _a : '[]'), region: data.region, language: (_b = data.lang) !== null && _b !== void 0 ? _b : undefined, groupId: data.groupId, brand: data.brand, slug: (_c = data.slug) !== null && _c !== void 0 ? _c : undefined, url: data.url, name: data.name, state: data.state, changeSetId: (_d = data.changeSetId) !== null && _d !== void 0 ? _d : undefined, errors: data.errors, createdOn,
|
|
230
|
+
updatedOn, publishedOn: data.publishedOn ? parseInt(data.publishedOn) : undefined, publication: data.publication ? parseInt(data.publication) : undefined });
|
|
231
|
+
}
|
|
232
|
+
PageData.deserializeRef = deserializeRef;
|
|
233
|
+
function serialize(page) {
|
|
234
|
+
var _a, _b, _c, _d, _e;
|
|
235
|
+
// serialize base page data
|
|
236
|
+
const base = {
|
|
237
|
+
groupId: page.groupId,
|
|
238
|
+
type: page.type,
|
|
239
|
+
tags: JSON.stringify(page.tags),
|
|
240
|
+
brand: page.brand,
|
|
241
|
+
lang: page.language,
|
|
242
|
+
slug: (_a = page.slug) !== null && _a !== void 0 ? _a : null,
|
|
243
|
+
url: page.url,
|
|
244
|
+
region: page.region,
|
|
245
|
+
name: page.name,
|
|
246
|
+
changeSetId: (_b = page.changeSetId) !== null && _b !== void 0 ? _b : null
|
|
247
|
+
};
|
|
248
|
+
// serialize existing page
|
|
249
|
+
if ('id' in page && page.id !== funnel_core_1.Schema.Page.Id.draft) {
|
|
250
|
+
// grab all refs
|
|
251
|
+
const assets = new Set();
|
|
252
|
+
const pages = new Set();
|
|
253
|
+
const collections = new Set();
|
|
254
|
+
const body = funnel_core_1.ObjectUtils.transform({
|
|
255
|
+
value: {
|
|
256
|
+
discover: page.discover,
|
|
257
|
+
content: page.content
|
|
258
|
+
},
|
|
259
|
+
recurse: ({ value }) => !funnel_core_1.Schema.Asset.filter(value)
|
|
260
|
+
&& !funnel_core_1.Schema.Field.Data.InternalLink.filter(value)
|
|
261
|
+
&& !funnel_core_1.Schema.Field.Data.Collection.Ref.filter(value)
|
|
262
|
+
&& !funnel_core_1.Schema.Field.Data.Page.filter(value),
|
|
263
|
+
transform: ({ value }) => {
|
|
264
|
+
// track assets
|
|
265
|
+
if (funnel_core_1.Schema.Asset.filter(value)) {
|
|
266
|
+
// track file (if it's real)
|
|
267
|
+
const assetId = funnel_core_1.Schema.Asset.getId(value);
|
|
268
|
+
if (assetId) {
|
|
269
|
+
assets.add(assetId);
|
|
270
|
+
}
|
|
271
|
+
// return value (don't transform)
|
|
272
|
+
return value;
|
|
273
|
+
}
|
|
274
|
+
// track page links
|
|
275
|
+
else if (funnel_core_1.Schema.Field.Data.InternalLink.filter(value)) {
|
|
276
|
+
// track page (only if the id's real)
|
|
277
|
+
const pageId = funnel_core_1.Schema.Field.Data.InternalLink.getId(value);
|
|
278
|
+
if (pageId && pageId !== funnel_core_1.Schema.Page.Id.draft) {
|
|
279
|
+
pages.add(pageId);
|
|
280
|
+
}
|
|
281
|
+
// return value (don't transform)
|
|
282
|
+
return value;
|
|
283
|
+
}
|
|
284
|
+
// transform collection refs
|
|
285
|
+
else if (funnel_core_1.Schema.Field.Data.Collection.Ref.filter(value)) {
|
|
286
|
+
// track collection (only if the id's real)
|
|
287
|
+
const collectionId = funnel_core_1.Schema.Field.Data.Collection.Ref.getId(value);
|
|
288
|
+
if (collectionId && collectionId !== funnel_core_1.Schema.Collection.Id.draft) {
|
|
289
|
+
collections.add(collectionId);
|
|
290
|
+
}
|
|
291
|
+
// return value (don't transform)
|
|
292
|
+
return value;
|
|
293
|
+
}
|
|
294
|
+
// transform page refs
|
|
295
|
+
else if (funnel_core_1.Schema.Field.Data.Page.filter(value)) {
|
|
296
|
+
// track page (only if the id's real)
|
|
297
|
+
const pageId = funnel_core_1.Schema.Field.Data.Page.getId(value);
|
|
298
|
+
if (pageId && pageId !== funnel_core_1.Schema.Page.Id.draft) {
|
|
299
|
+
pages.add(pageId);
|
|
300
|
+
}
|
|
301
|
+
// return value (don't transform)
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
// or ignore
|
|
305
|
+
else {
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
// bind update
|
|
311
|
+
return Object.assign(Object.assign(Object.assign({}, base), body), { preview: (_c = page.preview) !== null && _c !== void 0 ? _c : null, assetRefs: { set: Array.from(assets) }, pageRefs: { set: Array.from(pages) }, collectionRefs: { set: Array.from(collections) }, errors: page.errors, state: page.state, publishedOn: (_d = page.publishedOn) === null || _d === void 0 ? void 0 : _d.toString(), publication: page.publication === undefined
|
|
312
|
+
? undefined
|
|
313
|
+
: page.publication < 0
|
|
314
|
+
? null
|
|
315
|
+
: page.publication.toString() });
|
|
316
|
+
}
|
|
317
|
+
// or a new one
|
|
318
|
+
else {
|
|
319
|
+
const seo = funnel_core_1.Schema.Seo;
|
|
320
|
+
const discover = (_e = page.discover) !== null && _e !== void 0 ? _e : {
|
|
321
|
+
seo: {
|
|
322
|
+
type: 'block',
|
|
323
|
+
id: seo.id,
|
|
324
|
+
version: seo.version,
|
|
325
|
+
config: {},
|
|
326
|
+
fields: {
|
|
327
|
+
title: funnel_core_1.Schema.TextField.Value.toData(page.name)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
return Object.assign(Object.assign({}, base), { discover, preview: null, content: {}, assetRefs: { set: [] }, pageRefs: { set: [] }, collectionRefs: { set: [] }, errors: true, state: 'draft' });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
PageData.serialize = serialize;
|
|
335
|
+
})(PageData || (exports.PageData = PageData = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Language, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
export type PageSnapshotData = StrapiData & {
|
|
4
|
+
groupId: Schema.Page.GroupId;
|
|
5
|
+
type: Schema.Page.Type;
|
|
6
|
+
brand: string;
|
|
7
|
+
region: string;
|
|
8
|
+
lang: Language;
|
|
9
|
+
tags: string;
|
|
10
|
+
name: string;
|
|
11
|
+
slug: string | null;
|
|
12
|
+
url: string;
|
|
13
|
+
discover: Schema.Page.Data.Discover;
|
|
14
|
+
preview: Schema.Page.Data.Preview | null;
|
|
15
|
+
content: Schema.Page.Data.Content;
|
|
16
|
+
changeSetId: Schema.ChangeSet.Id;
|
|
17
|
+
};
|
|
18
|
+
export declare namespace PageSnapshotData {
|
|
19
|
+
function deserialize(data: PageSnapshotData): Schema.PageSnapshot;
|
|
20
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageSnapshotData = void 0;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
// extension
|
|
7
|
+
var PageSnapshotData;
|
|
8
|
+
(function (PageSnapshotData) {
|
|
9
|
+
// deserialize (handles all cases safely)
|
|
10
|
+
function deserialize(data) {
|
|
11
|
+
var _a;
|
|
12
|
+
// create output
|
|
13
|
+
const snapshot = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
14
|
+
const createdOn = Date.parse(data.createdAt);
|
|
15
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
16
|
+
// helper
|
|
17
|
+
const bindProp = (prop, target, transform) => {
|
|
18
|
+
if (prop in data) {
|
|
19
|
+
snapshot[target] = transform(data[prop]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
// bind required props to snapshot
|
|
23
|
+
for (const prop of funnel_core_1.Schema.PageSnapshot.props) {
|
|
24
|
+
switch (prop) {
|
|
25
|
+
// handled by base
|
|
26
|
+
case 'id':
|
|
27
|
+
break;
|
|
28
|
+
// language
|
|
29
|
+
case 'language':
|
|
30
|
+
bindProp('lang', prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
31
|
+
break;
|
|
32
|
+
// direct transforms
|
|
33
|
+
case 'groupId':
|
|
34
|
+
case 'brand':
|
|
35
|
+
case 'region':
|
|
36
|
+
case 'type':
|
|
37
|
+
case 'slug':
|
|
38
|
+
case 'url':
|
|
39
|
+
case 'name':
|
|
40
|
+
case 'preview':
|
|
41
|
+
case 'changeSetId':
|
|
42
|
+
snapshot[prop] = (_a = data[prop]) !== null && _a !== void 0 ? _a : undefined;
|
|
43
|
+
break;
|
|
44
|
+
// tags
|
|
45
|
+
case 'tags':
|
|
46
|
+
bindProp(prop, prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
47
|
+
break;
|
|
48
|
+
// content
|
|
49
|
+
case 'discover':
|
|
50
|
+
case 'content':
|
|
51
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : {});
|
|
52
|
+
break;
|
|
53
|
+
// timestamps
|
|
54
|
+
case 'createdOn':
|
|
55
|
+
snapshot.createdOn = createdOn;
|
|
56
|
+
break;
|
|
57
|
+
case 'updatedOn':
|
|
58
|
+
snapshot.updatedOn = updatedOn;
|
|
59
|
+
break;
|
|
60
|
+
// unhandled
|
|
61
|
+
default:
|
|
62
|
+
throw new funnel_core_1.NotImplementedError(`Missing support for transforming PageSnapshot "${prop}" prop`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// return change set
|
|
66
|
+
return snapshot;
|
|
67
|
+
}
|
|
68
|
+
PageSnapshotData.deserialize = deserialize;
|
|
69
|
+
})(PageSnapshotData || (exports.PageSnapshotData = PageSnapshotData = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SiteConfig } from '../../models';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
export type SiteConfigData = StrapiData & {
|
|
4
|
+
brand: string;
|
|
5
|
+
lockdownEditor: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare namespace SiteConfigData {
|
|
8
|
+
function deserialize(siteConfigData: SiteConfigData): SiteConfig.Data;
|
|
9
|
+
type Update = Omit<Partial<SiteConfigData>, StrapiData.Keys>;
|
|
10
|
+
function serialize(data: SiteConfig.Data.AsDraft | SiteConfig.Data.Update): Update;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiteConfigData = void 0;
|
|
4
|
+
// extension
|
|
5
|
+
var SiteConfigData;
|
|
6
|
+
(function (SiteConfigData) {
|
|
7
|
+
function deserialize(siteConfigData) {
|
|
8
|
+
return {
|
|
9
|
+
id: siteConfigData.documentId,
|
|
10
|
+
brand: siteConfigData.brand,
|
|
11
|
+
lockdownEditor: siteConfigData.lockdownEditor
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
SiteConfigData.deserialize = deserialize;
|
|
15
|
+
function serialize(data) {
|
|
16
|
+
// serialize base config data
|
|
17
|
+
return {
|
|
18
|
+
brand: data.brand,
|
|
19
|
+
lockdownEditor: data.lockdownEditor
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
SiteConfigData.serialize = serialize;
|
|
23
|
+
})(SiteConfigData || (exports.SiteConfigData = SiteConfigData = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MimeType, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { StrapiData, StrapiFile } from '../models';
|
|
3
|
+
export type StrapiAssetData = StrapiData & {
|
|
4
|
+
brand?: string;
|
|
5
|
+
type: MimeType.Image | MimeType.Video;
|
|
6
|
+
url: string;
|
|
7
|
+
size: number;
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
tags?: string;
|
|
12
|
+
metadata: Schema.AssetField.LinkedValue.Image.Metadata | Schema.AssetField.LinkedValue.Video.Metadata;
|
|
13
|
+
file?: StrapiFile;
|
|
14
|
+
};
|
|
15
|
+
export declare namespace StrapiAssetData {
|
|
16
|
+
function deserialize(data: StrapiAssetData, strapiUrl: string): Schema.Asset.Linked;
|
|
17
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StrapiAssetData = void 0;
|
|
4
|
+
// extension
|
|
5
|
+
var StrapiAssetData;
|
|
6
|
+
(function (StrapiAssetData) {
|
|
7
|
+
// methods
|
|
8
|
+
function deserialize(data, strapiUrl) {
|
|
9
|
+
// create base asset (works for most types)
|
|
10
|
+
const { id, documentId, url, type, size, name, description, scope, tags, metadata, file } = data;
|
|
11
|
+
// normalize metadata urls
|
|
12
|
+
if ('thumbUrl' in metadata && typeof metadata.thumbUrl === 'string') {
|
|
13
|
+
metadata.thumbUrl = new URL(metadata.thumbUrl, strapiUrl).href;
|
|
14
|
+
}
|
|
15
|
+
// return asset
|
|
16
|
+
return {
|
|
17
|
+
__root: 'asset',
|
|
18
|
+
type: 'asset',
|
|
19
|
+
value: {
|
|
20
|
+
__internal: {
|
|
21
|
+
assetId: id,
|
|
22
|
+
fileId: file === null || file === void 0 ? void 0 : file.id
|
|
23
|
+
},
|
|
24
|
+
id: documentId,
|
|
25
|
+
url: url
|
|
26
|
+
? new URL(url, strapiUrl).href
|
|
27
|
+
: '',
|
|
28
|
+
type: type,
|
|
29
|
+
size,
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
scope: scope,
|
|
33
|
+
tags: JSON.parse(tags !== null && tags !== void 0 ? tags : '[]'),
|
|
34
|
+
metadata
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
StrapiAssetData.deserialize = deserialize;
|
|
39
|
+
})(StrapiAssetData || (exports.StrapiAssetData = StrapiAssetData = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { User } from '../../models';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
import type { RoleData } from './RoleData';
|
|
4
|
+
export type UserData = StrapiData & {
|
|
5
|
+
username: string;
|
|
6
|
+
email: string;
|
|
7
|
+
confirmed: boolean;
|
|
8
|
+
blocked: boolean;
|
|
9
|
+
role: RoleData;
|
|
10
|
+
brands: string;
|
|
11
|
+
};
|
|
12
|
+
export declare namespace UserData {
|
|
13
|
+
type Update = Omit<Partial<UserData>, keyof StrapiData | 'role'> & {
|
|
14
|
+
role?: number;
|
|
15
|
+
};
|
|
16
|
+
function deserialize(data: UserData): User.Data;
|
|
17
|
+
function serialize(data: Omit<Partial<User.Data>, 'id'>, roles: ReadonlyArray<RoleData>): Update;
|
|
18
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserData = void 0;
|
|
4
|
+
// extension
|
|
5
|
+
var UserData;
|
|
6
|
+
(function (UserData) {
|
|
7
|
+
function deserialize(data) {
|
|
8
|
+
var _a;
|
|
9
|
+
return {
|
|
10
|
+
id: data.documentId,
|
|
11
|
+
email: data.email,
|
|
12
|
+
username: data.username,
|
|
13
|
+
blocked: data.blocked,
|
|
14
|
+
role: data.role.type,
|
|
15
|
+
brands: JSON.parse((_a = data.brands) !== null && _a !== void 0 ? _a : '[]')
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
UserData.deserialize = deserialize;
|
|
19
|
+
function serialize(data, roles) {
|
|
20
|
+
const serializedData = {};
|
|
21
|
+
if (data.email !== undefined) {
|
|
22
|
+
serializedData.email = data.email;
|
|
23
|
+
}
|
|
24
|
+
if (data.username !== undefined) {
|
|
25
|
+
serializedData.username = data.username;
|
|
26
|
+
}
|
|
27
|
+
if (data.blocked !== undefined) {
|
|
28
|
+
serializedData.blocked = data.blocked;
|
|
29
|
+
}
|
|
30
|
+
if (data.brands !== undefined) {
|
|
31
|
+
serializedData.brands = JSON.stringify(data.brands);
|
|
32
|
+
}
|
|
33
|
+
if (data.role !== undefined) {
|
|
34
|
+
const roleData = roles.find((role) => role.type === data.role);
|
|
35
|
+
if (roleData) {
|
|
36
|
+
serializedData.role = roleData.id;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return serializedData;
|
|
40
|
+
}
|
|
41
|
+
UserData.serialize = serialize;
|
|
42
|
+
})(UserData || (exports.UserData = UserData = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Upgrade } from '../../models';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
export type VersionData = StrapiData & {
|
|
4
|
+
version: Upgrade.Version;
|
|
5
|
+
state: VersionData.State;
|
|
6
|
+
message: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare namespace VersionData {
|
|
9
|
+
type State = 'upgrading' | 'failed' | 'ready';
|
|
10
|
+
/**
|
|
11
|
+
* Converts a {@link VersionData} array to an {@link Upgrade.Status} model.
|
|
12
|
+
*
|
|
13
|
+
* @param versionsData - an array of `VersionData`, sorted in descending order.
|
|
14
|
+
* @param available - all available versions, sorted in ascending order.
|
|
15
|
+
* @param dbReady - `true` if the underling CMS db is at the correct version
|
|
16
|
+
*/
|
|
17
|
+
function deserialize(versionsData: ReadonlyArray<VersionData>, available: ReadonlyArray<Upgrade.Version>, dbReady: boolean): Upgrade.Status;
|
|
18
|
+
type CreateArgs = {
|
|
19
|
+
version: Upgrade.Version;
|
|
20
|
+
status: Exclude<Upgrade.Status['status'], 'pending'>;
|
|
21
|
+
message?: string;
|
|
22
|
+
};
|
|
23
|
+
function serializeCreate({ version, status, message }: CreateArgs): Omit<VersionData, StrapiData.Keys>;
|
|
24
|
+
type UpdateArgs = Omit<CreateArgs, 'version'>;
|
|
25
|
+
function serializeUpdate({ status, message }: UpdateArgs): Partial<Omit<VersionData, StrapiData.Keys>>;
|
|
26
|
+
}
|