sharetribe-community-cli 1.16.13 → 1.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/commands/version.ts", "../src/commands/login.ts", "../src/commands/logout.ts", "../src/commands/process/list.ts", "../src/util/output.ts", "../src/commands/process/create.ts", "../src/util/process-files.ts", "../src/commands/process/push.ts", "../src/commands/process/pull.ts", "../src/commands/process/aliases.ts", "../src/commands/process/combined.ts", "../src/commands/process/index.ts", "../src/commands/search/index.ts", "../src/commands/assets/index.ts", "../src/commands/notifications/index.ts", "../src/commands/listing-approval.ts", "../src/commands/events/index.ts", "../src/commands/stripe/index.ts", "../src/commands/debug.ts", "../src/util/help-formatter.ts", "../src/util/command-router.ts"],
4
- "sourcesContent": ["/**\n * Sharetribe CLI - Unofficial 100% compatible implementation\n *\n * Main entry point for the CLI application\n */\n\nimport { Command } from 'commander';\nimport { readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\nimport chalk from 'chalk';\nimport { resolveConfigDir } from 'sharetribe-flex-build-sdk';\nimport { version } from './commands/version.js';\nimport { login } from './commands/login.js';\nimport { logout } from './commands/logout.js';\nimport { registerProcessCommands } from './commands/process/index.js';\nimport { registerSearchCommands } from './commands/search/index.js';\nimport { registerAssetsCommands } from './commands/assets/index.js';\nimport { registerNotificationsCommands } from './commands/notifications/index.js';\nimport { registerListingApprovalCommand } from './commands/listing-approval.js';\nimport { registerEventsCommand } from './commands/events/index.js';\nimport { registerStripeCommands } from './commands/stripe/index.js';\nimport { debug } from './commands/debug.js';\nimport { configureHelp } from './util/help-formatter.js';\nimport { routeProcessCommand } from './util/command-router.js';\n\n// Get package.json for version info\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(\n readFileSync(join(__dirname, '../package.json'), 'utf-8')\n);\n\n// Print unofficial notice to stderr on first run only\nconst configDir = resolveConfigDir();\nconst noticeShownMarker = join(configDir, '.sharetribe-community-cli-notice-shown');\nif (!existsSync(noticeShownMarker)) {\n console.error(chalk.yellow('\u26A0\uFE0F NOTICE: This is an UNOFFICIAL Sharetribe CLI (community reimplementation).'));\n console.error(chalk.yellow(' For the official CLI, install: ') + chalk.cyan('npm install -g flex-cli') + '\\n');\n try {\n mkdirSync(configDir, { recursive: true });\n writeFileSync(noticeShownMarker, new Date().toISOString());\n } catch {\n // Ignore errors writing marker file\n }\n}\n\n// Route argv to handle process subcommands\nconst routedArgv = routeProcessCommand(process.argv);\n\nconst program = new Command();\n\n// Configure custom help formatter to match flex-cli\nconfigureHelp(program);\n\n// Configure output to add trailing newline (flex-cli behavior)\nprogram.configureOutput({\n writeOut: (str) => process.stdout.write(str + '\\n'),\n writeErr: (str) => process.stderr.write(str + '\\n'),\n});\n\n// Configure the main program\nprogram\n .name('sharetribe-community-cli')\n .description('CLI to interact with Sharetribe Flex')\n .version(packageJson.version, '-V', 'output the version number')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n// Register commands\n\n// version command\nprogram\n .command('version')\n .description('show version')\n .action(() => {\n version();\n });\n\n// login command\nprogram\n .command('login')\n .description('log in with API key')\n .action(async () => {\n await login();\n });\n\n// logout command\nprogram\n .command('logout')\n .description('logout')\n .action(async () => {\n await logout();\n });\n\n// debug command\nprogram\n .command('debug')\n .description('display debug info')\n .action(() => {\n debug();\n });\n\n// Register process commands\nregisterProcessCommands(program);\n\n// Register search commands\nregisterSearchCommands(program);\n\n// Register assets commands\nregisterAssetsCommands(program);\n\n// Register notifications commands\nregisterNotificationsCommands(program);\n\n// Register listing-approval command\nregisterListingApprovalCommand(program);\n\n// Register events command\nregisterEventsCommand(program);\n\n// Register stripe commands\nregisterStripeCommands(program);\n\n// Register custom help command (to support \"help process list\" syntax)\nprogram\n .command('help [command...]')\n .description('display help for Flex CLI')\n .action((commandPath: string[]) => {\n if (!commandPath || commandPath.length === 0) {\n program.outputHelp();\n return;\n }\n\n // Navigate to the nested command\n let targetCmd: Command = program;\n for (const cmdName of commandPath) {\n const subCmd = targetCmd.commands.find(c => c.name() === cmdName);\n if (!subCmd) {\n console.error(`Unknown command: ${commandPath.join(' ')}`);\n process.exitCode = 1; return;\n }\n targetCmd = subCmd;\n }\n\n // Show help for the target command\n targetCmd.outputHelp();\n });\n\n// If no command specified, show help and exit with status 0\nif (!routedArgv.slice(2).length) {\n program.outputHelp();\n // Don't call process.exit() - let Commander handle it naturally with exitOverride\n} else {\n // Parse command line arguments with routed argv\n program.parse(routedArgv);\n}\n", "/**\n * Version command - displays the CLI version\n *\n * Must match flex-cli output format exactly\n */\n\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\n/**\n * Finds package.json by traversing up from current file\n */\nfunction findPackageJson(): string {\n const __filename = fileURLToPath(import.meta.url);\n let currentDir = dirname(__filename);\n\n // Traverse up to find package.json\n while (currentDir !== '/') {\n try {\n const pkgPath = join(currentDir, 'package.json');\n const content = readFileSync(pkgPath, 'utf-8');\n return content;\n } catch {\n currentDir = dirname(currentDir);\n }\n }\n\n throw new Error('Could not find package.json');\n}\n\n/**\n * Displays the version of the CLI\n *\n * Output must match flex-cli exactly\n */\nexport function version(): void {\n const packageJson = JSON.parse(findPackageJson());\n console.log(packageJson.version);\n}\n", "/**\n * Login command - interactive API key authentication\n *\n * Must match flex-cli behavior exactly:\n * - Prompt for API key\n * - Store in flex-cli's auth.edn (XDG_CONFIG_HOME, %LOCALAPPDATA% on Windows, else ~/.config)\n * - Display admin email on success\n */\n\nimport inquirer from 'inquirer';\nimport { writeAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the login command\n *\n * Prompts for API key and stores it in auth.edn\n */\nexport async function login(): Promise<void> {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n name: 'apiKey',\n message: 'Enter API key:',\n mask: '*',\n validate: (input: string) => {\n if (!input || input.trim().length === 0) {\n return 'API key cannot be empty';\n }\n return true;\n },\n },\n ]);\n\n // Store the API key\n writeAuth({ apiKey: answers.apiKey });\n\n // TODO: Validate API key by making a test request to get admin email\n // For now, just confirm storage\n console.log('Successfully logged in.');\n\n // Note: flex-cli displays admin email after successful login\n // We'll need to implement API client to fetch this\n}\n", "/**\n * Logout command - clears authentication\n *\n * Must match flex-cli behavior exactly\n */\n\nimport { clearAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the logout command\n *\n * Clears auth.edn file\n */\nexport async function logout(): Promise<void> {\n await clearAuth();\n console.log('Successfully logged out.');\n}\n", "/**\n * Process list command - lists all transaction processes\n */\n\nimport {\n listProcesses as sdkListProcesses,\n listProcessVersions as sdkListProcessVersions,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\n\n/**\n * Formats timestamp to match flex-cli format for process list\n */\nfunction formatProcessTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Lists all processes for a marketplace\n */\nexport async function listProcesses(marketplace: string, processName?: string): Promise<void> {\n try {\n // If processName is specified, show version history for that process\n if (processName) {\n const versions = await sdkListProcessVersions(undefined, marketplace, processName);\n\n if (versions.length === 0) {\n console.log(`No versions found for process: ${processName}`);\n return;\n }\n\n const versionRows = versions.map((v) => ({\n 'Created': formatProcessTimestamp(v.createdAt),\n 'Version': v.version.toString(),\n 'Aliases': v.aliases?.join(', ') || '',\n 'Transactions': v.transactionCount?.toString() || '0',\n }));\n\n printTable(['Created', 'Version', 'Aliases', 'Transactions'], versionRows);\n } else {\n // List all processes\n const processes = await sdkListProcesses(undefined, marketplace);\n\n if (processes.length === 0) {\n console.log('No processes found.');\n return;\n }\n\n const processRows = processes.map((p) => ({\n 'Name': p.name,\n 'Latest version': p.version?.toString() || '',\n }));\n\n printTable(['Name', 'Latest version'], processRows);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list processes');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Output formatting utilities\n *\n * Must match flex-cli output format exactly\n */\n\nimport chalk from 'chalk';\n\n/**\n * Prints a table with headers and rows\n *\n * Matches flex-cli table formatting exactly\n */\nexport function printTable(headers: string[], rows: Array<Record<string, string>>): void {\n if (rows.length === 0) {\n return;\n }\n\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const header of headers) {\n widths[header] = header.length + 1; // +1 to match flex-cli keyword string behavior\n }\n\n for (const row of rows) {\n for (const header of headers) {\n const value = row[header] || '';\n widths[header] = Math.max(widths[header] || 0, value.length);\n }\n }\n\n // Print empty line before table (like flex-cli)\n console.log('');\n\n // Print header with bold formatting\n // flex-cli format: each column padded to (max_width + 1), with single space separator between columns\n // Last column: padding but no separator (interpose doesn't add separator after last element)\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = h.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const headerRow = headerParts.join('');\n console.log(chalk.bold.black(headerRow));\n\n // Print rows with same formatting\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const rowStr = rowParts.join('');\n console.log(rowStr);\n }\n\n // Print empty line after table (like flex-cli)\n console.log('');\n}\n\n/**\n * Prints an error message\n */\nexport function printError(message: string): void {\n console.error(chalk.red(`Error: ${message}`));\n}\n\n/**\n * Prints a success message\n */\nexport function printSuccess(message: string): void {\n console.log(chalk.green(message));\n}\n\n/**\n * Prints a warning message\n *\n * Goes to stderr, as flex-cli's ppd-err does, so that a warning never lands in\n * output a script is capturing: deploy-test.sh compares a push's whole stdout\n * against \"No changes\".\n */\nexport function printWarning(message: string): void {\n console.error(chalk.yellow(`Warning: ${message}`));\n}\n", "/**\n * Process create command\n */\n\nimport { createProcess as sdkCreateProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport {\n ensureProcessDir,\n ensureTemplates,\n processFilePath,\n readTemplates,\n} from '../../util/process-files.js';\nimport { readFileSync } from 'node:fs';\n\n/**\n * Creates a new transaction process\n */\nexport async function createProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n ensureProcessDir(path);\n\n const definition = readFileSync(processFilePath(path), 'utf-8');\n const templates = readTemplates(path);\n ensureTemplates(path, templates);\n\n const result = await sdkCreateProcess(\n undefined,\n marketplace,\n processName,\n definition,\n templates\n );\n\n printSuccess(`Process ${result.name} successfully created.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create process');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process directory helpers\n *\n * Mirrors what upstream flex-cli does before it uploads a process: locate the\n * process.edn file, read the templates directory, and check that every\n * notification the process declares has a template on disk. Upstream splits\n * this between io-util and process-util; there is little enough of it to keep\n * it in one place here.\n */\n\nimport { readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { parseProcessFile, type ProcessTemplate } from 'sharetribe-flex-build-sdk';\nimport { printWarning } from './output.js';\n\n/**\n * Returns the path of the process.edn file inside a process directory.\n */\nexport function processFilePath(path: string): string {\n return join(path, 'process.edn');\n}\n\n/**\n * Throws unless the given path is a process directory, i.e. one holding a\n * process.edn file. Matches upstream's ensure-process-dir!.\n */\nexport function ensureProcessDir(path: string): void {\n try {\n if (statSync(processFilePath(path)).isFile()) return;\n } catch {\n // Fall through to the same error a non-file gives.\n }\n throw new Error('--path should be a process directory');\n}\n\n/**\n * Reads the email templates that sit under <path>/templates, each in its own\n * directory holding <name>-html.html and <name>-subject.txt.\n */\nexport function readTemplates(path: string): ProcessTemplate[] {\n const templatesDir = join(path, 'templates');\n const templates: ProcessTemplate[] = [];\n\n let templateNames: string[];\n try {\n templateNames = readdirSync(templatesDir);\n } catch {\n return templates;\n }\n\n for (const name of templateNames) {\n const templateDir = join(templatesDir, name);\n try {\n templates.push({\n name,\n html: readFileSync(join(templateDir, `${name}-html.html`), 'utf-8'),\n subject: readFileSync(join(templateDir, `${name}-subject.txt`), 'utf-8'),\n });\n } catch {\n // A directory without both halves is not a template.\n }\n }\n\n return templates;\n}\n\n/**\n * Checks the templates on disk against the notifications the process declares:\n * a notification whose template is missing is an error, a template nothing\n * refers to is a warning. This is the only reason the process file is parsed;\n * what gets uploaded is always the file's own text. Matches upstream's\n * ensure-templates!.\n */\nexport function ensureTemplates(path: string, templates: ProcessTemplate[]): void {\n const { notifications } = parseProcessFile(processFilePath(path));\n const templateNames = new Set(templates.map((t) => t.name));\n const usedNames = new Set(notifications.map((n) => n.template));\n\n for (const name of templateNames) {\n if (!usedNames.has(name)) {\n printWarning(`template exists but is not used in the process: ${name}`);\n }\n }\n\n const missing = notifications.filter((n) => !templateNames.has(n.template));\n if (missing.length > 0) {\n throw new Error(\n missing\n .map((n) => `Template ${n.template} not found for notification ${unqualified(n.name)}`)\n .join('\\n')\n );\n }\n}\n\n/**\n * Drops a keyword's namespace, so :notification/booking-accepted reads as\n * booking-accepted. parseProcessFile keeps the namespace; flex-cli's error\n * message does not.\n */\nfunction unqualified(keyword: string): string {\n return keyword.slice(keyword.indexOf('/') + 1);\n}\n", "/**\n * Process push command\n */\n\nimport { pushProcess as sdkPushProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport {\n ensureProcessDir,\n ensureTemplates,\n processFilePath,\n readTemplates,\n} from '../../util/process-files.js';\nimport { readFileSync } from 'node:fs';\n\n/**\n * Pushes a new version of an existing process\n */\nexport async function pushProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n ensureProcessDir(path);\n\n const definition = readFileSync(processFilePath(path), 'utf-8');\n const templates = readTemplates(path);\n ensureTemplates(path, templates);\n\n const result = await sdkPushProcess(undefined, marketplace, processName, definition, templates);\n\n if (result.noChanges) {\n console.log('No changes');\n } else {\n printSuccess(`Version ${result.version} successfully saved for process ${processName}`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push process');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process pull command\n */\n\nimport { getProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { writeFileSync, mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Pulls a process from the server\n */\nexport async function pullProcess(\n marketplace: string,\n processName: string,\n path: string,\n version?: string,\n alias?: string\n): Promise<void> {\n try {\n const process = await getProcess(undefined, marketplace, processName, { version, alias });\n\n if (!process.definition) {\n throw new Error('No process definition in response');\n }\n\n // Ensure directory exists (print message if creating new directory)\n const { existsSync } = await import('node:fs');\n const dirExists = existsSync(path);\n mkdirSync(path, { recursive: true });\n\n if (!dirExists) {\n console.error(`Creating a new directory: ${path}`);\n }\n\n // Write process.edn file\n const processFilePath = join(path, 'process.edn');\n writeFileSync(processFilePath, process.definition, 'utf-8');\n\n // Write email templates if they exist\n const templates = process.emailTemplates || [];\n\n if (templates && Array.isArray(templates) && templates.length > 0) {\n const templatesDir = join(path, 'templates');\n mkdirSync(templatesDir, { recursive: true });\n\n for (const template of templates) {\n const templateName = template.name;\n const htmlContent = template.html;\n const subjectContent = template.subject;\n\n if (templateName) {\n // Create subdirectory for this template\n const templateSubdir = join(templatesDir, templateName);\n mkdirSync(templateSubdir, { recursive: true });\n\n // Write HTML file\n if (htmlContent) {\n const htmlPath = join(templateSubdir, `${templateName}-html.html`);\n writeFileSync(htmlPath, htmlContent, 'utf-8');\n }\n\n // Write subject file\n if (subjectContent) {\n const subjectPath = join(templateSubdir, `${templateName}-subject.txt`);\n writeFileSync(subjectPath, subjectContent, 'utf-8');\n }\n }\n }\n }\n\n console.error(`Saved process to ${path}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull process');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process alias commands\n */\n\nimport {\n createAlias as sdkCreateAlias,\n updateAlias as sdkUpdateAlias,\n deleteAlias as sdkDeleteAlias\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\n\n/**\n * Creates a process alias\n */\nexport async function createAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkCreateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully created to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create alias');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Updates a process alias\n */\nexport async function updateAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkUpdateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully updated to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update alias');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Deletes a process alias\n */\nexport async function deleteAlias(\n marketplace: string,\n processName: string,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkDeleteAlias(undefined, marketplace, processName, alias);\n\n printSuccess(`Alias ${result.alias} successfully deleted.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to delete alias');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Combined process command - create-or-push-and-create-or-update-alias\n *\n * Composes the SDK's endpoint primitives rather than calling a high-level SDK\n * helper: the SDK is a one-function-per-endpoint surface, and this workflow is\n * the CLI's own.\n */\n\nimport {\n createAlias,\n createProcess,\n listProcessVersions,\n pushProcess,\n updateAlias,\n type ProcessVersion,\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport {\n ensureProcessDir,\n ensureTemplates,\n processFilePath,\n readTemplates,\n} from '../../util/process-files.js';\nimport { readFileSync } from 'node:fs';\n\n/**\n * Reads a process's versions, or returns null when the marketplace has no\n * process by that name.\n *\n * This one call decides everything the command branches on: whether the\n * process exists at all, and, because aliases sit on the versions they point\n * at, whether the alias already exists. Catching a create or a push failure\n * would not, since getProcess cannot tell \"no such process\" from \"no such\n * alias\".\n */\nasync function readVersions(\n marketplace: string,\n processName: string\n): Promise<ProcessVersion[] | null> {\n try {\n return await listProcessVersions(undefined, marketplace, processName);\n } catch (error) {\n if (error && typeof error === 'object' && (error as { code?: string }).code === 'tx-process-not-found') {\n return null;\n }\n throw error;\n }\n}\n\n/**\n * Creates or pushes a process and creates or updates an alias\n *\n * Prints exactly what the equivalent flex-cli commands print for each step it\n * performs, so scripts that grep the output of process create, process push\n * and the alias commands read this command's output the same way.\n */\nexport async function createOrPushAndCreateOrUpdateAlias(\n marketplace: string,\n processName: string,\n path: string,\n alias: string\n): Promise<void> {\n try {\n ensureProcessDir(path);\n\n // The file's own text is what gets uploaded. The parse inside\n // ensureTemplates only checks that the notifications' templates are on disk.\n const definition = readFileSync(processFilePath(path), 'utf-8');\n const templates = readTemplates(path);\n ensureTemplates(path, templates);\n\n const versions = await readVersions(marketplace, processName);\n\n if (versions === null) {\n const created = await createProcess(\n undefined,\n marketplace,\n processName,\n definition,\n templates\n );\n printSuccess(`Process ${created.name} successfully created.`);\n\n const aliasResult = await createAlias(\n undefined,\n marketplace,\n processName,\n created.version,\n alias\n );\n printSuccess(\n `Alias ${aliasResult.alias} successfully created to point to version ${aliasResult.version}.`\n );\n return;\n }\n\n const aliasExists = versions.some((v) => v.aliases?.includes(alias));\n\n const pushed = await pushProcess(\n undefined,\n marketplace,\n processName,\n definition,\n templates\n );\n\n let version: number;\n if (pushed.noChanges) {\n // Nothing to push means the file already matches the newest version, so\n // that is the version the alias should point at.\n console.log('No changes');\n version = Math.max(...versions.map((v) => v.version));\n } else if (pushed.version === undefined) {\n throw new Error(`The API saved a version of ${processName} but did not say which`);\n } else {\n version = pushed.version;\n printSuccess(`Version ${version} successfully saved for process ${processName}`);\n }\n\n if (aliasExists) {\n const aliasResult = await updateAlias(undefined, marketplace, processName, version, alias);\n printSuccess(\n `Alias ${aliasResult.alias} successfully updated to point to version ${aliasResult.version}.`\n );\n } else {\n const aliasResult = await createAlias(undefined, marketplace, processName, version, alias);\n printSuccess(\n `Alias ${aliasResult.alias} successfully created to point to version ${aliasResult.version}.`\n );\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create/push process and alias');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process command - main entry point for process subcommands\n */\n\nimport { Command } from 'commander';\nimport { listProcesses } from './list.js';\nimport { createProcess } from './create.js';\nimport { pushProcess } from './push.js';\nimport { pullProcess } from './pull.js';\nimport { createAlias, updateAlias, deleteAlias } from './aliases.js';\nimport { createOrPushAndCreateOrUpdateAlias } from './combined.js';\n\n/**\n * Registers all process subcommands\n */\nexport function registerProcessCommands(program: Command): void {\n // Register the parent 'process' command for help display\n const processCmd = program\n .command('process')\n .description('describe a process file')\n .option('--path <PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('--transition <TRANSITION_NAME>', 'transition name, e.g. transition/request to get more details of it')\n .action(async (options) => {\n // Process describe functionality\n if (options.path) {\n console.log(`Describing process at: ${options.path}`);\n if (options.transition) {\n console.log(`Transition: ${options.transition}`);\n }\n // TODO: Implement actual process file parsing and description\n console.log('Process description not yet implemented');\n } else {\n // If no options, show help\n processCmd.outputHelp();\n }\n });\n\n // Register subcommands - these are registered as BOTH subcommands (for help) and top-level (for routing)\n\n // process list (as subcommand)\n processCmd\n .command('list')\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await listProcesses(marketplace, options.process);\n });\n\n // process create\n processCmd\n .command('create')\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n // process push\n processCmd\n .command('push')\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n // process pull\n processCmd\n .command('pull')\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n // process create-alias\n processCmd\n .command('create-alias')\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .allowUnknownOption(false)\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process update-alias\n processCmd\n .command('update-alias')\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process delete-alias\n processCmd\n .command('delete-alias')\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n // process deploy (combined command: create-or-push-and-create-or-update-alias)\n processCmd\n .command('deploy')\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n\n // Register top-level command aliases for routing (hidden from help)\n // These handle the routed commands like 'process-pull' that avoid Commander's parent/child option conflicts\n\n program\n .command('process-list', { hidden: true })\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await listProcesses(marketplace, options.process);\n });\n\n program\n .command('process-create', { hidden: true })\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-push', { hidden: true })\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-pull', { hidden: true })\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n program\n .command('process-create-alias', { hidden: true })\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-update-alias', { hidden: true })\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-delete-alias', { hidden: true })\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n program\n .command('process-deploy', { hidden: true })\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n}\n", "/**\n * Search command - manage search schemas\n */\n\nimport { Command } from 'commander';\nimport {\n listSearchSchemas as sdkListSearchSchemas,\n setSearchSchema as sdkSetSearchSchema,\n unsetSearchSchema as sdkUnsetSearchSchema,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\ninterface SetSchemaOptions {\n key: string;\n scope: string;\n type: string;\n doc?: string;\n default?: string;\n schemaFor?: string;\n}\n\ninterface UnsetSchemaOptions {\n key: string;\n scope: string;\n schemaFor?: string;\n}\n\n/**\n * Scope label mapping\n */\nconst SCOPE_LABELS: Record<string, string> = {\n metadata: 'Metadata',\n private: 'Private data',\n protected: 'Protected data',\n public: 'Public data',\n};\n\n/**\n * Sets a search schema field\n */\nasync function setSearchSchema(marketplace: string, opts: SetSchemaOptions): Promise<void> {\n try {\n await sdkSetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n defaultValue: opts.default,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully set for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to set search schema');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Unsets a search schema field\n */\nasync function unsetSearchSchema(marketplace: string, opts: UnsetSchemaOptions): Promise<void> {\n try {\n await sdkUnsetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully unset for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to unset search schema');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Converts default value to display string\n */\nfunction getDefaultValueLabel(value: unknown): string {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value.join(', ');\n }\n\n return String(value);\n}\n\n/**\n * Lists all search schemas\n */\nasync function listSearchSchemas(marketplace: string): Promise<void> {\n try {\n const schemas = await sdkListSearchSchemas(undefined, marketplace);\n\n if (schemas.length === 0) {\n console.log('No search schemas found.');\n return;\n }\n\n // Map and sort the data (by schema-for, scope, key)\n const rows = schemas\n .map((s) => ({\n 'Schema for': s.schemaFor,\n 'Scope': s.scope,\n 'Key': s.key,\n 'Type': s.type,\n 'Default value': getDefaultValueLabel(s.defaultValue),\n 'Doc': s.doc || '',\n }))\n .sort((a, b) => {\n // Sort by schema-for, then scope, then key\n if (a['Schema for'] !== b['Schema for']) {\n return a['Schema for'].localeCompare(b['Schema for']);\n }\n if (a['Scope'] !== b['Scope']) {\n return a['Scope'].localeCompare(b['Scope']);\n }\n return a['Key'].localeCompare(b['Key']);\n });\n\n // Print table using flex-cli compatible formatting\n const headers = ['Schema for', 'Scope', 'Key', 'Type', 'Default value', 'Doc'];\n\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const h of headers) {\n widths[h] = h.length + 1;\n }\n for (const row of rows) {\n for (const h of headers) {\n const value = row[h] || '';\n widths[h] = Math.max(widths[h], value.length);\n }\n }\n\n // Print empty line before table\n console.log('');\n\n // Print header\n // flex-cli search format: each column padded to max_width, with 2 space separator between columns\n // Last column: padding with trailing space\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = h.padEnd(width);\n return i === headers.length - 1 ? padded + ' ' : padded + ' ';\n });\n console.log(headerParts.join(''));\n\n // Print rows\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width);\n return i === headers.length - 1 ? padded + ' ' : padded + ' ';\n });\n console.log(rowParts.join(''));\n }\n\n // Print empty line after table\n console.log('');\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list search schemas');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers search commands\n */\nexport function registerSearchCommands(program: Command): void {\n const searchCmd = program\n .command('search')\n .description('list all search schemas')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await listSearchSchemas(marketplace);\n });\n\n // search set\n searchCmd\n .command('set')\n .description('set search schema')\n .requiredOption('--key <KEY>', 'key name')\n .requiredOption(\n '--scope <SCOPE>',\n 'extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)'\n )\n .requiredOption('--type <TYPE>', 'value type (either enum, multi-enum, boolean, long or text)')\n .option('--doc <DOC>', 'description of the schema')\n .option('--default <DEFAULT>', 'default value for search if value is not set')\n .option(\n '--schema-for <SCHEMA_FOR>',\n 'Subject of the schema (either listing, userProfile or transaction, defaults to listing)'\n )\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await setSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n default: opts.default,\n schemaFor: opts.schemaFor,\n });\n });\n\n // search unset\n searchCmd\n .command('unset')\n .description('unset search schema')\n .requiredOption('--key <KEY>', 'key name')\n .requiredOption(\n '--scope <SCOPE>',\n 'extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)'\n )\n .option(\n '--schema-for <SCHEMA_FOR>',\n 'Subject of the schema (either listing, userProfile or transaction, defaults to listing)'\n )\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await unsetSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n });\n}\n", "/**\n * Assets commands - manage marketplace assets\n */\n\nimport { Command } from 'commander';\nimport {\n pushAssets as sdkPushAssets,\n stageAsset as sdkStageAsset,\n getApiBaseUrl,\n readAuth,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport {\n readFileSync,\n writeFileSync,\n existsSync,\n mkdirSync,\n readdirSync,\n statSync,\n unlinkSync,\n createWriteStream,\n} from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport * as http from 'node:http';\nimport * as https from 'node:https';\nimport { tmpdir } from 'node:os';\nimport { pipeline } from 'node:stream/promises';\nimport chalk from 'chalk';\nimport edn from 'jsedn';\nimport yauzl from 'yauzl';\n\n\ninterface AssetMetadata {\n version: string;\n assets: Array<{ path: string; 'content-hash': string }>;\n}\n\nconst ASSET_META_FILENAME = 'meta/asset-meta.edn';\nconst ASSETS_DIR = 'assets/';\nconst CLEAR_LINE = '\\x1b[K';\nconst CARRIAGE_RETURN = '\\r';\n\nfunction parseAssetMetadataEdn(content: string): AssetMetadata | null {\n try {\n const parsed = edn.parse(content);\n const version = parsed.at(edn.kw(':version')) || parsed.at(edn.kw(':aliased-version'));\n const assets = parsed.at(edn.kw(':assets'));\n\n const assetList: Array<{ path: string; 'content-hash': string }> = [];\n if (assets && assets.val) {\n for (const asset of assets.val) {\n assetList.push({\n path: asset.at(edn.kw(':path')),\n 'content-hash': asset.at(edn.kw(':content-hash')),\n });\n }\n }\n\n if (!version) {\n return null;\n }\n\n return { version, assets: assetList };\n } catch {\n return null;\n }\n}\n\n/**\n * Reads asset metadata from .flex-cli/asset-meta.edn\n */\nfunction readAssetMetadata(basePath: string): AssetMetadata | null {\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n if (!existsSync(metaPath)) {\n return null;\n }\n\n try {\n const content = readFileSync(metaPath, 'utf-8');\n return parseAssetMetadataEdn(content);\n } catch {\n return null;\n }\n}\n\n/**\n * Writes asset metadata to .flex-cli/asset-meta.edn\n */\nfunction writeAssetMetadata(basePath: string, metadata: AssetMetadata): void {\n const metaDir = join(basePath, '.flex-cli');\n if (!existsSync(metaDir)) {\n mkdirSync(metaDir, { recursive: true });\n }\n\n const assets = metadata.assets.map(a =>\n new edn.Map([\n edn.kw(':path'), a.path,\n edn.kw(':content-hash'), a['content-hash']\n ])\n );\n\n const ednMap = new edn.Map([\n edn.kw(':version'), metadata.version,\n edn.kw(':assets'), new edn.Vector(assets)\n ]);\n\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n writeFileSync(metaPath, edn.encode(ednMap), 'utf-8');\n}\n\n/**\n * Calculates SHA-1 hash of file content matching backend convention\n * Content is prefixed with `${byte-count}|` before hashing\n */\nfunction calculateHash(data: Buffer): string {\n const prefix = Buffer.from(`${data.length}|`, 'utf-8');\n return createHash('sha1').update(prefix).update(data).digest('hex');\n}\n\n/**\n * Reads all assets from a directory\n */\nfunction readLocalAssets(basePath: string): Array<{ path: string; data: Buffer; hash: string }> {\n const assets: Array<{ path: string; data: Buffer; hash: string }> = [];\n\n function scanDir(dir: string, relativePath: string = '') {\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n if (entry === '.flex-cli') continue; // Skip metadata directory\n if (entry === '.DS_Store') continue; // Skip .DS_Store files\n\n const fullPath = join(dir, entry);\n const relPath = relativePath ? join(relativePath, entry) : entry;\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n scanDir(fullPath, relPath);\n } else if (stat.isFile()) {\n const data = readFileSync(fullPath);\n const hash = calculateHash(data);\n assets.push({ path: relPath, data, hash });\n }\n }\n }\n\n scanDir(basePath);\n return assets;\n}\n\n/**\n * Lists local asset paths without reading file data\n */\nfunction listLocalAssetPaths(basePath: string): string[] {\n const assets: string[] = [];\n\n function scanDir(dir: string, relativePath: string = '') {\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n if (entry === '.flex-cli') continue;\n if (entry === '.DS_Store') continue;\n\n const fullPath = join(dir, entry);\n const relPath = relativePath ? join(relativePath, entry) : entry;\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n scanDir(fullPath, relPath);\n } else if (stat.isFile()) {\n assets.push(relPath);\n }\n }\n }\n\n scanDir(basePath);\n return assets;\n}\n\n/**\n * Validates JSON files\n */\nfunction validateJsonAssets(assets: Array<{ path: string; data: Buffer }>): void {\n for (const asset of assets) {\n if (asset.path.endsWith('.json')) {\n try {\n JSON.parse(asset.data.toString('utf-8'));\n } catch (error) {\n throw new Error(`Invalid JSON in ${asset.path}: ${error}`);\n }\n }\n }\n}\n\nfunction formatDownloadProgress(bytes: number): string {\n const mb = bytes / 1024 / 1024;\n return `${CARRIAGE_RETURN}${CLEAR_LINE}Downloaded ${mb.toFixed(2)}MB`;\n}\n\nfunction printDownloadProgress(stream: NodeJS.ReadableStream): void {\n let downloaded = 0;\n const printProgress = (): void => {\n process.stderr.write(formatDownloadProgress(downloaded));\n };\n const interval = setInterval(printProgress, 100);\n\n stream.on('data', (chunk: Buffer) => {\n downloaded += chunk.length;\n });\n\n stream.on('end', () => {\n clearInterval(interval);\n printProgress();\n process.stderr.write('\\nFinished downloading assets\\n');\n });\n}\n\nfunction getApiKeyOrThrow(): string {\n const auth = readAuth();\n if (!auth?.apiKey) {\n throw new Error('Not logged in. Please provide apiKey or run: sharetribe-community-cli login');\n }\n return auth.apiKey;\n}\n\nfunction getAssetsPullUrl(marketplace: string, version?: string): URL {\n const url = new URL(getApiBaseUrl() + '/assets/pull');\n url.searchParams.set('marketplace', marketplace);\n if (version) {\n url.searchParams.set('version', version);\n } else {\n url.searchParams.set('version-alias', 'latest');\n }\n return url;\n}\n\nfunction getErrorMessage(body: string, statusCode: number): string {\n try {\n const parsed = JSON.parse(body) as { errors?: Array<{ message?: string }> };\n const message = parsed.errors?.[0]?.message;\n if (message) {\n return message;\n }\n } catch {\n // Ignore JSON parse errors\n }\n return body || `HTTP ${statusCode}`;\n}\n\nasync function getAssetsZipStream(\n marketplace: string,\n version?: string\n): Promise<http.IncomingMessage> {\n const url = getAssetsPullUrl(marketplace, version);\n const apiKey = getApiKeyOrThrow();\n const isHttps = url.protocol === 'https:';\n const client = isHttps ? https : http;\n\n return new Promise((resolve, reject) => {\n const req = client.request(\n {\n method: 'GET',\n hostname: url.hostname,\n port: url.port || (isHttps ? 443 : 80),\n path: url.pathname + url.search,\n headers: {\n Authorization: `Apikey ${apiKey}`,\n Accept: 'application/zip',\n },\n },\n (res) => {\n const statusCode = res.statusCode || 0;\n if (statusCode < 200 || statusCode >= 300) {\n const chunks: Buffer[] = [];\n res.on('data', (chunk: Buffer) => chunks.push(chunk));\n res.on('end', () => {\n const body = Buffer.concat(chunks).toString('utf-8');\n reject(new Error(getErrorMessage(body, statusCode)));\n });\n return;\n }\n resolve(res);\n }\n );\n\n req.setTimeout(120000, () => {\n req.destroy(new Error('Request timeout'));\n });\n req.on('error', reject);\n req.end();\n });\n}\n\nfunction createTempZipPath(): string {\n return join(tmpdir(), `assets-${Date.now()}.zip`);\n}\n\nfunction removeAssetsDir(filename: string): string {\n if (filename.startsWith(ASSETS_DIR)) {\n return filename.slice(ASSETS_DIR.length);\n }\n return filename;\n}\n\nfunction readStreamToString(stream: NodeJS.ReadableStream): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n stream.on('data', (chunk: Buffer) => chunks.push(chunk));\n stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));\n stream.on('error', reject);\n });\n}\n\nasync function unzipAssets(zipPath: string, basePath: string): Promise<AssetMetadata> {\n return new Promise((resolve, reject) => {\n yauzl.open(zipPath, { lazyEntries: true }, (err, zipfile) => {\n if (err || !zipfile) {\n reject(err || new Error('Failed to open zip file'));\n return;\n }\n\n let assetMeta: AssetMetadata | null = null;\n\n zipfile.on('error', reject);\n zipfile.on('end', () => {\n if (!assetMeta) {\n reject(new Error('Asset metadata not found in zip'));\n return;\n }\n resolve(assetMeta);\n });\n\n zipfile.readEntry();\n zipfile.on('entry', (entry) => {\n if (entry.fileName.endsWith('/')) {\n zipfile.readEntry();\n return;\n }\n\n zipfile.openReadStream(entry, (streamErr, readStream) => {\n if (streamErr || !readStream) {\n reject(streamErr || new Error('Failed to read zip entry'));\n return;\n }\n\n if (entry.fileName === ASSET_META_FILENAME) {\n readStreamToString(readStream)\n .then((content) => {\n assetMeta = parseAssetMetadataEdn(content);\n if (!assetMeta) {\n reject(new Error('Invalid asset metadata'));\n return;\n }\n zipfile.readEntry();\n })\n .catch(reject);\n return;\n }\n\n const assetPath = join(basePath, removeAssetsDir(entry.fileName));\n const assetDir = dirname(assetPath);\n if (!existsSync(assetDir)) {\n mkdirSync(assetDir, { recursive: true });\n }\n\n pipeline(readStream, createWriteStream(assetPath))\n .then(() => zipfile.readEntry())\n .catch(reject);\n });\n });\n });\n });\n}\n\n/**\n * Pulls assets from remote\n */\nasync function pullAssets(\n marketplace: string,\n path: string,\n version?: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Create directory if it doesn't exist\n if (!existsSync(path)) {\n mkdirSync(path, { recursive: true });\n }\n\n const stat = statSync(path);\n if (!stat.isDirectory()) {\n throw new Error(`${path} is not a directory`);\n }\n\n const localAssets = prune ? listLocalAssetPaths(path) : [];\n const currentMeta = readAssetMetadata(path);\n const tempZipPath = createTempZipPath();\n\n try {\n const zipStream = await getAssetsZipStream(marketplace, version);\n printDownloadProgress(zipStream);\n await pipeline(zipStream, createWriteStream(tempZipPath));\n\n const newAssetMeta = await unzipAssets(tempZipPath, path);\n const remoteVersion = newAssetMeta.version;\n\n const deletedPaths = prune\n ? new Set(localAssets.filter(p => !newAssetMeta.assets.some(a => a.path === p)))\n : new Set<string>();\n\n const updated = currentMeta?.version !== remoteVersion;\n const shouldReportUpdate = updated || deletedPaths.size > 0;\n\n if (deletedPaths.size > 0) {\n for (const assetPath of deletedPaths) {\n const fullPath = join(path, assetPath);\n if (existsSync(fullPath)) {\n unlinkSync(fullPath);\n }\n }\n }\n\n if (shouldReportUpdate) {\n writeAssetMetadata(path, {\n version: remoteVersion,\n assets: newAssetMeta.assets,\n });\n console.log(`Version ${remoteVersion} successfully pulled.`);\n } else {\n console.log('Assets are up to date.');\n }\n } finally {\n if (existsSync(tempZipPath)) {\n unlinkSync(tempZipPath);\n }\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull assets');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Filters assets to only those that have changed\n */\nfunction filterChangedAssets(\n existingMeta: Array<{ path: string; 'content-hash': string }>,\n localAssets: Array<{ path: string; hash: string }>\n): Array<{ path: string; data: Buffer; hash: string }> {\n const hashByPath = new Map(existingMeta.map(a => [a.path, a['content-hash']]));\n \n return localAssets.filter(asset => {\n const storedHash = hashByPath.get(asset.path);\n // Assets without stored metadata are treated as changed\n return !storedHash || storedHash !== asset.hash;\n });\n}\n\n/**\n * Pushes assets to remote\n */\nasync function pushAssets(\n marketplace: string,\n path: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Validate path\n if (!existsSync(path) || !statSync(path).isDirectory()) {\n throw new Error(`${path} is not a valid directory`);\n }\n\n // Read current metadata\n const currentMeta = readAssetMetadata(path);\n const currentVersion = currentMeta?.version || 'nil';\n\n // Read local assets\n const localAssets = readLocalAssets(path);\n\n // Validate JSON files\n validateJsonAssets(localAssets);\n\n // Filter to only changed assets\n const changedAssets = filterChangedAssets(currentMeta?.assets || [], localAssets);\n\n // Separate JSON and non-JSON assets\n const isJsonAsset = (assetPath: string): boolean => {\n return assetPath.toLowerCase().endsWith('.json');\n };\n\n const stageableAssets = changedAssets.filter(a => !isJsonAsset(a.path));\n\n // Find assets to delete (if prune enabled)\n const localAssetMap = new Map(localAssets.map(a => [a.path, a]));\n const deleteOperations: Array<{ path: string; op: 'delete' }> = [];\n if (prune && currentMeta) {\n for (const currentAsset of currentMeta.assets) {\n if (!localAssetMap.has(currentAsset.path)) {\n deleteOperations.push({\n path: currentAsset.path,\n op: 'delete',\n });\n }\n }\n }\n\n // Check if there are any changes\n const noOps = changedAssets.length === 0 && deleteOperations.length === 0;\n if (noOps) {\n console.log('Assets are up to date.');\n return;\n }\n\n // Log changed assets\n if (changedAssets.length > 0) {\n const paths = changedAssets.map(a => a.path).join(', ');\n console.log(chalk.green(`Uploading changed assets: ${paths}`));\n }\n\n // Stage non-JSON assets\n const stagedByPath = new Map<string, string>();\n if (stageableAssets.length > 0) {\n const paths = stageableAssets.map(a => a.path).join(', ');\n console.log(chalk.green(`Staging assets: ${paths}`));\n\n for (const asset of stageableAssets) {\n try {\n const stagingResult = await sdkStageAsset(\n undefined,\n marketplace,\n asset.data,\n asset.path\n );\n stagedByPath.set(asset.path, stagingResult.stagingId);\n } catch (error) {\n if (error && typeof error === 'object' && 'code' in error && error.code === 'asset-invalid-content') {\n const detail = 'message' in error ? error.message : 'The file is missing or uses an unsupported format.';\n throw new Error(`Failed to stage image ${asset.path}: ${detail}\\nFix the file and rerun assets push to retry staging.`);\n }\n throw error;\n }\n }\n }\n\n // Build upsert operations\n const upsertOperations = changedAssets.map(asset => {\n const stagingId = stagedByPath.get(asset.path);\n return {\n path: asset.path,\n op: 'upsert' as const,\n ...(stagingId\n ? { stagingId }\n : { data: asset.data, filename: asset.path }),\n };\n });\n\n // Upload to API\n const result = await sdkPushAssets(\n undefined,\n marketplace,\n currentVersion,\n [...upsertOperations, ...deleteOperations]\n );\n\n // Update local metadata\n writeAssetMetadata(path, {\n version: result.version,\n assets: result.assets.map(a => ({\n path: a.path,\n 'content-hash': a.contentHash,\n })),\n });\n\n console.log(`New version ${result.version} successfully created.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push assets');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers assets commands\n */\nexport function registerAssetsCommands(program: Command): void {\n const assetsCmd = program.command('assets').description('manage marketplace assets');\n\n // assets pull\n assetsCmd\n .command('pull')\n .description('pull assets from remote')\n .requiredOption('--path <PATH>', 'path to directory where assets will be stored')\n .option('--version <VERSION>', 'version of assets to pull')\n .option('--prune', 'delete local files no longer present as remote assets')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pullAssets(marketplace, opts.path, opts.version, opts.prune);\n });\n\n // assets push\n assetsCmd\n .command('push')\n .description('push assets to remote')\n .requiredOption('--path <PATH>', 'path to directory with assets')\n .option('--prune', 'delete remote assets no longer present locally')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pushAssets(marketplace, opts.path, opts.prune);\n });\n}\n\nexport const __test__ = {\n formatDownloadProgress,\n removeAssetsDir,\n parseAssetMetadataEdn,\n};\n", "/**\n * Notifications commands - manage email notifications\n */\n\nimport { Command } from 'commander';\nimport {\n sendNotification as sdkSendNotification,\n previewNotification as sdkPreviewNotification,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport { readFileSync, existsSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createServer, IncomingMessage, ServerResponse } from 'node:http';\n\n\n/**\n * Reads a notification template from a directory\n */\nfunction readTemplate(templatePath: string): { html: string; subject: string } {\n if (!existsSync(templatePath) || !statSync(templatePath).isDirectory()) {\n throw new Error(`Template directory not found: ${templatePath}`);\n }\n\n const htmlPath = join(templatePath, 'template.html');\n const subjectPath = join(templatePath, 'template-subject.txt');\n\n if (!existsSync(htmlPath)) {\n throw new Error(`template.html not found in ${templatePath}`);\n }\n\n if (!existsSync(subjectPath)) {\n throw new Error(`template-subject.txt not found in ${templatePath}`);\n }\n\n const html = readFileSync(htmlPath, 'utf-8');\n const subject = readFileSync(subjectPath, 'utf-8').trim();\n\n return { html, subject };\n}\n\n/**\n * Reads template context JSON file\n */\nfunction readContext(contextPath?: string): unknown {\n if (!contextPath) {\n return undefined;\n }\n\n if (!existsSync(contextPath)) {\n throw new Error(`Context file not found: ${contextPath}`);\n }\n\n const content = readFileSync(contextPath, 'utf-8');\n try {\n return JSON.parse(content);\n } catch (error) {\n throw new Error(`Invalid JSON in context file: ${error}`);\n }\n}\n\n/**\n * Sends a preview email to the marketplace admin\n */\nasync function sendNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n const result = await sdkSendNotification(undefined, marketplace, { template, context });\n\n console.log(`Preview successfully sent to ${result.adminEmail}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to send notification');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Previews a notification in the browser\n */\nasync function previewNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n console.log(`Template: ${templatePath}`);\n console.log(`Subject: ${template.subject}`);\n console.log('');\n console.log('Starting preview server at http://localhost:3535');\n console.log('Press Ctrl+C to stop');\n console.log('');\n\n let previewHtml: string | null = null;\n\n // Fetch preview from API\n const fetchPreview = async () => {\n try {\n const result = await sdkPreviewNotification(undefined, marketplace, { template, context });\n\n // Inject title into HTML\n const html = result.html;\n const titleTag = `<title>${template.subject}</title>`;\n\n if (html.includes('<head>')) {\n previewHtml = html.replace('<head>', `<head>\\n${titleTag}`);\n } else if (html.includes('<html>')) {\n previewHtml = html.replace('<html>', `<html>\\n<head>${titleTag}</head>`);\n } else {\n previewHtml = `<html><head>${titleTag}</head><body>${html}</body></html>`;\n }\n } catch (error) {\n const errorMessage = error && typeof error === 'object' && 'message' in error\n ? (error.message as string)\n : 'Failed to preview notification';\n\n previewHtml = `\n <html>\n <head><title>Error</title></head>\n <body style=\"font-family: sans-serif; padding: 20px;\">\n <h1 style=\"color: #d32f2f;\">Error</h1>\n <pre style=\"background: #f5f5f5; padding: 15px; border-radius: 4px;\">${errorMessage}</pre>\n </body>\n </html>\n `;\n }\n };\n\n // Initial fetch\n await fetchPreview();\n\n // Create HTTP server\n const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/' || req.url === '') {\n // Refresh preview on each request\n await fetchPreview();\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(previewHtml);\n } else {\n res.writeHead(404, { 'Content-Type': 'text/plain' });\n res.end('Not Found');\n }\n });\n\n server.listen(3535, () => {\n console.log('Preview server started. Open http://localhost:3535 in your browser.');\n });\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nShutting down preview server...');\n server.close(() => {\n process.exitCode = 0; return;\n });\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to preview notification');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers notifications commands\n */\nexport function registerNotificationsCommands(program: Command): void {\n const notificationsCmd = program\n .command('notifications')\n .description('manage email notifications');\n\n // notifications preview\n notificationsCmd\n .command('preview')\n .description('render a preview of an email template')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await previewNotification(marketplace, opts.template, opts.context);\n });\n\n // notifications send\n notificationsCmd\n .command('send')\n .description('send a preview of an email template to the logged in admin')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await sendNotification(marketplace, opts.template, opts.context);\n });\n}\n", "/**\n * Listing approval command - DEPRECATED\n *\n * This command is deprecated and should not be used.\n * Use the Sharetribe Console instead.\n */\n\nimport { Command } from 'commander';\nimport {\n getListingApprovalStatus as sdkGetStatus,\n enableListingApproval as sdkEnable,\n disableListingApproval as sdkDisable,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../util/output.js';\n\n/**\n * Gets current listing approval status\n */\nasync function getStatus(marketplace: string): Promise<void> {\n try {\n const result = await sdkGetStatus(undefined, marketplace);\n\n if (result.enabled) {\n console.log(`Listing approvals are enabled in ${marketplace}`);\n } else {\n console.log(`Listing approvals are disabled in ${marketplace}`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to get listing approval status');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Enables listing approvals\n */\nasync function enableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkEnable(undefined, marketplace);\n console.log(`Successfully enabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to enable listing approvals');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Disables listing approvals\n */\nasync function disableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkDisable(undefined, marketplace);\n console.log(`Successfully disabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to disable listing approvals');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers listing-approval command\n */\nexport function registerListingApprovalCommand(program: Command): void {\n const cmd = program\n .command('listing-approval')\n .description('manage listing approvals (DEPRECATED - use Console instead)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - show status\n cmd.action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await getStatus(marketplace);\n });\n\n // Enable subcommand\n cmd\n .command('enable')\n .description('enable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await enableApprovals(marketplace);\n });\n\n // Disable subcommand\n cmd\n .command('disable')\n .description('disable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await disableApprovals(marketplace);\n });\n}\n", "/**\n * Events command - query marketplace events\n */\n\nimport { Command } from 'commander';\nimport { printTable, printError } from '../../util/output.js';\nimport {\n queryEvents as sdkQueryEvents,\n pollEvents as sdkPollEvents,\n type EventData as SdkEventData\n} from 'sharetribe-flex-build-sdk';\n\ninterface EventsQueryOptions {\n resourceId?: string;\n relatedResourceId?: string;\n eventTypes?: string;\n sequenceId?: number;\n afterSeqId?: number;\n beforeSeqId?: number;\n afterTs?: string;\n beforeTs?: string;\n limit?: number;\n json?: boolean;\n jsonPretty?: boolean;\n}\n\n/**\n * Validates query parameters\n */\nfunction validateParams(opts: EventsQueryOptions): void {\n const exclusiveParams = [\n opts.sequenceId !== undefined,\n opts.afterSeqId !== undefined,\n opts.beforeSeqId !== undefined,\n opts.afterTs !== undefined,\n opts.beforeTs !== undefined,\n ];\n\n if (exclusiveParams.filter(Boolean).length > 1) {\n throw new Error(\n 'Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified'\n );\n }\n\n if (opts.resourceId && opts.relatedResourceId) {\n throw new Error('Only one of --resource or --related-resource can be specified');\n }\n}\n\n/**\n * Formats timestamp to match flex-cli format: YYYY-MM-DD H:MM:SS AM/PM\n */\nfunction formatTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Queries events from API\n */\nasync function queryEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n const events = await sdkQueryEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n sequenceId: opts.sequenceId,\n afterSeqId: opts.afterSeqId,\n beforeSeqId: opts.beforeSeqId,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit,\n }\n );\n\n if (events.length === 0) {\n console.log('No events found.');\n return;\n }\n\n // Output format\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n ['Seq ID', 'Resource ID', 'Event type', 'Created at local time', 'Source', 'Actor'],\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to query events');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Tails events (live streaming)\n */\nasync function tailEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n console.log('Tailing events... Press Ctrl+C to stop');\n console.log('');\n\n const stopPolling = sdkPollEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n limit: opts.limit || 10,\n },\n (events: SdkEventData[]) => {\n // Output events\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n ['Seq ID', 'Resource ID', 'Event type', 'Created at local time', 'Source', 'Actor'],\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n },\n 5000 // 5 second poll interval\n );\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nStopping tail...');\n stopPolling();\n process.exitCode = 0; return;\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to tail events');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers events command\n */\nexport function registerEventsCommand(program: Command): void {\n const cmd = program\n .command('events')\n .description('Get a list of events.')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('--seqid <SEQUENCE_ID>', 'get event with specific sequence ID', parseInt)\n .option('--after-seqid <SEQUENCE_ID>', 'show events after sequence ID (exclusive)', parseInt)\n .option('--before-seqid <SEQUENCE_ID>', 'show events before sequence ID (exclusive)', parseInt)\n .option('--after-ts <TIMESTAMP>', 'show events after timestamp')\n .option('--before-ts <TIMESTAMP>', 'show events before timestamp')\n .option('-l, --limit <NUMBER>', 'limit results (default: 100, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - query\n cmd.action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exitCode = 1; return;\n }\n\n await queryEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n sequenceId: opts.seqid,\n afterSeqId: opts.afterSeqid,\n beforeSeqId: opts.beforeSeqid,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit || 100,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n\n // tail subcommand\n cmd\n .command('tail')\n .description('Tail events live as they happen')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('-l, --limit <NUMBER>', 'limit results per poll (default: 10, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exitCode = 1; return;\n }\n\n await tailEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n limit: opts.limit || 10,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n}\n", "/**\n * Stripe command - manage Stripe integration\n */\n\nimport { Command } from 'commander';\nimport { updateStripeVersion as sdkUpdateStripeVersion, SUPPORTED_STRIPE_VERSIONS } from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport inquirer from 'inquirer';\n\n\n/**\n * Prompts for version selection\n */\nasync function promptForVersion(): Promise<string> {\n const answers = await inquirer.prompt([\n {\n type: 'list',\n name: 'version',\n message: 'Select Stripe API version:',\n choices: [...SUPPORTED_STRIPE_VERSIONS],\n },\n ]);\n\n return answers.version;\n}\n\n/**\n * Prompts for confirmation\n */\nasync function promptForConfirmation(): Promise<boolean> {\n console.log('');\n console.log('WARNING: Changing Stripe API version may affect your integration.');\n console.log('');\n console.log('After updating the Stripe API version, you may need to:');\n console.log('- Handle new Capabilities requirements');\n console.log('- Update identity verification settings');\n console.log('');\n console.log('See Stripe documentation for details:');\n console.log('https://stripe.com/docs/connect/capabilities-overview');\n console.log('https://stripe.com/docs/connect/identity-verification');\n console.log('');\n\n const answers = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirmed',\n message: 'Do you want to continue?',\n default: false,\n },\n ]);\n\n return answers.confirmed;\n}\n\n/**\n * Updates Stripe API version\n */\nasync function updateStripeVersion(\n marketplace: string,\n version?: string,\n force?: boolean\n): Promise<void> {\n try {\n // Get version if not provided\n let selectedVersion = version;\n if (!selectedVersion) {\n selectedVersion = await promptForVersion();\n }\n\n // Get confirmation unless --force flag is used\n if (!force) {\n const confirmed = await promptForConfirmation();\n if (!confirmed) {\n console.log('Cancelled.');\n process.exitCode = 0; return;\n }\n }\n\n // Update via API (SDK validates version)\n await sdkUpdateStripeVersion(undefined, marketplace, selectedVersion);\n\n console.log(`Stripe API version successfully changed to ${selectedVersion}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update Stripe API version');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers stripe commands\n */\nexport function registerStripeCommands(program: Command): void {\n const stripeCmd = program.command('stripe').description('manage Stripe integration');\n\n // stripe update-version\n stripeCmd\n .command('update-version')\n .description('update Stripe API version in use')\n .option('--version <VERSION>', 'Stripe API version to update to')\n .option('-f, --force', 'skip confirmation prompt and force update')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await updateStripeVersion(marketplace, opts.version, opts.force);\n });\n}\n", "/**\n * Debug command - display config and auth info\n */\n\nimport { getConfigMap, readAuth } from 'sharetribe-flex-build-sdk';\n\nfunction maskLast4(value: string): string {\n if (value.length <= 4) {\n return `...${value}`;\n }\n return `...${value.slice(-4)}`;\n}\n\nexport function debug(): void {\n const auth = readAuth();\n const apiKey = auth?.apiKey ? maskLast4(auth.apiKey) : 'No API key set';\n const confMap = getConfigMap();\n\n const confMapEntries = Object.keys(confMap)\n .sort()\n .map((key) => `:${key} ${confMap[key]}`)\n .join(' ');\n const confMapFormatted = confMapEntries ? `{${confMapEntries}}` : '{}';\n\n console.log(`{:api-key ${apiKey}, :conf-map ${confMapFormatted}}`);\n}\n", "/**\n * Custom help formatter to match flex-cli output exactly\n */\n\nimport { Command, Help } from 'commander';\nimport chalk from 'chalk';\n\n/**\n * Formats help text to match flex-cli style\n *\n * flex-cli format:\n * - Description (no label)\n * - VERSION section (for main help only)\n * - USAGE section\n * - COMMANDS section (flattened list of all leaf commands)\n * - OPTIONS section (for subcommands only, not main)\n * - Subcommand help instructions\n *\n * @param cmd - Commander command instance\n * @returns Formatted help text matching flex-cli\n */\nexport function formatHelp(cmd: Command): string {\n const parts: string[] = [];\n const isRootCommand = !cmd.parent;\n\n // Description (no label, just the text)\n const description = cmd.description();\n if (description) {\n parts.push(description);\n parts.push('');\n }\n\n // VERSION section (only for root command)\n if (isRootCommand) {\n const version = cmd.version();\n if (version) {\n parts.push('VERSION');\n parts.push(` ${version}`);\n parts.push('');\n }\n }\n\n // USAGE section\n parts.push('USAGE');\n const usage = formatUsage(cmd);\n parts.push(` $ ${usage}`);\n parts.push('');\n\n // COMMANDS section\n // Note: If command has an action (options), don't show COMMANDS section (like flex-cli)\n const allCommands = collectAllLeafCommands(cmd);\n const hasAction = cmd.options.length > 0 && !isRootCommand;\n\n if (allCommands.length > 0 && !hasAction) {\n parts.push('COMMANDS');\n\n // Calculate max command name length for alignment\n const maxLength = Math.max(...allCommands.map(c => c.name.length));\n\n for (const cmdInfo of allCommands) {\n const paddedName = cmdInfo.name.padEnd(maxLength + 2);\n parts.push(` ${paddedName}${cmdInfo.description}`);\n }\n parts.push('');\n }\n\n // OPTIONS section (only for subcommands, not root)\n if (!isRootCommand) {\n const options = cmd.options;\n if (options.length > 0) {\n parts.push('OPTIONS');\n\n // Calculate max option flags length for alignment\n const maxFlagsLength = Math.max(...options.map(opt => formatOptionFlags(opt).length));\n\n for (const opt of options) {\n const flags = formatOptionFlags(opt);\n const paddedFlags = flags.padEnd(maxFlagsLength + 2);\n const desc = opt.description || '';\n parts.push(` ${paddedFlags}${desc}`);\n }\n parts.push('');\n }\n }\n\n // Subcommand help instructions (only for main and group commands without actions)\n if (allCommands.length > 0 && !hasAction) {\n parts.push('Subcommand help:');\n const cmdName = getCommandName(cmd);\n parts.push(` $ ${cmdName} help [COMMAND]`);\n }\n\n // Always add empty line at end to match flex-cli\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Recursively collects all commands (both parent and leaf commands)\n *\n * flex-cli shows ALL commands, including parent commands that have their own actions\n * Example: both \"events\" and \"events tail\" are shown\n *\n * @param cmd - Commander command instance\n * @returns Array of command info objects with name and description\n */\nfunction collectAllLeafCommands(cmd: Command): Array<{ name: string; description: string }> {\n const results: Array<{ name: string; description: string }> = [];\n const commands = cmd.commands.filter(c => !c._hidden && c.name() !== 'help');\n\n for (const subCmd of commands) {\n const fullName = getCommandFullName(subCmd);\n const subCommands = subCmd.commands.filter(c => !c._hidden);\n\n // Add this command if it has an action or description\n if (subCmd.description()) {\n results.push({\n name: fullName,\n description: subCmd.description() || ''\n });\n }\n\n // If it has subcommands, recurse and add those too\n if (subCommands.length > 0) {\n const subResults = collectAllLeafCommands(subCmd);\n for (const sub of subResults) {\n results.push(sub);\n }\n }\n }\n\n // Add \"help\" command at the beginning if this is root\n if (!cmd.parent) {\n results.unshift({\n name: 'help',\n description: 'display help for Flex CLI'\n });\n }\n\n // Sort alphabetically by command name\n results.sort((a, b) => a.name.localeCompare(b.name));\n\n return results;\n}\n\n/**\n * Gets the command name for usage (flex-cli vs sharetribe-community-cli)\n *\n * @param cmd - Commander command instance\n * @returns Command name (e.g., \"sharetribe-community-cli\" or \"sharetribe-community-cli process\")\n */\nfunction getCommandName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n // Replace first name with \"sharetribe-community-cli\" (or \"flex-cli\" for reference)\n if (names.length > 0) {\n names[0] = 'sharetribe-community-cli';\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats the USAGE line\n *\n * @param cmd - Commander command instance\n * @returns Usage string (e.g., \"sharetribe-community-cli [COMMAND]\" or \"sharetribe-community-cli process list\")\n */\nfunction formatUsage(cmd: Command): string {\n const cmdName = getCommandName(cmd);\n const commands = cmd.commands.filter(c => !c._hidden);\n const hasOptions = cmd.options.length > 0;\n const isRoot = !cmd.parent;\n\n // Root command always shows [COMMAND] if it has subcommands\n if (isRoot && commands.length > 0) {\n return `${cmdName} [COMMAND]`;\n }\n\n // If command has options (its own action), don't show [COMMAND] even if it has subcommands\n // This matches flex-cli behavior for commands like \"process\" which have both action and subcommands\n if (commands.length > 0 && !hasOptions) {\n // Has subcommands but no action\n return `${cmdName} [COMMAND]`;\n } else {\n // Leaf command or command with action - just show the command path\n return cmdName;\n }\n}\n\n/**\n * Gets the full command name including parent path\n *\n * @param cmd - Commander command instance\n * @returns Full command name (e.g., \"process list\" or \"events tail\")\n */\nfunction getCommandFullName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current && current.parent) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats option flags for display\n *\n * @param opt - Commander option instance\n * @returns Formatted flags string (e.g., \"-m, --marketplace=MARKETPLACE_ID\")\n */\nfunction formatOptionFlags(opt: any): string {\n // Commander option flags are in opt.flags (e.g., \"-m, --marketplace <MARKETPLACE_ID>\")\n // We need to parse and reformat this to match flex-cli style\n const flagsStr = opt.flags || '';\n\n // Parse the flags string\n // Format: \"-m, --marketplace <VALUE>\" or \"--flag\" or \"-f\"\n const parts = flagsStr.split(/,\\s*/);\n const formatted: string[] = [];\n\n for (const part of parts) {\n const trimmed = part.trim();\n\n // Check if it has a value placeholder (angle brackets or square brackets)\n const valueMatch = trimmed.match(/^((?:-{1,2}[\\w-]+))\\s*[<\\[]([^\\]>]+)[\\]>]/);\n if (valueMatch) {\n // Has a value: \"-m <MARKETPLACE_ID>\" or \"--marketplace <MARKETPLACE_ID>\"\n const flag = valueMatch[1];\n const valueName = valueMatch[2];\n formatted.push(`${flag}=${valueName}`);\n } else {\n // No value: just the flag\n formatted.push(trimmed);\n }\n }\n\n return formatted.join(', ');\n}\n\n/**\n * Configures Commander.js to use custom help formatter\n *\n * @param program - Commander program instance\n */\nexport function configureHelp(program: Command): void {\n program.configureHelp({\n formatHelp: (cmd: Command, helper: Help) => {\n return formatHelp(cmd);\n }\n });\n}\n", "/**\n * Custom command router to handle Commander.js limitations\n *\n * Commander.js cannot handle parent and child commands with the same option names.\n * This router intercepts argv and routes to the correct command handler.\n */\n\n/**\n * Routes process subcommands to avoid Commander parent/child option conflicts\n *\n * This is necessary because Commander validates parent command options before\n * subcommand actions run, causing conflicts when both use --path.\n */\nexport function routeProcessCommand(argv: string[]): string[] {\n // Check if this is a process subcommand\n const processIndex = argv.findIndex(arg => arg === 'process');\n if (processIndex === -1) {\n return argv;\n }\n\n // Check for subcommands\n const nextArg = argv[processIndex + 1];\n const subcommands = ['list', 'create', 'push', 'pull', 'create-alias', 'update-alias', 'delete-alias', 'deploy'];\n\n if (nextArg && subcommands.includes(nextArg)) {\n // This is a subcommand - remove 'process' from argv and make the subcommand top-level\n // e.g. ['node', 'cli', 'process', 'pull', ...] => ['node', 'cli', 'process-pull', ...]\n const newArgv = [\n ...argv.slice(0, processIndex),\n `process-${nextArg}`,\n ...argv.slice(processIndex + 2)\n ];\n\n // Special handling: If this is an alias command with --version option,\n // we need to filter out the global --version flag from program\n // by ensuring the routed command is properly isolated\n return newArgv;\n }\n\n return argv;\n}\n"],
5
- "mappings": ";;AAMA,OAAS,WAAAA,OAAe,YACxB,OAAS,gBAAAC,GAAc,cAAAC,GAAY,iBAAAC,GAAe,aAAAC,OAAiB,UACnE,OAAS,iBAAAC,OAAqB,WAC9B,OAAS,WAAAC,GAAS,QAAAC,OAAY,YAC9B,OAAOC,MAAW,QAClB,OAAS,oBAAAC,OAAwB,4BCLjC,OAAS,gBAAAC,OAAoB,UAC7B,OAAS,iBAAAC,OAAqB,WAC9B,OAAS,WAAAC,EAAS,QAAAC,OAAY,YAK9B,SAASC,IAA0B,CACjC,IAAMC,EAAaJ,GAAc,YAAY,GAAG,EAC5CK,EAAaJ,EAAQG,CAAU,EAGnC,KAAOC,IAAe,KACpB,GAAI,CACF,IAAMC,EAAUJ,GAAKG,EAAY,cAAc,EAE/C,OADgBN,GAAaO,EAAS,OAAO,CAE/C,MAAQ,CACND,EAAaJ,EAAQI,CAAU,CACjC,CAGF,MAAM,IAAI,MAAM,6BAA6B,CAC/C,CAOO,SAASE,GAAgB,CAC9B,IAAMC,EAAc,KAAK,MAAML,GAAgB,CAAC,EAChD,QAAQ,IAAIK,EAAY,OAAO,CACjC,CC9BA,OAAOC,OAAc,WACrB,OAAS,aAAAC,OAAiB,4BAO1B,eAAsBC,GAAuB,CAC3C,IAAMC,EAAU,MAAMH,GAAS,OAAO,CACpC,CACE,KAAM,WACN,KAAM,SACN,QAAS,iBACT,KAAM,IACN,SAAWI,GACL,CAACA,GAASA,EAAM,KAAK,EAAE,SAAW,EAC7B,0BAEF,EAEX,CACF,CAAC,EA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O,EAGrCY,GAA+BZ,CAAO,EAGtCa,GAAsBb,CAAO,EAG7Bc,GAAuBd,CAAO,EAG9BA,EACG,QAAQ,mBAAmB,EAC3B,YAAY,2BAA2B,EACvC,OAAQe,GAA0B,CACjC,GAAI,CAACA,GAAeA,EAAY,SAAW,EAAG,CAC5Cf,EAAQ,WAAW,EACnB,MACF,CAGA,IAAIgB,EAAqBhB,EACzB,QAAWiB,KAAWF,EAAa,CACjC,IAAMG,EAASF,EAAU,SAAS,KAAKG,GAAKA,EAAE,KAAK,IAAMF,CAAO,EAChE,GAAI,CAACC,EAAQ,CACX,QAAQ,MAAM,oBAAoBH,EAAY,KAAK,GAAG,CAAC,EAAE,EACzD,QAAQ,SAAW,EAAG,MACxB,CACAC,EAAYE,CACd,CAGAF,EAAU,WAAW,CACvB,CAAC,EAGElB,GAAW,MAAM,CAAC,EAAE,OAKvBE,EAAQ,MAAMF,EAAU,EAJxBE,EAAQ,WAAW",
6
- "names": ["Command", "readFileSync", "existsSync", "writeFileSync", "mkdirSync", "fileURLToPath", "dirname", "join", "chalk", "resolveConfigDir", "readFileSync", "fileURLToPath", "dirname", "join", "findPackageJson", "__filename", "currentDir", "pkgPath", "version", "packageJson", "inquirer", "writeAuth", "login", "answers", "input", "clearAuth", "logout", "sdkListProcesses", "sdkListProcessVersions", "chalk", "printTable", "headers", "rows", "widths", "header", "row", "value", "headerRow", "h", "width", "padded", "rowStr", "i", "printError", "message", "printSuccess", "printWarning", "formatProcessTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "listProcesses", "marketplace", "processName", "versions", "sdkListProcessVersions", "versionRows", "v", "printTable", "processes", "sdkListProcesses", "processRows", "p", "error", "printError", "sdkCreateProcess", "readdirSync", "readFileSync", "statSync", "join", "parseProcessFile", "processFilePath", "path", "join", "ensureProcessDir", "statSync", "readTemplates", "templatesDir", "templates", "templateNames", "readdirSync", "name", "templateDir", "readFileSync", "ensureTemplates", "notifications", "parseProcessFile", "t", "usedNames", "n", "printWarning", "missing", "unqualified", "keyword", "readFileSync", "createProcess", "marketplace", "processName", "path", "ensureProcessDir", "definition", "processFilePath", "templates", "readTemplates", "ensureTemplates", "result", "sdkCreateProcess", "printSuccess", "error", "printError", "sdkPushProcess", "readFileSync", "pushProcess", "marketplace", "processName", "path", "ensureProcessDir", "definition", "processFilePath", "templates", "readTemplates", "ensureTemplates", "result", "sdkPushProcess", "printSuccess", "error", "printError", "getProcess", "writeFileSync", "mkdirSync", "join", "pullProcess", "marketplace", "processName", "path", "version", "alias", "process", "getProcess", "existsSync", "dirExists", "processFilePath", "templates", "templatesDir", "template", "templateName", "htmlContent", "subjectContent", "templateSubdir", "htmlPath", "subjectPath", "error", "printError", "sdkCreateAlias", "sdkUpdateAlias", "sdkDeleteAlias", "createAlias", "marketplace", "processName", "version", "alias", "result", "sdkCreateAlias", "printSuccess", "error", "printError", "updateAlias", "sdkUpdateAlias", "deleteAlias", "sdkDeleteAlias", "createAlias", "createProcess", "listProcessVersions", "pushProcess", "updateAlias", "readFileSync", "readVersions", "marketplace", "processName", "listProcessVersions", "error", "createOrPushAndCreateOrUpdateAlias", "path", "alias", "ensureProcessDir", "definition", "processFilePath", "templates", "readTemplates", "ensureTemplates", "versions", "created", "createProcess", "printSuccess", "aliasResult", "createAlias", "aliasExists", "v", "pushed", "pushProcess", "version", "updateAlias", "printError", "registerProcessCommands", "program", "processCmd", "options", "marketplace", "listProcesses", "createProcess", "pushProcess", "pullProcess", "createAlias", "updateAlias", "deleteAlias", "createOrPushAndCreateOrUpdateAlias", "sdkListSearchSchemas", "sdkSetSearchSchema", "sdkUnsetSearchSchema", "SCOPE_LABELS", "setSearchSchema", "marketplace", "opts", "sdkSetSearchSchema", "schemaFor", "scopeLabel", "error", "printError", "unsetSearchSchema", "sdkUnsetSearchSchema", "getDefaultValueLabel", "value", "listSearchSchemas", "schemas", "sdkListSearchSchemas", "rows", "s", "a", "b", "headers", "widths", "h", "row", "headerParts", "i", "width", "padded", "rowParts", "registerSearchCommands", "program", "searchCmd", "options", "sdkPushAssets", "sdkStageAsset", "getApiBaseUrl", "readAuth", "readFileSync", "writeFileSync", "existsSync", "mkdirSync", "readdirSync", "statSync", "unlinkSync", "createWriteStream", "join", "dirname", "createHash", "http", "https", "tmpdir", "pipeline", "chalk", "edn", "yauzl", "ASSET_META_FILENAME", "ASSETS_DIR", "CLEAR_LINE", "CARRIAGE_RETURN", "parseAssetMetadataEdn", "content", "parsed", "version", "assets", "assetList", "asset", "readAssetMetadata", "basePath", "metaPath", "writeAssetMetadata", "metadata", "metaDir", "a", "ednMap", "calculateHash", "data", "prefix", "readLocalAssets", "scanDir", "dir", "relativePath", "entries", "entry", "fullPath", "relPath", "stat", "hash", "listLocalAssetPaths", "validateJsonAssets", "error", "formatDownloadProgress", "bytes", "mb", "printDownloadProgress", "stream", "downloaded", "printProgress", "interval", "chunk", "getApiKeyOrThrow", "auth", "readAuth", "getAssetsPullUrl", "marketplace", "url", "getApiBaseUrl", "getErrorMessage", "body", "statusCode", "message", "getAssetsZipStream", "apiKey", "isHttps", "client", "resolve", "reject", "req", "res", "chunks", "createTempZipPath", "removeAssetsDir", "filename", "readStreamToString", "unzipAssets", "zipPath", "err", "zipfile", "assetMeta", "streamErr", "readStream", "assetPath", "assetDir", "pullAssets", "path", "prune", "localAssets", "currentMeta", "tempZipPath", "zipStream", "newAssetMeta", "remoteVersion", "deletedPaths", "p", "shouldReportUpdate", "printError", "filterChangedAssets", "existingMeta", "hashByPath", "storedHash", "pushAssets", "currentVersion", "changedAssets", "isJsonAsset", "stageableAssets", "localAssetMap", "deleteOperations", "currentAsset", "paths", "stagedByPath", "stagingResult", "sdkStageAsset", "detail", "upsertOperations", "stagingId", "result", "sdkPushAssets", "registerAssetsCommands", "program", "assetsCmd", "opts", "sdkSendNotification", "sdkPreviewNotification", "readFileSync", "existsSync", "statSync", "join", "createServer", "readTemplate", "templatePath", "htmlPath", "subjectPath", "html", "subject", "readContext", "contextPath", "content", "error", "sendNotification", "marketplace", "template", "context", "result", "sdkSendNotification", "printError", "previewNotification", "previewHtml", "fetchPreview", "sdkPreviewNotification", "titleTag", "server", "req", "res", "shutdown", "registerNotificationsCommands", "program", "notificationsCmd", "opts", "sdkGetStatus", "sdkEnable", "sdkDisable", "getStatus", "marketplace", "sdkGetStatus", "error", "printError", "enableApprovals", "sdkEnable", "disableApprovals", "sdkDisable", "registerListingApprovalCommand", "program", "cmd", "opts", "sdkQueryEvents", "sdkPollEvents", "validateParams", "opts", "formatTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "queryEvents", "marketplace", "events", "event", "auditEmails", "eventWithoutEmails", "printTable", "actor", "source", "error", "printError", "tailEvents", "stopPolling", "shutdown", "registerEventsCommand", "program", "cmd", "sdkUpdateStripeVersion", "SUPPORTED_STRIPE_VERSIONS", "inquirer", "promptForVersion", "SUPPORTED_STRIPE_VERSIONS", "promptForConfirmation", "updateStripeVersion", "marketplace", "version", "force", "selectedVersion", "sdkUpdateStripeVersion", "error", "printError", "registerStripeCommands", "program", "opts", "getConfigMap", "readAuth", "maskLast4", "value", "debug", "auth", "apiKey", "confMap", "confMapEntries", "key", "confMapFormatted", "formatHelp", "cmd", "parts", "isRootCommand", "description", "version", "usage", "formatUsage", "allCommands", "collectAllLeafCommands", "hasAction", "maxLength", "c", "cmdInfo", "paddedName", "options", "maxFlagsLength", "opt", "formatOptionFlags", "paddedFlags", "desc", "cmdName", "getCommandName", "results", "commands", "subCmd", "fullName", "getCommandFullName", "subCommands", "subResults", "sub", "a", "b", "names", "current", "hasOptions", "formatted", "part", "trimmed", "valueMatch", "flag", "valueName", "configureHelp", "program", "helper", "routeProcessCommand", "argv", "processIndex", "arg", "nextArg", "__filename", "fileURLToPath", "__dirname", "dirname", "packageJson", "readFileSync", "join", "configDir", "resolveConfigDir", "noticeShownMarker", "existsSync", "chalk", "mkdirSync", "writeFileSync", "routedArgv", "routeProcessCommand", "program", "Command", "configureHelp", "str", "version", "login", "logout", "debug", "registerProcessCommands", "registerSearchCommands", "registerAssetsCommands", "registerNotificationsCommands", "registerListingApprovalCommand", "registerEventsCommand", "registerStripeCommands", "commandPath", "targetCmd", "cmdName", "subCmd", "c"]
3
+ "sources": ["../src/index.ts", "../src/commands/version.ts", "../src/commands/login.ts", "../src/commands/logout.ts", "../src/commands/process/list.ts", "../src/util/output.ts", "../src/commands/process/create.ts", "../src/util/process-files.ts", "../src/commands/process/push.ts", "../src/commands/process/pull.ts", "../src/commands/process/aliases.ts", "../src/commands/process/combined.ts", "../src/commands/process/index.ts", "../src/commands/search/index.ts", "../src/commands/assets/index.ts", "../src/util/api-error.ts", "../src/commands/notifications/index.ts", "../src/commands/listing-approval.ts", "../src/commands/events/index.ts", "../src/commands/stripe/index.ts", "../src/commands/debug.ts", "../src/util/help-formatter.ts", "../src/util/command-router.ts"],
4
+ "sourcesContent": ["/**\n * Sharetribe CLI - Unofficial 100% compatible implementation\n *\n * Main entry point for the CLI application\n */\n\nimport { Command } from 'commander';\nimport { readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\nimport chalk from 'chalk';\nimport { resolveConfigDir } from 'sharetribe-flex-build-sdk';\nimport { version } from './commands/version.js';\nimport { login } from './commands/login.js';\nimport { logout } from './commands/logout.js';\nimport { registerProcessCommands } from './commands/process/index.js';\nimport { registerSearchCommands } from './commands/search/index.js';\nimport { registerAssetsCommands } from './commands/assets/index.js';\nimport { registerNotificationsCommands } from './commands/notifications/index.js';\nimport { registerListingApprovalCommand } from './commands/listing-approval.js';\nimport { registerEventsCommand } from './commands/events/index.js';\nimport { registerStripeCommands } from './commands/stripe/index.js';\nimport { debug } from './commands/debug.js';\nimport { configureHelp } from './util/help-formatter.js';\nimport { routeProcessCommand } from './util/command-router.js';\n\n// Get package.json for version info\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(\n readFileSync(join(__dirname, '../package.json'), 'utf-8')\n);\n\n// Print unofficial notice to stderr on first run only\nconst configDir = resolveConfigDir();\nconst noticeShownMarker = join(configDir, '.sharetribe-community-cli-notice-shown');\nif (!existsSync(noticeShownMarker)) {\n console.error(chalk.yellow('\u26A0\uFE0F NOTICE: This is an UNOFFICIAL Sharetribe CLI (community reimplementation).'));\n console.error(chalk.yellow(' For the official CLI, install: ') + chalk.cyan('npm install -g flex-cli') + '\\n');\n try {\n mkdirSync(configDir, { recursive: true });\n writeFileSync(noticeShownMarker, new Date().toISOString());\n } catch {\n // Ignore errors writing marker file\n }\n}\n\n// Route argv to handle process subcommands\nconst routedArgv = routeProcessCommand(process.argv);\n\nconst program = new Command();\n\n// Configure custom help formatter to match flex-cli\nconfigureHelp(program);\n\n// Configure output to add trailing newline (flex-cli behavior)\nprogram.configureOutput({\n writeOut: (str) => process.stdout.write(str + '\\n'),\n writeErr: (str) => process.stderr.write(str + '\\n'),\n});\n\n// Configure the main program\nprogram\n .name('sharetribe-community-cli')\n .description('CLI to interact with Sharetribe Flex')\n .version(packageJson.version, '-V', 'output the version number')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n// Register commands\n\n// version command\nprogram\n .command('version')\n .description('show version')\n .action(() => {\n version();\n });\n\n// login command\nprogram\n .command('login')\n .description('log in with API key')\n .action(async () => {\n await login();\n });\n\n// logout command\nprogram\n .command('logout')\n .description('logout')\n .action(async () => {\n await logout();\n });\n\n// debug command\nprogram\n .command('debug')\n .description('display debug info')\n .action(() => {\n debug();\n });\n\n// Register process commands\nregisterProcessCommands(program);\n\n// Register search commands\nregisterSearchCommands(program);\n\n// Register assets commands\nregisterAssetsCommands(program);\n\n// Register notifications commands\nregisterNotificationsCommands(program);\n\n// Register listing-approval command\nregisterListingApprovalCommand(program);\n\n// Register events command\nregisterEventsCommand(program);\n\n// Register stripe commands\nregisterStripeCommands(program);\n\n// Register custom help command (to support \"help process list\" syntax)\nprogram\n .command('help [command...]')\n .description('display help for Flex CLI')\n .action((commandPath: string[]) => {\n if (!commandPath || commandPath.length === 0) {\n program.outputHelp();\n return;\n }\n\n // Navigate to the nested command\n let targetCmd: Command = program;\n for (const cmdName of commandPath) {\n const subCmd = targetCmd.commands.find(c => c.name() === cmdName);\n if (!subCmd) {\n console.error(`Unknown command: ${commandPath.join(' ')}`);\n process.exitCode = 1; return;\n }\n targetCmd = subCmd;\n }\n\n // Show help for the target command\n targetCmd.outputHelp();\n });\n\nconst commandArgs = routedArgv.slice(2);\n\n// flex-cli hides the assets subcommands and puts no handler on the group itself,\n// so naming the group without one of them is a miss rather than a help page.\nconst isAssetsGroupWithoutSubcommand =\n commandArgs[0] === 'assets' && !['pull', 'push', 'help'].includes(commandArgs[1] ?? '');\n\n// If no command specified, show help and exit with status 0\nif (!commandArgs.length) {\n program.outputHelp();\n // Don't call process.exit() - let Commander handle it naturally with exitOverride\n} else if (isAssetsGroupWithoutSubcommand) {\n console.error('Command not found: assets');\n process.exitCode = 1;\n} else {\n // Parse command line arguments with routed argv\n program.parse(routedArgv);\n}\n", "/**\n * Version command - displays the CLI version\n *\n * Must match flex-cli output format exactly\n */\n\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\n/**\n * Finds package.json by traversing up from current file\n */\nfunction findPackageJson(): string {\n const __filename = fileURLToPath(import.meta.url);\n let currentDir = dirname(__filename);\n\n // Traverse up to find package.json\n while (currentDir !== '/') {\n try {\n const pkgPath = join(currentDir, 'package.json');\n const content = readFileSync(pkgPath, 'utf-8');\n return content;\n } catch {\n currentDir = dirname(currentDir);\n }\n }\n\n throw new Error('Could not find package.json');\n}\n\n/**\n * Displays the version of the CLI\n *\n * Output must match flex-cli exactly\n */\nexport function version(): void {\n const packageJson = JSON.parse(findPackageJson());\n console.log(packageJson.version);\n}\n", "/**\n * Login command - interactive API key authentication\n *\n * Must match flex-cli behavior exactly:\n * - Prompt for API key\n * - Store in flex-cli's auth.edn (XDG_CONFIG_HOME, %LOCALAPPDATA% on Windows, else ~/.config)\n * - Display admin email on success\n */\n\nimport inquirer from 'inquirer';\nimport { writeAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the login command\n *\n * Prompts for API key and stores it in auth.edn\n */\nexport async function login(): Promise<void> {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n name: 'apiKey',\n message: 'Enter API key:',\n mask: '*',\n validate: (input: string) => {\n if (!input || input.trim().length === 0) {\n return 'API key cannot be empty';\n }\n return true;\n },\n },\n ]);\n\n // Store the API key\n writeAuth({ apiKey: answers.apiKey });\n\n // TODO: Validate API key by making a test request to get admin email\n // For now, just confirm storage\n console.log('Successfully logged in.');\n\n // Note: flex-cli displays admin email after successful login\n // We'll need to implement API client to fetch this\n}\n", "/**\n * Logout command - clears authentication\n *\n * Must match flex-cli behavior exactly\n */\n\nimport { clearAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the logout command\n *\n * Clears auth.edn file\n */\nexport async function logout(): Promise<void> {\n await clearAuth();\n console.log('Successfully logged out.');\n}\n", "/**\n * Process list command - lists all transaction processes\n */\n\nimport {\n listProcesses as sdkListProcesses,\n listProcessVersions as sdkListProcessVersions,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, columnsFromRows, printError } from '../../util/output.js';\n\n\n/**\n * Formats timestamp to match flex-cli format for process list\n */\nfunction formatProcessTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Lists all processes for a marketplace\n */\nexport async function listProcesses(marketplace: string, processName?: string): Promise<void> {\n try {\n // If processName is specified, show version history for that process\n if (processName) {\n const versions = await sdkListProcessVersions(undefined, marketplace, processName);\n\n const versionRows = versions.map((v) => ({\n 'Created': formatProcessTimestamp(v.createdAt),\n 'Version': v.version.toString(),\n 'Aliases': v.aliases?.join(', ') || '',\n 'Transactions': v.transactionCount?.toString() || '0',\n }));\n\n // flex-cli calls print-table without a column list here, so an empty\n // version list prints a table of no columns rather than a header.\n printTable(columnsFromRows(versionRows), versionRows);\n } else {\n // List all processes\n const processes = await sdkListProcesses(undefined, marketplace);\n\n const processRows = processes.map((p) => ({\n 'Name': p.name,\n 'Latest version': p.version?.toString() || '',\n }));\n\n printTable(columnsFromRows(processRows), processRows);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list processes');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Output formatting utilities\n *\n * Must match flex-cli output format exactly\n */\n\nimport chalk from 'chalk';\n\n/** Column width per header, as flex-cli's print-table returns for a continuation */\nexport type ColumnWidths = Record<string, number>;\n\n/**\n * Derives the columns from the first row, as flex-cli's print-table does when\n * called without an explicit column list\n *\n * flex-cli has two arities and they differ on an empty result: given columns it\n * prints the header, and without them it derives them from `(first rows)`, which\n * is nil, so it prints a table of no columns and therefore no header. Callers\n * that match the ks-less arity go through here so the difference stays visible\n * where it matters.\n *\n * @param rows - Rows keyed by header; an empty set yields no columns\n */\nexport function columnsFromRows(rows: Array<Record<string, string>>): string[] {\n return Object.keys(rows[0] ?? {});\n}\n\n/**\n * Prints a table with headers and rows\n *\n * Matches flex-cli table formatting exactly. An empty row set still prints the\n * header, as flex-cli's print-table does: it takes the column width from the\n * header alone when no row is wider.\n *\n * @param headers - Column headers, in order\n * @param rows - Rows keyed by header\n * @returns The column widths, to pass to printTableContinuation\n */\nexport function printTable(headers: string[], rows: Array<Record<string, string>>): ColumnWidths {\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const header of headers) {\n widths[header] = header.length + 1; // +1 to match flex-cli keyword string behavior\n }\n\n for (const row of rows) {\n for (const header of headers) {\n const value = row[header] || '';\n widths[header] = Math.max(widths[header] || 0, value.length);\n }\n }\n\n // Print empty line before table (like flex-cli)\n console.log('');\n\n // Print header with bold formatting\n // flex-cli format: each column padded to (max_width + 1), with single space separator between columns\n // Last column: padding but no separator (interpose doesn't add separator after last element)\n // flex-cli styles each title on its own and pads outside the escapes, so the\n // padding between columns carries no colour. Styling the whole row instead\n // would print the same characters but different bytes.\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = chalk.bold.black(h) + ' '.repeat(Math.max(0, width + 1 - h.length));\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n console.log(headerParts.join(''));\n\n // Print rows with same formatting\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const rowStr = rowParts.join('');\n console.log(rowStr);\n }\n\n // Print empty line after table (like flex-cli)\n console.log('');\n\n return widths;\n}\n\n/**\n * Prints more rows under a table printed earlier\n *\n * Reproduces flex-cli's print-table-continuation: no header, no surrounding\n * blank lines, and the column widths of the first batch, so a live tail keeps\n * its columns aligned without repeating the header. An empty row set prints\n * nothing.\n *\n * @param headers - Column headers, in order, to order the columns\n * @param widths - Column widths returned by the printTable call that printed the header\n * @param rows - Rows keyed by header\n */\nexport function printTableContinuation(\n headers: string[],\n widths: ColumnWidths,\n rows: Array<Record<string, string>>\n): void {\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n console.log(rowParts.join(''));\n }\n}\n\n/**\n * Prints an error message\n */\nexport function printError(message: string): void {\n console.error(chalk.red(`Error: ${message}`));\n}\n\n/** Single right-pointing angle quotation mark, flex-cli's error-page bullet */\nconst ERROR_ARROW = '\u203A';\n\n/**\n * Builds one error-page line: a space, the bold red arrow, then the text\n *\n * The text carries its own leading spacing, as flex-cli's own error-page\n * fragments do, so a nested line can indent further than the section it hangs\n * under.\n *\n * @param text - Everything that follows the arrow, including its leading space\n */\nexport function errorPageLine(text: string): string {\n return ` ${chalk.bold.red(ERROR_ARROW)}${text}`;\n}\n\n/**\n * Prints flex-cli's error page to stderr\n *\n * Every line is prefixed with a bold red arrow, sections are separated by an\n * arrow-only line, and the page ends with two blank lines. Reproduced from\n * flex-cli's error-page (api/client.cljs) so a failed API call writes the same\n * bytes we do.\n *\n * A section may carry embedded newlines, which are written through untouched:\n * flex-cli re-prefixes only the first line of a section, so any further line\n * has to supply its own arrow through errorPageLine.\n *\n * @param sections - Sections of the page, each without its trailing newline\n */\nexport function printErrorPage(sections: string[]): void {\n const page = sections.map(section => `${errorPageLine(` ${section}`)}\\n`).join(`${errorPageLine(' ')}\\n`);\n process.stderr.write(`${page}\\n\\n`);\n}\n\n/**\n * Prints flex-cli's argument parse error, naming every missing option at once\n *\n * Commander stops at the first missing required option, while flex-cli lists\n * them all in declaration order, so callers collect the missing options by hand\n * and pass them here.\n *\n * @param missing - Option names in declaration order, e.g. ['--path', '--marketplace']\n */\nexport function printMissingOptions(missing: string[]): void {\n console.error('Could not parse arguments:');\n for (const option of missing) {\n console.error(`${option} is required`);\n }\n}\n\n/**\n * Prints a success message\n */\nexport function printSuccess(message: string): void {\n console.log(chalk.green(message));\n}\n\n/**\n * Prints a warning message\n *\n * Goes to stderr, as flex-cli's ppd-err does, so that a warning never lands in\n * output a script is capturing: deploy-test.sh compares a push's whole stdout\n * against \"No changes\".\n */\nexport function printWarning(message: string): void {\n console.error(chalk.yellow(`Warning: ${message}`));\n}\n", "/**\n * Process create command\n */\n\nimport { createProcess as sdkCreateProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport {\n ensureProcessDir,\n ensureTemplates,\n processFilePath,\n readTemplates,\n} from '../../util/process-files.js';\nimport { readFileSync } from 'node:fs';\n\n/**\n * Creates a new transaction process\n */\nexport async function createProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n ensureProcessDir(path);\n\n const definition = readFileSync(processFilePath(path), 'utf-8');\n const templates = readTemplates(path);\n ensureTemplates(path, templates);\n\n const result = await sdkCreateProcess(\n undefined,\n marketplace,\n processName,\n definition,\n templates\n );\n\n printSuccess(`Process ${result.name} successfully created.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create process');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process directory helpers\n *\n * Mirrors what upstream flex-cli does before it uploads a process: locate the\n * process.edn file, read the templates directory, and check that every\n * notification the process declares has a template on disk. Upstream splits\n * this between io-util and process-util; there is little enough of it to keep\n * it in one place here.\n */\n\nimport { readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { parseProcessFile, type ProcessTemplate } from 'sharetribe-flex-build-sdk';\nimport { printWarning } from './output.js';\n\n/**\n * Returns the path of the process.edn file inside a process directory.\n */\nexport function processFilePath(path: string): string {\n return join(path, 'process.edn');\n}\n\n/**\n * Throws unless the given path is a process directory, i.e. one holding a\n * process.edn file. Matches upstream's ensure-process-dir!.\n */\nexport function ensureProcessDir(path: string): void {\n try {\n if (statSync(processFilePath(path)).isFile()) return;\n } catch {\n // Fall through to the same error a non-file gives.\n }\n throw new Error('--path should be a process directory');\n}\n\n/**\n * Reads the email templates that sit under <path>/templates, each in its own\n * directory holding <name>-html.html and <name>-subject.txt.\n */\nexport function readTemplates(path: string): ProcessTemplate[] {\n const templatesDir = join(path, 'templates');\n const templates: ProcessTemplate[] = [];\n\n let templateNames: string[];\n try {\n templateNames = readdirSync(templatesDir);\n } catch {\n return templates;\n }\n\n for (const name of templateNames) {\n const templateDir = join(templatesDir, name);\n try {\n templates.push({\n name,\n html: readFileSync(join(templateDir, `${name}-html.html`), 'utf-8'),\n subject: readFileSync(join(templateDir, `${name}-subject.txt`), 'utf-8'),\n });\n } catch {\n // A directory without both halves is not a template.\n }\n }\n\n return templates;\n}\n\n/**\n * Checks the templates on disk against the notifications the process declares:\n * a notification whose template is missing is an error, a template nothing\n * refers to is a warning. This is the only reason the process file is parsed;\n * what gets uploaded is always the file's own text. Matches upstream's\n * ensure-templates!.\n */\nexport function ensureTemplates(path: string, templates: ProcessTemplate[]): void {\n const { notifications } = parseProcessFile(processFilePath(path));\n const templateNames = new Set(templates.map((t) => t.name));\n const usedNames = new Set(notifications.map((n) => n.template));\n\n for (const name of templateNames) {\n if (!usedNames.has(name)) {\n printWarning(`template exists but is not used in the process: ${name}`);\n }\n }\n\n const missing = notifications.filter((n) => !templateNames.has(n.template));\n if (missing.length > 0) {\n throw new Error(\n missing\n .map((n) => `Template ${n.template} not found for notification ${unqualified(n.name)}`)\n .join('\\n')\n );\n }\n}\n\n/**\n * Drops a keyword's namespace, so :notification/booking-accepted reads as\n * booking-accepted. parseProcessFile keeps the namespace; flex-cli's error\n * message does not.\n */\nfunction unqualified(keyword: string): string {\n return keyword.slice(keyword.indexOf('/') + 1);\n}\n", "/**\n * Process push command\n */\n\nimport { pushProcess as sdkPushProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport {\n ensureProcessDir,\n ensureTemplates,\n processFilePath,\n readTemplates,\n} from '../../util/process-files.js';\nimport { readFileSync } from 'node:fs';\n\n/**\n * Pushes a new version of an existing process\n */\nexport async function pushProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n ensureProcessDir(path);\n\n const definition = readFileSync(processFilePath(path), 'utf-8');\n const templates = readTemplates(path);\n ensureTemplates(path, templates);\n\n const result = await sdkPushProcess(undefined, marketplace, processName, definition, templates);\n\n if (result.noChanges) {\n console.log('No changes');\n } else {\n printSuccess(`Version ${result.version} successfully saved for process ${processName}`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push process');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process pull command\n */\n\nimport { getProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { writeFileSync, mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Pulls a process from the server\n */\nexport async function pullProcess(\n marketplace: string,\n processName: string,\n path: string,\n version?: string,\n alias?: string\n): Promise<void> {\n try {\n const process = await getProcess(undefined, marketplace, processName, { version, alias });\n\n if (!process.definition) {\n throw new Error('No process definition in response');\n }\n\n // Ensure directory exists (print message if creating new directory)\n const { existsSync } = await import('node:fs');\n const dirExists = existsSync(path);\n mkdirSync(path, { recursive: true });\n\n if (!dirExists) {\n console.error(`Creating a new directory: ${path}`);\n }\n\n // Write process.edn file\n const processFilePath = join(path, 'process.edn');\n writeFileSync(processFilePath, process.definition, 'utf-8');\n\n // Write email templates if they exist\n const templates = process.emailTemplates || [];\n\n if (templates && Array.isArray(templates) && templates.length > 0) {\n const templatesDir = join(path, 'templates');\n mkdirSync(templatesDir, { recursive: true });\n\n for (const template of templates) {\n const templateName = template.name;\n const htmlContent = template.html;\n const subjectContent = template.subject;\n\n if (templateName) {\n // Create subdirectory for this template\n const templateSubdir = join(templatesDir, templateName);\n mkdirSync(templateSubdir, { recursive: true });\n\n // Write HTML file\n if (htmlContent) {\n const htmlPath = join(templateSubdir, `${templateName}-html.html`);\n writeFileSync(htmlPath, htmlContent, 'utf-8');\n }\n\n // Write subject file\n if (subjectContent) {\n const subjectPath = join(templateSubdir, `${templateName}-subject.txt`);\n writeFileSync(subjectPath, subjectContent, 'utf-8');\n }\n }\n }\n }\n\n console.error(`Saved process to ${path}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull process');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process alias commands\n */\n\nimport {\n createAlias as sdkCreateAlias,\n updateAlias as sdkUpdateAlias,\n deleteAlias as sdkDeleteAlias\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\n\n/**\n * Creates a process alias\n */\nexport async function createAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkCreateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully created to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create alias');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Updates a process alias\n */\nexport async function updateAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkUpdateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully updated to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update alias');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Deletes a process alias\n */\nexport async function deleteAlias(\n marketplace: string,\n processName: string,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkDeleteAlias(undefined, marketplace, processName, alias);\n\n printSuccess(`Alias ${result.alias} successfully deleted.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to delete alias');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Combined process command - create-or-push-and-create-or-update-alias\n *\n * Composes the SDK's endpoint primitives rather than calling a high-level SDK\n * helper: the SDK is a one-function-per-endpoint surface, and this workflow is\n * the CLI's own.\n */\n\nimport {\n createAlias,\n createProcess,\n listProcessVersions,\n pushProcess,\n updateAlias,\n type ProcessVersion,\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport {\n ensureProcessDir,\n ensureTemplates,\n processFilePath,\n readTemplates,\n} from '../../util/process-files.js';\nimport { readFileSync } from 'node:fs';\n\n/**\n * Reads a process's versions, or returns null when the marketplace has no\n * process by that name.\n *\n * This one call decides everything the command branches on: whether the\n * process exists at all, and, because aliases sit on the versions they point\n * at, whether the alias already exists. Catching a create or a push failure\n * would not, since getProcess cannot tell \"no such process\" from \"no such\n * alias\".\n */\nasync function readVersions(\n marketplace: string,\n processName: string\n): Promise<ProcessVersion[] | null> {\n try {\n return await listProcessVersions(undefined, marketplace, processName);\n } catch (error) {\n if (error && typeof error === 'object' && (error as { code?: string }).code === 'tx-process-not-found') {\n return null;\n }\n throw error;\n }\n}\n\n/**\n * Creates or pushes a process and creates or updates an alias\n *\n * Prints exactly what the equivalent flex-cli commands print for each step it\n * performs, so scripts that grep the output of process create, process push\n * and the alias commands read this command's output the same way.\n */\nexport async function createOrPushAndCreateOrUpdateAlias(\n marketplace: string,\n processName: string,\n path: string,\n alias: string\n): Promise<void> {\n try {\n ensureProcessDir(path);\n\n // The file's own text is what gets uploaded. The parse inside\n // ensureTemplates only checks that the notifications' templates are on disk.\n const definition = readFileSync(processFilePath(path), 'utf-8');\n const templates = readTemplates(path);\n ensureTemplates(path, templates);\n\n const versions = await readVersions(marketplace, processName);\n\n if (versions === null) {\n const created = await createProcess(\n undefined,\n marketplace,\n processName,\n definition,\n templates\n );\n printSuccess(`Process ${created.name} successfully created.`);\n\n const aliasResult = await createAlias(\n undefined,\n marketplace,\n processName,\n created.version,\n alias\n );\n printSuccess(\n `Alias ${aliasResult.alias} successfully created to point to version ${aliasResult.version}.`\n );\n return;\n }\n\n const aliasExists = versions.some((v) => v.aliases?.includes(alias));\n\n const pushed = await pushProcess(\n undefined,\n marketplace,\n processName,\n definition,\n templates\n );\n\n let version: number;\n if (pushed.noChanges) {\n // Nothing to push means the file already matches the newest version, so\n // that is the version the alias should point at.\n console.log('No changes');\n version = Math.max(...versions.map((v) => v.version));\n } else if (pushed.version === undefined) {\n throw new Error(`The API saved a version of ${processName} but did not say which`);\n } else {\n version = pushed.version;\n printSuccess(`Version ${version} successfully saved for process ${processName}`);\n }\n\n if (aliasExists) {\n const aliasResult = await updateAlias(undefined, marketplace, processName, version, alias);\n printSuccess(\n `Alias ${aliasResult.alias} successfully updated to point to version ${aliasResult.version}.`\n );\n } else {\n const aliasResult = await createAlias(undefined, marketplace, processName, version, alias);\n printSuccess(\n `Alias ${aliasResult.alias} successfully created to point to version ${aliasResult.version}.`\n );\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create/push process and alias');\n }\n process.exitCode = 1; return;\n }\n}\n", "/**\n * Process command - main entry point for process subcommands\n */\n\nimport { Command } from 'commander';\nimport { listProcesses } from './list.js';\nimport { createProcess } from './create.js';\nimport { pushProcess } from './push.js';\nimport { pullProcess } from './pull.js';\nimport { createAlias, updateAlias, deleteAlias } from './aliases.js';\nimport { createOrPushAndCreateOrUpdateAlias } from './combined.js';\n\n/**\n * Registers all process subcommands\n */\nexport function registerProcessCommands(program: Command): void {\n // Register the parent 'process' command for help display\n const processCmd = program\n .command('process')\n .description('describe a process file')\n .option('--path <PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('--transition <TRANSITION_NAME>', 'transition name, e.g. transition/request to get more details of it')\n .action(async (options) => {\n // Process describe functionality\n if (options.path) {\n console.log(`Describing process at: ${options.path}`);\n if (options.transition) {\n console.log(`Transition: ${options.transition}`);\n }\n // TODO: Implement actual process file parsing and description\n console.log('Process description not yet implemented');\n } else {\n // If no options, show help\n processCmd.outputHelp();\n }\n });\n\n // Register subcommands - these are registered as BOTH subcommands (for help) and top-level (for routing)\n\n // process list (as subcommand)\n processCmd\n .command('list')\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await listProcesses(marketplace, options.process);\n });\n\n // process create\n processCmd\n .command('create')\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n // process push\n processCmd\n .command('push')\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n // process pull\n processCmd\n .command('pull')\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n // process create-alias\n processCmd\n .command('create-alias')\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .allowUnknownOption(false)\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process update-alias\n processCmd\n .command('update-alias')\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process delete-alias\n processCmd\n .command('delete-alias')\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n // process deploy (combined command: create-or-push-and-create-or-update-alias)\n processCmd\n .command('deploy')\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n\n // Register top-level command aliases for routing (hidden from help)\n // These handle the routed commands like 'process-pull' that avoid Commander's parent/child option conflicts\n\n program\n .command('process-list', { hidden: true })\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await listProcesses(marketplace, options.process);\n });\n\n program\n .command('process-create', { hidden: true })\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-push', { hidden: true })\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-pull', { hidden: true })\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n program\n .command('process-create-alias', { hidden: true })\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-update-alias', { hidden: true })\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-delete-alias', { hidden: true })\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n program\n .command('process-deploy', { hidden: true })\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n}\n", "/**\n * Search command - manage search schemas\n */\n\nimport { Command } from 'commander';\nimport {\n listSearchSchemas as sdkListSearchSchemas,\n setSearchSchema as sdkSetSearchSchema,\n unsetSearchSchema as sdkUnsetSearchSchema,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\ninterface SetSchemaOptions {\n key: string;\n scope: string;\n type: string;\n doc?: string;\n default?: string;\n schemaFor?: string;\n}\n\ninterface UnsetSchemaOptions {\n key: string;\n scope: string;\n schemaFor?: string;\n}\n\n/**\n * Scope label mapping\n */\nconst SCOPE_LABELS: Record<string, string> = {\n metadata: 'Metadata',\n private: 'Private data',\n protected: 'Protected data',\n public: 'Public data',\n};\n\n/**\n * Sets a search schema field\n */\nasync function setSearchSchema(marketplace: string, opts: SetSchemaOptions): Promise<void> {\n try {\n await sdkSetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n defaultValue: opts.default,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully set for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to set search schema');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Unsets a search schema field\n */\nasync function unsetSearchSchema(marketplace: string, opts: UnsetSchemaOptions): Promise<void> {\n try {\n await sdkUnsetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully unset for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to unset search schema');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Converts default value to display string\n */\nfunction getDefaultValueLabel(value: unknown): string {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value.join(', ');\n }\n\n return String(value);\n}\n\n/**\n * Lists all search schemas\n */\nasync function listSearchSchemas(marketplace: string): Promise<void> {\n try {\n const schemas = await sdkListSearchSchemas(undefined, marketplace);\n\n // No schemas is not a special case: flex-cli passes its column list to\n // print-table, so an empty result still prints the header.\n // Map and sort the data (by schema-for, scope, key)\n const rows = schemas\n .map((s) => ({\n 'Schema for': s.schemaFor,\n 'Scope': s.scope,\n 'Key': s.key,\n 'Type': s.type,\n 'Default value': getDefaultValueLabel(s.defaultValue),\n 'Doc': s.doc || '',\n }))\n .sort((a, b) => {\n // Sort by schema-for, then scope, then key\n if (a['Schema for'] !== b['Schema for']) {\n return a['Schema for'].localeCompare(b['Schema for']);\n }\n if (a['Scope'] !== b['Scope']) {\n return a['Scope'].localeCompare(b['Scope']);\n }\n return a['Key'].localeCompare(b['Key']);\n });\n\n // Print table using flex-cli compatible formatting\n const headers = ['Schema for', 'Scope', 'Key', 'Type', 'Default value', 'Doc'];\n\n // One renderer for every table: search's own copy padded each column to\n // width then used a two space separator, which is the same bytes printTable\n // produces from width + 1 and a one space separator, but it missed the bold\n // header. flex-cli passes its column list here, so an empty result still\n // prints the header.\n printTable(headers, rows);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list search schemas');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers search commands\n */\nexport function registerSearchCommands(program: Command): void {\n const searchCmd = program\n .command('search')\n .description('list all search schemas')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await listSearchSchemas(marketplace);\n });\n\n // search set\n searchCmd\n .command('set')\n .description('set search schema')\n .requiredOption('--key <KEY>', 'key name')\n .requiredOption(\n '--scope <SCOPE>',\n 'extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)'\n )\n .requiredOption('--type <TYPE>', 'value type (either enum, multi-enum, boolean, long or text)')\n .option('--doc <DOC>', 'description of the schema')\n .option('--default <DEFAULT>', 'default value for search if value is not set')\n .option(\n '--schema-for <SCHEMA_FOR>',\n 'Subject of the schema (either listing, userProfile or transaction, defaults to listing)'\n )\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await setSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n default: opts.default,\n schemaFor: opts.schemaFor,\n });\n });\n\n // search unset\n searchCmd\n .command('unset')\n .description('unset search schema')\n .requiredOption('--key <KEY>', 'key name')\n .requiredOption(\n '--scope <SCOPE>',\n 'extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)'\n )\n .option(\n '--schema-for <SCHEMA_FOR>',\n 'Subject of the schema (either listing, userProfile or transaction, defaults to listing)'\n )\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await unsetSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n });\n}\n", "/**\n * Assets commands - manage marketplace assets\n */\n\nimport { Command } from 'commander';\nimport {\n pushAssets as sdkPushAssets,\n stageAsset as sdkStageAsset,\n getApiBaseUrl,\n readAuth,\n type ApiError,\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printMissingOptions } from '../../util/output.js';\nimport { parseApiErrorBody, printApiError, type ApiErrorDetails } from '../../util/api-error.js';\nimport {\n readFileSync,\n writeFileSync,\n existsSync,\n mkdirSync,\n readdirSync,\n statSync,\n unlinkSync,\n createWriteStream,\n} from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport * as http from 'node:http';\nimport * as https from 'node:https';\nimport { tmpdir } from 'node:os';\nimport { pipeline } from 'node:stream/promises';\nimport chalk from 'chalk';\nimport edn from 'jsedn';\nimport yauzl from 'yauzl';\n\n\ninterface AssetMetadata {\n version: string;\n assets: Array<{ path: string; 'content-hash': string }>;\n}\n\nconst ASSET_META_FILENAME = 'meta/asset-meta.edn';\nconst ASSETS_DIR = 'assets/';\nconst CLEAR_LINE = '\\x1b[K';\nconst CARRIAGE_RETURN = '\\r';\n\nfunction parseAssetMetadataEdn(content: string): AssetMetadata | null {\n try {\n const parsed = edn.parse(content);\n const version = parsed.at(edn.kw(':version')) || parsed.at(edn.kw(':aliased-version'));\n const assets = parsed.at(edn.kw(':assets'));\n\n const assetList: Array<{ path: string; 'content-hash': string }> = [];\n if (assets && assets.val) {\n for (const asset of assets.val) {\n assetList.push({\n path: asset.at(edn.kw(':path')),\n 'content-hash': asset.at(edn.kw(':content-hash')),\n });\n }\n }\n\n if (!version) {\n return null;\n }\n\n return { version, assets: assetList };\n } catch {\n return null;\n }\n}\n\n/**\n * Reads asset metadata from .flex-cli/asset-meta.edn\n */\nfunction readAssetMetadata(basePath: string): AssetMetadata | null {\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n if (!existsSync(metaPath)) {\n return null;\n }\n\n try {\n const content = readFileSync(metaPath, 'utf-8');\n return parseAssetMetadataEdn(content);\n } catch {\n return null;\n }\n}\n\n/**\n * Writes asset metadata to .flex-cli/asset-meta.edn\n */\nfunction writeAssetMetadata(basePath: string, metadata: AssetMetadata): void {\n const metaDir = join(basePath, '.flex-cli');\n if (!existsSync(metaDir)) {\n mkdirSync(metaDir, { recursive: true });\n }\n\n const assets = metadata.assets.map(a =>\n new edn.Map([\n edn.kw(':path'), a.path,\n edn.kw(':content-hash'), a['content-hash']\n ])\n );\n\n const ednMap = new edn.Map([\n edn.kw(':version'), metadata.version,\n edn.kw(':assets'), new edn.Vector(assets)\n ]);\n\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n writeFileSync(metaPath, edn.encode(ednMap), 'utf-8');\n}\n\n/**\n * Calculates SHA-1 hash of file content matching backend convention\n * Content is prefixed with `${byte-count}|` before hashing\n */\nfunction calculateHash(data: Buffer): string {\n const prefix = Buffer.from(`${data.length}|`, 'utf-8');\n return createHash('sha1').update(prefix).update(data).digest('hex');\n}\n\n/**\n * Reads all assets from a directory\n */\nfunction readLocalAssets(basePath: string): Array<{ path: string; data: Buffer; hash: string }> {\n const assets: Array<{ path: string; data: Buffer; hash: string }> = [];\n\n function scanDir(dir: string, relativePath: string = '') {\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n if (entry === '.flex-cli') continue; // Skip metadata directory\n if (entry === '.DS_Store') continue; // Skip .DS_Store files\n\n const fullPath = join(dir, entry);\n const relPath = relativePath ? join(relativePath, entry) : entry;\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n scanDir(fullPath, relPath);\n } else if (stat.isFile()) {\n const data = readFileSync(fullPath);\n const hash = calculateHash(data);\n assets.push({ path: relPath, data, hash });\n }\n }\n }\n\n scanDir(basePath);\n return assets;\n}\n\n/**\n * Lists local asset paths without reading file data\n */\nfunction listLocalAssetPaths(basePath: string): string[] {\n const assets: string[] = [];\n\n function scanDir(dir: string, relativePath: string = '') {\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n if (entry === '.flex-cli') continue;\n if (entry === '.DS_Store') continue;\n\n const fullPath = join(dir, entry);\n const relPath = relativePath ? join(relativePath, entry) : entry;\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n scanDir(fullPath, relPath);\n } else if (stat.isFile()) {\n assets.push(relPath);\n }\n }\n }\n\n scanDir(basePath);\n return assets;\n}\n\n/**\n * Validates JSON files\n */\nfunction validateJsonAssets(assets: Array<{ path: string; data: Buffer }>): void {\n for (const asset of assets) {\n if (asset.path.endsWith('.json')) {\n try {\n JSON.parse(asset.data.toString('utf-8'));\n } catch (error) {\n throw new Error(`Invalid JSON in ${asset.path}: ${error}`);\n }\n }\n }\n}\n\nfunction formatDownloadProgress(bytes: number): string {\n const mb = bytes / 1024 / 1024;\n return `${CARRIAGE_RETURN}${CLEAR_LINE}Downloaded ${mb.toFixed(2)}MB`;\n}\n\nfunction printDownloadProgress(stream: NodeJS.ReadableStream): void {\n let downloaded = 0;\n const printProgress = (): void => {\n process.stderr.write(formatDownloadProgress(downloaded));\n };\n const interval = setInterval(printProgress, 100);\n\n stream.on('data', (chunk: Buffer) => {\n downloaded += chunk.length;\n });\n\n stream.on('end', () => {\n clearInterval(interval);\n printProgress();\n process.stderr.write('\\nFinished downloading assets\\n');\n });\n}\n\nfunction getApiKeyOrThrow(): string {\n const auth = readAuth();\n if (!auth?.apiKey) {\n throw new Error('Not logged in. Please provide apiKey or run: sharetribe-community-cli login');\n }\n return auth.apiKey;\n}\n\nfunction getAssetsPullUrl(marketplace: string, version?: string): URL {\n const url = new URL(getApiBaseUrl() + '/assets/pull');\n url.searchParams.set('marketplace', marketplace);\n if (version) {\n url.searchParams.set('version', version);\n } else {\n url.searchParams.set('version-alias', 'latest');\n }\n return url;\n}\n\n/**\n * A non-2xx API response, carrying what the error page needs to render it\n *\n * flex-cli cannot report these at all on pull: it asks for application/zip, gets\n * an edn error body back, and dies on \"No matching clause: application/edn\"\n * before hanging on its download progress line. We print the error page instead.\n */\nclass AssetsApiError extends Error {\n constructor(readonly details: ApiErrorDetails) {\n super(`API call failed. Status: ${details.status}`);\n this.name = 'AssetsApiError';\n }\n}\n\n/**\n * Tells an API error thrown by the SDK from any other failure\n */\nfunction isApiError(error: unknown): error is ApiError {\n return (\n typeof error === 'object' && error !== null && 'status' in error && 'code' in error\n );\n}\n\n/**\n * Reads the API key for the error page, which prints its last four characters\n */\nfunction apiKeyForErrorPage(): string {\n return readAuth()?.apiKey ?? '';\n}\n\nasync function getAssetsZipStream(\n marketplace: string,\n version?: string\n): Promise<http.IncomingMessage> {\n const url = getAssetsPullUrl(marketplace, version);\n const apiKey = getApiKeyOrThrow();\n const isHttps = url.protocol === 'https:';\n const client = isHttps ? https : http;\n\n return new Promise((resolve, reject) => {\n const req = client.request(\n {\n method: 'GET',\n hostname: url.hostname,\n port: url.port || (isHttps ? 443 : 80),\n path: url.pathname + url.search,\n headers: {\n Authorization: `Apikey ${apiKey}`,\n Accept: 'application/zip',\n },\n },\n (res) => {\n const statusCode = res.statusCode || 0;\n if (statusCode < 200 || statusCode >= 300) {\n const chunks: Buffer[] = [];\n res.on('data', (chunk: Buffer) => chunks.push(chunk));\n res.on('end', () => {\n const body = Buffer.concat(chunks).toString('utf-8');\n reject(new AssetsApiError(parseApiErrorBody(body, statusCode)));\n });\n return;\n }\n resolve(res);\n }\n );\n\n req.setTimeout(120000, () => {\n req.destroy(new Error('Request timeout'));\n });\n req.on('error', reject);\n req.end();\n });\n}\n\nfunction createTempZipPath(): string {\n return join(tmpdir(), `assets-${Date.now()}.zip`);\n}\n\nfunction removeAssetsDir(filename: string): string {\n if (filename.startsWith(ASSETS_DIR)) {\n return filename.slice(ASSETS_DIR.length);\n }\n return filename;\n}\n\nfunction readStreamToString(stream: NodeJS.ReadableStream): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n stream.on('data', (chunk: Buffer) => chunks.push(chunk));\n stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));\n stream.on('error', reject);\n });\n}\n\nasync function unzipAssets(zipPath: string, basePath: string): Promise<AssetMetadata> {\n return new Promise((resolve, reject) => {\n yauzl.open(zipPath, { lazyEntries: true }, (err, zipfile) => {\n if (err || !zipfile) {\n reject(err || new Error('Failed to open zip file'));\n return;\n }\n\n let assetMeta: AssetMetadata | null = null;\n\n zipfile.on('error', reject);\n zipfile.on('end', () => {\n if (!assetMeta) {\n reject(new Error('Asset metadata not found in zip'));\n return;\n }\n resolve(assetMeta);\n });\n\n zipfile.readEntry();\n zipfile.on('entry', (entry) => {\n if (entry.fileName.endsWith('/')) {\n zipfile.readEntry();\n return;\n }\n\n zipfile.openReadStream(entry, (streamErr, readStream) => {\n if (streamErr || !readStream) {\n reject(streamErr || new Error('Failed to read zip entry'));\n return;\n }\n\n if (entry.fileName === ASSET_META_FILENAME) {\n readStreamToString(readStream)\n .then((content) => {\n assetMeta = parseAssetMetadataEdn(content);\n if (!assetMeta) {\n reject(new Error('Invalid asset metadata'));\n return;\n }\n zipfile.readEntry();\n })\n .catch(reject);\n return;\n }\n\n const assetPath = join(basePath, removeAssetsDir(entry.fileName));\n const assetDir = dirname(assetPath);\n if (!existsSync(assetDir)) {\n mkdirSync(assetDir, { recursive: true });\n }\n\n pipeline(readStream, createWriteStream(assetPath))\n .then(() => zipfile.readEntry())\n .catch(reject);\n });\n });\n });\n });\n}\n\n/**\n * Pulls assets from remote\n */\nasync function pullAssets(\n marketplace: string,\n path: string,\n version?: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Create directory if it doesn't exist\n if (!existsSync(path)) {\n mkdirSync(path, { recursive: true });\n }\n\n const stat = statSync(path);\n if (!stat.isDirectory()) {\n throw new Error(`${path} is not a directory`);\n }\n\n const localAssets = prune ? listLocalAssetPaths(path) : [];\n const currentMeta = readAssetMetadata(path);\n const tempZipPath = createTempZipPath();\n\n try {\n const zipStream = await getAssetsZipStream(marketplace, version);\n printDownloadProgress(zipStream);\n await pipeline(zipStream, createWriteStream(tempZipPath));\n\n const newAssetMeta = await unzipAssets(tempZipPath, path);\n const remoteVersion = newAssetMeta.version;\n\n const deletedPaths = prune\n ? new Set(localAssets.filter(p => !newAssetMeta.assets.some(a => a.path === p)))\n : new Set<string>();\n\n const updated = currentMeta?.version !== remoteVersion;\n const shouldReportUpdate = updated || deletedPaths.size > 0;\n\n if (deletedPaths.size > 0) {\n for (const assetPath of deletedPaths) {\n const fullPath = join(path, assetPath);\n if (existsSync(fullPath)) {\n unlinkSync(fullPath);\n }\n }\n }\n\n if (shouldReportUpdate) {\n writeAssetMetadata(path, {\n version: remoteVersion,\n assets: newAssetMeta.assets,\n });\n console.log(`Version ${remoteVersion} successfully pulled.`);\n } else {\n console.log('Assets are up to date.');\n }\n } finally {\n if (existsSync(tempZipPath)) {\n unlinkSync(tempZipPath);\n }\n }\n } catch (error) {\n if (error instanceof AssetsApiError) {\n printApiError(error.details, marketplace, apiKeyForErrorPage());\n process.exitCode = 1; return;\n }\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull assets');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Filters assets to only those that have changed\n */\nfunction filterChangedAssets(\n existingMeta: Array<{ path: string; 'content-hash': string }>,\n localAssets: Array<{ path: string; hash: string }>\n): Array<{ path: string; data: Buffer; hash: string }> {\n const hashByPath = new Map(existingMeta.map(a => [a.path, a['content-hash']]));\n \n return localAssets.filter(asset => {\n const storedHash = hashByPath.get(asset.path);\n // Assets without stored metadata are treated as changed\n return !storedHash || storedHash !== asset.hash;\n });\n}\n\n/**\n * Pushes assets to remote\n */\nasync function pushAssets(\n marketplace: string,\n path: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Validate path\n if (!existsSync(path) || !statSync(path).isDirectory()) {\n throw new Error(`${path} is not a valid directory`);\n }\n\n // Read current metadata\n const currentMeta = readAssetMetadata(path);\n const currentVersion = currentMeta?.version || 'nil';\n\n // Read local assets\n const localAssets = readLocalAssets(path);\n\n // Validate JSON files\n validateJsonAssets(localAssets);\n\n // Filter to only changed assets\n const changedAssets = filterChangedAssets(currentMeta?.assets || [], localAssets);\n\n // Separate JSON and non-JSON assets\n const isJsonAsset = (assetPath: string): boolean => {\n return assetPath.toLowerCase().endsWith('.json');\n };\n\n const stageableAssets = changedAssets.filter(a => !isJsonAsset(a.path));\n\n // Find assets to delete (if prune enabled)\n const localAssetMap = new Map(localAssets.map(a => [a.path, a]));\n const deleteOperations: Array<{ path: string; op: 'delete' }> = [];\n if (prune && currentMeta) {\n for (const currentAsset of currentMeta.assets) {\n if (!localAssetMap.has(currentAsset.path)) {\n deleteOperations.push({\n path: currentAsset.path,\n op: 'delete',\n });\n }\n }\n }\n\n // Check if there are any changes\n const noOps = changedAssets.length === 0 && deleteOperations.length === 0;\n if (noOps) {\n console.log('Assets are up to date.');\n return;\n }\n\n // Log changed assets. flex-cli logs progress through io-util/log, which\n // writes to stderr, and keeps stdout for the command's result line.\n if (changedAssets.length > 0) {\n const paths = changedAssets.map(a => a.path).join(', ');\n console.error(chalk.green(`Uploading changed assets: ${paths}`));\n }\n\n // Stage non-JSON assets\n const stagedByPath = new Map<string, string>();\n if (stageableAssets.length > 0) {\n const paths = stageableAssets.map(a => a.path).join(', ');\n console.error(chalk.green(`Staging assets: ${paths}`));\n\n for (const asset of stageableAssets) {\n try {\n const stagingResult = await sdkStageAsset(\n undefined,\n marketplace,\n asset.data,\n asset.path\n );\n stagedByPath.set(asset.path, stagingResult.stagingId);\n } catch (error) {\n if (error && typeof error === 'object' && 'code' in error && error.code === 'asset-invalid-content') {\n const detail = 'message' in error ? error.message : 'The file is missing or uses an unsupported format.';\n throw new Error(`Failed to stage image ${asset.path}: ${detail}\\nFix the file and rerun assets push to retry staging.`);\n }\n throw error;\n }\n }\n }\n\n // Build upsert operations\n const upsertOperations = changedAssets.map(asset => {\n const stagingId = stagedByPath.get(asset.path);\n return {\n path: asset.path,\n op: 'upsert' as const,\n ...(stagingId\n ? { stagingId }\n : { data: asset.data, filename: asset.path }),\n };\n });\n\n // Upload to API\n const result = await sdkPushAssets(\n undefined,\n marketplace,\n currentVersion,\n [...upsertOperations, ...deleteOperations]\n );\n\n // Update local metadata\n writeAssetMetadata(path, {\n version: result.version,\n assets: result.assets.map(a => ({\n path: a.path,\n 'content-hash': a.contentHash,\n })),\n });\n\n console.log(`New version ${result.version} successfully created.`);\n } catch (error) {\n if (isApiError(error)) {\n printApiError(\n parseApiErrorBody(error.body ?? '', error.status),\n marketplace,\n apiKeyForErrorPage()\n );\n // flex-cli reads no new version out of the failed response, so it falls\n // into its no-op branch and exits 0. Matched here because byte-for-byte\n // compatibility is the goal, even though it hides a failed push.\n console.log('Assets are up to date.');\n return;\n }\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push assets');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Names the required options a pull or push invocation is missing\n *\n * Declaration order, which is the order flex-cli reports them in.\n */\nfunction missingAssetsOptions(path?: string, marketplace?: string): string[] {\n const missing: string[] = [];\n if (!path) missing.push('--path');\n if (!marketplace) missing.push('--marketplace');\n return missing;\n}\n\n/**\n * Registers assets commands\n */\nexport function registerAssetsCommands(program: Command): void {\n const assetsCmd = program.command('assets').description('manage marketplace assets');\n\n // assets pull\n assetsCmd\n .command('pull')\n .description('pull assets from remote')\n .option('--path <PATH>', 'path to directory where assets will be stored')\n .option('--version <VERSION>', 'version of assets to pull')\n .option('--prune', 'delete local files no longer present as remote assets')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n const missing = missingAssetsOptions(opts.path, marketplace);\n if (missing.length > 0) {\n printMissingOptions(missing);\n process.exitCode = 1; return;\n }\n await pullAssets(marketplace, opts.path, opts.version, opts.prune);\n });\n\n // assets push\n assetsCmd\n .command('push')\n .description('push assets to remote')\n .option('--path <PATH>', 'path to directory with assets')\n .option('--prune', 'delete remote assets no longer present locally')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n const missing = missingAssetsOptions(opts.path, marketplace);\n if (missing.length > 0) {\n printMissingOptions(missing);\n process.exitCode = 1; return;\n }\n await pushAssets(marketplace, opts.path, opts.prune);\n });\n}\n\nexport const __test__ = {\n formatDownloadProgress,\n removeAssetsDir,\n parseAssetMetadataEdn,\n};\n", "/**\n * API error rendering\n *\n * Reproduces the branches of flex-cli's default-error-format\n * (src/sharetribe/flex_cli/api/client.cljs) that a failing assets call can\n * reach, so our stderr matches flex-cli byte for byte.\n */\n\nimport chalk from 'chalk';\nimport edn from 'jsedn';\nimport { errorPageLine, printErrorPage } from './output.js';\n\nconst BIN = 'sharetribe-community-cli';\n\n/** JSON Schema validation failures the API reported against a single asset */\nexport interface AssetValidationError {\n /** Path of the asset that failed validation */\n path: string;\n /** Validation messages for that asset, in response order, duplicates dropped */\n messages: string[];\n}\n\nexport interface ApiErrorDetails {\n status: number;\n /** errors[0].title from the response body, when the body carried one */\n title?: string;\n /** Raw response body, used as the reason when the body carried no title */\n originalText?: string;\n /** errors[0].details.assets, listed under the reason on the error page */\n assetErrors?: AssetValidationError[];\n}\n\n/**\n * Reads errors[0].title out of a JSON error body\n */\nfunction titleFromJson(body: string): string | undefined {\n try {\n const parsed = JSON.parse(body) as { errors?: Array<{ title?: string }> };\n return parsed.errors?.[0]?.title;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reads errors[0].title out of an edn error body\n */\nfunction titleFromEdn(body: string): string | undefined {\n try {\n const errors = edn.parse(body).at(edn.kw(':errors'));\n const first = errors?.val?.[0];\n return first ? first.at(edn.kw(':title')) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reads errors[0].details.assets out of a JSON error body\n *\n * Only asset pushes carry these details, and the Build API answers that\n * endpoint in JSON, so the edn bodies that assets pull returns are not searched\n * for them.\n *\n * Duplicate errors are dropped per asset, as flex-cli's asset-validation-errors\n * does. It deduplicates whole error objects rather than messages, so two\n * failures that share a message but differ elsewhere are both printed.\n *\n * @param body - Raw response body\n */\nfunction assetErrorsFromJson(body: string): AssetValidationError[] | undefined {\n let assets: Array<{ path?: string; errors?: Array<{ message?: string }> }> | undefined;\n try {\n const parsed = JSON.parse(body) as {\n errors?: Array<{\n details?: { assets?: Array<{ path?: string; errors?: Array<{ message?: string }> }> };\n }>;\n };\n assets = parsed.errors?.[0]?.details?.assets;\n } catch {\n return undefined;\n }\n\n if (!Array.isArray(assets) || assets.length === 0) {\n return undefined;\n }\n\n return assets.map(asset => {\n const seen = new Set<string>();\n const messages: string[] = [];\n for (const error of asset.errors ?? []) {\n const key = JSON.stringify(error);\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n messages.push(error.message ?? '');\n }\n return { path: asset.path ?? '', messages };\n });\n}\n\n/**\n * Renders the per-asset validation lines that hang under the reason\n *\n * Each asset gets a line naming its path in bold and one further line per\n * message, indented two spaces deeper. Every line carries its own arrow because\n * the whole block is one error-page section.\n *\n * @param assetErrors - Validation failures, one entry per asset\n */\nfunction formatAssetErrors(assetErrors: AssetValidationError[]): string {\n return assetErrors\n .flatMap(({ path, messages }) => [\n errorPageLine(` In ${chalk.bold(path)}:`),\n ...messages.map(message => errorPageLine(` ${message}`)),\n ])\n .map(line => `\\n${line}`)\n .join('');\n}\n\n/**\n * Parses an API error body into what the error page prints\n *\n * The Build API answers JSON on most endpoints but edn on assets pull, which\n * asks for application/zip, so both shapes have to be understood here.\n *\n * @param body - Raw response body\n * @param status - HTTP status of the response\n */\nexport function parseApiErrorBody(body: string, status: number): ApiErrorDetails {\n return {\n status,\n title: titleFromJson(body) ?? titleFromEdn(body),\n originalText: body || undefined,\n assetErrors: assetErrorsFromJson(body),\n };\n}\n\n/**\n * Prints the error page flex-cli prints for a failed API call\n *\n * The 401 page names the marketplace and the last four characters of the API\n * key, exactly as flex-cli does. flex-cli also has a 401 page specific to\n * /current_admin/show, which only its login command can reach and which is not\n * reproduced here.\n *\n * @param details - Status and reason taken from the response\n * @param marketplace - Marketplace the call was made against\n * @param apiKey - API key the call used; only its last four characters are printed\n */\nexport function printApiError(details: ApiErrorDetails, marketplace: string, apiKey: string): void {\n const { status, title, originalText, assetErrors } = details;\n\n if (status === 500) {\n printErrorPage(['API call failed. Reason: Internal server error.']);\n return;\n }\n\n if (status === 401) {\n printErrorPage([\n 'Error: Access denied',\n `Failed to access marketplace ${chalk.bold(marketplace)} with API key ending with ...${chalk.bold(apiKey.slice(-4))}`,\n `Use ${chalk.bold(`${BIN} login`)} to relogin if needed.`,\n ]);\n return;\n }\n\n const reason = `API call failed. Status: ${status}, reason: ${title || originalText || 'Unspecified'}`;\n printErrorPage([\n assetErrors?.length ? `${reason}${formatAssetErrors(assetErrors)}` : reason,\n ]);\n}\n", "/**\n * Notifications commands - manage email notifications\n */\n\nimport { Command } from 'commander';\nimport {\n sendNotification as sdkSendNotification,\n previewNotification as sdkPreviewNotification,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport { readFileSync, existsSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createServer, IncomingMessage, ServerResponse } from 'node:http';\n\n\n/**\n * Reads a notification template from a directory\n */\nfunction readTemplate(templatePath: string): { html: string; subject: string } {\n if (!existsSync(templatePath) || !statSync(templatePath).isDirectory()) {\n throw new Error(`Template directory not found: ${templatePath}`);\n }\n\n const htmlPath = join(templatePath, 'template.html');\n const subjectPath = join(templatePath, 'template-subject.txt');\n\n if (!existsSync(htmlPath)) {\n throw new Error(`template.html not found in ${templatePath}`);\n }\n\n if (!existsSync(subjectPath)) {\n throw new Error(`template-subject.txt not found in ${templatePath}`);\n }\n\n const html = readFileSync(htmlPath, 'utf-8');\n const subject = readFileSync(subjectPath, 'utf-8').trim();\n\n return { html, subject };\n}\n\n/**\n * Reads template context JSON file\n */\nfunction readContext(contextPath?: string): unknown {\n if (!contextPath) {\n return undefined;\n }\n\n if (!existsSync(contextPath)) {\n throw new Error(`Context file not found: ${contextPath}`);\n }\n\n const content = readFileSync(contextPath, 'utf-8');\n try {\n return JSON.parse(content);\n } catch (error) {\n throw new Error(`Invalid JSON in context file: ${error}`);\n }\n}\n\n/**\n * Sends a preview email to the marketplace admin\n */\nasync function sendNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n const result = await sdkSendNotification(undefined, marketplace, { template, context });\n\n console.log(`Preview successfully sent to ${result.adminEmail}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to send notification');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Previews a notification in the browser\n */\nasync function previewNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n console.log(`Template: ${templatePath}`);\n console.log(`Subject: ${template.subject}`);\n console.log('');\n console.log('Starting preview server at http://localhost:3535');\n console.log('Press Ctrl+C to stop');\n console.log('');\n\n let previewHtml: string | null = null;\n\n // Fetch preview from API\n const fetchPreview = async () => {\n try {\n const result = await sdkPreviewNotification(undefined, marketplace, { template, context });\n\n // Inject title into HTML\n const html = result.html;\n const titleTag = `<title>${template.subject}</title>`;\n\n if (html.includes('<head>')) {\n previewHtml = html.replace('<head>', `<head>\\n${titleTag}`);\n } else if (html.includes('<html>')) {\n previewHtml = html.replace('<html>', `<html>\\n<head>${titleTag}</head>`);\n } else {\n previewHtml = `<html><head>${titleTag}</head><body>${html}</body></html>`;\n }\n } catch (error) {\n const errorMessage = error && typeof error === 'object' && 'message' in error\n ? (error.message as string)\n : 'Failed to preview notification';\n\n previewHtml = `\n <html>\n <head><title>Error</title></head>\n <body style=\"font-family: sans-serif; padding: 20px;\">\n <h1 style=\"color: #d32f2f;\">Error</h1>\n <pre style=\"background: #f5f5f5; padding: 15px; border-radius: 4px;\">${errorMessage}</pre>\n </body>\n </html>\n `;\n }\n };\n\n // Initial fetch\n await fetchPreview();\n\n // Create HTTP server\n const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/' || req.url === '') {\n // Refresh preview on each request\n await fetchPreview();\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(previewHtml);\n } else {\n res.writeHead(404, { 'Content-Type': 'text/plain' });\n res.end('Not Found');\n }\n });\n\n server.listen(3535, () => {\n console.log('Preview server started. Open http://localhost:3535 in your browser.');\n });\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nShutting down preview server...');\n server.close(() => {\n process.exitCode = 0; return;\n });\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to preview notification');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers notifications commands\n */\nexport function registerNotificationsCommands(program: Command): void {\n const notificationsCmd = program\n .command('notifications')\n .description('manage email notifications');\n\n // notifications preview\n notificationsCmd\n .command('preview')\n .description('render a preview of an email template')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await previewNotification(marketplace, opts.template, opts.context);\n });\n\n // notifications send\n notificationsCmd\n .command('send')\n .description('send a preview of an email template to the logged in admin')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await sendNotification(marketplace, opts.template, opts.context);\n });\n}\n", "/**\n * Listing approval command - DEPRECATED\n *\n * This command is deprecated and should not be used.\n * Use the Sharetribe Console instead.\n */\n\nimport { Command } from 'commander';\nimport {\n getListingApprovalStatus as sdkGetStatus,\n enableListingApproval as sdkEnable,\n disableListingApproval as sdkDisable,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../util/output.js';\n\n/**\n * Gets current listing approval status\n */\nasync function getStatus(marketplace: string): Promise<void> {\n try {\n const result = await sdkGetStatus(undefined, marketplace);\n\n if (result.enabled) {\n console.log(`Listing approvals are enabled in ${marketplace}`);\n } else {\n console.log(`Listing approvals are disabled in ${marketplace}`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to get listing approval status');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Enables listing approvals\n */\nasync function enableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkEnable(undefined, marketplace);\n console.log(`Successfully enabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to enable listing approvals');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Disables listing approvals\n */\nasync function disableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkDisable(undefined, marketplace);\n console.log(`Successfully disabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to disable listing approvals');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers listing-approval command\n */\nexport function registerListingApprovalCommand(program: Command): void {\n const cmd = program\n .command('listing-approval')\n .description('manage listing approvals (DEPRECATED - use Console instead)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - show status\n cmd.action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await getStatus(marketplace);\n });\n\n // Enable subcommand\n cmd\n .command('enable')\n .description('enable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await enableApprovals(marketplace);\n });\n\n // Disable subcommand\n cmd\n .command('disable')\n .description('disable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await disableApprovals(marketplace);\n });\n}\n", "/**\n * Events command - query marketplace events\n */\n\nimport { Command } from 'commander';\nimport { printTable, printTableContinuation, printError, type ColumnWidths } from '../../util/output.js';\nimport {\n queryEvents as sdkQueryEvents,\n pollEvents as sdkPollEvents,\n type EventData as SdkEventData\n} from 'sharetribe-flex-build-sdk';\n\n/** Event table columns, in flex-cli's order */\nconst EVENT_HEADERS = [\n 'Seq ID',\n 'Resource ID',\n 'Event type',\n 'Created at local time',\n 'Source',\n 'Actor',\n];\n\ninterface EventsQueryOptions {\n resourceId?: string;\n relatedResourceId?: string;\n eventTypes?: string;\n sequenceId?: number;\n afterSeqId?: number;\n beforeSeqId?: number;\n afterTs?: string;\n beforeTs?: string;\n limit?: number;\n json?: boolean;\n jsonPretty?: boolean;\n}\n\n/**\n * Validates query parameters\n */\nfunction validateParams(opts: EventsQueryOptions): void {\n const exclusiveParams = [\n opts.sequenceId !== undefined,\n opts.afterSeqId !== undefined,\n opts.beforeSeqId !== undefined,\n opts.afterTs !== undefined,\n opts.beforeTs !== undefined,\n ];\n\n if (exclusiveParams.filter(Boolean).length > 1) {\n throw new Error(\n 'Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified'\n );\n }\n\n if (opts.resourceId && opts.relatedResourceId) {\n throw new Error('Only one of --resource or --related-resource can be specified');\n }\n}\n\n/**\n * Formats timestamp to match flex-cli format: YYYY-MM-DD H:MM:SS AM/PM\n */\nfunction formatTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Queries events from API\n */\nasync function queryEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n const events = await sdkQueryEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n sequenceId: opts.sequenceId,\n afterSeqId: opts.afterSeqId,\n beforeSeqId: opts.beforeSeqId,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit,\n }\n );\n\n // Output format. No events is not a special case: flex-cli prints the\n // header-only table, and nothing at all under --json or --json-pretty, so\n // that a parser reading the pipe never sees a prose line.\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n EVENT_HEADERS,\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to query events');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Tails events (live streaming)\n */\nasync function tailEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n console.log('Tailing events... Press Ctrl+C to stop');\n console.log('');\n\n let tailWidths: ColumnWidths | undefined;\n\n const stopPolling = sdkPollEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n limit: opts.limit || 10,\n },\n (events: SdkEventData[]) => {\n // Output events\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n const rows = events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n });\n\n // flex-cli's polling loop prints the header once and every later\n // batch as a continuation, so the columns stay aligned and the\n // header does not repeat on each poll.\n if (tailWidths) {\n printTableContinuation(EVENT_HEADERS, tailWidths, rows);\n } else {\n tailWidths = printTable(EVENT_HEADERS, rows);\n }\n }\n },\n 5000 // 5 second poll interval\n );\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nStopping tail...');\n stopPolling();\n process.exitCode = 0; return;\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to tail events');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers events command\n */\nexport function registerEventsCommand(program: Command): void {\n const cmd = program\n .command('events')\n .description('Get a list of events.')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('--seqid <SEQUENCE_ID>', 'get event with specific sequence ID', parseInt)\n .option('--after-seqid <SEQUENCE_ID>', 'show events after sequence ID (exclusive)', parseInt)\n .option('--before-seqid <SEQUENCE_ID>', 'show events before sequence ID (exclusive)', parseInt)\n .option('--after-ts <TIMESTAMP>', 'show events after timestamp')\n .option('--before-ts <TIMESTAMP>', 'show events before timestamp')\n .option('-l, --limit <NUMBER>', 'limit results (default: 100, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - query\n cmd.action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exitCode = 1; return;\n }\n\n await queryEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n sequenceId: opts.seqid,\n afterSeqId: opts.afterSeqid,\n beforeSeqId: opts.beforeSeqid,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit || 100,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n\n // tail subcommand\n cmd\n .command('tail')\n .description('Tail events live as they happen')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('-l, --limit <NUMBER>', 'limit results per poll (default: 10, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exitCode = 1; return;\n }\n\n await tailEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n limit: opts.limit || 10,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n}\n", "/**\n * Stripe command - manage Stripe integration\n */\n\nimport { Command } from 'commander';\nimport { updateStripeVersion as sdkUpdateStripeVersion, SUPPORTED_STRIPE_VERSIONS } from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport inquirer from 'inquirer';\n\n\n/**\n * Prompts for version selection\n */\nasync function promptForVersion(): Promise<string> {\n const answers = await inquirer.prompt([\n {\n type: 'list',\n name: 'version',\n message: 'Select Stripe API version:',\n choices: [...SUPPORTED_STRIPE_VERSIONS],\n },\n ]);\n\n return answers.version;\n}\n\n/**\n * Prompts for confirmation\n */\nasync function promptForConfirmation(): Promise<boolean> {\n console.log('');\n console.log('WARNING: Changing Stripe API version may affect your integration.');\n console.log('');\n console.log('After updating the Stripe API version, you may need to:');\n console.log('- Handle new Capabilities requirements');\n console.log('- Update identity verification settings');\n console.log('');\n console.log('See Stripe documentation for details:');\n console.log('https://stripe.com/docs/connect/capabilities-overview');\n console.log('https://stripe.com/docs/connect/identity-verification');\n console.log('');\n\n const answers = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirmed',\n message: 'Do you want to continue?',\n default: false,\n },\n ]);\n\n return answers.confirmed;\n}\n\n/**\n * Updates Stripe API version\n */\nasync function updateStripeVersion(\n marketplace: string,\n version?: string,\n force?: boolean\n): Promise<void> {\n try {\n // Get version if not provided\n let selectedVersion = version;\n if (!selectedVersion) {\n selectedVersion = await promptForVersion();\n }\n\n // Get confirmation unless --force flag is used\n if (!force) {\n const confirmed = await promptForConfirmation();\n if (!confirmed) {\n console.log('Cancelled.');\n process.exitCode = 0; return;\n }\n }\n\n // Update via API (SDK validates version)\n await sdkUpdateStripeVersion(undefined, marketplace, selectedVersion);\n\n console.log(`Stripe API version successfully changed to ${selectedVersion}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update Stripe API version');\n }\n process.exitCode = 1; return;\n }\n}\n\n/**\n * Registers stripe commands\n */\nexport function registerStripeCommands(program: Command): void {\n const stripeCmd = program.command('stripe').description('manage Stripe integration');\n\n // stripe update-version\n stripeCmd\n .command('update-version')\n .description('update Stripe API version in use')\n .option('--version <VERSION>', 'Stripe API version to update to')\n .option('-f, --force', 'skip confirmation prompt and force update')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exitCode = 1; return;\n }\n await updateStripeVersion(marketplace, opts.version, opts.force);\n });\n}\n", "/**\n * Debug command - display config and auth info\n */\n\nimport { getConfigMap, readAuth } from 'sharetribe-flex-build-sdk';\n\nfunction maskLast4(value: string): string {\n if (value.length <= 4) {\n return `...${value}`;\n }\n return `...${value.slice(-4)}`;\n}\n\nexport function debug(): void {\n const auth = readAuth();\n const apiKey = auth?.apiKey ? maskLast4(auth.apiKey) : 'No API key set';\n const confMap = getConfigMap();\n\n const confMapEntries = Object.keys(confMap)\n .sort()\n .map((key) => `:${key} ${confMap[key]}`)\n .join(' ');\n const confMapFormatted = confMapEntries ? `{${confMapEntries}}` : '{}';\n\n console.log(`{:api-key ${apiKey}, :conf-map ${confMapFormatted}}`);\n}\n", "/**\n * Custom help formatter to match flex-cli output exactly\n */\n\nimport { Command, Help } from 'commander';\nimport chalk from 'chalk';\n\n/**\n * Formats help text to match flex-cli style\n *\n * flex-cli format:\n * - Description (no label)\n * - VERSION section (for main help only)\n * - USAGE section\n * - COMMANDS section (flattened list of all leaf commands)\n * - OPTIONS section (for subcommands only, not main)\n * - Subcommand help instructions\n *\n * @param cmd - Commander command instance\n * @returns Formatted help text matching flex-cli\n */\nexport function formatHelp(cmd: Command): string {\n const parts: string[] = [];\n const isRootCommand = !cmd.parent;\n\n // Description (no label, just the text)\n const description = cmd.description();\n if (description) {\n parts.push(description);\n parts.push('');\n }\n\n // VERSION section (only for root command)\n if (isRootCommand) {\n const version = cmd.version();\n if (version) {\n parts.push('VERSION');\n parts.push(` ${version}`);\n parts.push('');\n }\n }\n\n // USAGE section\n parts.push('USAGE');\n const usage = formatUsage(cmd);\n parts.push(` $ ${usage}`);\n parts.push('');\n\n // COMMANDS section\n // Note: If command has an action (options), don't show COMMANDS section (like flex-cli)\n const allCommands = collectAllLeafCommands(cmd);\n const hasAction = cmd.options.length > 0 && !isRootCommand;\n\n if (allCommands.length > 0 && !hasAction) {\n parts.push('COMMANDS');\n\n // Calculate max command name length for alignment\n const maxLength = Math.max(...allCommands.map(c => c.name.length));\n\n for (const cmdInfo of allCommands) {\n const paddedName = cmdInfo.name.padEnd(maxLength + 2);\n parts.push(` ${paddedName}${cmdInfo.description}`);\n }\n parts.push('');\n }\n\n // OPTIONS section (only for subcommands, not root)\n if (!isRootCommand) {\n const options = cmd.options;\n if (options.length > 0) {\n parts.push('OPTIONS');\n\n // Calculate max option flags length for alignment\n const maxFlagsLength = Math.max(...options.map(opt => formatOptionFlags(opt).length));\n\n for (const opt of options) {\n const flags = formatOptionFlags(opt);\n const paddedFlags = flags.padEnd(maxFlagsLength + 2);\n const desc = opt.description || '';\n parts.push(` ${paddedFlags}${desc}`);\n }\n parts.push('');\n }\n }\n\n // Subcommand help instructions (only for main and group commands without actions)\n if (allCommands.length > 0 && !hasAction) {\n parts.push('Subcommand help:');\n const cmdName = getCommandName(cmd);\n parts.push(` $ ${cmdName} help [COMMAND]`);\n }\n\n // Always add empty line at end to match flex-cli\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Recursively collects all commands (both parent and leaf commands)\n *\n * flex-cli shows ALL commands, including parent commands that have their own actions\n * Example: both \"events\" and \"events tail\" are shown\n *\n * @param cmd - Commander command instance\n * @returns Array of command info objects with name and description\n */\nfunction collectAllLeafCommands(cmd: Command): Array<{ name: string; description: string }> {\n const results: Array<{ name: string; description: string }> = [];\n const commands = cmd.commands.filter(c => !c._hidden && c.name() !== 'help');\n\n for (const subCmd of commands) {\n const fullName = getCommandFullName(subCmd);\n const subCommands = subCmd.commands.filter(c => !c._hidden);\n\n // Add this command if it has an action or description\n if (subCmd.description()) {\n results.push({\n name: fullName,\n description: subCmd.description() || ''\n });\n }\n\n // If it has subcommands, recurse and add those too\n if (subCommands.length > 0) {\n const subResults = collectAllLeafCommands(subCmd);\n for (const sub of subResults) {\n results.push(sub);\n }\n }\n }\n\n // Add \"help\" command at the beginning if this is root\n if (!cmd.parent) {\n results.unshift({\n name: 'help',\n description: 'display help for Flex CLI'\n });\n }\n\n // Sort alphabetically by command name\n results.sort((a, b) => a.name.localeCompare(b.name));\n\n return results;\n}\n\n/**\n * Gets the command name for usage (flex-cli vs sharetribe-community-cli)\n *\n * @param cmd - Commander command instance\n * @returns Command name (e.g., \"sharetribe-community-cli\" or \"sharetribe-community-cli process\")\n */\nfunction getCommandName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n // Replace first name with \"sharetribe-community-cli\" (or \"flex-cli\" for reference)\n if (names.length > 0) {\n names[0] = 'sharetribe-community-cli';\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats the USAGE line\n *\n * @param cmd - Commander command instance\n * @returns Usage string (e.g., \"sharetribe-community-cli [COMMAND]\" or \"sharetribe-community-cli process list\")\n */\nfunction formatUsage(cmd: Command): string {\n const cmdName = getCommandName(cmd);\n const commands = cmd.commands.filter(c => !c._hidden);\n const hasOptions = cmd.options.length > 0;\n const isRoot = !cmd.parent;\n\n // Root command always shows [COMMAND] if it has subcommands\n if (isRoot && commands.length > 0) {\n return `${cmdName} [COMMAND]`;\n }\n\n // If command has options (its own action), don't show [COMMAND] even if it has subcommands\n // This matches flex-cli behavior for commands like \"process\" which have both action and subcommands\n if (commands.length > 0 && !hasOptions) {\n // Has subcommands but no action\n return `${cmdName} [COMMAND]`;\n } else {\n // Leaf command or command with action - just show the command path\n return cmdName;\n }\n}\n\n/**\n * Gets the full command name including parent path\n *\n * @param cmd - Commander command instance\n * @returns Full command name (e.g., \"process list\" or \"events tail\")\n */\nfunction getCommandFullName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current && current.parent) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats option flags for display\n *\n * @param opt - Commander option instance\n * @returns Formatted flags string (e.g., \"-m, --marketplace=MARKETPLACE_ID\")\n */\nfunction formatOptionFlags(opt: any): string {\n // Commander option flags are in opt.flags (e.g., \"-m, --marketplace <MARKETPLACE_ID>\")\n // We need to parse and reformat this to match flex-cli style\n const flagsStr = opt.flags || '';\n\n // Parse the flags string\n // Format: \"-m, --marketplace <VALUE>\" or \"--flag\" or \"-f\"\n const parts = flagsStr.split(/,\\s*/);\n const formatted: string[] = [];\n\n for (const part of parts) {\n const trimmed = part.trim();\n\n // Check if it has a value placeholder (angle brackets or square brackets)\n const valueMatch = trimmed.match(/^((?:-{1,2}[\\w-]+))\\s*[<\\[]([^\\]>]+)[\\]>]/);\n if (valueMatch) {\n // Has a value: \"-m <MARKETPLACE_ID>\" or \"--marketplace <MARKETPLACE_ID>\"\n const flag = valueMatch[1];\n const valueName = valueMatch[2];\n formatted.push(`${flag}=${valueName}`);\n } else {\n // No value: just the flag\n formatted.push(trimmed);\n }\n }\n\n return formatted.join(', ');\n}\n\n/**\n * Configures Commander.js to use custom help formatter\n *\n * @param program - Commander program instance\n */\nexport function configureHelp(program: Command): void {\n program.configureHelp({\n formatHelp: (cmd: Command, helper: Help) => {\n return formatHelp(cmd);\n }\n });\n}\n", "/**\n * Custom command router to handle Commander.js limitations\n *\n * Commander.js cannot handle parent and child commands with the same option names.\n * This router intercepts argv and routes to the correct command handler.\n */\n\n/**\n * Routes process subcommands to avoid Commander parent/child option conflicts\n *\n * This is necessary because Commander validates parent command options before\n * subcommand actions run, causing conflicts when both use --path.\n */\nexport function routeProcessCommand(argv: string[]): string[] {\n // Check if this is a process subcommand\n const processIndex = argv.findIndex(arg => arg === 'process');\n if (processIndex === -1) {\n return argv;\n }\n\n // Check for subcommands\n const nextArg = argv[processIndex + 1];\n const subcommands = ['list', 'create', 'push', 'pull', 'create-alias', 'update-alias', 'delete-alias', 'deploy'];\n\n if (nextArg && subcommands.includes(nextArg)) {\n // This is a subcommand - remove 'process' from argv and make the subcommand top-level\n // e.g. ['node', 'cli', 'process', 'pull', ...] => ['node', 'cli', 'process-pull', ...]\n const newArgv = [\n ...argv.slice(0, processIndex),\n `process-${nextArg}`,\n ...argv.slice(processIndex + 2)\n ];\n\n // Special handling: If this is an alias command with --version option,\n // we need to filter out the global --version flag from program\n // by ensuring the routed command is properly isolated\n return newArgv;\n }\n\n return argv;\n}\n"],
5
+ "mappings": ";;AAMA,OAAS,WAAAA,OAAe,YACxB,OAAS,gBAAAC,GAAc,cAAAC,GAAY,iBAAAC,GAAe,aAAAC,OAAiB,UACnE,OAAS,iBAAAC,OAAqB,WAC9B,OAAS,WAAAC,GAAS,QAAAC,OAAY,YAC9B,OAAOC,OAAW,QAClB,OAAS,oBAAAC,OAAwB,4BCLjC,OAAS,gBAAAC,OAAoB,UAC7B,OAAS,iBAAAC,OAAqB,WAC9B,OAAS,WAAAC,GAAS,QAAAC,OAAY,YAK9B,SAASC,IAA0B,CACjC,IAAMC,EAAaJ,GAAc,YAAY,GAAG,EAC5CK,EAAaJ,GAAQG,CAAU,EAGnC,KAAOC,IAAe,KACpB,GAAI,CACF,IAAMC,EAAUJ,GAAKG,EAAY,cAAc,EAE/C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", "fileURLToPath", "dirname", "join", "chalk", "resolveConfigDir", "readFileSync", "fileURLToPath", "dirname", "join", "findPackageJson", "__filename", "currentDir", "pkgPath", "version", "packageJson", "inquirer", "writeAuth", "login", "answers", "input", "clearAuth", "logout", "sdkListProcesses", "sdkListProcessVersions", "chalk", "columnsFromRows", "rows", "printTable", "headers", "widths", "header", "row", "value", "headerParts", "h", "i", "width", "padded", "rowStr", "printTableContinuation", "rowParts", "printError", "message", "ERROR_ARROW", "errorPageLine", "text", "printErrorPage", "sections", "page", "section", "printMissingOptions", "missing", "option", "printSuccess", "printWarning", "formatProcessTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "listProcesses", "marketplace", "processName", "versionRows", "sdkListProcessVersions", "v", "printTable", "columnsFromRows", "processRows", "sdkListProcesses", "p", "error", "printError", "sdkCreateProcess", "readdirSync", "readFileSync", "statSync", "join", "parseProcessFile", "processFilePath", "path", "join", "ensureProcessDir", "statSync", "readTemplates", "templatesDir", "templates", "templateNames", "readdirSync", "name", "templateDir", "readFileSync", "ensureTemplates", "notifications", "parseProcessFile", "t", "usedNames", "n", "printWarning", "missing", "unqualified", "keyword", "readFileSync", "createProcess", "marketplace", "processName", "path", "ensureProcessDir", "definition", "processFilePath", "templates", "readTemplates", "ensureTemplates", "result", "sdkCreateProcess", "printSuccess", "error", "printError", "sdkPushProcess", "readFileSync", "pushProcess", "marketplace", "processName", "path", "ensureProcessDir", "definition", "processFilePath", "templates", "readTemplates", "ensureTemplates", "result", "sdkPushProcess", "printSuccess", "error", "printError", "getProcess", "writeFileSync", "mkdirSync", "join", "pullProcess", "marketplace", "processName", "path", "version", "alias", "process", "getProcess", "existsSync", "dirExists", "processFilePath", "templates", "templatesDir", "template", "templateName", "htmlContent", "subjectContent", "templateSubdir", "htmlPath", "subjectPath", "error", "printError", "sdkCreateAlias", "sdkUpdateAlias", "sdkDeleteAlias", "createAlias", "marketplace", "processName", "version", "alias", "result", "sdkCreateAlias", "printSuccess", "error", "printError", "updateAlias", "sdkUpdateAlias", "deleteAlias", "sdkDeleteAlias", "createAlias", "createProcess", "listProcessVersions", "pushProcess", "updateAlias", "readFileSync", "readVersions", "marketplace", "processName", "listProcessVersions", "error", "createOrPushAndCreateOrUpdateAlias", "path", "alias", "ensureProcessDir", "definition", "processFilePath", "templates", "readTemplates", "ensureTemplates", "versions", "created", "createProcess", "printSuccess", "aliasResult", "createAlias", "aliasExists", "v", "pushed", "pushProcess", "version", "updateAlias", "printError", "registerProcessCommands", "program", "processCmd", "options", "marketplace", "listProcesses", "createProcess", "pushProcess", "pullProcess", "createAlias", "updateAlias", "deleteAlias", "createOrPushAndCreateOrUpdateAlias", "sdkListSearchSchemas", "sdkSetSearchSchema", "sdkUnsetSearchSchema", "SCOPE_LABELS", "setSearchSchema", "marketplace", "opts", "sdkSetSearchSchema", "schemaFor", "scopeLabel", "error", "printError", "unsetSearchSchema", "sdkUnsetSearchSchema", "getDefaultValueLabel", "value", "listSearchSchemas", "rows", "sdkListSearchSchemas", "s", "a", "b", "printTable", "registerSearchCommands", "program", "searchCmd", "options", "sdkPushAssets", "sdkStageAsset", "getApiBaseUrl", "readAuth", "chalk", "edn", "BIN", "titleFromJson", "body", "titleFromEdn", "first", "edn", "assetErrorsFromJson", "assets", "asset", "seen", "messages", "error", "key", "formatAssetErrors", "assetErrors", "path", "errorPageLine", "chalk", "message", "line", "parseApiErrorBody", "status", "printApiError", "details", "marketplace", "apiKey", "title", "originalText", "printErrorPage", "reason", "readFileSync", "writeFileSync", "existsSync", "mkdirSync", "readdirSync", "statSync", "unlinkSync", "createWriteStream", "join", "dirname", "createHash", "http", "https", "tmpdir", "pipeline", "chalk", "edn", "yauzl", "ASSET_META_FILENAME", "ASSETS_DIR", "CLEAR_LINE", "CARRIAGE_RETURN", "parseAssetMetadataEdn", "content", "parsed", "version", "assets", "assetList", "asset", "readAssetMetadata", "basePath", "metaPath", "writeAssetMetadata", "metadata", "metaDir", "a", "ednMap", "calculateHash", "data", "prefix", "readLocalAssets", "scanDir", "dir", "relativePath", "entries", "entry", "fullPath", "relPath", "stat", "hash", "listLocalAssetPaths", "validateJsonAssets", "error", "formatDownloadProgress", "bytes", "mb", "printDownloadProgress", "stream", "downloaded", "printProgress", "interval", "chunk", "getApiKeyOrThrow", "auth", "readAuth", "getAssetsPullUrl", "marketplace", "url", "getApiBaseUrl", "AssetsApiError", "details", "isApiError", "apiKeyForErrorPage", "getAssetsZipStream", "apiKey", "isHttps", "client", "resolve", "reject", "req", "res", "statusCode", "chunks", "body", "parseApiErrorBody", "createTempZipPath", "removeAssetsDir", "filename", "readStreamToString", "unzipAssets", "zipPath", "err", "zipfile", "assetMeta", "streamErr", "readStream", "assetPath", "assetDir", "pullAssets", "path", "prune", "localAssets", "currentMeta", "tempZipPath", "zipStream", "newAssetMeta", "remoteVersion", "deletedPaths", "p", "shouldReportUpdate", "printApiError", "printError", "filterChangedAssets", "existingMeta", "hashByPath", "storedHash", "pushAssets", "currentVersion", "changedAssets", "isJsonAsset", "stageableAssets", "localAssetMap", "deleteOperations", "currentAsset", "paths", "stagedByPath", "stagingResult", "sdkStageAsset", "detail", "upsertOperations", "stagingId", "result", "sdkPushAssets", "missingAssetsOptions", "missing", "registerAssetsCommands", "program", "assetsCmd", "opts", "printMissingOptions", "sdkSendNotification", "sdkPreviewNotification", "readFileSync", "existsSync", "statSync", "join", "createServer", "readTemplate", "templatePath", "htmlPath", "subjectPath", "html", "subject", "readContext", "contextPath", "content", "error", "sendNotification", "marketplace", "template", "context", "result", "sdkSendNotification", "printError", "previewNotification", "previewHtml", "fetchPreview", "sdkPreviewNotification", "titleTag", "server", "req", "res", "shutdown", "registerNotificationsCommands", "program", "notificationsCmd", "opts", "sdkGetStatus", "sdkEnable", "sdkDisable", "getStatus", "marketplace", "sdkGetStatus", "error", "printError", "enableApprovals", "sdkEnable", "disableApprovals", "sdkDisable", "registerListingApprovalCommand", "program", "cmd", "opts", "sdkQueryEvents", "sdkPollEvents", "EVENT_HEADERS", "validateParams", "opts", "formatTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "queryEvents", "marketplace", "events", "event", "auditEmails", "eventWithoutEmails", "printTable", "actor", "source", "error", "printError", "tailEvents", "tailWidths", "stopPolling", "rows", "printTableContinuation", "shutdown", "registerEventsCommand", "program", "cmd", "sdkUpdateStripeVersion", "SUPPORTED_STRIPE_VERSIONS", "inquirer", "promptForVersion", "SUPPORTED_STRIPE_VERSIONS", "promptForConfirmation", "updateStripeVersion", "marketplace", "version", "force", "selectedVersion", "sdkUpdateStripeVersion", "error", "printError", "registerStripeCommands", "program", "opts", "getConfigMap", "readAuth", "maskLast4", "value", "debug", "auth", "apiKey", "confMap", "confMapEntries", "key", "confMapFormatted", "formatHelp", "cmd", "parts", "isRootCommand", "description", "version", "usage", "formatUsage", "allCommands", "collectAllLeafCommands", "hasAction", "maxLength", "c", "cmdInfo", "paddedName", "options", "maxFlagsLength", "opt", "formatOptionFlags", "paddedFlags", "desc", "cmdName", "getCommandName", "results", "commands", "subCmd", "fullName", "getCommandFullName", "subCommands", "subResults", "sub", "a", "b", "names", "current", "hasOptions", "formatted", "part", "trimmed", "valueMatch", "flag", "valueName", "configureHelp", "program", "helper", "routeProcessCommand", "argv", "processIndex", "arg", "nextArg", "__filename", "fileURLToPath", "__dirname", "dirname", "packageJson", "readFileSync", "join", "configDir", "resolveConfigDir", "noticeShownMarker", "existsSync", "chalk", "mkdirSync", "writeFileSync", "routedArgv", "routeProcessCommand", "program", "Command", "configureHelp", "str", "version", "login", "logout", "debug", "registerProcessCommands", "registerSearchCommands", "registerAssetsCommands", "registerNotificationsCommands", "registerListingApprovalCommand", "registerEventsCommand", "registerStripeCommands", "commandPath", "targetCmd", "cmdName", "subCmd", "c", "commandArgs", "isAssetsGroupWithoutSubcommand"]
7
7
  }