@sanity/cli 8.3.0 → 8.4.1

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.
Files changed (115) hide show
  1. package/dist/actions/build/buildApp.js +14 -7
  2. package/dist/actions/build/buildApp.js.map +1 -1
  3. package/dist/actions/build/buildStudio.js +3 -3
  4. package/dist/actions/build/buildStudio.js.map +1 -1
  5. package/dist/actions/deploy/deployApp.js +32 -25
  6. package/dist/actions/deploy/deployApp.js.map +1 -1
  7. package/dist/actions/deploy/deployStudio.js +2 -1
  8. package/dist/actions/deploy/deployStudio.js.map +1 -1
  9. package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js +2 -4
  10. package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js.map +1 -1
  11. package/dist/actions/deploy/deploymentPlan.js.map +1 -1
  12. package/dist/actions/dev/devAction.js +2 -2
  13. package/dist/actions/dev/devAction.js.map +1 -1
  14. package/dist/actions/dev/servers/getDevServerConfig.js +13 -6
  15. package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
  16. package/dist/actions/dev/servers/startAppDevServer.js +4 -2
  17. package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
  18. package/dist/actions/graphql/gen1/generateTypeFilters.js +1 -2
  19. package/dist/actions/graphql/gen1/generateTypeFilters.js.map +1 -1
  20. package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js +5 -2
  21. package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js.map +1 -1
  22. package/dist/actions/init/templates/shopify.js +2 -1
  23. package/dist/actions/init/templates/shopify.js.map +1 -1
  24. package/dist/actions/manifest/extractManifest.js +5 -37
  25. package/dist/actions/manifest/extractManifest.js.map +1 -1
  26. package/dist/actions/manifest/extractStudioManifest.js +1 -1
  27. package/dist/actions/manifest/extractStudioManifest.js.map +1 -1
  28. package/dist/actions/preview/previewAction.js +1 -1
  29. package/dist/actions/preview/previewAction.js.map +1 -1
  30. package/dist/actions/schema/deleteSchemaAction.js +1 -1
  31. package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
  32. package/dist/actions/schema/deploySchemas.js.map +1 -1
  33. package/dist/actions/schema/extractSanityWorkspace.worker.js +1 -1
  34. package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -1
  35. package/dist/actions/schema/listSchemas.js +1 -1
  36. package/dist/actions/schema/listSchemas.js.map +1 -1
  37. package/dist/actions/schema/schemaTypeHelpers.js +5 -0
  38. package/dist/actions/schema/schemaTypeHelpers.js.map +1 -0
  39. package/dist/actions/schema/updateWorkspaceSchema.js +1 -1
  40. package/dist/actions/schema/updateWorkspaceSchema.js.map +1 -1
  41. package/dist/actions/schema/utils/schemaStoreValidation.js +2 -2
  42. package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
  43. package/dist/actions/schema/utils/workspaceSchemaId.js +1 -1
  44. package/dist/actions/schema/utils/workspaceSchemaId.js.map +1 -1
  45. package/dist/actions/versions/getFormatters.js +1 -2
  46. package/dist/actions/versions/getFormatters.js.map +1 -1
  47. package/dist/commands/documents/create.js +4 -4
  48. package/dist/commands/documents/create.js.map +1 -1
  49. package/dist/commands/hooks/logs.js +1 -2
  50. package/dist/commands/hooks/logs.js.map +1 -1
  51. package/dist/commands/projects/list.js +3 -5
  52. package/dist/commands/projects/list.js.map +1 -1
  53. package/dist/commands/undeploy.js +7 -5
  54. package/dist/commands/undeploy.js.map +1 -1
  55. package/dist/commands/users/list.js +3 -5
  56. package/dist/commands/users/list.js.map +1 -1
  57. package/dist/commands/versions.js +1 -2
  58. package/dist/commands/versions.js.map +1 -1
  59. package/dist/exports/_internal.d.ts +1 -67
  60. package/dist/exports/_internal.js +1 -1
  61. package/dist/exports/_internal.js.map +1 -1
  62. package/dist/exports/index.d.ts +2 -2
  63. package/dist/exports/index.js +2 -1
  64. package/dist/exports/index.js.map +1 -1
  65. package/dist/exports/runtime.d.ts +2 -2
  66. package/dist/exports/runtime.js +1 -1
  67. package/dist/exports/runtime.js.map +1 -1
  68. package/dist/generated/apiRoutes.js +4 -0
  69. package/dist/generated/apiRoutes.js.map +1 -1
  70. package/dist/prompts/selectMediaLibrary.js +2 -3
  71. package/dist/prompts/selectMediaLibrary.js.map +1 -1
  72. package/dist/services/mintProject.js +27 -14
  73. package/dist/services/mintProject.js.map +1 -1
  74. package/dist/services/schemas.js.map +1 -1
  75. package/dist/services/userApplications.js.map +1 -1
  76. package/dist/util/determineIsApp.js +1 -1
  77. package/dist/util/determineIsApp.js.map +1 -1
  78. package/dist/util/sortRowsByColumn.js +23 -0
  79. package/dist/util/sortRowsByColumn.js.map +1 -0
  80. package/oclif.manifest.json +253 -253
  81. package/package.json +6 -9
  82. package/dist/actions/manifest/blockTypeTransformer.js +0 -67
  83. package/dist/actions/manifest/blockTypeTransformer.js.map +0 -1
  84. package/dist/actions/manifest/extractCoreAppManifest.js +0 -111
  85. package/dist/actions/manifest/extractCoreAppManifest.js.map +0 -1
  86. package/dist/actions/manifest/extractManifest.worker.js +0 -30
  87. package/dist/actions/manifest/extractManifest.worker.js.map +0 -1
  88. package/dist/actions/manifest/extractWorkspaceManifest.js +0 -72
  89. package/dist/actions/manifest/extractWorkspaceManifest.js.map +0 -1
  90. package/dist/actions/manifest/iconResolver.js +0 -36
  91. package/dist/actions/manifest/iconResolver.js.map +0 -1
  92. package/dist/actions/manifest/purifyConfig.js +0 -307
  93. package/dist/actions/manifest/purifyConfig.js.map +0 -1
  94. package/dist/actions/manifest/referenceTransformer.js +0 -51
  95. package/dist/actions/manifest/referenceTransformer.js.map +0 -1
  96. package/dist/actions/manifest/resolveSchemaIcon.js +0 -43
  97. package/dist/actions/manifest/resolveSchemaIcon.js.map +0 -1
  98. package/dist/actions/manifest/sanitizeIcon.js +0 -13
  99. package/dist/actions/manifest/sanitizeIcon.js.map +0 -1
  100. package/dist/actions/manifest/schemaTypeHelpers.js +0 -110
  101. package/dist/actions/manifest/schemaTypeHelpers.js.map +0 -1
  102. package/dist/actions/manifest/schemaTypeTransformer.js +0 -169
  103. package/dist/actions/manifest/schemaTypeTransformer.js.map +0 -1
  104. package/dist/actions/manifest/transformerUtils.js +0 -40
  105. package/dist/actions/manifest/transformerUtils.js.map +0 -1
  106. package/dist/actions/manifest/types.js +0 -13
  107. package/dist/actions/manifest/types.js.map +0 -1
  108. package/dist/actions/manifest/validationTransformer.js +0 -84
  109. package/dist/actions/manifest/validationTransformer.js.map +0 -1
  110. package/dist/actions/manifest/writeManifestFile.js +0 -29
  111. package/dist/actions/manifest/writeManifestFile.js.map +0 -1
  112. package/dist/actions/manifest/writeWorkspaceFiles.js +0 -30
  113. package/dist/actions/manifest/writeWorkspaceFiles.js.map +0 -1
  114. package/dist/actions/schema/uploadSchemaToLexicon.js +0 -91
  115. package/dist/actions/schema/uploadSchemaToLexicon.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/validationTransformer.ts"],"sourcesContent":["import {type Rule, type RuleSpec, type SchemaValidationValue} from '@sanity/types'\n\nimport {type SerializableProp} from './transformerUtils.js'\nimport {type ManifestValidationGroup, type ManifestValidationRule} from './types.js'\n\ntype Validation = Record<string, never> | {validation: ManifestValidationGroup[]}\ntype ManifestValidationFlag = ManifestValidationRule['flag']\ntype ValidationRuleTransformer = (rule: RuleSpec) => ManifestValidationRule | undefined\n\nconst transformTypeValidationRule: ValidationRuleTransformer = (rule) => {\n return {\n ...rule,\n constraint:\n 'constraint' in rule &&\n (typeof rule.constraint === 'string'\n ? rule.constraint.toLowerCase()\n : retainSerializablePropsForValidation(rule.constraint)),\n }\n}\n\nconst validationRuleTransformers: Partial<\n Record<ManifestValidationFlag, ValidationRuleTransformer>\n> = {\n type: transformTypeValidationRule,\n}\n\n/**\n * Transforms schema validation rules to their manifest representation\n */\nexport function transformValidation(\n validation: SchemaValidationValue,\n retainSerializableProps: (value: unknown, depth?: number) => SerializableProp,\n): Validation {\n const validationArray = (Array.isArray(validation) ? validation : [validation]).filter(\n (value): value is Rule => typeof value === 'object' && '_type' in value,\n )\n\n // we don't want type in the output as that is implicitly given by the typedef itself an will only bloat the payload\n const disallowedFlags = new Set(['type'])\n\n const serializedValidation = validationArray\n .map(({_level, _message, _rules}) => {\n const message: Partial<Pick<ManifestValidationGroup, 'message'>> =\n typeof _message === 'string' ? {message: _message} : {}\n\n const serializedRules = _rules\n .filter((rule) => {\n if (!('constraint' in rule)) {\n return false\n }\n\n const {constraint, flag} = rule\n\n if (disallowedFlags.has(flag)) {\n return false\n }\n\n // Validation rules that refer to other fields use symbols, which cannot be serialized. It would\n // be possible to transform these to a serializable type, but we haven't implemented that for now.\n const isFieldReference =\n typeof constraint === 'object' &&\n 'type' in constraint &&\n typeof constraint.type === 'symbol' &&\n (constraint.type.description === 'FIELD_REF' ||\n constraint.type.description === '@sanity/schema/field-ref')\n\n return !isFieldReference\n })\n .map((rule) => {\n const transformer: ValidationRuleTransformer =\n validationRuleTransformers[rule.flag] ??\n ((spec) => retainSerializableProps(spec) as ManifestValidationRule)\n\n const transformedRule = transformer(rule)\n\n if (!transformedRule) {\n return\n }\n\n return transformedRule\n })\n .filter((rule) => rule !== undefined)\n\n return {\n level: _level,\n rules: serializedRules,\n ...message,\n }\n })\n .filter((group) => group.rules.length > 0)\n\n return serializedValidation.length > 0 ? {validation: serializedValidation} : {}\n}\n\n/**\n * Helper function to retain serializable props specifically for validation transformation.\n * This is used internally by transformTypeValidationRule.\n */\nfunction retainSerializablePropsForValidation(value: unknown): SerializableProp {\n if (value === null || value === undefined) {\n return undefined\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n if (value === '') {\n return undefined\n }\n return value\n }\n\n if (value instanceof RegExp) {\n return value.toString()\n }\n\n if (Array.isArray(value)) {\n const items = value\n .map((item) => retainSerializablePropsForValidation(item))\n .filter((item) => item !== undefined)\n return items.length > 0 ? (items as SerializableProp) : undefined\n }\n\n if (typeof value === 'object') {\n const entries = Object.entries(value)\n .map(([key, val]) => [key, retainSerializablePropsForValidation(val)])\n .filter(([, val]) => val !== undefined)\n return entries.length > 0 ? Object.fromEntries(entries) : undefined\n }\n\n return undefined\n}\n"],"names":["transformTypeValidationRule","rule","constraint","toLowerCase","retainSerializablePropsForValidation","validationRuleTransformers","type","transformValidation","validation","retainSerializableProps","validationArray","Array","isArray","filter","value","disallowedFlags","Set","serializedValidation","map","_level","_message","_rules","message","serializedRules","flag","has","isFieldReference","description","transformer","spec","transformedRule","undefined","level","rules","group","length","RegExp","toString","items","item","entries","Object","key","val","fromEntries"],"mappings":"AASA,MAAMA,8BAAyD,CAACC;IAC9D,OAAO;QACL,GAAGA,IAAI;QACPC,YACE,gBAAgBD,QACf,CAAA,OAAOA,KAAKC,UAAU,KAAK,WACxBD,KAAKC,UAAU,CAACC,WAAW,KAC3BC,qCAAqCH,KAAKC,UAAU,CAAA;IAC5D;AACF;AAEA,MAAMG,6BAEF;IACFC,MAAMN;AACR;AAEA;;CAEC,GACD,OAAO,SAASO,oBACdC,UAAiC,EACjCC,uBAA6E;IAE7E,MAAMC,kBAAkB,AAACC,CAAAA,MAAMC,OAAO,CAACJ,cAAcA,aAAa;QAACA;KAAW,AAAD,EAAGK,MAAM,CACpF,CAACC,QAAyB,OAAOA,UAAU,YAAY,WAAWA;IAGpE,oHAAoH;IACpH,MAAMC,kBAAkB,IAAIC,IAAI;QAAC;KAAO;IAExC,MAAMC,uBAAuBP,gBAC1BQ,GAAG,CAAC,CAAC,EAACC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAC;QAC9B,MAAMC,UACJ,OAAOF,aAAa,WAAW;YAACE,SAASF;QAAQ,IAAI,CAAC;QAExD,MAAMG,kBAAkBF,OACrBR,MAAM,CAAC,CAACZ;YACP,IAAI,CAAE,CAAA,gBAAgBA,IAAG,GAAI;gBAC3B,OAAO;YACT;YAEA,MAAM,EAACC,UAAU,EAAEsB,IAAI,EAAC,GAAGvB;YAE3B,IAAIc,gBAAgBU,GAAG,CAACD,OAAO;gBAC7B,OAAO;YACT;YAEA,gGAA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UAAU;QAC7B,MAAM0B,UAAUC,OAAOD,OAAO,CAAC1B,OAC5BI,GAAG,CAAC,CAAC,CAACwB,KAAKC,IAAI,GAAK;gBAACD;gBAAKtC,qCAAqCuC;aAAK,EACpE9B,MAAM,CAAC,CAAC,GAAG8B,IAAI,GAAKA,QAAQZ;QAC/B,OAAOS,QAAQL,MAAM,GAAG,IAAIM,OAAOG,WAAW,CAACJ,WAAWT;IAC5D;IAEA,OAAOA;AACT"}
@@ -1,29 +0,0 @@
1
- import { mkdir, writeFile } from 'node:fs/promises';
2
- import { isAbsolute, join, resolve } from 'node:path';
3
- import { getLocalPackageVersion, subdebug } from '@sanity/cli-core';
4
- import { writeWorkspaceFiles } from './writeWorkspaceFiles.js';
5
- export const MANIFEST_FILENAME = 'create-manifest.json';
6
- const debug = subdebug('writeManifestFile');
7
- export async function writeManifestFile({ outPath, workDir, workspaceManifests }) {
8
- const staticPath = isAbsolute(outPath) ? outPath : resolve(join(workDir, outPath));
9
- debug('Writing manifest to %s', staticPath);
10
- const path = join(staticPath, MANIFEST_FILENAME);
11
- await mkdir(staticPath, {
12
- recursive: true
13
- });
14
- const workspaceFiles = await writeWorkspaceFiles(workspaceManifests, staticPath);
15
- const manifest = {
16
- /**
17
- * Version history:
18
- * 1: Initial release.
19
- * 2: Added tools file.
20
- * 3. Added studioVersion field.
21
- */ createdAt: new Date().toISOString(),
22
- studioVersion: await getLocalPackageVersion('sanity', workDir),
23
- version: 3,
24
- workspaces: workspaceFiles
25
- };
26
- await writeFile(path, JSON.stringify(manifest, null, 2));
27
- }
28
-
29
- //# sourceMappingURL=writeManifestFile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/writeManifestFile.ts"],"sourcesContent":["import {mkdir, writeFile} from 'node:fs/promises'\nimport {isAbsolute, join, resolve} from 'node:path'\n\nimport {getLocalPackageVersion, subdebug} from '@sanity/cli-core'\n\nimport {type CreateManifest, type CreateWorkspaceManifest} from './types.js'\nimport {writeWorkspaceFiles} from './writeWorkspaceFiles.js'\n\nexport const MANIFEST_FILENAME = 'create-manifest.json'\n\nconst debug = subdebug('writeManifestFile')\n\nexport interface WriteManifestFileOptions {\n /**\n * Target directory for the manifest files. May be absolute or relative — relative\n * paths are resolved against `workDir`.\n */\n outPath: string\n /**\n * Studio root directory. Used to resolve a relative `outPath` and to look up the\n * local `sanity` package version that gets stamped onto the manifest.\n */\n workDir: string\n /** Extracted workspace manifests to serialize alongside the top-level manifest. */\n workspaceManifests: CreateWorkspaceManifest[]\n}\n\nexport async function writeManifestFile({\n outPath,\n workDir,\n workspaceManifests,\n}: WriteManifestFileOptions) {\n const staticPath = isAbsolute(outPath) ? outPath : resolve(join(workDir, outPath))\n debug('Writing manifest to %s', staticPath)\n const path = join(staticPath, MANIFEST_FILENAME)\n\n await mkdir(staticPath, {recursive: true})\n\n const workspaceFiles = await writeWorkspaceFiles(workspaceManifests, staticPath)\n\n const manifest: CreateManifest = {\n /**\n * Version history:\n * 1: Initial release.\n * 2: Added tools file.\n * 3. Added studioVersion field.\n */\n createdAt: new Date().toISOString(),\n studioVersion: await getLocalPackageVersion('sanity', workDir),\n version: 3,\n workspaces: workspaceFiles,\n }\n\n await writeFile(path, JSON.stringify(manifest, null, 2))\n}\n"],"names":["mkdir","writeFile","isAbsolute","join","resolve","getLocalPackageVersion","subdebug","writeWorkspaceFiles","MANIFEST_FILENAME","debug","writeManifestFile","outPath","workDir","workspaceManifests","staticPath","path","recursive","workspaceFiles","manifest","createdAt","Date","toISOString","studioVersion","version","workspaces","JSON","stringify"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,SAAQC,UAAU,EAAEC,IAAI,EAAEC,OAAO,QAAO,YAAW;AAEnD,SAAQC,sBAAsB,EAAEC,QAAQ,QAAO,mBAAkB;AAGjE,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,OAAO,MAAMC,oBAAoB,uBAAsB;AAEvD,MAAMC,QAAQH,SAAS;AAiBvB,OAAO,eAAeI,kBAAkB,EACtCC,OAAO,EACPC,OAAO,EACPC,kBAAkB,EACO;IACzB,MAAMC,aAAaZ,WAAWS,WAAWA,UAAUP,QAAQD,KAAKS,SAASD;IACzEF,MAAM,0BAA0BK;IAChC,MAAMC,OAAOZ,KAAKW,YAAYN;IAE9B,MAAMR,MAAMc,YAAY;QAACE,WAAW;IAAI;IAExC,MAAMC,iBAAiB,MAAMV,oBAAoBM,oBAAoBC;IAErE,MAAMI,WAA2B;QAC/B;;;;;KAKC,GACDC,WAAW,IAAIC,OAAOC,WAAW;QACjCC,eAAe,MAAMjB,uBAAuB,UAAUO;QACtDW,SAAS;QACTC,YAAYP;IACd;IAEA,MAAMhB,UAAUc,MAAMU,KAAKC,SAAS,CAACR,UAAU,MAAM;AACvD"}
@@ -1,30 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { writeFile } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- const SCHEMA_FILENAME_SUFFIX = '.create-schema.json';
5
- const TOOLS_FILENAME_SUFFIX = '.create-tools.json';
6
- export function writeWorkspaceFiles(manifestWorkspaces, staticPath) {
7
- const output = manifestWorkspaces.map((workspace)=>writeWorkspaceFile(workspace, staticPath));
8
- return Promise.all(output);
9
- }
10
- async function writeWorkspaceFile(workspace, staticPath) {
11
- const [schemaFilename, toolsFilename] = await Promise.all([
12
- createFile(staticPath, workspace.schema, SCHEMA_FILENAME_SUFFIX),
13
- createFile(staticPath, workspace.tools, TOOLS_FILENAME_SUFFIX)
14
- ]);
15
- return {
16
- ...workspace,
17
- schema: schemaFilename,
18
- tools: toolsFilename
19
- };
20
- }
21
- async function createFile(path, content, filenameSuffix) {
22
- const stringifiedContent = JSON.stringify(content, null, 2);
23
- const hash = createHash('sha1').update(stringifiedContent).digest('hex');
24
- const filename = `${hash.slice(0, 8)}${filenameSuffix}`;
25
- // workspaces with identical data will overwrite each others file. This is ok, since they are identical and can be shared
26
- await writeFile(join(path, filename), stringifiedContent);
27
- return filename;
28
- }
29
-
30
- //# sourceMappingURL=writeWorkspaceFiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/writeWorkspaceFiles.ts"],"sourcesContent":["import {createHash} from 'node:crypto'\nimport {writeFile} from 'node:fs/promises'\nimport {join} from 'node:path'\n\nimport {type CreateWorkspaceManifest, type ManifestWorkspaceFile} from './types.js'\n\nconst SCHEMA_FILENAME_SUFFIX = '.create-schema.json'\nconst TOOLS_FILENAME_SUFFIX = '.create-tools.json'\n\nexport function writeWorkspaceFiles(\n manifestWorkspaces: CreateWorkspaceManifest[],\n staticPath: string,\n): Promise<ManifestWorkspaceFile[]> {\n const output = manifestWorkspaces.map((workspace) => writeWorkspaceFile(workspace, staticPath))\n\n return Promise.all(output)\n}\n\nasync function writeWorkspaceFile(\n workspace: CreateWorkspaceManifest,\n staticPath: string,\n): Promise<ManifestWorkspaceFile> {\n const [schemaFilename, toolsFilename] = await Promise.all([\n createFile(staticPath, workspace.schema, SCHEMA_FILENAME_SUFFIX),\n createFile(staticPath, workspace.tools, TOOLS_FILENAME_SUFFIX),\n ])\n\n return {\n ...workspace,\n schema: schemaFilename,\n tools: toolsFilename,\n }\n}\n\nasync function createFile(path: string, content: unknown, filenameSuffix: string) {\n const stringifiedContent = JSON.stringify(content, null, 2)\n const hash = createHash('sha1').update(stringifiedContent).digest('hex')\n const filename = `${hash.slice(0, 8)}${filenameSuffix}`\n\n // workspaces with identical data will overwrite each others file. This is ok, since they are identical and can be shared\n await writeFile(join(path, filename), stringifiedContent)\n\n return filename\n}\n"],"names":["createHash","writeFile","join","SCHEMA_FILENAME_SUFFIX","TOOLS_FILENAME_SUFFIX","writeWorkspaceFiles","manifestWorkspaces","staticPath","output","map","workspace","writeWorkspaceFile","Promise","all","schemaFilename","toolsFilename","createFile","schema","tools","path","content","filenameSuffix","stringifiedContent","JSON","stringify","hash","update","digest","filename","slice"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAa;AACtC,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,IAAI,QAAO,YAAW;AAI9B,MAAMC,yBAAyB;AAC/B,MAAMC,wBAAwB;AAE9B,OAAO,SAASC,oBACdC,kBAA6C,EAC7CC,UAAkB;IAElB,MAAMC,SAASF,mBAAmBG,GAAG,CAAC,CAACC,YAAcC,mBAAmBD,WAAWH;IAEnF,OAAOK,QAAQC,GAAG,CAACL;AACrB;AAEA,eAAeG,mBACbD,SAAkC,EAClCH,UAAkB;IAElB,MAAM,CAACO,gBAAgBC,cAAc,GAAG,MAAMH,QAAQC,GAAG,CAAC;QACxDG,WAAWT,YAAYG,UAAUO,MAAM,EAAEd;QACzCa,WAAWT,YAAYG,UAAUQ,KAAK,EAAEd;KACzC;IAED,OAAO;QACL,GAAGM,SAAS;QACZO,QAAQH;QACRI,OAAOH;IACT;AACF;AAEA,eAAeC,WAAWG,IAAY,EAAEC,OAAgB,EAAEC,cAAsB;IAC9E,MAAMC,qBAAqBC,KAAKC,SAAS,CAACJ,SAAS,MAAM;IACzD,MAAMK,OAAOzB,WAAW,QAAQ0B,MAAM,CAACJ,oBAAoBK,MAAM,CAAC;IAClE,MAAMC,WAAW,GAAGH,KAAKI,KAAK,CAAC,GAAG,KAAKR,gBAAgB;IAEvD,yHAAyH;IACzH,MAAMpB,UAAUC,KAAKiB,MAAMS,WAAWN;IAEtC,OAAOM;AACT"}
@@ -1,91 +0,0 @@
1
- import { styleText } from 'node:util';
2
- import { ux } from '@oclif/core/ux';
3
- import { doImport, getLocalPackageVersion, getProjectCliClient, resolveLocalPackage, subdebug } from '@sanity/cli-core';
4
- import { spinner } from '@sanity/cli-core/ux';
5
- import { SCHEMA_API_VERSION } from '../../services/schemas.js';
6
- const iconResolverPath = new URL('../manifest/iconResolver.js', import.meta.url).href;
7
- const debug = subdebug('uploadSchemaToLexicon');
8
- /**
9
- * Uploads the schemas to Lexicon and returns the studio manifest
10
- * @param options - The options for the uploadSchemaToLexicon function
11
- * @returns The studio manifest
12
- */ export async function uploadSchemaToLexicon(options) {
13
- const { projectId, verbose, workDir, workspaces } = options;
14
- const spin = spinner('Generating studio manifest').start();
15
- try {
16
- const schemaDescriptors = new Map();
17
- const client = await getProjectCliClient({
18
- apiVersion: SCHEMA_API_VERSION,
19
- projectId,
20
- requestTagPrefix: 'sanity.cli.deploy',
21
- requireUser: true
22
- });
23
- const [bundleVersion, { generateStudioManifest, uploadSchema }] = await Promise.all([
24
- getLocalPackageVersion('sanity', workDir),
25
- resolveLocalPackage('sanity', workDir)
26
- ]);
27
- if (!bundleVersion) {
28
- throw new Error('Failed to find sanity version');
29
- }
30
- for (const workspace of workspaces){
31
- const workspaceClient = client.withConfig({
32
- dataset: workspace.dataset,
33
- projectId: workspace.projectId
34
- });
35
- try {
36
- debug('Uploading schema to lexicon for workspace %o', {
37
- dataset: workspace.dataset,
38
- projectId: workspace.projectId
39
- });
40
- // The local `sanity` package types its client against its own
41
- // @sanity/client major; the runtime surface uploadSchema uses is
42
- // compatible across v7/v8.
43
- const descriptorId = await uploadSchema(workspace.schema, workspaceClient);
44
- if (!descriptorId) {
45
- throw new Error(`Failed to get schema descriptor ID for workspace "${workspace.name}": upload returned empty result`);
46
- }
47
- schemaDescriptors.set(workspace.name, descriptorId);
48
- debug(`Uploaded schema for workspace "${workspace.name}" to Lexicon with descriptor ID: ${descriptorId}`);
49
- } catch (error) {
50
- debug('Error uploading schema to lexicon for workspace %o', error);
51
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
52
- throw new Error(`Failed to upload schema for workspace "${workspace.name}": ${errorMessage}`, {
53
- cause: error
54
- });
55
- }
56
- }
57
- // Lazy import to avoid pulling in @sanity/ui at module load time
58
- const { resolveIcon } = await doImport(iconResolverPath);
59
- // Generate studio manifest using the shared utility
60
- const manifest = await generateStudioManifest({
61
- buildId: JSON.stringify(Date.now()),
62
- bundleVersion,
63
- // @todo replace with import from @sanity/schema/_internal in future
64
- resolveIcon: async (workspace)=>await resolveIcon({
65
- icon: workspace.icon,
66
- subtitle: workspace.subtitle,
67
- title: workspace.title || workspace.name || 'default',
68
- workDir
69
- }) ?? undefined,
70
- resolveSchemaDescriptorId: (workspace)=>schemaDescriptors.get(workspace.name),
71
- workspaces
72
- });
73
- spin.succeed('Generated studio manifest');
74
- const studioManifest = manifest.workspaces.length === 0 ? null : manifest;
75
- if (verbose) {
76
- if (studioManifest) {
77
- for (const workspace of studioManifest.workspaces){
78
- ux.stdout(styleText('gray', `↳ projectId: ${workspace.projectId}, dataset: ${workspace.dataset}, schemaDescriptorId: ${workspace.schemaDescriptorId}`));
79
- }
80
- } else {
81
- ux.stdout(`${styleText('gray', '↳ No workspaces found')}`);
82
- }
83
- }
84
- return studioManifest;
85
- } catch (error) {
86
- spin.fail(error instanceof Error ? error.message : 'Unknown error');
87
- throw error;
88
- }
89
- }
90
-
91
- //# sourceMappingURL=uploadSchemaToLexicon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/schema/uploadSchemaToLexicon.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {ux} from '@oclif/core/ux'\nimport {\n doImport,\n getLocalPackageVersion,\n getProjectCliClient,\n resolveLocalPackage,\n subdebug,\n} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type StudioManifest, type Workspace} from 'sanity'\n\nimport {SCHEMA_API_VERSION} from '../../services/schemas.js'\n\nconst iconResolverPath = new URL('../manifest/iconResolver.js', import.meta.url).href\n\ninterface UploadSchemaToLexiconOptions {\n projectId: string\n workDir: string\n workspaces: Workspace[]\n\n verbose?: boolean\n}\n\nconst debug = subdebug('uploadSchemaToLexicon')\n\n/**\n * Uploads the schemas to Lexicon and returns the studio manifest\n * @param options - The options for the uploadSchemaToLexicon function\n * @returns The studio manifest\n */\nexport async function uploadSchemaToLexicon(\n options: UploadSchemaToLexiconOptions,\n): Promise<StudioManifest | null> {\n const {projectId, verbose, workDir, workspaces} = options\n const spin = spinner('Generating studio manifest').start()\n\n try {\n const schemaDescriptors = new Map<string, string>()\n\n const client = await getProjectCliClient({\n apiVersion: SCHEMA_API_VERSION,\n projectId,\n requestTagPrefix: 'sanity.cli.deploy',\n requireUser: true,\n })\n\n const [bundleVersion, {generateStudioManifest, uploadSchema}] = await Promise.all([\n getLocalPackageVersion('sanity', workDir),\n resolveLocalPackage<typeof import('sanity')>('sanity', workDir),\n ])\n\n if (!bundleVersion) {\n throw new Error('Failed to find sanity version')\n }\n\n for (const workspace of workspaces) {\n const workspaceClient = client.withConfig({\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n\n try {\n debug('Uploading schema to lexicon for workspace %o', {\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n // The local `sanity` package types its client against its own\n // @sanity/client major; the runtime surface uploadSchema uses is\n // compatible across v7/v8.\n const descriptorId = await uploadSchema(\n workspace.schema,\n workspaceClient as unknown as Parameters<typeof uploadSchema>[1],\n )\n\n if (!descriptorId) {\n throw new Error(\n `Failed to get schema descriptor ID for workspace \"${workspace.name}\": upload returned empty result`,\n )\n }\n\n schemaDescriptors.set(workspace.name, descriptorId)\n debug(\n `Uploaded schema for workspace \"${workspace.name}\" to Lexicon with descriptor ID: ${descriptorId}`,\n )\n } catch (error) {\n debug('Error uploading schema to lexicon for workspace %o', error)\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n throw new Error(\n `Failed to upload schema for workspace \"${workspace.name}\": ${errorMessage}`,\n {cause: error},\n )\n }\n }\n\n // Lazy import to avoid pulling in @sanity/ui at module load time\n const {resolveIcon} = await doImport(iconResolverPath)\n\n // Generate studio manifest using the shared utility\n const manifest = await generateStudioManifest({\n buildId: JSON.stringify(Date.now()),\n bundleVersion,\n // @todo replace with import from @sanity/schema/_internal in future\n resolveIcon: async (workspace) =>\n (await resolveIcon({\n icon: workspace.icon,\n subtitle: workspace.subtitle,\n title: workspace.title || workspace.name || 'default',\n workDir,\n })) ?? undefined,\n resolveSchemaDescriptorId: (workspace) => schemaDescriptors.get(workspace.name),\n workspaces,\n })\n\n spin.succeed('Generated studio manifest')\n\n const studioManifest = manifest.workspaces.length === 0 ? null : manifest\n\n if (verbose) {\n if (studioManifest) {\n for (const workspace of studioManifest.workspaces) {\n ux.stdout(\n styleText(\n 'gray',\n `↳ projectId: ${workspace.projectId}, dataset: ${workspace.dataset}, schemaDescriptorId: ${workspace.schemaDescriptorId}`,\n ),\n )\n }\n } else {\n ux.stdout(`${styleText('gray', '↳ No workspaces found')}`)\n }\n }\n\n return studioManifest\n } catch (error) {\n spin.fail(error instanceof Error ? error.message : 'Unknown error')\n throw error\n }\n}\n"],"names":["styleText","ux","doImport","getLocalPackageVersion","getProjectCliClient","resolveLocalPackage","subdebug","spinner","SCHEMA_API_VERSION","iconResolverPath","URL","url","href","debug","uploadSchemaToLexicon","options","projectId","verbose","workDir","workspaces","spin","start","schemaDescriptors","Map","client","apiVersion","requestTagPrefix","requireUser","bundleVersion","generateStudioManifest","uploadSchema","Promise","all","Error","workspace","workspaceClient","withConfig","dataset","descriptorId","schema","name","set","error","errorMessage","message","cause","resolveIcon","manifest","buildId","JSON","stringify","Date","now","icon","subtitle","title","undefined","resolveSchemaDescriptorId","get","succeed","studioManifest","length","stdout","schemaDescriptorId","fail"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,EAAE,QAAO,iBAAgB;AACjC,SACEC,QAAQ,EACRC,sBAAsB,EACtBC,mBAAmB,EACnBC,mBAAmB,EACnBC,QAAQ,QACH,mBAAkB;AACzB,SAAQC,OAAO,QAAO,sBAAqB;AAG3C,SAAQC,kBAAkB,QAAO,4BAA2B;AAE5D,MAAMC,mBAAmB,IAAIC,IAAI,+BAA+B,YAAYC,GAAG,EAAEC,IAAI;AAUrF,MAAMC,QAAQP,SAAS;AAEvB;;;;CAIC,GACD,OAAO,eAAeQ,sBACpBC,OAAqC;IAErC,MAAM,EAACC,SAAS,EAAEC,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAC,GAAGJ;IAClD,MAA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