@cargo-ai/api 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/api/ai/index.d.ts +78 -0
- package/build/src/api/ai/index.d.ts.map +1 -0
- package/build/src/api/ai/index.js +530 -0
- package/build/src/api/billing/index.d.ts +25 -0
- package/build/src/api/billing/index.d.ts.map +1 -0
- package/build/src/api/billing/index.js +155 -0
- package/build/src/api/connection/index.d.ts +28 -0
- package/build/src/api/connection/index.d.ts.map +1 -0
- package/build/src/api/connection/index.js +172 -0
- package/build/src/api/expression/index.d.ts +26 -0
- package/build/src/api/expression/index.d.ts.map +1 -0
- package/build/src/api/expression/index.js +115 -0
- package/build/src/api/index.d.ts +72 -0
- package/build/src/api/index.d.ts.map +1 -0
- package/build/src/api/index.js +51 -0
- package/build/src/api/orchestration/index.d.ts +66 -0
- package/build/src/api/orchestration/index.d.ts.map +1 -0
- package/build/src/api/orchestration/index.js +625 -0
- package/build/src/api/revenueOrganization/index.d.ts +37 -0
- package/build/src/api/revenueOrganization/index.d.ts.map +1 -0
- package/build/src/api/revenueOrganization/index.js +241 -0
- package/build/src/api/segmentation/index.d.ts +28 -0
- package/build/src/api/segmentation/index.d.ts.map +1 -0
- package/build/src/api/segmentation/index.js +188 -0
- package/build/src/api/storage/index.d.ts +45 -0
- package/build/src/api/storage/index.d.ts.map +1 -0
- package/build/src/api/storage/index.js +402 -0
- package/build/src/api/systemOfRecordIntegration/index.d.ts +29 -0
- package/build/src/api/systemOfRecordIntegration/index.d.ts.map +1 -0
- package/build/src/api/systemOfRecordIntegration/index.js +151 -0
- package/build/src/api/userManagement/index.d.ts +14 -0
- package/build/src/api/userManagement/index.d.ts.map +1 -0
- package/build/src/api/userManagement/index.js +33 -0
- package/build/src/api/workspaceManagement/index.d.ts +43 -0
- package/build/src/api/workspaceManagement/index.d.ts.map +1 -0
- package/build/src/api/workspaceManagement/index.js +283 -0
- package/build/src/client.d.ts +5 -0
- package/build/src/client.d.ts.map +1 -0
- package/build/src/client.js +24 -0
- package/build/src/fetcher/client.d.ts +7 -0
- package/build/src/fetcher/client.d.ts.map +1 -0
- package/build/src/fetcher/client.js +9 -0
- package/build/src/fetcher/error.d.ts +101 -0
- package/build/src/fetcher/error.d.ts.map +1 -0
- package/build/src/fetcher/error.js +184 -0
- package/build/src/fetcher/fetcher.d.ts +12 -0
- package/build/src/fetcher/fetcher.d.ts.map +1 -0
- package/build/src/fetcher/fetcher.js +1 -0
- package/build/src/fetcher/index.d.ts +34 -0
- package/build/src/fetcher/index.d.ts.map +1 -0
- package/build/src/fetcher/index.js +78 -0
- package/build/src/index.d.ts +5 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +3 -0
- package/build/src/store/ai.d.ts +481 -0
- package/build/src/store/ai.d.ts.map +1 -0
- package/build/src/store/ai.js +112 -0
- package/build/src/store/billing.d.ts +140 -0
- package/build/src/store/billing.d.ts.map +1 -0
- package/build/src/store/billing.js +62 -0
- package/build/src/store/connection.d.ts +183 -0
- package/build/src/store/connection.d.ts.map +1 -0
- package/build/src/store/connection.js +88 -0
- package/build/src/store/expression.d.ts +112 -0
- package/build/src/store/expression.d.ts.map +1 -0
- package/build/src/store/expression.js +27 -0
- package/build/src/store/index.d.ts +14 -0
- package/build/src/store/index.d.ts.map +1 -0
- package/build/src/store/index.js +25 -0
- package/build/src/store/orchestration.d.ts +942 -0
- package/build/src/store/orchestration.d.ts.map +1 -0
- package/build/src/store/orchestration.js +217 -0
- package/build/src/store/revenueOrganization.d.ts +201 -0
- package/build/src/store/revenueOrganization.d.ts.map +1 -0
- package/build/src/store/revenueOrganization.js +68 -0
- package/build/src/store/segmentation.d.ts +566 -0
- package/build/src/store/segmentation.d.ts.map +1 -0
- package/build/src/store/segmentation.js +103 -0
- package/build/src/store/storage.d.ts +1096 -0
- package/build/src/store/storage.d.ts.map +1 -0
- package/build/src/store/storage.js +174 -0
- package/build/src/store/systemOfRecordIntegration.d.ts +122 -0
- package/build/src/store/systemOfRecordIntegration.d.ts.map +1 -0
- package/build/src/store/systemOfRecordIntegration.js +53 -0
- package/build/src/store/userManagement.d.ts +34 -0
- package/build/src/store/userManagement.d.ts.map +1 -0
- package/build/src/store/userManagement.js +22 -0
- package/build/src/store/workspaceManagement.d.ts +215 -0
- package/build/src/store/workspaceManagement.d.ts.map +1 -0
- package/build/src/store/workspaceManagement.js +103 -0
- package/build/src/types.d.ts +6 -0
- package/build/src/types.d.ts.map +1 -0
- package/build/src/types.js +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import { nullToUndefined } from "cargo-utils";
|
|
2
|
+
import { getErrorWithReasonErrorMessage, } from "../../fetcher/index.js";
|
|
3
|
+
import { Orchestration } from "../../store/index.js";
|
|
4
|
+
export const buildOrchestrationApi = ({ fetcher, }) => {
|
|
5
|
+
async function allWorkflows() {
|
|
6
|
+
const result = await fetcher.fetch({
|
|
7
|
+
method: "get",
|
|
8
|
+
endpoint: "/orchestration/workflows/list",
|
|
9
|
+
});
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
async function createPlay(payload) {
|
|
13
|
+
try {
|
|
14
|
+
const result = await fetcher.fetch({
|
|
15
|
+
method: "post",
|
|
16
|
+
endpoint: "/orchestration/plays",
|
|
17
|
+
payload,
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodCreatePlayErrorReason, {
|
|
23
|
+
modelNotFound: "Model not found.",
|
|
24
|
+
failedToCreateSegment: "Fail to create segment",
|
|
25
|
+
folderNotFound: "Folder not found.",
|
|
26
|
+
failedToSchedule: "Fail to schedule.",
|
|
27
|
+
invalidFilter: "Invalid filter.",
|
|
28
|
+
integrationNotCompatible: "Integration is not compatible.",
|
|
29
|
+
datasetNotFound: "Dataset not found.",
|
|
30
|
+
datasetNotCompatible: "Dataset is not compatible.",
|
|
31
|
+
connectorNotFound: "Connector not found.",
|
|
32
|
+
integrationNotFound: "Integration not found.",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function allPlays() {
|
|
37
|
+
const result = await fetcher.fetch({
|
|
38
|
+
method: "get",
|
|
39
|
+
endpoint: "/orchestration/plays/list",
|
|
40
|
+
});
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
async function removePlay(uuid) {
|
|
44
|
+
try {
|
|
45
|
+
await fetcher.fetch({
|
|
46
|
+
method: "delete",
|
|
47
|
+
endpoint: `/orchestration/plays/${uuid}`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodRemovePlayErrorReason, {
|
|
52
|
+
playNotFound: "Play not found.",
|
|
53
|
+
failedToRemoveSegment: "Failed to remove segment linked to play.",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function updatePlay(payload) {
|
|
58
|
+
const { uuid, ...other } = payload;
|
|
59
|
+
try {
|
|
60
|
+
const result = await fetcher.fetch({
|
|
61
|
+
method: "put",
|
|
62
|
+
endpoint: `/orchestration/plays/${uuid}`,
|
|
63
|
+
payload: other,
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodUpdatePlayErrorReason, {
|
|
69
|
+
playNotFound: "Play not found.",
|
|
70
|
+
playNotDeployed: "You cannot enable a non-deployed play.",
|
|
71
|
+
failedToUpdateSegment: "Failed to update segment linked to play.",
|
|
72
|
+
folderNotFound: "Folder not found.",
|
|
73
|
+
failedToSchedule: "Fail to schedule.",
|
|
74
|
+
invalidFilter: "Invalid filter.",
|
|
75
|
+
integrationNotCompatible: "Integration is not compatible.",
|
|
76
|
+
datasetNotFound: "Dataset not found.",
|
|
77
|
+
datasetNotCompatible: "Dataset is not compatible.",
|
|
78
|
+
connectorNotFound: "Connector not found.",
|
|
79
|
+
integrationNotFound: "Integration not found.",
|
|
80
|
+
modelNotFound: "Model not found.",
|
|
81
|
+
segmentNotFound: "Segment not found.",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function createTool(payload) {
|
|
86
|
+
const result = await fetcher.fetch({
|
|
87
|
+
method: "post",
|
|
88
|
+
endpoint: "/orchestration/tools",
|
|
89
|
+
payload,
|
|
90
|
+
});
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
async function allTools() {
|
|
94
|
+
const result = await fetcher.fetch({
|
|
95
|
+
method: "get",
|
|
96
|
+
endpoint: "/orchestration/tools/list",
|
|
97
|
+
});
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
async function removeTool(uuid) {
|
|
101
|
+
try {
|
|
102
|
+
await fetcher.fetch({
|
|
103
|
+
method: "delete",
|
|
104
|
+
endpoint: `/orchestration/tools/${uuid}`,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodRemoveToolErrorReason, {
|
|
109
|
+
toolNotFound: "Tool not found.",
|
|
110
|
+
toolIsReadOnly: "Tool is read only.",
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function updateTool(payload) {
|
|
115
|
+
const { uuid, ...other } = payload;
|
|
116
|
+
try {
|
|
117
|
+
const result = await fetcher.fetch({
|
|
118
|
+
method: "put",
|
|
119
|
+
endpoint: `/orchestration/tools/${uuid}`,
|
|
120
|
+
payload: other,
|
|
121
|
+
});
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodUpdateToolErrorReason, {
|
|
126
|
+
toolNotFound: "Tool not found.",
|
|
127
|
+
toolIsReadOnly: "Tool is read only.",
|
|
128
|
+
folderNotFound: "Folder not found.",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function computeNode(payload) {
|
|
133
|
+
const result = await fetcher.fetch({
|
|
134
|
+
method: "post",
|
|
135
|
+
endpoint: "/orchestration/nodes/compute",
|
|
136
|
+
payload,
|
|
137
|
+
replaceNullByUndefined: false,
|
|
138
|
+
});
|
|
139
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
140
|
+
return {
|
|
141
|
+
...nullToUndefined(result),
|
|
142
|
+
computedConfig: result.computedConfig,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function executeNode(payload) {
|
|
146
|
+
try {
|
|
147
|
+
const result = await fetcher.fetch({
|
|
148
|
+
method: "post",
|
|
149
|
+
endpoint: "/orchestration/nodes/execute",
|
|
150
|
+
payload,
|
|
151
|
+
replaceNullByUndefined: false,
|
|
152
|
+
});
|
|
153
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
154
|
+
if (result.status === "pending") {
|
|
155
|
+
return nullToUndefined(result);
|
|
156
|
+
}
|
|
157
|
+
const parsedGroupItems = result.groupItems !== undefined
|
|
158
|
+
? result.groupItems.map((groupItem) => {
|
|
159
|
+
const executions = Object.entries(groupItem.executions).reduce((currentExecutions, [nodeUuid, executionResult]) => {
|
|
160
|
+
if (executionResult.outcome === "executed") {
|
|
161
|
+
currentExecutions[nodeUuid] = {
|
|
162
|
+
...nullToUndefined(executionResult),
|
|
163
|
+
data: executionResult.data,
|
|
164
|
+
};
|
|
165
|
+
return currentExecutions;
|
|
166
|
+
}
|
|
167
|
+
currentExecutions[nodeUuid] = nullToUndefined(executionResult);
|
|
168
|
+
return currentExecutions;
|
|
169
|
+
}, {});
|
|
170
|
+
const computedConfigs = Object.entries(groupItem.computedConfigs).reduce((currentComputedConfigs, [nodeUuid, computedConfigResult]) => {
|
|
171
|
+
if (computedConfigResult.outcome === "computed") {
|
|
172
|
+
currentComputedConfigs[nodeUuid] = {
|
|
173
|
+
...nullToUndefined(computedConfigResult),
|
|
174
|
+
computedConfig: computedConfigResult.computedConfig,
|
|
175
|
+
};
|
|
176
|
+
return currentComputedConfigs;
|
|
177
|
+
}
|
|
178
|
+
currentComputedConfigs[nodeUuid] =
|
|
179
|
+
nullToUndefined(computedConfigResult);
|
|
180
|
+
return currentComputedConfigs;
|
|
181
|
+
}, {});
|
|
182
|
+
return {
|
|
183
|
+
...nullToUndefined(groupItem),
|
|
184
|
+
item: groupItem.item,
|
|
185
|
+
executions,
|
|
186
|
+
computedConfigs,
|
|
187
|
+
};
|
|
188
|
+
})
|
|
189
|
+
: undefined;
|
|
190
|
+
if (result.status === "error") {
|
|
191
|
+
return {
|
|
192
|
+
...nullToUndefined(result),
|
|
193
|
+
groupItems: parsedGroupItems,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
...nullToUndefined(result),
|
|
198
|
+
data: result.data,
|
|
199
|
+
groupItems: parsedGroupItems,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodExecuteNodeErrorReason, {
|
|
204
|
+
releaseNotFound: "Release not found.",
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async function previewBatch(payload) {
|
|
209
|
+
try {
|
|
210
|
+
const result = await fetcher.fetch({
|
|
211
|
+
method: "post",
|
|
212
|
+
endpoint: `/orchestration/batches/preview`,
|
|
213
|
+
payload,
|
|
214
|
+
});
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodPreviewBatchErrorReason, {
|
|
219
|
+
workflowNotFound: "Workflow not found.",
|
|
220
|
+
segmentNotFound: "Segment not found.",
|
|
221
|
+
modelLinkedToWorkflow: "A model is linked to this workflow.",
|
|
222
|
+
noModelLinkedToWorkflow: "No model is linked to this workflow.",
|
|
223
|
+
failedToFetchFromClient: "Fail to fetch records.",
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async function createBatch(payload) {
|
|
228
|
+
try {
|
|
229
|
+
const result = await fetcher.fetch({
|
|
230
|
+
method: "post",
|
|
231
|
+
endpoint: `/orchestration/batches`,
|
|
232
|
+
payload,
|
|
233
|
+
});
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodCreateBatchErrorReason, {
|
|
238
|
+
workflowNotFound: "Workflow not found.",
|
|
239
|
+
invalidReleaseOrCustomNodes: "Invalid release or custom nodes.",
|
|
240
|
+
nodesNotFound: "Unable to retrieve nodes.",
|
|
241
|
+
startNodeNotFound: "Start node not found.",
|
|
242
|
+
failedToStart: "Fail to start.",
|
|
243
|
+
notEnoughCredits: "Not enough credits.",
|
|
244
|
+
dataError: (data) => {
|
|
245
|
+
if (data.dataError === undefined) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
const dataErrorReason = data.dataError.reason;
|
|
249
|
+
return {
|
|
250
|
+
failedToGetSegment: "Fail to get segment.",
|
|
251
|
+
noRecords: "No records.",
|
|
252
|
+
failedToGetSegmentChange: "Fail to get segment change.",
|
|
253
|
+
invalidChange: "Invalid change.",
|
|
254
|
+
invalidChangeKinds: "Invalid changes.",
|
|
255
|
+
invalidData: "Invalid data.",
|
|
256
|
+
}[dataErrorReason];
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async function listBatches(payload) {
|
|
262
|
+
const result = await fetcher.fetch({
|
|
263
|
+
method: "get",
|
|
264
|
+
endpoint: "/orchestration/batches/list",
|
|
265
|
+
params: payload,
|
|
266
|
+
});
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
async function getBatch(uuid) {
|
|
270
|
+
const result = await fetcher.fetch({
|
|
271
|
+
method: "get",
|
|
272
|
+
endpoint: `/orchestration/batches/${uuid}`,
|
|
273
|
+
});
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
async function cancelBatch(uuid) {
|
|
277
|
+
try {
|
|
278
|
+
await fetcher.fetch({
|
|
279
|
+
method: "post",
|
|
280
|
+
endpoint: `/orchestration/batches/${uuid}/cancel`,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodCancelBatchErrorReason, {
|
|
285
|
+
batchNotFound: "Batch not found.",
|
|
286
|
+
batchAlreadyFinished: "Batch already finished.",
|
|
287
|
+
failedToStart: "Failed to cancel batch.",
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
async function downloadBatch(payload) {
|
|
292
|
+
const { uuid, outputNodeSlug } = payload;
|
|
293
|
+
try {
|
|
294
|
+
const result = await fetcher.fetch({
|
|
295
|
+
method: "post",
|
|
296
|
+
endpoint: `/orchestration/batches/${uuid}/download`,
|
|
297
|
+
payload: {
|
|
298
|
+
outputNodeSlug,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodDownloadBatchErrorReason, {
|
|
305
|
+
batchNotFound: "Batch not found.",
|
|
306
|
+
batchNotFinished: "Batch not finished.",
|
|
307
|
+
batchNotSupported: "Batch not supported.",
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async function createRun(payload) {
|
|
312
|
+
try {
|
|
313
|
+
const result = await fetcher.fetch({
|
|
314
|
+
method: "post",
|
|
315
|
+
endpoint: "/orchestration/runs",
|
|
316
|
+
payload,
|
|
317
|
+
});
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodCreateRunErrorReason, {
|
|
322
|
+
workflowNotFound: "Workflow not found.",
|
|
323
|
+
invalidReleaseOrCustomNodes: "Invalid release or custom nodes.",
|
|
324
|
+
nodesNotFound: "Unable to retrieve nodes.",
|
|
325
|
+
invalidData: "Invalid data.",
|
|
326
|
+
startNodeNotFound: "Start node not found.",
|
|
327
|
+
failedToStart: "Failed to start.",
|
|
328
|
+
notEnoughCredits: "Not enough credits.",
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
async function cancelRuns(payload) {
|
|
333
|
+
try {
|
|
334
|
+
await fetcher.fetch({
|
|
335
|
+
method: "post",
|
|
336
|
+
endpoint: `/orchestration/runs/cancel`,
|
|
337
|
+
payload,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodCancelRunsErrorReason, {
|
|
342
|
+
failedToStart: "Failed to cancel runs.",
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async function getRun(uuid) {
|
|
347
|
+
const result = await fetcher.fetch({
|
|
348
|
+
method: "get",
|
|
349
|
+
endpoint: `/orchestration/runs/${uuid}`,
|
|
350
|
+
replaceNullByUndefined: false,
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
...nullToUndefined(result),
|
|
354
|
+
runContext: result.runContext,
|
|
355
|
+
runComputedConfigs: result.runComputedConfigs,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
async function listRuns(payload) {
|
|
359
|
+
const result = await fetcher.fetch({
|
|
360
|
+
method: "post",
|
|
361
|
+
endpoint: "/orchestration/runs/list",
|
|
362
|
+
payload,
|
|
363
|
+
});
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
async function countRuns(payload) {
|
|
367
|
+
const result = await fetcher.fetch({
|
|
368
|
+
method: "post",
|
|
369
|
+
endpoint: "/orchestration/runs/count",
|
|
370
|
+
payload,
|
|
371
|
+
});
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
async function downloadRuns(payload) {
|
|
375
|
+
const result = await fetcher.fetch({
|
|
376
|
+
method: "post",
|
|
377
|
+
endpoint: "/orchestration/runs/download",
|
|
378
|
+
payload,
|
|
379
|
+
});
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
async function getRunMetrics(payload) {
|
|
383
|
+
const result = await fetcher.fetch({
|
|
384
|
+
method: "post",
|
|
385
|
+
endpoint: `/orchestration/runs/metrics`,
|
|
386
|
+
payload,
|
|
387
|
+
});
|
|
388
|
+
return result;
|
|
389
|
+
}
|
|
390
|
+
async function listRecords(payload) {
|
|
391
|
+
const result = await fetcher.fetch({
|
|
392
|
+
method: "post",
|
|
393
|
+
endpoint: "/orchestration/records/list",
|
|
394
|
+
payload,
|
|
395
|
+
});
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
async function countRecords(payload) {
|
|
399
|
+
const result = await fetcher.fetch({
|
|
400
|
+
method: "post",
|
|
401
|
+
endpoint: "/orchestration/records/count",
|
|
402
|
+
payload,
|
|
403
|
+
});
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
406
|
+
async function downloadRecords(payload) {
|
|
407
|
+
const result = await fetcher.fetch({
|
|
408
|
+
method: "post",
|
|
409
|
+
endpoint: "/orchestration/records/download",
|
|
410
|
+
payload,
|
|
411
|
+
});
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
async function getRecordMetrics(payload) {
|
|
415
|
+
const result = await fetcher.fetch({
|
|
416
|
+
method: "post",
|
|
417
|
+
endpoint: `/orchestration/records/metrics`,
|
|
418
|
+
payload,
|
|
419
|
+
});
|
|
420
|
+
return result;
|
|
421
|
+
}
|
|
422
|
+
async function cancelRecords(payload) {
|
|
423
|
+
try {
|
|
424
|
+
await fetcher.fetch({
|
|
425
|
+
method: "post",
|
|
426
|
+
endpoint: `/orchestration/records/cancel`,
|
|
427
|
+
payload,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodCancelRecordsErrorReason, {
|
|
432
|
+
failedToStart: "Failed to cancel runs.",
|
|
433
|
+
tooManyRecordsSelected: "Selecting more than 2000 records is not supported.",
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
async function getRelease(uuid) {
|
|
438
|
+
const result = await fetcher.fetch({
|
|
439
|
+
method: "get",
|
|
440
|
+
endpoint: `/orchestration/releases/${uuid}`,
|
|
441
|
+
replaceNullByUndefined: false,
|
|
442
|
+
});
|
|
443
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
444
|
+
return {
|
|
445
|
+
...nullToUndefined(result),
|
|
446
|
+
release: {
|
|
447
|
+
...nullToUndefined(result.release),
|
|
448
|
+
testRecords: result.release.testRecords,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
async function listReleases(payload) {
|
|
453
|
+
const result = await fetcher.fetch({
|
|
454
|
+
method: "get",
|
|
455
|
+
endpoint: "/orchestration/releases/list",
|
|
456
|
+
params: payload,
|
|
457
|
+
replaceNullByUndefined: false,
|
|
458
|
+
});
|
|
459
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
460
|
+
return {
|
|
461
|
+
...nullToUndefined(result),
|
|
462
|
+
releases: result.releases.map((release) => {
|
|
463
|
+
return {
|
|
464
|
+
...nullToUndefined(release),
|
|
465
|
+
testRecords: release.testRecords,
|
|
466
|
+
};
|
|
467
|
+
}),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
async function getDraftRelease(payload) {
|
|
471
|
+
try {
|
|
472
|
+
const result = await fetcher.fetch({
|
|
473
|
+
method: "get",
|
|
474
|
+
endpoint: "/orchestration/releases/draft",
|
|
475
|
+
params: payload,
|
|
476
|
+
replaceNullByUndefined: false,
|
|
477
|
+
});
|
|
478
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
479
|
+
return {
|
|
480
|
+
...nullToUndefined(result),
|
|
481
|
+
release: {
|
|
482
|
+
...nullToUndefined(result.release),
|
|
483
|
+
testRecords: result.release.testRecords,
|
|
484
|
+
},
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodGetDraftReleaseErrorReason, {
|
|
489
|
+
workflowNotFound: "Workflow not found.",
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
async function deployDraftRelease(payload) {
|
|
494
|
+
try {
|
|
495
|
+
const result = await fetcher.fetch({
|
|
496
|
+
method: "post",
|
|
497
|
+
endpoint: `/orchestration/releases/draft/deploy`,
|
|
498
|
+
payload,
|
|
499
|
+
replaceNullByUndefined: false,
|
|
500
|
+
});
|
|
501
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
502
|
+
return {
|
|
503
|
+
...nullToUndefined(result),
|
|
504
|
+
release: {
|
|
505
|
+
...nullToUndefined(result.release),
|
|
506
|
+
testRecords: result.release.testRecords,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodDeployDraftReleaseErrorReason, {
|
|
512
|
+
workflowNotFound: "Workflow not found.",
|
|
513
|
+
draftReleaseNotFound: "Draft release not found.",
|
|
514
|
+
draftReleaseNodesAreInvalid: "The nodes are invalid.",
|
|
515
|
+
duplicatedReleaseVersion: "Release version already used.",
|
|
516
|
+
failedToReconciliateNodes: "Failed to reconciliate nodes.",
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
async function updateDraftRelease(payload) {
|
|
521
|
+
try {
|
|
522
|
+
const result = await fetcher.fetch({
|
|
523
|
+
method: "post",
|
|
524
|
+
endpoint: `/orchestration/releases/draft/update`,
|
|
525
|
+
payload,
|
|
526
|
+
replaceNullByUndefined: false,
|
|
527
|
+
});
|
|
528
|
+
// Then cast the fields that should not keep the null values from the backend
|
|
529
|
+
return {
|
|
530
|
+
...nullToUndefined(result),
|
|
531
|
+
release: {
|
|
532
|
+
...nullToUndefined(result.release),
|
|
533
|
+
testRecords: result.release.testRecords,
|
|
534
|
+
},
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
catch (error) {
|
|
538
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodUpdateDraftReleaseErrorReason, {
|
|
539
|
+
workflowNotFound: "Workflow not found.",
|
|
540
|
+
draftReleaseNotFound: "Workflow draft release not found.",
|
|
541
|
+
invalidParent: "Invalid parent workflow release.",
|
|
542
|
+
failedToReconciliateNodes: "Failed to reconciliate nodes.",
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async function allTemplates() {
|
|
547
|
+
const result = await fetcher.fetch({
|
|
548
|
+
method: "get",
|
|
549
|
+
endpoint: `/orchestration/templates/list`,
|
|
550
|
+
});
|
|
551
|
+
return result;
|
|
552
|
+
}
|
|
553
|
+
async function getTemplate(payload) {
|
|
554
|
+
try {
|
|
555
|
+
const result = await fetcher.fetch({
|
|
556
|
+
method: "get",
|
|
557
|
+
endpoint: `/orchestration/templates/${payload.slug}`,
|
|
558
|
+
});
|
|
559
|
+
return result;
|
|
560
|
+
}
|
|
561
|
+
catch (error) {
|
|
562
|
+
throw getErrorWithReasonErrorMessage(error, Orchestration.Api.zodGetTemplateErrorReason, {
|
|
563
|
+
templateNotFound: "Template not found.",
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return {
|
|
568
|
+
batch: {
|
|
569
|
+
list: listBatches,
|
|
570
|
+
create: createBatch,
|
|
571
|
+
preview: previewBatch,
|
|
572
|
+
get: getBatch,
|
|
573
|
+
cancel: cancelBatch,
|
|
574
|
+
download: downloadBatch,
|
|
575
|
+
},
|
|
576
|
+
workflow: {
|
|
577
|
+
all: allWorkflows,
|
|
578
|
+
},
|
|
579
|
+
play: {
|
|
580
|
+
create: createPlay,
|
|
581
|
+
update: updatePlay,
|
|
582
|
+
remove: removePlay,
|
|
583
|
+
all: allPlays,
|
|
584
|
+
},
|
|
585
|
+
tool: {
|
|
586
|
+
create: createTool,
|
|
587
|
+
update: updateTool,
|
|
588
|
+
remove: removeTool,
|
|
589
|
+
all: allTools,
|
|
590
|
+
},
|
|
591
|
+
release: {
|
|
592
|
+
list: listReleases,
|
|
593
|
+
get: getRelease,
|
|
594
|
+
},
|
|
595
|
+
draftRelease: {
|
|
596
|
+
get: getDraftRelease,
|
|
597
|
+
update: updateDraftRelease,
|
|
598
|
+
deploy: deployDraftRelease,
|
|
599
|
+
},
|
|
600
|
+
run: {
|
|
601
|
+
create: createRun,
|
|
602
|
+
list: listRuns,
|
|
603
|
+
count: countRuns,
|
|
604
|
+
download: downloadRuns,
|
|
605
|
+
get: getRun,
|
|
606
|
+
getMetrics: getRunMetrics,
|
|
607
|
+
cancel: cancelRuns,
|
|
608
|
+
},
|
|
609
|
+
record: {
|
|
610
|
+
list: listRecords,
|
|
611
|
+
count: countRecords,
|
|
612
|
+
download: downloadRecords,
|
|
613
|
+
getMetrics: getRecordMetrics,
|
|
614
|
+
cancel: cancelRecords,
|
|
615
|
+
},
|
|
616
|
+
node: {
|
|
617
|
+
compute: computeNode,
|
|
618
|
+
execute: executeNode,
|
|
619
|
+
},
|
|
620
|
+
template: {
|
|
621
|
+
all: allTemplates,
|
|
622
|
+
get: getTemplate,
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Fetcher } from "../../fetcher/index.js";
|
|
2
|
+
import { RevenueOrganization } from "../../store/index.js";
|
|
3
|
+
interface RevenueOrganizationApiDependencies {
|
|
4
|
+
fetcher: Fetcher;
|
|
5
|
+
}
|
|
6
|
+
export interface RevenueOrganizationApi {
|
|
7
|
+
allocation: {
|
|
8
|
+
get: (uuid: string) => Promise<RevenueOrganization.Api.GetAllocationResult>;
|
|
9
|
+
list: (payload: RevenueOrganization.Api.ListAllocationsPayload) => Promise<RevenueOrganization.Api.ListAllocationsResult>;
|
|
10
|
+
remove: (uuid: string) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
capacity: {
|
|
13
|
+
create: (payload: RevenueOrganization.Api.CreateCapacityPayload) => Promise<RevenueOrganization.Api.CreateCapacityResult>;
|
|
14
|
+
get: (uuid: string) => Promise<RevenueOrganization.Api.GetCapacityResult>;
|
|
15
|
+
all: () => Promise<RevenueOrganization.Api.ListCapacitiesResult>;
|
|
16
|
+
remove: (uuid: string) => Promise<void>;
|
|
17
|
+
update: (payload: RevenueOrganization.Api.UpdateCapacityPayload) => Promise<RevenueOrganization.Api.UpdateCapacityResult>;
|
|
18
|
+
};
|
|
19
|
+
member: {
|
|
20
|
+
sync: (payload: RevenueOrganization.Api.SyncMemberPayload) => Promise<void>;
|
|
21
|
+
archive: (uuid: string) => Promise<RevenueOrganization.Api.ArchiveMemberResult>;
|
|
22
|
+
get: (uuid: string) => Promise<RevenueOrganization.Api.GetMemberResult>;
|
|
23
|
+
all: () => Promise<RevenueOrganization.Api.ListMembersResult>;
|
|
24
|
+
unarchive: (uuid: string) => Promise<RevenueOrganization.Api.UnarchiveMemberResult>;
|
|
25
|
+
update: (payload: RevenueOrganization.Api.UpdateMemberPayload) => Promise<RevenueOrganization.Api.UpdateMemberResult>;
|
|
26
|
+
};
|
|
27
|
+
territory: {
|
|
28
|
+
create: (payload: RevenueOrganization.Api.CreateTerritoryPayload) => Promise<RevenueOrganization.Api.CreateTerritoryResult>;
|
|
29
|
+
get: (uuid: string) => Promise<RevenueOrganization.Api.GetTerritoryResult>;
|
|
30
|
+
all: () => Promise<RevenueOrganization.Api.ListTerritoriesResult>;
|
|
31
|
+
remove: (uuid: string) => Promise<void>;
|
|
32
|
+
update: (payload: RevenueOrganization.Api.UpdateTerritoryPayload) => Promise<RevenueOrganization.Api.UpdateTerritoryResult>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare const buildRevenueOrganizationApi: ({ fetcher, }: RevenueOrganizationApiDependencies) => RevenueOrganizationApi;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/revenueOrganization/index.ts"],"names":[],"mappings":"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"}
|