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