contentful-management 11.55.0-canary.8 → 11.55.0

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 (31) hide show
  1. package/README.md +0 -14
  2. package/dist/contentful-management.browser.js +290 -240
  3. package/dist/contentful-management.browser.js.map +1 -1
  4. package/dist/contentful-management.browser.min.js +1 -1
  5. package/dist/contentful-management.node.js +204 -212
  6. package/dist/contentful-management.node.js.map +1 -1
  7. package/dist/contentful-management.node.min.js +1 -1
  8. package/dist/es-modules/adapters/REST/endpoints/app-action-call.js +59 -0
  9. package/dist/es-modules/adapters/REST/endpoints/entry.js +6 -31
  10. package/dist/es-modules/adapters/REST/endpoints/index.js +0 -2
  11. package/dist/es-modules/adapters/REST/endpoints/release.js +0 -24
  12. package/dist/es-modules/common-types.js +2 -0
  13. package/dist/es-modules/contentful-management.js +1 -1
  14. package/dist/es-modules/create-environment-api.js +39 -4
  15. package/dist/es-modules/entities/app-action-call.js +35 -0
  16. package/dist/es-modules/plain/plain-client.js +4 -9
  17. package/dist/typings/adapters/REST/endpoints/app-action-call.d.ts +3 -0
  18. package/dist/typings/adapters/REST/endpoints/index.d.ts +0 -2
  19. package/dist/typings/common-types.d.ts +39 -137
  20. package/dist/typings/create-entry-api.d.ts +1 -1
  21. package/dist/typings/create-environment-api.d.ts +31 -9
  22. package/dist/typings/entities/app-action-call.d.ts +37 -1
  23. package/dist/typings/entities/entry.d.ts +3 -3
  24. package/dist/typings/entities/release.d.ts +1 -19
  25. package/dist/typings/export-types.d.ts +1 -1
  26. package/dist/typings/plain/common-types.d.ts +17 -92
  27. package/dist/typings/plain/entities/app-action-call.d.ts +84 -2
  28. package/dist/typings/plain/wrappers/wrap.d.ts +0 -2
  29. package/package.json +2 -6
  30. package/dist/es-modules/adapters/REST/endpoints/release-entry.js +0 -63
  31. package/dist/typings/adapters/REST/endpoints/release-entry.d.ts +0 -7
@@ -66,4 +66,63 @@ export const createWithResponse = async (http, params, data) => {
66
66
  return callAppActionResult(http, params, {
67
67
  callId
68
68
  });
69
+ };
70
+
71
+ // Get structured AppActionCall (status/result/error) via new route that includes app installation context
72
+ export const get = (http, params) => {
73
+ return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations/${params.appDefinitionId}/actions/${params.appActionId}/calls/${params.callId}`);
74
+ };
75
+
76
+ // Get raw AppActionCall response (headers/body) for a completed call
77
+ export const getResponse = (http, params) => {
78
+ return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations/${params.appDefinitionId}/actions/${params.appActionId}/calls/${params.callId}/response`);
79
+ };
80
+ async function pollStructuredAppActionCall(http, params, {
81
+ callId
82
+ }) {
83
+ let checkCount = 1;
84
+ const retryInterval = params.retryInterval || APP_ACTION_CALL_RETRY_INTERVAL;
85
+ const retries = params.retries || APP_ACTION_CALL_RETRIES;
86
+ return new Promise((resolve, reject) => {
87
+ const poll = async () => {
88
+ try {
89
+ const result = await get(http, _objectSpread(_objectSpread({}, params), {}, {
90
+ callId
91
+ }));
92
+
93
+ // If backend has not yet written the record, keep polling up to retries
94
+ // Otherwise, resolve when status is terminal
95
+ if ((result === null || result === void 0 ? void 0 : result.status) === 'succeeded' || (result === null || result === void 0 ? void 0 : result.status) === 'failed') {
96
+ resolve(result);
97
+ } else if ((result === null || result === void 0 ? void 0 : result.status) === 'processing' && checkCount < retries) {
98
+ checkCount++;
99
+ await waitFor(retryInterval);
100
+ poll();
101
+ } else {
102
+ // Status not terminal and no more retries
103
+ reject(new Error('The app action result is taking longer than expected to process.'));
104
+ }
105
+ } catch (error) {
106
+ checkCount++;
107
+ if (checkCount > retries) {
108
+ reject(new Error('The app action result is taking longer than expected to process.'));
109
+ return;
110
+ }
111
+
112
+ // Similar to legacy behavior: transient errors (e.g., 404 during propagation) → re-poll
113
+ await waitFor(retryInterval);
114
+ poll();
115
+ }
116
+ };
117
+ poll();
118
+ });
119
+ }
120
+
121
+ // Create and poll the structured AppActionCall until completion (succeeded/failed)
122
+ export const createWithResult = async (http, params, data) => {
123
+ const createResponse = await raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations/${params.appDefinitionId}/actions/${params.appActionId}/calls`, data);
124
+ const callId = createResponse.sys.id;
125
+ return pollStructuredAppActionCall(http, params, {
126
+ callId
127
+ });
69
128
  };
@@ -5,15 +5,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
5
5
  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); }
6
6
  import copy from 'fast-copy';
7
7
  import * as raw from './raw';
8
- import { createWithId as createWithIdReleaseEntry } from './release-entry';
9
8
  import { normalizeSelect } from './utils';
10
- import * as releaseEntry from './release-entry';
11
9
  export const get = (http, params, rawData, headers) => {
12
- if (params.releaseId) {
13
- params.query = _objectSpread(_objectSpread({}, params.query), {}, {
14
- 'release[lte]': params.releaseId
15
- });
16
- }
17
10
  return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, {
18
11
  params: normalizeSelect(params.query),
19
12
  headers: _objectSpread({}, headers)
@@ -26,20 +19,12 @@ export const getPublished = (http, params, rawData, headers) => {
26
19
  });
27
20
  };
28
21
  export const getMany = (http, params, rawData, headers) => {
29
- if (params.releaseId) {
30
- params.query = _objectSpread(_objectSpread({}, params.query), {}, {
31
- 'release[lte]': params.releaseId
32
- });
33
- }
34
22
  return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries`, {
35
23
  params: normalizeSelect(params.query),
36
24
  headers: _objectSpread({}, headers)
37
25
  });
38
26
  };
39
27
  export const patch = (http, params, data, headers) => {
40
- if (params.releaseId) {
41
- return releaseEntry.patch(http, params, data, headers !== null && headers !== void 0 ? headers : {});
42
- }
43
28
  return raw.patch(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
44
29
  headers: _objectSpread({
45
30
  'X-Contentful-Version': params.version,
@@ -49,9 +34,6 @@ export const patch = (http, params, data, headers) => {
49
34
  };
50
35
  export const update = (http, params, rawData, headers) => {
51
36
  var _rawData$sys$version;
52
- if (params.releaseId) {
53
- return releaseEntry.update(http, params, rawData, headers !== null && headers !== void 0 ? headers : {});
54
- }
55
37
  const data = copy(rawData);
56
38
  delete data.sys;
57
39
  return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
@@ -104,9 +86,6 @@ export const unarchive = (http, params) => {
104
86
  return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/archived`);
105
87
  };
106
88
  export const create = (http, params, rawData) => {
107
- if (params.releaseId) {
108
- return releaseEntry.create(http, params, rawData, {});
109
- }
110
89
  const data = copy(rawData);
111
90
  return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries`, data, {
112
91
  headers: {
@@ -115,16 +94,12 @@ export const create = (http, params, rawData) => {
115
94
  });
116
95
  };
117
96
  export const createWithId = (http, params, rawData) => {
118
- if (params.releaseId) {
119
- return createWithIdReleaseEntry(http, params, rawData, {});
120
- } else {
121
- const data = copy(rawData);
122
- return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
123
- headers: {
124
- 'X-Contentful-Content-Type': params.contentTypeId
125
- }
126
- });
127
- }
97
+ const data = copy(rawData);
98
+ return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`, data, {
99
+ headers: {
100
+ 'X-Contentful-Content-Type': params.contentTypeId
101
+ }
102
+ });
128
103
  };
129
104
  export const references = (http, params) => {
130
105
  const {
@@ -39,7 +39,6 @@ import * as OAuthApplication from './oauth-application';
39
39
  import * as PersonalAccessToken from './personal-access-token';
40
40
  import * as PreviewApiKey from './preview-api-key';
41
41
  import * as Release from './release';
42
- import * as ReleaseEntry from './release-entry';
43
42
  import * as ReleaseAction from './release-action';
44
43
  import * as Resource from './resource';
45
44
  import * as ResourceProvider from './resource-provider';
@@ -107,7 +106,6 @@ export default {
107
106
  AccessToken,
108
107
  PreviewApiKey,
109
108
  Release,
110
- ReleaseEntry,
111
109
  ReleaseAction,
112
110
  Resource,
113
111
  ResourceProvider,
@@ -8,38 +8,14 @@ export const get = (http, params) => {
8
8
  return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}`);
9
9
  };
10
10
  export const query = (http, params) => {
11
- var _ref, _params$query$sysSch, _params$query;
12
- // Set the schema version in the query if provided in params or query options
13
- const releaseSchemaVersion = (_ref = (_params$query$sysSch = (_params$query = params.query) === null || _params$query === void 0 ? void 0 : _params$query['sys.schemaVersion']) !== null && _params$query$sysSch !== void 0 ? _params$query$sysSch : params.releaseSchemaVersion) !== null && _ref !== void 0 ? _ref : undefined;
14
- if (releaseSchemaVersion !== undefined) {
15
- params.query = _objectSpread(_objectSpread({}, params.query), {}, {
16
- 'sys.schemaVersion': releaseSchemaVersion
17
- });
18
- }
19
11
  return raw.get(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases`, {
20
12
  params: params.query
21
13
  });
22
14
  };
23
15
  export const create = (http, params, payload) => {
24
- var _payload$sys$schemaVe, _payload$sys;
25
- const releaseSchemaVersion = (_payload$sys$schemaVe = (_payload$sys = payload.sys) === null || _payload$sys === void 0 ? void 0 : _payload$sys.schemaVersion) !== null && _payload$sys$schemaVe !== void 0 ? _payload$sys$schemaVe : params.releaseSchemaVersion;
26
- if (releaseSchemaVersion === 'Release.v2') {
27
- payload.sys = _objectSpread(_objectSpread({}, payload.sys), {}, {
28
- type: 'Release',
29
- schemaVersion: 'Release.v2'
30
- });
31
- }
32
16
  return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases`, payload);
33
17
  };
34
18
  export const update = (http, params, payload, headers) => {
35
- var _payload$sys$schemaVe2, _payload$sys2;
36
- const releaseSchemaVersion = (_payload$sys$schemaVe2 = (_payload$sys2 = payload.sys) === null || _payload$sys2 === void 0 ? void 0 : _payload$sys2.schemaVersion) !== null && _payload$sys$schemaVe2 !== void 0 ? _payload$sys$schemaVe2 : params.releaseSchemaVersion;
37
- if (releaseSchemaVersion === 'Release.v2') {
38
- payload.sys = _objectSpread(_objectSpread({}, payload.sys), {}, {
39
- type: 'Release',
40
- schemaVersion: 'Release.v2'
41
- });
42
- }
43
19
  return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}`, payload, {
44
20
  headers: _objectSpread({
45
21
  'X-Contentful-Version': params.version
@@ -55,6 +55,8 @@
55
55
 
56
56
  /** Base interface for all Payload interfaces. Used as part of the MakeRequestOptions to simplify payload definitions. */
57
57
 
58
+ // New route params for fetching structured call or raw response
59
+
58
60
  export let ScheduledActionReferenceFilters = /*#__PURE__*/function (ScheduledActionReferenceFilters) {
59
61
  ScheduledActionReferenceFilters["contentTypeAnnotationNotIn"] = "sys.contentType.metadata.annotations.ContentType[nin]";
60
62
  return ScheduledActionReferenceFilters;
@@ -47,7 +47,7 @@ function createClient(params, opts = {}) {
47
47
  const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
48
48
  const userAgent = getUserAgentHeader(
49
49
  // @ts-expect-error
50
- `${sdkMain}/${"11.55.0-canary.8"}`, params.application, params.integration, params.feature);
50
+ `${sdkMain}/${"11.55.0"}`, params.application, params.integration, params.feature);
51
51
  const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
52
52
  userAgent
53
53
  }));
@@ -389,7 +389,7 @@ export default function createEnvironmentApi(makeRequest) {
389
389
  *
390
390
  * // Using Thenables
391
391
  * client.getSpace('<space_id>')
392
- * .then((space) => space.getEnvironment('<environment-id>'))
392
+ * .then((space) => space.getEnvironment('<environment_id>'))
393
393
  * .then((environment) => environment.createUnpublishBulkAction(payload))
394
394
  * .then((bulkAction) => console.log(bulkAction.waitProcessing()))
395
395
  * .catch(console.error)
@@ -397,7 +397,7 @@ export default function createEnvironmentApi(makeRequest) {
397
397
  * // Using async/await
398
398
  * try {
399
399
  * const space = await clientgetSpace('<space_id>')
400
- * const environment = await space.getEnvironment('<environment-id>')
400
+ * const environment = await space.getEnvironment('<environment_id>')
401
401
  * const bulkActionInProgress = await environment.createUnpublishBulkAction(payload)
402
402
  *
403
403
  * // You can wait for a recently created BulkAction to be processed by using `bulkAction.waitProcessing()`
@@ -851,7 +851,7 @@ export default function createEnvironmentApi(makeRequest) {
851
851
  *
852
852
  * // Get entry references
853
853
  * client.getSpace('<space_id>')
854
- * .then((space) => space.getEnvironment('<environment-id>'))
854
+ * .then((space) => space.getEnvironment('<environment_id>'))
855
855
  * .then((environment) => environment.getEntryReferences('<entry_id>', {include: number}))
856
856
  * .then((entry) => console.log(entry.includes))
857
857
  * // or
@@ -1581,6 +1581,41 @@ export default function createEnvironmentApi(makeRequest) {
1581
1581
  payload: data
1582
1582
  }).then(payload => wrapAppActionCall(makeRequest, payload));
1583
1583
  },
1584
+ /**
1585
+ * Gets the raw response (headers/body) for a completed App Action Call
1586
+ * @param appDefinitionId - AppDefinition ID
1587
+ * @param appActionId - App Action ID
1588
+ * @param callId - App Action Call ID
1589
+ * @return Promise for the raw response object including `response.body` and optional `response.headers`
1590
+ * @example ```javascript
1591
+ * const contentful = require('contentful-management')
1592
+ *
1593
+ * const client = contentful.createClient({
1594
+ * accessToken: '<content_management_api_key>'
1595
+ * })
1596
+ *
1597
+ * client
1598
+ * .getSpace('<space_id>')
1599
+ * .then((space) => space.getEnvironment('<environment_id>'))
1600
+ * .then((environment) => environment.getAppActionCallResponse('<app_definition_id>', '<app_action_id>', '<call_id>'))
1601
+ * .then((raw) => console.log(raw.response.body))
1602
+ * .catch(console.error)
1603
+ * ```
1604
+ */
1605
+ getAppActionCallResponse(appDefinitionId, appActionId, callId) {
1606
+ const raw = this.toPlainObject();
1607
+ return makeRequest({
1608
+ entityType: 'AppActionCall',
1609
+ action: 'getResponse',
1610
+ params: {
1611
+ spaceId: raw.sys.space.sys.id,
1612
+ environmentId: raw.sys.id,
1613
+ appDefinitionId,
1614
+ appActionId,
1615
+ callId
1616
+ }
1617
+ });
1618
+ },
1584
1619
  /**
1585
1620
  * Creates an app signed request
1586
1621
  * @param appDefinitionId - AppDefinition ID
@@ -2401,7 +2436,7 @@ export default function createEnvironmentApi(makeRequest) {
2401
2436
  * })
2402
2437
  *
2403
2438
  * client.getSpace('<space_id>')
2404
- * .then((space) => space.getEnvironment('<environment-id>'))
2439
+ * .then((space) => space.getEnvironment('<environment_id>'))
2405
2440
  * .then((environment) => environment.getResourceTypes({limit: 10}))
2406
2441
  * .then((installations) => console.log(installations.items))
2407
2442
  * .catch(console.error)
@@ -6,6 +6,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
6
6
  import copy from 'fast-copy';
7
7
  import { toPlainObject } from 'contentful-sdk-core';
8
8
  import enhanceWithMethods from '../enhance-with-methods';
9
+
10
+ // Raw App Action call response (new endpoint). Not yet wired to runtime behavior.
11
+
9
12
  /**
10
13
  * @private
11
14
  */
@@ -41,6 +44,38 @@ export default function createAppActionCallApi(makeRequest, retryOptions) {
41
44
  appActionId: 'app-action-id'
42
45
  }
43
46
  }).then(data => wrapAppActionCallResponse(makeRequest, data));
47
+ },
48
+ get: function get() {
49
+ return makeRequest({
50
+ entityType: 'AppActionCall',
51
+ action: 'get',
52
+ params: {
53
+ spaceId: 'space-id',
54
+ environmentId: 'environment-id',
55
+ appDefinitionId: 'app-definiton-id',
56
+ appActionId: 'app-action-id',
57
+ callId: 'call-id'
58
+ }
59
+ }).then(data => wrapAppActionCall(makeRequest, data));
60
+ },
61
+ createWithResult: function () {
62
+ const payload = {
63
+ parameters: {
64
+ recipient: 'Alice <alice@my-company.com>',
65
+ message_body: 'Hello from Bob!'
66
+ }
67
+ };
68
+ return makeRequest({
69
+ entityType: 'AppActionCall',
70
+ action: 'createWithResult',
71
+ params: _objectSpread({
72
+ spaceId: 'space-id',
73
+ environmentId: 'environment-id',
74
+ appDefinitionId: 'app-definiton-id',
75
+ appActionId: 'app-action-id'
76
+ }, retryOptions),
77
+ payload: payload
78
+ }).then(data => wrapAppActionCall(makeRequest, data));
44
79
  }
45
80
  };
46
81
  }
@@ -92,7 +92,10 @@ export const createPlainClient = (makeRequest, defaults) => {
92
92
  appActionCall: {
93
93
  create: wrap(wrapParams, 'AppActionCall', 'create'),
94
94
  getCallDetails: wrap(wrapParams, 'AppActionCall', 'getCallDetails'),
95
- createWithResponse: wrap(wrapParams, 'AppActionCall', 'createWithResponse')
95
+ createWithResponse: wrap(wrapParams, 'AppActionCall', 'createWithResponse'),
96
+ get: wrap(wrapParams, 'AppActionCall', 'get'),
97
+ createWithResult: wrap(wrapParams, 'AppActionCall', 'createWithResult'),
98
+ getResponse: wrap(wrapParams, 'AppActionCall', 'getResponse')
96
99
  },
97
100
  appBundle: {
98
101
  get: wrap(wrapParams, 'AppBundle', 'get'),
@@ -343,14 +346,6 @@ export const createPlainClient = (makeRequest, defaults) => {
343
346
  getManyForOrganization: wrap(wrapParams, 'Usage', 'getManyForOrganization')
344
347
  },
345
348
  release: {
346
- entry: {
347
- get: wrap(wrapParams, 'ReleaseEntry', 'get'),
348
- getMany: wrap(wrapParams, 'ReleaseEntry', 'getMany'),
349
- update: wrap(wrapParams, 'ReleaseEntry', 'update'),
350
- patch: wrap(wrapParams, 'ReleaseEntry', 'patch'),
351
- create: wrap(wrapParams, 'ReleaseEntry', 'create'),
352
- createWithId: wrap(wrapParams, 'ReleaseEntry', 'createWithId')
353
- },
354
349
  archive: wrap(wrapParams, 'Release', 'archive'),
355
350
  get: wrap(wrapParams, 'Release', 'get'),
356
351
  query: wrap(wrapParams, 'Release', 'query'),
@@ -2,3 +2,6 @@ import type { RestEndpoint } from '../types';
2
2
  export declare const create: RestEndpoint<'AppActionCall', 'create'>;
3
3
  export declare const getCallDetails: RestEndpoint<'AppActionCall', 'getCallDetails'>;
4
4
  export declare const createWithResponse: RestEndpoint<'AppActionCall', 'createWithResponse'>;
5
+ export declare const get: RestEndpoint<'AppActionCall', 'get'>;
6
+ export declare const getResponse: RestEndpoint<'AppActionCall', 'getResponse'>;
7
+ export declare const createWithResult: RestEndpoint<'AppActionCall', 'createWithResult'>;
@@ -39,7 +39,6 @@ import * as OAuthApplication from './oauth-application';
39
39
  import * as PersonalAccessToken from './personal-access-token';
40
40
  import * as PreviewApiKey from './preview-api-key';
41
41
  import * as Release from './release';
42
- import * as ReleaseEntry from './release-entry';
43
42
  import * as ReleaseAction from './release-action';
44
43
  import * as Resource from './resource';
45
44
  import * as ResourceProvider from './resource-provider';
@@ -107,7 +106,6 @@ declare const _default: {
107
106
  AccessToken: typeof AccessToken;
108
107
  PreviewApiKey: typeof PreviewApiKey;
109
108
  Release: typeof Release;
110
- ReleaseEntry: typeof ReleaseEntry;
111
109
  ReleaseAction: typeof ReleaseAction;
112
110
  Resource: typeof Resource;
113
111
  ResourceProvider: typeof ResourceProvider;