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

1 line
4.9 KiB
Plaintext

{"version":3,"sources":["../../src/bin/generateTypes.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport { initI18n } from '@payloadcms/translations'\nimport fs from 'fs/promises'\nimport { compile } from 'json-schema-to-typescript'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport { addSelectGenericsToGeneratedTypes } from '../utilities/addSelectGenericsToGeneretedTypes.js'\nimport { configToJSONSchema } from '../utilities/configToJSONSchema.js'\nimport { getLogger } from '../utilities/logger.js'\n\nexport async function generateTypes(\n config: SanitizedConfig,\n options?: { log: boolean },\n): Promise<void> {\n const logger = getLogger('payload', 'sync')\n const outputFile = process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile\n\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n logger.info('Compiling TS types for Collections and Globals...')\n }\n\n const languages = Object.keys(config.i18n.supportedLanguages) as AcceptedLanguages[]\n\n const language = languages.includes('en') ? 'en' : config.i18n.fallbackLanguage\n\n const i18n = await initI18n({ config: config.i18n, context: 'api', language })\n\n const jsonSchema = configToJSONSchema(config, config.db.defaultIDType, i18n)\n\n const declare = `declare module 'payload' {\\n export interface GeneratedTypes extends Config {}\\n}`\n const declareWithTSIgnoreError = `declare module 'payload' {\\n // @ts-ignore \\n export interface GeneratedTypes extends Config {}\\n}`\n\n let compiled = await compile(jsonSchema, 'Config', {\n bannerComment:\n '/* tslint:disable */\\n/* eslint-disable */\\n/**\\n* This file was automatically generated by Payload.\\n* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\\n* and re-run `payload generate:types` to regenerate this file.\\n*/',\n style: {\n singleQuote: true,\n },\n // Generates code for $defs that aren't referenced by the schema. Reason:\n // If a field defines an interfaceName, it should be included in the generated types\n // even if it's not used by another type. Reason: the user might want to use it in their own code.\n unreachableDefinitions: true,\n // Allow resolving external file references in $ref pointers\n cwd: process.cwd(),\n })\n\n compiled = addSelectGenericsToGeneratedTypes({ compiledGeneratedTypes: compiled })\n\n if (config.typescript.declare !== false) {\n if (config.typescript.declare?.ignoreTSError) {\n compiled += `\\n\\n${declareWithTSIgnoreError}`\n } else {\n compiled += `\\n\\n${declare}`\n }\n }\n\n // Diff the compiled types against the existing types file\n try {\n const existingTypes = await fs.readFile(outputFile, 'utf-8')\n\n if (compiled === existingTypes) {\n return\n }\n } catch (_) {\n // swallow err\n }\n\n await fs.writeFile(outputFile, compiled)\n if (shouldLog) {\n logger.info(`Types written to ${outputFile}`)\n }\n}\n"],"names":["initI18n","fs","compile","addSelectGenericsToGeneratedTypes","configToJSONSchema","getLogger","generateTypes","config","options","logger","outputFile","process","env","PAYLOAD_TS_OUTPUT_PATH","typescript","shouldLog","log","info","languages","Object","keys","i18n","supportedLanguages","language","includes","fallbackLanguage","context","jsonSchema","db","defaultIDType","declare","declareWithTSIgnoreError","compiled","bannerComment","style","singleQuote","unreachableDefinitions","cwd","compiledGeneratedTypes","ignoreTSError","existingTypes","readFile","_","writeFile"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,OAAOC,QAAQ,cAAa;AAC5B,SAASC,OAAO,QAAQ,4BAA2B;AAInD,SAASC,iCAAiC,QAAQ,oDAAmD;AACrG,SAASC,kBAAkB,QAAQ,qCAAoC;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