@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 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(maxConcurrency: number): (input: SanityClient) => SanityClient;
8
- export { createClientConcurrencyLimiter };
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
- export { ConcurrencyLimiter };
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 isEmptyArray: typeof isDeepEmptyArray;
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 isEmpty: typeof isDeepEmpty;
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
- declare function isShallowEmptyObject(value: {
31
+ export declare const isEmptyObject: typeof isDeepEmptyObject;
32
+
33
+ export declare function isShallowEmptyObject(value: {
30
34
  [key: string]: unknown;
31
35
  }): boolean;
32
- declare function randomKey(length?: number): string;
33
- declare function resolveTypeName(value: unknown): string;
34
- export { isDeepEmpty, isEmpty, isEmptyArray, isEmptyObject, isShallowEmptyObject, randomKey, resolveTypeName };
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
- export { createSafeJsonParser };
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
- export { createSafeJsonParser };
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 pathIsEmpty(dir: string): Promise<boolean>;
2
- declare function expandHome(filePath: string): string;
3
- declare function absolutify(dir: string): string;
4
- export { absolutify, expandHome, pathIsEmpty };
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 sanitizeLocale: (locale: string) => string;
2
- declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
3
- declare const DEFAULT_TIME_FORMAT = "HH:mm";
4
- type ParseResult = {
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
- 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 };
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, 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;
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
- 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 };
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.14+7a4041cd60",
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/eslint-config": "5.8.1-next.14+7a4041cd60",
86
- "@repo/package.config": "5.8.1-next.14+7a4041cd60",
87
- "@repo/tsconfig": "5.8.1-next.14+7a4041cd60",
88
- "@repo/test-config": "5.8.1-next.14+7a4041cd60"
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"