contentful-management 11.49.0-beta.1 → 11.49.0
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 +830 -264
- package/dist/contentful-management.browser.js.map +1 -1
- package/dist/contentful-management.browser.min.js +1 -1
- package/dist/contentful-management.node.js +806 -257
- 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/ai-action-invocation.js +6 -0
- package/dist/es-modules/adapters/REST/endpoints/ai-action.js +61 -0
- package/dist/es-modules/adapters/REST/endpoints/index.js +4 -0
- package/dist/es-modules/adapters/REST/make-request.js +1 -5
- package/dist/es-modules/contentful-management.js +1 -1
- package/dist/es-modules/create-environment-api.js +61 -0
- package/dist/es-modules/create-space-api.js +186 -0
- package/dist/es-modules/entities/ai-action-invocation.js +46 -0
- package/dist/es-modules/entities/ai-action.js +85 -0
- package/dist/es-modules/entities/index.js +4 -0
- package/dist/es-modules/plain/entities/ai-action-invocation.js +1 -0
- package/dist/es-modules/plain/entities/ai-action.js +1 -0
- package/dist/es-modules/plain/plain-client.js +13 -0
- package/dist/typings/adapters/REST/endpoints/ai-action-invocation.d.ts +2 -0
- package/dist/typings/adapters/REST/endpoints/ai-action.d.ts +9 -0
- package/dist/typings/adapters/REST/endpoints/index.d.ts +4 -0
- package/dist/typings/common-types.d.ts +75 -0
- package/dist/typings/constants/editor-interface-defaults/controls-defaults.d.ts +1 -1
- package/dist/typings/create-environment-api.d.ts +37 -0
- package/dist/typings/create-space-api.d.ts +100 -0
- package/dist/typings/entities/ai-action-invocation.d.ts +90 -0
- package/dist/typings/entities/ai-action.d.ts +97 -0
- package/dist/typings/entities/app-event-subscription.d.ts +8 -2
- package/dist/typings/entities/index.d.ts +4 -0
- package/dist/typings/export-types.d.ts +2 -0
- package/dist/typings/plain/common-types.d.ts +5 -0
- package/dist/typings/plain/entities/ai-action-invocation.d.ts +18 -0
- package/dist/typings/plain/entities/ai-action.d.ts +84 -0
- package/dist/typings/plain/entities/app-event-subscription.d.ts +25 -0
- package/package.json +2 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const _excluded = ["sys"];
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
8
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
9
|
+
import copy from 'fast-copy';
|
|
10
|
+
import * as raw from './raw';
|
|
11
|
+
export const get = (http, params, headers) => {
|
|
12
|
+
return raw.get(http, `/spaces/${params.spaceId}/ai/actions/${params.aiActionId}`, {
|
|
13
|
+
headers
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export const getMany = (http, params, headers) => {
|
|
17
|
+
return raw.get(http, `/spaces/${params.spaceId}/ai/actions`, {
|
|
18
|
+
params: params.query,
|
|
19
|
+
headers
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export const create = (http, params, data, headers) => {
|
|
23
|
+
return raw.post(http, `/spaces/${params.spaceId}/ai/actions`, data, {
|
|
24
|
+
headers
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const update = (http, params, rawData, headers) => {
|
|
28
|
+
var _rawData$sys$version;
|
|
29
|
+
const data = copy(rawData);
|
|
30
|
+
const {
|
|
31
|
+
sys
|
|
32
|
+
} = data,
|
|
33
|
+
payload = _objectWithoutProperties(data, _excluded);
|
|
34
|
+
return raw.put(http, `/spaces/${params.spaceId}/ai/actions/${params.aiActionId}`, payload, {
|
|
35
|
+
headers: _objectSpread({
|
|
36
|
+
'X-Contentful-Version': (_rawData$sys$version = rawData.sys.version) !== null && _rawData$sys$version !== void 0 ? _rawData$sys$version : 0
|
|
37
|
+
}, headers)
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export const del = (http, params, headers) => {
|
|
41
|
+
return raw.del(http, `/spaces/${params.spaceId}/ai/actions/${params.aiActionId}`, {
|
|
42
|
+
headers
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export const publish = (http, params, rawData, headers) => {
|
|
46
|
+
return raw.put(http, `/spaces/${params.spaceId}/ai/actions/${params.aiActionId}/published`, null, {
|
|
47
|
+
headers: _objectSpread({
|
|
48
|
+
'X-Contentful-Version': rawData.sys.version
|
|
49
|
+
}, headers)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
export const unpublish = (http, params, headers) => {
|
|
53
|
+
return raw.del(http, `/spaces/${params.spaceId}/ai/actions/${params.aiActionId}/published`, {
|
|
54
|
+
headers
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export const invoke = (http, params, data, headers) => {
|
|
58
|
+
return raw.post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/ai/actions/${params.aiActionId}/invoke`, data, {
|
|
59
|
+
headers
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as AiAction from './ai-action';
|
|
2
|
+
import * as AiActionInvocation from './ai-action-invocation';
|
|
1
3
|
import * as AccessToken from './access-token';
|
|
2
4
|
import * as ApiKey from './api-key';
|
|
3
5
|
import * as AppAccessToken from './app-access-token';
|
|
@@ -63,6 +65,8 @@ import * as Workflow from './workflow';
|
|
|
63
65
|
import * as WorkflowDefinition from './workflow-definition';
|
|
64
66
|
import * as WorkflowsChangelog from './workflows-changelog';
|
|
65
67
|
export default {
|
|
68
|
+
AiAction,
|
|
69
|
+
AiActionInvocation,
|
|
66
70
|
ApiKey,
|
|
67
71
|
AppAction,
|
|
68
72
|
AppActionCall,
|
|
@@ -22,11 +22,7 @@ export const makeRequest = async ({
|
|
|
22
22
|
if (endpoint === undefined) {
|
|
23
23
|
throw new Error('Unknown endpoint');
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
return await endpoint(axiosInstance, params, payload, _objectSpread(_objectSpread({}, headers), userAgent ? {
|
|
26
26
|
'X-Contentful-User-Agent': userAgent
|
|
27
27
|
} : {}));
|
|
28
|
-
if (response instanceof ReadableStream) {
|
|
29
|
-
return await new Response(response).json();
|
|
30
|
-
}
|
|
31
|
-
return response;
|
|
32
28
|
};
|
|
@@ -47,7 +47,7 @@ function createClient(params, opts = {}) {
|
|
|
47
47
|
const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
|
|
48
48
|
const userAgent = getUserAgentHeader(
|
|
49
49
|
// @ts-expect-error
|
|
50
|
-
`${sdkMain}/${"11.49.0
|
|
50
|
+
`${sdkMain}/${"11.49.0"}`, params.application, params.integration, params.feature);
|
|
51
51
|
const adapter = createAdapter(_objectSpread(_objectSpread({}, params), {}, {
|
|
52
52
|
userAgent
|
|
53
53
|
}));
|
|
@@ -16,6 +16,7 @@ import { wrapUserUIConfig } from './entities/user-ui-config';
|
|
|
16
16
|
import { wrapEnvironmentTemplateInstallationCollection } from './entities/environment-template-installation';
|
|
17
17
|
import { wrapFunctionCollection } from './entities/function';
|
|
18
18
|
import { wrapFunctionLog, wrapFunctionLogCollection } from './entities/function-log';
|
|
19
|
+
import { wrapAiActionInvocation } from './entities/ai-action-invocation';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* @private
|
|
@@ -2459,6 +2460,66 @@ export default function createEnvironmentApi(makeRequest) {
|
|
|
2459
2460
|
resourceTypeId
|
|
2460
2461
|
}
|
|
2461
2462
|
}).then(data => wrapResourceCollection(makeRequest, data));
|
|
2463
|
+
},
|
|
2464
|
+
/**
|
|
2465
|
+
* Invokes an AI Action.
|
|
2466
|
+
* @param aiActionId - The ID of the AI Action to invoke.
|
|
2467
|
+
* @param payload - The invocation payload.
|
|
2468
|
+
* @returns Promise for an AI Action Invocation.
|
|
2469
|
+
* @example ```javascript
|
|
2470
|
+
* client.getSpace('<space_id>')
|
|
2471
|
+
* .then(space => space.getEnvironment('<environment_id>'))
|
|
2472
|
+
* .then(environment => environment.invokeAiAction('<ai_action_id>', {
|
|
2473
|
+
* variables: [ ... ],
|
|
2474
|
+
* outputFormat: 'RichText'
|
|
2475
|
+
* }))
|
|
2476
|
+
* .then(invocation => console.log(invocation))
|
|
2477
|
+
* .catch(console.error)
|
|
2478
|
+
* ```
|
|
2479
|
+
*/
|
|
2480
|
+
invokeAiAction(aiActionId, payload) {
|
|
2481
|
+
const raw = this.toPlainObject();
|
|
2482
|
+
return makeRequest({
|
|
2483
|
+
entityType: 'AiAction',
|
|
2484
|
+
action: 'invoke',
|
|
2485
|
+
params: {
|
|
2486
|
+
spaceId: raw.sys.space.sys.id,
|
|
2487
|
+
environmentId: raw.sys.id,
|
|
2488
|
+
aiActionId
|
|
2489
|
+
},
|
|
2490
|
+
payload
|
|
2491
|
+
}).then(data => wrapAiActionInvocation(makeRequest, data));
|
|
2492
|
+
},
|
|
2493
|
+
/**
|
|
2494
|
+
* Retrieves an AI Action Invocation.
|
|
2495
|
+
* @param params - Object containing the AI Action ID and the Invocation ID.
|
|
2496
|
+
* @returns Promise for an AI Action Invocation.
|
|
2497
|
+
* @example ```javascript
|
|
2498
|
+
* client.getSpace('<space_id>')
|
|
2499
|
+
* .then(space => space.getEnvironment('<environment_id>'))
|
|
2500
|
+
* .then(environment => environment.getAiActionInvocation({
|
|
2501
|
+
* aiActionId: '<ai_action_id>',
|
|
2502
|
+
* invocationId: '<invocation_id>'
|
|
2503
|
+
* }))
|
|
2504
|
+
* .then(invocation => console.log(invocation))
|
|
2505
|
+
* .catch(console.error)
|
|
2506
|
+
* ```
|
|
2507
|
+
*/
|
|
2508
|
+
getAiActionInvocation({
|
|
2509
|
+
aiActionId,
|
|
2510
|
+
invocationId
|
|
2511
|
+
}) {
|
|
2512
|
+
const raw = this.toPlainObject();
|
|
2513
|
+
return makeRequest({
|
|
2514
|
+
entityType: 'AiActionInvocation',
|
|
2515
|
+
action: 'get',
|
|
2516
|
+
params: {
|
|
2517
|
+
spaceId: raw.sys.space.sys.id,
|
|
2518
|
+
environmentId: raw.sys.id,
|
|
2519
|
+
aiActionId,
|
|
2520
|
+
invocationId
|
|
2521
|
+
}
|
|
2522
|
+
}).then(data => wrapAiActionInvocation(makeRequest, data));
|
|
2462
2523
|
}
|
|
2463
2524
|
};
|
|
2464
2525
|
}
|
|
@@ -67,6 +67,14 @@ export default function createSpaceApi(makeRequest) {
|
|
|
67
67
|
wrapScheduledAction,
|
|
68
68
|
wrapScheduledActionCollection
|
|
69
69
|
} = entities.scheduledAction;
|
|
70
|
+
const {
|
|
71
|
+
wrapAiAction,
|
|
72
|
+
wrapAiActionCollection
|
|
73
|
+
} = entities.aiAction;
|
|
74
|
+
const {
|
|
75
|
+
wrapAiActionInvocation,
|
|
76
|
+
wrapAiActionInvocationCollection
|
|
77
|
+
} = entities.aiActionInvocation;
|
|
70
78
|
return {
|
|
71
79
|
/**
|
|
72
80
|
* Deletes the space
|
|
@@ -1560,6 +1568,184 @@ export default function createSpaceApi(makeRequest) {
|
|
|
1560
1568
|
scheduledActionId
|
|
1561
1569
|
}
|
|
1562
1570
|
}).then(response => wrapScheduledAction(makeRequest, response));
|
|
1571
|
+
},
|
|
1572
|
+
/**
|
|
1573
|
+
* Gets a single AI Action.
|
|
1574
|
+
* @param aiActionId - AI Action ID
|
|
1575
|
+
* @return Promise for an AI Action
|
|
1576
|
+
* @example
|
|
1577
|
+
* ```javascript
|
|
1578
|
+
* client.getSpace('<space_id>')
|
|
1579
|
+
* .then((space) => space.getAiAction('<ai_action_id>'))
|
|
1580
|
+
* .then((aiAction) => console.log(aiAction))
|
|
1581
|
+
* .catch(console.error)
|
|
1582
|
+
* ```
|
|
1583
|
+
*/
|
|
1584
|
+
getAiAction(aiActionId) {
|
|
1585
|
+
const raw = this.toPlainObject();
|
|
1586
|
+
return makeRequest({
|
|
1587
|
+
entityType: 'AiAction',
|
|
1588
|
+
action: 'get',
|
|
1589
|
+
params: {
|
|
1590
|
+
spaceId: raw.sys.id,
|
|
1591
|
+
aiActionId
|
|
1592
|
+
}
|
|
1593
|
+
}).then(data => wrapAiAction(makeRequest, data));
|
|
1594
|
+
},
|
|
1595
|
+
/**
|
|
1596
|
+
* Gets a collection of AI Actions.
|
|
1597
|
+
* @param query - Object with search parameters.
|
|
1598
|
+
* @return Promise for a collection of AI Actions
|
|
1599
|
+
* @example
|
|
1600
|
+
* ```javascript
|
|
1601
|
+
* client.getSpace('<space_id>')
|
|
1602
|
+
* .then((space) => space.getAiActions({ limit: 10 }))
|
|
1603
|
+
* .then((response) => console.log(response.items))
|
|
1604
|
+
* .catch(console.error)
|
|
1605
|
+
* ```
|
|
1606
|
+
*/
|
|
1607
|
+
getAiActions(query = {}) {
|
|
1608
|
+
const raw = this.toPlainObject();
|
|
1609
|
+
return makeRequest({
|
|
1610
|
+
entityType: 'AiAction',
|
|
1611
|
+
action: 'getMany',
|
|
1612
|
+
params: {
|
|
1613
|
+
spaceId: raw.sys.id,
|
|
1614
|
+
query
|
|
1615
|
+
}
|
|
1616
|
+
}).then(data => wrapAiActionCollection(makeRequest, data));
|
|
1617
|
+
},
|
|
1618
|
+
/**
|
|
1619
|
+
* Creates an AI Action.
|
|
1620
|
+
* @param data - Object representation of the AI Action to be created
|
|
1621
|
+
* @return Promise for the newly created AI Action
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```javascript
|
|
1624
|
+
* client.getSpace('<space_id>')
|
|
1625
|
+
* .then((space) => space.createAiAction({
|
|
1626
|
+
* name: 'My AI Action',
|
|
1627
|
+
* description: 'Description here',
|
|
1628
|
+
* configuration: { modelType: 'model-x', modelTemperature: 0.7 },
|
|
1629
|
+
* instruction: { template: 'Do something: {{var.input}}', variables: [], conditions: [] },
|
|
1630
|
+
* testCases: []
|
|
1631
|
+
* }))
|
|
1632
|
+
* .then((aiAction) => console.log(aiAction))
|
|
1633
|
+
* .catch(console.error)
|
|
1634
|
+
* ```
|
|
1635
|
+
*/
|
|
1636
|
+
createAiAction(data) {
|
|
1637
|
+
const raw = this.toPlainObject();
|
|
1638
|
+
return makeRequest({
|
|
1639
|
+
entityType: 'AiAction',
|
|
1640
|
+
action: 'create',
|
|
1641
|
+
params: {
|
|
1642
|
+
spaceId: raw.sys.id
|
|
1643
|
+
},
|
|
1644
|
+
payload: data
|
|
1645
|
+
}).then(response => wrapAiAction(makeRequest, response));
|
|
1646
|
+
},
|
|
1647
|
+
/**
|
|
1648
|
+
* Updates an AI Action.
|
|
1649
|
+
* @param aiActionId - AI Action ID
|
|
1650
|
+
* @param data - Object representation of the AI Action update
|
|
1651
|
+
* @return Promise for the updated AI Action
|
|
1652
|
+
* @example
|
|
1653
|
+
* ```javascript
|
|
1654
|
+
* client.getSpace('<space_id>')
|
|
1655
|
+
* .then((space) => space.updateAiAction('<ai_action_id>', { name: 'New Name', ... }))
|
|
1656
|
+
* .then((aiAction) => console.log(aiAction))
|
|
1657
|
+
* .catch(console.error)
|
|
1658
|
+
* ```
|
|
1659
|
+
*/
|
|
1660
|
+
updateAiAction(aiActionId, data) {
|
|
1661
|
+
var _data$sys$version;
|
|
1662
|
+
const raw = this.toPlainObject();
|
|
1663
|
+
return makeRequest({
|
|
1664
|
+
entityType: 'AiAction',
|
|
1665
|
+
action: 'update',
|
|
1666
|
+
params: {
|
|
1667
|
+
spaceId: raw.sys.id,
|
|
1668
|
+
aiActionId
|
|
1669
|
+
},
|
|
1670
|
+
payload: data,
|
|
1671
|
+
headers: {
|
|
1672
|
+
'X-Contentful-Version': (_data$sys$version = data.sys.version) !== null && _data$sys$version !== void 0 ? _data$sys$version : 0
|
|
1673
|
+
}
|
|
1674
|
+
}).then(response => wrapAiAction(makeRequest, response));
|
|
1675
|
+
},
|
|
1676
|
+
/**
|
|
1677
|
+
* Publishes an AI Action.
|
|
1678
|
+
* @param aiActionId - AI Action ID
|
|
1679
|
+
* @param data - Object representation of the AI Action to be published
|
|
1680
|
+
* @return Promise for the published AI Action
|
|
1681
|
+
* @example
|
|
1682
|
+
* ```javascript
|
|
1683
|
+
* client.getSpace('<space_id>')
|
|
1684
|
+
* .then((space) => space.publishAiAction('<ai_action_id>', { ... }))
|
|
1685
|
+
* .then((aiAction) => console.log(aiAction))
|
|
1686
|
+
* .catch(console.error)
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
publishAiAction(aiActionId, data) {
|
|
1690
|
+
const raw = this.toPlainObject();
|
|
1691
|
+
return makeRequest({
|
|
1692
|
+
entityType: 'AiAction',
|
|
1693
|
+
action: 'publish',
|
|
1694
|
+
params: {
|
|
1695
|
+
spaceId: raw.sys.id,
|
|
1696
|
+
aiActionId
|
|
1697
|
+
},
|
|
1698
|
+
payload: data,
|
|
1699
|
+
headers: {
|
|
1700
|
+
'X-Contentful-Version': data.sys.version
|
|
1701
|
+
}
|
|
1702
|
+
}).then(response => wrapAiAction(makeRequest, response));
|
|
1703
|
+
},
|
|
1704
|
+
/**
|
|
1705
|
+
* Unpublishes an AI Action.
|
|
1706
|
+
* @param aiActionId - AI Action ID
|
|
1707
|
+
* @return Promise for the unpublished AI Action
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```javascript
|
|
1710
|
+
* client.getSpace('<space_id>')
|
|
1711
|
+
* .then((space) => space.unpublishAiAction('<ai_action_id>'))
|
|
1712
|
+
* .then((aiAction) => console.log(aiAction))
|
|
1713
|
+
* .catch(console.error)
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
unpublishAiAction(aiActionId) {
|
|
1717
|
+
const raw = this.toPlainObject();
|
|
1718
|
+
return makeRequest({
|
|
1719
|
+
entityType: 'AiAction',
|
|
1720
|
+
action: 'unpublish',
|
|
1721
|
+
params: {
|
|
1722
|
+
spaceId: raw.sys.id,
|
|
1723
|
+
aiActionId
|
|
1724
|
+
}
|
|
1725
|
+
}).then(response => wrapAiAction(makeRequest, response));
|
|
1726
|
+
},
|
|
1727
|
+
/**
|
|
1728
|
+
* Deletes an AI Action.
|
|
1729
|
+
* @param aiActionId - AI Action ID
|
|
1730
|
+
* @return Promise for deletion (void)
|
|
1731
|
+
* @example
|
|
1732
|
+
* ```javascript
|
|
1733
|
+
* client.getSpace('<space_id>')
|
|
1734
|
+
* .then((space) => space.deleteAiAction('<ai_action_id>'))
|
|
1735
|
+
* .then(() => console.log('AI Action deleted'))
|
|
1736
|
+
* .catch(console.error)
|
|
1737
|
+
* ```
|
|
1738
|
+
*/
|
|
1739
|
+
deleteAiAction(aiActionId) {
|
|
1740
|
+
const raw = this.toPlainObject();
|
|
1741
|
+
return makeRequest({
|
|
1742
|
+
entityType: 'AiAction',
|
|
1743
|
+
action: 'delete',
|
|
1744
|
+
params: {
|
|
1745
|
+
spaceId: raw.sys.id,
|
|
1746
|
+
aiActionId
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1563
1749
|
}
|
|
1564
1750
|
};
|
|
1565
1751
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { freezeSys, toPlainObject } from 'contentful-sdk-core';
|
|
2
|
+
import copy from 'fast-copy';
|
|
3
|
+
import { wrapCollection } from '../common-utils';
|
|
4
|
+
export let InvocationStatus = /*#__PURE__*/function (InvocationStatus) {
|
|
5
|
+
InvocationStatus["Scheduled"] = "SCHEDULED";
|
|
6
|
+
InvocationStatus["InProgress"] = "IN_PROGRESS";
|
|
7
|
+
InvocationStatus["Failed"] = "FAILED";
|
|
8
|
+
InvocationStatus["Completed"] = "COMPLETED";
|
|
9
|
+
InvocationStatus["Cancelled"] = "CANCELLED";
|
|
10
|
+
return InvocationStatus;
|
|
11
|
+
}({});
|
|
12
|
+
export let InvocationResultType = /*#__PURE__*/function (InvocationResultType) {
|
|
13
|
+
InvocationResultType["Text"] = "text";
|
|
14
|
+
return InvocationResultType;
|
|
15
|
+
}({});
|
|
16
|
+
export const AiActionOutputFormat = {
|
|
17
|
+
RichText: 'RichText',
|
|
18
|
+
Markdown: 'Markdown',
|
|
19
|
+
PlainText: 'PlainText'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The AI Action Invocation entity.
|
|
24
|
+
* This entity is read-only and primarily used to inspect the result of an AI action invocation.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Wraps raw AI Action Invocation data with SDK helper methods.
|
|
29
|
+
*
|
|
30
|
+
* @param makeRequest - Function to make API requests.
|
|
31
|
+
* @param data - Raw AI Action Invocation data.
|
|
32
|
+
* @returns The AI Action Invocation entity.
|
|
33
|
+
*/
|
|
34
|
+
export function wrapAiActionInvocation(makeRequest, data) {
|
|
35
|
+
const invocation = toPlainObject(copy(data));
|
|
36
|
+
return freezeSys(invocation);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Wraps a collection of raw AI Action Invocation data.
|
|
41
|
+
*
|
|
42
|
+
* @param makeRequest - Function to make API requests.
|
|
43
|
+
* @param data - Raw collection data.
|
|
44
|
+
* @returns A collection of AI Action Invocation entities.
|
|
45
|
+
*/
|
|
46
|
+
export const wrapAiActionInvocationCollection = wrapCollection(wrapAiActionInvocation);
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { wrapAiActionInvocation } from './ai-action-invocation';
|
|
6
|
+
export let StatusFilter = /*#__PURE__*/function (StatusFilter) {
|
|
7
|
+
StatusFilter["ALL"] = "all";
|
|
8
|
+
StatusFilter["PUBLISHED"] = "published";
|
|
9
|
+
return StatusFilter;
|
|
10
|
+
}({});
|
|
11
|
+
export let VariableType = /*#__PURE__*/function (VariableType) {
|
|
12
|
+
VariableType["RESOURCE_LINK"] = "ResourceLink";
|
|
13
|
+
VariableType["TEXT"] = "Text";
|
|
14
|
+
VariableType["STANDARD_INPUT"] = "StandardInput";
|
|
15
|
+
VariableType["LOCALE"] = "Locale";
|
|
16
|
+
VariableType["MEDIA_REFERENCE"] = "MediaReference";
|
|
17
|
+
VariableType["REFERENCE"] = "Reference";
|
|
18
|
+
VariableType["SMART_CONTEXT"] = "SmartContext";
|
|
19
|
+
return VariableType;
|
|
20
|
+
}({});
|
|
21
|
+
export let EntityTypeEntry = /*#__PURE__*/function (EntityTypeEntry) {
|
|
22
|
+
EntityTypeEntry["ENTRY"] = "Entry";
|
|
23
|
+
return EntityTypeEntry;
|
|
24
|
+
}({});
|
|
25
|
+
function createAiActionApi(makeRequest) {
|
|
26
|
+
const getParams = data => ({
|
|
27
|
+
spaceId: data.sys.space.sys.id,
|
|
28
|
+
aiActionId: data.sys.id
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
update: function update() {
|
|
32
|
+
const self = this;
|
|
33
|
+
return makeRequest({
|
|
34
|
+
entityType: 'AiAction',
|
|
35
|
+
action: 'update',
|
|
36
|
+
params: getParams(self),
|
|
37
|
+
payload: self
|
|
38
|
+
}).then(data => wrapAiAction(makeRequest, data));
|
|
39
|
+
},
|
|
40
|
+
delete: function del() {
|
|
41
|
+
const self = this;
|
|
42
|
+
return makeRequest({
|
|
43
|
+
entityType: 'AiAction',
|
|
44
|
+
action: 'delete',
|
|
45
|
+
params: getParams(self)
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
publish: function publish() {
|
|
49
|
+
const self = this;
|
|
50
|
+
return makeRequest({
|
|
51
|
+
entityType: 'AiAction',
|
|
52
|
+
action: 'publish',
|
|
53
|
+
params: getParams(self),
|
|
54
|
+
payload: self
|
|
55
|
+
}).then(data => wrapAiAction(makeRequest, data));
|
|
56
|
+
},
|
|
57
|
+
unpublish: function unpublish() {
|
|
58
|
+
const self = this;
|
|
59
|
+
return makeRequest({
|
|
60
|
+
entityType: 'AiAction',
|
|
61
|
+
action: 'unpublish',
|
|
62
|
+
params: getParams(self)
|
|
63
|
+
}).then(data => wrapAiAction(makeRequest, data));
|
|
64
|
+
},
|
|
65
|
+
invoke: function invoke(environmentId, payload) {
|
|
66
|
+
const self = this;
|
|
67
|
+
return makeRequest({
|
|
68
|
+
entityType: 'AiAction',
|
|
69
|
+
action: 'invoke',
|
|
70
|
+
params: {
|
|
71
|
+
spaceId: self.sys.space.sys.id,
|
|
72
|
+
environmentId,
|
|
73
|
+
aiActionId: self.sys.id
|
|
74
|
+
},
|
|
75
|
+
payload
|
|
76
|
+
}).then(data => wrapAiActionInvocation(makeRequest, data));
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function wrapAiAction(makeRequest, data) {
|
|
81
|
+
const aiAction = toPlainObject(copy(data));
|
|
82
|
+
const aiActionWithMethods = enhanceWithMethods(aiAction, createAiActionApi(makeRequest));
|
|
83
|
+
return freezeSys(aiActionWithMethods);
|
|
84
|
+
}
|
|
85
|
+
export const wrapAiActionCollection = wrapCollection(wrapAiAction);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as aiAction from './ai-action';
|
|
2
|
+
import * as aiActionInvocation from './ai-action-invocation';
|
|
1
3
|
import * as apiKey from './api-key';
|
|
2
4
|
import * as appAction from './app-action';
|
|
3
5
|
import * as appActionCall from './app-action-call';
|
|
@@ -59,6 +61,8 @@ import * as resourceProvider from './resource-provider';
|
|
|
59
61
|
import * as resourceType from './resource-type';
|
|
60
62
|
import * as resource from './resource';
|
|
61
63
|
export default {
|
|
64
|
+
aiAction,
|
|
65
|
+
aiActionInvocation,
|
|
62
66
|
accessToken,
|
|
63
67
|
appAction,
|
|
64
68
|
appActionCall,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -68,6 +68,19 @@ export const createPlainClient = (makeRequest, defaults) => {
|
|
|
68
68
|
}
|
|
69
69
|
})
|
|
70
70
|
},
|
|
71
|
+
aiAction: {
|
|
72
|
+
get: wrap(wrapParams, 'AiAction', 'get'),
|
|
73
|
+
getMany: wrap(wrapParams, 'AiAction', 'getMany'),
|
|
74
|
+
create: wrap(wrapParams, 'AiAction', 'create'),
|
|
75
|
+
update: wrap(wrapParams, 'AiAction', 'update'),
|
|
76
|
+
delete: wrap(wrapParams, 'AiAction', 'delete'),
|
|
77
|
+
publish: wrap(wrapParams, 'AiAction', 'publish'),
|
|
78
|
+
unpublish: wrap(wrapParams, 'AiAction', 'unpublish'),
|
|
79
|
+
invoke: wrap(wrapParams, 'AiAction', 'invoke')
|
|
80
|
+
},
|
|
81
|
+
aiActionInvocation: {
|
|
82
|
+
get: wrap(wrapParams, 'AiActionInvocation', 'get')
|
|
83
|
+
},
|
|
71
84
|
appAction: {
|
|
72
85
|
get: wrap(wrapParams, 'AppAction', 'get'),
|
|
73
86
|
getMany: wrap(wrapParams, 'AppAction', 'getMany'),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RestEndpoint } from '../types';
|
|
2
|
+
export declare const get: RestEndpoint<'AiAction', 'get'>;
|
|
3
|
+
export declare const getMany: RestEndpoint<'AiAction', 'getMany'>;
|
|
4
|
+
export declare const create: RestEndpoint<'AiAction', 'create'>;
|
|
5
|
+
export declare const update: RestEndpoint<'AiAction', 'update'>;
|
|
6
|
+
export declare const del: RestEndpoint<'AiAction', 'delete'>;
|
|
7
|
+
export declare const publish: RestEndpoint<'AiAction', 'publish'>;
|
|
8
|
+
export declare const unpublish: RestEndpoint<'AiAction', 'unpublish'>;
|
|
9
|
+
export declare const invoke: RestEndpoint<'AiAction', 'invoke'>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as AiAction from './ai-action';
|
|
2
|
+
import * as AiActionInvocation from './ai-action-invocation';
|
|
1
3
|
import * as AccessToken from './access-token';
|
|
2
4
|
import * as ApiKey from './api-key';
|
|
3
5
|
import * as AppAccessToken from './app-access-token';
|
|
@@ -63,6 +65,8 @@ import * as Workflow from './workflow';
|
|
|
63
65
|
import * as WorkflowDefinition from './workflow-definition';
|
|
64
66
|
import * as WorkflowsChangelog from './workflows-changelog';
|
|
65
67
|
declare const _default: {
|
|
68
|
+
AiAction: typeof AiAction;
|
|
69
|
+
AiActionInvocation: typeof AiActionInvocation;
|
|
66
70
|
ApiKey: typeof ApiKey;
|
|
67
71
|
AppAction: typeof AppAction;
|
|
68
72
|
AppActionCall: typeof AppActionCall;
|