@newfold/huapi-js 1.1.3 → 1.2.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/openapi.json +47 -6
- package/package.json +1 -1
- package/src/huapi.js +25 -2
- package/src/huapi.ts +54 -2
package/openapi.json
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"description": "A site",
|
|
13
13
|
"properties": {
|
|
14
14
|
"id": {
|
|
15
|
-
"type": "
|
|
15
|
+
"type": "string",
|
|
16
16
|
"description": "TODO",
|
|
17
|
-
"example": 1
|
|
17
|
+
"example": "1"
|
|
18
18
|
},
|
|
19
19
|
"name": {
|
|
20
20
|
"type": "string",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
},
|
|
68
68
|
"example": [
|
|
69
69
|
{
|
|
70
|
-
"id": 1,
|
|
70
|
+
"id": "1",
|
|
71
71
|
"name": "Example Site 1",
|
|
72
72
|
"url": "https://example.com"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
"id": 2,
|
|
75
|
+
"id": "2",
|
|
76
76
|
"name": "Example Site 2",
|
|
77
77
|
"url": "https://example2.com"
|
|
78
78
|
}
|
|
@@ -87,12 +87,12 @@
|
|
|
87
87
|
"rows": [
|
|
88
88
|
[
|
|
89
89
|
{
|
|
90
|
-
"id": 1,
|
|
90
|
+
"id": "1",
|
|
91
91
|
"name": "Example Site 1",
|
|
92
92
|
"url": "https://example.com"
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
"id": 2,
|
|
95
|
+
"id": "2",
|
|
96
96
|
"name": "Example Site 2",
|
|
97
97
|
"url": "https://example2.com"
|
|
98
98
|
}
|
|
@@ -194,6 +194,47 @@
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
+
},
|
|
198
|
+
"/hosting/{hosting_id}/sites/{site_id}": {
|
|
199
|
+
"get": {
|
|
200
|
+
"operationId": "get_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"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
197
238
|
}
|
|
198
239
|
},
|
|
199
240
|
"servers": [
|
package/package.json
CHANGED
package/src/huapi.js
CHANGED
|
@@ -20,7 +20,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
20
20
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
21
|
};
|
|
22
22
|
exports.__esModule = true;
|
|
23
|
-
exports.getHostingUAPIMSW = exports.getGetHostingSitesMock = exports.getSiteSsoMock = exports.useGetHostingSites = exports.getGetHostingSitesQueryKey = exports.getHostingSites = exports.useSiteSso = exports.siteSso = void 0;
|
|
23
|
+
exports.getHostingUAPIMSW = exports.getGetHostingSiteByIdMock = exports.getGetHostingSitesMock = exports.getSiteSsoMock = exports.useGetHostingSiteById = exports.getGetHostingSiteByIdQueryKey = exports.getHostingSiteById = exports.useGetHostingSites = exports.getGetHostingSitesQueryKey = exports.getHostingSites = exports.useSiteSso = exports.siteSso = void 0;
|
|
24
24
|
/**
|
|
25
25
|
* Generated by orval v6.7.1 🍺
|
|
26
26
|
* Do not edit manually.
|
|
@@ -68,15 +68,38 @@ var useGetHostingSites = function (hostingId, options) {
|
|
|
68
68
|
return __assign({ queryKey: queryKey }, query);
|
|
69
69
|
};
|
|
70
70
|
exports.useGetHostingSites = useGetHostingSites;
|
|
71
|
+
/**
|
|
72
|
+
* Obtain a specific site.
|
|
73
|
+
* @summary For a hosting id, get a specific site by site id
|
|
74
|
+
*/
|
|
75
|
+
var getHostingSiteById = function (hostingId, siteId, options) {
|
|
76
|
+
return axios_1["default"].get("/hosting/".concat(hostingId, "/sites/").concat(siteId), options);
|
|
77
|
+
};
|
|
78
|
+
exports.getHostingSiteById = getHostingSiteById;
|
|
79
|
+
var getGetHostingSiteByIdQueryKey = function (hostingId, siteId) { return ["/hosting/".concat(hostingId, "/sites/").concat(siteId)]; };
|
|
80
|
+
exports.getGetHostingSiteByIdQueryKey = getGetHostingSiteByIdQueryKey;
|
|
81
|
+
var useGetHostingSiteById = function (hostingId, siteId, options) {
|
|
82
|
+
var _a;
|
|
83
|
+
var _b = options || {}, queryOptions = _b.query, axiosOptions = _b.axios;
|
|
84
|
+
var queryKey = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.queryKey) !== null && _a !== void 0 ? _a : (0, exports.getGetHostingSiteByIdQueryKey)(hostingId, siteId);
|
|
85
|
+
var queryFn = function () { return (0, exports.getHostingSiteById)(hostingId, siteId, axiosOptions); };
|
|
86
|
+
var query = (0, react_query_1.useQuery)(queryKey, queryFn, __assign({ enabled: !!(hostingId && siteId) }, queryOptions));
|
|
87
|
+
return __assign({ queryKey: queryKey }, query);
|
|
88
|
+
};
|
|
89
|
+
exports.useGetHostingSiteById = useGetHostingSiteById;
|
|
71
90
|
var getSiteSsoMock = function () { return ({ sso: faker_1.faker.random.word() }); };
|
|
72
91
|
exports.getSiteSsoMock = getSiteSsoMock;
|
|
73
|
-
var getGetHostingSitesMock = function () { return ({ limit: faker_1.faker.datatype.number(), n_pages: faker_1.faker.datatype.number(), n_rows: faker_1.faker.datatype.number(), page: faker_1.faker.datatype.number(), rows: __spreadArray([], Array(faker_1.faker.datatype.number({ min: 1, max: 10 })), true).map(function () { return ({ id: faker_1.faker.
|
|
92
|
+
var getGetHostingSitesMock = function () { return ({ limit: faker_1.faker.datatype.number(), n_pages: faker_1.faker.datatype.number(), n_rows: faker_1.faker.datatype.number(), page: faker_1.faker.datatype.number(), rows: __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() }); }) }); };
|
|
74
93
|
exports.getGetHostingSitesMock = getGetHostingSitesMock;
|
|
94
|
+
var getGetHostingSiteByIdMock = function () { return ({ id: faker_1.faker.random.word(), name: faker_1.faker.random.word(), url: faker_1.faker.random.word() }); };
|
|
95
|
+
exports.getGetHostingSiteByIdMock = getGetHostingSiteByIdMock;
|
|
75
96
|
var getHostingUAPIMSW = function () { return [
|
|
76
97
|
msw_1.rest.post('*/sites/:siteid/sso', function (_req, res, ctx) {
|
|
77
98
|
return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getSiteSsoMock)()));
|
|
78
99
|
}), msw_1.rest.get('*/hosting/:hostingid/sites', function (_req, res, ctx) {
|
|
79
100
|
return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getGetHostingSitesMock)()));
|
|
101
|
+
}), msw_1.rest.get('*/hosting/:hostingid/sites/:siteid', function (_req, res, ctx) {
|
|
102
|
+
return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getGetHostingSiteByIdMock)()));
|
|
80
103
|
}),
|
|
81
104
|
]; };
|
|
82
105
|
exports.getHostingUAPIMSW = getHostingUAPIMSW;
|
package/src/huapi.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface SiteSso {
|
|
|
39
39
|
*/
|
|
40
40
|
export interface Site {
|
|
41
41
|
/** TODO */
|
|
42
|
-
id:
|
|
42
|
+
id: string;
|
|
43
43
|
/** TODO */
|
|
44
44
|
name: string;
|
|
45
45
|
/** TODO */
|
|
@@ -147,11 +147,57 @@ export const useGetHostingSites = <TData = AsyncReturnType<typeof getHostingSite
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Obtain a specific site.
|
|
152
|
+
* @summary For a hosting id, get a specific site by site id
|
|
153
|
+
*/
|
|
154
|
+
export const getHostingSiteById = (
|
|
155
|
+
hostingId: number,
|
|
156
|
+
siteId: string, options?: AxiosRequestConfig
|
|
157
|
+
): Promise<AxiosResponse<Site>> => {
|
|
158
|
+
return axios.get(
|
|
159
|
+
`/hosting/${hostingId}/sites/${siteId}`,options
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
export const getGetHostingSiteByIdQueryKey = (hostingId: number,
|
|
165
|
+
siteId: string,) => [`/hosting/${hostingId}/sites/${siteId}`];
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
export type GetHostingSiteByIdQueryResult = NonNullable<AsyncReturnType<typeof getHostingSiteById>>
|
|
169
|
+
export type GetHostingSiteByIdQueryError = AxiosError<unknown>
|
|
170
|
+
|
|
171
|
+
export const useGetHostingSiteById = <TData = AsyncReturnType<typeof getHostingSiteById>, TError = AxiosError<unknown>>(
|
|
172
|
+
hostingId: number,
|
|
173
|
+
siteId: string, options?: { query?:UseQueryOptions<AsyncReturnType<typeof getHostingSiteById>, TError, TData>, axios?: AxiosRequestConfig}
|
|
174
|
+
|
|
175
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
176
|
+
|
|
177
|
+
const {query: queryOptions, axios: axiosOptions} = options || {}
|
|
178
|
+
|
|
179
|
+
const queryKey = queryOptions?.queryKey ?? getGetHostingSiteByIdQueryKey(hostingId,siteId);
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getHostingSiteById>> = () => getHostingSiteById(hostingId,siteId, axiosOptions);
|
|
184
|
+
|
|
185
|
+
const query = useQuery<AsyncReturnType<typeof getHostingSiteById>, TError, TData>(queryKey, queryFn, {enabled: !!(hostingId && siteId), ...queryOptions})
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
queryKey,
|
|
189
|
+
...query
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
150
194
|
|
|
151
195
|
|
|
152
196
|
export const getSiteSsoMock = () => ({sso: faker.random.word()})
|
|
153
197
|
|
|
154
|
-
export const getGetHostingSitesMock = () => ({limit: faker.datatype.number(), n_pages: faker.datatype.number(), n_rows: faker.datatype.number(), page: faker.datatype.number(), rows: [...Array(faker.datatype.number({min: 1, max: 10}))].map(() => ({id: faker.
|
|
198
|
+
export const getGetHostingSitesMock = () => ({limit: faker.datatype.number(), n_pages: faker.datatype.number(), n_rows: faker.datatype.number(), page: faker.datatype.number(), rows: [...Array(faker.datatype.number({min: 1, max: 10}))].map(() => ({id: faker.random.word(), name: faker.random.word(), url: faker.random.word()}))})
|
|
199
|
+
|
|
200
|
+
export const getGetHostingSiteByIdMock = () => ({id: faker.random.word(), name: faker.random.word(), url: faker.random.word()})
|
|
155
201
|
|
|
156
202
|
export const getHostingUAPIMSW = () => [
|
|
157
203
|
rest.post('*/sites/:siteid/sso', (_req, res, ctx) => {
|
|
@@ -166,4 +212,10 @@ ctx.json(getSiteSsoMock()),
|
|
|
166
212
|
ctx.status(200, 'Mocked status'),
|
|
167
213
|
ctx.json(getGetHostingSitesMock()),
|
|
168
214
|
)
|
|
215
|
+
}),rest.get('*/hosting/:hostingid/sites/:siteid', (_req, res, ctx) => {
|
|
216
|
+
return res(
|
|
217
|
+
ctx.delay(1000),
|
|
218
|
+
ctx.status(200, 'Mocked status'),
|
|
219
|
+
ctx.json(getGetHostingSiteByIdMock()),
|
|
220
|
+
)
|
|
169
221
|
}),]
|