@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,57 @@
|
|
|
1
|
+
import { Language, RequiredBy, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
import type { CollectionSnapshotData } from './CollectionSnapshotData';
|
|
4
|
+
import { StrapiAssetData } from './StrapiAssetData';
|
|
5
|
+
export type CollectionData = StrapiData & {
|
|
6
|
+
groupId: Schema.Collection.GroupId;
|
|
7
|
+
type: Schema.Collection.Type;
|
|
8
|
+
brand: string | null;
|
|
9
|
+
lang: Language;
|
|
10
|
+
version: number;
|
|
11
|
+
name: string;
|
|
12
|
+
tags: string;
|
|
13
|
+
fields: Schema.Collection.Data.ForFields;
|
|
14
|
+
assetRefs: StrapiAssetData[];
|
|
15
|
+
collectionRefs: CollectionData.Link[];
|
|
16
|
+
pageRefIds: string | null;
|
|
17
|
+
state: Schema.Collection.State;
|
|
18
|
+
errors: boolean;
|
|
19
|
+
changeSetId: Schema.ChangeSet.Id | null;
|
|
20
|
+
snapshot?: CollectionSnapshotData;
|
|
21
|
+
publishedOn?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare namespace CollectionData {
|
|
24
|
+
type Link = Omit<CollectionData, 'snapshot'>;
|
|
25
|
+
type Ref = Omit<CollectionData, 'fields' | 'assetRefs' | 'collectionRefs' | 'snapshot'>;
|
|
26
|
+
const populate: {
|
|
27
|
+
readonly assetRefs: {
|
|
28
|
+
readonly populate: "*";
|
|
29
|
+
};
|
|
30
|
+
readonly collectionRefs: {
|
|
31
|
+
readonly fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
32
|
+
readonly populate: {
|
|
33
|
+
readonly assetRefs: {
|
|
34
|
+
readonly populate: "*";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly snapshot: {
|
|
39
|
+
readonly populate: "*";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
function withoutLinks<T extends Schema.Collection.Data.Props.All>(props: ReadonlyArray<T>): Exclude<T, Schema.Collection.Data.Props.Links>[];
|
|
43
|
+
function getStrapiFields(props: ReadonlyArray<Schema.Collection.Data.Props.All>): Array<keyof CollectionData>;
|
|
44
|
+
function getStrapiFilter(props: ReadonlyArray<Schema.Collection.Data.Props.All>): Array<keyof CollectionData>;
|
|
45
|
+
type Potential = RequiredBy<Partial<CollectionData>, StrapiData.Keys>;
|
|
46
|
+
function deserialize<TCollection extends Schema.Collection.Data>(data: Potential, strapiUrl: string, props?: ReadonlyArray<Schema.Collection.Data.Props.All>): TCollection;
|
|
47
|
+
function deserializeRef(data: Ref): Schema.Collection.Data.AsRef;
|
|
48
|
+
type Update = Omit<CollectionData, StrapiData.Keys | 'assetRefs' | 'collectionRefs'> & {
|
|
49
|
+
assetRefs?: {
|
|
50
|
+
set: Schema.Asset.Id[];
|
|
51
|
+
};
|
|
52
|
+
collectionRefs?: {
|
|
53
|
+
set: Schema.Collection.Id[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
function serialize(collection: Schema.Collection.Data.AsDraft | Schema.Collection.Data): Update;
|
|
57
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionData = void 0;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const StrapiAssetData_1 = require("./StrapiAssetData");
|
|
7
|
+
// extension
|
|
8
|
+
var CollectionData;
|
|
9
|
+
(function (CollectionData) {
|
|
10
|
+
// constants
|
|
11
|
+
const collectionRefFields = getStrapiFields(funnel_core_1.Schema.Collection.Data.AsLink.props);
|
|
12
|
+
CollectionData.populate = {
|
|
13
|
+
assetRefs: { populate: '*' },
|
|
14
|
+
collectionRefs: {
|
|
15
|
+
fields: collectionRefFields,
|
|
16
|
+
populate: {
|
|
17
|
+
assetRefs: { populate: '*' }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
snapshot: { populate: '*' }
|
|
21
|
+
};
|
|
22
|
+
// strip out any link props (file, collection) from props array
|
|
23
|
+
function withoutLinks(props) {
|
|
24
|
+
return props.filter(prop => !funnel_core_1.Schema.Collection.Data.Props.links.includes(prop));
|
|
25
|
+
}
|
|
26
|
+
CollectionData.withoutLinks = withoutLinks;
|
|
27
|
+
// map props
|
|
28
|
+
function getStrapiFields(props) {
|
|
29
|
+
return props
|
|
30
|
+
.filter(prop => prop !== '__root' && prop !== 'createdOn' && prop !== 'updatedOn' && prop !== 'snapshotId')
|
|
31
|
+
.map(prop => {
|
|
32
|
+
switch (prop) {
|
|
33
|
+
case 'language':
|
|
34
|
+
return 'lang';
|
|
35
|
+
case 'files':
|
|
36
|
+
return 'assetRefs';
|
|
37
|
+
case 'collections':
|
|
38
|
+
return 'collectionRefs';
|
|
39
|
+
case 'pageIds':
|
|
40
|
+
return 'pageRefIds';
|
|
41
|
+
default:
|
|
42
|
+
return prop;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
CollectionData.getStrapiFields = getStrapiFields;
|
|
47
|
+
function getStrapiFilter(props) {
|
|
48
|
+
// build list
|
|
49
|
+
const filters = new Set(['createdAt', 'updatedAt', 'publishedAt']);
|
|
50
|
+
for (const prop of props) {
|
|
51
|
+
switch (prop) {
|
|
52
|
+
// special handling
|
|
53
|
+
case 'language':
|
|
54
|
+
filters.add('lang');
|
|
55
|
+
break;
|
|
56
|
+
case 'pageIds':
|
|
57
|
+
filters.add('pageRefIds');
|
|
58
|
+
break;
|
|
59
|
+
// parity
|
|
60
|
+
case 'groupId':
|
|
61
|
+
case 'type':
|
|
62
|
+
case 'brand':
|
|
63
|
+
case 'version':
|
|
64
|
+
case 'name':
|
|
65
|
+
case 'tags':
|
|
66
|
+
case 'fields':
|
|
67
|
+
case 'state':
|
|
68
|
+
case 'errors':
|
|
69
|
+
case 'changeSetId':
|
|
70
|
+
case 'publishedOn':
|
|
71
|
+
filters.add(prop);
|
|
72
|
+
break;
|
|
73
|
+
// ignore the rest
|
|
74
|
+
default:
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// return filters
|
|
79
|
+
return Array.from(filters);
|
|
80
|
+
}
|
|
81
|
+
CollectionData.getStrapiFilter = getStrapiFilter;
|
|
82
|
+
function deserialize(data, strapiUrl, props = funnel_core_1.Schema.Collection.Data.Props.all) {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
// create output
|
|
85
|
+
const collection = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
86
|
+
const createdOn = Date.parse(data.createdAt);
|
|
87
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
88
|
+
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 => deserialize(collectionRef, strapiUrl, funnel_core_1.Schema.Collection.Data.Props.all));
|
|
90
|
+
// add root if there's any content props
|
|
91
|
+
if (funnel_core_1.Schema.Collection.Data.Props.content.some(prop => props.includes(prop))) {
|
|
92
|
+
collection.__root = 'collection';
|
|
93
|
+
}
|
|
94
|
+
// helper
|
|
95
|
+
const bindProp = (prop, target, transform) => {
|
|
96
|
+
if (prop in data) {
|
|
97
|
+
collection[target] = transform(data[prop]);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
// bind required props to page
|
|
101
|
+
for (const prop of props) {
|
|
102
|
+
switch (prop) {
|
|
103
|
+
// handled by base
|
|
104
|
+
case 'id':
|
|
105
|
+
break;
|
|
106
|
+
// language
|
|
107
|
+
case 'language':
|
|
108
|
+
bindProp('lang', prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
109
|
+
break;
|
|
110
|
+
// direct transforms
|
|
111
|
+
case 'groupId':
|
|
112
|
+
case 'type':
|
|
113
|
+
case 'brand':
|
|
114
|
+
case 'version':
|
|
115
|
+
case 'name':
|
|
116
|
+
case 'state':
|
|
117
|
+
case 'changeSetId':
|
|
118
|
+
case 'snapshot':
|
|
119
|
+
case 'errors':
|
|
120
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
121
|
+
break;
|
|
122
|
+
// snapshot
|
|
123
|
+
case 'snapshotId':
|
|
124
|
+
if ('snapshot' in data && data.snapshot) {
|
|
125
|
+
collection.snapshotId = data.snapshot.id;
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
// tags
|
|
129
|
+
case 'tags':
|
|
130
|
+
bindProp(prop, prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
131
|
+
break;
|
|
132
|
+
// content
|
|
133
|
+
case 'fields':
|
|
134
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : {});
|
|
135
|
+
break;
|
|
136
|
+
// links
|
|
137
|
+
case 'files':
|
|
138
|
+
collection.files = files;
|
|
139
|
+
break;
|
|
140
|
+
case 'collections':
|
|
141
|
+
collection.collections = collections;
|
|
142
|
+
break;
|
|
143
|
+
case 'pageIds':
|
|
144
|
+
bindProp('pageRefIds', prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
145
|
+
break;
|
|
146
|
+
// timestamps
|
|
147
|
+
case 'createdOn':
|
|
148
|
+
bindProp('createdAt', prop, () => createdOn);
|
|
149
|
+
break;
|
|
150
|
+
case 'updatedOn':
|
|
151
|
+
bindProp('updatedAt', prop, value => updatedOn);
|
|
152
|
+
break;
|
|
153
|
+
case 'publishedOn':
|
|
154
|
+
bindProp(prop, prop, value => value ? parseInt(value) : undefined);
|
|
155
|
+
break;
|
|
156
|
+
// unhandled
|
|
157
|
+
default:
|
|
158
|
+
throw new funnel_core_1.NotImplementedError(`Missing support for transforming Collection "${prop}" prop`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// return collection
|
|
162
|
+
return collection;
|
|
163
|
+
}
|
|
164
|
+
CollectionData.deserialize = deserialize;
|
|
165
|
+
// deserialize ref
|
|
166
|
+
function deserializeRef(data) {
|
|
167
|
+
var _a, _b, _c;
|
|
168
|
+
// transform directly (easier because we know what we're looking for)
|
|
169
|
+
const createdOn = Date.parse(data.createdAt);
|
|
170
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
171
|
+
return Object.assign(Object.assign({}, models_1.StrapiData.deserialize(data)), { groupId: data.groupId, type: data.type, tags: JSON.parse((_a = data.tags) !== null && _a !== void 0 ? _a : '[]'), brand: (_b = data.brand) !== null && _b !== void 0 ? _b : undefined, language: (_c = data.lang) !== null && _c !== void 0 ? _c : undefined, version: data.version, name: data.name, state: data.state, errors: data.errors, createdOn,
|
|
172
|
+
updatedOn, publishedOn: data.publishedOn ? parseInt(data.publishedOn) : undefined });
|
|
173
|
+
}
|
|
174
|
+
CollectionData.deserializeRef = deserializeRef;
|
|
175
|
+
function serialize(collection) {
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
// serialize base collection data
|
|
178
|
+
const base = {
|
|
179
|
+
groupId: collection.groupId,
|
|
180
|
+
type: collection.type,
|
|
181
|
+
tags: JSON.stringify(collection.tags),
|
|
182
|
+
brand: (_a = collection.brand) !== null && _a !== void 0 ? _a : null,
|
|
183
|
+
lang: collection.language,
|
|
184
|
+
version: collection.version,
|
|
185
|
+
name: collection.name,
|
|
186
|
+
changeSetId: (_b = collection.changeSetId) !== null && _b !== void 0 ? _b : null
|
|
187
|
+
};
|
|
188
|
+
// serialize existing collection
|
|
189
|
+
if ('id' in collection && collection.id !== funnel_core_1.Schema.Collection.Id.draft) {
|
|
190
|
+
// grab all refs
|
|
191
|
+
const assets = new Set();
|
|
192
|
+
const pages = new Set();
|
|
193
|
+
const collections = new Set();
|
|
194
|
+
const body = funnel_core_1.ObjectUtils.transform({
|
|
195
|
+
value: {
|
|
196
|
+
fields: collection.fields
|
|
197
|
+
},
|
|
198
|
+
recurse: ({ value }) => !funnel_core_1.Schema.Asset.filter(value)
|
|
199
|
+
&& !funnel_core_1.Schema.Field.Data.InternalLink.filter(value)
|
|
200
|
+
&& !funnel_core_1.Schema.Field.Data.Collection.Ref.filter(value)
|
|
201
|
+
&& !funnel_core_1.Schema.Field.Data.Page.filter(value),
|
|
202
|
+
transform: ({ value }) => {
|
|
203
|
+
// transform files
|
|
204
|
+
if (funnel_core_1.Schema.Asset.filter(value)) {
|
|
205
|
+
// track file (if it's real)
|
|
206
|
+
const assetId = funnel_core_1.Schema.Asset.getId(value);
|
|
207
|
+
if (assetId) {
|
|
208
|
+
assets.add(assetId);
|
|
209
|
+
}
|
|
210
|
+
// return value (don't transform)
|
|
211
|
+
return value;
|
|
212
|
+
}
|
|
213
|
+
// track page links
|
|
214
|
+
else if (funnel_core_1.Schema.Field.Data.InternalLink.filter(value)) {
|
|
215
|
+
// track page (only if the id's real)
|
|
216
|
+
const pageId = funnel_core_1.Schema.Field.Data.InternalLink.getId(value);
|
|
217
|
+
if (pageId && pageId !== funnel_core_1.Schema.Page.Id.draft) {
|
|
218
|
+
pages.add(pageId);
|
|
219
|
+
}
|
|
220
|
+
// return value (don't transform)
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
// transform collections
|
|
224
|
+
else if (funnel_core_1.Schema.Field.Data.Collection.Ref.filter(value)) {
|
|
225
|
+
// track collection (only if the id's real)
|
|
226
|
+
const collectionId = funnel_core_1.Schema.Field.Data.Collection.Ref.getId(value);
|
|
227
|
+
if (collectionId && collectionId !== funnel_core_1.Schema.Collection.Id.draft) {
|
|
228
|
+
collections.add(collectionId);
|
|
229
|
+
}
|
|
230
|
+
// return value (don't transform)
|
|
231
|
+
return value;
|
|
232
|
+
}
|
|
233
|
+
// transform pages
|
|
234
|
+
else if (funnel_core_1.Schema.Field.Data.Page.filter(value)) {
|
|
235
|
+
// track page (only if the id's real)
|
|
236
|
+
const pageId = funnel_core_1.Schema.Field.Data.Page.getId(value);
|
|
237
|
+
if (pageId && pageId !== funnel_core_1.Schema.Page.Id.draft) {
|
|
238
|
+
pages.add(pageId);
|
|
239
|
+
}
|
|
240
|
+
// return value (don't transform)
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
// or ignore
|
|
244
|
+
else {
|
|
245
|
+
return value;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
// bind update
|
|
250
|
+
return Object.assign(Object.assign(Object.assign({}, base), body), { assetRefs: { set: Array.from(assets) }, collectionRefs: { set: Array.from(collections) }, pageRefIds: JSON.stringify(Array.from(pages)), errors: collection.errors, state: collection.state, publishedOn: (_c = collection.publishedOn) === null || _c === void 0 ? void 0 : _c.toString() });
|
|
251
|
+
}
|
|
252
|
+
// or a new one
|
|
253
|
+
else {
|
|
254
|
+
return Object.assign(Object.assign({}, base), { fields: {}, errors: true, state: 'draft', changeSetId: null, pageRefIds: null });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
CollectionData.serialize = serialize;
|
|
258
|
+
})(CollectionData || (exports.CollectionData = CollectionData = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Language, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
export type CollectionSnapshotData = StrapiData & {
|
|
4
|
+
groupId: Schema.Collection.GroupId;
|
|
5
|
+
type: Schema.Collection.Type;
|
|
6
|
+
brand: string | null;
|
|
7
|
+
lang: Language;
|
|
8
|
+
version: number;
|
|
9
|
+
name: string;
|
|
10
|
+
tags: string;
|
|
11
|
+
fields: Schema.Collection.Data.ForFields;
|
|
12
|
+
changeSetId: Schema.ChangeSet.Id;
|
|
13
|
+
};
|
|
14
|
+
export declare namespace CollectionSnapshotData {
|
|
15
|
+
function deserialize(data: CollectionSnapshotData): Schema.CollectionSnapshot;
|
|
16
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionSnapshotData = void 0;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
// extension
|
|
7
|
+
// extension
|
|
8
|
+
var CollectionSnapshotData;
|
|
9
|
+
(function (CollectionSnapshotData) {
|
|
10
|
+
// deserialize (handles all cases safely)
|
|
11
|
+
function deserialize(data) {
|
|
12
|
+
var _a;
|
|
13
|
+
// create output
|
|
14
|
+
const snapshot = Object.assign({}, models_1.StrapiData.deserialize(data));
|
|
15
|
+
const createdOn = Date.parse(data.createdAt);
|
|
16
|
+
const updatedOn = data.updatedAt ? Date.parse(data.updatedAt) : createdOn;
|
|
17
|
+
// helper
|
|
18
|
+
const bindProp = (prop, target, transform) => {
|
|
19
|
+
if (prop in data) {
|
|
20
|
+
snapshot[target] = transform(data[prop]);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// bind required props to changeset
|
|
24
|
+
for (const prop of funnel_core_1.Schema.CollectionSnapshot.props) {
|
|
25
|
+
switch (prop) {
|
|
26
|
+
// handled by base
|
|
27
|
+
case 'id':
|
|
28
|
+
break;
|
|
29
|
+
// language
|
|
30
|
+
case 'language':
|
|
31
|
+
bindProp('lang', prop, value => value !== null && value !== void 0 ? value : undefined);
|
|
32
|
+
break;
|
|
33
|
+
// direct transforms
|
|
34
|
+
case 'groupId':
|
|
35
|
+
case 'type':
|
|
36
|
+
case 'brand':
|
|
37
|
+
case 'version':
|
|
38
|
+
case 'name':
|
|
39
|
+
case 'changeSetId':
|
|
40
|
+
snapshot[prop] = (_a = data[prop]) !== null && _a !== void 0 ? _a : undefined;
|
|
41
|
+
break;
|
|
42
|
+
// tags
|
|
43
|
+
case 'tags':
|
|
44
|
+
bindProp(prop, prop, value => JSON.parse(value !== null && value !== void 0 ? value : '[]'));
|
|
45
|
+
break;
|
|
46
|
+
// content
|
|
47
|
+
case 'fields':
|
|
48
|
+
bindProp(prop, prop, value => value !== null && value !== void 0 ? value : {});
|
|
49
|
+
break;
|
|
50
|
+
// timestamps
|
|
51
|
+
case 'createdOn':
|
|
52
|
+
snapshot.createdOn = createdOn;
|
|
53
|
+
break;
|
|
54
|
+
case 'updatedOn':
|
|
55
|
+
snapshot.updatedOn = updatedOn;
|
|
56
|
+
break;
|
|
57
|
+
// unhandled
|
|
58
|
+
default:
|
|
59
|
+
throw new funnel_core_1.NotImplementedError(`Missing support for transforming CollectionSnapshot "${prop}" prop`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// return change set
|
|
63
|
+
return snapshot;
|
|
64
|
+
}
|
|
65
|
+
CollectionSnapshotData.deserialize = deserialize;
|
|
66
|
+
})(CollectionSnapshotData || (exports.CollectionSnapshotData = CollectionSnapshotData = {}));
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Language, RequiredBy, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { StrapiData } from '../models';
|
|
3
|
+
import { CollectionData } from './CollectionData';
|
|
4
|
+
import { StrapiAssetData } from './StrapiAssetData';
|
|
5
|
+
import type { PageSnapshotData } from './PageSnapshotData';
|
|
6
|
+
export type PageData = StrapiData & {
|
|
7
|
+
groupId: Schema.Page.GroupId;
|
|
8
|
+
type: Schema.Page.Type;
|
|
9
|
+
brand: string;
|
|
10
|
+
region: string;
|
|
11
|
+
lang: Language;
|
|
12
|
+
tags: string;
|
|
13
|
+
name: string;
|
|
14
|
+
slug: string | null;
|
|
15
|
+
url: string;
|
|
16
|
+
discover: Schema.Page.Data.Discover;
|
|
17
|
+
preview: Schema.Page.Data.Preview | null;
|
|
18
|
+
content: Schema.Page.Data.Content;
|
|
19
|
+
assetRefs: StrapiAssetData[];
|
|
20
|
+
pageRefs: PageData.Preview[];
|
|
21
|
+
collectionRefs: CollectionData[];
|
|
22
|
+
state: Schema.Page.State;
|
|
23
|
+
errors: boolean;
|
|
24
|
+
changeSetId: Schema.ChangeSet.Id | null;
|
|
25
|
+
snapshot?: PageSnapshotData;
|
|
26
|
+
publishedOn?: string;
|
|
27
|
+
publication?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare namespace PageData {
|
|
30
|
+
type Ref = Omit<PageData, 'discover' | 'preview' | 'content' | 'assetRefs' | 'pageRefs' | 'collectionRefs' | 'snapshot'>;
|
|
31
|
+
type Preview = Omit<PageData, 'discover' | 'content' | 'snapshot'>;
|
|
32
|
+
namespace Populate {
|
|
33
|
+
const full: {
|
|
34
|
+
assetRefs: {
|
|
35
|
+
populate: string;
|
|
36
|
+
};
|
|
37
|
+
pageRefs: {
|
|
38
|
+
fields: ("content" | "brand" | "preview" | "type" | "tags" | "name" | "url" | "groupId" | "publishedOn" | "errors" | "state" | "changeSetId" | "snapshot" | "slug" | "region" | "discover" | "publication" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefs")[];
|
|
39
|
+
populate: {
|
|
40
|
+
assetRefs: {
|
|
41
|
+
populate: string;
|
|
42
|
+
};
|
|
43
|
+
pageRefs: {
|
|
44
|
+
fields: ("content" | "brand" | "preview" | "type" | "tags" | "name" | "url" | "groupId" | "publishedOn" | "errors" | "state" | "changeSetId" | "snapshot" | "slug" | "region" | "discover" | "publication" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefs")[];
|
|
45
|
+
populate: string;
|
|
46
|
+
};
|
|
47
|
+
collectionRefs: {
|
|
48
|
+
fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
49
|
+
populate: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
collectionRefs: {
|
|
54
|
+
readonly fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
55
|
+
readonly populate: {
|
|
56
|
+
readonly assetRefs: {
|
|
57
|
+
readonly populate: "*";
|
|
58
|
+
};
|
|
59
|
+
readonly collectionRefs: {
|
|
60
|
+
readonly fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
61
|
+
readonly populate: {
|
|
62
|
+
readonly assetRefs: {
|
|
63
|
+
readonly populate: "*";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
snapshot: {
|
|
70
|
+
populate: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const preview: {
|
|
74
|
+
assetRefs: {
|
|
75
|
+
populate: string;
|
|
76
|
+
};
|
|
77
|
+
pageRefs: {
|
|
78
|
+
fields: ("content" | "brand" | "preview" | "type" | "tags" | "name" | "url" | "groupId" | "publishedOn" | "errors" | "state" | "changeSetId" | "snapshot" | "slug" | "region" | "discover" | "publication" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefs")[];
|
|
79
|
+
populate: {
|
|
80
|
+
assetRefs: {
|
|
81
|
+
populate: string;
|
|
82
|
+
};
|
|
83
|
+
pageRefs: {
|
|
84
|
+
fields: readonly Schema.Page.Data.AsRef.Prop[];
|
|
85
|
+
};
|
|
86
|
+
collectionRefs: {
|
|
87
|
+
fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
collectionRefs: {
|
|
92
|
+
readonly fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
93
|
+
readonly populate: {
|
|
94
|
+
readonly assetRefs: {
|
|
95
|
+
readonly populate: "*";
|
|
96
|
+
};
|
|
97
|
+
readonly collectionRefs: {
|
|
98
|
+
readonly fields: ("brand" | "type" | "tags" | "name" | "groupId" | "publishedOn" | "errors" | "version" | "fields" | "state" | "changeSetId" | "snapshot" | keyof StrapiData | "lang" | "assetRefs" | "collectionRefs" | "pageRefIds")[];
|
|
99
|
+
readonly populate: {
|
|
100
|
+
readonly assetRefs: {
|
|
101
|
+
readonly populate: "*";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function getStrapiFields(props: ReadonlyArray<Schema.Page.Data.Props.All>): Array<keyof PageData>;
|
|
110
|
+
function getStrapiFilter(props: ReadonlyArray<Schema.Page.Data.Props.All>): Array<keyof PageData>;
|
|
111
|
+
type Potential = RequiredBy<Partial<PageData>, StrapiData.Keys>;
|
|
112
|
+
function deserialize<TPage extends Schema.Page.Data>(data: Potential, strapiUrl: string, props?: ReadonlyArray<Schema.Page.Data.Props.All>): TPage;
|
|
113
|
+
function deserializeRef(data: Ref): Schema.Page.Data.AsLink;
|
|
114
|
+
type Update = Omit<PageData, StrapiData.Keys | 'assetRefs' | 'pageRefs' | 'collectionRefs'> & {
|
|
115
|
+
assetRefs?: {
|
|
116
|
+
set: Schema.Asset.Id[];
|
|
117
|
+
};
|
|
118
|
+
pageRefs?: {
|
|
119
|
+
set: Schema.Page.Id[];
|
|
120
|
+
};
|
|
121
|
+
collectionRefs?: {
|
|
122
|
+
set: Schema.Collection.Id[];
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
function serialize(page: Schema.Page.Data.AsDraft | Schema.Page.Data): Update;
|
|
126
|
+
}
|