UNPKG

@syngrisi/syngrisi

Version:
155 lines (147 loc) 5.86 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/index.ts var schemas_exports = {}; __export(schemas_exports, { AppInfoRespSchema: () => AppInfoRespSchema, AppRespSchema: () => AppRespSchema, IdentJSONStringSchema: () => IdentJSONStringSchema, RequiredIdentOptionsSchema: () => RequiredIdentOptionsSchema, createCheckParamsSchema: () => createCheckParamsSchema, registry: () => registry }); module.exports = __toCommonJS(schemas_exports); // src/server/schemas/CreateCheck.shema.ts var import_zod = require("zod"); var createCheckParamsSchema = import_zod.z.object({ branch: import_zod.z.string().min(1), appName: import_zod.z.string().min(1), suitename: import_zod.z.string().min(1), testid: import_zod.z.string().regex(/^[a-f0-9]{24}$/), // Regex for 24 hex characters name: import_zod.z.string().min(1), viewport: import_zod.z.string().regex(/^\d+x\d+$/), // "WidthxHeight" format browserName: import_zod.z.string().min(1), browserVersion: import_zod.z.string().min(1), browserFullVersion: import_zod.z.string(), os: import_zod.z.string().min(1), hashcode: import_zod.z.string().length(128) // Assuming hashcode is always 128 chars length }); // src/server/schemas/GetBaseline.shema.ts var import_zod2 = require("zod"); var RequiredIdentOptionsSchema = import_zod2.z.object({ name: import_zod2.z.string().min(1), viewport: import_zod2.z.string().min(3), browserName: import_zod2.z.string().min(1), os: import_zod2.z.string().min(1), app: import_zod2.z.string().min(1), branch: import_zod2.z.string().min(1) }); var IdentJSONStringSchema = import_zod2.z.string().optional().refine((data) => { if (!data) return false; try { const parsed = JSON.parse(data); RequiredIdentOptionsSchema.parse(parsed); return true; } catch (e) { return false; } }, { message: "Invalid JSON string or does not match the required schema" }).openapi({ description: "baseline filter based on ident", example: '{"name": "Login page", "viewport": "1366x768", "browserName": "chrome", "os": "macOS", "app": "My App", "branch": "master"}' }); // src/server/schemas/App.schema.ts var import_zod_to_openapi2 = require("@asteasolutions/zod-to-openapi"); // src/server/schemas/utils/commonValidations.ts var import_zod4 = require("zod"); var import_zod_to_openapi = require("@asteasolutions/zod-to-openapi"); // src/server/schemas/common/Version.schema.ts var import_zod3 = require("zod"); var VersionSchema = import_zod3.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_zod4.z); var mongooseIdRegex = /^[0-9a-fA-F]{24}$/; var id = import_zod4.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_zod4.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_zod4.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_zod4.z.string().min(1).openapi({ example: "john.doe@example.com" }), // TODO: workaround TBD date: import_zod4.z.string().refine((val) => { const date = new Date(val); return !isNaN(date.getTime()); }, { message: "Invalid date format" }), paramsId: { params: import_zod4.z.object({ id }) }, paramsTestId: { params: import_zod4.z.object({ testid: id }) }, success: import_zod4.z.object({ message: import_zod4.z.literal("success") }) }; // src/server/schemas/App.schema.ts var import_zod5 = require("zod"); (0, import_zod_to_openapi2.extendZodWithOpenApi)(import_zod5.z); var registry = new import_zod_to_openapi2.OpenAPIRegistry(); var AppInfoRespSchema = import_zod5.z.object({ version: commonValidations.version }); var AppRespSchema = import_zod5.z.object({ _id: commonValidations.id, id: commonValidations.id, name: import_zod5.z.string().min(1, "AppRespSchema: the name is empty").openapi({ example: "Admin Panel" }) }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { AppInfoRespSchema, AppRespSchema, IdentJSONStringSchema, RequiredIdentOptionsSchema, createCheckParamsSchema, registry }); //# sourceMappingURL=index.js.map