sanity 5.0.0-next-major.14 → 5.0.0-next-major.20251210134624
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/bin/sanity +2 -1
- package/lib/_chunks-es/LiveQueries.js +1 -1
- package/lib/_chunks-es/LiveQueries.js.map +1 -1
- package/lib/_chunks-es/MenuGroup.js +3 -3
- package/lib/_chunks-es/MenuGroup.js.map +1 -1
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js +2 -2
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +54 -54
- package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -1
- package/lib/_chunks-es/QRCodeSVG.js +1 -1
- package/lib/_chunks-es/QRCodeSVG.js.map +1 -1
- package/lib/_chunks-es/StructureToolProvider.js +1 -1
- package/lib/_chunks-es/StructureToolProvider.js.map +1 -1
- package/lib/_chunks-es/VideoPlayer.js +1 -1
- package/lib/_chunks-es/VideoPlayer.js.map +1 -1
- package/lib/_chunks-es/ViteDevServerStopped.js +6 -6
- package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -1
- package/lib/_chunks-es/_internal.js +1 -1
- package/lib/_chunks-es/_internal.js.map +1 -1
- package/lib/_chunks-es/deployApiAction.js +1 -1
- package/lib/_chunks-es/deployApiAction.js.map +1 -1
- package/lib/_chunks-es/execScript.js +2 -1
- package/lib/_chunks-es/execScript.js.map +1 -1
- package/lib/_chunks-es/exportAssetsAction.js +1 -1
- package/lib/_chunks-es/exportAssetsAction.js.map +1 -1
- package/lib/_chunks-es/extractAction.js +2 -1
- package/lib/_chunks-es/extractAction.js.map +1 -1
- package/lib/_chunks-es/extractManifestAction.js +2 -1
- package/lib/_chunks-es/extractManifestAction.js.map +1 -1
- package/lib/_chunks-es/generate-help-url.esm.js +1 -1
- package/lib/_chunks-es/generate-help-url.esm.js.map +1 -1
- package/lib/_chunks-es/getGraphQLAPIs.js +2 -1
- package/lib/_chunks-es/getGraphQLAPIs.js.map +1 -1
- package/lib/_chunks-es/helpers.js +2 -1
- package/lib/_chunks-es/helpers.js.map +1 -1
- package/lib/_chunks-es/index2.js +1 -1
- package/lib/_chunks-es/index2.js.map +1 -1
- package/lib/_chunks-es/index3.js +8 -8
- package/lib/_chunks-es/index3.js.map +1 -1
- package/lib/_chunks-es/package.js +1 -1
- package/lib/_chunks-es/pane.js +140 -140
- package/lib/_chunks-es/pane.js.map +1 -1
- package/lib/_chunks-es/presentation.js +4 -4
- package/lib/_chunks-es/presentation.js.map +1 -1
- package/lib/_chunks-es/previewServer.js +2 -1
- package/lib/_chunks-es/previewServer.js.map +1 -1
- package/lib/_chunks-es/runtime.js +14 -13
- package/lib/_chunks-es/runtime.js.map +1 -1
- package/lib/_chunks-es/validateAction.js +2 -1
- package/lib/_chunks-es/validateAction.js.map +1 -1
- package/lib/_chunks-es/validateAction2.js +2 -1
- package/lib/_chunks-es/validateAction2.js.map +1 -1
- package/lib/_chunks-es/version.js +1 -1
- package/lib/_internal/cli/threads/validateDocuments.cjs +1 -1
- package/lib/_internal/cli/threads/validateDocuments.cjs.map +1 -1
- package/lib/_singletons.d.ts +82 -2
- package/lib/_singletons.js +6 -2
- package/lib/_singletons.js.map +1 -1
- package/lib/desk.d.ts +28 -2
- package/lib/index.d.ts +30 -1
- package/lib/index.js +3739 -3306
- package/lib/index.js.map +1 -1
- package/lib/presentation.d.ts +14 -1
- package/lib/structure.d.ts +14 -1
- package/package.json +34 -34
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import readPkgUp from "read-pkg-up";
|
|
5
6
|
import { hideBin } from "yargs/helpers";
|
|
6
7
|
import yargs from "yargs/yargs";
|
|
7
|
-
const __dirname$1 = path.dirname(
|
|
8
|
+
const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
async function parseCliFlags(args) {
|
|
9
10
|
return {
|
|
10
11
|
...await yargs(hideBin(args.argv || process.argv).slice(2)).option("with-user-token", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execScript.js","sources":["../../src/_internal/cli/actions/exec/execScript.ts"],"sourcesContent":["import {spawn} from 'node:child_process'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {type CliCommandAction, type CliCommandArguments} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\nimport {hideBin} from 'yargs/helpers'\nimport yargs from 'yargs/yargs'\n\nconst __dirname = path.dirname(
|
|
1
|
+
{"version":3,"file":"execScript.js","sources":["../../src/_internal/cli/actions/exec/execScript.ts"],"sourcesContent":["import {spawn} from 'node:child_process'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nimport {type CliCommandAction, type CliCommandArguments} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\nimport {hideBin} from 'yargs/helpers'\nimport yargs from 'yargs/yargs'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\ninterface ExecFlags {\n 'with-user-token'?: boolean\n 'mock-browser-env'?: boolean\n}\n\nasync function parseCliFlags(args: CliCommandArguments<ExecFlags>) {\n const flags = await yargs(hideBin(args.argv || process.argv).slice(2))\n .option('with-user-token', {type: 'boolean', default: false})\n .option('mock-browser-env', {type: 'boolean', default: false}).argv\n\n return {\n ...flags,\n script: args.argsWithoutOptions[0],\n }\n}\n\nconst execScript: CliCommandAction<ExecFlags> = async function execScript(args, context) {\n // Reparsing CLI flags for better control of binary flags\n const {withUserToken, mockBrowserEnv, script} = await parseCliFlags(args)\n const {workDir} = context\n\n const scriptPath = path.resolve(script || '')\n if (!script) {\n throw new Error('SCRIPT must be provided. `sanity exec <script>`')\n }\n\n if (!(await fs.stat(scriptPath).catch(() => false))) {\n throw new Error(`${scriptPath} does not exist`)\n }\n\n const sanityPkgPath = (await readPkgUp({cwd: __dirname}))?.path\n if (!sanityPkgPath) {\n throw new Error('Unable to resolve `sanity` module root')\n }\n\n const sanityDir = path.dirname(sanityPkgPath)\n const threadsDir = path.join(sanityDir, 'lib', '_internal', 'cli', 'threads')\n const esbuildPath = path.join(threadsDir, 'esbuild.cjs')\n const browserEnvPath = path.join(threadsDir, 'registerBrowserEnv.cjs')\n const configClientPath = path.join(threadsDir, 'configClient.cjs')\n\n if (!(await fs.stat(esbuildPath).catch(() => false))) {\n throw new Error('`sanity` module build error: missing threads')\n }\n\n const baseArgs = mockBrowserEnv ? ['-r', browserEnvPath] : ['-r', esbuildPath]\n const tokenArgs = withUserToken ? ['-r', configClientPath] : []\n\n const nodeArgs = [...baseArgs, ...tokenArgs, scriptPath, ...args.extraArguments]\n\n const proc = spawn(process.argv[0], nodeArgs, {\n stdio: 'inherit',\n env: {\n ...process.env,\n SANITY_BASE_PATH: workDir,\n },\n })\n proc.on('close', process.exit)\n}\n\nexport default execScript\n"],"names":["__dirname","path","dirname","fileURLToPath","import","url","parseCliFlags","args","yargs","hideBin","argv","process","slice","option","type","default","script","argsWithoutOptions","execScript","context","withUserToken","mockBrowserEnv","workDir","scriptPath","resolve","Error","fs","stat","catch","sanityPkgPath","readPkgUp","cwd","sanityDir","threadsDir","join","esbuildPath","browserEnvPath","configClientPath","baseArgs","tokenArgs","nodeArgs","extraArguments","spawn","stdio","env","SANITY_BASE_PATH","on","exit"],"mappings":";;;;;;;AAUA,MAAMA,cAAYC,KAAKC,QAAQC,cAAcC,YAAYC,GAAG,CAAC;AAO7D,eAAeC,cAAcC,MAAsC;AAKjE,SAAO;AAAA,IACL,GALY,MAAMC,MAAMC,QAAQF,KAAKG,QAAQC,QAAQD,IAAI,EAAEE,MAAM,CAAC,CAAC,EAClEC,OAAO,mBAAmB;AAAA,MAACC,MAAM;AAAA,MAAWC,SAAS;AAAA,IAAA,CAAM,EAC3DF,OAAO,oBAAoB;AAAA,MAAC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AQD,KAAK,CAAC,GAAG8B,UAAU;AAAA,IAC5CG,OAAO;AAAA,IACPC,KAAK;AAAA,MACH,GAAGjC,QAAQiC;AAAAA,MACXC,kBAAkBvB;AAAAA,IAAAA;AAAAA,EACpB,CACD,EACIwB,GAAG,SAASnC,QAAQoC,IAAI;AAC/B;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import exportDataset from "@sanity/export";
|
|
2
|
+
import { exportDataset } from "@sanity/export";
|
|
3
3
|
import { determineTargetMediaLibrary, MINIMUM_API_VERSION } from "./determineTargetMediaLibrary.js";
|
|
4
4
|
const DEFAULT_CONCURRENCY = 6, exportAssetsAction = async (args, context) => {
|
|
5
5
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportAssetsAction.js","sources":["../../src/_internal/cli/actions/media/exportAssetsAction.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliCommandAction} from '@sanity/cli'\nimport exportDataset from '@sanity/export'\n\nimport {type ProgressEvent} from '../../commands/dataset/exportDatasetCommand'\nimport {MINIMUM_API_VERSION} from './constants'\nimport {determineTargetMediaLibrary} from './lib/determineTargetMediaLibrary'\n\ninterface ExportAssetsFlags {\n 'media-library-id'?: string\n}\n\nconst DEFAULT_CONCURRENCY = 6\n\nconst exportAssetsAction: CliCommandAction<ExportAssetsFlags> = async (args, context) => {\n const {apiClient, output, chalk} = context\n\n const mediaLibraryId =\n args.extOptions['media-library-id'] ?? (await determineTargetMediaLibrary(context))\n\n const client = apiClient().withConfig({\n apiVersion: MINIMUM_API_VERSION,\n requestTagPrefix: 'sanity.mediaLibraryCli.export',\n })\n\n const outputPath = path.join(\n process.cwd(),\n `media-library-${mediaLibraryId}-${Date.now()}.tar.gz`,\n )\n\n output.print()\n output.print(`Exporting from media library: ${chalk.bold(mediaLibraryId)}`)\n output.print(`Exporting to path: ${chalk.bold(outputPath)}`)\n output.print()\n\n let currentStep = 'Beginning export…'\n let spinner = output.spinner(currentStep).start()\n\n try {\n await exportDataset({\n client,\n mediaLibraryId,\n outputPath,\n drafts: false,\n types: ['sanity.asset'],\n assetConcurrency: DEFAULT_CONCURRENCY,\n mode: 'stream',\n onProgress: (progress: ProgressEvent) => {\n if (progress.step !== currentStep) {\n spinner.succeed()\n spinner = output.spinner(progress.step).start()\n } else if (progress.step === currentStep && progress.update) {\n spinner.text = `${progress.step} (${progress.current}/${progress.total})`\n }\n currentStep = progress.step\n },\n // The `assets.json` assets map is not required for Media Library archives, because the\n // import process reads asset files directly from the archive.\n assetsMap: false,\n // The documents listed in `data.ndjson` are only used for recording aspect data. If there\n // is no aspect data, the document can safely be omitted.\n filterDocument: (doc: unknown) => {\n if (typeof doc !== 'object' || doc === null || !('aspects' in doc)) {\n return false\n }\n\n // Filter out video assets (we dont have access to the raw video file for now)\n if ('assetType' in doc && doc.assetType === 'sanity.videoAsset') {\n return false\n }\n\n return (\n typeof doc.aspects === 'object' &&\n doc.aspects !== null &&\n Object.keys(doc.aspects).length !== 0\n )\n },\n // Media Library archives only record asset aspect data. All other data can be safely\n // ommitted.\n transformDocument: (doc: unknown) => {\n if (\n typeof doc !== 'object' ||\n doc === null ||\n !('currentVersion' in doc) ||\n !('aspects' in doc)\n ) {\n return doc\n }\n\n if (\n typeof doc.currentVersion !== 'object' ||\n doc.currentVersion === null ||\n !('_ref' in doc.currentVersion) ||\n typeof doc.currentVersion._ref !== 'string'\n ) {\n return doc\n }\n\n // Determine the asset's path inside the archive: either \"images\" or \"files\".\n const pathPrefix = [doc.currentVersion._ref.split('-')[0], 's'].join('')\n\n return {\n filename: [pathPrefix, generateFilename(doc.currentVersion._ref)].join('/'),\n aspects: doc.aspects,\n }\n },\n })\n } catch (error) {\n spinner.fail(`Failed to export media library`)\n throw error\n }\n\n spinner.succeed(`Exported media library to ${chalk.bold(outputPath)}`)\n}\n\nexport default exportAssetsAction\n\nfunction generateFilename(assetId: string): string {\n const [, , asset, ext] = assetId.match(/^(image|file)-(.*?)(-[a-z]+)?$/) || []\n const extension = (ext || 'bin').replace(/^-/, '')\n return asset ? `${asset}.${extension}` : `${assetId}.bin`\n}\n"],"names":["DEFAULT_CONCURRENCY","exportAssetsAction","args","context","apiClient","output","chalk","mediaLibraryId","extOptions","determineTargetMediaLibrary","client","withConfig","apiVersion","MINIMUM_API_VERSION","requestTagPrefix","outputPath","path","join","process","cwd","Date","now","print","bold","currentStep","spinner","start","exportDataset","drafts","types","assetConcurrency","mode","onProgress","progress","step","succeed","update","text","current","total","assetsMap","filterDocument","doc","assetType","aspects","Object","keys","length","transformDocument","currentVersion","_ref","filename","split","generateFilename","error","fail","assetId","asset","ext","match","extension","replace"],"mappings":";;;AAaA,MAAMA,sBAAsB,GAEtBC,qBAA0D,OAAOC,MAAMC,YAAY;AACvF,QAAM;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,EAAAA,IAASH,SAE7BI,iBACJL,KAAKM,WAAW,kBAAkB,KAAM,MAAMC,4BAA4BN,OAAO,GAE7EO,SAASN,UAAAA,EAAYO,WAAW;AAAA,IACpCC,YAAYC;AAAAA,IACZC,kBAAkB;AAAA,EAAA,CACnB,GAEKC,aAAaC,KAAKC,KACtBC,QAAQC,IAAAA,GACR,iBAAiBZ,cAAc,IAAIa,KAAKC,IAAAA,CAAK,SAC/C;AAEAhB,SAAOiB,SACPjB,OAAOiB,MAAM,iCAAiChB,MAAMiB,KAAKhB,cAAc,CAAC,EAAE,GAC1EF,OAAOiB,MAAM,sBAAsBhB,MAAMiB,KAAKR,UAAU,CAAC,EAAE,GAC3DV,OAAOiB,MAAAA;AAEP,MAAIE,cAAc,0BACdC,UAAUpB,OAAOoB,QAAQD,WAAW,EAAEE,MAAAA;AAE1C,MAAI;AACF,UAAMC,cAAc;AAAA,MAClBjB;AAAAA,MACAH;AAAAA,MACAQ;AAAAA,MACAa,QAAQ;AAAA,MACRC,OAAO,CAAC,cAAc;AAAA,MACtBC,kBAAkB9B;AAAAA,MAClB+B,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A,EAAKC,OAAOC,GAAG,IAAIF,QAAQG,MAAM,gCAAgC,KAAK,CAAA,GACtEC,aAAaF,OAAO,OAAOG,QAAQ,MAAM,EAAE;AACjD,SAAOJ,QAAQ,GAAGA,KAAK,IAAIG,SAAS,KAAK,GAAGJ,OAAO;AACrD;"}
|
|
1
|
+
{"version":3,"file":"exportAssetsAction.js","sources":["../../src/_internal/cli/actions/media/exportAssetsAction.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliCommandAction} from '@sanity/cli'\nimport {exportDataset} from '@sanity/export'\n\nimport {type ProgressEvent} from '../../commands/dataset/exportDatasetCommand'\nimport {MINIMUM_API_VERSION} from './constants'\nimport {determineTargetMediaLibrary} from './lib/determineTargetMediaLibrary'\n\ninterface ExportAssetsFlags {\n 'media-library-id'?: string\n}\n\nconst DEFAULT_CONCURRENCY = 6\n\nconst exportAssetsAction: CliCommandAction<ExportAssetsFlags> = async (args, context) => {\n const {apiClient, output, chalk} = context\n\n const mediaLibraryId =\n args.extOptions['media-library-id'] ?? (await determineTargetMediaLibrary(context))\n\n const client = apiClient().withConfig({\n apiVersion: MINIMUM_API_VERSION,\n requestTagPrefix: 'sanity.mediaLibraryCli.export',\n })\n\n const outputPath = path.join(\n process.cwd(),\n `media-library-${mediaLibraryId}-${Date.now()}.tar.gz`,\n )\n\n output.print()\n output.print(`Exporting from media library: ${chalk.bold(mediaLibraryId)}`)\n output.print(`Exporting to path: ${chalk.bold(outputPath)}`)\n output.print()\n\n let currentStep = 'Beginning export…'\n let spinner = output.spinner(currentStep).start()\n\n try {\n await exportDataset({\n client,\n mediaLibraryId,\n outputPath,\n drafts: false,\n types: ['sanity.asset'],\n assetConcurrency: DEFAULT_CONCURRENCY,\n mode: 'stream',\n onProgress: (progress: ProgressEvent) => {\n if (progress.step !== currentStep) {\n spinner.succeed()\n spinner = output.spinner(progress.step).start()\n } else if (progress.step === currentStep && progress.update) {\n spinner.text = `${progress.step} (${progress.current}/${progress.total})`\n }\n currentStep = progress.step\n },\n // The `assets.json` assets map is not required for Media Library archives, because the\n // import process reads asset files directly from the archive.\n assetsMap: false,\n // The documents listed in `data.ndjson` are only used for recording aspect data. If there\n // is no aspect data, the document can safely be omitted.\n filterDocument: (doc: unknown) => {\n if (typeof doc !== 'object' || doc === null || !('aspects' in doc)) {\n return false\n }\n\n // Filter out video assets (we dont have access to the raw video file for now)\n if ('assetType' in doc && doc.assetType === 'sanity.videoAsset') {\n return false\n }\n\n return (\n typeof doc.aspects === 'object' &&\n doc.aspects !== null &&\n Object.keys(doc.aspects).length !== 0\n )\n },\n // Media Library archives only record asset aspect data. All other data can be safely\n // ommitted.\n transformDocument: (doc: unknown) => {\n if (\n typeof doc !== 'object' ||\n doc === null ||\n !('currentVersion' in doc) ||\n !('aspects' in doc)\n ) {\n return doc\n }\n\n if (\n typeof doc.currentVersion !== 'object' ||\n doc.currentVersion === null ||\n !('_ref' in doc.currentVersion) ||\n typeof doc.currentVersion._ref !== 'string'\n ) {\n return doc\n }\n\n // Determine the asset's path inside the archive: either \"images\" or \"files\".\n const pathPrefix = [doc.currentVersion._ref.split('-')[0], 's'].join('')\n\n return {\n filename: [pathPrefix, generateFilename(doc.currentVersion._ref)].join('/'),\n aspects: doc.aspects,\n }\n },\n })\n } catch (error) {\n spinner.fail(`Failed to export media library`)\n throw error\n }\n\n spinner.succeed(`Exported media library to ${chalk.bold(outputPath)}`)\n}\n\nexport default exportAssetsAction\n\nfunction generateFilename(assetId: string): string {\n const [, , asset, ext] = assetId.match(/^(image|file)-(.*?)(-[a-z]+)?$/) || []\n const extension = (ext || 'bin').replace(/^-/, '')\n return asset ? `${asset}.${extension}` : `${assetId}.bin`\n}\n"],"names":["DEFAULT_CONCURRENCY","exportAssetsAction","args","context","apiClient","output","chalk","mediaLibraryId","extOptions","determineTargetMediaLibrary","client","withConfig","apiVersion","MINIMUM_API_VERSION","requestTagPrefix","outputPath","path","join","process","cwd","Date","now","print","bold","currentStep","spinner","start","exportDataset","drafts","types","assetConcurrency","mode","onProgress","progress","step","succeed","update","text","current","total","assetsMap","filterDocument","doc","assetType","aspects","Object","keys","length","transformDocument","currentVersion","_ref","filename","split","generateFilename","error","fail","assetId","asset","ext","match","extension","replace"],"mappings":";;;AAaA,MAAMA,sBAAsB,GAEtBC,qBAA0D,OAAOC,MAAMC,YAAY;AACvF,QAAM;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,EAAAA,IAASH,SAE7BI,iBACJL,KAAKM,WAAW,kBAAkB,KAAM,MAAMC,4BAA4BN,OAAO,GAE7EO,SAASN,UAAAA,EAAYO,WAAW;AAAA,IACpCC,YAAYC;AAAAA,IACZC,kBAAkB;AAAA,EAAA,CACnB,GAEKC,aAAaC,KAAKC,KACtBC,QAAQC,IAAAA,GACR,iBAAiBZ,cAAc,IAAIa,KAAKC,IAAAA,CAAK,SAC/C;AAEAhB,SAAOiB,SACPjB,OAAOiB,MAAM,iCAAiChB,MAAMiB,KAAKhB,cAAc,CAAC,EAAE,GAC1EF,OAAOiB,MAAM,sBAAsBhB,MAAMiB,KAAKR,UAAU,CAAC,EAAE,GAC3DV,OAAOiB,MAAAA;AAEP,MAAIE,cAAc,0BACdC,UAAUpB,OAAOoB,QAAQD,WAAW,EAAEE,MAAAA;AAE1C,MAAI;AACF,UAAMC,cAAc;AAAA,MAClBjB;AAAAA,MACAH;AAAAA,MACAQ;AAAAA,MACAa,QAAQ;AAAA,MACRC,OAAO,CAAC,cAAc;AAAA,MACtBC,kBAAkB9B;AAAAA,MAClB+B,MAAM;AAAA,MACNC,YAAaC,CAAAA,aAA4B;AACnCA,iBAASC,SAASV,eACpBC,QAAQU,WACRV,UAAUpB,OAAOoB,QAAQQ,SAASC,IAAI,EAAER,MAAAA,KAC/BO,SAASC,SAASV,eAAeS,SAASG,WACnDX,QAAQY,OAAO,GAAGJ,SAASC,IAAI,KAAKD,SAASK,OAAO,IAAIL,SAASM,KAAK,MAExEf,cAAcS,SAASC;AAAAA,MACzB;AAAA;AAA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
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { Worker } from "node:worker_threads";
|
|
4
5
|
import readPkgUp from "read-pkg-up";
|
|
5
6
|
import { defineTrace } from "@sanity/telemetry";
|
|
@@ -7,7 +8,7 @@ const SchemaExtractedTrace = defineTrace({
|
|
|
7
8
|
name: "Schema Extracted",
|
|
8
9
|
version: 0,
|
|
9
10
|
description: "Trace emitted when extracting schema"
|
|
10
|
-
}), __dirname$1 = dirname(
|
|
11
|
+
}), __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
11
12
|
async function extractAction(args, {
|
|
12
13
|
workDir,
|
|
13
14
|
output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractAction.js","sources":["../../src/_internal/cli/actions/schema/extractSchema.telemetry.ts","../../src/_internal/cli/actions/schema/extractAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\ninterface SchemaExtractedTraceAttrubutes {\n schemaAllTypesCount: number\n schemaDocumentTypesCount: number\n schemaTypesCount: number\n\n enforceRequiredFields: boolean\n schemaFormat: string\n}\n\nexport const SchemaExtractedTrace = defineTrace<SchemaExtractedTraceAttrubutes>({\n name: 'Schema Extracted',\n version: 0,\n description: 'Trace emitted when extracting schema',\n})\n","import {writeFile} from 'node:fs/promises'\nimport {dirname, join} from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\n\nimport {\n type ExtractSchemaWorkerData,\n type ExtractSchemaWorkerResult,\n} from '../../threads/extractSchema'\nimport {SchemaExtractedTrace} from './extractSchema.telemetry'\n\nconst __dirname = dirname(
|
|
1
|
+
{"version":3,"file":"extractAction.js","sources":["../../src/_internal/cli/actions/schema/extractSchema.telemetry.ts","../../src/_internal/cli/actions/schema/extractAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\ninterface SchemaExtractedTraceAttrubutes {\n schemaAllTypesCount: number\n schemaDocumentTypesCount: number\n schemaTypesCount: number\n\n enforceRequiredFields: boolean\n schemaFormat: string\n}\n\nexport const SchemaExtractedTrace = defineTrace<SchemaExtractedTraceAttrubutes>({\n name: 'Schema Extracted',\n version: 0,\n description: 'Trace emitted when extracting schema',\n})\n","import {writeFile} from 'node:fs/promises'\nimport {dirname, join} from 'node:path'\nimport {fileURLToPath} from 'node:url'\nimport {Worker} from 'node:worker_threads'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\n\nimport {\n type ExtractSchemaWorkerData,\n type ExtractSchemaWorkerResult,\n} from '../../threads/extractSchema'\nimport {SchemaExtractedTrace} from './extractSchema.telemetry'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\ninterface ExtractFlags {\n 'workspace'?: string\n 'path'?: string\n 'enforce-required-fields'?: boolean\n 'format'?: 'groq-type-nodes' | string\n}\n\nexport type SchemaValidationFormatter = (result: ExtractSchemaWorkerResult) => string\n\nexport default async function extractAction(\n args: CliCommandArguments<ExtractFlags>,\n {workDir, output, telemetry}: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n const formatFlag = flags.format || 'groq-type-nodes'\n const enforceRequiredFields = flags['enforce-required-fields'] || false\n\n const rootPkgPath = readPkgUp.sync({cwd: __dirname})?.path\n if (!rootPkgPath) {\n throw new Error('Could not find root directory for `sanity` package')\n }\n\n const workerPath = join(\n dirname(rootPkgPath),\n 'lib',\n '_internal',\n 'cli',\n 'threads',\n 'extractSchema.cjs',\n )\n\n const spinner = output\n .spinner({})\n .start(\n enforceRequiredFields\n ? 'Extracting schema, with enforced required fields'\n : 'Extracting schema',\n )\n\n const trace = telemetry.trace(SchemaExtractedTrace)\n trace.start()\n\n const worker = new Worker(workerPath, {\n workerData: {\n workDir,\n workspaceName: flags.workspace,\n enforceRequiredFields,\n format: formatFlag,\n } satisfies ExtractSchemaWorkerData,\n env: process.env,\n })\n\n try {\n const {schema} = await new Promise<ExtractSchemaWorkerResult>((resolve, reject) => {\n worker.addListener('message', resolve)\n worker.addListener('error', reject)\n })\n\n trace.log({\n schemaAllTypesCount: schema.length,\n schemaDocumentTypesCount: schema.filter((type) => type.type === 'document').length,\n schemaTypesCount: schema.filter((type) => type.type === 'type').length,\n enforceRequiredFields,\n schemaFormat: formatFlag,\n })\n\n const path = flags.path || join(process.cwd(), 'schema.json')\n\n spinner.text = `Writing schema to ${path}`\n\n await writeFile(path, `${JSON.stringify(schema, null, 2)}\\n`)\n\n trace.complete()\n\n spinner.succeed(\n enforceRequiredFields\n ? `Extracted schema to ${path} with enforced required fields`\n : `Extracted schema to ${path}`,\n )\n } catch (err) {\n trace.error(err)\n spinner.fail(\n enforceRequiredFields\n ? 'Failed to extract schema, with enforced required fields'\n : 'Failed to extract schema',\n )\n throw err\n }\n}\n"],"names":["SchemaExtractedTrace","defineTrace","name","version","description","__dirname","dirname","fileURLToPath","import","url","extractAction","args","workDir","output","telemetry","flags","extOptions","formatFlag","format","enforceRequiredFields","rootPkgPath","readPkgUp","sync","cwd","path","Error","workerPath","join","spinner","start","trace","worker","Worker","workerData","workspaceName","workspace","env","process","schema","Promise","resolve","reject","addListener","log","schemaAllTypesCount","length","schemaDocumentTypesCount","filter","type","schemaTypesCount","schemaFormat","text","writeFile","JSON","stringify","complete","succeed","err","error","fail"],"mappings":";;;;;;AAWO,MAAMA,uBAAuBC,YAA4C;AAAA,EAC9EC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC,GCDKC,cAAYC,QAAQC,cAAcC,YAAYC,GAAG,CAAC;AAWxD,eAA8BC,cAC5BC,MACA;AAAA,EAACC;AAAAA,EAASC;AAAAA,EAAQC;AAA4B,GAC/B;AACf,QAAMC,QAAQJ,KAAKK,YACbC,aAAaF,MAAMG,UAAU,mBAC7BC,wBAAwBJ,MAAM,yBAAyB,KAAK,IAE5DK,cAAcC,UAAUC,KAAK;AAAA,IAACC,KAAKlB;AAAAA,EAAAA,CAAU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AAA,MAAM4B,MAAMD,GAAG,GACf7B,QAAQ+B,KACNxC,wBACI,4DACA,0BACN,GACMsC;AAAAA,EACR;AACF;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import { resolve, join, dirname } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { Worker } from "node:worker_threads";
|
|
5
6
|
import { minutesToMilliseconds } from "date-fns";
|
|
6
7
|
import readPkgUp from "read-pkg-up";
|
|
7
8
|
import { getTimer, readModuleVersion } from "./timing.js";
|
|
8
|
-
const __dirname$1 = dirname(
|
|
9
|
+
const __dirname$1 = dirname(fileURLToPath(import.meta.url)), MANIFEST_FILENAME = "create-manifest.json", SCHEMA_FILENAME_SUFFIX = ".create-schema.json", TOOLS_FILENAME_SUFFIX = ".create-tools.json", FEATURE_ENABLED_ENV_NAME = "SANITY_CLI_EXTRACT_MANIFEST_ENABLED", EXTRACT_MANIFEST_ENABLED = process.env[FEATURE_ENABLED_ENV_NAME] !== "false", EXTRACT_MANIFEST_LOG_ERRORS = process.env.SANITY_CLI_EXTRACT_MANIFEST_LOG_ERRORS === "true", CREATE_TIMER = "create-manifest", EXTRACT_TASK_TIMEOUT_MS = minutesToMilliseconds(2);
|
|
9
10
|
async function extractManifestSafe(args, context) {
|
|
10
11
|
if (EXTRACT_MANIFEST_ENABLED)
|
|
11
12
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractManifestAction.js","sources":["../../src/_internal/cli/actions/manifest/extractManifestAction.ts"],"sourcesContent":["import {createHash} from 'node:crypto'\nimport {mkdir, writeFile} from 'node:fs/promises'\nimport {dirname, join, resolve} from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport {minutesToMilliseconds} from 'date-fns'\nimport readPkgUp from 'read-pkg-up'\n\nimport {\n type CreateManifest,\n type CreateWorkspaceManifest,\n type ManifestWorkspaceFile,\n} from '../../../manifest/manifestTypes'\nimport {type ExtractManifestWorkerData} from '../../threads/extractManifest'\nimport {readModuleVersion} from '../../util/readModuleVersion'\nimport {getTimer} from '../../util/timing'\n\nconst __dirname = dirname(new URL(import.meta.url).pathname)\n\nexport const MANIFEST_FILENAME = 'create-manifest.json'\nconst SCHEMA_FILENAME_SUFFIX = '.create-schema.json'\nconst TOOLS_FILENAME_SUFFIX = '.create-tools.json'\n\n/** Escape-hatch env flags to change action behavior */\nconst FEATURE_ENABLED_ENV_NAME = 'SANITY_CLI_EXTRACT_MANIFEST_ENABLED'\nconst EXTRACT_MANIFEST_ENABLED = process.env[FEATURE_ENABLED_ENV_NAME] !== 'false'\nconst EXTRACT_MANIFEST_LOG_ERRORS = process.env.SANITY_CLI_EXTRACT_MANIFEST_LOG_ERRORS === 'true'\n\nconst CREATE_TIMER = 'create-manifest'\n\nconst EXTRACT_TASK_TIMEOUT_MS = minutesToMilliseconds(2)\n\nconst EXTRACT_FAILURE_MESSAGE =\n \"↳ Couldn't extract manifest file. Sanity Create will not be available for the studio.\\n\" +\n ` Disable this message with ${FEATURE_ENABLED_ENV_NAME}=false`\n\nexport interface ExtractManifestFlags {\n path?: string\n}\n\n/**\n * This function will never throw.\n * @returns `undefined` if extract succeeded - caught error if it failed\n */\nexport async function extractManifestSafe(\n args: CliCommandArguments<ExtractManifestFlags>,\n context: CliCommandContext,\n): Promise<Error | undefined> {\n if (!EXTRACT_MANIFEST_ENABLED) {\n return undefined\n }\n\n try {\n await extractManifest(args, context)\n return undefined\n } catch (err) {\n if (EXTRACT_MANIFEST_LOG_ERRORS) {\n context.output.error(err)\n }\n return err\n }\n}\n\nasync function extractManifest(\n args: CliCommandArguments<ExtractManifestFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {output, workDir} = context\n\n const flags = args.extOptions\n const defaultOutputDir = resolve(join(workDir, 'dist'))\n\n const outputDir = resolve(defaultOutputDir)\n const defaultStaticPath = join(outputDir, 'static')\n\n const staticPath = flags.path ?? defaultStaticPath\n\n const path = join(staticPath, MANIFEST_FILENAME)\n\n const rootPkgPath = readPkgUp.sync({cwd: __dirname})?.path\n if (!rootPkgPath) {\n throw new Error('Could not find root directory for `sanity` package')\n }\n\n const timer = getTimer()\n timer.start(CREATE_TIMER)\n const spinner = output.spinner({}).start('Extracting manifest')\n\n try {\n const workspaceManifests = await getWorkspaceManifests({rootPkgPath, workDir})\n await mkdir(staticPath, {recursive: true})\n\n const workspaceFiles = await writeWorkspaceFiles(workspaceManifests, staticPath)\n\n const manifest: CreateManifest = {\n /**\n * Version history:\n * 1: Initial release.\n * 2: Added tools file.\n * 3. Added studioVersion field.\n */\n version: 3,\n createdAt: new Date().toISOString(),\n workspaces: workspaceFiles,\n studioVersion: await readModuleVersion(workDir, 'sanity'),\n }\n\n await writeFile(path, JSON.stringify(manifest, null, 2))\n const manifestDuration = timer.end(CREATE_TIMER)\n\n spinner.succeed(`Extracted manifest (${manifestDuration.toFixed()}ms)`)\n } catch (err) {\n spinner.fail(err.message)\n throw err\n }\n}\n\nasync function getWorkspaceManifests({\n rootPkgPath,\n workDir,\n}: {\n rootPkgPath: string\n workDir: string\n}): Promise<CreateWorkspaceManifest[]> {\n const workerPath = join(\n dirname(rootPkgPath),\n 'lib',\n '_internal',\n 'cli',\n 'threads',\n 'extractManifest.cjs',\n )\n\n const worker = new Worker(workerPath, {\n workerData: {workDir} satisfies ExtractManifestWorkerData,\n env: process.env,\n })\n\n let timeout = false\n const timeoutId = setTimeout(() => {\n timeout = true\n void worker.terminate()\n }, EXTRACT_TASK_TIMEOUT_MS)\n\n try {\n return await new Promise<CreateWorkspaceManifest[]>((resolveWorkspaces, reject) => {\n const buffer: CreateWorkspaceManifest[] = []\n worker.addListener('message', (message) => buffer.push(message))\n worker.addListener('exit', (exitCode) => {\n if (exitCode === 0) {\n resolveWorkspaces(buffer)\n } else if (timeout) {\n reject(new Error(`Extract manifest was aborted after ${EXTRACT_TASK_TIMEOUT_MS}ms`))\n }\n })\n worker.addListener('error', reject)\n })\n } finally {\n clearTimeout(timeoutId)\n }\n}\n\nfunction writeWorkspaceFiles(\n manifestWorkspaces: CreateWorkspaceManifest[],\n staticPath: string,\n): Promise<ManifestWorkspaceFile[]> {\n const output = manifestWorkspaces.reduce<Promise<ManifestWorkspaceFile>[]>(\n (workspaces, workspace) => {\n return [...workspaces, writeWorkspaceFile(workspace, staticPath)]\n },\n [],\n )\n return Promise.all(output)\n}\n\nasync function writeWorkspaceFile(\n workspace: CreateWorkspaceManifest,\n staticPath: string,\n): Promise<ManifestWorkspaceFile> {\n const [schemaFilename, toolsFilename] = await Promise.all([\n createFile(staticPath, workspace.schema, SCHEMA_FILENAME_SUFFIX),\n createFile(staticPath, workspace.tools, TOOLS_FILENAME_SUFFIX),\n ])\n\n return {\n ...workspace,\n schema: schemaFilename,\n tools: toolsFilename,\n }\n}\n\nconst createFile = async (path: string, content: any, filenameSuffix: string) => {\n const stringifiedContent = JSON.stringify(content, null, 2)\n const hash = createHash('sha1').update(stringifiedContent).digest('hex')\n const filename = `${hash.slice(0, 8)}${filenameSuffix}`\n\n // workspaces with identical data will overwrite each others file. This is ok, since they are identical and can be shared\n await writeFile(join(path, filename), stringifiedContent)\n\n return filename\n}\n"],"names":["__dirname","dirname","URL","import","url","pathname","MANIFEST_FILENAME","SCHEMA_FILENAME_SUFFIX","TOOLS_FILENAME_SUFFIX","FEATURE_ENABLED_ENV_NAME","EXTRACT_MANIFEST_ENABLED","process","env","EXTRACT_MANIFEST_LOG_ERRORS","SANITY_CLI_EXTRACT_MANIFEST_LOG_ERRORS","CREATE_TIMER","EXTRACT_TASK_TIMEOUT_MS","minutesToMilliseconds","extractManifestSafe","args","context","extractManifest","err","output","error","workDir","flags","extOptions","defaultOutputDir","resolve","join","outputDir","defaultStaticPath","staticPath","path","rootPkgPath","readPkgUp","sync","cwd","Error","timer","getTimer","start","spinner","workspaceManifests","getWorkspaceManifests","mkdir","recursive","workspaceFiles","writeWorkspaceFiles","manifest","version","createdAt","Date","toISOString","workspaces","studioVersion","readModuleVersion","writeFile","JSON","stringify","manifestDuration","end","succeed","toFixed","fail","message","workerPath","worker","Worker","workerData","timeout","timeoutId","setTimeout","terminate","Promise","resolveWorkspaces","reject","buffer","addListener","push","exitCode","clearTimeout","manifestWorkspaces","reduce","workspace","writeWorkspaceFile","all","schemaFilename","toolsFilename","createFile","schema","tools","content","filenameSuffix","stringifiedContent","filename","createHash","update","digest","slice"],"mappings":";;;;;;;AAkBA,MAAMA,cAAYC,QAAQ,IAAIC,IAAIC,YAAYC,GAAG,EAAEC,QAAQ,GAE9CC,oBAAoB,wBAC3BC,yBAAyB,uBACzBC,wBAAwB,sBAGxBC,2BAA2B,uCAC3BC,2BAA2BC,QAAQC,IAAIH,wBAAwB,MAAM,SACrEI,8BAA8BF,QAAQC,IAAIE,2CAA2C,QAErFC,eAAe,mBAEfC,0BAA0BC,sBAAsB,CAAC;AAcvD,eAAsBC,oBACpBC,MACAC,SAC4B;AAC5B,MAAKV;AAIL,QAAI;AACF,YAAMW,gBAAgBF,MAAMC,OAAO;AACnC;AAAA,IACF,SAASE,KAAK;AACZ,aAAIT,+BACFO,QAAQG,OAAOC,MAAMF,GAAG,GAEnBA;AAAAA,IACT;AACF;AAEA,eAAeD,gBACbF,MACAC,SACe;AACf,QAAM;AAAA,IAACG;AAAAA,IAAQE;AAAAA,EAAAA,IAAWL,SAEpBM,QAAQP,KAAKQ,YACbC,mBAAmBC,QAAQC,KAAKL,SAAS,MAAM,CAAC,GAEhDM,YAAYF,QAAQD,gBAAgB,GACpCI,oBAAoBF,KAAKC,WAAW,QAAQ,GAE5CE,aAAaP,MAAMQ,QAAQF,mBAE3BE,OAAOJ,KAAKG,YAAY3B,iBAAiB,GAEzC6B,cAAcC,UAAUC,KAAK;AAAA,IAACC,KAAKtC;AAAAA,EAAAA,CAAU,GAAGkC;AACtD,MAAI,CAACC;AACH,UAAM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,GAEjDC;AACT;"}
|
|
1
|
+
{"version":3,"file":"extractManifestAction.js","sources":["../../src/_internal/cli/actions/manifest/extractManifestAction.ts"],"sourcesContent":["import {createHash} from 'node:crypto'\nimport {mkdir, writeFile} from 'node:fs/promises'\nimport {dirname, join, resolve} from 'node:path'\nimport {fileURLToPath} from 'node:url'\nimport {Worker} from 'node:worker_threads'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport {minutesToMilliseconds} from 'date-fns'\nimport readPkgUp from 'read-pkg-up'\n\nimport {\n type CreateManifest,\n type CreateWorkspaceManifest,\n type ManifestWorkspaceFile,\n} from '../../../manifest/manifestTypes'\nimport {type ExtractManifestWorkerData} from '../../threads/extractManifest'\nimport {readModuleVersion} from '../../util/readModuleVersion'\nimport {getTimer} from '../../util/timing'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nexport const MANIFEST_FILENAME = 'create-manifest.json'\nconst SCHEMA_FILENAME_SUFFIX = '.create-schema.json'\nconst TOOLS_FILENAME_SUFFIX = '.create-tools.json'\n\n/** Escape-hatch env flags to change action behavior */\nconst FEATURE_ENABLED_ENV_NAME = 'SANITY_CLI_EXTRACT_MANIFEST_ENABLED'\nconst EXTRACT_MANIFEST_ENABLED = process.env[FEATURE_ENABLED_ENV_NAME] !== 'false'\nconst EXTRACT_MANIFEST_LOG_ERRORS = process.env.SANITY_CLI_EXTRACT_MANIFEST_LOG_ERRORS === 'true'\n\nconst CREATE_TIMER = 'create-manifest'\n\nconst EXTRACT_TASK_TIMEOUT_MS = minutesToMilliseconds(2)\n\nconst EXTRACT_FAILURE_MESSAGE =\n \"↳ Couldn't extract manifest file. Sanity Create will not be available for the studio.\\n\" +\n ` Disable this message with ${FEATURE_ENABLED_ENV_NAME}=false`\n\nexport interface ExtractManifestFlags {\n path?: string\n}\n\n/**\n * This function will never throw.\n * @returns `undefined` if extract succeeded - caught error if it failed\n */\nexport async function extractManifestSafe(\n args: CliCommandArguments<ExtractManifestFlags>,\n context: CliCommandContext,\n): Promise<Error | undefined> {\n if (!EXTRACT_MANIFEST_ENABLED) {\n return undefined\n }\n\n try {\n await extractManifest(args, context)\n return undefined\n } catch (err) {\n if (EXTRACT_MANIFEST_LOG_ERRORS) {\n context.output.error(err)\n }\n return err\n }\n}\n\nasync function extractManifest(\n args: CliCommandArguments<ExtractManifestFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {output, workDir} = context\n\n const flags = args.extOptions\n const defaultOutputDir = resolve(join(workDir, 'dist'))\n\n const outputDir = resolve(defaultOutputDir)\n const defaultStaticPath = join(outputDir, 'static')\n\n const staticPath = flags.path ?? defaultStaticPath\n\n const path = join(staticPath, MANIFEST_FILENAME)\n\n const rootPkgPath = readPkgUp.sync({cwd: __dirname})?.path\n if (!rootPkgPath) {\n throw new Error('Could not find root directory for `sanity` package')\n }\n\n const timer = getTimer()\n timer.start(CREATE_TIMER)\n const spinner = output.spinner({}).start('Extracting manifest')\n\n try {\n const workspaceManifests = await getWorkspaceManifests({rootPkgPath, workDir})\n await mkdir(staticPath, {recursive: true})\n\n const workspaceFiles = await writeWorkspaceFiles(workspaceManifests, staticPath)\n\n const manifest: CreateManifest = {\n /**\n * Version history:\n * 1: Initial release.\n * 2: Added tools file.\n * 3. Added studioVersion field.\n */\n version: 3,\n createdAt: new Date().toISOString(),\n workspaces: workspaceFiles,\n studioVersion: await readModuleVersion(workDir, 'sanity'),\n }\n\n await writeFile(path, JSON.stringify(manifest, null, 2))\n const manifestDuration = timer.end(CREATE_TIMER)\n\n spinner.succeed(`Extracted manifest (${manifestDuration.toFixed()}ms)`)\n } catch (err) {\n spinner.fail(err.message)\n throw err\n }\n}\n\nasync function getWorkspaceManifests({\n rootPkgPath,\n workDir,\n}: {\n rootPkgPath: string\n workDir: string\n}): Promise<CreateWorkspaceManifest[]> {\n const workerPath = join(\n dirname(rootPkgPath),\n 'lib',\n '_internal',\n 'cli',\n 'threads',\n 'extractManifest.cjs',\n )\n\n const worker = new Worker(workerPath, {\n workerData: {workDir} satisfies ExtractManifestWorkerData,\n env: process.env,\n })\n\n let timeout = false\n const timeoutId = setTimeout(() => {\n timeout = true\n void worker.terminate()\n }, EXTRACT_TASK_TIMEOUT_MS)\n\n try {\n return await new Promise<CreateWorkspaceManifest[]>((resolveWorkspaces, reject) => {\n const buffer: CreateWorkspaceManifest[] = []\n worker.addListener('message', (message) => buffer.push(message))\n worker.addListener('exit', (exitCode) => {\n if (exitCode === 0) {\n resolveWorkspaces(buffer)\n } else if (timeout) {\n reject(new Error(`Extract manifest was aborted after ${EXTRACT_TASK_TIMEOUT_MS}ms`))\n }\n })\n worker.addListener('error', reject)\n })\n } finally {\n clearTimeout(timeoutId)\n }\n}\n\nfunction writeWorkspaceFiles(\n manifestWorkspaces: CreateWorkspaceManifest[],\n staticPath: string,\n): Promise<ManifestWorkspaceFile[]> {\n const output = manifestWorkspaces.reduce<Promise<ManifestWorkspaceFile>[]>(\n (workspaces, workspace) => {\n return [...workspaces, writeWorkspaceFile(workspace, staticPath)]\n },\n [],\n )\n return Promise.all(output)\n}\n\nasync function writeWorkspaceFile(\n workspace: CreateWorkspaceManifest,\n staticPath: string,\n): Promise<ManifestWorkspaceFile> {\n const [schemaFilename, toolsFilename] = await Promise.all([\n createFile(staticPath, workspace.schema, SCHEMA_FILENAME_SUFFIX),\n createFile(staticPath, workspace.tools, TOOLS_FILENAME_SUFFIX),\n ])\n\n return {\n ...workspace,\n schema: schemaFilename,\n tools: toolsFilename,\n }\n}\n\nconst createFile = async (path: string, content: any, filenameSuffix: string) => {\n const stringifiedContent = JSON.stringify(content, null, 2)\n const hash = createHash('sha1').update(stringifiedContent).digest('hex')\n const filename = `${hash.slice(0, 8)}${filenameSuffix}`\n\n // workspaces with identical data will overwrite each others file. This is ok, since they are identical and can be shared\n await writeFile(join(path, filename), stringifiedContent)\n\n return filename\n}\n"],"names":["__dirname","dirname","fileURLToPath","import","url","MANIFEST_FILENAME","SCHEMA_FILENAME_SUFFIX","TOOLS_FILENAME_SUFFIX","FEATURE_ENABLED_ENV_NAME","EXTRACT_MANIFEST_ENABLED","process","env","EXTRACT_MANIFEST_LOG_ERRORS","SANITY_CLI_EXTRACT_MANIFEST_LOG_ERRORS","CREATE_TIMER","EXTRACT_TASK_TIMEOUT_MS","minutesToMilliseconds","extractManifestSafe","args","context","extractManifest","err","output","error","workDir","flags","extOptions","defaultOutputDir","resolve","join","outputDir","defaultStaticPath","staticPath","path","rootPkgPath","readPkgUp","sync","cwd","Error","timer","getTimer","start","spinner","workspaceManifests","getWorkspaceManifests","mkdir","recursive","workspaceFiles","writeWorkspaceFiles","manifest","version","createdAt","Date","toISOString","workspaces","studioVersion","readModuleVersion","writeFile","JSON","stringify","manifestDuration","end","succeed","toFixed","fail","message","workerPath","worker","Worker","workerData","timeout","timeoutId","setTimeout","terminate","Promise","resolveWorkspaces","reject","buffer","addListener","push","exitCode","clearTimeout","manifestWorkspaces","reduce","workspace","writeWorkspaceFile","all","schemaFilename","toolsFilename","createFile","schema","tools","content","filenameSuffix","stringifiedContent","filename","createHash","update","digest","slice"],"mappings":";;;;;;;;AAmBA,MAAMA,cAAYC,QAAQC,cAAcC,YAAYC,GAAG,CAAC,GAE3CC,oBAAoB,wBAC3BC,yBAAyB,uBACzBC,wBAAwB,sBAGxBC,2BAA2B,uCAC3BC,2BAA2BC,QAAQC,IAAIH,wBAAwB,MAAM,SACrEI,8BAA8BF,QAAQC,IAAIE,2CAA2C,QAErFC,eAAe,mBAEfC,0BAA0BC,sBAAsB,CAAC;AAcvD,eAAsBC,oBACpBC,MACAC,SAC4B;AAC5B,MAAKV;AAIL,QAAI;AACF,YAAMW,gBAAgBF,MAAMC,OAAO;AACnC;AAAA,IACF,SAASE,KAAK;AACZ,aAAIT,+BACFO,QAAQG,OAAOC,MAAMF,GAAG,GAEnBA;AAAAA,IACT;AACF;AAEA,eAAeD,gBACbF,MACAC,SACe;AACf,QAAM;AAAA,IAACG;AAAAA,IAAQE;AAAAA,EAAAA,IAAWL,SAEp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AAA,EAAAA;AAEX;AAEA,MAAMC,aAAa,OAAOxD,MAAc2D,SAAcC,mBAA2B;AAC/E,QAAMC,qBAAqBpC,KAAKC,UAAUiC,SAAS,MAAM,CAAC,GAEpDG,WAAW,GADJC,WAAW,MAAM,EAAEC,OAAOH,kBAAkB,EAAEI,OAAO,KAAK,EAC9CC,MAAM,GAAG,CAAC,CAAC,GAAGN,cAAc;AAGrD,SAAA,MAAMpC,UAAU5B,KAAKI,MAAM8D,QAAQ,GAAGD,kBAAkB,GAEjDC;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-help-url.esm.js","sources":["../../../../node_modules/.pnpm/@sanity+generate-help-url@3.0.
|
|
1
|
+
{"version":3,"file":"generate-help-url.esm.js","sources":["../../../../node_modules/.pnpm/@sanity+generate-help-url@3.0.1/node_modules/@sanity/generate-help-url/dist/generate-help-url.esm.js"],"sourcesContent":["const BASE_URL = \"https://www.sanity.io/docs/help/\";\nfunction generateHelpUrl(slug) {\n return BASE_URL + slug;\n}\nexport { generateHelpUrl };\n//# sourceMappingURL=generate-help-url.esm.js.map\n"],"names":["BASE_URL","generateHelpUrl","slug"],"mappings":"AAAA,MAAMA,WAAW;AAEV,SAASC,gBAAgBC,MAAsB;AACpD,SAAOF,WAAWE;AACpB;","x_google_ignoreList":[0]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
2
3
|
import { isMainThread, Worker } from "node:worker_threads";
|
|
3
4
|
import readPkgUp from "read-pkg-up";
|
|
4
5
|
import { createSchema } from "sanity";
|
|
5
|
-
const __dirname$1 = path.dirname(
|
|
6
|
+
const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
6
7
|
async function getGraphQLAPIs(cliContext) {
|
|
7
8
|
if (!isMainThread)
|
|
8
9
|
throw new Error("getGraphQLAPIs() must be called from the main thread");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGraphQLAPIs.js","sources":["../../src/_internal/cli/actions/graphql/getGraphQLAPIs.ts"],"sourcesContent":["import path from 'node:path'\nimport {isMainThread, Worker} from 'node:worker_threads'\n\nimport {type CliCommandContext} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\nimport {createSchema} from 'sanity'\n\nimport {\n type ResolvedGraphQLAPI,\n type ResolvedSourceProperties,\n type SchemaDefinitionish,\n type TypeResolvedGraphQLAPI,\n} from './types'\n\nconst __dirname = path.dirname(
|
|
1
|
+
{"version":3,"file":"getGraphQLAPIs.js","sources":["../../src/_internal/cli/actions/graphql/getGraphQLAPIs.ts"],"sourcesContent":["import path from 'node:path'\nimport {fileURLToPath} from 'node:url'\nimport {isMainThread, Worker} from 'node:worker_threads'\n\nimport {type CliCommandContext} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\nimport {createSchema} from 'sanity'\n\nimport {\n type ResolvedGraphQLAPI,\n type ResolvedSourceProperties,\n type SchemaDefinitionish,\n type TypeResolvedGraphQLAPI,\n} from './types'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport async function getGraphQLAPIs(cliContext: CliCommandContext): Promise<ResolvedGraphQLAPI[]> {\n if (!isMainThread) {\n throw new Error('getGraphQLAPIs() must be called from the main thread')\n }\n\n const defaultSchema = createSchema({name: 'default', types: []})\n const defaultTypes = defaultSchema.getTypeNames()\n const isCustomType = (type: SchemaDefinitionish) => !defaultTypes.includes(type.name)\n\n const apis = await getApisWithSchemaTypes(cliContext)\n const resolved = apis.map(\n ({schemaTypes, ...api}): ResolvedSourceProperties => ({\n schema: createSchema({name: 'default', types: schemaTypes.filter(isCustomType)}),\n ...api,\n }),\n )\n\n return resolved\n}\n\nfunction getApisWithSchemaTypes(cliContext: CliCommandContext): Promise<TypeResolvedGraphQLAPI[]> {\n return new Promise<TypeResolvedGraphQLAPI[]>((resolve, reject) => {\n const {cliConfig, cliConfigPath, workDir} = cliContext\n const rootPkgPath = readPkgUp.sync({cwd: __dirname})?.path\n if (!rootPkgPath) {\n throw new Error('Could not find root directory for `sanity` package')\n }\n\n const rootDir = path.dirname(rootPkgPath)\n const workerPath = path.join(\n rootDir,\n 'lib',\n '_internal',\n 'cli',\n 'threads',\n 'getGraphQLAPIs.cjs',\n )\n const worker = new Worker(workerPath, {\n workerData: {cliConfig: serialize(cliConfig || {}), cliConfigPath, workDir},\n env: process.env,\n })\n worker.on('message', resolve)\n worker.on('error', reject)\n worker.on('exit', (code) => {\n if (code !== 0) reject(new Error(`Worker stopped with exit code ${code}`))\n })\n })\n}\n\nfunction serialize<T>(obj: T): T {\n try {\n return JSON.parse(JSON.stringify(obj))\n } catch (cause) {\n throw new Error(`Failed to serialize CLI configuration`, {cause})\n }\n}\n"],"names":["__dirname","path","dirname","fileURLToPath","import","url","getGraphQLAPIs","cliContext","isMainThread","Error","defaultTypes","createSchema","name","types","getTypeNames","isCustomType","type","includes","getApisWithSchemaTypes","map","schemaTypes","api","schema","filter","Promise","resolve","reject","cliConfig","cliConfigPath","workDir","rootPkgPath","readPkgUp","sync","cwd","rootDir","workerPath","join","worker","Worker","workerData","serialize","env","process","on","code","obj","JSON","parse","stringify","cause"],"mappings":";;;;;AAeA,MAAMA,cAAYC,KAAKC,QAAQC,cAAcC,YAAYC,GAAG,CAAC;AAE7D,eAAsBC,eAAeC,YAA8D;AACjG,MAAI,CAACC;AACH,UAAM,IAAIC,MAAM,sDAAsD;AAIxE,QAAMC,eADgBC,aAAa;AAAA,IAACC,MAAM;AAAA,IAAWC,OAAO,CAAA;AAAA,EAAA,CAAG,EAC5BC,gBAC7BC,eAAgBC,UAA8B,CAACN,aAAaO,SAASD,KAAKJ,IAAI;AAUpF,UARa,MAAMM,uBAAuBX,UAAU,GAC9BY,IACpB,CAAC;AAAA,IAACC;AAAAA,IAAa,GAAGC;AAAAA,EAAAA,OAAoC;AAAA,IACpDC,QAAQX,aAAa;AAAA,MAACC,MAAM;AAAA,MAAWC,OAAOO,YAAYG,OAAOR,YAAY;AAAA,IAAA,CAAE;AAAA,IAC/E,GAAGM;AAAAA,EAAAA,EAEP;AAGF;AAEA,SAASH,uBAAuBX,YAAkE;AAChG,SAAO,IAAIiB,QAAkC,CAACC,SAASC,WAAW;AAChE,UAAM;AAAA,MAACC;AAAAA,MAAWC;AAAAA,MAAeC;AAAAA,IAAAA,IAAWtB,YACtCuB,cAAcC,UAAUC,KAAK;AAAA,MAACC,KAAKjC;AAAAA,IAAAA,CAAU,GAAGC;AACtD,QAAI,CAAC6B;AACH,YAAM,IAAIrB,MAAM,oDAAoD;AAGtE,UAAMyB,UAAUjC,KAAKC,QAAQ4B,WAAW,GAClCK,aAAalC,KAAKmC,KACtBF,SACA,OACA,aACA,OACA,WACA,oBACF,GACMG,SAAS,IAAIC,OAAOH,YAAY;AAAA,MACpCI,YAAY;AAAA,QAACZ,WAAWa,UAAUb,aAAa,EAAE;AAAA,QAAGC;AAAAA,QAAeC;AAAAA,MAAAA;AAAAA,MACnEY,KAAKC,QAAQD;AAAAA,IAAAA,CACd;AACDJ,WAAOM,GAAG,WAAWlB,OAAO,GAC5BY,OAAOM,GAAG,SAASjB,MAAM,GACzBW,OAAOM,GAAG,QAASC,CAAAA,SAAS;AACtBA,eAAS,KAAGlB,OAAO,IAAIjB,MAAM,iCAAiCmC,IAAI,EAAE,CAAC;AAAA,IAC3E,CAAC;AAAA,EACH,CAAC;AACH;AAEA,SAASJ,UAAaK,KAAW;AAC/B,MAAI;AACF,WAAOC,KAAKC,MAAMD,KAAKE,UAAUH,GAAG,CAAC;AAAA,EACvC,SAASI,OAAO;AACd,UAAM,IAAIxC,MAAM,yCAAyC;AAAA,MAACwC;AAAAA,IAAAA,CAAM;AAAA,EAClE;AACF;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { PassThrough } from "node:stream";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import FormData from "form-data";
|
|
5
6
|
import { customAlphabet } from "nanoid";
|
|
6
7
|
import readPkgUp from "read-pkg-up";
|
|
7
8
|
import { debug as debug$1, determineIsApp } from "./_internal.js";
|
|
8
|
-
const __dirname$1 = path.dirname(
|
|
9
|
+
const __dirname$1 = path.dirname(fileURLToPath(import.meta.url)), debug = debug$1.extend("deploy");
|
|
9
10
|
function promiseWithResolvers() {
|
|
10
11
|
let resolve, reject;
|
|
11
12
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../src/_internal/cli/actions/deploy/helpers.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {type CliCommandContext, type CliOutputter} from '@sanity/cli'\nimport {type SanityClient} from '@sanity/client'\nimport FormData from 'form-data'\nimport {customAlphabet} from 'nanoid'\nimport readPkgUp from 'read-pkg-up'\n\nimport {debug as debugIt} from '../../debug'\nimport {determineIsApp} from '../../util/determineIsApp'\n\nconst __dirname = path.dirname(new URL(import.meta.url).pathname)\n\nexport const debug = debugIt.extend('deploy')\n\n// TODO: replace with `Promise.withResolvers()` once it lands in node\nfunction promiseWithResolvers<T>() {\n let resolve!: (t: T) => void\n let reject!: (err: unknown) => void\n const promise = new Promise<T>((res, rej) => {\n resolve = res\n reject = rej\n })\n return {promise, resolve, reject}\n}\n\nexport interface ActiveDeployment {\n deployedAt: string\n deployedBy: string\n isActiveDeployment: boolean\n isAutoUpdating: boolean | null\n size: string | null\n createdAt: string\n updatedAt: string\n version: string\n}\n\nexport interface UserApplication {\n id: string\n projectId: string | null\n organizationId: string | null\n title: string | null\n appHost: string\n urlType: 'internal' | 'external'\n createdAt: string\n updatedAt: string\n type: 'studio' | 'coreApp'\n activeDeployment?: ActiveDeployment | null\n}\n\nexport interface GetUserApplicationsOptions {\n client: SanityClient\n organizationId?: string\n}\n\nexport interface GetUserApplicationOptions {\n client: SanityClient\n appHost?: string\n appId?: string\n isSdkApp?: boolean\n}\nexport async function getUserApplication({\n client,\n appHost,\n appId,\n isSdkApp,\n}: GetUserApplicationOptions): Promise<UserApplication | null> {\n let query: undefined | Record<string, string>\n\n const uri = appId ? `/user-applications/${appId}` : '/user-applications'\n\n if (isSdkApp) {\n query = {appType: 'coreApp'}\n } else if (!appId) {\n // either request the app by host or get the default app\n query = appHost ? {appHost} : {default: 'true'}\n }\n try {\n return await client.request({\n uri,\n query,\n })\n } catch (e) {\n if (e?.statusCode === 404) {\n return null\n }\n\n debug('Error getting user application', e)\n throw e\n }\n}\nexport async function getUserApplications({\n client,\n organizationId,\n}: GetUserApplicationsOptions): Promise<UserApplication[] | null> {\n const query: Record<string, string> = organizationId\n ? {organizationId: organizationId, appType: 'coreApp'}\n : {appType: 'studio'}\n try {\n return await client.request({\n uri: '/user-applications',\n query,\n })\n } catch (e) {\n if (e?.statusCode === 404) {\n return null\n }\n\n debug('Error getting user applications', e)\n throw e\n }\n}\n\nfunction createUserApplication(\n client: SanityClient,\n body: Pick<UserApplication, 'appHost' | 'urlType' | 'type'> & {\n title?: string\n },\n organizationId?: string,\n): Promise<UserApplication> {\n const query: Record<string, string> = organizationId\n ? {organizationId: organizationId, appType: 'coreApp'}\n : {appType: 'studio'}\n return client.request({uri: '/user-applications', method: 'POST', body, query})\n}\n\ninterface SelectApplicationOptions {\n client: SanityClient\n prompt: GetOrCreateUserApplicationOptions['context']['prompt']\n message: string\n createNewLabel: string\n organizationId?: string\n}\n\n/**\n * Shared utility for selecting an existing application or opting to create a new one\n * @internal\n */\nasync function selectExistingApplication({\n client,\n prompt,\n message,\n createNewLabel,\n organizationId,\n}: SelectApplicationOptions): Promise<UserApplication | null> {\n const userApplications = await getUserApplications({client, organizationId})\n\n if (!userApplications?.length) {\n return null\n }\n\n const choices = userApplications.map((app) => ({\n value: app.appHost,\n name: app.title ?? app.appHost,\n }))\n\n const selected = await prompt.single({\n message,\n type: 'list',\n choices: [...choices, new prompt.Separator(), {value: 'new', name: createNewLabel}],\n })\n\n if (selected === 'new') {\n return null\n }\n\n return userApplications.find((app) => app.appHost === selected)!\n}\n\nexport interface GetOrCreateUserApplicationOptions {\n client: SanityClient\n context: Pick<CliCommandContext, 'output' | 'prompt' | 'cliConfig'>\n spinner: ReturnType<CliOutputter['spinner']>\n}\n\n/**\n * These functions handle the logic for managing user applications when\n * studioHost is not provided in the CLI config.\n *\n * @internal\n *\n * +-------------------------------+\n * | Fetch Existing user-app? |\n * +---------+--------------------+\n * |\n * +-----+-----+\n * | |\n * v v\n * +---------+ +-------------------------+\n * | Return | | Fetch all user apps |\n * | user-app| +-------------------------+\n * +---------+ |\n * v\n * +---------------------------+\n * | User apps found? |\n * +-----------+---------------+\n * |\n * +------v------+\n * | |\n * v v\n * +--------------------+ +------------------------+\n * | Show list and | | Prompt for hostname |\n * | prompt selection | | and create new app |\n * +--------------------+ +------------------------+\n */\nexport async function getOrCreateStudio({\n client,\n spinner,\n context,\n}: GetOrCreateUserApplicationOptions): Promise<UserApplication> {\n const {output, prompt} = context\n // if there is already an existing user-app, then just return it\n const existingUserApplication = await getUserApplication({client})\n\n // Complete the spinner so prompt can properly work\n spinner.succeed()\n\n if (existingUserApplication) {\n return existingUserApplication\n }\n\n const selectedApp = await selectExistingApplication({\n client,\n prompt,\n message: 'Select existing studio hostname',\n createNewLabel: 'Create new studio hostname',\n })\n\n if (selectedApp) {\n return selectedApp\n }\n\n // otherwise, prompt the user for a hostname\n output.print('Your project has not been assigned a studio hostname.')\n output.print('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.print('you will need one. Please enter the part you want to use.')\n\n const {promise, resolve} = promiseWithResolvers<UserApplication>()\n\n await prompt.single({\n type: 'input',\n filter: (inp: string) => inp.replace(/\\.sanity\\.studio$/i, ''),\n message: 'Studio hostname (<value>.sanity.studio):',\n // if a string is returned here, it is relayed to the user and prompt allows\n // the user to try again until this function returns true\n validate: async (appHost: string) => {\n try {\n const response = await createUserApplication(client, {\n appHost,\n urlType: 'internal',\n type: 'studio',\n })\n resolve(response)\n return true\n } catch (e) {\n // if the name is taken, it should return a 409 so we relay to the user\n if ([402, 409].includes(e?.statusCode)) {\n return e?.response?.body?.message || 'Bad request' // just in case\n }\n\n debug('Error creating user application', e)\n // otherwise, it's a fatal error\n throw e\n }\n },\n })\n\n return await promise\n}\n\n/**\n * Creates a core application with an auto-generated hostname\n *\n * @internal\n */\nexport async function getOrCreateApplication({\n client,\n context,\n spinner,\n}: GetOrCreateUserApplicationOptions): Promise<UserApplication> {\n const {prompt, cliConfig} = context\n const organizationId = cliConfig && 'app' in cliConfig && cliConfig.app?.organizationId\n\n // Complete the spinner so prompt can properly work\n spinner.succeed()\n\n const selectedApp = await selectExistingApplication({\n client,\n prompt,\n message: 'Select an existing deployed application',\n createNewLabel: 'Create new deployed application',\n organizationId: organizationId || undefined,\n })\n\n if (selectedApp) {\n return selectedApp\n }\n\n // First get the title from the user\n const title = await prompt.single({\n type: 'input',\n message: 'Enter a title for your application:',\n validate: (input: string) => input.length > 0 || 'Title is required',\n })\n\n const {promise, resolve, reject} = promiseWithResolvers<UserApplication>()\n\n // Try to create the application, retrying with new hostnames if needed\n const tryCreateApp = async () => {\n // appHosts have some restrictions (no uppercase, must start with a letter)\n const generateId = () => {\n const letters = 'abcdefghijklmnopqrstuvwxyz'\n const firstChar = customAlphabet(letters, 1)()\n const rest = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 11)()\n return `${firstChar}${rest}`\n }\n\n // we will likely prepend this with an org ID or other parameter in the future\n const appHost = generateId()\n\n try {\n const response = await createUserApplication(\n client,\n {\n appHost,\n urlType: 'internal',\n title,\n type: 'coreApp',\n },\n organizationId || undefined,\n )\n resolve(response)\n return true\n } catch (e) {\n // if the name is taken, generate a new one and try again\n if ([402, 409].includes(e?.statusCode)) {\n debug('App host taken, retrying with new host')\n return tryCreateApp()\n }\n\n debug('Error creating core application', e)\n reject(e)\n // otherwise, it's a fatal error\n throw e\n }\n }\n\n spinner.start('Creating application')\n\n await tryCreateApp()\n const response = await promise\n\n spinner.succeed()\n return response\n}\n\nexport interface BaseConfigOptions {\n client: SanityClient\n context: Pick<CliCommandContext, 'output' | 'prompt' | 'cliConfig'>\n spinner: ReturnType<CliOutputter['spinner']>\n}\n\ntype UserApplicationConfigOptions = BaseConfigOptions &\n (\n | {\n /**\n * @deprecated – appHost is replaced by appId, but kept for backwards compat\n */\n appHost: string | undefined\n appId: undefined\n }\n | {\n appId: string | undefined\n /**\n * @deprecated – appHost is replaced by appId, but kept for backwards compat\n */\n appHost: undefined\n }\n )\n\nasync function getOrCreateStudioFromConfig({\n client,\n context,\n spinner,\n appHost,\n appId,\n}: UserApplicationConfigOptions): Promise<UserApplication> {\n const {output} = context\n // if there is already an existing user-app, then just return it\n const existingUserApplication = await getUserApplication({client, appId, appHost})\n\n // Complete the spinner so prompt can properly work\n spinner.succeed()\n\n if (existingUserApplication) {\n return existingUserApplication\n }\n\n if (!appHost) {\n throw new Error(`Application not found. Application with id ${appId} does not exist`)\n }\n\n output.print('Your project has not been assigned a studio hostname.')\n output.print(`Creating https://${appHost}.sanity.studio`)\n output.print('')\n spinner.start('Creating studio hostname')\n\n try {\n const response = await createUserApplication(client, {\n appHost,\n urlType: 'internal',\n type: 'studio',\n })\n spinner.succeed()\n return response\n } catch (e) {\n spinner.fail()\n // if the name is taken, it should return a 409 so we relay to the user\n if ([402, 409].includes(e?.statusCode)) {\n throw new Error(e?.response?.body?.message || 'Bad request', {cause: e}) // just in case\n }\n debug('Error creating user application from config', e)\n // otherwise, it's a fatal error\n throw e\n }\n}\n\nasync function getOrCreateAppFromConfig({\n client,\n context,\n spinner,\n appHost,\n appId,\n}: UserApplicationConfigOptions): Promise<UserApplication> {\n const {output, cliConfig} = context\n if (appId) {\n const existingUserApplication = await getUserApplication({\n client,\n appId,\n appHost,\n isSdkApp: determineIsApp(cliConfig),\n })\n spinner.succeed()\n\n if (existingUserApplication) {\n return existingUserApplication\n }\n }\n\n // custom apps cannot arbitrarily create ids or hosts, so send them to create option\n output.print('The id provided in your configuration is not recognized.')\n output.print('Checking existing applications...')\n return getOrCreateApplication({client, context, spinner})\n}\n\n/**\n * This function handles the logic for managing user applications when\n * studioHost or appId is provided in the CLI config.\n *\n * @internal\n */\nexport async function getOrCreateUserApplicationFromConfig(\n options: UserApplicationConfigOptions,\n): Promise<UserApplication> {\n const {context, appId, appHost} = options\n const isSdkApp = determineIsApp(context.cliConfig)\n\n if (isSdkApp) {\n return getOrCreateAppFromConfig(options)\n }\n\n if (!appId && !appHost) {\n throw new Error(\n 'Studio was detected, but neither appId or appHost (deprecated) found in CLI config',\n )\n }\n\n return getOrCreateStudioFromConfig(options)\n}\n\nexport interface CreateDeploymentOptions {\n client: SanityClient\n applicationId: string\n version: string\n isAutoUpdating: boolean\n tarball: Gzip\n isSdkApp?: boolean\n}\n\nexport async function createDeployment({\n client,\n tarball,\n applicationId,\n isAutoUpdating,\n version,\n isSdkApp,\n}: CreateDeploymentOptions): Promise<{location: string}> {\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n formData.append('version', version)\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n\n return client.request({\n uri: `/user-applications/${applicationId}/deployments`,\n method: 'POST',\n headers: formData.getHeaders(),\n body: formData.pipe(new PassThrough()),\n query: isSdkApp ? {appType: 'coreApp'} : {appType: 'studio'},\n })\n}\n\nexport interface DeleteUserApplicationOptions {\n client: SanityClient\n applicationId: string\n appType: 'coreApp' | 'studio'\n}\n\nexport async function deleteUserApplication({\n applicationId,\n client,\n appType,\n}: DeleteUserApplicationOptions): Promise<void> {\n await client.request({\n uri: `/user-applications/${applicationId}`,\n query: {\n appType,\n },\n method: 'DELETE',\n })\n}\n\nexport async function getInstalledSanityVersion(): Promise<string> {\n const sanityPkgPath = (await readPkgUp({cwd: __dirname}))?.path\n if (!sanityPkgPath) {\n throw new Error('Unable to resolve `sanity` module root')\n }\n\n const pkg = JSON.parse(await fs.readFile(sanityPkgPath, 'utf-8'))\n if (typeof pkg?.version !== 'string') {\n throw new Error('Unable to find version of `sanity` module')\n }\n return pkg.version\n}\n\nexport async function dirIsEmptyOrNonExistent(sourceDir: string): Promise<boolean> {\n try {\n const stats = await fs.stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`Directory ${sourceDir} is not a directory`)\n }\n } catch (err) {\n if (err.code === 'ENOENT') {\n return true\n }\n\n throw err\n }\n\n const content = await fs.readdir(sourceDir)\n return content.length === 0\n}\n\nexport async function checkDir(sourceDir: string): Promise<void> {\n try {\n const stats = await fs.stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`Directory ${sourceDir} is not a directory`)\n }\n } catch (err) {\n const error = err.code === 'ENOENT' ? new Error(`Directory \"${sourceDir}\" does not exist`) : err\n\n throw error\n }\n\n try {\n await fs.stat(path.join(sourceDir, 'index.html'))\n } catch (err) {\n const error =\n err.code === 'ENOENT'\n ? new Error(\n [\n `\"${sourceDir}/index.html\" does not exist -`,\n '[SOURCE_DIR] must be a directory containing',\n 'a Sanity studio built using \"sanity build\"',\n ].join(' '),\n )\n : err\n\n throw error\n }\n}\n"],"names":["__dirname","path","dirname","URL","import","url","pathname","debug","debugIt","extend","promiseWithResolvers","resolve","reject","promise","Promise","res","rej","getUserApplication","client","appHost","appId","isSdkApp","query","uri","appType","default","request","e","statusCode","getUserApplications","organizationId","createUserApplication","body","method","selectExistingApplication","prompt","message","createNewLabel","userApplications","length","choices","map","app","value","name","title","selected","single","type","Separator","find","getOrCreateStudio","spinner","context","output","existingUserApplication","succeed","selectedApp","print","filter","inp","replace","validate","response","urlType","includes","getOrCreateApplication","cliConfig","undefined","input","tryCreateApp","generateId","firstChar","customAlphabet","rest","start","getOrCreateStudioFromConfig","Error","fail","cause","getOrCreateAppFromConfig","determineIsApp","getOrCreateUserApplicationFromConfig","options","createDeployment","tarball","applicationId","isAutoUpdating","version","formData","FormData","append","toString","contentType","filename","headers","getHeaders","pipe","PassThrough","deleteUserApplication","getInstalledSanityVersion","sanityPkgPath","readPkgUp","cwd","pkg","JSON","parse","fs","readFile","dirIsEmptyOrNonExistent","sourceDir","stat","isDirectory","err","code","readdir","checkDir","join"],"mappings":";;;;;;;AAcA,MAAMA,cAAYC,KAAKC,QAAQ,IAAIC,IAAIC,YAAYC,GAAG,EAAEC,QAAQ,GAEnDC,QAAQC,QAAQC,OAAO,QAAQ;AAG5C,SAASC,uBAA0B;AACjC,MAAIC,SACAC;AAKJ,SAAO;AAAA,IAACC,SAJQ,IAAIC,QAAW,CAACC,KAAKC,QAAQ;AAC3CL,gBAAUI,KACVH,SAASI;AAAAA,IACX,CAAC;AAAA,IACgBL;AAAAA,IAASC;AAAAA,EAAAA;AAC5B;AAqCA,eAAsBK,mBAAmB;AAAA,EACvCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACyB,GAAoC;AAC7D,MAAIC;AAEJ,QAAMC,MAAMH,QAAQ,sBAAsBA,KAAK,KAAK;AAEhDC,aACFC,QAAQ;AAAA,IAACE,SAAS;AAAA,EAAA,IACRJ,UAEVE,QAAQH,UAAU;AAAA,IAACA;AAAAA,EAAAA,IAAW;AAAA,IAACM,SAAS;AAAA,EAAA;AAE1C,MAAI;AACF,WAAO,MAAMP,OAAOQ,QAAQ;AAAA,MAC1BH;AAAAA,MACAD;AAAAA,IAAAA,CACD;AAAA,EACH,SAASK,GAAG;AACV,QAAIA,GAAGC,eAAe;AACpB,aAAO;AAGTrB,UAAAA,MAAM,kCAAkCoB,CAAC,GACnCA;AAAAA,EACR;AACF;AACA,eAAsBE,oBAAoB;AAAA,EACxCX;AAAAA,EACAY;AAC0B,GAAsC;AAChE,QAAMR,QAAgCQ,iBAClC;AAAA,IAACA;AAAAA,IAAgCN,SAAS;AAAA,EAAA,IAC1C;AAAA,IAACA,SAAS;AAAA,EAAA;AACd,MAAI;AACF,WAAO,MAAMN,OAAOQ,QAAQ;AAAA,MAC1BH,KAAK;AAAA,MACLD;AAAA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A6C;AACjE,QAAMC,iBAAiB,MAAMC,UAAU;AAAA,IAACC,KAAKvG;AAAAA,EAAAA,CAAU,IAAIC;AAC3D,MAAI,CAACoG;AACH,UAAM,IAAIxB,MAAM,wCAAwC;AAG1D,QAAM2B,MAAMC,KAAKC,MAAM,MAAMC,GAAGC,SAASP,eAAe,OAAO,CAAC;AAChE,MAAI,OAAOG,KAAKhB,WAAY;AAC1B,UAAM,IAAIX,MAAM,2CAA2C;AAE7D,SAAO2B,IAAIhB;AACb;AAEA,eAAsBqB,wBAAwBC,WAAqC;AACjF,MAAI;AAEF,QAAI,EADU,MAAMH,GAAGI,KAAKD,SAAS,GAC1BE,YAAAA;AACT,YAAM,IAAInC,MAAM,aAAaiC,SAAS,qBAAqB;AAAA,EAE/D,SAASG,KAAK;AACZ,QAAIA,IAAIC,SAAS;AACf,aAAO;AAGT,UAAMD;AAAAA,EACR;AAGA,UADgB,MAAMN,GAAGQ,QAAQL,SAAS,GAC3BvE,WAAW;AAC5B;AAEA,eAAsB6E,SAASN,WAAkC;AAC/D,MAAI;AAEF,QAAI,EADU,MAAMH,GAAGI,KAAKD,SAAS,GAC1BE,YAAAA;AACT,YAAM,IAAInC,MAAM,aAAaiC,SAAS,qBAAqB;AAAA,EAE/D,SAASG,KAAK;AAGZ,UAFcA,IAAIC,SAAS,WAAW,IAAIrC,MAAM,cAAciC,SAAS,kBAAkB,IAAIG;AAAAA,EAG/F;AAEA,MAAI;AACF,UAAMN,GAAGI,KAAK9G,KAAKoH,KAAKP,WAAW,YAAY,CAAC;AAAA,EAClD,SAASG,KAAK;AAYZ,UAVEA,IAAIC,SAAS,WACT,IAAIrC,MACF,CACE,IAAIiC,SAAS,iCACb,+CACA,4CAA4C,EAC5CO,KAAK,GAAG,CACZ,IACAJ;AAAAA,EAGR;AACF;"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../src/_internal/cli/actions/deploy/helpers.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {PassThrough} from 'node:stream'\nimport {fileURLToPath} from 'node:url'\nimport {type Gzip} from 'node:zlib'\n\nimport {type CliCommandContext, type CliOutputter} from '@sanity/cli'\nimport {type SanityClient} from '@sanity/client'\nimport FormData from 'form-data'\nimport {customAlphabet} from 'nanoid'\nimport readPkgUp from 'read-pkg-up'\n\nimport {debug as debugIt} from '../../debug'\nimport {determineIsApp} from '../../util/determineIsApp'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport const debug = debugIt.extend('deploy')\n\n// TODO: replace with `Promise.withResolvers()` once it lands in node\nfunction promiseWithResolvers<T>() {\n let resolve!: (t: T) => void\n let reject!: (err: unknown) => void\n const promise = new Promise<T>((res, rej) => {\n resolve = res\n reject = rej\n })\n return {promise, resolve, reject}\n}\n\nexport interface ActiveDeployment {\n deployedAt: string\n deployedBy: string\n isActiveDeployment: boolean\n isAutoUpdating: boolean | null\n size: string | null\n createdAt: string\n updatedAt: string\n version: string\n}\n\nexport interface UserApplication {\n id: string\n projectId: string | null\n organizationId: string | null\n title: string | null\n appHost: string\n urlType: 'internal' | 'external'\n createdAt: string\n updatedAt: string\n type: 'studio' | 'coreApp'\n activeDeployment?: ActiveDeployment | null\n}\n\nexport interface GetUserApplicationsOptions {\n client: SanityClient\n organizationId?: string\n}\n\nexport interface GetUserApplicationOptions {\n client: SanityClient\n appHost?: string\n appId?: string\n isSdkApp?: boolean\n}\nexport async function getUserApplication({\n client,\n appHost,\n appId,\n isSdkApp,\n}: GetUserApplicationOptions): Promise<UserApplication | null> {\n let query: undefined | Record<string, string>\n\n const uri = appId ? `/user-applications/${appId}` : '/user-applications'\n\n if (isSdkApp) {\n query = {appType: 'coreApp'}\n } else if (!appId) {\n // either request the app by host or get the default app\n query = appHost ? {appHost} : {default: 'true'}\n }\n try {\n return await client.request({\n uri,\n query,\n })\n } catch (e) {\n if (e?.statusCode === 404) {\n return null\n }\n\n debug('Error getting user application', e)\n throw e\n }\n}\nexport async function getUserApplications({\n client,\n organizationId,\n}: GetUserApplicationsOptions): Promise<UserApplication[] | null> {\n const query: Record<string, string> = organizationId\n ? {organizationId: organizationId, appType: 'coreApp'}\n : {appType: 'studio'}\n try {\n return await client.request({\n uri: '/user-applications',\n query,\n })\n } catch (e) {\n if (e?.statusCode === 404) {\n return null\n }\n\n debug('Error getting user applications', e)\n throw e\n }\n}\n\nfunction createUserApplication(\n client: SanityClient,\n body: Pick<UserApplication, 'appHost' | 'urlType' | 'type'> & {\n title?: string\n },\n organizationId?: string,\n): Promise<UserApplication> {\n const query: Record<string, string> = organizationId\n ? {organizationId: organizationId, appType: 'coreApp'}\n : {appType: 'studio'}\n return client.request({uri: '/user-applications', method: 'POST', body, query})\n}\n\ninterface SelectApplicationOptions {\n client: SanityClient\n prompt: GetOrCreateUserApplicationOptions['context']['prompt']\n message: string\n createNewLabel: string\n organizationId?: string\n}\n\n/**\n * Shared utility for selecting an existing application or opting to create a new one\n * @internal\n */\nasync function selectExistingApplication({\n client,\n prompt,\n message,\n createNewLabel,\n organizationId,\n}: SelectApplicationOptions): Promise<UserApplication | null> {\n const userApplications = await getUserApplications({client, organizationId})\n\n if (!userApplications?.length) {\n return null\n }\n\n const choices = userApplications.map((app) => ({\n value: app.appHost,\n name: app.title ?? app.appHost,\n }))\n\n const selected = await prompt.single({\n message,\n type: 'list',\n choices: [...choices, new prompt.Separator(), {value: 'new', name: createNewLabel}],\n })\n\n if (selected === 'new') {\n return null\n }\n\n return userApplications.find((app) => app.appHost === selected)!\n}\n\nexport interface GetOrCreateUserApplicationOptions {\n client: SanityClient\n context: Pick<CliCommandContext, 'output' | 'prompt' | 'cliConfig'>\n spinner: ReturnType<CliOutputter['spinner']>\n}\n\n/**\n * These functions handle the logic for managing user applications when\n * studioHost is not provided in the CLI config.\n *\n * @internal\n *\n * +-------------------------------+\n * | Fetch Existing user-app? |\n * +---------+--------------------+\n * |\n * +-----+-----+\n * | |\n * v v\n * +---------+ +-------------------------+\n * | Return | | Fetch all user apps |\n * | user-app| +-------------------------+\n * +---------+ |\n * v\n * +---------------------------+\n * | User apps found? |\n * +-----------+---------------+\n * |\n * +------v------+\n * | |\n * v v\n * +--------------------+ +------------------------+\n * | Show list and | | Prompt for hostname |\n * | prompt selection | | and create new app |\n * +--------------------+ +------------------------+\n */\nexport async function getOrCreateStudio({\n client,\n spinner,\n context,\n}: GetOrCreateUserApplicationOptions): Promise<UserApplication> {\n const {output, prompt} = context\n // if there is already an existing user-app, then just return it\n const existingUserApplication = await getUserApplication({client})\n\n // Complete the spinner so prompt can properly work\n spinner.succeed()\n\n if (existingUserApplication) {\n return existingUserApplication\n }\n\n const selectedApp = await selectExistingApplication({\n client,\n prompt,\n message: 'Select existing studio hostname',\n createNewLabel: 'Create new studio hostname',\n })\n\n if (selectedApp) {\n return selectedApp\n }\n\n // otherwise, prompt the user for a hostname\n output.print('Your project has not been assigned a studio hostname.')\n output.print('To deploy your Sanity Studio to our hosted sanity.studio service,')\n output.print('you will need one. Please enter the part you want to use.')\n\n const {promise, resolve} = promiseWithResolvers<UserApplication>()\n\n await prompt.single({\n type: 'input',\n filter: (inp: string) => inp.replace(/\\.sanity\\.studio$/i, ''),\n message: 'Studio hostname (<value>.sanity.studio):',\n // if a string is returned here, it is relayed to the user and prompt allows\n // the user to try again until this function returns true\n validate: async (appHost: string) => {\n try {\n const response = await createUserApplication(client, {\n appHost,\n urlType: 'internal',\n type: 'studio',\n })\n resolve(response)\n return true\n } catch (e) {\n // if the name is taken, it should return a 409 so we relay to the user\n if ([402, 409].includes(e?.statusCode)) {\n return e?.response?.body?.message || 'Bad request' // just in case\n }\n\n debug('Error creating user application', e)\n // otherwise, it's a fatal error\n throw e\n }\n },\n })\n\n return await promise\n}\n\n/**\n * Creates a core application with an auto-generated hostname\n *\n * @internal\n */\nexport async function getOrCreateApplication({\n client,\n context,\n spinner,\n}: GetOrCreateUserApplicationOptions): Promise<UserApplication> {\n const {prompt, cliConfig} = context\n const organizationId = cliConfig && 'app' in cliConfig && cliConfig.app?.organizationId\n\n // Complete the spinner so prompt can properly work\n spinner.succeed()\n\n const selectedApp = await selectExistingApplication({\n client,\n prompt,\n message: 'Select an existing deployed application',\n createNewLabel: 'Create new deployed application',\n organizationId: organizationId || undefined,\n })\n\n if (selectedApp) {\n return selectedApp\n }\n\n // First get the title from the user\n const title = await prompt.single({\n type: 'input',\n message: 'Enter a title for your application:',\n validate: (input: string) => input.length > 0 || 'Title is required',\n })\n\n const {promise, resolve, reject} = promiseWithResolvers<UserApplication>()\n\n // Try to create the application, retrying with new hostnames if needed\n const tryCreateApp = async () => {\n // appHosts have some restrictions (no uppercase, must start with a letter)\n const generateId = () => {\n const letters = 'abcdefghijklmnopqrstuvwxyz'\n const firstChar = customAlphabet(letters, 1)()\n const rest = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 11)()\n return `${firstChar}${rest}`\n }\n\n // we will likely prepend this with an org ID or other parameter in the future\n const appHost = generateId()\n\n try {\n const response = await createUserApplication(\n client,\n {\n appHost,\n urlType: 'internal',\n title,\n type: 'coreApp',\n },\n organizationId || undefined,\n )\n resolve(response)\n return true\n } catch (e) {\n // if the name is taken, generate a new one and try again\n if ([402, 409].includes(e?.statusCode)) {\n debug('App host taken, retrying with new host')\n return tryCreateApp()\n }\n\n debug('Error creating core application', e)\n reject(e)\n // otherwise, it's a fatal error\n throw e\n }\n }\n\n spinner.start('Creating application')\n\n await tryCreateApp()\n const response = await promise\n\n spinner.succeed()\n return response\n}\n\nexport interface BaseConfigOptions {\n client: SanityClient\n context: Pick<CliCommandContext, 'output' | 'prompt' | 'cliConfig'>\n spinner: ReturnType<CliOutputter['spinner']>\n}\n\ntype UserApplicationConfigOptions = BaseConfigOptions &\n (\n | {\n /**\n * @deprecated – appHost is replaced by appId, but kept for backwards compat\n */\n appHost: string | undefined\n appId: undefined\n }\n | {\n appId: string | undefined\n /**\n * @deprecated – appHost is replaced by appId, but kept for backwards compat\n */\n appHost: undefined\n }\n )\n\nasync function getOrCreateStudioFromConfig({\n client,\n context,\n spinner,\n appHost,\n appId,\n}: UserApplicationConfigOptions): Promise<UserApplication> {\n const {output} = context\n // if there is already an existing user-app, then just return it\n const existingUserApplication = await getUserApplication({client, appId, appHost})\n\n // Complete the spinner so prompt can properly work\n spinner.succeed()\n\n if (existingUserApplication) {\n return existingUserApplication\n }\n\n if (!appHost) {\n throw new Error(`Application not found. Application with id ${appId} does not exist`)\n }\n\n output.print('Your project has not been assigned a studio hostname.')\n output.print(`Creating https://${appHost}.sanity.studio`)\n output.print('')\n spinner.start('Creating studio hostname')\n\n try {\n const response = await createUserApplication(client, {\n appHost,\n urlType: 'internal',\n type: 'studio',\n })\n spinner.succeed()\n return response\n } catch (e) {\n spinner.fail()\n // if the name is taken, it should return a 409 so we relay to the user\n if ([402, 409].includes(e?.statusCode)) {\n throw new Error(e?.response?.body?.message || 'Bad request', {cause: e}) // just in case\n }\n debug('Error creating user application from config', e)\n // otherwise, it's a fatal error\n throw e\n }\n}\n\nasync function getOrCreateAppFromConfig({\n client,\n context,\n spinner,\n appHost,\n appId,\n}: UserApplicationConfigOptions): Promise<UserApplication> {\n const {output, cliConfig} = context\n if (appId) {\n const existingUserApplication = await getUserApplication({\n client,\n appId,\n appHost,\n isSdkApp: determineIsApp(cliConfig),\n })\n spinner.succeed()\n\n if (existingUserApplication) {\n return existingUserApplication\n }\n }\n\n // custom apps cannot arbitrarily create ids or hosts, so send them to create option\n output.print('The id provided in your configuration is not recognized.')\n output.print('Checking existing applications...')\n return getOrCreateApplication({client, context, spinner})\n}\n\n/**\n * This function handles the logic for managing user applications when\n * studioHost or appId is provided in the CLI config.\n *\n * @internal\n */\nexport async function getOrCreateUserApplicationFromConfig(\n options: UserApplicationConfigOptions,\n): Promise<UserApplication> {\n const {context, appId, appHost} = options\n const isSdkApp = determineIsApp(context.cliConfig)\n\n if (isSdkApp) {\n return getOrCreateAppFromConfig(options)\n }\n\n if (!appId && !appHost) {\n throw new Error(\n 'Studio was detected, but neither appId or appHost (deprecated) found in CLI config',\n )\n }\n\n return getOrCreateStudioFromConfig(options)\n}\n\nexport interface CreateDeploymentOptions {\n client: SanityClient\n applicationId: string\n version: string\n isAutoUpdating: boolean\n tarball: Gzip\n isSdkApp?: boolean\n}\n\nexport async function createDeployment({\n client,\n tarball,\n applicationId,\n isAutoUpdating,\n version,\n isSdkApp,\n}: CreateDeploymentOptions): Promise<{location: string}> {\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n formData.append('version', version)\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n\n return client.request({\n uri: `/user-applications/${applicationId}/deployments`,\n method: 'POST',\n headers: formData.getHeaders(),\n body: formData.pipe(new PassThrough()),\n query: isSdkApp ? {appType: 'coreApp'} : {appType: 'studio'},\n })\n}\n\nexport interface DeleteUserApplicationOptions {\n client: SanityClient\n applicationId: string\n appType: 'coreApp' | 'studio'\n}\n\nexport async function deleteUserApplication({\n applicationId,\n client,\n appType,\n}: DeleteUserApplicationOptions): Promise<void> {\n await client.request({\n uri: `/user-applications/${applicationId}`,\n query: {\n appType,\n },\n method: 'DELETE',\n })\n}\n\nexport async function getInstalledSanityVersion(): Promise<string> {\n const sanityPkgPath = (await readPkgUp({cwd: __dirname}))?.path\n if (!sanityPkgPath) {\n throw new Error('Unable to resolve `sanity` module root')\n }\n\n const pkg = JSON.parse(await fs.readFile(sanityPkgPath, 'utf-8'))\n if (typeof pkg?.version !== 'string') {\n throw new Error('Unable to find version of `sanity` module')\n }\n return pkg.version\n}\n\nexport async function dirIsEmptyOrNonExistent(sourceDir: string): Promise<boolean> {\n try {\n const stats = await fs.stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`Directory ${sourceDir} is not a directory`)\n }\n } catch (err) {\n if (err.code === 'ENOENT') {\n return true\n }\n\n throw err\n }\n\n const content = await fs.readdir(sourceDir)\n return content.length === 0\n}\n\nexport async function checkDir(sourceDir: string): Promise<void> {\n try {\n const stats = await fs.stat(sourceDir)\n if (!stats.isDirectory()) {\n throw new Error(`Directory ${sourceDir} is not a directory`)\n }\n } catch (err) {\n const error = err.code === 'ENOENT' ? new Error(`Directory \"${sourceDir}\" does not exist`) : err\n\n throw error\n }\n\n try {\n await fs.stat(path.join(sourceDir, 'index.html'))\n } catch (err) {\n const error =\n err.code === 'ENOENT'\n ? new Error(\n [\n `\"${sourceDir}/index.html\" does not exist -`,\n '[SOURCE_DIR] must be a directory containing',\n 'a Sanity studio built using \"sanity build\"',\n ].join(' '),\n )\n : err\n\n throw error\n }\n}\n"],"names":["__dirname","path","dirname","fileURLToPath","import","url","debug","debugIt","extend","promiseWithResolvers","resolve","reject","promise","Promise","res","rej","getUserApplication","client","appHost","appId","isSdkApp","query","uri","appType","default","request","e","statusCode","getUserApplications","organizationId","createUserApplication","body","method","selectExistingApplication","prompt","message","createNewLabel","userApplications","length","choices","map","app","value","name","title","selected","single","type","Separator","find","getOrCreateStudio","spinner","context","output","existingUserApplication","succeed","selectedApp","print","filter","inp","replace","validate","response","urlType","includes","getOrCreateApplication","cliConfig","undefined","input","tryCreateApp","generateId","firstChar","customAlphabet","rest","start","getOrCreateStudioFromConfig","Error","fail","cause","getOrCreateAppFromConfig","determineIsApp","getOrCreateUserApplicationFromConfig","options","createDeployment","tarball","applicationId","isAutoUpdating","version","formData","FormData","append","toString","contentType","filename","headers","getHeaders","pipe","PassThrough","deleteUserApplication","getInstalledSanityVersion","sanityPkgPath","readPkgUp","cwd","pkg","JSON","parse","fs","readFile","dirIsEmptyOrNonExistent","sourceDir","stat","isDirectory","err","code","readdir","checkDir","join"],"mappings":";;;;;;;;AAeA,MAAMA,cAAYC,KAAKC,QAAQC,cAAcC,YAAYC,GAAG,CAAC,GAEhDC,QAAQC,QAAQC,OAAO,QAAQ;AAG5C,SAASC,uBAA0B;AACjC,MAAIC,SACAC;AAKJ,SAAO;AAAA,IAACC,SAJQ,IAAIC,QAAW,CAACC,KAAKC,QAAQ;AAC3CL,gBAAUI,KACVH,SAASI;AAAAA,IAC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AC1BE,YAAAA;AACT,YAAM,IAAInC,MAAM,aAAaiC,SAAS,qBAAqB;AAAA,EAE/D,SAASG,KAAK;AACZ,QAAIA,IAAIC,SAAS;AACf,aAAO;AAGT,UAAMD;AAAAA,EACR;AAGA,UADgB,MAAMN,GAAGQ,QAAQL,SAAS,GAC3BvE,WAAW;AAC5B;AAEA,eAAsB6E,SAASN,WAAkC;AAC/D,MAAI;AAEF,QAAI,EADU,MAAMH,GAAGI,KAAKD,SAAS,GAC1BE,YAAAA;AACT,YAAM,IAAInC,MAAM,aAAaiC,SAAS,qBAAqB;AAAA,EAE/D,SAASG,KAAK;AAGZ,UAFcA,IAAIC,SAAS,WAAW,IAAIrC,MAAM,cAAciC,SAAS,kBAAkB,IAAIG;AAAAA,EAG/F;AAEA,MAAI;AACF,UAAMN,GAAGI,KAAK7G,KAAKmH,KAAKP,WAAW,YAAY,CAAC;AAAA,EAClD,SAASG,KAAK;AAYZ,UAVEA,IAAIC,SAAS,WACT,IAAIrC,MACF,CACE,IAAIiC,SAAS,iCACb,+CACA,4CAA4C,EAC5CO,KAAK,GAAG,CACZ,IACAJ;AAAAA,EAGR;AACF;"}
|
package/lib/_chunks-es/index2.js
CHANGED
|
@@ -33,7 +33,7 @@ function DividerItem(t0) {
|
|
|
33
33
|
let t1;
|
|
34
34
|
$[0] !== dividerTitle ? (t1 = /* @__PURE__ */ jsx(DividerTitle, { weight: "semibold", muted: !0, size: 1, children: dividerTitle }), $[0] = dividerTitle, $[1] = t1) : t1 = $[1];
|
|
35
35
|
let t2;
|
|
36
|
-
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Divider, {}), $[2] = t2) : t2 = $[2];
|
|
36
|
+
$[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Divider, {}), $[2] = t2) : t2 = $[2];
|
|
37
37
|
let t3;
|
|
38
38
|
return $[3] !== t1 ? (t3 = /* @__PURE__ */ jsxs(DividerContainer, { children: [
|
|
39
39
|
t1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","sources":["../../src/structure/panes/list/ListPaneContent.tsx","../../src/structure/panes/list/ListPaneHeader.tsx","../../src/structure/panes/list/ListPane.tsx"],"sourcesContent":["import {Box, Text} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {\n CommandList,\n type CommandListItemContext,\n type GeneralPreviewLayoutKey,\n useGetI18nText,\n useI18nText,\n} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport {PaneContent, PaneItem, usePaneLayout} from '../../components'\nimport {type PaneListItem, type PaneListItemDivider} from '../../types'\n\ninterface ListPaneContentProps {\n childItemId?: string\n isActive?: boolean\n items: (PaneListItem<unknown> | PaneListItemDivider)[] | undefined\n layout?: GeneralPreviewLayoutKey\n showIcons: boolean\n title: string\n}\n\nconst DividerContainer = styled(Box)`\n display: flex;\n align-items: center;\n gap: 1rem;\n margin: 0.75rem 0 0.25rem 0;\n`\n\nconst Divider = styled.hr`\n flex: 1;\n background-color: var(--card-border-color);\n height: 1px;\n margin: 0;\n border: none;\n`\n\nconst DividerTitle = styled(Text)`\n padding-bottom: 0.75rem;\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n`\n\ninterface DividerItemProps {\n item: PaneListItemDivider\n}\n\nfunction DividerItem({item}: DividerItemProps) {\n const {title: dividerTitle} = useI18nText(item)\n return (\n <DividerContainer>\n <DividerTitle weight=\"semibold\" muted size={1}>\n {dividerTitle}\n </DividerTitle>\n\n <Divider />\n </DividerContainer>\n )\n}\n\n/**\n * @internal\n */\nexport function ListPaneContent(props: ListPaneContentProps) {\n const {childItemId, items, isActive, layout, showIcons, title} = props\n const {collapsed: layoutCollapsed} = usePaneLayout()\n const getI18nText = useGetI18nText(\n items?.filter(\n (item): item is Exclude<typeof item, {type: 'divider'}> => item.type !== 'divider',\n ),\n )\n\n const getItemDisabled = useCallback(\n (itemIndex: number) => {\n return items?.find((_, i) => i === itemIndex)?.type === 'divider'\n },\n [items],\n )\n\n const shouldShowIconForItem = useCallback(\n (item: PaneListItem): boolean => {\n const itemShowIcon = item.displayOptions?.showIcon\n\n // Specific true/false on item should have precedence over list setting\n if (typeof itemShowIcon !== 'undefined') {\n return itemShowIcon !== false // Boolean(item.icon)\n }\n\n // If no item setting is defined, defer to the pane settings\n return showIcons !== false // Boolean(item.icon)\n },\n [showIcons],\n )\n\n const renderItem = useCallback(\n (item: PaneListItem<unknown> | PaneListItemDivider, ctx: CommandListItemContext) => {\n const {virtualIndex: itemIndex} = ctx\n\n if (item.type === 'divider') {\n return (\n <Box key={`divider-${itemIndex}`} marginBottom={1}>\n {item.title ? <DividerItem item={item} /> : <Divider />}\n </Box>\n )\n }\n\n const pressed = !isActive && childItemId === item.id\n const selected = isActive && childItemId === item.id\n // If this is a document list item, pass on the ID and type,\n // otherwise leave it undefined to use the passed title and gang\n const value =\n item._id && item.schemaType\n ? {_id: item._id, _type: item.schemaType.name, title: item.title}\n : undefined\n\n return (\n <PaneItem\n key={item.id}\n icon={shouldShowIconForItem(item) ? item.icon : false}\n id={item.id}\n layout={layout}\n marginBottom={1}\n pressed={pressed}\n schemaType={item.schemaType}\n selected={selected}\n title={getI18nText(item).title}\n value={value}\n />\n )\n },\n [childItemId, getI18nText, isActive, layout, shouldShowIconForItem],\n )\n\n return (\n <PaneContent overflow={layoutCollapsed ? 'hidden' : 'auto'}>\n {items && items.length > 0 && (\n <CommandList\n activeItemDataAttr=\"data-hovered\"\n ariaLabel={title}\n canReceiveFocus\n getItemDisabled={getItemDisabled}\n itemHeight={51}\n items={items}\n onlyShowSelectionWhenActive\n paddingBottom={1}\n paddingX={3}\n renderItem={renderItem}\n wrapAround={false}\n />\n )}\n </PaneContent>\n )\n}\n","import {ArrowLeftIcon} from '@sanity/icons'\n\nimport {Button} from '../../../ui-components'\nimport {BackLink, PaneHeader, PaneHeaderActions, usePane} from '../../components'\nimport {type PaneMenuItem, type PaneMenuItemGroup} from '../../types'\nimport {useStructureTool} from '../../useStructureTool'\n\ninterface ListPaneHeaderProps {\n index: number\n menuItems?: PaneMenuItem[]\n menuItemGroups?: PaneMenuItemGroup[]\n title: string\n}\n\nexport const ListPaneHeader = ({index, menuItems, menuItemGroups, title}: ListPaneHeaderProps) => {\n const {features} = useStructureTool()\n const {collapsed, isLast} = usePane()\n // Prevent focus if this is the last (non-collapsed) pane.\n const tabIndex = isLast && !collapsed ? -1 : 0\n\n return (\n <PaneHeader\n actions={<PaneHeaderActions menuItems={menuItems} menuItemGroups={menuItemGroups} />}\n backButton={\n features.backButton &&\n index > 0 && (\n <Button\n as={BackLink}\n data-as=\"a\"\n icon={ArrowLeftIcon}\n mode=\"bleed\"\n tooltipProps={{content: 'Back'}}\n />\n )\n }\n tabIndex={tabIndex}\n title={title}\n />\n )\n}\n","import {Card, Code} from '@sanity/ui'\nimport {useI18nText} from 'sanity'\n\nimport {Pane} from '../../components'\nimport {_DEBUG} from '../../constants'\nimport {type BaseStructureToolPaneProps} from '../types'\nimport {ListPaneContent} from './ListPaneContent'\nimport {ListPaneHeader} from './ListPaneHeader'\n\ntype ListPaneProps = BaseStructureToolPaneProps<'list'>\n\n/**\n * @internal\n */\nexport function ListPane(props: ListPaneProps) {\n const {childItemId, index, isActive, isSelected, pane, paneKey} = props\n\n const {defaultLayout, displayOptions, items, menuItems, menuItemGroups} = pane\n const showIcons = displayOptions?.showIcons !== false\n const {title} = useI18nText(pane)\n\n return (\n <Pane\n currentMaxWidth={350}\n data-testid=\"structure-tool-list-pane\"\n data-ui=\"ListPane\"\n id={paneKey}\n maxWidth={640}\n minWidth={320}\n selected={isSelected}\n >\n {_DEBUG && (\n <Card padding={4} tone=\"transparent\">\n <Code>{pane.source || '(none)'}</Code>\n </Card>\n )}\n\n <ListPaneHeader\n index={index}\n menuItems={menuItems}\n menuItemGroups={menuItemGroups}\n title={title}\n />\n\n <ListPaneContent\n key={paneKey}\n childItemId={childItemId}\n isActive={isActive}\n items={items}\n layout={defaultLayout}\n showIcons={showIcons}\n title={title}\n />\n </Pane>\n )\n}\n"],"names":["DividerContainer","styled","Box","Divider","hr","DividerTitle","Text","DividerItem","t0","$","_c","item","title","dividerTitle","useI18nText","t1","t2","Symbol","for","t3","ListPaneContent","props","childItemId","items","isActive","layout","showIcons","collapsed","layoutCollapsed","usePaneLayout","filter","_temp","getI18nText","useGetI18nText","itemIndex","find","_","i","type","getItemDisabled","item_0","itemShowIcon","displayOptions","showIcon","shouldShowIconForItem","item_1","ctx","virtualIndex","itemIndex_0","pressed","id","selected","value","_id","schemaType","_type","name","undefined","icon","renderItem","t4","t5","length","t6","ListPaneHeader","index","menuItems","menuItemGroups","features","useStructureTool","isLast","usePane","tabIndex","backButton","BackLink","ArrowLeftIcon","content","ListPane","isSelected","pane","paneKey","defaultLayout","source","_DEBUG"],"mappings":";;;;;;;;;;AAuBA,MAAMA,mBAAmBC,OAAOC,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,GAO7BC,UAAUF,OAAOG;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,GAQjBC,eAAeJ,OAAOK,IAAI;AAAA;AAAA;AAAA;AAAA;AAUhC,SAAAC,YAAAC,IAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAqB;AAAA,IAAAC;AAAAA,EAAAA,IAAAH,IACnB;AAAA,IAAAI,OAAAC;AAAAA,EAAAA,IAA8BC,YAAYH,IAAI;AAAC,MAAAI;AAAAN,WAAAI,gBAG3CE,yBAAC,cAAA,EAAoB,QAAA,YAAW,OAAA,IAAY,MAAA,2BAE5C,GAAeN,OAAAI,cAAAJ,OAAAM,MAAAA,KAAAN,EAAA,CAAA;AAAA,MAAAO;AAAAP,IAAA,CAAA,MAAAQ,OAAAC,IAAA,2BAAA,KAEfF,KAAA,oBAAC,SAAA,CAAA,CAAO,GAAGP,OAAAO,MAAAA,KAAAP,EAAA,CAAA;AAAA,MAAAU;AAAA,SAAAV,SAAAM,MALbI,0BAAC,kBAAA,EACCJ,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AEcM,aACHE,UACHD,OACC0D,uBACGvD,WACJd,MAAAA,UAAK,GACZH,OAAAa,aAAAb,OAAAwE,eAAAxE,OAAAe,UAAAf,QAAAc,OAAAd,QAAAuE,SAAAvE,QAAAiB,WAAAjB,QAAAG,OAAAH,QAAAO,MAAAA,KAAAP,EAAA,EAAA;AAAA,MAAAU;AAAA,SAAAV,EAAA,EAAA,MAAAqE,cAAArE,EAAA,EAAA,MAAAuE,WAAAvE,EAAA,EAAA,MAAAD,MAAAC,EAAA,EAAA,MAAAM,MAAAN,UAAAO,MA9BJG,KAAA,qBAAC,MAAA,EACkB,iBAAA,KACL,eAAA,4BACJ,WAAA,YACJ6D,IAAAA,SACM,eACA,UAAA,KACAF,UAAAA,YAETtE,UAAAA;AAAAA,IAAAA;AAAAA,IAMDO;AAAAA,IAOAC;AAAAA,EAAAA,EAAAA,CASF,GAAOP,QAAAqE,YAAArE,QAAAuE,SAAAvE,QAAAD,IAAAC,QAAAM,IAAAN,QAAAO,IAAAP,QAAAU,MAAAA,KAAAV,EAAA,EAAA,GA/BPU;AA+BO;"}
|
|
1
|
+
{"version":3,"file":"index2.js","sources":["../../src/structure/panes/list/ListPaneContent.tsx","../../src/structure/panes/list/ListPaneHeader.tsx","../../src/structure/panes/list/ListPane.tsx"],"sourcesContent":["import {Box, Text} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {\n CommandList,\n type CommandListItemContext,\n type GeneralPreviewLayoutKey,\n useGetI18nText,\n useI18nText,\n} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport {PaneContent, PaneItem, usePaneLayout} from '../../components'\nimport {type PaneListItem, type PaneListItemDivider} from '../../types'\n\ninterface ListPaneContentProps {\n childItemId?: string\n isActive?: boolean\n items: (PaneListItem<unknown> | PaneListItemDivider)[] | undefined\n layout?: GeneralPreviewLayoutKey\n showIcons: boolean\n title: string\n}\n\nconst DividerContainer = styled(Box)`\n display: flex;\n align-items: center;\n gap: 1rem;\n margin: 0.75rem 0 0.25rem 0;\n`\n\nconst Divider = styled.hr`\n flex: 1;\n background-color: var(--card-border-color);\n height: 1px;\n margin: 0;\n border: none;\n`\n\nconst DividerTitle = styled(Text)`\n padding-bottom: 0.75rem;\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n`\n\ninterface DividerItemProps {\n item: PaneListItemDivider\n}\n\nfunction DividerItem({item}: DividerItemProps) {\n const {title: dividerTitle} = useI18nText(item)\n return (\n <DividerContainer>\n <DividerTitle weight=\"semibold\" muted size={1}>\n {dividerTitle}\n </DividerTitle>\n\n <Divider />\n </DividerContainer>\n )\n}\n\n/**\n * @internal\n */\nexport function ListPaneContent(props: ListPaneContentProps) {\n const {childItemId, items, isActive, layout, showIcons, title} = props\n const {collapsed: layoutCollapsed} = usePaneLayout()\n const getI18nText = useGetI18nText(\n items?.filter(\n (item): item is Exclude<typeof item, {type: 'divider'}> => item.type !== 'divider',\n ),\n )\n\n const getItemDisabled = useCallback(\n (itemIndex: number) => {\n return items?.find((_, i) => i === itemIndex)?.type === 'divider'\n },\n [items],\n )\n\n const shouldShowIconForItem = useCallback(\n (item: PaneListItem): boolean => {\n const itemShowIcon = item.displayOptions?.showIcon\n\n // Specific true/false on item should have precedence over list setting\n if (typeof itemShowIcon !== 'undefined') {\n return itemShowIcon !== false // Boolean(item.icon)\n }\n\n // If no item setting is defined, defer to the pane settings\n return showIcons !== false // Boolean(item.icon)\n },\n [showIcons],\n )\n\n const renderItem = useCallback(\n (item: PaneListItem<unknown> | PaneListItemDivider, ctx: CommandListItemContext) => {\n const {virtualIndex: itemIndex} = ctx\n\n if (item.type === 'divider') {\n return (\n <Box key={`divider-${itemIndex}`} marginBottom={1}>\n {item.title ? <DividerItem item={item} /> : <Divider />}\n </Box>\n )\n }\n\n const pressed = !isActive && childItemId === item.id\n const selected = isActive && childItemId === item.id\n // If this is a document list item, pass on the ID and type,\n // otherwise leave it undefined to use the passed title and gang\n const value =\n item._id && item.schemaType\n ? {_id: item._id, _type: item.schemaType.name, title: item.title}\n : undefined\n\n return (\n <PaneItem\n key={item.id}\n icon={shouldShowIconForItem(item) ? item.icon : false}\n id={item.id}\n layout={layout}\n marginBottom={1}\n pressed={pressed}\n schemaType={item.schemaType}\n selected={selected}\n title={getI18nText(item).title}\n value={value}\n />\n )\n },\n [childItemId, getI18nText, isActive, layout, shouldShowIconForItem],\n )\n\n return (\n <PaneContent overflow={layoutCollapsed ? 'hidden' : 'auto'}>\n {items && items.length > 0 && (\n <CommandList\n activeItemDataAttr=\"data-hovered\"\n ariaLabel={title}\n canReceiveFocus\n getItemDisabled={getItemDisabled}\n itemHeight={51}\n items={items}\n onlyShowSelectionWhenActive\n paddingBottom={1}\n paddingX={3}\n renderItem={renderItem}\n wrapAround={false}\n />\n )}\n </PaneContent>\n )\n}\n","import {ArrowLeftIcon} from '@sanity/icons'\n\nimport {Button} from '../../../ui-components'\nimport {BackLink, PaneHeader, PaneHeaderActions, usePane} from '../../components'\nimport {type PaneMenuItem, type PaneMenuItemGroup} from '../../types'\nimport {useStructureTool} from '../../useStructureTool'\n\ninterface ListPaneHeaderProps {\n index: number\n menuItems?: PaneMenuItem[]\n menuItemGroups?: PaneMenuItemGroup[]\n title: string\n}\n\nexport const ListPaneHeader = ({index, menuItems, menuItemGroups, title}: ListPaneHeaderProps) => {\n const {features} = useStructureTool()\n const {collapsed, isLast} = usePane()\n // Prevent focus if this is the last (non-collapsed) pane.\n const tabIndex = isLast && !collapsed ? -1 : 0\n\n return (\n <PaneHeader\n actions={<PaneHeaderActions menuItems={menuItems} menuItemGroups={menuItemGroups} />}\n backButton={\n features.backButton &&\n index > 0 && (\n <Button\n as={BackLink}\n data-as=\"a\"\n icon={ArrowLeftIcon}\n mode=\"bleed\"\n tooltipProps={{content: 'Back'}}\n />\n )\n }\n tabIndex={tabIndex}\n title={title}\n />\n )\n}\n","import {Card, Code} from '@sanity/ui'\nimport {useI18nText} from 'sanity'\n\nimport {Pane} from '../../components'\nimport {_DEBUG} from '../../constants'\nimport {type BaseStructureToolPaneProps} from '../types'\nimport {ListPaneContent} from './ListPaneContent'\nimport {ListPaneHeader} from './ListPaneHeader'\n\ntype ListPaneProps = BaseStructureToolPaneProps<'list'>\n\n/**\n * @internal\n */\nexport function ListPane(props: ListPaneProps) {\n const {childItemId, index, isActive, isSelected, pane, paneKey} = props\n\n const {defaultLayout, displayOptions, items, menuItems, menuItemGroups} = pane\n const showIcons = displayOptions?.showIcons !== false\n const {title} = useI18nText(pane)\n\n return (\n <Pane\n currentMaxWidth={350}\n data-testid=\"structure-tool-list-pane\"\n data-ui=\"ListPane\"\n id={paneKey}\n maxWidth={640}\n minWidth={320}\n selected={isSelected}\n >\n {_DEBUG && (\n <Card padding={4} tone=\"transparent\">\n <Code>{pane.source || '(none)'}</Code>\n </Card>\n )}\n\n <ListPaneHeader\n index={index}\n menuItems={menuItems}\n menuItemGroups={menuItemGroups}\n title={title}\n />\n\n <ListPaneContent\n key={paneKey}\n childItemId={childItemId}\n isActive={isActive}\n items={items}\n layout={defaultLayout}\n showIcons={showIcons}\n title={title}\n />\n </Pane>\n )\n}\n"],"names":["DividerContainer","styled","Box","Divider","hr","DividerTitle","Text","DividerItem","t0","$","_c","item","title","dividerTitle","useI18nText","t1","t2","Symbol","for","t3","ListPaneContent","props","childItemId","items","isActive","layout","showIcons","collapsed","layoutCollapsed","usePaneLayout","filter","_temp","getI18nText","useGetI18nText","itemIndex","find","_","i","type","getItemDisabled","item_0","itemShowIcon","displayOptions","showIcon","shouldShowIconForItem","item_1","ctx","virtualIndex","itemIndex_0","pressed","id","selected","value","_id","schemaType","_type","name","undefined","icon","renderItem","t4","t5","length","t6","ListPaneHeader","index","menuItems","menuItemGroups","features","useStructureTool","isLast","usePane","tabIndex","backButton","BackLink","ArrowLeftIcon","content","ListPane","isSelected","pane","paneKey","defaultLayout","source","_DEBUG"],"mappings":";;;;;;;;;;AAuBA,MAAMA,mBAAmBC,OAAOC,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,GAO7BC,UAAUF,OAAOG;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IAAAP,QAAAU,MAAAA,KAAAV,EAAA,EAAA,GA/BPU;AA+BO;"}
|
package/lib/_chunks-es/index3.js
CHANGED
|
@@ -429,7 +429,7 @@ function useResolvedPanes() {
|
|
|
429
429
|
rootPaneNode
|
|
430
430
|
} = useStructureTool();
|
|
431
431
|
let t0;
|
|
432
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
432
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
433
433
|
paneDataItems: [],
|
|
434
434
|
resolvedPanes: [],
|
|
435
435
|
routerPanes: []
|
|
@@ -658,7 +658,7 @@ function NoDocumentTypesScreen() {
|
|
|
658
658
|
t
|
|
659
659
|
} = useTranslation(structureLocaleNamespace);
|
|
660
660
|
let t0;
|
|
661
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(WarningOutlineIcon, {}) }) }), $[0] = t0) : t0 = $[0];
|
|
661
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(WarningOutlineIcon, {}) }) }), $[0] = t0) : t0 = $[0];
|
|
662
662
|
let t1;
|
|
663
663
|
$[1] !== t ? (t1 = t("no-document-types-screen.title"), $[1] = t, $[2] = t1) : t1 = $[2];
|
|
664
664
|
let t2;
|
|
@@ -726,7 +726,7 @@ const DocumentTitle = (props) => {
|
|
|
726
726
|
const lastPane = resolvedPanes[resolvedPanes.length - 1];
|
|
727
727
|
if (isLoadingPane(lastPane)) {
|
|
728
728
|
let t02;
|
|
729
|
-
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsx(PassthroughTitle, {}), $[0] = t02) : t02 = $[0], t02;
|
|
729
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t02 = /* @__PURE__ */ jsx(PassthroughTitle, {}), $[0] = t02) : t02 = $[0], t02;
|
|
730
730
|
}
|
|
731
731
|
if (isDocumentPane(lastPane)) {
|
|
732
732
|
if (lastPane?.title) {
|
|
@@ -847,7 +847,7 @@ const StyledPaneLayout = styled(PaneLayout)`
|
|
|
847
847
|
}
|
|
848
848
|
}, t11 = [maximizedPane, paneDataItems, setMaximizedPane], $[17] = maximizedPane, $[18] = paneDataItems, $[19] = setMaximizedPane, $[20] = t10, $[21] = t11) : (t10 = $[20], t11 = $[21]), useEffect(t10, t11), !hasDefinedDocumentTypes) {
|
|
849
849
|
let t122;
|
|
850
|
-
return $[22] === Symbol.for("react.memo_cache_sentinel") ? (t122 = /* @__PURE__ */ jsx(NoDocumentTypesScreen, {}), $[22] = t122) : t122 = $[22], t122;
|
|
850
|
+
return $[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t122 = /* @__PURE__ */ jsx(NoDocumentTypesScreen, {}), $[22] = t122) : t122 = $[22], t122;
|
|
851
851
|
}
|
|
852
852
|
const t12 = portalElement || null, t13 = layoutCollapsed ? void 0 : "fill", t14 = media[1];
|
|
853
853
|
let t15;
|
|
@@ -883,7 +883,7 @@ const StyledPaneLayout = styled(PaneLayout)`
|
|
|
883
883
|
let t18;
|
|
884
884
|
$[38] !== resolvedPanes ? (t18 = /* @__PURE__ */ jsx(StructureTitle, { resolvedPanes }), $[38] = resolvedPanes, $[39] = t18) : t18 = $[39];
|
|
885
885
|
let t19;
|
|
886
|
-
$[40] === Symbol.for("react.memo_cache_sentinel") ? (t19 = /* @__PURE__ */ jsx("div", { "data-portal": "", ref: setPortalElement }), $[40] = t19) : t19 = $[40];
|
|
886
|
+
$[40] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t19 = /* @__PURE__ */ jsx("div", { "data-portal": "", ref: setPortalElement }), $[40] = t19) : t19 = $[40];
|
|
887
887
|
let t20;
|
|
888
888
|
$[41] !== t12 || $[42] !== t17 || $[43] !== t18 ? (t20 = /* @__PURE__ */ jsxs(PortalProvider, { element: t12, children: [
|
|
889
889
|
t17,
|
|
@@ -918,9 +918,9 @@ function StructureToolBoundary(t0) {
|
|
|
918
918
|
structure
|
|
919
919
|
} = t2;
|
|
920
920
|
let t3;
|
|
921
|
-
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[2] = t3) : t3 = $[2], useEffect(_temp2, t3);
|
|
921
|
+
$[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[2] = t3) : t3 = $[2], useEffect(_temp2, t3);
|
|
922
922
|
let t4;
|
|
923
|
-
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
|
923
|
+
$[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
|
924
924
|
error: null
|
|
925
925
|
}, $[3] = t4) : t4 = $[3];
|
|
926
926
|
const [t5, setError] = useState(t4), {
|
|
@@ -932,7 +932,7 @@ function StructureToolBoundary(t0) {
|
|
|
932
932
|
}
|
|
933
933
|
const t6 = source || firstSource.name;
|
|
934
934
|
let t7, t8;
|
|
935
|
-
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t7 = /* @__PURE__ */ jsx(StructureTool, { onPaneChange: setActivePanes }), t8 = /* @__PURE__ */ jsx(IntentResolver, {}), $[6] = t7, $[7] = t8) : (t7 = $[6], t8 = $[7]);
|
|
935
|
+
$[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = /* @__PURE__ */ jsx(StructureTool, { onPaneChange: setActivePanes }), t8 = /* @__PURE__ */ jsx(IntentResolver, {}), $[6] = t7, $[7] = t8) : (t7 = $[6], t8 = $[7]);
|
|
936
936
|
let t9;
|
|
937
937
|
$[8] !== defaultDocumentNode || $[9] !== structure ? (t9 = /* @__PURE__ */ jsxs(StructureToolProvider, { defaultDocumentNode, structure, children: [
|
|
938
938
|
t7,
|