UNPKG

@syngrisi/syngrisi

Version:
455 lines (450 loc) 15.3 kB
"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/Client.schema.ts var Client_schema_exports = {}; __export(Client_schema_exports, { ClientCreateCheckResponseSchema: () => ClientCreateCheckResponseSchema, ClientCreateCheckSchema: () => ClientCreateCheckSchema, ClientEndSessionSchema: () => ClientEndSessionSchema, ClientGetBaselinesSchema: () => ClientGetBaselinesSchema, ClientGetIdentSchema: () => ClientGetIdentSchema, ClientGetSnapshotsSchema: () => ClientGetSnapshotsSchema, ClientStartSessionResponseSchema: () => ClientStartSessionResponseSchema, ClientStartSessionSchema: () => ClientStartSessionSchema }); module.exports = __toCommonJS(Client_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/Client.schema.ts var ClientStartSessionSchema = import_zod3.z.object({ name: import_zod3.z.string().min(1).openapi({ description: "Name of the session", example: "Login test" }), app: import_zod3.z.string().min(1).openapi({ description: "Application name", example: "My project" }), tags: import_zod3.z.string().openapi({ description: "Tags associated with the session", example: '["@smoke", "@PJ-231"]' }).optional(), branch: import_zod3.z.string().min(1).openapi({ description: "Branch name", example: "master" }), viewport: import_zod3.z.string().min(1).openapi({ description: "Viewport size", example: "1366x768" }), browser: import_zod3.z.string().min(1).openapi({ description: "Browser name", example: "chrome" }), browserVersion: import_zod3.z.string().min(1).openapi({ description: "Browser version", example: "125" }), browserFullVersion: import_zod3.z.string().min(1).openapi({ description: "Browser full version", example: "125.12.56.001" }).optional(), os: import_zod3.z.string().min(1).openapi({ description: "Operating system", example: "macOS" }), run: import_zod3.z.string().min(1).openapi({ description: "Run name", example: "Build #123" }), runident: import_zod3.z.string().min(1).openapi({ description: "Run identifier", example: "978ee42c-78f8-40f4-8954-51ebc08d1718" }), suite: import_zod3.z.string().min(1).openapi({ description: "Suite name", example: "Smoke tests" }) }); var ClientStartSessionResponseSchema = import_zod3.z.object({ name: import_zod3.z.string().openapi({ description: "Name of the session", example: "Login test" }), status: import_zod3.z.string().openapi({ description: "Status of the session", example: "Running" }), browserName: import_zod3.z.string().openapi({ description: "Browser name", example: "chrome" }), browserVersion: import_zod3.z.string().openapi({ description: "Browser version", 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 session", example: ["@smoke", "@PJ-231"] }), viewport: import_zod3.z.string().openapi({ description: "Viewport size", example: "1366x768" }), os: import_zod3.z.string().openapi({ description: "Operating system", example: "macOS" }), app: import_zod3.z.string().openapi({ description: "Application identifier", example: "666b3b82db17d34ecdbd06f6" }), blinking: import_zod3.z.number().openapi({ description: "Blinking count", example: 0 }), updatedDate: import_zod3.z.string().openapi({ description: "Last updated date", example: "2024-06-13T18:34:28.121Z" }), startDate: import_zod3.z.string().openapi({ description: "Start date of the session", example: "2024-06-13T18:34:28.121Z" }), checks: import_zod3.z.array(import_zod3.z.any()).openapi({ description: "Checks associated with the session", example: [] }), suite: import_zod3.z.string().openapi({ description: "Suite identifier", example: "666b3b828833d0cf24a670d7" }), run: import_zod3.z.string().openapi({ description: "Run identifier", example: "666b244a70a6fb0a4368b59e" }), _id: commonValidations.id.openapi({ description: "Identifier of the session", example: "666b3bb49e0c25666d76e0c4" }), id: commonValidations.id.openapi({ description: "Identifier of the session", example: "666b3bb49e0c25666d76e0c4" }) }); var ClientEndSessionSchema = import_zod3.z.object({ testid: commonValidations.id }); var ClientCreateCheckSchema = import_zod3.z.object({ testid: commonValidations.id.openapi({ description: "Test identifier", example: "666b2e1e93ca920ef5985b47" }), name: import_zod3.z.string().openapi({ description: "Name of the check", example: "Login page" }), appName: import_zod3.z.string().openapi({ description: "Application name", example: "My App" }), branch: import_zod3.z.string().openapi({ description: "Branch name", example: "master" }), suitename: import_zod3.z.string().openapi({ description: "Suite name", example: "Smoke tests" }), viewport: import_zod3.z.string().openapi({ description: "Viewport size", example: "1366x768" }), browserName: import_zod3.z.string().openapi({ description: "Browser name", example: "chrome" }), browserVersion: import_zod3.z.string().openapi({ description: "Browser version", example: "125" }), browserFullVersion: import_zod3.z.string().openapi({ description: "Full browser version", example: "125.0.6422.142" }), os: import_zod3.z.string().openapi({ description: "Operating system", example: "macOS" }), hashcode: import_zod3.z.string().openapi({ description: "Hash of the snapshot - In the first phase, only the hash is sent, in case the snapshot is already in the Syngrisi database", example: "ef6ff7c6e6fd536de877c02cf61381e5a1111a24c9d21c1c2a0c0c06fdd2f01271da8880da80a1caa7c123ce3256068c40055753d70bd1dbc558d088f90cd398" }) }); var SnapshotSchema = import_zod3.z.object({ name: import_zod3.z.string().openapi({ description: "Name of the snapshot", example: "Login page" }), filename: import_zod3.z.string().openapi({ description: "Filename of the snapshot", example: "666b12d859ac872b495af4b0.png" }), imghash: import_zod3.z.string().openapi({ description: "Image hash of the snapshot", example: "ef6ff7c6e6fd536de877c02cf61381e5a1111a24c9d21c1c2a0c0c06fdd2f01271da8880da80a1caa7c123ce3256068c40055753d70bd1dbc558d088f90cd398" }), _id: commonValidations.id.openapi({ description: "Identifier of the snapshot", example: "666b4ebc421977cbf466b478" }), createdDate: import_zod3.z.string().openapi({ description: "Creation date", example: "2024-06-13T19:55:40.068Z" }), id: commonValidations.id.openapi({ description: "Identifier of the snapshot", example: "666b4ebc421977cbf466b478" }) }); var ClientCreateCheckResponseSchema = import_zod3.z.object({ name: import_zod3.z.string().openapi({ description: "Name of the check", example: "Login page" }), test: commonValidations.id.openapi({ description: "Test identifier", example: "666b4e74421977cbf466b446" }), suite: commonValidations.id.openapi({ description: "Suite identifier", example: "666b3b828833d0cf24a670d7" }), app: commonValidations.id.openapi({ description: "Application identifier", example: "6651dd45b9c3e1e0b8c1ce26" }), branch: import_zod3.z.string().openapi({ description: "Branch name", example: "master" }), baselineId: commonValidations.id.openapi({ description: "Baseline identifier", example: "666b4ebc421977cbf466b478" }), actualSnapshotId: commonValidations.id.openapi({ description: "Actual snapshot identifier", example: "666b4ebc421977cbf466b478" }), updatedDate: import_zod3.z.string().openapi({ description: "Last updated date", example: "2024-06-13T19:55:40.061Z" }), status: import_zod3.z.array(import_zod3.z.string()).openapi({ description: "Status of the check", example: ["new"] }), browserName: import_zod3.z.string().openapi({ description: "Browser name", example: "chrome" }), browserVersion: import_zod3.z.string().openapi({ description: "Browser version", example: "125" }), browserFullVersion: import_zod3.z.string().openapi({ description: "Full browser version", example: "125.0.6422.142" }), viewport: import_zod3.z.string().openapi({ description: "Viewport size", example: "1366x768" }), os: import_zod3.z.string().openapi({ description: "Operating system", example: "macOS" }), result: import_zod3.z.string().openapi({ description: "Result of the check", example: "{}" }), 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: "Creator username", example: "Guest" }), failReasons: import_zod3.z.array(import_zod3.z.any()).openapi({ description: "Reasons for failure", example: [] }), _id: commonValidations.id.openapi({ description: "Identifier of the check", example: "666b4ebc421977cbf466b47c" }), createdDate: import_zod3.z.string().openapi({ description: "Creation date", example: "2024-06-13T19:55:40.082Z" }), currentSnapshot: SnapshotSchema, expectedSnapshot: SnapshotSchema, lastSuccess: commonValidations.id.openapi({ description: "Identifier of the last successful check", example: "666b4ebc421977cbf466b47c" }) }); var ClientGetIdentSchema = import_zod3.z.array(import_zod3.z.string()).openapi({ description: "Set of fields that identify checks and baselines", example: ["name", "viewport", "browserName", "os", "app", "branch"] }); var ClientGetBaselinesSchema = import_zod3.z.object({ baselines: import_zod3.z.array(import_zod3.z.object({ id: commonValidations.id, name: import_zod3.z.string().openapi({ description: "Name of the baseline", example: "A-A-A" }), app: commonValidations.id.openapi({ description: "Application identifier", example: "6651dd45b9c3e1e0b8c1ce26" }), branch: import_zod3.z.string().openapi({ description: "Branch name", example: "master" }), browserName: import_zod3.z.string().openapi({ description: "Browser name", example: "chrome" }), viewport: import_zod3.z.string().openapi({ description: "Viewport size", example: "1366x768" }), os: import_zod3.z.string().openapi({ description: "Operating system", example: "macOS" }), createdDate: import_zod3.z.string().openapi({ description: "Creation date", example: "2024-06-13T15:59:44.479Z" }), lastMarkedDate: import_zod3.z.string().openapi({ description: "Last marked date", example: "2024-06-13T15:59:44.381Z" }), markedAs: import_zod3.z.string().openapi({ description: "Marked status", example: "accepted" }), markedById: commonValidations.id.openapi({ description: "Identifier of the user who marked the baseline", example: "66519e1682764a892a1a0031" }), markedByUsername: import_zod3.z.string().openapi({ description: "Username of the user who marked the baseline", example: "Administrator" }), snapshootId: commonValidations.id.openapi({ description: "Snapshot identifier", example: "666b12d859ac872b495af4b0" }), _id: commonValidations.id.openapi({ description: "Identifier of the baseline", example: "666b177059ac872b495af63d" }) })) }); var ClientGetSnapshotsSchema = import_zod3.z.object({ snapshots: import_zod3.z.array(import_zod3.z.object({ id: commonValidations.id, name: import_zod3.z.string() })) }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ClientCreateCheckResponseSchema, ClientCreateCheckSchema, ClientEndSessionSchema, ClientGetBaselinesSchema, ClientGetIdentSchema, ClientGetSnapshotsSchema, ClientStartSessionResponseSchema, ClientStartSessionSchema }); //# sourceMappingURL=Client.schema.js.map