@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.
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 +6 -4
  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 +353 -353
  81. package/package.json +7 -10
  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,169 +0,0 @@
1
- import { transformBlockType } from './blockTypeTransformer.js';
2
- import { transformCrossDatasetReference, transformGlobalDocumentReference, transformReference } from './referenceTransformer.js';
3
- import { getCustomFields, getDefinedTypeName, isCrossDatasetReference, isCustomized, isDefined, isGlobalDocumentReference, isPrimitive, isRecord, isReference } from './schemaTypeHelpers.js';
4
- import { ensureConditional, ensureCustomTitle, ensureString } from './transformerUtils.js';
5
- import { transformValidation } from './validationTransformer.js';
6
- const MAX_CUSTOM_PROPERTY_DEPTH = 5;
7
- /**
8
- * Transforms a SchemaType to its manifest representation
9
- */ export function transformType(type, context) {
10
- const typeName = type.type ? type.type.name : type.jsonType;
11
- return {
12
- ...transformCommonTypeFields(type, typeName, context),
13
- name: type.name,
14
- type: typeName,
15
- ...ensureCustomTitle(type.name, type.title)
16
- };
17
- }
18
- /**
19
- * Transforms common fields shared across all schema types
20
- */ function transformCommonTypeFields(type, typeName, context) {
21
- const arrayProps = typeName === 'array' && type.jsonType === 'array' ? transformArrayMember(type, context) : {};
22
- const referenceProps = isReference(type) ? transformReference(type, retainCustomTypeProps) : {};
23
- const crossDatasetRefProps = isCrossDatasetReference(type) ? transformCrossDatasetReference(type) : {};
24
- const globalRefProps = isGlobalDocumentReference(type) ? transformGlobalDocumentReference(type) : {};
25
- const objectFields = type.jsonType === 'object' && type.type && isCustomized(type) ? {
26
- fields: getCustomFields(type).map((objectField)=>transformField(objectField, context))
27
- } : {};
28
- return {
29
- ...retainCustomTypeProps(type),
30
- ...transformValidation(type.validation, retainSerializableProps),
31
- ...ensureString('description', type.description),
32
- ...objectFields,
33
- ...arrayProps,
34
- ...referenceProps,
35
- ...crossDatasetRefProps,
36
- ...globalRefProps,
37
- ...ensureConditional('readOnly', type.readOnly),
38
- ...ensureConditional('hidden', type.hidden),
39
- ...transformFieldsets(type),
40
- // fieldset prop gets instrumented via getCustomFields
41
- ...ensureString('fieldset', type.fieldset),
42
- ...transformBlockType(type, context, transformType)
43
- };
44
- }
45
- /**
46
- * Transforms fieldsets from a schema type
47
- */ function transformFieldsets(type) {
48
- if (type.jsonType !== 'object') {
49
- return {};
50
- }
51
- const fieldsets = type.fieldsets?.filter((fs)=>!fs.single).map((fs)=>{
52
- const options = isRecord(fs.options) ? {
53
- options: retainSerializableProps(fs.options)
54
- } : {};
55
- return {
56
- name: fs.name,
57
- ...ensureCustomTitle(fs.name, fs.title),
58
- ...ensureString('description', fs.description),
59
- ...ensureConditional('readOnly', fs.readOnly),
60
- ...ensureConditional('hidden', fs.hidden),
61
- ...options
62
- };
63
- });
64
- return fieldsets?.length ? {
65
- fieldsets
66
- } : {};
67
- }
68
- /**
69
- * Retains custom type properties that should be included in the manifest
70
- */ function retainCustomTypeProps(type) {
71
- const manuallySerializedFields = new Set([
72
- '__experimental_actions',
73
- '__experimental_formPreviewTitle',
74
- '__experimental_omnisearch_visibility',
75
- '__experimental_search',
76
- 'components',
77
- 'description',
78
- 'fields',
79
- 'fieldsets',
80
- //only exists on fields
81
- 'group',
82
- 'groups',
83
- 'hidden',
84
- 'icon',
85
- 'jsonType',
86
- //explicitly added
87
- 'name',
88
- 'of',
89
- 'orderings',
90
- 'preview',
91
- 'readOnly',
92
- 'title',
93
- 'to',
94
- // not serialized
95
- 'type',
96
- 'validation'
97
- ]);
98
- const typeWithoutManuallyHandledFields = Object.fromEntries(Object.entries(type).filter(([key])=>!manuallySerializedFields.has(key)));
99
- return retainSerializableProps(typeWithoutManuallyHandledFields);
100
- }
101
- /**
102
- * Retains serializable properties from an unknown value, recursively processing objects and arrays
103
- * @internal Exported for testing purposes only
104
- */ export function retainSerializableProps(maybeSerializable, depth = 0) {
105
- if (depth > MAX_CUSTOM_PROPERTY_DEPTH) {
106
- return undefined;
107
- }
108
- if (!isDefined(maybeSerializable)) {
109
- return undefined;
110
- }
111
- if (isPrimitive(maybeSerializable)) {
112
- // cull empty strings
113
- if (maybeSerializable === '') {
114
- return undefined;
115
- }
116
- return maybeSerializable;
117
- }
118
- // url-schemes ect..
119
- if (maybeSerializable instanceof RegExp) {
120
- return maybeSerializable.toString();
121
- }
122
- if (Array.isArray(maybeSerializable)) {
123
- const arrayItems = maybeSerializable.map((item)=>retainSerializableProps(item, depth + 1)).filter((item)=>isDefined(item));
124
- return arrayItems.length > 0 ? arrayItems : undefined;
125
- }
126
- if (isRecord(maybeSerializable)) {
127
- const serializableEntries = Object.entries(maybeSerializable).map(([key, value])=>{
128
- return [
129
- key,
130
- retainSerializableProps(value, depth + 1)
131
- ];
132
- }).filter(([, value])=>isDefined(value));
133
- return serializableEntries.length > 0 ? Object.fromEntries(serializableEntries) : undefined;
134
- }
135
- return undefined;
136
- }
137
- /**
138
- * Transforms an ObjectField to its manifest representation
139
- */ function transformField(field, context) {
140
- const fieldType = field.type;
141
- const typeName = getDefinedTypeName(fieldType) ?? fieldType.name;
142
- return {
143
- ...transformCommonTypeFields(fieldType, typeName, context),
144
- name: field.name,
145
- type: typeName,
146
- ...ensureCustomTitle(field.name, fieldType.title),
147
- // this prop gets added synthetically via getCustomFields
148
- ...ensureString('fieldset', field.fieldset)
149
- };
150
- }
151
- /**
152
- * Transforms array member types to their manifest representation
153
- */ function transformArrayMember(arrayMember, context) {
154
- return {
155
- of: arrayMember.of.map((type)=>{
156
- const typeName = getDefinedTypeName(type) ?? type.name;
157
- return {
158
- ...transformCommonTypeFields(type, typeName, context),
159
- type: typeName,
160
- ...typeName === type.name ? {} : {
161
- name: type.name
162
- },
163
- ...ensureCustomTitle(type.name, type.title)
164
- };
165
- })
166
- };
167
- }
168
-
169
- //# sourceMappingURL=schemaTypeTransformer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/schemaTypeTransformer.ts"],"sourcesContent":["import {\n type ArraySchemaType,\n type BlockDefinition,\n type BooleanSchemaType,\n type FileSchemaType,\n type MultiFieldSet,\n type NumberSchemaType,\n type ObjectField,\n type ObjectSchemaType,\n type ReferenceSchemaType,\n type SchemaType,\n type StringSchemaType,\n} from '@sanity/types'\n\nimport {transformBlockType} from './blockTypeTransformer.js'\nimport {\n transformCrossDatasetReference,\n transformGlobalDocumentReference,\n transformReference,\n} from './referenceTransformer.js'\nimport {\n getCustomFields,\n getDefinedTypeName,\n isCrossDatasetReference,\n isCustomized,\n isDefined,\n isGlobalDocumentReference,\n isPrimitive,\n isRecord,\n isReference,\n} from './schemaTypeHelpers.js'\nimport {\n type Context,\n ensureConditional,\n ensureCustomTitle,\n ensureString,\n type SerializableProp,\n} from './transformerUtils.js'\nimport {\n type ManifestField,\n type ManifestFieldset,\n type ManifestSchemaType,\n type ManifestSerializable,\n} from './types.js'\nimport {transformValidation} from './validationTransformer.js'\n\ntype SchemaTypeKey =\n | 'group' // we strip this from fields\n | keyof ArraySchemaType\n | keyof BlockDefinition\n | keyof BooleanSchemaType\n | keyof FileSchemaType\n | keyof NumberSchemaType\n | keyof ObjectSchemaType\n | keyof ReferenceSchemaType\n | keyof StringSchemaType\n\ntype ObjectFields = Record<string, never> | {fields: ManifestField[]}\n\nconst MAX_CUSTOM_PROPERTY_DEPTH = 5\n\n/**\n * Transforms a SchemaType to its manifest representation\n */\nexport function transformType(type: SchemaType, context: Context): ManifestSchemaType {\n const typeName = type.type ? type.type.name : type.jsonType\n\n return {\n ...transformCommonTypeFields(type, typeName, context),\n name: type.name,\n type: typeName,\n ...ensureCustomTitle(type.name, type.title),\n }\n}\n\n/**\n * Transforms common fields shared across all schema types\n */\nfunction transformCommonTypeFields(\n type: SchemaType & {fieldset?: string},\n typeName: string,\n context: Context,\n): Omit<ManifestSchemaType, 'name' | 'title' | 'type'> {\n const arrayProps =\n typeName === 'array' && type.jsonType === 'array' ? transformArrayMember(type, context) : {}\n\n const referenceProps = isReference(type) ? transformReference(type, retainCustomTypeProps) : {}\n const crossDatasetRefProps = isCrossDatasetReference(type)\n ? transformCrossDatasetReference(type)\n : {}\n const globalRefProps = isGlobalDocumentReference(type)\n ? transformGlobalDocumentReference(type)\n : {}\n\n const objectFields: ObjectFields =\n type.jsonType === 'object' && type.type && isCustomized(type)\n ? {\n fields: getCustomFields(type).map((objectField) => transformField(objectField, context)),\n }\n : {}\n\n return {\n ...retainCustomTypeProps(type),\n ...transformValidation(type.validation, retainSerializableProps),\n ...ensureString('description', type.description),\n ...objectFields,\n ...arrayProps,\n ...referenceProps,\n ...crossDatasetRefProps,\n ...globalRefProps,\n ...ensureConditional('readOnly', type.readOnly),\n ...ensureConditional('hidden', type.hidden),\n ...transformFieldsets(type),\n // fieldset prop gets instrumented via getCustomFields\n ...ensureString('fieldset', type.fieldset),\n ...transformBlockType(type, context, transformType),\n }\n}\n\n/**\n * Transforms fieldsets from a schema type\n */\nfunction transformFieldsets(\n type: SchemaType,\n): Record<string, never> | {fieldsets: ManifestFieldset[]} {\n if (type.jsonType !== 'object') {\n return {}\n }\n const fieldsets = type.fieldsets\n ?.filter((fs): fs is MultiFieldSet => !fs.single)\n .map((fs) => {\n const options = isRecord(fs.options) ? {options: retainSerializableProps(fs.options)} : {}\n return {\n name: fs.name,\n ...ensureCustomTitle(fs.name, fs.title),\n ...ensureString('description', fs.description),\n ...ensureConditional('readOnly', fs.readOnly),\n ...ensureConditional('hidden', fs.hidden),\n ...options,\n }\n })\n\n return fieldsets?.length ? {fieldsets} : {}\n}\n\n/**\n * Retains custom type properties that should be included in the manifest\n */\nfunction retainCustomTypeProps(type: SchemaType): Record<string, SerializableProp> {\n const manuallySerializedFields = new Set<SchemaTypeKey>([\n '__experimental_actions',\n '__experimental_formPreviewTitle',\n '__experimental_omnisearch_visibility',\n '__experimental_search',\n 'components',\n 'description',\n 'fields',\n 'fieldsets',\n //only exists on fields\n 'group',\n 'groups',\n 'hidden',\n 'icon',\n 'jsonType',\n //explicitly added\n 'name',\n 'of',\n 'orderings',\n 'preview',\n 'readOnly',\n 'title',\n 'to',\n // not serialized\n 'type',\n 'validation',\n // we know about these, but let them be generically handled\n // deprecated\n // rows (from text)\n // initialValue\n // options\n // crossDatasetReference props\n ])\n const typeWithoutManuallyHandledFields = Object.fromEntries(\n Object.entries(type).filter(\n ([key]) => !manuallySerializedFields.has(key as unknown as SchemaTypeKey),\n ),\n )\n return retainSerializableProps(typeWithoutManuallyHandledFields) as Record<\n string,\n SerializableProp\n >\n}\n\n/**\n * Retains serializable properties from an unknown value, recursively processing objects and arrays\n * @internal Exported for testing purposes only\n */\nexport function retainSerializableProps(maybeSerializable: unknown, depth = 0): SerializableProp {\n if (depth > MAX_CUSTOM_PROPERTY_DEPTH) {\n return undefined\n }\n\n if (!isDefined(maybeSerializable)) {\n return undefined\n }\n\n if (isPrimitive(maybeSerializable)) {\n // cull empty strings\n if (maybeSerializable === '') {\n return undefined\n }\n return maybeSerializable\n }\n\n // url-schemes ect..\n if (maybeSerializable instanceof RegExp) {\n return maybeSerializable.toString()\n }\n\n if (Array.isArray(maybeSerializable)) {\n const arrayItems = maybeSerializable\n .map((item) => retainSerializableProps(item, depth + 1))\n .filter((item): item is ManifestSerializable => isDefined(item))\n return arrayItems.length > 0 ? arrayItems : undefined\n }\n\n if (isRecord(maybeSerializable)) {\n const serializableEntries = Object.entries(maybeSerializable)\n .map(([key, value]) => {\n return [key, retainSerializableProps(value, depth + 1)]\n })\n .filter(([, value]) => isDefined(value))\n return serializableEntries.length > 0 ? Object.fromEntries(serializableEntries) : undefined\n }\n\n return undefined\n}\n\n/**\n * Transforms an ObjectField to its manifest representation\n */\nfunction transformField(field: ObjectField & {fieldset?: string}, context: Context): ManifestField {\n const fieldType = field.type\n const typeName = getDefinedTypeName(fieldType) ?? fieldType.name\n return {\n ...transformCommonTypeFields(fieldType, typeName, context),\n name: field.name,\n type: typeName,\n ...ensureCustomTitle(field.name, fieldType.title),\n // this prop gets added synthetically via getCustomFields\n ...ensureString('fieldset', field.fieldset),\n }\n}\n\n/**\n * Transforms array member types to their manifest representation\n */\nfunction transformArrayMember(\n arrayMember: ArraySchemaType,\n context: Context,\n): Pick<ManifestField, 'of'> {\n return {\n of: arrayMember.of.map((type) => {\n const typeName = getDefinedTypeName(type) ?? type.name\n return {\n ...transformCommonTypeFields(type, typeName, context),\n type: typeName,\n ...(typeName === type.name ? {} : {name: type.name}),\n ...ensureCustomTitle(type.name, type.title),\n }\n }),\n }\n}\n"],"names":["transformBlockType","transformCrossDatasetReference","transformGlobalDocumentReference","transformReference","getCustomFields","getDefinedTypeName","isCrossDatasetReference","isCustomized","isDefined","isGlobalDocumentReference","isPrimitive","isRecord","isReference","ensureConditional","ensureCustomTitle","ensureString","transformValidation","MAX_CUSTOM_PROPERTY_DEPTH","transformType","type","context","typeName","name","jsonType","transformCommonTypeFields","title","arrayProps","transformArrayMember","referenceProps","retainCustomTypeProps","crossDatasetRefProps","globalRefProps","objectFields","fields","map","objectField","transformField","validation","retainSerializableProps","description","readOnly","hidden","transformFieldsets","fieldset","fieldsets","filter","fs","single","options","length","manuallySerializedFields","Set","typeWithoutManuallyHandledFields","Object","fromEntries","entries","key","has","maybeSerializable","depth","undefined","RegExp","toString","Array","isArray","arrayItems","item","serializableEntries","value","field","fieldType","arrayMember","of"],"mappings":"AAcA,SAAQA,kBAAkB,QAAO,4BAA2B;AAC5D,SACEC,8BAA8B,EAC9BC,gCAAgC,EAChCC,kBAAkB,QACb,4BAA2B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lD,IAAI;IAC5B,MAAME,WAAWhB,mBAAmBiE,cAAcA,UAAUhD,IAAI;IAChE,OAAO;QACL,GAAGE,0BAA0B8C,WAAWjD,UAAUD,QAAQ;QAC1DE,MAAM+C,MAAM/C,IAAI;QAChBH,MAAME;QACN,GAAGP,kBAAkBuD,MAAM/C,IAAI,EAAEgD,UAAU7C,KAAK,CAAC;QACjD,yDAAyD;QACzD,GAAGV,aAAa,YAAYsD,MAAM1B,QAAQ,CAAC;IAC7C;AACF;AAEA;;CAEC,GACD,SAAShB,qBACP4C,WAA4B,EAC5BnD,OAAgB;IAEhB,OAAO;QACLoD,IAAID,YAAYC,EAAE,CAACtC,GAAG,CAAC,CAACf;YACtB,MAAME,WAAWhB,mBAAmBc,SAASA,KAAKG,IAAI;YACtD,OAAO;gBACL,GAAGE,0BAA0BL,MAAME,UAAUD,QAAQ;gBACrDD,MAAME;gBACN,GAAIA,aAAaF,KAAKG,IAAI,GAAG,CAAC,IAAI;oBAACA,MAAMH,KAAKG,IAAI;gBAAA,CAAC;gBACnD,GAAGR,kBAAkBK,KAAKG,IAAI,EAAEH,KAAKM,KAAK,CAAC;YAC7C;QACF;IACF;AACF"}
@@ -1,40 +0,0 @@
1
- import startCase from 'lodash-es/startCase.js';
2
- /**
3
- * Ensures a string value is returned for the given key, or an empty object if not a string
4
- */ export function ensureString(key, value) {
5
- if (typeof value === 'string') {
6
- return {
7
- [key]: value
8
- };
9
- }
10
- return {};
11
- }
12
- /**
13
- * Ensures a conditional value is returned for the given key.
14
- * Returns the boolean value if it's a boolean, 'conditional' if it's a function, or empty object otherwise.
15
- */ export function ensureConditional(key, value) {
16
- if (typeof value === 'boolean') {
17
- return {
18
- [key]: value
19
- };
20
- }
21
- if (typeof value === 'function') {
22
- return {
23
- [key]: 'conditional'
24
- };
25
- }
26
- return {};
27
- }
28
- /**
29
- * Ensures a custom title is returned, omitting it if it matches the default startCase title
30
- */ export function ensureCustomTitle(typeName, value) {
31
- const titleObject = ensureString('title', value);
32
- const defaultTitle = startCase(typeName);
33
- // omit title if its the same as default, to reduce payload
34
- if (titleObject.title === defaultTitle) {
35
- return {};
36
- }
37
- return titleObject;
38
- }
39
-
40
- //# sourceMappingURL=transformerUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/transformerUtils.ts"],"sourcesContent":["import {type Schema} from '@sanity/types'\nimport startCase from 'lodash-es/startCase.js'\n\nimport {type ManifestSerializable} from './types.js'\n\n/**\n * Context object passed to transformer functions\n */\nexport interface Context {\n schema: Schema\n}\n\n/**\n * Type for serializable properties that can be stored in the manifest\n */\nexport type SerializableProp = ManifestSerializable | ManifestSerializable[] | undefined\n\n/**\n * Ensures a string value is returned for the given key, or an empty object if not a string\n */\nexport function ensureString<Key extends string>(key: Key, value: unknown) {\n if (typeof value === 'string') {\n return {\n [key]: value,\n }\n }\n\n return {}\n}\n\n/**\n * Ensures a conditional value is returned for the given key.\n * Returns the boolean value if it's a boolean, 'conditional' if it's a function, or empty object otherwise.\n */\nexport function ensureConditional<const Key extends string>(key: Key, value: unknown) {\n if (typeof value === 'boolean') {\n return {\n [key]: value,\n }\n }\n\n if (typeof value === 'function') {\n return {\n [key]: 'conditional',\n }\n }\n\n return {}\n}\n\n/**\n * Ensures a custom title is returned, omitting it if it matches the default startCase title\n */\nexport function ensureCustomTitle(typeName: string, value: unknown) {\n const titleObject = ensureString('title', value)\n\n const defaultTitle = startCase(typeName)\n // omit title if its the same as default, to reduce payload\n if (titleObject.title === defaultTitle) {\n return {}\n }\n return titleObject\n}\n"],"names":["startCase","ensureString","key","value","ensureConditional","ensureCustomTitle","typeName","titleObject","defaultTitle","title"],"mappings":"AACA,OAAOA,eAAe,yBAAwB;AAgB9C;;CAEC,GACD,OAAO,SAASC,aAAiCC,GAAQ,EAAEC,KAAc;IACvE,IAAI,OAAOA,UAAU,UAAU;QAC7B,OAAO;YACL,CAACD,IAAI,EAAEC;QACT;IACF;IAEA,OAAO,CAAC;AACV;AAEA;;;CAGC,GACD,OAAO,SAASC,kBAA4CF,GAAQ,EAAEC,KAAc;IAClF,IAAI,OAAOA,UAAU,WAAW;QAC9B,OAAO;YACL,CAACD,IAAI,EAAEC;QACT;IACF;IAEA,IAAI,OAAOA,UAAU,YAAY;QAC/B,OAAO;YACL,CAACD,IAAI,EAAE;QACT;IACF;IAEA,OAAO,CAAC;AACV;AAEA;;CAEC,GACD,OAAO,SAASG,kBAAkBC,QAAgB,EAAEH,KAAc;IAChE,MAAMI,cAAcN,aAAa,SAASE;IAE1C,MAAMK,eAAeR,UAAUM;IAC/B,2DAA2D;IAC3D,IAAIC,YAAYE,KAAK,KAAKD,cAAc;QACtC,OAAO,CAAC;IACV;IACA,OAAOD;AACT"}
@@ -1,13 +0,0 @@
1
- import { z } from 'zod/mini';
2
- export const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas';
3
- export const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01';
4
- // The studio/app manifest contract lives in `@sanity/cli-core` so the CLI and
5
- // the workbench dev-server registry validate against the same schemas without
6
- // depending on each other.
7
- export { coreAppManifestSchema } from '@sanity/cli-core';
8
- export const extractManifestWorkerData = z.object({
9
- configPath: z.string(),
10
- workDir: z.string()
11
- });
12
-
13
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/manifest/types.ts"],"sourcesContent":["import {type SanityDocumentLike} from '@sanity/types'\nimport {type MediaLibraryConfig} from 'sanity'\nimport {z} from 'zod/mini'\n\nexport const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = '_.schemas'\nexport const CURRENT_WORKSPACE_SCHEMA_VERSION = '2025-05-01'\n\nexport type ManifestSerializable =\n | boolean\n | ManifestSerializable[]\n | number\n | string\n | {[k: string]: ManifestSerializable}\n\nexport interface CreateManifest {\n createdAt: string\n studioVersion: string | null\n version: number\n workspaces: ManifestWorkspaceFile[]\n}\n\n// The studio/app manifest contract lives in `@sanity/cli-core` so the CLI and\n// the workbench dev-server registry validate against the same schemas without\n// depending on each other.\nexport {type CoreAppManifest, coreAppManifestSchema, type StudioManifest} from '@sanity/cli-core'\n\nexport interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {\n schema: string // filename\n tools: string // filename\n}\n\nexport interface CreateWorkspaceManifest {\n basePath: string\n dataset: string\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n projectId: string\n schema: ManifestSchemaType[]\n tools: ManifestTool[]\n\n mediaLibrary?: MediaLibraryConfig\n subtitle?: string\n title?: string\n}\n\nexport interface ManifestSchemaType {\n name: string\n type: string\n\n deprecated?: {\n reason: string\n }\n fields?: ManifestField[]\n fieldsets?: ManifestFieldset[]\n hidden?: 'conditional' | boolean\n lists?: ManifestTitledValue[]\n //portable text\n marks?: {\n annotations?: ManifestArrayMember[]\n decorators?: ManifestTitledValue[]\n }\n of?: ManifestArrayMember[]\n options?: Record<string, ManifestSerializable>\n preview?: {\n select: Record<string, string>\n }\n readOnly?: 'conditional' | boolean\n styles?: ManifestTitledValue[]\n title?: string\n to?: ManifestReferenceMember[]\n validation?: ManifestValidationGroup[]\n\n // userland (assignable to ManifestSerializable | undefined)\n // not included to add some typesafty to extractManifest\n // [index: string]: unknown\n}\n\nexport interface ManifestFieldset {\n [index: string]: ManifestSerializable | undefined\n name: string\n\n title?: string\n}\n\nexport interface ManifestTitledValue {\n value: string\n\n title?: string\n}\n\ntype ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\ntype ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {name?: string}\nexport type ManifestField = ManifestSchemaType & {fieldset?: string}\n\nexport interface ManifestValidationGroup {\n rules: ManifestValidationRule[]\n\n level?: 'error' | 'info' | 'warning'\n message?: string\n}\n\nexport type ManifestValidationRule = {\n [index: string]: ManifestSerializable | undefined\n constraint?: ManifestSerializable\n flag: string\n}\n\nexport interface ManifestTool {\n /**\n * returns null in the case of the icon not being able to be stringified\n */\n icon: string | null\n name: string\n title: string\n type: string | null\n}\n\nexport type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`\ntype PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`\nexport type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId\n\nexport interface StoredWorkspaceSchema extends SanityDocumentLike {\n _id: WorkspaceSchemaId\n _type: 'system.schema'\n /**\n * The API expects JSON coming in, but will store a string to save on attribute paths.\n * Consumers must use JSON.parse on the value, but we deploy to the API using ManifestSchemaType[]\n */\n schema: ManifestSchemaType[] | string\n /* api-like version string: date at which the format had a meaningful change */\n version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined\n workspace: {\n name: string\n title?: string\n }\n\n tag?: string\n}\n\nexport const extractManifestWorkerData = z.object({configPath: z.string(), workDir: z.string()})\n\nexport type ExtractManifestWorkerData = z.infer<typeof extractManifestWorkerData>\n"],"names":["z","SANITY_WORKSPACE_SCHEMA_ID_PREFIX","CURRENT_WORKSPACE_SCHEMA_VERSION","coreAppManifestSchema","extractManifestWorkerData","object","configPath","string","workDir"],"mappings":"AAEA,SAAQA,CAAC,QAAO,WAAU;AAE1B,OAAO,MAAMC,oCAAoC,YAAW;AAC5D,OAAO,MAAMC,mCAAmC,aAAY;AAgB5D,8EAA8E;AAC9E,8EAA8E;AAC9E,2BAA2B;AAC3B,SAA8BC,qBAAqB,QAA4B,mBAAkB;AAsHjG,OAAO,MAAMC,4BAA4BJ,EAAEK,MAAM,CAAC;IAACC,YAAYN,EAAEO,MAAM;IAAIC,SAASR,EAAEO,MAAM;AAAE,GAAE"}
@@ -1,84 +0,0 @@
1
- const transformTypeValidationRule = (rule)=>{
2
- return {
3
- ...rule,
4
- constraint: 'constraint' in rule && (typeof rule.constraint === 'string' ? rule.constraint.toLowerCase() : retainSerializablePropsForValidation(rule.constraint))
5
- };
6
- };
7
- const validationRuleTransformers = {
8
- type: transformTypeValidationRule
9
- };
10
- /**
11
- * Transforms schema validation rules to their manifest representation
12
- */ export function transformValidation(validation, retainSerializableProps) {
13
- const validationArray = (Array.isArray(validation) ? validation : [
14
- validation
15
- ]).filter((value)=>typeof value === 'object' && '_type' in value);
16
- // we don't want type in the output as that is implicitly given by the typedef itself an will only bloat the payload
17
- const disallowedFlags = new Set([
18
- 'type'
19
- ]);
20
- const serializedValidation = validationArray.map(({ _level, _message, _rules })=>{
21
- const message = typeof _message === 'string' ? {
22
- message: _message
23
- } : {};
24
- const serializedRules = _rules.filter((rule)=>{
25
- if (!('constraint' in rule)) {
26
- return false;
27
- }
28
- const { constraint, flag } = rule;
29
- if (disallowedFlags.has(flag)) {
30
- return false;
31
- }
32
- // Validation rules that refer to other fields use symbols, which cannot be serialized. It would
33
- // be possible to transform these to a serializable type, but we haven't implemented that for now.
34
- const isFieldReference = typeof constraint === 'object' && 'type' in constraint && typeof constraint.type === 'symbol' && (constraint.type.description === 'FIELD_REF' || constraint.type.description === '@sanity/schema/field-ref');
35
- return !isFieldReference;
36
- }).map((rule)=>{
37
- const transformer = validationRuleTransformers[rule.flag] ?? ((spec)=>retainSerializableProps(spec));
38
- const transformedRule = transformer(rule);
39
- if (!transformedRule) {
40
- return;
41
- }
42
- return transformedRule;
43
- }).filter((rule)=>rule !== undefined);
44
- return {
45
- level: _level,
46
- rules: serializedRules,
47
- ...message
48
- };
49
- }).filter((group)=>group.rules.length > 0);
50
- return serializedValidation.length > 0 ? {
51
- validation: serializedValidation
52
- } : {};
53
- }
54
- /**
55
- * Helper function to retain serializable props specifically for validation transformation.
56
- * This is used internally by transformTypeValidationRule.
57
- */ function retainSerializablePropsForValidation(value) {
58
- if (value === null || value === undefined) {
59
- return undefined;
60
- }
61
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
62
- if (value === '') {
63
- return undefined;
64
- }
65
- return value;
66
- }
67
- if (value instanceof RegExp) {
68
- return value.toString();
69
- }
70
- if (Array.isArray(value)) {
71
- const items = value.map((item)=>retainSerializablePropsForValidation(item)).filter((item)=>item !== undefined);
72
- return items.length > 0 ? items : undefined;
73
- }
74
- if (typeof value === 'object') {
75
- const entries = Object.entries(value).map(([key, val])=>[
76
- key,
77
- retainSerializablePropsForValidation(val)
78
- ]).filter(([, val])=>val !== undefined);
79
- return entries.length > 0 ? Object.fromEntries(entries) : undefined;
80
- }
81
- return undefined;
82
- }
83
-
84
- //# sourceMappingURL=validationTransformer.js.map
@@ -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,gGAAgG;YAChG,kGAAkG;YAClG,MAAME,mBACJ,OAAOxB,eAAe,YACtB,UAAUA,cACV,OAAOA,WAAWI,IAAI,KAAK,YAC1BJ,CAAAA,WAAWI,IAAI,CAACqB,WAAW,KAAK,eAC/BzB,WAAWI,IAAI,CAACqB,WAAW,KAAK,0BAAyB;YAE7D,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AOS,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,MAAMK,OAAOb,QAAQ,8BAA8Bc,KAAK;IAExD,IAAI;QACF,MAAMC,oBAAoB,IAAIC;QAE9B,MAAMC,SAAS,MAAMpB,oBAAoB;YACvCqB,YAAYjB;YACZQ;YACAU,kBAAkB;YAClBC,aAAa;QACf;QAEA,MAAM,CAACC,eAAe,EAACC,sBAA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