contentful-management 12.0.0-beta.1 → 12.0.0-beta.3
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/README.md +3 -0
- package/dist/cjs/adapters/REST/endpoints/access-token.cjs +136 -0
- package/dist/cjs/adapters/REST/endpoints/ai-action-invocation.cjs +9 -0
- package/dist/cjs/adapters/REST/endpoints/ai-action.cjs +53 -0
- package/dist/cjs/adapters/REST/endpoints/api-key.cjs +48 -0
- package/dist/cjs/adapters/REST/endpoints/app-access-token.cjs +9 -0
- package/dist/cjs/adapters/REST/endpoints/app-action-call.cjs +65 -0
- package/dist/cjs/adapters/REST/endpoints/app-action.cjs +42 -0
- package/dist/cjs/adapters/REST/endpoints/app-bundle.cjs +39 -0
- package/dist/cjs/adapters/REST/endpoints/app-definition.cjs +47 -0
- package/dist/cjs/adapters/REST/endpoints/app-details.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/app-event-subscription.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/app-installation.cjs +42 -0
- package/dist/cjs/adapters/REST/endpoints/app-key.cjs +21 -0
- package/dist/cjs/adapters/REST/endpoints/app-signed-request.cjs +9 -0
- package/dist/cjs/adapters/REST/endpoints/app-signing-secret.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/app-upload.cjs +28 -0
- package/dist/cjs/adapters/REST/endpoints/asset-key.cjs +34 -0
- package/dist/cjs/adapters/REST/endpoints/asset.cjs +185 -0
- package/dist/cjs/adapters/REST/endpoints/bulk-action.cjs +21 -0
- package/dist/cjs/adapters/REST/endpoints/comment.cjs +92 -0
- package/dist/cjs/adapters/REST/endpoints/concept-scheme.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/concept.cjs +65 -0
- package/dist/cjs/adapters/REST/endpoints/content-type.cjs +56 -0
- package/dist/cjs/adapters/REST/endpoints/editor-interface.cjs +24 -0
- package/dist/cjs/adapters/REST/endpoints/entry.cjs +104 -0
- package/dist/cjs/adapters/REST/endpoints/environment-alias.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/environment-template-installation.cjs +23 -0
- package/dist/cjs/adapters/REST/endpoints/environment-template.cjs +49 -0
- package/dist/cjs/adapters/REST/endpoints/environment.cjs +47 -0
- package/dist/cjs/adapters/REST/endpoints/extension.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/function-log.cjs +23 -0
- package/dist/cjs/adapters/REST/endpoints/function.cjs +25 -0
- package/dist/cjs/adapters/REST/endpoints/http.cjs +29 -0
- package/dist/cjs/adapters/REST/endpoints/index.cjs +139 -0
- package/dist/cjs/adapters/REST/endpoints/locale.cjs +37 -0
- package/dist/cjs/adapters/REST/endpoints/oauth-application.cjs +147 -0
- package/dist/cjs/adapters/REST/endpoints/organization-invitation.cjs +23 -0
- package/dist/cjs/adapters/REST/endpoints/organization-membership.cjs +32 -0
- package/dist/cjs/adapters/REST/endpoints/organization.cjs +28 -0
- package/dist/cjs/adapters/REST/endpoints/personal-access-token.cjs +37 -0
- package/dist/cjs/adapters/REST/endpoints/preview-api-key.cjs +15 -0
- package/dist/cjs/adapters/REST/endpoints/raw.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/release-action.cjs +21 -0
- package/dist/cjs/adapters/REST/endpoints/release.cjs +61 -0
- package/dist/cjs/adapters/REST/endpoints/resource-provider.cjs +18 -0
- package/dist/cjs/adapters/REST/endpoints/resource-type.cjs +30 -0
- package/dist/cjs/adapters/REST/endpoints/resource.cjs +10 -0
- package/dist/cjs/adapters/REST/endpoints/role.cjs +48 -0
- package/dist/cjs/adapters/REST/endpoints/scheduled-action.cjs +44 -0
- package/dist/cjs/adapters/REST/endpoints/snapshot.cjs +30 -0
- package/dist/cjs/adapters/REST/endpoints/space-member.cjs +11 -0
- package/dist/cjs/adapters/REST/endpoints/space-membership.cjs +60 -0
- package/dist/cjs/adapters/REST/endpoints/space.cjs +34 -0
- package/dist/cjs/adapters/REST/endpoints/tag.cjs +37 -0
- package/dist/cjs/adapters/REST/endpoints/task.cjs +40 -0
- package/dist/cjs/adapters/REST/endpoints/team-membership.cjs +35 -0
- package/dist/cjs/adapters/REST/endpoints/team-space-membership.cjs +46 -0
- package/dist/cjs/adapters/REST/endpoints/team.cjs +36 -0
- package/dist/cjs/adapters/REST/endpoints/ui-config.cjs +22 -0
- package/dist/cjs/adapters/REST/endpoints/upload-credentials.cjs +16 -0
- package/dist/cjs/adapters/REST/endpoints/upload.cjs +42 -0
- package/dist/cjs/adapters/REST/endpoints/usage.cjs +17 -0
- package/dist/cjs/adapters/REST/endpoints/user-ui-config.cjs +22 -0
- package/dist/cjs/adapters/REST/endpoints/user.cjs +27 -0
- package/dist/cjs/adapters/REST/endpoints/utils.cjs +20 -0
- package/dist/cjs/adapters/REST/endpoints/webhook.cjs +98 -0
- package/dist/cjs/adapters/REST/endpoints/workflow-definition.cjs +41 -0
- package/dist/cjs/adapters/REST/endpoints/workflow.cjs +49 -0
- package/dist/cjs/adapters/REST/endpoints/workflows-changelog.cjs +11 -0
- package/dist/cjs/adapters/REST/make-request.cjs +19 -0
- package/dist/cjs/adapters/REST/rest-adapter.cjs +32 -0
- package/dist/cjs/common-types.cjs +6 -0
- package/dist/cjs/common-utils.cjs +38 -0
- package/dist/cjs/constants/editor-interface-defaults/controls-defaults.cjs +161 -0
- package/dist/cjs/constants/editor-interface-defaults/editors-defaults.cjs +40 -0
- package/dist/cjs/constants/editor-interface-defaults/index.cjs +14 -0
- package/dist/cjs/constants/editor-interface-defaults/sidebar-defaults.cjs +71 -0
- package/dist/cjs/constants/editor-interface-defaults/types.cjs +18 -0
- package/dist/cjs/create-adapter.cjs +21 -0
- package/dist/cjs/create-app-definition-api.cjs +254 -0
- package/dist/cjs/create-contentful-api.cjs +592 -0
- package/dist/cjs/create-entry-api.cjs +481 -0
- package/dist/cjs/create-environment-api.cjs +2403 -0
- package/dist/cjs/create-environment-template-api.cjs +270 -0
- package/dist/cjs/create-organization-api.cjs +1136 -0
- package/dist/cjs/create-space-api.cjs +1591 -0
- package/dist/cjs/create-ui-config-api.cjs +55 -0
- package/dist/cjs/create-user-ui-config-api.cjs +55 -0
- package/dist/cjs/enhance-with-methods.cjs +26 -0
- package/dist/cjs/entities/access-token.cjs +36 -0
- package/dist/cjs/entities/ai-action-invocation.cjs +46 -0
- package/dist/cjs/entities/ai-action.cjs +94 -0
- package/dist/cjs/entities/api-key.cjs +59 -0
- package/dist/cjs/entities/app-access-token.cjs +17 -0
- package/dist/cjs/entities/app-action-call.cjs +67 -0
- package/dist/cjs/entities/app-action.cjs +48 -0
- package/dist/cjs/entities/app-bundle.cjs +48 -0
- package/dist/cjs/entities/app-definition.cjs +29 -0
- package/dist/cjs/entities/app-details.cjs +39 -0
- package/dist/cjs/entities/app-event-subscription.cjs +34 -0
- package/dist/cjs/entities/app-installation.cjs +55 -0
- package/dist/cjs/entities/app-key.cjs +44 -0
- package/dist/cjs/entities/app-signed-request.cjs +17 -0
- package/dist/cjs/entities/app-signing-secret.cjs +34 -0
- package/dist/cjs/entities/app-upload.cjs +47 -0
- package/dist/cjs/entities/asset-key.cjs +17 -0
- package/dist/cjs/entities/asset.cjs +124 -0
- package/dist/cjs/entities/bulk-action.cjs +60 -0
- package/dist/cjs/entities/comment.cjs +63 -0
- package/dist/cjs/entities/concept-scheme.cjs +2 -0
- package/dist/cjs/entities/concept.cjs +2 -0
- package/dist/cjs/entities/content-type.cjs +120 -0
- package/dist/cjs/entities/editor-interface.cjs +50 -0
- package/dist/cjs/entities/entry.cjs +27 -0
- package/dist/cjs/entities/environment-alias.cjs +58 -0
- package/dist/cjs/entities/environment-template-installation.cjs +23 -0
- package/dist/cjs/entities/environment-template.cjs +18 -0
- package/dist/cjs/entities/environment.cjs +34 -0
- package/dist/cjs/entities/extension.cjs +54 -0
- package/dist/cjs/entities/function-log.cjs +26 -0
- package/dist/cjs/entities/function.cjs +66 -0
- package/dist/cjs/entities/index.cjs +131 -0
- package/dist/cjs/entities/locale.cjs +57 -0
- package/dist/cjs/entities/oauth-application.cjs +66 -0
- package/dist/cjs/entities/organization-invitation.cjs +17 -0
- package/dist/cjs/entities/organization-membership.cjs +53 -0
- package/dist/cjs/entities/organization.cjs +32 -0
- package/dist/cjs/entities/personal-access-token.cjs +36 -0
- package/dist/cjs/entities/preview-api-key.cjs +31 -0
- package/dist/cjs/entities/release-action.cjs +55 -0
- package/dist/cjs/entities/release.cjs +111 -0
- package/dist/cjs/entities/resource-provider.cjs +139 -0
- package/dist/cjs/entities/resource-type.cjs +98 -0
- package/dist/cjs/entities/resource.cjs +13 -0
- package/dist/cjs/entities/role.cjs +53 -0
- package/dist/cjs/entities/scheduled-action.cjs +154 -0
- package/dist/cjs/entities/snapshot.cjs +36 -0
- package/dist/cjs/entities/space-member.cjs +23 -0
- package/dist/cjs/entities/space-membership.cjs +53 -0
- package/dist/cjs/entities/space.cjs +33 -0
- package/dist/cjs/entities/tag.cjs +56 -0
- package/dist/cjs/entities/task.cjs +57 -0
- package/dist/cjs/entities/team-membership.cjs +54 -0
- package/dist/cjs/entities/team-space-membership.cjs +53 -0
- package/dist/cjs/entities/team.cjs +53 -0
- package/dist/cjs/entities/ui-config.cjs +20 -0
- package/dist/cjs/entities/upload.cjs +38 -0
- package/dist/cjs/entities/usage.cjs +25 -0
- package/dist/cjs/entities/user-ui-config.cjs +20 -0
- package/dist/cjs/entities/user.cjs +28 -0
- package/dist/cjs/entities/webhook.cjs +77 -0
- package/dist/cjs/entities/workflow-definition.cjs +79 -0
- package/dist/cjs/index.cjs +65 -0
- package/dist/cjs/methods/action.cjs +53 -0
- package/dist/cjs/methods/content-type.cjs +51 -0
- package/dist/cjs/methods/utils.cjs +11 -0
- package/dist/cjs/plain/as-iterator.cjs +32 -0
- package/dist/cjs/plain/checks.cjs +15 -0
- package/dist/cjs/plain/pagination-helper.cjs +56 -0
- package/dist/cjs/plain/plain-client.cjs +516 -0
- package/dist/cjs/plain/wrappers/wrap.cjs +26 -0
- package/dist/cjs/upload-http-client.cjs +17 -0
- package/dist/contentful-management.browser.js +50 -34
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.cjs +35 -19
- package/dist/esm/create-contentful-api.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/plain/plain-client.js +1 -1
- package/dist/stats-browser-min.html +1 -1
- package/package.json +6 -6
- package/types.d.ts +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
4
|
+
var copy = require('fast-copy');
|
|
5
|
+
var commonUtils = require('../common-utils.js');
|
|
6
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
function createPreviewApiKeyApi() {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
* @param makeRequest - function to make requests via an adapter
|
|
17
|
+
* @param data - Raw api key data
|
|
18
|
+
* @return Wrapped preview api key data
|
|
19
|
+
*/
|
|
20
|
+
function wrapPreviewApiKey(_makeRequest, data) {
|
|
21
|
+
const previewApiKey = contentfulSdkCore.toPlainObject(copy(data));
|
|
22
|
+
const previewApiKeyWithMethods = enhanceWithMethods(previewApiKey, createPreviewApiKeyApi());
|
|
23
|
+
return contentfulSdkCore.freezeSys(previewApiKeyWithMethods);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
const wrapPreviewApiKeyCollection = commonUtils.wrapCollection(wrapPreviewApiKey);
|
|
29
|
+
|
|
30
|
+
exports.wrapPreviewApiKey = wrapPreviewApiKey;
|
|
31
|
+
exports.wrapPreviewApiKeyCollection = wrapPreviewApiKeyCollection;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
4
|
+
var copy = require('fast-copy');
|
|
5
|
+
var commonUtils = require('../common-utils.js');
|
|
6
|
+
var action = require('../methods/action.js');
|
|
7
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
8
|
+
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
function createReleaseActionApi(makeRequest) {
|
|
14
|
+
const getParams = (self) => {
|
|
15
|
+
const action = self.toPlainObject();
|
|
16
|
+
return {
|
|
17
|
+
spaceId: action.sys.space.sys.id,
|
|
18
|
+
environmentId: action.sys.environment.sys.id,
|
|
19
|
+
releaseId: action.sys.release.sys.id,
|
|
20
|
+
actionId: action.sys.id,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
async get() {
|
|
25
|
+
const params = getParams(this);
|
|
26
|
+
return makeRequest({
|
|
27
|
+
entityType: 'ReleaseAction',
|
|
28
|
+
action: 'get',
|
|
29
|
+
params,
|
|
30
|
+
}).then((releaseAction) => wrapReleaseAction(makeRequest, releaseAction));
|
|
31
|
+
},
|
|
32
|
+
/** Waits for a Release Action to complete */
|
|
33
|
+
async waitProcessing(options) {
|
|
34
|
+
return action.pollAsyncActionStatus(async () => this.get(), options);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
* @param makeRequest - function to make requests via an adapter
|
|
41
|
+
* @param data - Raw Release data
|
|
42
|
+
* @return Wrapped Release data
|
|
43
|
+
*/
|
|
44
|
+
function wrapReleaseAction(makeRequest, data) {
|
|
45
|
+
const releaseAction = contentfulSdkCore.toPlainObject(copy(data));
|
|
46
|
+
const releaseActionWithApiMethods = enhanceWithMethods(releaseAction, createReleaseActionApi(makeRequest));
|
|
47
|
+
return contentfulSdkCore.freezeSys(releaseActionWithApiMethods);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
const wrapReleaseActionCollection = commonUtils.wrapCollection(wrapReleaseAction);
|
|
53
|
+
|
|
54
|
+
exports.wrapReleaseAction = wrapReleaseAction;
|
|
55
|
+
exports.wrapReleaseActionCollection = wrapReleaseActionCollection;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
4
|
+
var copy = require('fast-copy');
|
|
5
|
+
var commonTypes = require('../common-types.js');
|
|
6
|
+
var commonUtils = require('../common-utils.js');
|
|
7
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
8
|
+
var releaseAction = require('./release-action.js');
|
|
9
|
+
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
const ReleaseReferenceFilters = commonTypes.ScheduledActionReferenceFilters;
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
function createReleaseApi(makeRequest) {
|
|
16
|
+
const getParams = (self) => {
|
|
17
|
+
const release = self.toPlainObject();
|
|
18
|
+
return {
|
|
19
|
+
spaceId: release.sys.space.sys.id,
|
|
20
|
+
environmentId: release.sys.environment.sys.id,
|
|
21
|
+
releaseId: release.sys.id,
|
|
22
|
+
version: release.sys.version,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
async archive() {
|
|
27
|
+
const params = getParams(this);
|
|
28
|
+
return makeRequest({
|
|
29
|
+
entityType: 'Release',
|
|
30
|
+
action: 'archive',
|
|
31
|
+
params,
|
|
32
|
+
}).then((release) => wrapRelease(makeRequest, release));
|
|
33
|
+
},
|
|
34
|
+
async unarchive() {
|
|
35
|
+
const params = getParams(this);
|
|
36
|
+
return makeRequest({
|
|
37
|
+
entityType: 'Release',
|
|
38
|
+
action: 'unarchive',
|
|
39
|
+
params,
|
|
40
|
+
}).then((release) => wrapRelease(makeRequest, release));
|
|
41
|
+
},
|
|
42
|
+
async update(payload) {
|
|
43
|
+
const params = getParams(this);
|
|
44
|
+
return makeRequest({
|
|
45
|
+
entityType: 'Release',
|
|
46
|
+
action: 'update',
|
|
47
|
+
params,
|
|
48
|
+
payload,
|
|
49
|
+
}).then((release) => wrapRelease(makeRequest, release));
|
|
50
|
+
},
|
|
51
|
+
async delete() {
|
|
52
|
+
const params = getParams(this);
|
|
53
|
+
await makeRequest({
|
|
54
|
+
entityType: 'Release',
|
|
55
|
+
action: 'delete',
|
|
56
|
+
params,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
async publish(options) {
|
|
60
|
+
const params = getParams(this);
|
|
61
|
+
return makeRequest({
|
|
62
|
+
entityType: 'Release',
|
|
63
|
+
action: 'publish',
|
|
64
|
+
params,
|
|
65
|
+
})
|
|
66
|
+
.then((data) => releaseAction.wrapReleaseAction(makeRequest, data))
|
|
67
|
+
.then((action) => action.waitProcessing(options));
|
|
68
|
+
},
|
|
69
|
+
async unpublish(options) {
|
|
70
|
+
const params = getParams(this);
|
|
71
|
+
return makeRequest({
|
|
72
|
+
entityType: 'Release',
|
|
73
|
+
action: 'unpublish',
|
|
74
|
+
params,
|
|
75
|
+
})
|
|
76
|
+
.then((data) => releaseAction.wrapReleaseAction(makeRequest, data))
|
|
77
|
+
.then((action) => action.waitProcessing(options));
|
|
78
|
+
},
|
|
79
|
+
async validate(options) {
|
|
80
|
+
const params = getParams(this);
|
|
81
|
+
return makeRequest({
|
|
82
|
+
entityType: 'Release',
|
|
83
|
+
action: 'validate',
|
|
84
|
+
params,
|
|
85
|
+
payload: options === null || options === void 0 ? void 0 : options.payload,
|
|
86
|
+
})
|
|
87
|
+
.then((data) => releaseAction.wrapReleaseAction(makeRequest, data))
|
|
88
|
+
.then((action) => action.waitProcessing(options === null || options === void 0 ? void 0 : options.processingOptions));
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Return a Release object enhanced with its own API helper functions.
|
|
94
|
+
* @private
|
|
95
|
+
* @param makeRequest - function to make requests via an adapter
|
|
96
|
+
* @param data - Raw Release data
|
|
97
|
+
* @return Wrapped Release data
|
|
98
|
+
*/
|
|
99
|
+
function wrapRelease(makeRequest, data) {
|
|
100
|
+
const release = contentfulSdkCore.toPlainObject(copy(data));
|
|
101
|
+
const releaseWithApiMethods = enhanceWithMethods(release, createReleaseApi(makeRequest));
|
|
102
|
+
return contentfulSdkCore.freezeSys(releaseWithApiMethods);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
const wrapReleaseCollection = commonUtils.wrapCursorPaginatedCollection(wrapRelease);
|
|
108
|
+
|
|
109
|
+
exports.ReleaseReferenceFilters = ReleaseReferenceFilters;
|
|
110
|
+
exports.wrapRelease = wrapRelease;
|
|
111
|
+
exports.wrapReleaseCollection = wrapReleaseCollection;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
4
|
+
var copy = require('fast-copy');
|
|
5
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
6
|
+
var index = require('./index.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
function createResourceProviderApi(makeRequest) {
|
|
12
|
+
const { wrapResourceType } = index.resourceType;
|
|
13
|
+
return {
|
|
14
|
+
/**
|
|
15
|
+
* Sends an update to the server with any changes made to the object's properties
|
|
16
|
+
* @return Object returned from the server with updated changes.
|
|
17
|
+
* @example ```javascript
|
|
18
|
+
* const contentful = require('contentful-management')
|
|
19
|
+
*
|
|
20
|
+
* const client = contentful.createClient({
|
|
21
|
+
* accessToken: '<content_management_api_key>'
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* client.getOrganization('<org_id>')
|
|
25
|
+
* .then((org) => org.getAppDefinition('<app_def_id>'))
|
|
26
|
+
* .then((appDefinition) => appDefinition.getResourceProvider())
|
|
27
|
+
* .then((resourceProvider) => {
|
|
28
|
+
* resourceProvider.function.sys.id = '<new_contentful_function_id>'
|
|
29
|
+
* return resourceProvider.upsert()
|
|
30
|
+
* })
|
|
31
|
+
* .catch(console.error)
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
upsert: function upsert() {
|
|
35
|
+
const data = this.toPlainObject();
|
|
36
|
+
return makeRequest({
|
|
37
|
+
entityType: 'ResourceProvider',
|
|
38
|
+
action: 'upsert',
|
|
39
|
+
params: getParams(data),
|
|
40
|
+
headers: {},
|
|
41
|
+
payload: getUpsertParams(data),
|
|
42
|
+
}).then((data) => wrapResourceProvider(makeRequest, data));
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Deletes this object on the server.
|
|
46
|
+
* @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
|
|
47
|
+
* @example ```javascript
|
|
48
|
+
* const contentful = require('contentful-management')
|
|
49
|
+
*
|
|
50
|
+
* const client = contentful.createClient({
|
|
51
|
+
* accessToken: '<content_management_api_key>'
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* client.getOrganization('<org_id>')
|
|
55
|
+
* .then((org) => org.getAppDefinition('<app_def_id>'))
|
|
56
|
+
* .then((appDefinition) => appDefinition.getResourceProvider())
|
|
57
|
+
* .then((resourceProvider) => resourceProvider.delete())
|
|
58
|
+
* .catch(console.error)
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
delete: function del() {
|
|
62
|
+
const data = this.toPlainObject();
|
|
63
|
+
return makeRequest({
|
|
64
|
+
entityType: 'ResourceProvider',
|
|
65
|
+
action: 'delete',
|
|
66
|
+
params: getParams(data),
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
getResourceType: function getResourceType(id) {
|
|
70
|
+
return makeRequest({
|
|
71
|
+
entityType: 'ResourceType',
|
|
72
|
+
action: 'get',
|
|
73
|
+
params: {
|
|
74
|
+
organizationId: this.sys.organization.sys.id,
|
|
75
|
+
appDefinitionId: this.sys.appDefinition.sys.id,
|
|
76
|
+
resourceTypeId: id,
|
|
77
|
+
},
|
|
78
|
+
}).then((data) => wrapResourceType(makeRequest, data));
|
|
79
|
+
},
|
|
80
|
+
upsertResourceType: function upsertResourceType(id, data) {
|
|
81
|
+
return makeRequest({
|
|
82
|
+
entityType: 'ResourceType',
|
|
83
|
+
action: 'upsert',
|
|
84
|
+
params: {
|
|
85
|
+
organizationId: this.sys.organization.sys.id,
|
|
86
|
+
appDefinitionId: this.sys.appDefinition.sys.id,
|
|
87
|
+
resourceTypeId: id,
|
|
88
|
+
},
|
|
89
|
+
headers: {},
|
|
90
|
+
payload: data,
|
|
91
|
+
}).then((data) => wrapResourceType(makeRequest, data));
|
|
92
|
+
},
|
|
93
|
+
getResourceTypes: function getResourceTypes() {
|
|
94
|
+
return makeRequest({
|
|
95
|
+
entityType: 'ResourceType',
|
|
96
|
+
action: 'getMany',
|
|
97
|
+
params: {
|
|
98
|
+
organizationId: this.sys.organization.sys.id,
|
|
99
|
+
appDefinitionId: this.sys.appDefinition.sys.id,
|
|
100
|
+
},
|
|
101
|
+
}).then((data) => {
|
|
102
|
+
data.items = data.items.map((item) => wrapResourceType(makeRequest, item));
|
|
103
|
+
return data;
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @private
|
|
110
|
+
* @param data - raw ResourceProvider Object
|
|
111
|
+
* @return Object containing the http params for the ResourceProvider request: organizationId and appDefinitionId
|
|
112
|
+
*/
|
|
113
|
+
const getParams = (data) => ({
|
|
114
|
+
organizationId: data.sys.organization.sys.id,
|
|
115
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* @private
|
|
119
|
+
* @param data - raw ResourceProvider Object
|
|
120
|
+
* @return UpsertResourceProviderProps
|
|
121
|
+
*/
|
|
122
|
+
const getUpsertParams = (data) => ({
|
|
123
|
+
sys: { id: data.sys.id },
|
|
124
|
+
type: data.type,
|
|
125
|
+
function: data.function,
|
|
126
|
+
});
|
|
127
|
+
/**
|
|
128
|
+
* @private
|
|
129
|
+
* @param makeRequest - function to make requests via an adapter
|
|
130
|
+
* @param data - Raw Resource Provider data
|
|
131
|
+
* @return Wrapped Resource Provider data
|
|
132
|
+
*/
|
|
133
|
+
function wrapResourceProvider(makeRequest, data) {
|
|
134
|
+
const resourceProvider = contentfulSdkCore.toPlainObject(copy(data));
|
|
135
|
+
const ResourceProviderWithMethods = enhanceWithMethods(resourceProvider, createResourceProviderApi(makeRequest));
|
|
136
|
+
return contentfulSdkCore.freezeSys(ResourceProviderWithMethods);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
exports.wrapResourceProvider = wrapResourceProvider;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
4
|
+
var copy = require('fast-copy');
|
|
5
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
6
|
+
var commonUtils = require('../common-utils.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
function createResourceTypeApi(makeRequest) {
|
|
12
|
+
return {
|
|
13
|
+
/**
|
|
14
|
+
* Sends an update to the server with any changes made to the object's properties
|
|
15
|
+
* @return Object returned from the server with updated changes.
|
|
16
|
+
* @example ```javascript
|
|
17
|
+
* const contentful = require('contentful-management')
|
|
18
|
+
*
|
|
19
|
+
* const client = contentful.createClient({
|
|
20
|
+
* accessToken: '<content_management_api_key>'
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* client.getOrganization('<org_id>')
|
|
24
|
+
* .then((org) => org.getAppDefinition('<app_def_id>'))
|
|
25
|
+
* .then((appDefinition) => appDefinition.getResourceType())
|
|
26
|
+
* .then((resourceType) => {
|
|
27
|
+
* resourceType.name = '<new_name>'
|
|
28
|
+
* return resourceType.upsert()
|
|
29
|
+
* })
|
|
30
|
+
* .catch(console.error)
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
upsert: function upsert() {
|
|
34
|
+
const data = this.toPlainObject();
|
|
35
|
+
return makeRequest({
|
|
36
|
+
entityType: 'ResourceType',
|
|
37
|
+
action: 'upsert',
|
|
38
|
+
params: getParams(data),
|
|
39
|
+
headers: {},
|
|
40
|
+
payload: getUpsertParams(data),
|
|
41
|
+
}).then((data) => wrapResourceType(makeRequest, data));
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Deletes this object on the server.
|
|
45
|
+
* @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
|
|
46
|
+
* @example ```javascript
|
|
47
|
+
* const contentful = require('contentful-management')
|
|
48
|
+
*
|
|
49
|
+
* const client = contentful.createClient({
|
|
50
|
+
* accessToken: '<content_management_api_key>'
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* client.getOrganization('<org_id>')
|
|
54
|
+
* .then((org) => org.getAppDefinition('<app_def_id>'))
|
|
55
|
+
* .then((appDefinition) => appDefinition.getResourceType())
|
|
56
|
+
* .then((resourceType) => resourceType.delete())
|
|
57
|
+
* .catch(console.error)
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
delete: function del() {
|
|
61
|
+
const data = this.toPlainObject();
|
|
62
|
+
return makeRequest({
|
|
63
|
+
entityType: 'ResourceType',
|
|
64
|
+
action: 'delete',
|
|
65
|
+
params: getParams(data),
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const getParams = (data) => ({
|
|
71
|
+
organizationId: data.sys.organization.sys.id,
|
|
72
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
73
|
+
resourceTypeId: data.sys.id,
|
|
74
|
+
});
|
|
75
|
+
const getUpsertParams = (data) => ({
|
|
76
|
+
name: data.name,
|
|
77
|
+
defaultFieldMapping: data.defaultFieldMapping,
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* @private
|
|
81
|
+
* @param makeRequest - function to make requests via an adapter
|
|
82
|
+
* @param data - Raw Resource Type data
|
|
83
|
+
* @return Wrapped Resource Type data
|
|
84
|
+
*/
|
|
85
|
+
function wrapResourceType(makeRequest, data) {
|
|
86
|
+
const resourceType = contentfulSdkCore.toPlainObject(copy(data));
|
|
87
|
+
const ResourceTypeWithMethods = enhanceWithMethods(resourceType, createResourceTypeApi(makeRequest));
|
|
88
|
+
return contentfulSdkCore.freezeSys(ResourceTypeWithMethods);
|
|
89
|
+
}
|
|
90
|
+
function wrapResourceTypeforEnvironment(makeRequest, data) {
|
|
91
|
+
const resourceType = contentfulSdkCore.toPlainObject(data);
|
|
92
|
+
return contentfulSdkCore.freezeSys(resourceType);
|
|
93
|
+
}
|
|
94
|
+
const wrapResourceTypesForEnvironmentCollection = commonUtils.wrapCursorPaginatedCollection(wrapResourceTypeforEnvironment);
|
|
95
|
+
|
|
96
|
+
exports.wrapResourceType = wrapResourceType;
|
|
97
|
+
exports.wrapResourceTypeforEnvironment = wrapResourceTypeforEnvironment;
|
|
98
|
+
exports.wrapResourceTypesForEnvironmentCollection = wrapResourceTypesForEnvironmentCollection;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commonUtils = require('../common-utils.js');
|
|
4
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
5
|
+
|
|
6
|
+
function wrapResource(makeRequest, data) {
|
|
7
|
+
const resource = contentfulSdkCore.toPlainObject(data);
|
|
8
|
+
return contentfulSdkCore.freezeSys(resource);
|
|
9
|
+
}
|
|
10
|
+
const wrapResourceCollection = commonUtils.wrapCursorPaginatedCollection(wrapResource);
|
|
11
|
+
|
|
12
|
+
exports.wrapResource = wrapResource;
|
|
13
|
+
exports.wrapResourceCollection = wrapResourceCollection;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copy = require('fast-copy');
|
|
4
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
5
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
6
|
+
var commonUtils = require('../common-utils.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
function createRoleApi(makeRequest) {
|
|
12
|
+
const getParams = (data) => ({
|
|
13
|
+
spaceId: data.sys.space.sys.id,
|
|
14
|
+
roleId: data.sys.id,
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
update: function update() {
|
|
18
|
+
const data = this.toPlainObject();
|
|
19
|
+
return makeRequest({
|
|
20
|
+
entityType: 'Role',
|
|
21
|
+
action: 'update',
|
|
22
|
+
params: getParams(data),
|
|
23
|
+
payload: data,
|
|
24
|
+
}).then((data) => wrapRole(makeRequest, data));
|
|
25
|
+
},
|
|
26
|
+
delete: function del() {
|
|
27
|
+
const data = this.toPlainObject();
|
|
28
|
+
return makeRequest({
|
|
29
|
+
entityType: 'Role',
|
|
30
|
+
action: 'delete',
|
|
31
|
+
params: getParams(data),
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @private
|
|
38
|
+
* @param makeRequest - function to make requests via an adapter
|
|
39
|
+
* @param data - Raw role data
|
|
40
|
+
* @return Wrapped role data
|
|
41
|
+
*/
|
|
42
|
+
function wrapRole(makeRequest, data) {
|
|
43
|
+
const role = contentfulSdkCore.toPlainObject(copy(data));
|
|
44
|
+
const roleWithMethods = enhanceWithMethods(role, createRoleApi(makeRequest));
|
|
45
|
+
return contentfulSdkCore.freezeSys(roleWithMethods);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
const wrapRoleCollection = commonUtils.wrapCollection(wrapRole);
|
|
51
|
+
|
|
52
|
+
exports.wrapRole = wrapRole;
|
|
53
|
+
exports.wrapRoleCollection = wrapRoleCollection;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
7
|
+
var copy = require('fast-copy');
|
|
8
|
+
var commonUtils = require('../common-utils.js');
|
|
9
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents that state of the scheduled action
|
|
13
|
+
*/
|
|
14
|
+
exports.ScheduledActionStatus = void 0;
|
|
15
|
+
(function (ScheduledActionStatus) {
|
|
16
|
+
/** action is pending execution */
|
|
17
|
+
ScheduledActionStatus["scheduled"] = "scheduled";
|
|
18
|
+
/** action has been started and pending completion */
|
|
19
|
+
ScheduledActionStatus["inProgress"] = "inProgress";
|
|
20
|
+
/** action was completed successfully (terminal state) */
|
|
21
|
+
ScheduledActionStatus["succeeded"] = "succeeded";
|
|
22
|
+
/** action failed to complete (terminal state) */
|
|
23
|
+
ScheduledActionStatus["failed"] = "failed";
|
|
24
|
+
/** action was canceled by a user (terminal state) */
|
|
25
|
+
ScheduledActionStatus["canceled"] = "canceled";
|
|
26
|
+
})(exports.ScheduledActionStatus || (exports.ScheduledActionStatus = {}));
|
|
27
|
+
function getInstanceMethods(makeRequest) {
|
|
28
|
+
const getParams = (self) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const scheduledAction = self.toPlainObject();
|
|
31
|
+
return {
|
|
32
|
+
spaceId: scheduledAction.sys.space.sys.id,
|
|
33
|
+
environmentId: (_a = scheduledAction.environment) === null || _a === void 0 ? void 0 : _a.sys.id,
|
|
34
|
+
scheduledActionId: scheduledAction.sys.id,
|
|
35
|
+
version: scheduledAction.sys.version,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
/**
|
|
40
|
+
* Cancels the current Scheduled Action schedule.
|
|
41
|
+
*
|
|
42
|
+
* @example ```javascript
|
|
43
|
+
* const contentful = require('contentful-management');
|
|
44
|
+
*
|
|
45
|
+
* const client = contentful.createClient({
|
|
46
|
+
* accessToken: '<content_management_api_key>'
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* client.getSpace('<space_id>')
|
|
50
|
+
* .then((space) => {
|
|
51
|
+
* return space.createScheduledAction({
|
|
52
|
+
* entity: {
|
|
53
|
+
* sys: {
|
|
54
|
+
* type: 'Link',
|
|
55
|
+
* linkType: 'Entry',
|
|
56
|
+
* id: '<entry_id>'
|
|
57
|
+
* }
|
|
58
|
+
* },
|
|
59
|
+
* environment: {
|
|
60
|
+
* sys: {
|
|
61
|
+
* type: 'Link',
|
|
62
|
+
* linkType: 'Environment',
|
|
63
|
+
* id: '<environment_id>'
|
|
64
|
+
* }
|
|
65
|
+
* },
|
|
66
|
+
* action: 'publish',
|
|
67
|
+
* scheduledFor: {
|
|
68
|
+
* datetime: <ISO_date_string>,
|
|
69
|
+
* timezone: 'Europe/Berlin'
|
|
70
|
+
* }
|
|
71
|
+
* })
|
|
72
|
+
* .then((scheduledAction) => scheduledAction.delete())
|
|
73
|
+
* .then((deletedScheduledAction) => console.log(deletedScheduledAction))
|
|
74
|
+
* .catch(console.error);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async delete() {
|
|
78
|
+
const params = getParams(this);
|
|
79
|
+
return makeRequest({
|
|
80
|
+
entityType: 'ScheduledAction',
|
|
81
|
+
action: 'delete',
|
|
82
|
+
params,
|
|
83
|
+
}).then((data) => wrapScheduledAction(makeRequest, data));
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* Update the current scheduled action. Currently, only changes made to the `scheduledFor` property will be saved.
|
|
87
|
+
*
|
|
88
|
+
* @example ```javascript
|
|
89
|
+
* const contentful = require('contentful-management');
|
|
90
|
+
*
|
|
91
|
+
* const client = contentful.createClient({
|
|
92
|
+
* accessToken: '<content_management_api_key>'
|
|
93
|
+
* })
|
|
94
|
+
*
|
|
95
|
+
* client.getSpace('<space_id>')
|
|
96
|
+
* .then((space) => {
|
|
97
|
+
* return space.createScheduledAction({
|
|
98
|
+
* entity: {
|
|
99
|
+
* sys: {
|
|
100
|
+
* type: 'Link',
|
|
101
|
+
* linkType: 'Entry',
|
|
102
|
+
* id: '<entry_id>'
|
|
103
|
+
* }
|
|
104
|
+
* },
|
|
105
|
+
* environment: {
|
|
106
|
+
* sys: {
|
|
107
|
+
* type: 'Link',
|
|
108
|
+
* linkType: 'Environment',
|
|
109
|
+
* id: '<environment_id>'
|
|
110
|
+
* }
|
|
111
|
+
* },
|
|
112
|
+
* action: 'publish',
|
|
113
|
+
* scheduledFor: {
|
|
114
|
+
* datetime: <ISO_date_string>,
|
|
115
|
+
* timezone: 'Europe/Berlin'
|
|
116
|
+
* }
|
|
117
|
+
* })
|
|
118
|
+
* .then((scheduledAction) => {
|
|
119
|
+
* scheduledAction.scheduledFor.timezone = 'Europe/Paris';
|
|
120
|
+
* return scheduledAction.update();
|
|
121
|
+
* })
|
|
122
|
+
* .then((scheduledAction) => console.log(scheduledAction))
|
|
123
|
+
* .catch(console.error);
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
async update() {
|
|
127
|
+
const params = getParams(this);
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
129
|
+
const _a = this.toPlainObject(), payload = tslib.__rest(_a, ["sys"]);
|
|
130
|
+
return makeRequest({
|
|
131
|
+
entityType: 'ScheduledAction',
|
|
132
|
+
action: 'update',
|
|
133
|
+
params,
|
|
134
|
+
payload,
|
|
135
|
+
}).then((data) => wrapScheduledAction(makeRequest, data));
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
function wrapScheduledAction(makeRequest, data) {
|
|
143
|
+
const scheduledAction = contentfulSdkCore.toPlainObject(copy(data));
|
|
144
|
+
const scheduledActionWithMethods = enhanceWithMethods(scheduledAction, getInstanceMethods(makeRequest));
|
|
145
|
+
return contentfulSdkCore.freezeSys(scheduledActionWithMethods);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
const wrapScheduledActionCollection = commonUtils.wrapCollection(wrapScheduledAction);
|
|
151
|
+
|
|
152
|
+
exports.default = getInstanceMethods;
|
|
153
|
+
exports.wrapScheduledAction = wrapScheduledAction;
|
|
154
|
+
exports.wrapScheduledActionCollection = wrapScheduledActionCollection;
|