@gravity-ui/data-source 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +752 -15
- package/build/cjs/core/index.d.ts +1 -0
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/types/DataManager.d.ts +5 -0
- package/build/cjs/core/types/DataManager.js.map +1 -1
- package/build/cjs/core/types/Normalizer.d.ts +29 -0
- package/build/cjs/core/types/Normalizer.js +6 -0
- package/build/cjs/core/types/Normalizer.js.map +1 -0
- package/build/cjs/react/DataManagerProvider.d.ts +7 -0
- package/build/cjs/react/DataManagerProvider.js +19 -0
- package/build/cjs/react/DataManagerProvider.js.map +1 -0
- package/build/cjs/react/__tests__/DataManagerContext.test.js +7 -6
- package/build/cjs/react/__tests__/DataManagerContext.test.js.map +1 -1
- package/build/cjs/react/__tests__/withDataManager.test.js +3 -0
- package/build/cjs/react/__tests__/withDataManager.test.js.map +1 -1
- package/build/cjs/react/index.d.ts +2 -0
- package/build/cjs/react/index.js +8 -0
- package/build/cjs/react/index.js.map +1 -1
- package/build/cjs/react-query/ClientDataManager.d.ts +11 -2
- package/build/cjs/react-query/ClientDataManager.js +76 -9
- package/build/cjs/react-query/ClientDataManager.js.map +1 -1
- package/build/cjs/react-query/DataSourceProvider.d.ts +7 -0
- package/build/cjs/react-query/DataSourceProvider.js +35 -0
- package/build/cjs/react-query/DataSourceProvider.js.map +1 -0
- package/build/cjs/react-query/__tests__/createQueryNormalizer.test.js +177 -0
- package/build/cjs/react-query/__tests__/createQueryNormalizer.test.js.map +1 -0
- package/build/cjs/react-query/__tests__/normalizationEdgeCases.test.js +100 -0
- package/build/cjs/react-query/__tests__/normalizationEdgeCases.test.js.map +1 -0
- package/build/cjs/react-query/__tests__/subscriptions.test.js +1180 -0
- package/build/cjs/react-query/__tests__/subscriptions.test.js.map +1 -0
- package/build/cjs/react-query/__tests__/threeLevelIntegration.test.js +514 -0
- package/build/cjs/react-query/__tests__/threeLevelIntegration.test.js.map +1 -0
- package/build/cjs/react-query/__tests__/updateQueriesFromMutationData.test.js +229 -0
- package/build/cjs/react-query/__tests__/updateQueriesFromMutationData.test.js.map +1 -0
- package/build/cjs/react-query/hooks/__tests__/useQueryData.refetch.test.js +195 -0
- package/build/cjs/react-query/hooks/__tests__/useQueryData.refetch.test.js.map +1 -0
- package/build/cjs/react-query/impl/infinite/hooks.js +4 -1
- package/build/cjs/react-query/impl/infinite/hooks.js.map +1 -1
- package/build/cjs/react-query/impl/infinite/types.d.ts +2 -2
- package/build/cjs/react-query/impl/infinite/types.js.map +1 -1
- package/build/cjs/react-query/impl/plain/hooks.js +4 -1
- package/build/cjs/react-query/impl/plain/hooks.js.map +1 -1
- package/build/cjs/react-query/impl/plain/types.d.ts +2 -2
- package/build/cjs/react-query/impl/plain/types.js.map +1 -1
- package/build/cjs/react-query/index.d.ts +2 -0
- package/build/cjs/react-query/index.js +7 -0
- package/build/cjs/react-query/index.js.map +1 -1
- package/build/cjs/react-query/types/normalizer.d.ts +21 -0
- package/build/cjs/react-query/types/normalizer.js +6 -0
- package/build/cjs/react-query/types/normalizer.js.map +1 -0
- package/build/cjs/react-query/types/options.d.ts +12 -0
- package/build/cjs/react-query/types/options.js.map +1 -1
- package/build/cjs/react-query/utils/normalize.d.ts +22 -0
- package/build/cjs/react-query/utils/normalize.js +150 -0
- package/build/cjs/react-query/utils/normalize.js.map +1 -0
- package/build/cjs/react-query/utils/warn.d.ts +1 -0
- package/build/cjs/react-query/utils/warn.js +15 -0
- package/build/cjs/react-query/utils/warn.js.map +1 -0
- package/build/cjs/react-query/utils/warnDisabledRefetch.d.ts +1 -0
- package/build/cjs/react-query/utils/warnDisabledRefetch.js +11 -0
- package/build/cjs/react-query/utils/warnDisabledRefetch.js.map +1 -0
- package/build/esm/core/index.d.ts +1 -0
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/types/DataManager.d.ts +5 -0
- package/build/esm/core/types/DataManager.js.map +1 -1
- package/build/esm/core/types/Normalizer.d.ts +29 -0
- package/build/esm/core/types/Normalizer.js +2 -0
- package/build/esm/core/types/Normalizer.js.map +1 -0
- package/build/esm/react/DataManagerProvider.d.ts +7 -0
- package/build/esm/react/DataManagerProvider.js +12 -0
- package/build/esm/react/DataManagerProvider.js.map +1 -0
- package/build/esm/react/__tests__/DataManagerContext.test.js +7 -6
- package/build/esm/react/__tests__/DataManagerContext.test.js.map +1 -1
- package/build/esm/react/__tests__/withDataManager.test.js +3 -0
- package/build/esm/react/__tests__/withDataManager.test.js.map +1 -1
- package/build/esm/react/index.d.ts +2 -0
- package/build/esm/react/index.js +1 -0
- package/build/esm/react/index.js.map +1 -1
- package/build/esm/react-query/ClientDataManager.d.ts +11 -2
- package/build/esm/react-query/ClientDataManager.js +70 -3
- package/build/esm/react-query/ClientDataManager.js.map +1 -1
- package/build/esm/react-query/DataSourceProvider.d.ts +7 -0
- package/build/esm/react-query/DataSourceProvider.js +28 -0
- package/build/esm/react-query/DataSourceProvider.js.map +1 -0
- package/build/esm/react-query/__tests__/createQueryNormalizer.test.js +174 -0
- package/build/esm/react-query/__tests__/createQueryNormalizer.test.js.map +1 -0
- package/build/esm/react-query/__tests__/normalizationEdgeCases.test.js +98 -0
- package/build/esm/react-query/__tests__/normalizationEdgeCases.test.js.map +1 -0
- package/build/esm/react-query/__tests__/subscriptions.test.js +1176 -0
- package/build/esm/react-query/__tests__/subscriptions.test.js.map +1 -0
- package/build/esm/react-query/__tests__/threeLevelIntegration.test.js +511 -0
- package/build/esm/react-query/__tests__/threeLevelIntegration.test.js.map +1 -0
- package/build/esm/react-query/__tests__/updateQueriesFromMutationData.test.js +227 -0
- package/build/esm/react-query/__tests__/updateQueriesFromMutationData.test.js.map +1 -0
- package/build/esm/react-query/hooks/__tests__/useQueryData.refetch.test.js +192 -0
- package/build/esm/react-query/hooks/__tests__/useQueryData.refetch.test.js.map +1 -0
- package/build/esm/react-query/impl/infinite/hooks.js +5 -2
- package/build/esm/react-query/impl/infinite/hooks.js.map +1 -1
- package/build/esm/react-query/impl/infinite/types.d.ts +2 -2
- package/build/esm/react-query/impl/infinite/types.js.map +1 -1
- package/build/esm/react-query/impl/plain/hooks.js +5 -2
- package/build/esm/react-query/impl/plain/hooks.js.map +1 -1
- package/build/esm/react-query/impl/plain/types.d.ts +2 -2
- package/build/esm/react-query/impl/plain/types.js.map +1 -1
- package/build/esm/react-query/index.d.ts +2 -0
- package/build/esm/react-query/index.js +1 -0
- package/build/esm/react-query/index.js.map +1 -1
- package/build/esm/react-query/types/normalizer.d.ts +21 -0
- package/build/esm/react-query/types/normalizer.js +2 -0
- package/build/esm/react-query/types/normalizer.js.map +1 -0
- package/build/esm/react-query/types/options.d.ts +12 -0
- package/build/esm/react-query/types/options.js.map +1 -1
- package/build/esm/react-query/utils/normalize.d.ts +22 -0
- package/build/esm/react-query/utils/normalize.js +143 -0
- package/build/esm/react-query/utils/normalize.js.map +1 -0
- package/build/esm/react-query/utils/warn.d.ts +1 -0
- package/build/esm/react-query/utils/warn.js +9 -0
- package/build/esm/react-query/utils/warn.js.map +1 -0
- package/build/esm/react-query/utils/warnDisabledRefetch.d.ts +1 -0
- package/build/esm/react-query/utils/warnDisabledRefetch.js +5 -0
- package/build/esm/react-query/utils/warnDisabledRefetch.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_react2","_ClientDataManager","_DataSourceProvider","_useQueryData","_factory","_jsxRuntime","e","__esModule","default","describe","queryClient","dataManager","beforeEach","ClientDataManager","normalizerConfig","devLogging","afterEach","_dataManager$queryNor","queryNormalizer","unsubscribe","clear","it","_asyncToGenerator","_regeneratorRuntime","mark","_callee2","customGetKey","customDataManager","queryKey","normalized","wrap","_callee2$","_context2","prev","next","jest","fn","obj","concat","id","getNormalizationObjectKey","subscribe","fetchQuery","queryFn","_queryFn","_callee","_callee$","_context","abrupt","name","stop","apply","arguments","normalize","getNormalizedData","expect","objects","toBeDefined","toHaveBeenCalled","_callee4","customGetArrayType","_callee4$","_context4","_ref3","arrayKey","getArrayType","_queryFn2","_callee3","_callee3$","_context3","items","_callee6","_callee6$","_context6","_queryFn3","_callee5","_callee5$","_context5","_callee8","_callee8$","_context8","_queryFn4","_callee7","_callee7$","_context7","toBeUndefined","_callee10","_callee10$","_context10","_queryFn5","_callee9","_callee9$","_context9","_callee12","wrapper","dataSource","_renderHook","result","_callee12$","_context12","_ref8","children","_jsx","DataSourceProvider","makePlainQueryDataSource","fetch","_fetch","_callee11","_callee11$","_context11","options","renderHook","useQueryData","waitFor","current","status","toBe","_callee15","dataSource1","dataSource2","_renderHook2","result1","_renderHook3","result2","_callee15$","_context15","_ref10","_fetch2","_callee13","_callee13$","_context13","_fetch3","_callee14","_callee14$","_context14","title","_callee16","dmWithOptimistic","initialData","data","_callee16$","_context16","optimistic","setQueryData","normalizer","setQuery","JSON","stringify","setNormalizedData","getQueryData","_callee17","dmWithOptimisticConfig","_callee17$","_context17","autoCalculateRollback","_callee18","dmWithInvalidate","_callee18$","_context18","invalidate","_callee19","dmWithBoth","_callee19$","_context19"],"sources":["threeLevelIntegration.test.tsx"],"sourcesContent":["import React from 'react';\n\nimport type {QueryClient} from '@tanstack/react-query';\nimport {renderHook, waitFor} from '@testing-library/react';\n\nimport {ClientDataManager} from '../ClientDataManager';\nimport {DataSourceProvider} from '../DataSourceProvider';\nimport {useQueryData} from '../hooks/useQueryData';\nimport {makePlainQueryDataSource} from '../impl/plain/factory';\n\ndescribe('Normalization Configuration Integration', () => {\n let queryClient: QueryClient;\n let dataManager: ClientDataManager;\n\n beforeEach(() => {\n dataManager = new ClientDataManager({\n normalizerConfig: {\n devLogging: false,\n },\n });\n queryClient = dataManager.queryClient;\n });\n\n afterEach(() => {\n dataManager.queryNormalizer?.unsubscribe();\n queryClient.clear();\n });\n\n describe('ClientDataManager configuration', () => {\n it('should use custom getNormalizationObjectKey from config', async () => {\n const customGetKey = jest.fn((obj) => `custom:${obj.id}`);\n\n const customDataManager = new ClientDataManager({\n normalizerConfig: {\n getNormalizationObjectKey: customGetKey,\n devLogging: false,\n },\n });\n\n customDataManager.queryNormalizer!.subscribe();\n\n const queryKey = ['users'];\n\n await customDataManager.queryClient.fetchQuery({\n queryKey,\n queryFn: async () => [{id: '1', name: 'User 1'}],\n normalize: true,\n } as Parameters<typeof customDataManager.queryClient.fetchQuery>[0] & {\n normalize: boolean;\n });\n\n const normalized = customDataManager.queryNormalizer!.getNormalizedData();\n\n expect(normalized.objects['@@custom:1']).toBeDefined();\n expect(customGetKey).toHaveBeenCalled();\n\n customDataManager.queryNormalizer!.unsubscribe();\n customDataManager.queryClient.clear();\n });\n\n it('should use custom getArrayType from config', async () => {\n const customGetArrayType = jest.fn(({arrayKey}) => `custom:${arrayKey}`);\n\n const customDataManager = new ClientDataManager({\n normalizerConfig: {\n getArrayType: customGetArrayType,\n devLogging: false,\n },\n });\n\n customDataManager.queryNormalizer!.subscribe();\n\n const queryKey = ['items'];\n\n await customDataManager.queryClient.fetchQuery({\n queryKey,\n queryFn: async () => ({\n items: [{id: '1', name: 'Item 1'}],\n }),\n normalize: true,\n } as Parameters<typeof customDataManager.queryClient.fetchQuery>[0] & {\n normalize: boolean;\n });\n\n expect(customGetArrayType).toHaveBeenCalled();\n\n customDataManager.queryNormalizer!.unsubscribe();\n customDataManager.queryClient.clear();\n });\n });\n\n describe('Query-level normalization control', () => {\n it('should normalize when query has normalize: true', async () => {\n dataManager.queryNormalizer!.subscribe();\n\n const queryKey = ['users-normalized'];\n\n await dataManager.queryClient.fetchQuery({\n queryKey,\n queryFn: async () => [{id: '1', name: 'User 1'}],\n normalize: true,\n } as Parameters<typeof dataManager.queryClient.fetchQuery>[0] & {normalize: boolean});\n\n const normalized = dataManager.queryNormalizer!.getNormalizedData();\n\n // Data SHOULD be normalized\n expect(normalized.objects['@@1']).toBeDefined();\n });\n\n it('should NOT normalize when query has normalize: false', async () => {\n dataManager.queryNormalizer!.subscribe();\n\n const queryKey = ['users-not-normalized'];\n\n await dataManager.queryClient.fetchQuery({\n queryKey,\n queryFn: async () => [{id: '2', name: 'User 2'}],\n normalize: false,\n } as Parameters<typeof dataManager.queryClient.fetchQuery>[0] & {normalize: boolean});\n\n const normalized = dataManager.queryNormalizer!.getNormalizedData();\n\n // Data should NOT be normalized\n expect(normalized.objects['@@2']).toBeUndefined();\n });\n\n it('should normalize by default when normalize option is not provided', async () => {\n dataManager.queryNormalizer!.subscribe();\n\n const queryKey = ['users-default'];\n\n await dataManager.queryClient.fetchQuery({\n queryKey,\n queryFn: async () => [{id: '3', name: 'User 3'}],\n });\n\n const normalized = dataManager.queryNormalizer!.getNormalizedData();\n\n // Data SHOULD be normalized (default behavior is now true)\n expect(normalized.objects['@@3']).toBeDefined();\n });\n });\n\n describe('DataSourceProvider integration', () => {\n it('should auto-subscribe queryNormalizer on mount', async () => {\n const wrapper = ({children}: {children: React.ReactNode}) => (\n <DataSourceProvider dataManager={dataManager}>{children}</DataSourceProvider>\n );\n\n const dataSource = makePlainQueryDataSource({\n name: 'users',\n fetch: async () => [{id: '1', name: 'User 1'}],\n options: {\n normalize: true,\n },\n });\n\n const {result} = renderHook(() => useQueryData(dataSource, {}), {wrapper});\n\n await waitFor(() => expect(result.current.status).toBe('success'));\n\n const normalized = dataManager.queryNormalizer!.getNormalizedData();\n\n // Data should be normalized because DataSourceProvider subscribes automatically\n expect(normalized.objects['@@1']).toBeDefined();\n });\n\n it('should work with multiple queries', async () => {\n const wrapper = ({children}: {children: React.ReactNode}) => (\n <DataSourceProvider dataManager={dataManager}>{children}</DataSourceProvider>\n );\n\n const dataSource1 = makePlainQueryDataSource({\n name: 'users',\n fetch: async () => [{id: '1', name: 'User 1'}],\n options: {\n normalize: true,\n },\n });\n\n const dataSource2 = makePlainQueryDataSource({\n name: 'posts',\n fetch: async () => [{id: '2', title: 'Post 1'}],\n options: {\n normalize: true,\n },\n });\n\n const {result: result1} = renderHook(() => useQueryData(dataSource1, {}), {wrapper});\n const {result: result2} = renderHook(() => useQueryData(dataSource2, {}), {wrapper});\n\n await waitFor(() => {\n expect(result1.current.status).toBe('success');\n expect(result2.current.status).toBe('success');\n });\n\n const normalized = dataManager.queryNormalizer!.getNormalizedData();\n\n expect(normalized.objects['@@1']).toBeDefined();\n expect(normalized.objects['@@2']).toBeDefined();\n });\n });\n\n describe('Optimistic updates configuration', () => {\n it('should enable optimistic updates when configured', async () => {\n const dmWithOptimistic = new ClientDataManager({\n normalizerConfig: {\n devLogging: false,\n optimistic: true,\n },\n });\n\n expect(dmWithOptimistic.queryNormalizer).toBeDefined();\n\n dmWithOptimistic.queryNormalizer!.subscribe();\n\n const queryKey = ['users'];\n const initialData = [{id: '1', name: 'Old'}];\n\n dmWithOptimistic.queryClient.setQueryData(queryKey, initialData);\n dmWithOptimistic.normalizer!.setQuery(JSON.stringify(queryKey), initialData);\n\n // Manual optimistic update via setNormalizedData\n dmWithOptimistic.queryNormalizer!.setNormalizedData({id: '1', name: 'New'});\n\n const data = dmWithOptimistic.queryClient.getQueryData(queryKey) as Array<{\n id: string;\n name: string;\n }>;\n expect(data[0].name).toBe('New');\n\n dmWithOptimistic.queryNormalizer!.unsubscribe();\n dmWithOptimistic.queryClient.clear();\n });\n\n it('should work with optimistic config object', async () => {\n const dmWithOptimisticConfig = new ClientDataManager({\n normalizerConfig: {\n devLogging: false,\n optimistic: {\n autoCalculateRollback: true,\n devLogging: false,\n },\n },\n });\n\n expect(dmWithOptimisticConfig.queryNormalizer).toBeDefined();\n expect(dmWithOptimisticConfig.normalizer).toBeDefined();\n\n dmWithOptimisticConfig.queryClient.clear();\n });\n });\n\n describe('Invalidate configuration', () => {\n it('should support invalidate option in global config', async () => {\n const dmWithInvalidate = new ClientDataManager({\n normalizerConfig: {\n devLogging: false,\n invalidate: true,\n },\n });\n\n expect(dmWithInvalidate.queryNormalizer).toBeDefined();\n expect(dmWithInvalidate.normalizer).toBeDefined();\n\n dmWithInvalidate.queryClient.clear();\n });\n\n it('should support both optimistic and invalidate options', async () => {\n const dmWithBoth = new ClientDataManager({\n normalizerConfig: {\n devLogging: false,\n optimistic: true,\n invalidate: true,\n },\n });\n\n expect(dmWithBoth.queryNormalizer).toBeDefined();\n expect(dmWithBoth.normalizer).toBeDefined();\n\n dmWithBoth.queryClient.clear();\n });\n });\n});\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAA+D,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/DG,QAAQ,CAAC,yCAAyC,EAAE,YAAM;EACtD,IAAIC,WAAwB;EAC5B,IAAIC,WAA8B;EAElCC,UAAU,CAAC,YAAM;IACbD,WAAW,GAAG,IAAIE,oCAAiB,CAAC;MAChCC,gBAAgB,EAAE;QACdC,UAAU,EAAE;MAChB;IACJ,CAAC,CAAC;IACFL,WAAW,GAAGC,WAAW,CAACD,WAAW;EACzC,CAAC,CAAC;EAEFM,SAAS,CAAC,YAAM;IAAA,IAAAC,qBAAA;IACZ,CAAAA,qBAAA,GAAAN,WAAW,CAACO,eAAe,cAAAD,qBAAA,eAA3BA,qBAAA,CAA6BE,WAAW,CAAC,CAAC;IAC1CT,WAAW,CAACU,KAAK,CAAC,CAAC;EACvB,CAAC,CAAC;EAEFX,QAAQ,CAAC,iCAAiC,EAAE,YAAM;IAC9CY,EAAE,CAAC,yDAAyD,mBAAAC,0BAAA,mBAAAC,4BAAA,IAAAC,IAAA,CAAE,SAAAC,SAAA;MAAA,IAAAC,YAAA,EAAAC,iBAAA,EAAAC,QAAA,EAAAC,UAAA;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WAAW,CAACU,KAAK,CAAC,CAAC;UAAC;UAAA;YAAA,OAAA0I,UAAA,CAAA5G,IAAA;QAAA;MAAA,GAAAyG,SAAA;IAAA,CACxC,GAAC;IAEFtI,EAAE,CAAC,uDAAuD,mBAAAC,0BAAA,mBAAAC,4BAAA,IAAAC,IAAA,CAAE,SAAAwI,UAAA;MAAA,IAAAC,UAAA;MAAA,WAAA1I,4BAAA,IAAAO,IAAA,UAAAoI,WAAAC,UAAA;QAAA,kBAAAA,UAAA,CAAAlI,IAAA,GAAAkI,UAAA,CAAAjI,IAAA;UAAA;YAClD+H,UAAU,GAAG,IAAIpJ,oCAAiB,CAAC;cACrCC,gBAAgB,EAAE;gBACdC,UAAU,EAAE,KAAK;gBACjB+H,UAAU,EAAE,IAAI;gBAChBiB,UAAU,EAAE;cAChB;YACJ,CAAC,CAAC;YAEFxG,MAAM,CAAC0G,UAAU,CAAC/I,eAAe,CAAC,CAACuC,WAAW,CAAC,CAAC;YAChDF,MAAM,CAAC0G,UAAU,CAACjB,UAAU,CAAC,CAACvF,WAAW,CAAC,CAAC;YAE3CwG,UAAU,CAACvJ,WAAW,CAACU,KAAK,CAAC,CAAC;UAAC;UAAA;YAAA,OAAA+I,UAAA,CAAAjH,IAAA;QAAA;MAAA,GAAA8G,SAAA;IAAA,CAClC,GAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _ClientDataManager = require("../ClientDataManager");
|
|
4
|
+
describe('updateQueriesFromMutationData', function () {
|
|
5
|
+
var dataManager;
|
|
6
|
+
beforeEach(function () {
|
|
7
|
+
dataManager = new _ClientDataManager.ClientDataManager({
|
|
8
|
+
defaultOptions: {
|
|
9
|
+
queries: {
|
|
10
|
+
retry: false
|
|
11
|
+
},
|
|
12
|
+
mutations: {
|
|
13
|
+
retry: false
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
normalizerConfig: {
|
|
17
|
+
devLogging: false
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
afterEach(function () {
|
|
22
|
+
dataManager.queryClient.clear();
|
|
23
|
+
});
|
|
24
|
+
it('should update query data based on normalized data', function () {
|
|
25
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
26
|
+
|
|
27
|
+
// Set initial data in query
|
|
28
|
+
var queryKey = ['users'];
|
|
29
|
+
dataManager.queryClient.setQueryData(queryKey, [{
|
|
30
|
+
id: '1',
|
|
31
|
+
name: 'Old Name'
|
|
32
|
+
}]);
|
|
33
|
+
|
|
34
|
+
// Add query to normalizer
|
|
35
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey), [{
|
|
36
|
+
id: '1',
|
|
37
|
+
name: 'Old Name'
|
|
38
|
+
}]);
|
|
39
|
+
|
|
40
|
+
// Update data via mutation
|
|
41
|
+
var mutationData = {
|
|
42
|
+
id: '1',
|
|
43
|
+
name: 'New Name'
|
|
44
|
+
};
|
|
45
|
+
dataManager.optimisticUpdate(mutationData);
|
|
46
|
+
|
|
47
|
+
// Verify that data was updated
|
|
48
|
+
var updatedData = dataManager.queryClient.getQueryData(queryKey);
|
|
49
|
+
expect(updatedData).toBeDefined();
|
|
50
|
+
expect(updatedData[0].name).toBe('New Name');
|
|
51
|
+
});
|
|
52
|
+
it('should update multiple queries with the same object', function () {
|
|
53
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
54
|
+
var queryKey1 = ['users'];
|
|
55
|
+
var queryKey2 = ['user', '1'];
|
|
56
|
+
|
|
57
|
+
// Set data in both queries
|
|
58
|
+
dataManager.queryClient.setQueryData(queryKey1, [{
|
|
59
|
+
id: '1',
|
|
60
|
+
name: 'User 1'
|
|
61
|
+
}]);
|
|
62
|
+
dataManager.queryClient.setQueryData(queryKey2, {
|
|
63
|
+
id: '1',
|
|
64
|
+
name: 'User 1'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Add to normalizer
|
|
68
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey1), [{
|
|
69
|
+
id: '1',
|
|
70
|
+
name: 'User 1'
|
|
71
|
+
}]);
|
|
72
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey2), {
|
|
73
|
+
id: '1',
|
|
74
|
+
name: 'User 1'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Update via mutation
|
|
78
|
+
var mutationData = {
|
|
79
|
+
id: '1',
|
|
80
|
+
name: 'Updated User'
|
|
81
|
+
};
|
|
82
|
+
dataManager.optimisticUpdate(mutationData);
|
|
83
|
+
|
|
84
|
+
// Check both queries
|
|
85
|
+
var data1 = dataManager.queryClient.getQueryData(queryKey1);
|
|
86
|
+
var data2 = dataManager.queryClient.getQueryData(queryKey2);
|
|
87
|
+
expect(data1[0].name).toBe('Updated User');
|
|
88
|
+
expect(data2.name).toBe('Updated User');
|
|
89
|
+
});
|
|
90
|
+
it('should preserve dataUpdatedAt on update', function () {
|
|
91
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
92
|
+
var queryKey = ['users'];
|
|
93
|
+
var originalUpdatedAt = Date.now();
|
|
94
|
+
|
|
95
|
+
// Set initial data
|
|
96
|
+
dataManager.queryClient.setQueryData(queryKey, [{
|
|
97
|
+
id: '1',
|
|
98
|
+
name: 'Old'
|
|
99
|
+
}], {
|
|
100
|
+
updatedAt: originalUpdatedAt
|
|
101
|
+
});
|
|
102
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey), [{
|
|
103
|
+
id: '1',
|
|
104
|
+
name: 'Old'
|
|
105
|
+
}]);
|
|
106
|
+
|
|
107
|
+
// Update data
|
|
108
|
+
var mutationData = {
|
|
109
|
+
id: '1',
|
|
110
|
+
name: 'New'
|
|
111
|
+
};
|
|
112
|
+
dataManager.optimisticUpdate(mutationData);
|
|
113
|
+
|
|
114
|
+
// Verify that dataUpdatedAt was preserved
|
|
115
|
+
var cachedQuery = dataManager.queryClient.getQueryCache().find({
|
|
116
|
+
queryKey: queryKey
|
|
117
|
+
});
|
|
118
|
+
expect(cachedQuery === null || cachedQuery === void 0 ? void 0 : cachedQuery.state.dataUpdatedAt).toBe(originalUpdatedAt);
|
|
119
|
+
});
|
|
120
|
+
it('should preserve error state on update', function () {
|
|
121
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
122
|
+
var queryKey = ['users'];
|
|
123
|
+
var error = new Error('Test error');
|
|
124
|
+
|
|
125
|
+
// Set initial data with error
|
|
126
|
+
dataManager.queryClient.setQueryData(queryKey, [{
|
|
127
|
+
id: '1',
|
|
128
|
+
name: 'Old'
|
|
129
|
+
}]);
|
|
130
|
+
var cachedQuery = dataManager.queryClient.getQueryCache().find({
|
|
131
|
+
queryKey: queryKey
|
|
132
|
+
});
|
|
133
|
+
cachedQuery === null || cachedQuery === void 0 || cachedQuery.setState({
|
|
134
|
+
error: error,
|
|
135
|
+
status: 'error'
|
|
136
|
+
});
|
|
137
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey), [{
|
|
138
|
+
id: '1',
|
|
139
|
+
name: 'Old'
|
|
140
|
+
}]);
|
|
141
|
+
|
|
142
|
+
// Update data
|
|
143
|
+
var mutationData = {
|
|
144
|
+
id: '1',
|
|
145
|
+
name: 'New'
|
|
146
|
+
};
|
|
147
|
+
dataManager.optimisticUpdate(mutationData);
|
|
148
|
+
|
|
149
|
+
// Verify that error and status were preserved
|
|
150
|
+
var updatedQuery = dataManager.queryClient.getQueryCache().find({
|
|
151
|
+
queryKey: queryKey
|
|
152
|
+
});
|
|
153
|
+
expect(updatedQuery === null || updatedQuery === void 0 ? void 0 : updatedQuery.state.error).toBe(error);
|
|
154
|
+
expect(updatedQuery === null || updatedQuery === void 0 ? void 0 : updatedQuery.state.status).toBe('error');
|
|
155
|
+
});
|
|
156
|
+
it('should preserve isInvalidated flag on update', function () {
|
|
157
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
158
|
+
var queryKey = ['users'];
|
|
159
|
+
|
|
160
|
+
// Set initial data and invalidate
|
|
161
|
+
dataManager.queryClient.setQueryData(queryKey, [{
|
|
162
|
+
id: '1',
|
|
163
|
+
name: 'Old'
|
|
164
|
+
}]);
|
|
165
|
+
dataManager.queryClient.invalidateQueries({
|
|
166
|
+
queryKey: queryKey
|
|
167
|
+
});
|
|
168
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey), [{
|
|
169
|
+
id: '1',
|
|
170
|
+
name: 'Old'
|
|
171
|
+
}]);
|
|
172
|
+
var cachedQueryBefore = dataManager.queryClient.getQueryCache().find({
|
|
173
|
+
queryKey: queryKey
|
|
174
|
+
});
|
|
175
|
+
var isInvalidatedBefore = cachedQueryBefore === null || cachedQueryBefore === void 0 ? void 0 : cachedQueryBefore.state.isInvalidated;
|
|
176
|
+
|
|
177
|
+
// Update data
|
|
178
|
+
var mutationData = {
|
|
179
|
+
id: '1',
|
|
180
|
+
name: 'New'
|
|
181
|
+
};
|
|
182
|
+
dataManager.optimisticUpdate(mutationData);
|
|
183
|
+
|
|
184
|
+
// Verify that isInvalidated was preserved
|
|
185
|
+
var cachedQueryAfter = dataManager.queryClient.getQueryCache().find({
|
|
186
|
+
queryKey: queryKey
|
|
187
|
+
});
|
|
188
|
+
expect(cachedQueryAfter === null || cachedQueryAfter === void 0 ? void 0 : cachedQueryAfter.state.isInvalidated).toBe(isInvalidatedBefore);
|
|
189
|
+
});
|
|
190
|
+
it('should work correctly with nested objects', function () {
|
|
191
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
192
|
+
var queryKey = ['posts'];
|
|
193
|
+
var initialData = [{
|
|
194
|
+
id: '1',
|
|
195
|
+
title: 'Post 1',
|
|
196
|
+
author: {
|
|
197
|
+
id: '10',
|
|
198
|
+
name: 'Author 1'
|
|
199
|
+
}
|
|
200
|
+
}];
|
|
201
|
+
dataManager.queryClient.setQueryData(queryKey, initialData);
|
|
202
|
+
dataManager.normalizer.setQuery(JSON.stringify(queryKey), initialData);
|
|
203
|
+
|
|
204
|
+
// Update author
|
|
205
|
+
var mutationData = {
|
|
206
|
+
id: '10',
|
|
207
|
+
name: 'Updated Author'
|
|
208
|
+
};
|
|
209
|
+
dataManager.optimisticUpdate(mutationData);
|
|
210
|
+
|
|
211
|
+
// Verify that author was updated
|
|
212
|
+
var data = dataManager.queryClient.getQueryData(queryKey);
|
|
213
|
+
expect(data[0].author.name).toBe('Updated Author');
|
|
214
|
+
});
|
|
215
|
+
it('should not throw if query is not in cache', function () {
|
|
216
|
+
expect(dataManager.normalizer).toBeDefined();
|
|
217
|
+
var mutationData = {
|
|
218
|
+
id: '1',
|
|
219
|
+
name: 'New'
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// Don't add query to cache, only to normalizer
|
|
223
|
+
// This should not throw an error
|
|
224
|
+
expect(function () {
|
|
225
|
+
dataManager.optimisticUpdate(mutationData);
|
|
226
|
+
}).not.toThrow();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
// #sourceMappingURL=updateQueriesFromMutationData.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ClientDataManager","require","describe","dataManager","beforeEach","ClientDataManager","defaultOptions","queries","retry","mutations","normalizerConfig","devLogging","afterEach","queryClient","clear","it","expect","normalizer","toBeDefined","queryKey","setQueryData","id","name","setQuery","JSON","stringify","mutationData","optimisticUpdate","updatedData","getQueryData","toBe","queryKey1","queryKey2","data1","data2","originalUpdatedAt","Date","now","updatedAt","cachedQuery","getQueryCache","find","state","dataUpdatedAt","error","Error","setState","status","updatedQuery","invalidateQueries","cachedQueryBefore","isInvalidatedBefore","isInvalidated","cachedQueryAfter","initialData","title","author","data","not","toThrow"],"sources":["updateQueriesFromMutationData.test.tsx"],"sourcesContent":["import type {Data} from '@normy/core';\n\nimport {ClientDataManager} from '../ClientDataManager';\n\ndescribe('updateQueriesFromMutationData', () => {\n let dataManager: ClientDataManager;\n\n beforeEach(() => {\n dataManager = new ClientDataManager({\n defaultOptions: {\n queries: {retry: false},\n mutations: {retry: false},\n },\n normalizerConfig: {\n devLogging: false,\n },\n });\n });\n\n afterEach(() => {\n dataManager.queryClient.clear();\n });\n\n it('should update query data based on normalized data', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n // Set initial data in query\n const queryKey = ['users'];\n dataManager.queryClient.setQueryData(queryKey, [{id: '1', name: 'Old Name'}]);\n\n // Add query to normalizer\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey), [{id: '1', name: 'Old Name'}]);\n\n // Update data via mutation\n const mutationData: Data = {id: '1', name: 'New Name'};\n\n dataManager.optimisticUpdate(mutationData);\n\n // Verify that data was updated\n const updatedData = dataManager.queryClient.getQueryData(queryKey) as Array<{\n id: string;\n name: string;\n }>;\n expect(updatedData).toBeDefined();\n expect(updatedData[0].name).toBe('New Name');\n });\n\n it('should update multiple queries with the same object', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n const queryKey1 = ['users'];\n const queryKey2 = ['user', '1'];\n\n // Set data in both queries\n dataManager.queryClient.setQueryData(queryKey1, [{id: '1', name: 'User 1'}]);\n dataManager.queryClient.setQueryData(queryKey2, {id: '1', name: 'User 1'});\n\n // Add to normalizer\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey1), [{id: '1', name: 'User 1'}]);\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey2), {id: '1', name: 'User 1'});\n\n // Update via mutation\n const mutationData: Data = {id: '1', name: 'Updated User'};\n dataManager.optimisticUpdate(mutationData);\n\n // Check both queries\n const data1 = dataManager.queryClient.getQueryData(queryKey1) as Array<{\n id: string;\n name: string;\n }>;\n const data2 = dataManager.queryClient.getQueryData(queryKey2) as {id: string; name: string};\n\n expect(data1[0].name).toBe('Updated User');\n expect(data2.name).toBe('Updated User');\n });\n\n it('should preserve dataUpdatedAt on update', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n const queryKey = ['users'];\n const originalUpdatedAt = Date.now();\n\n // Set initial data\n dataManager.queryClient.setQueryData(queryKey, [{id: '1', name: 'Old'}], {\n updatedAt: originalUpdatedAt,\n });\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey), [{id: '1', name: 'Old'}]);\n\n // Update data\n const mutationData: Data = {id: '1', name: 'New'};\n dataManager.optimisticUpdate(mutationData);\n\n // Verify that dataUpdatedAt was preserved\n const cachedQuery = dataManager.queryClient.getQueryCache().find({queryKey});\n expect(cachedQuery?.state.dataUpdatedAt).toBe(originalUpdatedAt);\n });\n\n it('should preserve error state on update', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n const queryKey = ['users'];\n const error = new Error('Test error');\n\n // Set initial data with error\n dataManager.queryClient.setQueryData(queryKey, [{id: '1', name: 'Old'}]);\n const cachedQuery = dataManager.queryClient.getQueryCache().find({queryKey});\n cachedQuery?.setState({error, status: 'error'});\n\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey), [{id: '1', name: 'Old'}]);\n\n // Update data\n const mutationData: Data = {id: '1', name: 'New'};\n dataManager.optimisticUpdate(mutationData);\n\n // Verify that error and status were preserved\n const updatedQuery = dataManager.queryClient.getQueryCache().find({queryKey});\n expect(updatedQuery?.state.error).toBe(error);\n expect(updatedQuery?.state.status).toBe('error');\n });\n\n it('should preserve isInvalidated flag on update', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n const queryKey = ['users'];\n\n // Set initial data and invalidate\n dataManager.queryClient.setQueryData(queryKey, [{id: '1', name: 'Old'}]);\n dataManager.queryClient.invalidateQueries({queryKey});\n\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey), [{id: '1', name: 'Old'}]);\n\n const cachedQueryBefore = dataManager.queryClient.getQueryCache().find({queryKey});\n const isInvalidatedBefore = cachedQueryBefore?.state.isInvalidated;\n\n // Update data\n const mutationData: Data = {id: '1', name: 'New'};\n dataManager.optimisticUpdate(mutationData);\n\n // Verify that isInvalidated was preserved\n const cachedQueryAfter = dataManager.queryClient.getQueryCache().find({queryKey});\n expect(cachedQueryAfter?.state.isInvalidated).toBe(isInvalidatedBefore);\n });\n\n it('should work correctly with nested objects', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n const queryKey = ['posts'];\n const initialData = [\n {\n id: '1',\n title: 'Post 1',\n author: {id: '10', name: 'Author 1'},\n },\n ];\n\n dataManager.queryClient.setQueryData(queryKey, initialData);\n dataManager.normalizer!.setQuery(JSON.stringify(queryKey), initialData);\n\n // Update author\n const mutationData: Data = {id: '10', name: 'Updated Author'};\n dataManager.optimisticUpdate(mutationData);\n\n // Verify that author was updated\n const data = dataManager.queryClient.getQueryData(queryKey) as Array<{\n id: string;\n title: string;\n author: {id: string; name: string};\n }>;\n expect(data[0].author.name).toBe('Updated Author');\n });\n\n it('should not throw if query is not in cache', () => {\n expect(dataManager.normalizer).toBeDefined();\n\n const mutationData: Data = {id: '1', name: 'New'};\n\n // Don't add query to cache, only to normalizer\n // This should not throw an error\n expect(() => {\n dataManager.optimisticUpdate(mutationData);\n }).not.toThrow();\n });\n});\n"],"mappings":";;AAEA,IAAAA,kBAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,+BAA+B,EAAE,YAAM;EAC5C,IAAIC,WAA8B;EAElCC,UAAU,CAAC,YAAM;IACbD,WAAW,GAAG,IAAIE,oCAAiB,CAAC;MAChCC,cAAc,EAAE;QACZC,OAAO,EAAE;UAACC,KAAK,EAAE;QAAK,CAAC;QACvBC,SAAS,EAAE;UAACD,KAAK,EAAE;QAAK;MAC5B,CAAC;MACDE,gBAAgB,EAAE;QACdC,UAAU,EAAE;MAChB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFC,SAAS,CAAC,YAAM;IACZT,WAAW,CAACU,WAAW,CAACC,KAAK,CAAC,CAAC;EACnC,CAAC,CAAC;EAEFC,EAAE,CAAC,mDAAmD,EAAE,YAAM;IAC1DC,MAAM,CAACb,WAAW,CAACc,UAAU,CAAC,CAACC,WAAW,CAAC,CAAC;;IAE5C;IACA,IAAMC,QAAQ,GAAG,CAAC,OAAO,CAAC;IAC1BhB,WAAW,CAACU,WAAW,CAACO,YAA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,IAAI,CAAC,CAAC,CAAC,CAACD,MAAM,CAAClC,IAAI,CAAC,CAACQ,IAAI,CAAC,gBAAgB,CAAC;EACtD,CAAC,CAAC;EAEFf,EAAE,CAAC,2CAA2C,EAAE,YAAM;IAClDC,MAAM,CAACb,WAAW,CAACc,UAAU,CAAC,CAACC,WAAW,CAAC,CAAC;IAE5C,IAAMQ,YAAkB,GAAG;MAACL,EAAE,EAAE,GAAG;MAAEC,IAAI,EAAE;IAAK,CAAC;;IAEjD;IACA;IACAN,MAAM,CAAC,YAAM;MACTb,WAAW,CAACwB,gBAAgB,CAACD,YAAY,CAAC;IAC9C,CAAC,CAAC,CAACgC,GAAG,CAACC,OAAO,CAAC,CAAC;EACpB,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
4
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
|
+
var _core = require("../../../core");
|
|
7
|
+
var _warnDisabledRefetch = require("../../utils/warnDisabledRefetch");
|
|
8
|
+
var _useQueryContext = require("../useQueryContext");
|
|
9
|
+
var _useQueryData = require("../useQueryData");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
jest.mock('@tanstack/react-query', function () {
|
|
12
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, jest.requireActual('@tanstack/react-query')), {}, {
|
|
13
|
+
useQuery: jest.fn(),
|
|
14
|
+
useInfiniteQuery: jest.fn()
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
jest.mock('../useQueryContext');
|
|
18
|
+
jest.mock('../../utils/warnDisabledRefetch');
|
|
19
|
+
var mockUseQuery = _reactQuery.useQuery;
|
|
20
|
+
var mockUseInfiniteQuery = _reactQuery.useInfiniteQuery;
|
|
21
|
+
var mockWarnDisabledRefetch = _warnDisabledRefetch.warnDisabledRefetch;
|
|
22
|
+
describe('useQueryData refetch behavior', function () {
|
|
23
|
+
var mockQueryClient = new _reactQuery.QueryClient();
|
|
24
|
+
var mockContext = {
|
|
25
|
+
queryClient: mockQueryClient
|
|
26
|
+
};
|
|
27
|
+
beforeEach(function () {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
_useQueryContext.useQueryContext.mockReturnValue(mockContext);
|
|
30
|
+
});
|
|
31
|
+
var createMockQueryResult = function createMockQueryResult() {
|
|
32
|
+
var refetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : jest.fn();
|
|
33
|
+
return {
|
|
34
|
+
data: 'test-data',
|
|
35
|
+
error: null,
|
|
36
|
+
status: 'success',
|
|
37
|
+
fetchStatus: 'idle',
|
|
38
|
+
isLoading: false,
|
|
39
|
+
isError: false,
|
|
40
|
+
isSuccess: true,
|
|
41
|
+
isPending: false,
|
|
42
|
+
refetch: refetch,
|
|
43
|
+
dataUpdatedAt: Date.now(),
|
|
44
|
+
errorUpdatedAt: 0,
|
|
45
|
+
failureCount: 0,
|
|
46
|
+
failureReason: null,
|
|
47
|
+
isFetched: true,
|
|
48
|
+
isFetchedAfterMount: true,
|
|
49
|
+
isFetching: false,
|
|
50
|
+
isInitialLoading: false,
|
|
51
|
+
isLoadingError: false,
|
|
52
|
+
isPaused: false,
|
|
53
|
+
isPlaceholderData: false,
|
|
54
|
+
isPreviousData: false,
|
|
55
|
+
isRefetchError: false,
|
|
56
|
+
isRefetching: false,
|
|
57
|
+
isStale: false,
|
|
58
|
+
promise: Promise.resolve('test-data')
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var createMockInfiniteResult = function createMockInfiniteResult() {
|
|
62
|
+
var refetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : jest.fn();
|
|
63
|
+
return {
|
|
64
|
+
data: {
|
|
65
|
+
pages: [['item1'], ['item2']],
|
|
66
|
+
pageParams: [undefined, 'next-page']
|
|
67
|
+
},
|
|
68
|
+
error: null,
|
|
69
|
+
status: 'success',
|
|
70
|
+
fetchStatus: 'idle',
|
|
71
|
+
isLoading: false,
|
|
72
|
+
isError: false,
|
|
73
|
+
isSuccess: true,
|
|
74
|
+
isPending: false,
|
|
75
|
+
refetch: refetch,
|
|
76
|
+
hasNextPage: false,
|
|
77
|
+
hasPreviousPage: false,
|
|
78
|
+
fetchNextPage: jest.fn(),
|
|
79
|
+
fetchPreviousPage: jest.fn(),
|
|
80
|
+
isFetchingNextPage: false,
|
|
81
|
+
isFetchingPreviousPage: false,
|
|
82
|
+
dataUpdatedAt: Date.now(),
|
|
83
|
+
errorUpdatedAt: 0,
|
|
84
|
+
failureCount: 0,
|
|
85
|
+
failureReason: null,
|
|
86
|
+
isFetched: true,
|
|
87
|
+
isFetchedAfterMount: true,
|
|
88
|
+
isFetching: false,
|
|
89
|
+
isInitialLoading: false,
|
|
90
|
+
isLoadingError: false,
|
|
91
|
+
isPaused: false,
|
|
92
|
+
isPlaceholderData: false,
|
|
93
|
+
isPreviousData: false,
|
|
94
|
+
isRefetchError: false,
|
|
95
|
+
isRefetching: false,
|
|
96
|
+
isStale: false,
|
|
97
|
+
promise: Promise.resolve({
|
|
98
|
+
pages: [['item1'], ['item2']],
|
|
99
|
+
pageParams: [undefined, 'next-page']
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
describe('plain data source', function () {
|
|
104
|
+
var plainDataSource = {
|
|
105
|
+
type: 'plain',
|
|
106
|
+
name: 'test-plain',
|
|
107
|
+
fetch: jest.fn().mockResolvedValue({
|
|
108
|
+
data: 'test-data'
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
it('should use original refetch when no enabled option', function () {
|
|
112
|
+
var originalRefetch = jest.fn();
|
|
113
|
+
mockUseQuery.mockReturnValue(createMockQueryResult(originalRefetch));
|
|
114
|
+
var _renderHook = (0, _react.renderHook)(function () {
|
|
115
|
+
return (0, _useQueryData.useQueryData)(plainDataSource, {
|
|
116
|
+
id: 1
|
|
117
|
+
});
|
|
118
|
+
}),
|
|
119
|
+
result = _renderHook.result;
|
|
120
|
+
expect(result.current.refetch).toBe(originalRefetch);
|
|
121
|
+
expect(result.current.refetch).not.toBe(mockWarnDisabledRefetch);
|
|
122
|
+
});
|
|
123
|
+
it('should use warnDisabledRefetch when enabled: false', function () {
|
|
124
|
+
var originalRefetch = jest.fn();
|
|
125
|
+
mockUseQuery.mockReturnValue(createMockQueryResult(originalRefetch));
|
|
126
|
+
var _renderHook2 = (0, _react.renderHook)(function () {
|
|
127
|
+
return (0, _useQueryData.useQueryData)(plainDataSource, {
|
|
128
|
+
id: 1
|
|
129
|
+
}, {
|
|
130
|
+
enabled: false
|
|
131
|
+
});
|
|
132
|
+
}),
|
|
133
|
+
result = _renderHook2.result;
|
|
134
|
+
expect(result.current.refetch).toBe(mockWarnDisabledRefetch);
|
|
135
|
+
expect(result.current.refetch).not.toBe(originalRefetch);
|
|
136
|
+
});
|
|
137
|
+
it('should use warnDisabledRefetch when params is idle', function () {
|
|
138
|
+
var originalRefetch = jest.fn();
|
|
139
|
+
mockUseQuery.mockReturnValue(createMockQueryResult(originalRefetch));
|
|
140
|
+
var _renderHook3 = (0, _react.renderHook)(function () {
|
|
141
|
+
return (0, _useQueryData.useQueryData)(plainDataSource, _core.idle);
|
|
142
|
+
}),
|
|
143
|
+
result = _renderHook3.result;
|
|
144
|
+
expect(result.current.refetch).toBe(mockWarnDisabledRefetch);
|
|
145
|
+
expect(result.current.refetch).not.toBe(originalRefetch);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe('infinite data source', function () {
|
|
149
|
+
var infiniteDataSource = {
|
|
150
|
+
type: 'infinite',
|
|
151
|
+
name: 'test-infinite',
|
|
152
|
+
fetch: jest.fn().mockResolvedValue({
|
|
153
|
+
data: ['item1', 'item2']
|
|
154
|
+
}),
|
|
155
|
+
next: jest.fn()
|
|
156
|
+
};
|
|
157
|
+
it('should use original refetch when no enabled option', function () {
|
|
158
|
+
var originalRefetch = jest.fn();
|
|
159
|
+
mockUseInfiniteQuery.mockReturnValue(createMockInfiniteResult(originalRefetch));
|
|
160
|
+
var _renderHook4 = (0, _react.renderHook)(function () {
|
|
161
|
+
return (0, _useQueryData.useQueryData)(infiniteDataSource, {
|
|
162
|
+
id: 1
|
|
163
|
+
});
|
|
164
|
+
}),
|
|
165
|
+
result = _renderHook4.result;
|
|
166
|
+
expect(result.current.refetch).toBe(originalRefetch);
|
|
167
|
+
expect(result.current.refetch).not.toBe(mockWarnDisabledRefetch);
|
|
168
|
+
});
|
|
169
|
+
it('should use warnDisabledRefetch when enabled: false', function () {
|
|
170
|
+
var originalRefetch = jest.fn();
|
|
171
|
+
mockUseInfiniteQuery.mockReturnValue(createMockInfiniteResult(originalRefetch));
|
|
172
|
+
var _renderHook5 = (0, _react.renderHook)(function () {
|
|
173
|
+
return (0, _useQueryData.useQueryData)(infiniteDataSource, {
|
|
174
|
+
id: 1
|
|
175
|
+
}, {
|
|
176
|
+
enabled: false
|
|
177
|
+
});
|
|
178
|
+
}),
|
|
179
|
+
result = _renderHook5.result;
|
|
180
|
+
expect(result.current.refetch).toBe(mockWarnDisabledRefetch);
|
|
181
|
+
expect(result.current.refetch).not.toBe(originalRefetch);
|
|
182
|
+
});
|
|
183
|
+
it('should use warnDisabledRefetch when params is idle', function () {
|
|
184
|
+
var originalRefetch = jest.fn();
|
|
185
|
+
mockUseInfiniteQuery.mockReturnValue(createMockInfiniteResult(originalRefetch));
|
|
186
|
+
var _renderHook6 = (0, _react.renderHook)(function () {
|
|
187
|
+
return (0, _useQueryData.useQueryData)(infiniteDataSource, _core.idle);
|
|
188
|
+
}),
|
|
189
|
+
result = _renderHook6.result;
|
|
190
|
+
expect(result.current.refetch).toBe(mockWarnDisabledRefetch);
|
|
191
|
+
expect(result.current.refetch).not.toBe(originalRefetch);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
// #sourceMappingURL=useQueryData.refetch.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactQuery","require","_react","_core","_warnDisabledRefetch","_useQueryContext","_useQueryData","_interopRequireDefault","e","__esModule","default","jest","mock","_objectSpread","requireActual","useQuery","fn","useInfiniteQuery","mockUseQuery","mockUseInfiniteQuery","mockWarnDisabledRefetch","warnDisabledRefetch","describe","mockQueryClient","QueryClient","mockContext","queryClient","beforeEach","clearAllMocks","useQueryContext","mockReturnValue","createMockQueryResult","refetch","arguments","length","undefined","data","error","status","fetchStatus","isLoading","isError","isSuccess","isPending","dataUpdatedAt","Date","now","errorUpdatedAt","failureCount","failureReason","isFetched","isFetchedAfterMount","isFetching","isInitialLoading","isLoadingError","isPaused","isPlaceholderData","isPreviousData","isRefetchError","isRefetching","isStale","promise","Promise","resolve","createMockInfiniteResult","pages","pageParams","hasNextPage","hasPreviousPage","fetchNextPage","fetchPreviousPage","isFetchingNextPage","isFetchingPreviousPage","plainDataSource","type","name","fetch","mockResolvedValue","it","originalRefetch","_renderHook","renderHook","useQueryData","id","result","expect","current","toBe","not","_renderHook2","enabled","_renderHook3","idle","infiniteDataSource","next","_renderHook4","_renderHook5","_renderHook6"],"sources":["useQueryData.refetch.test.ts"],"sourcesContent":["import {QueryClient, useInfiniteQuery, useQuery} from '@tanstack/react-query';\nimport {renderHook} from '@testing-library/react';\n\nimport {idle} from '../../../core';\nimport type {AnyInfiniteQueryDataSource} from '../../impl/infinite/types';\nimport type {AnyPlainQueryDataSource} from '../../impl/plain/types';\nimport {warnDisabledRefetch} from '../../utils/warnDisabledRefetch';\nimport {useQueryContext} from '../useQueryContext';\nimport {useQueryData} from '../useQueryData';\n\njest.mock('@tanstack/react-query', () => ({\n ...jest.requireActual('@tanstack/react-query'),\n useQuery: jest.fn(),\n useInfiniteQuery: jest.fn(),\n}));\n\njest.mock('../useQueryContext');\njest.mock('../../utils/warnDisabledRefetch');\n\nconst mockUseQuery = useQuery as jest.MockedFunction<typeof useQuery>;\nconst mockUseInfiniteQuery = useInfiniteQuery as jest.MockedFunction<typeof useInfiniteQuery>;\nconst mockWarnDisabledRefetch = warnDisabledRefetch as jest.MockedFunction<\n typeof warnDisabledRefetch\n>;\n\ndescribe('useQueryData refetch behavior', () => {\n const mockQueryClient = new QueryClient();\n const mockContext = {queryClient: mockQueryClient};\n\n beforeEach(() => {\n jest.clearAllMocks();\n (useQueryContext as jest.Mock).mockReturnValue(mockContext);\n });\n\n const createMockQueryResult = (refetch = jest.fn()) => ({\n data: 'test-data',\n error: null,\n status: 'success' as const,\n fetchStatus: 'idle' as const,\n isLoading: false,\n isError: false,\n isSuccess: true,\n isPending: false,\n refetch,\n dataUpdatedAt: Date.now(),\n errorUpdatedAt: 0,\n failureCount: 0,\n failureReason: null,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: false,\n isInitialLoading: false,\n isLoadingError: false,\n isPaused: false,\n isPlaceholderData: false,\n isPreviousData: false,\n isRefetchError: false,\n isRefetching: false,\n isStale: false,\n promise: Promise.resolve('test-data'),\n });\n\n const createMockInfiniteResult = (refetch = jest.fn()) => ({\n data: {pages: [['item1'], ['item2']], pageParams: [undefined, 'next-page']},\n error: null,\n status: 'success' as const,\n fetchStatus: 'idle' as const,\n isLoading: false,\n isError: false,\n isSuccess: true,\n isPending: false,\n refetch,\n hasNextPage: false,\n hasPreviousPage: false,\n fetchNextPage: jest.fn(),\n fetchPreviousPage: jest.fn(),\n isFetchingNextPage: false,\n isFetchingPreviousPage: false,\n dataUpdatedAt: Date.now(),\n errorUpdatedAt: 0,\n failureCount: 0,\n failureReason: null,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: false,\n isInitialLoading: false,\n isLoadingError: false,\n isPaused: false,\n isPlaceholderData: false,\n isPreviousData: false,\n isRefetchError: false,\n isRefetching: false,\n isStale: false,\n promise: Promise.resolve({\n pages: [['item1'], ['item2']],\n pageParams: [undefined, 'next-page'],\n }),\n });\n\n describe('plain data source', () => {\n const plainDataSource: AnyPlainQueryDataSource = {\n type: 'plain',\n name: 'test-plain',\n fetch: jest.fn().mockResolvedValue({data: 'test-data'}),\n };\n\n it('should use original refetch when no enabled option', () => {\n const originalRefetch = jest.fn();\n mockUseQuery.mockReturnValue(createMockQueryResult(originalRefetch) as any);\n\n const {result} = renderHook(() => useQueryData(plainDataSource, {id: 1}));\n\n expect(result.current.refetch).toBe(originalRefetch);\n expect(result.current.refetch).not.toBe(mockWarnDisabledRefetch);\n });\n\n it('should use warnDisabledRefetch when enabled: false', () => {\n const originalRefetch = jest.fn();\n mockUseQuery.mockReturnValue(createMockQueryResult(originalRefetch) as any);\n\n const {result} = renderHook(() =>\n useQueryData(plainDataSource, {id: 1}, {enabled: false}),\n );\n\n expect(result.current.refetch).toBe(mockWarnDisabledRefetch);\n expect(result.current.refetch).not.toBe(originalRefetch);\n });\n\n it('should use warnDisabledRefetch when params is idle', () => {\n const originalRefetch = jest.fn();\n mockUseQuery.mockReturnValue(createMockQueryResult(originalRefetch) as any);\n\n const {result} = renderHook(() => useQueryData(plainDataSource, idle));\n\n expect(result.current.refetch).toBe(mockWarnDisabledRefetch);\n expect(result.current.refetch).not.toBe(originalRefetch);\n });\n });\n\n describe('infinite data source', () => {\n const infiniteDataSource: AnyInfiniteQueryDataSource = {\n type: 'infinite',\n name: 'test-infinite',\n fetch: jest.fn().mockResolvedValue({data: ['item1', 'item2']}),\n next: jest.fn(),\n };\n\n it('should use original refetch when no enabled option', () => {\n const originalRefetch = jest.fn();\n mockUseInfiniteQuery.mockReturnValue(createMockInfiniteResult(originalRefetch) as any);\n\n const {result} = renderHook(() => useQueryData(infiniteDataSource, {id: 1}));\n\n expect(result.current.refetch).toBe(originalRefetch);\n expect(result.current.refetch).not.toBe(mockWarnDisabledRefetch);\n });\n\n it('should use warnDisabledRefetch when enabled: false', () => {\n const originalRefetch = jest.fn();\n mockUseInfiniteQuery.mockReturnValue(createMockInfiniteResult(originalRefetch) as any);\n\n const {result} = renderHook(() =>\n useQueryData(infiniteDataSource, {id: 1}, {enabled: false}),\n );\n\n expect(result.current.refetch).toBe(mockWarnDisabledRefetch);\n expect(result.current.refetch).not.toBe(originalRefetch);\n });\n\n it('should use warnDisabledRefetch when params is idle', () => {\n const originalRefetch = jest.fn();\n mockUseInfiniteQuery.mockReturnValue(createMockInfiniteResult(originalRefetch) as any);\n\n const {result} = renderHook(() => useQueryData(infiniteDataSource, idle));\n\n expect(result.current.refetch).toBe(mockWarnDisabledRefetch);\n expect(result.current.refetch).not.toBe(originalRefetch);\n });\n });\n});\n"],"mappings":";;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAGA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAA4C,SAAAM,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5CG,IAAI,CAACC,IAAI,CAAC,uBAAuB,EAAE;EAAA,WAAAC,sBAAA,MAAAA,sBAAA,MAC5BF,IAAI,CAACG,aAAa,CAAC,uBAAuB,CAAC;IAC9CC,QAAQ,EAAEJ,IAAI,CAACK,EAAE,CAAC,CAAC;IACnBC,gBAAgB,EAAEN,IAAI,CAACK,EAAE,CAAC;EAAC;AAAA,CAC7B,CAAC;AAEHL,IAAI,CAACC,IAAI,CAAC,oBAAoB,CAAC;AAC/BD,IAAI,CAACC,IAAI,CAAC,iCAAiC,CAAC;AAE5C,IAAMM,YAAY,GAAGH,oBAAgD;AACrE,IAAMI,oBAAoB,GAAGF,4BAAgE;AAC7F,IAAMG,uBAAuB,GAAGC,wCAE/B;AAEDC,QAAQ,CAAC,+BAA+B,EAAE,YAAM;EAC5C,IAAMC,eAAe,GAAG,IAAIC,uBAAW,CAAC,C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,UAAI,CAAC;QAAA,EAAC;QAAlER,MAAM,GAAAa,YAAA,CAANb,MAAM;MAEbC,MAAM,CAACD,MAAM,CAACE,OAAO,CAACtD,OAAO,CAAC,CAACuD,IAAI,CAACnE,uBAAuB,CAAC;MAC5DiE,MAAM,CAACD,MAAM,CAACE,OAAO,CAACtD,OAAO,CAAC,CAACwD,GAAG,CAACD,IAAI,CAACR,eAAe,CAAC;IAC5D,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ var _react = require("react");
|
|
|
10
10
|
var _reactQuery = require("@tanstack/react-query");
|
|
11
11
|
var _useRefetchInterval2 = require("../../hooks/useRefetchInterval");
|
|
12
12
|
var _normalizeStatus = require("../../utils/normalizeStatus");
|
|
13
|
+
var _warnDisabledRefetch = require("../../utils/warnDisabledRefetch");
|
|
13
14
|
var _utils = require("./utils");
|
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
var _excluded = ["queryFn", "refetchInterval"];
|
|
@@ -33,11 +34,13 @@ var useInfiniteQueryData = exports.useInfiniteQueryData = function useInfiniteQu
|
|
|
33
34
|
var _state$data$pages$fla, _state$data;
|
|
34
35
|
return (_state$data$pages$fla = (_state$data = state.data) === null || _state$data === void 0 ? void 0 : _state$data.pages.flat(1)) !== null && _state$data$pages$fla !== void 0 ? _state$data$pages$fla : [];
|
|
35
36
|
}, [state.data]);
|
|
37
|
+
var isDisabled = composedOptions.enabled === false || composedOptions.queryFn === _reactQuery.skipToken;
|
|
36
38
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
|
|
37
39
|
status: (0, _normalizeStatus.normalizeStatus)(state.status, state.fetchStatus),
|
|
38
40
|
data: transformedData,
|
|
39
41
|
originalStatus: state.status,
|
|
40
|
-
originalData: state.data
|
|
42
|
+
originalData: state.data,
|
|
43
|
+
refetch: isDisabled ? _warnDisabledRefetch.warnDisabledRefetch : state.refetch
|
|
41
44
|
});
|
|
42
45
|
};
|
|
43
46
|
// #sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactQuery","_useRefetchInterval2","_normalizeStatus","_utils","_interopRequireDefault","e","__esModule","default","useInfiniteQueryDataOptions","composedOptions","queryFnOption","queryFn","refetchIntervalOption","refetchInterval","restOptions","_objectWithoutProperties","_excluded","_useRefetchInterval","useRefetchInterval","_objectSpread","useInfiniteQueryData","exports","context","dataSource","params","options","extendedOptions","composeOptions","state","useInfiniteQuery","transformedData","useMemo","_state$data$pages$fla","_state$data","data","pages","flat","status","normalizeStatus","fetchStatus","originalStatus","originalData"],"sources":["hooks.ts"],"sourcesContent":["import {useMemo} from 'react';\n\nimport {useInfiniteQuery} from '@tanstack/react-query';\nimport type {InfiniteData, InfiniteQueryObserverOptions} from '@tanstack/react-query';\n\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceRequest,\n DataSourceResponse,\n DataSourceState,\n} from '../../../core';\nimport {useRefetchInterval} from '../../hooks/useRefetchInterval';\nimport {normalizeStatus} from '../../utils/normalizeStatus';\n\nimport type {AnyInfiniteQueryDataSource, InfiniteQueryObserverExtendedOptions} from './types';\nimport {composeOptions} from './utils';\n\nconst useInfiniteQueryDataOptions = <TDataSource extends AnyInfiniteQueryDataSource>(\n composedOptions: InfiniteQueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n InfiniteData<DataSourceData<TDataSource>, Partial<DataSourceRequest<TDataSource>>>,\n DataSourceResponse<TDataSource>,\n DataSourceKey,\n Partial<DataSourceRequest<TDataSource>>\n >,\n): InfiniteQueryObserverOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n InfiniteData<DataSourceData<TDataSource>, Partial<DataSourceRequest<TDataSource>>>,\n DataSourceResponse<TDataSource>,\n DataSourceKey,\n Partial<DataSourceRequest<TDataSource>>\n> => {\n const {\n queryFn: queryFnOption,\n refetchInterval: refetchIntervalOption,\n ...restOptions\n } = composedOptions;\n\n const {queryFn, refetchInterval} = useRefetchInterval(refetchIntervalOption, queryFnOption);\n\n return {...restOptions, queryFn, refetchInterval};\n};\n\nexport const useInfiniteQueryData = <TDataSource extends AnyInfiniteQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): DataSourceState<TDataSource> => {\n const extendedOptions = composeOptions(context, dataSource, params, options);\n const composedOptions = useInfiniteQueryDataOptions(extendedOptions);\n const state = useInfiniteQuery(composedOptions);\n\n const transformedData = useMemo<DataSourceState<TDataSource>['data']>(\n () => state.data?.pages.flat(1) ?? [],\n [state.data],\n );\n\n return {\n ...state,\n status: normalizeStatus(state.status, state.fetchStatus),\n data: transformedData,\n originalStatus: state.status,\n originalData: state.data,\n } as DataSourceState<TDataSource>;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAcA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;
|
|
1
|
+
{"version":3,"names":["_react","require","_reactQuery","_useRefetchInterval2","_normalizeStatus","_warnDisabledRefetch","_utils","_interopRequireDefault","e","__esModule","default","useInfiniteQueryDataOptions","composedOptions","queryFnOption","queryFn","refetchIntervalOption","refetchInterval","restOptions","_objectWithoutProperties","_excluded","_useRefetchInterval","useRefetchInterval","_objectSpread","useInfiniteQueryData","exports","context","dataSource","params","options","extendedOptions","composeOptions","state","useInfiniteQuery","transformedData","useMemo","_state$data$pages$fla","_state$data","data","pages","flat","isDisabled","enabled","skipToken","status","normalizeStatus","fetchStatus","originalStatus","originalData","refetch","warnDisabledRefetch"],"sources":["hooks.ts"],"sourcesContent":["import {useMemo} from 'react';\n\nimport {skipToken, useInfiniteQuery} from '@tanstack/react-query';\nimport type {InfiniteData, InfiniteQueryObserverOptions} from '@tanstack/react-query';\n\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceRequest,\n DataSourceResponse,\n DataSourceState,\n} from '../../../core';\nimport {useRefetchInterval} from '../../hooks/useRefetchInterval';\nimport {normalizeStatus} from '../../utils/normalizeStatus';\nimport {warnDisabledRefetch} from '../../utils/warnDisabledRefetch';\n\nimport type {AnyInfiniteQueryDataSource, InfiniteQueryObserverExtendedOptions} from './types';\nimport {composeOptions} from './utils';\n\nconst useInfiniteQueryDataOptions = <TDataSource extends AnyInfiniteQueryDataSource>(\n composedOptions: InfiniteQueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n InfiniteData<DataSourceData<TDataSource>, Partial<DataSourceRequest<TDataSource>>>,\n DataSourceResponse<TDataSource>,\n DataSourceKey,\n Partial<DataSourceRequest<TDataSource>>\n >,\n): InfiniteQueryObserverOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n InfiniteData<DataSourceData<TDataSource>, Partial<DataSourceRequest<TDataSource>>>,\n DataSourceResponse<TDataSource>,\n DataSourceKey,\n Partial<DataSourceRequest<TDataSource>>\n> => {\n const {\n queryFn: queryFnOption,\n refetchInterval: refetchIntervalOption,\n ...restOptions\n } = composedOptions;\n\n const {queryFn, refetchInterval} = useRefetchInterval(refetchIntervalOption, queryFnOption);\n\n return {...restOptions, queryFn, refetchInterval};\n};\n\nexport const useInfiniteQueryData = <TDataSource extends AnyInfiniteQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): DataSourceState<TDataSource> => {\n const extendedOptions = composeOptions(context, dataSource, params, options);\n const composedOptions = useInfiniteQueryDataOptions(extendedOptions);\n const state = useInfiniteQuery(composedOptions);\n\n const transformedData = useMemo<DataSourceState<TDataSource>['data']>(\n () => state.data?.pages.flat(1) ?? [],\n [state.data],\n );\n\n const isDisabled = composedOptions.enabled === false || composedOptions.queryFn === skipToken;\n\n return {\n ...state,\n status: normalizeStatus(state.status, state.fetchStatus),\n data: transformedData,\n originalStatus: state.status,\n originalData: state.data,\n refetch: isDisabled ? warnDisabledRefetch : state.refetch,\n } as DataSourceState<TDataSource>;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAcA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AAAsC,SAAAM,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;;AAEtC,IAAMG,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAC7BC,eAOC,EAQA;EACD,IACaC,aAAa,GAGtBD,eAAe,CAHfE,OAAO;IACUC,qBAAqB,GAEtCH,eAAe,CAFfI,eAAe;IACZC,WAAW,OAAAC,iCAAA,EACdN,eAAe,EAAAO,SAAA;EAEnB,IAAAC,mBAAA,GAAmC,IAAAC,uCAAkB,EAACN,qBAAqB,EAAEF,aAAa,CAAC;IAApFC,OAAO,GAAAM,mBAAA,CAAPN,OAAO;IAAEE,eAAe,GAAAI,mBAAA,CAAfJ,eAAe;EAE/B,WAAAM,sBAAA,MAAAA,sBAAA,MAAWL,WAAW;IAAEH,OAAO,EAAPA,OAAO;IAAEE,eAAe,EAAfA;EAAe;AACpD,CAAC;AAEM,IAAMO,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAC7BE,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAClB;EAC/B,IAAMC,eAAe,GAAG,IAAAC,qBAAc,EAACL,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,CAAC;EAC5E,IAAMhB,eAAe,GAAGD,2BAA2B,CAACkB,eAAe,CAAC;EACpE,IAAME,KAAK,GAAG,IAAAC,4BAAgB,EAACpB,eAAe,CAAC;EAE/C,IAAMqB,eAAe,GAAG,IAAAC,cAAO,EAC3B;IAAA,IAAAC,qBAAA,EAAAC,WAAA;IAAA,QAAAD,qBAAA,IAAAC,WAAA,GAAML,KAAK,CAACM,IAAI,cAAAD,WAAA,uBAAVA,WAAA,CAAYE,KAAK,CAACC,IAAI,CAAC,CAAC,CAAC,cAAAJ,qBAAA,cAAAA,qBAAA,GAAI,EAAE;EAAA,GACrC,CAACJ,KAAK,CAACM,IAAI,CACf,CAAC;EAED,IAAMG,UAAU,GAAG5B,eAAe,CAAC6B,OAAO,KAAK,KAAK,IAAI7B,eAAe,CAACE,OAAO,KAAK4B,qBAAS;EAE7F,WAAApB,sBAAA,MAAAA,sBAAA,MACOS,KAAK;IACRY,MAAM,EAAE,IAAAC,gCAAe,EAACb,KAAK,CAACY,MAAM,EAAEZ,KAAK,CAACc,WAAW,CAAC;IACxDR,IAAI,EAAEJ,eAAe;IACrBa,cAAc,EAAEf,KAAK,CAACY,MAAM;IAC5BI,YAAY,EAAEhB,KAAK,CAACM,IAAI;IACxBW,OAAO,EAAER,UAAU,GAAGS,wCAAmB,GAAGlB,KAAK,CAACiB;EAAO;AAEjE,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DefaultError, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, QueryFunctionContext, QueryKey } from '@tanstack/react-query';
|
|
2
|
-
import type { Overwrite } from 'utility-types';
|
|
2
|
+
import type { Assign, Overwrite } from 'utility-types';
|
|
3
3
|
import type { ActualData, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
|
|
4
4
|
import type { QueryDataSourceContext } from '../../types/base';
|
|
5
5
|
import type { QueryDataAdditionalOptions } from '../../types/options';
|
|
6
|
-
export type InfiniteQueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> =
|
|
6
|
+
export type InfiniteQueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Assign<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, QueryDataAdditionalOptions<TQueryFnData, TError, InfiniteData<TQueryData, TPageParam>, TQueryKey>>;
|
|
7
7
|
export type InfiniteQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, InfiniteQueryObserverExtendedOptions<NoInfer<TResponse>, NoInfer<TError>, InfiniteData<ActualData<NoInfer<TData>, NoInfer<TResponse>>, Partial<TRequest>>, NoInfer<TResponse>, DataSourceKey, Partial<NoInfer<TRequest>>>, ResultWrapper<InfiniteQueryObserverResult<InfiniteData<ActualData<NoInfer<TData>, NoInfer<TResponse>>, Partial<TRequest>>, NoInfer<TError>>, NoInfer<TRequest>, NoInfer<TResponse>, NoInfer<TData>, NoInfer<TError>>, QueryFunctionContext<DataSourceKey, Partial<NoInfer<TRequest>>>> & {
|
|
8
8
|
type: 'infinite';
|
|
9
9
|
next: (lastPage: NoInfer<TResponse>, allPages: NoInfer<TResponse>[]) => Partial<NoInfer<TRequest>> | null | undefined;
|