@nascentdigital/funnel-cms 4.4.13 → 4.4.14
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/PageClient.d.ts
CHANGED
|
@@ -617,97 +617,11 @@ class StrapiPageClient {
|
|
|
617
617
|
return serialization_1.PageData.deserializeRef(updatedData);
|
|
618
618
|
}
|
|
619
619
|
async update(args) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
command: 'page/update',
|
|
625
|
-
method: 'POST',
|
|
626
|
-
data: JSON.stringify(args)
|
|
627
|
-
});
|
|
628
|
-
console.debug('[StrapiPageClient/update] custom update result: ', data);
|
|
629
|
-
// stop processing
|
|
630
|
-
return data;
|
|
631
|
-
}
|
|
632
|
-
// resolve current user (or throw)
|
|
633
|
-
const { id: pageId, slug: pageSlug, publication: pagePublication, errors, updates } = args;
|
|
634
|
-
const { client, users } = this.provider;
|
|
635
|
-
const strapiUrl = client.baseURL;
|
|
636
|
-
const user = await users.me();
|
|
637
|
-
if (!user) {
|
|
638
|
-
throw new funnel_core_1.NotAuthenticatedError();
|
|
639
|
-
}
|
|
640
|
-
// get latest version of page
|
|
641
|
-
const collection = client.collection('pages');
|
|
642
|
-
const resultProps = funnel_core_1.Schema.Page.Data.Props.all;
|
|
643
|
-
const { data: currentData } = await collection.findOne(pageId, {
|
|
644
|
-
status: 'draft',
|
|
645
|
-
populate: serialization_1.PageData.Populate.full
|
|
646
|
-
});
|
|
647
|
-
// TODO: validate page is able to be updated (e.g. not archived, etc.)
|
|
648
|
-
// throw if page doesn't exist
|
|
649
|
-
if (!currentData) {
|
|
650
|
-
throw new funnel_core_1.NotFoundError();
|
|
651
|
-
}
|
|
652
|
-
// deserialize page (we'll be updating this version)
|
|
653
|
-
let page = serialization_1.PageData.deserialize(currentData, strapiUrl, resultProps);
|
|
654
|
-
// update slug
|
|
655
|
-
if (pageSlug && page.slug) {
|
|
656
|
-
console.debug(`[StrapiPageClient/update] updating page slug from "${page.slug}" to ${pageSlug}`);
|
|
657
|
-
// validate slug before updating
|
|
658
|
-
const validateSlugResult = await this.validateSlug({
|
|
659
|
-
brand: page.brand,
|
|
660
|
-
type: page.type,
|
|
661
|
-
region: page.region,
|
|
662
|
-
groupId: page.groupId,
|
|
663
|
-
slug: pageSlug
|
|
664
|
-
});
|
|
665
|
-
if (validateSlugResult.status !== 'available') {
|
|
666
|
-
throw new errors_1.SlugValidationError({ slug: pageSlug, reason: validateSlugResult });
|
|
667
|
-
}
|
|
668
|
-
page.slug = pageSlug;
|
|
669
|
-
}
|
|
670
|
-
// update publication
|
|
671
|
-
if (pagePublication !== undefined) {
|
|
672
|
-
page.publication = pagePublication !== null && pagePublication !== void 0 ? pagePublication : -1;
|
|
673
|
-
}
|
|
674
|
-
// set errors
|
|
675
|
-
page.errors = errors;
|
|
676
|
-
console.debug(`[StrapiPageClient/update] applying ${updates.length} page updates`);
|
|
677
|
-
// merge changes (the original page will have changed)
|
|
678
|
-
const model = funnel_core_1.Schema.PageModel.from(page);
|
|
679
|
-
model.update(updates);
|
|
680
|
-
console.debug(`[StrapiPageClient/update] saving updated page`);
|
|
681
|
-
// resolve change set (rebind)
|
|
682
|
-
const { provider } = this;
|
|
683
|
-
const changeSet = await provider.changeSets.resolve({ id: page.changeSetId, fallbackToGlobal: true });
|
|
684
|
-
page.changeSetId = changeSet.id;
|
|
685
|
-
// save page
|
|
686
|
-
const update = serialization_1.PageData.serialize(page);
|
|
687
|
-
const { data: updatedData } = await collection.update(page.id, Object.assign(Object.assign({}, update), { state: 'draft' }), {
|
|
688
|
-
status: 'draft',
|
|
689
|
-
populate: serialization_1.PageData.Populate.full
|
|
690
|
-
});
|
|
691
|
-
page = serialization_1.PageData.deserialize(updatedData, strapiUrl, resultProps);
|
|
692
|
-
// update changeset
|
|
693
|
-
changeSet.addPageChange(user.id, {
|
|
694
|
-
__type: 'page',
|
|
695
|
-
id: page.id,
|
|
696
|
-
name: page.name,
|
|
697
|
-
schema: page.type,
|
|
698
|
-
region: page.region,
|
|
699
|
-
language: page.language,
|
|
700
|
-
slug: page.slug,
|
|
701
|
-
type: page.publishedOn ? 'update' : 'create',
|
|
702
|
-
errors: page.errors
|
|
620
|
+
return this.provider.customRequest({
|
|
621
|
+
command: 'page/update',
|
|
622
|
+
method: 'POST',
|
|
623
|
+
data: JSON.stringify(args)
|
|
703
624
|
});
|
|
704
|
-
provider.changeSets.update(changeSet.toData())
|
|
705
|
-
.catch(console.error);
|
|
706
|
-
// return page
|
|
707
|
-
return {
|
|
708
|
-
updatedOn: page.updatedOn,
|
|
709
|
-
page
|
|
710
|
-
};
|
|
711
625
|
}
|
|
712
626
|
async replace({ page, version, skipSync = false }) {
|
|
713
627
|
console.debug(`[StrapiPageClient/replace] replacing page`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-cms",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/cms"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"ts-jest": "^29",
|
|
42
42
|
"type-fest": "^4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "242a9e0979c03d4037eb2462c5b01b2a095e8e8f"
|
|
45
45
|
}
|