contentful-management 12.0.0-beta.1 → 12.0.0-beta.3

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.
Files changed (172) hide show
  1. package/README.md +3 -0
  2. package/dist/cjs/adapters/REST/endpoints/access-token.cjs +136 -0
  3. package/dist/cjs/adapters/REST/endpoints/ai-action-invocation.cjs +9 -0
  4. package/dist/cjs/adapters/REST/endpoints/ai-action.cjs +53 -0
  5. package/dist/cjs/adapters/REST/endpoints/api-key.cjs +48 -0
  6. package/dist/cjs/adapters/REST/endpoints/app-access-token.cjs +9 -0
  7. package/dist/cjs/adapters/REST/endpoints/app-action-call.cjs +65 -0
  8. package/dist/cjs/adapters/REST/endpoints/app-action.cjs +42 -0
  9. package/dist/cjs/adapters/REST/endpoints/app-bundle.cjs +39 -0
  10. package/dist/cjs/adapters/REST/endpoints/app-definition.cjs +47 -0
  11. package/dist/cjs/adapters/REST/endpoints/app-details.cjs +17 -0
  12. package/dist/cjs/adapters/REST/endpoints/app-event-subscription.cjs +17 -0
  13. package/dist/cjs/adapters/REST/endpoints/app-installation.cjs +42 -0
  14. package/dist/cjs/adapters/REST/endpoints/app-key.cjs +21 -0
  15. package/dist/cjs/adapters/REST/endpoints/app-signed-request.cjs +9 -0
  16. package/dist/cjs/adapters/REST/endpoints/app-signing-secret.cjs +17 -0
  17. package/dist/cjs/adapters/REST/endpoints/app-upload.cjs +28 -0
  18. package/dist/cjs/adapters/REST/endpoints/asset-key.cjs +34 -0
  19. package/dist/cjs/adapters/REST/endpoints/asset.cjs +185 -0
  20. package/dist/cjs/adapters/REST/endpoints/bulk-action.cjs +21 -0
  21. package/dist/cjs/adapters/REST/endpoints/comment.cjs +92 -0
  22. package/dist/cjs/adapters/REST/endpoints/concept-scheme.cjs +44 -0
  23. package/dist/cjs/adapters/REST/endpoints/concept.cjs +65 -0
  24. package/dist/cjs/adapters/REST/endpoints/content-type.cjs +56 -0
  25. package/dist/cjs/adapters/REST/endpoints/editor-interface.cjs +24 -0
  26. package/dist/cjs/adapters/REST/endpoints/entry.cjs +104 -0
  27. package/dist/cjs/adapters/REST/endpoints/environment-alias.cjs +44 -0
  28. package/dist/cjs/adapters/REST/endpoints/environment-template-installation.cjs +23 -0
  29. package/dist/cjs/adapters/REST/endpoints/environment-template.cjs +49 -0
  30. package/dist/cjs/adapters/REST/endpoints/environment.cjs +47 -0
  31. package/dist/cjs/adapters/REST/endpoints/extension.cjs +44 -0
  32. package/dist/cjs/adapters/REST/endpoints/function-log.cjs +23 -0
  33. package/dist/cjs/adapters/REST/endpoints/function.cjs +25 -0
  34. package/dist/cjs/adapters/REST/endpoints/http.cjs +29 -0
  35. package/dist/cjs/adapters/REST/endpoints/index.cjs +139 -0
  36. package/dist/cjs/adapters/REST/endpoints/locale.cjs +37 -0
  37. package/dist/cjs/adapters/REST/endpoints/oauth-application.cjs +147 -0
  38. package/dist/cjs/adapters/REST/endpoints/organization-invitation.cjs +23 -0
  39. package/dist/cjs/adapters/REST/endpoints/organization-membership.cjs +32 -0
  40. package/dist/cjs/adapters/REST/endpoints/organization.cjs +28 -0
  41. package/dist/cjs/adapters/REST/endpoints/personal-access-token.cjs +37 -0
  42. package/dist/cjs/adapters/REST/endpoints/preview-api-key.cjs +15 -0
  43. package/dist/cjs/adapters/REST/endpoints/raw.cjs +44 -0
  44. package/dist/cjs/adapters/REST/endpoints/release-action.cjs +21 -0
  45. package/dist/cjs/adapters/REST/endpoints/release.cjs +61 -0
  46. package/dist/cjs/adapters/REST/endpoints/resource-provider.cjs +18 -0
  47. package/dist/cjs/adapters/REST/endpoints/resource-type.cjs +30 -0
  48. package/dist/cjs/adapters/REST/endpoints/resource.cjs +10 -0
  49. package/dist/cjs/adapters/REST/endpoints/role.cjs +48 -0
  50. package/dist/cjs/adapters/REST/endpoints/scheduled-action.cjs +44 -0
  51. package/dist/cjs/adapters/REST/endpoints/snapshot.cjs +30 -0
  52. package/dist/cjs/adapters/REST/endpoints/space-member.cjs +11 -0
  53. package/dist/cjs/adapters/REST/endpoints/space-membership.cjs +60 -0
  54. package/dist/cjs/adapters/REST/endpoints/space.cjs +34 -0
  55. package/dist/cjs/adapters/REST/endpoints/tag.cjs +37 -0
  56. package/dist/cjs/adapters/REST/endpoints/task.cjs +40 -0
  57. package/dist/cjs/adapters/REST/endpoints/team-membership.cjs +35 -0
  58. package/dist/cjs/adapters/REST/endpoints/team-space-membership.cjs +46 -0
  59. package/dist/cjs/adapters/REST/endpoints/team.cjs +36 -0
  60. package/dist/cjs/adapters/REST/endpoints/ui-config.cjs +22 -0
  61. package/dist/cjs/adapters/REST/endpoints/upload-credentials.cjs +16 -0
  62. package/dist/cjs/adapters/REST/endpoints/upload.cjs +42 -0
  63. package/dist/cjs/adapters/REST/endpoints/usage.cjs +17 -0
  64. package/dist/cjs/adapters/REST/endpoints/user-ui-config.cjs +22 -0
  65. package/dist/cjs/adapters/REST/endpoints/user.cjs +27 -0
  66. package/dist/cjs/adapters/REST/endpoints/utils.cjs +20 -0
  67. package/dist/cjs/adapters/REST/endpoints/webhook.cjs +98 -0
  68. package/dist/cjs/adapters/REST/endpoints/workflow-definition.cjs +41 -0
  69. package/dist/cjs/adapters/REST/endpoints/workflow.cjs +49 -0
  70. package/dist/cjs/adapters/REST/endpoints/workflows-changelog.cjs +11 -0
  71. package/dist/cjs/adapters/REST/make-request.cjs +19 -0
  72. package/dist/cjs/adapters/REST/rest-adapter.cjs +32 -0
  73. package/dist/cjs/common-types.cjs +6 -0
  74. package/dist/cjs/common-utils.cjs +38 -0
  75. package/dist/cjs/constants/editor-interface-defaults/controls-defaults.cjs +161 -0
  76. package/dist/cjs/constants/editor-interface-defaults/editors-defaults.cjs +40 -0
  77. package/dist/cjs/constants/editor-interface-defaults/index.cjs +14 -0
  78. package/dist/cjs/constants/editor-interface-defaults/sidebar-defaults.cjs +71 -0
  79. package/dist/cjs/constants/editor-interface-defaults/types.cjs +18 -0
  80. package/dist/cjs/create-adapter.cjs +21 -0
  81. package/dist/cjs/create-app-definition-api.cjs +254 -0
  82. package/dist/cjs/create-contentful-api.cjs +592 -0
  83. package/dist/cjs/create-entry-api.cjs +481 -0
  84. package/dist/cjs/create-environment-api.cjs +2403 -0
  85. package/dist/cjs/create-environment-template-api.cjs +270 -0
  86. package/dist/cjs/create-organization-api.cjs +1136 -0
  87. package/dist/cjs/create-space-api.cjs +1591 -0
  88. package/dist/cjs/create-ui-config-api.cjs +55 -0
  89. package/dist/cjs/create-user-ui-config-api.cjs +55 -0
  90. package/dist/cjs/enhance-with-methods.cjs +26 -0
  91. package/dist/cjs/entities/access-token.cjs +36 -0
  92. package/dist/cjs/entities/ai-action-invocation.cjs +46 -0
  93. package/dist/cjs/entities/ai-action.cjs +94 -0
  94. package/dist/cjs/entities/api-key.cjs +59 -0
  95. package/dist/cjs/entities/app-access-token.cjs +17 -0
  96. package/dist/cjs/entities/app-action-call.cjs +67 -0
  97. package/dist/cjs/entities/app-action.cjs +48 -0
  98. package/dist/cjs/entities/app-bundle.cjs +48 -0
  99. package/dist/cjs/entities/app-definition.cjs +29 -0
  100. package/dist/cjs/entities/app-details.cjs +39 -0
  101. package/dist/cjs/entities/app-event-subscription.cjs +34 -0
  102. package/dist/cjs/entities/app-installation.cjs +55 -0
  103. package/dist/cjs/entities/app-key.cjs +44 -0
  104. package/dist/cjs/entities/app-signed-request.cjs +17 -0
  105. package/dist/cjs/entities/app-signing-secret.cjs +34 -0
  106. package/dist/cjs/entities/app-upload.cjs +47 -0
  107. package/dist/cjs/entities/asset-key.cjs +17 -0
  108. package/dist/cjs/entities/asset.cjs +124 -0
  109. package/dist/cjs/entities/bulk-action.cjs +60 -0
  110. package/dist/cjs/entities/comment.cjs +63 -0
  111. package/dist/cjs/entities/concept-scheme.cjs +2 -0
  112. package/dist/cjs/entities/concept.cjs +2 -0
  113. package/dist/cjs/entities/content-type.cjs +120 -0
  114. package/dist/cjs/entities/editor-interface.cjs +50 -0
  115. package/dist/cjs/entities/entry.cjs +27 -0
  116. package/dist/cjs/entities/environment-alias.cjs +58 -0
  117. package/dist/cjs/entities/environment-template-installation.cjs +23 -0
  118. package/dist/cjs/entities/environment-template.cjs +18 -0
  119. package/dist/cjs/entities/environment.cjs +34 -0
  120. package/dist/cjs/entities/extension.cjs +54 -0
  121. package/dist/cjs/entities/function-log.cjs +26 -0
  122. package/dist/cjs/entities/function.cjs +66 -0
  123. package/dist/cjs/entities/index.cjs +131 -0
  124. package/dist/cjs/entities/locale.cjs +57 -0
  125. package/dist/cjs/entities/oauth-application.cjs +66 -0
  126. package/dist/cjs/entities/organization-invitation.cjs +17 -0
  127. package/dist/cjs/entities/organization-membership.cjs +53 -0
  128. package/dist/cjs/entities/organization.cjs +32 -0
  129. package/dist/cjs/entities/personal-access-token.cjs +36 -0
  130. package/dist/cjs/entities/preview-api-key.cjs +31 -0
  131. package/dist/cjs/entities/release-action.cjs +55 -0
  132. package/dist/cjs/entities/release.cjs +111 -0
  133. package/dist/cjs/entities/resource-provider.cjs +139 -0
  134. package/dist/cjs/entities/resource-type.cjs +98 -0
  135. package/dist/cjs/entities/resource.cjs +13 -0
  136. package/dist/cjs/entities/role.cjs +53 -0
  137. package/dist/cjs/entities/scheduled-action.cjs +154 -0
  138. package/dist/cjs/entities/snapshot.cjs +36 -0
  139. package/dist/cjs/entities/space-member.cjs +23 -0
  140. package/dist/cjs/entities/space-membership.cjs +53 -0
  141. package/dist/cjs/entities/space.cjs +33 -0
  142. package/dist/cjs/entities/tag.cjs +56 -0
  143. package/dist/cjs/entities/task.cjs +57 -0
  144. package/dist/cjs/entities/team-membership.cjs +54 -0
  145. package/dist/cjs/entities/team-space-membership.cjs +53 -0
  146. package/dist/cjs/entities/team.cjs +53 -0
  147. package/dist/cjs/entities/ui-config.cjs +20 -0
  148. package/dist/cjs/entities/upload.cjs +38 -0
  149. package/dist/cjs/entities/usage.cjs +25 -0
  150. package/dist/cjs/entities/user-ui-config.cjs +20 -0
  151. package/dist/cjs/entities/user.cjs +28 -0
  152. package/dist/cjs/entities/webhook.cjs +77 -0
  153. package/dist/cjs/entities/workflow-definition.cjs +79 -0
  154. package/dist/cjs/index.cjs +65 -0
  155. package/dist/cjs/methods/action.cjs +53 -0
  156. package/dist/cjs/methods/content-type.cjs +51 -0
  157. package/dist/cjs/methods/utils.cjs +11 -0
  158. package/dist/cjs/plain/as-iterator.cjs +32 -0
  159. package/dist/cjs/plain/checks.cjs +15 -0
  160. package/dist/cjs/plain/pagination-helper.cjs +56 -0
  161. package/dist/cjs/plain/plain-client.cjs +516 -0
  162. package/dist/cjs/plain/wrappers/wrap.cjs +26 -0
  163. package/dist/cjs/upload-http-client.cjs +17 -0
  164. package/dist/contentful-management.browser.js +50 -34
  165. package/dist/contentful-management.browser.min.js +1 -1
  166. package/dist/contentful-management.cjs +35 -19
  167. package/dist/esm/create-contentful-api.js +1 -1
  168. package/dist/esm/index.js +1 -1
  169. package/dist/esm/plain/plain-client.js +1 -1
  170. package/dist/stats-browser-min.html +1 -1
  171. package/package.json +6 -6
  172. package/types.d.ts +0 -1
@@ -0,0 +1,1591 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var index = require('./entities/index.js');
5
+
6
+ /**
7
+ * Contentful Space API. Contains methods to access any operations at a space
8
+ * level, such as creating and reading entities contained in a space.
9
+ */
10
+ /**
11
+ * Creates API object with methods to access the Space API
12
+ * @param {MakeRequest} makeRequest - function to make requests via an adapter
13
+ * @return {ContentfulSpaceAPI}
14
+ * @private
15
+ */
16
+ function createSpaceApi(makeRequest) {
17
+ const { wrapSpace } = index.space;
18
+ const { wrapEnvironment, wrapEnvironmentCollection } = index.environment;
19
+ const { wrapWebhook, wrapWebhookCollection } = index.webhook;
20
+ const { wrapRole, wrapRoleCollection } = index.role;
21
+ const { wrapUser, wrapUserCollection } = index.user;
22
+ const { wrapSpaceMember, wrapSpaceMemberCollection } = index.spaceMember;
23
+ const { wrapSpaceMembership, wrapSpaceMembershipCollection } = index.spaceMembership;
24
+ const { wrapTeamSpaceMembership, wrapTeamSpaceMembershipCollection } = index.teamSpaceMembership;
25
+ const { wrapTeamCollection } = index.team;
26
+ const { wrapApiKey, wrapApiKeyCollection } = index.apiKey;
27
+ const { wrapEnvironmentAlias, wrapEnvironmentAliasCollection } = index.environmentAlias;
28
+ const { wrapPreviewApiKey, wrapPreviewApiKeyCollection } = index.previewApiKey;
29
+ const { wrapScheduledAction, wrapScheduledActionCollection } = index.scheduledAction;
30
+ const { wrapAiAction, wrapAiActionCollection } = index.aiAction;
31
+ return {
32
+ /**
33
+ * Deletes the space
34
+ * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
35
+ * @example ```javascript
36
+ * const contentful = require('contentful-management')
37
+ *
38
+ * const client = contentful.createClient({
39
+ * accessToken: '<content_management_api_key>'
40
+ * })
41
+ *
42
+ * client.getSpace('<space_id>')
43
+ * .then((space) => space.delete())
44
+ * .then(() => console.log('Space deleted.'))
45
+ * .catch(console.error)
46
+ * ```
47
+ */
48
+ delete: function deleteSpace() {
49
+ const raw = this.toPlainObject();
50
+ return makeRequest({
51
+ entityType: 'Space',
52
+ action: 'delete',
53
+ params: { spaceId: raw.sys.id },
54
+ });
55
+ },
56
+ /**
57
+ * Updates the space
58
+ * @return Promise for the updated space.
59
+ * @example ```javascript
60
+ * const contentful = require('contentful-management')
61
+ *
62
+ * const client = contentful.createClient({
63
+ * accessToken: '<content_management_api_key>'
64
+ * })
65
+ *
66
+ * client.getSpace('<space_id>')
67
+ * .then((space) => {
68
+ * space.name = 'New name'
69
+ * return space.update()
70
+ * })
71
+ * .then((space) => console.log(`Space ${space.sys.id} renamed.`)
72
+ * .catch(console.error)
73
+ * ```
74
+ */
75
+ update: function updateSpace() {
76
+ const raw = this.toPlainObject();
77
+ return makeRequest({
78
+ entityType: 'Space',
79
+ action: 'update',
80
+ params: { spaceId: raw.sys.id },
81
+ payload: raw,
82
+ headers: {},
83
+ }).then((data) => wrapSpace(makeRequest, data));
84
+ },
85
+ /**
86
+ * Gets an environment
87
+ * @param id - Environment ID
88
+ * @return Promise for an Environment
89
+ * @example ```javascript
90
+ * const contentful = require('contentful-management')
91
+ *
92
+ * const client = contentful.createClient({
93
+ * accessToken: '<content_management_api_key>'
94
+ * })
95
+ *
96
+ * client.getSpace('<space_id>')
97
+ * .then((space) => space.getEnvironment('<environment_id>'))
98
+ * .then((environment) => console.log(environment))
99
+ * .catch(console.error)
100
+ * ```
101
+ */
102
+ getEnvironment(environmentId) {
103
+ const raw = this.toPlainObject();
104
+ return makeRequest({
105
+ entityType: 'Environment',
106
+ action: 'get',
107
+ params: { spaceId: raw.sys.id, environmentId },
108
+ }).then((data) => wrapEnvironment(makeRequest, data));
109
+ },
110
+ /**
111
+ * Gets a collection of Environments
112
+ * @return Promise for a collection of Environment
113
+ * @example ```javascript
114
+ * const contentful = require('contentful-management')
115
+ *
116
+ * const client = contentful.createClient({
117
+ * accessToken: '<content_management_api_key>'
118
+ * })
119
+ *
120
+ * client.getSpace('<space_id>')
121
+ * .then((space) => space.getEnvironments())
122
+ * .then((response) => console.log(response.items))
123
+ * .catch(console.error)
124
+ * ```
125
+ */
126
+ getEnvironments(query = {}) {
127
+ const raw = this.toPlainObject();
128
+ return makeRequest({
129
+ entityType: 'Environment',
130
+ action: 'getMany',
131
+ params: { spaceId: raw.sys.id, query },
132
+ }).then((data) => wrapEnvironmentCollection(makeRequest, data));
133
+ },
134
+ /**
135
+ * Creates an environment
136
+ * @param data - Object representation of the Environment to be created
137
+ * @return Promise for the newly created Environment
138
+ * @example ```javascript
139
+ * const contentful = require('contentful-management')
140
+ *
141
+ * const client = contentful.createClient({
142
+ * accessToken: '<content_management_api_key>'
143
+ * })
144
+ *
145
+ * client.getSpace('<space_id>')
146
+ * .then((space) => space.createEnvironment({ name: 'Staging' }))
147
+ * .then((environment) => console.log(environment))
148
+ * .catch(console.error)
149
+ * ```
150
+ */
151
+ createEnvironment(data = {}) {
152
+ const raw = this.toPlainObject();
153
+ return makeRequest({
154
+ entityType: 'Environment',
155
+ action: 'create',
156
+ params: {
157
+ spaceId: raw.sys.id,
158
+ },
159
+ payload: data,
160
+ }).then((response) => wrapEnvironment(makeRequest, response));
161
+ },
162
+ /**
163
+ * Creates an Environment with a custom ID
164
+ * @param id - Environment ID
165
+ * @param data - Object representation of the Environment to be created
166
+ * @param sourceEnvironmentId - ID of the source environment that will be copied to create the new environment. Default is "master"
167
+ * @return Promise for the newly created Environment
168
+ * @example ```javascript
169
+ * const contentful = require('contentful-management')
170
+ *
171
+ * const client = contentful.createClient({
172
+ * accessToken: '<content_management_api_key>'
173
+ * })
174
+ *
175
+ * client.getSpace('<space_id>')
176
+ * .then((space) => space.createEnvironmentWithId('<environment-id>', { name: 'Staging'}, 'master'))
177
+ * .then((environment) => console.log(environment))
178
+ * .catch(console.error)
179
+ * ```
180
+ */
181
+ createEnvironmentWithId(id, data, sourceEnvironmentId) {
182
+ const raw = this.toPlainObject();
183
+ return makeRequest({
184
+ entityType: 'Environment',
185
+ action: 'createWithId',
186
+ params: {
187
+ spaceId: raw.sys.id,
188
+ environmentId: id,
189
+ sourceEnvironmentId,
190
+ },
191
+ payload: data,
192
+ }).then((response) => wrapEnvironment(makeRequest, response));
193
+ },
194
+ /**
195
+ * Gets a Webhook
196
+ * @param id - Webhook ID
197
+ * @return Promise for a Webhook
198
+ * @example ```javascript
199
+ * const contentful = require('contentful-management')
200
+ *
201
+ * const client = contentful.createClient({
202
+ * accessToken: '<content_management_api_key>'
203
+ * })
204
+ *
205
+ * client.getSpace('<space_id>')
206
+ * .then((space) => space.getWebhook('<webhook_id>'))
207
+ * .then((webhook) => console.log(webhook))
208
+ * .catch(console.error)
209
+ * ```
210
+ */
211
+ getWebhook(id) {
212
+ const raw = this.toPlainObject();
213
+ return makeRequest({
214
+ entityType: 'Webhook',
215
+ action: 'get',
216
+ params: { spaceId: raw.sys.id, webhookDefinitionId: id },
217
+ }).then((data) => wrapWebhook(makeRequest, data));
218
+ },
219
+ /**
220
+ * Gets a collection of Webhooks
221
+ * @return Promise for a collection of Webhooks
222
+ * @example ```javascript
223
+ * const contentful = require('contentful-management')
224
+ *
225
+ * const client = contentful.createClient({
226
+ * accessToken: '<content_management_api_key>'
227
+ * })
228
+ *
229
+ * client.getSpace('<space_id>')
230
+ * .then((space) => space.getWebhooks())
231
+ * .then((response) => console.log(response.items))
232
+ * .catch(console.error)
233
+ * ```
234
+ */
235
+ getWebhooks() {
236
+ const raw = this.toPlainObject();
237
+ return makeRequest({
238
+ entityType: 'Webhook',
239
+ action: 'getMany',
240
+ params: { spaceId: raw.sys.id },
241
+ }).then((data) => wrapWebhookCollection(makeRequest, data));
242
+ },
243
+ /**
244
+ * Fetch a webhook signing secret
245
+ * @returns Promise for the redacted webhook signing secret in this space
246
+ * @example ```javascript
247
+ * const contentful = require('contentful-management')
248
+ *
249
+ * const client = contentful.createClient({
250
+ * accessToken: '<content_management_api_key>'
251
+ * })
252
+ *
253
+ * client.getSpace('<space_id>')
254
+ * .then((space) => space.getWebhookSigningSecret())
255
+ * .then((response) => console.log(response.redactedValue))
256
+ * .catch(console.error)
257
+ * ```
258
+ */
259
+ getWebhookSigningSecret: function getSigningSecret() {
260
+ const raw = this.toPlainObject();
261
+ return makeRequest({
262
+ entityType: 'Webhook',
263
+ action: 'getSigningSecret',
264
+ params: { spaceId: raw.sys.id },
265
+ });
266
+ },
267
+ /**
268
+ * Fetch a webhook retry policy
269
+ * @returns Promise for the redacted webhook retry policy in this space
270
+ * @example ```javascript
271
+ * const contentful = require('contentful-management')
272
+ *
273
+ * const client = contentful.createClient({
274
+ * accessToken: '<content_management_api_key>'
275
+ * })
276
+ *
277
+ * client.getSpace('<space_id>')
278
+ * .then((space) => space.getRetryPolicy())
279
+ * .then((response) => console.log(response.redactedValue))
280
+ * .catch(console.error)
281
+ * ```
282
+ */
283
+ getWebhookRetryPolicy: function getWebhookRetryPolicy() {
284
+ const raw = this.toPlainObject();
285
+ return makeRequest({
286
+ entityType: 'Webhook',
287
+ action: 'getRetryPolicy',
288
+ params: { spaceId: raw.sys.id },
289
+ });
290
+ },
291
+ /**
292
+ * Creates a Webhook
293
+ * @param data - Object representation of the Webhook to be created
294
+ * @return Promise for the newly created Webhook
295
+ * @example ```javascript
296
+ * const contentful = require('contentful-management')
297
+ *
298
+ * client.getSpace('<space_id>')
299
+ * .then((space) => space.createWebhook({
300
+ * 'name': 'My webhook',
301
+ * 'url': 'https://www.example.com/test',
302
+ * 'topics': [
303
+ * 'Entry.create',
304
+ * 'ContentType.create',
305
+ * '*.publish',
306
+ * 'Asset.*'
307
+ * ]
308
+ * }))
309
+ * .then((webhook) => console.log(webhook))
310
+ * .catch(console.error)
311
+ * ```
312
+ */
313
+ createWebhook(data) {
314
+ const raw = this.toPlainObject();
315
+ return makeRequest({
316
+ entityType: 'Webhook',
317
+ action: 'create',
318
+ params: { spaceId: raw.sys.id },
319
+ payload: data,
320
+ }).then((data) => wrapWebhook(makeRequest, data));
321
+ },
322
+ /**
323
+ * Creates a Webhook with a custom ID
324
+ * @param id - Webhook ID
325
+ * @param data - Object representation of the Webhook to be created
326
+ * @return Promise for the newly created Webhook
327
+ * @example ```javascript
328
+ * const contentful = require('contentful-management')
329
+ *
330
+ * client.getSpace('<space_id>')
331
+ * .then((space) => space.createWebhookWithId('<webhook_id>', {
332
+ * 'name': 'My webhook',
333
+ * 'url': 'https://www.example.com/test',
334
+ * 'topics': [
335
+ * 'Entry.create',
336
+ * 'ContentType.create',
337
+ * '*.publish',
338
+ * 'Asset.*'
339
+ * ]
340
+ * }))
341
+ * .then((webhook) => console.log(webhook))
342
+ * .catch(console.error)
343
+ * ```
344
+ */
345
+ createWebhookWithId(id, data) {
346
+ const raw = this.toPlainObject();
347
+ return makeRequest({
348
+ entityType: 'Webhook',
349
+ action: 'createWithId',
350
+ params: { spaceId: raw.sys.id, webhookDefinitionId: id },
351
+ payload: data,
352
+ }).then((data) => wrapWebhook(makeRequest, data));
353
+ },
354
+ /**
355
+ * Create or update the webhook signing secret for this space
356
+ * @param data 64 character string that will be used to sign the webhook calls
357
+ * @returns Promise for the redacted webhook signing secret that was created or updated
358
+ * @example ```javascript
359
+ * const contentful = require('contentful-management')
360
+ * const crypto = require('crypto')
361
+ *
362
+ * const client = contentful.createClient({
363
+ * accessToken: '<content_management_api_key>'
364
+ * })
365
+ *
366
+ * const signingSecret = client.getSpace('<space_id>')
367
+ * .then((space) => space.upsertWebhookSigningSecret({
368
+ * value: crypto.randomBytes(32).toString('hex')
369
+ * }))
370
+ * .then((response) => console.log(response.redactedValue))
371
+ * .catch(console.error)
372
+ * ```
373
+ */
374
+ upsertWebhookSigningSecret: function getSigningSecret(data) {
375
+ const raw = this.toPlainObject();
376
+ return makeRequest({
377
+ entityType: 'Webhook',
378
+ action: 'upsertSigningSecret',
379
+ params: { spaceId: raw.sys.id },
380
+ payload: data,
381
+ });
382
+ },
383
+ /**
384
+ * Create or update the webhook retry policy for this space
385
+ * @param data the maxRetries with integer value >= 2 and <= 99 value to set in the Retry Policy
386
+ * @returns Promise for the redacted webhook retry policy that was created or updated
387
+ * @example ```javascript
388
+ * const contentful = require('contentful-management')
389
+ *
390
+ * const client = contentful.createClient({
391
+ * accessToken: '<content_management_api_key>'
392
+ * })
393
+ *
394
+ * const retryPolicy = client.getSpace('<space_id>')
395
+ * .then((space) => space.upsertWebhookRetryPolicy({
396
+ * maxRetries: 15
397
+ * }))
398
+ * .then((response) => console.log(response.redactedValue))
399
+ * .catch(console.error)
400
+ * ```
401
+ */
402
+ upsertWebhookRetryPolicy: function upsertWebhookRetryPolicy(data) {
403
+ const raw = this.toPlainObject();
404
+ return makeRequest({
405
+ entityType: 'Webhook',
406
+ action: 'upsertRetryPolicy',
407
+ params: { spaceId: raw.sys.id },
408
+ payload: data,
409
+ });
410
+ },
411
+ /**
412
+ * Delete the webhook signing secret for this space
413
+ * @returns Promise<void>
414
+ * @example ```javascript
415
+ * const contentful = require('contentful-management')
416
+ *
417
+ * const client = contentful.createClient({
418
+ * accessToken: '<content_management_api_key>'
419
+ * })
420
+ *
421
+ * client.getSpace('<space_id>')
422
+ * .then((space) => space.deleteWebhookSigningSecret())
423
+ * .then(() => console.log("success"))
424
+ * .catch(console.error)
425
+ * ```
426
+ */
427
+ deleteWebhookSigningSecret: function getSigningSecret() {
428
+ const raw = this.toPlainObject();
429
+ return makeRequest({
430
+ entityType: 'Webhook',
431
+ action: 'deleteSigningSecret',
432
+ params: { spaceId: raw.sys.id },
433
+ });
434
+ },
435
+ /**
436
+ * Delete the webhook retry policy for this space
437
+ * @returns Promise<void>
438
+ * @example ```javascript
439
+ * const contentful = require('contentful-management')
440
+ *
441
+ * const client = contentful.createClient({
442
+ * accessToken: '<content_management_api_key>'
443
+ * })
444
+ *
445
+ * client.getSpace('<space_id>')
446
+ * .then((space) => space.deleteWebhookRetryPolicy())
447
+ * .then(() => console.log("success"))
448
+ * .catch(console.error)
449
+ * ```
450
+ */
451
+ deleteWebhookRetryPolicy: function deleteRetryPolicy() {
452
+ const raw = this.toPlainObject();
453
+ return makeRequest({
454
+ entityType: 'Webhook',
455
+ action: 'deleteRetryPolicy',
456
+ params: { spaceId: raw.sys.id },
457
+ });
458
+ },
459
+ /**
460
+ * Gets a Role
461
+ * @param id - Role ID
462
+ * @return Promise for a Role
463
+ * @example ```javascript
464
+ * const contentful = require('contentful-management')
465
+ *
466
+ * const client = contentful.createClient({
467
+ * accessToken: '<content_management_api_key>'
468
+ * })
469
+ *
470
+ * client.getSpace('<space_id>')
471
+ * .then((space) => space.createRole({
472
+ * fields: {
473
+ * title: {
474
+ * 'en-US': 'Role title'
475
+ * }
476
+ * }
477
+ * }))
478
+ * .then((role) => console.log(role))
479
+ * .catch(console.error)
480
+ * ```
481
+ */
482
+ getRole(id) {
483
+ const raw = this.toPlainObject();
484
+ return makeRequest({
485
+ entityType: 'Role',
486
+ action: 'get',
487
+ params: { spaceId: raw.sys.id, roleId: id },
488
+ }).then((data) => wrapRole(makeRequest, data));
489
+ },
490
+ /**
491
+ * Gets a collection of Roles
492
+ * @return Promise for a collection of Roles
493
+ * @example ```javascript
494
+ * const contentful = require('contentful-management')
495
+ *
496
+ * const client = contentful.createClient({
497
+ * accessToken: '<content_management_api_key>'
498
+ * })
499
+ *
500
+ * client.getSpace('<space_id>')
501
+ * .then((space) => space.getRoles())
502
+ * .then((response) => console.log(response.items))
503
+ * .catch(console.error)
504
+ * ```
505
+ */
506
+ getRoles(query = {}) {
507
+ const raw = this.toPlainObject();
508
+ return makeRequest({
509
+ entityType: 'Role',
510
+ action: 'getMany',
511
+ params: { spaceId: raw.sys.id, query: contentfulSdkCore.createRequestConfig({ query }).params },
512
+ }).then((data) => wrapRoleCollection(makeRequest, data));
513
+ },
514
+ /**
515
+ * Creates a Role
516
+ * @param data - Object representation of the Role to be created
517
+ * @return Promise for the newly created Role
518
+ * @example ```javascript
519
+ * const contentful = require('contentful-management')
520
+ *
521
+ * const client = contentful.createClient({
522
+ * accessToken: '<content_management_api_key>'
523
+ * })
524
+ * client.getSpace('<space_id>')
525
+ * .then((space) => space.createRole({
526
+ * name: 'My Role',
527
+ * description: 'foobar role',
528
+ * permissions: {
529
+ * ContentDelivery: 'all',
530
+ * ContentModel: ['read'],
531
+ * Settings: []
532
+ * },
533
+ * policies: [
534
+ * {
535
+ * effect: 'allow',
536
+ * actions: 'all',
537
+ * constraint: {
538
+ * and: [
539
+ * {
540
+ * equals: [
541
+ * { doc: 'sys.type' },
542
+ * 'Entry'
543
+ * ]
544
+ * },
545
+ * {
546
+ * equals: [
547
+ * { doc: 'sys.type' },
548
+ * 'Asset'
549
+ * ]
550
+ * }
551
+ * ]
552
+ * }
553
+ * }
554
+ * ]
555
+ * }))
556
+ * .then((role) => console.log(role))
557
+ * .catch(console.error)
558
+ * ```
559
+ */
560
+ createRole(data) {
561
+ const raw = this.toPlainObject();
562
+ return makeRequest({
563
+ entityType: 'Role',
564
+ action: 'create',
565
+ params: { spaceId: raw.sys.id },
566
+ payload: data,
567
+ }).then((data) => wrapRole(makeRequest, data));
568
+ },
569
+ /**
570
+ * Creates a Role with a custom ID
571
+ * @param id - Role ID
572
+ * @param data - Object representation of the Role to be created
573
+ * @return Promise for the newly created Role
574
+ * @example ```javascript
575
+ * const contentful = require('contentful-management')
576
+ *
577
+ * const client = contentful.createClient({
578
+ * accessToken: '<content_management_api_key>'
579
+ * })
580
+ * client.getSpace('<space_id>')
581
+ * .then((space) => space.createRoleWithId('<role-id>', {
582
+ * name: 'My Role',
583
+ * description: 'foobar role',
584
+ * permissions: {
585
+ * ContentDelivery: 'all',
586
+ * ContentModel: ['read'],
587
+ * Settings: []
588
+ * },
589
+ * policies: [
590
+ * {
591
+ * effect: 'allow',
592
+ * actions: 'all',
593
+ * constraint: {
594
+ * and: [
595
+ * {
596
+ * equals: [
597
+ * { doc: 'sys.type' },
598
+ * 'Entry'
599
+ * ]
600
+ * },
601
+ * {
602
+ * equals: [
603
+ * { doc: 'sys.type' },
604
+ * 'Asset'
605
+ * ]
606
+ * }
607
+ * ]
608
+ * }
609
+ * }
610
+ * ]
611
+ * }))
612
+ * .then((role) => console.log(role))
613
+ * .catch(console.error)
614
+ * ```
615
+ */
616
+ createRoleWithId(id, roleData) {
617
+ const raw = this.toPlainObject();
618
+ return makeRequest({
619
+ entityType: 'Role',
620
+ action: 'createWithId',
621
+ params: { spaceId: raw.sys.id, roleId: id },
622
+ payload: roleData,
623
+ }).then((data) => wrapRole(makeRequest, data));
624
+ },
625
+ /**
626
+ * Gets a User
627
+ * @param userId - User ID
628
+ * @return Promise for a User
629
+ * @example ```javascript
630
+ * const contentful = require('contentful-management')
631
+ *
632
+ * client.getSpace('<space_id>')
633
+ * .then((space) => space.getSpaceUser('id'))
634
+ * .then((user) => console.log(user))
635
+ * .catch(console.error)
636
+ * ```
637
+ */
638
+ getSpaceUser(userId) {
639
+ const raw = this.toPlainObject();
640
+ return makeRequest({
641
+ entityType: 'User',
642
+ action: 'getForSpace',
643
+ params: {
644
+ spaceId: raw.sys.id,
645
+ userId,
646
+ },
647
+ }).then((data) => wrapUser(makeRequest, data));
648
+ },
649
+ /**
650
+ * Gets a collection of Users in a space
651
+ * @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.
652
+ * @return Promise a collection of Users in a space
653
+ * @example ```javascript
654
+ * const contentful = require('contentful-management')
655
+ *
656
+ * client.getSpace('<space_id>')
657
+ * .then((space) => space.getSpaceUsers(query))
658
+ * .then((data) => console.log(data))
659
+ * .catch(console.error)
660
+ * ```
661
+ */
662
+ getSpaceUsers(query = {}) {
663
+ const raw = this.toPlainObject();
664
+ return makeRequest({
665
+ entityType: 'User',
666
+ action: 'getManyForSpace',
667
+ params: {
668
+ spaceId: raw.sys.id,
669
+ query: contentfulSdkCore.createRequestConfig({ query }).params,
670
+ },
671
+ }).then((data) => wrapUserCollection(makeRequest, data));
672
+ },
673
+ /**
674
+ * Gets a collection of teams for a space
675
+ * @param query
676
+ * @return Promise for a collection of teams for a space
677
+ * @example ```javascript
678
+ * const contentful = require('contentful-management')
679
+ *
680
+ * client.getSpace('<space_id>')
681
+ * .then((space) => space.getTeams())
682
+ * .then((teamsCollection) => console.log(teamsCollection))
683
+ * .catch(console.error)
684
+ * ```
685
+ */
686
+ getTeams(query = { limit: 100 }) {
687
+ const raw = this.toPlainObject();
688
+ return makeRequest({
689
+ entityType: 'Team',
690
+ action: 'getManyForSpace',
691
+ params: {
692
+ spaceId: raw.sys.id,
693
+ query: contentfulSdkCore.createRequestConfig({ query }).params,
694
+ },
695
+ }).then((data) => wrapTeamCollection(makeRequest, data));
696
+ },
697
+ /**
698
+ * Gets a Space Member
699
+ * @param id Get Space Member by user_id
700
+ * @return Promise for a Space Member
701
+ * @example ```javascript
702
+ * const contentful = require('contentful-management')
703
+ *
704
+ * client.getSpace('<space_id>')
705
+ * .then((space) => space.getSpaceMember(id))
706
+ * .then((spaceMember) => console.log(spaceMember))
707
+ * .catch(console.error)
708
+ * ```
709
+ */
710
+ getSpaceMember(id) {
711
+ const raw = this.toPlainObject();
712
+ return makeRequest({
713
+ entityType: 'SpaceMember',
714
+ action: 'get',
715
+ params: { spaceId: raw.sys.id, spaceMemberId: id },
716
+ }).then((data) => wrapSpaceMember(makeRequest, data));
717
+ },
718
+ /**
719
+ * Gets a collection of Space Members
720
+ * @param query
721
+ * @return Promise for a collection of Space Members
722
+ * @example ```javascript
723
+ * const contentful = require('contentful-management')
724
+ *
725
+ * client.getSpace('<space_id>')
726
+ * .then((space) => space.getSpaceMembers({'limit': 100}))
727
+ * .then((spaceMemberCollection) => console.log(spaceMemberCollection))
728
+ * .catch(console.error)
729
+ * ```
730
+ */
731
+ getSpaceMembers(query = {}) {
732
+ const raw = this.toPlainObject();
733
+ return makeRequest({
734
+ entityType: 'SpaceMember',
735
+ action: 'getMany',
736
+ params: {
737
+ spaceId: raw.sys.id,
738
+ query: contentfulSdkCore.createRequestConfig({ query }).params,
739
+ },
740
+ }).then((data) => wrapSpaceMemberCollection(makeRequest, data));
741
+ },
742
+ /**
743
+ * Gets a Space Membership
744
+ * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).
745
+ * @param id - Space Membership ID
746
+ * @return Promise for a Space Membership
747
+ * @example ```javascript
748
+ * const contentful = require('contentful-management')
749
+ *
750
+ * client.getSpace('<space_id>')
751
+ * .then((space) => space.getSpaceMembership('id'))
752
+ * .then((spaceMembership) => console.log(spaceMembership))
753
+ * .catch(console.error)
754
+ * ```
755
+ */
756
+ getSpaceMembership(id) {
757
+ const raw = this.toPlainObject();
758
+ return makeRequest({
759
+ entityType: 'SpaceMembership',
760
+ action: 'get',
761
+ params: { spaceId: raw.sys.id, spaceMembershipId: id },
762
+ }).then((data) => wrapSpaceMembership(makeRequest, data));
763
+ },
764
+ /**
765
+ * Gets a collection of Space Memberships
766
+ * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).
767
+ * @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.
768
+ * @return Promise for a collection of Space Memberships
769
+ * @example ```javascript
770
+ * const contentful = require('contentful-management')
771
+ *
772
+ * client.getSpace('<space_id>')
773
+ * .then((space) => space.getSpaceMemberships({'limit': 100})) // you can add more queries as 'key': 'value'
774
+ * .then((response) => console.log(response.items))
775
+ * .catch(console.error)
776
+ * ```
777
+ */
778
+ getSpaceMemberships(query = {}) {
779
+ const raw = this.toPlainObject();
780
+ return makeRequest({
781
+ entityType: 'SpaceMembership',
782
+ action: 'getMany',
783
+ params: {
784
+ spaceId: raw.sys.id,
785
+ query: contentfulSdkCore.createRequestConfig({ query }).params,
786
+ },
787
+ }).then((data) => wrapSpaceMembershipCollection(makeRequest, data));
788
+ },
789
+ /**
790
+ * Creates a Space Membership
791
+ * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).
792
+ * @param data - Object representation of the Space Membership to be created
793
+ * @return Promise for the newly created Space Membership
794
+ * @example ```javascript
795
+ * const contentful = require('contentful-management')
796
+ *
797
+ * const client = contentful.createClient({
798
+ * accessToken: '<content_management_api_key>'
799
+ * })
800
+ *
801
+ * client.getSpace('<space_id>')
802
+ * .then((space) => space.createSpaceMembership({
803
+ * admin: false,
804
+ * roles: [
805
+ * {
806
+ * type: 'Link',
807
+ * linkType: 'Role',
808
+ * id: '<role_id>'
809
+ * }
810
+ * ],
811
+ * email: 'foo@example.com'
812
+ * }))
813
+ * .then((spaceMembership) => console.log(spaceMembership))
814
+ * .catch(console.error)
815
+ * ```
816
+ */
817
+ createSpaceMembership(data) {
818
+ const raw = this.toPlainObject();
819
+ return makeRequest({
820
+ entityType: 'SpaceMembership',
821
+ action: 'create',
822
+ params: {
823
+ spaceId: raw.sys.id,
824
+ },
825
+ payload: data,
826
+ }).then((response) => wrapSpaceMembership(makeRequest, response));
827
+ },
828
+ /**
829
+ * Creates a Space Membership with a custom ID
830
+ * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user).
831
+ * @param id - Space Membership ID
832
+ * @param data - Object representation of the Space Membership to be created
833
+ * @return Promise for the newly created Space Membership
834
+ * @example ```javascript
835
+ * const contentful = require('contentful-management')
836
+ *
837
+ * const client = contentful.createClient({
838
+ * accessToken: '<content_management_api_key>'
839
+ * })
840
+ *
841
+ * client.getSpace('<space_id>')
842
+ * .then((space) => space.createSpaceMembershipWithId('<space-membership-id>', {
843
+ * admin: false,
844
+ * roles: [
845
+ * {
846
+ * type: 'Link',
847
+ * linkType: 'Role',
848
+ * id: '<role_id>'
849
+ * }
850
+ * ],
851
+ * email: 'foo@example.com'
852
+ * }))
853
+ * .then((spaceMembership) => console.log(spaceMembership))
854
+ * .catch(console.error)
855
+ * ```
856
+ */
857
+ createSpaceMembershipWithId(id, data) {
858
+ const raw = this.toPlainObject();
859
+ return makeRequest({
860
+ entityType: 'SpaceMembership',
861
+ action: 'createWithId',
862
+ params: {
863
+ spaceId: raw.sys.id,
864
+ spaceMembershipId: id,
865
+ },
866
+ payload: data,
867
+ }).then((response) => wrapSpaceMembership(makeRequest, response));
868
+ },
869
+ /**
870
+ * Gets a Team Space Membership
871
+ * @param id - Team Space Membership ID
872
+ * @return Promise for a Team Space Membership
873
+ * @example ```javascript
874
+ * const contentful = require('contentful-management')
875
+ *
876
+ * client.getSpace('<space_id>')
877
+ * .then((space) => space.getTeamSpaceMembership('team_space_membership_id'))
878
+ * .then((teamSpaceMembership) => console.log(teamSpaceMembership))
879
+ * .catch(console.error)
880
+ * ```
881
+ */
882
+ getTeamSpaceMembership(teamSpaceMembershipId) {
883
+ const raw = this.toPlainObject();
884
+ return makeRequest({
885
+ entityType: 'TeamSpaceMembership',
886
+ action: 'get',
887
+ params: {
888
+ spaceId: raw.sys.id,
889
+ teamSpaceMembershipId,
890
+ },
891
+ }).then((data) => wrapTeamSpaceMembership(makeRequest, data));
892
+ },
893
+ /**
894
+ * Gets a collection of Team Space Memberships
895
+ * @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.
896
+ * @return Promise for a collection of Team Space Memberships
897
+ * @example ```javascript
898
+ * const contentful = require('contentful-management')
899
+ *
900
+ * client.getSpace('<space_id>')
901
+ * .then((space) => space.getTeamSpaceMemberships())
902
+ * .then((response) => console.log(response.items))
903
+ * .catch(console.error)
904
+ * ```
905
+ */
906
+ getTeamSpaceMemberships(query = {}) {
907
+ const raw = this.toPlainObject();
908
+ return makeRequest({
909
+ entityType: 'TeamSpaceMembership',
910
+ action: 'getMany',
911
+ params: {
912
+ spaceId: raw.sys.id,
913
+ query: contentfulSdkCore.createRequestConfig({ query: query }).params,
914
+ },
915
+ }).then((data) => wrapTeamSpaceMembershipCollection(makeRequest, data));
916
+ },
917
+ /**
918
+ * Creates a Team Space Membership
919
+ * @param id - Team ID
920
+ * @param data - Object representation of the Team Space Membership to be created
921
+ * @return Promise for the newly created Team Space Membership
922
+ * @example ```javascript
923
+ * const contentful = require('contentful-management')
924
+ *
925
+ * const client = contentful.createClient({
926
+ * accessToken: '<content_management_api_key>'
927
+ * })
928
+ *
929
+ * client.getSpace('<space_id>')
930
+ * .then((space) => space.createTeamSpaceMembership('team_id', {
931
+ * admin: false,
932
+ * roles: [
933
+ * {
934
+ sys: {
935
+ * type: 'Link',
936
+ * linkType: 'Role',
937
+ * id: '<role_id>'
938
+ * }
939
+ * }
940
+ * ],
941
+ * }))
942
+ * .then((teamSpaceMembership) => console.log(teamSpaceMembership))
943
+ * .catch(console.error)
944
+ * ```
945
+ */
946
+ createTeamSpaceMembership(teamId, data) {
947
+ const raw = this.toPlainObject();
948
+ return makeRequest({
949
+ entityType: 'TeamSpaceMembership',
950
+ action: 'create',
951
+ params: {
952
+ spaceId: raw.sys.id,
953
+ teamId,
954
+ },
955
+ payload: data,
956
+ }).then((response) => wrapTeamSpaceMembership(makeRequest, response));
957
+ },
958
+ /**
959
+ * Gets a Api Key
960
+ * @param id - API Key ID
961
+ * @return Promise for a Api Key
962
+ * @example ```javascript
963
+ * const contentful = require('contentful-management')
964
+ *
965
+ * const client = contentful.createClient({
966
+ * accessToken: '<content_management_api_key>'
967
+ * })
968
+ *
969
+ * client.getSpace('<space_id>')
970
+ * .then((space) => space.getApiKey('<apikey-id>'))
971
+ * .then((apikey) => console.log(apikey))
972
+ * .catch(console.error)
973
+ * ```
974
+ */
975
+ getApiKey(id) {
976
+ const raw = this.toPlainObject();
977
+ return makeRequest({
978
+ entityType: 'ApiKey',
979
+ action: 'get',
980
+ params: {
981
+ spaceId: raw.sys.id,
982
+ apiKeyId: id,
983
+ },
984
+ }).then((data) => wrapApiKey(makeRequest, data));
985
+ },
986
+ /**
987
+ * Gets a collection of Api Keys
988
+ * @return Promise for a collection of Api Keys
989
+ * @example ```javascript
990
+ * const contentful = require('contentful-management')
991
+ *
992
+ * const client = contentful.createClient({
993
+ * accessToken: '<content_management_api_key>'
994
+ * })
995
+ *
996
+ * client.getSpace('<space_id>')
997
+ * .then((space) => space.getApiKeys())
998
+ * .then((response) => console.log(response.items))
999
+ * .catch(console.error)
1000
+ * ```
1001
+ */
1002
+ getApiKeys() {
1003
+ const raw = this.toPlainObject();
1004
+ return makeRequest({
1005
+ entityType: 'ApiKey',
1006
+ action: 'getMany',
1007
+ params: {
1008
+ spaceId: raw.sys.id,
1009
+ },
1010
+ }).then((data) => wrapApiKeyCollection(makeRequest, data));
1011
+ },
1012
+ /**
1013
+ * Gets a collection of preview Api Keys
1014
+ * @return Promise for a collection of Preview Api Keys
1015
+ * @example ```javascript
1016
+ * const contentful = require('contentful-management')
1017
+ *
1018
+ * const client = contentful.createClient({
1019
+ * accessToken: '<content_management_api_key>'
1020
+ * })
1021
+ *
1022
+ * client.getSpace('<space_id>')
1023
+ * .then((space) => space.getPreviewApiKeys())
1024
+ * .then((response) => console.log(response.items))
1025
+ * .catch(console.error)
1026
+ * ```
1027
+ */
1028
+ getPreviewApiKeys() {
1029
+ const raw = this.toPlainObject();
1030
+ return makeRequest({
1031
+ entityType: 'PreviewApiKey',
1032
+ action: 'getMany',
1033
+ params: {
1034
+ spaceId: raw.sys.id,
1035
+ },
1036
+ }).then((data) => wrapPreviewApiKeyCollection(makeRequest, data));
1037
+ },
1038
+ /**
1039
+ * Gets a preview Api Key
1040
+ * @param id - Preview API Key ID
1041
+ * @return Promise for a Preview Api Key
1042
+ * @example ```javascript
1043
+ * const contentful = require('contentful-management')
1044
+ *
1045
+ * const client = contentful.createClient({
1046
+ * accessToken: '<content_management_api_key>'
1047
+ * })
1048
+ *
1049
+ * client.getSpace('<space_id>')
1050
+ * .then((space) => space.getPreviewApiKey('<preview-apikey-id>'))
1051
+ * .then((previewApikey) => console.log(previewApikey))
1052
+ * .catch(console.error)
1053
+ * ```
1054
+ */
1055
+ getPreviewApiKey(id) {
1056
+ const raw = this.toPlainObject();
1057
+ return makeRequest({
1058
+ entityType: 'PreviewApiKey',
1059
+ action: 'get',
1060
+ params: {
1061
+ spaceId: raw.sys.id,
1062
+ previewApiKeyId: id,
1063
+ },
1064
+ }).then((data) => wrapPreviewApiKey(makeRequest, data));
1065
+ },
1066
+ /**
1067
+ * Creates a Api Key
1068
+ * @param payload - Object representation of the Api Key to be created
1069
+ * @return Promise for the newly created Api Key
1070
+ * @example ```javascript
1071
+ * const contentful = require('contentful-management')
1072
+ *
1073
+ * const client = contentful.createClient({
1074
+ * accessToken: '<content_management_api_key>'
1075
+ * })
1076
+ *
1077
+ * client.getSpace('<space_id>')
1078
+ * .then((space) => space.createApiKey({
1079
+ * name: 'API Key name',
1080
+ * environments:[
1081
+ * {
1082
+ * sys: {
1083
+ * type: 'Link'
1084
+ * linkType: 'Environment',
1085
+ * id:'<environment_id>'
1086
+ * }
1087
+ * }
1088
+ * ]
1089
+ * }
1090
+ * }))
1091
+ * .then((apiKey) => console.log(apiKey))
1092
+ * .catch(console.error)
1093
+ * ```
1094
+ */
1095
+ createApiKey: function createApiKey(payload) {
1096
+ const raw = this.toPlainObject();
1097
+ return makeRequest({
1098
+ entityType: 'ApiKey',
1099
+ action: 'create',
1100
+ params: { spaceId: raw.sys.id },
1101
+ payload,
1102
+ }).then((data) => wrapApiKey(makeRequest, data));
1103
+ },
1104
+ /**
1105
+ * Creates a Api Key with a custom ID
1106
+ * @param id - Api Key ID
1107
+ * @param payload - Object representation of the Api Key to be created
1108
+ * @return Promise for the newly created Api Key
1109
+ * @example ```javascript
1110
+ * const contentful = require('contentful-management')
1111
+ *
1112
+ * const client = contentful.createClient({
1113
+ * accessToken: '<content_management_api_key>'
1114
+ * })
1115
+ *
1116
+ * client.getSpace('<space_id>')
1117
+ * .then((space) => space.createApiKeyWithId('<api-key-id>', {
1118
+ * name: 'API Key name'
1119
+ * environments:[
1120
+ * {
1121
+ * sys: {
1122
+ * type: 'Link'
1123
+ * linkType: 'Environment',
1124
+ * id:'<environment_id>'
1125
+ * }
1126
+ * }
1127
+ * ]
1128
+ * }
1129
+ * }))
1130
+ * .then((apiKey) => console.log(apiKey))
1131
+ * .catch(console.error)
1132
+ * ```
1133
+ */
1134
+ createApiKeyWithId(id, payload) {
1135
+ const raw = this.toPlainObject();
1136
+ return makeRequest({
1137
+ entityType: 'ApiKey',
1138
+ action: 'createWithId',
1139
+ params: { spaceId: raw.sys.id, apiKeyId: id },
1140
+ payload,
1141
+ }).then((data) => wrapApiKey(makeRequest, data));
1142
+ },
1143
+ /**
1144
+ * Creates an EnvironmentAlias with a custom ID
1145
+ * @param environmentAliasId - EnvironmentAlias ID
1146
+ * @param data - Object representation of the EnvironmentAlias to be created
1147
+ * @return Promise for the newly created EnvironmentAlias
1148
+ * @example ```javascript
1149
+ * const contentful = require('contentful-management')
1150
+ *
1151
+ * const client = contentful.createClient({
1152
+ * accessToken: '<content_management_api_key>'
1153
+ * })
1154
+ *
1155
+ * client.getSpace('<space_id>')
1156
+ * .then((space) => space.createEnvironmentAliasWithId('<environment-alias-id>', {
1157
+ * environment: {
1158
+ * sys: { type: 'Link', linkType: 'Environment', id: 'targetEnvironment' }
1159
+ * }
1160
+ * }))
1161
+ * .then((environmentAlias) => console.log(environmentAlias))
1162
+ * .catch(console.error)
1163
+ * ```
1164
+ */
1165
+ createEnvironmentAliasWithId(environmentAliasId, data) {
1166
+ const raw = this.toPlainObject();
1167
+ return makeRequest({
1168
+ entityType: 'EnvironmentAlias',
1169
+ action: 'createWithId',
1170
+ params: { spaceId: raw.sys.id, environmentAliasId },
1171
+ payload: data,
1172
+ }).then((response) => wrapEnvironmentAlias(makeRequest, response));
1173
+ },
1174
+ /**
1175
+ * Gets an Environment Alias
1176
+ * @param Environment Alias ID
1177
+ * @return Promise for an Environment Alias
1178
+ * @example ```javascript
1179
+ * const contentful = require('contentful-management')
1180
+ *
1181
+ * const client = contentful.createClient({
1182
+ * accessToken: '<content_management_api_key>'
1183
+ * })
1184
+ *
1185
+ * client.getSpace('<space_id>')
1186
+ * .then((space) => space.getEnvironmentAlias('<alias-id>'))
1187
+ * .then((alias) => console.log(alias))
1188
+ * .catch(console.error)
1189
+ * ```
1190
+ */
1191
+ getEnvironmentAlias(environmentAliasId) {
1192
+ const raw = this.toPlainObject();
1193
+ return makeRequest({
1194
+ entityType: 'EnvironmentAlias',
1195
+ action: 'get',
1196
+ params: { spaceId: raw.sys.id, environmentAliasId },
1197
+ }).then((data) => wrapEnvironmentAlias(makeRequest, data));
1198
+ },
1199
+ /**
1200
+ * Gets a collection of Environment Aliases
1201
+ * @return Promise for a collection of Environment Aliases
1202
+ * @example ```javascript
1203
+ * const contentful = require('contentful-management')
1204
+ *
1205
+ * const client = contentful.createClient({
1206
+ * accessToken: '<content_management_api_key>'
1207
+ * })
1208
+ *
1209
+ * client.getSpace('<space_id>')
1210
+ * .then((space) => space.getEnvironmentAliases()
1211
+ * .then((response) => console.log(response.items))
1212
+ * .catch(console.error)
1213
+ * ```
1214
+ */
1215
+ getEnvironmentAliases() {
1216
+ const raw = this.toPlainObject();
1217
+ return makeRequest({
1218
+ entityType: 'EnvironmentAlias',
1219
+ action: 'getMany',
1220
+ params: {
1221
+ spaceId: raw.sys.id,
1222
+ },
1223
+ }).then((data) => wrapEnvironmentAliasCollection(makeRequest, data));
1224
+ },
1225
+ /**
1226
+ * Query for scheduled actions in space.
1227
+ * @param query - Object with search parameters. The enviroment id field is mandatory. Check the <a href="https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/scheduled-actions-collection">REST API reference</a> for more details.
1228
+ * @return Promise for the scheduled actions query
1229
+ *
1230
+ * @example ```javascript
1231
+ * const contentful = require('contentful-management');
1232
+ *
1233
+ * const client = contentful.createClient({
1234
+ * accessToken: '<content_management_api_key>'
1235
+ * })
1236
+ *
1237
+ * client.getSpace('<space_id>')
1238
+ * .then((space) => space.getScheduledActions({
1239
+ * 'environment.sys.id': '<environment_id>',
1240
+ * 'sys.status': 'scheduled'
1241
+ * }))
1242
+ * .then((scheduledActionCollection) => console.log(scheduledActionCollection.items))
1243
+ * .catch(console.error)
1244
+ * ```
1245
+ */
1246
+ getScheduledActions(query) {
1247
+ const raw = this.toPlainObject();
1248
+ return makeRequest({
1249
+ entityType: 'ScheduledAction',
1250
+ action: 'getMany',
1251
+ params: { spaceId: raw.sys.id, query },
1252
+ }).then((response) => wrapScheduledActionCollection(makeRequest, response));
1253
+ },
1254
+ /**
1255
+ * Get a Scheduled Action in the current space by environment and ID.
1256
+ *
1257
+ * @throws if the Scheduled Action cannot be found or the user doesn't have permission to read schedules from the entity of the scheduled action itself.
1258
+ * @returns Promise with the Scheduled Action
1259
+ * @example ```javascript
1260
+ * const contentful = require('contentful-management');
1261
+ *
1262
+ * const client = contentful.createClient({
1263
+ * accessToken: '<content_management_api_key>'
1264
+ * })
1265
+ *
1266
+ * client.getSpace('<space_id>')
1267
+ * .then((space) => space.getScheduledAction({
1268
+ * scheduledActionId: '<scheduled-action-id>',
1269
+ * environmentId: '<environmentId>'
1270
+ * }))
1271
+ * .then((scheduledAction) => console.log(scheduledAction))
1272
+ * .catch(console.error)
1273
+ * ```
1274
+ */
1275
+ getScheduledAction({ scheduledActionId, environmentId, }) {
1276
+ const space = this.toPlainObject();
1277
+ return makeRequest({
1278
+ entityType: 'ScheduledAction',
1279
+ action: 'get',
1280
+ params: {
1281
+ spaceId: space.sys.id,
1282
+ environmentId,
1283
+ scheduledActionId,
1284
+ },
1285
+ }).then((scheduledAction) => wrapScheduledAction(makeRequest, scheduledAction));
1286
+ },
1287
+ /**
1288
+ * Creates a scheduled action
1289
+ * @param data - Object representation of the scheduled action to be created
1290
+ * @return Promise for the newly created scheduled actions
1291
+ * @example ```javascript
1292
+ * const contentful = require('contentful-management');
1293
+ *
1294
+ * const client = contentful.createClient({
1295
+ * accessToken: '<content_management_api_key>'
1296
+ * })
1297
+ *
1298
+ * client.getSpace('<space_id>')
1299
+ * .then((space) => space.createScheduledAction({
1300
+ * entity: {
1301
+ * sys: {
1302
+ * type: 'Link',
1303
+ * linkType: 'Entry',
1304
+ * id: '<entry_id>'
1305
+ * }
1306
+ * },
1307
+ * environment: {
1308
+ * sys: {
1309
+ * type: 'Link',
1310
+ * linkType: 'Environment',
1311
+ * id: '<environment_id>'
1312
+ * }
1313
+ * },
1314
+ * action: 'publish',
1315
+ * scheduledFor: {
1316
+ * datetime: <ISO_date_string>,
1317
+ * timezone: 'Europe/Berlin'
1318
+ * }
1319
+ * }))
1320
+ * .then((scheduledAction) => console.log(scheduledAction))
1321
+ * .catch(console.error)
1322
+ * ```
1323
+ */
1324
+ createScheduledAction(data) {
1325
+ const raw = this.toPlainObject();
1326
+ return makeRequest({
1327
+ entityType: 'ScheduledAction',
1328
+ action: 'create',
1329
+ params: { spaceId: raw.sys.id },
1330
+ payload: data,
1331
+ }).then((response) => wrapScheduledAction(makeRequest, response));
1332
+ },
1333
+ /**
1334
+ * Update a scheduled action
1335
+ * @param {object} options
1336
+ * @param options.scheduledActionId the id of the scheduled action to update
1337
+ * @param options.version the sys.version of the scheduled action to be updated
1338
+ * @param payload the scheduled actions object with updates, omitting sys object
1339
+ * @returns Promise containing a wrapped scheduled action with helper methods
1340
+ * @example ```javascript
1341
+ * const contentful = require('contentful-management');
1342
+ *
1343
+ * const client = contentful.createClient({
1344
+ * accessToken: '<content_management_api_key>'
1345
+ * })
1346
+ *
1347
+ * client.getSpace('<space_id>')
1348
+ * .then((space) => {
1349
+ * return space.createScheduledAction({
1350
+ * entity: {
1351
+ * sys: {
1352
+ * type: 'Link',
1353
+ * linkType: 'Entry',
1354
+ * id: '<entry_id>'
1355
+ * }
1356
+ * },
1357
+ * environment: {
1358
+ * sys: {
1359
+ * type: 'Link',
1360
+ * linkType: 'Environment',
1361
+ * id: '<environment_id>'
1362
+ * }
1363
+ * },
1364
+ * action: 'publish',
1365
+ * scheduledFor: {
1366
+ * datetime: <ISO_date_string>,
1367
+ * timezone: 'Europe/Berlin'
1368
+ * }
1369
+ * })
1370
+ * .then((scheduledAction) => {
1371
+ * const { _sys, ...payload } = scheduledAction;
1372
+ * return space.updateScheduledAction({
1373
+ * ...payload,
1374
+ * scheduledFor: {
1375
+ * ...payload.scheduledFor,
1376
+ * timezone: 'Europe/Paris'
1377
+ * }
1378
+ * })
1379
+ * })
1380
+ * .then((scheduledAction) => console.log(scheduledAction))
1381
+ * .catch(console.error);
1382
+ * ```
1383
+ */
1384
+ updateScheduledAction({ scheduledActionId, payload, version, }) {
1385
+ const spaceProps = this.toPlainObject();
1386
+ return makeRequest({
1387
+ entityType: 'ScheduledAction',
1388
+ action: 'update',
1389
+ params: {
1390
+ spaceId: spaceProps.sys.id,
1391
+ version,
1392
+ scheduledActionId,
1393
+ },
1394
+ payload,
1395
+ }).then((response) => wrapScheduledAction(makeRequest, response));
1396
+ },
1397
+ /**
1398
+ * Cancels a Scheduled Action.
1399
+ * Only cancels actions that have not yet executed.
1400
+ *
1401
+ * @param {object} options
1402
+ * @param options.scheduledActionId the id of the scheduled action to be canceled
1403
+ * @param options.environmentId the environment ID of the scheduled action to be canceled
1404
+ * @throws if the Scheduled Action cannot be found or the user doesn't have permissions in the entity in the action.
1405
+ * @returns Promise containing a wrapped Scheduled Action with helper methods
1406
+ * @example ```javascript
1407
+ * const contentful = require('contentful-management');
1408
+ *
1409
+ * const client = contentful.createClient({
1410
+ * accessToken: '<content_management_api_key>'
1411
+ * })
1412
+ *
1413
+ * // Given that an Scheduled Action is scheduled
1414
+ * client.getSpace('<space_id>')
1415
+ * .then((space) => space.deleteScheduledAction({
1416
+ * environmentId: '<environment-id>',
1417
+ * scheduledActionId: '<scheduled-action-id>'
1418
+ * }))
1419
+ * // The scheduled Action sys.status is now 'canceled'
1420
+ * .then((scheduledAction) => console.log(scheduledAction))
1421
+ * .catch(console.error);
1422
+ * ```
1423
+ */
1424
+ deleteScheduledAction({ scheduledActionId, environmentId, }) {
1425
+ const spaceProps = this.toPlainObject();
1426
+ return makeRequest({
1427
+ entityType: 'ScheduledAction',
1428
+ action: 'delete',
1429
+ params: {
1430
+ spaceId: spaceProps.sys.id,
1431
+ environmentId,
1432
+ scheduledActionId,
1433
+ },
1434
+ }).then((response) => wrapScheduledAction(makeRequest, response));
1435
+ },
1436
+ /**
1437
+ * Gets a single AI Action.
1438
+ * @param aiActionId - AI Action ID
1439
+ * @return Promise for an AI Action
1440
+ * @example
1441
+ * ```javascript
1442
+ * client.getSpace('<space_id>')
1443
+ * .then((space) => space.getAiAction('<ai_action_id>'))
1444
+ * .then((aiAction) => console.log(aiAction))
1445
+ * .catch(console.error)
1446
+ * ```
1447
+ */
1448
+ getAiAction(aiActionId) {
1449
+ const raw = this.toPlainObject();
1450
+ return makeRequest({
1451
+ entityType: 'AiAction',
1452
+ action: 'get',
1453
+ params: { spaceId: raw.sys.id, aiActionId },
1454
+ }).then((data) => wrapAiAction(makeRequest, data));
1455
+ },
1456
+ /**
1457
+ * Gets a collection of AI Actions.
1458
+ * @param query - Object with search parameters.
1459
+ * @return Promise for a collection of AI Actions
1460
+ * @example
1461
+ * ```javascript
1462
+ * client.getSpace('<space_id>')
1463
+ * .then((space) => space.getAiActions({ limit: 10 }))
1464
+ * .then((response) => console.log(response.items))
1465
+ * .catch(console.error)
1466
+ * ```
1467
+ */
1468
+ getAiActions(query = {}) {
1469
+ const raw = this.toPlainObject();
1470
+ return makeRequest({
1471
+ entityType: 'AiAction',
1472
+ action: 'getMany',
1473
+ params: { spaceId: raw.sys.id, query },
1474
+ }).then((data) => wrapAiActionCollection(makeRequest, data));
1475
+ },
1476
+ /**
1477
+ * Creates an AI Action.
1478
+ * @param data - Object representation of the AI Action to be created
1479
+ * @return Promise for the newly created AI Action
1480
+ * @example
1481
+ * ```javascript
1482
+ * client.getSpace('<space_id>')
1483
+ * .then((space) => space.createAiAction({
1484
+ * name: 'My AI Action',
1485
+ * description: 'Description here',
1486
+ * configuration: { modelType: 'model-x', modelTemperature: 0.7 },
1487
+ * instruction: { template: 'Do something: {{var.input}}', variables: [], conditions: [] },
1488
+ * testCases: []
1489
+ * }))
1490
+ * .then((aiAction) => console.log(aiAction))
1491
+ * .catch(console.error)
1492
+ * ```
1493
+ */
1494
+ createAiAction(data) {
1495
+ const raw = this.toPlainObject();
1496
+ return makeRequest({
1497
+ entityType: 'AiAction',
1498
+ action: 'create',
1499
+ params: { spaceId: raw.sys.id },
1500
+ payload: data,
1501
+ }).then((response) => wrapAiAction(makeRequest, response));
1502
+ },
1503
+ /**
1504
+ * Updates an AI Action.
1505
+ * @param aiActionId - AI Action ID
1506
+ * @param data - Object representation of the AI Action update
1507
+ * @return Promise for the updated AI Action
1508
+ * @example
1509
+ * ```javascript
1510
+ * client.getSpace('<space_id>')
1511
+ * .then((space) => space.updateAiAction('<ai_action_id>', { name: 'New Name', ... }))
1512
+ * .then((aiAction) => console.log(aiAction))
1513
+ * .catch(console.error)
1514
+ * ```
1515
+ */
1516
+ updateAiAction(aiActionId, data) {
1517
+ var _a;
1518
+ const raw = this.toPlainObject();
1519
+ return makeRequest({
1520
+ entityType: 'AiAction',
1521
+ action: 'update',
1522
+ params: { spaceId: raw.sys.id, aiActionId },
1523
+ payload: data,
1524
+ headers: { 'X-Contentful-Version': (_a = data.sys.version) !== null && _a !== void 0 ? _a : 0 },
1525
+ }).then((response) => wrapAiAction(makeRequest, response));
1526
+ },
1527
+ /**
1528
+ * Publishes an AI Action.
1529
+ * @param aiActionId - AI Action ID
1530
+ * @param data - Object representation of the AI Action to be published
1531
+ * @return Promise for the published AI Action
1532
+ * @example
1533
+ * ```javascript
1534
+ * client.getSpace('<space_id>')
1535
+ * .then((space) => space.publishAiAction('<ai_action_id>', { ... }))
1536
+ * .then((aiAction) => console.log(aiAction))
1537
+ * .catch(console.error)
1538
+ * ```
1539
+ */
1540
+ publishAiAction(aiActionId, { version }) {
1541
+ const raw = this.toPlainObject();
1542
+ return makeRequest({
1543
+ entityType: 'AiAction',
1544
+ action: 'publish',
1545
+ params: { spaceId: raw.sys.id, aiActionId, version },
1546
+ }).then((response) => wrapAiAction(makeRequest, response));
1547
+ },
1548
+ /**
1549
+ * Unpublishes an AI Action.
1550
+ * @param aiActionId - AI Action ID
1551
+ * @return Promise for the unpublished AI Action
1552
+ * @example
1553
+ * ```javascript
1554
+ * client.getSpace('<space_id>')
1555
+ * .then((space) => space.unpublishAiAction('<ai_action_id>'))
1556
+ * .then((aiAction) => console.log(aiAction))
1557
+ * .catch(console.error)
1558
+ * ```
1559
+ */
1560
+ unpublishAiAction(aiActionId) {
1561
+ const raw = this.toPlainObject();
1562
+ return makeRequest({
1563
+ entityType: 'AiAction',
1564
+ action: 'unpublish',
1565
+ params: { spaceId: raw.sys.id, aiActionId },
1566
+ }).then((response) => wrapAiAction(makeRequest, response));
1567
+ },
1568
+ /**
1569
+ * Deletes an AI Action.
1570
+ * @param aiActionId - AI Action ID
1571
+ * @return Promise for deletion (void)
1572
+ * @example
1573
+ * ```javascript
1574
+ * client.getSpace('<space_id>')
1575
+ * .then((space) => space.deleteAiAction('<ai_action_id>'))
1576
+ * .then(() => console.log('AI Action deleted'))
1577
+ * .catch(console.error)
1578
+ * ```
1579
+ */
1580
+ deleteAiAction(aiActionId) {
1581
+ const raw = this.toPlainObject();
1582
+ return makeRequest({
1583
+ entityType: 'AiAction',
1584
+ action: 'delete',
1585
+ params: { spaceId: raw.sys.id, aiActionId },
1586
+ });
1587
+ },
1588
+ };
1589
+ }
1590
+
1591
+ module.exports = createSpaceApi;