@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,639 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _iterable_to_array_limit(arr, i) {
|
|
39
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
+
if (_i == null) return;
|
|
41
|
+
var _arr = [];
|
|
42
|
+
var _n = true;
|
|
43
|
+
var _d = false;
|
|
44
|
+
var _s, _e;
|
|
45
|
+
try {
|
|
46
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
47
|
+
_arr.push(_s.value);
|
|
48
|
+
if (i && _arr.length === i) break;
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_d = true;
|
|
52
|
+
_e = err;
|
|
53
|
+
} finally{
|
|
54
|
+
try {
|
|
55
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
56
|
+
} finally{
|
|
57
|
+
if (_d) throw _e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return _arr;
|
|
61
|
+
}
|
|
62
|
+
function _non_iterable_rest() {
|
|
63
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
+
}
|
|
65
|
+
function _sliced_to_array(arr, i) {
|
|
66
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
67
|
+
}
|
|
68
|
+
function _type_of(obj) {
|
|
69
|
+
"@swc/helpers - typeof";
|
|
70
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
71
|
+
}
|
|
72
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
73
|
+
if (!o) return;
|
|
74
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
75
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
76
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
77
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
78
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
79
|
+
}
|
|
80
|
+
function _ts_generator(thisArg, body) {
|
|
81
|
+
var f, y, t, _ = {
|
|
82
|
+
label: 0,
|
|
83
|
+
sent: function() {
|
|
84
|
+
if (t[0] & 1) throw t[1];
|
|
85
|
+
return t[1];
|
|
86
|
+
},
|
|
87
|
+
trys: [],
|
|
88
|
+
ops: []
|
|
89
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
90
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
91
|
+
return this;
|
|
92
|
+
}), g;
|
|
93
|
+
function verb(n) {
|
|
94
|
+
return function(v) {
|
|
95
|
+
return step([
|
|
96
|
+
n,
|
|
97
|
+
v
|
|
98
|
+
]);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function step(op) {
|
|
102
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
103
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
104
|
+
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;
|
|
105
|
+
if (y = 0, t) op = [
|
|
106
|
+
op[0] & 2,
|
|
107
|
+
t.value
|
|
108
|
+
];
|
|
109
|
+
switch(op[0]){
|
|
110
|
+
case 0:
|
|
111
|
+
case 1:
|
|
112
|
+
t = op;
|
|
113
|
+
break;
|
|
114
|
+
case 4:
|
|
115
|
+
_.label++;
|
|
116
|
+
return {
|
|
117
|
+
value: op[1],
|
|
118
|
+
done: false
|
|
119
|
+
};
|
|
120
|
+
case 5:
|
|
121
|
+
_.label++;
|
|
122
|
+
y = op[1];
|
|
123
|
+
op = [
|
|
124
|
+
0
|
|
125
|
+
];
|
|
126
|
+
continue;
|
|
127
|
+
case 7:
|
|
128
|
+
op = _.ops.pop();
|
|
129
|
+
_.trys.pop();
|
|
130
|
+
continue;
|
|
131
|
+
default:
|
|
132
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
133
|
+
_ = 0;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
137
|
+
_.label = op[1];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
141
|
+
_.label = t[1];
|
|
142
|
+
t = op;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (t && _.label < t[2]) {
|
|
146
|
+
_.label = t[2];
|
|
147
|
+
_.ops.push(op);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (t[2]) _.ops.pop();
|
|
151
|
+
_.trys.pop();
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
op = body.call(thisArg, _);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
op = [
|
|
157
|
+
6,
|
|
158
|
+
e
|
|
159
|
+
];
|
|
160
|
+
y = 0;
|
|
161
|
+
} finally{
|
|
162
|
+
f = t = 0;
|
|
163
|
+
}
|
|
164
|
+
if (op[0] & 5) throw op[1];
|
|
165
|
+
return {
|
|
166
|
+
value: op[0] ? op[1] : void 0,
|
|
167
|
+
done: true
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export var webhooks = {
|
|
172
|
+
list: /**
|
|
173
|
+
* Test GET /webhooks - List all available webhook handlers
|
|
174
|
+
*/ function list(fetch) {
|
|
175
|
+
return _async_to_generator(function() {
|
|
176
|
+
var request, response, data, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, webhook, error;
|
|
177
|
+
return _ts_generator(this, function(_state) {
|
|
178
|
+
switch(_state.label){
|
|
179
|
+
case 0:
|
|
180
|
+
_state.trys.push([
|
|
181
|
+
0,
|
|
182
|
+
3,
|
|
183
|
+
,
|
|
184
|
+
4
|
|
185
|
+
]);
|
|
186
|
+
request = new Request('http://example.com/webhooks', {
|
|
187
|
+
method: 'GET'
|
|
188
|
+
});
|
|
189
|
+
return [
|
|
190
|
+
4,
|
|
191
|
+
fetch(request)
|
|
192
|
+
];
|
|
193
|
+
case 1:
|
|
194
|
+
response = _state.sent();
|
|
195
|
+
if (!response.ok) {
|
|
196
|
+
console.error("GET /webhooks returned ".concat(response.status));
|
|
197
|
+
return [
|
|
198
|
+
2,
|
|
199
|
+
false
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
return [
|
|
203
|
+
4,
|
|
204
|
+
response.json()
|
|
205
|
+
];
|
|
206
|
+
case 2:
|
|
207
|
+
data = _state.sent();
|
|
208
|
+
// Validate response structure
|
|
209
|
+
if (!Array.isArray(data.webhooks)) {
|
|
210
|
+
console.error("Expected webhooks to be an array, got ".concat(_type_of(data.webhooks)));
|
|
211
|
+
return [
|
|
212
|
+
2,
|
|
213
|
+
false
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
if (typeof data.count !== 'number') {
|
|
217
|
+
console.error("Expected count to be number, got ".concat(_type_of(data.count)));
|
|
218
|
+
return [
|
|
219
|
+
2,
|
|
220
|
+
false
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
224
|
+
try {
|
|
225
|
+
// Validate each webhook has required fields
|
|
226
|
+
for(_iterator = data.webhooks[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
227
|
+
webhook = _step.value;
|
|
228
|
+
if (!webhook.slug || typeof webhook.slug !== 'string') {
|
|
229
|
+
console.error("Webhook missing slug or has invalid type: ".concat(JSON.stringify(webhook)));
|
|
230
|
+
return [
|
|
231
|
+
2,
|
|
232
|
+
false
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
// Description is optional
|
|
236
|
+
if (webhook.description !== undefined && typeof webhook.description !== 'string') {
|
|
237
|
+
console.error("Webhook description has invalid type: ".concat(JSON.stringify(webhook)));
|
|
238
|
+
return [
|
|
239
|
+
2,
|
|
240
|
+
false
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_didIteratorError = true;
|
|
246
|
+
_iteratorError = err;
|
|
247
|
+
} finally{
|
|
248
|
+
try {
|
|
249
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
250
|
+
_iterator.return();
|
|
251
|
+
}
|
|
252
|
+
} finally{
|
|
253
|
+
if (_didIteratorError) {
|
|
254
|
+
throw _iteratorError;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return [
|
|
259
|
+
2,
|
|
260
|
+
true
|
|
261
|
+
];
|
|
262
|
+
case 3:
|
|
263
|
+
error = _state.sent();
|
|
264
|
+
console.error("Failed to test GET /webhooks:", error);
|
|
265
|
+
return [
|
|
266
|
+
2,
|
|
267
|
+
false
|
|
268
|
+
];
|
|
269
|
+
case 4:
|
|
270
|
+
return [
|
|
271
|
+
2
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
})();
|
|
276
|
+
},
|
|
277
|
+
receive: /**
|
|
278
|
+
* Test POST /webhooks/:slug - Receive an incoming webhook from an external service
|
|
279
|
+
*/ function receive(fetch, slug, payload) {
|
|
280
|
+
return _async_to_generator(function() {
|
|
281
|
+
var request, response, data, error;
|
|
282
|
+
return _ts_generator(this, function(_state) {
|
|
283
|
+
switch(_state.label){
|
|
284
|
+
case 0:
|
|
285
|
+
_state.trys.push([
|
|
286
|
+
0,
|
|
287
|
+
3,
|
|
288
|
+
,
|
|
289
|
+
4
|
|
290
|
+
]);
|
|
291
|
+
request = new Request("http://example.com/webhooks/".concat(encodeURIComponent(slug)), {
|
|
292
|
+
method: 'POST',
|
|
293
|
+
headers: {
|
|
294
|
+
'Content-Type': 'application/json'
|
|
295
|
+
},
|
|
296
|
+
body: JSON.stringify(payload)
|
|
297
|
+
});
|
|
298
|
+
return [
|
|
299
|
+
4,
|
|
300
|
+
fetch(request)
|
|
301
|
+
];
|
|
302
|
+
case 1:
|
|
303
|
+
response = _state.sent();
|
|
304
|
+
// Accept either 200 (OK) or 202 (Accepted)
|
|
305
|
+
if (response.status !== 200 && response.status !== 202) {
|
|
306
|
+
console.error("POST /webhooks/".concat(slug, " returned ").concat(response.status, ", expected 200 or 202"));
|
|
307
|
+
return [
|
|
308
|
+
2,
|
|
309
|
+
false
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
return [
|
|
313
|
+
4,
|
|
314
|
+
response.json()
|
|
315
|
+
];
|
|
316
|
+
case 2:
|
|
317
|
+
data = _state.sent();
|
|
318
|
+
// Validate response structure
|
|
319
|
+
if (typeof data.received !== 'boolean') {
|
|
320
|
+
console.error("Expected received to be boolean, got ".concat(_type_of(data.received)));
|
|
321
|
+
return [
|
|
322
|
+
2,
|
|
323
|
+
false
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
// Action field is optional
|
|
327
|
+
if (data.action !== undefined && ![
|
|
328
|
+
'resumed',
|
|
329
|
+
'started',
|
|
330
|
+
'queued',
|
|
331
|
+
'no-match'
|
|
332
|
+
].includes(data.action)) {
|
|
333
|
+
console.error("Invalid action value: ".concat(data.action));
|
|
334
|
+
return [
|
|
335
|
+
2,
|
|
336
|
+
false
|
|
337
|
+
];
|
|
338
|
+
}
|
|
339
|
+
return [
|
|
340
|
+
2,
|
|
341
|
+
true
|
|
342
|
+
];
|
|
343
|
+
case 3:
|
|
344
|
+
error = _state.sent();
|
|
345
|
+
console.error("Failed to test POST /webhooks/".concat(slug, ":"), error);
|
|
346
|
+
return [
|
|
347
|
+
2,
|
|
348
|
+
false
|
|
349
|
+
];
|
|
350
|
+
case 4:
|
|
351
|
+
return [
|
|
352
|
+
2
|
|
353
|
+
];
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
})();
|
|
357
|
+
},
|
|
358
|
+
notFound: /**
|
|
359
|
+
* Test POST /webhooks/:slug with non-existent webhook - Should return 404
|
|
360
|
+
*/ function notFound(fetch, slug) {
|
|
361
|
+
return _async_to_generator(function() {
|
|
362
|
+
var request, response, data, error;
|
|
363
|
+
return _ts_generator(this, function(_state) {
|
|
364
|
+
switch(_state.label){
|
|
365
|
+
case 0:
|
|
366
|
+
_state.trys.push([
|
|
367
|
+
0,
|
|
368
|
+
3,
|
|
369
|
+
,
|
|
370
|
+
4
|
|
371
|
+
]);
|
|
372
|
+
request = new Request("http://example.com/webhooks/".concat(encodeURIComponent(slug)), {
|
|
373
|
+
method: 'POST',
|
|
374
|
+
headers: {
|
|
375
|
+
'Content-Type': 'application/json'
|
|
376
|
+
},
|
|
377
|
+
body: JSON.stringify({})
|
|
378
|
+
});
|
|
379
|
+
return [
|
|
380
|
+
4,
|
|
381
|
+
fetch(request)
|
|
382
|
+
];
|
|
383
|
+
case 1:
|
|
384
|
+
response = _state.sent();
|
|
385
|
+
if (response.status !== 404) {
|
|
386
|
+
console.error("POST /webhooks/".concat(slug, " with non-existent webhook returned ").concat(response.status, ", expected 404"));
|
|
387
|
+
return [
|
|
388
|
+
2,
|
|
389
|
+
false
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
return [
|
|
393
|
+
4,
|
|
394
|
+
response.json()
|
|
395
|
+
];
|
|
396
|
+
case 2:
|
|
397
|
+
data = _state.sent();
|
|
398
|
+
if (!data.error || typeof data.error !== 'string') {
|
|
399
|
+
console.error("Expected error to be string, got ".concat(_type_of(data.error)));
|
|
400
|
+
return [
|
|
401
|
+
2,
|
|
402
|
+
false
|
|
403
|
+
];
|
|
404
|
+
}
|
|
405
|
+
// Verify error message mentions the webhook slug
|
|
406
|
+
if (!data.error.toLowerCase().includes('webhook')) {
|
|
407
|
+
console.error("Expected error message to mention webhook, got: ".concat(data.error));
|
|
408
|
+
return [
|
|
409
|
+
2,
|
|
410
|
+
false
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
return [
|
|
414
|
+
2,
|
|
415
|
+
true
|
|
416
|
+
];
|
|
417
|
+
case 3:
|
|
418
|
+
error = _state.sent();
|
|
419
|
+
console.error("Failed to test POST /webhooks/".concat(slug, " with non-existent webhook:"), error);
|
|
420
|
+
return [
|
|
421
|
+
2,
|
|
422
|
+
false
|
|
423
|
+
];
|
|
424
|
+
case 4:
|
|
425
|
+
return [
|
|
426
|
+
2
|
|
427
|
+
];
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
})();
|
|
431
|
+
},
|
|
432
|
+
uiForm: /**
|
|
433
|
+
* Test POST /webhooks/system/ui-form - Built-in webhook for UI form submissions.
|
|
434
|
+
* This is used by pages generated via .ui() steps to submit form data.
|
|
435
|
+
*
|
|
436
|
+
* The endpoint:
|
|
437
|
+
* - Accepts form data (application/x-www-form-urlencoded or multipart/form-data)
|
|
438
|
+
* - Requires an `identifier` query parameter to match the waiting brain
|
|
439
|
+
* - Returns { received: true, action: 'resumed' | 'not_found', ... }
|
|
440
|
+
*/ function uiForm(fetch, identifier, formData) {
|
|
441
|
+
return _async_to_generator(function() {
|
|
442
|
+
var params, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, key, value, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, v, request, response, data, error;
|
|
443
|
+
return _ts_generator(this, function(_state) {
|
|
444
|
+
switch(_state.label){
|
|
445
|
+
case 0:
|
|
446
|
+
_state.trys.push([
|
|
447
|
+
0,
|
|
448
|
+
3,
|
|
449
|
+
,
|
|
450
|
+
4
|
|
451
|
+
]);
|
|
452
|
+
// Build URLSearchParams from form data
|
|
453
|
+
params = new URLSearchParams();
|
|
454
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
455
|
+
try {
|
|
456
|
+
for(_iterator = Object.entries(formData)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
457
|
+
_step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
458
|
+
if (Array.isArray(value)) {
|
|
459
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
460
|
+
try {
|
|
461
|
+
for(_iterator1 = value[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
462
|
+
v = _step1.value;
|
|
463
|
+
params.append("".concat(key, "[]"), v);
|
|
464
|
+
}
|
|
465
|
+
} catch (err) {
|
|
466
|
+
_didIteratorError1 = true;
|
|
467
|
+
_iteratorError1 = err;
|
|
468
|
+
} finally{
|
|
469
|
+
try {
|
|
470
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
471
|
+
_iterator1.return();
|
|
472
|
+
}
|
|
473
|
+
} finally{
|
|
474
|
+
if (_didIteratorError1) {
|
|
475
|
+
throw _iteratorError1;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
} else {
|
|
480
|
+
params.append(key, value);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
} catch (err) {
|
|
484
|
+
_didIteratorError = true;
|
|
485
|
+
_iteratorError = err;
|
|
486
|
+
} finally{
|
|
487
|
+
try {
|
|
488
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
489
|
+
_iterator.return();
|
|
490
|
+
}
|
|
491
|
+
} finally{
|
|
492
|
+
if (_didIteratorError) {
|
|
493
|
+
throw _iteratorError;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
request = new Request("http://example.com/webhooks/system/ui-form?identifier=".concat(encodeURIComponent(identifier)), {
|
|
498
|
+
method: 'POST',
|
|
499
|
+
headers: {
|
|
500
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
501
|
+
},
|
|
502
|
+
body: params.toString()
|
|
503
|
+
});
|
|
504
|
+
return [
|
|
505
|
+
4,
|
|
506
|
+
fetch(request)
|
|
507
|
+
];
|
|
508
|
+
case 1:
|
|
509
|
+
response = _state.sent();
|
|
510
|
+
// Accept 200 (found and processed) or 404 (no brain waiting)
|
|
511
|
+
if (response.status !== 200 && response.status !== 404) {
|
|
512
|
+
console.error("POST /webhooks/system/ui-form returned ".concat(response.status, ", expected 200 or 404"));
|
|
513
|
+
return [
|
|
514
|
+
2,
|
|
515
|
+
false
|
|
516
|
+
];
|
|
517
|
+
}
|
|
518
|
+
return [
|
|
519
|
+
4,
|
|
520
|
+
response.json()
|
|
521
|
+
];
|
|
522
|
+
case 2:
|
|
523
|
+
data = _state.sent();
|
|
524
|
+
// Validate response structure
|
|
525
|
+
if (typeof data.received !== 'boolean') {
|
|
526
|
+
console.error("Expected received to be boolean, got ".concat(_type_of(data.received)));
|
|
527
|
+
return [
|
|
528
|
+
2,
|
|
529
|
+
false
|
|
530
|
+
];
|
|
531
|
+
}
|
|
532
|
+
if (!data.action || typeof data.action !== 'string') {
|
|
533
|
+
console.error("Expected action to be string, got ".concat(_type_of(data.action)));
|
|
534
|
+
return [
|
|
535
|
+
2,
|
|
536
|
+
false
|
|
537
|
+
];
|
|
538
|
+
}
|
|
539
|
+
// Action should be 'resumed' or 'not_found'
|
|
540
|
+
if (data.action !== 'resumed' && data.action !== 'not_found') {
|
|
541
|
+
console.error("Expected action to be 'resumed' or 'not_found', got '".concat(data.action, "'"));
|
|
542
|
+
return [
|
|
543
|
+
2,
|
|
544
|
+
false
|
|
545
|
+
];
|
|
546
|
+
}
|
|
547
|
+
return [
|
|
548
|
+
2,
|
|
549
|
+
true
|
|
550
|
+
];
|
|
551
|
+
case 3:
|
|
552
|
+
error = _state.sent();
|
|
553
|
+
console.error('Failed to test POST /webhooks/system/ui-form:', error);
|
|
554
|
+
return [
|
|
555
|
+
2,
|
|
556
|
+
false
|
|
557
|
+
];
|
|
558
|
+
case 4:
|
|
559
|
+
return [
|
|
560
|
+
2
|
|
561
|
+
];
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
})();
|
|
565
|
+
},
|
|
566
|
+
uiFormMissingIdentifier: /**
|
|
567
|
+
* Test POST /webhooks/system/ui-form with missing identifier - Should return 400
|
|
568
|
+
*/ function uiFormMissingIdentifier(fetch) {
|
|
569
|
+
return _async_to_generator(function() {
|
|
570
|
+
var request, response, data, error;
|
|
571
|
+
return _ts_generator(this, function(_state) {
|
|
572
|
+
switch(_state.label){
|
|
573
|
+
case 0:
|
|
574
|
+
_state.trys.push([
|
|
575
|
+
0,
|
|
576
|
+
3,
|
|
577
|
+
,
|
|
578
|
+
4
|
|
579
|
+
]);
|
|
580
|
+
request = new Request('http://example.com/webhooks/system/ui-form', {
|
|
581
|
+
method: 'POST',
|
|
582
|
+
headers: {
|
|
583
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
584
|
+
},
|
|
585
|
+
body: 'test=data'
|
|
586
|
+
});
|
|
587
|
+
return [
|
|
588
|
+
4,
|
|
589
|
+
fetch(request)
|
|
590
|
+
];
|
|
591
|
+
case 1:
|
|
592
|
+
response = _state.sent();
|
|
593
|
+
if (response.status !== 400) {
|
|
594
|
+
console.error("POST /webhooks/system/ui-form without identifier returned ".concat(response.status, ", expected 400"));
|
|
595
|
+
return [
|
|
596
|
+
2,
|
|
597
|
+
false
|
|
598
|
+
];
|
|
599
|
+
}
|
|
600
|
+
return [
|
|
601
|
+
4,
|
|
602
|
+
response.json()
|
|
603
|
+
];
|
|
604
|
+
case 2:
|
|
605
|
+
data = _state.sent();
|
|
606
|
+
if (!data.error || typeof data.error !== 'string') {
|
|
607
|
+
console.error("Expected error to be string, got ".concat(_type_of(data.error)));
|
|
608
|
+
return [
|
|
609
|
+
2,
|
|
610
|
+
false
|
|
611
|
+
];
|
|
612
|
+
}
|
|
613
|
+
if (!data.error.toLowerCase().includes('identifier')) {
|
|
614
|
+
console.error("Expected error message to mention identifier, got: ".concat(data.error));
|
|
615
|
+
return [
|
|
616
|
+
2,
|
|
617
|
+
false
|
|
618
|
+
];
|
|
619
|
+
}
|
|
620
|
+
return [
|
|
621
|
+
2,
|
|
622
|
+
true
|
|
623
|
+
];
|
|
624
|
+
case 3:
|
|
625
|
+
error = _state.sent();
|
|
626
|
+
console.error('Failed to test POST /webhooks/system/ui-form without identifier:', error);
|
|
627
|
+
return [
|
|
628
|
+
2,
|
|
629
|
+
false
|
|
630
|
+
];
|
|
631
|
+
case 4:
|
|
632
|
+
return [
|
|
633
|
+
2
|
|
634
|
+
];
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
})();
|
|
638
|
+
}
|
|
639
|
+
};
|
package/dist/src/index.js
CHANGED
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
*
|
|
14
14
|
* This interface provides lifecycle management for a server instance,
|
|
15
15
|
* abstracting away the underlying implementation details (process, worker, etc.)
|
|
16
|
-
*/ export { testStatus, resources, brains, schedules, secrets, webhooks, pages, bundle } from './api.js';
|
|
16
|
+
*/ export { testStatus, resources, brains, schedules, secrets, webhooks, signals, pages, bundle } from './api/index.js';
|
package/package.json
CHANGED
package/dist/api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO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