@cntrl-site/sdk 1.27.1 → 1.27.2

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.
@@ -18,6 +18,7 @@ export declare class Client {
18
18
  getHostname(): string;
19
19
  private fetchProject;
20
20
  private fetchArticle;
21
+ private request;
21
22
  private findArticleIdByPageSlug;
22
23
  }
23
24
  interface FetchImplResponse {
@@ -90,11 +90,7 @@ class Client {
90
90
  return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
91
91
  const { username: projectId, password: apiKey, origin } = this.url;
92
92
  const url = new url_1.URL(`/projects/${projectId}/custom-components?buildMode=${buildMode}`, origin);
93
- const response = yield this.fetchImpl(url.href, {
94
- headers: {
95
- Authorization: `Bearer ${apiKey}`
96
- }
97
- });
93
+ const response = yield this.request(url.href, apiKey);
98
94
  if (!response.ok) {
99
95
  throw new Error(`Failed to fetch custom components for project #${projectId}: ${response.statusText}`);
100
96
  }
@@ -105,11 +101,7 @@ class Client {
105
101
  return __awaiter(this, arguments, void 0, function* (componentId, buildMode = 'default') {
106
102
  const { username: projectId, password: apiKey, origin } = this.url;
107
103
  const url = new url_1.URL(`/projects/${projectId}/custom-components/${componentId}/bundle.js?buildMode=${buildMode}`, origin);
108
- const response = yield this.fetchImpl(url.href, {
109
- headers: {
110
- Authorization: `Bearer ${apiKey}`
111
- }
112
- });
104
+ const response = yield this.request(url.href, apiKey);
113
105
  if (!response.ok) {
114
106
  throw new Error(`Failed to fetch bundle for custom component #${componentId}: ${response.statusText}`);
115
107
  }
@@ -123,11 +115,7 @@ class Client {
123
115
  return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
124
116
  const { username: projectId, password: apiKey, origin } = this.url;
125
117
  const url = new url_1.URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
126
- const response = yield this.fetchImpl(url.href, {
127
- headers: {
128
- Authorization: `Bearer ${apiKey}`
129
- }
130
- });
118
+ const response = yield this.request(url.href, apiKey);
131
119
  if (!response.ok) {
132
120
  throw new Error(`Failed to fetch project with id #${projectId}: ${response.statusText}`);
133
121
  }
@@ -140,11 +128,7 @@ class Client {
140
128
  return __awaiter(this, arguments, void 0, function* (articleId, buildMode = 'default') {
141
129
  const { username: projectId, password: apiKey, origin } = this.url;
142
130
  const url = new url_1.URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
143
- const response = yield this.fetchImpl(url.href, {
144
- headers: {
145
- Authorization: `Bearer ${apiKey}`
146
- }
147
- });
131
+ const response = yield this.request(url.href, apiKey);
148
132
  if (!response.ok) {
149
133
  throw new Error(`Failed to fetch article with id #${articleId}: ${response.statusText}`);
150
134
  }
@@ -154,6 +138,16 @@ class Client {
154
138
  return { article, keyframes };
155
139
  });
156
140
  }
141
+ request(url, apiKey) {
142
+ const init = {
143
+ compress: false,
144
+ headers: {
145
+ Authorization: `Bearer ${apiKey}`,
146
+ 'Accept-Encoding': 'identity'
147
+ }
148
+ };
149
+ return this.fetchImpl(url, init);
150
+ }
157
151
  findArticleIdByPageSlug(slug, pages) {
158
152
  const { username: projectId } = this.url;
159
153
  const page = pages.find((page) => page.slug === slug);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.27.1",
3
+ "version": "1.27.2",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",