@escapenavigator/services 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.
Files changed (47) hide show
  1. package/dist/api/cities-api/get-cities-by-country.d.ts +7 -0
  2. package/dist/api/cities-api/get-cities-by-country.js +8 -0
  3. package/dist/api/cities-api/get-city-by-ip.d.ts +6 -0
  4. package/dist/api/cities-api/get-city-by-ip.js +8 -0
  5. package/dist/api/cities-api/get-city-by-slug.d.ts +6 -0
  6. package/dist/api/cities-api/get-city-by-slug.js +8 -0
  7. package/dist/api/cities-api/get-one.d.ts +6 -0
  8. package/dist/api/cities-api/get-one.js +8 -0
  9. package/dist/api/cities-api/get-popular-cities-near.d.ts +6 -0
  10. package/dist/api/cities-api/get-popular-cities-near.js +8 -0
  11. package/dist/api/cities-api/index.d.ts +18 -0
  12. package/dist/api/cities-api/index.js +19 -0
  13. package/dist/api/cities-api/query.d.ts +7 -0
  14. package/dist/api/cities-api/query.js +9 -0
  15. package/dist/api/cities-api/remove.d.ts +7 -0
  16. package/dist/api/cities-api/remove.js +8 -0
  17. package/dist/api/cities-api/update.d.ts +10 -0
  18. package/dist/api/cities-api/update.js +9 -0
  19. package/dist/api/index.js +1 -1
  20. package/dist/api/init-client-api.d.ts +4 -3
  21. package/dist/api/init-client-api.js +32 -34
  22. package/dist/api/locations-api/get-by-coordinates.d.ts +7 -0
  23. package/dist/api/locations-api/get-by-coordinates.js +8 -0
  24. package/dist/api/locations-api/index.d.ts +2 -0
  25. package/dist/api/locations-api/index.js +2 -0
  26. package/dist/api/profiles-api/get-by-slug.d.ts +7 -0
  27. package/dist/api/profiles-api/get-by-slug.js +8 -0
  28. package/dist/api/profiles-api/index.d.ts +2 -0
  29. package/dist/api/profiles-api/index.js +2 -0
  30. package/dist/api/questrooms-api/get-by-coordinates.d.ts +7 -0
  31. package/dist/api/questrooms-api/get-by-coordinates.js +8 -0
  32. package/dist/api/questrooms-api/get-by-location.d.ts +7 -0
  33. package/dist/api/questrooms-api/get-by-location.js +8 -0
  34. package/dist/api/questrooms-api/get-by-slug.d.ts +7 -0
  35. package/dist/api/questrooms-api/get-by-slug.js +8 -0
  36. package/dist/api/questrooms-api/get-by-title.d.ts +7 -0
  37. package/dist/api/questrooms-api/get-by-title.js +8 -0
  38. package/dist/api/questrooms-api/index.d.ts +6 -0
  39. package/dist/api/questrooms-api/index.js +6 -0
  40. package/dist/hooks/use-api-method/index.d.ts +1 -1
  41. package/dist/hooks/use-api-method/index.js +11 -11
  42. package/dist/utils/get-service-error.js +2 -2
  43. package/dist/utils/is-network-error.js +1 -1
  44. package/dist/utils/serialize-record.d.ts +1 -2
  45. package/dist/utils/serialize-record.js +3 -1
  46. package/dist/utils/validate-by-dto.js +1 -1
  47. package/package.json +7 -5
@@ -0,0 +1,7 @@
1
+ import { CountriesEnum } from '@escapenavigator/types/dist/shared/enum/countries.enum';
2
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
3
+ import { ApiMethodDeclaration } from '..';
4
+ declare type ParamsData = CountriesEnum;
5
+ declare type ResponseData = CityResponseObject[];
6
+ export declare const getCitiesByCountry: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCitiesByCountry = void 0;
4
+ const getCitiesByCountry = (country) => ({
5
+ url: '/cities/country/' + country,
6
+ method: 'GET'
7
+ });
8
+ exports.getCitiesByCountry = getCitiesByCountry;
@@ -0,0 +1,6 @@
1
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ declare type ParamsData = string;
4
+ declare type ResponseData = CityResponseObject;
5
+ export declare const getCityByIp: ApiMethodDeclaration<ParamsData, ResponseData>;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCityByIp = void 0;
4
+ const getCityByIp = (ip) => ({
5
+ url: '/cities/current/' + ip,
6
+ method: 'GET'
7
+ });
8
+ exports.getCityByIp = getCityByIp;
@@ -0,0 +1,6 @@
1
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ declare type ParamsData = string;
4
+ declare type ResponseData = CityResponseObject;
5
+ export declare const getCityBySlug: ApiMethodDeclaration<ParamsData, ResponseData>;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCityBySlug = void 0;
4
+ const getCityBySlug = (slug) => ({
5
+ url: '/cities/slug/' + slug,
6
+ method: 'GET'
7
+ });
8
+ exports.getCityBySlug = getCityBySlug;
@@ -0,0 +1,6 @@
1
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ declare type ParamsData = number;
4
+ declare type ResponseData = CityResponseObject;
5
+ export declare const getOne: ApiMethodDeclaration<ParamsData, ResponseData>;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOne = void 0;
4
+ const getOne = (id) => ({
5
+ url: `/cities/${id}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getOne = getOne;
@@ -0,0 +1,6 @@
1
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ declare type ParamsData = string;
4
+ declare type ResponseData = CityResponseObject[];
5
+ export declare const getPopularCitiesNear: ApiMethodDeclaration<ParamsData, ResponseData>;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPopularCitiesNear = void 0;
4
+ const getPopularCitiesNear = (slug) => ({
5
+ url: '/cities/near/' + slug,
6
+ method: 'GET'
7
+ });
8
+ exports.getPopularCitiesNear = getPopularCitiesNear;
@@ -0,0 +1,18 @@
1
+ import { getCitiesByCountry } from './get-cities-by-country';
2
+ import { getCityBySlug } from './get-city-by-slug';
3
+ import { getCityByIp } from './get-city-by-ip';
4
+ import { getPopularCitiesNear } from './get-popular-cities-near';
5
+ import { getOne } from './get-one';
6
+ import { update } from './update';
7
+ import { remove } from './remove';
8
+ declare type ApiDeclaration = {
9
+ getCitiesByCountry: typeof getCitiesByCountry;
10
+ getCityBySlug: typeof getCityBySlug;
11
+ getCityByIp: typeof getCityByIp;
12
+ getPopularCitiesNear: typeof getPopularCitiesNear;
13
+ getOne: typeof getOne;
14
+ update: typeof update;
15
+ remove: typeof remove;
16
+ };
17
+ export declare const citiesApiDeclaration: ApiDeclaration;
18
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.citiesApiDeclaration = void 0;
4
+ const get_cities_by_country_1 = require("./get-cities-by-country");
5
+ const get_city_by_slug_1 = require("./get-city-by-slug");
6
+ const get_city_by_ip_1 = require("./get-city-by-ip");
7
+ const get_popular_cities_near_1 = require("./get-popular-cities-near");
8
+ const get_one_1 = require("./get-one");
9
+ const update_1 = require("./update");
10
+ const remove_1 = require("./remove");
11
+ exports.citiesApiDeclaration = {
12
+ getCitiesByCountry: get_cities_by_country_1.getCitiesByCountry,
13
+ getCityBySlug: get_city_by_slug_1.getCityBySlug,
14
+ getCityByIp: get_city_by_ip_1.getCityByIp,
15
+ getPopularCitiesNear: get_popular_cities_near_1.getPopularCitiesNear,
16
+ getOne: get_one_1.getOne,
17
+ update: update_1.update,
18
+ remove: remove_1.remove,
19
+ };
@@ -0,0 +1,7 @@
1
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
2
+ import { QueryDto } from '@escapenavigator/types/dist/shared/query.dto';
3
+ import { ApiMethodDeclaration } from '..';
4
+ declare type ParamsData = QueryDto;
5
+ declare type ResponseData = CityResponseObject[];
6
+ export declare const query: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.query = void 0;
4
+ const query = (params) => ({
5
+ url: '/cities',
6
+ method: 'GET',
7
+ params
8
+ });
9
+ exports.query = query;
@@ -0,0 +1,7 @@
1
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ /** ID city */
4
+ declare type ParamsData = number;
5
+ declare type ResponseData = CityResponseObject;
6
+ export declare const remove: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remove = void 0;
4
+ const remove = (id) => ({
5
+ url: `/cities/${id}`,
6
+ method: 'DELETE',
7
+ });
8
+ exports.remove = remove;
@@ -0,0 +1,10 @@
1
+ import { UpdateCityDto } from '@escapenavigator/types/dist/city/update-city.dto';
2
+ import { CityResponseObject } from '@escapenavigator/types/dist/city/city.ro';
3
+ import { ApiMethodDeclaration } from '..';
4
+ declare type ParamsData = {
5
+ id: number;
6
+ data: UpdateCityDto;
7
+ };
8
+ declare type ResponseData = CityResponseObject;
9
+ export declare const update: ApiMethodDeclaration<ParamsData, ResponseData>;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.update = void 0;
4
+ const update = ({ id, data }) => ({
5
+ url: `/cities/${id}`,
6
+ method: 'PATCH',
7
+ data,
8
+ });
9
+ exports.update = update;
package/dist/api/index.js CHANGED
@@ -26,7 +26,7 @@ function initApi(apiDeclaration, baseURL) {
26
26
  axiosConfig = Object.assign(Object.assign({}, axiosConfig), { baseURL, withCredentials: true });
27
27
  // console.log({ axiosConfig });
28
28
  try {
29
- const result = yield axios_1.default(axiosConfig);
29
+ const result = yield (0, axios_1.default)(axiosConfig);
30
30
  return result;
31
31
  }
32
32
  catch (error) {
@@ -27,8 +27,10 @@ import { upsellingsApiDeclaration } from './upsellings-api';
27
27
  import { userMessagesApiDeclaration } from './user-messages-api';
28
28
  import { usersApiDeclaration } from './users-api';
29
29
  import { widgetsApiDeclaration } from './widgets-api';
30
+ import { citiesApiDeclaration } from './cities-api';
30
31
  import { Api } from '.';
31
- declare type InitApiDeclaration = {
32
+ export declare type InitApiDeclaration = {
33
+ cities: Api<typeof citiesApiDeclaration>;
32
34
  admins: Api<typeof adminsApiDeclaration>;
33
35
  uploads: Api<typeof uploadsApiDeclaration>;
34
36
  emails: Api<typeof emailsApiDeclaration>;
@@ -59,5 +61,4 @@ declare type InitApiDeclaration = {
59
61
  support: Api<typeof supportApiDeclaration>;
60
62
  registrationRequests: Api<typeof registrationRequestsApiDeclaration>;
61
63
  };
62
- export declare const initClientApi: (baseURL?: string) => InitApiDeclaration;
63
- export {};
64
+ export declare const initClientApi: (url: string) => InitApiDeclaration;
@@ -30,42 +30,40 @@ const upsellings_api_1 = require("./upsellings-api");
30
30
  const user_messages_api_1 = require("./user-messages-api");
31
31
  const users_api_1 = require("./users-api");
32
32
  const widgets_api_1 = require("./widgets-api");
33
+ const cities_api_1 = require("./cities-api");
33
34
  const _1 = require(".");
34
- const initClientApi = (baseURL) => {
35
- const url = baseURL
36
- || (process === null || process === void 0 ? void 0 : process.env.REACT_APP_API_URL)
37
- || (process === null || process === void 0 ? void 0 : process.env.NEXT_PUBLIC_API_URL)
38
- || 'http://localhost:9999';
35
+ const initClientApi = (url) => {
39
36
  return {
40
- agbs: _1.initApi(agb_api_1.agbApiDeclaration, url),
41
- uploads: _1.initApi(uploads_api_1.uploadsApiDeclaration, url),
42
- emails: _1.initApi(emails_api_1.emailsApiDeclaration, url),
43
- admins: _1.initApi(admins_api_1.adminsApiDeclaration, url),
44
- userMessages: _1.initApi(user_messages_api_1.userMessagesApiDeclaration, url),
45
- orderDiscounts: _1.initApi(order_discounts_api_1.orderDiscountsApiDeclaration, url),
46
- orderPenalties: _1.initApi(order_penalties_api_1.orderPenaltiesApiDeclaration, url),
47
- orderUpsellngs: _1.initApi(order_upsellings_api_1.orderUpsellngsApiDeclaration, url),
48
- slots: _1.initApi(slots_api_1.slotsApiDeclaration, url),
49
- slotTemplates: _1.initApi(slot_templates_api_1.slotTemplatesApiDeclaration, url),
50
- orders: _1.initApi(orders_api_1.ordersApiDeclaration, url),
51
- cashboxes: _1.initApi(cashboxes_api_1.cashboxesApiDeclaration, url),
52
- certificates: _1.initApi(certificates_api_1.certificatesApiDeclaration, url),
53
- financeItems: _1.initApi(financeitems_api_1.financeItemsApiDeclaration, url),
54
- locations: _1.initApi(locations_api_1.locationsApiDeclaration, url),
55
- upsellings: _1.initApi(upsellings_api_1.upsellingsApiDeclaration, url),
56
- partners: _1.initApi(partners_api_1.partnersApiDeclaration, url),
57
- questrooms: _1.initApi(questrooms_api_1.questroomsApiDeclaration, url),
58
- widgets: _1.initApi(widgets_api_1.widgetsApiDeclaration, url),
59
- profiles: _1.initApi(profiles_api_1.profilesApiDeclaration, url),
60
- users: _1.initApi(users_api_1.usersApiDeclaration, url),
61
- clients: _1.initApi(clients_api_1.clientsApiDeclaration, url),
62
- transactions: _1.initApi(transactions_api_1.transactionsApiDeclaration, url),
63
- images: _1.initApi(images_api_1.imagesApiDeclaration, url),
64
- roles: _1.initApi(roles_api_1.rolesApiDeclaration, url),
65
- tariffs: _1.initApi(tariffs_api_1.tariffsApiDeclaration, url),
66
- certificatesales: _1.initApi(certificatesales_api_1.certificateSalesApiDeclaration, url),
67
- support: _1.initApi(support_1.supportApiDeclaration, url),
68
- registrationRequests: _1.initApi(registration_requests_api_1.registrationRequestsApiDeclaration, url),
37
+ cities: (0, _1.initApi)(cities_api_1.citiesApiDeclaration, url),
38
+ agbs: (0, _1.initApi)(agb_api_1.agbApiDeclaration, url),
39
+ uploads: (0, _1.initApi)(uploads_api_1.uploadsApiDeclaration, url),
40
+ emails: (0, _1.initApi)(emails_api_1.emailsApiDeclaration, url),
41
+ admins: (0, _1.initApi)(admins_api_1.adminsApiDeclaration, url),
42
+ userMessages: (0, _1.initApi)(user_messages_api_1.userMessagesApiDeclaration, url),
43
+ orderDiscounts: (0, _1.initApi)(order_discounts_api_1.orderDiscountsApiDeclaration, url),
44
+ orderPenalties: (0, _1.initApi)(order_penalties_api_1.orderPenaltiesApiDeclaration, url),
45
+ orderUpsellngs: (0, _1.initApi)(order_upsellings_api_1.orderUpsellngsApiDeclaration, url),
46
+ slots: (0, _1.initApi)(slots_api_1.slotsApiDeclaration, url),
47
+ slotTemplates: (0, _1.initApi)(slot_templates_api_1.slotTemplatesApiDeclaration, url),
48
+ orders: (0, _1.initApi)(orders_api_1.ordersApiDeclaration, url),
49
+ cashboxes: (0, _1.initApi)(cashboxes_api_1.cashboxesApiDeclaration, url),
50
+ certificates: (0, _1.initApi)(certificates_api_1.certificatesApiDeclaration, url),
51
+ financeItems: (0, _1.initApi)(financeitems_api_1.financeItemsApiDeclaration, url),
52
+ locations: (0, _1.initApi)(locations_api_1.locationsApiDeclaration, url),
53
+ upsellings: (0, _1.initApi)(upsellings_api_1.upsellingsApiDeclaration, url),
54
+ partners: (0, _1.initApi)(partners_api_1.partnersApiDeclaration, url),
55
+ questrooms: (0, _1.initApi)(questrooms_api_1.questroomsApiDeclaration, url),
56
+ widgets: (0, _1.initApi)(widgets_api_1.widgetsApiDeclaration, url),
57
+ profiles: (0, _1.initApi)(profiles_api_1.profilesApiDeclaration, url),
58
+ users: (0, _1.initApi)(users_api_1.usersApiDeclaration, url),
59
+ clients: (0, _1.initApi)(clients_api_1.clientsApiDeclaration, url),
60
+ transactions: (0, _1.initApi)(transactions_api_1.transactionsApiDeclaration, url),
61
+ images: (0, _1.initApi)(images_api_1.imagesApiDeclaration, url),
62
+ roles: (0, _1.initApi)(roles_api_1.rolesApiDeclaration, url),
63
+ tariffs: (0, _1.initApi)(tariffs_api_1.tariffsApiDeclaration, url),
64
+ certificatesales: (0, _1.initApi)(certificatesales_api_1.certificateSalesApiDeclaration, url),
65
+ support: (0, _1.initApi)(support_1.supportApiDeclaration, url),
66
+ registrationRequests: (0, _1.initApi)(registration_requests_api_1.registrationRequestsApiDeclaration, url),
69
67
  };
70
68
  };
71
69
  exports.initClientApi = initClientApi;
@@ -0,0 +1,7 @@
1
+ import { GetNearestLocationDto } from '@escapenavigator/types/dist/location/get-nearest-location.dto';
2
+ import { NearestLocationResponseObject } from '@escapenavigator/types/dist/location/nearest-location.ro';
3
+ import { ApiMethodDeclaration } from '..';
4
+ declare type ParamsData = GetNearestLocationDto;
5
+ declare type ResponseData = NearestLocationResponseObject[];
6
+ export declare const getByCoordinates: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getByCoordinates = void 0;
4
+ const getByCoordinates = (id) => ({
5
+ url: `/locations/near/${id}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getByCoordinates = getByCoordinates;
@@ -4,6 +4,7 @@ import { query } from './query';
4
4
  import { recover } from './recover';
5
5
  import { remove } from './remove';
6
6
  import { update } from './update';
7
+ import { getByCoordinates } from './get-by-coordinates';
7
8
  declare type ApiDeclaration = {
8
9
  create: typeof create;
9
10
  remove: typeof remove;
@@ -11,6 +12,7 @@ declare type ApiDeclaration = {
11
12
  getOne: typeof getOne;
12
13
  recover: typeof recover;
13
14
  query: typeof query;
15
+ getByCoordinates: typeof getByCoordinates;
14
16
  };
15
17
  export declare const locationsApiDeclaration: ApiDeclaration;
16
18
  export {};
@@ -7,6 +7,7 @@ const query_1 = require("./query");
7
7
  const recover_1 = require("./recover");
8
8
  const remove_1 = require("./remove");
9
9
  const update_1 = require("./update");
10
+ const get_by_coordinates_1 = require("./get-by-coordinates");
10
11
  exports.locationsApiDeclaration = {
11
12
  create: create_1.create,
12
13
  remove: remove_1.remove,
@@ -14,4 +15,5 @@ exports.locationsApiDeclaration = {
14
15
  query: query_1.query,
15
16
  recover: recover_1.recover,
16
17
  getOne: get_one_1.getOne,
18
+ getByCoordinates: get_by_coordinates_1.getByCoordinates,
17
19
  };
@@ -0,0 +1,7 @@
1
+ import { AgregatorProfileResponseObject } from '@escapenavigator/types/dist/profile/agregator-profile.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ /** slug */
4
+ declare type ParamsData = string;
5
+ declare type ResponseData = AgregatorProfileResponseObject;
6
+ export declare const getBySlug: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBySlug = void 0;
4
+ const getBySlug = (slug) => ({
5
+ url: `/profiles/slug/${slug}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getBySlug = getBySlug;
@@ -4,6 +4,7 @@ import { getOne } from './get-one';
4
4
  import { query } from './query';
5
5
  import { remove } from './remove';
6
6
  import { update } from './update';
7
+ import { getBySlug } from './get-by-slug';
7
8
  declare type ApiDeclaration = {
8
9
  create: typeof create;
9
10
  remove: typeof remove;
@@ -11,6 +12,7 @@ declare type ApiDeclaration = {
11
12
  query: typeof query;
12
13
  getOne: typeof getOne;
13
14
  current: typeof current;
15
+ getBySlug: typeof getBySlug;
14
16
  };
15
17
  export declare const profilesApiDeclaration: ApiDeclaration;
16
18
  export {};
@@ -7,6 +7,7 @@ const get_one_1 = require("./get-one");
7
7
  const query_1 = require("./query");
8
8
  const remove_1 = require("./remove");
9
9
  const update_1 = require("./update");
10
+ const get_by_slug_1 = require("./get-by-slug");
10
11
  exports.profilesApiDeclaration = {
11
12
  create: create_1.create,
12
13
  remove: remove_1.remove,
@@ -14,4 +15,5 @@ exports.profilesApiDeclaration = {
14
15
  query: query_1.query,
15
16
  getOne: get_one_1.getOne,
16
17
  current: current_1.current,
18
+ getBySlug: get_by_slug_1.getBySlug
17
19
  };
@@ -0,0 +1,7 @@
1
+ import { AgregatorQuestroomResponseObject } from '@escapenavigator/types/dist/questroom/agregator-questroom.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ /** coordinates */
4
+ declare type ParamsData = string;
5
+ declare type ResponseData = AgregatorQuestroomResponseObject[];
6
+ export declare const getByCoordinates: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getByCoordinates = void 0;
4
+ const getByCoordinates = (coordinates) => ({
5
+ url: `/questrooms/near/${coordinates}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getByCoordinates = getByCoordinates;
@@ -0,0 +1,7 @@
1
+ import { AgregatorQuestroomResponseObject } from '@escapenavigator/types/dist/questroom/agregator-questroom.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ /** ID локации */
4
+ declare type ParamsData = number;
5
+ declare type ResponseData = AgregatorQuestroomResponseObject[];
6
+ export declare const getByLocation: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getByLocation = void 0;
4
+ const getByLocation = (id) => ({
5
+ url: `/questrooms/location/${id}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getByLocation = getByLocation;
@@ -0,0 +1,7 @@
1
+ import { AgregatorQuestroomResponseObject } from '@escapenavigator/types/dist/questroom/agregator-questroom.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ /** slug */
4
+ declare type ParamsData = string;
5
+ declare type ResponseData = AgregatorQuestroomResponseObject;
6
+ export declare const getBySlug: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBySlug = void 0;
4
+ const getBySlug = (slug) => ({
5
+ url: `/questrooms/slug/${slug}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getBySlug = getBySlug;
@@ -0,0 +1,7 @@
1
+ import { AgregatorQuestroomResponseObject } from '@escapenavigator/types/dist/questroom/agregator-questroom.ro';
2
+ import { ApiMethodDeclaration } from '..';
3
+ /** Название */
4
+ declare type ParamsData = string;
5
+ declare type ResponseData = AgregatorQuestroomResponseObject[];
6
+ export declare const getByTitle: ApiMethodDeclaration<ParamsData, ResponseData>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getByTitle = void 0;
4
+ const getByTitle = (title) => ({
5
+ url: `/questrooms/title/${title}`,
6
+ method: 'GET',
7
+ });
8
+ exports.getByTitle = getByTitle;
@@ -4,6 +4,9 @@ import { query } from './query';
4
4
  import { recover } from './recover';
5
5
  import { remove } from './remove';
6
6
  import { update } from './update';
7
+ import { getByLocation } from './get-by-location';
8
+ import { getByCoordinates } from './get-by-coordinates';
9
+ import { getBySlug } from './get-by-slug';
7
10
  declare type ApiDeclaration = {
8
11
  create: typeof create;
9
12
  remove: typeof remove;
@@ -11,6 +14,9 @@ declare type ApiDeclaration = {
11
14
  query: typeof query;
12
15
  getOne: typeof getOne;
13
16
  recover: typeof recover;
17
+ getByLocation: typeof getByLocation;
18
+ getByCoordinates: typeof getByCoordinates;
19
+ getBySlug: typeof getBySlug;
14
20
  };
15
21
  export declare const questroomsApiDeclaration: ApiDeclaration;
16
22
  export {};
@@ -7,6 +7,9 @@ const query_1 = require("./query");
7
7
  const recover_1 = require("./recover");
8
8
  const remove_1 = require("./remove");
9
9
  const update_1 = require("./update");
10
+ const get_by_location_1 = require("./get-by-location");
11
+ const get_by_coordinates_1 = require("./get-by-coordinates");
12
+ const get_by_slug_1 = require("./get-by-slug");
10
13
  exports.questroomsApiDeclaration = {
11
14
  create: create_1.create,
12
15
  remove: remove_1.remove,
@@ -14,4 +17,7 @@ exports.questroomsApiDeclaration = {
14
17
  query: query_1.query,
15
18
  getOne: get_one_1.getOne,
16
19
  recover: recover_1.recover,
20
+ getByLocation: get_by_location_1.getByLocation,
21
+ getByCoordinates: get_by_coordinates_1.getByCoordinates,
22
+ getBySlug: get_by_slug_1.getBySlug
17
23
  };
@@ -17,7 +17,7 @@ declare type Result<P, T, R, DisplayName extends string> = {
17
17
  declare type Props<P, T, R, DisplayName extends string> = {
18
18
  api: ApiMethod<P, T, R, DisplayName>;
19
19
  successCallback?: (data: AxiosResponse<R>) => void;
20
- errorCallback?: (error: any) => void;
20
+ errorCallback?: (error: ServiceError) => void;
21
21
  delay?: number;
22
22
  };
23
23
  export declare const useApiMethod: <P, T, R, DisplayName extends string>({ api, successCallback, errorCallback, delay, }: Props<P, T, R, DisplayName>) => Result<P, T, R, DisplayName>;
@@ -19,34 +19,34 @@ const get_service_error_1 = require("../../utils/get-service-error");
19
19
  const api_1 = require("./actions/creators/api");
20
20
  const api_2 = require("./reducers/api");
21
21
  const useApiMethod = ({ api, successCallback, errorCallback, delay, }) => {
22
- const mounted = react_1.useRef(false);
23
- const source = react_1.useRef(null);
24
- const [state, dispatch] = react_1.useReducer(api_2.apiReducer, api_2.initialState);
25
- const fetch = react_1.useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const mounted = (0, react_1.useRef)(false);
23
+ const source = (0, react_1.useRef)(null);
24
+ const [state, dispatch] = (0, react_1.useReducer)(api_2.apiReducer, api_2.initialState);
25
+ const fetch = (0, react_1.useCallback)((params) => __awaiter(void 0, void 0, void 0, function* () {
26
26
  source.current = axios_1.default.CancelToken.source();
27
27
  const startTime = Date.now();
28
28
  try {
29
- dispatch(api_1.fetchStart());
29
+ dispatch((0, api_1.fetchStart)());
30
30
  const response = yield api(params);
31
31
  const deltaTime = Date.now() - startTime;
32
32
  const delta = delay && deltaTime < delay ? 500 - deltaTime : 0;
33
33
  setTimeout(() => {
34
34
  if (successCallback)
35
35
  successCallback(response);
36
- dispatch(api_1.fetchSuccess(response));
36
+ dispatch((0, api_1.fetchSuccess)(response));
37
37
  }, delta);
38
38
  }
39
39
  catch (error) {
40
- if (errorCallback)
41
- errorCallback(error);
42
40
  if (!mounted.current)
43
41
  return;
44
- const err = get_service_error_1.getServiceError(error);
45
- dispatch(api_1.fetchFailure(err));
42
+ const err = (0, get_service_error_1.getServiceError)(error);
43
+ if (errorCallback)
44
+ errorCallback(err);
45
+ dispatch((0, api_1.fetchFailure)(err));
46
46
  throw error;
47
47
  }
48
48
  }), [api, successCallback, errorCallback, delay]);
49
- react_1.useEffect(() => {
49
+ (0, react_1.useEffect)(() => {
50
50
  mounted.current = true;
51
51
  return () => {
52
52
  var _a;
@@ -29,7 +29,7 @@ const INTERNAL_SERVICE_ERROR_CODES = [
29
29
  * @param error Ошибка от сервиса
30
30
  */
31
31
  function getServiceError(error) {
32
- if (is_network_error_1.isNetworkError(error)) {
32
+ if ((0, is_network_error_1.isNetworkError)(error)) {
33
33
  return {
34
34
  code: ERROR_CODES[ErrorType.NETWORK],
35
35
  message: ERROR_MESSAGES[ErrorType.NETWORK],
@@ -37,7 +37,7 @@ function getServiceError(error) {
37
37
  originalError: error,
38
38
  };
39
39
  }
40
- if (is_axios_error_1.isAxiosError(error)) {
40
+ if ((0, is_axios_error_1.isAxiosError)(error)) {
41
41
  const { errorCode, originalErrorCode, message } = error.response.data;
42
42
  let code = errorCode;
43
43
  let errorType = ErrorType.BUSINESS;
@@ -8,7 +8,7 @@ const NETWORK_ERROR_CODES = ['ENETUNREACH', 'ECONNABORTED', 'ENOTCONN'];
8
8
  * @param error Ошибка от сервиса
9
9
  */
10
10
  function isNetworkError(error) {
11
- if (is_axios_error_1.isAxiosError(error)) {
11
+ if ((0, is_axios_error_1.isAxiosError)(error)) {
12
12
  const { response, code, message } = error;
13
13
  return (typeof response === 'undefined' &&
14
14
  (NETWORK_ERROR_CODES.includes(code) || message === 'Network Error'));
@@ -1,2 +1 @@
1
- import { ClassConstructor } from 'class-transformer';
2
- export declare const serializeRecord: <T extends ClassConstructor<unknown>>(Dto: T, data: any) => T;
1
+ export declare const serializeRecord: <T, D>(Dto: T, data: D) => T;
@@ -2,5 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializeRecord = void 0;
4
4
  const class_transformer_1 = require("class-transformer");
5
- const serializeRecord = (Dto, data) => class_transformer_1.plainToClass(Dto, data, { strategy: 'excludeAll' });
5
+ // export const serializeRecord = <T extends ClassConstructor<unknown>>(Dto: T, data): T =>
6
+ // plainToClass(Dto, data, { strategy: 'excludeAll' }) as unknown as T;
7
+ const serializeRecord = (Dto, data) => (0, class_transformer_1.plainToClass)(Dto, data, { strategy: 'excludeAll' });
6
8
  exports.serializeRecord = serializeRecord;
@@ -4,7 +4,7 @@ exports.validateByDto = void 0;
4
4
  const class_validator_1 = require("class-validator");
5
5
  function validateByDto(t) {
6
6
  const validate = (data) => {
7
- const errors = class_validator_1.validateSync(typeof data === 'object' ? data : {});
7
+ const errors = (0, class_validator_1.validateSync)(typeof data === 'object' ? data : {});
8
8
  return Object.fromEntries(errors.map(({ property, constraints }) => {
9
9
  const err = (constraints === null || constraints === void 0 ? void 0 : constraints.IsNotEmpty) || Object.values(constraints)[0];
10
10
  const errorText = err.substr(err.indexOf(' ') + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/services",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,12 +12,13 @@
12
12
  "scripts": {
13
13
  "build": "rm -rf dist && tsc --project tsconfig.build.json"
14
14
  },
15
- "gitHead": "e7057a7b3d2b1c032cfd9cf7ab94363110f6e8a3",
15
+ "gitHead": "43ba790bdf5d3c603dbd5330963d0ad3946d98d8",
16
16
  "dependencies": {
17
- "@escapenavigator/types": "^1.1.3",
17
+ "@escapenavigator/types": "^1.2.0",
18
18
  "axios": "^0.21.4",
19
- "class-transformer": "^0.4.0",
19
+ "class-transformer": "^0.5.1",
20
20
  "class-validator": "^0.13.1",
21
+ "i18next": "^21.6.4",
21
22
  "react": "^17.0.2",
22
23
  "react-dom": "^17.0.2"
23
24
  },
@@ -34,7 +35,8 @@
34
35
  "rollup-plugin-node-resolve": "^5.2.0",
35
36
  "rollup-plugin-peer-deps-external": "^2.2.4",
36
37
  "rollup-plugin-terser": "^7.0.2",
37
- "ts-loader": "^6.2.1"
38
+ "ts-loader": "^6.2.1",
39
+ "typescript": "^4.5.4"
38
40
  },
39
41
  "perDependencies": {
40
42
  "react": "17.0.2",