@nicefer/types 1.0.13 → 1.0.15

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/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // src/index.ts
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ /** ID único para un usuario */
19
+ // export type UserId = string & { __brand: 'UserId' };
20
+ __exportStar(require("./types/api"), exports);
21
+ __exportStar(require("./types/bag"), exports);
22
+ __exportStar(require("./types/branch"), exports);
23
+ __exportStar(require("./types/categories"), exports);
24
+ __exportStar(require("./types/countries"), exports);
25
+ __exportStar(require("./types/orders"), exports);
26
+ __exportStar(require("./types/payments"), exports);
27
+ __exportStar(require("./types/product-category"), exports);
28
+ __exportStar(require("./types/products"), exports);
29
+ __exportStar(require("./types/replenishment"), exports);
30
+ __exportStar(require("./types/users"), exports);
31
+ __exportStar(require("./types/warehouses"), exports);
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductCategories = void 0;
4
+ exports.getSubcategoryByParentId = getSubcategoryByParentId;
5
+ /** @deprecated */
6
+ exports.ProductCategories = [
7
+ {
8
+ id: 'tops',
9
+ title: 'Tops',
10
+ childs: [
11
+ { id: 'tops-blouses', title: 'Blusas', parentId: 'tops', },
12
+ { id: 'tops-knitwear', title: 'Camisas de punto', parentId: 'tops', },
13
+ { id: 'tops-jackets', title: 'Chaquetas', parentId: 'tops', },
14
+ { id: 'tops-crop-tops', title: 'Tops cortos', parentId: 'tops', },
15
+ { id: 'tops-bodysuits', title: 'Body Suits', parentId: 'tops', },
16
+ { id: 'tops-tank-tops', title: 'Tank tops', parentId: 'tops', }
17
+ ]
18
+ },
19
+ {
20
+ id: 'dresses',
21
+ title: 'Vestidos',
22
+ childs: [
23
+ { id: 'dresses-casual', title: 'Casual', parentId: 'dresses' },
24
+ { id: 'dresses-bodycon', title: 'Bodycon', parentId: 'dresses' },
25
+ { id: 'dresses-maxi', title: 'maxi', parentId: 'dresses' },
26
+ { id: 'dresses-sun-dresses', title: 'Vestidos de verano', parentId: 'dresses' },
27
+ { id: 'dresses-long-sleeve', title: 'Long Sleeve', parentId: 'dresses' },
28
+ { id: 'dresses-knit', title: 'knit', parentId: 'dresses' },
29
+ { id: 'dresses-midi', title: 'midi', parentId: 'dresses' },
30
+ { id: 'dresses-mini', title: 'mini', parentId: 'dresses' },
31
+ { id: 'dresses-off-the-shoulder', title: 'Of the shoulder', parentId: 'dresses' },
32
+ { id: 'dresses-ruffle', title: 'Ruffle', parentId: 'dresses' },
33
+ { id: 'dresses-party-dress', title: 'Vestidos de fiesta', parentId: 'dresses' },
34
+ ]
35
+ },
36
+ { id: 't-shirts', title: 'Camisetas' },
37
+ { id: 'sweatshirts', title: 'Sweatshirts' },
38
+ { id: 'hoodies', title: 'Hoodies' },
39
+ {
40
+ id: 'lingerie',
41
+ title: 'Lencería',
42
+ childs: [
43
+ { id: 'lingerie-bras', title: 'Bras', parentId: 'lingerie' },
44
+ { id: 'lingerie-bra-sets', title: 'Bra Sets', parentId: 'lingerie' },
45
+ { id: 'lingerie-panties', title: 'Panties', parentId: 'lingerie' },
46
+ { id: 'lingerie-shapewear', title: 'shapewear', parentId: 'lingerie' },
47
+ { id: 'lingerie-plus-size', title: 'Talla grande', parentId: 'lingerie' },
48
+ ]
49
+ },
50
+ {
51
+ id: 'bottoms',
52
+ title: 'Bottoms',
53
+ childs: [
54
+ { id: 'bottoms-pants', title: 'Pantalones', parentId: 'bottoms' },
55
+ { id: 'bottoms-skirts', title: 'Faldas', parentId: 'bottoms' },
56
+ { id: 'bottoms-shorts', title: 'Shorts', parentId: 'bottoms' },
57
+ { id: 'bottoms-jumpsuits', title: 'jumpsuits', parentId: 'bottoms' },
58
+ { id: 'bottoms-rompers', title: 'Rompers', parentId: 'bottoms' },
59
+ ]
60
+ },
61
+ {
62
+ id: 'other',
63
+ title: 'Otras categorías',
64
+ childs: [
65
+ { id: 'other-sports', title: 'Sports', parentId: 'other' },
66
+ { id: 'other-sets', title: 'Sets', parentId: 'other' },
67
+ { id: 'other-socks', title: 'Calcetínes', parentId: 'other' },
68
+ { id: 'other-pajamas', title: 'Pijamas', parentId: 'other' },
69
+ { id: 'other-denim', title: 'Denim Jackets', parentId: 'other' },
70
+ { id: 'other-jeans', title: 'Jeans', parentId: 'other' },
71
+ { id: 'other-hangers', title: 'Hangers', parentId: 'other' },
72
+ { id: 'other-stockings', title: 'Medias', parentId: 'other' },
73
+ { id: 'other-leggings', title: 'leggings', parentId: 'other' },
74
+ ]
75
+ }
76
+ ];
77
+ function getSubcategoryByParentId(categoryId) {
78
+ /**
79
+ * Cortar el categoryId
80
+ * @note La primera posición del split contiene el id de la categoría padre.
81
+ * @example ```
82
+ * const categoryId = '`other`-category';
83
+ */
84
+ var splitCategoryId = categoryId.split('-');
85
+ /**
86
+ * Id de la categoría padre
87
+ */
88
+ var parentCategoryId = splitCategoryId[0];
89
+ /**
90
+ * Categoría padre
91
+ */
92
+ var parentCategory = exports.ProductCategories.find(function (pc) { return pc.id == parentCategoryId; });
93
+ if (parentCategory && parentCategory.childs)
94
+ return parentCategory.childs.find(function (child) { return child.id == categoryId; });
95
+ else
96
+ return undefined;
97
+ }
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareRegions = exports.compareCountries = exports.Regions = exports.Countries = void 0;
4
+ exports.getRegionsByCountryId = getRegionsByCountryId;
5
+ exports.Countries = [
6
+ {
7
+ id: 'HN',
8
+ name: 'Honduras',
9
+ code: 504
10
+ },
11
+ {
12
+ id: 'SV',
13
+ name: 'El Salvador',
14
+ code: 503
15
+ },
16
+ // {
17
+ // id: 'US',
18
+ // name: 'Estados Unidos',
19
+ // code: '1'
20
+ // },
21
+ ];
22
+ exports.Regions = {
23
+ HN: [
24
+ {
25
+ id: "AT",
26
+ name: "Atlántida",
27
+ cities: [
28
+ { id: "LCB", name: "La Ceiba", regionId: "AT" },
29
+ { id: "ELP", name: "El Porvenir", regionId: "AT" },
30
+ { id: "ESP", name: "Esparta", regionId: "AT" },
31
+ { id: "JUT", name: "Jutiapa", regionId: "AT" },
32
+ { id: "LAM", name: "La Masica", regionId: "AT" },
33
+ { id: "SFR", name: "San Francisco", regionId: "AT" },
34
+ { id: "TEL", name: "Tela", regionId: "AT" },
35
+ { id: "ARI", name: "Arizona", regionId: "AT" }
36
+ ]
37
+ },
38
+ {
39
+ id: "CH",
40
+ name: "Choluteca",
41
+ cities: []
42
+ },
43
+ { id: "CL", name: "Colón" },
44
+ { id: "CM", name: "Comayagua" },
45
+ { id: "CP", name: "Copán" },
46
+ { id: "CR", name: "Cortés" },
47
+ { id: "EP", name: "El Paraíso" },
48
+ {
49
+ id: "FM",
50
+ name: "Francisco Morazán",
51
+ cities: [
52
+ { id: "TGU", name: "Tegucigalpa", regionId: "FM" },
53
+ { id: "AMA", name: "Amarateca", regionId: "FM" },
54
+ { id: "AZA", name: "Azacualpa", regionId: "FM" },
55
+ { id: "CAR", name: "Carpinteron", regionId: "FM" },
56
+ { id: "CEN", name: "Cerro Grande", regionId: "FM" },
57
+ { id: "COA", name: "Coa Abajo", regionId: "FM" },
58
+ { id: "COU", name: "Coa Arriba", regionId: "FM" }, // id corregido
59
+ { id: "COF", name: "Cofradía", regionId: "FM" },
60
+ { id: "CON", name: "Concepción de Río Grande", regionId: "FM" },
61
+ { id: "ELN", name: "El Naranjal", regionId: "FM" },
62
+ { id: "EPI", name: "El Piliguín", regionId: "FM" },
63
+ { id: "TIZ", name: "El Tizatillo", regionId: "FM" },
64
+ { id: "GER", name: "Germania", regionId: "FM" },
65
+ { id: "GUA", name: "Guangololo", regionId: "FM" },
66
+ { id: "GUS", name: "Guasculile", regionId: "FM" },
67
+ { id: "JAC", name: "Jacaleapa", regionId: "FM" },
68
+ { id: "JUT", name: "Jutiapa", regionId: "FM" },
69
+ { id: "CAL", name: "La Calera", regionId: "FM" },
70
+ { id: "CU2", name: "La Cuesta No.2", regionId: "FM" },
71
+ { id: "MON", name: "La Montañita", regionId: "FM" },
72
+ { id: "SAB", name: "La Sábana", regionId: "FM" },
73
+ { id: "VEN", name: "La Venta", regionId: "FM" },
74
+ { id: "CAS", name: "Las Casitas", regionId: "FM" },
75
+ { id: "FLO", name: "Las Flores", regionId: "FM" },
76
+ { id: "TAP", name: "Las Tapias", regionId: "FM" },
77
+ { id: "JUT2", name: "Los Jutes", regionId: "FM" },
78
+ { id: "MAT", name: "Mateo", regionId: "FM" },
79
+ { id: "RED", name: "Monte Redondo", regionId: "FM" },
80
+ { id: "NAL", name: "Nueva Aldea", regionId: "FM" },
81
+ { id: "RAB", name: "Río Abajo", regionId: "FM" },
82
+ { id: "RHO", name: "Río Hondo", regionId: "FM" },
83
+ { id: "SOR", name: "San Francisco de Soroguara", regionId: "FM" },
84
+ { id: "SJC", name: "San Juancito", regionId: "FM" },
85
+ { id: "SJR", name: "San Juan del Rancho", regionId: "FM" },
86
+ { id: "SRG", name: "San Juan del Río Grande", regionId: "FM" },
87
+ { id: "SMT", name: "San Matías", regionId: "FM" },
88
+ { id: "SCA", name: "Santa Cruz Abajo", regionId: "FM" },
89
+ { id: "SCR", name: "Santa Cruz Arriba", regionId: "FM" },
90
+ { id: "SAR", name: "Santa Rosa", regionId: "FM" },
91
+ { id: "SRO", name: "Soroguara", regionId: "FM" },
92
+ { id: "TAM", name: "Támara", regionId: "FM" },
93
+ { id: "VNU", name: "Villa Nueva", regionId: "FM" },
94
+ { id: "YAG", name: "Yaguacire", regionId: "FM" },
95
+ { id: "ZAM", name: "Zambrano", regionId: "FM" }
96
+ ]
97
+ },
98
+ { id: "GD", name: "Gracias a Dios" },
99
+ { id: "IN", name: "Intibucá" },
100
+ { id: "IB", name: "Islas de la Bahía" },
101
+ { id: "LP", name: "La Paz" },
102
+ { id: "LE", name: "Lempira" },
103
+ { id: "OC", name: "Ocotepeque" },
104
+ { id: "OL", name: "Olancho" },
105
+ { id: "SB", name: "Santa Bárbara" },
106
+ { id: "VA", name: "Valle" },
107
+ { id: "YO", name: "Yoro" }
108
+ ],
109
+ US: [
110
+ { id: "AL", name: "Alabama" },
111
+ { id: "AK", name: "Alaska" },
112
+ { id: "AZ", name: "Arizona" },
113
+ { id: "AR", name: "Arkansas" },
114
+ { id: "CA", name: "California" },
115
+ { id: "CO", name: "Colorado" },
116
+ { id: "CT", name: "Connecticut" },
117
+ { id: "DE", name: "Delaware" },
118
+ { id: "FL", name: "Florida" },
119
+ { id: "GA", name: "Georgia" },
120
+ { id: "HI", name: "Hawaii" },
121
+ { id: "ID", name: "Idaho" },
122
+ { id: "IL", name: "Illinois" },
123
+ { id: "IN", name: "Indiana" },
124
+ { id: "IA", name: "Iowa" },
125
+ { id: "KS", name: "Kansas" },
126
+ { id: "KY", name: "Kentucky" },
127
+ { id: "LA", name: "Louisiana" },
128
+ { id: "ME", name: "Maine" },
129
+ { id: "MD", name: "Maryland" },
130
+ { id: "MA", name: "Massachusetts" },
131
+ { id: "MI", name: "Michigan" },
132
+ { id: "MN", name: "Minnesota" },
133
+ { id: "MS", name: "Mississippi" },
134
+ { id: "MO", name: "Missouri" },
135
+ { id: "MT", name: "Montana" },
136
+ { id: "NE", name: "Nebraska" },
137
+ { id: "NV", name: "Nevada" },
138
+ { id: "NH", name: "New Hampshire" },
139
+ { id: "NJ", name: "New Jersey" },
140
+ { id: "NM", name: "New Mexico" },
141
+ { id: "NY", name: "New York" },
142
+ { id: "NC", name: "North Carolina" },
143
+ { id: "ND", name: "North Dakota" },
144
+ { id: "OH", name: "Ohio" },
145
+ { id: "OK", name: "Oklahoma" },
146
+ { id: "OR", name: "Oregon" },
147
+ { id: "PA", name: "Pennsylvania" },
148
+ { id: "RI", name: "Rhode Island" },
149
+ { id: "SC", name: "South Carolina" },
150
+ { id: "SD", name: "South Dakota" },
151
+ { id: "TN", name: "Tennessee" },
152
+ { id: "TX", name: "Texas" },
153
+ { id: "UT", name: "Utah" },
154
+ { id: "VT", name: "Vermont" },
155
+ { id: "VA", name: "Virginia" },
156
+ { id: "WA", name: "Washington" },
157
+ { id: "WV", name: "West Virginia" },
158
+ { id: "WI", name: "Wisconsin" },
159
+ { id: "WY", name: "Wyoming" }
160
+ ]
161
+ };
162
+ function getRegionsByCountryId(id) {
163
+ return exports.Regions[id];
164
+ }
165
+ /**
166
+ * Usado en el atributo [compareWith] de los mat-select's
167
+ * de los formularios que manejan paises y regiones.
168
+ * @param c1
169
+ * @param c2
170
+ * @returns
171
+ */
172
+ var compareCountries = function (c1, c2) { return c1 && c2 ? c1.id === c2.id : false; };
173
+ exports.compareCountries = compareCountries;
174
+ var compareRegions = function (r1, r2) { return r1 && r2 ? r1.id === r2.id : false; };
175
+ exports.compareRegions = compareRegions;
@@ -0,0 +1,13 @@
1
+ /** ID único para un usuario */
2
+ export * from './types/api';
3
+ export * from './types/bag';
4
+ export * from './types/branch';
5
+ export * from './types/categories';
6
+ export * from './types/countries';
7
+ export * from './types/orders';
8
+ export * from './types/payments';
9
+ export * from './types/product-category';
10
+ export * from './types/products';
11
+ export * from './types/replenishment';
12
+ export * from './types/users';
13
+ export * from './types/warehouses';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
5
+ ;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
5
+ ;
6
+ ;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
5
+ ;
6
+ ;
@@ -0,0 +1,11 @@
1
+ export interface ApiRequest {
2
+ route: string;
3
+ auth?: boolean;
4
+ params?: any;
5
+ page?: number;
6
+ }
7
+ export interface ApiResponse<Data, ErrorCodes = string> {
8
+ ok: boolean;
9
+ error?: ErrorCodes;
10
+ data?: Data;
11
+ }
@@ -0,0 +1,37 @@
1
+ import { OrderDiscountApplied } from "./orders";
2
+ import { PaymentInDB } from "./payments";
3
+ import { ProductVariantInDB } from "./products";
4
+ export interface Bag {
5
+ subtotalPrice: number;
6
+ subtotalWithDiscount: number;
7
+ totalPrice: number;
8
+ shippingPrice: number;
9
+ discounts?: OrderDiscountApplied[];
10
+ ccy: PaymentInDB['ccy'];
11
+ products: ProductWithVariantInBag[];
12
+ }
13
+ /**
14
+ * En la bolsa cada variante será independiente,
15
+ * @example Si un producto tiene 3 variantes y el usuario
16
+ * agrega cada variante, entonces se tomará como 3 productos independientes.
17
+ */
18
+ export interface ProductWithVariantInBag {
19
+ productId: string;
20
+ productName: string;
21
+ imgFullUrl: string | undefined;
22
+ ccy: PaymentInDB['ccy'];
23
+ variantId: string;
24
+ warehouseId: string;
25
+ selectedOptions: ProductVariantInDB['selectedOptions'];
26
+ variantQty: number;
27
+ variantPrice: number;
28
+ createdAt: string;
29
+ updatedAt?: string;
30
+ }
31
+ export interface DeliveryMethod {
32
+ id: 'standard' | 'express' | 'weekend';
33
+ name: string;
34
+ desc: string;
35
+ estimatedDate: string;
36
+ price: number;
37
+ }
@@ -0,0 +1,21 @@
1
+ import { FieldValue } from "firebase/firestore";
2
+ import { Country, Region } from "./countries";
3
+ export interface BranchInDB {
4
+ id: string;
5
+ name: string;
6
+ address: string;
7
+ secondLineAddress?: string;
8
+ city: string;
9
+ region: Region;
10
+ zipcode: number;
11
+ country: Country;
12
+ status: 'active' | 'tmpClosed' | 'closed';
13
+ createdAt: FieldValue | string;
14
+ }
15
+ /**
16
+ * Enlace de la sucursal en otro documento
17
+ */
18
+ export interface BranchFK {
19
+ id: string;
20
+ name: string;
21
+ }
@@ -0,0 +1,3 @@
1
+ /** @deprecated */
2
+ export declare const ProductCategories: any[];
3
+ export declare function getSubcategoryByParentId(categoryId: string): any;
@@ -0,0 +1,30 @@
1
+ export interface Country {
2
+ id: 'HN' | 'US' | 'SV';
3
+ name: string;
4
+ code: number | null | undefined;
5
+ }
6
+ export interface City {
7
+ id: string;
8
+ name: string;
9
+ regionId: string;
10
+ }
11
+ export interface Region {
12
+ id: string;
13
+ name: string;
14
+ cities?: City[];
15
+ }
16
+ export declare const Countries: Country[];
17
+ export declare const Regions: {
18
+ HN: Region[];
19
+ US: Region[];
20
+ };
21
+ export declare function getRegionsByCountryId(id: 'HN' | 'US'): Region[] | any[];
22
+ /**
23
+ * Usado en el atributo [compareWith] de los mat-select's
24
+ * de los formularios que manejan paises y regiones.
25
+ * @param c1
26
+ * @param c2
27
+ * @returns
28
+ */
29
+ export declare const compareCountries: (c1: Country, c2: Country) => boolean;
30
+ export declare const compareRegions: (r1: Region, r2: Region) => boolean;
@@ -0,0 +1,62 @@
1
+ import { PaymentIntent } from "@stripe/stripe-js";
2
+ import { DeliveryMethod, ProductWithVariantInBag } from "./bag";
3
+ import { FieldValue, Timestamp } from "firebase/firestore";
4
+ import { UserAddressInDB } from "./users";
5
+ export interface OrderDiscount {
6
+ id: string;
7
+ name: string;
8
+ code: string;
9
+ automatic?: boolean;
10
+ amount: number;
11
+ isPercent: boolean;
12
+ condition: 'first_order' | 'delivery_free' | 'none';
13
+ }
14
+ export interface OrderDiscountApplied extends OrderDiscount {
15
+ amountInCurrentCcy?: number;
16
+ }
17
+ export interface ProductPrepared {
18
+ productId: string;
19
+ variantId: string;
20
+ qty: number;
21
+ }
22
+ /**
23
+ * Indicará qué productos de {@link OrderInDB.products} fueron ordenados y cuales fueron preparados
24
+ */
25
+ export interface ProductCheckedAfterPrepared {
26
+ productId: string;
27
+ variantId: string;
28
+ qtyOrdered: number;
29
+ qtyPrepared: number;
30
+ }
31
+ export interface OrderInDB {
32
+ id: string;
33
+ customerName: string;
34
+ customerId: string;
35
+ products: ProductWithVariantInBag[];
36
+ /**
37
+ * Indicará qué productos de {@link products} fueron preparados y cuantas unidades.
38
+ */
39
+ productsPrepared?: ProductPrepared[];
40
+ subtotalPrice: number;
41
+ subtotalWithDiscount: number;
42
+ totalPrice: number;
43
+ shippingPrice: number;
44
+ discounts?: OrderDiscountApplied[];
45
+ ccy: string;
46
+ status: 'pending' | 'payment_error' | 'processing' | 'prepared' | 'shipped' | 'delivered' | 'canceled';
47
+ orderDate: string | FieldValue | Timestamp;
48
+ /**
49
+ * Tiempo de entrega estimada
50
+ */
51
+ estimatedDeliveryDate?: string;
52
+ deliveryAddress: UserAddressInDB;
53
+ paymentStatus?: PaymentIntent.Status;
54
+ paymentMethod: 'credit_card' | 'paypal' | 'bank_transfer' | 'cash_on_delivery';
55
+ shippingMethod: DeliveryMethod;
56
+ gift?: {
57
+ fullname: string;
58
+ msg?: string;
59
+ };
60
+ notes?: string;
61
+ }
62
+ export type OrderErrorCodes = 'ERR_CREATE_ORDER' | 'ERR_ORDER_INFO' | 'ERR_CHANGE_ORDER_STATUS';
@@ -0,0 +1,71 @@
1
+ import { FieldValue, Timestamp } from "firebase/firestore";
2
+ import { Metadata, PaymentIntent } from "@stripe/stripe-js";
3
+ /**
4
+ * Payment como está registrado en la base de datos
5
+ */
6
+ export interface PaymentInDB {
7
+ /**
8
+ * @property {string} `id`
9
+ * mismo que `Stripe.PaymentIntent.id`
10
+ */
11
+ id: string;
12
+ /**
13
+ * @property {@link Issuer} `recipientMap`
14
+ * Quién pagó
15
+ */
16
+ issuerMap: {
17
+ id: string;
18
+ displayName: string;
19
+ };
20
+ /**
21
+ * @property {number} `amount`
22
+ * Monto a pagar, incluyendo impuestos, tarifas y comisiones.
23
+ */
24
+ amount: number;
25
+ /**
26
+ * @property {number} `tax`
27
+ * Impuesto de la transacción, basado en EEUU.
28
+ */
29
+ tax: 8.25;
30
+ /**
31
+ * @property ccy {@link PaymentCCY}
32
+ * Moneda en la que se ejecutará el pago.
33
+ */
34
+ ccy: 'HNL' | 'USD';
35
+ /**
36
+ * @property {Timestamp} `createdAt`
37
+ * Fecha y hora en que se generó la transacción,
38
+ * igual que `Stripe.PaymentIntent.created`.
39
+ */
40
+ createdAt: Timestamp | FieldValue;
41
+ }
42
+ /**
43
+ * Parámetros que se enviarán al servidor,
44
+ * y así registrar el PaymentIntent con stripe.
45
+ */
46
+ export interface StripePaymentIntentParams {
47
+ cardHolder: string | string | null | undefined;
48
+ billingAddressLine1: string | string | null | undefined;
49
+ billingAddressCity: string | string | null | undefined;
50
+ amount: number;
51
+ currency: string;
52
+ metadata: PaymentInStripeMetadata;
53
+ }
54
+ export interface PaymentInStripeMetadata {
55
+ /** Ej. users/{userId}/orders/{orderId} */
56
+ refDB: string;
57
+ issuerId: string;
58
+ issuerName: string;
59
+ }
60
+ /**
61
+ * Respuesta de la API Ivife cuándo se busca un PaymentIntent por su {@link StripeMetadata.refId}
62
+ */
63
+ export interface StripePaymentIntentResponse {
64
+ metadata: PaymentInStripeMetadata | Metadata;
65
+ status: PaymentIntent.Status;
66
+ amount: number;
67
+ amount_capturable: number;
68
+ amount_received: number;
69
+ currency: string;
70
+ }
71
+ export type PaymentErrorCodes = 'ERR_PAYMENT' | 'ERR_REINTENT_PAYMENT' | 'authentication_required' | 'requires_action';
@@ -0,0 +1,21 @@
1
+ export interface SubCategory {
2
+ id: string;
3
+ title: string;
4
+ }
5
+ export interface Category {
6
+ id: string;
7
+ title: string;
8
+ icon: string;
9
+ subcategories?: SubCategory[];
10
+ hidden?: boolean;
11
+ }
12
+ export interface CategoryType {
13
+ title: string;
14
+ type: 'clothes' | 'gifts' | 'perfumes' | 'electric';
15
+ icon: string;
16
+ categories: Category[];
17
+ }
18
+ export interface ProductCategoryInDB {
19
+ id: string;
20
+ subcategory: string;
21
+ }
@@ -0,0 +1,116 @@
1
+ import { PaymentInDB } from "./payments";
2
+ import { ProductCategoryInDB } from "./product-category";
3
+ import { RProduct, RSupplier } from "./replenishment";
4
+ export interface ProductFirstOptionTypeValue {
5
+ value: string;
6
+ codeColor?: string;
7
+ }
8
+ export interface ProductOptionValue {
9
+ value: string;
10
+ code?: string;
11
+ }
12
+ export interface ProductOptionToSelect {
13
+ option: 'talla' | 'color' | 'onzas';
14
+ valuesAllowed: ProductOptionValue[];
15
+ }
16
+ /**
17
+ * Igual que store-product-in-db.ts del proyecto `Zavafa`
18
+ */
19
+ export interface ProductInDB {
20
+ id: string;
21
+ name: string;
22
+ description: string;
23
+ category: ProductCategoryInDB;
24
+ brand: string | null | undefined;
25
+ coverImg?: ProductVariantImage;
26
+ type: 'clothes' | 'perfumes';
27
+ /**
28
+ * Opciones con las que se identificará cada variante de este producto,
29
+ * serán establecidas por el usuario.
30
+ *
31
+ * Máximo 2.
32
+ * @example: Talla, Color, Onzas, etc. Y todos sus valores posibles.
33
+ */
34
+ optionsToSelect: ProductOptionToSelect[];
35
+ /** Peso en libras */
36
+ weightLbs?: number;
37
+ ccy: PaymentInDB['ccy'];
38
+ status: 'active' | 'inactive' | 'discontinued';
39
+ tags: string[];
40
+ createdAt: any;
41
+ updatedAt?: string;
42
+ }
43
+ /**
44
+ * /products/{productId}/variants/{sku}
45
+ */
46
+ export interface ProductVariantImage {
47
+ url: string;
48
+ path: string;
49
+ }
50
+ export interface ProductVariantInDB {
51
+ /** Este es el SKU */
52
+ id?: string;
53
+ supplier: RSupplier;
54
+ supplierVariantId: RProduct['supplierVariantId'];
55
+ productId?: string;
56
+ images?: ProductVariantImage[];
57
+ barcode?: string;
58
+ /**
59
+ * Packages dónde está la variante
60
+ */
61
+ inPackages?: {
62
+ packageId: string;
63
+ orderId: string;
64
+ }[];
65
+ /**
66
+ * Warehouses dónde está disponible esta variante.
67
+ * Cada ```key``` del objeto es el id del warehouse y su valor será {@link ProductVariantWarehouseFK}.
68
+ *
69
+ * @note Se usa esta nueva manera para poder usar los FieldValue (serverTimestamp, etc) de Firestore,
70
+ * ya que en los arrays no funcionan.
71
+ */
72
+ warehouses: {
73
+ [key: string]: VariantWarehouseFK;
74
+ };
75
+ /**
76
+ * Opciones de la variante, por ejemplo una prenda tiene color y talla.
77
+ * Obligatoriamente tiene que tener al menos una opción.
78
+ *
79
+ * @note {@link secondOptionType} NO puede ser de tipo 'color'
80
+ */
81
+ selectedOptions: {
82
+ option: ProductOptionToSelect['option'];
83
+ value: {
84
+ value: string;
85
+ code?: string;
86
+ };
87
+ }[];
88
+ }
89
+ /**
90
+ * La forma en que se enlaza información del producto en determinada warehouse,
91
+ * esta información va adentro de la variante.
92
+ *
93
+ * /products/{id}/variants/{id}
94
+ */
95
+ export interface VariantWarehouseFK {
96
+ id: string;
97
+ name: string;
98
+ stock: number;
99
+ price: number;
100
+ lastPrice?: number;
101
+ supplierPriceUSD: number;
102
+ supplierPriceHNL: number;
103
+ profitMarginUSD: number;
104
+ profitMarginHNL: number;
105
+ profitMarginPercent: number;
106
+ }
107
+ /**
108
+ * Para poder mostrar las variantes agrupadas
109
+ *
110
+ * Ej. Verde / S, Verde / M, etc
111
+ */
112
+ export interface ProductGroupVariant {
113
+ variant: ProductVariantInDB;
114
+ /** Indica si la información se cargó desde el servidor o se creó automaticamente */
115
+ dataFromServer: boolean;
116
+ }
@@ -0,0 +1,100 @@
1
+ import { FieldValue, Timestamp } from "firebase/firestore";
2
+ import { ProductVariantInDB } from "./products";
3
+ import { WarehouseInDB } from "./warehouses";
4
+ export interface RSupplier {
5
+ id: string;
6
+ name: string;
7
+ }
8
+ /**
9
+ * Productos de la orden de reabastecimiento realizada al proveedor
10
+ */
11
+ export interface RProduct {
12
+ id?: string;
13
+ productId: string;
14
+ variantId: string;
15
+ packageId: string;
16
+ selectedOptions: ProductVariantInDB['selectedOptions'];
17
+ newStock: number;
18
+ supplier: RSupplier;
19
+ /** Id que usa el proveedor para manejar este producto en su sistema */
20
+ supplierVariantId: string;
21
+ /**
22
+ * Fecha de registro de el paquete en el sistema
23
+ */
24
+ createdAt?: string | FieldValue;
25
+ /**
26
+ * Si no tiene rPackageId se considera un
27
+ * producto de la misma orden pero huérfano
28
+ */
29
+ rPackageId?: string;
30
+ }
31
+ export interface ROrder {
32
+ /**
33
+ * Id único interno
34
+ */
35
+ id?: string;
36
+ /**
37
+ * Número de orden del proveedor
38
+ *
39
+ * Este es el número de orden con el que
40
+ * el proveedor da seguimiento a la orden.
41
+ */
42
+ supplierOrderId: string;
43
+ supplier: RSupplier;
44
+ totalValue: number;
45
+ packsQty: number;
46
+ /**
47
+ * Almacén final que recibirá la orden.
48
+ * Es donde se pondrán en venta los productos o desde dónde
49
+ * se distribuirán al resto de almacenes.
50
+ */
51
+ warehouseDestination: Pick<WarehouseInDB, 'id' | 'name'>;
52
+ /**
53
+ * Moneda siempre será USD
54
+ */
55
+ ccy: 'USD';
56
+ createdAt: Timestamp | FieldValue;
57
+ }
58
+ export interface RPackageHistory {
59
+ title: string;
60
+ /**
61
+ * Si esta en el JSON, entonces ya se llegó al `ROrder['warehouseDestination']` requerido.
62
+ */
63
+ warehouseDestination?: ROrder['warehouseDestination'];
64
+ mode: 'on-the-way' | 'arrived' | 'info';
65
+ /**
66
+ * Nombre de la empresa que realiza el envío desde {@link from}
67
+ * @example UPS, FedEx, SerCargo, etc
68
+ */
69
+ shippingCompany?: string | null;
70
+ trackingURL?: string | null;
71
+ icon?: string;
72
+ /**
73
+ * Fecha en la que se registró el evento
74
+ */
75
+ createdAt: string;
76
+ }
77
+ export interface RPackage {
78
+ id: string;
79
+ /**
80
+ * Id de {@link ROrder}
81
+ */
82
+ orderId: string;
83
+ itemsQty: number;
84
+ historyTracking: RPackageHistory[];
85
+ /**
86
+ * Detalles adicionales sobre el paquete
87
+ */
88
+ notes?: string;
89
+ /**
90
+ * Usuario que registró el paquete
91
+ */
92
+ createdBy: {
93
+ id: string;
94
+ displayName: string;
95
+ };
96
+ /**
97
+ * Fecha de registro de el paquete en el sistema
98
+ */
99
+ createdAt: string | FieldValue;
100
+ }
@@ -0,0 +1,79 @@
1
+ import { FieldValue, Timestamp } from "firebase/firestore";
2
+ import { Country } from "./countries";
3
+ export interface User {
4
+ uid: string;
5
+ displayName: string;
6
+ email: string;
7
+ stripeCustomerId?: string;
8
+ userDevices?: UserDevice[];
9
+ phoneNumber?: string;
10
+ photoURL?: string;
11
+ createdAt: Timestamp | FieldValue;
12
+ updatedAt?: Timestamp | FieldValue;
13
+ }
14
+ export interface UserDevice {
15
+ id: string;
16
+ FCMToken?: string;
17
+ /**
18
+ * ios | android | web
19
+ */
20
+ platform: string;
21
+ /**
22
+ * Iphone 12 | Pixel 5
23
+ */
24
+ model: string;
25
+ /**
26
+ * ios | android
27
+ */
28
+ operatingSystem: string;
29
+ /**
30
+ * 13 | 10
31
+ */
32
+ osVersion: string;
33
+ /**
34
+ * Apple | Google | Microsoft | Samsung
35
+ */
36
+ manufacturer: string;
37
+ /**
38
+ * ``true`` si es un emulador
39
+ */
40
+ isVirtual: boolean;
41
+ /**
42
+ * ``es`` | ``en``
43
+ */
44
+ language: string;
45
+ /**
46
+ * Versión de la app
47
+ */
48
+ appVersion: string;
49
+ appBuild: string;
50
+ lastLogin: Timestamp | FieldValue;
51
+ ipSecurity?: {
52
+ ip: string;
53
+ type: 'IPv4' | 'IPv6';
54
+ country: string;
55
+ country_code: string;
56
+ region: string;
57
+ city: string;
58
+ isp: string;
59
+ };
60
+ }
61
+ export interface UserAddressInDB {
62
+ id: string;
63
+ isDefault?: boolean;
64
+ fullname: string;
65
+ phone: string;
66
+ address: string;
67
+ references: string;
68
+ region: string;
69
+ city: string;
70
+ country: Country | null | undefined;
71
+ }
72
+ export interface UserSearch {
73
+ id: string;
74
+ displayName: string;
75
+ uid: string;
76
+ k: string;
77
+ tags: string[];
78
+ createdAt: FieldValue | Timestamp;
79
+ }
@@ -0,0 +1,14 @@
1
+ import { FieldValue } from "firebase/firestore";
2
+ import { Country, Region } from "./countries";
3
+ export interface WarehouseInDB {
4
+ id?: string;
5
+ name: string;
6
+ address: string;
7
+ secondLineAddress?: string | null;
8
+ city: string;
9
+ region: Region;
10
+ zipcode: number;
11
+ country: Country;
12
+ status: 'active' | 'tmpClosed' | 'closed';
13
+ createdAt: FieldValue | string;
14
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@nicefer/types",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Tipos compartidos para Nicefer",
5
+ "main": "dist/index.js",
5
6
  "types": "dist/index.d.ts",
6
7
  "files": [
7
8
  "dist"