@payloadcms/figma 0.0.1-alpha.17 → 0.0.1-alpha.19

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/init.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport fs from 'fs/promises'\nimport path from 'path'\nimport pc from 'picocolors'\n\nimport type { Tenant } from '../types/config.js'\n\nimport { ControlPlaneError, getTenantDetails } from '../api/control-plane.js'\nimport { FigmaApiError } from '../api/figma-api.js'\nimport { getValidAccessToken } from '../auth/oauth-flow.js'\nimport { getValidProjectToken, ProjectTokenError } from '../auth/project-token.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { isDebug } from '../utils/is-debug.js'\nimport * as log from '../utils/log.js'\nimport {\n displayManualInstructions,\n ensurePayloadFigmaConfig,\n} from '../utils/payload-config-modifier.js'\nimport {\n detectPayloadProject,\n hasRequiredDependencies,\n initializeGitRepo,\n installDependencies,\n isInProjectDirectory,\n scaffoldProject,\n validatePayloadVersion,\n} from '../utils/project.js'\nimport { loginCommand } from './login.js'\n\n/**\n * Options for init command\n */\nexport interface InitCommandOptions {\n /** Enable debug mode */\n debug?: boolean\n /** Force reconfiguration of existing project */\n force?: boolean\n /** Tenant ID to use (optional - will prompt if not provided) */\n id?: string\n /** Project name (for scaffolding) */\n name?: string\n /** Disable Content System (defaults to enabled) */\n noContentSystem?: boolean\n /** AWS region for deployment (defaults to us-east-1) */\n region?: string\n /** Skip authentication check (for testing/development) */\n skipAuth?: boolean\n /** Skip prompts and use defaults where possible */\n yes?: boolean\n}\n\n/**\n * Generate and store project token for a tenant\n * Non-blocking - will show warning but not exit on failure\n * Only shows feedback if DEBUG mode is enabled, otherwise runs silently\n *\n * @param tokenStore - Token store instance\n * @param tenantId - Tenant ID to generate token for\n * @param spinner - Clack spinner instance for status updates (only used in debug mode)\n */\nasync function generateProjectTokenWithFeedback(\n tokenStore: TokenStore,\n tenantId: string,\n spinner: ReturnType<typeof p.spinner>,\n): Promise<void> {\n if (isDebug()) {\n spinner.start('Generating project token...')\n }\n\n try {\n const projectToken = await getValidProjectToken(tokenStore, tenantId)\n if (isDebug()) {\n if (projectToken) {\n spinner.stop(pc.green('✓ Project token generated'))\n } else {\n spinner.stop(pc.yellow('⚠ Project token not generated (authentication required)'))\n }\n }\n } catch (error) {\n if (isDebug()) {\n spinner.stop(pc.yellow('⚠ Project token generation failed'))\n }\n // Always show failures, even without debug\n if (error instanceof ProjectTokenError || error instanceof FigmaApiError) {\n log.warning(error.message)\n p.note(\n 'Project token is used for authenticating to the Content API.\\nYou can continue without it, but may need to regenerate later.',\n 'Note',\n )\n } else {\n log.warning(\n `Unable to retrieve project token: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n // Don't exit - token generation failure shouldn't block initialization\n }\n}\n\n/**\n * Handle the `init` command\n *\n * Sets up a project by:\n * 1. Checking authentication\n * 2. Detecting/scaffolding Payload project\n * 3. Fetching tenant details\n * 4. Storing configuration\n *\n * @param options - Command options\n */\nexport async function initCommand(options: InitCommandOptions): Promise<void> {\n // Check authentication\n const tokenStore = new TokenStore()\n const s = p.spinner()\n\n let accessToken: string\n\n if (options.skipAuth) {\n // Skip authentication for testing/development\n p.log.warn(pc.yellow('Skipping authentication (--skip-auth mode)'))\n accessToken = 'mock-access-token'\n } else {\n try {\n // Check for valid cached tokens first (no API call needed)\n if (tokenStore.hasValidTokens()) {\n // Use cached token silently - no spinner needed\n accessToken = tokenStore.getAccessToken()!\n } else {\n // Need to refresh or authenticate - show spinner for API call\n s.start('Checking authentication...')\n const token = await getValidAccessToken(tokenStore)\n if (!token) {\n s.stop(pc.yellow('⚠ Not authenticated'))\n p.log.info('Authentication required to continue')\n\n // Prompt user to authenticate now\n const shouldAuth = await p.confirm({\n initialValue: true,\n message: 'Would you like to authenticate now?',\n })\n\n if (p.isCancel(shouldAuth) || !shouldAuth) {\n p.cancel('Operation cancelled')\n process.exit(0)\n }\n\n // Run login command\n await loginCommand()\n\n // Get token after auth\n const newToken = await getValidAccessToken(tokenStore)\n if (!newToken) {\n p.log.error('Authentication failed')\n process.exit(1)\n }\n accessToken = newToken\n p.log.success(pc.green('✓ Authenticated'))\n } else {\n accessToken = token\n s.stop(pc.green('✓ Authenticated'))\n }\n }\n } catch (error) {\n s.stop(pc.red('✗ Authentication failed'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n p.note('Run `figma auth` to authenticate', 'Tip')\n process.exit(1)\n }\n }\n\n // Note: We no longer check for figma.config.json here\n // Instead, the AST detection will check if figma object already exists in payload.config.ts\n // and skip modification if it does (unless --force is used)\n\n // Step 3: Get CMS ID with retry loop\n log.debug('Configuring Project...')\n\n let tenantId = options.id\n let selectedTenant: Tenant | undefined\n\n while (!selectedTenant) {\n // Prompt for ID if not provided\n if (!tenantId) {\n const input = await p.text({\n message: 'Enter your CMS ID:',\n placeholder: 'tenant_abc123',\n validate: (value) => {\n if (!value || typeof value !== 'string') {\n return 'CMS ID is required'\n }\n return undefined\n },\n })\n\n if (p.isCancel(input)) {\n p.cancel('Operation cancelled')\n process.exit(0)\n }\n\n tenantId = input\n }\n\n // Try to fetch tenant details\n try {\n log.debug('Using mock Control Plane API (no real network calls)')\n selectedTenant = await getTenantDetails(accessToken, tenantId)\n log.debug(`Using: ${selectedTenant.domain}`)\n } catch (error) {\n p.log.error(pc.red('✗ Failed to fetch CMS details'))\n\n // Check if permission error (403)\n if (error instanceof ControlPlaneError && error.statusCode === 403) {\n p.log.error('You do not have permission to access the provided CMS ID. Please try again.')\n } else if (error instanceof ControlPlaneError && error.statusCode === 404) {\n p.log.error('Tenant ID not found. Verify the ID is correct.')\n } else {\n p.log.error(error instanceof Error ? error.message : 'Unknown error')\n }\n\n // Clear tenantId to prompt again\n tenantId = undefined\n\n // Ask if they want to retry\n const shouldRetry = await p.confirm({\n initialValue: true,\n message: 'Would you like to try a different CMS ID?',\n })\n\n if (p.isCancel(shouldRetry) || !shouldRetry) {\n p.cancel('Operation cancelled')\n process.exit(1)\n }\n }\n }\n\n // Step 4: Detect or scaffold Payload project\n const isInProject = await isInProjectDirectory()\n\n if (isInProject) {\n // ===== EXISTING PROJECT FLOW =====\n log.debug('Project directory detected')\n\n // Detect Payload\n const projectInfo = await detectPayloadProject()\n\n if (projectInfo.hasPayload) {\n // Validate existing Payload version\n if (projectInfo.payloadVersion && !validatePayloadVersion(projectInfo.payloadVersion)) {\n p.log.warn(\n pc.yellow(\n `Payload version ${projectInfo.payloadVersion} detected. Version 3.x is required.`,\n ),\n )\n p.note('Upgrade to Payload 3.x before continuing', 'Action Required')\n process.exit(1)\n }\n\n p.log.success(pc.green(`✓ Payload ${projectInfo.payloadVersion || 'detected'}`))\n\n // Check dependencies\n s.start('Checking dependencies...')\n const hasDeps = await hasRequiredDependencies(process.cwd())\n s.stop(pc.green('✓ Dependencies checked'))\n\n if (!hasDeps) {\n const shouldInstall = await p.confirm({\n initialValue: true,\n message: 'Install dependencies now?',\n })\n\n if (!p.isCancel(shouldInstall) && shouldInstall) {\n s.start('Installing dependencies...')\n await installDependencies(process.cwd(), projectInfo.packageManager || 'pnpm')\n s.stop(pc.green('✓ Dependencies installed'))\n }\n }\n\n s.start('Checking Payload configuration...')\n const modResult = await ensurePayloadFigmaConfig(\n process.cwd(),\n projectInfo.packageManager || 'pnpm',\n {\n contentSystemId: selectedTenant.id,\n region: options.region || 'us-east-1',\n useContentSystem: !options.noContentSystem,\n },\n )\n\n if (!modResult.success) {\n s.stop(pc.red('✗ Configuration check failed'))\n displayManualInstructions(modResult.error || 'Unknown error')\n process.exit(1)\n }\n\n if (modResult.modified) {\n s.stop(pc.green('✓ Payload configuration updated'))\n if (modResult.changes.length > 0) {\n modResult.changes.forEach((change) => log.debug(pc.dim(` → ${change}`)))\n }\n } else {\n s.stop(pc.green('✓ Payload configuration valid'))\n }\n\n // Display warnings if any\n if (modResult.warnings && modResult.warnings.length > 0) {\n modResult.warnings.forEach((warning) => {\n p.log.warn(pc.yellow(`⚠ ${warning}`))\n })\n }\n } else {\n // Has package.json but no Payload - offer to add Payload\n p.log.warn(pc.yellow('⚠ No Payload detected in this project'))\n\n const shouldAddPayload = await p.confirm({\n initialValue: true,\n message: 'Would you like to add Payload to this project?',\n })\n\n if (p.isCancel(shouldAddPayload)) {\n p.cancel('Operation cancelled')\n process.exit(0)\n }\n\n if (!shouldAddPayload) {\n p.log.error('Payload is required to use Figma CMS')\n process.exit(1)\n }\n\n // TODO: Add Payload to existing project (future enhancement)\n p.log.error('Adding Payload to existing projects is not yet supported')\n p.note('Create a new project or manually add Payload dependencies', 'Action Required')\n process.exit(1)\n }\n\n // Generate project token (unless skipping auth)\n if (!options.skipAuth) {\n await generateProjectTokenWithFeedback(tokenStore, selectedTenant.id, s)\n }\n\n // Success message for existing project\n p.outro(pc.green('✓ Project initialized successfully!'))\n\n const nextSteps = [\n selectedTenant.status === 'provisioning'\n ? 'Wait for CMS provisioning to complete (check status with `@payloadcms/figma list`)'\n : undefined,\n 'Start development server: `pnpm dev`',\n `Access your CMS at: ${pc.cyan(`https://${selectedTenant.domain}`)}`,\n ].filter(Boolean)\n\n p.note(nextSteps.join('\\n'), 'Next Steps')\n } else {\n // ===== NEW PROJECT FLOW =====\n // p.log.info('No project detected - Creating New Project')\n\n // Prompt for path\n const projectPathInput = await p.text({\n initialValue: './',\n message: 'Enter path to create project:',\n placeholder: './my-cms-project',\n validate: (value) => {\n if (!value) {\n return 'Path is required'\n }\n // Allow relative or absolute paths\n return undefined\n },\n })\n\n if (p.isCancel(projectPathInput)) {\n p.cancel('Operation cancelled')\n process.exit(0)\n }\n\n const projectPath = projectPathInput\n const fullPath = path.resolve(process.cwd(), projectPath)\n\n // Get project name from path or prompt\n const projectName = options.name || path.basename(fullPath)\n\n // Create directory\n try {\n await fs.mkdir(fullPath, { recursive: true })\n } catch (error) {\n p.log.error(\n `Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n process.exit(1)\n }\n\n // Scaffold project\n s.start('Downloading template from GitHub...')\n try {\n await scaffoldProject(fullPath, projectName)\n s.stop(pc.green('✓ Template downloaded'))\n\n s.start('Installing dependencies...')\n await installDependencies(fullPath, 'pnpm')\n s.stop(pc.green('✓ Dependencies installed'))\n } catch (error) {\n s.stop(pc.red('✗ Failed'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n process.exit(1)\n }\n\n // Modify Payload configuration\n s.start('Checking Payload configuration...')\n const modResult = await ensurePayloadFigmaConfig(fullPath, 'pnpm', {\n contentSystemId: selectedTenant.id,\n region: options.region || 'us-east-1',\n useContentSystem: !options.noContentSystem,\n })\n\n if (!modResult.success) {\n s.stop(pc.red('✗ Configuration check failed'))\n displayManualInstructions(modResult.error || 'Unknown error')\n process.exit(1)\n }\n\n if (modResult.modified) {\n s.stop(pc.green('✓ Payload configuration updated'))\n if (modResult.changes.length > 0) {\n modResult.changes.forEach((change) => log.debug(pc.dim(` → ${change}`)))\n }\n } else {\n s.stop(pc.green('✓ Payload configuration valid'))\n }\n\n // Display warnings if any\n if (modResult.warnings && modResult.warnings.length > 0) {\n modResult.warnings.forEach((warning) => {\n p.log.warn(pc.yellow(`⚠ ${warning}`))\n })\n }\n\n // Generate project token (unless skipping auth)\n if (!options.skipAuth) {\n await generateProjectTokenWithFeedback(tokenStore, selectedTenant.id, s)\n }\n\n // Initialize git repository (after all files including lock file are ready)\n initializeGitRepo(fullPath)\n\n // Success message for NEW project\n p.log.step(pc.bgGreen(pc.black(' Project created successfully! ')))\n\n const relativePath = path.relative(process.cwd(), fullPath)\n const nextSteps: string[] = []\n\n // Only show cd command if user needs to navigate\n if (relativePath && relativePath !== '.') {\n nextSteps.push(`cd ${relativePath}`)\n }\n\n nextSteps.push(\n 'pnpm dev or follow directions in README.md',\n '',\n 'Documentation:',\n '- Getting Started: https://payloadcms.com/docs/getting-started/what-is-payload',\n '- Configuration: https://payloadcms.com/docs/configuration/overview',\n )\n\n p.note(nextSteps.join('\\n'), 'Next Steps')\n p.outro(pc.green('✓ Done'))\n }\n}\n"],"names":["p","fs","path","pc","ControlPlaneError","getTenantDetails","FigmaApiError","getValidAccessToken","getValidProjectToken","ProjectTokenError","TokenStore","isDebug","log","displayManualInstructions","ensurePayloadFigmaConfig","detectPayloadProject","hasRequiredDependencies","initializeGitRepo","installDependencies","isInProjectDirectory","scaffoldProject","validatePayloadVersion","loginCommand","generateProjectTokenWithFeedback","tokenStore","tenantId","spinner","start","projectToken","stop","green","yellow","error","warning","message","note","Error","initCommand","options","s","accessToken","skipAuth","warn","hasValidTokens","getAccessToken","token","info","shouldAuth","confirm","initialValue","isCancel","cancel","process","exit","newToken","success","red","debug","id","selectedTenant","input","text","placeholder","validate","value","undefined","domain","statusCode","shouldRetry","isInProject","projectInfo","hasPayload","payloadVersion","hasDeps","cwd","shouldInstall","packageManager","modResult","contentSystemId","region","useContentSystem","noContentSystem","modified","changes","length","forEach","change","dim","warnings","shouldAddPayload","outro","nextSteps","status","cyan","filter","Boolean","join","projectPathInput","projectPath","fullPath","resolve","projectName","name","basename","mkdir","recursive","step","bgGreen","black","relativePath","relative","push"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AACvB,OAAOC,QAAQ,aAAY;AAI3B,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,0BAAyB;AAC7E,SAASC,aAAa,QAAQ,sBAAqB;AACnD,SAASC,mBAAmB,QAAQ,wBAAuB;AAC3D,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,2BAA0B;AAClF,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,YAAYC,SAAS,kBAAiB;AACtC,SACEC,yBAAyB,EACzBC,wBAAwB,QACnB,sCAAqC;AAC5C,SACEC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,EACjBC,mBAAmB,EACnBC,oBAAoB,EACpBC,eAAe,EACfC,sBAAsB,QACjB,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,CAACK,QAAQG,QAAQ,EAAE;YACrB,MAAMlB,iCAAiCC,YAAYmC,eAAeD,EAAE,EAAEnB;QACxE;QAEA,4EAA4E;QAC5EtB,kBAAkBkF;QAElB,kCAAkC;QAClCnG,EAAEY,GAAG,CAAC8F,IAAI,CAACvG,GAAGwG,OAAO,CAACxG,GAAGyG,KAAK,CAAC;QAE/B,MAAMC,eAAe3G,KAAK4G,QAAQ,CAAC1D,QAAQsB,GAAG,IAAIyB;QAClD,MAAMR,YAAsB,EAAE;QAE9B,iDAAiD;QACjD,IAAIkB,gBAAgBA,iBAAiB,KAAK;YACxClB,UAAUoB,IAAI,CAAC,CAAC,GAAG,EAAEF,cAAc;QACrC;QAEAlB,UAAUoB,IAAI,CACZ,8CACA,IACA,kBACA,kFACA;QAGF/G,EAAEmC,IAAI,CAACwD,UAAUK,IAAI,CAAC,OAAO;QAC7BhG,EAAE0F,KAAK,CAACvF,GAAG2B,KAAK,CAAC;IACnB;AACF"}
1
+ {"version":3,"sources":["../../src/commands/init.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport fs from 'fs/promises'\nimport path from 'path'\nimport pc from 'picocolors'\n\nimport { FigmaApiError } from '../api/figma-api.js'\nimport { getValidAccessToken } from '../auth/oauth-flow.js'\nimport { getValidProjectToken, ProjectTokenError } from '../auth/project-token.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { isDebug } from '../utils/is-debug.js'\nimport * as log from '../utils/log.js'\nimport {\n displayManualInstructions,\n ensurePayloadFigmaConfig,\n} from '../utils/payload-config-modifier.js'\nimport {\n detectPayloadProject,\n hasRequiredDependencies,\n initializeGitRepo,\n installDependencies,\n isInProjectDirectory,\n scaffoldProject,\n validatePayloadVersion,\n} from '../utils/project.js'\nimport { loginCommand } from './login.js'\n\n/**\n * Options for init command\n */\nexport interface InitCommandOptions {\n /** Enable debug mode */\n debug?: boolean\n /** Force reconfiguration of existing project */\n force?: boolean\n /** Tenant ID to use (optional - will prompt if not provided) */\n id?: string\n /** Project name (for scaffolding) */\n name?: string\n /** Disable Content System (defaults to enabled) */\n noContentSystem?: boolean\n /** AWS region for deployment (defaults to us-east-1) */\n region?: string\n /** Skip authentication check (for testing/development) */\n skipAuth?: boolean\n /** Skip prompts and use defaults where possible */\n yes?: boolean\n}\n\n/**\n * Generate and store project token for a tenant\n * Non-blocking - will show warning but not exit on failure\n * Only shows feedback if DEBUG mode is enabled, otherwise runs silently\n *\n * @param tokenStore - Token store instance\n * @param tenantId - Tenant ID to generate token for\n * @param spinner - Clack spinner instance for status updates (only used in debug mode)\n */\nasync function generateProjectTokenWithFeedback(\n tokenStore: TokenStore,\n tenantId: string,\n spinner: ReturnType<typeof p.spinner>,\n): Promise<void> {\n if (isDebug()) {\n spinner.start('Generating project token...')\n }\n\n try {\n const projectToken = await getValidProjectToken(tokenStore, tenantId)\n if (isDebug()) {\n if (projectToken) {\n spinner.stop(pc.green('✓ Project token generated'))\n } else {\n spinner.stop(pc.yellow('⚠ Project token not generated (authentication required)'))\n }\n }\n } catch (error) {\n if (isDebug()) {\n spinner.stop(pc.yellow('⚠ Project token generation failed'))\n }\n // Always show failures, even without debug\n if (error instanceof ProjectTokenError || error instanceof FigmaApiError) {\n log.warning(error.message)\n p.note(\n 'Project token is used for authenticating to the Content API.\\nYou can continue without it, but may need to regenerate later.',\n 'Note',\n )\n } else {\n log.warning(\n `Unable to retrieve project token: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n // Don't exit - token generation failure shouldn't block initialization\n }\n}\n\n/**\n * Handle the `init` command\n *\n * Sets up a project by:\n * 1. Checking authentication\n * 2. Detecting/scaffolding Payload project\n * 3. Fetching tenant details\n * 4. Storing configuration\n *\n * @param options - Command options\n */\nexport async function initCommand(options: InitCommandOptions): Promise<void> {\n // Check authentication\n const tokenStore = new TokenStore()\n const s = p.spinner()\n\n if (options.skipAuth) {\n // Skip authentication for testing/development\n p.log.warn(pc.yellow('Skipping authentication (--skip-auth mode)'))\n } else {\n try {\n // Check for valid cached tokens first (no API call needed)\n if (!tokenStore.hasValidTokens()) {\n // Need to refresh or authenticate - show spinner for API call\n s.start('Checking authentication...')\n const token = await getValidAccessToken(tokenStore)\n if (!token) {\n s.stop(pc.yellow('⚠ Not authenticated'))\n p.log.info('Authentication required to continue')\n\n // Run login command\n await loginCommand({ showNextSteps: false })\n\n // Get token after auth\n const newToken = await getValidAccessToken(tokenStore)\n if (!newToken) {\n p.log.error('Authentication failed')\n process.exit(1)\n }\n } else {\n s.stop(pc.green('✓ Authenticated'))\n }\n }\n } catch (error) {\n s.stop(pc.red('✗ Authentication failed'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n p.note('Run `figma auth` to authenticate', 'Tip')\n process.exit(1)\n }\n }\n\n // Note: We no longer check for figma.config.json here\n // Instead, the AST detection will check if figma object already exists in payload.config.ts\n // and skip modification if it does (unless --force is used)\n\n // Step 3: Get CMS ID (required argument)\n log.debug('Configuring Project...')\n\n if (!options.id) {\n p.log.error('CMS ID is required. Use --id <tenant_id>')\n process.exit(1)\n }\n\n const tenantId = options.id\n\n // Step 4: Detect or scaffold Payload project\n const isInProject = await isInProjectDirectory()\n\n if (isInProject) {\n // ===== EXISTING PROJECT FLOW =====\n log.debug('Project directory detected')\n\n // Detect Payload\n const projectInfo = await detectPayloadProject()\n\n if (projectInfo.hasPayload) {\n // Validate existing Payload version\n if (projectInfo.payloadVersion && !validatePayloadVersion(projectInfo.payloadVersion)) {\n p.log.warn(\n pc.yellow(\n `Payload version ${projectInfo.payloadVersion} detected. Version 3.x is required.`,\n ),\n )\n p.note('Upgrade to Payload 3.x before continuing', 'Action Required')\n process.exit(1)\n }\n\n p.log.success(pc.green(`✓ Payload ${projectInfo.payloadVersion || 'detected'}`))\n\n // Check dependencies\n s.start('Checking dependencies...')\n const hasDeps = await hasRequiredDependencies(process.cwd())\n s.stop(pc.green('✓ Dependencies checked'))\n\n if (!hasDeps) {\n const shouldInstall = await p.confirm({\n initialValue: true,\n message: 'Install dependencies now?',\n })\n\n if (!p.isCancel(shouldInstall) && shouldInstall) {\n s.start('Installing dependencies...')\n await installDependencies(process.cwd(), projectInfo.packageManager || 'pnpm')\n s.stop(pc.green('✓ Dependencies installed'))\n }\n }\n\n s.start('Checking Payload configuration...')\n const modResult = await ensurePayloadFigmaConfig(\n process.cwd(),\n projectInfo.packageManager || 'pnpm',\n {\n contentSystemId: tenantId,\n region: options.region || 'us-east-1',\n useContentSystem: !options.noContentSystem,\n },\n )\n\n if (!modResult.success) {\n s.stop(pc.red('✗ Configuration check failed'))\n displayManualInstructions(modResult.error || 'Unknown error')\n process.exit(1)\n }\n\n if (modResult.modified) {\n s.stop(pc.green('✓ Payload configuration updated'))\n if (modResult.changes.length > 0) {\n modResult.changes.forEach((change) => log.debug(pc.dim(` → ${change}`)))\n }\n } else {\n s.stop(pc.green('✓ Payload configuration valid'))\n }\n\n // Display warnings if any\n if (modResult.warnings && modResult.warnings.length > 0) {\n modResult.warnings.forEach((warning) => {\n p.log.warn(pc.yellow(`⚠ ${warning}`))\n })\n }\n } else {\n // Has package.json but no Payload - offer to add Payload\n p.log.warn(pc.yellow('⚠ No Payload detected in this project'))\n\n const shouldAddPayload = await p.confirm({\n initialValue: true,\n message: 'Would you like to add Payload to this project?',\n })\n\n if (p.isCancel(shouldAddPayload)) {\n p.cancel('Operation cancelled')\n process.exit(0)\n }\n\n if (!shouldAddPayload) {\n p.log.error('Payload is required to use Figma CMS')\n process.exit(1)\n }\n\n // TODO: Add Payload to existing project (future enhancement)\n p.log.error('Adding Payload to existing projects is not yet supported')\n p.note('Create a new project or manually add Payload dependencies', 'Action Required')\n process.exit(1)\n }\n\n // Generate project token (unless skipping auth)\n if (!options.skipAuth) {\n await generateProjectTokenWithFeedback(tokenStore, tenantId, s)\n }\n\n // Success message for existing project\n p.outro(pc.green('✓ Project initialized successfully!'))\n\n const nextSteps = ['Start development server: `pnpm dev`'].filter(Boolean)\n\n p.note(nextSteps.join('\\n'), 'Next Steps')\n } else {\n // ===== NEW PROJECT FLOW =====\n // p.log.info('No project detected - Creating New Project')\n\n // Prompt for path\n const projectPathInput = await p.text({\n initialValue: './',\n message: 'Enter path to create project:',\n placeholder: './my-cms-project',\n validate: (value) => {\n if (!value) {\n return 'Path is required'\n }\n // Allow relative or absolute paths\n return undefined\n },\n })\n\n if (p.isCancel(projectPathInput)) {\n p.cancel('Operation cancelled')\n process.exit(0)\n }\n\n const projectPath = projectPathInput\n const fullPath = path.resolve(process.cwd(), projectPath)\n\n // Get project name from path or prompt\n const projectName = options.name || path.basename(fullPath)\n\n // Create directory\n try {\n await fs.mkdir(fullPath, { recursive: true })\n } catch (error) {\n p.log.error(\n `Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n process.exit(1)\n }\n\n // Scaffold project\n s.start('Downloading template from GitHub...')\n try {\n await scaffoldProject(fullPath, projectName)\n s.stop(pc.green('✓ Template downloaded'))\n\n s.start('Installing dependencies...')\n await installDependencies(fullPath, 'pnpm')\n s.stop(pc.green('✓ Dependencies installed'))\n } catch (error) {\n s.stop(pc.red('✗ Failed'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n process.exit(1)\n }\n\n // Modify Payload configuration\n s.start('Checking Payload configuration...')\n const modResult = await ensurePayloadFigmaConfig(fullPath, 'pnpm', {\n contentSystemId: tenantId,\n region: options.region || 'us-east-1',\n useContentSystem: !options.noContentSystem,\n })\n\n if (!modResult.success) {\n s.stop(pc.red('✗ Configuration check failed'))\n displayManualInstructions(modResult.error || 'Unknown error')\n process.exit(1)\n }\n\n if (modResult.modified) {\n s.stop(pc.green('✓ Payload configuration updated'))\n if (modResult.changes.length > 0) {\n modResult.changes.forEach((change) => log.debug(pc.dim(` → ${change}`)))\n }\n } else {\n s.stop(pc.green('✓ Payload configuration valid'))\n }\n\n // Display warnings if any\n if (modResult.warnings && modResult.warnings.length > 0) {\n modResult.warnings.forEach((warning) => {\n p.log.warn(pc.yellow(`⚠ ${warning}`))\n })\n }\n\n // Generate project token (unless skipping auth)\n if (!options.skipAuth) {\n await generateProjectTokenWithFeedback(tokenStore, tenantId, s)\n }\n\n // Initialize git repository (after all files including lock file are ready)\n initializeGitRepo(fullPath)\n\n // Success message for NEW project\n p.log.step(pc.bgGreen(pc.black(' Project created successfully! ')))\n\n const relativePath = path.relative(process.cwd(), fullPath)\n const nextSteps: string[] = []\n\n // Only show cd command if user needs to navigate\n if (relativePath && relativePath !== '.') {\n nextSteps.push(`cd ${relativePath}`)\n }\n\n nextSteps.push(\n 'pnpm dev or follow directions in README.md',\n '',\n 'Documentation:',\n '- Getting Started: https://payloadcms.com/docs/getting-started/what-is-payload',\n '- Configuration: https://payloadcms.com/docs/configuration/overview',\n )\n\n p.note(nextSteps.join('\\n'), 'Next Steps')\n p.outro(pc.green('✓ Done'))\n }\n}\n"],"names":["p","fs","path","pc","FigmaApiError","getValidAccessToken","getValidProjectToken","ProjectTokenError","TokenStore","isDebug","log","displayManualInstructions","ensurePayloadFigmaConfig","detectPayloadProject","hasRequiredDependencies","initializeGitRepo","installDependencies","isInProjectDirectory","scaffoldProject","validatePayloadVersion","loginCommand","generateProjectTokenWithFeedback","tokenStore","tenantId","spinner","start","projectToken","stop","green","yellow","error","warning","message","note","Error","initCommand","options","s","skipAuth","warn","hasValidTokens","token","info","showNextSteps","newToken","process","exit","red","debug","id","isInProject","projectInfo","hasPayload","payloadVersion","success","hasDeps","cwd","shouldInstall","confirm","initialValue","isCancel","packageManager","modResult","contentSystemId","region","useContentSystem","noContentSystem","modified","changes","length","forEach","change","dim","warnings","shouldAddPayload","cancel","outro","nextSteps","filter","Boolean","join","projectPathInput","text","placeholder","validate","value","undefined","projectPath","fullPath","resolve","projectName","name","basename","mkdir","recursive","step","bgGreen","black","relativePath","relative","push"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AACvB,OAAOC,QAAQ,aAAY;AAE3B,SAASC,aAAa,QAAQ,sBAAqB;AACnD,SAASC,mB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kCAAkC;QAClCxF,EAAEU,GAAG,CAACqF,IAAI,CAAC5F,GAAG6F,OAAO,CAAC7F,GAAG8F,KAAK,CAAC;QAE/B,MAAMC,eAAehG,KAAKiG,QAAQ,CAACtD,QAAQW,GAAG,IAAIgC;QAClD,MAAMX,YAAsB,EAAE;QAE9B,iDAAiD;QACjD,IAAIqB,gBAAgBA,iBAAiB,KAAK;YACxCrB,UAAUuB,IAAI,CAAC,CAAC,GAAG,EAAEF,cAAc;QACrC;QAEArB,UAAUuB,IAAI,CACZ,8CACA,IACA,kBACA,kFACA;QAGFpG,EAAEiC,IAAI,CAAC4C,UAAUG,IAAI,CAAC,OAAO;QAC7BhF,EAAE4E,KAAK,CAACzE,GAAGyB,KAAK,CAAC;IACnB;AACF"}
@@ -1,8 +1,15 @@
1
+ type LoginArgs = {
2
+ /** Set this to show next steps after login
3
+ * @default true
4
+ */
5
+ showNextSteps: boolean;
6
+ };
1
7
  /**
2
8
  * Handle the `@payloadcms/figma login` command
3
9
  *
4
10
  * Authenticates the user with Figma OAuth2 and stores tokens locally.
5
11
  * If valid tokens already exist, shows an error message.
6
12
  */
7
- export declare function loginCommand(): Promise<void>;
13
+ export declare function loginCommand(args?: LoginArgs): Promise<void>;
14
+ export {};
8
15
  //# sourceMappingURL=login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBlD"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAQA,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BlE"}
@@ -9,7 +9,10 @@ import * as log from '../utils/log.js';
9
9
  *
10
10
  * Authenticates the user with Figma OAuth2 and stores tokens locally.
11
11
  * If valid tokens already exist, shows an error message.
12
- */ export async function loginCommand() {
12
+ */ export async function loginCommand(args) {
13
+ const { showNextSteps } = args || {
14
+ showNextSteps: false
15
+ };
13
16
  const tokenStore = new TokenStore();
14
17
  // Check for existing valid tokens
15
18
  try {
@@ -30,12 +33,13 @@ import * as log from '../utils/log.js';
30
33
  }
31
34
  // Start OAuth flow
32
35
  await handleAuthentication({
36
+ showNextSteps,
33
37
  tokenStore
34
38
  });
35
39
  }
36
40
  /**
37
41
  * Handle authentication flow
38
- */ async function handleAuthentication({ tokenStore }) {
42
+ */ async function handleAuthentication({ showNextSteps, tokenStore }) {
39
43
  try {
40
44
  // Execute OAuth flow
41
45
  const result = await executeOAuthFlow(tokenStore, {
@@ -48,8 +52,10 @@ import * as log from '../utils/log.js';
48
52
  log.debug(`User ID: ${result.userId}`);
49
53
  }
50
54
  log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`);
51
- // Show next steps
52
- p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps');
55
+ // Show next steps unless disabled
56
+ if (showNextSteps !== false) {
57
+ p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps');
58
+ }
53
59
  } catch (error) {
54
60
  if (error instanceof OAuthFlowError) {
55
61
  log.error(error.message);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/login.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { OAUTH_CONFIG } from '../config/oauth.js'\nimport * as log from '../utils/log.js'\n\n/**\n * Handle the `@payloadcms/figma login` command\n *\n * Authenticates the user with Figma OAuth2 and stores tokens locally.\n * If valid tokens already exist, shows an error message.\n */\nexport async function loginCommand(): Promise<void> {\n const tokenStore = new TokenStore()\n\n // Check for existing valid tokens\n try {\n const existingToken = await getValidAccessToken(tokenStore)\n if (existingToken) {\n const tokens = tokenStore.getTokens()\n p.log.warn(pc.yellow('Already logged in'))\n if (tokens?.userId) {\n log.info(`User ID: ${tokens.userId}`)\n }\n log.info(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n p.note(`To re-authenticate, first run ${pc.cyan('@payloadcms/figma logout')}`, 'Tip')\n return\n }\n } catch {\n // Token refresh failed - continue with new auth flow\n log.warning('Existing tokens are invalid. Starting new authentication...')\n }\n\n // Start OAuth flow\n await handleAuthentication({\n tokenStore,\n })\n}\n\n/**\n * Handle authentication flow\n */\nasync function handleAuthentication({ tokenStore }: { tokenStore: TokenStore }): Promise<void> {\n try {\n // Execute OAuth flow\n const result = await executeOAuthFlow(tokenStore, {\n clientId: OAUTH_CONFIG.clientId,\n redirectUri: OAUTH_CONFIG.redirectUri,\n scopes: OAUTH_CONFIG.scopes,\n })\n\n p.log.success(pc.green('✓ You are now authenticated with Figma'))\n\n if (result.userId) {\n log.debug(`User ID: ${result.userId}`)\n }\n\n log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n\n // Show next steps\n p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps')\n } catch (error) {\n if (error instanceof OAuthFlowError) {\n log.error(error.message)\n\n if (error.cause) {\n log.debug(`Cause: ${error.cause.message}`)\n }\n } else {\n log.error(error instanceof Error ? error.message : 'Unknown error')\n }\n\n process.exit(1)\n }\n}\n"],"names":["p","pc","executeOAuthFlow","getValidAccessToken","OAuthFlowError","TokenStore","OAUTH_CONFIG","log","loginCommand","tokenStore","existingToken","tokens","getTokens","warn","yellow","userId","info","dim","getStoragePath","note","cyan","warning","handleAuthentication","result","clientId","redirectUri","scopes","success","green","debug","error","message","cause","Error","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAE3B,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gB,GAAG,CAACR,WAAWS,cAAc,KAAK;QAEjE,kBAAkB;QAClBlB,EAAEmB,IAAI,CAAC,CAAC,EAAE,EAAElB,GAAGmB,IAAI,CAAC,0BAA0B,2BAA2B,CAAC,EAAE;IAC9E,EAAE,OAAOU,OAAO;QACd,IAAIA,iBAAiB1B,gBAAgB;YACnCG,IAAIuB,KAAK,CAACA,MAAMC,OAAO;YAEvB,IAAID,MAAME,KAAK,EAAE;gBACfzB,IAAIsB,KAAK,CAAC,CAAC,OAAO,EAAEC,MAAME,KAAK,CAACD,OAAO,EAAE;YAC3C;QACF,OAAO;YACLxB,IAAIuB,KAAK,CAACA,iBAAiBG,QAAQH,MAAMC,OAAO,GAAG;QACrD;QAEAG,QAAQC,IAAI,CAAC;IACf;AACF"}
1
+ {"version":3,"sources":["../../src/commands/login.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { OAUTH_CONFIG } from '../config/oauth.js'\nimport * as log from '../utils/log.js'\n\ntype LoginArgs = {\n /** Set this to show next steps after login\n * @default true\n */\n showNextSteps: boolean\n}\n\n/**\n * Handle the `@payloadcms/figma login` command\n *\n * Authenticates the user with Figma OAuth2 and stores tokens locally.\n * If valid tokens already exist, shows an error message.\n */\nexport async function loginCommand(args?: LoginArgs): Promise<void> {\n const { showNextSteps } = args || { showNextSteps: false }\n const tokenStore = new TokenStore()\n\n // Check for existing valid tokens\n try {\n const existingToken = await getValidAccessToken(tokenStore)\n if (existingToken) {\n const tokens = tokenStore.getTokens()\n p.log.warn(pc.yellow('Already logged in'))\n if (tokens?.userId) {\n log.info(`User ID: ${tokens.userId}`)\n }\n log.info(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n p.note(`To re-authenticate, first run ${pc.cyan('@payloadcms/figma logout')}`, 'Tip')\n return\n }\n } catch {\n // Token refresh failed - continue with new auth flow\n log.warning('Existing tokens are invalid. Starting new authentication...')\n }\n\n // Start OAuth flow\n await handleAuthentication({\n showNextSteps,\n tokenStore,\n })\n}\n\n/**\n * Handle authentication flow\n */\nasync function handleAuthentication({\n showNextSteps,\n tokenStore,\n}: {\n showNextSteps: boolean\n tokenStore: TokenStore\n}): Promise<void> {\n try {\n // Execute OAuth flow\n const result = await executeOAuthFlow(tokenStore, {\n clientId: OAUTH_CONFIG.clientId,\n redirectUri: OAUTH_CONFIG.redirectUri,\n scopes: OAUTH_CONFIG.scopes,\n })\n\n p.log.success(pc.green('✓ You are now authenticated with Figma'))\n\n if (result.userId) {\n log.debug(`User ID: ${result.userId}`)\n }\n\n log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n\n // Show next steps unless disabled\n if (showNextSteps !== false) {\n p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps')\n }\n } catch (error) {\n if (error instanceof OAuthFlowError) {\n log.error(error.message)\n\n if (error.cause) {\n log.debug(`Cause: ${error.cause.message}`)\n }\n } else {\n log.error(error instanceof Error ? error.message : 'Unknown error')\n }\n\n process.exit(1)\n }\n}\n"],"names":["p","pc","executeOAuthFlow","getValidAccessToken","OAuthFlowError","TokenStore","OAUTH_CONFIG","log","loginCommand","args","showNextSteps","tokenStore","existingToken","tokens","getTokens","warn","yellow","userId","info","dim","getStoragePath","note","cyan","warning","handleAuthentication","result","clientId","redirectUri","scopes","success","green","debug","error","message","cause","Error","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAE3B,SAASC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,QAAQ,wBAAuB;AAC7F,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,YAAY,QAAQ,qBAAoB;AACjD,YAAYC,SAAS,kBAAiB;AAStC;;;;;CAKC,GACD,OAAO,eAAeC,aAAaC,IAAgB;IACjD,MAAM,EAAEC,aAAa,E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B,IAAI,CAAC,0BAA0B,2BAA2B,CAAC,EAAE;QAC9E;IACF,EAAE,OAAOU,OAAO;QACd,IAAIA,iBAAiB5B,gBAAgB;YACnCG,IAAIyB,KAAK,CAACA,MAAMC,OAAO;YAEvB,IAAID,MAAME,KAAK,EAAE;gBACf3B,IAAIwB,KAAK,CAAC,CAAC,OAAO,EAAEC,MAAME,KAAK,CAACD,OAAO,EAAE;YAC3C;QACF,OAAO;YACL1B,IAAIyB,KAAK,CAACA,iBAAiBG,QAAQH,MAAMC,OAAO,GAAG;QACrD;QAEAG,QAAQC,IAAI,CAAC;IACf;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"db-adapter.d.ts","sourceRoot":"","sources":["../src/db-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAanB,kBAAkB,EAqBnB,MAAM,SAAS,CAAA;AAchB,UAAU,gCAAgC;IACxC,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACvD,GAAG,mBAAmB,CAAA;AAgzBvB,eAAO,MAAM,iBAAiB,SAAU,gCAAgC,KAAG,kBA6C1E,CAAA"}
1
+ {"version":3,"file":"db-adapter.d.ts","sourceRoot":"","sources":["../src/db-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAanB,kBAAkB,EAqBnB,MAAM,SAAS,CAAA;AAchB,UAAU,gCAAgC;IACxC,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACvD,GAAG,mBAAmB,CAAA;AAqzBvB,eAAO,MAAM,iBAAiB,SAAU,gCAAgC,KAAG,kBA6C1E,CAAA"}
@@ -692,9 +692,12 @@ const request = async function(path, body = {}) {
692
692
  ...body
693
693
  }),
694
694
  headers: {
695
- Authorization: `Bearer ${this.projectToken}`,
696
695
  'Content-Type': 'application/json',
697
- 'X-Api-Key': this.contentApiKey
696
+ ...this.contentApiKey ? {
697
+ 'X-Api-Key': this.contentApiKey
698
+ } : {
699
+ Authorization: `Bearer ${this.projectToken}`
700
+ }
698
701
  },
699
702
  method: 'POST'
700
703
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/db-adapter.ts"],"sourcesContent":["import type {\n BaseDatabaseAdapter,\n BeginTransaction,\n Collection,\n CollectionSlug,\n CommitTransaction,\n Config,\n Count,\n CountGlobalVersions,\n CountVersions,\n Create,\n CreateGlobal,\n CreateGlobalVersion,\n CreateVersion,\n DatabaseAdapterObj,\n DeleteMany,\n DeleteOne,\n DeleteVersions,\n Find,\n FindDistinct,\n FindGlobal,\n FindGlobalVersions,\n FindOne,\n FindVersions,\n FlattenedField,\n QueryDrafts,\n SanitizedConfig,\n SanitizedGlobalConfig,\n UpdateGlobal,\n UpdateGlobalVersion,\n UpdateMany,\n UpdateOne,\n UpdateVersion,\n Upsert,\n Where,\n} from 'payload'\n\nimport { randomUUID } from 'crypto'\nimport {\n buildVersionCollectionFields,\n buildVersionGlobalFields,\n combineQueries,\n createArrayFromCommaDelineated,\n createDatabaseAdapter,\n getFieldByPath,\n} from 'payload'\n// import { fieldShouldBeLocalized } from 'payload/shared'\n// import { db, uuid } from './db'\n\ninterface ContentAPIDatabaseAdapterOptions {\n contentApiKey: string\n contentApiUrl: string\n contentSystemId: string\n projectToken: string\n}\n\nexport type ContentAPIAdapter = {\n contentApiKey: string\n contentApiUrl: string\n contentSystemId: string\n projectToken: string\n request<T = any>(path: string, body?: any): Promise<T>\n} & BaseDatabaseAdapter\n\nconst slugIsGlobal = (slug: string) => slug.startsWith('_global-')\n\nconst getGlobalSlug = (slug: string) => `_global-${slug}`\n\n// Transform Payload Where format to Content API WhereClause format\nfunction transformWhereClause(where: undefined | Where): any {\n if (!where) {\n return undefined\n }\n\n // Handle and/or logical operators\n if (where.and) {\n return {\n and: where.and.map(transformWhereClause).filter(Boolean),\n }\n }\n\n if (where.or) {\n return {\n or: where.or.map(transformWhereClause).filter(Boolean),\n }\n }\n\n // Transform field conditions\n const transformedClauses: any[] = []\n\n for (const [field, condition] of Object.entries(where)) {\n if (field === 'and' || field === 'or') {\n continue\n }\n\n if (Array.isArray(condition)) {\n // Handle nested and/or arrays\n transformedClauses.push({\n [field]: condition.map(transformWhereClause).filter(Boolean),\n })\n } else if (typeof condition === 'object' && condition !== null) {\n // Handle field operators like { equals: 'value' }, { greater_than: 10 }\n for (const [operator, value] of Object.entries(condition)) {\n transformedClauses.push({\n operator: operator as any, // Map Payload operators to Content API operators\n path: field,\n value,\n })\n }\n } else {\n // Handle direct field values like { status: 'published' }\n transformedClauses.push({\n operator: 'equals',\n path: field,\n value: condition,\n })\n }\n }\n\n if (transformedClauses.length === 1) {\n return transformedClauses[0]\n } else if (transformedClauses.length > 1) {\n return {\n and: transformedClauses,\n }\n }\n\n return undefined\n}\n\nconst formatDocument = (doc: any) => {\n if (!doc) {\n return null\n }\n\n const { id, data, ...meta } = doc\n\n return {\n id,\n _meta: meta,\n ...data,\n }\n}\n\nasync function init(this: ContentAPIAdapter) {\n console.log('🔍 [DB_CONTENT_API] init() called')\n console.log('🔍 [DB_CONTENT_API] this:', this)\n console.log(\n '🔍 [DB_CONTENT_API] payload collections:',\n this.payload.config.collections.map((c) => c.slug),\n )\n\n // Create collections in content API\n for (const collection of this.payload.config.collections) {\n try {\n console.log(`🔧 [DB_CONTENT_API] Creating collection: ${collection.slug}`)\n const response = await this.request('/api/v0/collections', {\n contentSystemId: this.contentSystemId,\n key: collection.slug,\n })\n\n if (response.error) {\n console.error(\n `[DB_CONTENT_API] create collection ${collection.slug} failure`,\n response.error,\n )\n } else {\n console.log(`✅ [DB_CONTENT_API] Created collection: ${collection.slug}`)\n }\n } catch (error) {\n console.warn(`⚠️ [DB_CONTENT_API] Failed to create collection ${collection.slug}:`, error)\n }\n }\n\n // Create globals as collections (with _global- prefix)\n for (const global of this.payload.config.globals) {\n try {\n const globalKey = getGlobalSlug(global.slug)\n console.log(`🔧 [DB_CONTENT_API] Creating global collection: ${globalKey}`)\n const response = await this.request('/api/v0/collections', {\n contentSystemId: this.contentSystemId,\n key: globalKey,\n })\n\n if (response.error) {\n console.error(\n `[DB_CONTENT_API] create global collection ${globalKey} failure`,\n response.error,\n )\n } else {\n console.log(`✅ [DB_CONTENT_API] Created global collection: ${globalKey}`)\n }\n } catch (error) {\n console.warn(`⚠️ [DB_CONTENT_API] Failed to create global collection ${global.slug}:`, error)\n }\n }\n\n console.log(\n '🔍 [DB_CONTENT_API] payload globals:',\n this.payload.config.globals.map((g) => g.slug),\n )\n}\n\nconst find: Find = async function find(\n this: ContentAPIAdapter,\n { collection, limit, page = 1, req, sort, where, ...args },\n) {\n console.log(\n '🔍 [DB_CONTENT_API] find() called with:',\n collection,\n JSON.stringify(transformWhereClause(where), null, 2),\n { limit, page, sort, ...args },\n )\n\n try {\n const response = await this.request<any>('/api/v0/documents:find', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n limit,\n offset: (page - 1) * (limit || 10),\n sort: sort\n ? [sort].flat().map((s: any) => ({\n direction: Object.values(s)[0] === -1 ? 'dsc' : 'asc',\n path: Object.keys(s)[0],\n }))\n : undefined,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] find() failure', response.error?.message || response.error)\n }\n\n const docs = response.result?.data || []\n const pagination = response.result?.pagination\n const totalDocs = pagination?.total || docs.length\n const actualLimit = limit || 10\n const totalPages = Math.ceil(totalDocs / actualLimit)\n const hasNextPage = page < totalPages\n\n const result = {\n docs: docs.map(formatDocument),\n hasNextPage,\n hasPrevPage: page > 1,\n limit: actualLimit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs,\n totalPages,\n }\n console.log('[DB_CONTENT_API] find() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in find():`, error)\n const docs: any[] = []\n const hasNextPage = false\n const totalPages = 1\n\n return {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages,\n }\n }\n}\n\nconst findVersions: FindVersions = async function findVersions(\n this: ContentAPIAdapter,\n { collection, limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findVersions() called with:', {\n collection,\n limit,\n page,\n where,\n ...args,\n })\n\n const docs: any[] = []\n const hasNextPage = false\n const result = {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages: limit && docs.length ? Math.ceil(docs.length / limit) : 1,\n }\n console.log('[DB_CONTENT_API] findVersions() result:', result)\n return result\n}\n\nconst queryDrafts: QueryDrafts = async function queryDrafts(\n this: ContentAPIAdapter,\n { collection, limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] queryDrafts() called with:', {\n collection,\n limit,\n page,\n where,\n ...args,\n })\n\n const docs: any[] = []\n const hasNextPage = false\n const result = {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages: limit && docs.length ? Math.ceil(docs.length / limit) : 1,\n }\n console.log('[DB_CONTENT_API] queryDrafts() result:', result)\n return result\n}\n\nconst createVersion: CreateVersion = async function createVersion(\n this: ContentAPIAdapter,\n { collectionSlug, req, versionData, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] createVersion() called with:', {\n collectionSlug,\n versionData,\n ...args,\n })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] createVersion() result:', result)\n return result\n}\n\nconst updateVersion: UpdateVersion = async function updateVersion(\n this: ContentAPIAdapter,\n { id, collection, req, versionData, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateVersion() called with:', {\n id,\n collection,\n versionData,\n ...args,\n })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] updateVersion() result:', result)\n return result\n}\n\nconst deleteVersions: DeleteVersions = async function deleteVersions(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] deleteVersions() called with:', { collection, where, ...args })\n\n const versionsToDelete: any[] = []\n const versionCollection = 'versions'\n\n console.log(\n `🗑️ [DB_CONTENT_API] Deleted ${versionsToDelete.length} versions from ${versionCollection}`,\n )\n\n // return versionsToDelete.length\n}\n\nconst findOne: FindOne = async function findOne(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log(\n '🔍 [DB_CONTENT_API] findOne() called with:',\n collection,\n JSON.stringify(transformWhereClause(where), null, 2),\n args,\n req?.body,\n )\n\n try {\n const response = await this.request<any>('/api/v0/documents:find', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n limit: 1,\n offset: 0,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] findOne() failure', response.error?.message || response.error)\n }\n\n const docs = response.result?.data || []\n const result = docs.length > 0 ? docs[0] : null\n console.log('[DB_CONTENT_API] findOne() result:', result)\n return formatDocument(result)\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in findOne():`, error)\n return null\n }\n}\n\nconst updateMany: UpdateMany = async function updateMany(\n this: ContentAPIAdapter,\n { collection, data, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateMany() called with:', { collection, data, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:update', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n data,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] updateMany() failure',\n response.error?.message || response.error,\n )\n }\n\n // Return array of updated documents if available, otherwise return placeholder\n const result = response.result?.data || []\n console.log('[DB_CONTENT_API] updateMany() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in updateMany():`, error)\n return []\n }\n}\n\nconst updateOne: UpdateOne = async function updateOne(\n this: ContentAPIAdapter,\n { id, collection, data, req, where = {}, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateOne() called with:', {\n id,\n collection,\n data,\n where,\n ...args,\n })\n try {\n const whereClause = id\n ? { operator: 'equals', path: 'id', value: id }\n : transformWhereClause(where)\n const response = await this.request<any>('/api/v0/documents:update', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n data,\n returning: { exclude: [] },\n where: whereClause,\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] updateOne() failure',\n response.error?.message || response.error,\n )\n }\n\n const result = response.result?.data || { id, ...data }\n console.log('[DB_CONTENT_API] updateOne() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in updateOne():`, error)\n return { id, ...data }\n }\n}\n\nconst deleteMany: DeleteMany = async function deleteMany(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] deleteMany() called with:', { collection, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:delete', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n returning: false,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] deleteMany() failure',\n response.error?.message || response.error,\n )\n }\n\n const deletedCount = response.result?.count || 0\n console.log(`🗑️ [DB_CONTENT_API] Deleted ${deletedCount} documents from ${collection}`)\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in deleteMany():`, error)\n }\n}\n\nconst deleteOne: DeleteOne = async function deleteOne(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] deleteOne() called with:', { collection, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:delete', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n returning: { exclude: [] },\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] deleteOne() failure',\n response.error?.message || response.error,\n )\n }\n\n const deletedDocs = response.result?.data || []\n const docId = deletedDocs.length > 0 ? deletedDocs[0].id : 'unknown'\n const result = deletedDocs.length > 0 ? deletedDocs[0] : {}\n\n console.log(`🗑️ [DB_CONTENT_API] Deleted document ${docId} from ${collection}`)\n console.log('[DB_CONTENT_API] deleteOne() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in deleteOne():`, error)\n return {}\n }\n}\n\nconst create: Create = async function create(\n this: ContentAPIAdapter,\n { collection, data, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] create() called with:', { collection, data, ...args })\n try {\n const randomKey = randomUUID()\n const response = await this.request<any>('/api/v0/documents:create', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n data,\n key: data.key || data.id || `doc-${randomKey}`,\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] create() failure', response.error?.message || response.error)\n }\n\n const result = response.result?.data || response.result || { id: `doc-${randomKey}`, ...data }\n console.log('[DB_CONTENT_API] create() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in create():`, error)\n return { id: `doc-${randomUUID()}`, ...data }\n }\n}\n\nconst count: Count = async function count(\n this: ContentAPIAdapter,\n { collection, req, where = {}, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] count() called with:', { collection, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:count', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] count() failure', response.error?.message || response.error)\n }\n\n const result = { totalDocs: response.result?.count || 0 }\n console.log('[DB_CONTENT_API] count() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in count():`, error)\n return { totalDocs: 0 }\n }\n}\n\nconst countVersions: CountVersions = async function countVersions(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] countVersions() called with:', { collection, where, ...args })\n\n const result = { totalDocs: 0 }\n console.log('[DB_CONTENT_API] countVersions() result:', result)\n return result\n}\n\nconst upsert: Upsert = async function upsert(\n this: ContentAPIAdapter,\n { collection, data, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] upsert() called with:', { collection, data, where, ...args })\n try {\n // Try to update first\n const updateResponse = await this.request<any>('/api/v0/documents:update', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: { documentKey: `upsert-${Date.now()}` },\n data,\n returning: { exclude: [] },\n where: transformWhereClause(where),\n })\n\n if (!updateResponse.success) {\n console.log('[DB_CONTENT_API] upsert() failure', updateResponse.error)\n }\n\n const result = updateResponse.result?.data || { ...data }\n console.log('[DB_CONTENT_API] upsert() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in upsert():`, error)\n return { ...data }\n }\n}\n\nconst createGlobal: CreateGlobal = async function createGlobal(\n this: ContentAPIAdapter,\n { slug, data, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] createGlobal() called with:', { slug, data, ...args })\n\n try {\n const globalKey = getGlobalSlug(slug)\n const response = await this.request<any>('/api/v0/documents:create', {\n collectionKey: globalKey,\n contentSystemId: this.contentSystemId,\n data,\n key: `global-${slug}`,\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] createGlobal() failure',\n response.error?.message || response.error,\n )\n }\n\n const result = response.result?.data || response.result || { id: `global-${slug}`, ...data }\n console.log('[DB_CONTENT_API] createGlobal() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in createGlobal():`, error)\n return { id: `global-${slug}`, ...data }\n }\n}\n\nconst findGlobal: FindGlobal = async function findGlobal(\n this: ContentAPIAdapter,\n { slug, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findGlobal() called with:', { slug, ...args })\n\n try {\n const globalKey = getGlobalSlug(slug)\n const response = await this.request<any>('/api/v0/documents:find', {\n collectionKey: globalKey,\n contentSystemId: this.contentSystemId,\n limit: 1,\n offset: 0,\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] findGlobal() failure',\n response.error?.message || response.error,\n )\n }\n\n const docs = response.result?.data || []\n const result = docs.length > 0 ? docs[0] : null\n console.log('[DB_CONTENT_API] findGlobal() result:', result)\n return formatDocument(result)\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in findGlobal():`, error)\n return null\n }\n}\n\nconst findDistinct: FindDistinct = async function findDistinct(\n this: ContentAPIAdapter,\n { collection, field, limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findDistinct() called with:', {\n collection,\n field,\n limit,\n page,\n where,\n ...args,\n })\n\n const distinctValues: any[] = []\n const paginatedValues: any[] = []\n const endIndex = 0\n const totalDocs = 0\n\n console.log(\n `📊 [DB_CONTENT_API] findDistinct result: ${distinctValues.length} distinct values for ${field}`,\n )\n\n return {\n hasNextPage: limit ? endIndex < totalDocs : false,\n hasPrevPage: page > 1,\n limit: limit || totalDocs,\n nextPage: limit && endIndex < totalDocs ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs,\n totalPages: limit ? Math.ceil(totalDocs / limit) : 1,\n values: paginatedValues,\n }\n}\n\nconst updateGlobal: UpdateGlobal = async function updateGlobal(\n this: ContentAPIAdapter,\n { slug, data, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateGlobal() called with:', { slug, data, ...args })\n\n try {\n const globalKey = getGlobalSlug(slug)\n const response = await this.request<any>('/api/v0/documents:update', {\n collectionKey: globalKey,\n contentSystemId: this.contentSystemId,\n createOnMissing: { documentKey: `global-${slug}` },\n data,\n returning: { exclude: [] },\n where: { operator: 'equals', path: 'key', value: `global-${slug}` },\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] updateGlobal() failure',\n response.error?.message || response.error,\n )\n }\n\n const result = response.result?.data || { id: `global-${slug}`, ...data }\n console.log('[DB_CONTENT_API] updateGlobal() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in updateGlobal():`, error)\n return { id: `global-${slug}`, ...data }\n }\n}\n\nconst findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: ContentAPIAdapter,\n { limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findGlobalVersions() called with:', {\n limit,\n page,\n where,\n ...args,\n })\n\n const docs: any[] = []\n const hasNextPage = false\n const result = {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages: limit && docs.length ? Math.ceil(docs.length / limit) : 1,\n }\n console.log('[DB_CONTENT_API] findGlobalVersions() result:', result)\n return result\n}\n\nconst createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(\n this: ContentAPIAdapter,\n { req, versionData, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] createGlobalVersion() called with:', { versionData, ...args })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] createGlobalVersion() result:', result)\n return result\n}\n\nconst updateGlobalVersion: UpdateGlobalVersion = async function updateGlobalVersion(\n this: ContentAPIAdapter,\n { id, req, versionData, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateGlobalVersion() called with:', {\n id,\n versionData,\n ...args,\n })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] updateGlobalVersion() result:', result)\n return result\n}\n\nconst countGlobalVersions: CountGlobalVersions = async function countGlobalVersions(\n this: ContentAPIAdapter,\n { req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] countGlobalVersions() called with:', { where, ...args })\n\n const totalDocs = 0\n const globalVersionsSlug = 'global-versions'\n\n console.log(\n `📊 [DB_CONTENT_API] countGlobalVersions result: ${totalDocs} versions in ${globalVersionsSlug}`,\n )\n\n const result = { totalDocs }\n console.log('[DB_CONTENT_API] countGlobalVersions() result:', result)\n return result\n}\n\nconst request = async function <T = any>(\n this: ContentAPIAdapter,\n path: string,\n body = {},\n): Promise<T> {\n console.log('🔍 [DB_CONTENT_API] request() called with:', { body, path })\n const res = await fetch(`${this.contentApiUrl}${path}`, {\n body: JSON.stringify({\n contentSystemId: this.contentSystemId,\n ...body,\n }),\n headers: {\n Authorization: `Bearer ${this.projectToken}`,\n 'Content-Type': 'application/json',\n 'X-Api-Key': this.contentApiKey,\n },\n method: 'POST',\n })\n\n return res.json() as T\n}\n\nconst beginTransaction: BeginTransaction = async function (options?: Record<string, any>) {\n console.log('🔍 [DB_CONTENT_API] beginTransaction() called', options)\n return null\n}\n\nconst commitTransaction: CommitTransaction = async function (\n id: number | Promise<number | string> | string,\n) {\n console.log('🔍 [DB_CONTENT_API] commitTransaction() called', id)\n}\n\nexport const contentAPIAdapter = (opts: ContentAPIDatabaseAdapterOptions): DatabaseAdapterObj => {\n return {\n name: 'content_api',\n defaultIDType: 'text',\n init: ({ payload }) => {\n return createDatabaseAdapter<ContentAPIAdapter>({\n name: 'content_api',\n beginTransaction,\n commitTransaction,\n contentApiKey: opts.contentApiKey,\n contentApiUrl: opts.contentApiUrl,\n contentSystemId: opts.contentSystemId,\n count,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createVersion,\n defaultIDType: 'text',\n deleteMany,\n deleteOne,\n deleteVersions,\n find,\n findDistinct,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n packageName: '@payloadcms/db-content-api',\n payload,\n projectToken: opts.projectToken,\n queryDrafts,\n request,\n rollbackTransaction: async () => {},\n updateGlobal,\n updateGlobalVersion,\n updateMany,\n updateOne,\n updateVersion,\n upsert,\n })\n },\n }\n}\n"],"names":["randomUUID","createDatabaseAdapter","slugIsGlobal","slug","startsWith","getGlobalSlug","transformWhereClause","where","undefined","and","map","filter","Boolean","or","transformedClauses","field","condition","Object","entries","Array","isArray","push","operator","value","path","length","formatDocument","doc","id","data","meta","_meta","init","console","log","payload","config","collections","c","collection","response","request","contentSystemId","key","error","warn","global","globals","globalKey","g","find","limit","page","req","sort","args","JSON","stringify","collectionKey","offset","flat","s","direction","values","keys","message","docs","result","pagination","totalDocs","total","actualLimit","totalPages","Math","ceil","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","findVersions","queryDrafts","createVersion","collectionSlug","versionData","updateVersion","deleteVersions","versionsToDelete","versionCollection","findOne","body","updateMany","createOnMissing","updateOne","whereClause","returning","exclude","deleteMany","deletedCount","count","deleteOne","deletedDocs","docId","create","randomKey","countVersions","upsert","updateResponse","documentKey","Date","now","success","createGlobal","findGlobal","findDistinct","distinctValues","paginatedValues","endIndex","updateGlobal","findGlobalVersions","createGlobalVersion","updateGlobalVersion","countGlobalVersions","globalVersionsSlug","res","fetch","contentApiUrl","headers","Authorization","projectToken","contentApiKey","method","json","beginTransaction","options","commitTransaction","contentAPIAdapter","opts","name","defaultIDType","packageName","rollbackTransaction"],"mappings":"AAqCA,SAASA,UAAU,QAAQ,SAAQ;AACnC,SAKEC,qBAAqB,QAEhB,UAAS;AAmBhB,MAAMC,eAAe,CAACC,OAAiBA,KAAKC,UAAU,CAAC;AAEvD,MAAMC,gBAAgB,CAACF,OAAiB,CAAC,QAAQ,EAAEA,MAAM;AAEzD,mEAAmE;AACnE,SAASG,qBAAqBC,KAAwB;IACpD,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IAEA,kCAAkC;IAClC,IAAID,MAAME,GAAG,EAAE;QACb,OAAO;YACLA,KAAKF,MAAME,GAAG,CAACC,GAAG,CAACJ,sBAAsBK,MAAM,CAACC;QAClD;IACF;IAEA,IAAIL,MAAMM,EAAE,EAAE;QACZ,OAAO;YACLA,IAAIN,MAAMM,EAAE,CAACH,GAAG,CAACJ,sBAAsBK,MAAM,CAACC;QAChD;IACF;IAEA,6BAA6B;IAC7B,MAAME,qBAA4B,EAAE;IAEpC,KAAK,MAAM,CAACC,OAAOC,UAAU,IAAIC,OAAOC,OAAO,CAACX,OAAQ;QACtD,IAAIQ,UAAU,SAASA,UAAU,MAAM;YACrC;QACF;QAEA,IAAII,MAAMC,OAAO,CAACJ,YAAY;YAC5B,8BAA8B;YAC9BF,mBAAmBO,IAAI,CAAC;gBACtB,CAACN,MAAM,EAAEC,UAAUN,GAAG,CAACJ,sBAAsBK,MAAM,CAACC;YACtD;QACF,OAAO,IAAI,OAAOI,cAAc,YAAYA,cAAc,MAAM;YAC9D,wEAAwE;YACxE,KAAK,MAAM,CAACM,UAAUC,MAAM,IAAIN,OAAOC,OAAO,CAACF,WAAY;gBACzDF,mBAAmBO,IAAI,CAAC;oBACtBC,UAAUA;oBACVE,MAAMT;oBACNQ;gBACF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Ae;gBACrCyD;gBACAuB;gBACAjB;gBACAF;gBACAS;gBACAQ;gBACAtC;gBACAyD,eAAe;gBACf1C;gBACAG;gBACAd;gBACApC;gBACAgE;gBACAD;gBACAM;gBACA9B;gBACAT;gBACAhD;gBACA4G,aAAa;gBACbzG;gBACA8F,cAAcQ,KAAKR,YAAY;gBAC/BhD;gBACAxC;gBACAoG,qBAAqB,WAAa;gBAClCvB;gBACAG;gBACA9B;gBACAE;gBACAR;gBACAqB;YACF;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/db-adapter.ts"],"sourcesContent":["import type {\n BaseDatabaseAdapter,\n BeginTransaction,\n Collection,\n CollectionSlug,\n CommitTransaction,\n Config,\n Count,\n CountGlobalVersions,\n CountVersions,\n Create,\n CreateGlobal,\n CreateGlobalVersion,\n CreateVersion,\n DatabaseAdapterObj,\n DeleteMany,\n DeleteOne,\n DeleteVersions,\n Find,\n FindDistinct,\n FindGlobal,\n FindGlobalVersions,\n FindOne,\n FindVersions,\n FlattenedField,\n QueryDrafts,\n SanitizedConfig,\n SanitizedGlobalConfig,\n UpdateGlobal,\n UpdateGlobalVersion,\n UpdateMany,\n UpdateOne,\n UpdateVersion,\n Upsert,\n Where,\n} from 'payload'\n\nimport { randomUUID } from 'crypto'\nimport {\n buildVersionCollectionFields,\n buildVersionGlobalFields,\n combineQueries,\n createArrayFromCommaDelineated,\n createDatabaseAdapter,\n getFieldByPath,\n} from 'payload'\n// import { fieldShouldBeLocalized } from 'payload/shared'\n// import { db, uuid } from './db'\n\ninterface ContentAPIDatabaseAdapterOptions {\n contentApiKey: string\n contentApiUrl: string\n contentSystemId: string\n projectToken: string\n}\n\nexport type ContentAPIAdapter = {\n contentApiKey: string\n contentApiUrl: string\n contentSystemId: string\n projectToken: string\n request<T = any>(path: string, body?: any): Promise<T>\n} & BaseDatabaseAdapter\n\nconst slugIsGlobal = (slug: string) => slug.startsWith('_global-')\n\nconst getGlobalSlug = (slug: string) => `_global-${slug}`\n\n// Transform Payload Where format to Content API WhereClause format\nfunction transformWhereClause(where: undefined | Where): any {\n if (!where) {\n return undefined\n }\n\n // Handle and/or logical operators\n if (where.and) {\n return {\n and: where.and.map(transformWhereClause).filter(Boolean),\n }\n }\n\n if (where.or) {\n return {\n or: where.or.map(transformWhereClause).filter(Boolean),\n }\n }\n\n // Transform field conditions\n const transformedClauses: any[] = []\n\n for (const [field, condition] of Object.entries(where)) {\n if (field === 'and' || field === 'or') {\n continue\n }\n\n if (Array.isArray(condition)) {\n // Handle nested and/or arrays\n transformedClauses.push({\n [field]: condition.map(transformWhereClause).filter(Boolean),\n })\n } else if (typeof condition === 'object' && condition !== null) {\n // Handle field operators like { equals: 'value' }, { greater_than: 10 }\n for (const [operator, value] of Object.entries(condition)) {\n transformedClauses.push({\n operator: operator as any, // Map Payload operators to Content API operators\n path: field,\n value,\n })\n }\n } else {\n // Handle direct field values like { status: 'published' }\n transformedClauses.push({\n operator: 'equals',\n path: field,\n value: condition,\n })\n }\n }\n\n if (transformedClauses.length === 1) {\n return transformedClauses[0]\n } else if (transformedClauses.length > 1) {\n return {\n and: transformedClauses,\n }\n }\n\n return undefined\n}\n\nconst formatDocument = (doc: any) => {\n if (!doc) {\n return null\n }\n\n const { id, data, ...meta } = doc\n\n return {\n id,\n _meta: meta,\n ...data,\n }\n}\n\nasync function init(this: ContentAPIAdapter) {\n console.log('🔍 [DB_CONTENT_API] init() called')\n console.log('🔍 [DB_CONTENT_API] this:', this)\n console.log(\n '🔍 [DB_CONTENT_API] payload collections:',\n this.payload.config.collections.map((c) => c.slug),\n )\n\n // Create collections in content API\n for (const collection of this.payload.config.collections) {\n try {\n console.log(`🔧 [DB_CONTENT_API] Creating collection: ${collection.slug}`)\n const response = await this.request('/api/v0/collections', {\n contentSystemId: this.contentSystemId,\n key: collection.slug,\n })\n\n if (response.error) {\n console.error(\n `[DB_CONTENT_API] create collection ${collection.slug} failure`,\n response.error,\n )\n } else {\n console.log(`✅ [DB_CONTENT_API] Created collection: ${collection.slug}`)\n }\n } catch (error) {\n console.warn(`⚠️ [DB_CONTENT_API] Failed to create collection ${collection.slug}:`, error)\n }\n }\n\n // Create globals as collections (with _global- prefix)\n for (const global of this.payload.config.globals) {\n try {\n const globalKey = getGlobalSlug(global.slug)\n console.log(`🔧 [DB_CONTENT_API] Creating global collection: ${globalKey}`)\n const response = await this.request('/api/v0/collections', {\n contentSystemId: this.contentSystemId,\n key: globalKey,\n })\n\n if (response.error) {\n console.error(\n `[DB_CONTENT_API] create global collection ${globalKey} failure`,\n response.error,\n )\n } else {\n console.log(`✅ [DB_CONTENT_API] Created global collection: ${globalKey}`)\n }\n } catch (error) {\n console.warn(`⚠️ [DB_CONTENT_API] Failed to create global collection ${global.slug}:`, error)\n }\n }\n\n console.log(\n '🔍 [DB_CONTENT_API] payload globals:',\n this.payload.config.globals.map((g) => g.slug),\n )\n}\n\nconst find: Find = async function find(\n this: ContentAPIAdapter,\n { collection, limit, page = 1, req, sort, where, ...args },\n) {\n console.log(\n '🔍 [DB_CONTENT_API] find() called with:',\n collection,\n JSON.stringify(transformWhereClause(where), null, 2),\n { limit, page, sort, ...args },\n )\n\n try {\n const response = await this.request<any>('/api/v0/documents:find', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n limit,\n offset: (page - 1) * (limit || 10),\n sort: sort\n ? [sort].flat().map((s: any) => ({\n direction: Object.values(s)[0] === -1 ? 'dsc' : 'asc',\n path: Object.keys(s)[0],\n }))\n : undefined,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] find() failure', response.error?.message || response.error)\n }\n\n const docs = response.result?.data || []\n const pagination = response.result?.pagination\n const totalDocs = pagination?.total || docs.length\n const actualLimit = limit || 10\n const totalPages = Math.ceil(totalDocs / actualLimit)\n const hasNextPage = page < totalPages\n\n const result = {\n docs: docs.map(formatDocument),\n hasNextPage,\n hasPrevPage: page > 1,\n limit: actualLimit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs,\n totalPages,\n }\n console.log('[DB_CONTENT_API] find() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in find():`, error)\n const docs: any[] = []\n const hasNextPage = false\n const totalPages = 1\n\n return {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages,\n }\n }\n}\n\nconst findVersions: FindVersions = async function findVersions(\n this: ContentAPIAdapter,\n { collection, limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findVersions() called with:', {\n collection,\n limit,\n page,\n where,\n ...args,\n })\n\n const docs: any[] = []\n const hasNextPage = false\n const result = {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages: limit && docs.length ? Math.ceil(docs.length / limit) : 1,\n }\n console.log('[DB_CONTENT_API] findVersions() result:', result)\n return result\n}\n\nconst queryDrafts: QueryDrafts = async function queryDrafts(\n this: ContentAPIAdapter,\n { collection, limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] queryDrafts() called with:', {\n collection,\n limit,\n page,\n where,\n ...args,\n })\n\n const docs: any[] = []\n const hasNextPage = false\n const result = {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages: limit && docs.length ? Math.ceil(docs.length / limit) : 1,\n }\n console.log('[DB_CONTENT_API] queryDrafts() result:', result)\n return result\n}\n\nconst createVersion: CreateVersion = async function createVersion(\n this: ContentAPIAdapter,\n { collectionSlug, req, versionData, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] createVersion() called with:', {\n collectionSlug,\n versionData,\n ...args,\n })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] createVersion() result:', result)\n return result\n}\n\nconst updateVersion: UpdateVersion = async function updateVersion(\n this: ContentAPIAdapter,\n { id, collection, req, versionData, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateVersion() called with:', {\n id,\n collection,\n versionData,\n ...args,\n })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] updateVersion() result:', result)\n return result\n}\n\nconst deleteVersions: DeleteVersions = async function deleteVersions(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] deleteVersions() called with:', { collection, where, ...args })\n\n const versionsToDelete: any[] = []\n const versionCollection = 'versions'\n\n console.log(\n `🗑️ [DB_CONTENT_API] Deleted ${versionsToDelete.length} versions from ${versionCollection}`,\n )\n\n // return versionsToDelete.length\n}\n\nconst findOne: FindOne = async function findOne(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log(\n '🔍 [DB_CONTENT_API] findOne() called with:',\n collection,\n JSON.stringify(transformWhereClause(where), null, 2),\n args,\n req?.body,\n )\n\n try {\n const response = await this.request<any>('/api/v0/documents:find', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n limit: 1,\n offset: 0,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] findOne() failure', response.error?.message || response.error)\n }\n\n const docs = response.result?.data || []\n const result = docs.length > 0 ? docs[0] : null\n console.log('[DB_CONTENT_API] findOne() result:', result)\n return formatDocument(result)\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in findOne():`, error)\n return null\n }\n}\n\nconst updateMany: UpdateMany = async function updateMany(\n this: ContentAPIAdapter,\n { collection, data, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateMany() called with:', { collection, data, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:update', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n data,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] updateMany() failure',\n response.error?.message || response.error,\n )\n }\n\n // Return array of updated documents if available, otherwise return placeholder\n const result = response.result?.data || []\n console.log('[DB_CONTENT_API] updateMany() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in updateMany():`, error)\n return []\n }\n}\n\nconst updateOne: UpdateOne = async function updateOne(\n this: ContentAPIAdapter,\n { id, collection, data, req, where = {}, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateOne() called with:', {\n id,\n collection,\n data,\n where,\n ...args,\n })\n try {\n const whereClause = id\n ? { operator: 'equals', path: 'id', value: id }\n : transformWhereClause(where)\n const response = await this.request<any>('/api/v0/documents:update', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: false,\n data,\n returning: { exclude: [] },\n where: whereClause,\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] updateOne() failure',\n response.error?.message || response.error,\n )\n }\n\n const result = response.result?.data || { id, ...data }\n console.log('[DB_CONTENT_API] updateOne() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in updateOne():`, error)\n return { id, ...data }\n }\n}\n\nconst deleteMany: DeleteMany = async function deleteMany(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] deleteMany() called with:', { collection, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:delete', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n returning: false,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] deleteMany() failure',\n response.error?.message || response.error,\n )\n }\n\n const deletedCount = response.result?.count || 0\n console.log(`🗑️ [DB_CONTENT_API] Deleted ${deletedCount} documents from ${collection}`)\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in deleteMany():`, error)\n }\n}\n\nconst deleteOne: DeleteOne = async function deleteOne(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] deleteOne() called with:', { collection, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:delete', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n returning: { exclude: [] },\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] deleteOne() failure',\n response.error?.message || response.error,\n )\n }\n\n const deletedDocs = response.result?.data || []\n const docId = deletedDocs.length > 0 ? deletedDocs[0].id : 'unknown'\n const result = deletedDocs.length > 0 ? deletedDocs[0] : {}\n\n console.log(`🗑️ [DB_CONTENT_API] Deleted document ${docId} from ${collection}`)\n console.log('[DB_CONTENT_API] deleteOne() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in deleteOne():`, error)\n return {}\n }\n}\n\nconst create: Create = async function create(\n this: ContentAPIAdapter,\n { collection, data, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] create() called with:', { collection, data, ...args })\n try {\n const randomKey = randomUUID()\n const response = await this.request<any>('/api/v0/documents:create', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n data,\n key: data.key || data.id || `doc-${randomKey}`,\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] create() failure', response.error?.message || response.error)\n }\n\n const result = response.result?.data || response.result || { id: `doc-${randomKey}`, ...data }\n console.log('[DB_CONTENT_API] create() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in create():`, error)\n return { id: `doc-${randomUUID()}`, ...data }\n }\n}\n\nconst count: Count = async function count(\n this: ContentAPIAdapter,\n { collection, req, where = {}, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] count() called with:', { collection, where, ...args })\n try {\n const response = await this.request<any>('/api/v0/documents:count', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n where: transformWhereClause(where),\n })\n\n if (response.error) {\n console.error('[DB_CONTENT_API] count() failure', response.error?.message || response.error)\n }\n\n const result = { totalDocs: response.result?.count || 0 }\n console.log('[DB_CONTENT_API] count() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in count():`, error)\n return { totalDocs: 0 }\n }\n}\n\nconst countVersions: CountVersions = async function countVersions(\n this: ContentAPIAdapter,\n { collection, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] countVersions() called with:', { collection, where, ...args })\n\n const result = { totalDocs: 0 }\n console.log('[DB_CONTENT_API] countVersions() result:', result)\n return result\n}\n\nconst upsert: Upsert = async function upsert(\n this: ContentAPIAdapter,\n { collection, data, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] upsert() called with:', { collection, data, where, ...args })\n try {\n // Try to update first\n const updateResponse = await this.request<any>('/api/v0/documents:update', {\n collectionKey: collection,\n contentSystemId: this.contentSystemId,\n createOnMissing: { documentKey: `upsert-${Date.now()}` },\n data,\n returning: { exclude: [] },\n where: transformWhereClause(where),\n })\n\n if (!updateResponse.success) {\n console.log('[DB_CONTENT_API] upsert() failure', updateResponse.error)\n }\n\n const result = updateResponse.result?.data || { ...data }\n console.log('[DB_CONTENT_API] upsert() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in upsert():`, error)\n return { ...data }\n }\n}\n\nconst createGlobal: CreateGlobal = async function createGlobal(\n this: ContentAPIAdapter,\n { slug, data, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] createGlobal() called with:', { slug, data, ...args })\n\n try {\n const globalKey = getGlobalSlug(slug)\n const response = await this.request<any>('/api/v0/documents:create', {\n collectionKey: globalKey,\n contentSystemId: this.contentSystemId,\n data,\n key: `global-${slug}`,\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] createGlobal() failure',\n response.error?.message || response.error,\n )\n }\n\n const result = response.result?.data || response.result || { id: `global-${slug}`, ...data }\n console.log('[DB_CONTENT_API] createGlobal() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in createGlobal():`, error)\n return { id: `global-${slug}`, ...data }\n }\n}\n\nconst findGlobal: FindGlobal = async function findGlobal(\n this: ContentAPIAdapter,\n { slug, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findGlobal() called with:', { slug, ...args })\n\n try {\n const globalKey = getGlobalSlug(slug)\n const response = await this.request<any>('/api/v0/documents:find', {\n collectionKey: globalKey,\n contentSystemId: this.contentSystemId,\n limit: 1,\n offset: 0,\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] findGlobal() failure',\n response.error?.message || response.error,\n )\n }\n\n const docs = response.result?.data || []\n const result = docs.length > 0 ? docs[0] : null\n console.log('[DB_CONTENT_API] findGlobal() result:', result)\n return formatDocument(result)\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in findGlobal():`, error)\n return null\n }\n}\n\nconst findDistinct: FindDistinct = async function findDistinct(\n this: ContentAPIAdapter,\n { collection, field, limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findDistinct() called with:', {\n collection,\n field,\n limit,\n page,\n where,\n ...args,\n })\n\n const distinctValues: any[] = []\n const paginatedValues: any[] = []\n const endIndex = 0\n const totalDocs = 0\n\n console.log(\n `📊 [DB_CONTENT_API] findDistinct result: ${distinctValues.length} distinct values for ${field}`,\n )\n\n return {\n hasNextPage: limit ? endIndex < totalDocs : false,\n hasPrevPage: page > 1,\n limit: limit || totalDocs,\n nextPage: limit && endIndex < totalDocs ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs,\n totalPages: limit ? Math.ceil(totalDocs / limit) : 1,\n values: paginatedValues,\n }\n}\n\nconst updateGlobal: UpdateGlobal = async function updateGlobal(\n this: ContentAPIAdapter,\n { slug, data, req, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateGlobal() called with:', { slug, data, ...args })\n\n try {\n const globalKey = getGlobalSlug(slug)\n const response = await this.request<any>('/api/v0/documents:update', {\n collectionKey: globalKey,\n contentSystemId: this.contentSystemId,\n createOnMissing: { documentKey: `global-${slug}` },\n data,\n returning: { exclude: [] },\n where: { operator: 'equals', path: 'key', value: `global-${slug}` },\n })\n\n if (response.error) {\n console.error(\n '[DB_CONTENT_API] updateGlobal() failure',\n response.error?.message || response.error,\n )\n }\n\n const result = response.result?.data || { id: `global-${slug}`, ...data }\n console.log('[DB_CONTENT_API] updateGlobal() result:', result)\n return result\n } catch (error) {\n console.error(`❌ [DB_CONTENT_API] Error in updateGlobal():`, error)\n return { id: `global-${slug}`, ...data }\n }\n}\n\nconst findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: ContentAPIAdapter,\n { limit, page = 1, req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] findGlobalVersions() called with:', {\n limit,\n page,\n where,\n ...args,\n })\n\n const docs: any[] = []\n const hasNextPage = false\n const result = {\n docs,\n hasNextPage,\n hasPrevPage: page > 1,\n limit: limit || docs.length,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter: 1,\n prevPage: page > 1 ? page - 1 : null,\n totalDocs: docs.length,\n totalPages: limit && docs.length ? Math.ceil(docs.length / limit) : 1,\n }\n console.log('[DB_CONTENT_API] findGlobalVersions() result:', result)\n return result\n}\n\nconst createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(\n this: ContentAPIAdapter,\n { req, versionData, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] createGlobalVersion() called with:', { versionData, ...args })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] createGlobalVersion() result:', result)\n return result\n}\n\nconst updateGlobalVersion: UpdateGlobalVersion = async function updateGlobalVersion(\n this: ContentAPIAdapter,\n { id, req, versionData, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] updateGlobalVersion() called with:', {\n id,\n versionData,\n ...args,\n })\n\n const result = {} as any\n console.log('[DB_CONTENT_API] updateGlobalVersion() result:', result)\n return result\n}\n\nconst countGlobalVersions: CountGlobalVersions = async function countGlobalVersions(\n this: ContentAPIAdapter,\n { req, where, ...args },\n) {\n console.log('🔍 [DB_CONTENT_API] countGlobalVersions() called with:', { where, ...args })\n\n const totalDocs = 0\n const globalVersionsSlug = 'global-versions'\n\n console.log(\n `📊 [DB_CONTENT_API] countGlobalVersions result: ${totalDocs} versions in ${globalVersionsSlug}`,\n )\n\n const result = { totalDocs }\n console.log('[DB_CONTENT_API] countGlobalVersions() result:', result)\n return result\n}\n\nconst request = async function <T = any>(\n this: ContentAPIAdapter,\n path: string,\n body = {},\n): Promise<T> {\n console.log('🔍 [DB_CONTENT_API] request() called with:', { body, path })\n const res = await fetch(`${this.contentApiUrl}${path}`, {\n body: JSON.stringify({\n contentSystemId: this.contentSystemId,\n ...body,\n }),\n headers: {\n 'Content-Type': 'application/json',\n ...(this.contentApiKey\n ? {\n 'X-Api-Key': this.contentApiKey,\n }\n : {\n Authorization: `Bearer ${this.projectToken}`,\n }),\n },\n method: 'POST',\n })\n\n return res.json() as T\n}\n\nconst beginTransaction: BeginTransaction = async function (options?: Record<string, any>) {\n console.log('🔍 [DB_CONTENT_API] beginTransaction() called', options)\n return null\n}\n\nconst commitTransaction: CommitTransaction = async function (\n id: number | Promise<number | string> | string,\n) {\n console.log('🔍 [DB_CONTENT_API] commitTransaction() called', id)\n}\n\nexport const contentAPIAdapter = (opts: ContentAPIDatabaseAdapterOptions): DatabaseAdapterObj => {\n return {\n name: 'content_api',\n defaultIDType: 'text',\n init: ({ payload }) => {\n return createDatabaseAdapter<ContentAPIAdapter>({\n name: 'content_api',\n beginTransaction,\n commitTransaction,\n contentApiKey: opts.contentApiKey,\n contentApiUrl: opts.contentApiUrl,\n contentSystemId: opts.contentSystemId,\n count,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createVersion,\n defaultIDType: 'text',\n deleteMany,\n deleteOne,\n deleteVersions,\n find,\n findDistinct,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n packageName: '@payloadcms/db-content-api',\n payload,\n projectToken: opts.projectToken,\n queryDrafts,\n request,\n rollbackTransaction: async () => {},\n updateGlobal,\n updateGlobalVersion,\n updateMany,\n updateOne,\n updateVersion,\n upsert,\n })\n },\n }\n}\n"],"names":["randomUUID","createDatabaseAdapter","slugIsGlobal","slug","startsWith","getGlobalSlug","transformWhereClause","where","undefined","and","map","filter","Boolean","or","transformedClauses","field","condition","Object","entries","Array","isArray","push","operator","value","path","length","formatDocument","doc","id","data","meta","_meta","init","console","log","payload","config","collections","c","collection","response","request","contentSystemId","key","error","warn","global","globals","globalKey","g","find","limit","page","req","sort","args","JSON","stringify","collectionKey","offset","flat","s","direction","values","keys","message","docs","result","pagination","totalDocs","total","actualLimit","totalPages","Math","ceil","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","findVersions","queryDrafts","createVersion","collectionSlug","versionData","updateVersion","deleteVersions","versionsToDelete","versionCollection","findOne","body","updateMany","createOnMissing","updateOne","whereClause","returning","exclude","deleteMany","deletedCount","count","deleteOne","deletedDocs","docId","create","randomKey","countVersions","upsert","updateResponse","documentKey","Date","now","success","createGlobal","findGlobal","findDistinct","distinctValues","paginatedValues","endIndex","updateGlobal","findGlobalVersions","createGlobalVersion","updateGlobalVersion","countGlobalVersions","globalVersionsSlug","res","fetch","contentApiUrl","headers","contentApiKey","Authorization","projectToken","method","json","beginTransaction","options","commitTransaction","contentAPIAdapter","opts","name","defaultIDType","packageName","rollbackTransaction"],"mappings":"AAqCA,SAASA,UAAU,QAAQ,SAAQ;AACnC,SAKEC,qBAAqB,QAEhB,UAAS;AAmBhB,MAAMC,eAAe,CAACC,OAAiBA,KAAKC,UAAU,CAAC;AAEvD,MAAMC,gBAAgB,CAACF,OAAiB,CAAC,QAAQ,EAAEA,MAAM;AAEzD,mEAAmE;AACnE,SAASG,qBAAqBC,KAAwB;IACpD,IAAI,CAACA,OAAO;QAC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["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAIrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAoDhE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAgDrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqDhE,CAAA"}
@@ -1,10 +1,49 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Button, useConfig } from '@payloadcms/ui';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useConfig } from '@payloadcms/ui';
4
4
  import { useSearchParams } from 'next/navigation.js';
5
5
  import React, { useEffect, useState } from 'react';
6
6
  import './index.scss';
7
7
  const baseClass = 'oauth-login';
8
+ // Figma logo SVG colored version
9
+ // const FigmaIcon: React.FC = () => (
10
+ // <svg fill="none" height="27" viewBox="0 0 400 600" width="18">
11
+ // <path
12
+ // d="M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z"
13
+ // fill="#24CB71"
14
+ // />
15
+ // <path
16
+ // d="M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z"
17
+ // fill="#FF7237"
18
+ // />
19
+ // <path
20
+ // d="M299.167 400C354.395 400 399.167 355.228 399.167 300C399.167 244.772 354.395 200 299.167 200C243.939 200 199.167 244.772 199.167 300C199.167 355.228 243.939 400 299.167 400Z"
21
+ // fill="#00B6FF"
22
+ // />
23
+ // <path
24
+ // d="M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z"
25
+ // fill="#FF3737"
26
+ // />
27
+ // <path
28
+ // d="M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z"
29
+ // fill="#874FFF"
30
+ // />
31
+ // </svg>
32
+ // )
33
+ // Figma logo SVG monochrome version
34
+ const FigmaIcon = ()=>/*#__PURE__*/ _jsx("svg", {
35
+ fill: "none",
36
+ height: "20px",
37
+ viewBox: "0 0 15 15",
38
+ width: "20px",
39
+ xmlns: "http://www.w3.org/2000/svg",
40
+ children: /*#__PURE__*/ _jsx("path", {
41
+ clipRule: "evenodd",
42
+ d: "M7.00005 2.04999H5.52505C4.71043 2.04999 4.05005 2.71037 4.05005 3.52499C4.05005 4.33961 4.71043 4.99999 5.52505 4.99999H7.00005V2.04999ZM7.00005 1.04999H8.00005H9.47505C10.842 1.04999 11.95 2.15808 11.95 3.52499C11.95 4.33163 11.5642 5.04815 10.9669 5.49999C11.5642 5.95184 11.95 6.66836 11.95 7.475C11.95 8.8419 10.842 9.95 9.47505 9.95C8.92236 9.95 8.41198 9.76884 8.00005 9.46266V9.95L8.00005 11.425C8.00005 12.7919 6.89195 13.9 5.52505 13.9C4.15814 13.9 3.05005 12.7919 3.05005 11.425C3.05005 10.6183 3.43593 9.90184 4.03317 9.44999C3.43593 8.99814 3.05005 8.28163 3.05005 7.475C3.05005 6.66836 3.43594 5.95184 4.03319 5.5C3.43594 5.04815 3.05005 4.33163 3.05005 3.52499C3.05005 2.15808 4.15814 1.04999 5.52505 1.04999H7.00005ZM8.00005 2.04999V4.99999H9.47505C10.2897 4.99999 10.95 4.33961 10.95 3.52499C10.95 2.71037 10.2897 2.04999 9.47505 2.04999H8.00005ZM5.52505 8.94998H7.00005L7.00005 7.4788L7.00005 7.475L7.00005 7.4712V6H5.52505C4.71043 6 4.05005 6.66038 4.05005 7.475C4.05005 8.28767 4.70727 8.94684 5.5192 8.94999L5.52505 8.94998ZM4.05005 11.425C4.05005 10.6123 4.70727 9.95315 5.5192 9.94999L5.52505 9.95H7.00005L7.00005 11.425C7.00005 12.2396 6.33967 12.9 5.52505 12.9C4.71043 12.9 4.05005 12.2396 4.05005 11.425ZM8.00005 7.47206C8.00164 6.65879 8.66141 6 9.47505 6C10.2897 6 10.95 6.66038 10.95 7.475C10.95 8.28962 10.2897 8.95 9.47505 8.95C8.66141 8.95 8.00164 8.29121 8.00005 7.47794V7.47206Z",
43
+ fill: "#FFFFFF",
44
+ fillRule: "evenodd"
45
+ })
46
+ });
8
47
  export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
9
48
  const { config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
10
49
  const [authorizeURL, setAuthorizeURL] = useState('');
@@ -40,11 +79,16 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
40
79
  }
41
80
  return /*#__PURE__*/ _jsx("div", {
42
81
  className: baseClass,
43
- children: /*#__PURE__*/ _jsx(Button, {
82
+ children: /*#__PURE__*/ _jsxs("a", {
44
83
  className: `${baseClass}__btn`,
45
- el: "anchor",
46
- url: authorizeURL,
47
- children: "Log in with Figma"
84
+ href: authorizeURL,
85
+ children: [
86
+ /*#__PURE__*/ _jsx(FigmaIcon, {}),
87
+ /*#__PURE__*/ _jsx("span", {
88
+ className: `${baseClass}__text`,
89
+ children: "Log in with Figma"
90
+ })
91
+ ]
48
92
  })
49
93
  });
50
94
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Button, useConfig } from '@payloadcms/ui'\nimport { useSearchParams } from 'next/navigation.js'\nimport React, { useEffect, useState } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-login'\n\ntype DefaultLoginButtonProps = {\n disabled?: boolean\n endpointSlug: string\n}\n\nexport const DefaultLoginButton: React.FC<DefaultLoginButtonProps> = ({\n disabled,\n endpointSlug,\n}: {\n disabled?: boolean\n endpointSlug: string\n}) => {\n const {\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [authorizeURL, setAuthorizeURL] = useState('')\n\n const searchParams = useSearchParams()\n const payloadRedirect = searchParams.get('redirect')\n\n useEffect(() => {\n if (payloadRedirect && !disabled) {\n // set cookie to redirect to the original page\n document.cookie = `payloadRedirect=${payloadRedirect}; path=/`\n }\n }, [payloadRedirect, disabled])\n\n useEffect(() => {\n const getAuthorizeURL = async () => {\n const serverURLFromWindow = window.location.origin\n const data = await fetch(\n `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`,\n ).then((res) => res.json())\n\n if (!disabled) {\n setAuthorizeURL(data.authorizeURL)\n }\n }\n\n void getAuthorizeURL()\n }, [api, serverURL, userSlug, disabled, endpointSlug])\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <Button className={`${baseClass}__btn`} el=\"anchor\" url={authorizeURL}>\n Log in with Figma\n </Button>\n </div>\n )\n}\n"],"names":["Button","useConfig","useSearchParams","React","useEffect","useState","baseClass","DefaultLoginButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","authorizeURL","setAuthorizeURL","searchParams","payloadRedirect","get","document","cookie","getAuthorizeURL","serverURLFromWindow","window","location","origin","data","fetch","then","res","json","div","className","el","url"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,SAAS,QAAQ,iBAAgB;AAClD,SAASC,eAAe,QAAQ,qBAAoB;AACpD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAOlB,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,QAAQ,EACRC,YAAY,EAIb;IACC,MAAM,EACJC,QAAQ,EACNC,OAAO,EAAEC,MAAMC,QAAQ,EAAE,EACzBC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGf;IACJ,MAAM,CAACgB,cAAcC,gBAAgB,GAAGb,SAAS;IAEjD,MAAMc,eAAejB;IACrB,MAAMkB,kBAAkBD,aAAaE,GAAG,CAAC;IAEzCjB,UAAU;QACR,IAAIgB,mBAAmB,CAACZ,UAAU;YAChC,8CAA8C;YAC9Cc,SAASC,MAAM,GAAG,CAAC,gBAAgB,EAAEH,gBAAgB,QAAQ,CAAC;QAChE;IACF,GAAG;QAACA;QAAiBZ;KAAS;IAE9BJ,UAAU;QACR,MAAMoB,kBAAkB;YACtB,MAAMC,sBAAsBC,OAAOC,QAAQ,CAACC,MAAM;YAClD,MAAMC,OAAO,MAAMC,MACjB,GAAGd,YAAYD,IAAI,CAAC,EAAEF,SAAS,CAAC,EAAEJ,aAAa,gBAAgB,EAAEgB,qBAAqB,EACtFM,IAAI,CAAC,CAACC,MAAQA,IAAIC,IAAI;YAExB,IAAI,CAACzB,UAAU;gBACbU,gBAAgBW,KAAKZ,YAAY;YACnC;QACF;QAEA,KAAKO;IACP,GAAG;QAACT;QAAKC;QAAWH;QAAUL;QAAUC;KAAa;IAErD,IAAID,UAAU;QACZ,OAAO;IACT;IAEA,qBACE,KAAC0B;QAAIC,WAAW7B;kBACd,cAAA,KAACN;YAAOmC,WAAW,GAAG7B,UAAU,KAAK,CAAC;YAAE8B,IAAG;YAASC,KAAKpB;sBAAc;;;AAK7E,EAAC"}
1
+ {"version":3,"sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { useConfig } from '@payloadcms/ui'\nimport { useSearchParams } from 'next/navigation.js'\nimport React, { useEffect, useState } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-login'\n\n// Figma logo SVG colored version\n// const FigmaIcon: React.FC = () => (\n// <svg fill=\"none\" height=\"27\" viewBox=\"0 0 400 600\" width=\"18\">\n// <path\n// d=\"M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z\"\n// fill=\"#24CB71\"\n// />\n// <path\n// d=\"M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z\"\n// fill=\"#FF7237\"\n// />\n// <path\n// d=\"M299.167 400C354.395 400 399.167 355.228 399.167 300C399.167 244.772 354.395 200 299.167 200C243.939 200 199.167 244.772 199.167 300C199.167 355.228 243.939 400 299.167 400Z\"\n// fill=\"#00B6FF\"\n// />\n// <path\n// d=\"M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z\"\n// fill=\"#FF3737\"\n// />\n// <path\n// d=\"M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z\"\n// fill=\"#874FFF\"\n// />\n// </svg>\n// )\n\n// Figma logo SVG monochrome version\nconst FigmaIcon: React.FC = () => (\n <svg\n fill=\"none\"\n height=\"20px\"\n viewBox=\"0 0 15 15\"\n width=\"20px\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n clipRule=\"evenodd\"\n d=\"M7.00005 2.04999H5.52505C4.71043 2.04999 4.05005 2.71037 4.05005 3.52499C4.05005 4.33961 4.71043 4.99999 5.52505 4.99999H7.00005V2.04999ZM7.00005 1.04999H8.00005H9.47505C10.842 1.04999 11.95 2.15808 11.95 3.52499C11.95 4.33163 11.5642 5.04815 10.9669 5.49999C11.5642 5.95184 11.95 6.66836 11.95 7.475C11.95 8.8419 10.842 9.95 9.47505 9.95C8.92236 9.95 8.41198 9.76884 8.00005 9.46266V9.95L8.00005 11.425C8.00005 12.7919 6.89195 13.9 5.52505 13.9C4.15814 13.9 3.05005 12.7919 3.05005 11.425C3.05005 10.6183 3.43593 9.90184 4.03317 9.44999C3.43593 8.99814 3.05005 8.28163 3.05005 7.475C3.05005 6.66836 3.43594 5.95184 4.03319 5.5C3.43594 5.04815 3.05005 4.33163 3.05005 3.52499C3.05005 2.15808 4.15814 1.04999 5.52505 1.04999H7.00005ZM8.00005 2.04999V4.99999H9.47505C10.2897 4.99999 10.95 4.33961 10.95 3.52499C10.95 2.71037 10.2897 2.04999 9.47505 2.04999H8.00005ZM5.52505 8.94998H7.00005L7.00005 7.4788L7.00005 7.475L7.00005 7.4712V6H5.52505C4.71043 6 4.05005 6.66038 4.05005 7.475C4.05005 8.28767 4.70727 8.94684 5.5192 8.94999L5.52505 8.94998ZM4.05005 11.425C4.05005 10.6123 4.70727 9.95315 5.5192 9.94999L5.52505 9.95H7.00005L7.00005 11.425C7.00005 12.2396 6.33967 12.9 5.52505 12.9C4.71043 12.9 4.05005 12.2396 4.05005 11.425ZM8.00005 7.47206C8.00164 6.65879 8.66141 6 9.47505 6C10.2897 6 10.95 6.66038 10.95 7.475C10.95 8.28962 10.2897 8.95 9.47505 8.95C8.66141 8.95 8.00164 8.29121 8.00005 7.47794V7.47206Z\"\n fill=\"#FFFFFF\"\n fillRule=\"evenodd\"\n />\n </svg>\n)\n\ntype DefaultLoginButtonProps = {\n disabled?: boolean\n endpointSlug: string\n}\n\nexport const DefaultLoginButton: React.FC<DefaultLoginButtonProps> = ({\n disabled,\n endpointSlug,\n}: {\n disabled?: boolean\n endpointSlug: string\n}) => {\n const {\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [authorizeURL, setAuthorizeURL] = useState('')\n\n const searchParams = useSearchParams()\n const payloadRedirect = searchParams.get('redirect')\n\n useEffect(() => {\n if (payloadRedirect && !disabled) {\n // set cookie to redirect to the original page\n document.cookie = `payloadRedirect=${payloadRedirect}; path=/`\n }\n }, [payloadRedirect, disabled])\n\n useEffect(() => {\n const getAuthorizeURL = async () => {\n const serverURLFromWindow = window.location.origin\n const data = await fetch(\n `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`,\n ).then((res) => res.json())\n\n if (!disabled) {\n setAuthorizeURL(data.authorizeURL)\n }\n }\n\n void getAuthorizeURL()\n }, [api, serverURL, userSlug, disabled, endpointSlug])\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <a className={`${baseClass}__btn`} href={authorizeURL}>\n <FigmaIcon />\n <span className={`${baseClass}__text`}>Log in with Figma</span>\n </a>\n </div>\n )\n}\n"],"names":["useConfig","useSearchParams","React","useEffect","useState","baseClass","FigmaIcon","svg","fill","height","viewBox","width","xmlns","path","clipRule","d","fillRule","DefaultLoginButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","authorizeURL","setAuthorizeURL","searchParams","payloadRedirect","get","document","cookie","getAuthorizeURL","serverURLFromWindow","window","location","origin","data","fetch","then","res","json","div","className","a","href","span"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,qBAAoB;AACpD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,iCAAiC;AACjC,sCAAsC;AACtC,mEAAmE;AACnE,YAAY;AACZ,oHAAoH;AACpH,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,2FAA2F;AAC3F,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,0LAA0L;AAC1L,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,mFAAmF;AACnF,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,wFAAwF;AACxF,uBAAuB;AACvB,SAAS;AACT,WAAW;AACX,IAAI;AAEJ,oCAAoC;AACpC,MAAMC,YAAsB,kBAC1B,KAACC;QACCC,MAAK;QACLC,QAAO;QACPC,SAAQ;QACRC,OAAM;QACNC,OAAM;kBAEN,cAAA,KAACC;YACCC,UAAS;YACTC,GAAE;YACFP,MAAK;YACLQ,UAAS;;;AAUf,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,QAAQ,EACRC,YAAY,EAIb;IAC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