create-payload-app 4.0.0-internal.38b7f1d → 4.0.0-internal.5d5a2b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/ast/payload-config.js +1 -1
- package/dist/lib/ast/payload-config.js.map +1 -1
- package/dist/lib/ast/types.d.ts +1 -1
- package/dist/lib/ast/types.d.ts.map +1 -1
- package/dist/lib/ast/types.js.map +1 -1
- package/dist/lib/configure-plugin-project.d.ts.map +1 -1
- package/dist/lib/wrap-next-config.d.ts.map +1 -1
- package/dist/template/src/app/(frontend)/page.tsx +5 -2
- package/dist/template/src/app/(payload)/admin/importMap.js +17 -2
- package/dist/template/src/collections/Folders.ts +16 -0
- package/dist/template/src/collections/Media.ts +4 -0
- package/dist/template/src/collections/Tags.ts +16 -0
- package/dist/template/src/collections/Users.ts +1 -0
- package/dist/template/src/payload-types.ts +171 -11
- package/dist/template/src/payload.config.ts +10 -2
- package/dist/utils/casing.d.ts.map +1 -1
- package/dist/utils/log.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -107,7 +107,7 @@ export function detectPayloadConfigStructure(sourceFile) {
|
|
|
107
107
|
},
|
|
108
108
|
importSources: {
|
|
109
109
|
dbAdapter: dbAdapterImportInfo,
|
|
110
|
-
|
|
110
|
+
storage: storageAdapterImports.length > 0 ? storageAdapterImports : undefined
|
|
111
111
|
},
|
|
112
112
|
sourceFile,
|
|
113
113
|
structures: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ast/payload-config.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport { Project, QuoteKind, type SourceFile, SyntaxKind } from 'ts-morph'\n\nimport type {\n ConfigureOptions,\n DatabaseAdapter,\n DetectionResult,\n Modification,\n StorageAdapter,\n TransformationResult,\n WriteOptions,\n WriteResult,\n} from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport { DB_ADAPTER_CONFIG, STORAGE_ADAPTER_CONFIG } from './adapter-config.js'\nimport {\n addImportDeclaration,\n cleanupOrphanedImports,\n formatError,\n removeImportDeclaration,\n} from './utils.js'\n\nexport function detectPayloadConfigStructure(sourceFile: SourceFile): DetectionResult {\n debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`)\n\n // First find the actual name being used (might be aliased)\n const payloadImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n const buildConfigImportSpec = payloadImport\n ?.getNamedImports()\n .find((spec) => spec.getName() === 'buildConfig')\n\n const aliasNode = buildConfigImportSpec?.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n\n debug(`[AST] Looking for function call: ${buildConfigName}`)\n\n // Find buildConfig call expression (using actual name in code)\n const buildConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n if (!buildConfigCall) {\n debug(`[AST] ✗ ${buildConfigName} call not found`)\n return {\n error: formatError({\n actual: `No ${buildConfigName} call found in file`,\n context: 'buildConfig call',\n expected: `export default ${buildConfigName}({ ... })`,\n technicalDetails: `Could not find CallExpression with identifier \"${buildConfigName}\"`,\n }),\n success: false,\n }\n }\n\n debug(`[AST] ✓ ${buildConfigName} call found`)\n\n // Get import statements\n const importStatements = sourceFile.getImportDeclarations()\n debug(`[AST] Found ${importStatements.length} import statements`)\n\n // Find db property if it exists\n const configObject = buildConfigCall.getArguments()[0]\n let dbProperty\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n dbProperty = configObject\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getProperty('db')\n ?.asKind(SyntaxKind.PropertyAssignment)\n }\n\n debug(`[AST] db property: ${dbProperty ? '✓ found' : '✗ not found'}`)\n\n // Find plugins array if it exists\n let pluginsArray\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const pluginsProperty = objLiteral.getProperty('plugins')\n\n // Handle PropertyAssignment (e.g., plugins: [...])\n const propertyAssignment = pluginsProperty?.asKind(SyntaxKind.PropertyAssignment)\n if (propertyAssignment) {\n const initializer = propertyAssignment.getInitializer()\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n pluginsArray = initializer.asKind(SyntaxKind.ArrayLiteralExpression)\n }\n }\n // For ShorthandPropertyAssignment (e.g., plugins), we can't get the array directly\n // but we'll detect it in addStorageAdapter\n }\n\n debug(`[AST] plugins array: ${pluginsArray ? '✓ found' : '✗ not found'}`)\n\n // Find all buildConfig calls for edge case detection (using actual name)\n const allBuildConfigCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n const hasImportAlias = !!aliasNode\n\n // Check for other Payload imports\n const payloadImports = payloadImport?.getNamedImports() || []\n const hasOtherPayloadImports =\n payloadImports.length > 1 || payloadImports.some((imp) => imp.getName() !== 'buildConfig')\n\n // Track database adapter imports\n let dbAdapterImportInfo\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n dbAdapterImportInfo = {\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n }\n break\n }\n }\n\n // Track storage adapter imports\n const storageAdapterImports = []\n for (const [, config] of Object.entries(STORAGE_ADAPTER_CONFIG)) {\n if (!config.packageName || !config.adapterName) {\n continue\n }\n\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n storageAdapterImports.push({\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n })\n }\n }\n\n const needsManualIntervention = hasImportAlias || allBuildConfigCalls.length > 2\n\n debug(\n `[AST] Edge cases: alias=${hasImportAlias}, multiple=${allBuildConfigCalls.length > 1}, otherImports=${hasOtherPayloadImports}, manual=${needsManualIntervention}`,\n )\n\n return {\n edgeCases: {\n hasImportAlias,\n hasOtherPayloadImports,\n multipleBuildConfigCalls: allBuildConfigCalls.length > 1,\n needsManualIntervention,\n },\n importSources: {\n dbAdapter: dbAdapterImportInfo,\n storageAdapters: storageAdapterImports.length > 0 ? storageAdapterImports : undefined,\n },\n sourceFile,\n structures: {\n buildConfigCall,\n dbProperty,\n importStatements,\n pluginsArray,\n },\n success: true,\n }\n}\n\nexport function addDatabaseAdapter({\n adapter,\n envVarName = 'DATABASE_URL',\n sourceFile,\n}: {\n adapter: DatabaseAdapter\n envVarName?: string\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding database adapter: ${adapter} (envVar: ${envVarName})`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall, dbProperty } = detection.structures\n const config = DB_ADAPTER_CONFIG[adapter]\n\n // Remove old db adapter imports and track position for replacement\n const oldAdapters = Object.values(DB_ADAPTER_CONFIG)\n const removedAdapters: string[] = []\n let importInsertIndex: number | undefined\n oldAdapters.forEach((oldConfig) => {\n if (oldConfig.packageName !== config.packageName) {\n const { removedIndex } = removeImportDeclaration({\n moduleSpecifier: oldConfig.packageName,\n sourceFile,\n })\n if (removedIndex !== undefined) {\n // Use the first removed adapter's position\n if (importInsertIndex === undefined) {\n importInsertIndex = removedIndex\n }\n removedAdapters.push(oldConfig.packageName)\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${oldConfig.packageName}'`,\n })\n }\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter imports: ${removedAdapters.join(', ')}`)\n }\n\n // Add new import at the position of the removed one (or default position)\n addImportDeclaration({\n insertIndex: importInsertIndex,\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n\n // Add special imports for specific adapters\n if (adapter === 'd1-sqlite') {\n debug('[AST] Adding special import: ./db/migrations')\n addImportDeclaration({\n defaultImport: 'migrations',\n moduleSpecifier: './db/migrations',\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: migrations from './db/migrations'`,\n })\n }\n\n // Get config object\n const configObject = buildConfigCall.getArguments()[0]\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'database adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n const newDbCode = `db: ${config.configTemplate(envVarName)}`\n\n if (dbProperty) {\n // Replace existing db property\n // NOTE: Using replaceWithText() instead of remove() + insertPropertyAssignment()\n // to avoid double comma issues. When remove() is called, ts-morph doesn't always\n // clean up trailing commas correctly, which can result in syntax like \"},,\" when\n // inserting a new property at that position. replaceWithText() preserves the\n // surrounding punctuation correctly.\n debug(`[AST] Replacing existing db property`)\n dbProperty.replaceWithText(newDbCode)\n modifications.push({\n type: 'property-added',\n description: `Replaced db property with ${adapter} adapter`,\n })\n } else {\n // No existing db property - insert at end\n const insertIndex = objLiteral.getProperties().length\n debug(`[AST] Adding db property at index ${insertIndex}`)\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'db',\n initializer: config.configTemplate(envVarName),\n })\n modifications.push({\n type: 'property-added',\n description: `Added db property with ${adapter} adapter`,\n })\n }\n\n debug(`[AST] ✓ Database adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function addStorageAdapter({\n adapter,\n sourceFile,\n}: {\n adapter: StorageAdapter\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding storage adapter: ${adapter}`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const config = STORAGE_ADAPTER_CONFIG[adapter]\n\n // Local disk doesn't need any imports or plugins\n if (adapter === 'localDisk') {\n debug('[AST] localDisk storage adapter - no imports or plugins needed')\n return {\n modifications: [],\n modified: false,\n success: true,\n }\n }\n\n // Add import\n if (config.packageName && config.adapterName) {\n addImportDeclaration({\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'storage adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n // Find or create plugins array\n const pluginsPropertyRaw = objLiteral.getProperty('plugins')\n let pluginsProperty = pluginsPropertyRaw?.asKind(SyntaxKind.PropertyAssignment)\n\n // Check if it's a shorthand property (e.g., `plugins` referencing an imported variable)\n const shorthandProperty = pluginsPropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n if (shorthandProperty) {\n debug('[AST] Found shorthand plugins property, converting to long form with spread')\n // Get the identifier name (usually 'plugins')\n const identifierName = shorthandProperty.getName()\n\n // Find insert position before removing\n const allProperties = objLiteral.getProperties()\n const insertIndex = allProperties.indexOf(shorthandProperty)\n\n // Remove the shorthand property\n shorthandProperty.remove()\n\n // Create new property with spread operator: plugins: [...plugins, newAdapter]\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'plugins',\n initializer: `[...${identifierName}]`,\n })\n\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Converted shorthand plugins property to array with spread syntax`,\n })\n } else if (!pluginsProperty) {\n debug('[AST] Creating new plugins array')\n // Create plugins array\n objLiteral.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n })\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Created plugins array`,\n })\n } else {\n debug('[AST] Reusing existing plugins array')\n }\n\n if (!pluginsProperty) {\n return {\n error: formatError({\n actual: 'Failed to create or find plugins property',\n context: 'storage adapter configuration',\n expected: 'plugins array property',\n technicalDetails: 'Could not create or access plugins property',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const initializer = pluginsProperty.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return {\n error: formatError({\n actual: 'plugins property is not an array',\n context: 'storage adapter configuration',\n expected: 'plugins: [...]',\n technicalDetails: 'plugins property must be an array literal expression',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const pluginsArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n // Add storage adapter call\n const configText = config.configTemplate()\n if (configText) {\n pluginsArray.addElement(configText)\n modifications.push({\n type: 'property-added',\n description: `Added ${adapter} to plugins array`,\n })\n }\n\n debug(`[AST] ✓ Storage adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function removeSharp(sourceFile: SourceFile): TransformationResult {\n debug('[AST] Removing sharp import and property')\n\n const modifications: Modification[] = []\n\n // Remove import\n const { removedIndex } = removeImportDeclaration({ moduleSpecifier: 'sharp', sourceFile })\n if (removedIndex !== undefined) {\n modifications.push({\n type: 'import-removed',\n description: `Removed import from 'sharp'`,\n })\n }\n\n // Find and remove sharp property from buildConfig\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n // If detection failed but we removed import, still count as partial success\n if (modifications.length > 0) {\n return {\n modifications,\n modified: true,\n success: true,\n warnings: ['Could not detect config structure to remove sharp property'],\n }\n }\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n warnings: ['buildConfig has no object literal argument - could not remove sharp property'],\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const sharpProperty = objLiteral.getProperty('sharp')\n\n if (sharpProperty) {\n sharpProperty.remove()\n modifications.push({\n type: 'property-removed',\n description: `Removed sharp property from config`,\n })\n debug('[AST] ✓ Sharp property removed from config')\n } else {\n debug('[AST] Sharp property not found (already absent)')\n }\n\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n }\n}\n\n/** This shouldn't be necessary once the templates are updated. Can't hurt to keep in, though */\nexport function removeCommentMarkers(sourceFile: SourceFile): SourceFile {\n // Get the full text and replace comment markers\n let text = sourceFile.getFullText()\n\n // Remove inline comment markers from imports\n text = text.replace(/\\s*\\/\\/\\s*database-adapter-import\\s*$/gm, '')\n text = text.replace(/\\s*\\/\\/\\s*storage-adapter-import-placeholder\\s*$/gm, '')\n\n // Remove standalone comment lines\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-start\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-end\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*storage-adapter-placeholder\\s*\\n/gm, '')\n\n // Also remove the placeholder line from template (storage-adapter-import-placeholder at top)\n text = text.replace(/^\\/\\/\\s*storage-adapter-import-placeholder\\s*\\n/gm, '')\n\n // Replace the entire source file content\n sourceFile.replaceWithText(text)\n\n return sourceFile\n}\n\n/**\n * Validates payload config structure has required elements after transformation.\n * Checks that buildConfig() call exists and has a db property configured.\n */\nexport function validateStructure(sourceFile: SourceFile): WriteResult {\n debug('[AST] Validating payload config structure')\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success) {\n debug('[AST] ✗ Validation failed: detection unsuccessful')\n return {\n error: detection.error,\n success: false,\n }\n }\n\n const { structures } = detection\n\n // Validate db property exists\n if (!structures?.dbProperty) {\n debug('[AST] ✗ Validation failed: db property missing')\n return {\n error: formatError({\n actual: 'No db property found',\n context: 'database configuration',\n expected: 'buildConfig must have a db property',\n technicalDetails: 'PropertyAssignment with name \"db\" not found in buildConfig object',\n }),\n success: false,\n }\n }\n\n debug('[AST] ✓ Validation passed')\n return { success: true }\n}\n\nexport async function writeTransformedFile(\n sourceFile: SourceFile,\n options: WriteOptions = {},\n): Promise<WriteResult> {\n const { formatWithPrettier = true, validateStructure: shouldValidate = true } = options\n\n debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`)\n\n // Validate if requested\n if (shouldValidate) {\n const validation = validateStructure(sourceFile)\n if (!validation.success) {\n return validation\n }\n }\n\n // Get file path and save to disk\n const filePath = sourceFile.getFilePath()\n\n // Format with ts-morph before saving (fixes trailing commas, indentation)\n debug('[AST] Formatting with ts-morph')\n sourceFile.formatText()\n\n // Write file\n debug('[AST] Writing file to disk')\n await sourceFile.save()\n\n // Format with prettier if requested\n if (formatWithPrettier) {\n debug('[AST] Running prettier formatting via CLI')\n try {\n // Detect project directory (go up from file until we find package.json or use dirname)\n const projectDir = path.dirname(filePath)\n\n // Run prettier via CLI (avoids Jest/ESM compatibility issues)\n const prettierCmd = `npx prettier --write \"${filePath}\"`\n\n debug(`[AST] Executing: ${prettierCmd}`)\n execSync(prettierCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Prettier formatting successful')\n } catch (error) {\n // Log but don't fail if prettier fails (might not be installed)\n debug(\n `[AST] ⚠ Prettier formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping prettier formatting (disabled)')\n }\n\n debug('[AST] ✓ File written successfully')\n\n return { success: true }\n}\n\nexport async function configurePayloadConfig(\n filePath: string,\n options: ConfigureOptions = {},\n): Promise<WriteResult> {\n debug(`[AST] Configuring payload config: ${filePath}`)\n debug(\n `[AST] Options: db=${options.db?.type}, storage=${options.storage}, removeSharp=${options.removeSharp}`,\n )\n\n const allModifications: Modification[] = []\n const allWarnings: string[] = []\n\n try {\n // Create Project and load source file with proper settings\n const project = new Project({\n manipulationSettings: {\n quoteKind: QuoteKind.Single,\n },\n })\n let sourceFile = project.addSourceFileAtPath(filePath)\n\n // Run detection\n const detection = detectPayloadConfigStructure(sourceFile)\n if (!detection.success) {\n return detection\n }\n\n // Apply transformations based on options\n if (options.db) {\n debug('[AST] Applying database adapter transformation')\n const result = addDatabaseAdapter({\n adapter: options.db.type,\n envVarName: options.db.envVarName,\n sourceFile,\n })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.storage) {\n debug('[AST] Applying storage adapter transformation')\n const result = addStorageAdapter({ adapter: options.storage, sourceFile })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.removeSharp) {\n debug('[AST] Applying sharp removal')\n const result = removeSharp(sourceFile)\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n // Remove comment markers from template\n sourceFile = removeCommentMarkers(sourceFile)\n\n // Cleanup orphaned imports after all transformations\n debug('[AST] Cleaning up orphaned imports')\n\n // Cleanup database adapter imports if db was removed\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n if (options.db && config.packageName !== DB_ADAPTER_CONFIG[options.db.type].packageName) {\n const cleanup = cleanupOrphanedImports({\n importNames: [config.adapterName],\n moduleSpecifier: config.packageName,\n sourceFile,\n })\n if (cleanup.removed.length > 0) {\n cleanup.removed.forEach((importName) => {\n allModifications.push({\n type: 'import-removed',\n description: `Cleaned up unused import '${importName}' from '${config.packageName}'`,\n })\n })\n }\n }\n }\n\n // Log summary of modifications\n if (allModifications.length > 0) {\n debug(`[AST] Applied ${allModifications.length} modification(s):`)\n allModifications.forEach((mod) => {\n debug(`[AST] - ${mod.type}: ${mod.description}`)\n })\n }\n\n if (allWarnings.length > 0) {\n debug(`[AST] ${allWarnings.length} warning(s):`)\n allWarnings.forEach((warning) => {\n debug(`[AST] - ${warning}`)\n })\n }\n\n // Write transformed file with validation and formatting\n return await writeTransformedFile(sourceFile, {\n formatWithPrettier: options.formatWithPrettier,\n validateStructure: options.validateStructure ?? true,\n })\n } catch (error) {\n debug(`[AST] ✗ Configuration failed: ${error instanceof Error ? error.message : String(error)}`)\n return {\n error: formatError({\n actual: error instanceof Error ? error.message : String(error),\n context: 'configurePayloadConfig',\n expected: 'Successful file transformation',\n technicalDetails: error instanceof Error ? error.stack || error.message : String(error),\n }),\n success: false,\n }\n }\n}\n"],"names":["execSync","path","Project","QuoteKind","SyntaxKind","debug","DB_ADAPTER_CONFIG","STORAGE_ADAPTER_CONFIG","addImportDeclaration","cleanupOrphanedImports","formatError","removeImportDeclaration","detectPayloadConfigStructure","sourceFile","getFilePath","payloadImport","getImportDeclarations","find","imp","getModuleSpecifierValue","buildConfigImportSpec","getNamedImports","spec","getName","aliasNode","getAliasNode","buildConfigName","getText","buildConfigCall","getDescendantsOfKind","CallExpression","call","expression","getExpression","error","actual","context","expected","technicalDetails","success","importStatements","length","configObject","getArguments","dbProperty","getKind","ObjectLiteralExpression","asKindOrThrow","getProperty","asKind","PropertyAssignment","pluginsArray","objLiteral","pluginsProperty","propertyAssignment","initializer","getInitializer","ArrayLiteralExpression","allBuildConfigCalls","filter","hasImportAlias","payloadImports","hasOtherPayloadImports","some","dbAdapterImportInfo","config","Object","entries","importDecl","packageName","namedImports","hasOtherImports","importDeclaration","storageAdapterImports","adapterName","push","needsManualIntervention","edgeCases","multipleBuildConfigCalls","importSources","dbAdapter","storageAdapters","undefined","structures","addDatabaseAdapter","adapter","envVarName","modifications","detection","modified","oldAdapters","values","removedAdapters","importInsertIndex","forEach","oldConfig","removedIndex","moduleSpecifier","type","description","join","insertIndex","defaultImport","newDbCode","configTemplate","replaceWithText","getProperties","insertPropertyAssignment","name","addStorageAdapter","pluginsPropertyRaw","shorthandProperty","ShorthandPropertyAssignment","identifierName","allProperties","indexOf","remove","addPropertyAssignment","configText","addElement","removeSharp","warnings","sharpProperty","removeCommentMarkers","text","getFullText","replace","validateStructure","writeTransformedFile","options","formatWithPrettier","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","prettierCmd","cwd","stdio","Error","message","configurePayloadConfig","db","storage","allModifications","allWarnings","project","manipulationSettings","quoteKind","Single","addSourceFileAtPath","result","cleanup","importNames","removed","importName","mod","warning","String","stack"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,EAAEC,SAAS,EAAmBC,UAAU,QAAQ,WAAU;AAa1E,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAC/E,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,WAAW,EACXC,uBAAuB,QAClB,aAAY;AAEnB,OAAO,SAASC,6BAA6BC,UAAsB;IACjER,M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AAM+H,KAAK,IAAI/H,MAAM4G,OAAO,GAAGkB,OAAO9H;YACnF;YACAK,SAAS;QACX;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/ast/payload-config.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport { Project, QuoteKind, type SourceFile, SyntaxKind } from 'ts-morph'\n\nimport type {\n ConfigureOptions,\n DatabaseAdapter,\n DetectionResult,\n Modification,\n StorageAdapter,\n TransformationResult,\n WriteOptions,\n WriteResult,\n} from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport { DB_ADAPTER_CONFIG, STORAGE_ADAPTER_CONFIG } from './adapter-config.js'\nimport {\n addImportDeclaration,\n cleanupOrphanedImports,\n formatError,\n removeImportDeclaration,\n} from './utils.js'\n\nexport function detectPayloadConfigStructure(sourceFile: SourceFile): DetectionResult {\n debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`)\n\n // First find the actual name being used (might be aliased)\n const payloadImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n const buildConfigImportSpec = payloadImport\n ?.getNamedImports()\n .find((spec) => spec.getName() === 'buildConfig')\n\n const aliasNode = buildConfigImportSpec?.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n\n debug(`[AST] Looking for function call: ${buildConfigName}`)\n\n // Find buildConfig call expression (using actual name in code)\n const buildConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n if (!buildConfigCall) {\n debug(`[AST] ✗ ${buildConfigName} call not found`)\n return {\n error: formatError({\n actual: `No ${buildConfigName} call found in file`,\n context: 'buildConfig call',\n expected: `export default ${buildConfigName}({ ... })`,\n technicalDetails: `Could not find CallExpression with identifier \"${buildConfigName}\"`,\n }),\n success: false,\n }\n }\n\n debug(`[AST] ✓ ${buildConfigName} call found`)\n\n // Get import statements\n const importStatements = sourceFile.getImportDeclarations()\n debug(`[AST] Found ${importStatements.length} import statements`)\n\n // Find db property if it exists\n const configObject = buildConfigCall.getArguments()[0]\n let dbProperty\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n dbProperty = configObject\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getProperty('db')\n ?.asKind(SyntaxKind.PropertyAssignment)\n }\n\n debug(`[AST] db property: ${dbProperty ? '✓ found' : '✗ not found'}`)\n\n // Find plugins array if it exists\n let pluginsArray\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const pluginsProperty = objLiteral.getProperty('plugins')\n\n // Handle PropertyAssignment (e.g., plugins: [...])\n const propertyAssignment = pluginsProperty?.asKind(SyntaxKind.PropertyAssignment)\n if (propertyAssignment) {\n const initializer = propertyAssignment.getInitializer()\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n pluginsArray = initializer.asKind(SyntaxKind.ArrayLiteralExpression)\n }\n }\n // For ShorthandPropertyAssignment (e.g., plugins), we can't get the array directly\n // but we'll detect it in addStorageAdapter\n }\n\n debug(`[AST] plugins array: ${pluginsArray ? '✓ found' : '✗ not found'}`)\n\n // Find all buildConfig calls for edge case detection (using actual name)\n const allBuildConfigCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n const hasImportAlias = !!aliasNode\n\n // Check for other Payload imports\n const payloadImports = payloadImport?.getNamedImports() || []\n const hasOtherPayloadImports =\n payloadImports.length > 1 || payloadImports.some((imp) => imp.getName() !== 'buildConfig')\n\n // Track database adapter imports\n let dbAdapterImportInfo\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n dbAdapterImportInfo = {\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n }\n break\n }\n }\n\n // Track storage adapter imports\n const storageAdapterImports = []\n for (const [, config] of Object.entries(STORAGE_ADAPTER_CONFIG)) {\n if (!config.packageName || !config.adapterName) {\n continue\n }\n\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n storageAdapterImports.push({\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n })\n }\n }\n\n const needsManualIntervention = hasImportAlias || allBuildConfigCalls.length > 2\n\n debug(\n `[AST] Edge cases: alias=${hasImportAlias}, multiple=${allBuildConfigCalls.length > 1}, otherImports=${hasOtherPayloadImports}, manual=${needsManualIntervention}`,\n )\n\n return {\n edgeCases: {\n hasImportAlias,\n hasOtherPayloadImports,\n multipleBuildConfigCalls: allBuildConfigCalls.length > 1,\n needsManualIntervention,\n },\n importSources: {\n dbAdapter: dbAdapterImportInfo,\n storage: storageAdapterImports.length > 0 ? storageAdapterImports : undefined,\n },\n sourceFile,\n structures: {\n buildConfigCall,\n dbProperty,\n importStatements,\n pluginsArray,\n },\n success: true,\n }\n}\n\nexport function addDatabaseAdapter({\n adapter,\n envVarName = 'DATABASE_URL',\n sourceFile,\n}: {\n adapter: DatabaseAdapter\n envVarName?: string\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding database adapter: ${adapter} (envVar: ${envVarName})`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall, dbProperty } = detection.structures\n const config = DB_ADAPTER_CONFIG[adapter]\n\n // Remove old db adapter imports and track position for replacement\n const oldAdapters = Object.values(DB_ADAPTER_CONFIG)\n const removedAdapters: string[] = []\n let importInsertIndex: number | undefined\n oldAdapters.forEach((oldConfig) => {\n if (oldConfig.packageName !== config.packageName) {\n const { removedIndex } = removeImportDeclaration({\n moduleSpecifier: oldConfig.packageName,\n sourceFile,\n })\n if (removedIndex !== undefined) {\n // Use the first removed adapter's position\n if (importInsertIndex === undefined) {\n importInsertIndex = removedIndex\n }\n removedAdapters.push(oldConfig.packageName)\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${oldConfig.packageName}'`,\n })\n }\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter imports: ${removedAdapters.join(', ')}`)\n }\n\n // Add new import at the position of the removed one (or default position)\n addImportDeclaration({\n insertIndex: importInsertIndex,\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n\n // Add special imports for specific adapters\n if (adapter === 'd1-sqlite') {\n debug('[AST] Adding special import: ./db/migrations')\n addImportDeclaration({\n defaultImport: 'migrations',\n moduleSpecifier: './db/migrations',\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: migrations from './db/migrations'`,\n })\n }\n\n // Get config object\n const configObject = buildConfigCall.getArguments()[0]\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'database adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n const newDbCode = `db: ${config.configTemplate(envVarName)}`\n\n if (dbProperty) {\n // Replace existing db property\n // NOTE: Using replaceWithText() instead of remove() + insertPropertyAssignment()\n // to avoid double comma issues. When remove() is called, ts-morph doesn't always\n // clean up trailing commas correctly, which can result in syntax like \"},,\" when\n // inserting a new property at that position. replaceWithText() preserves the\n // surrounding punctuation correctly.\n debug(`[AST] Replacing existing db property`)\n dbProperty.replaceWithText(newDbCode)\n modifications.push({\n type: 'property-added',\n description: `Replaced db property with ${adapter} adapter`,\n })\n } else {\n // No existing db property - insert at end\n const insertIndex = objLiteral.getProperties().length\n debug(`[AST] Adding db property at index ${insertIndex}`)\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'db',\n initializer: config.configTemplate(envVarName),\n })\n modifications.push({\n type: 'property-added',\n description: `Added db property with ${adapter} adapter`,\n })\n }\n\n debug(`[AST] ✓ Database adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function addStorageAdapter({\n adapter,\n sourceFile,\n}: {\n adapter: StorageAdapter\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding storage adapter: ${adapter}`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const config = STORAGE_ADAPTER_CONFIG[adapter]\n\n // Local disk doesn't need any imports or plugins\n if (adapter === 'localDisk') {\n debug('[AST] localDisk storage adapter - no imports or plugins needed')\n return {\n modifications: [],\n modified: false,\n success: true,\n }\n }\n\n // Add import\n if (config.packageName && config.adapterName) {\n addImportDeclaration({\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'storage adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n // Find or create plugins array\n const pluginsPropertyRaw = objLiteral.getProperty('plugins')\n let pluginsProperty = pluginsPropertyRaw?.asKind(SyntaxKind.PropertyAssignment)\n\n // Check if it's a shorthand property (e.g., `plugins` referencing an imported variable)\n const shorthandProperty = pluginsPropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n if (shorthandProperty) {\n debug('[AST] Found shorthand plugins property, converting to long form with spread')\n // Get the identifier name (usually 'plugins')\n const identifierName = shorthandProperty.getName()\n\n // Find insert position before removing\n const allProperties = objLiteral.getProperties()\n const insertIndex = allProperties.indexOf(shorthandProperty)\n\n // Remove the shorthand property\n shorthandProperty.remove()\n\n // Create new property with spread operator: plugins: [...plugins, newAdapter]\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'plugins',\n initializer: `[...${identifierName}]`,\n })\n\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Converted shorthand plugins property to array with spread syntax`,\n })\n } else if (!pluginsProperty) {\n debug('[AST] Creating new plugins array')\n // Create plugins array\n objLiteral.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n })\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Created plugins array`,\n })\n } else {\n debug('[AST] Reusing existing plugins array')\n }\n\n if (!pluginsProperty) {\n return {\n error: formatError({\n actual: 'Failed to create or find plugins property',\n context: 'storage adapter configuration',\n expected: 'plugins array property',\n technicalDetails: 'Could not create or access plugins property',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const initializer = pluginsProperty.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return {\n error: formatError({\n actual: 'plugins property is not an array',\n context: 'storage adapter configuration',\n expected: 'plugins: [...]',\n technicalDetails: 'plugins property must be an array literal expression',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const pluginsArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n // Add storage adapter call\n const configText = config.configTemplate()\n if (configText) {\n pluginsArray.addElement(configText)\n modifications.push({\n type: 'property-added',\n description: `Added ${adapter} to plugins array`,\n })\n }\n\n debug(`[AST] ✓ Storage adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function removeSharp(sourceFile: SourceFile): TransformationResult {\n debug('[AST] Removing sharp import and property')\n\n const modifications: Modification[] = []\n\n // Remove import\n const { removedIndex } = removeImportDeclaration({ moduleSpecifier: 'sharp', sourceFile })\n if (removedIndex !== undefined) {\n modifications.push({\n type: 'import-removed',\n description: `Removed import from 'sharp'`,\n })\n }\n\n // Find and remove sharp property from buildConfig\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n // If detection failed but we removed import, still count as partial success\n if (modifications.length > 0) {\n return {\n modifications,\n modified: true,\n success: true,\n warnings: ['Could not detect config structure to remove sharp property'],\n }\n }\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n warnings: ['buildConfig has no object literal argument - could not remove sharp property'],\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const sharpProperty = objLiteral.getProperty('sharp')\n\n if (sharpProperty) {\n sharpProperty.remove()\n modifications.push({\n type: 'property-removed',\n description: `Removed sharp property from config`,\n })\n debug('[AST] ✓ Sharp property removed from config')\n } else {\n debug('[AST] Sharp property not found (already absent)')\n }\n\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n }\n}\n\n/** This shouldn't be necessary once the templates are updated. Can't hurt to keep in, though */\nexport function removeCommentMarkers(sourceFile: SourceFile): SourceFile {\n // Get the full text and replace comment markers\n let text = sourceFile.getFullText()\n\n // Remove inline comment markers from imports\n text = text.replace(/\\s*\\/\\/\\s*database-adapter-import\\s*$/gm, '')\n text = text.replace(/\\s*\\/\\/\\s*storage-adapter-import-placeholder\\s*$/gm, '')\n\n // Remove standalone comment lines\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-start\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-end\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*storage-adapter-placeholder\\s*\\n/gm, '')\n\n // Also remove the placeholder line from template (storage-adapter-import-placeholder at top)\n text = text.replace(/^\\/\\/\\s*storage-adapter-import-placeholder\\s*\\n/gm, '')\n\n // Replace the entire source file content\n sourceFile.replaceWithText(text)\n\n return sourceFile\n}\n\n/**\n * Validates payload config structure has required elements after transformation.\n * Checks that buildConfig() call exists and has a db property configured.\n */\nexport function validateStructure(sourceFile: SourceFile): WriteResult {\n debug('[AST] Validating payload config structure')\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success) {\n debug('[AST] ✗ Validation failed: detection unsuccessful')\n return {\n error: detection.error,\n success: false,\n }\n }\n\n const { structures } = detection\n\n // Validate db property exists\n if (!structures?.dbProperty) {\n debug('[AST] ✗ Validation failed: db property missing')\n return {\n error: formatError({\n actual: 'No db property found',\n context: 'database configuration',\n expected: 'buildConfig must have a db property',\n technicalDetails: 'PropertyAssignment with name \"db\" not found in buildConfig object',\n }),\n success: false,\n }\n }\n\n debug('[AST] ✓ Validation passed')\n return { success: true }\n}\n\nexport async function writeTransformedFile(\n sourceFile: SourceFile,\n options: WriteOptions = {},\n): Promise<WriteResult> {\n const { formatWithPrettier = true, validateStructure: shouldValidate = true } = options\n\n debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`)\n\n // Validate if requested\n if (shouldValidate) {\n const validation = validateStructure(sourceFile)\n if (!validation.success) {\n return validation\n }\n }\n\n // Get file path and save to disk\n const filePath = sourceFile.getFilePath()\n\n // Format with ts-morph before saving (fixes trailing commas, indentation)\n debug('[AST] Formatting with ts-morph')\n sourceFile.formatText()\n\n // Write file\n debug('[AST] Writing file to disk')\n await sourceFile.save()\n\n // Format with prettier if requested\n if (formatWithPrettier) {\n debug('[AST] Running prettier formatting via CLI')\n try {\n // Detect project directory (go up from file until we find package.json or use dirname)\n const projectDir = path.dirname(filePath)\n\n // Run prettier via CLI (avoids Jest/ESM compatibility issues)\n const prettierCmd = `npx prettier --write \"${filePath}\"`\n\n debug(`[AST] Executing: ${prettierCmd}`)\n execSync(prettierCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Prettier formatting successful')\n } catch (error) {\n // Log but don't fail if prettier fails (might not be installed)\n debug(\n `[AST] ⚠ Prettier formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping prettier formatting (disabled)')\n }\n\n debug('[AST] ✓ File written successfully')\n\n return { success: true }\n}\n\nexport async function configurePayloadConfig(\n filePath: string,\n options: ConfigureOptions = {},\n): Promise<WriteResult> {\n debug(`[AST] Configuring payload config: ${filePath}`)\n debug(\n `[AST] Options: db=${options.db?.type}, storage=${options.storage}, removeSharp=${options.removeSharp}`,\n )\n\n const allModifications: Modification[] = []\n const allWarnings: string[] = []\n\n try {\n // Create Project and load source file with proper settings\n const project = new Project({\n manipulationSettings: {\n quoteKind: QuoteKind.Single,\n },\n })\n let sourceFile = project.addSourceFileAtPath(filePath)\n\n // Run detection\n const detection = detectPayloadConfigStructure(sourceFile)\n if (!detection.success) {\n return detection\n }\n\n // Apply transformations based on options\n if (options.db) {\n debug('[AST] Applying database adapter transformation')\n const result = addDatabaseAdapter({\n adapter: options.db.type,\n envVarName: options.db.envVarName,\n sourceFile,\n })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.storage) {\n debug('[AST] Applying storage adapter transformation')\n const result = addStorageAdapter({ adapter: options.storage, sourceFile })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.removeSharp) {\n debug('[AST] Applying sharp removal')\n const result = removeSharp(sourceFile)\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n // Remove comment markers from template\n sourceFile = removeCommentMarkers(sourceFile)\n\n // Cleanup orphaned imports after all transformations\n debug('[AST] Cleaning up orphaned imports')\n\n // Cleanup database adapter imports if db was removed\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n if (options.db && config.packageName !== DB_ADAPTER_CONFIG[options.db.type].packageName) {\n const cleanup = cleanupOrphanedImports({\n importNames: [config.adapterName],\n moduleSpecifier: config.packageName,\n sourceFile,\n })\n if (cleanup.removed.length > 0) {\n cleanup.removed.forEach((importName) => {\n allModifications.push({\n type: 'import-removed',\n description: `Cleaned up unused import '${importName}' from '${config.packageName}'`,\n })\n })\n }\n }\n }\n\n // Log summary of modifications\n if (allModifications.length > 0) {\n debug(`[AST] Applied ${allModifications.length} modification(s):`)\n allModifications.forEach((mod) => {\n debug(`[AST] - ${mod.type}: ${mod.description}`)\n })\n }\n\n if (allWarnings.length > 0) {\n debug(`[AST] ${allWarnings.length} warning(s):`)\n allWarnings.forEach((warning) => {\n debug(`[AST] - ${warning}`)\n })\n }\n\n // Write transformed file with validation and formatting\n return await writeTransformedFile(sourceFile, {\n formatWithPrettier: options.formatWithPrettier,\n validateStructure: options.validateStructure ?? true,\n })\n } catch (error) {\n debug(`[AST] ✗ Configuration failed: ${error instanceof Error ? error.message : String(error)}`)\n return {\n error: formatError({\n actual: error instanceof Error ? error.message : String(error),\n context: 'configurePayloadConfig',\n expected: 'Successful file transformation',\n technicalDetails: error instanceof Error ? error.stack || error.message : String(error),\n }),\n success: false,\n }\n }\n}\n"],"names":["execSync","path","Project","QuoteKind","SyntaxKind","debug","DB_ADAPTER_CONFIG","STORAGE_ADAPTER_CONFIG","addImportDeclaration","cleanupOrphanedImports","formatError","removeImportDeclaration","detectPayloadConfigStructure","sourceFile","getFilePath","payloadImport","getImportDeclarations","find","imp","getModuleSpecifierValue","buildConfigImportSpec","getNamedImports","spec","getName","aliasNode","getAliasNode","buildConfigName","getText","buildConfigCall","getDescendantsOfKind","CallExpression","call","expression","getExpression","error","actual","context","expected","technicalDetails","success","importStatements","length","configObject","getArguments","dbProperty","getKind","ObjectLiteralExpression","asKindOrThrow","getProperty","asKind","PropertyAssignment","pluginsArray","objLiteral","pluginsProperty","propertyAssignment","initializer","getInitializer","ArrayLiteralExpression","allBuildConfigCalls","filter","hasImportAlias","payloadImports","hasOtherPayloadImports","some","dbAdapterImportInfo","config","Object","entries","importDecl","packageName","namedImports","hasOtherImports","importDeclaration","storageAdapterImports","adapterName","push","needsManualIntervention","edgeCases","multipleBuildConfigCalls","importSources","dbAdapter","storage","undefined","structures","addDatabaseAdapter","adapter","envVarName","modifications","detection","modified","oldAdapters","values","removedAdapters","importInsertIndex","forEach","oldConfig","removedIndex","moduleSpecifier","type","description","join","insertIndex","defaultImport","newDbCode","configTemplate","replaceWithText","getProperties","insertPropertyAssignment","name","addStorageAdapter","pluginsPropertyRaw","shorthandProperty","ShorthandPropertyAssignment","identifierName","allProperties","indexOf","remove","addPropertyAssignment","configText","addElement","removeSharp","warnings","sharpProperty","removeCommentMarkers","text","getFullText","replace","validateStructure","writeTransformedFile","options","formatWithPrettier","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","prettierCmd","cwd","stdio","Error","message","configurePayloadConfig","db","allModifications","allWarnings","project","manipulationSettings","quoteKind","Single","addSourceFileAtPath","result","cleanup","importNames","removed","importName","mod","warning","String","stack"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,EAAEC,SAAS,EAAmBC,UAAU,QAAQ,WAAU;AAa1E,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAC/E,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,WAAW,EACXC,uBAAuB,QAClB,aAAY;AAEnB,OAAO,SAASC,6BAA6BC,UAAsB;IACjER,MAAM,CAAC,4CAA4C,EAAEQ,WAAWC,WAAW,IAAI;IAE/E,2DAA2D;IAC3D,MAAMC,gBAAgBF,WACnBG,qBAAqB,GACrBC,IAAI,CAAC,CAACC,MAAQA,IAAIC,uBAAuB,OAAO;IAEnD,MAAMC,wBAAwBL,eAC1BM,kBACDJ,KAAK,CAACK,OAASA,KAAKC,OAAO,OAAO;IAErC,MAAMC,YAAYJ,uBAAuBK;IACzC,MAAMC,kBAAkBF,YAAYA,UAAUG,OAAO,KAAK;IAE1DtB,MAAM,CAAC,iCAAiC,EAAEqB,iBAAiB;IAE3D,+DAA+D;IAC/D,MAAME,kBAAkBf,WACrBgB,oBAAoB,CAACzB,WAAW0B,cAAc,EAC9Cb,IAAI,CAAC,CAACc;QACL,MAAMC,aAAaD,KAAKE,aAAa;QACrC,OAAOD,WAAWL,OAAO,OAAOD;IAClC;IAEF,IAAI,CAACE,iBAAiB;QACpBvB,MAAM,CAAC,QAAQ,EAAEqB,gBAAgB,eAAe,CAAC;QACjD,OAAO;YACLQ,OAAOxB,YAAY;gBACjByB,QAAQ,CAAC,GAAG,EAAET,gBAAgB,mBAAmB,CAAC;gBAClDU,SAAS;gBACTC,UAAU,CAAC,eAAe,EAAEX,gBAAgB,SAAS,CAAC;gBACtDY,kBAAkB,CAAC,+CAA+C,EAAEZ,gBAAgB,CAAC,CAAC;YACxF;YACAa,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AAY;YAC5CqH,oBAAoBD,QAAQC,kBAAkB;YAC9CH,mBAAmBE,QAAQF,iBAAiB,IAAI;QAClD;IACF,EAAE,OAAO7F,OAAO;QACd7B,MAAM,CAAC,8BAA8B,EAAE6B,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGiB,OAAO7H,QAAQ;QAC/F,OAAO;YACLA,OAAOxB,YAAY;gBACjByB,QAAQD,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGiB,OAAO7H;gBACxDE,SAAS;gBACTC,UAAU;gBACVC,kBAAkBJ,iBAAiB2G,QAAQ3G,MAAM8H,KAAK,IAAI9H,MAAM4G,OAAO,GAAGiB,OAAO7H;YACnF;YACAK,SAAS;QACX;IACF;AACF"}
|
package/dist/lib/ast/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,gBAAgB,EAAE,MAAM,CAAA;IACxB,WA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OAAO,CAAA;IACrB,cAAc,CAAC,EAAE;QACf,IAAI,EAAE,cAAc,CAAA;KACrB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE;QACH,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,eAAe,CAAA;KACtB,CAAA;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB,GAAG,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ast/types.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n CallExpression,\n ImportDeclaration,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\n// Result types for import utility functions\nexport type ImportRemovalResult = {\n removedIndex?: number\n sourceFile: SourceFile\n}\n\nexport type NamedImportRemovalResult = {\n fullyRemoved: boolean\n index?: number\n sourceFile: SourceFile\n}\n\nexport type ImportCleanupResult = {\n kept: string[]\n removed: string[]\n sourceFile: SourceFile\n}\n\nexport type DetectionError = {\n debugInfo?: Record<string, unknown>\n technicalDetails: string\n userMessage: string\n}\n\nexport type PayloadConfigStructures = {\n buildConfigCall: CallExpression\n dbProperty?: PropertyAssignment\n importStatements: ImportDeclaration[]\n pluginsArray?: ArrayLiteralExpression\n}\n\n/**\n * Detection result with edge case tracking and import source information\n */\nexport type DetectionResult = {\n /** Edge case flags */\n edgeCases?: {\n /** Import uses an alias (e.g., import { buildConfig as bc }) */\n hasImportAlias: boolean\n /** Other Payload imports exist (e.g., CollectionConfig) */\n hasOtherPayloadImports: boolean\n /** Multiple buildConfig calls found in file */\n multipleBuildConfigCalls: boolean\n /** Needs manual intervention (can't be automatically handled) */\n needsManualIntervention: boolean\n }\n error?: DetectionError\n /** Import source tracking */\n importSources?: {\n /** Current database adapter import info */\n dbAdapter?: {\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }\n /** Current storage adapter import info */\n
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/ast/types.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n CallExpression,\n ImportDeclaration,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\n// Result types for import utility functions\nexport type ImportRemovalResult = {\n removedIndex?: number\n sourceFile: SourceFile\n}\n\nexport type NamedImportRemovalResult = {\n fullyRemoved: boolean\n index?: number\n sourceFile: SourceFile\n}\n\nexport type ImportCleanupResult = {\n kept: string[]\n removed: string[]\n sourceFile: SourceFile\n}\n\nexport type DetectionError = {\n debugInfo?: Record<string, unknown>\n technicalDetails: string\n userMessage: string\n}\n\nexport type PayloadConfigStructures = {\n buildConfigCall: CallExpression\n dbProperty?: PropertyAssignment\n importStatements: ImportDeclaration[]\n pluginsArray?: ArrayLiteralExpression\n}\n\n/**\n * Detection result with edge case tracking and import source information\n */\nexport type DetectionResult = {\n /** Edge case flags */\n edgeCases?: {\n /** Import uses an alias (e.g., import { buildConfig as bc }) */\n hasImportAlias: boolean\n /** Other Payload imports exist (e.g., CollectionConfig) */\n hasOtherPayloadImports: boolean\n /** Multiple buildConfig calls found in file */\n multipleBuildConfigCalls: boolean\n /** Needs manual intervention (can't be automatically handled) */\n needsManualIntervention: boolean\n }\n error?: DetectionError\n /** Import source tracking */\n importSources?: {\n /** Current database adapter import info */\n dbAdapter?: {\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }\n /** Current storage adapter import info */\n storage?: Array<{\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }>\n }\n /** Source file reference */\n sourceFile?: SourceFile\n /** Detected structures */\n structures?: PayloadConfigStructures\n success: boolean\n}\n\n/**\n * Tracks a single modification made to the AST\n */\nexport type Modification = {\n description: string\n location?: {\n column: number\n line: number\n }\n type:\n | 'function-renamed'\n | 'import-added'\n | 'import-modified'\n | 'import-removed'\n | 'property-added'\n | 'property-removed'\n}\n\n/**\n * Result of transformation operations\n */\nexport type TransformationResult = {\n error?: DetectionError\n modifications: Modification[]\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Final result after writing to disk\n */\nexport type ModificationResult = {\n error?: DetectionError\n filePath: string\n formatted?: boolean\n modifications: Modification[]\n success: boolean\n warnings?: string[]\n}\nexport type DatabaseAdapter = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport const ALL_DATABASE_ADAPTERS = [\n 'mongodb',\n 'postgres',\n 'sqlite',\n 'vercel-postgres',\n 'd1-sqlite',\n] as const\n\nexport const ALL_STORAGE_ADAPTERS = [\n 'azureStorage',\n 'gcsStorage',\n 'localDisk',\n 'r2Storage',\n 's3Storage',\n 'uploadthingStorage',\n 'vercelBlobStorage',\n] as const\n\nexport type StorageAdapter = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type TransformOptions = {\n databaseAdapter?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storageAdapter?: {\n type: StorageAdapter\n }\n}\n\nexport type WriteOptions = {\n formatWithPrettier?: boolean\n validateStructure?: boolean\n}\n\nexport type WriteResult = {\n error?: DetectionError\n success: boolean\n}\n\nexport type ConfigureOptions = {\n db?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storage?: StorageAdapter\n} & WriteOptions\n"],"names":["ALL_DATABASE_ADAPTERS","ALL_STORAGE_ADAPTERS"],"mappings":"AAuHA,OAAO,MAAMA,wBAAwB;IACnC;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,uBAAuB;IAClC;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure-plugin-project.d.ts","sourceRoot":"","sources":["../../src/lib/configure-plugin-project.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"configure-plugin-project.d.ts","sourceRoot":"","sources":["../../src/lib/configure-plugin-project.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,kCAGpC;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB,SAmCA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM;IACzC,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,cAAc,CAAA;CAC/B,kBAaA,CAAA;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC;IAAE,qBAAqB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA4H9D"}
|
|
@@ -27,8 +27,11 @@ export default async function HomePage() {
|
|
|
27
27
|
width={65}
|
|
28
28
|
/>
|
|
29
29
|
</picture>
|
|
30
|
-
{!user
|
|
31
|
-
|
|
30
|
+
{!user || !('email' in user) ? (
|
|
31
|
+
<h1>Welcome to your new project.</h1>
|
|
32
|
+
) : (
|
|
33
|
+
<h1>Welcome back, {user.email}</h1>
|
|
34
|
+
)}
|
|
32
35
|
<div className="links">
|
|
33
36
|
<a
|
|
34
37
|
className="admin"
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NullField as NullField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
2
|
+
import { HierarchyField as HierarchyField_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
3
|
+
import { HierarchyButton as HierarchyButton_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
4
|
+
import { AccessField as AccessField_210e1789eef737e0b4d9f054258f19bb } from '@payloadcms/plugin-mcp/client'
|
|
5
|
+
import { FolderIcon as FolderIcon_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
6
|
+
import { HierarchySidebarTabServer as HierarchySidebarTabServer_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
7
|
+
import { TagIcon as TagIcon_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
8
|
+
import { CollectionCards as CollectionCards_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
2
9
|
|
|
3
10
|
/** @type import('payload').ImportMap */
|
|
4
11
|
export const importMap = {
|
|
5
|
-
'@payloadcms/
|
|
12
|
+
'@payloadcms/ui#NullField': NullField_3817bf644402e67bfe6577f60ef982de,
|
|
13
|
+
'@payloadcms/ui/rsc#HierarchyField': HierarchyField_ab83ff7e88da8d3530831f296ec4756a,
|
|
14
|
+
'@payloadcms/ui/rsc#HierarchyButton': HierarchyButton_ab83ff7e88da8d3530831f296ec4756a,
|
|
15
|
+
'@payloadcms/plugin-mcp/client#AccessField': AccessField_210e1789eef737e0b4d9f054258f19bb,
|
|
16
|
+
'@payloadcms/ui#FolderIcon': FolderIcon_3817bf644402e67bfe6577f60ef982de,
|
|
17
|
+
'@payloadcms/ui/rsc#HierarchySidebarTabServer':
|
|
18
|
+
HierarchySidebarTabServer_ab83ff7e88da8d3530831f296ec4756a,
|
|
19
|
+
'@payloadcms/ui#TagIcon': TagIcon_3817bf644402e67bfe6577f60ef982de,
|
|
20
|
+
'@payloadcms/ui/rsc#CollectionCards': CollectionCards_ab83ff7e88da8d3530831f296ec4756a,
|
|
6
21
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CollectionConfig } from 'payload'
|
|
2
|
+
|
|
3
|
+
export const Folders: CollectionConfig = {
|
|
4
|
+
slug: 'folders',
|
|
5
|
+
admin: {
|
|
6
|
+
useAsTitle: 'name',
|
|
7
|
+
},
|
|
8
|
+
folders: true,
|
|
9
|
+
fields: [
|
|
10
|
+
{
|
|
11
|
+
name: 'name',
|
|
12
|
+
type: 'text',
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CollectionConfig } from 'payload'
|
|
2
2
|
|
|
3
|
+
import { createFolderField, createTagField } from 'payload'
|
|
4
|
+
|
|
3
5
|
export const Media: CollectionConfig = {
|
|
4
6
|
slug: 'media',
|
|
5
7
|
access: {
|
|
@@ -11,6 +13,8 @@ export const Media: CollectionConfig = {
|
|
|
11
13
|
type: 'text',
|
|
12
14
|
required: true,
|
|
13
15
|
},
|
|
16
|
+
createFolderField({ relationTo: 'folders' }),
|
|
17
|
+
createTagField({ relationTo: 'tags' }),
|
|
14
18
|
],
|
|
15
19
|
upload: true,
|
|
16
20
|
}
|
|
@@ -64,11 +64,15 @@ export type SupportedTimezones =
|
|
|
64
64
|
export interface Config {
|
|
65
65
|
auth: {
|
|
66
66
|
users: UserAuthOperations;
|
|
67
|
+
'payload-mcp-api-keys': PayloadMcpApiKeyAuthOperations;
|
|
67
68
|
};
|
|
68
69
|
blocks: {};
|
|
69
70
|
collections: {
|
|
70
71
|
users: User;
|
|
71
72
|
media: Media;
|
|
73
|
+
folders: Folder;
|
|
74
|
+
tags: Tag;
|
|
75
|
+
'payload-mcp-api-keys': PayloadMcpApiKey;
|
|
72
76
|
'payload-kv': PayloadKv;
|
|
73
77
|
'payload-locked-documents': PayloadLockedDocument;
|
|
74
78
|
'payload-preferences': PayloadPreference;
|
|
@@ -78,6 +82,9 @@ export interface Config {
|
|
|
78
82
|
collectionsSelect: {
|
|
79
83
|
users: UsersSelect<false> | UsersSelect<true>;
|
|
80
84
|
media: MediaSelect<false> | MediaSelect<true>;
|
|
85
|
+
folders: FoldersSelect<false> | FoldersSelect<true>;
|
|
86
|
+
tags: TagsSelect<false> | TagsSelect<true>;
|
|
87
|
+
'payload-mcp-api-keys': PayloadMcpApiKeysSelect<false> | PayloadMcpApiKeysSelect<true>;
|
|
81
88
|
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
|
|
82
89
|
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
|
83
90
|
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
|
|
@@ -86,14 +93,14 @@ export interface Config {
|
|
|
86
93
|
db: {
|
|
87
94
|
defaultIDType: string;
|
|
88
95
|
};
|
|
89
|
-
fallbackLocale: null;
|
|
96
|
+
fallbackLocale: ('false' | 'none' | 'null') | false | null | 'en' | 'en'[];
|
|
90
97
|
globals: {};
|
|
91
98
|
globalsSelect: {};
|
|
92
|
-
locale:
|
|
99
|
+
locale: 'en';
|
|
93
100
|
widgets: {
|
|
94
101
|
collections: CollectionsWidget;
|
|
95
102
|
};
|
|
96
|
-
user: User;
|
|
103
|
+
user: User | PayloadMcpApiKey;
|
|
97
104
|
jobs: {
|
|
98
105
|
tasks: unknown;
|
|
99
106
|
workflows: unknown;
|
|
@@ -117,6 +124,24 @@ export interface UserAuthOperations {
|
|
|
117
124
|
password: string;
|
|
118
125
|
};
|
|
119
126
|
}
|
|
127
|
+
export interface PayloadMcpApiKeyAuthOperations {
|
|
128
|
+
forgotPassword: {
|
|
129
|
+
email: string;
|
|
130
|
+
password: string;
|
|
131
|
+
};
|
|
132
|
+
login: {
|
|
133
|
+
email: string;
|
|
134
|
+
password: string;
|
|
135
|
+
};
|
|
136
|
+
registerFirstUser: {
|
|
137
|
+
email: string;
|
|
138
|
+
password: string;
|
|
139
|
+
};
|
|
140
|
+
unlock: {
|
|
141
|
+
email: string;
|
|
142
|
+
password: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
120
145
|
/**
|
|
121
146
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
122
147
|
* via the `definition` "users".
|
|
@@ -149,6 +174,8 @@ export interface User {
|
|
|
149
174
|
export interface Media {
|
|
150
175
|
id: string;
|
|
151
176
|
alt: string;
|
|
177
|
+
_h_folders?: (string | null) | Folder;
|
|
178
|
+
_h_tags?: (string | Tag)[] | null;
|
|
152
179
|
updatedAt: string;
|
|
153
180
|
createdAt: string;
|
|
154
181
|
url?: string | null;
|
|
@@ -161,6 +188,75 @@ export interface Media {
|
|
|
161
188
|
focalX?: number | null;
|
|
162
189
|
focalY?: number | null;
|
|
163
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
193
|
+
* via the `definition` "folders".
|
|
194
|
+
*/
|
|
195
|
+
export interface Folder {
|
|
196
|
+
id: string;
|
|
197
|
+
_h_folders?: (string | null) | Folder;
|
|
198
|
+
name: string;
|
|
199
|
+
updatedAt: string;
|
|
200
|
+
createdAt: string;
|
|
201
|
+
_h_slugPath?: string | null;
|
|
202
|
+
_h_titlePath?: string | null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
206
|
+
* via the `definition` "tags".
|
|
207
|
+
*/
|
|
208
|
+
export interface Tag {
|
|
209
|
+
id: string;
|
|
210
|
+
_h_tags?: (string | null) | Tag;
|
|
211
|
+
name: string;
|
|
212
|
+
updatedAt: string;
|
|
213
|
+
createdAt: string;
|
|
214
|
+
_h_slugPath?: string | null;
|
|
215
|
+
_h_titlePath?: string | null;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* API keys control which collections, resources, tools, and prompts MCP clients can access
|
|
219
|
+
*
|
|
220
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
221
|
+
* via the `definition` "payload-mcp-api-keys".
|
|
222
|
+
*/
|
|
223
|
+
export interface PayloadMcpApiKey {
|
|
224
|
+
id: string;
|
|
225
|
+
/**
|
|
226
|
+
* The user that the API key is associated with.
|
|
227
|
+
*/
|
|
228
|
+
user: string | User;
|
|
229
|
+
/**
|
|
230
|
+
* A useful label for the API key.
|
|
231
|
+
*/
|
|
232
|
+
label?: string | null;
|
|
233
|
+
/**
|
|
234
|
+
* The purpose of the API key.
|
|
235
|
+
*/
|
|
236
|
+
description?: string | null;
|
|
237
|
+
/**
|
|
238
|
+
* When checked, this key bypasses Payload access control on every operation it performs. Leave unchecked unless you have a specific reason.
|
|
239
|
+
*/
|
|
240
|
+
overrideAccess?: boolean | null;
|
|
241
|
+
/**
|
|
242
|
+
* Access for this API key — uncheck to revoke individual tools.
|
|
243
|
+
*/
|
|
244
|
+
access?:
|
|
245
|
+
| {
|
|
246
|
+
[k: string]: unknown;
|
|
247
|
+
}
|
|
248
|
+
| unknown[]
|
|
249
|
+
| string
|
|
250
|
+
| number
|
|
251
|
+
| boolean
|
|
252
|
+
| null;
|
|
253
|
+
updatedAt: string;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
enableAPIKey?: boolean | null;
|
|
256
|
+
apiKey?: string | null;
|
|
257
|
+
apiKeyIndex?: string | null;
|
|
258
|
+
collection: 'payload-mcp-api-keys';
|
|
259
|
+
}
|
|
164
260
|
/**
|
|
165
261
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
166
262
|
* via the `definition` "payload-kv".
|
|
@@ -192,12 +288,29 @@ export interface PayloadLockedDocument {
|
|
|
192
288
|
| ({
|
|
193
289
|
relationTo: 'media';
|
|
194
290
|
value: string | Media;
|
|
291
|
+
} | null)
|
|
292
|
+
| ({
|
|
293
|
+
relationTo: 'folders';
|
|
294
|
+
value: string | Folder;
|
|
295
|
+
} | null)
|
|
296
|
+
| ({
|
|
297
|
+
relationTo: 'tags';
|
|
298
|
+
value: string | Tag;
|
|
299
|
+
} | null)
|
|
300
|
+
| ({
|
|
301
|
+
relationTo: 'payload-mcp-api-keys';
|
|
302
|
+
value: string | PayloadMcpApiKey;
|
|
195
303
|
} | null);
|
|
196
304
|
globalSlug?: string | null;
|
|
197
|
-
user:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
305
|
+
user:
|
|
306
|
+
| {
|
|
307
|
+
relationTo: 'users';
|
|
308
|
+
value: string | User;
|
|
309
|
+
}
|
|
310
|
+
| {
|
|
311
|
+
relationTo: 'payload-mcp-api-keys';
|
|
312
|
+
value: string | PayloadMcpApiKey;
|
|
313
|
+
};
|
|
201
314
|
updatedAt: string;
|
|
202
315
|
createdAt: string;
|
|
203
316
|
}
|
|
@@ -207,10 +320,15 @@ export interface PayloadLockedDocument {
|
|
|
207
320
|
*/
|
|
208
321
|
export interface PayloadPreference {
|
|
209
322
|
id: string;
|
|
210
|
-
user:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
323
|
+
user:
|
|
324
|
+
| {
|
|
325
|
+
relationTo: 'users';
|
|
326
|
+
value: string | User;
|
|
327
|
+
}
|
|
328
|
+
| {
|
|
329
|
+
relationTo: 'payload-mcp-api-keys';
|
|
330
|
+
value: string | PayloadMcpApiKey;
|
|
331
|
+
};
|
|
214
332
|
key?: string | null;
|
|
215
333
|
value?:
|
|
216
334
|
| {
|
|
@@ -263,6 +381,8 @@ export interface UsersSelect<T extends boolean = true> {
|
|
|
263
381
|
*/
|
|
264
382
|
export interface MediaSelect<T extends boolean = true> {
|
|
265
383
|
alt?: T;
|
|
384
|
+
_h_folders?: T;
|
|
385
|
+
_h_tags?: T;
|
|
266
386
|
updatedAt?: T;
|
|
267
387
|
createdAt?: T;
|
|
268
388
|
url?: T;
|
|
@@ -275,6 +395,46 @@ export interface MediaSelect<T extends boolean = true> {
|
|
|
275
395
|
focalX?: T;
|
|
276
396
|
focalY?: T;
|
|
277
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
400
|
+
* via the `definition` "folders_select".
|
|
401
|
+
*/
|
|
402
|
+
export interface FoldersSelect<T extends boolean = true> {
|
|
403
|
+
_h_folders?: T;
|
|
404
|
+
name?: T;
|
|
405
|
+
updatedAt?: T;
|
|
406
|
+
createdAt?: T;
|
|
407
|
+
_h_slugPath?: T;
|
|
408
|
+
_h_titlePath?: T;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
412
|
+
* via the `definition` "tags_select".
|
|
413
|
+
*/
|
|
414
|
+
export interface TagsSelect<T extends boolean = true> {
|
|
415
|
+
_h_tags?: T;
|
|
416
|
+
name?: T;
|
|
417
|
+
updatedAt?: T;
|
|
418
|
+
createdAt?: T;
|
|
419
|
+
_h_slugPath?: T;
|
|
420
|
+
_h_titlePath?: T;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
424
|
+
* via the `definition` "payload-mcp-api-keys_select".
|
|
425
|
+
*/
|
|
426
|
+
export interface PayloadMcpApiKeysSelect<T extends boolean = true> {
|
|
427
|
+
user?: T;
|
|
428
|
+
label?: T;
|
|
429
|
+
description?: T;
|
|
430
|
+
overrideAccess?: T;
|
|
431
|
+
access?: T;
|
|
432
|
+
updatedAt?: T;
|
|
433
|
+
createdAt?: T;
|
|
434
|
+
enableAPIKey?: T;
|
|
435
|
+
apiKey?: T;
|
|
436
|
+
apiKeyIndex?: T;
|
|
437
|
+
}
|
|
278
438
|
/**
|
|
279
439
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
280
440
|
* via the `definition` "payload-kv_select".
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
2
|
+
import { mcpPlugin } from '@payloadcms/plugin-mcp'
|
|
2
3
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
3
4
|
import path from 'path'
|
|
4
5
|
import { buildConfig } from 'payload'
|
|
@@ -7,6 +8,8 @@ import sharp from 'sharp'
|
|
|
7
8
|
|
|
8
9
|
import { Users } from './collections/Users'
|
|
9
10
|
import { Media } from './collections/Media'
|
|
11
|
+
import { Folders } from './collections/Folders'
|
|
12
|
+
import { Tags } from './collections/Tags'
|
|
10
13
|
|
|
11
14
|
const filename = fileURLToPath(import.meta.url)
|
|
12
15
|
const dirname = path.dirname(filename)
|
|
@@ -18,7 +21,7 @@ export default buildConfig({
|
|
|
18
21
|
baseDir: path.resolve(dirname),
|
|
19
22
|
},
|
|
20
23
|
},
|
|
21
|
-
collections: [Users, Media],
|
|
24
|
+
collections: [Users, Media, Folders, Tags],
|
|
22
25
|
editor: lexicalEditor(),
|
|
23
26
|
secret: process.env.PAYLOAD_SECRET || '',
|
|
24
27
|
typescript: {
|
|
@@ -28,5 +31,10 @@ export default buildConfig({
|
|
|
28
31
|
url: process.env.DATABASE_URL || '',
|
|
29
32
|
}),
|
|
30
33
|
sharp,
|
|
31
|
-
|
|
34
|
+
localization: {
|
|
35
|
+
locales: ['en'],
|
|
36
|
+
fallback: true,
|
|
37
|
+
defaultLocale: 'en',
|
|
38
|
+
},
|
|
39
|
+
plugins: [mcpPlugin({})],
|
|
32
40
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/utils/casing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/utils/casing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,WAMtC,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKlD"}
|
package/dist/utils/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,KAAG,IAEzC,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,KAAG,IAEtC,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,KAAG,IAEvC,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,KAAG,IAIvC,CAAA;AAED,eAAO,MAAM,GAAG,GAAI,SAAS,MAAM,KAAG,IAErC,CAAA"}
|