sanity 3.77.2-server-side-schemas.18 → 3.77.2-server-side-schemas.24
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/lib/_chunks-cjs/_internal.js +19 -4
- package/lib/_chunks-cjs/_internal.js.map +1 -1
- package/lib/_chunks-cjs/deleteSchemaAction.js +32 -19
- package/lib/_chunks-cjs/deleteSchemaAction.js.map +1 -1
- package/lib/_chunks-cjs/deployAction.js +2 -2
- package/lib/_chunks-cjs/deployAction.js.map +1 -1
- package/lib/_chunks-cjs/storeSchemasAction.js +101 -21
- package/lib/_chunks-cjs/storeSchemasAction.js.map +1 -1
- package/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/lib/_legacy/version.esm.js +1 -1
- package/package.json +10 -10
- package/src/_internal/cli/actions/schema/deleteSchemaAction.ts +58 -19
- package/src/_internal/cli/actions/schema/schemaListAction.ts +63 -38
- package/src/_internal/cli/actions/schema/storeSchemasAction.ts +49 -37
- package/src/_internal/cli/commands/schema/deleteSchemaCommand.ts +2 -0
- package/src/_internal/cli/commands/schema/storeSchemaCommand.ts +12 -1
- package/lib/_chunks-cjs/schemaListAction.js +0 -59
- package/lib/_chunks-cjs/schemaListAction.js.map +0 -1
@@ -1,11 +1,15 @@
|
|
1
1
|
import {type CliCommandArguments, type CliCommandContext, type CliOutputter} from '@sanity/cli'
|
2
2
|
import {type SanityDocument} from '@sanity/client'
|
3
3
|
import chalk from 'chalk'
|
4
|
-
import {size, sortBy} from 'lodash'
|
4
|
+
import {size, sortBy, uniqBy} from 'lodash'
|
5
|
+
|
6
|
+
import {type ManifestWorkspaceFile} from '../../../manifest/manifestTypes'
|
7
|
+
import {getManifestPath, readManifest, throwIfProjectIdMismatch} from './storeSchemasAction'
|
5
8
|
|
6
9
|
export interface SchemaListFlags {
|
7
10
|
json: boolean
|
8
11
|
id: string
|
12
|
+
path: string
|
9
13
|
}
|
10
14
|
|
11
15
|
type PrintSchemaListArgs = {
|
@@ -13,14 +17,18 @@ type PrintSchemaListArgs = {
|
|
13
17
|
output: CliOutputter
|
14
18
|
dataset: string
|
15
19
|
projectId: string
|
20
|
+
path: string
|
16
21
|
}
|
17
22
|
|
18
23
|
export const SANITY_WORKSPACE_SCHEMA_ID = 'sanity.workspace.schema'
|
19
24
|
|
20
|
-
const printSchemaList = ({
|
25
|
+
const printSchemaList = ({
|
26
|
+
schemas,
|
27
|
+
output,
|
28
|
+
}: Omit<PrintSchemaListArgs, 'path' | 'dataset' | 'projectId'>) => {
|
21
29
|
const ordered = sortBy(
|
22
30
|
schemas.map(({_createdAt: createdAt, _id: id, workspace}) => {
|
23
|
-
return [id, workspace.title, dataset, projectId, createdAt].map(String)
|
31
|
+
return [id, workspace.title, workspace.dataset, workspace.projectId, createdAt].map(String)
|
24
32
|
}),
|
25
33
|
['createdAt'],
|
26
34
|
)
|
@@ -38,7 +46,7 @@ const printSchemaList = ({schemas, output, dataset, projectId}: PrintSchemaListA
|
|
38
46
|
rows.forEach((row) => output.print(printRow(row)))
|
39
47
|
}
|
40
48
|
|
41
|
-
export default async function
|
49
|
+
export default async function fetchSchemaAction(
|
42
50
|
args: CliCommandArguments<SchemaListFlags>,
|
43
51
|
context: CliCommandContext,
|
44
52
|
): Promise<void> {
|
@@ -50,50 +58,67 @@ export default async function storeSchemaAction(
|
|
50
58
|
}).withConfig({apiVersion: 'v2024-08-01'})
|
51
59
|
|
52
60
|
const projectId = client.config().projectId
|
53
|
-
const dataset = client.config().dataset
|
54
61
|
|
55
|
-
if (!projectId
|
56
|
-
output.error('Project ID
|
62
|
+
if (!projectId) {
|
63
|
+
output.error('Project ID must be defined.')
|
57
64
|
return
|
58
65
|
}
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
67
|
+
const manifestPath = getManifestPath(context, flags.path)
|
68
|
+
const manifest = readManifest(manifestPath, output)
|
69
|
+
|
70
|
+
// Gather all schemas
|
71
|
+
const results = await Promise.allSettled(
|
72
|
+
uniqBy<ManifestWorkspaceFile>(manifest.workspaces, 'dataset').map(async (workspace) => {
|
73
|
+
throwIfProjectIdMismatch(workspace, projectId)
|
74
|
+
if (flags.id) {
|
75
|
+
// Fetch a specific schema by id
|
76
|
+
return await client
|
77
|
+
.withConfig({
|
78
|
+
dataset: workspace.dataset,
|
79
|
+
projectId: workspace.projectId,
|
80
|
+
})
|
81
|
+
.fetch<SanityDocument[]>(`*[_type == $type && _id == $id]`, {
|
82
|
+
id: flags.id,
|
83
|
+
type: SANITY_WORKSPACE_SCHEMA_ID,
|
84
|
+
})
|
85
|
+
}
|
86
|
+
// Fetch all schemas
|
87
|
+
return await client
|
88
|
+
.withConfig({
|
89
|
+
dataset: workspace.dataset,
|
90
|
+
projectId: workspace.projectId,
|
91
|
+
})
|
92
|
+
.fetch<SanityDocument[]>(`*[_type == $type]`, {
|
93
|
+
type: SANITY_WORKSPACE_SCHEMA_ID,
|
94
|
+
})
|
95
|
+
}),
|
96
|
+
)
|
97
|
+
|
98
|
+
// Log errors and collect successful results
|
99
|
+
const schemas = results
|
100
|
+
.map((result, index) => {
|
101
|
+
if (result.status === 'rejected') {
|
102
|
+
const workspace = manifest.workspaces[index]
|
103
|
+
output.error(
|
104
|
+
chalk.red(
|
105
|
+
`Failed to fetch schemas for workspace '${workspace.name}': ${result.reason.message}`,
|
106
|
+
),
|
107
|
+
)
|
108
|
+
return []
|
109
|
+
}
|
110
|
+
return result.value
|
111
|
+
})
|
112
|
+
.flat()
|
84
113
|
|
85
114
|
if (schemas.length === 0) {
|
86
|
-
|
87
|
-
output.error(`No schema found with id: ${flags.id}`)
|
88
|
-
} else {
|
89
|
-
output.error(`No schemas found`)
|
90
|
-
}
|
115
|
+
output.error(`No schemas found`)
|
91
116
|
return
|
92
117
|
}
|
93
118
|
|
94
119
|
if (flags.json) {
|
95
|
-
output.print(`${JSON.stringify(
|
120
|
+
output.print(`${JSON.stringify(schemas, null, 2)}`)
|
96
121
|
} else {
|
97
|
-
printSchemaList({schemas, output
|
122
|
+
printSchemaList({schemas, output})
|
98
123
|
}
|
99
124
|
}
|
@@ -1,14 +1,11 @@
|
|
1
1
|
import {readFileSync} from 'node:fs'
|
2
2
|
import path, {join, resolve} from 'node:path'
|
3
3
|
|
4
|
-
import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'
|
4
|
+
import {type CliCommandArguments, type CliCommandContext, type CliOutputter} from '@sanity/cli'
|
5
5
|
import chalk from 'chalk'
|
6
|
+
import {type Ora} from 'ora'
|
6
7
|
|
7
|
-
import {
|
8
|
-
type CreateManifest,
|
9
|
-
type ManifestSchemaType,
|
10
|
-
type ManifestWorkspaceFile,
|
11
|
-
} from '../../../manifest/manifestTypes'
|
8
|
+
import {type ManifestSchemaType, type ManifestWorkspaceFile} from '../../../manifest/manifestTypes'
|
12
9
|
import {MANIFEST_FILENAME} from '../manifest/extractManifestAction'
|
13
10
|
import {SANITY_WORKSPACE_SCHEMA_ID} from './schemaListAction'
|
14
11
|
|
@@ -20,57 +17,74 @@ export interface StoreManifestSchemasFlags {
|
|
20
17
|
'verbose'?: boolean
|
21
18
|
}
|
22
19
|
|
20
|
+
export const getManifestPath = (context: CliCommandContext, customPath?: string) => {
|
21
|
+
const defaultOutputDir = resolve(join(context.workDir, 'dist'))
|
22
|
+
|
23
|
+
const outputDir = resolve(defaultOutputDir)
|
24
|
+
const defaultStaticPath = join(outputDir, 'static')
|
25
|
+
|
26
|
+
const staticPath = customPath ?? defaultStaticPath
|
27
|
+
const manifestPath = path.resolve(process.cwd(), staticPath)
|
28
|
+
return manifestPath
|
29
|
+
}
|
30
|
+
|
31
|
+
export const readManifest = (readPath: string, output?: CliOutputter, spinner?: Ora) => {
|
32
|
+
try {
|
33
|
+
return JSON.parse(readFileSync(`${readPath}/${MANIFEST_FILENAME}`, 'utf-8'))
|
34
|
+
} catch (error) {
|
35
|
+
const errorMessage = `Manifest not found at ${readPath}/${MANIFEST_FILENAME}`
|
36
|
+
if (spinner) spinner.fail(errorMessage)
|
37
|
+
if (output) output.error(errorMessage)
|
38
|
+
throw error
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
export const throwIfProjectIdMismatch = (workspace: ManifestWorkspaceFile, projectId: string) => {
|
43
|
+
if (workspace.projectId !== projectId) {
|
44
|
+
throw new Error(
|
45
|
+
`↳ No permissions to store schema for workspace ${workspace.name} with projectId: ${workspace.projectId}`,
|
46
|
+
)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
23
50
|
export default async function storeSchemasAction(
|
24
51
|
args: CliCommandArguments<StoreManifestSchemasFlags>,
|
25
52
|
context: CliCommandContext,
|
26
53
|
): Promise<Error | undefined> {
|
27
54
|
const flags = args.extOptions
|
55
|
+
if (typeof flags.path === 'boolean') throw new Error('Path is empty')
|
56
|
+
if (typeof flags['id-prefix'] === 'boolean') throw new Error('Id prefix is empty')
|
57
|
+
if (typeof flags.workspace === 'boolean') throw new Error('Workspace is empty')
|
58
|
+
|
28
59
|
const schemaRequired = flags['schema-required']
|
29
60
|
const workspaceName = flags.workspace
|
30
61
|
const idPrefix = flags['id-prefix']
|
31
62
|
const verbose = flags.verbose
|
32
|
-
const {output,
|
33
|
-
|
34
|
-
const defaultOutputDir = resolve(join(workDir, 'dist'))
|
35
|
-
|
36
|
-
const outputDir = resolve(defaultOutputDir)
|
37
|
-
const defaultStaticPath = join(outputDir, 'static')
|
38
|
-
|
39
|
-
const staticPath = flags.path ?? defaultStaticPath
|
63
|
+
const {output, apiClient} = context
|
40
64
|
|
41
65
|
const spinner = output.spinner({}).start('Storing schemas')
|
42
66
|
|
67
|
+
const manifestPath = getManifestPath(context, flags.path)
|
68
|
+
|
43
69
|
try {
|
44
|
-
const manifestPath = path.resolve(process.cwd(), staticPath)
|
45
70
|
const client = apiClient({
|
46
71
|
requireUser: true,
|
47
72
|
requireProject: true,
|
48
73
|
}).withConfig({apiVersion: 'v2024-08-01'})
|
49
74
|
|
50
75
|
const projectId = client.config().projectId
|
76
|
+
if (!projectId) throw new Error('Project ID is not defined')
|
51
77
|
|
52
|
-
|
53
|
-
|
54
|
-
try {
|
55
|
-
manifest = JSON.parse(readFileSync(`${manifestPath}/${MANIFEST_FILENAME}`, 'utf-8'))
|
56
|
-
} catch (error) {
|
57
|
-
spinner.fail(`Manifest not found at ${manifestPath}/${MANIFEST_FILENAME}`)
|
58
|
-
output.error(error)
|
59
|
-
throw error
|
60
|
-
}
|
78
|
+
const manifest = readManifest(manifestPath, output, spinner)
|
61
79
|
|
62
80
|
let storedCount = 0
|
63
81
|
|
64
82
|
let error: Error | undefined
|
65
83
|
|
66
84
|
const saveSchema = async (workspace: ManifestWorkspaceFile) => {
|
67
|
-
const id = `${idPrefix
|
85
|
+
const id = `${idPrefix ? `${idPrefix}.` : ''}${SANITY_WORKSPACE_SCHEMA_ID}.${workspace.name}`
|
68
86
|
try {
|
69
|
-
|
70
|
-
throw new Error(
|
71
|
-
`↳ No permissions to store schema for workspace ${workspace.name} with projectId: ${workspace.projectId}`,
|
72
|
-
)
|
73
|
-
}
|
87
|
+
throwIfProjectIdMismatch(workspace, projectId)
|
74
88
|
const schema = JSON.parse(
|
75
89
|
readFileSync(`${manifestPath}/${workspace.schema}`, 'utf-8'),
|
76
90
|
) as ManifestSchemaType
|
@@ -88,15 +102,13 @@ export default async function storeSchemasAction(
|
|
88
102
|
} catch (err) {
|
89
103
|
error = err
|
90
104
|
spinner.fail(
|
91
|
-
`Error storing schema for workspace '${workspace.name}':\n${chalk.red(
|
105
|
+
`Error storing schema for workspace '${workspace.name}':\n${chalk.red(`${err.message}`)}`,
|
92
106
|
)
|
93
107
|
if (schemaRequired) throw err
|
94
108
|
} finally {
|
95
109
|
if (verbose) {
|
96
110
|
output.print(
|
97
|
-
chalk.gray(
|
98
|
-
`↳ schemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset}, workspace: ${workspace.name}\n`,
|
99
|
-
),
|
111
|
+
chalk.gray(`↳ schemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset}`),
|
100
112
|
)
|
101
113
|
}
|
102
114
|
}
|
@@ -105,7 +117,7 @@ export default async function storeSchemasAction(
|
|
105
117
|
// If a workspace name is provided, only save the schema for that workspace
|
106
118
|
if (workspaceName) {
|
107
119
|
const workspaceToSave = manifest.workspaces.find(
|
108
|
-
(workspace) => workspace.name === workspaceName,
|
120
|
+
(workspace: ManifestWorkspaceFile) => workspace.name === workspaceName,
|
109
121
|
)
|
110
122
|
if (!workspaceToSave) {
|
111
123
|
spinner.fail(`Workspace ${workspaceName} not found in manifest`)
|
@@ -115,7 +127,7 @@ export default async function storeSchemasAction(
|
|
115
127
|
spinner.succeed(`Stored 1 schemas`)
|
116
128
|
} else {
|
117
129
|
await Promise.all(
|
118
|
-
manifest.workspaces.map(async (workspace): Promise<void> => {
|
130
|
+
manifest.workspaces.map(async (workspace: ManifestWorkspaceFile): Promise<void> => {
|
119
131
|
await saveSchema(workspace)
|
120
132
|
}),
|
121
133
|
)
|
@@ -129,6 +141,6 @@ export default async function storeSchemasAction(
|
|
129
141
|
if (schemaRequired) throw err
|
130
142
|
return err
|
131
143
|
} finally {
|
132
|
-
output.print(
|
144
|
+
output.print(`${chalk.gray('↳ List stored schemas with:')} ${chalk.cyan('sanity schema list')}`)
|
133
145
|
}
|
134
146
|
}
|
@@ -9,6 +9,8 @@ const helpText = `
|
|
9
9
|
|
10
10
|
Options
|
11
11
|
--ids <schema_id_1,schema_id_2,...> comma-separated list of schema IDs to delete
|
12
|
+
--dataset <dataset_name> delete schemas from a specific dataset
|
13
|
+
--path <path> path to the manifest file if it is not in the default location
|
12
14
|
|
13
15
|
Examples
|
14
16
|
# Delete single schema
|
@@ -29,7 +29,18 @@ const storeSchemaCommand = {
|
|
29
29
|
action: async (args, context) => {
|
30
30
|
const mod = await import('../../actions/schema/storeSchemasAction')
|
31
31
|
|
32
|
-
|
32
|
+
const extendedArgs = {
|
33
|
+
...args,
|
34
|
+
extOptions: {
|
35
|
+
...args.extOptions,
|
36
|
+
'schema-required': true,
|
37
|
+
},
|
38
|
+
}
|
39
|
+
|
40
|
+
return mod.default(
|
41
|
+
extendedArgs as unknown as CliCommandArguments<StoreManifestSchemasFlags>,
|
42
|
+
context,
|
43
|
+
)
|
33
44
|
},
|
34
45
|
} satisfies CliCommandDefinition
|
35
46
|
|
@@ -1,59 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var chalk = require("chalk"), size = require("lodash/size.js"), sortBy = require("lodash/sortBy.js");
|
3
|
-
function _interopDefaultCompat(e) {
|
4
|
-
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
5
|
-
}
|
6
|
-
var chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), size__default = /* @__PURE__ */ _interopDefaultCompat(size), sortBy__default = /* @__PURE__ */ _interopDefaultCompat(sortBy);
|
7
|
-
const SANITY_WORKSPACE_SCHEMA_ID = "sanity.workspace.schema", printSchemaList = ({
|
8
|
-
schemas,
|
9
|
-
output,
|
10
|
-
dataset,
|
11
|
-
projectId
|
12
|
-
}) => {
|
13
|
-
const ordered = sortBy__default.default(schemas.map(({
|
14
|
-
_createdAt: createdAt,
|
15
|
-
_id: id,
|
16
|
-
workspace
|
17
|
-
}) => [id, workspace.title, dataset, projectId, createdAt].map(String)), ["createdAt"]), headings = ["Id", "Title", "Dataset", "ProjectId", "CreatedAt"], rows = ordered.reverse(), maxWidths = rows.reduce((max, row) => row.map((current, index) => Math.max(size__default.default(current), max[index])), headings.map((str) => size__default.default(str))), printRow = (row) => row.map((col, i) => `${col}`.padEnd(maxWidths[i])).join(" ");
|
18
|
-
output.print(chalk__default.default.cyan(printRow(headings))), rows.forEach((row) => output.print(printRow(row)));
|
19
|
-
};
|
20
|
-
async function storeSchemaAction(args, context) {
|
21
|
-
const flags = args.extOptions, {
|
22
|
-
apiClient,
|
23
|
-
output
|
24
|
-
} = context, client = apiClient({
|
25
|
-
requireUser: !0,
|
26
|
-
requireProject: !0
|
27
|
-
}).withConfig({
|
28
|
-
apiVersion: "v2024-08-01"
|
29
|
-
}), projectId = client.config().projectId, dataset = client.config().dataset;
|
30
|
-
if (!projectId || !dataset) {
|
31
|
-
output.error("Project ID and Dataset must be defined.");
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
let schemas;
|
35
|
-
if (flags.id ? schemas = await client.withConfig({
|
36
|
-
dataset,
|
37
|
-
projectId
|
38
|
-
}).fetch("*[_type == $type && _id == $id]", {
|
39
|
-
id: flags.id,
|
40
|
-
type: SANITY_WORKSPACE_SCHEMA_ID
|
41
|
-
}) : schemas = await client.withConfig({
|
42
|
-
dataset,
|
43
|
-
projectId
|
44
|
-
}).fetch("*[_type == $type]", {
|
45
|
-
type: SANITY_WORKSPACE_SCHEMA_ID
|
46
|
-
}), schemas.length === 0) {
|
47
|
-
flags.id ? output.error(`No schema found with id: ${flags.id}`) : output.error("No schemas found");
|
48
|
-
return;
|
49
|
-
}
|
50
|
-
flags.json ? output.print(`${JSON.stringify(flags.id ? schemas[0] : schemas, null, 2)}`) : printSchemaList({
|
51
|
-
schemas,
|
52
|
-
output,
|
53
|
-
dataset,
|
54
|
-
projectId
|
55
|
-
});
|
56
|
-
}
|
57
|
-
exports.SANITY_WORKSPACE_SCHEMA_ID = SANITY_WORKSPACE_SCHEMA_ID;
|
58
|
-
exports.default = storeSchemaAction;
|
59
|
-
//# sourceMappingURL=schemaListAction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"schemaListAction.js","sources":["../../src/_internal/cli/actions/schema/schemaListAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext, type CliOutputter} from '@sanity/cli'\nimport {type SanityDocument} from '@sanity/client'\nimport chalk from 'chalk'\nimport {size, sortBy} from 'lodash'\n\nexport interface SchemaListFlags {\n json: boolean\n id: string\n}\n\ntype PrintSchemaListArgs = {\n schemas: SanityDocument[]\n output: CliOutputter\n dataset: string\n projectId: string\n}\n\nexport const SANITY_WORKSPACE_SCHEMA_ID = 'sanity.workspace.schema'\n\nconst printSchemaList = ({schemas, output, dataset, projectId}: PrintSchemaListArgs) => {\n const ordered = sortBy(\n schemas.map(({_createdAt: createdAt, _id: id, workspace}) => {\n return [id, workspace.title, dataset, projectId, createdAt].map(String)\n }),\n ['createdAt'],\n )\n const headings = ['Id', 'Title', 'Dataset', 'ProjectId', 'CreatedAt']\n const rows = ordered.reverse()\n\n const maxWidths = rows.reduce(\n (max, row) => row.map((current, index) => Math.max(size(current), max[index])),\n headings.map((str) => size(str)),\n )\n\n const printRow = (row: string[]) => row.map((col, i) => `${col}`.padEnd(maxWidths[i])).join(' ')\n\n output.print(chalk.cyan(printRow(headings)))\n rows.forEach((row) => output.print(printRow(row)))\n}\n\nexport default async function storeSchemaAction(\n args: CliCommandArguments<SchemaListFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n const {apiClient, output} = context\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n const projectId = client.config().projectId\n const dataset = client.config().dataset\n\n if (!projectId || !dataset) {\n output.error('Project ID and Dataset must be defined.')\n return\n }\n\n let schemas: SanityDocument[]\n\n if (flags.id) {\n // Fetch a specific schema by id\n schemas = await client\n .withConfig({\n dataset: dataset,\n projectId: projectId,\n })\n .fetch<SanityDocument[]>(`*[_type == $type && _id == $id]`, {\n id: flags.id,\n type: SANITY_WORKSPACE_SCHEMA_ID,\n })\n } else {\n // Fetch all schemas\n schemas = await client\n .withConfig({\n dataset: dataset,\n projectId: projectId,\n })\n .fetch<SanityDocument[]>(`*[_type == $type]`, {\n type: SANITY_WORKSPACE_SCHEMA_ID,\n })\n }\n\n if (schemas.length === 0) {\n if (flags.id) {\n output.error(`No schema found with id: ${flags.id}`)\n } else {\n output.error(`No schemas found`)\n }\n return\n }\n\n if (flags.json) {\n output.print(`${JSON.stringify(flags.id ? schemas[0] : schemas, null, 2)}`)\n } else {\n printSchemaList({schemas, output, dataset, projectId})\n }\n}\n"],"names":["SANITY_WORKSPACE_SCHEMA_ID","printSchemaList","schemas","output","dataset","projectId","ordered","sortBy","map","_createdAt","createdAt","_id","id","workspace","title","String","headings","rows","reverse","maxWidths","reduce","max","row","current","index","Math","size","str","printRow","col","i","padEnd","join","print","chalk","cyan","forEach","storeSchemaAction","args","context","flags","extOptions","apiClient","client","requireUser","requireProject","withConfig","apiVersion","config","error","fetch","type","length","json","JSON","stringify"],"mappings":";;;;;;AAiBO,MAAMA,6BAA6B,2BAEpCC,kBAAkBA,CAAC;AAAA,EAACC;AAAAA,EAASC;AAAAA,EAAQC;AAAAA,EAASC;AAA8B,MAAM;AACtF,QAAMC,UAAUC,gBAAAA,QACdL,QAAQM,IAAI,CAAC;AAAA,IAACC,YAAYC;AAAAA,IAAWC,KAAKC;AAAAA,IAAIC;AAAAA,EAAAA,MACrC,CAACD,IAAIC,UAAUC,OAAOV,SAASC,WAAWK,SAAS,EAAEF,IAAIO,MAAM,CACvE,GACD,CAAC,WAAW,CACd,GACMC,WAAW,CAAC,MAAM,SAAS,WAAW,aAAa,WAAW,GAC9DC,OAAOX,QAAQY,QAAQ,GAEvBC,YAAYF,KAAKG,OACrB,CAACC,KAAKC,QAAQA,IAAId,IAAI,CAACe,SAASC,UAAUC,KAAKJ,IAAIK,cAAAA,QAAKH,OAAO,GAAGF,IAAIG,KAAK,CAAC,CAAC,GAC7ER,SAASR,IAAKmB,CAAQD,QAAAA,cAAAA,QAAKC,GAAG,CAAC,CACjC,GAEMC,WAAYN,SAAkBA,IAAId,IAAI,CAACqB,KAAKC,MAAM,GAAGD,GAAG,GAAGE,OAAOZ,UAAUW,CAAC,CAAC,CAAC,EAAEE,KAAK,KAAK;AAEjG7B,SAAO8B,MAAMC,eAAMC,QAAAA,KAAKP,SAASZ,QAAQ,CAAC,CAAC,GAC3CC,KAAKmB,QAASd,SAAQnB,OAAO8B,MAAML,SAASN,GAAG,CAAC,CAAC;AACnD;AAE8Be,eAAAA,kBAC5BC,MACAC,SACe;AACTC,QAAAA,QAAQF,KAAKG,YACb;AAAA,IAACC;AAAAA,IAAWvC;AAAAA,EAAAA,IAAUoC,SACtBI,SAASD,UAAU;AAAA,IACvBE,aAAa;AAAA,IACbC,gBAAgB;AAAA,EACjB,CAAA,EAAEC,WAAW;AAAA,IAACC,YAAY;AAAA,EAAA,CAAc,GAEnC1C,YAAYsC,OAAOK,SAAS3C,WAC5BD,UAAUuC,OAAOK,OAAAA,EAAS5C;AAE5B,MAAA,CAACC,aAAa,CAACD,SAAS;AAC1BD,WAAO8C,MAAM,yCAAyC;AACtD;AAAA,EAAA;AAGE/C,MAAAA;AAyBJ,MAvBIsC,MAAM5B,KAERV,UAAU,MAAMyC,OACbG,WAAW;AAAA,IACV1C;AAAAA,IACAC;AAAAA,EAAAA,CACD,EACA6C,MAAwB,mCAAmC;AAAA,IAC1DtC,IAAI4B,MAAM5B;AAAAA,IACVuC,MAAMnD;AAAAA,EACP,CAAA,IAGHE,UAAU,MAAMyC,OACbG,WAAW;AAAA,IACV1C;AAAAA,IACAC;AAAAA,EAAAA,CACD,EACA6C,MAAwB,qBAAqB;AAAA,IAC5CC,MAAMnD;AAAAA,EAAAA,CACP,GAGDE,QAAQkD,WAAW,GAAG;AACpBZ,UAAM5B,KACRT,OAAO8C,MAAM,4BAA4BT,MAAM5B,EAAE,EAAE,IAEnDT,OAAO8C,MAAM,kBAAkB;AAEjC;AAAA,EAAA;AAGET,QAAMa,OACRlD,OAAO8B,MAAM,GAAGqB,KAAKC,UAAUf,MAAM5B,KAAKV,QAAQ,CAAC,IAAIA,SAAS,MAAM,CAAC,CAAC,EAAE,IAE1ED,gBAAgB;AAAA,IAACC;AAAAA,IAASC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAAA,CAAU;AAEzD;;;"}
|