@chopkola/common 1.0.213

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/build/helpers/helpers.d.ts +2 -0
  2. package/build/helpers/helpers.js +34 -0
  3. package/build/index.d.ts +15 -0
  4. package/build/index.js +31 -0
  5. package/build/types/address.d.ts +12 -0
  6. package/build/types/address.js +2 -0
  7. package/build/types/apis/administrator/access.control.list.type.d.ts +8 -0
  8. package/build/types/apis/administrator/access.control.list.type.js +2 -0
  9. package/build/types/apis/administrator/administrator.category.management.type.d.ts +22 -0
  10. package/build/types/apis/administrator/administrator.category.management.type.js +2 -0
  11. package/build/types/apis/administrator/administrator.dashboard.type.d.ts +38 -0
  12. package/build/types/apis/administrator/administrator.dashboard.type.js +10 -0
  13. package/build/types/apis/administrator/administrator.system.settings.type.d.ts +29 -0
  14. package/build/types/apis/administrator/administrator.system.settings.type.js +2 -0
  15. package/build/types/apis/administrator/administrator.vendor.management.type.d.ts +37 -0
  16. package/build/types/apis/administrator/administrator.vendor.management.type.js +7 -0
  17. package/build/types/apis/administrator/create.administrator.type.d.ts +4 -0
  18. package/build/types/apis/administrator/create.administrator.type.js +2 -0
  19. package/build/types/apis/administrator/system.user.management.type.d.ts +38 -0
  20. package/build/types/apis/administrator/system.user.management.type.js +9 -0
  21. package/build/types/apis/google.d.ts +22 -0
  22. package/build/types/apis/google.js +2 -0
  23. package/build/types/apis/index.d.ts +11 -0
  24. package/build/types/apis/index.js +27 -0
  25. package/build/types/apis/vendor/active.business.d.ts +7 -0
  26. package/build/types/apis/vendor/active.business.js +2 -0
  27. package/build/types/apis/vendor/active.business.summary.statistics.and.page.resource.d.ts +39 -0
  28. package/build/types/apis/vendor/active.business.summary.statistics.and.page.resource.js +10 -0
  29. package/build/types/apis/vendor/vendor.user.summary.statistics.resource.data.d.ts +35 -0
  30. package/build/types/apis/vendor/vendor.user.summary.statistics.resource.data.js +2 -0
  31. package/build/types/cart.d.ts +113 -0
  32. package/build/types/cart.js +20 -0
  33. package/build/types/category.d.ts +38 -0
  34. package/build/types/category.js +2 -0
  35. package/build/types/enum/collection.d.ts +133 -0
  36. package/build/types/enum/collection.js +157 -0
  37. package/build/types/enum/error.d.ts +12 -0
  38. package/build/types/enum/error.js +17 -0
  39. package/build/types/errors/index.d.ts +17 -0
  40. package/build/types/errors/index.js +2 -0
  41. package/build/types/file.types.d.ts +11 -0
  42. package/build/types/file.types.js +2 -0
  43. package/build/types/global.d.ts +88 -0
  44. package/build/types/global.js +26 -0
  45. package/build/types/menu_n_meal.d.ts +104 -0
  46. package/build/types/menu_n_meal.js +2 -0
  47. package/build/types/products.d.ts +208 -0
  48. package/build/types/products.js +2 -0
  49. package/build/types/reservation.d.ts +27 -0
  50. package/build/types/reservation.js +2 -0
  51. package/build/types/role_n_permission.d.ts +56 -0
  52. package/build/types/role_n_permission.js +5 -0
  53. package/build/types/user.d.ts +74 -0
  54. package/build/types/user.js +5 -0
  55. package/build/types/vendor.d.ts +126 -0
  56. package/build/types/vendor.js +2 -0
  57. package/build/validators/index.d.ts +2 -0
  58. package/build/validators/index.js +18 -0
  59. package/build/validators/regex.d.ts +3 -0
  60. package/build/validators/regex.js +6 -0
  61. package/build/validators/validate.d.ts +3 -0
  62. package/build/validators/validate.js +24 -0
  63. package/package.json +29 -0
@@ -0,0 +1,208 @@
1
+ import { LucideIcon } from "lucide-react";
2
+ import { Category } from "./category";
3
+ import { Currency, JsonObject, MoneyString, Nullable, QuantityString, Timestamps, UUID } from "./global";
4
+ import { ProductTypeEnum, StockMovementReasonEnum, StockStatusEnum, VendorProductsStatisticsIconEnum } from "./enum/collection";
5
+ export interface BackendVendorProductStatistic {
6
+ key: "total_products" | "low_stock" | "out_of_stock" | "top_category";
7
+ title: string;
8
+ value: string | number;
9
+ icon: VendorProductsStatisticsIconEnum;
10
+ color?: string;
11
+ }
12
+ export interface VendorProductStatistic {
13
+ key: "total_products" | "low_stock" | "out_of_stock" | "top_category";
14
+ title: string;
15
+ value: string | number;
16
+ icon: LucideIcon;
17
+ color?: string;
18
+ }
19
+ export type VendorProductsStats = Record<BackendVendorProductStatistic["key"], BackendVendorProductStatistic>;
20
+ /**
21
+ * Persisted Product Entity
22
+ */
23
+ export interface Product extends Timestamps {
24
+ id: UUID;
25
+ vendor_id: UUID;
26
+ name: string;
27
+ slug: string;
28
+ sku: string;
29
+ description: Nullable<string>;
30
+ brand: Nullable<string>;
31
+ images: Nullable<string[]>;
32
+ category_id: Nullable<UUID>;
33
+ tags: Nullable<string[]>;
34
+ attributes: Nullable<JsonObject>;
35
+ is_approved: boolean;
36
+ }
37
+ /**
38
+ * Expanded Product (with category)
39
+ */
40
+ export interface ProductWithCategory extends Product {
41
+ category?: Category;
42
+ }
43
+ export interface ProductVariant extends Timestamps {
44
+ id: UUID;
45
+ product_id: UUID;
46
+ name_suffix: Nullable<string>;
47
+ sku: string;
48
+ options: JsonObject;
49
+ images: Nullable<string[]>;
50
+ is_default: boolean;
51
+ }
52
+ export type InventoryLink = {
53
+ product_id: UUID;
54
+ product_variant_id: null;
55
+ } | {
56
+ product_id: null;
57
+ product_variant_id: UUID;
58
+ };
59
+ /**
60
+ * 🛠️ FIX 1: Extracted standard fields into a Base Interface.
61
+ */
62
+ export interface BaseInventoryItem extends Timestamps {
63
+ id: UUID;
64
+ vendor_id: UUID;
65
+ sku: string;
66
+ price: MoneyString;
67
+ cost_price: Nullable<MoneyString>;
68
+ sale_price: Nullable<MoneyString>;
69
+ quantity: QuantityString;
70
+ low_stock_threshold: Nullable<QuantityString>;
71
+ stock_status: StockStatusEnum;
72
+ is_trackable: boolean;
73
+ is_visible: boolean;
74
+ supplier: Nullable<string>;
75
+ storage_location: Nullable<string>;
76
+ }
77
+ /**
78
+ * 🛠️ FIX 2: Used Type Intersection (&) to merge the Base and the Union safely.
79
+ * DB constraint: Either product OR variant — never both.
80
+ */
81
+ export type InventoryItem = BaseInventoryItem & InventoryLink;
82
+ export interface StockMovement extends Timestamps {
83
+ id: UUID;
84
+ inventory_item_id: UUID;
85
+ quantity_change: QuantityString;
86
+ quantity_before: QuantityString;
87
+ quantity_after: QuantityString;
88
+ reason: StockMovementReasonEnum;
89
+ notes: Nullable<string>;
90
+ source_reference_id: Nullable<UUID>;
91
+ user_id: Nullable<UUID>;
92
+ }
93
+ /**
94
+ * 🛠️ FIX 3: Changed from `interface` to `type`.
95
+ * An interface cannot extend a Union Type (InventoryItem).
96
+ */
97
+ export type InventoryWithMovements = InventoryItem & {
98
+ movements: StockMovement[];
99
+ };
100
+ export interface ProductVariantAggregate extends ProductVariant {
101
+ inventory: Nullable<InventoryWithMovements>;
102
+ }
103
+ /**
104
+ * SIMPLE PRODUCT AGGREGATE
105
+ */
106
+ export interface ProductSimpleAggregate extends ProductWithCategory {
107
+ type: ProductTypeEnum.SIMPLE;
108
+ inventory: Nullable<InventoryWithMovements>;
109
+ variants: [];
110
+ }
111
+ /**
112
+ * VARIANT PRODUCT AGGREGATE
113
+ */
114
+ export interface ProductWithVariantsAggregate extends ProductWithCategory {
115
+ type: ProductTypeEnum.VARIANT;
116
+ inventory: null;
117
+ variants: ProductVariantAggregate[];
118
+ }
119
+ /**
120
+ * FINAL DISCRIMINATED UNION
121
+ */
122
+ export type ProductAggregate = ProductSimpleAggregate | ProductWithVariantsAggregate;
123
+ export type CreateProductInput = Omit<Product, "id" | "created_at" | "updated_at">;
124
+ export type UpdateProductInput = Partial<CreateProductInput>;
125
+ export type CreateProductVariantInput = Omit<ProductVariant, "id" | "created_at" | "updated_at">;
126
+ export type UpdateProductVariantInput = Partial<CreateProductVariantInput>;
127
+ /**
128
+ * 🛠️ FIX 4: Safe Union Omit.
129
+ * Omitting directly from `InventoryItem` breaks the discriminated union.
130
+ * Omitting from `BaseInventoryItem` and re-attaching `InventoryLink` keeps the XOR rule intact!
131
+ */
132
+ export type CreateInventoryItemInput = Omit<BaseInventoryItem, "id" | "created_at" | "updated_at" | "stock_status"> & InventoryLink;
133
+ export type UpdateInventoryItemInput = Partial<CreateInventoryItemInput>;
134
+ export type CreateStockMovementInput = Omit<StockMovement, "id" | "created_at" | "updated_at">;
135
+ export interface CategoryLite {
136
+ id: UUID;
137
+ name: string;
138
+ slug: string;
139
+ }
140
+ export interface ProductAggregateLite {
141
+ id: UUID;
142
+ vendor_id: UUID;
143
+ name: string;
144
+ slug: string;
145
+ sku: string | null;
146
+ description: string | null;
147
+ brand: string | null;
148
+ images: string[] | null;
149
+ tags: string[] | null;
150
+ attributes: Record<string, unknown> | null;
151
+ is_approved: boolean;
152
+ created_at: Date;
153
+ category: CategoryLite | null;
154
+ }
155
+ export interface ProductVariantAggregateLite {
156
+ id: UUID;
157
+ product_id: UUID;
158
+ name_suffix: string | null;
159
+ sku: string | null;
160
+ options: Record<string, unknown> | null;
161
+ images: string[] | null;
162
+ is_default: boolean;
163
+ }
164
+ export interface VendorLite {
165
+ id: UUID;
166
+ business_name: string;
167
+ slug: string;
168
+ logo_url: string | null;
169
+ }
170
+ export interface InventoryItemAggregate {
171
+ id?: UUID;
172
+ vendor_id: UUID;
173
+ product_id: UUID | null;
174
+ product_variant_id: UUID | null;
175
+ sku: string;
176
+ price: number;
177
+ cost_price: number;
178
+ sale_price: number;
179
+ quantity: number;
180
+ low_stock_threshold: number;
181
+ stock_status: StockStatusEnum;
182
+ is_trackable: boolean;
183
+ is_visible: boolean;
184
+ supplier: string | null;
185
+ storage_location: string | null;
186
+ created_at: Date;
187
+ updated_a: Date;
188
+ product: ProductAggregateLite | null;
189
+ product_variant: ProductVariantAggregateLite | null;
190
+ vendor: VendorLite;
191
+ }
192
+ export interface VendorProductsManagementData {
193
+ products: ProductAggregate[];
194
+ stats: VendorProductsStats;
195
+ currency: Currency;
196
+ }
197
+ export interface VendorCreateOrEditProductPageData {
198
+ categories: Category[];
199
+ product?: ProductAggregate;
200
+ currency: Currency;
201
+ }
202
+ export interface ProductDetailsData {
203
+ product: ProductAggregate;
204
+ currency: Currency;
205
+ }
206
+ export type WebApplicationProductsResourceData = {
207
+ products: InventoryItemAggregate[];
208
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { ReservationStatusEnum } from "./enum/collection";
2
+ export type Reservation = {
3
+ id: string;
4
+ vendor_id: string;
5
+ user_id: string;
6
+ start_time: Date;
7
+ end_time: Date;
8
+ party_size: number;
9
+ status: ReservationStatusEnum;
10
+ special_requests: string | null;
11
+ metadata: Record<string, any> | null;
12
+ created_at: Date;
13
+ updated_at: Date;
14
+ };
15
+ export type ReservationExtension = {
16
+ id: string;
17
+ reservation_id: string;
18
+ vendor_id: string;
19
+ start_time: Date;
20
+ end_time: Date;
21
+ created_at: Date;
22
+ updated_at: Date;
23
+ };
24
+ export type CreateReservationInput = Omit<Reservation, "id" | "created_at" | "updated_at">;
25
+ export type UpdateReservationInput = Partial<Reservation>;
26
+ export type CreateReservationExtensionInput = Omit<ReservationExtension, "id" | "created_at" | "updated_at">;
27
+ export type UpdateReservationExtensionInput = Partial<ReservationExtension>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,56 @@
1
+ import { RoleIconEnum, RoleRiskLevelEnum } from "./enum/collection";
2
+ import { UUID } from "./global";
3
+ export type ResourceType = "users" | "roles" | "vendors" | "orders" | "products" | "*";
4
+ export type VendorResourceType = "$";
5
+ export type ActionType = "create" | "read" | "update" | "delete";
6
+ export type AdministratorActionType = ActionType | "*";
7
+ export type VendorActionType = ActionType | "$";
8
+ export type PermissionKey = `${ResourceType}:${ActionType}`;
9
+ export interface Permission {
10
+ id: UUID;
11
+ resource: ResourceType | VendorResourceType;
12
+ action: AdministratorActionType | VendorActionType;
13
+ /**
14
+ * Canonical rule representation
15
+ * Example:
16
+ * users:create
17
+ * vendors:manage
18
+ * *:*
19
+ */
20
+ rule: PermissionKey;
21
+ created_at: Date;
22
+ updated_at: Date;
23
+ }
24
+ export interface Role {
25
+ id: UUID;
26
+ name: string;
27
+ slug: string;
28
+ description: string | null;
29
+ icon: RoleIconEnum | null;
30
+ risk: RoleRiskLevelEnum;
31
+ created_at: Date;
32
+ updated_at: Date;
33
+ }
34
+ export interface RolePermission {
35
+ role_id: UUID;
36
+ permission_id: UUID;
37
+ }
38
+ export interface RoleWithPermissions extends Role {
39
+ permissions: Permission[];
40
+ }
41
+ export type CreatePermissionInput = Omit<Permission, "id" | "created_at" | "updated_at">;
42
+ export type UpdatePermissionInput = Partial<Omit<Permission, "id" | "created_at" | "updated_at">>;
43
+ export type CreateRoleInput = Omit<Role, "id" | "created_at" | "updated_at"> & {
44
+ permission_ids?: UUID[];
45
+ };
46
+ export type UpdateRoleInput = Partial<Omit<Role, "id" | "created_at" | "updated_at">> & {
47
+ permission_ids?: UUID[];
48
+ };
49
+ export interface AuthorizationContext {
50
+ user_id: UUID;
51
+ role: RoleWithPermissions;
52
+ }
53
+ export interface PermissionCheck {
54
+ resource: ResourceType;
55
+ action: ActionType;
56
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // =======================================================
3
+ // RBAC DOMAIN MODEL (PRODUCTION READY)
4
+ // =======================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,74 @@
1
+ import { AddressI } from "./address";
2
+ import { UserAccountStatusEnum, UserAccountTypeEnum, UserGenderEnum, VerificationPurposeEnum } from "./enum/collection";
3
+ import { UUID } from "./global";
4
+ import { RoleWithPermissions } from "./role_n_permission";
5
+ import { Vendor } from "./vendor";
6
+ export interface User {
7
+ id: UUID;
8
+ first_name: string;
9
+ last_name: string;
10
+ email: string;
11
+ phone_number: string;
12
+ photo_url: string | null;
13
+ gender: UserGenderEnum;
14
+ account_status: UserAccountStatusEnum;
15
+ account_type: UserAccountTypeEnum;
16
+ locale: string;
17
+ timezone: string;
18
+ is_email_verified: boolean;
19
+ email_verified_at: Date | null;
20
+ token_version: number;
21
+ last_login_at: Date | null;
22
+ last_login_ip: string | null;
23
+ password_changed_at: Date | null;
24
+ last_consented_at: Date | null;
25
+ deleted_at: Date | null;
26
+ created_at: Date;
27
+ updated_at: Date;
28
+ }
29
+ export interface UserSecurity {
30
+ password?: string;
31
+ refresh_token_hash: string | null;
32
+ mfa_enabled: boolean;
33
+ mfa_secret: string | null;
34
+ mfa_backup_codes: string[] | null;
35
+ verification_token_hash: string | null;
36
+ verification_token_for: VerificationPurposeEnum | null;
37
+ verification_token_expires_at: Date | null;
38
+ }
39
+ export type PersistedUser = User & UserSecurity;
40
+ export interface UserWithRole extends User {
41
+ role_id: string;
42
+ role: RoleWithPermissions;
43
+ permissions?: string[];
44
+ }
45
+ export interface AdministratorUser extends UserWithRole {
46
+ account_type: UserAccountTypeEnum.ADMINISTRATOR;
47
+ }
48
+ export interface VendorUser extends UserWithRole {
49
+ account_type: UserAccountTypeEnum.VENDOR;
50
+ businesses: Vendor[];
51
+ }
52
+ export interface CustomerUser extends User {
53
+ account_type: UserAccountTypeEnum.CUSTOMER;
54
+ dietary_preferences?: string[];
55
+ addresses?: AddressI[];
56
+ orders?: string[];
57
+ }
58
+ export type UserAggregate = AdministratorUser | VendorUser | CustomerUser;
59
+ export type PublicUser = Omit<UserAggregate, "token_version" | "deleted_at">;
60
+ export type CreateUserInput = Omit<User, "id" | "token_version" | "last_login_at" | "last_login_ip" | "password_changed_at" | "last_consented_at" | "deleted_at" | "created_at" | "updated_at"> & {
61
+ password: string;
62
+ role_id?: string;
63
+ };
64
+ export type UpdateUserInput = Partial<Omit<User, "id" | "account_type" | "account_status" | "token_version" | "created_at" | "updated_at">>;
65
+ export interface SuccessfulUserRegistrationResponse {
66
+ data: {
67
+ user: PublicUser;
68
+ vendor?: Vendor;
69
+ };
70
+ payload?: unknown;
71
+ subject: string;
72
+ context?: string;
73
+ message?: string;
74
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // =========================================
3
+ // USER DOMAIN MODEL (PRODUCTION READY)
4
+ // =========================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,126 @@
1
+ import { AddressI } from "./address";
2
+ import { PromotionTypeEnum, ScopeEnum, VendorStatusEnum } from "./enum/collection";
3
+ import { AddressPayloadType, UUID } from "./global";
4
+ import { MenuWithMeals } from "./menu_n_meal";
5
+ import { VendorUser } from "./user";
6
+ export type CuisineType = "African" | "Asian" | "Continental" | "Mediterranean" | "American";
7
+ export type AmbienceType = "Casual" | "Fine Dining" | "Family Friendly" | "Romantic" | "Outdoor" | "Rooftop";
8
+ export type StoreType = "Supermarket" | "Organic Store" | "Wholesale" | "Convenience Store" | "Mini Mart";
9
+ export type GroceryCategory = "Fresh Produce" | "Frozen Foods" | "Household Items" | "Beverages" | "Snacks" | "Meat & Poultry" | "Dairy";
10
+ type OperatingHours = {
11
+ day: "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
12
+ open: string;
13
+ close: string;
14
+ is_closed: boolean;
15
+ };
16
+ export interface Vendor {
17
+ id: UUID;
18
+ owner_id: UUID;
19
+ business_name: string;
20
+ slug: string;
21
+ sku_prefix: string;
22
+ description: string | null;
23
+ scope: ScopeEnum;
24
+ business_status: VendorStatusEnum;
25
+ contact_email: string;
26
+ contact_phone: string;
27
+ business_address?: AddressI;
28
+ location?: string;
29
+ logo_url: string | null;
30
+ banner_url: string | null;
31
+ operating_hours: OperatingHours[];
32
+ is_accepting_orders: boolean;
33
+ avg_preparation_time_minutes: number | null;
34
+ rating: number;
35
+ review_count: number;
36
+ payout_provider_account_id: string | null;
37
+ verification_documents: unknown;
38
+ approved_by: string | null;
39
+ approved_on: Date | null;
40
+ is_featured?: boolean;
41
+ created_at: Date;
42
+ updated_at: Date;
43
+ owner?: VendorUser;
44
+ }
45
+ export interface RestaurantInfo {
46
+ id: UUID;
47
+ vendor_id: UUID;
48
+ seating_capacity: number | null;
49
+ cuisines: CuisineType[];
50
+ ambience: AmbienceType[] | null;
51
+ tags: string[] | null;
52
+ offers_dine_in: boolean;
53
+ offers_takeaway: boolean;
54
+ offers_delivery: boolean;
55
+ has_reservation: boolean;
56
+ serves_alcohol: boolean;
57
+ has_live_music: boolean;
58
+ avg_cost_for_two: number | null;
59
+ promotion_description: string | null;
60
+ promotion_type: PromotionTypeEnum | null;
61
+ promotion_start_date: Date | null;
62
+ promotion_end_date: Date | null;
63
+ instagram_url: string | null;
64
+ facebook_url: string | null;
65
+ website_url: string | null;
66
+ created_at: Date;
67
+ updated_at: Date;
68
+ }
69
+ export interface GroceryInfo {
70
+ id: UUID;
71
+ vendor_id: UUID;
72
+ store_type: StoreType[];
73
+ product_categories: GroceryCategory[];
74
+ tags: string[] | null;
75
+ offers_delivery: boolean;
76
+ offers_pickup: boolean;
77
+ offers_in_store_shopping: boolean;
78
+ is_24_hours: boolean;
79
+ avg_delivery_time_minutes: number | null;
80
+ has_bulk_pricing: boolean;
81
+ promotion_description: string | null;
82
+ promotion_type: PromotionTypeEnum | null;
83
+ promotion_start_date: Date | null;
84
+ promotion_end_date: Date | null;
85
+ has_pharmacy_section: boolean;
86
+ has_bakery_section: boolean;
87
+ has_butcher_section: boolean;
88
+ instagram_url: string | null;
89
+ facebook_url: string | null;
90
+ website_url: string | null;
91
+ created_at: Date;
92
+ updated_at: Date;
93
+ }
94
+ export interface RestaurantVendorAggregate extends Vendor {
95
+ scope: ScopeEnum.RESTAURANT;
96
+ restaurant_info: RestaurantInfo;
97
+ }
98
+ export interface GroceryVendorAggregate extends Vendor {
99
+ scope: ScopeEnum.GROCERY;
100
+ grocery_info: GroceryInfo;
101
+ }
102
+ export type VendorAggregate = RestaurantVendorAggregate | GroceryVendorAggregate;
103
+ export type VendorAggregateForWeb = VendorAggregate & {
104
+ distance?: string | number;
105
+ duration?: string | number;
106
+ deliveryFee?: number;
107
+ reviews?: number;
108
+ rating?: number;
109
+ menus?: MenuWithMeals[];
110
+ };
111
+ export type CreateVendorInput = Omit<Vendor, "id" | "rating" | "review_count" | "business_status" | "approved_by" | "approved_on" | "created_at" | "updated_at"> & {
112
+ address_payload: AddressPayloadType;
113
+ registration_cert: File;
114
+ id_proof: File;
115
+ };
116
+ export type UpdateVendorInput = Partial<Omit<Vendor, "id" | "owner_id" | "scope" | "rating" | "review_count" | "created_at" | "updated_at">>;
117
+ export type CreateRestaurantInfoInput = Omit<RestaurantInfo, "id" | "created_at" | "updated_at">;
118
+ export type UpdateRestaurantInfoInput = Partial<Omit<RestaurantInfo, "id" | "vendor_id" | "created_at" | "updated_at">>;
119
+ export type CreateGroceryInfoInput = Omit<GroceryInfo, "id" | "created_at" | "updated_at">;
120
+ export type UpdateGroceryInfoInput = Partial<Omit<GroceryInfo, "id" | "vendor_id" | "created_at" | "updated_at">>;
121
+ export type WebApplicationRestaurantsResourceData = {
122
+ restaurants: VendorAggregateForWeb[];
123
+ cuisines: CuisineType[];
124
+ ambience: AmbienceType[];
125
+ };
126
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './regex';
2
+ export * from './validate';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./regex"), exports);
18
+ __exportStar(require("./validate"), exports);
@@ -0,0 +1,3 @@
1
+ export declare const emailRegex: RegExp;
2
+ export declare const phoneNumberRegex: RegExp;
3
+ export declare const stringDurationToMsRegex: RegExp;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringDurationToMsRegex = exports.phoneNumberRegex = exports.emailRegex = void 0;
4
+ exports.emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
5
+ exports.phoneNumberRegex = /^(?:\+234|234|0)(7[0-9]|8[01]|9[01])\d{8}$/;
6
+ exports.stringDurationToMsRegex = /^(\d+)\s*(ms|s|m|h|d|w|y)$/i;
@@ -0,0 +1,3 @@
1
+ export declare const checkIsEmailValid: (email: string) => boolean;
2
+ export declare const checkIsPhoneNumberValid: (phoneNumber: string) => boolean;
3
+ export declare const checkIsEmailOrPhoneValid: (account_ref: string) => "phone_number" | "email" | false;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsEmailOrPhoneValid = exports.checkIsPhoneNumberValid = exports.checkIsEmailValid = void 0;
4
+ const regex_1 = require("./regex");
5
+ const checkIsEmailValid = (email) => {
6
+ return regex_1.emailRegex.test(email);
7
+ };
8
+ exports.checkIsEmailValid = checkIsEmailValid;
9
+ const checkIsPhoneNumberValid = (phoneNumber) => {
10
+ return regex_1.phoneNumberRegex.test(phoneNumber);
11
+ };
12
+ exports.checkIsPhoneNumberValid = checkIsPhoneNumberValid;
13
+ const checkIsEmailOrPhoneValid = (account_ref) => {
14
+ const validEmail = (0, exports.checkIsEmailValid)(account_ref);
15
+ const validPhoneNumber = (0, exports.checkIsPhoneNumberValid)(account_ref);
16
+ if (validEmail) {
17
+ return 'email';
18
+ }
19
+ if (validPhoneNumber) {
20
+ return 'phone_number';
21
+ }
22
+ return false;
23
+ };
24
+ exports.checkIsEmailOrPhoneValid = checkIsEmailOrPhoneValid;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@chopkola/common",
3
+ "version": "1.0.213",
4
+ "description": "",
5
+ "license": "ISC",
6
+ "author": "akrosoft technology ltd",
7
+ "main": "./build/index.js",
8
+ "types": "./build/index.d.ts",
9
+ "files": [
10
+ "build/**/*"
11
+ ],
12
+ "scripts": {
13
+ "clean": "del ./build/*",
14
+ "build": "npm run clean && tsc",
15
+ "pub": "git add . && git commit -m \"Update\" && npm version patch && npm run build && npm publish"
16
+ },
17
+ "keywords": [],
18
+ "dependencies": {
19
+ "jsonwebtoken": "^9.0.3"
20
+ },
21
+ "devDependencies": {
22
+ "@types/jsonwebtoken": "^9.0.10",
23
+ "del-cli": "^7.0.0",
24
+ "typescript": "^5.9.3"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }