contentful-management 11.41.0 → 11.43.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.
- package/dist/contentful-management.browser.js +410 -139
- package/dist/contentful-management.browser.js.map +1 -1
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.node.js +401 -139
- package/dist/contentful-management.node.js.map +1 -1
- package/dist/contentful-management.node.min.js +1 -1
- package/dist/es-modules/adapters/REST/endpoints/asset.js +27 -4
- package/dist/es-modules/adapters/REST/endpoints/entry.js +27 -3
- package/dist/es-modules/adapters/REST/endpoints/function.js +16 -0
- package/dist/es-modules/adapters/REST/endpoints/index.js +2 -0
- package/dist/es-modules/contentful-management.js +1 -1
- package/dist/es-modules/create-function-api.js +115 -0
- package/dist/es-modules/entities/function.js +24 -1
- package/dist/es-modules/entities/index.js +2 -0
- package/dist/es-modules/plain/entities/function.js +1 -0
- package/dist/es-modules/plain/plain-client.js +3 -1
- package/dist/typings/adapters/REST/endpoints/function.d.ts +4 -0
- package/dist/typings/adapters/REST/endpoints/index.d.ts +2 -0
- package/dist/typings/common-types.d.ts +27 -6
- package/dist/typings/create-function-api.d.ts +78 -0
- package/dist/typings/entities/function.d.ts +23 -1
- package/dist/typings/entities/index.d.ts +2 -0
- package/dist/typings/plain/common-types.d.ts +7 -5
- package/dist/typings/plain/entities/function.d.ts +49 -0
- package/package.json +1 -1
|
@@ -45,15 +45,38 @@ export const del = (http, params) => {
|
|
|
45
45
|
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}`);
|
|
46
46
|
};
|
|
47
47
|
export const publish = (http, params, rawData) => {
|
|
48
|
-
var _rawData$sys$version2;
|
|
49
|
-
|
|
48
|
+
var _params$locales, _rawData$sys$version2;
|
|
49
|
+
const payload = (_params$locales = params.locales) !== null && _params$locales !== void 0 && _params$locales.length ? {
|
|
50
|
+
add: {
|
|
51
|
+
fields: {
|
|
52
|
+
'*': params.locales
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} : null;
|
|
56
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/published`, payload, {
|
|
50
57
|
headers: {
|
|
51
58
|
'X-Contentful-Version': (_rawData$sys$version2 = rawData.sys.version) !== null && _rawData$sys$version2 !== void 0 ? _rawData$sys$version2 : 0
|
|
52
59
|
}
|
|
53
60
|
});
|
|
54
61
|
};
|
|
55
|
-
export const unpublish = (http, params) => {
|
|
56
|
-
|
|
62
|
+
export const unpublish = (http, params, rawData) => {
|
|
63
|
+
var _params$locales2;
|
|
64
|
+
if ((_params$locales2 = params.locales) !== null && _params$locales2 !== void 0 && _params$locales2.length) {
|
|
65
|
+
const payload = {
|
|
66
|
+
remove: {
|
|
67
|
+
fields: {
|
|
68
|
+
'*': params.locales
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/published`, payload, {
|
|
73
|
+
headers: {
|
|
74
|
+
'X-Contentful-Version': rawData === null || rawData === void 0 ? void 0 : rawData.sys.version
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/published`);
|
|
79
|
+
}
|
|
57
80
|
};
|
|
58
81
|
export const archive = (http, params) => {
|
|
59
82
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/assets/${params.assetId}/archived`);
|
|
@@ -46,14 +46,38 @@ export const del = (http, params) => {
|
|
|
46
46
|
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}`);
|
|
47
47
|
};
|
|
48
48
|
export const publish = (http, params, rawData) => {
|
|
49
|
-
|
|
49
|
+
var _params$locales;
|
|
50
|
+
const payload = (_params$locales = params.locales) !== null && _params$locales !== void 0 && _params$locales.length ? {
|
|
51
|
+
add: {
|
|
52
|
+
fields: {
|
|
53
|
+
'*': params.locales
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} : null;
|
|
57
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/published`, payload, {
|
|
50
58
|
headers: {
|
|
51
59
|
'X-Contentful-Version': rawData.sys.version
|
|
52
60
|
}
|
|
53
61
|
});
|
|
54
62
|
};
|
|
55
|
-
export const unpublish = (http, params) => {
|
|
56
|
-
|
|
63
|
+
export const unpublish = (http, params, rawData) => {
|
|
64
|
+
var _params$locales2;
|
|
65
|
+
if ((_params$locales2 = params.locales) !== null && _params$locales2 !== void 0 && _params$locales2.length) {
|
|
66
|
+
const payload = {
|
|
67
|
+
remove: {
|
|
68
|
+
fields: {
|
|
69
|
+
'*': params.locales
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/published`, payload, {
|
|
74
|
+
headers: {
|
|
75
|
+
'X-Contentful-Version': rawData === null || rawData === void 0 ? void 0 : rawData.sys.version
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
return raw.del(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/published`);
|
|
80
|
+
}
|
|
57
81
|
};
|
|
58
82
|
export const archive = (http, params) => {
|
|
59
83
|
return raw.put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/archived`);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as raw from './raw';
|
|
2
|
+
// Base URL
|
|
3
|
+
const getManyUrl = params => `/organizations/${params.organizationId}/app_definitions/${params.appDefinitionId}/functions`;
|
|
4
|
+
const getFunctionUrl = params => `${getManyUrl(params)}/${params.functionId}`;
|
|
5
|
+
const getFunctionsEnvURL = params => {
|
|
6
|
+
return `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations/${params.appInstallationId}/functions`;
|
|
7
|
+
};
|
|
8
|
+
export const get = (http, params) => {
|
|
9
|
+
return raw.get(http, getFunctionUrl(params));
|
|
10
|
+
};
|
|
11
|
+
export const getMany = (http, params) => {
|
|
12
|
+
return raw.get(http, getManyUrl(params));
|
|
13
|
+
};
|
|
14
|
+
export const getManyForEnvironment = (http, params) => {
|
|
15
|
+
return raw.get(http, getFunctionsEnvURL(params));
|
|
16
|
+
};
|
|
@@ -26,6 +26,7 @@ import * as EnvironmentAlias from './environment-alias';
|
|
|
26
26
|
import * as EnvironmentTemplate from './environment-template';
|
|
27
27
|
import * as EnvironmentTemplateInstallation from './environment-template-installation';
|
|
28
28
|
import * as Extension from './extension';
|
|
29
|
+
import * as Function from './function';
|
|
29
30
|
import * as Http from './http';
|
|
30
31
|
import * as Locale from './locale';
|
|
31
32
|
import * as Organization from './organization';
|
|
@@ -87,6 +88,7 @@ export default {
|
|
|
87
88
|
EnvironmentTemplate,
|
|
88
89
|
EnvironmentTemplateInstallation,
|
|
89
90
|
Extension,
|
|
91
|
+
Function,
|
|
90
92
|
Http,
|
|
91
93
|
Locale,
|
|
92
94
|
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.
|
|
49
|
+
`${sdkMain}/${"11.43.0-beta.1"}`, params.application, params.integration, params.feature);
|
|
50
50
|
const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
|
|
51
51
|
userAgent
|
|
52
52
|
}));
|
|
@@ -0,0 +1,115 @@
|
|
|
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 +1,24 @@
|
|
|
1
|
-
|
|
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 createFunctionApi from '../create-function-api';
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @param makeRequest - (real) function to make requests via an adapter
|
|
9
|
+
* @param data - raw contentful-Function data
|
|
10
|
+
* @return Wrapped Function data
|
|
11
|
+
*/
|
|
12
|
+
export function wrapFunction(makeRequest, data) {
|
|
13
|
+
const appAction = toPlainObject(copy(data));
|
|
14
|
+
const appActionWithMethods = enhanceWithMethods(appAction, createFunctionApi(makeRequest));
|
|
15
|
+
return freezeSys(appActionWithMethods);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @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
|
+
*/
|
|
24
|
+
export const wrapFunctionCollection = wrapCollection(wrapFunction);
|
|
@@ -23,6 +23,7 @@ import * as environmentAlias from './environment-alias';
|
|
|
23
23
|
import * as environmentTemplate from './environment-template';
|
|
24
24
|
import * as environmentTemplateInstallation from './environment-template-installation';
|
|
25
25
|
import * as extension from './extension';
|
|
26
|
+
import * as func from './function';
|
|
26
27
|
import * as locale from './locale';
|
|
27
28
|
import * as organization from './organization';
|
|
28
29
|
import * as organizationInvitation from './organization-invitation';
|
|
@@ -84,6 +85,7 @@ export default {
|
|
|
84
85
|
environmentTemplate,
|
|
85
86
|
environmentTemplateInstallation,
|
|
86
87
|
extension,
|
|
88
|
+
func,
|
|
87
89
|
locale,
|
|
88
90
|
organization,
|
|
89
91
|
organizationInvitation,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -139,7 +139,9 @@ export const createPlainClient = (makeRequest, defaults) => {
|
|
|
139
139
|
updatePut: wrap(wrapParams, 'ConceptScheme', 'updatePut')
|
|
140
140
|
},
|
|
141
141
|
function: {
|
|
142
|
-
|
|
142
|
+
get: wrap(wrapParams, 'Function', 'get'),
|
|
143
|
+
getMany: wrap(wrapParams, 'Function', 'getMany'),
|
|
144
|
+
getManyForEnvironment: wrap(wrapParams, 'Function', 'getManyForEnvironment')
|
|
143
145
|
},
|
|
144
146
|
editorInterface: {
|
|
145
147
|
get: wrap(wrapParams, 'EditorInterface', 'get'),
|
|
@@ -26,6 +26,7 @@ import * as EnvironmentAlias from './environment-alias';
|
|
|
26
26
|
import * as EnvironmentTemplate from './environment-template';
|
|
27
27
|
import * as EnvironmentTemplateInstallation from './environment-template-installation';
|
|
28
28
|
import * as Extension from './extension';
|
|
29
|
+
import * as Function from './function';
|
|
29
30
|
import * as Http from './http';
|
|
30
31
|
import * as Locale from './locale';
|
|
31
32
|
import * as Organization from './organization';
|
|
@@ -87,6 +88,7 @@ declare const _default: {
|
|
|
87
88
|
EnvironmentTemplate: typeof EnvironmentTemplate;
|
|
88
89
|
EnvironmentTemplateInstallation: typeof EnvironmentTemplateInstallation;
|
|
89
90
|
Extension: typeof Extension;
|
|
91
|
+
Function: typeof Function;
|
|
90
92
|
Http: typeof Http;
|
|
91
93
|
Locale: typeof Locale;
|
|
92
94
|
Organization: typeof Organization;
|
|
@@ -152,6 +152,9 @@ export interface EntityMetaSysProps extends MetaSysProps {
|
|
|
152
152
|
firstPublishedAt?: string;
|
|
153
153
|
publishedCounter?: number;
|
|
154
154
|
locale?: string;
|
|
155
|
+
fieldStatus: {
|
|
156
|
+
'*': Record<string, 'draft' | 'changed' | 'published'>;
|
|
157
|
+
};
|
|
155
158
|
}
|
|
156
159
|
export interface EntryMetaSysProps extends EntityMetaSysProps {
|
|
157
160
|
contentType: SysLink;
|
|
@@ -357,6 +360,9 @@ type MRInternal<UA extends boolean> = {
|
|
|
357
360
|
(opts: MROpts<'Extension', 'createWithId', UA>): MRReturn<'Extension', 'createWithId'>;
|
|
358
361
|
(opts: MROpts<'Extension', 'update', UA>): MRReturn<'Extension', 'update'>;
|
|
359
362
|
(opts: MROpts<'Extension', 'delete', UA>): MRReturn<'Extension', 'delete'>;
|
|
363
|
+
(opts: MROpts<'Function', 'get', UA>): MRReturn<'Function', 'get'>;
|
|
364
|
+
(opts: MROpts<'Function', 'getMany', UA>): MRReturn<'Function', 'getMany'>;
|
|
365
|
+
(opts: MROpts<'Function', 'getManyForEnvironment', UA>): MRReturn<'Function', 'getManyForEnvironment'>;
|
|
360
366
|
(opts: MROpts<'Locale', 'get', UA>): MRReturn<'Locale', 'get'>;
|
|
361
367
|
(opts: MROpts<'Locale', 'getMany', UA>): MRReturn<'Locale', 'getMany'>;
|
|
362
368
|
(opts: MROpts<'Locale', 'delete', UA>): MRReturn<'Locale', 'delete'>;
|
|
@@ -1215,12 +1221,6 @@ export type MRActions = {
|
|
|
1215
1221
|
return: EditorInterfaceProps;
|
|
1216
1222
|
};
|
|
1217
1223
|
};
|
|
1218
|
-
Function: {
|
|
1219
|
-
getMany: {
|
|
1220
|
-
params: GetAppDefinitionParams & QueryParams;
|
|
1221
|
-
return: CollectionProp<FunctionProps>;
|
|
1222
|
-
};
|
|
1223
|
-
};
|
|
1224
1224
|
Environment: {
|
|
1225
1225
|
get: {
|
|
1226
1226
|
params: GetSpaceEnvironmentParams;
|
|
@@ -1483,6 +1483,20 @@ export type MRActions = {
|
|
|
1483
1483
|
return: any;
|
|
1484
1484
|
};
|
|
1485
1485
|
};
|
|
1486
|
+
Function: {
|
|
1487
|
+
get: {
|
|
1488
|
+
params: GetFunctionParams;
|
|
1489
|
+
return: FunctionProps;
|
|
1490
|
+
};
|
|
1491
|
+
getMany: {
|
|
1492
|
+
params: GetManyFunctionParams;
|
|
1493
|
+
return: CollectionProp<FunctionProps>;
|
|
1494
|
+
};
|
|
1495
|
+
getManyForEnvironment: {
|
|
1496
|
+
params: GetFunctionForEnvParams;
|
|
1497
|
+
return: CollectionProp<FunctionProps>;
|
|
1498
|
+
};
|
|
1499
|
+
};
|
|
1486
1500
|
Locale: {
|
|
1487
1501
|
get: {
|
|
1488
1502
|
params: GetSpaceEnvironmentParams & {
|
|
@@ -2364,6 +2378,13 @@ export type GetExtensionParams = GetSpaceEnvironmentParams & {
|
|
|
2364
2378
|
export type GetEnvironmentTemplateParams = GetOrganizationParams & {
|
|
2365
2379
|
environmentTemplateId: string;
|
|
2366
2380
|
};
|
|
2381
|
+
export type GetFunctionParams = GetAppDefinitionParams & {
|
|
2382
|
+
functionId: string;
|
|
2383
|
+
};
|
|
2384
|
+
export type GetManyFunctionParams = GetAppDefinitionParams;
|
|
2385
|
+
export type GetFunctionForEnvParams = GetSpaceEnvironmentParams & {
|
|
2386
|
+
appInstallationId: string;
|
|
2387
|
+
};
|
|
2367
2388
|
export type GetOrganizationParams = {
|
|
2368
2389
|
organizationId: string;
|
|
2369
2390
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Link } from '../common-types';
|
|
1
|
+
import type { Link, DefaultElements } from '../common-types';
|
|
2
|
+
import type { MakeRequest } from '../common-types';
|
|
3
|
+
import createFunctionApi from '../create-function-api';
|
|
2
4
|
export type FunctionProps = {
|
|
3
5
|
sys: {
|
|
4
6
|
id: string;
|
|
@@ -16,3 +18,23 @@ export type FunctionProps = {
|
|
|
16
18
|
accepts: string[];
|
|
17
19
|
allowNetworks?: string[];
|
|
18
20
|
};
|
|
21
|
+
export interface Function extends FunctionProps, DefaultElements<FunctionProps> {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
* @param makeRequest - (real) function to make requests via an adapter
|
|
26
|
+
* @param data - raw contentful-Function data
|
|
27
|
+
* @return Wrapped Function data
|
|
28
|
+
*/
|
|
29
|
+
export declare function wrapFunction(makeRequest: MakeRequest, data: FunctionProps): FunctionProps & ReturnType<typeof createFunctionApi>;
|
|
30
|
+
/**
|
|
31
|
+
* @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
|
+
*/
|
|
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>;
|
|
@@ -23,6 +23,7 @@ import * as environmentAlias from './environment-alias';
|
|
|
23
23
|
import * as environmentTemplate from './environment-template';
|
|
24
24
|
import * as environmentTemplateInstallation from './environment-template-installation';
|
|
25
25
|
import * as extension from './extension';
|
|
26
|
+
import * as func from './function';
|
|
26
27
|
import * as locale from './locale';
|
|
27
28
|
import * as organization from './organization';
|
|
28
29
|
import * as organizationInvitation from './organization-invitation';
|
|
@@ -84,6 +85,7 @@ declare const _default: {
|
|
|
84
85
|
environmentTemplate: typeof environmentTemplate;
|
|
85
86
|
environmentTemplateInstallation: typeof environmentTemplateInstallation;
|
|
86
87
|
extension: typeof extension;
|
|
88
|
+
func: typeof func;
|
|
87
89
|
locale: typeof locale;
|
|
88
90
|
organization: typeof organization;
|
|
89
91
|
organizationInvitation: typeof organizationInvitation;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RawAxiosRequestConfig, RawAxiosRequestHeaders } from 'axios';
|
|
2
2
|
import type { OpPatch } from 'json-patch';
|
|
3
|
-
import type { BasicCursorPaginationOptions, CollectionProp, CursorPaginatedCollectionProp, EnvironmentTemplateParams,
|
|
3
|
+
import type { BasicCursorPaginationOptions, CollectionProp, CursorPaginatedCollectionProp, EnvironmentTemplateParams, GetBulkActionParams, GetContentTypeParams, GetEnvironmentTemplateParams, GetOrganizationMembershipParams, GetOrganizationParams, GetReleaseParams, GetSnapshotForContentTypeParams, GetSnapshotForEntryParams, GetSpaceEnvironmentParams, GetSpaceParams, KeyValueMap, QueryParams } from '../common-types';
|
|
4
4
|
import type { AccessTokenProps, CreatePersonalAccessTokenProps as CreatePATProps } from '../entities/access-token';
|
|
5
5
|
import type { ApiKeyProps, CreateApiKeyProps } from '../entities/api-key';
|
|
6
6
|
import type { AssetFileProp, AssetProcessingForLocale, AssetProps, CreateAssetProps } from '../entities/asset';
|
|
@@ -10,7 +10,6 @@ import type { ContentTypeProps, CreateContentTypeProps } from '../entities/conte
|
|
|
10
10
|
import type { CreateEntryProps, EntryProps, EntryReferenceProps } from '../entities/entry';
|
|
11
11
|
import type { CreateEnvironmentTemplateProps, EnvironmentTemplateProps } from '../entities/environment-template';
|
|
12
12
|
import type { CreateEnvironmentTemplateInstallationProps, EnvironmentTemplateInstallationProps, EnvironmentTemplateValidationProps, ValidateEnvironmentTemplateInstallationProps } from '../entities/environment-template-installation';
|
|
13
|
-
import type { FunctionProps } from '../entities/function';
|
|
14
13
|
import type { CreateOrganizationInvitationProps, OrganizationInvitationProps } from '../entities/organization-invitation';
|
|
15
14
|
import type { OrganizationMembershipProps } from '../entities/organization-membership';
|
|
16
15
|
import type { CreatePersonalAccessTokenProps, PersonalAccessTokenProps } from '../entities/personal-access-token';
|
|
@@ -38,6 +37,7 @@ import type { EditorInterfacePlainClientAPI } from './entities/editor-interface'
|
|
|
38
37
|
import type { EnvironmentPlainClientAPI } from './entities/environment';
|
|
39
38
|
import type { EnvironmentAliasPlainClientAPI } from './entities/environment-alias';
|
|
40
39
|
import type { ExtensionPlainClientAPI } from './entities/extension';
|
|
40
|
+
import type { FunctionPlainClientAPI } from './entities/function';
|
|
41
41
|
import type { LocalePlainClientAPI } from './entities/locale';
|
|
42
42
|
import type { OrganizationPlainClientAPI } from './entities/organization';
|
|
43
43
|
import type { ResourcePlainAPI } from './entities/resource';
|
|
@@ -82,9 +82,7 @@ export type PlainClientAPI = {
|
|
|
82
82
|
appSignedRequest: AppSignedRequestPlainClientAPI;
|
|
83
83
|
appSigningSecret: AppSigningSecretPlainClientAPI;
|
|
84
84
|
appAccessToken: AppAccessTokenPlainClientAPI;
|
|
85
|
-
function:
|
|
86
|
-
getMany(params: OptionalDefaults<GetAppDefinitionParams & QueryParams>): Promise<CollectionProp<FunctionProps>>;
|
|
87
|
-
};
|
|
85
|
+
function: FunctionPlainClientAPI;
|
|
88
86
|
editorInterface: EditorInterfacePlainClientAPI;
|
|
89
87
|
space: SpacePlainClientAPI;
|
|
90
88
|
environment: EnvironmentPlainClientAPI;
|
|
@@ -172,9 +170,11 @@ export type PlainClientAPI = {
|
|
|
172
170
|
}>): Promise<any>;
|
|
173
171
|
publish<T extends KeyValueMap = KeyValueMap>(params: OptionalDefaults<GetSpaceEnvironmentParams & {
|
|
174
172
|
entryId: string;
|
|
173
|
+
locales?: string[];
|
|
175
174
|
}>, rawData: EntryProps<T>): Promise<EntryProps<T>>;
|
|
176
175
|
unpublish<T extends KeyValueMap = KeyValueMap>(params: OptionalDefaults<GetSpaceEnvironmentParams & {
|
|
177
176
|
entryId: string;
|
|
177
|
+
locales?: string[];
|
|
178
178
|
}>): Promise<EntryProps<T>>;
|
|
179
179
|
archive<T extends KeyValueMap = KeyValueMap>(params: OptionalDefaults<GetSpaceEnvironmentParams & {
|
|
180
180
|
entryId: string;
|
|
@@ -208,9 +208,11 @@ export type PlainClientAPI = {
|
|
|
208
208
|
}>): Promise<any>;
|
|
209
209
|
publish(params: OptionalDefaults<GetSpaceEnvironmentParams & {
|
|
210
210
|
assetId: string;
|
|
211
|
+
locales?: string[];
|
|
211
212
|
}>, rawData: AssetProps): Promise<AssetProps>;
|
|
212
213
|
unpublish(params: OptionalDefaults<GetSpaceEnvironmentParams & {
|
|
213
214
|
assetId: string;
|
|
215
|
+
locales?: string[];
|
|
214
216
|
}>): Promise<AssetProps>;
|
|
215
217
|
archive(params: OptionalDefaults<GetSpaceEnvironmentParams & {
|
|
216
218
|
assetId: string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { CollectionProp, GetFunctionParams, GetFunctionForEnvParams, GetManyFunctionParams } from '../../common-types';
|
|
2
|
+
import type { FunctionProps } from '../../entities/function';
|
|
3
|
+
import type { OptionalDefaults } from '../wrappers/wrap';
|
|
4
|
+
export type FunctionPlainClientAPI = {
|
|
5
|
+
/**
|
|
6
|
+
* Fetches the specified function
|
|
7
|
+
* @param params organization ID, app definition ID, entity ID to identify the function
|
|
8
|
+
* @returns the function
|
|
9
|
+
* @throws if the request fails, or the Function is not found
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* const func = await client.function.get({
|
|
13
|
+
* organizationId: "<org_id>",
|
|
14
|
+
* appDefinitionId: "<app_definition_id>",
|
|
15
|
+
* functionId: "<function_id>",
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
get(params: OptionalDefaults<GetFunctionParams>): Promise<FunctionProps>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches all functions for the given app
|
|
22
|
+
* @param params organization ID, app definition ID to identify the functions
|
|
23
|
+
* @returns an object containing an array of Functions
|
|
24
|
+
* @throws if the request fails, or the App is not found
|
|
25
|
+
* @example
|
|
26
|
+
* ```javascript
|
|
27
|
+
* const functions = await client.function.getMany({
|
|
28
|
+
* organizationId: "<org_id>",
|
|
29
|
+
* appDefinitionId: "<app_definition_id>",
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
getMany(params: OptionalDefaults<GetManyFunctionParams>): Promise<CollectionProp<FunctionProps>>;
|
|
34
|
+
/**
|
|
35
|
+
* Fetches all functions for the given environment
|
|
36
|
+
* @param params space ID, environment ID, app installation ID to identify the functions
|
|
37
|
+
* @returns an object containing an array of Functions
|
|
38
|
+
* @throws if the request fails, or the Environment is not found
|
|
39
|
+
* @example
|
|
40
|
+
* ```javascript
|
|
41
|
+
* const functions = await client.function.getManyForEnvironment({
|
|
42
|
+
* spaceId: "<space_id>",
|
|
43
|
+
* environmentId: "<environment_id>",
|
|
44
|
+
* appInstallationId: "<app_installation_id>",
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
getManyForEnvironment(params: OptionalDefaults<GetFunctionForEnvParams>): Promise<CollectionProp<FunctionProps>>;
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentful-management",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.43.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",
|