Skip to content

Commit 0718c4d

Browse files
authored
Merge pull request #921 from evershopcommerce/fix/imports
Fix: Fix the missing exports
2 parents fd7c5f0 + 497cd30 commit 0718c4d

9 files changed

Lines changed: 153 additions & 127 deletions

File tree

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
1-
import createAttribute from './attribute/createProductAttribute.js';
2-
import deleteAttribute from './attribute/deleteProductAttribute.js';
3-
import updateAttribute from './attribute/updateProductAttribute.js';
4-
import createCategory from './category/createCategory.js';
5-
import deleteCategory from './category/deleteCategory.js';
6-
import updateCategory from './category/updateCategory.js';
7-
import createCollection from './collection/createCollection.js';
8-
import deleteCollection from './collection/deleteCollection.js';
9-
import updateCollection from './collection/updateCollection.js';
10-
import { getCategoriesBaseQuery } from './getCategoriesBaseQuery.js';
11-
import { getCollectionsBaseQuery } from './getCollectionsBaseQuery.js';
12-
import { getProductsBaseQuery } from './getProductsBaseQuery.js';
13-
import { getProductsByCategoryBaseQuery } from './getProductsByCategoryBaseQuery.js';
14-
import { getProductsByCollectionBaseQuery } from './getProductsByCollectionBaseQuery.js';
15-
import createProduct from './product/createProduct.js';
16-
import deleteProduct from './product/deleteProduct.js';
17-
import updateProduct from './product/updateProduct.js';
1+
// Products
2+
export { default as createProduct } from './product/createProduct.js';
3+
export * from './product/createProduct.js';
4+
export { default as updateProduct } from './product/updateProduct.js';
5+
export * from './product/updateProduct.js';
6+
export { default as deleteProduct } from './product/deleteProduct.js';
7+
export * from './product/deleteProduct.js';
188

9+
// Categories
10+
export { default as createCategory } from './category/createCategory.js';
11+
export * from './category/createCategory.js';
12+
export { default as updateCategory } from './category/updateCategory.js';
13+
export * from './category/updateCategory.js';
14+
export { default as deleteCategory } from './category/deleteCategory.js';
15+
export * from './category/deleteCategory.js';
16+
17+
// Collections
18+
export { default as createCollection } from './collection/createCollection.js';
19+
export * from './collection/createCollection.js';
20+
export { default as updateCollection } from './collection/updateCollection.js';
21+
export * from './collection/updateCollection.js';
22+
export { default as deleteCollection } from './collection/deleteCollection.js';
23+
export * from './collection/deleteCollection.js';
24+
25+
// Attributes
26+
// AttributeData is exported from createProductAttribute only to avoid name conflict
27+
export { default as createAttribute } from './attribute/createProductAttribute.js';
28+
export * from './attribute/createProductAttribute.js';
29+
export { default as updateAttribute } from './attribute/updateProductAttribute.js';
1930
export {
20-
createProduct,
21-
updateProduct,
22-
deleteProduct,
23-
createCollection,
24-
updateCollection,
25-
deleteCollection,
26-
createCategory,
27-
updateCategory,
28-
deleteCategory,
29-
createAttribute,
30-
updateAttribute,
31-
deleteAttribute,
32-
getCategoriesBaseQuery,
33-
getCollectionsBaseQuery,
34-
getProductsBaseQuery,
35-
getProductsByCategoryBaseQuery,
36-
getProductsByCollectionBaseQuery
37-
};
31+
hookBeforeUpdateAttributeData,
32+
hookAfterUpdateAttributeData,
33+
hookBeforeUpdateAttributeGroups,
34+
hookAfterUpdateAttributeGroups,
35+
hookBeforeUpdateAttributeOptions,
36+
hookAfterUpdateAttributeOptions,
37+
hookBeforeUpdateAttribute,
38+
hookAfterUpdateAttribute
39+
} from './attribute/updateProductAttribute.js';
40+
export { default as deleteAttribute } from './attribute/deleteProductAttribute.js';
41+
export * from './attribute/deleteProductAttribute.js';
42+
43+
// Query helpers
44+
export * from './getCategoriesBaseQuery.js';
45+
export * from './getCollectionsBaseQuery.js';
46+
export * from './getProductsBaseQuery.js';
47+
export * from './getProductsByCategoryBaseQuery.js';
48+
export * from './getProductsByCollectionBaseQuery.js';

packages/evershop/src/modules/checkout/services/addBillingAddress.ts

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface BillingAddress extends Address {
3030
* @throws {Error} If cart does not exist or address validation fails
3131
* @returns {Promise<Address>} The newly created address object
3232
*/
33-
async function addBillingAddressService<
33+
const _addBillingAddress = async function addBillingAddress<
3434
T extends Address = Address,
3535
R = BillingAddress
3636
>(
@@ -85,7 +85,7 @@ async function addBillingAddressService<
8585
})(addressData, connection);
8686

8787
// Update cart with billing address
88-
await hookable(updateCartWithAddress, {
88+
await hookable(updateCartWithBillingAddress, {
8989
cartUUID,
9090
addressData,
9191
cart,
@@ -100,7 +100,7 @@ async function addBillingAddressService<
100100
await rollback(connection);
101101
throw error;
102102
}
103-
}
103+
};
104104

105105
/**
106106
* Save billing address to database
@@ -126,7 +126,7 @@ async function saveBillingAddress(
126126
/**
127127
* Update cart with billing address
128128
*/
129-
async function updateCartWithAddress(
129+
async function updateCartWithBillingAddress(
130130
cartId: number,
131131
addressId: number,
132132
connection: PoolClient
@@ -148,7 +148,7 @@ export const addBillingAddress = async (
148148
addressData: Address,
149149
context: Record<string, unknown> = {}
150150
) => {
151-
const result = await hookable(addBillingAddressService, {
151+
const result = await hookable(_addBillingAddress, {
152152
cartUUID,
153153
addressData,
154154
...context
@@ -159,10 +159,7 @@ export const addBillingAddress = async (
159159
export function hookBeforeSaveBillingAddress(
160160
callback: (
161161
this: Record<string, unknown>,
162-
...args: [
163-
addressData: Address,
164-
connection: PoolClient
165-
]
162+
...args: [addressData: Address, connection: PoolClient]
166163
) => void | Promise<void>,
167164
priority: number = 10
168165
): void {
@@ -172,68 +169,57 @@ export function hookBeforeSaveBillingAddress(
172169
export function hookAfterSaveBillingAddress(
173170
callback: (
174171
this: Record<string, unknown>,
175-
...args: [
176-
addressData: Address,
177-
connection: PoolClient
178-
]
172+
...args: [addressData: Address, connection: PoolClient]
179173
) => void | Promise<void>,
180174
priority: number = 10
181175
): void {
182176
hookAfter('saveBillingAddress', callback, priority);
183177
}
184178

185-
export function hookBeforeUpdateCartWithAddress(
179+
export function hookBeforeUpdateCartWithBillingAddress(
186180
callback: (
187181
this: Record<string, unknown>,
188-
...args: [
189-
cartId: number,
190-
addressId: number,
191-
connection: PoolClient
192-
]
182+
...args: [cartId: number, addressId: number, connection: PoolClient]
193183
) => void | Promise<void>,
194184
priority: number = 10
195185
): void {
196-
hookBefore('updateCartWithAddress', callback, priority);
186+
hookBefore('updateCartWithBillingAddress', callback, priority);
197187
}
198188

199-
export function hookAfterUpdateCartWithAddress(
189+
export function hookAfterUpdateCartWithBillingAddress(
200190
callback: (
201191
this: Record<string, unknown>,
202-
...args: [
203-
cartId: number,
204-
addressId: number,
205-
connection: PoolClient
206-
]
192+
...args: [cartId: number, addressId: number, connection: PoolClient]
207193
) => void | Promise<void>,
208194
priority: number = 10
209195
): void {
210-
hookAfter('updateCartWithAddress', callback, priority);
196+
hookAfter('updateCartWithBillingAddress', callback, priority);
211197
}
212198

213-
export function hookBeforeAddBillingAddressService(
199+
export function hookBeforeAddBillingAddress(
214200
callback: (
215201
this: Record<string, unknown>,
216202
...args: [
217-
cartUUID: string,
218-
addressData: Address,
219-
context: Record<string, unknown>
203+
cartUUID: string,
204+
addressData: Address,
205+
context: Record<string, unknown>
220206
]
221207
) => void | Promise<void>,
222208
priority: number = 10
223209
): void {
224-
hookBefore('addBillingAddressService', callback, priority);
210+
hookBefore('addBillingAddress', callback, priority);
225211
}
226212

227-
export function hookAfterAddBillingAddressService(
213+
export function hookAfterAddBillingAddress(
228214
callback: (
229215
this: Record<string, unknown>,
230216
...args: [
231-
cartUUID: string,
232-
addressData: Address,
233-
context: Record<string, unknown>
217+
cartUUID: string,
218+
addressData: Address,
219+
context: Record<string, unknown>
234220
]
235221
) => void | Promise<void>,
236222
priority: number = 10
237223
): void {
238-
hookAfter('addBillingAddressService', callback, priority);
224+
hookAfter('addBillingAddress', callback, priority);
239225
}

packages/evershop/src/modules/checkout/services/addShippingAddress.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface ShippingAddress extends Address {
2929
* @throws {Error} If cart does not exist, address validation fails, or shipping zone is not available
3030
* @returns {Promise<Address>} The newly created address object
3131
*/
32-
async function addShippingAddressService<
32+
const _addShippingAddress = async function addShippingAddress<
3333
T extends Address = Address,
3434
R = ShippingAddress
3535
>(
@@ -97,7 +97,7 @@ async function addShippingAddressService<
9797
})(addressData, connection);
9898

9999
// Update cart with shipping zone and address
100-
await hookable(updateCartWithAddress, {
100+
await hookable(updateCartWithShippingAddress, {
101101
cartUUID,
102102
addressData,
103103
cart,
@@ -113,7 +113,7 @@ async function addShippingAddressService<
113113
await rollback(connection);
114114
throw error;
115115
}
116-
}
116+
};
117117

118118
/**
119119
* Find shipping zone for the given address
@@ -161,7 +161,7 @@ async function saveShippingAddress(
161161
/**
162162
* Update cart with shipping zone and address
163163
*/
164-
async function updateCartWithAddress(
164+
async function updateCartWithShippingAddress(
165165
cartId: number,
166166
addressId: number,
167167
connection: PoolClient
@@ -183,7 +183,7 @@ export const addShippingAddress = async (
183183
addressData: Address,
184184
context: Record<string, unknown> = {}
185185
) => {
186-
const result = await hookable(addShippingAddressService, {
186+
const result = await hookable(_addShippingAddress, {
187187
cartUUID,
188188
addressData,
189189
...context
@@ -194,10 +194,7 @@ export const addShippingAddress = async (
194194
export function hookBeforeSaveShippingAddress(
195195
callback: (
196196
this: Record<string, unknown>,
197-
...args: [
198-
addressData: Address,
199-
connection: PoolClient
200-
]
197+
...args: [addressData: Address, connection: PoolClient]
201198
) => void | Promise<void>,
202199
priority: number = 10
203200
): void {
@@ -207,40 +204,37 @@ export function hookBeforeSaveShippingAddress(
207204
export function hookAfterSaveShippingAddress(
208205
callback: (
209206
this: Record<string, unknown>,
210-
...args: [
211-
addressData: Address,
212-
connection: PoolClient
213-
]
207+
...args: [addressData: Address, connection: PoolClient]
214208
) => void | Promise<void>,
215209
priority: number = 10
216210
): void {
217211
hookAfter('saveShippingAddress', callback, priority);
218212
}
219213

220-
export function hookBeforeAddShippingAddressService(
214+
export function hookBeforeAddShippingAddress(
221215
callback: (
222216
this: Record<string, unknown>,
223217
...args: [
224-
cartUUID: string,
225-
addressData: Address,
226-
context: Record<string, unknown>
218+
cartUUID: string,
219+
addressData: Address,
220+
context: Record<string, unknown>
227221
]
228222
) => void | Promise<void>,
229223
priority: number = 10
230224
): void {
231-
hookBefore('addShippingAddressService', callback, priority);
225+
hookBefore('addShippingAddress', callback, priority);
232226
}
233227

234-
export function hookAfterAddShippingAddressService(
228+
export function hookAfterAddShippingAddress(
235229
callback: (
236230
this: Record<string, unknown>,
237231
...args: [
238-
cartUUID: string,
239-
addressData: Address,
240-
context: Record<string, unknown>
232+
cartUUID: string,
233+
addressData: Address,
234+
context: Record<string, unknown>
241235
]
242236
) => void | Promise<void>,
243237
priority: number = 10
244238
): void {
245-
hookAfter('addShippingAddressService', callback, priority);
239+
hookAfter('addShippingAddress', callback, priority);
246240
}

packages/evershop/src/modules/checkout/services/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ export * from './toPrice.js';
88
export * from './orderCreator.js';
99
export * from './orderValidator.js';
1010
export * from './addShippingAddress.js';
11-
export { default as removeCartItem } from './removeCartItem.js';
12-
export { default as updateCartItemQty } from './updateCartItemQty.js';
13-
export { default as addCartItem } from './addCartItem.js';
11+
export * from './addBillingAddress.js';
12+
export * from './checkout.js';
13+
export {
14+
default as removeCartItem,
15+
hookBeforeRemoveCartItem,
16+
hookAfterRemoveCartItem
17+
} from './removeCartItem.js';
18+
export {
19+
default as updateCartItemQty,
20+
hookBeforeUpdateCartItemQty,
21+
hookAfterUpdateCartItemQty
22+
} from './updateCartItemQty.js';
23+
export {
24+
default as addCartItem,
25+
hookBeforeAddCartItem,
26+
hookAfterAddCartItem
27+
} from './addCartItem.js';

packages/evershop/src/modules/cms/api/createCmsPage/createPage[finish].ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EvershopRequest } from '../../../../types/request.js';
22
import { EvershopResponse } from '../../../../types/response.js';
3-
import createPage from '../../services/page/createPage.js';
3+
import { createPage } from '../../services/page/createPage.js';
44

55
export default async (request: EvershopRequest, response: EvershopResponse) => {
66
const data = request.body;

packages/evershop/src/modules/cms/services/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ export * from './browFiles.js';
22
export * from './createFolder.js';
33
export * from './deleteFile.js';
44
export * from './uploadFile.js';
5+
export * from './page/createPage.js';
6+
export * from './page/deletePage.js';
7+
export * from './page/updatePage.js';

0 commit comments

Comments
 (0)