gt-sanity 0.0.5 → 1.0.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.
Files changed (108) hide show
  1. package/LICENSE.md +1 -8
  2. package/README.md +5 -5
  3. package/dist/index.d.mts +122 -95
  4. package/dist/index.d.ts +122 -95
  5. package/dist/index.js +9089 -1119
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +9099 -1100
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +11 -4
  10. package/src/adapter/core.ts +111 -9
  11. package/src/adapter/createTask.ts +1 -1
  12. package/src/adapter/getLocales.ts +2 -2
  13. package/src/adapter/types.ts +9 -0
  14. package/src/components/TranslationsProvider.tsx +942 -0
  15. package/src/components/page/BatchProgress.tsx +27 -0
  16. package/src/components/page/ImportAllDialog.tsx +51 -0
  17. package/src/components/page/ImportMissingDialog.tsx +55 -0
  18. package/src/components/page/TranslateAllDialog.tsx +55 -0
  19. package/src/components/page/TranslationsTable.tsx +81 -0
  20. package/src/components/page/TranslationsTool.tsx +338 -0
  21. package/src/components/shared/BaseTranslationWrapper.tsx +82 -0
  22. package/src/components/{LanguageStatus.tsx → shared/LanguageStatus.tsx} +2 -0
  23. package/src/components/shared/LocaleCheckbox.tsx +47 -0
  24. package/src/components/{ProgressBar.tsx → shared/ProgressBar.tsx} +2 -0
  25. package/src/components/shared/SingleDocumentView.tsx +108 -0
  26. package/src/components/tab/TranslationView.tsx +379 -0
  27. package/src/components/tab/TranslationsTab.tsx +25 -0
  28. package/src/configuration/baseDocumentLevelConfig/documentLevelPatch.ts +21 -11
  29. package/src/configuration/baseDocumentLevelConfig/helpers/createI18nDocAndPatchMetadata.ts +57 -23
  30. package/src/configuration/baseDocumentLevelConfig/helpers/createTranslationMetadata.ts +2 -0
  31. package/src/configuration/baseDocumentLevelConfig/helpers/getOrCreateTranslationMetadata.ts +2 -0
  32. package/src/configuration/baseDocumentLevelConfig/helpers/getTranslationMetadata.ts +2 -0
  33. package/src/configuration/baseDocumentLevelConfig/helpers/patchI18nDoc.ts +31 -8
  34. package/src/configuration/baseDocumentLevelConfig/index.ts +18 -101
  35. package/src/configuration/baseFieldLevelConfig.ts +19 -51
  36. package/src/configuration/utils/checkSerializationVersion.ts +2 -0
  37. package/src/configuration/utils/findDocumentAtRevision.ts +2 -0
  38. package/src/configuration/utils/findLatestDraft.ts +2 -0
  39. package/src/hooks/useClient.ts +3 -1
  40. package/src/hooks/useSecrets.ts +2 -0
  41. package/src/index.ts +91 -67
  42. package/src/sanity-api/findDocuments.ts +44 -0
  43. package/src/sanity-api/publishDocuments.ts +49 -0
  44. package/src/sanity-api/resolveRefs.ts +146 -0
  45. package/src/serialization/BaseDocumentMerger.ts +138 -0
  46. package/src/serialization/BaseSerializationConfig.ts +220 -0
  47. package/src/serialization/__tests__/BaseDocumentDeserializer/__snapshots__/documentLevelDeserialization.test.ts.snap +189 -0
  48. package/src/serialization/__tests__/BaseDocumentDeserializer/__snapshots__/fieldLevelDeserialization.test.ts.snap +107 -0
  49. package/src/serialization/__tests__/BaseDocumentDeserializer/baseDeserialization.test.ts +397 -0
  50. package/src/serialization/__tests__/BaseDocumentDeserializer/documentLevelDeserialization.test.ts +107 -0
  51. package/src/serialization/__tests__/BaseDocumentDeserializer/fieldLevelDeserialization.test.ts +107 -0
  52. package/src/serialization/__tests__/BaseDocumentMerger/__snapshots__/documentLevelMerge.test.ts.snap +193 -0
  53. package/src/serialization/__tests__/BaseDocumentMerger/__snapshots__/fieldLevelMerge.test.ts.snap +97 -0
  54. package/src/serialization/__tests__/BaseDocumentMerger/baseMerge.test.ts +36 -0
  55. package/src/serialization/__tests__/BaseDocumentMerger/documentLevelMerge.test.ts +96 -0
  56. package/src/serialization/__tests__/BaseDocumentMerger/fieldLevelMerge.test.ts +142 -0
  57. package/src/serialization/__tests__/BaseDocumentMerger/utils.ts +52 -0
  58. package/src/serialization/__tests__/BaseDocumentSerializer/__snapshots__/documentInlineMarks.test.ts.snap +39 -0
  59. package/src/serialization/__tests__/BaseDocumentSerializer/__snapshots__/documentLevelSerialization.test.ts.snap +8 -0
  60. package/src/serialization/__tests__/BaseDocumentSerializer/__snapshots__/fieldLevelSerialization.test.ts.snap +8 -0
  61. package/src/serialization/__tests__/BaseDocumentSerializer/baseSerialization.test.ts +345 -0
  62. package/src/serialization/__tests__/BaseDocumentSerializer/documentInlineMarks.test.ts +53 -0
  63. package/src/serialization/__tests__/BaseDocumentSerializer/documentLevelSerialization.test.ts +120 -0
  64. package/src/serialization/__tests__/BaseDocumentSerializer/fieldLevelSerialization.test.ts +153 -0
  65. package/src/serialization/__tests__/BaseDocumentSerializer/utils.ts +27 -0
  66. package/src/serialization/__tests__/README +2 -0
  67. package/src/serialization/__tests__/__fixtures__/annotationAndInlineBlocks.json +140 -0
  68. package/src/serialization/__tests__/__fixtures__/customStyles.json +62 -0
  69. package/src/serialization/__tests__/__fixtures__/documentInlineMarks.json +70 -0
  70. package/src/serialization/__tests__/__fixtures__/documentLevelArticle.json +185 -0
  71. package/src/serialization/__tests__/__fixtures__/fieldLevelArticle.json +107 -0
  72. package/src/serialization/__tests__/__fixtures__/inlineDocumentLevelArticle.json +134 -0
  73. package/src/serialization/__tests__/__fixtures__/inlineSchema.ts +270 -0
  74. package/src/serialization/__tests__/__fixtures__/messy-html.html +26 -0
  75. package/src/serialization/__tests__/__fixtures__/nestedLanguageFields.json +54 -0
  76. package/src/serialization/__tests__/__fixtures__/schema.ts +310 -0
  77. package/src/serialization/__tests__/global.setup.ts +40 -0
  78. package/src/serialization/__tests__/helpers.ts +132 -0
  79. package/src/serialization/data.ts +82 -0
  80. package/src/serialization/deserialize/BaseDocumentDeserializer.ts +171 -0
  81. package/src/serialization/deserialize/helpers.ts +42 -0
  82. package/src/serialization/helpers.ts +18 -0
  83. package/src/serialization/index.ts +11 -0
  84. package/src/serialization/serialize/fieldFilters.ts +124 -0
  85. package/src/serialization/serialize/index.ts +284 -0
  86. package/src/serialization/types.ts +41 -0
  87. package/src/translation/checkTranslationStatus.ts +42 -0
  88. package/src/translation/createJobs.ts +16 -0
  89. package/src/translation/downloadTranslations.ts +68 -0
  90. package/src/translation/importDocument.ts +23 -0
  91. package/src/translation/initProject.ts +61 -0
  92. package/src/translation/uploadFiles.ts +32 -0
  93. package/src/types.ts +7 -20
  94. package/src/utils/applyDocuments.ts +72 -0
  95. package/src/utils/batchProcessor.ts +111 -0
  96. package/src/utils/importUtils.ts +95 -0
  97. package/src/utils/serialize.ts +52 -0
  98. package/src/utils/shared.ts +1 -0
  99. package/src/adapter/index.ts +0 -13
  100. package/src/components/NewTask.tsx +0 -249
  101. package/src/components/TaskView.tsx +0 -255
  102. package/src/components/TranslationContext.tsx +0 -19
  103. package/src/components/TranslationView.tsx +0 -82
  104. package/src/components/TranslationsTab.tsx +0 -177
  105. package/src/configuration/baseDocumentLevelConfig/helpers/index.ts +0 -5
  106. package/src/configuration/baseDocumentLevelConfig/legacyDocumentLevelPatch.ts +0 -69
  107. package/src/configuration/index.ts +0 -18
  108. package/src/configuration/utils/index.ts +0 -3
@@ -0,0 +1,185 @@
1
+ {
2
+ "_id": "drafts.d8ffc675-ce86-4f60-9ac8-da164cde3b0a",
3
+ "_rev": "fxcnqj-uew-gr7-v6r-z965tfm69",
4
+ "_type": "documentLevelArticle",
5
+ "_createdAt": "2021-09-01T23:00:13Z",
6
+ "_updatedAt": "2021-09-01T23:02:05Z",
7
+ "config": {
8
+ "_type": "objectField",
9
+ "nestedArrayField": [
10
+ {
11
+ "_key": "4a58adc7c507",
12
+ "_type": "block",
13
+ "children": [
14
+ {
15
+ "_key": "4f6bc15ae261",
16
+ "_type": "span",
17
+ "marks": [],
18
+ "text": "This is block text 1 level deep"
19
+ }
20
+ ],
21
+ "markDefs": [],
22
+ "style": "normal"
23
+ }
24
+ ],
25
+ "objectAsField": {
26
+ "_type": "childObjectField",
27
+ "content": [
28
+ {
29
+ "_key": "1aa228ac848b",
30
+ "_type": "block",
31
+ "children": [
32
+ {
33
+ "_key": "e2cf67af8e62",
34
+ "_type": "span",
35
+ "marks": [],
36
+ "text": "This is a block text 2 levels deep"
37
+ }
38
+ ],
39
+ "markDefs": [],
40
+ "style": "normal"
41
+ }
42
+ ],
43
+ "title": "This is one level deeper"
44
+ },
45
+ "title": "This is an object nested in a document"
46
+ },
47
+ "content": [
48
+ {
49
+ "_key": "a4d177e92666",
50
+ "_type": "block",
51
+ "children": [
52
+ {
53
+ "_key": "a896ea6fcd59",
54
+ "_type": "span",
55
+ "marks": [],
56
+ "text": "This is block text at the top level."
57
+ }
58
+ ],
59
+ "markDefs": [],
60
+ "style": "normal"
61
+ },
62
+ {
63
+ "_key": "c0313627775e",
64
+ "_type": "objectField",
65
+ "objectAsField": {
66
+ "_type": "childObjectField",
67
+ "content": [
68
+ {
69
+ "_key": "4f24f6fbfae7",
70
+ "_type": "block",
71
+ "children": [
72
+ {
73
+ "_key": "d68f4288f5b7",
74
+ "_type": "span",
75
+ "marks": [],
76
+ "text": "This is block text in a nested object in an object in top-level block text."
77
+ }
78
+ ],
79
+ "markDefs": [],
80
+ "style": "normal"
81
+ }
82
+ ],
83
+ "title": "This is a nested object in an object in top-level block text."
84
+ },
85
+ "title": "This is an object in top-level block text."
86
+ },
87
+ {
88
+ "_key": "9e2ab13c6d63",
89
+ "_type": "block",
90
+ "children": [
91
+ {
92
+ "_key": "17e856dc4766",
93
+ "_type": "span",
94
+ "marks": [],
95
+ "text": "This is h1 text"
96
+ }
97
+ ],
98
+ "markDefs": [],
99
+ "style": "h1"
100
+ },
101
+ {
102
+ "_key": "297142fbaf21",
103
+ "_type": "block",
104
+ "children": [
105
+ {
106
+ "_key": "0b2f9e94a161",
107
+ "_type": "span",
108
+ "marks": [],
109
+ "text": "This is h2 text"
110
+ }
111
+ ],
112
+ "markDefs": [],
113
+ "style": "h2"
114
+ },
115
+ {
116
+ "_key": "76e648fc3845",
117
+ "_type": "block",
118
+ "children": [
119
+ {
120
+ "_key": "49f466bbc78c",
121
+ "_type": "span",
122
+ "marks": [],
123
+ "text": "Bullet 1"
124
+ }
125
+ ],
126
+ "level": 1,
127
+ "listItem": "bullet",
128
+ "markDefs": [],
129
+ "style": "normal"
130
+ },
131
+ {
132
+ "_key": "d090cd8b27d2",
133
+ "_type": "block",
134
+ "children": [
135
+ {
136
+ "_key": "599c6991018f",
137
+ "_type": "span",
138
+ "marks": [],
139
+ "text": "nested bullet a"
140
+ }
141
+ ],
142
+ "level": 2,
143
+ "listItem": "bullet",
144
+ "markDefs": [],
145
+ "style": "normal"
146
+ },
147
+ {
148
+ "_key": "1cdffa5d50f5",
149
+ "_type": "block",
150
+ "children": [
151
+ {
152
+ "_key": "c16eb16f01cb",
153
+ "_type": "span",
154
+ "marks": [],
155
+ "text": "Styled bullet 2"
156
+ }
157
+ ],
158
+ "level": 1,
159
+ "listItem": "bullet",
160
+ "markDefs": [],
161
+ "style": "h2"
162
+ },
163
+ {
164
+ "_key": "da29f5063059",
165
+ "_type": "block",
166
+ "children": [
167
+ {
168
+ "_key": "e3d7e3eaad54",
169
+ "_type": "span",
170
+ "marks": [],
171
+ "text": "Number 1"
172
+ }
173
+ ],
174
+ "level": 1,
175
+ "listItem": "number",
176
+ "markDefs": [],
177
+ "style": "h3"
178
+ }
179
+ ],
180
+ "hidden": true,
181
+ "meta": "Do not translate this",
182
+ "snippet": "This is text in my text field.",
183
+ "tags": ["tag 1", "tag 2", "tag 3"],
184
+ "title": "My Document-Level Article"
185
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "_createdAt": "2021-10-10T23:00:13Z",
3
+ "_id": "drafts.2947533e-1ea5-4116-955b-339608d3445d",
4
+ "_rev": "l58oha-n06-1s4-f6i-74g6cuakl",
5
+ "_type": "fieldLevelArticle",
6
+ "_updatedAt": "2021-10-10T23:02:05Z",
7
+ "slug": {
8
+ "_type": "slug",
9
+ "current": "happy-kitchen-hamburger"
10
+ },
11
+ "config": {
12
+ "en": {
13
+ "_type": "objectField",
14
+ "nestedArrayField": [
15
+ {
16
+ "_key": "f49b4d7e3e51",
17
+ "_type": "block",
18
+ "children": [
19
+ {
20
+ "_key": "a6170f21181c",
21
+ "_type": "span",
22
+ "marks": [],
23
+ "text": "This is block text 1 level deep"
24
+ }
25
+ ],
26
+ "markDefs": [],
27
+ "style": "normal"
28
+ }
29
+ ],
30
+ "objectAsField": {
31
+ "_type": "childObjectField",
32
+ "content": [
33
+ {
34
+ "_key": "869168fe3a2a",
35
+ "_type": "block",
36
+ "children": [
37
+ {
38
+ "_key": "10d423df228a",
39
+ "_type": "span",
40
+ "marks": [],
41
+ "text": "This is block text 2 levels deep"
42
+ }
43
+ ],
44
+ "markDefs": [],
45
+ "style": "normal"
46
+ }
47
+ ],
48
+ "title": "This is one level deeper"
49
+ },
50
+ "title": "This is an object nested in a document"
51
+ }
52
+ },
53
+ "content": {
54
+ "en": [
55
+ {
56
+ "_key": "e2a39d768ff8",
57
+ "_type": "block",
58
+ "children": [
59
+ {
60
+ "_key": "216e97c5a5cc",
61
+ "_type": "span",
62
+ "marks": [],
63
+ "text": "This is block text at the top level."
64
+ }
65
+ ],
66
+ "markDefs": [],
67
+ "style": "normal"
68
+ },
69
+ {
70
+ "_key": "271b0c6ee984",
71
+ "_type": "objectField",
72
+ "objectAsField": {
73
+ "_type": "childObjectField",
74
+ "content": [
75
+ {
76
+ "_key": "4f24f6fbfae7",
77
+ "_type": "block",
78
+ "children": [
79
+ {
80
+ "_key": "d68f4288f5b7",
81
+ "_type": "span",
82
+ "marks": [],
83
+ "text": "This is block text in a nested object in an object in top-level block text."
84
+ }
85
+ ],
86
+ "markDefs": [],
87
+ "style": "normal"
88
+ }
89
+ ],
90
+ "title": "This is a nested object in an object in top-level block text."
91
+ },
92
+ "title": "This is an object in top-level block text."
93
+ }
94
+ ]
95
+ },
96
+ "hidden": true,
97
+ "meta": "Do not translate this",
98
+ "snippet": {
99
+ "en": "This is text in my text field"
100
+ },
101
+ "tags": {
102
+ "en": ["tag 1", "tag 2", "tag 3"]
103
+ },
104
+ "title": {
105
+ "en": "My Field-Level Article"
106
+ }
107
+ }
@@ -0,0 +1,134 @@
1
+ {
2
+ "_id": "drafts.d8ffc675-ce86-4f60-9ac8-da164cde3b0a",
3
+ "_rev": "fxcnqj-uew-gr7-v6r-z965tfm69",
4
+ "_type": "documentLevelArticle",
5
+ "_createdAt": "2021-09-01T23:00:13Z",
6
+ "_updatedAt": "2021-09-01T23:02:05Z",
7
+ "tabs": {
8
+ "_type": "object",
9
+ "config": {
10
+ "_type": "objectField",
11
+ "nestedArrayField": [
12
+ {
13
+ "_key": "4a58adc7c507",
14
+ "_type": "block",
15
+ "children": [
16
+ {
17
+ "_key": "4f6bc15ae261",
18
+ "_type": "span",
19
+ "marks": [],
20
+ "text": "This is block text 1 level deep"
21
+ }
22
+ ],
23
+ "markDefs": [],
24
+ "style": "normal"
25
+ }
26
+ ],
27
+ "objectAsField": {
28
+ "_type": "object",
29
+ "content": [
30
+ {
31
+ "_key": "1aa228ac848b",
32
+ "_type": "block",
33
+ "children": [
34
+ {
35
+ "_key": "e2cf67af8e62",
36
+ "_type": "span",
37
+ "marks": [],
38
+ "text": "This is a block text 2 levels deep"
39
+ }
40
+ ],
41
+ "markDefs": [],
42
+ "style": "normal"
43
+ }
44
+ ],
45
+ "title": "This is one level deeper"
46
+ },
47
+ "title": "This is an object nested in a document"
48
+ },
49
+ "content": [
50
+ {
51
+ "_key": "a4d177e92666",
52
+ "_type": "block",
53
+ "children": [
54
+ {
55
+ "_key": "a896ea6fcd59",
56
+ "_type": "span",
57
+ "marks": [],
58
+ "text": "This is block text at the top level."
59
+ }
60
+ ],
61
+ "markDefs": [],
62
+ "style": "normal"
63
+ },
64
+ {
65
+ "_key": "c0313627775e",
66
+ "_type": "objectField",
67
+ "objectAsField": {
68
+ "_type": "childObjectField",
69
+ "content": [
70
+ {
71
+ "_key": "4f24f6fbfae7",
72
+ "_type": "block",
73
+ "children": [
74
+ {
75
+ "_key": "d68f4288f5b7",
76
+ "_type": "span",
77
+ "marks": [],
78
+ "text": "This is block text in a nested object in an object in top-level block text."
79
+ }
80
+ ],
81
+ "markDefs": [],
82
+ "style": "normal"
83
+ }
84
+ ],
85
+ "title": "This is a nested object in an object in top-level block text."
86
+ },
87
+ "title": "This is an object in top-level block text."
88
+ },
89
+ {
90
+ "_key": "9e2ab13c6d63",
91
+ "_type": "block",
92
+ "children": [
93
+ {
94
+ "_key": "17e856dc4766",
95
+ "_type": "span",
96
+ "marks": [],
97
+ "text": "This is h1 text"
98
+ }
99
+ ],
100
+ "markDefs": [],
101
+ "style": "h1"
102
+ },
103
+ {
104
+ "_key": "297142fbaf21",
105
+ "_type": "block",
106
+ "children": [
107
+ {
108
+ "_key": "0b2f9e94a161",
109
+ "_type": "span",
110
+ "marks": [],
111
+ "text": "This is h2 text"
112
+ }
113
+ ],
114
+ "markDefs": [],
115
+ "style": "h2"
116
+ }
117
+ ],
118
+ "hidden": true,
119
+ "meta": "Do not translate this",
120
+ "snippet": "This is text in my text field.",
121
+ "tags": ["tag 1", "tag 2", "tag 3"],
122
+ "title": "My Document-Level Article",
123
+ "arrayWithAnonymousObjects": [
124
+ {
125
+ "_key": "4c146e0ab346",
126
+ "cells": ["Standard", "Americas", "EMEA"]
127
+ },
128
+ {
129
+ "_key": "038f8c197939",
130
+ "cells": ["Friends", "Family", "Other"]
131
+ }
132
+ ]
133
+ }
134
+ }
@@ -0,0 +1,270 @@
1
+ import { Schema } from '@sanity/schema';
2
+
3
+ const arrayField = {
4
+ name: 'arrayField',
5
+ title: 'Array Field',
6
+ type: 'array',
7
+ of: [
8
+ { type: 'block' },
9
+ {
10
+ type: 'object',
11
+ fields: [
12
+ {
13
+ name: 'title',
14
+ title: 'Title',
15
+ type: 'string',
16
+ },
17
+ {
18
+ name: 'objectAsField',
19
+ title: 'Object As Field',
20
+ type: 'object',
21
+ fields: [
22
+ {
23
+ name: 'title',
24
+ title: 'Title',
25
+ type: 'string',
26
+ },
27
+ {
28
+ name: 'content',
29
+ title: 'Content',
30
+ type: 'array',
31
+ of: [{ type: 'block' }],
32
+ },
33
+ ],
34
+ },
35
+ {
36
+ name: 'nestedArrayField',
37
+ title: 'Nested Array Field',
38
+ type: 'array',
39
+ of: [{ type: 'block' }, { type: 'childObjectField' }],
40
+ },
41
+ ],
42
+ },
43
+ ],
44
+ };
45
+
46
+ const childObjectField = {
47
+ name: 'childObjectField',
48
+ title: 'Child Object Field',
49
+ type: 'object',
50
+ fields: [
51
+ {
52
+ name: 'title',
53
+ title: 'Title',
54
+ type: 'string',
55
+ },
56
+ {
57
+ name: 'content',
58
+ title: 'Content',
59
+ type: 'array',
60
+ of: [{ type: 'block' }],
61
+ },
62
+ ],
63
+ };
64
+
65
+ const objectField = {
66
+ name: 'objectField',
67
+ title: 'Object Field',
68
+ type: 'object',
69
+ fields: [
70
+ {
71
+ name: 'title',
72
+ title: 'Title',
73
+ type: 'string',
74
+ },
75
+ {
76
+ name: 'objectAsField',
77
+ title: 'Object As Field',
78
+ type: 'object',
79
+ fields: [
80
+ {
81
+ name: 'title',
82
+ title: 'Title',
83
+ type: 'string',
84
+ },
85
+ {
86
+ name: 'content',
87
+ title: 'Content',
88
+ type: 'array',
89
+ of: [{ type: 'block' }],
90
+ },
91
+ ],
92
+ },
93
+ {
94
+ name: 'nestedArrayField',
95
+ title: 'Nested Array Field',
96
+ type: 'array',
97
+ of: [{ type: 'block' }, { type: 'childObjectField' }],
98
+ },
99
+ ],
100
+ };
101
+
102
+ const documentLevelArticle = {
103
+ name: 'documentLevelArticle',
104
+ title: 'Document Level Article',
105
+ type: 'document',
106
+ fields: [
107
+ {
108
+ name: 'tabs',
109
+ type: 'object',
110
+ fields: [
111
+ {
112
+ name: 'title',
113
+ title: 'Title',
114
+ type: 'string',
115
+ },
116
+ {
117
+ name: 'meta',
118
+ title: 'Meta',
119
+ type: 'string',
120
+ localize: false,
121
+ },
122
+ {
123
+ name: 'snippet',
124
+ title: 'Snippet',
125
+ type: 'text',
126
+ },
127
+ {
128
+ name: 'tags',
129
+ title: 'Tags',
130
+ type: 'array',
131
+ of: [{ type: 'string' }],
132
+ },
133
+ {
134
+ name: 'hidden',
135
+ title: 'Hidden',
136
+ type: 'boolean',
137
+ },
138
+ {
139
+ name: 'config',
140
+ title: 'Config',
141
+ type: 'objectField',
142
+ },
143
+ {
144
+ name: 'content',
145
+ title: 'Content',
146
+ type: 'arrayField',
147
+ },
148
+ ],
149
+ },
150
+ ],
151
+ };
152
+
153
+ function createLocaleFields(locales: string[], fieldType: Record<string, any>) {
154
+ return locales.map((locale) => ({
155
+ ...{ name: locale },
156
+ ...fieldType,
157
+ }));
158
+ }
159
+
160
+ const fieldLevelArticle = {
161
+ name: 'fieldLevelArticle',
162
+ title: 'Field Level Article',
163
+ type: 'document',
164
+ fields: [
165
+ {
166
+ name: 'title',
167
+ title: 'Title',
168
+ type: 'localeString',
169
+ },
170
+ {
171
+ name: 'meta',
172
+ title: 'Meta',
173
+ type: 'string',
174
+ localize: false,
175
+ },
176
+ {
177
+ name: 'snippet',
178
+ title: 'Snippet',
179
+ type: 'object',
180
+ fields: createLocaleFields(['en', 'fr', 'de'], { type: 'text' }),
181
+ },
182
+ {
183
+ name: 'tags',
184
+ title: 'Tags',
185
+ type: 'object',
186
+ fields: createLocaleFields(['en', 'fr', 'de'], {
187
+ type: 'array',
188
+ of: [{ type: 'string' }],
189
+ }),
190
+ },
191
+ {
192
+ name: 'hidden',
193
+ title: 'Hidden',
194
+ type: 'boolean',
195
+ },
196
+ {
197
+ name: 'config',
198
+ title: 'Config',
199
+ type: 'object',
200
+ fields: createLocaleFields(['en', 'fr', 'de'], { type: 'objectField' }),
201
+ },
202
+ {
203
+ name: 'content',
204
+ title: 'Content',
205
+ type: 'object',
206
+ fields: createLocaleFields(['en', 'fr', 'de'], { type: 'arrayField' }),
207
+ },
208
+ {
209
+ name: 'slices',
210
+ title: 'Slices',
211
+ type: 'array',
212
+ of: [
213
+ { type: 'localeBlock' },
214
+ { type: 'reference', to: [{ type: 'marketText' }] },
215
+ ],
216
+ },
217
+ {
218
+ name: 'pageFields',
219
+ title: 'Page Fields',
220
+ type: 'pageFields',
221
+ },
222
+ ],
223
+ };
224
+
225
+ const localeBlock = {
226
+ name: 'localeBlock',
227
+ title: 'Locale Block',
228
+ type: 'object',
229
+ fields: createLocaleFields(['en', 'fr_FR', 'de_DE'], { type: 'arrayField' }),
230
+ };
231
+
232
+ const localeString = {
233
+ name: 'localeString',
234
+ title: 'Locale String',
235
+ type: 'object',
236
+ fields: createLocaleFields(['en', 'fr_FR', 'de_DE'], { type: 'string' }),
237
+ };
238
+
239
+ const pageFields = {
240
+ name: 'pageFields',
241
+ title: 'Page Fields',
242
+ type: 'object',
243
+ fields: [
244
+ {
245
+ title: 'Page Name',
246
+ name: 'name',
247
+ type: 'localeString',
248
+ },
249
+ {
250
+ name: 'slug',
251
+ type: 'string',
252
+ },
253
+ ],
254
+ };
255
+
256
+ const types = [
257
+ arrayField,
258
+ childObjectField,
259
+ objectField,
260
+ documentLevelArticle,
261
+ fieldLevelArticle,
262
+ pageFields,
263
+ localeBlock,
264
+ localeString,
265
+ ];
266
+
267
+ export default new Schema({
268
+ name: 'test',
269
+ types,
270
+ });