@newfold/huapi-js 1.0.1 → 1.0.2

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/orval.config.js CHANGED
@@ -9,6 +9,7 @@ module.exports = {
9
9
  target: "./src/huapi.ts",
10
10
  // schemas: "src/model",
11
11
  client: "react-query",
12
+ mock: true,
12
13
  },
13
14
  },
14
15
  };
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@newfold/huapi-js",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "src/huapi.js",
5
5
  "license": "MIT",
6
- "devDependencies": {
6
+ "dependencies": {
7
+ "@faker-js/faker": "^6.1.2",
7
8
  "axios": "^0.26.1",
9
+ "msw": "^0.39.2",
8
10
  "orval": "^6.7.1",
9
11
  "react": "^18.0.0",
10
12
  "react-query": "^3.34.19",
11
13
  "typescript": "^4.6.3"
12
14
  },
13
- "peerDependencies": {
14
- "react-query": "^3.0.0"
15
- },
16
15
  "scripts": {
17
16
  "clean": "rm -rf ./src",
18
17
  "orval": "orval",
package/src/huapi.js CHANGED
@@ -10,8 +10,17 @@ 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
+ };
13
22
  exports.__esModule = true;
14
- exports.useGetHostingHostingIdSites = exports.getGetHostingHostingIdSitesQueryKey = exports.getHostingHostingIdSites = exports.usePostSitesSiteIdSso = exports.postSitesSiteIdSso = void 0;
23
+ exports.getHostingUAPIMSW = exports.getGetHostingHostingIdSitesMock = exports.getPostSitesSiteIdSsoMock = exports.useGetHostingHostingIdSites = exports.getGetHostingHostingIdSitesQueryKey = exports.getHostingHostingIdSites = exports.usePostSitesSiteIdSso = exports.postSitesSiteIdSso = void 0;
15
24
  /**
16
25
  * Generated by orval v6.7.1 🍺
17
26
  * Do not edit manually.
@@ -20,6 +29,8 @@ exports.useGetHostingHostingIdSites = exports.getGetHostingHostingIdSitesQueryKe
20
29
  */
21
30
  var axios_1 = require("axios");
22
31
  var react_query_1 = require("react-query");
32
+ var msw_1 = require("msw");
33
+ var faker_1 = require("@faker-js/faker");
23
34
  /**
24
35
  * Return an SSO token or login URL for this site (if supported).
25
36
  * @summary site_sso
@@ -56,3 +67,15 @@ var useGetHostingHostingIdSites = function (hostingId, options) {
56
67
  return __assign({ queryKey: queryKey }, query);
57
68
  };
58
69
  exports.useGetHostingHostingIdSites = useGetHostingHostingIdSites;
70
+ var getPostSitesSiteIdSsoMock = function () { return ({ sso: faker_1.faker.random.word() }); };
71
+ exports.getPostSitesSiteIdSsoMock = getPostSitesSiteIdSsoMock;
72
+ var getGetHostingHostingIdSitesMock = function () { return ({ limit: faker_1.faker.random.word(), n_pages: faker_1.faker.random.word(), n_rows: faker_1.faker.random.word(), page: faker_1.faker.random.word(), 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() }); }) }); };
73
+ exports.getGetHostingHostingIdSitesMock = getGetHostingHostingIdSitesMock;
74
+ var getHostingUAPIMSW = function () { return [
75
+ msw_1.rest.post('*/sites/:siteid/sso', function (_req, res, ctx) {
76
+ return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getPostSitesSiteIdSsoMock)()));
77
+ }), msw_1.rest.get('*/hosting/:hostingid/sites', function (_req, res, ctx) {
78
+ return res(ctx.delay(1000), ctx.status(200, 'Mocked status'), ctx.json((0, exports.getGetHostingHostingIdSitesMock)()));
79
+ }),
80
+ ]; };
81
+ exports.getHostingUAPIMSW = getHostingUAPIMSW;
package/src/huapi.ts CHANGED
@@ -19,6 +19,12 @@ import {
19
19
  UseQueryResult,
20
20
  QueryKey
21
21
  } from 'react-query'
22
+ import {
23
+ rest
24
+ } from 'msw'
25
+ import {
26
+ faker
27
+ } from '@faker-js/faker'
22
28
  export type GetHostingHostingIdSites200RowsItem = {
23
29
  id: string;
24
30
  name: string;
@@ -122,3 +128,23 @@ export const useGetHostingHostingIdSites = <TData = AsyncReturnType<typeof getHo
122
128
  }
123
129
 
124
130
 
131
+
132
+
133
+ export const getPostSitesSiteIdSsoMock = () => ({sso: faker.random.word()})
134
+
135
+ export const getGetHostingHostingIdSitesMock = () => ({limit: faker.random.word(), n_pages: faker.random.word(), n_rows: faker.random.word(), page: faker.random.word(), rows: [...Array(faker.datatype.number({min: 1, max: 10}))].map(() => ({id: faker.random.word(), name: faker.random.word(), url: faker.random.word()}))})
136
+
137
+ export const getHostingUAPIMSW = () => [
138
+ rest.post('*/sites/:siteid/sso', (_req, res, ctx) => {
139
+ return res(
140
+ ctx.delay(1000),
141
+ ctx.status(200, 'Mocked status'),
142
+ ctx.json(getPostSitesSiteIdSsoMock()),
143
+ )
144
+ }),rest.get('*/hosting/:hostingid/sites', (_req, res, ctx) => {
145
+ return res(
146
+ ctx.delay(1000),
147
+ ctx.status(200, 'Mocked status'),
148
+ ctx.json(getGetHostingHostingIdSitesMock()),
149
+ )
150
+ }),]