@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.
- package/lib/Client/Client.d.ts +1 -0
- package/lib/Client/Client.js +14 -20
- package/package.json +1 -1
package/lib/Client/Client.d.ts
CHANGED
package/lib/Client/Client.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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);
|