@sanity/validation 2.34.0 → 3.0.0-canary.186
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/dts/src/index.d.ts +36 -0
- package/lib/index.js +1543 -36
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +1542 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +26 -11
- package/src/Rule.ts +6 -2
- package/src/index.ts +1 -1
- package/src/inferFromSchema.ts +7 -1
- package/src/util/convertToValidationMarker.ts +5 -3
- package/src/util/requestIdleCallback.ts +4 -2
- package/src/validateDocument.test.ts +35 -24
- package/src/validateDocument.ts +48 -16
- package/src/validators/dateValidator.ts +4 -4
- package/src/validators/slugValidator.ts +19 -5
- package/src/validators/stringValidator.ts +2 -1
- package/dist/dts/Rule.d.ts +0 -4
- package/dist/dts/Rule.d.ts.map +0 -1
- package/dist/dts/ValidationError.d.ts +0 -4
- package/dist/dts/ValidationError.d.ts.map +0 -1
- package/dist/dts/getClient.d.ts +0 -3
- package/dist/dts/getClient.d.ts.map +0 -1
- package/dist/dts/index.d.ts +0 -14
- package/dist/dts/index.d.ts.map +0 -1
- package/dist/dts/inferFromSchema.d.ts +0 -4
- package/dist/dts/inferFromSchema.d.ts.map +0 -1
- package/dist/dts/inferFromSchemaType.d.ts +0 -5
- package/dist/dts/inferFromSchemaType.d.ts.map +0 -1
- package/dist/dts/util/convertToValidationMarker.d.ts +0 -6
- package/dist/dts/util/convertToValidationMarker.d.ts.map +0 -1
- package/dist/dts/util/deepEquals.d.ts +0 -6
- package/dist/dts/util/deepEquals.d.ts.map +0 -1
- package/dist/dts/util/escapeRegex.d.ts +0 -3
- package/dist/dts/util/escapeRegex.d.ts.map +0 -1
- package/dist/dts/util/normalizeValidationRules.d.ts +0 -6
- package/dist/dts/util/normalizeValidationRules.d.ts.map +0 -1
- package/dist/dts/util/normalizeValidationRules.test.d.ts +0 -2
- package/dist/dts/util/normalizeValidationRules.test.d.ts.map +0 -1
- package/dist/dts/util/pathToString.d.ts +0 -3
- package/dist/dts/util/pathToString.d.ts.map +0 -1
- package/dist/dts/util/requestIdleCallback.d.ts +0 -3
- package/dist/dts/util/requestIdleCallback.d.ts.map +0 -1
- package/dist/dts/util/typeString.d.ts +0 -2
- package/dist/dts/util/typeString.d.ts.map +0 -1
- package/dist/dts/util/typeString.test.d.ts +0 -2
- package/dist/dts/util/typeString.test.d.ts.map +0 -1
- package/dist/dts/validateDocument.d.ts +0 -24
- package/dist/dts/validateDocument.d.ts.map +0 -1
- package/dist/dts/validateDocument.test.d.ts +0 -2
- package/dist/dts/validateDocument.test.d.ts.map +0 -1
- package/dist/dts/validators/arrayValidator.d.ts +0 -4
- package/dist/dts/validators/arrayValidator.d.ts.map +0 -1
- package/dist/dts/validators/booleanValidator.d.ts +0 -4
- package/dist/dts/validators/booleanValidator.d.ts.map +0 -1
- package/dist/dts/validators/dateValidator.d.ts +0 -5
- package/dist/dts/validators/dateValidator.d.ts.map +0 -1
- package/dist/dts/validators/genericValidator.d.ts +0 -4
- package/dist/dts/validators/genericValidator.d.ts.map +0 -1
- package/dist/dts/validators/numberValidator.d.ts +0 -4
- package/dist/dts/validators/numberValidator.d.ts.map +0 -1
- package/dist/dts/validators/objectValidator.d.ts +0 -4
- package/dist/dts/validators/objectValidator.d.ts.map +0 -1
- package/dist/dts/validators/slugValidator.d.ts +0 -9
- package/dist/dts/validators/slugValidator.d.ts.map +0 -1
- package/dist/dts/validators/stringValidator.d.ts +0 -4
- package/dist/dts/validators/stringValidator.d.ts.map +0 -1
- package/jest.config.js +0 -5
- package/lib/Rule.js +0 -491
- package/lib/ValidationError.js +0 -39
- package/lib/getClient.js +0 -20
- package/lib/inferFromSchema.js +0 -22
- package/lib/inferFromSchemaType.js +0 -86
- package/lib/util/convertToValidationMarker.js +0 -65
- package/lib/util/deepEquals.js +0 -87
- package/lib/util/escapeRegex.js +0 -14
- package/lib/util/normalizeValidationRules.js +0 -115
- package/lib/util/pathToString.js +0 -30
- package/lib/util/requestIdleCallback.js +0 -35
- package/lib/util/typeString.js +0 -29
- package/lib/validateDocument.js +0 -242
- package/lib/validators/arrayValidator.js +0 -123
- package/lib/validators/booleanValidator.js +0 -29
- package/lib/validators/dateValidator.js +0 -120
- package/lib/validators/genericValidator.js +0 -135
- package/lib/validators/numberValidator.js +0 -70
- package/lib/validators/objectValidator.js +0 -93
- package/lib/validators/slugValidator.js +0 -133
- package/lib/validators/stringValidator.js +0 -131
- package/src/getClient.ts +0 -13
- package/tsconfig.json +0 -10
package/src/validateDocument.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isBlock,
|
|
3
|
-
isBlockSchemaType,
|
|
4
|
-
isKeyedObject,
|
|
5
|
-
isSpanSchemaType,
|
|
6
|
-
isTypedObject,
|
|
7
2
|
SanityDocument,
|
|
8
3
|
Schema,
|
|
9
4
|
SchemaType,
|
|
10
5
|
ValidationContext,
|
|
11
6
|
ValidationMarker,
|
|
7
|
+
isKeyedObject,
|
|
8
|
+
isTypedObject,
|
|
9
|
+
isBlock,
|
|
10
|
+
isBlockSchemaType,
|
|
11
|
+
isSpanSchemaType,
|
|
12
12
|
} from '@sanity/types'
|
|
13
13
|
import {concat, defer, merge, Observable, of} from 'rxjs'
|
|
14
14
|
import {catchError, map, mergeAll, mergeMap, toArray} from 'rxjs/operators'
|
|
15
15
|
import {flatten, uniqBy} from 'lodash'
|
|
16
|
+
import type {SanityClient} from '@sanity/client'
|
|
16
17
|
import typeString from './util/typeString'
|
|
17
|
-
import {
|
|
18
|
+
import {cancelIdleCallback, requestIdleCallback} from './util/requestIdleCallback'
|
|
18
19
|
import ValidationErrorClass from './ValidationError'
|
|
19
20
|
import normalizeValidationRules from './util/normalizeValidationRules'
|
|
20
21
|
|
|
@@ -50,15 +51,17 @@ export function resolveTypeForArrayItem(
|
|
|
50
51
|
}
|
|
51
52
|
const EMPTY_MARKERS: ValidationMarker[] = []
|
|
52
53
|
|
|
53
|
-
export default function validateDocument(
|
|
54
|
+
export default async function validateDocument(
|
|
55
|
+
getClient: (options: {apiVersion: string}) => SanityClient,
|
|
54
56
|
doc: SanityDocument,
|
|
55
57
|
schema: Schema,
|
|
56
58
|
context?: Pick<ValidationContext, 'getDocumentExists'>
|
|
57
59
|
): Promise<ValidationMarker[]> {
|
|
58
|
-
return validateDocumentObservable(doc, schema, context).toPromise()
|
|
60
|
+
return validateDocumentObservable(getClient, doc, schema, context).toPromise()
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
export function validateDocumentObservable(
|
|
64
|
+
getClient: (options: {apiVersion: string}) => SanityClient,
|
|
62
65
|
doc: SanityDocument,
|
|
63
66
|
schema: Schema,
|
|
64
67
|
context?: Pick<ValidationContext, 'getDocumentExists'>
|
|
@@ -69,14 +72,43 @@ export function validateDocumentObservable(
|
|
|
69
72
|
return of(EMPTY_MARKERS)
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
const client = getClient({apiVersion: '2021-06-07'})
|
|
76
|
+
const validationOptions: ValidateItemOptions = {
|
|
77
|
+
client,
|
|
78
|
+
getClient,
|
|
79
|
+
schema,
|
|
73
80
|
parent: undefined,
|
|
74
81
|
value: doc,
|
|
75
82
|
path: [],
|
|
76
83
|
document: doc,
|
|
77
84
|
type: documentType,
|
|
78
85
|
getDocumentExists: context?.getDocumentExists,
|
|
79
|
-
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// <TEMPORARY UGLY HACK TO PRINT DEPRECATION WARNINGS ON USE>
|
|
89
|
+
/* eslint-disable no-proto */
|
|
90
|
+
const wrappedClient = client as any
|
|
91
|
+
validationOptions.client = [
|
|
92
|
+
...Object.keys(client),
|
|
93
|
+
...Object.keys(wrappedClient.__proto__),
|
|
94
|
+
].reduce((acc, key) => {
|
|
95
|
+
const original = Object.hasOwnProperty.call(client, key)
|
|
96
|
+
? wrappedClient[key]
|
|
97
|
+
: wrappedClient.__proto__[key]
|
|
98
|
+
|
|
99
|
+
return Object.defineProperty(acc, key, {
|
|
100
|
+
get() {
|
|
101
|
+
console.warn(
|
|
102
|
+
'`configContext.client` is deprecated and will be removed in the next release! Use `context.getClient({apiVersion: "2021-06-07"})` instead'
|
|
103
|
+
)
|
|
104
|
+
return original
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
}, {}) as any as SanityClient
|
|
108
|
+
/* eslint-enable no-proto */
|
|
109
|
+
// </TEMPORARY UGLY HACK TO PRINT DEPRECATION WARNINGS ON USE>
|
|
110
|
+
|
|
111
|
+
return validateItemObservable(validationOptions).pipe(
|
|
80
112
|
catchError((err) => {
|
|
81
113
|
console.error(err)
|
|
82
114
|
return of([
|
|
@@ -131,7 +163,7 @@ function validateItemObservable({
|
|
|
131
163
|
)
|
|
132
164
|
|
|
133
165
|
// run validation for nested values (conditionally)
|
|
134
|
-
let
|
|
166
|
+
let nestedChecks: Array<Observable<ValidationMarker[]>> = []
|
|
135
167
|
|
|
136
168
|
const selfIsRequired = rules.some((rule) => rule.isRequired())
|
|
137
169
|
const shouldRunNestedObjectValidation =
|
|
@@ -149,7 +181,7 @@ function validateItemObservable({
|
|
|
149
181
|
}, {})
|
|
150
182
|
|
|
151
183
|
// Validation for rules set at the object level with `Rule.fields({/* ... */})`
|
|
152
|
-
|
|
184
|
+
nestedChecks = nestedChecks.concat(
|
|
153
185
|
rules
|
|
154
186
|
.map((rule) => rule._fieldRules)
|
|
155
187
|
.filter(isNonNullable)
|
|
@@ -171,7 +203,7 @@ function validateItemObservable({
|
|
|
171
203
|
)
|
|
172
204
|
|
|
173
205
|
// Validation from each field's schema `validation: Rule => {/* ... */}` function
|
|
174
|
-
|
|
206
|
+
nestedChecks = nestedChecks.concat(
|
|
175
207
|
type.fields.map((field) =>
|
|
176
208
|
validateItemObservable({
|
|
177
209
|
...restOfContext,
|
|
@@ -191,7 +223,7 @@ function validateItemObservable({
|
|
|
191
223
|
const shouldRunNestedValidationForArrays = type?.jsonType === 'array' && Array.isArray(value)
|
|
192
224
|
|
|
193
225
|
if (shouldRunNestedValidationForArrays) {
|
|
194
|
-
|
|
226
|
+
nestedChecks = nestedChecks.concat(
|
|
195
227
|
value.map((item) =>
|
|
196
228
|
validateItemObservable({
|
|
197
229
|
...restOfContext,
|
|
@@ -221,7 +253,7 @@ function validateItemObservable({
|
|
|
221
253
|
new Map()
|
|
222
254
|
)
|
|
223
255
|
|
|
224
|
-
|
|
256
|
+
nestedChecks = nestedChecks.concat(
|
|
225
257
|
value.markDefs.map((markDef) =>
|
|
226
258
|
validateItemObservable({
|
|
227
259
|
...restOfContext,
|
|
@@ -234,7 +266,7 @@ function validateItemObservable({
|
|
|
234
266
|
)
|
|
235
267
|
}
|
|
236
268
|
|
|
237
|
-
return defer(() => merge([...selfChecks, ...
|
|
269
|
+
return defer(() => merge([...selfChecks, ...nestedChecks])).pipe(
|
|
238
270
|
mergeMap((validateNode) => concat(idle(), validateNode), 40),
|
|
239
271
|
mergeAll(),
|
|
240
272
|
toArray(),
|
|
@@ -6,8 +6,8 @@ export function isRecord(obj: unknown): obj is Record<string, unknown> {
|
|
|
6
6
|
return typeof obj === 'object' && obj !== null && !Array.isArray(obj)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const isoDate =
|
|
10
|
+
/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line no-warning-comments
|
|
13
13
|
// TODO (eventually): move these to schema type package
|
|
@@ -79,7 +79,7 @@ const dateValidators: Validators = {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const dateTimeOptions: DateTimeOptions = isRecord(context.type.options)
|
|
82
|
-
? context.type.options
|
|
82
|
+
? (context.type.options as DateTimeOptions)
|
|
83
83
|
: {}
|
|
84
84
|
|
|
85
85
|
const date = getFormattedDate(context.type.name, minDate, dateTimeOptions)
|
|
@@ -102,7 +102,7 @@ const dateValidators: Validators = {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
const dateTimeOptions: DateTimeOptions = isRecord(context.type.options)
|
|
105
|
-
? context.type.options
|
|
105
|
+
? (context.type.options as DateTimeOptions)
|
|
106
106
|
: {}
|
|
107
107
|
|
|
108
108
|
const date = getFormattedDate(context.type.name, maxDate, dateTimeOptions)
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
SlugIsUniqueValidator,
|
|
3
|
+
Path,
|
|
4
|
+
CustomValidator,
|
|
5
|
+
isKeyedObject,
|
|
6
|
+
SlugValidationContext,
|
|
7
|
+
SlugParent,
|
|
8
|
+
SlugSchemaType,
|
|
9
|
+
} from '@sanity/types'
|
|
2
10
|
import {memoize} from 'lodash'
|
|
3
|
-
import getClient from '../getClient'
|
|
11
|
+
// import getClient from '../getClient'
|
|
4
12
|
|
|
5
13
|
const memoizedWarnOnArraySlug = memoize(warnOnArraySlug)
|
|
6
14
|
|
|
@@ -23,7 +31,7 @@ function serializePath(path: Path): string {
|
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
const defaultIsUnique: SlugIsUniqueValidator = (slug, context) => {
|
|
26
|
-
const {document, path, type} = context
|
|
34
|
+
const {getClient, document, path, type} = context
|
|
27
35
|
const schemaOptions = type?.options as {disableArrayWarning?: boolean} | undefined
|
|
28
36
|
|
|
29
37
|
if (!document) {
|
|
@@ -48,7 +56,7 @@ const defaultIsUnique: SlugIsUniqueValidator = (slug, context) => {
|
|
|
48
56
|
`${atPath} == $slug`,
|
|
49
57
|
].join(' && ')
|
|
50
58
|
|
|
51
|
-
return getClient().fetch<boolean>(
|
|
59
|
+
return getClient({apiVersion: '2022-09-09'}).fetch<boolean>(
|
|
52
60
|
`!defined(*[${constraints}][0]._id)`,
|
|
53
61
|
{
|
|
54
62
|
docType,
|
|
@@ -94,7 +102,13 @@ export const slugValidator: CustomValidator = async (value, context) => {
|
|
|
94
102
|
const options = context?.type?.options as {isUnique?: SlugIsUniqueValidator} | undefined
|
|
95
103
|
const isUnique = options?.isUnique || defaultIsUnique
|
|
96
104
|
|
|
97
|
-
const
|
|
105
|
+
const slugContext: SlugValidationContext = {
|
|
106
|
+
...context,
|
|
107
|
+
parent: context.parent as SlugParent,
|
|
108
|
+
type: context.type as SlugSchemaType,
|
|
109
|
+
defaultIsUnique,
|
|
110
|
+
}
|
|
111
|
+
const wasUnique = await isUnique(slugValue, slugContext)
|
|
98
112
|
if (wasUnique) {
|
|
99
113
|
return true
|
|
100
114
|
}
|
|
@@ -2,7 +2,8 @@ import {Validators} from '@sanity/types'
|
|
|
2
2
|
import genericValidator from './genericValidator'
|
|
3
3
|
|
|
4
4
|
const DUMMY_ORIGIN = 'http://sanity'
|
|
5
|
-
const emailRegex =
|
|
5
|
+
const emailRegex =
|
|
6
|
+
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
6
7
|
const isRelativeUrl = (url: string) => /^\.*\//.test(url)
|
|
7
8
|
|
|
8
9
|
const stringValidators: Validators = {
|
package/dist/dts/Rule.d.ts
DELETED
package/dist/dts/Rule.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Rule.d.ts","sourceRoot":"","sources":["../../src/Rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAUV,MAAM,eAAe,CAAA;AA0DtB,QAAA,MAAM,IAAI,EAAE,SAkWX,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../src/ValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,oBAAoB,EACrB,MAAM,eAAe,CAAA;AAGtB,QAAA,MAAM,eAAe,EAAE,oBAoBtB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
package/dist/dts/getClient.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getClient.d.ts","sourceRoot":"","sources":["../../src/getClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAIhD,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI,YAAY,CAQhD"}
|
package/dist/dts/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import RuleClass from './Rule';
|
|
2
|
-
import validateDocument from './validateDocument';
|
|
3
|
-
import inferFromSchema from './inferFromSchema';
|
|
4
|
-
import inferFromSchemaType from './inferFromSchemaType';
|
|
5
|
-
declare const _default: {
|
|
6
|
-
Rule: import("@sanity/types/dist/dts").RuleClass;
|
|
7
|
-
validateDocument: typeof validateDocument;
|
|
8
|
-
inferFromSchema: typeof inferFromSchema;
|
|
9
|
-
inferFromSchemaType: typeof inferFromSchemaType;
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|
|
12
|
-
export { RuleClass as Rule, validateDocument, inferFromSchema, inferFromSchemaType };
|
|
13
|
-
export { validateDocumentObservable } from './validateDocument';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/dts/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,QAAQ,CAAA;AAC9B,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;;;;;;;AAEvD,wBAAwF;AACxF,OAAO,EAAC,SAAS,IAAI,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAC,CAAA;AAElF,OAAO,EAAC,0BAA0B,EAAC,MAAM,oBAAoB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inferFromSchema.d.ts","sourceRoot":"","sources":["../../src/inferFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAA;AAIpC,iBAAS,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Schema, SchemaType } from '@sanity/types';
|
|
2
|
-
declare function inferFromSchemaType(typeDef: SchemaType, _schema: Schema, _visited?: Set<SchemaType>): SchemaType;
|
|
3
|
-
declare function inferFromSchemaType(typeDef: SchemaType): SchemaType;
|
|
4
|
-
export default inferFromSchemaType;
|
|
5
|
-
//# sourceMappingURL=inferFromSchemaType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inferFromSchemaType.d.ts","sourceRoot":"","sources":["../../src/inferFromSchemaType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,eAAe,CAAA;AAoChD,iBAAS,mBAAmB,CAC1B,OAAO,EAAE,UAAU,EAEnB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,GACzB,UAAU,CAAA;AAEb,iBAAS,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAAA;AAM7D,eAAe,mBAAmB,CAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ValidationMarker, ValidationError, ValidationContext } from '@sanity/types';
|
|
2
|
-
declare type ValidationErrorLike = Pick<ValidationError, 'message'> & Partial<ValidationError>;
|
|
3
|
-
export declare function isNonNullable<T>(t: T): t is NonNullable<T>;
|
|
4
|
-
export default function convertToValidationMarker(validatorResult: true | true[] | string | string[] | ValidationError | ValidationError[] | ValidationErrorLike | ValidationErrorLike[], level: 'error' | 'warning' | 'info' | undefined, context: ValidationContext): ValidationMarker[];
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=convertToValidationMarker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertToValidationMarker.d.ts","sourceRoot":"","sources":["../../../src/util/convertToValidationMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAIlF,aAAK,mBAAmB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAEtF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAE1D;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,eAAe,EACX,IAAI,GACJ,IAAI,EAAE,GACN,MAAM,GACN,MAAM,EAAE,GACR,eAAe,GACf,eAAe,EAAE,GACjB,mBAAmB,GACnB,mBAAmB,EAAE,EACzB,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EAC/C,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,EAAE,CA2DpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepEquals.d.ts","sourceRoot":"","sources":["../../../src/util/deepEquals.ts"],"names":[],"mappings":"AAAA;;;IAGI;AAOJ,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAkElE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"escapeRegex.d.ts","sourceRoot":"","sources":["../../../src/util/escapeRegex.ts"],"names":[],"mappings":"iCACwB,MAAM,KAAG,MAAM;AAAvC,wBAGC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SchemaType, Rule } from '@sanity/types';
|
|
2
|
-
/**
|
|
3
|
-
* Takes in `SchemaValidationValue` and returns an array of `Rule` instances.
|
|
4
|
-
*/
|
|
5
|
-
export default function normalizeValidationRules(typeDef: SchemaType | undefined): Rule[];
|
|
6
|
-
//# sourceMappingURL=normalizeValidationRules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeValidationRules.d.ts","sourceRoot":"","sources":["../../../src/util/normalizeValidationRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAqB,MAAM,eAAe,CAAA;AA6ElE;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,EAAE,CAqCxF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeValidationRules.test.d.ts","sourceRoot":"","sources":["../../../src/util/normalizeValidationRules.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathToString.d.ts","sourceRoot":"","sources":["../../../src/util/pathToString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAgB,MAAM,eAAe,CAAA;AAEjD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAI,GAAE,IAAI,GAAG,SAAc,GAAG,MAAM,CAkBxE"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const requestIdleCallback: ((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof globalThis.requestIdleCallback;
|
|
2
|
-
export declare const cancelIdleCallback: ((handle: number) => void) & typeof globalThis.cancelIdleCallback;
|
|
3
|
-
//# sourceMappingURL=requestIdleCallback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestIdleCallback.d.ts","sourceRoot":"","sources":["../../../src/util/requestIdleCallback.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,mBAAmB,+HAAwD,CAAA;AACxF,eAAO,MAAM,kBAAkB,mEAAsD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeString.d.ts","sourceRoot":"","sources":["../../../src/util/typeString.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CASvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeString.test.d.ts","sourceRoot":"","sources":["../../../src/util/typeString.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SanityDocument, Schema, SchemaType, ValidationContext, ValidationMarker } from '@sanity/types';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveTypeForArrayItem(item: unknown, candidates: SchemaType[]): SchemaType | undefined;
|
|
7
|
-
export default function validateDocument(doc: SanityDocument, schema: Schema, context?: Pick<ValidationContext, 'getDocumentExists'>): Promise<ValidationMarker[]>;
|
|
8
|
-
export declare function validateDocumentObservable(doc: SanityDocument, schema: Schema, context?: Pick<ValidationContext, 'getDocumentExists'>): Observable<ValidationMarker[]>;
|
|
9
|
-
/**
|
|
10
|
-
* this is used make optional properties required by replacing optionals with
|
|
11
|
-
* `T[P] | undefined`. this is used to prevent errors in `validateItem` where
|
|
12
|
-
* an option from a previous invocation would be incorrectly passed down.
|
|
13
|
-
*
|
|
14
|
-
* https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585
|
|
15
|
-
*/
|
|
16
|
-
declare type ExplicitUndefined<T> = {
|
|
17
|
-
[P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined;
|
|
18
|
-
};
|
|
19
|
-
declare type ValidateItemOptions = {
|
|
20
|
-
value: unknown;
|
|
21
|
-
} & ExplicitUndefined<ValidationContext>;
|
|
22
|
-
export declare function validateItem(opts: ValidateItemOptions): Promise<ValidationMarker[]>;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=validateDocument.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateDocument.d.ts","sourceRoot":"","sources":["../../src/validateDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,cAAc,EACd,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAuB,UAAU,EAAK,MAAM,MAAM,CAAA;AAczD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,EAAE,GACvB,UAAU,GAAG,SAAS,CAiBxB;AAGD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,GACrD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE7B;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,GACrD,UAAU,CAAC,gBAAgB,EAAE,CAAC,CA2BhC;AAED;;;;;;GAMG;AACH,aAAK,iBAAiB,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;CAC5F,CAAA;AAED,aAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,OAAO,CAAA;CACf,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,CAAA;AAExC,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAEnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateDocument.test.d.ts","sourceRoot":"","sources":["../../src/validateDocument.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/arrayValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,UAAU,EAAC,MAAM,eAAe,CAAA;AAK3D,QAAA,MAAM,eAAe,EAAE,UA4FtB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"booleanValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/booleanValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AAGxC,QAAA,MAAM,iBAAiB,EAAE,UAUxB,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dateValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/dateValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AAIxC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAErE;AAiDD,QAAA,MAAM,cAAc,EAAE,UAuDrB,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genericValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/genericValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAC,MAAM,eAAe,CAAA;AA+B1D,QAAA,MAAM,iBAAiB,EAAE,UAmFxB,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"numberValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/numberValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AAKxC,QAAA,MAAM,gBAAgB,EAAE,UA0DvB,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objectValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/objectValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAc,MAAM,eAAe,CAAA;AAKrD,QAAA,MAAM,gBAAgB,EAAE,UAwDvB,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CustomValidator } from '@sanity/types';
|
|
2
|
-
/**
|
|
3
|
-
* Validates slugs values by querying for uniqueness from the client.
|
|
4
|
-
*
|
|
5
|
-
* This is a custom rule implementation (e.g. `Rule.custom(slugValidator)`)
|
|
6
|
-
* that's populated in `inferFromSchemaType` when the type name is `slug`
|
|
7
|
-
*/
|
|
8
|
-
export declare const slugValidator: CustomValidator;
|
|
9
|
-
//# sourceMappingURL=slugValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slugValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/slugValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,eAAe,EAAgB,MAAM,eAAe,CAAA;AA0EzF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,eAsB3B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringValidator.d.ts","sourceRoot":"","sources":["../../../src/validators/stringValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AAOxC,QAAA,MAAM,gBAAgB,EAAE,UA6GvB,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|