1 | const _excluded = ["installationId"];
|
2 | function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3 | function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4 | function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
5 | function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
6 | function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7 | function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
8 | function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
9 | import { createRequestConfig } from 'contentful-sdk-core';
|
10 | import entities from './entities';
|
11 | import { wrapReleaseAction, wrapReleaseActionCollection } from './entities/release-action';
|
12 | import { wrapRelease, wrapReleaseCollection } from './entities/release';
|
13 | import { wrapTag, wrapTagCollection } from './entities/tag';
|
14 | import { wrapUIConfig } from './entities/ui-config';
|
15 | import { wrapUserUIConfig } from './entities/user-ui-config';
|
16 | import { wrapEnvironmentTemplateInstallationCollection } from './entities/environment-template-installation';
|
17 |
|
18 | /**
|
19 | * @private
|
20 | */
|
21 |
|
22 | /**
|
23 | * Creates API object with methods to access the Environment API
|
24 | * @param {ContentfulEnvironmentAPI} makeRequest - function to make requests via an adapter
|
25 | * @return {ContentfulSpaceAPI}
|
26 | * @private
|
27 | */
|
28 | export default function createEnvironmentApi(makeRequest) {
|
29 | const {
|
30 | wrapEnvironment
|
31 | } = entities.environment;
|
32 | const {
|
33 | wrapContentType,
|
34 | wrapContentTypeCollection
|
35 | } = entities.contentType;
|
36 | const {
|
37 | wrapEntry,
|
38 | wrapEntryCollection
|
39 | } = entities.entry;
|
40 | const {
|
41 | wrapAsset,
|
42 | wrapAssetCollection
|
43 | } = entities.asset;
|
44 | const {
|
45 | wrapAssetKey
|
46 | } = entities.assetKey;
|
47 | const {
|
48 | wrapLocale,
|
49 | wrapLocaleCollection
|
50 | } = entities.locale;
|
51 | const {
|
52 | wrapSnapshotCollection
|
53 | } = entities.snapshot;
|
54 | const {
|
55 | wrapEditorInterface,
|
56 | wrapEditorInterfaceCollection
|
57 | } = entities.editorInterface;
|
58 | const {
|
59 | wrapUpload
|
60 | } = entities.upload;
|
61 | const {
|
62 | wrapExtension,
|
63 | wrapExtensionCollection
|
64 | } = entities.extension;
|
65 | const {
|
66 | wrapAppInstallation,
|
67 | wrapAppInstallationCollection
|
68 | } = entities.appInstallation;
|
69 | const {
|
70 | wrapAppSignedRequest
|
71 | } = entities.appSignedRequest;
|
72 | const {
|
73 | wrapAppActionCall
|
74 | } = entities.appActionCall;
|
75 | const {
|
76 | wrapBulkAction
|
77 | } = entities.bulkAction;
|
78 | const {
|
79 | wrapAppAccessToken
|
80 | } = entities.appAccessToken;
|
81 | const {
|
82 | wrapResourceTypesForEnvironmentCollection
|
83 | } = entities.resourceType;
|
84 | const {
|
85 | wrapResourceCollection
|
86 | } = entities.resource;
|
87 | return {
|
88 | /**
|
89 | * Deletes the environment
|
90 | * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
|
91 | * @example ```javascript
|
92 | * const contentful = require('contentful-management')
|
93 | *
|
94 | * const client = contentful.createClient({
|
95 | * accessToken: '<content_management_api_key>'
|
96 | * })
|
97 | *
|
98 | * client.getSpace('<space_id>')
|
99 | * .then((space) => space.getEnvironment('<environment-id>'))
|
100 | * .then((environment) => environment.delete())
|
101 | * .then(() => console.log('Environment deleted.'))
|
102 | * .catch(console.error)
|
103 | * ```
|
104 | */
|
105 | delete: function deleteEnvironment() {
|
106 | const raw = this.toPlainObject();
|
107 | return makeRequest({
|
108 | entityType: 'Environment',
|
109 | action: 'delete',
|
110 | params: {
|
111 | spaceId: raw.sys.space.sys.id,
|
112 | environmentId: raw.sys.id
|
113 | }
|
114 | }).then(() => {
|
115 | // noop
|
116 | });
|
117 | },
|
118 | /**
|
119 | * Updates the environment
|
120 | * @return Promise for the updated environment.
|
121 | * @example ```javascript
|
122 | * const contentful = require('contentful-management')
|
123 | *
|
124 | * const client = contentful.createClient({
|
125 | * accessToken: '<content_management_api_key>'
|
126 | * })
|
127 | *
|
128 | * client.getSpace('<space_id>')
|
129 | * .then((space) => space.getEnvironment('<environment-id>'))
|
130 | * .then((environment) => {
|
131 | * environment.name = 'New name'
|
132 | * return environment.update()
|
133 | * })
|
134 | * .then((environment) => console.log(`Environment ${environment.sys.id} renamed.`)
|
135 | * .catch(console.error)
|
136 | * ```
|
137 | */
|
138 | update: function updateEnvironment() {
|
139 | const raw = this.toPlainObject();
|
140 | return makeRequest({
|
141 | entityType: 'Environment',
|
142 | action: 'update',
|
143 | params: {
|
144 | spaceId: raw.sys.space.sys.id,
|
145 | environmentId: raw.sys.id
|
146 | },
|
147 | payload: raw
|
148 | }).then(data => wrapEnvironment(makeRequest, data));
|
149 | },
|
150 | /**
|
151 | * Creates SDK Entry object (locally) from entry data
|
152 | * @param entryData - Entry Data
|
153 | * @return Entry
|
154 | * @example ```javascript
|
155 | * environment.getEntry('entryId').then(entry => {
|
156 | *
|
157 | * // Build a plainObject in order to make it usable for React (saving in state or redux)
|
158 | * const plainObject = entry.toPlainObject();
|
159 | *
|
160 | * // The entry is being updated in some way as plainObject:
|
161 | * const updatedPlainObject = {
|
162 | * ...plainObject,
|
163 | * fields: {
|
164 | * ...plainObject.fields,
|
165 | * title: {
|
166 | * 'en-US': 'updatedTitle'
|
167 | * }
|
168 | * }
|
169 | * };
|
170 | *
|
171 | * // Rebuild an sdk object out of the updated plainObject:
|
172 | * const entryWithMethodsAgain = environment.getEntryFromData(updatedPlainObject);
|
173 | *
|
174 | * // Update with help of the sdk method:
|
175 | * entryWithMethodsAgain.update();
|
176 | *
|
177 | * });
|
178 | * ```
|
179 | **/
|
180 | getEntryFromData(entryData) {
|
181 | return wrapEntry(makeRequest, entryData);
|
182 | },
|
183 | /**
|
184 | * Creates SDK Asset object (locally) from entry data
|
185 | * @param assetData - Asset ID
|
186 | * @return Asset
|
187 | * @example ```javascript
|
188 | * environment.getAsset('asset_id').then(asset => {
|
189 | *
|
190 | * // Build a plainObject in order to make it usable for React (saving in state or redux)
|
191 | * const plainObject = asset.toPlainObject();
|
192 | *
|
193 | * // The asset is being updated in some way as plainObject:
|
194 | * const updatedPlainObject = {
|
195 | * ...plainObject,
|
196 | * fields: {
|
197 | * ...plainObject.fields,
|
198 | * title: {
|
199 | * 'en-US': 'updatedTitle'
|
200 | * }
|
201 | * }
|
202 | * };
|
203 | *
|
204 | * // Rebuild an sdk object out of the updated plainObject:
|
205 | * const assetWithMethodsAgain = environment.getAssetFromData(updatedPlainObject);
|
206 | *
|
207 | * // Update with help of the sdk method:
|
208 | * assetWithMethodsAgain.update();
|
209 | *
|
210 | * });
|
211 | * ```
|
212 | */
|
213 | getAssetFromData(assetData) {
|
214 | return wrapAsset(makeRequest, assetData);
|
215 | },
|
216 | /**
|
217 | *
|
218 | * @description Get a BulkAction by ID.
|
219 | * See: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/bulk-actions/bulk-action
|
220 | * @param bulkActionId - ID of the BulkAction to fetch
|
221 | * @returns - Promise with the BulkAction
|
222 | *
|
223 | * @example ```javascript
|
224 | * const contentful = require('contentful-management')
|
225 | *
|
226 | * const client = contentful.createClient({
|
227 | * accessToken: '<content_management_api_key>'
|
228 | * })
|
229 | *
|
230 | * client.getSpace('<space_id>')
|
231 | * .then((space) => space.getEnvironment('<environment_id>'))
|
232 | * .then((environment) => environment.getBulkAction('<bulk_action_id>'))
|
233 | * .then((bulkAction) => console.log(bulkAction))
|
234 | * ```
|
235 | */
|
236 | getBulkAction(bulkActionId) {
|
237 | const raw = this.toPlainObject();
|
238 | return makeRequest({
|
239 | entityType: 'BulkAction',
|
240 | action: 'get',
|
241 | params: {
|
242 | spaceId: raw.sys.space.sys.id,
|
243 | environmentId: raw.sys.id,
|
244 | bulkActionId
|
245 | }
|
246 | }).then(data => wrapBulkAction(makeRequest, data));
|
247 | },
|
248 | /**
|
249 | * @description Creates a BulkAction that will attempt to publish all items contained in the payload.
|
250 | * See: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/bulk-actions/publish-bulk-action
|
251 | * @param {BulkActionPayload} payload - Object containing the items to be processed in the bulkAction
|
252 | * @returns - Promise with the BulkAction
|
253 | *
|
254 | * @example
|
255 | *
|
256 | * ```javascript
|
257 | * const contentful = require('contentful-management')
|
258 | *
|
259 | * const client = contentful.createClient({
|
260 | * accessToken: '<content_management_api_key>'
|
261 | * })
|
262 | *
|
263 | * const payload = {
|
264 | * entities: {
|
265 | * sys: { type: 'Array' }
|
266 | * items: [
|
267 | * { sys: { type: 'Link', id: '<entry-id>', linkType: 'Entry', version: 2 } }
|
268 | * ]
|
269 | * }
|
270 | * }
|
271 | *
|
272 | * // Using Thenables
|
273 | * client.getSpace('<space_id>')
|
274 | * .then((space) => space.getEnvironment('<environment_id>'))
|
275 | * .then((environment) => environment.createPublishBulkAction(payload))
|
276 | * .then((bulkAction) => console.log(bulkAction.waitProcessing()))
|
277 | * .catch(console.error)
|
278 | *
|
279 | * // Using async/await
|
280 | * try {
|
281 | * const space = await client.getSpace('<space_id>')
|
282 | * const environment = await space.getEnvironment('<environment_id>')
|
283 | * const bulkActionInProgress = await environment.createPublishBulkAction(payload)
|
284 | *
|
285 | * // You can wait for a recently created BulkAction to be processed by using `bulkAction.waitProcessing()`
|
286 | * const bulkActionCompleted = await bulkActionInProgress.waitProcessing()
|
287 | * console.log(bulkActionCompleted)
|
288 | * } catch (error) {
|
289 | * console.log(error)
|
290 | * }
|
291 | * ```
|
292 | */
|
293 | createPublishBulkAction(payload) {
|
294 | const raw = this.toPlainObject();
|
295 | return makeRequest({
|
296 | entityType: 'BulkAction',
|
297 | action: 'publish',
|
298 | params: {
|
299 | spaceId: raw.sys.space.sys.id,
|
300 | environmentId: raw.sys.id
|
301 | },
|
302 | payload
|
303 | }).then(data => wrapBulkAction(makeRequest, data));
|
304 | },
|
305 | /**
|
306 | * @description Creates a BulkAction that will attempt to validate all items contained in the payload.
|
307 | * See: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/bulk-actions/validate-bulk-action
|
308 | * @param {BulkActionPayload} payload - Object containing the items to be processed in the bulkAction
|
309 | * @returns - Promise with the BulkAction
|
310 | *
|
311 | * @example
|
312 | *
|
313 | * ```javascript
|
314 | * const contentful = require('contentful-management')
|
315 | *
|
316 | * const client = contentful.createClient({
|
317 | * accessToken: '<content_management_api_key>'
|
318 | * })
|
319 | *
|
320 | * const payload = {
|
321 | * action: 'publish',
|
322 | * entities: {
|
323 | * sys: { type: 'Array' }
|
324 | * items: [
|
325 | * { sys: { type: 'Link', id: '<entry-id>', linkType: 'Entry' } }
|
326 | * ]
|
327 | * }
|
328 | * }
|
329 | *
|
330 | * // Using Thenables
|
331 | * client.getSpace('<space_id>')
|
332 | * .then((space) => space.getEnvironment('<environment_id>'))
|
333 | * .then((environment) => environment.createValidateBulkAction(payload))
|
334 | * .then((bulkAction) => console.log(bulkAction.waitProcessing()))
|
335 | * .catch(console.error)
|
336 | *
|
337 | * // Using async/await
|
338 | * try {
|
339 | * const space = await client.getSpace('<space_id>')
|
340 | * const environment = await space.getEnvironment('<environment_id>')
|
341 | * const bulkActionInProgress = await environment.createValidateBulkAction(payload)
|
342 | *
|
343 | * // You can wait for a recently created BulkAction to be processed by using `bulkAction.waitProcessing()`
|
344 | * const bulkActionCompleted = await bulkActionInProgress.waitProcessing()
|
345 | * console.log(bulkActionCompleted)
|
346 | * } catch (error) {
|
347 | * console.log(error)
|
348 | * }
|
349 | * ```
|
350 | */
|
351 | createValidateBulkAction(payload) {
|
352 | const raw = this.toPlainObject();
|
353 | return makeRequest({
|
354 | entityType: 'BulkAction',
|
355 | action: 'validate',
|
356 | params: {
|
357 | spaceId: raw.sys.space.sys.id,
|
358 | environmentId: raw.sys.id
|
359 | },
|
360 | payload
|
361 | }).then(data => wrapBulkAction(makeRequest, data));
|
362 | },
|
363 | /**
|
364 | * @description Creates a BulkAction that will attempt to unpublish all items contained in the payload.
|
365 | * See: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/bulk-actions/unpublish-bulk-action
|
366 | * @param {BulkActionPayload} payload - Object containing the items to be processed in the bulkAction
|
367 | * @returns - Promise with the BulkAction
|
368 | *
|
369 | * @example
|
370 | *
|
371 | * ```javascript
|
372 | * const contentful = require('contentful-management')
|
373 | *
|
374 | * const client = contentful.createClient({
|
375 | * accessToken: '<content_management_api_key>'
|
376 | * })
|
377 | *
|
378 | * const payload = {
|
379 | * entities: {
|
380 | * sys: { type: 'Array' }
|
381 | * items: [
|
382 | * { sys: { type: 'Link', id: 'entry-id', linkType: 'Entry' } }
|
383 | * ]
|
384 | * }
|
385 | * }
|
386 | *
|
387 | * // Using Thenables
|
388 | * client.getSpace('<space_id>')
|
389 | * .then((space) => space.getEnvironment('<environment_id>'))
|
390 | * .then((environment) => environment.createUnpublishBulkAction(payload))
|
391 | * .then((bulkAction) => console.log(bulkAction.waitProcessing()))
|
392 | * .catch(console.error)
|
393 | *
|
394 | * // Using async/await
|
395 | * try {
|
396 | * const space = await clientgetSpace('<space_id>')
|
397 | * const environment = await space.getEnvironment('<environment_id>')
|
398 | * const bulkActionInProgress = await environment.createUnpublishBulkAction(payload)
|
399 | *
|
400 | * // You can wait for a recently created BulkAction to be processed by using `bulkAction.waitProcessing()`
|
401 | * const bulkActionCompleted = await bulkActionInProgress.waitProcessing()
|
402 | * console.log(bulkActionCompleted)
|
403 | * } catch (error) {
|
404 | * console.log(error)
|
405 | * }
|
406 | * ```
|
407 | */
|
408 | createUnpublishBulkAction(payload) {
|
409 | const raw = this.toPlainObject();
|
410 | return makeRequest({
|
411 | entityType: 'BulkAction',
|
412 | action: 'unpublish',
|
413 | params: {
|
414 | spaceId: raw.sys.space.sys.id,
|
415 | environmentId: raw.sys.id
|
416 | },
|
417 | payload
|
418 | }).then(data => wrapBulkAction(makeRequest, data));
|
419 | },
|
420 | /**
|
421 | * Gets a Content Type
|
422 | * @param contentTypeId - Content Type ID
|
423 | * @return Promise for a Content Type
|
424 | * @example ```javascript
|
425 | * const contentful = require('contentful-management')
|
426 | *
|
427 | * const client = contentful.createClient({
|
428 | * accessToken: '<content_management_api_key>'
|
429 | * })
|
430 | *
|
431 | * client.getSpace('<space_id>')
|
432 | * .then((space) => space.getEnvironment('<environment-id>'))
|
433 | * .then((environment) => environment.getContentType('<content_type_id>'))
|
434 | * .then((contentType) => console.log(contentType))
|
435 | * .catch(console.error)
|
436 | * ```
|
437 | */
|
438 | getContentType(contentTypeId) {
|
439 | const raw = this.toPlainObject();
|
440 | return makeRequest({
|
441 | entityType: 'ContentType',
|
442 | action: 'get',
|
443 | params: {
|
444 | spaceId: raw.sys.space.sys.id,
|
445 | environmentId: raw.sys.id,
|
446 | contentTypeId
|
447 | }
|
448 | }).then(data => wrapContentType(makeRequest, data));
|
449 | },
|
450 | /**
|
451 | * Gets a collection of Content Types
|
452 | * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
|
453 | * @return Promise for a collection of Content Types
|
454 | * @example ```javascript
|
455 | * const contentful = require('contentful-management')
|
456 | *
|
457 | * const client = contentful.createClient({
|
458 | * accessToken: '<content_management_api_key>'
|
459 | * })
|
460 | *
|
461 | * client.getSpace('<space_id>')
|
462 | * .then((space) => space.getEnvironment('<environment-id>'))
|
463 | * .then((environment) => environment.getContentTypes())
|
464 | * .then((response) => console.log(response.items))
|
465 | * .catch(console.error)
|
466 | * ```
|
467 | */
|
468 | getContentTypes(query = {}) {
|
469 | const raw = this.toPlainObject();
|
470 | return makeRequest({
|
471 | entityType: 'ContentType',
|
472 | action: 'getMany',
|
473 | params: {
|
474 | spaceId: raw.sys.space.sys.id,
|
475 | environmentId: raw.sys.id,
|
476 | query: createRequestConfig({
|
477 | query
|
478 | }).params
|
479 | }
|
480 | }).then(data => wrapContentTypeCollection(makeRequest, data));
|
481 | },
|
482 | /**
|
483 | * Creates a Content Type
|
484 | * @param data - Object representation of the Content Type to be created
|
485 | * @return Promise for the newly created Content Type
|
486 | * @example ```javascript
|
487 | * const contentful = require('contentful-management')
|
488 | *
|
489 | * const client = contentful.createClient({
|
490 | * accessToken: '<content_management_api_key>'
|
491 | * })
|
492 | *
|
493 | * client.getSpace('<space_id>')
|
494 | * .then((space) => space.getEnvironment('<environment-id>'))
|
495 | * .then((environment) => environment.createContentType({
|
496 | * name: 'Blog Post',
|
497 | * fields: [
|
498 | * {
|
499 | * id: 'title',
|
500 | * name: 'Title',
|
501 | * required: true,
|
502 | * localized: false,
|
503 | * type: 'Text'
|
504 | * }
|
505 | * ]
|
506 | * }))
|
507 | * .then((contentType) => console.log(contentType))
|
508 | * .catch(console.error)
|
509 | * ```
|
510 | */
|
511 | createContentType(data) {
|
512 | const raw = this.toPlainObject();
|
513 | return makeRequest({
|
514 | entityType: 'ContentType',
|
515 | action: 'create',
|
516 | params: {
|
517 | spaceId: raw.sys.space.sys.id,
|
518 | environmentId: raw.sys.id
|
519 | },
|
520 | payload: data
|
521 | }).then(response => wrapContentType(makeRequest, response));
|
522 | },
|
523 | /**
|
524 | * Creates a Content Type with a custom ID
|
525 | * @param contentTypeId - Content Type ID
|
526 | * @param data - Object representation of the Content Type to be created
|
527 | * @return Promise for the newly created Content Type
|
528 | * @example ```javascript
|
529 | * const contentful = require('contentful-management')
|
530 | *
|
531 | * const client = contentful.createClient({
|
532 | * accessToken: '<content_management_api_key>'
|
533 | * })
|
534 | *
|
535 | * client.getSpace('<space_id>')
|
536 | * .then((space) => space.getEnvironment('<environment-id>'))
|
537 | * .then((environment) => environment.createContentTypeWithId('<content-type-id>', {
|
538 | * name: 'Blog Post',
|
539 | * fields: [
|
540 | * {
|
541 | * id: 'title',
|
542 | * name: 'Title',
|
543 | * required: true,
|
544 | * localized: false,
|
545 | * type: 'Text'
|
546 | * }
|
547 | * ]
|
548 | * }))
|
549 | * .then((contentType) => console.log(contentType))
|
550 | * .catch(console.error)
|
551 | * ```
|
552 | */
|
553 | createContentTypeWithId(contentTypeId, data) {
|
554 | const raw = this.toPlainObject();
|
555 | return makeRequest({
|
556 | entityType: 'ContentType',
|
557 | action: 'createWithId',
|
558 | params: {
|
559 | spaceId: raw.sys.space.sys.id,
|
560 | environmentId: raw.sys.id,
|
561 | contentTypeId
|
562 | },
|
563 | payload: data
|
564 | }).then(response => wrapContentType(makeRequest, response));
|
565 | },
|
566 | /**
|
567 | * Gets an EditorInterface for a ContentType
|
568 | * @param contentTypeId - Content Type ID
|
569 | * @return Promise for an EditorInterface
|
570 | * @example ```javascript
|
571 | * const contentful = require('contentful-management')
|
572 | *
|
573 | * const client = contentful.createClient({
|
574 | * accessToken: '<content_management_api_key>'
|
575 | * })
|
576 | *
|
577 | * client.getSpace('<space_id>')
|
578 | * .then((space) => space.getEnvironment('<environment-id>'))
|
579 | * .then((environment) => environment.getEditorInterfaceForContentType('<content_type_id>'))
|
580 | * .then((EditorInterface) => console.log(EditorInterface))
|
581 | * .catch(console.error)
|
582 | * ```
|
583 | */
|
584 | getEditorInterfaceForContentType(contentTypeId) {
|
585 | const raw = this.toPlainObject();
|
586 | return makeRequest({
|
587 | entityType: 'EditorInterface',
|
588 | action: 'get',
|
589 | params: {
|
590 | spaceId: raw.sys.space.sys.id,
|
591 | environmentId: raw.sys.id,
|
592 | contentTypeId
|
593 | }
|
594 | }).then(response => wrapEditorInterface(makeRequest, response));
|
595 | },
|
596 | /**
|
597 | * Gets all EditorInterfaces
|
598 | * @return Promise for a collection of EditorInterface
|
599 | * @example ```javascript
|
600 | * const contentful = require('contentful-management')
|
601 | *
|
602 | * const client = contentful.createClient({
|
603 | * accessToken: '<content_management_api_key>'
|
604 | * })
|
605 | *
|
606 | * client.getSpace('<space_id>')
|
607 | * .then((space) => space.getEnvironment('<environment-id>'))
|
608 | * .then((environment) => environment.getEditorInterfaces())
|
609 | * .then((response) => console.log(response.items))
|
610 | * .catch(console.error)
|
611 | * ```
|
612 | */
|
613 | getEditorInterfaces() {
|
614 | const raw = this.toPlainObject();
|
615 | return makeRequest({
|
616 | entityType: 'EditorInterface',
|
617 | action: 'getMany',
|
618 | params: {
|
619 | spaceId: raw.sys.space.sys.id,
|
620 | environmentId: raw.sys.id
|
621 | }
|
622 | }).then(response => wrapEditorInterfaceCollection(makeRequest, response));
|
623 | },
|
624 | /**
|
625 | * Gets an Entry
|
626 | * Warning: if you are using the select operator, when saving, any field that was not selected will be removed
|
627 | * from your entry in the backend
|
628 | * @param id - Entry ID
|
629 | * @param query - Object with search parameters. In this method it's only useful for `locale`.
|
630 | * @return Promise for an Entry
|
631 | * @example ```javascript
|
632 | * const contentful = require('contentful-management')
|
633 | *
|
634 | * const client = contentful.createClient({
|
635 | * accessToken: '<content_management_api_key>'
|
636 | * })
|
637 | *
|
638 | * client.getSpace('<space_id>')
|
639 | * .then((space) => space.getEnvironment('<environment-id>'))
|
640 | * .then((environment) => environment.getEntry('<entry-id>'))
|
641 | * .then((entry) => console.log(entry))
|
642 | * .catch(console.error)
|
643 | * ```
|
644 | */
|
645 | getEntry(id, query = {}) {
|
646 | const raw = this.toPlainObject();
|
647 | return makeRequest({
|
648 | entityType: 'Entry',
|
649 | action: 'get',
|
650 | params: {
|
651 | spaceId: raw.sys.space.sys.id,
|
652 | environmentId: raw.sys.id,
|
653 | entryId: id,
|
654 | query: createRequestConfig({
|
655 | query: query
|
656 | }).params
|
657 | }
|
658 | }).then(data => wrapEntry(makeRequest, data));
|
659 | },
|
660 | /**
|
661 | * Deletes an Entry of this environment
|
662 | * @param id - Entry ID
|
663 | * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
|
664 | * @example ```javascript
|
665 | * const contentful = require('contentful-management')
|
666 | *
|
667 | * const client = contentful.createClient({
|
668 | * accessToken: '<content_management_api_key>'
|
669 | * })
|
670 | *
|
671 | * client.getSpace('<space_id>')
|
672 | * .then((space) => space.getEnvironment('<environment-id>'))
|
673 | * .then((environment) => environment.deleteEntry("4bmLXiuviAZH3jkj5DLRWE"))
|
674 | * .then(() => console.log('Entry deleted.'))
|
675 | * .catch(console.error)
|
676 | * ```
|
677 | */
|
678 | deleteEntry(id) {
|
679 | const raw = this.toPlainObject();
|
680 | return makeRequest({
|
681 | entityType: 'Entry',
|
682 | action: 'delete',
|
683 | params: {
|
684 | spaceId: raw.sys.space.sys.id,
|
685 | environmentId: raw.sys.id,
|
686 | entryId: id
|
687 | }
|
688 | }).then(() => {
|
689 | // noop
|
690 | });
|
691 | },
|
692 | /**
|
693 | * Gets a collection of Entries
|
694 | * Warning: if you are using the select operator, when saving, any field that was not selected will be removed
|
695 | * from your entry in the backend
|
696 | * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
|
697 | * @return Promise for a collection of Entries
|
698 | * @example ```javascript
|
699 | * const contentful = require('contentful-management')
|
700 | *
|
701 | * const client = contentful.createClient({
|
702 | * accessToken: '<content_management_api_key>'
|
703 | * })
|
704 | *
|
705 | * client.getSpace('<space_id>')
|
706 | * .then((space) => space.getEnvironment('<environment-id>'))
|
707 | * .then((environment) => environment.getEntries({'content_type': 'foo'})) // you can add more queries as 'key': 'value'
|
708 | * .then((response) => console.log(response.items))
|
709 | * .catch(console.error)
|
710 | * ```
|
711 | */
|
712 | getEntries(query = {}) {
|
713 | const raw = this.toPlainObject();
|
714 | return makeRequest({
|
715 | entityType: 'Entry',
|
716 | action: 'getMany',
|
717 | params: {
|
718 | spaceId: raw.sys.space.sys.id,
|
719 | environmentId: raw.sys.id,
|
720 | query: createRequestConfig({
|
721 | query: query
|
722 | }).params
|
723 | }
|
724 | }).then(data => wrapEntryCollection(makeRequest, data));
|
725 | },
|
726 | /**
|
727 | * Gets a collection of published Entries
|
728 | * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
|
729 | * @return Promise for a collection of published Entries
|
730 | * @example ```javascript
|
731 | * const contentful = require('contentful-management')
|
732 | *
|
733 | * const client = contentful.createClient({
|
734 | * accessToken: '<content_management_api_key>'
|
735 | * })
|
736 | *
|
737 | * client.getSpace('<space_id>')
|
738 | * .then((space) => space.getEnvironment('<environment-id>'))
|
739 | * .then((environment) => environment.getPublishedEntries({'content_type': 'foo'})) // you can add more queries as 'key': 'value'
|
740 | * .then((response) => console.log(response.items))
|
741 | * .catch(console.error)
|
742 | * ```
|
743 | */
|
744 | getPublishedEntries(query = {}) {
|
745 | const raw = this.toPlainObject();
|
746 | return makeRequest({
|
747 | entityType: 'Entry',
|
748 | action: 'getPublished',
|
749 | params: {
|
750 | spaceId: raw.sys.space.sys.id,
|
751 | environmentId: raw.sys.id,
|
752 | query: createRequestConfig({
|
753 | query: query
|
754 | }).params
|
755 | }
|
756 | }).then(data => wrapEntryCollection(makeRequest, data));
|
757 | },
|
758 | /**
|
759 | * Creates a Entry
|
760 | * @param contentTypeId - The Content Type ID of the newly created Entry
|
761 | * @param data - Object representation of the Entry to be created
|
762 | * @return Promise for the newly created Entry
|
763 | * @example ```javascript
|
764 | * const contentful = require('contentful-management')
|
765 | *
|
766 | * const client = contentful.createClient({
|
767 | * accessToken: '<content_management_api_key>'
|
768 | * })
|
769 | *
|
770 | * client.getSpace('<space_id>')
|
771 | * .then((space) => space.getEnvironment('<environment-id>'))
|
772 | * .then((environment) => environment.createEntry('<content_type_id>', {
|
773 | * fields: {
|
774 | * title: {
|
775 | * 'en-US': 'Entry title'
|
776 | * }
|
777 | * }
|
778 | * }))
|
779 | * .then((entry) => console.log(entry))
|
780 | * .catch(console.error)
|
781 | * ```
|
782 | */
|
783 | createEntry(contentTypeId, data) {
|
784 | const raw = this.toPlainObject();
|
785 | return makeRequest({
|
786 | entityType: 'Entry',
|
787 | action: 'create',
|
788 | params: {
|
789 | spaceId: raw.sys.space.sys.id,
|
790 | environmentId: raw.sys.id,
|
791 | contentTypeId: contentTypeId
|
792 | },
|
793 | payload: data
|
794 | }).then(response => wrapEntry(makeRequest, response));
|
795 | },
|
796 | /**
|
797 | * Creates a Entry with a custom ID
|
798 | * @param contentTypeId - The Content Type of the newly created Entry
|
799 | * @param id - Entry ID
|
800 | * @param data - Object representation of the Entry to be created
|
801 | * @return Promise for the newly created Entry
|
802 | * @example ```javascript
|
803 | * const contentful = require('contentful-management')
|
804 | *
|
805 | * const client = contentful.createClient({
|
806 | * accessToken: '<content_management_api_key>'
|
807 | * })
|
808 | *
|
809 | * // Create entry
|
810 | * client.getSpace('<space_id>')
|
811 | * .then((space) => space.getEnvironment('<environment-id>'))
|
812 | * .then((environment) => environment.createEntryWithId('<content_type_id>', '<entry_id>', {
|
813 | * fields: {
|
814 | * title: {
|
815 | * 'en-US': 'Entry title'
|
816 | * }
|
817 | * }
|
818 | * }))
|
819 | * .then((entry) => console.log(entry))
|
820 | * .catch(console.error)
|
821 | * ```
|
822 | */
|
823 | createEntryWithId(contentTypeId, id, data) {
|
824 | const raw = this.toPlainObject();
|
825 | return makeRequest({
|
826 | entityType: 'Entry',
|
827 | action: 'createWithId',
|
828 | params: {
|
829 | spaceId: raw.sys.space.sys.id,
|
830 | environmentId: raw.sys.id,
|
831 | entryId: id,
|
832 | contentTypeId: contentTypeId
|
833 | },
|
834 | payload: data
|
835 | }).then(response => wrapEntry(makeRequest, response));
|
836 | },
|
837 | /**
|
838 | * Get entry references
|
839 | * @param entryId - Entry ID
|
840 | * @param {Object} options.include - Level of the entry descendants from 1 up to 10 maximum
|
841 | * @returns Promise of Entry references
|
842 | * @example ```javascript
|
843 | * const contentful = require('contentful-management');
|
844 | *
|
845 | * const client = contentful.createClient({
|
846 | * accessToken: '<contentful_management_api_key>
|
847 | * })
|
848 | *
|
849 | * // Get entry references
|
850 | * client.getSpace('<space_id>')
|
851 | * .then((space) => space.getEnvironment('<environment_id>'))
|
852 | * .then((environment) => environment.getEntryReferences('<entry_id>', {include: number}))
|
853 | * .then((entry) => console.log(entry.includes))
|
854 | * // or
|
855 | * .then((environment) => environment.getEntry('<entry_id>')).then((entry) => entry.references({include: number}))
|
856 | * .catch(console.error)
|
857 | * ```
|
858 | */
|
859 | getEntryReferences(entryId, options) {
|
860 | const raw = this.toPlainObject();
|
861 | return makeRequest({
|
862 | entityType: 'Entry',
|
863 | action: 'references',
|
864 | params: {
|
865 | spaceId: raw.sys.space.sys.id,
|
866 | environmentId: raw.sys.id,
|
867 | entryId: entryId,
|
868 | include: options === null || options === void 0 ? void 0 : options.include
|
869 | }
|
870 | }).then(response => wrapEntryCollection(makeRequest, response));
|
871 | },
|
872 | /**
|
873 | * Gets an Asset
|
874 | * Warning: if you are using the select operator, when saving, any field that was not selected will be removed
|
875 | * from your entry in the backend
|
876 | * @param id - Asset ID
|
877 | * @param query - Object with search parameters. In this method it's only useful for `locale`.
|
878 | * @return Promise for an Asset
|
879 | * @example ```javascript
|
880 | * const contentful = require('contentful-management')
|
881 | *
|
882 | * const client = contentful.createClient({
|
883 | * accessToken: '<content_management_api_key>'
|
884 | * })
|
885 | *
|
886 | * client.getSpace('<space_id>')
|
887 | * .then((space) => space.getEnvironment('<environment-id>'))
|
888 | * .then((environment) => environment.getAsset('<asset_id>'))
|
889 | * .then((asset) => console.log(asset))
|
890 | * .catch(console.error)
|
891 | * ```
|
892 | */
|
893 | getAsset(id, query = {}) {
|
894 | const raw = this.toPlainObject();
|
895 | return makeRequest({
|
896 | entityType: 'Asset',
|
897 | action: 'get',
|
898 | params: {
|
899 | spaceId: raw.sys.space.sys.id,
|
900 | environmentId: raw.sys.id,
|
901 | assetId: id,
|
902 | query: createRequestConfig({
|
903 | query: query
|
904 | }).params
|
905 | }
|
906 | }).then(data => wrapAsset(makeRequest, data));
|
907 | },
|
908 | /**
|
909 | * Gets a collection of Assets
|
910 | * Warning: if you are using the select operator, when saving, any field that was not selected will be removed
|
911 | * from your entry in the backend
|
912 | * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
|
913 | * @return Promise for a collection of Assets
|
914 | * @example ```javascript
|
915 | * const contentful = require('contentful-management')
|
916 | *
|
917 | * const client = contentful.createClient({
|
918 | * accessToken: '<content_management_api_key>'
|
919 | * })
|
920 | *
|
921 | * client.getSpace('<space_id>')
|
922 | * .then((space) => space.getEnvironment('<environment-id>'))
|
923 | * .then((environment) => environment.getAssets())
|
924 | * .then((response) => console.log(response.items))
|
925 | * .catch(console.error)
|
926 | * ```
|
927 | */
|
928 | getAssets(query = {}) {
|
929 | const raw = this.toPlainObject();
|
930 | return makeRequest({
|
931 | entityType: 'Asset',
|
932 | action: 'getMany',
|
933 | params: {
|
934 | spaceId: raw.sys.space.sys.id,
|
935 | environmentId: raw.sys.id,
|
936 | query: createRequestConfig({
|
937 | query: query
|
938 | }).params
|
939 | }
|
940 | }).then(data => wrapAssetCollection(makeRequest, data));
|
941 | },
|
942 | /**
|
943 | * Gets a collection of published Assets
|
944 | * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
|
945 | * @return Promise for a collection of published Assets
|
946 | * @example ```javascript
|
947 | * const contentful = require('contentful-management')
|
948 | *
|
949 | * const client = contentful.createClient({
|
950 | * accessToken: '<content_management_api_key>'
|
951 | * })
|
952 | *
|
953 | * client.getSpace('<space_id>')
|
954 | * .then((space) => space.getEnvironment('<environment-id>'))
|
955 | * .then((environment) => environment.getPublishedAssets())
|
956 | * .then((response) => console.log(response.items))
|
957 | * .catch(console.error)
|
958 | * ```
|
959 | */
|
960 | getPublishedAssets(query = {}) {
|
961 | const raw = this.toPlainObject();
|
962 | return makeRequest({
|
963 | entityType: 'Asset',
|
964 | action: 'getPublished',
|
965 | params: {
|
966 | spaceId: raw.sys.space.sys.id,
|
967 | environmentId: raw.sys.id,
|
968 | query: createRequestConfig({
|
969 | query: query
|
970 | }).params
|
971 | }
|
972 | }).then(data => wrapAssetCollection(makeRequest, data));
|
973 | },
|
974 | /**
|
975 | * Creates a Asset. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
|
976 | * @param data - Object representation of the Asset to be created. Note that the field object should have an upload property on asset creation, which will be removed and replaced with an url property when processing is finished.
|
977 | * @return Promise for the newly created Asset
|
978 | * @example ```javascript
|
979 | * const client = contentful.createClient({
|
980 | * accessToken: '<content_management_api_key>'
|
981 | * })
|
982 | *
|
983 | * // Create asset
|
984 | * client.getSpace('<space_id>')
|
985 | * .then((space) => space.getEnvironment('<environment-id>'))
|
986 | * .then((environment) => environment.createAsset({
|
987 | * fields: {
|
988 | * title: {
|
989 | * 'en-US': 'Playsam Streamliner'
|
990 | * },
|
991 | * file: {
|
992 | * 'en-US': {
|
993 | * contentType: 'image/jpeg',
|
994 | * fileName: 'example.jpeg',
|
995 | * upload: 'https://example.com/example.jpg'
|
996 | * }
|
997 | * }
|
998 | * }
|
999 | * }))
|
1000 | * .then((asset) => asset.processForLocale("en-US")) // OR asset.processForAllLocales()
|
1001 | * .then((asset) => console.log(asset))
|
1002 | * .catch(console.error)
|
1003 | * ```
|
1004 | */
|
1005 | createAsset(data) {
|
1006 | const raw = this.toPlainObject();
|
1007 | return makeRequest({
|
1008 | entityType: 'Asset',
|
1009 | action: 'create',
|
1010 | params: {
|
1011 | spaceId: raw.sys.space.sys.id,
|
1012 | environmentId: raw.sys.id
|
1013 | },
|
1014 | payload: data
|
1015 | }).then(response => wrapAsset(makeRequest, response));
|
1016 | },
|
1017 | /**
|
1018 | * Creates a Asset with a custom ID. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
|
1019 | * @param id - Asset ID
|
1020 | * @param data - Object representation of the Asset to be created. Note that the field object should have an upload property on asset creation, which will be removed and replaced with an url property when processing is finished.
|
1021 | * @return Promise for the newly created Asset
|
1022 | * @example ```javascript
|
1023 | * const client = contentful.createClient({
|
1024 | * accessToken: '<content_management_api_key>'
|
1025 | * })
|
1026 | *
|
1027 | * // Create asset
|
1028 | * client.getSpace('<space_id>')
|
1029 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1030 | * .then((environment) => environment.createAssetWithId('<asset_id>', {
|
1031 | * title: {
|
1032 | * 'en-US': 'Playsam Streamliner'
|
1033 | * },
|
1034 | * file: {
|
1035 | * 'en-US': {
|
1036 | * contentType: 'image/jpeg',
|
1037 | * fileName: 'example.jpeg',
|
1038 | * upload: 'https://example.com/example.jpg'
|
1039 | * }
|
1040 | * }
|
1041 | * }))
|
1042 | * .then((asset) => asset.process())
|
1043 | * .then((asset) => console.log(asset))
|
1044 | * .catch(console.error)
|
1045 | * ```
|
1046 | */
|
1047 | createAssetWithId(id, data) {
|
1048 | const raw = this.toPlainObject();
|
1049 | return makeRequest({
|
1050 | entityType: 'Asset',
|
1051 | action: 'createWithId',
|
1052 | params: {
|
1053 | spaceId: raw.sys.space.sys.id,
|
1054 | environmentId: raw.sys.id,
|
1055 | assetId: id
|
1056 | },
|
1057 | payload: data
|
1058 | }).then(response => wrapAsset(makeRequest, response));
|
1059 | },
|
1060 | /**
|
1061 | * Creates a Asset based on files. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
|
1062 | * @param data - Object representation of the Asset to be created. Note that the field object should have an uploadFrom property on asset creation, which will be removed and replaced with an url property when processing is finished.
|
1063 | * @param data.fields.file.[LOCALE].file - Can be a string, an ArrayBuffer or a Stream.
|
1064 | * @return Promise for the newly created Asset
|
1065 | * @example ```javascript
|
1066 | * const client = contentful.createClient({
|
1067 | * accessToken: '<content_management_api_key>'
|
1068 | * })
|
1069 | *
|
1070 | * client.getSpace('<space_id>')
|
1071 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1072 | * .then((environment) => environment.createAssetFromFiles({
|
1073 | * fields: {
|
1074 | * file: {
|
1075 | * 'en-US': {
|
1076 | * contentType: 'image/jpeg',
|
1077 | * fileName: 'filename_english.jpg',
|
1078 | * file: createReadStream('path/to/filename_english.jpg')
|
1079 | * },
|
1080 | * 'de-DE': {
|
1081 | * contentType: 'image/svg+xml',
|
1082 | * fileName: 'filename_german.svg',
|
1083 | * file: '<svg><path fill="red" d="M50 50h150v50H50z"/></svg>'
|
1084 | * }
|
1085 | * }
|
1086 | * }
|
1087 | * }))
|
1088 | * .then((asset) => console.log(asset))
|
1089 | * .catch(console.error)
|
1090 | * ```
|
1091 | */
|
1092 | createAssetFromFiles(data, options) {
|
1093 | const raw = this.toPlainObject();
|
1094 | return makeRequest({
|
1095 | entityType: 'Asset',
|
1096 | action: 'createFromFiles',
|
1097 | params: {
|
1098 | spaceId: raw.sys.space.sys.id,
|
1099 | environmentId: raw.sys.id,
|
1100 | uploadTimeout: options === null || options === void 0 ? void 0 : options.uploadTimeout
|
1101 | },
|
1102 | payload: data
|
1103 | }).then(response => wrapAsset(makeRequest, response));
|
1104 | },
|
1105 | /**
|
1106 | * Creates an asset key for signing asset URLs (Embargoed Assets)
|
1107 | * @param data Object with request payload
|
1108 | * @param data.expiresAt number a UNIX timestamp in the future (but not more than 48 hours from time of calling)
|
1109 | * @return Promise for the newly created AssetKey
|
1110 | * @example ```javascript
|
1111 | * const client = contentful.createClient({
|
1112 | * accessToken: '<content_management_api_key>'
|
1113 | * })
|
1114 | *
|
1115 | * // Create assetKey
|
1116 | * now = () => Math.floor(Date.now() / 1000)
|
1117 | * const withExpiryIn1Hour = () => now() + 1 * 60 * 60
|
1118 | * client.getSpace('<space_id>')
|
1119 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1120 | * .then((environment) => environment.createAssetKey({ expiresAt: withExpiryIn1Hour() }))
|
1121 | * .then((policy, secret) => console.log({ policy, secret }))
|
1122 | * .catch(console.error)
|
1123 | * ```
|
1124 | */
|
1125 | createAssetKey(payload) {
|
1126 | const raw = this.toPlainObject();
|
1127 | return makeRequest({
|
1128 | entityType: 'AssetKey',
|
1129 | action: 'create',
|
1130 | params: {
|
1131 | spaceId: raw.sys.space.sys.id,
|
1132 | environmentId: raw.sys.id
|
1133 | },
|
1134 | payload
|
1135 | }).then(data => wrapAssetKey(makeRequest, data));
|
1136 | },
|
1137 | /**
|
1138 | * Gets an Upload
|
1139 | * @param id - Upload ID
|
1140 | * @return Promise for an Upload
|
1141 | * @example ```javascript
|
1142 | * const client = contentful.createClient({
|
1143 | * accessToken: '<content_management_api_key>'
|
1144 | * })
|
1145 | * const uploadStream = createReadStream('path/to/filename_english.jpg')
|
1146 | *
|
1147 | * client.getSpace('<space_id>')
|
1148 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1149 | * .then((environment) => environment.getUpload('<upload-id>')
|
1150 | * .then((upload) => console.log(upload))
|
1151 | * .catch(console.error)
|
1152 | */
|
1153 | getUpload(id) {
|
1154 | const raw = this.toPlainObject();
|
1155 | return makeRequest({
|
1156 | entityType: 'Upload',
|
1157 | action: 'get',
|
1158 | params: {
|
1159 | spaceId: raw.sys.space.sys.id,
|
1160 | environmentId: raw.sys.id,
|
1161 | uploadId: id
|
1162 | }
|
1163 | }).then(data => wrapUpload(makeRequest, data));
|
1164 | },
|
1165 | /**
|
1166 | * Creates a Upload.
|
1167 | * @param data - Object with file information.
|
1168 | * @param data.file - Actual file content. Can be a string, an ArrayBuffer or a Stream.
|
1169 | * @return Upload object containing information about the uploaded file.
|
1170 | * @example ```javascript
|
1171 | * const client = contentful.createClient({
|
1172 | * accessToken: '<content_management_api_key>'
|
1173 | * })
|
1174 | * const uploadStream = createReadStream('path/to/filename_english.jpg')
|
1175 | *
|
1176 | * client.getSpace('<space_id>')
|
1177 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1178 | * .then((environment) => environment.createUpload({file: uploadStream})
|
1179 | * .then((upload) => console.log(upload))
|
1180 | * .catch(console.error)
|
1181 | * ```
|
1182 | */
|
1183 | createUpload: function createUpload(data) {
|
1184 | const raw = this.toPlainObject();
|
1185 | return makeRequest({
|
1186 | entityType: 'Upload',
|
1187 | action: 'create',
|
1188 | params: {
|
1189 | spaceId: raw.sys.space.sys.id,
|
1190 | environmentId: raw.sys.id
|
1191 | },
|
1192 | payload: data
|
1193 | }).then(data => wrapUpload(makeRequest, data));
|
1194 | },
|
1195 | /**
|
1196 | * Gets a Locale
|
1197 | * @param localeId - Locale ID
|
1198 | * @return Promise for an Locale
|
1199 | * @example ```javascript
|
1200 | * const contentful = require('contentful-management')
|
1201 | *
|
1202 | * const client = contentful.createClient({
|
1203 | * accessToken: '<content_management_api_key>'
|
1204 | * })
|
1205 | *
|
1206 | * client.getSpace('<space_id>')
|
1207 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1208 | * .then((environment) => environment.getLocale('<locale_id>'))
|
1209 | * .then((locale) => console.log(locale))
|
1210 | * .catch(console.error)
|
1211 | * ```
|
1212 | */
|
1213 | getLocale(localeId) {
|
1214 | const raw = this.toPlainObject();
|
1215 | return makeRequest({
|
1216 | entityType: 'Locale',
|
1217 | action: 'get',
|
1218 | params: {
|
1219 | spaceId: raw.sys.space.sys.id,
|
1220 | environmentId: raw.sys.id,
|
1221 | localeId
|
1222 | }
|
1223 | }).then(data => wrapLocale(makeRequest, data));
|
1224 | },
|
1225 | /**
|
1226 | * Gets a collection of Locales
|
1227 | * @return Promise for a collection of Locales
|
1228 | * @example ```javascript
|
1229 | * const contentful = require('contentful-management')
|
1230 | *
|
1231 | * const client = contentful.createClient({
|
1232 | * accessToken: '<content_management_api_key>'
|
1233 | * })
|
1234 | *
|
1235 | * client.getSpace('<space_id>')
|
1236 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1237 | * .then((environment) => environment.getLocales())
|
1238 | * .then((response) => console.log(response.items))
|
1239 | * .catch(console.error)
|
1240 | * ```
|
1241 | */
|
1242 | getLocales() {
|
1243 | const raw = this.toPlainObject();
|
1244 | return makeRequest({
|
1245 | entityType: 'Locale',
|
1246 | action: 'getMany',
|
1247 | params: {
|
1248 | spaceId: raw.sys.space.sys.id,
|
1249 | environmentId: raw.sys.id
|
1250 | }
|
1251 | }).then(data => wrapLocaleCollection(makeRequest, data));
|
1252 | },
|
1253 | /**
|
1254 | * Creates a Locale
|
1255 | * @param data - Object representation of the Locale to be created
|
1256 | * @return Promise for the newly created Locale
|
1257 | * @example ```javascript
|
1258 | * const contentful = require('contentful-management')
|
1259 | *
|
1260 | * const client = contentful.createClient({
|
1261 | * accessToken: '<content_management_api_key>'
|
1262 | * })
|
1263 | *
|
1264 | * // Create locale
|
1265 | * client.getSpace('<space_id>')
|
1266 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1267 | * .then((environment) => environment.createLocale({
|
1268 | * name: 'German (Austria)',
|
1269 | * code: 'de-AT',
|
1270 | * fallbackCode: 'de-DE',
|
1271 | * optional: true
|
1272 | * }))
|
1273 | * .then((locale) => console.log(locale))
|
1274 | * .catch(console.error)
|
1275 | * ```
|
1276 | */
|
1277 | createLocale(data) {
|
1278 | const raw = this.toPlainObject();
|
1279 | return makeRequest({
|
1280 | entityType: 'Locale',
|
1281 | action: 'create',
|
1282 | params: {
|
1283 | spaceId: raw.sys.space.sys.id,
|
1284 | environmentId: raw.sys.id
|
1285 | },
|
1286 | payload: data
|
1287 | }).then(response => wrapLocale(makeRequest, response));
|
1288 | },
|
1289 | /**
|
1290 | * Gets an UI Extension
|
1291 | * @param id - Extension ID
|
1292 | * @return Promise for an UI Extension
|
1293 | * @example ```javascript
|
1294 | * const contentful = require('contentful-management')
|
1295 | *
|
1296 | * const client = contentful.createClient({
|
1297 | * accessToken: '<content_management_api_key>'
|
1298 | * })
|
1299 | *
|
1300 | * client.getSpace('<space_id>')
|
1301 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1302 | * .then((environment) => environment.getUiExtension('<extension-id>'))
|
1303 | * .then((extension) => console.log(extension))
|
1304 | * .catch(console.error)
|
1305 | * ```
|
1306 | */
|
1307 | getUiExtension(id) {
|
1308 | const raw = this.toPlainObject();
|
1309 | return makeRequest({
|
1310 | entityType: 'Extension',
|
1311 | action: 'get',
|
1312 | params: {
|
1313 | spaceId: raw.sys.space.sys.id,
|
1314 | environmentId: raw.sys.id,
|
1315 | extensionId: id
|
1316 | }
|
1317 | }).then(data => wrapExtension(makeRequest, data));
|
1318 | },
|
1319 | /**
|
1320 | * Gets a collection of UI Extension
|
1321 | * @return Promise for a collection of UI Extensions
|
1322 | * @example ```javascript
|
1323 | * const contentful = require('contentful-management')
|
1324 | *
|
1325 | * const client = contentful.createClient({
|
1326 | * accessToken: '<content_management_api_key>'
|
1327 | * })
|
1328 | *
|
1329 | * client.getSpace('<space_id>')
|
1330 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1331 | * .then((environment) => environment.getUiExtensions()
|
1332 | * .then((response) => console.log(response.items))
|
1333 | * .catch(console.error)
|
1334 | * ```
|
1335 | */
|
1336 | getUiExtensions() {
|
1337 | const raw = this.toPlainObject();
|
1338 | return makeRequest({
|
1339 | entityType: 'Extension',
|
1340 | action: 'getMany',
|
1341 | params: {
|
1342 | spaceId: raw.sys.space.sys.id,
|
1343 | environmentId: raw.sys.id
|
1344 | }
|
1345 | }).then(response => wrapExtensionCollection(makeRequest, response));
|
1346 | },
|
1347 | /**
|
1348 | * Creates a UI Extension
|
1349 | * @param data - Object representation of the UI Extension to be created
|
1350 | * @return Promise for the newly created UI Extension
|
1351 | * @example ```javascript
|
1352 | * const contentful = require('contentful-management')
|
1353 | *
|
1354 | * const client = contentful.createClient({
|
1355 | * accessToken: '<content_management_api_key>'
|
1356 | * })
|
1357 | *
|
1358 | * client.getSpace('<space_id>')
|
1359 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1360 | * .then((environment) => environment.createUiExtension({
|
1361 | * extension: {
|
1362 | * name: 'My awesome extension',
|
1363 | * src: 'https://example.com/my',
|
1364 | * fieldTypes: [
|
1365 | * {
|
1366 | * type: 'Symbol'
|
1367 | * },
|
1368 | * {
|
1369 | * type: 'Text'
|
1370 | * }
|
1371 | * ],
|
1372 | * sidebar: false
|
1373 | * }
|
1374 | * }))
|
1375 | * .then((extension) => console.log(extension))
|
1376 | * .catch(console.error)
|
1377 | * ```
|
1378 | */
|
1379 | createUiExtension(data) {
|
1380 | const raw = this.toPlainObject();
|
1381 | return makeRequest({
|
1382 | entityType: 'Extension',
|
1383 | action: 'create',
|
1384 | params: {
|
1385 | spaceId: raw.sys.space.sys.id,
|
1386 | environmentId: raw.sys.id
|
1387 | },
|
1388 | payload: data
|
1389 | }).then(response => wrapExtension(makeRequest, response));
|
1390 | },
|
1391 | /**
|
1392 | * Creates a UI Extension with a custom ID
|
1393 | * @param id - Extension ID
|
1394 | * @param data - Object representation of the UI Extension to be created
|
1395 | * @return Promise for the newly created UI Extension
|
1396 | * @example ```javascript
|
1397 | * const contentful = require('contentful-management')
|
1398 | *
|
1399 | * const client = contentful.createClient({
|
1400 | * accessToken: '<content_management_api_key>'
|
1401 | * })
|
1402 | *
|
1403 | * client.getSpace('<space_id>')
|
1404 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1405 | * .then((environment) => environment.createUiExtensionWithId('<extension_id>', {
|
1406 | * extension: {
|
1407 | * name: 'My awesome extension',
|
1408 | * src: 'https://example.com/my',
|
1409 | * fieldTypes: [
|
1410 | * {
|
1411 | * type: 'Symbol'
|
1412 | * },
|
1413 | * {
|
1414 | * type: 'Text'
|
1415 | * }
|
1416 | * ],
|
1417 | * sidebar: false
|
1418 | * }
|
1419 | * }))
|
1420 | * .then((extension) => console.log(extension))
|
1421 | * .catch(console.error)
|
1422 | * ```
|
1423 | */
|
1424 | createUiExtensionWithId(id, data) {
|
1425 | const raw = this.toPlainObject();
|
1426 | return makeRequest({
|
1427 | entityType: 'Extension',
|
1428 | action: 'createWithId',
|
1429 | params: {
|
1430 | spaceId: raw.sys.space.sys.id,
|
1431 | environmentId: raw.sys.id,
|
1432 | extensionId: id
|
1433 | },
|
1434 | payload: data
|
1435 | }).then(response => wrapExtension(makeRequest, response));
|
1436 | },
|
1437 | /**
|
1438 | * Creates an App Installation
|
1439 | * @param appDefinitionId - AppDefinition ID
|
1440 | * @param data - AppInstallation data
|
1441 | * @param options.acceptAllTerms - Flag for accepting Apps' Marketplace EULA, Terms, and Privacy policy (need to pass `{acceptAllTerms: true}` to install a marketplace app)
|
1442 | * @return Promise for an App Installation
|
1443 | * @example ```javascript
|
1444 | * const contentful = require('contentful-management')
|
1445 | *
|
1446 | * const client = contentful.createClient({
|
1447 | * accessToken: '<content_management_api_key>'
|
1448 | * })
|
1449 | *
|
1450 | * client.getSpace('<space_id>')
|
1451 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1452 | * .then((environment) => environment.createAppInstallation('<app_definition_id>', {
|
1453 | * parameters: {
|
1454 | * someParameter: someValue
|
1455 | * }
|
1456 | * })
|
1457 | * .then((appInstallation) => console.log(appInstallation))
|
1458 | * .catch(console.error)
|
1459 | * ```
|
1460 | */
|
1461 | createAppInstallation(appDefinitionId, data, {
|
1462 | acceptAllTerms
|
1463 | } = {}) {
|
1464 | const raw = this.toPlainObject();
|
1465 | return makeRequest({
|
1466 | entityType: 'AppInstallation',
|
1467 | action: 'upsert',
|
1468 | params: {
|
1469 | spaceId: raw.sys.space.sys.id,
|
1470 | environmentId: raw.sys.id,
|
1471 | appDefinitionId,
|
1472 | acceptAllTerms
|
1473 | },
|
1474 | payload: data
|
1475 | }).then(payload => wrapAppInstallation(makeRequest, payload));
|
1476 | },
|
1477 | /**
|
1478 | * Gets an App Installation
|
1479 | * @param id - AppDefintion ID
|
1480 | * @return Promise for an App Installation
|
1481 | * @example ```javascript
|
1482 | * const contentful = require('contentful-management')
|
1483 | *
|
1484 | * const client = contentful.createClient({
|
1485 | * accessToken: '<content_management_api_key>'
|
1486 | * })
|
1487 | *
|
1488 | * client.getSpace('<space_id>')
|
1489 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1490 | * .then((environment) => environment.getAppInstallation('<app-definition-id>'))
|
1491 | * .then((appInstallation) => console.log(appInstallation))
|
1492 | * .catch(console.error)
|
1493 | * ```
|
1494 | */
|
1495 | getAppInstallation(id) {
|
1496 | const raw = this.toPlainObject();
|
1497 | return makeRequest({
|
1498 | entityType: 'AppInstallation',
|
1499 | action: 'get',
|
1500 | params: {
|
1501 | spaceId: raw.sys.space.sys.id,
|
1502 | environmentId: raw.sys.id,
|
1503 | appDefinitionId: id
|
1504 | }
|
1505 | }).then(data => wrapAppInstallation(makeRequest, data));
|
1506 | },
|
1507 | /**
|
1508 | * Gets a collection of App Installation
|
1509 | * @return Promise for a collection of App Installations
|
1510 | * @example ```javascript
|
1511 | * const contentful = require('contentful-management')
|
1512 | *
|
1513 | * const client = contentful.createClient({
|
1514 | * accessToken: '<content_management_api_key>'
|
1515 | * })
|
1516 | *
|
1517 | * client.getSpace('<space_id>')
|
1518 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1519 | * .then((environment) => environment.getAppInstallations()
|
1520 | * .then((response) => console.log(response.items))
|
1521 | * .catch(console.error)
|
1522 | * ```
|
1523 | */
|
1524 | getAppInstallations() {
|
1525 | const raw = this.toPlainObject();
|
1526 | return makeRequest({
|
1527 | entityType: 'AppInstallation',
|
1528 | action: 'getMany',
|
1529 | params: {
|
1530 | spaceId: raw.sys.space.sys.id,
|
1531 | environmentId: raw.sys.id
|
1532 | }
|
1533 | }).then(data => wrapAppInstallationCollection(makeRequest, data));
|
1534 | },
|
1535 | /**
|
1536 | * Creates an app action call
|
1537 | * @param appDefinitionId - AppDefinition ID
|
1538 | * @param appActionId - action ID
|
1539 | * @param data - App Action Call data
|
1540 | * @return Promise for an App Action Call
|
1541 | * @example ```javascript
|
1542 | * const contentful = require('contentful-management')
|
1543 | *
|
1544 | * const client = contentful.createClient({
|
1545 | * accessToken: '<content_management_api_key>'
|
1546 | * })
|
1547 | *
|
1548 | * const data = {
|
1549 | * headers: {
|
1550 | * 'x-my-header': 'some-value'
|
1551 | * },
|
1552 | * body: {
|
1553 | * 'some-body-value': true
|
1554 | * }
|
1555 | * }
|
1556 | *
|
1557 | * client.getSpace('<space_id>')
|
1558 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1559 | * .then((environment) => environment.createAppActionCall('<app_definition_id>', '<action_id>', data)
|
1560 | * .then((appActionCall) => console.log(appActionCall))
|
1561 | * .catch(console.error)
|
1562 | * ```
|
1563 | */
|
1564 | createAppActionCall(appDefinitionId, appActionId, data) {
|
1565 | const raw = this.toPlainObject();
|
1566 | return makeRequest({
|
1567 | entityType: 'AppActionCall',
|
1568 | action: 'create',
|
1569 | params: {
|
1570 | spaceId: raw.sys.space.sys.id,
|
1571 | environmentId: raw.sys.id,
|
1572 | appDefinitionId,
|
1573 | appActionId
|
1574 | },
|
1575 | payload: data
|
1576 | }).then(payload => wrapAppActionCall(makeRequest, payload));
|
1577 | },
|
1578 | /**
|
1579 | * Creates an app signed request
|
1580 | * @param appDefinitionId - AppDefinition ID
|
1581 | * @param data - SignedRequest data
|
1582 | * @return Promise for a Signed Request
|
1583 | * @example ```javascript
|
1584 | * const contentful = require('contentful-management')
|
1585 | *
|
1586 | * const client = contentful.createClient({
|
1587 | * accessToken: '<content_management_api_key>'
|
1588 | * })
|
1589 | *
|
1590 | * const data = {
|
1591 | * method: 'POST',
|
1592 | * path: '/request_path',
|
1593 | * body: '{ "key": "data" }',
|
1594 | * headers: {
|
1595 | * 'x-my-header': 'some-value'
|
1596 | * },
|
1597 | * }
|
1598 | *
|
1599 | * client.getSpace('<space_id>')
|
1600 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1601 | * .then((environment) => environment.createAppSignedRequest('<app_definition_id>', data)
|
1602 | * .then((signedRequest) => console.log(signedRequest))
|
1603 | * .catch(console.error)
|
1604 | * ```
|
1605 | */
|
1606 | createAppSignedRequest(appDefinitionId, data) {
|
1607 | const raw = this.toPlainObject();
|
1608 | return makeRequest({
|
1609 | entityType: 'AppSignedRequest',
|
1610 | action: 'create',
|
1611 | params: {
|
1612 | spaceId: raw.sys.space.sys.id,
|
1613 | environmentId: raw.sys.id,
|
1614 | appDefinitionId
|
1615 | },
|
1616 | payload: data
|
1617 | }).then(payload => wrapAppSignedRequest(makeRequest, payload));
|
1618 | },
|
1619 | /**
|
1620 | * Creates an app access token
|
1621 | * @param appDefinitionId - AppDefinition ID
|
1622 | * @param data - Json Web Token
|
1623 | * @return Promise for an app access token
|
1624 | * @example ```javascript
|
1625 | * const contentful = require('contentful-management')
|
1626 | * const { sign } = require('jsonwebtoken')
|
1627 | *
|
1628 | * const signOptions = { algorithm: 'RS256', issuer: '<app_definition_id>', expiresIn: '10m' }
|
1629 | *
|
1630 | * const client = contentful.createClient({
|
1631 | * accessToken: '<content_management_api_key>'
|
1632 | * })
|
1633 | *
|
1634 | * const data = {
|
1635 | * jwt: sign({}, '<private_key>', signOptions)
|
1636 | * }
|
1637 | *
|
1638 | * client.getSpace('<space_id>')
|
1639 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1640 | * .then((environment) => environment.createAppAccessToken('<app_definition_id>', data)
|
1641 | * .then((appAccessToken) => console.log(appAccessToken))
|
1642 | * .catch(console.error)
|
1643 | * ```
|
1644 | */
|
1645 | createAppAccessToken(appDefinitionId, data) {
|
1646 | const raw = this.toPlainObject();
|
1647 | return makeRequest({
|
1648 | entityType: 'AppAccessToken',
|
1649 | action: 'create',
|
1650 | params: {
|
1651 | spaceId: raw.sys.space.sys.id,
|
1652 | environmentId: raw.sys.id,
|
1653 | appDefinitionId
|
1654 | },
|
1655 | payload: data
|
1656 | }).then(payload => wrapAppAccessToken(makeRequest, payload));
|
1657 | },
|
1658 | /**
|
1659 | * Gets all snapshots of an entry
|
1660 | * @func getEntrySnapshots
|
1661 | * @param entryId - Entry ID
|
1662 | * @param query - query additional query paramaters
|
1663 | * @return Promise for a collection of Entry Snapshots
|
1664 | * @example ```javascript
|
1665 | * const contentful = require('contentful-management')
|
1666 | *
|
1667 | * const client = contentful.createClient({
|
1668 | * accessToken: '<content_management_api_key>'
|
1669 | * })
|
1670 | *
|
1671 | * client.getSpace('<space_id>')
|
1672 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1673 | * .then((environment) => environment.getEntrySnapshots('<entry_id>'))
|
1674 | * .then((snapshots) => console.log(snapshots.items))
|
1675 | * .catch(console.error)
|
1676 | * ```
|
1677 | */
|
1678 | getEntrySnapshots(entryId, query = {}) {
|
1679 | const raw = this.toPlainObject();
|
1680 | return makeRequest({
|
1681 | entityType: 'Snapshot',
|
1682 | action: 'getManyForEntry',
|
1683 | params: {
|
1684 | spaceId: raw.sys.space.sys.id,
|
1685 | environmentId: raw.sys.id,
|
1686 | entryId,
|
1687 | query
|
1688 | }
|
1689 | }).then(data => wrapSnapshotCollection(makeRequest, data));
|
1690 | },
|
1691 | /**
|
1692 | * Gets all snapshots of a contentType
|
1693 | * @func getContentTypeSnapshots
|
1694 | * @param contentTypeId - Content Type ID
|
1695 | * @param query - query additional query paramaters
|
1696 | * @return Promise for a collection of Content Type Snapshots
|
1697 | * @example ```javascript
|
1698 | * const contentful = require('contentful-management')
|
1699 | *
|
1700 | * const client = contentful.createClient({
|
1701 | * accessToken: '<content_management_api_key>'
|
1702 | * })
|
1703 | *
|
1704 | * client.getSpace('<space_id>')
|
1705 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1706 | * .then((environment) => environment.getContentTypeSnapshots('<contentTypeId>'))
|
1707 | * .then((snapshots) => console.log(snapshots.items))
|
1708 | * .catch(console.error)
|
1709 | * ```
|
1710 | */
|
1711 | getContentTypeSnapshots(contentTypeId, query = {}) {
|
1712 | const raw = this.toPlainObject();
|
1713 | return makeRequest({
|
1714 | entityType: 'Snapshot',
|
1715 | action: 'getManyForContentType',
|
1716 | params: {
|
1717 | spaceId: raw.sys.space.sys.id,
|
1718 | environmentId: raw.sys.id,
|
1719 | contentTypeId,
|
1720 | query
|
1721 | }
|
1722 | }).then(data => wrapSnapshotCollection(makeRequest, data));
|
1723 | },
|
1724 | createTag(id, name, visibility) {
|
1725 | const raw = this.toPlainObject();
|
1726 | return makeRequest({
|
1727 | entityType: 'Tag',
|
1728 | action: 'createWithId',
|
1729 | params: {
|
1730 | spaceId: raw.sys.space.sys.id,
|
1731 | environmentId: raw.sys.id,
|
1732 | tagId: id
|
1733 | },
|
1734 | payload: {
|
1735 | name,
|
1736 | sys: {
|
1737 | visibility: visibility !== null && visibility !== void 0 ? visibility : 'private'
|
1738 | }
|
1739 | }
|
1740 | }).then(data => wrapTag(makeRequest, data));
|
1741 | },
|
1742 | getTags(query = {}) {
|
1743 | const raw = this.toPlainObject();
|
1744 | return makeRequest({
|
1745 | entityType: 'Tag',
|
1746 | action: 'getMany',
|
1747 | params: {
|
1748 | spaceId: raw.sys.space.sys.id,
|
1749 | environmentId: raw.sys.id,
|
1750 | query: createRequestConfig({
|
1751 | query
|
1752 | }).params
|
1753 | }
|
1754 | }).then(data => wrapTagCollection(makeRequest, data));
|
1755 | },
|
1756 | getTag(id) {
|
1757 | const raw = this.toPlainObject();
|
1758 | return makeRequest({
|
1759 | entityType: 'Tag',
|
1760 | action: 'get',
|
1761 | params: {
|
1762 | spaceId: raw.sys.space.sys.id,
|
1763 | environmentId: raw.sys.id,
|
1764 | tagId: id
|
1765 | }
|
1766 | }).then(data => wrapTag(makeRequest, data));
|
1767 | },
|
1768 | /**
|
1769 | * Retrieves a Release by ID
|
1770 | * @param releaseId
|
1771 | * @returns Promise containing a wrapped Release
|
1772 | * @example ```javascript
|
1773 | * const contentful = require('contentful-management')
|
1774 | *
|
1775 | * const client = contentful.createClient({
|
1776 | * accessToken: '<content_management_api_key>'
|
1777 | * })
|
1778 | *
|
1779 | * client.getSpace('<space_id>')
|
1780 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1781 | * .then((environment) => environment.getRelease('<release_id>'))
|
1782 | * .then((release) => console.log(release))
|
1783 | * .catch(console.error)
|
1784 | * ```
|
1785 | */
|
1786 | getRelease(releaseId) {
|
1787 | const raw = this.toPlainObject();
|
1788 | return makeRequest({
|
1789 | entityType: 'Release',
|
1790 | action: 'get',
|
1791 | params: {
|
1792 | spaceId: raw.sys.space.sys.id,
|
1793 | environmentId: raw.sys.id,
|
1794 | releaseId
|
1795 | }
|
1796 | }).then(data => wrapRelease(makeRequest, data));
|
1797 | },
|
1798 | /**
|
1799 | * Gets a Collection of Releases,
|
1800 | * @param {ReleaseQueryOptions} query filtering options for the collection result
|
1801 | * @returns Promise containing a wrapped Release Collection
|
1802 | * @example ```javascript
|
1803 | * const contentful = require('contentful-management')
|
1804 | *
|
1805 | * const client = contentful.createClient({
|
1806 | * accessToken: '<content_management_api_key>'
|
1807 | * })
|
1808 | *
|
1809 | * client.getSpace('<space_id>')
|
1810 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1811 | * .then((environment) => environment.getReleases({ 'entities.sys.id[in]': '<asset_id>,<entry_id>' }))
|
1812 | * .then((releases) => console.log(releases))
|
1813 | * .catch(console.error)
|
1814 | * ```
|
1815 | */
|
1816 | getReleases(query) {
|
1817 | const raw = this.toPlainObject();
|
1818 | return makeRequest({
|
1819 | entityType: 'Release',
|
1820 | action: 'query',
|
1821 | params: {
|
1822 | spaceId: raw.sys.space.sys.id,
|
1823 | environmentId: raw.sys.id,
|
1824 | query
|
1825 | }
|
1826 | }).then(data => wrapReleaseCollection(makeRequest, data));
|
1827 | },
|
1828 | /**
|
1829 | * Creates a new Release with the entities and title in the payload
|
1830 | * @param payload Object containing the payload in order to create a Release
|
1831 | * @returns Promise containing a wrapped Release, that has other helper methods within.
|
1832 | * @example ```javascript
|
1833 | * const contentful = require('contentful-management')
|
1834 | *
|
1835 | * const client = contentful.createClient({
|
1836 | * accessToken: '<content_management_api_key>'
|
1837 | * })
|
1838 | *
|
1839 | * const payload = {
|
1840 | * title: 'My Release',
|
1841 | * entities: {
|
1842 | * sys: { type: 'Array' },
|
1843 | * items: [
|
1844 | * { sys: { linkType: 'Entry', type: 'Link', id: '<entry_id>' } }
|
1845 | * ]
|
1846 | * }
|
1847 | * }
|
1848 | *
|
1849 | * client.getSpace('<space_id>')
|
1850 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1851 | * .then((environment) => environment.createRelease(payload))
|
1852 | * .then((release) => console.log(release))
|
1853 | * .catch(console.error)
|
1854 | * ```
|
1855 | */
|
1856 | createRelease(payload) {
|
1857 | const raw = this.toPlainObject();
|
1858 | return makeRequest({
|
1859 | entityType: 'Release',
|
1860 | action: 'create',
|
1861 | params: {
|
1862 | spaceId: raw.sys.space.sys.id,
|
1863 | environmentId: raw.sys.id
|
1864 | },
|
1865 | payload
|
1866 | }).then(data => wrapRelease(makeRequest, data));
|
1867 | },
|
1868 | /**
|
1869 | * Updates a Release and replaces all the properties.
|
1870 | * @param {object} options,
|
1871 | * @param options.releaseId the ID of the release
|
1872 | * @param options.payload the payload to be updated in the Release
|
1873 | * @param options.version Release sys.version that to be updated
|
1874 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
1875 | *
|
1876 | * @example ```javascript
|
1877 | * const contentful = require('contentful-management')
|
1878 | *
|
1879 | * const client = contentful.createClient({
|
1880 | * accessToken: '<content_management_api_key>'
|
1881 | * })
|
1882 | *
|
1883 | *
|
1884 | * const payload = {
|
1885 | * title: "Updated Release title",
|
1886 | * entities: {
|
1887 | * sys: { type: 'Array' },
|
1888 | * items: [
|
1889 | * { sys: { linkType: 'Entry', type: 'Link', id: '<entry_id>' } }
|
1890 | * ]
|
1891 | * }
|
1892 | * }
|
1893 | *
|
1894 | * client.getSpace('<space_id>')
|
1895 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1896 | * .then((environment) => environment.updateRelease({ releaseId: '<release_id>', version: 1, payload } ))
|
1897 | * .then((release) => console.log(release))
|
1898 | * .catch(console.error)
|
1899 | * ```
|
1900 | */
|
1901 | updateRelease({
|
1902 | releaseId,
|
1903 | payload,
|
1904 | version
|
1905 | }) {
|
1906 | const raw = this.toPlainObject();
|
1907 | return makeRequest({
|
1908 | entityType: 'Release',
|
1909 | action: 'update',
|
1910 | params: {
|
1911 | spaceId: raw.sys.space.sys.id,
|
1912 | environmentId: raw.sys.id,
|
1913 | releaseId,
|
1914 | version
|
1915 | },
|
1916 | payload
|
1917 | }).then(data => wrapRelease(makeRequest, data));
|
1918 | },
|
1919 | /**
|
1920 | * Deletes a Release by ID - does not delete any entities.
|
1921 | * @param releaseId the ID of the release
|
1922 | *
|
1923 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
1924 | * @example ```javascript
|
1925 | * const contentful = require('contentful-management')
|
1926 | *
|
1927 | * const client = contentful.createClient({
|
1928 | * accessToken: '<content_management_api_key>'
|
1929 | * })
|
1930 | *
|
1931 | * client.getSpace('<space_id>')
|
1932 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1933 | * .then((environment) => environment.deleteRelease('<release_id>')
|
1934 | * .catch(console.error)
|
1935 | * ```
|
1936 | */
|
1937 | deleteRelease(releaseId) {
|
1938 | const raw = this.toPlainObject();
|
1939 | return makeRequest({
|
1940 | entityType: 'Release',
|
1941 | action: 'delete',
|
1942 | params: {
|
1943 | spaceId: raw.sys.space.sys.id,
|
1944 | environmentId: raw.sys.id,
|
1945 | releaseId
|
1946 | }
|
1947 | });
|
1948 | },
|
1949 | /**
|
1950 | * Publishes all Entities contained in a Release.
|
1951 | * @param options.releaseId the ID of the release
|
1952 | * @param options.version the version of the release that is to be published
|
1953 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
1954 | *
|
1955 | * @example ```javascript
|
1956 | * const contentful = require('contentful-management')
|
1957 | *
|
1958 | * const client = contentful.createClient({
|
1959 | * accessToken: '<content_management_api_key>'
|
1960 | * })
|
1961 | *
|
1962 | * client.getSpace('<space_id>')
|
1963 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1964 | * .then((environment) => environment.publishRelease({ releaseId: '<release_id>', version: 1 }))
|
1965 | * .catch(console.error)
|
1966 | * ```
|
1967 | */
|
1968 | publishRelease({
|
1969 | releaseId,
|
1970 | version
|
1971 | }) {
|
1972 | const raw = this.toPlainObject();
|
1973 | return makeRequest({
|
1974 | entityType: 'Release',
|
1975 | action: 'publish',
|
1976 | params: {
|
1977 | spaceId: raw.sys.space.sys.id,
|
1978 | environmentId: raw.sys.id,
|
1979 | releaseId,
|
1980 | version
|
1981 | }
|
1982 | }).then(data => wrapReleaseAction(makeRequest, data));
|
1983 | },
|
1984 | /**
|
1985 | * Unpublishes all Entities contained in a Release.
|
1986 | * @param options.releaseId the ID of the release
|
1987 | * @param options.version the version of the release that is to be published
|
1988 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
1989 | *
|
1990 | * @example ```javascript
|
1991 | * const contentful = require('contentful-management')
|
1992 | *
|
1993 | * const client = contentful.createClient({
|
1994 | * accessToken: '<content_management_api_key>'
|
1995 | * })
|
1996 | *
|
1997 | * client.getSpace('<space_id>')
|
1998 | * .then((space) => space.getEnvironment('<environment-id>'))
|
1999 | * .then((environment) => environment.unpublishRelease({ releaseId: '<release_id>', version: 1 }))
|
2000 | * .catch(console.error)
|
2001 | * ```
|
2002 | */
|
2003 | unpublishRelease({
|
2004 | releaseId,
|
2005 | version
|
2006 | }) {
|
2007 | const raw = this.toPlainObject();
|
2008 | return makeRequest({
|
2009 | entityType: 'Release',
|
2010 | action: 'unpublish',
|
2011 | params: {
|
2012 | spaceId: raw.sys.space.sys.id,
|
2013 | environmentId: raw.sys.id,
|
2014 | releaseId,
|
2015 | version
|
2016 | }
|
2017 | }).then(data => wrapReleaseAction(makeRequest, data));
|
2018 | },
|
2019 | /**
|
2020 | * Validates all Entities contained in a Release against an action (publish or unpublish)
|
2021 | * @param options.releaseId the ID of the release
|
2022 | * @param options.payload (optional) the type of action to be validated against
|
2023 | *
|
2024 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
2025 | *
|
2026 | * @example ```javascript
|
2027 | * const contentful = require('contentful-management')
|
2028 | *
|
2029 | * const client = contentful.createClient({
|
2030 | * accessToken: '<content_management_api_key>'
|
2031 | * })
|
2032 | *
|
2033 | * client.getSpace('<space_id>')
|
2034 | * .then((space) => space.getEnvironment('<environment-id>'))
|
2035 | * .then((environment) => environment.validateRelease({ releaseId: '<release_id>', payload: { action: 'unpublish' } }))
|
2036 | * .catch(console.error)
|
2037 | * ```
|
2038 | */
|
2039 | validateRelease({
|
2040 | releaseId,
|
2041 | payload
|
2042 | }) {
|
2043 | const raw = this.toPlainObject();
|
2044 | return makeRequest({
|
2045 | entityType: 'Release',
|
2046 | action: 'validate',
|
2047 | params: {
|
2048 | spaceId: raw.sys.space.sys.id,
|
2049 | environmentId: raw.sys.id,
|
2050 | releaseId
|
2051 | },
|
2052 | payload
|
2053 | }).then(data => wrapReleaseAction(makeRequest, data));
|
2054 | },
|
2055 | /**
|
2056 | * Archives a Release and prevents new operations (publishing, unpublishing adding new entities etc).
|
2057 | * @param options.releaseId the ID of the release
|
2058 | * @param options.version the version of the release that is to be archived
|
2059 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
2060 | *
|
2061 | * @example ```javascript
|
2062 | * const contentful = require('contentful-management')
|
2063 | *
|
2064 | * const client = contentful.createClient({
|
2065 | * accessToken: '<content_management_api_key>'
|
2066 | * })
|
2067 | *
|
2068 | * client.getSpace('<space_id>')
|
2069 | * .then((space) => space.getEnvironment('<environment-id>'))
|
2070 | * .then((environment) => environment.archiveRelease({ releaseId: '<release_id>', version: 1 }))
|
2071 | * .catch(console.error)
|
2072 | * ```
|
2073 | */
|
2074 | archiveRelease({
|
2075 | releaseId,
|
2076 | version
|
2077 | }) {
|
2078 | const raw = this.toPlainObject();
|
2079 | return makeRequest({
|
2080 | entityType: 'Release',
|
2081 | action: 'archive',
|
2082 | params: {
|
2083 | spaceId: raw.sys.space.sys.id,
|
2084 | environmentId: raw.sys.id,
|
2085 | releaseId,
|
2086 | version
|
2087 | }
|
2088 | }).then(data => wrapRelease(makeRequest, data));
|
2089 | },
|
2090 | /**
|
2091 | * Unarchives a previously archived Release - this enables the release to be published, unpublished etc.
|
2092 | * @param options.releaseId the ID of the release
|
2093 | * @param options.version the version of the release that is to be unarchived
|
2094 | * @returns Promise containing a wrapped Release, that has helper methods within.
|
2095 | *
|
2096 | * @example ```javascript
|
2097 | * const contentful = require('contentful-management')
|
2098 | *
|
2099 | * const client = contentful.createClient({
|
2100 | * accessToken: '<content_management_api_key>'
|
2101 | * })
|
2102 | *
|
2103 | * client.getSpace('<space_id>')
|
2104 | * .then((space) => space.getEnvironment('<environment-id>'))
|
2105 | * .then((environment) => environment.unarchiveRelease({ releaseId: '<release_id>', version: 1 }))
|
2106 | * .catch(console.error)
|
2107 | * ```
|
2108 | */
|
2109 | unarchiveRelease({
|
2110 | releaseId,
|
2111 | version
|
2112 | }) {
|
2113 | const raw = this.toPlainObject();
|
2114 | return makeRequest({
|
2115 | entityType: 'Release',
|
2116 | action: 'unarchive',
|
2117 | params: {
|
2118 | spaceId: raw.sys.space.sys.id,
|
2119 | environmentId: raw.sys.id,
|
2120 | releaseId,
|
2121 | version
|
2122 | }
|
2123 | }).then(data => wrapRelease(makeRequest, data));
|
2124 | },
|
2125 | /**
|
2126 | * Retrieves a ReleaseAction by ID
|
2127 | * @param params.releaseId The ID of a Release
|
2128 | * @param params.actionId The ID of a Release Action
|
2129 | * @returns Promise containing a wrapped ReleaseAction
|
2130 | * @example ```javascript
|
2131 | * const contentful = require('contentful-management')
|
2132 | *
|
2133 | * const client = contentful.createClient({
|
2134 | * accessToken: '<content_management_api_key>'
|
2135 | * })
|
2136 | *
|
2137 | * client.getSpace('<space_id>')
|
2138 | * .then((space) => space.getEnvironment('<environment-id>'))
|
2139 | * .then((environment) => environment.getReleaseAction({ releaseId: '<release_id>', actionId: '<action_id>' }))
|
2140 | * .then((releaseAction) => console.log(releaseAction))
|
2141 | * .catch(console.error)
|
2142 | * ```
|
2143 | */
|
2144 | getReleaseAction({
|
2145 | actionId,
|
2146 | releaseId
|
2147 | }) {
|
2148 | const raw = this.toPlainObject();
|
2149 | return makeRequest({
|
2150 | entityType: 'ReleaseAction',
|
2151 | action: 'get',
|
2152 | params: {
|
2153 | actionId,
|
2154 | spaceId: raw.sys.space.sys.id,
|
2155 | environmentId: raw.sys.id,
|
2156 | releaseId
|
2157 | }
|
2158 | }).then(data => wrapReleaseAction(makeRequest, data));
|
2159 | },
|
2160 | /**
|
2161 | * Gets a Collection of ReleaseActions
|
2162 | * @param {string} params.releaseId ID of the Release to fetch the actions from
|
2163 | * @param {ReleaseQueryOptions} params.query filtering options for the collection result
|
2164 | * @returns Promise containing a wrapped ReleaseAction Collection
|
2165 | *
|
2166 | * @example ```javascript
|
2167 | * const contentful = require('contentful-management')
|
2168 | *
|
2169 | * const client = contentful.createClient({
|
2170 | * accessToken: '<content_management_api_key>'
|
2171 | * })
|
2172 | *
|
2173 | * client.getSpace('<space_id>')
|
2174 | * .then((space) => space.getEnvironment('<environment-id>'))
|
2175 | * .then((environment) => environment.getReleaseActions({ query: { 'sys.id[in]': '<id_1>,<id_2>', 'sys.release.sys.id[in]': '<id1>,<id2>' } }))
|
2176 | * .then((releaseActions) => console.log(releaseActions))
|
2177 | * .catch(console.error)
|
2178 | * ```
|
2179 | */
|
2180 | getReleaseActions({
|
2181 | query
|
2182 | }) {
|
2183 | const raw = this.toPlainObject();
|
2184 | return makeRequest({
|
2185 | entityType: 'ReleaseAction',
|
2186 | action: 'getMany',
|
2187 | params: {
|
2188 | spaceId: raw.sys.space.sys.id,
|
2189 | environmentId: raw.sys.id,
|
2190 | query
|
2191 | }
|
2192 | }).then(data => wrapReleaseActionCollection(makeRequest, data));
|
2193 | },
|
2194 | async getUIConfig() {
|
2195 | const raw = this.toPlainObject();
|
2196 | const data = await makeRequest({
|
2197 | entityType: 'UIConfig',
|
2198 | action: 'get',
|
2199 | params: {
|
2200 | spaceId: raw.sys.space.sys.id,
|
2201 | environmentId: raw.sys.id
|
2202 | }
|
2203 | });
|
2204 | return wrapUIConfig(makeRequest, data);
|
2205 | },
|
2206 | async getUserUIConfig() {
|
2207 | const raw = this.toPlainObject();
|
2208 | const data = await makeRequest({
|
2209 | entityType: 'UserUIConfig',
|
2210 | action: 'get',
|
2211 | params: {
|
2212 | spaceId: raw.sys.space.sys.id,
|
2213 | environmentId: raw.sys.id
|
2214 | }
|
2215 | });
|
2216 | return wrapUserUIConfig(makeRequest, data);
|
2217 | },
|
2218 | /**
|
2219 | * Gets a collection of all environment template installations in the environment for a given template
|
2220 | * @param environmentTemplateId - Environment template ID to return installations for
|
2221 | * @param [options.installationId] - Installation ID to filter for a specific installation
|
2222 | * @return Promise for a collection of EnvironmentTemplateInstallations
|
2223 | * ```javascript
|
2224 | * const contentful = require('contentful-management')
|
2225 | *
|
2226 | * const client = contentful.createClient({
|
2227 | * accessToken: '<content_management_api_key>'
|
2228 | * })
|
2229 | *
|
2230 | * client.getSpace('<space_id>')
|
2231 | * .then((space) => space.getEnvironment('<environment_id>'))
|
2232 | * .then((environment) => environment.getEnvironmentTemplateInstallations('<environment_template_id>'))
|
2233 | * .then((installations) => console.log(installations.items))
|
2234 | * .catch(console.error)
|
2235 | * ```
|
2236 | */
|
2237 | async getEnvironmentTemplateInstallations(environmentTemplateId, _ref = {}) {
|
2238 | let {
|
2239 | installationId
|
2240 | } = _ref,
|
2241 | query = _objectWithoutProperties(_ref, _excluded);
|
2242 | const raw = this.toPlainObject();
|
2243 | return makeRequest({
|
2244 | entityType: 'EnvironmentTemplateInstallation',
|
2245 | action: 'getForEnvironment',
|
2246 | params: _objectSpread(_objectSpread({
|
2247 | environmentTemplateId
|
2248 | }, installationId && {
|
2249 | installationId
|
2250 | }), {}, {
|
2251 | query: _objectSpread({}, createRequestConfig({
|
2252 | query
|
2253 | }).params),
|
2254 | spaceId: raw.sys.space.sys.id,
|
2255 | environmentId: raw.sys.id
|
2256 | })
|
2257 | }).then(data => wrapEnvironmentTemplateInstallationCollection(makeRequest, data));
|
2258 | },
|
2259 | /**
|
2260 | * Gets a collection of all resource types based on native external references app installations in the environment
|
2261 | * @param query - BasicCursorPaginationOptions
|
2262 | * @return Promise for a collection of ResourceTypes
|
2263 | * ```javascript
|
2264 | * const contentful = require('contentful-management')
|
2265 | *
|
2266 | * const client = contentful.createClient({
|
2267 | * accessToken: '<content_management_api_key>'
|
2268 | * })
|
2269 | *
|
2270 | * client.getSpace('<space_id>')
|
2271 | * .then((space) => space.getEnvironment('<environment_id>'))
|
2272 | * .then((environment) => environment.getResourceTypes({limit: 10}))
|
2273 | * .then((installations) => console.log(installations.items))
|
2274 | * .catch(console.error)
|
2275 | * ```
|
2276 | */
|
2277 | async getResourceTypes(query) {
|
2278 | const raw = this.toPlainObject();
|
2279 | return makeRequest({
|
2280 | entityType: 'ResourceType',
|
2281 | action: 'getForEnvironment',
|
2282 | params: {
|
2283 | query,
|
2284 | spaceId: raw.sys.space.sys.id,
|
2285 | environmentId: raw.sys.id
|
2286 | }
|
2287 | }).then(data => wrapResourceTypesForEnvironmentCollection(makeRequest, data));
|
2288 | },
|
2289 | /**
|
2290 | * Gets a collection of all resources for a given resource type based on native external references app installations in the environment
|
2291 | * @param resourceTypeId - Id of the resourceType to get its resources
|
2292 | * @param query - Either LookupQuery options with 'sys.urn[in]' param or a Search query with 'query' param, in both cases you can add pagination options
|
2293 | * @return Promise for a collection of Resources for a given resourceTypeId
|
2294 | * ```javascript
|
2295 | * const contentful = require('contentful-management')
|
2296 | *
|
2297 | * const client = contentful.createClient({
|
2298 | * accessToken: '<content_management_api_key>'
|
2299 | * })
|
2300 | *
|
2301 | * // Search Query
|
2302 | * client.getSpace('<space_id>')
|
2303 | * .then((space) => space.getEnvironment('<environment_id>'))
|
2304 | * // <search_query> is a string you want to search for in the external resources
|
2305 | * .then((environment) => environment.getResourcesForResourceType('<resource_type_id>', {query: '<search_query>', limit: 10}))
|
2306 | * .then((installations) => console.log(installations.items))
|
2307 | * .catch(console.error)
|
2308 | *
|
2309 | * // Lookup query
|
2310 | *
|
2311 | * client.getSpace('<space_id>')
|
2312 | * .then((space) => space.getEnvironment('<environment_id>'))
|
2313 | * .then((environment) => environment.getResourcesForResourceType('<resource_type_id>', {'sys.urn[in]': '<resource_urn1>,<resource_urn2>', limit: 10}))
|
2314 | * .then((installations) => console.log(installations.items))
|
2315 | * .catch(console.error)
|
2316 | * ```
|
2317 | */
|
2318 | async getResourcesForResourceType(resourceTypeId, query) {
|
2319 | const raw = this.toPlainObject();
|
2320 | return makeRequest({
|
2321 | entityType: 'Resource',
|
2322 | action: 'getMany',
|
2323 | params: {
|
2324 | query,
|
2325 | spaceId: raw.sys.space.sys.id,
|
2326 | environmentId: raw.sys.id,
|
2327 | resourceTypeId
|
2328 | }
|
2329 | }).then(data => wrapResourceCollection(makeRequest, data));
|
2330 | }
|
2331 | };
|
2332 | } |
\ | No newline at end of file |