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,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./entities/index.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
function createUIConfigApi(makeRequest) {
|
|
9
|
+
const { wrapUIConfig } = index.uiConfig;
|
|
10
|
+
const getParams = (self) => {
|
|
11
|
+
const uiConfig = self.toPlainObject();
|
|
12
|
+
return {
|
|
13
|
+
params: {
|
|
14
|
+
spaceId: uiConfig.sys.space.sys.id,
|
|
15
|
+
environmentId: uiConfig.sys.environment.sys.id,
|
|
16
|
+
},
|
|
17
|
+
raw: uiConfig,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
/**
|
|
22
|
+
* Sends an update to the server with any changes made to the object's properties
|
|
23
|
+
* @return Object returned from the server with updated changes.
|
|
24
|
+
* @example ```javascript
|
|
25
|
+
* const contentful = require('contentful-management')
|
|
26
|
+
*
|
|
27
|
+
* const client = contentful.createClient({
|
|
28
|
+
* accessToken: '<content_management_api_key>'
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* client.getSpace('<space_id>')
|
|
32
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
33
|
+
* .then((environment) => environment.getUIConfig())
|
|
34
|
+
* .then((uiConfig) => {
|
|
35
|
+
* uiConfig.entryListViews = [...]
|
|
36
|
+
* return uiConfig.update()
|
|
37
|
+
* })
|
|
38
|
+
* .then((uiConfig) => console.log(`UIConfig updated.`))
|
|
39
|
+
* .catch(console.error)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
update: async function update() {
|
|
43
|
+
const { raw, params } = getParams(this);
|
|
44
|
+
const data = await makeRequest({
|
|
45
|
+
entityType: 'UIConfig',
|
|
46
|
+
action: 'update',
|
|
47
|
+
params,
|
|
48
|
+
payload: raw,
|
|
49
|
+
});
|
|
50
|
+
return wrapUIConfig(makeRequest, data);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = createUIConfigApi;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./entities/index.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
function createUserUIConfigApi(makeRequest) {
|
|
9
|
+
const { wrapUserUIConfig } = index.userUIConfig;
|
|
10
|
+
const getParams = (self) => {
|
|
11
|
+
const userUIConfig = self.toPlainObject();
|
|
12
|
+
return {
|
|
13
|
+
params: {
|
|
14
|
+
spaceId: userUIConfig.sys.space.sys.id,
|
|
15
|
+
environmentId: userUIConfig.sys.environment.sys.id,
|
|
16
|
+
},
|
|
17
|
+
raw: userUIConfig,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
/**
|
|
22
|
+
* Sends an update to the server with any changes made to the object's properties
|
|
23
|
+
* @return Object returned from the server with updated changes.
|
|
24
|
+
* @example ```javascript
|
|
25
|
+
* const contentful = require('contentful-management')
|
|
26
|
+
*
|
|
27
|
+
* const client = contentful.createClient({
|
|
28
|
+
* accessToken: '<content_management_api_key>'
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* client.getSpace('<space_id>')
|
|
32
|
+
* .then((space) => space.getEnvironment('<environment_id>'))
|
|
33
|
+
* .then((environment) => environment.getUserUIConfig())
|
|
34
|
+
* .then((uiConfig) => {
|
|
35
|
+
* uiConfig.entryListViews = [...]
|
|
36
|
+
* return uiConfig.update()
|
|
37
|
+
* })
|
|
38
|
+
* .then((uiConfig) => console.log(`UserUIConfig updated.`))
|
|
39
|
+
* .catch(console.error)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
update: async function update() {
|
|
43
|
+
const { raw, params } = getParams(this);
|
|
44
|
+
const data = await makeRequest({
|
|
45
|
+
entityType: 'UserUIConfig',
|
|
46
|
+
action: 'update',
|
|
47
|
+
params,
|
|
48
|
+
payload: raw,
|
|
49
|
+
});
|
|
50
|
+
return wrapUserUIConfig(makeRequest, data);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = createUserUIConfigApi;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This method enhances a base object which would normally contain data, with
|
|
5
|
+
* methods from another object that might work on manipulating that data.
|
|
6
|
+
* All the added methods are set as non enumerable, non configurable, and non
|
|
7
|
+
* writable properties. This ensures that if we try to clone or stringify the
|
|
8
|
+
* base object, we don't have to worry about these additional methods.
|
|
9
|
+
* @private
|
|
10
|
+
* @param {object} baseObject - Base object with data
|
|
11
|
+
* @param {object} methodsObject - Object with methods as properties. The key
|
|
12
|
+
* values used here will be the same that will be defined on the baseObject.
|
|
13
|
+
*/
|
|
14
|
+
function enhanceWithMethods(baseObject, methodsObject) {
|
|
15
|
+
return Object.keys(methodsObject).reduce((enhancedObject, methodName) => {
|
|
16
|
+
Object.defineProperty(enhancedObject, methodName, {
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: false,
|
|
20
|
+
value: methodsObject[methodName],
|
|
21
|
+
});
|
|
22
|
+
return enhancedObject;
|
|
23
|
+
}, baseObject);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = enhanceWithMethods;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
* @param makeRequest - function to make requests via an adapter
|
|
11
|
+
* @param data - Raw access token data
|
|
12
|
+
* @return Wrapped access token
|
|
13
|
+
*/
|
|
14
|
+
function wrapAccessToken(makeRequest, data) {
|
|
15
|
+
const AccessToken = contentfulSdkCore.toPlainObject(copy(data));
|
|
16
|
+
const accessTokenWithMethods = enhanceWithMethods(AccessToken, {
|
|
17
|
+
revoke: function () {
|
|
18
|
+
return makeRequest({
|
|
19
|
+
entityType: 'AccessToken',
|
|
20
|
+
action: 'revoke',
|
|
21
|
+
params: { tokenId: data.sys.id },
|
|
22
|
+
}).then((data) => wrapAccessToken(makeRequest, data));
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return contentfulSdkCore.freezeSys(accessTokenWithMethods);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
* @param makeRequest - function to make requests via an adapter
|
|
30
|
+
* @param data - Raw access collection data
|
|
31
|
+
* @return Wrapped access token collection data
|
|
32
|
+
*/
|
|
33
|
+
const wrapAccessTokenCollection = commonUtils.wrapCollection(wrapAccessToken);
|
|
34
|
+
|
|
35
|
+
exports.wrapAccessToken = wrapAccessToken;
|
|
36
|
+
exports.wrapAccessTokenCollection = wrapAccessTokenCollection;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
|
|
7
|
+
exports.InvocationStatus = void 0;
|
|
8
|
+
(function (InvocationStatus) {
|
|
9
|
+
InvocationStatus["Scheduled"] = "SCHEDULED";
|
|
10
|
+
InvocationStatus["InProgress"] = "IN_PROGRESS";
|
|
11
|
+
InvocationStatus["Failed"] = "FAILED";
|
|
12
|
+
InvocationStatus["Completed"] = "COMPLETED";
|
|
13
|
+
InvocationStatus["Cancelled"] = "CANCELLED";
|
|
14
|
+
})(exports.InvocationStatus || (exports.InvocationStatus = {}));
|
|
15
|
+
exports.InvocationResultType = void 0;
|
|
16
|
+
(function (InvocationResultType) {
|
|
17
|
+
InvocationResultType["Text"] = "text";
|
|
18
|
+
})(exports.InvocationResultType || (exports.InvocationResultType = {}));
|
|
19
|
+
const AiActionOutputFormat = {
|
|
20
|
+
RichText: 'RichText',
|
|
21
|
+
Markdown: 'Markdown',
|
|
22
|
+
PlainText: 'PlainText',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Wraps raw AI Action Invocation data with SDK helper methods.
|
|
26
|
+
*
|
|
27
|
+
* @param makeRequest - Function to make API requests.
|
|
28
|
+
* @param data - Raw AI Action Invocation data.
|
|
29
|
+
* @returns The AI Action Invocation entity.
|
|
30
|
+
*/
|
|
31
|
+
function wrapAiActionInvocation(makeRequest, data) {
|
|
32
|
+
const invocation = contentfulSdkCore.toPlainObject(copy(data));
|
|
33
|
+
return contentfulSdkCore.freezeSys(invocation);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a collection of raw AI Action Invocation data.
|
|
37
|
+
*
|
|
38
|
+
* @param makeRequest - Function to make API requests.
|
|
39
|
+
* @param data - Raw collection data.
|
|
40
|
+
* @returns A collection of AI Action Invocation entities.
|
|
41
|
+
*/
|
|
42
|
+
const wrapAiActionInvocationCollection = commonUtils.wrapCollection(wrapAiActionInvocation);
|
|
43
|
+
|
|
44
|
+
exports.AiActionOutputFormat = AiActionOutputFormat;
|
|
45
|
+
exports.wrapAiActionInvocation = wrapAiActionInvocation;
|
|
46
|
+
exports.wrapAiActionInvocationCollection = wrapAiActionInvocationCollection;
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
var aiActionInvocation = require('./ai-action-invocation.js');
|
|
8
|
+
|
|
9
|
+
exports.StatusFilter = void 0;
|
|
10
|
+
(function (StatusFilter) {
|
|
11
|
+
StatusFilter["ALL"] = "all";
|
|
12
|
+
StatusFilter["PUBLISHED"] = "published";
|
|
13
|
+
})(exports.StatusFilter || (exports.StatusFilter = {}));
|
|
14
|
+
exports.VariableType = void 0;
|
|
15
|
+
(function (VariableType) {
|
|
16
|
+
VariableType["RESOURCE_LINK"] = "ResourceLink";
|
|
17
|
+
VariableType["TEXT"] = "Text";
|
|
18
|
+
VariableType["STANDARD_INPUT"] = "StandardInput";
|
|
19
|
+
VariableType["LOCALE"] = "Locale";
|
|
20
|
+
VariableType["MEDIA_REFERENCE"] = "MediaReference";
|
|
21
|
+
VariableType["REFERENCE"] = "Reference";
|
|
22
|
+
VariableType["SMART_CONTEXT"] = "SmartContext";
|
|
23
|
+
})(exports.VariableType || (exports.VariableType = {}));
|
|
24
|
+
exports.EntityTypeEntry = void 0;
|
|
25
|
+
(function (EntityTypeEntry) {
|
|
26
|
+
EntityTypeEntry["ENTRY"] = "Entry";
|
|
27
|
+
})(exports.EntityTypeEntry || (exports.EntityTypeEntry = {}));
|
|
28
|
+
function createAiActionApi(makeRequest) {
|
|
29
|
+
const getParams = (data) => ({
|
|
30
|
+
spaceId: data.sys.space.sys.id,
|
|
31
|
+
aiActionId: data.sys.id,
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
update: function update() {
|
|
35
|
+
const self = this;
|
|
36
|
+
return makeRequest({
|
|
37
|
+
entityType: 'AiAction',
|
|
38
|
+
action: 'update',
|
|
39
|
+
params: getParams(self),
|
|
40
|
+
payload: self,
|
|
41
|
+
}).then((data) => wrapAiAction(makeRequest, data));
|
|
42
|
+
},
|
|
43
|
+
delete: function del() {
|
|
44
|
+
const self = this;
|
|
45
|
+
return makeRequest({
|
|
46
|
+
entityType: 'AiAction',
|
|
47
|
+
action: 'delete',
|
|
48
|
+
params: getParams(self),
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
publish: function publish() {
|
|
52
|
+
const self = this;
|
|
53
|
+
return makeRequest({
|
|
54
|
+
entityType: 'AiAction',
|
|
55
|
+
action: 'publish',
|
|
56
|
+
params: {
|
|
57
|
+
aiActionId: self.sys.id,
|
|
58
|
+
spaceId: self.sys.space.sys.id,
|
|
59
|
+
version: self.sys.version,
|
|
60
|
+
},
|
|
61
|
+
}).then((data) => wrapAiAction(makeRequest, data));
|
|
62
|
+
},
|
|
63
|
+
unpublish: function unpublish() {
|
|
64
|
+
const self = this;
|
|
65
|
+
return makeRequest({
|
|
66
|
+
entityType: 'AiAction',
|
|
67
|
+
action: 'unpublish',
|
|
68
|
+
params: getParams(self),
|
|
69
|
+
}).then((data) => wrapAiAction(makeRequest, data));
|
|
70
|
+
},
|
|
71
|
+
invoke: function invoke(environmentId, payload) {
|
|
72
|
+
const self = this;
|
|
73
|
+
return makeRequest({
|
|
74
|
+
entityType: 'AiAction',
|
|
75
|
+
action: 'invoke',
|
|
76
|
+
params: {
|
|
77
|
+
spaceId: self.sys.space.sys.id,
|
|
78
|
+
environmentId,
|
|
79
|
+
aiActionId: self.sys.id,
|
|
80
|
+
},
|
|
81
|
+
payload,
|
|
82
|
+
}).then((data) => aiActionInvocation.wrapAiActionInvocation(makeRequest, data));
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function wrapAiAction(makeRequest, data) {
|
|
87
|
+
const aiAction = contentfulSdkCore.toPlainObject(copy(data));
|
|
88
|
+
const aiActionWithMethods = enhanceWithMethods(aiAction, createAiActionApi(makeRequest));
|
|
89
|
+
return contentfulSdkCore.freezeSys(aiActionWithMethods);
|
|
90
|
+
}
|
|
91
|
+
const wrapAiActionCollection = commonUtils.wrapCollection(wrapAiAction);
|
|
92
|
+
|
|
93
|
+
exports.wrapAiAction = wrapAiAction;
|
|
94
|
+
exports.wrapAiActionCollection = wrapAiActionCollection;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 createApiKeyApi(makeRequest) {
|
|
12
|
+
const getParams = (data) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return ({
|
|
15
|
+
spaceId: (_b = (_a = data.sys.space) === null || _a === void 0 ? void 0 : _a.sys.id) !== null && _b !== void 0 ? _b : '',
|
|
16
|
+
apiKeyId: data.sys.id,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
update: function update() {
|
|
21
|
+
const self = this;
|
|
22
|
+
return makeRequest({
|
|
23
|
+
entityType: 'ApiKey',
|
|
24
|
+
action: 'update',
|
|
25
|
+
params: getParams(self),
|
|
26
|
+
payload: self,
|
|
27
|
+
headers: {},
|
|
28
|
+
}).then((data) => wrapApiKey(makeRequest, data));
|
|
29
|
+
},
|
|
30
|
+
delete: function del() {
|
|
31
|
+
const self = this;
|
|
32
|
+
return makeRequest({
|
|
33
|
+
entityType: 'ApiKey',
|
|
34
|
+
action: 'delete',
|
|
35
|
+
params: getParams(self),
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
* @param makeRequest - function to make requests via an adapter
|
|
43
|
+
* @param data - Raw api key data
|
|
44
|
+
*/
|
|
45
|
+
function wrapApiKey(makeRequest, data) {
|
|
46
|
+
const apiKey = contentfulSdkCore.toPlainObject(copy(data));
|
|
47
|
+
const apiKeyWithMethods = enhanceWithMethods(apiKey, createApiKeyApi(makeRequest));
|
|
48
|
+
return contentfulSdkCore.freezeSys(apiKeyWithMethods);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
* @param makeRequest - function to make requests via an adapter
|
|
53
|
+
* @param data - Raw api key collection data
|
|
54
|
+
* @return Wrapped api key collection data
|
|
55
|
+
*/
|
|
56
|
+
const wrapApiKeyCollection = commonUtils.wrapCollection(wrapApiKey);
|
|
57
|
+
|
|
58
|
+
exports.wrapApiKey = wrapApiKey;
|
|
59
|
+
exports.wrapApiKeyCollection = wrapApiKeyCollection;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copy = require('fast-copy');
|
|
4
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @param makeRequest - function to make requests via an adapter
|
|
9
|
+
* @param data - Raw app access token data
|
|
10
|
+
* @return {AppAccessToken} Wrapped AppAccessToken data
|
|
11
|
+
*/
|
|
12
|
+
function wrapAppAccessToken(_makeRequest, data) {
|
|
13
|
+
const appAccessToken = contentfulSdkCore.toPlainObject(copy(data));
|
|
14
|
+
return contentfulSdkCore.freezeSys(appAccessToken);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.wrapAppAccessToken = wrapAppAccessToken;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var copy = require('fast-copy');
|
|
6
|
+
var contentfulSdkCore = require('contentful-sdk-core');
|
|
7
|
+
var enhanceWithMethods = require('../enhance-with-methods.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
function createAppActionCallApi(makeRequest, retryOptions) {
|
|
13
|
+
return {
|
|
14
|
+
createWithResponse: function () {
|
|
15
|
+
const payload = {
|
|
16
|
+
parameters: {
|
|
17
|
+
recipient: 'Alice <alice@my-company.com>',
|
|
18
|
+
message_body: 'Hello from Bob!',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
return makeRequest({
|
|
22
|
+
entityType: 'AppActionCall',
|
|
23
|
+
action: 'createWithResponse',
|
|
24
|
+
params: Object.assign({ spaceId: 'space-id', environmentId: 'environment-id', appDefinitionId: 'app-definiton-id', appActionId: 'app-action-id' }, retryOptions),
|
|
25
|
+
payload: payload,
|
|
26
|
+
}).then((data) => wrapAppActionCallResponse(makeRequest, data));
|
|
27
|
+
},
|
|
28
|
+
getCallDetails: function getCallDetails() {
|
|
29
|
+
return makeRequest({
|
|
30
|
+
entityType: 'AppActionCall',
|
|
31
|
+
action: 'getCallDetails',
|
|
32
|
+
params: {
|
|
33
|
+
spaceId: 'space-id',
|
|
34
|
+
environmentId: 'environment-id',
|
|
35
|
+
callId: 'call-id',
|
|
36
|
+
appActionId: 'app-action-id',
|
|
37
|
+
},
|
|
38
|
+
}).then((data) => wrapAppActionCallResponse(makeRequest, data));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
* @param http - HTTP client instance
|
|
45
|
+
* @param data - Raw AppActionCall data
|
|
46
|
+
* @return Wrapped AppActionCall data
|
|
47
|
+
*/
|
|
48
|
+
function wrapAppActionCall(makeRequest, data) {
|
|
49
|
+
const signedRequest = contentfulSdkCore.toPlainObject(copy(data));
|
|
50
|
+
const signedRequestWithMethods = enhanceWithMethods(signedRequest, createAppActionCallApi(makeRequest));
|
|
51
|
+
return signedRequestWithMethods;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
* @param http - HTTP client instance
|
|
56
|
+
* @param data - Raw AppActionCall data
|
|
57
|
+
* @return Wrapped AppActionCall data
|
|
58
|
+
*/
|
|
59
|
+
function wrapAppActionCallResponse(makeRequest, data, retryOptions) {
|
|
60
|
+
const appActionCallResponse = contentfulSdkCore.toPlainObject(copy(data));
|
|
61
|
+
const appActionCallResponseWithMethods = enhanceWithMethods(appActionCallResponse, createAppActionCallApi(makeRequest, retryOptions));
|
|
62
|
+
return appActionCallResponseWithMethods;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.default = createAppActionCallApi;
|
|
66
|
+
exports.wrapAppActionCall = wrapAppActionCall;
|
|
67
|
+
exports.wrapAppActionCallResponse = wrapAppActionCallResponse;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 createAppActionApi(makeRequest) {
|
|
12
|
+
const getParams = (data) => ({
|
|
13
|
+
organizationId: data.sys.organization.sys.id,
|
|
14
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
15
|
+
appActionId: data.sys.id,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
delete: function del() {
|
|
19
|
+
const data = this.toPlainObject();
|
|
20
|
+
return makeRequest({
|
|
21
|
+
entityType: 'AppAction',
|
|
22
|
+
action: 'delete',
|
|
23
|
+
params: getParams(data),
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
* @param makeRequest - function to make requests via an adapter
|
|
31
|
+
* @param data - Raw App Bundle data
|
|
32
|
+
* @return Wrapped App Bundle data
|
|
33
|
+
*/
|
|
34
|
+
function wrapAppAction(makeRequest, data) {
|
|
35
|
+
const appAction = contentfulSdkCore.toPlainObject(copy(data));
|
|
36
|
+
const appActionWithMethods = enhanceWithMethods(appAction, createAppActionApi(makeRequest));
|
|
37
|
+
return contentfulSdkCore.freezeSys(appActionWithMethods);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
* @param makeRequest - function to make requests via an adapter
|
|
42
|
+
* @param data - Raw App Bundle collection data
|
|
43
|
+
* @return Wrapped App Bundle collection data
|
|
44
|
+
*/
|
|
45
|
+
const wrapAppActionCollection = commonUtils.wrapCollection(wrapAppAction);
|
|
46
|
+
|
|
47
|
+
exports.wrapAppAction = wrapAppAction;
|
|
48
|
+
exports.wrapAppActionCollection = wrapAppActionCollection;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 createAppBundleApi(makeRequest) {
|
|
12
|
+
const getParams = (data) => ({
|
|
13
|
+
organizationId: data.sys.organization.sys.id,
|
|
14
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
15
|
+
appBundleId: data.sys.id,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
delete: function del() {
|
|
19
|
+
const data = this.toPlainObject();
|
|
20
|
+
return makeRequest({
|
|
21
|
+
entityType: 'AppBundle',
|
|
22
|
+
action: 'delete',
|
|
23
|
+
params: getParams(data),
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
* @param makeRequest - function to make requests via an adapter
|
|
31
|
+
* @param data - Raw App Bundle data
|
|
32
|
+
* @return Wrapped App Bundle data
|
|
33
|
+
*/
|
|
34
|
+
function wrapAppBundle(makeRequest, data) {
|
|
35
|
+
const appBundle = contentfulSdkCore.toPlainObject(copy(data));
|
|
36
|
+
const appBundleWithMethods = enhanceWithMethods(appBundle, createAppBundleApi(makeRequest));
|
|
37
|
+
return contentfulSdkCore.freezeSys(appBundleWithMethods);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
* @param makeRequest - function to make requests via an adapter
|
|
42
|
+
* @param data - Raw App Bundle collection data
|
|
43
|
+
* @return Wrapped App Bundle collection data
|
|
44
|
+
*/
|
|
45
|
+
const wrapAppBundleCollection = commonUtils.wrapCollection(wrapAppBundle);
|
|
46
|
+
|
|
47
|
+
exports.wrapAppBundle = wrapAppBundle;
|
|
48
|
+
exports.wrapAppBundleCollection = wrapAppBundleCollection;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
var createAppDefinitionApi = require('../create-app-definition-api.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
* @param makeRequest - function to make requests via an adapter
|
|
12
|
+
* @param data - Raw App Definition data
|
|
13
|
+
* @return Wrapped App Definition data
|
|
14
|
+
*/
|
|
15
|
+
function wrapAppDefinition(makeRequest, data) {
|
|
16
|
+
const appDefinition = contentfulSdkCore.toPlainObject(copy(data));
|
|
17
|
+
const appDefinitionWithMethods = enhanceWithMethods(appDefinition, createAppDefinitionApi(makeRequest));
|
|
18
|
+
return contentfulSdkCore.freezeSys(appDefinitionWithMethods);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
* @param makeRequest - function to make requests via an adapter
|
|
23
|
+
* @param data - Raw App Definition collection data
|
|
24
|
+
* @return Wrapped App Definition collection data
|
|
25
|
+
*/
|
|
26
|
+
const wrapAppDefinitionCollection = commonUtils.wrapCollection(wrapAppDefinition);
|
|
27
|
+
|
|
28
|
+
exports.wrapAppDefinition = wrapAppDefinition;
|
|
29
|
+
exports.wrapAppDefinitionCollection = wrapAppDefinitionCollection;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
* @param makeRequest - function to make requests via an adapter
|
|
10
|
+
* @return Wrapped App Details data
|
|
11
|
+
*/
|
|
12
|
+
function createAppDetailsApi(makeRequest) {
|
|
13
|
+
const getParams = (data) => ({
|
|
14
|
+
organizationId: data.sys.organization.sys.id,
|
|
15
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
delete: function del() {
|
|
19
|
+
const self = this;
|
|
20
|
+
return makeRequest({
|
|
21
|
+
entityType: 'AppDetails',
|
|
22
|
+
action: 'delete',
|
|
23
|
+
params: getParams(self),
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
* @param http - HTTP client instance
|
|
31
|
+
* @param data - Raw AppDetails data
|
|
32
|
+
* @return Wrapped AppDetails data
|
|
33
|
+
*/
|
|
34
|
+
function wrapAppDetails(makeRequest, data) {
|
|
35
|
+
const appDetails = contentfulSdkCore.toPlainObject(copy(data));
|
|
36
|
+
return enhanceWithMethods(appDetails, createAppDetailsApi(makeRequest));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.wrapAppDetails = wrapAppDetails;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
7
|
+
function createEventSubscriptionApi(makeRequest) {
|
|
8
|
+
const getParams = (data) => ({
|
|
9
|
+
organizationId: data.sys.organization.sys.id,
|
|
10
|
+
appDefinitionId: data.sys.appDefinition.sys.id,
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
delete: function del() {
|
|
14
|
+
const self = this;
|
|
15
|
+
return makeRequest({
|
|
16
|
+
entityType: 'AppEventSubscription',
|
|
17
|
+
action: 'delete',
|
|
18
|
+
params: getParams(self),
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
* @param http - HTTP client instance
|
|
26
|
+
* @param data - Raw AppEventSubscription data
|
|
27
|
+
* @return Wrapped AppEventSubscription data
|
|
28
|
+
*/
|
|
29
|
+
function wrapAppEventSubscription(makeRequest, data) {
|
|
30
|
+
const eventSubscription = contentfulSdkCore.toPlainObject(copy(data));
|
|
31
|
+
return enhanceWithMethods(eventSubscription, createEventSubscriptionApi(makeRequest));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.wrapAppEventSubscription = wrapAppEventSubscription;
|