@sanity/util 5.8.0 → 5.8.1-next.1
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/client.d.ts +3 -3
- package/lib/concurrency-limiter.d.ts +7 -7
- package/lib/content.d.ts +12 -10
- package/lib/createSafeJsonParser.d.cts +6 -4
- package/lib/createSafeJsonParser.d.ts +6 -4
- package/lib/fs.d.ts +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/legacyDateFormat.d.ts +17 -17
- package/lib/paths.d.ts +38 -22
- package/package.json +27 -27
package/lib/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SanityClient} from
|
|
1
|
+
import { SanityClient } from "@sanity/client";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Decorates a sanity client to limit the concurrency of `client.fetch`
|
|
@@ -7,6 +7,6 @@ import {SanityClient} from '@sanity/client'
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function createClientConcurrencyLimiter(
|
|
9
9
|
maxConcurrency: number,
|
|
10
|
-
): (input: SanityClient) => SanityClient
|
|
10
|
+
): (input: SanityClient) => SanityClient;
|
|
11
11
|
|
|
12
|
-
export {}
|
|
12
|
+
export {};
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
* It ensures that the number of operations does not exceed a specified maximum limit.
|
|
4
4
|
*/
|
|
5
5
|
export declare class ConcurrencyLimiter {
|
|
6
|
-
current: number
|
|
7
|
-
resolvers: Array<() => void
|
|
8
|
-
max: number
|
|
9
|
-
constructor(max: number)
|
|
6
|
+
current: number;
|
|
7
|
+
resolvers: Array<() => void>;
|
|
8
|
+
max: number;
|
|
9
|
+
constructor(max: number);
|
|
10
10
|
/**
|
|
11
11
|
* Indicates when a slot for a new operation is ready.
|
|
12
12
|
* If under the limit, it resolves immediately; otherwise, it waits until a slot is free.
|
|
13
13
|
*/
|
|
14
|
-
ready: () => Promise<void
|
|
14
|
+
ready: () => Promise<void>;
|
|
15
15
|
/**
|
|
16
16
|
* Releases a slot, decrementing the current count of operations if nothing is in the queue.
|
|
17
17
|
* If there are operations waiting, it allows the next one in the queue to proceed.
|
|
18
18
|
*/
|
|
19
|
-
release: () => void
|
|
19
|
+
release: () => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export {}
|
|
22
|
+
export {};
|
package/lib/content.d.ts
CHANGED
|
@@ -6,34 +6,36 @@
|
|
|
6
6
|
* - an array where all items are deeply empty
|
|
7
7
|
* @param value - the value to check for deep emptiness
|
|
8
8
|
*/
|
|
9
|
-
export declare function isDeepEmpty(value: unknown): boolean
|
|
9
|
+
export declare function isDeepEmpty(value: unknown): boolean;
|
|
10
10
|
|
|
11
|
-
declare function isDeepEmptyArray(value: unknown[]): boolean
|
|
11
|
+
declare function isDeepEmptyArray(value: unknown[]): boolean;
|
|
12
12
|
|
|
13
|
-
declare function isDeepEmptyObject(value: {[key: string]: any}): boolean
|
|
13
|
+
declare function isDeepEmptyObject(value: { [key: string]: any }): boolean;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @deprecated Use `isDeepEmpty` instead
|
|
17
17
|
* todo: remove in v4
|
|
18
18
|
*/
|
|
19
|
-
export declare const isEmpty: typeof isDeepEmpty
|
|
19
|
+
export declare const isEmpty: typeof isDeepEmpty;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @deprecated Use `isDeepEmpty` instead
|
|
23
23
|
* todo: remove in v4
|
|
24
24
|
*/
|
|
25
|
-
export declare const isEmptyArray: typeof isDeepEmptyArray
|
|
25
|
+
export declare const isEmptyArray: typeof isDeepEmptyArray;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @deprecated Use `isDeepEmpty` instead
|
|
29
29
|
* todo: remove in v4
|
|
30
30
|
*/
|
|
31
|
-
export declare const isEmptyObject: typeof isDeepEmptyObject
|
|
31
|
+
export declare const isEmptyObject: typeof isDeepEmptyObject;
|
|
32
32
|
|
|
33
|
-
export declare function isShallowEmptyObject(value: {
|
|
33
|
+
export declare function isShallowEmptyObject(value: {
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}): boolean;
|
|
34
36
|
|
|
35
|
-
export declare function randomKey(length?: number): string
|
|
37
|
+
export declare function randomKey(length?: number): string;
|
|
36
38
|
|
|
37
|
-
export declare function resolveTypeName(value: unknown): string
|
|
39
|
+
export declare function resolveTypeName(value: unknown): string;
|
|
38
40
|
|
|
39
|
-
export {}
|
|
41
|
+
export {};
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
* @internal
|
|
7
7
|
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
8
8
|
*/
|
|
9
|
-
export declare function createSafeJsonParser<Type>({
|
|
9
|
+
export declare function createSafeJsonParser<Type>({
|
|
10
|
+
errorLabel,
|
|
11
|
+
}: Options): Parser<Type>;
|
|
10
12
|
|
|
11
13
|
declare interface Options {
|
|
12
|
-
errorLabel: string
|
|
14
|
+
errorLabel: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
declare type Parser<Type> = (line: string) => Type
|
|
17
|
+
declare type Parser<Type> = (line: string) => Type;
|
|
16
18
|
|
|
17
|
-
export {}
|
|
19
|
+
export {};
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
* @internal
|
|
7
7
|
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
8
8
|
*/
|
|
9
|
-
export declare function createSafeJsonParser<Type>({
|
|
9
|
+
export declare function createSafeJsonParser<Type>({
|
|
10
|
+
errorLabel,
|
|
11
|
+
}: Options): Parser<Type>;
|
|
10
12
|
|
|
11
13
|
declare interface Options {
|
|
12
|
-
errorLabel: string
|
|
14
|
+
errorLabel: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
declare type Parser<Type> = (line: string) => Type
|
|
17
|
+
declare type Parser<Type> = (line: string) => Type;
|
|
16
18
|
|
|
17
|
-
export {}
|
|
19
|
+
export {};
|
package/lib/fs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare function absolutify(dir: string): string
|
|
1
|
+
export declare function absolutify(dir: string): string;
|
|
2
2
|
|
|
3
|
-
export declare function expandHome(filePath: string): string
|
|
3
|
+
export declare function expandHome(filePath: string): string;
|
|
4
4
|
|
|
5
|
-
export declare function pathIsEmpty(dir: string): Promise<boolean
|
|
5
|
+
export declare function pathIsEmpty(dir: string): Promise<boolean>;
|
|
6
6
|
|
|
7
|
-
export {}
|
|
7
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
export declare const DEFAULT_DATE_FORMAT =
|
|
1
|
+
export declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
2
2
|
|
|
3
|
-
export declare const DEFAULT_TIME_FORMAT =
|
|
3
|
+
export declare const DEFAULT_TIME_FORMAT = "HH:mm";
|
|
4
4
|
|
|
5
5
|
export declare function format(
|
|
6
6
|
input: Date,
|
|
7
7
|
dateFormat: string,
|
|
8
8
|
options?: {
|
|
9
|
-
useUTC?: boolean
|
|
10
|
-
timeZone?: string
|
|
9
|
+
useUTC?: boolean;
|
|
10
|
+
timeZone?: string;
|
|
11
11
|
},
|
|
12
|
-
): string
|
|
12
|
+
): string;
|
|
13
13
|
|
|
14
|
-
export declare function isValidTimeZoneString(timeZone: string): boolean
|
|
14
|
+
export declare function isValidTimeZoneString(timeZone: string): boolean;
|
|
15
15
|
|
|
16
16
|
export declare function parse(
|
|
17
17
|
dateString: string,
|
|
18
18
|
dateFormat?: string,
|
|
19
19
|
timeZone?: string,
|
|
20
|
-
): ParseResult
|
|
20
|
+
): ParseResult;
|
|
21
21
|
|
|
22
22
|
export declare type ParseResult = {
|
|
23
|
-
isValid: boolean
|
|
24
|
-
date?: Date
|
|
25
|
-
error?: string
|
|
23
|
+
isValid: boolean;
|
|
24
|
+
date?: Date;
|
|
25
|
+
error?: string;
|
|
26
26
|
} & (
|
|
27
27
|
| {
|
|
28
|
-
isValid: true
|
|
29
|
-
date: Date
|
|
28
|
+
isValid: true;
|
|
29
|
+
date: Date;
|
|
30
30
|
}
|
|
31
31
|
| {
|
|
32
|
-
isValid: false
|
|
33
|
-
error?: string
|
|
32
|
+
isValid: false;
|
|
33
|
+
error?: string;
|
|
34
34
|
}
|
|
35
|
-
)
|
|
35
|
+
);
|
|
36
36
|
|
|
37
|
-
export declare const sanitizeLocale: (locale: string) => string
|
|
37
|
+
export declare const sanitizeLocale: (locale: string) => string;
|
|
38
38
|
|
|
39
|
-
export {}
|
|
39
|
+
export {};
|
package/lib/paths.d.ts
CHANGED
|
@@ -1,27 +1,43 @@
|
|
|
1
|
-
import {Path} from
|
|
2
|
-
import {PathSegment} from
|
|
1
|
+
import { Path } from "@sanity/types";
|
|
2
|
+
import { PathSegment } from "@sanity/types";
|
|
3
3
|
|
|
4
|
-
export declare const FOCUS_TERMINATOR =
|
|
4
|
+
export declare const FOCUS_TERMINATOR = "$";
|
|
5
5
|
|
|
6
|
-
export declare function fromString(path: string): Path
|
|
6
|
+
export declare function fromString(path: string): Path;
|
|
7
7
|
|
|
8
|
-
export declare function get<R>(
|
|
8
|
+
export declare function get<R>(
|
|
9
|
+
obj: unknown,
|
|
10
|
+
path: Path | string,
|
|
11
|
+
): R | undefined;
|
|
9
12
|
|
|
10
|
-
export declare function get<R>(
|
|
13
|
+
export declare function get<R>(
|
|
14
|
+
obj: unknown,
|
|
15
|
+
path: Path | string,
|
|
16
|
+
defaultValue: R,
|
|
17
|
+
): R;
|
|
11
18
|
|
|
12
|
-
export declare function hasFocus(focusPath: Path, path: Path): boolean
|
|
19
|
+
export declare function hasFocus(focusPath: Path, path: Path): boolean;
|
|
13
20
|
|
|
14
|
-
export declare function hasItemFocus(
|
|
21
|
+
export declare function hasItemFocus(
|
|
22
|
+
focusPath: Path,
|
|
23
|
+
item: PathSegment,
|
|
24
|
+
): boolean;
|
|
15
25
|
|
|
16
|
-
export declare function isEqual(path: Path, otherPath: Path): boolean
|
|
26
|
+
export declare function isEqual(path: Path, otherPath: Path): boolean;
|
|
17
27
|
|
|
18
|
-
export declare function isExpanded(
|
|
28
|
+
export declare function isExpanded(
|
|
29
|
+
segment: PathSegment,
|
|
30
|
+
focusPath: Path,
|
|
31
|
+
): boolean;
|
|
19
32
|
|
|
20
|
-
export declare function isSegmentEqual(
|
|
33
|
+
export declare function isSegmentEqual(
|
|
34
|
+
segmentA: PathSegment,
|
|
35
|
+
segmentB: PathSegment,
|
|
36
|
+
): boolean;
|
|
21
37
|
|
|
22
|
-
export declare function numEqualSegments(path: Path, otherPath: Path): number
|
|
38
|
+
export declare function numEqualSegments(path: Path, otherPath: Path): number;
|
|
23
39
|
|
|
24
|
-
export declare function pathFor(path: Path): Path
|
|
40
|
+
export declare function pathFor(path: Path): Path;
|
|
25
41
|
|
|
26
42
|
/**
|
|
27
43
|
* Takes a value and a path that may include numeric indices and attempts to replace numeric indices with keyed paths
|
|
@@ -35,19 +51,19 @@ export declare function pathFor(path: Path): Path
|
|
|
35
51
|
* - `resolveKeyedPath([0, 'foo', 'bar'], [{_key: 'xyz'}])` will return `[{_key: 'xyz'}, 'foo', 'bar']` since array has no value at index 0
|
|
36
52
|
* Object keys will be preserved as-is, e.g. `resolveKeyedPath(['foo', 'bar'], undefined)` will return `['foo', 'bar']`
|
|
37
53
|
*/
|
|
38
|
-
export declare function resolveKeyedPath(value: unknown, path: Path): Path
|
|
54
|
+
export declare function resolveKeyedPath(value: unknown, path: Path): Path;
|
|
39
55
|
|
|
40
|
-
export declare function _resolveKeyedPath(value: unknown, path: Path): Path
|
|
56
|
+
export declare function _resolveKeyedPath(value: unknown, path: Path): Path;
|
|
41
57
|
|
|
42
|
-
export declare function startsWith(prefix: Path, path: Path): boolean
|
|
58
|
+
export declare function startsWith(prefix: Path, path: Path): boolean;
|
|
43
59
|
|
|
44
|
-
declare function toString_2(path: Path): string
|
|
45
|
-
export {toString_2 as toString}
|
|
60
|
+
declare function toString_2(path: Path): string;
|
|
61
|
+
export { toString_2 as toString };
|
|
46
62
|
|
|
47
|
-
export declare function trimChildPath(path: Path, childPath: Path): Path
|
|
63
|
+
export declare function trimChildPath(path: Path, childPath: Path): Path;
|
|
48
64
|
|
|
49
|
-
export declare function trimLeft(prefix: Path, path: Path): Path
|
|
65
|
+
export declare function trimLeft(prefix: Path, path: Path): Path;
|
|
50
66
|
|
|
51
|
-
export declare function trimRight(suffix: Path, path: Path): Path
|
|
67
|
+
export declare function trimRight(suffix: Path, path: Path): Path;
|
|
52
68
|
|
|
53
|
-
export {}
|
|
69
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,42 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/util",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.1-next.1+a2c187ff7a",
|
|
4
4
|
"description": "Utilities shared across projects of Sanity",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"sanity",
|
|
7
6
|
"cms",
|
|
7
|
+
"content",
|
|
8
8
|
"headless",
|
|
9
9
|
"realtime",
|
|
10
|
-
"
|
|
10
|
+
"sanity",
|
|
11
11
|
"util"
|
|
12
12
|
],
|
|
13
13
|
"homepage": "https://www.sanity.io/",
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/sanity-io/sanity/issues"
|
|
16
16
|
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
19
21
|
"url": "git+https://github.com/sanity-io/sanity.git",
|
|
20
22
|
"directory": "packages/@sanity/util"
|
|
21
23
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
"files": [
|
|
25
|
+
"lib"
|
|
26
|
+
],
|
|
25
27
|
"type": "module",
|
|
26
|
-
"
|
|
27
|
-
".": "./lib/index.js",
|
|
28
|
-
"./fs": "./lib/fs.js",
|
|
29
|
-
"./client": "./lib/client.js",
|
|
30
|
-
"./concurrency-limiter": "./lib/concurrency-limiter.js",
|
|
31
|
-
"./content": "./lib/content.js",
|
|
32
|
-
"./createSafeJsonParser": {
|
|
33
|
-
"require": "./lib/createSafeJsonParser.cjs",
|
|
34
|
-
"default": "./lib/createSafeJsonParser.js"
|
|
35
|
-
},
|
|
36
|
-
"./legacyDateFormat": "./lib/legacyDateFormat.js",
|
|
37
|
-
"./paths": "./lib/paths.js",
|
|
38
|
-
"./package.json": "./package.json"
|
|
39
|
-
},
|
|
28
|
+
"sideEffects": false,
|
|
40
29
|
"main": "./lib/index.js",
|
|
41
30
|
"types": "./lib/index.d.ts",
|
|
42
31
|
"typesVersions": {
|
|
@@ -64,9 +53,20 @@
|
|
|
64
53
|
]
|
|
65
54
|
}
|
|
66
55
|
},
|
|
67
|
-
"
|
|
68
|
-
"lib"
|
|
69
|
-
|
|
56
|
+
"exports": {
|
|
57
|
+
".": "./lib/index.js",
|
|
58
|
+
"./fs": "./lib/fs.js",
|
|
59
|
+
"./client": "./lib/client.js",
|
|
60
|
+
"./concurrency-limiter": "./lib/concurrency-limiter.js",
|
|
61
|
+
"./content": "./lib/content.js",
|
|
62
|
+
"./createSafeJsonParser": {
|
|
63
|
+
"require": "./lib/createSafeJsonParser.cjs",
|
|
64
|
+
"default": "./lib/createSafeJsonParser.js"
|
|
65
|
+
},
|
|
66
|
+
"./legacyDateFormat": "./lib/legacyDateFormat.js",
|
|
67
|
+
"./paths": "./lib/paths.js",
|
|
68
|
+
"./package.json": "./package.json"
|
|
69
|
+
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@date-fns/tz": "^1.4.1",
|
|
72
72
|
"@date-fns/utc": "^2.1.1",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"eslint": "^9.39.2",
|
|
83
83
|
"rimraf": "^5.0.10",
|
|
84
84
|
"vitest": "^4.0.18",
|
|
85
|
-
"@repo/eslint-config": "5.8.
|
|
86
|
-
"@repo/
|
|
87
|
-
"@repo/
|
|
88
|
-
"@repo/
|
|
85
|
+
"@repo/eslint-config": "5.8.1-next.1+a2c187ff7a",
|
|
86
|
+
"@repo/test-config": "5.8.1-next.1+a2c187ff7a",
|
|
87
|
+
"@repo/package.config": "5.8.1-next.1+a2c187ff7a",
|
|
88
|
+
"@repo/tsconfig": "5.8.1-next.1+a2c187ff7a"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=20.19 <22 || >=22.12"
|