@gravity-ui/data-source 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/build/cjs/core/index.d.ts +2 -1
  2. package/build/cjs/core/index.js +7 -0
  3. package/build/cjs/core/index.js.map +1 -1
  4. package/build/cjs/core/types/DataSource.d.ts +15 -19
  5. package/build/cjs/core/types/DataSource.js.map +1 -1
  6. package/build/cjs/core/utils/__tests__/composeFullKey.test.js +34 -0
  7. package/build/cjs/core/utils/__tests__/composeFullKey.test.js.map +1 -0
  8. package/build/cjs/core/utils/__tests__/composeKey.test.js +32 -0
  9. package/build/cjs/core/utils/__tests__/composeKey.test.js.map +1 -0
  10. package/build/cjs/core/utils/__tests__/getError.test.js +31 -0
  11. package/build/cjs/core/utils/__tests__/getError.test.js.map +1 -0
  12. package/build/cjs/core/utils/__tests__/getStatus.test.js +49 -0
  13. package/build/cjs/core/utils/__tests__/getStatus.test.js.map +1 -0
  14. package/build/cjs/core/utils/__tests__/hasTag.test.js +31 -0
  15. package/build/cjs/core/utils/__tests__/hasTag.test.js.map +1 -0
  16. package/build/cjs/core/utils/__tests__/mergeStatuses.test.js +25 -0
  17. package/build/cjs/core/utils/__tests__/mergeStatuses.test.js.map +1 -0
  18. package/build/cjs/core/utils/__tests__/skipContext.test.js +70 -0
  19. package/build/cjs/core/utils/__tests__/skipContext.test.js.map +1 -0
  20. package/build/cjs/core/utils/__tests__/withCancellation.test.js +106 -0
  21. package/build/cjs/core/utils/__tests__/withCancellation.test.js.map +1 -0
  22. package/build/cjs/core/utils/__tests__/withCatch.test.js +208 -0
  23. package/build/cjs/core/utils/__tests__/withCatch.test.js.map +1 -0
  24. package/build/cjs/core/utils/withCatch.d.ts +26 -0
  25. package/build/cjs/core/utils/withCatch.js +37 -0
  26. package/build/cjs/core/utils/withCatch.js.map +1 -0
  27. package/build/cjs/react/__tests__/DataManagerContext.test.js +46 -0
  28. package/build/cjs/react/__tests__/DataManagerContext.test.js.map +1 -0
  29. package/build/cjs/react/__tests__/withDataManager.test.js +58 -0
  30. package/build/cjs/react/__tests__/withDataManager.test.js.map +1 -0
  31. package/build/cjs/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js +187 -0
  32. package/build/cjs/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js.map +1 -0
  33. package/build/cjs/react/components/DataLoader/__tests__/DataLoader.test.js +119 -0
  34. package/build/cjs/react/components/DataLoader/__tests__/DataLoader.test.js.map +1 -0
  35. package/build/cjs/react/withDataManager.d.ts +1 -1
  36. package/build/cjs/react/withDataManager.js +3 -3
  37. package/build/cjs/react/withDataManager.js.map +1 -1
  38. package/build/cjs/react-query/constants.d.ts +2 -0
  39. package/build/cjs/react-query/constants.js +9 -0
  40. package/build/cjs/react-query/constants.js.map +1 -0
  41. package/build/cjs/react-query/hooks/__tests__/useQueryContext.test.js +55 -0
  42. package/build/cjs/react-query/hooks/__tests__/useQueryContext.test.js.map +1 -0
  43. package/build/cjs/react-query/hooks/__tests__/useQueryData.test.js +97 -0
  44. package/build/cjs/react-query/hooks/__tests__/useQueryData.test.js.map +1 -0
  45. package/build/cjs/react-query/hooks/__tests__/useQueryResponses.test.js +77 -0
  46. package/build/cjs/react-query/hooks/__tests__/useQueryResponses.test.js.map +1 -0
  47. package/build/cjs/react-query/hooks/__tests__/useRefetchAll.test.js +79 -0
  48. package/build/cjs/react-query/hooks/__tests__/useRefetchAll.test.js.map +1 -0
  49. package/build/cjs/react-query/hooks/__tests__/useRefetchErrored.test.js +117 -0
  50. package/build/cjs/react-query/hooks/__tests__/useRefetchErrored.test.js.map +1 -0
  51. package/build/cjs/react-query/hooks/__tests__/useRefetchInterval.test.js +156 -0
  52. package/build/cjs/react-query/hooks/__tests__/useRefetchInterval.test.js.map +1 -0
  53. package/build/cjs/react-query/hooks/useRefetchInterval.d.ts +1 -1
  54. package/build/cjs/react-query/impl/infinite/factory.d.ts +1 -1
  55. package/build/cjs/react-query/impl/infinite/factory.js.map +1 -1
  56. package/build/cjs/react-query/impl/infinite/types.d.ts +7 -7
  57. package/build/cjs/react-query/impl/infinite/types.js.map +1 -1
  58. package/build/cjs/react-query/impl/infinite/utils.js +11 -22
  59. package/build/cjs/react-query/impl/infinite/utils.js.map +1 -1
  60. package/build/cjs/react-query/impl/plain/factory.d.ts +1 -1
  61. package/build/cjs/react-query/impl/plain/factory.js.map +1 -1
  62. package/build/cjs/react-query/impl/plain/types.d.ts +4 -4
  63. package/build/cjs/react-query/impl/plain/types.js.map +1 -1
  64. package/build/cjs/react-query/impl/plain/utils.js +12 -23
  65. package/build/cjs/react-query/impl/plain/utils.js.map +1 -1
  66. package/build/cjs/react-query/utils/__tests__/formatNullableValue.test.js +27 -0
  67. package/build/cjs/react-query/utils/__tests__/formatNullableValue.test.js.map +1 -0
  68. package/build/cjs/react-query/utils/__tests__/getProgressiveRefetch.test.js +76 -0
  69. package/build/cjs/react-query/utils/__tests__/getProgressiveRefetch.test.js.map +1 -0
  70. package/build/cjs/react-query/utils/__tests__/normalizeStatus.test.js +30 -0
  71. package/build/cjs/react-query/utils/__tests__/normalizeStatus.test.js.map +1 -0
  72. package/build/cjs/react-query/utils/__tests__/notReachable.test.js +35 -0
  73. package/build/cjs/react-query/utils/__tests__/notReachable.test.js.map +1 -0
  74. package/build/cjs/react-query/utils/__tests__/parseNullableValue.test.js +27 -0
  75. package/build/cjs/react-query/utils/__tests__/parseNullableValue.test.js.map +1 -0
  76. package/build/cjs/react-query/utils/formatNullableValue.d.ts +2 -0
  77. package/build/cjs/react-query/utils/formatNullableValue.js +17 -0
  78. package/build/cjs/react-query/utils/formatNullableValue.js.map +1 -0
  79. package/build/cjs/react-query/utils/getProgressiveRefetch.d.ts +2 -2
  80. package/build/cjs/react-query/utils/parseNullableValue.d.ts +2 -0
  81. package/build/cjs/react-query/utils/parseNullableValue.js +17 -0
  82. package/build/cjs/react-query/utils/parseNullableValue.js.map +1 -0
  83. package/build/cjs/setupTests.d.ts +1 -0
  84. package/build/cjs/setupTests.js +4 -0
  85. package/build/cjs/setupTests.js.map +1 -0
  86. package/build/esm/core/index.d.ts +2 -1
  87. package/build/esm/core/index.js +1 -0
  88. package/build/esm/core/index.js.map +1 -1
  89. package/build/esm/core/types/DataSource.d.ts +15 -19
  90. package/build/esm/core/types/DataSource.js.map +1 -1
  91. package/build/esm/core/utils/__tests__/composeFullKey.test.js +32 -0
  92. package/build/esm/core/utils/__tests__/composeFullKey.test.js.map +1 -0
  93. package/build/esm/core/utils/__tests__/composeKey.test.js +30 -0
  94. package/build/esm/core/utils/__tests__/composeKey.test.js.map +1 -0
  95. package/build/esm/core/utils/__tests__/getError.test.js +29 -0
  96. package/build/esm/core/utils/__tests__/getError.test.js.map +1 -0
  97. package/build/esm/core/utils/__tests__/getStatus.test.js +47 -0
  98. package/build/esm/core/utils/__tests__/getStatus.test.js.map +1 -0
  99. package/build/esm/core/utils/__tests__/hasTag.test.js +29 -0
  100. package/build/esm/core/utils/__tests__/hasTag.test.js.map +1 -0
  101. package/build/esm/core/utils/__tests__/mergeStatuses.test.js +23 -0
  102. package/build/esm/core/utils/__tests__/mergeStatuses.test.js.map +1 -0
  103. package/build/esm/core/utils/__tests__/skipContext.test.js +67 -0
  104. package/build/esm/core/utils/__tests__/skipContext.test.js.map +1 -0
  105. package/build/esm/core/utils/__tests__/withCancellation.test.js +104 -0
  106. package/build/esm/core/utils/__tests__/withCancellation.test.js.map +1 -0
  107. package/build/esm/core/utils/__tests__/withCatch.test.js +205 -0
  108. package/build/esm/core/utils/__tests__/withCatch.test.js.map +1 -0
  109. package/build/esm/core/utils/withCatch.d.ts +26 -0
  110. package/build/esm/core/utils/withCatch.js +31 -0
  111. package/build/esm/core/utils/withCatch.js.map +1 -0
  112. package/build/esm/react/__tests__/DataManagerContext.test.js +43 -0
  113. package/build/esm/react/__tests__/DataManagerContext.test.js.map +1 -0
  114. package/build/esm/react/__tests__/withDataManager.test.js +55 -0
  115. package/build/esm/react/__tests__/withDataManager.test.js.map +1 -0
  116. package/build/esm/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js +184 -0
  117. package/build/esm/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js.map +1 -0
  118. package/build/esm/react/components/DataLoader/__tests__/DataLoader.test.js +116 -0
  119. package/build/esm/react/components/DataLoader/__tests__/DataLoader.test.js.map +1 -0
  120. package/build/esm/react/withDataManager.d.ts +1 -1
  121. package/build/esm/react/withDataManager.js +3 -3
  122. package/build/esm/react/withDataManager.js.map +1 -1
  123. package/build/esm/react-query/constants.d.ts +2 -0
  124. package/build/esm/react-query/constants.js +3 -0
  125. package/build/esm/react-query/constants.js.map +1 -0
  126. package/build/esm/react-query/hooks/__tests__/useQueryContext.test.js +52 -0
  127. package/build/esm/react-query/hooks/__tests__/useQueryContext.test.js.map +1 -0
  128. package/build/esm/react-query/hooks/__tests__/useQueryData.test.js +95 -0
  129. package/build/esm/react-query/hooks/__tests__/useQueryData.test.js.map +1 -0
  130. package/build/esm/react-query/hooks/__tests__/useQueryResponses.test.js +74 -0
  131. package/build/esm/react-query/hooks/__tests__/useQueryResponses.test.js.map +1 -0
  132. package/build/esm/react-query/hooks/__tests__/useRefetchAll.test.js +77 -0
  133. package/build/esm/react-query/hooks/__tests__/useRefetchAll.test.js.map +1 -0
  134. package/build/esm/react-query/hooks/__tests__/useRefetchErrored.test.js +115 -0
  135. package/build/esm/react-query/hooks/__tests__/useRefetchErrored.test.js.map +1 -0
  136. package/build/esm/react-query/hooks/__tests__/useRefetchInterval.test.js +154 -0
  137. package/build/esm/react-query/hooks/__tests__/useRefetchInterval.test.js.map +1 -0
  138. package/build/esm/react-query/hooks/useRefetchInterval.d.ts +1 -1
  139. package/build/esm/react-query/impl/infinite/factory.d.ts +1 -1
  140. package/build/esm/react-query/impl/infinite/factory.js.map +1 -1
  141. package/build/esm/react-query/impl/infinite/types.d.ts +7 -7
  142. package/build/esm/react-query/impl/infinite/types.js.map +1 -1
  143. package/build/esm/react-query/impl/infinite/utils.js +9 -20
  144. package/build/esm/react-query/impl/infinite/utils.js.map +1 -1
  145. package/build/esm/react-query/impl/plain/factory.d.ts +1 -1
  146. package/build/esm/react-query/impl/plain/factory.js.map +1 -1
  147. package/build/esm/react-query/impl/plain/types.d.ts +4 -4
  148. package/build/esm/react-query/impl/plain/types.js.map +1 -1
  149. package/build/esm/react-query/impl/plain/utils.js +10 -21
  150. package/build/esm/react-query/impl/plain/utils.js.map +1 -1
  151. package/build/esm/react-query/utils/__tests__/formatNullableValue.test.js +25 -0
  152. package/build/esm/react-query/utils/__tests__/formatNullableValue.test.js.map +1 -0
  153. package/build/esm/react-query/utils/__tests__/getProgressiveRefetch.test.js +74 -0
  154. package/build/esm/react-query/utils/__tests__/getProgressiveRefetch.test.js.map +1 -0
  155. package/build/esm/react-query/utils/__tests__/normalizeStatus.test.js +28 -0
  156. package/build/esm/react-query/utils/__tests__/normalizeStatus.test.js.map +1 -0
  157. package/build/esm/react-query/utils/__tests__/notReachable.test.js +33 -0
  158. package/build/esm/react-query/utils/__tests__/notReachable.test.js.map +1 -0
  159. package/build/esm/react-query/utils/__tests__/parseNullableValue.test.js +25 -0
  160. package/build/esm/react-query/utils/__tests__/parseNullableValue.test.js.map +1 -0
  161. package/build/esm/react-query/utils/formatNullableValue.d.ts +2 -0
  162. package/build/esm/react-query/utils/formatNullableValue.js +11 -0
  163. package/build/esm/react-query/utils/formatNullableValue.js.map +1 -0
  164. package/build/esm/react-query/utils/getProgressiveRefetch.d.ts +2 -2
  165. package/build/esm/react-query/utils/parseNullableValue.d.ts +2 -0
  166. package/build/esm/react-query/utils/parseNullableValue.js +11 -0
  167. package/build/esm/react-query/utils/parseNullableValue.js.map +1 -0
  168. package/build/esm/setupTests.d.ts +1 -0
  169. package/build/esm/setupTests.js +2 -0
  170. package/build/esm/setupTests.js.map +1 -0
  171. package/package.json +17 -13
  172. package/build/cjs/react-query/impl/utils.d.ts +0 -4
  173. package/build/cjs/react-query/impl/utils.js +0 -27
  174. package/build/cjs/react-query/impl/utils.js.map +0 -1
  175. package/build/esm/react-query/impl/utils.d.ts +0 -4
  176. package/build/esm/react-query/impl/utils.js +0 -21
  177. package/build/esm/react-query/impl/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_reactQuery","require","_core","_utils","_interopRequireDefault","e","__esModule","default","composeOptions","exports","context","dataSource","params","options","transformParams","transformResponse","transformError","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","response","wrap","_callee$","_context","prev","next","fetch","sent","abrupt","formatNullableValue","t0","stop","_x","apply","arguments","select","actualResponse","parseNullableValue","_objectSpread","queryKey","composeFullKey","idle","skipToken"],"sources":["utils.ts"],"sourcesContent":["import {type QueryFunctionContext, skipToken} from '@tanstack/react-query';\n\nimport {composeFullKey, idle} from '../../../core';\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceResponse,\n} from '../../../core';\nimport type {nullSymbol, undefinedSymbol} from '../utils';\nimport {formatNullableValue, parseNullableValue} from '../utils';\n\nimport type {AnyPlainQueryDataSource, QueryObserverExtendedOptions} from './types';\n\nexport const composeOptions = <TDataSource extends AnyPlainQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): QueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n DataSourceData<TDataSource>,\n DataSourceResponse<TDataSource>,\n DataSourceKey\n> => {\n const {transformParams, transformResponse, transformError} = dataSource;\n\n const queryFn = async (\n fetchContext: QueryFunctionContext<DataSourceKey>,\n ): Promise<DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol> => {\n try {\n const response = await dataSource.fetch(\n context,\n fetchContext,\n transformParams ? transformParams(params) : params,\n );\n\n return formatNullableValue(response);\n } catch (error) {\n if (!transformError) {\n throw error;\n }\n\n return formatNullableValue(transformError(error));\n }\n };\n\n const select = (\n response: DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol,\n ): DataSourceData<TDataSource> => {\n const actualResponse = parseNullableValue(response);\n\n return transformResponse ? transformResponse(actualResponse) : actualResponse;\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAWA,IAAAE,MAAA,GAAAF,OAAA;AAAgE,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIzD,IAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CACvBE,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAOhD;EACD,IAAOC,eAAe,GAAuCH,UAAU,CAAhEG,eAAe;IAAEC,iBAAiB,GAAoBJ,UAAU,CAA/CI,iBAAiB;IAAEC,cAAc,GAAIL,UAAU,CAA5BK,cAAc;EAEzD,IAAMC,OAAO;IAAA,IAAAC,IAAA,OAAAC,0BAAA,gBAAAC,oBAAA,CAAAC,IAAA,CAAG,SAAAC,QACZC,YAAiD;MAAA,IAAAC,QAAA;MAAA,OAAAJ,oBAAA,CAAAK,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAAF,QAAA,CAAAC,IAAA;YAAAD,QAAA,CAAAE,IAAA;YAAA,OAGtBlB,UAAU,CAACmB,KAAK,CACnCpB,OAAO,EACPa,YAAY,EACZT,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAChD,CAAC;UAAA;YAJKY,QAAQ,GAAAG,QAAA,CAAAI,IAAA;YAAA,OAAAJ,QAAA,CAAAK,MAAA,WAMP,IAAAC,0BAAmB,EAACT,QAAQ,CAAC;UAAA;YAAAG,QAAA,CAAAC,IAAA;YAAAD,QAAA,CAAAO,EAAA,GAAAP,QAAA;YAAA,IAE/BX,cAAc;cAAAW,QAAA,CAAAE,IAAA;cAAA;YAAA;YAAA,MAAAF,QAAA,CAAAO,EAAA;UAAA;YAAA,OAAAP,QAAA,CAAAK,MAAA,WAIZ,IAAAC,0BAAmB,EAACjB,cAAc,CAAAW,QAAA,CAAAO,EAAM,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAP,QAAA,CAAAQ,IAAA;QAAA;MAAA,GAAAb,OAAA;IAAA,CAExD;IAAA,gBAlBKL,OAAOA,CAAAmB,EAAA;MAAA,OAAAlB,IAAA,CAAAmB,KAAA,OAAAC,SAAA;IAAA;EAAA,GAkBZ;EAED,IAAMC,MAAM,GAAG,SAATA,MAAMA,CACRf,QAAsF,EACxD;IAC9B,IAAMgB,cAAc,GAAG,IAAAC,yBAAkB,EAACjB,QAAQ,CAAC;IAEnD,OAAOT,iBAAiB,GAAGA,iBAAiB,CAACyB,cAAc,CAAC,GAAGA,cAAc;EACjF,CAAC;EAED,WAAAE,sBAAA,MAAAA,sBAAA;IACIC,QAAQ,EAAE,IAAAC,oBAAc,EAACjC,UAAU,EAAEC,MAAM,CAAC;IAC5CK,OAAO,EAAEL,MAAM,KAAKiC,UAAI,GAAGC,qBAAS,GAAG7B,OAAO;IAC9CsB,MAAM,EAANA;EAAM,GACH5B,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactQuery","require","_core","_formatNullableValue","_parseNullableValue","_interopRequireDefault","e","__esModule","default","composeOptions","exports","context","dataSource","params","options","transformParams","transformResponse","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","response","wrap","_callee$","_context","prev","next","fetch","sent","abrupt","formatNullableValue","stop","_x","apply","arguments","select","actualResponse","parseNullableValue","_objectSpread","queryKey","composeFullKey","idle","skipToken"],"sources":["utils.ts"],"sourcesContent":["import {type QueryFunctionContext, skipToken} from '@tanstack/react-query';\n\nimport {composeFullKey, idle} from '../../../core';\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceResponse,\n} from '../../../core';\nimport type {nullSymbol, undefinedSymbol} from '../../constants';\nimport {formatNullableValue} from '../../utils/formatNullableValue';\nimport {parseNullableValue} from '../../utils/parseNullableValue';\n\nimport type {AnyPlainQueryDataSource, QueryObserverExtendedOptions} from './types';\n\nexport const composeOptions = <TDataSource extends AnyPlainQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): QueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n DataSourceData<TDataSource>,\n DataSourceResponse<TDataSource>,\n DataSourceKey\n> => {\n const {transformParams, transformResponse} = dataSource;\n\n const queryFn = async (\n fetchContext: QueryFunctionContext<DataSourceKey>,\n ): Promise<DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol> => {\n const response = await dataSource.fetch(\n context,\n fetchContext,\n transformParams ? transformParams(params) : params,\n );\n\n return formatNullableValue(response);\n };\n\n const select = (\n response: DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol,\n ): DataSourceData<TDataSource> => {\n const actualResponse = parseNullableValue(response) as DataSourceData<TDataSource>;\n\n return transformResponse ? transformResponse(actualResponse) : actualResponse;\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAWA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAAiE,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI1D,IAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CACvBE,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAOhD;EACD,IAAOC,eAAe,GAAuBH,UAAU,CAAhDG,eAAe;IAAEC,iBAAiB,GAAIJ,UAAU,CAA/BI,iBAAiB;EAEzC,IAAMC,OAAO;IAAA,IAAAC,IAAA,OAAAC,0BAAA,mBAAAC,4BAAA,IAAAC,IAAA,CAAG,SAAAC,QACZC,YAAiD;MAAA,IAAAC,QAAA;MAAA,WAAAJ,4BAAA,IAAAK,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAAF,QAAA,CAAAE,IAAA;YAAA,OAE1BjB,UAAU,CAACkB,KAAK,CACnCnB,OAAO,EACPY,YAAY,EACZR,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAChD,CAAC;UAAA;YAJKW,QAAQ,GAAAG,QAAA,CAAAI,IAAA;YAAA,OAAAJ,QAAA,CAAAK,MAAA,WAMP,IAAAC,wCAAmB,EAACT,QAAQ,CAAC;UAAA;UAAA;YAAA,OAAAG,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAZ,OAAA;IAAA,CACvC;IAAA,gBAVKL,OAAOA,CAAAkB,EAAA;MAAA,OAAAjB,IAAA,CAAAkB,KAAA,OAAAC,SAAA;IAAA;EAAA,GAUZ;EAED,IAAMC,MAAM,GAAG,SAATA,MAAMA,CACRd,QAAsF,EACxD;IAC9B,IAAMe,cAAc,GAAG,IAAAC,sCAAkB,EAAChB,QAAQ,CAAgC;IAElF,OAAOR,iBAAiB,GAAGA,iBAAiB,CAACuB,cAAc,CAAC,GAAGA,cAAc;EACjF,CAAC;EAED,WAAAE,sBAAA,MAAAA,sBAAA;IACIC,QAAQ,EAAE,IAAAC,oBAAc,EAAC/B,UAAU,EAAEC,MAAM,CAAC;IAC5CI,OAAO,EAAEJ,MAAM,KAAK+B,UAAI,GAAGC,qBAAS,GAAG5B,OAAO;IAC9CqB,MAAM,EAANA;EAAM,GACH1B,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _constants = require("../../constants");
4
+ var _formatNullableValue = require("../formatNullableValue");
5
+ describe('formatNullableValue', function () {
6
+ it('should return undefinedSymbol for undefined', function () {
7
+ expect((0, _formatNullableValue.formatNullableValue)(undefined)).toBe(_constants.undefinedSymbol);
8
+ });
9
+ it('should return nullSymbol for null', function () {
10
+ expect((0, _formatNullableValue.formatNullableValue)(null)).toBe(_constants.nullSymbol);
11
+ });
12
+ it('should return the value for non-nullable values', function () {
13
+ expect((0, _formatNullableValue.formatNullableValue)(42)).toBe(42);
14
+ expect((0, _formatNullableValue.formatNullableValue)(0)).toBe(0);
15
+ expect((0, _formatNullableValue.formatNullableValue)('test')).toBe('test');
16
+ expect((0, _formatNullableValue.formatNullableValue)('')).toBe('');
17
+ expect((0, _formatNullableValue.formatNullableValue)(true)).toBe(true);
18
+ expect((0, _formatNullableValue.formatNullableValue)(false)).toBe(false);
19
+ var obj = {
20
+ a: 1
21
+ };
22
+ expect((0, _formatNullableValue.formatNullableValue)(obj)).toBe(obj);
23
+ var arr = [1, 2, 3];
24
+ expect((0, _formatNullableValue.formatNullableValue)(arr)).toBe(arr);
25
+ });
26
+ });
27
+ // #sourceMappingURL=formatNullableValue.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","_formatNullableValue","describe","it","expect","formatNullableValue","undefined","toBe","undefinedSymbol","nullSymbol","obj","a","arr"],"sources":["formatNullableValue.test.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../../constants';\nimport {formatNullableValue} from '../formatNullableValue';\n\ndescribe('formatNullableValue', () => {\n it('should return undefinedSymbol for undefined', () => {\n expect(formatNullableValue(undefined)).toBe(undefinedSymbol);\n });\n\n it('should return nullSymbol for null', () => {\n expect(formatNullableValue(null)).toBe(nullSymbol);\n });\n\n it('should return the value for non-nullable values', () => {\n expect(formatNullableValue(42)).toBe(42);\n expect(formatNullableValue(0)).toBe(0);\n expect(formatNullableValue('test')).toBe('test');\n expect(formatNullableValue('')).toBe('');\n expect(formatNullableValue(true)).toBe(true);\n expect(formatNullableValue(false)).toBe(false);\n\n const obj = {a: 1};\n expect(formatNullableValue(obj)).toBe(obj);\n\n const arr = [1, 2, 3];\n expect(formatNullableValue(arr)).toBe(arr);\n });\n});\n"],"mappings":";;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAEAE,QAAQ,CAAC,qBAAqB,EAAE,YAAM;EAClCC,EAAE,CAAC,6CAA6C,EAAE,YAAM;IACpDC,MAAM,CAAC,IAAAC,wCAAmB,EAACC,SAAS,CAAC,CAAC,CAACC,IAAI,CAACC,0BAAe,CAAC;EAChE,CAAC,CAAC;EAEFL,EAAE,CAAC,mCAAmC,EAAE,YAAM;IAC1CC,MAAM,CAAC,IAAAC,wCAAmB,EAAC,IAAI,CAAC,CAAC,CAACE,IAAI,CAACE,qBAAU,CAAC;EACtD,CAAC,CAAC;EAEFN,EAAE,CAAC,iDAAiD,EAAE,YAAM;IACxDC,MAAM,CAAC,IAAAC,wCAAmB,EAAC,EAAE,CAAC,CAAC,CAACE,IAAI,CAAC,EAAE,CAAC;IACxCH,MAAM,CAAC,IAAAC,wCAAmB,EAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,CAAC,CAAC;IACtCH,MAAM,CAAC,IAAAC,wCAAmB,EAAC,MAAM,CAAC,CAAC,CAACE,IAAI,CAAC,MAAM,CAAC;IAChDH,MAAM,CAAC,IAAAC,wCAAmB,EAAC,EAAE,CAAC,CAAC,CAACE,IAAI,CAAC,EAAE,CAAC;IACxCH,MAAM,CAAC,IAAAC,wCAAmB,EAAC,IAAI,CAAC,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;IAC5CH,MAAM,CAAC,IAAAC,wCAAmB,EAAC,KAAK,CAAC,CAAC,CAACE,IAAI,CAAC,KAAK,CAAC;IAE9C,IAAMG,GAAG,GAAG;MAACC,CAAC,EAAE;IAAC,CAAC;IAClBP,MAAM,CAAC,IAAAC,wCAAmB,EAACK,GAAG,CAAC,CAAC,CAACH,IAAI,CAACG,GAAG,CAAC;IAE1C,IAAME,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrBR,MAAM,CAAC,IAAAC,wCAAmB,EAACO,GAAG,CAAC,CAAC,CAACL,IAAI,CAACK,GAAG,CAAC;EAC9C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _getProgressiveRefetch = require("../getProgressiveRefetch");
4
+ describe('getProgressiveRefetch', function () {
5
+ it('should return a function', function () {
6
+ var refetchFn = (0, _getProgressiveRefetch.getProgressiveRefetch)({
7
+ minInterval: 1000,
8
+ maxInterval: 10000
9
+ });
10
+ expect(refetchFn).toEqual(expect.any(Function));
11
+ });
12
+ it('should return minInterval for the first call (count = 0)', function () {
13
+ var minInterval = 1000;
14
+ var maxInterval = 10000;
15
+ var refetchFn = (0, _getProgressiveRefetch.getProgressiveRefetch)({
16
+ minInterval: minInterval,
17
+ maxInterval: maxInterval
18
+ });
19
+ var result = refetchFn({}, 0);
20
+ expect(result).toBe(minInterval);
21
+ });
22
+ it('should increase interval by multiplier for each count', function () {
23
+ var minInterval = 1000;
24
+ var maxInterval = 10000;
25
+ var multiplier = 2;
26
+ var refetchFn = (0, _getProgressiveRefetch.getProgressiveRefetch)({
27
+ minInterval: minInterval,
28
+ maxInterval: maxInterval,
29
+ multiplier: multiplier
30
+ });
31
+ expect(refetchFn({}, 0)).toBe(1000);
32
+ expect(refetchFn({}, 1)).toBe(2000);
33
+ expect(refetchFn({}, 2)).toBe(4000);
34
+ expect(refetchFn({}, 3)).toBe(8000);
35
+ });
36
+ it('should not exceed maxInterval', function () {
37
+ var minInterval = 1000;
38
+ var maxInterval = 5000;
39
+ var multiplier = 2;
40
+ var refetchFn = (0, _getProgressiveRefetch.getProgressiveRefetch)({
41
+ minInterval: minInterval,
42
+ maxInterval: maxInterval,
43
+ multiplier: multiplier
44
+ });
45
+ expect(refetchFn({}, 0)).toBe(1000);
46
+ expect(refetchFn({}, 1)).toBe(2000);
47
+ expect(refetchFn({}, 2)).toBe(4000);
48
+ expect(refetchFn({}, 3)).toBe(5000);
49
+ expect(refetchFn({}, 4)).toBe(5000);
50
+ });
51
+ it('should use default multiplier (2) if not provided', function () {
52
+ var minInterval = 1000;
53
+ var maxInterval = 10000;
54
+ var refetchFn = (0, _getProgressiveRefetch.getProgressiveRefetch)({
55
+ minInterval: minInterval,
56
+ maxInterval: maxInterval
57
+ });
58
+ expect(refetchFn({}, 0)).toBe(1000);
59
+ expect(refetchFn({}, 1)).toBe(2000);
60
+ expect(refetchFn({}, 2)).toBe(4000);
61
+ });
62
+ it('should work with custom multiplier', function () {
63
+ var minInterval = 1000;
64
+ var maxInterval = 10000;
65
+ var multiplier = 1.5;
66
+ var refetchFn = (0, _getProgressiveRefetch.getProgressiveRefetch)({
67
+ minInterval: minInterval,
68
+ maxInterval: maxInterval,
69
+ multiplier: multiplier
70
+ });
71
+ expect(refetchFn({}, 0)).toBe(1000);
72
+ expect(refetchFn({}, 1)).toBe(1500);
73
+ expect(refetchFn({}, 2)).toBe(2250);
74
+ });
75
+ });
76
+ // #sourceMappingURL=getProgressiveRefetch.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getProgressiveRefetch","require","describe","it","refetchFn","getProgressiveRefetch","minInterval","maxInterval","expect","toEqual","any","Function","result","toBe","multiplier"],"sources":["getProgressiveRefetch.test.ts"],"sourcesContent":["import type {Query} from '@tanstack/react-query';\n\nimport {getProgressiveRefetch} from '../getProgressiveRefetch';\n\ndescribe('getProgressiveRefetch', () => {\n it('should return a function', () => {\n const refetchFn = getProgressiveRefetch({\n minInterval: 1000,\n maxInterval: 10000,\n });\n\n expect(refetchFn).toEqual(expect.any(Function));\n });\n\n it('should return minInterval for the first call (count = 0)', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n });\n\n const result = refetchFn({} as Query, 0);\n\n expect(result).toBe(minInterval);\n });\n\n it('should increase interval by multiplier for each count', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const multiplier = 2;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n multiplier,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(2000);\n expect(refetchFn({} as Query, 2)).toBe(4000);\n expect(refetchFn({} as Query, 3)).toBe(8000);\n });\n\n it('should not exceed maxInterval', () => {\n const minInterval = 1000;\n const maxInterval = 5000;\n const multiplier = 2;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n multiplier,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(2000);\n expect(refetchFn({} as Query, 2)).toBe(4000);\n expect(refetchFn({} as Query, 3)).toBe(5000);\n expect(refetchFn({} as Query, 4)).toBe(5000);\n });\n\n it('should use default multiplier (2) if not provided', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(2000);\n expect(refetchFn({} as Query, 2)).toBe(4000);\n });\n\n it('should work with custom multiplier', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const multiplier = 1.5;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n multiplier,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(1500);\n expect(refetchFn({} as Query, 2)).toBe(2250);\n });\n});\n"],"mappings":";;AAEA,IAAAA,sBAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,uBAAuB,EAAE,YAAM;EACpCC,EAAE,CAAC,0BAA0B,EAAE,YAAM;IACjC,IAAMC,SAAS,GAAG,IAAAC,4CAAqB,EAAC;MACpCC,WAAW,EAAE,IAAI;MACjBC,WAAW,EAAE;IACjB,CAAC,CAAC;IAEFC,MAAM,CAACJ,SAAS,CAAC,CAACK,OAAO,CAACD,MAAM,CAACE,GAAG,CAACC,QAAQ,CAAC,CAAC;EACnD,CAAC,CAAC;EAEFR,EAAE,CAAC,0DAA0D,EAAE,YAAM;IACjE,IAAMG,WAAW,GAAG,IAAI;IACxB,IAAMC,WAAW,GAAG,KAAK;IACzB,IAAMH,SAAS,GAAG,IAAAC,4CAAqB,EAAC;MACpCC,WAAW,EAAXA,WAAW;MACXC,WAAW,EAAXA;IACJ,CAAC,CAAC;IAEF,IAAMK,MAAM,GAAGR,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC;IAExCI,MAAM,CAACI,MAAM,CAAC,CAACC,IAAI,CAACP,WAAW,CAAC;EACpC,CAAC,CAAC;EAEFH,EAAE,CAAC,uDAAuD,EAAE,YAAM;IAC9D,IAAMG,WAAW,GAAG,IAAI;IACxB,IAAMC,WAAW,GAAG,KAAK;IACzB,IAAMO,UAAU,GAAG,CAAC;IACpB,IAAMV,SAAS,GAAG,IAAAC,4CAAqB,EAAC;MACpCC,WAAW,EAAXA,WAAW;MACXC,WAAW,EAAXA,WAAW;MACXO,UAAU,EAAVA;IACJ,CAAC,CAAC;IAEFN,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;EAChD,CAAC,CAAC;EAEFV,EAAE,CAAC,+BAA+B,EAAE,YAAM;IACtC,IAAMG,WAAW,GAAG,IAAI;IACxB,IAAMC,WAAW,GAAG,IAAI;IACxB,IAAMO,UAAU,GAAG,CAAC;IACpB,IAAMV,SAAS,GAAG,IAAAC,4CAAqB,EAAC;MACpCC,WAAW,EAAXA,WAAW;MACXC,WAAW,EAAXA,WAAW;MACXO,UAAU,EAAVA;IACJ,CAAC,CAAC;IAEFN,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;EAChD,CAAC,CAAC;EAEFV,EAAE,CAAC,mDAAmD,EAAE,YAAM;IAC1D,IAAMG,WAAW,GAAG,IAAI;IACxB,IAAMC,WAAW,GAAG,KAAK;IACzB,IAAMH,SAAS,GAAG,IAAAC,4CAAqB,EAAC;MACpCC,WAAW,EAAXA,WAAW;MACXC,WAAW,EAAXA;IACJ,CAAC,CAAC;IAEFC,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;EAChD,CAAC,CAAC;EAEFV,EAAE,CAAC,oCAAoC,EAAE,YAAM;IAC3C,IAAMG,WAAW,GAAG,IAAI;IACxB,IAAMC,WAAW,GAAG,KAAK;IACzB,IAAMO,UAAU,GAAG,GAAG;IACtB,IAAMV,SAAS,GAAG,IAAAC,4CAAqB,EAAC;MACpCC,WAAW,EAAXA,WAAW;MACXC,WAAW,EAAXA,WAAW;MACXO,UAAU,EAAVA;IACJ,CAAC,CAAC;IAEFN,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACJ,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACS,IAAI,CAAC,IAAI,CAAC;EAChD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _normalizeStatus = require("../normalizeStatus");
4
+ describe('normalizeStatus', function () {
5
+ it('should return loading when status is pending and fetchStatus is fetching', function () {
6
+ var status = 'pending';
7
+ var fetchStatus = 'fetching';
8
+ var result = (0, _normalizeStatus.normalizeStatus)(status, fetchStatus);
9
+ expect(result).toBe('loading');
10
+ });
11
+ it('should return success when status is pending and fetchStatus is not fetching', function () {
12
+ var status = 'pending';
13
+ var fetchStatus = 'idle';
14
+ var result = (0, _normalizeStatus.normalizeStatus)(status, fetchStatus);
15
+ expect(result).toBe('success');
16
+ });
17
+ it('should return success when status is success', function () {
18
+ var status = 'success';
19
+ var fetchStatus = 'idle';
20
+ var result = (0, _normalizeStatus.normalizeStatus)(status, fetchStatus);
21
+ expect(result).toBe('success');
22
+ });
23
+ it('should return error when status is error', function () {
24
+ var status = 'error';
25
+ var fetchStatus = 'idle';
26
+ var result = (0, _normalizeStatus.normalizeStatus)(status, fetchStatus);
27
+ expect(result).toBe('error');
28
+ });
29
+ });
30
+ // #sourceMappingURL=normalizeStatus.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeStatus","require","describe","it","status","fetchStatus","result","normalizeStatus","expect","toBe"],"sources":["normalizeStatus.test.ts"],"sourcesContent":["import type {FetchStatus, QueryStatus} from '@tanstack/react-query';\n\nimport {normalizeStatus} from '../normalizeStatus';\n\ndescribe('normalizeStatus', () => {\n it('should return loading when status is pending and fetchStatus is fetching', () => {\n const status: QueryStatus = 'pending';\n const fetchStatus: FetchStatus = 'fetching';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('loading');\n });\n\n it('should return success when status is pending and fetchStatus is not fetching', () => {\n const status: QueryStatus = 'pending';\n const fetchStatus: FetchStatus = 'idle';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('success');\n });\n\n it('should return success when status is success', () => {\n const status: QueryStatus = 'success';\n const fetchStatus: FetchStatus = 'idle';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('success');\n });\n\n it('should return error when status is error', () => {\n const status: QueryStatus = 'error';\n const fetchStatus: FetchStatus = 'idle';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('error');\n });\n});\n"],"mappings":";;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,iBAAiB,EAAE,YAAM;EAC9BC,EAAE,CAAC,0EAA0E,EAAE,YAAM;IACjF,IAAMC,MAAmB,GAAG,SAAS;IACrC,IAAMC,WAAwB,GAAG,UAAU;IAE3C,IAAMC,MAAM,GAAG,IAAAC,gCAAe,EAACH,MAAM,EAAEC,WAAW,CAAC;IAEnDG,MAAM,CAACF,MAAM,CAAC,CAACG,IAAI,CAAC,SAAS,CAAC;EAClC,CAAC,CAAC;EAEFN,EAAE,CAAC,8EAA8E,EAAE,YAAM;IACrF,IAAMC,MAAmB,GAAG,SAAS;IACrC,IAAMC,WAAwB,GAAG,MAAM;IAEvC,IAAMC,MAAM,GAAG,IAAAC,gCAAe,EAACH,MAAM,EAAEC,WAAW,CAAC;IAEnDG,MAAM,CAACF,MAAM,CAAC,CAACG,IAAI,CAAC,SAAS,CAAC;EAClC,CAAC,CAAC;EAEFN,EAAE,CAAC,8CAA8C,EAAE,YAAM;IACrD,IAAMC,MAAmB,GAAG,SAAS;IACrC,IAAMC,WAAwB,GAAG,MAAM;IAEvC,IAAMC,MAAM,GAAG,IAAAC,gCAAe,EAACH,MAAM,EAAEC,WAAW,CAAC;IAEnDG,MAAM,CAACF,MAAM,CAAC,CAACG,IAAI,CAAC,SAAS,CAAC;EAClC,CAAC,CAAC;EAEFN,EAAE,CAAC,0CAA0C,EAAE,YAAM;IACjD,IAAMC,MAAmB,GAAG,OAAO;IACnC,IAAMC,WAAwB,GAAG,MAAM;IAEvC,IAAMC,MAAM,GAAG,IAAAC,gCAAe,EAACH,MAAM,EAAEC,WAAW,CAAC;IAEnDG,MAAM,CAACF,MAAM,CAAC,CAACG,IAAI,CAAC,OAAO,CAAC;EAChC,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _notReachable = require("../notReachable");
4
+ describe('notReachable', function () {
5
+ it('should throw an error with default message', function () {
6
+ var callNotReachable = function callNotReachable() {
7
+ (0, _notReachable.notReachable)('test');
8
+ };
9
+ expect(callNotReachable).toThrow('Not reachable state: test');
10
+ });
11
+ it('should throw an error with custom message', function () {
12
+ var callNotReachable = function callNotReachable() {
13
+ (0, _notReachable.notReachable)('test', 'Custom error message');
14
+ };
15
+ expect(callNotReachable).toThrow('Custom error message');
16
+ });
17
+ it('should be used for exhaustive type checking', function () {
18
+ var getNumberName = function getNumberName(num) {
19
+ switch (num) {
20
+ case 1:
21
+ return 'one';
22
+ case 2:
23
+ return 'two';
24
+ case 3:
25
+ return 'three';
26
+ default:
27
+ return (0, _notReachable.notReachable)(num);
28
+ }
29
+ };
30
+ expect(getNumberName(1)).toBe('one');
31
+ expect(getNumberName(2)).toBe('two');
32
+ expect(getNumberName(3)).toBe('three');
33
+ });
34
+ });
35
+ // #sourceMappingURL=notReachable.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_notReachable","require","describe","it","callNotReachable","notReachable","expect","toThrow","getNumberName","num","toBe"],"sources":["notReachable.test.ts"],"sourcesContent":["import {notReachable} from '../notReachable';\n\ndescribe('notReachable', () => {\n it('should throw an error with default message', () => {\n const callNotReachable = () => {\n notReachable('test' as never);\n };\n\n expect(callNotReachable).toThrow('Not reachable state: test');\n });\n\n it('should throw an error with custom message', () => {\n const callNotReachable = () => {\n notReachable('test' as never, 'Custom error message');\n };\n\n expect(callNotReachable).toThrow('Custom error message');\n });\n\n it('should be used for exhaustive type checking', () => {\n const getNumberName = (num: 1 | 2 | 3): string => {\n switch (num) {\n case 1:\n return 'one';\n case 2:\n return 'two';\n case 3:\n return 'three';\n default:\n return notReachable(num);\n }\n };\n\n expect(getNumberName(1)).toBe('one');\n expect(getNumberName(2)).toBe('two');\n expect(getNumberName(3)).toBe('three');\n });\n});\n"],"mappings":";;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,cAAc,EAAE,YAAM;EAC3BC,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACnD,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAA,EAAS;MAC3B,IAAAC,0BAAY,EAAC,MAAe,CAAC;IACjC,CAAC;IAEDC,MAAM,CAACF,gBAAgB,CAAC,CAACG,OAAO,CAAC,2BAA2B,CAAC;EACjE,CAAC,CAAC;EAEFJ,EAAE,CAAC,2CAA2C,EAAE,YAAM;IAClD,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAA,EAAS;MAC3B,IAAAC,0BAAY,EAAC,MAAM,EAAW,sBAAsB,CAAC;IACzD,CAAC;IAEDC,MAAM,CAACF,gBAAgB,CAAC,CAACG,OAAO,CAAC,sBAAsB,CAAC;EAC5D,CAAC,CAAC;EAEFJ,EAAE,CAAC,6CAA6C,EAAE,YAAM;IACpD,IAAMK,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,GAAc,EAAa;MAC9C,QAAQA,GAAG;QACP,KAAK,CAAC;UACF,OAAO,KAAK;QAChB,KAAK,CAAC;UACF,OAAO,KAAK;QAChB,KAAK,CAAC;UACF,OAAO,OAAO;QAClB;UACI,OAAO,IAAAJ,0BAAY,EAACI,GAAG,CAAC;MAChC;IACJ,CAAC;IAEDH,MAAM,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,KAAK,CAAC;IACpCJ,MAAM,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,KAAK,CAAC;IACpCJ,MAAM,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,OAAO,CAAC;EAC1C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _constants = require("../../constants");
4
+ var _parseNullableValue = require("../parseNullableValue");
5
+ describe('parseNullableValue', function () {
6
+ it('should return undefined for undefinedSymbol', function () {
7
+ expect((0, _parseNullableValue.parseNullableValue)(_constants.undefinedSymbol)).toBeUndefined();
8
+ });
9
+ it('should return null for nullSymbol', function () {
10
+ expect((0, _parseNullableValue.parseNullableValue)(_constants.nullSymbol)).toBeNull();
11
+ });
12
+ it('should return the value for non-symbol values', function () {
13
+ expect((0, _parseNullableValue.parseNullableValue)(42)).toBe(42);
14
+ expect((0, _parseNullableValue.parseNullableValue)(0)).toBe(0);
15
+ expect((0, _parseNullableValue.parseNullableValue)('test')).toBe('test');
16
+ expect((0, _parseNullableValue.parseNullableValue)('')).toBe('');
17
+ expect((0, _parseNullableValue.parseNullableValue)(true)).toBe(true);
18
+ expect((0, _parseNullableValue.parseNullableValue)(false)).toBe(false);
19
+ var obj = {
20
+ a: 1
21
+ };
22
+ expect((0, _parseNullableValue.parseNullableValue)(obj)).toBe(obj);
23
+ var arr = [1, 2, 3];
24
+ expect((0, _parseNullableValue.parseNullableValue)(arr)).toBe(arr);
25
+ });
26
+ });
27
+ // #sourceMappingURL=parseNullableValue.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","_parseNullableValue","describe","it","expect","parseNullableValue","undefinedSymbol","toBeUndefined","nullSymbol","toBeNull","toBe","obj","a","arr"],"sources":["parseNullableValue.test.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../../constants';\nimport {parseNullableValue} from '../parseNullableValue';\n\ndescribe('parseNullableValue', () => {\n it('should return undefined for undefinedSymbol', () => {\n expect(parseNullableValue(undefinedSymbol)).toBeUndefined();\n });\n\n it('should return null for nullSymbol', () => {\n expect(parseNullableValue(nullSymbol)).toBeNull();\n });\n\n it('should return the value for non-symbol values', () => {\n expect(parseNullableValue(42)).toBe(42);\n expect(parseNullableValue(0)).toBe(0);\n expect(parseNullableValue('test')).toBe('test');\n expect(parseNullableValue('')).toBe('');\n expect(parseNullableValue(true)).toBe(true);\n expect(parseNullableValue(false)).toBe(false);\n\n const obj = {a: 1};\n expect(parseNullableValue(obj)).toBe(obj);\n\n const arr = [1, 2, 3];\n expect(parseNullableValue(arr)).toBe(arr);\n });\n});\n"],"mappings":";;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEAE,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACjCC,EAAE,CAAC,6CAA6C,EAAE,YAAM;IACpDC,MAAM,CAAC,IAAAC,sCAAkB,EAACC,0BAAe,CAAC,CAAC,CAACC,aAAa,CAAC,CAAC;EAC/D,CAAC,CAAC;EAEFJ,EAAE,CAAC,mCAAmC,EAAE,YAAM;IAC1CC,MAAM,CAAC,IAAAC,sCAAkB,EAACG,qBAAU,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACrD,CAAC,CAAC;EAEFN,EAAE,CAAC,+CAA+C,EAAE,YAAM;IACtDC,MAAM,CAAC,IAAAC,sCAAkB,EAAC,EAAE,CAAC,CAAC,CAACK,IAAI,CAAC,EAAE,CAAC;IACvCN,MAAM,CAAC,IAAAC,sCAAkB,EAAC,CAAC,CAAC,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;IACrCN,MAAM,CAAC,IAAAC,sCAAkB,EAAC,MAAM,CAAC,CAAC,CAACK,IAAI,CAAC,MAAM,CAAC;IAC/CN,MAAM,CAAC,IAAAC,sCAAkB,EAAC,EAAE,CAAC,CAAC,CAACK,IAAI,CAAC,EAAE,CAAC;IACvCN,MAAM,CAAC,IAAAC,sCAAkB,EAAC,IAAI,CAAC,CAAC,CAACK,IAAI,CAAC,IAAI,CAAC;IAC3CN,MAAM,CAAC,IAAAC,sCAAkB,EAAC,KAAK,CAAC,CAAC,CAACK,IAAI,CAAC,KAAK,CAAC;IAE7C,IAAMC,GAAG,GAAG;MAACC,CAAC,EAAE;IAAC,CAAC;IAClBR,MAAM,CAAC,IAAAC,sCAAkB,EAACM,GAAG,CAAC,CAAC,CAACD,IAAI,CAACC,GAAG,CAAC;IAEzC,IAAME,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrBT,MAAM,CAAC,IAAAC,sCAAkB,EAACQ,GAAG,CAAC,CAAC,CAACH,IAAI,CAACG,GAAG,CAAC;EAC7C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { nullSymbol, undefinedSymbol } from '../constants';
2
+ export declare const formatNullableValue: <T>(value: T | undefined | null) => T | typeof undefinedSymbol | typeof nullSymbol;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatNullableValue = void 0;
7
+ var _constants = require("../constants");
8
+ var formatNullableValue = exports.formatNullableValue = function formatNullableValue(value) {
9
+ if (value === undefined) {
10
+ return _constants.undefinedSymbol;
11
+ }
12
+ if (value === null) {
13
+ return _constants.nullSymbol;
14
+ }
15
+ return value;
16
+ };
17
+ // #sourceMappingURL=formatNullableValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","formatNullableValue","exports","value","undefined","undefinedSymbol","nullSymbol"],"sources":["formatNullableValue.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../constants';\n\nexport const formatNullableValue = <T>(\n value: T | undefined | null,\n): T | typeof undefinedSymbol | typeof nullSymbol => {\n if (value === undefined) {\n return undefinedSymbol;\n }\n\n if (value === null) {\n return nullSymbol;\n }\n\n return value;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,IAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,SAAtBA,mBAAmBA,CAC5BE,KAA2B,EACsB;EACjD,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACrB,OAAOC,0BAAe;EAC1B;EAEA,IAAIF,KAAK,KAAK,IAAI,EAAE;IAChB,OAAOG,qBAAU;EACrB;EAEA,OAAOH,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import type { QueryKey } from '@tanstack/react-query';
1
+ import type { DefaultError, QueryKey } from '@tanstack/react-query';
2
2
  import type { RefetchIntervalFunction } from '../types/refetch-interval';
3
3
  export interface ProgressiveRefetchOptions {
4
4
  minInterval: number;
5
5
  maxInterval: number;
6
6
  multiplier?: number;
7
7
  }
8
- export declare const getProgressiveRefetch: <TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>({ minInterval, maxInterval, multiplier, }: ProgressiveRefetchOptions) => RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey>;
8
+ export declare const getProgressiveRefetch: <TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>({ minInterval, maxInterval, multiplier, }: ProgressiveRefetchOptions) => RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey>;
@@ -0,0 +1,2 @@
1
+ import { nullSymbol, undefinedSymbol } from '../constants';
2
+ export declare const parseNullableValue: <T>(value: T | typeof undefinedSymbol | typeof nullSymbol) => T | undefined | null;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseNullableValue = void 0;
7
+ var _constants = require("../constants");
8
+ var parseNullableValue = exports.parseNullableValue = function parseNullableValue(value) {
9
+ if (value === _constants.undefinedSymbol) {
10
+ return undefined;
11
+ }
12
+ if (value === _constants.nullSymbol) {
13
+ return null;
14
+ }
15
+ return value;
16
+ };
17
+ // #sourceMappingURL=parseNullableValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","parseNullableValue","exports","value","undefinedSymbol","undefined","nullSymbol"],"sources":["parseNullableValue.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../constants';\n\nexport const parseNullableValue = <T>(\n value: T | typeof undefinedSymbol | typeof nullSymbol,\n): T | undefined | null => {\n if (value === undefinedSymbol) {\n return undefined;\n }\n\n if (value === nullSymbol) {\n return null;\n }\n\n return value;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,IAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,SAArBA,kBAAkBA,CAC3BE,KAAqD,EAC9B;EACvB,IAAIA,KAAK,KAAKC,0BAAe,EAAE;IAC3B,OAAOC,SAAS;EACpB;EAEA,IAAIF,KAAK,KAAKG,qBAAU,EAAE;IACtB,OAAO,IAAI;EACf;EAEA,OAAOH,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("@testing-library/jest-dom");
4
+ // #sourceMappingURL=setupTests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["require"],"sources":["setupTests.ts"],"sourcesContent":["import '@testing-library/jest-dom';\n"],"mappings":";;AAAAA,OAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- export type { DataSourceKey, DataSourceTag, DataSource, AnyDataSource, DataSourceContext, DataSourceParams, DataSourceRequest, DataSourceResponse, DataSourceErrorResponse, DataSourceData, DataSourceError, DataSourceOptions, DataSourceState, DataSourceFetchContext, ActualParams, ActualData, ActualResponse, } from './types/DataSource';
1
+ export type { DataSourceKey, DataSourceTag, DataSource, AnyDataSource, DataSourceContext, DataSourceParams, DataSourceRequest, DataSourceResponse, DataSourceData, DataSourceError, DataSourceOptions, DataSourceState, DataSourceFetchContext, ActualParams, ActualData, } from './types/DataSource';
2
2
  export type { DataManager } from './types/DataManager';
3
3
  export type { DataLoaderStatus } from './types/DataLoaderStatus';
4
4
  export type { InvalidateRepeatOptions, InvalidateOptions } from './types/DataManagerOptions';
@@ -10,5 +10,6 @@ export { getStatus } from './utils/getStatus';
10
10
  export { hasTag } from './utils/hasTag';
11
11
  export { mergeStatuses } from './utils/mergeStatuses';
12
12
  export { skipContext } from './utils/skipContext';
13
+ export { withCatch } from './utils/withCatch';
13
14
  export type { Cancellable } from './utils/withCancellation';
14
15
  export { isCancellable, isAbortable, withCancellation } from './utils/withCancellation';
@@ -6,5 +6,6 @@ export { getStatus } from './utils/getStatus';
6
6
  export { hasTag } from './utils/hasTag';
7
7
  export { mergeStatuses } from './utils/mergeStatuses';
8
8
  export { skipContext } from './utils/skipContext';
9
+ export { withCatch } from './utils/withCatch';
9
10
  export { isCancellable, isAbortable, withCancellation } from './utils/withCancellation';
10
11
  // #sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["idle","composeKey","composeFullKey","getError","getStatus","hasTag","mergeStatuses","skipContext","isCancellable","isAbortable","withCancellation"],"sources":["index.ts"],"sourcesContent":["export type {\n DataSourceKey,\n DataSourceTag,\n DataSource,\n AnyDataSource,\n DataSourceContext,\n DataSourceParams,\n DataSourceRequest,\n DataSourceResponse,\n DataSourceErrorResponse,\n DataSourceData,\n DataSourceError,\n DataSourceOptions,\n DataSourceState,\n DataSourceFetchContext,\n ActualParams,\n ActualData,\n ActualResponse,\n} from './types/DataSource';\nexport type {DataManager} from './types/DataManager';\nexport type {DataLoaderStatus} from './types/DataLoaderStatus';\nexport type {InvalidateRepeatOptions, InvalidateOptions} from './types/DataManagerOptions';\n\nexport {idle} from './constants';\n\nexport {composeKey} from './utils/composeKey';\nexport {composeFullKey} from './utils/composeFullKey';\nexport {getError} from './utils/getError';\nexport {getStatus} from './utils/getStatus';\nexport {hasTag} from './utils/hasTag';\nexport {mergeStatuses} from './utils/mergeStatuses';\nexport {skipContext} from './utils/skipContext';\nexport type {Cancellable} from './utils/withCancellation';\nexport {isCancellable, isAbortable, withCancellation} from './utils/withCancellation';\n"],"mappings":"AAuBA,SAAQA,IAAI,QAAO,aAAa;AAEhC,SAAQC,UAAU,QAAO,oBAAoB;AAC7C,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SAAQC,QAAQ,QAAO,kBAAkB;AACzC,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,MAAM,QAAO,gBAAgB;AACrC,SAAQC,aAAa,QAAO,uBAAuB;AACnD,SAAQC,WAAW,QAAO,qBAAqB;AAE/C,SAAQC,aAAa,EAAEC,WAAW,EAAEC,gBAAgB,QAAO,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["idle","composeKey","composeFullKey","getError","getStatus","hasTag","mergeStatuses","skipContext","withCatch","isCancellable","isAbortable","withCancellation"],"sources":["index.ts"],"sourcesContent":["export type {\n DataSourceKey,\n DataSourceTag,\n DataSource,\n AnyDataSource,\n DataSourceContext,\n DataSourceParams,\n DataSourceRequest,\n DataSourceResponse,\n DataSourceData,\n DataSourceError,\n DataSourceOptions,\n DataSourceState,\n DataSourceFetchContext,\n ActualParams,\n ActualData,\n} from './types/DataSource';\nexport type {DataManager} from './types/DataManager';\nexport type {DataLoaderStatus} from './types/DataLoaderStatus';\nexport type {InvalidateRepeatOptions, InvalidateOptions} from './types/DataManagerOptions';\n\nexport {idle} from './constants';\n\nexport {composeKey} from './utils/composeKey';\nexport {composeFullKey} from './utils/composeFullKey';\nexport {getError} from './utils/getError';\nexport {getStatus} from './utils/getStatus';\nexport {hasTag} from './utils/hasTag';\nexport {mergeStatuses} from './utils/mergeStatuses';\nexport {skipContext} from './utils/skipContext';\nexport {withCatch} from './utils/withCatch';\nexport type {Cancellable} from './utils/withCancellation';\nexport {isCancellable, isAbortable, withCancellation} from './utils/withCancellation';\n"],"mappings":"AAqBA,SAAQA,IAAI,QAAO,aAAa;AAEhC,SAAQC,UAAU,QAAO,oBAAoB;AAC7C,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SAAQC,QAAQ,QAAO,kBAAkB;AACzC,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,MAAM,QAAO,gBAAgB;AACrC,SAAQC,aAAa,QAAO,uBAAuB;AACnD,SAAQC,WAAW,QAAO,qBAAqB;AAC/C,SAAQC,SAAS,QAAO,mBAAmB;AAE3C,SAAQC,aAAa,EAAEC,WAAW,EAAEC,gBAAgB,QAAO,0BAA0B","ignoreList":[]}
@@ -1,32 +1,28 @@
1
1
  import type { idle } from '../constants';
2
2
  export type DataSourceKey = ReadonlyArray<unknown>;
3
3
  export type DataSourceTag = string;
4
+ declare const errorHintSymbol: unique symbol;
4
5
  declare const stateHintSymbol: unique symbol;
5
- export interface DataSource<TContext, TParams, TRequest, TResponse, TData, TError, TErrorResponse, TOptions, TState, TFetchContext> {
6
+ export interface DataSource<TContext, TParams, TRequest, TResponse, TData, TError, TOptions, TState, TFetchContext> {
6
7
  readonly name: string;
7
8
  fetch: (context: TContext, fetchContext: TFetchContext, request: TRequest) => Promise<TResponse> | TResponse;
8
9
  tags?: (params: ActualParams<NoInfer<TParams>, NoInfer<TRequest>>) => DataSourceTag[];
9
10
  transformParams?: (params: TParams) => NoInfer<TRequest>;
10
- transformResponse?: (response: ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>) => TData;
11
- /**
12
- * When set, the `fetch` errors will be transformed into data without changing the state to error.
13
- */
14
- transformError?: (error: TError) => TErrorResponse;
11
+ transformResponse?: (response: TResponse) => TData;
15
12
  options?: Partial<TOptions>;
16
13
  [stateHintSymbol]?: TState;
14
+ [errorHintSymbol]?: TError;
17
15
  }
18
- export type AnyDataSource = DataSource<any, any, any, any, any, any, any, any, any, any>;
19
- export type DataSourceContext<TDataSource> = TDataSource extends DataSource<infer TContext, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? TContext : never;
20
- export type DataSourceParams<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer TParams, infer TRequest, infer _TResponse, infer _TData, infer _TError, infer _TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualParams<TParams, TRequest> : never;
21
- export type DataSourceRequest<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer TRequest, infer _TResponse, infer _TData, infer _TError, infer _TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? TRequest : never;
22
- export type DataSourceResponse<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer TResponse, infer _TData, infer _TError, infer TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualResponse<TResponse, TErrorResponse> : never;
23
- export type DataSourceData<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer TResponse, infer TData, infer _TError, infer TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualData<TResponse, TData, TErrorResponse> : never;
24
- export type DataSourceError<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer TError, infer _TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? TError : never;
25
- export type DataSourceErrorResponse<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer TErrorResponse, infer _TOptions, infer _TState, infer _TFetchContext> ? TErrorResponse : never;
26
- export type DataSourceOptions<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TErrorResponse, infer TOptions, infer _TState, infer _TFetchContext> ? TOptions : never;
27
- export type DataSourceState<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TErrorResponse, infer _TOptions, infer TState, infer _TFetchContext> ? TState : never;
28
- export type DataSourceFetchContext<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TErrorResponse, infer _TOptions, infer _TState, infer TFetchContext> ? TFetchContext : never;
16
+ export type AnyDataSource = DataSource<any, any, any, any, any, any, any, any, any>;
17
+ export type DataSourceContext<TDataSource> = TDataSource extends DataSource<infer TContext, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TContext : never;
18
+ export type DataSourceParams<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer TParams, infer TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualParams<TParams, TRequest> : never;
19
+ export type DataSourceRequest<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TRequest : never;
20
+ export type DataSourceResponse<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TResponse : never;
21
+ export type DataSourceData<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer TResponse, infer TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualData<TData, TResponse> : never;
22
+ export type DataSourceError<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TError : never;
23
+ export type DataSourceOptions<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer TOptions, infer _TState, infer _TFetchContext> ? TOptions : never;
24
+ export type DataSourceState<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer TState, infer _TFetchContext> ? TState : never;
25
+ export type DataSourceFetchContext<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer TFetchContext> ? TFetchContext : never;
29
26
  export type ActualParams<TParams, TRequest> = (unknown extends TParams ? TRequest : TParams) | typeof idle;
30
- export type ActualResponse<TResponse, TErrorResponse> = unknown extends TErrorResponse ? TResponse : TResponse | TErrorResponse;
31
- export type ActualData<TResponse, TData, TErrorResponse> = unknown extends TData ? ActualResponse<TResponse, TErrorResponse> : TData;
27
+ export type ActualData<TData, TResponse> = unknown extends TData ? TResponse : TData;
32
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DataSource.ts"],"sourcesContent":["import type {idle} from '../constants';\n\nexport type DataSourceKey = ReadonlyArray<unknown>;\nexport type DataSourceTag = string;\n\ndeclare const stateHintSymbol: unique symbol;\n\nexport interface DataSource<\n TContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TErrorResponse,\n TOptions,\n TState,\n TFetchContext,\n> {\n readonly name: string;\n\n fetch: (\n context: TContext,\n fetchContext: TFetchContext,\n request: TRequest,\n ) => Promise<TResponse> | TResponse;\n tags?: (params: ActualParams<NoInfer<TParams>, NoInfer<TRequest>>) => DataSourceTag[];\n\n transformParams?: (params: TParams) => NoInfer<TRequest>;\n transformResponse?: (\n response: ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n ) => TData;\n\n /**\n * When set, the `fetch` errors will be transformed into data without changing the state to error.\n */\n transformError?: (error: TError) => TErrorResponse;\n\n options?: Partial<TOptions>;\n [stateHintSymbol]?: TState;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyDataSource = DataSource<any, any, any, any, any, any, any, any, any, any>;\n\nexport type DataSourceContext<TDataSource> =\n TDataSource extends DataSource<\n infer TContext,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TContext\n : never;\n\nexport type DataSourceParams<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer TParams,\n infer TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualParams<TParams, TRequest>\n : never;\n\nexport type DataSourceRequest<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TRequest\n : never;\n\nexport type DataSourceResponse<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer TResponse,\n infer _TData,\n infer _TError,\n infer TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualResponse<TResponse, TErrorResponse>\n : never;\n\nexport type DataSourceData<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer TResponse,\n infer TData,\n infer _TError,\n infer TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualData<TResponse, TData, TErrorResponse>\n : never;\n\nexport type DataSourceError<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer TError,\n infer _TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TError\n : never;\n\nexport type DataSourceErrorResponse<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TErrorResponse\n : never;\n\nexport type DataSourceOptions<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TErrorResponse,\n infer TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TOptions\n : never;\n\nexport type DataSourceState<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TErrorResponse,\n infer _TOptions,\n infer TState,\n infer _TFetchContext\n >\n ? TState\n : never;\n\nexport type DataSourceFetchContext<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TErrorResponse,\n infer _TOptions,\n infer _TState,\n infer TFetchContext\n >\n ? TFetchContext\n : never;\n\nexport type ActualParams<TParams, TRequest> =\n | (unknown extends TParams ? TRequest : TParams)\n | typeof idle;\n\nexport type ActualResponse<TResponse, TErrorResponse> = unknown extends TErrorResponse\n ? TResponse\n : TResponse | TErrorResponse;\n\nexport type ActualData<TResponse, TData, TErrorResponse> = unknown extends TData\n ? ActualResponse<TResponse, TErrorResponse>\n : TData;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["DataSource.ts"],"sourcesContent":["import type {idle} from '../constants';\n\nexport type DataSourceKey = ReadonlyArray<unknown>;\nexport type DataSourceTag = string;\n\ndeclare const errorHintSymbol: unique symbol;\ndeclare const stateHintSymbol: unique symbol;\n\nexport interface DataSource<\n TContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TOptions,\n TState,\n TFetchContext,\n> {\n readonly name: string;\n\n fetch: (\n context: TContext,\n fetchContext: TFetchContext,\n request: TRequest,\n ) => Promise<TResponse> | TResponse;\n tags?: (params: ActualParams<NoInfer<TParams>, NoInfer<TRequest>>) => DataSourceTag[];\n\n transformParams?: (params: TParams) => NoInfer<TRequest>;\n transformResponse?: (response: TResponse) => TData;\n\n options?: Partial<TOptions>;\n [stateHintSymbol]?: TState;\n [errorHintSymbol]?: TError;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyDataSource = DataSource<any, any, any, any, any, any, any, any, any>;\n\nexport type DataSourceContext<TDataSource> =\n TDataSource extends DataSource<\n infer TContext,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TContext\n : never;\n\nexport type DataSourceParams<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer TParams,\n infer TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualParams<TParams, TRequest>\n : never;\n\nexport type DataSourceRequest<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TRequest\n : never;\n\nexport type DataSourceResponse<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TResponse\n : never;\n\nexport type DataSourceData<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer TResponse,\n infer TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualData<TData, TResponse>\n : never;\n\nexport type DataSourceError<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TError\n : never;\n\nexport type DataSourceOptions<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TOptions\n : never;\n\nexport type DataSourceState<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer TState,\n infer _TFetchContext\n >\n ? TState\n : never;\n\nexport type DataSourceFetchContext<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer TFetchContext\n >\n ? TFetchContext\n : never;\n\nexport type ActualParams<TParams, TRequest> =\n | (unknown extends TParams ? TRequest : TParams)\n | typeof idle;\n\nexport type ActualData<TData, TResponse> = unknown extends TData ? TResponse : TData;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ import { composeFullKey } from '../composeFullKey';
2
+ import { composeKey } from '../composeKey';
3
+ describe('composeFullKey', function () {
4
+ var dataSource = {
5
+ name: 'test',
6
+ fetch: jest.fn()
7
+ };
8
+ var dataSourceWithTags = {
9
+ name: 'test',
10
+ fetch: jest.fn(),
11
+ tags: function tags() {
12
+ return ['tag1', 'tag2'];
13
+ }
14
+ };
15
+ it('should compose full key without tags', function () {
16
+ var params = {
17
+ id: 1
18
+ };
19
+ var result = composeFullKey(dataSource, params);
20
+ var key = composeKey(dataSource, params);
21
+ expect(result).toEqual(['test', key]);
22
+ });
23
+ it('should compose full key with tags', function () {
24
+ var params = {
25
+ id: 1
26
+ };
27
+ var result = composeFullKey(dataSourceWithTags, params);
28
+ var key = composeKey(dataSourceWithTags, params);
29
+ expect(result).toEqual(['test', 'tag1', 'tag2', key]);
30
+ });
31
+ });
32
+ // #sourceMappingURL=composeFullKey.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["composeFullKey","composeKey","describe","dataSource","name","fetch","jest","fn","dataSourceWithTags","tags","it","params","id","result","key","expect","toEqual"],"sources":["composeFullKey.test.ts"],"sourcesContent":["import type {AnyDataSource} from '../../types/DataSource';\nimport {composeFullKey} from '../composeFullKey';\nimport {composeKey} from '../composeKey';\n\ndescribe('composeFullKey', () => {\n const dataSource: AnyDataSource = {\n name: 'test',\n fetch: jest.fn(),\n };\n\n const dataSourceWithTags: AnyDataSource = {\n name: 'test',\n fetch: jest.fn(),\n tags: () => ['tag1', 'tag2'],\n };\n\n it('should compose full key without tags', () => {\n const params = {id: 1};\n const result = composeFullKey(dataSource, params);\n const key = composeKey(dataSource, params);\n expect(result).toEqual(['test', key]);\n });\n\n it('should compose full key with tags', () => {\n const params = {id: 1};\n const result = composeFullKey(dataSourceWithTags, params);\n const key = composeKey(dataSourceWithTags, params);\n expect(result).toEqual(['test', 'tag1', 'tag2', key]);\n });\n});\n"],"mappings":"AACA,SAAQA,cAAc,QAAO,mBAAmB;AAChD,SAAQC,UAAU,QAAO,eAAe;AAExCC,QAAQ,CAAC,gBAAgB,EAAE,YAAM;EAC7B,IAAMC,UAAyB,GAAG;IAC9BC,IAAI,EAAE,MAAM;IACZC,KAAK,EAAEC,IAAI,CAACC,EAAE,CAAC;EACnB,CAAC;EAED,IAAMC,kBAAiC,GAAG;IACtCJ,IAAI,EAAE,MAAM;IACZC,KAAK,EAAEC,IAAI,CAACC,EAAE,CAAC,CAAC;IAChBE,IAAI,EAAE,SAANA,IAAIA,CAAA;MAAA,OAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAA;EAChC,CAAC;EAEDC,EAAE,CAAC,sCAAsC,EAAE,YAAM;IAC7C,IAAMC,MAAM,GAAG;MAACC,EAAE,EAAE;IAAC,CAAC;IACtB,IAAMC,MAAM,GAAGb,cAAc,CAACG,UAAU,EAAEQ,MAAM,CAAC;IACjD,IAAMG,GAAG,GAAGb,UAAU,CAACE,UAAU,EAAEQ,MAAM,CAAC;IAC1CI,MAAM,CAACF,MAAM,CAAC,CAACG,OAAO,CAAC,CAAC,MAAM,EAAEF,GAAG,CAAC,CAAC;EACzC,CAAC,CAAC;EAEFJ,EAAE,CAAC,mCAAmC,EAAE,YAAM;IAC1C,IAAMC,MAAM,GAAG;MAACC,EAAE,EAAE;IAAC,CAAC;IACtB,IAAMC,MAAM,GAAGb,cAAc,CAACQ,kBAAkB,EAAEG,MAAM,CAAC;IACzD,IAAMG,GAAG,GAAGb,UAAU,CAACO,kBAAkB,EAAEG,MAAM,CAAC;IAClDI,MAAM,CAACF,MAAM,CAAC,CAACG,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAEF,GAAG,CAAC,CAAC;EACzD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ import { idle } from '../../constants';
2
+ import { composeKey } from '../composeKey';
3
+ describe('composeKey', function () {
4
+ var dataSource = {
5
+ name: 'test',
6
+ fetch: jest.fn()
7
+ };
8
+ it('should compose key with idle params', function () {
9
+ var result = composeKey(dataSource, idle);
10
+ expect(result).toBe('test:idle');
11
+ });
12
+ it('should compose key with string param', function () {
13
+ var params = 'string';
14
+ var result = composeKey(dataSource, params);
15
+ expect(result).toBe('test("string")');
16
+ });
17
+ it('should compose key with object param', function () {
18
+ var params = {
19
+ id: 1
20
+ };
21
+ var result = composeKey(dataSource, params);
22
+ expect(result).toMatch(/^test\(.+\)$/);
23
+ });
24
+ it('should compose key with array param', function () {
25
+ var params = [1, 2, 3];
26
+ var result = composeKey(dataSource, params);
27
+ expect(result).toMatch(/^test\(.+\)$/);
28
+ });
29
+ });
30
+ // #sourceMappingURL=composeKey.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["idle","composeKey","describe","dataSource","name","fetch","jest","fn","it","result","expect","toBe","params","id","toMatch"],"sources":["composeKey.test.ts"],"sourcesContent":["import {idle} from '../../constants';\nimport type {AnyDataSource} from '../../types/DataSource';\nimport {composeKey} from '../composeKey';\n\ndescribe('composeKey', () => {\n const dataSource: AnyDataSource = {\n name: 'test',\n fetch: jest.fn(),\n };\n\n it('should compose key with idle params', () => {\n const result = composeKey(dataSource, idle);\n expect(result).toBe('test:idle');\n });\n\n it('should compose key with string param', () => {\n const params = 'string';\n const result = composeKey(dataSource, params);\n expect(result).toBe('test(\"string\")');\n });\n\n it('should compose key with object param', () => {\n const params = {id: 1};\n const result = composeKey(dataSource, params);\n expect(result).toMatch(/^test\\(.+\\)$/);\n });\n\n it('should compose key with array param', () => {\n const params = [1, 2, 3];\n const result = composeKey(dataSource, params);\n expect(result).toMatch(/^test\\(.+\\)$/);\n });\n});\n"],"mappings":"AAAA,SAAQA,IAAI,QAAO,iBAAiB;AAEpC,SAAQC,UAAU,QAAO,eAAe;AAExCC,QAAQ,CAAC,YAAY,EAAE,YAAM;EACzB,IAAMC,UAAyB,GAAG;IAC9BC,IAAI,EAAE,MAAM;IACZC,KAAK,EAAEC,IAAI,CAACC,EAAE,CAAC;EACnB,CAAC;EAEDC,EAAE,CAAC,qCAAqC,EAAE,YAAM;IAC5C,IAAMC,MAAM,GAAGR,UAAU,CAACE,UAAU,EAAEH,IAAI,CAAC;IAC3CU,MAAM,CAACD,MAAM,CAAC,CAACE,IAAI,CAAC,WAAW,CAAC;EACpC,CAAC,CAAC;EAEFH,EAAE,CAAC,sCAAsC,EAAE,YAAM;IAC7C,IAAMI,MAAM,GAAG,QAAQ;IACvB,IAAMH,MAAM,GAAGR,UAAU,CAACE,UAAU,EAAES,MAAM,CAAC;IAC7CF,MAAM,CAACD,MAAM,CAAC,CAACE,IAAI,CAAC,gBAAgB,CAAC;EACzC,CAAC,CAAC;EAEFH,EAAE,CAAC,sCAAsC,EAAE,YAAM;IAC7C,IAAMI,MAAM,GAAG;MAACC,EAAE,EAAE;IAAC,CAAC;IACtB,IAAMJ,MAAM,GAAGR,UAAU,CAACE,UAAU,EAAES,MAAM,CAAC;IAC7CF,MAAM,CAACD,MAAM,CAAC,CAACK,OAAO,CAAC,cAAc,CAAC;EAC1C,CAAC,CAAC;EAEFN,EAAE,CAAC,qCAAqC,EAAE,YAAM;IAC5C,IAAMI,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxB,IAAMH,MAAM,GAAGR,UAAU,CAACE,UAAU,EAAES,MAAM,CAAC;IAC7CF,MAAM,CAACD,MAAM,CAAC,CAACK,OAAO,CAAC,cAAc,CAAC;EAC1C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ import { getError } from '../getError';
2
+ describe('getError', function () {
3
+ it('should return null when no errors', function () {
4
+ var states = [{
5
+ error: null
6
+ }, {
7
+ error: null
8
+ }, {
9
+ error: null
10
+ }];
11
+ expect(getError(states)).toBeNull();
12
+ });
13
+ it('should return the first error found', function () {
14
+ var error1 = 'Error 1';
15
+ var error2 = 'Error 2';
16
+ var states = [{
17
+ error: null
18
+ }, {
19
+ error: error1
20
+ }, {
21
+ error: error2
22
+ }];
23
+ expect(getError(states)).toBe(error1);
24
+ });
25
+ it('should handle empty array', function () {
26
+ expect(getError([])).toBeNull();
27
+ });
28
+ });
29
+ // #sourceMappingURL=getError.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getError","describe","it","states","error","expect","toBeNull","error1","error2","toBe"],"sources":["getError.test.ts"],"sourcesContent":["import {getError} from '../getError';\n\ndescribe('getError', () => {\n it('should return null when no errors', () => {\n const states = [{error: null}, {error: null}, {error: null}];\n expect(getError(states)).toBeNull();\n });\n\n it('should return the first error found', () => {\n const error1 = 'Error 1';\n const error2 = 'Error 2';\n const states = [{error: null}, {error: error1}, {error: error2}];\n expect(getError(states)).toBe(error1);\n });\n\n it('should handle empty array', () => {\n expect(getError([])).toBeNull();\n });\n});\n"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,aAAa;AAEpCC,QAAQ,CAAC,UAAU,EAAE,YAAM;EACvBC,EAAE,CAAC,mCAAmC,EAAE,YAAM;IAC1C,IAAMC,MAAM,GAAG,CAAC;MAACC,KAAK,EAAE;IAAI,CAAC,EAAE;MAACA,KAAK,EAAE;IAAI,CAAC,EAAE;MAACA,KAAK,EAAE;IAAI,CAAC,CAAC;IAC5DC,MAAM,CAACL,QAAQ,CAACG,MAAM,CAAC,CAAC,CAACG,QAAQ,CAAC,CAAC;EACvC,CAAC,CAAC;EAEFJ,EAAE,CAAC,qCAAqC,EAAE,YAAM;IAC5C,IAAMK,MAAM,GAAG,SAAS;IACxB,IAAMC,MAAM,GAAG,SAAS;IACxB,IAAML,MAAM,GAAG,CAAC;MAACC,KAAK,EAAE;IAAI,CAAC,EAAE;MAACA,KAAK,EAAEG;IAAM,CAAC,EAAE;MAACH,KAAK,EAAEI;IAAM,CAAC,CAAC;IAChEH,MAAM,CAACL,QAAQ,CAACG,MAAM,CAAC,CAAC,CAACM,IAAI,CAACF,MAAM,CAAC;EACzC,CAAC,CAAC;EAEFL,EAAE,CAAC,2BAA2B,EAAE,YAAM;IAClCG,MAAM,CAACL,QAAQ,CAAC,EAAE,CAAC,CAAC,CAACM,QAAQ,CAAC,CAAC;EACnC,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}