@tonightpass/react 0.0.169 → 0.0.171
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,6 @@ declare function useAPI<Path extends PathsFor<"GET">>(path: Path | null | undefi
|
|
|
18
18
|
interface UseAPIInfiniteConfig<Path extends PathsFor<"GET">> extends SWRInfiniteConfiguration<ResponseType<Path>, ErrorType<Path>> {
|
|
19
19
|
requestOptions?: APIRequestOptions;
|
|
20
20
|
}
|
|
21
|
-
declare function useAPIInfinite<Path extends PathsFor<"GET">>(getKey: (pageIndex: number, previousPageData: ResponseType<Path> | null) => [Path, Query<Path>] | null, config?: UseAPIInfiniteConfig<Path>): SWRInfiniteResponse<ResponseType<Path>, ErrorType<Path>>;
|
|
21
|
+
declare function useAPIInfinite<Path extends PathsFor<"GET">>(getKey: (pageIndex: number, previousPageData: ResponseType<Path> | null) => [Path, Query<Path> | undefined] | null, config?: UseAPIInfiniteConfig<Path>): SWRInfiniteResponse<ResponseType<Path>, ErrorType<Path>>;
|
|
22
22
|
|
|
23
23
|
export { type ErrorType, type ResponseType, type UseAPIConfig, type UseAPIInfiniteConfig, client, useAPI, useAPIInfinite };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ declare function useAPI<Path extends PathsFor<"GET">>(path: Path | null | undefi
|
|
|
18
18
|
interface UseAPIInfiniteConfig<Path extends PathsFor<"GET">> extends SWRInfiniteConfiguration<ResponseType<Path>, ErrorType<Path>> {
|
|
19
19
|
requestOptions?: APIRequestOptions;
|
|
20
20
|
}
|
|
21
|
-
declare function useAPIInfinite<Path extends PathsFor<"GET">>(getKey: (pageIndex: number, previousPageData: ResponseType<Path> | null) => [Path, Query<Path>] | null, config?: UseAPIInfiniteConfig<Path>): SWRInfiniteResponse<ResponseType<Path>, ErrorType<Path>>;
|
|
21
|
+
declare function useAPIInfinite<Path extends PathsFor<"GET">>(getKey: (pageIndex: number, previousPageData: ResponseType<Path> | null) => [Path, Query<Path> | undefined] | null, config?: UseAPIInfiniteConfig<Path>): SWRInfiniteResponse<ResponseType<Path>, ErrorType<Path>>;
|
|
22
22
|
|
|
23
23
|
export { type ErrorType, type ResponseType, type UseAPIConfig, type UseAPIInfiniteConfig, client, useAPI, useAPIInfinite };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var P=require('swr'),tonightpass=require('tonightpass'),f=require('swr/infinite');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var P__default=/*#__PURE__*/_interopDefault(P);var f__default=/*#__PURE__*/_interopDefault(f);var
|
|
1
|
+
'use strict';var P=require('swr'),tonightpass=require('tonightpass'),f=require('swr/infinite');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var P__default=/*#__PURE__*/_interopDefault(P);var f__default=/*#__PURE__*/_interopDefault(f);var r=new tonightpass.Client({baseURL:tonightpass.DEFAULT_API_URL});function m(e,t,n){let{requestOptions:s,...p}=n||{};return P__default.default(e?[e,t]:null,async([o,i])=>await r.get(o,i,s),p)}function w(e,t){let{requestOptions:n,...s}=t||{};return f__default.default(e,async([a,o])=>await r.get(a,o,n),s)}exports.client=r;exports.useAPI=m;exports.useAPIInfinite=w;//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useAPI.ts","../src/hooks/useAPIInfinite.ts"],"names":["client","Client","DEFAULT_API_URL","useAPI","path","query","config","requestOptions","swrConfig","useSWR","fetchPath","fetchQuery","useAPIInfinite","getKey","useSWRInfinite"],"mappings":"8PAWO,IAAMA,EAAS,IAAIC,kBAAAA,CAAO,CAAE,OAASC,CAAAA,2BAAgB,CAAC,EAmBtD,SAASC,EACdC,CACAC,CAAAA,CAAAA,CACAC,EACkD,CAClD,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,CAUpD,OAAOG,kBAILL,CAAAA,CAAAA,CAAO,CAACA,CAAMC,CAAAA,CAAK,EAAI,IAZT,CAAA,MAAO,CAACK,CAAWC,CAAAA,CAAU,CAI1B,GAAA,MAAMX,EAAO,GAAIU,CAAAA,CAAAA,CAAWC,EAAYJ,CAAc,CAAA,CAQjCC,CAAS,CACnD,CCrCO,SAASI,CACdC,CAAAA,CAAAA,CAIAP,EAC0D,CAC1D,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useAPI.ts","../src/hooks/useAPIInfinite.ts"],"names":["client","Client","DEFAULT_API_URL","useAPI","path","query","config","requestOptions","swrConfig","useSWR","fetchPath","fetchQuery","useAPIInfinite","getKey","useSWRInfinite"],"mappings":"8PAWO,IAAMA,EAAS,IAAIC,kBAAAA,CAAO,CAAE,OAASC,CAAAA,2BAAgB,CAAC,EAmBtD,SAASC,EACdC,CACAC,CAAAA,CAAAA,CACAC,EACkD,CAClD,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,CAUpD,OAAOG,kBAILL,CAAAA,CAAAA,CAAO,CAACA,CAAMC,CAAAA,CAAK,EAAI,IAZT,CAAA,MAAO,CAACK,CAAWC,CAAAA,CAAU,CAI1B,GAAA,MAAMX,EAAO,GAAIU,CAAAA,CAAAA,CAAWC,EAAYJ,CAAc,CAAA,CAQjCC,CAAS,CACnD,CCrCO,SAASI,CACdC,CAAAA,CAAAA,CAIAP,EAC0D,CAC1D,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,CAUpD,OAAOQ,kBAAeD,CAAAA,CAAAA,CARN,MAAO,CAACH,CAAAA,CAAWC,CAAU,CAI1B,GAAA,MAAMX,EAAO,GAAIU,CAAAA,CAAAA,CAAWC,EAAYJ,CAAc,CAAA,CAIlCC,CAAS,CAClD","file":"index.js","sourcesContent":["import useSWR, { SWRConfiguration, SWRResponse } from \"swr\";\nimport {\n Endpoints,\n APIRequestOptions,\n Client,\n PathsFor,\n DEFAULT_API_URL,\n TonightPassAPIError,\n Query,\n} from \"tonightpass\";\n\nexport const client = new Client({ baseURL: DEFAULT_API_URL });\n\ntype AnyEndpoint = Endpoints extends infer T ? T : never;\n\ntype ForceAccept<T> = T extends never ? any : T;\n\nexport type ResponseType<Path extends PathsFor<\"GET\">> = ForceAccept<\n Extract<AnyEndpoint, { path: Path; method: \"GET\" }>[\"res\"]\n>;\n\nexport type ErrorType<Path extends PathsFor<\"GET\">> = TonightPassAPIError<\n ResponseType<Path>\n>;\n\nexport interface UseAPIConfig<Path extends PathsFor<\"GET\">>\n extends SWRConfiguration<ResponseType<Path>, ErrorType<Path>> {\n requestOptions?: APIRequestOptions;\n}\n\nexport function useAPI<Path extends PathsFor<\"GET\">>(\n path: Path | null | undefined,\n query?: Query<Path>,\n config?: UseAPIConfig<Path>,\n): SWRResponse<ResponseType<Path>, ErrorType<Path>> {\n const { requestOptions, ...swrConfig } = config || {};\n\n const fetcher = async ([fetchPath, fetchQuery]: [\n Path,\n Query<Path> | undefined,\n ]) => {\n const response = await client.get(fetchPath, fetchQuery, requestOptions);\n return response as unknown as ResponseType<Path>;\n };\n\n return useSWR<\n ResponseType<Path>,\n ErrorType<Path>,\n [Path, Query<Path> | undefined] | null\n >(path ? [path, query] : null, fetcher, swrConfig);\n}\n","import useSWRInfinite, {\n SWRInfiniteConfiguration,\n SWRInfiniteResponse,\n} from \"swr/infinite\";\nimport { APIRequestOptions, PathsFor, Query } from \"tonightpass\";\n\nimport { client, ResponseType, ErrorType } from \"./useAPI\";\n\nexport interface UseAPIInfiniteConfig<Path extends PathsFor<\"GET\">>\n extends SWRInfiniteConfiguration<ResponseType<Path>, ErrorType<Path>> {\n requestOptions?: APIRequestOptions;\n}\n\nexport function useAPIInfinite<Path extends PathsFor<\"GET\">>(\n getKey: (\n pageIndex: number,\n previousPageData: ResponseType<Path> | null,\n ) => [Path, Query<Path> | undefined] | null,\n config?: UseAPIInfiniteConfig<Path>,\n): SWRInfiniteResponse<ResponseType<Path>, ErrorType<Path>> {\n const { requestOptions, ...swrConfig } = config || {};\n\n const fetcher = async ([fetchPath, fetchQuery]: [\n Path,\n Query<Path> | undefined,\n ]) => {\n const response = await client.get(fetchPath, fetchQuery, requestOptions);\n return response as unknown as ResponseType<Path>;\n };\n\n return useSWRInfinite(getKey, fetcher, swrConfig);\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import P from'swr';import {Client,DEFAULT_API_URL}from'tonightpass';import f from'swr/infinite';var
|
|
1
|
+
import P from'swr';import {Client,DEFAULT_API_URL}from'tonightpass';import f from'swr/infinite';var r=new Client({baseURL:DEFAULT_API_URL});function m(e,t,n){let{requestOptions:s,...p}=n||{};return P(e?[e,t]:null,async([o,i])=>await r.get(o,i,s),p)}function w(e,t){let{requestOptions:n,...s}=t||{};return f(e,async([a,o])=>await r.get(a,o,n),s)}export{r as client,m as useAPI,w as useAPIInfinite};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useAPI.ts","../src/hooks/useAPIInfinite.ts"],"names":["client","Client","DEFAULT_API_URL","useAPI","path","query","config","requestOptions","swrConfig","useSWR","fetchPath","fetchQuery","useAPIInfinite","getKey","useSWRInfinite"],"mappings":"gGAWO,IAAMA,EAAS,IAAIC,MAAAA,CAAO,CAAE,OAASC,CAAAA,eAAgB,CAAC,EAmBtD,SAASC,EACdC,CACAC,CAAAA,CAAAA,CACAC,EACkD,CAClD,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,CAUpD,OAAOG,CAILL,CAAAA,CAAAA,CAAO,CAACA,CAAMC,CAAAA,CAAK,EAAI,IAZT,CAAA,MAAO,CAACK,CAAWC,CAAAA,CAAU,CAI1B,GAAA,MAAMX,EAAO,GAAIU,CAAAA,CAAAA,CAAWC,EAAYJ,CAAc,CAAA,CAQjCC,CAAS,CACnD,CCrCO,SAASI,CACdC,CAAAA,CAAAA,CAIAP,EAC0D,CAC1D,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useAPI.ts","../src/hooks/useAPIInfinite.ts"],"names":["client","Client","DEFAULT_API_URL","useAPI","path","query","config","requestOptions","swrConfig","useSWR","fetchPath","fetchQuery","useAPIInfinite","getKey","useSWRInfinite"],"mappings":"gGAWO,IAAMA,EAAS,IAAIC,MAAAA,CAAO,CAAE,OAASC,CAAAA,eAAgB,CAAC,EAmBtD,SAASC,EACdC,CACAC,CAAAA,CAAAA,CACAC,EACkD,CAClD,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,CAUpD,OAAOG,CAILL,CAAAA,CAAAA,CAAO,CAACA,CAAMC,CAAAA,CAAK,EAAI,IAZT,CAAA,MAAO,CAACK,CAAWC,CAAAA,CAAU,CAI1B,GAAA,MAAMX,EAAO,GAAIU,CAAAA,CAAAA,CAAWC,EAAYJ,CAAc,CAAA,CAQjCC,CAAS,CACnD,CCrCO,SAASI,CACdC,CAAAA,CAAAA,CAIAP,EAC0D,CAC1D,GAAM,CAAE,cAAAC,CAAAA,CAAAA,CAAgB,GAAGC,CAAU,CAAA,CAAIF,GAAU,EAAC,CAUpD,OAAOQ,CAAeD,CAAAA,CAAAA,CARN,MAAO,CAACH,CAAAA,CAAWC,CAAU,CAI1B,GAAA,MAAMX,EAAO,GAAIU,CAAAA,CAAAA,CAAWC,EAAYJ,CAAc,CAAA,CAIlCC,CAAS,CAClD","file":"index.mjs","sourcesContent":["import useSWR, { SWRConfiguration, SWRResponse } from \"swr\";\nimport {\n Endpoints,\n APIRequestOptions,\n Client,\n PathsFor,\n DEFAULT_API_URL,\n TonightPassAPIError,\n Query,\n} from \"tonightpass\";\n\nexport const client = new Client({ baseURL: DEFAULT_API_URL });\n\ntype AnyEndpoint = Endpoints extends infer T ? T : never;\n\ntype ForceAccept<T> = T extends never ? any : T;\n\nexport type ResponseType<Path extends PathsFor<\"GET\">> = ForceAccept<\n Extract<AnyEndpoint, { path: Path; method: \"GET\" }>[\"res\"]\n>;\n\nexport type ErrorType<Path extends PathsFor<\"GET\">> = TonightPassAPIError<\n ResponseType<Path>\n>;\n\nexport interface UseAPIConfig<Path extends PathsFor<\"GET\">>\n extends SWRConfiguration<ResponseType<Path>, ErrorType<Path>> {\n requestOptions?: APIRequestOptions;\n}\n\nexport function useAPI<Path extends PathsFor<\"GET\">>(\n path: Path | null | undefined,\n query?: Query<Path>,\n config?: UseAPIConfig<Path>,\n): SWRResponse<ResponseType<Path>, ErrorType<Path>> {\n const { requestOptions, ...swrConfig } = config || {};\n\n const fetcher = async ([fetchPath, fetchQuery]: [\n Path,\n Query<Path> | undefined,\n ]) => {\n const response = await client.get(fetchPath, fetchQuery, requestOptions);\n return response as unknown as ResponseType<Path>;\n };\n\n return useSWR<\n ResponseType<Path>,\n ErrorType<Path>,\n [Path, Query<Path> | undefined] | null\n >(path ? [path, query] : null, fetcher, swrConfig);\n}\n","import useSWRInfinite, {\n SWRInfiniteConfiguration,\n SWRInfiniteResponse,\n} from \"swr/infinite\";\nimport { APIRequestOptions, PathsFor, Query } from \"tonightpass\";\n\nimport { client, ResponseType, ErrorType } from \"./useAPI\";\n\nexport interface UseAPIInfiniteConfig<Path extends PathsFor<\"GET\">>\n extends SWRInfiniteConfiguration<ResponseType<Path>, ErrorType<Path>> {\n requestOptions?: APIRequestOptions;\n}\n\nexport function useAPIInfinite<Path extends PathsFor<\"GET\">>(\n getKey: (\n pageIndex: number,\n previousPageData: ResponseType<Path> | null,\n ) => [Path, Query<Path> | undefined] | null,\n config?: UseAPIInfiniteConfig<Path>,\n): SWRInfiniteResponse<ResponseType<Path>, ErrorType<Path>> {\n const { requestOptions, ...swrConfig } = config || {};\n\n const fetcher = async ([fetchPath, fetchQuery]: [\n Path,\n Query<Path> | undefined,\n ]) => {\n const response = await client.get(fetchPath, fetchQuery, requestOptions);\n return response as unknown as ResponseType<Path>;\n };\n\n return useSWRInfinite(getKey, fetcher, swrConfig);\n}\n"]}
|