@sanity/cli 8.3.0 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/build/buildApp.js +14 -7
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +3 -3
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +32 -25
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +2 -1
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js +2 -4
- package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js.map +1 -1
- package/dist/actions/deploy/deploymentPlan.js.map +1 -1
- package/dist/actions/dev/devAction.js +6 -4
- package/dist/actions/dev/devAction.js.map +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js +13 -6
- package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
- package/dist/actions/dev/servers/startAppDevServer.js +4 -2
- package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
- package/dist/actions/graphql/gen1/generateTypeFilters.js +1 -2
- package/dist/actions/graphql/gen1/generateTypeFilters.js.map +1 -1
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js +5 -2
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js.map +1 -1
- package/dist/actions/init/templates/shopify.js +2 -1
- package/dist/actions/init/templates/shopify.js.map +1 -1
- package/dist/actions/manifest/extractManifest.js +5 -37
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/manifest/extractStudioManifest.js +1 -1
- package/dist/actions/manifest/extractStudioManifest.js.map +1 -1
- package/dist/actions/preview/previewAction.js +1 -1
- package/dist/actions/preview/previewAction.js.map +1 -1
- package/dist/actions/schema/deleteSchemaAction.js +1 -1
- package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
- package/dist/actions/schema/deploySchemas.js.map +1 -1
- package/dist/actions/schema/extractSanityWorkspace.worker.js +1 -1
- package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -1
- package/dist/actions/schema/listSchemas.js +1 -1
- package/dist/actions/schema/listSchemas.js.map +1 -1
- package/dist/actions/schema/schemaTypeHelpers.js +5 -0
- package/dist/actions/schema/schemaTypeHelpers.js.map +1 -0
- package/dist/actions/schema/updateWorkspaceSchema.js +1 -1
- package/dist/actions/schema/updateWorkspaceSchema.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreValidation.js +2 -2
- package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
- package/dist/actions/schema/utils/workspaceSchemaId.js +1 -1
- package/dist/actions/schema/utils/workspaceSchemaId.js.map +1 -1
- package/dist/actions/versions/getFormatters.js +1 -2
- package/dist/actions/versions/getFormatters.js.map +1 -1
- package/dist/commands/documents/create.js +4 -4
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/hooks/logs.js +1 -2
- package/dist/commands/hooks/logs.js.map +1 -1
- package/dist/commands/projects/list.js +3 -5
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/undeploy.js +7 -5
- package/dist/commands/undeploy.js.map +1 -1
- package/dist/commands/users/list.js +3 -5
- package/dist/commands/users/list.js.map +1 -1
- package/dist/commands/versions.js +1 -2
- package/dist/commands/versions.js.map +1 -1
- package/dist/exports/_internal.d.ts +1 -67
- package/dist/exports/_internal.js +1 -1
- package/dist/exports/_internal.js.map +1 -1
- package/dist/exports/index.d.ts +2 -2
- package/dist/exports/index.js +2 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/runtime.d.ts +2 -2
- package/dist/exports/runtime.js +1 -1
- package/dist/exports/runtime.js.map +1 -1
- package/dist/generated/apiRoutes.js +4 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/prompts/selectMediaLibrary.js +2 -3
- package/dist/prompts/selectMediaLibrary.js.map +1 -1
- package/dist/services/mintProject.js +27 -14
- package/dist/services/mintProject.js.map +1 -1
- package/dist/services/schemas.js.map +1 -1
- package/dist/services/userApplications.js.map +1 -1
- package/dist/util/determineIsApp.js +1 -1
- package/dist/util/determineIsApp.js.map +1 -1
- package/dist/util/sortRowsByColumn.js +23 -0
- package/dist/util/sortRowsByColumn.js.map +1 -0
- package/oclif.manifest.json +353 -353
- package/package.json +7 -10
- package/dist/actions/manifest/blockTypeTransformer.js +0 -67
- package/dist/actions/manifest/blockTypeTransformer.js.map +0 -1
- package/dist/actions/manifest/extractCoreAppManifest.js +0 -111
- package/dist/actions/manifest/extractCoreAppManifest.js.map +0 -1
- package/dist/actions/manifest/extractManifest.worker.js +0 -30
- package/dist/actions/manifest/extractManifest.worker.js.map +0 -1
- package/dist/actions/manifest/extractWorkspaceManifest.js +0 -72
- package/dist/actions/manifest/extractWorkspaceManifest.js.map +0 -1
- package/dist/actions/manifest/iconResolver.js +0 -36
- package/dist/actions/manifest/iconResolver.js.map +0 -1
- package/dist/actions/manifest/purifyConfig.js +0 -307
- package/dist/actions/manifest/purifyConfig.js.map +0 -1
- package/dist/actions/manifest/referenceTransformer.js +0 -51
- package/dist/actions/manifest/referenceTransformer.js.map +0 -1
- package/dist/actions/manifest/resolveSchemaIcon.js +0 -43
- package/dist/actions/manifest/resolveSchemaIcon.js.map +0 -1
- package/dist/actions/manifest/sanitizeIcon.js +0 -13
- package/dist/actions/manifest/sanitizeIcon.js.map +0 -1
- package/dist/actions/manifest/schemaTypeHelpers.js +0 -110
- package/dist/actions/manifest/schemaTypeHelpers.js.map +0 -1
- package/dist/actions/manifest/schemaTypeTransformer.js +0 -169
- package/dist/actions/manifest/schemaTypeTransformer.js.map +0 -1
- package/dist/actions/manifest/transformerUtils.js +0 -40
- package/dist/actions/manifest/transformerUtils.js.map +0 -1
- package/dist/actions/manifest/types.js +0 -13
- package/dist/actions/manifest/types.js.map +0 -1
- package/dist/actions/manifest/validationTransformer.js +0 -84
- package/dist/actions/manifest/validationTransformer.js.map +0 -1
- package/dist/actions/manifest/writeManifestFile.js +0 -29
- package/dist/actions/manifest/writeManifestFile.js.map +0 -1
- package/dist/actions/manifest/writeWorkspaceFiles.js +0 -30
- package/dist/actions/manifest/writeWorkspaceFiles.js.map +0 -1
- package/dist/actions/schema/uploadSchemaToLexicon.js +0 -91
- package/dist/actions/schema/uploadSchemaToLexicon.js.map +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
2
|
-
import { extractValidationFromSchemaError } from '@sanity/cli-build/_internal/extract';
|
|
2
|
+
import { extractValidationFromSchemaError, uploadSchemaToLexicon } from '@sanity/cli-build/_internal/extract';
|
|
3
|
+
import { extractWorkspaceManifest, writeManifestFile } from '@sanity/cli-build/_internal/manifest';
|
|
3
4
|
import { getStudioWorkspaces, subdebug } from '@sanity/cli-core';
|
|
4
|
-
import { extractWorkspaceManifest } from '../manifest/extractWorkspaceManifest.js';
|
|
5
|
-
import { writeManifestFile } from '../manifest/writeManifestFile.js';
|
|
6
5
|
import { updateWorkspacesSchemas } from '../schema/updateWorkspaceSchema.js';
|
|
7
|
-
import { uploadSchemaToLexicon } from '../schema/uploadSchemaToLexicon.js';
|
|
8
6
|
import { deployStudioSchemasAndManifestsWorkerData } from './types.js';
|
|
9
7
|
const debug = subdebug('deployStudioSchemasAndManifests.worker');
|
|
10
8
|
async function main() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deployStudioSchemasAndManifests.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {extractValidationFromSchemaError} from '@sanity/cli-build/_internal/extract'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deployStudioSchemasAndManifests.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {\n extractValidationFromSchemaError,\n uploadSchemaToLexicon,\n} from '@sanity/cli-build/_internal/extract'\nimport {\n type CreateWorkspaceManifest,\n extractWorkspaceManifest,\n writeManifestFile,\n} from '@sanity/cli-build/_internal/manifest'\nimport {getStudioWorkspaces, subdebug} from '@sanity/cli-core'\nimport {type StudioManifest, type Workspace} from 'sanity'\n\nimport {\n updateWorkspacesSchemas,\n type WorkspaceSchemaInput,\n} from '../schema/updateWorkspaceSchema.js'\nimport {deployStudioSchemasAndManifestsWorkerData} from './types.js'\n\nconst debug = subdebug('deployStudioSchemasAndManifests.worker')\n\nasync function main() {\n if (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n }\n\n const {configPath, isExternal, outPath, projectId, schemaRequired, verbose, workDir} =\n deployStudioSchemasAndManifestsWorkerData.parse(workerData)\n\n try {\n debug('Deploying studio schemas and manifests from config path %s', configPath)\n const workspaces = await getStudioWorkspaces(configPath)\n debug('Workspaces %o', workspaces)\n\n if (workspaces.length === 0) {\n throw new Error('No workspaces found')\n }\n\n // Extract manifest data (including ManifestSchemaType[]) once, while Schema objects are\n // still live. Both writeWorkspaceToDist and updateWorkspacesSchemas consume the result.\n const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir)\n\n const schemaInputs: WorkspaceSchemaInput[] = workspaceManifests.map((manifest) => ({\n dataset: manifest.dataset,\n manifestSchema: manifest.schema,\n name: manifest.name,\n projectId: manifest.projectId,\n title: manifest.title,\n }))\n\n debug('Handling deployment for %s', isExternal ? 'external' : 'internal')\n\n let studioManifest: StudioManifest | null = null\n\n if (isExternal) {\n ;[studioManifest] = await handleExternalDeployment({\n projectId,\n schemaInputs,\n schemaRequired,\n verbose,\n workDir,\n workspaces,\n })\n } else {\n ;[studioManifest] = await handleInternalDeployment({\n outPath,\n projectId,\n schemaInputs,\n verbose,\n workDir,\n workspaceManifests,\n workspaces,\n })\n }\n\n parentPort.postMessage({\n studioManifest,\n type: 'success',\n })\n } catch (error) {\n debug('Error deploying studio schemas and manifests', error)\n const validation = await extractValidationFromSchemaError(error, workDir)\n parentPort.postMessage({\n error: error instanceof Error ? error.message : String(error),\n type: 'error',\n validation,\n })\n }\n}\n\n/**\n * External deployments:\n * 1. Update the workspace schemas to the /schemas endpoint IF --schema-required is passed\n * 2. Update server-side schemas\n */\nasync function handleExternalDeployment({\n projectId,\n schemaInputs,\n schemaRequired,\n verbose,\n workDir,\n workspaces,\n}: {\n projectId: string\n schemaInputs: WorkspaceSchemaInput[]\n schemaRequired: boolean\n verbose: boolean\n workDir: string\n workspaces: Workspace[]\n}): Promise<[StudioManifest | null]> {\n const [studioManifest] = await Promise.all([\n uploadSchemaToLexicon({\n projectId,\n verbose,\n workDir,\n workspaces,\n }),\n schemaRequired ? updateWorkspacesSchemas({verbose, workspaces: schemaInputs}) : undefined,\n ])\n\n return [studioManifest]\n}\n\n/**\n *\n * Internal deployments:\n * 1. Write the workspace manifests to the dist directory\n * 2. Update the workspaces schemas to the /schemas endpoint\n * 3. Update server-side schemas\n *\n * @param workspaces - The workspaces to deploy\n */\nasync function handleInternalDeployment({\n outPath,\n projectId,\n schemaInputs,\n verbose,\n workDir,\n workspaceManifests,\n workspaces,\n}: {\n outPath: string\n projectId: string\n schemaInputs: WorkspaceSchemaInput[]\n verbose: boolean\n workDir: string\n workspaceManifests: CreateWorkspaceManifest[]\n workspaces: Workspace[]\n}): Promise<[StudioManifest | null]> {\n const [studioManifest] = await Promise.all([\n uploadSchemaToLexicon({\n projectId,\n verbose,\n workDir,\n workspaces,\n }),\n writeManifestFile({outPath, workDir, workspaceManifests}),\n // Updates the workspaces schemas to /schemas endpoint\n updateWorkspacesSchemas({\n verbose,\n workspaces: schemaInputs,\n }),\n ])\n\n return [studioManifest]\n}\n\nawait main()\n"],"names":["isMainThread","parentPort","workerData","extractValidationFromSchemaError","uploadSchemaToLexicon","extractWorkspaceManifest","writeManifestFile","getStudioWorkspaces","subdebug","updateWorkspacesSchemas","deployStudioSchemasAndManifestsWorkerData","debug","main","Error","configPath","isExternal","outPath","projectId","schemaRequired","verbose","workDir","parse","workspaces","length","workspaceManifests","schemaInputs","map","manifest","dataset","manifestSchema","schema","name","title","studioManifest","handleExternalDeployment","handleInternalDeployment","postMessage","type","error","validation","message","String","Promise","all","undefined"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SACEC,gCAAgC,EAChCC,qBAAqB,QAChB,sCAAqC;AAC5C,SAEEC,wBAAwB,EACxBC,iBAAiB,QACZ,uCAAsC;AAC7C,SAAQC,mBAAmB,EAAEC,QAAQ,QAAO,mBAAkB;AAG9D,SACEC,uBAAuB,QAElB,qCAAoC;AAC3C,SAAQC,yCAAyC,QAAO,aAAY;AAEpE,MAAMC,QAAQH,SAAS;AAEvB,eAAeI;IACb,IAAIZ,gBAAgB,CAACC,YAAY;QAC/B,MAAM,IAAIY,MAAM;IAClB;IAEA,MAAM,EAACC,UAAU,EAAEC,UAAU,EAAEC,OAAO,EAAEC,SAAS,EAAEC,cAAc,EAAEC,OAAO,EAAEC,OAAO,EAAC,GAClFV,0CAA0CW,KAAK,CAACnB;IAElD,IAAI;QACFS,MAAM,8DAA8DG;QACpE,MAAMQ,aAAa,MAAMf,oBAAoBO;QAC7CH,MAAM,iBAAiBW;QAEvB,IAAIA,WAAWC,MAAM,KAAK,GAAG;YAC3B,MAAM,IAAIV,MAAM;QAClB;QAEA,wFAAwF;QACxF,wFAAwF;QACxF,MAAMW,qBAAqB,MAAMnB,yBAAyBiB,YAAYF;QAEtE,MAAMK,eAAuCD,mBAAmBE,GAAG,CAAC,CAACC,WAAc,CAAA;gBACjFC,SAASD,SAASC,OAAO;gBACzBC,gBAAgBF,SAASG,MAAM;gBAC/BC,MAAMJ,SAASI,IAAI;gBACnBd,WAAWU,SAASV,SAAS;gBAC7Be,OAAOL,SAASK,KAAK;YACvB,CAAA;QAEArB,MAAM,8BAA8BI,aAAa,aAAa;QAE9D,IAAIkB,iBAAwC;QAE5C,IAAIlB,YAAY;;YACb,CAACkB,eAAe,GAAG,MAAMC,yBAAyB;gBACjDjB;gBACAQ;gBACAP;gBACAC;gBACAC;gBACAE;YACF;QACF,OAAO;;YACJ,CAACW,eAAe,GAAG,MAAME,yBAAyB;gBACjDnB;gBACAC;gBACAQ;gBACAN;gBACAC;gBACAI;gBACAF;YACF;QACF;QAEArB,WAAWmC,WAAW,CAAC;YACrBH;YACAI,MAAM;QACR;IACF,EAAE,OAAOC,OAAO;QACd3B,MAAM,gDAAgD2B;QACtD,MAAMC,aAAa,MAAMpC,iCAAiCmC,OAAOlB;QACjEnB,WAAWmC,WAAW,CAAC;YACrBE,OAAOA,iBAAiBzB,QAAQyB,MAAME,OAAO,GAAGC,OAAOH;YACvDD,MAAM;YACNE;QACF;IACF;AACF;AAEA;;;;CAIC,GACD,eAAeL,yBAAyB,EACtCjB,SAAS,EACTQ,YAAY,EACZP,cAAc,EACdC,OAAO,EACPC,OAAO,EACPE,UAAU,EAQX;IACC,MAAM,CAACW,eAAe,GAAG,MAAMS,QAAQC,GAAG,CAAC;QACzCvC,sBAAsB;YACpBa;YACAE;YACAC;YACAE;QACF;QACAJ,iBAAiBT,wBAAwB;YAACU;YAASG,YAAYG;QAAY,KAAKmB;KACjF;IAED,OAAO;QAACX;KAAe;AACzB;AAEA;;;;;;;;CAQC,GACD,eAAeE,yBAAyB,EACtCnB,OAAO,EACPC,SAAS,EACTQ,YAAY,EACZN,OAAO,EACPC,OAAO,EACPI,kBAAkB,EAClBF,UAAU,EASX;IACC,MAAM,CAACW,eAAe,GAAG,MAAMS,QAAQC,GAAG,CAAC;QACzCvC,sBAAsB;YACpBa;YACAE;YACAC;YACAE;QACF;QACAhB,kBAAkB;YAACU;YAASI;YAASI;QAAkB;QACvD,sDAAsD;QACtDf,wBAAwB;YACtBU;YACAG,YAAYG;QACd;KACD;IAED,OAAO;QAACQ;KAAe;AACzB;AAEA,MAAMrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/deploy/deploymentPlan.ts"],"sourcesContent":["import {readdir, stat} from 'node:fs/promises'\nimport {join, relative, sep} from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\nimport {type
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/deploy/deploymentPlan.ts"],"sourcesContent":["import {readdir, stat} from 'node:fs/promises'\nimport {join, relative, sep} from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\nimport {\n type DeployedView,\n type DeployedWebWorker,\n summarizeInterfaces,\n} from '@sanity/workbench-cli/deploy'\n\nimport {checkStatusIcon, nestLines, renderIssues} from '../../util/checks.js'\nimport {pluralize} from '../../util/pluralize.js'\nimport {type DeployCheck, type DeployCheckReporter, type DeployTarget} from './deployChecks.js'\nimport {type DeployPayload} from './deployRunner.js'\n\nexport interface DeploymentFile {\n /** Path relative to the project root, POSIX-style. */\n path: string\n size: number\n}\n\n/** What a `--dry-run` deploy would do: the real deploy sequence with every mutation gated off. */\nexport interface DeploymentPlan {\n checks: DeployCheck[]\n files: DeploymentFile[]\n /** `null` when the run bailed before collecting it. */\n payload: DeployPayload | null\n /** The resolved deploy target; `null` when the checks can't determine one. */\n target: DeployTarget | null\n type: 'coreApp' | 'studio'\n}\n\n/**\n * Lists the files a deploy would pack from `sourceDir`, as paths relative to\n * `fromDir`. A missing directory yields an empty list rather than throwing.\n */\nexport async function listDeploymentFiles(\n sourceDir: string,\n fromDir: string,\n): Promise<DeploymentFile[]> {\n const walk = async (dir: string): Promise<string[]> => {\n let entries\n try {\n entries = await readdir(dir, {withFileTypes: true})\n } catch {\n return []\n }\n const nested = await Promise.all(\n entries.map((entry) => {\n const full = join(dir, entry.name)\n return entry.isDirectory() ? walk(full) : Promise.resolve([full])\n }),\n )\n return nested.flat()\n }\n\n const absolute = await walk(sourceDir)\n const files = await Promise.all(\n absolute.map(async (file) => ({\n // Deploy paths are POSIX-style regardless of the host OS (Windows gives `\\`).\n path: relative(fromDir, file).split(sep).join('/'),\n size: (await stat(file)).size,\n })),\n )\n return files.toSorted((a, b) => a.path.localeCompare(b.path))\n}\n\nexport function isDeployable(plan: DeploymentPlan): boolean {\n return plan.checks.every((check) => check.status !== 'fail')\n}\n\nfunction totalBytes(files: DeploymentFile[]): number {\n return files.reduce((sum, file) => sum + file.size, 0)\n}\n\n/**\n * A problem-focused, machine-readable projection of the plan: blocking problems\n * mapped to their fix, warnings as messages. Derived from the same checks the\n * human report renders (its pass/skip lines are informational and omitted here).\n */\nexport function deploymentPlanToJson(plan: DeploymentPlan): {\n action: DeployTarget['action'] | null\n application: null\n canDeploy: boolean\n errors: Record<string, string | null>\n files: DeploymentFile[]\n payload: DeployPayload | null\n reason: string | null\n totalBytes: number\n url: string | null\n warnings: string[]\n} {\n const errors: Record<string, string | null> = {}\n const warnings: string[] = []\n for (const check of plan.checks) {\n if (check.status === 'fail') errors[check.message] = check.solution ?? null\n else if (check.status === 'warn') warnings.push(check.message)\n }\n\n return {\n action: plan.target?.action ?? null,\n // Only a successful deploy reports the backend's record.\n application: null,\n canDeploy: isDeployable(plan),\n errors,\n files: plan.files,\n payload: plan.payload,\n reason: plan.checks.find((check) => check.status === 'fail')?.message ?? null,\n totalBytes: totalBytes(plan.files),\n url: plan.target?.url ?? null,\n warnings,\n }\n}\n\nexport function reportInterfaces(\n reporter: DeployCheckReporter,\n app: Parameters<typeof summarizeInterfaces>[0],\n): {services: DeployedWebWorker[]; views: DeployedView[]} {\n const {lines, services, views} = summarizeInterfaces(app)\n for (const message of lines) reporter.report({message, status: 'pass'})\n return {services, views}\n}\n\nexport function renderDeploymentPlan(plan: DeploymentPlan, output: Output): void {\n const label = plan.type === 'coreApp' ? 'application' : 'studio'\n const problems = plan.checks.filter((check) => check.status === 'fail')\n const warnings = plan.checks.filter((check) => check.status === 'warn')\n\n output.log('\\nDry run — no changes made.\\n')\n\n // Only pass/skip here; problems and warnings render below with their fixes.\n for (const check of plan.checks) {\n if (check.status === 'pass' || check.status === 'skip') {\n output.log(nestLines(` ${checkStatusIcon(check.status)} ${check.message}`))\n }\n }\n\n output.log(\n isDeployable(plan)\n ? styleText('green', `\\nThis ${label} can be deployed.`)\n : styleText('red', `\\nThis ${label} can't be deployed.`),\n )\n\n renderIssues(output, 'Problems to fix:', problems)\n renderIssues(output, 'Warnings:', warnings)\n\n // A blocked deploy uploads nothing, so only list files for a deployable plan.\n if (isDeployable(plan) && plan.files.length > 0) {\n output.log(\n `\\nFiles to deploy (${plan.files.length} ${pluralize('file', plan.files.length)}, ${formatMB(totalBytes(plan.files))}):`,\n )\n for (const file of plan.files) {\n output.log(` ${file.path} (${formatMB(file.size)})`)\n }\n }\n}\n\nfunction formatMB(bytes: number): string {\n return `${(bytes / 1024 / 1024).toFixed(2)} MB`\n}\n"],"names":["readdir","stat","join","relative","sep","styleText","summarizeInterfaces","checkStatusIcon","nestLines","renderIssues","pluralize","listDeploymentFiles","sourceDir","fromDir","walk","dir","entries","withFileTypes","nested","Promise","all","map","entry","full","name","isDirectory","resolve","flat","absolute","files","file","path","split","size","toSorted","a","b","localeCompare","isDeployable","plan","checks","every","check","status","totalBytes","reduce","sum","deploymentPlanToJson","errors","warnings","message","solution","push","action","target","application","canDeploy","payload","reason","find","url","reportInterfaces","reporter","app","lines","services","views","report","renderDeploymentPlan","output","label","type","problems","filter","log","length","formatMB","bytes","toFixed"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,IAAI,QAAO,mBAAkB;AAC9C,SAAQC,IAAI,EAAEC,QAAQ,EAAEC,GAAG,QAAO,YAAW;AAC7C,SAAQC,SAAS,QAAO,YAAW;AAGnC,SAGEC,mBAAmB,QACd,+BAA8B;AAErC,SAAQC,eAAe,EAAEC,SAAS,EAAEC,YAAY,QAAO,uBAAsB;AAC7E,SAAQC,SAAS,QAAO,0BAAyB;AAqBjD;;;CAGC,GACD,OAAO,eAAeC,oBACpBC,SAAiB,EACjBC,OAAe;IAEf,MAAMC,OAAO,OAAOC;QAClB,IAAIC;QACJ,IAAI;YACFA,UAAU,MAAMhB,QAAQe,KAAK;gBAACE,eAAe;YAAI;QACnD,E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,EAAEiE,MAAM,iBAAiB,CAAC,IACrDjE,UAAU,OAAO,CAAC,OAAO,EAAEiE,MAAM,mBAAmB,CAAC;IAG3D7D,aAAa4D,QAAQ,oBAAoBG;IACzC/D,aAAa4D,QAAQ,aAAapB;IAElC,8EAA8E;IAC9E,IAAIX,aAAaC,SAASA,KAAKV,KAAK,CAAC8C,MAAM,GAAG,GAAG;QAC/CN,OAAOK,GAAG,CACR,CAAC,mBAAmB,EAAEnC,KAAKV,KAAK,CAAC8C,MAAM,CAAC,CAAC,EAAEjE,UAAU,QAAQ6B,KAAKV,KAAK,CAAC8C,MAAM,EAAE,EAAE,EAAEC,SAAShC,WAAWL,KAAKV,KAAK,GAAG,EAAE,CAAC;QAE1H,KAAK,MAAMC,QAAQS,KAAKV,KAAK,CAAE;YAC7BwC,OAAOK,GAAG,CAAC,CAAC,EAAE,EAAE5C,KAAKC,IAAI,CAAC,EAAE,EAAE6C,SAAS9C,KAAKG,IAAI,EAAE,CAAC,CAAC;QACtD;IACF;AACF;AAEA,SAAS2C,SAASC,KAAa;IAC7B,OAAO,GAAG,AAACA,CAAAA,QAAQ,OAAO,IAAG,EAAGC,OAAO,CAAC,GAAG,GAAG,CAAC;AACjD"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { SANITY_CACHE_DIR } from '@sanity/cli-build/_internal/build';
|
|
2
|
-
import {
|
|
2
|
+
import { extractCoreAppManifest } from '@sanity/cli-build/_internal/manifest';
|
|
3
|
+
import { isWorkbenchApp, isWorkbenchConfig } from '@sanity/workbench-cli';
|
|
3
4
|
import { checkForDeprecatedAppId } from '../../util/appId.js';
|
|
4
5
|
import { getSharedServerConfig } from '../../util/getSharedServerConfig.js';
|
|
5
6
|
import { resolveReactStrictMode } from '../../util/resolveReactStrictMode.js';
|
|
6
|
-
import { extractCoreAppManifest } from '../manifest/extractCoreAppManifest.js';
|
|
7
7
|
import { extractStudioManifest } from '../manifest/extractStudioManifest.js';
|
|
8
8
|
import { startAppDevServer } from './servers/startAppDevServer.js';
|
|
9
9
|
import { startStudioDevServer } from './servers/startStudioDevServer.js';
|
|
10
10
|
const noop = async ()=>{};
|
|
11
11
|
/**
|
|
12
12
|
* Entry point for `sanity dev`. A plain studio/app starts a single dev server, as
|
|
13
|
-
* before workbench existed. A workbench app (via `
|
|
13
|
+
* before workbench existed. A workbench app (via `defineApplication`) delegates to
|
|
14
14
|
* `@sanity/workbench-cli`, injecting the CLI-domain pieces (app server, manifest
|
|
15
15
|
* extraction, app id) and loading the package lazily so plain projects never do.
|
|
16
16
|
*/ export async function devAction(options) {
|
|
@@ -31,7 +31,9 @@ const noop = async ()=>{};
|
|
|
31
31
|
cliConfig: params.cliConfig,
|
|
32
32
|
httpPort: params.httpPort
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
// A workbench app (an app to render) or a workbench config (config-only, like
|
|
35
|
+
// the media library, which needs the workbench to render it) both delegate.
|
|
36
|
+
if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {
|
|
35
37
|
// Lazy so a non-workbench `sanity dev` never loads the package. `doImport`
|
|
36
38
|
// is path-based and doesn't apply to a bare specifier.
|
|
37
39
|
// eslint-disable-next-line no-restricted-syntax
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/dev/devAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {type CliConfig} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {getSharedServerConfig} from '../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/dev/devAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {type CliConfig} from '@sanity/cli-core'\nimport {isWorkbenchApp, isWorkbenchConfig} from '@sanity/workbench-cli'\n\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {getSharedServerConfig} from '../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {startAppDevServer} from './servers/startAppDevServer.js'\nimport {startStudioDevServer} from './servers/startStudioDevServer.js'\nimport {type DevActionOptions} from './types.js'\n\nconst noop = async () => {}\n\n/**\n * Entry point for `sanity dev`. A plain studio/app starts a single dev server, as\n * before workbench existed. A workbench app (via `defineApplication`) delegates to\n * `@sanity/workbench-cli`, injecting the CLI-domain pieces (app server, manifest\n * extraction, app id) and loading the package lazily so plain projects never do.\n */\nexport async function devAction(options: DevActionOptions): Promise<{close: () => Promise<void>}> {\n const {cliConfig, flags, isApp, output, workDir} = options\n\n const {httpHost, httpPort} = getSharedServerConfig({\n cliConfig,\n flags: {host: flags.host, port: flags.port},\n workDir,\n })\n\n // The app/studio server, parameterized per call; `announceUrl` is false when\n // the workbench announces the URL on its behalf.\n const startAppServer = (params: {announceUrl: boolean; cliConfig: CliConfig; httpPort: number}) =>\n (isApp ? startAppDevServer : startStudioDevServer)({\n ...options,\n announceUrl: params.announceUrl,\n cliConfig: params.cliConfig,\n httpPort: params.httpPort,\n })\n\n // A workbench app (an app to render) or a workbench config (config-only, like\n // the media library, which needs the workbench to render it) both delegate.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n // Lazy so a non-workbench `sanity dev` never loads the package. `doImport`\n // is path-based and doesn't apply to a bare specifier.\n // eslint-disable-next-line no-restricted-syntax\n const {startWorkbenchDev} = await import('@sanity/workbench-cli/dev')\n return startWorkbenchDev({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({workDir: wd}) => extractCoreAppManifest({workDir: wd})\n : (params) => extractStudioManifest(params),\n httpHost,\n httpPort,\n isApp,\n output,\n // Runtime template needs a concrete boolean; collapse an unset config to off.\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n startAppServer,\n workDir,\n })\n }\n\n // Plain non-workbench studio/app: one dev server announcing its own URL.\n const result = await startAppServer({announceUrl: true, cliConfig, httpPort})\n return {close: result.started ? result.close : noop}\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","isWorkbenchConfig","checkForDeprecatedAppId","getSharedServerConfig","resolveReactStrictMode","extractStudioManifest","startAppDevServer","startStudioDevServer","noop","devAction","options","cliConfig","flags","isApp","output","workDir","httpHost","httpPort","host","port","startAppServer","params","announceUrl","app","startWorkbenchDev","cacheDir","extractManifest","wd","reactStrictMode","result","close","started"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,sBAAsB,QAAO,uCAAsC;AAE3E,SAAQC,cAAc,EAAEC,iBAAiB,QAAO,wBAAuB;AAEvE,SAAQC,uBAAuB,QAAO,sBAAqB;AAC3D,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,iBAAiB,QAAO,iCAAgC;AAChE,SAAQC,oBAAoB,QAAO,oCAAmC;AAGtE,MAAMC,OAAO,WAAa;AAE1B;;;;;CAKC,GACD,OAAO,eAAeC,UAAUC,OAAyB;IACvD,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGL;IAEnD,MAAM,EAACM,QAAQ,EAAEC,QAAQ,EAAC,GAAGd,sBAAsB;QACjDQ;QACAC,OAAO;YAACM,MAAMN,MAAMM,IAAI;YAAEC,MAAMP,MAAMO,IAAI;QAAA;QAC1CJ;IACF;IAEA,6EAA6E;IAC7E,iDAAiD;IACjD,MAAMK,iBAAiB,CAACC,SACtB,AAACR,CAAAA,QAAQP,oBAAoBC,oBAAmB,EAAG;YACjD,GAAGG,OAAO;YACVY,aAAaD,OAAOC,WAAW;YAC/BX,WAAWU,OAAOV,SAAS;YAC3BM,UAAUI,OAAOJ,QAAQ;QAC3B;IAEF,8EAA8E;IAC9E,4EAA4E;IAC5E,IAAIjB,eAAeW,WAAWY,QAAQtB,kBAAkBU,WAAWY,MAAM;QACvE,2EAA2E;QAC3E,uDAAuD;QACvD,gDAAgD;QAChD,MAAM,EAACC,iBAAiB,EAAC,GAAG,MAAM,MAAM,CAAC;QACzC,OAAOA,kBAAkB;YACvBC,UAAU,GAAG3B,iBAAiB,KAAK,CAAC;YACpCI,yBAAyB,IAAMA,wBAAwB;oBAACS;oBAAWG;gBAAM;YACzEH;YACAe,iBAAiBb,QACb,CAAC,EAACE,SAASY,EAAE,EAAC,GAAK5B,uBAAuB;oBAACgB,SAASY;gBAAE,KACtD,CAACN,SAAWhB,sBAAsBgB;YACtCL;YACAC;YACAJ;YACAC;YACA,8EAA8E;YAC9Ec,iBAAiBxB,uBAAuBO,cAAc;YACtDS;YACAL;QACF;IACF;IAEA,yEAAyE;IACzE,MAAMc,SAAS,MAAMT,eAAe;QAACE,aAAa;QAAMX;QAAWM;IAAQ;IAC3E,OAAO;QAACa,OAAOD,OAAOE,OAAO,GAAGF,OAAOC,KAAK,GAAGtB;IAAI;AACrD"}
|
|
@@ -2,6 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { getSanityEnvVar } from '@sanity/cli-core';
|
|
3
3
|
import { logSymbols, spinner } from '@sanity/cli-core/ux';
|
|
4
4
|
import { isWorkbenchApp } from '@sanity/workbench-cli';
|
|
5
|
+
import { resolveWorkbenchConfig } from '@sanity/workbench-cli/build';
|
|
5
6
|
import { determineIsApp } from '../../../util/determineIsApp.js';
|
|
6
7
|
import { getSharedServerConfig } from '../../../util/getSharedServerConfig.js';
|
|
7
8
|
import { resolveReactStrictMode } from '../../../util/resolveReactStrictMode.js';
|
|
@@ -18,9 +19,11 @@ export function getDevServerConfig({ cliConfig, flags, httpPort, output, workDir
|
|
|
18
19
|
configSpinner.succeed();
|
|
19
20
|
const isApp = cliConfig ? determineIsApp(cliConfig) : false;
|
|
20
21
|
const reactStrictMode = resolveReactStrictMode(cliConfig);
|
|
21
|
-
// `views`/`
|
|
22
|
-
// the branded app result rather than the legacy `app` config type.
|
|
22
|
+
// `views`/`webWorkers` are declared via `defineApplication`, so read them off
|
|
23
|
+
// the branded app result rather than the legacy `app` config type. A config is
|
|
24
|
+
// not an app — it resolves separately and expands only its `fields`.
|
|
23
25
|
const app = cliConfig?.app;
|
|
26
|
+
const workbenchConfig = resolveWorkbenchConfig(cliConfig);
|
|
24
27
|
const envBasePath = getSanityEnvVar('BASEPATH', isApp ?? false);
|
|
25
28
|
if (envBasePath && cliConfig?.project?.basePath) {
|
|
26
29
|
output.warn(`Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${envBasePath})`);
|
|
@@ -38,14 +41,18 @@ export function getDevServerConfig({ cliConfig, flags, httpPort, output, workDir
|
|
|
38
41
|
// view: the runtime/federation skip the `./App` render path entirely.
|
|
39
42
|
entry: app?.entry,
|
|
40
43
|
exposes: isWorkbenchApp(app) ? {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
views: app.views,
|
|
45
|
+
webWorkers: app.webWorkers
|
|
46
|
+
} : workbenchConfig ? {
|
|
47
|
+
config: {
|
|
48
|
+
appType: workbenchConfig.appType,
|
|
49
|
+
fields: workbenchConfig.fields
|
|
50
|
+
}
|
|
44
51
|
} : undefined,
|
|
45
52
|
// `devAction` passes an explicit port when a running workbench claimed the
|
|
46
53
|
// configured one; otherwise the shared resolution stands.
|
|
47
54
|
httpPort: httpPort ?? baseConfig.httpPort,
|
|
48
|
-
isWorkbenchApp: isWorkbenchApp(app),
|
|
55
|
+
isWorkbenchApp: isWorkbenchApp(app) || !!workbenchConfig,
|
|
49
56
|
reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,
|
|
50
57
|
reactStrictMode,
|
|
51
58
|
staticPath: path.join(workDir, 'static'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/dev/servers/getDevServerConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, getSanityEnvVar, type Output} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {type DevServerOptions} from '../../../server/devServer.js'\nimport {determineIsApp} from '../../../util/determineIsApp.js'\nimport {getSharedServerConfig} from '../../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../../util/resolveReactStrictMode.js'\nimport {type DevFlags} from '../types.js'\n\nexport function getDevServerConfig({\n cliConfig,\n flags,\n httpPort,\n output,\n workDir,\n}: {\n cliConfig?: CliConfig\n flags: DevFlags\n httpPort?: number\n output: Output\n workDir: string\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = spinner('Checking configuration files...')\n\n const baseConfig = getSharedServerConfig({\n cliConfig,\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n })\n\n configSpinner.succeed()\n\n const isApp = cliConfig ? determineIsApp(cliConfig) : false\n const reactStrictMode = resolveReactStrictMode(cliConfig)\n // `views`/`
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/dev/servers/getDevServerConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, getSanityEnvVar, type Output} from '@sanity/cli-core'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {resolveWorkbenchConfig} from '@sanity/workbench-cli/build'\n\nimport {type DevServerOptions} from '../../../server/devServer.js'\nimport {determineIsApp} from '../../../util/determineIsApp.js'\nimport {getSharedServerConfig} from '../../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../../util/resolveReactStrictMode.js'\nimport {type DevFlags} from '../types.js'\n\nexport function getDevServerConfig({\n cliConfig,\n flags,\n httpPort,\n output,\n workDir,\n}: {\n cliConfig?: CliConfig\n flags: DevFlags\n httpPort?: number\n output: Output\n workDir: string\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = spinner('Checking configuration files...')\n\n const baseConfig = getSharedServerConfig({\n cliConfig,\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n })\n\n configSpinner.succeed()\n\n const isApp = cliConfig ? determineIsApp(cliConfig) : false\n const reactStrictMode = resolveReactStrictMode(cliConfig)\n // `views`/`webWorkers` are declared via `defineApplication`, so read them off\n // the branded app result rather than the legacy `app` config type. A config is\n // not an app — it resolves separately and expands only its `fields`.\n const app = cliConfig?.app\n const workbenchConfig = resolveWorkbenchConfig(cliConfig)\n\n const envBasePath = getSanityEnvVar('BASEPATH', isApp ?? false)\n if (envBasePath && cliConfig?.project?.basePath) {\n output.warn(\n `Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n // Unstable opt-in to Vite's experimental bundled dev mode, via\n // `unstable_bundledDev` in sanity.cli.ts. Defaults to off.\n const bundledDev = cliConfig?.unstable_bundledDev ?? false\n if (bundledDev) {\n output.log(`${logSymbols.info} Running dev server with experimental Vite bundled dev mode`)\n }\n\n return {\n ...baseConfig,\n bundledDev,\n // The app's navigable entry. A branded app that omits `entry` has no app\n // view: the runtime/federation skip the `./App` render path entirely.\n entry: app?.entry,\n exposes: isWorkbenchApp(app)\n ? {views: app.views, webWorkers: app.webWorkers}\n : workbenchConfig\n ? {config: {appType: workbenchConfig.appType, fields: workbenchConfig.fields}}\n : undefined,\n // `devAction` passes an explicit port when a running workbench claimed the\n // configured one; otherwise the shared resolution stands.\n httpPort: httpPort ?? baseConfig.httpPort,\n isWorkbenchApp: isWorkbenchApp(app) || !!workbenchConfig,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n reactStrictMode,\n staticPath: path.join(workDir, 'static'),\n typegen: cliConfig?.typegen,\n workbenchAppId: isWorkbenchApp(app) ? app.slug : undefined,\n }\n}\n"],"names":["path","getSanityEnvVar","logSymbols","spinner","isWorkbenchApp","resolveWorkbenchConfig","determineIsApp","getSharedServerConfig","resolveReactStrictMode","getDevServerConfig","cliConfig","flags","httpPort","output","workDir","configSpinner","baseConfig","host","port","succeed","isApp","reactStrictMode","app","workbenchConfig","envBasePath","project","basePath","warn","bundledDev","unstable_bundledDev","log","info","entry","exposes","views","webWorkers","config","appType","fields","undefined","reactCompiler","staticPath","join","typegen","workbenchAppId","slug"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAwBC,eAAe,QAAoB,mBAAkB;AAC7E,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AACvD,SAAQC,cAAc,QAAO,wBAAuB;AACpD,SAAQC,sBAAsB,QAAO,8BAA6B;AAGlE,SAAQC,cAAc,QAAO,kCAAiC;AAC9D,SAAQC,qBAAqB,QAAO,yCAAwC;AAC5E,SAAQC,sBAAsB,QAAO,0CAAyC;AAG9E,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,KAAK,EACLC,QAAQ,EACRC,MAAM,EACNC,OAAO,EAOR;IACC,MAAMC,gBAAgBZ,QAAQ;IAE9B,MAAMa,aAAaT,sBAAsB;QACvCG;QACAC,OAAO;YACLM,MAAMN,MAAMM,IAAI;YAChBC,MAAMP,MAAMO,IAAI;QAClB;QACAJ;IACF;IAEAC,cAAcI,OAAO;IAErB,MAAMC,QAAQV,YAAYJ,eAAeI,aAAa;IACtD,MAAMW,kBAAkBb,uBAAuBE;IAC/C,8EAA8E;IAC9E,+EAA+E;IAC/E,qEAAqE;IACrE,MAAMY,MAAMZ,WAAWY;IACvB,MAAMC,kBAAkBlB,uBAAuBK;IAE/C,MAAMc,cAAcvB,gBAAgB,YAAYmB,SAAS;IACzD,IAAII,eAAed,WAAWe,SAASC,UAAU;QAC/Cb,OAAOc,IAAI,CACT,CAAC,iCAAiC,EAAEjB,UAAUe,OAAO,CAACC,QAAQ,CAAC,wCAAwC,EAAEF,YAAY,CAAC,CAAC;IAE3H;IAEA,+DAA+D;IAC/D,2DAA2D;IAC3D,MAAMI,aAAalB,WAAWmB,uBAAuB;IACrD,IAAID,YAAY;QACdf,OAAOiB,GAAG,CAAC,GAAG5B,WAAW6B,IAAI,CAAC,2DAA2D,CAAC;IAC5F;IAEA,OAAO;QACL,GAAGf,UAAU;QACbY;QACA,yEAAyE;QACzE,sEAAsE;QACtEI,OAAOV,KAAKU;QACZC,SAAS7B,eAAekB,OACpB;YAACY,OAAOZ,IAAIY,KAAK;YAAEC,YAAYb,IAAIa,UAAU;QAAA,IAC7CZ,kBACE;YAACa,QAAQ;gBAACC,SAASd,gBAAgBc,OAAO;gBAAEC,QAAQf,gBAAgBe,MAAM;YAAA;QAAC,IAC3EC;QACN,2EAA2E;QAC3E,0DAA0D;QAC1D3B,UAAUA,YAAYI,WAAWJ,QAAQ;QACzCR,gBAAgBA,eAAekB,QAAQ,CAAC,CAACC;QACzCiB,eAAe9B,aAAa,mBAAmBA,YAAYA,UAAU8B,aAAa,GAAGD;QACrFlB;QACAoB,YAAYzC,KAAK0C,IAAI,CAAC5B,SAAS;QAC/B6B,SAASjC,WAAWiC;QACpBC,gBAAgBxC,eAAekB,OAAOA,IAAIuB,IAAI,GAAGN;IACnD;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
import { exitCodes } from '@sanity/cli-core';
|
|
3
|
-
import { isWorkbenchApp as determineIsWorkbenchApp } from '@sanity/workbench-cli';
|
|
3
|
+
import { isWorkbenchApp as determineIsWorkbenchApp, isWorkbenchConfig as determineIsWorkbenchConfig } from '@sanity/workbench-cli';
|
|
4
4
|
import { startDevServer } from '../../../server/devServer.js';
|
|
5
5
|
import { gracefulServerDeath } from '../../../server/gracefulServerDeath.js';
|
|
6
6
|
import { devDebug } from '../devDebug.js';
|
|
@@ -16,7 +16,9 @@ function toDisplayHost(host) {
|
|
|
16
16
|
}
|
|
17
17
|
export async function startAppDevServer(options) {
|
|
18
18
|
const { announceUrl = true, cliConfig, flags, httpPort, output, workDir } = options;
|
|
19
|
-
|
|
19
|
+
// A config (the Media Library) surfaces through the workbench, not the
|
|
20
|
+
// dashboard, so it takes the same path as an app here.
|
|
21
|
+
const isWorkbenchApp = determineIsWorkbenchApp(cliConfig?.app) || determineIsWorkbenchConfig(cliConfig?.app);
|
|
20
22
|
// Workbench apps don't load through the dashboard, so the flag has no
|
|
21
23
|
// meaning for them and is ignored.
|
|
22
24
|
if (!isWorkbenchApp && !flags['load-in-dashboard']) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/dev/servers/startAppDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {exitCodes} from '@sanity/cli-core'\nimport {isWorkbenchApp as determineIsWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {startDevServer} from '../../../server/devServer.js'\nimport {gracefulServerDeath} from '../../../server/gracefulServerDeath.js'\nimport {devDebug} from '../devDebug.js'\nimport {type DevActionOptions, type StartDevServerResult} from '../types.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\n\n// Bind-only addresses ('0.0.0.0', '::') aren't routable in every browser; the\n// displayed URL falls back to localhost. The bind address itself is untouched.\nfunction toDisplayHost(host: string | undefined): string {\n if (!host || host === '0.0.0.0' || host === '::' || host === '[::]') {\n return 'localhost'\n }\n return host\n}\n\nexport async function startAppDevServer(options: DevActionOptions): Promise<StartDevServerResult> {\n const {announceUrl = true, cliConfig, flags, httpPort, output, workDir} = options\n\n const isWorkbenchApp
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/dev/servers/startAppDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {exitCodes} from '@sanity/cli-core'\nimport {\n isWorkbenchApp as determineIsWorkbenchApp,\n isWorkbenchConfig as determineIsWorkbenchConfig,\n} from '@sanity/workbench-cli'\n\nimport {startDevServer} from '../../../server/devServer.js'\nimport {gracefulServerDeath} from '../../../server/gracefulServerDeath.js'\nimport {devDebug} from '../devDebug.js'\nimport {type DevActionOptions, type StartDevServerResult} from '../types.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\n\n// Bind-only addresses ('0.0.0.0', '::') aren't routable in every browser; the\n// displayed URL falls back to localhost. The bind address itself is untouched.\nfunction toDisplayHost(host: string | undefined): string {\n if (!host || host === '0.0.0.0' || host === '::' || host === '[::]') {\n return 'localhost'\n }\n return host\n}\n\nexport async function startAppDevServer(options: DevActionOptions): Promise<StartDevServerResult> {\n const {announceUrl = true, cliConfig, flags, httpPort, output, workDir} = options\n\n // A config (the Media Library) surfaces through the workbench, not the\n // dashboard, so it takes the same path as an app here.\n const isWorkbenchApp =\n determineIsWorkbenchApp(cliConfig?.app) || determineIsWorkbenchConfig(cliConfig?.app)\n\n // Workbench apps don't load through the dashboard, so the flag has no\n // meaning for them and is ignored.\n if (!isWorkbenchApp && !flags['load-in-dashboard']) {\n output.warn(`Apps cannot run without the Sanity dashboard`)\n output.warn(`Starting dev server with the --load-in-dashboard flag set to true`)\n }\n\n let organizationId: string | undefined\n if (cliConfig && 'app' in cliConfig && cliConfig.app?.organizationId) {\n organizationId = cliConfig.app.organizationId\n }\n\n if (!organizationId) {\n output.error(`Apps require an organization ID (orgId) specified in your sanity.cli.ts file`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n return {reason: 'missing-organization-id', started: false}\n }\n\n const config = getDevServerConfig({cliConfig, flags, httpPort, output, workDir})\n\n try {\n output.log('Starting dev server')\n\n const appTitle = cliConfig && 'app' in cliConfig ? cliConfig.app?.title : undefined\n const {close, server} = await startDevServer({\n ...config,\n appTitle,\n isApp: true,\n })\n\n const {port} = server.config.server\n\n // Federated apps surface through the workbench, which announces the URL;\n // only the package-unavailable fallback announces from here.\n if (isWorkbenchApp && announceUrl) {\n const url = `http://${toDisplayHost(config.httpHost)}:${port}`\n output.log(`App dev server started at ${styleText(['blue', 'underline'], url)}`)\n } else if (!isWorkbenchApp) {\n const httpHost = config.httpHost || 'localhost'\n\n const dashboardAppUrl = await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId,\n })\n output.log(`Dev server started on port ${port}`)\n output.log(`View your app in the Sanity dashboard here:`)\n output.log(styleText(['blue', 'underline'], dashboardAppUrl))\n }\n\n return {close, server, started: true}\n } catch (err) {\n devDebug('Error starting app dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["styleText","exitCodes","isWorkbenchApp","determineIsWorkbenchApp","isWorkbenchConfig","determineIsWorkbenchConfig","startDevServer","gracefulServerDeath","devDebug","getDashboardAppURL","getDevServerConfig","toDisplayHost","host","startAppDevServer","options","announceUrl","cliConfig","flags","httpPort","output","workDir","app","warn","organizationId","error","exit","RUNTIME_ERROR","reason","started","config","log","appTitle","title","undefined","close","server","isApp","port","url","httpHost","dashboardAppUrl","err"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SACEC,kBAAkBC,uBAAuB,EACzCC,qBAAqBC,0BAA0B,QAC1C,wBAAuB;AAE9B,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,mBAAmB,QAAO,yCAAwC;AAC1E,SAAQC,QAAQ,QAAO,iBAAgB;AAEvC,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,SAAQC,kBAAkB,QAAO,0BAAyB;AAE1D,8EAA8E;AAC9E,+EAA+E;AAC/E,SAASC,cAAcC,IAAwB;IAC7C,IAAI,CAACA,QAAQA,SAAS,aAAaA,SAAS,QAAQA,SAAS,QAAQ;QACnE,OAAO;IACT;IACA,OAAOA;AACT;AAEA,OAAO,eAA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AAC,CAAC,0BAA0B,EAAE9B,UAAU;gBAAC;gBAAQ;aAAY,EAAEsC,MAAM;QACjF,OAAO,IAAI,CAACpC,gBAAgB;YAC1B,MAAMqC,WAAWV,OAAOU,QAAQ,IAAI;YAEpC,MAAMC,kBAAkB,MAAM/B,mBAAmB;gBAC/C8B;gBACArB,UAAUmB;gBACVd;YACF;YACAJ,OAAOW,GAAG,CAAC,CAAC,2BAA2B,EAAEO,MAAM;YAC/ClB,OAAOW,GAAG,CAAC,CAAC,2CAA2C,CAAC;YACxDX,OAAOW,GAAG,CAAC9B,UAAU;gBAAC;gBAAQ;aAAY,EAAEwC;QAC9C;QAEA,OAAO;YAACN;YAAOC;YAAQP,SAAS;QAAI;IACtC,EAAE,OAAOa,KAAK;QACZjC,SAAS,iCAAiCiC;QAC1C,MAAMlC,oBAAoB,OAAOsB,OAAOU,QAAQ,EAAEV,OAAOX,QAAQ,EAAEuB;IACrE;AACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import flatten from 'lodash-es/flatten.js';
|
|
2
1
|
import { isNonUnion } from '../helpers.js';
|
|
3
2
|
const filterCreators = {
|
|
4
3
|
Boolean: createBooleanFilters,
|
|
@@ -15,7 +14,7 @@ export function generateTypeFilters(types) {
|
|
|
15
14
|
const queryable = types.filter((type)=>isNonUnion(type)).filter((type)=>type.type === 'Object' && type.interfaces && type.interfaces.includes('Document'));
|
|
16
15
|
return queryable.map((type)=>{
|
|
17
16
|
const name = `${type.name}Filter`;
|
|
18
|
-
const fields =
|
|
17
|
+
const fields = type.fields.flatMap((field)=>createFieldFilters(field)).filter(Boolean);
|
|
19
18
|
return {
|
|
20
19
|
fields: [
|
|
21
20
|
...fields,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/graphql/gen1/generateTypeFilters.ts"],"sourcesContent":["import flatten from 'lodash-es/flatten.js'\n\nimport {isNonUnion} from '../helpers.js'\nimport {\n type ConvertedField,\n type ConvertedFieldDefinition,\n type ConvertedType,\n type ConvertedUnion,\n type InputFilterField,\n type InputObjectType,\n} from '../types.js'\n\ntype FilterCreator = (field: ConvertedField) => InputFilterField[]\n\nconst filterCreators: Record<string, FilterCreator> = {\n Boolean: createBooleanFilters,\n Date: createDateFilters,\n Datetime: createDateFilters,\n Float: createNumberFilters,\n ID: createIdFilters,\n Integer: createNumberFilters,\n Object: createObjectFilters,\n String: createStringFilters,\n Url: createStringFilters,\n}\n\nexport function generateTypeFilters(types: (ConvertedType | ConvertedUnion)[]): InputObjectType[] {\n const queryable = types\n .filter((type) => isNonUnion(type))\n .filter(\n (type) => type.type === 'Object' && type.interfaces && type.interfaces.includes('Document'),\n )\n\n return queryable.map((type) => {\n const name = `${type.name}Filter`\n const fields = flatten(type.fields.map((field) => createFieldFilters(field))).filter(Boolean)\n return {fields: [...fields, ...getDocumentFilters()], kind: 'InputObject', name}\n })\n}\n\nfunction createFieldFilters(field: ConvertedField) {\n if (filterCreators[field.type]) {\n return filterCreators[field.type](field)\n }\n\n if (field.kind === 'List') {\n return createListFilters()\n }\n\n if (field.isReference) {\n return createReferenceFilters(field)\n }\n\n return createInlineTypeFilters()\n}\n\nfunction getFieldName(field: ConvertedField, modifier = '') {\n const suffix = modifier ? `_${modifier}` : ''\n return `${field.fieldName}${suffix}`\n}\n\nfunction getDocumentFilters(): InputFilterField[] {\n return [\n {\n constraint: {\n comparator: 'REFERENCES',\n },\n description: 'All documents references the given document ID',\n fieldName: 'references',\n type: 'ID',\n },\n {\n constraint: {\n comparator: 'IS_DRAFT',\n field: '_id',\n },\n description: 'All documents that are drafts',\n fieldName: 'is_draft',\n type: 'Boolean',\n },\n ]\n}\n\nfunction createIsDefinedFilter(field: ConvertedFieldDefinition): InputFilterField {\n return {\n constraint: {\n comparator: 'IS_DEFINED',\n field: field.fieldName,\n },\n description: 'All documents that have a value for this field',\n fieldName: getFieldName(field, 'is_defined'),\n type: 'Boolean',\n }\n}\n\nfunction createEqualityFilter(field: ConvertedFieldDefinition): InputFilterField {\n return {\n constraint: {\n comparator: 'EQUALS',\n field: field.fieldName,\n },\n description: 'All documents that are equal to given value',\n fieldName: getFieldName(field),\n type: field.type,\n }\n}\n\nfunction createInequalityFilter(field: ConvertedFieldDefinition): InputFilterField {\n return {\n constraint: {\n comparator: 'NOT_EQUALS',\n field: field.fieldName,\n },\n description: 'All documents that are not equal to given value',\n fieldName: getFieldName(field, 'not'),\n type: field.type,\n }\n}\n\nfunction createDefaultFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [createEqualityFilter(field), createInequalityFilter(field), createIsDefinedFilter(field)]\n}\n\nfunction createGtLtFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [\n {\n constraint: {\n comparator: 'LT',\n field: field.fieldName,\n },\n description: 'All documents are less than given value',\n fieldName: getFieldName(field, 'lt'),\n type: field.type,\n },\n {\n constraint: {\n comparator: 'LTE',\n field: field.fieldName,\n },\n description: 'All documents are less than or equal to given value',\n fieldName: getFieldName(field, 'lte'),\n type: field.type,\n },\n {\n constraint: {\n comparator: 'GT',\n field: field.fieldName,\n },\n description: 'All documents are greater than given value',\n fieldName: getFieldName(field, 'gt'),\n type: field.type,\n },\n {\n constraint: {\n comparator: 'GTE',\n field: field.fieldName,\n },\n description: 'All documents are greater than or equal to given value',\n fieldName: getFieldName(field, 'gte'),\n type: field.type,\n },\n ]\n}\n\nfunction createBooleanFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return createDefaultFilters(field)\n}\n\nfunction createIdFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return createStringFilters(field)\n}\n\nfunction createDateFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [...createDefaultFilters(field), ...createGtLtFilters(field)]\n}\n\nfunction createStringFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [\n ...createDefaultFilters(field),\n {\n constraint: {\n comparator: 'MATCHES',\n field: field.fieldName,\n },\n description: 'All documents contain (match) the given word/words',\n fieldName: getFieldName(field, 'matches'),\n type: 'String',\n },\n {\n children: {\n isNullable: false,\n type: 'String',\n },\n constraint: {\n comparator: 'IN',\n field: field.fieldName,\n },\n description: 'All documents match one of the given values',\n fieldName: getFieldName(field, 'in'),\n kind: 'List',\n },\n {\n children: {\n isNullable: false,\n type: 'String',\n },\n constraint: {\n comparator: 'NOT_IN',\n field: field.fieldName,\n },\n description: 'None of the values match any of the given values',\n fieldName: getFieldName(field, 'not_in'),\n kind: 'List',\n },\n ]\n}\n\nfunction createNumberFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [...createDefaultFilters(field), ...createGtLtFilters(field)]\n}\n\nfunction createObjectFilters(_field: ConvertedFieldDefinition): InputFilterField[] {\n return []\n}\n\nfunction createListFilters(): InputFilterField[] {\n return []\n}\n\nfunction createInlineTypeFilters(): InputFilterField[] {\n return []\n}\n\nfunction createReferenceFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [\n {\n constraint: {\n comparator: 'EQUALS',\n field: `${field.fieldName}._ref`,\n },\n fieldName: getFieldName(field),\n type: 'ID',\n },\n ]\n}\n"],"names":["flatten","isNonUnion","filterCreators","Boolean","createBooleanFilters","Date","createDateFilters","Datetime","Float","createNumberFilters","ID","createIdFilters","Integer","Object","createObjectFilters","String","createStringFilters","Url","generateTypeFilters","types","queryable","filter","type","interfaces","includes","map","name","fields","field","createFieldFilters","getDocumentFilters","kind","createListFilters","isReference","createReferenceFilters","createInlineTypeFilters","getFieldName","modifier","suffix","fieldName","constraint","comparator","description","createIsDefinedFilter","createEqualityFilter","createInequalityFilter","createDefaultFilters","createGtLtFilters","children","isNullable","_field"],"mappings":"AAAA,OAAOA,aAAa,uBAAsB;AAE1C,SAAQC,UAAU,QAAO,gBAAe;AAYxC,MAAMC,iBAAgD;IACpDC,SAASC;IACTC,MAAMC;IACNC,UAAUD;IACVE,OAAOC;IACPC,IAAIC;IACJC,SAASH;IACTI,QAAQC;IACRC,QAAQC;IACRC,KAAKD;AACP;AAEA,OAAO,SAASE,oBAAoBC,KAAyC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A,SAAStB,kBAAkBsB,KAA+B;IACxD,OAAO;WAAIkB,qBAAqBlB;WAAWmB,kBAAkBnB;KAAO;AACtE;AAEA,SAASZ,oBAAoBY,KAA+B;IAC1D,OAAO;WACFkB,qBAAqBlB;QACxB;YACEY,YAAY;gBACVC,YAAY;gBACZb,OAAOA,MAAMW,SAAS;YACxB;YACAG,aAAa;YACbH,WAAWH,aAAaR,OAAO;YAC/BN,MAAM;QACR;QACA;YACE0B,UAAU;gBACRC,YAAY;gBACZ3B,MAAM;YACR;YACAkB,YAAY;gBACVC,YAAY;gBACZb,OAAOA,MAAMW,SAAS;YACxB;YACAG,aAAa;YACbH,WAAWH,aAAaR,OAAO;YAC/BG,MAAM;QACR;QACA;YACEiB,UAAU;gBACRC,YAAY;gBACZ3B,MAAM;YACR;YACAkB,YAAY;gBACVC,YAAY;gBACZb,OAAOA,MAAMW,SAAS;YACxB;YACAG,aAAa;YACbH,WAAWH,aAAaR,OAAO;YAC/BG,MAAM;QACR;KACD;AACH;AAEA,SAAStB,oBAAoBmB,KAA+B;IAC1D,OAAO;WAAIkB,qBAAqBlB;WAAWmB,kBAAkBnB;KAAO;AACtE;AAEA,SAASd,oBAAoBoC,MAAgC;IAC3D,OAAO,EAAE;AACX;AAEA,SAASlB;IACP,OAAO,EAAE;AACX;AAEA,SAASG;IACP,OAAO,EAAE;AACX;AAEA,SAASD,uBAAuBN,KAA+B;IAC7D,OAAO;QACL;YACEY,YAAY;gBACVC,YAAY;gBACZb,OAAO,GAAGA,MAAMW,SAAS,CAAC,KAAK,CAAC;YAClC;YACAA,WAAWH,aAAaR;YACxBN,MAAM;QACR;KACD;AACH"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/graphql/gen1/generateTypeFilters.ts"],"sourcesContent":["import {isNonUnion} from '../helpers.js'\nimport {\n type ConvertedField,\n type ConvertedFieldDefinition,\n type ConvertedType,\n type ConvertedUnion,\n type InputFilterField,\n type InputObjectType,\n} from '../types.js'\n\ntype FilterCreator = (field: ConvertedField) => InputFilterField[]\n\nconst filterCreators: Record<string, FilterCreator> = {\n Boolean: createBooleanFilters,\n Date: createDateFilters,\n Datetime: createDateFilters,\n Float: createNumberFilters,\n ID: createIdFilters,\n Integer: createNumberFilters,\n Object: createObjectFilters,\n String: createStringFilters,\n Url: createStringFilters,\n}\n\nexport function generateTypeFilters(types: (ConvertedType | ConvertedUnion)[]): InputObjectType[] {\n const queryable = types\n .filter((type) => isNonUnion(type))\n .filter(\n (type) => type.type === 'Object' && type.interfaces && type.interfaces.includes('Document'),\n )\n\n return queryable.map((type) => {\n const name = `${type.name}Filter`\n const fields = type.fields.flatMap((field) => createFieldFilters(field)).filter(Boolean)\n return {fields: [...fields, ...getDocumentFilters()], kind: 'InputObject', name}\n })\n}\n\nfunction createFieldFilters(field: ConvertedField) {\n if (filterCreators[field.type]) {\n return filterCreators[field.type](field)\n }\n\n if (field.kind === 'List') {\n return createListFilters()\n }\n\n if (field.isReference) {\n return createReferenceFilters(field)\n }\n\n return createInlineTypeFilters()\n}\n\nfunction getFieldName(field: ConvertedField, modifier = '') {\n const suffix = modifier ? `_${modifier}` : ''\n return `${field.fieldName}${suffix}`\n}\n\nfunction getDocumentFilters(): InputFilterField[] {\n return [\n {\n constraint: {\n comparator: 'REFERENCES',\n },\n description: 'All documents references the given document ID',\n fieldName: 'references',\n type: 'ID',\n },\n {\n constraint: {\n comparator: 'IS_DRAFT',\n field: '_id',\n },\n description: 'All documents that are drafts',\n fieldName: 'is_draft',\n type: 'Boolean',\n },\n ]\n}\n\nfunction createIsDefinedFilter(field: ConvertedFieldDefinition): InputFilterField {\n return {\n constraint: {\n comparator: 'IS_DEFINED',\n field: field.fieldName,\n },\n description: 'All documents that have a value for this field',\n fieldName: getFieldName(field, 'is_defined'),\n type: 'Boolean',\n }\n}\n\nfunction createEqualityFilter(field: ConvertedFieldDefinition): InputFilterField {\n return {\n constraint: {\n comparator: 'EQUALS',\n field: field.fieldName,\n },\n description: 'All documents that are equal to given value',\n fieldName: getFieldName(field),\n type: field.type,\n }\n}\n\nfunction createInequalityFilter(field: ConvertedFieldDefinition): InputFilterField {\n return {\n constraint: {\n comparator: 'NOT_EQUALS',\n field: field.fieldName,\n },\n description: 'All documents that are not equal to given value',\n fieldName: getFieldName(field, 'not'),\n type: field.type,\n }\n}\n\nfunction createDefaultFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [createEqualityFilter(field), createInequalityFilter(field), createIsDefinedFilter(field)]\n}\n\nfunction createGtLtFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [\n {\n constraint: {\n comparator: 'LT',\n field: field.fieldName,\n },\n description: 'All documents are less than given value',\n fieldName: getFieldName(field, 'lt'),\n type: field.type,\n },\n {\n constraint: {\n comparator: 'LTE',\n field: field.fieldName,\n },\n description: 'All documents are less than or equal to given value',\n fieldName: getFieldName(field, 'lte'),\n type: field.type,\n },\n {\n constraint: {\n comparator: 'GT',\n field: field.fieldName,\n },\n description: 'All documents are greater than given value',\n fieldName: getFieldName(field, 'gt'),\n type: field.type,\n },\n {\n constraint: {\n comparator: 'GTE',\n field: field.fieldName,\n },\n description: 'All documents are greater than or equal to given value',\n fieldName: getFieldName(field, 'gte'),\n type: field.type,\n },\n ]\n}\n\nfunction createBooleanFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return createDefaultFilters(field)\n}\n\nfunction createIdFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return createStringFilters(field)\n}\n\nfunction createDateFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [...createDefaultFilters(field), ...createGtLtFilters(field)]\n}\n\nfunction createStringFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [\n ...createDefaultFilters(field),\n {\n constraint: {\n comparator: 'MATCHES',\n field: field.fieldName,\n },\n description: 'All documents contain (match) the given word/words',\n fieldName: getFieldName(field, 'matches'),\n type: 'String',\n },\n {\n children: {\n isNullable: false,\n type: 'String',\n },\n constraint: {\n comparator: 'IN',\n field: field.fieldName,\n },\n description: 'All documents match one of the given values',\n fieldName: getFieldName(field, 'in'),\n kind: 'List',\n },\n {\n children: {\n isNullable: false,\n type: 'String',\n },\n constraint: {\n comparator: 'NOT_IN',\n field: field.fieldName,\n },\n description: 'None of the values match any of the given values',\n fieldName: getFieldName(field, 'not_in'),\n kind: 'List',\n },\n ]\n}\n\nfunction createNumberFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [...createDefaultFilters(field), ...createGtLtFilters(field)]\n}\n\nfunction createObjectFilters(_field: ConvertedFieldDefinition): InputFilterField[] {\n return []\n}\n\nfunction createListFilters(): InputFilterField[] {\n return []\n}\n\nfunction createInlineTypeFilters(): InputFilterField[] {\n return []\n}\n\nfunction createReferenceFilters(field: ConvertedFieldDefinition): InputFilterField[] {\n return [\n {\n constraint: {\n comparator: 'EQUALS',\n field: `${field.fieldName}._ref`,\n },\n fieldName: getFieldName(field),\n type: 'ID',\n },\n ]\n}\n"],"names":["isNonUnion","filterCreators","Boolean","createBooleanFilters","Date","createDateFilters","Datetime","Float","createNumberFilters","ID","createIdFilters","Integer","Object","createObjectFilters","String","createStringFilters","Url","generateTypeFilters","types","queryable","filter","type","interfaces","includes","map","name","fields","flatMap","field","createFieldFilters","getDocumentFilters","kind","createListFilters","isReference","createReferenceFilters","createInlineTypeFilters","getFieldName","modifier","suffix","fieldName","constraint","comparator","description","createIsDefinedFilter","createEqualityFilter","createInequalityFilter","createDefaultFilters","createGtLtFilters","children","isNullable","_field"],"mappings":"AAAA,SAAQA,UAAU,QAAO,gBAAe;AAYxC,MAAMC,iBAAgD;IACpDC,SAASC;IACTC,MAAMC;IACNC,UAAUD;IACVE,OAAOC;IACPC,IAAIC;IACJC,SAASH;IACTI,QAAQC;IACRC,QAAQC;IACRC,KAAKD;AACP;AAEA,OAAO,SAASE,oBAAoBC,KAAyC;IAC3E,MAAMC,YAAYD,MACfE,MAAM,CAAC,CAACC,OAASrB,WAAWqB,OAC5BD,MAAM,CACL,CAACC,OAASA,KAAKA,IAAI,KAA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1D,OAAO;WACFkB,qBAAqBlB;QACxB;YACEY,YAAY;gBACVC,YAAY;gBACZb,OAAOA,MAAMW,SAAS;YACxB;YACAG,aAAa;YACbH,WAAWH,aAAaR,OAAO;YAC/BP,MAAM;QACR;QACA;YACE2B,UAAU;gBACRC,YAAY;gBACZ5B,MAAM;YACR;YACAmB,YAAY;gBACVC,YAAY;gBACZb,OAAOA,MAAMW,SAAS;YACxB;YACAG,aAAa;YACbH,WAAWH,aAAaR,OAAO;YAC/BG,MAAM;QACR;QACA;YACEiB,UAAU;gBACRC,YAAY;gBACZ5B,MAAM;YACR;YACAmB,YAAY;gBACVC,YAAY;gBACZb,OAAOA,MAAMW,SAAS;YACxB;YACAG,aAAa;YACbH,WAAWH,aAAaR,OAAO;YAC/BG,MAAM;QACR;KACD;AACH;AAEA,SAASvB,oBAAoBoB,KAA+B;IAC1D,OAAO;WAAIkB,qBAAqBlB;WAAWmB,kBAAkBnB;KAAO;AACtE;AAEA,SAASf,oBAAoBqC,MAAgC;IAC3D,OAAO,EAAE;AACX;AAEA,SAASlB;IACP,OAAO,EAAE;AACX;AAEA,SAASG;IACP,OAAO,EAAE;AACX;AAEA,SAASD,uBAAuBN,KAA+B;IAC7D,OAAO;QACL;YACEY,YAAY;gBACVC,YAAY;gBACZb,OAAO,GAAGA,MAAMW,SAAS,CAAC,KAAK,CAAC;YAClC;YACAA,WAAWH,aAAaR;YACxBP,MAAM;QACR;KACD;AACH"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import isPlainObject from 'lodash-es/isPlainObject.js';
|
|
2
1
|
import { oneline } from 'oneline';
|
|
3
2
|
export function resolveGraphQLApis({ cliConfig, workspaces }) {
|
|
4
3
|
const numSources = workspaces.reduce((count, workspace)=>count + workspace.unstable_sources.length, 0);
|
|
@@ -171,7 +170,11 @@ function strip(input) {
|
|
|
171
170
|
return isBasicType(input) ? input : undefined;
|
|
172
171
|
}
|
|
173
172
|
function isPlainishObject(input) {
|
|
174
|
-
|
|
173
|
+
if (typeof input !== 'object' || input === null) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const prototype = Object.getPrototypeOf(input);
|
|
177
|
+
return prototype === null || prototype === Object.prototype;
|
|
175
178
|
}
|
|
176
179
|
function isBasicType(input) {
|
|
177
180
|
const type = typeof input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/graphql/resolveGraphQLApisFromWorkspaces.ts"],"sourcesContent":["import {type Schema} from '@sanity/types'\nimport isPlainObject from 'lodash-es/isPlainObject.js'\nimport {oneline} from 'oneline'\n\nimport {\n type ExtractedGraphQLAPI,\n type GraphQLAPIConfig,\n type SchemaDefinitionish,\n type TypeResolvedGraphQLAPI,\n} from './types.js'\n\ninterface Source {\n dataset: string\n name: string\n projectId: string\n schema: Schema\n}\n\nexport interface Workspace extends Source {\n unstable_sources: Source[]\n}\n\n/**\n * Minimal source metadata — dataset/projectId pair for a source within a workspace.\n */\nexport interface SourceMetadata {\n dataset: string\n name: string\n projectId: string\n}\n\n/**\n * Minimal workspace metadata — enough for resolving API identifiers without compiling schemas.\n * This matches the raw workspace shape from `defineConfig()` before `resolveConfig()` processes it.\n *\n * The `sources` array mirrors `Workspace.unstable_sources` from the full resolved config.\n * When the raw config includes `unstable_sources`, they are extracted here. Otherwise, the\n * workspace itself is used as a single default source (matching what `resolveConfig()` would do).\n */\nexport interface WorkspaceMetadata {\n dataset: string\n name: string\n projectId: string\n sources: SourceMetadata[]\n}\n\ninterface ResolveGraphQLApisOptions {\n workspaces: Workspace[]\n\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n}\n\nexport function resolveGraphQLApis({\n cliConfig,\n workspaces,\n}: ResolveGraphQLApisOptions): TypeResolvedGraphQLAPI[] {\n const numSources = workspaces.reduce(\n (count, workspace) => count + workspace.unstable_sources.length,\n 0,\n )\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId, schema} = workspaces[0].unstable_sources[0]\n return [{dataset, projectId, schemaTypes: getStrippedSchemaTypes(schema)}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLAPIsFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Resolve GraphQL API metadata (projectId, dataset, tag, etc.) from raw workspace configs\n * without compiling schemas. This is used when we only need API identifiers, not schema types —\n * e.g. for `graphql undeploy --api` or `graphql list`.\n */\nexport function resolveGraphQLApiMetadata({\n cliConfig,\n workspaces,\n}: {\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n workspaces: WorkspaceMetadata[]\n}): ExtractedGraphQLAPI[] {\n const numSources = workspaces.reduce((count, ws) => count + ws.sources.length, 0)\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // Validate that workspaces and their sources have non-empty projectId/dataset.\n // The worker's toWorkspaceMetadata validates this before constructing metadata,\n // but assert here to make the invariant explicit.\n for (const ws of workspaces) {\n if (!ws.projectId || !ws.dataset) {\n throw new Error(\n `Workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n for (const source of ws.sources) {\n if (!source.projectId || !source.dataset) {\n throw new Error(\n `Source \"${source.name}\" in workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n }\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId} = workspaces[0].sources[0]\n return [{dataset, projectId}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLApiMetadataFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Shared workspace/source resolution logic for both the metadata and full-compile paths.\n *\n * Both `resolveGraphQLAPIsFromConfig` and `resolveGraphQLApiMetadataFromConfig` need to\n * resolve the workspace and source for each GraphQL API config entry. This helper\n * extracts that shared logic so bug fixes and edge-case handling apply to both paths.\n */\nfunction resolveWorkspaceAndSource<\n TWorkspace extends {name: string},\n TSource extends {name: string},\n>(\n apiDef: GraphQLAPIConfig,\n workspaces: TWorkspace[],\n getSources: (workspace: TWorkspace) => TSource[],\n): {source: TSource; workspace: TWorkspace} {\n const {source: sourceName, workspace: workspaceName} = apiDef\n\n if (!workspaceName && workspaces.length > 1) {\n throw new Error(\n 'Must define `workspace` name in GraphQL API config when multiple workspaces are defined',\n )\n }\n\n // If we only have a single workspace defined, we can assume that is the intended one,\n // even if no `workspace` is defined for the GraphQL API\n const workspace =\n !workspaceName && workspaces.length === 1\n ? workspaces[0]\n : workspaces.find((space) => space.name === (workspaceName || 'default'))\n\n if (!workspace) {\n throw new Error(`Workspace \"${workspaceName || 'default'}\" not found`)\n }\n\n const sources = getSources(workspace)\n\n // If we only have a single source defined, we can assume that is the intended one,\n // even if no `source` is defined for the GraphQL API\n const source =\n !sourceName && sources.length === 1\n ? sources[0]\n : sources.find((src) => src.name === (sourceName || 'default'))\n\n if (!source) {\n throw new Error(\n `Source \"${sourceName || 'default'}\" not found in workspace \"${workspaceName || 'default'}\"`,\n )\n }\n\n return {source, workspace}\n}\n\nfunction resolveGraphQLApiMetadataFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: WorkspaceMetadata[],\n): ExtractedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.sources)\n\n return {\n dataset: source.dataset,\n filterSuffix: apiDef.filterSuffix,\n generation: apiDef.generation,\n id: apiDef.id,\n nonNullDocumentFields: apiDef.nonNullDocumentFields,\n playground: apiDef.playground,\n projectId: source.projectId,\n tag: apiDef.tag,\n }\n })\n}\n\nfunction resolveGraphQLAPIsFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: Workspace[],\n): TypeResolvedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.unstable_sources)\n\n return {\n ...apiDef,\n dataset: source.dataset,\n projectId: source.projectId,\n schemaTypes: getStrippedSchemaTypes(source.schema),\n }\n })\n}\n\nfunction validateCliConfig(\n config: GraphQLAPIConfig[],\n configPath = 'sanity.cli.js',\n): GraphQLAPIConfig[] {\n if (!Array.isArray(config)) {\n throw new TypeError(`\"graphql\" key in \"${configPath}\" must be an array if defined`)\n }\n\n if (config.length === 0) {\n throw new Error(`No GraphQL APIs defined in \"${configPath}\"`)\n }\n\n return config\n}\n\nfunction getStrippedSchemaTypes(schema: Schema): SchemaDefinitionish[] {\n const schemaDef = schema._original || {types: []}\n return schemaDef.types.map((type) => stripType(type))\n}\n\nfunction stripType(input: unknown): SchemaDefinitionish {\n return strip(input) as SchemaDefinitionish\n}\n\nfunction strip(input: unknown): unknown {\n if (Array.isArray(input)) {\n return input.map((item) => strip(item)).filter((item) => item !== undefined)\n }\n\n if (isPlainishObject(input)) {\n const stripped: Record<string, unknown> = {}\n for (const key of Object.keys(input)) {\n stripped[key] = strip(input[key])\n }\n return stripped\n }\n\n return isBasicType(input) ? input : undefined\n}\n\nfunction isPlainishObject(input: unknown): input is Record<string, unknown> {\n return isPlainObject(input)\n}\n\nfunction isBasicType(input: unknown): boolean {\n const type = typeof input\n if (type === 'boolean' || type === 'number' || type === 'string') {\n return true\n }\n\n if (type !== 'object') {\n return false\n }\n\n return Array.isArray(input) || input === null || isPlainishObject(input)\n}\n"],"names":["isPlainObject","oneline","resolveGraphQLApis","cliConfig","workspaces","numSources","reduce","count","workspace","unstable_sources","length","multiSource","multiWorkspace","hasGraphQLConfig","Boolean","graphql","Error","dataset","projectId","schema","schemaTypes","getStrippedSchemaTypes","apiDefs","validateCliConfig","resolveGraphQLAPIsFromConfig","resolveGraphQLApiMetadata","ws","sources","name","source","resolveGraphQLApiMetadataFromConfig","resolveWorkspaceAndSource","apiDef","getSources","sourceName","workspaceName","find","space","src","map","filterSuffix","generation","id","nonNullDocumentFields","playground","tag","config","configPath","Array","isArray","TypeError","schemaDef","_original","types","type","stripType","input","strip","item","filter","undefined","isPlainishObject","stripped","key","Object","keys","isBasicType"],"mappings":"AACA,OAAOA,mBAAmB,6BAA4B;AACtD,SAAQC,OAAO,QAAO,UAAS;AAkD/B,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,UAAU,EACgB;IAC1B,MAAMC,aAAaD,WAAWE,MAAM,CAClC,CAACC,OAAOC,YAAcD,QAAQC,UAAUC,gBAAgB,CAACC,MAAM,EAC/D;IAEF,MAAMC,cAAcN,aAAa;IACjC,MAAMO,iBAAiBR,WAAWM,MAAM,GAAG;IAC3C,MAAMG,mBAAmBC,QAAQX,WAAWY;IAE5C,IAAIX,WAAWM,MAAM,KAAK,GAAG;QAC3B,MAAM,IAAIM,MAAM;IAClB;IAEA,IAAIX,eAAe,GAAG;QACpB,MAAM,IAAIW,MAAM;IAClB;IAEA,sFAAsF;IACtF,IAAI,AAACJ,CAAAA,kBAAkBD,WAAU,KAAM,CA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AEA,OAAOD;AACT;AAEA,SAASzB,uBAAuBF,MAAc;IAC5C,MAAMgC,YAAYhC,OAAOiC,SAAS,IAAI;QAACC,OAAO,EAAE;IAAA;IAChD,OAAOF,UAAUE,KAAK,CAACd,GAAG,CAAC,CAACe,OAASC,UAAUD;AACjD;AAEA,SAASC,UAAUC,KAAc;IAC/B,OAAOC,MAAMD;AACf;AAEA,SAASC,MAAMD,KAAc;IAC3B,IAAIR,MAAMC,OAAO,CAACO,QAAQ;QACxB,OAAOA,MAAMjB,GAAG,CAAC,CAACmB,OAASD,MAAMC,OAAOC,MAAM,CAAC,CAACD,OAASA,SAASE;IACpE;IAEA,IAAIC,iBAAiBL,QAAQ;QAC3B,MAAMM,WAAoC,CAAC;QAC3C,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAACT,OAAQ;YACpCM,QAAQ,CAACC,IAAI,GAAGN,MAAMD,KAAK,CAACO,IAAI;QAClC;QACA,OAAOD;IACT;IAEA,OAAOI,YAAYV,SAASA,QAAQI;AACtC;AAEA,SAASC,iBAAiBL,KAAc;IACtC,OAAOxD,cAAcwD;AACvB;AAEA,SAASU,YAAYV,KAAc;IACjC,MAAMF,OAAO,OAAOE;IACpB,IAAIF,SAAS,aAAaA,SAAS,YAAYA,SAAS,UAAU;QAChE,OAAO;IACT;IAEA,IAAIA,SAAS,UAAU;QACrB,OAAO;IACT;IAEA,OAAON,MAAMC,OAAO,CAACO,UAAUA,UAAU,QAAQK,iBAAiBL;AACpE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/graphql/resolveGraphQLApisFromWorkspaces.ts"],"sourcesContent":["import {type Schema} from '@sanity/types'\nimport {oneline} from 'oneline'\n\nimport {\n type ExtractedGraphQLAPI,\n type GraphQLAPIConfig,\n type SchemaDefinitionish,\n type TypeResolvedGraphQLAPI,\n} from './types.js'\n\ninterface Source {\n dataset: string\n name: string\n projectId: string\n schema: Schema\n}\n\nexport interface Workspace extends Source {\n unstable_sources: Source[]\n}\n\n/**\n * Minimal source metadata — dataset/projectId pair for a source within a workspace.\n */\nexport interface SourceMetadata {\n dataset: string\n name: string\n projectId: string\n}\n\n/**\n * Minimal workspace metadata — enough for resolving API identifiers without compiling schemas.\n * This matches the raw workspace shape from `defineConfig()` before `resolveConfig()` processes it.\n *\n * The `sources` array mirrors `Workspace.unstable_sources` from the full resolved config.\n * When the raw config includes `unstable_sources`, they are extracted here. Otherwise, the\n * workspace itself is used as a single default source (matching what `resolveConfig()` would do).\n */\nexport interface WorkspaceMetadata {\n dataset: string\n name: string\n projectId: string\n sources: SourceMetadata[]\n}\n\ninterface ResolveGraphQLApisOptions {\n workspaces: Workspace[]\n\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n}\n\nexport function resolveGraphQLApis({\n cliConfig,\n workspaces,\n}: ResolveGraphQLApisOptions): TypeResolvedGraphQLAPI[] {\n const numSources = workspaces.reduce(\n (count, workspace) => count + workspace.unstable_sources.length,\n 0,\n )\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId, schema} = workspaces[0].unstable_sources[0]\n return [{dataset, projectId, schemaTypes: getStrippedSchemaTypes(schema)}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLAPIsFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Resolve GraphQL API metadata (projectId, dataset, tag, etc.) from raw workspace configs\n * without compiling schemas. This is used when we only need API identifiers, not schema types —\n * e.g. for `graphql undeploy --api` or `graphql list`.\n */\nexport function resolveGraphQLApiMetadata({\n cliConfig,\n workspaces,\n}: {\n cliConfig?: {graphql?: GraphQLAPIConfig[]}\n workspaces: WorkspaceMetadata[]\n}): ExtractedGraphQLAPI[] {\n const numSources = workspaces.reduce((count, ws) => count + ws.sources.length, 0)\n const multiSource = numSources > 1\n const multiWorkspace = workspaces.length > 1\n const hasGraphQLConfig = Boolean(cliConfig?.graphql)\n\n if (workspaces.length === 0) {\n throw new Error('No studio configuration found')\n }\n\n if (numSources === 0) {\n throw new Error('No sources (project ID / dataset) configured')\n }\n\n // We can only automatically configure if there is a single workspace + source in play\n if ((multiWorkspace || multiSource) && !hasGraphQLConfig) {\n throw new Error(oneline`\n Multiple workspaces/sources configured.\n You must define an array of GraphQL APIs in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\`\n and specify which workspace/source to use.\n `)\n }\n\n // Validate that workspaces and their sources have non-empty projectId/dataset.\n // The worker's toWorkspaceMetadata validates this before constructing metadata,\n // but assert here to make the invariant explicit.\n for (const ws of workspaces) {\n if (!ws.projectId || !ws.dataset) {\n throw new Error(\n `Workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n for (const source of ws.sources) {\n if (!source.projectId || !source.dataset) {\n throw new Error(\n `Source \"${source.name}\" in workspace \"${ws.name}\" is missing a projectId or dataset. ` +\n 'Check your studio configuration.',\n )\n }\n }\n }\n\n // No config is defined, but we have a single workspace + source, so use that\n if (!hasGraphQLConfig) {\n const {dataset, projectId} = workspaces[0].sources[0]\n return [{dataset, projectId}]\n }\n\n // Explicitly defined config\n const apiDefs = validateCliConfig(cliConfig?.graphql || [])\n return resolveGraphQLApiMetadataFromConfig(apiDefs, workspaces)\n}\n\n/**\n * Shared workspace/source resolution logic for both the metadata and full-compile paths.\n *\n * Both `resolveGraphQLAPIsFromConfig` and `resolveGraphQLApiMetadataFromConfig` need to\n * resolve the workspace and source for each GraphQL API config entry. This helper\n * extracts that shared logic so bug fixes and edge-case handling apply to both paths.\n */\nfunction resolveWorkspaceAndSource<\n TWorkspace extends {name: string},\n TSource extends {name: string},\n>(\n apiDef: GraphQLAPIConfig,\n workspaces: TWorkspace[],\n getSources: (workspace: TWorkspace) => TSource[],\n): {source: TSource; workspace: TWorkspace} {\n const {source: sourceName, workspace: workspaceName} = apiDef\n\n if (!workspaceName && workspaces.length > 1) {\n throw new Error(\n 'Must define `workspace` name in GraphQL API config when multiple workspaces are defined',\n )\n }\n\n // If we only have a single workspace defined, we can assume that is the intended one,\n // even if no `workspace` is defined for the GraphQL API\n const workspace =\n !workspaceName && workspaces.length === 1\n ? workspaces[0]\n : workspaces.find((space) => space.name === (workspaceName || 'default'))\n\n if (!workspace) {\n throw new Error(`Workspace \"${workspaceName || 'default'}\" not found`)\n }\n\n const sources = getSources(workspace)\n\n // If we only have a single source defined, we can assume that is the intended one,\n // even if no `source` is defined for the GraphQL API\n const source =\n !sourceName && sources.length === 1\n ? sources[0]\n : sources.find((src) => src.name === (sourceName || 'default'))\n\n if (!source) {\n throw new Error(\n `Source \"${sourceName || 'default'}\" not found in workspace \"${workspaceName || 'default'}\"`,\n )\n }\n\n return {source, workspace}\n}\n\nfunction resolveGraphQLApiMetadataFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: WorkspaceMetadata[],\n): ExtractedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.sources)\n\n return {\n dataset: source.dataset,\n filterSuffix: apiDef.filterSuffix,\n generation: apiDef.generation,\n id: apiDef.id,\n nonNullDocumentFields: apiDef.nonNullDocumentFields,\n playground: apiDef.playground,\n projectId: source.projectId,\n tag: apiDef.tag,\n }\n })\n}\n\nfunction resolveGraphQLAPIsFromConfig(\n apiDefs: GraphQLAPIConfig[],\n workspaces: Workspace[],\n): TypeResolvedGraphQLAPI[] {\n return apiDefs.map((apiDef) => {\n const {source} = resolveWorkspaceAndSource(apiDef, workspaces, (ws) => ws.unstable_sources)\n\n return {\n ...apiDef,\n dataset: source.dataset,\n projectId: source.projectId,\n schemaTypes: getStrippedSchemaTypes(source.schema),\n }\n })\n}\n\nfunction validateCliConfig(\n config: GraphQLAPIConfig[],\n configPath = 'sanity.cli.js',\n): GraphQLAPIConfig[] {\n if (!Array.isArray(config)) {\n throw new TypeError(`\"graphql\" key in \"${configPath}\" must be an array if defined`)\n }\n\n if (config.length === 0) {\n throw new Error(`No GraphQL APIs defined in \"${configPath}\"`)\n }\n\n return config\n}\n\nfunction getStrippedSchemaTypes(schema: Schema): SchemaDefinitionish[] {\n const schemaDef = schema._original || {types: []}\n return schemaDef.types.map((type) => stripType(type))\n}\n\nfunction stripType(input: unknown): SchemaDefinitionish {\n return strip(input) as SchemaDefinitionish\n}\n\nfunction strip(input: unknown): unknown {\n if (Array.isArray(input)) {\n return input.map((item) => strip(item)).filter((item) => item !== undefined)\n }\n\n if (isPlainishObject(input)) {\n const stripped: Record<string, unknown> = {}\n for (const key of Object.keys(input)) {\n stripped[key] = strip(input[key])\n }\n return stripped\n }\n\n return isBasicType(input) ? input : undefined\n}\n\nfunction isPlainishObject(input: unknown): input is Record<string, unknown> {\n if (typeof input !== 'object' || input === null) {\n return false\n }\n\n const prototype = Object.getPrototypeOf(input)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isBasicType(input: unknown): boolean {\n const type = typeof input\n if (type === 'boolean' || type === 'number' || type === 'string') {\n return true\n }\n\n if (type !== 'object') {\n return false\n }\n\n return Array.isArray(input) || input === null || isPlainishObject(input)\n}\n"],"names":["oneline","resolveGraphQLApis","cliConfig","workspaces","numSources","reduce","count","workspace","unstable_sources","length","multiSource","multiWorkspace","hasGraphQLConfig","Boolean","graphql","Error","dataset","projectId","schema","schemaTypes","getStrippedSchemaTypes","apiDefs","validateCliConfig","resolveGraphQLAPIsFromConfig","resolveGraphQLApiMetadata","ws","sources","name","source","resolveGraphQLApiMetadataFromConfig","resolveWorkspaceAndSource","apiDef","getSources","sourceName","workspaceName","find","space","src","map","filterSuffix","generation","id","nonNullDocumentFields","playground","tag","config","configPath","Array","isArray","TypeError","schemaDef","_original","types","type","stripType","input","strip","item","filter","undefined","isPlainishObject","stripped","key","Object","keys","isBasicType","prototype","getPrototypeOf"],"mappings":"AACA,SAAQA,OAAO,QAAO,UAAS;AAkD/B,OAAO,SAASC,mBAAmB,EACjCC,SAAS,EACTC,UAAU,EACgB;IAC1B,MAAMC,aAAaD,WAAWE,MAAM,CAClC,CAACC,OAAOC,YAAcD,QAAQC,UAAUC,gBAAgB,CAACC,MAAM,EAC/D;IAEF,MAAMC,cAAcN,aAAa;IACjC,MAAMO,iBAAiBR,WAAWM,MAAM,GAAG;IAC3C,MAAMG,mBAAmBC,QAAQX,WAAWY;IAE5C,IAAIX,WAAWM,MAAM,KAAK,GAAG;QAC3B,MAAM,IAAIM,MAAM;IAClB;IAEA,IAAIX,eAAe,GAAG;QACpB,MAAM,IAAIW,MAAM;IAClB;IAEA,sFAAsF;IACtF,IAAI,AAACJ,CAAAA,kBAAkBD,WAAU,KAAM,CAACE,kBAAkB;QACxD,MAAM,IAAIG,MAAMf,OAAO,CAAC;;;;IAIxB,CAAC;IACH;IAEA,6EAA6E;IAC7E,IAAI,CAACY,kBAAkB;QACrB,MAAM,EAACI,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAC,GAAGf,UAAU,CAAC,EAAE,CAACK,gBAAgB,CAAC,EAAE;QACtE,OAAO;YAAC;gBAACQ;gBAASC;gBAAWE,aAAaC,uBAAuBF;YAAO;SAAE;IAC5E;IAEA,4BAA4B;IAC5B,MAAMG,UAAUC,kBAAkBpB,WAAWY,WAAW,EAAE;IAC1D,OAAOS,6BAA6BF,SAASlB;AAC/C;AAEA;;;;CAIC,GACD,OAAO,SAASqB,0BAA0B,EACxCtB,SAAS,EACTC,UAAU,EAIX;IACC,MAAMC,aAAaD,WAAWE,MAAM,CA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CM,QAAQ,CAACC,IAAI,GAAGN,MAAMD,KAAK,CAACO,IAAI;QAClC;QACA,OAAOD;IACT;IAEA,OAAOI,YAAYV,SAASA,QAAQI;AACtC;AAEA,SAASC,iBAAiBL,KAAc;IACtC,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM;QAC/C,OAAO;IACT;IAEA,MAAMW,YAAYH,OAAOI,cAAc,CAACZ;IACxC,OAAOW,cAAc,QAAQA,cAAcH,OAAOG,SAAS;AAC7D;AAEA,SAASD,YAAYV,KAAc;IACjC,MAAMF,OAAO,OAAOE;IACpB,IAAIF,SAAS,aAAaA,SAAS,YAAYA,SAAS,UAAU;QAChE,OAAO;IACT;IAEA,IAAIA,SAAS,UAAU;QACrB,OAAO;IACT;IAEA,OAAON,MAAMC,OAAO,CAACO,UAAUA,UAAU,QAAQK,iBAAiBL;AACpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/init/templates/shopify.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig, isDev} from 'sanity'\n\nimport {structureTool} from 'sanity/structure'\nimport {schemaTypes} from './schemaTypes'\nimport {structure} from './structure'\n\nimport {visionTool} from '@sanity/vision'\nimport {colorInput} from '@sanity/color-input'\nimport {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'\nimport {media, mediaAssetSource} from 'sanity-plugin-media'\nimport {customDocumentActions} from './plugins/customDocumentActions'\nimport Navbar from './components/studio/Navbar'\n\nconst devOnlyPlugins = [visionTool()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool({structure}),\n colorInput(),\n imageHotspotArrayPlugin(),\n customDocumentActions(),\n media(),\n ...(isDev ? devOnlyPlugins : []),\n ],\n\n schema: {\n types: schemaTypes,\n },\n\n form: {\n file: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)\n },\n },\n image: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource === mediaAssetSource)\n },\n },\n },\n\n studio: {\n components: {\n navbar: Navbar,\n },\n },\n})`\n\nconst shopifyTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@sanity/asset-utils': '^2.3.0',\n '@sanity/color-input': '^6.0.6',\n '@sanity/icons': '^5.0.0',\n '@sanity/ui': '^3.5.0',\n 'lodash.get': '^4.4.2',\n 'pluralize-esm': '^9.0.2',\n 'sanity-plugin-hotspot-array': '^5.0.11',\n 'sanity-plugin-media': '^4.3.1',\n slug: '^8.2.2',\n },\n devDependencies: {\n '@portabletext/types': '^2.0.2',\n '@types/lodash.get': '^4.4.7',\n '@types/slug': '^5.0.3',\n },\n}\nexport default shopifyTemplate\n"],"names":["configTemplate","shopifyTemplate","dependencies","slug","devDependencies"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDtB,CAAC;AAEH,MAAMC,kBAAmC;IACvCD;IACAE,cAAc;QACZ,uBAAuB;QACvB,uBAAuB;QACvB,iBAAiB;QACjB,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,+BAA+B;QAC/B,uBAAuB;QACvBC,MAAM;IACR;IACAC,iBAAiB;QACf,uBAAuB;QACvB,qBAAqB;QACrB,eAAe;IACjB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/init/templates/shopify.ts"],"sourcesContent":["import {type ProjectTemplate} from '../types.js'\n\nconst configTemplate = `\nimport {defineConfig, isDev} from 'sanity'\n\nimport {structureTool} from 'sanity/structure'\nimport {schemaTypes} from './schemaTypes'\nimport {structure} from './structure'\n\nimport {visionTool} from '@sanity/vision'\nimport {colorInput} from '@sanity/color-input'\nimport {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'\nimport {media, mediaAssetSource} from 'sanity-plugin-media'\nimport {customDocumentActions} from './plugins/customDocumentActions'\nimport Navbar from './components/studio/Navbar'\n\nconst devOnlyPlugins = [visionTool()]\n\nexport default defineConfig({\n name: '%sourceName%',\n title: '%projectName%',\n\n projectId: '%projectId%',\n dataset: '%dataset%',\n\n plugins: [\n structureTool({structure}),\n colorInput(),\n imageHotspotArrayPlugin(),\n customDocumentActions(),\n media(),\n ...(isDev ? devOnlyPlugins : []),\n ],\n\n schema: {\n types: schemaTypes,\n },\n\n form: {\n file: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)\n },\n },\n image: {\n assetSources: (previousAssetSources) => {\n return previousAssetSources.filter((assetSource) => assetSource === mediaAssetSource)\n },\n },\n },\n\n studio: {\n components: {\n navbar: Navbar,\n },\n },\n})`\n\nconst shopifyTemplate: ProjectTemplate = {\n configTemplate,\n dependencies: {\n '@sanity/asset-utils': '^2.3.0',\n '@sanity/color-input': '^6.0.6',\n '@sanity/icons': '^5.0.0',\n '@sanity/ui': '^3.5.0',\n 'lodash.get': '^4.4.2',\n 'pluralize-esm': '^9.0.2',\n 'sanity-plugin-hotspot-array': '^5.0.11',\n 'sanity-plugin-media': '^4.3.1',\n slug: '^8.2.2',\n },\n devDependencies: {\n '@portabletext/types': '^2.0.2',\n '@types/lodash.get': '^4.4.7',\n '@types/slug': '^5.0.3',\n },\n typescriptOnly: true,\n}\nexport default shopifyTemplate\n"],"names":["configTemplate","shopifyTemplate","dependencies","slug","devDependencies","typescriptOnly"],"mappings":"AAEA,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDtB,CAAC;AAEH,MAAMC,kBAAmC;IACvCD;IACAE,cAAc;QACZ,uBAAuB;QACvB,uBAAuB;QACvB,iBAAiB;QACjB,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,+BAA+B;QAC/B,uBAAuB;QACvBC,MAAM;IACR;IACAC,iBAAiB;QACf,uBAAuB;QACvB,qBAAqB;QACrB,eAAe;IACjB;IACAC,gBAAgB;AAClB;AACA,eAAeJ,gBAAe"}
|
|
@@ -1,42 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getTimer, studioWorkerTask } from '@sanity/cli-core';
|
|
3
|
-
import { spinner } from '@sanity/cli-core/ux';
|
|
4
|
-
import { manifestDebug } from './debug.js';
|
|
5
|
-
import { writeManifestFile } from './writeManifestFile.js';
|
|
6
|
-
const CREATE_TIMER = 'create-manifest';
|
|
1
|
+
import { extractManifest as internalExtractManifest } from '@sanity/cli-build/_internal/manifest';
|
|
7
2
|
export async function extractManifest({ outPath, path, workDir }) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
path
|
|
3
|
+
await internalExtractManifest({
|
|
4
|
+
outPath,
|
|
5
|
+
path,
|
|
6
|
+
workDir
|
|
11
7
|
});
|
|
12
|
-
const timer = getTimer();
|
|
13
|
-
timer.start(CREATE_TIMER);
|
|
14
|
-
const spin = spinner('Extracting manifest').start();
|
|
15
|
-
try {
|
|
16
|
-
const result = await studioWorkerTask(new URL('extractManifest.worker.js', import.meta.url), {
|
|
17
|
-
name: 'extractManifest',
|
|
18
|
-
studioRootPath: workDir,
|
|
19
|
-
workerData: {
|
|
20
|
-
configPath: path,
|
|
21
|
-
workDir
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
manifestDebug('Result %o', result);
|
|
25
|
-
if (result.type === 'error') {
|
|
26
|
-
throw new SchemaExtractionError(result.error, result.validation);
|
|
27
|
-
}
|
|
28
|
-
await writeManifestFile({
|
|
29
|
-
outPath,
|
|
30
|
-
workDir,
|
|
31
|
-
workspaceManifests: result.workspaceManifests
|
|
32
|
-
});
|
|
33
|
-
const manifestDuration = timer.end(CREATE_TIMER);
|
|
34
|
-
spin.succeed(`Extracted manifest (${manifestDuration.toFixed(0)}ms)`);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
manifestDebug('Error extracting manifest', err);
|
|
37
|
-
spin.fail();
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
8
|
}
|
|
41
9
|
|
|
42
10
|
//# sourceMappingURL=extractManifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/manifest/extractManifest.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/manifest/extractManifest.ts"],"sourcesContent":["import {extractManifest as internalExtractManifest} from '@sanity/cli-build/_internal/manifest'\n\ntype ExtractManifestOptions = Parameters<typeof internalExtractManifest>[0]\n\nexport async function extractManifest({\n outPath,\n path,\n workDir,\n}: ExtractManifestOptions): Promise<void> {\n await internalExtractManifest({outPath, path, workDir})\n}\n"],"names":["extractManifest","internalExtractManifest","outPath","path","workDir"],"mappings":"AAAA,SAAQA,mBAAmBC,uBAAuB,QAAO,uCAAsC;AAI/F,OAAO,eAAeD,gBAAgB,EACpCE,OAAO,EACPC,IAAI,EACJC,OAAO,EACgB;IACvB,MAAMH,wBAAwB;QAACC;QAASC;QAAMC;IAAO;AACvD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { SANITY_CACHE_DIR } from '@sanity/cli-build/_internal/build';
|
|
4
|
+
import { MANIFEST_FILENAME } from '@sanity/cli-build/_internal/manifest';
|
|
4
5
|
import { extractManifest } from './extractManifest.js';
|
|
5
|
-
import { MANIFEST_FILENAME } from './writeManifestFile.js';
|
|
6
6
|
/**
|
|
7
7
|
* Dev-time manifest output directory, relative to the studio working
|
|
8
8
|
* directory. Sibling of Vite's `cacheDir` so it stays out of `dist` and is
|