@positronic/spec 0.0.55 → 0.0.57
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 → api/brains.d.ts} +2 -160
- package/dist/api/brains.d.ts.map +1 -0
- package/dist/{api.js → api/brains.js} +18 -1234
- package/dist/api/brains.js.map +1 -0
- package/dist/api/bundle.d.ts +17 -0
- package/dist/api/bundle.d.ts.map +1 -0
- package/dist/api/bundle.js +56 -0
- package/dist/api/bundle.js.map +1 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +11 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/pages.d.ts +46 -0
- package/dist/api/pages.d.ts.map +1 -0
- package/dist/api/pages.js +338 -0
- package/dist/api/pages.js.map +1 -0
- package/dist/api/resources.d.ts +28 -0
- package/dist/api/resources.d.ts.map +1 -0
- package/dist/api/resources.js +272 -0
- package/dist/api/resources.js.map +1 -0
- package/dist/api/schedules.d.ts +20 -0
- package/dist/api/schedules.d.ts.map +1 -0
- package/dist/api/schedules.js +159 -0
- package/dist/api/schedules.js.map +1 -0
- package/dist/api/secrets.d.ts +27 -0
- package/dist/api/secrets.d.ts.map +1 -0
- package/dist/api/secrets.js +175 -0
- package/dist/api/secrets.js.map +1 -0
- package/dist/api/signals.d.ts +53 -0
- package/dist/api/signals.d.ts.map +1 -0
- package/dist/api/signals.js +276 -0
- package/dist/api/signals.js.map +1 -0
- package/dist/api/status.d.ts +3 -0
- package/dist/api/status.d.ts.map +1 -0
- package/dist/api/status.js +23 -0
- package/dist/api/status.js.map +1 -0
- package/dist/api/types.d.ts +2 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/users.d.ts +43 -0
- package/dist/api/users.d.ts.map +1 -0
- package/dist/api/users.js +221 -0
- package/dist/api/users.js.map +1 -0
- package/dist/api/webhooks.d.ts +30 -0
- package/dist/api/webhooks.d.ts.map +1 -0
- package/dist/api/webhooks.js +208 -0
- package/dist/api/webhooks.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/{api.js → api/brains.js} +1378 -4108
- package/dist/src/api/bundle.js +228 -0
- package/dist/src/api/index.js +10 -0
- package/dist/src/api/pages.js +840 -0
- package/dist/src/api/resources.js +707 -0
- package/dist/src/api/schedules.js +479 -0
- package/dist/src/api/secrets.js +518 -0
- package/dist/src/api/signals.js +778 -0
- package/dist/src/api/status.js +180 -0
- package/dist/src/api/types.js +1 -0
- package/dist/src/api/users.js +650 -0
- package/dist/src/api/webhooks.js +639 -0
- package/dist/src/index.js +1 -1
- package/package.json +1 -1
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js.map +0 -1
|
@@ -0,0 +1,707 @@
|
|
|
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 var resources = {
|
|
126
|
+
list: /**
|
|
127
|
+
* Test GET /resources - List all resources
|
|
128
|
+
*/ function list(fetch) {
|
|
129
|
+
return _async_to_generator(function() {
|
|
130
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, resource, error;
|
|
131
|
+
return _ts_generator(this, function(_state) {
|
|
132
|
+
switch(_state.label){
|
|
133
|
+
case 0:
|
|
134
|
+
_state.trys.push([
|
|
135
|
+
0,
|
|
136
|
+
3,
|
|
137
|
+
,
|
|
138
|
+
4
|
|
139
|
+
]);
|
|
140
|
+
request = new Request('http://example.com/resources', {
|
|
141
|
+
method: 'GET'
|
|
142
|
+
});
|
|
143
|
+
return [
|
|
144
|
+
4,
|
|
145
|
+
fetch(request)
|
|
146
|
+
];
|
|
147
|
+
case 1:
|
|
148
|
+
response = _state.sent();
|
|
149
|
+
if (!response.ok) {
|
|
150
|
+
console.error("GET /resources returned ".concat(response.status));
|
|
151
|
+
return [
|
|
152
|
+
2,
|
|
153
|
+
false
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
return [
|
|
157
|
+
4,
|
|
158
|
+
response.json()
|
|
159
|
+
];
|
|
160
|
+
case 2:
|
|
161
|
+
data = _state.sent();
|
|
162
|
+
// Validate response structure
|
|
163
|
+
if (!Array.isArray(data.resources)) {
|
|
164
|
+
console.error("Expected resources to be an array, got ".concat(_type_of(data.resources)));
|
|
165
|
+
return [
|
|
166
|
+
2,
|
|
167
|
+
false
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
if (typeof data.truncated !== 'boolean') {
|
|
171
|
+
console.error("Expected truncated to be boolean, got ".concat(_type_of(data.truncated)));
|
|
172
|
+
return [
|
|
173
|
+
2,
|
|
174
|
+
false
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
if (typeof data.count !== 'number') {
|
|
178
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
179
|
+
return [
|
|
180
|
+
2,
|
|
181
|
+
false
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
185
|
+
try {
|
|
186
|
+
// Validate each resource has required fields
|
|
187
|
+
for(_iterator = data.resources[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
188
|
+
resource = _step.value;
|
|
189
|
+
if (!resource.key || !resource.type || typeof resource.size !== 'number' || !resource.lastModified || typeof resource.local !== 'boolean') {
|
|
190
|
+
console.error("Resource missing required fields: ".concat(JSON.stringify(resource)));
|
|
191
|
+
return [
|
|
192
|
+
2,
|
|
193
|
+
false
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
if (![
|
|
197
|
+
'text',
|
|
198
|
+
'binary'
|
|
199
|
+
].includes(resource.type)) {
|
|
200
|
+
console.error("Invalid resource type: ".concat(resource.type));
|
|
201
|
+
return [
|
|
202
|
+
2,
|
|
203
|
+
false
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} catch (err) {
|
|
208
|
+
_didIteratorError = true;
|
|
209
|
+
_iteratorError = err;
|
|
210
|
+
} finally{
|
|
211
|
+
try {
|
|
212
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
213
|
+
_iterator.return();
|
|
214
|
+
}
|
|
215
|
+
} finally{
|
|
216
|
+
if (_didIteratorError) {
|
|
217
|
+
throw _iteratorError;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return [
|
|
222
|
+
2,
|
|
223
|
+
true
|
|
224
|
+
];
|
|
225
|
+
case 3:
|
|
226
|
+
error = _state.sent();
|
|
227
|
+
console.error("Failed to test GET /resources:", error);
|
|
228
|
+
return [
|
|
229
|
+
2,
|
|
230
|
+
false
|
|
231
|
+
];
|
|
232
|
+
case 4:
|
|
233
|
+
return [
|
|
234
|
+
2
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
})();
|
|
239
|
+
},
|
|
240
|
+
upload: /**
|
|
241
|
+
* Test POST /resources - Upload a resource
|
|
242
|
+
*/ function upload(fetch) {
|
|
243
|
+
return _async_to_generator(function() {
|
|
244
|
+
var formData, request, response, data, error;
|
|
245
|
+
return _ts_generator(this, function(_state) {
|
|
246
|
+
switch(_state.label){
|
|
247
|
+
case 0:
|
|
248
|
+
_state.trys.push([
|
|
249
|
+
0,
|
|
250
|
+
3,
|
|
251
|
+
,
|
|
252
|
+
4
|
|
253
|
+
]);
|
|
254
|
+
formData = new FormData();
|
|
255
|
+
formData.append('file', new Blob([
|
|
256
|
+
'test content'
|
|
257
|
+
], {
|
|
258
|
+
type: 'text/plain'
|
|
259
|
+
}), 'test.txt');
|
|
260
|
+
formData.append('type', 'text');
|
|
261
|
+
formData.append('key', 'test-resource.txt');
|
|
262
|
+
formData.append('local', 'false');
|
|
263
|
+
request = new Request('http://example.com/resources', {
|
|
264
|
+
method: 'POST',
|
|
265
|
+
body: formData
|
|
266
|
+
});
|
|
267
|
+
return [
|
|
268
|
+
4,
|
|
269
|
+
fetch(request)
|
|
270
|
+
];
|
|
271
|
+
case 1:
|
|
272
|
+
response = _state.sent();
|
|
273
|
+
if (response.status !== 201) {
|
|
274
|
+
console.error("POST /resources returned ".concat(response.status, ", expected 201"));
|
|
275
|
+
return [
|
|
276
|
+
2,
|
|
277
|
+
false
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
return [
|
|
281
|
+
4,
|
|
282
|
+
response.json()
|
|
283
|
+
];
|
|
284
|
+
case 2:
|
|
285
|
+
data = _state.sent();
|
|
286
|
+
// Validate response has required fields
|
|
287
|
+
if (!data.key || !data.type || typeof data.size !== 'number' || !data.lastModified || typeof data.local !== 'boolean') {
|
|
288
|
+
console.error("Response missing required fields: ".concat(JSON.stringify(data)));
|
|
289
|
+
return [
|
|
290
|
+
2,
|
|
291
|
+
false
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
if (data.key !== 'test-resource.txt') {
|
|
295
|
+
console.error("Expected key to be 'test-resource.txt', got ".concat(data.key));
|
|
296
|
+
return [
|
|
297
|
+
2,
|
|
298
|
+
false
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
if (data.type !== 'text') {
|
|
302
|
+
console.error("Expected type to be 'text', got ".concat(data.type));
|
|
303
|
+
return [
|
|
304
|
+
2,
|
|
305
|
+
false
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
if (data.local !== false) {
|
|
309
|
+
console.error("Expected local to be false, got ".concat(data.local));
|
|
310
|
+
return [
|
|
311
|
+
2,
|
|
312
|
+
false
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
return [
|
|
316
|
+
2,
|
|
317
|
+
true
|
|
318
|
+
];
|
|
319
|
+
case 3:
|
|
320
|
+
error = _state.sent();
|
|
321
|
+
console.error("Failed to test POST /resources:", error);
|
|
322
|
+
return [
|
|
323
|
+
2,
|
|
324
|
+
false
|
|
325
|
+
];
|
|
326
|
+
case 4:
|
|
327
|
+
return [
|
|
328
|
+
2
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
})();
|
|
333
|
+
},
|
|
334
|
+
delete: /**
|
|
335
|
+
* Test DELETE /resources/:key - Delete a specific resource
|
|
336
|
+
*/ function _delete(fetch, key) {
|
|
337
|
+
return _async_to_generator(function() {
|
|
338
|
+
var request, response, error;
|
|
339
|
+
return _ts_generator(this, function(_state) {
|
|
340
|
+
switch(_state.label){
|
|
341
|
+
case 0:
|
|
342
|
+
_state.trys.push([
|
|
343
|
+
0,
|
|
344
|
+
2,
|
|
345
|
+
,
|
|
346
|
+
3
|
|
347
|
+
]);
|
|
348
|
+
request = new Request("http://example.com/resources/".concat(encodeURIComponent(key)), {
|
|
349
|
+
method: 'DELETE'
|
|
350
|
+
});
|
|
351
|
+
return [
|
|
352
|
+
4,
|
|
353
|
+
fetch(request)
|
|
354
|
+
];
|
|
355
|
+
case 1:
|
|
356
|
+
response = _state.sent();
|
|
357
|
+
if (response.status !== 204) {
|
|
358
|
+
console.error("DELETE /resources/".concat(key, " returned ").concat(response.status, ", expected 204"));
|
|
359
|
+
return [
|
|
360
|
+
2,
|
|
361
|
+
false
|
|
362
|
+
];
|
|
363
|
+
}
|
|
364
|
+
return [
|
|
365
|
+
2,
|
|
366
|
+
true
|
|
367
|
+
];
|
|
368
|
+
case 2:
|
|
369
|
+
error = _state.sent();
|
|
370
|
+
console.error("Failed to test DELETE /resources/".concat(key, ":"), error);
|
|
371
|
+
return [
|
|
372
|
+
2,
|
|
373
|
+
false
|
|
374
|
+
];
|
|
375
|
+
case 3:
|
|
376
|
+
return [
|
|
377
|
+
2
|
|
378
|
+
];
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
})();
|
|
382
|
+
},
|
|
383
|
+
deleteAll: /**
|
|
384
|
+
* Test DELETE /resources - Bulk delete all resources (dev mode only)
|
|
385
|
+
*/ function deleteAll(fetch) {
|
|
386
|
+
return _async_to_generator(function() {
|
|
387
|
+
var request, response, data, data1, error;
|
|
388
|
+
return _ts_generator(this, function(_state) {
|
|
389
|
+
switch(_state.label){
|
|
390
|
+
case 0:
|
|
391
|
+
_state.trys.push([
|
|
392
|
+
0,
|
|
393
|
+
5,
|
|
394
|
+
,
|
|
395
|
+
6
|
|
396
|
+
]);
|
|
397
|
+
request = new Request('http://example.com/resources', {
|
|
398
|
+
method: 'DELETE'
|
|
399
|
+
});
|
|
400
|
+
return [
|
|
401
|
+
4,
|
|
402
|
+
fetch(request)
|
|
403
|
+
];
|
|
404
|
+
case 1:
|
|
405
|
+
response = _state.sent();
|
|
406
|
+
if (!(response.status === 403)) return [
|
|
407
|
+
3,
|
|
408
|
+
3
|
|
409
|
+
];
|
|
410
|
+
return [
|
|
411
|
+
4,
|
|
412
|
+
response.json()
|
|
413
|
+
];
|
|
414
|
+
case 2:
|
|
415
|
+
data = _state.sent();
|
|
416
|
+
if (data.error === 'Bulk delete is only available in development mode') {
|
|
417
|
+
// This is expected behavior in production
|
|
418
|
+
return [
|
|
419
|
+
2,
|
|
420
|
+
true
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
_state.label = 3;
|
|
424
|
+
case 3:
|
|
425
|
+
if (response.status !== 200) {
|
|
426
|
+
console.error("DELETE /resources returned ".concat(response.status, ", expected 200 or 403"));
|
|
427
|
+
return [
|
|
428
|
+
2,
|
|
429
|
+
false
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
return [
|
|
433
|
+
4,
|
|
434
|
+
response.json()
|
|
435
|
+
];
|
|
436
|
+
case 4:
|
|
437
|
+
data1 = _state.sent();
|
|
438
|
+
if (typeof data1.deletedCount !== 'number') {
|
|
439
|
+
console.error("Expected deletedCount to be number, got ".concat(_type_of(data1.deletedCount)));
|
|
440
|
+
return [
|
|
441
|
+
2,
|
|
442
|
+
false
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
return [
|
|
446
|
+
2,
|
|
447
|
+
true
|
|
448
|
+
];
|
|
449
|
+
case 5:
|
|
450
|
+
error = _state.sent();
|
|
451
|
+
console.error("Failed to test DELETE /resources:", error);
|
|
452
|
+
return [
|
|
453
|
+
2,
|
|
454
|
+
false
|
|
455
|
+
];
|
|
456
|
+
case 6:
|
|
457
|
+
return [
|
|
458
|
+
2
|
|
459
|
+
];
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
})();
|
|
463
|
+
},
|
|
464
|
+
deleteAllPreservesPages: /**
|
|
465
|
+
* Test DELETE /resources preserves pages - bulk delete should not delete pages
|
|
466
|
+
*/ function deleteAllPreservesPages(fetch) {
|
|
467
|
+
return _async_to_generator(function() {
|
|
468
|
+
var pageSlug, pageHtml, brainRunId, createPageRequest, createPageResponse, deleteRequest, deleteResponse, getPageRequest, getPageResponse, error;
|
|
469
|
+
return _ts_generator(this, function(_state) {
|
|
470
|
+
switch(_state.label){
|
|
471
|
+
case 0:
|
|
472
|
+
_state.trys.push([
|
|
473
|
+
0,
|
|
474
|
+
7,
|
|
475
|
+
,
|
|
476
|
+
8
|
|
477
|
+
]);
|
|
478
|
+
// First create a page
|
|
479
|
+
pageSlug = "spec-test-page-".concat(Date.now());
|
|
480
|
+
pageHtml = '<html><body>Test page for spec</body></html>';
|
|
481
|
+
brainRunId = 'spec-test-brain-run-id';
|
|
482
|
+
createPageRequest = new Request('http://example.com/pages', {
|
|
483
|
+
method: 'POST',
|
|
484
|
+
headers: {
|
|
485
|
+
'Content-Type': 'application/json'
|
|
486
|
+
},
|
|
487
|
+
body: JSON.stringify({
|
|
488
|
+
slug: pageSlug,
|
|
489
|
+
html: pageHtml,
|
|
490
|
+
brainRunId: brainRunId
|
|
491
|
+
})
|
|
492
|
+
});
|
|
493
|
+
return [
|
|
494
|
+
4,
|
|
495
|
+
fetch(createPageRequest)
|
|
496
|
+
];
|
|
497
|
+
case 1:
|
|
498
|
+
createPageResponse = _state.sent();
|
|
499
|
+
if (createPageResponse.status !== 201) {
|
|
500
|
+
console.error("Failed to create test page: ".concat(createPageResponse.status));
|
|
501
|
+
return [
|
|
502
|
+
2,
|
|
503
|
+
false
|
|
504
|
+
];
|
|
505
|
+
}
|
|
506
|
+
// Now bulk delete all resources
|
|
507
|
+
deleteRequest = new Request('http://example.com/resources', {
|
|
508
|
+
method: 'DELETE'
|
|
509
|
+
});
|
|
510
|
+
return [
|
|
511
|
+
4,
|
|
512
|
+
fetch(deleteRequest)
|
|
513
|
+
];
|
|
514
|
+
case 2:
|
|
515
|
+
deleteResponse = _state.sent();
|
|
516
|
+
if (!(deleteResponse.status === 403)) return [
|
|
517
|
+
3,
|
|
518
|
+
4
|
|
519
|
+
];
|
|
520
|
+
// Clean up the page we created
|
|
521
|
+
return [
|
|
522
|
+
4,
|
|
523
|
+
fetch(new Request("http://example.com/pages/".concat(encodeURIComponent(pageSlug)), {
|
|
524
|
+
method: 'DELETE'
|
|
525
|
+
}))
|
|
526
|
+
];
|
|
527
|
+
case 3:
|
|
528
|
+
_state.sent();
|
|
529
|
+
console.log('Skipping deleteAllPreservesPages test - bulk delete not available in production');
|
|
530
|
+
return [
|
|
531
|
+
2,
|
|
532
|
+
true
|
|
533
|
+
];
|
|
534
|
+
case 4:
|
|
535
|
+
if (deleteResponse.status !== 200) {
|
|
536
|
+
console.error("DELETE /resources returned ".concat(deleteResponse.status, ", expected 200"));
|
|
537
|
+
return [
|
|
538
|
+
2,
|
|
539
|
+
false
|
|
540
|
+
];
|
|
541
|
+
}
|
|
542
|
+
// Verify the page still exists
|
|
543
|
+
getPageRequest = new Request("http://example.com/pages/".concat(encodeURIComponent(pageSlug)), {
|
|
544
|
+
method: 'GET'
|
|
545
|
+
});
|
|
546
|
+
return [
|
|
547
|
+
4,
|
|
548
|
+
fetch(getPageRequest)
|
|
549
|
+
];
|
|
550
|
+
case 5:
|
|
551
|
+
getPageResponse = _state.sent();
|
|
552
|
+
if (getPageResponse.status === 404) {
|
|
553
|
+
console.error('DELETE /resources incorrectly deleted pages - page not found after bulk delete');
|
|
554
|
+
return [
|
|
555
|
+
2,
|
|
556
|
+
false
|
|
557
|
+
];
|
|
558
|
+
}
|
|
559
|
+
if (!getPageResponse.ok) {
|
|
560
|
+
console.error("GET /pages/".concat(pageSlug, " returned ").concat(getPageResponse.status));
|
|
561
|
+
return [
|
|
562
|
+
2,
|
|
563
|
+
false
|
|
564
|
+
];
|
|
565
|
+
}
|
|
566
|
+
// Clean up: delete the test page
|
|
567
|
+
return [
|
|
568
|
+
4,
|
|
569
|
+
fetch(new Request("http://example.com/pages/".concat(encodeURIComponent(pageSlug)), {
|
|
570
|
+
method: 'DELETE'
|
|
571
|
+
}))
|
|
572
|
+
];
|
|
573
|
+
case 6:
|
|
574
|
+
_state.sent();
|
|
575
|
+
return [
|
|
576
|
+
2,
|
|
577
|
+
true
|
|
578
|
+
];
|
|
579
|
+
case 7:
|
|
580
|
+
error = _state.sent();
|
|
581
|
+
console.error("Failed to test DELETE /resources preserves pages:", error);
|
|
582
|
+
return [
|
|
583
|
+
2,
|
|
584
|
+
false
|
|
585
|
+
];
|
|
586
|
+
case 8:
|
|
587
|
+
return [
|
|
588
|
+
2
|
|
589
|
+
];
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
})();
|
|
593
|
+
},
|
|
594
|
+
generatePresignedLink: /**
|
|
595
|
+
* Test POST /resources/presigned-link - Generate presigned URL for upload
|
|
596
|
+
*/ function generatePresignedLink(fetch) {
|
|
597
|
+
return _async_to_generator(function() {
|
|
598
|
+
var request, response, data, data1, error;
|
|
599
|
+
return _ts_generator(this, function(_state) {
|
|
600
|
+
switch(_state.label){
|
|
601
|
+
case 0:
|
|
602
|
+
_state.trys.push([
|
|
603
|
+
0,
|
|
604
|
+
5,
|
|
605
|
+
,
|
|
606
|
+
6
|
|
607
|
+
]);
|
|
608
|
+
request = new Request('http://example.com/resources/presigned-link', {
|
|
609
|
+
method: 'POST',
|
|
610
|
+
headers: {
|
|
611
|
+
'Content-Type': 'application/json'
|
|
612
|
+
},
|
|
613
|
+
body: JSON.stringify({
|
|
614
|
+
key: 'test-files/large-video.mp4',
|
|
615
|
+
type: 'binary',
|
|
616
|
+
size: 150 * 1024 * 1024
|
|
617
|
+
})
|
|
618
|
+
});
|
|
619
|
+
return [
|
|
620
|
+
4,
|
|
621
|
+
fetch(request)
|
|
622
|
+
];
|
|
623
|
+
case 1:
|
|
624
|
+
response = _state.sent();
|
|
625
|
+
if (!(response.status === 400)) return [
|
|
626
|
+
3,
|
|
627
|
+
3
|
|
628
|
+
];
|
|
629
|
+
return [
|
|
630
|
+
4,
|
|
631
|
+
response.json()
|
|
632
|
+
];
|
|
633
|
+
case 2:
|
|
634
|
+
data = _state.sent();
|
|
635
|
+
// This is acceptable - implementation may not have credentials configured
|
|
636
|
+
console.log('Presigned URL generation not available - this is acceptable');
|
|
637
|
+
return [
|
|
638
|
+
2,
|
|
639
|
+
true
|
|
640
|
+
];
|
|
641
|
+
case 3:
|
|
642
|
+
if (response.status !== 200) {
|
|
643
|
+
console.error("POST /resources/presigned-link returned ".concat(response.status, ", expected 200 or 400"));
|
|
644
|
+
return [
|
|
645
|
+
2,
|
|
646
|
+
false
|
|
647
|
+
];
|
|
648
|
+
}
|
|
649
|
+
return [
|
|
650
|
+
4,
|
|
651
|
+
response.json()
|
|
652
|
+
];
|
|
653
|
+
case 4:
|
|
654
|
+
data1 = _state.sent();
|
|
655
|
+
// Validate response structure (backend-agnostic)
|
|
656
|
+
if (!data1.url || typeof data1.url !== 'string') {
|
|
657
|
+
console.error("Expected url to be string, got ".concat(_type_of(data1.url)));
|
|
658
|
+
return [
|
|
659
|
+
2,
|
|
660
|
+
false
|
|
661
|
+
];
|
|
662
|
+
}
|
|
663
|
+
if (!data1.method || data1.method !== 'PUT') {
|
|
664
|
+
console.error("Expected method to be 'PUT', got ".concat(data1.method));
|
|
665
|
+
return [
|
|
666
|
+
2,
|
|
667
|
+
false
|
|
668
|
+
];
|
|
669
|
+
}
|
|
670
|
+
if (typeof data1.expiresIn !== 'number' || data1.expiresIn <= 0) {
|
|
671
|
+
console.error("Expected expiresIn to be positive number, got ".concat(data1.expiresIn));
|
|
672
|
+
return [
|
|
673
|
+
2,
|
|
674
|
+
false
|
|
675
|
+
];
|
|
676
|
+
}
|
|
677
|
+
// Basic URL validation - just ensure it's a valid URL
|
|
678
|
+
try {
|
|
679
|
+
new URL(data1.url);
|
|
680
|
+
console.log('Presigned URL structure validated successfully');
|
|
681
|
+
} catch (error) {
|
|
682
|
+
console.error("Invalid URL returned: ".concat(data1.url));
|
|
683
|
+
return [
|
|
684
|
+
2,
|
|
685
|
+
false
|
|
686
|
+
];
|
|
687
|
+
}
|
|
688
|
+
return [
|
|
689
|
+
2,
|
|
690
|
+
true
|
|
691
|
+
];
|
|
692
|
+
case 5:
|
|
693
|
+
error = _state.sent();
|
|
694
|
+
console.error("Failed to test POST /resources/presigned-link:", error);
|
|
695
|
+
return [
|
|
696
|
+
2,
|
|
697
|
+
false
|
|
698
|
+
];
|
|
699
|
+
case 6:
|
|
700
|
+
return [
|
|
701
|
+
2
|
|
702
|
+
];
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
})();
|
|
706
|
+
}
|
|
707
|
+
};
|