contentful-management 11.44.0 → 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 (32) 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/function-log.d.ts +46 -0
  25. package/dist/typings/entities/function.d.ts +2 -10
  26. package/dist/typings/entities/index.d.ts +2 -0
  27. package/dist/typings/plain/common-types.d.ts +2 -0
  28. package/dist/typings/plain/entities/function-log.d.ts +39 -0
  29. package/dist/typings/plain/entities/function.d.ts +5 -3
  30. package/package.json +1 -1
  31. package/dist/es-modules/create-function-api.js +0 -115
  32. package/dist/typings/create-function-api.d.ts +0 -78
@@ -0,0 +1,46 @@
1
+ import type { Link, DefaultElements } from '../common-types';
2
+ import type { MakeRequest } from '../common-types';
3
+ export type FunctionLogProps = {
4
+ sys: {
5
+ id: string;
6
+ type: 'FunctionLog';
7
+ createdBy: Link<'User'>;
8
+ createdAt: string;
9
+ space: Link<'Space'>;
10
+ environment: Link<'Environment'>;
11
+ appDefinition: Link<'AppDefinition'>;
12
+ };
13
+ severity: {
14
+ info: number;
15
+ warn: number;
16
+ error: number;
17
+ };
18
+ requestId: string;
19
+ event: {
20
+ type: string;
21
+ query: string;
22
+ isIntrospectionQuery: boolean;
23
+ variables: Record<string, any>;
24
+ };
25
+ messages: Array<{
26
+ timestamp: number;
27
+ type: 'INFO' | 'ERROR' | 'WARN';
28
+ message: string;
29
+ }>;
30
+ };
31
+ export interface FunctionLog extends FunctionLogProps, DefaultElements<FunctionLogProps> {
32
+ }
33
+ /**
34
+ * @private
35
+ * @param makeRequest - function to make requests via an adapter
36
+ * @param data - raw contentful-Function data
37
+ * @return Wrapped Function data
38
+ */
39
+ export declare function wrapFunctionLog(makeRequest: MakeRequest, data: FunctionLogProps): FunctionLogProps;
40
+ /**
41
+ * @private
42
+ * @param makeRequest - function to make requests via an adapter
43
+ * @param data - raw contentful-function data
44
+ * @return Wrapped App Function collection data
45
+ */
46
+ export declare const wrapFunctionLogCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<FunctionLogProps>) => import("../common-types").Collection<FunctionLogProps, FunctionLogProps>;
@@ -1,6 +1,5 @@
1
1
  import type { Link, DefaultElements } from '../common-types';
2
2
  import type { MakeRequest } from '../common-types';
3
- import createFunctionApi from '../create-function-api';
4
3
  export type FunctionProps = {
5
4
  sys: {
6
5
  id: string;
@@ -26,15 +25,8 @@ export interface Function extends FunctionProps, DefaultElements<FunctionProps>
26
25
  * @param data - raw contentful-Function data
27
26
  * @return Wrapped Function data
28
27
  */
29
- export declare function wrapFunction(makeRequest: MakeRequest, data: FunctionProps): FunctionProps & ReturnType<typeof createFunctionApi>;
28
+ export declare function wrapFunction(makeRequest: MakeRequest, data: FunctionProps): FunctionProps;
30
29
  /**
31
30
  * @private
32
- * @param makeRequest - real) function to make requests via an adapter
33
- * @param data - raw contentful-function data
34
- * @return Wrapped App Function collection data
35
31
  */
36
- export declare const wrapFunctionCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<FunctionProps>) => import("../common-types").Collection<FunctionProps & {
37
- getManyFunctions(): Promise<import("../common-types").Collection<FunctionProps & any, FunctionProps>>;
38
- getFunction(functionId: string): Promise<FunctionProps & any>;
39
- getManyFunctionsForEnvironment(spaceId: string, environmentId: string, appInstallationId: string): Promise<import("../common-types").Collection<FunctionProps & any, FunctionProps>>;
40
- }, FunctionProps>;
32
+ export declare const wrapFunctionCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<FunctionProps>) => import("../common-types").Collection<FunctionProps, FunctionProps>;
@@ -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,39 @@
1
+ import type { CollectionProp, GetFunctionLogParams, GetManyFunctionLogParams } 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
+ * @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
+ * @params spaceId, environmentId, appInstallationId, functionId, query
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
+ * query: { limit: 100 }
35
+ * });
36
+ * ```
37
+ */
38
+ getMany(params: OptionalDefaults<GetManyFunctionLogParams>): Promise<CollectionProp<FunctionLogProps>>;
39
+ };
@@ -4,7 +4,7 @@ import type { OptionalDefaults } from '../wrappers/wrap';
4
4
  export type FunctionPlainClientAPI = {
5
5
  /**
6
6
  * Fetches the specified Function
7
- * @param params organization ID, app definition ID, entity ID to identify the function
7
+ * @params organizationId, appDefinitionId, functionId
8
8
  * @returns the Function
9
9
  * @throws if the request fails, or the Function is not found
10
10
  * @example
@@ -19,7 +19,7 @@ export type FunctionPlainClientAPI = {
19
19
  get(params: OptionalDefaults<GetFunctionParams>): Promise<FunctionProps>;
20
20
  /**
21
21
  * Fetches all Functions for the given app
22
- * @param params organization ID, app definition ID to identify the functions
22
+ * @params organizationId, appDefinitionId, query
23
23
  * @returns an object containing an array of Functions
24
24
  * @throws if the request fails, or the App is not found
25
25
  * @example
@@ -27,13 +27,14 @@ export type FunctionPlainClientAPI = {
27
27
  * const functions = await client.function.getMany({
28
28
  * organizationId: "<org_id>",
29
29
  * appDefinitionId: "<app_definition_id>",
30
+ * query: { 'accepts[all]': '<action>' },
30
31
  * });
31
32
  * ```
32
33
  */
33
34
  getMany(params: OptionalDefaults<GetManyFunctionParams>): Promise<CollectionProp<FunctionProps>>;
34
35
  /**
35
36
  * Fetches all Functions for the given environment
36
- * @param params space ID, environment ID, app installation ID to identify the functions
37
+ * @params spaceId, environmentId, appInstallationId, query
37
38
  * @returns an object containing an array of Functions
38
39
  * @throws if the request fails, or the Environment is not found
39
40
  * @example
@@ -42,6 +43,7 @@ export type FunctionPlainClientAPI = {
42
43
  * spaceId: "<space_id>",
43
44
  * environmentId: "<environment_id>",
44
45
  * appInstallationId: "<app_installation_id>",
46
+ * query: { 'accepts[all]': '<action>' },
45
47
  * });
46
48
  * ```
47
49
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-management",
3
- "version": "11.44.0",
3
+ "version": "11.45.0-beta.1",
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",
@@ -1,115 +0,0 @@
1
- import entities from './entities';
2
-
3
- /**
4
- * @private
5
- */
6
-
7
- /**
8
- * @private
9
- */
10
- export default function createFunctionApi(makeRequest) {
11
- const {
12
- wrapFunction,
13
- wrapFunctionCollection
14
- } = entities.func;
15
- return {
16
- /**
17
- * Gets all Functions for an App Definition
18
- * @Param organizationId - Organization ID
19
- * @Param appDefinitionId - App Definition ID
20
- * @returns a collection of Functions
21
- * ```javascript
22
- * const contentful = require('contentful-management')
23
- *
24
- * const client = contentful.createClient({
25
- * accessToken: '<content_management_api_key>'
26
- * })
27
- *
28
- * client.function.getMany({
29
- * organizationId: <organizationId>,
30
- * appDefinitionId: <appDefinitionId>
31
- * })
32
- * .then((response) => console.log(response.items))
33
- * .catch(console.error)
34
- * ```
35
- */
36
- getManyFunctions() {
37
- const raw = this.toPlainObject();
38
- return makeRequest({
39
- entityType: 'Function',
40
- action: 'getMany',
41
- params: {
42
- appDefinitionId: raw.sys.appDefinition.sys.id,
43
- organizationId: raw.sys.organization.sys.id
44
- }
45
- }).then(data => wrapFunctionCollection(makeRequest, data));
46
- },
47
- /**
48
- * Gets a Function by ID
49
- * @Param organizationId - Organization ID
50
- * @Param appDefinitionId - App Definition ID
51
- * @Param functionId - Function ID
52
- * @returns a collection of Functions
53
- * ```javascript
54
- * const contentful = require('contentful-management')
55
- *
56
- * const client = contentful.createClient({
57
- * accessToken: '<content_management_api_key>'
58
- * })
59
- *
60
- * client.function.get({
61
- * organizationId: <organizationId>,
62
- * appDefinitionId: <appDefinitionId>,
63
- * functionId: <functionId>
64
- * })
65
- * .then((response) => console.log(response.items))
66
- * .catch(console.error)
67
- * ```
68
- */
69
- getFunction(functionId) {
70
- const raw = this.toPlainObject();
71
- return makeRequest({
72
- entityType: 'Function',
73
- action: 'get',
74
- params: {
75
- appDefinitionId: raw.sys.appDefinition.sys.id,
76
- organizationId: raw.sys.organization.sys.id,
77
- functionId
78
- }
79
- }).then(data => wrapFunction(makeRequest, data));
80
- },
81
- /**
82
- * Gets all Functions for an Environment
83
- * @Param organizationId - Organization ID
84
- * @Param appDefinitionId - App Definition ID
85
- * @Param functionId - Function ID
86
- * @returns a collection of Functions
87
- * ```javascript
88
- * const contentful = require('contentful-management')
89
- *
90
- * const client = contentful.createClient({
91
- * accessToken: '<content_management_api_key>'
92
- * })
93
- *
94
- * client.function.get({
95
- * environmentId: <environmentId>,
96
- * spaceId: <spaceId>,
97
- * appInstallationId: <appInstallationId>
98
- * })
99
- * .then((response) => console.log(response.items))
100
- * .catch(console.error)
101
- * ```
102
- */
103
- getManyFunctionsForEnvironment(spaceId, environmentId, appInstallationId) {
104
- return makeRequest({
105
- entityType: 'Function',
106
- action: 'getManyForEnvironment',
107
- params: {
108
- spaceId: spaceId,
109
- environmentId: environmentId,
110
- appInstallationId: appInstallationId
111
- }
112
- }).then(data => wrapFunctionCollection(makeRequest, data));
113
- }
114
- };
115
- }
@@ -1,78 +0,0 @@
1
- import type { MakeRequest } from './common-types';
2
- import type { FunctionProps } from './entities/function';
3
- /**
4
- * @private
5
- */
6
- export type ContentfulFunctionApi = ReturnType<typeof createFunctionApi>;
7
- /**
8
- * @private
9
- */
10
- export default function createFunctionApi(makeRequest: MakeRequest): {
11
- /**
12
- * Gets all Functions for an App Definition
13
- * @Param organizationId - Organization ID
14
- * @Param appDefinitionId - App Definition ID
15
- * @returns a collection of Functions
16
- * ```javascript
17
- * const contentful = require('contentful-management')
18
- *
19
- * const client = contentful.createClient({
20
- * accessToken: '<content_management_api_key>'
21
- * })
22
- *
23
- * client.function.getMany({
24
- * organizationId: <organizationId>,
25
- * appDefinitionId: <appDefinitionId>
26
- * })
27
- * .then((response) => console.log(response.items))
28
- * .catch(console.error)
29
- * ```
30
- */
31
- getManyFunctions(): Promise<import("./common-types").Collection<FunctionProps & any, FunctionProps>>;
32
- /**
33
- * Gets a Function by ID
34
- * @Param organizationId - Organization ID
35
- * @Param appDefinitionId - App Definition ID
36
- * @Param functionId - Function ID
37
- * @returns a collection of Functions
38
- * ```javascript
39
- * const contentful = require('contentful-management')
40
- *
41
- * const client = contentful.createClient({
42
- * accessToken: '<content_management_api_key>'
43
- * })
44
- *
45
- * client.function.get({
46
- * organizationId: <organizationId>,
47
- * appDefinitionId: <appDefinitionId>,
48
- * functionId: <functionId>
49
- * })
50
- * .then((response) => console.log(response.items))
51
- * .catch(console.error)
52
- * ```
53
- */
54
- getFunction(functionId: string): Promise<FunctionProps & any>;
55
- /**
56
- * Gets all Functions for an Environment
57
- * @Param organizationId - Organization ID
58
- * @Param appDefinitionId - App Definition ID
59
- * @Param functionId - Function ID
60
- * @returns a collection of Functions
61
- * ```javascript
62
- * const contentful = require('contentful-management')
63
- *
64
- * const client = contentful.createClient({
65
- * accessToken: '<content_management_api_key>'
66
- * })
67
- *
68
- * client.function.get({
69
- * environmentId: <environmentId>,
70
- * spaceId: <spaceId>,
71
- * appInstallationId: <appInstallationId>
72
- * })
73
- * .then((response) => console.log(response.items))
74
- * .catch(console.error)
75
- * ```
76
- */
77
- getManyFunctionsForEnvironment(spaceId: string, environmentId: string, appInstallationId: string): Promise<import("./common-types").Collection<FunctionProps & any, FunctionProps>>;
78
- };