@mydoormot/app-types 2.2.5 → 2.3.1

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,5 +1,5 @@
1
1
 
2
- > @mydoormot/app-types@2.2.4 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
2
+ > @mydoormot/app-types@2.3.0 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@ CLI tsup v7.3.0
8
8
  CLI Target: es2021
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.js 15.03 KB
12
- ESM ⚡️ Build success in 162ms
13
- CJS dist/index.cjs 18.10 KB
14
- CJS ⚡️ Build success in 163ms
11
+ CJS dist/index.cjs 17.50 KB
12
+ CJS ⚡️ Build success in 243ms
13
+ ESM dist/index.js 14.57 KB
14
+ ESM ⚡️ Build success in 246ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3023ms
17
- DTS dist/index.d.ts 59.34 KB
18
- DTS dist/index.d.cts 59.34 KB
16
+ DTS ⚡️ Build success in 1079ms
17
+ DTS dist/index.d.ts 53.90 KB
18
+ DTS dist/index.d.cts 53.90 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 2.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated errands types
8
+
9
+ ## 2.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Added public errand types
14
+
3
15
  ## 2.2.5
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -28,7 +28,6 @@ __export(src_exports, {
28
28
  BusinessRole: () => BusinessRole,
29
29
  BusinessStatus: () => BusinessStatus,
30
30
  BusinessType: () => BusinessType,
31
- DEFAULT_BUSINESS_FUEL_SETTINGS: () => DEFAULT_BUSINESS_FUEL_SETTINGS,
32
31
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: () => DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
33
32
  DEFAULT_BUSINESS_SETTINGS: () => DEFAULT_BUSINESS_SETTINGS,
34
33
  DeliveryStatus: () => DeliveryStatus,
@@ -39,7 +38,6 @@ __export(src_exports, {
39
38
  ErrandStatus: () => ErrandStatus,
40
39
  FeePaymentStatus: () => FeePaymentStatus,
41
40
  FeeSettlement: () => FeeSettlement,
42
- FuelDueStatus: () => FuelDueStatus,
43
41
  GlobalRoles: () => GlobalRoles,
44
42
  InvoiceEventType: () => InvoiceEventType,
45
43
  InvoiceGenerationType: () => InvoiceGenerationType,
@@ -54,7 +52,6 @@ __export(src_exports, {
54
52
  PaymentOptions: () => PaymentOptions,
55
53
  PayoutPeriodType: () => PayoutPeriodType,
56
54
  PayoutRateSource: () => PayoutRateSource,
57
- PortalStatus: () => PortalStatus,
58
55
  RemittanceStatus: () => RemittanceStatus,
59
56
  RiderPayoutStatus: () => RiderPayoutStatus,
60
57
  RoleType: () => RoleType,
@@ -219,6 +216,7 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
219
216
  InvoiceEventType2["PaymentReversed"] = "payment_reversed";
220
217
  InvoiceEventType2["PaymentUpdated"] = "payment_updated";
221
218
  InvoiceEventType2["StatusChanged"] = "status_changed";
219
+ InvoiceEventType2["ErrandSettlementChanged"] = "errand_settlement_changed";
222
220
  InvoiceEventType2["Viewed"] = "viewed";
223
221
  return InvoiceEventType2;
224
222
  })(InvoiceEventType || {});
@@ -249,11 +247,6 @@ var VehicleLogType = /* @__PURE__ */ ((VehicleLogType2) => {
249
247
  VehicleLogType2["REFUEL"] = "REFUEL";
250
248
  return VehicleLogType2;
251
249
  })(VehicleLogType || {});
252
- var FuelDueStatus = /* @__PURE__ */ ((FuelDueStatus2) => {
253
- FuelDueStatus2["Due"] = "DUE";
254
- FuelDueStatus2["Ok"] = "OK";
255
- return FuelDueStatus2;
256
- })(FuelDueStatus || {});
257
250
 
258
251
  // src/rider.ts
259
252
  var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
@@ -333,9 +326,6 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
333
326
  MembershipStatus2["DISABLED"] = "DISABLED";
334
327
  return MembershipStatus2;
335
328
  })(MembershipStatus || {});
336
- var DEFAULT_BUSINESS_FUEL_SETTINGS = {
337
- revenuePercent: null
338
- };
339
329
  var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
340
330
  defaultPercentage: null,
341
331
  periodType: null
@@ -363,7 +353,6 @@ var DEFAULT_BUSINESS_SETTINGS = {
363
353
  tiktok: null,
364
354
  website: null
365
355
  },
366
- fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
367
356
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
368
357
  };
369
358
  var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
@@ -420,13 +409,6 @@ var WhatsappTemplateParamSource = /* @__PURE__ */ ((WhatsappTemplateParamSource2
420
409
  return WhatsappTemplateParamSource2;
421
410
  })(WhatsappTemplateParamSource || {});
422
411
 
423
- // src/portal.ts
424
- var PortalStatus = /* @__PURE__ */ ((PortalStatus2) => {
425
- PortalStatus2["Draft"] = "draft";
426
- PortalStatus2["Published"] = "published";
427
- return PortalStatus2;
428
- })(PortalStatus || {});
429
-
430
412
  // src/index.ts
431
413
  var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
432
414
  LinkDestination2["Website"] = "web";
@@ -444,7 +426,6 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
444
426
  BusinessRole,
445
427
  BusinessStatus,
446
428
  BusinessType,
447
- DEFAULT_BUSINESS_FUEL_SETTINGS,
448
429
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
449
430
  DEFAULT_BUSINESS_SETTINGS,
450
431
  DeliveryStatus,
@@ -455,7 +436,6 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
455
436
  ErrandStatus,
456
437
  FeePaymentStatus,
457
438
  FeeSettlement,
458
- FuelDueStatus,
459
439
  GlobalRoles,
460
440
  InvoiceEventType,
461
441
  InvoiceGenerationType,
@@ -470,7 +450,6 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
470
450
  PaymentOptions,
471
451
  PayoutPeriodType,
472
452
  PayoutRateSource,
473
- PortalStatus,
474
453
  RemittanceStatus,
475
454
  RiderPayoutStatus,
476
455
  RoleType,
package/dist/index.d.cts CHANGED
@@ -111,6 +111,8 @@ interface CustomerAddress {
111
111
  coordinates: number[];
112
112
  };
113
113
  isDefault: boolean;
114
+ /** When an errand last went to or from this address. */
115
+ lastUsedAt?: string;
114
116
  createdAt: string;
115
117
  updatedAt: string;
116
118
  }
@@ -200,6 +202,7 @@ declare enum InvoiceEventType {
200
202
  PaymentReversed = "payment_reversed",
201
203
  PaymentUpdated = "payment_updated",
202
204
  StatusChanged = "status_changed",
205
+ ErrandSettlementChanged = "errand_settlement_changed",
203
206
  Viewed = "viewed"
204
207
  }
205
208
  /** Why an errand in the period was not charged on the statement. */
@@ -218,6 +221,7 @@ interface InvoicePayment {
218
221
  method?: InvoicePaymentMethod | `${InvoicePaymentMethod}`;
219
222
  reference?: string;
220
223
  note?: string;
224
+ errandId?: string;
221
225
  recordedBy: string;
222
226
  reversedAt?: string;
223
227
  reversedBy?: string;
@@ -556,15 +560,6 @@ interface BusinessModules {
556
560
  }
557
561
  /** Every module key, so a plan map can be checked for completeness. */
558
562
  type BusinessModuleKey = keyof BusinessModules;
559
- /**
560
- * How a business funds fuel. `revenuePercent` is the share of errand revenue a
561
- * vehicle sets aside for its own fuel — the single knob behind the fuel-owed
562
- * balance. `null` (the default) means the business hasn't configured it and the
563
- * balance is not computed at all.
564
- */
565
- interface BusinessFuelSettings {
566
- revenuePercent: number | null;
567
- }
568
563
  /**
569
564
  * How a business pays its riders. `defaultPercentage` is the share of the
570
565
  * errand fees a rider earned that the rider takes home, used for every rider
@@ -599,10 +594,8 @@ interface BusinessSettings {
599
594
  tiktok: string | null;
600
595
  website: string | null;
601
596
  };
602
- fuel?: BusinessFuelSettings;
603
597
  riderPay?: BusinessRiderPaySettings;
604
598
  }
605
- declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
606
599
  declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
607
600
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
608
601
  interface BusinessMember {
@@ -737,95 +730,6 @@ interface VehiclePerformanceData {
737
730
  totals: VehiclePerformanceTotals;
738
731
  filters: VehiclePerformanceFilters;
739
732
  }
740
- declare enum FuelDueStatus {
741
- /** Worked through the fuel it was last given. Fuel this one. */
742
- Due = "DUE",
743
- /** Still running on fuel already paid for. Leave it. */
744
- Ok = "OK"
745
- }
746
- /** What the vehicle has done since the fuel it was last given. */
747
- interface FuelSinceLastRefuel {
748
- revenue: number;
749
- errandCount: number;
750
- fuelEarned: number;
751
- }
752
- interface FuelDueItem {
753
- vehicleId: string;
754
- vehicleNumber: string;
755
- shortName: string | null;
756
- vehicleType: VehicleType | `${VehicleType}`;
757
- /**
758
- * The fuel gauge, and the field to lead a UI with: how much of the fuel this
759
- * vehicle was last given it has worked through. 0 is freshly filled, 100 is
760
- * due, past 100 is overdue. Null when it has never been fuelled.
761
- */
762
- fuelUsedPercent: number | null;
763
- /** `fuelEarned - fuelSpent`, in naira — how much to give, not whether to. */
764
- fuelDue: number;
765
- fuelEarned: number;
766
- fuelSpent: number;
767
- revenue: number;
768
- errandCount: number;
769
- refuelCount: number;
770
- /** What this vehicle is typically fuelled with; null if never fuelled. */
771
- averageRefuelCost: number | null;
772
- /**
773
- * The figure has drifted far past what this vehicle is ever fuelled with —
774
- * the signature of a wrong `revenuePercent` compounding rather than a real
775
- * fuel need. Prompt to check the percentage instead of showing the figure.
776
- */
777
- needsCalibration: boolean;
778
- lastRefuel: {
779
- at: string;
780
- cost: number;
781
- } | null;
782
- sinceLastRefuel: FuelSinceLastRefuel | null;
783
- dueStatus: FuelDueStatus | `${FuelDueStatus}`;
784
- /** Counting starts here when the prediction has been reset; null otherwise. */
785
- countingFrom: string | null;
786
- }
787
- interface FuelDueTotals {
788
- totalDue: number;
789
- totalEarned: number;
790
- totalSpent: number;
791
- vehiclesDue: number;
792
- vehiclesNeedingCalibration: number;
793
- }
794
- interface FuelDueData {
795
- /** False when the business has not set `settings.fuel.revenuePercent`. */
796
- configured: boolean;
797
- revenuePercent: number | null;
798
- /** Only when `configured` is false: what history says the percent should be. */
799
- suggestedPercent?: number | null;
800
- vehicles: FuelDueItem[];
801
- totals: FuelDueTotals;
802
- }
803
- type FuelSuggestionConfidence = 'low' | 'medium' | 'high';
804
- interface FuelPercentSuggestion {
805
- /**
806
- * Fuel spend as a share of the revenue that earned it, to one decimal —
807
- * the percentage this business has actually been running at. Null when
808
- * there is too little history; `reason` says which.
809
- */
810
- suggestedPercent: number | null;
811
- /**
812
- * Read off the number of refuels behind the suggestion, not the length of
813
- * the window. Fuel bought near a window's edge is burnt outside it, so a
814
- * thin refuel count gives a volatile ratio however many days were read.
815
- */
816
- confidence: FuelSuggestionConfidence;
817
- reason: string | null;
818
- days: number;
819
- basedOn: {
820
- totalFuelCost: number;
821
- totalRevenue: number;
822
- refuelCount: number;
823
- errandCount: number;
824
- refuelledVehicles: number;
825
- /** Refuels per vehicle — what says whether the ratio has settled. */
826
- refuelsPerVehicle: number | null;
827
- };
828
- }
829
733
 
830
734
  type Rider = {
831
735
  id: string;
@@ -1108,7 +1012,6 @@ interface Errand {
1108
1012
  aliasId: string;
1109
1013
  updatedAt: Date;
1110
1014
  createdAt: Date;
1111
- errandRating?: string | ErrandRating;
1112
1015
  additionalData?: string;
1113
1016
  deliveryDate?: Date;
1114
1017
  cityId?: City;
@@ -1176,17 +1079,31 @@ interface AggregatedErrand extends Errand {
1176
1079
  };
1177
1080
  riderUserDetails?: User;
1178
1081
  }
1179
- interface ErrandRating {
1180
- createdAt: string;
1181
- errandId: string;
1182
- rating: number;
1183
- ratingText: string;
1184
- riderId: string;
1185
- updatedAt: string;
1186
- userId: string;
1187
- version: number;
1188
- _id: string;
1189
- }
1082
+ type PublicBusiness = Pick<Business, 'id' | 'name' | 'logoUrl' | 'officeNumber'>;
1083
+ type PublicPlace = Pick<AddressDetails, 'fullName' | 'address' | 'landmark'>;
1084
+ /**
1085
+ * `GET /errands/:alias/tracking`, which needs no login. An `AggregatedErrand`
1086
+ * cut down to what a tracking page shows: same field names, fewer fields.
1087
+ */
1088
+ type PublicTrackedErrand = Pick<AggregatedErrand, 'aliasId' | 'deliveryStatus' | 'updatedAt' | 'nameOfItem' | 'additionalData'> & {
1089
+ errandTimeline: (Pick<ErrandTimeline, 'currTimelineIndex'> & {
1090
+ timeline: {
1091
+ status: ErrandStatus | `${ErrandStatus}`;
1092
+ date?: Date;
1093
+ }[];
1094
+ }) | null;
1095
+ riderDetails: Pick<Rider, 'firstName' | 'lastName' | 'mobileNumber'> | null;
1096
+ businessDetails: PublicBusiness | null;
1097
+ courierBusinessDetails: PublicBusiness | null;
1098
+ pickupDetails: PublicPlace;
1099
+ deliveryDetails: PublicPlace;
1100
+ pickupLocation: {
1101
+ cityName?: string;
1102
+ };
1103
+ deliveryLocation: {
1104
+ cityName?: string;
1105
+ };
1106
+ };
1190
1107
  declare enum AddressTypes {
1191
1108
  DeliveryAddress = "deliveryAddress",
1192
1109
  PickupAddress = "pickupAddress"
@@ -1229,25 +1146,18 @@ type AddressDetails = {
1229
1146
  cityId: string;
1230
1147
  address: string;
1231
1148
  fullName: string;
1232
- location: {
1149
+ /** GeoJSON point, `[longitude, latitude]`. Absent when the stop has no coordinates. */
1150
+ location?: {
1151
+ type: 'Point';
1233
1152
  coordinates: number[];
1234
1153
  };
1235
1154
  mobileNumber?: string;
1236
1155
  alternateMobileNumber?: string;
1237
1156
  landmark?: string;
1238
1157
  addressId?: string;
1158
+ /** The saved customer this stop came from. */
1159
+ customerId?: string;
1239
1160
  };
1240
- interface ErrandReviewLink {
1241
- id: string;
1242
- errandId: string;
1243
- phoneNumber: string;
1244
- token: string;
1245
- expiresAt: string;
1246
- isUsed: boolean;
1247
- usedAt: string;
1248
- createdBy: string;
1249
- createdAt: string;
1250
- }
1251
1161
  declare enum DraftErrandStatus {
1252
1162
  Draft = "draft",
1253
1163
  RiderCompleted = "rider_completed",
@@ -1279,23 +1189,6 @@ interface DraftErrand {
1279
1189
  riderDetails?: Rider;
1280
1190
  riderUserDetails?: User | null;
1281
1191
  }
1282
- type ErrandDeliveryTiming = 'early' | 'on_time' | 'late';
1283
- type ErrandPackagingQuality = 'excellent' | 'average' | 'poor';
1284
- type ErrandRiderBehavior = 'outstanding' | 'acceptable' | 'unsatisfactory';
1285
- interface ErrandReview {
1286
- id: string;
1287
- errandId: string;
1288
- riderId: string;
1289
- reviewText: string;
1290
- rating: number;
1291
- deliveryTiming: ErrandDeliveryTiming;
1292
- packagingQuality: ErrandPackagingQuality;
1293
- riderBehavior: ErrandRiderBehavior;
1294
- reviewerMobile: string;
1295
- reviewerType: 'creator' | 'recipient';
1296
- createdAt: string;
1297
- updatedAt: string;
1298
- }
1299
1192
 
1300
1193
  declare enum NotificationType {
1301
1194
  Errand = "errand",
@@ -1775,67 +1668,6 @@ interface WhatsappSendLog {
1775
1668
  sentAt: string | Date;
1776
1669
  }
1777
1670
 
1778
- declare enum PortalStatus {
1779
- Draft = "draft",
1780
- Published = "published"
1781
- }
1782
- interface BusinessPortal {
1783
- id: string;
1784
- businessId: string;
1785
- /** Compose the URL yourself, e.g. `https://mydoormot.io/b/${handle}`. */
1786
- handle: string;
1787
- previousHandles: string[];
1788
- status: PortalStatus;
1789
- publishedAt?: string;
1790
- createdAt: string;
1791
- updatedAt: string;
1792
- }
1793
- interface PublicPortalBusiness {
1794
- name?: string;
1795
- description?: string;
1796
- officeNumber?: string;
1797
- address?: string;
1798
- logoUrl?: string;
1799
- logoBlurHash?: string;
1800
- coverImageUrl?: string;
1801
- coverImageBlurHash?: string;
1802
- isOnline?: boolean;
1803
- openingHours?: Record<string, unknown>;
1804
- socialLinks?: Record<string, unknown>;
1805
- }
1806
- /** `GET /api/v2/portals/:handle` — unauthenticated. */
1807
- interface PublicPortal {
1808
- handle: string;
1809
- /** Set when the requested handle was retired — redirect to `handle`. */
1810
- redirectedFrom?: string;
1811
- business: PublicPortalBusiness;
1812
- }
1813
- /** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
1814
- interface PortalHandleAvailability {
1815
- /** Normalised — what you would actually be assigned. */
1816
- handle: string;
1817
- available: boolean;
1818
- reason?: string;
1819
- }
1820
-
1821
- /**
1822
- * Platform-wide suggestions for businesses that haven't set their own values.
1823
- * Prefill forms only — e.g. `business.settings.fuel?.revenuePercent ??
1824
- * platform.fuel.revenuePercent`. Never applied to a business's calculations.
1825
- */
1826
- interface PlatformSettings {
1827
- fuel: {
1828
- /** Current pump price per litre, for prefilling refuel logs. */
1829
- pumpPrice: number | null;
1830
- revenuePercent: number | null;
1831
- };
1832
- riderPay: {
1833
- defaultPercentage: number | null;
1834
- };
1835
- createdAt: string;
1836
- updatedAt: string;
1837
- }
1838
-
1839
1671
  /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
1840
1672
  type GeoPoint = {
1841
1673
  type: 'Point';
@@ -1939,4 +1771,4 @@ declare enum LinkDestination {
1939
1771
  }
1940
1772
  type NullOrUndefined = null | undefined;
1941
1773
 
1942
- export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessFuelSettings, type BusinessLimits, type BusinessMember, type BusinessModuleKey, type BusinessModuleStates, type BusinessModules, type BusinessPg, BusinessPlan, type BusinessPortal, type BusinessRiderPaySettings, BusinessRole, type BusinessSettings, BusinessStatus, BusinessType, type BusinessWhatsappConfig, type City, type Collection, type ConnectionStatus, type Customer, type CustomerAddress, type CustomerBilling, type CustomerTransactionStats, DEFAULT_BUSINESS_FUEL_SETTINGS, DEFAULT_BUSINESS_RIDER_PAY_SETTINGS, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, ErrandFulfilment, ErrandInvoiceState, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type FuelDueData, type FuelDueItem, FuelDueStatus, type FuelDueTotals, type FuelPercentSuggestion, type FuelSinceLastRefuel, type FuelSuggestionConfidence, type GeoPoint, GlobalRoles, type IntegrationProvider, type IntegrationStatus, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, InvoiceStatus, type LatLng, LinkDestination, type LynqoneIntegrationSummary, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type ModuleState, type MotionState, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, PLAN_LIMIT_REACHED, PLAN_REQUIRED, type PaginateResult, PaymentOptions, PayoutPeriodType, PayoutRateSource, type PendingErrand, type PlatformSettings, type PortalHandleAvailability, PortalStatus, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, type PublicPortal, type PublicPortalBusiness, RemittanceStatus, type Rider, type RiderPayout, type RiderPayoutAdjustment, type RiderPayoutPreview, type RiderPayoutPreviewItem, RiderPayoutStatus, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, SweepExclusionReason, type Tracker, type TrackerPosition, type TrackerStatus, type TrackerType, type Transaction, type TransactionCategory, type TransactionItem, type TransactionRiderUser, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
1774
+ export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessLimits, type BusinessMember, type BusinessModuleKey, type BusinessModuleStates, type BusinessModules, type BusinessPg, BusinessPlan, type BusinessRiderPaySettings, BusinessRole, type BusinessSettings, BusinessStatus, BusinessType, type BusinessWhatsappConfig, type City, type Collection, type ConnectionStatus, type Customer, type CustomerAddress, type CustomerBilling, type CustomerTransactionStats, DEFAULT_BUSINESS_RIDER_PAY_SETTINGS, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, ErrandFulfilment, ErrandInvoiceState, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type GeoPoint, GlobalRoles, type IntegrationProvider, type IntegrationStatus, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, InvoiceStatus, type LatLng, LinkDestination, type LynqoneIntegrationSummary, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type ModuleState, type MotionState, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, PLAN_LIMIT_REACHED, PLAN_REQUIRED, type PaginateResult, PaymentOptions, PayoutPeriodType, PayoutRateSource, type PendingErrand, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, type PublicTrackedErrand, RemittanceStatus, type Rider, type RiderPayout, type RiderPayoutAdjustment, type RiderPayoutPreview, type RiderPayoutPreviewItem, RiderPayoutStatus, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, SweepExclusionReason, type Tracker, type TrackerPosition, type TrackerStatus, type TrackerType, type Transaction, type TransactionCategory, type TransactionItem, type TransactionRiderUser, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
package/dist/index.d.ts CHANGED
@@ -111,6 +111,8 @@ interface CustomerAddress {
111
111
  coordinates: number[];
112
112
  };
113
113
  isDefault: boolean;
114
+ /** When an errand last went to or from this address. */
115
+ lastUsedAt?: string;
114
116
  createdAt: string;
115
117
  updatedAt: string;
116
118
  }
@@ -200,6 +202,7 @@ declare enum InvoiceEventType {
200
202
  PaymentReversed = "payment_reversed",
201
203
  PaymentUpdated = "payment_updated",
202
204
  StatusChanged = "status_changed",
205
+ ErrandSettlementChanged = "errand_settlement_changed",
203
206
  Viewed = "viewed"
204
207
  }
205
208
  /** Why an errand in the period was not charged on the statement. */
@@ -218,6 +221,7 @@ interface InvoicePayment {
218
221
  method?: InvoicePaymentMethod | `${InvoicePaymentMethod}`;
219
222
  reference?: string;
220
223
  note?: string;
224
+ errandId?: string;
221
225
  recordedBy: string;
222
226
  reversedAt?: string;
223
227
  reversedBy?: string;
@@ -556,15 +560,6 @@ interface BusinessModules {
556
560
  }
557
561
  /** Every module key, so a plan map can be checked for completeness. */
558
562
  type BusinessModuleKey = keyof BusinessModules;
559
- /**
560
- * How a business funds fuel. `revenuePercent` is the share of errand revenue a
561
- * vehicle sets aside for its own fuel — the single knob behind the fuel-owed
562
- * balance. `null` (the default) means the business hasn't configured it and the
563
- * balance is not computed at all.
564
- */
565
- interface BusinessFuelSettings {
566
- revenuePercent: number | null;
567
- }
568
563
  /**
569
564
  * How a business pays its riders. `defaultPercentage` is the share of the
570
565
  * errand fees a rider earned that the rider takes home, used for every rider
@@ -599,10 +594,8 @@ interface BusinessSettings {
599
594
  tiktok: string | null;
600
595
  website: string | null;
601
596
  };
602
- fuel?: BusinessFuelSettings;
603
597
  riderPay?: BusinessRiderPaySettings;
604
598
  }
605
- declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
606
599
  declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
607
600
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
608
601
  interface BusinessMember {
@@ -737,95 +730,6 @@ interface VehiclePerformanceData {
737
730
  totals: VehiclePerformanceTotals;
738
731
  filters: VehiclePerformanceFilters;
739
732
  }
740
- declare enum FuelDueStatus {
741
- /** Worked through the fuel it was last given. Fuel this one. */
742
- Due = "DUE",
743
- /** Still running on fuel already paid for. Leave it. */
744
- Ok = "OK"
745
- }
746
- /** What the vehicle has done since the fuel it was last given. */
747
- interface FuelSinceLastRefuel {
748
- revenue: number;
749
- errandCount: number;
750
- fuelEarned: number;
751
- }
752
- interface FuelDueItem {
753
- vehicleId: string;
754
- vehicleNumber: string;
755
- shortName: string | null;
756
- vehicleType: VehicleType | `${VehicleType}`;
757
- /**
758
- * The fuel gauge, and the field to lead a UI with: how much of the fuel this
759
- * vehicle was last given it has worked through. 0 is freshly filled, 100 is
760
- * due, past 100 is overdue. Null when it has never been fuelled.
761
- */
762
- fuelUsedPercent: number | null;
763
- /** `fuelEarned - fuelSpent`, in naira — how much to give, not whether to. */
764
- fuelDue: number;
765
- fuelEarned: number;
766
- fuelSpent: number;
767
- revenue: number;
768
- errandCount: number;
769
- refuelCount: number;
770
- /** What this vehicle is typically fuelled with; null if never fuelled. */
771
- averageRefuelCost: number | null;
772
- /**
773
- * The figure has drifted far past what this vehicle is ever fuelled with —
774
- * the signature of a wrong `revenuePercent` compounding rather than a real
775
- * fuel need. Prompt to check the percentage instead of showing the figure.
776
- */
777
- needsCalibration: boolean;
778
- lastRefuel: {
779
- at: string;
780
- cost: number;
781
- } | null;
782
- sinceLastRefuel: FuelSinceLastRefuel | null;
783
- dueStatus: FuelDueStatus | `${FuelDueStatus}`;
784
- /** Counting starts here when the prediction has been reset; null otherwise. */
785
- countingFrom: string | null;
786
- }
787
- interface FuelDueTotals {
788
- totalDue: number;
789
- totalEarned: number;
790
- totalSpent: number;
791
- vehiclesDue: number;
792
- vehiclesNeedingCalibration: number;
793
- }
794
- interface FuelDueData {
795
- /** False when the business has not set `settings.fuel.revenuePercent`. */
796
- configured: boolean;
797
- revenuePercent: number | null;
798
- /** Only when `configured` is false: what history says the percent should be. */
799
- suggestedPercent?: number | null;
800
- vehicles: FuelDueItem[];
801
- totals: FuelDueTotals;
802
- }
803
- type FuelSuggestionConfidence = 'low' | 'medium' | 'high';
804
- interface FuelPercentSuggestion {
805
- /**
806
- * Fuel spend as a share of the revenue that earned it, to one decimal —
807
- * the percentage this business has actually been running at. Null when
808
- * there is too little history; `reason` says which.
809
- */
810
- suggestedPercent: number | null;
811
- /**
812
- * Read off the number of refuels behind the suggestion, not the length of
813
- * the window. Fuel bought near a window's edge is burnt outside it, so a
814
- * thin refuel count gives a volatile ratio however many days were read.
815
- */
816
- confidence: FuelSuggestionConfidence;
817
- reason: string | null;
818
- days: number;
819
- basedOn: {
820
- totalFuelCost: number;
821
- totalRevenue: number;
822
- refuelCount: number;
823
- errandCount: number;
824
- refuelledVehicles: number;
825
- /** Refuels per vehicle — what says whether the ratio has settled. */
826
- refuelsPerVehicle: number | null;
827
- };
828
- }
829
733
 
830
734
  type Rider = {
831
735
  id: string;
@@ -1108,7 +1012,6 @@ interface Errand {
1108
1012
  aliasId: string;
1109
1013
  updatedAt: Date;
1110
1014
  createdAt: Date;
1111
- errandRating?: string | ErrandRating;
1112
1015
  additionalData?: string;
1113
1016
  deliveryDate?: Date;
1114
1017
  cityId?: City;
@@ -1176,17 +1079,31 @@ interface AggregatedErrand extends Errand {
1176
1079
  };
1177
1080
  riderUserDetails?: User;
1178
1081
  }
1179
- interface ErrandRating {
1180
- createdAt: string;
1181
- errandId: string;
1182
- rating: number;
1183
- ratingText: string;
1184
- riderId: string;
1185
- updatedAt: string;
1186
- userId: string;
1187
- version: number;
1188
- _id: string;
1189
- }
1082
+ type PublicBusiness = Pick<Business, 'id' | 'name' | 'logoUrl' | 'officeNumber'>;
1083
+ type PublicPlace = Pick<AddressDetails, 'fullName' | 'address' | 'landmark'>;
1084
+ /**
1085
+ * `GET /errands/:alias/tracking`, which needs no login. An `AggregatedErrand`
1086
+ * cut down to what a tracking page shows: same field names, fewer fields.
1087
+ */
1088
+ type PublicTrackedErrand = Pick<AggregatedErrand, 'aliasId' | 'deliveryStatus' | 'updatedAt' | 'nameOfItem' | 'additionalData'> & {
1089
+ errandTimeline: (Pick<ErrandTimeline, 'currTimelineIndex'> & {
1090
+ timeline: {
1091
+ status: ErrandStatus | `${ErrandStatus}`;
1092
+ date?: Date;
1093
+ }[];
1094
+ }) | null;
1095
+ riderDetails: Pick<Rider, 'firstName' | 'lastName' | 'mobileNumber'> | null;
1096
+ businessDetails: PublicBusiness | null;
1097
+ courierBusinessDetails: PublicBusiness | null;
1098
+ pickupDetails: PublicPlace;
1099
+ deliveryDetails: PublicPlace;
1100
+ pickupLocation: {
1101
+ cityName?: string;
1102
+ };
1103
+ deliveryLocation: {
1104
+ cityName?: string;
1105
+ };
1106
+ };
1190
1107
  declare enum AddressTypes {
1191
1108
  DeliveryAddress = "deliveryAddress",
1192
1109
  PickupAddress = "pickupAddress"
@@ -1229,25 +1146,18 @@ type AddressDetails = {
1229
1146
  cityId: string;
1230
1147
  address: string;
1231
1148
  fullName: string;
1232
- location: {
1149
+ /** GeoJSON point, `[longitude, latitude]`. Absent when the stop has no coordinates. */
1150
+ location?: {
1151
+ type: 'Point';
1233
1152
  coordinates: number[];
1234
1153
  };
1235
1154
  mobileNumber?: string;
1236
1155
  alternateMobileNumber?: string;
1237
1156
  landmark?: string;
1238
1157
  addressId?: string;
1158
+ /** The saved customer this stop came from. */
1159
+ customerId?: string;
1239
1160
  };
1240
- interface ErrandReviewLink {
1241
- id: string;
1242
- errandId: string;
1243
- phoneNumber: string;
1244
- token: string;
1245
- expiresAt: string;
1246
- isUsed: boolean;
1247
- usedAt: string;
1248
- createdBy: string;
1249
- createdAt: string;
1250
- }
1251
1161
  declare enum DraftErrandStatus {
1252
1162
  Draft = "draft",
1253
1163
  RiderCompleted = "rider_completed",
@@ -1279,23 +1189,6 @@ interface DraftErrand {
1279
1189
  riderDetails?: Rider;
1280
1190
  riderUserDetails?: User | null;
1281
1191
  }
1282
- type ErrandDeliveryTiming = 'early' | 'on_time' | 'late';
1283
- type ErrandPackagingQuality = 'excellent' | 'average' | 'poor';
1284
- type ErrandRiderBehavior = 'outstanding' | 'acceptable' | 'unsatisfactory';
1285
- interface ErrandReview {
1286
- id: string;
1287
- errandId: string;
1288
- riderId: string;
1289
- reviewText: string;
1290
- rating: number;
1291
- deliveryTiming: ErrandDeliveryTiming;
1292
- packagingQuality: ErrandPackagingQuality;
1293
- riderBehavior: ErrandRiderBehavior;
1294
- reviewerMobile: string;
1295
- reviewerType: 'creator' | 'recipient';
1296
- createdAt: string;
1297
- updatedAt: string;
1298
- }
1299
1192
 
1300
1193
  declare enum NotificationType {
1301
1194
  Errand = "errand",
@@ -1775,67 +1668,6 @@ interface WhatsappSendLog {
1775
1668
  sentAt: string | Date;
1776
1669
  }
1777
1670
 
1778
- declare enum PortalStatus {
1779
- Draft = "draft",
1780
- Published = "published"
1781
- }
1782
- interface BusinessPortal {
1783
- id: string;
1784
- businessId: string;
1785
- /** Compose the URL yourself, e.g. `https://mydoormot.io/b/${handle}`. */
1786
- handle: string;
1787
- previousHandles: string[];
1788
- status: PortalStatus;
1789
- publishedAt?: string;
1790
- createdAt: string;
1791
- updatedAt: string;
1792
- }
1793
- interface PublicPortalBusiness {
1794
- name?: string;
1795
- description?: string;
1796
- officeNumber?: string;
1797
- address?: string;
1798
- logoUrl?: string;
1799
- logoBlurHash?: string;
1800
- coverImageUrl?: string;
1801
- coverImageBlurHash?: string;
1802
- isOnline?: boolean;
1803
- openingHours?: Record<string, unknown>;
1804
- socialLinks?: Record<string, unknown>;
1805
- }
1806
- /** `GET /api/v2/portals/:handle` — unauthenticated. */
1807
- interface PublicPortal {
1808
- handle: string;
1809
- /** Set when the requested handle was retired — redirect to `handle`. */
1810
- redirectedFrom?: string;
1811
- business: PublicPortalBusiness;
1812
- }
1813
- /** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
1814
- interface PortalHandleAvailability {
1815
- /** Normalised — what you would actually be assigned. */
1816
- handle: string;
1817
- available: boolean;
1818
- reason?: string;
1819
- }
1820
-
1821
- /**
1822
- * Platform-wide suggestions for businesses that haven't set their own values.
1823
- * Prefill forms only — e.g. `business.settings.fuel?.revenuePercent ??
1824
- * platform.fuel.revenuePercent`. Never applied to a business's calculations.
1825
- */
1826
- interface PlatformSettings {
1827
- fuel: {
1828
- /** Current pump price per litre, for prefilling refuel logs. */
1829
- pumpPrice: number | null;
1830
- revenuePercent: number | null;
1831
- };
1832
- riderPay: {
1833
- defaultPercentage: number | null;
1834
- };
1835
- createdAt: string;
1836
- updatedAt: string;
1837
- }
1838
-
1839
1671
  /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
1840
1672
  type GeoPoint = {
1841
1673
  type: 'Point';
@@ -1939,4 +1771,4 @@ declare enum LinkDestination {
1939
1771
  }
1940
1772
  type NullOrUndefined = null | undefined;
1941
1773
 
1942
- export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessFuelSettings, type BusinessLimits, type BusinessMember, type BusinessModuleKey, type BusinessModuleStates, type BusinessModules, type BusinessPg, BusinessPlan, type BusinessPortal, type BusinessRiderPaySettings, BusinessRole, type BusinessSettings, BusinessStatus, BusinessType, type BusinessWhatsappConfig, type City, type Collection, type ConnectionStatus, type Customer, type CustomerAddress, type CustomerBilling, type CustomerTransactionStats, DEFAULT_BUSINESS_FUEL_SETTINGS, DEFAULT_BUSINESS_RIDER_PAY_SETTINGS, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, type ErrandDeliveryTiming, ErrandFulfilment, ErrandInvoiceState, type ErrandPackagingQuality, type ErrandRating, type ErrandReview, type ErrandReviewLink, type ErrandRiderBehavior, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type FuelDueData, type FuelDueItem, FuelDueStatus, type FuelDueTotals, type FuelPercentSuggestion, type FuelSinceLastRefuel, type FuelSuggestionConfidence, type GeoPoint, GlobalRoles, type IntegrationProvider, type IntegrationStatus, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, InvoiceStatus, type LatLng, LinkDestination, type LynqoneIntegrationSummary, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type ModuleState, type MotionState, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, PLAN_LIMIT_REACHED, PLAN_REQUIRED, type PaginateResult, PaymentOptions, PayoutPeriodType, PayoutRateSource, type PendingErrand, type PlatformSettings, type PortalHandleAvailability, PortalStatus, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, type PublicPortal, type PublicPortalBusiness, RemittanceStatus, type Rider, type RiderPayout, type RiderPayoutAdjustment, type RiderPayoutPreview, type RiderPayoutPreviewItem, RiderPayoutStatus, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, SweepExclusionReason, type Tracker, type TrackerPosition, type TrackerStatus, type TrackerType, type Transaction, type TransactionCategory, type TransactionItem, type TransactionRiderUser, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
1774
+ export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessLimits, type BusinessMember, type BusinessModuleKey, type BusinessModuleStates, type BusinessModules, type BusinessPg, BusinessPlan, type BusinessRiderPaySettings, BusinessRole, type BusinessSettings, BusinessStatus, BusinessType, type BusinessWhatsappConfig, type City, type Collection, type ConnectionStatus, type Customer, type CustomerAddress, type CustomerBilling, type CustomerTransactionStats, DEFAULT_BUSINESS_RIDER_PAY_SETTINGS, DEFAULT_BUSINESS_SETTINGS, DeliveryStatus, type DraftErrand, DraftErrandStatus, type Enterprise, type EnterpriseCategoryDoc, type EnterpriseSubCategoryDoc, EnterpriseType, type Errand, ErrandFulfilment, ErrandInvoiceState, ErrandStatus, type ErrandTimeline, type ExpensePaidBy, FeePaymentStatus, FeeSettlement, type GeoPoint, GlobalRoles, type IntegrationProvider, type IntegrationStatus, type Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, InvoiceStatus, type LatLng, LinkDestination, type LynqoneIntegrationSummary, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type ModuleState, type MotionState, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, PLAN_LIMIT_REACHED, PLAN_REQUIRED, type PaginateResult, PaymentOptions, PayoutPeriodType, PayoutRateSource, type PendingErrand, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductTag, type ProductVariant, type ProductVariantPrice, type PublicTrackedErrand, RemittanceStatus, type Rider, type RiderPayout, type RiderPayoutAdjustment, type RiderPayoutPreview, type RiderPayoutPreviewItem, RiderPayoutStatus, type RiderPerformanceItem, type RiderPerformanceStats, type RiderPerformanceSummary, type RiderPerformanceTimeSeries, type RiderSettlement, type RiderWithUserDetails, RoleType, type State, SweepExclusionReason, type Tracker, type TrackerPosition, type TrackerStatus, type TrackerType, type Transaction, type TransactionCategory, type TransactionItem, type TransactionRiderUser, type TransactionType, type TransactionWithCategory, type TransactionWithJoin, type User, type UserAddress, type Vehicle, type VehicleErrandStats, type VehicleFuelStats, type VehicleLog, type VehicleLogStatsSummary, VehicleLogType, type VehicleLogWithErrands, type VehicleMaintenanceStats, type VehiclePerformanceData, type VehiclePerformanceFilters, type VehiclePerformanceItem, type VehiclePerformanceTotals, VehicleType, type VehicleWithRider, type Vendor, WhatsappButtonType, WhatsappComponentType, WhatsappEvent, WhatsappRecipient, type WhatsappSendLog, type WhatsappTemplate, type WhatsappTemplateButton, type WhatsappTemplateComponent, WhatsappTemplateMetaStatus, WhatsappTemplateParamSource, type WhatsappTemplateSource, errandTimeline };
package/dist/index.js CHANGED
@@ -146,6 +146,7 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
146
146
  InvoiceEventType2["PaymentReversed"] = "payment_reversed";
147
147
  InvoiceEventType2["PaymentUpdated"] = "payment_updated";
148
148
  InvoiceEventType2["StatusChanged"] = "status_changed";
149
+ InvoiceEventType2["ErrandSettlementChanged"] = "errand_settlement_changed";
149
150
  InvoiceEventType2["Viewed"] = "viewed";
150
151
  return InvoiceEventType2;
151
152
  })(InvoiceEventType || {});
@@ -176,11 +177,6 @@ var VehicleLogType = /* @__PURE__ */ ((VehicleLogType2) => {
176
177
  VehicleLogType2["REFUEL"] = "REFUEL";
177
178
  return VehicleLogType2;
178
179
  })(VehicleLogType || {});
179
- var FuelDueStatus = /* @__PURE__ */ ((FuelDueStatus2) => {
180
- FuelDueStatus2["Due"] = "DUE";
181
- FuelDueStatus2["Ok"] = "OK";
182
- return FuelDueStatus2;
183
- })(FuelDueStatus || {});
184
180
 
185
181
  // src/rider.ts
186
182
  var RemittanceStatus = /* @__PURE__ */ ((RemittanceStatus2) => {
@@ -260,9 +256,6 @@ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
260
256
  MembershipStatus2["DISABLED"] = "DISABLED";
261
257
  return MembershipStatus2;
262
258
  })(MembershipStatus || {});
263
- var DEFAULT_BUSINESS_FUEL_SETTINGS = {
264
- revenuePercent: null
265
- };
266
259
  var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
267
260
  defaultPercentage: null,
268
261
  periodType: null
@@ -290,7 +283,6 @@ var DEFAULT_BUSINESS_SETTINGS = {
290
283
  tiktok: null,
291
284
  website: null
292
285
  },
293
- fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
294
286
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
295
287
  };
296
288
  var BusinessCourierLinkStatus = /* @__PURE__ */ ((BusinessCourierLinkStatus2) => {
@@ -347,13 +339,6 @@ var WhatsappTemplateParamSource = /* @__PURE__ */ ((WhatsappTemplateParamSource2
347
339
  return WhatsappTemplateParamSource2;
348
340
  })(WhatsappTemplateParamSource || {});
349
341
 
350
- // src/portal.ts
351
- var PortalStatus = /* @__PURE__ */ ((PortalStatus2) => {
352
- PortalStatus2["Draft"] = "draft";
353
- PortalStatus2["Published"] = "published";
354
- return PortalStatus2;
355
- })(PortalStatus || {});
356
-
357
342
  // src/index.ts
358
343
  var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
359
344
  LinkDestination2["Website"] = "web";
@@ -370,7 +355,6 @@ export {
370
355
  BusinessRole,
371
356
  BusinessStatus,
372
357
  BusinessType,
373
- DEFAULT_BUSINESS_FUEL_SETTINGS,
374
358
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
375
359
  DEFAULT_BUSINESS_SETTINGS,
376
360
  DeliveryStatus,
@@ -381,7 +365,6 @@ export {
381
365
  ErrandStatus,
382
366
  FeePaymentStatus,
383
367
  FeeSettlement,
384
- FuelDueStatus,
385
368
  GlobalRoles,
386
369
  InvoiceEventType,
387
370
  InvoiceGenerationType,
@@ -396,7 +379,6 @@ export {
396
379
  PaymentOptions,
397
380
  PayoutPeriodType,
398
381
  PayoutRateSource,
399
- PortalStatus,
400
382
  RemittanceStatus,
401
383
  RiderPayoutStatus,
402
384
  RoleType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "2.2.5",
3
+ "version": "2.3.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/business.ts CHANGED
@@ -279,16 +279,6 @@ export interface BusinessModules {
279
279
  /** Every module key, so a plan map can be checked for completeness. */
280
280
  export type BusinessModuleKey = keyof BusinessModules;
281
281
 
282
- /**
283
- * How a business funds fuel. `revenuePercent` is the share of errand revenue a
284
- * vehicle sets aside for its own fuel — the single knob behind the fuel-owed
285
- * balance. `null` (the default) means the business hasn't configured it and the
286
- * balance is not computed at all.
287
- */
288
- export interface BusinessFuelSettings {
289
- revenuePercent: number | null;
290
- }
291
-
292
282
  /**
293
283
  * How a business pays its riders. `defaultPercentage` is the share of the
294
284
  * errand fees a rider earned that the rider takes home, used for every rider
@@ -324,14 +314,9 @@ export interface BusinessSettings {
324
314
  tiktok: string | null;
325
315
  website: string | null;
326
316
  };
327
- fuel?: BusinessFuelSettings;
328
317
  riderPay?: BusinessRiderPaySettings;
329
318
  }
330
319
 
331
- export const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings = {
332
- revenuePercent: null,
333
- };
334
-
335
320
  export const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings = {
336
321
  defaultPercentage: null,
337
322
  periodType: null,
@@ -360,7 +345,6 @@ export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
360
345
  tiktok: null,
361
346
  website: null,
362
347
  },
363
- fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
364
348
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
365
349
  };
366
350
 
package/src/customer.ts CHANGED
@@ -21,6 +21,8 @@ export interface CustomerAddress {
21
21
  coordinates: number[];
22
22
  };
23
23
  isDefault: boolean;
24
+ /** When an errand last went to or from this address. */
25
+ lastUsedAt?: string;
24
26
  createdAt: string;
25
27
  updatedAt: string;
26
28
  }
package/src/errand.ts CHANGED
@@ -177,7 +177,6 @@ export interface Errand {
177
177
  aliasId: string;
178
178
  updatedAt: Date;
179
179
  createdAt: Date;
180
- errandRating?: string | ErrandRating;
181
180
  additionalData?: string;
182
181
  deliveryDate?: Date;
183
182
  cityId?: City;
@@ -254,6 +253,37 @@ export interface AggregatedErrand extends Errand {
254
253
  riderUserDetails?: User;
255
254
  }
256
255
 
256
+ type PublicBusiness = Pick<
257
+ Business,
258
+ 'id' | 'name' | 'logoUrl' | 'officeNumber'
259
+ >;
260
+ type PublicPlace = Pick<AddressDetails, 'fullName' | 'address' | 'landmark'>;
261
+
262
+ /**
263
+ * `GET /errands/:alias/tracking`, which needs no login. An `AggregatedErrand`
264
+ * cut down to what a tracking page shows: same field names, fewer fields.
265
+ */
266
+ export type PublicTrackedErrand = Pick<
267
+ AggregatedErrand,
268
+ 'aliasId' | 'deliveryStatus' | 'updatedAt' | 'nameOfItem' | 'additionalData'
269
+ > & {
270
+ errandTimeline:
271
+ | (Pick<ErrandTimeline, 'currTimelineIndex'> & {
272
+ timeline: {
273
+ status: ErrandStatus | `${ErrandStatus}`;
274
+ date?: Date;
275
+ }[];
276
+ })
277
+ | null;
278
+ riderDetails: Pick<Rider, 'firstName' | 'lastName' | 'mobileNumber'> | null;
279
+ businessDetails: PublicBusiness | null;
280
+ courierBusinessDetails: PublicBusiness | null;
281
+ pickupDetails: PublicPlace;
282
+ deliveryDetails: PublicPlace;
283
+ pickupLocation: { cityName?: string };
284
+ deliveryLocation: { cityName?: string };
285
+ };
286
+
257
287
  export interface ErrandTimeline {
258
288
  id: string;
259
289
  errandId: string;
@@ -269,18 +299,6 @@ export interface ErrandTimeline {
269
299
  createdAt: Date;
270
300
  }
271
301
 
272
- export interface ErrandRating {
273
- createdAt: string;
274
- errandId: string;
275
- rating: number;
276
- ratingText: string;
277
- riderId: string;
278
- updatedAt: string;
279
- userId: string;
280
- version: number;
281
- _id: string;
282
- }
283
-
284
302
  export enum AddressTypes {
285
303
  DeliveryAddress = 'deliveryAddress',
286
304
  PickupAddress = 'pickupAddress',
@@ -312,27 +330,19 @@ export type AddressDetails = {
312
330
  cityId: string;
313
331
  address: string;
314
332
  fullName: string;
315
- location: {
333
+ /** GeoJSON point, `[longitude, latitude]`. Absent when the stop has no coordinates. */
334
+ location?: {
335
+ type: 'Point';
316
336
  coordinates: number[];
317
337
  };
318
338
  mobileNumber?: string;
319
339
  alternateMobileNumber?: string;
320
340
  landmark?: string;
321
341
  addressId?: string;
342
+ /** The saved customer this stop came from. */
343
+ customerId?: string;
322
344
  };
323
345
 
324
- export interface ErrandReviewLink {
325
- id: string;
326
- errandId: string;
327
- phoneNumber: string;
328
- token: string;
329
- expiresAt: string;
330
- isUsed: boolean;
331
- usedAt: string;
332
- createdBy: string;
333
- createdAt: string;
334
- }
335
-
336
346
  export enum DraftErrandStatus {
337
347
  Draft = 'draft',
338
348
  RiderCompleted = 'rider_completed',
@@ -375,24 +385,3 @@ export interface DraftErrand {
375
385
  riderUserDetails?: User | null;
376
386
  }
377
387
 
378
- export type ErrandDeliveryTiming = 'early' | 'on_time' | 'late';
379
- export type ErrandPackagingQuality = 'excellent' | 'average' | 'poor';
380
- export type ErrandRiderBehavior =
381
- | 'outstanding'
382
- | 'acceptable'
383
- | 'unsatisfactory';
384
-
385
- export interface ErrandReview {
386
- id: string;
387
- errandId: string;
388
- riderId: string;
389
- reviewText: string;
390
- rating: number;
391
- deliveryTiming: ErrandDeliveryTiming;
392
- packagingQuality: ErrandPackagingQuality;
393
- riderBehavior: ErrandRiderBehavior;
394
- reviewerMobile: string;
395
- reviewerType: 'creator' | 'recipient';
396
- createdAt: string;
397
- updatedAt: string;
398
- }
package/src/index.ts CHANGED
@@ -37,7 +37,5 @@ export * from './transaction';
37
37
  export * from './stat';
38
38
  export * from './maintenance';
39
39
  export * from './whatsapp';
40
- export * from './portal';
41
- export * from './platform';
42
40
  export * from './tracker';
43
41
  export * from './integration';
package/src/invoice.ts CHANGED
@@ -44,6 +44,7 @@ export enum InvoiceEventType {
44
44
  PaymentReversed = 'payment_reversed',
45
45
  PaymentUpdated = 'payment_updated',
46
46
  StatusChanged = 'status_changed',
47
+ ErrandSettlementChanged = 'errand_settlement_changed',
47
48
  Viewed = 'viewed',
48
49
  }
49
50
 
@@ -64,6 +65,7 @@ export interface InvoicePayment {
64
65
  method?: InvoicePaymentMethod | `${InvoicePaymentMethod}`;
65
66
  reference?: string;
66
67
  note?: string;
68
+ errandId?: string;
67
69
  recordedBy: string;
68
70
  reversedAt?: string;
69
71
  reversedBy?: string;
package/src/vehicle.ts CHANGED
@@ -109,103 +109,3 @@ export interface VehiclePerformanceData {
109
109
  filters: VehiclePerformanceFilters;
110
110
  }
111
111
 
112
- // Fuel Due Types
113
- //
114
- // These answer "which vehicles are due for fuel" without anyone counting
115
- // errands by hand. Errands generate fuel money at the business's
116
- // `settings.fuel.revenuePercent`; logged refuels spend it. The difference is
117
- // `fuelDue`, and `fuelUsedPercent` reads it back as a fuel gauge — 0 freshly
118
- // filled, 100 due, beyond that overdue.
119
-
120
- export enum FuelDueStatus {
121
- /** Worked through the fuel it was last given. Fuel this one. */
122
- Due = 'DUE',
123
- /** Still running on fuel already paid for. Leave it. */
124
- Ok = 'OK',
125
- }
126
-
127
- /** What the vehicle has done since the fuel it was last given. */
128
- export interface FuelSinceLastRefuel {
129
- revenue: number;
130
- errandCount: number;
131
- fuelEarned: number;
132
- }
133
-
134
- export interface FuelDueItem {
135
- vehicleId: string;
136
- vehicleNumber: string;
137
- shortName: string | null;
138
- vehicleType: VehicleType | `${VehicleType}`;
139
- /**
140
- * The fuel gauge, and the field to lead a UI with: how much of the fuel this
141
- * vehicle was last given it has worked through. 0 is freshly filled, 100 is
142
- * due, past 100 is overdue. Null when it has never been fuelled.
143
- */
144
- fuelUsedPercent: number | null;
145
- /** `fuelEarned - fuelSpent`, in naira — how much to give, not whether to. */
146
- fuelDue: number;
147
- fuelEarned: number;
148
- fuelSpent: number;
149
- revenue: number;
150
- errandCount: number;
151
- refuelCount: number;
152
- /** What this vehicle is typically fuelled with; null if never fuelled. */
153
- averageRefuelCost: number | null;
154
- /**
155
- * The figure has drifted far past what this vehicle is ever fuelled with —
156
- * the signature of a wrong `revenuePercent` compounding rather than a real
157
- * fuel need. Prompt to check the percentage instead of showing the figure.
158
- */
159
- needsCalibration: boolean;
160
- lastRefuel: { at: string; cost: number } | null;
161
- sinceLastRefuel: FuelSinceLastRefuel | null;
162
- dueStatus: FuelDueStatus | `${FuelDueStatus}`;
163
- /** Counting starts here when the prediction has been reset; null otherwise. */
164
- countingFrom: string | null;
165
- }
166
-
167
- export interface FuelDueTotals {
168
- totalDue: number;
169
- totalEarned: number;
170
- totalSpent: number;
171
- vehiclesDue: number;
172
- vehiclesNeedingCalibration: number;
173
- }
174
-
175
- export interface FuelDueData {
176
- /** False when the business has not set `settings.fuel.revenuePercent`. */
177
- configured: boolean;
178
- revenuePercent: number | null;
179
- /** Only when `configured` is false: what history says the percent should be. */
180
- suggestedPercent?: number | null;
181
- vehicles: FuelDueItem[];
182
- totals: FuelDueTotals;
183
- }
184
-
185
- export type FuelSuggestionConfidence = 'low' | 'medium' | 'high';
186
-
187
- export interface FuelPercentSuggestion {
188
- /**
189
- * Fuel spend as a share of the revenue that earned it, to one decimal —
190
- * the percentage this business has actually been running at. Null when
191
- * there is too little history; `reason` says which.
192
- */
193
- suggestedPercent: number | null;
194
- /**
195
- * Read off the number of refuels behind the suggestion, not the length of
196
- * the window. Fuel bought near a window's edge is burnt outside it, so a
197
- * thin refuel count gives a volatile ratio however many days were read.
198
- */
199
- confidence: FuelSuggestionConfidence;
200
- reason: string | null;
201
- days: number;
202
- basedOn: {
203
- totalFuelCost: number;
204
- totalRevenue: number;
205
- refuelCount: number;
206
- errandCount: number;
207
- refuelledVehicles: number;
208
- /** Refuels per vehicle — what says whether the ratio has settled. */
209
- refuelsPerVehicle: number | null;
210
- };
211
- }
package/src/platform.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Platform-wide suggestions for businesses that haven't set their own values.
3
- * Prefill forms only — e.g. `business.settings.fuel?.revenuePercent ??
4
- * platform.fuel.revenuePercent`. Never applied to a business's calculations.
5
- */
6
- export interface PlatformSettings {
7
- fuel: {
8
- /** Current pump price per litre, for prefilling refuel logs. */
9
- pumpPrice: number | null;
10
- revenuePercent: number | null;
11
- };
12
- riderPay: {
13
- defaultPercentage: number | null;
14
- };
15
- createdAt: string;
16
- updatedAt: string;
17
- }
package/src/portal.ts DELETED
@@ -1,46 +0,0 @@
1
- export enum PortalStatus {
2
- Draft = 'draft',
3
- Published = 'published',
4
- }
5
-
6
- export interface BusinessPortal {
7
- id: string;
8
- businessId: string;
9
- /** Compose the URL yourself, e.g. `https://mydoormot.io/b/${handle}`. */
10
- handle: string;
11
- previousHandles: string[];
12
- status: PortalStatus;
13
- publishedAt?: string;
14
- createdAt: string;
15
- updatedAt: string;
16
- }
17
-
18
- export interface PublicPortalBusiness {
19
- name?: string;
20
- description?: string;
21
- officeNumber?: string;
22
- address?: string;
23
- logoUrl?: string;
24
- logoBlurHash?: string;
25
- coverImageUrl?: string;
26
- coverImageBlurHash?: string;
27
- isOnline?: boolean;
28
- openingHours?: Record<string, unknown>;
29
- socialLinks?: Record<string, unknown>;
30
- }
31
-
32
- /** `GET /api/v2/portals/:handle` — unauthenticated. */
33
- export interface PublicPortal {
34
- handle: string;
35
- /** Set when the requested handle was retired — redirect to `handle`. */
36
- redirectedFrom?: string;
37
- business: PublicPortalBusiness;
38
- }
39
-
40
- /** `GET /api/v2/portals/handles/:handle` — unauthenticated. */
41
- export interface PortalHandleAvailability {
42
- /** Normalised — what you would actually be assigned. */
43
- handle: string;
44
- available: boolean;
45
- reason?: string;
46
- }