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,16 @@
1
+ 'use strict';
2
+
3
+ var uploadHttpClient = require('../../../upload-http-client.js');
4
+ var raw = require('./raw.js');
5
+
6
+ const getBaseUrl = (params) => {
7
+ var _a;
8
+ return `/spaces/${params.spaceId}/environments/${(_a = params.environmentId) !== null && _a !== void 0 ? _a : 'master'}/upload_credentials`;
9
+ };
10
+ const create = (http, params) => {
11
+ const httpUpload = uploadHttpClient.getUploadHttpClient(http);
12
+ const path = getBaseUrl(params);
13
+ return raw.post(httpUpload, path);
14
+ };
15
+
16
+ exports.create = create;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var uploadHttpClient = require('../../../upload-http-client.js');
4
+ var raw = require('./raw.js');
5
+
6
+ const getBaseUploadUrl = (params) => {
7
+ const spacePath = `/spaces/${params.spaceId}/uploads`;
8
+ const environmentPath = `/spaces/${params.spaceId}/environments/${params.environmentId}/uploads`;
9
+ const path = params.environmentId ? environmentPath : spacePath;
10
+ return path;
11
+ };
12
+ const getEntityUploadUrl = (params) => {
13
+ const path = getBaseUploadUrl(params);
14
+ return path + `/${params.uploadId}`;
15
+ };
16
+ const create = (http, params, data) => {
17
+ const httpUpload = uploadHttpClient.getUploadHttpClient(http);
18
+ const { file } = data;
19
+ if (!file) {
20
+ return Promise.reject(new Error('Unable to locate a file to upload.'));
21
+ }
22
+ const path = getBaseUploadUrl(params);
23
+ return raw.post(httpUpload, path, file, {
24
+ headers: {
25
+ 'Content-Type': 'application/octet-stream',
26
+ },
27
+ });
28
+ };
29
+ const del = (http, params) => {
30
+ const httpUpload = uploadHttpClient.getUploadHttpClient(http);
31
+ const path = getEntityUploadUrl(params);
32
+ return raw.del(httpUpload, path);
33
+ };
34
+ const get = (http, params) => {
35
+ const httpUpload = uploadHttpClient.getUploadHttpClient(http);
36
+ const path = getEntityUploadUrl(params);
37
+ return raw.get(httpUpload, path);
38
+ };
39
+
40
+ exports.create = create;
41
+ exports.del = del;
42
+ exports.get = get;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var raw = require('./raw.js');
4
+
5
+ const getManyForSpace = (http, params) => {
6
+ return raw.get(http, `/organizations/${params.organizationId}/space_periodic_usages`, {
7
+ params: params.query,
8
+ });
9
+ };
10
+ const getManyForOrganization = (http, params) => {
11
+ return raw.get(http, `/organizations/${params.organizationId}/organization_periodic_usages`, {
12
+ params: params.query,
13
+ });
14
+ };
15
+
16
+ exports.getManyForOrganization = getManyForOrganization;
17
+ exports.getManyForSpace = getManyForSpace;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var raw = require('./raw.js');
5
+
6
+ const getUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/ui_config/me`;
7
+ const get = (http, params) => {
8
+ return raw.get(http, getUrl(params));
9
+ };
10
+ const update = (http, params, rawData) => {
11
+ var _a;
12
+ const data = copy(rawData);
13
+ delete data.sys;
14
+ return raw.put(http, getUrl(params), data, {
15
+ headers: {
16
+ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0,
17
+ },
18
+ });
19
+ };
20
+
21
+ exports.get = get;
22
+ exports.update = update;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var raw = require('./raw.js');
4
+
5
+ const getForSpace = (http, params) => {
6
+ return raw.get(http, `/spaces/${params.spaceId}/users/${params.userId}`);
7
+ };
8
+ const getCurrent = (http, params) => raw.get(http, `/users/me`, { params: params === null || params === void 0 ? void 0 : params.query });
9
+ const getManyForSpace = (http, params) => {
10
+ return raw.get(http, `/spaces/${params.spaceId}/users`, {
11
+ params: params.query,
12
+ });
13
+ };
14
+ const getForOrganization = (http, params) => {
15
+ return raw.get(http, `/organizations/${params.organizationId}/users/${params.userId}`);
16
+ };
17
+ const getManyForOrganization = (http, params) => {
18
+ return raw.get(http, `/organizations/${params.organizationId}/users`, {
19
+ params: params.query,
20
+ });
21
+ };
22
+
23
+ exports.getCurrent = getCurrent;
24
+ exports.getForOrganization = getForOrganization;
25
+ exports.getForSpace = getForSpace;
26
+ exports.getManyForOrganization = getManyForOrganization;
27
+ exports.getManyForSpace = getManyForSpace;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+
5
+ function normalizeSelect(query) {
6
+ if (query && query.select && !/sys/i.test(query.select)) {
7
+ return Object.assign(Object.assign({}, query), { select: query.select + ',sys' });
8
+ }
9
+ return query;
10
+ }
11
+ function normalizeSpaceId(query) {
12
+ if (query && query.spaceId) {
13
+ const { spaceId } = query, rest = tslib.__rest(query, ["spaceId"]);
14
+ return Object.assign(Object.assign({}, rest), { 'sys.space.sys.id[in]': spaceId });
15
+ }
16
+ return query;
17
+ }
18
+
19
+ exports.normalizeSelect = normalizeSelect;
20
+ exports.normalizeSpaceId = normalizeSpaceId;
@@ -0,0 +1,98 @@
1
+ 'use strict';
2
+
3
+ var copy = require('fast-copy');
4
+ var raw = require('./raw.js');
5
+ var utils = require('./utils.js');
6
+
7
+ const getBaseUrl = (params) => `/spaces/${params.spaceId}/webhook_definitions`;
8
+ const getWebhookCallBaseUrl = (params) => `/spaces/${params.spaceId}/webhooks`;
9
+ const getWebhookUrl = (params) => `${getBaseUrl(params)}/${params.webhookDefinitionId}`;
10
+ const getWebhookCallUrl = (params) => `${getWebhookCallBaseUrl(params)}/${params.webhookDefinitionId}/calls`;
11
+ const getWebhookCallDetailsUrl = (params) => `${getWebhookCallBaseUrl(params)}/${params.webhookDefinitionId}/calls/${params.callId}`;
12
+ const getWebhookHealthUrl = (params) => `${getWebhookCallBaseUrl(params)}/${params.webhookDefinitionId}/health`;
13
+ const getWebhookSettingsUrl = (params) => `/spaces/${params.spaceId}/webhook_settings`;
14
+ const getWebhookSigningSecretUrl = (params) => `${getWebhookSettingsUrl(params)}/signing_secret`;
15
+ const getWebhookRetryPolicyUrl = (params) => `${getWebhookSettingsUrl(params)}/retry_policy`;
16
+ const get = (http, params) => {
17
+ return raw.get(http, getWebhookUrl(params));
18
+ };
19
+ const getManyCallDetails = (http, params) => {
20
+ return raw.get(http, getWebhookCallUrl(params), {
21
+ params: utils.normalizeSelect(params.query),
22
+ });
23
+ };
24
+ const getCallDetails = (http, params) => {
25
+ return raw.get(http, getWebhookCallDetailsUrl(params));
26
+ };
27
+ const getHealthStatus = (http, params) => {
28
+ return raw.get(http, getWebhookHealthUrl(params));
29
+ };
30
+ const getMany = (http, params) => {
31
+ return raw.get(http, getBaseUrl(params), {
32
+ params: utils.normalizeSelect(params.query),
33
+ });
34
+ };
35
+ const getSigningSecret = (http, params) => {
36
+ return raw.get(http, getWebhookSigningSecretUrl(params));
37
+ };
38
+ /**
39
+ * @deprecated The EAP for this feature has ended. This method will be removed in the next major version.
40
+ */
41
+ const getRetryPolicy = (http, params) => {
42
+ return raw.get(http, getWebhookRetryPolicyUrl(params));
43
+ };
44
+ const create = (http, params, rawData, headers) => {
45
+ const data = copy(rawData);
46
+ return raw.post(http, getBaseUrl(params), data, { headers });
47
+ };
48
+ const createWithId = (http, params, rawData, headers) => {
49
+ const data = copy(rawData);
50
+ return raw.put(http, getWebhookUrl(params), data, { headers });
51
+ };
52
+ const update = async (http, params, rawData, headers) => {
53
+ var _a;
54
+ const data = copy(rawData);
55
+ delete data.sys;
56
+ return raw.put(http, getWebhookUrl(params), data, {
57
+ headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
58
+ });
59
+ };
60
+ const upsertSigningSecret = async (http, params, rawData) => {
61
+ const data = copy(rawData);
62
+ return raw.put(http, getWebhookSigningSecretUrl(params), data);
63
+ };
64
+ /**
65
+ * @deprecated The EAP for this feature has ended. This method will be removed in the next major version.
66
+ */
67
+ const upsertRetryPolicy = async (http, params, rawData) => {
68
+ const data = copy(rawData);
69
+ return raw.put(http, getWebhookRetryPolicyUrl(params), data);
70
+ };
71
+ const del = (http, params) => {
72
+ return raw.del(http, getWebhookUrl(params));
73
+ };
74
+ const deleteSigningSecret = async (http, params) => {
75
+ return raw.del(http, getWebhookSigningSecretUrl(params));
76
+ };
77
+ /**
78
+ * @deprecated The EAP for this feature has ended. This method will be removed in the next major version.
79
+ */
80
+ const deleteRetryPolicy = async (http, params) => {
81
+ return raw.del(http, getWebhookRetryPolicyUrl(params));
82
+ };
83
+
84
+ exports.create = create;
85
+ exports.createWithId = createWithId;
86
+ exports.del = del;
87
+ exports.deleteRetryPolicy = deleteRetryPolicy;
88
+ exports.deleteSigningSecret = deleteSigningSecret;
89
+ exports.get = get;
90
+ exports.getCallDetails = getCallDetails;
91
+ exports.getHealthStatus = getHealthStatus;
92
+ exports.getMany = getMany;
93
+ exports.getManyCallDetails = getManyCallDetails;
94
+ exports.getRetryPolicy = getRetryPolicy;
95
+ exports.getSigningSecret = getSigningSecret;
96
+ exports.update = update;
97
+ exports.upsertRetryPolicy = upsertRetryPolicy;
98
+ exports.upsertSigningSecret = upsertSigningSecret;
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var copy = require('fast-copy');
5
+ var raw = require('./raw.js');
6
+
7
+ const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/workflow_definitions`;
8
+ const getWorkflowDefinitionUrl = (params) => `${getBaseUrl(params)}/${params.workflowDefinitionId}`;
9
+ const get = (http, params, headers) => raw.get(http, getWorkflowDefinitionUrl(params), {
10
+ headers,
11
+ });
12
+ const getMany = (http, params, headers) => raw.get(http, getBaseUrl(params), {
13
+ headers,
14
+ params: params.query,
15
+ });
16
+ const create = (http, params, rawData, headers) => {
17
+ const data = copy(rawData);
18
+ return raw.post(http, getBaseUrl(params), data, {
19
+ headers,
20
+ });
21
+ };
22
+ const update = (http, params, rawData, headers) => {
23
+ var _a;
24
+ const data = copy(rawData);
25
+ delete data.sys;
26
+ return raw.put(http, getWorkflowDefinitionUrl(params), data, {
27
+ headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
28
+ });
29
+ };
30
+ const del = (http, _a, headers) => {
31
+ var { version } = _a, params = tslib.__rest(_a, ["version"]);
32
+ return raw.del(http, getWorkflowDefinitionUrl(params), {
33
+ headers: Object.assign({ 'X-Contentful-Version': version }, headers),
34
+ });
35
+ };
36
+
37
+ exports.create = create;
38
+ exports.del = del;
39
+ exports.get = get;
40
+ exports.getMany = getMany;
41
+ exports.update = update;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var copy = require('fast-copy');
5
+ var raw = require('./raw.js');
6
+
7
+ const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/workflows`;
8
+ const getWorkflowUrl = (params) => `${getBaseUrl(params)}/${params.workflowId}`;
9
+ const completeWorkflowUrl = (params) => `${getWorkflowUrl(params)}/complete`;
10
+ const getMany = (http, params, headers) => raw.get(http, getBaseUrl(params), {
11
+ headers,
12
+ params: params.query,
13
+ });
14
+ const get = (http, params, headers) => raw.get(http, getWorkflowUrl(params), {
15
+ headers,
16
+ });
17
+ const create = (http, params, rawData, headers) => {
18
+ const data = copy(rawData);
19
+ return raw.post(http, getBaseUrl(params), data, {
20
+ headers,
21
+ });
22
+ };
23
+ const update = (http, params, rawData, headers) => {
24
+ var _a;
25
+ const data = copy(rawData);
26
+ delete data.sys;
27
+ return raw.put(http, getWorkflowUrl(params), data, {
28
+ headers: Object.assign({ 'X-Contentful-Version': (_a = rawData.sys.version) !== null && _a !== void 0 ? _a : 0 }, headers),
29
+ });
30
+ };
31
+ const del = (http, _a, headers) => {
32
+ var { version } = _a, params = tslib.__rest(_a, ["version"]);
33
+ return raw.del(http, getWorkflowUrl(params), {
34
+ headers: Object.assign({ 'X-Contentful-Version': version }, headers),
35
+ });
36
+ };
37
+ const complete = (http, _a, headers) => {
38
+ var { version } = _a, params = tslib.__rest(_a, ["version"]);
39
+ return raw.put(http, completeWorkflowUrl(params), null, {
40
+ headers: Object.assign({ 'X-Contentful-Version': version }, headers),
41
+ });
42
+ };
43
+
44
+ exports.complete = complete;
45
+ exports.create = create;
46
+ exports.del = del;
47
+ exports.get = get;
48
+ exports.getMany = getMany;
49
+ exports.update = update;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var raw = require('./raw.js');
4
+
5
+ const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/workflows_changelog`;
6
+ const getMany = (http, params, headers) => raw.get(http, getBaseUrl(params), {
7
+ headers,
8
+ params: params.query,
9
+ });
10
+
11
+ exports.getMany = getMany;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var index = require('./endpoints/index.js');
4
+
5
+ const makeRequest = async ({ axiosInstance, entityType, action: actionInput, params, payload, headers, userAgent, }) => {
6
+ var _a;
7
+ // `delete` is a reserved keyword. Therefore, the methods are called `del`.
8
+ const action = actionInput === 'delete' ? 'del' : actionInput;
9
+ const endpoint =
10
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
+ // @ts-ignore
12
+ (_a = index[entityType]) === null || _a === void 0 ? void 0 : _a[action];
13
+ if (endpoint === undefined) {
14
+ throw new Error('Unknown endpoint');
15
+ }
16
+ return await endpoint(axiosInstance, params, payload, Object.assign(Object.assign({}, headers), (userAgent ? { 'X-Contentful-User-Agent': userAgent } : {})));
17
+ };
18
+
19
+ exports.makeRequest = makeRequest;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var contentfulSdkCore = require('contentful-sdk-core');
5
+ var copy = require('fast-copy');
6
+ var makeRequest = require('./make-request.js');
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ const defaultHostParameters = {
12
+ defaultHostname: 'api.contentful.com',
13
+ defaultHostnameUpload: 'upload.contentful.com',
14
+ };
15
+ class RestAdapter {
16
+ constructor(params) {
17
+ if (!params.accessToken) {
18
+ throw new TypeError('Expected parameter accessToken');
19
+ }
20
+ const copiedParams = copy(params);
21
+ // httpAgent and httpsAgent cannot be copied because they can contain private fields
22
+ copiedParams.httpAgent = params.httpAgent;
23
+ copiedParams.httpsAgent = params.httpsAgent;
24
+ this.params = Object.assign(Object.assign({}, defaultHostParameters), copiedParams);
25
+ this.axiosInstance = contentfulSdkCore.createHttpClient(axios, Object.assign(Object.assign({}, this.params), { headers: Object.assign(Object.assign({ 'Content-Type': 'application/vnd.contentful.management.v1+json' }, (params.userAgent ? { 'X-Contentful-User-Agent': params.userAgent } : {})), this.params.headers) }));
26
+ }
27
+ async makeRequest(opts) {
28
+ return makeRequest.makeRequest(Object.assign(Object.assign({}, opts), { axiosInstance: this.axiosInstance }));
29
+ }
30
+ }
31
+
32
+ exports.RestAdapter = RestAdapter;
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ exports.ScheduledActionReferenceFilters = void 0;
4
+ (function (ScheduledActionReferenceFilters) {
5
+ ScheduledActionReferenceFilters["contentTypeAnnotationNotIn"] = "sys.contentType.metadata.annotations.ContentType[nin]";
6
+ })(exports.ScheduledActionReferenceFilters || (exports.ScheduledActionReferenceFilters = {}));
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var contentfulSdkCore = require('contentful-sdk-core');
4
+ var copy = require('fast-copy');
5
+
6
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
7
+ /**
8
+ * @private
9
+ */
10
+ const wrapCollection = (fn) => (makeRequest, data, ...rest) => {
11
+ const collectionData = contentfulSdkCore.toPlainObject(copy(data));
12
+ // @ts-expect-error
13
+ collectionData.items = collectionData.items.map((entity) => fn(makeRequest, entity, ...rest));
14
+ // @ts-expect-error
15
+ return collectionData;
16
+ };
17
+ const wrapCursorPaginatedCollection = (fn) => (makeRequest, data, ...rest) => {
18
+ const collectionData = contentfulSdkCore.toPlainObject(copy(data));
19
+ // @ts-expect-error
20
+ collectionData.items = collectionData.items.map((entity) => fn(makeRequest, entity, ...rest));
21
+ // @ts-expect-error
22
+ return collectionData;
23
+ };
24
+ function isSuccessful(statusCode) {
25
+ return statusCode < 300;
26
+ }
27
+ function shouldRePoll(statusCode) {
28
+ return [404, 422, 429, 400].includes(statusCode);
29
+ }
30
+ async function waitFor(ms = 1000) {
31
+ return new Promise((resolve) => setTimeout(resolve, ms));
32
+ }
33
+
34
+ exports.isSuccessful = isSuccessful;
35
+ exports.shouldRePoll = shouldRePoll;
36
+ exports.waitFor = waitFor;
37
+ exports.wrapCollection = wrapCollection;
38
+ exports.wrapCursorPaginatedCollection = wrapCursorPaginatedCollection;
@@ -0,0 +1,161 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var types = require('./types.js');
6
+
7
+ const DROPDOWN_TYPES = ['Text', 'Symbol', 'Integer', 'Number', 'Boolean'];
8
+ const INTERNAL_TO_API = {
9
+ Symbol: { type: 'Symbol' },
10
+ Text: { type: 'Text' },
11
+ RichText: { type: 'RichText' },
12
+ Integer: { type: 'Integer' },
13
+ Number: { type: 'Number' },
14
+ Boolean: { type: 'Boolean' },
15
+ Date: { type: 'Date' },
16
+ Location: { type: 'Location' },
17
+ Object: { type: 'Object' },
18
+ File: { type: 'File' },
19
+ Entry: { type: 'Link', linkType: 'Entry' },
20
+ Asset: { type: 'Link', linkType: 'Asset' },
21
+ Resource: { type: 'ResourceLink' },
22
+ Symbols: { type: 'Array', items: { type: 'Symbol' } },
23
+ Entries: { type: 'Array', items: { type: 'Link', linkType: 'Entry' } },
24
+ Assets: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } },
25
+ Resources: { type: 'Array', items: { type: 'ResourceLink' } },
26
+ };
27
+ const FIELD_TYPES = Object.keys(INTERNAL_TO_API);
28
+ /**
29
+ * Returns an internal string identifier for an API field object.
30
+ *
31
+ * We use this string as a simplified reference to field types.
32
+ * Possible values are:
33
+ *
34
+ * - Symbol
35
+ * - Symbols
36
+ * - Text
37
+ * - RichText
38
+ * - Integer
39
+ * - Number
40
+ * - Boolean
41
+ * - Date
42
+ * - Location
43
+ * - Object
44
+ * - Entry
45
+ * - Entries
46
+ * - Asset
47
+ * - Assets
48
+ * - File
49
+ */
50
+ function toInternalFieldType(api) {
51
+ return FIELD_TYPES.find((key) => {
52
+ const internalApi = INTERNAL_TO_API[key];
53
+ const stripped = {
54
+ type: api.type,
55
+ linkType: api.linkType,
56
+ items: api.items,
57
+ };
58
+ if (stripped.items) {
59
+ stripped.items = { type: stripped.items.type, linkType: stripped.items.linkType };
60
+ }
61
+ if (internalApi.type === 'Link') {
62
+ return internalApi.linkType === stripped.linkType;
63
+ }
64
+ if (internalApi.type === 'Array' && internalApi.items && stripped.items) {
65
+ if (internalApi.items.type === 'Link') {
66
+ return internalApi.items.linkType === stripped.items.linkType;
67
+ }
68
+ return internalApi.items.type === stripped.items.type;
69
+ }
70
+ return internalApi.type === stripped.type;
71
+ });
72
+ }
73
+ const DEFAULTS_WIDGET = {
74
+ Text: { widgetId: 'markdown' },
75
+ Symbol: { widgetId: 'singleLine' },
76
+ Integer: { widgetId: 'numberEditor' },
77
+ Number: { widgetId: 'numberEditor' },
78
+ Boolean: { widgetId: 'boolean' },
79
+ Date: { widgetId: 'datePicker' },
80
+ Location: { widgetId: 'locationEditor' },
81
+ Object: { widgetId: 'objectEditor' },
82
+ RichText: { widgetId: 'richTextEditor' },
83
+ Entry: { widgetId: 'entryLinkEditor' },
84
+ Asset: { widgetId: 'assetLinkEditor' },
85
+ Symbols: { widgetId: 'tagEditor' },
86
+ Entries: { widgetId: 'entryLinksEditor' },
87
+ Assets: { widgetId: 'assetLinksEditor' },
88
+ File: { widgetId: 'fileEditor' },
89
+ Resource: { widgetId: 'resourceLinkEditor' },
90
+ Resources: { widgetId: 'resourceLinksEditor' },
91
+ };
92
+ const DEFAULTS_SETTINGS = {
93
+ Boolean: {
94
+ falseLabel: 'No',
95
+ helpText: null,
96
+ trueLabel: 'Yes',
97
+ },
98
+ Date: {
99
+ helpText: null,
100
+ ampm: '24',
101
+ format: 'timeZ',
102
+ },
103
+ Entry: {
104
+ helpText: null,
105
+ showCreateEntityAction: true,
106
+ showLinkEntityAction: true,
107
+ },
108
+ Asset: {
109
+ helpText: null,
110
+ showCreateEntityAction: true,
111
+ showLinkEntityAction: true,
112
+ },
113
+ Entries: {
114
+ helpText: null,
115
+ bulkEditing: false,
116
+ showCreateEntityAction: true,
117
+ showLinkEntityAction: true,
118
+ },
119
+ Assets: {
120
+ helpText: null,
121
+ showCreateEntityAction: true,
122
+ showLinkEntityAction: true,
123
+ },
124
+ };
125
+ function getDefaultWidget(field, fieldId) {
126
+ const defaultWidget = Object.assign(Object.assign({}, DEFAULTS_WIDGET[field]), { settings: {
127
+ helpText: null,
128
+ }, widgetNamespace: 'builtin', fieldId });
129
+ if (types.in_(field, DEFAULTS_SETTINGS)) {
130
+ defaultWidget.settings = Object.assign(Object.assign({}, defaultWidget.settings), DEFAULTS_SETTINGS[field]);
131
+ }
132
+ return defaultWidget;
133
+ }
134
+ /*
135
+ * Gets the default widget ID for a field:
136
+ * - If a field allows predefined values then `dropdown` widget is used
137
+ * in the presence of the `in` validation.
138
+ * - If a Text field is a title then the `singleLine` widget is used.
139
+ * - Otherwise a simple type-to-editor mapping is used.
140
+ */
141
+ function getDefaultControlOfField(field) {
142
+ const fieldType = toInternalFieldType(field);
143
+ if (!fieldType) {
144
+ throw new Error('Invalid field type');
145
+ }
146
+ const hasInValidation = (field.validations || []).find((v) => 'in' in v);
147
+ if (hasInValidation && DROPDOWN_TYPES.includes(fieldType)) {
148
+ return {
149
+ widgetId: 'dropdown',
150
+ fieldId: field.id,
151
+ widgetNamespace: 'builtin',
152
+ };
153
+ }
154
+ return getDefaultWidget(fieldType, field.id);
155
+ }
156
+
157
+ exports.DEFAULTS_SETTINGS = DEFAULTS_SETTINGS;
158
+ exports.DEFAULTS_WIDGET = DEFAULTS_WIDGET;
159
+ exports.FIELD_TYPES = FIELD_TYPES;
160
+ exports.default = getDefaultControlOfField;
161
+ exports.toInternalFieldType = toInternalFieldType;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ var types = require('./types.js');
4
+
5
+ const EntryEditorWidgetTypes = {
6
+ DEFAULT_EDITOR: {
7
+ name: 'Editor',
8
+ id: types.DEFAULT_EDITOR_ID,
9
+ icon: 'Entry',
10
+ },
11
+ REFERENCE_TREE: {
12
+ name: 'References',
13
+ id: 'reference-tree',
14
+ icon: 'References',
15
+ },
16
+ TAGS_EDITOR: {
17
+ name: 'Tags',
18
+ id: 'tags-editor',
19
+ icon: 'Tags',
20
+ },
21
+ };
22
+ const DefaultEntryEditor = {
23
+ widgetId: EntryEditorWidgetTypes.DEFAULT_EDITOR.id,
24
+ widgetNamespace: types.WidgetNamespace.EDITOR_BUILTIN,
25
+ name: EntryEditorWidgetTypes.DEFAULT_EDITOR.name,
26
+ };
27
+ const ReferencesEntryEditor = {
28
+ widgetId: EntryEditorWidgetTypes.REFERENCE_TREE.id,
29
+ widgetNamespace: types.WidgetNamespace.EDITOR_BUILTIN,
30
+ name: EntryEditorWidgetTypes.REFERENCE_TREE.name,
31
+ };
32
+ const TagsEditor = {
33
+ widgetId: EntryEditorWidgetTypes.TAGS_EDITOR.id,
34
+ widgetNamespace: types.WidgetNamespace.EDITOR_BUILTIN,
35
+ name: EntryEditorWidgetTypes.TAGS_EDITOR.name,
36
+ };
37
+ const EntryConfiguration = [DefaultEntryEditor, ReferencesEntryEditor, TagsEditor];
38
+
39
+ exports.EntryConfiguration = EntryConfiguration;
40
+ exports.EntryEditorWidgetTypes = EntryEditorWidgetTypes;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var sidebarDefaults = require('./sidebar-defaults.js');
4
+ var editorsDefaults = require('./editors-defaults.js');
5
+ var controlsDefaults = require('./controls-defaults.js');
6
+
7
+ var index = {
8
+ SidebarEntryConfiguration: sidebarDefaults.SidebarEntryConfiguration,
9
+ SidebarAssetConfiguration: sidebarDefaults.SidebarAssetConfiguration,
10
+ EntryConfiguration: editorsDefaults.EntryConfiguration,
11
+ getDefaultControlOfField: controlsDefaults.default,
12
+ };
13
+
14
+ module.exports = index;