|
1 | 1 | import { StackConfig, SyncStack, SyncType, LivePreviewQuery } from './types'; |
2 | | -import { AxiosInstance } from '@contentstack/core'; |
| 2 | +import { AxiosInstance, getData } from '@contentstack/core'; |
3 | 3 | import { Asset } from './asset'; |
4 | 4 | import { AssetQuery } from './asset-query'; |
5 | 5 | import { ContentType } from './content-type'; |
@@ -78,8 +78,8 @@ export class Stack { |
78 | 78 | * const taxonomy = stack.taxonomy() // For taxonomy query object |
79 | 79 | */ |
80 | 80 | taxonomy(): TaxonomyQuery { |
81 | | - return new TaxonomyQuery(this._client) |
82 | | - }; |
| 81 | + return new TaxonomyQuery(this._client); |
| 82 | + } |
83 | 83 |
|
84 | 84 | /** |
85 | 85 | * @method GlobalField |
@@ -170,20 +170,61 @@ export class Stack { |
170 | 170 | this._client.stackConfig.live_preview = livePreviewParams; |
171 | 171 | } |
172 | 172 |
|
173 | | - if (query.hasOwnProperty('release_id')) { |
174 | | - this._client.defaults.headers['release_id'] = query.release_id; |
| 173 | + if (query.hasOwnProperty("release_id")) { |
| 174 | + this._client.defaults.headers["release_id"] = query.release_id; |
175 | 175 | } else { |
176 | | - delete this._client.defaults.headers['release_id']; |
| 176 | + delete this._client.defaults.headers["release_id"]; |
177 | 177 | } |
178 | 178 |
|
179 | | - if (query.hasOwnProperty('preview_timestamp')) { |
180 | | - this._client.defaults.headers['preview_timestamp'] = query.preview_timestamp; |
| 179 | + if (query.hasOwnProperty("preview_timestamp")) { |
| 180 | + this._client.defaults.headers["preview_timestamp"] = |
| 181 | + query.preview_timestamp; |
181 | 182 | } else { |
182 | | - delete this._client.defaults.headers['preview_timestamp']; |
| 183 | + delete this._client.defaults.headers["preview_timestamp"]; |
183 | 184 | } |
184 | 185 | } |
185 | 186 |
|
186 | 187 | getClient(): any { |
187 | 188 | return this._client; |
188 | 189 | } |
| 190 | + |
| 191 | + async getLastActivities() { |
| 192 | + try { |
| 193 | + const result = await getData(this._client, '/content_types', { |
| 194 | + params: { |
| 195 | + only_last_activity: true, |
| 196 | + environment: this.config.environment, |
| 197 | + }, |
| 198 | + }); |
| 199 | + return result; |
| 200 | + } catch (error) { |
| 201 | + throw new Error("Error fetching last activities"); |
| 202 | + } |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * @method setPort |
| 207 | + * @memberOf Stack |
| 208 | + * @description Sets the port of the host |
| 209 | + * @param {Number} port - Port Number |
| 210 | + * @return {Stack} |
| 211 | + * @instance |
| 212 | + * */ |
| 213 | + setPort(port: number) { |
| 214 | + if (typeof port === "number") this.config.port = port; |
| 215 | + return this; |
| 216 | + } |
| 217 | + |
| 218 | + /** |
| 219 | + * @method setDebug |
| 220 | + * @memberOf Stack |
| 221 | + * @description Sets the debug option |
| 222 | + * @param {Number} debug - Debug value |
| 223 | + * @return {Stack} |
| 224 | + * @instance |
| 225 | + * */ |
| 226 | + setDebug(debug: boolean) { |
| 227 | + if (typeof debug === "boolean") this.config.debug = debug; |
| 228 | + return this; |
| 229 | + } |
189 | 230 | } |
0 commit comments