@sanity/cli 8.14.0 → 8.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/init/project/getProjectDetails.js +1 -0
- package/dist/actions/init/project/getProjectDetails.js.map +1 -1
- package/dist/actions/typegen/fetchResourceSchema.js +40 -0
- package/dist/actions/typegen/fetchResourceSchema.js.map +1 -0
- package/dist/actions/typegen/generateResourceTypes.js +115 -0
- package/dist/actions/typegen/generateResourceTypes.js.map +1 -0
- package/dist/actions/typegen/parseTypegenResources.js +92 -0
- package/dist/actions/typegen/parseTypegenResources.js.map +1 -0
- package/dist/commands/typegen/generate.js +59 -5
- package/dist/commands/typegen/generate.js.map +1 -1
- package/dist/generated/apiRoutes.js +2 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/server/vite/plugin-typegen.js +10 -0
- package/dist/server/vite/plugin-typegen.js.map +1 -1
- package/dist/services/schemas.js +36 -0
- package/dist/services/schemas.js.map +1 -1
- package/oclif.manifest.json +163 -163
- package/package.json +18 -17
- package/templates/shared/dashboard/app-quickstart/AGENTS.md +1 -1
- package/templates/shared/dashboard/app-quickstart/README.md +1 -1
- package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +1 -1
- package/templates/shared/dashboard/app-sanity-ui/README.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/generated/apiRoutes.ts"],"sourcesContent":["/**\n * GENERATED FILE - DO NOT EDIT\n *\n * Routing manifest for `sanity api`, distilled from the published OpenAPI\n * specifications at https://www.sanity.io/docs/api/openapi\n *\n * Regenerate with: pnpm generate:api-routes\n */\nimport {type ApiRouteEntry} from '../actions/api/types.js'\n\nexport const apiRoutes: ApiRouteEntry[] = [\n {\n defaultApiVersion: 'v2025-07-11',\n host: 'global',\n pathPatterns: [\n 'access/invites/me',\n 'access/organization/{resourceId}/users/roles/default',\n 'access/requests/me',\n 'access/robots/me',\n 'access/robots/me/rotate',\n 'access/{resourceType}/{resourceId}/invites',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/accept',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/eligibility',\n 'access/{resourceType}/{resourceId}/invites/{inviteId}',\n 'access/{resourceType}/{resourceId}/permissions',\n 'access/{resourceType}/{resourceId}/permissions/{permissionName}',\n 'access/{resourceType}/{resourceId}/requests',\n 'access/{resourceType}/{resourceId}/requests/state',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/accept',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/decline',\n 'access/{resourceType}/{resourceId}/robots',\n 'access/{resourceType}/{resourceId}/robots/{robotId}',\n 'access/{resourceType}/{resourceId}/roles',\n 'access/{resourceType}/{resourceId}/roles/{roleName}',\n 'access/{resourceType}/{resourceId}/user-permissions/me',\n 'access/{resourceType}/{resourceId}/user-permissions/me/check',\n 'access/{resourceType}/{resourceId}/users',\n 'access/{resourceType}/{resourceId}/users/me',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles/{roleName}'\n ],\n slug: 'access-api',\n title: 'Access API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/actions/{dataset}'\n ],\n slug: 'actions',\n title: 'Actions API reference'\n },\n {\n defaultApiVersion: 'v2021-02-01',\n host: 'global',\n pathPatterns: [\n 'activity',\n 'activity/export/csv'\n ],\n slug: 'activity-log',\n title: 'Activity Log API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'agent/action/generate/{dataset}',\n 'agent/action/patch/{dataset}',\n 'agent/action/prompt/{dataset}',\n 'agent/action/transform/{dataset}',\n 'agent/action/translate/{dataset}'\n ],\n slug: 'agent-actions',\n title: 'Agent Actions'\n },\n {\n host: 'global',\n pathPatterns: [\n 'applications',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n host: 'project',\n pathPatterns: [\n 'applications',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n defaultApiVersion: 'v2024-06-24',\n host: 'project',\n pathPatterns: [\n 'assets/files/{dataset}',\n 'assets/files/{dataset}/from-url',\n 'assets/images/{dataset}',\n 'assets/images/{dataset}/from-url',\n 'assets/media-library-link/{dataset}'\n ],\n slug: 'assets',\n title: 'Assets API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/{datasetName}/backups',\n 'projects/{projectId}/datasets/{datasetName}/backups/{backupId}',\n 'projects/{projectId}/datasets/{datasetName}/settings/backups'\n ],\n slug: 'backups',\n title: 'Backups API reference'\n },\n {\n defaultApiVersion: 'v1',\n host: 'global',\n pathPatterns: [\n 'projects/{project_id}/datasets/{dataset_name}/assets/{asset_id}/purges',\n 'projects/{project_id}/datasets/{dataset_name}/purges'\n ],\n slug: 'cdn-cache-purge',\n title: 'CDN Cache Purge API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'global',\n pathPatterns: [\n 'agent/prompt',\n 'agent/{organizationId}/threads/{threadId}'\n ],\n slug: 'content-agent',\n title: 'Content Agent API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/{dataset}/copy'\n ],\n slug: 'copy',\n title: 'Copy API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/doc/{dataset}/{documentId}'\n ],\n slug: 'doc',\n title: 'Doc API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'embeddings-index/query/{dataset}/{indexName}',\n 'embeddings-index/{dataset}',\n 'embeddings-index/{dataset}/{indexName}'\n ],\n slug: 'embeddings-index',\n title: 'Embeddings Index API reference (deprecated)'\n },\n {\n defaultApiVersion: 'v2021-03-25',\n host: 'project',\n pathPatterns: [\n 'data/export/{dataset}'\n ],\n slug: 'export',\n title: 'Export API reference'\n },\n {\n host: 'global',\n pathPatterns: [\n 'functions',\n 'functions/{functionId}',\n 'functions/{functionId}/envvars',\n 'functions/{functionId}/envvars/{envVarKey}',\n 'functions/{functionId}/invoke',\n 'functions/{functionId}/logs',\n 'functions/{functionId}/logs/stream'\n ],\n slug: 'functions-api',\n title: 'Functions API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/history/{dataset}/documents/{documentId}',\n 'data/history/{dataset}/transactions',\n 'data/history/{dataset}/transactions/{documentIds}'\n ],\n slug: 'history',\n title: 'History API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'jobs/{jobId}',\n 'jobs/{jobId}/listen'\n ],\n slug: 'jobs',\n title: 'Jobs API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/listen/{dataset}'\n ],\n slug: 'listen',\n title: 'Listen API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/live/events/{dataset}'\n ],\n slug: 'live',\n title: 'Live Content API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/mutate/{dataset}'\n ],\n slug: 'mutation',\n title: 'Mutation API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'projects',\n 'projects/{projectId}',\n 'projects/{projectId}/cors',\n 'projects/{projectId}/cors/{id}',\n 'projects/{projectId}/datasets',\n 'projects/{projectId}/datasets/{datasetName}/tags/{tagIdentifier}',\n 'projects/{projectId}/datasets/{name}',\n 'projects/{projectId}/datasets/{name}/copy',\n 'projects/{projectId}/datasets/{name}/settings/embeddings',\n 'projects/{projectId}/datasets/{name}/tags',\n 'projects/{projectId}/features',\n 'projects/{projectId}/permissions',\n 'projects/{projectId}/tags',\n 'projects/{projectId}/tags/{tagIdentifier}',\n 'projects/{projectId}/tokens',\n 'projects/{projectId}/tokens/{tokenId}',\n 'projects/{projectId}/users/{userId}'\n ],\n slug: 'projects-api',\n title: 'Projects API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/query/{dataset}'\n ],\n slug: 'query',\n title: 'Query API reference'\n },\n {\n defaultApiVersion: 'v2021-10-04',\n host: 'global',\n pathPatterns: [\n 'organizations/{organizationId}/acl',\n 'organizations/{organizationId}/acl/{sanityUserId}',\n 'organizations/{organizationId}/grants',\n 'organizations/{organizationId}/providers/{providerId}/projects/{projectId}/role-mappings',\n 'projects/{projectId}/acl',\n 'projects/{projectId}/acl/{userId}',\n 'projects/{projectId}/datasets/{datasetName}/acl',\n 'projects/{projectId}/datasets/{datasetName}/grants',\n 'projects/{projectId}/grants',\n 'projects/{projectId}/permissionResourceSchemas',\n 'projects/{projectId}/roles',\n 'projects/{projectId}/roles/{roleName}'\n ],\n slug: 'roles',\n title: 'Roles API reference'\n },\n {\n defaultApiVersion: 'v2022-04-01',\n host: 'project',\n pathPatterns: [\n 'publish/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}/{scheduleId}',\n 'schedules/{projectId}/{dataset}/{scheduleId}/publish',\n 'unpublish/{projectId}/{dataset}'\n ],\n slug: 'scheduling',\n title: 'Scheduling API reference'\n },\n {\n defaultApiVersion: 'v2026-04-27',\n host: 'global',\n pathPatterns: [\n 'organizations/{organizationId}/attribute-definitions',\n 'organizations/{organizationId}/attribute-definitions/{key}',\n 'organizations/{organizationId}/users/me/attributes',\n 'organizations/{organizationId}/users/{sanityUserId}/attributes'\n ],\n slug: 'user-attributes',\n title: 'User attributes API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'hooks/projects/{projectId}',\n 'hooks/projects/{projectId}/{id}',\n 'hooks/projects/{projectId}/{id}/attempts',\n 'hooks/{id}/messages'\n ],\n slug: 'webhooks',\n title: 'Webhooks API reference'\n }\n]\n"],"names":["apiRoutes","defaultApiVersion","host","pathPatterns","slug","title"],"mappings":"AAAA;;;;;;;CAOC,GAGD,OAAO,MAAMA,YAA6B;IACxC;QACEC,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;CACD,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../src/generated/apiRoutes.ts"],"sourcesContent":["/**\n * GENERATED FILE - DO NOT EDIT\n *\n * Routing manifest for `sanity api`, distilled from the published OpenAPI\n * specifications at https://www.sanity.io/docs/api/openapi\n *\n * Regenerate with: pnpm generate:api-routes\n */\nimport {type ApiRouteEntry} from '../actions/api/types.js'\n\nexport const apiRoutes: ApiRouteEntry[] = [\n {\n defaultApiVersion: 'v2025-07-11',\n host: 'global',\n pathPatterns: [\n 'access/invites/me',\n 'access/organization/{resourceId}/users/roles/default',\n 'access/requests/me',\n 'access/robots/me',\n 'access/robots/me/rotate',\n 'access/{resourceType}/{resourceId}/invites',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/accept',\n 'access/{resourceType}/{resourceId}/invites/token/{inviteToken}/eligibility',\n 'access/{resourceType}/{resourceId}/invites/{inviteId}',\n 'access/{resourceType}/{resourceId}/permissions',\n 'access/{resourceType}/{resourceId}/permissions/{permissionName}',\n 'access/{resourceType}/{resourceId}/requests',\n 'access/{resourceType}/{resourceId}/requests/state',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/accept',\n 'access/{resourceType}/{resourceId}/requests/{requestId}/decline',\n 'access/{resourceType}/{resourceId}/robots',\n 'access/{resourceType}/{resourceId}/robots/{robotId}',\n 'access/{resourceType}/{resourceId}/roles',\n 'access/{resourceType}/{resourceId}/roles/{roleName}',\n 'access/{resourceType}/{resourceId}/user-permissions/me',\n 'access/{resourceType}/{resourceId}/user-permissions/me/check',\n 'access/{resourceType}/{resourceId}/users',\n 'access/{resourceType}/{resourceId}/users/me',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles',\n 'access/{resourceType}/{resourceId}/users/{sanityUserId}/roles/{roleName}'\n ],\n slug: 'access-api',\n title: 'Access API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/actions/{dataset}'\n ],\n slug: 'actions',\n title: 'Actions API reference'\n },\n {\n defaultApiVersion: 'v2021-02-01',\n host: 'global',\n pathPatterns: [\n 'activity',\n 'activity/export/csv'\n ],\n slug: 'activity-log',\n title: 'Activity Log API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'agent/action/generate/{dataset}',\n 'agent/action/patch/{dataset}',\n 'agent/action/prompt/{dataset}',\n 'agent/action/transform/{dataset}',\n 'agent/action/translate/{dataset}'\n ],\n slug: 'agent-actions',\n title: 'Agent Actions'\n },\n {\n host: 'global',\n pathPatterns: [\n 'applications',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/embeddable',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n host: 'project',\n pathPatterns: [\n 'applications',\n 'applications/{applicationId}',\n 'applications/{applicationId}/access',\n 'applications/{applicationId}/deployments',\n 'applications/{applicationId}/embeddable',\n 'applications/{applicationId}/installations',\n 'applications/{applicationId}/interfaces',\n 'applications/{applicationId}/workspaces',\n 'deploy',\n 'deploy/quickstart',\n 'installations',\n 'installations/ai-features',\n 'installations/catalog',\n 'installations/defaults',\n 'installations/{installationId}',\n 'installations/{installationId}/access',\n 'installations/{installationId}/configs',\n 'installations/{installationId}/configs/{configId}',\n 'installations/{installationId}/interfaces',\n 'projects/{projectId}/user-applications',\n 'projects/{projectId}/user-applications/{userApplicationId}',\n 'projects/{projectId}/user-applications/{userApplicationId}/config/{configKey}',\n 'projects/{projectId}/user-applications/{userApplicationId}/deployments',\n 'studiohosts/{appHost}/availability',\n 'user-applications',\n 'user-applications/auto-update-version/{userApplicationId}',\n 'user-applications/resolve/application',\n 'user-applications/resolve/project',\n 'user-applications/workspaces',\n 'user-applications/{userApplicationId}',\n 'user-applications/{userApplicationId}/applicationData',\n 'user-applications/{userApplicationId}/config/{configKey}',\n 'user-applications/{userApplicationId}/deployments',\n 'user-applications/{userApplicationId}/workspaces'\n ],\n slug: 'applications-api',\n title: 'Applications API Reference'\n },\n {\n defaultApiVersion: 'v2024-06-24',\n host: 'project',\n pathPatterns: [\n 'assets/files/{dataset}',\n 'assets/files/{dataset}/from-url',\n 'assets/images/{dataset}',\n 'assets/images/{dataset}/from-url',\n 'assets/media-library-link/{dataset}'\n ],\n slug: 'assets',\n title: 'Assets API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/{datasetName}/backups',\n 'projects/{projectId}/datasets/{datasetName}/backups/{backupId}',\n 'projects/{projectId}/datasets/{datasetName}/settings/backups'\n ],\n slug: 'backups',\n title: 'Backups API reference'\n },\n {\n defaultApiVersion: 'v1',\n host: 'global',\n pathPatterns: [\n 'projects/{project_id}/datasets/{dataset_name}/assets/{asset_id}/purges',\n 'projects/{project_id}/datasets/{dataset_name}/purges'\n ],\n slug: 'cdn-cache-purge',\n title: 'CDN Cache Purge API Reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'global',\n pathPatterns: [\n 'agent/prompt',\n 'agent/{organizationId}/threads/{threadId}'\n ],\n slug: 'content-agent',\n title: 'Content Agent API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'projects/{projectId}/datasets/{dataset}/copy'\n ],\n slug: 'copy',\n title: 'Copy API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/doc/{dataset}/{documentId}'\n ],\n slug: 'doc',\n title: 'Doc API reference'\n },\n {\n defaultApiVersion: 'vX',\n host: 'project',\n pathPatterns: [\n 'embeddings-index/query/{dataset}/{indexName}',\n 'embeddings-index/{dataset}',\n 'embeddings-index/{dataset}/{indexName}'\n ],\n slug: 'embeddings-index',\n title: 'Embeddings Index API reference (deprecated)'\n },\n {\n defaultApiVersion: 'v2021-03-25',\n host: 'project',\n pathPatterns: [\n 'data/export/{dataset}'\n ],\n slug: 'export',\n title: 'Export API reference'\n },\n {\n host: 'global',\n pathPatterns: [\n 'functions',\n 'functions/{functionId}',\n 'functions/{functionId}/envvars',\n 'functions/{functionId}/envvars/{envVarKey}',\n 'functions/{functionId}/invoke',\n 'functions/{functionId}/logs',\n 'functions/{functionId}/logs/stream'\n ],\n slug: 'functions-api',\n title: 'Functions API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/history/{dataset}/documents/{documentId}',\n 'data/history/{dataset}/transactions',\n 'data/history/{dataset}/transactions/{documentIds}'\n ],\n slug: 'history',\n title: 'History API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'jobs/{jobId}',\n 'jobs/{jobId}/listen'\n ],\n slug: 'jobs',\n title: 'Jobs API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/listen/{dataset}'\n ],\n slug: 'listen',\n title: 'Listen API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/live/events/{dataset}'\n ],\n slug: 'live',\n title: 'Live Content API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'global',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'media-libraries/{libraryId}/from-url',\n 'media-libraries/{libraryId}/mutate',\n 'media-libraries/{libraryId}/query',\n 'media-libraries/{libraryId}/references/documents/{assetId}/to',\n 'media-libraries/{libraryId}/refsearch',\n 'media-libraries/{libraryId}/signing-keys',\n 'media-libraries/{libraryId}/signing-keys/{keyId}',\n 'media-libraries/{libraryId}/upload',\n 'media-libraries/{libraryId}/video/{videoId}/playback-info',\n 'media-libraries/{libraryId}/video/{videoId}/playback/{type}',\n 'media-libraries/{libraryId}/video/{videoId}/renditions/{name}',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/upload',\n 'media-libraries/{libraryId}/video/{videoId}/subtitles/{subtitleId}'\n ],\n slug: 'media-library',\n title: 'Media Library API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/mutate/{dataset}'\n ],\n slug: 'mutation',\n title: 'Mutation API reference'\n },\n {\n defaultApiVersion: 'v2021-06-07',\n host: 'global',\n pathPatterns: [\n 'projects',\n 'projects/{projectId}',\n 'projects/{projectId}/cors',\n 'projects/{projectId}/cors/{id}',\n 'projects/{projectId}/datasets',\n 'projects/{projectId}/datasets/{datasetName}/tags/{tagIdentifier}',\n 'projects/{projectId}/datasets/{name}',\n 'projects/{projectId}/datasets/{name}/copy',\n 'projects/{projectId}/datasets/{name}/settings/embeddings',\n 'projects/{projectId}/datasets/{name}/tags',\n 'projects/{projectId}/features',\n 'projects/{projectId}/permissions',\n 'projects/{projectId}/tags',\n 'projects/{projectId}/tags/{tagIdentifier}',\n 'projects/{projectId}/tokens',\n 'projects/{projectId}/tokens/{tokenId}',\n 'projects/{projectId}/users/{userId}'\n ],\n slug: 'projects-api',\n title: 'Projects API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'data/query/{dataset}'\n ],\n slug: 'query',\n title: 'Query API reference'\n },\n {\n defaultApiVersion: 'v2021-10-04',\n host: 'global',\n pathPatterns: [\n 'organizations/{organizationId}/acl',\n 'organizations/{organizationId}/acl/{sanityUserId}',\n 'organizations/{organizationId}/grants',\n 'organizations/{organizationId}/providers/{providerId}/projects/{projectId}/role-mappings',\n 'projects/{projectId}/acl',\n 'projects/{projectId}/acl/{userId}',\n 'projects/{projectId}/datasets/{datasetName}/acl',\n 'projects/{projectId}/datasets/{datasetName}/grants',\n 'projects/{projectId}/grants',\n 'projects/{projectId}/permissionResourceSchemas',\n 'projects/{projectId}/roles',\n 'projects/{projectId}/roles/{roleName}'\n ],\n slug: 'roles',\n title: 'Roles API reference'\n },\n {\n defaultApiVersion: 'v2022-04-01',\n host: 'project',\n pathPatterns: [\n 'publish/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}',\n 'schedules/{projectId}/{dataset}/{scheduleId}',\n 'schedules/{projectId}/{dataset}/{scheduleId}/publish',\n 'unpublish/{projectId}/{dataset}'\n ],\n slug: 'scheduling',\n title: 'Scheduling API reference'\n },\n {\n defaultApiVersion: 'v2026-04-27',\n host: 'global',\n pathPatterns: [\n 'organizations/{organizationId}/attribute-definitions',\n 'organizations/{organizationId}/attribute-definitions/{key}',\n 'organizations/{organizationId}/users/me/attributes',\n 'organizations/{organizationId}/users/{sanityUserId}/attributes'\n ],\n slug: 'user-attributes',\n title: 'User attributes API reference'\n },\n {\n defaultApiVersion: 'v2025-02-19',\n host: 'project',\n pathPatterns: [\n 'hooks/projects/{projectId}',\n 'hooks/projects/{projectId}/{id}',\n 'hooks/projects/{projectId}/{id}/attempts',\n 'hooks/{id}/messages'\n ],\n slug: 'webhooks',\n title: 'Webhooks API reference'\n }\n]\n"],"names":["apiRoutes","defaultApiVersion","host","pathPatterns","slug","title"],"mappings":"AAAA;;;;;;;CAOC,GAGD,OAAO,MAAMA,YAA6B;IACxC;QACEC,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEH,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;IACA;QACEJ,mBAAmB;QACnBC,MAAM;QACNC,cAAc;YACZ;YACA;YACA;YACA;SACD;QACDC,MAAM;QACNC,OAAO;IACT;CACD,CAAA"}
|
|
@@ -33,6 +33,16 @@ import { toForwardSlashes } from '../../util/toForwardSlashes.js';
|
|
|
33
33
|
* @internal
|
|
34
34
|
*/ export function sanityTypegenPlugin(options) {
|
|
35
35
|
const { config: inputConfig, output = console, telemetryLogger, workDir } = options;
|
|
36
|
+
// Generating per resource is not supported here yet. Without this check the plugin would
|
|
37
|
+
// generate from the top-level `schema`, which a resources config does not use.
|
|
38
|
+
if (inputConfig.resources !== undefined) {
|
|
39
|
+
return {
|
|
40
|
+
configResolved () {
|
|
41
|
+
output.log(logSymbols.warning, 'Typegen during "sanity dev" does not support typegen.resources yet. Run "sanity typegen generate" instead.');
|
|
42
|
+
},
|
|
43
|
+
name: 'sanity/typegen'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
36
46
|
// Apply defaults through the same schema as `sanity typegen generate`,
|
|
37
47
|
// so watch mode and manual generation produce identical output
|
|
38
48
|
const config = parseTypegenConfig(inputConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/vite/plugin-typegen.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport path from 'node:path'\n\nimport {CLITelemetryStore} from '@sanity/cli-core'\nimport {logSymbols} from '@sanity/cli-core/ux'\nimport {\n type GenerationResult,\n runTypegenGenerate,\n type TypeGenConfig,\n TypegenWatchModeTrace,\n TypesGeneratedTrace,\n} from '@sanity/codegen'\nimport debounce from 'lodash-es/debounce.js'\nimport mean from 'lodash-es/mean.js'\nimport once from 'lodash-es/once.js'\nimport picomatch from 'picomatch'\nimport {type Plugin} from 'vite'\n\nimport {parseTypegenConfig} from '../../actions/typegen/parseTypegenConfig.js'\nimport {toForwardSlashes} from '../../util/toForwardSlashes.js'\n\n/** Default debounce delay in milliseconds */\nconst DEFAULT_DEBOUNCE_MS = 1000\n\n/**\n * Delay before initial generation to allow Vite to finish startup\n * and avoid race conditions with module resolution.\n */\nconst INITIAL_GENERATION_DELAY_MS = 1000\n\n/**\n * Options for the Sanity typegen Vite plugin.\n *\n * @internal\n */\ninterface TypegenPluginOptions {\n /**\n * Typegen configuration from sanity.cli.ts.\n * All fields are optional and will use sensible defaults.\n */\n config: Partial<TypeGenConfig>\n\n /**\n * Working directory containing the Sanity configuration.\n * This should be the root of your Sanity Studio project.\n */\n workDir: string\n\n /**\n * Logger for output messages. Must implement `log`, `info`, and `error` methods.\n * @defaultValue `console`\n */\n output?: Pick<Console, 'error' | 'info' | 'log'>\n\n /**\n * Telemetry logger for the Sanity CLI tooling.\n */\n telemetryLogger?: CLITelemetryStore\n}\n\n/**\n * Creates a Vite plugin that automatically generates TypeScript types during development and build.\n *\n * **During development:**\n * The plugin performs an initial generation when the dev server starts, then watches\n * for file changes and re-generates types when relevant files are modified.\n *\n * **During build:**\n * The plugin generates types once at the end of the build process.\n *\n * **Prerequisites:**\n * The schema.json file must exist before typegen can run. Run `sanity schema extract`\n * first to generate the schema file.\n *\n * @param options - Configuration options for the plugin\n * @returns A Vite plugin configured for typegen\n *\n * @internal\n */\nexport function sanityTypegenPlugin(options: TypegenPluginOptions): Plugin {\n const {config: inputConfig, output = console, telemetryLogger, workDir} = options\n\n // Apply defaults through the same schema as `sanity typegen generate`,\n // so watch mode and manual generation produce identical output\n const config: TypeGenConfig = parseTypegenConfig(inputConfig)\n\n // Build query patterns from config\n const queryPatterns = Array.isArray(config.path) ? config.path : [config.path]\n\n // Resolved after Vite config is available\n let resolvedSchemaPath: string\n\n // State for concurrency control\n let isGenerating = false\n let pendingGeneration = false\n\n // Stats for telemetry\n const startTime = Date.now()\n const stats: {failedCount: number; successfulDurations: number[]} = {\n failedCount: 0,\n successfulDurations: [],\n }\n\n /**\n * Runs type generation with concurrency control.\n * If generation is already running, queues one more generation to run after completion.\n * Returns the generation result, or null if generation was skipped or failed.\n */\n async function runGeneration(isBuilding = false): Promise<GenerationResult | null> {\n if (isGenerating) {\n pendingGeneration = true\n return null\n }\n\n isGenerating = true\n pendingGeneration = false\n\n const generationStartTime = Date.now()\n\n try {\n // Validate schema.json exists\n if (!existsSync(resolvedSchemaPath)) {\n output.error(\n `${logSymbols.error} Schema file not found: ${config.schema}\\n` +\n `Run \"sanity schema extract\" first to generate the schema file.`,\n )\n return null\n }\n\n const result = await runTypegenGenerate({\n config,\n workDir,\n })\n\n if (isBuilding) {\n // Add newline for better formatting in build output\n output.log('')\n }\n\n if (result.filesWithErrors > 0) {\n output.log(\n logSymbols.warning,\n `Generated types to ${config.generates} (with errors in ${result.filesWithErrors} file${result.filesWithErrors === 1 ? '' : 's'})`,\n )\n } else {\n output.log(logSymbols.success, `Generated types to ${config.generates}`)\n }\n\n // Track stats for telemetry (all completed generations count as successful)\n stats.successfulDurations.push(Date.now() - generationStartTime)\n\n return result\n } catch (err) {\n output.error(\n `${logSymbols.error} Generation failed: ${err instanceof Error ? err.message : String(err)}`,\n )\n stats.failedCount++\n return null\n } finally {\n isGenerating = false\n\n // If a change came in during generation, run again\n if (pendingGeneration) {\n pendingGeneration = false\n void runGeneration()\n }\n }\n }\n\n const debouncedGenerate = debounce(() => {\n void runGeneration()\n }, DEFAULT_DEBOUNCE_MS)\n\n // Create a matcher function from query patterns\n const isQueryMatch = picomatch(queryPatterns)\n\n return {\n name: 'sanity/typegen',\n\n configResolved() {\n const rootDir = workDir\n\n resolvedSchemaPath = path.isAbsolute(config.schema)\n ? config.schema\n : path.join(rootDir, config.schema)\n },\n\n configureServer(server) {\n const trace = telemetryLogger?.trace(TypegenWatchModeTrace)\n trace?.start()\n trace?.log({step: 'started'})\n\n // Build absolute patterns for query files\n const absoluteQueryPatterns = queryPatterns.map((pattern) =>\n path.isAbsolute(pattern) ? pattern : path.join(workDir, pattern),\n )\n\n // Add query patterns AND schema.json to Vite's watcher\n server.watcher.add([...absoluteQueryPatterns, resolvedSchemaPath])\n\n // Listen for file changes\n const handleChange = (filePath: string) => {\n const relativePath = path.isAbsolute(filePath) ? path.relative(workDir, filePath) : filePath\n // Normalize to forward slashes for cross-platform picomatch compatibility\n const normalizedPath = toForwardSlashes(relativePath)\n\n // Trigger on schema.json change OR matching query file\n if (filePath === resolvedSchemaPath || isQueryMatch(normalizedPath)) {\n debouncedGenerate()\n }\n }\n\n // Prepare function to log \"stopped\" event to trace and complete the trace\n const onClose = once(() => {\n // Cancel any pending debounced extractions\n debouncedGenerate.cancel()\n\n if (trace) {\n trace.log({\n averageGenerationDuration: mean(stats.successfulDurations) || 0,\n generationFailedCount: stats.failedCount,\n generationSuccessfulCount: stats.successfulDurations.length,\n step: 'stopped',\n watcherDuration: Date.now() - startTime,\n })\n trace.complete()\n }\n\n // Clean up process listeners (must always run, not just when trace exists)\n process.off('SIGTERM', onClose)\n process.off('SIGINT', onClose)\n })\n\n server.watcher.on('change', handleChange)\n server.watcher.on('add', handleChange)\n server.watcher.on('unlink', handleChange)\n\n // Call the onClose method when watcher is closed or when process is stopped/killed\n server.watcher.on('close', onClose)\n process.on('SIGTERM', onClose)\n process.on('SIGINT', onClose)\n\n // Run initial generation after server is ready\n const startGeneration = () => {\n setTimeout(() => {\n // Notify about typegen enabled\n output.info(logSymbols.info, 'Typegen enabled. Watching:')\n for (const pattern of queryPatterns) {\n output.info(` - ${pattern}`)\n }\n output.info(` - ${config.schema} (schema)`)\n\n // Perform first generation\n void runGeneration()\n }, INITIAL_GENERATION_DELAY_MS)\n }\n\n if (server.httpServer) {\n server.httpServer.once('listening', startGeneration)\n } else {\n // Middleware mode - no HTTP server, run generation immediately\n startGeneration()\n }\n },\n\n async buildEnd() {\n // Build mode: One-time generation with telemetry tracking\n const result = await runGeneration(true)\n\n // Only log telemetry if generation completed successfully\n if (result && telemetryLogger) {\n const trace = telemetryLogger.trace(TypesGeneratedTrace)\n trace.start()\n trace.log({\n configMethod: 'cli',\n configOverloadClientMethods: config.overloadClientMethods ?? false,\n emptyUnionTypeNodesGenerated: result.emptyUnionTypeNodesGenerated,\n filesWithErrors: result.filesWithErrors,\n outputSize: result.code.length,\n queriesCount: result.queriesCount,\n queryFilesCount: result.queryFilesCount,\n schemaTypesCount: result.schemaTypesCount,\n typeNodesGenerated: result.typeNodesGenerated,\n unknownTypeNodesGenerated: result.unknownTypeNodesGenerated,\n unknownTypeNodesRatio:\n result.typeNodesGenerated > 0\n ? result.unknownTypeNodesGenerated / result.typeNodesGenerated\n : 0,\n })\n trace.complete()\n }\n },\n } satisfies Plugin\n}\n"],"names":["existsSync","path","logSymbols","runTypegenGenerate","TypegenWatchModeTrace","TypesGeneratedTrace","debounce","mean","once","picomatch","parseTypegenConfig","toForwardSlashes","DEFAULT_DEBOUNCE_MS","INITIAL_GENERATION_DELAY_MS","sanityTypegenPlugin","options","config","inputConfig","output","console","telemetryLogger","workDir","queryPatterns","Array","isArray","resolvedSchemaPath","isGenerating","pendingGeneration","startTime","Date","now","stats","failedCount","successfulDurations","runGeneration","isBuilding","generationStartTime","error","schema","result","log","filesWithErrors","warning","generates","success","push","err","Error","message","String","debouncedGenerate","isQueryMatch","name","configResolved","rootDir","isAbsolute","join","configureServer","server","trace","start","step","absoluteQueryPatterns","map","pattern","watcher","add","handleChange","filePath","relativePath","relative","normalizedPath","onClose","cancel","averageGenerationDuration","generationFailedCount","generationSuccessfulCount","length","watcherDuration","complete","process","off","on","startGeneration","setTimeout","info","httpServer","buildEnd","configMethod","configOverloadClientMethods","overloadClientMethods","emptyUnionTypeNodesGenerated","outputSize","code","queriesCount","queryFilesCount","schemaTypesCount","typeNodesGenerated","unknownTypeNodesGenerated","unknownTypeNodesRatio"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,UAAU,YAAW;AAG5B,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SAEEC,kBAAkB,EAElBC,qBAAqB,EACrBC,mBAAmB,QACd,kBAAiB;AACxB,OAAOC,cAAc,wBAAuB;AAC5C,OAAOC,UAAU,oBAAmB;AACpC,OAAOC,UAAU,oBAAmB;AACpC,OAAOC,eAAe,YAAW;AAGjC,SAAQC,kBAAkB,QAAO,8CAA6C;AAC9E,SAAQC,gBAAgB,QAAO,iCAAgC;AAE/D,2CAA2C,GAC3C,MAAMC,sBAAsB;AAE5B;;;CAGC,GACD,MAAMC,8BAA8B;AAgCpC;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,oBAAoBC,OAA6B;I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,IAAI6C,OAAO4B,UAAU,EAAE;gBACrB5B,OAAO4B,UAAU,CAAC9E,IAAI,CAAC,aAAa2E;YACtC,OAAO;gBACL,+DAA+D;gBAC/DA;YACF;QACF;QAEA,MAAMI;YACJ,0DAA0D;YAC1D,MAAMhD,SAAS,MAAML,cAAc;YAEnC,0DAA0D;YAC1D,IAAIK,UAAUnB,iBAAiB;gBAC7B,MAAMuC,QAAQvC,gBAAgBuC,KAAK,CAACtD;gBACpCsD,MAAMC,KAAK;gBACXD,MAAMnB,GAAG,CAAC;oBACRgD,cAAc;oBACdC,6BAA6BzE,OAAO0E,qBAAqB,IAAI;oBAC7DC,8BAA8BpD,OAAOoD,4BAA4B;oBACjElD,iBAAiBF,OAAOE,eAAe;oBACvCmD,YAAYrD,OAAOsD,IAAI,CAAChB,MAAM;oBAC9BiB,cAAcvD,OAAOuD,YAAY;oBACjCC,iBAAiBxD,OAAOwD,eAAe;oBACvCC,kBAAkBzD,OAAOyD,gBAAgB;oBACzCC,oBAAoB1D,OAAO0D,kBAAkB;oBAC7CC,2BAA2B3D,OAAO2D,yBAAyB;oBAC3DC,uBACE5D,OAAO0D,kBAAkB,GAAG,IACxB1D,OAAO2D,yBAAyB,GAAG3D,OAAO0D,kBAAkB,GAC5D;gBACR;gBACAtC,MAAMoB,QAAQ;YAChB;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/vite/plugin-typegen.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport path from 'node:path'\n\nimport {type CliConfig, CLITelemetryStore} from '@sanity/cli-core'\nimport {logSymbols} from '@sanity/cli-core/ux'\nimport {\n type GenerationResult,\n runTypegenGenerate,\n type TypeGenConfig,\n TypegenWatchModeTrace,\n TypesGeneratedTrace,\n} from '@sanity/codegen'\nimport debounce from 'lodash-es/debounce.js'\nimport mean from 'lodash-es/mean.js'\nimport once from 'lodash-es/once.js'\nimport picomatch from 'picomatch'\nimport {type Plugin} from 'vite'\n\nimport {parseTypegenConfig} from '../../actions/typegen/parseTypegenConfig.js'\nimport {toForwardSlashes} from '../../util/toForwardSlashes.js'\n\n/** Default debounce delay in milliseconds */\nconst DEFAULT_DEBOUNCE_MS = 1000\n\n/**\n * Delay before initial generation to allow Vite to finish startup\n * and avoid race conditions with module resolution.\n */\nconst INITIAL_GENERATION_DELAY_MS = 1000\n\n/**\n * Options for the Sanity typegen Vite plugin.\n *\n * @internal\n */\ninterface TypegenPluginOptions {\n /**\n * Typegen configuration from sanity.cli.ts.\n * All fields are optional and will use sensible defaults.\n */\n config: Partial<TypeGenConfig> & Pick<NonNullable<CliConfig['typegen']>, 'resources'>\n\n /**\n * Working directory containing the Sanity configuration.\n * This should be the root of your Sanity Studio project.\n */\n workDir: string\n\n /**\n * Logger for output messages. Must implement `log`, `info`, and `error` methods.\n * @defaultValue `console`\n */\n output?: Pick<Console, 'error' | 'info' | 'log'>\n\n /**\n * Telemetry logger for the Sanity CLI tooling.\n */\n telemetryLogger?: CLITelemetryStore\n}\n\n/**\n * Creates a Vite plugin that automatically generates TypeScript types during development and build.\n *\n * **During development:**\n * The plugin performs an initial generation when the dev server starts, then watches\n * for file changes and re-generates types when relevant files are modified.\n *\n * **During build:**\n * The plugin generates types once at the end of the build process.\n *\n * **Prerequisites:**\n * The schema.json file must exist before typegen can run. Run `sanity schema extract`\n * first to generate the schema file.\n *\n * @param options - Configuration options for the plugin\n * @returns A Vite plugin configured for typegen\n *\n * @internal\n */\nexport function sanityTypegenPlugin(options: TypegenPluginOptions): Plugin {\n const {config: inputConfig, output = console, telemetryLogger, workDir} = options\n\n // Generating per resource is not supported here yet. Without this check the plugin would\n // generate from the top-level `schema`, which a resources config does not use.\n if (inputConfig.resources !== undefined) {\n return {\n configResolved() {\n output.log(\n logSymbols.warning,\n 'Typegen during \"sanity dev\" does not support typegen.resources yet. Run \"sanity typegen generate\" instead.',\n )\n },\n name: 'sanity/typegen',\n } satisfies Plugin\n }\n\n // Apply defaults through the same schema as `sanity typegen generate`,\n // so watch mode and manual generation produce identical output\n const config: TypeGenConfig = parseTypegenConfig(inputConfig)\n\n // Build query patterns from config\n const queryPatterns = Array.isArray(config.path) ? config.path : [config.path]\n\n // Resolved after Vite config is available\n let resolvedSchemaPath: string\n\n // State for concurrency control\n let isGenerating = false\n let pendingGeneration = false\n\n // Stats for telemetry\n const startTime = Date.now()\n const stats: {failedCount: number; successfulDurations: number[]} = {\n failedCount: 0,\n successfulDurations: [],\n }\n\n /**\n * Runs type generation with concurrency control.\n * If generation is already running, queues one more generation to run after completion.\n * Returns the generation result, or null if generation was skipped or failed.\n */\n async function runGeneration(isBuilding = false): Promise<GenerationResult | null> {\n if (isGenerating) {\n pendingGeneration = true\n return null\n }\n\n isGenerating = true\n pendingGeneration = false\n\n const generationStartTime = Date.now()\n\n try {\n // Validate schema.json exists\n if (!existsSync(resolvedSchemaPath)) {\n output.error(\n `${logSymbols.error} Schema file not found: ${config.schema}\\n` +\n `Run \"sanity schema extract\" first to generate the schema file.`,\n )\n return null\n }\n\n const result = await runTypegenGenerate({\n config,\n workDir,\n })\n\n if (isBuilding) {\n // Add newline for better formatting in build output\n output.log('')\n }\n\n if (result.filesWithErrors > 0) {\n output.log(\n logSymbols.warning,\n `Generated types to ${config.generates} (with errors in ${result.filesWithErrors} file${result.filesWithErrors === 1 ? '' : 's'})`,\n )\n } else {\n output.log(logSymbols.success, `Generated types to ${config.generates}`)\n }\n\n // Track stats for telemetry (all completed generations count as successful)\n stats.successfulDurations.push(Date.now() - generationStartTime)\n\n return result\n } catch (err) {\n output.error(\n `${logSymbols.error} Generation failed: ${err instanceof Error ? err.message : String(err)}`,\n )\n stats.failedCount++\n return null\n } finally {\n isGenerating = false\n\n // If a change came in during generation, run again\n if (pendingGeneration) {\n pendingGeneration = false\n void runGeneration()\n }\n }\n }\n\n const debouncedGenerate = debounce(() => {\n void runGeneration()\n }, DEFAULT_DEBOUNCE_MS)\n\n // Create a matcher function from query patterns\n const isQueryMatch = picomatch(queryPatterns)\n\n return {\n name: 'sanity/typegen',\n\n configResolved() {\n const rootDir = workDir\n\n resolvedSchemaPath = path.isAbsolute(config.schema)\n ? config.schema\n : path.join(rootDir, config.schema)\n },\n\n configureServer(server) {\n const trace = telemetryLogger?.trace(TypegenWatchModeTrace)\n trace?.start()\n trace?.log({step: 'started'})\n\n // Build absolute patterns for query files\n const absoluteQueryPatterns = queryPatterns.map((pattern) =>\n path.isAbsolute(pattern) ? pattern : path.join(workDir, pattern),\n )\n\n // Add query patterns AND schema.json to Vite's watcher\n server.watcher.add([...absoluteQueryPatterns, resolvedSchemaPath])\n\n // Listen for file changes\n const handleChange = (filePath: string) => {\n const relativePath = path.isAbsolute(filePath) ? path.relative(workDir, filePath) : filePath\n // Normalize to forward slashes for cross-platform picomatch compatibility\n const normalizedPath = toForwardSlashes(relativePath)\n\n // Trigger on schema.json change OR matching query file\n if (filePath === resolvedSchemaPath || isQueryMatch(normalizedPath)) {\n debouncedGenerate()\n }\n }\n\n // Prepare function to log \"stopped\" event to trace and complete the trace\n const onClose = once(() => {\n // Cancel any pending debounced extractions\n debouncedGenerate.cancel()\n\n if (trace) {\n trace.log({\n averageGenerationDuration: mean(stats.successfulDurations) || 0,\n generationFailedCount: stats.failedCount,\n generationSuccessfulCount: stats.successfulDurations.length,\n step: 'stopped',\n watcherDuration: Date.now() - startTime,\n })\n trace.complete()\n }\n\n // Clean up process listeners (must always run, not just when trace exists)\n process.off('SIGTERM', onClose)\n process.off('SIGINT', onClose)\n })\n\n server.watcher.on('change', handleChange)\n server.watcher.on('add', handleChange)\n server.watcher.on('unlink', handleChange)\n\n // Call the onClose method when watcher is closed or when process is stopped/killed\n server.watcher.on('close', onClose)\n process.on('SIGTERM', onClose)\n process.on('SIGINT', onClose)\n\n // Run initial generation after server is ready\n const startGeneration = () => {\n setTimeout(() => {\n // Notify about typegen enabled\n output.info(logSymbols.info, 'Typegen enabled. Watching:')\n for (const pattern of queryPatterns) {\n output.info(` - ${pattern}`)\n }\n output.info(` - ${config.schema} (schema)`)\n\n // Perform first generation\n void runGeneration()\n }, INITIAL_GENERATION_DELAY_MS)\n }\n\n if (server.httpServer) {\n server.httpServer.once('listening', startGeneration)\n } else {\n // Middleware mode - no HTTP server, run generation immediately\n startGeneration()\n }\n },\n\n async buildEnd() {\n // Build mode: One-time generation with telemetry tracking\n const result = await runGeneration(true)\n\n // Only log telemetry if generation completed successfully\n if (result && telemetryLogger) {\n const trace = telemetryLogger.trace(TypesGeneratedTrace)\n trace.start()\n trace.log({\n configMethod: 'cli',\n configOverloadClientMethods: config.overloadClientMethods ?? false,\n emptyUnionTypeNodesGenerated: result.emptyUnionTypeNodesGenerated,\n filesWithErrors: result.filesWithErrors,\n outputSize: result.code.length,\n queriesCount: result.queriesCount,\n queryFilesCount: result.queryFilesCount,\n schemaTypesCount: result.schemaTypesCount,\n typeNodesGenerated: result.typeNodesGenerated,\n unknownTypeNodesGenerated: result.unknownTypeNodesGenerated,\n unknownTypeNodesRatio:\n result.typeNodesGenerated > 0\n ? result.unknownTypeNodesGenerated / result.typeNodesGenerated\n : 0,\n })\n trace.complete()\n }\n },\n } satisfies Plugin\n}\n"],"names":["existsSync","path","logSymbols","runTypegenGenerate","TypegenWatchModeTrace","TypesGeneratedTrace","debounce","mean","once","picomatch","parseTypegenConfig","toForwardSlashes","DEFAULT_DEBOUNCE_MS","INITIAL_GENERATION_DELAY_MS","sanityTypegenPlugin","options","config","inputConfig","output","console","telemetryLogger","workDir","resources","undefined","configResolved","log","warning","name","queryPatterns","Array","isArray","resolvedSchemaPath","isGenerating","pendingGeneration","startTime","Date","now","stats","failedCount","successfulDurations","runGeneration","isBuilding","generationStartTime","error","schema","result","filesWithErrors","generates","success","push","err","Error","message","String","debouncedGenerate","isQueryMatch","rootDir","isAbsolute","join","configureServer","server","trace","start","step","absoluteQueryPatterns","map","pattern","watcher","add","handleChange","filePath","relativePath","relative","normalizedPath","onClose","cancel","averageGenerationDuration","generationFailedCount","generationSuccessfulCount","length","watcherDuration","complete","process","off","on","startGeneration","setTimeout","info","httpServer","buildEnd","configMethod","configOverloadClientMethods","overloadClientMethods","emptyUnionTypeNodesGenerated","outputSize","code","queriesCount","queryFilesCount","schemaTypesCount","typeNodesGenerated","unknownTypeNodesGenerated","unknownTypeNodesRatio"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,UAAU,YAAW;AAG5B,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SAEEC,kBAAkB,EAElBC,qBAAqB,EACrBC,mBAAmB,QACd,kBAAiB;AACxB,OAAOC,cAAc,wBAAuB;AAC5C,OAAOC,UAAU,oBAAmB;AACpC,OAAOC,UAAU,oBAAmB;AACpC,OAAOC,eAAe,YAAW;AAGjC,SAAQC,kBAAkB,QAAO,8CAA6C;AAC9E,SAAQC,gBAAgB,QAAO,iCAAgC;AAE/D,2CAA2C,GAC3C,MAAMC,sBAAsB;AAE5B;;;CAGC,GACD,MAAMC,8BAA8B;AAgCpC;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,oBAAoBC,OAA6B;IAC/D,MAAM,EAACC,QAAQC,WAAW,EAAEC,SAASC,OAAO,EAAEC,eAAe,EAAEC,OAAO,EAAC,GAAGN;IAE1E,yFAAyF;IACzF,+EAA+E;IAC/E,IAAIE,YAAYK,SAAS,KAAKC,WAAW;QACvC,OAAO;YACLC;gBACEN,OAAOO,GAAG,CACRvB,WAAWwB,OAAO,EAClB;YAEJ;YACAC,MAAM;QACR;IACF;IAEA,uEAAuE;IACvE,+DAA+D;IAC/D,MAAMX,SAAwBN,mBAAmBO;IAEjD,mCAAmC;IACnC,MAAMW,gBAAgBC,MAAMC,OAAO,CAACd,OAAOf,IAAI,IAAIe,OAAOf,IAAI,GAAG;QAACe,OAAOf,IAAI;KAAC;IAE9E,0CAA0C;IAC1C,IAAI8B;IAEJ,gCAAgC;IAChC,IAAIC,eAAe;IACnB,IAAIC,oBAAoB;IAExB,sBAAsB;IACtB,MAAMC,YAAYC,KAAKC,GAAG;I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B;oBACjE/C,iBAAiBD,OAAOC,eAAe;oBACvCgD,YAAYjD,OAAOkD,IAAI,CAAChB,MAAM;oBAC9BiB,cAAcnD,OAAOmD,YAAY;oBACjCC,iBAAiBpD,OAAOoD,eAAe;oBACvCC,kBAAkBrD,OAAOqD,gBAAgB;oBACzCC,oBAAoBtD,OAAOsD,kBAAkB;oBAC7CC,2BAA2BvD,OAAOuD,yBAAyB;oBAC3DC,uBACExD,OAAOsD,kBAAkB,GAAG,IACxBtD,OAAOuD,yBAAyB,GAAGvD,OAAOsD,kBAAkB,GAC5D;gBACR;gBACAtC,MAAMoB,QAAQ;YAChB;QACF;IACF;AACF"}
|
package/dist/services/schemas.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getGlobalCliClient } from '@sanity/cli-core';
|
|
2
|
+
import { EXPERIMENTAL_API_WARNING, isHttpError } from '@sanity/client';
|
|
2
3
|
export const SCHEMA_API_VERSION = 'v2025-03-01';
|
|
4
|
+
/** The dataset schema binding endpoint is only available on the experimental API version. */ export const SCHEMA_BINDING_API_VERSION = 'vX';
|
|
5
|
+
export const SCHEMA_DESCRIPTOR_API_VERSION = 'v2025-06-01';
|
|
3
6
|
async function getSchemaClient() {
|
|
4
7
|
return await getGlobalCliClient({
|
|
5
8
|
apiVersion: SCHEMA_API_VERSION,
|
|
@@ -26,6 +29,39 @@ export async function deleteSchema(dataset, projectId, id) {
|
|
|
26
29
|
url: `/projects/${projectId}/datasets/${dataset}/schemas/${id}`
|
|
27
30
|
});
|
|
28
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the schema bound to a dataset, or `null` when the dataset has no binding.
|
|
34
|
+
*/ export async function getDatasetSchemaBinding(projectId, dataset) {
|
|
35
|
+
const client = await getGlobalCliClient({
|
|
36
|
+
apiVersion: SCHEMA_BINDING_API_VERSION,
|
|
37
|
+
// The endpoint has no stable version yet, and the warning would interrupt command output.
|
|
38
|
+
// The client splits the warning header on commas, so its second clause is matched separately.
|
|
39
|
+
ignoreWarnings: [
|
|
40
|
+
EXPERIMENTAL_API_WARNING,
|
|
41
|
+
'which will change without warning'
|
|
42
|
+
],
|
|
43
|
+
requireUser: true
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
return await client.request({
|
|
47
|
+
url: `/schemas/dataset/${encodeURIComponent(`${projectId}.${dataset}`)}`
|
|
48
|
+
});
|
|
49
|
+
} catch (err) {
|
|
50
|
+
if (isHttpError(err) && err.statusCode === 404) return null;
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets a schema descriptor from Lexicon by its ID, such as a binding's `schemaVersion`.
|
|
56
|
+
*/ export async function getSchemaDescriptor(id) {
|
|
57
|
+
const client = await getGlobalCliClient({
|
|
58
|
+
apiVersion: SCHEMA_DESCRIPTOR_API_VERSION,
|
|
59
|
+
requireUser: true
|
|
60
|
+
});
|
|
61
|
+
return client.request({
|
|
62
|
+
url: `/descriptors/schemas/${encodeURIComponent(id)}`
|
|
63
|
+
});
|
|
64
|
+
}
|
|
29
65
|
export async function updateSchemas(dataset, projectId, schemas) {
|
|
30
66
|
const client = await getSchemaClient();
|
|
31
67
|
return client.request({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/schemas.ts"],"sourcesContent":["import {type StoredWorkspaceSchema} from '@sanity/cli-build/_internal/manifest'\nimport {getGlobalCliClient} from '@sanity/cli-core'\n\nexport const SCHEMA_API_VERSION = 'v2025-03-01'\n\nasync function getSchemaClient() {\n return await getGlobalCliClient({\n apiVersion: SCHEMA_API_VERSION,\n requireUser: true,\n })\n}\n\nexport async function getSchemas(dataset: string, projectId: string, id?: string) {\n const client = await getSchemaClient()\n\n return client.request<StoredWorkspaceSchema[]>({\n method: 'GET',\n url: `/projects/${projectId}/datasets/${dataset}/schemas${id ? `/${id}` : ''}`,\n })\n}\n\nexport async function deleteSchema(dataset: string, projectId: string, id: string) {\n const exists = await getSchemas(dataset, projectId, id)\n\n if (exists?.length === 0) {\n return {\n deleted: false,\n }\n }\n\n const client = await getSchemaClient()\n\n return client.request({\n method: 'DELETE',\n url: `/projects/${projectId}/datasets/${dataset}/schemas/${id}`,\n })\n}\n\nexport async function updateSchemas<T>(dataset: string, projectId: string, schemas: T) {\n const client = await getSchemaClient()\n\n return client.request({\n body: {\n schemas,\n },\n method: 'PUT',\n url: `/projects/${projectId}/datasets/${dataset}/schemas`,\n })\n}\n"],"names":["getGlobalCliClient","SCHEMA_API_VERSION","getSchemaClient","apiVersion","requireUser","getSchemas","dataset","projectId","id","client","request","method","url","deleteSchema","exists","length","deleted","updateSchemas","schemas","body"],"mappings":"AACA,SAAQA,kBAAkB,QAAO,mBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../src/services/schemas.ts"],"sourcesContent":["import {type StoredWorkspaceSchema} from '@sanity/cli-build/_internal/manifest'\nimport {getGlobalCliClient} from '@sanity/cli-core'\nimport {EXPERIMENTAL_API_WARNING, isHttpError} from '@sanity/client'\nimport {type SchemaSummary} from '@sanity/schema-descriptor-utils'\n\nexport const SCHEMA_API_VERSION = 'v2025-03-01'\n\n/** The dataset schema binding endpoint is only available on the experimental API version. */\nexport const SCHEMA_BINDING_API_VERSION = 'vX'\n\nexport const SCHEMA_DESCRIPTOR_API_VERSION = 'v2025-06-01'\n\n/**\n * The schema bound to a dataset, as returned by `GET /schemas/dataset/:projectId.:dataset`.\n * Only `_meta` is used: its `types` are hydrated for display and cannot be compiled.\n */\nexport interface DatasetSchemaBinding {\n _meta: {\n producer: 'api' | 'blueprint' | 'mcp' | 'studio'\n /** The Lexicon descriptor ID of the bound schema. Also returned as the `ETag`. */\n schemaVersion: string\n source: string | null\n sourceLabel: string | null\n }\n name: string\n}\n\nasync function getSchemaClient() {\n return await getGlobalCliClient({\n apiVersion: SCHEMA_API_VERSION,\n requireUser: true,\n })\n}\n\nexport async function getSchemas(dataset: string, projectId: string, id?: string) {\n const client = await getSchemaClient()\n\n return client.request<StoredWorkspaceSchema[]>({\n method: 'GET',\n url: `/projects/${projectId}/datasets/${dataset}/schemas${id ? `/${id}` : ''}`,\n })\n}\n\nexport async function deleteSchema(dataset: string, projectId: string, id: string) {\n const exists = await getSchemas(dataset, projectId, id)\n\n if (exists?.length === 0) {\n return {\n deleted: false,\n }\n }\n\n const client = await getSchemaClient()\n\n return client.request({\n method: 'DELETE',\n url: `/projects/${projectId}/datasets/${dataset}/schemas/${id}`,\n })\n}\n\n/**\n * Gets the schema bound to a dataset, or `null` when the dataset has no binding.\n */\nexport async function getDatasetSchemaBinding(\n projectId: string,\n dataset: string,\n): Promise<DatasetSchemaBinding | null> {\n const client = await getGlobalCliClient({\n apiVersion: SCHEMA_BINDING_API_VERSION,\n // The endpoint has no stable version yet, and the warning would interrupt command output.\n // The client splits the warning header on commas, so its second clause is matched separately.\n ignoreWarnings: [EXPERIMENTAL_API_WARNING, 'which will change without warning'],\n requireUser: true,\n })\n\n try {\n return await client.request<DatasetSchemaBinding>({\n url: `/schemas/dataset/${encodeURIComponent(`${projectId}.${dataset}`)}`,\n })\n } catch (err) {\n if (isHttpError(err) && err.statusCode === 404) return null\n throw err\n }\n}\n\n/**\n * Gets a schema descriptor from Lexicon by its ID, such as a binding's `schemaVersion`.\n */\nexport async function getSchemaDescriptor(id: string): Promise<SchemaSummary> {\n const client = await getGlobalCliClient({\n apiVersion: SCHEMA_DESCRIPTOR_API_VERSION,\n requireUser: true,\n })\n\n return client.request<SchemaSummary>({\n url: `/descriptors/schemas/${encodeURIComponent(id)}`,\n })\n}\n\nexport async function updateSchemas<T>(dataset: string, projectId: string, schemas: T) {\n const client = await getSchemaClient()\n\n return client.request({\n body: {\n schemas,\n },\n method: 'PUT',\n url: `/projects/${projectId}/datasets/${dataset}/schemas`,\n })\n}\n"],"names":["getGlobalCliClient","EXPERIMENTAL_API_WARNING","isHttpError","SCHEMA_API_VERSION","SCHEMA_BINDING_API_VERSION","SCHEMA_DESCRIPTOR_API_VERSION","getSchemaClient","apiVersion","requireUser","getSchemas","dataset","projectId","id","client","request","method","url","deleteSchema","exists","length","deleted","getDatasetSchemaBinding","ignoreWarnings","encodeURIComponent","err","statusCode","getSchemaDescriptor","updateSchemas","schemas","body"],"mappings":"AACA,SAAQA,kBAAkB,QAAO,mBAAkB;AACnD,SAAQC,wBAAwB,EAAEC,WAAW,QAAO,iBAAgB;AAGpE,OAAO,MAAMC,qBAAqB,cAAa;AAE/C,2FAA2F,GAC3F,OAAO,MAAMC,6BAA6B,KAAI;AAE9C,OAAO,MAAMC,gCAAgC,cAAa;AAiB1D,eAAeC;IACb,OAAO,MAAMN,mBAAmB;QAC9BO,YAAYJ;QACZK,aAAa;IACf;AACF;AAEA,OAAO,eAAeC,WAAWC,OAAe,EAAEC,SAAiB,EAAEC,EAAW;IAC9E,MAAMC,SAAS,MAAMP;IAErB,OAAOO,OAAOC,OAAO,CAA0B;QAC7CC,QAAQ;QACRC,KAAK,CAAC,UAAU,EAAEL,UAAU,UAAU,EAAED,QAAQ,QAAQ,EAAEE,KAAK,CAAC,CAAC,EAAEA,IAAI,GAAG,IAAI;IAChF;AACF;AAEA,OAAO,eAAeK,aAAaP,OAAe,EAAEC,SAAiB,EAAEC,EAAU;IAC/E,MAAMM,SAAS,MAAMT,WAAWC,SAASC,WAAWC;IAEpD,IAAIM,QAAQC,WAAW,GAAG;QACxB,OAAO;YACLC,SAAS;QACX;IACF;IAEA,MAAMP,SAAS,MAAMP;IAErB,OAAOO,OAAOC,OAAO,CAAC;QACpBC,QAAQ;QACRC,KAAK,CAAC,UAAU,EAAEL,UAAU,UAAU,EAAED,QAAQ,SAAS,EAAEE,IAAI;IACjE;AACF;AAEA;;CAEC,GACD,OAAO,eAAeS,wBACpBV,SAAiB,EACjBD,OAAe;IAEf,MAAMG,SAAS,MAAMb,mBAAmB;QACtCO,YAAYH;QACZ,0FAA0F;QAC1F,8FAA8F;QAC9FkB,gBAAgB;YAACrB;YAA0B;SAAoC;QAC/EO,aAAa;IACf;IAEA,IAAI;QACF,OAAO,MAAMK,OAAOC,OAAO,CAAuB;YAChDE,KAAK,CAAC,iBAAiB,EAAEO,mBAAmB,GAAGZ,UAAU,CAAC,EAAED,SAAS,GAAG;QAC1E;IACF,EAAE,OAAOc,KAAK;QACZ,IAAItB,YAAYsB,QAAQA,IAAIC,UAAU,KAAK,KAAK,OAAO;QACvD,MAAMD;IACR;AACF;AAEA;;CAEC,GACD,OAAO,eAAeE,oBAAoBd,EAAU;IAClD,MAAMC,SAAS,MAAMb,mBAAmB;QACtCO,YAAYF;QACZG,aAAa;IACf;IAEA,OAAOK,OAAOC,OAAO,CAAgB;QACnCE,KAAK,CAAC,qBAAqB,EAAEO,mBAAmBX,KAAK;IACvD;AACF;AAEA,OAAO,eAAee,cAAiBjB,OAAe,EAAEC,SAAiB,EAAEiB,OAAU;IACnF,MAAMf,SAAS,MAAMP;IAErB,OAAOO,OAAOC,OAAO,CAAC;QACpBe,MAAM;YACJD;QACF;QACAb,QAAQ;QACRC,KAAK,CAAC,UAAU,EAAEL,UAAU,UAAU,EAAED,QAAQ,QAAQ,CAAC;IAC3D;AACF"}
|
package/oclif.manifest.json
CHANGED
|
@@ -1773,6 +1773,167 @@
|
|
|
1773
1773
|
"list.js"
|
|
1774
1774
|
]
|
|
1775
1775
|
},
|
|
1776
|
+
"cors:add": {
|
|
1777
|
+
"aliases": [],
|
|
1778
|
+
"args": {
|
|
1779
|
+
"origin": {
|
|
1780
|
+
"description": "Origin to allow (e.g., https://example.com)",
|
|
1781
|
+
"name": "origin",
|
|
1782
|
+
"required": true
|
|
1783
|
+
}
|
|
1784
|
+
},
|
|
1785
|
+
"description": "Add a CORS origin to the project",
|
|
1786
|
+
"examples": [
|
|
1787
|
+
{
|
|
1788
|
+
"command": "<%= config.bin %> <%= command.id %>",
|
|
1789
|
+
"description": "Interactively add a CORS origin"
|
|
1790
|
+
},
|
|
1791
|
+
{
|
|
1792
|
+
"command": "<%= config.bin %> <%= command.id %> http://localhost:3000 --no-credentials",
|
|
1793
|
+
"description": "Add a localhost origin without credentials"
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
"command": "<%= config.bin %> <%= command.id %> https://myapp.com --credentials",
|
|
1797
|
+
"description": "Add a production origin with credentials allowed"
|
|
1798
|
+
},
|
|
1799
|
+
{
|
|
1800
|
+
"command": "<%= config.bin %> <%= command.id %> https://myapp.com --project-id abc123",
|
|
1801
|
+
"description": "Add a CORS origin for a specific project"
|
|
1802
|
+
}
|
|
1803
|
+
],
|
|
1804
|
+
"flags": {
|
|
1805
|
+
"project-id": {
|
|
1806
|
+
"char": "p",
|
|
1807
|
+
"description": "Project ID to add CORS origin to (overrides CLI configuration)",
|
|
1808
|
+
"helpGroup": "OVERRIDE",
|
|
1809
|
+
"name": "project-id",
|
|
1810
|
+
"hasDynamicHelp": false,
|
|
1811
|
+
"helpValue": "<id>",
|
|
1812
|
+
"multiple": false,
|
|
1813
|
+
"type": "option"
|
|
1814
|
+
},
|
|
1815
|
+
"credentials": {
|
|
1816
|
+
"description": "Allow credentials (token/cookie) to be sent from this origin",
|
|
1817
|
+
"name": "credentials",
|
|
1818
|
+
"required": false,
|
|
1819
|
+
"allowNo": true,
|
|
1820
|
+
"type": "boolean"
|
|
1821
|
+
},
|
|
1822
|
+
"yes": {
|
|
1823
|
+
"char": "y",
|
|
1824
|
+
"description": "Confirm risky wildcard origins without prompting",
|
|
1825
|
+
"name": "yes",
|
|
1826
|
+
"allowNo": false,
|
|
1827
|
+
"type": "boolean"
|
|
1828
|
+
}
|
|
1829
|
+
},
|
|
1830
|
+
"hasDynamicHelp": false,
|
|
1831
|
+
"hiddenAliases": [],
|
|
1832
|
+
"id": "cors:add",
|
|
1833
|
+
"pluginAlias": "@sanity/cli",
|
|
1834
|
+
"pluginName": "@sanity/cli",
|
|
1835
|
+
"pluginType": "core",
|
|
1836
|
+
"strict": true,
|
|
1837
|
+
"isESM": true,
|
|
1838
|
+
"relativePath": [
|
|
1839
|
+
"dist",
|
|
1840
|
+
"commands",
|
|
1841
|
+
"cors",
|
|
1842
|
+
"add.js"
|
|
1843
|
+
]
|
|
1844
|
+
},
|
|
1845
|
+
"cors:delete": {
|
|
1846
|
+
"aliases": [],
|
|
1847
|
+
"args": {
|
|
1848
|
+
"origin": {
|
|
1849
|
+
"description": "Origin to delete (will prompt if not provided)",
|
|
1850
|
+
"name": "origin",
|
|
1851
|
+
"required": false
|
|
1852
|
+
}
|
|
1853
|
+
},
|
|
1854
|
+
"description": "Delete a CORS origin from the project",
|
|
1855
|
+
"examples": [
|
|
1856
|
+
{
|
|
1857
|
+
"command": "<%= config.bin %> <%= command.id %>",
|
|
1858
|
+
"description": "Interactively select and delete a CORS origin"
|
|
1859
|
+
},
|
|
1860
|
+
{
|
|
1861
|
+
"command": "<%= config.bin %> <%= command.id %> https://example.com",
|
|
1862
|
+
"description": "Delete a specific CORS origin"
|
|
1863
|
+
},
|
|
1864
|
+
{
|
|
1865
|
+
"command": "<%= config.bin %> <%= command.id %> --project-id abc123",
|
|
1866
|
+
"description": "Delete a CORS origin from a specific project"
|
|
1867
|
+
}
|
|
1868
|
+
],
|
|
1869
|
+
"flags": {
|
|
1870
|
+
"project-id": {
|
|
1871
|
+
"char": "p",
|
|
1872
|
+
"description": "Project ID to delete CORS origin from (overrides CLI configuration)",
|
|
1873
|
+
"helpGroup": "OVERRIDE",
|
|
1874
|
+
"name": "project-id",
|
|
1875
|
+
"hasDynamicHelp": false,
|
|
1876
|
+
"helpValue": "<id>",
|
|
1877
|
+
"multiple": false,
|
|
1878
|
+
"type": "option"
|
|
1879
|
+
}
|
|
1880
|
+
},
|
|
1881
|
+
"hasDynamicHelp": false,
|
|
1882
|
+
"hiddenAliases": [],
|
|
1883
|
+
"id": "cors:delete",
|
|
1884
|
+
"pluginAlias": "@sanity/cli",
|
|
1885
|
+
"pluginName": "@sanity/cli",
|
|
1886
|
+
"pluginType": "core",
|
|
1887
|
+
"strict": true,
|
|
1888
|
+
"isESM": true,
|
|
1889
|
+
"relativePath": [
|
|
1890
|
+
"dist",
|
|
1891
|
+
"commands",
|
|
1892
|
+
"cors",
|
|
1893
|
+
"delete.js"
|
|
1894
|
+
]
|
|
1895
|
+
},
|
|
1896
|
+
"cors:list": {
|
|
1897
|
+
"aliases": [],
|
|
1898
|
+
"args": {},
|
|
1899
|
+
"description": "List CORS origins for the project",
|
|
1900
|
+
"examples": [
|
|
1901
|
+
{
|
|
1902
|
+
"command": "<%= config.bin %> <%= command.id %>",
|
|
1903
|
+
"description": "List CORS origins for the project"
|
|
1904
|
+
},
|
|
1905
|
+
{
|
|
1906
|
+
"command": "<%= config.bin %> <%= command.id %> --project-id abc123",
|
|
1907
|
+
"description": "List CORS origins for a specific project"
|
|
1908
|
+
}
|
|
1909
|
+
],
|
|
1910
|
+
"flags": {
|
|
1911
|
+
"project-id": {
|
|
1912
|
+
"char": "p",
|
|
1913
|
+
"description": "Project ID to list CORS origins for (overrides CLI configuration)",
|
|
1914
|
+
"helpGroup": "OVERRIDE",
|
|
1915
|
+
"name": "project-id",
|
|
1916
|
+
"hasDynamicHelp": false,
|
|
1917
|
+
"helpValue": "<id>",
|
|
1918
|
+
"multiple": false,
|
|
1919
|
+
"type": "option"
|
|
1920
|
+
}
|
|
1921
|
+
},
|
|
1922
|
+
"hasDynamicHelp": false,
|
|
1923
|
+
"hiddenAliases": [],
|
|
1924
|
+
"id": "cors:list",
|
|
1925
|
+
"pluginAlias": "@sanity/cli",
|
|
1926
|
+
"pluginName": "@sanity/cli",
|
|
1927
|
+
"pluginType": "core",
|
|
1928
|
+
"strict": true,
|
|
1929
|
+
"isESM": true,
|
|
1930
|
+
"relativePath": [
|
|
1931
|
+
"dist",
|
|
1932
|
+
"commands",
|
|
1933
|
+
"cors",
|
|
1934
|
+
"list.js"
|
|
1935
|
+
]
|
|
1936
|
+
},
|
|
1776
1937
|
"context:build": {
|
|
1777
1938
|
"aliases": [],
|
|
1778
1939
|
"args": {
|
|
@@ -2160,167 +2321,6 @@
|
|
|
2160
2321
|
"update.js"
|
|
2161
2322
|
]
|
|
2162
2323
|
},
|
|
2163
|
-
"cors:add": {
|
|
2164
|
-
"aliases": [],
|
|
2165
|
-
"args": {
|
|
2166
|
-
"origin": {
|
|
2167
|
-
"description": "Origin to allow (e.g., https://example.com)",
|
|
2168
|
-
"name": "origin",
|
|
2169
|
-
"required": true
|
|
2170
|
-
}
|
|
2171
|
-
},
|
|
2172
|
-
"description": "Add a CORS origin to the project",
|
|
2173
|
-
"examples": [
|
|
2174
|
-
{
|
|
2175
|
-
"command": "<%= config.bin %> <%= command.id %>",
|
|
2176
|
-
"description": "Interactively add a CORS origin"
|
|
2177
|
-
},
|
|
2178
|
-
{
|
|
2179
|
-
"command": "<%= config.bin %> <%= command.id %> http://localhost:3000 --no-credentials",
|
|
2180
|
-
"description": "Add a localhost origin without credentials"
|
|
2181
|
-
},
|
|
2182
|
-
{
|
|
2183
|
-
"command": "<%= config.bin %> <%= command.id %> https://myapp.com --credentials",
|
|
2184
|
-
"description": "Add a production origin with credentials allowed"
|
|
2185
|
-
},
|
|
2186
|
-
{
|
|
2187
|
-
"command": "<%= config.bin %> <%= command.id %> https://myapp.com --project-id abc123",
|
|
2188
|
-
"description": "Add a CORS origin for a specific project"
|
|
2189
|
-
}
|
|
2190
|
-
],
|
|
2191
|
-
"flags": {
|
|
2192
|
-
"project-id": {
|
|
2193
|
-
"char": "p",
|
|
2194
|
-
"description": "Project ID to add CORS origin to (overrides CLI configuration)",
|
|
2195
|
-
"helpGroup": "OVERRIDE",
|
|
2196
|
-
"name": "project-id",
|
|
2197
|
-
"hasDynamicHelp": false,
|
|
2198
|
-
"helpValue": "<id>",
|
|
2199
|
-
"multiple": false,
|
|
2200
|
-
"type": "option"
|
|
2201
|
-
},
|
|
2202
|
-
"credentials": {
|
|
2203
|
-
"description": "Allow credentials (token/cookie) to be sent from this origin",
|
|
2204
|
-
"name": "credentials",
|
|
2205
|
-
"required": false,
|
|
2206
|
-
"allowNo": true,
|
|
2207
|
-
"type": "boolean"
|
|
2208
|
-
},
|
|
2209
|
-
"yes": {
|
|
2210
|
-
"char": "y",
|
|
2211
|
-
"description": "Confirm risky wildcard origins without prompting",
|
|
2212
|
-
"name": "yes",
|
|
2213
|
-
"allowNo": false,
|
|
2214
|
-
"type": "boolean"
|
|
2215
|
-
}
|
|
2216
|
-
},
|
|
2217
|
-
"hasDynamicHelp": false,
|
|
2218
|
-
"hiddenAliases": [],
|
|
2219
|
-
"id": "cors:add",
|
|
2220
|
-
"pluginAlias": "@sanity/cli",
|
|
2221
|
-
"pluginName": "@sanity/cli",
|
|
2222
|
-
"pluginType": "core",
|
|
2223
|
-
"strict": true,
|
|
2224
|
-
"isESM": true,
|
|
2225
|
-
"relativePath": [
|
|
2226
|
-
"dist",
|
|
2227
|
-
"commands",
|
|
2228
|
-
"cors",
|
|
2229
|
-
"add.js"
|
|
2230
|
-
]
|
|
2231
|
-
},
|
|
2232
|
-
"cors:delete": {
|
|
2233
|
-
"aliases": [],
|
|
2234
|
-
"args": {
|
|
2235
|
-
"origin": {
|
|
2236
|
-
"description": "Origin to delete (will prompt if not provided)",
|
|
2237
|
-
"name": "origin",
|
|
2238
|
-
"required": false
|
|
2239
|
-
}
|
|
2240
|
-
},
|
|
2241
|
-
"description": "Delete a CORS origin from the project",
|
|
2242
|
-
"examples": [
|
|
2243
|
-
{
|
|
2244
|
-
"command": "<%= config.bin %> <%= command.id %>",
|
|
2245
|
-
"description": "Interactively select and delete a CORS origin"
|
|
2246
|
-
},
|
|
2247
|
-
{
|
|
2248
|
-
"command": "<%= config.bin %> <%= command.id %> https://example.com",
|
|
2249
|
-
"description": "Delete a specific CORS origin"
|
|
2250
|
-
},
|
|
2251
|
-
{
|
|
2252
|
-
"command": "<%= config.bin %> <%= command.id %> --project-id abc123",
|
|
2253
|
-
"description": "Delete a CORS origin from a specific project"
|
|
2254
|
-
}
|
|
2255
|
-
],
|
|
2256
|
-
"flags": {
|
|
2257
|
-
"project-id": {
|
|
2258
|
-
"char": "p",
|
|
2259
|
-
"description": "Project ID to delete CORS origin from (overrides CLI configuration)",
|
|
2260
|
-
"helpGroup": "OVERRIDE",
|
|
2261
|
-
"name": "project-id",
|
|
2262
|
-
"hasDynamicHelp": false,
|
|
2263
|
-
"helpValue": "<id>",
|
|
2264
|
-
"multiple": false,
|
|
2265
|
-
"type": "option"
|
|
2266
|
-
}
|
|
2267
|
-
},
|
|
2268
|
-
"hasDynamicHelp": false,
|
|
2269
|
-
"hiddenAliases": [],
|
|
2270
|
-
"id": "cors:delete",
|
|
2271
|
-
"pluginAlias": "@sanity/cli",
|
|
2272
|
-
"pluginName": "@sanity/cli",
|
|
2273
|
-
"pluginType": "core",
|
|
2274
|
-
"strict": true,
|
|
2275
|
-
"isESM": true,
|
|
2276
|
-
"relativePath": [
|
|
2277
|
-
"dist",
|
|
2278
|
-
"commands",
|
|
2279
|
-
"cors",
|
|
2280
|
-
"delete.js"
|
|
2281
|
-
]
|
|
2282
|
-
},
|
|
2283
|
-
"cors:list": {
|
|
2284
|
-
"aliases": [],
|
|
2285
|
-
"args": {},
|
|
2286
|
-
"description": "List CORS origins for the project",
|
|
2287
|
-
"examples": [
|
|
2288
|
-
{
|
|
2289
|
-
"command": "<%= config.bin %> <%= command.id %>",
|
|
2290
|
-
"description": "List CORS origins for the project"
|
|
2291
|
-
},
|
|
2292
|
-
{
|
|
2293
|
-
"command": "<%= config.bin %> <%= command.id %> --project-id abc123",
|
|
2294
|
-
"description": "List CORS origins for a specific project"
|
|
2295
|
-
}
|
|
2296
|
-
],
|
|
2297
|
-
"flags": {
|
|
2298
|
-
"project-id": {
|
|
2299
|
-
"char": "p",
|
|
2300
|
-
"description": "Project ID to list CORS origins for (overrides CLI configuration)",
|
|
2301
|
-
"helpGroup": "OVERRIDE",
|
|
2302
|
-
"name": "project-id",
|
|
2303
|
-
"hasDynamicHelp": false,
|
|
2304
|
-
"helpValue": "<id>",
|
|
2305
|
-
"multiple": false,
|
|
2306
|
-
"type": "option"
|
|
2307
|
-
}
|
|
2308
|
-
},
|
|
2309
|
-
"hasDynamicHelp": false,
|
|
2310
|
-
"hiddenAliases": [],
|
|
2311
|
-
"id": "cors:list",
|
|
2312
|
-
"pluginAlias": "@sanity/cli",
|
|
2313
|
-
"pluginName": "@sanity/cli",
|
|
2314
|
-
"pluginType": "core",
|
|
2315
|
-
"strict": true,
|
|
2316
|
-
"isESM": true,
|
|
2317
|
-
"relativePath": [
|
|
2318
|
-
"dist",
|
|
2319
|
-
"commands",
|
|
2320
|
-
"cors",
|
|
2321
|
-
"list.js"
|
|
2322
|
-
]
|
|
2323
|
-
},
|
|
2324
2324
|
"datasets:copy": {
|
|
2325
2325
|
"aliases": [],
|
|
2326
2326
|
"args": {
|
|
@@ -5927,7 +5927,7 @@
|
|
|
5927
5927
|
"typegen:generate": {
|
|
5928
5928
|
"aliases": [],
|
|
5929
5929
|
"args": {},
|
|
5930
|
-
"description": "Sanity TypeGen\n\nConfiguration:\nThis command can utilize configuration settings defined in a `sanity-typegen.json` file. These settings include:\n\n- \"path\": Specifies a glob pattern to locate your TypeScript or JavaScript files.\n Default: \"./src/**/*.{ts,tsx,js,jsx}\"\n\n- \"schema\": Defines the path to your Sanity schema file. This file should be generated using the `sanity schema extract` command.\n Default: \"schema.json\"\n\n- \"generates\": Indicates the path where the generated TypeScript type definitions will be saved.\n Default: \"./sanity.types.ts\"\n\nThe default configuration values listed above are used if not overridden in your `sanity-typegen.json` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.\n\nNote:\n- The `sanity schema extract` command is a prerequisite for extracting your Sanity Studio schema into a `schema.json` file, which is then used by the `sanity typegen generate` command to generate type definitions.",
|
|
5930
|
+
"description": "Sanity TypeGen\n\nConfiguration:\nThis command can utilize configuration settings defined in a `sanity-typegen.json` file. These settings include:\n\n- \"path\": Specifies a glob pattern to locate your TypeScript or JavaScript files.\n Default: \"./src/**/*.{ts,tsx,js,jsx}\"\n\n- \"schema\": Defines the path to your Sanity schema file. This file should be generated using the `sanity schema extract` command.\n Default: \"schema.json\"\n\n- \"generates\": Indicates the path where the generated TypeScript type definitions will be saved.\n Default: \"./sanity.types.ts\"\n\nThe default configuration values listed above are used if not overridden in your `sanity-typegen.json` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.\n\nNote:\n- The `sanity schema extract` command is a prerequisite for extracting your Sanity Studio schema into a `schema.json` file, which is then used by the `sanity typegen generate` command to generate type definitions.\n- To generate types for several datasets, list them in `typegen.resources` in `sanity.cli.ts` (beta). Each resource uses its own `schema` file, or the schema bound to its dataset when `schema` is omitted.",
|
|
5931
5931
|
"examples": [
|
|
5932
5932
|
{
|
|
5933
5933
|
"command": "<%= config.bin %> <%= command.id %>",
|
|
@@ -7055,5 +7055,5 @@
|
|
|
7055
7055
|
]
|
|
7056
7056
|
}
|
|
7057
7057
|
},
|
|
7058
|
-
"version": "8.
|
|
7058
|
+
"version": "8.16.0"
|
|
7059
7059
|
}
|