@sanity/util 5.8.1-next.8 → 5.8.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 +2 -6
- package/lib/concurrency-limiter.d.ts +2 -3
- package/lib/content.d.ts +12 -19
- package/lib/createSafeJsonParser.d.cts +7 -10
- package/lib/createSafeJsonParser.d.ts +7 -10
- package/lib/fs.d.ts +4 -7
- package/lib/index.d.ts +1 -1
- package/lib/legacyDateFormat.d.ts +18 -36
- package/lib/paths.d.ts +20 -57
- package/package.json +6 -6
package/lib/client.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { SanityClient } from "@sanity/client";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Decorates a sanity client to limit the concurrency of `client.fetch`
|
|
5
4
|
* requests. Keeps the concurrency limit state and returns wrapped clients with
|
|
6
5
|
* that same state if the `clone` `config` or `withConfig` methods are called.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
): (input: SanityClient) => SanityClient;
|
|
11
|
-
|
|
12
|
-
export {};
|
|
7
|
+
declare function createClientConcurrencyLimiter(maxConcurrency: number): (input: SanityClient) => SanityClient;
|
|
8
|
+
export { createClientConcurrencyLimiter };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ConcurrencyLimiter manages the number of concurrent operations that can be performed.
|
|
3
3
|
* It ensures that the number of operations does not exceed a specified maximum limit.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare class ConcurrencyLimiter {
|
|
6
6
|
current: number;
|
|
7
7
|
resolvers: Array<() => void>;
|
|
8
8
|
max: number;
|
|
@@ -18,5 +18,4 @@ export declare class ConcurrencyLimiter {
|
|
|
18
18
|
*/
|
|
19
19
|
release: () => void;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
export {};
|
|
21
|
+
export { ConcurrencyLimiter };
|
package/lib/content.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
declare function isDeepEmptyObject(value: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}): boolean;
|
|
4
|
+
declare function isDeepEmptyArray(value: unknown[]): boolean;
|
|
1
5
|
/**
|
|
2
6
|
* Looks at the value and determines if it is deeply empty while not considering _type and _key attributes on objects.
|
|
3
7
|
* A value will be considered deeply empty if it is:
|
|
@@ -6,36 +10,25 @@
|
|
|
6
10
|
* - an array where all items are deeply empty
|
|
7
11
|
* @param value - the value to check for deep emptiness
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare function isDeepEmptyArray(value: unknown[]): boolean;
|
|
12
|
-
|
|
13
|
-
declare function isDeepEmptyObject(value: { [key: string]: any }): boolean;
|
|
14
|
-
|
|
13
|
+
declare function isDeepEmpty(value: unknown): boolean;
|
|
15
14
|
/**
|
|
16
15
|
* @deprecated Use `isDeepEmpty` instead
|
|
17
16
|
* todo: remove in v4
|
|
18
17
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
declare const isEmptyArray: typeof isDeepEmptyArray;
|
|
21
19
|
/**
|
|
22
20
|
* @deprecated Use `isDeepEmpty` instead
|
|
23
21
|
* todo: remove in v4
|
|
24
22
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
declare const isEmpty: typeof isDeepEmpty;
|
|
27
24
|
/**
|
|
28
25
|
* @deprecated Use `isDeepEmpty` instead
|
|
29
26
|
* todo: remove in v4
|
|
30
27
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export declare function isShallowEmptyObject(value: {
|
|
28
|
+
declare const isEmptyObject: typeof isDeepEmptyObject;
|
|
29
|
+
declare function isShallowEmptyObject(value: {
|
|
34
30
|
[key: string]: unknown;
|
|
35
31
|
}): boolean;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export declare function resolveTypeName(value: unknown): string;
|
|
40
|
-
|
|
41
|
-
export {};
|
|
32
|
+
declare function randomKey(length?: number): string;
|
|
33
|
+
declare function resolveTypeName(value: unknown): string;
|
|
34
|
+
export { isDeepEmpty, isEmpty, isEmptyArray, isEmptyObject, isShallowEmptyObject, randomKey, resolveTypeName };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
errorLabel: string;
|
|
3
|
+
}
|
|
4
|
+
type Parser<Type> = (line: string) => Type;
|
|
1
5
|
/**
|
|
2
6
|
* Create a safe JSON parser that is able to handle lines interrupted by an error object.
|
|
3
7
|
*
|
|
@@ -6,14 +10,7 @@
|
|
|
6
10
|
* @internal
|
|
7
11
|
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
errorLabel
|
|
13
|
+
declare function createSafeJsonParser<Type>({
|
|
14
|
+
errorLabel
|
|
11
15
|
}: Options): Parser<Type>;
|
|
12
|
-
|
|
13
|
-
declare interface Options {
|
|
14
|
-
errorLabel: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare type Parser<Type> = (line: string) => Type;
|
|
18
|
-
|
|
19
|
-
export {};
|
|
16
|
+
export { createSafeJsonParser };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
errorLabel: string;
|
|
3
|
+
}
|
|
4
|
+
type Parser<Type> = (line: string) => Type;
|
|
1
5
|
/**
|
|
2
6
|
* Create a safe JSON parser that is able to handle lines interrupted by an error object.
|
|
3
7
|
*
|
|
@@ -6,14 +10,7 @@
|
|
|
6
10
|
* @internal
|
|
7
11
|
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
errorLabel
|
|
13
|
+
declare function createSafeJsonParser<Type>({
|
|
14
|
+
errorLabel
|
|
11
15
|
}: Options): Parser<Type>;
|
|
12
|
-
|
|
13
|
-
declare interface Options {
|
|
14
|
-
errorLabel: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare type Parser<Type> = (line: string) => Type;
|
|
18
|
-
|
|
19
|
-
export {};
|
|
16
|
+
export { createSafeJsonParser };
|
package/lib/fs.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function pathIsEmpty(dir: string): Promise<boolean>;
|
|
6
|
-
|
|
7
|
-
export {};
|
|
1
|
+
declare function pathIsEmpty(dir: string): Promise<boolean>;
|
|
2
|
+
declare function expandHome(filePath: string): string;
|
|
3
|
+
declare function absolutify(dir: string): string;
|
|
4
|
+
export { absolutify, expandHome, pathIsEmpty };
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function format(
|
|
6
|
-
input: Date,
|
|
7
|
-
dateFormat: string,
|
|
8
|
-
options?: {
|
|
9
|
-
useUTC?: boolean;
|
|
10
|
-
timeZone?: string;
|
|
11
|
-
},
|
|
12
|
-
): string;
|
|
13
|
-
|
|
14
|
-
export declare function isValidTimeZoneString(timeZone: string): boolean;
|
|
15
|
-
|
|
16
|
-
export declare function parse(
|
|
17
|
-
dateString: string,
|
|
18
|
-
dateFormat?: string,
|
|
19
|
-
timeZone?: string,
|
|
20
|
-
): ParseResult;
|
|
21
|
-
|
|
22
|
-
export declare type ParseResult = {
|
|
1
|
+
declare const sanitizeLocale: (locale: string) => string;
|
|
2
|
+
declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
3
|
+
declare const DEFAULT_TIME_FORMAT = "HH:mm";
|
|
4
|
+
type ParseResult = {
|
|
23
5
|
isValid: boolean;
|
|
24
6
|
date?: Date;
|
|
25
7
|
error?: string;
|
|
26
|
-
} & (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export {};
|
|
8
|
+
} & ({
|
|
9
|
+
isValid: true;
|
|
10
|
+
date: Date;
|
|
11
|
+
} | {
|
|
12
|
+
isValid: false;
|
|
13
|
+
error?: string;
|
|
14
|
+
});
|
|
15
|
+
declare function format(input: Date, dateFormat: string, options?: {
|
|
16
|
+
useUTC?: boolean;
|
|
17
|
+
timeZone?: string;
|
|
18
|
+
}): string;
|
|
19
|
+
declare function parse(dateString: string, dateFormat?: string, timeZone?: string): ParseResult;
|
|
20
|
+
declare function isValidTimeZoneString(timeZone: string): boolean;
|
|
21
|
+
export { DEFAULT_DATE_FORMAT, DEFAULT_TIME_FORMAT, ParseResult, format, isValidTimeZoneString, parse, sanitizeLocale };
|
package/lib/paths.d.ts
CHANGED
|
@@ -1,44 +1,20 @@
|
|
|
1
|
-
import { Path } from "@sanity/types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
):
|
|
18
|
-
|
|
19
|
-
export declare function hasFocus(focusPath: Path, path: Path): boolean;
|
|
20
|
-
|
|
21
|
-
export declare function hasItemFocus(
|
|
22
|
-
focusPath: Path,
|
|
23
|
-
item: PathSegment,
|
|
24
|
-
): boolean;
|
|
25
|
-
|
|
26
|
-
export declare function isEqual(path: Path, otherPath: Path): boolean;
|
|
27
|
-
|
|
28
|
-
export declare function isExpanded(
|
|
29
|
-
segment: PathSegment,
|
|
30
|
-
focusPath: Path,
|
|
31
|
-
): boolean;
|
|
32
|
-
|
|
33
|
-
export declare function isSegmentEqual(
|
|
34
|
-
segmentA: PathSegment,
|
|
35
|
-
segmentB: PathSegment,
|
|
36
|
-
): boolean;
|
|
37
|
-
|
|
38
|
-
export declare function numEqualSegments(path: Path, otherPath: Path): number;
|
|
39
|
-
|
|
40
|
-
export declare function pathFor(path: Path): Path;
|
|
41
|
-
|
|
1
|
+
import { Path, PathSegment } from "@sanity/types";
|
|
2
|
+
declare const FOCUS_TERMINATOR = "$";
|
|
3
|
+
declare function get<R>(obj: unknown, path: Path | string): R | undefined;
|
|
4
|
+
declare function get<R>(obj: unknown, path: Path | string, defaultValue: R): R;
|
|
5
|
+
declare function pathFor(path: Path): Path;
|
|
6
|
+
declare function isEqual(path: Path, otherPath: Path): boolean;
|
|
7
|
+
declare function numEqualSegments(path: Path, otherPath: Path): number;
|
|
8
|
+
declare function isSegmentEqual(segmentA: PathSegment, segmentB: PathSegment): boolean;
|
|
9
|
+
declare function hasFocus(focusPath: Path, path: Path): boolean;
|
|
10
|
+
declare function hasItemFocus(focusPath: Path, item: PathSegment): boolean;
|
|
11
|
+
declare function isExpanded(segment: PathSegment, focusPath: Path): boolean;
|
|
12
|
+
declare function startsWith(prefix: Path, path: Path): boolean;
|
|
13
|
+
declare function trimLeft(prefix: Path, path: Path): Path;
|
|
14
|
+
declare function trimRight(suffix: Path, path: Path): Path;
|
|
15
|
+
declare function trimChildPath(path: Path, childPath: Path): Path;
|
|
16
|
+
declare function toString(path: Path): string;
|
|
17
|
+
declare function _resolveKeyedPath(value: unknown, path: Path): Path;
|
|
42
18
|
/**
|
|
43
19
|
* Takes a value and a path that may include numeric indices and attempts to replace numeric indices with keyed paths
|
|
44
20
|
*
|
|
@@ -51,19 +27,6 @@ export declare function pathFor(path: Path): Path;
|
|
|
51
27
|
* - `resolveKeyedPath([0, 'foo', 'bar'], [{_key: 'xyz'}])` will return `[{_key: 'xyz'}, 'foo', 'bar']` since array has no value at index 0
|
|
52
28
|
* Object keys will be preserved as-is, e.g. `resolveKeyedPath(['foo', 'bar'], undefined)` will return `['foo', 'bar']`
|
|
53
29
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
export declare function startsWith(prefix: Path, path: Path): boolean;
|
|
59
|
-
|
|
60
|
-
declare function toString_2(path: Path): string;
|
|
61
|
-
export { toString_2 as toString };
|
|
62
|
-
|
|
63
|
-
export declare function trimChildPath(path: Path, childPath: Path): Path;
|
|
64
|
-
|
|
65
|
-
export declare function trimLeft(prefix: Path, path: Path): Path;
|
|
66
|
-
|
|
67
|
-
export declare function trimRight(suffix: Path, path: Path): Path;
|
|
68
|
-
|
|
69
|
-
export {};
|
|
30
|
+
declare function resolveKeyedPath(value: unknown, path: Path): Path;
|
|
31
|
+
declare function fromString(path: string): Path;
|
|
32
|
+
export { FOCUS_TERMINATOR, _resolveKeyedPath, fromString, get, hasFocus, hasItemFocus, isEqual, isExpanded, isSegmentEqual, numEqualSegments, pathFor, resolveKeyedPath, startsWith, toString, trimChildPath, trimLeft, trimRight };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/util",
|
|
3
|
-
"version": "5.8.1
|
|
3
|
+
"version": "5.8.1",
|
|
4
4
|
"description": "Utilities shared across projects of Sanity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@sanity/client": "^7.14.1",
|
|
74
74
|
"date-fns": "^4.1.0",
|
|
75
75
|
"rxjs": "^7.8.2",
|
|
76
|
-
"@sanity/types": "5.8.
|
|
76
|
+
"@sanity/types": "5.8.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@sanity/pkg-utils": "^10.4.4",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"eslint": "^9.39.2",
|
|
83
83
|
"rimraf": "^5.0.10",
|
|
84
84
|
"vitest": "^4.0.18",
|
|
85
|
-
"@repo/
|
|
86
|
-
"@repo/test-config": "5.8.1
|
|
87
|
-
"@repo/
|
|
88
|
-
"@repo/
|
|
85
|
+
"@repo/eslint-config": "5.8.1",
|
|
86
|
+
"@repo/test-config": "5.8.1",
|
|
87
|
+
"@repo/package.config": "5.8.1",
|
|
88
|
+
"@repo/tsconfig": "5.8.1"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=20.19 <22 || >=22.12"
|