|
1
|
"use strict"; |
|
2
|
var __defProp = Object.defineProperty; |
|
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
4
|
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
6
|
var __export = (target, all) => { |
|
7
|
for (var name in all) |
|
8
|
__defProp(target, name, { get: all[name], enumerable: true }); |
|
9
|
}; |
|
10
|
var __copyProps = (to, from, except, desc) => { |
|
11
|
if (from && typeof from === "object" || typeof from === "function") { |
|
12
|
for (let key of __getOwnPropNames(from)) |
|
13
|
if (!__hasOwnProp.call(to, key) && key !== except) |
|
14
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
15
|
} |
|
16
|
return to; |
|
17
|
}; |
|
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
19
|
var validators_exports = {}; |
|
20
|
__export(validators_exports, { |
|
21
|
validateTestAnnotation: () => validateTestAnnotation, |
|
22
|
validateTestDetails: () => validateTestDetails |
|
23
|
}); |
|
24
|
module.exports = __toCommonJS(validators_exports); |
|
25
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle"); |
|
26
|
const testAnnotationSchema = import_mcpBundle.z.object({ |
|
27
|
type: import_mcpBundle.z.string(), |
|
28
|
description: import_mcpBundle.z.string().optional() |
|
29
|
}); |
|
30
|
const testDetailsSchema = import_mcpBundle.z.object({ |
|
31
|
tag: import_mcpBundle.z.union([ |
|
32
|
import_mcpBundle.z.string().optional(), |
|
33
|
import_mcpBundle.z.array(import_mcpBundle.z.string()) |
|
34
|
]).transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : []).refine((val) => val.every((v) => v.startsWith("@")), { |
|
35
|
message: "Tag must start with '@'" |
|
36
|
}), |
|
37
|
annotation: import_mcpBundle.z.union([ |
|
38
|
testAnnotationSchema, |
|
39
|
import_mcpBundle.z.array(testAnnotationSchema).optional() |
|
40
|
]).transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : []) |
|
41
|
}); |
|
42
|
function validateTestAnnotation(annotation) { |
|
43
|
try { |
|
44
|
return testAnnotationSchema.parse(annotation); |
|
45
|
} catch (error) { |
|
46
|
throwZodError(error); |
|
47
|
} |
|
48
|
} |
|
49
|
function validateTestDetails(details, location) { |
|
50
|
try { |
|
51
|
const parsedDetails = testDetailsSchema.parse(details); |
|
52
|
return { |
|
53
|
annotations: parsedDetails.annotation.map((a) => ({ ...a, location })), |
|
54
|
tags: parsedDetails.tag, |
|
55
|
location |
|
56
|
}; |
|
57
|
} catch (error) { |
|
58
|
throwZodError(error); |
|
59
|
} |
|
60
|
} |
|
61
|
function throwZodError(error) { |
|
62
|
throw new Error(error.issues.map((i) => i.message).join("\n")); |
|
63
|
} |
|
64
|
// Annotate the CommonJS export names for ESM import in node: |
|
65
|
0 && (module.exports = { |
|
66
|
validateTestAnnotation, |
|
67
|
validateTestDetails |
|
68
|
}); |
|
69
|
|