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