Files
klz-cables.com/.pnpm-store/v10/files/bd/df5af0237a3fe981ea9811294e433186246246334b7ce307c7b46f1d6f6fe31cde02f9b7ae0b1ada5393ff5d3d28585724a1fdd5f4fed84ae4fb1c6e9af829
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

62 lines
2.3 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLLocalDateTime = exports.LocalDateTimeConfig = void 0;
const graphql_1 = require("graphql");
const error_js_1 = require("../error.js");
const LOCAL_DATE_TIME_REGEX = /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$/;
function validateLocalDateTime(value, ast) {
if (typeof value !== 'string') {
throw (0, error_js_1.createGraphQLError)(`Value is not string: ${value}`, ast
? {
nodes: [ast],
}
: undefined);
}
if (!LOCAL_DATE_TIME_REGEX.test(value.toUpperCase())) {
throw (0, error_js_1.createGraphQLError)(`LocalDateTime cannot represent an invalid local date-time-string ${value}.`, ast
? {
nodes: [ast],
}
: undefined);
}
const valueAsDate = new Date(value);
const isValidDate = !isNaN(valueAsDate.getTime());
if (!isValidDate) {
throw (0, error_js_1.createGraphQLError)(`Value is not a valid LocalDateTime: ${value}`, ast
? {
nodes: [ast],
}
: undefined);
}
return value;
}
exports.LocalDateTimeConfig = {
name: 'LocalDateTime',
description: 'A local date-time string (i.e., with no associated timezone) in `YYYY-MM-DDTHH:mm:ss` format, e.g. `2020-01-01T00:00:00`.',
serialize(value) {
return validateLocalDateTime(value);
},
parseValue(value) {
return validateLocalDateTime(value);
},
parseLiteral(ast) {
if (ast.kind !== graphql_1.Kind.STRING) {
throw (0, error_js_1.createGraphQLError)(`Can only validate strings as local date-times but got a: ${ast.kind}`, {
nodes: [ast],
});
}
return validateLocalDateTime(ast.value, ast);
},
extensions: {
codegenScalarType:
// eslint-disable-next-line no-template-curly-in-string
'`${number}${number}${number}${number}-${number}${number}-${number}${number}T${number}${number}:${number}${number}:${number}${number}`',
jsonSchema: {
title: 'LocalDateTime',
type: 'string',
format: 'date-time',
},
},
};
exports.GraphQLLocalDateTime = new graphql_1.GraphQLScalarType(exports.LocalDateTimeConfig);