Files
klz-cables.com/.pnpm-store/v10/files/09/12ec1cbe68e255bd154b7177f7f58a732c02c710b69c09734953b4ce16b719f862b660f23c9389cd6f6a2c1da2506d0867608534eff7e4759ebdc6ec59dc9e
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

52 lines
1.7 KiB
Plaintext

import { GraphQLScalarType, Kind } from 'graphql';
import { createGraphQLError } from '../error.js';
const validateTimeZone = (str, ast) => {
if (!(Intl === null || Intl === void 0 ? void 0 : Intl.DateTimeFormat().resolvedOptions().timeZone)) {
throw createGraphQLError('Time zones are not available in this environment', ast
? {
nodes: ast,
}
: undefined);
}
try {
Intl.DateTimeFormat(undefined, { timeZone: str });
return str;
}
catch (ex) {
if (ex instanceof RangeError) {
throw createGraphQLError(`Value is not a valid IANA time zone: ${str}`, ast
? {
nodes: ast,
}
: undefined);
}
else {
throw createGraphQLError('Could not validate time zone.', ast
? {
nodes: ast,
}
: undefined);
}
}
};
export const GraphQLTimeZone = /*#__PURE__*/ new GraphQLScalarType({
name: 'TimeZone',
description: 'A field whose value exists in the standard IANA Time Zone Database: https://www.iana.org/time-zones',
serialize: validateTimeZone,
parseValue: validateTimeZone,
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw createGraphQLError(`Can only sanitize time zone strings, but got: ${ast.kind}`);
}
return validateTimeZone(ast.value);
},
extensions: {
codegenScalarType: 'string',
jsonSchema: {
title: 'TimeZone',
type: 'string',
pattern: '^(?:[A-Za-z0-9_]|(?:%[0-9A-Fa-f]{2}))+',
},
},
});