@nascentdigital/funnel-cms 4.4.4 → 4.4.13

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.
@@ -121,13 +121,6 @@ export declare namespace PageClient {
121
121
  }
122
122
  export {};
123
123
  }
124
- type Update = {
125
- id: Schema.Page.Id;
126
- slug?: string;
127
- publication?: number | null;
128
- errors: boolean;
129
- updates: ReadonlyArray<Schema.Page.Update>;
130
- };
131
124
  namespace GetOverview {
132
125
  type Args = Query.ByBrandAndRegion;
133
126
  type Result = {
@@ -206,8 +199,18 @@ export declare namespace PageClient {
206
199
  type Result = Schema.Page.Data.AsLink;
207
200
  }
208
201
  namespace Update {
209
- type Args = Update;
210
- type Result = Schema.Page.Data;
202
+ type Args = {
203
+ id: Schema.Page.Id;
204
+ slug?: string;
205
+ publication?: number | null;
206
+ errors: boolean;
207
+ updatedOn: number;
208
+ updates: ReadonlyArray<Schema.Page.Update>;
209
+ };
210
+ type Result = {
211
+ updatedOn: number;
212
+ page?: Schema.Page.Data;
213
+ };
211
214
  }
212
215
  namespace Replace {
213
216
  type Args = {
@@ -30,7 +30,7 @@ export declare namespace IStrapiContentClient {
30
30
  method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
31
31
  onError?: Callback<TError>;
32
32
  };
33
- type CustomCommand = 'changeset/query' | 'changeset/commit' | 'changeset/revert' | 'query/pages' | 'query/rank-pages' | 'query/collections' | 'query/collection' | 'publish' | 'unpublish' | 'version';
33
+ type CustomCommand = 'changeset/query' | 'changeset/commit' | 'changeset/revert' | 'page/update' | 'query/pages' | 'query/rank-pages' | 'query/collections' | 'query/collection' | 'publish' | 'unpublish' | 'version';
34
34
  type UnpublishErrorData = Jsonify<{
35
35
  error: true;
36
36
  pageRefs: PageData.Ref[];
@@ -14,7 +14,7 @@ export declare class StrapiPageClient implements PageClient {
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>;
16
16
  touch({ id: pageId, version: status }: PageClient.Touch.Args): Promise<PageClient.Touch.Result>;
17
- update({ id: pageId, slug: pageSlug, publication: pagePublication, errors, updates }: PageClient.Update.Args): Promise<PageClient.Update.Result>;
17
+ update(args: PageClient.Update.Args): Promise<PageClient.Update.Result>;
18
18
  replace({ page, version, skipSync }: PageClient.Replace.Args): Promise<PageClient.Replace.Result>;
19
19
  unpublish(pageId: PageClient.Unpublish.Args): Promise<PageClient.Unpublish.Result>;
20
20
  getDependants({ id: pageId, version }: PageClient.GetDependants.Args): Promise<PageClient.GetDependants.Result>;
@@ -616,8 +616,21 @@ class StrapiPageClient {
616
616
  // return page ref
617
617
  return serialization_1.PageData.deserializeRef(updatedData);
618
618
  }
619
- async update({ id: pageId, slug: pageSlug, publication: pagePublication, errors, updates }) {
619
+ async update(args) {
620
+ // TODO: migrating towards this as the new method for ALL updates in the future
621
+ if (args.updates.length === 1 && args.updates[0].type === 'section.blockName') {
622
+ // publish changeset (transactional)
623
+ const data = await this.provider.customRequest({
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
+ }
620
632
  // resolve current user (or throw)
633
+ const { id: pageId, slug: pageSlug, publication: pagePublication, errors, updates } = args;
621
634
  const { client, users } = this.provider;
622
635
  const strapiUrl = client.baseURL;
623
636
  const user = await users.me();
@@ -671,7 +684,6 @@ class StrapiPageClient {
671
684
  page.changeSetId = changeSet.id;
672
685
  // save page
673
686
  const update = serialization_1.PageData.serialize(page);
674
- console.debug(`[StrapiPageClient/update] sending update`, JSON.stringify(update, undefined, ' '));
675
687
  const { data: updatedData } = await collection.update(page.id, Object.assign(Object.assign({}, update), { state: 'draft' }), {
676
688
  status: 'draft',
677
689
  populate: serialization_1.PageData.Populate.full
@@ -692,7 +704,10 @@ class StrapiPageClient {
692
704
  provider.changeSets.update(changeSet.toData())
693
705
  .catch(console.error);
694
706
  // return page
695
- return page;
707
+ return {
708
+ updatedOn: page.updatedOn,
709
+ page
710
+ };
696
711
  }
697
712
  async replace({ page, version, skipSync = false }) {
698
713
  console.debug(`[StrapiPageClient/replace] replacing page`);
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@nascentdigital/funnel-cms",
3
- "version": "4.4.4",
3
+ "version": "4.4.13",
4
4
  "repository": {
5
- "url": "https://github.com/nascentdigital/funnel.git",
5
+ "url": "git+https://github.com/nascentdigital/funnel.git",
6
6
  "directory": "libs/cms"
7
7
  },
8
+ "publishConfig": {
9
+ "registry": "https://npmjs.org"
10
+ },
8
11
  "main": "dist/index.js",
9
12
  "types": "dist/index.d.ts",
10
13
  "exports": {
@@ -38,5 +41,5 @@
38
41
  "ts-jest": "^29",
39
42
  "type-fest": "^4"
40
43
  },
41
- "gitHead": "debc0f359106c88e8444638236f7ed7a4f77ec5a"
44
+ "gitHead": "af6ff70daf556e824442ce09959ecff07b43c47c"
42
45
  }
@@ -1,23 +0,0 @@
1
- /**
2
- * Provides access to (and management of) {@link Site} related models.
3
- */
4
- export interface SiteClient {
5
- /**
6
- * Fetches the details for a specific Site for a given brand
7
- */
8
- get(args: SiteClient.Get.Args): Promise<SiteClient.Get.Result>;
9
- /**
10
- * Updates an existing site.
11
- */
12
- update(args: SiteClient.Update.Args): Promise<SiteClient.Update.Result>;
13
- }
14
- export declare namespace SiteClient {
15
- namespace Get {
16
- type Args = {};
17
- type Result = {};
18
- }
19
- namespace Get {
20
- type Args = {};
21
- type Result = {};
22
- }
23
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });