@sanity/util 4.21.0-next.9 → 5.0.0-next-major.14
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/util",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-next-major.14+63b1f6d82c",
|
|
4
4
|
"description": "Utilities shared across projects of Sanity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
},
|
|
47
47
|
"./createSafeJsonParser": {
|
|
48
48
|
"source": "./src/_exports/createSafeJsonParser.ts",
|
|
49
|
-
"require": "./lib/createSafeJsonParser.cjs",
|
|
50
49
|
"default": "./lib/createSafeJsonParser.js"
|
|
51
50
|
},
|
|
52
51
|
"./legacyDateFormat": {
|
|
@@ -95,19 +94,19 @@
|
|
|
95
94
|
"@sanity/client": "^7.13.1",
|
|
96
95
|
"date-fns": "^4.1.0",
|
|
97
96
|
"rxjs": "^7.8.2",
|
|
98
|
-
"@sanity/types": "
|
|
97
|
+
"@sanity/types": "5.0.0-next-major.14+63b1f6d82c"
|
|
99
98
|
},
|
|
100
99
|
"devDependencies": {
|
|
101
|
-
"@sanity/pkg-utils": "^10.
|
|
100
|
+
"@sanity/pkg-utils": "^10.0.0",
|
|
102
101
|
"@types/node": "^24.3.0",
|
|
103
102
|
"@typescript/native-preview": "7.0.0-dev.20251128.1",
|
|
104
103
|
"eslint": "^9.39.1",
|
|
105
104
|
"rimraf": "^5.0.10",
|
|
106
105
|
"vitest": "^3.2.4",
|
|
107
|
-
"@repo/eslint-config": "
|
|
108
|
-
"@repo/
|
|
109
|
-
"@repo/
|
|
110
|
-
"@repo/tsconfig": "
|
|
106
|
+
"@repo/eslint-config": "5.0.0-next-major.14+63b1f6d82c",
|
|
107
|
+
"@repo/package.config": "5.0.0-next-major.14+63b1f6d82c",
|
|
108
|
+
"@repo/test-config": "5.0.0-next-major.14+63b1f6d82c",
|
|
109
|
+
"@repo/tsconfig": "5.0.0-next-major.14+63b1f6d82c"
|
|
111
110
|
},
|
|
112
111
|
"engines": {
|
|
113
112
|
"node": ">=20.19 <22 || >=22.12"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
function createSafeJsonParser({ errorLabel }) {
|
|
4
|
-
return function(line) {
|
|
5
|
-
try {
|
|
6
|
-
return JSON.parse(line);
|
|
7
|
-
} catch (err) {
|
|
8
|
-
const errorPosition = line.lastIndexOf('{"error":');
|
|
9
|
-
if (errorPosition === -1)
|
|
10
|
-
throw err.message = `${err.message} (${line})`, err;
|
|
11
|
-
const errorJson = line.slice(errorPosition), errorLine = JSON.parse(errorJson), error = errorLine && errorLine.error;
|
|
12
|
-
throw error && error.description ? new Error(`${errorLabel}: ${error.description}
|
|
13
|
-
|
|
14
|
-
${errorJson}
|
|
15
|
-
`, { cause: err }) : err;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.createSafeJsonParser = createSafeJsonParser;
|
|
20
|
-
//# sourceMappingURL=createSafeJsonParser.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSafeJsonParser.cjs","sources":["../src/createSafeJsonParser.ts"],"sourcesContent":["interface Options {\n errorLabel: string\n}\n\ntype Parser<Type> = (line: string) => Type\n\n/**\n * Create a safe JSON parser that is able to handle lines interrupted by an error object.\n *\n * This may occur when streaming NDJSON from the Export HTTP API.\n *\n * @internal\n * @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}\n */\nexport function createSafeJsonParser<Type>({errorLabel}: Options): Parser<Type> {\n return function safeJsonParser(line) {\n try {\n return JSON.parse(line)\n } catch (err) {\n // Catch half-done lines with an error at the end\n const errorPosition = line.lastIndexOf('{\"error\":')\n if (errorPosition === -1) {\n err.message = `${err.message} (${line})`\n throw err\n }\n\n const errorJson = line.slice(errorPosition)\n const errorLine = JSON.parse(errorJson)\n const error = errorLine && errorLine.error\n if (error && error.description) {\n throw new Error(`${errorLabel}: ${error.description}\\n\\n${errorJson}\\n`, {cause: err})\n }\n\n throw err\n }\n }\n}\n"],"names":[],"mappings":";;AAcO,SAAS,qBAA2B,EAAC,cAAoC;AAC9E,SAAO,SAAwB,MAAM;AACnC,QAAI;AACF,aAAO,KAAK,MAAM,IAAI;AAAA,IACxB,SAAS,KAAK;AAEZ,YAAM,gBAAgB,KAAK,YAAY,WAAW;AAClD,UAAI,kBAAkB;AACpB,cAAA,IAAI,UAAU,GAAG,IAAI,OAAO,KAAK,IAAI,KAC/B;AAGR,YAAM,YAAY,KAAK,MAAM,aAAa,GACpC,YAAY,KAAK,MAAM,SAAS,GAChC,QAAQ,aAAa,UAAU;AACrC,YAAI,SAAS,MAAM,cACX,IAAI,MAAM,GAAG,UAAU,KAAK,MAAM,WAAW;AAAA;AAAA,EAAO,SAAS;AAAA,GAAM,EAAC,OAAO,IAAA,CAAI,IAGjF;AAAA,IACR;AAAA,EACF;AACF;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a safe JSON parser that is able to handle lines interrupted by an error object.
|
|
3
|
-
*
|
|
4
|
-
* This may occur when streaming NDJSON from the Export HTTP API.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
* @see {@link https://github.com/sanity-io/sanity/pull/1787 | Initial pull request}
|
|
8
|
-
*/
|
|
9
|
-
export declare function createSafeJsonParser<Type>({errorLabel}: Options): Parser<Type>
|
|
10
|
-
|
|
11
|
-
declare interface Options {
|
|
12
|
-
errorLabel: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare type Parser<Type> = (line: string) => Type
|
|
16
|
-
|
|
17
|
-
export {}
|