contentful-management 11.44.0 → 11.45.0-beta.2

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