ingeniuscliq-core 0.3.47 → 0.4.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.
@@ -3,7 +3,7 @@ import { CoreOrderBaseService } from '../services/base';
3
3
  import { CoreOrder, CoreOrderStore } from '../types/CoreOrder';
4
4
  export declare class CoreOrderBuilder<T> implements CoreBuilder {
5
5
  protected orderService: CoreOrderBaseService;
6
- protected initialState: Pick<CoreOrderStore<T>, 'order' | 'loading' | 'error'>;
6
+ protected initialState: Pick<CoreOrderStore<T>, 'order' | 'orders' | 'loading' | 'error'>;
7
7
  constructor(orderService?: CoreOrderBaseService, initialState?: any);
8
8
  build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreOrderStore<T>>, "persist"> & {
9
9
  persist: {
@@ -1,6 +1,6 @@
1
1
  import { BaseType } from '../../../types/BaseType';
2
2
  import { IOrderActions } from './interfaces/OrderActions';
3
- import { BaseStore } from '../../../types';
3
+ import { BasePagination, BaseStore } from '../../../types';
4
4
  /**
5
5
  * CoreOrder base type
6
6
  */
@@ -31,6 +31,7 @@ export interface CoreOrder<T> extends BaseType {
31
31
  }
32
32
  export interface CoreOrderStore<T> extends BaseStore, IOrderActions<T> {
33
33
  order: CoreOrder<T>;
34
+ orders: BasePagination<CoreOrder<T>> | null;
34
35
  }
35
36
  export interface CoreOrderForm extends BaseType {
36
37
  customer_name: string;
@@ -1,10 +1,11 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { BaseApiResponse } from '../../../../types/contracts/BaseApiResponse';
2
+ import { BaseApiResponse, BaseApiResponsePagination } from '../../../../types/contracts/BaseApiResponse';
3
3
  import { CoreOrderForm, CoreOrder } from '../CoreOrder';
4
4
  export interface IOrderActions<T> {
5
5
  createOrder: (order: CoreOrderForm) => Promise<BaseApiResponse<CreateOrderResponse<CoreOrder<T>>>>;
6
6
  fetchOrder: (order_id: string | number) => Promise<BaseApiResponse<CoreOrder<T>>>;
7
7
  getOrder: () => CoreOrder<T>;
8
+ fetchOrders: (params?: any) => Promise<BaseApiResponsePagination<CoreOrder<T>>>;
8
9
  }
9
10
  export interface IOrderActionsService<T> {
10
11
  createOrder: (order: CoreOrderForm) => Promise<AxiosResponse<BaseApiResponse<CreateOrderResponse<CoreOrder<T>>>>>;
@@ -1,3 +1,4 @@
1
+ import { CoreActions } from '../../../types';
1
2
  import { BaseStore } from '../../../types/BaseStore';
2
3
  import { BaseType } from '../../../types/BaseType';
3
4
  /**
@@ -13,5 +14,5 @@ export interface CorePayFormStore<T extends CorePayForm> extends BaseStore {
13
14
  payForms: T[] | null;
14
15
  setPayForms: (payForms: T[] | null) => void;
15
16
  getPayForms: () => T[] | null;
16
- fetchPayForms: (params?: Record<string, any>) => Promise<T[]>;
17
+ fetchPayForms: (params?: Record<string, any>, actions?: CoreActions) => Promise<T[]>;
17
18
  }
@@ -10,7 +10,7 @@ export declare class CoreProductBuilder implements CoreBuilder {
10
10
  persist: {
11
11
  setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreProductStore<CoreProduct, CoreProductCategory>, {
12
12
  productDetails: CoreProduct | null;
13
- products: import('../../..').BasePagination<CoreProduct> | null;
13
+ products: import('../../../types').BasePagination<CoreProduct> | null;
14
14
  categories: CoreProductCategory[] | null;
15
15
  }>>) => void;
16
16
  clearStorage: () => void;
@@ -20,7 +20,7 @@ export declare class CoreProductBuilder implements CoreBuilder {
20
20
  onFinishHydration: (fn: (state: CoreProductStore<CoreProduct, CoreProductCategory>) => void) => () => void;
21
21
  getOptions: () => Partial<import('zustand/middleware').PersistOptions<CoreProductStore<CoreProduct, CoreProductCategory>, {
22
22
  productDetails: CoreProduct | null;
23
- products: import('../../..').BasePagination<CoreProduct> | null;
23
+ products: import('../../../types').BasePagination<CoreProduct> | null;
24
24
  categories: CoreProductCategory[] | null;
25
25
  }>>;
26
26
  };
@@ -6,6 +6,7 @@ import { BaseSlugType } from '../../../types/interfaces/BaseSlugType';
6
6
  import { BaseVisibleType } from '../../../types/interfaces/BaseVisibleType';
7
7
  import { CoreProductCategory, HasProductCategories } from './CoreProductCategory';
8
8
  import { BaseApiResponse, BaseApiResponsePagination } from '../../../types/contracts/BaseApiResponse';
9
+ import { CoreActions } from '../../../types';
9
10
  /**
10
11
  * CoreProduct base type
11
12
  */
@@ -28,7 +29,7 @@ export interface CoreProductStore<T extends CoreProduct, K extends CoreProductCa
28
29
  setProducts: (products: BasePagination<T> | null) => void;
29
30
  setCategories: (categories: K[]) => void;
30
31
  setProductDetails: (product: T | null) => void;
31
- fetchProducts: (params?: Record<string, any>) => Promise<BaseApiResponsePagination<T>>;
32
+ fetchProducts: (params?: Record<string, any>, actions?: CoreActions) => Promise<BaseApiResponsePagination<T>>;
32
33
  getProducts: () => BasePagination<T> | null;
33
34
  fetchProductDetails: (id: string | number) => Promise<BaseApiResponse<T>>;
34
35
  getProductDetails: () => T | null;
@@ -44,3 +45,9 @@ export interface CoreProductible extends BaseType {
44
45
  base_price_per_unit_in_cents: number;
45
46
  base_total_in_cents: number;
46
47
  }
48
+ export interface GetProductsResponse<T extends CoreProduct> extends BaseApiResponsePagination<T> {
49
+ metadata: {
50
+ min_price: number;
51
+ max_price: number;
52
+ };
53
+ }
@@ -1,24 +1,26 @@
1
1
  import { CoreBuilder } from '../../../classes/CoreBuilder';
2
2
  import { CoreShipmentBaseService } from '../services/base';
3
- import { CoreShippingAddress, CoreShipmentStore, CoreShippingMethod, CoreShippingMethodTypes } from '../types/CoreShipment';
4
- export declare class CoreShipmentBuilder<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes> implements CoreBuilder {
5
- protected shipmentService: CoreShipmentBaseService<T, K, Z>;
6
- protected initialState: Pick<CoreShipmentStore<T, K, Z>, "shippingMethods" | "shippingAddresses" | "loading" | "error">;
7
- constructor(service?: CoreShipmentBaseService<T, K, Z>, initialState?: any);
8
- build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShipmentStore<T, K, Z>>, "persist"> & {
3
+ import { CoreShippingAddress, CoreShipmentStore, CoreShippingMethod, CoreShippingMethodTypes, CoreShipmentBeneficiary } from '../types/CoreShipment';
4
+ export declare class CoreShipmentBuilder<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes, Y extends CoreShipmentBeneficiary> implements CoreBuilder {
5
+ protected shipmentService: CoreShipmentBaseService<T, K, Z, Y>;
6
+ protected initialState: Pick<CoreShipmentStore<T, K, Z, Y>, "shippingMethods" | "shippingAddresses" | "beneficiaries" | "loading" | "error">;
7
+ constructor(service?: CoreShipmentBaseService<T, K, Z, Y>, initialState?: any);
8
+ build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShipmentStore<T, K, Z, Y>>, "persist"> & {
9
9
  persist: {
10
- setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K, Z>, {
10
+ setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K, Z, Y>, {
11
11
  shippingMethods: T[] | null;
12
- shippingAddresses: import('../../..').BasePagination<K> | null;
12
+ shippingAddresses: import('../../../types').BasePagination<K> | null;
13
+ beneficiaries: import('../../../types').BasePagination<Y> | null;
13
14
  }>>) => void;
14
15
  clearStorage: () => void;
15
16
  rehydrate: () => Promise<void> | void;
16
17
  hasHydrated: () => boolean;
17
- onHydrate: (fn: (state: CoreShipmentStore<T, K, Z>) => void) => () => void;
18
- onFinishHydration: (fn: (state: CoreShipmentStore<T, K, Z>) => void) => () => void;
19
- getOptions: () => Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K, Z>, {
18
+ onHydrate: (fn: (state: CoreShipmentStore<T, K, Z, Y>) => void) => () => void;
19
+ onFinishHydration: (fn: (state: CoreShipmentStore<T, K, Z, Y>) => void) => () => void;
20
+ getOptions: () => Partial<import('zustand/middleware').PersistOptions<CoreShipmentStore<T, K, Z, Y>, {
20
21
  shippingMethods: T[] | null;
21
- shippingAddresses: import('../../..').BasePagination<K> | null;
22
+ shippingAddresses: import('../../../types').BasePagination<K> | null;
23
+ beneficiaries: import('../../../types').BasePagination<Y> | null;
22
24
  }>>;
23
25
  };
24
26
  }>;
@@ -1,13 +1,18 @@
1
1
  import { BaseService } from '../../../services/base';
2
- import { CoreShippingAddress, CoreShippingAddressForm, CoreShippingMethod, CoreShippingMethodTypes } from '../types/CoreShipment';
2
+ import { CoreShipmentBeneficiary, CoreShipmentBeneficiaryForm, CoreShippingAddress, CoreShippingAddressForm, CoreShippingMethod, CoreShippingMethodTypes } from '../types/CoreShipment';
3
3
  import { BaseApiResponse, BaseApiResponsePagination } from '../../../types';
4
4
  /**
5
5
  * Base class that can be extended by concrete services
6
6
  */
7
- export declare class CoreShipmentBaseService<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes> extends BaseService {
7
+ export declare class CoreShipmentBaseService<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes, Y extends CoreShipmentBeneficiary> extends BaseService {
8
8
  constructor();
9
9
  getShippingMethods(): Promise<import('axios').AxiosResponse<BaseApiResponse<T[]>, any>>;
10
10
  getShippingAddresses(params?: Record<string, any>): Promise<import('axios').AxiosResponse<BaseApiResponsePagination<K>, any>>;
11
11
  addShippingAddress<T extends CoreShippingAddressForm>(newAddress: T): Promise<import('axios').AxiosResponse<BaseApiResponse<K>, any>>;
12
12
  updateShippingAddress(addressId: Pick<K, 'id'>, updateAddress: Partial<K>): Promise<import('axios').AxiosResponse<BaseApiResponse<K>, any>>;
13
+ deleteShippingAddress: (addressId: Pick<K, "id">) => Promise<import('axios').AxiosResponse<BaseApiResponse<null>, any>>;
14
+ getBeneficiaries: (params?: Record<string, any>) => Promise<import('axios').AxiosResponse<BaseApiResponsePagination<Y>, any>>;
15
+ addBeneficiary<X extends CoreShipmentBeneficiaryForm>(newBeneficiary: X): Promise<import('axios').AxiosResponse<BaseApiResponse<Y>, any>>;
16
+ updateBeneficiary<X extends CoreShipmentBeneficiaryForm>(beneficiaryId: Pick<Y, 'id'>, updateBeneficiary: X): Promise<import('axios').AxiosResponse<BaseApiResponse<Y>, any>>;
17
+ deleteBeneficiary(beneficiaryId: Pick<Y, 'id'>): Promise<import('axios').AxiosResponse<BaseApiResponse<null>, any>>;
13
18
  }
@@ -1,15 +1,22 @@
1
- import { BaseApiResponse, BaseApiResponsePagination, BasePagination, BaseStore } from '../../../types';
1
+ import { BaseApiResponse, BaseApiResponsePagination, BasePagination, BaseStore, CoreActions } from '../../../types';
2
2
  import { BaseType } from '../../../types/BaseType';
3
- export interface CoreShipmentStore<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes> extends BaseStore {
3
+ export interface CoreShipmentStore<T extends CoreShippingMethod<Z>, K extends CoreShippingAddress, Z extends CoreShippingMethodTypes, Y extends CoreShipmentBeneficiary> extends BaseStore {
4
4
  shippingMethods: T[] | null;
5
5
  shippingAddresses: BasePagination<K> | null;
6
+ beneficiaries: BasePagination<Y> | null;
6
7
  setShippingMethods: (shippingMethods: T[] | null) => void;
7
8
  getShippingMethods: () => T[] | null;
8
9
  fetchShippingMethods: () => Promise<BaseApiResponse<T[]>>;
9
10
  setShippingAddresses: (shippingAddresses: BasePagination<K> | null) => void;
10
11
  getShippingAddresses: () => BasePagination<K> | null;
11
- fetchShippingAddresses: (params?: Record<string, any>) => Promise<BaseApiResponsePagination<K>>;
12
- addShippingAddress: (newAddress: K) => void;
12
+ fetchShippingAddresses: (params?: Record<string, any>, actions?: CoreActions) => Promise<BaseApiResponsePagination<K>>;
13
+ addShippingAddress: <X extends CoreShippingAddressForm>(newAddress: X, params?: Record<string, any>, actions?: CoreActions) => void;
14
+ updateShippingAddress: (addressId: Pick<K, 'id'>, updateAddress: Partial<K>, params?: Record<string, any>, actions?: CoreActions) => void;
15
+ deleteShippingAddress: (addressId: Pick<K, 'id'>, params?: Record<string, any>, actions?: CoreActions) => void;
16
+ fetchBeneficiaries: (params?: Record<string, any>, actions?: CoreActions) => Promise<BaseApiResponsePagination<Y>>;
17
+ addBeneficiary: <X extends CoreShipmentBeneficiaryForm>(newBeneficiary: X, params?: Record<string, any>, actions?: CoreActions) => void;
18
+ updateBeneficiary: (beneficiaryId: Pick<Y, 'id'>, updateBeneficiary: CoreShipmentBeneficiaryForm, params?: Record<string, any>, actions?: CoreActions) => void;
19
+ deleteBeneficiary: (beneficiaryId: Pick<Y, 'id'>, params?: Record<string, any>, actions?: CoreActions) => void;
13
20
  }
14
21
  export interface CoreShippingMethod<T extends CoreShippingMethodTypes> extends BaseType {
15
22
  name: string;
@@ -39,7 +46,7 @@ export interface CoreShippingAddress extends BaseType {
39
46
  export interface CoreShippingAddressLocalPickup extends CoreShippingAddress {
40
47
  }
41
48
  export interface CoreShippingAddressHomeDelivery extends CoreShippingAddress {
42
- label: string;
49
+ label?: string;
43
50
  is_default: boolean;
44
51
  }
45
52
  export interface CoreShippingAddressProvinceMunicipality extends CoreShippingAddressHomeDelivery {
@@ -57,3 +64,15 @@ export interface CoreShippingAddressProvinceMunicipalityForm extends CoreShippin
57
64
  province: string;
58
65
  municipality: string;
59
66
  }
67
+ export interface CoreShipmentBeneficiary extends BaseType {
68
+ name: string;
69
+ email: string;
70
+ phone: string;
71
+ is_default: boolean;
72
+ }
73
+ export interface CoreShipmentBeneficiaryForm {
74
+ name: string;
75
+ email: string;
76
+ phone: string;
77
+ is_default: boolean;
78
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeniuscliq-core",
3
- "version": "0.3.47",
3
+ "version": "0.4.0",
4
4
  "description": "IngeniusCliq Core UI y lógica compartida",
5
5
  "license": "MIT",
6
6
  "type": "module",