@syngrisi/syngrisi
Version:
Syngrisi - Visual Testing Tool
183 lines (178 loc) • 6.79 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/Baseline.schema.ts
var Baseline_schema_exports = {};
__export(Baseline_schema_exports, {
BaselineGetSchema: () => BaselineGetSchema,
BaselinePutSchema: () => BaselinePutSchema
});
module.exports = __toCommonJS(Baseline_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/Baseline.schema.ts
var BaselineGetSchema = import_zod3.z.object({
_id: commonValidations.id,
name: import_zod3.z.string().min(1).openapi({
description: "Name of the baseline",
example: "Green Button"
}),
app: commonValidations.id.openapi({
description: "Application identifier for the baseline",
example: "6651dd45b9c3e1e0b8c1ce26"
}),
branch: import_zod3.z.string().min(1).openapi({
description: "Branch name for the baseline",
example: "master"
}),
browserName: import_zod3.z.string().min(1).openapi({
description: "Browser name used for the baseline",
example: "chrome"
}),
viewport: import_zod3.z.string().min(1).openapi({
description: "Viewport size used for the baseline",
example: "1366x768"
}),
os: import_zod3.z.string().min(1).openapi({
description: "Operating system used for the baseline",
example: "macOS"
}),
createdDate: commonValidations.date.openapi({
description: "Creation date of the baseline",
example: "2024-05-26T10:49:19.896Z"
}),
lastMarkedDate: commonValidations.date.openapi({
description: "Last marked date of the baseline",
example: "2024-05-26T10:49:19.852Z"
}),
markedAs: import_zod3.z.string().min(1).openapi({
description: "Status marked for the baseline",
example: "accepted"
}),
markedById: commonValidations.id.openapi({
description: "Identifier of the user who marked the baseline",
example: "66519e582c2c701cc438ce59"
}),
markedByUsername: import_zod3.z.string().min(1).openapi({
description: "Username of the user who marked the baseline",
example: "Guest"
}),
snapshootId: commonValidations.id.openapi({
description: "Snapshot identifier for the baseline",
example: "6651ec20917e9ce26f7c0849"
}),
id: commonValidations.id
});
var BaselinePutSchema = import_zod3.z.object({
name: import_zod3.z.string().min(1).openapi({
description: "Name of the baseline",
example: "Green Button"
}).optional(),
branch: import_zod3.z.string().min(1).openapi({
description: "Branch name for the baseline",
example: "master"
}).optional(),
browserName: import_zod3.z.string().min(1).openapi({
description: "Browser name used for the baseline",
example: "chrome"
}).optional(),
viewport: import_zod3.z.string().min(1).openapi({
description: "Viewport size used for the baseline",
example: "1366x768"
}).optional(),
os: import_zod3.z.string().min(1).openapi({
description: "Operating system used for the baseline",
example: "macOS"
}).optional(),
createdDate: commonValidations.date.openapi({
description: "Creation date of the baseline",
example: "2024-05-26T10:49:19.896Z"
}).optional(),
lastMarkedDate: commonValidations.date.openapi({
description: "Last marked date of the baseline",
example: "2024-05-26T10:49:19.852Z"
}).optional(),
markedAs: import_zod3.z.string().min(1).openapi({
description: "Status marked for the baseline",
example: "accepted"
}).optional(),
markedById: commonValidations.id.openapi({
description: "Identifier of the user who marked the baseline",
example: "66519e582c2c701cc438ce59"
}).optional(),
markedByUsername: import_zod3.z.string().min(1).openapi({
description: "Username of the user who marked the baseline",
example: "Guest"
}).optional()
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BaselineGetSchema,
BaselinePutSchema
});
//# sourceMappingURL=Baseline.schema.js.map