sahab-utils 1.2.7 → 1.2.9

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.
@@ -1,776 +0,0 @@
1
- import { DocumentReference, GeoPoint, Timestamp } from 'firebase/firestore';
2
-
3
- export type GeoPointType = GeoPoint;
4
- export type TimestampType = Timestamp;
5
-
6
- export type DistenceDueration = {
7
- distance: string;
8
- duration: string;
9
- };
10
-
11
- export enum CarSize {
12
- X_SMALL,
13
- SMALL,
14
- MEDIUM,
15
- LARGE,
16
- X_LARGE,
17
- }
18
-
19
- export type Car = {
20
- carId: string;
21
- manufacturer: string;
22
- model: string;
23
- size: CarSize;
24
- year: string;
25
- color: string;
26
- plateLetters: string;
27
- plateNumber: string;
28
- imageUrl?: string;
29
- };
30
-
31
- export type ClientLocation = {
32
- locationId: string;
33
- name: string;
34
- latitude: number;
35
- longitude: number;
36
- isPrimary?: boolean;
37
- };
38
-
39
- export type Client = {
40
- uid: string;
41
- phoneNumber: string;
42
- firstName?: string;
43
- lastName?: string;
44
- email?: string;
45
- balance?: number;
46
- rating?: number;
47
- imageUrl?: string;
48
- isTest?: boolean;
49
- isEmailVerified?: boolean;
50
- language?: string;
51
- checkoutCustomerId?: string;
52
- latitude?: number;
53
- longitude?: number;
54
- joinDate?: Date;
55
- locations?: ClientLocation[];
56
- version?: string;
57
- };
58
-
59
- export type Price = {
60
- size: CarSize;
61
- price: number;
62
- };
63
-
64
- export enum OrderStatus {
65
- PENDING, // 0
66
- CONFIRMED, // 1
67
- REJECTED, // 2
68
- EXPIRED, // 3
69
- IN_PROGRESS, // 4
70
- COMPLETED, // 5
71
- CANCELLED, // 6
72
- RATED, // 7
73
- STARTED, // 8
74
- }
75
-
76
- export enum OrderPaymentType {
77
- APPLE_PAY,
78
- CREDIT,
79
- CASH,
80
- GOOGLE_PAY,
81
- SAMSUNG_PAY,
82
- STC_PAY,
83
- TABBY,
84
- TAMARA,
85
- }
86
-
87
- export type Location = {
88
- geohash?: string;
89
- northeast: GeoPointType;
90
- southwest: GeoPointType;
91
- };
92
-
93
- // IF ADDING A NEW PROPERTY TO THIS TYPE
94
- // PLEASE ADD IT TO THE REDUX ORDER TYPE AS WELL
95
- // AND ALSO IN `extractReduxOrder` FUNCTION IN `utils.ts`
96
- // IN ORDER TO AVOID ANY PROBLEMS
97
- export type Order = {
98
- orderId?: string;
99
- clientRef?: DocumentReference;
100
- clientId?: string;
101
- client?: Client;
102
- providerRef?: DocumentReference;
103
- providerId?: string;
104
- servedBy?: DocumentReference;
105
- servedByName?: string;
106
- createdDate?: TimestampType;
107
- orderDate?: TimestampType;
108
- services?: CarService[];
109
- location?: GeoPointType;
110
- locationUrl?: string;
111
- willClientBeThere?: boolean;
112
- paymentType?: OrderPaymentType;
113
- clientRating?: number;
114
- providerRating?: number;
115
- orderStatus?: OrderStatus;
116
- staticMap?: any; // For static map
117
- isPaid?: boolean;
118
- rejectedBy?: string[];
119
- finishDate?: TimestampType;
120
- arrivalDate?: TimestampType;
121
- canceledDate?: TimestampType;
122
- paymentAmount?: number;
123
- sahabPercentage?: number; // 0.06
124
- sahabClientPercentage?: number; // 0.03
125
- sahabOnlinePercentage?: number; // 0.03
126
- sahabProviderPercentage?: number; // 0.03
127
- sahabExtraPaymentAmount?: number; // for cash payments
128
- paymentId?: string;
129
- paymentCancelationId?: string;
130
- paymentRefundId?: string;
131
- paymentCaptureId?: string;
132
- canceledBy?: 'provider' | 'client';
133
- movementsCreated?: boolean;
134
- orderNote?: string;
135
- cancelReason?: string;
136
- isDismissed?: boolean;
137
- isLate?: boolean;
138
- promoCode?: Discount;
139
- isTest?: boolean;
140
- clientNumber?: string;
141
- usedBalance?: number;
142
- isDummyOrder?: boolean;
143
- ratingNote?: string;
144
- isAddonStructure?: boolean;
145
- isMonthlyPackage?: boolean;
146
- isPaymentSettled?: boolean;
147
- notificationTaskId?: string;
148
- providerName?: {
149
- ar: string;
150
- en: string;
151
- };
152
- providerPhoneNumber?: string;
153
- providerLogoUrl?: string;
154
- paymentGateway?: 'PAYLINK' | 'CHECKOUT';
155
- };
156
-
157
- // ! DO NOT PLACE ANY FIRESTORE REF IN THIS OBJECT TYPE
158
- export type ReduxOrder = {
159
- orderId?: string;
160
- clientId?: string;
161
- client?: Client;
162
- servedByPath?: string; // as "service_providers/providerId/drivers/driverId"
163
- providerId?: string;
164
- servedByName?: string;
165
- createdDate?: TimestampType;
166
- orderDate?: TimestampType;
167
- canceledDate?: TimestampType;
168
- services?: CarService[];
169
- location?: GeoPointType;
170
- locationUrl?: string;
171
- willClientBeThere?: boolean;
172
- paymentType?: OrderPaymentType;
173
- clientRating?: number;
174
- providerRating?: number;
175
- orderStatus?: OrderStatus;
176
- staticMap?: any; // For static map
177
- isPaid?: boolean;
178
- rejectedBy?: string[];
179
- finishDate?: TimestampType;
180
- arrivalDate?: TimestampType;
181
- paymentAmount?: number;
182
- sahabPercentage?: number; // 0.06
183
- sahabClientPercentage?: number; // 0.03
184
- sahabOnlinePercentage?: number; // 0.03
185
- sahabProviderPercentage?: number; // 0.03
186
- sahabExtraPaymentAmount?: number; // for cash payments
187
- paymentId?: string;
188
- paymentCancelationId?: string;
189
- paymentRefundId?: string;
190
- paymentCaptureId?: string;
191
- canceledBy?: 'provider' | 'client';
192
- movementsCreated?: boolean;
193
- orderNote?: string;
194
- cancelReason?: string;
195
- isDismissed?: boolean;
196
- isLate?: boolean;
197
- promoCode?: Discount;
198
- clientNumber?: string;
199
- isTest?: boolean;
200
- usedBalance?: number;
201
- isDummyOrder?: boolean;
202
- ratingNote?: string;
203
- isAddonStructure?: boolean;
204
- isMonthlyPackage?: boolean;
205
- isPaymentSettled?: boolean;
206
- notificationTaskId?: string;
207
- providerName?: {
208
- ar: string;
209
- en: string;
210
- };
211
- providerPhoneNumber?: string;
212
- providerLogoUrl?: string;
213
- };
214
-
215
- export type MoneyMovement = {
216
- movementId: string;
217
- amount: number;
218
- orderId?: string;
219
- date: TimestampType;
220
- movementType: MovementType;
221
- createdBy?: string;
222
- };
223
-
224
- export enum MovementType {
225
- CLIENT_ORDER_PAYMENT,
226
- CLIENT_BALANCE_TOP_UP,
227
- PROVIDER_NEGATIVE_BALANCE_PAYMENT,
228
- PROVIDER_POSITIVE_BALANCE_PAYMENT,
229
- ORDER_REFUND,
230
- SAHAB_PAYMENT_TO_PROVIDER,
231
- SAHAB_RECEIVE_FROM_PROVIDER,
232
- USING_BALANCE,
233
- }
234
-
235
- export enum ComplaintType {
236
- BUG,
237
- COMPLAINT,
238
- }
239
-
240
- export enum ComplaintStatus {
241
- PENDING,
242
- IN_REVIEW,
243
- RESOLVED,
244
- }
245
-
246
- export type Complaint = {
247
- complaintId: string;
248
- complaintNumber: string;
249
- desc: string;
250
- createdDate: TimestampType;
251
- status: ComplaintStatus;
252
- type: ComplaintType;
253
- resolvedBy?: string;
254
- resolveDate?: string;
255
- };
256
-
257
- export type City = {
258
- cityId?: string;
259
- cityName: string;
260
- countryName: string;
261
- cityName_ar: string;
262
- countryName_ar: string;
263
- locationBounds?: Location;
264
- coordinates?: GeoPointType;
265
- g?: { geohash: string; geopoint: GeoPointType };
266
- providerUid?: string;
267
- };
268
-
269
- export type Driver = {
270
- type?: 'driver';
271
- driverId?: string;
272
- providerUid?: string;
273
- firstName?: string;
274
- lastName?: string;
275
- phoneNumber?: string;
276
- imageUrl?: string;
277
- language?: 'en' | 'ar';
278
- mainPushToken?: string;
279
- hmsPushToken?: string;
280
- cities?: City[];
281
- isAllowedToCross?: boolean;
282
- deactivated?: boolean;
283
- };
284
-
285
- export type ProviderCar = {
286
- carId?: string;
287
- providerRef?: DocumentReference;
288
- manufacturer?: string;
289
- model?: string;
290
- year?: string;
291
- color?: string;
292
- plateLetters?: string;
293
- plateNumber?: string;
294
- istimarahUrl?: string;
295
- fileType?: string;
296
- };
297
-
298
- export type Day = 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday';
299
-
300
- export type HH =
301
- | '00'
302
- | '01'
303
- | '02'
304
- | '03'
305
- | '04'
306
- | '05'
307
- | '06'
308
- | '07'
309
- | '08'
310
- | '09'
311
- | '10'
312
- | '11'
313
- | '12'
314
- | '13'
315
- | '14'
316
- | '15'
317
- | '16'
318
- | '17'
319
- | '18'
320
- | '19'
321
- | '20'
322
- | '21'
323
- | '22'
324
- | '23';
325
- export type MM =
326
- | '00'
327
- | '01'
328
- | '02'
329
- | '03'
330
- | '04'
331
- | '05'
332
- | '06'
333
- | '07'
334
- | '08'
335
- | '09'
336
- | '10'
337
- | '11'
338
- | '12'
339
- | '13'
340
- | '14'
341
- | '15'
342
- | '16'
343
- | '17'
344
- | '18'
345
- | '19'
346
- | '20'
347
- | '21'
348
- | '22'
349
- | '23'
350
- | '24'
351
- | '25'
352
- | '26'
353
- | '27'
354
- | '28'
355
- | '29'
356
- | '30'
357
- | '31'
358
- | '32'
359
- | '33'
360
- | '34'
361
- | '35'
362
- | '36'
363
- | '37'
364
- | '38'
365
- | '39'
366
- | '40'
367
- | '41'
368
- | '42'
369
- | '43'
370
- | '44'
371
- | '45'
372
- | '46'
373
- | '47'
374
- | '48'
375
- | '49'
376
- | '50'
377
- | '51'
378
- | '52'
379
- | '53'
380
- | '54'
381
- | '55'
382
- | '56'
383
- | '57'
384
- | '58'
385
- | '59';
386
- export type Hour = `${HH}:${MM}`;
387
- export type WorkingHour = {
388
- start: Hour;
389
- end: Hour;
390
- };
391
- export type WorkingHours = {
392
- sunday: WorkingHour[];
393
- monday: WorkingHour[];
394
- tuesday: WorkingHour[];
395
- wednesday: WorkingHour[];
396
- thursday: WorkingHour[];
397
- friday: WorkingHour[];
398
- saturday: WorkingHour[];
399
- };
400
-
401
- export enum ReviewStatus {
402
- PENDING,
403
- IN_REVIEW,
404
- ACCEPTED,
405
- DECLINED,
406
- }
407
-
408
- export enum RegistrationSection {
409
- OWNER_NAME,
410
- CITY,
411
- RULES,
412
- BUSINESS_INFO,
413
- DRIVERS_INFO,
414
- VEHICLE_PERMIT,
415
- VEHICLE_REGISTRATION,
416
- SERVICES,
417
- ADDONS,
418
- WORKING_HOURS,
419
- OVERVIEW,
420
- STATUS,
421
- DONE,
422
- }
423
-
424
- export type DeclineReason = {
425
- reasonDesc: {
426
- ar: string;
427
- en: string;
428
- };
429
- section: RegistrationSection;
430
- };
431
-
432
- export type ProviderService = {
433
- serviceId?: string;
434
- name?: {
435
- ar: string;
436
- en: string;
437
- };
438
- imageUrl?: string;
439
- providerId?: string;
440
- prices?: Price[];
441
- description?: {
442
- ar: string;
443
- en: string;
444
- };
445
- includedServices?: {
446
- ar: string;
447
- en: string;
448
- }[];
449
- hide?: boolean;
450
- time?: number;
451
- numberOfVisits?: number;
452
- };
453
-
454
- export type ProvidedService = {
455
- serviceId?: string;
456
- name?: {
457
- ar: string;
458
- en: string;
459
- };
460
- imageUrl?: string;
461
- providerId?: string;
462
- description?: {
463
- ar: string;
464
- en: string;
465
- };
466
- price: Price;
467
- isDone?: boolean;
468
- finishDate?: TimestampType;
469
- quantity?: number;
470
- type: 'service';
471
- time?: number;
472
- includedServices?: {
473
- ar: string;
474
- en: string;
475
- }[];
476
- numberOfVisits?: number;
477
- discount?: Discount;
478
- };
479
-
480
- export type ProviderAddon = {
481
- addonId?: string;
482
- providerId?: string;
483
- name?: {
484
- ar: string;
485
- en: string;
486
- };
487
- prices?: Price[];
488
- description?: {
489
- ar: string;
490
- en: string;
491
- };
492
- hide?: boolean;
493
- time?: number;
494
- };
495
-
496
- export type ProvidedAddon = {
497
- addonId?: string;
498
- providerId?: string;
499
- name?: {
500
- ar: string;
501
- en: string;
502
- };
503
- price?: Price;
504
- description?: {
505
- ar: string;
506
- en: string;
507
- };
508
- quantity?: number;
509
- type: 'addon';
510
- time?: number;
511
- isDone?: boolean;
512
- finishDate?: TimestampType;
513
- discount?: Discount;
514
- };
515
-
516
- export type Provider = {
517
- type?: 'provider';
518
- providerUid?: string;
519
- providerName?: {
520
- ar: string;
521
- en: string;
522
- };
523
- providerPhoneNumber?: string; // not used anymore
524
- providerCarNumber?: string;
525
- numberOfDrivers?: number;
526
- numberOfCars?: number;
527
- totalRating?: number;
528
- numberOfRaters?: number;
529
- logoUrl?: string;
530
- phoneNumber?: string;
531
- ownerFirstName?: string;
532
- ownerLastName?: string;
533
- services?: ProviderService[];
534
- addons?: ProviderAddon[];
535
- working247?: boolean;
536
- workingHoursV2?: WorkingHours;
537
- submitDate?: TimestampType;
538
- reviewStatus?: ReviewStatus;
539
- reviewedBy?: string;
540
- declineReasons?: DeclineReason[];
541
- acceptOrdersAutomatically?: boolean;
542
- freeWashes?: number;
543
- registrationSection?: RegistrationSection;
544
- currency?: string;
545
- mainPushToken?: string;
546
- hmsPushToken?: string;
547
- isTest?: boolean;
548
- language?: 'en' | 'ar';
549
- balance?: number;
550
- permitUrl?: string;
551
- permitType?: string;
552
- checkoutCustomerId?: string;
553
- ownerEmail?: string;
554
- isEmailVerified?: boolean;
555
- receiveOrders?: boolean; // true if undefined or null
556
- isAcceptingOrders?: boolean;
557
- ordersPercentage?: number; // percentage
558
- integrations?: { email?: string; isActive?: boolean; key: string }[];
559
- };
560
-
561
- export type Card = {
562
- id?: string;
563
- issuer?: string;
564
- expiry_month?: string;
565
- expiry_year?: string;
566
- name?: string;
567
- scheme?: string;
568
- bin?: string;
569
- last4?: string;
570
- customer?: {
571
- id?: string;
572
- };
573
-
574
- default?: boolean;
575
- customer_id?: string;
576
- };
577
-
578
- export type CheckoutCustomer = {
579
- default?: string;
580
- email?: string;
581
- id?: string;
582
- name?: string;
583
- instruments?: Card[];
584
- metadata?: {
585
- iban?: string;
586
- providerUid?: string;
587
- };
588
- };
589
-
590
- export type CarService = {
591
- car?: Car;
592
- services: Array<ProvidedService | ProvidedAddon>;
593
- isDone?: boolean;
594
- };
595
-
596
- export type Discount = {
597
- promoCodeId?: string;
598
- promoCode?: string;
599
- validFrom?: TimestampType;
600
- validTo?: TimestampType;
601
- createdAt?: TimestampType;
602
- allowedOnce?: boolean;
603
- createdByProvider?: boolean;
604
- providerUid?: string;
605
- usedBy?: string[];
606
- amount?: number;
607
- isPercentage?: boolean;
608
- maxAmount?: number;
609
- isAutoApplied?: boolean;
610
- servicesIds?: string[];
611
- addonsIds?: string[];
612
- };
613
-
614
- export type OrderReview = {
615
- ratingId: string;
616
- ratingNote: string;
617
- orderId: string;
618
- orderDate: TimestampType;
619
- createdDate: TimestampType;
620
- providerId: string;
621
- arrivalDate: string;
622
- finishDate: string;
623
- rating: number;
624
- clientId: string;
625
- };
626
-
627
- // Country Codes Type
628
- export type CountryCode = {
629
- code: string;
630
- dial_code: string;
631
- flag: string;
632
- name_en: string;
633
- name_ar: string;
634
- };
635
-
636
- export type LocationInfo = {
637
- city?: string;
638
- country?: string;
639
- postalCode?: string;
640
- line1: string;
641
- line2?: string;
642
- long_name?: string;
643
- latitude?: number;
644
- longitude?: number;
645
- };
646
-
647
- export type SavedLocation = {
648
- locationId: string;
649
- name: string;
650
- latitude: number;
651
- longitude: number;
652
- isPrimary?: boolean;
653
- };
654
-
655
- export type CheckoutCard = {
656
- id?: string;
657
- type?: string;
658
- fingerprint?: string;
659
- expiry_month?: string;
660
- expiry_year?: string;
661
- scheme?: string;
662
- scheme_local?: string;
663
- last4?: string;
664
- bin?: string;
665
- card_type?: string;
666
- card_category?: string;
667
- issuer?: string;
668
- issuer_country?: string;
669
- product_type?: string;
670
- };
671
-
672
- export type CheckoutToken = {
673
- type?: string;
674
- token?: string;
675
- expires_on?: string;
676
- expiry_month?: number;
677
- expiry_year?: number;
678
- scheme?: string;
679
- scheme_local?: string;
680
- last4?: string;
681
- bin?: string;
682
- card_type?: string;
683
- card_category?: string;
684
- issuer?: string;
685
- issuer_country?: string;
686
- product_id: string;
687
- product_type: string;
688
- billing_address?: {
689
- address_line1?: string;
690
- address_line2: string;
691
- city?: string;
692
- state?: string;
693
- zip?: string;
694
- country?: string;
695
- };
696
- phone?: {
697
- country_code?: string;
698
- number?: string;
699
- };
700
- name?: string;
701
- };
702
-
703
- export type SPECIFIED_TIME = 'anytime' | number;
704
-
705
- export type PlaceOrder = {
706
- clientID: string;
707
- providerId: string;
708
- orderMilllSec: number;
709
- orderNanoSec: number;
710
- services: CarService[];
711
- lat: number;
712
- long: number;
713
- willClientBeThere: boolean;
714
- paymentType: OrderPaymentType;
715
- isPaid: boolean;
716
- paymentId: string;
717
- isProviderTest: boolean;
718
- providerReceiveOrders: boolean;
719
- orderNote: string;
720
- promoCode: Discount;
721
- driverIds: string[];
722
- providerName: {
723
- ar: string;
724
- en: string;
725
- };
726
- paymentAmount: number;
727
- usedBalance: number;
728
- providerPhoneNumber: string;
729
- isAddonStructure: boolean;
730
- isMonthlyPackage: boolean;
731
- sahabExtraPaymentAmount: number;
732
- orderId?: string;
733
- };
734
-
735
- export type WeatherData = {
736
- date: string;
737
- precipitationProbability: number; // in %
738
- rainAccumulation: number; // in mm
739
- cloudCover: number; // in %
740
- humidity: number; // in %
741
- windSpeed: number; // in km/h
742
- uvIndex: number; // scale from 0-11+
743
- };
744
-
745
- export type PaymentConfigs = {
746
- isCashAllowed: boolean;
747
- isGooglePayAllowed?: boolean;
748
- paymentGateways: {
749
- key: string;
750
- isActive: boolean;
751
- priority: number;
752
- }[];
753
- };
754
-
755
- export type Slot = {
756
- id: string;
757
- time: number;
758
- selected: boolean;
759
- reserved: boolean;
760
- };
761
-
762
- export type Statement = {
763
- numberOfOrders: number;
764
- completedOrders: number;
765
- ratedOrders: number;
766
- cancelledOrders: number;
767
- cashOrders: number;
768
- creditOrders: number;
769
- applePayPayments: number;
770
- expiredOrders: number;
771
- confirmedOrders: number;
772
- lateOrders: number;
773
- ordersTotal: number;
774
- orders: Order[];
775
- statmentDate?: Date | string;
776
- };