@ohos-ports/prisma-internals 7.10.0-beta.0

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.
Files changed (328) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Generator.d.ts +42 -0
  3. package/dist/Generator.js +29 -0
  4. package/dist/WasmPanicRegistry.d.ts +5 -0
  5. package/dist/WasmPanicRegistry.js +25 -0
  6. package/dist/WasmSchemaEngineLoader.d.ts +5 -0
  7. package/dist/WasmSchemaEngineLoader.js +25 -0
  8. package/dist/built-in-provider.d.ts +5 -0
  9. package/dist/built-in-provider.js +25 -0
  10. package/dist/chunk-2B26F5N3.js +72 -0
  11. package/dist/chunk-2IOZUH3U.js +26 -0
  12. package/dist/chunk-2SDPW6AX.js +39 -0
  13. package/dist/chunk-3IMRWXIL.js +176 -0
  14. package/dist/chunk-3TYD3ZGQ.js +115 -0
  15. package/dist/chunk-3U4QB2G3.js +166 -0
  16. package/dist/chunk-3VD46SL7.js +151 -0
  17. package/dist/chunk-3YOF262C.js +176 -0
  18. package/dist/chunk-3ZHE2IX4.js +55 -0
  19. package/dist/chunk-4VNS5WPM.js +61 -0
  20. package/dist/chunk-5AI4FIZ3.js +1342 -0
  21. package/dist/chunk-5BDP445D.js +51 -0
  22. package/dist/chunk-5DBOS77Y.js +609 -0
  23. package/dist/chunk-5FJ3MENK.js +30 -0
  24. package/dist/chunk-5I4ERIIY.js +30 -0
  25. package/dist/chunk-5PJQQKQI.js +106 -0
  26. package/dist/chunk-5VQNKCKW.js +38 -0
  27. package/dist/chunk-5WRIOIZY.js +31 -0
  28. package/dist/chunk-6JE6QGSJ.js +37 -0
  29. package/dist/chunk-6PWHYRKR.js +74 -0
  30. package/dist/chunk-6QMQ2JYG.js +122 -0
  31. package/dist/chunk-6Z766KGR.js +95 -0
  32. package/dist/chunk-74RGCSUJ.js +44 -0
  33. package/dist/chunk-7B5PXS6N.js +29 -0
  34. package/dist/chunk-ANU3HEGF.js +29 -0
  35. package/dist/chunk-BERN76ZI.js +347 -0
  36. package/dist/chunk-BGMZPA2F.js +39 -0
  37. package/dist/chunk-BPDMLM32.js +105 -0
  38. package/dist/chunk-C47SCASR.js +37 -0
  39. package/dist/chunk-CGFNDGGI.js +40 -0
  40. package/dist/chunk-CTQD6OLG.js +438 -0
  41. package/dist/chunk-CUD726EK.js +36 -0
  42. package/dist/chunk-CXEXLFVL.js +166 -0
  43. package/dist/chunk-CYAS6B5N.js +48 -0
  44. package/dist/chunk-D4VZUY3O.js +71 -0
  45. package/dist/chunk-DODIJPCS.js +34 -0
  46. package/dist/chunk-DTPFRZWV.js +31 -0
  47. package/dist/chunk-DUDEWDFC.js +101 -0
  48. package/dist/chunk-DZ4QWHTB.js +127 -0
  49. package/dist/chunk-E23HYCQJ.js +37 -0
  50. package/dist/chunk-E476ARWS.js +2091 -0
  51. package/dist/chunk-EKGEKB22.js +28 -0
  52. package/dist/chunk-EU6UOKRD.js +26 -0
  53. package/dist/chunk-EWPXLBGE.js +115 -0
  54. package/dist/chunk-FCYHZHVW.js +43 -0
  55. package/dist/chunk-FRVJZOHP.js +1823 -0
  56. package/dist/chunk-GJSFP4V4.js +30 -0
  57. package/dist/chunk-GXW4NTU2.js +34 -0
  58. package/dist/chunk-H4NI2RIK.js +35 -0
  59. package/dist/chunk-HHG4DGHC.js +496 -0
  60. package/dist/chunk-HPVMQFIY.js +407 -0
  61. package/dist/chunk-I2CBQZJY.js +122 -0
  62. package/dist/chunk-I4K46RGG.js +31 -0
  63. package/dist/chunk-I6WLABB2.js +429 -0
  64. package/dist/chunk-ICFLO5JW.js +26 -0
  65. package/dist/chunk-IL7PSY44.js +26 -0
  66. package/dist/chunk-IOIAK7V7.js +53 -0
  67. package/dist/chunk-IYN5VKMD.js +110 -0
  68. package/dist/chunk-J77ZIDXB.js +69 -0
  69. package/dist/chunk-J7ZPY2XA.js +47 -0
  70. package/dist/chunk-JFXHOFJA.js +46 -0
  71. package/dist/chunk-JOIHHXR6.js +2067 -0
  72. package/dist/chunk-JPZYSRK3.js +6412 -0
  73. package/dist/chunk-JTKAT4KZ.js +26 -0
  74. package/dist/chunk-K2EOOA2X.js +91 -0
  75. package/dist/chunk-KDP6C3CB.js +56 -0
  76. package/dist/chunk-L3LDE52J.js +51 -0
  77. package/dist/chunk-L6V54WGO.js +39 -0
  78. package/dist/chunk-LMVSIVKQ.js +62 -0
  79. package/dist/chunk-LPNBWFQ3.js +38 -0
  80. package/dist/chunk-LRBXMV4B.js +26 -0
  81. package/dist/chunk-LRU47BGE.js +78 -0
  82. package/dist/chunk-M3GBKLGE.js +24 -0
  83. package/dist/chunk-MCS5ZY6Y.js +27 -0
  84. package/dist/chunk-NBWRGVYR.js +47 -0
  85. package/dist/chunk-NIWBAJZV.js +36 -0
  86. package/dist/chunk-NTDBN2N2.js +104 -0
  87. package/dist/chunk-NVNI2SRU.js +4230 -0
  88. package/dist/chunk-OIVPX3BR.js +32 -0
  89. package/dist/chunk-PFYALFCY.js +26 -0
  90. package/dist/chunk-PG5FDKSF.js +79 -0
  91. package/dist/chunk-PKF53VLJ.js +26 -0
  92. package/dist/chunk-PTPRBA7K.js +6675 -0
  93. package/dist/chunk-QBNYSYZK.js +74 -0
  94. package/dist/chunk-QMNPESAP.js +124 -0
  95. package/dist/chunk-QN6PSQY7.js +37 -0
  96. package/dist/chunk-QVJ2BXKF.js +3997 -0
  97. package/dist/chunk-R47SFJ5Z.js +104 -0
  98. package/dist/chunk-R6QH57HZ.js +311 -0
  99. package/dist/chunk-RBDYOTWB.js +193 -0
  100. package/dist/chunk-SBUSVJCV.js +62 -0
  101. package/dist/chunk-SP2ETLT2.js +41 -0
  102. package/dist/chunk-TPCPXGC5.js +218 -0
  103. package/dist/chunk-TWSLDIFL.js +48 -0
  104. package/dist/chunk-UGR6KLZN.js +30 -0
  105. package/dist/chunk-UMM35VP5.js +1193 -0
  106. package/dist/chunk-VFNP7Q3Y.js +15529 -0
  107. package/dist/chunk-VNIE2AZB.js +41 -0
  108. package/dist/chunk-VUGB2H7M.js +438 -0
  109. package/dist/chunk-WFMA7DI5.js +92 -0
  110. package/dist/chunk-WV4QHCSM.js +26 -0
  111. package/dist/chunk-WXRVYSYN.js +33 -0
  112. package/dist/chunk-X3P4J7WW.js +28 -0
  113. package/dist/chunk-X77CS5RK.js +33 -0
  114. package/dist/chunk-XAAVALN7.js +110 -0
  115. package/dist/chunk-XXTPN4LB.js +41 -0
  116. package/dist/chunk-XYCIH36R.js +29 -0
  117. package/dist/chunk-Y4TOGY6I.js +30 -0
  118. package/dist/chunk-YNDZCLVL.js +307 -0
  119. package/dist/chunk-YXB6APHS.js +447 -0
  120. package/dist/chunk-ZJWZK45Z.js +68 -0
  121. package/dist/chunk-ZKWDIAVF.js +29 -0
  122. package/dist/cli/Help.d.ts +11 -0
  123. package/dist/cli/Help.js +27 -0
  124. package/dist/cli/checkUnsupportedDataProxy.d.ts +16 -0
  125. package/dist/cli/checkUnsupportedDataProxy.js +125 -0
  126. package/dist/cli/completion-values.d.ts +24 -0
  127. package/dist/cli/completion-values.js +47 -0
  128. package/dist/cli/directoryConfig.d.ts +11 -0
  129. package/dist/cli/directoryConfig.js +25 -0
  130. package/dist/cli/getGeneratorSuccessMessage.d.ts +7 -0
  131. package/dist/cli/getGeneratorSuccessMessage.js +29 -0
  132. package/dist/cli/getSchema.d.ts +46 -0
  133. package/dist/cli/getSchema.js +31 -0
  134. package/dist/cli/getTypescriptVersion.d.ts +1 -0
  135. package/dist/cli/getTypescriptVersion.js +25 -0
  136. package/dist/cli/hashes.d.ts +11 -0
  137. package/dist/cli/hashes.js +28 -0
  138. package/dist/cli/schemaContext.d.ts +56 -0
  139. package/dist/cli/schemaContext.js +126 -0
  140. package/dist/cli/types.d.ts +63 -0
  141. package/dist/cli/types.js +1 -0
  142. package/dist/cli/utils.d.ts +13 -0
  143. package/dist/cli/utils.js +27 -0
  144. package/dist/convertCredentials.d.ts +10 -0
  145. package/dist/convertCredentials.js +28 -0
  146. package/dist/engine-commands/errorHelpers.d.ts +4 -0
  147. package/dist/engine-commands/errorHelpers.js +28 -0
  148. package/dist/engine-commands/formatSchema.d.ts +22 -0
  149. package/dist/engine-commands/formatSchema.js +124 -0
  150. package/dist/engine-commands/getConfig.d.ts +27 -0
  151. package/dist/engine-commands/getConfig.js +39 -0
  152. package/dist/engine-commands/getDmmf.d.ts +21 -0
  153. package/dist/engine-commands/getDmmf.js +40 -0
  154. package/dist/engine-commands/getEngineVersion.d.ts +4 -0
  155. package/dist/engine-commands/getEngineVersion.js +33 -0
  156. package/dist/engine-commands/getEnginesInfo.d.ts +20 -0
  157. package/dist/engine-commands/getEnginesInfo.js +36 -0
  158. package/dist/engine-commands/index.d.ts +10 -0
  159. package/dist/engine-commands/index.js +136 -0
  160. package/dist/engine-commands/lintSchema.d.ts +26 -0
  161. package/dist/engine-commands/lintSchema.js +34 -0
  162. package/dist/engine-commands/mergeSchemas.d.ts +12 -0
  163. package/dist/engine-commands/mergeSchemas.js +39 -0
  164. package/dist/engine-commands/queryEngineCommons.d.ts +31 -0
  165. package/dist/engine-commands/queryEngineCommons.js +33 -0
  166. package/dist/engine-commands/relativizePathInPSLError.d.ts +1 -0
  167. package/dist/engine-commands/relativizePathInPSLError.js +25 -0
  168. package/dist/engine-commands/validate.d.ts +12 -0
  169. package/dist/engine-commands/validate.js +39 -0
  170. package/dist/errorReporting.d.ts +25 -0
  171. package/dist/errorReporting.js +29 -0
  172. package/dist/get-generators/getGenerators.d.ts +71 -0
  173. package/dist/get-generators/getGenerators.js +127 -0
  174. package/dist/get-generators/utils/binaryTypeToEngineType.d.ts +3 -0
  175. package/dist/get-generators/utils/binaryTypeToEngineType.js +25 -0
  176. package/dist/get-generators/utils/engineTypeToBinaryType.d.ts +3 -0
  177. package/dist/get-generators/utils/engineTypeToBinaryType.js +25 -0
  178. package/dist/get-generators/utils/fixBinaryTargets.d.ts +3 -0
  179. package/dist/get-generators/utils/fixBinaryTargets.js +25 -0
  180. package/dist/get-generators/utils/getBinaryPathsByVersion.d.ts +7 -0
  181. package/dist/get-generators/utils/getBinaryPathsByVersion.js +30 -0
  182. package/dist/get-generators/utils/getEngineVersionForGenerator.d.ts +2 -0
  183. package/dist/get-generators/utils/getEngineVersionForGenerator.js +25 -0
  184. package/dist/get-generators/utils/printGeneratorConfig.d.ts +9 -0
  185. package/dist/get-generators/utils/printGeneratorConfig.js +29 -0
  186. package/dist/getPackedPackage.d.ts +1 -0
  187. package/dist/getPackedPackage.js +29 -0
  188. package/dist/highlight/highlight.d.ts +3 -0
  189. package/dist/highlight/highlight.js +32 -0
  190. package/dist/highlight/languages/dml.d.ts +2 -0
  191. package/dist/highlight/languages/dml.js +25 -0
  192. package/dist/highlight/languages/sql.d.ts +2 -0
  193. package/dist/highlight/languages/sql.js +25 -0
  194. package/dist/highlight/prism.d.ts +6 -0
  195. package/dist/highlight/prism.js +28 -0
  196. package/dist/highlight/theme.d.ts +2 -0
  197. package/dist/highlight/theme.js +26 -0
  198. package/dist/highlight/types.d.ts +35 -0
  199. package/dist/highlight/types.js +1 -0
  200. package/dist/index.d.ts +80 -0
  201. package/dist/index.js +257 -0
  202. package/dist/logger.d.ts +14 -0
  203. package/dist/logger.js +32 -0
  204. package/dist/magic-string.es-B2CP4FDB.js +1324 -0
  205. package/dist/migrateTypes.d.ts +99 -0
  206. package/dist/migrateTypes.js +1 -0
  207. package/dist/multipart-parser-3AFJFP6K.js +374 -0
  208. package/dist/panic.d.ts +31 -0
  209. package/dist/panic.js +29 -0
  210. package/dist/resolveBinary.d.ts +6 -0
  211. package/dist/resolveBinary.js +34 -0
  212. package/dist/resolveOutput.d.ts +5 -0
  213. package/dist/resolveOutput.js +25 -0
  214. package/dist/resolvePkg.d.ts +7 -0
  215. package/dist/resolvePkg.js +25 -0
  216. package/dist/schemaEngineCommands.d.ts +36 -0
  217. package/dist/schemaEngineCommands.js +36 -0
  218. package/dist/sendPanic.d.ts +10 -0
  219. package/dist/sendPanic.js +29 -0
  220. package/dist/types.d.ts +34 -0
  221. package/dist/types.js +1 -0
  222. package/dist/utils/__tests__/isCi.test.js +58 -0
  223. package/dist/utils/__tests__/isInteractive.test.js +47 -0
  224. package/dist/utils/assertAlways.d.ts +14 -0
  225. package/dist/utils/assertAlways.js +25 -0
  226. package/dist/utils/assertNever.d.ts +27 -0
  227. package/dist/utils/assertNever.js +25 -0
  228. package/dist/utils/binaryTargetRegex.d.ts +8 -0
  229. package/dist/utils/binaryTargetRegex.js +25 -0
  230. package/dist/utils/callOnce.d.ts +13 -0
  231. package/dist/utils/callOnce.js +25 -0
  232. package/dist/utils/callOnce.test.d.ts +1 -0
  233. package/dist/utils/callOnce.test.js +36 -0
  234. package/dist/utils/canPrompt.d.ts +1 -0
  235. package/dist/utils/canPrompt.js +27 -0
  236. package/dist/utils/chmodPlusX.d.ts +1 -0
  237. package/dist/utils/chmodPlusX.js +25 -0
  238. package/dist/utils/drawBox.d.ts +9 -0
  239. package/dist/utils/drawBox.js +26 -0
  240. package/dist/utils/extractPreviewFeatures.d.ts +2 -0
  241. package/dist/utils/extractPreviewFeatures.js +28 -0
  242. package/dist/utils/formatTable.d.ts +5 -0
  243. package/dist/utils/formatTable.js +25 -0
  244. package/dist/utils/formatms.d.ts +5 -0
  245. package/dist/utils/formatms.js +25 -0
  246. package/dist/utils/fs-functional.d.ts +53 -0
  247. package/dist/utils/fs-functional.js +35 -0
  248. package/dist/utils/fs-utils.d.ts +30 -0
  249. package/dist/utils/fs-utils.js +32 -0
  250. package/dist/utils/getCommandWithExecutor.d.ts +1 -0
  251. package/dist/utils/getCommandWithExecutor.js +26 -0
  252. package/dist/utils/getGitHubIssueUrl.d.ts +18 -0
  253. package/dist/utils/getGitHubIssueUrl.js +27 -0
  254. package/dist/utils/getVersionFromPackageJson.d.ts +1 -0
  255. package/dist/utils/getVersionFromPackageJson.js +26 -0
  256. package/dist/utils/handlePanic.d.ts +11 -0
  257. package/dist/utils/handlePanic.js +36 -0
  258. package/dist/utils/hasOwnProperty.d.ts +1 -0
  259. package/dist/utils/hasOwnProperty.js +25 -0
  260. package/dist/utils/isCi.d.ts +1 -0
  261. package/dist/utils/isCi.js +25 -0
  262. package/dist/utils/isCurrentBinInstalledGlobally.d.ts +1 -0
  263. package/dist/utils/isCurrentBinInstalledGlobally.js +25 -0
  264. package/dist/utils/isInContainer.d.ts +5 -0
  265. package/dist/utils/isInContainer.js +25 -0
  266. package/dist/utils/isInNpmLifecycleHook.d.ts +4 -0
  267. package/dist/utils/isInNpmLifecycleHook.js +25 -0
  268. package/dist/utils/isInteractive.d.ts +6 -0
  269. package/dist/utils/isInteractive.js +25 -0
  270. package/dist/utils/isPromiseLike.d.ts +1 -0
  271. package/dist/utils/isPromiseLike.js +25 -0
  272. package/dist/utils/isValidJsIdentifier.d.ts +1 -0
  273. package/dist/utils/isValidJsIdentifier.js +25 -0
  274. package/dist/utils/keyBy.d.ts +9 -0
  275. package/dist/utils/keyBy.js +25 -0
  276. package/dist/utils/link.d.ts +1 -0
  277. package/dist/utils/link.js +26 -0
  278. package/dist/utils/mapKeys.d.ts +1 -0
  279. package/dist/utils/mapKeys.js +25 -0
  280. package/dist/utils/mapObjectValues.d.ts +1 -0
  281. package/dist/utils/mapObjectValues.js +25 -0
  282. package/dist/utils/max.d.ts +11 -0
  283. package/dist/utils/max.js +26 -0
  284. package/dist/utils/max.test.d.ts +1 -0
  285. package/dist/utils/max.test.js +22 -0
  286. package/dist/utils/maybeInGitHook.d.ts +9 -0
  287. package/dist/utils/maybeInGitHook.js +25 -0
  288. package/dist/utils/missingDatasource.d.ts +1 -0
  289. package/dist/utils/missingDatasource.js +32 -0
  290. package/dist/utils/missingGeneratorMessage.d.ts +3 -0
  291. package/dist/utils/missingGeneratorMessage.js +34 -0
  292. package/dist/utils/now.d.ts +3 -0
  293. package/dist/utils/now.js +51 -0
  294. package/dist/utils/omit.d.ts +6 -0
  295. package/dist/utils/omit.js +30 -0
  296. package/dist/utils/parseAWSNodejsRuntimeEnvVarVersion.d.ts +1 -0
  297. package/dist/utils/parseAWSNodejsRuntimeEnvVarVersion.js +25 -0
  298. package/dist/utils/parseEnvValue.d.ts +17 -0
  299. package/dist/utils/parseEnvValue.js +27 -0
  300. package/dist/utils/path.d.ts +14 -0
  301. package/dist/utils/path.js +26 -0
  302. package/dist/utils/path.test.d.ts +1 -0
  303. package/dist/utils/path.test.js +54 -0
  304. package/dist/utils/pick.d.ts +1 -0
  305. package/dist/utils/pick.js +25 -0
  306. package/dist/utils/printConfigWarnings.d.ts +1 -0
  307. package/dist/utils/printConfigWarnings.js +26 -0
  308. package/dist/utils/prismaPostgres.d.ts +13 -0
  309. package/dist/utils/prismaPostgres.js +28 -0
  310. package/dist/utils/prismaPostgres.test.d.ts +1 -0
  311. package/dist/utils/prismaPostgres.test.js +33 -0
  312. package/dist/utils/schemaFileInput.d.ts +2 -0
  313. package/dist/utils/schemaFileInput.js +25 -0
  314. package/dist/utils/setClassName.d.ts +9 -0
  315. package/dist/utils/setClassName.js +25 -0
  316. package/dist/utils/toSchemasContainer.d.ts +5 -0
  317. package/dist/utils/toSchemasContainer.js +26 -0
  318. package/dist/utils/unique.d.ts +5 -0
  319. package/dist/utils/unique.js +38 -0
  320. package/dist/utils/validatePrismaConfigWithDatasource.d.ts +17 -0
  321. package/dist/utils/validatePrismaConfigWithDatasource.js +28 -0
  322. package/dist/utils/vercelPkgPathRegex.d.ts +1 -0
  323. package/dist/utils/vercelPkgPathRegex.js +25 -0
  324. package/dist/warnOnce.d.ts +1 -0
  325. package/dist/warnOnce.js +27 -0
  326. package/dist/wasm.d.ts +5 -0
  327. package/dist/wasm.js +29 -0
  328. package/package.json +93 -0
@@ -0,0 +1,1342 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_5AI4FIZ3_exports = {};
30
+ __export(chunk_5AI4FIZ3_exports, {
31
+ ErrorKind: () => ErrorKind,
32
+ createErrorReport: () => createErrorReport,
33
+ makeErrorReportCompleted: () => makeErrorReportCompleted,
34
+ uploadZip: () => uploadZip
35
+ });
36
+ module.exports = __toCommonJS(chunk_5AI4FIZ3_exports);
37
+ var import_chunk_NVNI2SRU = require("./chunk-NVNI2SRU.js");
38
+ var import_fetch_engine = require("@prisma/fetch-engine");
39
+ var import_node_http = __toESM(require("node:http"));
40
+ var import_node_https = __toESM(require("node:https"));
41
+ var import_node_zlib = __toESM(require("node:zlib"));
42
+ var import_node_stream = __toESM(require("node:stream"));
43
+ var import_node_buffer = require("node:buffer");
44
+ var import_node_stream2 = __toESM(require("node:stream"));
45
+ var import_node_util = require("node:util");
46
+ var import_node_buffer2 = require("node:buffer");
47
+ var import_node_util2 = require("node:util");
48
+ var import_node_http2 = __toESM(require("node:http"));
49
+ var import_node_url = require("node:url");
50
+ var import_node_util3 = require("node:util");
51
+ var import_node_net = require("node:net");
52
+ function dataUriToBuffer(uri) {
53
+ if (!/^data:/i.test(uri)) {
54
+ throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
55
+ }
56
+ uri = uri.replace(/\r?\n/g, "");
57
+ const firstComma = uri.indexOf(",");
58
+ if (firstComma === -1 || firstComma <= 4) {
59
+ throw new TypeError("malformed data: URI");
60
+ }
61
+ const meta = uri.substring(5, firstComma).split(";");
62
+ let charset = "";
63
+ let base64 = false;
64
+ const type = meta[0] || "text/plain";
65
+ let typeFull = type;
66
+ for (let i = 1; i < meta.length; i++) {
67
+ if (meta[i] === "base64") {
68
+ base64 = true;
69
+ } else if (meta[i]) {
70
+ typeFull += `;${meta[i]}`;
71
+ if (meta[i].indexOf("charset=") === 0) {
72
+ charset = meta[i].substring(8);
73
+ }
74
+ }
75
+ }
76
+ if (!meta[0] && !charset.length) {
77
+ typeFull += ";charset=US-ASCII";
78
+ charset = "US-ASCII";
79
+ }
80
+ const encoding = base64 ? "base64" : "ascii";
81
+ const data = unescape(uri.substring(firstComma + 1));
82
+ const buffer = Buffer.from(data, encoding);
83
+ buffer.type = type;
84
+ buffer.typeFull = typeFull;
85
+ buffer.charset = charset;
86
+ return buffer;
87
+ }
88
+ var dist_default = dataUriToBuffer;
89
+ var FetchBaseError = class extends Error {
90
+ constructor(message, type) {
91
+ super(message);
92
+ Error.captureStackTrace(this, this.constructor);
93
+ this.type = type;
94
+ }
95
+ get name() {
96
+ return this.constructor.name;
97
+ }
98
+ get [Symbol.toStringTag]() {
99
+ return this.constructor.name;
100
+ }
101
+ };
102
+ var FetchError = class extends FetchBaseError {
103
+ /**
104
+ * @param {string} message - Error message for human
105
+ * @param {string} [type] - Error type for machine
106
+ * @param {SystemError} [systemError] - For Node.js system error
107
+ */
108
+ constructor(message, type, systemError) {
109
+ super(message, type);
110
+ if (systemError) {
111
+ this.code = this.errno = systemError.code;
112
+ this.erroredSysCall = systemError.syscall;
113
+ }
114
+ }
115
+ };
116
+ var NAME = Symbol.toStringTag;
117
+ var isURLSearchParameters = (object) => {
118
+ return typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && typeof object.sort === "function" && object[NAME] === "URLSearchParams";
119
+ };
120
+ var isBlob = (object) => {
121
+ return object && typeof object === "object" && typeof object.arrayBuffer === "function" && typeof object.type === "string" && typeof object.stream === "function" && typeof object.constructor === "function" && /^(Blob|File)$/.test(object[NAME]);
122
+ };
123
+ var isAbortSignal = (object) => {
124
+ return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
125
+ };
126
+ var isDomainOrSubdomain = (destination, original) => {
127
+ const orig = new URL(original).hostname;
128
+ const dest = new URL(destination).hostname;
129
+ return orig === dest || orig.endsWith(`.${dest}`);
130
+ };
131
+ var isSameProtocol = (destination, original) => {
132
+ const orig = new URL(original).protocol;
133
+ const dest = new URL(destination).protocol;
134
+ return orig === dest;
135
+ };
136
+ var pipeline = (0, import_node_util.promisify)(import_node_stream2.default.pipeline);
137
+ var INTERNALS = Symbol("Body internals");
138
+ var Body = class {
139
+ constructor(body, {
140
+ size = 0
141
+ } = {}) {
142
+ let boundary = null;
143
+ if (body === null) {
144
+ body = null;
145
+ } else if (isURLSearchParameters(body)) {
146
+ body = import_node_buffer2.Buffer.from(body.toString());
147
+ } else if (isBlob(body)) {
148
+ } else if (import_node_buffer2.Buffer.isBuffer(body)) {
149
+ } else if (import_node_util.types.isAnyArrayBuffer(body)) {
150
+ body = import_node_buffer2.Buffer.from(body);
151
+ } else if (ArrayBuffer.isView(body)) {
152
+ body = import_node_buffer2.Buffer.from(body.buffer, body.byteOffset, body.byteLength);
153
+ } else if (body instanceof import_node_stream2.default) {
154
+ } else if (body instanceof import_chunk_NVNI2SRU.FormData) {
155
+ body = (0, import_chunk_NVNI2SRU.formDataToBlob)(body);
156
+ boundary = body.type.split("=")[1];
157
+ } else {
158
+ body = import_node_buffer2.Buffer.from(String(body));
159
+ }
160
+ let stream = body;
161
+ if (import_node_buffer2.Buffer.isBuffer(body)) {
162
+ stream = import_node_stream2.default.Readable.from(body);
163
+ } else if (isBlob(body)) {
164
+ stream = import_node_stream2.default.Readable.from(body.stream());
165
+ }
166
+ this[INTERNALS] = {
167
+ body,
168
+ stream,
169
+ boundary,
170
+ disturbed: false,
171
+ error: null
172
+ };
173
+ this.size = size;
174
+ if (body instanceof import_node_stream2.default) {
175
+ body.on("error", (error_) => {
176
+ const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
177
+ this[INTERNALS].error = error;
178
+ });
179
+ }
180
+ }
181
+ get body() {
182
+ return this[INTERNALS].stream;
183
+ }
184
+ get bodyUsed() {
185
+ return this[INTERNALS].disturbed;
186
+ }
187
+ /**
188
+ * Decode response as ArrayBuffer
189
+ *
190
+ * @return Promise
191
+ */
192
+ async arrayBuffer() {
193
+ const { buffer, byteOffset, byteLength } = await consumeBody(this);
194
+ return buffer.slice(byteOffset, byteOffset + byteLength);
195
+ }
196
+ async formData() {
197
+ const ct = this.headers.get("content-type");
198
+ if (ct.startsWith("application/x-www-form-urlencoded")) {
199
+ const formData = new import_chunk_NVNI2SRU.FormData();
200
+ const parameters = new URLSearchParams(await this.text());
201
+ for (const [name, value] of parameters) {
202
+ formData.append(name, value);
203
+ }
204
+ return formData;
205
+ }
206
+ const { toFormData } = await import("./multipart-parser-3AFJFP6K.js");
207
+ return toFormData(this.body, ct);
208
+ }
209
+ /**
210
+ * Return raw response as Blob
211
+ *
212
+ * @return Promise
213
+ */
214
+ async blob() {
215
+ const ct = this.headers && this.headers.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
216
+ const buf = await this.arrayBuffer();
217
+ return new import_chunk_NVNI2SRU.fetch_blob_default([buf], {
218
+ type: ct
219
+ });
220
+ }
221
+ /**
222
+ * Decode response as json
223
+ *
224
+ * @return Promise
225
+ */
226
+ async json() {
227
+ const text = await this.text();
228
+ return JSON.parse(text);
229
+ }
230
+ /**
231
+ * Decode response as text
232
+ *
233
+ * @return Promise
234
+ */
235
+ async text() {
236
+ const buffer = await consumeBody(this);
237
+ return new TextDecoder().decode(buffer);
238
+ }
239
+ /**
240
+ * Decode response as buffer (non-spec api)
241
+ *
242
+ * @return Promise
243
+ */
244
+ buffer() {
245
+ return consumeBody(this);
246
+ }
247
+ };
248
+ Body.prototype.buffer = (0, import_node_util.deprecate)(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
249
+ Object.defineProperties(Body.prototype, {
250
+ body: { enumerable: true },
251
+ bodyUsed: { enumerable: true },
252
+ arrayBuffer: { enumerable: true },
253
+ blob: { enumerable: true },
254
+ json: { enumerable: true },
255
+ text: { enumerable: true },
256
+ data: { get: (0, import_node_util.deprecate)(
257
+ () => {
258
+ },
259
+ "data doesn't exist, use json(), text(), arrayBuffer(), or body instead",
260
+ "https://github.com/node-fetch/node-fetch/issues/1000 (response)"
261
+ ) }
262
+ });
263
+ async function consumeBody(data) {
264
+ if (data[INTERNALS].disturbed) {
265
+ throw new TypeError(`body used already for: ${data.url}`);
266
+ }
267
+ data[INTERNALS].disturbed = true;
268
+ if (data[INTERNALS].error) {
269
+ throw data[INTERNALS].error;
270
+ }
271
+ const { body } = data;
272
+ if (body === null) {
273
+ return import_node_buffer2.Buffer.alloc(0);
274
+ }
275
+ if (!(body instanceof import_node_stream2.default)) {
276
+ return import_node_buffer2.Buffer.alloc(0);
277
+ }
278
+ const accum = [];
279
+ let accumBytes = 0;
280
+ try {
281
+ for await (const chunk of body) {
282
+ if (data.size > 0 && accumBytes + chunk.length > data.size) {
283
+ const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
284
+ body.destroy(error);
285
+ throw error;
286
+ }
287
+ accumBytes += chunk.length;
288
+ accum.push(chunk);
289
+ }
290
+ } catch (error) {
291
+ const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
292
+ throw error_;
293
+ }
294
+ if (body.readableEnded === true || body._readableState.ended === true) {
295
+ try {
296
+ if (accum.every((c) => typeof c === "string")) {
297
+ return import_node_buffer2.Buffer.from(accum.join(""));
298
+ }
299
+ return import_node_buffer2.Buffer.concat(accum, accumBytes);
300
+ } catch (error) {
301
+ throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
302
+ }
303
+ } else {
304
+ throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
305
+ }
306
+ }
307
+ var clone = (instance, highWaterMark) => {
308
+ let p1;
309
+ let p2;
310
+ let { body } = instance[INTERNALS];
311
+ if (instance.bodyUsed) {
312
+ throw new Error("cannot clone body after it is used");
313
+ }
314
+ if (body instanceof import_node_stream2.default && typeof body.getBoundary !== "function") {
315
+ p1 = new import_node_stream2.PassThrough({ highWaterMark });
316
+ p2 = new import_node_stream2.PassThrough({ highWaterMark });
317
+ body.pipe(p1);
318
+ body.pipe(p2);
319
+ instance[INTERNALS].stream = p1;
320
+ body = p2;
321
+ }
322
+ return body;
323
+ };
324
+ var getNonSpecFormDataBoundary = (0, import_node_util.deprecate)(
325
+ (body) => body.getBoundary(),
326
+ "form-data doesn't follow the spec and requires special treatment. Use alternative package",
327
+ "https://github.com/node-fetch/node-fetch/issues/1167"
328
+ );
329
+ var extractContentType = (body, request2) => {
330
+ if (body === null) {
331
+ return null;
332
+ }
333
+ if (typeof body === "string") {
334
+ return "text/plain;charset=UTF-8";
335
+ }
336
+ if (isURLSearchParameters(body)) {
337
+ return "application/x-www-form-urlencoded;charset=UTF-8";
338
+ }
339
+ if (isBlob(body)) {
340
+ return body.type || null;
341
+ }
342
+ if (import_node_buffer2.Buffer.isBuffer(body) || import_node_util.types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
343
+ return null;
344
+ }
345
+ if (body instanceof import_chunk_NVNI2SRU.FormData) {
346
+ return `multipart/form-data; boundary=${request2[INTERNALS].boundary}`;
347
+ }
348
+ if (body && typeof body.getBoundary === "function") {
349
+ return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
350
+ }
351
+ if (body instanceof import_node_stream2.default) {
352
+ return null;
353
+ }
354
+ return "text/plain;charset=UTF-8";
355
+ };
356
+ var getTotalBytes = (request2) => {
357
+ const { body } = request2[INTERNALS];
358
+ if (body === null) {
359
+ return 0;
360
+ }
361
+ if (isBlob(body)) {
362
+ return body.size;
363
+ }
364
+ if (import_node_buffer2.Buffer.isBuffer(body)) {
365
+ return body.length;
366
+ }
367
+ if (body && typeof body.getLengthSync === "function") {
368
+ return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
369
+ }
370
+ return null;
371
+ };
372
+ var writeToStream = async (dest, { body }) => {
373
+ if (body === null) {
374
+ dest.end();
375
+ } else {
376
+ await pipeline(body, dest);
377
+ }
378
+ };
379
+ var validateHeaderName = typeof import_node_http2.default.validateHeaderName === "function" ? import_node_http2.default.validateHeaderName : (name) => {
380
+ if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
381
+ const error = new TypeError(`Header name must be a valid HTTP token [${name}]`);
382
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
383
+ throw error;
384
+ }
385
+ };
386
+ var validateHeaderValue = typeof import_node_http2.default.validateHeaderValue === "function" ? import_node_http2.default.validateHeaderValue : (name, value) => {
387
+ if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
388
+ const error = new TypeError(`Invalid character in header content ["${name}"]`);
389
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
390
+ throw error;
391
+ }
392
+ };
393
+ var Headers = class _Headers extends URLSearchParams {
394
+ /**
395
+ * Headers class
396
+ *
397
+ * @constructor
398
+ * @param {HeadersInit} [init] - Response headers
399
+ */
400
+ constructor(init) {
401
+ let result = [];
402
+ if (init instanceof _Headers) {
403
+ const raw = init.raw();
404
+ for (const [name, values] of Object.entries(raw)) {
405
+ result.push(...values.map((value) => [name, value]));
406
+ }
407
+ } else if (init == null) {
408
+ } else if (typeof init === "object" && !import_node_util2.types.isBoxedPrimitive(init)) {
409
+ const method = init[Symbol.iterator];
410
+ if (method == null) {
411
+ result.push(...Object.entries(init));
412
+ } else {
413
+ if (typeof method !== "function") {
414
+ throw new TypeError("Header pairs must be iterable");
415
+ }
416
+ result = [...init].map((pair) => {
417
+ if (typeof pair !== "object" || import_node_util2.types.isBoxedPrimitive(pair)) {
418
+ throw new TypeError("Each header pair must be an iterable object");
419
+ }
420
+ return [...pair];
421
+ }).map((pair) => {
422
+ if (pair.length !== 2) {
423
+ throw new TypeError("Each header pair must be a name/value tuple");
424
+ }
425
+ return [...pair];
426
+ });
427
+ }
428
+ } else {
429
+ throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
430
+ }
431
+ result = result.length > 0 ? result.map(([name, value]) => {
432
+ validateHeaderName(name);
433
+ validateHeaderValue(name, String(value));
434
+ return [String(name).toLowerCase(), String(value)];
435
+ }) : void 0;
436
+ super(result);
437
+ return new Proxy(this, {
438
+ get(target, p, receiver) {
439
+ switch (p) {
440
+ case "append":
441
+ case "set":
442
+ return (name, value) => {
443
+ validateHeaderName(name);
444
+ validateHeaderValue(name, String(value));
445
+ return URLSearchParams.prototype[p].call(
446
+ target,
447
+ String(name).toLowerCase(),
448
+ String(value)
449
+ );
450
+ };
451
+ case "delete":
452
+ case "has":
453
+ case "getAll":
454
+ return (name) => {
455
+ validateHeaderName(name);
456
+ return URLSearchParams.prototype[p].call(
457
+ target,
458
+ String(name).toLowerCase()
459
+ );
460
+ };
461
+ case "keys":
462
+ return () => {
463
+ target.sort();
464
+ return new Set(URLSearchParams.prototype.keys.call(target)).keys();
465
+ };
466
+ default:
467
+ return Reflect.get(target, p, receiver);
468
+ }
469
+ }
470
+ });
471
+ }
472
+ get [Symbol.toStringTag]() {
473
+ return this.constructor.name;
474
+ }
475
+ toString() {
476
+ return Object.prototype.toString.call(this);
477
+ }
478
+ get(name) {
479
+ const values = this.getAll(name);
480
+ if (values.length === 0) {
481
+ return null;
482
+ }
483
+ let value = values.join(", ");
484
+ if (/^content-encoding$/i.test(name)) {
485
+ value = value.toLowerCase();
486
+ }
487
+ return value;
488
+ }
489
+ forEach(callback, thisArg = void 0) {
490
+ for (const name of this.keys()) {
491
+ Reflect.apply(callback, thisArg, [this.get(name), name, this]);
492
+ }
493
+ }
494
+ *values() {
495
+ for (const name of this.keys()) {
496
+ yield this.get(name);
497
+ }
498
+ }
499
+ /**
500
+ * @type {() => IterableIterator<[string, string]>}
501
+ */
502
+ *entries() {
503
+ for (const name of this.keys()) {
504
+ yield [name, this.get(name)];
505
+ }
506
+ }
507
+ [Symbol.iterator]() {
508
+ return this.entries();
509
+ }
510
+ /**
511
+ * Node-fetch non-spec method
512
+ * returning all headers and their values as array
513
+ * @returns {Record<string, string[]>}
514
+ */
515
+ raw() {
516
+ return [...this.keys()].reduce((result, key) => {
517
+ result[key] = this.getAll(key);
518
+ return result;
519
+ }, {});
520
+ }
521
+ /**
522
+ * For better console.log(headers) and also to convert Headers into Node.js Request compatible format
523
+ */
524
+ [Symbol.for("nodejs.util.inspect.custom")]() {
525
+ return [...this.keys()].reduce((result, key) => {
526
+ const values = this.getAll(key);
527
+ if (key === "host") {
528
+ result[key] = values[0];
529
+ } else {
530
+ result[key] = values.length > 1 ? values : values[0];
531
+ }
532
+ return result;
533
+ }, {});
534
+ }
535
+ };
536
+ Object.defineProperties(
537
+ Headers.prototype,
538
+ ["get", "entries", "forEach", "values"].reduce((result, property) => {
539
+ result[property] = { enumerable: true };
540
+ return result;
541
+ }, {})
542
+ );
543
+ function fromRawHeaders(headers = []) {
544
+ return new Headers(
545
+ headers.reduce((result, value, index, array) => {
546
+ if (index % 2 === 0) {
547
+ result.push(array.slice(index, index + 2));
548
+ }
549
+ return result;
550
+ }, []).filter(([name, value]) => {
551
+ try {
552
+ validateHeaderName(name);
553
+ validateHeaderValue(name, String(value));
554
+ return true;
555
+ } catch {
556
+ return false;
557
+ }
558
+ })
559
+ );
560
+ }
561
+ var redirectStatus = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
562
+ var isRedirect = (code) => {
563
+ return redirectStatus.has(code);
564
+ };
565
+ var INTERNALS2 = Symbol("Response internals");
566
+ var Response = class _Response extends Body {
567
+ constructor(body = null, options = {}) {
568
+ super(body, options);
569
+ const status = options.status != null ? options.status : 200;
570
+ const headers = new Headers(options.headers);
571
+ if (body !== null && !headers.has("Content-Type")) {
572
+ const contentType = extractContentType(body, this);
573
+ if (contentType) {
574
+ headers.append("Content-Type", contentType);
575
+ }
576
+ }
577
+ this[INTERNALS2] = {
578
+ type: "default",
579
+ url: options.url,
580
+ status,
581
+ statusText: options.statusText || "",
582
+ headers,
583
+ counter: options.counter,
584
+ highWaterMark: options.highWaterMark
585
+ };
586
+ }
587
+ get type() {
588
+ return this[INTERNALS2].type;
589
+ }
590
+ get url() {
591
+ return this[INTERNALS2].url || "";
592
+ }
593
+ get status() {
594
+ return this[INTERNALS2].status;
595
+ }
596
+ /**
597
+ * Convenience property representing if the request ended normally
598
+ */
599
+ get ok() {
600
+ return this[INTERNALS2].status >= 200 && this[INTERNALS2].status < 300;
601
+ }
602
+ get redirected() {
603
+ return this[INTERNALS2].counter > 0;
604
+ }
605
+ get statusText() {
606
+ return this[INTERNALS2].statusText;
607
+ }
608
+ get headers() {
609
+ return this[INTERNALS2].headers;
610
+ }
611
+ get highWaterMark() {
612
+ return this[INTERNALS2].highWaterMark;
613
+ }
614
+ /**
615
+ * Clone this response
616
+ *
617
+ * @return Response
618
+ */
619
+ clone() {
620
+ return new _Response(clone(this, this.highWaterMark), {
621
+ type: this.type,
622
+ url: this.url,
623
+ status: this.status,
624
+ statusText: this.statusText,
625
+ headers: this.headers,
626
+ ok: this.ok,
627
+ redirected: this.redirected,
628
+ size: this.size,
629
+ highWaterMark: this.highWaterMark
630
+ });
631
+ }
632
+ /**
633
+ * @param {string} url The URL that the new response is to originate from.
634
+ * @param {number} status An optional status code for the response (e.g., 302.)
635
+ * @returns {Response} A Response object.
636
+ */
637
+ static redirect(url, status = 302) {
638
+ if (!isRedirect(status)) {
639
+ throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
640
+ }
641
+ return new _Response(null, {
642
+ headers: {
643
+ location: new URL(url).toString()
644
+ },
645
+ status
646
+ });
647
+ }
648
+ static error() {
649
+ const response = new _Response(null, { status: 0, statusText: "" });
650
+ response[INTERNALS2].type = "error";
651
+ return response;
652
+ }
653
+ static json(data = void 0, init = {}) {
654
+ const body = JSON.stringify(data);
655
+ if (body === void 0) {
656
+ throw new TypeError("data is not JSON serializable");
657
+ }
658
+ const headers = new Headers(init && init.headers);
659
+ if (!headers.has("content-type")) {
660
+ headers.set("content-type", "application/json");
661
+ }
662
+ return new _Response(body, {
663
+ ...init,
664
+ headers
665
+ });
666
+ }
667
+ get [Symbol.toStringTag]() {
668
+ return "Response";
669
+ }
670
+ };
671
+ Object.defineProperties(Response.prototype, {
672
+ type: { enumerable: true },
673
+ url: { enumerable: true },
674
+ status: { enumerable: true },
675
+ ok: { enumerable: true },
676
+ redirected: { enumerable: true },
677
+ statusText: { enumerable: true },
678
+ headers: { enumerable: true },
679
+ clone: { enumerable: true }
680
+ });
681
+ var getSearch = (parsedURL) => {
682
+ if (parsedURL.search) {
683
+ return parsedURL.search;
684
+ }
685
+ const lastOffset = parsedURL.href.length - 1;
686
+ const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
687
+ return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
688
+ };
689
+ function stripURLForUseAsAReferrer(url, originOnly = false) {
690
+ if (url == null) {
691
+ return "no-referrer";
692
+ }
693
+ url = new URL(url);
694
+ if (/^(about|blob|data):$/.test(url.protocol)) {
695
+ return "no-referrer";
696
+ }
697
+ url.username = "";
698
+ url.password = "";
699
+ url.hash = "";
700
+ if (originOnly) {
701
+ url.pathname = "";
702
+ url.search = "";
703
+ }
704
+ return url;
705
+ }
706
+ var ReferrerPolicy = /* @__PURE__ */ new Set([
707
+ "",
708
+ "no-referrer",
709
+ "no-referrer-when-downgrade",
710
+ "same-origin",
711
+ "origin",
712
+ "strict-origin",
713
+ "origin-when-cross-origin",
714
+ "strict-origin-when-cross-origin",
715
+ "unsafe-url"
716
+ ]);
717
+ var DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
718
+ function validateReferrerPolicy(referrerPolicy) {
719
+ if (!ReferrerPolicy.has(referrerPolicy)) {
720
+ throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
721
+ }
722
+ return referrerPolicy;
723
+ }
724
+ function isOriginPotentiallyTrustworthy(url) {
725
+ if (/^(http|ws)s:$/.test(url.protocol)) {
726
+ return true;
727
+ }
728
+ const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
729
+ const hostIPVersion = (0, import_node_net.isIP)(hostIp);
730
+ if (hostIPVersion === 4 && /^127\./.test(hostIp)) {
731
+ return true;
732
+ }
733
+ if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) {
734
+ return true;
735
+ }
736
+ if (url.host === "localhost" || url.host.endsWith(".localhost")) {
737
+ return false;
738
+ }
739
+ if (url.protocol === "file:") {
740
+ return true;
741
+ }
742
+ return false;
743
+ }
744
+ function isUrlPotentiallyTrustworthy(url) {
745
+ if (/^about:(blank|srcdoc)$/.test(url)) {
746
+ return true;
747
+ }
748
+ if (url.protocol === "data:") {
749
+ return true;
750
+ }
751
+ if (/^(blob|filesystem):$/.test(url.protocol)) {
752
+ return true;
753
+ }
754
+ return isOriginPotentiallyTrustworthy(url);
755
+ }
756
+ function determineRequestsReferrer(request2, { referrerURLCallback, referrerOriginCallback } = {}) {
757
+ if (request2.referrer === "no-referrer" || request2.referrerPolicy === "") {
758
+ return null;
759
+ }
760
+ const policy = request2.referrerPolicy;
761
+ if (request2.referrer === "about:client") {
762
+ return "no-referrer";
763
+ }
764
+ const referrerSource = request2.referrer;
765
+ let referrerURL = stripURLForUseAsAReferrer(referrerSource);
766
+ let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
767
+ if (referrerURL.toString().length > 4096) {
768
+ referrerURL = referrerOrigin;
769
+ }
770
+ if (referrerURLCallback) {
771
+ referrerURL = referrerURLCallback(referrerURL);
772
+ }
773
+ if (referrerOriginCallback) {
774
+ referrerOrigin = referrerOriginCallback(referrerOrigin);
775
+ }
776
+ const currentURL = new URL(request2.url);
777
+ switch (policy) {
778
+ case "no-referrer":
779
+ return "no-referrer";
780
+ case "origin":
781
+ return referrerOrigin;
782
+ case "unsafe-url":
783
+ return referrerURL;
784
+ case "strict-origin":
785
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
786
+ return "no-referrer";
787
+ }
788
+ return referrerOrigin.toString();
789
+ case "strict-origin-when-cross-origin":
790
+ if (referrerURL.origin === currentURL.origin) {
791
+ return referrerURL;
792
+ }
793
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
794
+ return "no-referrer";
795
+ }
796
+ return referrerOrigin;
797
+ case "same-origin":
798
+ if (referrerURL.origin === currentURL.origin) {
799
+ return referrerURL;
800
+ }
801
+ return "no-referrer";
802
+ case "origin-when-cross-origin":
803
+ if (referrerURL.origin === currentURL.origin) {
804
+ return referrerURL;
805
+ }
806
+ return referrerOrigin;
807
+ case "no-referrer-when-downgrade":
808
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) {
809
+ return "no-referrer";
810
+ }
811
+ return referrerURL;
812
+ default:
813
+ throw new TypeError(`Invalid referrerPolicy: ${policy}`);
814
+ }
815
+ }
816
+ function parseReferrerPolicyFromHeader(headers) {
817
+ const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
818
+ let policy = "";
819
+ for (const token of policyTokens) {
820
+ if (token && ReferrerPolicy.has(token)) {
821
+ policy = token;
822
+ }
823
+ }
824
+ return policy;
825
+ }
826
+ var INTERNALS3 = Symbol("Request internals");
827
+ var isRequest = (object) => {
828
+ return typeof object === "object" && typeof object[INTERNALS3] === "object";
829
+ };
830
+ var doBadDataWarn = (0, import_node_util3.deprecate)(
831
+ () => {
832
+ },
833
+ ".data is not a valid RequestInit property, use .body instead",
834
+ "https://github.com/node-fetch/node-fetch/issues/1000 (request)"
835
+ );
836
+ var Request = class _Request extends Body {
837
+ constructor(input, init = {}) {
838
+ let parsedURL;
839
+ if (isRequest(input)) {
840
+ parsedURL = new URL(input.url);
841
+ } else {
842
+ parsedURL = new URL(input);
843
+ input = {};
844
+ }
845
+ if (parsedURL.username !== "" || parsedURL.password !== "") {
846
+ throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
847
+ }
848
+ let method = init.method || input.method || "GET";
849
+ if (/^(delete|get|head|options|post|put)$/i.test(method)) {
850
+ method = method.toUpperCase();
851
+ }
852
+ if (!isRequest(init) && "data" in init) {
853
+ doBadDataWarn();
854
+ }
855
+ if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
856
+ throw new TypeError("Request with GET/HEAD method cannot have body");
857
+ }
858
+ const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
859
+ super(inputBody, {
860
+ size: init.size || input.size || 0
861
+ });
862
+ const headers = new Headers(init.headers || input.headers || {});
863
+ if (inputBody !== null && !headers.has("Content-Type")) {
864
+ const contentType = extractContentType(inputBody, this);
865
+ if (contentType) {
866
+ headers.set("Content-Type", contentType);
867
+ }
868
+ }
869
+ let signal = isRequest(input) ? input.signal : null;
870
+ if ("signal" in init) {
871
+ signal = init.signal;
872
+ }
873
+ if (signal != null && !isAbortSignal(signal)) {
874
+ throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
875
+ }
876
+ let referrer = init.referrer == null ? input.referrer : init.referrer;
877
+ if (referrer === "") {
878
+ referrer = "no-referrer";
879
+ } else if (referrer) {
880
+ const parsedReferrer = new URL(referrer);
881
+ referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
882
+ } else {
883
+ referrer = void 0;
884
+ }
885
+ this[INTERNALS3] = {
886
+ method,
887
+ redirect: init.redirect || input.redirect || "follow",
888
+ headers,
889
+ parsedURL,
890
+ signal,
891
+ referrer
892
+ };
893
+ this.follow = init.follow === void 0 ? input.follow === void 0 ? 20 : input.follow : init.follow;
894
+ this.compress = init.compress === void 0 ? input.compress === void 0 ? true : input.compress : init.compress;
895
+ this.counter = init.counter || input.counter || 0;
896
+ this.agent = init.agent || input.agent;
897
+ this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
898
+ this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
899
+ this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
900
+ }
901
+ /** @returns {string} */
902
+ get method() {
903
+ return this[INTERNALS3].method;
904
+ }
905
+ /** @returns {string} */
906
+ get url() {
907
+ return (0, import_node_url.format)(this[INTERNALS3].parsedURL);
908
+ }
909
+ /** @returns {Headers} */
910
+ get headers() {
911
+ return this[INTERNALS3].headers;
912
+ }
913
+ get redirect() {
914
+ return this[INTERNALS3].redirect;
915
+ }
916
+ /** @returns {AbortSignal} */
917
+ get signal() {
918
+ return this[INTERNALS3].signal;
919
+ }
920
+ // https://fetch.spec.whatwg.org/#dom-request-referrer
921
+ get referrer() {
922
+ if (this[INTERNALS3].referrer === "no-referrer") {
923
+ return "";
924
+ }
925
+ if (this[INTERNALS3].referrer === "client") {
926
+ return "about:client";
927
+ }
928
+ if (this[INTERNALS3].referrer) {
929
+ return this[INTERNALS3].referrer.toString();
930
+ }
931
+ return void 0;
932
+ }
933
+ get referrerPolicy() {
934
+ return this[INTERNALS3].referrerPolicy;
935
+ }
936
+ set referrerPolicy(referrerPolicy) {
937
+ this[INTERNALS3].referrerPolicy = validateReferrerPolicy(referrerPolicy);
938
+ }
939
+ /**
940
+ * Clone this request
941
+ *
942
+ * @return Request
943
+ */
944
+ clone() {
945
+ return new _Request(this);
946
+ }
947
+ get [Symbol.toStringTag]() {
948
+ return "Request";
949
+ }
950
+ };
951
+ Object.defineProperties(Request.prototype, {
952
+ method: { enumerable: true },
953
+ url: { enumerable: true },
954
+ headers: { enumerable: true },
955
+ redirect: { enumerable: true },
956
+ clone: { enumerable: true },
957
+ signal: { enumerable: true },
958
+ referrer: { enumerable: true },
959
+ referrerPolicy: { enumerable: true }
960
+ });
961
+ var getNodeRequestOptions = (request2) => {
962
+ const { parsedURL } = request2[INTERNALS3];
963
+ const headers = new Headers(request2[INTERNALS3].headers);
964
+ if (!headers.has("Accept")) {
965
+ headers.set("Accept", "*/*");
966
+ }
967
+ let contentLengthValue = null;
968
+ if (request2.body === null && /^(post|put)$/i.test(request2.method)) {
969
+ contentLengthValue = "0";
970
+ }
971
+ if (request2.body !== null) {
972
+ const totalBytes = getTotalBytes(request2);
973
+ if (typeof totalBytes === "number" && !Number.isNaN(totalBytes)) {
974
+ contentLengthValue = String(totalBytes);
975
+ }
976
+ }
977
+ if (contentLengthValue) {
978
+ headers.set("Content-Length", contentLengthValue);
979
+ }
980
+ if (request2.referrerPolicy === "") {
981
+ request2.referrerPolicy = DEFAULT_REFERRER_POLICY;
982
+ }
983
+ if (request2.referrer && request2.referrer !== "no-referrer") {
984
+ request2[INTERNALS3].referrer = determineRequestsReferrer(request2);
985
+ } else {
986
+ request2[INTERNALS3].referrer = "no-referrer";
987
+ }
988
+ if (request2[INTERNALS3].referrer instanceof URL) {
989
+ headers.set("Referer", request2.referrer);
990
+ }
991
+ if (!headers.has("User-Agent")) {
992
+ headers.set("User-Agent", "node-fetch");
993
+ }
994
+ if (request2.compress && !headers.has("Accept-Encoding")) {
995
+ headers.set("Accept-Encoding", "gzip, deflate, br");
996
+ }
997
+ let { agent } = request2;
998
+ if (typeof agent === "function") {
999
+ agent = agent(parsedURL);
1000
+ }
1001
+ const search = getSearch(parsedURL);
1002
+ const options = {
1003
+ // Overwrite search to retain trailing ? (issue #776)
1004
+ path: parsedURL.pathname + search,
1005
+ // The following options are not expressed in the URL
1006
+ method: request2.method,
1007
+ headers: headers[Symbol.for("nodejs.util.inspect.custom")](),
1008
+ insecureHTTPParser: request2.insecureHTTPParser,
1009
+ agent
1010
+ };
1011
+ return {
1012
+ /** @type {URL} */
1013
+ parsedURL,
1014
+ options
1015
+ };
1016
+ };
1017
+ var AbortError = class extends FetchBaseError {
1018
+ constructor(message, type = "aborted") {
1019
+ super(message, type);
1020
+ }
1021
+ };
1022
+ var supportedSchemas = /* @__PURE__ */ new Set(["data:", "http:", "https:"]);
1023
+ async function fetch(url, options_) {
1024
+ return new Promise((resolve, reject) => {
1025
+ const request2 = new Request(url, options_);
1026
+ const { parsedURL, options } = getNodeRequestOptions(request2);
1027
+ if (!supportedSchemas.has(parsedURL.protocol)) {
1028
+ throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
1029
+ }
1030
+ if (parsedURL.protocol === "data:") {
1031
+ const data = dist_default(request2.url);
1032
+ const response2 = new Response(data, { headers: { "Content-Type": data.typeFull } });
1033
+ resolve(response2);
1034
+ return;
1035
+ }
1036
+ const send = (parsedURL.protocol === "https:" ? import_node_https.default : import_node_http.default).request;
1037
+ const { signal } = request2;
1038
+ let response = null;
1039
+ const abort = () => {
1040
+ const error = new AbortError("The operation was aborted.");
1041
+ reject(error);
1042
+ if (request2.body && request2.body instanceof import_node_stream.default.Readable) {
1043
+ request2.body.destroy(error);
1044
+ }
1045
+ if (!response || !response.body) {
1046
+ return;
1047
+ }
1048
+ response.body.emit("error", error);
1049
+ };
1050
+ if (signal && signal.aborted) {
1051
+ abort();
1052
+ return;
1053
+ }
1054
+ const abortAndFinalize = () => {
1055
+ abort();
1056
+ finalize();
1057
+ };
1058
+ const request_ = send(parsedURL.toString(), options);
1059
+ if (signal) {
1060
+ signal.addEventListener("abort", abortAndFinalize);
1061
+ }
1062
+ const finalize = () => {
1063
+ request_.abort();
1064
+ if (signal) {
1065
+ signal.removeEventListener("abort", abortAndFinalize);
1066
+ }
1067
+ };
1068
+ request_.on("error", (error) => {
1069
+ reject(new FetchError(`request to ${request2.url} failed, reason: ${error.message}`, "system", error));
1070
+ finalize();
1071
+ });
1072
+ fixResponseChunkedTransferBadEnding(request_, (error) => {
1073
+ if (response && response.body) {
1074
+ response.body.destroy(error);
1075
+ }
1076
+ });
1077
+ if (process.version < "v14") {
1078
+ request_.on("socket", (s) => {
1079
+ let endedWithEventsCount;
1080
+ s.prependListener("end", () => {
1081
+ endedWithEventsCount = s._eventsCount;
1082
+ });
1083
+ s.prependListener("close", (hadError) => {
1084
+ if (response && endedWithEventsCount < s._eventsCount && !hadError) {
1085
+ const error = new Error("Premature close");
1086
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
1087
+ response.body.emit("error", error);
1088
+ }
1089
+ });
1090
+ });
1091
+ }
1092
+ request_.on("response", (response_) => {
1093
+ request_.setTimeout(0);
1094
+ const headers = fromRawHeaders(response_.rawHeaders);
1095
+ if (isRedirect(response_.statusCode)) {
1096
+ const location = headers.get("Location");
1097
+ let locationURL = null;
1098
+ try {
1099
+ locationURL = location === null ? null : new URL(location, request2.url);
1100
+ } catch {
1101
+ if (request2.redirect !== "manual") {
1102
+ reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
1103
+ finalize();
1104
+ return;
1105
+ }
1106
+ }
1107
+ switch (request2.redirect) {
1108
+ case "error":
1109
+ reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request2.url}`, "no-redirect"));
1110
+ finalize();
1111
+ return;
1112
+ case "manual":
1113
+ break;
1114
+ case "follow": {
1115
+ if (locationURL === null) {
1116
+ break;
1117
+ }
1118
+ if (request2.counter >= request2.follow) {
1119
+ reject(new FetchError(`maximum redirect reached at: ${request2.url}`, "max-redirect"));
1120
+ finalize();
1121
+ return;
1122
+ }
1123
+ const requestOptions = {
1124
+ headers: new Headers(request2.headers),
1125
+ follow: request2.follow,
1126
+ counter: request2.counter + 1,
1127
+ agent: request2.agent,
1128
+ compress: request2.compress,
1129
+ method: request2.method,
1130
+ body: clone(request2),
1131
+ signal: request2.signal,
1132
+ size: request2.size,
1133
+ referrer: request2.referrer,
1134
+ referrerPolicy: request2.referrerPolicy
1135
+ };
1136
+ if (!isDomainOrSubdomain(request2.url, locationURL) || !isSameProtocol(request2.url, locationURL)) {
1137
+ for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) {
1138
+ requestOptions.headers.delete(name);
1139
+ }
1140
+ }
1141
+ if (response_.statusCode !== 303 && request2.body && options_.body instanceof import_node_stream.default.Readable) {
1142
+ reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
1143
+ finalize();
1144
+ return;
1145
+ }
1146
+ if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request2.method === "POST") {
1147
+ requestOptions.method = "GET";
1148
+ requestOptions.body = void 0;
1149
+ requestOptions.headers.delete("content-length");
1150
+ }
1151
+ const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
1152
+ if (responseReferrerPolicy) {
1153
+ requestOptions.referrerPolicy = responseReferrerPolicy;
1154
+ }
1155
+ resolve(fetch(new Request(locationURL, requestOptions)));
1156
+ finalize();
1157
+ return;
1158
+ }
1159
+ default:
1160
+ return reject(new TypeError(`Redirect option '${request2.redirect}' is not a valid value of RequestRedirect`));
1161
+ }
1162
+ }
1163
+ if (signal) {
1164
+ response_.once("end", () => {
1165
+ signal.removeEventListener("abort", abortAndFinalize);
1166
+ });
1167
+ }
1168
+ let body = (0, import_node_stream.pipeline)(response_, new import_node_stream.PassThrough(), (error) => {
1169
+ if (error) {
1170
+ reject(error);
1171
+ }
1172
+ });
1173
+ if (process.version < "v12.10") {
1174
+ response_.on("aborted", abortAndFinalize);
1175
+ }
1176
+ const responseOptions = {
1177
+ url: request2.url,
1178
+ status: response_.statusCode,
1179
+ statusText: response_.statusMessage,
1180
+ headers,
1181
+ size: request2.size,
1182
+ counter: request2.counter,
1183
+ highWaterMark: request2.highWaterMark
1184
+ };
1185
+ const codings = headers.get("Content-Encoding");
1186
+ if (!request2.compress || request2.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
1187
+ response = new Response(body, responseOptions);
1188
+ resolve(response);
1189
+ return;
1190
+ }
1191
+ const zlibOptions = {
1192
+ flush: import_node_zlib.default.Z_SYNC_FLUSH,
1193
+ finishFlush: import_node_zlib.default.Z_SYNC_FLUSH
1194
+ };
1195
+ if (codings === "gzip" || codings === "x-gzip") {
1196
+ body = (0, import_node_stream.pipeline)(body, import_node_zlib.default.createGunzip(zlibOptions), (error) => {
1197
+ if (error) {
1198
+ reject(error);
1199
+ }
1200
+ });
1201
+ response = new Response(body, responseOptions);
1202
+ resolve(response);
1203
+ return;
1204
+ }
1205
+ if (codings === "deflate" || codings === "x-deflate") {
1206
+ const raw = (0, import_node_stream.pipeline)(response_, new import_node_stream.PassThrough(), (error) => {
1207
+ if (error) {
1208
+ reject(error);
1209
+ }
1210
+ });
1211
+ raw.once("data", (chunk) => {
1212
+ if ((chunk[0] & 15) === 8) {
1213
+ body = (0, import_node_stream.pipeline)(body, import_node_zlib.default.createInflate(), (error) => {
1214
+ if (error) {
1215
+ reject(error);
1216
+ }
1217
+ });
1218
+ } else {
1219
+ body = (0, import_node_stream.pipeline)(body, import_node_zlib.default.createInflateRaw(), (error) => {
1220
+ if (error) {
1221
+ reject(error);
1222
+ }
1223
+ });
1224
+ }
1225
+ response = new Response(body, responseOptions);
1226
+ resolve(response);
1227
+ });
1228
+ raw.once("end", () => {
1229
+ if (!response) {
1230
+ response = new Response(body, responseOptions);
1231
+ resolve(response);
1232
+ }
1233
+ });
1234
+ return;
1235
+ }
1236
+ if (codings === "br") {
1237
+ body = (0, import_node_stream.pipeline)(body, import_node_zlib.default.createBrotliDecompress(), (error) => {
1238
+ if (error) {
1239
+ reject(error);
1240
+ }
1241
+ });
1242
+ response = new Response(body, responseOptions);
1243
+ resolve(response);
1244
+ return;
1245
+ }
1246
+ response = new Response(body, responseOptions);
1247
+ resolve(response);
1248
+ });
1249
+ writeToStream(request_, request2).catch(reject);
1250
+ });
1251
+ }
1252
+ function fixResponseChunkedTransferBadEnding(request2, errorCallback) {
1253
+ const LAST_CHUNK = import_node_buffer.Buffer.from("0\r\n\r\n");
1254
+ let isChunkedTransfer = false;
1255
+ let properLastChunkReceived = false;
1256
+ let previousChunk;
1257
+ request2.on("response", (response) => {
1258
+ const { headers } = response;
1259
+ isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
1260
+ });
1261
+ request2.on("socket", (socket) => {
1262
+ const onSocketClose = () => {
1263
+ if (isChunkedTransfer && !properLastChunkReceived) {
1264
+ const error = new Error("Premature close");
1265
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
1266
+ errorCallback(error);
1267
+ }
1268
+ };
1269
+ const onData = (buf) => {
1270
+ properLastChunkReceived = import_node_buffer.Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0;
1271
+ if (!properLastChunkReceived && previousChunk) {
1272
+ properLastChunkReceived = import_node_buffer.Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && import_node_buffer.Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0;
1273
+ }
1274
+ previousChunk = buf;
1275
+ };
1276
+ socket.prependListener("close", onSocketClose);
1277
+ socket.on("data", onData);
1278
+ request2.on("close", () => {
1279
+ socket.removeListener("close", onSocketClose);
1280
+ socket.removeListener("data", onData);
1281
+ });
1282
+ });
1283
+ }
1284
+ var ErrorKind = /* @__PURE__ */ ((ErrorKind2) => {
1285
+ ErrorKind2["JS_ERROR"] = "JS_ERROR";
1286
+ ErrorKind2["RUST_PANIC"] = "RUST_PANIC";
1287
+ return ErrorKind2;
1288
+ })(ErrorKind || {});
1289
+ async function uploadZip(zip, url) {
1290
+ return await fetch(url, {
1291
+ method: "PUT",
1292
+ agent: (0, import_fetch_engine.getProxyAgent)(url),
1293
+ headers: {
1294
+ "Content-Length": String(zip.byteLength)
1295
+ },
1296
+ body: zip
1297
+ });
1298
+ }
1299
+ async function createErrorReport(data) {
1300
+ const result = await request(
1301
+ `mutation ($data: CreateErrorReportInput!) {
1302
+ createErrorReport(data: $data)
1303
+ }`,
1304
+ { data }
1305
+ );
1306
+ return result.createErrorReport;
1307
+ }
1308
+ async function makeErrorReportCompleted(signedUrl) {
1309
+ const result = await request(
1310
+ `mutation ($signedUrl: String!) {
1311
+ markErrorReportCompleted(signedUrl: $signedUrl)
1312
+ }`,
1313
+ { signedUrl }
1314
+ );
1315
+ return result.markErrorReportCompleted;
1316
+ }
1317
+ async function request(query, variables) {
1318
+ const url = "https://error-reports.prisma.sh/";
1319
+ const body = JSON.stringify({
1320
+ query,
1321
+ variables
1322
+ });
1323
+ return await fetch(url, {
1324
+ method: "POST",
1325
+ agent: (0, import_fetch_engine.getProxyAgent)(url),
1326
+ body,
1327
+ headers: {
1328
+ Accept: "application/json",
1329
+ "Content-Type": "application/json"
1330
+ }
1331
+ }).then((response) => {
1332
+ if (!response.ok) {
1333
+ throw new Error(`Error during request: ${response.status} ${response.statusText} - Query: ${query}`);
1334
+ }
1335
+ return response.json();
1336
+ }).then((responseAsJson) => {
1337
+ if (responseAsJson.errors) {
1338
+ throw new Error(JSON.stringify(responseAsJson.errors));
1339
+ }
1340
+ return responseAsJson.data;
1341
+ });
1342
+ }