Files
klz-cables.com/.pnpm-store/v10/files/5d/f9f78eb5f6e211bfdd8e216881f3029e0c22557c970c370b3962158fda172f21d0e2d4ae489bded9a38c7573a6b8d4b86398b49e0749a748426130c384324a
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

54 lines
1.8 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLISBN = void 0;
const graphql_1 = require("graphql");
const error_js_1 = require("../error.js");
const ISBN_REGEX_ARR = [
/^(?:ISBN(?:-10)?:? *)?((?=\d{1,5}([ -]?)\d{1,7}\2?\d{1,6}\2?\d)(?:\d\2*){9}[\dX])$/i,
/^(?:ISBN(?:-13)?:? *)?(97(?:8|9)([ -]?)(?=\d{1,5}\2?\d{1,7}\2?\d{1,6}\2?\d)(?:\d\2*){9}\d)$/i,
];
const validate = (value, ast) => {
if (typeof value !== 'string') {
throw (0, error_js_1.createGraphQLError)(`Value is not string: ${value}`, ast ? { nodes: ast } : undefined);
}
let valid = false;
for (const regex of ISBN_REGEX_ARR) {
if (regex.test(value)) {
valid = true;
break;
}
}
if (!valid) {
throw (0, error_js_1.createGraphQLError)(`Value is not a valid ISBN number: ${value}`, ast ? { nodes: ast } : undefined);
}
return value;
};
exports.GraphQLISBN = new graphql_1.GraphQLScalarType({
name: `ISBN`,
description: `A field whose value is a ISBN-10 or ISBN-13 number: https://en.wikipedia.org/wiki/International_Standard_Book_Number.`,
serialize(value) {
return validate(value);
},
parseValue(value) {
return validate(value);
},
parseLiteral(ast) {
if (ast.kind !== graphql_1.Kind.STRING) {
throw (0, error_js_1.createGraphQLError)(`Can only validate strings as ISBN numbers but got a: ${ast.kind}`, {
nodes: ast,
});
}
return validate(ast.value, ast);
},
extensions: {
codegenScalarType: 'string',
jsonSchema: {
title: 'ISBN',
oneOf: ISBN_REGEX_ARR.map(regex => ({
type: 'string',
pattern: regex.source,
})),
},
},
});