contentful-management 11.43.2 → 11.45.0-beta.1

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 (33) hide show
  1. package/dist/contentful-management.browser.js +467 -276
  2. package/dist/contentful-management.browser.js.map +1 -1
  3. package/dist/contentful-management.browser.min.js +1 -1
  4. package/dist/contentful-management.node.js +447 -271
  5. package/dist/contentful-management.node.js.map +1 -1
  6. package/dist/contentful-management.node.min.js +1 -1
  7. package/dist/es-modules/adapters/REST/endpoints/function-log.js +22 -0
  8. package/dist/es-modules/adapters/REST/endpoints/function.js +6 -2
  9. package/dist/es-modules/adapters/REST/endpoints/index.js +2 -0
  10. package/dist/es-modules/common-types.js +4 -0
  11. package/dist/es-modules/contentful-management.js +1 -1
  12. package/dist/es-modules/create-environment-api.js +119 -0
  13. package/dist/es-modules/create-organization-api.js +54 -0
  14. package/dist/es-modules/entities/function-log.js +21 -0
  15. package/dist/es-modules/entities/function.js +45 -8
  16. package/dist/es-modules/entities/index.js +2 -0
  17. package/dist/es-modules/plain/entities/function-log.js +1 -0
  18. package/dist/es-modules/plain/plain-client.js +4 -0
  19. package/dist/typings/adapters/REST/endpoints/function-log.d.ts +3 -0
  20. package/dist/typings/adapters/REST/endpoints/index.d.ts +2 -0
  21. package/dist/typings/common-types.d.ts +50 -2
  22. package/dist/typings/create-environment-api.d.ts +78 -1
  23. package/dist/typings/create-organization-api.d.ts +29 -1
  24. package/dist/typings/entities/app-installation.d.ts +1 -0
  25. package/dist/typings/entities/function-log.d.ts +46 -0
  26. package/dist/typings/entities/function.d.ts +2 -10
  27. package/dist/typings/entities/index.d.ts +2 -0
  28. package/dist/typings/plain/common-types.d.ts +2 -0
  29. package/dist/typings/plain/entities/function-log.d.ts +39 -0
  30. package/dist/typings/plain/entities/function.d.ts +5 -3
  31. package/package.json +1 -1
  32. package/dist/es-modules/create-function-api.js +0 -115
  33. package/dist/typings/create-function-api.d.ts +0 -78
@@ -0,0 +1,22 @@
1
+ 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; }
2
+ 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; }
3
+ 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; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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
+ import * as raw from './raw';
7
+ const FunctionLogAlphaHeaders = {
8
+ 'x-contentful-enable-alpha-feature': 'function-logs'
9
+ };
10
+ const baseURL = params => `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations/${params.appInstallationId}/functions/${params.functionId}/logs`;
11
+ const getURL = params => `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations/${params.appInstallationId}/functions/${params.functionId}/logs/${params.logId}`;
12
+ export const get = (http, params) => {
13
+ return raw.get(http, getURL(params), {
14
+ headers: _objectSpread({}, FunctionLogAlphaHeaders)
15
+ });
16
+ };
17
+ export const getMany = (http, params) => {
18
+ return raw.get(http, baseURL(params), {
19
+ params: params.query,
20
+ headers: _objectSpread({}, FunctionLogAlphaHeaders)
21
+ });
22
+ };
@@ -9,8 +9,12 @@ export const get = (http, params) => {
9
9
  return raw.get(http, getFunctionUrl(params));
10
10
  };
11
11
  export const getMany = (http, params) => {
12
- return raw.get(http, getManyUrl(params));
12
+ return raw.get(http, getManyUrl(params), {
13
+ params: params.query
14
+ });
13
15
  };
14
16
  export const getManyForEnvironment = (http, params) => {
15
- return raw.get(http, getFunctionsEnvURL(params));
17
+ return raw.get(http, getFunctionsEnvURL(params), {
18
+ params: params.query
19
+ });
16
20
  };
@@ -27,6 +27,7 @@ import * as EnvironmentTemplate from './environment-template';
27
27
  import * as EnvironmentTemplateInstallation from './environment-template-installation';
28
28
  import * as Extension from './extension';
29
29
  import * as Function from './function';
30
+ import * as FunctionLog from './function-log';
30
31
  import * as Http from './http';
31
32
  import * as Locale from './locale';
32
33
  import * as Organization from './organization';
@@ -89,6 +90,7 @@ export default {
89
90
  EnvironmentTemplateInstallation,
90
91
  Extension,
91
92
  Function,
93
+ FunctionLog,
92
94
  Http,
93
95
  Locale,
94
96
  Organization,
@@ -10,6 +10,10 @@
10
10
 
11
11
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
12
 
13
+ // Base interface for shared fields
14
+
15
+ // Interfaces for each “exclusive” shape
16
+
13
17
  /**
14
18
  * @private
15
19
  */
@@ -46,7 +46,7 @@ function createClient(params, opts = {}) {
46
46
  const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
47
47
  const userAgent = getUserAgentHeader(
48
48
  // @ts-expect-error
49
- `${sdkMain}/${"11.43.2"}`, params.application, params.integration, params.feature);
49
+ `${sdkMain}/${"11.45.0-beta.1"}`, params.application, params.integration, params.feature);
50
50
  const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
51
51
  userAgent
52
52
  }));
@@ -14,6 +14,8 @@ import { wrapTag, wrapTagCollection } from './entities/tag';
14
14
  import { wrapUIConfig } from './entities/ui-config';
15
15
  import { wrapUserUIConfig } from './entities/user-ui-config';
16
16
  import { wrapEnvironmentTemplateInstallationCollection } from './entities/environment-template-installation';
17
+ import { wrapFunctionCollection } from './entities/function';
18
+ import { wrapFunctionLog, wrapFunctionLogCollection } from './entities/function-log';
17
19
 
18
20
  /**
19
21
  * @private
@@ -1658,6 +1660,123 @@ export default function createEnvironmentApi(makeRequest) {
1658
1660
  payload: data
1659
1661
  }).then(payload => wrapAppAccessToken(makeRequest, payload));
1660
1662
  },
1663
+ /**
1664
+ * Gets a collection of Functions for a given environment
1665
+ * @param appInstallationId
1666
+ * @param {import('../common-types').AcceptsQueryOptions} query - optional query parameter for filtering functions by action
1667
+ * @return Promise containing wrapped collection of Functions in an environment
1668
+ * @example ```javascript
1669
+ * const contentful = require('contentful-management')
1670
+ *
1671
+ * const client = contentful.createClient({
1672
+ * accessToken: '<content_management_api_key>'
1673
+ * })
1674
+ *
1675
+ * client
1676
+ * .getSpace('<space-id>')
1677
+ * .then((space) => space.getEnvironment('<environment-id>'))
1678
+ * .then((environment) => environment.getFunctionsForEnvironment('<app-installation-id>', { 'accepts[all]': '<action>' }))
1679
+ * .then((functions) => console.log(functions.items))
1680
+ * .catch(console.error)
1681
+ * ```
1682
+ */
1683
+ getFunctionsForEnvironment(appInstallationId, query) {
1684
+ const raw = this.toPlainObject();
1685
+ return makeRequest({
1686
+ entityType: 'Function',
1687
+ action: 'getManyForEnvironment',
1688
+ params: {
1689
+ spaceId: raw.sys.space.sys.id,
1690
+ environmentId: raw.sys.id,
1691
+ appInstallationId,
1692
+ query
1693
+ }
1694
+ }).then(data => wrapFunctionCollection(makeRequest, data));
1695
+ },
1696
+ /**
1697
+ * Gets a collection of FunctionLogs for a given app installation id and FunctionId
1698
+ * @param appInstallationId
1699
+ * @param functionId
1700
+ * @param {import('../common-types').CursorBasedParams} query - optional query parameter for pagination (limit, nextPage, prevPage)
1701
+ * @return Promise containing wrapped collection of FunctionLogs
1702
+ * * @example ```javascript
1703
+ * const contentful = require('contentful-management')
1704
+ *
1705
+ * const client = contentful.createClient({
1706
+ * accessToken: '<content_management_api_key>'
1707
+ * })
1708
+ *
1709
+ * client
1710
+ * .getSpace('<space-id>')
1711
+ * .then((space) => space.getEnvironment('<environment-id>'))
1712
+ * .then((environment) =>
1713
+ * environment.getFunctionLogs(
1714
+ * '<app-installation-id>',
1715
+ * '<function-id>',
1716
+ * { limit: 10 },
1717
+ * )
1718
+ * )
1719
+ * .then((functionLogs) => console.log(functionLog.items))
1720
+ * .catch(console.error)
1721
+ * ```
1722
+ */
1723
+ getFunctionLogs(appInstallationId, functionId, query) {
1724
+ const raw = this.toPlainObject();
1725
+ return makeRequest({
1726
+ entityType: 'FunctionLog',
1727
+ action: 'getMany',
1728
+ params: {
1729
+ spaceId: raw.sys.space.sys.id,
1730
+ environmentId: raw.sys.id,
1731
+ appInstallationId,
1732
+ functionId,
1733
+ query: query ? createRequestConfig({
1734
+ query
1735
+ }).params : undefined
1736
+ }
1737
+ }).then(data => wrapFunctionLogCollection(makeRequest, data));
1738
+ },
1739
+ /**
1740
+ * Gets a FunctionLog by appInstallationId, functionId and logId
1741
+ * @param appInstallationId
1742
+ * @param functionId
1743
+ * @param logId
1744
+ * @return Promise containing a wrapped FunctionLog
1745
+ * @example ```javascript
1746
+ * const contentful = require('contentful-management')
1747
+ *
1748
+ * const client = contentful.createClient({
1749
+ * accessToken: '<content_management_api_key>'
1750
+ * })
1751
+ *
1752
+ * client
1753
+ * .getSpace(<space-id>)
1754
+ * .then((space) => space.getEnvironment('<environment-id>'))
1755
+ * .then((environment) =>
1756
+ * environment.getFunctionLog(
1757
+ * '<app-installation-id>',
1758
+ * '<function-id>',
1759
+ * '<log-id>'
1760
+ * )
1761
+ * )
1762
+ * .then((functionLog) => console.log(functionLog))
1763
+ * .catch(console.error)
1764
+ * ```
1765
+ */
1766
+ getFunctionLog(appInstallationId, functionId, logId) {
1767
+ const raw = this.toPlainObject();
1768
+ return makeRequest({
1769
+ entityType: 'FunctionLog',
1770
+ action: 'get',
1771
+ params: {
1772
+ spaceId: raw.sys.space.sys.id,
1773
+ environmentId: raw.sys.id,
1774
+ appInstallationId,
1775
+ functionId,
1776
+ logId
1777
+ }
1778
+ }).then(data => wrapFunctionLog(makeRequest, data));
1779
+ },
1661
1780
  /**
1662
1781
  * Gets all snapshots of an entry
1663
1782
  * @func getEntrySnapshots
@@ -68,6 +68,10 @@ export default function createOrganizationApi(makeRequest) {
68
68
  wrapAppAction,
69
69
  wrapAppActionCollection
70
70
  } = entities.appAction;
71
+ const {
72
+ wrapFunction,
73
+ wrapFunctionCollection
74
+ } = entities.func;
71
75
  const {
72
76
  wrapRoleCollection
73
77
  } = entities.role;
@@ -1247,6 +1251,56 @@ export default function createOrganizationApi(makeRequest) {
1247
1251
  appDefinitionId
1248
1252
  }
1249
1253
  }).then(payload => wrapAppActionCollection(makeRequest, payload));
1254
+ },
1255
+ /**
1256
+ * Gets an app function
1257
+ * @param appDefinitionId
1258
+ * @param functionId
1259
+ * @returns Promise for a Function
1260
+ * @example ```javascript
1261
+ * const contentful = require('contentful-management')
1262
+ * const client = contentful.createClient({
1263
+ * accessToken: '<content_management_api_key>'
1264
+ * })
1265
+ * const org = await client.getOrganization('<org_id>')
1266
+ * const functions = await org.getFunction('<app_definition_id>', '<function_id>')
1267
+ */
1268
+ getFunction(appDefinitionId, functionId) {
1269
+ const raw = this.toPlainObject();
1270
+ return makeRequest({
1271
+ entityType: 'Function',
1272
+ action: 'get',
1273
+ params: {
1274
+ organizationId: raw.sys.id,
1275
+ appDefinitionId,
1276
+ functionId
1277
+ }
1278
+ }).then(payload => wrapFunction(makeRequest, payload));
1279
+ },
1280
+ /**
1281
+ * Gets a collection of app functions.
1282
+ * @param appDefinitionId
1283
+ * @param {import('../common-types').AcceptsQueryOptions} query - optional query parameter for filtering functions by action
1284
+ * @returns Promise for a Function
1285
+ * @example ```javascript
1286
+ * const contentful = require('contentful-management')
1287
+ * const client = contentful.createClient({
1288
+ * accessToken: '<content_management_api_key>'
1289
+ * })
1290
+ * const org = await client.getOrganization('<org_id>')
1291
+ * const functions = await org.getFunctions('<app_definition_id>', { 'accepts[all]': '<action>' })
1292
+ */
1293
+ getFunctions(appDefinitionId, query) {
1294
+ const raw = this.toPlainObject();
1295
+ return makeRequest({
1296
+ entityType: 'Function',
1297
+ action: 'getMany',
1298
+ params: {
1299
+ organizationId: raw.sys.id,
1300
+ appDefinitionId,
1301
+ query
1302
+ }
1303
+ }).then(payload => wrapFunctionCollection(makeRequest, payload));
1250
1304
  }
1251
1305
  };
1252
1306
  }
@@ -0,0 +1,21 @@
1
+ import { freezeSys, toPlainObject } from 'contentful-sdk-core';
2
+ import copy from 'fast-copy';
3
+ import { wrapCollection } from '../common-utils';
4
+ /**
5
+ * @private
6
+ * @param makeRequest - function to make requests via an adapter
7
+ * @param data - raw contentful-Function data
8
+ * @return Wrapped Function data
9
+ */
10
+ export function wrapFunctionLog(makeRequest, data) {
11
+ const functionLog = toPlainObject(copy(data));
12
+ return freezeSys(functionLog);
13
+ }
14
+
15
+ /**
16
+ * @private
17
+ * @param makeRequest - function to make requests via an adapter
18
+ * @param data - raw contentful-function data
19
+ * @return Wrapped App Function collection data
20
+ */
21
+ export const wrapFunctionLogCollection = wrapCollection(wrapFunctionLog);
@@ -2,7 +2,48 @@ import { freezeSys, toPlainObject } from 'contentful-sdk-core';
2
2
  import copy from 'fast-copy';
3
3
  import { wrapCollection } from '../common-utils';
4
4
  import enhanceWithMethods from '../enhance-with-methods';
5
- import createFunctionApi from '../create-function-api';
5
+ /**
6
+ * @private
7
+ */
8
+ function createFunctionApi(makeRequest) {
9
+ return {
10
+ getFunction: function getFunction() {
11
+ const raw = this.toPlainObject();
12
+ return makeRequest({
13
+ entityType: 'Function',
14
+ action: 'get',
15
+ params: {
16
+ organizationId: raw.sys.organization.sys.id,
17
+ appDefinitionId: raw.sys.appDefinition.sys.id,
18
+ functionId: raw.sys.id
19
+ }
20
+ }).then(data => wrapFunction(makeRequest, data));
21
+ },
22
+ getManyFunctions: function getManyFunctions() {
23
+ const raw = this.toPlainObject();
24
+ return makeRequest({
25
+ entityType: 'Function',
26
+ action: 'getMany',
27
+ params: {
28
+ appDefinitionId: raw.sys.appDefinition.sys.id,
29
+ organizationId: raw.sys.organization.sys.id
30
+ }
31
+ }).then(data => wrapFunctionCollection(makeRequest, data));
32
+ },
33
+ getManyFunctionsForEnvironment(spaceId, environmentId, appInstallationId) {
34
+ return makeRequest({
35
+ entityType: 'Function',
36
+ action: 'getManyForEnvironment',
37
+ params: {
38
+ spaceId: spaceId,
39
+ environmentId: environmentId,
40
+ appInstallationId: appInstallationId
41
+ }
42
+ }).then(data => wrapFunctionCollection(makeRequest, data));
43
+ }
44
+ };
45
+ }
46
+
6
47
  /**
7
48
  * @private
8
49
  * @param makeRequest - (real) function to make requests via an adapter
@@ -10,15 +51,11 @@ import createFunctionApi from '../create-function-api';
10
51
  * @return Wrapped Function data
11
52
  */
12
53
  export function wrapFunction(makeRequest, data) {
13
- const appAction = toPlainObject(copy(data));
14
- const appActionWithMethods = enhanceWithMethods(appAction, createFunctionApi(makeRequest));
15
- return freezeSys(appActionWithMethods);
54
+ const func = toPlainObject(copy(data));
55
+ const funcWithMethods = enhanceWithMethods(func, createFunctionApi(makeRequest));
56
+ return freezeSys(funcWithMethods);
16
57
  }
17
-
18
58
  /**
19
59
  * @private
20
- * @param makeRequest - real) function to make requests via an adapter
21
- * @param data - raw contentful-function data
22
- * @return Wrapped App Function collection data
23
60
  */
24
61
  export const wrapFunctionCollection = wrapCollection(wrapFunction);
@@ -24,6 +24,7 @@ import * as environmentTemplate from './environment-template';
24
24
  import * as environmentTemplateInstallation from './environment-template-installation';
25
25
  import * as extension from './extension';
26
26
  import * as func from './function';
27
+ import * as functionLog from './function-log';
27
28
  import * as locale from './locale';
28
29
  import * as organization from './organization';
29
30
  import * as organizationInvitation from './organization-invitation';
@@ -86,6 +87,7 @@ export default {
86
87
  environmentTemplateInstallation,
87
88
  extension,
88
89
  func,
90
+ functionLog,
89
91
  locale,
90
92
  organization,
91
93
  organizationInvitation,
@@ -0,0 +1 @@
1
+ export {};
@@ -143,6 +143,10 @@ export const createPlainClient = (makeRequest, defaults) => {
143
143
  getMany: wrap(wrapParams, 'Function', 'getMany'),
144
144
  getManyForEnvironment: wrap(wrapParams, 'Function', 'getManyForEnvironment')
145
145
  },
146
+ functionLog: {
147
+ get: wrap(wrapParams, 'FunctionLog', 'get'),
148
+ getMany: wrap(wrapParams, 'FunctionLog', 'getMany')
149
+ },
146
150
  editorInterface: {
147
151
  get: wrap(wrapParams, 'EditorInterface', 'get'),
148
152
  getMany: wrap(wrapParams, 'EditorInterface', 'getMany'),
@@ -0,0 +1,3 @@
1
+ import type { RestEndpoint } from '../types';
2
+ export declare const get: RestEndpoint<'FunctionLog', 'get'>;
3
+ export declare const getMany: RestEndpoint<'FunctionLog', 'getMany'>;
@@ -27,6 +27,7 @@ import * as EnvironmentTemplate from './environment-template';
27
27
  import * as EnvironmentTemplateInstallation from './environment-template-installation';
28
28
  import * as Extension from './extension';
29
29
  import * as Function from './function';
30
+ import * as FunctionLog from './function-log';
30
31
  import * as Http from './http';
31
32
  import * as Locale from './locale';
32
33
  import * as Organization from './organization';
@@ -89,6 +90,7 @@ declare const _default: {
89
90
  EnvironmentTemplateInstallation: typeof EnvironmentTemplateInstallation;
90
91
  Extension: typeof Extension;
91
92
  Function: typeof Function;
93
+ FunctionLog: typeof FunctionLog;
92
94
  Http: typeof Http;
93
95
  Locale: typeof Locale;
94
96
  Organization: typeof Organization;
@@ -60,6 +60,7 @@ import type { UserUIConfigProps } from './entities/user-ui-config';
60
60
  import type { CompleteWorkflowParams, CreateWorkflowParams, CreateWorkflowProps, DeleteWorkflowParams, WorkflowProps, WorkflowQueryOptions } from './entities/workflow';
61
61
  import type { CreateWorkflowDefinitionParams, CreateWorkflowDefinitionProps, DeleteWorkflowDefinitionParams, WorkflowDefinitionProps, WorkflowDefinitionQueryOptions } from './entities/workflow-definition';
62
62
  import type { WorkflowsChangelogEntryProps, WorkflowsChangelogQueryOptions } from './entities/workflows-changelog-entry';
63
+ import type { FunctionLogProps } from './entities/function-log';
63
64
  export interface DefaultElements<TPlainObject extends object = object> {
64
65
  toPlainObject(): TPlainObject;
65
66
  }
@@ -205,6 +206,24 @@ export interface BasicCursorPaginationOptions extends Omit<BasicQueryOptions, 's
205
206
  pageNext?: string;
206
207
  pagePrev?: string;
207
208
  }
209
+ interface CursorPaginationBase {
210
+ limit?: number;
211
+ }
212
+ interface CursorPaginationPageNext extends CursorPaginationBase {
213
+ pageNext: string;
214
+ pagePrev?: never;
215
+ }
216
+ interface CursorPaginationPagePrev extends CursorPaginationBase {
217
+ pageNext?: never;
218
+ pagePrev: string;
219
+ }
220
+ interface CursorPaginationNone extends CursorPaginationBase {
221
+ pageNext?: never;
222
+ pagePrev?: never;
223
+ }
224
+ export interface AcceptsQueryOptions {
225
+ 'accepts[all]'?: string;
226
+ }
208
227
  export type KeyValueMap = Record<string, any>;
209
228
  /**
210
229
  * @private
@@ -363,6 +382,8 @@ type MRInternal<UA extends boolean> = {
363
382
  (opts: MROpts<'Function', 'get', UA>): MRReturn<'Function', 'get'>;
364
383
  (opts: MROpts<'Function', 'getMany', UA>): MRReturn<'Function', 'getMany'>;
365
384
  (opts: MROpts<'Function', 'getManyForEnvironment', UA>): MRReturn<'Function', 'getManyForEnvironment'>;
385
+ (opts: MROpts<'FunctionLog', 'get', UA>): MRReturn<'FunctionLog', 'get'>;
386
+ (opts: MROpts<'FunctionLog', 'getMany', UA>): MRReturn<'FunctionLog', 'getMany'>;
366
387
  (opts: MROpts<'Locale', 'get', UA>): MRReturn<'Locale', 'get'>;
367
388
  (opts: MROpts<'Locale', 'getMany', UA>): MRReturn<'Locale', 'getMany'>;
368
389
  (opts: MROpts<'Locale', 'delete', UA>): MRReturn<'Locale', 'delete'>;
@@ -1497,6 +1518,18 @@ export type MRActions = {
1497
1518
  return: CollectionProp<FunctionProps>;
1498
1519
  };
1499
1520
  };
1521
+ FunctionLog: {
1522
+ get: {
1523
+ params: GetFunctionLogParams;
1524
+ return: FunctionLogProps;
1525
+ headers?: RawAxiosRequestHeaders;
1526
+ };
1527
+ getMany: {
1528
+ params: GetManyFunctionLogParams;
1529
+ return: CollectionProp<FunctionLogProps>;
1530
+ headers?: RawAxiosRequestHeaders;
1531
+ };
1532
+ };
1500
1533
  Locale: {
1501
1534
  get: {
1502
1535
  params: GetSpaceEnvironmentParams & {
@@ -2381,10 +2414,16 @@ export type GetEnvironmentTemplateParams = GetOrganizationParams & {
2381
2414
  export type GetFunctionParams = GetAppDefinitionParams & {
2382
2415
  functionId: string;
2383
2416
  };
2384
- export type GetManyFunctionParams = GetAppDefinitionParams;
2385
- export type GetFunctionForEnvParams = GetSpaceEnvironmentParams & {
2417
+ export type GetManyFunctionParams = AcceptsQueryParams & GetAppDefinitionParams;
2418
+ export type GetFunctionForEnvParams = AcceptsQueryParams & GetSpaceEnvironmentParams & {
2386
2419
  appInstallationId: string;
2387
2420
  };
2421
+ export type GetManyFunctionLogParams = CursorBasedParams & GetFunctionForEnvParams & {
2422
+ functionId: string;
2423
+ };
2424
+ export type GetFunctionLogParams = GetManyFunctionLogParams & {
2425
+ logId: string;
2426
+ };
2388
2427
  export type GetOrganizationParams = {
2389
2428
  organizationId: string;
2390
2429
  };
@@ -2515,6 +2554,15 @@ export type SpaceQueryParams = {
2515
2554
  export type PaginationQueryParams = {
2516
2555
  query?: PaginationQueryOptions;
2517
2556
  };
2557
+ export type CursorPaginationXORParams = {
2558
+ query?: (CursorPaginationPageNext | CursorPaginationPagePrev | CursorPaginationNone) & {
2559
+ limit?: number;
2560
+ };
2561
+ };
2562
+ export type CursorBasedParams = CursorPaginationXORParams;
2563
+ export type AcceptsQueryParams = {
2564
+ query?: AcceptsQueryOptions;
2565
+ };
2518
2566
  export declare enum ScheduledActionReferenceFilters {
2519
2567
  contentTypeAnnotationNotIn = "sys.contentType.metadata.annotations.ContentType[nin]"
2520
2568
  }
@@ -1,5 +1,5 @@
1
1
  import type { Stream } from 'stream';
2
- import type { BasicCursorPaginationOptions, QueryOptions } from './common-types';
2
+ import type { AcceptsQueryOptions, BasicCursorPaginationOptions, CursorBasedParams, QueryOptions } from './common-types';
3
3
  import type { BasicQueryOptions, MakeRequest } from './common-types';
4
4
  import type { CreateAppInstallationProps } from './entities/app-installation';
5
5
  import type { CreateAppSignedRequestProps } from './entities/app-signed-request';
@@ -1123,6 +1123,83 @@ export default function createEnvironmentApi(makeRequest: MakeRequest): {
1123
1123
  * ```
1124
1124
  */
1125
1125
  createAppAccessToken(appDefinitionId: string, data: CreateAppAccessTokenProps): Promise<import("./entities/app-access-token").AppAccessToken>;
1126
+ /**
1127
+ * Gets a collection of Functions for a given environment
1128
+ * @param appInstallationId
1129
+ * @param {import('../common-types').AcceptsQueryOptions} query - optional query parameter for filtering functions by action
1130
+ * @return Promise containing wrapped collection of Functions in an environment
1131
+ * @example ```javascript
1132
+ * const contentful = require('contentful-management')
1133
+ *
1134
+ * const client = contentful.createClient({
1135
+ * accessToken: '<content_management_api_key>'
1136
+ * })
1137
+ *
1138
+ * client
1139
+ * .getSpace('<space-id>')
1140
+ * .then((space) => space.getEnvironment('<environment-id>'))
1141
+ * .then((environment) => environment.getFunctionsForEnvironment('<app-installation-id>', { 'accepts[all]': '<action>' }))
1142
+ * .then((functions) => console.log(functions.items))
1143
+ * .catch(console.error)
1144
+ * ```
1145
+ */
1146
+ getFunctionsForEnvironment(appInstallationId: string, query?: AcceptsQueryOptions): Promise<import("./common-types").Collection<import("./entities/function").FunctionProps, import("./entities/function").FunctionProps>>;
1147
+ /**
1148
+ * Gets a collection of FunctionLogs for a given app installation id and FunctionId
1149
+ * @param appInstallationId
1150
+ * @param functionId
1151
+ * @param {import('../common-types').CursorBasedParams} query - optional query parameter for pagination (limit, nextPage, prevPage)
1152
+ * @return Promise containing wrapped collection of FunctionLogs
1153
+ * * @example ```javascript
1154
+ * const contentful = require('contentful-management')
1155
+ *
1156
+ * const client = contentful.createClient({
1157
+ * accessToken: '<content_management_api_key>'
1158
+ * })
1159
+ *
1160
+ * client
1161
+ * .getSpace('<space-id>')
1162
+ * .then((space) => space.getEnvironment('<environment-id>'))
1163
+ * .then((environment) =>
1164
+ * environment.getFunctionLogs(
1165
+ * '<app-installation-id>',
1166
+ * '<function-id>',
1167
+ * { limit: 10 },
1168
+ * )
1169
+ * )
1170
+ * .then((functionLogs) => console.log(functionLog.items))
1171
+ * .catch(console.error)
1172
+ * ```
1173
+ */
1174
+ getFunctionLogs(appInstallationId: string, functionId: string, query?: CursorBasedParams): Promise<import("./common-types").Collection<import("./entities/function-log").FunctionLogProps, import("./entities/function-log").FunctionLogProps>>;
1175
+ /**
1176
+ * Gets a FunctionLog by appInstallationId, functionId and logId
1177
+ * @param appInstallationId
1178
+ * @param functionId
1179
+ * @param logId
1180
+ * @return Promise containing a wrapped FunctionLog
1181
+ * @example ```javascript
1182
+ * const contentful = require('contentful-management')
1183
+ *
1184
+ * const client = contentful.createClient({
1185
+ * accessToken: '<content_management_api_key>'
1186
+ * })
1187
+ *
1188
+ * client
1189
+ * .getSpace(<space-id>)
1190
+ * .then((space) => space.getEnvironment('<environment-id>'))
1191
+ * .then((environment) =>
1192
+ * environment.getFunctionLog(
1193
+ * '<app-installation-id>',
1194
+ * '<function-id>',
1195
+ * '<log-id>'
1196
+ * )
1197
+ * )
1198
+ * .then((functionLog) => console.log(functionLog))
1199
+ * .catch(console.error)
1200
+ * ```
1201
+ */
1202
+ getFunctionLog(appInstallationId: string, functionId: string, logId: string): Promise<import("./entities/function-log").FunctionLogProps>;
1126
1203
  /**
1127
1204
  * Gets all snapshots of an entry
1128
1205
  * @func getEntrySnapshots
@@ -2,7 +2,7 @@ import type { Stream } from 'stream';
2
2
  import type { CreateTeamMembershipProps } from './entities/team-membership';
3
3
  import type { CreateTeamProps } from './entities/team';
4
4
  import type { CreateOrganizationInvitationProps } from './entities/organization-invitation';
5
- import type { BasicQueryOptions, MakeRequest, QueryOptions, QueryParams } from './common-types';
5
+ import type { AcceptsQueryOptions, BasicQueryOptions, MakeRequest, QueryOptions, QueryParams } from './common-types';
6
6
  import type { CreateAppDefinitionProps } from './entities/app-definition';
7
7
  import type { CreateAppActionProps } from './entities/app-action';
8
8
  import type { CreateAppSigningSecretProps } from './entities/app-signing-secret';
@@ -855,4 +855,32 @@ export default function createOrganizationApi(makeRequest: MakeRequest): {
855
855
  * ```
856
856
  */
857
857
  getAppActions(appDefinitionId: string): Promise<import("./common-types").Collection<import("./entities/app-action").AppAction, import("./entities/app-action").AppActionProps>>;
858
+ /**
859
+ * Gets an app function
860
+ * @param appDefinitionId
861
+ * @param functionId
862
+ * @returns Promise for a Function
863
+ * @example ```javascript
864
+ * const contentful = require('contentful-management')
865
+ * const client = contentful.createClient({
866
+ * accessToken: '<content_management_api_key>'
867
+ * })
868
+ * const org = await client.getOrganization('<org_id>')
869
+ * const functions = await org.getFunction('<app_definition_id>', '<function_id>')
870
+ */
871
+ getFunction(appDefinitionId: string, functionId: string): Promise<import("./export-types").FunctionProps>;
872
+ /**
873
+ * Gets a collection of app functions.
874
+ * @param appDefinitionId
875
+ * @param {import('../common-types').AcceptsQueryOptions} query - optional query parameter for filtering functions by action
876
+ * @returns Promise for a Function
877
+ * @example ```javascript
878
+ * const contentful = require('contentful-management')
879
+ * const client = contentful.createClient({
880
+ * accessToken: '<content_management_api_key>'
881
+ * })
882
+ * const org = await client.getOrganization('<org_id>')
883
+ * const functions = await org.getFunctions('<app_definition_id>', { 'accepts[all]': '<action>' })
884
+ */
885
+ getFunctions(appDefinitionId: string, query?: AcceptsQueryOptions): Promise<import("./common-types").Collection<import("./export-types").FunctionProps, import("./export-types").FunctionProps>>;
858
886
  };
@@ -6,6 +6,7 @@ export type AppInstallationProps = {
6
6
  appDefinition: SysLink;
7
7
  environment: SysLink;
8
8
  space: SysLink;
9
+ organization: SysLink;
9
10
  };
10
11
  /**
11
12
  * Free-form installation parameters (API limits stringified length to 32KB)