ingeniuscliq-core 0.5.21 → 0.5.22

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 (28) hide show
  1. package/dist/classes/CoreBaseBuilder.d.ts +67 -0
  2. package/dist/classes/CoreBaseBuilder.d.ts.map +1 -0
  3. package/dist/classes/CoreBaseBuilder.js +65 -0
  4. package/dist/classes/index.d.ts +1 -0
  5. package/dist/classes/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -0
  7. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts +3 -2
  8. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts.map +1 -1
  9. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.js +153 -147
  10. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts +3 -2
  11. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts.map +1 -1
  12. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.js +66 -60
  13. package/dist/modules/CoreOrder/classes/CoreOrderBuilder.d.ts +3 -2
  14. package/dist/modules/CoreOrder/classes/CoreOrderBuilder.d.ts.map +1 -1
  15. package/dist/modules/CoreOrder/classes/CoreOrderBuilder.js +95 -89
  16. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts +3 -2
  17. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts.map +1 -1
  18. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.js +50 -44
  19. package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts +3 -2
  20. package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts.map +1 -1
  21. package/dist/modules/CoreProduct/classes/CoreProductBuilder.js +119 -113
  22. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts +3 -2
  23. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts.map +1 -1
  24. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.js +170 -164
  25. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts +3 -2
  26. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts.map +1 -1
  27. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.js +144 -138
  28. package/package.json +1 -1
@@ -1,11 +1,13 @@
1
1
  import { create } from 'zustand';
2
2
  import { persist } from '../../../node_modules/zustand/esm/middleware.js';
3
+ import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder.js';
3
4
  import { CoreShipmentBaseService } from '../services/base.js';
4
5
 
5
- class CoreShipmentBuilder {
6
+ class CoreShipmentBuilder extends CoreBaseBuilder {
6
7
  shipmentService;
7
8
  initialState;
8
9
  constructor(service, initialState) {
10
+ super();
9
11
  this.shipmentService = service || new CoreShipmentBaseService();
10
12
  this.initialState = initialState || {
11
13
  shippingMethods: null,
@@ -16,177 +18,181 @@ class CoreShipmentBuilder {
16
18
  error: null
17
19
  };
18
20
  }
19
- build() {
20
- return create()(
21
- persist(
22
- (set, get) => ({
23
- ...this.initialState,
24
- // Shipping Methods
25
- setShippingMethods: (shippingMethods) => set({ shippingMethods }),
26
- getShippingMethods: () => get().shippingMethods,
27
- fetchShippingMethods: async (params) => {
28
- const { onlyFetch } = params || {};
29
- try {
30
- if (!onlyFetch) {
31
- set({ loading: true, error: null });
32
- }
33
- const response = await this.shipmentService.getShippingMethods();
34
- if (!onlyFetch) {
35
- set({ shippingMethods: response.data.data, loading: false });
36
- }
37
- return response.data;
38
- } catch (error) {
39
- if (!onlyFetch) {
40
- set({ error: error || "Failed to fetch shipping methods", loading: false });
41
- }
42
- throw error;
43
- }
44
- },
45
- // Shipping Addresses
46
- setShippingAddresses: (shippingAddresses) => set({ shippingAddresses }),
47
- getShippingAddresses: () => get().shippingAddresses,
48
- // Selected Address
49
- setSelectedAddress: (address) => set({ selectedAddress: address }),
50
- getSelectedAddress: () => get().selectedAddress,
51
- fetchShippingAddresses: async (params, actions) => {
52
- const { onlyFetch, ...queryParams } = params || {};
53
- try {
54
- if (!onlyFetch) {
55
- set({ loading: true, error: null });
56
- }
57
- const response = await this.shipmentService.getShippingAddresses(queryParams);
58
- if (!onlyFetch) {
59
- set({ shippingAddresses: response.data.data, loading: false });
60
- }
61
- actions?.onSuccess?.(response.data);
62
- return response.data;
63
- } catch (error) {
64
- if (!onlyFetch) {
65
- set({ error: error || "Failed to fetch shipping addresses", loading: false });
66
- }
67
- actions?.onError?.(error);
68
- throw error;
69
- } finally {
70
- actions?.onFinish?.();
71
- }
72
- },
73
- addShippingAddress: async (newAddress, params, actions) => {
74
- set({ loading: true, error: null });
75
- try {
76
- const response = await this.shipmentService.addShippingAddress(newAddress);
77
- await get().fetchShippingAddresses(params);
78
- actions?.onSuccess?.(response);
79
- } catch (error) {
80
- set({ error: error.message || "Failed to add shipping address", loading: false });
81
- actions?.onError?.(error);
82
- throw error;
83
- } finally {
84
- actions?.onFinish?.();
85
- }
86
- },
87
- updateShippingAddress: async (addressId, updateAddress, params, actions) => {
88
- set({ loading: true, error: null });
89
- try {
90
- const response = await this.shipmentService.updateShippingAddress(addressId, updateAddress);
91
- await get().fetchShippingAddresses(params);
92
- actions?.onSuccess?.(response);
93
- } catch (error) {
94
- set({ error: error || "Failed to update shipping address", loading: false });
95
- actions?.onError?.(error);
96
- throw error;
97
- } finally {
98
- actions?.onFinish?.();
99
- }
100
- },
101
- deleteShippingAddress: async (addressId, params, actions) => {
21
+ getBaseState(set, get) {
22
+ return {
23
+ ...this.initialState,
24
+ // Shipping Methods
25
+ setShippingMethods: (shippingMethods) => set({ shippingMethods }),
26
+ getShippingMethods: () => get().shippingMethods,
27
+ fetchShippingMethods: async (params) => {
28
+ const { onlyFetch } = params || {};
29
+ try {
30
+ if (!onlyFetch) {
102
31
  set({ loading: true, error: null });
103
- try {
104
- const response = await this.shipmentService.deleteShippingAddress(addressId);
105
- await get().fetchShippingAddresses(params);
106
- actions?.onSuccess?.(response);
107
- } catch (error) {
108
- set({ error: error || "Failed to delete shipping address", loading: false });
109
- actions?.onError?.(error);
110
- throw error;
111
- } finally {
112
- actions?.onFinish?.();
113
- }
114
- },
115
- // Beneficiaries
116
- fetchBeneficiaries: async (params, actions) => {
117
- const { onlyFetch, ...queryParams } = params || {};
118
- try {
119
- if (!onlyFetch) {
120
- set({ loading: true, error: null });
121
- }
122
- const response = await this.shipmentService.getBeneficiaries(queryParams);
123
- if (!onlyFetch) {
124
- set({ beneficiaries: response.data.data, loading: false });
125
- }
126
- actions?.onSuccess?.(response.data);
127
- return response.data;
128
- } catch (error) {
129
- if (!onlyFetch) {
130
- set({ error: error || "Failed to fetch beneficiaries", loading: false });
131
- }
132
- actions?.onError?.(error);
133
- throw error;
134
- } finally {
135
- actions?.onFinish?.();
136
- }
137
- },
138
- addBeneficiary: async (newBeneficiary, params, actions) => {
139
- set({ loading: true, error: null });
140
- try {
141
- const response = await this.shipmentService.addBeneficiary(newBeneficiary);
142
- await get().fetchBeneficiaries(params);
143
- actions?.onSuccess?.(response);
144
- } catch (error) {
145
- set({ error: error || "Failed to add beneficiary", loading: false });
146
- actions?.onError?.(error);
147
- throw error;
148
- } finally {
149
- actions?.onFinish?.();
150
- }
151
- },
152
- updateBeneficiary: async (beneficiaryId, updateBeneficiary, params, actions) => {
32
+ }
33
+ const response = await this.shipmentService.getShippingMethods();
34
+ if (!onlyFetch) {
35
+ set({ shippingMethods: response.data.data, loading: false });
36
+ }
37
+ return response.data;
38
+ } catch (error) {
39
+ if (!onlyFetch) {
40
+ set({ error: error || "Failed to fetch shipping methods", loading: false });
41
+ }
42
+ throw error;
43
+ }
44
+ },
45
+ // Shipping Addresses
46
+ setShippingAddresses: (shippingAddresses) => set({ shippingAddresses }),
47
+ getShippingAddresses: () => get().shippingAddresses,
48
+ // Selected Address
49
+ setSelectedAddress: (address) => set({ selectedAddress: address }),
50
+ getSelectedAddress: () => get().selectedAddress,
51
+ fetchShippingAddresses: async (params, actions) => {
52
+ const { onlyFetch, ...queryParams } = params || {};
53
+ try {
54
+ if (!onlyFetch) {
153
55
  set({ loading: true, error: null });
154
- try {
155
- const response = await this.shipmentService.updateBeneficiary(beneficiaryId, updateBeneficiary);
156
- await get().fetchBeneficiaries(params);
157
- actions?.onSuccess?.(response);
158
- } catch (error) {
159
- set({ error: error || "Failed to update beneficiary", loading: false });
160
- actions?.onError?.(error);
161
- throw error;
162
- } finally {
163
- actions?.onFinish?.();
164
- }
165
- },
166
- deleteBeneficiary: async (beneficiaryId, params, actions) => {
56
+ }
57
+ const response = await this.shipmentService.getShippingAddresses(queryParams);
58
+ if (!onlyFetch) {
59
+ set({ shippingAddresses: response.data.data, loading: false });
60
+ }
61
+ actions?.onSuccess?.(response.data);
62
+ return response.data;
63
+ } catch (error) {
64
+ if (!onlyFetch) {
65
+ set({ error: error || "Failed to fetch shipping addresses", loading: false });
66
+ }
67
+ actions?.onError?.(error);
68
+ throw error;
69
+ } finally {
70
+ actions?.onFinish?.();
71
+ }
72
+ },
73
+ addShippingAddress: async (newAddress, params, actions) => {
74
+ set({ loading: true, error: null });
75
+ try {
76
+ const response = await this.shipmentService.addShippingAddress(newAddress);
77
+ await get().fetchShippingAddresses(params);
78
+ actions?.onSuccess?.(response);
79
+ } catch (error) {
80
+ set({ error: error.message || "Failed to add shipping address", loading: false });
81
+ actions?.onError?.(error);
82
+ throw error;
83
+ } finally {
84
+ actions?.onFinish?.();
85
+ }
86
+ },
87
+ updateShippingAddress: async (addressId, updateAddress, params, actions) => {
88
+ set({ loading: true, error: null });
89
+ try {
90
+ const response = await this.shipmentService.updateShippingAddress(addressId, updateAddress);
91
+ await get().fetchShippingAddresses(params);
92
+ actions?.onSuccess?.(response);
93
+ } catch (error) {
94
+ set({ error: error || "Failed to update shipping address", loading: false });
95
+ actions?.onError?.(error);
96
+ throw error;
97
+ } finally {
98
+ actions?.onFinish?.();
99
+ }
100
+ },
101
+ deleteShippingAddress: async (addressId, params, actions) => {
102
+ set({ loading: true, error: null });
103
+ try {
104
+ const response = await this.shipmentService.deleteShippingAddress(addressId);
105
+ await get().fetchShippingAddresses(params);
106
+ actions?.onSuccess?.(response);
107
+ } catch (error) {
108
+ set({ error: error || "Failed to delete shipping address", loading: false });
109
+ actions?.onError?.(error);
110
+ throw error;
111
+ } finally {
112
+ actions?.onFinish?.();
113
+ }
114
+ },
115
+ // Beneficiaries
116
+ fetchBeneficiaries: async (params, actions) => {
117
+ const { onlyFetch, ...queryParams } = params || {};
118
+ try {
119
+ if (!onlyFetch) {
167
120
  set({ loading: true, error: null });
168
- try {
169
- const response = await this.shipmentService.deleteBeneficiary(beneficiaryId);
170
- await get().fetchBeneficiaries(params);
171
- actions?.onSuccess?.(response);
172
- } catch (error) {
173
- set({ error: error || "Failed to delete beneficiary", loading: false });
174
- actions?.onError?.(error);
175
- throw error;
176
- } finally {
177
- actions?.onFinish?.();
178
- }
179
- },
180
- setLoading: (loading) => set({ loading }),
181
- setError: (error) => set({ error }),
182
- reset: () => set(this.initialState)
183
- }),
121
+ }
122
+ const response = await this.shipmentService.getBeneficiaries(queryParams);
123
+ if (!onlyFetch) {
124
+ set({ beneficiaries: response.data.data, loading: false });
125
+ }
126
+ actions?.onSuccess?.(response.data);
127
+ return response.data;
128
+ } catch (error) {
129
+ if (!onlyFetch) {
130
+ set({ error: error || "Failed to fetch beneficiaries", loading: false });
131
+ }
132
+ actions?.onError?.(error);
133
+ throw error;
134
+ } finally {
135
+ actions?.onFinish?.();
136
+ }
137
+ },
138
+ addBeneficiary: async (newBeneficiary, params, actions) => {
139
+ set({ loading: true, error: null });
140
+ try {
141
+ const response = await this.shipmentService.addBeneficiary(newBeneficiary);
142
+ await get().fetchBeneficiaries(params);
143
+ actions?.onSuccess?.(response);
144
+ } catch (error) {
145
+ set({ error: error || "Failed to add beneficiary", loading: false });
146
+ actions?.onError?.(error);
147
+ throw error;
148
+ } finally {
149
+ actions?.onFinish?.();
150
+ }
151
+ },
152
+ updateBeneficiary: async (beneficiaryId, updateBeneficiary, params, actions) => {
153
+ set({ loading: true, error: null });
154
+ try {
155
+ const response = await this.shipmentService.updateBeneficiary(beneficiaryId, updateBeneficiary);
156
+ await get().fetchBeneficiaries(params);
157
+ actions?.onSuccess?.(response);
158
+ } catch (error) {
159
+ set({ error: error || "Failed to update beneficiary", loading: false });
160
+ actions?.onError?.(error);
161
+ throw error;
162
+ } finally {
163
+ actions?.onFinish?.();
164
+ }
165
+ },
166
+ deleteBeneficiary: async (beneficiaryId, params, actions) => {
167
+ set({ loading: true, error: null });
168
+ try {
169
+ const response = await this.shipmentService.deleteBeneficiary(beneficiaryId);
170
+ await get().fetchBeneficiaries(params);
171
+ actions?.onSuccess?.(response);
172
+ } catch (error) {
173
+ set({ error: error || "Failed to delete beneficiary", loading: false });
174
+ actions?.onError?.(error);
175
+ throw error;
176
+ } finally {
177
+ actions?.onFinish?.();
178
+ }
179
+ },
180
+ setLoading: (loading) => set({ loading }),
181
+ setError: (error) => set({ error }),
182
+ reset: () => set({ ...this.initialState, ...this.extendInitialState() })
183
+ };
184
+ }
185
+ build() {
186
+ return create()(
187
+ persist(
188
+ (set, get) => this.buildStoreState(set, get),
184
189
  {
185
190
  name: "shipment-storage",
186
191
  partialize: (state) => ({
187
192
  shippingMethods: state.shippingMethods,
188
193
  shippingAddresses: state.shippingAddresses,
189
- beneficiaries: state.beneficiaries
194
+ beneficiaries: state.beneficiaries,
195
+ ...this.extendPartialize(state)
190
196
  })
191
197
  }
192
198
  )
@@ -1,7 +1,7 @@
1
1
  import { CoreShopCartBaseService } from '../services/base';
2
2
  import { CoreShopCartStore } from '../types/CoreShopCart';
3
- import { CoreBuilder } from '../../../classes/CoreBuilder';
4
- export declare class CoreShopCartBuilder<T> implements CoreBuilder {
3
+ import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder';
4
+ export declare class CoreShopCartBuilder<T> extends CoreBaseBuilder<CoreShopCartStore<T>> {
5
5
  protected shopCartService: CoreShopCartBaseService<T>;
6
6
  protected initialState: Pick<CoreShopCartStore<T>, 'cart' | 'cartItems' | 'loading' | 'error'>;
7
7
  constructor(service?: CoreShopCartBaseService<T>, initialState?: {
@@ -15,6 +15,7 @@ export declare class CoreShopCartBuilder<T> implements CoreBuilder {
15
15
  loading: boolean;
16
16
  error: any;
17
17
  });
18
+ protected getBaseState(set: any, get: any): CoreShopCartStore<T>;
18
19
  build(): import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CoreShopCartStore<T>>, "persist"> & {
19
20
  persist: {
20
21
  setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CoreShopCartStore<T>, {
@@ -1 +1 @@
1
- {"version":3,"file":"CoreShopCartBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreShopCart/classes/CoreShopCartBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,qBAAa,mBAAmB,CAAC,CAAC,CAAE,YAAW,WAAW;IACxD,SAAS,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACtD,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAG7F,OAAO,GAAE,uBAAuB,CAAC,CAAC,CAAoC,EACtE,YAAY;;;;;;;;;;KAUX;IAMI,KAAK;;;;;;;;;;;;;;;;;CA2Kb"}
1
+ {"version":3,"file":"CoreShopCartBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreShopCart/classes/CoreShopCartBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,qBAAa,mBAAmB,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC/E,SAAS,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACtD,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAG7F,OAAO,GAAE,uBAAuB,CAAC,CAAC,CAAoC,EACtE,YAAY;;;;;;;;;;KAUX;IAOH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC;IAiKzD,KAAK;;;;;;;;;;;;;;;;;CAeb"}