feeef 0.5.35-dev.1 → 0.5.36-dev.10
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/build/index.js +140 -4
- package/build/index.js.map +1 -1
- package/build/src/core/entities/category.d.ts +13 -0
- package/build/src/core/entities/order.d.ts +3 -0
- package/build/src/core/entities/product.d.ts +18 -2
- package/build/src/core/entities/store.d.ts +132 -3
- package/build/src/feeef/feeef.d.ts +14 -0
- package/build/src/feeef/repositories/categories.d.ts +51 -0
- package/build/src/feeef/repositories/orders.d.ts +31 -0
- package/build/src/feeef/repositories/products.d.ts +6 -0
- package/build/src/index.d.ts +1 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -125,6 +125,24 @@ var OrderRepository = class extends ModelRepository {
|
|
|
125
125
|
});
|
|
126
126
|
return res.data;
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Assigns a single order to a member (as confirmer)
|
|
130
|
+
* @param data - The data containing orderId, memberId, and storeId
|
|
131
|
+
* @returns A Promise that resolves to the updated OrderEntity
|
|
132
|
+
*/
|
|
133
|
+
async assign(data) {
|
|
134
|
+
const res = await this.client.post(`/${this.resource}/assign`, data);
|
|
135
|
+
return res.data;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Assigns multiple orders to a member (as confirmer)
|
|
139
|
+
* @param data - The data containing orderIds, memberId, and storeId
|
|
140
|
+
* @returns A Promise that resolves to a success message
|
|
141
|
+
*/
|
|
142
|
+
async assignMany(data) {
|
|
143
|
+
const res = await this.client.post(`/${this.resource}/assignMany`, data);
|
|
144
|
+
return res.data;
|
|
145
|
+
}
|
|
128
146
|
};
|
|
129
147
|
|
|
130
148
|
// src/feeef/repositories/products.ts
|
|
@@ -136,6 +154,17 @@ var ProductRepository = class extends ModelRepository {
|
|
|
136
154
|
constructor(client) {
|
|
137
155
|
super("products", client);
|
|
138
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves a random products from the repository.
|
|
159
|
+
* @param limit - The number of random products to retrieve. Default is 1.
|
|
160
|
+
* @returns A promise that resolves to an array of random ProductEntity objects.
|
|
161
|
+
*/
|
|
162
|
+
async random(limit = 12) {
|
|
163
|
+
const response = await this.client.get(`/products/random`, {
|
|
164
|
+
params: { limit }
|
|
165
|
+
});
|
|
166
|
+
return response.data;
|
|
167
|
+
}
|
|
139
168
|
};
|
|
140
169
|
|
|
141
170
|
// src/feeef/repositories/stores.ts
|
|
@@ -275,6 +304,55 @@ var DepositRepository = class extends ModelRepository {
|
|
|
275
304
|
}
|
|
276
305
|
};
|
|
277
306
|
|
|
307
|
+
// src/feeef/repositories/categories.ts
|
|
308
|
+
var CategoryRepository = class extends ModelRepository {
|
|
309
|
+
/**
|
|
310
|
+
* Constructs a new CategoryRepository instance.
|
|
311
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
312
|
+
*/
|
|
313
|
+
constructor(client) {
|
|
314
|
+
super("categories", client);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Lists categories for a store with optional parent filter.
|
|
318
|
+
* @param options The options for listing categories.
|
|
319
|
+
* @returns A Promise that resolves to a list of categories.
|
|
320
|
+
*/
|
|
321
|
+
async list(options) {
|
|
322
|
+
const { storeId, parentId, ...listOptions } = options || {};
|
|
323
|
+
const params = {
|
|
324
|
+
...listOptions.params,
|
|
325
|
+
...storeId ? { store_id: storeId } : {},
|
|
326
|
+
...parentId !== void 0 ? { parent_id: parentId } : {}
|
|
327
|
+
};
|
|
328
|
+
return super.list({ ...listOptions, params });
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Gets the category tree structure for a store.
|
|
332
|
+
* @param storeId The store ID.
|
|
333
|
+
* @returns A Promise that resolves to the category tree.
|
|
334
|
+
*/
|
|
335
|
+
async tree(storeId) {
|
|
336
|
+
const res = await this.client.get(`/stores/${storeId}/categories/tree`);
|
|
337
|
+
return res.data;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Creates a new Category entity.
|
|
341
|
+
* @param options The options for creating the Category entity.
|
|
342
|
+
* @returns A Promise that resolves to the created Category entity.
|
|
343
|
+
*/
|
|
344
|
+
async create(options) {
|
|
345
|
+
const { storeId, data, ...rest } = options;
|
|
346
|
+
if (storeId) {
|
|
347
|
+
const res = await this.client.post(`/stores/${storeId}/categories`, data, {
|
|
348
|
+
params: rest.params
|
|
349
|
+
});
|
|
350
|
+
return res.data;
|
|
351
|
+
}
|
|
352
|
+
return super.create(options);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
278
356
|
// src/core/entities/order.ts
|
|
279
357
|
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
280
358
|
OrderStatus2["draft"] = "draft";
|
|
@@ -920,6 +998,10 @@ var FeeeF = class {
|
|
|
920
998
|
* The repository for managing deposits.
|
|
921
999
|
*/
|
|
922
1000
|
deposits;
|
|
1001
|
+
/**
|
|
1002
|
+
* The repository for managing categories.
|
|
1003
|
+
*/
|
|
1004
|
+
categories;
|
|
923
1005
|
/**
|
|
924
1006
|
* The cart service for managing the cart.
|
|
925
1007
|
*/
|
|
@@ -936,28 +1018,45 @@ var FeeeF = class {
|
|
|
936
1018
|
console.log("feeef super cache", cache);
|
|
937
1019
|
this.apiKey = apiKey;
|
|
938
1020
|
this.client = client || axios;
|
|
1021
|
+
this.client.defaults.headers.common["Authorization"] = `Bearer ${this.apiKey}`;
|
|
939
1022
|
this.client.defaults.baseURL = baseURL;
|
|
940
1023
|
this.stores = new StoreRepository(this.client);
|
|
941
1024
|
this.products = new ProductRepository(this.client);
|
|
942
1025
|
this.users = new UserRepository(this.client);
|
|
943
1026
|
this.orders = new OrderRepository(this.client);
|
|
944
1027
|
this.deposits = new DepositRepository(this.client);
|
|
1028
|
+
this.categories = new CategoryRepository(this.client);
|
|
945
1029
|
this.cart = new CartService();
|
|
946
1030
|
}
|
|
1031
|
+
/**
|
|
1032
|
+
* set header method to set custom headers for all requests
|
|
1033
|
+
*/
|
|
1034
|
+
setHeader(key, value) {
|
|
1035
|
+
this.client.defaults.headers.common[key] = value;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Removes a header from the default headers.
|
|
1039
|
+
* @param {string} key - The key of the header to remove.
|
|
1040
|
+
*/
|
|
1041
|
+
removeHeader(key) {
|
|
1042
|
+
delete this.client.defaults.headers.common[key];
|
|
1043
|
+
}
|
|
947
1044
|
};
|
|
948
1045
|
|
|
949
1046
|
// src/core/entities/store.ts
|
|
950
1047
|
var generatePublicStoreIntegrations = (integrations) => {
|
|
951
1048
|
if (!integrations) return null;
|
|
952
|
-
const { metaPixel, tiktokPixel, googleAnalytics, googleTags, orderdz, webhooks } = integrations;
|
|
1049
|
+
const { metaPixel, tiktokPixel, googleAnalytics, googleTags, orderdz, webhooks, ai, security } = integrations;
|
|
953
1050
|
return {
|
|
954
1051
|
metaPixel: generatePublicStoreIntegrationMetaPixel(metaPixel) || null,
|
|
955
1052
|
tiktokPixel: generatePublicStoreIntegrationTiktokPixel(tiktokPixel) || null,
|
|
956
1053
|
googleAnalytics: generatePublicStoreIntegrationGoogleAnalytics(googleAnalytics) || null,
|
|
957
1054
|
googleTags: generatePublicStoreIntegrationGoogleTags(googleTags) || null,
|
|
958
1055
|
googleSheet: null,
|
|
1056
|
+
ai: generatePublicStoreIntegrationAi(ai) || null,
|
|
959
1057
|
orderdz: generatePublicStoreIntegrationOrderdz(orderdz) || null,
|
|
960
|
-
webhooks: generatePublicStoreIntegrationWebhooks(webhooks) || null
|
|
1058
|
+
webhooks: generatePublicStoreIntegrationWebhooks(webhooks) || null,
|
|
1059
|
+
security: generatePublicStoreIntegrationSecurity(security) || null
|
|
961
1060
|
};
|
|
962
1061
|
};
|
|
963
1062
|
var generatePublicStoreIntegrationMetaPixel = (metaPixel) => {
|
|
@@ -977,7 +1076,9 @@ var generatePublicStoreIntegrationTiktokPixel = (tiktokPixel) => {
|
|
|
977
1076
|
pixels: tiktokPixel.pixels.map((pixel) => ({
|
|
978
1077
|
id: pixel.id
|
|
979
1078
|
})),
|
|
980
|
-
active: tiktokPixel.active
|
|
1079
|
+
active: tiktokPixel.active,
|
|
1080
|
+
objective: tiktokPixel.objective,
|
|
1081
|
+
draftObjective: tiktokPixel.draftObjective
|
|
981
1082
|
};
|
|
982
1083
|
};
|
|
983
1084
|
var generatePublicStoreIntegrationGoogleAnalytics = (googleAnalytics) => {
|
|
@@ -999,6 +1100,14 @@ var generatePublicStoreIntegrationGoogleTags = (googleTags) => {
|
|
|
999
1100
|
active
|
|
1000
1101
|
};
|
|
1001
1102
|
};
|
|
1103
|
+
var generatePublicStoreIntegrationAi = (ai) => {
|
|
1104
|
+
if (!ai) return null;
|
|
1105
|
+
return {
|
|
1106
|
+
active: ai.active,
|
|
1107
|
+
textModel: ai.textModel,
|
|
1108
|
+
imageModel: ai.imageModel
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1002
1111
|
var generatePublicStoreIntegrationOrderdz = (orderdz) => {
|
|
1003
1112
|
if (!orderdz) return null;
|
|
1004
1113
|
return {
|
|
@@ -1016,6 +1125,16 @@ var generatePublicStoreIntegrationWebhooks = (webhooks) => {
|
|
|
1016
1125
|
webhookUrls: activeWebhooks.map((webhook) => webhook.url)
|
|
1017
1126
|
};
|
|
1018
1127
|
};
|
|
1128
|
+
var generatePublicStoreIntegrationSecurity = (security) => {
|
|
1129
|
+
if (!security) return null;
|
|
1130
|
+
return {
|
|
1131
|
+
key: "[none]",
|
|
1132
|
+
orders: security.orders ? {
|
|
1133
|
+
frontend: security.orders.frontend
|
|
1134
|
+
} : void 0,
|
|
1135
|
+
active: security.active
|
|
1136
|
+
};
|
|
1137
|
+
};
|
|
1019
1138
|
var StoreMemberRole = /* @__PURE__ */ ((StoreMemberRole2) => {
|
|
1020
1139
|
StoreMemberRole2["editor"] = "editor";
|
|
1021
1140
|
StoreMemberRole2["viewer"] = "viewer";
|
|
@@ -1070,7 +1189,12 @@ function generatePublicIntegrationsDataMetaPixel(data) {
|
|
|
1070
1189
|
}
|
|
1071
1190
|
function generatePublicIntegrationsDataTiktokPixel(data) {
|
|
1072
1191
|
if (!data) return data;
|
|
1073
|
-
|
|
1192
|
+
const { ids, objective, draftObjective } = data;
|
|
1193
|
+
return {
|
|
1194
|
+
ids,
|
|
1195
|
+
objective,
|
|
1196
|
+
draftObjective
|
|
1197
|
+
};
|
|
1074
1198
|
}
|
|
1075
1199
|
function generatePublicIntegrationsDataGoogleAnalytics(data) {
|
|
1076
1200
|
if (!data) return data;
|
|
@@ -1094,6 +1218,16 @@ var MetaPixelEvent = /* @__PURE__ */ ((MetaPixelEvent2) => {
|
|
|
1094
1218
|
return MetaPixelEvent2;
|
|
1095
1219
|
})(MetaPixelEvent || {});
|
|
1096
1220
|
var TiktokPixelEvent = /* @__PURE__ */ ((TiktokPixelEvent2) => {
|
|
1221
|
+
TiktokPixelEvent2["none"] = "none";
|
|
1222
|
+
TiktokPixelEvent2["viewContent"] = "ViewContent";
|
|
1223
|
+
TiktokPixelEvent2["addToWishlist"] = "AddToWishlist";
|
|
1224
|
+
TiktokPixelEvent2["search"] = "Search";
|
|
1225
|
+
TiktokPixelEvent2["addPaymentInfo"] = "AddPaymentInfo";
|
|
1226
|
+
TiktokPixelEvent2["addToCart"] = "AddToCart";
|
|
1227
|
+
TiktokPixelEvent2["initiateCheckout"] = "InitiateCheckout";
|
|
1228
|
+
TiktokPixelEvent2["placeAnOrder"] = "PlaceAnOrder";
|
|
1229
|
+
TiktokPixelEvent2["completeRegistration"] = "CompleteRegistration";
|
|
1230
|
+
TiktokPixelEvent2["purchase"] = "Purchase";
|
|
1097
1231
|
return TiktokPixelEvent2;
|
|
1098
1232
|
})(TiktokPixelEvent || {});
|
|
1099
1233
|
var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
|
|
@@ -1249,11 +1383,13 @@ export {
|
|
|
1249
1383
|
generatePublicIntegrationsDataGoogleTag,
|
|
1250
1384
|
generatePublicIntegrationsDataMetaPixel,
|
|
1251
1385
|
generatePublicIntegrationsDataTiktokPixel,
|
|
1386
|
+
generatePublicStoreIntegrationAi,
|
|
1252
1387
|
generatePublicStoreIntegrationGoogleAnalytics,
|
|
1253
1388
|
generatePublicStoreIntegrationGoogleSheet,
|
|
1254
1389
|
generatePublicStoreIntegrationGoogleTags,
|
|
1255
1390
|
generatePublicStoreIntegrationMetaPixel,
|
|
1256
1391
|
generatePublicStoreIntegrationOrderdz,
|
|
1392
|
+
generatePublicStoreIntegrationSecurity,
|
|
1257
1393
|
generatePublicStoreIntegrationTiktokPixel,
|
|
1258
1394
|
generatePublicStoreIntegrationWebhooks,
|
|
1259
1395
|
generatePublicStoreIntegrations,
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/feeef/feeef.ts","../src/feeef/repositories/repository.ts","../src/feeef/repositories/orders.ts","../src/feeef/repositories/products.ts","../src/feeef/repositories/stores.ts","../src/feeef/repositories/users.ts","../src/feeef/repositories/deposits.ts","../src/core/entities/order.ts","../src/core/entities/shipping_method.ts","../src/feeef/services/service.ts","../src/feeef/services/cart.ts","../src/core/entities/store.ts","../src/core/entities/product.ts","../src/core/embadded/contact.ts","../src/utils.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios'\n// import { buildMemoryStorage, buildWebStorage, setupCache } from 'axios-cache-interceptor'\nimport { OrderRepository } from './repositories/orders.js'\nimport { ProductRepository } from './repositories/products.js'\nimport { StoreRepository } from './repositories/stores.js'\nimport { UserRepository } from './repositories/users.js'\nimport { DepositRepository } from './repositories/deposits.js'\nimport { CartService } from './services/cart.js'\n\n/**\n * Configuration options for the FeeeF module.\n */\nexport interface FeeeFConfig {\n /**\n * The API key to be used for authentication.\n */\n apiKey: string\n\n /**\n * An optional Axios instance to be used for making HTTP requests.\n */\n client?: AxiosInstance\n\n /**\n * Specifies whether caching should be enabled or disabled.\n * If set to a number, it represents the maximum number of seconds to cache the responses.\n * If set to `false`, caching will be disabled (5s).\n * cannot be less than 5 seconds\n */\n cache?: false | number\n\n /**\n * The base URL for the API.\n */\n baseURL?: string\n}\n\n/**\n * Represents the FeeeF class.\n */\nexport class FeeeF {\n /**\n * The API key used for authentication.\n */\n apiKey: string\n\n /**\n * The Axios instance used for making HTTP requests.\n */\n client: AxiosInstance\n\n /**\n * The repository for managing stores.\n */\n stores: StoreRepository\n\n /**\n * The repository for managing products.\n */\n products: ProductRepository\n\n /**\n * The repository for managing users.\n */\n users: UserRepository\n\n /**\n * The repository for managing orders.\n */\n orders: OrderRepository\n\n /**\n * The repository for managing deposits.\n */\n deposits: DepositRepository\n\n /**\n * The cart service for managing the cart.\n */\n cart: CartService\n\n /**\n * Constructs a new instance of the FeeeF class.\n * @param {FeeeFConfig} config - The configuration object.\n * @param {string} config.apiKey - The API key used for authentication.\n * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.\n * @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.\n */\n //\n constructor({ apiKey, client, cache, baseURL = 'http://localhost:3333/api/v1' }: FeeeFConfig) {\n console.log('feeef super cache', cache)\n this.apiKey = apiKey\n // get th \"cache\" search param\n // const urlParams = new URLSearchParams(window.location.search)\n // const cacheParam = urlParams.get('cache')\n // if is 0 or false, disable cache\n // if (cacheParam == '0') {\n this.client = client || axios\n // } else {\n // this.client = setupCache(client || axios, {\n // ttl: cache === false ? 5 : Math.max(cache!, 5) || 1 * 60 * 1000, // 1 minute by default\n // // for persistent cache use buildWebStorage\n // storage: buildWebStorage(localStorage, 'ff:'),\n // })\n // }\n // set base url\n this.client.defaults.baseURL = baseURL\n this.stores = new StoreRepository(this.client)\n this.products = new ProductRepository(this.client)\n this.users = new UserRepository(this.client)\n this.orders = new OrderRepository(this.client)\n this.deposits = new DepositRepository(this.client)\n\n // cart\n this.cart = new CartService()\n }\n}\n","import { AxiosInstance } from 'axios'\n\n/**\n * Represents a generic model repository.\n * @template T - The type of the model.\n * @template C - The type of the create options.\n * @template U - The type of the update options.\n */\nexport abstract class ModelRepository<T, C, U> {\n resource: string\n // client\n client: AxiosInstance\n\n /**\n * Constructs a new instance of the ModelRepository class.\n * @param resource - The resource name.\n * @param client - The Axios instance used for making HTTP requests.\n */\n constructor(resource: string, client: AxiosInstance) {\n this.resource = resource\n this.client = client\n }\n\n /**\n * Finds a model by its ID or other criteria.\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async find(options: ModelFindOptions): Promise<T> {\n const { id, by, params } = options\n const res = await this.client.get(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n return res.data\n }\n\n /**\n * Lists models with optional pagination and filtering.\n * @param options - The options for listing the models.\n * @returns A promise that resolves to a list of models.\n */\n async list(options?: ModelListOptions): Promise<ListResponse<T>> {\n const { page, offset, limit, params } = options || {}\n const res = await this.client.get(`/${this.resource}`, {\n params: { page, offset, limit, ...params },\n })\n // if res.data is an array then create ListResponse\n if (Array.isArray(res.data)) {\n return {\n data: res.data,\n }\n } else {\n return {\n data: res.data.data,\n total: res.data.meta.total,\n page: res.data.meta.currentPage,\n limit: res.data.meta.perPage,\n }\n }\n }\n\n /**\n * Creates a new model.\n * @param options - The options for creating the model.\n * @returns A promise that resolves to the created model.\n */\n async create(options: ModelCreateOptions<C>): Promise<T> {\n const { data, params } = options\n const res = await this.client.post(`/${this.resource}`, data, { params })\n return res.data\n }\n\n /**\n * Updates an existing model.\n * @param options - The options for updating the model.\n * @returns A promise that resolves to the updated model.\n */\n async update(options: ModelUpdateOptions<U>): Promise<T> {\n const { id, data, params } = options\n const res = await this.client.put(`/${this.resource}/${id}`, data, {\n params,\n })\n return res.data\n }\n\n /**\n * Deletes a model by its ID or other criteria.\n * @param options - The options for deleting the model.\n * @returns A promise that resolves when the model is deleted.\n */\n async delete(options: ModelFindOptions): Promise<void> {\n const { id, by, params } = options\n await this.client.delete(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n }\n}\n\n/**\n * Represents a list response containing an array of data of type T.\n */\nexport interface ListResponse<T> {\n data: T[]\n total?: number\n page?: number\n limit?: number\n}\n\n/**\n * Represents the options for making a request.\n */\ninterface RequestOptions {\n params?: Record<string, any>\n}\n\nexport interface ModelFindOptions extends RequestOptions {\n /**\n * The ID of the model to find or the value to find by.\n */\n id: string\n /**\n * The field to find by.\n * @default \"id\" - The ID field.\n */\n by?: string\n}\n\n/**\n * Options for listing models.\n */\nexport interface ModelListOptions extends RequestOptions {\n /**\n * The page number to retrieve.\n */\n page?: number\n\n /**\n * The offset from the beginning of the list.\n */\n offset?: number\n\n /**\n * The maximum number of models to retrieve per page.\n */\n limit?: number\n}\n\n/**\n * Represents the options for creating a model.\n * @template T - The type of data being created.\n */\nexport interface ModelCreateOptions<T> extends RequestOptions {\n data: T\n}\n\n/**\n * Represents the options for updating a model.\n * @template T - The type of the data being updated.\n */\nexport interface ModelUpdateOptions<T> extends RequestOptions {\n /**\n * The ID of the model to update.\n */\n id: string\n /**\n * The data to update the model with.\n */\n data: T\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { OrderEntity, OrderTrackEntity, ShippingType } from '../../core/entities/order.js'\n/**\n * Represents the options for tracking an order.\n */\nexport interface OrderModelTrackOptions {\n id: string\n params?: Record<string, any>\n}\n\nexport interface SendOrderSchema {\n id?: string // Order ID (optional)\n customerName?: string // Name of the customer (optional)\n customerNote?: string // Note from the customer (optional)\n customerPhone: string // Customer's phone number (required)\n customerEmail?: string // Customer's email address (optional)\n source?: string // the source of the order (facebook...tiktok..)\n shippingAddress?: string // Address for shipping (optional)\n shippingCity?: string // City for shipping (optional)\n shippingState?: string // State for shipping (optional)\n shippingType: ShippingType // Shipping type (required)\n shippingMethodId?: string // ID of the shipping method (optional)\n paymentMethodId?: string // ID of the payment method (optional)\n items: GuestOrderItemSchema[] // Array of order items, must have at least one item\n coupon?: string // Applied coupon code (optional)\n status: 'pending' | 'draft' // Order status (required)\n storeId: string // ID of the store (required)\n metadata?: any // Additional metadata (optional)\n}\n\n// Assuming GuestOrderItemSchema was defined elsewhere, define it here as well if needed.\nexport interface GuestOrderItemSchema {\n productId: string\n offerCode?: string\n variantPath?: string\n quantity: number\n addons?: Record<string, number>\n}\n\n/**\n * Represents a repository for managing orders.\n */\nexport class OrderRepository extends ModelRepository<OrderEntity, any, any> {\n /**\n * Constructs a new OrderRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('orders', client)\n }\n\n /**\n * Sends an order from an anonymous user.\n * @param data - The data representing the order to be sent.\n * @returns A Promise that resolves to the sent OrderEntity.\n */\n async send(data: SendOrderSchema): Promise<OrderEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n\n // Return the sent OrderEntity\n return res.data\n }\n\n /**\n * track the order by the order id\n * it will return the order status and history\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async track(options: OrderModelTrackOptions): Promise<OrderTrackEntity> {\n const { id, params } = options\n const res = await this.client.get(`/${this.resource}/${id}/track`, {\n params: {\n ...params,\n },\n })\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { ProductEntity } from '../../core/entities/product.js'\n\n/**\n * Represents a repository for managing products.\n */\nexport class ProductRepository extends ModelRepository<ProductEntity, any, any> {\n /**\n * Creates a new instance of the ProductRepository class.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('products', client)\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository, ModelCreateOptions } from './repository.js'\nimport { StoreEntity } from '../../core/entities/store.js'\n\n/**\n * Repository for managing Store entities.\n */\nexport class StoreRepository extends ModelRepository<StoreEntity, any, any> {\n /**\n * Constructs a new StoreRepository instance.\n * @param client The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('stores', client)\n }\n\n /**\n * Creates a new Store entity.\n * @param options The options for creating the Store entity.\n * @returns A Promise that resolves to the created Store entity.\n */\n async create(options: ModelCreateOptions<any>): Promise<StoreEntity> {\n const output = options.data\n return super.create({ ...options, data: output })\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { AuthToken, UserEntity } from '../../core/entities/user.js'\n\n/**\n * Represents the response returned by the authentication process.\n */\nexport interface AuthResponse {\n token: AuthToken\n user: UserEntity\n}\n\n/**\n * Represents a repository for managing user data.\n * Extends the ModelRepository class.\n */\nexport class UserRepository extends ModelRepository<UserEntity, any, any> {\n /**\n * Represents the authentication response.\n */\n auth: AuthResponse | null = null\n\n /**\n * Constructs a new UserRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('users', client)\n }\n\n /**\n * Signs in a user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signin(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signin`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs up a new user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signup(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signup`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs out the currently authenticated user.\n * @returns A promise that resolves when the user is signed out.\n */\n async signout(): Promise<void> {\n this.auth = null\n }\n\n /**\n * Updates the authenticated user's data.\n * @param data - The updated user data.\n * @returns A promise that resolves to the updated user entity.\n */\n async updateMe(data: any): Promise<UserEntity> {\n const output = data\n const res = await this.client.put(`/${this.resource}/auth`, output)\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\n\n/**\n * Represents a deposit entity for wallet transactions\n */\nexport interface DepositEntity {\n id: string\n externalId?: string | null\n userId: string\n amount: number\n currency: string\n paymentMethod?: string | null\n attachment?: string | null\n status: 'pending' | 'completed' | 'failed' | 'cancelled'\n note?: string | null\n metadata: Record<string, any>\n history: Array<{\n status: string\n timestamp: string\n note?: string\n }>\n createdAt: any\n updatedAt: any\n}\n\n/**\n * Input data for creating a new deposit\n */\nexport interface DepositCreateInput {\n id?: string\n externalId?: string\n amount: number\n currency?: string\n paymentMethod?: string\n attachment?: string\n note?: string\n metadata?: Record<string, any>\n}\n\n/**\n * PayPal order creation response\n */\nexport interface PayPalOrderResponse {\n id: string\n status: string\n approvalUrl?: string\n links: Array<{\n href: string\n rel: string\n method: string\n }>\n}\n\n/**\n * PayPal order capture response\n */\nexport interface PayPalCaptureResponse {\n id: string\n status: string\n captureId?: string\n amount?: number\n currency?: string\n}\n\n/**\n * Repository for managing deposit data and PayPal integration\n */\nexport class DepositRepository extends ModelRepository<DepositEntity, DepositCreateInput, any> {\n /**\n * Constructs a new DepositRepository instance\n * @param client - The AxiosInstance used for making HTTP requests\n */\n constructor(client: AxiosInstance) {\n super('deposits', client)\n }\n\n /**\n * Create a new deposit request\n * @param data - The deposit data\n * @returns Promise that resolves to the created deposit\n */\n async send(data: DepositCreateInput): Promise<DepositEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n return res.data\n }\n\n /**\n * Create a PayPal order for deposit\n * @param params - PayPal order parameters\n * @returns Promise that resolves to PayPal order details\n */\n async createPayPalOrder(params: {\n amount: number\n currency?: string\n depositId?: string\n returnUrl: string\n cancelUrl: string\n }): Promise<PayPalOrderResponse> {\n const orderData = {\n amount: params.amount,\n currency: params.currency || 'USD',\n depositId: params.depositId,\n returnUrl: params.returnUrl,\n cancelUrl: params.cancelUrl,\n }\n\n const res = await this.client.post(`/${this.resource}/paypal/create-order`, orderData)\n\n // Extract approval URL from links\n const approvalLink = res.data.links?.find((link: any) => link.rel === 'approve')\n\n return {\n id: res.data.id,\n status: res.data.status,\n approvalUrl: approvalLink?.href,\n links: res.data.links || [],\n }\n }\n\n /**\n * Capture a PayPal order after user approval\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to capture details\n */\n async capturePayPalOrder(orderId: string): Promise<PayPalCaptureResponse> {\n const res = await this.client.post(`/${this.resource}/paypal/capture-order`, {\n orderId,\n })\n return res.data\n }\n\n /**\n * Get PayPal order status\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to order details\n */\n async getPayPalOrderStatus(orderId: string): Promise<{\n id: string\n status: string\n amount?: number\n currency?: string\n }> {\n const res = await this.client.get(`/${this.resource}/paypal/order/${orderId}`)\n return res.data\n }\n}\n","export enum OrderStatus {\n draft = 'draft',\n pending = 'pending',\n review = 'review',\n accepted = 'accepted',\n processing = 'processing',\n completed = 'completed',\n cancelled = 'cancelled',\n}\n\n// PaymentStatus\nexport enum PaymentStatus {\n unpaid = 'unpaid',\n paid = 'paid',\n received = 'received',\n}\nexport enum DeliveryStatus {\n pending = 'pending',\n delivering = 'delivering',\n delivered = 'delivered',\n returned = 'returned',\n}\n\nexport enum ShippingType {\n // delivery to customer home\n home = 'home',\n // the customer picks up the order from the local shipping center\n pickup = 'pickup',\n // the customer picks up the order from the store\n store = 'store',\n}\n\nexport interface OrderEntity {\n id: string\n customerName?: string | null\n customerPhone: string\n customerEmail?: string | null\n customerIp?: string | null\n shippingAddress?: string | null\n shippingCity?: string | null\n shippingState?: string | null\n shippingMethodId?: string | null\n shippingType: ShippingType\n paymentMethodId?: string | null\n items: OrderItem[]\n subtotal: number\n shippingPrice: number\n total: number\n discount: number\n // @Deprecated\n coupon?: string | null\n couponId?: string | null\n couponCode?: string | null\n couponDiscount?: string | null\n storeId: string\n confirmerId: string | null\n metadata: OrderMetadata\n status: OrderStatus\n paymentStatus: PaymentStatus\n deliveryStatus: DeliveryStatus\n tags: string[] | null\n createdAt: any\n updatedAt: any\n}\nexport interface OrderItem {\n productId: string\n productName: string\n productPhotoUrl?: string | null\n variantPath?: string\n sku?: string | null\n discount?: number | null\n quantity: number\n price: number\n offerCode?: string | null\n offerName?: string | null\n addons?: Record<string, number>\n}\n\n// order track entity\nexport interface OrderTrackEntity {\n id: string\n customerName?: string | null\n items: OrderItem[]\n total: number\n createdAt: any\n storeId: string\n status: OrderStatus\n history: OrderTrackHistory[]\n}\n\n// order track history\nexport interface OrderTrackHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n}\n\n// order metadata history\ninterface OrderMetadataHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n message: string\n code: string\n userId: string\n}\n\n// order metadata\ninterface OrderMetadata {\n note?: string\n history?: OrderMetadataHistory[]\n metaPixel?: any\n customOrderTagHistories?: any[]\n [key: string]: any\n}\n\n// utils\n// order entity to order track entity\nexport const convertOrderEntityToOrderTrackEntity = (order: OrderEntity): OrderTrackEntity => {\n return {\n id: order.id,\n customerName: order.customerName,\n items: order.items,\n total: order.total,\n createdAt: order.createdAt,\n storeId: order.storeId,\n status: order.status,\n history:\n order.metadata.history?.map((history) => ({\n status: history.status,\n deliveryStatus: history.deliveryStatus,\n paymentStatus: history.paymentStatus,\n createdAt: history.createdAt,\n })) || [],\n }\n}\n","import { OrderEntity } from './order.js'\n\nexport interface ShippingMethodEntity {\n id: string\n name: string\n description: string | null\n logoUrl: string | null\n ondarkLogoUrl: string | null\n price: number\n forks: number\n sourceId: string\n storeId: string\n rates: (number | null)[][] | null\n status: ShippingMethodStatus\n policy: ShippingMethodPolicy\n verifiedAt: any\n createdAt: any\n updatedAt: any\n orders: OrderEntity[]\n source: ShippingMethodEntity | null\n}\n\nexport enum ShippingMethodStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n}\n\nexport enum ShippingMethodPolicy {\n private = 'private',\n public = 'public',\n}\n","export type Listener<T extends NotifiableService> = (service: T) => void\n\nexport class NotifiableService {\n // Array of listeners (functions) to notify when changes occur\n private listeners: Set<Listener<typeof this>> = new Set()\n\n /**\n * Adds a listener that gets called when `notify` is triggered.\n * @param listener - The function to be called on notification.\n * @returns The same listener for potential chaining or removal.\n */\n addListener(listener: Listener<typeof this>): Listener<typeof this> {\n this.listeners.add(listener) // Using Set for uniqueness and faster removal\n return listener\n }\n\n /**\n * Removes a previously added listener.\n * @param listener - The function to be removed from the listeners list.\n */\n removeListener(listener: Listener<typeof this>): void {\n this.listeners.delete(listener) // Set deletion is O(1) for better performance\n }\n\n /**\n * Notifies all registered listeners, passing the service instance.\n * This allows listeners to react to changes.\n */\n notify(): void {\n // Iterating over the Set of listeners and invoking each one\n this.listeners.forEach((listener) => listener(this))\n }\n\n /**\n * Clears all listeners, removing any references to them.\n */\n clearListeners(): void {\n this.listeners.clear() // Clears the Set entirely\n }\n\n /**\n * Constructor for NotifiableService, initializes listeners as an empty Set.\n * The Set ensures unique listeners and better management.\n */\n constructor() {\n // Initialization can be skipped since listeners is already initialized as an empty Set\n }\n}\n","import { ShippingType } from '../../core/entities/order.js'\nimport { ProductEntity, ProductOffer } from '../../core/entities/product.js'\nimport {\n ShippingMethodEntity,\n ShippingMethodPolicy,\n ShippingMethodStatus,\n} from '../../core/entities/shipping_method.js'\nimport { StoreEntity } from '../../core/entities/store.js'\nimport { NotifiableService } from './service.js'\n\n/**\n * Represents an item in the cart.\n */\nexport interface CartItem {\n product: ProductEntity\n offer?: ProductOffer\n quantity: number\n variantPath?: string\n addons?: Record<string, number>\n}\n\n/**\n * Cart shipping types.\n * - `pickup`: The user will pick up the order from the closest desk.\n * - `home`: The order will be delivered to the user's home.\n * - `store`: The order will be delivered to the store.\n */\n// export type CartShippingTypes = 'pickup' | 'home' | 'store'\n\n/**\n * Interface for a shipping address.\n */\nexport interface CartShippingAddress {\n name: string | null\n phone: string | null\n city: string | null\n state: string | null\n street: string | null\n country: 'dz' | string\n type: ShippingType\n}\n\n/**\n * Manages the shopping cart and its operations.\n */\nexport class CartService extends NotifiableService {\n private items: CartItem[] = [] // Array to support multiple items with same product but different variants\n private shippingMethod: ShippingMethodEntity | null = null\n private shippingAddress: CartShippingAddress = {\n name: null,\n phone: null,\n city: null,\n state: null,\n street: null,\n country: 'dz',\n type: ShippingType.pickup,\n }\n private cachedSubtotal: number | null = null // Cache for subtotal to avoid redundant calculations\n private currentItem: CartItem | null = null\n\n /**\n * Generates a unique key for a cart item based on product ID, variant path, offer code, and addons\n * @param item - The cart item to generate a key for\n * @returns A unique string key\n */\n private getItemKey(item: CartItem): string {\n const addonKeys = item.addons ? Object.keys(item.addons).sort().join('|') : ''\n return `${item.product.id}:${item.variantPath || ''}:${item.offer?.code || ''}:${addonKeys}`\n }\n\n /**\n * Finds an item in the cart that matches the given item's key\n * @param item - The item to find\n * @returns The matching cart item or undefined\n */\n private findItem(item: CartItem): CartItem | undefined {\n const targetKey = this.getItemKey(item)\n return this.items.find((cartItem) => this.getItemKey(cartItem) === targetKey)\n }\n\n /**\n * Finds the index of an item in the cart that matches the given item's key\n * @param item - The item to find\n * @returns The index of the matching cart item or -1 if not found\n */\n private findItemIndex(item: CartItem): number {\n const targetKey = this.getItemKey(item)\n return this.items.findIndex((cartItem) => this.getItemKey(cartItem) === targetKey)\n }\n\n /**\n * Sets the current item to be managed in the cart.\n * @param item - The item to be set as current.\n */\n setCurrentItem(item: CartItem, notify = true): void {\n this.currentItem = item\n\n const existingItemIndex = this.findItemIndex(this.currentItem)\n if (existingItemIndex !== -1) {\n this.items[existingItemIndex] = this.currentItem\n }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Clamps the quantity to be within the offer's min/max range\n * @param offer - The offer containing quantity constraints\n * @param quantity - The quantity to clamp\n * @returns The clamped quantity value\n */\n private clampQuantityToOfferLimits(offer: ProductOffer, quantity: number): number {\n if (offer.minQuantity !== undefined) {\n quantity = Math.max(quantity, offer.minQuantity)\n }\n if (offer.maxQuantity !== undefined) {\n quantity = Math.min(quantity, offer.maxQuantity)\n }\n return quantity\n }\n\n /**\n * Update item by unique key (product ID + variant + offer + addons).\n * @param item - The item to identify the cart item to update.\n * @param updates - Partial item data to update.\n */\n updateItem(item: CartItem, updates: Partial<CartItem>, notify = true): void {\n const index = this.findItemIndex(item)\n\n if (index !== -1) {\n const currentItem = this.items[index]\n const newItem = { ...currentItem, ...updates }\n\n // Clamp quantity if there's an offer with constraints\n if (newItem.offer) {\n newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity)\n }\n\n this.items[index] = newItem\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Update current item.\n * @param updates - a partial item to update.\n */\n updateCurrentItem(updates: Partial<CartItem>, notify = true): void {\n if (!this.currentItem) return\n\n this.currentItem = { ...this.currentItem, ...updates }\n\n const existingItemIndex = this.findItemIndex(this.currentItem)\n if (existingItemIndex !== -1) {\n this.items[existingItemIndex] = this.currentItem\n }\n\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping address.\n * @param address - a partial address to update.\n */\n updateShippingAddress(address: Partial<CartShippingAddress>, notify = true): void {\n this.shippingAddress = { ...this.shippingAddress, ...address }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping method.\n * @param method - a partial shipping method to update.\n */\n updateShippingMethod(method: Partial<ShippingMethodEntity>, notify = true): void {\n if (!this.shippingMethod) return\n\n this.shippingMethod = { ...this.shippingMethod, ...method }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Retrieves the current item in the cart.\n * @returns The current cart item or null if not set.\n */\n getCurrentItem(): CartItem | null {\n return this.currentItem\n }\n\n /**\n * Checks if the current item is already in the cart.\n * @returns True if the current item is in the cart, false otherwise.\n */\n isCurrentItemInCart(): boolean {\n return this.currentItem ? this.findItem(this.currentItem) !== undefined : false\n }\n\n /**\n * Adds the current item to the cart if it's not already present.\n */\n addCurrentItemToCart(): void {\n if (!this.currentItem || this.isCurrentItemInCart()) return\n this.add(this.currentItem)\n this.cachedSubtotal = null\n }\n\n /**\n * Removes the current item from the cart if present.\n */\n removeCurrentItemFromCart(): void {\n if (this.currentItem) {\n this.remove(this.currentItem)\n }\n }\n\n /**\n * Toggles the current item's presence in the cart (add/remove).\n */\n toggleCurrentItemInCart(): void {\n this.isCurrentItemInCart() ? this.removeCurrentItemFromCart() : this.addCurrentItemToCart()\n }\n\n /**\n * Adds an item to the cart. If the item is already present, increments its quantity.\n * @param item - The cart item to add.\n */\n add(item: CartItem): void {\n const existingItem = this.findItem(item)\n\n if (existingItem) {\n existingItem.quantity += item.quantity\n } else {\n this.items.push({ ...item })\n }\n\n this.cachedSubtotal = null // Reset subtotal cache\n this.notifyIfChanged()\n }\n\n /**\n * Checks if an item exists in the cart by matching product ID and variant path.\n * @param productId - The product ID to check for.\n * @param variantPath - The variant path to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(productId: string, variantPath?: string): boolean {\n return this.items.some((item) => {\n if (item.product.id !== productId) return false\n if (variantPath !== undefined && item.variantPath !== variantPath) return false\n return true\n })\n }\n\n /**\n * Checks if an item exists in the cart by matching the item's unique key.\n * @param item - The item to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n hasItem(item: CartItem): boolean {\n return this.findItem(item) !== undefined\n }\n\n /**\n * Checks if any item with the given product ID exists in the cart.\n * @param productId - The product ID to check for.\n * @returns True if any item with the product ID exists, false otherwise.\n */\n hasProduct(productId: string): boolean {\n return this.items.some((item) => item.product.id === productId)\n }\n\n /**\n * Removes an item from the cart by matching the item's unique key.\n * @param item - The item to remove.\n */\n remove(item: CartItem): void {\n const index = this.findItemIndex(item)\n if (index !== -1) {\n this.items.splice(index, 1)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Removes all items with the given product ID from the cart.\n * @param productId - The product ID to remove.\n */\n removeByProductId(productId: string, variantPath?: string): void {\n const initialLength = this.items.length\n this.items = this.items.filter((item) => {\n if (item.product.id !== productId) return true\n if (variantPath !== undefined && item.variantPath !== variantPath) return true\n return false\n })\n\n if (this.items.length !== initialLength) {\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Clears all items from the cart.\n */\n clear(notify = true): void {\n if (this.items.length > 0) {\n this.items = []\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the subtotal of the cart.\n * @param withCurrentItem - Whether to include the current item in the subtotal.\n * @returns The subtotal amount.\n */\n getSubtotal(withCurrentItem = true): number {\n if (this.cachedSubtotal === null) {\n this.cachedSubtotal = this.items.reduce((sum, item) => {\n return sum + this.getItemTotal(item)\n }, 0)\n }\n\n if (withCurrentItem && this.currentItem && !this.hasItem(this.currentItem)) {\n return this.cachedSubtotal + this.getItemTotal(this.currentItem)\n }\n\n return this.cachedSubtotal\n }\n\n /**\n * Calculates the total price for a cart item.\n * @param item - The cart item.\n * @returns The total price for the item.\n */\n getItemTotal(item: CartItem): number {\n const { product, variantPath, quantity, offer, addons } = item\n let price = product.price\n let discount = product.discount ?? 0\n\n // Handle variant pricing if a variant path exists\n if (variantPath) {\n const parts = variantPath.split('/')\n let currentVariant = product.variant\n\n for (const part of parts) {\n if (!currentVariant) break\n const option = currentVariant.options.find((o) => o.name === part)\n if (!option) break\n price = option.price ?? price\n discount = option.discount ?? discount\n currentVariant = option.child\n }\n }\n\n // Apply offer if present\n if (offer) {\n if (offer.price !== undefined) {\n // If offer has a fixed price, use it\n price = offer.price\n discount = 0 // Reset discount since we're using a fixed price\n }\n }\n\n // Calculate base product price with quantity\n let total = (price - discount) * quantity\n\n // Add pricing for addons if present\n if (addons && product.addons) {\n for (const [addonId, addonQuantity] of Object.entries(addons)) {\n // Find the addon in the product's addons array\n const addon = product.addons.find((a) => a.title === addonId)\n if (addon && addon.price) {\n // Add the addon price * quantity to the total\n total += addon.price * addonQuantity\n }\n }\n }\n\n return total\n }\n\n /**\n * Validates if an offer can be applied to the given quantity\n * @param offer - The offer to validate\n * @param quantity - The quantity to check\n * @returns boolean indicating if the offer is valid for the quantity\n */\n isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean {\n if (offer.minQuantity && quantity < offer.minQuantity) return false\n if (offer.maxQuantity && quantity > offer.maxQuantity) return false\n return true\n }\n\n /**\n * Updates the offer for a specific cart item\n * @param item - The item to update\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateItemOffer(item: CartItem, offer?: ProductOffer): void {\n const existingItem = this.findItem(item)\n if (!existingItem) return\n\n const updatedItem = { ...existingItem, offer }\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, existingItem.quantity)\n }\n\n this.updateItem(item, updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Updates the offer for the current item\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateCurrentItemOffer(offer?: ProductOffer): void {\n if (!this.currentItem) return\n\n const updatedItem = { ...this.currentItem }\n updatedItem.offer = offer\n\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, this.currentItem.quantity)\n }\n\n this.updateCurrentItem(updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Sets the shipping method.\n * @param method - Either a store or a shipping method.\n */\n setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify = true): void {\n const store = (method as StoreEntity)?.defaultShippingRates ? (method as StoreEntity) : null\n const shippingMethod = (method as ShippingMethodEntity)?.rates\n ? (method as ShippingMethodEntity)\n : null\n\n if (store) {\n this.shippingMethod = {\n id: store.id,\n name: store.name,\n description: store.description,\n logoUrl: store.logoUrl,\n ondarkLogoUrl: store.ondarkLogoUrl,\n price: 0,\n forks: 0,\n sourceId: store.id,\n storeId: store.id,\n rates: store.defaultShippingRates,\n status: ShippingMethodStatus.published,\n policy: ShippingMethodPolicy.public,\n verifiedAt: null,\n createdAt: null,\n updatedAt: null,\n orders: [],\n source: null,\n }\n if (notify) {\n this.notify()\n }\n } else if (shippingMethod) {\n this.shippingMethod = shippingMethod\n if (notify) {\n this.notify()\n }\n } else {\n throw new Error('Invalid shipping method')\n }\n }\n\n // getAvailableShippingTypes\n /**\n * Retrieves the available shipping types for the current shipping method.\n *\n * rates is a 2D array for example `[[10, 20, 30], [5, 10, 15]]`\n * where the first array is for `home` fees and the second is for `pickup` fees, and the third is for `store` fees\n * if the fee value is 0, then it's free shipping, and if it's null, then it's not available\n *\n * @returns An array of available shipping types.\n */\n getAvailableShippingTypes(): ShippingType[] {\n if (!this.shippingMethod?.rates) return []\n\n var state = Number.parseInt(this.shippingAddress.state!)\n var stateRates = this.shippingMethod.rates[state - 1]\n\n if (!stateRates) return []\n\n var availableTypes: ShippingType[] = []\n\n if (stateRates[0] || stateRates[0] === 0) availableTypes.push(ShippingType.pickup)\n if (stateRates[1] || stateRates[1] === 0) availableTypes.push(ShippingType.home)\n if (stateRates[2] || stateRates[2] === 0) availableTypes.push(ShippingType.store)\n\n return availableTypes\n }\n\n /**\n * Retrieves the current shipping method.\n * @returns The shipping method or null.\n */\n getShippingMethod(): ShippingMethodEntity | null {\n return this.shippingMethod\n }\n\n /**\n * Sets the shipping address for the cart.\n * @param address - The shipping address.\n */\n setShippingAddress(address: CartShippingAddress, notify = true): void {\n if (\n this.shippingAddress.city !== address.city ||\n this.shippingAddress.state !== address.state ||\n this.shippingAddress.type !== address.type\n ) {\n this.shippingAddress = address\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the current shipping address.\n * @returns The shipping address.\n */\n getShippingAddress(): CartShippingAddress {\n return this.shippingAddress\n }\n\n /**\n * Calculates the shipping price based on the address and shipping method.\n * @returns The shipping price or 0 if not applicable.\n */\n getShippingPrice(): number {\n // if at least one item have freeShipping offer return 0\n for (const item of this.items) {\n if (item.offer?.freeShipping) return 0\n }\n\n // if no shipping method is set, return 0\n if (!this.shippingMethod) return 0\n\n // if no shipping address is set, return the shipping method price\n if (!this.shippingAddress.state) return this.shippingMethod.price ?? 0\n\n // avalable shipping types\n const shippings = this.getAvailableShippingTypes()\n\n const currentOne = this.getShippingPriceForType(this.shippingAddress.type)\n if (currentOne) {\n return currentOne\n }\n\n for (const type of shippings) {\n if (this.getShippingPriceForType(type) !== null) {\n return this.getShippingPriceForType(type)!\n }\n }\n\n return 0\n }\n\n /**\n * Gets the shipping price for a specific shipping type using the current shipping address state.\n * @param type - The shipping type to check (pickup, home, store)\n * @returns The shipping price for the specified type, or null if not available\n */\n getShippingPriceForType(type: ShippingType): number | null {\n if (!this.shippingMethod?.rates || !this.shippingAddress.state) return null\n\n const stateIndex = Number.parseInt(this.shippingAddress.state, 10) - 1\n const rates = this.shippingMethod.rates[stateIndex]\n\n if (!rates) return null\n\n switch (type) {\n case ShippingType.pickup:\n return rates[0]\n case ShippingType.home:\n return rates[1]\n case ShippingType.store:\n return rates[2]\n default:\n return null\n }\n }\n\n /**\n * Calculates the total cost of the cart including shipping.\n * @param withCurrentItem - Whether to include the current item in the total.\n * @returns The total cost.\n */\n getTotal(withCurrentItem = true): number {\n const subTotal = this.getSubtotal(withCurrentItem)\n const shippingPrice = this.getShippingPrice() ?? 0\n const selectedOffer = this.currentItem?.offer\n if (selectedOffer && selectedOffer.freeShipping) {\n return subTotal // If the current item has free shipping, return subtotal only\n }\n return subTotal + shippingPrice\n }\n\n /**\n * Retrieves all items in the cart.\n * @returns An array of cart items.\n */\n getAll(): CartItem[] {\n return [...this.items] // Return a copy to prevent external modification\n }\n\n /**\n * Checks if the cart is empty.\n * @returns True if the cart is empty, otherwise false.\n */\n isEmpty(): boolean {\n return this.items.length === 0\n }\n\n /**\n * Notifies listeners if the cart state has meaningfully changed.\n */\n private notifyIfChanged(): void {\n // This method could be enhanced to track and notify only meaningful changes\n this.notify()\n }\n}\n","import { EmbaddedAddress } from '../embadded/address.js'\nimport { EmbaddedCategory } from '../embadded/category.js'\nimport { EmbaddedContact } from '../embadded/contact.js'\nimport { OrderEntity } from './order.js'\nimport { MetaPixelEvent } from './product.js'\n// import { OrderEntity } from \"./order.js\";\n// import { ShippingMethodEntity } from \"./shipping_method.js\";\nimport { UserEntity } from './user.js'\nimport { DateTime } from 'luxon'\n\nexport interface StoreEntity {\n id: string\n slug: string\n banner: StoreBanner | null\n action: StoreAction | null\n domain: StoreDomain | null\n decoration: StoreDecoration | null\n name: string\n iconUrl: string | null\n logoUrl: string | null\n // deprecated\n ondarkLogoUrl: string | null\n userId: string\n categories: EmbaddedCategory[]\n title: string | null\n description: string | null\n addresses: EmbaddedAddress[]\n address: EmbaddedAddress | null\n metadata: Record<string, any>\n contacts: EmbaddedContact[]\n integrations?: StoreIntegrations | null\n publicIntegrations: PublicStoreIntegrations | null\n verifiedAt: any | null\n blockedAt: any | null\n createdAt: any\n updatedAt: any\n // products: ProductEntity[];\n user?: UserEntity\n // orders: OrderEntity[];\n // shippingMethods: ShippingMethodEntity[];\n defaultShippingRates: (number | null)[][] | null\n\n // subscription\n subscription?: any\n due?: number\n\n // StoreConfigs\n configs?: StoreConfigs\n\n // metaPixelIds\n metaPixelIds?: string[] | null\n\n // tiktokPixelIds\n tiktokPixelIds?: string[] | null\n\n // googleAnalyticsId\n googleAnalyticsId?: string | null\n\n // googleTagsId\n googleTagsId?: string | null\n\n // members\n members?: Record<string, StoreMember>\n}\n\n// function that generate public data from the integrations data\nexport const generatePublicStoreIntegrations = (\n integrations: StoreIntegrations | null | undefined\n): PublicStoreIntegrations | null => {\n if (!integrations) return null\n const { metaPixel, tiktokPixel, googleAnalytics, googleTags, orderdz, webhooks } = integrations\n return {\n metaPixel: generatePublicStoreIntegrationMetaPixel(metaPixel) || null,\n tiktokPixel: generatePublicStoreIntegrationTiktokPixel(tiktokPixel) || null,\n googleAnalytics: generatePublicStoreIntegrationGoogleAnalytics(googleAnalytics) || null,\n googleTags: generatePublicStoreIntegrationGoogleTags(googleTags) || null,\n googleSheet: null,\n orderdz: generatePublicStoreIntegrationOrderdz(orderdz) || null,\n webhooks: generatePublicStoreIntegrationWebhooks(webhooks) || null,\n }\n}\nexport const generatePublicStoreIntegrationMetaPixel = (\n metaPixel: MetaPixelIntegration | null | undefined\n): PublicMetaPixelIntegration | null | undefined => {\n if (!metaPixel) return null\n return {\n pixels: metaPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: metaPixel.active,\n objective: metaPixel.objective,\n draftObjective: metaPixel.draftObjective,\n }\n}\nexport const generatePublicStoreIntegrationTiktokPixel = (\n tiktokPixel: TiktokPixelIntegration | null | undefined\n): PublicTiktokPixelIntegration | null | undefined => {\n if (!tiktokPixel) return null\n return {\n pixels: tiktokPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: tiktokPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleAnalytics = (\n googleAnalytics: GoogleAnalyticsIntegration | null | undefined\n): PublicGoogleAnalyticsIntegration | null | undefined => {\n if (!googleAnalytics) return null\n return {\n id: googleAnalytics.id,\n active: googleAnalytics.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleSheet = (\n googleSheet: GoogleSheetsIntegration | null | undefined\n): PublicGoogleSheetsIntegration | null | undefined => {\n if (!googleSheet) return null\n return null\n}\nexport const generatePublicStoreIntegrationGoogleTags = (\n googleTags: GoogleTagsIntegration | null | undefined\n): PublicGoogleTagsIntegration | null | undefined => {\n if (!googleTags) return null\n const { id, active } = googleTags\n return {\n id,\n active,\n }\n}\n\n/**\n * Generates public OrderDZ integration data from private integration data.\n * Only exposes the URL and active status, keeping the token private for security.\n */\nexport const generatePublicStoreIntegrationOrderdz = (\n orderdz: OrderdzIntegration | null | undefined\n): PublicOrderdzIntegration | null | undefined => {\n if (!orderdz) return null\n return {\n url: orderdz.url,\n active: orderdz.active,\n }\n}\n\n/**\n * Generates public webhooks integration data from private integration data.\n * Only exposes non-sensitive information, keeping secrets private for security.\n */\nexport const generatePublicStoreIntegrationWebhooks = (\n webhooks: WebhooksIntegration | null | undefined\n): PublicWebhooksIntegration | null | undefined => {\n if (!webhooks) return null\n\n const activeWebhooks = webhooks.webhooks.filter((webhook) => webhook.active)\n\n return {\n webhookCount: webhooks.webhooks.length,\n activeWebhookCount: activeWebhooks.length,\n active: webhooks.active,\n webhookUrls: activeWebhooks.map((webhook) => webhook.url),\n }\n}\n\n/**\n * Public interface for OrderDZ integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicOrderdzIntegration {\n url: string\n active: boolean\n}\n\n/**\n * Public interface for webhooks integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicWebhooksIntegration {\n /** Total number of configured webhooks */\n webhookCount: number\n /** Number of active webhooks */\n activeWebhookCount: number\n /** Whether the integration is active */\n active: boolean\n /** List of active webhook URLs (without secrets) */\n webhookUrls: string[]\n}\n\nexport interface PublicMetaPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n}\nexport interface PublicTiktokPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicGoogleAnalyticsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleSheetsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleTagsIntegration {\n id: string\n active: boolean\n}\n\nexport interface PublicStoreIntegrations {\n metaPixel: PublicMetaPixelIntegration | null\n tiktokPixel: PublicTiktokPixelIntegration | null\n googleAnalytics: PublicGoogleAnalyticsIntegration | null\n googleSheet: PublicGoogleSheetsIntegration | null\n googleTags: PublicGoogleTagsIntegration | null\n orderdz: PublicOrderdzIntegration | null\n webhooks: PublicWebhooksIntegration | null\n}\n\nexport enum StoreMemberRole {\n editor = 'editor',\n viewer = 'viewer',\n confermer = 'confermer',\n}\n\nexport interface StoreMember {\n name: string\n userId: string\n role: StoreMemberRole\n acceptedAt: any | null\n expiredAt: any | null\n createdAt: any\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreConfigs {\n currencies: StoreCurrencyConfig[]\n defaultCurrency: number\n}\n\nexport interface StoreCurrencyConfig {\n code: string\n symbol: string\n precision: number\n rate: number\n}\n\nexport interface StoreDomain {\n name: string\n verifiedAt: any | null\n metadata: Record<string, any>\n}\nexport interface StoreBanner {\n title: string\n url?: string | null\n enabled: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreDecoration {\n // primary\n primary: number\n onPrimary?: number\n // on dark mode\n primaryDark?: number\n onPrimaryDark?: number\n // secondary\n secondary?: number\n onSecondary?: number\n // on dark mode\n secondaryDark?: number\n onSecondaryDark?: number\n\n useLogoDarkFilter?: boolean\n\n showStoreLogoInHeader?: boolean\n logoFullHeight?: boolean\n showStoreNameInHeader?: boolean\n metadata?: Record<string, any>\n [key: string]: any\n}\n\nexport interface StoreAction {\n label: string\n url: string\n type: StoreActionType\n}\n\nexport enum StoreActionType {\n link = 'link',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n phone = 'phone',\n}\nexport interface MetaPixel {\n name?: string\n id: string\n key?: string\n}\n// tiktok pixel\nexport interface TiktokPixel {\n id: string\n key?: string\n}\n// meta pixel integration\nexport interface MetaPixelIntegration {\n id: string\n pixels: MetaPixel[]\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n active: boolean\n metadata: Record<string, any>\n}\n// tiktok pixel integration\nexport interface TiktokPixelIntegration {\n id: string\n pixels: TiktokPixel[]\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface GoogleAnalyticsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n// export enum GoogleSheetsColumnType {\n// string = 'string',\n// number = 'number',\n// boolean = 'boolean',\n// date = 'date',\n// }\n\nexport interface GoogleSheetsColumn<T> {\n // it can be path in json field for exmple metadata.customData\n field: keyof OrderEntity | string | 'skus' | 'quantities' | 'itemsNames'\n name: string\n enabled: boolean\n defaultValue?: T\n // type:\n}\nexport interface GoogleSheetsIntegration {\n id: string\n name: string\n active: boolean\n oauth2?: Record<string, any>\n metadata: Record<string, any>\n simple?: boolean\n columns?: GoogleSheetsColumn<any>[]\n}\nexport interface GoogleTagsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n/**\n * OrderDZ integration configuration for order confirmation service.\n * This integration allows automatic order confirmation via OrderDZ API.\n */\nexport interface OrderdzIntegration {\n /** Unique identifier for this integration instance */\n id: string\n /** API endpoint URL for OrderDZ service (e.g., \"https://orderdz.com/api/v1/feeef/order\") */\n url: string\n /** Authentication token for OrderDZ API */\n token: string\n /** Whether this integration is currently active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\n/**\n * Webhook event types for order lifecycle\n */\nexport enum WebhookEvent {\n ORDER_CREATED = 'orderCreated',\n ORDER_UPDATED = 'orderUpdated',\n ORDER_DELETED = 'orderDeleted',\n}\n\n/**\n * Individual webhook configuration\n */\nexport interface WebhookConfig {\n /** Unique identifier for this webhook */\n id: string\n /** Human-readable name for this webhook */\n name: string\n /** Target URL where webhook events will be sent */\n url: string\n /** Events this webhook is subscribed to */\n events: WebhookEvent[]\n /** Optional secret key for HMAC signature verification */\n secret?: string\n /** Whether this webhook is currently active */\n active: boolean\n /** Additional HTTP headers to send with webhook requests */\n headers?: Record<string, string>\n /** Additional metadata for this webhook */\n metadata: Record<string, any>\n}\n\n/**\n * Webhooks integration configuration for real-time order notifications\n */\nexport interface WebhooksIntegration {\n /** List of configured webhooks */\n webhooks: WebhookConfig[]\n /** Whether the webhooks integration is active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\nexport interface StoreIntegrations {\n [key: string]: any\n metadata?: Record<string, any>\n\n // @Default('default') String id,\n // @Default([]) List<MetaPixel> pixels,\n // @Default(true) bool active,\n // @Default({}) Map<String, dynamic> metadata,\n metaPixel?: MetaPixelIntegration\n tiktokPixel?: TiktokPixelIntegration\n googleAnalytics?: GoogleAnalyticsIntegration\n googleSheet?: GoogleSheetsIntegration\n googleTags?: GoogleTagsIntegration\n orderdz?: OrderdzIntegration\n webhooks?: WebhooksIntegration\n\n sms?: any\n telegram?: any\n yalidine?: any\n maystroDelivery?: any\n echotrak?: any\n procolis?: any\n noest?: any\n}\n\nexport enum StoreSubscriptionStatus {\n active = 'active',\n inactive = 'inactive',\n}\n\nexport enum StoreSubscriptionType {\n free = 'free',\n premium = 'premium',\n vip = 'vip',\n custom = 'custom',\n}\n\nexport interface StoreSubscription {\n type: StoreSubscriptionType\n name: string\n status: StoreSubscriptionStatus\n startedAt: DateTime\n expiresAt: DateTime | null\n quota: number\n consumed: number\n remaining: number\n metadata: Record<string, any>\n}\n","import { EmbaddedCategory } from '../embadded/category.js'\nimport { ShippingMethodEntity } from './shipping_method.js'\nimport { GoogleSheetsColumn, StoreEntity } from './store.js'\n\nexport interface ProductEntity {\n id: string\n\n slug: string\n\n decoration: ProductDecoration | null\n\n name: string | null\n\n photoUrl: string | null\n\n media: string[]\n\n storeId: string\n\n shippingMethodId?: string | null\n\n category?: EmbaddedCategory | null\n\n title: string | null\n\n description: string | null\n\n body: string | null\n\n // sku\n sku: string | null\n\n price: number\n\n cost: number | null\n\n discount: number | null\n\n stock: number | null\n\n sold: number\n\n views: number\n\n likes: number\n\n dislikes: number\n\n variant?: ProductVariant | null\n\n offers?: ProductOffer[] | null\n\n metadata: Record<string, any>\n\n status: ProductStatus\n\n type: ProductType\n\n verifiedAt: any | null\n\n blockedAt: any | null\n\n createdAt: any\n\n updatedAt: any\n\n addons?: ProductAddon[] | null\n\n // integrations configs\n integrationsData?: IntegrationsData | null\n publicIntegrationsData?: IntegrationsData | null\n\n // relations\n store?: StoreEntity | null\n shippingMethod?: ShippingMethodEntity | null\n}\n\n// function that generate public data from the integrations data\nexport function generatePublicIntegrationsData(data: IntegrationsData | null | null): any {\n if (!data) return data\n const { metaPixelData, tiktokPixelData, googleAnalyticsData, googleTagsData } = data\n return {\n metaPixelData: generatePublicIntegrationsDataMetaPixel(metaPixelData),\n tiktokPixelData: generatePublicIntegrationsDataTiktokPixel(tiktokPixelData),\n googleAnalyticsData: generatePublicIntegrationsDataGoogleAnalytics(googleAnalyticsData),\n googleTagsData: generatePublicIntegrationsDataGoogleTag(googleTagsData),\n }\n}\n// function that generate public data from the meta pixel data\nexport function generatePublicIntegrationsDataMetaPixel(\n data: MetaPixelData | null | undefined\n): PublicMetaPixelData | null | undefined {\n if (!data) return data\n const { ids, objective, draftObjective } = data\n return {\n ids: ids,\n objective,\n draftObjective,\n }\n}\n// function that generate public data from the tiktok pixel data\nexport function generatePublicIntegrationsDataTiktokPixel(\n data: TiktokPixelData | null | undefined\n): PubllicTiktokPixelData | null | undefined {\n if (!data) return data\n // const { ids, objective, draftObjective } = data\n return {}\n}\n// function that generate public data from the google analytics data\nexport function generatePublicIntegrationsDataGoogleAnalytics(\n data: GoogleAnalyticsData | null | undefined\n): PublicGoogleAnalyticsData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google tag data\nexport function generatePublicIntegrationsDataGoogleTag(\n data: GoogleTagData | null | undefined\n): PublicGoogleTagData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google sheets data\nexport function generatePublicIntegrationsDataGoogleSheets(\n data: GoogleSheetsData | null | undefined\n): PublicGoogleSheetsData | null | undefined {\n if (!data) return data\n return {}\n}\n\nexport interface IntegrationsData {\n metaPixelData?: MetaPixelData | null\n tiktokPixelData?: TiktokPixelData | null\n googleAnalyticsData?: GoogleAnalyticsData | null\n googleTagsData?: GoogleTagData | null\n googleSheetsData?: GoogleSheetsData | null\n}\n\nexport enum MetaPixelEvent {\n none = 'none',\n lead = 'Lead',\n purchase = 'Purchase',\n viewContent = 'ViewContent',\n addToCart = 'AddToCart',\n initiateCheckout = 'InitiateCheckout',\n}\nexport interface MetaPixelData {\n // active meta pixel ids\n ids: string[] | null\n // main objective\n objective: MetaPixelEvent | null\n // draft objective\n draftObjective: MetaPixelEvent | null\n}\n\nexport enum TiktokPixelEvent {}\nexport interface TiktokPixelData {\n // active tiktok pixel ids\n ids: string[] | null\n // main objective\n objective: TiktokPixelEvent | null\n // draft objective\n draftObjective: TiktokPixelEvent | null\n}\nexport interface GoogleAnalyticsData {}\nexport interface GoogleTagData {}\nexport interface GoogleSheetsData {\n enabled: boolean\n // use cant use both sheetId and sheetName\n sheetId: string | null\n // if sheetId is null, use sheetName\n // if sheetName not exists in the spreadsheet, create it\n sheetName: string | null\n spreadsheetId: string | null\n // the next row to insert data\n nextRow: number | null\n // columns to insert data\n columns: GoogleSheetsColumn<any>[] | null\n}\n\n// public meta pixel data\nexport interface PublicMetaPixelData {\n ids: string[] | null\n objective: MetaPixelEvent | null\n draftObjective: MetaPixelEvent | null\n}\n// public tiktok pixel data\nexport interface PubllicTiktokPixelData {}\n// public google analytics data\nexport interface PublicGoogleAnalyticsData {}\n// public google tag data\nexport interface PublicGoogleTagData {}\n// public google sheets data\nexport interface PublicGoogleSheetsData {}\n\nexport interface ProductAddon {\n photoUrl?: string\n title: string\n subtitle?: string\n stock?: number\n price?: number\n min?: number\n max?: number\n}\n\nexport enum ProductStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n deleted = 'deleted',\n}\n\nexport interface ProductDecoration {\n metadata: Record<string, any>\n}\n\nexport interface ProductVariant {\n name: string\n view?: ProductVariantView\n options: ProductVariantOption[]\n required?: boolean\n}\n\nexport enum ProductVariantView {\n list = 'list',\n chips = 'chips',\n dropdown = 'dropdown',\n}\n\nexport interface ProductVariantOption {\n name: string\n sku?: string | null\n price?: number | null\n discount?: number | null\n stock?: number | null\n sold?: number | null\n type?: VariantOptionType\n child?: ProductVariant | null\n mediaIndex?: number | null\n hint?: string | null\n value?: any\n mediaId?: string | null\n hidden?: boolean\n}\n\nexport enum VariantOptionType {\n color = 'color',\n image = 'image',\n text = 'text',\n}\n\nexport enum ProductType {\n physical = 'physical',\n digital = 'digital',\n service = 'service',\n}\n\nexport interface ProductOffer {\n code: string\n title: string\n subtitle?: string\n price?: number\n minQuantity?: number\n maxQuantity?: number\n freeShipping?: boolean\n}\n","export enum EmbaddedContactType {\n phone = 'phone',\n email = 'email',\n facebook = 'facebook',\n twitter = 'twitter',\n instagram = 'instagram',\n linkedin = 'linkedin',\n website = 'website',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n signal = 'signal',\n viber = 'viber',\n skype = 'skype',\n zoom = 'zoom',\n other = 'other',\n}\n\n// EmbaddedContactType is not enum but can only be: \"phone\" | \"email\" | \"facebook\" | \"twitter\" | \"instagram\" | \"linkedin\" | \"website\" | \"whatsapp\" | \"telegram\" | \"signal\" | \"viber\" | \"skype\" | \"zoom\" | \"other\n\nexport interface EmbaddedContact {\n type: EmbaddedContactType\n value: string\n name?: string\n metadata?: Record<string, any>\n}\n","/**\n * Converts a Dart color (0xffXXXXXX) to a CSS-compatible number (0xXXXXXXFF).\n *\n * @param dartColor - The Dart color represented as a 32-bit integer (0xffXXXXXX).\n * @returns A number representing the color in CSS format (0xXXXXXXFF).\n */\nexport const convertDartColorToCssNumber = (dartColor: number): number => {\n const alpha = (dartColor >> 24) & 0xff // Extract alpha (high 8 bits)\n const rgb = dartColor & 0xffffff // Extract RGB (low 24 bits)\n\n // Return color as 0xXXXXXXFF (CSS format: RGB + alpha)\n return (rgb << 8) | alpha\n}\n\n/**\n * Converts a CSS color (0xXXXXXXFF) to HSL format.\n *\n * @param cssColor - The CSS color represented as a 32-bit integer (0xXXXXXXFF).\n * @returns An object with HSL values {h, s, l}.\n */\nexport const cssColorToHslString = (cssColor: number): string => {\n const r = ((cssColor >> 24) & 0xff) / 255 // Extract red channel\n const g = ((cssColor >> 16) & 0xff) / 255 // Extract green channel\n const b = ((cssColor >> 8) & 0xff) / 255 // Extract blue channel\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n let l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0)\n break\n case g:\n h = (b - r) / d + 2\n break\n case b:\n h = (r - g) / d + 4\n break\n }\n h /= 6\n }\n\n return `${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%`\n}\n\n/**\n * Trims and attempts to fix the phone number by:\n * - Removing all non-numeric characters\n * - Ensuring it starts with a '0'\n * @param phone - The input phone number string\n * @returns The cleaned phone number\n */\nexport function tryFixPhoneNumber(phone: string): string {\n phone = phone.trim() // Remove leading/trailing spaces\n // Remove all non-numeric characters\n phone = phone.replace(/\\D/g, '')\n // Ensure the phone number starts with '0'\n if (!phone.startsWith('0')) {\n phone = '0' + phone\n }\n return phone\n}\n\n/**\n * Validates the phone number based on specific rules:\n * - Cannot be empty or just \"0\"\n * - Must start with '05', '06', '07', or '02'\n * - Must be 10 digits for mobile numbers (05, 06, 07)\n * - Must be 9 digits for landline numbers (02)\n * @param phone - The input phone number string\n * @returns Error message if validation fails, otherwise null\n */\nexport function validatePhoneNumber(phone: string): string | null {\n // Helper function to handle length overflow/underflow messages\n const getLengthError = (requiredLength: number, actualLength: number): string => {\n const difference = actualLength - requiredLength\n if (difference > 0) {\n return `عدد الأرقام زائد عن ${requiredLength} رقماً بـ ${difference}`\n } else {\n const missingDigits = -difference\n if (missingDigits === 1) return 'ينقصك رقم واحد'\n if (missingDigits === 2) return 'ينقصك رقمان'\n return `ينقصك ${missingDigits} أرقام`\n }\n }\n\n if (phone === '0') {\n return 'اكمل رقم الهاتف'\n }\n\n // Check if phone number is empty\n if (!phone) {\n return 'رقم الهاتف لا يمكن أن يكون فارغاً.'\n }\n\n // Check if phone number contains only digits\n if (!/^\\d+$/.test(phone)) {\n return 'رقم الهاتف يجب أن يحتوي فقط على أرقام.'\n }\n\n // Ensure the phone starts with valid prefixes\n if (!/^(05|06|07|02)/.test(phone)) {\n return 'يجب أن يبدأ بـ 05, 06, 07, أو 02'\n }\n\n const length = phone.length\n\n // Validate mobile numbers (05, 06, 07 should be 10 digits)\n if (/^(05|06|07)/.test(phone)) {\n if (length !== 10) {\n return getLengthError(10, length)\n }\n }\n\n // Validate landline numbers (02 should be 9 digits)\n else if (phone.startsWith('02')) {\n if (length !== 9) {\n return getLengthError(9, length)\n }\n }\n\n // If all checks pass, return null (no errors)\n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jB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,QAAQ,KAAK,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,iBAAiB,KAAK,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM;AAGrB,MAAI,cAAc,KAAK,KAAK,GAAG;AAC7B,QAAI,WAAW,IAAI;AACjB,aAAO,eAAe,IAAI,MAAM;AAAA,IAClC;AAAA,EACF,WAGS,MAAM,WAAW,IAAI,GAAG;AAC/B,QAAI,WAAW,GAAG;AAChB,aAAO,eAAe,GAAG,MAAM;AAAA,IACjC;AAAA,EACF;AAGA,SAAO;AACT;","names":["OrderStatus","PaymentStatus","DeliveryStatus","ShippingType","ShippingMethodStatus","ShippingMethodPolicy","StoreMemberRole","StoreActionType","WebhookEvent","StoreSubscriptionStatus","StoreSubscriptionType","MetaPixelEvent","TiktokPixelEvent","ProductStatus","ProductVariantView","VariantOptionType","ProductType","EmbaddedContactType"]}
|
|
1
|
+
{"version":3,"sources":["../src/feeef/feeef.ts","../src/feeef/repositories/repository.ts","../src/feeef/repositories/orders.ts","../src/feeef/repositories/products.ts","../src/feeef/repositories/stores.ts","../src/feeef/repositories/users.ts","../src/feeef/repositories/deposits.ts","../src/feeef/repositories/categories.ts","../src/core/entities/order.ts","../src/core/entities/shipping_method.ts","../src/feeef/services/service.ts","../src/feeef/services/cart.ts","../src/core/entities/store.ts","../src/core/entities/product.ts","../src/core/embadded/contact.ts","../src/utils.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios'\n// import { buildMemoryStorage, buildWebStorage, setupCache } from 'axios-cache-interceptor'\nimport { OrderRepository } from './repositories/orders.js'\nimport { ProductRepository } from './repositories/products.js'\nimport { StoreRepository } from './repositories/stores.js'\nimport { UserRepository } from './repositories/users.js'\nimport { DepositRepository } from './repositories/deposits.js'\nimport { CategoryRepository } from './repositories/categories.js'\nimport { CartService } from './services/cart.js'\n\n/**\n * Configuration options for the FeeeF module.\n */\nexport interface FeeeFConfig {\n /**\n * The API key to be used for authentication.\n */\n apiKey: string\n\n /**\n * An optional Axios instance to be used for making HTTP requests.\n */\n client?: AxiosInstance\n\n /**\n * Specifies whether caching should be enabled or disabled.\n * If set to a number, it represents the maximum number of seconds to cache the responses.\n * If set to `false`, caching will be disabled (5s).\n * cannot be less than 5 seconds\n */\n cache?: false | number\n\n /**\n * The base URL for the API.\n */\n baseURL?: string\n}\n\n/**\n * Represents the FeeeF class.\n */\nexport class FeeeF {\n /**\n * The API key used for authentication.\n */\n apiKey: string\n\n /**\n * The Axios instance used for making HTTP requests.\n */\n client: AxiosInstance\n\n /**\n * The repository for managing stores.\n */\n stores: StoreRepository\n\n /**\n * The repository for managing products.\n */\n products: ProductRepository\n\n /**\n * The repository for managing users.\n */\n users: UserRepository\n\n /**\n * The repository for managing orders.\n */\n orders: OrderRepository\n\n /**\n * The repository for managing deposits.\n */\n deposits: DepositRepository\n\n /**\n * The repository for managing categories.\n */\n categories: CategoryRepository\n\n /**\n * The cart service for managing the cart.\n */\n cart: CartService\n\n /**\n * Constructs a new instance of the FeeeF class.\n * @param {FeeeFConfig} config - The configuration object.\n * @param {string} config.apiKey - The API key used for authentication.\n * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.\n * @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.\n */\n //\n constructor({ apiKey, client, cache, baseURL = 'http://localhost:3333/api/v1' }: FeeeFConfig) {\n console.log('feeef super cache', cache)\n this.apiKey = apiKey\n // get th \"cache\" search param\n // const urlParams = new URLSearchParams(window.location.search)\n // const cacheParam = urlParams.get('cache')\n // if is 0 or false, disable cache\n // if (cacheParam == '0') {\n this.client = client || axios\n // set the api key\n this.client.defaults.headers.common['Authorization'] = `Bearer ${this.apiKey}`\n // } else {\n // this.client = setupCache(client || axios, {\n // ttl: cache === false ? 5 : Math.max(cache!, 5) || 1 * 60 * 1000, // 1 minute by default\n // // for persistent cache use buildWebStorage\n // storage: buildWebStorage(localStorage, 'ff:'),\n // })\n // }\n // set base url\n this.client.defaults.baseURL = baseURL\n this.stores = new StoreRepository(this.client)\n this.products = new ProductRepository(this.client)\n this.users = new UserRepository(this.client)\n this.orders = new OrderRepository(this.client)\n this.deposits = new DepositRepository(this.client)\n this.categories = new CategoryRepository(this.client)\n\n // cart\n this.cart = new CartService()\n }\n\n /**\n * set header method to set custom headers for all requests\n */\n setHeader(key: string, value: string) {\n this.client.defaults.headers.common[key] = value\n }\n\n /**\n * Removes a header from the default headers.\n * @param {string} key - The key of the header to remove.\n */\n removeHeader(key: string) {\n delete this.client.defaults.headers.common[key]\n }\n}\n","import { AxiosInstance } from 'axios'\n\n/**\n * Represents a generic model repository.\n * @template T - The type of the model.\n * @template C - The type of the create options.\n * @template U - The type of the update options.\n */\nexport abstract class ModelRepository<T, C, U> {\n resource: string\n // client\n client: AxiosInstance\n\n /**\n * Constructs a new instance of the ModelRepository class.\n * @param resource - The resource name.\n * @param client - The Axios instance used for making HTTP requests.\n */\n constructor(resource: string, client: AxiosInstance) {\n this.resource = resource\n this.client = client\n }\n\n /**\n * Finds a model by its ID or other criteria.\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async find(options: ModelFindOptions): Promise<T> {\n const { id, by, params } = options\n const res = await this.client.get(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n return res.data\n }\n\n /**\n * Lists models with optional pagination and filtering.\n * @param options - The options for listing the models.\n * @returns A promise that resolves to a list of models.\n */\n async list(options?: ModelListOptions): Promise<ListResponse<T>> {\n const { page, offset, limit, params } = options || {}\n const res = await this.client.get(`/${this.resource}`, {\n params: { page, offset, limit, ...params },\n })\n // if res.data is an array then create ListResponse\n if (Array.isArray(res.data)) {\n return {\n data: res.data,\n }\n } else {\n return {\n data: res.data.data,\n total: res.data.meta.total,\n page: res.data.meta.currentPage,\n limit: res.data.meta.perPage,\n }\n }\n }\n\n /**\n * Creates a new model.\n * @param options - The options for creating the model.\n * @returns A promise that resolves to the created model.\n */\n async create(options: ModelCreateOptions<C>): Promise<T> {\n const { data, params } = options\n const res = await this.client.post(`/${this.resource}`, data, { params })\n return res.data\n }\n\n /**\n * Updates an existing model.\n * @param options - The options for updating the model.\n * @returns A promise that resolves to the updated model.\n */\n async update(options: ModelUpdateOptions<U>): Promise<T> {\n const { id, data, params } = options\n const res = await this.client.put(`/${this.resource}/${id}`, data, {\n params,\n })\n return res.data\n }\n\n /**\n * Deletes a model by its ID or other criteria.\n * @param options - The options for deleting the model.\n * @returns A promise that resolves when the model is deleted.\n */\n async delete(options: ModelFindOptions): Promise<void> {\n const { id, by, params } = options\n await this.client.delete(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n }\n}\n\n/**\n * Represents a list response containing an array of data of type T.\n */\nexport interface ListResponse<T> {\n data: T[]\n total?: number\n page?: number\n limit?: number\n}\n\n/**\n * Represents the options for making a request.\n */\ninterface RequestOptions {\n params?: Record<string, any>\n}\n\nexport interface ModelFindOptions extends RequestOptions {\n /**\n * The ID of the model to find or the value to find by.\n */\n id: string\n /**\n * The field to find by.\n * @default \"id\" - The ID field.\n */\n by?: string\n}\n\n/**\n * Options for listing models.\n */\nexport interface ModelListOptions extends RequestOptions {\n /**\n * The page number to retrieve.\n */\n page?: number\n\n /**\n * The offset from the beginning of the list.\n */\n offset?: number\n\n /**\n * The maximum number of models to retrieve per page.\n */\n limit?: number\n}\n\n/**\n * Represents the options for creating a model.\n * @template T - The type of data being created.\n */\nexport interface ModelCreateOptions<T> extends RequestOptions {\n data: T\n}\n\n/**\n * Represents the options for updating a model.\n * @template T - The type of the data being updated.\n */\nexport interface ModelUpdateOptions<T> extends RequestOptions {\n /**\n * The ID of the model to update.\n */\n id: string\n /**\n * The data to update the model with.\n */\n data: T\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { OrderEntity, OrderTrackEntity, ShippingType } from '../../core/entities/order.js'\n/**\n * Represents the options for tracking an order.\n */\nexport interface OrderModelTrackOptions {\n id: string\n params?: Record<string, any>\n}\n\nexport interface SendOrderSchema {\n id?: string // Order ID (optional)\n customerName?: string // Name of the customer (optional)\n customerNote?: string // Note from the customer (optional)\n customerPhone: string // Customer's phone number (required)\n customerEmail?: string // Customer's email address (optional)\n source?: string // the source of the order (facebook...tiktok..)\n shippingAddress?: string // Address for shipping (optional)\n shippingCity?: string // City for shipping (optional)\n shippingState?: string // State for shipping (optional)\n shippingType: ShippingType // Shipping type (required)\n shippingMethodId?: string // ID of the shipping method (optional)\n shippingNote?: string // Note for shipping (optional)\n paymentMethodId?: string // ID of the payment method (optional)\n items: GuestOrderItemSchema[] // Array of order items, must have at least one item\n coupon?: string // Applied coupon code (optional)\n status: 'pending' | 'draft' // Order status (required)\n storeId: string // ID of the store (required)\n metadata?: any // Additional metadata (optional)\n}\n\n// Assuming GuestOrderItemSchema was defined elsewhere, define it here as well if needed.\nexport interface GuestOrderItemSchema {\n productId: string\n offerCode?: string\n variantPath?: string\n quantity: number\n addons?: Record<string, number>\n}\n\n/**\n * Schema for assigning a single order to a member\n */\nexport interface AssignOrderSchema {\n orderId: string\n memberId: string\n storeId: string\n}\n\n/**\n * Schema for assigning multiple orders to a member\n */\nexport interface AssignManyOrdersSchema {\n orderIds: string[]\n memberId: string\n storeId: string\n}\n\n/**\n * Represents a repository for managing orders.\n */\nexport class OrderRepository extends ModelRepository<OrderEntity, any, any> {\n /**\n * Constructs a new OrderRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('orders', client)\n }\n\n /**\n * Sends an order from an anonymous user.\n * @param data - The data representing the order to be sent.\n * @returns A Promise that resolves to the sent OrderEntity.\n */\n async send(data: SendOrderSchema): Promise<OrderEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n\n // Return the sent OrderEntity\n return res.data\n }\n\n /**\n * track the order by the order id\n * it will return the order status and history\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async track(options: OrderModelTrackOptions): Promise<OrderTrackEntity> {\n const { id, params } = options\n const res = await this.client.get(`/${this.resource}/${id}/track`, {\n params: {\n ...params,\n },\n })\n return res.data\n }\n\n /**\n * Assigns a single order to a member (as confirmer)\n * @param data - The data containing orderId, memberId, and storeId\n * @returns A Promise that resolves to the updated OrderEntity\n */\n async assign(data: AssignOrderSchema): Promise<OrderEntity> {\n const res = await this.client.post(`/${this.resource}/assign`, data)\n return res.data\n }\n\n /**\n * Assigns multiple orders to a member (as confirmer)\n * @param data - The data containing orderIds, memberId, and storeId\n * @returns A Promise that resolves to a success message\n */\n async assignMany(data: AssignManyOrdersSchema): Promise<{ message: string }> {\n const res = await this.client.post(`/${this.resource}/assignMany`, data)\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { ProductEntity } from '../../core/entities/product.js'\n\n/**\n * Represents a repository for managing products.\n */\nexport class ProductRepository extends ModelRepository<ProductEntity, any, any> {\n /**\n * Creates a new instance of the ProductRepository class.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('products', client)\n }\n\n /**\n * Retrieves a random products from the repository.\n * @param limit - The number of random products to retrieve. Default is 1.\n * @returns A promise that resolves to an array of random ProductEntity objects.\n */\n async random(limit = 12): Promise<ProductEntity[]> {\n const response = await this.client.get<ProductEntity[]>(`/products/random`, {\n params: { limit },\n })\n return response.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository, ModelCreateOptions } from './repository.js'\nimport { StoreEntity } from '../../core/entities/store.js'\n\n/**\n * Repository for managing Store entities.\n */\nexport class StoreRepository extends ModelRepository<StoreEntity, any, any> {\n /**\n * Constructs a new StoreRepository instance.\n * @param client The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('stores', client)\n }\n\n /**\n * Creates a new Store entity.\n * @param options The options for creating the Store entity.\n * @returns A Promise that resolves to the created Store entity.\n */\n async create(options: ModelCreateOptions<any>): Promise<StoreEntity> {\n const output = options.data\n return super.create({ ...options, data: output })\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { AuthToken, UserEntity } from '../../core/entities/user.js'\n\n/**\n * Represents the response returned by the authentication process.\n */\nexport interface AuthResponse {\n token: AuthToken\n user: UserEntity\n}\n\n/**\n * Represents a repository for managing user data.\n * Extends the ModelRepository class.\n */\nexport class UserRepository extends ModelRepository<UserEntity, any, any> {\n /**\n * Represents the authentication response.\n */\n auth: AuthResponse | null = null\n\n /**\n * Constructs a new UserRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('users', client)\n }\n\n /**\n * Signs in a user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signin(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signin`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs up a new user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signup(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signup`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs out the currently authenticated user.\n * @returns A promise that resolves when the user is signed out.\n */\n async signout(): Promise<void> {\n this.auth = null\n }\n\n /**\n * Updates the authenticated user's data.\n * @param data - The updated user data.\n * @returns A promise that resolves to the updated user entity.\n */\n async updateMe(data: any): Promise<UserEntity> {\n const output = data\n const res = await this.client.put(`/${this.resource}/auth`, output)\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\n\n/**\n * Represents a deposit entity for wallet transactions\n */\nexport interface DepositEntity {\n id: string\n externalId?: string | null\n userId: string\n amount: number\n currency: string\n paymentMethod?: string | null\n attachment?: string | null\n status: 'pending' | 'completed' | 'failed' | 'cancelled'\n note?: string | null\n metadata: Record<string, any>\n history: Array<{\n status: string\n timestamp: string\n note?: string\n }>\n createdAt: any\n updatedAt: any\n}\n\n/**\n * Input data for creating a new deposit\n */\nexport interface DepositCreateInput {\n id?: string\n externalId?: string\n amount: number\n currency?: string\n paymentMethod?: string\n attachment?: string\n note?: string\n metadata?: Record<string, any>\n}\n\n/**\n * PayPal order creation response\n */\nexport interface PayPalOrderResponse {\n id: string\n status: string\n approvalUrl?: string\n links: Array<{\n href: string\n rel: string\n method: string\n }>\n}\n\n/**\n * PayPal order capture response\n */\nexport interface PayPalCaptureResponse {\n id: string\n status: string\n captureId?: string\n amount?: number\n currency?: string\n}\n\n/**\n * Repository for managing deposit data and PayPal integration\n */\nexport class DepositRepository extends ModelRepository<DepositEntity, DepositCreateInput, any> {\n /**\n * Constructs a new DepositRepository instance\n * @param client - The AxiosInstance used for making HTTP requests\n */\n constructor(client: AxiosInstance) {\n super('deposits', client)\n }\n\n /**\n * Create a new deposit request\n * @param data - The deposit data\n * @returns Promise that resolves to the created deposit\n */\n async send(data: DepositCreateInput): Promise<DepositEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n return res.data\n }\n\n /**\n * Create a PayPal order for deposit\n * @param params - PayPal order parameters\n * @returns Promise that resolves to PayPal order details\n */\n async createPayPalOrder(params: {\n amount: number\n currency?: string\n depositId?: string\n returnUrl: string\n cancelUrl: string\n }): Promise<PayPalOrderResponse> {\n const orderData = {\n amount: params.amount,\n currency: params.currency || 'USD',\n depositId: params.depositId,\n returnUrl: params.returnUrl,\n cancelUrl: params.cancelUrl,\n }\n\n const res = await this.client.post(`/${this.resource}/paypal/create-order`, orderData)\n\n // Extract approval URL from links\n const approvalLink = res.data.links?.find((link: any) => link.rel === 'approve')\n\n return {\n id: res.data.id,\n status: res.data.status,\n approvalUrl: approvalLink?.href,\n links: res.data.links || [],\n }\n }\n\n /**\n * Capture a PayPal order after user approval\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to capture details\n */\n async capturePayPalOrder(orderId: string): Promise<PayPalCaptureResponse> {\n const res = await this.client.post(`/${this.resource}/paypal/capture-order`, {\n orderId,\n })\n return res.data\n }\n\n /**\n * Get PayPal order status\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to order details\n */\n async getPayPalOrderStatus(orderId: string): Promise<{\n id: string\n status: string\n amount?: number\n currency?: string\n }> {\n const res = await this.client.get(`/${this.resource}/paypal/order/${orderId}`)\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository, ModelCreateOptions, ModelListOptions } from './repository.js'\nimport { CategoryEntity } from '../../core/entities/category.js'\n\nexport interface CategoryCreate {\n store_id: string\n parent_id?: string | null\n name: string\n description?: string | null\n photo_url?: string | null\n metadata?: Record<string, any>\n}\n\nexport interface CategoryUpdate {\n parent_id?: string | null\n name?: string\n description?: string | null\n photo_url?: string | null\n metadata?: Record<string, any>\n}\n\n/**\n * Repository for managing Category entities.\n */\nexport class CategoryRepository extends ModelRepository<\n CategoryEntity,\n CategoryCreate,\n CategoryUpdate\n> {\n /**\n * Constructs a new CategoryRepository instance.\n * @param client The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('categories', client)\n }\n\n /**\n * Lists categories for a store with optional parent filter.\n * @param options The options for listing categories.\n * @returns A Promise that resolves to a list of categories.\n */\n async list(\n options?: ModelListOptions & { storeId?: string; parentId?: string | null }\n ): Promise<any> {\n const { storeId, parentId, ...listOptions } = options || {}\n const params = {\n ...listOptions.params,\n ...(storeId ? { store_id: storeId } : {}),\n ...(parentId !== undefined ? { parent_id: parentId } : {}),\n }\n return super.list({ ...listOptions, params })\n }\n\n /**\n * Gets the category tree structure for a store.\n * @param storeId The store ID.\n * @returns A Promise that resolves to the category tree.\n */\n async tree(storeId: string): Promise<CategoryEntity[]> {\n const res = await this.client.get(`/stores/${storeId}/categories/tree`)\n return res.data\n }\n\n /**\n * Creates a new Category entity.\n * @param options The options for creating the Category entity.\n * @returns A Promise that resolves to the created Category entity.\n */\n async create(\n options: ModelCreateOptions<CategoryCreate> & { storeId?: string }\n ): Promise<CategoryEntity> {\n const { storeId, data, ...rest } = options\n if (storeId) {\n const res = await this.client.post(`/stores/${storeId}/categories`, data, {\n params: rest.params,\n })\n return res.data\n }\n return super.create(options)\n }\n}\n","export enum OrderStatus {\n draft = 'draft',\n pending = 'pending',\n review = 'review',\n accepted = 'accepted',\n processing = 'processing',\n completed = 'completed',\n cancelled = 'cancelled',\n}\n\n// PaymentStatus\nexport enum PaymentStatus {\n unpaid = 'unpaid',\n paid = 'paid',\n received = 'received',\n}\nexport enum DeliveryStatus {\n pending = 'pending',\n delivering = 'delivering',\n delivered = 'delivered',\n returned = 'returned',\n}\n\nexport enum ShippingType {\n // delivery to customer home\n home = 'home',\n // the customer picks up the order from the local shipping center\n pickup = 'pickup',\n // the customer picks up the order from the store\n store = 'store',\n}\n\nexport interface OrderEntity {\n id: string\n customerName?: string | null\n customerPhone: string\n customerEmail?: string | null\n customerNote?: string | null\n customerIp?: string | null\n shippingAddress?: string | null\n shippingCity?: string | null\n shippingState?: string | null\n shippingMethodId?: string | null\n shippingType: ShippingType\n paymentMethodId?: string | null\n items: OrderItem[]\n subtotal: number\n shippingPrice: number\n total: number\n discount: number\n // @Deprecated\n coupon?: string | null\n couponId?: string | null\n couponCode?: string | null\n couponDiscount?: string | null\n storeId: string\n source: string | null\n confirmerId: string | null\n metadata: OrderMetadata\n status: OrderStatus\n paymentStatus: PaymentStatus\n deliveryStatus: DeliveryStatus\n customStatus?: string | null\n tags: string[] | null\n createdAt: any\n updatedAt: any\n}\nexport interface OrderItem {\n productId: string\n productName: string\n productPhotoUrl?: string | null\n variantPath?: string\n sku?: string | null\n discount?: number | null\n quantity: number\n price: number\n offerCode?: string | null\n offerName?: string | null\n addons?: Record<string, number>\n}\n\n// order track entity\nexport interface OrderTrackEntity {\n id: string\n customerName?: string | null\n items: OrderItem[]\n total: number\n createdAt: any\n storeId: string\n status: OrderStatus\n history: OrderTrackHistory[]\n}\n\n// order track history\nexport interface OrderTrackHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n}\n\n// order metadata history\ninterface OrderMetadataHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n message: string\n code: string\n userId: string\n}\n\n// order metadata\ninterface OrderMetadata {\n note?: string\n history?: OrderMetadataHistory[]\n metaPixel?: any\n customOrderTagHistories?: any[]\n [key: string]: any\n}\n\n// utils\n// order entity to order track entity\nexport const convertOrderEntityToOrderTrackEntity = (order: OrderEntity): OrderTrackEntity => {\n return {\n id: order.id,\n customerName: order.customerName,\n items: order.items,\n total: order.total,\n createdAt: order.createdAt,\n storeId: order.storeId,\n status: order.status,\n history:\n order.metadata.history?.map((history) => ({\n status: history.status,\n deliveryStatus: history.deliveryStatus,\n paymentStatus: history.paymentStatus,\n createdAt: history.createdAt,\n })) || [],\n }\n}\n","import { OrderEntity } from './order.js'\n\nexport interface ShippingMethodEntity {\n id: string\n name: string\n description: string | null\n logoUrl: string | null\n ondarkLogoUrl: string | null\n price: number\n forks: number\n sourceId: string\n storeId: string\n rates: (number | null)[][] | null\n status: ShippingMethodStatus\n policy: ShippingMethodPolicy\n verifiedAt: any\n createdAt: any\n updatedAt: any\n orders: OrderEntity[]\n source: ShippingMethodEntity | null\n}\n\nexport enum ShippingMethodStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n}\n\nexport enum ShippingMethodPolicy {\n private = 'private',\n public = 'public',\n}\n","export type Listener<T extends NotifiableService> = (service: T) => void\n\nexport class NotifiableService {\n // Array of listeners (functions) to notify when changes occur\n private listeners: Set<Listener<typeof this>> = new Set()\n\n /**\n * Adds a listener that gets called when `notify` is triggered.\n * @param listener - The function to be called on notification.\n * @returns The same listener for potential chaining or removal.\n */\n addListener(listener: Listener<typeof this>): Listener<typeof this> {\n this.listeners.add(listener) // Using Set for uniqueness and faster removal\n return listener\n }\n\n /**\n * Removes a previously added listener.\n * @param listener - The function to be removed from the listeners list.\n */\n removeListener(listener: Listener<typeof this>): void {\n this.listeners.delete(listener) // Set deletion is O(1) for better performance\n }\n\n /**\n * Notifies all registered listeners, passing the service instance.\n * This allows listeners to react to changes.\n */\n notify(): void {\n // Iterating over the Set of listeners and invoking each one\n this.listeners.forEach((listener) => listener(this))\n }\n\n /**\n * Clears all listeners, removing any references to them.\n */\n clearListeners(): void {\n this.listeners.clear() // Clears the Set entirely\n }\n\n /**\n * Constructor for NotifiableService, initializes listeners as an empty Set.\n * The Set ensures unique listeners and better management.\n */\n constructor() {\n // Initialization can be skipped since listeners is already initialized as an empty Set\n }\n}\n","import { ShippingType } from '../../core/entities/order.js'\nimport { ProductEntity, ProductOffer } from '../../core/entities/product.js'\nimport {\n ShippingMethodEntity,\n ShippingMethodPolicy,\n ShippingMethodStatus,\n} from '../../core/entities/shipping_method.js'\nimport { StoreEntity } from '../../core/entities/store.js'\nimport { NotifiableService } from './service.js'\n\n/**\n * Represents an item in the cart.\n */\nexport interface CartItem {\n product: ProductEntity\n offer?: ProductOffer\n quantity: number\n variantPath?: string\n addons?: Record<string, number>\n}\n\n/**\n * Cart shipping types.\n * - `pickup`: The user will pick up the order from the closest desk.\n * - `home`: The order will be delivered to the user's home.\n * - `store`: The order will be delivered to the store.\n */\n// export type CartShippingTypes = 'pickup' | 'home' | 'store'\n\n/**\n * Interface for a shipping address.\n */\nexport interface CartShippingAddress {\n name: string | null\n phone: string | null\n city: string | null\n state: string | null\n street: string | null\n country: 'dz' | string\n type: ShippingType\n}\n\n/**\n * Manages the shopping cart and its operations.\n */\nexport class CartService extends NotifiableService {\n private items: CartItem[] = [] // Array to support multiple items with same product but different variants\n private shippingMethod: ShippingMethodEntity | null = null\n private shippingAddress: CartShippingAddress = {\n name: null,\n phone: null,\n city: null,\n state: null,\n street: null,\n country: 'dz',\n type: ShippingType.pickup,\n }\n private cachedSubtotal: number | null = null // Cache for subtotal to avoid redundant calculations\n private currentItem: CartItem | null = null\n\n /**\n * Generates a unique key for a cart item based on product ID, variant path, offer code, and addons\n * @param item - The cart item to generate a key for\n * @returns A unique string key\n */\n private getItemKey(item: CartItem): string {\n const addonKeys = item.addons ? Object.keys(item.addons).sort().join('|') : ''\n return `${item.product.id}:${item.variantPath || ''}:${item.offer?.code || ''}:${addonKeys}`\n }\n\n /**\n * Finds an item in the cart that matches the given item's key\n * @param item - The item to find\n * @returns The matching cart item or undefined\n */\n private findItem(item: CartItem): CartItem | undefined {\n const targetKey = this.getItemKey(item)\n return this.items.find((cartItem) => this.getItemKey(cartItem) === targetKey)\n }\n\n /**\n * Finds the index of an item in the cart that matches the given item's key\n * @param item - The item to find\n * @returns The index of the matching cart item or -1 if not found\n */\n private findItemIndex(item: CartItem): number {\n const targetKey = this.getItemKey(item)\n return this.items.findIndex((cartItem) => this.getItemKey(cartItem) === targetKey)\n }\n\n /**\n * Sets the current item to be managed in the cart.\n * @param item - The item to be set as current.\n */\n setCurrentItem(item: CartItem, notify = true): void {\n this.currentItem = item\n\n const existingItemIndex = this.findItemIndex(this.currentItem)\n if (existingItemIndex !== -1) {\n this.items[existingItemIndex] = this.currentItem\n }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Clamps the quantity to be within the offer's min/max range\n * @param offer - The offer containing quantity constraints\n * @param quantity - The quantity to clamp\n * @returns The clamped quantity value\n */\n private clampQuantityToOfferLimits(offer: ProductOffer, quantity: number): number {\n if (offer.minQuantity !== undefined) {\n quantity = Math.max(quantity, offer.minQuantity)\n }\n if (offer.maxQuantity !== undefined) {\n quantity = Math.min(quantity, offer.maxQuantity)\n }\n return quantity\n }\n\n /**\n * Update item by unique key (product ID + variant + offer + addons).\n * @param item - The item to identify the cart item to update.\n * @param updates - Partial item data to update.\n */\n updateItem(item: CartItem, updates: Partial<CartItem>, notify = true): void {\n const index = this.findItemIndex(item)\n\n if (index !== -1) {\n const currentItem = this.items[index]\n const newItem = { ...currentItem, ...updates }\n\n // Clamp quantity if there's an offer with constraints\n if (newItem.offer) {\n newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity)\n }\n\n this.items[index] = newItem\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Update current item.\n * @param updates - a partial item to update.\n */\n updateCurrentItem(updates: Partial<CartItem>, notify = true): void {\n if (!this.currentItem) return\n\n this.currentItem = { ...this.currentItem, ...updates }\n\n const existingItemIndex = this.findItemIndex(this.currentItem)\n if (existingItemIndex !== -1) {\n this.items[existingItemIndex] = this.currentItem\n }\n\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping address.\n * @param address - a partial address to update.\n */\n updateShippingAddress(address: Partial<CartShippingAddress>, notify = true): void {\n this.shippingAddress = { ...this.shippingAddress, ...address }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping method.\n * @param method - a partial shipping method to update.\n */\n updateShippingMethod(method: Partial<ShippingMethodEntity>, notify = true): void {\n if (!this.shippingMethod) return\n\n this.shippingMethod = { ...this.shippingMethod, ...method }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Retrieves the current item in the cart.\n * @returns The current cart item or null if not set.\n */\n getCurrentItem(): CartItem | null {\n return this.currentItem\n }\n\n /**\n * Checks if the current item is already in the cart.\n * @returns True if the current item is in the cart, false otherwise.\n */\n isCurrentItemInCart(): boolean {\n return this.currentItem ? this.findItem(this.currentItem) !== undefined : false\n }\n\n /**\n * Adds the current item to the cart if it's not already present.\n */\n addCurrentItemToCart(): void {\n if (!this.currentItem || this.isCurrentItemInCart()) return\n this.add(this.currentItem)\n this.cachedSubtotal = null\n }\n\n /**\n * Removes the current item from the cart if present.\n */\n removeCurrentItemFromCart(): void {\n if (this.currentItem) {\n this.remove(this.currentItem)\n }\n }\n\n /**\n * Toggles the current item's presence in the cart (add/remove).\n */\n toggleCurrentItemInCart(): void {\n this.isCurrentItemInCart() ? this.removeCurrentItemFromCart() : this.addCurrentItemToCart()\n }\n\n /**\n * Adds an item to the cart. If the item is already present, increments its quantity.\n * @param item - The cart item to add.\n */\n add(item: CartItem): void {\n const existingItem = this.findItem(item)\n\n if (existingItem) {\n existingItem.quantity += item.quantity\n } else {\n this.items.push({ ...item })\n }\n\n this.cachedSubtotal = null // Reset subtotal cache\n this.notifyIfChanged()\n }\n\n /**\n * Checks if an item exists in the cart by matching product ID and variant path.\n * @param productId - The product ID to check for.\n * @param variantPath - The variant path to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(productId: string, variantPath?: string): boolean {\n return this.items.some((item) => {\n if (item.product.id !== productId) return false\n if (variantPath !== undefined && item.variantPath !== variantPath) return false\n return true\n })\n }\n\n /**\n * Checks if an item exists in the cart by matching the item's unique key.\n * @param item - The item to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n hasItem(item: CartItem): boolean {\n return this.findItem(item) !== undefined\n }\n\n /**\n * Checks if any item with the given product ID exists in the cart.\n * @param productId - The product ID to check for.\n * @returns True if any item with the product ID exists, false otherwise.\n */\n hasProduct(productId: string): boolean {\n return this.items.some((item) => item.product.id === productId)\n }\n\n /**\n * Removes an item from the cart by matching the item's unique key.\n * @param item - The item to remove.\n */\n remove(item: CartItem): void {\n const index = this.findItemIndex(item)\n if (index !== -1) {\n this.items.splice(index, 1)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Removes all items with the given product ID from the cart.\n * @param productId - The product ID to remove.\n */\n removeByProductId(productId: string, variantPath?: string): void {\n const initialLength = this.items.length\n this.items = this.items.filter((item) => {\n if (item.product.id !== productId) return true\n if (variantPath !== undefined && item.variantPath !== variantPath) return true\n return false\n })\n\n if (this.items.length !== initialLength) {\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Clears all items from the cart.\n */\n clear(notify = true): void {\n if (this.items.length > 0) {\n this.items = []\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the subtotal of the cart.\n * @param withCurrentItem - Whether to include the current item in the subtotal.\n * @returns The subtotal amount.\n */\n getSubtotal(withCurrentItem = true): number {\n if (this.cachedSubtotal === null) {\n this.cachedSubtotal = this.items.reduce((sum, item) => {\n return sum + this.getItemTotal(item)\n }, 0)\n }\n\n if (withCurrentItem && this.currentItem && !this.hasItem(this.currentItem)) {\n return this.cachedSubtotal + this.getItemTotal(this.currentItem)\n }\n\n return this.cachedSubtotal\n }\n\n /**\n * Calculates the total price for a cart item.\n * @param item - The cart item.\n * @returns The total price for the item.\n */\n getItemTotal(item: CartItem): number {\n const { product, variantPath, quantity, offer, addons } = item\n let price = product.price\n let discount = product.discount ?? 0\n\n // Handle variant pricing if a variant path exists\n if (variantPath) {\n const parts = variantPath.split('/')\n let currentVariant = product.variant\n\n for (const part of parts) {\n if (!currentVariant) break\n const option = currentVariant.options.find((o) => o.name === part)\n if (!option) break\n price = option.price ?? price\n discount = option.discount ?? discount\n currentVariant = option.child\n }\n }\n\n // Apply offer if present\n if (offer) {\n if (offer.price !== undefined) {\n // If offer has a fixed price, use it\n price = offer.price\n discount = 0 // Reset discount since we're using a fixed price\n }\n }\n\n // Calculate base product price with quantity\n let total = (price - discount) * quantity\n\n // Add pricing for addons if present\n if (addons && product.addons) {\n for (const [addonId, addonQuantity] of Object.entries(addons)) {\n // Find the addon in the product's addons array\n const addon = product.addons.find((a) => a.title === addonId)\n if (addon && addon.price) {\n // Add the addon price * quantity to the total\n total += addon.price * addonQuantity\n }\n }\n }\n\n return total\n }\n\n /**\n * Validates if an offer can be applied to the given quantity\n * @param offer - The offer to validate\n * @param quantity - The quantity to check\n * @returns boolean indicating if the offer is valid for the quantity\n */\n isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean {\n if (offer.minQuantity && quantity < offer.minQuantity) return false\n if (offer.maxQuantity && quantity > offer.maxQuantity) return false\n return true\n }\n\n /**\n * Updates the offer for a specific cart item\n * @param item - The item to update\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateItemOffer(item: CartItem, offer?: ProductOffer): void {\n const existingItem = this.findItem(item)\n if (!existingItem) return\n\n const updatedItem = { ...existingItem, offer }\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, existingItem.quantity)\n }\n\n this.updateItem(item, updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Updates the offer for the current item\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateCurrentItemOffer(offer?: ProductOffer): void {\n if (!this.currentItem) return\n\n const updatedItem = { ...this.currentItem }\n updatedItem.offer = offer\n\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, this.currentItem.quantity)\n }\n\n this.updateCurrentItem(updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Sets the shipping method.\n * @param method - Either a store or a shipping method.\n */\n setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify = true): void {\n const store = (method as StoreEntity)?.defaultShippingRates ? (method as StoreEntity) : null\n const shippingMethod = (method as ShippingMethodEntity)?.rates\n ? (method as ShippingMethodEntity)\n : null\n\n if (store) {\n this.shippingMethod = {\n id: store.id,\n name: store.name,\n description: store.description,\n logoUrl: store.logoUrl,\n ondarkLogoUrl: store.ondarkLogoUrl,\n price: 0,\n forks: 0,\n sourceId: store.id,\n storeId: store.id,\n rates: store.defaultShippingRates,\n status: ShippingMethodStatus.published,\n policy: ShippingMethodPolicy.public,\n verifiedAt: null,\n createdAt: null,\n updatedAt: null,\n orders: [],\n source: null,\n }\n if (notify) {\n this.notify()\n }\n } else if (shippingMethod) {\n this.shippingMethod = shippingMethod\n if (notify) {\n this.notify()\n }\n } else {\n throw new Error('Invalid shipping method')\n }\n }\n\n // getAvailableShippingTypes\n /**\n * Retrieves the available shipping types for the current shipping method.\n *\n * rates is a 2D array for example `[[10, 20, 30], [5, 10, 15]]`\n * where the first array is for `home` fees and the second is for `pickup` fees, and the third is for `store` fees\n * if the fee value is 0, then it's free shipping, and if it's null, then it's not available\n *\n * @returns An array of available shipping types.\n */\n getAvailableShippingTypes(): ShippingType[] {\n if (!this.shippingMethod?.rates) return []\n\n var state = Number.parseInt(this.shippingAddress.state!)\n var stateRates = this.shippingMethod.rates[state - 1]\n\n if (!stateRates) return []\n\n var availableTypes: ShippingType[] = []\n\n if (stateRates[0] || stateRates[0] === 0) availableTypes.push(ShippingType.pickup)\n if (stateRates[1] || stateRates[1] === 0) availableTypes.push(ShippingType.home)\n if (stateRates[2] || stateRates[2] === 0) availableTypes.push(ShippingType.store)\n\n return availableTypes\n }\n\n /**\n * Retrieves the current shipping method.\n * @returns The shipping method or null.\n */\n getShippingMethod(): ShippingMethodEntity | null {\n return this.shippingMethod\n }\n\n /**\n * Sets the shipping address for the cart.\n * @param address - The shipping address.\n */\n setShippingAddress(address: CartShippingAddress, notify = true): void {\n if (\n this.shippingAddress.city !== address.city ||\n this.shippingAddress.state !== address.state ||\n this.shippingAddress.type !== address.type\n ) {\n this.shippingAddress = address\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the current shipping address.\n * @returns The shipping address.\n */\n getShippingAddress(): CartShippingAddress {\n return this.shippingAddress\n }\n\n /**\n * Calculates the shipping price based on the address and shipping method.\n * @returns The shipping price or 0 if not applicable.\n */\n getShippingPrice(): number {\n // if at least one item have freeShipping offer return 0\n for (const item of this.items) {\n if (item.offer?.freeShipping) return 0\n }\n\n // if no shipping method is set, return 0\n if (!this.shippingMethod) return 0\n\n // if no shipping address is set, return the shipping method price\n if (!this.shippingAddress.state) return this.shippingMethod.price ?? 0\n\n // avalable shipping types\n const shippings = this.getAvailableShippingTypes()\n\n const currentOne = this.getShippingPriceForType(this.shippingAddress.type)\n if (currentOne) {\n return currentOne\n }\n\n for (const type of shippings) {\n if (this.getShippingPriceForType(type) !== null) {\n return this.getShippingPriceForType(type)!\n }\n }\n\n return 0\n }\n\n /**\n * Gets the shipping price for a specific shipping type using the current shipping address state.\n * @param type - The shipping type to check (pickup, home, store)\n * @returns The shipping price for the specified type, or null if not available\n */\n getShippingPriceForType(type: ShippingType): number | null {\n if (!this.shippingMethod?.rates || !this.shippingAddress.state) return null\n\n const stateIndex = Number.parseInt(this.shippingAddress.state, 10) - 1\n const rates = this.shippingMethod.rates[stateIndex]\n\n if (!rates) return null\n\n switch (type) {\n case ShippingType.pickup:\n return rates[0]\n case ShippingType.home:\n return rates[1]\n case ShippingType.store:\n return rates[2]\n default:\n return null\n }\n }\n\n /**\n * Calculates the total cost of the cart including shipping.\n * @param withCurrentItem - Whether to include the current item in the total.\n * @returns The total cost.\n */\n getTotal(withCurrentItem = true): number {\n const subTotal = this.getSubtotal(withCurrentItem)\n const shippingPrice = this.getShippingPrice() ?? 0\n const selectedOffer = this.currentItem?.offer\n if (selectedOffer && selectedOffer.freeShipping) {\n return subTotal // If the current item has free shipping, return subtotal only\n }\n return subTotal + shippingPrice\n }\n\n /**\n * Retrieves all items in the cart.\n * @returns An array of cart items.\n */\n getAll(): CartItem[] {\n return [...this.items] // Return a copy to prevent external modification\n }\n\n /**\n * Checks if the cart is empty.\n * @returns True if the cart is empty, otherwise false.\n */\n isEmpty(): boolean {\n return this.items.length === 0\n }\n\n /**\n * Notifies listeners if the cart state has meaningfully changed.\n */\n private notifyIfChanged(): void {\n // This method could be enhanced to track and notify only meaningful changes\n this.notify()\n }\n}\n","import { EmbaddedAddress } from '../embadded/address.js'\nimport { EmbaddedCategory } from '../embadded/category.js'\nimport { EmbaddedContact } from '../embadded/contact.js'\nimport { OrderEntity, OrderStatus, DeliveryStatus, PaymentStatus } from './order.js'\nimport { MetaPixelEvent, TiktokPixelEvent } from './product.js'\n// import { OrderEntity } from \"./order.js\";\n// import { ShippingMethodEntity } from \"./shipping_method.js\";\nimport { UserEntity } from './user.js'\nimport { CategoryEntity } from './category.js'\nimport { DateTime } from 'luxon'\n\nexport interface StoreEntity {\n id: string\n slug: string\n banner: StoreBanner | null\n action: StoreAction | null\n domain: StoreDomain | null\n decoration: StoreDecoration | null\n name: string\n iconUrl: string | null\n logoUrl: string | null\n // deprecated\n ondarkLogoUrl: string | null\n userId: string\n categories: EmbaddedCategory[]\n categoriesRelation?: CategoryEntity[]\n title: string | null\n description: string | null\n addresses: EmbaddedAddress[]\n address: EmbaddedAddress | null\n metadata: Record<string, any>\n contacts: EmbaddedContact[]\n integrations?: StoreIntegrations | null\n publicIntegrations: PublicStoreIntegrations | null\n verifiedAt: any | null\n blockedAt: any | null\n createdAt: any\n updatedAt: any\n // products: ProductEntity[];\n user?: UserEntity\n // orders: OrderEntity[];\n // shippingMethods: ShippingMethodEntity[];\n defaultShippingRates: (number | null)[][] | null\n\n // subscription\n subscription?: any\n due?: number\n\n // StoreConfigs\n configs?: StoreConfigs\n\n // metaPixelIds\n metaPixelIds?: string[] | null\n\n // tiktokPixelIds\n tiktokPixelIds?: string[] | null\n\n // googleAnalyticsId\n googleAnalyticsId?: string | null\n\n // googleTagsId\n googleTagsId?: string | null\n\n // members\n members?: Record<string, StoreMember>\n}\n\n// function that generate public data from the integrations data\nexport const generatePublicStoreIntegrations = (\n integrations: StoreIntegrations | null | undefined\n): PublicStoreIntegrations | null => {\n if (!integrations) return null\n const { metaPixel, tiktokPixel, googleAnalytics, googleTags, orderdz, webhooks, ai, security } =\n integrations\n return {\n metaPixel: generatePublicStoreIntegrationMetaPixel(metaPixel) || null,\n tiktokPixel: generatePublicStoreIntegrationTiktokPixel(tiktokPixel) || null,\n googleAnalytics: generatePublicStoreIntegrationGoogleAnalytics(googleAnalytics) || null,\n googleTags: generatePublicStoreIntegrationGoogleTags(googleTags) || null,\n googleSheet: null,\n ai: generatePublicStoreIntegrationAi(ai) || null,\n orderdz: generatePublicStoreIntegrationOrderdz(orderdz) || null,\n webhooks: generatePublicStoreIntegrationWebhooks(webhooks) || null,\n security: generatePublicStoreIntegrationSecurity(security) || null,\n }\n}\nexport const generatePublicStoreIntegrationMetaPixel = (\n metaPixel: MetaPixelIntegration | null | undefined\n): PublicMetaPixelIntegration | null | undefined => {\n if (!metaPixel) return null\n return {\n pixels: metaPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: metaPixel.active,\n objective: metaPixel.objective,\n draftObjective: metaPixel.draftObjective,\n }\n}\nexport const generatePublicStoreIntegrationTiktokPixel = (\n tiktokPixel: TiktokPixelIntegration | null | undefined\n): PublicTiktokPixelIntegration | null | undefined => {\n if (!tiktokPixel) return null\n return {\n pixels: tiktokPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: tiktokPixel.active,\n objective: tiktokPixel.objective,\n draftObjective: tiktokPixel.draftObjective,\n }\n}\nexport const generatePublicStoreIntegrationGoogleAnalytics = (\n googleAnalytics: GoogleAnalyticsIntegration | null | undefined\n): PublicGoogleAnalyticsIntegration | null | undefined => {\n if (!googleAnalytics) return null\n return {\n id: googleAnalytics.id,\n active: googleAnalytics.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleSheet = (\n googleSheet: GoogleSheetsIntegration | null | undefined\n): PublicGoogleSheetsIntegration | null | undefined => {\n if (!googleSheet) return null\n return null\n}\nexport const generatePublicStoreIntegrationGoogleTags = (\n googleTags: GoogleTagsIntegration | null | undefined\n): PublicGoogleTagsIntegration | null | undefined => {\n if (!googleTags) return null\n const { id, active } = googleTags\n return {\n id,\n active,\n }\n}\n\n/**\n * Generates public AI integration data from private integration data.\n * Only exposes non-sensitive information, keeping the API key private for security.\n */\nexport const generatePublicStoreIntegrationAi = (\n ai: AiIntegration | null | undefined\n): PublicAiIntegration | null | undefined => {\n if (!ai) return null\n return {\n active: ai.active,\n textModel: ai.textModel,\n imageModel: ai.imageModel,\n }\n}\n\n/**\n * Generates public OrderDZ integration data from private integration data.\n * Only exposes the URL and active status, keeping the token private for security.\n */\nexport const generatePublicStoreIntegrationOrderdz = (\n orderdz: OrderdzIntegration | null | undefined\n): PublicOrderdzIntegration | null | undefined => {\n if (!orderdz) return null\n return {\n url: orderdz.url,\n active: orderdz.active,\n }\n}\n\n/**\n * Generates public webhooks integration data from private integration data.\n * Only exposes non-sensitive information, keeping secrets private for security.\n */\nexport const generatePublicStoreIntegrationWebhooks = (\n webhooks: WebhooksIntegration | null | undefined\n): PublicWebhooksIntegration | null | undefined => {\n if (!webhooks) return null\n\n const activeWebhooks = webhooks.webhooks.filter((webhook) => webhook.active)\n\n return {\n webhookCount: webhooks.webhooks.length,\n activeWebhookCount: activeWebhooks.length,\n active: webhooks.active,\n webhookUrls: activeWebhooks.map((webhook) => webhook.url),\n }\n}\n/**\n * Generates public security integration data from private integration data.\n * Only exposes non-sensitive information, keeping backend protection details private for security.\n */\nexport const generatePublicStoreIntegrationSecurity = (\n security: SecurityIntegration | null | undefined\n): PublicSecurityIntegration | null | undefined => {\n if (!security) return null\n\n return {\n key: '[none]',\n orders: security.orders\n ? {\n frontend: security.orders.frontend,\n }\n : undefined,\n active: security.active,\n }\n}\n\n/**\n * Public interface for OrderDZ integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicOrderdzIntegration {\n url: string\n active: boolean\n}\n\n/**\n * Public interface for webhooks integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicWebhooksIntegration {\n /** Total number of configured webhooks */\n webhookCount: number\n /** Number of active webhooks */\n activeWebhookCount: number\n /** Whether the integration is active */\n active: boolean\n /** List of active webhook URLs (without secrets) */\n webhookUrls: string[]\n}\n\nexport interface PublicMetaPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n}\nexport interface PublicTiktokPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n objective?: TiktokPixelEvent | null\n draftObjective?: TiktokPixelEvent | null\n}\nexport interface PublicGoogleAnalyticsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleSheetsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleTagsIntegration {\n id: string\n active: boolean\n}\n\nexport interface PublicAiIntegration {\n active: boolean\n textModel: string\n imageModel: string\n}\n\nexport interface PublicStoreIntegrations {\n metaPixel: PublicMetaPixelIntegration | null\n tiktokPixel: PublicTiktokPixelIntegration | null\n googleAnalytics: PublicGoogleAnalyticsIntegration | null\n googleSheet: PublicGoogleSheetsIntegration | null\n googleTags: PublicGoogleTagsIntegration | null\n ai: PublicAiIntegration | null\n orderdz: PublicOrderdzIntegration | null\n webhooks: PublicWebhooksIntegration | null\n security: PublicSecurityIntegration | null\n}\n\nexport enum StoreMemberRole {\n editor = 'editor',\n viewer = 'viewer',\n confermer = 'confermer',\n}\n\nexport interface StoreMember {\n name: string\n userId: string\n role: StoreMemberRole\n acceptedAt: any | null\n expiredAt: any | null\n createdAt: any\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreConfigs {\n currencies: StoreCurrencyConfig[]\n defaultCurrency: number\n languages?: StoreLanguageConfig[]\n defaultLanguage?: string\n customStatusMappings?: CustomStatusMapping[]\n /** Feature flag to enable custom statuses across the app */\n customStatusEnabled?: boolean\n}\n\nexport interface CustomStatusMapping {\n /** The custom status name (e.g., \"not_respond\", \"phone_closed_1\") */\n name: string\n /** Auto-generated code based on name if not provided (e.g., \"not_respond\" -> \"not_respond\") */\n code?: string\n /** Optional color for UI display (hex color as number) */\n color?: number\n /** Whether this custom status is enabled and should be shown in UI */\n enabled?: boolean\n /** Status to map to (null means no change) */\n status?: OrderStatus | null\n /** Delivery status to map to (null means no change) */\n deliveryStatus?: DeliveryStatus | null\n /** Payment status to map to (null means no change) */\n paymentStatus?: PaymentStatus | null\n}\n\nexport interface StoreCurrencyConfig {\n code: string\n symbol: string\n precision: number\n rate: number\n}\n\nexport interface StoreLanguageConfig {\n code: string\n name: string\n nativeName: string\n rtl?: boolean\n}\n\nexport interface StoreDomain {\n name: string\n verifiedAt: any | null\n metadata: Record<string, any>\n}\nexport interface StoreBanner {\n title: string\n url?: string | null\n enabled: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreDecoration {\n // primary\n primary: number\n onPrimary?: number\n // on dark mode\n primaryDark?: number\n onPrimaryDark?: number\n // secondary\n secondary?: number\n onSecondary?: number\n // on dark mode\n secondaryDark?: number\n onSecondaryDark?: number\n\n useLogoDarkFilter?: boolean\n\n showStoreLogoInHeader?: boolean\n logoFullHeight?: boolean\n showStoreNameInHeader?: boolean\n metadata?: Record<string, any>\n [key: string]: any\n}\n\nexport interface StoreAction {\n label: string\n url: string\n type: StoreActionType\n}\n\nexport enum StoreActionType {\n link = 'link',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n phone = 'phone',\n}\nexport interface MetaPixel {\n name?: string\n id: string\n key?: string\n}\n// tiktok pixel\nexport interface TiktokPixel {\n name?: string\n id: string\n accessToken?: string\n}\n// meta pixel integration\nexport interface MetaPixelIntegration {\n id: string\n pixels: MetaPixel[]\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n active: boolean\n metadata: Record<string, any>\n}\n// tiktok pixel integration\nexport interface TiktokPixelIntegration {\n id: string\n pixels: TiktokPixel[]\n objective?: TiktokPixelEvent | null\n draftObjective?: TiktokPixelEvent | null\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface GoogleAnalyticsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n// export enum GoogleSheetsColumnType {\n// string = 'string',\n// number = 'number',\n// boolean = 'boolean',\n// date = 'date',\n// }\n\nexport interface GoogleSheetsColumn<T> {\n // it can be path in json field for exmple metadata.customData\n field: keyof OrderEntity | string | 'skus' | 'quantities' | 'itemsNames'\n name: string\n enabled: boolean\n defaultValue?: T\n // type:\n}\nexport interface GoogleSheetsIntegration {\n id: string\n name: string\n active: boolean\n oauth2?: Record<string, any>\n metadata: Record<string, any>\n simple?: boolean\n columns?: GoogleSheetsColumn<any>[]\n}\nexport interface GoogleTagsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n/**\n * AI integration configuration for Google AI Studio.\n */\nexport interface AiIntegration {\n active: boolean\n apiKey?: string\n textModel: string\n imageModel: string\n metadata: Record<string, any>\n}\n\n/**\n * OrderDZ integration configuration for order confirmation service.\n * This integration allows automatic order confirmation via OrderDZ API.\n */\nexport interface OrderdzIntegration {\n /** Unique identifier for this integration instance */\n id: string\n /** API endpoint URL for OrderDZ service (e.g., \"https://orderdz.com/api/v1/feeef/order\") */\n url: string\n /** Authentication token for OrderDZ API */\n token: string\n /** Whether this integration is currently active */\n active: boolean\n /** Whether to automatically send orders when they are marked as sent */\n autoSend?: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\n/**\n * Ecomanager integration configuration for delivery management.\n * This integration allows order management and tracking via Ecomanager API.\n */\nexport interface EcomanagerIntegration {\n active: boolean\n baseUrl: string\n token: string\n autoSend?: boolean\n metadata?: Record<string, any>\n}\n\n/**\n * Zimou Express integration configuration for delivery management.\n * This integration allows order management and tracking via Zimou Express API.\n */\nexport interface ZimouIntegration {\n /** Unique identifier for this integration instance */\n id: string\n /** API authentication key for Zimou Express */\n apiKey: string\n /** Whether this integration is currently active */\n active: boolean\n /** Whether to send orders directly without confirmation dialog */\n silentMode?: boolean\n /** Whether to automatically send orders when they are marked as sent */\n autoSend?: boolean\n /** Additional metadata for the integration */\n metadata?: Record<string, any>\n}\n\nexport interface SecurityIntegrationOrdersProtection {\n frontend: {\n active: boolean\n }\n backend: {\n active: boolean\n phoneTtl: number\n ipTtl: number\n blockDirectOrders: boolean\n adsOnlyMode: boolean\n }\n}\nexport interface PublicSecurityIntegrationOrdersProtection {\n frontend: {\n active: boolean\n }\n}\nexport interface SecurityIntegration {\n orders?: SecurityIntegrationOrdersProtection\n\n /** Whether this integration is currently active */\n active: boolean\n /** Additional metadata for the integration */\n metadata?: Record<string, any>\n}\nexport interface PublicSecurityIntegration {\n key?: string | null\n orders?: PublicSecurityIntegrationOrdersProtection\n\n /** Whether this integration is currently active */\n active: boolean\n /** Additional metadata for the integration */\n metadata?: Record<string, any>\n}\n\n/**\n * Webhook event types for order lifecycle\n */\nexport enum WebhookEvent {\n ORDER_CREATED = 'orderCreated',\n ORDER_UPDATED = 'orderUpdated',\n ORDER_DELETED = 'orderDeleted',\n}\n\n/**\n * Individual webhook configuration\n */\nexport interface WebhookConfig {\n /** Unique identifier for this webhook */\n id: string\n /** Human-readable name for this webhook */\n name: string\n /** Target URL where webhook events will be sent */\n url: string\n /** Events this webhook is subscribed to */\n events: WebhookEvent[]\n /** Optional secret key for HMAC signature verification */\n secret?: string\n /** Whether this webhook is currently active */\n active: boolean\n /** Additional HTTP headers to send with webhook requests */\n headers?: Record<string, string>\n /** Additional metadata for this webhook */\n metadata: Record<string, any>\n}\n\n/**\n * Webhooks integration configuration for real-time order notifications\n */\nexport interface WebhooksIntegration {\n /** List of configured webhooks */\n webhooks: WebhookConfig[]\n /** Whether the webhooks integration is active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\nexport interface StoreIntegrations {\n [key: string]: any\n metadata?: Record<string, any>\n\n // @Default('default') String id,\n // @Default([]) List<MetaPixel> pixels,\n // @Default(true) bool active,\n // @Default({}) Map<String, dynamic> metadata,\n metaPixel?: MetaPixelIntegration\n tiktokPixel?: TiktokPixelIntegration\n googleAnalytics?: GoogleAnalyticsIntegration\n googleSheet?: GoogleSheetsIntegration\n googleTags?: GoogleTagsIntegration\n ai?: AiIntegration\n orderdz?: OrderdzIntegration\n webhooks?: WebhooksIntegration\n\n sms?: any\n telegram?: any\n yalidine?: any\n maystroDelivery?: any\n echotrak?: any\n ecotrack?: any\n ecomanager?: EcomanagerIntegration\n procolis?: any\n noest?: any\n zimou?: ZimouIntegration\n\n security?: SecurityIntegration\n}\n\nexport enum StoreSubscriptionStatus {\n active = 'active',\n inactive = 'inactive',\n}\n\nexport enum StoreSubscriptionType {\n free = 'free',\n premium = 'premium',\n vip = 'vip',\n custom = 'custom',\n}\n\nexport interface StoreSubscription {\n type: StoreSubscriptionType\n name: string\n status: StoreSubscriptionStatus\n startedAt: DateTime\n expiresAt: DateTime | null\n quota: number\n consumed: number\n remaining: number\n metadata: Record<string, any>\n}\n","import { EmbaddedCategory } from '../embadded/category.js'\nimport { ShippingMethodEntity } from './shipping_method.js'\nimport { GoogleSheetsColumn, StoreEntity } from './store.js'\nimport { CategoryEntity } from './category.js'\n\nexport interface ProductEntity {\n id: string\n\n slug: string\n\n decoration: ProductDecoration | null\n\n name: string | null\n\n photoUrl: string | null\n\n media: string[]\n\n storeId: string\n\n shippingMethodId?: string | null\n\n categoryId?: string | null\n\n category?: EmbaddedCategory | null\n\n categoryRelation?: CategoryEntity | null\n\n title: string | null\n\n description: string | null\n\n body: string | null\n\n // sku\n sku: string | null\n\n price: number\n\n cost: number | null\n\n discount: number | null\n\n stock: number | null\n\n sold: number\n\n views: number\n\n likes: number\n\n dislikes: number\n\n variant?: ProductVariant | null\n\n offers?: ProductOffer[] | null\n\n metadata: Record<string, any>\n\n status: ProductStatus\n\n type: ProductType\n\n verifiedAt: any | null\n\n blockedAt: any | null\n\n createdAt: any\n\n updatedAt: any\n\n addons?: ProductAddon[] | null\n\n // integrations configs\n integrationsData?: IntegrationsData | null\n publicIntegrationsData?: IntegrationsData | null\n\n // relations\n store?: StoreEntity | null\n shippingMethod?: ShippingMethodEntity | null\n}\n\n// function that generate public data from the integrations data\nexport function generatePublicIntegrationsData(data: IntegrationsData | null | null): any {\n if (!data) return data\n const { metaPixelData, tiktokPixelData, googleAnalyticsData, googleTagsData } = data\n return {\n metaPixelData: generatePublicIntegrationsDataMetaPixel(metaPixelData),\n tiktokPixelData: generatePublicIntegrationsDataTiktokPixel(tiktokPixelData),\n googleAnalyticsData: generatePublicIntegrationsDataGoogleAnalytics(googleAnalyticsData),\n googleTagsData: generatePublicIntegrationsDataGoogleTag(googleTagsData),\n }\n}\n// function that generate public data from the meta pixel data\nexport function generatePublicIntegrationsDataMetaPixel(\n data: MetaPixelData | null | undefined\n): PublicMetaPixelData | null | undefined {\n if (!data) return data\n const { ids, objective, draftObjective } = data\n return {\n ids: ids,\n objective,\n draftObjective,\n }\n}\n// function that generate public data from the tiktok pixel data\nexport function generatePublicIntegrationsDataTiktokPixel(\n data: TiktokPixelData | null | undefined\n): PublicTiktokPixelData | null | undefined {\n if (!data) return data\n const { ids, objective, draftObjective } = data\n return {\n ids: ids,\n objective,\n draftObjective,\n }\n}\n// function that generate public data from the google analytics data\nexport function generatePublicIntegrationsDataGoogleAnalytics(\n data: GoogleAnalyticsData | null | undefined\n): PublicGoogleAnalyticsData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google tag data\nexport function generatePublicIntegrationsDataGoogleTag(\n data: GoogleTagData | null | undefined\n): PublicGoogleTagData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google sheets data\nexport function generatePublicIntegrationsDataGoogleSheets(\n data: GoogleSheetsData | null | undefined\n): PublicGoogleSheetsData | null | undefined {\n if (!data) return data\n return {}\n}\n\nexport interface IntegrationsData {\n metaPixelData?: MetaPixelData | null\n tiktokPixelData?: TiktokPixelData | null\n googleAnalyticsData?: GoogleAnalyticsData | null\n googleTagsData?: GoogleTagData | null\n googleSheetsData?: GoogleSheetsData | null\n}\n\nexport enum MetaPixelEvent {\n none = 'none',\n lead = 'Lead',\n purchase = 'Purchase',\n viewContent = 'ViewContent',\n addToCart = 'AddToCart',\n initiateCheckout = 'InitiateCheckout',\n}\nexport interface MetaPixelData {\n // active meta pixel ids\n ids: string[] | null\n // main objective\n objective: MetaPixelEvent | null\n // draft objective\n draftObjective: MetaPixelEvent | null\n}\n\nexport enum TiktokPixelEvent {\n none = 'none',\n viewContent = 'ViewContent',\n addToWishlist = 'AddToWishlist',\n search = 'Search',\n addPaymentInfo = 'AddPaymentInfo',\n addToCart = 'AddToCart',\n initiateCheckout = 'InitiateCheckout',\n placeAnOrder = 'PlaceAnOrder',\n completeRegistration = 'CompleteRegistration',\n purchase = 'Purchase',\n}\nexport interface TiktokPixelData {\n // active tiktok pixel ids\n ids: string[] | null\n // main objective\n objective: TiktokPixelEvent | null\n // draft objective\n draftObjective: TiktokPixelEvent | null\n}\nexport interface GoogleAnalyticsData {}\nexport interface GoogleTagData {}\nexport interface GoogleSheetsData {\n enabled: boolean\n // use cant use both sheetId and sheetName\n sheetId: string | null\n // if sheetId is null, use sheetName\n // if sheetName not exists in the spreadsheet, create it\n sheetName: string | null\n spreadsheetId: string | null\n // the next row to insert data\n nextRow: number | null\n // columns to insert data\n columns: GoogleSheetsColumn<any>[] | null\n}\n\n// public meta pixel data\nexport interface PublicMetaPixelData {\n ids: string[] | null\n objective: MetaPixelEvent | null\n draftObjective: MetaPixelEvent | null\n}\n// public tiktok pixel data\nexport interface PublicTiktokPixelData {\n ids: string[] | null\n objective: TiktokPixelEvent | null\n draftObjective: TiktokPixelEvent | null\n}\n// public google analytics data\nexport interface PublicGoogleAnalyticsData {}\n// public google tag data\nexport interface PublicGoogleTagData {}\n// public google sheets data\nexport interface PublicGoogleSheetsData {}\n\nexport interface ProductAddon {\n photoUrl?: string\n title: string\n subtitle?: string\n stock?: number\n price?: number\n min?: number\n max?: number\n}\n\nexport enum ProductStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n deleted = 'deleted',\n}\n\nexport interface ProductDecoration {\n metadata: Record<string, any>\n}\n\nexport interface ProductVariant {\n name: string\n view?: ProductVariantView\n options: ProductVariantOption[]\n required?: boolean\n}\n\nexport enum ProductVariantView {\n list = 'list',\n chips = 'chips',\n dropdown = 'dropdown',\n}\n\nexport interface ProductVariantOption {\n name: string\n sku?: string | null\n price?: number | null\n discount?: number | null\n stock?: number | null\n sold?: number | null\n type?: VariantOptionType\n child?: ProductVariant | null\n mediaIndex?: number | null\n hint?: string | null\n value?: any\n mediaId?: string | null\n hidden?: boolean\n}\n\nexport enum VariantOptionType {\n color = 'color',\n image = 'image',\n text = 'text',\n}\n\nexport enum ProductType {\n physical = 'physical',\n digital = 'digital',\n service = 'service',\n}\n\nexport interface ProductOffer {\n code: string\n title: string\n subtitle?: string\n price?: number\n minQuantity?: number\n maxQuantity?: number\n freeShipping?: boolean\n}\n","export enum EmbaddedContactType {\n phone = 'phone',\n email = 'email',\n facebook = 'facebook',\n twitter = 'twitter',\n instagram = 'instagram',\n linkedin = 'linkedin',\n website = 'website',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n signal = 'signal',\n viber = 'viber',\n skype = 'skype',\n zoom = 'zoom',\n other = 'other',\n}\n\n// EmbaddedContactType is not enum but can only be: \"phone\" | \"email\" | \"facebook\" | \"twitter\" | \"instagram\" | \"linkedin\" | \"website\" | \"whatsapp\" | \"telegram\" | \"signal\" | \"viber\" | \"skype\" | \"zoom\" | \"other\n\nexport interface EmbaddedContact {\n type: EmbaddedContactType\n value: string\n name?: string\n metadata?: Record<string, any>\n}\n","/**\n * Converts a Dart color (0xffXXXXXX) to a CSS-compatible number (0xXXXXXXFF).\n *\n * @param dartColor - The Dart color represented as a 32-bit integer (0xffXXXXXX).\n * @returns A number representing the color in CSS format (0xXXXXXXFF).\n */\nexport const convertDartColorToCssNumber = (dartColor: number): number => {\n const alpha = (dartColor >> 24) & 0xff // Extract alpha (high 8 bits)\n const rgb = dartColor & 0xffffff // Extract RGB (low 24 bits)\n\n // Return color as 0xXXXXXXFF (CSS format: RGB + alpha)\n return (rgb << 8) | alpha\n}\n\n/**\n * Converts a CSS color (0xXXXXXXFF) to HSL format.\n *\n * @param cssColor - The CSS color represented as a 32-bit integer (0xXXXXXXFF).\n * @returns An object with HSL values {h, s, l}.\n */\nexport const cssColorToHslString = (cssColor: number): string => {\n const r = ((cssColor >> 24) & 0xff) / 255 // Extract red channel\n const g = ((cssColor >> 16) & 0xff) / 255 // Extract green channel\n const b = ((cssColor >> 8) & 0xff) / 255 // Extract blue channel\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n let l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0)\n break\n case g:\n h = (b - r) / d + 2\n break\n case b:\n h = (r - g) / d + 4\n break\n }\n h /= 6\n }\n\n return `${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%`\n}\n\n/**\n * Trims and attempts to fix the phone number by:\n * - Removing all non-numeric characters\n * - Ensuring it starts with a '0'\n * @param phone - The input phone number string\n * @returns The cleaned phone number\n */\nexport function tryFixPhoneNumber(phone: string): string {\n phone = phone.trim() // Remove leading/trailing spaces\n // Remove all non-numeric characters\n phone = phone.replace(/\\D/g, '')\n // Ensure the phone number starts with '0'\n if (!phone.startsWith('0')) {\n phone = '0' + phone\n }\n return phone\n}\n\n/**\n * Validates the phone number based on specific rules:\n * - Cannot be empty or just \"0\"\n * - Must start with '05', '06', '07', or '02'\n * - Must be 10 digits for mobile numbers (05, 06, 07)\n * - Must be 9 digits for landline numbers (02)\n * @param phone - The input phone number string\n * @returns Error message if validation fails, otherwise null\n */\nexport function validatePhoneNumber(phone: string): string | null {\n // Helper function to handle length overflow/underflow messages\n const getLengthError = (requiredLength: number, actualLength: number): string => {\n const difference = actualLength - requiredLength\n if (difference > 0) {\n return `عدد الأرقام زائد عن ${requiredLength} رقماً بـ ${difference}`\n } else {\n const missingDigits = -difference\n if (missingDigits === 1) return 'ينقصك رقم واحد'\n if (missingDigits === 2) return 'ينقصك رقمان'\n return `ينقصك ${missingDigits} أرقام`\n }\n }\n\n if (phone === '0') {\n return 'اكمل رقم الهاتف'\n }\n\n // Check if phone number is empty\n if (!phone) {\n return 'رقم الهاتف لا يمكن أن يكون فارغاً.'\n }\n\n // Check if phone number contains only digits\n if (!/^\\d+$/.test(phone)) {\n return 'رقم الهاتف يجب أن يحتوي فقط على أرقام.'\n }\n\n // Ensure the phone starts with valid prefixes\n if (!/^(05|06|07|02)/.test(phone)) {\n return 'يجب أن يبدأ بـ 05, 06, 07, أو 02'\n }\n\n const length = phone.length\n\n // Validate mobile numbers (05, 06, 07 should be 10 digits)\n if (/^(05|06|07)/.test(phone)) {\n if (length !== 10) {\n return getLengthError(10, length)\n }\n }\n\n // Validate landline numbers (02 should be 9 digits)\n else if (phone.startsWith('02')) {\n if (length !== 9) {\n return getLengthError(9, length)\n }\n }\n\n // If all checks pass, return null (no errors)\n return null\n}\n"],"mappings":";AAAA,OAAO,WAA8B;;;ACQ9B,IAAe,kBAAf,MAAwC;AAAA,EAC7C;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,UAAkB,QAAuB;AACnD,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAuC;AAChD,UAAM,EAAE,IAAI,IAAI,OAAO,IAAI;AAC3B,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,EAAE,IAAI;AAAA,MAC3D,QAAQ;AAAA,QACN,IAAI,MAAM;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AACD,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAsD;AAC/D,UAAM,EAAE,MAAM,QAAQ,OAAO,OAAO,IAAI,WAAW,CAAC;AACpD,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI;AAAA,MACrD,QAAQ,EAAE,MAAM,QAAQ,OAAO,GAAG,OAAO;AAAA,IAC3C,CAAC;AAED,QAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;AAC3B,aAAO;AAAA,QACL,MAAM,IAAI;AAAA,MACZ;AAAA,IACF,OAAO;AACL,aAAO;AAAA,QACL,MAAM,IAAI,KAAK;AAAA,QACf,OAAO,IAAI,KAAK,KAAK;AAAA,QACrB,MAAM,IAAI,KA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AM,KAAK;AAEnB,UAAQ,MAAM,QAAQ,OAAO,EAAE;AAE/B,MAAI,CAAC,MAAM,WAAW,GAAG,GAAG;AAC1B,YAAQ,MAAM;AAAA,EAChB;AACA,SAAO;AACT;AAWO,SAAS,oBAAoB,OAA8B;AAEhE,QAAM,iBAAiB,CAAC,gBAAwB,iBAAiC;AAC/E,UAAM,aAAa,eAAe;AAClC,QAAI,aAAa,GAAG;AAClB,aAAO,uGAAuB,cAAc,gDAAa,UAAU;AAAA,IACrE,OAAO;AACL,YAAM,gBAAgB,CAAC;AACvB,UAAI,kBAAkB,EAAG,QAAO;AAChC,UAAI,kBAAkB,EAAG,QAAO;AAChC,aAAO,kCAAS,aAAa;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI,UAAU,KAAK;AACjB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,QAAQ,KAAK,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,iBAAiB,KAAK,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM;AAGrB,MAAI,cAAc,KAAK,KAAK,GAAG;AAC7B,QAAI,WAAW,IAAI;AACjB,aAAO,eAAe,IAAI,MAAM;AAAA,IAClC;AAAA,EACF,WAGS,MAAM,WAAW,IAAI,GAAG;AAC/B,QAAI,WAAW,GAAG;AAChB,aAAO,eAAe,GAAG,MAAM;AAAA,IACjC;AAAA,EACF;AAGA,SAAO;AACT;","names":["OrderStatus","PaymentStatus","DeliveryStatus","ShippingType","ShippingMethodStatus","ShippingMethodPolicy","StoreMemberRole","StoreActionType","WebhookEvent","StoreSubscriptionStatus","StoreSubscriptionType","MetaPixelEvent","TiktokPixelEvent","ProductStatus","ProductVariantView","VariantOptionType","ProductType","EmbaddedContactType"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CategoryEntity {
|
|
2
|
+
id: string;
|
|
3
|
+
storeId: string;
|
|
4
|
+
parentId: string | null;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
photoUrl: string | null;
|
|
8
|
+
metadata: Record<string, any>;
|
|
9
|
+
parent?: CategoryEntity | null;
|
|
10
|
+
children?: CategoryEntity[];
|
|
11
|
+
createdAt: any;
|
|
12
|
+
updatedAt: any;
|
|
13
|
+
}
|
|
@@ -28,6 +28,7 @@ export interface OrderEntity {
|
|
|
28
28
|
customerName?: string | null;
|
|
29
29
|
customerPhone: string;
|
|
30
30
|
customerEmail?: string | null;
|
|
31
|
+
customerNote?: string | null;
|
|
31
32
|
customerIp?: string | null;
|
|
32
33
|
shippingAddress?: string | null;
|
|
33
34
|
shippingCity?: string | null;
|
|
@@ -45,11 +46,13 @@ export interface OrderEntity {
|
|
|
45
46
|
couponCode?: string | null;
|
|
46
47
|
couponDiscount?: string | null;
|
|
47
48
|
storeId: string;
|
|
49
|
+
source: string | null;
|
|
48
50
|
confirmerId: string | null;
|
|
49
51
|
metadata: OrderMetadata;
|
|
50
52
|
status: OrderStatus;
|
|
51
53
|
paymentStatus: PaymentStatus;
|
|
52
54
|
deliveryStatus: DeliveryStatus;
|
|
55
|
+
customStatus?: string | null;
|
|
53
56
|
tags: string[] | null;
|
|
54
57
|
createdAt: any;
|
|
55
58
|
updatedAt: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EmbaddedCategory } from '../embadded/category.js';
|
|
2
2
|
import { ShippingMethodEntity } from './shipping_method.js';
|
|
3
3
|
import { GoogleSheetsColumn, StoreEntity } from './store.js';
|
|
4
|
+
import { CategoryEntity } from './category.js';
|
|
4
5
|
export interface ProductEntity {
|
|
5
6
|
id: string;
|
|
6
7
|
slug: string;
|
|
@@ -10,7 +11,9 @@ export interface ProductEntity {
|
|
|
10
11
|
media: string[];
|
|
11
12
|
storeId: string;
|
|
12
13
|
shippingMethodId?: string | null;
|
|
14
|
+
categoryId?: string | null;
|
|
13
15
|
category?: EmbaddedCategory | null;
|
|
16
|
+
categoryRelation?: CategoryEntity | null;
|
|
14
17
|
title: string | null;
|
|
15
18
|
description: string | null;
|
|
16
19
|
body: string | null;
|
|
@@ -40,7 +43,7 @@ export interface ProductEntity {
|
|
|
40
43
|
}
|
|
41
44
|
export declare function generatePublicIntegrationsData(data: IntegrationsData | null | null): any;
|
|
42
45
|
export declare function generatePublicIntegrationsDataMetaPixel(data: MetaPixelData | null | undefined): PublicMetaPixelData | null | undefined;
|
|
43
|
-
export declare function generatePublicIntegrationsDataTiktokPixel(data: TiktokPixelData | null | undefined):
|
|
46
|
+
export declare function generatePublicIntegrationsDataTiktokPixel(data: TiktokPixelData | null | undefined): PublicTiktokPixelData | null | undefined;
|
|
44
47
|
export declare function generatePublicIntegrationsDataGoogleAnalytics(data: GoogleAnalyticsData | null | undefined): PublicGoogleAnalyticsData | null | undefined;
|
|
45
48
|
export declare function generatePublicIntegrationsDataGoogleTag(data: GoogleTagData | null | undefined): PublicGoogleTagData | null | undefined;
|
|
46
49
|
export declare function generatePublicIntegrationsDataGoogleSheets(data: GoogleSheetsData | null | undefined): PublicGoogleSheetsData | null | undefined;
|
|
@@ -65,6 +68,16 @@ export interface MetaPixelData {
|
|
|
65
68
|
draftObjective: MetaPixelEvent | null;
|
|
66
69
|
}
|
|
67
70
|
export declare enum TiktokPixelEvent {
|
|
71
|
+
none = "none",
|
|
72
|
+
viewContent = "ViewContent",
|
|
73
|
+
addToWishlist = "AddToWishlist",
|
|
74
|
+
search = "Search",
|
|
75
|
+
addPaymentInfo = "AddPaymentInfo",
|
|
76
|
+
addToCart = "AddToCart",
|
|
77
|
+
initiateCheckout = "InitiateCheckout",
|
|
78
|
+
placeAnOrder = "PlaceAnOrder",
|
|
79
|
+
completeRegistration = "CompleteRegistration",
|
|
80
|
+
purchase = "Purchase"
|
|
68
81
|
}
|
|
69
82
|
export interface TiktokPixelData {
|
|
70
83
|
ids: string[] | null;
|
|
@@ -88,7 +101,10 @@ export interface PublicMetaPixelData {
|
|
|
88
101
|
objective: MetaPixelEvent | null;
|
|
89
102
|
draftObjective: MetaPixelEvent | null;
|
|
90
103
|
}
|
|
91
|
-
export interface
|
|
104
|
+
export interface PublicTiktokPixelData {
|
|
105
|
+
ids: string[] | null;
|
|
106
|
+
objective: TiktokPixelEvent | null;
|
|
107
|
+
draftObjective: TiktokPixelEvent | null;
|
|
92
108
|
}
|
|
93
109
|
export interface PublicGoogleAnalyticsData {
|
|
94
110
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EmbaddedAddress } from '../embadded/address.js';
|
|
2
2
|
import { EmbaddedCategory } from '../embadded/category.js';
|
|
3
3
|
import { EmbaddedContact } from '../embadded/contact.js';
|
|
4
|
-
import { OrderEntity } from './order.js';
|
|
5
|
-
import { MetaPixelEvent } from './product.js';
|
|
4
|
+
import { OrderEntity, OrderStatus, DeliveryStatus, PaymentStatus } from './order.js';
|
|
5
|
+
import { MetaPixelEvent, TiktokPixelEvent } from './product.js';
|
|
6
6
|
import { UserEntity } from './user.js';
|
|
7
|
+
import { CategoryEntity } from './category.js';
|
|
7
8
|
import { DateTime } from 'luxon';
|
|
8
9
|
export interface StoreEntity {
|
|
9
10
|
id: string;
|
|
@@ -18,6 +19,7 @@ export interface StoreEntity {
|
|
|
18
19
|
ondarkLogoUrl: string | null;
|
|
19
20
|
userId: string;
|
|
20
21
|
categories: EmbaddedCategory[];
|
|
22
|
+
categoriesRelation?: CategoryEntity[];
|
|
21
23
|
title: string | null;
|
|
22
24
|
description: string | null;
|
|
23
25
|
addresses: EmbaddedAddress[];
|
|
@@ -47,6 +49,11 @@ export declare const generatePublicStoreIntegrationTiktokPixel: (tiktokPixel: Ti
|
|
|
47
49
|
export declare const generatePublicStoreIntegrationGoogleAnalytics: (googleAnalytics: GoogleAnalyticsIntegration | null | undefined) => PublicGoogleAnalyticsIntegration | null | undefined;
|
|
48
50
|
export declare const generatePublicStoreIntegrationGoogleSheet: (googleSheet: GoogleSheetsIntegration | null | undefined) => PublicGoogleSheetsIntegration | null | undefined;
|
|
49
51
|
export declare const generatePublicStoreIntegrationGoogleTags: (googleTags: GoogleTagsIntegration | null | undefined) => PublicGoogleTagsIntegration | null | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Generates public AI integration data from private integration data.
|
|
54
|
+
* Only exposes non-sensitive information, keeping the API key private for security.
|
|
55
|
+
*/
|
|
56
|
+
export declare const generatePublicStoreIntegrationAi: (ai: AiIntegration | null | undefined) => PublicAiIntegration | null | undefined;
|
|
50
57
|
/**
|
|
51
58
|
* Generates public OrderDZ integration data from private integration data.
|
|
52
59
|
* Only exposes the URL and active status, keeping the token private for security.
|
|
@@ -57,6 +64,11 @@ export declare const generatePublicStoreIntegrationOrderdz: (orderdz: OrderdzInt
|
|
|
57
64
|
* Only exposes non-sensitive information, keeping secrets private for security.
|
|
58
65
|
*/
|
|
59
66
|
export declare const generatePublicStoreIntegrationWebhooks: (webhooks: WebhooksIntegration | null | undefined) => PublicWebhooksIntegration | null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Generates public security integration data from private integration data.
|
|
69
|
+
* Only exposes non-sensitive information, keeping backend protection details private for security.
|
|
70
|
+
*/
|
|
71
|
+
export declare const generatePublicStoreIntegrationSecurity: (security: SecurityIntegration | null | undefined) => PublicSecurityIntegration | null | undefined;
|
|
60
72
|
/**
|
|
61
73
|
* Public interface for OrderDZ integration.
|
|
62
74
|
* Contains only non-sensitive information that can be safely exposed to clients.
|
|
@@ -92,6 +104,8 @@ export interface PublicTiktokPixelIntegration {
|
|
|
92
104
|
id: string;
|
|
93
105
|
}[];
|
|
94
106
|
active: boolean;
|
|
107
|
+
objective?: TiktokPixelEvent | null;
|
|
108
|
+
draftObjective?: TiktokPixelEvent | null;
|
|
95
109
|
}
|
|
96
110
|
export interface PublicGoogleAnalyticsIntegration {
|
|
97
111
|
id: string;
|
|
@@ -105,14 +119,21 @@ export interface PublicGoogleTagsIntegration {
|
|
|
105
119
|
id: string;
|
|
106
120
|
active: boolean;
|
|
107
121
|
}
|
|
122
|
+
export interface PublicAiIntegration {
|
|
123
|
+
active: boolean;
|
|
124
|
+
textModel: string;
|
|
125
|
+
imageModel: string;
|
|
126
|
+
}
|
|
108
127
|
export interface PublicStoreIntegrations {
|
|
109
128
|
metaPixel: PublicMetaPixelIntegration | null;
|
|
110
129
|
tiktokPixel: PublicTiktokPixelIntegration | null;
|
|
111
130
|
googleAnalytics: PublicGoogleAnalyticsIntegration | null;
|
|
112
131
|
googleSheet: PublicGoogleSheetsIntegration | null;
|
|
113
132
|
googleTags: PublicGoogleTagsIntegration | null;
|
|
133
|
+
ai: PublicAiIntegration | null;
|
|
114
134
|
orderdz: PublicOrderdzIntegration | null;
|
|
115
135
|
webhooks: PublicWebhooksIntegration | null;
|
|
136
|
+
security: PublicSecurityIntegration | null;
|
|
116
137
|
}
|
|
117
138
|
export declare enum StoreMemberRole {
|
|
118
139
|
editor = "editor",
|
|
@@ -132,6 +153,27 @@ export interface StoreMember {
|
|
|
132
153
|
export interface StoreConfigs {
|
|
133
154
|
currencies: StoreCurrencyConfig[];
|
|
134
155
|
defaultCurrency: number;
|
|
156
|
+
languages?: StoreLanguageConfig[];
|
|
157
|
+
defaultLanguage?: string;
|
|
158
|
+
customStatusMappings?: CustomStatusMapping[];
|
|
159
|
+
/** Feature flag to enable custom statuses across the app */
|
|
160
|
+
customStatusEnabled?: boolean;
|
|
161
|
+
}
|
|
162
|
+
export interface CustomStatusMapping {
|
|
163
|
+
/** The custom status name (e.g., "not_respond", "phone_closed_1") */
|
|
164
|
+
name: string;
|
|
165
|
+
/** Auto-generated code based on name if not provided (e.g., "not_respond" -> "not_respond") */
|
|
166
|
+
code?: string;
|
|
167
|
+
/** Optional color for UI display (hex color as number) */
|
|
168
|
+
color?: number;
|
|
169
|
+
/** Whether this custom status is enabled and should be shown in UI */
|
|
170
|
+
enabled?: boolean;
|
|
171
|
+
/** Status to map to (null means no change) */
|
|
172
|
+
status?: OrderStatus | null;
|
|
173
|
+
/** Delivery status to map to (null means no change) */
|
|
174
|
+
deliveryStatus?: DeliveryStatus | null;
|
|
175
|
+
/** Payment status to map to (null means no change) */
|
|
176
|
+
paymentStatus?: PaymentStatus | null;
|
|
135
177
|
}
|
|
136
178
|
export interface StoreCurrencyConfig {
|
|
137
179
|
code: string;
|
|
@@ -139,6 +181,12 @@ export interface StoreCurrencyConfig {
|
|
|
139
181
|
precision: number;
|
|
140
182
|
rate: number;
|
|
141
183
|
}
|
|
184
|
+
export interface StoreLanguageConfig {
|
|
185
|
+
code: string;
|
|
186
|
+
name: string;
|
|
187
|
+
nativeName: string;
|
|
188
|
+
rtl?: boolean;
|
|
189
|
+
}
|
|
142
190
|
export interface StoreDomain {
|
|
143
191
|
name: string;
|
|
144
192
|
verifiedAt: any | null;
|
|
@@ -183,8 +231,9 @@ export interface MetaPixel {
|
|
|
183
231
|
key?: string;
|
|
184
232
|
}
|
|
185
233
|
export interface TiktokPixel {
|
|
234
|
+
name?: string;
|
|
186
235
|
id: string;
|
|
187
|
-
|
|
236
|
+
accessToken?: string;
|
|
188
237
|
}
|
|
189
238
|
export interface MetaPixelIntegration {
|
|
190
239
|
id: string;
|
|
@@ -197,6 +246,8 @@ export interface MetaPixelIntegration {
|
|
|
197
246
|
export interface TiktokPixelIntegration {
|
|
198
247
|
id: string;
|
|
199
248
|
pixels: TiktokPixel[];
|
|
249
|
+
objective?: TiktokPixelEvent | null;
|
|
250
|
+
draftObjective?: TiktokPixelEvent | null;
|
|
200
251
|
active: boolean;
|
|
201
252
|
metadata: Record<string, any>;
|
|
202
253
|
}
|
|
@@ -225,6 +276,16 @@ export interface GoogleTagsIntegration {
|
|
|
225
276
|
active: boolean;
|
|
226
277
|
metadata: Record<string, any>;
|
|
227
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* AI integration configuration for Google AI Studio.
|
|
281
|
+
*/
|
|
282
|
+
export interface AiIntegration {
|
|
283
|
+
active: boolean;
|
|
284
|
+
apiKey?: string;
|
|
285
|
+
textModel: string;
|
|
286
|
+
imageModel: string;
|
|
287
|
+
metadata: Record<string, any>;
|
|
288
|
+
}
|
|
228
289
|
/**
|
|
229
290
|
* OrderDZ integration configuration for order confirmation service.
|
|
230
291
|
* This integration allows automatic order confirmation via OrderDZ API.
|
|
@@ -238,9 +299,72 @@ export interface OrderdzIntegration {
|
|
|
238
299
|
token: string;
|
|
239
300
|
/** Whether this integration is currently active */
|
|
240
301
|
active: boolean;
|
|
302
|
+
/** Whether to automatically send orders when they are marked as sent */
|
|
303
|
+
autoSend?: boolean;
|
|
241
304
|
/** Additional metadata for the integration */
|
|
242
305
|
metadata: Record<string, any>;
|
|
243
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Ecomanager integration configuration for delivery management.
|
|
309
|
+
* This integration allows order management and tracking via Ecomanager API.
|
|
310
|
+
*/
|
|
311
|
+
export interface EcomanagerIntegration {
|
|
312
|
+
active: boolean;
|
|
313
|
+
baseUrl: string;
|
|
314
|
+
token: string;
|
|
315
|
+
autoSend?: boolean;
|
|
316
|
+
metadata?: Record<string, any>;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Zimou Express integration configuration for delivery management.
|
|
320
|
+
* This integration allows order management and tracking via Zimou Express API.
|
|
321
|
+
*/
|
|
322
|
+
export interface ZimouIntegration {
|
|
323
|
+
/** Unique identifier for this integration instance */
|
|
324
|
+
id: string;
|
|
325
|
+
/** API authentication key for Zimou Express */
|
|
326
|
+
apiKey: string;
|
|
327
|
+
/** Whether this integration is currently active */
|
|
328
|
+
active: boolean;
|
|
329
|
+
/** Whether to send orders directly without confirmation dialog */
|
|
330
|
+
silentMode?: boolean;
|
|
331
|
+
/** Whether to automatically send orders when they are marked as sent */
|
|
332
|
+
autoSend?: boolean;
|
|
333
|
+
/** Additional metadata for the integration */
|
|
334
|
+
metadata?: Record<string, any>;
|
|
335
|
+
}
|
|
336
|
+
export interface SecurityIntegrationOrdersProtection {
|
|
337
|
+
frontend: {
|
|
338
|
+
active: boolean;
|
|
339
|
+
};
|
|
340
|
+
backend: {
|
|
341
|
+
active: boolean;
|
|
342
|
+
phoneTtl: number;
|
|
343
|
+
ipTtl: number;
|
|
344
|
+
blockDirectOrders: boolean;
|
|
345
|
+
adsOnlyMode: boolean;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
export interface PublicSecurityIntegrationOrdersProtection {
|
|
349
|
+
frontend: {
|
|
350
|
+
active: boolean;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
export interface SecurityIntegration {
|
|
354
|
+
orders?: SecurityIntegrationOrdersProtection;
|
|
355
|
+
/** Whether this integration is currently active */
|
|
356
|
+
active: boolean;
|
|
357
|
+
/** Additional metadata for the integration */
|
|
358
|
+
metadata?: Record<string, any>;
|
|
359
|
+
}
|
|
360
|
+
export interface PublicSecurityIntegration {
|
|
361
|
+
key?: string | null;
|
|
362
|
+
orders?: PublicSecurityIntegrationOrdersProtection;
|
|
363
|
+
/** Whether this integration is currently active */
|
|
364
|
+
active: boolean;
|
|
365
|
+
/** Additional metadata for the integration */
|
|
366
|
+
metadata?: Record<string, any>;
|
|
367
|
+
}
|
|
244
368
|
/**
|
|
245
369
|
* Webhook event types for order lifecycle
|
|
246
370
|
*/
|
|
@@ -289,6 +413,7 @@ export interface StoreIntegrations {
|
|
|
289
413
|
googleAnalytics?: GoogleAnalyticsIntegration;
|
|
290
414
|
googleSheet?: GoogleSheetsIntegration;
|
|
291
415
|
googleTags?: GoogleTagsIntegration;
|
|
416
|
+
ai?: AiIntegration;
|
|
292
417
|
orderdz?: OrderdzIntegration;
|
|
293
418
|
webhooks?: WebhooksIntegration;
|
|
294
419
|
sms?: any;
|
|
@@ -296,8 +421,12 @@ export interface StoreIntegrations {
|
|
|
296
421
|
yalidine?: any;
|
|
297
422
|
maystroDelivery?: any;
|
|
298
423
|
echotrak?: any;
|
|
424
|
+
ecotrack?: any;
|
|
425
|
+
ecomanager?: EcomanagerIntegration;
|
|
299
426
|
procolis?: any;
|
|
300
427
|
noest?: any;
|
|
428
|
+
zimou?: ZimouIntegration;
|
|
429
|
+
security?: SecurityIntegration;
|
|
301
430
|
}
|
|
302
431
|
export declare enum StoreSubscriptionStatus {
|
|
303
432
|
active = "active",
|
|
@@ -4,6 +4,7 @@ import { ProductRepository } from './repositories/products.js';
|
|
|
4
4
|
import { StoreRepository } from './repositories/stores.js';
|
|
5
5
|
import { UserRepository } from './repositories/users.js';
|
|
6
6
|
import { DepositRepository } from './repositories/deposits.js';
|
|
7
|
+
import { CategoryRepository } from './repositories/categories.js';
|
|
7
8
|
import { CartService } from './services/cart.js';
|
|
8
9
|
/**
|
|
9
10
|
* Configuration options for the FeeeF module.
|
|
@@ -61,6 +62,10 @@ export declare class FeeeF {
|
|
|
61
62
|
* The repository for managing deposits.
|
|
62
63
|
*/
|
|
63
64
|
deposits: DepositRepository;
|
|
65
|
+
/**
|
|
66
|
+
* The repository for managing categories.
|
|
67
|
+
*/
|
|
68
|
+
categories: CategoryRepository;
|
|
64
69
|
/**
|
|
65
70
|
* The cart service for managing the cart.
|
|
66
71
|
*/
|
|
@@ -73,4 +78,13 @@ export declare class FeeeF {
|
|
|
73
78
|
* @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.
|
|
74
79
|
*/
|
|
75
80
|
constructor({ apiKey, client, cache, baseURL }: FeeeFConfig);
|
|
81
|
+
/**
|
|
82
|
+
* set header method to set custom headers for all requests
|
|
83
|
+
*/
|
|
84
|
+
setHeader(key: string, value: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Removes a header from the default headers.
|
|
87
|
+
* @param {string} key - The key of the header to remove.
|
|
88
|
+
*/
|
|
89
|
+
removeHeader(key: string): void;
|
|
76
90
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository, ModelCreateOptions, ModelListOptions } from './repository.js';
|
|
3
|
+
import { CategoryEntity } from '../../core/entities/category.js';
|
|
4
|
+
export interface CategoryCreate {
|
|
5
|
+
store_id: string;
|
|
6
|
+
parent_id?: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string | null;
|
|
9
|
+
photo_url?: string | null;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export interface CategoryUpdate {
|
|
13
|
+
parent_id?: string | null;
|
|
14
|
+
name?: string;
|
|
15
|
+
description?: string | null;
|
|
16
|
+
photo_url?: string | null;
|
|
17
|
+
metadata?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Repository for managing Category entities.
|
|
21
|
+
*/
|
|
22
|
+
export declare class CategoryRepository extends ModelRepository<CategoryEntity, CategoryCreate, CategoryUpdate> {
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new CategoryRepository instance.
|
|
25
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
26
|
+
*/
|
|
27
|
+
constructor(client: AxiosInstance);
|
|
28
|
+
/**
|
|
29
|
+
* Lists categories for a store with optional parent filter.
|
|
30
|
+
* @param options The options for listing categories.
|
|
31
|
+
* @returns A Promise that resolves to a list of categories.
|
|
32
|
+
*/
|
|
33
|
+
list(options?: ModelListOptions & {
|
|
34
|
+
storeId?: string;
|
|
35
|
+
parentId?: string | null;
|
|
36
|
+
}): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the category tree structure for a store.
|
|
39
|
+
* @param storeId The store ID.
|
|
40
|
+
* @returns A Promise that resolves to the category tree.
|
|
41
|
+
*/
|
|
42
|
+
tree(storeId: string): Promise<CategoryEntity[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new Category entity.
|
|
45
|
+
* @param options The options for creating the Category entity.
|
|
46
|
+
* @returns A Promise that resolves to the created Category entity.
|
|
47
|
+
*/
|
|
48
|
+
create(options: ModelCreateOptions<CategoryCreate> & {
|
|
49
|
+
storeId?: string;
|
|
50
|
+
}): Promise<CategoryEntity>;
|
|
51
|
+
}
|
|
@@ -20,6 +20,7 @@ export interface SendOrderSchema {
|
|
|
20
20
|
shippingState?: string;
|
|
21
21
|
shippingType: ShippingType;
|
|
22
22
|
shippingMethodId?: string;
|
|
23
|
+
shippingNote?: string;
|
|
23
24
|
paymentMethodId?: string;
|
|
24
25
|
items: GuestOrderItemSchema[];
|
|
25
26
|
coupon?: string;
|
|
@@ -34,6 +35,22 @@ export interface GuestOrderItemSchema {
|
|
|
34
35
|
quantity: number;
|
|
35
36
|
addons?: Record<string, number>;
|
|
36
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Schema for assigning a single order to a member
|
|
40
|
+
*/
|
|
41
|
+
export interface AssignOrderSchema {
|
|
42
|
+
orderId: string;
|
|
43
|
+
memberId: string;
|
|
44
|
+
storeId: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Schema for assigning multiple orders to a member
|
|
48
|
+
*/
|
|
49
|
+
export interface AssignManyOrdersSchema {
|
|
50
|
+
orderIds: string[];
|
|
51
|
+
memberId: string;
|
|
52
|
+
storeId: string;
|
|
53
|
+
}
|
|
37
54
|
/**
|
|
38
55
|
* Represents a repository for managing orders.
|
|
39
56
|
*/
|
|
@@ -56,4 +73,18 @@ export declare class OrderRepository extends ModelRepository<OrderEntity, any, a
|
|
|
56
73
|
* @returns A promise that resolves to the found model.
|
|
57
74
|
*/
|
|
58
75
|
track(options: OrderModelTrackOptions): Promise<OrderTrackEntity>;
|
|
76
|
+
/**
|
|
77
|
+
* Assigns a single order to a member (as confirmer)
|
|
78
|
+
* @param data - The data containing orderId, memberId, and storeId
|
|
79
|
+
* @returns A Promise that resolves to the updated OrderEntity
|
|
80
|
+
*/
|
|
81
|
+
assign(data: AssignOrderSchema): Promise<OrderEntity>;
|
|
82
|
+
/**
|
|
83
|
+
* Assigns multiple orders to a member (as confirmer)
|
|
84
|
+
* @param data - The data containing orderIds, memberId, and storeId
|
|
85
|
+
* @returns A Promise that resolves to a success message
|
|
86
|
+
*/
|
|
87
|
+
assignMany(data: AssignManyOrdersSchema): Promise<{
|
|
88
|
+
message: string;
|
|
89
|
+
}>;
|
|
59
90
|
}
|
|
@@ -10,4 +10,10 @@ export declare class ProductRepository extends ModelRepository<ProductEntity, an
|
|
|
10
10
|
* @param client - The AxiosInstance used for making HTTP requests.
|
|
11
11
|
*/
|
|
12
12
|
constructor(client: AxiosInstance);
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves a random products from the repository.
|
|
15
|
+
* @param limit - The number of random products to retrieve. Default is 1.
|
|
16
|
+
* @returns A promise that resolves to an array of random ProductEntity objects.
|
|
17
|
+
*/
|
|
18
|
+
random(limit?: number): Promise<ProductEntity[]>;
|
|
13
19
|
}
|
package/build/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './core/entities/store.js';
|
|
|
4
4
|
export * from './core/entities/product.js';
|
|
5
5
|
export * from './core/entities/user.js';
|
|
6
6
|
export * from './core/entities/shipping_method.js';
|
|
7
|
+
export * from './core/entities/category.js';
|
|
7
8
|
export * from './feeef/repositories/deposits.js';
|
|
8
9
|
export * from './core/embadded/address.js';
|
|
9
10
|
export * from './core/embadded/category.js';
|