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

46 lines
1.7 KiB
Plaintext

import { GraphQLScalarType, Kind } from 'graphql';
import { createGraphQLError } from '../../error.js';
/* 1. [A-H] represents the Section Level of the Classification
2. \d{2} represents the class level
3. [A-Z] represents the subclass level
4. \/ separates the subclass from the subgroup
5. \d{2,4} represents the subgroup level
(Only four levels of subgroup, as far as I know)
*/
const IPC_PATENT_REGEX = /^[A-H]\d{2}[A-Z] \d{1,2}\/\d{2,4}$/;
const validate = (value, ast) => {
if (typeof value !== 'string') {
throw createGraphQLError(`Value is not string: ${value}`, { nodes: ast });
}
if (!IPC_PATENT_REGEX.test(value)) {
throw createGraphQLError(`Value is not a valid IPC Class Symbol: ${value}`, { nodes: ast });
}
return value;
};
const specifiedByURL = 'https://www.wipo.int/classifications/ipc/en/';
export const GraphQLIPCPatentConfig = {
name: 'IPCPatent',
description: `A field whose value is an IPC Class Symbol within the International Patent Classification System: https://www.wipo.int/classifications/ipc/en/`,
serialize: validate,
parseValue: validate,
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw createGraphQLError(`Can only validate strings as an IPC Class Symbol but got a: ${ast.kind}`, {
nodes: ast,
});
}
return validate(ast.value, ast);
},
specifiedByURL,
specifiedByUrl: specifiedByURL,
extensions: {
codegenScalarType: 'string',
jsonSchema: {
title: 'DeweyDecimal',
type: 'string',
pattern: IPC_PATENT_REGEX.source,
},
},
};
export const GraphQLIPCPatent = /*#__PURE__*/ new GraphQLScalarType(GraphQLIPCPatentConfig);