@keboola/api-client 1.0.1 → 3.0.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/ai/index.cjs +5 -201
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.js +2 -201
- package/dist/ai/index.js.map +1 -1
- package/dist/assets/index.cjs +5 -180
- package/dist/assets/index.cjs.map +1 -1
- package/dist/assets/index.js +2 -180
- package/dist/assets/index.js.map +1 -1
- package/dist/chat/index.cjs +6 -422
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.js +3 -422
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/suggestions.cjs +70 -152
- package/dist/chat/suggestions.cjs.map +1 -1
- package/dist/chat/suggestions.js +1 -138
- package/dist/chat/suggestions.js.map +1 -1
- package/dist/chunk-3B7L6MCG.js +189 -0
- package/dist/chunk-3B7L6MCG.js.map +1 -0
- package/dist/chunk-3T54WH4X.cjs +42 -0
- package/dist/chunk-3T54WH4X.cjs.map +1 -0
- package/dist/chunk-3Y6NK7TC.js +34 -0
- package/dist/chunk-3Y6NK7TC.js.map +1 -0
- package/dist/chunk-4RC5E3SL.js +140 -0
- package/dist/chunk-4RC5E3SL.js.map +1 -0
- package/dist/chunk-633QJMHH.cjs +73 -0
- package/dist/chunk-633QJMHH.cjs.map +1 -0
- package/dist/chunk-6RQDX6JY.cjs +132 -0
- package/dist/chunk-6RQDX6JY.cjs.map +1 -0
- package/dist/chunk-76AHKXLC.cjs +29 -0
- package/dist/chunk-76AHKXLC.cjs.map +1 -0
- package/dist/chunk-7FY6COWG.js +71 -0
- package/dist/chunk-7FY6COWG.js.map +1 -0
- package/dist/chunk-7J2R6XHB.js +3 -0
- package/dist/chunk-7J2R6XHB.js.map +1 -0
- package/dist/chunk-BGLICNTG.cjs +33 -0
- package/dist/chunk-BGLICNTG.cjs.map +1 -0
- package/dist/chunk-BR3SBEFE.cjs +182 -0
- package/dist/chunk-BR3SBEFE.cjs.map +1 -0
- package/dist/chunk-CVV4HROS.cjs +37 -0
- package/dist/chunk-CVV4HROS.cjs.map +1 -0
- package/dist/chunk-DCTDH77P.cjs +277 -0
- package/dist/chunk-DCTDH77P.cjs.map +1 -0
- package/dist/chunk-EBCZUGUX.js +35 -0
- package/dist/chunk-EBCZUGUX.js.map +1 -0
- package/dist/chunk-EY5LALX2.cjs +26 -0
- package/dist/chunk-EY5LALX2.cjs.map +1 -0
- package/dist/chunk-FBQHHAL5.js +40 -0
- package/dist/chunk-FBQHHAL5.js.map +1 -0
- package/dist/chunk-GF4XZK5N.cjs +43 -0
- package/dist/chunk-GF4XZK5N.cjs.map +1 -0
- package/dist/chunk-GNPQB3MT.js +27 -0
- package/dist/chunk-GNPQB3MT.js.map +1 -0
- package/dist/chunk-GO6SOMGL.js +181 -0
- package/dist/chunk-GO6SOMGL.js.map +1 -0
- package/dist/chunk-HCNNMUTR.cjs +36 -0
- package/dist/chunk-HCNNMUTR.cjs.map +1 -0
- package/dist/chunk-HPVTVQBJ.cjs +238 -0
- package/dist/chunk-HPVTVQBJ.cjs.map +1 -0
- package/dist/chunk-HYUGRMCY.cjs +247 -0
- package/dist/chunk-HYUGRMCY.cjs.map +1 -0
- package/dist/chunk-IJMQCOBC.js +34 -0
- package/dist/chunk-IJMQCOBC.js.map +1 -0
- package/dist/chunk-IY3VNVXD.cjs +183 -0
- package/dist/chunk-IY3VNVXD.cjs.map +1 -0
- package/dist/chunk-JKFIB6SQ.cjs +685 -0
- package/dist/chunk-JKFIB6SQ.cjs.map +1 -0
- package/dist/chunk-JLNOESHX.cjs +47 -0
- package/dist/chunk-JLNOESHX.cjs.map +1 -0
- package/dist/chunk-JURD5MC3.js +178 -0
- package/dist/chunk-JURD5MC3.js.map +1 -0
- package/dist/chunk-LV3ZWNDC.js +75 -0
- package/dist/chunk-LV3ZWNDC.js.map +1 -0
- package/dist/chunk-LZ6A6J2E.cjs +77 -0
- package/dist/chunk-LZ6A6J2E.cjs.map +1 -0
- package/dist/chunk-OKVYLO6C.js +108 -0
- package/dist/chunk-OKVYLO6C.js.map +1 -0
- package/dist/chunk-PD3LJYS2.js +218 -0
- package/dist/chunk-PD3LJYS2.js.map +1 -0
- package/dist/chunk-PV4HIVW2.js +130 -0
- package/dist/chunk-PV4HIVW2.js.map +1 -0
- package/dist/chunk-R7PD3BRA.js +261 -0
- package/dist/chunk-R7PD3BRA.js.map +1 -0
- package/dist/chunk-SAEG42HW.js +64 -0
- package/dist/chunk-SAEG42HW.js.map +1 -0
- package/dist/chunk-TIIRBQUA.cjs +110 -0
- package/dist/chunk-TIIRBQUA.cjs.map +1 -0
- package/dist/chunk-TNJWOHPM.js +948 -0
- package/dist/chunk-TNJWOHPM.js.map +1 -0
- package/dist/chunk-TXFQ4YIK.js +31 -0
- package/dist/chunk-TXFQ4YIK.js.map +1 -0
- package/dist/chunk-U5SE6W5M.cjs +158 -0
- package/dist/chunk-U5SE6W5M.cjs.map +1 -0
- package/dist/chunk-UABYNGBZ.js +39 -0
- package/dist/chunk-UABYNGBZ.js.map +1 -0
- package/dist/chunk-UXF53ZOV.js +220 -0
- package/dist/chunk-UXF53ZOV.js.map +1 -0
- package/dist/chunk-VAOCYA6B.js +20 -0
- package/dist/chunk-VAOCYA6B.js.map +1 -0
- package/dist/chunk-VS5PM7KL.js +45 -0
- package/dist/chunk-VS5PM7KL.js.map +1 -0
- package/dist/chunk-WQ7EZWBF.js +24 -0
- package/dist/chunk-WQ7EZWBF.js.map +1 -0
- package/dist/chunk-XFC52BJV.cjs +952 -0
- package/dist/chunk-XFC52BJV.cjs.map +1 -0
- package/dist/chunk-XPDEQND7.cjs +4 -0
- package/dist/chunk-XPDEQND7.cjs.map +1 -0
- package/dist/chunk-XUDMML5C.cjs +211 -0
- package/dist/chunk-XUDMML5C.cjs.map +1 -0
- package/dist/chunk-YPCD7M2N.cjs +22 -0
- package/dist/chunk-YPCD7M2N.cjs.map +1 -0
- package/dist/chunk-YUEYMIMI.cjs +67 -0
- package/dist/chunk-YUEYMIMI.cjs.map +1 -0
- package/dist/chunk-YXCVNX2Q.cjs +36 -0
- package/dist/chunk-YXCVNX2Q.cjs.map +1 -0
- package/dist/chunk-ZEMKE6DI.js +681 -0
- package/dist/chunk-ZEMKE6DI.js.map +1 -0
- package/dist/dataScience/index.cjs +8 -412
- package/dist/dataScience/index.cjs.map +1 -1
- package/dist/dataScience/index.js +2 -391
- package/dist/dataScience/index.js.map +1 -1
- package/dist/domain/permissions/index.cjs +131 -2
- package/dist/domain/permissions/index.cjs.map +1 -1
- package/dist/domain/permissions/index.d.cts +108 -2
- package/dist/domain/permissions/index.d.ts +108 -2
- package/dist/domain/permissions/index.js +106 -3
- package/dist/domain/permissions/index.js.map +1 -1
- package/dist/editor/index.cjs +5 -264
- package/dist/editor/index.cjs.map +1 -1
- package/dist/editor/index.js +2 -264
- package/dist/editor/index.js.map +1 -1
- package/dist/encryption/index.cjs +5 -190
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.js +2 -190
- package/dist/encryption/index.js.map +1 -1
- package/dist/import/index.cjs +5 -196
- package/dist/import/index.cjs.map +1 -1
- package/dist/import/index.js +2 -196
- package/dist/import/index.js.map +1 -1
- package/dist/index.cjs +334 -3752
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1814 -104
- package/dist/index.d.ts +1814 -104
- package/dist/index.js +176 -3627
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +10 -881
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.js +3 -880
- package/dist/management/index.js.map +1 -1
- package/dist/metastore/index.cjs +5 -337
- package/dist/metastore/index.cjs.map +1 -1
- package/dist/metastore/index.js +2 -337
- package/dist/metastore/index.js.map +1 -1
- package/dist/oauth/index.cjs +5 -226
- package/dist/oauth/index.cjs.map +1 -1
- package/dist/oauth/index.js +2 -226
- package/dist/oauth/index.js.map +1 -1
- package/dist/project-Bzslbq4u.d.ts +16 -0
- package/dist/project-CYhB6rYN.d.cts +16 -0
- package/dist/queryService/index.cjs +5 -248
- package/dist/queryService/index.cjs.map +1 -1
- package/dist/queryService/index.js +2 -248
- package/dist/queryService/index.js.map +1 -1
- package/dist/queue/index.cjs +5 -190
- package/dist/queue/index.cjs.map +1 -1
- package/dist/queue/index.js +2 -190
- package/dist/queue/index.js.map +1 -1
- package/dist/sdk/configurations/index.d.cts +2 -12
- package/dist/sdk/configurations/index.d.ts +2 -12
- package/dist/sdk/storage/index.cjs +49 -267
- package/dist/sdk/storage/index.cjs.map +1 -1
- package/dist/sdk/storage/index.d.cts +2 -2
- package/dist/sdk/storage/index.d.ts +2 -2
- package/dist/sdk/storage/index.js +1 -259
- package/dist/sdk/storage/index.js.map +1 -1
- package/dist/sdk/tag/index.cjs +6 -203
- package/dist/sdk/tag/index.cjs.map +1 -1
- package/dist/sdk/tag/index.js +2 -206
- package/dist/sdk/tag/index.js.map +1 -1
- package/dist/status/index.cjs +6 -176
- package/dist/status/index.cjs.map +1 -1
- package/dist/status/index.js +3 -176
- package/dist/status/index.js.map +1 -1
- package/dist/status/types.cjs +2 -0
- package/dist/status/types.js +1 -1
- package/dist/storage/index.cjs +9 -1110
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +3 -1110
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/types.d.cts +39 -2
- package/dist/storage/types.d.ts +39 -2
- package/dist/{storageClient-DrYOs4Xm.d.ts → storageClient-BgvUM7gy.d.ts} +4 -1
- package/dist/{storageClient-DSLTM3Cr.d.cts → storageClient-CDX-GvNV.d.cts} +4 -1
- package/dist/{storageSdk-BBqAo0Vx.d.cts → storageSdk-IOIdwqy-.d.cts} +1 -1
- package/dist/{storageSdk-ZVmKQQSl.d.ts → storageSdk-qGaWB1dy.d.ts} +1 -1
- package/dist/syncActions/index.cjs +5 -364
- package/dist/syncActions/index.cjs.map +1 -1
- package/dist/syncActions/index.js +2 -345
- package/dist/syncActions/index.js.map +1 -1
- package/dist/telemetry/index.cjs +5 -187
- package/dist/telemetry/index.cjs.map +1 -1
- package/dist/telemetry/index.js +2 -187
- package/dist/telemetry/index.js.map +1 -1
- package/dist/vault/index.cjs +5 -219
- package/dist/vault/index.cjs.map +1 -1
- package/dist/vault/index.js +2 -219
- package/dist/vault/index.js.map +1 -1
- package/dist/verify/index.cjs +5 -184
- package/dist/verify/index.cjs.map +1 -1
- package/dist/verify/index.js +2 -184
- package/dist/verify/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,65 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
var z5__namespace = /*#__PURE__*/_interopNamespace(z5);
|
|
30
|
-
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
|
|
31
|
-
var utc__default = /*#__PURE__*/_interopDefault(utc);
|
|
32
|
-
|
|
33
|
-
// src/errors/UserError.ts
|
|
34
|
-
var UserError = class extends Error {
|
|
35
|
-
constructor(message2) {
|
|
36
|
-
super(message2);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// src/errors/ApiError.ts
|
|
41
|
-
var ApiError = class extends Error {
|
|
42
|
-
response;
|
|
43
|
-
request;
|
|
44
|
-
data;
|
|
45
|
-
constructor({ response, request, data }) {
|
|
46
|
-
super(response.statusText);
|
|
47
|
-
this.response = response;
|
|
48
|
-
this.request = request;
|
|
49
|
-
this.data = data;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/errors/ManagementClientAuthError.ts
|
|
54
|
-
var ManagementClientAuthError = class extends ApiError {
|
|
55
|
-
title;
|
|
56
|
-
message;
|
|
57
|
-
constructor(title, message2, res) {
|
|
58
|
-
super(res);
|
|
59
|
-
this.title = title;
|
|
60
|
-
this.message = message2;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
3
|
+
var chunkGF4XZK5N_cjs = require('./chunk-GF4XZK5N.cjs');
|
|
4
|
+
var chunkBR3SBEFE_cjs = require('./chunk-BR3SBEFE.cjs');
|
|
5
|
+
var chunkDCTDH77P_cjs = require('./chunk-DCTDH77P.cjs');
|
|
6
|
+
var chunkBGLICNTG_cjs = require('./chunk-BGLICNTG.cjs');
|
|
7
|
+
var chunkYUEYMIMI_cjs = require('./chunk-YUEYMIMI.cjs');
|
|
8
|
+
var chunkJKFIB6SQ_cjs = require('./chunk-JKFIB6SQ.cjs');
|
|
9
|
+
var chunk76AHKXLC_cjs = require('./chunk-76AHKXLC.cjs');
|
|
10
|
+
var chunkIY3VNVXD_cjs = require('./chunk-IY3VNVXD.cjs');
|
|
11
|
+
var chunk633QJMHH_cjs = require('./chunk-633QJMHH.cjs');
|
|
12
|
+
var chunkLZ6A6J2E_cjs = require('./chunk-LZ6A6J2E.cjs');
|
|
13
|
+
var chunkYXCVNX2Q_cjs = require('./chunk-YXCVNX2Q.cjs');
|
|
14
|
+
var chunkYPCD7M2N_cjs = require('./chunk-YPCD7M2N.cjs');
|
|
15
|
+
require('./chunk-XPDEQND7.cjs');
|
|
16
|
+
var chunkXFC52BJV_cjs = require('./chunk-XFC52BJV.cjs');
|
|
17
|
+
var chunkCVV4HROS_cjs = require('./chunk-CVV4HROS.cjs');
|
|
18
|
+
var chunkXUDMML5C_cjs = require('./chunk-XUDMML5C.cjs');
|
|
19
|
+
var chunkJLNOESHX_cjs = require('./chunk-JLNOESHX.cjs');
|
|
20
|
+
var chunkEY5LALX2_cjs = require('./chunk-EY5LALX2.cjs');
|
|
21
|
+
var chunk6RQDX6JY_cjs = require('./chunk-6RQDX6JY.cjs');
|
|
22
|
+
var chunkU5SE6W5M_cjs = require('./chunk-U5SE6W5M.cjs');
|
|
23
|
+
var chunkHYUGRMCY_cjs = require('./chunk-HYUGRMCY.cjs');
|
|
24
|
+
var chunkTIIRBQUA_cjs = require('./chunk-TIIRBQUA.cjs');
|
|
25
|
+
var chunkHCNNMUTR_cjs = require('./chunk-HCNNMUTR.cjs');
|
|
26
|
+
var chunk3T54WH4X_cjs = require('./chunk-3T54WH4X.cjs');
|
|
27
|
+
var chunkHPVTVQBJ_cjs = require('./chunk-HPVTVQBJ.cjs');
|
|
28
|
+
var zod = require('zod');
|
|
63
29
|
|
|
64
30
|
// src/errors/ServiceUnavailableError.ts
|
|
65
31
|
var ServiceUnavailableError = class _ServiceUnavailableError extends Error {
|
|
@@ -67,3474 +33,228 @@ var ServiceUnavailableError = class _ServiceUnavailableError extends Error {
|
|
|
67
33
|
super(
|
|
68
34
|
`Service "${serviceId}" is not available in this stack. Caused by: ${clientName}.${path.join(".")}()`
|
|
69
35
|
);
|
|
70
|
-
this.name = "ServiceUnavailableError";
|
|
71
|
-
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var cleanHeadersInit = (headersInit) => {
|
|
125
|
-
if (Array.isArray(headersInit)) return headersInit;
|
|
126
|
-
if (headersInit instanceof Headers) return headersInit;
|
|
127
|
-
if (headersInit == null) return headersInit;
|
|
128
|
-
return removeUndefined(headersInit);
|
|
129
|
-
};
|
|
130
|
-
var createHeaders = (headersInitA, headersInitB) => {
|
|
131
|
-
const headersA = new Headers(cleanHeadersInit(headersInitA));
|
|
132
|
-
const headersB = new Headers(cleanHeadersInit(headersInitB));
|
|
133
|
-
headersB.forEach((value, key) => {
|
|
134
|
-
headersA.set(key, value);
|
|
135
|
-
});
|
|
136
|
-
return headersA;
|
|
137
|
-
};
|
|
138
|
-
var createPath = (path, pathParam = {}) => path.replace(/\{([^}]+)}/g, (_, key) => {
|
|
139
|
-
if (!(key in pathParam))
|
|
140
|
-
throw new Error(`Path parameter "${key}" is missing in the path "${path}"`);
|
|
141
|
-
return encodeURIComponent(pathParam[key]);
|
|
142
|
-
});
|
|
143
|
-
var createSearch = (query, options = {}) => {
|
|
144
|
-
return qs__default.default.stringify(query, {
|
|
145
|
-
encodeValuesOnly: true,
|
|
146
|
-
skipNulls: true,
|
|
147
|
-
...options
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
var createBody = (body, headers) => {
|
|
151
|
-
if (body == null) return null;
|
|
152
|
-
if (body instanceof FormData) return body;
|
|
153
|
-
if (typeof body === "string") return body;
|
|
154
|
-
const stringifyBody = JSON.stringify(body);
|
|
155
|
-
const stringBody = stringifyBody === "{}" ? null : stringifyBody;
|
|
156
|
-
if (stringBody) headers.set(HttpHeader.CONTENT_TYPE, HttpContentType.JSON);
|
|
157
|
-
return stringBody;
|
|
158
|
-
};
|
|
159
|
-
var parseContentDispositionHeader = (contentDisposition) => {
|
|
160
|
-
const type = (() => {
|
|
161
|
-
const typeMatch = contentDisposition?.match(/^\s*(inline|attachment)\s*;/i);
|
|
162
|
-
return typeMatch?.[1]?.toLowerCase() ?? "unknown";
|
|
163
|
-
})();
|
|
164
|
-
const filename = (() => {
|
|
165
|
-
const filenameMatch = contentDisposition?.match(/filename="([^"]+)"/i);
|
|
166
|
-
if (filenameMatch) return filenameMatch[1];
|
|
167
|
-
const encodedFilenameMatch = contentDisposition?.match(/filename\*=(?:UTF-8'')?([^;]+)/i);
|
|
168
|
-
if (encodedFilenameMatch?.[1]) return decodeURIComponent(encodedFilenameMatch[1]);
|
|
169
|
-
const unquotedFilenameMatch = contentDisposition?.match(/filename=([^;]+)/i);
|
|
170
|
-
return unquotedFilenameMatch?.[1] ?? null;
|
|
171
|
-
})();
|
|
172
|
-
return { type, filename };
|
|
173
|
-
};
|
|
174
|
-
var createFetchRequest = ({
|
|
175
|
-
url,
|
|
176
|
-
method,
|
|
177
|
-
params,
|
|
178
|
-
options = {},
|
|
179
|
-
defaultOptions
|
|
180
|
-
}) => {
|
|
181
|
-
const {
|
|
182
|
-
baseUrl,
|
|
183
|
-
validateStatus: defValidateStatus = defaultValidateStatus,
|
|
184
|
-
headers: defaultHeaders,
|
|
185
|
-
...restDefaultOptions
|
|
186
|
-
} = defaultOptions;
|
|
187
|
-
const { validateStatus, queryArrayFormat, headers: endpointHeaders, ...restOptions } = options;
|
|
188
|
-
const headers = createHeaders(defaultHeaders, endpointHeaders);
|
|
189
|
-
const path = createPath(url, params.path);
|
|
190
|
-
const search = createSearch(params.query ?? {}, { arrayFormat: queryArrayFormat });
|
|
191
|
-
const body = createBody(params.body, headers);
|
|
192
|
-
const urlInstance = new URL(baseUrl + path);
|
|
193
|
-
urlInstance.search = search;
|
|
194
|
-
const request = new Request(urlInstance, {
|
|
195
|
-
...restDefaultOptions,
|
|
196
|
-
...restOptions,
|
|
197
|
-
headers,
|
|
198
|
-
method: method.toUpperCase(),
|
|
199
|
-
body
|
|
200
|
-
});
|
|
201
|
-
return { request, validateStatus: validateStatus ?? defValidateStatus };
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// src/fetchClient/createFetchClient/createFetchClient.ts
|
|
205
|
-
var isApiError = (error) => error instanceof ApiError;
|
|
206
|
-
var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
|
|
207
|
-
var isFetchClientError = (error) => error instanceof TypeError || error instanceof SyntaxError || isApiError(error);
|
|
208
|
-
var createCoreFetch = (fetchFn) => async ({ request, validateStatus }) => {
|
|
209
|
-
const response = await fetchFn(request);
|
|
210
|
-
const data = await parseData(response);
|
|
211
|
-
const apiResponse = {
|
|
212
|
-
request,
|
|
213
|
-
response,
|
|
214
|
-
data
|
|
215
|
-
};
|
|
216
|
-
const boolOrError = validateStatus(apiResponse);
|
|
217
|
-
if (isApiError(boolOrError)) throw boolOrError;
|
|
218
|
-
if (!boolOrError) throw new ApiError(apiResponse);
|
|
219
|
-
return apiResponse;
|
|
220
|
-
};
|
|
221
|
-
var createFetchClient = ({
|
|
222
|
-
middlewares = [],
|
|
223
|
-
...defaultOptions
|
|
224
|
-
}) => {
|
|
225
|
-
const coreFetch = createCoreFetch(defaultOptions.fetchFn ?? fetch);
|
|
226
|
-
const fetchWithMiddlewares = middlewares.reduceRight(
|
|
227
|
-
(next, middleware) => middleware(next),
|
|
228
|
-
coreFetch
|
|
229
|
-
);
|
|
230
|
-
const createFetchMethod = (method) => async (url, params, options = {}) => {
|
|
231
|
-
const request = createFetchRequest({
|
|
232
|
-
url,
|
|
233
|
-
method,
|
|
234
|
-
params,
|
|
235
|
-
defaultOptions,
|
|
236
|
-
options
|
|
237
|
-
});
|
|
238
|
-
const methodMiddlewares = options?.middlewares ?? [];
|
|
239
|
-
return methodMiddlewares.reduceRight(
|
|
240
|
-
(next, middleware) => middleware(next),
|
|
241
|
-
fetchWithMiddlewares
|
|
242
|
-
)(request);
|
|
243
|
-
};
|
|
244
|
-
return {
|
|
245
|
-
get: createFetchMethod("get"),
|
|
246
|
-
post: createFetchMethod("post"),
|
|
247
|
-
put: createFetchMethod("put"),
|
|
248
|
-
patch: createFetchMethod("patch"),
|
|
249
|
-
delete: createFetchMethod("delete")
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
// src/fetchClient/createFetchClient/middlewares.ts
|
|
254
|
-
var createCallbackMiddleware = ({ onError, onSettled, onSuccess } = {}) => (next) => async (request) => {
|
|
255
|
-
let response;
|
|
256
|
-
try {
|
|
257
|
-
response = await next(request);
|
|
258
|
-
onSuccess?.();
|
|
259
|
-
} catch (error) {
|
|
260
|
-
onError?.(error);
|
|
261
|
-
throw error;
|
|
262
|
-
} finally {
|
|
263
|
-
onSettled?.();
|
|
264
|
-
}
|
|
265
|
-
return response;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// src/fetchClient/createGenericFetchClient.ts
|
|
269
|
-
var createGenericFetchClient = (defaultOptions) => createFetchClient(defaultOptions);
|
|
270
|
-
|
|
271
|
-
// src/fetchClient/createOpenapiFetchClient.ts
|
|
272
|
-
var createOpenapiFetchClient = (defaultOptions) => createFetchClient(defaultOptions);
|
|
273
|
-
|
|
274
|
-
// src/clients/ai/aiClient.ts
|
|
275
|
-
var createAiClient = ({ baseUrl, middlewares }) => {
|
|
276
|
-
const client = createOpenapiFetchClient({
|
|
277
|
-
baseUrl,
|
|
278
|
-
middlewares
|
|
279
|
-
});
|
|
280
|
-
const describeConfigurationVersion = async (body) => {
|
|
281
|
-
const { data } = await client.post("/describe/configuration-version", { body });
|
|
282
|
-
return data;
|
|
283
|
-
};
|
|
284
|
-
const describeConfigurationMerge = async (body) => {
|
|
285
|
-
const { data } = await client.post("/describe/configuration-merge", { body });
|
|
286
|
-
return data;
|
|
287
|
-
};
|
|
288
|
-
const explainError = async (body) => {
|
|
289
|
-
const { data } = await client.post("/explain", { body });
|
|
290
|
-
return data;
|
|
291
|
-
};
|
|
292
|
-
const describeConfiguration = async (body) => {
|
|
293
|
-
const { data } = await client.post("/describe/configuration", { body });
|
|
294
|
-
return data;
|
|
295
|
-
};
|
|
296
|
-
const suggestComponent = async (body) => {
|
|
297
|
-
const { data } = await client.post("/suggest/component", { body });
|
|
298
|
-
return data;
|
|
299
|
-
};
|
|
300
|
-
const feedback = async (body) => {
|
|
301
|
-
const { data } = await client.post("/feedback", { body });
|
|
302
|
-
return data;
|
|
303
|
-
};
|
|
304
|
-
return {
|
|
305
|
-
describeConfigurationVersion,
|
|
306
|
-
describeConfigurationMerge,
|
|
307
|
-
explainError,
|
|
308
|
-
describeConfiguration,
|
|
309
|
-
suggestComponent,
|
|
310
|
-
feedback
|
|
311
|
-
};
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
// src/clients/assets/assetsClient.ts
|
|
315
|
-
var createAssetsClient = ({ baseUrl, middlewares }) => {
|
|
316
|
-
const client = createGenericFetchClient({
|
|
317
|
-
baseUrl,
|
|
318
|
-
middlewares
|
|
319
|
-
});
|
|
320
|
-
const getPublishedChangelogPosts = async (signal) => {
|
|
321
|
-
const { data } = await client.get(
|
|
322
|
-
"/platform-changelog/published-posts.json",
|
|
323
|
-
{},
|
|
324
|
-
{ signal }
|
|
325
|
-
);
|
|
326
|
-
return data;
|
|
327
|
-
};
|
|
328
|
-
return {
|
|
329
|
-
getPublishedChangelogPosts
|
|
330
|
-
};
|
|
331
|
-
};
|
|
332
|
-
var SUGGESTION_CATEGORIES = ["error", "maintenance", "documentation"];
|
|
333
|
-
var suggestionCategorySchema = z5.z.enum(SUGGESTION_CATEGORIES);
|
|
334
|
-
var suggestionSchema = z5.z.object({
|
|
335
|
-
label: z5.z.preprocess((v) => typeof v === "string" ? v.slice(0, 80) : v, z5.z.string().max(80)),
|
|
336
|
-
prompt: z5.z.string(),
|
|
337
|
-
priority: z5.z.number().int().min(1).max(3),
|
|
338
|
-
category: suggestionCategorySchema,
|
|
339
|
-
reasoning: z5.z.string()
|
|
340
|
-
});
|
|
341
|
-
z5.z.object({
|
|
342
|
-
suggestions: z5.z.array(suggestionSchema).max(4)
|
|
343
|
-
});
|
|
344
|
-
var suggestionWithIdSchema = suggestionSchema.extend({
|
|
345
|
-
id: z5.z.string()
|
|
346
|
-
});
|
|
347
|
-
var suggestionsApiResponseSchema = z5.z.object({
|
|
348
|
-
suggestions: z5.z.array(suggestionWithIdSchema).max(4),
|
|
349
|
-
suggestionSessionId: z5.z.string()
|
|
350
|
-
});
|
|
351
|
-
var recentFailedJobSchema = z5.z.object({
|
|
352
|
-
id: z5.z.string(),
|
|
353
|
-
status: z5.z.enum(["error", "warning"]),
|
|
354
|
-
component: z5.z.string(),
|
|
355
|
-
configId: z5.z.string(),
|
|
356
|
-
configName: z5.z.string().optional(),
|
|
357
|
-
createdTime: z5.z.string(),
|
|
358
|
-
durationSeconds: z5.z.number().int().nonnegative().optional(),
|
|
359
|
-
errorMessage: z5.z.string().max(200).optional()
|
|
360
|
-
});
|
|
361
|
-
var deprecatedComponentSchema = z5.z.object({
|
|
362
|
-
id: z5.z.string(),
|
|
363
|
-
name: z5.z.string(),
|
|
364
|
-
type: z5.z.string(),
|
|
365
|
-
expiredOn: z5.z.string(),
|
|
366
|
-
configCount: z5.z.number().int().nonnegative()
|
|
367
|
-
});
|
|
368
|
-
var userRecentEditSchema = z5.z.object({
|
|
369
|
-
component: z5.z.string(),
|
|
370
|
-
configId: z5.z.string(),
|
|
371
|
-
configName: z5.z.string(),
|
|
372
|
-
lastEdited: z5.z.string()
|
|
373
|
-
});
|
|
374
|
-
var dashboardContextDataSchema = z5.z.object({
|
|
375
|
-
recentFailedJobs: z5.z.array(recentFailedJobSchema).max(5),
|
|
376
|
-
deprecatedComponents: z5.z.array(deprecatedComponentSchema).max(5),
|
|
377
|
-
userRecentEdits: z5.z.array(userRecentEditSchema).max(5),
|
|
378
|
-
currentUserEmail: z5.z.string().email()
|
|
379
|
-
});
|
|
380
|
-
var JOB_STATUSES = [
|
|
381
|
-
"created",
|
|
382
|
-
"waiting",
|
|
383
|
-
"processing",
|
|
384
|
-
"success",
|
|
385
|
-
"error",
|
|
386
|
-
"terminating",
|
|
387
|
-
"terminated",
|
|
388
|
-
"cancelled",
|
|
389
|
-
"warning"
|
|
390
|
-
];
|
|
391
|
-
var jobDetailContextDataSchema = z5.z.object({
|
|
392
|
-
job: z5.z.object({
|
|
393
|
-
id: z5.z.string(),
|
|
394
|
-
status: z5.z.enum(JOB_STATUSES),
|
|
395
|
-
component: z5.z.string(),
|
|
396
|
-
configId: z5.z.string().optional(),
|
|
397
|
-
configName: z5.z.string().optional(),
|
|
398
|
-
createdTime: z5.z.string(),
|
|
399
|
-
startTime: z5.z.string().optional(),
|
|
400
|
-
endTime: z5.z.string().optional(),
|
|
401
|
-
durationSeconds: z5.z.number().int().nonnegative().optional(),
|
|
402
|
-
errorMessage: z5.z.string().max(500).optional(),
|
|
403
|
-
errorType: z5.z.enum(["user", "application"]).optional(),
|
|
404
|
-
backendSize: z5.z.string().optional()
|
|
405
|
-
}),
|
|
406
|
-
component: z5.z.object({
|
|
407
|
-
id: z5.z.string(),
|
|
408
|
-
name: z5.z.string(),
|
|
409
|
-
type: z5.z.string()
|
|
410
|
-
}).optional(),
|
|
411
|
-
runtimeHistory: z5.z.object({
|
|
412
|
-
averageDurationSeconds: z5.z.number().nonnegative().optional(),
|
|
413
|
-
minDurationSeconds: z5.z.number().nonnegative().optional(),
|
|
414
|
-
maxDurationSeconds: z5.z.number().nonnegative().optional(),
|
|
415
|
-
recentJobsCount: z5.z.number().int().nonnegative(),
|
|
416
|
-
isSlowerThanAverage: z5.z.boolean().optional(),
|
|
417
|
-
isFasterThanAverage: z5.z.boolean().optional(),
|
|
418
|
-
percentageDifference: z5.z.number().optional()
|
|
419
|
-
}).optional(),
|
|
420
|
-
currentUserEmail: z5.z.string().email()
|
|
421
|
-
});
|
|
422
|
-
var configurationDetailContextDataSchema = z5.z.object({
|
|
423
|
-
configuration: z5.z.object({
|
|
424
|
-
id: z5.z.string(),
|
|
425
|
-
name: z5.z.string(),
|
|
426
|
-
description: z5.z.string().max(500).optional(),
|
|
427
|
-
component: z5.z.string(),
|
|
428
|
-
hasRows: z5.z.boolean(),
|
|
429
|
-
rowCount: z5.z.number().int().nonnegative().optional(),
|
|
430
|
-
lastChangeDescription: z5.z.string().max(200).optional()
|
|
431
|
-
}),
|
|
432
|
-
component: z5.z.object({
|
|
433
|
-
id: z5.z.string(),
|
|
434
|
-
name: z5.z.string(),
|
|
435
|
-
type: z5.z.string()
|
|
436
|
-
}).optional(),
|
|
437
|
-
latestJobs: z5.z.array(
|
|
438
|
-
z5.z.object({
|
|
439
|
-
id: z5.z.string(),
|
|
440
|
-
status: z5.z.enum(JOB_STATUSES),
|
|
441
|
-
durationSeconds: z5.z.number().int().nonnegative().optional(),
|
|
442
|
-
errorMessage: z5.z.string().max(200).optional(),
|
|
443
|
-
createdTime: z5.z.string()
|
|
444
|
-
})
|
|
445
|
-
).max(5).optional(),
|
|
446
|
-
currentUserEmail: z5.z.string().email()
|
|
447
|
-
});
|
|
448
|
-
var dashboardSuggestionsRequestSchema = z5.z.object({
|
|
449
|
-
context: z5.z.literal("dashboard"),
|
|
450
|
-
data: dashboardContextDataSchema
|
|
451
|
-
});
|
|
452
|
-
var jobDetailSuggestionsRequestSchema = z5.z.object({
|
|
453
|
-
context: z5.z.literal("job-detail"),
|
|
454
|
-
data: jobDetailContextDataSchema
|
|
455
|
-
});
|
|
456
|
-
var configurationDetailSuggestionsRequestSchema = z5.z.object({
|
|
457
|
-
context: z5.z.literal("configuration-detail"),
|
|
458
|
-
data: configurationDetailContextDataSchema
|
|
459
|
-
});
|
|
460
|
-
z5.z.discriminatedUnion("context", [
|
|
461
|
-
dashboardSuggestionsRequestSchema,
|
|
462
|
-
jobDetailSuggestionsRequestSchema,
|
|
463
|
-
configurationDetailSuggestionsRequestSchema
|
|
464
|
-
]);
|
|
465
|
-
|
|
466
|
-
// src/clients/chat/chatClient.ts
|
|
467
|
-
var agentSettingsSchema = z5.z.object({
|
|
468
|
-
projectId: z5.z.string(),
|
|
469
|
-
customInstructions: z5.z.string().nullable(),
|
|
470
|
-
createdAt: z5.z.string(),
|
|
471
|
-
updatedAt: z5.z.string()
|
|
472
|
-
});
|
|
473
|
-
var toolPermissionValueSchema = z5.z.enum(["always_allow", "always_ask", "blocked"]);
|
|
474
|
-
var userAgentSettingsSchema = z5.z.object({
|
|
475
|
-
projectId: z5.z.string(),
|
|
476
|
-
userId: z5.z.string(),
|
|
477
|
-
customInstructions: z5.z.string().nullable(),
|
|
478
|
-
toolPermissions: z5.z.record(z5.z.string(), toolPermissionValueSchema).nullable(),
|
|
479
|
-
createdAt: z5.z.string(),
|
|
480
|
-
updatedAt: z5.z.string()
|
|
481
|
-
});
|
|
482
|
-
var toolInfoSchema = z5.z.object({
|
|
483
|
-
name: z5.z.string(),
|
|
484
|
-
description: z5.z.string(),
|
|
485
|
-
readOnly: z5.z.boolean()
|
|
486
|
-
});
|
|
487
|
-
var toolsListResponseSchema = z5.z.object({
|
|
488
|
-
tools: z5.z.array(toolInfoSchema)
|
|
489
|
-
});
|
|
490
|
-
var createChatClient = ({ baseUrl, middlewares, storageApiUrl }) => {
|
|
491
|
-
const client = createOpenapiFetchClient({
|
|
492
|
-
baseUrl,
|
|
493
|
-
headers: new Headers({
|
|
494
|
-
[KeboolaHttpHeader.STORAGE_API_URL]: storageApiUrl
|
|
495
|
-
}),
|
|
496
|
-
middlewares
|
|
497
|
-
});
|
|
498
|
-
const getHistory = async (params) => {
|
|
499
|
-
const { data } = await client.get("/history", { query: params });
|
|
500
|
-
return data;
|
|
501
|
-
};
|
|
502
|
-
const getChat = async (chatId, signal) => {
|
|
503
|
-
const { data } = await client.get("/chat/{id}", { path: { id: chatId } }, { signal });
|
|
504
|
-
return data;
|
|
505
|
-
};
|
|
506
|
-
const deleteChat = async (chatId) => {
|
|
507
|
-
const { data } = await client.delete("/chat", { query: { id: chatId } });
|
|
508
|
-
return data;
|
|
509
|
-
};
|
|
510
|
-
const getVotes = async (chatId) => {
|
|
511
|
-
const { data } = await client.get("/vote", { query: { chatId } });
|
|
512
|
-
return data;
|
|
513
|
-
};
|
|
514
|
-
const submitVote = async (params) => {
|
|
515
|
-
await client.patch("/vote", { body: params });
|
|
516
|
-
};
|
|
517
|
-
const createChat = async (request) => {
|
|
518
|
-
const { response } = await client.post("/chat", { body: request });
|
|
519
|
-
return response;
|
|
520
|
-
};
|
|
521
|
-
const getUsage = async (signal) => {
|
|
522
|
-
const { data } = await client.get("/usage", {}, { signal });
|
|
523
|
-
return data;
|
|
524
|
-
};
|
|
525
|
-
const getSuggestions = async (request, signal) => {
|
|
526
|
-
const { data } = await client.post("/suggestions", { body: request }, { signal });
|
|
527
|
-
const result = suggestionsApiResponseSchema.safeParse(data);
|
|
528
|
-
if (!result.success) {
|
|
529
|
-
throw new Error("Invalid suggestions response format");
|
|
530
|
-
}
|
|
531
|
-
return result.data;
|
|
532
|
-
};
|
|
533
|
-
const getAgentSettings = async (signal) => {
|
|
534
|
-
const { data } = await client.get("/settings", {}, { signal });
|
|
535
|
-
const result = agentSettingsSchema.safeParse(data);
|
|
536
|
-
if (!result.success) {
|
|
537
|
-
throw new Error("Invalid agent settings response format");
|
|
538
|
-
}
|
|
539
|
-
return result.data;
|
|
540
|
-
};
|
|
541
|
-
const updateAgentSettings = async (request, signal) => {
|
|
542
|
-
const { data } = await client.patch("/settings", { body: request }, { signal });
|
|
543
|
-
const result = agentSettingsSchema.safeParse(data);
|
|
544
|
-
if (!result.success) {
|
|
545
|
-
throw new Error("Invalid agent settings response format");
|
|
546
|
-
}
|
|
547
|
-
return result.data;
|
|
548
|
-
};
|
|
549
|
-
const getUserAgentSettings = async (signal) => {
|
|
550
|
-
const { data } = await client.get("/settings/user", {}, { signal });
|
|
551
|
-
const result = userAgentSettingsSchema.safeParse(data);
|
|
552
|
-
if (!result.success) {
|
|
553
|
-
throw new Error("Invalid user agent settings response format");
|
|
554
|
-
}
|
|
555
|
-
return result.data;
|
|
556
|
-
};
|
|
557
|
-
const updateUserAgentSettings = async (request, signal) => {
|
|
558
|
-
const { data } = await client.patch("/settings/user", { body: request }, { signal });
|
|
559
|
-
const result = userAgentSettingsSchema.safeParse(data);
|
|
560
|
-
if (!result.success) {
|
|
561
|
-
throw new Error("Invalid user agent settings response format");
|
|
562
|
-
}
|
|
563
|
-
return result.data;
|
|
564
|
-
};
|
|
565
|
-
const getToolsList = async (signal) => {
|
|
566
|
-
const { data } = await client.get("/settings/tools", {}, { signal });
|
|
567
|
-
const result = toolsListResponseSchema.safeParse(data);
|
|
568
|
-
if (!result.success) {
|
|
569
|
-
throw new Error("Invalid tools list response format");
|
|
570
|
-
}
|
|
571
|
-
return result.data;
|
|
572
|
-
};
|
|
573
|
-
return {
|
|
574
|
-
getHistory,
|
|
575
|
-
getChat,
|
|
576
|
-
deleteChat,
|
|
577
|
-
createChat,
|
|
578
|
-
getVotes,
|
|
579
|
-
submitVote,
|
|
580
|
-
getUsage,
|
|
581
|
-
getSuggestions,
|
|
582
|
-
getAgentSettings,
|
|
583
|
-
updateAgentSettings,
|
|
584
|
-
getUserAgentSettings,
|
|
585
|
-
updateUserAgentSettings,
|
|
586
|
-
getToolsList
|
|
587
|
-
};
|
|
588
|
-
};
|
|
589
|
-
var TailError = z5__namespace.object({
|
|
590
|
-
context: z5__namespace.object({
|
|
591
|
-
code: z5__namespace.string()
|
|
592
|
-
})
|
|
593
|
-
});
|
|
594
|
-
dayjs__default.default.extend(utc__default.default);
|
|
595
|
-
var ISO_TIMESTAMP_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z/;
|
|
596
|
-
var LEADING_ISO_TIMESTAMP_REGEX = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z)\s?/;
|
|
597
|
-
var tryParseJsonl = (line) => {
|
|
598
|
-
if (!line.startsWith("{")) return null;
|
|
599
|
-
let parsed;
|
|
600
|
-
try {
|
|
601
|
-
parsed = JSON.parse(line);
|
|
602
|
-
} catch {
|
|
603
|
-
return null;
|
|
604
|
-
}
|
|
605
|
-
if (typeof parsed !== "object" || parsed === null) return null;
|
|
606
|
-
const record = parsed;
|
|
607
|
-
const { timestamp, message: message2 } = record;
|
|
608
|
-
if (typeof timestamp !== "string" || typeof message2 !== "string") return null;
|
|
609
|
-
return {
|
|
610
|
-
timestamp,
|
|
611
|
-
message: message2
|
|
612
|
-
};
|
|
613
|
-
};
|
|
614
|
-
var parsePlainTextLine = (line) => {
|
|
615
|
-
const match = line.match(LEADING_ISO_TIMESTAMP_REGEX);
|
|
616
|
-
if (match) {
|
|
617
|
-
return { timestamp: match[1], message: line.slice(match[0].length) };
|
|
618
|
-
}
|
|
619
|
-
return { timestamp: null, message: line };
|
|
620
|
-
};
|
|
621
|
-
var parseLogLine = (line) => tryParseJsonl(line) ?? parsePlainTextLine(line);
|
|
622
|
-
var toLogEntryFromObject = (raw) => {
|
|
623
|
-
if (typeof raw.message !== "string") return null;
|
|
624
|
-
return {
|
|
625
|
-
timestamp: typeof raw.timestamp === "string" ? raw.timestamp : null,
|
|
626
|
-
message: raw.message
|
|
627
|
-
};
|
|
628
|
-
};
|
|
629
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
630
|
-
var parseLogLines = (raw) => {
|
|
631
|
-
if (raw === null || raw === void 0 || raw === "") return [];
|
|
632
|
-
if (Array.isArray(raw)) {
|
|
633
|
-
return raw.flatMap((item) => {
|
|
634
|
-
if (typeof item === "string") return item === "" ? [] : [parseLogLine(item)];
|
|
635
|
-
if (isPlainObject(item)) {
|
|
636
|
-
const entry = toLogEntryFromObject(item);
|
|
637
|
-
return entry ? [entry] : [];
|
|
638
|
-
}
|
|
639
|
-
return [];
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
if (isPlainObject(raw)) {
|
|
643
|
-
const entry = toLogEntryFromObject(raw);
|
|
644
|
-
return entry ? [entry] : [];
|
|
645
|
-
}
|
|
646
|
-
if (typeof raw !== "string") return [];
|
|
647
|
-
const lines = raw.split("\n");
|
|
648
|
-
const entries = [];
|
|
649
|
-
for (const line of lines) {
|
|
650
|
-
if (line === "") continue;
|
|
651
|
-
entries.push(parseLogLine(line));
|
|
652
|
-
}
|
|
653
|
-
return entries;
|
|
654
|
-
};
|
|
655
|
-
var parseLastLogTimestamp = (logs) => {
|
|
656
|
-
const entries = parseLogLines(logs);
|
|
657
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
658
|
-
const entry = entries[i];
|
|
659
|
-
if (!entry) continue;
|
|
660
|
-
if (entry.timestamp) return entry.timestamp;
|
|
661
|
-
const match = entry.message.match(ISO_TIMESTAMP_REGEX);
|
|
662
|
-
if (match) return match[0];
|
|
663
|
-
}
|
|
664
|
-
return null;
|
|
665
|
-
};
|
|
666
|
-
var calculateNextLogTimestamp = (timestamp) => {
|
|
667
|
-
if (timestamp === null) return null;
|
|
668
|
-
return dayjs__default.default(timestamp).utc().add(1, "second").utc().format();
|
|
669
|
-
};
|
|
670
|
-
var prepareAppRun = (appRun) => {
|
|
671
|
-
return {
|
|
672
|
-
...appRun,
|
|
673
|
-
state: appRun.state ?? (appRun.stoppedAt ? "finished" : "running")
|
|
674
|
-
// fallback state for historic non migrated runs
|
|
675
|
-
};
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
// src/clients/dataScience/dataScienceClient.ts
|
|
679
|
-
var createDataScienceClient = ({ baseUrl, middlewares }) => {
|
|
680
|
-
const client = createOpenapiFetchClient({
|
|
681
|
-
baseUrl,
|
|
682
|
-
middlewares
|
|
683
|
-
});
|
|
684
|
-
const getAppRuns = async (appId, query, signal) => {
|
|
685
|
-
const { data } = await client.get("/apps/{appId}/runs", { path: { appId }, query }, { signal });
|
|
686
|
-
return data.map(prepareAppRun);
|
|
687
|
-
};
|
|
688
|
-
const getAppRun = async (appId, runId, signal) => {
|
|
689
|
-
const { data } = await client.get(
|
|
690
|
-
"/apps/{appId}/runs/{runId}",
|
|
691
|
-
{ path: { appId, runId } },
|
|
692
|
-
{ signal }
|
|
693
|
-
);
|
|
694
|
-
return prepareAppRun(data);
|
|
695
|
-
};
|
|
696
|
-
const getAppLogsDownload = async (id, signal) => {
|
|
697
|
-
const { data, response } = await client.get(
|
|
698
|
-
"/apps/{appId}/logs/download",
|
|
699
|
-
{ path: { appId: id } },
|
|
700
|
-
{ signal }
|
|
701
|
-
);
|
|
702
|
-
const contentDisposition = parseContentDispositionHeader(
|
|
703
|
-
response.headers.get(HttpHeader.CONTENT_DISPOSITION)
|
|
704
|
-
);
|
|
705
|
-
return {
|
|
706
|
-
logs: data,
|
|
707
|
-
fileName: contentDisposition?.filename ?? "logs.txt"
|
|
708
|
-
};
|
|
709
|
-
};
|
|
710
|
-
const getAppLogsTail = async (id, { query, signal } = {}) => {
|
|
711
|
-
try {
|
|
712
|
-
const { data } = await client.get(
|
|
713
|
-
"/apps/{appId}/logs/tail",
|
|
714
|
-
{
|
|
715
|
-
query,
|
|
716
|
-
path: {
|
|
717
|
-
appId: id
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
signal
|
|
722
|
-
}
|
|
723
|
-
);
|
|
724
|
-
const logs = data === "" ? null : data;
|
|
725
|
-
const lastLogTimestamp = parseLastLogTimestamp(logs);
|
|
726
|
-
const nextLogTimestamp = calculateNextLogTimestamp(lastLogTimestamp);
|
|
727
|
-
return {
|
|
728
|
-
entries: parseLogLines(logs),
|
|
729
|
-
nextLogTimestamp
|
|
730
|
-
};
|
|
731
|
-
} catch (error) {
|
|
732
|
-
if (isApiError(error) && error.response.status === HttpStatus.BAD_REQUEST && TailError.safeParse(error.data).data?.context?.code === "apps.appNotRunning") {
|
|
733
|
-
return { entries: [], nextLogTimestamp: null };
|
|
734
|
-
}
|
|
735
|
-
throw error;
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
const getApps = async (query, signal) => {
|
|
739
|
-
const { data } = await client.get("/apps", { query }, { signal });
|
|
740
|
-
return data;
|
|
741
|
-
};
|
|
742
|
-
const getApp = async (appId, signal) => {
|
|
743
|
-
const { data } = await client.get("/apps/{appId}", { path: { appId } }, { signal });
|
|
744
|
-
return data;
|
|
745
|
-
};
|
|
746
|
-
const createApp = async (body, signal) => {
|
|
747
|
-
const { data } = await client.post("/apps", { body }, { signal });
|
|
748
|
-
return data;
|
|
749
|
-
};
|
|
750
|
-
const patchApp = async (appId, body, signal) => {
|
|
751
|
-
const { data } = await client.patch(
|
|
752
|
-
"/apps/{appId}",
|
|
753
|
-
{
|
|
754
|
-
path: { appId },
|
|
755
|
-
body
|
|
756
|
-
},
|
|
757
|
-
{ signal }
|
|
758
|
-
);
|
|
759
|
-
return data;
|
|
760
|
-
};
|
|
761
|
-
const deleteApp = async (appId, signal) => {
|
|
762
|
-
return client.delete("/apps/{appId}", { path: { appId } }, { signal });
|
|
763
|
-
};
|
|
764
|
-
const getAppPassword = async (appId, signal) => {
|
|
765
|
-
const { data } = await client.get("/apps/{appId}/password", { path: { appId } }, { signal });
|
|
766
|
-
return data;
|
|
767
|
-
};
|
|
768
|
-
const resetAppPassword = async (appId, signal) => {
|
|
769
|
-
const { data } = await client.post(
|
|
770
|
-
"/apps/{appId}/reset-password",
|
|
771
|
-
{ path: { appId } },
|
|
772
|
-
{ signal }
|
|
773
|
-
);
|
|
774
|
-
return data;
|
|
775
|
-
};
|
|
776
|
-
const getRuntimes = async (signal) => {
|
|
777
|
-
const { data } = await client.get("/runtimes", {}, { signal });
|
|
778
|
-
return data;
|
|
779
|
-
};
|
|
780
|
-
const getSandbox = async (appId, signal) => {
|
|
781
|
-
const { data } = await client.get("/sandboxes/{appId}", { path: { appId } }, { signal });
|
|
782
|
-
return data;
|
|
783
|
-
};
|
|
784
|
-
return {
|
|
785
|
-
getAppRuns,
|
|
786
|
-
getAppRun,
|
|
787
|
-
getAppLogsDownload,
|
|
788
|
-
getAppLogsTail,
|
|
789
|
-
getApps,
|
|
790
|
-
getApp,
|
|
791
|
-
createApp,
|
|
792
|
-
patchApp,
|
|
793
|
-
deleteApp,
|
|
794
|
-
getAppPassword,
|
|
795
|
-
resetAppPassword,
|
|
796
|
-
getRuntimes,
|
|
797
|
-
getSandbox
|
|
798
|
-
};
|
|
799
|
-
};
|
|
800
|
-
|
|
801
|
-
// src/clients/editor/editorClient.ts
|
|
802
|
-
var createEditorClient = ({ baseUrl, middlewares }) => {
|
|
803
|
-
const client = createOpenapiFetchClient({
|
|
804
|
-
baseUrl,
|
|
805
|
-
middlewares
|
|
806
|
-
});
|
|
807
|
-
const createSession = async (body) => {
|
|
808
|
-
const { data } = await client.post("/sql/sessions", {
|
|
809
|
-
body
|
|
810
|
-
});
|
|
811
|
-
return data;
|
|
812
|
-
};
|
|
813
|
-
const getSession = async ({ id }, signal) => {
|
|
814
|
-
const { data } = await client.get(`/sql/sessions/{id}`, { path: { id } }, { signal });
|
|
815
|
-
return data;
|
|
816
|
-
};
|
|
817
|
-
const getSessions = async (query, signal) => {
|
|
818
|
-
const { data } = await client.get(`/sql/sessions`, { query }, { signal });
|
|
819
|
-
return data;
|
|
820
|
-
};
|
|
821
|
-
const getSessionSchema = async ({
|
|
822
|
-
id,
|
|
823
|
-
onlyWorkspaceSchema = "1",
|
|
824
|
-
loadTables = "1"
|
|
825
|
-
}, signal) => {
|
|
826
|
-
const { data } = await client.get(
|
|
827
|
-
`/sql/sessions/{id}/schema`,
|
|
828
|
-
{
|
|
829
|
-
path: { id },
|
|
830
|
-
query: { onlyWorkspaceSchema, loadTables }
|
|
831
|
-
},
|
|
832
|
-
{ signal }
|
|
833
|
-
);
|
|
834
|
-
return data;
|
|
835
|
-
};
|
|
836
|
-
const createQueryJob = async ({ id }, body) => {
|
|
837
|
-
const { data } = await client.post(`/sql/sessions/{id}/run-query`, {
|
|
838
|
-
path: { id },
|
|
839
|
-
body
|
|
840
|
-
});
|
|
841
|
-
return data;
|
|
842
|
-
};
|
|
843
|
-
const tablePreview = async ({ id }, body) => {
|
|
844
|
-
const { data } = await client.post(`/sql/sessions/{id}/table-preview`, {
|
|
845
|
-
path: { id },
|
|
846
|
-
body
|
|
847
|
-
});
|
|
848
|
-
return data;
|
|
849
|
-
};
|
|
850
|
-
const tableDefinition = async ({ id, ...query }, signal) => {
|
|
851
|
-
const { data } = await client.get(
|
|
852
|
-
`/sql/sessions/{id}/table-ddl`,
|
|
853
|
-
{ path: { id }, query },
|
|
854
|
-
{ signal }
|
|
855
|
-
);
|
|
856
|
-
return data;
|
|
857
|
-
};
|
|
858
|
-
const load = async ({ id }, body) => {
|
|
859
|
-
const { data } = await client.post(`/sql/sessions/{id}/load`, {
|
|
860
|
-
path: { id },
|
|
861
|
-
body
|
|
862
|
-
});
|
|
863
|
-
return data;
|
|
864
|
-
};
|
|
865
|
-
const unload = async ({ id }, body) => {
|
|
866
|
-
const { data } = await client.post(`/sql/sessions/{id}/unload`, {
|
|
867
|
-
path: { id },
|
|
868
|
-
// BE error: The body is optional; however, without it, the request will fail with the message "Request content type must be application/json."
|
|
869
|
-
// This is expected, as our client cannot correctly determine the content type without the body.
|
|
870
|
-
// This issue should be addressed to indicate that the body is required in their Swagger schema.
|
|
871
|
-
body: body ?? { tableId: null }
|
|
872
|
-
});
|
|
873
|
-
return data;
|
|
874
|
-
};
|
|
875
|
-
const resetWorkspacePassword = async (id) => {
|
|
876
|
-
const { data } = await client.post(`/sql/sessions/{id}/reset-password`, {
|
|
877
|
-
path: { id }
|
|
878
|
-
});
|
|
879
|
-
return data;
|
|
880
|
-
};
|
|
881
|
-
const getSessionCredentials = async (id, signal) => {
|
|
882
|
-
const { data } = await client.get(
|
|
883
|
-
`/sql/sessions/{id}/credentials`,
|
|
884
|
-
{ path: { id } },
|
|
885
|
-
{ signal }
|
|
886
|
-
);
|
|
887
|
-
return data;
|
|
888
|
-
};
|
|
889
|
-
return {
|
|
890
|
-
createSession,
|
|
891
|
-
getSession,
|
|
892
|
-
getSessions,
|
|
893
|
-
getSessionSchema,
|
|
894
|
-
createQueryJob,
|
|
895
|
-
tablePreview,
|
|
896
|
-
tableDefinition,
|
|
897
|
-
load,
|
|
898
|
-
unload,
|
|
899
|
-
resetWorkspacePassword,
|
|
900
|
-
getSessionCredentials
|
|
901
|
-
};
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
// src/clients/encryption/encryptionClient.ts
|
|
905
|
-
var createEncryptionClient = ({ baseUrl, middlewares }) => {
|
|
906
|
-
const client = createGenericFetchClient({
|
|
907
|
-
baseUrl,
|
|
908
|
-
middlewares
|
|
909
|
-
});
|
|
910
|
-
const _encrypt = async (data, signal) => {
|
|
911
|
-
const response = await client.post(
|
|
912
|
-
"/encrypt",
|
|
913
|
-
{
|
|
914
|
-
query: {
|
|
915
|
-
projectId: data.projectId,
|
|
916
|
-
branchType: data.branchType,
|
|
917
|
-
componentId: data.componentId
|
|
918
|
-
},
|
|
919
|
-
body: data.data
|
|
920
|
-
},
|
|
921
|
-
{ signal }
|
|
922
|
-
);
|
|
923
|
-
return response.data;
|
|
924
|
-
};
|
|
925
|
-
const encrypt = (data, signal) => _encrypt(data, signal);
|
|
926
|
-
const encryptSecrets = (data, signal) => _encrypt(data, signal);
|
|
927
|
-
return {
|
|
928
|
-
encryptSecrets,
|
|
929
|
-
encrypt
|
|
930
|
-
};
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
// src/clients/import/importClient.ts
|
|
934
|
-
var createImportClient = ({ baseUrl, middlewares }) => {
|
|
935
|
-
const client = createGenericFetchClient({
|
|
936
|
-
baseUrl,
|
|
937
|
-
middlewares
|
|
938
|
-
});
|
|
939
|
-
const uploadFile = async (file, params = {}, signal) => {
|
|
940
|
-
const formData = new FormData();
|
|
941
|
-
formData.append("data", file);
|
|
942
|
-
if (params.isPermanent) {
|
|
943
|
-
formData.append("isPermanent", "1");
|
|
944
|
-
}
|
|
945
|
-
if (params.notify) {
|
|
946
|
-
formData.append("notify", "1");
|
|
947
|
-
}
|
|
948
|
-
if (params.branchId) {
|
|
949
|
-
formData.append("branchId", params.branchId);
|
|
950
|
-
}
|
|
951
|
-
if (params.tags) {
|
|
952
|
-
for (const tag of params.tags) {
|
|
953
|
-
formData.append("tags[]", tag);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
const { data } = await client.post(
|
|
957
|
-
"/upload-file",
|
|
958
|
-
{ body: formData },
|
|
959
|
-
{ signal }
|
|
960
|
-
);
|
|
961
|
-
return data;
|
|
962
|
-
};
|
|
963
|
-
return {
|
|
964
|
-
uploadFile
|
|
965
|
-
};
|
|
966
|
-
};
|
|
967
|
-
var agentSettingsSchema2 = z5.z.object({
|
|
968
|
-
projectId: z5.z.string(),
|
|
969
|
-
customInstructions: z5.z.string().nullable(),
|
|
970
|
-
createdAt: z5.z.string(),
|
|
971
|
-
updatedAt: z5.z.string()
|
|
972
|
-
});
|
|
973
|
-
var toolPermissionValueSchema2 = z5.z.enum(["always_allow", "always_ask", "blocked"]);
|
|
974
|
-
var userAgentSettingsSchema2 = z5.z.object({
|
|
975
|
-
projectId: z5.z.string(),
|
|
976
|
-
userId: z5.z.string(),
|
|
977
|
-
customInstructions: z5.z.string().nullable(),
|
|
978
|
-
toolPermissions: z5.z.record(z5.z.string(), toolPermissionValueSchema2).nullable(),
|
|
979
|
-
createdAt: z5.z.string(),
|
|
980
|
-
updatedAt: z5.z.string()
|
|
981
|
-
});
|
|
982
|
-
var toolInfoSchema2 = z5.z.object({
|
|
983
|
-
name: z5.z.string(),
|
|
984
|
-
description: z5.z.string(),
|
|
985
|
-
readOnly: z5.z.boolean()
|
|
986
|
-
});
|
|
987
|
-
var toolsListResponseSchema2 = z5.z.object({
|
|
988
|
-
tools: z5.z.array(toolInfoSchema2)
|
|
989
|
-
});
|
|
990
|
-
var sandboxFileEntrySchema = z5.z.object({
|
|
991
|
-
name: z5.z.string(),
|
|
992
|
-
path: z5.z.string(),
|
|
993
|
-
type: z5.z.enum(["file", "dir"]),
|
|
994
|
-
size: z5.z.number().int().nonnegative().optional()
|
|
995
|
-
});
|
|
996
|
-
var sandboxFileListingSchema = z5.z.object({
|
|
997
|
-
entries: z5.z.array(sandboxFileEntrySchema)
|
|
998
|
-
});
|
|
999
|
-
var sandboxFileContentSchema = z5.z.object({
|
|
1000
|
-
content: z5.z.string(),
|
|
1001
|
-
encoding: z5.z.enum(["utf-8", "binary"]),
|
|
1002
|
-
truncated: z5.z.boolean(),
|
|
1003
|
-
size: z5.z.number().int().nonnegative()
|
|
1004
|
-
});
|
|
1005
|
-
var sandboxGitBranchSchema = z5.z.object({
|
|
1006
|
-
branch: z5.z.string().nullable()
|
|
1007
|
-
});
|
|
1008
|
-
var createKaiAgentClient = ({ baseUrl, middlewares }) => {
|
|
1009
|
-
const clientOptions = { baseUrl, middlewares };
|
|
1010
|
-
const client = createOpenapiFetchClient(clientOptions);
|
|
1011
|
-
const genericClient = createGenericFetchClient(clientOptions);
|
|
1012
|
-
const getHistory = async (params) => {
|
|
1013
|
-
const { data } = await client.get("/api/history", { query: params });
|
|
1014
|
-
return data;
|
|
1015
|
-
};
|
|
1016
|
-
const getChat = async (chatId, signal) => {
|
|
1017
|
-
const { data } = await client.get("/api/chat/{id}", { path: { id: chatId } }, { signal });
|
|
1018
|
-
return data;
|
|
1019
|
-
};
|
|
1020
|
-
const deleteChat = async (chatId) => {
|
|
1021
|
-
const { data } = await client.delete("/api/chat", { query: { id: chatId } });
|
|
1022
|
-
return data;
|
|
1023
|
-
};
|
|
1024
|
-
const createChat = async (request) => {
|
|
1025
|
-
const { response } = await client.post("/api/chat", { body: request });
|
|
1026
|
-
return response;
|
|
1027
|
-
};
|
|
1028
|
-
const getVotes = async (chatId) => {
|
|
1029
|
-
const { data } = await client.get("/api/vote", { query: { chatId } });
|
|
1030
|
-
return data;
|
|
1031
|
-
};
|
|
1032
|
-
const submitVote = async (params) => {
|
|
1033
|
-
await client.patch("/api/vote", { body: params });
|
|
1034
|
-
};
|
|
1035
|
-
const getUsage = async (signal) => {
|
|
1036
|
-
const { data } = await client.get("/api/usage", {}, { signal });
|
|
1037
|
-
return data;
|
|
1038
|
-
};
|
|
1039
|
-
const approveToolCall = async (chatId, body) => {
|
|
1040
|
-
await client.post("/api/chat/{id}/approval", { path: { id: chatId }, body });
|
|
1041
|
-
};
|
|
1042
|
-
const submitToolOutput = async (chatId, body) => {
|
|
1043
|
-
await client.post("/api/chat/{id}/ui-tool-result", { path: { id: chatId }, body });
|
|
1044
|
-
};
|
|
1045
|
-
const stopChat = async (chatId) => {
|
|
1046
|
-
const { data } = await client.post("/api/chat/{id}/stop", { path: { id: chatId } });
|
|
1047
|
-
return data;
|
|
1048
|
-
};
|
|
1049
|
-
const getSuggestions = async (request, signal) => {
|
|
1050
|
-
const { data } = await genericClient.post(
|
|
1051
|
-
"/api/suggestions",
|
|
1052
|
-
{ body: request },
|
|
1053
|
-
{ signal }
|
|
1054
|
-
);
|
|
1055
|
-
const result = suggestionsApiResponseSchema.safeParse(data);
|
|
1056
|
-
if (!result.success) {
|
|
1057
|
-
throw new Error("Invalid suggestions response format");
|
|
1058
|
-
}
|
|
1059
|
-
return result.data;
|
|
1060
|
-
};
|
|
1061
|
-
const getAgentSettings = async (signal) => {
|
|
1062
|
-
const { data } = await genericClient.get("/api/settings", {}, { signal });
|
|
1063
|
-
const result = agentSettingsSchema2.safeParse(data);
|
|
1064
|
-
if (!result.success) {
|
|
1065
|
-
throw new Error("Invalid agent settings response format");
|
|
1066
|
-
}
|
|
1067
|
-
return result.data;
|
|
1068
|
-
};
|
|
1069
|
-
const updateAgentSettings = async (request, signal) => {
|
|
1070
|
-
const { data } = await genericClient.patch(
|
|
1071
|
-
"/api/settings",
|
|
1072
|
-
{ body: request },
|
|
1073
|
-
{ signal }
|
|
1074
|
-
);
|
|
1075
|
-
const result = agentSettingsSchema2.safeParse(data);
|
|
1076
|
-
if (!result.success) {
|
|
1077
|
-
throw new Error("Invalid agent settings response format");
|
|
1078
|
-
}
|
|
1079
|
-
return result.data;
|
|
1080
|
-
};
|
|
1081
|
-
const getUserAgentSettings = async (signal) => {
|
|
1082
|
-
const { data } = await genericClient.get(
|
|
1083
|
-
"/api/settings/user",
|
|
1084
|
-
{},
|
|
1085
|
-
{ signal }
|
|
1086
|
-
);
|
|
1087
|
-
const result = userAgentSettingsSchema2.safeParse(data);
|
|
1088
|
-
if (!result.success) {
|
|
1089
|
-
throw new Error("Invalid user agent settings response format");
|
|
1090
|
-
}
|
|
1091
|
-
return result.data;
|
|
1092
|
-
};
|
|
1093
|
-
const updateUserAgentSettings = async (request, signal) => {
|
|
1094
|
-
const { data } = await genericClient.patch(
|
|
1095
|
-
"/api/settings/user",
|
|
1096
|
-
{ body: request },
|
|
1097
|
-
{ signal }
|
|
1098
|
-
);
|
|
1099
|
-
const result = userAgentSettingsSchema2.safeParse(data);
|
|
1100
|
-
if (!result.success) {
|
|
1101
|
-
throw new Error("Invalid user agent settings response format");
|
|
1102
|
-
}
|
|
1103
|
-
return result.data;
|
|
1104
|
-
};
|
|
1105
|
-
const getToolsList = async (signal) => {
|
|
1106
|
-
const { data } = await genericClient.get(
|
|
1107
|
-
"/api/settings/tools",
|
|
1108
|
-
{},
|
|
1109
|
-
{ signal }
|
|
1110
|
-
);
|
|
1111
|
-
const result = toolsListResponseSchema2.safeParse(data);
|
|
1112
|
-
if (!result.success) {
|
|
1113
|
-
throw new Error("Invalid tools list response format");
|
|
1114
|
-
}
|
|
1115
|
-
return result.data;
|
|
1116
|
-
};
|
|
1117
|
-
const listSandboxFiles = async (chatId, path, signal) => {
|
|
1118
|
-
const { data } = await genericClient.get(
|
|
1119
|
-
`/api/chat/${encodeURIComponent(chatId)}/sandbox/files`,
|
|
1120
|
-
{ query: path ? { path } : void 0 },
|
|
1121
|
-
{ signal }
|
|
1122
|
-
);
|
|
1123
|
-
const result = sandboxFileListingSchema.safeParse(data);
|
|
1124
|
-
if (!result.success) {
|
|
1125
|
-
throw new Error("Invalid sandbox files response format");
|
|
1126
|
-
}
|
|
1127
|
-
return result.data;
|
|
1128
|
-
};
|
|
1129
|
-
const readSandboxFile = async (chatId, path, signal) => {
|
|
1130
|
-
const { data } = await genericClient.get(
|
|
1131
|
-
`/api/chat/${encodeURIComponent(chatId)}/sandbox/file`,
|
|
1132
|
-
{ query: { path } },
|
|
1133
|
-
{ signal }
|
|
1134
|
-
);
|
|
1135
|
-
const result = sandboxFileContentSchema.safeParse(data);
|
|
1136
|
-
if (!result.success) {
|
|
1137
|
-
throw new Error("Invalid sandbox file response format");
|
|
1138
|
-
}
|
|
1139
|
-
return result.data;
|
|
1140
|
-
};
|
|
1141
|
-
const getSandboxGitBranch = async (chatId, signal) => {
|
|
1142
|
-
const { data } = await genericClient.get(
|
|
1143
|
-
`/api/chat/${encodeURIComponent(chatId)}/sandbox/git-branch`,
|
|
1144
|
-
{},
|
|
1145
|
-
{ signal }
|
|
1146
|
-
);
|
|
1147
|
-
const result = sandboxGitBranchSchema.safeParse(data);
|
|
1148
|
-
if (!result.success) {
|
|
1149
|
-
throw new Error("Invalid sandbox git-branch response format");
|
|
1150
|
-
}
|
|
1151
|
-
return result.data;
|
|
1152
|
-
};
|
|
1153
|
-
const chatStreamUrl = baseUrl + "/api/chat";
|
|
1154
|
-
return {
|
|
1155
|
-
getHistory,
|
|
1156
|
-
getChat,
|
|
1157
|
-
deleteChat,
|
|
1158
|
-
createChat,
|
|
1159
|
-
getVotes,
|
|
1160
|
-
submitVote,
|
|
1161
|
-
getUsage,
|
|
1162
|
-
approveToolCall,
|
|
1163
|
-
submitToolOutput,
|
|
1164
|
-
stopChat,
|
|
1165
|
-
getSuggestions,
|
|
1166
|
-
getAgentSettings,
|
|
1167
|
-
updateAgentSettings,
|
|
1168
|
-
getUserAgentSettings,
|
|
1169
|
-
updateUserAgentSettings,
|
|
1170
|
-
getToolsList,
|
|
1171
|
-
listSandboxFiles,
|
|
1172
|
-
readSandboxFile,
|
|
1173
|
-
getSandboxGitBranch,
|
|
1174
|
-
chatStreamUrl
|
|
1175
|
-
};
|
|
1176
|
-
};
|
|
1177
|
-
|
|
1178
|
-
// src/clients/verify/createVerifyClient.ts
|
|
1179
|
-
var createVerifyClient = () => {
|
|
1180
|
-
const storageApiToken = async (host, token, signal) => {
|
|
1181
|
-
const { data } = await createGenericFetchClient({
|
|
1182
|
-
baseUrl: `${host}/v2/storage`,
|
|
1183
|
-
headers: new Headers({ [KeboolaHttpHeader.STORAGE_API_TOKEN]: token })
|
|
1184
|
-
}).get("/tokens/verify", {}, { signal });
|
|
1185
|
-
return data;
|
|
1186
|
-
};
|
|
1187
|
-
const managementApiToken = async (host, token, signal) => {
|
|
1188
|
-
const { data } = await createGenericFetchClient({
|
|
1189
|
-
baseUrl: host,
|
|
1190
|
-
headers: new Headers({ [KeboolaHttpHeader.MANAGEMENT_API_TOKEN]: token })
|
|
1191
|
-
}).get("/manage/tokens/verify", {}, { signal });
|
|
1192
|
-
return data;
|
|
1193
|
-
};
|
|
1194
|
-
return {
|
|
1195
|
-
storageApiToken,
|
|
1196
|
-
managementApiToken
|
|
1197
|
-
};
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
|
-
// src/clients/management/authMiddleware.ts
|
|
1201
|
-
var TOKEN_CACHE_TTL_MS = 6e4;
|
|
1202
|
-
var isManagementClientAuthError = (error) => error instanceof ManagementClientAuthError;
|
|
1203
|
-
var createAuth = (baseUrl) => {
|
|
1204
|
-
const fetchClient = createGenericFetchClient({ baseUrl });
|
|
1205
|
-
const createCurrentUserSessionToken = async (accessToken) => {
|
|
1206
|
-
const headers = new Headers({ [KeboolaHttpHeader.MANAGEMENT_API_TOKEN]: accessToken });
|
|
1207
|
-
const { data } = await fetchClient.post(
|
|
1208
|
-
"/manage/current-user/session-token",
|
|
1209
|
-
{},
|
|
1210
|
-
{ headers }
|
|
1211
|
-
);
|
|
1212
|
-
return data.token;
|
|
1213
|
-
};
|
|
1214
|
-
const createAdminAccountSessionToken = async () => {
|
|
1215
|
-
const { data } = await fetchClient.post(
|
|
1216
|
-
"/admin/account/session-token",
|
|
1217
|
-
{},
|
|
1218
|
-
{
|
|
1219
|
-
// transform valid response, to invalid and throw custom error
|
|
1220
|
-
validateStatus: (apiResponse) => {
|
|
1221
|
-
const { response } = apiResponse;
|
|
1222
|
-
const isTextContent = response.headers.get(HttpHeader.CONTENT_TYPE)?.includes(HttpContentType.TEXT_HTML);
|
|
1223
|
-
if (isTextContent)
|
|
1224
|
-
return new ManagementClientAuthError(
|
|
1225
|
-
"Your session expired",
|
|
1226
|
-
"You will be logged out automatically.",
|
|
1227
|
-
apiResponse
|
|
1228
|
-
);
|
|
1229
|
-
return defaultValidateStatus(apiResponse);
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
);
|
|
1233
|
-
return data.token;
|
|
1234
|
-
};
|
|
1235
|
-
return {
|
|
1236
|
-
createCurrentUserSessionToken,
|
|
1237
|
-
createAdminAccountSessionToken
|
|
1238
|
-
};
|
|
1239
|
-
};
|
|
1240
|
-
var createAuthMiddleware = ({
|
|
1241
|
-
accessToken,
|
|
1242
|
-
baseUrl
|
|
1243
|
-
}) => {
|
|
1244
|
-
const auth = createAuth(baseUrl);
|
|
1245
|
-
const verify = createVerifyClient();
|
|
1246
|
-
let token = accessToken;
|
|
1247
|
-
let tokenValidUntil = 0;
|
|
1248
|
-
let inflightAuth = null;
|
|
1249
|
-
const isDevelopment = process.env.NODE_ENV === "development";
|
|
1250
|
-
const ensureValidToken = async () => {
|
|
1251
|
-
if (token && Date.now() < tokenValidUntil) return token;
|
|
1252
|
-
if (token) {
|
|
1253
|
-
const tokenInfo = await verify.managementApiToken(baseUrl, token);
|
|
1254
|
-
const isTokenValid = !tokenInfo.isDisabled && !tokenInfo.isExpired;
|
|
1255
|
-
if (isTokenValid) {
|
|
1256
|
-
tokenValidUntil = Date.now() + TOKEN_CACHE_TTL_MS;
|
|
1257
|
-
return token;
|
|
1258
|
-
}
|
|
1259
|
-
token = isDevelopment ? await auth.createCurrentUserSessionToken(token) : await auth.createAdminAccountSessionToken();
|
|
1260
|
-
tokenValidUntil = Date.now() + TOKEN_CACHE_TTL_MS;
|
|
1261
|
-
return token;
|
|
1262
|
-
}
|
|
1263
|
-
token = await auth.createAdminAccountSessionToken();
|
|
1264
|
-
tokenValidUntil = Date.now() + TOKEN_CACHE_TTL_MS;
|
|
1265
|
-
return token;
|
|
1266
|
-
};
|
|
1267
|
-
return (next) => async (request) => {
|
|
1268
|
-
if (!inflightAuth) {
|
|
1269
|
-
inflightAuth = ensureValidToken().finally(() => {
|
|
1270
|
-
inflightAuth = null;
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
const validToken = await inflightAuth;
|
|
1274
|
-
request.request.headers.set(KeboolaHttpHeader.MANAGEMENT_API_TOKEN, validToken);
|
|
1275
|
-
return next(request);
|
|
1276
|
-
};
|
|
1277
|
-
};
|
|
1278
|
-
|
|
1279
|
-
// src/clients/management/currentUser/currentUser.ts
|
|
1280
|
-
var createCurrentUser = (client) => {
|
|
1281
|
-
const getMaintainerInvitations = async (signal) => {
|
|
1282
|
-
const { data } = await client.get(
|
|
1283
|
-
"/manage/current-user/maintainers-invitations",
|
|
1284
|
-
{},
|
|
1285
|
-
{ signal }
|
|
1286
|
-
);
|
|
1287
|
-
return data;
|
|
1288
|
-
};
|
|
1289
|
-
const getMaintainerInvitation = async (id, signal) => {
|
|
1290
|
-
const { data } = await client.get(
|
|
1291
|
-
"/manage/current-user/maintainers-invitations/{id}",
|
|
1292
|
-
{ path: { id } },
|
|
1293
|
-
{ signal }
|
|
1294
|
-
);
|
|
1295
|
-
return data;
|
|
1296
|
-
};
|
|
1297
|
-
const acceptMaintainerInvitation = async (id) => {
|
|
1298
|
-
await client.put("/manage/current-user/maintainers-invitations/{id}", { path: { id } });
|
|
1299
|
-
};
|
|
1300
|
-
const rejectMaintainerInvitation = async (id) => {
|
|
1301
|
-
await client.delete("/manage/current-user/maintainers-invitations/{id}", { path: { id } });
|
|
1302
|
-
};
|
|
1303
|
-
const getOrganizationInvitations = async (signal) => {
|
|
1304
|
-
const { data } = await client.get(
|
|
1305
|
-
"/manage/current-user/organizations-invitations",
|
|
1306
|
-
{},
|
|
1307
|
-
{ signal }
|
|
1308
|
-
);
|
|
1309
|
-
return data;
|
|
1310
|
-
};
|
|
1311
|
-
const getOrganizationInvitation = async (id, signal) => {
|
|
1312
|
-
const { data } = await client.get(
|
|
1313
|
-
"/manage/current-user/organizations-invitations/{id}",
|
|
1314
|
-
{ path: { id } },
|
|
1315
|
-
{ signal }
|
|
1316
|
-
);
|
|
1317
|
-
return data;
|
|
1318
|
-
};
|
|
1319
|
-
const acceptOrganizationInvitation = async (id) => {
|
|
1320
|
-
await client.put("/manage/current-user/organizations-invitations/{id}", { path: { id } });
|
|
1321
|
-
};
|
|
1322
|
-
const rejectOrganizationInvitation = async (id) => {
|
|
1323
|
-
await client.delete("/manage/current-user/organizations-invitations/{id}", { path: { id } });
|
|
1324
|
-
};
|
|
1325
|
-
const getProjectInvitations = async (signal) => {
|
|
1326
|
-
const { data } = await client.get("/manage/current-user/projects-invitations", {}, { signal });
|
|
1327
|
-
return data;
|
|
1328
|
-
};
|
|
1329
|
-
const getProjectInvitation = async (id, signal) => {
|
|
1330
|
-
const { data } = await client.get(
|
|
1331
|
-
"/manage/current-user/projects-invitations/{id}",
|
|
1332
|
-
{ path: { id } },
|
|
1333
|
-
{ signal }
|
|
1334
|
-
);
|
|
1335
|
-
return data;
|
|
1336
|
-
};
|
|
1337
|
-
const acceptProjectInvitation = async (id) => {
|
|
1338
|
-
await client.put("/manage/current-user/projects-invitations/{id}", { path: { id } });
|
|
1339
|
-
};
|
|
1340
|
-
const rejectProjectInvitation = async (id) => {
|
|
1341
|
-
await client.delete("/manage/current-user/projects-invitations/{id}", { path: { id } });
|
|
1342
|
-
};
|
|
1343
|
-
const getProjectJoinRequests = async (signal) => {
|
|
1344
|
-
const { data } = await client.get(
|
|
1345
|
-
"/manage/current-user/projects-join-requests",
|
|
1346
|
-
{},
|
|
1347
|
-
{ signal }
|
|
1348
|
-
);
|
|
1349
|
-
return data;
|
|
1350
|
-
};
|
|
1351
|
-
const deleteProjectJoinRequest = async (id) => {
|
|
1352
|
-
await client.delete("/manage/current-user/projects-join-requests/{id}", { path: { id } });
|
|
1353
|
-
};
|
|
1354
|
-
return {
|
|
1355
|
-
getMaintainerInvitations,
|
|
1356
|
-
getMaintainerInvitation,
|
|
1357
|
-
acceptMaintainerInvitation,
|
|
1358
|
-
rejectMaintainerInvitation,
|
|
1359
|
-
getOrganizationInvitations,
|
|
1360
|
-
getOrganizationInvitation,
|
|
1361
|
-
acceptOrganizationInvitation,
|
|
1362
|
-
rejectOrganizationInvitation,
|
|
1363
|
-
getProjectInvitations,
|
|
1364
|
-
getProjectInvitation,
|
|
1365
|
-
acceptProjectInvitation,
|
|
1366
|
-
rejectProjectInvitation,
|
|
1367
|
-
getProjectJoinRequests,
|
|
1368
|
-
deleteProjectJoinRequest
|
|
1369
|
-
};
|
|
1370
|
-
};
|
|
1371
|
-
|
|
1372
|
-
// src/clients/management/features/features.ts
|
|
1373
|
-
var createFeatures = (client) => {
|
|
1374
|
-
const getAllFeatures = async (query, signal) => {
|
|
1375
|
-
const { data } = await client.get(
|
|
1376
|
-
"/features",
|
|
1377
|
-
{ query },
|
|
1378
|
-
{ signal }
|
|
1379
|
-
);
|
|
1380
|
-
return data;
|
|
1381
|
-
};
|
|
1382
|
-
return {
|
|
1383
|
-
getAllFeatures
|
|
1384
|
-
};
|
|
1385
|
-
};
|
|
1386
|
-
|
|
1387
|
-
// src/clients/management/maintainers/maintainers.ts
|
|
1388
|
-
var createMaintainers = (client) => {
|
|
1389
|
-
const getMaintainers = async (signal) => {
|
|
1390
|
-
const { data } = await client.get("/manage/maintainers", {}, { signal });
|
|
1391
|
-
return data;
|
|
1392
|
-
};
|
|
1393
|
-
const getMaintainer = async (maintainerId, signal) => {
|
|
1394
|
-
const { data } = await client.get(
|
|
1395
|
-
"/manage/maintainers/{id}",
|
|
1396
|
-
{ path: { id: maintainerId } },
|
|
1397
|
-
{ signal }
|
|
1398
|
-
);
|
|
1399
|
-
return data;
|
|
1400
|
-
};
|
|
1401
|
-
const createMaintainer = async (body) => {
|
|
1402
|
-
const { data } = await client.post("/manage/maintainers", { body });
|
|
1403
|
-
return data;
|
|
1404
|
-
};
|
|
1405
|
-
const updateMaintainer = async ({
|
|
1406
|
-
maintainerId,
|
|
1407
|
-
...body
|
|
1408
|
-
}) => {
|
|
1409
|
-
const { data } = await client.patch("/manage/maintainers/{id}", {
|
|
1410
|
-
path: { id: maintainerId },
|
|
1411
|
-
body
|
|
1412
|
-
});
|
|
1413
|
-
return data;
|
|
1414
|
-
};
|
|
1415
|
-
const deleteMaintainer = async (maintainerId) => {
|
|
1416
|
-
await client.delete("/manage/maintainers/{id}", { path: { id: maintainerId } });
|
|
1417
|
-
};
|
|
1418
|
-
const getMaintainerUsers = async (maintainerId, signal) => {
|
|
1419
|
-
const { data } = await client.get(
|
|
1420
|
-
"/manage/maintainers/{id}/users",
|
|
1421
|
-
{ path: { id: maintainerId } },
|
|
1422
|
-
{ signal }
|
|
1423
|
-
);
|
|
1424
|
-
return data;
|
|
1425
|
-
};
|
|
1426
|
-
const addMaintainerUser = async ({
|
|
1427
|
-
maintainerId,
|
|
1428
|
-
...body
|
|
1429
|
-
}) => {
|
|
1430
|
-
const { data } = await client.post("/manage/maintainers/{id}/users", {
|
|
1431
|
-
path: { id: maintainerId },
|
|
1432
|
-
body
|
|
1433
|
-
});
|
|
1434
|
-
return data;
|
|
1435
|
-
};
|
|
1436
|
-
const removeMaintainerUser = async ({
|
|
1437
|
-
maintainerId,
|
|
1438
|
-
adminId
|
|
1439
|
-
}) => {
|
|
1440
|
-
await client.delete("/manage/maintainers/{id}/users/{adminId}", {
|
|
1441
|
-
path: { id: maintainerId, adminId }
|
|
1442
|
-
});
|
|
1443
|
-
};
|
|
1444
|
-
const getMaintainerInvitations = async (maintainerId, signal) => {
|
|
1445
|
-
const { data } = await client.get(
|
|
1446
|
-
"/manage/maintainers/{id}/invitations",
|
|
1447
|
-
{ path: { id: maintainerId } },
|
|
1448
|
-
{ signal }
|
|
1449
|
-
);
|
|
1450
|
-
return data;
|
|
1451
|
-
};
|
|
1452
|
-
const getMaintainerInvitation = async ({ maintainerId, invitationId }, signal) => {
|
|
1453
|
-
const { data } = await client.get(
|
|
1454
|
-
"/manage/maintainers/{id}/invitations/{invitationId}",
|
|
1455
|
-
{ path: { id: maintainerId, invitationId } },
|
|
1456
|
-
{ signal }
|
|
1457
|
-
);
|
|
1458
|
-
return data;
|
|
1459
|
-
};
|
|
1460
|
-
const createMaintainerInvitation = async ({
|
|
1461
|
-
maintainerId,
|
|
1462
|
-
...body
|
|
1463
|
-
}) => {
|
|
1464
|
-
const { data } = await client.post("/manage/maintainers/{id}/invitations", {
|
|
1465
|
-
path: { id: maintainerId },
|
|
1466
|
-
body
|
|
1467
|
-
});
|
|
1468
|
-
return data;
|
|
1469
|
-
};
|
|
1470
|
-
const deleteMaintainerInvitation = async ({
|
|
1471
|
-
maintainerId,
|
|
1472
|
-
invitationId
|
|
1473
|
-
}) => {
|
|
1474
|
-
await client.delete("/manage/maintainers/{id}/invitations/{invitationId}", {
|
|
1475
|
-
path: { id: maintainerId, invitationId }
|
|
1476
|
-
});
|
|
1477
|
-
};
|
|
1478
|
-
const createMaintainerOrganization = async ({
|
|
1479
|
-
maintainerId,
|
|
1480
|
-
...body
|
|
1481
|
-
}) => {
|
|
1482
|
-
const { data } = await client.post("/manage/maintainers/{id}/organizations", {
|
|
1483
|
-
path: { id: maintainerId },
|
|
1484
|
-
body
|
|
1485
|
-
});
|
|
1486
|
-
return data;
|
|
1487
|
-
};
|
|
1488
|
-
const getMaintainerMetadata = async (maintainerId, signal) => {
|
|
1489
|
-
const { data } = await client.get(
|
|
1490
|
-
"/manage/maintainers/{id}/metadata",
|
|
1491
|
-
{ path: { id: maintainerId } },
|
|
1492
|
-
{ signal }
|
|
1493
|
-
);
|
|
1494
|
-
return data;
|
|
1495
|
-
};
|
|
1496
|
-
const setMaintainerMetadata = async ({
|
|
1497
|
-
maintainerId,
|
|
1498
|
-
...body
|
|
1499
|
-
}) => {
|
|
1500
|
-
const { data } = await client.post("/manage/maintainers/{id}/metadata", {
|
|
1501
|
-
path: { id: maintainerId },
|
|
1502
|
-
body
|
|
1503
|
-
});
|
|
1504
|
-
return data;
|
|
1505
|
-
};
|
|
1506
|
-
const deleteMaintainerMetadata = async ({
|
|
1507
|
-
maintainerId,
|
|
1508
|
-
metadataId
|
|
1509
|
-
}) => {
|
|
1510
|
-
await client.delete("/manage/maintainers/{id}/metadata/{metadataId}", {
|
|
1511
|
-
path: { id: maintainerId, metadataId }
|
|
1512
|
-
});
|
|
1513
|
-
};
|
|
1514
|
-
return {
|
|
1515
|
-
getMaintainers,
|
|
1516
|
-
getMaintainer,
|
|
1517
|
-
createMaintainer,
|
|
1518
|
-
updateMaintainer,
|
|
1519
|
-
deleteMaintainer,
|
|
1520
|
-
getMaintainerUsers,
|
|
1521
|
-
addMaintainerUser,
|
|
1522
|
-
removeMaintainerUser,
|
|
1523
|
-
getMaintainerInvitations,
|
|
1524
|
-
getMaintainerInvitation,
|
|
1525
|
-
createMaintainerInvitation,
|
|
1526
|
-
deleteMaintainerInvitation,
|
|
1527
|
-
createMaintainerOrganization,
|
|
1528
|
-
getMaintainerMetadata,
|
|
1529
|
-
setMaintainerMetadata,
|
|
1530
|
-
deleteMaintainerMetadata
|
|
1531
|
-
};
|
|
1532
|
-
};
|
|
1533
|
-
|
|
1534
|
-
// src/clients/management/organizations/organizations.ts
|
|
1535
|
-
var createOrganizations = (client) => {
|
|
1536
|
-
const getOrganizations = async (signal) => {
|
|
1537
|
-
const { data } = await client.get("/manage/organizations", {}, { signal });
|
|
1538
|
-
return data;
|
|
1539
|
-
};
|
|
1540
|
-
const getOrganization = async (organizationId, signal) => {
|
|
1541
|
-
const { data } = await client.get(
|
|
1542
|
-
"/manage/organizations/{id}",
|
|
1543
|
-
{ path: { id: organizationId } },
|
|
1544
|
-
{ signal }
|
|
1545
|
-
);
|
|
1546
|
-
return data;
|
|
1547
|
-
};
|
|
1548
|
-
const updateOrganization = async ({
|
|
1549
|
-
organizationId,
|
|
1550
|
-
...body
|
|
1551
|
-
}) => {
|
|
1552
|
-
const { data } = await client.patch("/manage/organizations/{id}", {
|
|
1553
|
-
path: { id: organizationId },
|
|
1554
|
-
body
|
|
1555
|
-
});
|
|
1556
|
-
return data;
|
|
1557
|
-
};
|
|
1558
|
-
const deleteOrganization = async (organizationId) => {
|
|
1559
|
-
await client.delete("/manage/organizations/{id}", { path: { id: organizationId } });
|
|
1560
|
-
};
|
|
1561
|
-
const forceMfa = async (organizationId) => {
|
|
1562
|
-
const { data } = await client.patch("/manage/organizations/{id}/force-mfa", {
|
|
1563
|
-
path: { id: organizationId }
|
|
1564
|
-
});
|
|
1565
|
-
return data;
|
|
1566
|
-
};
|
|
1567
|
-
const joinOrganization = async (organizationId) => {
|
|
1568
|
-
await client.post("/manage/organizations/{id}/join-organization", {
|
|
1569
|
-
path: { id: organizationId }
|
|
1570
|
-
});
|
|
1571
|
-
};
|
|
1572
|
-
const getOrganizationUsers = async (organizationId, signal) => {
|
|
1573
|
-
const { data } = await client.get(
|
|
1574
|
-
"/manage/organizations/{id}/users",
|
|
1575
|
-
{ path: { id: organizationId } },
|
|
1576
|
-
{ signal }
|
|
1577
|
-
);
|
|
1578
|
-
return data;
|
|
1579
|
-
};
|
|
1580
|
-
const addOrganizationUser = async ({
|
|
1581
|
-
organizationId,
|
|
1582
|
-
...body
|
|
1583
|
-
}) => {
|
|
1584
|
-
const { data } = await client.post("/manage/organizations/{id}/users", {
|
|
1585
|
-
path: { id: organizationId },
|
|
1586
|
-
body
|
|
1587
|
-
});
|
|
1588
|
-
return data;
|
|
1589
|
-
};
|
|
1590
|
-
const removeOrganizationUser = async ({
|
|
1591
|
-
organizationId,
|
|
1592
|
-
userId
|
|
1593
|
-
}) => {
|
|
1594
|
-
await client.delete("/manage/organizations/{id}/users/{userId}", {
|
|
1595
|
-
path: { id: organizationId, userId }
|
|
1596
|
-
});
|
|
1597
|
-
};
|
|
1598
|
-
const getOrganizationProjectsUsers = async (organizationId, signal) => {
|
|
1599
|
-
const { data } = await client.get(
|
|
1600
|
-
"/manage/organizations/{id}/projects-users",
|
|
1601
|
-
{ path: { id: organizationId } },
|
|
1602
|
-
{ signal }
|
|
1603
|
-
);
|
|
1604
|
-
return data;
|
|
1605
|
-
};
|
|
1606
|
-
const getOrganizationInvitations = async (organizationId, signal) => {
|
|
1607
|
-
const { data } = await client.get(
|
|
1608
|
-
"/manage/organizations/{id}/invitations",
|
|
1609
|
-
{ path: { id: organizationId } },
|
|
1610
|
-
{ signal }
|
|
1611
|
-
);
|
|
1612
|
-
return data;
|
|
1613
|
-
};
|
|
1614
|
-
const getOrganizationInvitation = async ({ organizationId, invitationId }, signal) => {
|
|
1615
|
-
const { data } = await client.get(
|
|
1616
|
-
"/manage/organizations/{id}/invitations/{invitationId}",
|
|
1617
|
-
{ path: { id: organizationId, invitationId } },
|
|
1618
|
-
{ signal }
|
|
1619
|
-
);
|
|
1620
|
-
return data;
|
|
1621
|
-
};
|
|
1622
|
-
const createOrganizationInvitation = async ({
|
|
1623
|
-
organizationId,
|
|
1624
|
-
...body
|
|
1625
|
-
}) => {
|
|
1626
|
-
const { data } = await client.post("/manage/organizations/{id}/invitations", {
|
|
1627
|
-
path: { id: organizationId },
|
|
1628
|
-
body
|
|
1629
|
-
});
|
|
1630
|
-
return data;
|
|
1631
|
-
};
|
|
1632
|
-
const deleteOrganizationInvitation = async ({
|
|
1633
|
-
organizationId,
|
|
1634
|
-
invitationId
|
|
1635
|
-
}) => {
|
|
1636
|
-
await client.delete("/manage/organizations/{id}/invitations/{invitationId}", {
|
|
1637
|
-
path: { id: organizationId, invitationId }
|
|
1638
|
-
});
|
|
1639
|
-
};
|
|
1640
|
-
const getOrganizationProjects = async (organizationId, signal) => {
|
|
1641
|
-
const { data } = await client.get(
|
|
1642
|
-
"/manage/organizations/{id}/projects",
|
|
1643
|
-
{ path: { id: organizationId } },
|
|
1644
|
-
{ signal }
|
|
1645
|
-
);
|
|
1646
|
-
return data;
|
|
1647
|
-
};
|
|
1648
|
-
const createOrganizationProject = async ({
|
|
1649
|
-
organizationId,
|
|
1650
|
-
...body
|
|
1651
|
-
}) => {
|
|
1652
|
-
const { data } = await client.post("/manage/organizations/{id}/projects", {
|
|
1653
|
-
path: { id: organizationId },
|
|
1654
|
-
body
|
|
1655
|
-
});
|
|
1656
|
-
return data;
|
|
1657
|
-
};
|
|
1658
|
-
const getOrganizationMetadata = async (organizationId, signal) => {
|
|
1659
|
-
const { data } = await client.get(
|
|
1660
|
-
"/manage/organizations/{id}/metadata",
|
|
1661
|
-
{ path: { id: organizationId } },
|
|
1662
|
-
{ signal }
|
|
1663
|
-
);
|
|
1664
|
-
return data;
|
|
1665
|
-
};
|
|
1666
|
-
const setOrganizationMetadata = async ({
|
|
1667
|
-
organizationId,
|
|
1668
|
-
...body
|
|
1669
|
-
}) => {
|
|
1670
|
-
const { data } = await client.post("/manage/organizations/{id}/metadata", {
|
|
1671
|
-
path: { id: organizationId },
|
|
1672
|
-
body
|
|
1673
|
-
});
|
|
1674
|
-
return data;
|
|
1675
|
-
};
|
|
1676
|
-
const deleteOrganizationMetadata = async ({
|
|
1677
|
-
organizationId,
|
|
1678
|
-
metadataId
|
|
1679
|
-
}) => {
|
|
1680
|
-
await client.delete("/manage/organizations/{id}/metadata/{metadataId}", {
|
|
1681
|
-
path: { id: organizationId, metadataId }
|
|
1682
|
-
});
|
|
1683
|
-
};
|
|
1684
|
-
return {
|
|
1685
|
-
getOrganizations,
|
|
1686
|
-
getOrganization,
|
|
1687
|
-
updateOrganization,
|
|
1688
|
-
deleteOrganization,
|
|
1689
|
-
forceMfa,
|
|
1690
|
-
joinOrganization,
|
|
1691
|
-
getOrganizationUsers,
|
|
1692
|
-
addOrganizationUser,
|
|
1693
|
-
removeOrganizationUser,
|
|
1694
|
-
getOrganizationProjectsUsers,
|
|
1695
|
-
getOrganizationInvitations,
|
|
1696
|
-
getOrganizationInvitation,
|
|
1697
|
-
createOrganizationInvitation,
|
|
1698
|
-
deleteOrganizationInvitation,
|
|
1699
|
-
getOrganizationProjects,
|
|
1700
|
-
createOrganizationProject,
|
|
1701
|
-
getOrganizationMetadata,
|
|
1702
|
-
setOrganizationMetadata,
|
|
1703
|
-
deleteOrganizationMetadata
|
|
1704
|
-
};
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
|
-
// src/clients/management/projects/projects.ts
|
|
1708
|
-
var createProjects = (client) => {
|
|
1709
|
-
const getProject = async (projectId, signal) => {
|
|
1710
|
-
const { data } = await client.get(
|
|
1711
|
-
"/projects/{projectId}",
|
|
1712
|
-
{ path: { projectId } },
|
|
1713
|
-
{ signal }
|
|
1714
|
-
);
|
|
1715
|
-
return data;
|
|
1716
|
-
};
|
|
1717
|
-
const addProjectFeature = async ({
|
|
1718
|
-
projectId,
|
|
1719
|
-
feature
|
|
1720
|
-
}) => {
|
|
1721
|
-
const { data } = await client.post("/projects/{projectId}/features", { path: { projectId }, body: { feature } });
|
|
1722
|
-
return data;
|
|
1723
|
-
};
|
|
1724
|
-
const removeProjectFeature = async (path) => {
|
|
1725
|
-
const { data } = await client.delete(
|
|
1726
|
-
"/projects/{projectId}/features/{feature}",
|
|
1727
|
-
{ path }
|
|
1728
|
-
);
|
|
1729
|
-
return data;
|
|
1730
|
-
};
|
|
1731
|
-
const changeProjectUserRole = async ({
|
|
1732
|
-
projectId,
|
|
1733
|
-
userId,
|
|
1734
|
-
role
|
|
1735
|
-
}) => {
|
|
1736
|
-
const { data } = await client.patch("/projects/{projectId}/users/{userId}", {
|
|
1737
|
-
path: { projectId, userId },
|
|
1738
|
-
body: { role }
|
|
1739
|
-
});
|
|
1740
|
-
return data;
|
|
1741
|
-
};
|
|
1742
|
-
const getProjectUsers = async (projectId, signal) => {
|
|
1743
|
-
const { data } = await client.get(
|
|
1744
|
-
"/projects/{projectId}/users",
|
|
1745
|
-
{ path: { projectId } },
|
|
1746
|
-
{ signal }
|
|
1747
|
-
);
|
|
1748
|
-
return data;
|
|
1749
|
-
};
|
|
1750
|
-
const getProjectMetadata = async (projectId, signal) => {
|
|
1751
|
-
const { data } = await client.get(
|
|
1752
|
-
"/projects/{projectId}/metadata",
|
|
1753
|
-
{ path: { projectId } },
|
|
1754
|
-
{ signal }
|
|
1755
|
-
);
|
|
1756
|
-
return data;
|
|
1757
|
-
};
|
|
1758
|
-
const setProjectMetadata = async ({
|
|
1759
|
-
projectId,
|
|
1760
|
-
provider,
|
|
1761
|
-
metadata
|
|
1762
|
-
}) => {
|
|
1763
|
-
const { data } = await client.post("/projects/{projectId}/metadata", {
|
|
1764
|
-
path: { projectId },
|
|
1765
|
-
body: { provider, metadata }
|
|
1766
|
-
});
|
|
1767
|
-
return data;
|
|
1768
|
-
};
|
|
1769
|
-
const getProjectReviewers = async (projectId, signal) => {
|
|
1770
|
-
const { data } = await client.get(
|
|
1771
|
-
"/projects/{projectId}/reviewers",
|
|
1772
|
-
{ path: { projectId } },
|
|
1773
|
-
{ signal }
|
|
1774
|
-
);
|
|
1775
|
-
return data;
|
|
1776
|
-
};
|
|
1777
|
-
const setProjectReviewers = async ({
|
|
1778
|
-
projectId,
|
|
1779
|
-
adminIds
|
|
1780
|
-
}) => {
|
|
1781
|
-
const { data } = await client.put("/projects/{projectId}/reviewers", {
|
|
1782
|
-
path: { projectId },
|
|
1783
|
-
body: { adminIds }
|
|
1784
|
-
});
|
|
1785
|
-
return data;
|
|
1786
|
-
};
|
|
1787
|
-
return {
|
|
1788
|
-
getProject,
|
|
1789
|
-
addProjectFeature,
|
|
1790
|
-
removeProjectFeature,
|
|
1791
|
-
changeProjectUserRole,
|
|
1792
|
-
getProjectUsers,
|
|
1793
|
-
getProjectMetadata,
|
|
1794
|
-
setProjectMetadata,
|
|
1795
|
-
getProjectReviewers,
|
|
1796
|
-
setProjectReviewers
|
|
1797
|
-
};
|
|
1798
|
-
};
|
|
1799
|
-
|
|
1800
|
-
// src/clients/management/users/users.ts
|
|
1801
|
-
var createUsers = (client) => {
|
|
1802
|
-
const addUserAdminFeature = async ({ feature, userIdOrMail }, signal) => {
|
|
1803
|
-
const { data } = await client.post(
|
|
1804
|
-
"/users/{userIdOrMail}/features",
|
|
1805
|
-
{ path: { userIdOrMail: encodeURIComponent(userIdOrMail) }, body: { feature } },
|
|
1806
|
-
{ signal }
|
|
1807
|
-
);
|
|
1808
|
-
return data;
|
|
1809
|
-
};
|
|
1810
|
-
const removeUserAdminFeature = async ({ userIdOrMail, feature }, signal) => {
|
|
1811
|
-
const { data } = await client.delete(
|
|
1812
|
-
"/users/{userIdOrMail}/features/{feature}",
|
|
1813
|
-
{ path: { userIdOrMail: encodeURIComponent(userIdOrMail), feature } },
|
|
1814
|
-
{ signal }
|
|
1815
|
-
);
|
|
1816
|
-
return data;
|
|
1817
|
-
};
|
|
1818
|
-
return {
|
|
1819
|
-
addUserAdminFeature,
|
|
1820
|
-
removeUserAdminFeature
|
|
1821
|
-
};
|
|
1822
|
-
};
|
|
1823
|
-
|
|
1824
|
-
// src/clients/management/managementClient.ts
|
|
1825
|
-
var createManagementClient = ({
|
|
1826
|
-
baseUrl,
|
|
1827
|
-
callbacks,
|
|
1828
|
-
token
|
|
1829
|
-
}) => {
|
|
1830
|
-
const callbackMiddleware = createCallbackMiddleware(callbacks);
|
|
1831
|
-
const authMiddleware = createAuthMiddleware({
|
|
1832
|
-
baseUrl,
|
|
1833
|
-
accessToken: token
|
|
1834
|
-
});
|
|
1835
|
-
const middlewares = [
|
|
1836
|
-
callbackMiddleware,
|
|
1837
|
-
authMiddleware
|
|
1838
|
-
// 👈 beware order of middlewares always matter
|
|
1839
|
-
];
|
|
1840
|
-
const client = createGenericFetchClient({
|
|
1841
|
-
baseUrl: `${baseUrl}/manage`,
|
|
1842
|
-
middlewares
|
|
1843
|
-
});
|
|
1844
|
-
const openApiClient = createOpenapiFetchClient({
|
|
1845
|
-
baseUrl,
|
|
1846
|
-
middlewares
|
|
1847
|
-
});
|
|
1848
|
-
const verifyToken = async (signal) => {
|
|
1849
|
-
const { data } = await openApiClient.get("/manage/tokens/verify", {}, { signal });
|
|
1850
|
-
return data;
|
|
1851
|
-
};
|
|
1852
|
-
return {
|
|
1853
|
-
currentUser: createCurrentUser(openApiClient),
|
|
1854
|
-
features: createFeatures(client),
|
|
1855
|
-
maintainers: createMaintainers(openApiClient),
|
|
1856
|
-
organizations: createOrganizations(openApiClient),
|
|
1857
|
-
projects: createProjects(client),
|
|
1858
|
-
users: createUsers(client),
|
|
1859
|
-
verifyToken
|
|
1860
|
-
};
|
|
1861
|
-
};
|
|
1862
|
-
|
|
1863
|
-
// src/clients/metastore/repository/repository.ts
|
|
1864
|
-
var createRepository = (client) => {
|
|
1865
|
-
const getMetaObjects = async (input, signal) => {
|
|
1866
|
-
const { data } = await client.get(
|
|
1867
|
-
"/api/v1/repository/{objectType}",
|
|
1868
|
-
{
|
|
1869
|
-
path: input
|
|
1870
|
-
},
|
|
1871
|
-
{ signal }
|
|
1872
|
-
);
|
|
1873
|
-
return data;
|
|
1874
|
-
};
|
|
1875
|
-
const getMetaObjectRevisions = async (input, signal) => {
|
|
1876
|
-
const { data } = await client.get(
|
|
1877
|
-
"/api/v1/repository/{objectType}/revisions",
|
|
1878
|
-
{
|
|
1879
|
-
path: input
|
|
1880
|
-
},
|
|
1881
|
-
{ signal }
|
|
1882
|
-
);
|
|
1883
|
-
return data;
|
|
1884
|
-
};
|
|
1885
|
-
const getMetaObject = async (input, signal) => {
|
|
1886
|
-
const { data } = await client.get(
|
|
1887
|
-
"/api/v1/repository/{objectType}/{UUID}",
|
|
1888
|
-
{
|
|
1889
|
-
path: input
|
|
1890
|
-
},
|
|
1891
|
-
{
|
|
1892
|
-
signal
|
|
1893
|
-
}
|
|
1894
|
-
);
|
|
1895
|
-
return data;
|
|
1896
|
-
};
|
|
1897
|
-
const createMetaObject = async ({
|
|
1898
|
-
objectType,
|
|
1899
|
-
data,
|
|
1900
|
-
...body
|
|
1901
|
-
}) => {
|
|
1902
|
-
const { data: createdMetaObject } = await client.post("/api/v1/repository/{objectType}", {
|
|
1903
|
-
path: { objectType },
|
|
1904
|
-
body: {
|
|
1905
|
-
data,
|
|
1906
|
-
...body
|
|
1907
|
-
}
|
|
1908
|
-
});
|
|
1909
|
-
return createdMetaObject;
|
|
1910
|
-
};
|
|
1911
|
-
const deleteMetaObject = async (input) => {
|
|
1912
|
-
const { data } = await client.delete("/api/v1/repository/{objectType}/{UUID}", {
|
|
1913
|
-
path: input
|
|
1914
|
-
});
|
|
1915
|
-
return data;
|
|
1916
|
-
};
|
|
1917
|
-
const updateMetaObject = async ({
|
|
1918
|
-
objectType,
|
|
1919
|
-
UUID,
|
|
1920
|
-
data,
|
|
1921
|
-
...body
|
|
1922
|
-
}) => {
|
|
1923
|
-
const { data: updatedMetaObject } = await client.patch(
|
|
1924
|
-
"/api/v1/repository/{objectType}/{UUID}",
|
|
1925
|
-
{
|
|
1926
|
-
path: {
|
|
1927
|
-
objectType,
|
|
1928
|
-
UUID
|
|
1929
|
-
},
|
|
1930
|
-
body: {
|
|
1931
|
-
data,
|
|
1932
|
-
...body
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
);
|
|
1936
|
-
return updatedMetaObject;
|
|
1937
|
-
};
|
|
1938
|
-
const replaceMetaObject = async ({
|
|
1939
|
-
objectType,
|
|
1940
|
-
UUID,
|
|
1941
|
-
data,
|
|
1942
|
-
...body
|
|
1943
|
-
}) => {
|
|
1944
|
-
const { data: replacedMetaObject } = await client.put(
|
|
1945
|
-
"/api/v1/repository/{objectType}/{UUID}",
|
|
1946
|
-
{
|
|
1947
|
-
path: {
|
|
1948
|
-
objectType,
|
|
1949
|
-
UUID
|
|
1950
|
-
},
|
|
1951
|
-
body: {
|
|
1952
|
-
data,
|
|
1953
|
-
...body
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
);
|
|
1957
|
-
return replacedMetaObject;
|
|
1958
|
-
};
|
|
1959
|
-
const getMetaObjectRevision = async (input, signal) => {
|
|
1960
|
-
const { data } = await client.get(
|
|
1961
|
-
"/api/v1/repository/{objectType}/{UUID}/revisions/{revision}",
|
|
1962
|
-
{
|
|
1963
|
-
path: input
|
|
1964
|
-
},
|
|
1965
|
-
{ signal }
|
|
1966
|
-
);
|
|
1967
|
-
return data;
|
|
1968
|
-
};
|
|
1969
|
-
const deleteMetaObjectRevision = async (input) => {
|
|
1970
|
-
const { data } = await client.delete(
|
|
1971
|
-
"/api/v1/repository/{objectType}/{UUID}/revisions/{revision}",
|
|
1972
|
-
{
|
|
1973
|
-
path: input
|
|
1974
|
-
}
|
|
1975
|
-
);
|
|
1976
|
-
return data;
|
|
1977
|
-
};
|
|
1978
|
-
return {
|
|
1979
|
-
// lists
|
|
1980
|
-
getMetaObjects,
|
|
1981
|
-
getMetaObjectRevisions,
|
|
1982
|
-
// objects
|
|
1983
|
-
getMetaObject,
|
|
1984
|
-
createMetaObject,
|
|
1985
|
-
deleteMetaObject,
|
|
1986
|
-
updateMetaObject,
|
|
1987
|
-
replaceMetaObject,
|
|
1988
|
-
// revisons
|
|
1989
|
-
getMetaObjectRevision,
|
|
1990
|
-
deleteMetaObjectRevision
|
|
1991
|
-
};
|
|
1992
|
-
};
|
|
1993
|
-
|
|
1994
|
-
// src/clients/metastore/schema/schema.ts
|
|
1995
|
-
var createSchema = (client) => {
|
|
1996
|
-
const getSchema = async (input, signal) => {
|
|
1997
|
-
const { data } = await client.get(
|
|
1998
|
-
"/api/v1/schema/{objectType}",
|
|
1999
|
-
{
|
|
2000
|
-
path: input
|
|
2001
|
-
},
|
|
2002
|
-
{ signal }
|
|
2003
|
-
);
|
|
2004
|
-
return data;
|
|
2005
|
-
};
|
|
2006
|
-
const getVersionedSchema = async (input, signal) => {
|
|
2007
|
-
const { data } = await client.get(
|
|
2008
|
-
"/api/v1/schema/{objectType}/{version}",
|
|
2009
|
-
{
|
|
2010
|
-
path: input
|
|
2011
|
-
},
|
|
2012
|
-
{ signal }
|
|
2013
|
-
);
|
|
2014
|
-
return data;
|
|
2015
|
-
};
|
|
2016
|
-
return {
|
|
2017
|
-
getSchema,
|
|
2018
|
-
getVersionedSchema
|
|
2019
|
-
};
|
|
2020
|
-
};
|
|
2021
|
-
|
|
2022
|
-
// src/clients/metastore/metastoreClient.ts
|
|
2023
|
-
var createMetastoreClient = ({ baseUrl, middlewares }) => {
|
|
2024
|
-
const client = createOpenapiFetchClient({
|
|
2025
|
-
baseUrl,
|
|
2026
|
-
middlewares
|
|
2027
|
-
});
|
|
2028
|
-
const healthCheck = async (signal) => {
|
|
2029
|
-
const { data } = await client.get("/health-check", {}, { signal });
|
|
2030
|
-
return data;
|
|
2031
|
-
};
|
|
2032
|
-
return {
|
|
2033
|
-
healthCheck,
|
|
2034
|
-
repository: createRepository(client),
|
|
2035
|
-
schema: createSchema(client)
|
|
2036
|
-
};
|
|
2037
|
-
};
|
|
2038
|
-
|
|
2039
|
-
// src/clients/oauth/oauthClient.ts
|
|
2040
|
-
var createOauthClient = ({ baseUrl, middlewares }) => {
|
|
2041
|
-
const client = createGenericFetchClient({ baseUrl, middlewares });
|
|
2042
|
-
const getCredentials = async (query, signal) => {
|
|
2043
|
-
const { data } = await client.get(
|
|
2044
|
-
"/credentials",
|
|
2045
|
-
{ query },
|
|
2046
|
-
{ signal }
|
|
2047
|
-
);
|
|
2048
|
-
return data;
|
|
2049
|
-
};
|
|
2050
|
-
const getCredential = async (componentId, id, signal) => {
|
|
2051
|
-
const { data } = await client.get(
|
|
2052
|
-
"/credentials/{componentId}/{id}",
|
|
2053
|
-
{ path: { componentId, id } },
|
|
2054
|
-
{ signal }
|
|
2055
|
-
);
|
|
2056
|
-
return data;
|
|
2057
|
-
};
|
|
2058
|
-
const _createCredentials = async (componentId, body, signal) => {
|
|
2059
|
-
const { data } = await client.post(
|
|
2060
|
-
"/credentials/{componentId}",
|
|
2061
|
-
{ path: { componentId }, body },
|
|
2062
|
-
{ signal }
|
|
2063
|
-
);
|
|
2064
|
-
return data;
|
|
2065
|
-
};
|
|
2066
|
-
const _createLegacyCredentials = async (componentId, { data: credentialsData, ...rest }, signal) => {
|
|
2067
|
-
const { data } = await client.post(
|
|
2068
|
-
"/credentials/{componentId}",
|
|
2069
|
-
{
|
|
2070
|
-
path: { componentId },
|
|
2071
|
-
body: {
|
|
2072
|
-
...rest,
|
|
2073
|
-
"#data": JSON.stringify(credentialsData)
|
|
2074
|
-
}
|
|
2075
|
-
},
|
|
2076
|
-
{ signal }
|
|
2077
|
-
);
|
|
2078
|
-
return data;
|
|
2079
|
-
};
|
|
2080
|
-
const createCredential = async (componentId, body, signal) => {
|
|
2081
|
-
try {
|
|
2082
|
-
return await _createCredentials(componentId, body, signal);
|
|
2083
|
-
} catch (error) {
|
|
2084
|
-
if (isApiError(error) && error.response.status === HttpStatus.UNPROCESSABLE_ENTITY) {
|
|
2085
|
-
return _createLegacyCredentials(componentId, body, signal);
|
|
2086
|
-
}
|
|
2087
|
-
throw error;
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
const deleteCredential = async (componentId, id, signal) => {
|
|
2091
|
-
await client.delete(
|
|
2092
|
-
"/credentials/{componentId}/{id}",
|
|
2093
|
-
{ path: { componentId, id } },
|
|
2094
|
-
{ signal }
|
|
2095
|
-
);
|
|
2096
|
-
};
|
|
2097
|
-
return {
|
|
2098
|
-
getCredentials,
|
|
2099
|
-
getCredential,
|
|
2100
|
-
createCredential,
|
|
2101
|
-
deleteCredential
|
|
2102
|
-
};
|
|
2103
|
-
};
|
|
2104
|
-
|
|
2105
|
-
// src/clients/queryService/queryServiceClient.ts
|
|
2106
|
-
var createQueryServiceClient = ({ baseUrl, middlewares }) => {
|
|
2107
|
-
const client = createOpenapiFetchClient({
|
|
2108
|
-
baseUrl,
|
|
2109
|
-
middlewares
|
|
2110
|
-
});
|
|
2111
|
-
const createQueryJob = async (branchId, workspaceId, body) => {
|
|
2112
|
-
const { data } = await client.post(
|
|
2113
|
-
"/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries",
|
|
2114
|
-
{ path: { branchId, workspaceId }, body }
|
|
2115
|
-
);
|
|
2116
|
-
return data;
|
|
2117
|
-
};
|
|
2118
|
-
const cancelQueryJob = async (queryJobId) => {
|
|
2119
|
-
const { data } = await client.post("/api/v1/queries/{queryJobId}/cancel", {
|
|
2120
|
-
path: { queryJobId },
|
|
2121
|
-
body: { reason: "Cancelled by user" }
|
|
2122
|
-
});
|
|
2123
|
-
return data;
|
|
2124
|
-
};
|
|
2125
|
-
const getQueryJob = async (queryJobId) => {
|
|
2126
|
-
const { data } = await client.get("/api/v1/queries/{queryJobId}", { path: { queryJobId } });
|
|
2127
|
-
return data;
|
|
2128
|
-
};
|
|
2129
|
-
const getQueryResults = async (queryJobId, statementId, query) => {
|
|
2130
|
-
const { data } = await client.get("/api/v1/queries/{queryJobId}/{statementId}/results", {
|
|
2131
|
-
path: { queryJobId, statementId },
|
|
2132
|
-
query
|
|
2133
|
-
});
|
|
2134
|
-
return data;
|
|
2135
|
-
};
|
|
2136
|
-
const getQueryHistory = async (branchId, workspaceId, query) => {
|
|
2137
|
-
const { data } = await client.get(
|
|
2138
|
-
"/api/v1/branches/{branchId}/workspaces/{workspaceId}/queries",
|
|
2139
|
-
{
|
|
2140
|
-
path: { branchId, workspaceId },
|
|
2141
|
-
query
|
|
2142
|
-
}
|
|
2143
|
-
);
|
|
2144
|
-
return data;
|
|
2145
|
-
};
|
|
2146
|
-
const exportResults = async (queryJobId, statementId, query, signal) => {
|
|
2147
|
-
const { data, response } = await client.get(
|
|
2148
|
-
"/api/v1/queries/{queryJobId}/{statementId}/export",
|
|
2149
|
-
{
|
|
2150
|
-
path: { queryJobId, statementId },
|
|
2151
|
-
query
|
|
2152
|
-
},
|
|
2153
|
-
{ signal }
|
|
2154
|
-
);
|
|
2155
|
-
const mimeType = response.headers.get(HttpHeader.CONTENT_TYPE) ?? "text/csv";
|
|
2156
|
-
const contentDisposition = parseContentDispositionHeader(
|
|
2157
|
-
response.headers.get(HttpHeader.CONTENT_DISPOSITION)
|
|
2158
|
-
);
|
|
2159
|
-
return {
|
|
2160
|
-
mimeType,
|
|
2161
|
-
content: data,
|
|
2162
|
-
fileName: contentDisposition?.filename ?? "export.csv"
|
|
2163
|
-
};
|
|
2164
|
-
};
|
|
2165
|
-
return {
|
|
2166
|
-
createQueryJob,
|
|
2167
|
-
cancelQueryJob,
|
|
2168
|
-
getQueryJob,
|
|
2169
|
-
getQueryResults,
|
|
2170
|
-
getQueryHistory,
|
|
2171
|
-
exportResults
|
|
2172
|
-
};
|
|
2173
|
-
};
|
|
2174
|
-
|
|
2175
|
-
// src/clients/queue/queueClient.ts
|
|
2176
|
-
var createQueueClient = ({ baseUrl, middlewares }) => {
|
|
2177
|
-
const client = createOpenapiFetchClient({
|
|
2178
|
-
baseUrl,
|
|
2179
|
-
middlewares
|
|
2180
|
-
});
|
|
2181
|
-
const getJob = async (jobId, signal) => {
|
|
2182
|
-
const { data } = await client.get(
|
|
2183
|
-
"/jobs/{jobId}",
|
|
2184
|
-
{
|
|
2185
|
-
path: { jobId }
|
|
2186
|
-
},
|
|
2187
|
-
{ signal }
|
|
2188
|
-
);
|
|
2189
|
-
return data;
|
|
2190
|
-
};
|
|
2191
|
-
const searchJobs = async (query, signal) => {
|
|
2192
|
-
const { data } = await client.get(
|
|
2193
|
-
"/search/jobs",
|
|
2194
|
-
{
|
|
2195
|
-
query
|
|
2196
|
-
},
|
|
2197
|
-
{ signal }
|
|
2198
|
-
);
|
|
2199
|
-
return data;
|
|
2200
|
-
};
|
|
2201
|
-
return { getJob, searchJobs };
|
|
2202
|
-
};
|
|
2203
|
-
|
|
2204
|
-
// src/clients/status/statusClient.ts
|
|
2205
|
-
var createStatusClient = ({ baseUrl, middlewares }) => {
|
|
2206
|
-
const client = createGenericFetchClient({
|
|
2207
|
-
baseUrl,
|
|
2208
|
-
middlewares
|
|
2209
|
-
});
|
|
2210
|
-
const getSummary = async (signal) => {
|
|
2211
|
-
const { data } = await client.get("/summary.json", {}, { signal });
|
|
2212
|
-
return data;
|
|
2213
|
-
};
|
|
2214
|
-
return {
|
|
2215
|
-
getSummary
|
|
2216
|
-
};
|
|
2217
|
-
};
|
|
2218
|
-
|
|
2219
|
-
// src/clients/storage/configurationVersions/configurationVersions.ts
|
|
2220
|
-
var createConfigurationVersions = (client) => {
|
|
2221
|
-
const listConfigurationVersions = async ({ branchId, componentId, configId }, signal) => {
|
|
2222
|
-
const { data } = await client.get(
|
|
2223
|
-
"/branch/{branchId}/components/{componentId}/configs/{configId}/versions",
|
|
2224
|
-
{ path: { branchId, componentId, configId } },
|
|
2225
|
-
{ signal }
|
|
2226
|
-
);
|
|
2227
|
-
return data;
|
|
2228
|
-
};
|
|
2229
|
-
const getConfigurationVersion = async ({ branchId, componentId, configId, versionId }, signal) => {
|
|
2230
|
-
const { data } = await client.get(
|
|
2231
|
-
"/branch/{branchId}/components/{componentId}/configs/{configId}/versions/{versionId}",
|
|
2232
|
-
{ path: { branchId, componentId, configId, versionId } },
|
|
2233
|
-
{ signal }
|
|
2234
|
-
);
|
|
2235
|
-
return data;
|
|
2236
|
-
};
|
|
2237
|
-
return {
|
|
2238
|
-
listConfigurationVersions,
|
|
2239
|
-
getConfigurationVersion
|
|
2240
|
-
};
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
// src/clients/storage/mergeRequests/mergeRequests.ts
|
|
2244
|
-
var createMergeRequests = (client) => {
|
|
2245
|
-
const getMergeRequests = async (signal) => {
|
|
2246
|
-
const { data } = await client.get("/v2/storage/merge-request", {}, { signal });
|
|
2247
|
-
return data;
|
|
2248
|
-
};
|
|
2249
|
-
const getMergeRequest = async (id, signal) => {
|
|
2250
|
-
const { data } = await client.get(
|
|
2251
|
-
"/v2/storage/merge-request/{id}",
|
|
2252
|
-
{ path: { id } },
|
|
2253
|
-
{ signal }
|
|
2254
|
-
);
|
|
2255
|
-
return data;
|
|
2256
|
-
};
|
|
2257
|
-
const getMergeRequestWithActivityLog = async (id, signal) => {
|
|
2258
|
-
const { data } = await client.get(
|
|
2259
|
-
"/v2/storage/merge-request/{id}",
|
|
2260
|
-
{ path: { id }, query: { include: "activityLog" } },
|
|
2261
|
-
{ signal }
|
|
2262
|
-
);
|
|
2263
|
-
return data;
|
|
2264
|
-
};
|
|
2265
|
-
const createMergeRequest = async (params) => {
|
|
2266
|
-
const { data } = await client.post("/v2/storage/merge-request", { body: params });
|
|
2267
|
-
return data;
|
|
2268
|
-
};
|
|
2269
|
-
const updateMergeRequest = async (id, params) => {
|
|
2270
|
-
const { data } = await client.put("/v2/storage/merge-request/{id}", {
|
|
2271
|
-
path: { id },
|
|
2272
|
-
body: params
|
|
2273
|
-
});
|
|
2274
|
-
return data;
|
|
2275
|
-
};
|
|
2276
|
-
const requestReview = async (id) => {
|
|
2277
|
-
const { data } = await client.put("/v2/storage/merge-request/{id}/request-review", {
|
|
2278
|
-
path: { id }
|
|
2279
|
-
});
|
|
2280
|
-
return data;
|
|
2281
|
-
};
|
|
2282
|
-
const approveMergeRequest = async (id) => {
|
|
2283
|
-
const { data } = await client.put("/v2/storage/merge-request/{id}/approve", {
|
|
2284
|
-
path: { id }
|
|
2285
|
-
});
|
|
2286
|
-
return data;
|
|
2287
|
-
};
|
|
2288
|
-
const requestChangesMergeRequest = async (id, reason) => {
|
|
2289
|
-
const { data } = await client.put("/v2/storage/merge-request/{id}/request-changes", {
|
|
2290
|
-
path: { id },
|
|
2291
|
-
body: reason ? { reason } : void 0
|
|
2292
|
-
});
|
|
2293
|
-
return data;
|
|
2294
|
-
};
|
|
2295
|
-
const getMergeRequestConflicts = async (id, signal) => {
|
|
2296
|
-
const { data } = await client.get(
|
|
2297
|
-
"/v2/storage/merge-request/{id}/conflicts",
|
|
2298
|
-
{ path: { id } },
|
|
2299
|
-
{ signal }
|
|
2300
|
-
);
|
|
2301
|
-
return data;
|
|
2302
|
-
};
|
|
2303
|
-
return {
|
|
2304
|
-
getMergeRequests,
|
|
2305
|
-
getMergeRequest,
|
|
2306
|
-
getMergeRequestWithActivityLog,
|
|
2307
|
-
createMergeRequest,
|
|
2308
|
-
updateMergeRequest,
|
|
2309
|
-
requestReview,
|
|
2310
|
-
approveMergeRequest,
|
|
2311
|
-
requestChangesMergeRequest,
|
|
2312
|
-
getMergeRequestConflicts
|
|
2313
|
-
};
|
|
2314
|
-
};
|
|
2315
|
-
|
|
2316
|
-
// src/clients/storage/branches/mappers.ts
|
|
2317
|
-
var mapBranchMetadata = (data) => ({
|
|
2318
|
-
...data,
|
|
2319
|
-
timestamp: new Date(data.timestamp)
|
|
2320
|
-
});
|
|
2321
|
-
|
|
2322
|
-
// src/clients/storage/branches/branches.ts
|
|
2323
|
-
var createBranches = (client) => {
|
|
2324
|
-
const getDevBranches = async (signal) => {
|
|
2325
|
-
const { data } = await client.get("/dev-branches", {}, { signal });
|
|
2326
|
-
return data;
|
|
2327
|
-
};
|
|
2328
|
-
const createDevBranchJob = async (body) => {
|
|
2329
|
-
const { data } = await client.post(
|
|
2330
|
-
"/dev-branches",
|
|
2331
|
-
{
|
|
2332
|
-
body
|
|
2333
|
-
}
|
|
2334
|
-
);
|
|
2335
|
-
return data;
|
|
2336
|
-
};
|
|
2337
|
-
const updateDevBranch = async ({
|
|
2338
|
-
id,
|
|
2339
|
-
name,
|
|
2340
|
-
description
|
|
2341
|
-
}) => {
|
|
2342
|
-
const { data } = await client.put(
|
|
2343
|
-
"/dev-branches/{id}",
|
|
2344
|
-
{
|
|
2345
|
-
path: { id },
|
|
2346
|
-
body: {
|
|
2347
|
-
name,
|
|
2348
|
-
description
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
);
|
|
2352
|
-
return data;
|
|
2353
|
-
};
|
|
2354
|
-
const deleteDevBranchJob = async (id) => {
|
|
2355
|
-
const { data } = await client.delete(
|
|
2356
|
-
"/dev-branches/{id}",
|
|
2357
|
-
{
|
|
2358
|
-
path: { id }
|
|
2359
|
-
}
|
|
2360
|
-
);
|
|
2361
|
-
return data;
|
|
2362
|
-
};
|
|
2363
|
-
const getDevBranchMetadata = async (id, signal) => {
|
|
2364
|
-
const { data } = await client.get(
|
|
2365
|
-
"/branch/{id}/metadata",
|
|
2366
|
-
{ path: { id } },
|
|
2367
|
-
{ signal }
|
|
2368
|
-
);
|
|
2369
|
-
return data.map(mapBranchMetadata);
|
|
2370
|
-
};
|
|
2371
|
-
const saveDevBranchMetadata = async (id, metadata, signal) => {
|
|
2372
|
-
const { data } = await client.post("/branch/{id}/metadata", { path: { id }, body: { metadata } }, { signal });
|
|
2373
|
-
return data.map(mapBranchMetadata);
|
|
2374
|
-
};
|
|
2375
|
-
const deleteDevBranchMetadata = async (id, metadataId, signal) => {
|
|
2376
|
-
await client.delete(
|
|
2377
|
-
"/branch/{id}/metadata/{metadataId}",
|
|
2378
|
-
{ path: { id, metadataId } },
|
|
2379
|
-
{ signal }
|
|
2380
|
-
);
|
|
2381
|
-
};
|
|
2382
|
-
return {
|
|
2383
|
-
getDevBranches,
|
|
2384
|
-
createDevBranchJob,
|
|
2385
|
-
updateDevBranch,
|
|
2386
|
-
deleteDevBranchJob,
|
|
2387
|
-
getDevBranchMetadata,
|
|
2388
|
-
saveDevBranchMetadata,
|
|
2389
|
-
deleteDevBranchMetadata
|
|
2390
|
-
};
|
|
2391
|
-
};
|
|
2392
|
-
|
|
2393
|
-
// src/clients/storage/buckets/listingConversion.ts
|
|
2394
|
-
var toBackendSubscribers = (subscribers) => subscribers.map((s) => `${s.type}:${s.email}`);
|
|
2395
|
-
var fromBackendSubscribers = (raw) => {
|
|
2396
|
-
const result = [];
|
|
2397
|
-
for (const entry of raw) {
|
|
2398
|
-
const colon = entry.indexOf(":");
|
|
2399
|
-
if (colon === -1) continue;
|
|
2400
|
-
const prefix = entry.slice(0, colon);
|
|
2401
|
-
const email2 = entry.slice(colon + 1);
|
|
2402
|
-
if (prefix !== "user" && prefix !== "group") continue;
|
|
2403
|
-
if (email2.length === 0) continue;
|
|
2404
|
-
result.push({ type: prefix, email: email2 });
|
|
2405
|
-
}
|
|
2406
|
-
return result;
|
|
2407
|
-
};
|
|
2408
|
-
var toBucketListing = (raw, bucketId) => ({
|
|
2409
|
-
bucketId,
|
|
2410
|
-
name: raw.name,
|
|
2411
|
-
description: raw.description ?? null,
|
|
2412
|
-
listingId: raw.bigquery.listingId,
|
|
2413
|
-
subscribers: fromBackendSubscribers(raw.bigquery.subscribers),
|
|
2414
|
-
createdAt: raw.createdAt
|
|
2415
|
-
});
|
|
2416
|
-
|
|
2417
|
-
// src/clients/storage/buckets/buckets.ts
|
|
2418
|
-
var createBuckets = (client) => {
|
|
2419
|
-
const getBuckets = async (query = {}, signal) => {
|
|
2420
|
-
const { data } = await client.get(
|
|
2421
|
-
`/buckets`,
|
|
2422
|
-
{ query },
|
|
2423
|
-
{ signal, queryArrayFormat: "comma" }
|
|
2424
|
-
);
|
|
2425
|
-
return data;
|
|
2426
|
-
};
|
|
2427
|
-
const getBucket = async (id, signal) => {
|
|
2428
|
-
const { data } = await client.get(
|
|
2429
|
-
`/buckets/{id}`,
|
|
2430
|
-
{ path: { id } },
|
|
2431
|
-
{ signal }
|
|
2432
|
-
);
|
|
2433
|
-
return data;
|
|
2434
|
-
};
|
|
2435
|
-
const createBucket = async (body) => {
|
|
2436
|
-
const { data } = await client.post(`/buckets`, {
|
|
2437
|
-
body
|
|
2438
|
-
});
|
|
2439
|
-
return data;
|
|
2440
|
-
};
|
|
2441
|
-
const updateBucket = async (id, body) => {
|
|
2442
|
-
const { data } = await client.patch(
|
|
2443
|
-
`/buckets/{id}`,
|
|
2444
|
-
{ path: { id }, body }
|
|
2445
|
-
);
|
|
2446
|
-
return data;
|
|
2447
|
-
};
|
|
2448
|
-
const deleteBucket = async (id) => {
|
|
2449
|
-
await client.delete(`/buckets/{id}`, { path: { id } });
|
|
2450
|
-
};
|
|
2451
|
-
const deleteBucketAsync = async (id, options = {}) => {
|
|
2452
|
-
const { data } = await client.delete(`/buckets/{id}`, { path: { id }, query: { async: true, ...options } });
|
|
2453
|
-
return data;
|
|
2454
|
-
};
|
|
2455
|
-
const createScheduledRefresh = async (input) => {
|
|
2456
|
-
const { branchId, bucketId, cronExpression } = input;
|
|
2457
|
-
const { data } = await client.post(`/branch/{branchId}/buckets/{bucketId}/scheduled-tasks/refresh`, {
|
|
2458
|
-
path: { branchId, bucketId },
|
|
2459
|
-
body: { cronExpression }
|
|
2460
|
-
});
|
|
2461
|
-
return data;
|
|
2462
|
-
};
|
|
2463
|
-
const deleteScheduledTask = async (taskId) => {
|
|
2464
|
-
await client.delete(`/scheduled-tasks/{taskId}`, {
|
|
2465
|
-
path: { taskId }
|
|
2466
|
-
});
|
|
2467
|
-
};
|
|
2468
|
-
const getListing = async (bucketId, signal) => {
|
|
2469
|
-
try {
|
|
2470
|
-
const { data } = await client.get(
|
|
2471
|
-
`/buckets/{bucketId}/listing`,
|
|
2472
|
-
{ path: { bucketId } },
|
|
2473
|
-
{ signal }
|
|
2474
|
-
);
|
|
2475
|
-
return toBucketListing(data, bucketId);
|
|
2476
|
-
} catch (error) {
|
|
2477
|
-
if (isApiError(error) && error.response.status === 404) return null;
|
|
2478
|
-
throw error;
|
|
2479
|
-
}
|
|
2480
|
-
};
|
|
2481
|
-
const createListing = async (bucketId, input, signal) => {
|
|
2482
|
-
const { data } = await client.post(
|
|
2483
|
-
`/buckets/{bucketId}/listing`,
|
|
2484
|
-
{
|
|
2485
|
-
path: { bucketId },
|
|
2486
|
-
body: {
|
|
2487
|
-
listingName: input.name,
|
|
2488
|
-
listingDescription: input.description?.trim() || null,
|
|
2489
|
-
bigquery: {
|
|
2490
|
-
listingId: input.listingId,
|
|
2491
|
-
subscribers: toBackendSubscribers(input.subscribers)
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2494
|
-
},
|
|
2495
|
-
{ signal }
|
|
2496
|
-
);
|
|
2497
|
-
return data;
|
|
2498
|
-
};
|
|
2499
|
-
const updateListing = async (bucketId, input, signal) => {
|
|
2500
|
-
const body = {};
|
|
2501
|
-
if (input.name !== void 0) body.exposureName = input.name;
|
|
2502
|
-
if (input.description !== void 0) {
|
|
2503
|
-
body.exposureDescription = input.description?.trim() || null;
|
|
2504
|
-
}
|
|
2505
|
-
if (input.subscribers !== void 0) {
|
|
2506
|
-
body.bigquery = { subscribers: toBackendSubscribers(input.subscribers) };
|
|
2507
|
-
}
|
|
2508
|
-
if (Object.keys(body).length === 0) {
|
|
2509
|
-
throw new Error("updateListing requires at least one field");
|
|
2510
|
-
}
|
|
2511
|
-
const { data } = await client.patch(`/buckets/{bucketId}/listing`, { path: { bucketId }, body }, { signal });
|
|
2512
|
-
return data;
|
|
2513
|
-
};
|
|
2514
|
-
const deleteListing = async (bucketId, signal) => {
|
|
2515
|
-
const { data } = await client.delete(
|
|
2516
|
-
`/buckets/{bucketId}/listing`,
|
|
2517
|
-
{ path: { bucketId } },
|
|
2518
|
-
{ signal }
|
|
2519
|
-
);
|
|
2520
|
-
return data;
|
|
2521
|
-
};
|
|
2522
|
-
const listListings = async (signal) => {
|
|
2523
|
-
const { data } = await client.get(`/listings`, {}, { signal });
|
|
2524
|
-
return data.map((row) => toBucketListing(row, row.bucketId));
|
|
2525
|
-
};
|
|
2526
|
-
return {
|
|
2527
|
-
getBuckets,
|
|
2528
|
-
getBucket,
|
|
2529
|
-
createBucket,
|
|
2530
|
-
updateBucket,
|
|
2531
|
-
deleteBucket,
|
|
2532
|
-
deleteBucketAsync,
|
|
2533
|
-
createScheduledRefresh,
|
|
2534
|
-
deleteScheduledTask,
|
|
2535
|
-
getListing,
|
|
2536
|
-
createListing,
|
|
2537
|
-
updateListing,
|
|
2538
|
-
deleteListing,
|
|
2539
|
-
listListings
|
|
2540
|
-
};
|
|
2541
|
-
};
|
|
2542
|
-
|
|
2543
|
-
// src/utils/assert.ts
|
|
2544
|
-
function assert(value, message2) {
|
|
2545
|
-
if (value == null) {
|
|
2546
|
-
throw new Error(message2);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
// src/utils/concurrent.ts
|
|
2551
|
-
var concurrent = async ({
|
|
2552
|
-
items,
|
|
2553
|
-
process: process2,
|
|
2554
|
-
concurrency = 2,
|
|
2555
|
-
middlewares = []
|
|
2556
|
-
}) => {
|
|
2557
|
-
if (concurrency < 1) throw new Error("Concurrency must be greater than 0");
|
|
2558
|
-
if (items.length === 0) return [];
|
|
2559
|
-
if (concurrency === Infinity)
|
|
2560
|
-
return Promise.all(items.map((item, index) => process2(item, index, items.length)));
|
|
2561
|
-
const n = items.length;
|
|
2562
|
-
const results = new Array(n);
|
|
2563
|
-
const processWithMiddlewares = middlewares.reduceRight(
|
|
2564
|
-
(next, middleware) => middleware(next),
|
|
2565
|
-
process2
|
|
2566
|
-
);
|
|
2567
|
-
const queue = items.map((item, index) => async () => {
|
|
2568
|
-
results[index] = await processWithMiddlewares(item, index, items.length);
|
|
2569
|
-
});
|
|
2570
|
-
const workers = Array.from(
|
|
2571
|
-
{ length: Math.min(concurrency, items.length) },
|
|
2572
|
-
async function processQueue() {
|
|
2573
|
-
while (queue.length) {
|
|
2574
|
-
await queue.shift()?.();
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
);
|
|
2578
|
-
await Promise.all(workers);
|
|
2579
|
-
return results;
|
|
2580
|
-
};
|
|
2581
|
-
|
|
2582
|
-
// src/utils/createAbortError.ts
|
|
2583
|
-
var createAbortError = (reason) => new DOMException(reason, "AbortError");
|
|
2584
|
-
|
|
2585
|
-
// src/utils/delay.ts
|
|
2586
|
-
var delay = (timeout, signal) => new Promise((resolve, reject) => {
|
|
2587
|
-
if (signal?.aborted) return reject(createAbortError(signal.reason));
|
|
2588
|
-
const timeoutId = setTimeout(resolve, timeout);
|
|
2589
|
-
signal?.addEventListener(
|
|
2590
|
-
"abort",
|
|
2591
|
-
() => {
|
|
2592
|
-
clearTimeout(timeoutId);
|
|
2593
|
-
reject(createAbortError(signal.reason));
|
|
2594
|
-
},
|
|
2595
|
-
{ once: true }
|
|
2596
|
-
);
|
|
2597
|
-
});
|
|
2598
|
-
|
|
2599
|
-
// src/utils/poll.ts
|
|
2600
|
-
var message = {
|
|
2601
|
-
PollPredicateError: "Poll predicate failed",
|
|
2602
|
-
PollTimeoutError: "Poll timeout exceeded",
|
|
2603
|
-
PollPollTimeoutError: "Poll data failed condition"
|
|
2604
|
-
};
|
|
2605
|
-
var PollException = class extends Error {
|
|
2606
|
-
result;
|
|
2607
|
-
constructor(type, result) {
|
|
2608
|
-
super(type, { cause: message[type] });
|
|
2609
|
-
this.result = result;
|
|
2610
|
-
}
|
|
2611
|
-
};
|
|
2612
|
-
var poll = async ({
|
|
2613
|
-
pollFn,
|
|
2614
|
-
interval,
|
|
2615
|
-
isDone,
|
|
2616
|
-
isFailed,
|
|
2617
|
-
abortSignal,
|
|
2618
|
-
maxAttempts = Infinity
|
|
2619
|
-
}) => {
|
|
2620
|
-
if (abortSignal?.aborted) throw createAbortError(abortSignal.reason);
|
|
2621
|
-
if (interval < 1) throw new Error("Invalid poll interval");
|
|
2622
|
-
if (maxAttempts < 1) throw new Error("Invalid poll maxAttempts");
|
|
2623
|
-
let callCount = 0;
|
|
2624
|
-
while (true) {
|
|
2625
|
-
callCount++;
|
|
2626
|
-
const data = await pollFn(abortSignal);
|
|
2627
|
-
const result = { data, callCount };
|
|
2628
|
-
try {
|
|
2629
|
-
if (isDone(data)) return result;
|
|
2630
|
-
if (isFailed?.(data) ?? false) throw new PollException("PollPollTimeoutError", result);
|
|
2631
|
-
} catch (error) {
|
|
2632
|
-
if (error instanceof PollException) throw error;
|
|
2633
|
-
throw new PollException("PollPredicateError", result);
|
|
2634
|
-
}
|
|
2635
|
-
if (callCount >= maxAttempts) throw new PollException("PollTimeoutError", result);
|
|
2636
|
-
await delay(interval, abortSignal);
|
|
2637
|
-
}
|
|
2638
|
-
};
|
|
2639
|
-
|
|
2640
|
-
// src/utils/keboolaUID.ts
|
|
2641
|
-
var KEBOOLA_OBJECT_ID_DELIMITER = "--";
|
|
2642
|
-
var keboolaUID = {
|
|
2643
|
-
serialize: (input) => {
|
|
2644
|
-
if (input.uid === "")
|
|
2645
|
-
throw new Error("Invalid Keboola Object ID: uid of an object cannot be empty");
|
|
2646
|
-
return ["KID", input.projectId, input.type, input.uid].join(KEBOOLA_OBJECT_ID_DELIMITER);
|
|
2647
|
-
},
|
|
2648
|
-
deserialize: (input) => {
|
|
2649
|
-
const [identifier, projectId, type, uid] = input.split(KEBOOLA_OBJECT_ID_DELIMITER);
|
|
2650
|
-
if (identifier !== "KID" || !projectId || !type || !uid)
|
|
2651
|
-
throw new Error("Invalid Keboola Object ID");
|
|
2652
|
-
return {
|
|
2653
|
-
projectId: Number(projectId),
|
|
2654
|
-
type,
|
|
2655
|
-
uid
|
|
2656
|
-
};
|
|
2657
|
-
}
|
|
2658
|
-
};
|
|
2659
|
-
|
|
2660
|
-
// src/utils/generateUUID.ts
|
|
2661
|
-
var generateUUID = () => crypto.randomUUID();
|
|
2662
|
-
|
|
2663
|
-
// src/utils/series.ts
|
|
2664
|
-
var series = async (options) => concurrent({
|
|
2665
|
-
...options,
|
|
2666
|
-
concurrency: 1
|
|
2667
|
-
});
|
|
2668
|
-
|
|
2669
|
-
// src/clients/storage/componentsAndConfigurations/componentsAndConfigurations.ts
|
|
2670
|
-
var createComponentsAndConfigurations = (client) => {
|
|
2671
|
-
const getComponent = async ({ componentId, branchId = "default" }, signal) => {
|
|
2672
|
-
const { data } = await client.get(
|
|
2673
|
-
"/branch/{branchId}/components/{componentId}",
|
|
2674
|
-
{ path: { componentId, branchId } },
|
|
2675
|
-
{ signal }
|
|
2676
|
-
);
|
|
2677
|
-
return data;
|
|
2678
|
-
};
|
|
2679
|
-
const getComponents = async ({ branchId = "default", ...query } = {}, signal) => {
|
|
2680
|
-
const { data } = await client.get(
|
|
2681
|
-
"/branch/{branchId}/components",
|
|
2682
|
-
{ path: { branchId }, query },
|
|
2683
|
-
{ signal, queryArrayFormat: "comma" }
|
|
2684
|
-
);
|
|
2685
|
-
return data;
|
|
2686
|
-
};
|
|
2687
|
-
const getConfiguration = async ({ componentId, configId, branchId = "default" }, signal) => {
|
|
2688
|
-
const { data } = await client.get(
|
|
2689
|
-
"/branch/{branchId}/components/{componentId}/configs/{configId}",
|
|
2690
|
-
{ path: { componentId, configId, branchId } },
|
|
2691
|
-
{ signal }
|
|
2692
|
-
);
|
|
2693
|
-
return data;
|
|
2694
|
-
};
|
|
2695
|
-
const createConfiguration = async ({
|
|
2696
|
-
branchId = "default",
|
|
2697
|
-
componentId,
|
|
2698
|
-
...body
|
|
2699
|
-
}) => {
|
|
2700
|
-
const { data } = await client.post("/branch/{branchId}/components/{componentId}/configs", {
|
|
2701
|
-
path: { branchId, componentId },
|
|
2702
|
-
body
|
|
2703
|
-
});
|
|
2704
|
-
return data;
|
|
2705
|
-
};
|
|
2706
|
-
const deleteConfiguration = async (path) => {
|
|
2707
|
-
await client.delete(
|
|
2708
|
-
"/branch/{branchId}/components/{componentId}/configs/{configId}",
|
|
2709
|
-
{ path }
|
|
2710
|
-
);
|
|
2711
|
-
};
|
|
2712
|
-
const deleteConfigurations = async ({
|
|
2713
|
-
configIds,
|
|
2714
|
-
...rest
|
|
2715
|
-
}) => {
|
|
2716
|
-
await concurrent({
|
|
2717
|
-
items: configIds,
|
|
2718
|
-
process: async (configId) => deleteConfiguration({ ...rest, configId })
|
|
2719
|
-
});
|
|
2720
|
-
};
|
|
2721
|
-
const getConfigurations = async ({ componentId, branchId = "default" }, signal) => {
|
|
2722
|
-
const { data } = await client.get(
|
|
2723
|
-
"/branch/{branchId}/components/{componentId}/configs",
|
|
2724
|
-
{ path: { componentId, branchId } },
|
|
2725
|
-
{ signal }
|
|
2726
|
-
);
|
|
2727
|
-
return data;
|
|
2728
|
-
};
|
|
2729
|
-
const getConfigurationWorkspaces = async ({
|
|
2730
|
-
componentId,
|
|
2731
|
-
branchId,
|
|
2732
|
-
configId
|
|
2733
|
-
}) => {
|
|
2734
|
-
const { data } = await client.get(
|
|
2735
|
-
"/branch/{branchId}/components/{componentId}/configs/{configId}/workspaces",
|
|
2736
|
-
{
|
|
2737
|
-
path: { componentId, branchId, configId }
|
|
2738
|
-
}
|
|
2739
|
-
);
|
|
2740
|
-
return data;
|
|
2741
|
-
};
|
|
2742
|
-
const createConfigurationWorkspace = async ({
|
|
2743
|
-
componentId,
|
|
2744
|
-
branchId,
|
|
2745
|
-
configId,
|
|
2746
|
-
...body
|
|
2747
|
-
}) => {
|
|
2748
|
-
const { data } = await client.post("/branch/{branchId}/components/{componentId}/configs/{configId}/workspaces", {
|
|
2749
|
-
path: { componentId, branchId, configId },
|
|
2750
|
-
body
|
|
2751
|
-
});
|
|
2752
|
-
return data;
|
|
2753
|
-
};
|
|
2754
|
-
const createConfigurationWorkspaceJob = async ({
|
|
2755
|
-
componentId,
|
|
2756
|
-
branchId,
|
|
2757
|
-
configId,
|
|
2758
|
-
...body
|
|
2759
|
-
}) => {
|
|
2760
|
-
const { data } = await client.post("/branch/{branchId}/components/{componentId}/configs/{configId}/workspaces", {
|
|
2761
|
-
path: { componentId, branchId, configId },
|
|
2762
|
-
body,
|
|
2763
|
-
query: { async: true }
|
|
2764
|
-
});
|
|
2765
|
-
return data;
|
|
2766
|
-
};
|
|
2767
|
-
const createConfigurationRow = async ({
|
|
2768
|
-
branchId = "default",
|
|
2769
|
-
componentId,
|
|
2770
|
-
configId,
|
|
2771
|
-
...body
|
|
2772
|
-
}) => {
|
|
2773
|
-
const { data } = await client.post("/branch/{branchId}/components/{componentId}/configs/{configId}/rows", {
|
|
2774
|
-
path: { branchId, componentId, configId },
|
|
2775
|
-
body
|
|
2776
|
-
});
|
|
2777
|
-
return data;
|
|
2778
|
-
};
|
|
2779
|
-
const createConfigurationRows = async ({
|
|
2780
|
-
branchId = "default",
|
|
2781
|
-
componentId,
|
|
2782
|
-
configId,
|
|
2783
|
-
data
|
|
2784
|
-
}, options) => {
|
|
2785
|
-
return series({
|
|
2786
|
-
items: data,
|
|
2787
|
-
process: (rowBody) => {
|
|
2788
|
-
return createConfigurationRow({
|
|
2789
|
-
branchId,
|
|
2790
|
-
componentId,
|
|
2791
|
-
configId,
|
|
2792
|
-
...rowBody
|
|
2793
|
-
});
|
|
2794
|
-
},
|
|
2795
|
-
middlewares: options?.middlewares
|
|
2796
|
-
});
|
|
2797
|
-
};
|
|
2798
|
-
const deleteConfigurationRow = async ({
|
|
2799
|
-
changeDescription,
|
|
2800
|
-
...path
|
|
2801
|
-
}) => {
|
|
2802
|
-
await client.delete(
|
|
2803
|
-
"/branch/{branchId}/components/{componentId}/configs/{configId}/rows/{rowId}",
|
|
2804
|
-
{
|
|
2805
|
-
path,
|
|
2806
|
-
body: { changeDescription }
|
|
2807
|
-
}
|
|
2808
|
-
);
|
|
2809
|
-
};
|
|
2810
|
-
const deleteConfigurationRows = async ({ rowIds, changeDescription, ...input }, options) => {
|
|
2811
|
-
await concurrent({
|
|
2812
|
-
items: rowIds,
|
|
2813
|
-
process: (rowId) => {
|
|
2814
|
-
const resolvedDescription = typeof changeDescription === "string" ? changeDescription : changeDescription?.(rowId);
|
|
2815
|
-
return deleteConfigurationRow({
|
|
2816
|
-
rowId,
|
|
2817
|
-
changeDescription: resolvedDescription,
|
|
2818
|
-
...input
|
|
2819
|
-
});
|
|
2820
|
-
},
|
|
2821
|
-
concurrency: 5,
|
|
2822
|
-
middlewares: options?.middlewares
|
|
2823
|
-
});
|
|
2824
|
-
};
|
|
2825
|
-
const searchComponentConfigurations = async ({ branchId = "default" } = {}, query, signal) => {
|
|
2826
|
-
const { data } = await client.get(
|
|
2827
|
-
"/branch/{branchId}/search/component-configurations",
|
|
2828
|
-
{ path: { branchId }, query },
|
|
2829
|
-
{ signal, queryArrayFormat: "comma" }
|
|
2830
|
-
);
|
|
2831
|
-
return data;
|
|
2832
|
-
};
|
|
2833
|
-
return {
|
|
2834
|
-
// components
|
|
2835
|
-
getComponent,
|
|
2836
|
-
getComponents,
|
|
2837
|
-
searchComponentConfigurations,
|
|
2838
|
-
// configurations
|
|
2839
|
-
createConfiguration,
|
|
2840
|
-
getConfiguration,
|
|
2841
|
-
deleteConfiguration,
|
|
2842
|
-
deleteConfigurations,
|
|
2843
|
-
getConfigurations,
|
|
2844
|
-
// configuration's rows
|
|
2845
|
-
createConfigurationRow,
|
|
2846
|
-
createConfigurationRows,
|
|
2847
|
-
deleteConfigurationRow,
|
|
2848
|
-
deleteConfigurationRows,
|
|
2849
|
-
// configuration's workspaces
|
|
2850
|
-
createConfigurationWorkspace,
|
|
2851
|
-
createConfigurationWorkspaceJob,
|
|
2852
|
-
getConfigurationWorkspaces
|
|
2853
|
-
};
|
|
2854
|
-
};
|
|
2855
|
-
|
|
2856
|
-
// src/clients/storage/events/events.ts
|
|
2857
|
-
var createEvents = (client) => {
|
|
2858
|
-
const getEvents = async (query, signal) => {
|
|
2859
|
-
const { data } = await client.get(
|
|
2860
|
-
"/events",
|
|
2861
|
-
{ query },
|
|
2862
|
-
{ signal }
|
|
2863
|
-
);
|
|
2864
|
-
return data;
|
|
2865
|
-
};
|
|
2866
|
-
const getEvent = async (eventId, signal) => {
|
|
2867
|
-
const { data } = await client.get(
|
|
2868
|
-
"/events/{eventId}",
|
|
2869
|
-
{
|
|
2870
|
-
path: { eventId }
|
|
2871
|
-
},
|
|
2872
|
-
{ signal }
|
|
2873
|
-
);
|
|
2874
|
-
return data;
|
|
2875
|
-
};
|
|
2876
|
-
const createEvent = async (body, signal) => {
|
|
2877
|
-
const { data } = await client.post(
|
|
2878
|
-
"/events",
|
|
2879
|
-
{
|
|
2880
|
-
body
|
|
2881
|
-
},
|
|
2882
|
-
{ signal }
|
|
2883
|
-
);
|
|
2884
|
-
return data;
|
|
2885
|
-
};
|
|
2886
|
-
return {
|
|
2887
|
-
getEvents,
|
|
2888
|
-
getEvent,
|
|
2889
|
-
createEvent
|
|
2890
|
-
};
|
|
2891
|
-
};
|
|
2892
|
-
|
|
2893
|
-
// src/clients/storage/files/files.ts
|
|
2894
|
-
var createFiles = (client) => {
|
|
2895
|
-
const getFile = async (fileId, signal) => {
|
|
2896
|
-
const { data } = await client.get(
|
|
2897
|
-
`/files/{fileId}`,
|
|
2898
|
-
{
|
|
2899
|
-
path: { fileId }
|
|
2900
|
-
},
|
|
2901
|
-
{ signal }
|
|
2902
|
-
);
|
|
2903
|
-
return data;
|
|
2904
|
-
};
|
|
2905
|
-
const getFiles = async (query, signal) => {
|
|
2906
|
-
const { data } = await client.get(
|
|
2907
|
-
"/files",
|
|
2908
|
-
{ query },
|
|
2909
|
-
{ signal, queryArrayFormat: "brackets" }
|
|
2910
|
-
);
|
|
2911
|
-
return data;
|
|
2912
|
-
};
|
|
2913
|
-
const deleteFile = async (fileId) => {
|
|
2914
|
-
const { data } = await client.delete(`/files/{fileId}`, {
|
|
2915
|
-
path: { fileId }
|
|
2916
|
-
});
|
|
2917
|
-
return data;
|
|
2918
|
-
};
|
|
2919
|
-
const addFileTag = async (fileId, tag) => {
|
|
2920
|
-
const { data } = await client.post(
|
|
2921
|
-
`/files/{fileId}/tags`,
|
|
2922
|
-
{
|
|
2923
|
-
path: { fileId },
|
|
2924
|
-
body: { tag }
|
|
2925
|
-
}
|
|
2926
|
-
);
|
|
2927
|
-
return data;
|
|
2928
|
-
};
|
|
2929
|
-
const getFileContent = async (fileId, signal) => {
|
|
2930
|
-
const { data } = await client.get(
|
|
2931
|
-
`/files/{fileId}/content`,
|
|
2932
|
-
{
|
|
2933
|
-
path: { fileId }
|
|
2934
|
-
},
|
|
2935
|
-
{ signal }
|
|
2936
|
-
);
|
|
2937
|
-
return typeof data === "string" ? data : JSON.stringify(data, null, 2);
|
|
2938
|
-
};
|
|
2939
|
-
const deleteFileTag = async (fileId, tag) => {
|
|
2940
|
-
const { data } = await client.delete(
|
|
2941
|
-
"/files/{fileId}/tags/{tag}",
|
|
2942
|
-
{
|
|
2943
|
-
path: { fileId, tag }
|
|
2944
|
-
}
|
|
2945
|
-
);
|
|
2946
|
-
return data;
|
|
2947
|
-
};
|
|
2948
|
-
const prepareFile = async (body, signal) => {
|
|
2949
|
-
const { data } = await client.post(
|
|
2950
|
-
"/files/prepare",
|
|
2951
|
-
{ body },
|
|
2952
|
-
{ signal }
|
|
2953
|
-
);
|
|
2954
|
-
return data;
|
|
2955
|
-
};
|
|
2956
|
-
return {
|
|
2957
|
-
getFile,
|
|
2958
|
-
getFileContent,
|
|
2959
|
-
getFiles,
|
|
2960
|
-
deleteFile,
|
|
2961
|
-
addFileTag,
|
|
2962
|
-
deleteFileTag,
|
|
2963
|
-
prepareFile
|
|
2964
|
-
};
|
|
2965
|
-
};
|
|
2966
|
-
|
|
2967
|
-
// src/clients/storage/jobs/jobs.ts
|
|
2968
|
-
var createJobs = (client) => {
|
|
2969
|
-
const getJob = async (id, signal) => {
|
|
2970
|
-
const { data } = await client.get(
|
|
2971
|
-
`/jobs/{id}`,
|
|
2972
|
-
{
|
|
2973
|
-
path: { id }
|
|
2974
|
-
},
|
|
2975
|
-
{ signal }
|
|
2976
|
-
);
|
|
2977
|
-
return data;
|
|
2978
|
-
};
|
|
2979
|
-
const getJobs = async (query, signal) => {
|
|
2980
|
-
const { data } = await client.get(
|
|
2981
|
-
"/jobs",
|
|
2982
|
-
{ query },
|
|
2983
|
-
{ signal, queryArrayFormat: "brackets" }
|
|
2984
|
-
);
|
|
2985
|
-
return data;
|
|
2986
|
-
};
|
|
2987
|
-
return { getJob, getJobs };
|
|
2988
|
-
};
|
|
2989
|
-
|
|
2990
|
-
// src/clients/storage/tables/tables.ts
|
|
2991
|
-
var createTables = (client) => {
|
|
2992
|
-
const getTables = async (query = { include: [] }, signal) => {
|
|
2993
|
-
const { data } = await client.get(
|
|
2994
|
-
`/tables`,
|
|
2995
|
-
{ query },
|
|
2996
|
-
{ signal, queryArrayFormat: "comma" }
|
|
2997
|
-
);
|
|
2998
|
-
return data;
|
|
2999
|
-
};
|
|
3000
|
-
const getTable = async (id, signal) => {
|
|
3001
|
-
const { data } = await client.get(
|
|
3002
|
-
`/tables/{id}`,
|
|
3003
|
-
{ path: { id } },
|
|
3004
|
-
{ signal }
|
|
3005
|
-
);
|
|
3006
|
-
return data;
|
|
3007
|
-
};
|
|
3008
|
-
const deleteTable = async (id, signal) => {
|
|
3009
|
-
await client.delete(`/tables/{id}`, { path: { id } }, { signal });
|
|
3010
|
-
};
|
|
3011
|
-
const deleteTables = async (ids) => {
|
|
3012
|
-
await concurrent({
|
|
3013
|
-
items: ids,
|
|
3014
|
-
process: (id) => deleteTable(id)
|
|
3015
|
-
});
|
|
3016
|
-
};
|
|
3017
|
-
const deleteTableRows = async (id, query, signal) => {
|
|
3018
|
-
const { data } = await client.delete(
|
|
3019
|
-
`/tables/{id}/rows`,
|
|
3020
|
-
{ path: { id }, query },
|
|
3021
|
-
{ signal }
|
|
3022
|
-
);
|
|
3023
|
-
return data;
|
|
3024
|
-
};
|
|
3025
|
-
const getDataPreview = async (id, query, signal) => {
|
|
3026
|
-
const { data } = await client.get(
|
|
3027
|
-
`/tables/{id}/data-preview`,
|
|
3028
|
-
{ path: { id }, query: { format: "json", ...query } },
|
|
3029
|
-
{ signal }
|
|
3030
|
-
);
|
|
3031
|
-
return data;
|
|
3032
|
-
};
|
|
3033
|
-
const exportAsync = async (tableId, body, signal) => {
|
|
3034
|
-
const { data } = await client.post(
|
|
3035
|
-
"/tables/{id}/export-async",
|
|
3036
|
-
{ path: { id: tableId }, body },
|
|
3037
|
-
{ signal }
|
|
3038
|
-
);
|
|
3039
|
-
return data;
|
|
3040
|
-
};
|
|
3041
|
-
const createTableAsync = async (bucketId, body, signal) => {
|
|
3042
|
-
const { data } = await client.post("/buckets/{bucketId}/tables-async", { path: { bucketId }, body }, { signal });
|
|
3043
|
-
return data;
|
|
3044
|
-
};
|
|
3045
|
-
const importAsync = async (tableId, body, signal) => {
|
|
3046
|
-
const { data } = await client.post(
|
|
3047
|
-
"/tables/{id}/import-async",
|
|
3048
|
-
{ path: { id: tableId }, body },
|
|
3049
|
-
{ signal }
|
|
3050
|
-
);
|
|
3051
|
-
return data;
|
|
3052
|
-
};
|
|
3053
|
-
return {
|
|
3054
|
-
getTables,
|
|
3055
|
-
getTable,
|
|
3056
|
-
getDataPreview,
|
|
3057
|
-
deleteTable,
|
|
3058
|
-
deleteTables,
|
|
3059
|
-
deleteTableRows,
|
|
3060
|
-
exportAsync,
|
|
3061
|
-
createTableAsync,
|
|
3062
|
-
importAsync
|
|
3063
|
-
};
|
|
3064
|
-
};
|
|
3065
|
-
|
|
3066
|
-
// src/clients/storage/tokens/tokens.ts
|
|
3067
|
-
var createTokens = (client) => {
|
|
3068
|
-
const verify = async (signal) => {
|
|
3069
|
-
const { data } = await client.get(
|
|
3070
|
-
"/tokens/verify",
|
|
3071
|
-
{},
|
|
3072
|
-
{ signal }
|
|
3073
|
-
);
|
|
3074
|
-
return data;
|
|
3075
|
-
};
|
|
3076
|
-
const refresh = async (id, signal) => {
|
|
3077
|
-
const { data } = await client.post(
|
|
3078
|
-
`/tokens/${id}/refresh`,
|
|
3079
|
-
{},
|
|
3080
|
-
{ signal }
|
|
3081
|
-
);
|
|
3082
|
-
return data;
|
|
3083
|
-
};
|
|
3084
|
-
return {
|
|
3085
|
-
verify,
|
|
3086
|
-
refresh
|
|
3087
|
-
};
|
|
3088
|
-
};
|
|
3089
|
-
|
|
3090
|
-
// src/clients/storage/workspaces/workspaces.ts
|
|
3091
|
-
var createWorkspaces = (client) => {
|
|
3092
|
-
const getWorkspaces = async (branchId, signal) => {
|
|
3093
|
-
const { data } = await client.get(
|
|
3094
|
-
"/branch/{branchId}/workspaces",
|
|
3095
|
-
{ path: { branchId } },
|
|
3096
|
-
{ signal }
|
|
3097
|
-
);
|
|
3098
|
-
return data;
|
|
3099
|
-
};
|
|
3100
|
-
const getWorkspace = async (path, signal) => {
|
|
3101
|
-
const { data } = await client.get(
|
|
3102
|
-
"/branch/{branchId}/workspaces/{workspaceId}",
|
|
3103
|
-
{ path },
|
|
3104
|
-
{ signal }
|
|
3105
|
-
);
|
|
3106
|
-
return data;
|
|
3107
|
-
};
|
|
3108
|
-
const deleteWorkspace = async (path) => {
|
|
3109
|
-
await client.delete(
|
|
3110
|
-
"/branch/{branchId}/workspaces/{workspaceId}",
|
|
3111
|
-
{ path }
|
|
3112
|
-
);
|
|
3113
|
-
};
|
|
3114
|
-
const deleteWorkspaces = async ({
|
|
3115
|
-
workspaceIds,
|
|
3116
|
-
branchId
|
|
3117
|
-
}) => {
|
|
3118
|
-
await concurrent({
|
|
3119
|
-
items: workspaceIds,
|
|
3120
|
-
process: async (workspaceId) => deleteWorkspace({ branchId, workspaceId }),
|
|
3121
|
-
concurrency: 5
|
|
3122
|
-
});
|
|
3123
|
-
};
|
|
3124
|
-
const deleteWorkspaceJob = async (path) => {
|
|
3125
|
-
const { data } = await client.delete(
|
|
3126
|
-
"/branch/{branchId}/workspaces/{workspaceId}",
|
|
3127
|
-
{ path, query: { async: true } },
|
|
3128
|
-
{}
|
|
3129
|
-
);
|
|
3130
|
-
return data;
|
|
3131
|
-
};
|
|
3132
|
-
const resetWorkspacePassword = async ({ branchId, workspaceId }) => {
|
|
3133
|
-
const { data } = await client.post(
|
|
3134
|
-
"/branch/{branchId}/workspaces/{workspaceId}/password",
|
|
3135
|
-
{
|
|
3136
|
-
path: { branchId, workspaceId }
|
|
3137
|
-
}
|
|
3138
|
-
);
|
|
3139
|
-
return data;
|
|
3140
|
-
};
|
|
3141
|
-
const getWorkspaceSaml2Login = async (path, signal) => {
|
|
3142
|
-
const { data } = await client.get(
|
|
3143
|
-
"/branch/{branchId}/workspaces/{workspaceId}/saml2-login",
|
|
3144
|
-
{ path },
|
|
3145
|
-
{ signal }
|
|
3146
|
-
);
|
|
3147
|
-
return data;
|
|
3148
|
-
};
|
|
3149
|
-
const setWorkspacePublicKey = async ({
|
|
3150
|
-
branchId,
|
|
3151
|
-
workspaceId,
|
|
3152
|
-
publicKey
|
|
3153
|
-
}) => {
|
|
3154
|
-
const { data } = await client.post("/branch/{branchId}/workspaces/{workspaceId}/public-key", {
|
|
3155
|
-
path: { branchId, workspaceId },
|
|
3156
|
-
body: { publicKey }
|
|
3157
|
-
});
|
|
3158
|
-
return data;
|
|
3159
|
-
};
|
|
3160
|
-
const getWorkspaceObjects = async (path, signal) => {
|
|
3161
|
-
const { data } = await client.get(
|
|
3162
|
-
"/branch/{branchId}/workspaces/{workspaceId}/objects",
|
|
3163
|
-
{ path },
|
|
3164
|
-
{ signal }
|
|
3165
|
-
);
|
|
3166
|
-
return data;
|
|
3167
|
-
};
|
|
3168
|
-
const deleteWorkspaceObjectsAsync = async ({
|
|
3169
|
-
branchId,
|
|
3170
|
-
workspaceId,
|
|
3171
|
-
...body
|
|
3172
|
-
}) => {
|
|
3173
|
-
const { data } = await client.post("/branch/{branchId}/workspaces/{workspaceId}/objects/batch-delete", {
|
|
3174
|
-
path: { branchId, workspaceId },
|
|
3175
|
-
body
|
|
3176
|
-
});
|
|
3177
|
-
return data;
|
|
3178
|
-
};
|
|
3179
|
-
return {
|
|
3180
|
-
getWorkspace,
|
|
3181
|
-
getWorkspaces,
|
|
3182
|
-
deleteWorkspace,
|
|
3183
|
-
resetWorkspacePassword,
|
|
3184
|
-
deleteWorkspaces,
|
|
3185
|
-
deleteWorkspaceJob,
|
|
3186
|
-
setWorkspacePublicKey,
|
|
3187
|
-
getWorkspaceSaml2Login,
|
|
3188
|
-
getWorkspaceObjects,
|
|
3189
|
-
deleteWorkspaceObjectsAsync
|
|
3190
|
-
};
|
|
3191
|
-
};
|
|
3192
|
-
|
|
3193
|
-
// src/clients/storage/storageClient.ts
|
|
3194
|
-
var createStorageClient = ({ baseUrl, middlewares = [] }) => {
|
|
3195
|
-
const storageBaseUrl = `${baseUrl}/v2/storage`;
|
|
3196
|
-
const client = createGenericFetchClient({
|
|
3197
|
-
baseUrl: storageBaseUrl,
|
|
3198
|
-
middlewares
|
|
3199
|
-
});
|
|
3200
|
-
const openApiClient = createOpenapiFetchClient({
|
|
3201
|
-
baseUrl,
|
|
3202
|
-
middlewares
|
|
3203
|
-
});
|
|
3204
|
-
const getStackInfo = async (query, signal) => {
|
|
3205
|
-
const { data } = await client.get(
|
|
3206
|
-
"",
|
|
3207
|
-
{ query },
|
|
3208
|
-
{ signal }
|
|
3209
|
-
);
|
|
3210
|
-
return data;
|
|
3211
|
-
};
|
|
3212
|
-
return {
|
|
3213
|
-
buckets: createBuckets(client),
|
|
3214
|
-
events: createEvents(client),
|
|
3215
|
-
files: createFiles(client),
|
|
3216
|
-
tables: createTables(client),
|
|
3217
|
-
branches: createBranches(client),
|
|
3218
|
-
workspaces: createWorkspaces(client),
|
|
3219
|
-
mergeRequests: createMergeRequests(openApiClient),
|
|
3220
|
-
jobs: createJobs(client),
|
|
3221
|
-
componentsAndConfigurations: createComponentsAndConfigurations(client),
|
|
3222
|
-
configurationVersions: createConfigurationVersions(client),
|
|
3223
|
-
tokens: createTokens(client),
|
|
3224
|
-
getStackInfo
|
|
3225
|
-
};
|
|
3226
|
-
};
|
|
3227
|
-
|
|
3228
|
-
// src/clients/storage/storageTokenMiddleware.ts
|
|
3229
|
-
var isTokenRefreshEndpoint = (request) => {
|
|
3230
|
-
const url = new URL(request.url);
|
|
3231
|
-
return request.method === "POST" && /\/tokens\/[^/]+\/refresh$/.test(url.pathname);
|
|
3232
|
-
};
|
|
3233
|
-
var tryParseNewToken = (data) => {
|
|
3234
|
-
if (data === null || typeof data !== "object") return null;
|
|
3235
|
-
const token = data.token;
|
|
3236
|
-
return typeof token === "string" ? token : null;
|
|
3237
|
-
};
|
|
3238
|
-
var createStorageTokenMiddleware = (initialToken) => {
|
|
3239
|
-
let current = initialToken;
|
|
3240
|
-
return (next) => async (request) => {
|
|
3241
|
-
request.request.headers.set(KeboolaHttpHeader.STORAGE_API_TOKEN, current);
|
|
3242
|
-
const response = await next(request);
|
|
3243
|
-
if (isTokenRefreshEndpoint(request.request)) {
|
|
3244
|
-
const newToken = tryParseNewToken(response.data);
|
|
3245
|
-
if (newToken !== null) current = newToken;
|
|
3246
|
-
}
|
|
3247
|
-
return response;
|
|
3248
|
-
};
|
|
3249
|
-
};
|
|
3250
|
-
|
|
3251
|
-
// src/clients/syncActions/constants.ts
|
|
3252
|
-
var SyncAction = {
|
|
3253
|
-
DATA_APP_GIT_REPOSITORY: "git-repository",
|
|
3254
|
-
GIT_REPOSITORY: "gitRepository",
|
|
3255
|
-
ENROLL_MFA: "enrollMFA"
|
|
3256
|
-
};
|
|
3257
|
-
var Component = {
|
|
3258
|
-
DATA_APP: "keboola.data-apps"
|
|
3259
|
-
};
|
|
3260
|
-
var Author = z5__namespace.object({
|
|
3261
|
-
name: z5__namespace.string(),
|
|
3262
|
-
email: z5__namespace.email()
|
|
3263
|
-
});
|
|
3264
|
-
var RepositoryBranch = z5__namespace.object({
|
|
3265
|
-
sha: z5__namespace.string(),
|
|
3266
|
-
date: z5__namespace.string(),
|
|
3267
|
-
comment: z5__namespace.string(),
|
|
3268
|
-
branch: z5__namespace.string(),
|
|
3269
|
-
author: Author
|
|
3270
|
-
});
|
|
3271
|
-
var Repository = z5__namespace.object({
|
|
3272
|
-
repository: z5__namespace.object({
|
|
3273
|
-
url: z5__namespace.string()
|
|
3274
|
-
}),
|
|
3275
|
-
branches: z5__namespace.array(RepositoryBranch)
|
|
3276
|
-
});
|
|
3277
|
-
|
|
3278
|
-
// src/clients/syncActions/gitRepository/utils.ts
|
|
3279
|
-
var GitRepoConfigDataBuilder = class {
|
|
3280
|
-
repositoryUrl;
|
|
3281
|
-
config = {};
|
|
3282
|
-
constructor(repositoryUrl) {
|
|
3283
|
-
this.repositoryUrl = repositoryUrl;
|
|
3284
|
-
}
|
|
3285
|
-
withCredentials(username, password) {
|
|
3286
|
-
this.config.username = username;
|
|
3287
|
-
delete this.config["#sshKey"];
|
|
3288
|
-
this.config["#password"] = password;
|
|
3289
|
-
return this;
|
|
3290
|
-
}
|
|
3291
|
-
withSshKey(username, sshKey) {
|
|
3292
|
-
this.config.username = username;
|
|
3293
|
-
delete this.config["#password"];
|
|
3294
|
-
this.config["#sshKey"] = sshKey;
|
|
3295
|
-
return this;
|
|
3296
|
-
}
|
|
3297
|
-
build() {
|
|
3298
|
-
return {
|
|
3299
|
-
parameters: {
|
|
3300
|
-
git: {
|
|
3301
|
-
repo: this.repositoryUrl,
|
|
3302
|
-
...this.config
|
|
3303
|
-
}
|
|
3304
|
-
}
|
|
3305
|
-
};
|
|
3306
|
-
}
|
|
3307
|
-
buildForDataApp() {
|
|
3308
|
-
return {
|
|
3309
|
-
parameters: {
|
|
3310
|
-
dataApp: {
|
|
3311
|
-
git: {
|
|
3312
|
-
repository: this.repositoryUrl,
|
|
3313
|
-
...this.config
|
|
3314
|
-
}
|
|
3315
|
-
}
|
|
3316
|
-
}
|
|
3317
|
-
};
|
|
3318
|
-
}
|
|
3319
|
-
};
|
|
3320
|
-
var createGitRepoConfigDataBuilder = (repositoryUrl) => new GitRepoConfigDataBuilder(repositoryUrl);
|
|
3321
|
-
|
|
3322
|
-
// src/clients/syncActions/gitRepository/gitRepository.ts
|
|
3323
|
-
var createGitRepository = (sendSyncAction) => {
|
|
3324
|
-
const getDataAppPublicGitRepository = async ({ repositoryUrl, ...other }, signal) => {
|
|
3325
|
-
const data = await sendSyncAction(
|
|
3326
|
-
{
|
|
3327
|
-
...other,
|
|
3328
|
-
action: SyncAction.DATA_APP_GIT_REPOSITORY,
|
|
3329
|
-
componentId: Component.DATA_APP,
|
|
3330
|
-
configData: createGitRepoConfigDataBuilder(repositoryUrl).buildForDataApp()
|
|
3331
|
-
},
|
|
3332
|
-
signal
|
|
3333
|
-
);
|
|
3334
|
-
return Repository.parse(data);
|
|
3335
|
-
};
|
|
3336
|
-
const getDataAppPasswordPrivateGitRepository = async ({ repositoryUrl, username, password, ...other }, signal) => {
|
|
3337
|
-
const data = await sendSyncAction(
|
|
3338
|
-
{
|
|
3339
|
-
...other,
|
|
3340
|
-
action: SyncAction.DATA_APP_GIT_REPOSITORY,
|
|
3341
|
-
componentId: Component.DATA_APP,
|
|
3342
|
-
configData: createGitRepoConfigDataBuilder(repositoryUrl).withCredentials(username, password).buildForDataApp()
|
|
3343
|
-
},
|
|
3344
|
-
signal
|
|
3345
|
-
);
|
|
3346
|
-
return Repository.parse(data);
|
|
36
|
+
this.name = "ServiceUnavailableError";
|
|
37
|
+
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var agentSettingsSchema = zod.z.object({
|
|
41
|
+
projectId: zod.z.string(),
|
|
42
|
+
customInstructions: zod.z.string().nullable(),
|
|
43
|
+
createdAt: zod.z.string(),
|
|
44
|
+
updatedAt: zod.z.string()
|
|
45
|
+
});
|
|
46
|
+
var toolPermissionValueSchema = zod.z.enum(["always_allow", "always_ask", "blocked"]);
|
|
47
|
+
var userAgentSettingsSchema = zod.z.object({
|
|
48
|
+
projectId: zod.z.string(),
|
|
49
|
+
userId: zod.z.string(),
|
|
50
|
+
customInstructions: zod.z.string().nullable(),
|
|
51
|
+
toolPermissions: zod.z.record(zod.z.string(), toolPermissionValueSchema).nullable(),
|
|
52
|
+
createdAt: zod.z.string(),
|
|
53
|
+
updatedAt: zod.z.string()
|
|
54
|
+
});
|
|
55
|
+
var toolInfoSchema = zod.z.object({
|
|
56
|
+
name: zod.z.string(),
|
|
57
|
+
description: zod.z.string(),
|
|
58
|
+
readOnly: zod.z.boolean()
|
|
59
|
+
});
|
|
60
|
+
var toolsListResponseSchema = zod.z.object({
|
|
61
|
+
tools: zod.z.array(toolInfoSchema)
|
|
62
|
+
});
|
|
63
|
+
var sandboxFileEntrySchema = zod.z.object({
|
|
64
|
+
name: zod.z.string(),
|
|
65
|
+
path: zod.z.string(),
|
|
66
|
+
type: zod.z.enum(["file", "dir"]),
|
|
67
|
+
size: zod.z.number().int().nonnegative().optional()
|
|
68
|
+
});
|
|
69
|
+
var sandboxFileListingSchema = zod.z.object({
|
|
70
|
+
entries: zod.z.array(sandboxFileEntrySchema)
|
|
71
|
+
});
|
|
72
|
+
var sandboxFileContentSchema = zod.z.object({
|
|
73
|
+
content: zod.z.string(),
|
|
74
|
+
encoding: zod.z.enum(["utf-8", "binary"]),
|
|
75
|
+
truncated: zod.z.boolean(),
|
|
76
|
+
size: zod.z.number().int().nonnegative()
|
|
77
|
+
});
|
|
78
|
+
var sandboxGitBranchSchema = zod.z.object({
|
|
79
|
+
branch: zod.z.string().nullable()
|
|
80
|
+
});
|
|
81
|
+
var createKaiAgentClient = ({ baseUrl, middlewares }) => {
|
|
82
|
+
const clientOptions = { baseUrl: chunkHPVTVQBJ_cjs.normalizeBaseUrl(baseUrl), middlewares };
|
|
83
|
+
const client = chunkHPVTVQBJ_cjs.createOpenapiFetchClient(clientOptions);
|
|
84
|
+
const genericClient = chunkHPVTVQBJ_cjs.createGenericFetchClient(clientOptions);
|
|
85
|
+
const getHistory = async (params) => {
|
|
86
|
+
const { data } = await client.get("/api/history", { query: params });
|
|
87
|
+
return data;
|
|
3347
88
|
};
|
|
3348
|
-
const
|
|
3349
|
-
const data = await
|
|
3350
|
-
|
|
3351
|
-
...other,
|
|
3352
|
-
action: SyncAction.DATA_APP_GIT_REPOSITORY,
|
|
3353
|
-
componentId: Component.DATA_APP,
|
|
3354
|
-
configData: createGitRepoConfigDataBuilder(repositoryUrl).withSshKey(username, sshKey).buildForDataApp()
|
|
3355
|
-
},
|
|
3356
|
-
signal
|
|
3357
|
-
);
|
|
3358
|
-
return Repository.parse(data);
|
|
89
|
+
const getChat = async (chatId, signal) => {
|
|
90
|
+
const { data } = await client.get("/api/chat/{id}", { path: { id: chatId } }, { signal });
|
|
91
|
+
return data;
|
|
3359
92
|
};
|
|
3360
|
-
const
|
|
3361
|
-
const data = await
|
|
3362
|
-
|
|
3363
|
-
...other,
|
|
3364
|
-
action: SyncAction.GIT_REPOSITORY,
|
|
3365
|
-
componentId,
|
|
3366
|
-
configData: createGitRepoConfigDataBuilder(repositoryUrl).build()
|
|
3367
|
-
},
|
|
3368
|
-
signal
|
|
3369
|
-
);
|
|
3370
|
-
return Repository.parse(data);
|
|
93
|
+
const deleteChat = async (chatId) => {
|
|
94
|
+
const { data } = await client.delete("/api/chat", { query: { id: chatId } });
|
|
95
|
+
return data;
|
|
3371
96
|
};
|
|
3372
|
-
const
|
|
3373
|
-
const
|
|
3374
|
-
|
|
3375
|
-
...other,
|
|
3376
|
-
action: SyncAction.GIT_REPOSITORY,
|
|
3377
|
-
componentId,
|
|
3378
|
-
configData: createGitRepoConfigDataBuilder(repositoryUrl).withCredentials(username, password).build()
|
|
3379
|
-
},
|
|
3380
|
-
signal
|
|
3381
|
-
);
|
|
3382
|
-
return Repository.parse(data);
|
|
97
|
+
const createChat = async (request) => {
|
|
98
|
+
const { response } = await client.post("/api/chat", { body: request });
|
|
99
|
+
return response;
|
|
3383
100
|
};
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
getDataAppSSHKeyPrivateGitRepository,
|
|
3388
|
-
getPublicGitRepository,
|
|
3389
|
-
getPrivateGitRepository
|
|
101
|
+
const getVotes = async (chatId) => {
|
|
102
|
+
const { data } = await client.get("/api/vote", { query: { chatId } });
|
|
103
|
+
return data;
|
|
3390
104
|
};
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
const { data } = await client.post(
|
|
3397
|
-
"/actions",
|
|
3398
|
-
{
|
|
3399
|
-
body
|
|
3400
|
-
},
|
|
3401
|
-
{ signal }
|
|
3402
|
-
);
|
|
105
|
+
const submitVote = async (params) => {
|
|
106
|
+
await client.patch("/api/vote", { body: params });
|
|
107
|
+
};
|
|
108
|
+
const getUsage = async (signal) => {
|
|
109
|
+
const { data } = await client.get("/api/usage", {}, { signal });
|
|
3403
110
|
return data;
|
|
3404
111
|
};
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
const client = createOpenapiFetchClient({
|
|
3408
|
-
baseUrl,
|
|
3409
|
-
middlewares
|
|
3410
|
-
});
|
|
3411
|
-
const sendSyncAction = createSendSyncAction(client);
|
|
3412
|
-
const enrollMFA = ({ email: email2, ...rest }, signal) => {
|
|
3413
|
-
return sendSyncAction(
|
|
3414
|
-
{
|
|
3415
|
-
...rest,
|
|
3416
|
-
action: SyncAction.ENROLL_MFA,
|
|
3417
|
-
configData: {
|
|
3418
|
-
parameters: {
|
|
3419
|
-
user: {
|
|
3420
|
-
email: email2
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
},
|
|
3425
|
-
signal
|
|
3426
|
-
);
|
|
112
|
+
const approveToolCall = async (chatId, body) => {
|
|
113
|
+
await client.post("/api/chat/{id}/approval", { path: { id: chatId }, body });
|
|
3427
114
|
};
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
gitRepository: createGitRepository(sendSyncAction)
|
|
115
|
+
const submitToolOutput = async (chatId, body) => {
|
|
116
|
+
await client.post("/api/chat/{id}/ui-tool-result", { path: { id: chatId }, body });
|
|
3431
117
|
};
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
// src/clients/telemetry/provisioning/provisioning.ts
|
|
3435
|
-
var createProvisioning = (client) => {
|
|
3436
|
-
const createCredentials = async (body, signal) => {
|
|
3437
|
-
const { data } = await client.post(
|
|
3438
|
-
"/provisioning/workspace",
|
|
3439
|
-
{ body },
|
|
3440
|
-
{ signal }
|
|
3441
|
-
);
|
|
118
|
+
const stopChat = async (chatId) => {
|
|
119
|
+
const { data } = await client.post("/api/chat/{id}/stop", { path: { id: chatId } });
|
|
3442
120
|
return data;
|
|
3443
121
|
};
|
|
3444
|
-
|
|
3445
|
-
|
|
122
|
+
const getSuggestions = async (request, signal) => {
|
|
123
|
+
const { data } = await genericClient.post(
|
|
124
|
+
"/api/suggestions",
|
|
125
|
+
{ body: request },
|
|
126
|
+
{ signal }
|
|
127
|
+
);
|
|
128
|
+
const result = chunkU5SE6W5M_cjs.suggestionsApiResponseSchema.safeParse(data);
|
|
129
|
+
if (!result.success) {
|
|
130
|
+
throw new Error("Invalid suggestions response format");
|
|
131
|
+
}
|
|
132
|
+
return result.data;
|
|
3446
133
|
};
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
});
|
|
3455
|
-
return {
|
|
3456
|
-
provisioning: createProvisioning(client)
|
|
134
|
+
const getAgentSettings = async (signal) => {
|
|
135
|
+
const { data } = await genericClient.get("/api/settings", {}, { signal });
|
|
136
|
+
const result = agentSettingsSchema.safeParse(data);
|
|
137
|
+
if (!result.success) {
|
|
138
|
+
throw new Error("Invalid agent settings response format");
|
|
139
|
+
}
|
|
140
|
+
return result.data;
|
|
3457
141
|
};
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
baseUrl,
|
|
3464
|
-
middlewares
|
|
3465
|
-
});
|
|
3466
|
-
const getVariables = async (query, signal) => {
|
|
3467
|
-
const { data } = await client.get(
|
|
3468
|
-
"/variables",
|
|
3469
|
-
{ query },
|
|
3470
|
-
{
|
|
3471
|
-
signal
|
|
3472
|
-
}
|
|
142
|
+
const updateAgentSettings = async (request, signal) => {
|
|
143
|
+
const { data } = await genericClient.patch(
|
|
144
|
+
"/api/settings",
|
|
145
|
+
{ body: request },
|
|
146
|
+
{ signal }
|
|
3473
147
|
);
|
|
3474
|
-
|
|
148
|
+
const result = agentSettingsSchema.safeParse(data);
|
|
149
|
+
if (!result.success) {
|
|
150
|
+
throw new Error("Invalid agent settings response format");
|
|
151
|
+
}
|
|
152
|
+
return result.data;
|
|
3475
153
|
};
|
|
3476
|
-
const
|
|
3477
|
-
await
|
|
3478
|
-
"/
|
|
3479
|
-
{
|
|
3480
|
-
path: { hash }
|
|
3481
|
-
},
|
|
154
|
+
const getUserAgentSettings = async (signal) => {
|
|
155
|
+
const { data } = await genericClient.get(
|
|
156
|
+
"/api/settings/user",
|
|
157
|
+
{},
|
|
3482
158
|
{ signal }
|
|
3483
159
|
);
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
throw new UserError("Encryption of a value failed. Please contact our support.");
|
|
160
|
+
const result = userAgentSettingsSchema.safeParse(data);
|
|
161
|
+
if (!result.success) {
|
|
162
|
+
throw new Error("Invalid user agent settings response format");
|
|
3488
163
|
}
|
|
3489
|
-
|
|
3490
|
-
return data;
|
|
164
|
+
return result.data;
|
|
3491
165
|
};
|
|
3492
|
-
const
|
|
3493
|
-
const { data } = await
|
|
3494
|
-
"/
|
|
3495
|
-
{
|
|
3496
|
-
path: { branchId }
|
|
3497
|
-
},
|
|
166
|
+
const updateUserAgentSettings = async (request, signal) => {
|
|
167
|
+
const { data } = await genericClient.patch(
|
|
168
|
+
"/api/settings/user",
|
|
169
|
+
{ body: request },
|
|
3498
170
|
{ signal }
|
|
3499
171
|
);
|
|
3500
|
-
|
|
172
|
+
const result = userAgentSettingsSchema.safeParse(data);
|
|
173
|
+
if (!result.success) {
|
|
174
|
+
throw new Error("Invalid user agent settings response format");
|
|
175
|
+
}
|
|
176
|
+
return result.data;
|
|
3501
177
|
};
|
|
3502
|
-
const
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
178
|
+
const getToolsList = async (signal) => {
|
|
179
|
+
const { data } = await genericClient.get(
|
|
180
|
+
"/api/settings/tools",
|
|
181
|
+
{},
|
|
182
|
+
{ signal }
|
|
183
|
+
);
|
|
184
|
+
const result = toolsListResponseSchema.safeParse(data);
|
|
185
|
+
if (!result.success) {
|
|
186
|
+
throw new Error("Invalid tools list response format");
|
|
187
|
+
}
|
|
188
|
+
return result.data;
|
|
3509
189
|
};
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
190
|
+
const listSandboxFiles = async (chatId, path, signal) => {
|
|
191
|
+
const { data } = await genericClient.get(
|
|
192
|
+
`/api/chat/${encodeURIComponent(chatId)}/sandbox/files`,
|
|
193
|
+
{ query: path ? { path } : void 0 },
|
|
194
|
+
{ signal }
|
|
195
|
+
);
|
|
196
|
+
const result = sandboxFileListingSchema.safeParse(data);
|
|
197
|
+
if (!result.success) {
|
|
198
|
+
throw new Error("Invalid sandbox files response format");
|
|
199
|
+
}
|
|
200
|
+
return result.data;
|
|
3520
201
|
};
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3523
|
-
|
|
202
|
+
const readSandboxFile = async (chatId, path, signal) => {
|
|
203
|
+
const { data } = await genericClient.get(
|
|
204
|
+
`/api/chat/${encodeURIComponent(chatId)}/sandbox/file`,
|
|
205
|
+
{ query: { path } },
|
|
206
|
+
{ signal }
|
|
207
|
+
);
|
|
208
|
+
const result = sandboxFileContentSchema.safeParse(data);
|
|
209
|
+
if (!result.success) {
|
|
210
|
+
throw new Error("Invalid sandbox file response format");
|
|
211
|
+
}
|
|
212
|
+
return result.data;
|
|
3524
213
|
};
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
214
|
+
const getSandboxGitBranch = async (chatId, signal) => {
|
|
215
|
+
const { data } = await genericClient.get(
|
|
216
|
+
`/api/chat/${encodeURIComponent(chatId)}/sandbox/git-branch`,
|
|
217
|
+
{},
|
|
218
|
+
{ signal }
|
|
219
|
+
);
|
|
220
|
+
const result = sandboxGitBranchSchema.safeParse(data);
|
|
221
|
+
if (!result.success) {
|
|
222
|
+
throw new Error("Invalid sandbox git-branch response format");
|
|
223
|
+
}
|
|
224
|
+
return result.data;
|
|
3529
225
|
};
|
|
226
|
+
const chatStreamUrl = clientOptions.baseUrl + "/api/chat";
|
|
3530
227
|
return {
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
228
|
+
getHistory,
|
|
229
|
+
getChat,
|
|
230
|
+
deleteChat,
|
|
231
|
+
createChat,
|
|
232
|
+
getVotes,
|
|
233
|
+
submitVote,
|
|
234
|
+
getUsage,
|
|
235
|
+
approveToolCall,
|
|
236
|
+
submitToolOutput,
|
|
237
|
+
stopChat,
|
|
238
|
+
getSuggestions,
|
|
239
|
+
getAgentSettings,
|
|
240
|
+
updateAgentSettings,
|
|
241
|
+
getUserAgentSettings,
|
|
242
|
+
updateUserAgentSettings,
|
|
243
|
+
getToolsList,
|
|
244
|
+
listSandboxFiles,
|
|
245
|
+
readSandboxFile,
|
|
246
|
+
getSandboxGitBranch,
|
|
247
|
+
chatStreamUrl
|
|
3535
248
|
};
|
|
3536
249
|
};
|
|
3537
250
|
|
|
251
|
+
// src/utils/assert.ts
|
|
252
|
+
function assert(value, message) {
|
|
253
|
+
if (value == null) {
|
|
254
|
+
throw new Error(message);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
3538
258
|
// src/domain/stack.ts
|
|
3539
259
|
var SERVICE_URL_OVERRIDES = {
|
|
3540
260
|
// The service URL for the Kai Assistant is incomplete; we need to add the `/api` suffix to get the full URL for the API.
|
|
@@ -3577,208 +297,6 @@ var createStack = ({ stackInfo, clientServiceUrls }) => {
|
|
|
3577
297
|
};
|
|
3578
298
|
};
|
|
3579
299
|
|
|
3580
|
-
// src/sdks/storage/storageSdk.ts
|
|
3581
|
-
var DEFAULT_POLL_INTERVAL = 2e3;
|
|
3582
|
-
var JOB_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["success", "warning", "error", "terminated", "cancelled"]);
|
|
3583
|
-
var createStorageSdk = ({ storageClient }) => {
|
|
3584
|
-
const waitForJob = async (job, options) => {
|
|
3585
|
-
const { data } = await poll({
|
|
3586
|
-
pollFn: (abortSignal) => storageClient.jobs.getJob(job.id, abortSignal),
|
|
3587
|
-
isDone: (j) => JOB_TERMINAL_STATUSES.has(j.status),
|
|
3588
|
-
interval: options?.interval ?? DEFAULT_POLL_INTERVAL,
|
|
3589
|
-
maxAttempts: options?.maxAttempts,
|
|
3590
|
-
abortSignal: options?.abortSignal
|
|
3591
|
-
});
|
|
3592
|
-
return data;
|
|
3593
|
-
};
|
|
3594
|
-
const createTable = async (bucketId, body, options) => {
|
|
3595
|
-
const job = await storageClient.tables.createTableAsync(bucketId, body, options?.abortSignal);
|
|
3596
|
-
return waitForJob(job, options);
|
|
3597
|
-
};
|
|
3598
|
-
const importFromFile = async (tableId, body, options) => {
|
|
3599
|
-
const job = await storageClient.tables.importAsync(tableId, body, options?.abortSignal);
|
|
3600
|
-
return waitForJob(job, options);
|
|
3601
|
-
};
|
|
3602
|
-
const exportToFile = async (tableId, body, options) => {
|
|
3603
|
-
const job = await storageClient.tables.exportAsync(tableId, body, options?.abortSignal);
|
|
3604
|
-
return waitForJob(job, options);
|
|
3605
|
-
};
|
|
3606
|
-
const getBucketListing = async (bucketId, signal) => storageClient.buckets.getListing(bucketId, signal);
|
|
3607
|
-
const listBucketListings = async (signal) => storageClient.buckets.listListings(signal);
|
|
3608
|
-
const createBucketListing = async (bucketId, input, options) => {
|
|
3609
|
-
const job = await storageClient.buckets.createListing(bucketId, input, options?.abortSignal);
|
|
3610
|
-
return waitForJob(job, options);
|
|
3611
|
-
};
|
|
3612
|
-
const updateBucketListing = async (bucketId, input, options) => {
|
|
3613
|
-
const job = await storageClient.buckets.updateListing(bucketId, input, options?.abortSignal);
|
|
3614
|
-
return waitForJob(job, options);
|
|
3615
|
-
};
|
|
3616
|
-
const deleteBucketListing = async (bucketId, options) => {
|
|
3617
|
-
const job = await storageClient.buckets.deleteListing(bucketId, options?.abortSignal);
|
|
3618
|
-
return waitForJob(job, options);
|
|
3619
|
-
};
|
|
3620
|
-
return {
|
|
3621
|
-
createTable,
|
|
3622
|
-
importFromFile,
|
|
3623
|
-
exportToFile,
|
|
3624
|
-
getBucketListing,
|
|
3625
|
-
listBucketListings,
|
|
3626
|
-
createBucketListing,
|
|
3627
|
-
updateBucketListing,
|
|
3628
|
-
deleteBucketListing
|
|
3629
|
-
};
|
|
3630
|
-
};
|
|
3631
|
-
|
|
3632
|
-
// src/sdks/tag/tagSdk.ts
|
|
3633
|
-
var ObjectType = {
|
|
3634
|
-
TAG: "tag",
|
|
3635
|
-
TAG_BINDING: "tag-binding"
|
|
3636
|
-
};
|
|
3637
|
-
var createTagSdk = ({ metastoreClient }) => {
|
|
3638
|
-
const _getTagMetaObjects = async (type, signal) => {
|
|
3639
|
-
const response = await metastoreClient.repository.getMetaObjects(
|
|
3640
|
-
{
|
|
3641
|
-
objectType: type
|
|
3642
|
-
},
|
|
3643
|
-
signal
|
|
3644
|
-
);
|
|
3645
|
-
return response.data.map(({ attributes }) => attributes);
|
|
3646
|
-
};
|
|
3647
|
-
const _getAllTagBindingMapByTagId = async (signal) => {
|
|
3648
|
-
const tagBindings = await _getTagMetaObjects(ObjectType.TAG_BINDING, signal);
|
|
3649
|
-
return Object.groupBy(tagBindings, (binding) => binding.data.tagUUID);
|
|
3650
|
-
};
|
|
3651
|
-
const _getTagBindingMapByTagId = async (tagUUIDs, objectId, signal) => {
|
|
3652
|
-
const tagBindingMapByTagId = await _getAllTagBindingMapByTagId(signal);
|
|
3653
|
-
const objectUID = keboolaUID.serialize(objectId);
|
|
3654
|
-
return tagUUIDs.reduce((acc, tagUUID) => {
|
|
3655
|
-
if (acc[tagUUID]) return acc;
|
|
3656
|
-
const tagBindings = tagBindingMapByTagId[tagUUID] ?? [];
|
|
3657
|
-
acc[tagUUID] = tagBindings.find((binding) => binding.data.objectUID === objectUID) ?? null;
|
|
3658
|
-
return acc;
|
|
3659
|
-
}, {});
|
|
3660
|
-
};
|
|
3661
|
-
const _deleteTagBindings = async (tagBindings) => {
|
|
3662
|
-
await concurrent({
|
|
3663
|
-
items: tagBindings,
|
|
3664
|
-
process: async (binding) => metastoreClient.repository.deleteMetaObject({
|
|
3665
|
-
objectType: ObjectType.TAG_BINDING,
|
|
3666
|
-
UUID: binding.uuid
|
|
3667
|
-
}),
|
|
3668
|
-
concurrency: 5
|
|
3669
|
-
});
|
|
3670
|
-
};
|
|
3671
|
-
const getTags = async (signal) => {
|
|
3672
|
-
const [tags, tagBindingMapByTagId] = await Promise.all([
|
|
3673
|
-
_getTagMetaObjects(ObjectType.TAG, signal),
|
|
3674
|
-
_getAllTagBindingMapByTagId(signal)
|
|
3675
|
-
]);
|
|
3676
|
-
return tags.map((tag) => ({
|
|
3677
|
-
tag,
|
|
3678
|
-
bindings: tagBindingMapByTagId[tag.uuid] ?? []
|
|
3679
|
-
}));
|
|
3680
|
-
};
|
|
3681
|
-
const getTagsByObjectId = async (objectId, signal) => {
|
|
3682
|
-
const tags = await getTags(signal);
|
|
3683
|
-
const keboolaObjectUID = keboolaUID.serialize(objectId);
|
|
3684
|
-
const mapByTagId = tags.reduce((acc, { tag, bindings }) => {
|
|
3685
|
-
acc[tag.uuid] = new Set(bindings.map((binding) => binding.data.objectUID));
|
|
3686
|
-
return acc;
|
|
3687
|
-
}, {});
|
|
3688
|
-
return tags.filter(({ tag }) => mapByTagId[tag.uuid]?.has(keboolaObjectUID));
|
|
3689
|
-
};
|
|
3690
|
-
const createTag = async (data, meta = {}) => {
|
|
3691
|
-
const {
|
|
3692
|
-
data: { attributes: tag }
|
|
3693
|
-
} = await metastoreClient.repository.createMetaObject({
|
|
3694
|
-
objectType: ObjectType.TAG,
|
|
3695
|
-
data,
|
|
3696
|
-
name: generateUUID(),
|
|
3697
|
-
...meta
|
|
3698
|
-
});
|
|
3699
|
-
return tag;
|
|
3700
|
-
};
|
|
3701
|
-
const updateTag = async (tagUUID, data, meta = {}) => {
|
|
3702
|
-
const {
|
|
3703
|
-
data: { attributes: tag }
|
|
3704
|
-
} = await metastoreClient.repository.updateMetaObject({
|
|
3705
|
-
objectType: ObjectType.TAG,
|
|
3706
|
-
UUID: tagUUID,
|
|
3707
|
-
data,
|
|
3708
|
-
...meta
|
|
3709
|
-
});
|
|
3710
|
-
return tag;
|
|
3711
|
-
};
|
|
3712
|
-
const deleteTag = async (tagUUID) => {
|
|
3713
|
-
const allBindings = await _getTagMetaObjects(ObjectType.TAG_BINDING);
|
|
3714
|
-
const tagBindings = allBindings.filter(({ data }) => data.tagUUID === tagUUID);
|
|
3715
|
-
await Promise.all([
|
|
3716
|
-
// delete tag itself
|
|
3717
|
-
metastoreClient.repository.deleteMetaObject({
|
|
3718
|
-
objectType: ObjectType.TAG,
|
|
3719
|
-
UUID: tagUUID
|
|
3720
|
-
}),
|
|
3721
|
-
// delete all tag associations
|
|
3722
|
-
_deleteTagBindings(tagBindings)
|
|
3723
|
-
]);
|
|
3724
|
-
};
|
|
3725
|
-
const assignTags = async (tagUUIDs, objectId, meta = {}) => {
|
|
3726
|
-
const tagBindingMapByTagId = await _getTagBindingMapByTagId(tagUUIDs, objectId);
|
|
3727
|
-
const unassignedTagUUIDs = tagUUIDs.filter((tagUUID) => tagBindingMapByTagId[tagUUID] === null);
|
|
3728
|
-
await concurrent({
|
|
3729
|
-
items: unassignedTagUUIDs,
|
|
3730
|
-
process: async (tagUUID) => metastoreClient.repository.createMetaObject({
|
|
3731
|
-
objectType: ObjectType.TAG_BINDING,
|
|
3732
|
-
data: {
|
|
3733
|
-
objectUID: keboolaUID.serialize(objectId),
|
|
3734
|
-
tagUUID
|
|
3735
|
-
},
|
|
3736
|
-
name: generateUUID(),
|
|
3737
|
-
...meta
|
|
3738
|
-
}),
|
|
3739
|
-
concurrency: 5
|
|
3740
|
-
});
|
|
3741
|
-
};
|
|
3742
|
-
const unassignTags = async (tagUUIDs, objectID) => {
|
|
3743
|
-
const tagBindingMapByTagId = await _getTagBindingMapByTagId(tagUUIDs, objectID);
|
|
3744
|
-
const assignedTagUUIDs = tagUUIDs.filter((tagUUID) => tagBindingMapByTagId[tagUUID] !== null);
|
|
3745
|
-
const tagBindings = assignedTagUUIDs.map((tagUUID) => tagBindingMapByTagId[tagUUID]);
|
|
3746
|
-
await concurrent({
|
|
3747
|
-
items: tagBindings,
|
|
3748
|
-
process: async (tagBinding) => metastoreClient.repository.deleteMetaObject({
|
|
3749
|
-
objectType: ObjectType.TAG_BINDING,
|
|
3750
|
-
UUID: tagBinding.uuid
|
|
3751
|
-
}),
|
|
3752
|
-
concurrency: 5
|
|
3753
|
-
});
|
|
3754
|
-
};
|
|
3755
|
-
const unassignAllTags = async (objectID, signal) => {
|
|
3756
|
-
const tagBindings = await _getTagMetaObjects(ObjectType.TAG_BINDING, signal);
|
|
3757
|
-
const objectsTagBindings = tagBindings.filter(
|
|
3758
|
-
({ data }) => data.objectUID === keboolaUID.serialize(objectID)
|
|
3759
|
-
);
|
|
3760
|
-
await _deleteTagBindings(objectsTagBindings);
|
|
3761
|
-
};
|
|
3762
|
-
const createAndAssignTag = async (data, objectId, meta = {}) => {
|
|
3763
|
-
const tag = await createTag(data, meta);
|
|
3764
|
-
await assignTags([tag.uuid], objectId, meta);
|
|
3765
|
-
return tag;
|
|
3766
|
-
};
|
|
3767
|
-
return {
|
|
3768
|
-
// retrievals
|
|
3769
|
-
getTags,
|
|
3770
|
-
getTagsByObjectId,
|
|
3771
|
-
// modifications
|
|
3772
|
-
createTag,
|
|
3773
|
-
updateTag,
|
|
3774
|
-
deleteTag,
|
|
3775
|
-
assignTags,
|
|
3776
|
-
unassignTags,
|
|
3777
|
-
unassignAllTags,
|
|
3778
|
-
createAndAssignTag
|
|
3779
|
-
};
|
|
3780
|
-
};
|
|
3781
|
-
|
|
3782
300
|
// src/serviceClientRegistry/utils.ts
|
|
3783
301
|
var isBuiltInProperty = (property) => typeof property === "symbol" || property === "then" || property === "constructor" || property === "toString" || property === "valueOf";
|
|
3784
302
|
var createDummyClient = ({
|
|
@@ -3838,14 +356,14 @@ var createClients = async ({
|
|
|
3838
356
|
clientServiceUrls,
|
|
3839
357
|
storageMiddlewares
|
|
3840
358
|
}) => {
|
|
3841
|
-
const callbackMiddleware = createCallbackMiddleware(callbacks);
|
|
3842
|
-
const storageTokenMiddleware = createStorageTokenMiddleware(token.storageApi);
|
|
359
|
+
const callbackMiddleware = chunkHPVTVQBJ_cjs.createCallbackMiddleware(callbacks);
|
|
360
|
+
const storageTokenMiddleware = chunkXFC52BJV_cjs.createStorageTokenMiddleware(token.storageApi);
|
|
3843
361
|
const commonMiddlewares = [callbackMiddleware, storageTokenMiddleware];
|
|
3844
|
-
const storage = createStorageClient({
|
|
362
|
+
const storage = chunkXFC52BJV_cjs.createStorageClient({
|
|
3845
363
|
baseUrl,
|
|
3846
364
|
middlewares: [...commonMiddlewares, ...storageMiddlewares || []]
|
|
3847
365
|
});
|
|
3848
|
-
const management = createManagementClient({
|
|
366
|
+
const management = chunkJKFIB6SQ_cjs.createManagementClient({
|
|
3849
367
|
baseUrl,
|
|
3850
368
|
token: token.managementApi,
|
|
3851
369
|
callbacks
|
|
@@ -3857,7 +375,7 @@ var createClients = async ({
|
|
|
3857
375
|
storage.tokens.verify()
|
|
3858
376
|
]);
|
|
3859
377
|
const stack = createStack({ stackInfo, clientServiceUrls });
|
|
3860
|
-
const project = createProject({ sapiToken });
|
|
378
|
+
const project = chunkGF4XZK5N_cjs.createProject({ sapiToken });
|
|
3861
379
|
const { client, meta } = createServiceClientRegistry()({
|
|
3862
380
|
getServiceBaseUrl: (serviceId) => stack.getServiceUrl(serviceId),
|
|
3863
381
|
onUnavailable: ({ serviceId, path, clientName }) => {
|
|
@@ -3867,47 +385,47 @@ var createClients = async ({
|
|
|
3867
385
|
{
|
|
3868
386
|
serviceId: "vault",
|
|
3869
387
|
clientName: "vault",
|
|
3870
|
-
clientFn: (serviceBaseUrl) => createVaultClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
388
|
+
clientFn: (serviceBaseUrl) => chunkYUEYMIMI_cjs.createVaultClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3871
389
|
},
|
|
3872
390
|
{
|
|
3873
391
|
serviceId: "data-science",
|
|
3874
392
|
clientName: "dataScience",
|
|
3875
|
-
clientFn: (serviceBaseUrl) => createDataScienceClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
393
|
+
clientFn: (serviceBaseUrl) => chunkHYUGRMCY_cjs.createDataScienceClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3876
394
|
},
|
|
3877
395
|
{
|
|
3878
396
|
serviceId: "encryption",
|
|
3879
397
|
clientName: "encryption",
|
|
3880
|
-
clientFn: (serviceBaseUrl) => createEncryptionClient({ baseUrl: serviceBaseUrl, middlewares: [callbackMiddleware] })
|
|
398
|
+
clientFn: (serviceBaseUrl) => chunkHCNNMUTR_cjs.createEncryptionClient({ baseUrl: serviceBaseUrl, middlewares: [callbackMiddleware] })
|
|
3881
399
|
},
|
|
3882
400
|
{
|
|
3883
401
|
serviceId: "editor",
|
|
3884
402
|
clientName: "editor",
|
|
3885
|
-
clientFn: (serviceBaseUrl) => createEditorClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
403
|
+
clientFn: (serviceBaseUrl) => chunkTIIRBQUA_cjs.createEditorClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3886
404
|
},
|
|
3887
405
|
{
|
|
3888
406
|
serviceId: "sync-actions",
|
|
3889
407
|
clientName: "syncActions",
|
|
3890
|
-
clientFn: (serviceBaseUrl) => createSyncActionsClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
408
|
+
clientFn: (serviceBaseUrl) => chunkXUDMML5C_cjs.createSyncActionsClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3891
409
|
},
|
|
3892
410
|
{
|
|
3893
411
|
serviceId: "telemetry",
|
|
3894
412
|
clientName: "telemetry",
|
|
3895
|
-
clientFn: (serviceBaseUrl) => createTelemetryClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
413
|
+
clientFn: (serviceBaseUrl) => chunkBGLICNTG_cjs.createTelemetryClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3896
414
|
},
|
|
3897
415
|
{
|
|
3898
416
|
serviceId: "query",
|
|
3899
417
|
clientName: "queryService",
|
|
3900
|
-
clientFn: (serviceBaseUrl) => createQueryServiceClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
418
|
+
clientFn: (serviceBaseUrl) => chunkLZ6A6J2E_cjs.createQueryServiceClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3901
419
|
},
|
|
3902
420
|
{
|
|
3903
421
|
serviceId: "queue",
|
|
3904
422
|
clientName: "queue",
|
|
3905
|
-
clientFn: (serviceBaseUrl) => createQueueClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
423
|
+
clientFn: (serviceBaseUrl) => chunkYXCVNX2Q_cjs.createQueueClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3906
424
|
},
|
|
3907
425
|
{
|
|
3908
426
|
serviceId: "kai-assistant",
|
|
3909
427
|
clientName: "chat",
|
|
3910
|
-
clientFn: (serviceBaseUrl) => createChatClient({
|
|
428
|
+
clientFn: (serviceBaseUrl) => chunk6RQDX6JY_cjs.createChatClient({
|
|
3911
429
|
storageApiUrl: baseUrl,
|
|
3912
430
|
baseUrl: serviceBaseUrl,
|
|
3913
431
|
middlewares: commonMiddlewares
|
|
@@ -3916,12 +434,12 @@ var createClients = async ({
|
|
|
3916
434
|
{
|
|
3917
435
|
serviceId: "ai",
|
|
3918
436
|
clientName: "ai",
|
|
3919
|
-
clientFn: (serviceBaseUrl) => createAiClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
437
|
+
clientFn: (serviceBaseUrl) => chunkJLNOESHX_cjs.createAiClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3920
438
|
},
|
|
3921
439
|
{
|
|
3922
440
|
serviceId: "import",
|
|
3923
441
|
clientName: "import",
|
|
3924
|
-
clientFn: (serviceBaseUrl) => createImportClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
442
|
+
clientFn: (serviceBaseUrl) => chunk3T54WH4X_cjs.createImportClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3925
443
|
},
|
|
3926
444
|
{
|
|
3927
445
|
serviceId: "kai-agent",
|
|
@@ -3934,26 +452,26 @@ var createClients = async ({
|
|
|
3934
452
|
{
|
|
3935
453
|
serviceId: "oauth",
|
|
3936
454
|
clientName: "oauth",
|
|
3937
|
-
clientFn: (serviceBaseUrl) => createOauthClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
455
|
+
clientFn: (serviceBaseUrl) => chunk633QJMHH_cjs.createOauthClient({ baseUrl: serviceBaseUrl, middlewares: commonMiddlewares })
|
|
3938
456
|
}
|
|
3939
457
|
]
|
|
3940
458
|
});
|
|
3941
|
-
const metastore = createMetastoreClient({
|
|
459
|
+
const metastore = chunkIY3VNVXD_cjs.createMetastoreClient({
|
|
3942
460
|
baseUrl: metastoreBaseUrl,
|
|
3943
461
|
middlewares: commonMiddlewares
|
|
3944
462
|
});
|
|
3945
|
-
const assets = createAssetsClient({
|
|
463
|
+
const assets = chunkEY5LALX2_cjs.createAssetsClient({
|
|
3946
464
|
baseUrl: assetsBaseUrl,
|
|
3947
465
|
middlewares: [callbackMiddleware]
|
|
3948
466
|
});
|
|
3949
|
-
const status = createStatusClient({
|
|
467
|
+
const status = chunkYPCD7M2N_cjs.createStatusClient({
|
|
3950
468
|
baseUrl: statusBaseUrl,
|
|
3951
469
|
middlewares: [callbackMiddleware]
|
|
3952
470
|
});
|
|
3953
|
-
const tag = createTagSdk({
|
|
471
|
+
const tag = chunkBR3SBEFE_cjs.createTagSdk({
|
|
3954
472
|
metastoreClient: metastore
|
|
3955
473
|
});
|
|
3956
|
-
const storageSdk = createStorageSdk({
|
|
474
|
+
const storageSdk = chunkDCTDH77P_cjs.createStorageSdk({
|
|
3957
475
|
storageClient: storage
|
|
3958
476
|
});
|
|
3959
477
|
return {
|
|
@@ -3994,8 +512,8 @@ var createApiClient = () => {
|
|
|
3994
512
|
// src/middlewares/loggingMiddleware.ts
|
|
3995
513
|
var CORRELATION_ID_HEADER = "X-Correlation-ID";
|
|
3996
514
|
var ALWAYS_REDACTED_HEADERS = [
|
|
3997
|
-
KeboolaHttpHeader.MANAGEMENT_API_TOKEN,
|
|
3998
|
-
KeboolaHttpHeader.STORAGE_API_TOKEN
|
|
515
|
+
chunkHPVTVQBJ_cjs.KeboolaHttpHeader.MANAGEMENT_API_TOKEN,
|
|
516
|
+
chunkHPVTVQBJ_cjs.KeboolaHttpHeader.STORAGE_API_TOKEN
|
|
3999
517
|
];
|
|
4000
518
|
var ALWAYS_REDACTED_QUERY_PARAMS = /* @__PURE__ */ new Set([
|
|
4001
519
|
"token",
|
|
@@ -4026,7 +544,7 @@ var getRedactedUrl = (rawUrl) => {
|
|
|
4026
544
|
return url.toString();
|
|
4027
545
|
};
|
|
4028
546
|
var ensureCorrelationId = (request) => {
|
|
4029
|
-
const correlationId = request.headers.get(CORRELATION_ID_HEADER) ?? generateUUID();
|
|
547
|
+
const correlationId = request.headers.get(CORRELATION_ID_HEADER) ?? chunkBR3SBEFE_cjs.generateUUID();
|
|
4030
548
|
request.headers.set(CORRELATION_ID_HEADER, correlationId);
|
|
4031
549
|
return correlationId;
|
|
4032
550
|
};
|
|
@@ -4105,13 +623,13 @@ var createLoggingMiddleware = (options = {}) => {
|
|
|
4105
623
|
// src/middlewares/retryMiddleware.ts
|
|
4106
624
|
var DEFAULT_MAX_RETRIES = 5;
|
|
4107
625
|
var DEFAULT_RETRYABLE_STATUSES = [
|
|
4108
|
-
HttpStatus.INTERNAL_SERVER_ERROR,
|
|
4109
|
-
HttpStatus.BAD_GATEWAY,
|
|
4110
|
-
HttpStatus.SERVICE_UNAVAILABLE,
|
|
4111
|
-
HttpStatus.GATEWAY_TIMEOUT
|
|
626
|
+
chunkHPVTVQBJ_cjs.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
627
|
+
chunkHPVTVQBJ_cjs.HttpStatus.BAD_GATEWAY,
|
|
628
|
+
chunkHPVTVQBJ_cjs.HttpStatus.SERVICE_UNAVAILABLE,
|
|
629
|
+
chunkHPVTVQBJ_cjs.HttpStatus.GATEWAY_TIMEOUT
|
|
4112
630
|
];
|
|
4113
631
|
var DEFAULT_BACKOFF_FACTOR = 0.3;
|
|
4114
|
-
var defaultShouldRetry = (error) => error instanceof ApiError && DEFAULT_RETRYABLE_STATUSES.includes(error.response.status);
|
|
632
|
+
var defaultShouldRetry = (error) => error instanceof chunkHPVTVQBJ_cjs.ApiError && DEFAULT_RETRYABLE_STATUSES.includes(error.response.status);
|
|
4115
633
|
var createRetryMiddleware = (options) => {
|
|
4116
634
|
const {
|
|
4117
635
|
maxRetries = DEFAULT_MAX_RETRIES,
|
|
@@ -4133,7 +651,7 @@ var createRetryMiddleware = (options) => {
|
|
|
4133
651
|
throw error;
|
|
4134
652
|
}
|
|
4135
653
|
const delayMs = backoffFactor * 1e3 * Math.pow(2, attempt);
|
|
4136
|
-
await delay(delayMs, request.request.signal ?? void 0);
|
|
654
|
+
await chunkDCTDH77P_cjs.delay(delayMs, request.request.signal ?? void 0);
|
|
4137
655
|
}
|
|
4138
656
|
}
|
|
4139
657
|
throw new Error("unreachable");
|
|
@@ -4142,35 +660,99 @@ var createRetryMiddleware = (options) => {
|
|
|
4142
660
|
|
|
4143
661
|
// src/devClient.ts
|
|
4144
662
|
var createDevApiClient = () => ({
|
|
4145
|
-
verify: createVerifyClient()
|
|
663
|
+
verify: chunk76AHKXLC_cjs.createVerifyClient()
|
|
4146
664
|
});
|
|
4147
665
|
|
|
4148
|
-
exports
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
exports
|
|
4153
|
-
|
|
666
|
+
Object.defineProperty(exports, "generateUUID", {
|
|
667
|
+
enumerable: true,
|
|
668
|
+
get: function () { return chunkBR3SBEFE_cjs.generateUUID; }
|
|
669
|
+
});
|
|
670
|
+
Object.defineProperty(exports, "keboolaUID", {
|
|
671
|
+
enumerable: true,
|
|
672
|
+
get: function () { return chunkBR3SBEFE_cjs.keboolaUID; }
|
|
673
|
+
});
|
|
674
|
+
Object.defineProperty(exports, "PollException", {
|
|
675
|
+
enumerable: true,
|
|
676
|
+
get: function () { return chunkDCTDH77P_cjs.PollException; }
|
|
677
|
+
});
|
|
678
|
+
Object.defineProperty(exports, "createStorageSdk", {
|
|
679
|
+
enumerable: true,
|
|
680
|
+
get: function () { return chunkDCTDH77P_cjs.createStorageSdk; }
|
|
681
|
+
});
|
|
682
|
+
Object.defineProperty(exports, "delay", {
|
|
683
|
+
enumerable: true,
|
|
684
|
+
get: function () { return chunkDCTDH77P_cjs.delay; }
|
|
685
|
+
});
|
|
686
|
+
Object.defineProperty(exports, "poll", {
|
|
687
|
+
enumerable: true,
|
|
688
|
+
get: function () { return chunkDCTDH77P_cjs.poll; }
|
|
689
|
+
});
|
|
690
|
+
Object.defineProperty(exports, "UserError", {
|
|
691
|
+
enumerable: true,
|
|
692
|
+
get: function () { return chunkYUEYMIMI_cjs.UserError; }
|
|
693
|
+
});
|
|
694
|
+
Object.defineProperty(exports, "ManagementClientAuthError", {
|
|
695
|
+
enumerable: true,
|
|
696
|
+
get: function () { return chunkJKFIB6SQ_cjs.ManagementClientAuthError; }
|
|
697
|
+
});
|
|
698
|
+
Object.defineProperty(exports, "isManagementClientAuthError", {
|
|
699
|
+
enumerable: true,
|
|
700
|
+
get: function () { return chunkJKFIB6SQ_cjs.isManagementClientAuthError; }
|
|
701
|
+
});
|
|
702
|
+
Object.defineProperty(exports, "series", {
|
|
703
|
+
enumerable: true,
|
|
704
|
+
get: function () { return chunkXFC52BJV_cjs.series; }
|
|
705
|
+
});
|
|
706
|
+
Object.defineProperty(exports, "concurrent", {
|
|
707
|
+
enumerable: true,
|
|
708
|
+
get: function () { return chunkCVV4HROS_cjs.concurrent; }
|
|
709
|
+
});
|
|
710
|
+
Object.defineProperty(exports, "parseLogLines", {
|
|
711
|
+
enumerable: true,
|
|
712
|
+
get: function () { return chunkHYUGRMCY_cjs.parseLogLines; }
|
|
713
|
+
});
|
|
714
|
+
Object.defineProperty(exports, "ApiError", {
|
|
715
|
+
enumerable: true,
|
|
716
|
+
get: function () { return chunkHPVTVQBJ_cjs.ApiError; }
|
|
717
|
+
});
|
|
718
|
+
Object.defineProperty(exports, "HttpContentType", {
|
|
719
|
+
enumerable: true,
|
|
720
|
+
get: function () { return chunkHPVTVQBJ_cjs.HttpContentType; }
|
|
721
|
+
});
|
|
722
|
+
Object.defineProperty(exports, "HttpHeader", {
|
|
723
|
+
enumerable: true,
|
|
724
|
+
get: function () { return chunkHPVTVQBJ_cjs.HttpHeader; }
|
|
725
|
+
});
|
|
726
|
+
Object.defineProperty(exports, "KeboolaHttpHeader", {
|
|
727
|
+
enumerable: true,
|
|
728
|
+
get: function () { return chunkHPVTVQBJ_cjs.KeboolaHttpHeader; }
|
|
729
|
+
});
|
|
730
|
+
Object.defineProperty(exports, "createGenericFetchClient", {
|
|
731
|
+
enumerable: true,
|
|
732
|
+
get: function () { return chunkHPVTVQBJ_cjs.createGenericFetchClient; }
|
|
733
|
+
});
|
|
734
|
+
Object.defineProperty(exports, "isAbortError", {
|
|
735
|
+
enumerable: true,
|
|
736
|
+
get: function () { return chunkHPVTVQBJ_cjs.isAbortError; }
|
|
737
|
+
});
|
|
738
|
+
Object.defineProperty(exports, "isApiError", {
|
|
739
|
+
enumerable: true,
|
|
740
|
+
get: function () { return chunkHPVTVQBJ_cjs.isApiError; }
|
|
741
|
+
});
|
|
742
|
+
Object.defineProperty(exports, "isFetchClientError", {
|
|
743
|
+
enumerable: true,
|
|
744
|
+
get: function () { return chunkHPVTVQBJ_cjs.isFetchClientError; }
|
|
745
|
+
});
|
|
746
|
+
Object.defineProperty(exports, "normalizeBaseUrl", {
|
|
747
|
+
enumerable: true,
|
|
748
|
+
get: function () { return chunkHPVTVQBJ_cjs.normalizeBaseUrl; }
|
|
749
|
+
});
|
|
4154
750
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
4155
|
-
exports.UserError = UserError;
|
|
4156
751
|
exports.assert = assert;
|
|
4157
|
-
exports.concurrent = concurrent;
|
|
4158
752
|
exports.consoleLogger = consoleLogger;
|
|
4159
753
|
exports.createApiClient = createApiClient;
|
|
4160
754
|
exports.createDevApiClient = createDevApiClient;
|
|
4161
|
-
exports.createGenericFetchClient = createGenericFetchClient;
|
|
4162
755
|
exports.createLoggingMiddleware = createLoggingMiddleware;
|
|
4163
756
|
exports.createRetryMiddleware = createRetryMiddleware;
|
|
4164
|
-
exports.createStorageSdk = createStorageSdk;
|
|
4165
|
-
exports.delay = delay;
|
|
4166
|
-
exports.generateUUID = generateUUID;
|
|
4167
|
-
exports.isAbortError = isAbortError;
|
|
4168
|
-
exports.isApiError = isApiError;
|
|
4169
|
-
exports.isFetchClientError = isFetchClientError;
|
|
4170
|
-
exports.isManagementClientAuthError = isManagementClientAuthError;
|
|
4171
|
-
exports.keboolaUID = keboolaUID;
|
|
4172
|
-
exports.parseLogLines = parseLogLines;
|
|
4173
|
-
exports.poll = poll;
|
|
4174
|
-
exports.series = series;
|
|
4175
757
|
//# sourceMappingURL=index.cjs.map
|
|
4176
758
|
//# sourceMappingURL=index.cjs.map
|