@syngrisi/syngrisi
Version:
Syngrisi - Visual Testing Tool
204 lines (199 loc) • 6.75 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/server/schemas/Test.schema.ts
var Test_schema_exports = {};
__export(Test_schema_exports, {
TestAcceptSchema: () => TestAcceptSchema,
TestDistinctRequestFieldParamsSchema: () => TestDistinctRequestFieldParamsSchema,
TestDistinctSchema: () => TestDistinctSchema,
TestGetSchema: () => TestGetSchema
});
module.exports = __toCommonJS(Test_schema_exports);
var import_zod3 = require("zod");
// src/server/schemas/utils/commonValidations.ts
var import_zod2 = require("zod");
var import_zod_to_openapi = require("@asteasolutions/zod-to-openapi");
// src/server/schemas/common/Version.schema.ts
var import_zod = require("zod");
var VersionSchema = import_zod.z.string().regex(/^\d+\.\d+\.\d+$/, 'Version must be in the format "x.y.z"').transform((value) => {
const parts = value.split(".");
return {
major: parseInt(parts[0]),
minor: parseInt(parts[1]),
patch: parseInt(parts[2])
};
});
var Version_schema_default = VersionSchema;
// src/server/schemas/utils/commonValidations.ts
(0, import_zod_to_openapi.extendZodWithOpenApi)(import_zod2.z);
var mongooseIdRegex = /^[0-9a-fA-F]{24}$/;
var id = import_zod2.z.string().regex(mongooseIdRegex, {
message: "Invalid Mongoose ObjectId format: /^[0-9a-fA-F]{24}$/"
}).openapi({
description: "baseline ID",
example: "6bbF35cAB3C59dA969edAe79"
});
var commonValidations = {
id,
version: Version_schema_default.openapi({ example: "1.1.2" }),
positiveNumberString: import_zod2.z.string().refine((value) => {
const num = Number(value);
return Number.isInteger(num) && num >= 0;
}, {
message: "String must be a positive number or 0"
}),
password: import_zod2.z.string().min(6).regex(/(?=.*[0-9])/, "Password must include a number").regex(/(?=.*[a-z])/, "Password must include a lowercase letter").regex(/(?=.*[A-Z])/, "Password must include an uppercase letter").refine((value) => {
return /(?=.*[!@#$%^&*(),.?":{}|<>-])/.test(value);
}, {
message: "Password must include a special symbol"
}).openapi({ example: "Aa1!IJASSNOJ" }),
username: import_zod2.z.string().min(1).openapi({ example: "john.doe@example.com" }),
// TODO: workaround TBD
date: import_zod2.z.string().refine((val) => {
const date = new Date(val);
return !isNaN(date.getTime());
}, {
message: "Invalid date format"
}),
paramsId: { params: import_zod2.z.object({ id }) },
paramsTestId: { params: import_zod2.z.object({ testid: id }) },
success: import_zod2.z.object({
message: import_zod2.z.literal("success")
})
};
// src/server/schemas/Test.schema.ts
var TestGetSchema = import_zod3.z.object({
_id: commonValidations.id,
name: import_zod3.z.string().min(1).openapi({
description: "Name of the test",
example: "Get IP"
}),
status: import_zod3.z.string().openapi({
description: "Status of the test",
example: "Failed"
}),
browserName: import_zod3.z.string().openapi({
description: "Name of the browser",
example: "chrome"
}),
browserVersion: import_zod3.z.string().openapi({
description: "Version of the browser",
example: "125"
}),
branch: import_zod3.z.string().openapi({
description: "Branch name",
example: "master"
}),
tags: import_zod3.z.array(import_zod3.z.string()).openapi({
description: "Tags associated with the test",
example: ["@smoke", "@regression"]
}),
viewport: import_zod3.z.string().openapi({
description: "Viewport size",
example: "1366x768"
}),
os: import_zod3.z.string().openapi({
description: "Operating system",
example: "macOS"
}),
app: commonValidations.id.openapi({
description: "Application identifier",
example: "6651dd45b9c3e1e0b8c1ce26"
}),
blinking: import_zod3.z.number().openapi({
description: "Blinking count",
example: 0
}),
updatedDate: commonValidations.date.openapi({
description: "Last update date of the test",
example: "2024-06-13T19:55:40.108Z"
}),
startDate: commonValidations.date.openapi({
description: "Start date of the test",
example: "2024-06-13T19:54:28.409Z"
}),
checks: import_zod3.z.array(commonValidations.id).openapi({
description: "List of checks associated with the test",
example: ["666b4e7e421977cbf466b458", "666b4ebc421977cbf466b47c"]
}),
suite: commonValidations.id.openapi({
description: "Suite identifier",
example: "666b3b828833d0cf24a670d7"
}),
run: commonValidations.id.openapi({
description: "Run identifier",
example: "666b4e74421977cbf466b443"
}),
creatorId: commonValidations.id.openapi({
description: "Creator identifier",
example: "66519e582c2c701cc438ce59"
}),
creatorUsername: import_zod3.z.string().openapi({
description: "Username of the creator",
example: "Guest"
}),
markedAs: import_zod3.z.string().openapi({
description: "Marked as status",
example: "Unaccepted"
}),
calculatedViewport: import_zod3.z.string().openapi({
description: "Calculated viewport size",
example: "1366x768"
}),
id: commonValidations.id.openapi({
description: "ID of the test",
example: "666b4e74421977cbf466b446"
})
});
var UpdateTestSchema = TestGetSchema.omit({ id: true, _id: true }).partial();
var TestAcceptSchema = import_zod3.z.object({
id: commonValidations.id
});
var validIds = [
"suite",
"run",
"markedAs",
"creatorId",
"creatorUsername",
"name",
"status",
"browserName",
"browserVersion",
"branch",
"tags",
"viewport",
"os",
"app",
"startDate"
];
var TestDistinctRequestFieldParamsSchema = import_zod3.z.object({
field: import_zod3.z.enum(validIds).openapi({
description: "Parameter identifier",
example: "suite"
})
});
var TestDistinctSchema = TestGetSchema;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestAcceptSchema,
TestDistinctRequestFieldParamsSchema,
TestDistinctSchema,
TestGetSchema
});
//# sourceMappingURL=Test.schema.js.map