@tailor-platform/sdk 1.12.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["listCommand","getCommand","packageJson","listCommand","getCommand","listCommand","createCommand","deleteCommand","listCommand","updateCommand","createCommand","deleteCommand","listCommand","updateCommand","createCommand","deleteCommand","listCommand","createCommand","deleteCommand","listCommand","setTimeout","fs","mimeLookup","listCommand","listCommand","fs","metadata","fs","listCommand","userCommand","listCommand","listCommand","getCommand","listCommand","listCommand","updateCommand","createCommand","deleteCommand","getCommand","listCommand","generateCommand","removeCommand","userCommand"],"sources":["../../src/cli/executor/index.ts","../../src/cli/init.ts","../../src/cli/login.ts","../../src/cli/logout.ts","../../src/cli/machineuser/index.ts","../../src/cli/oauth2client/index.ts","../../src/cli/open.ts","../../src/cli/profile/create.ts","../../src/cli/profile/delete.ts","../../src/cli/profile/list.ts","../../src/cli/profile/update.ts","../../src/cli/profile/index.ts","../../src/cli/secret/args.ts","../../src/cli/secret/create.ts","../../src/cli/secret/delete.ts","../../src/cli/secret/list.ts","../../src/cli/secret/update.ts","../../src/cli/secret/vault/args.ts","../../src/cli/secret/vault/create.ts","../../src/cli/secret/vault/delete.ts","../../src/cli/secret/vault/list.ts","../../src/cli/secret/vault/index.ts","../../src/cli/secret/index.ts","../../src/cli/utils/progress.ts","../../src/cli/staticwebsite/deploy.ts","../../src/cli/staticwebsite/get.ts","../../src/cli/staticwebsite/list.ts","../../src/cli/staticwebsite/index.ts","../../src/cli/utils/resolve-cli-bin.ts","../../src/cli/tailordb/erd/schema.ts","../../src/cli/tailordb/erd/utils.ts","../../src/cli/tailordb/erd/export.ts","../../src/cli/tailordb/erd/deploy.ts","../../src/cli/tailordb/erd/serve.ts","../../src/cli/tailordb/erd/index.ts","../../src/cli/tailordb/migrate/set.ts","../../src/cli/tailordb/migrate/status.ts","../../src/cli/tailordb/migrate/index.ts","../../src/cli/tailordb/index.ts","../../src/cli/user/current.ts","../../src/cli/user/list.ts","../../src/cli/user/pat/transform.ts","../../src/cli/user/pat/create.ts","../../src/cli/user/pat/delete.ts","../../src/cli/user/pat/list.ts","../../src/cli/user/pat/update.ts","../../src/cli/user/pat/index.ts","../../src/cli/user/switch.ts","../../src/cli/user/index.ts","../../src/cli/workflow/index.ts","../../src/cli/workspace/app/index.ts","../../src/cli/workspace/user/index.ts","../../src/cli/workspace/index.ts","../../src/cli/index.ts"],"sourcesContent":["import { defineCommand, runCommand } from \"politty\";\nimport { getCommand } from \"./get\";\nimport { jobsCommand } from \"./jobs\";\nimport { listCommand } from \"./list\";\nimport { triggerCommand } from \"./trigger\";\nimport { webhookCommand } from \"./webhook\";\n\nexport const executorCommand = defineCommand({\n name: \"executor\",\n description: \"Manage executors\",\n subCommands: {\n list: listCommand,\n get: getCommand,\n jobs: jobsCommand,\n trigger: triggerCommand,\n webhook: webhookCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { spawnSync } from \"node:child_process\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"./args\";\nimport { logger } from \"./utils/logger\";\nimport { readPackageJson } from \"./utils/package-json\";\n\nconst detectPackageManager = () => {\n const availablePMs = [\"npm\", \"yarn\", \"pnpm\"];\n const userAgent = process.env.npm_config_user_agent;\n if (!userAgent) return;\n const [name] = userAgent.split(\"/\");\n if (!availablePMs.includes(name)) return;\n return name;\n};\n\nexport const initCommand = defineCommand({\n name: \"init\",\n description: \"Initialize a new project using create-sdk.\",\n args: z.object({\n ...commonArgs,\n name: arg(z.string().optional(), {\n positional: true,\n description: \"Project name\",\n }),\n template: arg(z.string().optional(), {\n alias: \"t\",\n description: \"Template name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const packageJson = await readPackageJson();\n const version =\n packageJson.version && packageJson.version !== \"0.0.0\" ? packageJson.version : \"latest\";\n\n let packageManager = detectPackageManager();\n if (!packageManager) {\n logger.warn(\"Could not detect package manager, defaulting to npm\");\n packageManager = \"npm\";\n }\n const initArgs = [\n \"create\",\n `@tailor-platform/sdk@${version}`,\n ...(args.name ? [args.name] : []),\n ...(packageManager === \"npm\" ? [\"--\"] : []),\n ...(args.template ? [\"--template\", args.template] : []),\n ];\n logger.log(`Running: ${packageManager} ${initArgs.join(\" \")}`);\n\n spawnSync(packageManager, initArgs, { stdio: \"inherit\" });\n }),\n});\n","import * as crypto from \"node:crypto\";\nimport * as http from \"node:http\";\nimport { generateCodeVerifier } from \"@badgateway/oauth2-client\";\nimport open from \"open\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"./args\";\nimport { fetchUserInfo, initOAuth2Client } from \"./client\";\nimport { readPlatformConfig, writePlatformConfig } from \"./context\";\nimport { logger } from \"./utils/logger\";\n\nconst redirectPort = 8085;\nconst redirectUri = `http://localhost:${redirectPort}/callback`;\n\nfunction randomState() {\n return crypto.randomBytes(32).toString(\"base64url\");\n}\n\nconst startAuthServer = async () => {\n const client = initOAuth2Client();\n const state = randomState();\n const codeVerifier = await generateCodeVerifier();\n\n return new Promise<void>((resolve, reject) => {\n const server = http.createServer(async (req, res) => {\n try {\n if (!req.url?.startsWith(\"/callback\")) {\n throw new Error(\"Invalid callback URL\");\n }\n const tokens = await client.authorizationCode.getTokenFromCodeRedirect(\n `http://${req.headers.host}${req.url}`,\n {\n redirectUri: redirectUri,\n state,\n codeVerifier,\n },\n );\n const userInfo = await fetchUserInfo(tokens.accessToken);\n\n const pfConfig = readPlatformConfig();\n pfConfig.users = {\n ...pfConfig.users,\n [userInfo.email]: {\n access_token: tokens.accessToken,\n refresh_token: tokens.refreshToken!,\n token_expires_at: new Date(tokens.expiresAt!).toISOString(),\n },\n };\n pfConfig.current_user = userInfo.email;\n writePlatformConfig(pfConfig);\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n status: \"ok\",\n message: \"Successfully authenticated. Please close this window.\",\n }),\n );\n resolve();\n } catch (error) {\n res.writeHead(401);\n res.end(\"Authentication failed\");\n reject(error);\n } finally {\n // Close the server after handling one request.\n server.close();\n }\n });\n\n const timeout = setTimeout(\n () => {\n server.close();\n reject(new Error(\"Login timeout exceeded\"));\n },\n 5 * 60 * 1000,\n );\n\n server.on(\"close\", () => {\n clearTimeout(timeout);\n });\n\n server.on(\"error\", (error) => {\n reject(error);\n });\n\n server.listen(redirectPort, async () => {\n const authorizeUri = await client.authorizationCode.getAuthorizeUri({\n redirectUri,\n state,\n codeVerifier,\n });\n\n logger.info(`Opening browser for login:\\n\\n${authorizeUri}\\n`);\n try {\n await open(authorizeUri);\n } catch {\n logger.warn(\"Failed to open browser automatically. Please open the URL above manually.\");\n }\n });\n });\n};\n\nexport const loginCommand = defineCommand({\n name: \"login\",\n description: \"Login to Tailor Platform.\",\n args: z.object({\n ...commonArgs,\n }),\n run: withCommonArgs(async () => {\n await startAuthServer();\n logger.success(\"Successfully logged in to Tailor Platform.\");\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"./args\";\nimport { initOAuth2Client } from \"./client\";\nimport { readPlatformConfig, writePlatformConfig } from \"./context\";\nimport { logger } from \"./utils/logger\";\n\nexport const logoutCommand = defineCommand({\n name: \"logout\",\n description: \"Logout from Tailor Platform.\",\n args: z.object({\n ...commonArgs,\n }),\n run: withCommonArgs(async () => {\n const pfConfig = readPlatformConfig();\n const tokens = pfConfig.current_user ? pfConfig.users[pfConfig.current_user] : undefined;\n if (!tokens) {\n logger.info(\"You are not logged in.\");\n return;\n }\n\n const client = initOAuth2Client();\n client.revoke(\n {\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token,\n expiresAt: Date.parse(tokens.token_expires_at),\n },\n \"refresh_token\",\n );\n\n delete pfConfig.users[pfConfig.current_user!];\n pfConfig.current_user = null;\n writePlatformConfig(pfConfig);\n logger.success(\"Successfully logged out from Tailor Platform.\");\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { listCommand } from \"./list\";\nimport { tokenCommand } from \"./token\";\n\nexport const machineuserCommand = defineCommand({\n name: \"machineuser\",\n description: \"Manage machine users in your Tailor Platform application.\",\n subCommands: {\n list: listCommand,\n token: tokenCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\n\nexport const oauth2clientCommand = defineCommand({\n name: \"oauth2client\",\n description: \"Manage OAuth2 clients in your Tailor Platform application.\",\n subCommands: {\n get: getCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import open from \"open\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, withCommonArgs } from \"./args\";\nimport { loadConfig } from \"./config-loader\";\nimport { loadWorkspaceId } from \"./context\";\nimport { logger } from \"./utils/logger\";\n\nconst consoleBaseUrl = \"https://console.tailor.tech\";\n\nexport const openCommand = defineCommand({\n name: \"open\",\n description: \"Open Tailor Platform Console.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n }),\n run: withCommonArgs(async (args) => {\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n const { config } = await loadConfig(args.config);\n const applicationName = config.name;\n const consolePath = `/workspaces/${workspaceId}/applications/${encodeURIComponent(applicationName)}/overview`;\n const consoleUrl = new URL(consolePath, consoleBaseUrl).toString();\n\n logger.info(\"Opening Tailor Platform Console...\");\n\n try {\n await open(consoleUrl);\n logger.out(`Console URL: ${consoleUrl}`);\n logger.out(`Workspace ID: ${workspaceId}`);\n logger.out(`Application Name: ${applicationName}`);\n } catch {\n logger.warn(\n `Failed to open browser automatically. Please open this URL manually:\\n${consoleUrl}`,\n );\n }\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { fetchLatestToken, readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport type { ProfileInfo } from \".\";\n\nexport const createCommand = defineCommand({\n name: \"create\",\n description: \"Create a new profile.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Profile name\",\n }),\n user: arg(z.string(), {\n alias: \"u\",\n description: \"User email\",\n }),\n \"workspace-id\": arg(z.string(), {\n alias: \"w\",\n description: \"Workspace ID\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if profile already exists\n if (config.profiles[args.name]) {\n throw new Error(`Profile \"${args.name}\" already exists.`);\n }\n\n // Check if user exists\n const token = await fetchLatestToken(config, args.user);\n\n // Check if workspace exists\n const client = await initOperatorClient(token);\n const workspaces = await fetchAll(async (pageToken) => {\n const { workspaces, nextPageToken } = await client.listWorkspaces({\n pageToken,\n });\n return [workspaces, nextPageToken];\n });\n\n const workspace = workspaces.find((ws) => ws.id === args[\"workspace-id\"]);\n if (!workspace) {\n throw new Error(`Workspace \"${args[\"workspace-id\"]}\" not found.`);\n }\n\n // Create new profile\n config.profiles[args.name] = {\n user: args.user,\n workspace_id: args[\"workspace-id\"],\n };\n writePlatformConfig(config);\n\n if (!args.json) {\n logger.success(`Profile \"${args.name}\" created successfully.`);\n }\n\n // Show profile info\n const profileInfo: ProfileInfo = {\n name: args.name,\n user: args.user,\n workspaceId: args[\"workspace-id\"],\n };\n logger.out(profileInfo);\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const deleteCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a profile.\",\n args: z.object({\n ...commonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Profile name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if profile exists\n if (!config.profiles[args.name]) {\n throw new Error(`Profile \"${args.name}\" not found.`);\n }\n\n // Delete profile\n delete config.profiles[args.name];\n writePlatformConfig(config);\n\n logger.success(`Profile \"${args.name}\" deleted successfully.`);\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport type { ProfileInfo } from \".\";\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all profiles.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n }),\n run: withCommonArgs(async () => {\n const config = readPlatformConfig();\n\n const profiles = Object.entries(config.profiles);\n if (profiles.length === 0) {\n logger.info(ml`\n No profiles found.\n Please create a profile first using 'tailor-sdk profile create' command.\n `);\n return;\n }\n\n const profileInfos: ProfileInfo[] = profiles.map(([name, profile]) => ({\n name,\n user: profile!.user,\n workspaceId: profile!.workspace_id,\n }));\n logger.out(profileInfos);\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { fetchLatestToken, readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport type { ProfileInfo } from \".\";\n\nexport const updateCommand = defineCommand({\n name: \"update\",\n description: \"Update profile properties.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Profile name\",\n }),\n user: arg(z.string().optional(), {\n alias: \"u\",\n description: \"New user email\",\n }),\n \"workspace-id\": arg(z.string().optional(), {\n alias: \"w\",\n description: \"New workspace ID\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if profile exists\n if (!config.profiles[args.name]) {\n throw new Error(`Profile \"${args.name}\" not found.`);\n }\n\n // Check if at least one property is provided\n if (!args.user && !args[\"workspace-id\"]) {\n throw new Error(\"Please provide at least one property to update.\");\n }\n\n const profile = config.profiles[args.name]!;\n const oldUser = profile.user;\n const newUser = args.user || oldUser;\n const oldWorkspaceId = profile.workspace_id;\n const newWorkspaceId = args[\"workspace-id\"] || oldWorkspaceId;\n\n // Check if user exists\n const token = await fetchLatestToken(config, newUser);\n\n // Check if workspace exists\n const client = await initOperatorClient(token);\n const workspaces = await fetchAll(async (pageToken) => {\n const { workspaces, nextPageToken } = await client.listWorkspaces({\n pageToken,\n });\n return [workspaces, nextPageToken];\n });\n const workspace = workspaces.find((ws) => ws.id === newWorkspaceId);\n if (!workspace) {\n throw new Error(`Workspace \"${newWorkspaceId}\" not found.`);\n }\n\n // Update properties\n profile.user = newUser;\n profile.workspace_id = newWorkspaceId;\n writePlatformConfig(config);\n if (!args.json) {\n logger.success(`Profile \"${args.name}\" updated successfully`);\n }\n\n // Show profile info\n const profileInfo: ProfileInfo = {\n name: args.name,\n user: newUser,\n workspaceId: newWorkspaceId,\n };\n logger.out(profileInfo);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { listCommand } from \"./list\";\nimport { updateCommand } from \"./update\";\n\nexport interface ProfileInfo {\n name: string;\n user: string;\n workspaceId: string;\n}\n\nexport const profileCommand = defineCommand({\n name: \"profile\",\n description: \"Manage workspace profiles (user + workspace combinations).\",\n subCommands: {\n create: createCommand,\n delete: deleteCommand,\n list: listCommand,\n update: updateCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { arg } from \"politty\";\nimport { z } from \"zod\";\n\n/**\n * Arguments for specify secret key\n */\nexport const vaultArgs = {\n \"vault-name\": arg(z.string(), {\n alias: \"V\",\n description: \"Vault name\",\n }),\n};\n\n/**\n * Arguments for specify secret key\n */\nexport const secretIdentifyArgs = {\n ...vaultArgs,\n name: arg(z.string(), {\n alias: \"n\",\n description: \"Secret name\",\n }),\n};\n\n/**\n * Arguments for specify secret key\n */\nexport const secretValueArgs = {\n ...secretIdentifyArgs,\n value: arg(z.string(), {\n alias: \"v\",\n description: \"Secret value\",\n }),\n};\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { secretValueArgs } from \"./args\";\n\nexport const createSecretCommand = defineCommand({\n name: \"create\",\n description: \"Create a secret in a vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...secretValueArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n try {\n await client.createSecretManagerSecret({\n workspaceId,\n secretmanagerVaultName: args[\"vault-name\"],\n secretmanagerSecretName: args.name,\n secretmanagerSecretValue: args.value,\n });\n } catch (error) {\n if (error instanceof ConnectError) {\n if (error.code === Code.NotFound) {\n throw new Error(`Vault \"${args[\"vault-name\"]}\" not found.`);\n }\n if (error.code === Code.AlreadyExists) {\n throw new Error(`Secret \"${args.name}\" already exists.`);\n }\n }\n throw error;\n }\n\n logger.success(`Secret: ${args.name} created in vault: ${args[\"vault-name\"]}`);\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, confirmationArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { secretIdentifyArgs } from \"./args\";\n\nexport const deleteSecretCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a secret in a vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...secretIdentifyArgs,\n ...confirmationArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n if (!args.yes) {\n const confirmation = await logger.prompt(\n `Enter the secret name to confirm deletion (\"${args.name}\"): `,\n { type: \"text\" },\n );\n\n if (confirmation !== args.name) {\n logger.info(\"Secret deletion cancelled.\");\n return;\n }\n }\n\n try {\n await client.deleteSecretManagerSecret({\n workspaceId,\n secretmanagerVaultName: args[\"vault-name\"],\n secretmanagerSecretName: args.name,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Secret \"${args.name}\" not found in vault \"${args[\"vault-name\"]}\".`);\n }\n throw error;\n }\n\n logger.success(`Secret: ${args.name} deleted from vault: ${args[\"vault-name\"]}`);\n }),\n});\n","import { timestampDate } from \"@bufbuild/protobuf/wkt\";\nimport { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { vaultArgs } from \"./args\";\nimport type { SecretManagerSecret } from \"@tailor-proto/tailor/v1/secret_manager_resource_pb\";\n\nexport interface SecretListOptions {\n workspaceId?: string;\n profile?: string;\n vaultName: string;\n}\n\nexport interface SecretInfo {\n name: string;\n createdAt: Date | null;\n updatedAt: Date | null;\n}\n\nfunction secretInfo(secret: SecretManagerSecret): SecretInfo {\n return {\n name: secret.name,\n createdAt: secret.createTime ? timestampDate(secret.createTime) : null,\n updatedAt: secret.updateTime ? timestampDate(secret.updateTime) : null,\n };\n}\n\n/**\n * List secrets in a Secret Manager vault.\n * @param options - Secret listing options\n * @returns List of secrets\n */\nasync function secretList(options: SecretListOptions): Promise<SecretInfo[]> {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: options.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options.workspaceId,\n profile: options.profile,\n });\n\n const secrets = await fetchAll(async (pageToken) => {\n const { secrets, nextPageToken } = await client.listSecretManagerSecrets({\n workspaceId,\n secretmanagerVaultName: options.vaultName,\n pageToken,\n });\n return [secrets, nextPageToken];\n });\n\n return secrets.map(secretInfo);\n}\n\nexport const listSecretCommand = defineCommand({\n name: \"list\",\n description: \"List all secrets in a vault.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n ...vaultArgs,\n }),\n run: withCommonArgs(async (args) => {\n try {\n const secrets = await secretList({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n vaultName: args[\"vault-name\"],\n });\n logger.out(secrets);\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Vault \"${args[\"vault-name\"]}\" not found.`);\n }\n throw error;\n }\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { secretValueArgs } from \"./args\";\n\nexport const updateSecretCommand = defineCommand({\n name: \"update\",\n description: \"Update a secret in a vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...secretValueArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n try {\n await client.updateSecretManagerSecret({\n workspaceId,\n secretmanagerVaultName: args[\"vault-name\"],\n secretmanagerSecretName: args.name,\n secretmanagerSecretValue: args.value,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Secret \"${args.name}\" not found in vault \"${args[\"vault-name\"]}\".`);\n }\n throw error;\n }\n\n logger.success(`Secret: ${args.name} updated in vault: ${args[\"vault-name\"]}`);\n }),\n});\n","import { arg } from \"politty\";\nimport { z } from \"zod\";\n\ntype ArgsShape = Record<string, z.ZodType>;\n\nexport const nameArgs = {\n name: arg(z.string(), {\n positional: true,\n description: \"Vault name\",\n }),\n} satisfies ArgsShape;\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs, workspaceArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport { nameArgs } from \"./args\";\n\nexport const createCommand = defineCommand({\n name: \"create\",\n description: \"Create a new Secret Manager vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...nameArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n try {\n await client.createSecretManagerVault({\n workspaceId,\n secretmanagerVaultName: args.name,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.AlreadyExists) {\n throw new Error(`Vault \"${args.name}\" already exists.`);\n }\n throw error;\n }\n\n logger.success(`Vault: ${args.name} created`);\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, confirmationArgs, withCommonArgs, workspaceArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport { nameArgs } from \"./args\";\n\nexport const deleteCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a Secret Manager vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...nameArgs,\n ...confirmationArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n if (!args.yes) {\n const confirmation = await logger.prompt(\n `Enter the vault name to confirm deletion (\"${args.name}\"): `,\n { type: \"text\" },\n );\n if (confirmation !== args.name) {\n logger.info(\"Vault deletion cancelled.\");\n return;\n }\n }\n\n try {\n await client.deleteSecretManagerVault({\n workspaceId,\n secretmanagerVaultName: args.name,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Vault \"${args.name}\" not found.`);\n }\n throw error;\n }\n\n logger.success(`Vault: ${args.name} deleted`);\n }),\n});\n","import { timestampDate } from \"@bufbuild/protobuf/wkt\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../../args\";\nimport { fetchAll, initOperatorClient } from \"../../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport type { SecretManagerVault } from \"@tailor-proto/tailor/v1/secret_manager_resource_pb\";\n\nexport interface VaultListOptions {\n workspaceId?: string;\n profile?: string;\n}\n\nexport interface VaultInfo {\n name: string;\n createdAt: Date | null;\n updatedAt: Date | null;\n}\n\nfunction vaultInfo(vault: SecretManagerVault): VaultInfo {\n return {\n name: vault.name,\n createdAt: vault.createTime ? timestampDate(vault.createTime) : null,\n updatedAt: vault.updateTime ? timestampDate(vault.updateTime) : null,\n };\n}\n\n/**\n * List Secret Manager vaults in the workspace.\n * @param options - Vault listing options\n * @returns List of vaults\n */\nasync function vaultList(options?: VaultListOptions): Promise<VaultInfo[]> {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: options?.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options?.workspaceId,\n profile: options?.profile,\n });\n\n const vaults = await fetchAll(async (pageToken) => {\n const { vaults, nextPageToken } = await client.listSecretManagerVaults({\n workspaceId,\n pageToken,\n });\n return [vaults, nextPageToken];\n });\n\n return vaults.map(vaultInfo);\n}\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all Secret Manager vaults in the workspace.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n }),\n run: withCommonArgs(async (args) => {\n const vaults = await vaultList({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n logger.out(vaults);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { listCommand } from \"./list\";\n\nexport const vaultCommand = defineCommand({\n name: \"vault\",\n description: \"Manage Secret Manager vaults.\",\n subCommands: {\n create: createCommand,\n delete: deleteCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { createSecretCommand } from \"./create\";\nimport { deleteSecretCommand } from \"./delete\";\nimport { listSecretCommand } from \"./list\";\nimport { updateSecretCommand } from \"./update\";\nimport { vaultCommand } from \"./vault\";\n\nexport const secretCommand = defineCommand({\n name: \"secret\",\n description: \"Manage Secret Manager vaults and secrets.\",\n subCommands: {\n create: createSecretCommand,\n delete: deleteSecretCommand,\n list: listSecretCommand,\n update: updateSecretCommand,\n vault: vaultCommand,\n },\n async run() {\n await runCommand(vaultCommand, []);\n },\n});\n","import { setTimeout } from \"node:timers/promises\";\n\n/**\n * Create a simple progress reporter that writes updates to stderr.\n * @param label - Label to prefix progress output\n * @param total - Total number of steps\n * @returns Progress helpers\n */\nexport function createProgress(label: string, total: number) {\n let current = 0;\n\n const update = () => {\n current += 1;\n const percent = Math.round((current / total) * 100);\n process.stderr.write(`\\r${label} ${current}/${total} (${percent}%)`);\n };\n\n const finish = () => {\n process.stderr.write(\"\\n\");\n };\n\n return { update, finish };\n}\n\n/**\n * Wrap a promise with a timeout, rejecting if the timeout elapses first.\n * @template T\n * @param p - Promise to await\n * @param ms - Timeout in milliseconds\n * @param message - Error message on timeout\n * @returns Result of the original promise if it completes in time\n */\nexport async function withTimeout<T>(p: Promise<T>, ms: number, message: string): Promise<T> {\n return await Promise.race([\n p,\n setTimeout(ms).then(() => {\n throw new Error(message);\n }),\n ]);\n}\n","import * as fs from \"fs\";\nimport { Code, ConnectError } from \"@connectrpc/connect\";\nimport { lookup as mimeLookup } from \"mime-types\";\nimport pLimit from \"p-limit\";\nimport * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { withCommonArgs, commonArgs, jsonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient, type OperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { createProgress, withTimeout } from \"../utils/progress\";\nimport type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport type { UploadFileRequestSchema } from \"@tailor-proto/tailor/v1/staticwebsite_pb\";\n\nconst CHUNK_SIZE = 64 * 1024; // 64KB\nconst IGNORED_FILES = new Set([\".DS_Store\", \"thumbs.db\", \"desktop.ini\"]);\nfunction shouldIgnoreFile(filePath: string) {\n const fileName = path.basename(filePath).toLowerCase();\n return IGNORED_FILES.has(fileName);\n}\n\nexport type DeployResult = {\n url: string;\n skippedFiles: string[];\n};\n\n/**\n * Deploy a static website by creating a deployment, uploading files, and publishing it.\n * @param client - Operator client instance\n * @param workspaceId - Workspace ID\n * @param name - Static website name\n * @param distDir - Directory containing static site files\n * @param showProgress - Whether to show upload progress\n * @returns Deployment result with URL and skipped files\n */\nexport async function deployStaticWebsite(\n client: OperatorClient,\n workspaceId: string,\n name: string,\n distDir: string,\n showProgress: boolean = true,\n): Promise<DeployResult> {\n const { deploymentId } = await client.createDeployment({\n workspaceId,\n name,\n });\n\n if (!deploymentId) {\n throw new Error(\"createDeployment returned empty deploymentId\");\n }\n\n const skippedFiles = await uploadDirectory(\n client,\n workspaceId,\n deploymentId,\n distDir,\n showProgress,\n );\n\n const { url } = await client.publishDeployment({\n workspaceId,\n deploymentId,\n });\n\n if (!url) {\n throw new Error(\"publishDeployment returned empty url\");\n }\n\n return { url, skippedFiles };\n}\n\nasync function uploadDirectory(\n client: OperatorClient,\n workspaceId: string,\n deploymentId: string,\n rootDir: string,\n showProgress: boolean,\n): Promise<string[]> {\n const files = await collectFiles(rootDir);\n if (files.length === 0) {\n logger.warn(`No files found under ${rootDir}`);\n return [];\n }\n\n const concurrency = 5;\n const limit = pLimit(concurrency);\n\n const total = files.length;\n const progress = showProgress ? createProgress(\"Uploading files\", total) : undefined;\n const skippedFiles: string[] = [];\n\n await Promise.all(\n files.map((relativePath) =>\n limit(async () => {\n await uploadSingleFile(\n client,\n workspaceId,\n deploymentId,\n rootDir,\n relativePath,\n skippedFiles,\n );\n if (progress) {\n progress.update();\n }\n }),\n ),\n );\n\n if (progress) {\n progress.finish();\n }\n\n return skippedFiles;\n}\n\n/**\n * Recursively collect all deployable files under the given directory.\n * @param rootDir - Root directory to scan\n * @param currentDir - Current relative directory (for recursion)\n * @returns List of file paths relative to rootDir\n */\nasync function collectFiles(rootDir: string, currentDir = \"\"): Promise<string[]> {\n const dirPath = path.join(rootDir, currentDir);\n\n const entries = await fs.promises.readdir(dirPath, {\n withFileTypes: true,\n });\n const files: string[] = [];\n\n for (const entry of entries) {\n const rel = path.join(currentDir, entry.name);\n if (entry.isDirectory()) {\n const sub = await collectFiles(rootDir, rel);\n files.push(...sub);\n } else if (entry.isFile() && !entry.isSymbolicLink() && !shouldIgnoreFile(rel)) {\n files.push(rel);\n }\n }\n\n return files;\n}\n\nasync function uploadSingleFile(\n client: OperatorClient,\n workspaceId: string,\n deploymentId: string,\n rootDir: string,\n filePath: string,\n skippedFiles: string[],\n): Promise<void> {\n const absPath = path.join(rootDir, filePath);\n\n const mime = mimeLookup(filePath);\n\n if (!mime) {\n skippedFiles.push(`${filePath} (unsupported content type; no MIME mapping found)`);\n return;\n }\n\n const contentType = mime;\n\n const readStream = fs.createReadStream(absPath, {\n highWaterMark: CHUNK_SIZE,\n });\n\n async function* requestStream(): AsyncIterable<MessageInitShape<typeof UploadFileRequestSchema>> {\n yield {\n payload: {\n case: \"initialMetadata\",\n value: {\n workspaceId,\n deploymentId,\n filePath,\n contentType,\n },\n },\n };\n for await (const chunk of readStream) {\n yield {\n payload: {\n case: \"chunkData\",\n value: chunk as Buffer,\n },\n };\n }\n }\n\n async function uploadWithLogging() {\n try {\n await client.uploadFile(requestStream());\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.InvalidArgument) {\n skippedFiles.push(`${filePath} (server rejected file as invalid: ${error.message})`);\n return;\n }\n // For non-validation errors, fail the deployment as before.\n throw error;\n }\n }\n\n await withTimeout(\n uploadWithLogging(),\n // 2 minutes per file\n 2 * 60_000,\n `Upload timed out for \"${filePath}\"`,\n );\n}\n\n/**\n * Log skipped files after a deployment, including reasons for skipping.\n * @param skippedFiles - List of skipped file descriptions\n */\nexport function logSkippedFiles(skippedFiles: string[]) {\n if (skippedFiles.length === 0) {\n return;\n }\n logger.warn(\n \"Deployment completed, but some files failed to upload. These files may have unsupported content types or other validation issues. Please review the list below:\",\n );\n for (const file of skippedFiles) {\n logger.log(` - ${file}`);\n }\n}\n\nexport const deployCommand = defineCommand({\n name: \"deploy\",\n description: \"Deploy a static website from a local build directory.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n name: arg(z.string(), {\n alias: \"n\",\n description: \"Static website name\",\n }),\n dir: arg(z.string(), {\n alias: \"d\",\n description: \"Path to the static website files\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n logger.info(`Deploying static website \"${args.name}\" from directory: ${args.dir}`);\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n\n const name = args.name;\n const dir = path.resolve(process.cwd(), args.dir);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {\n throw new Error(`Directory not found or not a directory: ${dir}`);\n }\n\n const { url, skippedFiles } = await withTimeout(\n deployStaticWebsite(client, workspaceId, name, dir, !args.json),\n // 10 minutes\n 10 * 60_000,\n \"Deployment timed out after 10 minutes.\",\n );\n\n if (args.json) {\n logger.out({ name, workspaceId, url, skippedFiles });\n } else {\n logger.success(`Static website \"${name}\" deployed successfully. URL: ${url}`);\n logSkippedFiles(skippedFiles);\n }\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const getCommand = defineCommand({\n name: \"get\",\n description: \"Get details of a specific static website.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Static website name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n const notFoundErrorMessage = `Static website \"${args.name}\" not found.`;\n\n try {\n const { staticwebsite } = await client.getStaticWebsite({\n workspaceId,\n name: args.name,\n });\n\n if (!staticwebsite) {\n throw new Error(notFoundErrorMessage);\n }\n\n const info = {\n workspaceId,\n name: staticwebsite.name,\n description: staticwebsite.description,\n url: staticwebsite.url,\n allowedIpAddresses: args.json\n ? staticwebsite.allowedIpAddresses\n : staticwebsite.allowedIpAddresses.join(\"\\n\"),\n };\n\n logger.out(info);\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(notFoundErrorMessage);\n }\n throw error;\n }\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport interface StaticWebsiteInfo {\n workspaceId: string;\n name: string;\n description: string;\n url: string;\n allowedIpAddresses: string[];\n}\n\ntype StaticWebsiteListOptions = {\n workspaceId?: string;\n profile?: string;\n};\n\n/**\n * List static websites in the workspace.\n * @param options - Static website listing options\n * @returns List of static websites\n */\nasync function listStaticWebsites(\n options?: StaticWebsiteListOptions,\n): Promise<StaticWebsiteInfo[]> {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: options?.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options?.workspaceId,\n profile: options?.profile,\n });\n\n const websites = await fetchAll(async (pageToken) => {\n const { staticwebsites, nextPageToken } = await client.listStaticWebsites({\n workspaceId,\n pageToken,\n });\n return [staticwebsites, nextPageToken];\n });\n\n return websites.map((site) => ({\n workspaceId,\n name: site.name,\n description: site.description,\n url: site.url ?? \"\",\n allowedIpAddresses: site.allowedIpAddresses,\n }));\n}\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all static websites in a workspace.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n }),\n run: withCommonArgs(async (args) => {\n const websites = await listStaticWebsites({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n const formatted = args.json\n ? websites\n : websites.map(({ allowedIpAddresses, ...rest }) => {\n if (allowedIpAddresses.length === 0) {\n return {\n ...rest,\n allowedIpAddresses: \"No allowed IP addresses\",\n };\n }\n\n const count = allowedIpAddresses.length;\n const label = count === 1 ? \"1 IP address\" : `${count} IP addresses`;\n\n return {\n ...rest,\n allowedIpAddresses: label,\n };\n });\n\n logger.out(formatted);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { deployCommand } from \"./deploy\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\n\nexport const staticwebsiteCommand = defineCommand({\n name: \"staticwebsite\",\n description: \"Manage static websites in your workspace.\",\n subCommands: {\n deploy: deployCommand,\n get: getCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"pathe\";\n\ninterface CliPackageJson {\n bin?: Record<string, string>;\n}\n\ntype ResolveCliBinOptions = {\n packageName: string;\n binName: string;\n};\n\n/**\n * Resolve a CLI binary path from the SDK's dependencies.\n * @param options - Resolution options for locating the CLI binary.\n * @returns Absolute path to the CLI binary entry.\n */\nexport function resolveCliBinPath(options: ResolveCliBinOptions): string {\n const { packageName, binName } = options;\n\n // Resolve from SDK's dependencies instead of user's project\n const requireFromSdk = createRequire(import.meta.url);\n let pkgJsonPath: string;\n try {\n pkgJsonPath = requireFromSdk.resolve(`${packageName}/package.json`);\n } catch {\n throw new Error(`Failed to resolve \\`${packageName}\\`.`);\n }\n\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\")) as CliPackageJson;\n const binRelativePath = pkgJson.bin?.[binName];\n if (!binRelativePath) {\n throw new Error(`\\`${packageName}\\` does not expose a \\`${binName}\\` binary entry.`);\n }\n\n return path.resolve(path.dirname(pkgJsonPath), binRelativePath);\n}\n","import * as fs from \"node:fs\";\nimport { Code, ConnectError } from \"@connectrpc/connect\";\nimport * as path from \"pathe\";\nimport { fetchAll } from \"../../client\";\nimport { logger } from \"../../utils/logger\";\nimport type {\n TblsColumn,\n TblsConstraint,\n TblsEnum,\n TblsRelation,\n TblsSchema,\n TblsTable,\n} from \"./types\";\nimport type { OperatorClient } from \"../../client\";\nimport type {\n TailorDBType as TailorDBProtoType,\n TailorDBType_FieldConfig,\n} from \"@tailor-proto/tailor/v1/tailordb_resource_pb\";\n\nexport interface TailorDBSchemaOptions {\n workspaceId: string;\n namespace: string;\n client: OperatorClient;\n}\n\n/**\n * Convert TailorDB field config to tbls column definition.\n * @param fieldName - Field name\n * @param fieldConfig - TailorDB field configuration\n * @returns tbls column definition\n */\nexport function toTblsColumn(fieldName: string, fieldConfig: TailorDBType_FieldConfig): TblsColumn {\n const baseType = fieldConfig.type || \"string\";\n const type = fieldConfig.array ? `${baseType}[]` : baseType;\n\n return {\n name: fieldName,\n type,\n nullable: !fieldConfig.required,\n comment: fieldConfig.description ?? \"\",\n };\n}\n\n/**\n * Build tbls schema JSON from TailorDB types.\n * @param types - TailorDB types fetched from platform\n * @param namespace - TailorDB namespace\n * @returns tbls-compatible schema representation\n */\nexport function buildTblsSchema(types: TailorDBProtoType[], namespace: string): TblsSchema {\n const tables: TblsTable[] = [];\n const relations: TblsRelation[] = [];\n const referencedByTable: Record<string, Set<string>> = {};\n const constraintsByTable: Record<string, TblsConstraint[]> = {};\n const enumsMap: Map<string, Set<string>> = new Map();\n\n for (const type of types) {\n const tableName = type.name;\n const schema = type.schema;\n\n const columns: TblsColumn[] = [];\n const tableConstraints: TblsConstraint[] = [];\n\n // Implicit primary key column\n columns.push({\n name: \"id\",\n type: \"uuid\",\n nullable: false,\n comment: \"\",\n });\n\n tableConstraints.push({\n name: `pk_${tableName}`,\n type: \"PRIMARY KEY\",\n def: \"\",\n table: tableName,\n columns: [\"id\"],\n });\n\n if (schema) {\n // Fields -> columns\n for (const [fieldName, fieldConfig] of Object.entries(schema.fields ?? {})) {\n columns.push(toTblsColumn(fieldName, fieldConfig));\n\n // Collect enum values\n if (fieldConfig.type === \"enum\" && fieldConfig.allowedValues.length > 0) {\n const enumName = `${tableName}_${fieldName}`;\n let values = enumsMap.get(enumName);\n if (!values) {\n values = new Set<string>();\n enumsMap.set(enumName, values);\n }\n for (const value of fieldConfig.allowedValues) {\n values.add(value.value);\n }\n }\n\n // Foreign key -> relation + constraint\n if (fieldConfig.foreignKey && fieldConfig.foreignKeyType) {\n const foreignTable = fieldConfig.foreignKeyType;\n const foreignColumn = fieldConfig.foreignKeyField || \"id\";\n\n // Cardinality:\n // - child side: exactly_one if non-nullable, zero_or_one if nullable FK\n // - parent side: zero_or_more (a parent can have many children)\n const childCardinality = fieldConfig.required ? \"exactly_one\" : \"zero_or_one\";\n const parentCardinality = \"zero_or_more\";\n\n // tbls RelationJSON:\n // - table/columns: child side (FK owner)\n // - parent_table/parent_columns: referenced side\n relations.push({\n table: tableName,\n columns: [fieldName],\n parent_table: foreignTable,\n parent_columns: [foreignColumn],\n cardinality: childCardinality,\n parent_cardinality: parentCardinality,\n def: \"\",\n });\n\n tableConstraints.push({\n name: `fk_${tableName}_${fieldName}`,\n type: \"FOREIGN KEY\",\n def: \"\",\n table: tableName,\n columns: [fieldName],\n referenced_table: foreignTable,\n referenced_columns: [foreignColumn],\n });\n\n if (!referencedByTable[tableName]) {\n referencedByTable[tableName] = new Set<string>();\n }\n referencedByTable[tableName].add(foreignTable);\n }\n }\n }\n\n constraintsByTable[tableName] = tableConstraints;\n\n tables.push({\n name: tableName,\n type: \"table\",\n comment: schema?.description ?? \"\",\n columns,\n indexes: [],\n constraints: constraintsByTable[tableName] ?? [],\n triggers: [],\n def: \"\",\n referenced_tables: [],\n });\n }\n\n // Populate referenced_tables from collected relations\n for (const table of tables) {\n const referenced = referencedByTable[table.name];\n table.referenced_tables = referenced ? Array.from(referenced) : [];\n }\n\n const enums: TblsEnum[] = [];\n for (const [name, values] of enumsMap.entries()) {\n enums.push({\n name,\n values: Array.from(values),\n });\n }\n\n return {\n name: namespace,\n tables,\n relations,\n enums,\n };\n}\n\n/**\n * Export apply-applied TailorDB schema for a namespace as tbls-compatible JSON.\n * @param options - Export options\n * @returns tbls schema representation\n */\nasync function exportTailorDBSchema(options: TailorDBSchemaOptions): Promise<TblsSchema> {\n const { client, workspaceId, namespace } = options;\n\n const types = await fetchAll(async (pageToken) => {\n try {\n const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({\n workspaceId,\n namespaceName: namespace,\n pageToken,\n });\n return [tailordbTypes, nextPageToken];\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n return [[], \"\"];\n }\n throw error;\n }\n });\n\n if (types.length === 0) {\n logger.warn(`No TailorDB types found in namespace \"${namespace}\". Returning empty schema.`);\n }\n\n return buildTblsSchema(types, namespace);\n}\n\nexport interface WriteSchemaOptions extends TailorDBSchemaOptions {\n outputPath: string;\n}\n\n/**\n * Writes the TailorDB schema to a file in tbls-compatible JSON format.\n * @param options - The options for writing the schema file.\n */\nexport async function writeTblsSchemaToFile(options: WriteSchemaOptions): Promise<void> {\n const schema = await exportTailorDBSchema(options);\n const json = JSON.stringify(schema, null, 2);\n\n fs.mkdirSync(path.dirname(options.outputPath), { recursive: true });\n fs.writeFileSync(options.outputPath, json, \"utf8\");\n\n const relativePath = path.relative(process.cwd(), options.outputPath);\n logger.success(`Wrote ERD schema to ${relativePath}`);\n}\n","import { initOperatorClient } from \"../../client\";\nimport { loadConfig } from \"../../config-loader\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logBetaWarning } from \"../../utils/beta\";\nimport type { OperatorClient } from \"../../client\";\nimport type { AppConfig } from \"@/parser/app-config\";\n\nexport interface ErdCommandContext {\n client: OperatorClient;\n workspaceId: string;\n config: AppConfig;\n}\n\ntype ErdCommandOptions = {\n profile?: string;\n workspaceId?: string;\n config?: string;\n};\n\n/**\n * Initialize shared ERD command context.\n * @param args - CLI arguments.\n * @returns Initialized context.\n */\nexport async function initErdContext(args: ErdCommandOptions): Promise<ErdCommandContext> {\n logBetaWarning(\"tailordb erd\");\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args.workspaceId,\n profile: args.profile,\n });\n const { config } = await loadConfig(args.config);\n\n return { client, workspaceId, config };\n}\n","import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { logger } from \"../../utils/logger\";\nimport { resolveCliBinPath } from \"../../utils/resolve-cli-bin\";\nimport { writeTblsSchemaToFile } from \"./schema\";\nimport { initErdContext } from \"./utils\";\nimport type { TailorDBSchemaOptions } from \"./schema\";\nimport type { OperatorClient } from \"../../client\";\nimport type { AppConfig } from \"@/parser/app-config\";\n\nconst DEFAULT_ERD_BASE_DIR = \".tailor-sdk/erd\";\n\n/**\n * Resolve TailorDB config and namespace.\n * @param config - Loaded Tailor SDK config.\n * @param explicitNamespace - Namespace override.\n * @returns Resolved namespace and erdSite.\n */\nfunction resolveDbConfig(\n config: AppConfig,\n explicitNamespace?: string,\n): { namespace: string; erdSite: string | undefined } {\n const namespace = explicitNamespace ?? Object.keys(config.db ?? {})[0];\n\n if (!namespace) {\n throw new Error(\n \"No TailorDB namespaces found in config. Please define db services in tailor.config.ts or pass --namespace.\",\n );\n }\n\n const dbConfig = config.db?.[namespace];\n\n if (!dbConfig || typeof dbConfig !== \"object\" || \"external\" in dbConfig) {\n throw new Error(`TailorDB namespace \"${namespace}\" not found in config.db.`);\n }\n\n return { namespace, erdSite: dbConfig.erdSite };\n}\n\ntype ResolveNamespacesOptions = {\n requireErdSite?: boolean;\n};\n\n/**\n * Get all namespaces from config.\n * @param config - Loaded Tailor SDK config.\n * @param options - Options for filtering namespaces.\n * @returns All namespaces with optional erdSite.\n */\nfunction resolveAllNamespaces(\n config: AppConfig,\n options?: ResolveNamespacesOptions,\n): Array<{ namespace: string; erdSite: string | undefined }> {\n const results: Array<{ namespace: string; erdSite: string | undefined }> = [];\n\n for (const [namespace, dbConfig] of Object.entries(config.db ?? {})) {\n if (dbConfig && !(\"external\" in dbConfig) && !(options?.requireErdSite && !dbConfig.erdSite)) {\n results.push({ namespace, erdSite: dbConfig.erdSite });\n }\n }\n\n return results;\n}\n\n/**\n * Run the liam CLI to build an ERD static site from a schema file.\n * @param schemaPath - Path to the ERD schema JSON file\n * @param cwd - Working directory where liam will run (dist is created here)\n * @returns Resolves when the build completes successfully\n */\nasync function runLiamBuild(schemaPath: string, cwd: string): Promise<void> {\n fs.mkdirSync(cwd, { recursive: true });\n\n return await new Promise<void>((resolve, reject) => {\n let liamBinPath: string;\n try {\n liamBinPath = resolveCliBinPath({\n packageName: \"@liam-hq/cli\",\n binName: \"liam\",\n });\n } catch (error) {\n logger.error(String(error));\n reject(error);\n return;\n }\n\n const child = spawn(\n process.execPath,\n [liamBinPath, \"erd\", \"build\", \"--format\", \"tbls\", \"--input\", schemaPath],\n {\n stdio: [\"pipe\", \"ignore\", \"pipe\"],\n cwd,\n },\n );\n\n let stderrOutput = \"\";\n child.stderr?.on(\"data\", (data: Buffer) => {\n stderrOutput += data.toString();\n });\n\n child.on(\"error\", (error) => {\n logger.error(\"Failed to run `@liam-hq/cli`.\");\n reject(error);\n });\n\n child.on(\"close\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n if (stderrOutput) {\n logger.error(stderrOutput);\n }\n logger.error(\n \"liam CLI exited with a non-zero code. Ensure `@liam-hq/cli erd build --format tbls --input schema.json` works in your project.\",\n );\n reject(new Error(`liam CLI exited with code ${code ?? 1}`));\n }\n });\n });\n}\n\ntype ErdBuildOptions = TailorDBSchemaOptions & {\n outputPath: string;\n erdDir: string;\n};\n\ntype ErdBuildsOptions = {\n client: OperatorClient;\n workspaceId: string;\n config: AppConfig;\n namespace?: string;\n outputDir?: string;\n requireErdSite?: boolean;\n};\n\n/**\n * Export TailorDB schema and build ERD artifacts via liam.\n * @param options - Build options.\n */\nasync function prepareErdBuild(options: ErdBuildOptions): Promise<void> {\n await writeTblsSchemaToFile(options);\n\n await runLiamBuild(options.outputPath, options.erdDir);\n\n const distDir = path.join(options.erdDir, \"dist\");\n const relativePath = path.relative(process.cwd(), distDir);\n logger.success(`Built ERD to ${relativePath}`);\n}\n\nexport interface ErdBuildResult {\n namespace: string;\n erdSite?: string;\n schemaOutputPath: string;\n distDir: string;\n erdDir: string;\n}\n\n/**\n * Prepare ERD builds for one or more namespaces.\n * @param options - Build options.\n * @returns Build results by namespace.\n */\nexport async function prepareErdBuilds(options: ErdBuildsOptions): Promise<ErdBuildResult[]> {\n const { client, workspaceId, config } = options;\n const baseDir = options.outputDir ?? path.resolve(process.cwd(), DEFAULT_ERD_BASE_DIR);\n let targets: ErdBuildResult[];\n\n if (options.namespace) {\n const { namespace, erdSite } = resolveDbConfig(config, options.namespace);\n if (options.requireErdSite && !erdSite) {\n throw new Error(\n `No erdSite configured for namespace \"${namespace}\". ` +\n `Add erdSite: \"<static-website-name>\" to db.${namespace} in tailor.config.ts.`,\n );\n }\n const erdDir = path.join(baseDir, namespace);\n targets = [\n {\n namespace,\n erdSite,\n schemaOutputPath: path.join(erdDir, \"schema.json\"),\n distDir: path.join(erdDir, \"dist\"),\n erdDir,\n },\n ];\n } else {\n const namespaces = resolveAllNamespaces(config, { requireErdSite: options.requireErdSite });\n if (namespaces.length === 0) {\n throw new Error(\n options.requireErdSite\n ? \"No namespaces with erdSite configured found. \" +\n 'Add erdSite: \"<static-website-name>\" to db.<namespace> in tailor.config.ts.'\n : \"No TailorDB namespaces found in config. Please define db services in tailor.config.ts.\",\n );\n }\n logger.info(\n `Found ${namespaces.length} namespace(s)${options.requireErdSite ? \" with erdSite configured\" : \"\"}.`,\n );\n targets = namespaces.map(({ namespace, erdSite }) => {\n const erdDir = path.join(baseDir, namespace);\n return {\n namespace,\n erdSite,\n schemaOutputPath: path.join(erdDir, \"schema.json\"),\n distDir: path.join(erdDir, \"dist\"),\n erdDir,\n };\n });\n }\n\n await Promise.all(\n targets.map((target) =>\n prepareErdBuild({\n namespace: target.namespace,\n client,\n workspaceId,\n outputPath: target.schemaOutputPath,\n erdDir: target.erdDir,\n }),\n ),\n );\n\n return targets;\n}\n\nexport const erdExportCommand = defineCommand({\n name: \"export\",\n description: \"Export Liam ERD dist from applied TailorDB schema.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n ...jsonArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"TailorDB namespace name (optional if only one namespace is defined in config)\",\n }),\n output: arg(z.string().default(DEFAULT_ERD_BASE_DIR), {\n alias: \"o\",\n description:\n \"Output directory path for tbls-compatible ERD JSON (writes to `<outputDir>/<namespace>/schema.json`)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const { client, workspaceId, config } = await initErdContext(args);\n const outputDir = path.resolve(process.cwd(), String(args.output));\n\n const results = await prepareErdBuilds({\n client,\n workspaceId,\n config,\n namespace: args.namespace,\n outputDir,\n });\n\n logger.newline();\n if (args.json) {\n logger.out(\n results.map((result) => ({\n namespace: result.namespace,\n distDir: result.distDir,\n schemaOutputPath: result.schemaOutputPath,\n })),\n );\n } else {\n for (const result of results) {\n logger.out(`Exported ERD for namespace \"${result.namespace}\"`);\n logger.out(` - Liam ERD dist: ${result.distDir}`);\n logger.out(` - tbls schema.json: ${result.schemaOutputPath}`);\n }\n }\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { deployStaticWebsite, logSkippedFiles } from \"../../staticwebsite/deploy\";\nimport { logger } from \"../../utils/logger\";\nimport { prepareErdBuilds } from \"./export\";\nimport { initErdContext } from \"./utils\";\n\nexport const erdDeployCommand = defineCommand({\n name: \"deploy\",\n description: \"Deploy ERD static website for TailorDB namespace(s).\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n ...jsonArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description:\n \"TailorDB namespace name (optional - deploys all namespaces with erdSite if omitted)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const { client, workspaceId, config } = await initErdContext(args);\n const buildResults = await prepareErdBuilds({\n client,\n workspaceId,\n config,\n namespace: args.namespace,\n requireErdSite: true,\n });\n\n const deployResults = await Promise.all(\n buildResults.map(async (result) => {\n if (!result.erdSite) {\n throw new Error(\n `No erdSite configured for namespace \"${result.namespace}\". ` +\n `Add erdSite: \"<static-website-name>\" to db.${result.namespace} in tailor.config.ts.`,\n );\n }\n\n if (!args.json) {\n logger.info(\n `Deploying ERD for namespace \"${result.namespace}\" to site \"${result.erdSite}\"...`,\n );\n }\n\n const { url, skippedFiles } = await deployStaticWebsite(\n client,\n workspaceId,\n result.erdSite,\n result.distDir,\n !args.json,\n );\n\n return {\n namespace: result.namespace,\n erdSite: result.erdSite,\n url,\n skippedFiles,\n };\n }),\n );\n logger.newline();\n\n if (args.json) {\n logger.out(deployResults);\n } else {\n for (const result of deployResults) {\n logSkippedFiles(result.skippedFiles);\n logger.newline();\n logger.success(`ERD site \"${result.erdSite}\" deployed successfully.`);\n logger.out(result.url);\n }\n }\n }),\n});\n","import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, withCommonArgs } from \"../../args\";\nimport { logger } from \"../../utils/logger\";\nimport { resolveCliBinPath } from \"../../utils/resolve-cli-bin\";\nimport { prepareErdBuilds, type ErdBuildResult } from \"./export\";\nimport { initErdContext } from \"./utils\";\n\nfunction formatServeCommand(namespace: string): string {\n return `tailor-sdk tailordb erd serve --namespace ${namespace}`;\n}\n\nasync function runServeDist(results: ErdBuildResult[]): Promise<void> {\n if (results.length === 0) {\n throw new Error(\"No ERD build results found.\");\n }\n\n const [primary, ...rest] = results;\n\n logger.info(`Serving ERD for namespace \"${primary.namespace}\".`);\n if (rest.length > 0) {\n const commands = rest.map((result) => ` - ${formatServeCommand(result.namespace)}`).join(\"\\n\");\n logger.warn(`Multiple namespaces found. To serve another namespace, run:\\n${commands}`);\n }\n\n fs.mkdirSync(primary.erdDir, { recursive: true });\n\n return await new Promise<void>((resolve, reject) => {\n let serveBinPath: string;\n try {\n serveBinPath = resolveCliBinPath({\n packageName: \"serve\",\n binName: \"serve\",\n });\n } catch (error) {\n logger.error(String(error));\n reject(error);\n return;\n }\n\n const child = spawn(process.execPath, [serveBinPath, \"dist\"], {\n stdio: \"inherit\",\n cwd: primary.erdDir,\n });\n\n child.on(\"error\", (error) => {\n logger.error(\"Failed to run `serve dist`.\");\n reject(error);\n });\n\n child.on(\"exit\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n logger.error(\n \"serve CLI exited with a non-zero code. Ensure `serve dist` works in your project.\",\n );\n reject(new Error(`serve CLI exited with code ${code ?? 1}`));\n }\n });\n });\n}\n\nexport const erdServeCommand = defineCommand({\n name: \"serve\",\n description: \"Generate and serve ERD locally (liam build + serve dist). (beta)\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"TailorDB namespace name (uses first namespace in config if not specified)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const { client, workspaceId, config } = await initErdContext(args);\n\n const results = await prepareErdBuilds({\n client,\n workspaceId,\n config,\n namespace: args.namespace,\n });\n\n await runServeDist(results);\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { erdDeployCommand } from \"./deploy\";\nimport { erdExportCommand } from \"./export\";\nimport { erdServeCommand } from \"./serve\";\n\nexport const erdCommand = defineCommand({\n name: \"erd\",\n description: \"Generate ERD artifacts for TailorDB namespaces using Liam ERD. (beta)\",\n subCommands: {\n export: erdExportCommand,\n serve: erdServeCommand,\n deploy: erdDeployCommand,\n },\n});\n","import * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { trnPrefix } from \"../../apply/services/label\";\nimport { commonArgs, confirmationArgs, deploymentArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadConfig } from \"../../config-loader\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logBetaWarning } from \"../../utils/beta\";\nimport { logger, styles } from \"../../utils/logger\";\nimport { getNamespacesWithMigrations } from \"./config\";\nimport { formatMigrationNumber, isValidMigrationNumber } from \"./snapshot\";\nimport { parseMigrationLabelNumber } from \"./types\";\n\nexport interface SetOptions {\n configPath?: string;\n number: string;\n namespace?: string;\n yes?: boolean;\n workspaceId?: string;\n profile?: string;\n}\n\n/**\n * Set migration checkpoint for a TailorDB namespace\n * @param {SetOptions} options - Command options\n */\nasync function set(options: SetOptions): Promise<void> {\n logBetaWarning(\"tailordb migration\");\n\n // 1. Validate migration number format\n const numberStr = options.number;\n\n // Accept either 4-digit format (0001) or integer (1)\n let migrationNumber: number;\n if (isValidMigrationNumber(numberStr)) {\n // 4-digit format\n migrationNumber = parseInt(numberStr, 10);\n } else {\n // Try parsing as integer\n migrationNumber = parseInt(numberStr, 10);\n if (isNaN(migrationNumber) || migrationNumber < 0) {\n throw new Error(\n `Invalid migration number format: ${numberStr}. Expected 4-digit format (e.g., 0001) or integer (e.g., 1).`,\n );\n }\n }\n\n // 2. Load configuration\n const { config } = await loadConfig(options.configPath);\n const configDir = path.dirname(config.path);\n\n // 3. Get namespaces with migrations\n const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);\n\n if (namespacesWithMigrations.length === 0) {\n throw new Error(\"No TailorDB services with migrations configuration found\");\n }\n\n // 4. Determine target namespace\n let targetNamespace: string;\n if (options.namespace) {\n if (!namespacesWithMigrations.some((ns) => ns.namespace === options.namespace)) {\n throw new Error(\n `Namespace \"${options.namespace}\" not found or does not have migrations configured`,\n );\n }\n targetNamespace = options.namespace;\n } else if (namespacesWithMigrations.length === 1) {\n targetNamespace = namespacesWithMigrations[0].namespace;\n } else {\n throw new Error(\n `Multiple TailorDB services found. Please specify namespace with --namespace flag: ${namespacesWithMigrations.map((ns) => ns.namespace).join(\", \")}`,\n );\n }\n\n // 5. Initialize client\n const accessToken = await loadAccessToken({\n useProfile: false,\n profile: options.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options.workspaceId,\n profile: options.profile,\n });\n\n // 6. Get current migration number\n const trn = `${trnPrefix(workspaceId)}:tailordb:${targetNamespace}`;\n let currentMigration: number;\n try {\n const { metadata } = await client.getMetadata({ trn });\n const label = metadata?.labels?.[\"sdk-migration\"];\n currentMigration = label ? (parseMigrationLabelNumber(label) ?? 0) : 0;\n } catch {\n currentMigration = 0;\n }\n\n // 7. Display warning and confirmation\n logger.newline();\n logger.warn(\"This operation will change the migration checkpoint.\");\n logger.log(`Namespace: ${styles.bold(targetNamespace)}`);\n logger.log(`Current migration: ${styles.bold(formatMigrationNumber(currentMigration))}`);\n logger.log(`New migration: ${styles.bold(formatMigrationNumber(migrationNumber))}`);\n logger.newline();\n\n if (migrationNumber < currentMigration) {\n logger.warn(\n `Setting migration number backwards (${formatMigrationNumber(currentMigration)} → ${formatMigrationNumber(migrationNumber)}) will cause previous migrations to be re-executed on next apply.`,\n );\n logger.newline();\n } else if (migrationNumber > currentMigration) {\n logger.warn(\n `Setting migration number forwards (${formatMigrationNumber(currentMigration)} → ${formatMigrationNumber(migrationNumber)}) will skip migrations ${formatMigrationNumber(currentMigration + 1)} to ${formatMigrationNumber(migrationNumber)}.`,\n );\n logger.newline();\n }\n\n // 8. Confirmation prompt (unless --yes flag)\n if (!options.yes) {\n const confirmation = await logger.prompt(\"Continue with migration checkpoint update?\", {\n type: \"confirm\",\n initial: false,\n });\n\n if (!confirmation) {\n logger.info(\"Operation cancelled.\");\n return;\n }\n logger.newline();\n }\n\n // 9. Update migration label\n const { metadata } = await client.getMetadata({ trn });\n const existingLabels = metadata?.labels ?? {};\n\n await client.setMetadata({\n trn,\n labels: {\n ...existingLabels,\n \"sdk-migration\": `m${formatMigrationNumber(migrationNumber)}`,\n },\n });\n\n logger.success(\n `Migration checkpoint set to ${styles.bold(formatMigrationNumber(migrationNumber))} for namespace ${styles.bold(targetNamespace)}`,\n );\n}\n\nexport const setCommand = defineCommand({\n name: \"set\",\n description: \"Set migration checkpoint to a specific number.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n ...confirmationArgs,\n number: arg(z.string(), {\n positional: true,\n description: \"Migration number to set (e.g., 0001 or 1)\",\n }),\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"Target TailorDB namespace (required if multiple namespaces exist)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n await set({\n configPath: args.config,\n number: args.number,\n namespace: args.namespace,\n yes: args.yes,\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n }),\n});\n","import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { trnPrefix } from \"../../apply/services/label\";\nimport { commonArgs, deploymentArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadConfig } from \"../../config-loader\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logBetaWarning } from \"../../utils/beta\";\nimport { logger, styles } from \"../../utils/logger\";\nimport { getNamespacesWithMigrations } from \"./config\";\nimport {\n getMigrationFiles,\n loadDiff,\n getMigrationFilePath,\n formatMigrationNumber,\n} from \"./snapshot\";\nimport { parseMigrationLabelNumber } from \"./types\";\n\nexport interface StatusOptions {\n configPath?: string;\n namespace?: string;\n workspaceId?: string;\n profile?: string;\n}\n\n/**\n * Show migration status for TailorDB namespaces\n * @param {StatusOptions} options - Command options\n */\nasync function status(options: StatusOptions): Promise<void> {\n logBetaWarning(\"tailordb migration\");\n\n // 1. Load configuration\n const { config } = await loadConfig(options.configPath);\n const configDir = path.dirname(config.path);\n\n // 2. Get namespaces with migrations\n const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);\n\n if (namespacesWithMigrations.length === 0) {\n throw new Error(\"No TailorDB services with migrations configuration found\");\n }\n\n // 3. Filter by namespace if specified\n const targetNamespaces = options.namespace\n ? namespacesWithMigrations.filter((ns) => ns.namespace === options.namespace)\n : namespacesWithMigrations;\n\n if (targetNamespaces.length === 0) {\n throw new Error(\n `Namespace \"${options.namespace}\" not found or does not have migrations configured`,\n );\n }\n\n // 4. Initialize client\n const accessToken = await loadAccessToken({\n useProfile: false,\n profile: options.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options.workspaceId,\n profile: options.profile,\n });\n\n // 5. Display status for each namespace\n for (const { namespace, migrationsDir } of targetNamespaces) {\n // Get current migration number\n const trn = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;\n let currentMigration: number;\n try {\n const { metadata } = await client.getMetadata({ trn });\n const label = metadata?.labels?.[\"sdk-migration\"];\n currentMigration = label ? (parseMigrationLabelNumber(label) ?? 0) : 0;\n } catch {\n currentMigration = 0;\n }\n\n // Get available migrations\n const migrationFiles = getMigrationFiles(migrationsDir);\n const availableNumbers = migrationFiles\n .map((f) => f.number)\n .filter((n, i, arr) => arr.indexOf(n) === i) // deduplicate\n .sort((a, b) => a - b);\n const pendingNumbers = availableNumbers.filter((n) => n > currentMigration);\n\n // Display\n logger.newline();\n logger.info(`Namespace: ${styles.bold(namespace)}`);\n logger.log(` Current migration: ${styles.bold(formatMigrationNumber(currentMigration))}`);\n\n if (pendingNumbers.length > 0) {\n logger.log(\" Pending migrations:\");\n for (const num of pendingNumbers) {\n const diffPath = getMigrationFilePath(migrationsDir, num, \"diff\");\n let description: string | undefined;\n\n if (fs.existsSync(diffPath)) {\n try {\n const diff = loadDiff(diffPath);\n description = diff.description;\n } catch {\n // Ignore errors loading diff\n }\n }\n\n if (description) {\n logger.log(` - ${formatMigrationNumber(num)}: ${description}`);\n } else {\n logger.log(` - ${formatMigrationNumber(num)}`);\n }\n }\n } else {\n logger.log(\" Pending migrations: (none)\");\n }\n }\n\n logger.newline();\n}\n\nexport const statusCommand = defineCommand({\n name: \"status\",\n description:\n \"Show the current migration status for TailorDB namespaces, including applied and pending migrations.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"Target TailorDB namespace (shows all namespaces if not specified)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n await status({\n configPath: args.config,\n namespace: args.namespace,\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n }),\n});\n","/**\n * TailorDB migration command\n *\n * Subcommands:\n * - generate: Generate migration files from schema differences\n * - set: Set migration checkpoint to a specific number\n * - status: Show migration status for TailorDB namespaces\n */\n\nimport { defineCommand } from \"politty\";\nimport { generateCommand } from \"./generate\";\nimport { setCommand } from \"./set\";\nimport { statusCommand } from \"./status\";\n\nexport const migrationCommand = defineCommand({\n name: \"migration\",\n description: \"Manage TailorDB schema migrations.\",\n subCommands: {\n generate: generateCommand,\n set: setCommand,\n status: statusCommand,\n },\n});\n\nexport { generateCommand } from \"./generate\";\nexport type { GenerateOptions } from \"./generate\";\nexport { setCommand } from \"./set\";\nexport type { SetOptions } from \"./set\";\nexport { statusCommand } from \"./status\";\nexport type { StatusOptions } from \"./status\";\n","import { defineCommand } from \"politty\";\nimport { erdCommand } from \"./erd\";\nimport { migrationCommand } from \"./migrate\";\nimport { truncateCommand } from \"./truncate\";\n\nexport const tailordbCommand = defineCommand({\n name: \"tailordb\",\n description: \"Manage TailorDB tables and data.\",\n subCommands: {\n erd: erdCommand,\n migration: migrationCommand,\n truncate: truncateCommand,\n },\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const currentCommand = defineCommand({\n name: \"current\",\n description: \"Show current user.\",\n args: z.object({\n ...commonArgs,\n }),\n run: withCommonArgs(async () => {\n const config = readPlatformConfig();\n\n // Check if current user is set\n if (!config.current_user) {\n throw new Error(ml`\n Current user not set.\n Please login first using 'tailor-sdk login' command to register a user.\n `);\n }\n\n // Check if user exists\n if (!config.users[config.current_user]) {\n throw new Error(ml`\n Current user '${config.current_user}' not found in registered users.\n Please login again using 'tailor-sdk login' command to register the user.\n `);\n }\n\n logger.log(config.current_user);\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all users.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n const users = Object.keys(config.users);\n if (users.length === 0) {\n logger.info(ml`\n No users found.\n Please login first using 'tailor-sdk login' command to register a user.\n `);\n return;\n }\n\n if (args.json) {\n logger.out(users);\n return;\n }\n\n users.forEach((user) => {\n if (user === config.current_user) {\n logger.success(`${user} (current)`, { mode: \"plain\" });\n } else {\n logger.log(user);\n }\n });\n }),\n});\n","import { PATScope } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\nimport ml from \"multiline-ts\";\nimport { logger } from \"../../utils/logger\";\nimport type { PersonalAccessToken } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n\nexport interface PersonalAccessTokenInfo {\n name: string;\n scopes: string[];\n}\n\nfunction patScopeToString(scope: PATScope): string {\n switch (scope) {\n case PATScope.PAT_SCOPE_READ:\n return \"read\";\n case PATScope.PAT_SCOPE_WRITE:\n return \"write\";\n default:\n return \"unknown\";\n }\n}\n\n/**\n * Transform a PersonalAccessToken into CLI-friendly info.\n * @param pat - Personal access token resource\n * @returns Flattened token info\n */\nexport function transformPersonalAccessToken(pat: PersonalAccessToken): PersonalAccessTokenInfo {\n return {\n name: pat.name,\n scopes: pat.scopes.map(patScopeToString),\n };\n}\n\n/**\n * Get PAT scopes from a write flag.\n * @param write - Whether write access is required\n * @returns Scopes to apply to the token\n */\nexport function getScopesFromWriteFlag(write: boolean): PATScope[] {\n return write ? [PATScope.PAT_SCOPE_READ, PATScope.PAT_SCOPE_WRITE] : [PATScope.PAT_SCOPE_READ];\n}\n\nfunction getScopeStringsFromWriteFlag(write: boolean): string[] {\n return write ? [\"read\", \"write\"] : [\"read\"];\n}\n\n/**\n * Print the created or updated personal access token to the logger.\n * @param name - Token name\n * @param token - Token value\n * @param write - Whether the token has write scope\n * @param action - Action performed\n */\nexport function printCreatedToken(\n name: string,\n token: string,\n write: boolean,\n action: \"created\" | \"updated\",\n): void {\n const scopes = getScopeStringsFromWriteFlag(write);\n\n if (logger.jsonMode) {\n logger.out({ name, scopes, token });\n } else {\n logger.log(ml`\n Personal access token ${action} successfully.\n\n name: ${name}\n scopes: ${scopes.join(\"/\")}\n token: ${token}\n\n Please save this token in a secure location. You won't be able to see it again.\n `);\n }\n}\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { getScopesFromWriteFlag, printCreatedToken } from \"./transform\";\n\nexport const createCommand = defineCommand({\n name: \"create\",\n description: \"Create a new personal access token.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Token name\",\n }),\n write: arg(z.boolean().default(false), {\n alias: \"W\",\n description: \"Grant write permission (default: read-only)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n const scopes = getScopesFromWriteFlag(args.write);\n const result = await client.createPersonalAccessToken({\n name: args.name,\n scopes,\n });\n\n if (!result.accessToken) {\n throw new Error(\"Failed to create personal access token\");\n }\n\n printCreatedToken(args.name, result.accessToken, args.write, \"created\");\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\n\nexport const deleteCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a personal access token.\",\n args: z.object({\n ...commonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Token name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n await client.deletePersonalAccessToken({\n name: args.name,\n });\n\n logger.success(`Personal access token \"${args.name}\" deleted successfully.`);\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { fetchAll, initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport { transformPersonalAccessToken, type PersonalAccessTokenInfo } from \"./transform\";\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all personal access tokens.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n const pats = await fetchAll(async (pageToken) => {\n const { personalAccessTokens, nextPageToken } = await client.listPersonalAccessTokens({\n pageToken,\n });\n return [personalAccessTokens, nextPageToken];\n });\n\n if (pats.length === 0 && !args.json) {\n logger.info(ml`\n No personal access tokens found.\n Please create a token using 'tailor-sdk user pat create' command.\n `);\n return;\n }\n\n const patInfos: PersonalAccessTokenInfo[] = pats.map(transformPersonalAccessToken);\n if (args.json) {\n logger.out(patInfos);\n return;\n }\n\n if (pats.length === 0) {\n return;\n }\n\n // Text format: aligned list \"name: scope1/scope2\"\n const maxNameLength = Math.max(...pats.map((pat) => pat.name.length));\n\n pats.forEach((pat) => {\n const info = transformPersonalAccessToken(pat);\n const paddedName = info.name.padStart(maxNameLength);\n logger.log(`${paddedName}: ${info.scopes.join(\"/\")}`);\n });\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { getScopesFromWriteFlag, printCreatedToken } from \"./transform\";\n\nexport const updateCommand = defineCommand({\n name: \"update\",\n description: \"Update a personal access token (delete and recreate).\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Token name\",\n }),\n write: arg(z.boolean().default(false), {\n alias: \"W\",\n description: \"Grant write permission (if not specified, keeps read-only)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n // Delete the existing token\n await client.deletePersonalAccessToken({\n name: args.name,\n });\n\n // Create a new token with the same name\n const scopes = getScopesFromWriteFlag(args.write);\n const result = await client.createPersonalAccessToken({\n name: args.name,\n scopes,\n });\n\n if (!result.accessToken) {\n throw new Error(\"Failed to create personal access token\");\n }\n\n printCreatedToken(args.name, result.accessToken, args.write, \"updated\");\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { listCommand } from \"./list\";\nimport { updateCommand } from \"./update\";\n\nexport const patCommand = defineCommand({\n name: \"pat\",\n description: \"Manage personal access tokens.\",\n args: listCommand.args,\n subCommands: {\n create: createCommand,\n delete: deleteCommand,\n list: listCommand,\n update: updateCommand,\n },\n async run(args) {\n // Default to list when no subcommand is provided\n await listCommand.run(args);\n },\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const switchCommand = defineCommand({\n name: \"switch\",\n description: \"Set current user.\",\n args: z.object({\n ...commonArgs,\n user: arg(z.string(), {\n positional: true,\n description: \"User email\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if user exists\n if (!config.users[args.user]) {\n throw new Error(ml`\n User \"${args.user}\" not found.\n Please login first using 'tailor-sdk login' command to register this user.\n `);\n }\n\n // Set current user\n config.current_user = args.user;\n writePlatformConfig(config);\n\n logger.success(`Current user set to \"${args.user}\" successfully.`);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { currentCommand } from \"./current\";\nimport { listCommand } from \"./list\";\nimport { patCommand } from \"./pat\";\nimport { switchCommand } from \"./switch\";\n\nexport const userCommand = defineCommand({\n name: \"user\",\n description: \"Manage Tailor Platform users.\",\n subCommands: {\n current: currentCommand,\n list: listCommand,\n pat: patCommand,\n switch: switchCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { executionsCommand } from \"./executions\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\nimport { resumeCommand } from \"./resume\";\nimport { startCommand } from \"./start\";\n\nexport const workflowCommand = defineCommand({\n name: \"workflow\",\n description: \"Manage workflows and workflow executions.\",\n subCommands: {\n list: listCommand,\n get: getCommand,\n start: startCommand,\n executions: executionsCommand,\n resume: resumeCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { healthCommand } from \"./health\";\nimport { listCommand } from \"./list\";\n\nexport const appCommand = defineCommand({\n name: \"app\",\n description: \"Manage workspace applications\",\n subCommands: {\n health: healthCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { inviteCommand } from \"./invite\";\nimport { listCommand } from \"./list\";\nimport { removeCommand } from \"./remove\";\nimport { updateCommand } from \"./update\";\n\nexport const userCommand = defineCommand({\n name: \"user\",\n description: \"Manage workspace users\",\n subCommands: {\n invite: inviteCommand,\n list: listCommand,\n remove: removeCommand,\n update: updateCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { appCommand } from \"./app\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\nimport { restoreCommand } from \"./restore\";\nimport { userCommand } from \"./user\";\n\nexport const workspaceCommand = defineCommand({\n name: \"workspace\",\n description: \"Manage Tailor Platform workspaces.\",\n subCommands: {\n app: appCommand,\n create: createCommand,\n delete: deleteCommand,\n get: getCommand,\n list: listCommand,\n restore: restoreCommand,\n user: userCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","#!/usr/bin/env node\n\nimport { register } from \"node:module\";\nimport { defineCommand, runMain } from \"politty\";\nimport { apiCommand } from \"./api\";\nimport { applyCommand } from \"./apply\";\nimport { executorCommand } from \"./executor\";\nimport { generateCommand } from \"./generator\";\nimport { initCommand } from \"./init\";\nimport { loginCommand } from \"./login\";\nimport { logoutCommand } from \"./logout\";\nimport { machineuserCommand } from \"./machineuser\";\nimport { oauth2clientCommand } from \"./oauth2client\";\nimport { openCommand } from \"./open\";\nimport { profileCommand } from \"./profile\";\nimport { removeCommand } from \"./remove\";\nimport { secretCommand } from \"./secret\";\nimport { showCommand } from \"./show\";\nimport { staticwebsiteCommand } from \"./staticwebsite\";\nimport { tailordbCommand } from \"./tailordb\";\nimport { userCommand } from \"./user\";\nimport { readPackageJson } from \"./utils/package-json\";\nimport { workflowCommand } from \"./workflow\";\nimport { workspaceCommand } from \"./workspace\";\n\nregister(\"tsx\", import.meta.url, { data: {} });\n\nconst packageJson = await readPackageJson();\n\nexport const mainCommand = defineCommand({\n name: Object.keys(packageJson.bin ?? {})[0] || \"tailor-sdk\",\n description:\n packageJson.description || \"Tailor CLI for managing Tailor Platform SDK applications\",\n subCommands: {\n api: apiCommand,\n apply: applyCommand,\n executor: executorCommand,\n generate: generateCommand,\n init: initCommand,\n login: loginCommand,\n logout: logoutCommand,\n machineuser: machineuserCommand,\n oauth2client: oauth2clientCommand,\n open: openCommand,\n profile: profileCommand,\n remove: removeCommand,\n secret: secretCommand,\n show: showCommand,\n staticwebsite: staticwebsiteCommand,\n tailordb: tailordbCommand,\n user: userCommand,\n workflow: workflowCommand,\n workspace: workspaceCommand,\n },\n});\n\nrunMain(mainCommand, { version: packageJson.version });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,kBAAkB,cAAc;CAC3C,MAAM;CACN,aAAa;CACb,aAAa;EACX,MAAMA;EACN,KAAKC;EACL,MAAM;EACN,SAAS;EACT,SAAS;EACV;CACD,MAAM,MAAM;AACV,QAAM,WAAWD,eAAa,EAAE,CAAC;;CAEpC,CAAC;;;;ACbF,MAAM,6BAA6B;CACjC,MAAM,eAAe;EAAC;EAAO;EAAQ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V,QAAM,WAAWD,eAAa,EAAE,CAAC;;CAEpC,CAAC;;;;AChBF,MAAa,aAAa,cAAc;CACtC,MAAM;CACN,aAAa;CACb,aAAa;EACX,QAAQ;EACR,MAAME;EACP;CACD,MAAM,MAAM;AACV,QAAM,WAAWA,eAAa,EAAE,CAAC;;CAEpC,CAAC;;;;ACRF,MAAa,cAAc,cAAc;CACvC,MAAM;CACN,aAAa;CACb,aAAa;EACX,QAAQ;EACR,MAAMC;EACN,QAAQ;EACR,QAAQC;EACT;CACD,MAAM,MAAM;AACV,QAAM,WAAWD,gBAAa,EAAE,CAAC;;CAEpC,CAAC;;;;ACTF,MAAa,mBAAmB,cAAc;CAC5C,MAAM;CACN,aAAa;CACb,aAAa;EACX,KAAK;EACL,QAAQE;EACR,QAAQC;EACR,KAAKC;EACL,MAAMC;EACN,SAAS;EACT,MAAM;EACP;CACD,MAAM,MAAM;AACV,QAAM,WAAWA,gBAAa,EAAE,CAAC;;CAEpC,CAAC;;;;ACCF,SAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;AAE9C,MAAM,cAAc,MAAM,iBAAiB;AAE3C,MAAa,cAAc,cAAc;CACvC,MAAM,OAAO,KAAK,YAAY,OAAO,EAAE,CAAC,CAAC,MAAM;CAC/C,aACE,YAAY,eAAe;CAC7B,aAAa;EACX,KAAK;EACL,OAAO;EACP,UAAU;EACV,UAAUC;EACV,MAAM;EACN,OAAO;EACP,QAAQ;EACR,aAAa;EACb,cAAc;EACd,MAAM;EACN,SAAS;EACT,QAAQC;EACR,QAAQ;EACR,MAAM;EACN,eAAe;EACf,UAAU;EACV,MAAMC;EACN,UAAU;EACV,WAAW;EACZ;CACF,CAAC;AAEF,QAAQ,aAAa,EAAE,SAAS,YAAY,SAAS,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["listCommand","getCommand","packageJson","listCommand","getCommand","listCommand","createCommand","deleteCommand","listCommand","updateCommand","createCommand","deleteCommand","listCommand","updateCommand","createCommand","deleteCommand","listCommand","createCommand","deleteCommand","listCommand","setTimeout","fs","mimeLookup","listCommand","listCommand","fs","metadata","fs","listCommand","userCommand","listCommand","listCommand","getCommand","listCommand","listCommand","updateCommand","createCommand","deleteCommand","getCommand","listCommand","generateCommand","removeCommand","userCommand"],"sources":["../../src/cli/executor/index.ts","../../src/cli/init.ts","../../src/cli/login.ts","../../src/cli/logout.ts","../../src/cli/machineuser/index.ts","../../src/cli/oauth2client/index.ts","../../src/cli/open.ts","../../src/cli/profile/create.ts","../../src/cli/profile/delete.ts","../../src/cli/profile/list.ts","../../src/cli/profile/update.ts","../../src/cli/profile/index.ts","../../src/cli/secret/args.ts","../../src/cli/secret/create.ts","../../src/cli/secret/delete.ts","../../src/cli/secret/list.ts","../../src/cli/secret/update.ts","../../src/cli/secret/vault/args.ts","../../src/cli/secret/vault/create.ts","../../src/cli/secret/vault/delete.ts","../../src/cli/secret/vault/list.ts","../../src/cli/secret/vault/index.ts","../../src/cli/secret/index.ts","../../src/cli/utils/progress.ts","../../src/cli/staticwebsite/deploy.ts","../../src/cli/staticwebsite/get.ts","../../src/cli/staticwebsite/list.ts","../../src/cli/staticwebsite/index.ts","../../src/cli/utils/resolve-cli-bin.ts","../../src/cli/tailordb/erd/schema.ts","../../src/cli/tailordb/erd/utils.ts","../../src/cli/tailordb/erd/export.ts","../../src/cli/tailordb/erd/deploy.ts","../../src/cli/tailordb/erd/serve.ts","../../src/cli/tailordb/erd/index.ts","../../src/cli/tailordb/migrate/set.ts","../../src/cli/tailordb/migrate/status.ts","../../src/cli/tailordb/migrate/index.ts","../../src/cli/tailordb/index.ts","../../src/cli/user/current.ts","../../src/cli/user/list.ts","../../src/cli/user/pat/transform.ts","../../src/cli/user/pat/create.ts","../../src/cli/user/pat/delete.ts","../../src/cli/user/pat/list.ts","../../src/cli/user/pat/update.ts","../../src/cli/user/pat/index.ts","../../src/cli/user/switch.ts","../../src/cli/user/index.ts","../../src/cli/workflow/index.ts","../../src/cli/workspace/app/index.ts","../../src/cli/workspace/user/index.ts","../../src/cli/workspace/index.ts","../../src/cli/index.ts"],"sourcesContent":["import { defineCommand, runCommand } from \"politty\";\nimport { getCommand } from \"./get\";\nimport { jobsCommand } from \"./jobs\";\nimport { listCommand } from \"./list\";\nimport { triggerCommand } from \"./trigger\";\nimport { webhookCommand } from \"./webhook\";\n\nexport const executorCommand = defineCommand({\n name: \"executor\",\n description: \"Manage executors\",\n subCommands: {\n list: listCommand,\n get: getCommand,\n jobs: jobsCommand,\n trigger: triggerCommand,\n webhook: webhookCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { spawnSync } from \"node:child_process\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"./args\";\nimport { logger } from \"./utils/logger\";\nimport { readPackageJson } from \"./utils/package-json\";\n\nconst detectPackageManager = () => {\n const availablePMs = [\"npm\", \"yarn\", \"pnpm\"];\n const userAgent = process.env.npm_config_user_agent;\n if (!userAgent) return;\n const [name] = userAgent.split(\"/\");\n if (!availablePMs.includes(name)) return;\n return name;\n};\n\nexport const initCommand = defineCommand({\n name: \"init\",\n description: \"Initialize a new project using create-sdk.\",\n args: z.object({\n ...commonArgs,\n name: arg(z.string().optional(), {\n positional: true,\n description: \"Project name\",\n }),\n template: arg(z.string().optional(), {\n alias: \"t\",\n description: \"Template name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const packageJson = await readPackageJson();\n const version =\n packageJson.version && packageJson.version !== \"0.0.0\" ? packageJson.version : \"latest\";\n\n let packageManager = detectPackageManager();\n if (!packageManager) {\n logger.warn(\"Could not detect package manager, defaulting to npm\");\n packageManager = \"npm\";\n }\n const initArgs = [\n \"create\",\n `@tailor-platform/sdk@${version}`,\n ...(args.name ? [args.name] : []),\n ...(packageManager === \"npm\" ? [\"--\"] : []),\n ...(args.template ? [\"--template\", args.template] : []),\n ];\n logger.log(`Running: ${packageManager} ${initArgs.join(\" \")}`);\n\n spawnSync(packageManager, initArgs, { stdio: \"inherit\" });\n }),\n});\n","import * as crypto from \"node:crypto\";\nimport * as http from \"node:http\";\nimport { generateCodeVerifier } from \"@badgateway/oauth2-client\";\nimport open from \"open\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"./args\";\nimport { fetchUserInfo, initOAuth2Client } from \"./client\";\nimport { readPlatformConfig, writePlatformConfig } from \"./context\";\nimport { logger } from \"./utils/logger\";\n\nconst redirectPort = 8085;\nconst redirectUri = `http://localhost:${redirectPort}/callback`;\n\nfunction randomState() {\n return crypto.randomBytes(32).toString(\"base64url\");\n}\n\nconst startAuthServer = async () => {\n const client = initOAuth2Client();\n const state = randomState();\n const codeVerifier = await generateCodeVerifier();\n\n return new Promise<void>((resolve, reject) => {\n const server = http.createServer(async (req, res) => {\n try {\n if (!req.url?.startsWith(\"/callback\")) {\n throw new Error(\"Invalid callback URL\");\n }\n const tokens = await client.authorizationCode.getTokenFromCodeRedirect(\n `http://${req.headers.host}${req.url}`,\n {\n redirectUri: redirectUri,\n state,\n codeVerifier,\n },\n );\n const userInfo = await fetchUserInfo(tokens.accessToken);\n\n const pfConfig = readPlatformConfig();\n pfConfig.users = {\n ...pfConfig.users,\n [userInfo.email]: {\n access_token: tokens.accessToken,\n refresh_token: tokens.refreshToken!,\n token_expires_at: new Date(tokens.expiresAt!).toISOString(),\n },\n };\n pfConfig.current_user = userInfo.email;\n writePlatformConfig(pfConfig);\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n status: \"ok\",\n message: \"Successfully authenticated. Please close this window.\",\n }),\n );\n resolve();\n } catch (error) {\n res.writeHead(401);\n res.end(\"Authentication failed\");\n reject(error);\n } finally {\n // Close the server after handling one request.\n server.close();\n }\n });\n\n const timeout = setTimeout(\n () => {\n server.close();\n reject(new Error(\"Login timeout exceeded\"));\n },\n 5 * 60 * 1000,\n );\n\n server.on(\"close\", () => {\n clearTimeout(timeout);\n });\n\n server.on(\"error\", (error) => {\n reject(error);\n });\n\n server.listen(redirectPort, async () => {\n const authorizeUri = await client.authorizationCode.getAuthorizeUri({\n redirectUri,\n state,\n codeVerifier,\n });\n\n logger.info(`Opening browser for login:\\n\\n${authorizeUri}\\n`);\n try {\n await open(authorizeUri);\n } catch {\n logger.warn(\"Failed to open browser automatically. Please open the URL above manually.\");\n }\n });\n });\n};\n\nexport const loginCommand = defineCommand({\n name: \"login\",\n description: \"Login to Tailor Platform.\",\n args: z.object({\n ...commonArgs,\n }),\n run: withCommonArgs(async () => {\n await startAuthServer();\n logger.success(\"Successfully logged in to Tailor Platform.\");\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"./args\";\nimport { initOAuth2Client } from \"./client\";\nimport { readPlatformConfig, writePlatformConfig } from \"./context\";\nimport { logger } from \"./utils/logger\";\n\nexport const logoutCommand = defineCommand({\n name: \"logout\",\n description: \"Logout from Tailor Platform.\",\n args: z.object({\n ...commonArgs,\n }),\n run: withCommonArgs(async () => {\n const pfConfig = readPlatformConfig();\n const tokens = pfConfig.current_user ? pfConfig.users[pfConfig.current_user] : undefined;\n if (!tokens) {\n logger.info(\"You are not logged in.\");\n return;\n }\n\n const client = initOAuth2Client();\n client.revoke(\n {\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token,\n expiresAt: Date.parse(tokens.token_expires_at),\n },\n \"refresh_token\",\n );\n\n delete pfConfig.users[pfConfig.current_user!];\n pfConfig.current_user = null;\n writePlatformConfig(pfConfig);\n logger.success(\"Successfully logged out from Tailor Platform.\");\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { listCommand } from \"./list\";\nimport { tokenCommand } from \"./token\";\n\nexport const machineuserCommand = defineCommand({\n name: \"machineuser\",\n description: \"Manage machine users in your Tailor Platform application.\",\n subCommands: {\n list: listCommand,\n token: tokenCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\n\nexport const oauth2clientCommand = defineCommand({\n name: \"oauth2client\",\n description: \"Manage OAuth2 clients in your Tailor Platform application.\",\n subCommands: {\n get: getCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import open from \"open\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, withCommonArgs } from \"./args\";\nimport { loadConfig } from \"./config-loader\";\nimport { loadWorkspaceId } from \"./context\";\nimport { logger } from \"./utils/logger\";\n\nconst consoleBaseUrl = \"https://console.tailor.tech\";\n\nexport const openCommand = defineCommand({\n name: \"open\",\n description: \"Open Tailor Platform Console.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n }),\n run: withCommonArgs(async (args) => {\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n const { config } = await loadConfig(args.config);\n const applicationName = config.name;\n const consolePath = `/workspaces/${workspaceId}/applications/${encodeURIComponent(applicationName)}/overview`;\n const consoleUrl = new URL(consolePath, consoleBaseUrl).toString();\n\n logger.info(\"Opening Tailor Platform Console...\");\n\n try {\n await open(consoleUrl);\n logger.out(`Console URL: ${consoleUrl}`);\n logger.out(`Workspace ID: ${workspaceId}`);\n logger.out(`Application Name: ${applicationName}`);\n } catch {\n logger.warn(\n `Failed to open browser automatically. Please open this URL manually:\\n${consoleUrl}`,\n );\n }\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { fetchLatestToken, readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport type { ProfileInfo } from \".\";\n\nexport const createCommand = defineCommand({\n name: \"create\",\n description: \"Create a new profile.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Profile name\",\n }),\n user: arg(z.string(), {\n alias: \"u\",\n description: \"User email\",\n }),\n \"workspace-id\": arg(z.string(), {\n alias: \"w\",\n description: \"Workspace ID\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if profile already exists\n if (config.profiles[args.name]) {\n throw new Error(`Profile \"${args.name}\" already exists.`);\n }\n\n // Check if user exists\n const token = await fetchLatestToken(config, args.user);\n\n // Check if workspace exists\n const client = await initOperatorClient(token);\n const workspaces = await fetchAll(async (pageToken) => {\n const { workspaces, nextPageToken } = await client.listWorkspaces({\n pageToken,\n });\n return [workspaces, nextPageToken];\n });\n\n const workspace = workspaces.find((ws) => ws.id === args[\"workspace-id\"]);\n if (!workspace) {\n throw new Error(`Workspace \"${args[\"workspace-id\"]}\" not found.`);\n }\n\n // Create new profile\n config.profiles[args.name] = {\n user: args.user,\n workspace_id: args[\"workspace-id\"],\n };\n writePlatformConfig(config);\n\n if (!args.json) {\n logger.success(`Profile \"${args.name}\" created successfully.`);\n }\n\n // Show profile info\n const profileInfo: ProfileInfo = {\n name: args.name,\n user: args.user,\n workspaceId: args[\"workspace-id\"],\n };\n logger.out(profileInfo);\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const deleteCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a profile.\",\n args: z.object({\n ...commonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Profile name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if profile exists\n if (!config.profiles[args.name]) {\n throw new Error(`Profile \"${args.name}\" not found.`);\n }\n\n // Delete profile\n delete config.profiles[args.name];\n writePlatformConfig(config);\n\n logger.success(`Profile \"${args.name}\" deleted successfully.`);\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport type { ProfileInfo } from \".\";\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all profiles.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n }),\n run: withCommonArgs(async () => {\n const config = readPlatformConfig();\n\n const profiles = Object.entries(config.profiles);\n if (profiles.length === 0) {\n logger.info(ml`\n No profiles found.\n Please create a profile first using 'tailor-sdk profile create' command.\n `);\n return;\n }\n\n const profileInfos: ProfileInfo[] = profiles.map(([name, profile]) => ({\n name,\n user: profile!.user,\n workspaceId: profile!.workspace_id,\n }));\n logger.out(profileInfos);\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { fetchLatestToken, readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport type { ProfileInfo } from \".\";\n\nexport const updateCommand = defineCommand({\n name: \"update\",\n description: \"Update profile properties.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Profile name\",\n }),\n user: arg(z.string().optional(), {\n alias: \"u\",\n description: \"New user email\",\n }),\n \"workspace-id\": arg(z.string().optional(), {\n alias: \"w\",\n description: \"New workspace ID\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if profile exists\n if (!config.profiles[args.name]) {\n throw new Error(`Profile \"${args.name}\" not found.`);\n }\n\n // Check if at least one property is provided\n if (!args.user && !args[\"workspace-id\"]) {\n throw new Error(\"Please provide at least one property to update.\");\n }\n\n const profile = config.profiles[args.name]!;\n const oldUser = profile.user;\n const newUser = args.user || oldUser;\n const oldWorkspaceId = profile.workspace_id;\n const newWorkspaceId = args[\"workspace-id\"] || oldWorkspaceId;\n\n // Check if user exists\n const token = await fetchLatestToken(config, newUser);\n\n // Check if workspace exists\n const client = await initOperatorClient(token);\n const workspaces = await fetchAll(async (pageToken) => {\n const { workspaces, nextPageToken } = await client.listWorkspaces({\n pageToken,\n });\n return [workspaces, nextPageToken];\n });\n const workspace = workspaces.find((ws) => ws.id === newWorkspaceId);\n if (!workspace) {\n throw new Error(`Workspace \"${newWorkspaceId}\" not found.`);\n }\n\n // Update properties\n profile.user = newUser;\n profile.workspace_id = newWorkspaceId;\n writePlatformConfig(config);\n if (!args.json) {\n logger.success(`Profile \"${args.name}\" updated successfully`);\n }\n\n // Show profile info\n const profileInfo: ProfileInfo = {\n name: args.name,\n user: newUser,\n workspaceId: newWorkspaceId,\n };\n logger.out(profileInfo);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { listCommand } from \"./list\";\nimport { updateCommand } from \"./update\";\n\nexport interface ProfileInfo {\n name: string;\n user: string;\n workspaceId: string;\n}\n\nexport const profileCommand = defineCommand({\n name: \"profile\",\n description: \"Manage workspace profiles (user + workspace combinations).\",\n subCommands: {\n create: createCommand,\n delete: deleteCommand,\n list: listCommand,\n update: updateCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { arg } from \"politty\";\nimport { z } from \"zod\";\n\n/**\n * Arguments for specify secret key\n */\nexport const vaultArgs = {\n \"vault-name\": arg(z.string(), {\n alias: \"V\",\n description: \"Vault name\",\n }),\n};\n\n/**\n * Arguments for specify secret key\n */\nexport const secretIdentifyArgs = {\n ...vaultArgs,\n name: arg(z.string(), {\n alias: \"n\",\n description: \"Secret name\",\n }),\n};\n\n/**\n * Arguments for specify secret key\n */\nexport const secretValueArgs = {\n ...secretIdentifyArgs,\n value: arg(z.string(), {\n alias: \"v\",\n description: \"Secret value\",\n }),\n};\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { secretValueArgs } from \"./args\";\n\nexport const createSecretCommand = defineCommand({\n name: \"create\",\n description: \"Create a secret in a vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...secretValueArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n try {\n await client.createSecretManagerSecret({\n workspaceId,\n secretmanagerVaultName: args[\"vault-name\"],\n secretmanagerSecretName: args.name,\n secretmanagerSecretValue: args.value,\n });\n } catch (error) {\n if (error instanceof ConnectError) {\n if (error.code === Code.NotFound) {\n throw new Error(`Vault \"${args[\"vault-name\"]}\" not found.`);\n }\n if (error.code === Code.AlreadyExists) {\n throw new Error(`Secret \"${args.name}\" already exists.`);\n }\n }\n throw error;\n }\n\n logger.success(`Secret: ${args.name} created in vault: ${args[\"vault-name\"]}`);\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, confirmationArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { secretIdentifyArgs } from \"./args\";\n\nexport const deleteSecretCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a secret in a vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...secretIdentifyArgs,\n ...confirmationArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n if (!args.yes) {\n const confirmation = await logger.prompt(\n `Enter the secret name to confirm deletion (\"${args.name}\"): `,\n { type: \"text\" },\n );\n\n if (confirmation !== args.name) {\n logger.info(\"Secret deletion cancelled.\");\n return;\n }\n }\n\n try {\n await client.deleteSecretManagerSecret({\n workspaceId,\n secretmanagerVaultName: args[\"vault-name\"],\n secretmanagerSecretName: args.name,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Secret \"${args.name}\" not found in vault \"${args[\"vault-name\"]}\".`);\n }\n throw error;\n }\n\n logger.success(`Secret: ${args.name} deleted from vault: ${args[\"vault-name\"]}`);\n }),\n});\n","import { timestampDate } from \"@bufbuild/protobuf/wkt\";\nimport { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { vaultArgs } from \"./args\";\nimport type { SecretManagerSecret } from \"@tailor-proto/tailor/v1/secret_manager_resource_pb\";\n\nexport interface SecretListOptions {\n workspaceId?: string;\n profile?: string;\n vaultName: string;\n}\n\nexport interface SecretInfo {\n name: string;\n createdAt: Date | null;\n updatedAt: Date | null;\n}\n\nfunction secretInfo(secret: SecretManagerSecret): SecretInfo {\n return {\n name: secret.name,\n createdAt: secret.createTime ? timestampDate(secret.createTime) : null,\n updatedAt: secret.updateTime ? timestampDate(secret.updateTime) : null,\n };\n}\n\n/**\n * List secrets in a Secret Manager vault.\n * @param options - Secret listing options\n * @returns List of secrets\n */\nasync function secretList(options: SecretListOptions): Promise<SecretInfo[]> {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: options.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options.workspaceId,\n profile: options.profile,\n });\n\n const secrets = await fetchAll(async (pageToken) => {\n const { secrets, nextPageToken } = await client.listSecretManagerSecrets({\n workspaceId,\n secretmanagerVaultName: options.vaultName,\n pageToken,\n });\n return [secrets, nextPageToken];\n });\n\n return secrets.map(secretInfo);\n}\n\nexport const listSecretCommand = defineCommand({\n name: \"list\",\n description: \"List all secrets in a vault.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n ...vaultArgs,\n }),\n run: withCommonArgs(async (args) => {\n try {\n const secrets = await secretList({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n vaultName: args[\"vault-name\"],\n });\n logger.out(secrets);\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Vault \"${args[\"vault-name\"]}\" not found.`);\n }\n throw error;\n }\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { secretValueArgs } from \"./args\";\n\nexport const updateSecretCommand = defineCommand({\n name: \"update\",\n description: \"Update a secret in a vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...secretValueArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n try {\n await client.updateSecretManagerSecret({\n workspaceId,\n secretmanagerVaultName: args[\"vault-name\"],\n secretmanagerSecretName: args.name,\n secretmanagerSecretValue: args.value,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Secret \"${args.name}\" not found in vault \"${args[\"vault-name\"]}\".`);\n }\n throw error;\n }\n\n logger.success(`Secret: ${args.name} updated in vault: ${args[\"vault-name\"]}`);\n }),\n});\n","import { arg } from \"politty\";\nimport { z } from \"zod\";\n\ntype ArgsShape = Record<string, z.ZodType>;\n\nexport const nameArgs = {\n name: arg(z.string(), {\n positional: true,\n description: \"Vault name\",\n }),\n} satisfies ArgsShape;\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs, workspaceArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport { nameArgs } from \"./args\";\n\nexport const createCommand = defineCommand({\n name: \"create\",\n description: \"Create a new Secret Manager vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...nameArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n try {\n await client.createSecretManagerVault({\n workspaceId,\n secretmanagerVaultName: args.name,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.AlreadyExists) {\n throw new Error(`Vault \"${args.name}\" already exists.`);\n }\n throw error;\n }\n\n logger.success(`Vault: ${args.name} created`);\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, confirmationArgs, withCommonArgs, workspaceArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport { nameArgs } from \"./args\";\n\nexport const deleteCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a Secret Manager vault.\",\n args: z.object({\n ...commonArgs,\n ...workspaceArgs,\n ...nameArgs,\n ...confirmationArgs,\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n if (!args.yes) {\n const confirmation = await logger.prompt(\n `Enter the vault name to confirm deletion (\"${args.name}\"): `,\n { type: \"text\" },\n );\n if (confirmation !== args.name) {\n logger.info(\"Vault deletion cancelled.\");\n return;\n }\n }\n\n try {\n await client.deleteSecretManagerVault({\n workspaceId,\n secretmanagerVaultName: args.name,\n });\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(`Vault \"${args.name}\" not found.`);\n }\n throw error;\n }\n\n logger.success(`Vault: ${args.name} deleted`);\n }),\n});\n","import { timestampDate } from \"@bufbuild/protobuf/wkt\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../../args\";\nimport { fetchAll, initOperatorClient } from \"../../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport type { SecretManagerVault } from \"@tailor-proto/tailor/v1/secret_manager_resource_pb\";\n\nexport interface VaultListOptions {\n workspaceId?: string;\n profile?: string;\n}\n\nexport interface VaultInfo {\n name: string;\n createdAt: Date | null;\n updatedAt: Date | null;\n}\n\nfunction vaultInfo(vault: SecretManagerVault): VaultInfo {\n return {\n name: vault.name,\n createdAt: vault.createTime ? timestampDate(vault.createTime) : null,\n updatedAt: vault.updateTime ? timestampDate(vault.updateTime) : null,\n };\n}\n\n/**\n * List Secret Manager vaults in the workspace.\n * @param options - Vault listing options\n * @returns List of vaults\n */\nasync function vaultList(options?: VaultListOptions): Promise<VaultInfo[]> {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: options?.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options?.workspaceId,\n profile: options?.profile,\n });\n\n const vaults = await fetchAll(async (pageToken) => {\n const { vaults, nextPageToken } = await client.listSecretManagerVaults({\n workspaceId,\n pageToken,\n });\n return [vaults, nextPageToken];\n });\n\n return vaults.map(vaultInfo);\n}\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all Secret Manager vaults in the workspace.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n }),\n run: withCommonArgs(async (args) => {\n const vaults = await vaultList({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n logger.out(vaults);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { listCommand } from \"./list\";\n\nexport const vaultCommand = defineCommand({\n name: \"vault\",\n description: \"Manage Secret Manager vaults.\",\n subCommands: {\n create: createCommand,\n delete: deleteCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { createSecretCommand } from \"./create\";\nimport { deleteSecretCommand } from \"./delete\";\nimport { listSecretCommand } from \"./list\";\nimport { updateSecretCommand } from \"./update\";\nimport { vaultCommand } from \"./vault\";\n\nexport const secretCommand = defineCommand({\n name: \"secret\",\n description: \"Manage Secret Manager vaults and secrets.\",\n subCommands: {\n create: createSecretCommand,\n delete: deleteSecretCommand,\n list: listSecretCommand,\n update: updateSecretCommand,\n vault: vaultCommand,\n },\n async run() {\n await runCommand(vaultCommand, []);\n },\n});\n","import { setTimeout } from \"node:timers/promises\";\n\n/**\n * Create a simple progress reporter that writes updates to stderr.\n * @param label - Label to prefix progress output\n * @param total - Total number of steps\n * @returns Progress helpers\n */\nexport function createProgress(label: string, total: number) {\n let current = 0;\n\n const update = () => {\n current += 1;\n const percent = Math.round((current / total) * 100);\n process.stderr.write(`\\r${label} ${current}/${total} (${percent}%)`);\n };\n\n const finish = () => {\n process.stderr.write(\"\\n\");\n };\n\n return { update, finish };\n}\n\n/**\n * Wrap a promise with a timeout, rejecting if the timeout elapses first.\n * @template T\n * @param p - Promise to await\n * @param ms - Timeout in milliseconds\n * @param message - Error message on timeout\n * @returns Result of the original promise if it completes in time\n */\nexport async function withTimeout<T>(p: Promise<T>, ms: number, message: string): Promise<T> {\n return await Promise.race([\n p,\n setTimeout(ms).then(() => {\n throw new Error(message);\n }),\n ]);\n}\n","import * as fs from \"fs\";\nimport { Code, ConnectError } from \"@connectrpc/connect\";\nimport { lookup as mimeLookup } from \"mime-types\";\nimport pLimit from \"p-limit\";\nimport * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { withCommonArgs, commonArgs, jsonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient, type OperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\nimport { createProgress, withTimeout } from \"../utils/progress\";\nimport type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport type { UploadFileRequestSchema } from \"@tailor-proto/tailor/v1/staticwebsite_pb\";\n\nconst CHUNK_SIZE = 64 * 1024; // 64KB\nconst IGNORED_FILES = new Set([\".DS_Store\", \"thumbs.db\", \"desktop.ini\"]);\nfunction shouldIgnoreFile(filePath: string) {\n const fileName = path.basename(filePath).toLowerCase();\n return IGNORED_FILES.has(fileName);\n}\n\nexport type DeployResult = {\n url: string;\n skippedFiles: string[];\n};\n\n/**\n * Deploy a static website by creating a deployment, uploading files, and publishing it.\n * @param client - Operator client instance\n * @param workspaceId - Workspace ID\n * @param name - Static website name\n * @param distDir - Directory containing static site files\n * @param showProgress - Whether to show upload progress\n * @returns Deployment result with URL and skipped files\n */\nexport async function deployStaticWebsite(\n client: OperatorClient,\n workspaceId: string,\n name: string,\n distDir: string,\n showProgress: boolean = true,\n): Promise<DeployResult> {\n const { deploymentId } = await client.createDeployment({\n workspaceId,\n name,\n });\n\n if (!deploymentId) {\n throw new Error(\"createDeployment returned empty deploymentId\");\n }\n\n const skippedFiles = await uploadDirectory(\n client,\n workspaceId,\n deploymentId,\n distDir,\n showProgress,\n );\n\n const { url } = await client.publishDeployment({\n workspaceId,\n deploymentId,\n });\n\n if (!url) {\n throw new Error(\"publishDeployment returned empty url\");\n }\n\n return { url, skippedFiles };\n}\n\nasync function uploadDirectory(\n client: OperatorClient,\n workspaceId: string,\n deploymentId: string,\n rootDir: string,\n showProgress: boolean,\n): Promise<string[]> {\n const files = await collectFiles(rootDir);\n if (files.length === 0) {\n logger.warn(`No files found under ${rootDir}`);\n return [];\n }\n\n const concurrency = 5;\n const limit = pLimit(concurrency);\n\n const total = files.length;\n const progress = showProgress ? createProgress(\"Uploading files\", total) : undefined;\n const skippedFiles: string[] = [];\n\n await Promise.all(\n files.map((relativePath) =>\n limit(async () => {\n await uploadSingleFile(\n client,\n workspaceId,\n deploymentId,\n rootDir,\n relativePath,\n skippedFiles,\n );\n if (progress) {\n progress.update();\n }\n }),\n ),\n );\n\n if (progress) {\n progress.finish();\n }\n\n return skippedFiles;\n}\n\n/**\n * Recursively collect all deployable files under the given directory.\n * @param rootDir - Root directory to scan\n * @param currentDir - Current relative directory (for recursion)\n * @returns List of file paths relative to rootDir\n */\nasync function collectFiles(rootDir: string, currentDir = \"\"): Promise<string[]> {\n const dirPath = path.join(rootDir, currentDir);\n\n const entries = await fs.promises.readdir(dirPath, {\n withFileTypes: true,\n });\n const files: string[] = [];\n\n for (const entry of entries) {\n const rel = path.join(currentDir, entry.name);\n if (entry.isDirectory()) {\n const sub = await collectFiles(rootDir, rel);\n files.push(...sub);\n } else if (entry.isFile() && !entry.isSymbolicLink() && !shouldIgnoreFile(rel)) {\n files.push(rel);\n }\n }\n\n return files;\n}\n\nasync function uploadSingleFile(\n client: OperatorClient,\n workspaceId: string,\n deploymentId: string,\n rootDir: string,\n filePath: string,\n skippedFiles: string[],\n): Promise<void> {\n const absPath = path.join(rootDir, filePath);\n\n const mime = mimeLookup(filePath);\n\n if (!mime) {\n skippedFiles.push(`${filePath} (unsupported content type; no MIME mapping found)`);\n return;\n }\n\n const contentType = mime;\n\n const readStream = fs.createReadStream(absPath, {\n highWaterMark: CHUNK_SIZE,\n });\n\n async function* requestStream(): AsyncIterable<MessageInitShape<typeof UploadFileRequestSchema>> {\n yield {\n payload: {\n case: \"initialMetadata\",\n value: {\n workspaceId,\n deploymentId,\n filePath,\n contentType,\n },\n },\n };\n for await (const chunk of readStream) {\n yield {\n payload: {\n case: \"chunkData\",\n value: chunk as Buffer,\n },\n };\n }\n }\n\n async function uploadWithLogging() {\n try {\n await client.uploadFile(requestStream());\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.InvalidArgument) {\n skippedFiles.push(`${filePath} (server rejected file as invalid: ${error.message})`);\n return;\n }\n // For non-validation errors, fail the deployment as before.\n throw error;\n }\n }\n\n await withTimeout(\n uploadWithLogging(),\n // 2 minutes per file\n 2 * 60_000,\n `Upload timed out for \"${filePath}\"`,\n );\n}\n\n/**\n * Log skipped files after a deployment, including reasons for skipping.\n * @param skippedFiles - List of skipped file descriptions\n */\nexport function logSkippedFiles(skippedFiles: string[]) {\n if (skippedFiles.length === 0) {\n return;\n }\n logger.warn(\n \"Deployment completed, but some files failed to upload. These files may have unsupported content types or other validation issues. Please review the list below:\",\n );\n for (const file of skippedFiles) {\n logger.log(` - ${file}`);\n }\n}\n\nexport const deployCommand = defineCommand({\n name: \"deploy\",\n description: \"Deploy a static website from a local build directory.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n name: arg(z.string(), {\n alias: \"n\",\n description: \"Static website name\",\n }),\n dir: arg(z.string(), {\n alias: \"d\",\n description: \"Path to the static website files\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n logger.info(`Deploying static website \"${args.name}\" from directory: ${args.dir}`);\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n\n const name = args.name;\n const dir = path.resolve(process.cwd(), args.dir);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {\n throw new Error(`Directory not found or not a directory: ${dir}`);\n }\n\n const { url, skippedFiles } = await withTimeout(\n deployStaticWebsite(client, workspaceId, name, dir, !args.json),\n // 10 minutes\n 10 * 60_000,\n \"Deployment timed out after 10 minutes.\",\n );\n\n if (args.json) {\n logger.out({ name, workspaceId, url, skippedFiles });\n } else {\n logger.success(`Static website \"${name}\" deployed successfully. URL: ${url}`);\n logSkippedFiles(skippedFiles);\n }\n }),\n});\n","import { Code, ConnectError } from \"@connectrpc/connect\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const getCommand = defineCommand({\n name: \"get\",\n description: \"Get details of a specific static website.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Static website name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n const notFoundErrorMessage = `Static website \"${args.name}\" not found.`;\n\n try {\n const { staticwebsite } = await client.getStaticWebsite({\n workspaceId,\n name: args.name,\n });\n\n if (!staticwebsite) {\n throw new Error(notFoundErrorMessage);\n }\n\n const info = {\n workspaceId,\n name: staticwebsite.name,\n description: staticwebsite.description,\n url: staticwebsite.url,\n allowedIpAddresses: args.json\n ? staticwebsite.allowedIpAddresses\n : staticwebsite.allowedIpAddresses.join(\"\\n\"),\n };\n\n logger.out(info);\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n throw new Error(notFoundErrorMessage);\n }\n throw error;\n }\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs, workspaceArgs } from \"../args\";\nimport { fetchAll, initOperatorClient } from \"../client\";\nimport { loadAccessToken, loadWorkspaceId } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport interface StaticWebsiteInfo {\n workspaceId: string;\n name: string;\n description: string;\n url: string;\n allowedIpAddresses: string[];\n}\n\ntype StaticWebsiteListOptions = {\n workspaceId?: string;\n profile?: string;\n};\n\n/**\n * List static websites in the workspace.\n * @param options - Static website listing options\n * @returns List of static websites\n */\nasync function listStaticWebsites(\n options?: StaticWebsiteListOptions,\n): Promise<StaticWebsiteInfo[]> {\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: options?.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options?.workspaceId,\n profile: options?.profile,\n });\n\n const websites = await fetchAll(async (pageToken) => {\n const { staticwebsites, nextPageToken } = await client.listStaticWebsites({\n workspaceId,\n pageToken,\n });\n return [staticwebsites, nextPageToken];\n });\n\n return websites.map((site) => ({\n workspaceId,\n name: site.name,\n description: site.description,\n url: site.url ?? \"\",\n allowedIpAddresses: site.allowedIpAddresses,\n }));\n}\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all static websites in a workspace.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n ...workspaceArgs,\n }),\n run: withCommonArgs(async (args) => {\n const websites = await listStaticWebsites({\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n\n const formatted = args.json\n ? websites\n : websites.map(({ allowedIpAddresses, ...rest }) => {\n if (allowedIpAddresses.length === 0) {\n return {\n ...rest,\n allowedIpAddresses: \"No allowed IP addresses\",\n };\n }\n\n const count = allowedIpAddresses.length;\n const label = count === 1 ? \"1 IP address\" : `${count} IP addresses`;\n\n return {\n ...rest,\n allowedIpAddresses: label,\n };\n });\n\n logger.out(formatted);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { deployCommand } from \"./deploy\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\n\nexport const staticwebsiteCommand = defineCommand({\n name: \"staticwebsite\",\n description: \"Manage static websites in your workspace.\",\n subCommands: {\n deploy: deployCommand,\n get: getCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"pathe\";\n\ninterface CliPackageJson {\n bin?: Record<string, string>;\n}\n\ntype ResolveCliBinOptions = {\n packageName: string;\n binName: string;\n};\n\n/**\n * Resolve a CLI binary path from the SDK's dependencies.\n * @param options - Resolution options for locating the CLI binary.\n * @returns Absolute path to the CLI binary entry.\n */\nexport function resolveCliBinPath(options: ResolveCliBinOptions): string {\n const { packageName, binName } = options;\n\n // Resolve from SDK's dependencies instead of user's project\n const requireFromSdk = createRequire(import.meta.url);\n let pkgJsonPath: string;\n try {\n pkgJsonPath = requireFromSdk.resolve(`${packageName}/package.json`);\n } catch {\n throw new Error(`Failed to resolve \\`${packageName}\\`.`);\n }\n\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\")) as CliPackageJson;\n const binRelativePath = pkgJson.bin?.[binName];\n if (!binRelativePath) {\n throw new Error(`\\`${packageName}\\` does not expose a \\`${binName}\\` binary entry.`);\n }\n\n return path.resolve(path.dirname(pkgJsonPath), binRelativePath);\n}\n","import * as fs from \"node:fs\";\nimport { Code, ConnectError } from \"@connectrpc/connect\";\nimport * as path from \"pathe\";\nimport { fetchAll } from \"../../client\";\nimport { logger } from \"../../utils/logger\";\nimport type {\n TblsColumn,\n TblsConstraint,\n TblsEnum,\n TblsRelation,\n TblsSchema,\n TblsTable,\n} from \"./types\";\nimport type { OperatorClient } from \"../../client\";\nimport type {\n TailorDBType as TailorDBProtoType,\n TailorDBType_FieldConfig,\n} from \"@tailor-proto/tailor/v1/tailordb_resource_pb\";\n\nexport interface TailorDBSchemaOptions {\n workspaceId: string;\n namespace: string;\n client: OperatorClient;\n}\n\n/**\n * Convert TailorDB field config to tbls column definition.\n * @param fieldName - Field name\n * @param fieldConfig - TailorDB field configuration\n * @returns tbls column definition\n */\nexport function toTblsColumn(fieldName: string, fieldConfig: TailorDBType_FieldConfig): TblsColumn {\n const baseType = fieldConfig.type || \"string\";\n const type = fieldConfig.array ? `${baseType}[]` : baseType;\n\n return {\n name: fieldName,\n type,\n nullable: !fieldConfig.required,\n comment: fieldConfig.description ?? \"\",\n };\n}\n\n/**\n * Build tbls schema JSON from TailorDB types.\n * @param types - TailorDB types fetched from platform\n * @param namespace - TailorDB namespace\n * @returns tbls-compatible schema representation\n */\nexport function buildTblsSchema(types: TailorDBProtoType[], namespace: string): TblsSchema {\n const tables: TblsTable[] = [];\n const relations: TblsRelation[] = [];\n const referencedByTable: Record<string, Set<string>> = {};\n const constraintsByTable: Record<string, TblsConstraint[]> = {};\n const enumsMap: Map<string, Set<string>> = new Map();\n\n for (const type of types) {\n const tableName = type.name;\n const schema = type.schema;\n\n const columns: TblsColumn[] = [];\n const tableConstraints: TblsConstraint[] = [];\n\n // Implicit primary key column\n columns.push({\n name: \"id\",\n type: \"uuid\",\n nullable: false,\n comment: \"\",\n });\n\n tableConstraints.push({\n name: `pk_${tableName}`,\n type: \"PRIMARY KEY\",\n def: \"\",\n table: tableName,\n columns: [\"id\"],\n });\n\n if (schema) {\n // Fields -> columns\n for (const [fieldName, fieldConfig] of Object.entries(schema.fields ?? {})) {\n columns.push(toTblsColumn(fieldName, fieldConfig));\n\n // Collect enum values\n if (fieldConfig.type === \"enum\" && fieldConfig.allowedValues.length > 0) {\n const enumName = `${tableName}_${fieldName}`;\n let values = enumsMap.get(enumName);\n if (!values) {\n values = new Set<string>();\n enumsMap.set(enumName, values);\n }\n for (const value of fieldConfig.allowedValues) {\n values.add(value.value);\n }\n }\n\n // Foreign key -> relation + constraint\n if (fieldConfig.foreignKey && fieldConfig.foreignKeyType) {\n const foreignTable = fieldConfig.foreignKeyType;\n const foreignColumn = fieldConfig.foreignKeyField || \"id\";\n\n // Cardinality:\n // - child side: exactly_one if non-nullable, zero_or_one if nullable FK\n // - parent side: zero_or_more (a parent can have many children)\n const childCardinality = fieldConfig.required ? \"exactly_one\" : \"zero_or_one\";\n const parentCardinality = \"zero_or_more\";\n\n // tbls RelationJSON:\n // - table/columns: child side (FK owner)\n // - parent_table/parent_columns: referenced side\n relations.push({\n table: tableName,\n columns: [fieldName],\n parent_table: foreignTable,\n parent_columns: [foreignColumn],\n cardinality: childCardinality,\n parent_cardinality: parentCardinality,\n def: \"\",\n });\n\n tableConstraints.push({\n name: `fk_${tableName}_${fieldName}`,\n type: \"FOREIGN KEY\",\n def: \"\",\n table: tableName,\n columns: [fieldName],\n referenced_table: foreignTable,\n referenced_columns: [foreignColumn],\n });\n\n if (!referencedByTable[tableName]) {\n referencedByTable[tableName] = new Set<string>();\n }\n referencedByTable[tableName].add(foreignTable);\n }\n }\n }\n\n constraintsByTable[tableName] = tableConstraints;\n\n tables.push({\n name: tableName,\n type: \"table\",\n comment: schema?.description ?? \"\",\n columns,\n indexes: [],\n constraints: constraintsByTable[tableName] ?? [],\n triggers: [],\n def: \"\",\n referenced_tables: [],\n });\n }\n\n // Populate referenced_tables from collected relations\n for (const table of tables) {\n const referenced = referencedByTable[table.name];\n table.referenced_tables = referenced ? Array.from(referenced) : [];\n }\n\n const enums: TblsEnum[] = [];\n for (const [name, values] of enumsMap.entries()) {\n enums.push({\n name,\n values: Array.from(values),\n });\n }\n\n return {\n name: namespace,\n tables,\n relations,\n enums,\n };\n}\n\n/**\n * Export apply-applied TailorDB schema for a namespace as tbls-compatible JSON.\n * @param options - Export options\n * @returns tbls schema representation\n */\nasync function exportTailorDBSchema(options: TailorDBSchemaOptions): Promise<TblsSchema> {\n const { client, workspaceId, namespace } = options;\n\n const types = await fetchAll(async (pageToken) => {\n try {\n const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({\n workspaceId,\n namespaceName: namespace,\n pageToken,\n });\n return [tailordbTypes, nextPageToken];\n } catch (error) {\n if (error instanceof ConnectError && error.code === Code.NotFound) {\n return [[], \"\"];\n }\n throw error;\n }\n });\n\n if (types.length === 0) {\n logger.warn(`No TailorDB types found in namespace \"${namespace}\". Returning empty schema.`);\n }\n\n return buildTblsSchema(types, namespace);\n}\n\nexport interface WriteSchemaOptions extends TailorDBSchemaOptions {\n outputPath: string;\n}\n\n/**\n * Writes the TailorDB schema to a file in tbls-compatible JSON format.\n * @param options - The options for writing the schema file.\n */\nexport async function writeTblsSchemaToFile(options: WriteSchemaOptions): Promise<void> {\n const schema = await exportTailorDBSchema(options);\n const json = JSON.stringify(schema, null, 2);\n\n fs.mkdirSync(path.dirname(options.outputPath), { recursive: true });\n fs.writeFileSync(options.outputPath, json, \"utf8\");\n\n const relativePath = path.relative(process.cwd(), options.outputPath);\n logger.success(`Wrote ERD schema to ${relativePath}`);\n}\n","import { initOperatorClient } from \"../../client\";\nimport { loadConfig } from \"../../config-loader\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logBetaWarning } from \"../../utils/beta\";\nimport type { OperatorClient } from \"../../client\";\nimport type { AppConfig } from \"@/parser/app-config\";\n\nexport interface ErdCommandContext {\n client: OperatorClient;\n workspaceId: string;\n config: AppConfig;\n}\n\ntype ErdCommandOptions = {\n profile?: string;\n workspaceId?: string;\n config?: string;\n};\n\n/**\n * Initialize shared ERD command context.\n * @param args - CLI arguments.\n * @returns Initialized context.\n */\nexport async function initErdContext(args: ErdCommandOptions): Promise<ErdCommandContext> {\n logBetaWarning(\"tailordb erd\");\n const accessToken = await loadAccessToken({\n useProfile: true,\n profile: args.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: args.workspaceId,\n profile: args.profile,\n });\n const { config } = await loadConfig(args.config);\n\n return { client, workspaceId, config };\n}\n","import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { logger } from \"../../utils/logger\";\nimport { resolveCliBinPath } from \"../../utils/resolve-cli-bin\";\nimport { writeTblsSchemaToFile } from \"./schema\";\nimport { initErdContext } from \"./utils\";\nimport type { TailorDBSchemaOptions } from \"./schema\";\nimport type { OperatorClient } from \"../../client\";\nimport type { AppConfig } from \"@/parser/app-config\";\n\nconst DEFAULT_ERD_BASE_DIR = \".tailor-sdk/erd\";\n\n/**\n * Resolve TailorDB config and namespace.\n * @param config - Loaded Tailor SDK config.\n * @param explicitNamespace - Namespace override.\n * @returns Resolved namespace and erdSite.\n */\nfunction resolveDbConfig(\n config: AppConfig,\n explicitNamespace?: string,\n): { namespace: string; erdSite: string | undefined } {\n const namespace = explicitNamespace ?? Object.keys(config.db ?? {})[0];\n\n if (!namespace) {\n throw new Error(\n \"No TailorDB namespaces found in config. Please define db services in tailor.config.ts or pass --namespace.\",\n );\n }\n\n const dbConfig = config.db?.[namespace];\n\n if (!dbConfig || typeof dbConfig !== \"object\" || \"external\" in dbConfig) {\n throw new Error(`TailorDB namespace \"${namespace}\" not found in config.db.`);\n }\n\n return { namespace, erdSite: dbConfig.erdSite };\n}\n\ntype ResolveNamespacesOptions = {\n requireErdSite?: boolean;\n};\n\n/**\n * Get all namespaces from config.\n * @param config - Loaded Tailor SDK config.\n * @param options - Options for filtering namespaces.\n * @returns All namespaces with optional erdSite.\n */\nfunction resolveAllNamespaces(\n config: AppConfig,\n options?: ResolveNamespacesOptions,\n): Array<{ namespace: string; erdSite: string | undefined }> {\n const results: Array<{ namespace: string; erdSite: string | undefined }> = [];\n\n for (const [namespace, dbConfig] of Object.entries(config.db ?? {})) {\n if (dbConfig && !(\"external\" in dbConfig) && !(options?.requireErdSite && !dbConfig.erdSite)) {\n results.push({ namespace, erdSite: dbConfig.erdSite });\n }\n }\n\n return results;\n}\n\n/**\n * Run the liam CLI to build an ERD static site from a schema file.\n * @param schemaPath - Path to the ERD schema JSON file\n * @param cwd - Working directory where liam will run (dist is created here)\n * @returns Resolves when the build completes successfully\n */\nasync function runLiamBuild(schemaPath: string, cwd: string): Promise<void> {\n fs.mkdirSync(cwd, { recursive: true });\n\n return await new Promise<void>((resolve, reject) => {\n let liamBinPath: string;\n try {\n liamBinPath = resolveCliBinPath({\n packageName: \"@liam-hq/cli\",\n binName: \"liam\",\n });\n } catch (error) {\n logger.error(String(error));\n reject(error);\n return;\n }\n\n const child = spawn(\n process.execPath,\n [liamBinPath, \"erd\", \"build\", \"--format\", \"tbls\", \"--input\", schemaPath],\n {\n stdio: [\"pipe\", \"ignore\", \"pipe\"],\n cwd,\n },\n );\n\n let stderrOutput = \"\";\n child.stderr?.on(\"data\", (data: Buffer) => {\n stderrOutput += data.toString();\n });\n\n child.on(\"error\", (error) => {\n logger.error(\"Failed to run `@liam-hq/cli`.\");\n reject(error);\n });\n\n child.on(\"close\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n if (stderrOutput) {\n logger.error(stderrOutput);\n }\n logger.error(\n \"liam CLI exited with a non-zero code. Ensure `@liam-hq/cli erd build --format tbls --input schema.json` works in your project.\",\n );\n reject(new Error(`liam CLI exited with code ${code ?? 1}`));\n }\n });\n });\n}\n\ntype ErdBuildOptions = TailorDBSchemaOptions & {\n outputPath: string;\n erdDir: string;\n};\n\ntype ErdBuildsOptions = {\n client: OperatorClient;\n workspaceId: string;\n config: AppConfig;\n namespace?: string;\n outputDir?: string;\n requireErdSite?: boolean;\n};\n\n/**\n * Export TailorDB schema and build ERD artifacts via liam.\n * @param options - Build options.\n */\nasync function prepareErdBuild(options: ErdBuildOptions): Promise<void> {\n await writeTblsSchemaToFile(options);\n\n await runLiamBuild(options.outputPath, options.erdDir);\n\n const distDir = path.join(options.erdDir, \"dist\");\n const relativePath = path.relative(process.cwd(), distDir);\n logger.success(`Built ERD to ${relativePath}`);\n}\n\nexport interface ErdBuildResult {\n namespace: string;\n erdSite?: string;\n schemaOutputPath: string;\n distDir: string;\n erdDir: string;\n}\n\n/**\n * Prepare ERD builds for one or more namespaces.\n * @param options - Build options.\n * @returns Build results by namespace.\n */\nexport async function prepareErdBuilds(options: ErdBuildsOptions): Promise<ErdBuildResult[]> {\n const { client, workspaceId, config } = options;\n const baseDir = options.outputDir ?? path.resolve(process.cwd(), DEFAULT_ERD_BASE_DIR);\n let targets: ErdBuildResult[];\n\n if (options.namespace) {\n const { namespace, erdSite } = resolveDbConfig(config, options.namespace);\n if (options.requireErdSite && !erdSite) {\n throw new Error(\n `No erdSite configured for namespace \"${namespace}\". ` +\n `Add erdSite: \"<static-website-name>\" to db.${namespace} in tailor.config.ts.`,\n );\n }\n const erdDir = path.join(baseDir, namespace);\n targets = [\n {\n namespace,\n erdSite,\n schemaOutputPath: path.join(erdDir, \"schema.json\"),\n distDir: path.join(erdDir, \"dist\"),\n erdDir,\n },\n ];\n } else {\n const namespaces = resolveAllNamespaces(config, { requireErdSite: options.requireErdSite });\n if (namespaces.length === 0) {\n throw new Error(\n options.requireErdSite\n ? \"No namespaces with erdSite configured found. \" +\n 'Add erdSite: \"<static-website-name>\" to db.<namespace> in tailor.config.ts.'\n : \"No TailorDB namespaces found in config. Please define db services in tailor.config.ts.\",\n );\n }\n logger.info(\n `Found ${namespaces.length} namespace(s)${options.requireErdSite ? \" with erdSite configured\" : \"\"}.`,\n );\n targets = namespaces.map(({ namespace, erdSite }) => {\n const erdDir = path.join(baseDir, namespace);\n return {\n namespace,\n erdSite,\n schemaOutputPath: path.join(erdDir, \"schema.json\"),\n distDir: path.join(erdDir, \"dist\"),\n erdDir,\n };\n });\n }\n\n await Promise.all(\n targets.map((target) =>\n prepareErdBuild({\n namespace: target.namespace,\n client,\n workspaceId,\n outputPath: target.schemaOutputPath,\n erdDir: target.erdDir,\n }),\n ),\n );\n\n return targets;\n}\n\nexport const erdExportCommand = defineCommand({\n name: \"export\",\n description: \"Export Liam ERD dist from applied TailorDB schema.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n ...jsonArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"TailorDB namespace name (optional if only one namespace is defined in config)\",\n }),\n output: arg(z.string().default(DEFAULT_ERD_BASE_DIR), {\n alias: \"o\",\n description:\n \"Output directory path for tbls-compatible ERD JSON (writes to `<outputDir>/<namespace>/schema.json`)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const { client, workspaceId, config } = await initErdContext(args);\n const outputDir = path.resolve(process.cwd(), String(args.output));\n\n const results = await prepareErdBuilds({\n client,\n workspaceId,\n config,\n namespace: args.namespace,\n outputDir,\n });\n\n logger.newline();\n if (args.json) {\n logger.out(\n results.map((result) => ({\n namespace: result.namespace,\n distDir: result.distDir,\n schemaOutputPath: result.schemaOutputPath,\n })),\n );\n } else {\n for (const result of results) {\n logger.out(`Exported ERD for namespace \"${result.namespace}\"`);\n logger.out(` - Liam ERD dist: ${result.distDir}`);\n logger.out(` - tbls schema.json: ${result.schemaOutputPath}`);\n }\n }\n }),\n});\n","import { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { deployStaticWebsite, logSkippedFiles } from \"../../staticwebsite/deploy\";\nimport { logger } from \"../../utils/logger\";\nimport { prepareErdBuilds } from \"./export\";\nimport { initErdContext } from \"./utils\";\n\nexport const erdDeployCommand = defineCommand({\n name: \"deploy\",\n description: \"Deploy ERD static website for TailorDB namespace(s).\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n ...jsonArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description:\n \"TailorDB namespace name (optional - deploys all namespaces with erdSite if omitted)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const { client, workspaceId, config } = await initErdContext(args);\n const buildResults = await prepareErdBuilds({\n client,\n workspaceId,\n config,\n namespace: args.namespace,\n requireErdSite: true,\n });\n\n const deployResults = await Promise.all(\n buildResults.map(async (result) => {\n if (!result.erdSite) {\n throw new Error(\n `No erdSite configured for namespace \"${result.namespace}\". ` +\n `Add erdSite: \"<static-website-name>\" to db.${result.namespace} in tailor.config.ts.`,\n );\n }\n\n if (!args.json) {\n logger.info(\n `Deploying ERD for namespace \"${result.namespace}\" to site \"${result.erdSite}\"...`,\n );\n }\n\n const { url, skippedFiles } = await deployStaticWebsite(\n client,\n workspaceId,\n result.erdSite,\n result.distDir,\n !args.json,\n );\n\n return {\n namespace: result.namespace,\n erdSite: result.erdSite,\n url,\n skippedFiles,\n };\n }),\n );\n logger.newline();\n\n if (args.json) {\n logger.out(deployResults);\n } else {\n for (const result of deployResults) {\n logSkippedFiles(result.skippedFiles);\n logger.newline();\n logger.success(`ERD site \"${result.erdSite}\" deployed successfully.`);\n logger.out(result.url);\n }\n }\n }),\n});\n","import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, deploymentArgs, withCommonArgs } from \"../../args\";\nimport { logger } from \"../../utils/logger\";\nimport { resolveCliBinPath } from \"../../utils/resolve-cli-bin\";\nimport { prepareErdBuilds, type ErdBuildResult } from \"./export\";\nimport { initErdContext } from \"./utils\";\n\nfunction formatServeCommand(namespace: string): string {\n return `tailor-sdk tailordb erd serve --namespace ${namespace}`;\n}\n\nasync function runServeDist(results: ErdBuildResult[]): Promise<void> {\n if (results.length === 0) {\n throw new Error(\"No ERD build results found.\");\n }\n\n const [primary, ...rest] = results;\n\n logger.info(`Serving ERD for namespace \"${primary.namespace}\".`);\n if (rest.length > 0) {\n const commands = rest.map((result) => ` - ${formatServeCommand(result.namespace)}`).join(\"\\n\");\n logger.warn(`Multiple namespaces found. To serve another namespace, run:\\n${commands}`);\n }\n\n fs.mkdirSync(primary.erdDir, { recursive: true });\n\n return await new Promise<void>((resolve, reject) => {\n let serveBinPath: string;\n try {\n serveBinPath = resolveCliBinPath({\n packageName: \"serve\",\n binName: \"serve\",\n });\n } catch (error) {\n logger.error(String(error));\n reject(error);\n return;\n }\n\n const child = spawn(process.execPath, [serveBinPath, \"dist\"], {\n stdio: \"inherit\",\n cwd: primary.erdDir,\n });\n\n child.on(\"error\", (error) => {\n logger.error(\"Failed to run `serve dist`.\");\n reject(error);\n });\n\n child.on(\"exit\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n logger.error(\n \"serve CLI exited with a non-zero code. Ensure `serve dist` works in your project.\",\n );\n reject(new Error(`serve CLI exited with code ${code ?? 1}`));\n }\n });\n });\n}\n\nexport const erdServeCommand = defineCommand({\n name: \"serve\",\n description: \"Generate and serve ERD locally (liam build + serve dist). (beta)\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"TailorDB namespace name (uses first namespace in config if not specified)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const { client, workspaceId, config } = await initErdContext(args);\n\n const results = await prepareErdBuilds({\n client,\n workspaceId,\n config,\n namespace: args.namespace,\n });\n\n await runServeDist(results);\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { erdDeployCommand } from \"./deploy\";\nimport { erdExportCommand } from \"./export\";\nimport { erdServeCommand } from \"./serve\";\n\nexport const erdCommand = defineCommand({\n name: \"erd\",\n description: \"Generate ERD artifacts for TailorDB namespaces using Liam ERD. (beta)\",\n subCommands: {\n export: erdExportCommand,\n serve: erdServeCommand,\n deploy: erdDeployCommand,\n },\n});\n","import * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { trnPrefix } from \"../../apply/services/label\";\nimport { commonArgs, confirmationArgs, deploymentArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadConfig } from \"../../config-loader\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logBetaWarning } from \"../../utils/beta\";\nimport { logger, styles } from \"../../utils/logger\";\nimport { getNamespacesWithMigrations } from \"./config\";\nimport { formatMigrationNumber, isValidMigrationNumber } from \"./snapshot\";\nimport { parseMigrationLabelNumber } from \"./types\";\n\nexport interface SetOptions {\n configPath?: string;\n number: string;\n namespace?: string;\n yes?: boolean;\n workspaceId?: string;\n profile?: string;\n}\n\n/**\n * Set migration checkpoint for a TailorDB namespace\n * @param {SetOptions} options - Command options\n */\nasync function set(options: SetOptions): Promise<void> {\n logBetaWarning(\"tailordb migration\");\n\n // 1. Validate migration number format\n const numberStr = options.number;\n\n // Accept either 4-digit format (0001) or integer (1)\n let migrationNumber: number;\n if (isValidMigrationNumber(numberStr)) {\n // 4-digit format\n migrationNumber = parseInt(numberStr, 10);\n } else {\n // Try parsing as integer\n migrationNumber = parseInt(numberStr, 10);\n if (isNaN(migrationNumber) || migrationNumber < 0) {\n throw new Error(\n `Invalid migration number format: ${numberStr}. Expected 4-digit format (e.g., 0001) or integer (e.g., 1).`,\n );\n }\n }\n\n // 2. Load configuration\n const { config } = await loadConfig(options.configPath);\n const configDir = path.dirname(config.path);\n\n // 3. Get namespaces with migrations\n const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);\n\n if (namespacesWithMigrations.length === 0) {\n throw new Error(\"No TailorDB services with migrations configuration found\");\n }\n\n // 4. Determine target namespace\n let targetNamespace: string;\n if (options.namespace) {\n if (!namespacesWithMigrations.some((ns) => ns.namespace === options.namespace)) {\n throw new Error(\n `Namespace \"${options.namespace}\" not found or does not have migrations configured`,\n );\n }\n targetNamespace = options.namespace;\n } else if (namespacesWithMigrations.length === 1) {\n targetNamespace = namespacesWithMigrations[0].namespace;\n } else {\n throw new Error(\n `Multiple TailorDB services found. Please specify namespace with --namespace flag: ${namespacesWithMigrations.map((ns) => ns.namespace).join(\", \")}`,\n );\n }\n\n // 5. Initialize client\n const accessToken = await loadAccessToken({\n useProfile: false,\n profile: options.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options.workspaceId,\n profile: options.profile,\n });\n\n // 6. Get current migration number\n const trn = `${trnPrefix(workspaceId)}:tailordb:${targetNamespace}`;\n let currentMigration: number;\n try {\n const { metadata } = await client.getMetadata({ trn });\n const label = metadata?.labels?.[\"sdk-migration\"];\n currentMigration = label ? (parseMigrationLabelNumber(label) ?? 0) : 0;\n } catch {\n currentMigration = 0;\n }\n\n // 7. Display warning and confirmation\n logger.newline();\n logger.warn(\"This operation will change the migration checkpoint.\");\n logger.log(`Namespace: ${styles.bold(targetNamespace)}`);\n logger.log(`Current migration: ${styles.bold(formatMigrationNumber(currentMigration))}`);\n logger.log(`New migration: ${styles.bold(formatMigrationNumber(migrationNumber))}`);\n logger.newline();\n\n if (migrationNumber < currentMigration) {\n logger.warn(\n `Setting migration number backwards (${formatMigrationNumber(currentMigration)} → ${formatMigrationNumber(migrationNumber)}) will cause previous migrations to be re-executed on next apply.`,\n );\n logger.newline();\n } else if (migrationNumber > currentMigration) {\n logger.warn(\n `Setting migration number forwards (${formatMigrationNumber(currentMigration)} → ${formatMigrationNumber(migrationNumber)}) will skip migrations ${formatMigrationNumber(currentMigration + 1)} to ${formatMigrationNumber(migrationNumber)}.`,\n );\n logger.newline();\n }\n\n // 8. Confirmation prompt (unless --yes flag)\n if (!options.yes) {\n const confirmation = await logger.prompt(\"Continue with migration checkpoint update?\", {\n type: \"confirm\",\n initial: false,\n });\n\n if (!confirmation) {\n logger.info(\"Operation cancelled.\");\n return;\n }\n logger.newline();\n }\n\n // 9. Update migration label\n const { metadata } = await client.getMetadata({ trn });\n const existingLabels = metadata?.labels ?? {};\n\n await client.setMetadata({\n trn,\n labels: {\n ...existingLabels,\n \"sdk-migration\": `m${formatMigrationNumber(migrationNumber)}`,\n },\n });\n\n logger.success(\n `Migration checkpoint set to ${styles.bold(formatMigrationNumber(migrationNumber))} for namespace ${styles.bold(targetNamespace)}`,\n );\n}\n\nexport const setCommand = defineCommand({\n name: \"set\",\n description: \"Set migration checkpoint to a specific number.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n ...confirmationArgs,\n number: arg(z.string(), {\n positional: true,\n description: \"Migration number to set (e.g., 0001 or 1)\",\n }),\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"Target TailorDB namespace (required if multiple namespaces exist)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n await set({\n configPath: args.config,\n number: args.number,\n namespace: args.namespace,\n yes: args.yes,\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n }),\n});\n","import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { trnPrefix } from \"../../apply/services/label\";\nimport { commonArgs, deploymentArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { loadConfig } from \"../../config-loader\";\nimport { loadAccessToken, loadWorkspaceId } from \"../../context\";\nimport { logBetaWarning } from \"../../utils/beta\";\nimport { logger, styles } from \"../../utils/logger\";\nimport { getNamespacesWithMigrations } from \"./config\";\nimport {\n getMigrationFiles,\n loadDiff,\n getMigrationFilePath,\n formatMigrationNumber,\n} from \"./snapshot\";\nimport { parseMigrationLabelNumber } from \"./types\";\n\nexport interface StatusOptions {\n configPath?: string;\n namespace?: string;\n workspaceId?: string;\n profile?: string;\n}\n\n/**\n * Show migration status for TailorDB namespaces\n * @param {StatusOptions} options - Command options\n */\nasync function status(options: StatusOptions): Promise<void> {\n logBetaWarning(\"tailordb migration\");\n\n // 1. Load configuration\n const { config } = await loadConfig(options.configPath);\n const configDir = path.dirname(config.path);\n\n // 2. Get namespaces with migrations\n const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);\n\n if (namespacesWithMigrations.length === 0) {\n throw new Error(\"No TailorDB services with migrations configuration found\");\n }\n\n // 3. Filter by namespace if specified\n const targetNamespaces = options.namespace\n ? namespacesWithMigrations.filter((ns) => ns.namespace === options.namespace)\n : namespacesWithMigrations;\n\n if (targetNamespaces.length === 0) {\n throw new Error(\n `Namespace \"${options.namespace}\" not found or does not have migrations configured`,\n );\n }\n\n // 4. Initialize client\n const accessToken = await loadAccessToken({\n useProfile: false,\n profile: options.profile,\n });\n const client = await initOperatorClient(accessToken);\n const workspaceId = loadWorkspaceId({\n workspaceId: options.workspaceId,\n profile: options.profile,\n });\n\n // 5. Display status for each namespace\n for (const { namespace, migrationsDir } of targetNamespaces) {\n // Get current migration number\n const trn = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;\n let currentMigration: number;\n try {\n const { metadata } = await client.getMetadata({ trn });\n const label = metadata?.labels?.[\"sdk-migration\"];\n currentMigration = label ? (parseMigrationLabelNumber(label) ?? 0) : 0;\n } catch {\n currentMigration = 0;\n }\n\n // Get available migrations\n const migrationFiles = getMigrationFiles(migrationsDir);\n const availableNumbers = migrationFiles\n .map((f) => f.number)\n .filter((n, i, arr) => arr.indexOf(n) === i) // deduplicate\n .sort((a, b) => a - b);\n const pendingNumbers = availableNumbers.filter((n) => n > currentMigration);\n\n // Display\n logger.newline();\n logger.info(`Namespace: ${styles.bold(namespace)}`);\n logger.log(` Current migration: ${styles.bold(formatMigrationNumber(currentMigration))}`);\n\n if (pendingNumbers.length > 0) {\n logger.log(\" Pending migrations:\");\n for (const num of pendingNumbers) {\n const diffPath = getMigrationFilePath(migrationsDir, num, \"diff\");\n let description: string | undefined;\n\n if (fs.existsSync(diffPath)) {\n try {\n const diff = loadDiff(diffPath);\n description = diff.description;\n } catch {\n // Ignore errors loading diff\n }\n }\n\n if (description) {\n logger.log(` - ${formatMigrationNumber(num)}: ${description}`);\n } else {\n logger.log(` - ${formatMigrationNumber(num)}`);\n }\n }\n } else {\n logger.log(\" Pending migrations: (none)\");\n }\n }\n\n logger.newline();\n}\n\nexport const statusCommand = defineCommand({\n name: \"status\",\n description:\n \"Show the current migration status for TailorDB namespaces, including applied and pending migrations.\",\n args: z.object({\n ...commonArgs,\n ...deploymentArgs,\n namespace: arg(z.string().optional(), {\n alias: \"n\",\n description: \"Target TailorDB namespace (shows all namespaces if not specified)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n await status({\n configPath: args.config,\n namespace: args.namespace,\n workspaceId: args[\"workspace-id\"],\n profile: args.profile,\n });\n }),\n});\n","/**\n * TailorDB migration command\n *\n * Subcommands:\n * - generate: Generate migration files from schema differences\n * - set: Set migration checkpoint to a specific number\n * - status: Show migration status for TailorDB namespaces\n */\n\nimport { defineCommand } from \"politty\";\nimport { generateCommand } from \"./generate\";\nimport { setCommand } from \"./set\";\nimport { statusCommand } from \"./status\";\n\nexport const migrationCommand = defineCommand({\n name: \"migration\",\n description: \"Manage TailorDB schema migrations.\",\n subCommands: {\n generate: generateCommand,\n set: setCommand,\n status: statusCommand,\n },\n});\n\nexport { generateCommand } from \"./generate\";\nexport type { GenerateOptions } from \"./generate\";\nexport { setCommand } from \"./set\";\nexport type { SetOptions } from \"./set\";\nexport { statusCommand } from \"./status\";\nexport type { StatusOptions } from \"./status\";\n","import { defineCommand } from \"politty\";\nimport { erdCommand } from \"./erd\";\nimport { migrationCommand } from \"./migrate\";\nimport { truncateCommand } from \"./truncate\";\n\nexport const tailordbCommand = defineCommand({\n name: \"tailordb\",\n description: \"Manage TailorDB tables and data.\",\n subCommands: {\n erd: erdCommand,\n migration: migrationCommand,\n truncate: truncateCommand,\n },\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const currentCommand = defineCommand({\n name: \"current\",\n description: \"Show current user.\",\n args: z.object({\n ...commonArgs,\n }),\n run: withCommonArgs(async () => {\n const config = readPlatformConfig();\n\n // Check if current user is set\n if (!config.current_user) {\n throw new Error(ml`\n Current user not set.\n Please login first using 'tailor-sdk login' command to register a user.\n `);\n }\n\n // Check if user exists\n if (!config.users[config.current_user]) {\n throw new Error(ml`\n Current user '${config.current_user}' not found in registered users.\n Please login again using 'tailor-sdk login' command to register the user.\n `);\n }\n\n logger.log(config.current_user);\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all users.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n const users = Object.keys(config.users);\n if (users.length === 0) {\n logger.info(ml`\n No users found.\n Please login first using 'tailor-sdk login' command to register a user.\n `);\n return;\n }\n\n if (args.json) {\n logger.out(users);\n return;\n }\n\n users.forEach((user) => {\n if (user === config.current_user) {\n logger.success(`${user} (current)`, { mode: \"plain\" });\n } else {\n logger.log(user);\n }\n });\n }),\n});\n","import { PATScope } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\nimport ml from \"multiline-ts\";\nimport { logger } from \"../../utils/logger\";\nimport type { PersonalAccessToken } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n\nexport interface PersonalAccessTokenInfo {\n name: string;\n scopes: string[];\n}\n\nfunction patScopeToString(scope: PATScope): string {\n switch (scope) {\n case PATScope.PAT_SCOPE_READ:\n return \"read\";\n case PATScope.PAT_SCOPE_WRITE:\n return \"write\";\n default:\n return \"unknown\";\n }\n}\n\n/**\n * Transform a PersonalAccessToken into CLI-friendly info.\n * @param pat - Personal access token resource\n * @returns Flattened token info\n */\nexport function transformPersonalAccessToken(pat: PersonalAccessToken): PersonalAccessTokenInfo {\n return {\n name: pat.name,\n scopes: pat.scopes.map(patScopeToString),\n };\n}\n\n/**\n * Get PAT scopes from a write flag.\n * @param write - Whether write access is required\n * @returns Scopes to apply to the token\n */\nexport function getScopesFromWriteFlag(write: boolean): PATScope[] {\n return write ? [PATScope.PAT_SCOPE_READ, PATScope.PAT_SCOPE_WRITE] : [PATScope.PAT_SCOPE_READ];\n}\n\nfunction getScopeStringsFromWriteFlag(write: boolean): string[] {\n return write ? [\"read\", \"write\"] : [\"read\"];\n}\n\n/**\n * Print the created or updated personal access token to the logger.\n * @param name - Token name\n * @param token - Token value\n * @param write - Whether the token has write scope\n * @param action - Action performed\n */\nexport function printCreatedToken(\n name: string,\n token: string,\n write: boolean,\n action: \"created\" | \"updated\",\n): void {\n const scopes = getScopeStringsFromWriteFlag(write);\n\n if (logger.jsonMode) {\n logger.out({ name, scopes, token });\n } else {\n logger.log(ml`\n Personal access token ${action} successfully.\n\n name: ${name}\n scopes: ${scopes.join(\"/\")}\n token: ${token}\n\n Please save this token in a secure location. You won't be able to see it again.\n `);\n }\n}\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { getScopesFromWriteFlag, printCreatedToken } from \"./transform\";\n\nexport const createCommand = defineCommand({\n name: \"create\",\n description: \"Create a new personal access token.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Token name\",\n }),\n write: arg(z.boolean().default(false), {\n alias: \"W\",\n description: \"Grant write permission (default: read-only)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n const scopes = getScopesFromWriteFlag(args.write);\n const result = await client.createPersonalAccessToken({\n name: args.name,\n scopes,\n });\n\n if (!result.accessToken) {\n throw new Error(\"Failed to create personal access token\");\n }\n\n printCreatedToken(args.name, result.accessToken, args.write, \"created\");\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\n\nexport const deleteCommand = defineCommand({\n name: \"delete\",\n description: \"Delete a personal access token.\",\n args: z.object({\n ...commonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Token name\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n await client.deletePersonalAccessToken({\n name: args.name,\n });\n\n logger.success(`Personal access token \"${args.name}\" deleted successfully.`);\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { fetchAll, initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { logger } from \"../../utils/logger\";\nimport { transformPersonalAccessToken, type PersonalAccessTokenInfo } from \"./transform\";\n\nexport const listCommand = defineCommand({\n name: \"list\",\n description: \"List all personal access tokens.\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n const pats = await fetchAll(async (pageToken) => {\n const { personalAccessTokens, nextPageToken } = await client.listPersonalAccessTokens({\n pageToken,\n });\n return [personalAccessTokens, nextPageToken];\n });\n\n if (pats.length === 0 && !args.json) {\n logger.info(ml`\n No personal access tokens found.\n Please create a token using 'tailor-sdk user pat create' command.\n `);\n return;\n }\n\n const patInfos: PersonalAccessTokenInfo[] = pats.map(transformPersonalAccessToken);\n if (args.json) {\n logger.out(patInfos);\n return;\n }\n\n if (pats.length === 0) {\n return;\n }\n\n // Text format: aligned list \"name: scope1/scope2\"\n const maxNameLength = Math.max(...pats.map((pat) => pat.name.length));\n\n pats.forEach((pat) => {\n const info = transformPersonalAccessToken(pat);\n const paddedName = info.name.padStart(maxNameLength);\n logger.log(`${paddedName}: ${info.scopes.join(\"/\")}`);\n });\n }),\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, jsonArgs, withCommonArgs } from \"../../args\";\nimport { initOperatorClient } from \"../../client\";\nimport { fetchLatestToken, readPlatformConfig } from \"../../context\";\nimport { getScopesFromWriteFlag, printCreatedToken } from \"./transform\";\n\nexport const updateCommand = defineCommand({\n name: \"update\",\n description: \"Update a personal access token (delete and recreate).\",\n args: z.object({\n ...commonArgs,\n ...jsonArgs,\n name: arg(z.string(), {\n positional: true,\n description: \"Token name\",\n }),\n write: arg(z.boolean().default(false), {\n alias: \"W\",\n description: \"Grant write permission (if not specified, keeps read-only)\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n if (!config.current_user) {\n throw new Error(ml`\n No user logged in.\n Please login first using 'tailor-sdk login' command.\n `);\n }\n\n const token = await fetchLatestToken(config, config.current_user);\n const client = await initOperatorClient(token);\n\n // Delete the existing token\n await client.deletePersonalAccessToken({\n name: args.name,\n });\n\n // Create a new token with the same name\n const scopes = getScopesFromWriteFlag(args.write);\n const result = await client.createPersonalAccessToken({\n name: args.name,\n scopes,\n });\n\n if (!result.accessToken) {\n throw new Error(\"Failed to create personal access token\");\n }\n\n printCreatedToken(args.name, result.accessToken, args.write, \"updated\");\n }),\n});\n","import { defineCommand } from \"politty\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { listCommand } from \"./list\";\nimport { updateCommand } from \"./update\";\n\nexport const patCommand = defineCommand({\n name: \"pat\",\n description: \"Manage personal access tokens.\",\n args: listCommand.args,\n subCommands: {\n create: createCommand,\n delete: deleteCommand,\n list: listCommand,\n update: updateCommand,\n },\n async run(args) {\n // Default to list when no subcommand is provided\n await listCommand.run(args);\n },\n});\n","import ml from \"multiline-ts\";\nimport { defineCommand, arg } from \"politty\";\nimport { z } from \"zod\";\nimport { commonArgs, withCommonArgs } from \"../args\";\nimport { readPlatformConfig, writePlatformConfig } from \"../context\";\nimport { logger } from \"../utils/logger\";\n\nexport const switchCommand = defineCommand({\n name: \"switch\",\n description: \"Set current user.\",\n args: z.object({\n ...commonArgs,\n user: arg(z.string(), {\n positional: true,\n description: \"User email\",\n }),\n }),\n run: withCommonArgs(async (args) => {\n const config = readPlatformConfig();\n\n // Check if user exists\n if (!config.users[args.user]) {\n throw new Error(ml`\n User \"${args.user}\" not found.\n Please login first using 'tailor-sdk login' command to register this user.\n `);\n }\n\n // Set current user\n config.current_user = args.user;\n writePlatformConfig(config);\n\n logger.success(`Current user set to \"${args.user}\" successfully.`);\n }),\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { currentCommand } from \"./current\";\nimport { listCommand } from \"./list\";\nimport { patCommand } from \"./pat\";\nimport { switchCommand } from \"./switch\";\n\nexport const userCommand = defineCommand({\n name: \"user\",\n description: \"Manage Tailor Platform users.\",\n subCommands: {\n current: currentCommand,\n list: listCommand,\n pat: patCommand,\n switch: switchCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { executionsCommand } from \"./executions\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\nimport { resumeCommand } from \"./resume\";\nimport { startCommand } from \"./start\";\n\nexport const workflowCommand = defineCommand({\n name: \"workflow\",\n description: \"Manage workflows and workflow executions.\",\n subCommands: {\n list: listCommand,\n get: getCommand,\n start: startCommand,\n executions: executionsCommand,\n resume: resumeCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { healthCommand } from \"./health\";\nimport { listCommand } from \"./list\";\n\nexport const appCommand = defineCommand({\n name: \"app\",\n description: \"Manage workspace applications\",\n subCommands: {\n health: healthCommand,\n list: listCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { inviteCommand } from \"./invite\";\nimport { listCommand } from \"./list\";\nimport { removeCommand } from \"./remove\";\nimport { updateCommand } from \"./update\";\n\nexport const userCommand = defineCommand({\n name: \"user\",\n description: \"Manage workspace users\",\n subCommands: {\n invite: inviteCommand,\n list: listCommand,\n remove: removeCommand,\n update: updateCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","import { defineCommand, runCommand } from \"politty\";\nimport { appCommand } from \"./app\";\nimport { createCommand } from \"./create\";\nimport { deleteCommand } from \"./delete\";\nimport { getCommand } from \"./get\";\nimport { listCommand } from \"./list\";\nimport { restoreCommand } from \"./restore\";\nimport { userCommand } from \"./user\";\n\nexport const workspaceCommand = defineCommand({\n name: \"workspace\",\n description: \"Manage Tailor Platform workspaces.\",\n subCommands: {\n app: appCommand,\n create: createCommand,\n delete: deleteCommand,\n get: getCommand,\n list: listCommand,\n restore: restoreCommand,\n user: userCommand,\n },\n async run() {\n await runCommand(listCommand, []);\n },\n});\n","#!/usr/bin/env node\n\nimport { register } from \"node:module\";\nimport { defineCommand, runMain } from \"politty\";\nimport { withCompletionCommand } from \"politty/completion\";\nimport { apiCommand } from \"./api\";\nimport { applyCommand } from \"./apply\";\nimport { executorCommand } from \"./executor\";\nimport { generateCommand } from \"./generator\";\nimport { initCommand } from \"./init\";\nimport { loginCommand } from \"./login\";\nimport { logoutCommand } from \"./logout\";\nimport { machineuserCommand } from \"./machineuser\";\nimport { oauth2clientCommand } from \"./oauth2client\";\nimport { openCommand } from \"./open\";\nimport { profileCommand } from \"./profile\";\nimport { removeCommand } from \"./remove\";\nimport { secretCommand } from \"./secret\";\nimport { showCommand } from \"./show\";\nimport { staticwebsiteCommand } from \"./staticwebsite\";\nimport { tailordbCommand } from \"./tailordb\";\nimport { userCommand } from \"./user\";\nimport { readPackageJson } from \"./utils/package-json\";\nimport { workflowCommand } from \"./workflow\";\nimport { workspaceCommand } from \"./workspace\";\n\nregister(\"tsx\", import.meta.url, { data: {} });\n\nconst packageJson = await readPackageJson();\nconst cliName = Object.keys(packageJson.bin ?? {})[0] || \"tailor-sdk\";\n\nexport const mainCommand = withCompletionCommand(\n defineCommand({\n name: cliName,\n description:\n packageJson.description || \"Tailor CLI for managing Tailor Platform SDK applications\",\n subCommands: {\n api: apiCommand,\n apply: applyCommand,\n executor: executorCommand,\n generate: generateCommand,\n init: initCommand,\n login: loginCommand,\n logout: logoutCommand,\n machineuser: machineuserCommand,\n oauth2client: oauth2clientCommand,\n open: openCommand,\n profile: profileCommand,\n remove: removeCommand,\n secret: secretCommand,\n show: showCommand,\n staticwebsite: staticwebsiteCommand,\n tailordb: tailordbCommand,\n user: userCommand,\n workflow: workflowCommand,\n workspace: workspaceCommand,\n },\n }),\n);\n\nrunMain(mainCommand, { version: packageJson.version });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,kBAAkB,cAAc;CAC3C,MAAM;CACN,aAAa;CACb,aAAa;EACX,MAAMA;EACN,KAAKC;EACL,MAAM;EACN,SAAS;EACT,SAAS;EACV;CACD,MAAM,MAAM;AACV,QAAM,WAAWD,eAAa,EAAE,CAAC;;CAEpC,CAAC;;;;ACbF,MAAM,6BAA6B;CACjC,MAAM,eAAe;EAAC;EAAO;EAAQ;EAAO;CAC5C,MAAM,YAAY,QAAQ,IAAI;AAC9B,KAAI,CAAC,UAAW;CAChB,MAAM,CAAC,QAAQ,UAAU,MAAM,IAAI;AACnC,KAAI,CAAC,aAAa,SAAS,KAAK,CAAE;AAClC,QAAO;;AAGT,MAAa,cAAc,cA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