@multiplatform.one/frappe 6.0.4 → 6.3.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 (792) hide show
  1. package/README.md +38 -12
  2. package/dist/cjs/auth.cjs +1 -1
  3. package/dist/cjs/auth.native.js.map +1 -1
  4. package/dist/cjs/call.cjs +1 -1
  5. package/dist/cjs/call.native.js.map +1 -1
  6. package/dist/cjs/collection.cjs +18 -4
  7. package/dist/cjs/collection.native.js +18 -4
  8. package/dist/cjs/collection.native.js.map +1 -1
  9. package/dist/cjs/core/http.cjs +92 -9
  10. package/dist/cjs/core/http.native.js +96 -7
  11. package/dist/cjs/core/http.native.js.map +1 -1
  12. package/dist/cjs/db.cjs +7 -7
  13. package/dist/cjs/db.native.js +4 -4
  14. package/dist/cjs/db.native.js.map +1 -1
  15. package/dist/cjs/doctype.cjs +97 -39
  16. package/dist/cjs/doctype.native.js +116 -46
  17. package/dist/cjs/doctype.native.js.map +1 -1
  18. package/dist/cjs/file.cjs +1 -1
  19. package/dist/cjs/file.native.js.map +1 -1
  20. package/dist/cjs/fixtureDb.cjs +3 -2
  21. package/dist/cjs/fixtureDb.native.js +2 -1
  22. package/dist/cjs/fixtureDb.native.js.map +1 -1
  23. package/dist/cjs/frappeApp.cjs +15 -14
  24. package/dist/cjs/frappeApp.native.js +16 -14
  25. package/dist/cjs/frappeApp.native.js.map +1 -1
  26. package/dist/cjs/frappeReact.cjs +198 -18
  27. package/dist/cjs/frappeReact.native.js +241 -18
  28. package/dist/cjs/frappeReact.native.js.map +1 -1
  29. package/dist/cjs/index.cjs +9 -4
  30. package/dist/cjs/index.native.js +9 -4
  31. package/dist/cjs/index.native.js.map +1 -1
  32. package/dist/cjs/pacer.cjs +2 -2
  33. package/dist/cjs/pacer.native.js +2 -2
  34. package/dist/cjs/pacer.native.js.map +1 -1
  35. package/dist/cjs/realtime.cjs +186 -46
  36. package/dist/cjs/realtime.native.js +268 -48
  37. package/dist/cjs/realtime.native.js.map +1 -1
  38. package/dist/cjs/sync/backfill.cjs +32 -27
  39. package/dist/cjs/sync/backfill.native.js +49 -43
  40. package/dist/cjs/sync/backfill.native.js.map +1 -1
  41. package/dist/cjs/sync/index.cjs +90 -24
  42. package/dist/cjs/sync/index.native.js +112 -10
  43. package/dist/cjs/sync/index.native.js.map +1 -1
  44. package/dist/cjs/sync/merge.cjs +0 -3
  45. package/dist/cjs/sync/merge.native.js +0 -3
  46. package/dist/cjs/sync/merge.native.js.map +1 -1
  47. package/dist/cjs/sync/mutationEngine.cjs +25 -19
  48. package/dist/cjs/sync/mutationEngine.native.js +16 -13
  49. package/dist/cjs/sync/mutationEngine.native.js.map +1 -1
  50. package/dist/cjs/sync/mutationJournal.cjs +9 -4
  51. package/dist/cjs/sync/mutationJournal.native.js +7 -4
  52. package/dist/cjs/sync/mutationJournal.native.js.map +1 -1
  53. package/dist/cjs/sync/normalizedCache.cjs +7 -3
  54. package/dist/cjs/sync/normalizedCache.native.js +7 -2
  55. package/dist/cjs/sync/normalizedCache.native.js.map +1 -1
  56. package/dist/cjs/sync/persistence.cjs +63 -31
  57. package/dist/cjs/sync/persistence.native.js +120 -63
  58. package/dist/cjs/sync/persistence.native.js.map +1 -1
  59. package/dist/cjs/sync/realtime.cjs +124 -13
  60. package/dist/cjs/sync/realtime.native.js +163 -20
  61. package/dist/cjs/sync/realtime.native.js.map +1 -1
  62. package/dist/cjs/sync/rehydration.cjs +16 -10
  63. package/dist/cjs/sync/rehydration.native.js +16 -14
  64. package/dist/cjs/sync/rehydration.native.js.map +1 -1
  65. package/dist/cjs/sync/storage.cjs +3 -3
  66. package/dist/cjs/sync/storage.native.js +1 -1
  67. package/dist/cjs/sync/storage.native.js.map +1 -1
  68. package/dist/cjs/sync/subscriptionManager.cjs +255 -65
  69. package/dist/cjs/sync/subscriptionManager.native.js +330 -93
  70. package/dist/cjs/sync/subscriptionManager.native.js.map +1 -1
  71. package/dist/cjs/sync/types.cjs +2 -0
  72. package/dist/cjs/sync/types.native.js +2 -0
  73. package/dist/cjs/sync/types.native.js.map +1 -1
  74. package/dist/cjs/sync/virtualPageManager.cjs +9 -9
  75. package/dist/cjs/sync/virtualPageManager.native.js +5 -9
  76. package/dist/cjs/sync/virtualPageManager.native.js.map +1 -1
  77. package/dist/cjs/useLiveQuery.cjs +52 -0
  78. package/dist/cjs/useLiveQuery.native.js +59 -0
  79. package/dist/cjs/useLiveQuery.native.js.map +1 -0
  80. package/dist/cjs/util.cjs +11 -2
  81. package/dist/cjs/util.native.js +16 -2
  82. package/dist/cjs/util.native.js.map +1 -1
  83. package/dist/esm/auth.mjs +1 -1
  84. package/dist/esm/auth.mjs.map +1 -1
  85. package/dist/esm/auth.native.js.map +1 -1
  86. package/dist/esm/call.mjs +1 -1
  87. package/dist/esm/call.mjs.map +1 -1
  88. package/dist/esm/call.native.js.map +1 -1
  89. package/dist/esm/collection.mjs +18 -4
  90. package/dist/esm/collection.mjs.map +1 -1
  91. package/dist/esm/collection.native.js +18 -4
  92. package/dist/esm/collection.native.js.map +1 -1
  93. package/dist/esm/core/http.mjs +93 -10
  94. package/dist/esm/core/http.mjs.map +1 -1
  95. package/dist/esm/core/http.native.js +97 -8
  96. package/dist/esm/core/http.native.js.map +1 -1
  97. package/dist/esm/db.mjs +7 -7
  98. package/dist/esm/db.mjs.map +1 -1
  99. package/dist/esm/db.native.js +4 -4
  100. package/dist/esm/db.native.js.map +1 -1
  101. package/dist/esm/doctype.mjs +96 -39
  102. package/dist/esm/doctype.mjs.map +1 -1
  103. package/dist/esm/doctype.native.js +115 -46
  104. package/dist/esm/doctype.native.js.map +1 -1
  105. package/dist/esm/file.mjs +1 -1
  106. package/dist/esm/file.mjs.map +1 -1
  107. package/dist/esm/file.native.js.map +1 -1
  108. package/dist/esm/fixtureDb.mjs +3 -2
  109. package/dist/esm/fixtureDb.mjs.map +1 -1
  110. package/dist/esm/fixtureDb.native.js +2 -1
  111. package/dist/esm/fixtureDb.native.js.map +1 -1
  112. package/dist/esm/frappeApp.mjs +15 -14
  113. package/dist/esm/frappeApp.mjs.map +1 -1
  114. package/dist/esm/frappeApp.native.js +16 -14
  115. package/dist/esm/frappeApp.native.js.map +1 -1
  116. package/dist/esm/frappeReact.mjs +197 -19
  117. package/dist/esm/frappeReact.mjs.map +1 -1
  118. package/dist/esm/frappeReact.native.js +240 -19
  119. package/dist/esm/frappeReact.native.js.map +1 -1
  120. package/dist/esm/index.mjs +5 -4
  121. package/dist/esm/index.mjs.map +1 -1
  122. package/dist/esm/index.native.js +5 -4
  123. package/dist/esm/index.native.js.map +1 -1
  124. package/dist/esm/pacer.mjs +1 -1
  125. package/dist/esm/pacer.native.js +1 -1
  126. package/dist/esm/realtime.mjs +187 -47
  127. package/dist/esm/realtime.mjs.map +1 -1
  128. package/dist/esm/realtime.native.js +269 -49
  129. package/dist/esm/realtime.native.js.map +1 -1
  130. package/dist/esm/sync/backfill.mjs +32 -27
  131. package/dist/esm/sync/backfill.mjs.map +1 -1
  132. package/dist/esm/sync/backfill.native.js +49 -43
  133. package/dist/esm/sync/backfill.native.js.map +1 -1
  134. package/dist/esm/sync/index.mjs +90 -24
  135. package/dist/esm/sync/index.mjs.map +1 -1
  136. package/dist/esm/sync/index.native.js +112 -10
  137. package/dist/esm/sync/index.native.js.map +1 -1
  138. package/dist/esm/sync/merge.mjs +1 -1
  139. package/dist/esm/sync/merge.mjs.map +1 -1
  140. package/dist/esm/sync/merge.native.js +1 -1
  141. package/dist/esm/sync/merge.native.js.map +1 -1
  142. package/dist/esm/sync/mutationEngine.mjs +25 -19
  143. package/dist/esm/sync/mutationEngine.mjs.map +1 -1
  144. package/dist/esm/sync/mutationEngine.native.js +16 -13
  145. package/dist/esm/sync/mutationEngine.native.js.map +1 -1
  146. package/dist/esm/sync/mutationJournal.mjs +9 -4
  147. package/dist/esm/sync/mutationJournal.mjs.map +1 -1
  148. package/dist/esm/sync/mutationJournal.native.js +7 -4
  149. package/dist/esm/sync/mutationJournal.native.js.map +1 -1
  150. package/dist/esm/sync/normalizedCache.mjs +7 -3
  151. package/dist/esm/sync/normalizedCache.mjs.map +1 -1
  152. package/dist/esm/sync/normalizedCache.native.js +7 -2
  153. package/dist/esm/sync/normalizedCache.native.js.map +1 -1
  154. package/dist/esm/sync/persistence.mjs +64 -32
  155. package/dist/esm/sync/persistence.mjs.map +1 -1
  156. package/dist/esm/sync/persistence.native.js +121 -64
  157. package/dist/esm/sync/persistence.native.js.map +1 -1
  158. package/dist/esm/sync/realtime.mjs +124 -13
  159. package/dist/esm/sync/realtime.mjs.map +1 -1
  160. package/dist/esm/sync/realtime.native.js +163 -20
  161. package/dist/esm/sync/realtime.native.js.map +1 -1
  162. package/dist/esm/sync/rehydration.mjs +16 -10
  163. package/dist/esm/sync/rehydration.mjs.map +1 -1
  164. package/dist/esm/sync/rehydration.native.js +16 -14
  165. package/dist/esm/sync/rehydration.native.js.map +1 -1
  166. package/dist/esm/sync/storage.mjs +3 -3
  167. package/dist/esm/sync/storage.mjs.map +1 -1
  168. package/dist/esm/sync/storage.native.js +1 -1
  169. package/dist/esm/sync/storage.native.js.map +1 -1
  170. package/dist/esm/sync/subscriptionManager.mjs +255 -65
  171. package/dist/esm/sync/subscriptionManager.mjs.map +1 -1
  172. package/dist/esm/sync/subscriptionManager.native.js +330 -93
  173. package/dist/esm/sync/subscriptionManager.native.js.map +1 -1
  174. package/dist/esm/sync/types.mjs +2 -0
  175. package/dist/esm/sync/types.mjs.map +1 -1
  176. package/dist/esm/sync/types.native.js +2 -0
  177. package/dist/esm/sync/types.native.js.map +1 -1
  178. package/dist/esm/sync/virtualPageManager.mjs +9 -9
  179. package/dist/esm/sync/virtualPageManager.mjs.map +1 -1
  180. package/dist/esm/sync/virtualPageManager.native.js +5 -9
  181. package/dist/esm/sync/virtualPageManager.native.js.map +1 -1
  182. package/dist/esm/useLiveQuery.mjs +26 -0
  183. package/dist/esm/useLiveQuery.mjs.map +1 -0
  184. package/dist/esm/useLiveQuery.native.js +30 -0
  185. package/dist/esm/useLiveQuery.native.js.map +1 -0
  186. package/dist/esm/util.mjs +11 -3
  187. package/dist/esm/util.mjs.map +1 -1
  188. package/dist/esm/util.native.js +16 -3
  189. package/dist/esm/util.native.js.map +1 -1
  190. package/dist/jsx/auth.mjs +1 -1
  191. package/dist/jsx/auth.mjs.map +1 -1
  192. package/dist/jsx/auth.native.js.map +1 -1
  193. package/dist/jsx/call.mjs +1 -1
  194. package/dist/jsx/call.mjs.map +1 -1
  195. package/dist/jsx/call.native.js.map +1 -1
  196. package/dist/jsx/collection.mjs +18 -4
  197. package/dist/jsx/collection.mjs.map +1 -1
  198. package/dist/jsx/collection.native.js +18 -4
  199. package/dist/jsx/collection.native.js.map +1 -1
  200. package/dist/jsx/core/http.mjs +93 -10
  201. package/dist/jsx/core/http.mjs.map +1 -1
  202. package/dist/jsx/core/http.native.js +96 -7
  203. package/dist/jsx/core/http.native.js.map +1 -1
  204. package/dist/jsx/db.mjs +7 -7
  205. package/dist/jsx/db.mjs.map +1 -1
  206. package/dist/jsx/db.native.js +4 -4
  207. package/dist/jsx/db.native.js.map +1 -1
  208. package/dist/jsx/doctype.mjs +96 -39
  209. package/dist/jsx/doctype.mjs.map +1 -1
  210. package/dist/jsx/doctype.native.js +116 -46
  211. package/dist/jsx/doctype.native.js.map +1 -1
  212. package/dist/jsx/file.mjs +1 -1
  213. package/dist/jsx/file.mjs.map +1 -1
  214. package/dist/jsx/file.native.js.map +1 -1
  215. package/dist/jsx/fixtureDb.mjs +3 -2
  216. package/dist/jsx/fixtureDb.mjs.map +1 -1
  217. package/dist/jsx/fixtureDb.native.js +2 -1
  218. package/dist/jsx/fixtureDb.native.js.map +1 -1
  219. package/dist/jsx/frappeApp.mjs +15 -14
  220. package/dist/jsx/frappeApp.mjs.map +1 -1
  221. package/dist/jsx/frappeApp.native.js +16 -14
  222. package/dist/jsx/frappeApp.native.js.map +1 -1
  223. package/dist/jsx/frappeReact.mjs +197 -19
  224. package/dist/jsx/frappeReact.mjs.map +1 -1
  225. package/dist/jsx/frappeReact.native.js +241 -18
  226. package/dist/jsx/frappeReact.native.js.map +1 -1
  227. package/dist/jsx/index.js +5 -4
  228. package/dist/jsx/index.js.map +1 -1
  229. package/dist/jsx/index.mjs +5 -4
  230. package/dist/jsx/index.mjs.map +1 -1
  231. package/dist/jsx/index.native.js +9 -4
  232. package/dist/jsx/index.native.js.map +1 -1
  233. package/dist/jsx/pacer.mjs +1 -1
  234. package/dist/jsx/pacer.native.js +2 -2
  235. package/dist/jsx/pacer.native.js.map +1 -1
  236. package/dist/jsx/realtime.mjs +187 -47
  237. package/dist/jsx/realtime.mjs.map +1 -1
  238. package/dist/jsx/realtime.native.js +268 -48
  239. package/dist/jsx/realtime.native.js.map +1 -1
  240. package/dist/jsx/sync/backfill.mjs +32 -27
  241. package/dist/jsx/sync/backfill.mjs.map +1 -1
  242. package/dist/jsx/sync/backfill.native.js +49 -43
  243. package/dist/jsx/sync/backfill.native.js.map +1 -1
  244. package/dist/jsx/sync/index.mjs +90 -24
  245. package/dist/jsx/sync/index.mjs.map +1 -1
  246. package/dist/jsx/sync/index.native.js +112 -10
  247. package/dist/jsx/sync/index.native.js.map +1 -1
  248. package/dist/jsx/sync/merge.mjs +1 -1
  249. package/dist/jsx/sync/merge.mjs.map +1 -1
  250. package/dist/jsx/sync/merge.native.js +0 -3
  251. package/dist/jsx/sync/merge.native.js.map +1 -1
  252. package/dist/jsx/sync/mutationEngine.mjs +25 -19
  253. package/dist/jsx/sync/mutationEngine.mjs.map +1 -1
  254. package/dist/jsx/sync/mutationEngine.native.js +16 -13
  255. package/dist/jsx/sync/mutationEngine.native.js.map +1 -1
  256. package/dist/jsx/sync/mutationJournal.mjs +9 -4
  257. package/dist/jsx/sync/mutationJournal.mjs.map +1 -1
  258. package/dist/jsx/sync/mutationJournal.native.js +7 -4
  259. package/dist/jsx/sync/mutationJournal.native.js.map +1 -1
  260. package/dist/jsx/sync/normalizedCache.mjs +7 -3
  261. package/dist/jsx/sync/normalizedCache.mjs.map +1 -1
  262. package/dist/jsx/sync/normalizedCache.native.js +7 -2
  263. package/dist/jsx/sync/normalizedCache.native.js.map +1 -1
  264. package/dist/jsx/sync/persistence.mjs +64 -32
  265. package/dist/jsx/sync/persistence.mjs.map +1 -1
  266. package/dist/jsx/sync/persistence.native.js +120 -63
  267. package/dist/jsx/sync/persistence.native.js.map +1 -1
  268. package/dist/jsx/sync/realtime.mjs +124 -13
  269. package/dist/jsx/sync/realtime.mjs.map +1 -1
  270. package/dist/jsx/sync/realtime.native.js +163 -20
  271. package/dist/jsx/sync/realtime.native.js.map +1 -1
  272. package/dist/jsx/sync/rehydration.mjs +16 -10
  273. package/dist/jsx/sync/rehydration.mjs.map +1 -1
  274. package/dist/jsx/sync/rehydration.native.js +16 -14
  275. package/dist/jsx/sync/rehydration.native.js.map +1 -1
  276. package/dist/jsx/sync/storage.mjs +3 -3
  277. package/dist/jsx/sync/storage.mjs.map +1 -1
  278. package/dist/jsx/sync/storage.native.js +1 -1
  279. package/dist/jsx/sync/storage.native.js.map +1 -1
  280. package/dist/jsx/sync/subscriptionManager.mjs +255 -65
  281. package/dist/jsx/sync/subscriptionManager.mjs.map +1 -1
  282. package/dist/jsx/sync/subscriptionManager.native.js +330 -93
  283. package/dist/jsx/sync/subscriptionManager.native.js.map +1 -1
  284. package/dist/jsx/sync/types.mjs +2 -0
  285. package/dist/jsx/sync/types.mjs.map +1 -1
  286. package/dist/jsx/sync/types.native.js +2 -0
  287. package/dist/jsx/sync/types.native.js.map +1 -1
  288. package/dist/jsx/sync/virtualPageManager.mjs +9 -9
  289. package/dist/jsx/sync/virtualPageManager.mjs.map +1 -1
  290. package/dist/jsx/sync/virtualPageManager.native.js +5 -9
  291. package/dist/jsx/sync/virtualPageManager.native.js.map +1 -1
  292. package/dist/jsx/useLiveQuery.mjs +26 -0
  293. package/dist/jsx/useLiveQuery.mjs.map +1 -0
  294. package/dist/jsx/useLiveQuery.native.js +59 -0
  295. package/dist/jsx/useLiveQuery.native.js.map +1 -0
  296. package/dist/jsx/util.mjs +11 -3
  297. package/dist/jsx/util.mjs.map +1 -1
  298. package/dist/jsx/util.native.js +16 -2
  299. package/dist/jsx/util.native.js.map +1 -1
  300. package/package.json +20 -17
  301. package/src/auth.ts +5 -1
  302. package/src/call.ts +5 -1
  303. package/src/collection.spec.ts +55 -0
  304. package/src/collection.ts +33 -4
  305. package/src/core/http.spec.ts +66 -0
  306. package/src/core/http.ts +115 -9
  307. package/src/core/httpNative.spec.ts +234 -0
  308. package/src/core/types.ts +2 -0
  309. package/src/db.spec.ts +91 -51
  310. package/src/db.ts +27 -8
  311. package/src/doctype.spec.ts +247 -39
  312. package/src/doctype.ts +203 -53
  313. package/src/file.ts +5 -1
  314. package/src/fixtureDb.ts +13 -2
  315. package/src/frappeApp.ts +18 -19
  316. package/src/frappeReact.spec.ts +565 -1
  317. package/src/frappeReact.ts +446 -38
  318. package/src/frappeReactLiveQueryGc.spec.ts +320 -0
  319. package/src/frappeReactNative.spec.ts +65 -0
  320. package/src/index.ts +10 -9
  321. package/src/pacer.ts +2 -2
  322. package/src/realtime.spec.ts +464 -20
  323. package/src/realtime.ts +284 -46
  324. package/src/sync/backfill.spec.ts +43 -0
  325. package/src/sync/backfill.ts +59 -39
  326. package/src/sync/debug.spec.ts +36 -0
  327. package/src/sync/filterValidation.spec.ts +197 -0
  328. package/src/sync/index.ts +98 -7
  329. package/src/sync/merge.ts +3 -3
  330. package/src/sync/mutationEngine.spec.ts +36 -4
  331. package/src/sync/mutationEngine.ts +30 -11
  332. package/src/sync/mutationJournal.ts +18 -4
  333. package/src/sync/normalizedCache.spec.ts +102 -0
  334. package/src/sync/normalizedCache.ts +19 -3
  335. package/src/sync/offlineRestore.spec.ts +423 -0
  336. package/src/sync/persistence.spec.ts +39 -7
  337. package/src/sync/persistence.ts +90 -18
  338. package/src/sync/persistenceGjs.spec.ts +143 -0
  339. package/src/sync/persistenceNative.spec.ts +139 -0
  340. package/src/sync/realtime.spec.ts +18 -1
  341. package/src/sync/realtime.ts +161 -13
  342. package/src/sync/rehydration.ts +23 -5
  343. package/src/sync/storage.ts +5 -4
  344. package/src/sync/subscriptionManager.spec.ts +94 -0
  345. package/src/sync/subscriptionManager.ts +304 -82
  346. package/src/sync/syncModule.spec.ts +137 -0
  347. package/src/sync/types.ts +39 -0
  348. package/src/sync/virtualPageManager.ts +8 -4
  349. package/src/useLiveQuery.ts +58 -0
  350. package/src/util.spec.ts +35 -4
  351. package/src/util.ts +37 -2
  352. package/types/auth.d.ts +13 -0
  353. package/types/auth.d.ts.map +1 -0
  354. package/types/call.d.ts +10 -0
  355. package/types/call.d.ts.map +1 -0
  356. package/types/collection.d.ts +127 -0
  357. package/types/collection.d.ts.map +1 -0
  358. package/types/common/types.d.ts +35 -0
  359. package/types/common/types.d.ts.map +1 -0
  360. package/types/core/http.d.ts +86 -0
  361. package/types/core/http.d.ts.map +1 -0
  362. package/types/core/types.d.ts +74 -0
  363. package/types/core/types.d.ts.map +1 -0
  364. package/types/core/wire.d.ts +405 -0
  365. package/types/core/wire.d.ts.map +1 -0
  366. package/types/db.d.ts +244 -0
  367. package/types/db.d.ts.map +1 -0
  368. package/types/devtools/FrappeDevtoolsPanel.d.ts +7 -0
  369. package/types/devtools/FrappeDevtoolsPanel.d.ts.map +1 -0
  370. package/types/devtools/index.d.ts +4 -0
  371. package/types/devtools/index.d.ts.map +1 -0
  372. package/types/devtools/plugin.d.ts +9 -0
  373. package/types/devtools/plugin.d.ts.map +1 -0
  374. package/types/devtools/theme.d.ts +15 -0
  375. package/types/devtools/theme.d.ts.map +1 -0
  376. package/types/doctype.d.ts +256 -0
  377. package/types/doctype.d.ts.map +1 -0
  378. package/types/file.d.ts +15 -0
  379. package/types/file.d.ts.map +1 -0
  380. package/types/fixtureDb.d.ts +76 -0
  381. package/types/fixtureDb.d.ts.map +1 -0
  382. package/types/fixtures.d.ts +55 -0
  383. package/types/fixtures.d.ts.map +1 -0
  384. package/types/frappeApp.d.ts +45 -0
  385. package/types/frappeApp.d.ts.map +1 -0
  386. package/types/frappeReact.d.ts +270 -0
  387. package/types/frappeReact.d.ts.map +1 -0
  388. package/types/index.d.ts +44 -0
  389. package/types/index.d.ts.map +1 -0
  390. package/types/optimistic.d.ts +38 -0
  391. package/types/optimistic.d.ts.map +1 -0
  392. package/types/pacer.d.ts +193 -0
  393. package/types/pacer.d.ts.map +1 -0
  394. package/types/plugin/index.d.ts +11 -0
  395. package/types/plugin/index.d.ts.map +1 -0
  396. package/types/realtime.d.ts +121 -0
  397. package/types/realtime.d.ts.map +1 -0
  398. package/types/sync/backfill.d.ts +60 -0
  399. package/types/sync/backfill.d.ts.map +1 -0
  400. package/types/sync/filters.d.ts +101 -0
  401. package/types/sync/filters.d.ts.map +1 -0
  402. package/types/sync/index.d.ts +181 -0
  403. package/types/sync/index.d.ts.map +1 -0
  404. package/types/sync/merge.d.ts +59 -0
  405. package/types/sync/merge.d.ts.map +1 -0
  406. package/types/sync/mutationEngine.d.ts +117 -0
  407. package/types/sync/mutationEngine.d.ts.map +1 -0
  408. package/types/sync/mutationJournal.d.ts +60 -0
  409. package/types/sync/mutationJournal.d.ts.map +1 -0
  410. package/types/sync/normalizedCache.d.ts +59 -0
  411. package/types/sync/normalizedCache.d.ts.map +1 -0
  412. package/types/sync/persistence.d.ts +185 -0
  413. package/types/sync/persistence.d.ts.map +1 -0
  414. package/types/sync/realtime.d.ts +121 -0
  415. package/types/sync/realtime.d.ts.map +1 -0
  416. package/types/sync/rehydration.d.ts +109 -0
  417. package/types/sync/rehydration.d.ts.map +1 -0
  418. package/types/sync/storage.d.ts +65 -0
  419. package/types/sync/storage.d.ts.map +1 -0
  420. package/types/sync/subscriptionManager.d.ts +161 -0
  421. package/types/sync/subscriptionManager.d.ts.map +1 -0
  422. package/types/sync/types.d.ts +435 -0
  423. package/types/sync/types.d.ts.map +1 -0
  424. package/types/sync/virtualPageManager.d.ts +190 -0
  425. package/types/sync/virtualPageManager.d.ts.map +1 -0
  426. package/types/useLiveQuery.d.ts +16 -0
  427. package/types/useLiveQuery.d.ts.map +1 -0
  428. package/types/util.d.ts +24 -0
  429. package/types/util.d.ts.map +1 -0
  430. package/dist/cjs/auth.spec.cjs +0 -322
  431. package/dist/cjs/auth.spec.native.js +0 -329
  432. package/dist/cjs/auth.spec.native.js.map +0 -1
  433. package/dist/cjs/call.spec.cjs +0 -427
  434. package/dist/cjs/call.spec.native.js +0 -430
  435. package/dist/cjs/call.spec.native.js.map +0 -1
  436. package/dist/cjs/collection.spec.cjs +0 -186
  437. package/dist/cjs/collection.spec.native.js +0 -216
  438. package/dist/cjs/collection.spec.native.js.map +0 -1
  439. package/dist/cjs/common/types.spec.cjs +0 -266
  440. package/dist/cjs/common/types.spec.native.js +0 -271
  441. package/dist/cjs/common/types.spec.native.js.map +0 -1
  442. package/dist/cjs/core/http.spec.cjs +0 -1259
  443. package/dist/cjs/core/http.spec.native.js +0 -1401
  444. package/dist/cjs/core/http.spec.native.js.map +0 -1
  445. package/dist/cjs/core/wire.spec.cjs +0 -478
  446. package/dist/cjs/core/wire.spec.native.js +0 -482
  447. package/dist/cjs/core/wire.spec.native.js.map +0 -1
  448. package/dist/cjs/db.spec.cjs +0 -862
  449. package/dist/cjs/db.spec.native.js +0 -865
  450. package/dist/cjs/db.spec.native.js.map +0 -1
  451. package/dist/cjs/doctype.spec.cjs +0 -460
  452. package/dist/cjs/doctype.spec.native.js +0 -538
  453. package/dist/cjs/doctype.spec.native.js.map +0 -1
  454. package/dist/cjs/file.spec.cjs +0 -315
  455. package/dist/cjs/file.spec.native.js +0 -342
  456. package/dist/cjs/file.spec.native.js.map +0 -1
  457. package/dist/cjs/frappeApp.spec.cjs +0 -306
  458. package/dist/cjs/frappeApp.spec.native.js +0 -308
  459. package/dist/cjs/frappeApp.spec.native.js.map +0 -1
  460. package/dist/cjs/frappeReact.spec.cjs +0 -531
  461. package/dist/cjs/frappeReact.spec.native.js +0 -670
  462. package/dist/cjs/frappeReact.spec.native.js.map +0 -1
  463. package/dist/cjs/optimistic.spec.cjs +0 -11
  464. package/dist/cjs/optimistic.spec.native.js +0 -19
  465. package/dist/cjs/optimistic.spec.native.js.map +0 -1
  466. package/dist/cjs/pacer.spec.cjs +0 -470
  467. package/dist/cjs/pacer.spec.native.js +0 -537
  468. package/dist/cjs/pacer.spec.native.js.map +0 -1
  469. package/dist/cjs/realtime.spec.cjs +0 -326
  470. package/dist/cjs/realtime.spec.native.js +0 -392
  471. package/dist/cjs/realtime.spec.native.js.map +0 -1
  472. package/dist/cjs/sync/backfill.spec.cjs +0 -586
  473. package/dist/cjs/sync/backfill.spec.native.js +0 -712
  474. package/dist/cjs/sync/backfill.spec.native.js.map +0 -1
  475. package/dist/cjs/sync/debug.spec.cjs +0 -125
  476. package/dist/cjs/sync/debug.spec.native.js +0 -133
  477. package/dist/cjs/sync/debug.spec.native.js.map +0 -1
  478. package/dist/cjs/sync/filters.spec.cjs +0 -168
  479. package/dist/cjs/sync/filters.spec.native.js +0 -173
  480. package/dist/cjs/sync/filters.spec.native.js.map +0 -1
  481. package/dist/cjs/sync/merge.spec.cjs +0 -908
  482. package/dist/cjs/sync/merge.spec.native.js +0 -937
  483. package/dist/cjs/sync/merge.spec.native.js.map +0 -1
  484. package/dist/cjs/sync/multiOrderBy.spec.cjs +0 -165
  485. package/dist/cjs/sync/multiOrderBy.spec.native.js +0 -229
  486. package/dist/cjs/sync/multiOrderBy.spec.native.js.map +0 -1
  487. package/dist/cjs/sync/mutationEngine.spec.cjs +0 -1158
  488. package/dist/cjs/sync/mutationEngine.spec.native.js +0 -1173
  489. package/dist/cjs/sync/mutationEngine.spec.native.js.map +0 -1
  490. package/dist/cjs/sync/mutationJournal.spec.cjs +0 -330
  491. package/dist/cjs/sync/mutationJournal.spec.native.js +0 -333
  492. package/dist/cjs/sync/mutationJournal.spec.native.js.map +0 -1
  493. package/dist/cjs/sync/mutations.spec.cjs +0 -327
  494. package/dist/cjs/sync/mutations.spec.native.js +0 -330
  495. package/dist/cjs/sync/mutations.spec.native.js.map +0 -1
  496. package/dist/cjs/sync/normalizedCache.spec.cjs +0 -302
  497. package/dist/cjs/sync/normalizedCache.spec.native.js +0 -311
  498. package/dist/cjs/sync/normalizedCache.spec.native.js.map +0 -1
  499. package/dist/cjs/sync/persistence.spec.cjs +0 -562
  500. package/dist/cjs/sync/persistence.spec.native.js +0 -572
  501. package/dist/cjs/sync/persistence.spec.native.js.map +0 -1
  502. package/dist/cjs/sync/realtime.spec.cjs +0 -499
  503. package/dist/cjs/sync/realtime.spec.native.js +0 -512
  504. package/dist/cjs/sync/realtime.spec.native.js.map +0 -1
  505. package/dist/cjs/sync/rehydration.spec.cjs +0 -731
  506. package/dist/cjs/sync/rehydration.spec.native.js +0 -736
  507. package/dist/cjs/sync/rehydration.spec.native.js.map +0 -1
  508. package/dist/cjs/sync/storage.spec.cjs +0 -446
  509. package/dist/cjs/sync/storage.spec.native.js +0 -470
  510. package/dist/cjs/sync/storage.spec.native.js.map +0 -1
  511. package/dist/cjs/sync/subscriptionManager.spec.cjs +0 -1102
  512. package/dist/cjs/sync/subscriptionManager.spec.native.js +0 -1136
  513. package/dist/cjs/sync/subscriptionManager.spec.native.js.map +0 -1
  514. package/dist/cjs/sync/subscriptions.spec.cjs +0 -937
  515. package/dist/cjs/sync/subscriptions.spec.native.js +0 -969
  516. package/dist/cjs/sync/subscriptions.spec.native.js.map +0 -1
  517. package/dist/cjs/sync/syncModule.spec.cjs +0 -206
  518. package/dist/cjs/sync/syncModule.spec.native.js +0 -222
  519. package/dist/cjs/sync/syncModule.spec.native.js.map +0 -1
  520. package/dist/cjs/sync/types.spec.cjs +0 -246
  521. package/dist/cjs/sync/types.spec.native.js +0 -256
  522. package/dist/cjs/sync/types.spec.native.js.map +0 -1
  523. package/dist/cjs/sync/virtualPageManager.spec.cjs +0 -801
  524. package/dist/cjs/sync/virtualPageManager.spec.native.js +0 -873
  525. package/dist/cjs/sync/virtualPageManager.spec.native.js.map +0 -1
  526. package/dist/cjs/util.spec.cjs +0 -43
  527. package/dist/cjs/util.spec.native.js +0 -48
  528. package/dist/cjs/util.spec.native.js.map +0 -1
  529. package/dist/esm/auth.spec.mjs +0 -323
  530. package/dist/esm/auth.spec.mjs.map +0 -1
  531. package/dist/esm/auth.spec.native.js +0 -327
  532. package/dist/esm/auth.spec.native.js.map +0 -1
  533. package/dist/esm/call.spec.mjs +0 -428
  534. package/dist/esm/call.spec.mjs.map +0 -1
  535. package/dist/esm/call.spec.native.js +0 -428
  536. package/dist/esm/call.spec.native.js.map +0 -1
  537. package/dist/esm/collection.spec.mjs +0 -187
  538. package/dist/esm/collection.spec.mjs.map +0 -1
  539. package/dist/esm/collection.spec.native.js +0 -214
  540. package/dist/esm/collection.spec.native.js.map +0 -1
  541. package/dist/esm/common/types.spec.mjs +0 -267
  542. package/dist/esm/common/types.spec.mjs.map +0 -1
  543. package/dist/esm/common/types.spec.native.js +0 -269
  544. package/dist/esm/common/types.spec.native.js.map +0 -1
  545. package/dist/esm/core/http.spec.mjs +0 -1260
  546. package/dist/esm/core/http.spec.mjs.map +0 -1
  547. package/dist/esm/core/http.spec.native.js +0 -1399
  548. package/dist/esm/core/http.spec.native.js.map +0 -1
  549. package/dist/esm/core/wire.spec.mjs +0 -479
  550. package/dist/esm/core/wire.spec.mjs.map +0 -1
  551. package/dist/esm/core/wire.spec.native.js +0 -480
  552. package/dist/esm/core/wire.spec.native.js.map +0 -1
  553. package/dist/esm/db.spec.mjs +0 -863
  554. package/dist/esm/db.spec.mjs.map +0 -1
  555. package/dist/esm/db.spec.native.js +0 -863
  556. package/dist/esm/db.spec.native.js.map +0 -1
  557. package/dist/esm/doctype.spec.mjs +0 -461
  558. package/dist/esm/doctype.spec.mjs.map +0 -1
  559. package/dist/esm/doctype.spec.native.js +0 -536
  560. package/dist/esm/doctype.spec.native.js.map +0 -1
  561. package/dist/esm/file.spec.mjs +0 -316
  562. package/dist/esm/file.spec.mjs.map +0 -1
  563. package/dist/esm/file.spec.native.js +0 -340
  564. package/dist/esm/file.spec.native.js.map +0 -1
  565. package/dist/esm/frappeApp.spec.mjs +0 -307
  566. package/dist/esm/frappeApp.spec.mjs.map +0 -1
  567. package/dist/esm/frappeApp.spec.native.js +0 -306
  568. package/dist/esm/frappeApp.spec.native.js.map +0 -1
  569. package/dist/esm/frappeReact.spec.mjs +0 -532
  570. package/dist/esm/frappeReact.spec.mjs.map +0 -1
  571. package/dist/esm/frappeReact.spec.native.js +0 -668
  572. package/dist/esm/frappeReact.spec.native.js.map +0 -1
  573. package/dist/esm/optimistic.spec.mjs +0 -12
  574. package/dist/esm/optimistic.spec.mjs.map +0 -1
  575. package/dist/esm/optimistic.spec.native.js +0 -17
  576. package/dist/esm/optimistic.spec.native.js.map +0 -1
  577. package/dist/esm/pacer.spec.mjs +0 -447
  578. package/dist/esm/pacer.spec.mjs.map +0 -1
  579. package/dist/esm/pacer.spec.native.js +0 -511
  580. package/dist/esm/pacer.spec.native.js.map +0 -1
  581. package/dist/esm/realtime.spec.mjs +0 -327
  582. package/dist/esm/realtime.spec.mjs.map +0 -1
  583. package/dist/esm/realtime.spec.native.js +0 -390
  584. package/dist/esm/realtime.spec.native.js.map +0 -1
  585. package/dist/esm/sync/backfill.spec.mjs +0 -563
  586. package/dist/esm/sync/backfill.spec.mjs.map +0 -1
  587. package/dist/esm/sync/backfill.spec.native.js +0 -686
  588. package/dist/esm/sync/backfill.spec.native.js.map +0 -1
  589. package/dist/esm/sync/debug.spec.mjs +0 -102
  590. package/dist/esm/sync/debug.spec.mjs.map +0 -1
  591. package/dist/esm/sync/debug.spec.native.js +0 -107
  592. package/dist/esm/sync/debug.spec.native.js.map +0 -1
  593. package/dist/esm/sync/filters.spec.mjs +0 -169
  594. package/dist/esm/sync/filters.spec.mjs.map +0 -1
  595. package/dist/esm/sync/filters.spec.native.js +0 -171
  596. package/dist/esm/sync/filters.spec.native.js.map +0 -1
  597. package/dist/esm/sync/merge.spec.mjs +0 -909
  598. package/dist/esm/sync/merge.spec.mjs.map +0 -1
  599. package/dist/esm/sync/merge.spec.native.js +0 -935
  600. package/dist/esm/sync/merge.spec.native.js.map +0 -1
  601. package/dist/esm/sync/multiOrderBy.spec.mjs +0 -166
  602. package/dist/esm/sync/multiOrderBy.spec.mjs.map +0 -1
  603. package/dist/esm/sync/multiOrderBy.spec.native.js +0 -227
  604. package/dist/esm/sync/multiOrderBy.spec.native.js.map +0 -1
  605. package/dist/esm/sync/mutationEngine.spec.mjs +0 -1159
  606. package/dist/esm/sync/mutationEngine.spec.mjs.map +0 -1
  607. package/dist/esm/sync/mutationEngine.spec.native.js +0 -1171
  608. package/dist/esm/sync/mutationEngine.spec.native.js.map +0 -1
  609. package/dist/esm/sync/mutationJournal.spec.mjs +0 -331
  610. package/dist/esm/sync/mutationJournal.spec.mjs.map +0 -1
  611. package/dist/esm/sync/mutationJournal.spec.native.js +0 -331
  612. package/dist/esm/sync/mutationJournal.spec.native.js.map +0 -1
  613. package/dist/esm/sync/mutations.spec.mjs +0 -328
  614. package/dist/esm/sync/mutations.spec.mjs.map +0 -1
  615. package/dist/esm/sync/mutations.spec.native.js +0 -328
  616. package/dist/esm/sync/mutations.spec.native.js.map +0 -1
  617. package/dist/esm/sync/normalizedCache.spec.mjs +0 -303
  618. package/dist/esm/sync/normalizedCache.spec.mjs.map +0 -1
  619. package/dist/esm/sync/normalizedCache.spec.native.js +0 -309
  620. package/dist/esm/sync/normalizedCache.spec.native.js.map +0 -1
  621. package/dist/esm/sync/persistence.spec.mjs +0 -563
  622. package/dist/esm/sync/persistence.spec.mjs.map +0 -1
  623. package/dist/esm/sync/persistence.spec.native.js +0 -570
  624. package/dist/esm/sync/persistence.spec.native.js.map +0 -1
  625. package/dist/esm/sync/realtime.spec.mjs +0 -500
  626. package/dist/esm/sync/realtime.spec.mjs.map +0 -1
  627. package/dist/esm/sync/realtime.spec.native.js +0 -510
  628. package/dist/esm/sync/realtime.spec.native.js.map +0 -1
  629. package/dist/esm/sync/rehydration.spec.mjs +0 -732
  630. package/dist/esm/sync/rehydration.spec.mjs.map +0 -1
  631. package/dist/esm/sync/rehydration.spec.native.js +0 -734
  632. package/dist/esm/sync/rehydration.spec.native.js.map +0 -1
  633. package/dist/esm/sync/storage.spec.mjs +0 -423
  634. package/dist/esm/sync/storage.spec.mjs.map +0 -1
  635. package/dist/esm/sync/storage.spec.native.js +0 -444
  636. package/dist/esm/sync/storage.spec.native.js.map +0 -1
  637. package/dist/esm/sync/subscriptionManager.spec.mjs +0 -1079
  638. package/dist/esm/sync/subscriptionManager.spec.mjs.map +0 -1
  639. package/dist/esm/sync/subscriptionManager.spec.native.js +0 -1110
  640. package/dist/esm/sync/subscriptionManager.spec.native.js.map +0 -1
  641. package/dist/esm/sync/subscriptions.spec.mjs +0 -914
  642. package/dist/esm/sync/subscriptions.spec.mjs.map +0 -1
  643. package/dist/esm/sync/subscriptions.spec.native.js +0 -943
  644. package/dist/esm/sync/subscriptions.spec.native.js.map +0 -1
  645. package/dist/esm/sync/syncModule.spec.mjs +0 -207
  646. package/dist/esm/sync/syncModule.spec.mjs.map +0 -1
  647. package/dist/esm/sync/syncModule.spec.native.js +0 -220
  648. package/dist/esm/sync/syncModule.spec.native.js.map +0 -1
  649. package/dist/esm/sync/types.spec.mjs +0 -247
  650. package/dist/esm/sync/types.spec.mjs.map +0 -1
  651. package/dist/esm/sync/types.spec.native.js +0 -254
  652. package/dist/esm/sync/types.spec.native.js.map +0 -1
  653. package/dist/esm/sync/virtualPageManager.spec.mjs +0 -802
  654. package/dist/esm/sync/virtualPageManager.spec.mjs.map +0 -1
  655. package/dist/esm/sync/virtualPageManager.spec.native.js +0 -871
  656. package/dist/esm/sync/virtualPageManager.spec.native.js.map +0 -1
  657. package/dist/esm/util.spec.mjs +0 -20
  658. package/dist/esm/util.spec.mjs.map +0 -1
  659. package/dist/esm/util.spec.native.js +0 -22
  660. package/dist/esm/util.spec.native.js.map +0 -1
  661. package/dist/jsx/auth.spec.mjs +0 -323
  662. package/dist/jsx/auth.spec.mjs.map +0 -1
  663. package/dist/jsx/auth.spec.native.js +0 -329
  664. package/dist/jsx/auth.spec.native.js.map +0 -1
  665. package/dist/jsx/call.spec.mjs +0 -428
  666. package/dist/jsx/call.spec.mjs.map +0 -1
  667. package/dist/jsx/call.spec.native.js +0 -430
  668. package/dist/jsx/call.spec.native.js.map +0 -1
  669. package/dist/jsx/collection.spec.mjs +0 -187
  670. package/dist/jsx/collection.spec.mjs.map +0 -1
  671. package/dist/jsx/collection.spec.native.js +0 -216
  672. package/dist/jsx/collection.spec.native.js.map +0 -1
  673. package/dist/jsx/common/types.spec.mjs +0 -267
  674. package/dist/jsx/common/types.spec.mjs.map +0 -1
  675. package/dist/jsx/common/types.spec.native.js +0 -271
  676. package/dist/jsx/common/types.spec.native.js.map +0 -1
  677. package/dist/jsx/core/http.spec.mjs +0 -1260
  678. package/dist/jsx/core/http.spec.mjs.map +0 -1
  679. package/dist/jsx/core/http.spec.native.js +0 -1401
  680. package/dist/jsx/core/http.spec.native.js.map +0 -1
  681. package/dist/jsx/core/wire.spec.mjs +0 -479
  682. package/dist/jsx/core/wire.spec.mjs.map +0 -1
  683. package/dist/jsx/core/wire.spec.native.js +0 -482
  684. package/dist/jsx/core/wire.spec.native.js.map +0 -1
  685. package/dist/jsx/db.spec.mjs +0 -863
  686. package/dist/jsx/db.spec.mjs.map +0 -1
  687. package/dist/jsx/db.spec.native.js +0 -865
  688. package/dist/jsx/db.spec.native.js.map +0 -1
  689. package/dist/jsx/doctype.spec.mjs +0 -461
  690. package/dist/jsx/doctype.spec.mjs.map +0 -1
  691. package/dist/jsx/doctype.spec.native.js +0 -538
  692. package/dist/jsx/doctype.spec.native.js.map +0 -1
  693. package/dist/jsx/file.spec.mjs +0 -316
  694. package/dist/jsx/file.spec.mjs.map +0 -1
  695. package/dist/jsx/file.spec.native.js +0 -342
  696. package/dist/jsx/file.spec.native.js.map +0 -1
  697. package/dist/jsx/frappeApp.spec.mjs +0 -307
  698. package/dist/jsx/frappeApp.spec.mjs.map +0 -1
  699. package/dist/jsx/frappeApp.spec.native.js +0 -308
  700. package/dist/jsx/frappeApp.spec.native.js.map +0 -1
  701. package/dist/jsx/frappeReact.spec.mjs +0 -532
  702. package/dist/jsx/frappeReact.spec.mjs.map +0 -1
  703. package/dist/jsx/frappeReact.spec.native.js +0 -670
  704. package/dist/jsx/frappeReact.spec.native.js.map +0 -1
  705. package/dist/jsx/optimistic.spec.mjs +0 -12
  706. package/dist/jsx/optimistic.spec.mjs.map +0 -1
  707. package/dist/jsx/optimistic.spec.native.js +0 -19
  708. package/dist/jsx/optimistic.spec.native.js.map +0 -1
  709. package/dist/jsx/pacer.spec.mjs +0 -447
  710. package/dist/jsx/pacer.spec.mjs.map +0 -1
  711. package/dist/jsx/pacer.spec.native.js +0 -537
  712. package/dist/jsx/pacer.spec.native.js.map +0 -1
  713. package/dist/jsx/realtime.spec.mjs +0 -327
  714. package/dist/jsx/realtime.spec.mjs.map +0 -1
  715. package/dist/jsx/realtime.spec.native.js +0 -392
  716. package/dist/jsx/realtime.spec.native.js.map +0 -1
  717. package/dist/jsx/sync/backfill.spec.mjs +0 -563
  718. package/dist/jsx/sync/backfill.spec.mjs.map +0 -1
  719. package/dist/jsx/sync/backfill.spec.native.js +0 -712
  720. package/dist/jsx/sync/backfill.spec.native.js.map +0 -1
  721. package/dist/jsx/sync/debug.spec.mjs +0 -102
  722. package/dist/jsx/sync/debug.spec.mjs.map +0 -1
  723. package/dist/jsx/sync/debug.spec.native.js +0 -133
  724. package/dist/jsx/sync/debug.spec.native.js.map +0 -1
  725. package/dist/jsx/sync/filters.spec.mjs +0 -169
  726. package/dist/jsx/sync/filters.spec.mjs.map +0 -1
  727. package/dist/jsx/sync/filters.spec.native.js +0 -173
  728. package/dist/jsx/sync/filters.spec.native.js.map +0 -1
  729. package/dist/jsx/sync/merge.spec.mjs +0 -909
  730. package/dist/jsx/sync/merge.spec.mjs.map +0 -1
  731. package/dist/jsx/sync/merge.spec.native.js +0 -937
  732. package/dist/jsx/sync/merge.spec.native.js.map +0 -1
  733. package/dist/jsx/sync/multiOrderBy.spec.mjs +0 -166
  734. package/dist/jsx/sync/multiOrderBy.spec.mjs.map +0 -1
  735. package/dist/jsx/sync/multiOrderBy.spec.native.js +0 -229
  736. package/dist/jsx/sync/multiOrderBy.spec.native.js.map +0 -1
  737. package/dist/jsx/sync/mutationEngine.spec.mjs +0 -1159
  738. package/dist/jsx/sync/mutationEngine.spec.mjs.map +0 -1
  739. package/dist/jsx/sync/mutationEngine.spec.native.js +0 -1173
  740. package/dist/jsx/sync/mutationEngine.spec.native.js.map +0 -1
  741. package/dist/jsx/sync/mutationJournal.spec.mjs +0 -331
  742. package/dist/jsx/sync/mutationJournal.spec.mjs.map +0 -1
  743. package/dist/jsx/sync/mutationJournal.spec.native.js +0 -333
  744. package/dist/jsx/sync/mutationJournal.spec.native.js.map +0 -1
  745. package/dist/jsx/sync/mutations.spec.mjs +0 -328
  746. package/dist/jsx/sync/mutations.spec.mjs.map +0 -1
  747. package/dist/jsx/sync/mutations.spec.native.js +0 -330
  748. package/dist/jsx/sync/mutations.spec.native.js.map +0 -1
  749. package/dist/jsx/sync/normalizedCache.spec.mjs +0 -303
  750. package/dist/jsx/sync/normalizedCache.spec.mjs.map +0 -1
  751. package/dist/jsx/sync/normalizedCache.spec.native.js +0 -311
  752. package/dist/jsx/sync/normalizedCache.spec.native.js.map +0 -1
  753. package/dist/jsx/sync/persistence.spec.mjs +0 -563
  754. package/dist/jsx/sync/persistence.spec.mjs.map +0 -1
  755. package/dist/jsx/sync/persistence.spec.native.js +0 -572
  756. package/dist/jsx/sync/persistence.spec.native.js.map +0 -1
  757. package/dist/jsx/sync/realtime.spec.mjs +0 -500
  758. package/dist/jsx/sync/realtime.spec.mjs.map +0 -1
  759. package/dist/jsx/sync/realtime.spec.native.js +0 -512
  760. package/dist/jsx/sync/realtime.spec.native.js.map +0 -1
  761. package/dist/jsx/sync/rehydration.spec.mjs +0 -732
  762. package/dist/jsx/sync/rehydration.spec.mjs.map +0 -1
  763. package/dist/jsx/sync/rehydration.spec.native.js +0 -736
  764. package/dist/jsx/sync/rehydration.spec.native.js.map +0 -1
  765. package/dist/jsx/sync/storage.spec.mjs +0 -423
  766. package/dist/jsx/sync/storage.spec.mjs.map +0 -1
  767. package/dist/jsx/sync/storage.spec.native.js +0 -470
  768. package/dist/jsx/sync/storage.spec.native.js.map +0 -1
  769. package/dist/jsx/sync/subscriptionManager.spec.mjs +0 -1079
  770. package/dist/jsx/sync/subscriptionManager.spec.mjs.map +0 -1
  771. package/dist/jsx/sync/subscriptionManager.spec.native.js +0 -1136
  772. package/dist/jsx/sync/subscriptionManager.spec.native.js.map +0 -1
  773. package/dist/jsx/sync/subscriptions.spec.mjs +0 -914
  774. package/dist/jsx/sync/subscriptions.spec.mjs.map +0 -1
  775. package/dist/jsx/sync/subscriptions.spec.native.js +0 -969
  776. package/dist/jsx/sync/subscriptions.spec.native.js.map +0 -1
  777. package/dist/jsx/sync/syncModule.spec.mjs +0 -207
  778. package/dist/jsx/sync/syncModule.spec.mjs.map +0 -1
  779. package/dist/jsx/sync/syncModule.spec.native.js +0 -222
  780. package/dist/jsx/sync/syncModule.spec.native.js.map +0 -1
  781. package/dist/jsx/sync/types.spec.mjs +0 -247
  782. package/dist/jsx/sync/types.spec.mjs.map +0 -1
  783. package/dist/jsx/sync/types.spec.native.js +0 -256
  784. package/dist/jsx/sync/types.spec.native.js.map +0 -1
  785. package/dist/jsx/sync/virtualPageManager.spec.mjs +0 -802
  786. package/dist/jsx/sync/virtualPageManager.spec.mjs.map +0 -1
  787. package/dist/jsx/sync/virtualPageManager.spec.native.js +0 -873
  788. package/dist/jsx/sync/virtualPageManager.spec.native.js.map +0 -1
  789. package/dist/jsx/util.spec.mjs +0 -20
  790. package/dist/jsx/util.spec.mjs.map +0 -1
  791. package/dist/jsx/util.spec.native.js +0 -48
  792. package/dist/jsx/util.spec.native.js.map +0 -1
@@ -1,1401 +0,0 @@
1
- "use strict";
2
-
3
- var import_vitest = require("vitest");
4
- var import_http = require("./http.native.js");
5
- var import_types = require("./types.native.js");
6
- (0, import_vitest.describe)("HttpClient", function () {
7
- var client;
8
- var baseURL = "https://api.example.com";
9
- var getMockFetch = function getMockFetch2() {
10
- return import_vitest.vi.mocked(fetch);
11
- };
12
- (0, import_vitest.beforeEach)(function () {
13
- client = new import_http.HttpClient(baseURL);
14
- global.fetch = import_vitest.vi.fn();
15
- });
16
- (0, import_vitest.afterEach)(function () {
17
- import_vitest.vi.restoreAllMocks();
18
- });
19
- (0, import_vitest.describe)("constructor", function () {
20
- (0, import_vitest.it)("should initialize with base URL", function () {
21
- var httpClient = new import_http.HttpClient(baseURL);
22
- (0, import_vitest.expect)(httpClient).toBeDefined();
23
- });
24
- (0, import_vitest.it)("should accept auth config", function () {
25
- var httpClient = new import_http.HttpClient(baseURL, {
26
- useToken: true,
27
- token: "test-token",
28
- type: import_types.AuthType.Bearer
29
- });
30
- (0, import_vitest.expect)(httpClient).toBeDefined();
31
- });
32
- (0, import_vitest.it)("should accept retry config", function () {
33
- var httpClient = new import_http.HttpClient(baseURL, void 0, {
34
- maxRetries: 5,
35
- baseDelayMs: 500,
36
- exponentialBackoff: false
37
- });
38
- (0, import_vitest.expect)(httpClient).toBeDefined();
39
- });
40
- });
41
- (0, import_vitest.describe)("request", function () {
42
- (0, import_vitest.it)("should make basic GET request", async function () {
43
- var mockPayload = {
44
- data: "test"
45
- };
46
- var mockHeaders = new Headers({
47
- "Content-Type": "application/json"
48
- });
49
- var mockRes = {
50
- ok: true,
51
- headers: mockHeaders,
52
- status: 200,
53
- json: async function json() {
54
- return mockPayload;
55
- }
56
- };
57
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
58
- var result = await client.request(import_types.HttpMethod.Get, "/test", {});
59
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
60
- method: "GET",
61
- credentials: "include"
62
- }));
63
- (0, import_vitest.expect)(result.payload).toEqual(mockPayload);
64
- (0, import_vitest.expect)(result.headers).toBe(mockHeaders);
65
- (0, import_vitest.expect)(result.status).toBe(200);
66
- (0, import_vitest.expect)(result._res).toBe(mockRes);
67
- });
68
- (0, import_vitest.it)("should make POST request with JSON body", async function () {
69
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
70
- var requestBody = {
71
- foo: "bar",
72
- nested: {
73
- value: 123
74
- }
75
- };
76
- var mockPayload = {
77
- success: true
78
- };
79
- var mockHeaders = new Headers({
80
- "Content-Type": "application/json"
81
- });
82
- var mockRes = {
83
- ok: true,
84
- headers: mockHeaders,
85
- status: 200,
86
- json: async function json() {
87
- return mockPayload;
88
- }
89
- };
90
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
91
- var result = await client.request(import_types.HttpMethod.Post, "/test", {
92
- body: requestBody
93
- });
94
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
95
- method: "POST",
96
- body: JSON.stringify(requestBody),
97
- headers: import_vitest.expect.any(Headers),
98
- credentials: "include"
99
- }));
100
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
101
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("Content-Type")).toBe("application/json");
102
- (0, import_vitest.expect)(result.payload).toEqual(mockPayload);
103
- (0, import_vitest.expect)(result.status).toBe(200);
104
- });
105
- (0, import_vitest.it)("should handle FormData body", async function () {
106
- var formData = new FormData();
107
- formData.append("field", "value");
108
- var mockRes = {
109
- ok: true,
110
- headers: new Headers({
111
- "Content-Type": "application/json"
112
- }),
113
- status: 200,
114
- json: async function json() {
115
- return {
116
- success: true
117
- };
118
- }
119
- };
120
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
121
- var result = await client.request(import_types.HttpMethod.Post, "/upload", {
122
- body: formData
123
- });
124
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/upload`, import_vitest.expect.objectContaining({
125
- method: "POST",
126
- body: formData,
127
- headers: import_vitest.expect.any(Headers),
128
- credentials: "include"
129
- }));
130
- (0, import_vitest.expect)(result.payload).toEqual({
131
- success: true
132
- });
133
- });
134
- (0, import_vitest.it)("should handle URLSearchParams body", async function () {
135
- var params = new URLSearchParams();
136
- params.append("key", "value");
137
- var mockRes = {
138
- ok: true,
139
- headers: new Headers({
140
- "Content-Type": "text/plain"
141
- }),
142
- status: 200,
143
- text: async function text() {
144
- return "success";
145
- }
146
- };
147
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
148
- var result = await client.request(import_types.HttpMethod.Post, "/form", {
149
- body: params
150
- });
151
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/form`, import_vitest.expect.objectContaining({
152
- method: "POST",
153
- body: params,
154
- credentials: "include"
155
- }));
156
- (0, import_vitest.expect)(result.payload).toBe("success");
157
- });
158
- (0, import_vitest.it)("should convert object to FormData when Content-Type is multipart/form-data", async function () {
159
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
160
- var requestBody = {
161
- field1: "value1",
162
- field2: "value2"
163
- };
164
- var mockRes = {
165
- ok: true,
166
- headers: new Headers({
167
- "Content-Type": "application/json"
168
- }),
169
- status: 200,
170
- json: async function json() {
171
- return {
172
- success: true
173
- };
174
- }
175
- };
176
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
177
- await client.request(import_types.HttpMethod.Post, "/test", {
178
- body: requestBody,
179
- headers: {
180
- "Content-Type": "multipart/form-data"
181
- }
182
- });
183
- var calledBody = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body;
184
- (0, import_vitest.expect)(calledBody).toBeInstanceOf(FormData);
185
- });
186
- (0, import_vitest.it)("should convert object to URLSearchParams when Content-Type is application/x-www-form-urlencoded", async function () {
187
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
188
- var requestBody = {
189
- field1: "value1",
190
- field2: "value2"
191
- };
192
- var mockRes = {
193
- ok: true,
194
- headers: new Headers({
195
- "Content-Type": "text/plain"
196
- }),
197
- status: 200,
198
- text: async function text() {
199
- return "success";
200
- }
201
- };
202
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
203
- await client.request(import_types.HttpMethod.Post, "/test", {
204
- body: requestBody,
205
- headers: {
206
- "Content-Type": "application/x-www-form-urlencoded"
207
- }
208
- });
209
- var calledBody = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body;
210
- (0, import_vitest.expect)(calledBody).toBe("field1=value1&field2=value2");
211
- });
212
- (0, import_vitest.it)("should handle text response", async function () {
213
- var textResponse = "Plain text response";
214
- var mockHeaders = new Headers({
215
- "Content-Type": "text/plain"
216
- });
217
- var mockRes = {
218
- ok: true,
219
- headers: mockHeaders,
220
- status: 200,
221
- text: async function text() {
222
- return textResponse;
223
- }
224
- };
225
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
226
- var result = await client.request(import_types.HttpMethod.Get, "/text", {});
227
- (0, import_vitest.expect)(result.payload).toBe(textResponse);
228
- (0, import_vitest.expect)(result.headers).toBe(mockHeaders);
229
- (0, import_vitest.expect)(result.status).toBe(200);
230
- });
231
- (0, import_vitest.it)("should throw FrappeError on non-ok response", async function () {
232
- var errorPayload = {
233
- message: "Bad Request",
234
- details: "Invalid input"
235
- };
236
- global.fetch = import_vitest.vi.fn().mockResolvedValue({
237
- ok: false,
238
- status: 400,
239
- statusText: "Bad Request",
240
- headers: new Headers({
241
- "Content-Type": "application/json"
242
- }),
243
- json: async function json() {
244
- return errorPayload;
245
- }
246
- });
247
- await (0, import_vitest.expect)(client.request(import_types.HttpMethod.Post, "/test", {})).rejects.toThrow(import_types.FrappeError);
248
- try {
249
- await client.request(import_types.HttpMethod.Post, "/test", {});
250
- } catch (error) {
251
- (0, import_vitest.expect)(error).toBeInstanceOf(import_types.FrappeError);
252
- (0, import_vitest.expect)(error.status).toBe(400);
253
- (0, import_vitest.expect)(error.message).toBe("Bad Request");
254
- (0, import_vitest.expect)(error.data).toEqual(errorPayload);
255
- }
256
- });
257
- (0, import_vitest.it)("should handle network errors", async function () {
258
- var networkError = new Error("Network error");
259
- global.fetch = import_vitest.vi.fn().mockRejectedValue(networkError);
260
- await (0, import_vitest.expect)(client.request(import_types.HttpMethod.Get, "/test", {})).rejects.toThrow("Network error");
261
- });
262
- });
263
- (0, import_vitest.describe)("authentication", function () {
264
- (0, import_vitest.it)("should add Bearer token to headers", async function () {
265
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_, _getMockFetch_mock_calls__1, _getMockFetch_mock_calls_1;
266
- var token = "test-bearer-token";
267
- var authClient = new import_http.HttpClient(baseURL, {
268
- useToken: true,
269
- token,
270
- type: import_types.AuthType.Bearer
271
- });
272
- var mockRes = {
273
- ok: true,
274
- headers: new Headers({
275
- "Content-Type": "application/json"
276
- }),
277
- status: 200,
278
- json: async function json() {
279
- return {
280
- success: true
281
- };
282
- }
283
- };
284
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
285
- await authClient.request(import_types.HttpMethod.Get, "/test", {});
286
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
287
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("Authorization")).toBe(`Bearer ${token}`);
288
- (0, import_vitest.expect)((_getMockFetch_mock_calls_1 = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_1 === void 0 ? void 0 : (_getMockFetch_mock_calls__1 = _getMockFetch_mock_calls_1[1]) === null || _getMockFetch_mock_calls__1 === void 0 ? void 0 : _getMockFetch_mock_calls__1.credentials).toBe("omit");
289
- });
290
- (0, import_vitest.it)("should add token auth to headers", async function () {
291
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
292
- var token = "test-token";
293
- var authClient = new import_http.HttpClient(baseURL, {
294
- useToken: true,
295
- token,
296
- type: import_types.AuthType.Token
297
- });
298
- var mockRes = {
299
- ok: true,
300
- headers: new Headers({
301
- "Content-Type": "application/json"
302
- }),
303
- status: 200,
304
- json: async function json() {
305
- return {
306
- success: true
307
- };
308
- }
309
- };
310
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
311
- await authClient.request(import_types.HttpMethod.Get, "/test", {});
312
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
313
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("Authorization")).toBe(`token ${token}`);
314
- });
315
- (0, import_vitest.it)("should support token as function", async function () {
316
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
317
- var token = "dynamic-token";
318
- var authClient = new import_http.HttpClient(baseURL, {
319
- useToken: true,
320
- token: async function token1() {
321
- return token;
322
- },
323
- type: import_types.AuthType.Bearer
324
- });
325
- var mockRes = {
326
- ok: true,
327
- headers: new Headers({
328
- "Content-Type": "application/json"
329
- }),
330
- status: 200,
331
- json: async function json() {
332
- return {
333
- success: true
334
- };
335
- }
336
- };
337
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
338
- await authClient.request(import_types.HttpMethod.Get, "/test", {});
339
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
340
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("Authorization")).toBe(`Bearer ${token}`);
341
- });
342
- (0, import_vitest.it)("should add CSRF token for non-GET requests without token auth", async function () {
343
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
344
- var csrfToken = "csrf-test-token";
345
- Object.defineProperty(global, "document", {
346
- value: {
347
- cookie: `frappe-csrf-token=${csrfToken}; path=/`
348
- },
349
- writable: true
350
- });
351
- Object.defineProperty(global, "window", {
352
- value: {},
353
- writable: true
354
- });
355
- var mockRes = {
356
- ok: true,
357
- headers: new Headers({
358
- "Content-Type": "application/json"
359
- }),
360
- status: 200,
361
- json: async function json() {
362
- return {
363
- success: true
364
- };
365
- }
366
- };
367
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
368
- await client.request(import_types.HttpMethod.Post, "/test", {});
369
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
370
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Frappe-CSRF-Token")).toBe(csrfToken);
371
- Object.defineProperty(global, "document", {
372
- value: void 0,
373
- configurable: true
374
- });
375
- Object.defineProperty(global, "window", {
376
- value: void 0,
377
- configurable: true
378
- });
379
- });
380
- (0, import_vitest.it)("should use credentials include when not using token auth", async function () {
381
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
382
- var mockRes = {
383
- ok: true,
384
- headers: new Headers({
385
- "Content-Type": "application/json"
386
- }),
387
- status: 200,
388
- json: async function json() {
389
- return {
390
- success: true
391
- };
392
- }
393
- };
394
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
395
- await client.request(import_types.HttpMethod.Get, "/test", {});
396
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.credentials).toBe("include");
397
- });
398
- (0, import_vitest.it)("should set token dynamically via function", async function () {
399
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
400
- var tokenFn = import_vitest.vi.fn().mockResolvedValue("new-token");
401
- var authClient = new import_http.HttpClient(baseURL, {
402
- useToken: true,
403
- token: tokenFn
404
- });
405
- var mockRes = {
406
- ok: true,
407
- headers: new Headers({
408
- "Content-Type": "application/json"
409
- }),
410
- status: 200,
411
- json: async function json() {
412
- return {
413
- success: true
414
- };
415
- }
416
- };
417
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
418
- await authClient.request(import_types.HttpMethod.Get, "/test", {});
419
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
420
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("Authorization")).toBe("Bearer new-token");
421
- (0, import_vitest.expect)(tokenFn).toHaveBeenCalledTimes(1);
422
- });
423
- });
424
- (0, import_vitest.describe)("retry logic", function () {
425
- (0, import_vitest.it)("should retry on retry-able status codes", async function () {
426
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
427
- maxRetries: 2,
428
- baseDelayMs: 10,
429
- retryStatusCodes: [503]
430
- });
431
- var attempt = 0;
432
- global.fetch = import_vitest.vi.fn().mockImplementation(async function () {
433
- attempt++;
434
- if (attempt < 3) {
435
- return {
436
- ok: false,
437
- status: 503,
438
- statusText: "Service Unavailable",
439
- headers: new Headers({
440
- "Content-Type": "text/plain"
441
- }),
442
- text: async function text() {
443
- return "Service temporarily unavailable";
444
- }
445
- };
446
- }
447
- return {
448
- ok: true,
449
- headers: new Headers({
450
- "Content-Type": "application/json"
451
- }),
452
- status: 200,
453
- json: async function json() {
454
- return {
455
- success: true
456
- };
457
- }
458
- };
459
- });
460
- var result = await retryClient.request(import_types.HttpMethod.Get, "/test", {});
461
- (0, import_vitest.expect)(fetch).toHaveBeenCalledTimes(3);
462
- (0, import_vitest.expect)(result.payload).toEqual({
463
- success: true
464
- });
465
- });
466
- (0, import_vitest.it)("should retry on network errors when configured", async function () {
467
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
468
- maxRetries: 1,
469
- baseDelayMs: 10,
470
- retryOnNetworkError: true
471
- });
472
- var attempt = 0;
473
- global.fetch = import_vitest.vi.fn().mockImplementation(async function () {
474
- attempt++;
475
- if (attempt === 1) {
476
- throw new Error("Network error");
477
- }
478
- return {
479
- ok: true,
480
- headers: new Headers({
481
- "Content-Type": "application/json"
482
- }),
483
- status: 200,
484
- json: async function json() {
485
- return {
486
- success: true
487
- };
488
- }
489
- };
490
- });
491
- var result = await retryClient.request(import_types.HttpMethod.Get, "/test", {});
492
- (0, import_vitest.expect)(fetch).toHaveBeenCalledTimes(2);
493
- (0, import_vitest.expect)(result.payload).toEqual({
494
- success: true
495
- });
496
- });
497
- (0, import_vitest.it)("should not retry on non-retry-able status codes", async function () {
498
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
499
- maxRetries: 2,
500
- baseDelayMs: 10,
501
- retryStatusCodes: [503]
502
- });
503
- global.fetch = import_vitest.vi.fn().mockResolvedValue({
504
- ok: false,
505
- status: 400,
506
- statusText: "Bad Request",
507
- headers: new Headers({
508
- "Content-Type": "text/plain"
509
- }),
510
- text: async function text() {
511
- return "Bad request";
512
- }
513
- });
514
- await (0, import_vitest.expect)(retryClient.request(import_types.HttpMethod.Get, "/test", {})).rejects.toThrow(import_types.FrappeError);
515
- (0, import_vitest.expect)(fetch).toHaveBeenCalledTimes(1);
516
- });
517
- (0, import_vitest.it)("should use exponential backoff when configured", async function () {
518
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
519
- maxRetries: 3,
520
- baseDelayMs: 100,
521
- exponentialBackoff: true,
522
- maxDelayMs: 500,
523
- retryStatusCodes: [503]
524
- });
525
- var delays = [];
526
- import_vitest.vi.spyOn(global, "setTimeout").mockImplementation(function (fn, delay) {
527
- delays.push(delay || 0);
528
- if (typeof fn === "function") fn();
529
- return 0;
530
- });
531
- var attempt = 0;
532
- global.fetch = import_vitest.vi.fn().mockImplementation(async function () {
533
- attempt++;
534
- if (attempt <= 3) {
535
- return {
536
- ok: false,
537
- status: 503,
538
- statusText: "Service Unavailable",
539
- headers: new Headers({
540
- "Content-Type": "text/plain"
541
- }),
542
- text: async function text() {
543
- return "Service unavailable";
544
- }
545
- };
546
- }
547
- return {
548
- ok: true,
549
- headers: new Headers({
550
- "Content-Type": "application/json"
551
- }),
552
- status: 200,
553
- json: async function json() {
554
- return {
555
- success: true
556
- };
557
- }
558
- };
559
- });
560
- var result = await retryClient.request(import_types.HttpMethod.Get, "/test", {});
561
- (0, import_vitest.expect)(delays[0]).toBe(100);
562
- (0, import_vitest.expect)(delays[1]).toBe(200);
563
- (0, import_vitest.expect)(delays[2]).toBe(400);
564
- (0, import_vitest.expect)(result.payload).toEqual({
565
- success: true
566
- });
567
- });
568
- (0, import_vitest.it)("should respect maxDelayMs", async function () {
569
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
570
- maxRetries: 3,
571
- baseDelayMs: 100,
572
- exponentialBackoff: true,
573
- maxDelayMs: 150,
574
- retryStatusCodes: [503]
575
- });
576
- var delays = [];
577
- import_vitest.vi.spyOn(global, "setTimeout").mockImplementation(function (fn, delay) {
578
- delays.push(delay || 0);
579
- if (typeof fn === "function") fn();
580
- return 0;
581
- });
582
- var attempt = 0;
583
- global.fetch = import_vitest.vi.fn().mockImplementation(async function () {
584
- attempt++;
585
- if (attempt <= 3) {
586
- return {
587
- ok: false,
588
- status: 503,
589
- statusText: "Service Unavailable",
590
- headers: new Headers({
591
- "Content-Type": "text/plain"
592
- }),
593
- text: async function text() {
594
- return "Service unavailable";
595
- }
596
- };
597
- }
598
- return {
599
- ok: true,
600
- headers: new Headers({
601
- "Content-Type": "application/json"
602
- }),
603
- status: 200,
604
- json: async function json() {
605
- return {
606
- success: true
607
- };
608
- }
609
- };
610
- });
611
- var result = await retryClient.request(import_types.HttpMethod.Get, "/test", {});
612
- (0, import_vitest.expect)(delays[0]).toBe(100);
613
- (0, import_vitest.expect)(delays[1]).toBe(150);
614
- (0, import_vitest.expect)(delays[2]).toBe(150);
615
- (0, import_vitest.expect)(result.payload).toEqual({
616
- success: true
617
- });
618
- });
619
- (0, import_vitest.it)("should use custom shouldRetry function", async function () {
620
- var shouldRetry = import_vitest.vi.fn(function (_err, attempt2) {
621
- return attempt2 < 2;
622
- });
623
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
624
- maxRetries: 3,
625
- baseDelayMs: 10,
626
- shouldRetry
627
- });
628
- var attempt = 0;
629
- global.fetch = import_vitest.vi.fn().mockImplementation(async function () {
630
- attempt++;
631
- if (attempt < 3) {
632
- return {
633
- ok: false,
634
- status: 500,
635
- statusText: "Internal Server Error",
636
- headers: new Headers({
637
- "Content-Type": "text/plain"
638
- }),
639
- text: async function text() {
640
- return "Server error";
641
- }
642
- };
643
- }
644
- return {
645
- ok: true,
646
- headers: new Headers({
647
- "Content-Type": "application/json"
648
- }),
649
- status: 200,
650
- json: async function json() {
651
- return {
652
- success: true
653
- };
654
- }
655
- };
656
- });
657
- var result = await retryClient.request(import_types.HttpMethod.Get, "/test", {});
658
- (0, import_vitest.expect)(shouldRetry).toHaveBeenCalledTimes(2);
659
- (0, import_vitest.expect)(fetch).toHaveBeenCalledTimes(3);
660
- (0, import_vitest.expect)(result.payload).toEqual({
661
- success: true
662
- });
663
- });
664
- (0, import_vitest.it)("should throw last error after max retries", async function () {
665
- var retryClient = new import_http.HttpClient(baseURL, void 0, {
666
- maxRetries: 2,
667
- baseDelayMs: 10,
668
- retryStatusCodes: [503]
669
- });
670
- global.fetch = import_vitest.vi.fn().mockResolvedValue({
671
- ok: false,
672
- status: 503,
673
- statusText: "Service Unavailable",
674
- headers: new Headers({
675
- "Content-Type": "text/plain"
676
- }),
677
- text: async function text() {
678
- return "Service unavailable";
679
- }
680
- });
681
- await (0, import_vitest.expect)(retryClient.request(import_types.HttpMethod.Get, "/test", {})).rejects.toThrow(import_types.FrappeError);
682
- (0, import_vitest.expect)(fetch).toHaveBeenCalledTimes(3);
683
- });
684
- });
685
- (0, import_vitest.describe)("convenience methods", function () {
686
- (0, import_vitest.beforeEach)(function () {
687
- var mockRes = {
688
- ok: true,
689
- headers: new Headers({
690
- "Content-Type": "application/json"
691
- }),
692
- status: 200,
693
- json: async function json() {
694
- return {
695
- success: true
696
- };
697
- }
698
- };
699
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
700
- });
701
- (0, import_vitest.describe)("get", function () {
702
- (0, import_vitest.it)("should make GET request without params", async function () {
703
- var result = await client.get("/test");
704
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
705
- method: "GET"
706
- }));
707
- (0, import_vitest.expect)(result.payload).toEqual({
708
- success: true
709
- });
710
- });
711
- (0, import_vitest.it)("should make GET request with params", async function () {
712
- await client.get("/test", {
713
- foo: "bar",
714
- num: 123,
715
- bool: true,
716
- nullValue: null,
717
- undefinedValue: void 0
718
- });
719
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test?foo=bar&num=123&bool=true`, import_vitest.expect.objectContaining({
720
- method: "GET"
721
- }));
722
- });
723
- (0, import_vitest.it)("should handle complex params", async function () {
724
- await client.get("/test", {
725
- array: [1, 2, 3],
726
- object: {
727
- nested: "value"
728
- }
729
- });
730
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test?array=%5B1%2C2%2C3%5D&object=%7B%22nested%22%3A%22value%22%7D`, import_vitest.expect.objectContaining({
731
- method: "GET"
732
- }));
733
- });
734
- (0, import_vitest.it)("should pass custom headers", async function () {
735
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
736
- await client.get("/test", {}, {
737
- "X-Custom": "header"
738
- });
739
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
740
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Custom")).toBe("header");
741
- });
742
- });
743
- (0, import_vitest.describe)("post", function () {
744
- (0, import_vitest.it)("should make POST request without body", async function () {
745
- var result = await client.post("/test");
746
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
747
- method: "POST"
748
- }));
749
- (0, import_vitest.expect)(result.payload).toEqual({
750
- success: true
751
- });
752
- });
753
- (0, import_vitest.it)("should make POST request with body", async function () {
754
- var body = {
755
- data: "test"
756
- };
757
- var result = await client.post("/test", body);
758
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
759
- method: "POST",
760
- body: JSON.stringify(body)
761
- }));
762
- (0, import_vitest.expect)(result.payload).toEqual({
763
- success: true
764
- });
765
- });
766
- (0, import_vitest.it)("should pass custom headers", async function () {
767
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
768
- await client.post("/test", {}, {
769
- "X-Custom": "header"
770
- });
771
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
772
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Custom")).toBe("header");
773
- });
774
- });
775
- (0, import_vitest.describe)("put", function () {
776
- (0, import_vitest.it)("should make PUT request", async function () {
777
- var body = {
778
- data: "test"
779
- };
780
- var result = await client.put("/test", body);
781
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
782
- method: "PUT",
783
- body: JSON.stringify(body)
784
- }));
785
- (0, import_vitest.expect)(result.payload).toEqual({
786
- success: true
787
- });
788
- });
789
- (0, import_vitest.it)("should pass custom headers", async function () {
790
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
791
- await client.put("/test", {}, {
792
- "X-Custom": "header"
793
- });
794
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
795
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Custom")).toBe("header");
796
- });
797
- });
798
- (0, import_vitest.describe)("delete", function () {
799
- (0, import_vitest.it)("should make DELETE request", async function () {
800
- var result = await client.delete("/test");
801
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
802
- method: "DELETE"
803
- }));
804
- (0, import_vitest.expect)(result.payload).toEqual({
805
- success: true
806
- });
807
- });
808
- (0, import_vitest.it)("should make DELETE request with body", async function () {
809
- var body = {
810
- id: "123"
811
- };
812
- var result = await client.delete("/test", body);
813
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
814
- method: "DELETE",
815
- body: JSON.stringify(body)
816
- }));
817
- (0, import_vitest.expect)(result.payload).toEqual({
818
- success: true
819
- });
820
- });
821
- (0, import_vitest.it)("should pass custom headers", async function () {
822
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
823
- await client.delete("/test", void 0, {
824
- "X-Custom": "header"
825
- });
826
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
827
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Custom")).toBe("header");
828
- });
829
- });
830
- (0, import_vitest.describe)("head", function () {
831
- (0, import_vitest.it)("should make HEAD request and return response", async function () {
832
- var mockRes = {
833
- ok: true,
834
- headers: new Headers({
835
- "Content-Type": "application/json",
836
- "Content-Length": "1234"
837
- }),
838
- status: 200,
839
- text: async function text() {
840
- return "";
841
- },
842
- json: async function json() {
843
- return {};
844
- }
845
- };
846
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
847
- var response = await client.head("/test");
848
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test`, import_vitest.expect.objectContaining({
849
- method: "HEAD"
850
- }));
851
- (0, import_vitest.expect)(response.headers.get("Content-Type")).toBe("application/json");
852
- (0, import_vitest.expect)(response.headers.get("Content-Length")).toBe("1234");
853
- (0, import_vitest.expect)(response.status).toBe(200);
854
- });
855
- (0, import_vitest.it)("should make HEAD request with params", async function () {
856
- var mockRes = {
857
- ok: true,
858
- headers: new Headers(),
859
- status: 200,
860
- text: async function text() {
861
- return "";
862
- },
863
- json: async function json() {
864
- return {};
865
- }
866
- };
867
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
868
- var response = await client.head("/test", {
869
- check: "true"
870
- });
871
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/test?check=true`, import_vitest.expect.objectContaining({
872
- method: "HEAD"
873
- }));
874
- (0, import_vitest.expect)(response.status).toBe(200);
875
- });
876
- (0, import_vitest.it)("should pass custom headers", async function () {
877
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
878
- var mockRes = {
879
- ok: true,
880
- headers: new Headers(),
881
- status: 200,
882
- text: async function text() {
883
- return "";
884
- },
885
- json: async function json() {
886
- return {};
887
- }
888
- };
889
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
890
- await client.head("/test", {}, {
891
- "X-Custom": "header"
892
- });
893
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
894
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Custom")).toBe("header");
895
- });
896
- (0, import_vitest.it)("should throw FrappeError on non-ok response", async function () {
897
- global.fetch = import_vitest.vi.fn().mockResolvedValue({
898
- ok: false,
899
- status: 404,
900
- statusText: "Not Found",
901
- headers: new Headers(),
902
- text: async function text() {
903
- return "Not found";
904
- }
905
- });
906
- await (0, import_vitest.expect)(client.head("/test")).rejects.toThrow(import_types.FrappeError);
907
- try {
908
- await client.head("/test");
909
- } catch (error) {
910
- (0, import_vitest.expect)(error).toBeInstanceOf(import_types.FrappeError);
911
- (0, import_vitest.expect)(error.status).toBe(404);
912
- (0, import_vitest.expect)(error.message).toBe("Not Found");
913
- }
914
- });
915
- (0, import_vitest.it)("should use credentials include when not using token auth", async function () {
916
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
917
- var mockRes = {
918
- ok: true,
919
- headers: new Headers(),
920
- status: 200,
921
- text: async function text() {
922
- return "";
923
- },
924
- json: async function json() {
925
- return {};
926
- }
927
- };
928
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
929
- await client.head("/test");
930
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.credentials).toBe("include");
931
- });
932
- (0, import_vitest.it)("should use credentials omit and add auth header when using token auth", async function () {
933
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_, _getMockFetch_mock_calls__1, _getMockFetch_mock_calls_1;
934
- var authClient = new import_http.HttpClient(baseURL, {
935
- useToken: true,
936
- token: "test-token",
937
- type: import_types.AuthType.Bearer
938
- });
939
- var mockRes = {
940
- ok: true,
941
- headers: new Headers(),
942
- status: 200,
943
- text: async function text() {
944
- return "";
945
- },
946
- json: async function json() {
947
- return {};
948
- }
949
- };
950
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
951
- await authClient.head("/test");
952
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.credentials).toBe("omit");
953
- var calledHeaders = (_getMockFetch_mock_calls_1 = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_1 === void 0 ? void 0 : (_getMockFetch_mock_calls__1 = _getMockFetch_mock_calls_1[1]) === null || _getMockFetch_mock_calls__1 === void 0 ? void 0 : _getMockFetch_mock_calls__1.headers;
954
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("Authorization")).toBe("Bearer test-token");
955
- });
956
- });
957
- });
958
- (0, import_vitest.describe)("edge cases", function () {
959
- (0, import_vitest.it)("should handle empty response", async function () {
960
- var mockRes = {
961
- ok: true,
962
- headers: new Headers(),
963
- status: 200,
964
- text: async function text() {
965
- return "";
966
- },
967
- json: async function json() {
968
- throw new Error("Invalid JSON");
969
- }
970
- };
971
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
972
- var result = await client.request(import_types.HttpMethod.Get, "/empty", {});
973
- (0, import_vitest.expect)(result.payload).toBe("");
974
- (0, import_vitest.expect)(result.status).toBe(200);
975
- });
976
- (0, import_vitest.it)("should handle ArrayBuffer body", async function () {
977
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
978
- var buffer = new ArrayBuffer(8);
979
- var mockRes = {
980
- ok: true,
981
- headers: new Headers({
982
- "Content-Type": "application/json"
983
- }),
984
- status: 200,
985
- json: async function json() {
986
- return {
987
- success: true
988
- };
989
- }
990
- };
991
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
992
- await client.request(import_types.HttpMethod.Post, "/binary", {
993
- body: buffer
994
- });
995
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body).toBe(buffer);
996
- });
997
- (0, import_vitest.it)("should handle Blob body", async function () {
998
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
999
- var blob = new Blob(["test"], {
1000
- type: "text/plain"
1001
- });
1002
- var mockRes = {
1003
- ok: true,
1004
- headers: new Headers({
1005
- "Content-Type": "application/json"
1006
- }),
1007
- status: 200,
1008
- json: async function json() {
1009
- return {
1010
- success: true
1011
- };
1012
- }
1013
- };
1014
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1015
- await client.request(import_types.HttpMethod.Post, "/blob", {
1016
- body: blob
1017
- });
1018
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body).toBe(blob);
1019
- });
1020
- (0, import_vitest.it)("should handle ArrayBufferView body", async function () {
1021
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1022
- var uint8Array = new Uint8Array([1, 2, 3, 4]);
1023
- var mockRes = {
1024
- ok: true,
1025
- headers: new Headers({
1026
- "Content-Type": "application/json"
1027
- }),
1028
- status: 200,
1029
- json: async function json() {
1030
- return {
1031
- success: true
1032
- };
1033
- }
1034
- };
1035
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1036
- await client.request(import_types.HttpMethod.Post, "/typed-array", {
1037
- body: uint8Array
1038
- });
1039
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body).toBe(uint8Array);
1040
- });
1041
- (0, import_vitest.it)("should handle relative paths", async function () {
1042
- var mockRes = {
1043
- ok: true,
1044
- headers: new Headers({
1045
- "Content-Type": "application/json"
1046
- }),
1047
- status: 200,
1048
- json: async function json() {
1049
- return {
1050
- success: true
1051
- };
1052
- }
1053
- };
1054
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1055
- await client.request(import_types.HttpMethod.Get, "relative/path", {});
1056
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/relative/path`, import_vitest.expect.any(Object));
1057
- });
1058
- (0, import_vitest.it)("should handle absolute paths", async function () {
1059
- var mockRes = {
1060
- ok: true,
1061
- headers: new Headers({
1062
- "Content-Type": "application/json"
1063
- }),
1064
- status: 200,
1065
- json: async function json() {
1066
- return {
1067
- success: true
1068
- };
1069
- }
1070
- };
1071
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1072
- await client.request(import_types.HttpMethod.Get, "/absolute/path", {});
1073
- (0, import_vitest.expect)(fetch).toHaveBeenCalledWith(`${baseURL}/absolute/path`, import_vitest.expect.any(Object));
1074
- });
1075
- (0, import_vitest.it)("should handle error response with _server_messages", async function () {
1076
- var errorPayload = {
1077
- _server_messages: "Server error messages",
1078
- exc: "Exception details",
1079
- message: "Error message"
1080
- };
1081
- global.fetch = import_vitest.vi.fn().mockResolvedValue({
1082
- ok: false,
1083
- status: 500,
1084
- statusText: "Internal Server Error",
1085
- headers: new Headers({
1086
- "Content-Type": "application/json"
1087
- }),
1088
- json: async function json() {
1089
- return errorPayload;
1090
- }
1091
- });
1092
- try {
1093
- await client.request(import_types.HttpMethod.Post, "/test", {});
1094
- } catch (error) {
1095
- (0, import_vitest.expect)(error).toBeInstanceOf(import_types.FrappeError);
1096
- (0, import_vitest.expect)(error.message).toBe("Error message");
1097
- }
1098
- });
1099
- (0, import_vitest.it)("should handle error response with exc", async function () {
1100
- var errorPayload = {
1101
- exc: "Exception details"
1102
- };
1103
- global.fetch = import_vitest.vi.fn().mockResolvedValue({
1104
- ok: false,
1105
- status: 500,
1106
- statusText: "Internal Server Error",
1107
- headers: new Headers({
1108
- "Content-Type": "application/json"
1109
- }),
1110
- json: async function json() {
1111
- return errorPayload;
1112
- }
1113
- });
1114
- try {
1115
- await client.request(import_types.HttpMethod.Post, "/test", {});
1116
- } catch (error) {
1117
- (0, import_vitest.expect)(error).toBeInstanceOf(import_types.FrappeError);
1118
- (0, import_vitest.expect)(error.message).toBe("Exception details");
1119
- }
1120
- });
1121
- (0, import_vitest.it)("should handle FormData with Blob values", async function () {
1122
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1123
- var blob = new Blob(["file content"], {
1124
- type: "text/plain"
1125
- });
1126
- var requestBody = {
1127
- field: "value",
1128
- file: blob
1129
- };
1130
- var mockRes = {
1131
- ok: true,
1132
- headers: new Headers({
1133
- "Content-Type": "application/json"
1134
- }),
1135
- status: 200,
1136
- json: async function json() {
1137
- return {
1138
- success: true
1139
- };
1140
- }
1141
- };
1142
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1143
- await client.request(import_types.HttpMethod.Post, "/upload", {
1144
- body: requestBody,
1145
- headers: {
1146
- "Content-Type": "multipart/form-data"
1147
- }
1148
- });
1149
- var calledBody = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body;
1150
- (0, import_vitest.expect)(calledBody).toBeInstanceOf(FormData);
1151
- });
1152
- (0, import_vitest.it)("should skip non-string values in URLSearchParams conversion", async function () {
1153
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1154
- var requestBody = {
1155
- field1: "value1",
1156
- field2: 123,
1157
- field3: null,
1158
- field4: void 0
1159
- };
1160
- var mockRes = {
1161
- ok: true,
1162
- headers: new Headers({
1163
- "Content-Type": "text/plain"
1164
- }),
1165
- status: 200,
1166
- text: async function text() {
1167
- return "success";
1168
- }
1169
- };
1170
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1171
- await client.request(import_types.HttpMethod.Post, "/test", {
1172
- body: requestBody,
1173
- headers: {
1174
- "Content-Type": "application/x-www-form-urlencoded"
1175
- }
1176
- });
1177
- var calledBody = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body;
1178
- (0, import_vitest.expect)(calledBody).toBe("field1=value1");
1179
- });
1180
- (0, import_vitest.it)("should handle ReadableStream body", async function () {
1181
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1182
- var stream = new ReadableStream();
1183
- var mockRes = {
1184
- ok: true,
1185
- headers: new Headers({
1186
- "Content-Type": "application/json"
1187
- }),
1188
- status: 200,
1189
- json: async function json() {
1190
- return {
1191
- success: true
1192
- };
1193
- }
1194
- };
1195
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1196
- await client.request(import_types.HttpMethod.Post, "/stream", {
1197
- body: stream
1198
- });
1199
- (0, import_vitest.expect)((_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.body).toBe(stream);
1200
- });
1201
- (0, import_vitest.it)("should handle global frappe csrf token", async function () {
1202
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1203
- Object.defineProperty(global, "document", {
1204
- value: {
1205
- cookie: ""
1206
- },
1207
- writable: true,
1208
- configurable: true
1209
- });
1210
- Object.defineProperty(global, "window", {
1211
- value: {},
1212
- writable: true,
1213
- configurable: true
1214
- });
1215
- Object.defineProperty(global, "frappe", {
1216
- value: {
1217
- csrf_token: "global-csrf-token"
1218
- },
1219
- writable: true,
1220
- configurable: true
1221
- });
1222
- var mockRes = {
1223
- ok: true,
1224
- headers: new Headers({
1225
- "Content-Type": "application/json"
1226
- }),
1227
- status: 200,
1228
- json: async function json() {
1229
- return {
1230
- success: true
1231
- };
1232
- }
1233
- };
1234
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1235
- await client.request(import_types.HttpMethod.Post, "/test", {});
1236
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
1237
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Frappe-CSRF-Token")).toBe("global-csrf-token");
1238
- Object.defineProperty(global, "document", {
1239
- value: void 0,
1240
- configurable: true
1241
- });
1242
- Object.defineProperty(global, "window", {
1243
- value: void 0,
1244
- configurable: true
1245
- });
1246
- Object.defineProperty(global, "frappe", {
1247
- value: void 0,
1248
- configurable: true
1249
- });
1250
- });
1251
- (0, import_vitest.it)("should prefer frappe-csrf-token cookie over csrf_token", async function () {
1252
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1253
- Object.defineProperty(global, "document", {
1254
- value: {
1255
- cookie: "frappe-csrf-token=preferred; csrf_token=fallback"
1256
- },
1257
- writable: true
1258
- });
1259
- Object.defineProperty(global, "window", {
1260
- value: {},
1261
- writable: true
1262
- });
1263
- var mockRes = {
1264
- ok: true,
1265
- headers: new Headers({
1266
- "Content-Type": "application/json"
1267
- }),
1268
- status: 200,
1269
- json: async function json() {
1270
- return {
1271
- success: true
1272
- };
1273
- }
1274
- };
1275
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1276
- await client.request(import_types.HttpMethod.Post, "/test", {});
1277
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
1278
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Frappe-CSRF-Token")).toBe("preferred");
1279
- Object.defineProperty(global, "document", {
1280
- value: void 0,
1281
- configurable: true
1282
- });
1283
- Object.defineProperty(global, "window", {
1284
- value: void 0,
1285
- configurable: true
1286
- });
1287
- });
1288
- (0, import_vitest.it)("should use csrf_token cookie as fallback", async function () {
1289
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1290
- Object.defineProperty(global, "document", {
1291
- value: {
1292
- cookie: "csrf_token=fallback"
1293
- },
1294
- writable: true
1295
- });
1296
- Object.defineProperty(global, "window", {
1297
- value: {},
1298
- writable: true
1299
- });
1300
- var mockRes = {
1301
- ok: true,
1302
- headers: new Headers({
1303
- "Content-Type": "application/json"
1304
- }),
1305
- status: 200,
1306
- json: async function json() {
1307
- return {
1308
- success: true
1309
- };
1310
- }
1311
- };
1312
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1313
- await client.request(import_types.HttpMethod.Post, "/test", {});
1314
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
1315
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Frappe-CSRF-Token")).toBe("fallback");
1316
- Object.defineProperty(global, "document", {
1317
- value: void 0,
1318
- configurable: true
1319
- });
1320
- Object.defineProperty(global, "window", {
1321
- value: void 0,
1322
- configurable: true
1323
- });
1324
- });
1325
- (0, import_vitest.it)("should not add CSRF token for GET requests", async function () {
1326
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1327
- Object.defineProperty(global, "document", {
1328
- value: {
1329
- cookie: "frappe-csrf-token=test-token"
1330
- },
1331
- writable: true
1332
- });
1333
- Object.defineProperty(global, "window", {
1334
- value: {},
1335
- writable: true
1336
- });
1337
- var mockRes = {
1338
- ok: true,
1339
- headers: new Headers({
1340
- "Content-Type": "application/json"
1341
- }),
1342
- status: 200,
1343
- json: async function json() {
1344
- return {
1345
- success: true
1346
- };
1347
- }
1348
- };
1349
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1350
- await client.request(import_types.HttpMethod.Get, "/test", {});
1351
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
1352
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Frappe-CSRF-Token")).toBeNull();
1353
- Object.defineProperty(global, "document", {
1354
- value: void 0,
1355
- configurable: true
1356
- });
1357
- Object.defineProperty(global, "window", {
1358
- value: void 0,
1359
- configurable: true
1360
- });
1361
- });
1362
- (0, import_vitest.it)("should handle cookie with special characters", async function () {
1363
- var _getMockFetch_mock_calls__, _getMockFetch_mock_calls_;
1364
- Object.defineProperty(global, "document", {
1365
- value: {
1366
- cookie: "frappe-csrf-token=%2Ftest%2Ftoken%3D"
1367
- },
1368
- writable: true
1369
- });
1370
- Object.defineProperty(global, "window", {
1371
- value: {},
1372
- writable: true
1373
- });
1374
- var mockRes = {
1375
- ok: true,
1376
- headers: new Headers({
1377
- "Content-Type": "application/json"
1378
- }),
1379
- status: 200,
1380
- json: async function json() {
1381
- return {
1382
- success: true
1383
- };
1384
- }
1385
- };
1386
- global.fetch = import_vitest.vi.fn().mockResolvedValue(mockRes);
1387
- await client.request(import_types.HttpMethod.Post, "/test", {});
1388
- var calledHeaders = (_getMockFetch_mock_calls_ = getMockFetch().mock.calls[0]) === null || _getMockFetch_mock_calls_ === void 0 ? void 0 : (_getMockFetch_mock_calls__ = _getMockFetch_mock_calls_[1]) === null || _getMockFetch_mock_calls__ === void 0 ? void 0 : _getMockFetch_mock_calls__.headers;
1389
- (0, import_vitest.expect)(calledHeaders === null || calledHeaders === void 0 ? void 0 : calledHeaders.get("X-Frappe-CSRF-Token")).toBe("/test/token=");
1390
- Object.defineProperty(global, "document", {
1391
- value: void 0,
1392
- configurable: true
1393
- });
1394
- Object.defineProperty(global, "window", {
1395
- value: void 0,
1396
- configurable: true
1397
- });
1398
- });
1399
- });
1400
- });
1401
- //# sourceMappingURL=http.spec.native.js.map