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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +3 -0
  2. package/dist/cjs/adapters/REST/endpoints/access-token.cjs +136 -0
  3. package/dist/cjs/adapters/REST/endpoints/ai-action-invocation.cjs +9 -0
  4. package/dist/cjs/adapters/REST/endpoints/ai-action.cjs +53 -0
  5. package/dist/cjs/adapters/REST/endpoints/api-key.cjs +48 -0
  6. package/dist/cjs/adapters/REST/endpoints/app-access-token.cjs +9 -0
  7. package/dist/cjs/adapters/REST/endpoints/app-action-call.cjs +65 -0
  8. package/dist/cjs/adapters/REST/endpoints/app-action.cjs +42 -0
  9. package/dist/cjs/adapters/REST/endpoints/app-bundle.cjs +39 -0
  10. package/dist/cjs/adapters/REST/endpoints/app-definition.cjs +47 -0
  11. package/dist/cjs/adapters/REST/endpoints/app-details.cjs +17 -0
  12. package/dist/cjs/adapters/REST/endpoints/app-event-subscription.cjs +17 -0
  13. package/dist/cjs/adapters/REST/endpoints/app-installation.cjs +42 -0
  14. package/dist/cjs/adapters/REST/endpoints/app-key.cjs +21 -0
  15. package/dist/cjs/adapters/REST/endpoints/app-signed-request.cjs +9 -0
  16. package/dist/cjs/adapters/REST/endpoints/app-signing-secret.cjs +17 -0
  17. package/dist/cjs/adapters/REST/endpoints/app-upload.cjs +28 -0
  18. package/dist/cjs/adapters/REST/endpoints/asset-key.cjs +34 -0
  19. package/dist/cjs/adapters/REST/endpoints/asset.cjs +185 -0
  20. package/dist/cjs/adapters/REST/endpoints/bulk-action.cjs +21 -0
  21. package/dist/cjs/adapters/REST/endpoints/comment.cjs +92 -0
  22. package/dist/cjs/adapters/REST/endpoints/concept-scheme.cjs +44 -0
  23. package/dist/cjs/adapters/REST/endpoints/concept.cjs +65 -0
  24. package/dist/cjs/adapters/REST/endpoints/content-type.cjs +56 -0
  25. package/dist/cjs/adapters/REST/endpoints/editor-interface.cjs +24 -0
  26. package/dist/cjs/adapters/REST/endpoints/entry.cjs +104 -0
  27. package/dist/cjs/adapters/REST/endpoints/environment-alias.cjs +44 -0
  28. package/dist/cjs/adapters/REST/endpoints/environment-template-installation.cjs +23 -0
  29. package/dist/cjs/adapters/REST/endpoints/environment-template.cjs +49 -0
  30. package/dist/cjs/adapters/REST/endpoints/environment.cjs +47 -0
  31. package/dist/cjs/adapters/REST/endpoints/extension.cjs +44 -0
  32. package/dist/cjs/adapters/REST/endpoints/function-log.cjs +23 -0
  33. package/dist/cjs/adapters/REST/endpoints/function.cjs +25 -0
  34. package/dist/cjs/adapters/REST/endpoints/http.cjs +29 -0
  35. package/dist/cjs/adapters/REST/endpoints/index.cjs +139 -0
  36. package/dist/cjs/adapters/REST/endpoints/locale.cjs +37 -0
  37. package/dist/cjs/adapters/REST/endpoints/oauth-application.cjs +147 -0
  38. package/dist/cjs/adapters/REST/endpoints/organization-invitation.cjs +23 -0
  39. package/dist/cjs/adapters/REST/endpoints/organization-membership.cjs +32 -0
  40. package/dist/cjs/adapters/REST/endpoints/organization.cjs +28 -0
  41. package/dist/cjs/adapters/REST/endpoints/personal-access-token.cjs +37 -0
  42. package/dist/cjs/adapters/REST/endpoints/preview-api-key.cjs +15 -0
  43. package/dist/cjs/adapters/REST/endpoints/raw.cjs +44 -0
  44. package/dist/cjs/adapters/REST/endpoints/release-action.cjs +21 -0
  45. package/dist/cjs/adapters/REST/endpoints/release.cjs +61 -0
  46. package/dist/cjs/adapters/REST/endpoints/resource-provider.cjs +18 -0
  47. package/dist/cjs/adapters/REST/endpoints/resource-type.cjs +30 -0
  48. package/dist/cjs/adapters/REST/endpoints/resource.cjs +10 -0
  49. package/dist/cjs/adapters/REST/endpoints/role.cjs +48 -0
  50. package/dist/cjs/adapters/REST/endpoints/scheduled-action.cjs +44 -0
  51. package/dist/cjs/adapters/REST/endpoints/snapshot.cjs +30 -0
  52. package/dist/cjs/adapters/REST/endpoints/space-member.cjs +11 -0
  53. package/dist/cjs/adapters/REST/endpoints/space-membership.cjs +60 -0
  54. package/dist/cjs/adapters/REST/endpoints/space.cjs +34 -0
  55. package/dist/cjs/adapters/REST/endpoints/tag.cjs +37 -0
  56. package/dist/cjs/adapters/REST/endpoints/task.cjs +40 -0
  57. package/dist/cjs/adapters/REST/endpoints/team-membership.cjs +35 -0
  58. package/dist/cjs/adapters/REST/endpoints/team-space-membership.cjs +46 -0
  59. package/dist/cjs/adapters/REST/endpoints/team.cjs +36 -0
  60. package/dist/cjs/adapters/REST/endpoints/ui-config.cjs +22 -0
  61. package/dist/cjs/adapters/REST/endpoints/upload-credentials.cjs +16 -0
  62. package/dist/cjs/adapters/REST/endpoints/upload.cjs +42 -0
  63. package/dist/cjs/adapters/REST/endpoints/usage.cjs +17 -0
  64. package/dist/cjs/adapters/REST/endpoints/user-ui-config.cjs +22 -0
  65. package/dist/cjs/adapters/REST/endpoints/user.cjs +27 -0
  66. package/dist/cjs/adapters/REST/endpoints/utils.cjs +20 -0
  67. package/dist/cjs/adapters/REST/endpoints/webhook.cjs +98 -0
  68. package/dist/cjs/adapters/REST/endpoints/workflow-definition.cjs +41 -0
  69. package/dist/cjs/adapters/REST/endpoints/workflow.cjs +49 -0
  70. package/dist/cjs/adapters/REST/endpoints/workflows-changelog.cjs +11 -0
  71. package/dist/cjs/adapters/REST/make-request.cjs +19 -0
  72. package/dist/cjs/adapters/REST/rest-adapter.cjs +32 -0
  73. package/dist/cjs/common-types.cjs +6 -0
  74. package/dist/cjs/common-utils.cjs +38 -0
  75. package/dist/cjs/constants/editor-interface-defaults/controls-defaults.cjs +161 -0
  76. package/dist/cjs/constants/editor-interface-defaults/editors-defaults.cjs +40 -0
  77. package/dist/cjs/constants/editor-interface-defaults/index.cjs +14 -0
  78. package/dist/cjs/constants/editor-interface-defaults/sidebar-defaults.cjs +71 -0
  79. package/dist/cjs/constants/editor-interface-defaults/types.cjs +18 -0
  80. package/dist/cjs/create-adapter.cjs +21 -0
  81. package/dist/cjs/create-app-definition-api.cjs +254 -0
  82. package/dist/cjs/create-contentful-api.cjs +592 -0
  83. package/dist/cjs/create-entry-api.cjs +481 -0
  84. package/dist/cjs/create-environment-api.cjs +2403 -0
  85. package/dist/cjs/create-environment-template-api.cjs +270 -0
  86. package/dist/cjs/create-organization-api.cjs +1136 -0
  87. package/dist/cjs/create-space-api.cjs +1591 -0
  88. package/dist/cjs/create-ui-config-api.cjs +55 -0
  89. package/dist/cjs/create-user-ui-config-api.cjs +55 -0
  90. package/dist/cjs/enhance-with-methods.cjs +26 -0
  91. package/dist/cjs/entities/access-token.cjs +36 -0
  92. package/dist/cjs/entities/ai-action-invocation.cjs +46 -0
  93. package/dist/cjs/entities/ai-action.cjs +94 -0
  94. package/dist/cjs/entities/api-key.cjs +59 -0
  95. package/dist/cjs/entities/app-access-token.cjs +17 -0
  96. package/dist/cjs/entities/app-action-call.cjs +67 -0
  97. package/dist/cjs/entities/app-action.cjs +48 -0
  98. package/dist/cjs/entities/app-bundle.cjs +48 -0
  99. package/dist/cjs/entities/app-definition.cjs +29 -0
  100. package/dist/cjs/entities/app-details.cjs +39 -0
  101. package/dist/cjs/entities/app-event-subscription.cjs +34 -0
  102. package/dist/cjs/entities/app-installation.cjs +55 -0
  103. package/dist/cjs/entities/app-key.cjs +44 -0
  104. package/dist/cjs/entities/app-signed-request.cjs +17 -0
  105. package/dist/cjs/entities/app-signing-secret.cjs +34 -0
  106. package/dist/cjs/entities/app-upload.cjs +47 -0
  107. package/dist/cjs/entities/asset-key.cjs +17 -0
  108. package/dist/cjs/entities/asset.cjs +124 -0
  109. package/dist/cjs/entities/bulk-action.cjs +60 -0
  110. package/dist/cjs/entities/comment.cjs +63 -0
  111. package/dist/cjs/entities/concept-scheme.cjs +2 -0
  112. package/dist/cjs/entities/concept.cjs +2 -0
  113. package/dist/cjs/entities/content-type.cjs +120 -0
  114. package/dist/cjs/entities/editor-interface.cjs +50 -0
  115. package/dist/cjs/entities/entry.cjs +27 -0
  116. package/dist/cjs/entities/environment-alias.cjs +58 -0
  117. package/dist/cjs/entities/environment-template-installation.cjs +23 -0
  118. package/dist/cjs/entities/environment-template.cjs +18 -0
  119. package/dist/cjs/entities/environment.cjs +34 -0
  120. package/dist/cjs/entities/extension.cjs +54 -0
  121. package/dist/cjs/entities/function-log.cjs +26 -0
  122. package/dist/cjs/entities/function.cjs +66 -0
  123. package/dist/cjs/entities/index.cjs +131 -0
  124. package/dist/cjs/entities/locale.cjs +57 -0
  125. package/dist/cjs/entities/oauth-application.cjs +66 -0
  126. package/dist/cjs/entities/organization-invitation.cjs +17 -0
  127. package/dist/cjs/entities/organization-membership.cjs +53 -0
  128. package/dist/cjs/entities/organization.cjs +32 -0
  129. package/dist/cjs/entities/personal-access-token.cjs +36 -0
  130. package/dist/cjs/entities/preview-api-key.cjs +31 -0
  131. package/dist/cjs/entities/release-action.cjs +55 -0
  132. package/dist/cjs/entities/release.cjs +111 -0
  133. package/dist/cjs/entities/resource-provider.cjs +139 -0
  134. package/dist/cjs/entities/resource-type.cjs +98 -0
  135. package/dist/cjs/entities/resource.cjs +13 -0
  136. package/dist/cjs/entities/role.cjs +53 -0
  137. package/dist/cjs/entities/scheduled-action.cjs +154 -0
  138. package/dist/cjs/entities/snapshot.cjs +36 -0
  139. package/dist/cjs/entities/space-member.cjs +23 -0
  140. package/dist/cjs/entities/space-membership.cjs +53 -0
  141. package/dist/cjs/entities/space.cjs +33 -0
  142. package/dist/cjs/entities/tag.cjs +56 -0
  143. package/dist/cjs/entities/task.cjs +57 -0
  144. package/dist/cjs/entities/team-membership.cjs +54 -0
  145. package/dist/cjs/entities/team-space-membership.cjs +53 -0
  146. package/dist/cjs/entities/team.cjs +53 -0
  147. package/dist/cjs/entities/ui-config.cjs +20 -0
  148. package/dist/cjs/entities/upload.cjs +38 -0
  149. package/dist/cjs/entities/usage.cjs +25 -0
  150. package/dist/cjs/entities/user-ui-config.cjs +20 -0
  151. package/dist/cjs/entities/user.cjs +28 -0
  152. package/dist/cjs/entities/webhook.cjs +77 -0
  153. package/dist/cjs/entities/workflow-definition.cjs +79 -0
  154. package/dist/cjs/index.cjs +65 -0
  155. package/dist/cjs/methods/action.cjs +53 -0
  156. package/dist/cjs/methods/content-type.cjs +51 -0
  157. package/dist/cjs/methods/utils.cjs +11 -0
  158. package/dist/cjs/plain/as-iterator.cjs +32 -0
  159. package/dist/cjs/plain/checks.cjs +15 -0
  160. package/dist/cjs/plain/pagination-helper.cjs +56 -0
  161. package/dist/cjs/plain/plain-client.cjs +516 -0
  162. package/dist/cjs/plain/wrappers/wrap.cjs +26 -0
  163. package/dist/cjs/upload-http-client.cjs +17 -0
  164. package/dist/contentful-management.browser.js +50 -34
  165. package/dist/contentful-management.browser.min.js +1 -1
  166. package/dist/contentful-management.cjs +35 -19
  167. package/dist/esm/create-contentful-api.js +1 -1
  168. package/dist/esm/index.js +1 -1
  169. package/dist/esm/plain/plain-client.js +1 -1
  170. package/dist/stats-browser-min.html +1 -1
  171. package/package.json +6 -6
  172. package/types.d.ts +0 -1
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var copy = require('fast-copy');
5
+ var enhanceWithMethods = require('../enhance-with-methods.js');
6
+ var commonUtils = require('../common-utils.js');
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ function createAppInstallationApi(makeRequest) {
12
+ const getParams = (data) => ({
13
+ spaceId: data.sys.space.sys.id,
14
+ environmentId: data.sys.environment.sys.id,
15
+ appDefinitionId: data.sys.appDefinition.sys.id,
16
+ });
17
+ return {
18
+ update: function update() {
19
+ const data = this.toPlainObject();
20
+ return makeRequest({
21
+ entityType: 'AppInstallation',
22
+ action: 'upsert',
23
+ params: getParams(data),
24
+ headers: {},
25
+ payload: data,
26
+ }).then((data) => wrapAppInstallation(makeRequest, data));
27
+ },
28
+ delete: function del() {
29
+ const data = this.toPlainObject();
30
+ return makeRequest({
31
+ entityType: 'AppInstallation',
32
+ action: 'delete',
33
+ params: getParams(data),
34
+ });
35
+ },
36
+ };
37
+ }
38
+ /**
39
+ * @private
40
+ * @param makeRequest - function to make requests via an adapter
41
+ * @param data - Raw App Installation data
42
+ * @return Wrapped App installation data
43
+ */
44
+ function wrapAppInstallation(makeRequest, data) {
45
+ const appInstallation = contentfulSdkCore.toPlainObject(copy(data));
46
+ const appInstallationWithMethods = enhanceWithMethods(appInstallation, createAppInstallationApi(makeRequest));
47
+ return contentfulSdkCore.freezeSys(appInstallationWithMethods);
48
+ }
49
+ /**
50
+ * @private
51
+ */
52
+ const wrapAppInstallationCollection = commonUtils.wrapCollection(wrapAppInstallation);
53
+
54
+ exports.wrapAppInstallation = wrapAppInstallation;
55
+ exports.wrapAppInstallationCollection = wrapAppInstallationCollection;
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+ var enhanceWithMethods = require('../enhance-with-methods.js');
6
+ var commonUtils = require('../common-utils.js');
7
+
8
+ function createKeyApi(makeRequest) {
9
+ const getParams = (data) => ({
10
+ organizationId: data.sys.organization.sys.id,
11
+ appDefinitionId: data.sys.appDefinition.sys.id,
12
+ fingerprint: data.sys.id,
13
+ });
14
+ return {
15
+ delete: function del() {
16
+ const self = this;
17
+ return makeRequest({
18
+ entityType: 'AppKey',
19
+ action: 'delete',
20
+ params: getParams(self),
21
+ });
22
+ },
23
+ };
24
+ }
25
+ /**
26
+ * @private
27
+ * @param http - HTTP client instance
28
+ * @param data - Raw AppKey data
29
+ * @return Wrapped AppKey data
30
+ */
31
+ function wrapAppKey(makeRequest, data) {
32
+ const key = contentfulSdkCore.toPlainObject(copy(data));
33
+ return enhanceWithMethods(key, createKeyApi(makeRequest));
34
+ }
35
+ /**
36
+ * @private
37
+ * @param makeRequest - function to make requests via an adapter
38
+ * @param data - Raw App Key collection data
39
+ * @return Wrapped App Key collection data
40
+ */
41
+ const wrapAppKeyCollection = commonUtils.wrapCollection(wrapAppKey);
42
+
43
+ exports.wrapAppKey = wrapAppKey;
44
+ exports.wrapAppKeyCollection = wrapAppKeyCollection;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+
6
+ /**
7
+ * @private
8
+ * @param http - HTTP client instance
9
+ * @param data - Raw AppSignedRequest data
10
+ * @return Wrapped AppSignedRequest data
11
+ */
12
+ function wrapAppSignedRequest(_makeRequest, data) {
13
+ const signedRequest = contentfulSdkCore.toPlainObject(copy(data));
14
+ return signedRequest;
15
+ }
16
+
17
+ exports.wrapAppSignedRequest = wrapAppSignedRequest;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+ var enhanceWithMethods = require('../enhance-with-methods.js');
6
+
7
+ function createSigningSecretApi(makeRequest) {
8
+ const getParams = (data) => ({
9
+ organizationId: data.sys.organization.sys.id,
10
+ appDefinitionId: data.sys.appDefinition.sys.id,
11
+ });
12
+ return {
13
+ delete: function del() {
14
+ const self = this;
15
+ return makeRequest({
16
+ entityType: 'AppSigningSecret',
17
+ action: 'delete',
18
+ params: getParams(self),
19
+ });
20
+ },
21
+ };
22
+ }
23
+ /**
24
+ * @private
25
+ * @param http - HTTP client instance
26
+ * @param data - Raw AppSigningSecret data
27
+ * @return Wrapped AppSigningSecret data
28
+ */
29
+ function wrapAppSigningSecret(makeRequest, data) {
30
+ const signingSecret = contentfulSdkCore.toPlainObject(copy(data));
31
+ return enhanceWithMethods(signingSecret, createSigningSecretApi(makeRequest));
32
+ }
33
+
34
+ exports.wrapAppSigningSecret = wrapAppSigningSecret;
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var copy = require('fast-copy');
5
+ var commonUtils = require('../common-utils.js');
6
+ var enhanceWithMethods = require('../enhance-with-methods.js');
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ function createAppUploadApi(makeRequest) {
12
+ const getParams = (data) => ({
13
+ organizationId: data.sys.organization.sys.id,
14
+ appUploadId: data.sys.id,
15
+ });
16
+ return {
17
+ delete: function del() {
18
+ const data = this.toPlainObject();
19
+ return makeRequest({
20
+ entityType: 'AppUpload',
21
+ action: 'delete',
22
+ params: getParams(data),
23
+ });
24
+ },
25
+ };
26
+ }
27
+ /**
28
+ * @private
29
+ * @param makeRequest - function to make requests via an adapter
30
+ * @param data - Raw App Upload data
31
+ * @return Wrapped App Upload data
32
+ */
33
+ function wrapAppUpload(makeRequest, data) {
34
+ const appUpload = contentfulSdkCore.toPlainObject(copy(data));
35
+ const appUploadWithMethods = enhanceWithMethods(appUpload, createAppUploadApi(makeRequest));
36
+ return contentfulSdkCore.freezeSys(appUploadWithMethods);
37
+ }
38
+ /**
39
+ * @private
40
+ * @param makeRequest - function to make requests via an adapter
41
+ * @param data - Raw App Upload collection data
42
+ * @return Wrapped App Upload collection data
43
+ */
44
+ const wrapAppUploadCollection = commonUtils.wrapCollection(wrapAppUpload);
45
+
46
+ exports.wrapAppUpload = wrapAppUpload;
47
+ exports.wrapAppUploadCollection = wrapAppUploadCollection;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+
6
+ /**
7
+ * @private
8
+ * @param http - HTTP client instance
9
+ * @param data - Raw asset key data
10
+ * @return Wrapped asset key data
11
+ */
12
+ function wrapAssetKey(_makeRequest, data) {
13
+ const assetKey = contentfulSdkCore.toPlainObject(copy(data));
14
+ return assetKey;
15
+ }
16
+
17
+ exports.wrapAssetKey = wrapAssetKey;
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+ var enhanceWithMethods = require('../enhance-with-methods.js');
6
+ var commonUtils = require('../common-utils.js');
7
+ var checks = require('../plain/checks.js');
8
+
9
+ /**
10
+ * @private
11
+ */
12
+ function createAssetApi(makeRequest) {
13
+ const getParams = (raw) => {
14
+ return {
15
+ spaceId: raw.sys.space.sys.id,
16
+ environmentId: raw.sys.environment.sys.id,
17
+ assetId: raw.sys.id,
18
+ };
19
+ };
20
+ return {
21
+ processForLocale: function processForLocale(locale, options) {
22
+ const raw = this.toPlainObject();
23
+ return makeRequest({
24
+ entityType: 'Asset',
25
+ action: 'processForLocale',
26
+ params: Object.assign(Object.assign({}, getParams(raw)), { locale,
27
+ options, asset: raw }),
28
+ }).then((data) => wrapAsset(makeRequest, data));
29
+ },
30
+ processForAllLocales: function processForAllLocales(options) {
31
+ const raw = this.toPlainObject();
32
+ return makeRequest({
33
+ entityType: 'Asset',
34
+ action: 'processForAllLocales',
35
+ params: Object.assign(Object.assign({}, getParams(raw)), { asset: raw, options }),
36
+ }).then((data) => wrapAsset(makeRequest, data));
37
+ },
38
+ update: function update() {
39
+ const raw = this.toPlainObject();
40
+ return makeRequest({
41
+ entityType: 'Asset',
42
+ action: 'update',
43
+ params: getParams(raw),
44
+ payload: raw,
45
+ headers: {},
46
+ }).then((data) => wrapAsset(makeRequest, data));
47
+ },
48
+ delete: function del() {
49
+ const raw = this.toPlainObject();
50
+ return makeRequest({
51
+ entityType: 'Asset',
52
+ action: 'delete',
53
+ params: getParams(raw),
54
+ });
55
+ },
56
+ publish: function publish() {
57
+ const raw = this.toPlainObject();
58
+ return makeRequest({
59
+ entityType: 'Asset',
60
+ action: 'publish',
61
+ params: getParams(raw),
62
+ payload: raw,
63
+ }).then((data) => wrapAsset(makeRequest, data));
64
+ },
65
+ unpublish: function unpublish() {
66
+ const raw = this.toPlainObject();
67
+ return makeRequest({
68
+ entityType: 'Asset',
69
+ action: 'unpublish',
70
+ params: getParams(raw),
71
+ }).then((data) => wrapAsset(makeRequest, data));
72
+ },
73
+ archive: function archive() {
74
+ const raw = this.toPlainObject();
75
+ return makeRequest({
76
+ entityType: 'Asset',
77
+ action: 'archive',
78
+ params: getParams(raw),
79
+ }).then((data) => wrapAsset(makeRequest, data));
80
+ },
81
+ unarchive: function unarchive() {
82
+ const raw = this.toPlainObject();
83
+ return makeRequest({
84
+ entityType: 'Asset',
85
+ action: 'unarchive',
86
+ params: getParams(raw),
87
+ }).then((data) => wrapAsset(makeRequest, data));
88
+ },
89
+ isPublished: function isPublished() {
90
+ const raw = this.toPlainObject();
91
+ return checks.isPublished(raw);
92
+ },
93
+ isUpdated: function isUpdated() {
94
+ const raw = this.toPlainObject();
95
+ return checks.isUpdated(raw);
96
+ },
97
+ isDraft: function isDraft() {
98
+ const raw = this.toPlainObject();
99
+ return checks.isDraft(raw);
100
+ },
101
+ isArchived: function isArchived() {
102
+ const raw = this.toPlainObject();
103
+ return checks.isArchived(raw);
104
+ },
105
+ };
106
+ }
107
+ /**
108
+ * @private
109
+ * @param makeRequest - function to make requests via an adapter
110
+ * @param data - Raw asset data
111
+ * @return Wrapped asset data
112
+ */
113
+ function wrapAsset(makeRequest, data) {
114
+ const asset = contentfulSdkCore.toPlainObject(copy(data));
115
+ const assetWithMethods = enhanceWithMethods(asset, createAssetApi(makeRequest));
116
+ return contentfulSdkCore.freezeSys(assetWithMethods);
117
+ }
118
+ /**
119
+ * @private
120
+ */
121
+ const wrapAssetCollection = commonUtils.wrapCollection(wrapAsset);
122
+
123
+ exports.wrapAsset = wrapAsset;
124
+ exports.wrapAssetCollection = wrapAssetCollection;
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var copy = require('fast-copy');
5
+ var enhanceWithMethods = require('../enhance-with-methods.js');
6
+ var action = require('../methods/action.js');
7
+
8
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9
+ /** Represents the state of the BulkAction */
10
+ exports.BulkActionStatus = void 0;
11
+ (function (BulkActionStatus) {
12
+ /** BulkAction is pending execution */
13
+ BulkActionStatus["created"] = "created";
14
+ /** BulkAction has been started and pending completion */
15
+ BulkActionStatus["inProgress"] = "inProgress";
16
+ /** BulkAction was completed successfully (terminal state) */
17
+ BulkActionStatus["succeeded"] = "succeeded";
18
+ /** BulkAction failed to complete (terminal state) */
19
+ BulkActionStatus["failed"] = "failed";
20
+ })(exports.BulkActionStatus || (exports.BulkActionStatus = {}));
21
+ Object.values(exports.BulkActionStatus);
22
+ /**
23
+ * @private
24
+ */
25
+ function createBulkActionApi(makeRequest) {
26
+ const getParams = (self) => {
27
+ const bulkAction = self.toPlainObject();
28
+ return {
29
+ spaceId: bulkAction.sys.space.sys.id,
30
+ environmentId: bulkAction.sys.environment.sys.id,
31
+ bulkActionId: bulkAction.sys.id,
32
+ };
33
+ };
34
+ return {
35
+ async get() {
36
+ const params = getParams(this);
37
+ return makeRequest({
38
+ entityType: 'BulkAction',
39
+ action: 'get',
40
+ params,
41
+ }).then((bulkAction) => wrapBulkAction(makeRequest, bulkAction));
42
+ },
43
+ async waitProcessing(options) {
44
+ return action.pollAsyncActionStatus(async () => this.get(), options);
45
+ },
46
+ };
47
+ }
48
+ /**
49
+ * @private
50
+ * @param makeRequest - function to make requests via an adapter
51
+ * @param data - Raw BulkAction data
52
+ * @return Wrapped BulkAction data
53
+ */
54
+ function wrapBulkAction(makeRequest, data) {
55
+ const bulkAction = contentfulSdkCore.toPlainObject(copy(data));
56
+ const bulkActionWithApiMethods = enhanceWithMethods(bulkAction, createBulkActionApi(makeRequest));
57
+ return contentfulSdkCore.freezeSys(bulkActionWithApiMethods);
58
+ }
59
+
60
+ exports.wrapBulkAction = wrapBulkAction;
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var contentfulSdkCore = require('contentful-sdk-core');
6
+ var copy = require('fast-copy');
7
+ var commonUtils = require('../common-utils.js');
8
+ var enhanceWithMethods = require('../enhance-with-methods.js');
9
+
10
+ // Remove and replace with BLOCKS as soon as rich-text-types supports mentions
11
+ exports.CommentNode = void 0;
12
+ (function (CommentNode) {
13
+ CommentNode["Document"] = "document";
14
+ CommentNode["Paragraph"] = "paragraph";
15
+ CommentNode["Mention"] = "mention";
16
+ })(exports.CommentNode || (exports.CommentNode = {}));
17
+ /**
18
+ * @private
19
+ */
20
+ function createCommentApi(makeRequest) {
21
+ const getParams = (comment) => ({
22
+ spaceId: comment.sys.space.sys.id,
23
+ environmentId: comment.sys.environment.sys.id,
24
+ entryId: comment.sys.parentEntity.sys.id,
25
+ commentId: comment.sys.id,
26
+ });
27
+ return {
28
+ update: async function () {
29
+ const raw = this.toPlainObject();
30
+ const data = await makeRequest({
31
+ entityType: 'Comment',
32
+ action: 'update',
33
+ params: getParams(raw),
34
+ payload: raw,
35
+ });
36
+ return wrapComment(makeRequest, data);
37
+ },
38
+ delete: async function () {
39
+ const raw = this.toPlainObject();
40
+ await makeRequest({
41
+ entityType: 'Comment',
42
+ action: 'delete',
43
+ params: Object.assign(Object.assign({}, getParams(raw)), { version: raw.sys.version }),
44
+ });
45
+ },
46
+ };
47
+ }
48
+ /**
49
+ * @private
50
+ */
51
+ function wrapComment(makeRequest, data) {
52
+ const comment = contentfulSdkCore.toPlainObject(copy(data));
53
+ const commentWithMethods = enhanceWithMethods(comment, createCommentApi(makeRequest));
54
+ return contentfulSdkCore.freezeSys(commentWithMethods);
55
+ }
56
+ /**
57
+ * @private
58
+ */
59
+ const wrapCommentCollection = commonUtils.wrapCollection(wrapComment);
60
+
61
+ exports.default = createCommentApi;
62
+ exports.wrapComment = wrapComment;
63
+ exports.wrapCommentCollection = wrapCommentCollection;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var copy = require('fast-copy');
5
+ var commonUtils = require('../common-utils.js');
6
+ var enhanceWithMethods = require('../enhance-with-methods.js');
7
+ var checks = require('../plain/checks.js');
8
+ var editorInterface = require('./editor-interface.js');
9
+ var snapshot = require('./snapshot.js');
10
+ var contentType = require('../methods/content-type.js');
11
+
12
+ /**
13
+ * @private
14
+ */
15
+ function createContentTypeApi(makeRequest) {
16
+ const getParams = (self) => {
17
+ const contentType = self.toPlainObject();
18
+ return {
19
+ raw: contentType,
20
+ params: {
21
+ spaceId: contentType.sys.space.sys.id,
22
+ environmentId: contentType.sys.environment.sys.id,
23
+ contentTypeId: contentType.sys.id,
24
+ },
25
+ };
26
+ };
27
+ return {
28
+ update: function () {
29
+ const { raw, params } = getParams(this);
30
+ return makeRequest({
31
+ entityType: 'ContentType',
32
+ action: 'update',
33
+ params,
34
+ payload: raw,
35
+ }).then((data) => wrapContentType(makeRequest, data));
36
+ },
37
+ delete: function () {
38
+ const { params } = getParams(this);
39
+ return makeRequest({
40
+ entityType: 'ContentType',
41
+ action: 'delete',
42
+ params,
43
+ }).then(() => {
44
+ // noop
45
+ });
46
+ },
47
+ publish: function () {
48
+ const { raw, params } = getParams(this);
49
+ return makeRequest({
50
+ entityType: 'ContentType',
51
+ action: 'publish',
52
+ params,
53
+ payload: raw,
54
+ }).then((data) => wrapContentType(makeRequest, data));
55
+ },
56
+ unpublish: function () {
57
+ const { params } = getParams(this);
58
+ return makeRequest({
59
+ entityType: 'ContentType',
60
+ action: 'unpublish',
61
+ params,
62
+ }).then((data) => wrapContentType(makeRequest, data));
63
+ },
64
+ getEditorInterface: function () {
65
+ const { params } = getParams(this);
66
+ return makeRequest({
67
+ entityType: 'EditorInterface',
68
+ action: 'get',
69
+ params,
70
+ }).then((data) => editorInterface.wrapEditorInterface(makeRequest, data));
71
+ },
72
+ getSnapshots: function (query = {}) {
73
+ const { params } = getParams(this);
74
+ return makeRequest({
75
+ entityType: 'Snapshot',
76
+ action: 'getManyForContentType',
77
+ params: Object.assign(Object.assign({}, params), { query }),
78
+ }).then((data) => snapshot.wrapSnapshotCollection(makeRequest, data));
79
+ },
80
+ getSnapshot: function (snapshotId) {
81
+ const { params } = getParams(this);
82
+ return makeRequest({
83
+ entityType: 'Snapshot',
84
+ action: 'getForContentType',
85
+ params: Object.assign(Object.assign({}, params), { snapshotId }),
86
+ }).then((data) => snapshot.wrapSnapshot(makeRequest, data));
87
+ },
88
+ isPublished: function () {
89
+ return checks.isPublished(this);
90
+ },
91
+ isUpdated: function () {
92
+ return checks.isUpdated(this);
93
+ },
94
+ isDraft: function () {
95
+ return checks.isDraft(this);
96
+ },
97
+ omitAndDeleteField: function (fieldId) {
98
+ const { raw, params } = getParams(this);
99
+ return contentType.omitAndDeleteField(makeRequest, Object.assign(Object.assign({}, params), { fieldId }), raw).then((data) => wrapContentType(makeRequest, data));
100
+ },
101
+ };
102
+ }
103
+ /**
104
+ * @private
105
+ * @param makeRequest - function to make requests via an adapter
106
+ * @param data - Raw content type data
107
+ * @return Wrapped content type data
108
+ */
109
+ function wrapContentType(makeRequest, data) {
110
+ const contentType = contentfulSdkCore.toPlainObject(copy(data));
111
+ const contentTypeWithMethods = enhanceWithMethods(contentType, createContentTypeApi(makeRequest));
112
+ return contentfulSdkCore.freezeSys(contentTypeWithMethods);
113
+ }
114
+ /**
115
+ * @private
116
+ */
117
+ const wrapContentTypeCollection = commonUtils.wrapCollection(wrapContentType);
118
+
119
+ exports.wrapContentType = wrapContentType;
120
+ exports.wrapContentTypeCollection = wrapContentTypeCollection;
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+ var enhanceWithMethods = require('../enhance-with-methods.js');
6
+ var commonUtils = require('../common-utils.js');
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ function createEditorInterfaceApi(makeRequest) {
12
+ return {
13
+ update: function () {
14
+ const self = this;
15
+ const raw = self.toPlainObject();
16
+ return makeRequest({
17
+ entityType: 'EditorInterface',
18
+ action: 'update',
19
+ params: {
20
+ spaceId: self.sys.space.sys.id,
21
+ environmentId: self.sys.environment.sys.id,
22
+ contentTypeId: self.sys.contentType.sys.id,
23
+ },
24
+ payload: raw,
25
+ }).then((response) => wrapEditorInterface(makeRequest, response));
26
+ },
27
+ getControlForField: function (fieldId) {
28
+ const self = this;
29
+ const result = (self.controls || []).filter((control) => {
30
+ return control.fieldId === fieldId;
31
+ });
32
+ return result && result.length > 0 ? result[0] : null;
33
+ },
34
+ };
35
+ }
36
+ /**
37
+ * @private
38
+ */
39
+ function wrapEditorInterface(makeRequest, data) {
40
+ const editorInterface = contentfulSdkCore.toPlainObject(copy(data));
41
+ const editorInterfaceWithMethods = enhanceWithMethods(editorInterface, createEditorInterfaceApi(makeRequest));
42
+ return contentfulSdkCore.freezeSys(editorInterfaceWithMethods);
43
+ }
44
+ /**
45
+ * @private
46
+ */
47
+ const wrapEditorInterfaceCollection = commonUtils.wrapCollection(wrapEditorInterface);
48
+
49
+ exports.wrapEditorInterface = wrapEditorInterface;
50
+ exports.wrapEditorInterfaceCollection = wrapEditorInterfaceCollection;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var copy = require('fast-copy');
5
+ var commonUtils = require('../common-utils.js');
6
+ var createEntryApi = require('../create-entry-api.js');
7
+ var enhanceWithMethods = require('../enhance-with-methods.js');
8
+
9
+ /**
10
+ * @private
11
+ * @param makeRequest - function to make requests via an adapter
12
+ * @param data - Raw entry data
13
+ * @return Wrapped entry data
14
+ */
15
+ function wrapEntry(makeRequest, data) {
16
+ const entry = contentfulSdkCore.toPlainObject(copy(data));
17
+ const entryWithMethods = enhanceWithMethods(entry, createEntryApi(makeRequest));
18
+ return contentfulSdkCore.freezeSys(entryWithMethods);
19
+ }
20
+ /**
21
+ * Data is also mixed in with link getters if links exist and includes were requested
22
+ * @private
23
+ */
24
+ const wrapEntryCollection = commonUtils.wrapCollection(wrapEntry);
25
+
26
+ exports.wrapEntry = wrapEntry;
27
+ exports.wrapEntryCollection = wrapEntryCollection;