cardus 0.0.4 → 0.0.6
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/.eslintignore +2 -0
- package/.eslintrc +14 -0
- package/.prettierrc +8 -0
- package/dist/index.js +65 -62
- package/dist/insertTempShipment/index.js +30 -21
- package/index.ts +263 -194
- package/insertTempShipment/index.ts +156 -138
- package/package.json +16 -6
- package/types/index.ts +162 -136
package/types/index.ts
CHANGED
|
@@ -1,173 +1,199 @@
|
|
|
1
|
-
export type AnyObject = Record<string, any
|
|
1
|
+
export type AnyObject = Record<string, any>; // Object with whichever properties
|
|
2
2
|
|
|
3
|
-
export type OriginalOrder = AnyObject
|
|
3
|
+
export type OriginalOrder = AnyObject;
|
|
4
4
|
|
|
5
5
|
export type Shipment = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
6
|
+
id_usuario: number;
|
|
7
|
+
id_agencia: number;
|
|
8
|
+
nom_ape_salida: string;
|
|
9
|
+
direccion_salida: string;
|
|
10
|
+
cod_pos_salida: string;
|
|
11
|
+
poblacion_salida: string;
|
|
12
|
+
provincia_salida: string;
|
|
13
|
+
id_zona_salida: string;
|
|
14
|
+
pais_salida: string;
|
|
15
|
+
tlf_salida: string;
|
|
16
|
+
observaciones_salida: string;
|
|
17
|
+
contacto_salida: string;
|
|
18
|
+
mail_salida: string;
|
|
19
|
+
pais_llegada: string | null;
|
|
20
|
+
provincia_llegada: string | null;
|
|
21
|
+
id_zona_llegada: string | null;
|
|
22
|
+
nom_ape_llegada: string;
|
|
23
|
+
contacto_llegada: string;
|
|
24
|
+
direccion_llegada: string;
|
|
25
|
+
cod_pos_llegada: string;
|
|
26
|
+
poblacion_llegada: string;
|
|
27
|
+
tlf_llegada: string;
|
|
28
|
+
mail_llegada: string;
|
|
29
|
+
cantidad_contrareembolso: number | null;
|
|
30
|
+
fecha_recogida: string;
|
|
31
|
+
hora_desde: string;
|
|
32
|
+
hora_hasta: string;
|
|
33
|
+
num_bultos: number;
|
|
34
|
+
tipo_envio: Type;
|
|
35
|
+
codigo_envio_externo: string;
|
|
36
|
+
id_almacen: number;
|
|
37
|
+
};
|
|
38
38
|
|
|
39
39
|
export type Bulto = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
40
|
+
id_envio: number;
|
|
41
|
+
bulto: {
|
|
42
|
+
peso: number;
|
|
43
|
+
alto: number;
|
|
44
|
+
ancho: number;
|
|
45
|
+
largo: number;
|
|
46
|
+
};
|
|
47
|
+
cantidad: number;
|
|
48
|
+
};
|
|
49
49
|
|
|
50
50
|
export type ModifiedOrder = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
51
|
+
lineas: Array<AnyObject>;
|
|
52
|
+
codigoPaisLLegada: string | undefined;
|
|
53
|
+
codigoPostalLLegada: string | undefined;
|
|
54
|
+
primerApellidoLLegada: string | undefined;
|
|
55
|
+
nombreLLegada: string | undefined;
|
|
56
|
+
direccionLLegada2: string | undefined;
|
|
57
|
+
direccionLLegada1: string | undefined;
|
|
58
|
+
ciudadLLegada: string | undefined;
|
|
59
|
+
telefonoLLegada: string | undefined;
|
|
60
|
+
emailLLegada: string | undefined;
|
|
61
|
+
cantidadContrareembolso: number | null;
|
|
62
|
+
codigoEnvioExterno: string;
|
|
63
|
+
idInternoShopify?: string;
|
|
64
|
+
precio: number | null;
|
|
65
|
+
};
|
|
66
66
|
|
|
67
67
|
export interface ModifiedOrderExtended extends ModifiedOrder {
|
|
68
|
-
|
|
68
|
+
idEnvioTemporal: number;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
type FetchAllOrders = () => Promise<OriginalOrder[]
|
|
72
|
-
export type CrearBulto = (params: {
|
|
73
|
-
|
|
71
|
+
type FetchAllOrders = () => Promise<OriginalOrder[]>;
|
|
72
|
+
export type CrearBulto = (params: {
|
|
73
|
+
lineItems: { idEnvioTemporal: number; line: AnyObject };
|
|
74
|
+
idUsuario: number;
|
|
75
|
+
}) => Promise<Bulto>;
|
|
76
|
+
type ModificarOrdenOriginal = (param: {
|
|
77
|
+
originalOrder: OriginalOrder;
|
|
78
|
+
}) => ModifiedOrder;
|
|
74
79
|
|
|
75
80
|
type GroupNotGrouped = {
|
|
76
|
-
|
|
77
|
-
}
|
|
81
|
+
grouped?: 0 | '0';
|
|
82
|
+
};
|
|
78
83
|
|
|
79
84
|
type GroupGrouped = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
85
|
+
grouped?: 1 | '1';
|
|
86
|
+
weight: number;
|
|
87
|
+
height: number;
|
|
88
|
+
width: number;
|
|
89
|
+
length: number;
|
|
90
|
+
};
|
|
86
91
|
|
|
87
|
-
export type Group = GroupNotGrouped | GroupGrouped
|
|
92
|
+
export type Group = GroupNotGrouped | GroupGrouped;
|
|
88
93
|
|
|
89
94
|
export interface InsertParams {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
payload: {
|
|
96
|
+
idUsuario: number;
|
|
97
|
+
agencyId: number;
|
|
98
|
+
addressId: number;
|
|
99
|
+
warehouseId: number;
|
|
100
|
+
group: Group;
|
|
101
|
+
};
|
|
102
|
+
fetchAllOrders: FetchAllOrders;
|
|
103
|
+
crearBulto: CrearBulto;
|
|
104
|
+
modificarOrdenOriginal: ModificarOrdenOriginal;
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
export type IntegrationsService = {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
filterExternalDuplicatedOrders: (params: {
|
|
109
|
+
idUsuario: number;
|
|
110
|
+
orders: OriginalOrder[];
|
|
111
|
+
type: Type;
|
|
112
|
+
}) => Promise<OriginalOrder[]>;
|
|
113
|
+
checkDuplicateTempShipment: (
|
|
114
|
+
codigoEnvioExterno: string,
|
|
115
|
+
idUsuario: number
|
|
116
|
+
) => Promise<boolean>;
|
|
117
|
+
insertTempShipment: (params: Shipment) => number | false;
|
|
118
|
+
insertExternalShipment: (params: {
|
|
119
|
+
id_envio_temporal_usuario: number;
|
|
120
|
+
codigo_envio_externo: string;
|
|
121
|
+
id_usuario: number;
|
|
122
|
+
fecha_hora_creacion: string;
|
|
123
|
+
servicio: Type;
|
|
124
|
+
id_interno_shopify?: string;
|
|
125
|
+
}) => number | false;
|
|
126
|
+
insertTempShipmentLines: (params: {
|
|
127
|
+
id_envio: number;
|
|
128
|
+
bulto: Bulto['bulto'];
|
|
129
|
+
}) => Promise<undefined>;
|
|
130
|
+
insertTempDetailsShipment: (params: {
|
|
131
|
+
id_envio: number;
|
|
132
|
+
bulto: Bulto['bulto'];
|
|
133
|
+
}) => Promise<undefined>;
|
|
134
|
+
};
|
|
117
135
|
|
|
118
136
|
export type SellerAddress = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
137
|
+
id_pais: number;
|
|
138
|
+
codigo_postal: string;
|
|
139
|
+
nombre: string;
|
|
140
|
+
direccion: string;
|
|
141
|
+
poblacion: string;
|
|
142
|
+
provincia: string;
|
|
143
|
+
id_zona: number;
|
|
144
|
+
nombre_pais: string;
|
|
145
|
+
telefono: string;
|
|
146
|
+
observaciones: string;
|
|
147
|
+
mail: string;
|
|
148
|
+
country_code_unico: string;
|
|
149
|
+
};
|
|
132
150
|
|
|
133
151
|
export type AddressesService = {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
152
|
+
getWarehouseAddress: (idUsuario: number) => Promise<SellerAddress>;
|
|
153
|
+
getAddress: (addressId: number, idUsuario: number) => Promise<SellerAddress>;
|
|
154
|
+
};
|
|
137
155
|
|
|
138
|
-
type Country = { nombre_pais: string
|
|
139
|
-
type Provincia = { nombre_provincia?: string }
|
|
140
|
-
type Zone = string
|
|
156
|
+
type Country = { nombre_pais: string; id_pais?: number };
|
|
157
|
+
type Provincia = { nombre_provincia?: string };
|
|
158
|
+
type Zone = string;
|
|
141
159
|
|
|
142
160
|
export type CountriesService = {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
getCountryFromCountryCode: (
|
|
162
|
+
countryCode: string
|
|
163
|
+
) => Promise<{ nombre_pais: string; id_pais?: number }>;
|
|
164
|
+
getProvinceByCountryIdAndPostalCode: (
|
|
165
|
+
id_pais: Country['id_pais'],
|
|
166
|
+
zipCode: string
|
|
167
|
+
) => Promise<Provincia>;
|
|
168
|
+
getZoneIdByCountryIdAndPostalCode: (
|
|
169
|
+
id_pais: Country['id_pais'],
|
|
170
|
+
zipCode: string
|
|
171
|
+
) => Promise<Zone>;
|
|
172
|
+
};
|
|
147
173
|
|
|
148
174
|
export type FindNextPickupDate = (params: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}) => { fecha_recogida_horas: `${string},${string},${string}` }
|
|
175
|
+
fecha?: string;
|
|
176
|
+
cp_salida: string;
|
|
177
|
+
id_pais_origen?: number;
|
|
178
|
+
id_pais_destino?: number;
|
|
179
|
+
idAgencia?: number | null;
|
|
180
|
+
}) => { fecha_recogida_horas: `${string},${string},${string}` };
|
|
155
181
|
|
|
156
|
-
export type Type = 'shopify' | 'amazon' | 'odoo'
|
|
182
|
+
export type Type = 'shopify' | 'amazon' | 'odoo';
|
|
157
183
|
|
|
158
184
|
type ExecutionManagerConstructorParams = {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
185
|
+
arrayParams: Array<any>;
|
|
186
|
+
executable: (params?: any) => any;
|
|
187
|
+
regularExecutionTime: number;
|
|
188
|
+
initialBatchQuantity: number;
|
|
189
|
+
};
|
|
164
190
|
|
|
165
191
|
type ExecutionManagerUploadReturn = {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
192
|
+
status: 'fulfilled' | 'rejected';
|
|
193
|
+
value: any;
|
|
194
|
+
};
|
|
169
195
|
|
|
170
196
|
export type ExecutionManager = {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
197
|
+
upload(): ExecutionManagerUploadReturn[];
|
|
198
|
+
new (params: ExecutionManagerConstructorParams): ExecutionManager;
|
|
199
|
+
};
|