@newfold/huapi-js 1.1.1 → 1.2.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.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @newfold/huapi-js
2
+
3
+ > A JavaScript Client Library for HUAPI
4
+
5
+ ## Installation
6
+
7
+ TODO
8
+
9
+ ## Usage
10
+
11
+ ### React Hooks
12
+
13
+ ```js
14
+ import React from "react";
15
+
16
+ import { useGetHostingSites } from "@newfold/huapi-js";
17
+
18
+ const MyComponent = () => {
19
+ const hostingId = "2";
20
+ const { isLoading, data } = useGetHostingSites(hostingId);
21
+
22
+ if (isLoading) return <h1>Loading...</h1>;
23
+
24
+ return (
25
+ <div>
26
+ {data?.data?.rows?.map((site) => {
27
+ <div key={site.id}>{site.name}</div>;
28
+ })}
29
+ </div>
30
+ );
31
+ };
32
+ ```
package/openapi.json CHANGED
@@ -11,9 +11,26 @@
11
11
  "type": "object",
12
12
  "description": "A site",
13
13
  "properties": {
14
- "id": { "type": "string", "description": "TODO" },
15
- "name": { "type": "string", "description": "TODO" },
16
- "url": { "type": "string", "description": "TODO" }
14
+ "id": {
15
+ "type": "string",
16
+ "description": "TODO",
17
+ "example": "1"
18
+ },
19
+ "name": {
20
+ "type": "string",
21
+ "description": "TODO",
22
+ "example": "Example Site 1"
23
+ },
24
+ "url": {
25
+ "type": "string",
26
+ "description": "TODO",
27
+ "example": "https://example.com"
28
+ }
29
+ },
30
+ "example": {
31
+ "id": 1,
32
+ "name": "Example Site 1",
33
+ "url": "https://example.com"
17
34
  },
18
35
  "required": ["id", "name", "url"]
19
36
  },
@@ -21,19 +38,68 @@
21
38
  "description": "List of sites",
22
39
  "type": "object",
23
40
  "properties": {
24
- "limit": { "type": "string", "description": "TODO" },
25
- "n_pages": { "type": "string", "description": "TODO" },
26
- "n_rows": { "type": "string", "description": "TODO" },
27
- "page": { "type": "string", "description": "TODO" },
41
+ "limit": {
42
+ "type": "integer",
43
+ "description": "Max number of sites included in response",
44
+ "example": 10
45
+ },
46
+ "n_pages": {
47
+ "type": "integer",
48
+ "description": "TODO",
49
+ "example": 1
50
+ },
51
+ "n_rows": {
52
+ "type": "integer",
53
+ "description": "TODO",
54
+ "example": 1
55
+ },
56
+ "page": {
57
+ "type": "integer",
58
+ "description": "TODO",
59
+ "example": 1
60
+ },
28
61
  "rows": {
29
62
  "type": "array",
30
63
  "description": "TODO",
31
64
  "items": {
32
65
  "type": "array",
33
66
  "$ref": "#/components/schemas/Site"
34
- }
67
+ },
68
+ "example": [
69
+ {
70
+ "id": "1",
71
+ "name": "Example Site 1",
72
+ "url": "https://example.com"
73
+ },
74
+ {
75
+ "id": "2",
76
+ "name": "Example Site 2",
77
+ "url": "https://example2.com"
78
+ }
79
+ ]
35
80
  }
36
- }
81
+ },
82
+ "example": {
83
+ "limit": 10,
84
+ "n_pages": 1,
85
+ "n_rows": 1,
86
+ "page": 1,
87
+ "rows": [
88
+ [
89
+ {
90
+ "id": "1",
91
+ "name": "Example Site 1",
92
+ "url": "https://example.com"
93
+ },
94
+ {
95
+ "id": "2",
96
+ "name": "Example Site 2",
97
+ "url": "https://example2.com"
98
+ }
99
+ ]
100
+ ]
101
+ },
102
+ "required": ["limit", "n_pages", "n_rows", "page", "rows"]
37
103
  },
38
104
  "SiteSso": {
39
105
  "description": "SSO token or login URL",
@@ -45,6 +111,9 @@
45
111
  "description": "TODO"
46
112
  }
47
113
  },
114
+ "example": {
115
+ "sso": "$randomUrl"
116
+ },
48
117
  "required": ["sso"]
49
118
  }
50
119
  },
@@ -63,7 +132,11 @@
63
132
  "operationId": "site_sso",
64
133
  "description": "TODO",
65
134
  "tags": ["sites"],
66
- "security": [{ "bearerAuth": [] }],
135
+ "security": [
136
+ {
137
+ "bearerAuth": []
138
+ }
139
+ ],
67
140
  "parameters": [
68
141
  {
69
142
  "name": "site_id",
@@ -83,9 +156,6 @@
83
156
  "application/json": {
84
157
  "schema": {
85
158
  "$ref": "#/components/schemas/SiteSso"
86
- },
87
- "example": {
88
- "sso": "$randomUrl"
89
159
  }
90
160
  }
91
161
  }
@@ -95,7 +165,7 @@
95
165
  },
96
166
  "/hosting/{hosting_id}/sites": {
97
167
  "get": {
98
- "operationId": "get_hosting_sites",
168
+ "operationId": "hosting_sites",
99
169
  "tags": ["sites"],
100
170
  "security": [{ "bearerAuth": [] }],
101
171
  "summary": "Get sites for a hosting id",
@@ -118,19 +188,47 @@
118
188
  "application/json": {
119
189
  "schema": {
120
190
  "$ref": "#/components/schemas/SiteList"
121
- },
122
- "example": {
123
- "limit": "10",
124
- "n_pages": "1",
125
- "n_rows": "1",
126
- "page": "1",
127
- "rows": [
128
- {
129
- "id": "1",
130
- "name": "Example Site",
131
- "url": "https://example.com"
132
- }
133
- ]
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+ }
197
+ },
198
+ "/hosting/{hosting_id}/sites/{site_id}": {
199
+ "get": {
200
+ "operationId": "hosting_site_by_id",
201
+ "tags": ["sites"],
202
+ "security": [{ "bearerAuth": [] }],
203
+ "summary": "For a hosting id, get a specific site by site id",
204
+ "description": "Obtain a specific site.",
205
+ "parameters": [
206
+ {
207
+ "name": "hosting_id",
208
+ "in": "path",
209
+ "required": true,
210
+ "schema": {
211
+ "type": "integer",
212
+ "description": "Specify the hosting id to get sites for."
213
+ }
214
+ },
215
+ {
216
+ "name": "site_id",
217
+ "in": "path",
218
+ "required": true,
219
+ "schema": {
220
+ "type": "string",
221
+ "description": "Specify the site id to get the site for."
222
+ }
223
+ }
224
+ ],
225
+ "responses": {
226
+ "200": {
227
+ "description": "OK",
228
+ "content": {
229
+ "application/json": {
230
+ "schema": {
231
+ "$ref": "#/components/schemas/Site"
134
232
  }
135
233
  }
136
234
  }
package/orval.config.js CHANGED
@@ -1,16 +1,57 @@
1
- module.exports = {
1
+ import { faker } from "@faker-js/faker";
2
+ import { defineConfig } from "orval";
3
+
4
+ const input = {
5
+ target: "./openapi.json",
6
+ validation: true,
7
+ };
8
+
9
+ const output = {
10
+ // mode: "tags-split",
11
+ target: "./src/huapi.ts",
12
+ // schemas: "src/model",
13
+ client: "react-query",
14
+ mock: true,
15
+ clean: true,
16
+ };
17
+
18
+ const sites = {
19
+ limit: 10,
20
+ n_pages: 1,
21
+ n_rows: 3,
22
+ page: 1,
23
+ rows: [...Array(3)].map((site, idx) => ({
24
+ id: idx,
25
+ name: faker.company.companyName(),
26
+ url: faker.internet.url(),
27
+ })),
28
+ };
29
+
30
+ export default defineConfig({
2
31
  huapi: {
3
- input: {
4
- target: "./openapi.json",
5
- validation: true,
6
- },
32
+ input,
7
33
  output: {
8
- // mode: "tags-split",
34
+ ...output,
9
35
  target: "./src/huapi.ts",
10
- // schemas: "src/model",
11
- client: "react-query",
12
- mock: true,
13
- clean: true,
36
+ override: {
37
+ operations: {
38
+ site_sso: {
39
+ mock: {
40
+ data: `${sites.rows[0].url}/wp-login.php?ssotoken=1234567890`,
41
+ },
42
+ },
43
+ hosting_sites: {
44
+ mock: {
45
+ data: sites,
46
+ },
47
+ },
48
+ hosting_site_by_id: {
49
+ mock: {
50
+ data: sites.rows[0],
51
+ },
52
+ },
53
+ },
54
+ },
14
55
  },
15
56
  },
16
- };
57
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newfold/huapi-js",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "main": "src/huapi.js",
5
5
  "license": "MIT",
6
6
  "devDependencies": {
@@ -17,7 +17,7 @@
17
17
  "axios": "^0.26.1",
18
18
  "msw": "^0.39.2",
19
19
  "orval": "^6.7.1",
20
- "react": "^18.0.0",
20
+ "react": "^17.0.2",
21
21
  "react-query": "^3.34.19"
22
22
  },
23
23
  "scripts": {
package/src/huapi.js CHANGED
@@ -10,17 +10,8 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
13
  exports.__esModule = true;
23
- exports.getHostingUAPIMSW = exports.getGetHostingSitesMock = exports.getSiteSsoMock = exports.useGetHostingSites = exports.getGetHostingSitesQueryKey = exports.getHostingSites = exports.useSiteSso = exports.siteSso = void 0;
14
+ exports.getHostingUAPIMSW = exports.getHostingSiteByIdMock = exports.getHostingSitesMock = exports.getSiteSsoMock = exports.useHostingSiteById = exports.getHostingSiteByIdQueryKey = exports.hostingSiteById = exports.useHostingSites = exports.getHostingSitesQueryKey = exports.hostingSites = exports.useSiteSso = exports.siteSso = void 0;
24
15
  /**
25
16
  * Generated by orval v6.7.1 🍺
26
17
  * Do not edit manually.
@@ -31,7 +22,6 @@ exports.getHostingUAPIMSW = exports.getGetHostingSitesMock = exports.getSiteSsoM
31
22
  var axios_1 = require("axios");
32
23
  var react_query_1 = require("react-query");
33
24
  var msw_1 = require("msw");
34
- var faker_1 = require("@faker-js/faker");
35
25
  /**
36
26
  * TODO
37
27
  * @summary Get SSO token
@@ -53,30 +43,53 @@ exports.useSiteSso = useSiteSso;
53
43
  * Obtain a list of sites.
54
44
  * @summary Get sites for a hosting id
55
45
  */
56
- var getHostingSites = function (hostingId, options) {
46
+ var hostingSites = function (hostingId, options) {
57
47
  return axios_1["default"].get("/hosting/".concat(hostingId, "/sites"), options);
58
48
  };
59
- exports.getHostingSites = getHostingSites;
60
- var getGetHostingSitesQueryKey = function (hostingId) { return ["/hosting/".concat(hostingId, "/sites")]; };
61
- exports.getGetHostingSitesQueryKey = getGetHostingSitesQueryKey;
62
- var useGetHostingSites = function (hostingId, options) {
49
+ exports.hostingSites = hostingSites;
50
+ var getHostingSitesQueryKey = function (hostingId) { return ["/hosting/".concat(hostingId, "/sites")]; };
51
+ exports.getHostingSitesQueryKey = getHostingSitesQueryKey;
52
+ var useHostingSites = function (hostingId, options) {
63
53
  var _a;
64
54
  var _b = options || {}, queryOptions = _b.query, axiosOptions = _b.axios;
65
- var queryKey = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.queryKey) !== null && _a !== void 0 ? _a : (0, exports.getGetHostingSitesQueryKey)(hostingId);
66
- var queryFn = function () { return (0, exports.getHostingSites)(hostingId, axiosOptions); };
55
+ var queryKey = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.queryKey) !== null && _a !== void 0 ? _a : (0, exports.getHostingSitesQueryKey)(hostingId);
56
+ var queryFn = function () { return (0, exports.hostingSites)(hostingId, axiosOptions); };
67
57
  var query = (0, react_query_1.useQuery)(queryKey, queryFn, __assign({ enabled: !!(hostingId) }, queryOptions));
68
58
  return __assign({ queryKey: queryKey }, query);
69
59
  };
70
- exports.useGetHostingSites = useGetHostingSites;
71
- var getSiteSsoMock = function () { return ({ sso: faker_1.faker.random.word() }); };
60
+ exports.useHostingSites = useHostingSites;
61
+ /**
62
+ * Obtain a specific site.
63
+ * @summary For a hosting id, get a specific site by site id
64
+ */
65
+ var hostingSiteById = function (hostingId, siteId, options) {
66
+ return axios_1["default"].get("/hosting/".concat(hostingId, "/sites/").concat(siteId), options);
67
+ };
68
+ exports.hostingSiteById = hostingSiteById;
69
+ var getHostingSiteByIdQueryKey = function (hostingId, siteId) { return ["/hosting/".concat(hostingId, "/sites/").concat(siteId)]; };
70
+ exports.getHostingSiteByIdQueryKey = getHostingSiteByIdQueryKey;
71
+ var useHostingSiteById = function (hostingId, siteId, options) {
72
+ var _a;
73
+ var _b = options || {}, queryOptions = _b.query, axiosOptions = _b.axios;
74
+ var queryKey = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.queryKey) !== null && _a !== void 0 ? _a : (0, exports.getHostingSiteByIdQueryKey)(hostingId, siteId);
75
+ var queryFn = function () { return (0, exports.hostingSiteById)(hostingId, siteId, axiosOptions); };
76
+ var query = (0, react_query_1.useQuery)(queryKey, queryFn, __assign({ enabled: !!(hostingId && siteId) }, queryOptions));
77
+ return __assign({ queryKey: queryKey }, query);
78
+ };
79
+ exports.useHostingSiteById = useHostingSiteById;
80
+ var getSiteSsoMock = function () { return ('https://parched-robe.name/wp-login.php?ssotoken=1234567890'); };
72
81
  exports.getSiteSsoMock = getSiteSsoMock;
73
- var getGetHostingSitesMock = function () { return ({ limit: faker_1.faker.helpers.randomize([faker_1.faker.random.word(), undefined]), n_pages: faker_1.faker.helpers.randomize([faker_1.faker.random.word(), undefined]), n_rows: faker_1.faker.helpers.randomize([faker_1.faker.random.word(), undefined]), page: faker_1.faker.helpers.randomize([faker_1.faker.random.word(), undefined]), rows: faker_1.faker.helpers.randomize([__spreadArray([], Array(faker_1.faker.datatype.number({ min: 1, max: 10 })), true).map(function () { return ({ id: faker_1.faker.random.word(), name: faker_1.faker.random.word(), url: faker_1.faker.random.word() }); }), undefined]) }); };
74
- exports.getGetHostingSitesMock = getGetHostingSitesMock;
82
+ var getHostingSitesMock = function () { return ({ limit: 10, n_pages: 1, n_rows: 3, page: 1, rows: [{ id: 0, name: 'Murazik - Weber', url: 'https://parched-robe.name' }, { id: 1, name: 'Gutmann - Bahringer', url: 'http://kindhearted-boogeyman.com' }, { id: 2, name: 'Volkman - Stiedemann', url: 'https://coarse-vendor.com' }] }); };
83
+ exports.getHostingSitesMock = getHostingSitesMock;
84
+ var getHostingSiteByIdMock = function () { return ({ id: 0, name: 'Murazik - Weber', url: 'https://parched-robe.name' }); };
85
+ exports.getHostingSiteByIdMock = getHostingSiteByIdMock;
75
86
  var getHostingUAPIMSW = function () { return [
76
87
  msw_1.rest.post('*/sites/:siteid/sso', function (_req, res, ctx) {
77
88
  return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getSiteSsoMock)()));
78
89
  }), msw_1.rest.get('*/hosting/:hostingid/sites', function (_req, res, ctx) {
79
- return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getGetHostingSitesMock)()));
90
+ return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getHostingSitesMock)()));
91
+ }), msw_1.rest.get('*/hosting/:hostingid/sites/:siteid', function (_req, res, ctx) {
92
+ return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getHostingSiteByIdMock)()));
80
93
  }),
81
94
  ]; };
82
95
  exports.getHostingUAPIMSW = getHostingUAPIMSW;
package/src/huapi.ts ADDED
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Generated by orval v6.7.1 🍺
3
+ * Do not edit manually.
4
+ * Hosting UAPI
5
+ * Hosting UAPI
6
+ * OpenAPI spec version: 0.1.0
7
+ */
8
+ import axios,{
9
+ AxiosRequestConfig,
10
+ AxiosResponse,
11
+ AxiosError
12
+ } from 'axios'
13
+ import {
14
+ useQuery,
15
+ useMutation,
16
+ UseQueryOptions,
17
+ UseMutationOptions,
18
+ QueryFunction,
19
+ MutationFunction,
20
+ UseQueryResult,
21
+ QueryKey
22
+ } from 'react-query'
23
+ import {
24
+ rest
25
+ } from 'msw'
26
+ /**
27
+ * SSO token or login URL
28
+ */
29
+ export interface SiteSso {
30
+ /** TODO */
31
+ sso: string;
32
+ }
33
+
34
+ /**
35
+ * A site
36
+ */
37
+ export interface Site {
38
+ /** TODO */
39
+ id: string;
40
+ /** TODO */
41
+ name: string;
42
+ /** TODO */
43
+ url: string;
44
+ }
45
+
46
+ /**
47
+ * List of sites
48
+ */
49
+ export interface SiteList {
50
+ /** Max number of sites included in response */
51
+ limit: number;
52
+ /** TODO */
53
+ n_pages: number;
54
+ /** TODO */
55
+ n_rows: number;
56
+ /** TODO */
57
+ page: number;
58
+ /** TODO */
59
+ rows: Site[];
60
+ }
61
+
62
+
63
+
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ type AsyncReturnType<
66
+ T extends (...args: any) => Promise<any>
67
+ > = T extends (...args: any) => Promise<infer R> ? R : any;
68
+
69
+
70
+ /**
71
+ * TODO
72
+ * @summary Get SSO token
73
+ */
74
+ export const siteSso = (
75
+ siteId: number, options?: AxiosRequestConfig
76
+ ): Promise<AxiosResponse<SiteSso>> => {
77
+ return axios.post(
78
+ `/sites/${siteId}/sso`,undefined,options
79
+ );
80
+ }
81
+
82
+
83
+
84
+ export type SiteSsoMutationResult = NonNullable<AsyncReturnType<typeof siteSso>>
85
+
86
+ export type SiteSsoMutationError = AxiosError<unknown>
87
+
88
+ export const useSiteSso = <TError = AxiosError<unknown>,
89
+
90
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<AsyncReturnType<typeof siteSso>, TError,{siteId: number}, TContext>, axios?: AxiosRequestConfig}
91
+ ) => {
92
+ const {mutation: mutationOptions, axios: axiosOptions} = options || {}
93
+
94
+
95
+
96
+
97
+ const mutationFn: MutationFunction<AsyncReturnType<typeof siteSso>, {siteId: number}> = (props) => {
98
+ const {siteId} = props || {};
99
+
100
+ return siteSso(siteId,axiosOptions)
101
+ }
102
+
103
+ return useMutation<AsyncReturnType<typeof siteSso>, TError, {siteId: number}, TContext>(mutationFn, mutationOptions)
104
+ }
105
+
106
+ /**
107
+ * Obtain a list of sites.
108
+ * @summary Get sites for a hosting id
109
+ */
110
+ export const hostingSites = (
111
+ hostingId: number, options?: AxiosRequestConfig
112
+ ): Promise<AxiosResponse<SiteList>> => {
113
+ return axios.get(
114
+ `/hosting/${hostingId}/sites`,options
115
+ );
116
+ }
117
+
118
+
119
+ export const getHostingSitesQueryKey = (hostingId: number,) => [`/hosting/${hostingId}/sites`];
120
+
121
+
122
+ export type HostingSitesQueryResult = NonNullable<AsyncReturnType<typeof hostingSites>>
123
+ export type HostingSitesQueryError = AxiosError<unknown>
124
+
125
+ export const useHostingSites = <TData = AsyncReturnType<typeof hostingSites>, TError = AxiosError<unknown>>(
126
+ hostingId: number, options?: { query?:UseQueryOptions<AsyncReturnType<typeof hostingSites>, TError, TData>, axios?: AxiosRequestConfig}
127
+
128
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
129
+
130
+ const {query: queryOptions, axios: axiosOptions} = options || {}
131
+
132
+ const queryKey = queryOptions?.queryKey ?? getHostingSitesQueryKey(hostingId);
133
+
134
+
135
+
136
+ const queryFn: QueryFunction<AsyncReturnType<typeof hostingSites>> = () => hostingSites(hostingId, axiosOptions);
137
+
138
+ const query = useQuery<AsyncReturnType<typeof hostingSites>, TError, TData>(queryKey, queryFn, {enabled: !!(hostingId), ...queryOptions})
139
+
140
+ return {
141
+ queryKey,
142
+ ...query
143
+ }
144
+ }
145
+
146
+
147
+ /**
148
+ * Obtain a specific site.
149
+ * @summary For a hosting id, get a specific site by site id
150
+ */
151
+ export const hostingSiteById = (
152
+ hostingId: number,
153
+ siteId: string, options?: AxiosRequestConfig
154
+ ): Promise<AxiosResponse<Site>> => {
155
+ return axios.get(
156
+ `/hosting/${hostingId}/sites/${siteId}`,options
157
+ );
158
+ }
159
+
160
+
161
+ export const getHostingSiteByIdQueryKey = (hostingId: number,
162
+ siteId: string,) => [`/hosting/${hostingId}/sites/${siteId}`];
163
+
164
+
165
+ export type HostingSiteByIdQueryResult = NonNullable<AsyncReturnType<typeof hostingSiteById>>
166
+ export type HostingSiteByIdQueryError = AxiosError<unknown>
167
+
168
+ export const useHostingSiteById = <TData = AsyncReturnType<typeof hostingSiteById>, TError = AxiosError<unknown>>(
169
+ hostingId: number,
170
+ siteId: string, options?: { query?:UseQueryOptions<AsyncReturnType<typeof hostingSiteById>, TError, TData>, axios?: AxiosRequestConfig}
171
+
172
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
173
+
174
+ const {query: queryOptions, axios: axiosOptions} = options || {}
175
+
176
+ const queryKey = queryOptions?.queryKey ?? getHostingSiteByIdQueryKey(hostingId,siteId);
177
+
178
+
179
+
180
+ const queryFn: QueryFunction<AsyncReturnType<typeof hostingSiteById>> = () => hostingSiteById(hostingId,siteId, axiosOptions);
181
+
182
+ const query = useQuery<AsyncReturnType<typeof hostingSiteById>, TError, TData>(queryKey, queryFn, {enabled: !!(hostingId && siteId), ...queryOptions})
183
+
184
+ return {
185
+ queryKey,
186
+ ...query
187
+ }
188
+ }
189
+
190
+
191
+
192
+
193
+ export const getSiteSsoMock = () => ('https://parched-robe.name/wp-login.php?ssotoken=1234567890')
194
+
195
+ export const getHostingSitesMock = () => ({ limit: 10, n_pages: 1, n_rows: 3, page: 1, rows: [{ id: 0, name: 'Murazik - Weber', url: 'https://parched-robe.name', }, { id: 1, name: 'Gutmann - Bahringer', url: 'http://kindhearted-boogeyman.com', }, { id: 2, name: 'Volkman - Stiedemann', url: 'https://coarse-vendor.com', }], })
196
+
197
+ export const getHostingSiteByIdMock = () => ({ id: 0, name: 'Murazik - Weber', url: 'https://parched-robe.name', })
198
+
199
+ export const getHostingUAPIMSW = () => [
200
+ rest.post('*/sites/:siteid/sso', (_req, res, ctx) => {
201
+ return res(
202
+ ctx.delay(1000),
203
+ ctx.status(200, 'Mocked status'),
204
+ ctx.json(getSiteSsoMock()),
205
+ )
206
+ }),rest.get('*/hosting/:hostingid/sites', (_req, res, ctx) => {
207
+ return res(
208
+ ctx.delay(1000),
209
+ ctx.status(200, 'Mocked status'),
210
+ ctx.json(getHostingSitesMock()),
211
+ )
212
+ }),rest.get('*/hosting/:hostingid/sites/:siteid', (_req, res, ctx) => {
213
+ return res(
214
+ ctx.delay(1000),
215
+ ctx.status(200, 'Mocked status'),
216
+ ctx.json(getHostingSiteByIdMock()),
217
+ )
218
+ }),]