@sanity/cli 8.38.2 → 8.39.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.
- package/dist/actions/deploy/deployApp.js +12 -1
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployRunner.js +9 -1
- package/dist/actions/deploy/deployRunner.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +12 -1
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/graphql/getSourceDeprecationWarning.js +20 -0
- package/dist/actions/graphql/getSourceDeprecationWarning.js.map +1 -0
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js +12 -6
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js.map +1 -1
- package/dist/actions/graphql/types.js.map +1 -1
- package/dist/commands/graphql/deploy.js +5 -0
- package/dist/commands/graphql/deploy.js.map +1 -1
- package/dist/commands/graphql/undeploy.js +5 -0
- package/dist/commands/graphql/undeploy.js.map +1 -1
- package/dist/commands/new.js +28 -29
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/projects/unclaimed.js +6 -5
- package/dist/commands/projects/unclaimed.js.map +1 -1
- package/dist/exports/index.d.ts +3 -0
- package/dist/generated/apiRoutes.js +2 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/services/mintProject.js +4 -0
- package/dist/services/mintProject.js.map +1 -1
- package/oclif.manifest.json +1109 -1109
- package/package.json +4 -4
- package/templates/shared/AGENTS.md +8 -1
package/dist/commands/new.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/new.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Args, Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes} from '@sanity/cli-core'\nimport {SanityCommand} from '@sanity/cli-core/SanityCommand'\nimport {createFlow, input} from '@sanity/cli-core/ux'\n\nimport {\n FRONTEND_DIR,\n FRONTEND_ENV_FILE,\n getUnavailableScaffoldTarget,\n scaffoldProject,\n type ScaffoldResult,\n STUDIO_DIR,\n STUDIO_ENV_FILE,\n} from '../actions/scaffold/scaffoldProject.js'\nimport {type MintedProject, mintUnclaimedProject} from '../services/mintProject.js'\nimport {\n fetchNewInstructions,\n INSTRUCTIONS_URL,\n InstructionsUnavailableError,\n} from '../services/newInstructions.js'\nimport {formatClaimDeadline} from '../util/formatClaimDeadline.js'\nimport {CLAIM_WINDOW_HOURS, SANITY_NEW_URL} from '../util/mintProjectConstants.js'\nimport {renderNewCommandSplash} from '../util/newCommandSplash.js'\nimport {recordUnclaimedProject} from '../util/unclaimedProjects.js'\n\nconst DEFAULT_PROJECT_NAME = 'My Sanity project'\nconst HELP_DESCRIPTION_WIDTH = 78\n\n/**\n * Prepended to the fetched instructions so an agent cannot read this command's success as the\n * project already existing. The only addition to an otherwise verbatim document.\n */\nconst INSTRUCTIONS_HEADER = '# Nothing has been created yet — follow these steps.'\n\nfunction formatHelpDescription(...paragraphs: string[]): string {\n return paragraphs\n .map((paragraph) => {\n const lines: string[] = []\n let line = ''\n\n for (const word of paragraph.split(/\\s+/u)) {\n if (!line || line.length + word.length + 1 <= HELP_DESCRIPTION_WIDTH) {\n line = line ? `${line} ${word}` : word\n } else {\n lines.push(line)\n line = word\n }\n }\n\n if (line) lines.push(line)\n return lines.join('\\n')\n })\n .join('\\n\\n')\n}\n\nconst FRONTEND_DEV_COMMANDS: Record<\n NonNullable<ScaffoldResult['frontendPackageManager']>,\n string\n> = {\n bun: 'bun dev',\n manual: 'npm run dev',\n npm: 'npm run dev',\n pnpm: 'pnpm dev',\n yarn: 'yarn dev',\n}\n\nfunction frontendDevCommand(packageManager: ScaffoldResult['frontendPackageManager']): string {\n return packageManager ? FRONTEND_DEV_COMMANDS[packageManager] : 'npm run dev'\n}\n\nfunction frontendInstallCommand(packageManager: ScaffoldResult['frontendPackageManager']): string {\n switch (packageManager) {\n case 'bun': {\n return 'bun add next-sanity'\n }\n case 'pnpm': {\n return 'pnpm add --save-prod next-sanity'\n }\n case 'yarn': {\n return 'yarn add next-sanity'\n }\n default: {\n return 'npm install next-sanity'\n }\n }\n}\n\nexport interface NewProjectResult {\n apiHost: string\n claimApiUrl: string\n claimToken: string\n claimUrl: string\n dataset: string\n expiresAt: string\n projectId: string\n terms: {\n notice: string\n url: string\n }\n token: string\n}\n\nfunction toResult(project: MintedProject): NewProjectResult {\n return {\n apiHost: project.apiHost,\n claimApiUrl: project.claimApiUrl,\n claimToken: project.claimToken,\n claimUrl: project.claimUrl,\n dataset: project.datasetName,\n expiresAt: project.expiresAt,\n projectId: project.resourceId,\n terms: {notice: project.termsNotice, url: project.termsUrl},\n token: project.token,\n }\n}\n\nexport class NewCommand extends SanityCommand<typeof NewCommand> {\n static override args = {\n projectName: Args.string({\n description: 'Display name for the new project',\n required: false,\n }),\n }\n\n static override description = formatHelpDescription(\n `Sets up two folders here: ./${STUDIO_DIR}, a Studio where you write and edit your content, ` +\n `and ./${FRONTEND_DIR}, a Next.js website that reads it. Both are already connected to your ` +\n 'new project, so you can start them straight away. Use --no-scaffold if you just want the ' +\n 'project and nothing else.',\n `The project is real and works immediately, but it is only yours for ${CLAIM_WINDOW_HOURS} hours. Claim it with ` +\n 'a Sanity account before the deadline and everything you have built stays exactly as it is. ' +\n 'Claiming is free and takes about a minute. Miss the deadline and the project and its ' +\n 'content are deleted.',\n 'Two things to keep private: the claim link, because anyone who opens it becomes the owner, ' +\n `and the access token saved in ./${STUDIO_ENV_FILE}, because it can read and change ` +\n `everything in the project. ./${FRONTEND_ENV_FILE} has only the project ID and dataset. ` +\n 'Keep both env files out of git, and never put the token in code that runs in the browser.',\n 'Run this command with --instructions for the full agent setup guide.',\n )\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Create a project with a Studio and a website',\n },\n {\n command: '<%= config.bin %> <%= command.id %> \"My New Project\"',\n description: 'Create a project called \"My New Project\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --yes',\n description: 'Create a project without being asked anything',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --no-scaffold',\n description: 'Create the project only, with no Studio or website',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --json',\n description: 'Create a project and print its details as JSON',\n },\n\n {\n command: '<%= config.bin %> <%= command.id %> --instructions',\n description: 'Print the full setup guide for an AI agent, without creating anything',\n },\n ]\n\n static override flags = {\n instructions: Flags.boolean({\n default: false,\n description: `Print the full setup guide from ${SANITY_NEW_URL} and exit, creating nothing`,\n }),\n scaffold: Flags.boolean({\n allowNo: true,\n default: true,\n description: `Set up a Studio in ./${STUDIO_DIR} and a Next.js website in ./${FRONTEND_DIR} (on by default)`,\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description: `Skip prompts and use defaults (project: \"${DEFAULT_PROJECT_NAME}\")`,\n }),\n }\n\n static override summary = `Create a Sanity project without an account, and claim it within ${CLAIM_WINDOW_HOURS} hours to keep it.`\n\n public async run(): Promise<NewProjectResult | undefined> {\n const {output} = this\n const json = this.jsonEnabled()\n const flow = createFlow(output.log)\n const invoked = [this.config.bin, ...(this.id?.split(':') ?? [])].join(' ')\n const cwd = process.cwd()\n\n // Runs before every precondition and side effect: this flag creates nothing.\n if (this.flags.instructions) {\n // oclif's `exclusive` does not cover the json flag added by enableJsonFlag, so guard it here.\n if (json) {\n throw new CLIError('--instructions cannot be combined with --json.', {\n code: 'INSTRUCTIONS_JSON_CONFLICT',\n exit: exitCodes.USAGE_ERROR,\n suggestions: [\n `Run \\`${invoked} --instructions\\` for the setup guide as markdown`,\n `Or run \\`${invoked} --json\\` to create a project and print its details as JSON`,\n ],\n })\n }\n\n await this.printInstructions()\n return undefined\n }\n\n const unavailableScaffoldTarget =\n !json && this.flags.scaffold ? await getUnavailableScaffoldTarget(cwd) : undefined\n if (unavailableScaffoldTarget) {\n throw new CLIError(\n `./${unavailableScaffoldTarget} is not an empty directory. No project was created.`,\n {\n code:\n unavailableScaffoldTarget === STUDIO_DIR\n ? 'EXISTING_STUDIO_DIRECTORY'\n : 'EXISTING_FRONTEND_DIRECTORY',\n exit: exitCodes.RUNTIME_ERROR,\n suggestions: [\n `Run this command where ./${unavailableScaffoldTarget} does not exist or is an empty directory`,\n `Or run \\`${invoked} --no-scaffold\\` to create the project without changing ./${unavailableScaffoldTarget}`,\n ],\n },\n )\n }\n\n if (!json) {\n renderNewCommandSplash(output.log)\n flow.intro('Setting up your Sanity project.')\n flow.gap()\n\n if (!this.isUnattended()) {\n flow.note(\n `${styleText('cyan', `${invoked} --yes`)} for a non-interactive flow with defaults.`,\n )\n flow.gap()\n }\n }\n\n let displayName = this.args.projectName?.trim()\n if (!displayName && this.isUnattended()) {\n displayName = DEFAULT_PROJECT_NAME\n } else if (!displayName) {\n displayName =\n (\n await input({\n default: DEFAULT_PROJECT_NAME,\n message: 'Project name',\n })\n ).trim() || DEFAULT_PROJECT_NAME\n }\n\n const spin = json ? undefined : flow.spin('Creating your project...')\n let project: MintedProject\n try {\n project = await mintUnclaimedProject({displayName})\n } catch (err) {\n spin?.fail('Creating your project failed.')\n throw err\n }\n\n const recorded = recordUnclaimedProject(project)\n spin?.succeed(`Created \"${displayName}\"`)\n\n if (!json) {\n flow.result(`Project ID: ${styleText('cyan', project.resourceId)}`)\n flow.result(`Dataset: ${styleText('cyan', project.datasetName)} (where your content lives)`)\n flow.result(`Token: ${styleText('cyan', project.token)}`)\n flow.link(project.claimUrl, {label: 'Claim link:'})\n flow.gap()\n flow.highlight(\n `Claim your project by ${styleText('yellow', formatClaimDeadline(project.expiresAt))} to avoid losing it.`,\n )\n flow.gap()\n flow.line('To use the Sanity CLI before claiming use your token by setting')\n flow.command(`SANITY_AUTH_TOKEN=\"${project.token}\" sanity \"command\"`)\n flow.gap()\n flow.note(\n styleText(\n 'dim',\n 'If you are an agent: give this claim URL to the person you are working for. They have ' +\n 'to open it themselves before the deadline.',\n ),\n )\n flow.gap()\n }\n\n const studioUrl =\n `http://localhost:3333/#token=${encodeURIComponent(project.token)}` +\n `&claim=${encodeURIComponent(project.claimUrl)}`\n\n const printStudioInstructions = () => {\n flow.highlight('Start your Studio:')\n flow.gap()\n flow.command(`cd ${STUDIO_DIR} && npx sanity@latest dev`)\n flow.gap()\n flow.link(studioUrl, {label: 'Then open this link:'})\n flow.gap()\n flow.line('The token signs you in: there is no account yet.')\n }\n const printWebsiteInstructions = (packageManager: ScaffoldResult['frontendPackageManager']) => {\n flow.highlight('In a separate terminal, start your website:')\n flow.gap()\n flow.command(`cd ${FRONTEND_DIR} && ${frontendDevCommand(packageManager)}`)\n flow.gap()\n flow.link('http://localhost:3000', {label: 'Then open this link:'})\n }\n\n let scaffold: ScaffoldResult | undefined\n if (!json && this.flags.scaffold) {\n const scaffoldController = new AbortController()\n const abortScaffold = () => scaffoldController.abort(new Error('SIGINT'))\n process.once('SIGINT', abortScaffold)\n try {\n scaffold = await scaffoldProject({\n cancelSignal: scaffoldController.signal,\n dataset: project.datasetName,\n displayName,\n output,\n projectId: project.resourceId,\n telemetry: this.telemetry,\n token: project.token,\n workDir: cwd,\n })\n scaffoldController.signal.throwIfAborted()\n } catch (err) {\n if (\n scaffoldController.signal.aborted ||\n (err instanceof Error && err.message === 'SIGINT')\n ) {\n throw err\n }\n // Scaffolding is best-effort and may leave files or directories behind when it fails.\n // Partial filesystem state does not prove the scaffold is runnable, so report the failure,\n // continue only with the project/token/claim handoff below, and do not attempt cleanup.\n flow.note(`Automatic setup did not finish: ${err instanceof Error ? err.message : err}`)\n flow.line('The project was created. You do not need to create another one.')\n flow.gap()\n } finally {\n process.off('SIGINT', abortScaffold)\n }\n }\n\n if (scaffold) {\n if (scaffold.frontendPath) {\n flow.result('Created two folders')\n flow.line(`./${STUDIO_DIR}: your Studio, where you write and edit content`)\n flow.line(`./${FRONTEND_DIR}: your website, a Next.js app that reads it`)\n flow.gap()\n printStudioInstructions()\n if (scaffold.frontendDependenciesInstalled === false) {\n flow.gap()\n if (scaffold.frontendDependencyError) {\n flow.line(`Installing website dependencies failed: ${scaffold.frontendDependencyError}`)\n flow.gap()\n }\n flow.highlight('Finish installing your website dependencies')\n flow.gap()\n flow.command(\n `cd ${FRONTEND_DIR} && ${frontendInstallCommand(scaffold.frontendPackageManager)}`,\n )\n }\n flow.gap()\n printWebsiteInstructions(scaffold.frontendPackageManager)\n } else if (scaffold.detectedFramework) {\n flow.result(`Created ./${STUDIO_DIR} for your existing ${scaffold.detectedFramework} app`)\n flow.line(`./${STUDIO_DIR}: your Studio, where you write and edit content`)\n flow.line(`Your existing ${scaffold.detectedFramework} frontend was left unchanged.`)\n flow.gap()\n printStudioInstructions()\n } else {\n flow.result(`Created ./${STUDIO_DIR}`)\n flow.line(`./${STUDIO_DIR}: your Studio, where you write and edit content`)\n flow.line(\n `The website was not created: ${scaffold.frontendCreationError ?? 'automatic setup did not finish'}`,\n )\n flow.gap()\n printStudioInstructions()\n }\n flow.gap()\n }\n\n if (recorded === false && !json) {\n flow.note('The local recovery record was not saved.')\n flow.line('Keep the claim URL and access token from this output.')\n flow.gap()\n }\n\n if (!json) {\n if (!scaffold && !this.flags.scaffold) {\n flow.result('Project created without scaffolding')\n flow.line(\n 'No folders or env files were created. Use the project ID and dataset above in your own setup.',\n )\n flow.gap()\n flow.link(studioUrl, {\n label: 'Once a Studio is running on http://localhost:3333, sign in with:',\n })\n flow.gap()\n flow.line('The token signs you in: there is no account yet.')\n flow.gap()\n }\n\n flow.line(\"Treat your token as a password and don't expose it publicly in your app.\")\n flow.gap()\n flow.line(\n 'The claim link and token are printed above but you can recover them ' +\n `with ${styleText('cyan', 'sanity projects unclaimed')} before the timer runs out on ${formatClaimDeadline(project.expiresAt)}.`,\n )\n flow.gap()\n flow.line(project.termsNotice)\n flow.link(project.termsUrl, {label: 'Terms of Service:'})\n flow.gap()\n flow.line('For more information on how claiming works or how to build your app')\n flow.link(SANITY_NEW_URL, {label: 'visit', outro: true})\n }\n\n return toResult(project)\n }\n\n /**\n * Dumps the guide from sanity.new verbatim, so an agent gets the whole document rather than a\n * summary produced by whatever fetched it.\n */\n private async printInstructions(): Promise<void> {\n let instructions: string\n try {\n instructions = await fetchNewInstructions()\n } catch (err) {\n if (err instanceof InstructionsUnavailableError) {\n throw new CLIError(err.message, {\n code: 'INSTRUCTIONS_UNAVAILABLE',\n exit: exitCodes.RUNTIME_ERROR,\n suggestions: [\n `Fetch them directly: curl -sSL ${INSTRUCTIONS_URL}`,\n `Or open ${SANITY_NEW_URL} in a browser`,\n ],\n })\n }\n throw err\n }\n\n this.output.log(`${INSTRUCTIONS_HEADER}\\n\\n${instructions}`)\n }\n}\n"],"names":["styleText","Args","Flags","CLIError","exitCodes","SanityCommand","createFlow","input","FRONTEND_DIR","FRONTEND_ENV_FILE","getUnavailableScaffoldTarget","scaffoldProject","STUDIO_DIR","STUDIO_ENV_FILE","mintUnclaimedProject","fetchNewInstructions","INSTRUCTIONS_URL","InstructionsUnavailableError","formatClaimDeadline","CLAIM_WINDOW_HOURS","SANITY_NEW_URL","renderNewCommandSplash","recordUnclaimedProject","DEFAULT_PROJECT_NAME","HELP_DESCRIPTION_WIDTH","INSTRUCTIONS_HEADER","formatHelpDescription","paragraphs","map","paragraph","lines","line","word","split","length","push","join","FRONTEND_DEV_COMMANDS","bun","manual","npm","pnpm","yarn","frontendDevCommand","packageManager","frontendInstallCommand","toResult","project","apiHost","claimApiUrl","claimToken","claimUrl","dataset","datasetName","expiresAt","projectId","resourceId","terms","notice","termsNotice","url","termsUrl","token","NewCommand","args","projectName","string","description","required","enableJsonFlag","examples","command","flags","instructions","boolean","default","scaffold","allowNo","yes","char","summary","run","output","json","jsonEnabled","flow","log","invoked","config","bin","id","cwd","process","code","exit","USAGE_ERROR","suggestions","printInstructions","undefined","unavailableScaffoldTarget","RUNTIME_ERROR","intro","gap","isUnattended","note","displayName","trim","message","spin","err","fail","recorded","succeed","result","link","label","highlight","studioUrl","encodeURIComponent","printStudioInstructions","printWebsiteInstructions","scaffoldController","AbortController","abortScaffold","abort","Error","once","cancelSignal","signal","telemetry","workDir","throwIfAborted","aborted","off","frontendPath","frontendDependenciesInstalled","frontendDependencyError","frontendPackageManager","detectedFramework","frontendCreationError","outro"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,aAAa,QAAO,iCAAgC;AAC5D,SAAQC,UAAU,EAAEC,KAAK,QAAO,sBAAqB;AAErD,SACEC,YAAY,EACZC,iBAAiB,EACjBC,4BAA4B,EAC5BC,eAAe,EAEfC,UAAU,EACVC,eAAe,QACV,yCAAwC;AAC/C,SAA4BC,oBAAoB,QAAO,6BAA4B;AACnF,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,4BAA4B,QACvB,iCAAgC;AACvC,SAAQC,mBAAmB,QAAO,iCAAgC;AAClE,SAAQC,kBAAkB,EAAEC,cAAc,QAAO,kCAAiC;AAClF,SAAQC,sBAAsB,QAAO,8BAA6B;AAClE,SAAQC,sBAAsB,QAAO,+BAA8B;AAEnE,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAE/B;;;CAGC,GACD,MAAMC,sBAAsB;AAE5B,SAASC,sBAAsB,GAAGC,UAAoB;IACpD,OAAOA,WACJC,GAAG,CAAC,CAACC;QACJ,MAAMC,QAAkB,EAAE;QAC1B,IAAIC,OAAO;QAEX,KAAK,MAAMC,QAAQH,UAAUI,KAAK,CAAC,QAAS;YAC1C,IAAI,CAACF,QAAQA,KAAKG,MAAM,GAAGF,KAAKE,MAAM,GAAG,KAAKV,wBAAwB;gBACpEO,OAAOA,OAAO,GAAGA,KAAK,CAAC,EAAEC,MAAM,GAAGA;YACpC,OAAO;gBACLF,MAAMK,IAAI,CAACJ;gBACXA,OAAOC;YACT;QACF;QAEA,IAAID,MAAMD,MAAMK,IAAI,CAACJ;QACrB,OAAOD,MAA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B,EAAEhF,kBAAkB;wBACpD,CAAC,QAAQ,EAAEI,eAAe,aAAa,CAAC;qBACzC;gBACH;YACF;YACA,MAAMyF;QACR;QAEA,IAAI,CAAC3B,MAAM,CAACI,GAAG,CAAC,GAAG7D,oBAAoB,IAAI,EAAEgD,cAAc;IAC7D;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/new.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Args, Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes} from '@sanity/cli-core'\nimport {getCliUserConfigPath} from '@sanity/cli-core/config'\nimport {SanityCommand} from '@sanity/cli-core/SanityCommand'\nimport {createFlow, input} from '@sanity/cli-core/ux'\n\nimport {\n FRONTEND_DIR,\n FRONTEND_ENV_FILE,\n getUnavailableScaffoldTarget,\n scaffoldProject,\n type ScaffoldResult,\n STUDIO_DIR,\n STUDIO_ENV_FILE,\n} from '../actions/scaffold/scaffoldProject.js'\nimport {type MintedProject, mintUnclaimedProject} from '../services/mintProject.js'\nimport {\n fetchNewInstructions,\n INSTRUCTIONS_URL,\n InstructionsUnavailableError,\n} from '../services/newInstructions.js'\nimport {formatClaimDeadline} from '../util/formatClaimDeadline.js'\nimport {CLAIM_WINDOW_HOURS, SANITY_NEW_URL} from '../util/mintProjectConstants.js'\nimport {renderNewCommandSplash} from '../util/newCommandSplash.js'\nimport {recordUnclaimedProject} from '../util/unclaimedProjects.js'\n\nconst DEFAULT_PROJECT_NAME = 'My Sanity project'\nconst HELP_DESCRIPTION_WIDTH = 78\n\n/**\n * Prepended to the fetched instructions so an agent cannot read this command's success as the\n * project already existing. The only addition to an otherwise verbatim document.\n */\nconst INSTRUCTIONS_HEADER = '# Nothing has been created yet — follow these steps.'\n\nfunction formatHelpDescription(...paragraphs: string[]): string {\n return paragraphs\n .map((paragraph) => {\n const lines: string[] = []\n let line = ''\n\n for (const word of paragraph.split(/\\s+/u)) {\n if (!line || line.length + word.length + 1 <= HELP_DESCRIPTION_WIDTH) {\n line = line ? `${line} ${word}` : word\n } else {\n lines.push(line)\n line = word\n }\n }\n\n if (line) lines.push(line)\n return lines.join('\\n')\n })\n .join('\\n\\n')\n}\n\nconst FRONTEND_DEV_COMMANDS: Record<\n NonNullable<ScaffoldResult['frontendPackageManager']>,\n string\n> = {\n bun: 'bun dev',\n manual: 'npm run dev',\n npm: 'npm run dev',\n pnpm: 'pnpm dev',\n yarn: 'yarn dev',\n}\n\nfunction frontendDevCommand(packageManager: ScaffoldResult['frontendPackageManager']): string {\n return packageManager ? FRONTEND_DEV_COMMANDS[packageManager] : 'npm run dev'\n}\n\nfunction frontendInstallCommand(packageManager: ScaffoldResult['frontendPackageManager']): string {\n switch (packageManager) {\n case 'bun': {\n return 'bun add next-sanity'\n }\n case 'pnpm': {\n return 'pnpm add --save-prod next-sanity'\n }\n case 'yarn': {\n return 'yarn add next-sanity'\n }\n default: {\n return 'npm install next-sanity'\n }\n }\n}\n\nexport interface NewProjectResult {\n apiHost: string\n claimApiUrl: string\n claimToken: string\n claimUrl: string\n dataset: string\n expiresAt: string\n projectId: string\n terms: {\n notice: string\n url: string\n }\n}\n\nfunction toResult(project: MintedProject): NewProjectResult {\n return {\n apiHost: project.apiHost,\n claimApiUrl: project.claimApiUrl,\n claimToken: project.claimToken,\n claimUrl: project.claimUrl,\n dataset: project.datasetName,\n expiresAt: project.expiresAt,\n projectId: project.resourceId,\n terms: {notice: project.termsNotice, url: project.termsUrl},\n }\n}\n\nexport class NewCommand extends SanityCommand<typeof NewCommand> {\n static override args = {\n projectName: Args.string({\n description: 'Display name for the new project',\n required: false,\n }),\n }\n\n static override description = formatHelpDescription(\n `Sets up two folders here: ./${STUDIO_DIR}, a Studio where you write and edit your content, ` +\n `and ./${FRONTEND_DIR}, a Next.js website that reads it. Both are already connected to your ` +\n 'new project, so you can start them straight away. Use --no-scaffold if you just want the ' +\n 'project and nothing else.',\n `The project is real and works immediately, but it is only yours for ${CLAIM_WINDOW_HOURS} hours. Claim it with ` +\n 'a Sanity account before the deadline and everything you have built stays exactly as it is. ' +\n 'Claiming is free and takes about a minute. Miss the deadline and the project and its ' +\n 'content are deleted.',\n 'Two things to keep private: the claim link, because anyone who opens it becomes the owner, ' +\n `and the access token saved in ./${STUDIO_ENV_FILE}, because it can read and change ` +\n `everything in the project. ./${FRONTEND_ENV_FILE} has only the project ID and dataset. ` +\n 'Keep both env files out of git, and never put the token in code that runs in the browser.',\n 'Run this command with --instructions for the full agent setup guide.',\n )\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Create a project with a Studio and a website',\n },\n {\n command: '<%= config.bin %> <%= command.id %> \"My New Project\"',\n description: 'Create a project called \"My New Project\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --yes',\n description: 'Create a project without being asked anything',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --no-scaffold',\n description: 'Create the project only, with no Studio or website',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --json',\n description: 'Create a project and print its details as JSON',\n },\n\n {\n command: '<%= config.bin %> <%= command.id %> --instructions',\n description: 'Print the full setup guide for an AI agent, without creating anything',\n },\n ]\n\n static override flags = {\n instructions: Flags.boolean({\n default: false,\n description: `Print the full setup guide from ${SANITY_NEW_URL} and exit, creating nothing`,\n }),\n scaffold: Flags.boolean({\n allowNo: true,\n default: true,\n description: `Set up a Studio in ./${STUDIO_DIR} and a Next.js website in ./${FRONTEND_DIR} (on by default)`,\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description: `Skip prompts and use defaults (project: \"${DEFAULT_PROJECT_NAME}\")`,\n }),\n }\n\n static override summary = `Create a Sanity project without an account, and claim it within ${CLAIM_WINDOW_HOURS} hours to keep it.`\n\n public async run(): Promise<NewProjectResult | undefined> {\n const {output} = this\n const json = this.jsonEnabled()\n const flow = createFlow(output.log)\n const invoked = [this.config.bin, ...(this.id?.split(':') ?? [])].join(' ')\n const cwd = process.cwd()\n\n // Runs before every precondition and side effect: this flag creates nothing.\n if (this.flags.instructions) {\n // oclif's `exclusive` does not cover the json flag added by enableJsonFlag, so guard it here.\n if (json) {\n throw new CLIError('--instructions cannot be combined with --json.', {\n code: 'INSTRUCTIONS_JSON_CONFLICT',\n exit: exitCodes.USAGE_ERROR,\n suggestions: [\n `Run \\`${invoked} --instructions\\` for the setup guide as markdown`,\n `Or run \\`${invoked} --json\\` to create a project and print its details as JSON`,\n ],\n })\n }\n\n await this.printInstructions()\n return undefined\n }\n\n const unavailableScaffoldTarget =\n !json && this.flags.scaffold ? await getUnavailableScaffoldTarget(cwd) : undefined\n if (unavailableScaffoldTarget) {\n throw new CLIError(\n `./${unavailableScaffoldTarget} is not an empty directory. No project was created.`,\n {\n code:\n unavailableScaffoldTarget === STUDIO_DIR\n ? 'EXISTING_STUDIO_DIRECTORY'\n : 'EXISTING_FRONTEND_DIRECTORY',\n exit: exitCodes.RUNTIME_ERROR,\n suggestions: [\n `Run this command where ./${unavailableScaffoldTarget} does not exist or is an empty directory`,\n `Or run \\`${invoked} --no-scaffold\\` to create the project without changing ./${unavailableScaffoldTarget}`,\n ],\n },\n )\n }\n\n if (!json) {\n renderNewCommandSplash(output.log)\n flow.intro('Setting up your Sanity project.')\n flow.gap()\n\n if (!this.isUnattended()) {\n flow.note(\n `${styleText('cyan', `${invoked} --yes`)} for a non-interactive flow with defaults.`,\n )\n flow.gap()\n }\n }\n\n let displayName = this.args.projectName?.trim()\n if (!displayName && this.isUnattended()) {\n displayName = DEFAULT_PROJECT_NAME\n } else if (!displayName) {\n displayName =\n (\n await input({\n default: DEFAULT_PROJECT_NAME,\n message: 'Project name',\n })\n ).trim() || DEFAULT_PROJECT_NAME\n }\n\n const spin = json ? undefined : flow.spin('Creating your project...')\n let project: MintedProject\n try {\n project = await mintUnclaimedProject({displayName})\n } catch (err) {\n spin?.fail('Creating your project failed.')\n throw err\n }\n\n if (!recordUnclaimedProject(project)) {\n const recoveryFile = getCliUserConfigPath()\n spin?.fail('The project was created, but its credentials could not be saved.')\n throw new CLIError(\n `Could not save credentials for project ${project.resourceId}. Make sure the CLI can write to ${recoveryFile}.`,\n {code: 'UNCLAIMED_PROJECT_SAVE_FAILED', exit: exitCodes.RUNTIME_ERROR},\n )\n }\n spin?.succeed(`Created \"${displayName}\"`)\n\n if (!json) {\n flow.result(`Project ID: ${styleText('cyan', project.resourceId)}`)\n flow.result(`Dataset: ${styleText('cyan', project.datasetName)} (where your content lives)`)\n flow.link(project.claimUrl, {label: 'Claim link:'})\n flow.gap()\n flow.highlight(\n `Claim your project by ${styleText('yellow', formatClaimDeadline(project.expiresAt))} to avoid losing it.`,\n )\n flow.gap()\n flow.note(\n 'If you are setting this up for someone else, give them the claim link before the deadline.',\n )\n flow.gap()\n }\n\n const printStudioSignIn = (tokenSource: string) => {\n flow.line('To sign in before claiming, use this URL template:')\n flow.line(`http://localhost:3333/#token=$token&claim=${encodeURIComponent(project.claimUrl)}`)\n flow.line(`Get the token from ${tokenSource}.`)\n flow.line('URL-encode the token and replace $token in the template.')\n }\n const printStudioInstructions = () => {\n flow.highlight('Start your Studio:')\n flow.gap()\n flow.command(`cd ${STUDIO_DIR} && npx sanity@latest dev`)\n flow.gap()\n printStudioSignIn(`SANITY_AUTH_TOKEN in ./${STUDIO_ENV_FILE}`)\n flow.line(`Run CLI commands from ./${STUDIO_DIR} to use the saved token.`)\n }\n const printWebsiteInstructions = (packageManager: ScaffoldResult['frontendPackageManager']) => {\n flow.highlight('In a separate terminal, start your website:')\n flow.gap()\n flow.command(`cd ${FRONTEND_DIR} && ${frontendDevCommand(packageManager)}`)\n flow.gap()\n flow.link('http://localhost:3000', {label: 'Then open this link:'})\n }\n\n let scaffold: ScaffoldResult | undefined\n if (!json && this.flags.scaffold) {\n const scaffoldController = new AbortController()\n const abortScaffold = () => scaffoldController.abort(new Error('SIGINT'))\n process.once('SIGINT', abortScaffold)\n try {\n scaffold = await scaffoldProject({\n cancelSignal: scaffoldController.signal,\n dataset: project.datasetName,\n displayName,\n output,\n projectId: project.resourceId,\n telemetry: this.telemetry,\n token: project.token,\n workDir: cwd,\n })\n scaffoldController.signal.throwIfAborted()\n } catch (err) {\n if (\n scaffoldController.signal.aborted ||\n (err instanceof Error && err.message === 'SIGINT')\n ) {\n throw err\n }\n // Scaffolding is best-effort and may leave files or directories behind when it fails.\n // Partial filesystem state does not prove the scaffold is runnable, so report the failure,\n // continue with the project and claim details below, and do not attempt cleanup.\n flow.note(\n `Automatic setup did not finish: ${String(err instanceof Error ? err.message : err)\n .replaceAll(project.claimUrl, '[redacted]')\n .replaceAll(project.claimToken, '[redacted]')\n .replaceAll(project.token, '[redacted]')}`,\n )\n flow.line('The project was created. You do not need to create another one.')\n flow.gap()\n } finally {\n process.off('SIGINT', abortScaffold)\n }\n }\n\n if (scaffold) {\n if (scaffold.frontendPath) {\n flow.result('Created two folders')\n flow.line(`./${STUDIO_DIR}: your Studio, where you write and edit content`)\n flow.line(`./${FRONTEND_DIR}: your website, a Next.js app that reads it`)\n flow.gap()\n printStudioInstructions()\n if (scaffold.frontendDependenciesInstalled === false) {\n flow.gap()\n if (scaffold.frontendDependencyError) {\n flow.line(`Installing website dependencies failed: ${scaffold.frontendDependencyError}`)\n flow.gap()\n }\n flow.highlight('Finish installing your website dependencies')\n flow.gap()\n flow.command(\n `cd ${FRONTEND_DIR} && ${frontendInstallCommand(scaffold.frontendPackageManager)}`,\n )\n }\n flow.gap()\n printWebsiteInstructions(scaffold.frontendPackageManager)\n } else if (scaffold.detectedFramework) {\n flow.result(`Created ./${STUDIO_DIR} for your existing ${scaffold.detectedFramework} app`)\n flow.line(`./${STUDIO_DIR}: your Studio, where you write and edit content`)\n flow.line(`Your existing ${scaffold.detectedFramework} frontend was left unchanged.`)\n flow.gap()\n printStudioInstructions()\n } else {\n flow.result(`Created ./${STUDIO_DIR}`)\n flow.line(`./${STUDIO_DIR}: your Studio, where you write and edit content`)\n flow.line(\n `The website was not created: ${scaffold.frontendCreationError ?? 'automatic setup did not finish'}`,\n )\n flow.gap()\n printStudioInstructions()\n }\n flow.gap()\n }\n\n if (!json) {\n if (!scaffold && !this.flags.scaffold) {\n flow.result('Project created without scaffolding')\n flow.line(\n 'No folders or env files were created. Use the project ID and dataset above in your own setup.',\n )\n flow.gap()\n }\n\n if (!scaffold) {\n flow.line('Find your saved token:')\n flow.command(`npx sanity@latest projects unclaimed --project ${project.resourceId}`)\n flow.gap()\n printStudioSignIn('the recovery file shown by the command above')\n flow.gap()\n flow.line('For CLI commands, set SANITY_AUTH_TOKEN to the saved token.')\n flow.gap()\n }\n\n flow.line(project.termsNotice)\n flow.link(project.termsUrl, {label: 'Terms of Service:'})\n flow.gap()\n flow.line('For more information on how claiming works or how to build your app')\n flow.link(SANITY_NEW_URL, {label: 'visit', outro: true})\n }\n\n return toResult(project)\n }\n\n /**\n * Dumps the guide from sanity.new verbatim, so an agent gets the whole document rather than a\n * summary produced by whatever fetched it.\n */\n private async printInstructions(): Promise<void> {\n let instructions: string\n try {\n instructions = await fetchNewInstructions()\n } catch (err) {\n if (err instanceof InstructionsUnavailableError) {\n throw new CLIError(err.message, {\n code: 'INSTRUCTIONS_UNAVAILABLE',\n exit: exitCodes.RUNTIME_ERROR,\n suggestions: [\n `Fetch them directly: curl -sSL ${INSTRUCTIONS_URL}`,\n `Or open ${SANITY_NEW_URL} in a browser`,\n ],\n })\n }\n throw err\n }\n\n this.output.log(`${INSTRUCTIONS_HEADER}\\n\\n${instructions}`)\n }\n}\n"],"names":["styleText","Args","Flags","CLIError","exitCodes","getCliUserConfigPath","SanityCommand","createFlow","input","FRONTEND_DIR","FRONTEND_ENV_FILE","getUnavailableScaffoldTarget","scaffoldProject","STUDIO_DIR","STUDIO_ENV_FILE","mintUnclaimedProject","fetchNewInstructions","INSTRUCTIONS_URL","InstructionsUnavailableError","formatClaimDeadline","CLAIM_WINDOW_HOURS","SANITY_NEW_URL","renderNewCommandSplash","recordUnclaimedProject","DEFAULT_PROJECT_NAME","HELP_DESCRIPTION_WIDTH","INSTRUCTIONS_HEADER","formatHelpDescription","paragraphs","map","paragraph","lines","line","word","split","length","push","join","FRONTEND_DEV_COMMANDS","bun","manual","npm","pnpm","yarn","frontendDevCommand","packageManager","frontendInstallCommand","toResult","project","apiHost","claimApiUrl","claimToken","claimUrl","dataset","datasetName","expiresAt","projectId","resourceId","terms","notice","termsNotice","url","termsUrl","NewCommand","args","projectName","string","description","required","enableJsonFlag","examples","command","flags","instructions","boolean","default","scaffold","allowNo","yes","char","summary","run","output","json","jsonEnabled","flow","log","invoked","config","bin","id","cwd","process","code","exit","USAGE_ERROR","suggestions","printInstructions","undefined","unavailableScaffoldTarget","RUNTIME_ERROR","intro","gap","isUnattended","note","displayName","trim","message","spin","err","fail","recoveryFile","succeed","result","link","label","highlight","printStudioSignIn","tokenSource","encodeURIComponent","printStudioInstructions","printWebsiteInstructions","scaffoldController","AbortController","abortScaffold","abort","Error","once","cancelSignal","signal","telemetry","token","workDir","throwIfAborted","aborted","String","replaceAll","off","frontendPath","frontendDependenciesInstalled","frontendDependencyError","frontendPackageManager","detectedFramework","frontendCreationError","outro"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,oBAAoB,QAAO,0BAAyB;AAC5D,SAAQC,aAAa,QAAO,iCAAgC;AAC5D,SAAQC,UAAU,EAAEC,KAAK,QAAO,sBAAqB;AAErD,SACEC,YAAY,EACZC,iBAAiB,EACjBC,4BAA4B,EAC5BC,eAAe,EAEfC,UAAU,EACVC,eAAe,QACV,yCAAwC;AAC/C,SAA4BC,oBAAoB,QAAO,6BAA4B;AACnF,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,4BAA4B,QACvB,iCAAgC;AACvC,SAAQC,mBAAmB,QAAO,iCAAgC;AAClE,SAAQC,kBAAkB,EAAEC,cAAc,QAA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,GAAG;gBACRjB,KAAKrD,IAAI,CAAC;gBACVqD,KAAKiB,GAAG;YACV;YAEAjB,KAAKrD,IAAI,CAACgB,QAAQY,WAAW;YAC7ByB,KAAK6B,IAAI,CAAClE,QAAQc,QAAQ,EAAE;gBAACqD,OAAO;YAAmB;YACvD9B,KAAKiB,GAAG;YACRjB,KAAKrD,IAAI,CAAC;YACVqD,KAAK6B,IAAI,CAAC7F,gBAAgB;gBAAC8F,OAAO;gBAAS6B,OAAO;YAAI;QACxD;QAEA,OAAOjG,SAASC;IAClB;IAEA;;;GAGC,GACD,MAAciD,oBAAmC;QAC/C,IAAIxB;QACJ,IAAI;YACFA,eAAe,MAAMzD;QACvB,EAAE,OAAO6F,KAAK;YACZ,IAAIA,eAAe3F,8BAA8B;gBAC/C,MAAM,IAAIf,SAAS0G,IAAIF,OAAO,EAAE;oBAC9Bd,MAAM;oBACNC,MAAM1F,UAAUgG,aAAa;oBAC7BJ,aAAa;wBACX,CAAC,+BAA+B,EAAE/E,kBAAkB;wBACpD,CAAC,QAAQ,EAAEI,eAAe,aAAa,CAAC;qBACzC;gBACH;YACF;YACA,MAAMwF;QACR;QAEA,IAAI,CAAC3B,MAAM,CAACI,GAAG,CAAC,GAAG5D,oBAAoB,IAAI,EAAE+C,cAAc;IAC7D;AACF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { exitCodes, SanityCommand } from '@sanity/cli-core';
|
|
2
|
+
import { getCliUserConfigPath } from '@sanity/cli-core/config';
|
|
2
3
|
import { logSymbols } from '@sanity/cli-core/ux';
|
|
3
4
|
import { formatKeyValue, sectionHeader } from '../../actions/debug/output.js';
|
|
4
5
|
import { getProjectClaimStatus } from '../../services/projects.js';
|
|
5
6
|
import { Table } from '../../util/responsiveTable.js';
|
|
6
7
|
import { getProjectIdFlag } from '../../util/sharedFlags.js';
|
|
7
|
-
import { readUnclaimedProjects, removeUnclaimedProject } from '../../util/unclaimedProjects.js';
|
|
8
|
+
import { readUnclaimedProjects, removeUnclaimedProject, UNCLAIMED_PROJECTS_CONFIG_KEY } from '../../util/unclaimedProjects.js';
|
|
8
9
|
function isExpired(record) {
|
|
9
10
|
return Date.parse(record.expiresAt) <= Date.now();
|
|
10
11
|
}
|
|
@@ -85,10 +86,6 @@ export class UnclaimedProjectsCommand extends SanityCommand {
|
|
|
85
86
|
[
|
|
86
87
|
'Claim URL',
|
|
87
88
|
record.claimUrl
|
|
88
|
-
],
|
|
89
|
-
[
|
|
90
|
-
'Access token',
|
|
91
|
-
record.token
|
|
92
89
|
]
|
|
93
90
|
];
|
|
94
91
|
for (const [label, value] of details){
|
|
@@ -96,6 +93,10 @@ export class UnclaimedProjectsCommand extends SanityCommand {
|
|
|
96
93
|
padTo: 14
|
|
97
94
|
}));
|
|
98
95
|
}
|
|
96
|
+
const recoveryEntry = `${UNCLAIMED_PROJECTS_CONFIG_KEY}[${JSON.stringify(projectId)}]`;
|
|
97
|
+
this.output.log();
|
|
98
|
+
this.output.log(`Recovery file: ${getCliUserConfigPath()}`);
|
|
99
|
+
this.output.log(`Studio token field: ${recoveryEntry}.token`);
|
|
99
100
|
this.output.log();
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/projects/unclaimed.ts"],"sourcesContent":["import {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {logSymbols} from '@sanity/cli-core/ux'\n\nimport {formatKeyValue, sectionHeader} from '../../actions/debug/output.js'\nimport {getProjectClaimStatus} from '../../services/projects.js'\nimport {Table} from '../../util/responsiveTable.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\nimport {\n readUnclaimedProjects,\n removeUnclaimedProject,\n type UnclaimedProjectRecord,\n} from '../../util/unclaimedProjects.js'\n\nfunction isExpired(record: UnclaimedProjectRecord): boolean {\n return Date.parse(record.expiresAt) <= Date.now()\n}\n\nexport class UnclaimedProjectsCommand extends SanityCommand<typeof UnclaimedProjectsCommand> {\n static override description = 'Recover details for unclaimed projects created on this machine'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List locally recorded unclaimed projects',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project abc123',\n description: 'Show recovery details for one project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to recover',\n semantics: 'specify',\n }),\n }\n\n static override hiddenAliases: string[] = ['project:unclaimed']\n\n public async run(): Promise<void> {\n let records: UnclaimedProjectRecord[]\n try {\n records = readUnclaimedProjects()\n } catch (error) {\n this.output.error(\n `Could not read local unclaimed projects: ${\n error instanceof Error ? error.message : String(error)\n } Remove or repair the \"unclaimedProjects\" entry in your Sanity user config.`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n return\n }\n\n const projectId = this.flags.project\n if (projectId) {\n const record = records.find((candidate) => candidate.projectId === projectId)\n if (!record) {\n this.output.error(\n `No local recovery record found for project \"${projectId}\". Run \\`sanity projects unclaimed\\` to list recorded projects.`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n return\n }\n\n if (isExpired(record)) {\n if (this.removeExpiredProject(record)) {\n this.logExpiredProject(record.projectId)\n }\n return\n }\n\n const status = await getProjectClaimStatus(record.projectId, record.token)\n if (status === 'claimed') {\n if (this.removeClaimedProject(record)) {\n this.logClaimedProject(record.projectId)\n }\n return\n }\n if (status === 'unknown') {\n this.output.warn(\n `Could not verify whether project \"${projectId}\" is claimed. Local recovery details were kept. Run this command again to retry.`,\n )\n }\n\n this.output.log(sectionHeader('Project'))\n const details = [\n ['Project ID', record.projectId],\n ['Dataset', record.dataset],\n ['Created', record.mintedAt],\n ['Claim deadline', record.expiresAt],\n ['Claim URL', record.claimUrl],\n ['Access token', record.token],\n ]\n for (const [label, value] of details) {\n this.output.log(formatKeyValue(label, value, {padTo: 14}))\n }\n this.output.log()\n return\n }\n\n const expiredProjectIds: string[] = []\n const activeRecords = records.filter((record) => {\n if (!isExpired(record)) return true\n if (this.removeExpiredProject(record)) {\n expiredProjectIds.push(record.projectId)\n }\n return false\n })\n const checked = await Promise.all(\n activeRecords.map(async (record) => ({\n record,\n status: await getProjectClaimStatus(record.projectId, record.token),\n })),\n )\n records = []\n const claimedProjectIds: string[] = []\n for (const {record, status} of checked) {\n if (status === 'claimed') {\n if (this.removeClaimedProject(record)) {\n claimedProjectIds.push(record.projectId)\n }\n continue\n }\n if (status === 'unknown') {\n this.output.warn(\n `Could not verify whether project \"${record.projectId}\" is claimed. Local recovery details were kept. Run this command again to retry.`,\n )\n }\n records.push(record)\n }\n\n if (records.length === 0) {\n if (claimedProjectIds.length > 0 || expiredProjectIds.length > 0) {\n for (const expiredProjectId of expiredProjectIds) {\n this.logExpiredProject(expiredProjectId)\n }\n for (const claimedProjectId of claimedProjectIds) {\n this.logClaimedProject(claimedProjectId)\n }\n return\n }\n this.output.log(\n 'No locally recorded unclaimed projects. Create one with `sanity new`, then return here if you need its recovery details.',\n )\n return\n }\n\n const table = new Table({\n columns: [\n {alignment: 'left', name: 'id', title: 'ID'},\n {alignment: 'left', name: 'dataset', title: 'Dataset'},\n {alignment: 'left', name: 'created', title: 'Created'},\n {alignment: 'left', name: 'claimDeadline', title: 'Claim deadline'},\n {alignment: 'left', name: 'claimUrl', title: 'Claim URL'},\n ],\n })\n for (const record of records) {\n table.addRow({\n claimDeadline: record.expiresAt,\n claimUrl: record.claimUrl,\n created: record.mintedAt,\n dataset: record.dataset,\n id: record.projectId,\n })\n }\n this.output.log(table.render())\n if (claimedProjectIds.length > 0 || expiredProjectIds.length > 0) {\n this.output.log()\n for (const expiredProjectId of expiredProjectIds) {\n this.logExpiredProject(expiredProjectId)\n }\n for (const claimedProjectId of claimedProjectIds) {\n this.logClaimedProject(claimedProjectId)\n }\n }\n }\n\n private logClaimedProject(projectId: string): void {\n this.output.log(\n `${logSymbols.success} Project \"${projectId}\" is claimed. Local recovery details removed.`,\n )\n }\n\n private logExpiredProject(projectId: string): void {\n this.output.log(\n `${logSymbols.success} Project \"${projectId}\" expired. Local recovery details removed.`,\n )\n }\n\n private removeClaimedProject(record: UnclaimedProjectRecord): boolean {\n const removed = removeUnclaimedProject(record.projectId, record.claimToken)\n if (!removed) {\n this.output.warn(\n `Project \"${record.projectId}\" is claimed, but its local recovery details could not be removed. Run this command again to retry.`,\n )\n }\n return removed\n }\n\n private removeExpiredProject(record: UnclaimedProjectRecord): boolean {\n const removed = removeUnclaimedProject(record.projectId, record.claimToken)\n if (!removed) {\n this.output.warn(\n `Project \"${record.projectId}\" expired, but its local recovery details could not be removed. Run this command again to retry.`,\n )\n }\n return removed\n }\n}\n"],"names":["exitCodes","SanityCommand","logSymbols","formatKeyValue","sectionHeader","getProjectClaimStatus","Table","getProjectIdFlag","readUnclaimedProjects","removeUnclaimedProject","isExpired","record","Date","parse","expiresAt","now","UnclaimedProjectsCommand","description","examples","command","flags","semantics","hiddenAliases","run","records","error","output","Error","message","String","exit","RUNTIME_ERROR","projectId","project","find","candidate","removeExpiredProject","logExpiredProject","status","token","removeClaimedProject","logClaimedProject","warn","log","details","dataset","mintedAt","claimUrl","label","value","padTo","expiredProjectIds","activeRecords","filter","push","checked","Promise","all","map","claimedProjectIds","length","expiredProjectId","claimedProjectId","table","columns","alignment","name","title","addRow","claimDeadline","created","id","render","success","removed","claimToken"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,UAAU,QAAO,sBAAqB;AAE9C,SAAQC,cAAc,EAAEC,aAAa,QAAO,gCAA+B;AAC3E,SAAQC,qBAAqB,QAAO,6BAA4B;AAChE,SAAQC,KAAK,QAAO,gCAA+B;AACnD,SAAQC,gBAAgB,QAAO,4BAA2B;AAC1D,SACEC,qBAAqB,EACrBC,sBAAsB,QAEjB,kCAAiC;AAExC,SAASC,UAAUC,MAA8B;IAC/C,OAAOC,KAAKC,KAAK,CAACF,OAAOG,SAAS,KAAKF,KAAKG,GAAG;AACjD;AAEA,OAAO,MAAMC,iCAAiCf;IAC5C,OAAgBgB,cAAc,i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KT,kBAAkBS,MAAM,GAAG,GAAG;YAChE,IAAI,CAAClC,MAAM,CAACiB,GAAG;YACf,KAAK,MAAMkB,oBAAoBV,kBAAmB;gBAChD,IAAI,CAACd,iBAAiB,CAACwB;YACzB;YACA,KAAK,MAAMC,oBAAoBH,kBAAmB;gBAChD,IAAI,CAAClB,iBAAiB,CAACqB;YACzB;QACF;IACF;IAEQrB,kBAAkBT,SAAiB,EAAQ;QACjD,IAAI,CAACN,MAAM,CAACiB,GAAG,CACb,GAAGzC,WAAWuE,OAAO,CAAC,UAAU,EAAEzC,UAAU,6CAA6C,CAAC;IAE9F;IAEQK,kBAAkBL,SAAiB,EAAQ;QACjD,IAAI,CAACN,MAAM,CAACiB,GAAG,CACb,GAAGzC,WAAWuE,OAAO,CAAC,UAAU,EAAEzC,UAAU,0CAA0C,CAAC;IAE3F;IAEQQ,qBAAqB7B,MAA8B,EAAW;QACpE,MAAM+D,UAAUjE,uBAAuBE,OAAOqB,SAAS,EAAErB,OAAOgE,UAAU;QAC1E,IAAI,CAACD,SAAS;YACZ,IAAI,CAAChD,MAAM,CAACgB,IAAI,CACd,CAAC,SAAS,EAAE/B,OAAOqB,SAAS,CAAC,mGAAmG,CAAC;QAErI;QACA,OAAO0C;IACT;IAEQtC,qBAAqBzB,MAA8B,EAAW;QACpE,MAAM+D,UAAUjE,uBAAuBE,OAAOqB,SAAS,EAAErB,OAAOgE,UAAU;QAC1E,IAAI,CAACD,SAAS;YACZ,IAAI,CAAChD,MAAM,CAACgB,IAAI,CACd,CAAC,SAAS,EAAE/B,OAAOqB,SAAS,CAAC,gGAAgG,CAAC;QAElI;QACA,OAAO0C;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/projects/unclaimed.ts"],"sourcesContent":["import {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {getCliUserConfigPath} from '@sanity/cli-core/config'\nimport {logSymbols} from '@sanity/cli-core/ux'\n\nimport {formatKeyValue, sectionHeader} from '../../actions/debug/output.js'\nimport {getProjectClaimStatus} from '../../services/projects.js'\nimport {Table} from '../../util/responsiveTable.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\nimport {\n readUnclaimedProjects,\n removeUnclaimedProject,\n UNCLAIMED_PROJECTS_CONFIG_KEY,\n type UnclaimedProjectRecord,\n} from '../../util/unclaimedProjects.js'\n\nfunction isExpired(record: UnclaimedProjectRecord): boolean {\n return Date.parse(record.expiresAt) <= Date.now()\n}\n\nexport class UnclaimedProjectsCommand extends SanityCommand<typeof UnclaimedProjectsCommand> {\n static override description = 'Recover details for unclaimed projects created on this machine'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List locally recorded unclaimed projects',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project abc123',\n description: 'Show recovery details for one project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to recover',\n semantics: 'specify',\n }),\n }\n\n static override hiddenAliases: string[] = ['project:unclaimed']\n\n public async run(): Promise<void> {\n let records: UnclaimedProjectRecord[]\n try {\n records = readUnclaimedProjects()\n } catch (error) {\n this.output.error(\n `Could not read local unclaimed projects: ${\n error instanceof Error ? error.message : String(error)\n } Remove or repair the \"unclaimedProjects\" entry in your Sanity user config.`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n return\n }\n\n const projectId = this.flags.project\n if (projectId) {\n const record = records.find((candidate) => candidate.projectId === projectId)\n if (!record) {\n this.output.error(\n `No local recovery record found for project \"${projectId}\". Run \\`sanity projects unclaimed\\` to list recorded projects.`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n return\n }\n\n if (isExpired(record)) {\n if (this.removeExpiredProject(record)) {\n this.logExpiredProject(record.projectId)\n }\n return\n }\n\n const status = await getProjectClaimStatus(record.projectId, record.token)\n if (status === 'claimed') {\n if (this.removeClaimedProject(record)) {\n this.logClaimedProject(record.projectId)\n }\n return\n }\n if (status === 'unknown') {\n this.output.warn(\n `Could not verify whether project \"${projectId}\" is claimed. Local recovery details were kept. Run this command again to retry.`,\n )\n }\n\n this.output.log(sectionHeader('Project'))\n const details = [\n ['Project ID', record.projectId],\n ['Dataset', record.dataset],\n ['Created', record.mintedAt],\n ['Claim deadline', record.expiresAt],\n ['Claim URL', record.claimUrl],\n ]\n for (const [label, value] of details) {\n this.output.log(formatKeyValue(label, value, {padTo: 14}))\n }\n const recoveryEntry = `${UNCLAIMED_PROJECTS_CONFIG_KEY}[${JSON.stringify(projectId)}]`\n this.output.log()\n this.output.log(`Recovery file: ${getCliUserConfigPath()}`)\n this.output.log(`Studio token field: ${recoveryEntry}.token`)\n this.output.log()\n return\n }\n\n const expiredProjectIds: string[] = []\n const activeRecords = records.filter((record) => {\n if (!isExpired(record)) return true\n if (this.removeExpiredProject(record)) {\n expiredProjectIds.push(record.projectId)\n }\n return false\n })\n const checked = await Promise.all(\n activeRecords.map(async (record) => ({\n record,\n status: await getProjectClaimStatus(record.projectId, record.token),\n })),\n )\n records = []\n const claimedProjectIds: string[] = []\n for (const {record, status} of checked) {\n if (status === 'claimed') {\n if (this.removeClaimedProject(record)) {\n claimedProjectIds.push(record.projectId)\n }\n continue\n }\n if (status === 'unknown') {\n this.output.warn(\n `Could not verify whether project \"${record.projectId}\" is claimed. Local recovery details were kept. Run this command again to retry.`,\n )\n }\n records.push(record)\n }\n\n if (records.length === 0) {\n if (claimedProjectIds.length > 0 || expiredProjectIds.length > 0) {\n for (const expiredProjectId of expiredProjectIds) {\n this.logExpiredProject(expiredProjectId)\n }\n for (const claimedProjectId of claimedProjectIds) {\n this.logClaimedProject(claimedProjectId)\n }\n return\n }\n this.output.log(\n 'No locally recorded unclaimed projects. Create one with `sanity new`, then return here if you need its recovery details.',\n )\n return\n }\n\n const table = new Table({\n columns: [\n {alignment: 'left', name: 'id', title: 'ID'},\n {alignment: 'left', name: 'dataset', title: 'Dataset'},\n {alignment: 'left', name: 'created', title: 'Created'},\n {alignment: 'left', name: 'claimDeadline', title: 'Claim deadline'},\n {alignment: 'left', name: 'claimUrl', title: 'Claim URL'},\n ],\n })\n for (const record of records) {\n table.addRow({\n claimDeadline: record.expiresAt,\n claimUrl: record.claimUrl,\n created: record.mintedAt,\n dataset: record.dataset,\n id: record.projectId,\n })\n }\n this.output.log(table.render())\n if (claimedProjectIds.length > 0 || expiredProjectIds.length > 0) {\n this.output.log()\n for (const expiredProjectId of expiredProjectIds) {\n this.logExpiredProject(expiredProjectId)\n }\n for (const claimedProjectId of claimedProjectIds) {\n this.logClaimedProject(claimedProjectId)\n }\n }\n }\n\n private logClaimedProject(projectId: string): void {\n this.output.log(\n `${logSymbols.success} Project \"${projectId}\" is claimed. Local recovery details removed.`,\n )\n }\n\n private logExpiredProject(projectId: string): void {\n this.output.log(\n `${logSymbols.success} Project \"${projectId}\" expired. Local recovery details removed.`,\n )\n }\n\n private removeClaimedProject(record: UnclaimedProjectRecord): boolean {\n const removed = removeUnclaimedProject(record.projectId, record.claimToken)\n if (!removed) {\n this.output.warn(\n `Project \"${record.projectId}\" is claimed, but its local recovery details could not be removed. Run this command again to retry.`,\n )\n }\n return removed\n }\n\n private removeExpiredProject(record: UnclaimedProjectRecord): boolean {\n const removed = removeUnclaimedProject(record.projectId, record.claimToken)\n if (!removed) {\n this.output.warn(\n `Project \"${record.projectId}\" expired, but its local recovery details could not be removed. Run this command again to retry.`,\n )\n }\n return removed\n }\n}\n"],"names":["exitCodes","SanityCommand","getCliUserConfigPath","logSymbols","formatKeyValue","sectionHeader","getProjectClaimStatus","Table","getProjectIdFlag","readUnclaimedProjects","removeUnclaimedProject","UNCLAIMED_PROJECTS_CONFIG_KEY","isExpired","record","Date","parse","expiresAt","now","UnclaimedProjectsCommand","description","examples","command","flags","semantics","hiddenAliases","run","records","error","output","Error","message","String","exit","RUNTIME_ERROR","projectId","project","find","candidate","removeExpiredProject","logExpiredProject","status","token","removeClaimedProject","logClaimedProject","warn","log","details","dataset","mintedAt","claimUrl","label","value","padTo","recoveryEntry","JSON","stringify","expiredProjectIds","activeRecords","filter","push","checked","Promise","all","map","claimedProjectIds","length","expiredProjectId","claimedProjectId","table","columns","alignment","name","title","addRow","claimDeadline","created","id","render","success","removed","claimToken"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,oBAAoB,QAAO,0BAAyB;AAC5D,SAAQC,UAAU,QAAO,sBAAqB;AAE9C,SAAQC,cAAc,EAAEC,aAAa,QAAO,gCAA+B;AAC3E,SAAQC,qBAAqB,QAAO,6BAA4B;AAChE,SAAQC,KAAK,QAAO,gCAA+B;AACnD,SAAQC,gBAAgB,QAAO,4BAA2B;AAC1D,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,6BAA6B,QAExB,kCAAiC;AAExC,SAASC,UAAUC,MAA8B;IAC/C,OAAOC,KAAKC,KAAK,CAACF,OAAOG,SAAS,KAAKF,KAAKG,GAAG;AACjD;AAEA,OAAO,MAAMC,iCAAiCjB;IAC5C,OAAgBkB,cAAc,iEAAgE;IAE9F,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,OAAgBG,QAAQ;QACtB,GAAGd,iBAAiB;YAClBW,aAAa;YACbI,WAAW;QACb,EAAE;IACJ,EAAC;IAED,OAAgBC,gBAA0B;QAAC;KAAoB,CAAA;IAE/D,MAAaC,MAAqB;QAChC,IAAIC;QACJ,IAAI;YACFA,UAAUjB;QACZ,EAAE,OAAOkB,OAAO;YACd,IAAI,CAACC,MAAM,CAACD,KAAK,CACf,CAAC,yCAAyC,EACxCA,iBAAiBE,QAAQF,MAAMG,OAAO,GAAGC,OAAOJ,OACjD,2EAA2E,CAAC,EAC7E;gBAACK,MAAMhC,UAAUiC,aAAa;YAAA;YAEhC;QACF;QAEA,MAAMC,YAAY,IAAI,CAACZ,KAAK,CAACa,OAAO;QACpC,IAAID,WAAW;YACb,MAAMrB,SAASa,QAAQU,IAAI,CAAC,CAACC,YAAcA,U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kBAAkBL,SAAiB,EAAQ;QACjD,IAAI,CAACN,MAAM,CAACiB,GAAG,CACb,GAAG1C,WAAW2E,OAAO,CAAC,UAAU,EAAE5C,UAAU,0CAA0C,CAAC;IAE3F;IAEQQ,qBAAqB7B,MAA8B,EAAW;QACpE,MAAMkE,UAAUrE,uBAAuBG,OAAOqB,SAAS,EAAErB,OAAOmE,UAAU;QAC1E,IAAI,CAACD,SAAS;YACZ,IAAI,CAACnD,MAAM,CAACgB,IAAI,CACd,CAAC,SAAS,EAAE/B,OAAOqB,SAAS,CAAC,mGAAmG,CAAC;QAErI;QACA,OAAO6C;IACT;IAEQzC,qBAAqBzB,MAA8B,EAAW;QACpE,MAAMkE,UAAUrE,uBAAuBG,OAAOqB,SAAS,EAAErB,OAAOmE,UAAU;QAC1E,IAAI,CAACD,SAAS;YACZ,IAAI,CAACnD,MAAM,CAACgB,IAAI,CACd,CAAC,SAAS,EAAE/B,OAAOqB,SAAS,CAAC,gGAAgG,CAAC;QAElI;QACA,OAAO6C;IACT;AACF"}
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ interface GraphQLAPIConfig {
|
|
|
39
39
|
* Name of source containing the schema to deploy, within the configured workspace
|
|
40
40
|
*
|
|
41
41
|
* Optional, defaults to `default` (eg the one used if no `name` is defined)
|
|
42
|
+
*
|
|
43
|
+
* @deprecated Studio v7 removes workspace sources. Configure the source as its own workspace
|
|
44
|
+
* and select it with `workspace` instead.
|
|
42
45
|
*/
|
|
43
46
|
source?: string;
|
|
44
47
|
/**
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
host: 'global',
|
|
78
78
|
pathPatterns: [
|
|
79
79
|
'applications',
|
|
80
|
+
'applications/auto-update-version/{applicationId}',
|
|
80
81
|
'applications/dashboards',
|
|
81
82
|
'applications/dashboards/{dashboardId}',
|
|
82
83
|
'applications/dashboards/{dashboardId}/configs',
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
host: 'project',
|
|
128
129
|
pathPatterns: [
|
|
129
130
|
'applications',
|
|
131
|
+
'applications/auto-update-version/{applicationId}',
|
|
130
132
|
'applications/dashboards',
|
|
131
133
|
'applications/dashboards/{dashboardId}',
|
|
132
134
|
'applications/dashboards/{dashboardId}/configs',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/generated/apiRoutes.ts"],"sourcesContent":["/**\n * GENERATED FILE - DO NOT EDIT\n *\n * Routing manifest for `sanity api`, distilled from the published OpenAPI\n * specifications at https://www.sanity.io/docs/api/openapi\n *\n * Regenerate with: pnpm generate:api-routes\n */\nimport {type ApiRouteEntry} from '../actions/api/types.js'\n\nexport const apiRoutes: ApiRouteEntry[] = [\n {\n defaultApiVersion: 'v2025-07-11',\n host: 'global',\n pathPatterns: [\n 'access/invites/me',\n 'access/organization/{resourceId}/users/roles/default',\n 'access/requests/me',\n 'access/robots/me',\n 'access/robots/me/rotate',\n 'access/{resourceType}/{resourceId}/invites',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/accept',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/eligibility',\n 'access/{resourceType}/{resourceId}/invites/{inviteId}',\n 'access/{resourceType}/{resourceId}/permissions',\n 'access/{resourceType}/{resourceId}/permissions/{permissionName}',\n 'access/{resourceType}/{resourceId}/requests',\n 'access/{resourceType}/{resourceId}/requests/state',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/accept',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/decline',\n 'access/{resourceType}/{resourceId}/robots',\n 'access/{resourceType}/{resourceId}/robots/{robotId}',\n 'access/{resourceType}/{resourceId}/roles',\n 'access/{resourceType}/{resourceId}/roles/{roleName}',\n 'access/{resourceType}/{resourceId}/user-permissions/me',\n 'access/{resourceType}/{resourceId}/user-permissions/me/check',\n 'access/{resourceType}/{resourceId}/users',\n 'access/{resourceType}/{resourceId}/users/me',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles/{roleName}'\n ],\n slug: 'access-api',\n title: 'Access API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/actions/{dataset}'\n ],\n slug: 'actions',\n title: 'Actions API reference'\n },\n {\n defaultApiVersion: 'v2021-02-01',\n host: 'global',\n pathPatterns: [\n 'activity',\n 'activity/export/csv'\n ],\n slug: 'activity-log',\n title: 'Activity Log API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'agent/action/generate/{dataset}',\n 'agent/action/patch/{dataset}',\n 'agent/action/prompt/{dataset}',\n 'agent/action/transform/{dataset}',\n 'agent/action/translate/{dataset}'\n ],\n slug: 'agent-actions',\n title: 'Agent Actions'\n },\n {\n host: 'global',\n pathPatterns: [\n 'applications',\n 'applications/dashboards',\n 'applications/dashboards/{dashboardId}',\n 'applications/dashboards/{dashboardId}/configs',\n 'applications/dashboards/{dashboardId}/configs/{configId}',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/embeddable',\n 'applications/{applicationId}/icon',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/interfaces/{interfaceId}/icon',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'organizations/{organizationId}/applications',\n 'organizations/{organizationId}/applications/{applicationId}',\n 'projects/{projectId}/applications',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n host: 'project',\n pathPatterns: [\n 'applications',\n 'applications/dashboards',\n 'applications/dashboards/{dashboardId}',\n 'applications/dashboards/{dashboardId}/configs',\n 'applications/dashboards/{dashboardId}/configs/{configId}',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/embeddable',\n 'applications/{applicationId}/icon',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/interfaces/{interfaceId}/icon',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'organizations/{organizationId}/applications',\n 'organizations/{organizationId}/applications/{applicationId}',\n 'projects/{projectId}/applications',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n defaultApiVersion: 'v2024-06-24',\n host: 'project',\n pathPatterns: [\n 'assets/files/{dataset}',\n 'assets/files/{dataset}/from-url',\n 'assets/images/{dataset}',\n 'assets/images/{dataset}/from-url',\n 'assets/media-library-link/{dataset}'\n ],\n slug: 'assets',\n title: 'Assets API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/{datasetName}/backups',\n 'projects/{projectId}/datasets/{datasetName}/backups/{backupId}',\n 'projects/{projectId}/datasets/{datasetName}/settings/backups'\n ],\n slug: 'backups',\n title: 'Backups API reference'\n },\n {\n defaultApiVersion: 'v1',\n host: 'global',\n pathPatterns: [\n 'projects/{project_id}/datasets/{dataset_name}/assets/{asset_id}/purges',\n 'projects/{project_id}/datasets/{dataset_name}/purges'\n ],\n slug: 'cdn-cache-purge',\n title: 'CDN Cache Purge API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'global',\n pathPatterns: [\n 'collaboration/comments',\n 'collaboration/comments/listen',\n 'collaboration/comments/query',\n 'collaboration/comments/{id}',\n 'collaboration/comments/{id}/reactions',\n 'collaboration/comments/{id}/reactions/{shortName}'\n ],\n slug: 'comments-api',\n title: 'Comments API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'collaboration/comments',\n 'collaboration/comments/listen',\n 'collaboration/comments/query',\n 'collaboration/comments/{id}',\n 'collaboration/comments/{id}/reactions',\n 'collaboration/comments/{id}/reactions/{shortName}'\n ],\n slug: 'comments-api',\n title: 'Comments API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'global',\n pathPatterns: [\n 'agent/prompt',\n 'agent/{organizationId}/threads/{threadId}'\n ],\n slug: 'content-agent',\n title: 'Content Agent API reference'\n },\n {\n host: 'global',\n pathPatterns: [\n 'context/knowledge-bases',\n 'context/knowledge-bases/{knowledgeBaseId}',\n 'context/knowledge-bases/{knowledgeBaseId}/apply',\n 'context/knowledge-bases/{knowledgeBaseId}/build',\n 'context/knowledge-bases/{knowledgeBaseId}/build/cancel',\n 'context/knowledge-bases/{knowledgeBaseId}/discard',\n 'context/knowledge-bases/{knowledgeBaseId}/documents',\n 'context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}',\n 'context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}/content',\n 'context/knowledge-bases/{knowledgeBaseId}/entries/{entryPath}/rebuild',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions/check',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions/draft',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions/{instructionId}',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/apply',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/dismiss',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/reopen',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/resolve',\n 'context/knowledge-bases/{knowledgeBaseId}/jobs/{jobId}',\n 'context/knowledge-bases/{knowledgeBaseId}/sources',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/uploads',\n 'context/knowledge-bases/{knowledgeBaseId}/sync',\n 'context/organizations/{organizationId}/conversations/{threadId}',\n 'context/organizations/{organizationId}/mcp',\n 'context/organizations/{organizationId}/mcp/{mcpEndpoint}',\n 'context/organizations/{organizationId}/mcp/{mcpEndpoint}/initial-context',\n 'context/organizations/{organizationId}/mcp/{mcpEndpoint}/status'\n ],\n slug: 'context-api',\n title: 'Context API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/copy',\n 'projects/{projectId}/datasets/{dataset}/copy'\n ],\n slug: 'copy',\n title: 'Copy API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/doc/{dataset}/{documentId}'\n ],\n slug: 'doc',\n title: 'Doc API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'embeddings-index/query/{dataset}/{indexName}',\n 'embeddings-index/{dataset}',\n 'embeddings-index/{dataset}/{indexName}'\n ],\n slug: 'embeddings-index',\n title: 'Embeddings Index API reference (deprecated)'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/export/{dataset}'\n ],\n slug: 'export',\n title: 'Export API reference'\n },\n {\n host: 'global',\n pathPatterns: [\n 'functions',\n 'functions/durables/callback/{callbackId}/failure',\n 'functions/durables/callback/{callbackId}/success',\n 'functions/durables/{functionId}/executions',\n 'functions/durables/{functionId}/executions/{executionId}',\n 'functions/durables/{functionId}/executions/{executionId}/stop',\n 'functions/{functionId}',\n 'functions/{functionId}/envvars',\n 'functions/{functionId}/envvars/{envVarKey}',\n 'functions/{functionId}/invoke',\n 'functions/{functionId}/logs',\n 'functions/{functionId}/logs/stream'\n ],\n slug: 'functions-api',\n title: 'Functions API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/history/{dataset}/documents/{documentId}',\n 'data/history/{dataset}/transactions',\n 'data/history/{dataset}/transactions/{documentIds}'\n ],\n slug: 'history',\n title: 'History API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'jobs/{jobId}',\n 'jobs/{jobId}/listen'\n ],\n slug: 'jobs',\n title: 'Jobs API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/listen/{dataset}'\n ],\n slug: 'listen',\n title: 'Listen API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/live/events/{dataset}'\n ],\n slug: 'live',\n title: 'Live Content API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-09-09',\n host: 'project',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/mutate/{dataset}'\n ],\n slug: 'mutation',\n title: 'Mutation API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'projects',\n 'projects/{projectId}',\n 'projects/{projectId}/cors',\n 'projects/{projectId}/cors/{id}',\n 'projects/{projectId}/datasets',\n 'projects/{projectId}/datasets/copy',\n 'projects/{projectId}/datasets/{datasetName}/tags/{tagIdentifier}',\n 'projects/{projectId}/datasets/{name}',\n 'projects/{projectId}/datasets/{name}/copy',\n 'projects/{projectId}/datasets/{name}/settings/embeddings',\n 'projects/{projectId}/datasets/{name}/tags',\n 'projects/{projectId}/features',\n 'projects/{projectId}/permissions',\n 'projects/{projectId}/tags',\n 'projects/{projectId}/tags/{tagIdentifier}',\n 'projects/{projectId}/tokens',\n 'projects/{projectId}/tokens/{tokenId}',\n 'projects/{projectId}/users/{userId}'\n ],\n slug: 'projects-api',\n title: 'Projects API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/query/{dataset}'\n ],\n slug: 'query',\n title: 'Query API reference'\n },\n {\n defaultApiVersion: 'v2021-10-04',\n host: 'global',\n pathPatterns: [\n 'auth/organizations/{organizationId}/providers/{providerId}/projects/{projectId}/role-mappings',\n 'organizations/{organizationId}/acl',\n 'organizations/{organizationId}/acl/{sanityUserId}',\n 'organizations/{organizationId}/grants',\n 'projects/{projectId}/acl',\n 'projects/{projectId}/acl/{projectUserId}',\n 'projects/{projectId}/datasets/{datasetName}/acl',\n 'projects/{projectId}/datasets/{datasetName}/grants',\n 'projects/{projectId}/grants',\n 'projects/{projectId}/grants/{projectUserId}',\n 'projects/{projectId}/permissionResourceSchemas',\n 'projects/{projectId}/permissionResources',\n 'projects/{projectId}/permissionResources/{resourceId}',\n 'projects/{projectId}/roles',\n 'projects/{projectId}/roles/{roleName}'\n ],\n slug: 'roles',\n title: 'Roles API reference'\n },\n {\n defaultApiVersion: 'v2022-04-01',\n host: 'project',\n pathPatterns: [\n 'publish/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}/{scheduleId}',\n 'schedules/{projectId}/{dataset}/{scheduleId}/publish',\n 'unpublish/{projectId}/{dataset}'\n ],\n slug: 'scheduling',\n title: 'Scheduling API reference'\n },\n {\n defaultApiVersion: 'v2026-09-01',\n host: 'global',\n pathPatterns: [\n 'usage/{resourceType}/{resourceId}/history',\n 'usage/{resourceType}/{resourceId}/snapshot',\n 'usage/{resourceType}/{resourceId}/{scope}/history',\n 'usage/{resourceType}/{resourceId}/{scope}/snapshot'\n ],\n slug: 'usage-api',\n title: 'Usage API reference'\n },\n {\n defaultApiVersion: 'v2026-04-27',\n host: 'global',\n pathPatterns: [\n 'organizations/{organizationId}/attribute-definitions',\n 'organizations/{organizationId}/attribute-definitions/{key}',\n 'organizations/{organizationId}/users/me/attributes',\n 'organizations/{organizationId}/users/{sanityUserId}/attributes'\n ],\n slug: 'user-attributes',\n title: 'User attributes API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'hooks/projects/{projectId}',\n 'hooks/projects/{projectId}/attempts/{attemptId}',\n 'hooks/projects/{projectId}/{id}',\n 'hooks/projects/{projectId}/{id}/attempts',\n 'hooks/projects/{projectId}/{id}/messages',\n 'hooks/projects/{projectId}/{id}/messages/{messageId}/attempts'\n ],\n slug: 'webhooks',\n title: 'Webhooks API reference'\n }\n]\n"],"names":["apiRoutes","defaultApiVersion","host","pathPatterns","slug","title"],"mappings":"AAAA;;;;;;;CAOC,GAGD,OAAO,MAAMA,YAA6B;IACxC;QACEC,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;CACD,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../src/generated/apiRoutes.ts"],"sourcesContent":["/**\n * GENERATED FILE - DO NOT EDIT\n *\n * Routing manifest for `sanity api`, distilled from the published OpenAPI\n * specifications at https://www.sanity.io/docs/api/openapi\n *\n * Regenerate with: pnpm generate:api-routes\n */\nimport {type ApiRouteEntry} from '../actions/api/types.js'\n\nexport const apiRoutes: ApiRouteEntry[] = [\n {\n defaultApiVersion: 'v2025-07-11',\n host: 'global',\n pathPatterns: [\n 'access/invites/me',\n 'access/organization/{resourceId}/users/roles/default',\n 'access/requests/me',\n 'access/robots/me',\n 'access/robots/me/rotate',\n 'access/{resourceType}/{resourceId}/invites',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/accept',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/eligibility',\n 'access/{resourceType}/{resourceId}/invites/{inviteId}',\n 'access/{resourceType}/{resourceId}/permissions',\n 'access/{resourceType}/{resourceId}/permissions/{permissionName}',\n 'access/{resourceType}/{resourceId}/requests',\n 'access/{resourceType}/{resourceId}/requests/state',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/accept',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/decline',\n 'access/{resourceType}/{resourceId}/robots',\n 'access/{resourceType}/{resourceId}/robots/{robotId}',\n 'access/{resourceType}/{resourceId}/roles',\n 'access/{resourceType}/{resourceId}/roles/{roleName}',\n 'access/{resourceType}/{resourceId}/user-permissions/me',\n 'access/{resourceType}/{resourceId}/user-permissions/me/check',\n 'access/{resourceType}/{resourceId}/users',\n 'access/{resourceType}/{resourceId}/users/me',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles/{roleName}'\n ],\n slug: 'access-api',\n title: 'Access API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/actions/{dataset}'\n ],\n slug: 'actions',\n title: 'Actions API reference'\n },\n {\n defaultApiVersion: 'v2021-02-01',\n host: 'global',\n pathPatterns: [\n 'activity',\n 'activity/export/csv'\n ],\n slug: 'activity-log',\n title: 'Activity Log API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'agent/action/generate/{dataset}',\n 'agent/action/patch/{dataset}',\n 'agent/action/prompt/{dataset}',\n 'agent/action/transform/{dataset}',\n 'agent/action/translate/{dataset}'\n ],\n slug: 'agent-actions',\n title: 'Agent Actions'\n },\n {\n host: 'global',\n pathPatterns: [\n 'applications',\n 'applications/auto-update-version/{applicationId}',\n 'applications/dashboards',\n 'applications/dashboards/{dashboardId}',\n 'applications/dashboards/{dashboardId}/configs',\n 'applications/dashboards/{dashboardId}/configs/{configId}',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/embeddable',\n 'applications/{applicationId}/icon',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/interfaces/{interfaceId}/icon',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'organizations/{organizationId}/applications',\n 'organizations/{organizationId}/applications/{applicationId}',\n 'projects/{projectId}/applications',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n host: 'project',\n pathPatterns: [\n 'applications',\n 'applications/auto-update-version/{applicationId}',\n 'applications/dashboards',\n 'applications/dashboards/{dashboardId}',\n 'applications/dashboards/{dashboardId}/configs',\n 'applications/dashboards/{dashboardId}/configs/{configId}',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/embeddable',\n 'applications/{applicationId}/icon',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/interfaces/{interfaceId}/icon',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'organizations/{organizationId}/applications',\n 'organizations/{organizationId}/applications/{applicationId}',\n 'projects/{projectId}/applications',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n defaultApiVersion: 'v2024-06-24',\n host: 'project',\n pathPatterns: [\n 'assets/files/{dataset}',\n 'assets/files/{dataset}/from-url',\n 'assets/images/{dataset}',\n 'assets/images/{dataset}/from-url',\n 'assets/media-library-link/{dataset}'\n ],\n slug: 'assets',\n title: 'Assets API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/{datasetName}/backups',\n 'projects/{projectId}/datasets/{datasetName}/backups/{backupId}',\n 'projects/{projectId}/datasets/{datasetName}/settings/backups'\n ],\n slug: 'backups',\n title: 'Backups API reference'\n },\n {\n defaultApiVersion: 'v1',\n host: 'global',\n pathPatterns: [\n 'projects/{project_id}/datasets/{dataset_name}/assets/{asset_id}/purges',\n 'projects/{project_id}/datasets/{dataset_name}/purges'\n ],\n slug: 'cdn-cache-purge',\n title: 'CDN Cache Purge API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'global',\n pathPatterns: [\n 'collaboration/comments',\n 'collaboration/comments/listen',\n 'collaboration/comments/query',\n 'collaboration/comments/{id}',\n 'collaboration/comments/{id}/reactions',\n 'collaboration/comments/{id}/reactions/{shortName}'\n ],\n slug: 'comments-api',\n title: 'Comments API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'collaboration/comments',\n 'collaboration/comments/listen',\n 'collaboration/comments/query',\n 'collaboration/comments/{id}',\n 'collaboration/comments/{id}/reactions',\n 'collaboration/comments/{id}/reactions/{shortName}'\n ],\n slug: 'comments-api',\n title: 'Comments API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'global',\n pathPatterns: [\n 'agent/prompt',\n 'agent/{organizationId}/threads/{threadId}'\n ],\n slug: 'content-agent',\n title: 'Content Agent API reference'\n },\n {\n host: 'global',\n pathPatterns: [\n 'context/knowledge-bases',\n 'context/knowledge-bases/{knowledgeBaseId}',\n 'context/knowledge-bases/{knowledgeBaseId}/apply',\n 'context/knowledge-bases/{knowledgeBaseId}/build',\n 'context/knowledge-bases/{knowledgeBaseId}/build/cancel',\n 'context/knowledge-bases/{knowledgeBaseId}/discard',\n 'context/knowledge-bases/{knowledgeBaseId}/documents',\n 'context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}',\n 'context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}/content',\n 'context/knowledge-bases/{knowledgeBaseId}/entries/{entryPath}/rebuild',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions/check',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions/draft',\n 'context/knowledge-bases/{knowledgeBaseId}/instructions/{instructionId}',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/apply',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/dismiss',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/reopen',\n 'context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/resolve',\n 'context/knowledge-bases/{knowledgeBaseId}/jobs/{jobId}',\n 'context/knowledge-bases/{knowledgeBaseId}/sources',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}',\n 'context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/uploads',\n 'context/knowledge-bases/{knowledgeBaseId}/sync',\n 'context/organizations/{organizationId}/conversations/{threadId}',\n 'context/organizations/{organizationId}/mcp',\n 'context/organizations/{organizationId}/mcp/{mcpEndpoint}',\n 'context/organizations/{organizationId}/mcp/{mcpEndpoint}/initial-context',\n 'context/organizations/{organizationId}/mcp/{mcpEndpoint}/status'\n ],\n slug: 'context-api',\n title: 'Context API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/copy',\n 'projects/{projectId}/datasets/{dataset}/copy'\n ],\n slug: 'copy',\n title: 'Copy API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/doc/{dataset}/{documentId}'\n ],\n slug: 'doc',\n title: 'Doc API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'embeddings-index/query/{dataset}/{indexName}',\n 'embeddings-index/{dataset}',\n 'embeddings-index/{dataset}/{indexName}'\n ],\n slug: 'embeddings-index',\n title: 'Embeddings Index API reference (deprecated)'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/export/{dataset}'\n ],\n slug: 'export',\n title: 'Export API reference'\n },\n {\n host: 'global',\n pathPatterns: [\n 'functions',\n 'functions/durables/callback/{callbackId}/failure',\n 'functions/durables/callback/{callbackId}/success',\n 'functions/durables/{functionId}/executions',\n 'functions/durables/{functionId}/executions/{executionId}',\n 'functions/durables/{functionId}/executions/{executionId}/stop',\n 'functions/{functionId}',\n 'functions/{functionId}/envvars',\n 'functions/{functionId}/envvars/{envVarKey}',\n 'functions/{functionId}/invoke',\n 'functions/{functionId}/logs',\n 'functions/{functionId}/logs/stream'\n ],\n slug: 'functions-api',\n title: 'Functions API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/history/{dataset}/documents/{documentId}',\n 'data/history/{dataset}/transactions',\n 'data/history/{dataset}/transactions/{documentIds}'\n ],\n slug: 'history',\n title: 'History API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'jobs/{jobId}',\n 'jobs/{jobId}/listen'\n ],\n slug: 'jobs',\n title: 'Jobs API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/listen/{dataset}'\n ],\n slug: 'listen',\n title: 'Listen API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/live/events/{dataset}'\n ],\n slug: 'live',\n title: 'Live Content API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-09-09',\n host: 'project',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/mutate/{dataset}'\n ],\n slug: 'mutation',\n title: 'Mutation API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'projects',\n 'projects/{projectId}',\n 'projects/{projectId}/cors',\n 'projects/{projectId}/cors/{id}',\n 'projects/{projectId}/datasets',\n 'projects/{projectId}/datasets/copy',\n 'projects/{projectId}/datasets/{datasetName}/tags/{tagIdentifier}',\n 'projects/{projectId}/datasets/{name}',\n 'projects/{projectId}/datasets/{name}/copy',\n 'projects/{projectId}/datasets/{name}/settings/embeddings',\n 'projects/{projectId}/datasets/{name}/tags',\n 'projects/{projectId}/features',\n 'projects/{projectId}/permissions',\n 'projects/{projectId}/tags',\n 'projects/{projectId}/tags/{tagIdentifier}',\n 'projects/{projectId}/tokens',\n 'projects/{projectId}/tokens/{tokenId}',\n 'projects/{projectId}/users/{userId}'\n ],\n slug: 'projects-api',\n title: 'Projects API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/query/{dataset}'\n ],\n slug: 'query',\n title: 'Query API reference'\n },\n {\n defaultApiVersion: 'v2021-10-04',\n host: 'global',\n pathPatterns: [\n 'auth/organizations/{organizationId}/providers/{providerId}/projects/{projectId}/role-mappings',\n 'organizations/{organizationId}/acl',\n 'organizations/{organizationId}/acl/{sanityUserId}',\n 'organizations/{organizationId}/grants',\n 'projects/{projectId}/acl',\n 'projects/{projectId}/acl/{projectUserId}',\n 'projects/{projectId}/datasets/{datasetName}/acl',\n 'projects/{projectId}/datasets/{datasetName}/grants',\n 'projects/{projectId}/grants',\n 'projects/{projectId}/grants/{projectUserId}',\n 'projects/{projectId}/permissionResourceSchemas',\n 'projects/{projectId}/permissionResources',\n 'projects/{projectId}/permissionResources/{resourceId}',\n 'projects/{projectId}/roles',\n 'projects/{projectId}/roles/{roleName}'\n ],\n slug: 'roles',\n title: 'Roles API reference'\n },\n {\n defaultApiVersion: 'v2022-04-01',\n host: 'project',\n pathPatterns: [\n 'publish/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}/{scheduleId}',\n 'schedules/{projectId}/{dataset}/{scheduleId}/publish',\n 'unpublish/{projectId}/{dataset}'\n ],\n slug: 'scheduling',\n title: 'Scheduling API reference'\n },\n {\n defaultApiVersion: 'v2026-09-01',\n host: 'global',\n pathPatterns: [\n 'usage/{resourceType}/{resourceId}/history',\n 'usage/{resourceType}/{resourceId}/snapshot',\n 'usage/{resourceType}/{resourceId}/{scope}/history',\n 'usage/{resourceType}/{resourceId}/{scope}/snapshot'\n ],\n slug: 'usage-api',\n title: 'Usage API reference'\n },\n {\n defaultApiVersion: 'v2026-04-27',\n host: 'global',\n pathPatterns: [\n 'organizations/{organizationId}/attribute-definitions',\n 'organizations/{organizationId}/attribute-definitions/{key}',\n 'organizations/{organizationId}/users/me/attributes',\n 'organizations/{organizationId}/users/{sanityUserId}/attributes'\n ],\n slug: 'user-attributes',\n title: 'User attributes API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'hooks/projects/{projectId}',\n 'hooks/projects/{projectId}/attempts/{attemptId}',\n 'hooks/projects/{projectId}/{id}',\n 'hooks/projects/{projectId}/{id}/attempts',\n 'hooks/projects/{projectId}/{id}/messages',\n 'hooks/projects/{projectId}/{id}/messages/{messageId}/attempts'\n ],\n slug: 'webhooks',\n title: 'Webhooks API reference'\n }\n]\n"],"names":["apiRoutes","defaultApiVersion","host","pathPatterns","slug","title"],"mappings":"AAAA;;;;;;;CAOC,GAGD,OAAO,MAAMA,YAA6B;IACxC;QACEC,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;CACD,CAAA"}
|
|
@@ -28,7 +28,11 @@ function getRequestTag() {
|
|
|
28
28
|
}
|
|
29
29
|
return override;
|
|
30
30
|
}
|
|
31
|
+
// The response contains credentials and must never appear in verbose request logs.
|
|
31
32
|
const request = createRequester({
|
|
33
|
+
debug: {
|
|
34
|
+
verbose: false
|
|
35
|
+
},
|
|
32
36
|
httpErrors: false
|
|
33
37
|
});
|
|
34
38
|
function getProvisionApiBase() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/mintProject.ts"],"sourcesContent":["import {getCliToken} from '@sanity/cli-core/config'\nimport {subdebug} from '@sanity/cli-core/debug'\nimport {createRequester} from '@sanity/cli-core/request'\nimport {isStaging} from '@sanity/cli-core/util'\n\nimport {\n TERMS_OF_SERVICE_FALLBACK_NOTICE,\n TERMS_OF_SERVICE_FALLBACK_URL,\n} from '../util/mintProjectConstants.js'\n\nconst debug = subdebug('new:provision')\n\n/** Provision API version for minting unclaimed projects. */\nexport const PROVISION_API_VERSION = 'v2026-06-23'\n\n/**\n * Request tag identifying the caller to the provisioning funnel, using the same `?tag=` convention\n * as every other Sanity API request. `sanity new` is deliberately usable without an account, so a\n * mint often has no user to attribute — the tag names the tool instead, and is how synthetic\n * callers are kept out of mint-to-claim conversion.\n */\nexport const MINT_REQUEST_TAG = 'sanity.cli'\n\n/**\n * Overrides {@link MINT_REQUEST_TAG}. Internal plumbing for the scheduled smoke test, which mints\n * against production several times an hour and never claims; it sets `sanity.cli.smoketest` so\n * those mints can be excluded from reporting.\n */\nconst MINT_TAG_ENV_VAR = 'SANITY_CLI_MINT_TAG'\n\n/** Mirrors `@sanity/client`'s `requestTag` rule, which is what the API accepts. */\nconst TAG_PATTERN = /^[a-z0-9._-]{1,75}$/i\n\nfunction getRequestTag(): string {\n const override = process.env[MINT_TAG_ENV_VAR]\n if (!override) return MINT_REQUEST_TAG\n if (!TAG_PATTERN.test(override)) {\n // A malformed override would be dropped by the API anyway; fall back rather than mint\n // untagged, so the request is still attributable.\n debug('ignoring malformed %s value %j', MINT_TAG_ENV_VAR, override)\n return MINT_REQUEST_TAG\n }\n return override\n}\n\nconst request = createRequester({httpErrors: false})\n\nexport interface MintedProject {\n apiHost: string\n claimApiUrl: string\n claimToken: string\n claimUrl: string\n datasetName: string\n expiresAt: string\n resourceId: string\n /** Terms of Service accepted by using the project. Falls back to the bundled constants. */\n termsNotice: string\n termsUrl: string\n token: string\n}\n\nfunction getProvisionApiBase(): string {\n const override = process.env.SANITY_API_HOST\n if (override) return override.replace(/\\/$/u, '')\n return isStaging() ? 'https://api.sanity.work' : 'https://api.sanity.io'\n}\n\nfunction parseJsonBody(body: unknown): unknown {\n if (typeof body !== 'string') return body\n\n try {\n return JSON.parse(body)\n } catch {\n return undefined\n }\n}\n\nfunction getString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nfunction getTrimmedMessage(body: unknown): string | undefined {\n const data = parseJsonBody(body)\n if (!data || typeof data !== 'object' || Array.isArray(data)) return undefined\n const message = (data as Record<string, unknown>).message\n if (typeof message !== 'string') return undefined\n const trimmed = message.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction parseProvisionResponse(body: unknown): MintedProject {\n const data = parseJsonBody(body)\n const response =\n data && typeof data === 'object' && !Array.isArray(data)\n ? (data as Record<string, unknown>)\n : {}\n const links =\n response.links && typeof response.links === 'object' && !Array.isArray(response.links)\n ? (response.links as Record<string, unknown>)\n : {}\n const terms =\n response.terms && typeof response.terms === 'object' && !Array.isArray(response.terms)\n ? (response.terms as Record<string, unknown>)\n : {}\n\n const minted = {\n apiHost: getString(response.apiHost),\n claimApiUrl: getString(links.claimApiUrl),\n claimToken: getString(response.claimToken),\n claimUrl: getString(links.claimUrl),\n datasetName: getString(response.datasetName),\n expiresAt: getString(response.expiresAt),\n resourceId: getString(response.resourceId),\n token: getString(response.token),\n }\n const missing = Object.entries(minted)\n .filter(([, value]) => value === undefined)\n .map(([key]) => key)\n\n if (response.resourceType !== 'project') {\n missing.push('resourceType')\n }\n if (missing.length > 0) {\n throw new Error(`Project creation response is missing or invalid: ${missing.join(', ')}`)\n }\n\n return {\n ...(minted as Omit<MintedProject, 'termsNotice' | 'termsUrl'>),\n termsNotice: getString(terms.notice) ?? TERMS_OF_SERVICE_FALLBACK_NOTICE,\n termsUrl: getString(terms.url) ?? TERMS_OF_SERVICE_FALLBACK_URL,\n }\n}\n\n/**\n * Mint an unclaimed Sanity project through the public provision endpoint.\n *\n * Works logged out. Credentials, when there are any, are sent only so the mint can be attributed\n * and are dropped on rejection, so being logged in changes reporting and nothing else.\n */\nexport async function mintUnclaimedProject(options: {displayName: string}): Promise<MintedProject> {\n const displayName = options.displayName.trim()\n if (!displayName || displayName.length > 80) {\n throw new Error('Project name must be 1-80 characters.')\n }\n\n const url = new URL(`${PROVISION_API_VERSION}/provision`, getProvisionApiBase())\n url.searchParams.set('tag', getRequestTag())\n debug('minting unclaimed project at %s', url.toString())\n\n const mint = (token?: string) =>\n request({\n body: JSON.stringify({displayName, resourceType: 'project'}),\n headers: {\n 'Content-Type': 'application/json',\n ...(token ? {Authorization: `Bearer ${token}`} : {}),\n },\n method: 'POST',\n url: url.toString(),\n })\n\n const token = await getCliToken()\n let response = await mint(token)\n\n if (token && (response.status === 401 || response.status === 403)) {\n debug('stored credentials rejected (HTTP %d), minting anonymously', response.status)\n response = await mint()\n }\n\n if (response.status === 404) {\n throw new Error(\n 'Creating projects without an account is currently unavailable. Try again later, or run `sanity login` and `sanity init`.',\n )\n }\n if (response.status === 429) {\n throw new Error('Project creation rate limit reached for this machine. Try again later.')\n }\n if (response.status === 410) {\n throw new Error(\n getTrimmedMessage(response.text()) ?? 'Project creation failed (HTTP 410). Try again later.',\n )\n }\n if (response.status < 200 || response.status >= 300) {\n throw new Error(`Project creation failed (HTTP ${response.status}). Try again later.`)\n }\n\n return parseProvisionResponse(response.text())\n}\n"],"names":["getCliToken","subdebug","createRequester","isStaging","TERMS_OF_SERVICE_FALLBACK_NOTICE","TERMS_OF_SERVICE_FALLBACK_URL","debug","PROVISION_API_VERSION","MINT_REQUEST_TAG","MINT_TAG_ENV_VAR","TAG_PATTERN","getRequestTag","override","process","env","test","request","httpErrors","getProvisionApiBase","SANITY_API_HOST","replace","parseJsonBody","body","JSON","parse","undefined","getString","value","length","getTrimmedMessage","data","Array","isArray","message","trimmed","trim","parseProvisionResponse","response","links","terms","minted","apiHost","claimApiUrl","claimToken","claimUrl","datasetName","expiresAt","resourceId","token","missing","Object","entries","filter","map","key","resourceType","push","Error","join","termsNotice","notice","termsUrl","url","mintUnclaimedProject","options","displayName","URL","searchParams","set","toString","mint","stringify","headers","Authorization","method","status","text"],"mappings":"AAAA,SAAQA,WAAW,QAAO,0BAAyB;AACnD,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,eAAe,QAAO,2BAA0B;AACxD,SAAQC,SAAS,QAAO,wBAAuB;AAE/C,SACEC,gCAAgC,EAChCC,6BAA6B,QACxB,kCAAiC;AAExC,MAAMC,QAAQL,SAAS;AAEvB,0DAA0D,GAC1D,OAAO,MAAMM,wBAAwB,cAAa;AAElD;;;;;CAKC,GACD,OAAO,MAAMC,mBAAmB,aAAY;AAE5C;;;;CAIC,GACD,MAAMC,mBAAmB;AAEzB,iFAAiF,GACjF,MAAMC,cAAc;AAEpB,SAASC;IACP,MAAMC,WAAWC,QAAQC,GAAG,CAACL,iBAAiB;IAC9C,IAAI,CAACG,UAAU,OAAOJ;IACtB,IAAI,CAACE,YAAYK,IAAI,CAACH,WAAW;QAC/B,sFAAsF;QACtF,kDAAkD;QAClDN,MAAM,kCAAkCG,kBAAkBG;QAC1D,OAAOJ;IACT;IACA,OAAOI;AACT;AAEA,MAAMI,UAAUd,gBAAgB;IAACe,YAAY;AAAK;AAgBlD,SAASC;IACP,MAAMN,WAAWC,QAAQC,GAAG,CAACK,eAAe;IAC5C,IAAIP,UAAU,OAAOA,SAASQ,OAAO,CAAC,QAAQ;IAC9C,OAAOjB,cAAc,4BAA4B;AACnD;AAEA,SAASkB,cAAcC,IAAa;IAClC,IAAI,OAAOA,SAAS,UAAU,OAAOA;IAErC,IAAI;QACF,OAAOC,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ACnFtC,WAAW,MAAMiC;IACnB;IAEA,IAAIjC,SAASsC,MAAM,KAAK,KAAK;QAC3B,MAAM,IAAIlB,MACR;IAEJ;IACA,IAAIpB,SAASsC,MAAM,KAAK,KAAK;QAC3B,MAAM,IAAIlB,MAAM;IAClB;IACA,IAAIpB,SAASsC,MAAM,KAAK,KAAK;QAC3B,MAAM,IAAIlB,MACR5B,kBAAkBQ,SAASuC,IAAI,OAAO;IAE1C;IACA,IAAIvC,SAASsC,MAAM,GAAG,OAAOtC,SAASsC,MAAM,IAAI,KAAK;QACnD,MAAM,IAAIlB,MAAM,CAAC,8BAA8B,EAAEpB,SAASsC,MAAM,CAAC,mBAAmB,CAAC;IACvF;IAEA,OAAOvC,uBAAuBC,SAASuC,IAAI;AAC7C"}
|
|
1
|
+
{"version":3,"sources":["../../src/services/mintProject.ts"],"sourcesContent":["import {getCliToken} from '@sanity/cli-core/config'\nimport {subdebug} from '@sanity/cli-core/debug'\nimport {createRequester} from '@sanity/cli-core/request'\nimport {isStaging} from '@sanity/cli-core/util'\n\nimport {\n TERMS_OF_SERVICE_FALLBACK_NOTICE,\n TERMS_OF_SERVICE_FALLBACK_URL,\n} from '../util/mintProjectConstants.js'\n\nconst debug = subdebug('new:provision')\n\n/** Provision API version for minting unclaimed projects. */\nexport const PROVISION_API_VERSION = 'v2026-06-23'\n\n/**\n * Request tag identifying the caller to the provisioning funnel, using the same `?tag=` convention\n * as every other Sanity API request. `sanity new` is deliberately usable without an account, so a\n * mint often has no user to attribute — the tag names the tool instead, and is how synthetic\n * callers are kept out of mint-to-claim conversion.\n */\nexport const MINT_REQUEST_TAG = 'sanity.cli'\n\n/**\n * Overrides {@link MINT_REQUEST_TAG}. Internal plumbing for the scheduled smoke test, which mints\n * against production several times an hour and never claims; it sets `sanity.cli.smoketest` so\n * those mints can be excluded from reporting.\n */\nconst MINT_TAG_ENV_VAR = 'SANITY_CLI_MINT_TAG'\n\n/** Mirrors `@sanity/client`'s `requestTag` rule, which is what the API accepts. */\nconst TAG_PATTERN = /^[a-z0-9._-]{1,75}$/i\n\nfunction getRequestTag(): string {\n const override = process.env[MINT_TAG_ENV_VAR]\n if (!override) return MINT_REQUEST_TAG\n if (!TAG_PATTERN.test(override)) {\n // A malformed override would be dropped by the API anyway; fall back rather than mint\n // untagged, so the request is still attributable.\n debug('ignoring malformed %s value %j', MINT_TAG_ENV_VAR, override)\n return MINT_REQUEST_TAG\n }\n return override\n}\n\n// The response contains credentials and must never appear in verbose request logs.\nconst request = createRequester({debug: {verbose: false}, httpErrors: false})\n\nexport interface MintedProject {\n apiHost: string\n claimApiUrl: string\n claimToken: string\n claimUrl: string\n datasetName: string\n expiresAt: string\n resourceId: string\n /** Terms of Service accepted by using the project. Falls back to the bundled constants. */\n termsNotice: string\n termsUrl: string\n token: string\n}\n\nfunction getProvisionApiBase(): string {\n const override = process.env.SANITY_API_HOST\n if (override) return override.replace(/\\/$/u, '')\n return isStaging() ? 'https://api.sanity.work' : 'https://api.sanity.io'\n}\n\nfunction parseJsonBody(body: unknown): unknown {\n if (typeof body !== 'string') return body\n\n try {\n return JSON.parse(body)\n } catch {\n return undefined\n }\n}\n\nfunction getString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nfunction getTrimmedMessage(body: unknown): string | undefined {\n const data = parseJsonBody(body)\n if (!data || typeof data !== 'object' || Array.isArray(data)) return undefined\n const message = (data as Record<string, unknown>).message\n if (typeof message !== 'string') return undefined\n const trimmed = message.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction parseProvisionResponse(body: unknown): MintedProject {\n const data = parseJsonBody(body)\n const response =\n data && typeof data === 'object' && !Array.isArray(data)\n ? (data as Record<string, unknown>)\n : {}\n const links =\n response.links && typeof response.links === 'object' && !Array.isArray(response.links)\n ? (response.links as Record<string, unknown>)\n : {}\n const terms =\n response.terms && typeof response.terms === 'object' && !Array.isArray(response.terms)\n ? (response.terms as Record<string, unknown>)\n : {}\n\n const minted = {\n apiHost: getString(response.apiHost),\n claimApiUrl: getString(links.claimApiUrl),\n claimToken: getString(response.claimToken),\n claimUrl: getString(links.claimUrl),\n datasetName: getString(response.datasetName),\n expiresAt: getString(response.expiresAt),\n resourceId: getString(response.resourceId),\n token: getString(response.token),\n }\n const missing = Object.entries(minted)\n .filter(([, value]) => value === undefined)\n .map(([key]) => key)\n\n if (response.resourceType !== 'project') {\n missing.push('resourceType')\n }\n if (missing.length > 0) {\n throw new Error(`Project creation response is missing or invalid: ${missing.join(', ')}`)\n }\n\n return {\n ...(minted as Omit<MintedProject, 'termsNotice' | 'termsUrl'>),\n termsNotice: getString(terms.notice) ?? TERMS_OF_SERVICE_FALLBACK_NOTICE,\n termsUrl: getString(terms.url) ?? TERMS_OF_SERVICE_FALLBACK_URL,\n }\n}\n\n/**\n * Mint an unclaimed Sanity project through the public provision endpoint.\n *\n * Works logged out. Credentials, when there are any, are sent only so the mint can be attributed\n * and are dropped on rejection, so being logged in changes reporting and nothing else.\n */\nexport async function mintUnclaimedProject(options: {displayName: string}): Promise<MintedProject> {\n const displayName = options.displayName.trim()\n if (!displayName || displayName.length > 80) {\n throw new Error('Project name must be 1-80 characters.')\n }\n\n const url = new URL(`${PROVISION_API_VERSION}/provision`, getProvisionApiBase())\n url.searchParams.set('tag', getRequestTag())\n debug('minting unclaimed project at %s', url.toString())\n\n const mint = (token?: string) =>\n request({\n body: JSON.stringify({displayName, resourceType: 'project'}),\n headers: {\n 'Content-Type': 'application/json',\n ...(token ? {Authorization: `Bearer ${token}`} : {}),\n },\n method: 'POST',\n url: url.toString(),\n })\n\n const token = await getCliToken()\n let response = await mint(token)\n\n if (token && (response.status === 401 || response.status === 403)) {\n debug('stored credentials rejected (HTTP %d), minting anonymously', response.status)\n response = await mint()\n }\n\n if (response.status === 404) {\n throw new Error(\n 'Creating projects without an account is currently unavailable. Try again later, or run `sanity login` and `sanity init`.',\n )\n }\n if (response.status === 429) {\n throw new Error('Project creation rate limit reached for this machine. Try again later.')\n }\n if (response.status === 410) {\n throw new Error(\n getTrimmedMessage(response.text()) ?? 'Project creation failed (HTTP 410). Try again later.',\n )\n }\n if (response.status < 200 || response.status >= 300) {\n throw new Error(`Project creation failed (HTTP ${response.status}). Try again later.`)\n }\n\n return parseProvisionResponse(response.text())\n}\n"],"names":["getCliToken","subdebug","createRequester","isStaging","TERMS_OF_SERVICE_FALLBACK_NOTICE","TERMS_OF_SERVICE_FALLBACK_URL","debug","PROVISION_API_VERSION","MINT_REQUEST_TAG","MINT_TAG_ENV_VAR","TAG_PATTERN","getRequestTag","override","process","env","test","request","verbose","httpErrors","getProvisionApiBase","SANITY_API_HOST","replace","parseJsonBody","body","JSON","parse","undefined","getString","value","length","getTrimmedMessage","data","Array","isArray","message","trimmed","trim","parseProvisionResponse","response","links","terms","minted","apiHost","claimApiUrl","claimToken","claimUrl","datasetName","expiresAt","resourceId","token","missing","Object","entries","filter","map","key","resourceType","push","Error","join","termsNotice","notice","termsUrl","url","mintUnclaimedProject","options","displayName","URL","searchParams","set","toString","mint","stringify","headers","Authorization","method","status","text"],"mappings":"AAAA,SAAQA,WAAW,QAAO,0BAAyB;AACnD,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,eAAe,QAAO,2BAA0B;AACxD,SAAQC,SAAS,QAAO,wBAAuB;AAE/C,SACEC,gCAAgC,EAChCC,6BAA6B,QACxB,kCAAiC;AAExC,MAAMC,QAAQL,SAAS;AAEvB,0DAA0D,GAC1D,OAAO,MAAMM,wBAAwB,cAAa;AAElD;;;;;CAKC,GACD,OAAO,MAAMC,mBAAmB,aAAY;AAE5C;;;;CAIC,GACD,MAAMC,mBAAmB;AAEzB,iFAAiF,GACjF,MAAMC,cAAc;AAEpB,SAASC;IACP,MAAMC,WAAWC,QAAQC,GAAG,CAACL,iBAAiB;IAC9C,IAAI,CAACG,UAAU,OAAOJ;IACtB,IAAI,CAACE,YAAYK,IAAI,CAACH,WAAW;QAC/B,sFAAsF;QACtF,kDAAkD;QAClDN,MA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