next-sanity 8.0.0 → 8.0.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/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.ts +3 -3
- package/dist/webhook.js.map +1 -1
- package/package.json +19 -49
- package/src/webhook/index.ts +4 -4
package/dist/webhook.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.cjs","sources":["../src/webhook/index.ts"],"sourcesContent":["import type {SanityDocument} from '@sanity/types'\nimport {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\nimport type {NextRequest} from 'next/server'\nimport type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n * @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n runtime: 'nodejs',\n}\n\n/** @public */\nexport type ParsedBody<T> = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: T | null\n}\n\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n
|
|
1
|
+
{"version":3,"file":"webhook.cjs","sources":["../src/webhook/index.ts"],"sourcesContent":["import type {SanityDocument} from '@sanity/types'\nimport {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\nimport type {NextRequest} from 'next/server'\nimport type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n * @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n runtime: 'nodejs',\n}\n\n/** @public */\nexport type ParsedBody<T> = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: T | null\n}\n\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n */\nexport async function parseBody<Body = SanityDocument>(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency?: boolean,\n): Promise<ParsedBody<Body>>\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n * @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.\n */\nexport async function parseBody<Body = SanityDocument>(\n req: NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency?: boolean,\n): Promise<ParsedBody<Body>>\n// eslint-disable-next-line require-await\nexport async function parseBody<Body = SanityDocument>(\n req: NextRequest | NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParsedBody<Body>> {\n return 'text' in req\n ? parseAppBody(req, secret, waitForContentLakeEventualConsistency)\n : parsePageBody(req, secret, waitForContentLakeEventualConsistency)\n}\n\n/** @deprecated */\nasync function parsePageBody<Body = SanityDocument>(\n req: NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParsedBody<Body>> {\n let signature = req.headers[SIGNATURE_HEADER_NAME]\n if (Array.isArray(signature)) {\n signature = signature[0]\n }\n if (!signature) {\n console.error('Missing signature header')\n return {body: null, isValidSignature: null}\n }\n\n if (req.readableEnded) {\n throw new Error(\n `Request already ended and the POST body can't be read. Have you setup \\`export {config} from 'next-sanity/webhook' in your webhook API handler?\\``,\n )\n }\n\n const body = await readBody(req)\n const validSignature = secret ? await isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 1000))\n }\n\n return {\n body: body.trim() ? JSON.parse(body) : null,\n isValidSignature: validSignature,\n }\n}\n\nasync function parseAppBody<Body = SanityDocument>(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParsedBody<Body>> {\n const signature = req.headers.get(SIGNATURE_HEADER_NAME)!\n if (!signature) {\n console.error('Missing signature header')\n return {body: null, isValidSignature: null}\n }\n\n const body = await req.text()\n const validSignature = secret ? await isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 3000))\n }\n\n return {\n body: body.trim() ? JSON.parse(body) : null,\n isValidSignature: validSignature,\n }\n}\n\nasync function readBody(readable: NextApiRequest): Promise<string> {\n const chunks = []\n for await (const chunk of readable) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)\n }\n return Buffer.concat(chunks).toString('utf8')\n}\n"],"names":["api","bodyParser","runtime","async","req","secret","waitForContentLakeEventualConsistency","signature","headers","get","SIGNATURE_HEADER_NAME","console","error","body","isValidSignature","text","validSignature","trim","Promise","resolve","setTimeout","JSON","parse","parseAppBody","Array","isArray","readableEnded","Error","readable","chunks","chunk","push","Buffer","from","concat","toString","readBody","parsePageBody"],"mappings":"oHAWkC,CAChCA,IAAK,CAIHC,YAAY,GAEdC,QAAS,4BAkCXC,eACEC,EACAC,EACAC,GAAiD,GAE1C,MAAA,SAAUF,EAuCnBD,eACEC,EACAC,EACAC,GAAiD,GAEjD,MAAMC,EAAYH,EAAII,QAAQC,IAAIC,EAAqBA,uBACvD,IAAKH,EAEH,OADAI,QAAQC,MAAM,4BACP,CAACC,KAAM,KAAMC,iBAAkB,MAGlC,MAAAD,QAAaT,EAAIW,OACjBC,EAAiBX,QAAeS,mBAAiBD,EAAMN,EAAWF,EAAOY,QAAU,MAElE,IAAnBD,GAA4BV,SACxB,IAAIY,SAASC,GAAYC,WAAWD,EAAS,OAG9C,MAAA,CACLN,KAAMA,EAAKI,OAASI,KAAKC,MAAMT,GAAQ,KACvCC,iBAAkBE,EAEtB,CA5DMO,CAAanB,EAAKC,EAAQC,GAKhCH,eACEC,EACAC,EACAC,GAAiD,GAE7C,IAAAC,EAAYH,EAAII,QAAQE,EAAqBA,uBAC7Cc,MAAMC,QAAQlB,KAChBA,EAAYA,EAAU,IAExB,IAAKA,EAEH,OADAI,QAAQC,MAAM,4BACP,CAACC,KAAM,KAAMC,iBAAkB,MAGxC,GAAIV,EAAIsB,cACN,MAAM,IAAIC,MACR,mJAIE,MAAAd,QAqCRV,eAAwByB,GACtB,MAAMC,EAAS,GACf,UAAA,MAAiBC,KAASF,EACjBC,EAAAE,KAAsB,iBAAVD,EAAqBE,OAAOC,KAAKH,GAASA,GAE/D,OAAOE,OAAOE,OAAOL,GAAQM,SAAS,OACxC,CA3CqBC,CAAShC,GACtBY,EAAiBX,QAAeS,mBAAiBD,EAAMN,EAAWF,EAAOY,QAAU,MAElE,IAAnBD,GAA4BV,SACxB,IAAIY,SAASC,GAAYC,WAAWD,EAAS,OAG9C,MAAA,CACLN,KAAMA,EAAKI,OAASI,KAAKC,MAAMT,GAAQ,KACvCC,iBAAkBE,EAEtB,CAnCMqB,CAAcjC,EAAKC,EAAQC,EACjC"}
|
package/dist/webhook.d.ts
CHANGED
|
@@ -14,10 +14,9 @@ export declare const config: PageConfig
|
|
|
14
14
|
* Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
|
|
15
15
|
* without worrying about getting stale data.
|
|
16
16
|
* @public
|
|
17
|
-
* @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.
|
|
18
17
|
*/
|
|
19
18
|
export declare function parseBody<Body = SanityDocument>(
|
|
20
|
-
req:
|
|
19
|
+
req: NextRequest,
|
|
21
20
|
secret?: string,
|
|
22
21
|
waitForContentLakeEventualConsistency?: boolean,
|
|
23
22
|
): Promise<ParsedBody<Body>>
|
|
@@ -26,9 +25,10 @@ export declare function parseBody<Body = SanityDocument>(
|
|
|
26
25
|
* Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
|
|
27
26
|
* without worrying about getting stale data.
|
|
28
27
|
* @public
|
|
28
|
+
* @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.
|
|
29
29
|
*/
|
|
30
30
|
export declare function parseBody<Body = SanityDocument>(
|
|
31
|
-
req:
|
|
31
|
+
req: NextApiRequest,
|
|
32
32
|
secret?: string,
|
|
33
33
|
waitForContentLakeEventualConsistency?: boolean,
|
|
34
34
|
): Promise<ParsedBody<Body>>
|
package/dist/webhook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sources":["../src/webhook/index.ts"],"sourcesContent":["import type {SanityDocument} from '@sanity/types'\nimport {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\nimport type {NextRequest} from 'next/server'\nimport type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n * @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n runtime: 'nodejs',\n}\n\n/** @public */\nexport type ParsedBody<T> = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: T | null\n}\n\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n
|
|
1
|
+
{"version":3,"file":"webhook.js","sources":["../src/webhook/index.ts"],"sourcesContent":["import type {SanityDocument} from '@sanity/types'\nimport {isValidSignature, SIGNATURE_HEADER_NAME} from '@sanity/webhook'\nimport type {NextApiRequest} from 'next'\nimport type {NextRequest} from 'next/server'\nimport type {PageConfig} from 'next/types'\n\n/**\n * Configurates the API function with the right runtime and body parsing to handle Sanity Webhook events.\n * @public\n * @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.\n */\nexport const config: PageConfig = {\n api: {\n /**\n * Next.js will by default parse the body, which can lead to invalid signatures.\n */\n bodyParser: false,\n },\n runtime: 'nodejs',\n}\n\n/** @public */\nexport type ParsedBody<T> = {\n /**\n * If a secret is given then it returns a boolean. If no secret is provided then no validation is done on the signature, and it'll return `null`\n */\n isValidSignature: boolean | null\n body: T | null\n}\n\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n */\nexport async function parseBody<Body = SanityDocument>(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency?: boolean,\n): Promise<ParsedBody<Body>>\n/**\n * Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries\n * without worrying about getting stale data.\n * @public\n * @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.\n */\nexport async function parseBody<Body = SanityDocument>(\n req: NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency?: boolean,\n): Promise<ParsedBody<Body>>\n// eslint-disable-next-line require-await\nexport async function parseBody<Body = SanityDocument>(\n req: NextRequest | NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParsedBody<Body>> {\n return 'text' in req\n ? parseAppBody(req, secret, waitForContentLakeEventualConsistency)\n : parsePageBody(req, secret, waitForContentLakeEventualConsistency)\n}\n\n/** @deprecated */\nasync function parsePageBody<Body = SanityDocument>(\n req: NextApiRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParsedBody<Body>> {\n let signature = req.headers[SIGNATURE_HEADER_NAME]\n if (Array.isArray(signature)) {\n signature = signature[0]\n }\n if (!signature) {\n console.error('Missing signature header')\n return {body: null, isValidSignature: null}\n }\n\n if (req.readableEnded) {\n throw new Error(\n `Request already ended and the POST body can't be read. Have you setup \\`export {config} from 'next-sanity/webhook' in your webhook API handler?\\``,\n )\n }\n\n const body = await readBody(req)\n const validSignature = secret ? await isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 1000))\n }\n\n return {\n body: body.trim() ? JSON.parse(body) : null,\n isValidSignature: validSignature,\n }\n}\n\nasync function parseAppBody<Body = SanityDocument>(\n req: NextRequest,\n secret?: string,\n waitForContentLakeEventualConsistency: boolean = true,\n): Promise<ParsedBody<Body>> {\n const signature = req.headers.get(SIGNATURE_HEADER_NAME)!\n if (!signature) {\n console.error('Missing signature header')\n return {body: null, isValidSignature: null}\n }\n\n const body = await req.text()\n const validSignature = secret ? await isValidSignature(body, signature, secret.trim()) : null\n\n if (validSignature !== false && waitForContentLakeEventualConsistency) {\n await new Promise((resolve) => setTimeout(resolve, 3000))\n }\n\n return {\n body: body.trim() ? JSON.parse(body) : null,\n isValidSignature: validSignature,\n }\n}\n\nasync function readBody(readable: NextApiRequest): Promise<string> {\n const chunks = []\n for await (const chunk of readable) {\n chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)\n }\n return Buffer.concat(chunks).toString('utf8')\n}\n"],"names":["config","api","bodyParser","runtime","async","parseBody","req","secret","waitForContentLakeEventualConsistency","signature","headers","get","SIGNATURE_HEADER_NAME","console","error","body","isValidSignature","text","validSignature","trim","Promise","resolve","setTimeout","JSON","parse","parseAppBody","Array","isArray","readableEnded","Error","readable","chunks","chunk","push","Buffer","from","concat","toString","readBody","parsePageBody"],"mappings":"8EAWO,MAAMA,EAAqB,CAChCC,IAAK,CAIHC,YAAY,GAEdC,QAAS,UAkCXC,eAAsBC,EACpBC,EACAC,EACAC,GAAiD,GAE1C,MAAA,SAAUF,EAuCnBF,eACEE,EACAC,EACAC,GAAiD,GAEjD,MAAMC,EAAYH,EAAII,QAAQC,IAAIC,GAClC,IAAKH,EAEH,OADAI,QAAQC,MAAM,4BACP,CAACC,KAAM,KAAMC,iBAAkB,MAGlC,MAAAD,QAAaT,EAAIW,OACjBC,EAAiBX,QAAeS,EAAiBD,EAAMN,EAAWF,EAAOY,QAAU,MAElE,IAAnBD,GAA4BV,SACxB,IAAIY,SAASC,GAAYC,WAAWD,EAAS,OAG9C,MAAA,CACLN,KAAMA,EAAKI,OAASI,KAAKC,MAAMT,GAAQ,KACvCC,iBAAkBE,EAEtB,CA5DMO,CAAanB,EAAKC,EAAQC,GAKhCJ,eACEE,EACAC,EACAC,GAAiD,GAE7C,IAAAC,EAAYH,EAAII,QAAQE,GACxBc,MAAMC,QAAQlB,KAChBA,EAAYA,EAAU,IAExB,IAAKA,EAEH,OADAI,QAAQC,MAAM,4BACP,CAACC,KAAM,KAAMC,iBAAkB,MAGxC,GAAIV,EAAIsB,cACN,MAAM,IAAIC,MACR,mJAIE,MAAAd,QAqCRX,eAAwB0B,GACtB,MAAMC,EAAS,GACf,UAAA,MAAiBC,KAASF,EACjBC,EAAAE,KAAsB,iBAAVD,EAAqBE,OAAOC,KAAKH,GAASA,GAE/D,OAAOE,OAAOE,OAAOL,GAAQM,SAAS,OACxC,CA3CqBC,CAAShC,GACtBY,EAAiBX,QAAeS,EAAiBD,EAAMN,EAAWF,EAAOY,QAAU,MAElE,IAAnBD,GAA4BV,SACxB,IAAIY,SAASC,GAAYC,WAAWD,EAAS,OAG9C,MAAA,CACLN,KAAMA,EAAKI,OAASI,KAAKC,MAAMT,GAAQ,KACvCC,iBAAkBE,EAEtB,CAnCMqB,CAAcjC,EAAKC,EAAQC,EACjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-sanity",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Sanity.io toolkit for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+ssh://git@github.com/sanity-io/next-sanity.git"
|
|
20
|
+
"url": "git+ssh://git@github.com/sanity-io/next-sanity.git",
|
|
21
|
+
"directory": "packages/next-sanity"
|
|
21
22
|
},
|
|
22
23
|
"license": "MIT",
|
|
23
24
|
"author": "Sanity.io <hello@sanity.io>",
|
|
@@ -134,82 +135,40 @@
|
|
|
134
135
|
"dist",
|
|
135
136
|
"src"
|
|
136
137
|
],
|
|
137
|
-
"scripts": {
|
|
138
|
-
"prebuild": "npm run clean",
|
|
139
|
-
"build": "pkg build --strict && pkg --strict",
|
|
140
|
-
"clean": "rimraf dist",
|
|
141
|
-
"coverage": "npm test -- --coverage",
|
|
142
|
-
"dev": "next",
|
|
143
|
-
"format": "npm run prettier -- --write . && eslint --fix .",
|
|
144
|
-
"lint": "eslint --max-warnings 0 .",
|
|
145
|
-
"prepublishOnly": "npm run build",
|
|
146
|
-
"prettier": "npx prettier --ignore-path .gitignore",
|
|
147
|
-
"test": "vitest",
|
|
148
|
-
"test:node-esm-cjs": "node test.mjs && node test.cjs",
|
|
149
|
-
"type-check": "tsc --noEmit"
|
|
150
|
-
},
|
|
151
138
|
"browserslist": "extends @sanity/browserslist-config",
|
|
152
|
-
"prettier": {
|
|
153
|
-
"bracketSpacing": false,
|
|
154
|
-
"plugins": [
|
|
155
|
-
"prettier-plugin-packagejson",
|
|
156
|
-
"prettier-plugin-tailwindcss"
|
|
157
|
-
],
|
|
158
|
-
"printWidth": 98,
|
|
159
|
-
"semi": false,
|
|
160
|
-
"singleQuote": true
|
|
161
|
-
},
|
|
162
139
|
"dependencies": {
|
|
163
|
-
"@sanity/client": "^6.
|
|
140
|
+
"@sanity/client": "^6.14.3",
|
|
164
141
|
"@sanity/preview-kit": "5.0.20",
|
|
165
142
|
"@sanity/visual-editing": "1.2.2",
|
|
166
143
|
"@sanity/webhook": "4.0.0",
|
|
167
144
|
"groq": "^3.19"
|
|
168
145
|
},
|
|
169
146
|
"devDependencies": {
|
|
170
|
-
"@next/bundle-analyzer": "^14.1.0",
|
|
171
|
-
"@next/eslint-plugin-next": "14.1.0",
|
|
172
147
|
"@rollup/plugin-terser": "^0.4.4",
|
|
173
148
|
"@sanity/browserslist-config": "^1.0.1",
|
|
174
149
|
"@sanity/eslint-config-studio": "^3.0.1",
|
|
175
|
-
"@sanity/image-url": "^1.0.2",
|
|
176
150
|
"@sanity/pkg-utils": "^4.2.0",
|
|
177
|
-
"@
|
|
178
|
-
"@sanity/vision": "3.28.0",
|
|
179
|
-
"@types/react": "^18.2.55",
|
|
180
|
-
"@types/react-dom": "^18.2.19",
|
|
151
|
+
"@types/react": "^18.2.58",
|
|
181
152
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
182
153
|
"@vitest/coverage-v8": "^1.2.2",
|
|
183
|
-
"autoprefixer": "^10.4.17",
|
|
184
154
|
"eslint": "^8.56.0",
|
|
185
155
|
"eslint-config-prettier": "^9.1.0",
|
|
186
156
|
"eslint-config-sanity": "^7.0.1",
|
|
187
157
|
"eslint-gitignore": "^0.1.0",
|
|
188
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
189
158
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
190
|
-
"groqd": "^0.15.10",
|
|
191
159
|
"ls-engines": "^0.9.1",
|
|
192
160
|
"next": "14.1.0",
|
|
193
|
-
"postcss": "^8.4.35",
|
|
194
|
-
"prettier": "^3.2.5",
|
|
195
|
-
"prettier-plugin-packagejson": "^2.4.10",
|
|
196
|
-
"prettier-plugin-tailwindcss": "^0.5.11",
|
|
197
161
|
"react": "^18.2.0",
|
|
198
|
-
"react-dom": "^18.2.0",
|
|
199
|
-
"react-is": "^18.2.0",
|
|
200
162
|
"rollup": "^4.10.0",
|
|
201
|
-
"
|
|
202
|
-
"server-only": "^0.0.1",
|
|
163
|
+
"rimraf": "^5.0.5",
|
|
203
164
|
"styled-components": "^6.1.8",
|
|
204
|
-
"suspend-react": "^0.1.3",
|
|
205
|
-
"tailwindcss": "^3.4.1",
|
|
206
165
|
"typescript": "^5.3.3",
|
|
207
166
|
"url-loader": "^4.1.1",
|
|
208
167
|
"vitest": "^1.2.2",
|
|
209
168
|
"vitest-github-actions-reporter": "^0.11.1"
|
|
210
169
|
},
|
|
211
170
|
"peerDependencies": {
|
|
212
|
-
"@sanity/client": "^6.
|
|
171
|
+
"@sanity/client": "^6.14.3",
|
|
213
172
|
"@sanity/icons": "^2.8",
|
|
214
173
|
"@sanity/types": "^3.25",
|
|
215
174
|
"@sanity/ui": "^1.8 || ^2.0.0-beta || ^2.0",
|
|
@@ -220,5 +179,16 @@
|
|
|
220
179
|
},
|
|
221
180
|
"engines": {
|
|
222
181
|
"node": ">=18.17"
|
|
182
|
+
},
|
|
183
|
+
"scripts": {
|
|
184
|
+
"prebuild": "npm run clean",
|
|
185
|
+
"build": "pkg build --strict && pkg --strict",
|
|
186
|
+
"clean": "npx rimraf dist",
|
|
187
|
+
"coverage": "npm test -- --coverage",
|
|
188
|
+
"dev": "next",
|
|
189
|
+
"format": "eslint --fix .",
|
|
190
|
+
"lint": "eslint --max-warnings 0 .",
|
|
191
|
+
"test": "vitest",
|
|
192
|
+
"type-check": "tsc --noEmit"
|
|
223
193
|
}
|
|
224
|
-
}
|
|
194
|
+
}
|
package/src/webhook/index.ts
CHANGED
|
@@ -32,10 +32,9 @@ export type ParsedBody<T> = {
|
|
|
32
32
|
* Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
|
|
33
33
|
* without worrying about getting stale data.
|
|
34
34
|
* @public
|
|
35
|
-
* @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.
|
|
36
35
|
*/
|
|
37
36
|
export async function parseBody<Body = SanityDocument>(
|
|
38
|
-
req:
|
|
37
|
+
req: NextRequest,
|
|
39
38
|
secret?: string,
|
|
40
39
|
waitForContentLakeEventualConsistency?: boolean,
|
|
41
40
|
): Promise<ParsedBody<Body>>
|
|
@@ -43,15 +42,16 @@ export async function parseBody<Body = SanityDocument>(
|
|
|
43
42
|
* Handles parsing the body JSON, and validating its signature. Also waits for Content Lake eventual consistency so you can run your queries
|
|
44
43
|
* without worrying about getting stale data.
|
|
45
44
|
* @public
|
|
45
|
+
* @deprecated using `parseBody` with `NextApiRequest` is deprecated and will be removed in the next major version. Use `parseBody` with `NextRequest` instead from a Route Handler in App Router.
|
|
46
46
|
*/
|
|
47
47
|
export async function parseBody<Body = SanityDocument>(
|
|
48
|
-
req:
|
|
48
|
+
req: NextApiRequest,
|
|
49
49
|
secret?: string,
|
|
50
50
|
waitForContentLakeEventualConsistency?: boolean,
|
|
51
51
|
): Promise<ParsedBody<Body>>
|
|
52
52
|
// eslint-disable-next-line require-await
|
|
53
53
|
export async function parseBody<Body = SanityDocument>(
|
|
54
|
-
req:
|
|
54
|
+
req: NextRequest | NextApiRequest,
|
|
55
55
|
secret?: string,
|
|
56
56
|
waitForContentLakeEventualConsistency: boolean = true,
|
|
57
57
|
): Promise<ParsedBody<Body>> {
|