@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.
- package/README.md +38 -12
- package/dist/cjs/auth.cjs +1 -1
- package/dist/cjs/auth.native.js.map +1 -1
- package/dist/cjs/call.cjs +1 -1
- package/dist/cjs/call.native.js.map +1 -1
- package/dist/cjs/collection.cjs +18 -4
- package/dist/cjs/collection.native.js +18 -4
- package/dist/cjs/collection.native.js.map +1 -1
- package/dist/cjs/core/http.cjs +92 -9
- package/dist/cjs/core/http.native.js +96 -7
- package/dist/cjs/core/http.native.js.map +1 -1
- package/dist/cjs/db.cjs +7 -7
- package/dist/cjs/db.native.js +4 -4
- package/dist/cjs/db.native.js.map +1 -1
- package/dist/cjs/doctype.cjs +97 -39
- package/dist/cjs/doctype.native.js +116 -46
- package/dist/cjs/doctype.native.js.map +1 -1
- package/dist/cjs/file.cjs +1 -1
- package/dist/cjs/file.native.js.map +1 -1
- package/dist/cjs/fixtureDb.cjs +3 -2
- package/dist/cjs/fixtureDb.native.js +2 -1
- package/dist/cjs/fixtureDb.native.js.map +1 -1
- package/dist/cjs/frappeApp.cjs +15 -14
- package/dist/cjs/frappeApp.native.js +16 -14
- package/dist/cjs/frappeApp.native.js.map +1 -1
- package/dist/cjs/frappeReact.cjs +198 -18
- package/dist/cjs/frappeReact.native.js +241 -18
- package/dist/cjs/frappeReact.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -4
- package/dist/cjs/index.native.js +9 -4
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/pacer.cjs +2 -2
- package/dist/cjs/pacer.native.js +2 -2
- package/dist/cjs/pacer.native.js.map +1 -1
- package/dist/cjs/realtime.cjs +186 -46
- package/dist/cjs/realtime.native.js +268 -48
- package/dist/cjs/realtime.native.js.map +1 -1
- package/dist/cjs/sync/backfill.cjs +32 -27
- package/dist/cjs/sync/backfill.native.js +49 -43
- package/dist/cjs/sync/backfill.native.js.map +1 -1
- package/dist/cjs/sync/index.cjs +90 -24
- package/dist/cjs/sync/index.native.js +112 -10
- package/dist/cjs/sync/index.native.js.map +1 -1
- package/dist/cjs/sync/merge.cjs +0 -3
- package/dist/cjs/sync/merge.native.js +0 -3
- package/dist/cjs/sync/merge.native.js.map +1 -1
- package/dist/cjs/sync/mutationEngine.cjs +25 -19
- package/dist/cjs/sync/mutationEngine.native.js +16 -13
- package/dist/cjs/sync/mutationEngine.native.js.map +1 -1
- package/dist/cjs/sync/mutationJournal.cjs +9 -4
- package/dist/cjs/sync/mutationJournal.native.js +7 -4
- package/dist/cjs/sync/mutationJournal.native.js.map +1 -1
- package/dist/cjs/sync/normalizedCache.cjs +7 -3
- package/dist/cjs/sync/normalizedCache.native.js +7 -2
- package/dist/cjs/sync/normalizedCache.native.js.map +1 -1
- package/dist/cjs/sync/persistence.cjs +63 -31
- package/dist/cjs/sync/persistence.native.js +120 -63
- package/dist/cjs/sync/persistence.native.js.map +1 -1
- package/dist/cjs/sync/realtime.cjs +124 -13
- package/dist/cjs/sync/realtime.native.js +163 -20
- package/dist/cjs/sync/realtime.native.js.map +1 -1
- package/dist/cjs/sync/rehydration.cjs +16 -10
- package/dist/cjs/sync/rehydration.native.js +16 -14
- package/dist/cjs/sync/rehydration.native.js.map +1 -1
- package/dist/cjs/sync/storage.cjs +3 -3
- package/dist/cjs/sync/storage.native.js +1 -1
- package/dist/cjs/sync/storage.native.js.map +1 -1
- package/dist/cjs/sync/subscriptionManager.cjs +255 -65
- package/dist/cjs/sync/subscriptionManager.native.js +330 -93
- package/dist/cjs/sync/subscriptionManager.native.js.map +1 -1
- package/dist/cjs/sync/types.cjs +2 -0
- package/dist/cjs/sync/types.native.js +2 -0
- package/dist/cjs/sync/types.native.js.map +1 -1
- package/dist/cjs/sync/virtualPageManager.cjs +9 -9
- package/dist/cjs/sync/virtualPageManager.native.js +5 -9
- package/dist/cjs/sync/virtualPageManager.native.js.map +1 -1
- package/dist/cjs/useLiveQuery.cjs +52 -0
- package/dist/cjs/useLiveQuery.native.js +59 -0
- package/dist/cjs/useLiveQuery.native.js.map +1 -0
- package/dist/cjs/util.cjs +11 -2
- package/dist/cjs/util.native.js +16 -2
- package/dist/cjs/util.native.js.map +1 -1
- package/dist/esm/auth.mjs +1 -1
- package/dist/esm/auth.mjs.map +1 -1
- package/dist/esm/auth.native.js.map +1 -1
- package/dist/esm/call.mjs +1 -1
- package/dist/esm/call.mjs.map +1 -1
- package/dist/esm/call.native.js.map +1 -1
- package/dist/esm/collection.mjs +18 -4
- package/dist/esm/collection.mjs.map +1 -1
- package/dist/esm/collection.native.js +18 -4
- package/dist/esm/collection.native.js.map +1 -1
- package/dist/esm/core/http.mjs +93 -10
- package/dist/esm/core/http.mjs.map +1 -1
- package/dist/esm/core/http.native.js +97 -8
- package/dist/esm/core/http.native.js.map +1 -1
- package/dist/esm/db.mjs +7 -7
- package/dist/esm/db.mjs.map +1 -1
- package/dist/esm/db.native.js +4 -4
- package/dist/esm/db.native.js.map +1 -1
- package/dist/esm/doctype.mjs +96 -39
- package/dist/esm/doctype.mjs.map +1 -1
- package/dist/esm/doctype.native.js +115 -46
- package/dist/esm/doctype.native.js.map +1 -1
- package/dist/esm/file.mjs +1 -1
- package/dist/esm/file.mjs.map +1 -1
- package/dist/esm/file.native.js.map +1 -1
- package/dist/esm/fixtureDb.mjs +3 -2
- package/dist/esm/fixtureDb.mjs.map +1 -1
- package/dist/esm/fixtureDb.native.js +2 -1
- package/dist/esm/fixtureDb.native.js.map +1 -1
- package/dist/esm/frappeApp.mjs +15 -14
- package/dist/esm/frappeApp.mjs.map +1 -1
- package/dist/esm/frappeApp.native.js +16 -14
- package/dist/esm/frappeApp.native.js.map +1 -1
- package/dist/esm/frappeReact.mjs +197 -19
- package/dist/esm/frappeReact.mjs.map +1 -1
- package/dist/esm/frappeReact.native.js +240 -19
- package/dist/esm/frappeReact.native.js.map +1 -1
- package/dist/esm/index.mjs +5 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +5 -4
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/pacer.mjs +1 -1
- package/dist/esm/pacer.native.js +1 -1
- package/dist/esm/realtime.mjs +187 -47
- package/dist/esm/realtime.mjs.map +1 -1
- package/dist/esm/realtime.native.js +269 -49
- package/dist/esm/realtime.native.js.map +1 -1
- package/dist/esm/sync/backfill.mjs +32 -27
- package/dist/esm/sync/backfill.mjs.map +1 -1
- package/dist/esm/sync/backfill.native.js +49 -43
- package/dist/esm/sync/backfill.native.js.map +1 -1
- package/dist/esm/sync/index.mjs +90 -24
- package/dist/esm/sync/index.mjs.map +1 -1
- package/dist/esm/sync/index.native.js +112 -10
- package/dist/esm/sync/index.native.js.map +1 -1
- package/dist/esm/sync/merge.mjs +1 -1
- package/dist/esm/sync/merge.mjs.map +1 -1
- package/dist/esm/sync/merge.native.js +1 -1
- package/dist/esm/sync/merge.native.js.map +1 -1
- package/dist/esm/sync/mutationEngine.mjs +25 -19
- package/dist/esm/sync/mutationEngine.mjs.map +1 -1
- package/dist/esm/sync/mutationEngine.native.js +16 -13
- package/dist/esm/sync/mutationEngine.native.js.map +1 -1
- package/dist/esm/sync/mutationJournal.mjs +9 -4
- package/dist/esm/sync/mutationJournal.mjs.map +1 -1
- package/dist/esm/sync/mutationJournal.native.js +7 -4
- package/dist/esm/sync/mutationJournal.native.js.map +1 -1
- package/dist/esm/sync/normalizedCache.mjs +7 -3
- package/dist/esm/sync/normalizedCache.mjs.map +1 -1
- package/dist/esm/sync/normalizedCache.native.js +7 -2
- package/dist/esm/sync/normalizedCache.native.js.map +1 -1
- package/dist/esm/sync/persistence.mjs +64 -32
- package/dist/esm/sync/persistence.mjs.map +1 -1
- package/dist/esm/sync/persistence.native.js +121 -64
- package/dist/esm/sync/persistence.native.js.map +1 -1
- package/dist/esm/sync/realtime.mjs +124 -13
- package/dist/esm/sync/realtime.mjs.map +1 -1
- package/dist/esm/sync/realtime.native.js +163 -20
- package/dist/esm/sync/realtime.native.js.map +1 -1
- package/dist/esm/sync/rehydration.mjs +16 -10
- package/dist/esm/sync/rehydration.mjs.map +1 -1
- package/dist/esm/sync/rehydration.native.js +16 -14
- package/dist/esm/sync/rehydration.native.js.map +1 -1
- package/dist/esm/sync/storage.mjs +3 -3
- package/dist/esm/sync/storage.mjs.map +1 -1
- package/dist/esm/sync/storage.native.js +1 -1
- package/dist/esm/sync/storage.native.js.map +1 -1
- package/dist/esm/sync/subscriptionManager.mjs +255 -65
- package/dist/esm/sync/subscriptionManager.mjs.map +1 -1
- package/dist/esm/sync/subscriptionManager.native.js +330 -93
- package/dist/esm/sync/subscriptionManager.native.js.map +1 -1
- package/dist/esm/sync/types.mjs +2 -0
- package/dist/esm/sync/types.mjs.map +1 -1
- package/dist/esm/sync/types.native.js +2 -0
- package/dist/esm/sync/types.native.js.map +1 -1
- package/dist/esm/sync/virtualPageManager.mjs +9 -9
- package/dist/esm/sync/virtualPageManager.mjs.map +1 -1
- package/dist/esm/sync/virtualPageManager.native.js +5 -9
- package/dist/esm/sync/virtualPageManager.native.js.map +1 -1
- package/dist/esm/useLiveQuery.mjs +26 -0
- package/dist/esm/useLiveQuery.mjs.map +1 -0
- package/dist/esm/useLiveQuery.native.js +30 -0
- package/dist/esm/useLiveQuery.native.js.map +1 -0
- package/dist/esm/util.mjs +11 -3
- package/dist/esm/util.mjs.map +1 -1
- package/dist/esm/util.native.js +16 -3
- package/dist/esm/util.native.js.map +1 -1
- package/dist/jsx/auth.mjs +1 -1
- package/dist/jsx/auth.mjs.map +1 -1
- package/dist/jsx/auth.native.js.map +1 -1
- package/dist/jsx/call.mjs +1 -1
- package/dist/jsx/call.mjs.map +1 -1
- package/dist/jsx/call.native.js.map +1 -1
- package/dist/jsx/collection.mjs +18 -4
- package/dist/jsx/collection.mjs.map +1 -1
- package/dist/jsx/collection.native.js +18 -4
- package/dist/jsx/collection.native.js.map +1 -1
- package/dist/jsx/core/http.mjs +93 -10
- package/dist/jsx/core/http.mjs.map +1 -1
- package/dist/jsx/core/http.native.js +96 -7
- package/dist/jsx/core/http.native.js.map +1 -1
- package/dist/jsx/db.mjs +7 -7
- package/dist/jsx/db.mjs.map +1 -1
- package/dist/jsx/db.native.js +4 -4
- package/dist/jsx/db.native.js.map +1 -1
- package/dist/jsx/doctype.mjs +96 -39
- package/dist/jsx/doctype.mjs.map +1 -1
- package/dist/jsx/doctype.native.js +116 -46
- package/dist/jsx/doctype.native.js.map +1 -1
- package/dist/jsx/file.mjs +1 -1
- package/dist/jsx/file.mjs.map +1 -1
- package/dist/jsx/file.native.js.map +1 -1
- package/dist/jsx/fixtureDb.mjs +3 -2
- package/dist/jsx/fixtureDb.mjs.map +1 -1
- package/dist/jsx/fixtureDb.native.js +2 -1
- package/dist/jsx/fixtureDb.native.js.map +1 -1
- package/dist/jsx/frappeApp.mjs +15 -14
- package/dist/jsx/frappeApp.mjs.map +1 -1
- package/dist/jsx/frappeApp.native.js +16 -14
- package/dist/jsx/frappeApp.native.js.map +1 -1
- package/dist/jsx/frappeReact.mjs +197 -19
- package/dist/jsx/frappeReact.mjs.map +1 -1
- package/dist/jsx/frappeReact.native.js +241 -18
- package/dist/jsx/frappeReact.native.js.map +1 -1
- package/dist/jsx/index.js +5 -4
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +5 -4
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +9 -4
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/pacer.mjs +1 -1
- package/dist/jsx/pacer.native.js +2 -2
- package/dist/jsx/pacer.native.js.map +1 -1
- package/dist/jsx/realtime.mjs +187 -47
- package/dist/jsx/realtime.mjs.map +1 -1
- package/dist/jsx/realtime.native.js +268 -48
- package/dist/jsx/realtime.native.js.map +1 -1
- package/dist/jsx/sync/backfill.mjs +32 -27
- package/dist/jsx/sync/backfill.mjs.map +1 -1
- package/dist/jsx/sync/backfill.native.js +49 -43
- package/dist/jsx/sync/backfill.native.js.map +1 -1
- package/dist/jsx/sync/index.mjs +90 -24
- package/dist/jsx/sync/index.mjs.map +1 -1
- package/dist/jsx/sync/index.native.js +112 -10
- package/dist/jsx/sync/index.native.js.map +1 -1
- package/dist/jsx/sync/merge.mjs +1 -1
- package/dist/jsx/sync/merge.mjs.map +1 -1
- package/dist/jsx/sync/merge.native.js +0 -3
- package/dist/jsx/sync/merge.native.js.map +1 -1
- package/dist/jsx/sync/mutationEngine.mjs +25 -19
- package/dist/jsx/sync/mutationEngine.mjs.map +1 -1
- package/dist/jsx/sync/mutationEngine.native.js +16 -13
- package/dist/jsx/sync/mutationEngine.native.js.map +1 -1
- package/dist/jsx/sync/mutationJournal.mjs +9 -4
- package/dist/jsx/sync/mutationJournal.mjs.map +1 -1
- package/dist/jsx/sync/mutationJournal.native.js +7 -4
- package/dist/jsx/sync/mutationJournal.native.js.map +1 -1
- package/dist/jsx/sync/normalizedCache.mjs +7 -3
- package/dist/jsx/sync/normalizedCache.mjs.map +1 -1
- package/dist/jsx/sync/normalizedCache.native.js +7 -2
- package/dist/jsx/sync/normalizedCache.native.js.map +1 -1
- package/dist/jsx/sync/persistence.mjs +64 -32
- package/dist/jsx/sync/persistence.mjs.map +1 -1
- package/dist/jsx/sync/persistence.native.js +120 -63
- package/dist/jsx/sync/persistence.native.js.map +1 -1
- package/dist/jsx/sync/realtime.mjs +124 -13
- package/dist/jsx/sync/realtime.mjs.map +1 -1
- package/dist/jsx/sync/realtime.native.js +163 -20
- package/dist/jsx/sync/realtime.native.js.map +1 -1
- package/dist/jsx/sync/rehydration.mjs +16 -10
- package/dist/jsx/sync/rehydration.mjs.map +1 -1
- package/dist/jsx/sync/rehydration.native.js +16 -14
- package/dist/jsx/sync/rehydration.native.js.map +1 -1
- package/dist/jsx/sync/storage.mjs +3 -3
- package/dist/jsx/sync/storage.mjs.map +1 -1
- package/dist/jsx/sync/storage.native.js +1 -1
- package/dist/jsx/sync/storage.native.js.map +1 -1
- package/dist/jsx/sync/subscriptionManager.mjs +255 -65
- package/dist/jsx/sync/subscriptionManager.mjs.map +1 -1
- package/dist/jsx/sync/subscriptionManager.native.js +330 -93
- package/dist/jsx/sync/subscriptionManager.native.js.map +1 -1
- package/dist/jsx/sync/types.mjs +2 -0
- package/dist/jsx/sync/types.mjs.map +1 -1
- package/dist/jsx/sync/types.native.js +2 -0
- package/dist/jsx/sync/types.native.js.map +1 -1
- package/dist/jsx/sync/virtualPageManager.mjs +9 -9
- package/dist/jsx/sync/virtualPageManager.mjs.map +1 -1
- package/dist/jsx/sync/virtualPageManager.native.js +5 -9
- package/dist/jsx/sync/virtualPageManager.native.js.map +1 -1
- package/dist/jsx/useLiveQuery.mjs +26 -0
- package/dist/jsx/useLiveQuery.mjs.map +1 -0
- package/dist/jsx/useLiveQuery.native.js +59 -0
- package/dist/jsx/useLiveQuery.native.js.map +1 -0
- package/dist/jsx/util.mjs +11 -3
- package/dist/jsx/util.mjs.map +1 -1
- package/dist/jsx/util.native.js +16 -2
- package/dist/jsx/util.native.js.map +1 -1
- package/package.json +20 -17
- package/src/auth.ts +5 -1
- package/src/call.ts +5 -1
- package/src/collection.spec.ts +55 -0
- package/src/collection.ts +33 -4
- package/src/core/http.spec.ts +66 -0
- package/src/core/http.ts +115 -9
- package/src/core/httpNative.spec.ts +234 -0
- package/src/core/types.ts +2 -0
- package/src/db.spec.ts +91 -51
- package/src/db.ts +27 -8
- package/src/doctype.spec.ts +247 -39
- package/src/doctype.ts +203 -53
- package/src/file.ts +5 -1
- package/src/fixtureDb.ts +13 -2
- package/src/frappeApp.ts +18 -19
- package/src/frappeReact.spec.ts +565 -1
- package/src/frappeReact.ts +446 -38
- package/src/frappeReactLiveQueryGc.spec.ts +320 -0
- package/src/frappeReactNative.spec.ts +65 -0
- package/src/index.ts +10 -9
- package/src/pacer.ts +2 -2
- package/src/realtime.spec.ts +464 -20
- package/src/realtime.ts +284 -46
- package/src/sync/backfill.spec.ts +43 -0
- package/src/sync/backfill.ts +59 -39
- package/src/sync/debug.spec.ts +36 -0
- package/src/sync/filterValidation.spec.ts +197 -0
- package/src/sync/index.ts +98 -7
- package/src/sync/merge.ts +3 -3
- package/src/sync/mutationEngine.spec.ts +36 -4
- package/src/sync/mutationEngine.ts +30 -11
- package/src/sync/mutationJournal.ts +18 -4
- package/src/sync/normalizedCache.spec.ts +102 -0
- package/src/sync/normalizedCache.ts +19 -3
- package/src/sync/offlineRestore.spec.ts +423 -0
- package/src/sync/persistence.spec.ts +39 -7
- package/src/sync/persistence.ts +90 -18
- package/src/sync/persistenceGjs.spec.ts +143 -0
- package/src/sync/persistenceNative.spec.ts +139 -0
- package/src/sync/realtime.spec.ts +18 -1
- package/src/sync/realtime.ts +161 -13
- package/src/sync/rehydration.ts +23 -5
- package/src/sync/storage.ts +5 -4
- package/src/sync/subscriptionManager.spec.ts +94 -0
- package/src/sync/subscriptionManager.ts +304 -82
- package/src/sync/syncModule.spec.ts +137 -0
- package/src/sync/types.ts +39 -0
- package/src/sync/virtualPageManager.ts +8 -4
- package/src/useLiveQuery.ts +58 -0
- package/src/util.spec.ts +35 -4
- package/src/util.ts +37 -2
- package/types/auth.d.ts +13 -0
- package/types/auth.d.ts.map +1 -0
- package/types/call.d.ts +10 -0
- package/types/call.d.ts.map +1 -0
- package/types/collection.d.ts +127 -0
- package/types/collection.d.ts.map +1 -0
- package/types/common/types.d.ts +35 -0
- package/types/common/types.d.ts.map +1 -0
- package/types/core/http.d.ts +86 -0
- package/types/core/http.d.ts.map +1 -0
- package/types/core/types.d.ts +74 -0
- package/types/core/types.d.ts.map +1 -0
- package/types/core/wire.d.ts +405 -0
- package/types/core/wire.d.ts.map +1 -0
- package/types/db.d.ts +244 -0
- package/types/db.d.ts.map +1 -0
- package/types/devtools/FrappeDevtoolsPanel.d.ts +7 -0
- package/types/devtools/FrappeDevtoolsPanel.d.ts.map +1 -0
- package/types/devtools/index.d.ts +4 -0
- package/types/devtools/index.d.ts.map +1 -0
- package/types/devtools/plugin.d.ts +9 -0
- package/types/devtools/plugin.d.ts.map +1 -0
- package/types/devtools/theme.d.ts +15 -0
- package/types/devtools/theme.d.ts.map +1 -0
- package/types/doctype.d.ts +256 -0
- package/types/doctype.d.ts.map +1 -0
- package/types/file.d.ts +15 -0
- package/types/file.d.ts.map +1 -0
- package/types/fixtureDb.d.ts +76 -0
- package/types/fixtureDb.d.ts.map +1 -0
- package/types/fixtures.d.ts +55 -0
- package/types/fixtures.d.ts.map +1 -0
- package/types/frappeApp.d.ts +45 -0
- package/types/frappeApp.d.ts.map +1 -0
- package/types/frappeReact.d.ts +270 -0
- package/types/frappeReact.d.ts.map +1 -0
- package/types/index.d.ts +44 -0
- package/types/index.d.ts.map +1 -0
- package/types/optimistic.d.ts +38 -0
- package/types/optimistic.d.ts.map +1 -0
- package/types/pacer.d.ts +193 -0
- package/types/pacer.d.ts.map +1 -0
- package/types/plugin/index.d.ts +11 -0
- package/types/plugin/index.d.ts.map +1 -0
- package/types/realtime.d.ts +121 -0
- package/types/realtime.d.ts.map +1 -0
- package/types/sync/backfill.d.ts +60 -0
- package/types/sync/backfill.d.ts.map +1 -0
- package/types/sync/filters.d.ts +101 -0
- package/types/sync/filters.d.ts.map +1 -0
- package/types/sync/index.d.ts +181 -0
- package/types/sync/index.d.ts.map +1 -0
- package/types/sync/merge.d.ts +59 -0
- package/types/sync/merge.d.ts.map +1 -0
- package/types/sync/mutationEngine.d.ts +117 -0
- package/types/sync/mutationEngine.d.ts.map +1 -0
- package/types/sync/mutationJournal.d.ts +60 -0
- package/types/sync/mutationJournal.d.ts.map +1 -0
- package/types/sync/normalizedCache.d.ts +59 -0
- package/types/sync/normalizedCache.d.ts.map +1 -0
- package/types/sync/persistence.d.ts +185 -0
- package/types/sync/persistence.d.ts.map +1 -0
- package/types/sync/realtime.d.ts +121 -0
- package/types/sync/realtime.d.ts.map +1 -0
- package/types/sync/rehydration.d.ts +109 -0
- package/types/sync/rehydration.d.ts.map +1 -0
- package/types/sync/storage.d.ts +65 -0
- package/types/sync/storage.d.ts.map +1 -0
- package/types/sync/subscriptionManager.d.ts +161 -0
- package/types/sync/subscriptionManager.d.ts.map +1 -0
- package/types/sync/types.d.ts +435 -0
- package/types/sync/types.d.ts.map +1 -0
- package/types/sync/virtualPageManager.d.ts +190 -0
- package/types/sync/virtualPageManager.d.ts.map +1 -0
- package/types/useLiveQuery.d.ts +16 -0
- package/types/useLiveQuery.d.ts.map +1 -0
- package/types/util.d.ts +24 -0
- package/types/util.d.ts.map +1 -0
- package/dist/cjs/auth.spec.cjs +0 -322
- package/dist/cjs/auth.spec.native.js +0 -329
- package/dist/cjs/auth.spec.native.js.map +0 -1
- package/dist/cjs/call.spec.cjs +0 -427
- package/dist/cjs/call.spec.native.js +0 -430
- package/dist/cjs/call.spec.native.js.map +0 -1
- package/dist/cjs/collection.spec.cjs +0 -186
- package/dist/cjs/collection.spec.native.js +0 -216
- package/dist/cjs/collection.spec.native.js.map +0 -1
- package/dist/cjs/common/types.spec.cjs +0 -266
- package/dist/cjs/common/types.spec.native.js +0 -271
- package/dist/cjs/common/types.spec.native.js.map +0 -1
- package/dist/cjs/core/http.spec.cjs +0 -1259
- package/dist/cjs/core/http.spec.native.js +0 -1401
- package/dist/cjs/core/http.spec.native.js.map +0 -1
- package/dist/cjs/core/wire.spec.cjs +0 -478
- package/dist/cjs/core/wire.spec.native.js +0 -482
- package/dist/cjs/core/wire.spec.native.js.map +0 -1
- package/dist/cjs/db.spec.cjs +0 -862
- package/dist/cjs/db.spec.native.js +0 -865
- package/dist/cjs/db.spec.native.js.map +0 -1
- package/dist/cjs/doctype.spec.cjs +0 -460
- package/dist/cjs/doctype.spec.native.js +0 -538
- package/dist/cjs/doctype.spec.native.js.map +0 -1
- package/dist/cjs/file.spec.cjs +0 -315
- package/dist/cjs/file.spec.native.js +0 -342
- package/dist/cjs/file.spec.native.js.map +0 -1
- package/dist/cjs/frappeApp.spec.cjs +0 -306
- package/dist/cjs/frappeApp.spec.native.js +0 -308
- package/dist/cjs/frappeApp.spec.native.js.map +0 -1
- package/dist/cjs/frappeReact.spec.cjs +0 -531
- package/dist/cjs/frappeReact.spec.native.js +0 -670
- package/dist/cjs/frappeReact.spec.native.js.map +0 -1
- package/dist/cjs/optimistic.spec.cjs +0 -11
- package/dist/cjs/optimistic.spec.native.js +0 -19
- package/dist/cjs/optimistic.spec.native.js.map +0 -1
- package/dist/cjs/pacer.spec.cjs +0 -470
- package/dist/cjs/pacer.spec.native.js +0 -537
- package/dist/cjs/pacer.spec.native.js.map +0 -1
- package/dist/cjs/realtime.spec.cjs +0 -326
- package/dist/cjs/realtime.spec.native.js +0 -392
- package/dist/cjs/realtime.spec.native.js.map +0 -1
- package/dist/cjs/sync/backfill.spec.cjs +0 -586
- package/dist/cjs/sync/backfill.spec.native.js +0 -712
- package/dist/cjs/sync/backfill.spec.native.js.map +0 -1
- package/dist/cjs/sync/debug.spec.cjs +0 -125
- package/dist/cjs/sync/debug.spec.native.js +0 -133
- package/dist/cjs/sync/debug.spec.native.js.map +0 -1
- package/dist/cjs/sync/filters.spec.cjs +0 -168
- package/dist/cjs/sync/filters.spec.native.js +0 -173
- package/dist/cjs/sync/filters.spec.native.js.map +0 -1
- package/dist/cjs/sync/merge.spec.cjs +0 -908
- package/dist/cjs/sync/merge.spec.native.js +0 -937
- package/dist/cjs/sync/merge.spec.native.js.map +0 -1
- package/dist/cjs/sync/multiOrderBy.spec.cjs +0 -165
- package/dist/cjs/sync/multiOrderBy.spec.native.js +0 -229
- package/dist/cjs/sync/multiOrderBy.spec.native.js.map +0 -1
- package/dist/cjs/sync/mutationEngine.spec.cjs +0 -1158
- package/dist/cjs/sync/mutationEngine.spec.native.js +0 -1173
- package/dist/cjs/sync/mutationEngine.spec.native.js.map +0 -1
- package/dist/cjs/sync/mutationJournal.spec.cjs +0 -330
- package/dist/cjs/sync/mutationJournal.spec.native.js +0 -333
- package/dist/cjs/sync/mutationJournal.spec.native.js.map +0 -1
- package/dist/cjs/sync/mutations.spec.cjs +0 -327
- package/dist/cjs/sync/mutations.spec.native.js +0 -330
- package/dist/cjs/sync/mutations.spec.native.js.map +0 -1
- package/dist/cjs/sync/normalizedCache.spec.cjs +0 -302
- package/dist/cjs/sync/normalizedCache.spec.native.js +0 -311
- package/dist/cjs/sync/normalizedCache.spec.native.js.map +0 -1
- package/dist/cjs/sync/persistence.spec.cjs +0 -562
- package/dist/cjs/sync/persistence.spec.native.js +0 -572
- package/dist/cjs/sync/persistence.spec.native.js.map +0 -1
- package/dist/cjs/sync/realtime.spec.cjs +0 -499
- package/dist/cjs/sync/realtime.spec.native.js +0 -512
- package/dist/cjs/sync/realtime.spec.native.js.map +0 -1
- package/dist/cjs/sync/rehydration.spec.cjs +0 -731
- package/dist/cjs/sync/rehydration.spec.native.js +0 -736
- package/dist/cjs/sync/rehydration.spec.native.js.map +0 -1
- package/dist/cjs/sync/storage.spec.cjs +0 -446
- package/dist/cjs/sync/storage.spec.native.js +0 -470
- package/dist/cjs/sync/storage.spec.native.js.map +0 -1
- package/dist/cjs/sync/subscriptionManager.spec.cjs +0 -1102
- package/dist/cjs/sync/subscriptionManager.spec.native.js +0 -1136
- package/dist/cjs/sync/subscriptionManager.spec.native.js.map +0 -1
- package/dist/cjs/sync/subscriptions.spec.cjs +0 -937
- package/dist/cjs/sync/subscriptions.spec.native.js +0 -969
- package/dist/cjs/sync/subscriptions.spec.native.js.map +0 -1
- package/dist/cjs/sync/syncModule.spec.cjs +0 -206
- package/dist/cjs/sync/syncModule.spec.native.js +0 -222
- package/dist/cjs/sync/syncModule.spec.native.js.map +0 -1
- package/dist/cjs/sync/types.spec.cjs +0 -246
- package/dist/cjs/sync/types.spec.native.js +0 -256
- package/dist/cjs/sync/types.spec.native.js.map +0 -1
- package/dist/cjs/sync/virtualPageManager.spec.cjs +0 -801
- package/dist/cjs/sync/virtualPageManager.spec.native.js +0 -873
- package/dist/cjs/sync/virtualPageManager.spec.native.js.map +0 -1
- package/dist/cjs/util.spec.cjs +0 -43
- package/dist/cjs/util.spec.native.js +0 -48
- package/dist/cjs/util.spec.native.js.map +0 -1
- package/dist/esm/auth.spec.mjs +0 -323
- package/dist/esm/auth.spec.mjs.map +0 -1
- package/dist/esm/auth.spec.native.js +0 -327
- package/dist/esm/auth.spec.native.js.map +0 -1
- package/dist/esm/call.spec.mjs +0 -428
- package/dist/esm/call.spec.mjs.map +0 -1
- package/dist/esm/call.spec.native.js +0 -428
- package/dist/esm/call.spec.native.js.map +0 -1
- package/dist/esm/collection.spec.mjs +0 -187
- package/dist/esm/collection.spec.mjs.map +0 -1
- package/dist/esm/collection.spec.native.js +0 -214
- package/dist/esm/collection.spec.native.js.map +0 -1
- package/dist/esm/common/types.spec.mjs +0 -267
- package/dist/esm/common/types.spec.mjs.map +0 -1
- package/dist/esm/common/types.spec.native.js +0 -269
- package/dist/esm/common/types.spec.native.js.map +0 -1
- package/dist/esm/core/http.spec.mjs +0 -1260
- package/dist/esm/core/http.spec.mjs.map +0 -1
- package/dist/esm/core/http.spec.native.js +0 -1399
- package/dist/esm/core/http.spec.native.js.map +0 -1
- package/dist/esm/core/wire.spec.mjs +0 -479
- package/dist/esm/core/wire.spec.mjs.map +0 -1
- package/dist/esm/core/wire.spec.native.js +0 -480
- package/dist/esm/core/wire.spec.native.js.map +0 -1
- package/dist/esm/db.spec.mjs +0 -863
- package/dist/esm/db.spec.mjs.map +0 -1
- package/dist/esm/db.spec.native.js +0 -863
- package/dist/esm/db.spec.native.js.map +0 -1
- package/dist/esm/doctype.spec.mjs +0 -461
- package/dist/esm/doctype.spec.mjs.map +0 -1
- package/dist/esm/doctype.spec.native.js +0 -536
- package/dist/esm/doctype.spec.native.js.map +0 -1
- package/dist/esm/file.spec.mjs +0 -316
- package/dist/esm/file.spec.mjs.map +0 -1
- package/dist/esm/file.spec.native.js +0 -340
- package/dist/esm/file.spec.native.js.map +0 -1
- package/dist/esm/frappeApp.spec.mjs +0 -307
- package/dist/esm/frappeApp.spec.mjs.map +0 -1
- package/dist/esm/frappeApp.spec.native.js +0 -306
- package/dist/esm/frappeApp.spec.native.js.map +0 -1
- package/dist/esm/frappeReact.spec.mjs +0 -532
- package/dist/esm/frappeReact.spec.mjs.map +0 -1
- package/dist/esm/frappeReact.spec.native.js +0 -668
- package/dist/esm/frappeReact.spec.native.js.map +0 -1
- package/dist/esm/optimistic.spec.mjs +0 -12
- package/dist/esm/optimistic.spec.mjs.map +0 -1
- package/dist/esm/optimistic.spec.native.js +0 -17
- package/dist/esm/optimistic.spec.native.js.map +0 -1
- package/dist/esm/pacer.spec.mjs +0 -447
- package/dist/esm/pacer.spec.mjs.map +0 -1
- package/dist/esm/pacer.spec.native.js +0 -511
- package/dist/esm/pacer.spec.native.js.map +0 -1
- package/dist/esm/realtime.spec.mjs +0 -327
- package/dist/esm/realtime.spec.mjs.map +0 -1
- package/dist/esm/realtime.spec.native.js +0 -390
- package/dist/esm/realtime.spec.native.js.map +0 -1
- package/dist/esm/sync/backfill.spec.mjs +0 -563
- package/dist/esm/sync/backfill.spec.mjs.map +0 -1
- package/dist/esm/sync/backfill.spec.native.js +0 -686
- package/dist/esm/sync/backfill.spec.native.js.map +0 -1
- package/dist/esm/sync/debug.spec.mjs +0 -102
- package/dist/esm/sync/debug.spec.mjs.map +0 -1
- package/dist/esm/sync/debug.spec.native.js +0 -107
- package/dist/esm/sync/debug.spec.native.js.map +0 -1
- package/dist/esm/sync/filters.spec.mjs +0 -169
- package/dist/esm/sync/filters.spec.mjs.map +0 -1
- package/dist/esm/sync/filters.spec.native.js +0 -171
- package/dist/esm/sync/filters.spec.native.js.map +0 -1
- package/dist/esm/sync/merge.spec.mjs +0 -909
- package/dist/esm/sync/merge.spec.mjs.map +0 -1
- package/dist/esm/sync/merge.spec.native.js +0 -935
- package/dist/esm/sync/merge.spec.native.js.map +0 -1
- package/dist/esm/sync/multiOrderBy.spec.mjs +0 -166
- package/dist/esm/sync/multiOrderBy.spec.mjs.map +0 -1
- package/dist/esm/sync/multiOrderBy.spec.native.js +0 -227
- package/dist/esm/sync/multiOrderBy.spec.native.js.map +0 -1
- package/dist/esm/sync/mutationEngine.spec.mjs +0 -1159
- package/dist/esm/sync/mutationEngine.spec.mjs.map +0 -1
- package/dist/esm/sync/mutationEngine.spec.native.js +0 -1171
- package/dist/esm/sync/mutationEngine.spec.native.js.map +0 -1
- package/dist/esm/sync/mutationJournal.spec.mjs +0 -331
- package/dist/esm/sync/mutationJournal.spec.mjs.map +0 -1
- package/dist/esm/sync/mutationJournal.spec.native.js +0 -331
- package/dist/esm/sync/mutationJournal.spec.native.js.map +0 -1
- package/dist/esm/sync/mutations.spec.mjs +0 -328
- package/dist/esm/sync/mutations.spec.mjs.map +0 -1
- package/dist/esm/sync/mutations.spec.native.js +0 -328
- package/dist/esm/sync/mutations.spec.native.js.map +0 -1
- package/dist/esm/sync/normalizedCache.spec.mjs +0 -303
- package/dist/esm/sync/normalizedCache.spec.mjs.map +0 -1
- package/dist/esm/sync/normalizedCache.spec.native.js +0 -309
- package/dist/esm/sync/normalizedCache.spec.native.js.map +0 -1
- package/dist/esm/sync/persistence.spec.mjs +0 -563
- package/dist/esm/sync/persistence.spec.mjs.map +0 -1
- package/dist/esm/sync/persistence.spec.native.js +0 -570
- package/dist/esm/sync/persistence.spec.native.js.map +0 -1
- package/dist/esm/sync/realtime.spec.mjs +0 -500
- package/dist/esm/sync/realtime.spec.mjs.map +0 -1
- package/dist/esm/sync/realtime.spec.native.js +0 -510
- package/dist/esm/sync/realtime.spec.native.js.map +0 -1
- package/dist/esm/sync/rehydration.spec.mjs +0 -732
- package/dist/esm/sync/rehydration.spec.mjs.map +0 -1
- package/dist/esm/sync/rehydration.spec.native.js +0 -734
- package/dist/esm/sync/rehydration.spec.native.js.map +0 -1
- package/dist/esm/sync/storage.spec.mjs +0 -423
- package/dist/esm/sync/storage.spec.mjs.map +0 -1
- package/dist/esm/sync/storage.spec.native.js +0 -444
- package/dist/esm/sync/storage.spec.native.js.map +0 -1
- package/dist/esm/sync/subscriptionManager.spec.mjs +0 -1079
- package/dist/esm/sync/subscriptionManager.spec.mjs.map +0 -1
- package/dist/esm/sync/subscriptionManager.spec.native.js +0 -1110
- package/dist/esm/sync/subscriptionManager.spec.native.js.map +0 -1
- package/dist/esm/sync/subscriptions.spec.mjs +0 -914
- package/dist/esm/sync/subscriptions.spec.mjs.map +0 -1
- package/dist/esm/sync/subscriptions.spec.native.js +0 -943
- package/dist/esm/sync/subscriptions.spec.native.js.map +0 -1
- package/dist/esm/sync/syncModule.spec.mjs +0 -207
- package/dist/esm/sync/syncModule.spec.mjs.map +0 -1
- package/dist/esm/sync/syncModule.spec.native.js +0 -220
- package/dist/esm/sync/syncModule.spec.native.js.map +0 -1
- package/dist/esm/sync/types.spec.mjs +0 -247
- package/dist/esm/sync/types.spec.mjs.map +0 -1
- package/dist/esm/sync/types.spec.native.js +0 -254
- package/dist/esm/sync/types.spec.native.js.map +0 -1
- package/dist/esm/sync/virtualPageManager.spec.mjs +0 -802
- package/dist/esm/sync/virtualPageManager.spec.mjs.map +0 -1
- package/dist/esm/sync/virtualPageManager.spec.native.js +0 -871
- package/dist/esm/sync/virtualPageManager.spec.native.js.map +0 -1
- package/dist/esm/util.spec.mjs +0 -20
- package/dist/esm/util.spec.mjs.map +0 -1
- package/dist/esm/util.spec.native.js +0 -22
- package/dist/esm/util.spec.native.js.map +0 -1
- package/dist/jsx/auth.spec.mjs +0 -323
- package/dist/jsx/auth.spec.mjs.map +0 -1
- package/dist/jsx/auth.spec.native.js +0 -329
- package/dist/jsx/auth.spec.native.js.map +0 -1
- package/dist/jsx/call.spec.mjs +0 -428
- package/dist/jsx/call.spec.mjs.map +0 -1
- package/dist/jsx/call.spec.native.js +0 -430
- package/dist/jsx/call.spec.native.js.map +0 -1
- package/dist/jsx/collection.spec.mjs +0 -187
- package/dist/jsx/collection.spec.mjs.map +0 -1
- package/dist/jsx/collection.spec.native.js +0 -216
- package/dist/jsx/collection.spec.native.js.map +0 -1
- package/dist/jsx/common/types.spec.mjs +0 -267
- package/dist/jsx/common/types.spec.mjs.map +0 -1
- package/dist/jsx/common/types.spec.native.js +0 -271
- package/dist/jsx/common/types.spec.native.js.map +0 -1
- package/dist/jsx/core/http.spec.mjs +0 -1260
- package/dist/jsx/core/http.spec.mjs.map +0 -1
- package/dist/jsx/core/http.spec.native.js +0 -1401
- package/dist/jsx/core/http.spec.native.js.map +0 -1
- package/dist/jsx/core/wire.spec.mjs +0 -479
- package/dist/jsx/core/wire.spec.mjs.map +0 -1
- package/dist/jsx/core/wire.spec.native.js +0 -482
- package/dist/jsx/core/wire.spec.native.js.map +0 -1
- package/dist/jsx/db.spec.mjs +0 -863
- package/dist/jsx/db.spec.mjs.map +0 -1
- package/dist/jsx/db.spec.native.js +0 -865
- package/dist/jsx/db.spec.native.js.map +0 -1
- package/dist/jsx/doctype.spec.mjs +0 -461
- package/dist/jsx/doctype.spec.mjs.map +0 -1
- package/dist/jsx/doctype.spec.native.js +0 -538
- package/dist/jsx/doctype.spec.native.js.map +0 -1
- package/dist/jsx/file.spec.mjs +0 -316
- package/dist/jsx/file.spec.mjs.map +0 -1
- package/dist/jsx/file.spec.native.js +0 -342
- package/dist/jsx/file.spec.native.js.map +0 -1
- package/dist/jsx/frappeApp.spec.mjs +0 -307
- package/dist/jsx/frappeApp.spec.mjs.map +0 -1
- package/dist/jsx/frappeApp.spec.native.js +0 -308
- package/dist/jsx/frappeApp.spec.native.js.map +0 -1
- package/dist/jsx/frappeReact.spec.mjs +0 -532
- package/dist/jsx/frappeReact.spec.mjs.map +0 -1
- package/dist/jsx/frappeReact.spec.native.js +0 -670
- package/dist/jsx/frappeReact.spec.native.js.map +0 -1
- package/dist/jsx/optimistic.spec.mjs +0 -12
- package/dist/jsx/optimistic.spec.mjs.map +0 -1
- package/dist/jsx/optimistic.spec.native.js +0 -19
- package/dist/jsx/optimistic.spec.native.js.map +0 -1
- package/dist/jsx/pacer.spec.mjs +0 -447
- package/dist/jsx/pacer.spec.mjs.map +0 -1
- package/dist/jsx/pacer.spec.native.js +0 -537
- package/dist/jsx/pacer.spec.native.js.map +0 -1
- package/dist/jsx/realtime.spec.mjs +0 -327
- package/dist/jsx/realtime.spec.mjs.map +0 -1
- package/dist/jsx/realtime.spec.native.js +0 -392
- package/dist/jsx/realtime.spec.native.js.map +0 -1
- package/dist/jsx/sync/backfill.spec.mjs +0 -563
- package/dist/jsx/sync/backfill.spec.mjs.map +0 -1
- package/dist/jsx/sync/backfill.spec.native.js +0 -712
- package/dist/jsx/sync/backfill.spec.native.js.map +0 -1
- package/dist/jsx/sync/debug.spec.mjs +0 -102
- package/dist/jsx/sync/debug.spec.mjs.map +0 -1
- package/dist/jsx/sync/debug.spec.native.js +0 -133
- package/dist/jsx/sync/debug.spec.native.js.map +0 -1
- package/dist/jsx/sync/filters.spec.mjs +0 -169
- package/dist/jsx/sync/filters.spec.mjs.map +0 -1
- package/dist/jsx/sync/filters.spec.native.js +0 -173
- package/dist/jsx/sync/filters.spec.native.js.map +0 -1
- package/dist/jsx/sync/merge.spec.mjs +0 -909
- package/dist/jsx/sync/merge.spec.mjs.map +0 -1
- package/dist/jsx/sync/merge.spec.native.js +0 -937
- package/dist/jsx/sync/merge.spec.native.js.map +0 -1
- package/dist/jsx/sync/multiOrderBy.spec.mjs +0 -166
- package/dist/jsx/sync/multiOrderBy.spec.mjs.map +0 -1
- package/dist/jsx/sync/multiOrderBy.spec.native.js +0 -229
- package/dist/jsx/sync/multiOrderBy.spec.native.js.map +0 -1
- package/dist/jsx/sync/mutationEngine.spec.mjs +0 -1159
- package/dist/jsx/sync/mutationEngine.spec.mjs.map +0 -1
- package/dist/jsx/sync/mutationEngine.spec.native.js +0 -1173
- package/dist/jsx/sync/mutationEngine.spec.native.js.map +0 -1
- package/dist/jsx/sync/mutationJournal.spec.mjs +0 -331
- package/dist/jsx/sync/mutationJournal.spec.mjs.map +0 -1
- package/dist/jsx/sync/mutationJournal.spec.native.js +0 -333
- package/dist/jsx/sync/mutationJournal.spec.native.js.map +0 -1
- package/dist/jsx/sync/mutations.spec.mjs +0 -328
- package/dist/jsx/sync/mutations.spec.mjs.map +0 -1
- package/dist/jsx/sync/mutations.spec.native.js +0 -330
- package/dist/jsx/sync/mutations.spec.native.js.map +0 -1
- package/dist/jsx/sync/normalizedCache.spec.mjs +0 -303
- package/dist/jsx/sync/normalizedCache.spec.mjs.map +0 -1
- package/dist/jsx/sync/normalizedCache.spec.native.js +0 -311
- package/dist/jsx/sync/normalizedCache.spec.native.js.map +0 -1
- package/dist/jsx/sync/persistence.spec.mjs +0 -563
- package/dist/jsx/sync/persistence.spec.mjs.map +0 -1
- package/dist/jsx/sync/persistence.spec.native.js +0 -572
- package/dist/jsx/sync/persistence.spec.native.js.map +0 -1
- package/dist/jsx/sync/realtime.spec.mjs +0 -500
- package/dist/jsx/sync/realtime.spec.mjs.map +0 -1
- package/dist/jsx/sync/realtime.spec.native.js +0 -512
- package/dist/jsx/sync/realtime.spec.native.js.map +0 -1
- package/dist/jsx/sync/rehydration.spec.mjs +0 -732
- package/dist/jsx/sync/rehydration.spec.mjs.map +0 -1
- package/dist/jsx/sync/rehydration.spec.native.js +0 -736
- package/dist/jsx/sync/rehydration.spec.native.js.map +0 -1
- package/dist/jsx/sync/storage.spec.mjs +0 -423
- package/dist/jsx/sync/storage.spec.mjs.map +0 -1
- package/dist/jsx/sync/storage.spec.native.js +0 -470
- package/dist/jsx/sync/storage.spec.native.js.map +0 -1
- package/dist/jsx/sync/subscriptionManager.spec.mjs +0 -1079
- package/dist/jsx/sync/subscriptionManager.spec.mjs.map +0 -1
- package/dist/jsx/sync/subscriptionManager.spec.native.js +0 -1136
- package/dist/jsx/sync/subscriptionManager.spec.native.js.map +0 -1
- package/dist/jsx/sync/subscriptions.spec.mjs +0 -914
- package/dist/jsx/sync/subscriptions.spec.mjs.map +0 -1
- package/dist/jsx/sync/subscriptions.spec.native.js +0 -969
- package/dist/jsx/sync/subscriptions.spec.native.js.map +0 -1
- package/dist/jsx/sync/syncModule.spec.mjs +0 -207
- package/dist/jsx/sync/syncModule.spec.mjs.map +0 -1
- package/dist/jsx/sync/syncModule.spec.native.js +0 -222
- package/dist/jsx/sync/syncModule.spec.native.js.map +0 -1
- package/dist/jsx/sync/types.spec.mjs +0 -247
- package/dist/jsx/sync/types.spec.mjs.map +0 -1
- package/dist/jsx/sync/types.spec.native.js +0 -256
- package/dist/jsx/sync/types.spec.native.js.map +0 -1
- package/dist/jsx/sync/virtualPageManager.spec.mjs +0 -802
- package/dist/jsx/sync/virtualPageManager.spec.mjs.map +0 -1
- package/dist/jsx/sync/virtualPageManager.spec.native.js +0 -873
- package/dist/jsx/sync/virtualPageManager.spec.native.js.map +0 -1
- package/dist/jsx/util.spec.mjs +0 -20
- package/dist/jsx/util.spec.mjs.map +0 -1
- package/dist/jsx/util.spec.native.js +0 -48
- 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
|
-
});
|