MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / validateUiPatchTask

Function validateUiPatchTask

js/botasaurus-server-js/src/validation.ts:360–388  ·  view source on GitHub ↗
(jsonData: any)

Source from the content-addressed store, hash-verified

358}
359
360export function validateUiPatchTask(jsonData: any): [string, number[]] {
361 ensureJsonBodyIsDict(jsonData);
362
363 let action = jsonData.action;
364 const taskIds = jsonData.task_ids;
365
366 if (isNullish(action)) {
367 throw new JsonHTTPResponseWithMessage("'action' must be provided");
368 }
369
370 if (typeof action !== 'string') {
371 throw new JsonHTTPResponseWithMessage("'action' must be a string");
372 }
373 action = action.toLowerCase();
374 if (!['abort', 'delete', 'retry'].includes(action)) {
375 throw new JsonHTTPResponseWithMessage('\'action\' must be either "abort", "delete", or "retry"');
376 }
377
378 if (isNullish(taskIds)) {
379 throw new JsonHTTPResponseWithMessage("'task_ids' must be provided. Task IDs are unique identifiers for scraping tasks.");
380 }
381
382 if (!isListOfValidIds(taskIds)) {
383 const taskIdsStr = isObject(taskIds) || Array.isArray(taskIds) ? JSON.stringify(taskIds) : taskIds;
384 throw new JsonHTTPResponseWithMessage(`'task_ids' with value '${taskIdsStr}' must be a list of integers representing scraping tasks.`);
385 }
386
387 return [action, taskIds];
388}
389
390// ─────────────────────────────────────────────────────────
391// K8s Validation Functions

Callers 1

executePatchTaskFunction · 0.90

Calls 4

isNullishFunction · 0.90
isObjectFunction · 0.90
ensureJsonBodyIsDictFunction · 0.85
isListOfValidIdsFunction · 0.85

Tested by

no test coverage detected