{"version":3,"file":"impl-Cl3hf0Pd.mjs","names":[],"sources":["../src/commands/custom-functions/list/impl.ts"],"sourcesContent":["import { buildTranscendGraphQLClient, fetchAllCustomFunctions } from '@transcend-io/sdk';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { validateTranscendAuth } from '../../../lib/api-keys/index.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { logger } from '../../../logger.js';\n\nexport interface CustomFunctionsListCommandFlags {\n  auth: string;\n  transcendUrl: string;\n}\n\nexport async function list(\n  this: LocalContext,\n  { auth, transcendUrl }: CustomFunctionsListCommandFlags,\n): Promise<void> {\n  doneInputValidation(this.process.exit);\n\n  const apiKeyOrList = validateTranscendAuth(auth);\n  if (Array.isArray(apiKeyOrList)) {\n    logger.error(\n      colors.red(\n        'transcend custom-functions list does not support a list of API keys — pass a single API key.',\n      ),\n    );\n    this.process.exit(1);\n  }\n\n  const client = buildTranscendGraphQLClient(transcendUrl, apiKeyOrList as string);\n  const customFunctions = await fetchAllCustomFunctions(client, { logger });\n\n  if (customFunctions.length === 0) {\n    logger.info(colors.yellow('No custom functions found in this organization.'));\n    return;\n  }\n\n  logger.info(colors.magenta(`Found ${customFunctions.length} custom function(s):`));\n  customFunctions.forEach((customFunction) => {\n    const active = customFunction.activeVersion\n      ? `active v${customFunction.activeVersion.versionNumber}`\n      : 'no active version';\n    const draft =\n      customFunction.hasPendingDraft && customFunction.draftVersion\n        ? `, pending draft v${customFunction.draftVersion.versionNumber}`\n        : '';\n    logger.info(\n      `  - ${colors.green(customFunction.name)} [${customFunction.type}] ` +\n        `(${customFunction.lifecycleState.toLowerCase()}, ${active}${draft}) ` +\n        colors.dim(`id: ${customFunction.id}`),\n    );\n  });\n}\n"],"mappings":"0QAaA,eAAsB,EAEpB,CAAE,OAAM,gBACO,CACf,EAAoB,KAAK,QAAQ,KAAK,CAEtC,IAAM,EAAe,EAAsB,EAAK,CAC5C,MAAM,QAAQ,EAAa,GAC7B,EAAO,MACL,EAAO,IACL,+FACD,CACF,CACD,KAAK,QAAQ,KAAK,EAAE,EAItB,IAAM,EAAkB,MAAM,EADf,EAA4B,EAAc,EACG,CAAE,CAAE,SAAQ,CAAC,CAEzE,GAAI,EAAgB,SAAW,EAAG,CAChC,EAAO,KAAK,EAAO,OAAO,kDAAkD,CAAC,CAC7E,OAGF,EAAO,KAAK,EAAO,QAAQ,SAAS,EAAgB,OAAO,sBAAsB,CAAC,CAClF,EAAgB,QAAS,GAAmB,CAC1C,IAAM,EAAS,EAAe,cAC1B,WAAW,EAAe,cAAc,gBACxC,oBACE,EACJ,EAAe,iBAAmB,EAAe,aAC7C,oBAAoB,EAAe,aAAa,gBAChD,GACN,EAAO,KACL,OAAO,EAAO,MAAM,EAAe,KAAK,CAAC,IAAI,EAAe,KAAK,KAC3D,EAAe,eAAe,aAAa,CAAC,IAAI,IAAS,EAAM,IACnE,EAAO,IAAI,OAAO,EAAe,KAAK,CACzC,EACD"}