@gravity-ui/data-source 0.5.1 → 0.6.1

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 (68) hide show
  1. package/build/cjs/core/index.d.ts +2 -2
  2. package/build/cjs/core/index.js.map +1 -1
  3. package/build/cjs/core/types/{DataManger.js → DataManager.js} +1 -1
  4. package/build/cjs/core/types/DataManager.js.map +1 -0
  5. package/build/cjs/core/types/DataSource.d.ts +21 -17
  6. package/build/cjs/core/types/DataSource.js.map +1 -1
  7. package/build/cjs/core/utils/hasTag.js +1 -1
  8. package/build/cjs/core/utils/hasTag.js.map +1 -1
  9. package/build/cjs/core/utils/skipContext.d.ts +24 -0
  10. package/build/cjs/core/utils/skipContext.js +24 -0
  11. package/build/cjs/core/utils/skipContext.js.map +1 -1
  12. package/build/cjs/react/DataManagerContext.js +1 -1
  13. package/build/cjs/react/DataManagerContext.js.map +1 -1
  14. package/build/cjs/react-query/ClientDataManager.d.ts +1 -1
  15. package/build/cjs/react-query/ClientDataManager.js +6 -6
  16. package/build/cjs/react-query/ClientDataManager.js.map +1 -1
  17. package/build/cjs/react-query/impl/infinite/factory.d.ts +1 -1
  18. package/build/cjs/react-query/impl/infinite/factory.js.map +1 -1
  19. package/build/cjs/react-query/impl/infinite/types.d.ts +7 -7
  20. package/build/cjs/react-query/impl/infinite/types.js.map +1 -1
  21. package/build/cjs/react-query/impl/infinite/utils.js +44 -7
  22. package/build/cjs/react-query/impl/infinite/utils.js.map +1 -1
  23. package/build/cjs/react-query/impl/plain/factory.d.ts +1 -1
  24. package/build/cjs/react-query/impl/plain/factory.js.map +1 -1
  25. package/build/cjs/react-query/impl/plain/types.d.ts +4 -4
  26. package/build/cjs/react-query/impl/plain/types.js.map +1 -1
  27. package/build/cjs/react-query/impl/plain/utils.js +42 -4
  28. package/build/cjs/react-query/impl/plain/utils.js.map +1 -1
  29. package/build/cjs/react-query/impl/utils.d.ts +4 -0
  30. package/build/cjs/react-query/impl/utils.js +27 -0
  31. package/build/cjs/react-query/impl/utils.js.map +1 -0
  32. package/build/esm/core/index.d.ts +2 -2
  33. package/build/esm/core/index.js.map +1 -1
  34. package/build/esm/core/types/DataManager.js +2 -0
  35. package/build/esm/core/types/DataManager.js.map +1 -0
  36. package/build/esm/core/types/DataSource.d.ts +21 -17
  37. package/build/esm/core/types/DataSource.js.map +1 -1
  38. package/build/esm/core/utils/hasTag.js +1 -1
  39. package/build/esm/core/utils/hasTag.js.map +1 -1
  40. package/build/esm/core/utils/skipContext.d.ts +24 -0
  41. package/build/esm/core/utils/skipContext.js +24 -0
  42. package/build/esm/core/utils/skipContext.js.map +1 -1
  43. package/build/esm/react/DataManagerContext.js +1 -1
  44. package/build/esm/react/DataManagerContext.js.map +1 -1
  45. package/build/esm/react-query/ClientDataManager.d.ts +1 -1
  46. package/build/esm/react-query/ClientDataManager.js +6 -6
  47. package/build/esm/react-query/ClientDataManager.js.map +1 -1
  48. package/build/esm/react-query/impl/infinite/factory.d.ts +1 -1
  49. package/build/esm/react-query/impl/infinite/factory.js.map +1 -1
  50. package/build/esm/react-query/impl/infinite/types.d.ts +7 -7
  51. package/build/esm/react-query/impl/infinite/types.js.map +1 -1
  52. package/build/esm/react-query/impl/infinite/utils.js +44 -7
  53. package/build/esm/react-query/impl/infinite/utils.js.map +1 -1
  54. package/build/esm/react-query/impl/plain/factory.d.ts +1 -1
  55. package/build/esm/react-query/impl/plain/factory.js.map +1 -1
  56. package/build/esm/react-query/impl/plain/types.d.ts +4 -4
  57. package/build/esm/react-query/impl/plain/types.js.map +1 -1
  58. package/build/esm/react-query/impl/plain/utils.js +42 -4
  59. package/build/esm/react-query/impl/plain/utils.js.map +1 -1
  60. package/build/esm/react-query/impl/utils.d.ts +4 -0
  61. package/build/esm/react-query/impl/utils.js +21 -0
  62. package/build/esm/react-query/impl/utils.js.map +1 -0
  63. package/package.json +1 -1
  64. package/build/cjs/core/types/DataManger.js.map +0 -1
  65. package/build/esm/core/types/DataManger.js +0 -2
  66. package/build/esm/core/types/DataManger.js.map +0 -1
  67. /package/build/cjs/core/types/{DataManger.d.ts → DataManager.d.ts} +0 -0
  68. /package/build/esm/core/types/{DataManger.d.ts → DataManager.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
1
  import type { PlainQueryDataSource } from './types';
2
- export declare const makePlainQueryDataSource: <TParams, TRequest, TResponse, TData, TError>(config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>, "type">) => PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>;
2
+ export declare const makePlainQueryDataSource: <TParams, TRequest, TResponse, TData, TError, TErrorResponse>(config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse>, "type">) => PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse>;
@@ -1 +1 @@
1
- {"version":3,"names":["makePlainQueryDataSource","config","_objectSpread","type"],"sources":["factory.ts"],"sourcesContent":["import type {PlainQueryDataSource} from './types';\n\nexport const makePlainQueryDataSource = <TParams, TRequest, TResponse, TData, TError>(\n config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>, 'type'>,\n): PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> => ({\n ...config,\n type: 'plain',\n});\n"],"mappings":";AAEA,OAAO,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CACjCC,MAAuF;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAEpFD,MAAM;IACTE,IAAI,EAAE;EAAO;AAAA,CACf","ignoreList":[]}
1
+ {"version":3,"names":["makePlainQueryDataSource","config","_objectSpread","type"],"sources":["factory.ts"],"sourcesContent":["import type {PlainQueryDataSource} from './types';\n\nexport const makePlainQueryDataSource = <\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TErrorResponse,\n>(\n config: Omit<\n PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse>,\n 'type'\n >,\n): PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse> => ({\n ...config,\n type: 'plain',\n});\n"],"mappings":";AAEA,OAAO,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAQjCC,MAGC;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAEED,MAAM;IACTE,IAAI,EAAE;EAAO;AAAA,CACf","ignoreList":[]}
@@ -1,14 +1,14 @@
1
1
  import type { DefaultError, QueryFunctionContext, QueryKey, QueryObserverOptions, QueryObserverResult } from '@tanstack/react-query';
2
2
  import type { Overwrite } from 'utility-types';
3
- import type { ActualData, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
3
+ import type { ActualData, ActualResponse, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
4
4
  import type { QueryDataSourceContext } from '../../types/base';
5
5
  import type { QueryDataAdditionalOptions } from '../../types/options';
6
6
  export type QueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = Overwrite<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, QueryDataAdditionalOptions<TQueryFnData, TError, TQueryData, TQueryKey>>;
7
- export type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, QueryObserverExtendedOptions<TResponse, TError, ActualData<TData, TResponse>, TResponse, DataSourceKey>, ResultWrapper<QueryObserverResult<ActualData<TData, TResponse>, TError>, TResponse, TData, TError>, QueryFunctionContext<DataSourceKey>> & {
7
+ export type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, TErrorResponse, QueryObserverExtendedOptions<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, NoInfer<TError>, ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>, ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, DataSourceKey>, ResultWrapper<QueryObserverResult<ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>, NoInfer<TError>>, NoInfer<TResponse>, NoInfer<TData>, NoInfer<TError>, NoInfer<TErrorResponse>>, QueryFunctionContext<DataSourceKey>> & {
8
8
  type: 'plain';
9
9
  };
10
- export type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any>;
11
- type ResultWrapper<TResult, TResponse, TData, TError> = TResult extends QueryObserverResult<ActualData<TData, TResponse>, TError> ? Overwrite<TResult, {
10
+ export type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any, any>;
11
+ type ResultWrapper<TResult, TResponse, TData, TError, TErrorResponse> = TResult extends QueryObserverResult<ActualData<TResponse, TData, TErrorResponse>, TError> ? Overwrite<TResult, {
12
12
  status: DataLoaderStatus;
13
13
  }> & {
14
14
  originalStatus: TResult['status'];
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n DefaultError,\n QueryFunctionContext,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n} from '@tanstack/react-query';\nimport type {Overwrite} from 'utility-types';\n\nimport type {ActualData, DataLoaderStatus, DataSource, DataSourceKey} from '../../../core';\nimport type {QueryDataSourceContext} from '../../types/base';\nimport type {QueryDataAdditionalOptions} from '../../types/options';\n\nexport type QueryObserverExtendedOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = Overwrite<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>,\n QueryDataAdditionalOptions<TQueryFnData, TError, TQueryData, TQueryKey>\n>;\n\nexport type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n QueryObserverExtendedOptions<\n TResponse,\n TError,\n ActualData<TData, TResponse>,\n TResponse,\n DataSourceKey\n >,\n ResultWrapper<\n QueryObserverResult<ActualData<TData, TResponse>, TError>,\n TResponse,\n TData,\n TError\n >,\n QueryFunctionContext<DataSourceKey>\n> & {\n type: 'plain';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any>;\n\ntype ResultWrapper<TResult, TResponse, TData, TError> =\n TResult extends QueryObserverResult<ActualData<TData, TResponse>, TError>\n ? Overwrite<TResult, {status: DataLoaderStatus}> & {originalStatus: TResult['status']}\n : never;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n DefaultError,\n QueryFunctionContext,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n} from '@tanstack/react-query';\nimport type {Overwrite} from 'utility-types';\n\nimport type {\n ActualData,\n ActualResponse,\n DataLoaderStatus,\n DataSource,\n DataSourceKey,\n} from '../../../core';\nimport type {QueryDataSourceContext} from '../../types/base';\nimport type {QueryDataAdditionalOptions} from '../../types/options';\n\nexport type QueryObserverExtendedOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = Overwrite<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>,\n QueryDataAdditionalOptions<TQueryFnData, TError, TQueryData, TQueryKey>\n>;\n\nexport type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse> =\n DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TErrorResponse,\n QueryObserverExtendedOptions<\n ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n NoInfer<TError>,\n ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>,\n ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n DataSourceKey\n >,\n ResultWrapper<\n QueryObserverResult<\n ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>,\n NoInfer<TError>\n >,\n NoInfer<TResponse>,\n NoInfer<TData>,\n NoInfer<TError>,\n NoInfer<TErrorResponse>\n >,\n QueryFunctionContext<DataSourceKey>\n > & {\n type: 'plain';\n };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any, any>;\n\ntype ResultWrapper<TResult, TResponse, TData, TError, TErrorResponse> =\n TResult extends QueryObserverResult<ActualData<TResponse, TData, TErrorResponse>, TError>\n ? Overwrite<TResult, {status: DataLoaderStatus}> & {originalStatus: TResult['status']}\n : never;\n"],"mappings":"","ignoreList":[]}
@@ -1,15 +1,53 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
4
  import { skipToken } from '@tanstack/react-query';
3
5
  import { composeFullKey, idle } from '../../../core';
6
+ import { formatNullableValue, parseNullableValue } from '../utils';
4
7
  export var composeOptions = function composeOptions(context, dataSource, params, options) {
5
- var transformParams = dataSource.transformParams;
6
- var queryFn = function queryFn(fetchContext) {
7
- return dataSource.fetch(context, fetchContext, transformParams ? transformParams(params) : params);
8
+ var transformParams = dataSource.transformParams,
9
+ transformResponse = dataSource.transformResponse,
10
+ transformError = dataSource.transformError;
11
+ var queryFn = /*#__PURE__*/function () {
12
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fetchContext) {
13
+ var response;
14
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
15
+ while (1) switch (_context.prev = _context.next) {
16
+ case 0:
17
+ _context.prev = 0;
18
+ _context.next = 3;
19
+ return dataSource.fetch(context, fetchContext, transformParams ? transformParams(params) : params);
20
+ case 3:
21
+ response = _context.sent;
22
+ return _context.abrupt("return", formatNullableValue(response));
23
+ case 7:
24
+ _context.prev = 7;
25
+ _context.t0 = _context["catch"](0);
26
+ if (transformError) {
27
+ _context.next = 11;
28
+ break;
29
+ }
30
+ throw _context.t0;
31
+ case 11:
32
+ return _context.abrupt("return", formatNullableValue(transformError(_context.t0)));
33
+ case 12:
34
+ case "end":
35
+ return _context.stop();
36
+ }
37
+ }, _callee, null, [[0, 7]]);
38
+ }));
39
+ return function queryFn(_x) {
40
+ return _ref.apply(this, arguments);
41
+ };
42
+ }();
43
+ var select = function select(response) {
44
+ var actualResponse = parseNullableValue(response);
45
+ return transformResponse ? transformResponse(actualResponse) : actualResponse;
8
46
  };
9
47
  return _objectSpread(_objectSpread({
10
48
  queryKey: composeFullKey(dataSource, params),
11
49
  queryFn: params === idle ? skipToken : queryFn,
12
- select: dataSource.transformResponse
50
+ select: select
13
51
  }, dataSource.options), options);
14
52
  };
15
53
  // #sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["skipToken","composeFullKey","idle","composeOptions","context","dataSource","params","options","transformParams","queryFn","fetchContext","fetch","_objectSpread","queryKey","select","transformResponse"],"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';\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} = dataSource;\n\n const queryFn = (\n fetchContext: QueryFunctionContext<DataSourceKey>,\n ): DataSourceResponse<TDataSource> | Promise<DataSourceResponse<TDataSource>> => {\n return dataSource.fetch(\n context,\n fetchContext,\n transformParams ? transformParams(params) : params,\n );\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select: dataSource.transformResponse,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";AAAA,SAAmCA,SAAS,QAAO,uBAAuB;AAE1E,SAAQC,cAAc,EAAEC,IAAI,QAAO,eAAe;AAalD,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAOhD;EACD,IAAOC,eAAe,GAAIH,UAAU,CAA7BG,eAAe;EAEtB,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CACTC,YAAiD,EAC4B;IAC7E,OAAOL,UAAU,CAACM,KAAK,CACnBP,OAAO,EACPM,YAAY,EACZF,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAChD,CAAC;EACL,CAAC;EAED,OAAAM,aAAA,CAAAA,aAAA;IACIC,QAAQ,EAAEZ,cAAc,CAACI,UAAU,EAAEC,MAAM,CAAC;IAC5CG,OAAO,EAAEH,MAAM,KAAKJ,IAAI,GAAGF,SAAS,GAAGS,OAAO;IAC9CK,MAAM,EAAET,UAAU,CAACU;EAAiB,GACjCV,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["skipToken","composeFullKey","idle","formatNullableValue","parseNullableValue","composeOptions","context","dataSource","params","options","transformParams","transformResponse","transformError","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","response","wrap","_callee$","_context","prev","next","fetch","sent","abrupt","t0","stop","_x","apply","arguments","select","actualResponse","_objectSpread","queryKey"],"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,SAAmCA,SAAS,QAAO,uBAAuB;AAE1E,SAAQC,cAAc,EAAEC,IAAI,QAAO,eAAe;AAWlD,SAAQC,mBAAmB,EAAEC,kBAAkB,QAAO,UAAU;AAIhE,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,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,GAAAC,iBAAA,eAAAC,mBAAA,CAAAC,IAAA,CAAG,SAAAC,QACZC,YAAiD;MAAA,IAAAC,QAAA;MAAA,OAAAJ,mBAAA,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,WAMPzB,mBAAmB,CAACiB,QAAQ,CAAC;UAAA;YAAAG,QAAA,CAAAC,IAAA;YAAAD,QAAA,CAAAM,EAAA,GAAAN,QAAA;YAAA,IAE/BX,cAAc;cAAAW,QAAA,CAAAE,IAAA;cAAA;YAAA;YAAA,MAAAF,QAAA,CAAAM,EAAA;UAAA;YAAA,OAAAN,QAAA,CAAAK,MAAA,WAIZzB,mBAAmB,CAACS,cAAc,CAAAW,QAAA,CAAAM,EAAM,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAN,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAZ,OAAA;IAAA,CAExD;IAAA,gBAlBKL,OAAOA,CAAAkB,EAAA;MAAA,OAAAjB,IAAA,CAAAkB,KAAA,OAAAC,SAAA;IAAA;EAAA,GAkBZ;EAED,IAAMC,MAAM,GAAG,SAATA,MAAMA,CACRd,QAAsF,EACxD;IAC9B,IAAMe,cAAc,GAAG/B,kBAAkB,CAACgB,QAAQ,CAAC;IAEnD,OAAOT,iBAAiB,GAAGA,iBAAiB,CAACwB,cAAc,CAAC,GAAGA,cAAc;EACjF,CAAC;EAED,OAAAC,aAAA,CAAAA,aAAA;IACIC,QAAQ,EAAEpC,cAAc,CAACM,UAAU,EAAEC,MAAM,CAAC;IAC5CK,OAAO,EAAEL,MAAM,KAAKN,IAAI,GAAGF,SAAS,GAAGa,OAAO;IAC9CqB,MAAM,EAANA;EAAM,GACH3B,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const undefinedSymbol: unique symbol;
2
+ export declare const nullSymbol: unique symbol;
3
+ export declare const formatNullableValue: <T>(value: T | undefined | null) => T | typeof undefinedSymbol | typeof nullSymbol;
4
+ export declare const parseNullableValue: <T>(value: T | typeof undefinedSymbol | typeof nullSymbol) => T | undefined | null;
@@ -0,0 +1,21 @@
1
+ export var undefinedSymbol = Symbol('undefined');
2
+ export var nullSymbol = Symbol('null');
3
+ export var formatNullableValue = function formatNullableValue(value) {
4
+ if (value === undefined) {
5
+ return undefinedSymbol;
6
+ }
7
+ if (value === null) {
8
+ return nullSymbol;
9
+ }
10
+ return value;
11
+ };
12
+ export var parseNullableValue = function parseNullableValue(value) {
13
+ if (value === undefinedSymbol) {
14
+ return undefined;
15
+ }
16
+ if (value === nullSymbol) {
17
+ return null;
18
+ }
19
+ return value;
20
+ };
21
+ // #sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["undefinedSymbol","Symbol","nullSymbol","formatNullableValue","value","undefined","parseNullableValue"],"sources":["utils.ts"],"sourcesContent":["export const undefinedSymbol = Symbol('undefined');\nexport const nullSymbol = Symbol('null');\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\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,OAAO,IAAMA,eAAe,GAAGC,MAAM,CAAC,WAAW,CAAC;AAClD,OAAO,IAAMC,UAAU,GAAGD,MAAM,CAAC,MAAM,CAAC;AAExC,OAAO,IAAME,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAC5BC,KAA2B,EACsB;EACjD,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACrB,OAAOL,eAAe;EAC1B;EAEA,IAAII,KAAK,KAAK,IAAI,EAAE;IAChB,OAAOF,UAAU;EACrB;EAEA,OAAOE,KAAK;AAChB,CAAC;AAED,OAAO,IAAME,kBAAkB,GAAG,SAArBA,kBAAkBA,CAC3BF,KAAqD,EAC9B;EACvB,IAAIA,KAAK,KAAKJ,eAAe,EAAE;IAC3B,OAAOK,SAAS;EACpB;EAEA,IAAID,KAAK,KAAKF,UAAU,EAAE;IACtB,OAAO,IAAI;EACf;EAEA,OAAOE,KAAK;AAChB,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/data-source",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "A wrapper around data fetching",
5
5
  "keywords": [
6
6
  "data-fetching",
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["DataManger.ts"],"sourcesContent":["import type {InvalidateOptions} from './DataManagerOptions';\nimport type {AnyDataSource, DataSourceParams, DataSourceTag} from './DataSource';\n\nexport interface DataManager {\n invalidateTag(tag: DataSourceTag, invalidateOptions?: InvalidateOptions): Promise<void>;\n\n invalidateTags(tags: DataSourceTag[], invalidateOptions?: InvalidateOptions): Promise<void>;\n\n invalidateSource<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n invalidateOptions?: InvalidateOptions,\n ): Promise<void>;\n\n resetSource<TDataSource extends AnyDataSource>(dataSource: TDataSource): Promise<void>;\n\n invalidateParams<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n invalidateOptions?: InvalidateOptions,\n ): Promise<void>;\n\n resetParams<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n ): Promise<void>;\n\n invalidateSourceTags<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n invalidateOptions?: InvalidateOptions,\n ): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- // #sourceMappingURL=DataManger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["DataManger.ts"],"sourcesContent":["import type {InvalidateOptions} from './DataManagerOptions';\nimport type {AnyDataSource, DataSourceParams, DataSourceTag} from './DataSource';\n\nexport interface DataManager {\n invalidateTag(tag: DataSourceTag, invalidateOptions?: InvalidateOptions): Promise<void>;\n\n invalidateTags(tags: DataSourceTag[], invalidateOptions?: InvalidateOptions): Promise<void>;\n\n invalidateSource<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n invalidateOptions?: InvalidateOptions,\n ): Promise<void>;\n\n resetSource<TDataSource extends AnyDataSource>(dataSource: TDataSource): Promise<void>;\n\n invalidateParams<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n invalidateOptions?: InvalidateOptions,\n ): Promise<void>;\n\n resetParams<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n ): Promise<void>;\n\n invalidateSourceTags<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n invalidateOptions?: InvalidateOptions,\n ): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}