@luzmo/analytics-components-kit 1.0.1-alpha.90 → 1.0.1-alpha.94
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 +195 -0
- package/angular/README.md +1 -0
- package/angular/components/widget-menu.component.ts +25 -0
- package/angular/esm/components/widget-menu.component.d.ts +13 -0
- package/angular/esm/components/widget-menu.component.js +49 -0
- package/angular/esm/index.d.ts +3 -1
- package/angular/esm/index.js +4 -1
- package/angular/esm/types.d.ts +4 -0
- package/angular/index.ts +4 -1
- package/angular/types.ts +6 -0
- package/components/ai-chat-message-assistant/index.cjs +1 -1
- package/components/ai-chat-message-assistant/index.js +1 -0
- package/components/ai-chat-messages-container/index.cjs +1 -1
- package/components/ai-chat-messages-container/index.js +2 -2
- package/components/ai-interaction-textarea/index.cjs +1 -1
- package/components/ai-interaction-textarea/index.js +2 -1
- package/components/area-chart-options.config-C7sMAHco.cjs +20 -0
- package/components/{area-chart-options.config-u8itidsi.js → area-chart-options.config-_J0sG4NF.js} +26 -14
- package/components/{bar-chart-options.config-DIirbAJ0.js → bar-chart-options.config-D1mb5TDl.js} +35 -21
- package/components/bar-chart-options.config-DcxEkOT5.cjs +20 -0
- package/components/box-plot-options.config-SrrbDEYW.cjs +20 -0
- package/components/{box-plot-options.config-BWROiguA.js → box-plot-options.config-xu_i6ms7.js} +88 -52
- package/components/{bubble-chart-options.config-4QD8VPhU.js → bubble-chart-options.config-BacgXkJ_.js} +18 -9
- package/components/bubble-chart-options.config-Ihn6eVQI.cjs +20 -0
- package/components/{bullet-chart-options.config-3bH7uekx.js → bullet-chart-options.config-CDPpX1yc.js} +1 -1
- package/components/{bullet-chart-options.config-tWb6Fio-.cjs → bullet-chart-options.config-DfS4Bwds.cjs} +1 -1
- package/components/calculate-data-item-icon-CEa82-5u.cjs +20 -0
- package/components/calculate-data-item-icon-DjlZwMdO.js +147 -0
- package/components/{choropleth-map-options.config-CMxx3ORp.js → choropleth-map-options.config-B_W9-rhe.js} +84 -63
- package/components/choropleth-map-options.config-ZW8yoZH2.cjs +20 -0
- package/components/{circular-gauge-options.config-DhIKn44k.js → circular-gauge-options.config-DAIjz4Rl.js} +36 -23
- package/components/circular-gauge-options.config-msZ4mfpN.cjs +20 -0
- package/components/color-B6LaL8qz.cjs +20 -0
- package/components/{color-B7m0j8lX.js → color-DuJ4-73S.js} +950 -941
- package/components/{color-range-utils-BSfqtB3A.js → color-range-utils-Bvo9sm5A.js} +32 -31
- package/components/color-range-utils-C5yXW7ZC.cjs +20 -0
- package/components/{column-chart-options.config-D5-yR7iq.js → column-chart-options.config-B5SjBVdy.js} +37 -27
- package/components/column-chart-options.config-BjDvA7i9.cjs +20 -0
- package/components/{conditional-number-options.config-DPYsdML5.js → conditional-number-options.config-BCEpSK9J.js} +40 -24
- package/components/conditional-number-options.config-DgzUo0xi.cjs +20 -0
- package/components/dataset-icon/index.cjs +1 -1
- package/components/dataset-icon/index.js +2 -1
- package/components/dataset-selector-list/index.cjs +1 -1
- package/components/dataset-selector-list/index.js +35 -32
- package/components/dataset-selector-row/index.cjs +9 -9
- package/components/dataset-selector-row/index.js +53 -51
- package/components/{date-comparison-filter-options.config-QaoWaFUn.cjs → date-comparison-filter-options.config-DAVncmi0.cjs} +1 -1
- package/components/{date-comparison-filter-options.config-CSwGyuBg.js → date-comparison-filter-options.config-JA_yYpJa.js} +6 -3
- package/components/{date-filter-options.config-n-zhWaYa.cjs → date-filter-options.config-CWPMtA18.cjs} +1 -1
- package/components/{date-filter-options.config-BTVyHRkp.js → date-filter-options.config-DBRxlTWy.js} +6 -3
- package/components/display-settings/index.cjs +1 -1
- package/components/display-settings/index.js +1 -1
- package/components/display-settings-binning/index.cjs +5 -5
- package/components/display-settings-binning/index.js +30 -29
- package/components/display-settings-datetime/index.cjs +29 -29
- package/components/display-settings-datetime/index.js +120 -112
- package/components/display-settings-grand-totals/index.cjs +4 -4
- package/components/display-settings-grand-totals/index.js +24 -23
- package/components/display-settings-numeric/index.cjs +48 -48
- package/components/display-settings-numeric/index.js +211 -194
- package/components/display-settings-period-over-period/index.cjs +16 -16
- package/components/display-settings-period-over-period/index.js +97 -91
- package/components/{donut-chart-options.config-3ZqX8Cbb.js → donut-chart-options.config-BulUEiaH.js} +37 -21
- package/components/donut-chart-options.config-tNpqBZfR.cjs +20 -0
- package/components/draggable-data-item/index.cjs +5 -5
- package/components/draggable-data-item/index.js +46 -45
- package/components/draggable-data-item-level/index.cjs +11 -11
- package/components/draggable-data-item-level/index.js +73 -70
- package/components/{dropdown-filter-options.config-CGJTtgAX.js → dropdown-filter-options.config-D9dvPypF.js} +10 -7
- package/components/{dropdown-filter-options.config-DJvfCTk7.cjs → dropdown-filter-options.config-DS-MORmq.cjs} +1 -1
- package/components/droppable-slot/index.cjs +16 -16
- package/components/droppable-slot/index.js +223 -208
- package/components/edit-item/index.cjs +9 -9
- package/components/edit-item/index.js +119 -116
- package/components/edit-option/index.cjs +1 -1
- package/components/edit-option/index.js +1 -1
- package/components/edit-option-action-button-group/index.cjs +8 -8
- package/components/edit-option-action-button-group/index.js +53 -52
- package/components/{edit-option-base-Bh29-Cak.js → edit-option-base-DIc7iC-b.js} +1 -1
- package/components/{edit-option-base-tFr8Qg2B.cjs → edit-option-base-VhTih9T1.cjs} +1 -1
- package/components/edit-option-color-palette-picker/index.cjs +1 -1
- package/components/edit-option-color-palette-picker/index.js +1 -1
- package/components/edit-option-color-picker/index.cjs +1 -1
- package/components/edit-option-color-picker/index.js +1 -1
- package/components/edit-option-color-range/index.cjs +19 -19
- package/components/edit-option-color-range/index.js +117 -106
- package/components/edit-option-multi-language-field/index.cjs +3 -3
- package/components/edit-option-multi-language-field/index.js +27 -26
- package/components/edit-option-number-field/index.cjs +1 -1
- package/components/edit-option-number-field/index.js +1 -1
- package/components/edit-option-picker/index.cjs +5 -5
- package/components/edit-option-picker/index.js +7 -7
- package/components/edit-option-position-picker/index.cjs +4 -4
- package/components/edit-option-position-picker/index.js +25 -21
- package/components/edit-option-positions-number-field/index.cjs +9 -9
- package/components/edit-option-positions-number-field/index.js +81 -76
- package/components/edit-option-radio-button-group/index.cjs +6 -6
- package/components/edit-option-radio-button-group/index.js +22 -21
- package/components/edit-option-slider/index.cjs +1 -1
- package/components/edit-option-slider/index.js +1 -1
- package/components/edit-option-switch/index.cjs +1 -1
- package/components/edit-option-switch/index.js +1 -1
- package/components/edit-option-text-field/index.cjs +2 -2
- package/components/edit-option-text-field/index.js +23 -22
- package/components/en-BKBhKBXY.cjs +20 -0
- package/components/en-BOTjhwEc.js +1488 -0
- package/components/{en-GB-ialeqj_z.js → en-GB-CEHEs8F2.js} +1 -1
- package/components/{en-GB-TqvgIw9B.cjs → en-GB-DG6uS3sM.cjs} +1 -1
- package/components/{evolution-number-options.config-Bc9eKYnn.cjs → evolution-number-options.config-BgIZY4gQ.cjs} +1 -1
- package/components/{evolution-number-options.config-BIPO_4n3.js → evolution-number-options.config-DzkfeoIN.js} +14 -11
- package/components/{extrapolate-color-C0n1UDs-.cjs → extrapolate-color-0j_AeYkz.cjs} +1 -1
- package/components/{extrapolate-color-v1PimdQr.js → extrapolate-color-CC9CURf6.js} +1 -1
- package/components/filter-data-item-picker/index.cjs +7 -7
- package/components/filter-data-item-picker/index.js +86 -85
- package/components/filter-expression-picker/index.cjs +1 -1
- package/components/filter-expression-picker/index.js +1 -1
- package/components/filter-item/index.cjs +6 -6
- package/components/filter-item/index.js +119 -109
- package/components/filter-value-picker/index.cjs +2 -2
- package/components/filter-value-picker/index.js +36 -34
- package/components/filter-value-picker-datetime/index.cjs +8 -8
- package/components/filter-value-picker-datetime/index.js +71 -56
- package/components/filter-value-picker-hierarchy/index.cjs +12 -12
- package/components/filter-value-picker-hierarchy/index.js +124 -113
- package/components/filter-value-picker-numeric/index.cjs +8 -8
- package/components/filter-value-picker-numeric/index.js +110 -101
- package/components/focusable-B3E_hQmm.cjs +20 -0
- package/components/{focusable-BS2pbY7w.js → focusable-DCIFkpiW.js} +26 -24
- package/components/{funnel-chart-options.config-CrJy2U7_.js → funnel-chart-options.config-C_VjTOvD.js} +20 -5
- package/components/funnel-chart-options.config-D7H7gFcx.cjs +20 -0
- package/components/get-css-variable-BEYG097C.js +1446 -0
- package/components/get-css-variable-BZxY4IOa.cjs +35 -0
- package/components/get-css-variable-DLiZYZEi.cjs +24 -0
- package/components/{get-css-variable-CdwF98oh.js → get-css-variable-YlLiVgo8.js} +35 -35
- package/components/grid/index.cjs +49 -43
- package/components/grid/index.js +1878 -2610
- package/components/{heat-map-options.config-CmL87j1j.js → heat-map-options.config-BnLWe8jS.js} +41 -35
- package/components/heat-map-options.config-DVH-Bb5-.cjs +20 -0
- package/components/heat-table-options.config-B12JEYnp.cjs +20 -0
- package/components/{heat-table-options.config-BrCYAgYD.js → heat-table-options.config-CUsDdgUr.js} +88 -60
- package/components/helpers-DXQwEH1P.cjs +20 -0
- package/components/helpers-v1bPALRP.js +91 -0
- package/components/hexbin-map-options.config-DZERRhM8.cjs +20 -0
- package/components/{hexbin-map-options.config-BguV1w8q.js → hexbin-map-options.config-F-7uCqxb.js} +38 -20
- package/components/{index-BNAmjOkm.cjs → index-BPNsFiyq.cjs} +4 -4
- package/components/index-CDi4fe3N.js +1716 -0
- package/components/index-CQ9ck-BO.cjs +249 -0
- package/components/index-CXn67vdn.cjs +121 -0
- package/components/{index-haa7WNrl.js → index-CdIUfo-L.js} +481 -453
- package/components/index-Cz9vSXy6.cjs +20 -0
- package/components/{index-DdyZ2g5L.js → index-D0GBF6tg.js} +104 -94
- package/components/index-Dn0j_pcR.cjs +20 -0
- package/components/{index-CqKpf0B8.js → index-Do7O9azB.js} +123 -112
- package/components/index-E239Dotg.js +1735 -0
- package/components/index.cjs +1 -1
- package/components/index.js +20 -18
- package/components/item-options-configs.cjs +1 -1
- package/components/item-options-configs.js +37 -37
- package/components/{line-chart-options.config-BhirTGqD.js → line-chart-options.config-DB3IsXXr.js} +28 -13
- package/components/line-chart-options.config-DSugoe0t.cjs +20 -0
- package/components/{localize-CcDpq940.js → localize-BX7q0S0M.js} +10 -10
- package/components/{localize-C4zNlrwK.cjs → localize-r7ALOUy_.cjs} +1 -1
- package/components/{marker-map-options.config-Bx17jmiq.js → marker-map-options.config-DPJ955tt.js} +1 -1
- package/components/{marker-map-options.config-CvhCylSC.cjs → marker-map-options.config-_FYZzRwA.cjs} +1 -1
- package/components/pivot-table-options.config-BiJXKSFR.cjs +20 -0
- package/components/{pivot-table-options.config-CFc7y0IT.js → pivot-table-options.config-DNK_AIG7.js} +24 -15
- package/components/pyramid-chart-options.config-C4zbFS26.cjs +20 -0
- package/components/{pyramid-chart-options.config-2Waxb11l.js → pyramid-chart-options.config-CcVMatYx.js} +43 -29
- package/components/{radar-chart-options.config-CPN5fOl8.js → radar-chart-options.config-CUZn_3Fd.js} +23 -11
- package/components/radar-chart-options.config-EqQu6PTh.cjs +20 -0
- package/components/{regular-table-options.config-CFKCJQK1.js → regular-table-options.config-BoLZsBry.js} +23 -17
- package/components/{regular-table-options.config-YRuoijIk.cjs → regular-table-options.config-DTx3RTnS.cjs} +1 -1
- package/components/{route-map-options.config-CyolTJfK.js → route-map-options.config-CN86T7c0.js} +109 -87
- package/components/route-map-options.config-D7NJePTu.cjs +20 -0
- package/components/{sankey-diagram-options.config-D7OSvSqm.cjs → sankey-diagram-options.config-RFB83YLZ.cjs} +1 -1
- package/components/{sankey-diagram-options.config-Ldjk84ro.js → sankey-diagram-options.config-tVLKy_Zn.js} +10 -7
- package/components/scatter-plot-options.config-CFfGJXsV.cjs +20 -0
- package/components/{scatter-plot-options.config-CfxEfkQ1.js → scatter-plot-options.config-Corlzno1.js} +86 -56
- package/components/{search-filter-options.config-Oqco9BKj.cjs → search-filter-options.config-BCaDlYqZ.cjs} +1 -1
- package/components/{search-filter-options.config-C0syQmP4.js → search-filter-options.config-BE3JhR-F.js} +6 -3
- package/components/{set-locale-hKTMz37h.js → set-locale-Dp3N_gXN.js} +8 -1
- package/components/{slicer-filter-options.config-DmOe3440.js → slicer-filter-options.config-3JZZcw5C.js} +18 -9
- package/components/slicer-filter-options.config-DNI-XevE.cjs +20 -0
- package/components/{slider-filter-options.config-B1M8RcDs.js → slider-filter-options.config-DH4SS8wH.js} +1 -1
- package/components/{slider-filter-options.config-k45I-t6G.cjs → slider-filter-options.config-_8Z2zKmU.cjs} +1 -1
- package/components/slot-contents-picker/index.cjs +33 -33
- package/components/slot-contents-picker/index.js +205 -194
- package/components/slot-menu/index.cjs +12 -12
- package/components/slot-menu/index.js +184 -171
- package/components/slot-menu-list/index.cjs +3 -3
- package/components/slot-menu-list/index.js +103 -97
- package/components/speedometer-chart-options.config-BX9LTQBH.cjs +20 -0
- package/components/{speedometer-chart-options.config-CzOmuEF8.js → speedometer-chart-options.config-SL581yOa.js} +53 -31
- package/components/{spike-map-options.config-Cbt1YUw6.js → spike-map-options.config-C5KewecZ.js} +122 -91
- package/components/spike-map-options.config-DoBFXPmN.cjs +20 -0
- package/components/{sunburst-chart-options.config-Yrxc2i57.cjs → sunburst-chart-options.config-AbNjWS6t.cjs} +1 -1
- package/components/{sunburst-chart-options.config-_dyLQxPJ.js → sunburst-chart-options.config-CNauGQJv.js} +20 -9
- package/components/{symbol-map-options.config-BORL1NSU.js → symbol-map-options.config-DdDA4aa7.js} +20 -11
- package/components/symbol-map-options.config-m-lwLTtu.cjs +20 -0
- package/components/treemap-chart-options.config-C0Q9aQ1Z.cjs +20 -0
- package/components/{treemap-chart-options.config-B9i9qIm_.js → treemap-chart-options.config-D5AJaF_u.js} +37 -20
- package/components/utils.cjs +1 -1
- package/components/utils.js +97 -94
- package/components/{video-options.config-B0asgYt8.cjs → video-options.config-CGsDTwHc.cjs} +1 -1
- package/components/{video-options.config-UX-9MDfS.js → video-options.config-Dk36zJ1B.js} +10 -7
- package/components/widget-menu/index.cjs +51 -0
- package/components/widget-menu/index.d.ts +8 -0
- package/components/widget-menu/index.js +211 -0
- package/components/widget-menu/widget-menu.d.ts +77 -0
- package/components/{wordcloud-chart-options.config-BKtJT8Va.cjs → wordcloud-chart-options.config-vGfCW8kE.cjs} +1 -1
- package/components/{wordcloud-chart-options.config-BoB_KuhA.js → wordcloud-chart-options.config-w2NUIWVA.js} +7 -4
- package/custom-elements.json +133 -20
- package/index.d.ts +1 -0
- package/package.json +6 -1
- package/types.d.ts +4 -0
- package/components/area-chart-options.config-Bl8bhhOo.cjs +0 -20
- package/components/bar-chart-options.config-CePAqM83.cjs +0 -20
- package/components/box-plot-options.config-BVNrV2eD.cjs +0 -20
- package/components/bubble-chart-options.config-BDgOe3GQ.cjs +0 -20
- package/components/calculate-data-item-icon-DMDhKq_m.js +0 -147
- package/components/calculate-data-item-icon-DtVGbet3.cjs +0 -20
- package/components/choropleth-map-options.config-CWJACFd0.cjs +0 -20
- package/components/circular-gauge-options.config-BMxgq3zH.cjs +0 -20
- package/components/color-Czp4Im5q.cjs +0 -20
- package/components/color-range-utils-DYYR-iwx.cjs +0 -20
- package/components/column-chart-options.config-BV9R3ssH.cjs +0 -20
- package/components/conditional-number-options.config-Co099Qfm.cjs +0 -20
- package/components/donut-chart-options.config-BQyPgnC9.cjs +0 -20
- package/components/en-D3ihEGXg.js +0 -1483
- package/components/en-DZcn_iz_.cjs +0 -20
- package/components/focusable-QLh-LlNt.cjs +0 -20
- package/components/funnel-chart-options.config-DrP4AFgk.cjs +0 -20
- package/components/get-css-variable-COd1d84B.cjs +0 -24
- package/components/heat-map-options.config-CIHnPdYE.cjs +0 -20
- package/components/heat-table-options.config-DTlZRc_i.cjs +0 -20
- package/components/helpers-9I0oLoUB.cjs +0 -20
- package/components/helpers-bR8Ibjqh.js +0 -79
- package/components/hexbin-map-options.config-CKnn3VAB.cjs +0 -20
- package/components/index-BekTY3Em.cjs +0 -121
- package/components/index-CFL6gmIu.cjs +0 -20
- package/components/index-DNPULp4A.js +0 -1755
- package/components/index-DvkzMbLt.cjs +0 -249
- package/components/line-chart-options.config-Cqwou5u6.cjs +0 -20
- package/components/pivot-table-options.config-uZDAertf.cjs +0 -20
- package/components/pyramid-chart-options.config-DoGfEvzU.cjs +0 -20
- package/components/radar-chart-options.config-CtNUMN1l.cjs +0 -20
- package/components/route-map-options.config-CVTk5RVL.cjs +0 -20
- package/components/scatter-plot-options.config-5gN7pMTm.cjs +0 -20
- package/components/slicer-filter-options.config-CrusP6a0.cjs +0 -20
- package/components/speedometer-chart-options.config-B4ceg_qI.cjs +0 -20
- package/components/spike-map-options.config-BkkDqb4g.cjs +0 -20
- package/components/symbol-map-options.config-NpBKm64d.cjs +0 -20
- package/components/treemap-chart-options.config-x4J54WSw.cjs +0 -20
|
@@ -0,0 +1,1735 @@
|
|
|
1
|
+
/*! * A kit of modern Luzmo Web Components for analytics in your web application.
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2025 Luzmo
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Luzmo web components (“Luzmo Web Components”)
|
|
6
|
+
* must be used according to the Luzmo Terms of Service.
|
|
7
|
+
* This license allows users with a current active Luzmo account
|
|
8
|
+
* to use the Luzmo Web Components. This license terminates
|
|
9
|
+
* automatically if a user no longer has an active Luzmo account.
|
|
10
|
+
* Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
|
|
11
|
+
*
|
|
12
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
* SOFTWARE.
|
|
19
|
+
* */
|
|
20
|
+
var Fe = (s) => {
|
|
21
|
+
throw TypeError(s);
|
|
22
|
+
};
|
|
23
|
+
var qe = (s, e, t) => e.has(s) || Fe("Cannot " + t);
|
|
24
|
+
var i = (s, e, t) => (qe(s, e, "read from private field"), t ? t.call(s) : e.get(s)), f = (s, e, t) => e.has(s) ? Fe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), h = (s, e, t, r) => (qe(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t), q = (s, e, t) => (qe(s, e, "access private method"), t);
|
|
25
|
+
var me = (s, e, t, r) => ({
|
|
26
|
+
set _(n) {
|
|
27
|
+
h(s, e, n, t);
|
|
28
|
+
},
|
|
29
|
+
get _() {
|
|
30
|
+
return i(s, e, r);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var be = class {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
36
|
+
}
|
|
37
|
+
subscribe(s) {
|
|
38
|
+
return this.listeners.add(s), this.onSubscribe(), () => {
|
|
39
|
+
this.listeners.delete(s), this.onUnsubscribe();
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
hasListeners() {
|
|
43
|
+
return this.listeners.size > 0;
|
|
44
|
+
}
|
|
45
|
+
onSubscribe() {
|
|
46
|
+
}
|
|
47
|
+
onUnsubscribe() {
|
|
48
|
+
}
|
|
49
|
+
}, we = typeof window > "u" || "Deno" in globalThis;
|
|
50
|
+
function M() {
|
|
51
|
+
}
|
|
52
|
+
function ze(s, e) {
|
|
53
|
+
return typeof s == "function" ? s(e) : s;
|
|
54
|
+
}
|
|
55
|
+
function Be(s) {
|
|
56
|
+
return typeof s == "number" && s >= 0 && s !== 1 / 0;
|
|
57
|
+
}
|
|
58
|
+
function We(s, e) {
|
|
59
|
+
return Math.max(s + (e || 0) - Date.now(), 0);
|
|
60
|
+
}
|
|
61
|
+
function Ae(s, e) {
|
|
62
|
+
return typeof s == "function" ? s(e) : s;
|
|
63
|
+
}
|
|
64
|
+
function Xe(s, e) {
|
|
65
|
+
return typeof s == "function" ? s(e) : s;
|
|
66
|
+
}
|
|
67
|
+
function De(s, e) {
|
|
68
|
+
const {
|
|
69
|
+
type: t = "all",
|
|
70
|
+
exact: r,
|
|
71
|
+
fetchStatus: n,
|
|
72
|
+
predicate: u,
|
|
73
|
+
queryKey: o,
|
|
74
|
+
stale: a
|
|
75
|
+
} = s;
|
|
76
|
+
if (o) {
|
|
77
|
+
if (r) {
|
|
78
|
+
if (e.queryHash !== Se(o, e.options))
|
|
79
|
+
return !1;
|
|
80
|
+
} else if (!ce(e.queryKey, o))
|
|
81
|
+
return !1;
|
|
82
|
+
}
|
|
83
|
+
if (t !== "all") {
|
|
84
|
+
const l = e.isActive();
|
|
85
|
+
if (t === "active" && !l || t === "inactive" && l)
|
|
86
|
+
return !1;
|
|
87
|
+
}
|
|
88
|
+
return !(typeof a == "boolean" && e.isStale() !== a || n && n !== e.state.fetchStatus || u && !u(e));
|
|
89
|
+
}
|
|
90
|
+
function Qe(s, e) {
|
|
91
|
+
const { exact: t, status: r, predicate: n, mutationKey: u } = s;
|
|
92
|
+
if (u) {
|
|
93
|
+
if (!e.options.mutationKey)
|
|
94
|
+
return !1;
|
|
95
|
+
if (t) {
|
|
96
|
+
if (he(e.options.mutationKey) !== he(u))
|
|
97
|
+
return !1;
|
|
98
|
+
} else if (!ce(e.options.mutationKey, u))
|
|
99
|
+
return !1;
|
|
100
|
+
}
|
|
101
|
+
return !(r && e.state.status !== r || n && !n(e));
|
|
102
|
+
}
|
|
103
|
+
function Se(s, e) {
|
|
104
|
+
return ((e == null ? void 0 : e.queryKeyHashFn) || he)(s);
|
|
105
|
+
}
|
|
106
|
+
function he(s) {
|
|
107
|
+
return JSON.stringify(
|
|
108
|
+
s,
|
|
109
|
+
(e, t) => Oe(t) ? Object.keys(t).sort().reduce((r, n) => (r[n] = t[n], r), {}) : t
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function ce(s, e) {
|
|
113
|
+
return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? Object.keys(e).every((t) => ce(s[t], e[t])) : !1;
|
|
114
|
+
}
|
|
115
|
+
function Ce(s, e) {
|
|
116
|
+
if (s === e)
|
|
117
|
+
return s;
|
|
118
|
+
const t = Ee(s) && Ee(e);
|
|
119
|
+
if (t || Oe(s) && Oe(e)) {
|
|
120
|
+
const r = t ? s : Object.keys(s), n = r.length, u = t ? e : Object.keys(e), o = u.length, a = t ? [] : {};
|
|
121
|
+
let l = 0;
|
|
122
|
+
for (let y = 0; y < o; y++) {
|
|
123
|
+
const m = t ? y : u[y];
|
|
124
|
+
(!t && r.includes(m) || t) && s[m] === void 0 && e[m] === void 0 ? (a[m] = void 0, l++) : (a[m] = Ce(s[m], e[m]), a[m] === s[m] && s[m] !== void 0 && l++);
|
|
125
|
+
}
|
|
126
|
+
return n === o && l === n ? s : a;
|
|
127
|
+
}
|
|
128
|
+
return e;
|
|
129
|
+
}
|
|
130
|
+
function Ee(s) {
|
|
131
|
+
return Array.isArray(s) && s.length === Object.keys(s).length;
|
|
132
|
+
}
|
|
133
|
+
function Oe(s) {
|
|
134
|
+
if (!Me(s))
|
|
135
|
+
return !1;
|
|
136
|
+
const e = s.constructor;
|
|
137
|
+
if (e === void 0)
|
|
138
|
+
return !0;
|
|
139
|
+
const t = e.prototype;
|
|
140
|
+
return !(!Me(t) || !t.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(s) !== Object.prototype);
|
|
141
|
+
}
|
|
142
|
+
function Me(s) {
|
|
143
|
+
return Object.prototype.toString.call(s) === "[object Object]";
|
|
144
|
+
}
|
|
145
|
+
function Ye(s) {
|
|
146
|
+
return new Promise((e) => {
|
|
147
|
+
setTimeout(e, s);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function Ze(s, e, t) {
|
|
151
|
+
if (typeof t.structuralSharing == "function")
|
|
152
|
+
return t.structuralSharing(s, e);
|
|
153
|
+
if (t.structuralSharing !== !1) {
|
|
154
|
+
try {
|
|
155
|
+
return Ce(s, e);
|
|
156
|
+
} catch (r) {
|
|
157
|
+
throw console.error(
|
|
158
|
+
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${t.queryHash}]: ${r}`
|
|
159
|
+
), r;
|
|
160
|
+
}
|
|
161
|
+
return Ce(s, e);
|
|
162
|
+
}
|
|
163
|
+
return e;
|
|
164
|
+
}
|
|
165
|
+
function et(s, e, t = 0) {
|
|
166
|
+
const r = [...s, e];
|
|
167
|
+
return t && r.length > t ? r.slice(1) : r;
|
|
168
|
+
}
|
|
169
|
+
function tt(s, e, t = 0) {
|
|
170
|
+
const r = [e, ...s];
|
|
171
|
+
return t && r.length > t ? r.slice(0, -1) : r;
|
|
172
|
+
}
|
|
173
|
+
var ve = Symbol();
|
|
174
|
+
function Ge(s, e) {
|
|
175
|
+
return s.queryFn === ve && console.error(
|
|
176
|
+
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`
|
|
177
|
+
), !s.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !s.queryFn || s.queryFn === ve ? () => Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)) : s.queryFn;
|
|
178
|
+
}
|
|
179
|
+
var z, G, Z, ke, st = (ke = class extends be {
|
|
180
|
+
constructor() {
|
|
181
|
+
super();
|
|
182
|
+
f(this, z);
|
|
183
|
+
f(this, G);
|
|
184
|
+
f(this, Z);
|
|
185
|
+
h(this, Z, (e) => {
|
|
186
|
+
if (!we && window.addEventListener) {
|
|
187
|
+
const t = () => e();
|
|
188
|
+
return window.addEventListener("visibilitychange", t, !1), () => {
|
|
189
|
+
window.removeEventListener("visibilitychange", t);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
onSubscribe() {
|
|
195
|
+
i(this, G) || this.setEventListener(i(this, Z));
|
|
196
|
+
}
|
|
197
|
+
onUnsubscribe() {
|
|
198
|
+
var e;
|
|
199
|
+
this.hasListeners() || ((e = i(this, G)) == null || e.call(this), h(this, G, void 0));
|
|
200
|
+
}
|
|
201
|
+
setEventListener(e) {
|
|
202
|
+
var t;
|
|
203
|
+
h(this, Z, e), (t = i(this, G)) == null || t.call(this), h(this, G, e((r) => {
|
|
204
|
+
typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
setFocused(e) {
|
|
208
|
+
i(this, z) !== e && (h(this, z, e), this.onFocus());
|
|
209
|
+
}
|
|
210
|
+
onFocus() {
|
|
211
|
+
const e = this.isFocused();
|
|
212
|
+
this.listeners.forEach((t) => {
|
|
213
|
+
t(e);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
isFocused() {
|
|
217
|
+
var e;
|
|
218
|
+
return typeof i(this, z) == "boolean" ? i(this, z) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
|
|
219
|
+
}
|
|
220
|
+
}, z = new WeakMap(), G = new WeakMap(), Z = new WeakMap(), ke), Ne = new st(), ee, N, te, Ke, rt = (Ke = class extends be {
|
|
221
|
+
constructor() {
|
|
222
|
+
super();
|
|
223
|
+
f(this, ee, !0);
|
|
224
|
+
f(this, N);
|
|
225
|
+
f(this, te);
|
|
226
|
+
h(this, te, (e) => {
|
|
227
|
+
if (!we && window.addEventListener) {
|
|
228
|
+
const t = () => e(!0), r = () => e(!1);
|
|
229
|
+
return window.addEventListener("online", t, !1), window.addEventListener("offline", r, !1), () => {
|
|
230
|
+
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
onSubscribe() {
|
|
236
|
+
i(this, N) || this.setEventListener(i(this, te));
|
|
237
|
+
}
|
|
238
|
+
onUnsubscribe() {
|
|
239
|
+
var e;
|
|
240
|
+
this.hasListeners() || ((e = i(this, N)) == null || e.call(this), h(this, N, void 0));
|
|
241
|
+
}
|
|
242
|
+
setEventListener(e) {
|
|
243
|
+
var t;
|
|
244
|
+
h(this, te, e), (t = i(this, N)) == null || t.call(this), h(this, N, e(this.setOnline.bind(this)));
|
|
245
|
+
}
|
|
246
|
+
setOnline(e) {
|
|
247
|
+
i(this, ee) !== e && (h(this, ee, e), this.listeners.forEach((r) => {
|
|
248
|
+
r(e);
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
isOnline() {
|
|
252
|
+
return i(this, ee);
|
|
253
|
+
}
|
|
254
|
+
}, ee = new WeakMap(), N = new WeakMap(), te = new WeakMap(), Ke), ge = new rt();
|
|
255
|
+
function it() {
|
|
256
|
+
let s, e;
|
|
257
|
+
const t = new Promise((n, u) => {
|
|
258
|
+
s = n, e = u;
|
|
259
|
+
});
|
|
260
|
+
t.status = "pending", t.catch(() => {
|
|
261
|
+
});
|
|
262
|
+
function r(n) {
|
|
263
|
+
Object.assign(t, n), delete t.resolve, delete t.reject;
|
|
264
|
+
}
|
|
265
|
+
return t.resolve = (n) => {
|
|
266
|
+
r({
|
|
267
|
+
status: "fulfilled",
|
|
268
|
+
value: n
|
|
269
|
+
}), s(n);
|
|
270
|
+
}, t.reject = (n) => {
|
|
271
|
+
r({
|
|
272
|
+
status: "rejected",
|
|
273
|
+
reason: n
|
|
274
|
+
}), e(n);
|
|
275
|
+
}, t;
|
|
276
|
+
}
|
|
277
|
+
function nt(s) {
|
|
278
|
+
return Math.min(1e3 * 2 ** s, 3e4);
|
|
279
|
+
}
|
|
280
|
+
function $e(s) {
|
|
281
|
+
return (s ?? "online") === "online" ? ge.isOnline() : !0;
|
|
282
|
+
}
|
|
283
|
+
var Ve = class extends Error {
|
|
284
|
+
constructor(s) {
|
|
285
|
+
super("CancelledError"), this.revert = s == null ? void 0 : s.revert, this.silent = s == null ? void 0 : s.silent;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
function Pe(s) {
|
|
289
|
+
return s instanceof Ve;
|
|
290
|
+
}
|
|
291
|
+
function _e(s) {
|
|
292
|
+
let e = !1, t = 0, r = !1, n;
|
|
293
|
+
const u = it(), o = (d) => {
|
|
294
|
+
var v;
|
|
295
|
+
r || (p(new Ve(d)), (v = s.abort) == null || v.call(s));
|
|
296
|
+
}, a = () => {
|
|
297
|
+
e = !0;
|
|
298
|
+
}, l = () => {
|
|
299
|
+
e = !1;
|
|
300
|
+
}, y = () => Ne.isFocused() && (s.networkMode === "always" || ge.isOnline()) && s.canRun(), m = () => $e(s.networkMode) && s.canRun(), c = (d) => {
|
|
301
|
+
var v;
|
|
302
|
+
r || (r = !0, (v = s.onSuccess) == null || v.call(s, d), n == null || n(), u.resolve(d));
|
|
303
|
+
}, p = (d) => {
|
|
304
|
+
var v;
|
|
305
|
+
r || (r = !0, (v = s.onError) == null || v.call(s, d), n == null || n(), u.reject(d));
|
|
306
|
+
}, F = () => new Promise((d) => {
|
|
307
|
+
var v;
|
|
308
|
+
n = (A) => {
|
|
309
|
+
(r || y()) && d(A);
|
|
310
|
+
}, (v = s.onPause) == null || v.call(s);
|
|
311
|
+
}).then(() => {
|
|
312
|
+
var d;
|
|
313
|
+
n = void 0, r || (d = s.onContinue) == null || d.call(s);
|
|
314
|
+
}), C = () => {
|
|
315
|
+
if (r)
|
|
316
|
+
return;
|
|
317
|
+
let d;
|
|
318
|
+
const v = t === 0 ? s.initialPromise : void 0;
|
|
319
|
+
try {
|
|
320
|
+
d = v ?? s.fn();
|
|
321
|
+
} catch (A) {
|
|
322
|
+
d = Promise.reject(A);
|
|
323
|
+
}
|
|
324
|
+
Promise.resolve(d).then(c).catch((A) => {
|
|
325
|
+
var K;
|
|
326
|
+
if (r)
|
|
327
|
+
return;
|
|
328
|
+
const E = s.retry ?? (we ? 0 : 3), b = s.retryDelay ?? nt, D = typeof b == "function" ? b(t, A) : b, k = E === !0 || typeof E == "number" && t < E || typeof E == "function" && E(t, A);
|
|
329
|
+
if (e || !k) {
|
|
330
|
+
p(A);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
t++, (K = s.onFail) == null || K.call(s, t, A), Ye(D).then(() => y() ? void 0 : F()).then(() => {
|
|
334
|
+
e ? p(A) : C();
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
promise: u,
|
|
340
|
+
cancel: o,
|
|
341
|
+
continue: () => (n == null || n(), u),
|
|
342
|
+
cancelRetry: a,
|
|
343
|
+
continueRetry: l,
|
|
344
|
+
canStart: m,
|
|
345
|
+
start: () => (m() ? C() : F().then(C), u)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
var at = (s) => setTimeout(s, 0);
|
|
349
|
+
function ut() {
|
|
350
|
+
let s = [], e = 0, t = (a) => {
|
|
351
|
+
a();
|
|
352
|
+
}, r = (a) => {
|
|
353
|
+
a();
|
|
354
|
+
}, n = at;
|
|
355
|
+
const u = (a) => {
|
|
356
|
+
e ? s.push(a) : n(() => {
|
|
357
|
+
t(a);
|
|
358
|
+
});
|
|
359
|
+
}, o = () => {
|
|
360
|
+
const a = s;
|
|
361
|
+
s = [], a.length && n(() => {
|
|
362
|
+
r(() => {
|
|
363
|
+
a.forEach((l) => {
|
|
364
|
+
t(l);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
return {
|
|
370
|
+
batch: (a) => {
|
|
371
|
+
let l;
|
|
372
|
+
e++;
|
|
373
|
+
try {
|
|
374
|
+
l = a();
|
|
375
|
+
} finally {
|
|
376
|
+
e--, e || o();
|
|
377
|
+
}
|
|
378
|
+
return l;
|
|
379
|
+
},
|
|
380
|
+
/**
|
|
381
|
+
* All calls to the wrapped function will be batched.
|
|
382
|
+
*/
|
|
383
|
+
batchCalls: (a) => (...l) => {
|
|
384
|
+
u(() => {
|
|
385
|
+
a(...l);
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
schedule: u,
|
|
389
|
+
/**
|
|
390
|
+
* Use this method to set a custom notify function.
|
|
391
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
392
|
+
*/
|
|
393
|
+
setNotifyFunction: (a) => {
|
|
394
|
+
t = a;
|
|
395
|
+
},
|
|
396
|
+
/**
|
|
397
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
398
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
399
|
+
*/
|
|
400
|
+
setBatchNotifyFunction: (a) => {
|
|
401
|
+
r = a;
|
|
402
|
+
},
|
|
403
|
+
setScheduler: (a) => {
|
|
404
|
+
n = a;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
var S = ut(), B, je, Je = (je = class {
|
|
409
|
+
constructor() {
|
|
410
|
+
f(this, B);
|
|
411
|
+
}
|
|
412
|
+
destroy() {
|
|
413
|
+
this.clearGcTimeout();
|
|
414
|
+
}
|
|
415
|
+
scheduleGc() {
|
|
416
|
+
this.clearGcTimeout(), Be(this.gcTime) && h(this, B, setTimeout(() => {
|
|
417
|
+
this.optionalRemove();
|
|
418
|
+
}, this.gcTime));
|
|
419
|
+
}
|
|
420
|
+
updateGcTime(s) {
|
|
421
|
+
this.gcTime = Math.max(
|
|
422
|
+
this.gcTime || 0,
|
|
423
|
+
s ?? (we ? 1 / 0 : 5 * 60 * 1e3)
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
clearGcTimeout() {
|
|
427
|
+
i(this, B) && (clearTimeout(i(this, B)), h(this, B, void 0));
|
|
428
|
+
}
|
|
429
|
+
}, B = new WeakMap(), je), se, re, Q, W, P, le, X, T, L, Ue, ot = (Ue = class extends Je {
|
|
430
|
+
constructor(e) {
|
|
431
|
+
super();
|
|
432
|
+
f(this, T);
|
|
433
|
+
f(this, se);
|
|
434
|
+
f(this, re);
|
|
435
|
+
f(this, Q);
|
|
436
|
+
f(this, W);
|
|
437
|
+
f(this, P);
|
|
438
|
+
f(this, le);
|
|
439
|
+
f(this, X);
|
|
440
|
+
h(this, X, !1), h(this, le, e.defaultOptions), this.setOptions(e.options), this.observers = [], h(this, W, e.client), h(this, Q, i(this, W).getQueryCache()), this.queryKey = e.queryKey, this.queryHash = e.queryHash, h(this, se, ct(this.options)), this.state = e.state ?? i(this, se), this.scheduleGc();
|
|
441
|
+
}
|
|
442
|
+
get meta() {
|
|
443
|
+
return this.options.meta;
|
|
444
|
+
}
|
|
445
|
+
get promise() {
|
|
446
|
+
var e;
|
|
447
|
+
return (e = i(this, P)) == null ? void 0 : e.promise;
|
|
448
|
+
}
|
|
449
|
+
setOptions(e) {
|
|
450
|
+
this.options = { ...i(this, le), ...e }, this.updateGcTime(this.options.gcTime);
|
|
451
|
+
}
|
|
452
|
+
optionalRemove() {
|
|
453
|
+
!this.observers.length && this.state.fetchStatus === "idle" && i(this, Q).remove(this);
|
|
454
|
+
}
|
|
455
|
+
setData(e, t) {
|
|
456
|
+
const r = Ze(this.state.data, e, this.options);
|
|
457
|
+
return q(this, T, L).call(this, {
|
|
458
|
+
data: r,
|
|
459
|
+
type: "success",
|
|
460
|
+
dataUpdatedAt: t == null ? void 0 : t.updatedAt,
|
|
461
|
+
manual: t == null ? void 0 : t.manual
|
|
462
|
+
}), r;
|
|
463
|
+
}
|
|
464
|
+
setState(e, t) {
|
|
465
|
+
q(this, T, L).call(this, { type: "setState", state: e, setStateOptions: t });
|
|
466
|
+
}
|
|
467
|
+
cancel(e) {
|
|
468
|
+
var r, n;
|
|
469
|
+
const t = (r = i(this, P)) == null ? void 0 : r.promise;
|
|
470
|
+
return (n = i(this, P)) == null || n.cancel(e), t ? t.then(M).catch(M) : Promise.resolve();
|
|
471
|
+
}
|
|
472
|
+
destroy() {
|
|
473
|
+
super.destroy(), this.cancel({ silent: !0 });
|
|
474
|
+
}
|
|
475
|
+
reset() {
|
|
476
|
+
this.destroy(), this.setState(i(this, se));
|
|
477
|
+
}
|
|
478
|
+
isActive() {
|
|
479
|
+
return this.observers.some(
|
|
480
|
+
(e) => Xe(e.options.enabled, this) !== !1
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
isDisabled() {
|
|
484
|
+
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === ve || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
|
|
485
|
+
}
|
|
486
|
+
isStale() {
|
|
487
|
+
return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
|
|
488
|
+
(e) => e.getCurrentResult().isStale
|
|
489
|
+
) : this.state.data === void 0;
|
|
490
|
+
}
|
|
491
|
+
isStaleByTime(e = 0) {
|
|
492
|
+
return this.state.isInvalidated || this.state.data === void 0 || !We(this.state.dataUpdatedAt, e);
|
|
493
|
+
}
|
|
494
|
+
onFocus() {
|
|
495
|
+
var t;
|
|
496
|
+
const e = this.observers.find((r) => r.shouldFetchOnWindowFocus());
|
|
497
|
+
e == null || e.refetch({ cancelRefetch: !1 }), (t = i(this, P)) == null || t.continue();
|
|
498
|
+
}
|
|
499
|
+
onOnline() {
|
|
500
|
+
var t;
|
|
501
|
+
const e = this.observers.find((r) => r.shouldFetchOnReconnect());
|
|
502
|
+
e == null || e.refetch({ cancelRefetch: !1 }), (t = i(this, P)) == null || t.continue();
|
|
503
|
+
}
|
|
504
|
+
addObserver(e) {
|
|
505
|
+
this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), i(this, Q).notify({ type: "observerAdded", query: this, observer: e }));
|
|
506
|
+
}
|
|
507
|
+
removeObserver(e) {
|
|
508
|
+
this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (i(this, P) && (i(this, X) ? i(this, P).cancel({ revert: !0 }) : i(this, P).cancelRetry()), this.scheduleGc()), i(this, Q).notify({ type: "observerRemoved", query: this, observer: e }));
|
|
509
|
+
}
|
|
510
|
+
getObserversCount() {
|
|
511
|
+
return this.observers.length;
|
|
512
|
+
}
|
|
513
|
+
invalidate() {
|
|
514
|
+
this.state.isInvalidated || q(this, T, L).call(this, { type: "invalidate" });
|
|
515
|
+
}
|
|
516
|
+
fetch(e, t) {
|
|
517
|
+
var l, y, m;
|
|
518
|
+
if (this.state.fetchStatus !== "idle") {
|
|
519
|
+
if (this.state.data !== void 0 && (t != null && t.cancelRefetch))
|
|
520
|
+
this.cancel({ silent: !0 });
|
|
521
|
+
else if (i(this, P))
|
|
522
|
+
return i(this, P).continueRetry(), i(this, P).promise;
|
|
523
|
+
}
|
|
524
|
+
if (e && this.setOptions(e), !this.options.queryFn) {
|
|
525
|
+
const c = this.observers.find((p) => p.options.queryFn);
|
|
526
|
+
c && this.setOptions(c.options);
|
|
527
|
+
}
|
|
528
|
+
Array.isArray(this.options.queryKey) || console.error(
|
|
529
|
+
"As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
|
|
530
|
+
);
|
|
531
|
+
const r = new AbortController(), n = (c) => {
|
|
532
|
+
Object.defineProperty(c, "signal", {
|
|
533
|
+
enumerable: !0,
|
|
534
|
+
get: () => (h(this, X, !0), r.signal)
|
|
535
|
+
});
|
|
536
|
+
}, u = () => {
|
|
537
|
+
const c = Ge(this.options, t), p = {
|
|
538
|
+
client: i(this, W),
|
|
539
|
+
queryKey: this.queryKey,
|
|
540
|
+
meta: this.meta
|
|
541
|
+
};
|
|
542
|
+
return n(p), h(this, X, !1), this.options.persister ? this.options.persister(
|
|
543
|
+
c,
|
|
544
|
+
p,
|
|
545
|
+
this
|
|
546
|
+
) : c(p);
|
|
547
|
+
}, o = {
|
|
548
|
+
fetchOptions: t,
|
|
549
|
+
options: this.options,
|
|
550
|
+
queryKey: this.queryKey,
|
|
551
|
+
client: i(this, W),
|
|
552
|
+
state: this.state,
|
|
553
|
+
fetchFn: u
|
|
554
|
+
};
|
|
555
|
+
n(o), (l = this.options.behavior) == null || l.onFetch(
|
|
556
|
+
o,
|
|
557
|
+
this
|
|
558
|
+
), h(this, re, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((y = o.fetchOptions) == null ? void 0 : y.meta)) && q(this, T, L).call(this, { type: "fetch", meta: (m = o.fetchOptions) == null ? void 0 : m.meta });
|
|
559
|
+
const a = (c) => {
|
|
560
|
+
var p, F, C, d;
|
|
561
|
+
Pe(c) && c.silent || q(this, T, L).call(this, {
|
|
562
|
+
type: "error",
|
|
563
|
+
error: c
|
|
564
|
+
}), Pe(c) || ((F = (p = i(this, Q).config).onError) == null || F.call(
|
|
565
|
+
p,
|
|
566
|
+
c,
|
|
567
|
+
this
|
|
568
|
+
), (d = (C = i(this, Q).config).onSettled) == null || d.call(
|
|
569
|
+
C,
|
|
570
|
+
this.state.data,
|
|
571
|
+
c,
|
|
572
|
+
this
|
|
573
|
+
)), this.scheduleGc();
|
|
574
|
+
};
|
|
575
|
+
return h(this, P, _e({
|
|
576
|
+
initialPromise: t == null ? void 0 : t.initialPromise,
|
|
577
|
+
fn: o.fetchFn,
|
|
578
|
+
abort: r.abort.bind(r),
|
|
579
|
+
onSuccess: (c) => {
|
|
580
|
+
var p, F, C, d;
|
|
581
|
+
if (c === void 0) {
|
|
582
|
+
console.error(
|
|
583
|
+
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
584
|
+
), a(new Error(`${this.queryHash} data is undefined`));
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
try {
|
|
588
|
+
this.setData(c);
|
|
589
|
+
} catch (v) {
|
|
590
|
+
a(v);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
(F = (p = i(this, Q).config).onSuccess) == null || F.call(p, c, this), (d = (C = i(this, Q).config).onSettled) == null || d.call(
|
|
594
|
+
C,
|
|
595
|
+
c,
|
|
596
|
+
this.state.error,
|
|
597
|
+
this
|
|
598
|
+
), this.scheduleGc();
|
|
599
|
+
},
|
|
600
|
+
onError: a,
|
|
601
|
+
onFail: (c, p) => {
|
|
602
|
+
q(this, T, L).call(this, { type: "failed", failureCount: c, error: p });
|
|
603
|
+
},
|
|
604
|
+
onPause: () => {
|
|
605
|
+
q(this, T, L).call(this, { type: "pause" });
|
|
606
|
+
},
|
|
607
|
+
onContinue: () => {
|
|
608
|
+
q(this, T, L).call(this, { type: "continue" });
|
|
609
|
+
},
|
|
610
|
+
retry: o.options.retry,
|
|
611
|
+
retryDelay: o.options.retryDelay,
|
|
612
|
+
networkMode: o.options.networkMode,
|
|
613
|
+
canRun: () => !0
|
|
614
|
+
})), i(this, P).start();
|
|
615
|
+
}
|
|
616
|
+
}, se = new WeakMap(), re = new WeakMap(), Q = new WeakMap(), W = new WeakMap(), P = new WeakMap(), le = new WeakMap(), X = new WeakMap(), T = new WeakSet(), L = function(e) {
|
|
617
|
+
const t = (r) => {
|
|
618
|
+
switch (e.type) {
|
|
619
|
+
case "failed":
|
|
620
|
+
return {
|
|
621
|
+
...r,
|
|
622
|
+
fetchFailureCount: e.failureCount,
|
|
623
|
+
fetchFailureReason: e.error
|
|
624
|
+
};
|
|
625
|
+
case "pause":
|
|
626
|
+
return {
|
|
627
|
+
...r,
|
|
628
|
+
fetchStatus: "paused"
|
|
629
|
+
};
|
|
630
|
+
case "continue":
|
|
631
|
+
return {
|
|
632
|
+
...r,
|
|
633
|
+
fetchStatus: "fetching"
|
|
634
|
+
};
|
|
635
|
+
case "fetch":
|
|
636
|
+
return {
|
|
637
|
+
...r,
|
|
638
|
+
...ht(r.data, this.options),
|
|
639
|
+
fetchMeta: e.meta ?? null
|
|
640
|
+
};
|
|
641
|
+
case "success":
|
|
642
|
+
return {
|
|
643
|
+
...r,
|
|
644
|
+
data: e.data,
|
|
645
|
+
dataUpdateCount: r.dataUpdateCount + 1,
|
|
646
|
+
dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
|
|
647
|
+
error: null,
|
|
648
|
+
isInvalidated: !1,
|
|
649
|
+
status: "success",
|
|
650
|
+
...!e.manual && {
|
|
651
|
+
fetchStatus: "idle",
|
|
652
|
+
fetchFailureCount: 0,
|
|
653
|
+
fetchFailureReason: null
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
case "error":
|
|
657
|
+
const n = e.error;
|
|
658
|
+
return Pe(n) && n.revert && i(this, re) ? { ...i(this, re), fetchStatus: "idle" } : {
|
|
659
|
+
...r,
|
|
660
|
+
error: n,
|
|
661
|
+
errorUpdateCount: r.errorUpdateCount + 1,
|
|
662
|
+
errorUpdatedAt: Date.now(),
|
|
663
|
+
fetchFailureCount: r.fetchFailureCount + 1,
|
|
664
|
+
fetchFailureReason: n,
|
|
665
|
+
fetchStatus: "idle",
|
|
666
|
+
status: "error"
|
|
667
|
+
};
|
|
668
|
+
case "invalidate":
|
|
669
|
+
return {
|
|
670
|
+
...r,
|
|
671
|
+
isInvalidated: !0
|
|
672
|
+
};
|
|
673
|
+
case "setState":
|
|
674
|
+
return {
|
|
675
|
+
...r,
|
|
676
|
+
...e.state
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
this.state = t(this.state), S.batch(() => {
|
|
681
|
+
this.observers.forEach((r) => {
|
|
682
|
+
r.onQueryUpdate();
|
|
683
|
+
}), i(this, Q).notify({ query: this, type: "updated", action: e });
|
|
684
|
+
});
|
|
685
|
+
}, Ue);
|
|
686
|
+
function ht(s, e) {
|
|
687
|
+
return {
|
|
688
|
+
fetchFailureCount: 0,
|
|
689
|
+
fetchFailureReason: null,
|
|
690
|
+
fetchStatus: $e(e.networkMode) ? "fetching" : "paused",
|
|
691
|
+
...s === void 0 && {
|
|
692
|
+
error: null,
|
|
693
|
+
status: "pending"
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function ct(s) {
|
|
698
|
+
const e = typeof s.initialData == "function" ? s.initialData() : s.initialData, t = e !== void 0, r = t ? typeof s.initialDataUpdatedAt == "function" ? s.initialDataUpdatedAt() : s.initialDataUpdatedAt : 0;
|
|
699
|
+
return {
|
|
700
|
+
data: e,
|
|
701
|
+
dataUpdateCount: 0,
|
|
702
|
+
dataUpdatedAt: t ? r ?? Date.now() : 0,
|
|
703
|
+
error: null,
|
|
704
|
+
errorUpdateCount: 0,
|
|
705
|
+
errorUpdatedAt: 0,
|
|
706
|
+
fetchFailureCount: 0,
|
|
707
|
+
fetchFailureReason: null,
|
|
708
|
+
fetchMeta: null,
|
|
709
|
+
isInvalidated: !1,
|
|
710
|
+
status: t ? "success" : "pending",
|
|
711
|
+
fetchStatus: "idle"
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
var j, Ie, lt = (Ie = class extends be {
|
|
715
|
+
constructor(e = {}) {
|
|
716
|
+
super();
|
|
717
|
+
f(this, j);
|
|
718
|
+
this.config = e, h(this, j, /* @__PURE__ */ new Map());
|
|
719
|
+
}
|
|
720
|
+
build(e, t, r) {
|
|
721
|
+
const n = t.queryKey, u = t.queryHash ?? Se(n, t);
|
|
722
|
+
let o = this.get(u);
|
|
723
|
+
return o || (o = new ot({
|
|
724
|
+
client: e,
|
|
725
|
+
queryKey: n,
|
|
726
|
+
queryHash: u,
|
|
727
|
+
options: e.defaultQueryOptions(t),
|
|
728
|
+
state: r,
|
|
729
|
+
defaultOptions: e.getQueryDefaults(n)
|
|
730
|
+
}), this.add(o)), o;
|
|
731
|
+
}
|
|
732
|
+
add(e) {
|
|
733
|
+
i(this, j).has(e.queryHash) || (i(this, j).set(e.queryHash, e), this.notify({
|
|
734
|
+
type: "added",
|
|
735
|
+
query: e
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
remove(e) {
|
|
739
|
+
const t = i(this, j).get(e.queryHash);
|
|
740
|
+
t && (e.destroy(), t === e && i(this, j).delete(e.queryHash), this.notify({ type: "removed", query: e }));
|
|
741
|
+
}
|
|
742
|
+
clear() {
|
|
743
|
+
S.batch(() => {
|
|
744
|
+
this.getAll().forEach((e) => {
|
|
745
|
+
this.remove(e);
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
get(e) {
|
|
750
|
+
return i(this, j).get(e);
|
|
751
|
+
}
|
|
752
|
+
getAll() {
|
|
753
|
+
return [...i(this, j).values()];
|
|
754
|
+
}
|
|
755
|
+
find(e) {
|
|
756
|
+
const t = { exact: !0, ...e };
|
|
757
|
+
return this.getAll().find(
|
|
758
|
+
(r) => De(t, r)
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
findAll(e = {}) {
|
|
762
|
+
const t = this.getAll();
|
|
763
|
+
return Object.keys(e).length > 0 ? t.filter((r) => De(e, r)) : t;
|
|
764
|
+
}
|
|
765
|
+
notify(e) {
|
|
766
|
+
S.batch(() => {
|
|
767
|
+
this.listeners.forEach((t) => {
|
|
768
|
+
t(e);
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
onFocus() {
|
|
773
|
+
S.batch(() => {
|
|
774
|
+
this.getAll().forEach((e) => {
|
|
775
|
+
e.onFocus();
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
onOnline() {
|
|
780
|
+
S.batch(() => {
|
|
781
|
+
this.getAll().forEach((e) => {
|
|
782
|
+
e.onOnline();
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}, j = new WeakMap(), Ie), U, O, Y, I, x, Le, dt = (Le = class extends Je {
|
|
787
|
+
constructor(e) {
|
|
788
|
+
super();
|
|
789
|
+
f(this, I);
|
|
790
|
+
f(this, U);
|
|
791
|
+
f(this, O);
|
|
792
|
+
f(this, Y);
|
|
793
|
+
this.mutationId = e.mutationId, h(this, O, e.mutationCache), h(this, U, []), this.state = e.state || ft(), this.setOptions(e.options), this.scheduleGc();
|
|
794
|
+
}
|
|
795
|
+
setOptions(e) {
|
|
796
|
+
this.options = e, this.updateGcTime(this.options.gcTime);
|
|
797
|
+
}
|
|
798
|
+
get meta() {
|
|
799
|
+
return this.options.meta;
|
|
800
|
+
}
|
|
801
|
+
addObserver(e) {
|
|
802
|
+
i(this, U).includes(e) || (i(this, U).push(e), this.clearGcTimeout(), i(this, O).notify({
|
|
803
|
+
type: "observerAdded",
|
|
804
|
+
mutation: this,
|
|
805
|
+
observer: e
|
|
806
|
+
}));
|
|
807
|
+
}
|
|
808
|
+
removeObserver(e) {
|
|
809
|
+
h(this, U, i(this, U).filter((t) => t !== e)), this.scheduleGc(), i(this, O).notify({
|
|
810
|
+
type: "observerRemoved",
|
|
811
|
+
mutation: this,
|
|
812
|
+
observer: e
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
optionalRemove() {
|
|
816
|
+
i(this, U).length || (this.state.status === "pending" ? this.scheduleGc() : i(this, O).remove(this));
|
|
817
|
+
}
|
|
818
|
+
continue() {
|
|
819
|
+
var e;
|
|
820
|
+
return ((e = i(this, Y)) == null ? void 0 : e.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
821
|
+
this.execute(this.state.variables);
|
|
822
|
+
}
|
|
823
|
+
async execute(e) {
|
|
824
|
+
var u, o, a, l, y, m, c, p, F, C, d, v, A, E, b, D, k, K, fe, oe;
|
|
825
|
+
const t = () => {
|
|
826
|
+
q(this, I, x).call(this, { type: "continue" });
|
|
827
|
+
};
|
|
828
|
+
h(this, Y, _e({
|
|
829
|
+
fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
|
|
830
|
+
onFail: (w, ye) => {
|
|
831
|
+
q(this, I, x).call(this, { type: "failed", failureCount: w, error: ye });
|
|
832
|
+
},
|
|
833
|
+
onPause: () => {
|
|
834
|
+
q(this, I, x).call(this, { type: "pause" });
|
|
835
|
+
},
|
|
836
|
+
onContinue: t,
|
|
837
|
+
retry: this.options.retry ?? 0,
|
|
838
|
+
retryDelay: this.options.retryDelay,
|
|
839
|
+
networkMode: this.options.networkMode,
|
|
840
|
+
canRun: () => i(this, O).canRun(this)
|
|
841
|
+
}));
|
|
842
|
+
const r = this.state.status === "pending", n = !i(this, Y).canStart();
|
|
843
|
+
try {
|
|
844
|
+
if (r)
|
|
845
|
+
t();
|
|
846
|
+
else {
|
|
847
|
+
q(this, I, x).call(this, { type: "pending", variables: e, isPaused: n }), await ((o = (u = i(this, O).config).onMutate) == null ? void 0 : o.call(
|
|
848
|
+
u,
|
|
849
|
+
e,
|
|
850
|
+
this
|
|
851
|
+
));
|
|
852
|
+
const ye = await ((l = (a = this.options).onMutate) == null ? void 0 : l.call(a, e));
|
|
853
|
+
ye !== this.state.context && q(this, I, x).call(this, {
|
|
854
|
+
type: "pending",
|
|
855
|
+
context: ye,
|
|
856
|
+
variables: e,
|
|
857
|
+
isPaused: n
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
const w = await i(this, Y).start();
|
|
861
|
+
return await ((m = (y = i(this, O).config).onSuccess) == null ? void 0 : m.call(
|
|
862
|
+
y,
|
|
863
|
+
w,
|
|
864
|
+
e,
|
|
865
|
+
this.state.context,
|
|
866
|
+
this
|
|
867
|
+
)), await ((p = (c = this.options).onSuccess) == null ? void 0 : p.call(c, w, e, this.state.context)), await ((C = (F = i(this, O).config).onSettled) == null ? void 0 : C.call(
|
|
868
|
+
F,
|
|
869
|
+
w,
|
|
870
|
+
null,
|
|
871
|
+
this.state.variables,
|
|
872
|
+
this.state.context,
|
|
873
|
+
this
|
|
874
|
+
)), await ((v = (d = this.options).onSettled) == null ? void 0 : v.call(d, w, null, e, this.state.context)), q(this, I, x).call(this, { type: "success", data: w }), w;
|
|
875
|
+
} catch (w) {
|
|
876
|
+
try {
|
|
877
|
+
throw await ((E = (A = i(this, O).config).onError) == null ? void 0 : E.call(
|
|
878
|
+
A,
|
|
879
|
+
w,
|
|
880
|
+
e,
|
|
881
|
+
this.state.context,
|
|
882
|
+
this
|
|
883
|
+
)), await ((D = (b = this.options).onError) == null ? void 0 : D.call(
|
|
884
|
+
b,
|
|
885
|
+
w,
|
|
886
|
+
e,
|
|
887
|
+
this.state.context
|
|
888
|
+
)), await ((K = (k = i(this, O).config).onSettled) == null ? void 0 : K.call(
|
|
889
|
+
k,
|
|
890
|
+
void 0,
|
|
891
|
+
w,
|
|
892
|
+
this.state.variables,
|
|
893
|
+
this.state.context,
|
|
894
|
+
this
|
|
895
|
+
)), await ((oe = (fe = this.options).onSettled) == null ? void 0 : oe.call(
|
|
896
|
+
fe,
|
|
897
|
+
void 0,
|
|
898
|
+
w,
|
|
899
|
+
e,
|
|
900
|
+
this.state.context
|
|
901
|
+
)), w;
|
|
902
|
+
} finally {
|
|
903
|
+
q(this, I, x).call(this, { type: "error", error: w });
|
|
904
|
+
}
|
|
905
|
+
} finally {
|
|
906
|
+
i(this, O).runNext(this);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}, U = new WeakMap(), O = new WeakMap(), Y = new WeakMap(), I = new WeakSet(), x = function(e) {
|
|
910
|
+
const t = (r) => {
|
|
911
|
+
switch (e.type) {
|
|
912
|
+
case "failed":
|
|
913
|
+
return {
|
|
914
|
+
...r,
|
|
915
|
+
failureCount: e.failureCount,
|
|
916
|
+
failureReason: e.error
|
|
917
|
+
};
|
|
918
|
+
case "pause":
|
|
919
|
+
return {
|
|
920
|
+
...r,
|
|
921
|
+
isPaused: !0
|
|
922
|
+
};
|
|
923
|
+
case "continue":
|
|
924
|
+
return {
|
|
925
|
+
...r,
|
|
926
|
+
isPaused: !1
|
|
927
|
+
};
|
|
928
|
+
case "pending":
|
|
929
|
+
return {
|
|
930
|
+
...r,
|
|
931
|
+
context: e.context,
|
|
932
|
+
data: void 0,
|
|
933
|
+
failureCount: 0,
|
|
934
|
+
failureReason: null,
|
|
935
|
+
error: null,
|
|
936
|
+
isPaused: e.isPaused,
|
|
937
|
+
status: "pending",
|
|
938
|
+
variables: e.variables,
|
|
939
|
+
submittedAt: Date.now()
|
|
940
|
+
};
|
|
941
|
+
case "success":
|
|
942
|
+
return {
|
|
943
|
+
...r,
|
|
944
|
+
data: e.data,
|
|
945
|
+
failureCount: 0,
|
|
946
|
+
failureReason: null,
|
|
947
|
+
error: null,
|
|
948
|
+
status: "success",
|
|
949
|
+
isPaused: !1
|
|
950
|
+
};
|
|
951
|
+
case "error":
|
|
952
|
+
return {
|
|
953
|
+
...r,
|
|
954
|
+
data: void 0,
|
|
955
|
+
error: e.error,
|
|
956
|
+
failureCount: r.failureCount + 1,
|
|
957
|
+
failureReason: e.error,
|
|
958
|
+
isPaused: !1,
|
|
959
|
+
status: "error"
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
this.state = t(this.state), S.batch(() => {
|
|
964
|
+
i(this, U).forEach((r) => {
|
|
965
|
+
r.onMutationUpdate(e);
|
|
966
|
+
}), i(this, O).notify({
|
|
967
|
+
mutation: this,
|
|
968
|
+
type: "updated",
|
|
969
|
+
action: e
|
|
970
|
+
});
|
|
971
|
+
});
|
|
972
|
+
}, Le);
|
|
973
|
+
function ft() {
|
|
974
|
+
return {
|
|
975
|
+
context: void 0,
|
|
976
|
+
data: void 0,
|
|
977
|
+
error: null,
|
|
978
|
+
failureCount: 0,
|
|
979
|
+
failureReason: null,
|
|
980
|
+
isPaused: !1,
|
|
981
|
+
status: "idle",
|
|
982
|
+
variables: void 0,
|
|
983
|
+
submittedAt: 0
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
var H, R, de, He, yt = (He = class extends be {
|
|
987
|
+
constructor(e = {}) {
|
|
988
|
+
super();
|
|
989
|
+
f(this, H);
|
|
990
|
+
f(this, R);
|
|
991
|
+
f(this, de);
|
|
992
|
+
this.config = e, h(this, H, /* @__PURE__ */ new Set()), h(this, R, /* @__PURE__ */ new Map()), h(this, de, 0);
|
|
993
|
+
}
|
|
994
|
+
build(e, t, r) {
|
|
995
|
+
const n = new dt({
|
|
996
|
+
mutationCache: this,
|
|
997
|
+
mutationId: ++me(this, de)._,
|
|
998
|
+
options: e.defaultMutationOptions(t),
|
|
999
|
+
state: r
|
|
1000
|
+
});
|
|
1001
|
+
return this.add(n), n;
|
|
1002
|
+
}
|
|
1003
|
+
add(e) {
|
|
1004
|
+
i(this, H).add(e);
|
|
1005
|
+
const t = pe(e);
|
|
1006
|
+
if (typeof t == "string") {
|
|
1007
|
+
const r = i(this, R).get(t);
|
|
1008
|
+
r ? r.push(e) : i(this, R).set(t, [e]);
|
|
1009
|
+
}
|
|
1010
|
+
this.notify({ type: "added", mutation: e });
|
|
1011
|
+
}
|
|
1012
|
+
remove(e) {
|
|
1013
|
+
if (i(this, H).delete(e)) {
|
|
1014
|
+
const t = pe(e);
|
|
1015
|
+
if (typeof t == "string") {
|
|
1016
|
+
const r = i(this, R).get(t);
|
|
1017
|
+
if (r)
|
|
1018
|
+
if (r.length > 1) {
|
|
1019
|
+
const n = r.indexOf(e);
|
|
1020
|
+
n !== -1 && r.splice(n, 1);
|
|
1021
|
+
} else r[0] === e && i(this, R).delete(t);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
this.notify({ type: "removed", mutation: e });
|
|
1025
|
+
}
|
|
1026
|
+
canRun(e) {
|
|
1027
|
+
const t = pe(e);
|
|
1028
|
+
if (typeof t == "string") {
|
|
1029
|
+
const r = i(this, R).get(t), n = r == null ? void 0 : r.find(
|
|
1030
|
+
(u) => u.state.status === "pending"
|
|
1031
|
+
);
|
|
1032
|
+
return !n || n === e;
|
|
1033
|
+
} else
|
|
1034
|
+
return !0;
|
|
1035
|
+
}
|
|
1036
|
+
runNext(e) {
|
|
1037
|
+
var r;
|
|
1038
|
+
const t = pe(e);
|
|
1039
|
+
if (typeof t == "string") {
|
|
1040
|
+
const n = (r = i(this, R).get(t)) == null ? void 0 : r.find((u) => u !== e && u.state.isPaused);
|
|
1041
|
+
return (n == null ? void 0 : n.continue()) ?? Promise.resolve();
|
|
1042
|
+
} else
|
|
1043
|
+
return Promise.resolve();
|
|
1044
|
+
}
|
|
1045
|
+
clear() {
|
|
1046
|
+
S.batch(() => {
|
|
1047
|
+
i(this, H).forEach((e) => {
|
|
1048
|
+
this.notify({ type: "removed", mutation: e });
|
|
1049
|
+
}), i(this, H).clear(), i(this, R).clear();
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
getAll() {
|
|
1053
|
+
return Array.from(i(this, H));
|
|
1054
|
+
}
|
|
1055
|
+
find(e) {
|
|
1056
|
+
const t = { exact: !0, ...e };
|
|
1057
|
+
return this.getAll().find(
|
|
1058
|
+
(r) => Qe(t, r)
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
findAll(e = {}) {
|
|
1062
|
+
return this.getAll().filter((t) => Qe(e, t));
|
|
1063
|
+
}
|
|
1064
|
+
notify(e) {
|
|
1065
|
+
S.batch(() => {
|
|
1066
|
+
this.listeners.forEach((t) => {
|
|
1067
|
+
t(e);
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
resumePausedMutations() {
|
|
1072
|
+
const e = this.getAll().filter((t) => t.state.isPaused);
|
|
1073
|
+
return S.batch(
|
|
1074
|
+
() => Promise.all(
|
|
1075
|
+
e.map((t) => t.continue().catch(M))
|
|
1076
|
+
)
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
}, H = new WeakMap(), R = new WeakMap(), de = new WeakMap(), He);
|
|
1080
|
+
function pe(s) {
|
|
1081
|
+
var e;
|
|
1082
|
+
return (e = s.options.scope) == null ? void 0 : e.id;
|
|
1083
|
+
}
|
|
1084
|
+
function Te(s) {
|
|
1085
|
+
return {
|
|
1086
|
+
onFetch: (e, t) => {
|
|
1087
|
+
var m, c, p, F, C;
|
|
1088
|
+
const r = e.options, n = (p = (c = (m = e.fetchOptions) == null ? void 0 : m.meta) == null ? void 0 : c.fetchMore) == null ? void 0 : p.direction, u = ((F = e.state.data) == null ? void 0 : F.pages) || [], o = ((C = e.state.data) == null ? void 0 : C.pageParams) || [];
|
|
1089
|
+
let a = { pages: [], pageParams: [] }, l = 0;
|
|
1090
|
+
const y = async () => {
|
|
1091
|
+
let d = !1;
|
|
1092
|
+
const v = (b) => {
|
|
1093
|
+
Object.defineProperty(b, "signal", {
|
|
1094
|
+
enumerable: !0,
|
|
1095
|
+
get: () => (e.signal.aborted ? d = !0 : e.signal.addEventListener("abort", () => {
|
|
1096
|
+
d = !0;
|
|
1097
|
+
}), e.signal)
|
|
1098
|
+
});
|
|
1099
|
+
}, A = Ge(e.options, e.fetchOptions), E = async (b, D, k) => {
|
|
1100
|
+
if (d)
|
|
1101
|
+
return Promise.reject();
|
|
1102
|
+
if (D == null && b.pages.length)
|
|
1103
|
+
return Promise.resolve(b);
|
|
1104
|
+
const K = {
|
|
1105
|
+
client: e.client,
|
|
1106
|
+
queryKey: e.queryKey,
|
|
1107
|
+
pageParam: D,
|
|
1108
|
+
direction: k ? "backward" : "forward",
|
|
1109
|
+
meta: e.options.meta
|
|
1110
|
+
};
|
|
1111
|
+
v(K);
|
|
1112
|
+
const fe = await A(
|
|
1113
|
+
K
|
|
1114
|
+
), { maxPages: oe } = e.options, w = k ? tt : et;
|
|
1115
|
+
return {
|
|
1116
|
+
pages: w(b.pages, fe, oe),
|
|
1117
|
+
pageParams: w(b.pageParams, D, oe)
|
|
1118
|
+
};
|
|
1119
|
+
};
|
|
1120
|
+
if (n && u.length) {
|
|
1121
|
+
const b = n === "backward", D = b ? mt : Re, k = {
|
|
1122
|
+
pages: u,
|
|
1123
|
+
pageParams: o
|
|
1124
|
+
}, K = D(r, k);
|
|
1125
|
+
a = await E(k, K, b);
|
|
1126
|
+
} else {
|
|
1127
|
+
const b = s ?? u.length;
|
|
1128
|
+
do {
|
|
1129
|
+
const D = l === 0 ? o[0] ?? r.initialPageParam : Re(r, a);
|
|
1130
|
+
if (l > 0 && D == null)
|
|
1131
|
+
break;
|
|
1132
|
+
a = await E(a, D), l++;
|
|
1133
|
+
} while (l < b);
|
|
1134
|
+
}
|
|
1135
|
+
return a;
|
|
1136
|
+
};
|
|
1137
|
+
e.options.persister ? e.fetchFn = () => {
|
|
1138
|
+
var d, v;
|
|
1139
|
+
return (v = (d = e.options).persister) == null ? void 0 : v.call(
|
|
1140
|
+
d,
|
|
1141
|
+
y,
|
|
1142
|
+
{
|
|
1143
|
+
client: e.client,
|
|
1144
|
+
queryKey: e.queryKey,
|
|
1145
|
+
meta: e.options.meta,
|
|
1146
|
+
signal: e.signal
|
|
1147
|
+
},
|
|
1148
|
+
t
|
|
1149
|
+
);
|
|
1150
|
+
} : e.fetchFn = y;
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
function Re(s, { pages: e, pageParams: t }) {
|
|
1155
|
+
const r = e.length - 1;
|
|
1156
|
+
return e.length > 0 ? s.getNextPageParam(
|
|
1157
|
+
e[r],
|
|
1158
|
+
e,
|
|
1159
|
+
t[r],
|
|
1160
|
+
t
|
|
1161
|
+
) : void 0;
|
|
1162
|
+
}
|
|
1163
|
+
function mt(s, { pages: e, pageParams: t }) {
|
|
1164
|
+
var r;
|
|
1165
|
+
return e.length > 0 ? (r = s.getPreviousPageParam) == null ? void 0 : r.call(s, e[0], e, t[0], t) : void 0;
|
|
1166
|
+
}
|
|
1167
|
+
var g, $, V, ie, ne, _, ae, ue, xe, pt = (xe = class {
|
|
1168
|
+
constructor(s = {}) {
|
|
1169
|
+
f(this, g);
|
|
1170
|
+
f(this, $);
|
|
1171
|
+
f(this, V);
|
|
1172
|
+
f(this, ie);
|
|
1173
|
+
f(this, ne);
|
|
1174
|
+
f(this, _);
|
|
1175
|
+
f(this, ae);
|
|
1176
|
+
f(this, ue);
|
|
1177
|
+
h(this, g, s.queryCache || new lt()), h(this, $, s.mutationCache || new yt()), h(this, V, s.defaultOptions || {}), h(this, ie, /* @__PURE__ */ new Map()), h(this, ne, /* @__PURE__ */ new Map()), h(this, _, 0);
|
|
1178
|
+
}
|
|
1179
|
+
mount() {
|
|
1180
|
+
me(this, _)._++, i(this, _) === 1 && (h(this, ae, Ne.subscribe(async (s) => {
|
|
1181
|
+
s && (await this.resumePausedMutations(), i(this, g).onFocus());
|
|
1182
|
+
})), h(this, ue, ge.subscribe(async (s) => {
|
|
1183
|
+
s && (await this.resumePausedMutations(), i(this, g).onOnline());
|
|
1184
|
+
})));
|
|
1185
|
+
}
|
|
1186
|
+
unmount() {
|
|
1187
|
+
var s, e;
|
|
1188
|
+
me(this, _)._--, i(this, _) === 0 && ((s = i(this, ae)) == null || s.call(this), h(this, ae, void 0), (e = i(this, ue)) == null || e.call(this), h(this, ue, void 0));
|
|
1189
|
+
}
|
|
1190
|
+
isFetching(s) {
|
|
1191
|
+
return i(this, g).findAll({ ...s, fetchStatus: "fetching" }).length;
|
|
1192
|
+
}
|
|
1193
|
+
isMutating(s) {
|
|
1194
|
+
return i(this, $).findAll({ ...s, status: "pending" }).length;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
1198
|
+
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
1199
|
+
*
|
|
1200
|
+
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
1201
|
+
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
1202
|
+
*/
|
|
1203
|
+
getQueryData(s) {
|
|
1204
|
+
var t;
|
|
1205
|
+
const e = this.defaultQueryOptions({ queryKey: s });
|
|
1206
|
+
return (t = i(this, g).get(e.queryHash)) == null ? void 0 : t.state.data;
|
|
1207
|
+
}
|
|
1208
|
+
ensureQueryData(s) {
|
|
1209
|
+
const e = this.defaultQueryOptions(s), t = i(this, g).build(this, e), r = t.state.data;
|
|
1210
|
+
return r === void 0 ? this.fetchQuery(s) : (s.revalidateIfStale && t.isStaleByTime(Ae(e.staleTime, t)) && this.prefetchQuery(e), Promise.resolve(r));
|
|
1211
|
+
}
|
|
1212
|
+
getQueriesData(s) {
|
|
1213
|
+
return i(this, g).findAll(s).map(({ queryKey: e, state: t }) => {
|
|
1214
|
+
const r = t.data;
|
|
1215
|
+
return [e, r];
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
setQueryData(s, e, t) {
|
|
1219
|
+
const r = this.defaultQueryOptions({ queryKey: s }), n = i(this, g).get(
|
|
1220
|
+
r.queryHash
|
|
1221
|
+
), u = n == null ? void 0 : n.state.data, o = ze(e, u);
|
|
1222
|
+
if (o !== void 0)
|
|
1223
|
+
return i(this, g).build(this, r).setData(o, { ...t, manual: !0 });
|
|
1224
|
+
}
|
|
1225
|
+
setQueriesData(s, e, t) {
|
|
1226
|
+
return S.batch(
|
|
1227
|
+
() => i(this, g).findAll(s).map(({ queryKey: r }) => [
|
|
1228
|
+
r,
|
|
1229
|
+
this.setQueryData(r, e, t)
|
|
1230
|
+
])
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
getQueryState(s) {
|
|
1234
|
+
var t;
|
|
1235
|
+
const e = this.defaultQueryOptions({ queryKey: s });
|
|
1236
|
+
return (t = i(this, g).get(
|
|
1237
|
+
e.queryHash
|
|
1238
|
+
)) == null ? void 0 : t.state;
|
|
1239
|
+
}
|
|
1240
|
+
removeQueries(s) {
|
|
1241
|
+
const e = i(this, g);
|
|
1242
|
+
S.batch(() => {
|
|
1243
|
+
e.findAll(s).forEach((t) => {
|
|
1244
|
+
e.remove(t);
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
resetQueries(s, e) {
|
|
1249
|
+
const t = i(this, g);
|
|
1250
|
+
return S.batch(() => (t.findAll(s).forEach((r) => {
|
|
1251
|
+
r.reset();
|
|
1252
|
+
}), this.refetchQueries(
|
|
1253
|
+
{
|
|
1254
|
+
type: "active",
|
|
1255
|
+
...s
|
|
1256
|
+
},
|
|
1257
|
+
e
|
|
1258
|
+
)));
|
|
1259
|
+
}
|
|
1260
|
+
cancelQueries(s, e = {}) {
|
|
1261
|
+
const t = { revert: !0, ...e }, r = S.batch(
|
|
1262
|
+
() => i(this, g).findAll(s).map((n) => n.cancel(t))
|
|
1263
|
+
);
|
|
1264
|
+
return Promise.all(r).then(M).catch(M);
|
|
1265
|
+
}
|
|
1266
|
+
invalidateQueries(s, e = {}) {
|
|
1267
|
+
return S.batch(() => (i(this, g).findAll(s).forEach((t) => {
|
|
1268
|
+
t.invalidate();
|
|
1269
|
+
}), (s == null ? void 0 : s.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
|
|
1270
|
+
{
|
|
1271
|
+
...s,
|
|
1272
|
+
type: (s == null ? void 0 : s.refetchType) ?? (s == null ? void 0 : s.type) ?? "active"
|
|
1273
|
+
},
|
|
1274
|
+
e
|
|
1275
|
+
)));
|
|
1276
|
+
}
|
|
1277
|
+
refetchQueries(s, e = {}) {
|
|
1278
|
+
const t = {
|
|
1279
|
+
...e,
|
|
1280
|
+
cancelRefetch: e.cancelRefetch ?? !0
|
|
1281
|
+
}, r = S.batch(
|
|
1282
|
+
() => i(this, g).findAll(s).filter((n) => !n.isDisabled()).map((n) => {
|
|
1283
|
+
let u = n.fetch(void 0, t);
|
|
1284
|
+
return t.throwOnError || (u = u.catch(M)), n.state.fetchStatus === "paused" ? Promise.resolve() : u;
|
|
1285
|
+
})
|
|
1286
|
+
);
|
|
1287
|
+
return Promise.all(r).then(M);
|
|
1288
|
+
}
|
|
1289
|
+
fetchQuery(s) {
|
|
1290
|
+
const e = this.defaultQueryOptions(s);
|
|
1291
|
+
e.retry === void 0 && (e.retry = !1);
|
|
1292
|
+
const t = i(this, g).build(this, e);
|
|
1293
|
+
return t.isStaleByTime(
|
|
1294
|
+
Ae(e.staleTime, t)
|
|
1295
|
+
) ? t.fetch(e) : Promise.resolve(t.state.data);
|
|
1296
|
+
}
|
|
1297
|
+
prefetchQuery(s) {
|
|
1298
|
+
return this.fetchQuery(s).then(M).catch(M);
|
|
1299
|
+
}
|
|
1300
|
+
fetchInfiniteQuery(s) {
|
|
1301
|
+
return s.behavior = Te(s.pages), this.fetchQuery(s);
|
|
1302
|
+
}
|
|
1303
|
+
prefetchInfiniteQuery(s) {
|
|
1304
|
+
return this.fetchInfiniteQuery(s).then(M).catch(M);
|
|
1305
|
+
}
|
|
1306
|
+
ensureInfiniteQueryData(s) {
|
|
1307
|
+
return s.behavior = Te(s.pages), this.ensureQueryData(s);
|
|
1308
|
+
}
|
|
1309
|
+
resumePausedMutations() {
|
|
1310
|
+
return ge.isOnline() ? i(this, $).resumePausedMutations() : Promise.resolve();
|
|
1311
|
+
}
|
|
1312
|
+
getQueryCache() {
|
|
1313
|
+
return i(this, g);
|
|
1314
|
+
}
|
|
1315
|
+
getMutationCache() {
|
|
1316
|
+
return i(this, $);
|
|
1317
|
+
}
|
|
1318
|
+
getDefaultOptions() {
|
|
1319
|
+
return i(this, V);
|
|
1320
|
+
}
|
|
1321
|
+
setDefaultOptions(s) {
|
|
1322
|
+
h(this, V, s);
|
|
1323
|
+
}
|
|
1324
|
+
setQueryDefaults(s, e) {
|
|
1325
|
+
i(this, ie).set(he(s), {
|
|
1326
|
+
queryKey: s,
|
|
1327
|
+
defaultOptions: e
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
getQueryDefaults(s) {
|
|
1331
|
+
const e = [...i(this, ie).values()], t = {};
|
|
1332
|
+
return e.forEach((r) => {
|
|
1333
|
+
ce(s, r.queryKey) && Object.assign(t, r.defaultOptions);
|
|
1334
|
+
}), t;
|
|
1335
|
+
}
|
|
1336
|
+
setMutationDefaults(s, e) {
|
|
1337
|
+
i(this, ne).set(he(s), {
|
|
1338
|
+
mutationKey: s,
|
|
1339
|
+
defaultOptions: e
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
getMutationDefaults(s) {
|
|
1343
|
+
const e = [...i(this, ne).values()], t = {};
|
|
1344
|
+
return e.forEach((r) => {
|
|
1345
|
+
ce(s, r.mutationKey) && Object.assign(t, r.defaultOptions);
|
|
1346
|
+
}), t;
|
|
1347
|
+
}
|
|
1348
|
+
defaultQueryOptions(s) {
|
|
1349
|
+
if (s._defaulted)
|
|
1350
|
+
return s;
|
|
1351
|
+
const e = {
|
|
1352
|
+
...i(this, V).queries,
|
|
1353
|
+
...this.getQueryDefaults(s.queryKey),
|
|
1354
|
+
...s,
|
|
1355
|
+
_defaulted: !0
|
|
1356
|
+
};
|
|
1357
|
+
return e.queryHash || (e.queryHash = Se(
|
|
1358
|
+
e.queryKey,
|
|
1359
|
+
e
|
|
1360
|
+
)), e.refetchOnReconnect === void 0 && (e.refetchOnReconnect = e.networkMode !== "always"), e.throwOnError === void 0 && (e.throwOnError = !!e.suspense), !e.networkMode && e.persister && (e.networkMode = "offlineFirst"), e.queryFn === ve && (e.enabled = !1), e;
|
|
1361
|
+
}
|
|
1362
|
+
defaultMutationOptions(s) {
|
|
1363
|
+
return s != null && s._defaulted ? s : {
|
|
1364
|
+
...i(this, V).mutations,
|
|
1365
|
+
...(s == null ? void 0 : s.mutationKey) && this.getMutationDefaults(s.mutationKey),
|
|
1366
|
+
...s,
|
|
1367
|
+
_defaulted: !0
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
clear() {
|
|
1371
|
+
i(this, g).clear(), i(this, $).clear();
|
|
1372
|
+
}
|
|
1373
|
+
}, g = new WeakMap(), $ = new WeakMap(), V = new WeakMap(), ie = new WeakMap(), ne = new WeakMap(), _ = new WeakMap(), ae = new WeakMap(), ue = new WeakMap(), xe);
|
|
1374
|
+
class J {
|
|
1375
|
+
constructor(e = {}) {
|
|
1376
|
+
this.availableDatasets = [], this.apiUrl = e.apiUrl || "https://api.luzmo.com", this.apiVersion = e.apiVersion || "0.1.0", this.authKey = e.authKey || "", this.authToken = e.authToken || "", this.queryClient = new pt({
|
|
1377
|
+
defaultOptions: {
|
|
1378
|
+
queries: {
|
|
1379
|
+
staleTime: e.staleTime || 5 * 60 * 1e3,
|
|
1380
|
+
// 5 minutes
|
|
1381
|
+
gcTime: e.gcTime || 10 * 60 * 1e3,
|
|
1382
|
+
// 10 minutes
|
|
1383
|
+
retry: e.retry || 3,
|
|
1384
|
+
retryDelay: e.retryDelay || ((t) => Math.min(1e3 * 2 ** t, 3e4))
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}), this.initNetworkListeners();
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Set API configuration
|
|
1391
|
+
* @param config - API configuration
|
|
1392
|
+
*/
|
|
1393
|
+
configure(e = {}) {
|
|
1394
|
+
if (e.apiVersion && (this.apiVersion = e.apiVersion), e.apiUrl && (this.apiUrl = e.apiUrl), e.authKey && (this.authKey = e.authKey), e.authToken && (this.authToken = e.authToken), e.staleTime || e.gcTime || e.retry) {
|
|
1395
|
+
const t = {};
|
|
1396
|
+
e.staleTime && (t.staleTime = e.staleTime), e.gcTime && (t.gcTime = e.gcTime), e.retry && (t.retry = e.retry), this.queryClient.setDefaultOptions({
|
|
1397
|
+
queries: {
|
|
1398
|
+
...this.queryClient.getDefaultOptions().queries,
|
|
1399
|
+
...t
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Initialize network status listeners
|
|
1406
|
+
*/
|
|
1407
|
+
initNetworkListeners() {
|
|
1408
|
+
typeof window < "u" && window.addEventListener("online", () => {
|
|
1409
|
+
console.warn("Network connection restored, refreshing data..."), this.refreshAll();
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Get API headers
|
|
1414
|
+
* @param additionalHeaders - Additional headers to include
|
|
1415
|
+
* @returns Headers for API requests
|
|
1416
|
+
*/
|
|
1417
|
+
getHeaders(e = {}) {
|
|
1418
|
+
return {
|
|
1419
|
+
"Content-Type": "application/json",
|
|
1420
|
+
...e
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Make API request with advanced error handling
|
|
1425
|
+
* Default method is POST and supports an optional JSON body
|
|
1426
|
+
* @param endpoint - API endpoint
|
|
1427
|
+
* @param jsonBody - Optional JSON body to send with request
|
|
1428
|
+
* @param options - Additional fetch options
|
|
1429
|
+
* @returns API response
|
|
1430
|
+
* @throws {Error} If API request fails
|
|
1431
|
+
*/
|
|
1432
|
+
async fetchApi(e, t, r = {}) {
|
|
1433
|
+
const n = `${this.apiUrl}/${this.apiVersion}${e}`, o = {
|
|
1434
|
+
method: r.method || "POST",
|
|
1435
|
+
headers: this.getHeaders(r.headers),
|
|
1436
|
+
mode: "cors",
|
|
1437
|
+
...r
|
|
1438
|
+
};
|
|
1439
|
+
t !== void 0 && (t.key = this.authKey, t.token = this.authToken, o.body = JSON.stringify(t));
|
|
1440
|
+
try {
|
|
1441
|
+
const a = await fetch(n, o);
|
|
1442
|
+
if (!a.ok) {
|
|
1443
|
+
const l = await a.json().catch(() => null);
|
|
1444
|
+
throw a.status === 401 || a.status === 403 ? new Error(
|
|
1445
|
+
"Authentication failed. Please check your API token."
|
|
1446
|
+
) : a.status === 404 ? new Error(`Resource not found: ${e}`) : a.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(
|
|
1447
|
+
(l == null ? void 0 : l.message) || `API request failed with status ${a.status}`
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
return await a.json();
|
|
1451
|
+
} catch (a) {
|
|
1452
|
+
throw console.error(`API request to ${e} failed:`, a), a instanceof Error && (a.endpoint = e, a.timestamp = (/* @__PURE__ */ new Date()).toISOString()), a;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Fetch all available datasets with pagination support
|
|
1457
|
+
* @param options - Pagination options
|
|
1458
|
+
* @returns Paginated list of datasets
|
|
1459
|
+
*/
|
|
1460
|
+
async fetchAllDatasets(e = {}) {
|
|
1461
|
+
const t = e.offset || 0, r = e.limit || 50, n = ["datasets", t, r];
|
|
1462
|
+
return await this.queryClient.fetchQuery({
|
|
1463
|
+
queryKey: n,
|
|
1464
|
+
queryFn: async () => {
|
|
1465
|
+
const u = {
|
|
1466
|
+
action: "get",
|
|
1467
|
+
version: this.apiVersion,
|
|
1468
|
+
find: {
|
|
1469
|
+
where: {
|
|
1470
|
+
type: "dataset"
|
|
1471
|
+
},
|
|
1472
|
+
limit: r,
|
|
1473
|
+
offset: t
|
|
1474
|
+
}
|
|
1475
|
+
}, o = await this.fetchApi("/securable", u);
|
|
1476
|
+
return {
|
|
1477
|
+
data: (o == null ? void 0 : o.rows) ?? [],
|
|
1478
|
+
pagination: {
|
|
1479
|
+
offset: t,
|
|
1480
|
+
limit: r,
|
|
1481
|
+
total: (o == null ? void 0 : o.count) ?? 0,
|
|
1482
|
+
pages: Math.ceil(((o == null ? void 0 : o.count) ?? 0) / r)
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Search datasets by name or description
|
|
1490
|
+
* @param query - Search query
|
|
1491
|
+
* @returns List of matching datasets
|
|
1492
|
+
*/
|
|
1493
|
+
async searchDatasets(e, t) {
|
|
1494
|
+
if (!e)
|
|
1495
|
+
return { data: [] };
|
|
1496
|
+
const r = ["datasets", "search", e, t];
|
|
1497
|
+
return await this.queryClient.fetchQuery({
|
|
1498
|
+
queryKey: r,
|
|
1499
|
+
queryFn: async () => {
|
|
1500
|
+
const n = {
|
|
1501
|
+
action: "get",
|
|
1502
|
+
version: this.apiVersion,
|
|
1503
|
+
find: {
|
|
1504
|
+
where: {
|
|
1505
|
+
type: "dataset"
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
(e == null ? void 0 : e.length) > 0 && (n.find.search = {
|
|
1510
|
+
match_types: ["name"],
|
|
1511
|
+
keyphrase: e
|
|
1512
|
+
}), t != null && t.offset && (n.find.offset = t == null ? void 0 : t.offset), t != null && t.limit && (n.find.limit = t == null ? void 0 : t.limit);
|
|
1513
|
+
const u = await this.fetchApi("/securable", n), o = {
|
|
1514
|
+
data: (u == null ? void 0 : u.rows) ?? []
|
|
1515
|
+
};
|
|
1516
|
+
return t != null && t.limit && (o.pagination = {
|
|
1517
|
+
offset: (t == null ? void 0 : t.offset) ?? 0,
|
|
1518
|
+
limit: t == null ? void 0 : t.limit,
|
|
1519
|
+
total: (u == null ? void 0 : u.count) ?? 0,
|
|
1520
|
+
pages: Math.ceil(((u == null ? void 0 : u.count) ?? 0) / (t == null ? void 0 : t.limit))
|
|
1521
|
+
}), o;
|
|
1522
|
+
}
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Fetches multiple datasets with their associated columns and formulas metadata
|
|
1527
|
+
* @param datasetIds - Array of dataset IDs to fetch
|
|
1528
|
+
* @returns Promise that resolves to an array of DatasetMetadata objects containing:
|
|
1529
|
+
* - Basic dataset info (id, name, description)
|
|
1530
|
+
* - Columns with metadata including joins, hierarchy levels, and currency info
|
|
1531
|
+
* - Formulas with their expressions and currency associations
|
|
1532
|
+
* @throws Error if datasetIds is empty or null
|
|
1533
|
+
*/
|
|
1534
|
+
async fetchDatasetsWithColumnsAndFormulas(e) {
|
|
1535
|
+
if (!e || e.length === 0)
|
|
1536
|
+
throw new Error("At least one dataset ID is required");
|
|
1537
|
+
const t = ["datasets", e, this.authKey, this.authToken];
|
|
1538
|
+
return await this.queryClient.fetchQuery({
|
|
1539
|
+
queryKey: t,
|
|
1540
|
+
queryFn: async () => {
|
|
1541
|
+
const r = {
|
|
1542
|
+
action: "get",
|
|
1543
|
+
version: this.apiVersion,
|
|
1544
|
+
find: {
|
|
1545
|
+
where: {
|
|
1546
|
+
type: "dataset",
|
|
1547
|
+
id: {
|
|
1548
|
+
in: e
|
|
1549
|
+
}
|
|
1550
|
+
},
|
|
1551
|
+
attributes: ["name", "id", "description"],
|
|
1552
|
+
include: [
|
|
1553
|
+
{
|
|
1554
|
+
model: "Column",
|
|
1555
|
+
attributes: [
|
|
1556
|
+
"id",
|
|
1557
|
+
"name",
|
|
1558
|
+
"description",
|
|
1559
|
+
"type",
|
|
1560
|
+
"subtype",
|
|
1561
|
+
"format",
|
|
1562
|
+
"hidden",
|
|
1563
|
+
"lowestLevel",
|
|
1564
|
+
"expression",
|
|
1565
|
+
"duration_levels",
|
|
1566
|
+
"duration_format"
|
|
1567
|
+
],
|
|
1568
|
+
separate: !0,
|
|
1569
|
+
order: [["order", "asc"]],
|
|
1570
|
+
include: [
|
|
1571
|
+
{
|
|
1572
|
+
model: "Column",
|
|
1573
|
+
attributes: [
|
|
1574
|
+
"id",
|
|
1575
|
+
"securable_id",
|
|
1576
|
+
"hierarchy_enabled",
|
|
1577
|
+
"currency_id"
|
|
1578
|
+
],
|
|
1579
|
+
as: "Joins"
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
model: "HierarchyLevel",
|
|
1583
|
+
attributes: ["id", "level", "name"],
|
|
1584
|
+
as: "HierarchyLevels"
|
|
1585
|
+
},
|
|
1586
|
+
{
|
|
1587
|
+
model: "Currency",
|
|
1588
|
+
attributes: ["id", "name", "symbol"],
|
|
1589
|
+
as: "Currency"
|
|
1590
|
+
}
|
|
1591
|
+
]
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
model: "Formula",
|
|
1595
|
+
attributes: [
|
|
1596
|
+
"id",
|
|
1597
|
+
"name",
|
|
1598
|
+
"description",
|
|
1599
|
+
"type",
|
|
1600
|
+
"subtype",
|
|
1601
|
+
"format",
|
|
1602
|
+
"hidden",
|
|
1603
|
+
"lowestLevel",
|
|
1604
|
+
"expression",
|
|
1605
|
+
"duration_levels",
|
|
1606
|
+
"duration_format"
|
|
1607
|
+
],
|
|
1608
|
+
include: [
|
|
1609
|
+
{
|
|
1610
|
+
model: "Currency",
|
|
1611
|
+
attributes: ["id", "name", "symbol"],
|
|
1612
|
+
as: "Currency"
|
|
1613
|
+
}
|
|
1614
|
+
]
|
|
1615
|
+
}
|
|
1616
|
+
]
|
|
1617
|
+
}
|
|
1618
|
+
}, n = await this.fetchApi("/securable", r);
|
|
1619
|
+
return (n == null ? void 0 : n.rows) ?? [];
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Fetch data from a dataset with filtering
|
|
1625
|
+
* @param datasetId - Dataset ID
|
|
1626
|
+
* @param queryParams - Query parameters (filters, sort, etc.)
|
|
1627
|
+
* @returns Dataset data
|
|
1628
|
+
*/
|
|
1629
|
+
async fetchData(e) {
|
|
1630
|
+
if (!e) throw new Error("Query is required");
|
|
1631
|
+
const t = ["data", e];
|
|
1632
|
+
return await this.queryClient.fetchQuery({
|
|
1633
|
+
queryKey: t,
|
|
1634
|
+
queryFn: async () => {
|
|
1635
|
+
const r = {
|
|
1636
|
+
action: "get",
|
|
1637
|
+
version: this.apiVersion,
|
|
1638
|
+
find: {
|
|
1639
|
+
queries: [e]
|
|
1640
|
+
}
|
|
1641
|
+
}, n = await this.fetchApi("/data", r);
|
|
1642
|
+
return {
|
|
1643
|
+
data: (n == null ? void 0 : n.data) || [],
|
|
1644
|
+
performance: (n == null ? void 0 : n.performance) || {}
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Refresh all queries
|
|
1651
|
+
*/
|
|
1652
|
+
refreshAll() {
|
|
1653
|
+
this.queryClient.refetchQueries();
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Invalidate cached data for a dataset
|
|
1657
|
+
* @param datasetId - Dataset ID (optional)
|
|
1658
|
+
*/
|
|
1659
|
+
invalidateDatasetData(e) {
|
|
1660
|
+
e ? (this.queryClient.invalidateQueries({ queryKey: ["dataset", e] }), this.queryClient.invalidateQueries({ queryKey: ["columns", e] })) : this.queryClient.invalidateQueries({ queryKey: ["datasets"] });
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Invalidate all cached data
|
|
1664
|
+
*/
|
|
1665
|
+
invalidateAll() {
|
|
1666
|
+
this.queryClient.clear();
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* Create a singleton instance
|
|
1670
|
+
* @param config - API configuration
|
|
1671
|
+
* @returns Singleton instance
|
|
1672
|
+
*/
|
|
1673
|
+
static getInstance(e = {}) {
|
|
1674
|
+
return J.instance ? Object.keys(e).length > 0 && J.instance.configure(e) : J.instance = new J(e), J.instance;
|
|
1675
|
+
}
|
|
1676
|
+
async fetchDatasetsRecursive(e) {
|
|
1677
|
+
if (!e || e.length === 0)
|
|
1678
|
+
throw new Error("At least one dataset ID is required");
|
|
1679
|
+
const t = [...new Set(e)], r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), u = (o) => {
|
|
1680
|
+
o && !r.has(o) && !t.includes(o) && t.push(o);
|
|
1681
|
+
};
|
|
1682
|
+
for (; t.length > 0; ) {
|
|
1683
|
+
const o = [];
|
|
1684
|
+
for (; t.length > 0 && o.length < 50; ) {
|
|
1685
|
+
const a = t.shift();
|
|
1686
|
+
r.has(a) || o.push(a);
|
|
1687
|
+
}
|
|
1688
|
+
if (o.length !== 0)
|
|
1689
|
+
try {
|
|
1690
|
+
(await this.fetchDatasetsWithColumnsAndFormulas(o)).forEach((l) => {
|
|
1691
|
+
const y = this.postProcessDatasetMetadata(l);
|
|
1692
|
+
r.add(y.id), this.queryClient.setQueryData(["dataset", y.id], y), (y.outgoingJoins ?? []).map((c) => c.securable_id).filter((c) => !!c && c !== y.id).forEach((c) => {
|
|
1693
|
+
u(c);
|
|
1694
|
+
}), n.set(y.id, y), this.availableDatasets.some((c) => c.id === y.id) || this.availableDatasets.push({
|
|
1695
|
+
id: y.id,
|
|
1696
|
+
name: y.name,
|
|
1697
|
+
columns: y.columns
|
|
1698
|
+
});
|
|
1699
|
+
});
|
|
1700
|
+
} catch (a) {
|
|
1701
|
+
console.error("Error fetching datasets recursively:", a);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
return [...n.values()];
|
|
1705
|
+
}
|
|
1706
|
+
postProcessDatasetMetadata(e) {
|
|
1707
|
+
const t = [], r = (e.columns ?? []).map((n) => {
|
|
1708
|
+
const u = n.joins ?? (Array.isArray(n.joins) ? n.joins : []);
|
|
1709
|
+
Array.isArray(u) && u.length > 0 && t.push(...u);
|
|
1710
|
+
const { joins: o, ...a } = n;
|
|
1711
|
+
return {
|
|
1712
|
+
...a,
|
|
1713
|
+
joins: u
|
|
1714
|
+
};
|
|
1715
|
+
});
|
|
1716
|
+
return {
|
|
1717
|
+
...e,
|
|
1718
|
+
columns: r,
|
|
1719
|
+
formulas: e.formulas ?? [],
|
|
1720
|
+
outgoingJoins: t,
|
|
1721
|
+
dateLoaded: /* @__PURE__ */ new Date()
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
getAvailableDatasets() {
|
|
1725
|
+
return this.availableDatasets;
|
|
1726
|
+
}
|
|
1727
|
+
getLinkedDatasetsIds(e) {
|
|
1728
|
+
const t = this.queryClient.getQueryData(["dataset", e]);
|
|
1729
|
+
return t ? (t.outgoingJoins ?? []).map((r) => r.securable_id).filter((r) => !!r && r !== e) : [];
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
const gt = J.getInstance();
|
|
1733
|
+
export {
|
|
1734
|
+
gt as d
|
|
1735
|
+
};
|