@zauru-sdk/services 1.0.4 → 1.0.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.5](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.4...v1.0.5) (2024-03-16)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/services
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.0.4](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.3...v1.0.4) (2024-03-15)
7
15
 
8
16
  **Note:** Version bump only for package @zauru-sdk/services
@@ -1,8 +1,7 @@
1
1
  import { Session } from "@remix-run/node";
2
2
  import { AxiosRequestHeaders } from "axios";
3
3
  import { AxiosUtilsResponse } from "./zauru/httpZauru.server.js";
4
- import { Agency, OauthProfile, ProfileResponse } from "./zauru/zauru-profiles.server.js";
5
- import { EmployeeGraphQL } from "@zauru-sdk/graphql";
4
+ import { EmployeeGraphQL, OauthProfile, ProfileResponse, AgencyGraphQL } from "@zauru-sdk/types";
6
5
  /**
7
6
  * loginWebApp
8
7
  * @param session
@@ -15,7 +14,7 @@ export declare const loginWebApp: (session: Session, codeValue: string, cookie:
15
14
  oauthProfile: OauthProfile;
16
15
  employeeProfile: EmployeeGraphQL;
17
16
  userProfile: ProfileResponse;
18
- agencyProfile: Agency;
17
+ agencyProfile: AgencyGraphQL;
19
18
  }>>;
20
19
  export type GraphQLToken = {
21
20
  status: number;
@@ -1,6 +1,6 @@
1
1
  import type { Session } from "@remix-run/node";
2
- import type { AgencyGraphQL } from "@zauru-sdk/graphql";
3
2
  import type { AxiosUtilsResponse } from "./httpZauru.server.js";
3
+ import type { AgencyGraphQL } from "@zauru-sdk/types";
4
4
  /**
5
5
  * getAgencies
6
6
  * @param headers
@@ -1,8 +1,7 @@
1
1
  import { handlePossibleAxiosErrors } from "./httpZauru.server.js";
2
2
  import httpGraphQLAPI from "./httpGraphQL.server.js";
3
3
  import { getGraphQLAPIHeaders } from "~/common.server.js";
4
- import graphql from "@zauru-sdk/graphql";
5
- const { default: queries } = graphql;
4
+ import { getAgenciesStringQuery } from "@zauru-sdk/graphql";
6
5
  /**
7
6
  * getAgencies
8
7
  * @param headers
@@ -12,7 +11,7 @@ export async function getAgencies(session) {
12
11
  return handlePossibleAxiosErrors(async () => {
13
12
  const headers = await getGraphQLAPIHeaders(session);
14
13
  const response = await httpGraphQLAPI.post(``, {
15
- query: queries.getAgencies,
14
+ query: getAgenciesStringQuery,
16
15
  }, {
17
16
  headers,
18
17
  });
@@ -1,143 +1,6 @@
1
1
  import type { Session } from "@remix-run/node";
2
2
  import type { AxiosUtilsResponse } from "./httpZauru.server.js";
3
- import { EmployeeGraphQL } from "@zauru-sdk/graphql";
4
- interface Logo {
5
- url: null | string;
6
- thumb: {
7
- url: null | string;
8
- };
9
- standard: {
10
- url: null | string;
11
- };
12
- header: {
13
- url: null | string;
14
- };
15
- }
16
- export type OauthProfile = {
17
- id: number;
18
- uid: number;
19
- username: string;
20
- name: string;
21
- time_zone: string;
22
- mobile_phone: string;
23
- admin: boolean;
24
- selected_entity: number;
25
- selected_entity_name: string;
26
- selected_entity_logo: string;
27
- selected_entity_role: number;
28
- employee_id: number;
29
- crm_admin: boolean;
30
- crm_supervisor: boolean;
31
- crm_user: boolean;
32
- currency_id: number;
33
- currency_name: string;
34
- currency_prefix: string;
35
- api_key: string;
36
- scope: string;
37
- email: string;
38
- };
39
- interface Entity {
40
- id: number;
41
- name: string;
42
- tin: string;
43
- country: string;
44
- currency_id: number;
45
- entity_type_id: number;
46
- industry: string;
47
- web: string;
48
- notes: string;
49
- vat: number;
50
- vat_included: boolean;
51
- logo: Logo;
52
- logo_2: Logo;
53
- created_at: string;
54
- updated_at: string;
55
- distributor: number;
56
- costing_method: string;
57
- address: string;
58
- state: string;
59
- city: string;
60
- income_tax: number;
61
- report_logo: Logo;
62
- distributor_contract_id: number | null;
63
- producer_contract_id: number | null;
64
- legal_representative_name: string | null;
65
- legal_representative_identification: string | null;
66
- legal_representative_birthday: string | null;
67
- legal_representative_gender: boolean;
68
- legal_representative_marital_status: string | null;
69
- legal_representative_occupation: string | null;
70
- legal_representative_nationality: string | null;
71
- exporter_code: string | null;
72
- }
73
- export type Agency = {
74
- id: number;
75
- zid: number;
76
- active: boolean;
77
- ean13: string;
78
- name: string;
79
- employee_id: number | null;
80
- updater_id: number;
81
- entity_id: number;
82
- virtual: boolean;
83
- virtual_type: string | null;
84
- warehouse: boolean;
85
- point_of_sale: boolean;
86
- workshop: boolean;
87
- factory: boolean;
88
- contact: string;
89
- city: string;
90
- address_line_1: string;
91
- address_line_2: string;
92
- phone: string;
93
- notes: string;
94
- created_at: string;
95
- updated_at: string;
96
- price_list_id: number | null;
97
- quote: boolean;
98
- ecommerce: boolean;
99
- external_storage_service_name: string;
100
- agency_category_id: number | null;
101
- };
102
- export type Membership = {
103
- id: number;
104
- active: boolean;
105
- current: boolean;
106
- reference: string;
107
- starts: string;
108
- expires: string;
109
- eternal: boolean;
110
- entity_id: number;
111
- notes: string;
112
- created_at: string;
113
- updated_at: string;
114
- licenses_count: number;
115
- entity: Entity;
116
- };
117
- type Profile = {
118
- id: number;
119
- email: string;
120
- active: boolean;
121
- admin: boolean;
122
- name: string;
123
- address: null | string;
124
- mobile_phone: string;
125
- birthday: null | string;
126
- gender: boolean;
127
- notes: null | string;
128
- time_zone: string;
129
- language: string;
130
- selected_entity_id: number;
131
- created_at: string;
132
- updated_at: string;
133
- authentication_token: string;
134
- provider: string;
135
- provider_token: string;
136
- };
137
- export type ProfileResponse = {
138
- profile: Profile;
139
- memberships: Membership[];
140
- };
3
+ import { AgencyGraphQL, EmployeeGraphQL, OauthProfile, ProfileResponse } from "@zauru-sdk/types";
141
4
  /**
142
5
  * getOauthUserInfo
143
6
  * @param codeValue
@@ -163,5 +26,4 @@ export declare const changeEntity: (headers: any, entityId: string) => Promise<a
163
26
  * @param headers
164
27
  * @returns
165
28
  */
166
- export declare const getAgencyInfo: (headers: any, session: Session) => Promise<AxiosUtilsResponse<Agency>>;
167
- export {};
29
+ export declare const getAgencyInfo: (headers: any, session: Session) => Promise<AxiosUtilsResponse<AgencyGraphQL>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Configuración centralizada para aplicaciones Zauru SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,12 +20,13 @@
20
20
  "dependencies": {
21
21
  "@remix-run/node": "^2.8.1",
22
22
  "@zauru-sdk/config": "^1.0.4",
23
- "@zauru-sdk/graphql": "^1.0.4",
23
+ "@zauru-sdk/graphql": "^1.0.5",
24
+ "@zauru-sdk/types": "^1.0.5",
24
25
  "axios": "^1.6.7",
25
26
  "chalk": "5.3.0"
26
27
  },
27
28
  "engines": {
28
29
  "node": ">=18.0.0"
29
30
  },
30
- "gitHead": "75cef0c437edf8240adc811bc7b395e1030adf90"
31
+ "gitHead": "0802e24e0ee8234741e4b50c68067dd025acde49"
31
32
  }
@@ -7,15 +7,17 @@ import httpZauru, {
7
7
  handlePossibleAxiosErrors,
8
8
  } from "./zauru/httpZauru.server.js";
9
9
  import {
10
- Agency,
11
- OauthProfile,
12
- ProfileResponse,
13
10
  getAgencyInfo,
14
11
  getEmployeeInfo,
15
12
  getOauthUserInfo,
16
13
  getProfileInformation,
17
14
  } from "./zauru/zauru-profiles.server.js";
18
- import { EmployeeGraphQL } from "@zauru-sdk/graphql";
15
+ import {
16
+ EmployeeGraphQL,
17
+ OauthProfile,
18
+ ProfileResponse,
19
+ AgencyGraphQL,
20
+ } from "@zauru-sdk/types";
19
21
 
20
22
  /**
21
23
  * loginWebApp
@@ -34,7 +36,7 @@ export const loginWebApp = async (
34
36
  oauthProfile: OauthProfile;
35
37
  employeeProfile: EmployeeGraphQL;
36
38
  userProfile: ProfileResponse;
37
- agencyProfile: Agency;
39
+ agencyProfile: AgencyGraphQL;
38
40
  }>
39
41
  > => {
40
42
  return handlePossibleAxiosErrors(async () => {
@@ -100,7 +102,7 @@ export const loginWebApp = async (
100
102
  oauthProfile: userInfo as OauthProfile,
101
103
  employeeProfile: empInfo as EmployeeGraphQL,
102
104
  userProfile: profileInfo as ProfileResponse,
103
- agencyProfile: agencyInfoResponse.data as Agency,
105
+ agencyProfile: agencyInfoResponse.data as AgencyGraphQL,
104
106
  };
105
107
  });
106
108
  };
@@ -1,12 +1,10 @@
1
1
  import type { Session } from "@remix-run/node";
2
- import type { AgencyGraphQL } from "@zauru-sdk/graphql";
3
2
  import type { AxiosUtilsResponse } from "./httpZauru.server.js";
4
3
  import { handlePossibleAxiosErrors } from "./httpZauru.server.js";
5
4
  import httpGraphQLAPI from "./httpGraphQL.server.js";
6
5
  import { getGraphQLAPIHeaders } from "~/common.server.js";
7
- import graphql from "@zauru-sdk/graphql";
8
-
9
- const { default: queries } = graphql;
6
+ import { getAgenciesStringQuery } from "@zauru-sdk/graphql";
7
+ import type { AgencyGraphQL } from "@zauru-sdk/types";
10
8
 
11
9
  /**
12
10
  * getAgencies
@@ -23,7 +21,7 @@ export async function getAgencies(
23
21
  }>(
24
22
  ``,
25
23
  {
26
- query: queries.getAgencies,
24
+ query: getAgenciesStringQuery,
27
25
  },
28
26
  {
29
27
  headers,
@@ -2,152 +2,14 @@ import type { Session } from "@remix-run/node";
2
2
  import type { AxiosUtilsResponse } from "./httpZauru.server.js";
3
3
  import httpZauru, { handlePossibleAxiosErrors } from "./httpZauru.server.js";
4
4
  import httpOauth from "./httpOauth.server.js";
5
- import { EmployeeGraphQL } from "@zauru-sdk/graphql";
5
+ import {
6
+ AgencyGraphQL,
7
+ EmployeeGraphQL,
8
+ OauthProfile,
9
+ ProfileResponse,
10
+ } from "@zauru-sdk/types";
6
11
  import { config } from "@zauru-sdk/config";
7
12
 
8
- interface Logo {
9
- url: null | string;
10
- thumb: {
11
- url: null | string;
12
- };
13
- standard: {
14
- url: null | string;
15
- };
16
- header: {
17
- url: null | string;
18
- };
19
- }
20
-
21
- export type OauthProfile = {
22
- id: number;
23
- uid: number;
24
- username: string;
25
- name: string;
26
- time_zone: string;
27
- mobile_phone: string;
28
- admin: boolean;
29
- selected_entity: number;
30
- selected_entity_name: string;
31
- selected_entity_logo: string;
32
- selected_entity_role: number;
33
- employee_id: number;
34
- crm_admin: boolean;
35
- crm_supervisor: boolean;
36
- crm_user: boolean;
37
- currency_id: number;
38
- currency_name: string;
39
- currency_prefix: string;
40
- api_key: string;
41
- scope: string;
42
- email: string;
43
- };
44
- interface Entity {
45
- id: number;
46
- name: string;
47
- tin: string;
48
- country: string;
49
- currency_id: number;
50
- entity_type_id: number;
51
- industry: string;
52
- web: string;
53
- notes: string;
54
- vat: number;
55
- vat_included: boolean;
56
- logo: Logo;
57
- logo_2: Logo;
58
- created_at: string;
59
- updated_at: string;
60
- distributor: number;
61
- costing_method: string;
62
- address: string;
63
- state: string;
64
- city: string;
65
- income_tax: number;
66
- report_logo: Logo;
67
- distributor_contract_id: number | null;
68
- producer_contract_id: number | null;
69
- legal_representative_name: string | null;
70
- legal_representative_identification: string | null;
71
- legal_representative_birthday: string | null;
72
- legal_representative_gender: boolean;
73
- legal_representative_marital_status: string | null;
74
- legal_representative_occupation: string | null;
75
- legal_representative_nationality: string | null;
76
- exporter_code: string | null;
77
- }
78
-
79
- export type Agency = {
80
- id: number;
81
- zid: number;
82
- active: boolean;
83
- ean13: string;
84
- name: string;
85
- employee_id: number | null;
86
- updater_id: number;
87
- entity_id: number;
88
- virtual: boolean;
89
- virtual_type: string | null;
90
- warehouse: boolean;
91
- point_of_sale: boolean;
92
- workshop: boolean;
93
- factory: boolean;
94
- contact: string;
95
- city: string;
96
- address_line_1: string;
97
- address_line_2: string;
98
- phone: string;
99
- notes: string;
100
- created_at: string;
101
- updated_at: string;
102
- price_list_id: number | null;
103
- quote: boolean;
104
- ecommerce: boolean;
105
- external_storage_service_name: string;
106
- agency_category_id: number | null;
107
- };
108
-
109
- export type Membership = {
110
- id: number;
111
- active: boolean;
112
- current: boolean;
113
- reference: string;
114
- starts: string;
115
- expires: string;
116
- eternal: boolean;
117
- entity_id: number;
118
- notes: string;
119
- created_at: string;
120
- updated_at: string;
121
- licenses_count: number;
122
- entity: Entity;
123
- };
124
-
125
- type Profile = {
126
- id: number;
127
- email: string;
128
- active: boolean;
129
- admin: boolean;
130
- name: string;
131
- address: null | string;
132
- mobile_phone: string;
133
- birthday: null | string;
134
- gender: boolean;
135
- notes: null | string;
136
- time_zone: string;
137
- language: string;
138
- selected_entity_id: number;
139
- created_at: string;
140
- updated_at: string;
141
- authentication_token: string;
142
- provider: string;
143
- provider_token: string;
144
- };
145
-
146
- export type ProfileResponse = {
147
- profile: Profile;
148
- memberships: Membership[];
149
- };
150
-
151
13
  /**
152
14
  * getOauthUserInfo
153
15
  * @param codeValue
@@ -223,7 +85,7 @@ export const changeEntity = async (headers: any, entityId: string) => {
223
85
  export const getAgencyInfo = async (
224
86
  headers: any,
225
87
  session: Session
226
- ): Promise<AxiosUtilsResponse<Agency>> => {
88
+ ): Promise<AxiosUtilsResponse<AgencyGraphQL>> => {
227
89
  return handlePossibleAxiosErrors(async () => {
228
90
  const agency_id = session.get("agency_id");
229
91
  if (!agency_id) {
@@ -231,7 +93,7 @@ export const getAgencyInfo = async (
231
93
  "No hay una agencia asignada para este usuario... Contacte con su administrador."
232
94
  );
233
95
  }
234
- const response = await httpZauru.get<Agency>(
96
+ const response = await httpZauru.get<AgencyGraphQL>(
235
97
  `/settings/agencies/${agency_id}.json`,
236
98
  {
237
99
  headers,