contentful-management 11.43.0-beta.1 → 11.43.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
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 getAll = (http, params) => {
18
+ return raw.get(http, baseURL(params), {
19
+ headers: _objectSpread({}, FunctionLogAlphaHeaders)
20
+ });
21
+ };
@@ -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,
@@ -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.0-beta.1"}`, params.application, params.integration, params.feature);
49
+ `${sdkMain}/${"11.43.0-beta.2"}`, params.application, params.integration, params.feature);
50
50
  const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
51
51
  userAgent
52
52
  }));
@@ -0,0 +1,94 @@
1
+ import entities from './entities';
2
+ import { wrapFunctionLogCollection } from './entities/function-log';
3
+
4
+ /**
5
+ * @private
6
+ */
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ export default function createFunctionLogApi(makeRequest) {
12
+ const {
13
+ wrapFunctionLog
14
+ } = entities.functionLog;
15
+ return {
16
+ /**
17
+ * Get a FunctionLog by it's log ID
18
+ * @Param spaceId - Space ID
19
+ * @Param environmentId - Environment ID
20
+ * @Param appInstallationId - App Installation ID
21
+ * @Param functionId - Function ID
22
+ * @Param logId - Log ID
23
+ * @returns a function log
24
+ * ```javascript
25
+ * const contentful = require('contentful-management')
26
+ *
27
+ * const client = contentful.createClient({
28
+ * accessToken: '<content_management_api_key>'
29
+ * })
30
+ *
31
+ * client.functionLog.get({
32
+ * spaceId: '<space_id>',
33
+ * environmentId: '<environment_id>',
34
+ * appInstallationId: '<app_installation_id>',
35
+ * functionId: '<function_id>',
36
+ * logId: '<log_id>'
37
+ * })
38
+ * .then((response) => console.log(response.items))
39
+ * .catch(console.error)
40
+ * ```
41
+ */
42
+ get(logId) {
43
+ const raw = this.toPlainObject();
44
+ return makeRequest({
45
+ entityType: 'FunctionLog',
46
+ action: 'get',
47
+ params: {
48
+ spaceId: raw.sys.space.sys.id,
49
+ environmentId: raw.sys.environment.sys.id,
50
+ appInstallationId: raw.sys.appDefinition.sys.id,
51
+ functionId: raw.sys.id,
52
+ logId: logId
53
+ }
54
+ }).then(data => wrapFunctionLog(makeRequest, data));
55
+ },
56
+ /**
57
+ * Get all FunctionLogs
58
+ * @Param spaceId - Space ID
59
+ * @Param environmentId - Environment ID
60
+ * @Param appInstallationId - App Installation ID
61
+ * @Param functionId - Function ID
62
+ * @returns a collection of FunctionLogs
63
+ * ```javascript
64
+ * const contentful = require('contentful-management')
65
+ *
66
+ * const client = contentful.createClient({
67
+ * accessToken: '<content_management_api_key>'
68
+ * })
69
+ *
70
+ * client.functionLog.getAll({
71
+ * spaceId: '<space_id>',
72
+ * environmentId: '<environment_id>',
73
+ * appInstallationId: '<app_installation_id>',
74
+ * functionId: '<function_id>'
75
+ * })
76
+ * .then((response) => console.log(response.items))
77
+ * .catch(console.error)
78
+ * ```
79
+ */
80
+ getAll() {
81
+ const raw = this.toPlainObject();
82
+ return makeRequest({
83
+ entityType: 'FunctionLog',
84
+ action: 'getAll',
85
+ params: {
86
+ spaceId: raw.sys.space.sys.id,
87
+ environmentId: raw.sys.environment.sys.id,
88
+ appInstallationId: raw.sys.appDefinition.sys.id,
89
+ functionId: raw.sys.id
90
+ }
91
+ }).then(data => wrapFunctionLogCollection(makeRequest, data));
92
+ }
93
+ };
94
+ }
@@ -0,0 +1,24 @@
1
+ import { freezeSys, toPlainObject } from 'contentful-sdk-core';
2
+ import copy from 'fast-copy';
3
+ import { wrapCollection } from '../common-utils';
4
+ import enhanceWithMethods from '../enhance-with-methods';
5
+ import createFunctionLogApi from '../create-function-log-api';
6
+ /**
7
+ * @private
8
+ * @param makeRequest - function to make requests via an adapter
9
+ * @param data - raw contentful-Function data
10
+ * @return Wrapped Function data
11
+ */
12
+ export function wrapFunctionLog(makeRequest, data) {
13
+ const appAction = toPlainObject(copy(data));
14
+ const appActionWithMethods = enhanceWithMethods(appAction, createFunctionLogApi(makeRequest));
15
+ return freezeSys(appActionWithMethods);
16
+ }
17
+
18
+ /**
19
+ * @private
20
+ * @param makeRequest - function to make requests via an adapter
21
+ * @param data - raw contentful-function data
22
+ * @return Wrapped App Function collection data
23
+ */
24
+ export const wrapFunctionLogCollection = wrapCollection(wrapFunctionLog);
@@ -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
+ getAll: wrap(wrapParams, 'FunctionLog', 'getAll')
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 getAll: RestEndpoint<'FunctionLog', 'getAll'>;
@@ -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
  }
@@ -363,6 +364,8 @@ type MRInternal<UA extends boolean> = {
363
364
  (opts: MROpts<'Function', 'get', UA>): MRReturn<'Function', 'get'>;
364
365
  (opts: MROpts<'Function', 'getMany', UA>): MRReturn<'Function', 'getMany'>;
365
366
  (opts: MROpts<'Function', 'getManyForEnvironment', UA>): MRReturn<'Function', 'getManyForEnvironment'>;
367
+ (opts: MROpts<'FunctionLog', 'get', UA>): MRReturn<'FunctionLog', 'get'>;
368
+ (opts: MROpts<'FunctionLog', 'getAll', UA>): MRReturn<'FunctionLog', 'getAll'>;
366
369
  (opts: MROpts<'Locale', 'get', UA>): MRReturn<'Locale', 'get'>;
367
370
  (opts: MROpts<'Locale', 'getMany', UA>): MRReturn<'Locale', 'getMany'>;
368
371
  (opts: MROpts<'Locale', 'delete', UA>): MRReturn<'Locale', 'delete'>;
@@ -1497,6 +1500,18 @@ export type MRActions = {
1497
1500
  return: CollectionProp<FunctionProps>;
1498
1501
  };
1499
1502
  };
1503
+ FunctionLog: {
1504
+ get: {
1505
+ params: GetFunctionLogParams;
1506
+ return: FunctionLogProps;
1507
+ headers?: RawAxiosRequestHeaders;
1508
+ };
1509
+ getAll: {
1510
+ params: GetAllFunctionLogParams;
1511
+ return: CollectionProp<FunctionLogProps>;
1512
+ headers?: RawAxiosRequestHeaders;
1513
+ };
1514
+ };
1500
1515
  Locale: {
1501
1516
  get: {
1502
1517
  params: GetSpaceEnvironmentParams & {
@@ -2385,6 +2400,12 @@ export type GetManyFunctionParams = GetAppDefinitionParams;
2385
2400
  export type GetFunctionForEnvParams = GetSpaceEnvironmentParams & {
2386
2401
  appInstallationId: string;
2387
2402
  };
2403
+ export type GetAllFunctionLogParams = GetFunctionForEnvParams & {
2404
+ functionId: string;
2405
+ };
2406
+ export type GetFunctionLogParams = GetAllFunctionLogParams & {
2407
+ logId: string;
2408
+ };
2388
2409
  export type GetOrganizationParams = {
2389
2410
  organizationId: string;
2390
2411
  };
@@ -0,0 +1,63 @@
1
+ import type { MakeRequest } from './common-types';
2
+ import type { FunctionLogProps } from './entities/function-log';
3
+ /**
4
+ * @private
5
+ */
6
+ export type ContentfulFunctionLogApi = ReturnType<typeof createFunctionLogApi>;
7
+ /**
8
+ * @private
9
+ */
10
+ export default function createFunctionLogApi(makeRequest: MakeRequest): {
11
+ /**
12
+ * Get a FunctionLog by it's log ID
13
+ * @Param spaceId - Space ID
14
+ * @Param environmentId - Environment ID
15
+ * @Param appInstallationId - App Installation ID
16
+ * @Param functionId - Function ID
17
+ * @Param logId - Log ID
18
+ * @returns a function log
19
+ * ```javascript
20
+ * const contentful = require('contentful-management')
21
+ *
22
+ * const client = contentful.createClient({
23
+ * accessToken: '<content_management_api_key>'
24
+ * })
25
+ *
26
+ * client.functionLog.get({
27
+ * spaceId: '<space_id>',
28
+ * environmentId: '<environment_id>',
29
+ * appInstallationId: '<app_installation_id>',
30
+ * functionId: '<function_id>',
31
+ * logId: '<log_id>'
32
+ * })
33
+ * .then((response) => console.log(response.items))
34
+ * .catch(console.error)
35
+ * ```
36
+ */
37
+ get(logId: string): Promise<FunctionLogProps & any>;
38
+ /**
39
+ * Get all FunctionLogs
40
+ * @Param spaceId - Space ID
41
+ * @Param environmentId - Environment ID
42
+ * @Param appInstallationId - App Installation ID
43
+ * @Param functionId - Function ID
44
+ * @returns a collection of FunctionLogs
45
+ * ```javascript
46
+ * const contentful = require('contentful-management')
47
+ *
48
+ * const client = contentful.createClient({
49
+ * accessToken: '<content_management_api_key>'
50
+ * })
51
+ *
52
+ * client.functionLog.getAll({
53
+ * spaceId: '<space_id>',
54
+ * environmentId: '<environment_id>',
55
+ * appInstallationId: '<app_installation_id>',
56
+ * functionId: '<function_id>'
57
+ * })
58
+ * .then((response) => console.log(response.items))
59
+ * .catch(console.error)
60
+ * ```
61
+ */
62
+ getAll(): Promise<import("./common-types").Collection<FunctionLogProps & any, FunctionLogProps>>;
63
+ };
@@ -0,0 +1,50 @@
1
+ import type { Link, DefaultElements } from '../common-types';
2
+ import type { MakeRequest } from '../common-types';
3
+ import createFunctionLogApi from '../create-function-log-api';
4
+ export type FunctionLogProps = {
5
+ sys: {
6
+ id: string;
7
+ type: 'FunctionLog';
8
+ createdBy: Link<'User'>;
9
+ createdAt: string;
10
+ space: Link<'Space'>;
11
+ environment: Link<'Environment'>;
12
+ appDefinition: Link<'AppDefinition'>;
13
+ };
14
+ severity: {
15
+ info: number;
16
+ warn: number;
17
+ error: number;
18
+ };
19
+ requestId: string;
20
+ event: {
21
+ type: string;
22
+ query: string;
23
+ isIntrospectionQuery: boolean;
24
+ variables: Record<string, any>;
25
+ };
26
+ messages: Array<{
27
+ timestamp: number;
28
+ type: 'INFO' | 'ERROR' | 'WARN';
29
+ message: string;
30
+ }>;
31
+ };
32
+ export interface FunctionLog extends FunctionLogProps, DefaultElements<FunctionLogProps> {
33
+ }
34
+ /**
35
+ * @private
36
+ * @param makeRequest - function to make requests via an adapter
37
+ * @param data - raw contentful-Function data
38
+ * @return Wrapped Function data
39
+ */
40
+ export declare function wrapFunctionLog(makeRequest: MakeRequest, data: FunctionLogProps): FunctionLogProps & ReturnType<typeof createFunctionLogApi>;
41
+ /**
42
+ * @private
43
+ * @param makeRequest - function to make requests via an adapter
44
+ * @param data - raw contentful-function data
45
+ * @return Wrapped App Function collection data
46
+ */
47
+ export declare const wrapFunctionLogCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<FunctionLogProps>) => import("../common-types").Collection<FunctionLogProps & {
48
+ get(logId: string): Promise<FunctionLogProps & any>;
49
+ getAll(): Promise<import("../common-types").Collection<FunctionLogProps & any, FunctionLogProps>>;
50
+ }, FunctionLogProps>;
@@ -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 @@ declare const _default: {
86
87
  environmentTemplateInstallation: typeof environmentTemplateInstallation;
87
88
  extension: typeof extension;
88
89
  func: typeof func;
90
+ functionLog: typeof functionLog;
89
91
  locale: typeof locale;
90
92
  organization: typeof organization;
91
93
  organizationInvitation: typeof organizationInvitation;
@@ -63,6 +63,7 @@ import type { WorkflowPlainClientAPI } from './entities/workflow';
63
63
  import type { WorkflowDefinitionPlainClientAPI } from './entities/workflow-definition';
64
64
  import type { WorkflowsChangelogPlainClientAPI } from './entities/workflows-changelog';
65
65
  import type { DefaultParams, OptionalDefaults } from './wrappers/wrap';
66
+ import type { FunctionLogPlainClientAPI } from './entities/function-log';
66
67
  export type PlainClientAPI = {
67
68
  raw: {
68
69
  getDefaultParams(): DefaultParams | undefined;
@@ -83,6 +84,7 @@ export type PlainClientAPI = {
83
84
  appSigningSecret: AppSigningSecretPlainClientAPI;
84
85
  appAccessToken: AppAccessTokenPlainClientAPI;
85
86
  function: FunctionPlainClientAPI;
87
+ functionLog: FunctionLogPlainClientAPI;
86
88
  editorInterface: EditorInterfacePlainClientAPI;
87
89
  space: SpacePlainClientAPI;
88
90
  environment: EnvironmentPlainClientAPI;
@@ -0,0 +1,38 @@
1
+ import type { CollectionProp, GetFunctionLogParams, GetAllFunctionLogParams } from '../../common-types';
2
+ import type { FunctionLogProps } from '../../entities/function-log';
3
+ import type { OptionalDefaults } from '../wrappers/wrap';
4
+ export type FunctionLogPlainClientAPI = {
5
+ /**
6
+ * Fetches the specified FunctionLog
7
+ * @param params - spaceId, environmentId, appInstallationId, functionId, logId
8
+ * @returns the FunctionLog
9
+ * @throws if the request fails, or the FunctionLog is not found
10
+ * @example
11
+ * ```javascript
12
+ * const functionLog = await client.functionLog.get({
13
+ * spaceId: '<space_id>',
14
+ * environmentId: '<environment_id>',
15
+ * appInstallationId: '<app_installation_id>',
16
+ * functionId: '<function_id>',
17
+ * logId: '<log_id>'
18
+ * });
19
+ * ```
20
+ */
21
+ get(params: OptionalDefaults<GetFunctionLogParams>): Promise<FunctionLogProps>;
22
+ /**
23
+ * Fetches all FunctionLogs for the given function
24
+ * @param params - spaceId, environmentId, appInstallationId, functionId
25
+ * @returns an object containing an array of FunctionLogs
26
+ * @throws if the request fails, or the FunctionLogs are not found
27
+ * @example
28
+ * ```javascript
29
+ * const functionLogs = await client.functionLog.getAll({
30
+ * spaceId: '<space_id>',
31
+ * environmentId: '<environment_id>',
32
+ * appInstallationId: '<app_installation_id>',
33
+ * functionId: '<function_id>'
34
+ * });
35
+ * ```
36
+ */
37
+ getAll(params: OptionalDefaults<GetAllFunctionLogParams>): Promise<CollectionProp<FunctionLogProps>>;
38
+ };
@@ -3,9 +3,9 @@ import type { FunctionProps } from '../../entities/function';
3
3
  import type { OptionalDefaults } from '../wrappers/wrap';
4
4
  export type FunctionPlainClientAPI = {
5
5
  /**
6
- * Fetches the specified function
6
+ * Fetches the specified Function
7
7
  * @param params organization ID, app definition ID, entity ID to identify the function
8
- * @returns the function
8
+ * @returns the Function
9
9
  * @throws if the request fails, or the Function is not found
10
10
  * @example
11
11
  * ```javascript
@@ -18,7 +18,7 @@ export type FunctionPlainClientAPI = {
18
18
  */
19
19
  get(params: OptionalDefaults<GetFunctionParams>): Promise<FunctionProps>;
20
20
  /**
21
- * Fetches all functions for the given app
21
+ * Fetches all Functions for the given app
22
22
  * @param params organization ID, app definition ID to identify the functions
23
23
  * @returns an object containing an array of Functions
24
24
  * @throws if the request fails, or the App is not found
@@ -32,7 +32,7 @@ export type FunctionPlainClientAPI = {
32
32
  */
33
33
  getMany(params: OptionalDefaults<GetManyFunctionParams>): Promise<CollectionProp<FunctionProps>>;
34
34
  /**
35
- * Fetches all functions for the given environment
35
+ * Fetches all Functions for the given environment
36
36
  * @param params space ID, environment ID, app installation ID to identify the functions
37
37
  * @returns an object containing an array of Functions
38
38
  * @throws if the request fails, or the Environment is not found
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-management",
3
- "version": "11.43.0-beta.1",
3
+ "version": "11.43.0-beta.2",
4
4
  "description": "Client for Contentful's Content Management API",
5
5
  "homepage": "https://www.contentful.com/developers/documentation/content-management-api/",
6
6
  "main": "./dist/contentful-management.node.js",