@sanity/util 5.8.1-next.14 → 5.8.1-next.2
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 +6 -2
- package/lib/concurrency-limiter.d.ts +3 -2
- package/lib/content.d.ts +19 -12
- package/lib/createSafeJsonParser.d.cts +10 -7
- package/lib/createSafeJsonParser.d.ts +10 -7
- package/lib/fs.d.ts +7 -4
- package/lib/index.d.ts +1 -1
- package/lib/legacyDateFormat.d.ts +36 -18
- package/lib/paths.d.ts +57 -20
- package/package.json +5 -5
package/lib/client.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { SanityClient } from "@sanity/client";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Decorates a sanity client to limit the concurrency of `client.fetch`
|
|
4
5
|
* requests. Keeps the concurrency limit state and returns wrapped clients with
|
|
5
6
|
* that same state if the `clone` `config` or `withConfig` methods are called.
|
|
6
7
|
*/
|
|
7
|
-
declare function createClientConcurrencyLimiter(
|
|
8
|
-
|
|
8
|
+
export declare function createClientConcurrencyLimiter(
|
|
9
|
+
maxConcurrency: number,
|
|
10
|
+
): (input: SanityClient) => SanityClient;
|
|
11
|
+
|
|
12
|
+
export {};
|
|
@@ -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
|
-
declare class ConcurrencyLimiter {
|
|
5
|
+
export declare class ConcurrencyLimiter {
|
|
6
6
|
current: number;
|
|
7
7
|
resolvers: Array<() => void>;
|
|
8
8
|
max: number;
|
|
@@ -18,4 +18,5 @@ declare class ConcurrencyLimiter {
|
|
|
18
18
|
*/
|
|
19
19
|
release: () => void;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
export {};
|
package/lib/content.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
declare function isDeepEmptyObject(value: {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
}): boolean;
|
|
4
|
-
declare function isDeepEmptyArray(value: unknown[]): boolean;
|
|
5
1
|
/**
|
|
6
2
|
* Looks at the value and determines if it is deeply empty while not considering _type and _key attributes on objects.
|
|
7
3
|
* A value will be considered deeply empty if it is:
|
|
@@ -10,25 +6,36 @@ declare function isDeepEmptyArray(value: unknown[]): boolean;
|
|
|
10
6
|
* - an array where all items are deeply empty
|
|
11
7
|
* @param value - the value to check for deep emptiness
|
|
12
8
|
*/
|
|
13
|
-
declare function isDeepEmpty(value: unknown): boolean;
|
|
9
|
+
export declare function isDeepEmpty(value: unknown): boolean;
|
|
10
|
+
|
|
11
|
+
declare function isDeepEmptyArray(value: unknown[]): boolean;
|
|
12
|
+
|
|
13
|
+
declare function isDeepEmptyObject(value: { [key: string]: any }): boolean;
|
|
14
|
+
|
|
14
15
|
/**
|
|
15
16
|
* @deprecated Use `isDeepEmpty` instead
|
|
16
17
|
* todo: remove in v4
|
|
17
18
|
*/
|
|
18
|
-
declare const
|
|
19
|
+
export declare const isEmpty: typeof isDeepEmpty;
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* @deprecated Use `isDeepEmpty` instead
|
|
21
23
|
* todo: remove in v4
|
|
22
24
|
*/
|
|
23
|
-
declare const
|
|
25
|
+
export declare const isEmptyArray: typeof isDeepEmptyArray;
|
|
26
|
+
|
|
24
27
|
/**
|
|
25
28
|
* @deprecated Use `isDeepEmpty` instead
|
|
26
29
|
* todo: remove in v4
|
|
27
30
|
*/
|
|
28
|
-
declare const isEmptyObject: typeof isDeepEmptyObject;
|
|
29
|
-
|
|
31
|
+
export declare const isEmptyObject: typeof isDeepEmptyObject;
|
|
32
|
+
|
|
33
|
+
export declare function isShallowEmptyObject(value: {
|
|
30
34
|
[key: string]: unknown;
|
|
31
35
|
}): boolean;
|
|
32
|
-
|
|
33
|
-
declare function
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
export declare function randomKey(length?: number): string;
|
|
38
|
+
|
|
39
|
+
export declare function resolveTypeName(value: unknown): string;
|
|
40
|
+
|
|
41
|
+
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
interface Options {
|
|
2
|
-
errorLabel: string;
|
|
3
|
-
}
|
|
4
|
-
type Parser<Type> = (line: string) => Type;
|
|
5
1
|
/**
|
|
6
2
|
* Create a safe JSON parser that is able to handle lines interrupted by an error object.
|
|
7
3
|
*
|
|
@@ -10,7 +6,14 @@ type Parser<Type> = (line: string) => Type;
|
|
|
10
6
|
* @internal
|
|
11
7
|
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
12
8
|
*/
|
|
13
|
-
declare function createSafeJsonParser<Type>({
|
|
14
|
-
errorLabel
|
|
9
|
+
export declare function createSafeJsonParser<Type>({
|
|
10
|
+
errorLabel,
|
|
15
11
|
}: Options): Parser<Type>;
|
|
16
|
-
|
|
12
|
+
|
|
13
|
+
declare interface Options {
|
|
14
|
+
errorLabel: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare type Parser<Type> = (line: string) => Type;
|
|
18
|
+
|
|
19
|
+
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
interface Options {
|
|
2
|
-
errorLabel: string;
|
|
3
|
-
}
|
|
4
|
-
type Parser<Type> = (line: string) => Type;
|
|
5
1
|
/**
|
|
6
2
|
* Create a safe JSON parser that is able to handle lines interrupted by an error object.
|
|
7
3
|
*
|
|
@@ -10,7 +6,14 @@ type Parser<Type> = (line: string) => Type;
|
|
|
10
6
|
* @internal
|
|
11
7
|
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
12
8
|
*/
|
|
13
|
-
declare function createSafeJsonParser<Type>({
|
|
14
|
-
errorLabel
|
|
9
|
+
export declare function createSafeJsonParser<Type>({
|
|
10
|
+
errorLabel,
|
|
15
11
|
}: Options): Parser<Type>;
|
|
16
|
-
|
|
12
|
+
|
|
13
|
+
declare interface Options {
|
|
14
|
+
errorLabel: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare type Parser<Type> = (line: string) => Type;
|
|
18
|
+
|
|
19
|
+
export {};
|
package/lib/fs.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
|
|
3
|
-
declare function
|
|
4
|
-
|
|
1
|
+
export declare function absolutify(dir: string): string;
|
|
2
|
+
|
|
3
|
+
export declare function expandHome(filePath: string): string;
|
|
4
|
+
|
|
5
|
+
export declare function pathIsEmpty(dir: string): Promise<boolean>;
|
|
6
|
+
|
|
7
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,39 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
declare const DEFAULT_TIME_FORMAT = "HH:mm";
|
|
4
|
-
|
|
1
|
+
export declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
2
|
+
|
|
3
|
+
export declare const DEFAULT_TIME_FORMAT = "HH:mm";
|
|
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 = {
|
|
5
23
|
isValid: boolean;
|
|
6
24
|
date?: Date;
|
|
7
25
|
error?: string;
|
|
8
|
-
} & (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
declare
|
|
20
|
-
|
|
21
|
-
export {
|
|
26
|
+
} & (
|
|
27
|
+
| {
|
|
28
|
+
isValid: true;
|
|
29
|
+
date: Date;
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
isValid: false;
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export declare const sanitizeLocale: (locale: string) => string;
|
|
38
|
+
|
|
39
|
+
export {};
|
package/lib/paths.d.ts
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
import { Path
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
declare function
|
|
7
|
-
|
|
8
|
-
declare function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { Path } from "@sanity/types";
|
|
2
|
+
import { PathSegment } from "@sanity/types";
|
|
3
|
+
|
|
4
|
+
export declare const FOCUS_TERMINATOR = "$";
|
|
5
|
+
|
|
6
|
+
export declare function fromString(path: string): Path;
|
|
7
|
+
|
|
8
|
+
export declare function get<R>(
|
|
9
|
+
obj: unknown,
|
|
10
|
+
path: Path | string,
|
|
11
|
+
): R | undefined;
|
|
12
|
+
|
|
13
|
+
export declare function get<R>(
|
|
14
|
+
obj: unknown,
|
|
15
|
+
path: Path | string,
|
|
16
|
+
defaultValue: R,
|
|
17
|
+
): R;
|
|
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
|
+
|
|
18
42
|
/**
|
|
19
43
|
* Takes a value and a path that may include numeric indices and attempts to replace numeric indices with keyed paths
|
|
20
44
|
*
|
|
@@ -27,6 +51,19 @@ declare function _resolveKeyedPath(value: unknown, path: Path): Path;
|
|
|
27
51
|
* - `resolveKeyedPath([0, 'foo', 'bar'], [{_key: 'xyz'}])` will return `[{_key: 'xyz'}, 'foo', 'bar']` since array has no value at index 0
|
|
28
52
|
* Object keys will be preserved as-is, e.g. `resolveKeyedPath(['foo', 'bar'], undefined)` will return `['foo', 'bar']`
|
|
29
53
|
*/
|
|
30
|
-
declare function resolveKeyedPath(value: unknown, path: Path): Path;
|
|
31
|
-
|
|
32
|
-
export
|
|
54
|
+
export declare function resolveKeyedPath(value: unknown, path: Path): Path;
|
|
55
|
+
|
|
56
|
+
export declare function _resolveKeyedPath(value: unknown, path: Path): Path;
|
|
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 {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/util",
|
|
3
|
-
"version": "5.8.1-next.
|
|
3
|
+
"version": "5.8.1-next.2+d50c281353",
|
|
4
4
|
"description": "Utilities shared across projects of Sanity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -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/
|
|
87
|
-
"@repo/tsconfig": "5.8.1-next.
|
|
88
|
-
"@repo/
|
|
85
|
+
"@repo/package.config": "5.8.1-next.2+d50c281353",
|
|
86
|
+
"@repo/test-config": "5.8.1-next.2+d50c281353",
|
|
87
|
+
"@repo/tsconfig": "5.8.1-next.2+d50c281353",
|
|
88
|
+
"@repo/eslint-config": "5.8.1-next.2+d50c281353"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=20.19 <22 || >=22.12"
|