@sanity/schema 5.14.0-next.8 → 5.14.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/lib/_internal.d.ts +191 -20
- package/lib/_internal.js +415 -0
- package/lib/_internal.js.map +1 -1
- package/package.json +6 -6
package/lib/_internal.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { a as SchemaValidationResult, i as ProblemPathTypeSegment, l as Schema$1, n as ProblemPathPropertySegment, o as TypeWithProblems, r as ProblemPathSegment, s as _FIXME_, t as ProblemPath } from "./_chunks-dts/typedefs.js";
|
|
2
2
|
import { SetSynchronization, SynchronizationRequest, SynchronizationResult } from "@sanity/descriptors";
|
|
3
3
|
import * as _sanity_types0 from "@sanity/types";
|
|
4
|
-
import { Schema, SchemaType, SchemaTypeDefinition, SchemaValidationProblem, SchemaValidationProblemGroup } from "@sanity/types";
|
|
4
|
+
import { SanityDocumentLike, Schema, SchemaType, SchemaTypeDefinition, SchemaValidationProblem, SchemaValidationProblemGroup } from "@sanity/types";
|
|
5
|
+
import { ComponentType, ReactNode } from "react";
|
|
5
6
|
import { SchemaType as SchemaType$1 } from "groq-js";
|
|
6
7
|
/** The scheduler is capable of executing work in different ways. */
|
|
7
8
|
type Scheduler = {
|
|
@@ -44,6 +45,180 @@ declare function resolveSearchConfigForBaseFieldPaths(type: any, maxDepth?: numb
|
|
|
44
45
|
*/
|
|
45
46
|
declare function resolveSearchConfig(type: any, maxDepth?: number): any;
|
|
46
47
|
declare const ALL_FIELDS_GROUP_NAME = "all-fields";
|
|
48
|
+
declare function createSchemaFromManifestTypes(schemaDef: {
|
|
49
|
+
name: string;
|
|
50
|
+
types: unknown[];
|
|
51
|
+
}): Schema$1;
|
|
52
|
+
interface MediaLibraryConfig {
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
libraryId?: string;
|
|
55
|
+
__internal?: {
|
|
56
|
+
frontendHost?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
declare const SANITY_WORKSPACE_SCHEMA_ID_PREFIX = "_.schemas";
|
|
60
|
+
declare const SANITY_WORKSPACE_SCHEMA_TYPE = "system.schema";
|
|
61
|
+
declare const CURRENT_WORKSPACE_SCHEMA_VERSION = "2025-05-01";
|
|
62
|
+
type ManifestSerializable = string | number | boolean | {
|
|
63
|
+
[k: string]: ManifestSerializable;
|
|
64
|
+
} | ManifestSerializable[];
|
|
65
|
+
interface CreateManifest {
|
|
66
|
+
version: number;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
workspaces: ManifestWorkspaceFile[];
|
|
69
|
+
studioVersion: string | null;
|
|
70
|
+
}
|
|
71
|
+
interface ManifestWorkspaceFile extends Omit<CreateWorkspaceManifest, 'schema' | 'tools'> {
|
|
72
|
+
schema: string;
|
|
73
|
+
tools: string;
|
|
74
|
+
}
|
|
75
|
+
interface CreateWorkspaceManifest {
|
|
76
|
+
name: string;
|
|
77
|
+
title?: string;
|
|
78
|
+
subtitle?: string;
|
|
79
|
+
basePath: string;
|
|
80
|
+
dataset: string;
|
|
81
|
+
projectId: string;
|
|
82
|
+
mediaLibrary?: MediaLibraryConfig;
|
|
83
|
+
schema: ManifestSchemaType[];
|
|
84
|
+
tools: ManifestTool[];
|
|
85
|
+
/**
|
|
86
|
+
* returns undefined in the case of the icon not being able to be stringified
|
|
87
|
+
*/
|
|
88
|
+
icon: string | undefined;
|
|
89
|
+
}
|
|
90
|
+
interface ManifestSchemaType {
|
|
91
|
+
type: string;
|
|
92
|
+
name: string;
|
|
93
|
+
title?: string;
|
|
94
|
+
deprecated?: {
|
|
95
|
+
reason: string;
|
|
96
|
+
};
|
|
97
|
+
readOnly?: boolean | 'conditional';
|
|
98
|
+
hidden?: boolean | 'conditional';
|
|
99
|
+
validation?: ManifestValidationGroup[];
|
|
100
|
+
fields?: ManifestField[];
|
|
101
|
+
to?: ManifestReferenceMember[];
|
|
102
|
+
of?: ManifestArrayMember[];
|
|
103
|
+
preview?: {
|
|
104
|
+
select: Record<string, string>;
|
|
105
|
+
};
|
|
106
|
+
fieldsets?: ManifestFieldset[];
|
|
107
|
+
options?: Record<string, ManifestSerializable>;
|
|
108
|
+
marks?: {
|
|
109
|
+
annotations?: ManifestArrayMember[];
|
|
110
|
+
decorators?: ManifestTitledValue[];
|
|
111
|
+
};
|
|
112
|
+
lists?: ManifestTitledValue[];
|
|
113
|
+
styles?: ManifestTitledValue[];
|
|
114
|
+
}
|
|
115
|
+
interface ManifestFieldset {
|
|
116
|
+
name: string;
|
|
117
|
+
title?: string;
|
|
118
|
+
[index: string]: ManifestSerializable | undefined;
|
|
119
|
+
}
|
|
120
|
+
interface ManifestTitledValue {
|
|
121
|
+
value: string;
|
|
122
|
+
title?: string;
|
|
123
|
+
}
|
|
124
|
+
type ManifestField = ManifestSchemaType & {
|
|
125
|
+
fieldset?: string;
|
|
126
|
+
};
|
|
127
|
+
type ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {
|
|
128
|
+
name?: string;
|
|
129
|
+
};
|
|
130
|
+
type ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {
|
|
131
|
+
name?: string;
|
|
132
|
+
};
|
|
133
|
+
interface ManifestValidationGroup {
|
|
134
|
+
rules: ManifestValidationRule[];
|
|
135
|
+
message?: string;
|
|
136
|
+
level?: 'error' | 'warning' | 'info';
|
|
137
|
+
}
|
|
138
|
+
type ManifestValidationRule = {
|
|
139
|
+
flag: string;
|
|
140
|
+
constraint?: ManifestSerializable;
|
|
141
|
+
[index: string]: ManifestSerializable | undefined;
|
|
142
|
+
};
|
|
143
|
+
interface ManifestTool {
|
|
144
|
+
name: string;
|
|
145
|
+
title: string;
|
|
146
|
+
/**
|
|
147
|
+
* returns undefined in the case of the icon not being able to be stringified
|
|
148
|
+
*/
|
|
149
|
+
icon: string | undefined;
|
|
150
|
+
type: string | null;
|
|
151
|
+
}
|
|
152
|
+
type DefaultWorkspaceSchemaId = `${typeof SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.${string}`;
|
|
153
|
+
type PrefixedWorkspaceSchemaId = `${DefaultWorkspaceSchemaId}.${string}`;
|
|
154
|
+
type WorkspaceSchemaId = DefaultWorkspaceSchemaId | PrefixedWorkspaceSchemaId;
|
|
155
|
+
interface StoredWorkspaceSchema extends SanityDocumentLike {
|
|
156
|
+
_type: typeof SANITY_WORKSPACE_SCHEMA_TYPE;
|
|
157
|
+
_id: WorkspaceSchemaId;
|
|
158
|
+
version: typeof CURRENT_WORKSPACE_SCHEMA_VERSION | undefined;
|
|
159
|
+
tag?: string;
|
|
160
|
+
workspace: {
|
|
161
|
+
name: string;
|
|
162
|
+
title?: string;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* The API expects JSON coming in, but will store a string to save on attribute paths.
|
|
166
|
+
* Consumers must use JSON.parse on the value, put we deploy to the API using ManifestSchemaType[]
|
|
167
|
+
*/
|
|
168
|
+
schema: string | ManifestSchemaType[];
|
|
169
|
+
}
|
|
170
|
+
interface ManifestWorkspaceInput {
|
|
171
|
+
name: string;
|
|
172
|
+
title?: string;
|
|
173
|
+
subtitle?: string;
|
|
174
|
+
basePath: string;
|
|
175
|
+
projectId: string;
|
|
176
|
+
dataset: string;
|
|
177
|
+
icon?: ComponentType | ReactNode;
|
|
178
|
+
mediaLibrary?: MediaLibraryConfig;
|
|
179
|
+
schema: Schema;
|
|
180
|
+
tools: ManifestToolInput[];
|
|
181
|
+
}
|
|
182
|
+
interface ManifestToolInput {
|
|
183
|
+
title: string;
|
|
184
|
+
name: string;
|
|
185
|
+
icon?: ComponentType | ReactNode;
|
|
186
|
+
__internalApplicationType?: string;
|
|
187
|
+
}
|
|
188
|
+
type IconResolver = (props: {
|
|
189
|
+
icon?: ComponentType | ReactNode;
|
|
190
|
+
title: string;
|
|
191
|
+
subtitle?: string;
|
|
192
|
+
}) => string | undefined | Promise<string | undefined>;
|
|
193
|
+
declare function extractCreateWorkspaceManifest(workspace: ManifestWorkspaceInput, iconResolver?: IconResolver): Promise<CreateWorkspaceManifest>;
|
|
194
|
+
/**
|
|
195
|
+
* Extracts all serializable properties from userland schema types,
|
|
196
|
+
* so they best-effort can be used as definitions for Schema.compile
|
|
197
|
+
. */
|
|
198
|
+
declare function extractManifestSchemaTypes(schema: Schema): ManifestSchemaType[];
|
|
199
|
+
declare const validForNamesChars = "a-zA-Z0-9_-";
|
|
200
|
+
declare const validForNamesPattern: RegExp;
|
|
201
|
+
declare function getWorkspaceSchemaId(args: {
|
|
202
|
+
workspaceName: string;
|
|
203
|
+
tag?: string;
|
|
204
|
+
}): {
|
|
205
|
+
safeBaseId: DefaultWorkspaceSchemaId;
|
|
206
|
+
safeTaggedId: WorkspaceSchemaId;
|
|
207
|
+
idWarning: string | undefined;
|
|
208
|
+
};
|
|
209
|
+
interface ParsedWorkspaceSchemaId {
|
|
210
|
+
schemaId: string;
|
|
211
|
+
workspace: string;
|
|
212
|
+
}
|
|
213
|
+
declare function parseWorkspaceSchemaId(id: string, errors: string[]): ParsedWorkspaceSchemaId | undefined;
|
|
214
|
+
declare function createStoredWorkspaceSchemaPayload(args: {
|
|
215
|
+
workspace: {
|
|
216
|
+
name: string;
|
|
217
|
+
title?: string;
|
|
218
|
+
};
|
|
219
|
+
schema: ManifestSchemaType[];
|
|
220
|
+
tag?: string;
|
|
221
|
+
}): Omit<StoredWorkspaceSchema, '_id' | '_type'>;
|
|
47
222
|
declare const builtinTypes: ({
|
|
48
223
|
name: string;
|
|
49
224
|
title: string;
|
|
@@ -58,17 +233,17 @@ declare const builtinTypes: ({
|
|
|
58
233
|
type: string;
|
|
59
234
|
title: string;
|
|
60
235
|
readOnly: boolean;
|
|
236
|
+
fieldset?: undefined;
|
|
61
237
|
validation?: undefined;
|
|
62
238
|
hidden?: undefined;
|
|
63
|
-
fieldset?: undefined;
|
|
64
239
|
} | {
|
|
65
240
|
name: string;
|
|
66
241
|
type: string;
|
|
67
242
|
title: string;
|
|
243
|
+
fieldset?: undefined;
|
|
244
|
+
readOnly?: undefined;
|
|
68
245
|
validation?: undefined;
|
|
69
246
|
hidden?: undefined;
|
|
70
|
-
readOnly?: undefined;
|
|
71
|
-
fieldset?: undefined;
|
|
72
247
|
} | {
|
|
73
248
|
name: string;
|
|
74
249
|
type: string;
|
|
@@ -83,8 +258,8 @@ declare const builtinTypes: ({
|
|
|
83
258
|
readOnly: boolean;
|
|
84
259
|
hidden: boolean;
|
|
85
260
|
fieldset: string;
|
|
86
|
-
validation?: undefined;
|
|
87
261
|
title?: undefined;
|
|
262
|
+
validation?: undefined;
|
|
88
263
|
} | {
|
|
89
264
|
name: string;
|
|
90
265
|
type: string;
|
|
@@ -137,17 +312,17 @@ declare const builtinTypes: ({
|
|
|
137
312
|
type: string;
|
|
138
313
|
title: string;
|
|
139
314
|
readOnly: boolean;
|
|
315
|
+
fieldset?: undefined;
|
|
140
316
|
validation?: undefined;
|
|
141
317
|
hidden?: undefined;
|
|
142
|
-
fieldset?: undefined;
|
|
143
318
|
} | {
|
|
144
319
|
name: string;
|
|
145
320
|
type: string;
|
|
146
321
|
title: string;
|
|
322
|
+
fieldset?: undefined;
|
|
323
|
+
readOnly?: undefined;
|
|
147
324
|
validation?: undefined;
|
|
148
325
|
hidden?: undefined;
|
|
149
|
-
readOnly?: undefined;
|
|
150
|
-
fieldset?: undefined;
|
|
151
326
|
} | {
|
|
152
327
|
name: string;
|
|
153
328
|
type: string;
|
|
@@ -157,21 +332,21 @@ declare const builtinTypes: ({
|
|
|
157
332
|
validation: (Rule: _sanity_types0.Rule) => _sanity_types0.Rule;
|
|
158
333
|
hidden?: undefined;
|
|
159
334
|
} | {
|
|
160
|
-
validation?: undefined;
|
|
161
335
|
name: string;
|
|
162
336
|
type: string;
|
|
163
337
|
readOnly: boolean;
|
|
164
338
|
hidden: boolean;
|
|
165
339
|
fieldset: string;
|
|
166
340
|
title?: undefined;
|
|
167
|
-
} | {
|
|
168
341
|
validation?: undefined;
|
|
169
|
-
|
|
342
|
+
} | {
|
|
170
343
|
name: string;
|
|
171
344
|
type: string;
|
|
172
345
|
title: string;
|
|
173
346
|
readOnly: boolean;
|
|
174
347
|
fieldset: string;
|
|
348
|
+
validation?: undefined;
|
|
349
|
+
hidden?: undefined;
|
|
175
350
|
})[];
|
|
176
351
|
preview: {
|
|
177
352
|
select: {
|
|
@@ -221,17 +396,17 @@ declare const builtinTypes: ({
|
|
|
221
396
|
};
|
|
222
397
|
}[];
|
|
223
398
|
fields: ({
|
|
224
|
-
title?: undefined;
|
|
225
|
-
readOnly?: undefined;
|
|
226
|
-
fieldset?: undefined;
|
|
227
399
|
name: string;
|
|
228
400
|
type: string;
|
|
229
|
-
|
|
401
|
+
fieldset?: undefined;
|
|
402
|
+
title?: undefined;
|
|
230
403
|
readOnly?: undefined;
|
|
404
|
+
} | {
|
|
231
405
|
name: string;
|
|
232
406
|
title: string;
|
|
233
407
|
type: string;
|
|
234
408
|
fieldset: string;
|
|
409
|
+
readOnly?: undefined;
|
|
235
410
|
} | {
|
|
236
411
|
fieldset?: undefined;
|
|
237
412
|
name: string;
|
|
@@ -240,10 +415,6 @@ declare const builtinTypes: ({
|
|
|
240
415
|
readOnly: boolean;
|
|
241
416
|
})[];
|
|
242
417
|
})[];
|
|
243
|
-
declare function createSchemaFromManifestTypes(schemaDef: {
|
|
244
|
-
name: string;
|
|
245
|
-
types: unknown[];
|
|
246
|
-
}): Schema$1;
|
|
247
418
|
interface ExtractSchemaOptions {
|
|
248
419
|
enforceRequiredFields?: boolean;
|
|
249
420
|
}
|
|
@@ -311,4 +482,4 @@ declare class ValidationError extends Error {
|
|
|
311
482
|
problems: SchemaValidationProblemGroup[];
|
|
312
483
|
constructor(problems: SchemaValidationProblemGroup[]);
|
|
313
484
|
}
|
|
314
|
-
export { ALL_FIELDS_GROUP_NAME, DEFAULT_MAX_FIELD_DEPTH, DescriptorConverter, type _FIXME_ as FIXME, type SchemaValidationResult as Problem, type SchemaValidationResult as ValidationResult, type ProblemPath, type ProblemPathPropertySegment, type ProblemPathSegment, type ProblemPathTypeSegment, SchemaSynchronizationRequest, SchemaSynchronizationResult, type TypeWithProblems, ValidationError, builtinTypes, createSchemaFromManifestTypes, extractSchema, groupProblems, isActionEnabled, processSchemaSynchronization, resolveSearchConfig, resolveSearchConfigForBaseFieldPaths, validateMediaLibraryAssetAspect, validateSchema };
|
|
485
|
+
export { ALL_FIELDS_GROUP_NAME, type CreateManifest, type CreateWorkspaceManifest, DEFAULT_MAX_FIELD_DEPTH, type DefaultWorkspaceSchemaId, DescriptorConverter, type _FIXME_ as FIXME, type IconResolver, type ManifestSchemaType, type ManifestWorkspaceFile, type ParsedWorkspaceSchemaId, type SchemaValidationResult as Problem, type SchemaValidationResult as ValidationResult, type ProblemPath, type ProblemPathPropertySegment, type ProblemPathSegment, type ProblemPathTypeSegment, SchemaSynchronizationRequest, SchemaSynchronizationResult, type StoredWorkspaceSchema, type TypeWithProblems, ValidationError, type WorkspaceSchemaId, builtinTypes, createSchemaFromManifestTypes, createStoredWorkspaceSchemaPayload, extractCreateWorkspaceManifest, extractManifestSchemaTypes, extractSchema, getWorkspaceSchemaId, groupProblems, isActionEnabled, parseWorkspaceSchemaId, processSchemaSynchronization, resolveSearchConfig, resolveSearchConfigForBaseFieldPaths, validForNamesChars, validForNamesPattern, validateMediaLibraryAssetAspect, validateSchema };
|