Skip to content

Commit

Permalink
feat: refactor to use compiled schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sgulseth committed Mar 11, 2024
1 parent 0d38a52 commit 4afe4ab
Show file tree
Hide file tree
Showing 19 changed files with 3,628 additions and 1,873 deletions.
857 changes: 332 additions & 525 deletions packages/@sanity/schema/src/sanity/extractSchema.ts

Large diffs are not rendered by default.

3,708 changes: 2,533 additions & 1,175 deletions packages/@sanity/schema/test/extractSchema/__snapshots__/extractSchema.test.ts.snap

Large diffs are not rendered by default.

432 changes: 331 additions & 101 deletions packages/@sanity/schema/test/extractSchema/extractSchema.test.ts

Large diffs are not rendered by default.

@@ -0,0 +1,26 @@
export default {
name: 'sanity.assetSourceData',
title: 'Asset Source Data',
type: 'object',
fields: [
{
name: 'name',
title: 'Source name',
description: 'A canonical name for the source this asset is originating from',
type: 'string',
},
{
name: 'id',
title: 'Asset Source ID',
description:
'The unique ID for the asset within the originating source so you can programatically find back to it',
type: 'string',
},
{
name: 'url',
title: 'Asset information URL',
description: 'A URL to find more information about this asset in the originating source',
type: 'string',
},
],
}
70 changes: 1 addition & 69 deletions packages/@sanity/schema/test/extractSchema/fixtures/block.ts
Expand Up @@ -19,7 +19,7 @@ const linkType = {
}

export default {
name: 'blocks',
name: 'blocksTest',
title: 'Blocks test',
type: 'object',
icon: ComposeIcon,
Expand Down Expand Up @@ -87,18 +87,6 @@ export default {
},
{type: 'author', title: 'Embedded author'},
{type: 'code', title: 'Code'},
// {
// type: 'color',
// name: 'colorBlock',
// title: 'Color (block)',
// icon: DropIcon,
// },
{
type: 'object',
title: 'Test object',
name: 'testObject',
fields: [{name: 'field1', type: 'string'}],
},
{
type: 'object',
title: 'Other test object',
Expand All @@ -120,62 +108,6 @@ export default {
},
],
},
// {
// type: 'block',
// of: [
// {
// type: 'color',
// title: 'Color',
// },
// ],
// },
{
type: 'spotifyEmbed',
name: 'spotifyEmbed',
title: 'Spotify embed',
},
],
},
{
name: 'nestedWithDualColumnCTA',
title: 'Nested, with dual column CTA',
type: 'array',
of: [
{
name: 'localeRichtext',
type: 'object',
fields: [
{
title: 'English',
name: 'en',
type: 'array',
of: [
{type: 'block'},
{type: 'image'},
{
name: 'twoColCTA',
type: 'object',
title: 'Two Column CTA',
description: 'Inserts two content blocks.',
fields: [
{
name: 'columnone',
title: 'Column One',
type: 'array',
of: [{type: 'richTextObject'}],
},
{
name: 'columntwo',
title: 'Column Two',
type: 'array',
of: [{type: 'richTextObject'}],
},
],
},
],
},
],
},
],
},
{
Expand Down
103 changes: 103 additions & 0 deletions packages/@sanity/schema/test/extractSchema/fixtures/fileAsset.ts
@@ -0,0 +1,103 @@
export default {
name: 'sanity.fileAsset',
title: 'File',
type: 'document',
fieldsets: [
{
name: 'system',
title: 'System fields',
description: 'These fields are managed by the system and not editable',
},
],
fields: [
{
name: 'originalFilename',
type: 'string',
title: 'Original file name',
readOnly: true,
},
{
name: 'label',
type: 'string',
title: 'Label',
},
{
name: 'title',
type: 'string',
title: 'Title',
},
{
name: 'description',
type: 'string',
title: 'Description',
},
{
name: 'altText',
type: 'string',
title: 'Alternative text',
},
{
name: 'sha1hash',
type: 'string',
title: 'SHA1 hash',
readOnly: true,
fieldset: 'system',
},
{
name: 'extension',
type: 'string',
title: 'File extension',
readOnly: true,
fieldset: 'system',
},
{
name: 'mimeType',
type: 'string',
title: 'Mime type',
readOnly: true,
fieldset: 'system',
},
{
name: 'size',
type: 'number',
title: 'File size in bytes',
readOnly: true,
fieldset: 'system',
},
{
name: 'assetId',
type: 'string',
title: 'Asset ID',
readOnly: true,
fieldset: 'system',
},
{
name: 'uploadId',
type: 'string',
readOnly: true,
hidden: true,
fieldset: 'system',
},
{
name: 'path',
type: 'string',
title: 'Path',
readOnly: true,
fieldset: 'system',
},
{
name: 'url',
type: 'string',
title: 'Url',
readOnly: true,
fieldset: 'system',
},
{
name: 'source',
type: 'sanity.assetSourceData',
title: 'Source',
readOnly: true,
fieldset: 'system',
},
],
}
22 changes: 22 additions & 0 deletions packages/@sanity/schema/test/extractSchema/fixtures/geopoint.ts
@@ -0,0 +1,22 @@
export default {
title: 'Geographical Point',
name: 'geopoint',
type: 'object',
fields: [
{
name: 'lat',
type: 'number',
title: 'Latitude',
},
{
name: 'lng',
type: 'number',
title: 'Longitude',
},
{
name: 'alt',
type: 'number',
title: 'Altitude',
},
],
}
108 changes: 108 additions & 0 deletions packages/@sanity/schema/test/extractSchema/fixtures/imageAsset.ts
@@ -0,0 +1,108 @@
export default {
name: 'sanity.imageAsset',
title: 'Image',
type: 'document',
fieldsets: [
{
name: 'system',
title: 'System fields',
description: 'These fields are managed by the system and not editable',
},
],
fields: [
{
name: 'originalFilename',
type: 'string',
title: 'Original file name',
readOnly: true,
},
{
name: 'label',
type: 'string',
title: 'Label',
},
{
name: 'title',
type: 'string',
title: 'Title',
},
{
name: 'description',
type: 'string',
title: 'Description',
},
{
name: 'altText',
type: 'string',
title: 'Alternative text',
},
{
name: 'sha1hash',
type: 'string',
title: 'SHA1 hash',
readOnly: true,
fieldset: 'system',
},
{
name: 'extension',
type: 'string',
readOnly: true,
title: 'File extension',
fieldset: 'system',
},
{
name: 'mimeType',
type: 'string',
readOnly: true,
title: 'Mime type',
fieldset: 'system',
},
{
name: 'size',
type: 'number',
title: 'File size in bytes',
readOnly: true,
fieldset: 'system',
},
{
name: 'assetId',
type: 'string',
title: 'Asset ID',
readOnly: true,
fieldset: 'system',
},
{
name: 'uploadId',
type: 'string',
readOnly: true,
hidden: true,
fieldset: 'system',
},
{
name: 'path',
type: 'string',
title: 'Path',
readOnly: true,
fieldset: 'system',
},
{
name: 'url',
type: 'string',
title: 'Url',
readOnly: true,
fieldset: 'system',
},
{
name: 'metadata',
type: 'sanity.imageMetadata',
title: 'Metadata',
},
{
name: 'source',
type: 'sanity.assetSourceData',
title: 'Source',
readOnly: true,
fieldset: 'system',
},
],
}
23 changes: 23 additions & 0 deletions packages/@sanity/schema/test/extractSchema/fixtures/imageCrop.ts
@@ -0,0 +1,23 @@
export default {
name: 'sanity.imageCrop',
title: 'Image crop',
type: 'object',
fields: [
{
name: 'top',
type: 'number',
},
{
name: 'bottom',
type: 'number',
},
{
name: 'left',
type: 'number',
},
{
name: 'right',
type: 'number',
},
],
}
@@ -0,0 +1,10 @@
export default {
name: 'sanity.imageDimensions',
type: 'object',
title: 'Image dimensions',
fields: [
{name: 'height', type: 'number', title: 'Height', readOnly: true},
{name: 'width', type: 'number', title: 'Width', readOnly: true},
{name: 'aspectRatio', type: 'number', title: 'Aspect ratio', readOnly: true},
],
}

0 comments on commit 4afe4ab

Please sign in to comment.