@positronic/spec 0.0.3 → 0.0.5
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/api.d.ts +107 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +948 -0
- package/dist/api.js.map +1 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/src/api.js +2246 -0
- package/dist/src/index.js +16 -0
- package/package.json +5 -1
- package/src/api.ts +0 -1404
- package/src/index.ts +0 -136
- package/tsconfig.json +0 -11
package/dist/src/api.js
ADDED
|
@@ -0,0 +1,2246 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _type_of(obj) {
|
|
31
|
+
"@swc/helpers - typeof";
|
|
32
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
33
|
+
}
|
|
34
|
+
function _ts_generator(thisArg, body) {
|
|
35
|
+
var f, y, t, _ = {
|
|
36
|
+
label: 0,
|
|
37
|
+
sent: function() {
|
|
38
|
+
if (t[0] & 1) throw t[1];
|
|
39
|
+
return t[1];
|
|
40
|
+
},
|
|
41
|
+
trys: [],
|
|
42
|
+
ops: []
|
|
43
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
44
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g;
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export function testStatus(fetch) {
|
|
126
|
+
return _async_to_generator(function() {
|
|
127
|
+
var request, response, data, error;
|
|
128
|
+
return _ts_generator(this, function(_state) {
|
|
129
|
+
switch(_state.label){
|
|
130
|
+
case 0:
|
|
131
|
+
_state.trys.push([
|
|
132
|
+
0,
|
|
133
|
+
3,
|
|
134
|
+
,
|
|
135
|
+
4
|
|
136
|
+
]);
|
|
137
|
+
request = new Request('http://example.com/status', {
|
|
138
|
+
method: 'GET'
|
|
139
|
+
});
|
|
140
|
+
return [
|
|
141
|
+
4,
|
|
142
|
+
fetch(request)
|
|
143
|
+
];
|
|
144
|
+
case 1:
|
|
145
|
+
response = _state.sent();
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
console.error("Status endpoint returned ".concat(response.status));
|
|
148
|
+
return [
|
|
149
|
+
2,
|
|
150
|
+
false
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
return [
|
|
154
|
+
4,
|
|
155
|
+
response.json()
|
|
156
|
+
];
|
|
157
|
+
case 2:
|
|
158
|
+
data = _state.sent();
|
|
159
|
+
if (data.ready !== true) {
|
|
160
|
+
console.error("Expected { ready: true }, got ".concat(JSON.stringify(data)));
|
|
161
|
+
return [
|
|
162
|
+
2,
|
|
163
|
+
false
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
return [
|
|
167
|
+
2,
|
|
168
|
+
true
|
|
169
|
+
];
|
|
170
|
+
case 3:
|
|
171
|
+
error = _state.sent();
|
|
172
|
+
console.error("Failed to test status endpoint:", error);
|
|
173
|
+
return [
|
|
174
|
+
2,
|
|
175
|
+
false
|
|
176
|
+
];
|
|
177
|
+
case 4:
|
|
178
|
+
return [
|
|
179
|
+
2
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
})();
|
|
184
|
+
}
|
|
185
|
+
export var resources = {
|
|
186
|
+
list: /**
|
|
187
|
+
* Test GET /resources - List all resources
|
|
188
|
+
*/ function list(fetch) {
|
|
189
|
+
return _async_to_generator(function() {
|
|
190
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, resource, error;
|
|
191
|
+
return _ts_generator(this, function(_state) {
|
|
192
|
+
switch(_state.label){
|
|
193
|
+
case 0:
|
|
194
|
+
_state.trys.push([
|
|
195
|
+
0,
|
|
196
|
+
3,
|
|
197
|
+
,
|
|
198
|
+
4
|
|
199
|
+
]);
|
|
200
|
+
request = new Request('http://example.com/resources', {
|
|
201
|
+
method: 'GET'
|
|
202
|
+
});
|
|
203
|
+
return [
|
|
204
|
+
4,
|
|
205
|
+
fetch(request)
|
|
206
|
+
];
|
|
207
|
+
case 1:
|
|
208
|
+
response = _state.sent();
|
|
209
|
+
if (!response.ok) {
|
|
210
|
+
console.error("GET /resources returned ".concat(response.status));
|
|
211
|
+
return [
|
|
212
|
+
2,
|
|
213
|
+
false
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
return [
|
|
217
|
+
4,
|
|
218
|
+
response.json()
|
|
219
|
+
];
|
|
220
|
+
case 2:
|
|
221
|
+
data = _state.sent();
|
|
222
|
+
// Validate response structure
|
|
223
|
+
if (!Array.isArray(data.resources)) {
|
|
224
|
+
console.error("Expected resources to be an array, got ".concat(_type_of(data.resources)));
|
|
225
|
+
return [
|
|
226
|
+
2,
|
|
227
|
+
false
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
if (typeof data.truncated !== 'boolean') {
|
|
231
|
+
console.error("Expected truncated to be boolean, got ".concat(_type_of(data.truncated)));
|
|
232
|
+
return [
|
|
233
|
+
2,
|
|
234
|
+
false
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
if (typeof data.count !== 'number') {
|
|
238
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
239
|
+
return [
|
|
240
|
+
2,
|
|
241
|
+
false
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
245
|
+
try {
|
|
246
|
+
// Validate each resource has required fields
|
|
247
|
+
for(_iterator = data.resources[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
248
|
+
resource = _step.value;
|
|
249
|
+
if (!resource.key || !resource.type || typeof resource.size !== 'number' || !resource.lastModified || typeof resource.local !== 'boolean') {
|
|
250
|
+
console.error("Resource missing required fields: ".concat(JSON.stringify(resource)));
|
|
251
|
+
return [
|
|
252
|
+
2,
|
|
253
|
+
false
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
if (![
|
|
257
|
+
'text',
|
|
258
|
+
'binary'
|
|
259
|
+
].includes(resource.type)) {
|
|
260
|
+
console.error("Invalid resource type: ".concat(resource.type));
|
|
261
|
+
return [
|
|
262
|
+
2,
|
|
263
|
+
false
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
} catch (err) {
|
|
268
|
+
_didIteratorError = true;
|
|
269
|
+
_iteratorError = err;
|
|
270
|
+
} finally{
|
|
271
|
+
try {
|
|
272
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
273
|
+
_iterator.return();
|
|
274
|
+
}
|
|
275
|
+
} finally{
|
|
276
|
+
if (_didIteratorError) {
|
|
277
|
+
throw _iteratorError;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return [
|
|
282
|
+
2,
|
|
283
|
+
true
|
|
284
|
+
];
|
|
285
|
+
case 3:
|
|
286
|
+
error = _state.sent();
|
|
287
|
+
console.error("Failed to test GET /resources:", error);
|
|
288
|
+
return [
|
|
289
|
+
2,
|
|
290
|
+
false
|
|
291
|
+
];
|
|
292
|
+
case 4:
|
|
293
|
+
return [
|
|
294
|
+
2
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
})();
|
|
299
|
+
},
|
|
300
|
+
upload: /**
|
|
301
|
+
* Test POST /resources - Upload a resource
|
|
302
|
+
*/ function upload(fetch) {
|
|
303
|
+
return _async_to_generator(function() {
|
|
304
|
+
var formData, request, response, data, error;
|
|
305
|
+
return _ts_generator(this, function(_state) {
|
|
306
|
+
switch(_state.label){
|
|
307
|
+
case 0:
|
|
308
|
+
_state.trys.push([
|
|
309
|
+
0,
|
|
310
|
+
3,
|
|
311
|
+
,
|
|
312
|
+
4
|
|
313
|
+
]);
|
|
314
|
+
formData = new FormData();
|
|
315
|
+
formData.append('file', new Blob([
|
|
316
|
+
'test content'
|
|
317
|
+
], {
|
|
318
|
+
type: 'text/plain'
|
|
319
|
+
}), 'test.txt');
|
|
320
|
+
formData.append('type', 'text');
|
|
321
|
+
formData.append('key', 'test-resource.txt');
|
|
322
|
+
formData.append('local', 'false');
|
|
323
|
+
request = new Request('http://example.com/resources', {
|
|
324
|
+
method: 'POST',
|
|
325
|
+
body: formData
|
|
326
|
+
});
|
|
327
|
+
return [
|
|
328
|
+
4,
|
|
329
|
+
fetch(request)
|
|
330
|
+
];
|
|
331
|
+
case 1:
|
|
332
|
+
response = _state.sent();
|
|
333
|
+
if (response.status !== 201) {
|
|
334
|
+
console.error("POST /resources returned ".concat(response.status, ", expected 201"));
|
|
335
|
+
return [
|
|
336
|
+
2,
|
|
337
|
+
false
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
return [
|
|
341
|
+
4,
|
|
342
|
+
response.json()
|
|
343
|
+
];
|
|
344
|
+
case 2:
|
|
345
|
+
data = _state.sent();
|
|
346
|
+
// Validate response has required fields
|
|
347
|
+
if (!data.key || !data.type || typeof data.size !== 'number' || !data.lastModified || typeof data.local !== 'boolean') {
|
|
348
|
+
console.error("Response missing required fields: ".concat(JSON.stringify(data)));
|
|
349
|
+
return [
|
|
350
|
+
2,
|
|
351
|
+
false
|
|
352
|
+
];
|
|
353
|
+
}
|
|
354
|
+
if (data.key !== 'test-resource.txt') {
|
|
355
|
+
console.error("Expected key to be 'test-resource.txt', got ".concat(data.key));
|
|
356
|
+
return [
|
|
357
|
+
2,
|
|
358
|
+
false
|
|
359
|
+
];
|
|
360
|
+
}
|
|
361
|
+
if (data.type !== 'text') {
|
|
362
|
+
console.error("Expected type to be 'text', got ".concat(data.type));
|
|
363
|
+
return [
|
|
364
|
+
2,
|
|
365
|
+
false
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
if (data.local !== false) {
|
|
369
|
+
console.error("Expected local to be false, got ".concat(data.local));
|
|
370
|
+
return [
|
|
371
|
+
2,
|
|
372
|
+
false
|
|
373
|
+
];
|
|
374
|
+
}
|
|
375
|
+
return [
|
|
376
|
+
2,
|
|
377
|
+
true
|
|
378
|
+
];
|
|
379
|
+
case 3:
|
|
380
|
+
error = _state.sent();
|
|
381
|
+
console.error("Failed to test POST /resources:", error);
|
|
382
|
+
return [
|
|
383
|
+
2,
|
|
384
|
+
false
|
|
385
|
+
];
|
|
386
|
+
case 4:
|
|
387
|
+
return [
|
|
388
|
+
2
|
|
389
|
+
];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
})();
|
|
393
|
+
},
|
|
394
|
+
delete: /**
|
|
395
|
+
* Test DELETE /resources/:key - Delete a specific resource
|
|
396
|
+
*/ function _delete(fetch, key) {
|
|
397
|
+
return _async_to_generator(function() {
|
|
398
|
+
var request, response, error;
|
|
399
|
+
return _ts_generator(this, function(_state) {
|
|
400
|
+
switch(_state.label){
|
|
401
|
+
case 0:
|
|
402
|
+
_state.trys.push([
|
|
403
|
+
0,
|
|
404
|
+
2,
|
|
405
|
+
,
|
|
406
|
+
3
|
|
407
|
+
]);
|
|
408
|
+
request = new Request("http://example.com/resources/".concat(encodeURIComponent(key)), {
|
|
409
|
+
method: 'DELETE'
|
|
410
|
+
});
|
|
411
|
+
return [
|
|
412
|
+
4,
|
|
413
|
+
fetch(request)
|
|
414
|
+
];
|
|
415
|
+
case 1:
|
|
416
|
+
response = _state.sent();
|
|
417
|
+
if (response.status !== 204) {
|
|
418
|
+
console.error("DELETE /resources/".concat(key, " returned ").concat(response.status, ", expected 204"));
|
|
419
|
+
return [
|
|
420
|
+
2,
|
|
421
|
+
false
|
|
422
|
+
];
|
|
423
|
+
}
|
|
424
|
+
return [
|
|
425
|
+
2,
|
|
426
|
+
true
|
|
427
|
+
];
|
|
428
|
+
case 2:
|
|
429
|
+
error = _state.sent();
|
|
430
|
+
console.error("Failed to test DELETE /resources/".concat(key, ":"), error);
|
|
431
|
+
return [
|
|
432
|
+
2,
|
|
433
|
+
false
|
|
434
|
+
];
|
|
435
|
+
case 3:
|
|
436
|
+
return [
|
|
437
|
+
2
|
|
438
|
+
];
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
})();
|
|
442
|
+
},
|
|
443
|
+
deleteAll: /**
|
|
444
|
+
* Test DELETE /resources - Bulk delete all resources (dev mode only)
|
|
445
|
+
*/ function deleteAll(fetch) {
|
|
446
|
+
return _async_to_generator(function() {
|
|
447
|
+
var request, response, data, data1, error;
|
|
448
|
+
return _ts_generator(this, function(_state) {
|
|
449
|
+
switch(_state.label){
|
|
450
|
+
case 0:
|
|
451
|
+
_state.trys.push([
|
|
452
|
+
0,
|
|
453
|
+
5,
|
|
454
|
+
,
|
|
455
|
+
6
|
|
456
|
+
]);
|
|
457
|
+
request = new Request('http://example.com/resources', {
|
|
458
|
+
method: 'DELETE'
|
|
459
|
+
});
|
|
460
|
+
return [
|
|
461
|
+
4,
|
|
462
|
+
fetch(request)
|
|
463
|
+
];
|
|
464
|
+
case 1:
|
|
465
|
+
response = _state.sent();
|
|
466
|
+
if (!(response.status === 403)) return [
|
|
467
|
+
3,
|
|
468
|
+
3
|
|
469
|
+
];
|
|
470
|
+
return [
|
|
471
|
+
4,
|
|
472
|
+
response.json()
|
|
473
|
+
];
|
|
474
|
+
case 2:
|
|
475
|
+
data = _state.sent();
|
|
476
|
+
if (data.error === 'Bulk delete is only available in development mode') {
|
|
477
|
+
// This is expected behavior in production
|
|
478
|
+
return [
|
|
479
|
+
2,
|
|
480
|
+
true
|
|
481
|
+
];
|
|
482
|
+
}
|
|
483
|
+
_state.label = 3;
|
|
484
|
+
case 3:
|
|
485
|
+
if (response.status !== 200) {
|
|
486
|
+
console.error("DELETE /resources returned ".concat(response.status, ", expected 200 or 403"));
|
|
487
|
+
return [
|
|
488
|
+
2,
|
|
489
|
+
false
|
|
490
|
+
];
|
|
491
|
+
}
|
|
492
|
+
return [
|
|
493
|
+
4,
|
|
494
|
+
response.json()
|
|
495
|
+
];
|
|
496
|
+
case 4:
|
|
497
|
+
data1 = _state.sent();
|
|
498
|
+
if (typeof data1.deletedCount !== 'number') {
|
|
499
|
+
console.error("Expected deletedCount to be number, got ".concat(_type_of(data1.deletedCount)));
|
|
500
|
+
return [
|
|
501
|
+
2,
|
|
502
|
+
false
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
return [
|
|
506
|
+
2,
|
|
507
|
+
true
|
|
508
|
+
];
|
|
509
|
+
case 5:
|
|
510
|
+
error = _state.sent();
|
|
511
|
+
console.error("Failed to test DELETE /resources:", error);
|
|
512
|
+
return [
|
|
513
|
+
2,
|
|
514
|
+
false
|
|
515
|
+
];
|
|
516
|
+
case 6:
|
|
517
|
+
return [
|
|
518
|
+
2
|
|
519
|
+
];
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
})();
|
|
523
|
+
},
|
|
524
|
+
generatePresignedLink: /**
|
|
525
|
+
* Test POST /resources/presigned-link - Generate presigned URL for upload
|
|
526
|
+
*/ function generatePresignedLink(fetch) {
|
|
527
|
+
return _async_to_generator(function() {
|
|
528
|
+
var request, response, data, data1, error;
|
|
529
|
+
return _ts_generator(this, function(_state) {
|
|
530
|
+
switch(_state.label){
|
|
531
|
+
case 0:
|
|
532
|
+
_state.trys.push([
|
|
533
|
+
0,
|
|
534
|
+
5,
|
|
535
|
+
,
|
|
536
|
+
6
|
|
537
|
+
]);
|
|
538
|
+
request = new Request('http://example.com/resources/presigned-link', {
|
|
539
|
+
method: 'POST',
|
|
540
|
+
headers: {
|
|
541
|
+
'Content-Type': 'application/json'
|
|
542
|
+
},
|
|
543
|
+
body: JSON.stringify({
|
|
544
|
+
key: 'test-files/large-video.mp4',
|
|
545
|
+
type: 'binary',
|
|
546
|
+
size: 150 * 1024 * 1024
|
|
547
|
+
})
|
|
548
|
+
});
|
|
549
|
+
return [
|
|
550
|
+
4,
|
|
551
|
+
fetch(request)
|
|
552
|
+
];
|
|
553
|
+
case 1:
|
|
554
|
+
response = _state.sent();
|
|
555
|
+
if (!(response.status === 400)) return [
|
|
556
|
+
3,
|
|
557
|
+
3
|
|
558
|
+
];
|
|
559
|
+
return [
|
|
560
|
+
4,
|
|
561
|
+
response.json()
|
|
562
|
+
];
|
|
563
|
+
case 2:
|
|
564
|
+
data = _state.sent();
|
|
565
|
+
// This is acceptable - implementation may not have credentials configured
|
|
566
|
+
console.log('Presigned URL generation not available - this is acceptable');
|
|
567
|
+
return [
|
|
568
|
+
2,
|
|
569
|
+
true
|
|
570
|
+
];
|
|
571
|
+
case 3:
|
|
572
|
+
if (response.status !== 200) {
|
|
573
|
+
console.error("POST /resources/presigned-link returned ".concat(response.status, ", expected 200 or 400"));
|
|
574
|
+
return [
|
|
575
|
+
2,
|
|
576
|
+
false
|
|
577
|
+
];
|
|
578
|
+
}
|
|
579
|
+
return [
|
|
580
|
+
4,
|
|
581
|
+
response.json()
|
|
582
|
+
];
|
|
583
|
+
case 4:
|
|
584
|
+
data1 = _state.sent();
|
|
585
|
+
// Validate response structure (backend-agnostic)
|
|
586
|
+
if (!data1.url || typeof data1.url !== 'string') {
|
|
587
|
+
console.error("Expected url to be string, got ".concat(_type_of(data1.url)));
|
|
588
|
+
return [
|
|
589
|
+
2,
|
|
590
|
+
false
|
|
591
|
+
];
|
|
592
|
+
}
|
|
593
|
+
if (!data1.method || data1.method !== 'PUT') {
|
|
594
|
+
console.error("Expected method to be 'PUT', got ".concat(data1.method));
|
|
595
|
+
return [
|
|
596
|
+
2,
|
|
597
|
+
false
|
|
598
|
+
];
|
|
599
|
+
}
|
|
600
|
+
if (typeof data1.expiresIn !== 'number' || data1.expiresIn <= 0) {
|
|
601
|
+
console.error("Expected expiresIn to be positive number, got ".concat(data1.expiresIn));
|
|
602
|
+
return [
|
|
603
|
+
2,
|
|
604
|
+
false
|
|
605
|
+
];
|
|
606
|
+
}
|
|
607
|
+
// Basic URL validation - just ensure it's a valid URL
|
|
608
|
+
try {
|
|
609
|
+
new URL(data1.url);
|
|
610
|
+
console.log('Presigned URL structure validated successfully');
|
|
611
|
+
} catch (error) {
|
|
612
|
+
console.error("Invalid URL returned: ".concat(data1.url));
|
|
613
|
+
return [
|
|
614
|
+
2,
|
|
615
|
+
false
|
|
616
|
+
];
|
|
617
|
+
}
|
|
618
|
+
return [
|
|
619
|
+
2,
|
|
620
|
+
true
|
|
621
|
+
];
|
|
622
|
+
case 5:
|
|
623
|
+
error = _state.sent();
|
|
624
|
+
console.error("Failed to test POST /resources/presigned-link:", error);
|
|
625
|
+
return [
|
|
626
|
+
2,
|
|
627
|
+
false
|
|
628
|
+
];
|
|
629
|
+
case 6:
|
|
630
|
+
return [
|
|
631
|
+
2
|
|
632
|
+
];
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
})();
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
export var brains = {
|
|
639
|
+
run: /**
|
|
640
|
+
* Test POST /brains/runs - Create a new brain run
|
|
641
|
+
*/ function run(fetch, brainName) {
|
|
642
|
+
return _async_to_generator(function() {
|
|
643
|
+
var request, response, data, error;
|
|
644
|
+
return _ts_generator(this, function(_state) {
|
|
645
|
+
switch(_state.label){
|
|
646
|
+
case 0:
|
|
647
|
+
_state.trys.push([
|
|
648
|
+
0,
|
|
649
|
+
3,
|
|
650
|
+
,
|
|
651
|
+
4
|
|
652
|
+
]);
|
|
653
|
+
request = new Request('http://example.com/brains/runs', {
|
|
654
|
+
method: 'POST',
|
|
655
|
+
headers: {
|
|
656
|
+
'Content-Type': 'application/json'
|
|
657
|
+
},
|
|
658
|
+
body: JSON.stringify({
|
|
659
|
+
brainName: brainName
|
|
660
|
+
})
|
|
661
|
+
});
|
|
662
|
+
return [
|
|
663
|
+
4,
|
|
664
|
+
fetch(request)
|
|
665
|
+
];
|
|
666
|
+
case 1:
|
|
667
|
+
response = _state.sent();
|
|
668
|
+
if (response.status !== 201) {
|
|
669
|
+
console.error("POST /brains/runs returned ".concat(response.status, ", expected 201"));
|
|
670
|
+
return [
|
|
671
|
+
2,
|
|
672
|
+
null
|
|
673
|
+
];
|
|
674
|
+
}
|
|
675
|
+
return [
|
|
676
|
+
4,
|
|
677
|
+
response.json()
|
|
678
|
+
];
|
|
679
|
+
case 2:
|
|
680
|
+
data = _state.sent();
|
|
681
|
+
if (!data.brainRunId || typeof data.brainRunId !== 'string') {
|
|
682
|
+
console.error("Expected brainRunId to be string, got ".concat(_type_of(data.brainRunId)));
|
|
683
|
+
return [
|
|
684
|
+
2,
|
|
685
|
+
null
|
|
686
|
+
];
|
|
687
|
+
}
|
|
688
|
+
return [
|
|
689
|
+
2,
|
|
690
|
+
data.brainRunId
|
|
691
|
+
];
|
|
692
|
+
case 3:
|
|
693
|
+
error = _state.sent();
|
|
694
|
+
console.error("Failed to test POST /brains/runs:", error);
|
|
695
|
+
return [
|
|
696
|
+
2,
|
|
697
|
+
null
|
|
698
|
+
];
|
|
699
|
+
case 4:
|
|
700
|
+
return [
|
|
701
|
+
2
|
|
702
|
+
];
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
})();
|
|
706
|
+
},
|
|
707
|
+
runNotFound: /**
|
|
708
|
+
* Test POST /brains/runs with non-existent brain - Should return 404
|
|
709
|
+
*/ function runNotFound(fetch, nonExistentBrainName) {
|
|
710
|
+
return _async_to_generator(function() {
|
|
711
|
+
var request, response, data, expectedPattern, error;
|
|
712
|
+
return _ts_generator(this, function(_state) {
|
|
713
|
+
switch(_state.label){
|
|
714
|
+
case 0:
|
|
715
|
+
_state.trys.push([
|
|
716
|
+
0,
|
|
717
|
+
3,
|
|
718
|
+
,
|
|
719
|
+
4
|
|
720
|
+
]);
|
|
721
|
+
request = new Request('http://example.com/brains/runs', {
|
|
722
|
+
method: 'POST',
|
|
723
|
+
headers: {
|
|
724
|
+
'Content-Type': 'application/json'
|
|
725
|
+
},
|
|
726
|
+
body: JSON.stringify({
|
|
727
|
+
brainName: nonExistentBrainName
|
|
728
|
+
})
|
|
729
|
+
});
|
|
730
|
+
return [
|
|
731
|
+
4,
|
|
732
|
+
fetch(request)
|
|
733
|
+
];
|
|
734
|
+
case 1:
|
|
735
|
+
response = _state.sent();
|
|
736
|
+
if (response.status !== 404) {
|
|
737
|
+
console.error("POST /brains/runs with non-existent brain returned ".concat(response.status, ", expected 404"));
|
|
738
|
+
return [
|
|
739
|
+
2,
|
|
740
|
+
false
|
|
741
|
+
];
|
|
742
|
+
}
|
|
743
|
+
return [
|
|
744
|
+
4,
|
|
745
|
+
response.json()
|
|
746
|
+
];
|
|
747
|
+
case 2:
|
|
748
|
+
data = _state.sent();
|
|
749
|
+
if (!data.error || typeof data.error !== 'string') {
|
|
750
|
+
console.error("Expected error to be string, got ".concat(_type_of(data.error)));
|
|
751
|
+
return [
|
|
752
|
+
2,
|
|
753
|
+
false
|
|
754
|
+
];
|
|
755
|
+
}
|
|
756
|
+
// Check that the error message mentions the brain name
|
|
757
|
+
if (!data.error.includes(nonExistentBrainName)) {
|
|
758
|
+
console.error("Expected error to mention brain name '".concat(nonExistentBrainName, "', got: ").concat(data.error));
|
|
759
|
+
return [
|
|
760
|
+
2,
|
|
761
|
+
false
|
|
762
|
+
];
|
|
763
|
+
}
|
|
764
|
+
// Check that the error message follows expected format
|
|
765
|
+
expectedPattern = new RegExp("Brain '".concat(nonExistentBrainName, "' not found"));
|
|
766
|
+
if (!expectedPattern.test(data.error)) {
|
|
767
|
+
console.error("Expected error message to match pattern \"Brain '".concat(nonExistentBrainName, "' not found\", got: ").concat(data.error));
|
|
768
|
+
return [
|
|
769
|
+
2,
|
|
770
|
+
false
|
|
771
|
+
];
|
|
772
|
+
}
|
|
773
|
+
return [
|
|
774
|
+
2,
|
|
775
|
+
true
|
|
776
|
+
];
|
|
777
|
+
case 3:
|
|
778
|
+
error = _state.sent();
|
|
779
|
+
console.error("Failed to test POST /brains/runs with non-existent brain:", error);
|
|
780
|
+
return [
|
|
781
|
+
2,
|
|
782
|
+
false
|
|
783
|
+
];
|
|
784
|
+
case 4:
|
|
785
|
+
return [
|
|
786
|
+
2
|
|
787
|
+
];
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
})();
|
|
791
|
+
},
|
|
792
|
+
watch: /**
|
|
793
|
+
* Test GET /brains/runs/:runId/watch - Watch a brain run via SSE
|
|
794
|
+
*/ function watch(fetch, runId) {
|
|
795
|
+
return _async_to_generator(function() {
|
|
796
|
+
var request, response, contentType, reader, value, text, error;
|
|
797
|
+
return _ts_generator(this, function(_state) {
|
|
798
|
+
switch(_state.label){
|
|
799
|
+
case 0:
|
|
800
|
+
_state.trys.push([
|
|
801
|
+
0,
|
|
802
|
+
7,
|
|
803
|
+
,
|
|
804
|
+
8
|
|
805
|
+
]);
|
|
806
|
+
request = new Request("http://example.com/brains/runs/".concat(runId, "/watch"), {
|
|
807
|
+
method: 'GET'
|
|
808
|
+
});
|
|
809
|
+
return [
|
|
810
|
+
4,
|
|
811
|
+
fetch(request)
|
|
812
|
+
];
|
|
813
|
+
case 1:
|
|
814
|
+
response = _state.sent();
|
|
815
|
+
if (!response.ok) {
|
|
816
|
+
console.error("GET /brains/runs/".concat(runId, "/watch returned ").concat(response.status));
|
|
817
|
+
return [
|
|
818
|
+
2,
|
|
819
|
+
false
|
|
820
|
+
];
|
|
821
|
+
}
|
|
822
|
+
// Check that it's an event stream
|
|
823
|
+
contentType = response.headers.get('content-type');
|
|
824
|
+
if (!contentType || !contentType.includes('text/event-stream')) {
|
|
825
|
+
console.error("Expected content-type to be text/event-stream, got ".concat(contentType));
|
|
826
|
+
return [
|
|
827
|
+
2,
|
|
828
|
+
false
|
|
829
|
+
];
|
|
830
|
+
}
|
|
831
|
+
if (!response.body) return [
|
|
832
|
+
3,
|
|
833
|
+
6
|
|
834
|
+
];
|
|
835
|
+
reader = response.body.getReader();
|
|
836
|
+
_state.label = 2;
|
|
837
|
+
case 2:
|
|
838
|
+
_state.trys.push([
|
|
839
|
+
2,
|
|
840
|
+
,
|
|
841
|
+
4,
|
|
842
|
+
6
|
|
843
|
+
]);
|
|
844
|
+
return [
|
|
845
|
+
4,
|
|
846
|
+
reader.read()
|
|
847
|
+
];
|
|
848
|
+
case 3:
|
|
849
|
+
value = _state.sent().value;
|
|
850
|
+
if (value) {
|
|
851
|
+
text = new TextDecoder().decode(value);
|
|
852
|
+
// SSE data should contain "data: " lines
|
|
853
|
+
if (!text.includes('data: ')) {
|
|
854
|
+
console.error('Expected SSE format with "data: " prefix, got: '.concat(text.substring(0, 100)));
|
|
855
|
+
return [
|
|
856
|
+
2,
|
|
857
|
+
false
|
|
858
|
+
];
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return [
|
|
862
|
+
3,
|
|
863
|
+
6
|
|
864
|
+
];
|
|
865
|
+
case 4:
|
|
866
|
+
// Always cancel the reader to clean up
|
|
867
|
+
return [
|
|
868
|
+
4,
|
|
869
|
+
reader.cancel()
|
|
870
|
+
];
|
|
871
|
+
case 5:
|
|
872
|
+
_state.sent();
|
|
873
|
+
return [
|
|
874
|
+
7
|
|
875
|
+
];
|
|
876
|
+
case 6:
|
|
877
|
+
return [
|
|
878
|
+
2,
|
|
879
|
+
true
|
|
880
|
+
];
|
|
881
|
+
case 7:
|
|
882
|
+
error = _state.sent();
|
|
883
|
+
console.error("Failed to test GET /brains/runs/".concat(runId, "/watch:"), error);
|
|
884
|
+
return [
|
|
885
|
+
2,
|
|
886
|
+
false
|
|
887
|
+
];
|
|
888
|
+
case 8:
|
|
889
|
+
return [
|
|
890
|
+
2
|
|
891
|
+
];
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
})();
|
|
895
|
+
},
|
|
896
|
+
history: /**
|
|
897
|
+
* Test GET /brains/:brainName/history - Get history of brain runs
|
|
898
|
+
*/ function history(fetch, brainName, limit) {
|
|
899
|
+
return _async_to_generator(function() {
|
|
900
|
+
var url, request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, run, error;
|
|
901
|
+
return _ts_generator(this, function(_state) {
|
|
902
|
+
switch(_state.label){
|
|
903
|
+
case 0:
|
|
904
|
+
_state.trys.push([
|
|
905
|
+
0,
|
|
906
|
+
3,
|
|
907
|
+
,
|
|
908
|
+
4
|
|
909
|
+
]);
|
|
910
|
+
url = new URL('http://example.com/brains/' + brainName + '/history');
|
|
911
|
+
if (limit !== undefined) {
|
|
912
|
+
url.searchParams.set('limit', limit.toString());
|
|
913
|
+
}
|
|
914
|
+
request = new Request(url.toString(), {
|
|
915
|
+
method: 'GET'
|
|
916
|
+
});
|
|
917
|
+
return [
|
|
918
|
+
4,
|
|
919
|
+
fetch(request)
|
|
920
|
+
];
|
|
921
|
+
case 1:
|
|
922
|
+
response = _state.sent();
|
|
923
|
+
if (!response.ok) {
|
|
924
|
+
console.error("GET /brains/".concat(brainName, "/history returned ").concat(response.status));
|
|
925
|
+
return [
|
|
926
|
+
2,
|
|
927
|
+
false
|
|
928
|
+
];
|
|
929
|
+
}
|
|
930
|
+
return [
|
|
931
|
+
4,
|
|
932
|
+
response.json()
|
|
933
|
+
];
|
|
934
|
+
case 2:
|
|
935
|
+
data = _state.sent();
|
|
936
|
+
// Validate response structure
|
|
937
|
+
if (!data.runs || !Array.isArray(data.runs)) {
|
|
938
|
+
console.error("Expected runs to be an array, got ".concat(_type_of(data.runs)));
|
|
939
|
+
return [
|
|
940
|
+
2,
|
|
941
|
+
false
|
|
942
|
+
];
|
|
943
|
+
}
|
|
944
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
945
|
+
try {
|
|
946
|
+
// Validate each run has required fields
|
|
947
|
+
for(_iterator = data.runs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
948
|
+
run = _step.value;
|
|
949
|
+
if (!run.brainRunId || !run.brainTitle || !run.type || !run.status || typeof run.createdAt !== 'number') {
|
|
950
|
+
console.error("Run missing required fields: ".concat(JSON.stringify(run)));
|
|
951
|
+
return [
|
|
952
|
+
2,
|
|
953
|
+
false
|
|
954
|
+
];
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
} catch (err) {
|
|
958
|
+
_didIteratorError = true;
|
|
959
|
+
_iteratorError = err;
|
|
960
|
+
} finally{
|
|
961
|
+
try {
|
|
962
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
963
|
+
_iterator.return();
|
|
964
|
+
}
|
|
965
|
+
} finally{
|
|
966
|
+
if (_didIteratorError) {
|
|
967
|
+
throw _iteratorError;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return [
|
|
972
|
+
2,
|
|
973
|
+
true
|
|
974
|
+
];
|
|
975
|
+
case 3:
|
|
976
|
+
error = _state.sent();
|
|
977
|
+
console.error("Failed to test GET /brains/".concat(brainName, "/history:"), error);
|
|
978
|
+
return [
|
|
979
|
+
2,
|
|
980
|
+
false
|
|
981
|
+
];
|
|
982
|
+
case 4:
|
|
983
|
+
return [
|
|
984
|
+
2
|
|
985
|
+
];
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
})();
|
|
989
|
+
},
|
|
990
|
+
watchAll: /**
|
|
991
|
+
* Test GET /brains/watch - Watch all running brains
|
|
992
|
+
*/ function watchAll(fetch) {
|
|
993
|
+
return _async_to_generator(function() {
|
|
994
|
+
var request, response, contentType, reader, value, text, error;
|
|
995
|
+
return _ts_generator(this, function(_state) {
|
|
996
|
+
switch(_state.label){
|
|
997
|
+
case 0:
|
|
998
|
+
_state.trys.push([
|
|
999
|
+
0,
|
|
1000
|
+
7,
|
|
1001
|
+
,
|
|
1002
|
+
8
|
|
1003
|
+
]);
|
|
1004
|
+
request = new Request('http://example.com/brains/watch', {
|
|
1005
|
+
method: 'GET'
|
|
1006
|
+
});
|
|
1007
|
+
return [
|
|
1008
|
+
4,
|
|
1009
|
+
fetch(request)
|
|
1010
|
+
];
|
|
1011
|
+
case 1:
|
|
1012
|
+
response = _state.sent();
|
|
1013
|
+
if (!response.ok) {
|
|
1014
|
+
console.error("GET /brains/watch returned ".concat(response.status));
|
|
1015
|
+
return [
|
|
1016
|
+
2,
|
|
1017
|
+
false
|
|
1018
|
+
];
|
|
1019
|
+
}
|
|
1020
|
+
// Check that it's an event stream
|
|
1021
|
+
contentType = response.headers.get('content-type');
|
|
1022
|
+
if (!contentType || !contentType.includes('text/event-stream')) {
|
|
1023
|
+
console.error("Expected content-type to be text/event-stream, got ".concat(contentType));
|
|
1024
|
+
return [
|
|
1025
|
+
2,
|
|
1026
|
+
false
|
|
1027
|
+
];
|
|
1028
|
+
}
|
|
1029
|
+
if (!response.body) return [
|
|
1030
|
+
3,
|
|
1031
|
+
6
|
|
1032
|
+
];
|
|
1033
|
+
reader = response.body.getReader();
|
|
1034
|
+
_state.label = 2;
|
|
1035
|
+
case 2:
|
|
1036
|
+
_state.trys.push([
|
|
1037
|
+
2,
|
|
1038
|
+
,
|
|
1039
|
+
4,
|
|
1040
|
+
6
|
|
1041
|
+
]);
|
|
1042
|
+
return [
|
|
1043
|
+
4,
|
|
1044
|
+
reader.read()
|
|
1045
|
+
];
|
|
1046
|
+
case 3:
|
|
1047
|
+
value = _state.sent().value;
|
|
1048
|
+
if (value) {
|
|
1049
|
+
text = new TextDecoder().decode(value);
|
|
1050
|
+
// SSE data should contain "data: " lines
|
|
1051
|
+
if (!text.includes('data: ')) {
|
|
1052
|
+
console.error('Expected SSE format with "data: " prefix, got: '.concat(text.substring(0, 100)));
|
|
1053
|
+
return [
|
|
1054
|
+
2,
|
|
1055
|
+
false
|
|
1056
|
+
];
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return [
|
|
1060
|
+
3,
|
|
1061
|
+
6
|
|
1062
|
+
];
|
|
1063
|
+
case 4:
|
|
1064
|
+
// Always cancel the reader to clean up
|
|
1065
|
+
return [
|
|
1066
|
+
4,
|
|
1067
|
+
reader.cancel()
|
|
1068
|
+
];
|
|
1069
|
+
case 5:
|
|
1070
|
+
_state.sent();
|
|
1071
|
+
return [
|
|
1072
|
+
7
|
|
1073
|
+
];
|
|
1074
|
+
case 6:
|
|
1075
|
+
return [
|
|
1076
|
+
2,
|
|
1077
|
+
true
|
|
1078
|
+
];
|
|
1079
|
+
case 7:
|
|
1080
|
+
error = _state.sent();
|
|
1081
|
+
console.error("Failed to test GET /brains/watch:", error);
|
|
1082
|
+
return [
|
|
1083
|
+
2,
|
|
1084
|
+
false
|
|
1085
|
+
];
|
|
1086
|
+
case 8:
|
|
1087
|
+
return [
|
|
1088
|
+
2
|
|
1089
|
+
];
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
})();
|
|
1093
|
+
},
|
|
1094
|
+
list: /**
|
|
1095
|
+
* Test GET /brains - List all brains
|
|
1096
|
+
*/ function list(fetch) {
|
|
1097
|
+
return _async_to_generator(function() {
|
|
1098
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, brain, error;
|
|
1099
|
+
return _ts_generator(this, function(_state) {
|
|
1100
|
+
switch(_state.label){
|
|
1101
|
+
case 0:
|
|
1102
|
+
_state.trys.push([
|
|
1103
|
+
0,
|
|
1104
|
+
3,
|
|
1105
|
+
,
|
|
1106
|
+
4
|
|
1107
|
+
]);
|
|
1108
|
+
request = new Request('http://example.com/brains', {
|
|
1109
|
+
method: 'GET'
|
|
1110
|
+
});
|
|
1111
|
+
return [
|
|
1112
|
+
4,
|
|
1113
|
+
fetch(request)
|
|
1114
|
+
];
|
|
1115
|
+
case 1:
|
|
1116
|
+
response = _state.sent();
|
|
1117
|
+
if (!response.ok) {
|
|
1118
|
+
console.error("GET /brains returned ".concat(response.status));
|
|
1119
|
+
return [
|
|
1120
|
+
2,
|
|
1121
|
+
false
|
|
1122
|
+
];
|
|
1123
|
+
}
|
|
1124
|
+
return [
|
|
1125
|
+
4,
|
|
1126
|
+
response.json()
|
|
1127
|
+
];
|
|
1128
|
+
case 2:
|
|
1129
|
+
data = _state.sent();
|
|
1130
|
+
// Validate response structure
|
|
1131
|
+
if (!Array.isArray(data.brains)) {
|
|
1132
|
+
console.error("Expected brains to be an array, got ".concat(_type_of(data.brains)));
|
|
1133
|
+
return [
|
|
1134
|
+
2,
|
|
1135
|
+
false
|
|
1136
|
+
];
|
|
1137
|
+
}
|
|
1138
|
+
if (typeof data.count !== 'number') {
|
|
1139
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
1140
|
+
return [
|
|
1141
|
+
2,
|
|
1142
|
+
false
|
|
1143
|
+
];
|
|
1144
|
+
}
|
|
1145
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1146
|
+
try {
|
|
1147
|
+
// Validate each brain has required fields
|
|
1148
|
+
for(_iterator = data.brains[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1149
|
+
brain = _step.value;
|
|
1150
|
+
if (!brain.name || typeof brain.name !== 'string' || !brain.title || typeof brain.title !== 'string' || !brain.description || typeof brain.description !== 'string') {
|
|
1151
|
+
console.error("Brain missing required fields or has invalid types: ".concat(JSON.stringify(brain)));
|
|
1152
|
+
return [
|
|
1153
|
+
2,
|
|
1154
|
+
false
|
|
1155
|
+
];
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
_didIteratorError = true;
|
|
1160
|
+
_iteratorError = err;
|
|
1161
|
+
} finally{
|
|
1162
|
+
try {
|
|
1163
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1164
|
+
_iterator.return();
|
|
1165
|
+
}
|
|
1166
|
+
} finally{
|
|
1167
|
+
if (_didIteratorError) {
|
|
1168
|
+
throw _iteratorError;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return [
|
|
1173
|
+
2,
|
|
1174
|
+
true
|
|
1175
|
+
];
|
|
1176
|
+
case 3:
|
|
1177
|
+
error = _state.sent();
|
|
1178
|
+
console.error("Failed to test GET /brains:", error);
|
|
1179
|
+
return [
|
|
1180
|
+
2,
|
|
1181
|
+
false
|
|
1182
|
+
];
|
|
1183
|
+
case 4:
|
|
1184
|
+
return [
|
|
1185
|
+
2
|
|
1186
|
+
];
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
})();
|
|
1190
|
+
},
|
|
1191
|
+
show: /**
|
|
1192
|
+
* Test GET /brains/:brainName - Get brain structure
|
|
1193
|
+
*/ function show(fetch, brainName) {
|
|
1194
|
+
return _async_to_generator(function() {
|
|
1195
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, step, error;
|
|
1196
|
+
return _ts_generator(this, function(_state) {
|
|
1197
|
+
switch(_state.label){
|
|
1198
|
+
case 0:
|
|
1199
|
+
_state.trys.push([
|
|
1200
|
+
0,
|
|
1201
|
+
3,
|
|
1202
|
+
,
|
|
1203
|
+
4
|
|
1204
|
+
]);
|
|
1205
|
+
request = new Request("http://example.com/brains/".concat(encodeURIComponent(brainName)), {
|
|
1206
|
+
method: 'GET'
|
|
1207
|
+
});
|
|
1208
|
+
return [
|
|
1209
|
+
4,
|
|
1210
|
+
fetch(request)
|
|
1211
|
+
];
|
|
1212
|
+
case 1:
|
|
1213
|
+
response = _state.sent();
|
|
1214
|
+
if (!response.ok) {
|
|
1215
|
+
console.error("GET /brains/".concat(brainName, " returned ").concat(response.status));
|
|
1216
|
+
return [
|
|
1217
|
+
2,
|
|
1218
|
+
false
|
|
1219
|
+
];
|
|
1220
|
+
}
|
|
1221
|
+
return [
|
|
1222
|
+
4,
|
|
1223
|
+
response.json()
|
|
1224
|
+
];
|
|
1225
|
+
case 2:
|
|
1226
|
+
data = _state.sent();
|
|
1227
|
+
// Validate response structure
|
|
1228
|
+
if (!data.name || typeof data.name !== 'string') {
|
|
1229
|
+
console.error("Expected name to be string, got ".concat(_type_of(data.name)));
|
|
1230
|
+
return [
|
|
1231
|
+
2,
|
|
1232
|
+
false
|
|
1233
|
+
];
|
|
1234
|
+
}
|
|
1235
|
+
if (!data.title || typeof data.title !== 'string') {
|
|
1236
|
+
console.error("Expected title to be string, got ".concat(_type_of(data.title)));
|
|
1237
|
+
return [
|
|
1238
|
+
2,
|
|
1239
|
+
false
|
|
1240
|
+
];
|
|
1241
|
+
}
|
|
1242
|
+
if (!Array.isArray(data.steps)) {
|
|
1243
|
+
console.error("Expected steps to be an array, got ".concat(_type_of(data.steps)));
|
|
1244
|
+
return [
|
|
1245
|
+
2,
|
|
1246
|
+
false
|
|
1247
|
+
];
|
|
1248
|
+
}
|
|
1249
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1250
|
+
try {
|
|
1251
|
+
// Validate each step
|
|
1252
|
+
for(_iterator = data.steps[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1253
|
+
step = _step.value;
|
|
1254
|
+
if (!step.type || ![
|
|
1255
|
+
'step',
|
|
1256
|
+
'brain'
|
|
1257
|
+
].includes(step.type)) {
|
|
1258
|
+
console.error("Invalid step type: ".concat(step.type));
|
|
1259
|
+
return [
|
|
1260
|
+
2,
|
|
1261
|
+
false
|
|
1262
|
+
];
|
|
1263
|
+
}
|
|
1264
|
+
if (!step.title || typeof step.title !== 'string') {
|
|
1265
|
+
console.error("Step missing title or has invalid type: ".concat(JSON.stringify(step)));
|
|
1266
|
+
return [
|
|
1267
|
+
2,
|
|
1268
|
+
false
|
|
1269
|
+
];
|
|
1270
|
+
}
|
|
1271
|
+
// If it's a brain step, validate the inner brain recursively
|
|
1272
|
+
if (step.type === 'brain' && step.innerBrain) {
|
|
1273
|
+
if (!step.innerBrain.title || typeof step.innerBrain.title !== 'string') {
|
|
1274
|
+
console.error("Inner brain missing title: ".concat(JSON.stringify(step.innerBrain)));
|
|
1275
|
+
return [
|
|
1276
|
+
2,
|
|
1277
|
+
false
|
|
1278
|
+
];
|
|
1279
|
+
}
|
|
1280
|
+
if (!Array.isArray(step.innerBrain.steps)) {
|
|
1281
|
+
console.error("Inner brain missing steps array: ".concat(JSON.stringify(step.innerBrain)));
|
|
1282
|
+
return [
|
|
1283
|
+
2,
|
|
1284
|
+
false
|
|
1285
|
+
];
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
} catch (err) {
|
|
1290
|
+
_didIteratorError = true;
|
|
1291
|
+
_iteratorError = err;
|
|
1292
|
+
} finally{
|
|
1293
|
+
try {
|
|
1294
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1295
|
+
_iterator.return();
|
|
1296
|
+
}
|
|
1297
|
+
} finally{
|
|
1298
|
+
if (_didIteratorError) {
|
|
1299
|
+
throw _iteratorError;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return [
|
|
1304
|
+
2,
|
|
1305
|
+
true
|
|
1306
|
+
];
|
|
1307
|
+
case 3:
|
|
1308
|
+
error = _state.sent();
|
|
1309
|
+
console.error("Failed to test GET /brains/".concat(brainName, ":"), error);
|
|
1310
|
+
return [
|
|
1311
|
+
2,
|
|
1312
|
+
false
|
|
1313
|
+
];
|
|
1314
|
+
case 4:
|
|
1315
|
+
return [
|
|
1316
|
+
2
|
|
1317
|
+
];
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
})();
|
|
1321
|
+
},
|
|
1322
|
+
activeRuns: /**
|
|
1323
|
+
* Test GET /brains/:brainName/active-runs - Get active/running brain runs
|
|
1324
|
+
*/ function activeRuns(fetch, brainName) {
|
|
1325
|
+
return _async_to_generator(function() {
|
|
1326
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, run, error;
|
|
1327
|
+
return _ts_generator(this, function(_state) {
|
|
1328
|
+
switch(_state.label){
|
|
1329
|
+
case 0:
|
|
1330
|
+
_state.trys.push([
|
|
1331
|
+
0,
|
|
1332
|
+
3,
|
|
1333
|
+
,
|
|
1334
|
+
4
|
|
1335
|
+
]);
|
|
1336
|
+
request = new Request("http://example.com/brains/".concat(encodeURIComponent(brainName), "/active-runs"), {
|
|
1337
|
+
method: 'GET'
|
|
1338
|
+
});
|
|
1339
|
+
return [
|
|
1340
|
+
4,
|
|
1341
|
+
fetch(request)
|
|
1342
|
+
];
|
|
1343
|
+
case 1:
|
|
1344
|
+
response = _state.sent();
|
|
1345
|
+
if (!response.ok) {
|
|
1346
|
+
console.error("GET /brains/".concat(brainName, "/active-runs returned ").concat(response.status));
|
|
1347
|
+
return [
|
|
1348
|
+
2,
|
|
1349
|
+
false
|
|
1350
|
+
];
|
|
1351
|
+
}
|
|
1352
|
+
return [
|
|
1353
|
+
4,
|
|
1354
|
+
response.json()
|
|
1355
|
+
];
|
|
1356
|
+
case 2:
|
|
1357
|
+
data = _state.sent();
|
|
1358
|
+
// Validate response structure
|
|
1359
|
+
if (!data.runs || !Array.isArray(data.runs)) {
|
|
1360
|
+
console.error("Expected runs to be an array, got ".concat(_type_of(data.runs)));
|
|
1361
|
+
return [
|
|
1362
|
+
2,
|
|
1363
|
+
false
|
|
1364
|
+
];
|
|
1365
|
+
}
|
|
1366
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1367
|
+
try {
|
|
1368
|
+
// Validate each run has required fields
|
|
1369
|
+
for(_iterator = data.runs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1370
|
+
run = _step.value;
|
|
1371
|
+
if (!run.brainRunId || !run.brainTitle || !run.type || !run.status || typeof run.createdAt !== 'number') {
|
|
1372
|
+
console.error("Active run missing required fields: ".concat(JSON.stringify(run)));
|
|
1373
|
+
return [
|
|
1374
|
+
2,
|
|
1375
|
+
false
|
|
1376
|
+
];
|
|
1377
|
+
}
|
|
1378
|
+
// All active runs should have status 'RUNNING'
|
|
1379
|
+
if (run.status !== 'RUNNING') {
|
|
1380
|
+
console.error("Expected active run status to be 'RUNNING', got ".concat(run.status));
|
|
1381
|
+
return [
|
|
1382
|
+
2,
|
|
1383
|
+
false
|
|
1384
|
+
];
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
} catch (err) {
|
|
1388
|
+
_didIteratorError = true;
|
|
1389
|
+
_iteratorError = err;
|
|
1390
|
+
} finally{
|
|
1391
|
+
try {
|
|
1392
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1393
|
+
_iterator.return();
|
|
1394
|
+
}
|
|
1395
|
+
} finally{
|
|
1396
|
+
if (_didIteratorError) {
|
|
1397
|
+
throw _iteratorError;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return [
|
|
1402
|
+
2,
|
|
1403
|
+
true
|
|
1404
|
+
];
|
|
1405
|
+
case 3:
|
|
1406
|
+
error = _state.sent();
|
|
1407
|
+
console.error("Failed to test GET /brains/".concat(brainName, "/active-runs:"), error);
|
|
1408
|
+
return [
|
|
1409
|
+
2,
|
|
1410
|
+
false
|
|
1411
|
+
];
|
|
1412
|
+
case 4:
|
|
1413
|
+
return [
|
|
1414
|
+
2
|
|
1415
|
+
];
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
})();
|
|
1419
|
+
},
|
|
1420
|
+
rerun: /**
|
|
1421
|
+
* Test POST /brains/runs/rerun - Rerun an existing brain run
|
|
1422
|
+
*/ function rerun(fetch, brainName, runId, startsAt, stopsAfter) {
|
|
1423
|
+
return _async_to_generator(function() {
|
|
1424
|
+
var body, request, response, data, error;
|
|
1425
|
+
return _ts_generator(this, function(_state) {
|
|
1426
|
+
switch(_state.label){
|
|
1427
|
+
case 0:
|
|
1428
|
+
_state.trys.push([
|
|
1429
|
+
0,
|
|
1430
|
+
3,
|
|
1431
|
+
,
|
|
1432
|
+
4
|
|
1433
|
+
]);
|
|
1434
|
+
body = {
|
|
1435
|
+
brainName: brainName
|
|
1436
|
+
};
|
|
1437
|
+
if (runId) body.runId = runId;
|
|
1438
|
+
if (startsAt !== undefined) body.startsAt = startsAt;
|
|
1439
|
+
if (stopsAfter !== undefined) body.stopsAfter = stopsAfter;
|
|
1440
|
+
request = new Request('http://example.com/brains/runs/rerun', {
|
|
1441
|
+
method: 'POST',
|
|
1442
|
+
headers: {
|
|
1443
|
+
'Content-Type': 'application/json'
|
|
1444
|
+
},
|
|
1445
|
+
body: JSON.stringify(body)
|
|
1446
|
+
});
|
|
1447
|
+
return [
|
|
1448
|
+
4,
|
|
1449
|
+
fetch(request)
|
|
1450
|
+
];
|
|
1451
|
+
case 1:
|
|
1452
|
+
response = _state.sent();
|
|
1453
|
+
if (response.status !== 201) {
|
|
1454
|
+
console.error("POST /brains/runs/rerun returned ".concat(response.status, ", expected 201"));
|
|
1455
|
+
return [
|
|
1456
|
+
2,
|
|
1457
|
+
null
|
|
1458
|
+
];
|
|
1459
|
+
}
|
|
1460
|
+
return [
|
|
1461
|
+
4,
|
|
1462
|
+
response.json()
|
|
1463
|
+
];
|
|
1464
|
+
case 2:
|
|
1465
|
+
data = _state.sent();
|
|
1466
|
+
if (!data.brainRunId || typeof data.brainRunId !== 'string') {
|
|
1467
|
+
console.error("Expected brainRunId to be string, got ".concat(_type_of(data.brainRunId)));
|
|
1468
|
+
return [
|
|
1469
|
+
2,
|
|
1470
|
+
null
|
|
1471
|
+
];
|
|
1472
|
+
}
|
|
1473
|
+
return [
|
|
1474
|
+
2,
|
|
1475
|
+
data.brainRunId
|
|
1476
|
+
];
|
|
1477
|
+
case 3:
|
|
1478
|
+
error = _state.sent();
|
|
1479
|
+
console.error("Failed to test POST /brains/runs/rerun:", error);
|
|
1480
|
+
return [
|
|
1481
|
+
2,
|
|
1482
|
+
null
|
|
1483
|
+
];
|
|
1484
|
+
case 4:
|
|
1485
|
+
return [
|
|
1486
|
+
2
|
|
1487
|
+
];
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
})();
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
export var schedules = {
|
|
1494
|
+
create: /**
|
|
1495
|
+
* Test POST /brains/schedules - Create a new schedule
|
|
1496
|
+
*/ function create(fetch, brainName, cronExpression) {
|
|
1497
|
+
return _async_to_generator(function() {
|
|
1498
|
+
var request, response, data, error;
|
|
1499
|
+
return _ts_generator(this, function(_state) {
|
|
1500
|
+
switch(_state.label){
|
|
1501
|
+
case 0:
|
|
1502
|
+
_state.trys.push([
|
|
1503
|
+
0,
|
|
1504
|
+
3,
|
|
1505
|
+
,
|
|
1506
|
+
4
|
|
1507
|
+
]);
|
|
1508
|
+
request = new Request('http://example.com/brains/schedules', {
|
|
1509
|
+
method: 'POST',
|
|
1510
|
+
headers: {
|
|
1511
|
+
'Content-Type': 'application/json'
|
|
1512
|
+
},
|
|
1513
|
+
body: JSON.stringify({
|
|
1514
|
+
brainName: brainName,
|
|
1515
|
+
cronExpression: cronExpression
|
|
1516
|
+
})
|
|
1517
|
+
});
|
|
1518
|
+
return [
|
|
1519
|
+
4,
|
|
1520
|
+
fetch(request)
|
|
1521
|
+
];
|
|
1522
|
+
case 1:
|
|
1523
|
+
response = _state.sent();
|
|
1524
|
+
if (response.status !== 201) {
|
|
1525
|
+
console.error("POST /brains/schedules returned ".concat(response.status, ", expected 201"));
|
|
1526
|
+
return [
|
|
1527
|
+
2,
|
|
1528
|
+
null
|
|
1529
|
+
];
|
|
1530
|
+
}
|
|
1531
|
+
return [
|
|
1532
|
+
4,
|
|
1533
|
+
response.json()
|
|
1534
|
+
];
|
|
1535
|
+
case 2:
|
|
1536
|
+
data = _state.sent();
|
|
1537
|
+
// Validate response structure
|
|
1538
|
+
if (!data.id || typeof data.id !== 'string') {
|
|
1539
|
+
console.error("Expected id to be string, got ".concat(_type_of(data.id)));
|
|
1540
|
+
return [
|
|
1541
|
+
2,
|
|
1542
|
+
null
|
|
1543
|
+
];
|
|
1544
|
+
}
|
|
1545
|
+
if (data.brainName !== brainName) {
|
|
1546
|
+
console.error("Expected brainName to be '".concat(brainName, "', got ").concat(data.brainName));
|
|
1547
|
+
return [
|
|
1548
|
+
2,
|
|
1549
|
+
null
|
|
1550
|
+
];
|
|
1551
|
+
}
|
|
1552
|
+
if (data.cronExpression !== cronExpression) {
|
|
1553
|
+
console.error("Expected cronExpression to be '".concat(cronExpression, "', got ").concat(data.cronExpression));
|
|
1554
|
+
return [
|
|
1555
|
+
2,
|
|
1556
|
+
null
|
|
1557
|
+
];
|
|
1558
|
+
}
|
|
1559
|
+
if (typeof data.enabled !== 'boolean') {
|
|
1560
|
+
console.error("Expected enabled to be boolean, got ".concat(_type_of(data.enabled)));
|
|
1561
|
+
return [
|
|
1562
|
+
2,
|
|
1563
|
+
null
|
|
1564
|
+
];
|
|
1565
|
+
}
|
|
1566
|
+
if (typeof data.createdAt !== 'number') {
|
|
1567
|
+
console.error("Expected createdAt to be number, got ".concat(_type_of(data.createdAt)));
|
|
1568
|
+
return [
|
|
1569
|
+
2,
|
|
1570
|
+
null
|
|
1571
|
+
];
|
|
1572
|
+
}
|
|
1573
|
+
return [
|
|
1574
|
+
2,
|
|
1575
|
+
data.id
|
|
1576
|
+
];
|
|
1577
|
+
case 3:
|
|
1578
|
+
error = _state.sent();
|
|
1579
|
+
console.error("Failed to test POST /brains/schedules:", error);
|
|
1580
|
+
return [
|
|
1581
|
+
2,
|
|
1582
|
+
null
|
|
1583
|
+
];
|
|
1584
|
+
case 4:
|
|
1585
|
+
return [
|
|
1586
|
+
2
|
|
1587
|
+
];
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
})();
|
|
1591
|
+
},
|
|
1592
|
+
list: /**
|
|
1593
|
+
* Test GET /brains/schedules - List all schedules
|
|
1594
|
+
*/ function list(fetch) {
|
|
1595
|
+
return _async_to_generator(function() {
|
|
1596
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, schedule, error;
|
|
1597
|
+
return _ts_generator(this, function(_state) {
|
|
1598
|
+
switch(_state.label){
|
|
1599
|
+
case 0:
|
|
1600
|
+
_state.trys.push([
|
|
1601
|
+
0,
|
|
1602
|
+
3,
|
|
1603
|
+
,
|
|
1604
|
+
4
|
|
1605
|
+
]);
|
|
1606
|
+
request = new Request('http://example.com/brains/schedules', {
|
|
1607
|
+
method: 'GET'
|
|
1608
|
+
});
|
|
1609
|
+
return [
|
|
1610
|
+
4,
|
|
1611
|
+
fetch(request)
|
|
1612
|
+
];
|
|
1613
|
+
case 1:
|
|
1614
|
+
response = _state.sent();
|
|
1615
|
+
if (!response.ok) {
|
|
1616
|
+
console.error("GET /brains/schedules returned ".concat(response.status));
|
|
1617
|
+
return [
|
|
1618
|
+
2,
|
|
1619
|
+
false
|
|
1620
|
+
];
|
|
1621
|
+
}
|
|
1622
|
+
return [
|
|
1623
|
+
4,
|
|
1624
|
+
response.json()
|
|
1625
|
+
];
|
|
1626
|
+
case 2:
|
|
1627
|
+
data = _state.sent();
|
|
1628
|
+
// Validate response structure
|
|
1629
|
+
if (!Array.isArray(data.schedules)) {
|
|
1630
|
+
console.error("Expected schedules to be an array, got ".concat(_type_of(data.schedules)));
|
|
1631
|
+
return [
|
|
1632
|
+
2,
|
|
1633
|
+
false
|
|
1634
|
+
];
|
|
1635
|
+
}
|
|
1636
|
+
if (typeof data.count !== 'number') {
|
|
1637
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
1638
|
+
return [
|
|
1639
|
+
2,
|
|
1640
|
+
false
|
|
1641
|
+
];
|
|
1642
|
+
}
|
|
1643
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1644
|
+
try {
|
|
1645
|
+
// Validate each schedule has required fields
|
|
1646
|
+
for(_iterator = data.schedules[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1647
|
+
schedule = _step.value;
|
|
1648
|
+
if (!schedule.id || !schedule.brainName || !schedule.cronExpression || typeof schedule.enabled !== 'boolean' || typeof schedule.createdAt !== 'number') {
|
|
1649
|
+
console.error("Schedule missing required fields: ".concat(JSON.stringify(schedule)));
|
|
1650
|
+
return [
|
|
1651
|
+
2,
|
|
1652
|
+
false
|
|
1653
|
+
];
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
} catch (err) {
|
|
1657
|
+
_didIteratorError = true;
|
|
1658
|
+
_iteratorError = err;
|
|
1659
|
+
} finally{
|
|
1660
|
+
try {
|
|
1661
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1662
|
+
_iterator.return();
|
|
1663
|
+
}
|
|
1664
|
+
} finally{
|
|
1665
|
+
if (_didIteratorError) {
|
|
1666
|
+
throw _iteratorError;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
return [
|
|
1671
|
+
2,
|
|
1672
|
+
true
|
|
1673
|
+
];
|
|
1674
|
+
case 3:
|
|
1675
|
+
error = _state.sent();
|
|
1676
|
+
console.error("Failed to test GET /brains/schedules:", error);
|
|
1677
|
+
return [
|
|
1678
|
+
2,
|
|
1679
|
+
false
|
|
1680
|
+
];
|
|
1681
|
+
case 4:
|
|
1682
|
+
return [
|
|
1683
|
+
2
|
|
1684
|
+
];
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
})();
|
|
1688
|
+
},
|
|
1689
|
+
delete: /**
|
|
1690
|
+
* Test DELETE /brains/schedules/:scheduleId - Delete a schedule
|
|
1691
|
+
*/ function _delete(fetch, scheduleId) {
|
|
1692
|
+
return _async_to_generator(function() {
|
|
1693
|
+
var request, response, error;
|
|
1694
|
+
return _ts_generator(this, function(_state) {
|
|
1695
|
+
switch(_state.label){
|
|
1696
|
+
case 0:
|
|
1697
|
+
_state.trys.push([
|
|
1698
|
+
0,
|
|
1699
|
+
2,
|
|
1700
|
+
,
|
|
1701
|
+
3
|
|
1702
|
+
]);
|
|
1703
|
+
request = new Request("http://example.com/brains/schedules/".concat(scheduleId), {
|
|
1704
|
+
method: 'DELETE'
|
|
1705
|
+
});
|
|
1706
|
+
return [
|
|
1707
|
+
4,
|
|
1708
|
+
fetch(request)
|
|
1709
|
+
];
|
|
1710
|
+
case 1:
|
|
1711
|
+
response = _state.sent();
|
|
1712
|
+
if (response.status !== 204) {
|
|
1713
|
+
console.error("DELETE /brains/schedules/".concat(scheduleId, " returned ").concat(response.status, ", expected 204"));
|
|
1714
|
+
return [
|
|
1715
|
+
2,
|
|
1716
|
+
false
|
|
1717
|
+
];
|
|
1718
|
+
}
|
|
1719
|
+
return [
|
|
1720
|
+
2,
|
|
1721
|
+
true
|
|
1722
|
+
];
|
|
1723
|
+
case 2:
|
|
1724
|
+
error = _state.sent();
|
|
1725
|
+
console.error("Failed to test DELETE /brains/schedules/".concat(scheduleId, ":"), error);
|
|
1726
|
+
return [
|
|
1727
|
+
2,
|
|
1728
|
+
false
|
|
1729
|
+
];
|
|
1730
|
+
case 3:
|
|
1731
|
+
return [
|
|
1732
|
+
2
|
|
1733
|
+
];
|
|
1734
|
+
}
|
|
1735
|
+
});
|
|
1736
|
+
})();
|
|
1737
|
+
},
|
|
1738
|
+
runs: /**
|
|
1739
|
+
* Test GET /brains/schedules/runs - Get history of scheduled runs
|
|
1740
|
+
*/ function runs(fetch, scheduleId, limit) {
|
|
1741
|
+
return _async_to_generator(function() {
|
|
1742
|
+
var url, request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, run, error;
|
|
1743
|
+
return _ts_generator(this, function(_state) {
|
|
1744
|
+
switch(_state.label){
|
|
1745
|
+
case 0:
|
|
1746
|
+
_state.trys.push([
|
|
1747
|
+
0,
|
|
1748
|
+
3,
|
|
1749
|
+
,
|
|
1750
|
+
4
|
|
1751
|
+
]);
|
|
1752
|
+
url = new URL('http://example.com/brains/schedules/runs');
|
|
1753
|
+
if (scheduleId !== undefined) {
|
|
1754
|
+
url.searchParams.set('scheduleId', scheduleId);
|
|
1755
|
+
}
|
|
1756
|
+
if (limit !== undefined) {
|
|
1757
|
+
url.searchParams.set('limit', limit.toString());
|
|
1758
|
+
}
|
|
1759
|
+
request = new Request(url.toString(), {
|
|
1760
|
+
method: 'GET'
|
|
1761
|
+
});
|
|
1762
|
+
return [
|
|
1763
|
+
4,
|
|
1764
|
+
fetch(request)
|
|
1765
|
+
];
|
|
1766
|
+
case 1:
|
|
1767
|
+
response = _state.sent();
|
|
1768
|
+
if (!response.ok) {
|
|
1769
|
+
console.error("GET /brains/schedules/runs returned ".concat(response.status));
|
|
1770
|
+
return [
|
|
1771
|
+
2,
|
|
1772
|
+
false
|
|
1773
|
+
];
|
|
1774
|
+
}
|
|
1775
|
+
return [
|
|
1776
|
+
4,
|
|
1777
|
+
response.json()
|
|
1778
|
+
];
|
|
1779
|
+
case 2:
|
|
1780
|
+
data = _state.sent();
|
|
1781
|
+
// Validate response structure
|
|
1782
|
+
if (!Array.isArray(data.runs)) {
|
|
1783
|
+
console.error("Expected runs to be an array, got ".concat(_type_of(data.runs)));
|
|
1784
|
+
return [
|
|
1785
|
+
2,
|
|
1786
|
+
false
|
|
1787
|
+
];
|
|
1788
|
+
}
|
|
1789
|
+
if (typeof data.count !== 'number') {
|
|
1790
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
1791
|
+
return [
|
|
1792
|
+
2,
|
|
1793
|
+
false
|
|
1794
|
+
];
|
|
1795
|
+
}
|
|
1796
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1797
|
+
try {
|
|
1798
|
+
// Validate each run has required fields
|
|
1799
|
+
for(_iterator = data.runs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1800
|
+
run = _step.value;
|
|
1801
|
+
if (!run.id || !run.scheduleId || !run.status || typeof run.ranAt !== 'number') {
|
|
1802
|
+
console.error("Scheduled run missing required fields: ".concat(JSON.stringify(run)));
|
|
1803
|
+
return [
|
|
1804
|
+
2,
|
|
1805
|
+
false
|
|
1806
|
+
];
|
|
1807
|
+
}
|
|
1808
|
+
if (![
|
|
1809
|
+
'triggered',
|
|
1810
|
+
'failed'
|
|
1811
|
+
].includes(run.status)) {
|
|
1812
|
+
console.error("Invalid run status: ".concat(run.status));
|
|
1813
|
+
return [
|
|
1814
|
+
2,
|
|
1815
|
+
false
|
|
1816
|
+
];
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
} catch (err) {
|
|
1820
|
+
_didIteratorError = true;
|
|
1821
|
+
_iteratorError = err;
|
|
1822
|
+
} finally{
|
|
1823
|
+
try {
|
|
1824
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1825
|
+
_iterator.return();
|
|
1826
|
+
}
|
|
1827
|
+
} finally{
|
|
1828
|
+
if (_didIteratorError) {
|
|
1829
|
+
throw _iteratorError;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
return [
|
|
1834
|
+
2,
|
|
1835
|
+
true
|
|
1836
|
+
];
|
|
1837
|
+
case 3:
|
|
1838
|
+
error = _state.sent();
|
|
1839
|
+
console.error("Failed to test GET /brains/schedules/runs:", error);
|
|
1840
|
+
return [
|
|
1841
|
+
2,
|
|
1842
|
+
false
|
|
1843
|
+
];
|
|
1844
|
+
case 4:
|
|
1845
|
+
return [
|
|
1846
|
+
2
|
|
1847
|
+
];
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
})();
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
export var secrets = {
|
|
1854
|
+
create: /**
|
|
1855
|
+
* Test POST /secrets - Create or update a secret
|
|
1856
|
+
*/ function create(fetch, name, value) {
|
|
1857
|
+
return _async_to_generator(function() {
|
|
1858
|
+
var request, response, data, error;
|
|
1859
|
+
return _ts_generator(this, function(_state) {
|
|
1860
|
+
switch(_state.label){
|
|
1861
|
+
case 0:
|
|
1862
|
+
_state.trys.push([
|
|
1863
|
+
0,
|
|
1864
|
+
3,
|
|
1865
|
+
,
|
|
1866
|
+
4
|
|
1867
|
+
]);
|
|
1868
|
+
request = new Request('http://example.com/secrets', {
|
|
1869
|
+
method: 'POST',
|
|
1870
|
+
headers: {
|
|
1871
|
+
'Content-Type': 'application/json'
|
|
1872
|
+
},
|
|
1873
|
+
body: JSON.stringify({
|
|
1874
|
+
name: name,
|
|
1875
|
+
value: value
|
|
1876
|
+
})
|
|
1877
|
+
});
|
|
1878
|
+
return [
|
|
1879
|
+
4,
|
|
1880
|
+
fetch(request)
|
|
1881
|
+
];
|
|
1882
|
+
case 1:
|
|
1883
|
+
response = _state.sent();
|
|
1884
|
+
if (response.status !== 201) {
|
|
1885
|
+
console.error("POST /secrets returned ".concat(response.status, ", expected 201"));
|
|
1886
|
+
return [
|
|
1887
|
+
2,
|
|
1888
|
+
false
|
|
1889
|
+
];
|
|
1890
|
+
}
|
|
1891
|
+
return [
|
|
1892
|
+
4,
|
|
1893
|
+
response.json()
|
|
1894
|
+
];
|
|
1895
|
+
case 2:
|
|
1896
|
+
data = _state.sent();
|
|
1897
|
+
// Validate response structure
|
|
1898
|
+
if (!data.name || typeof data.name !== 'string') {
|
|
1899
|
+
console.error("Expected name to be string, got ".concat(_type_of(data.name)));
|
|
1900
|
+
return [
|
|
1901
|
+
2,
|
|
1902
|
+
false
|
|
1903
|
+
];
|
|
1904
|
+
}
|
|
1905
|
+
if (data.name !== name) {
|
|
1906
|
+
console.error("Expected name to be '".concat(name, "', got ").concat(data.name));
|
|
1907
|
+
return [
|
|
1908
|
+
2,
|
|
1909
|
+
false
|
|
1910
|
+
];
|
|
1911
|
+
}
|
|
1912
|
+
if (typeof data.createdAt !== 'string') {
|
|
1913
|
+
console.error("Expected createdAt to be string, got ".concat(_type_of(data.createdAt)));
|
|
1914
|
+
return [
|
|
1915
|
+
2,
|
|
1916
|
+
false
|
|
1917
|
+
];
|
|
1918
|
+
}
|
|
1919
|
+
if (typeof data.updatedAt !== 'string') {
|
|
1920
|
+
console.error("Expected updatedAt to be string, got ".concat(_type_of(data.updatedAt)));
|
|
1921
|
+
return [
|
|
1922
|
+
2,
|
|
1923
|
+
false
|
|
1924
|
+
];
|
|
1925
|
+
}
|
|
1926
|
+
return [
|
|
1927
|
+
2,
|
|
1928
|
+
true
|
|
1929
|
+
];
|
|
1930
|
+
case 3:
|
|
1931
|
+
error = _state.sent();
|
|
1932
|
+
console.error("Failed to test POST /secrets:", error);
|
|
1933
|
+
return [
|
|
1934
|
+
2,
|
|
1935
|
+
false
|
|
1936
|
+
];
|
|
1937
|
+
case 4:
|
|
1938
|
+
return [
|
|
1939
|
+
2
|
|
1940
|
+
];
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
})();
|
|
1944
|
+
},
|
|
1945
|
+
list: /**
|
|
1946
|
+
* Test GET /secrets - List all secrets (names only, not values)
|
|
1947
|
+
*/ function list(fetch) {
|
|
1948
|
+
return _async_to_generator(function() {
|
|
1949
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, secret, error;
|
|
1950
|
+
return _ts_generator(this, function(_state) {
|
|
1951
|
+
switch(_state.label){
|
|
1952
|
+
case 0:
|
|
1953
|
+
_state.trys.push([
|
|
1954
|
+
0,
|
|
1955
|
+
3,
|
|
1956
|
+
,
|
|
1957
|
+
4
|
|
1958
|
+
]);
|
|
1959
|
+
request = new Request('http://example.com/secrets', {
|
|
1960
|
+
method: 'GET'
|
|
1961
|
+
});
|
|
1962
|
+
return [
|
|
1963
|
+
4,
|
|
1964
|
+
fetch(request)
|
|
1965
|
+
];
|
|
1966
|
+
case 1:
|
|
1967
|
+
response = _state.sent();
|
|
1968
|
+
if (!response.ok) {
|
|
1969
|
+
console.error("GET /secrets returned ".concat(response.status));
|
|
1970
|
+
return [
|
|
1971
|
+
2,
|
|
1972
|
+
false
|
|
1973
|
+
];
|
|
1974
|
+
}
|
|
1975
|
+
return [
|
|
1976
|
+
4,
|
|
1977
|
+
response.json()
|
|
1978
|
+
];
|
|
1979
|
+
case 2:
|
|
1980
|
+
data = _state.sent();
|
|
1981
|
+
// Validate response structure
|
|
1982
|
+
if (!Array.isArray(data.secrets)) {
|
|
1983
|
+
console.error("Expected secrets to be an array, got ".concat(_type_of(data.secrets)));
|
|
1984
|
+
return [
|
|
1985
|
+
2,
|
|
1986
|
+
false
|
|
1987
|
+
];
|
|
1988
|
+
}
|
|
1989
|
+
if (typeof data.count !== 'number') {
|
|
1990
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
1991
|
+
return [
|
|
1992
|
+
2,
|
|
1993
|
+
false
|
|
1994
|
+
];
|
|
1995
|
+
}
|
|
1996
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1997
|
+
try {
|
|
1998
|
+
// Validate each secret has required fields (but NOT the value)
|
|
1999
|
+
for(_iterator = data.secrets[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2000
|
+
secret = _step.value;
|
|
2001
|
+
if (!secret.name || typeof secret.name !== 'string' || typeof secret.createdAt !== 'string' || typeof secret.updatedAt !== 'string') {
|
|
2002
|
+
console.error("Secret missing required fields: ".concat(JSON.stringify(secret)));
|
|
2003
|
+
return [
|
|
2004
|
+
2,
|
|
2005
|
+
false
|
|
2006
|
+
];
|
|
2007
|
+
}
|
|
2008
|
+
// Ensure value is NOT included
|
|
2009
|
+
if ('value' in secret) {
|
|
2010
|
+
console.error("Secret should not include value field: ".concat(JSON.stringify(secret)));
|
|
2011
|
+
return [
|
|
2012
|
+
2,
|
|
2013
|
+
false
|
|
2014
|
+
];
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
} catch (err) {
|
|
2018
|
+
_didIteratorError = true;
|
|
2019
|
+
_iteratorError = err;
|
|
2020
|
+
} finally{
|
|
2021
|
+
try {
|
|
2022
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2023
|
+
_iterator.return();
|
|
2024
|
+
}
|
|
2025
|
+
} finally{
|
|
2026
|
+
if (_didIteratorError) {
|
|
2027
|
+
throw _iteratorError;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
return [
|
|
2032
|
+
2,
|
|
2033
|
+
true
|
|
2034
|
+
];
|
|
2035
|
+
case 3:
|
|
2036
|
+
error = _state.sent();
|
|
2037
|
+
console.error("Failed to test GET /secrets:", error);
|
|
2038
|
+
return [
|
|
2039
|
+
2,
|
|
2040
|
+
false
|
|
2041
|
+
];
|
|
2042
|
+
case 4:
|
|
2043
|
+
return [
|
|
2044
|
+
2
|
|
2045
|
+
];
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
})();
|
|
2049
|
+
},
|
|
2050
|
+
delete: /**
|
|
2051
|
+
* Test DELETE /secrets/:name - Delete a specific secret
|
|
2052
|
+
*/ function _delete(fetch, name) {
|
|
2053
|
+
return _async_to_generator(function() {
|
|
2054
|
+
var request, response, error;
|
|
2055
|
+
return _ts_generator(this, function(_state) {
|
|
2056
|
+
switch(_state.label){
|
|
2057
|
+
case 0:
|
|
2058
|
+
_state.trys.push([
|
|
2059
|
+
0,
|
|
2060
|
+
2,
|
|
2061
|
+
,
|
|
2062
|
+
3
|
|
2063
|
+
]);
|
|
2064
|
+
request = new Request("http://example.com/secrets/".concat(encodeURIComponent(name)), {
|
|
2065
|
+
method: 'DELETE'
|
|
2066
|
+
});
|
|
2067
|
+
return [
|
|
2068
|
+
4,
|
|
2069
|
+
fetch(request)
|
|
2070
|
+
];
|
|
2071
|
+
case 1:
|
|
2072
|
+
response = _state.sent();
|
|
2073
|
+
if (response.status !== 204) {
|
|
2074
|
+
console.error("DELETE /secrets/".concat(name, " returned ").concat(response.status, ", expected 204"));
|
|
2075
|
+
return [
|
|
2076
|
+
2,
|
|
2077
|
+
false
|
|
2078
|
+
];
|
|
2079
|
+
}
|
|
2080
|
+
return [
|
|
2081
|
+
2,
|
|
2082
|
+
true
|
|
2083
|
+
];
|
|
2084
|
+
case 2:
|
|
2085
|
+
error = _state.sent();
|
|
2086
|
+
console.error("Failed to test DELETE /secrets/".concat(name, ":"), error);
|
|
2087
|
+
return [
|
|
2088
|
+
2,
|
|
2089
|
+
false
|
|
2090
|
+
];
|
|
2091
|
+
case 3:
|
|
2092
|
+
return [
|
|
2093
|
+
2
|
|
2094
|
+
];
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
})();
|
|
2098
|
+
},
|
|
2099
|
+
exists: /**
|
|
2100
|
+
* Test GET /secrets/:name/exists - Check if a secret exists
|
|
2101
|
+
*/ function exists(fetch, name) {
|
|
2102
|
+
return _async_to_generator(function() {
|
|
2103
|
+
var request, response, data, error;
|
|
2104
|
+
return _ts_generator(this, function(_state) {
|
|
2105
|
+
switch(_state.label){
|
|
2106
|
+
case 0:
|
|
2107
|
+
_state.trys.push([
|
|
2108
|
+
0,
|
|
2109
|
+
3,
|
|
2110
|
+
,
|
|
2111
|
+
4
|
|
2112
|
+
]);
|
|
2113
|
+
request = new Request("http://example.com/secrets/".concat(encodeURIComponent(name), "/exists"), {
|
|
2114
|
+
method: 'GET'
|
|
2115
|
+
});
|
|
2116
|
+
return [
|
|
2117
|
+
4,
|
|
2118
|
+
fetch(request)
|
|
2119
|
+
];
|
|
2120
|
+
case 1:
|
|
2121
|
+
response = _state.sent();
|
|
2122
|
+
if (!response.ok) {
|
|
2123
|
+
console.error("GET /secrets/".concat(name, "/exists returned ").concat(response.status));
|
|
2124
|
+
return [
|
|
2125
|
+
2,
|
|
2126
|
+
false
|
|
2127
|
+
];
|
|
2128
|
+
}
|
|
2129
|
+
return [
|
|
2130
|
+
4,
|
|
2131
|
+
response.json()
|
|
2132
|
+
];
|
|
2133
|
+
case 2:
|
|
2134
|
+
data = _state.sent();
|
|
2135
|
+
// Validate response structure
|
|
2136
|
+
if (typeof data.exists !== 'boolean') {
|
|
2137
|
+
console.error("Expected exists to be boolean, got ".concat(_type_of(data.exists)));
|
|
2138
|
+
return [
|
|
2139
|
+
2,
|
|
2140
|
+
false
|
|
2141
|
+
];
|
|
2142
|
+
}
|
|
2143
|
+
return [
|
|
2144
|
+
2,
|
|
2145
|
+
true
|
|
2146
|
+
];
|
|
2147
|
+
case 3:
|
|
2148
|
+
error = _state.sent();
|
|
2149
|
+
console.error("Failed to test GET /secrets/".concat(name, "/exists:"), error);
|
|
2150
|
+
return [
|
|
2151
|
+
2,
|
|
2152
|
+
false
|
|
2153
|
+
];
|
|
2154
|
+
case 4:
|
|
2155
|
+
return [
|
|
2156
|
+
2
|
|
2157
|
+
];
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
})();
|
|
2161
|
+
},
|
|
2162
|
+
bulk: /**
|
|
2163
|
+
* Test POST /secrets/bulk - Create multiple secrets
|
|
2164
|
+
*/ function bulk(fetch, secrets) {
|
|
2165
|
+
return _async_to_generator(function() {
|
|
2166
|
+
var request, response, data, error;
|
|
2167
|
+
return _ts_generator(this, function(_state) {
|
|
2168
|
+
switch(_state.label){
|
|
2169
|
+
case 0:
|
|
2170
|
+
_state.trys.push([
|
|
2171
|
+
0,
|
|
2172
|
+
3,
|
|
2173
|
+
,
|
|
2174
|
+
4
|
|
2175
|
+
]);
|
|
2176
|
+
request = new Request('http://example.com/secrets/bulk', {
|
|
2177
|
+
method: 'POST',
|
|
2178
|
+
headers: {
|
|
2179
|
+
'Content-Type': 'application/json'
|
|
2180
|
+
},
|
|
2181
|
+
body: JSON.stringify({
|
|
2182
|
+
secrets: secrets
|
|
2183
|
+
})
|
|
2184
|
+
});
|
|
2185
|
+
return [
|
|
2186
|
+
4,
|
|
2187
|
+
fetch(request)
|
|
2188
|
+
];
|
|
2189
|
+
case 1:
|
|
2190
|
+
response = _state.sent();
|
|
2191
|
+
if (response.status !== 201) {
|
|
2192
|
+
console.error("POST /secrets/bulk returned ".concat(response.status, ", expected 201"));
|
|
2193
|
+
return [
|
|
2194
|
+
2,
|
|
2195
|
+
false
|
|
2196
|
+
];
|
|
2197
|
+
}
|
|
2198
|
+
return [
|
|
2199
|
+
4,
|
|
2200
|
+
response.json()
|
|
2201
|
+
];
|
|
2202
|
+
case 2:
|
|
2203
|
+
data = _state.sent();
|
|
2204
|
+
// Validate response structure
|
|
2205
|
+
if (typeof data.created !== 'number') {
|
|
2206
|
+
console.error("Expected created to be number, got ".concat(_type_of(data.created)));
|
|
2207
|
+
return [
|
|
2208
|
+
2,
|
|
2209
|
+
false
|
|
2210
|
+
];
|
|
2211
|
+
}
|
|
2212
|
+
if (typeof data.updated !== 'number') {
|
|
2213
|
+
console.error("Expected updated to be number, got ".concat(_type_of(data.updated)));
|
|
2214
|
+
return [
|
|
2215
|
+
2,
|
|
2216
|
+
false
|
|
2217
|
+
];
|
|
2218
|
+
}
|
|
2219
|
+
// Total should match input
|
|
2220
|
+
if (data.created + data.updated !== secrets.length) {
|
|
2221
|
+
console.error("Expected total (".concat(data.created + data.updated, ") to match input length (").concat(secrets.length, ")"));
|
|
2222
|
+
return [
|
|
2223
|
+
2,
|
|
2224
|
+
false
|
|
2225
|
+
];
|
|
2226
|
+
}
|
|
2227
|
+
return [
|
|
2228
|
+
2,
|
|
2229
|
+
true
|
|
2230
|
+
];
|
|
2231
|
+
case 3:
|
|
2232
|
+
error = _state.sent();
|
|
2233
|
+
console.error("Failed to test POST /secrets/bulk:", error);
|
|
2234
|
+
return [
|
|
2235
|
+
2,
|
|
2236
|
+
false
|
|
2237
|
+
];
|
|
2238
|
+
case 4:
|
|
2239
|
+
return [
|
|
2240
|
+
2
|
|
2241
|
+
];
|
|
2242
|
+
}
|
|
2243
|
+
});
|
|
2244
|
+
})();
|
|
2245
|
+
}
|
|
2246
|
+
};
|