Files
klz-cables.com/.pnpm-store/v10/files/00/a751323d31a2f28764be51742dcd28597c0473b116873eae71b103ef452b5ad37658b10c8dd3eeaf657ad2fcfd74ccc4a73cb4c873c268af69e7c3c23f68e4
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
9.4 KiB
Plaintext

{"version":3,"sources":["../../../src/queues/config/generateJobsJSONSchemas.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\n\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { JobsConfig } from './types/index.js'\n\nimport { fieldsToJSONSchema } from '../../utilities/configToJSONSchema.js'\nimport { flattenAllFields } from '../../utilities/flattenAllFields.js'\nexport function generateJobsJSONSchemas(\n config: SanitizedConfig,\n jobsConfig: JobsConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n): {\n definitions?: Map<string, JSONSchema4>\n properties?: { tasks: JSONSchema4 }\n} {\n const properties: { tasks: JSONSchema4; workflows: JSONSchema4 } = {\n tasks: {},\n workflows: {},\n }\n const definitions: Map<string, JSONSchema4> = new Map()\n\n if (jobsConfig?.tasks?.length) {\n for (const task of jobsConfig.tasks) {\n const fullTaskJsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n input: {},\n output: {},\n },\n required: [],\n }\n if (task?.inputSchema?.length) {\n const inputJsonSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: task.inputSchema }),\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n const fullInputJsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: inputJsonSchema.properties,\n required: inputJsonSchema.required,\n }\n\n fullTaskJsonSchema.properties!.input = fullInputJsonSchema\n ;(fullTaskJsonSchema.required as string[]).push('input')\n }\n if (task?.outputSchema?.length) {\n const outputJsonSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: task.outputSchema }),\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n const fullOutputJsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: outputJsonSchema.properties,\n required: outputJsonSchema.required,\n }\n\n fullTaskJsonSchema.properties!.output = fullOutputJsonSchema\n ;(fullTaskJsonSchema.required as string[]).push('output')\n }\n\n const normalizedTaskSlug = task.slug[0].toUpperCase() + task.slug.slice(1)\n\n definitions.set(task.interfaceName ?? `Task${normalizedTaskSlug}`, fullTaskJsonSchema)\n }\n // Now add properties.tasks definition that references the types in definitions keyed by task slug:\n properties.tasks = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...Object.fromEntries(\n (jobsConfig.tasks ?? []).map((task) => {\n const normalizedTaskSlug = task.slug[0].toUpperCase() + task.slug.slice(1)\n\n const toReturn: JSONSchema4 = {\n $ref: task.interfaceName\n ? `#/definitions/${task.interfaceName}`\n : `#/definitions/Task${normalizedTaskSlug}`,\n }\n\n return [task.slug, toReturn]\n }),\n ),\n inline: {\n type: 'object',\n additionalProperties: false,\n properties: {\n input: {},\n output: {},\n },\n required: ['input', 'output'],\n },\n },\n required: [...(jobsConfig.tasks ?? []).map((task) => task.slug), 'inline'],\n }\n }\n\n if (jobsConfig?.workflows?.length) {\n for (const workflow of jobsConfig.workflows) {\n const fullWorkflowJsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n input: {},\n },\n required: [],\n }\n\n if (workflow?.inputSchema?.length) {\n const inputJsonSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: workflow.inputSchema }),\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n const fullInputJsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: inputJsonSchema.properties,\n required: inputJsonSchema.required,\n }\n\n fullWorkflowJsonSchema.properties!.input = fullInputJsonSchema\n ;(fullWorkflowJsonSchema.required as string[]).push('input')\n }\n const normalizedWorkflowSlug = workflow.slug[0].toUpperCase() + workflow.slug.slice(1)\n\n definitions.set(\n workflow.interfaceName ?? `Workflow${normalizedWorkflowSlug}`,\n fullWorkflowJsonSchema,\n )\n\n properties.workflows = {\n type: 'object',\n additionalProperties: false,\n properties: Object.fromEntries(\n jobsConfig.workflows.map((workflow) => {\n const normalizedWorkflowSlug = workflow.slug[0].toUpperCase() + workflow.slug.slice(1)\n\n const toReturn: JSONSchema4 = {\n $ref: workflow.interfaceName\n ? `#/definitions/${workflow.interfaceName}`\n : `#/definitions/Workflow${normalizedWorkflowSlug}`,\n }\n\n return [workflow.slug, toReturn]\n }),\n ),\n required: jobsConfig.workflows.map((workflow) => workflow.slug),\n }\n }\n }\n\n return {\n definitions,\n properties,\n }\n}\n"],"names":["fieldsToJSONSchema","flattenAllFields","generateJobsJSONSchemas","config","jobsConfig","interfaceNameDefinitions","collectionIDFieldTypes","i18n","properties","tasks","workflows","definitions","Map","length","task","fullTaskJsonSchema","type","additionalProperties","input","output","required","inputSchema","inputJsonSchema","fields","fullInputJsonSchema","push","outputSchema","outputJsonSchema","fullOutputJsonSchema","normalizedTaskSlug","slug","toUpperCase","slice","set","interfaceName","Object","fromEntries","map","toReturn","$ref","inline","workflow","fullWorkflowJsonSchema","normalizedWorkflowSlug"],"mappings":"AAMA,SAASA,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,gBAAgB,QAAQ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