@mydoormot/app-types 2.1.3 → 2.2.0

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,18 +1,18 @@
1
-
2
- > @mydoormot/app-types@2.1.2 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
3
- > tsup src/index.ts --format esm,cjs --dts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.3.0
8
- CLI Target: es2021
9
- ESM Build start
10
- CJS Build start
11
- ESM dist/index.js 14.81 KB
12
- ESM ⚡️ Build success in 69ms
13
- CJS dist/index.cjs 17.79 KB
14
- CJS ⚡️ Build success in 69ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 723ms
17
- DTS dist/index.d.ts 55.91 KB
18
- DTS dist/index.d.cts 55.91 KB
1
+
2
+ > @mydoormot/app-types@2.1.4 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
3
+ > tsup src/index.ts --format esm,cjs --dts
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v7.3.0
8
+ CLI Target: es2021
9
+ ESM Build start
10
+ CJS Build start
11
+ CJS dist/index.cjs 18.21 KB
12
+ CJS ⚡️ Build success in 67ms
13
+ ESM dist/index.js 15.13 KB
14
+ ESM ⚡️ Build success in 67ms
15
+ DTS Build start
16
+ DTS ⚡️ Build success in 800ms
17
+ DTS dist/index.d.ts 58.74 KB
18
+ DTS dist/index.d.cts 58.74 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added tracking and lyqone integration
8
+
9
+ ## 2.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated plan
14
+
3
15
  ## 2.1.3
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -49,6 +49,8 @@ __export(src_exports, {
49
49
  LinkDestination: () => LinkDestination,
50
50
  MembershipStatus: () => MembershipStatus,
51
51
  NotificationType: () => NotificationType,
52
+ PLAN_LIMIT_REACHED: () => PLAN_LIMIT_REACHED,
53
+ PLAN_REQUIRED: () => PLAN_REQUIRED,
52
54
  PaymentOptions: () => PaymentOptions,
53
55
  PayoutPeriodType: () => PayoutPeriodType,
54
56
  PayoutRateSource: () => PayoutRateSource,
@@ -186,6 +188,7 @@ var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus2) => {
186
188
  })(InvoiceStatus || {});
187
189
  var InvoiceItemType = /* @__PURE__ */ ((InvoiceItemType2) => {
188
190
  InvoiceItemType2["Errand"] = "errand";
191
+ InvoiceItemType2["Manual"] = "manual";
189
192
  return InvoiceItemType2;
190
193
  })(InvoiceItemType || {});
191
194
  var InvoiceGenerationType = /* @__PURE__ */ ((InvoiceGenerationType2) => {
@@ -215,6 +218,7 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
215
218
  InvoiceEventType2["LineAmountChanged"] = "line_amount_changed";
216
219
  InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
217
220
  InvoiceEventType2["PaymentReversed"] = "payment_reversed";
221
+ InvoiceEventType2["PaymentUpdated"] = "payment_updated";
218
222
  InvoiceEventType2["StatusChanged"] = "status_changed";
219
223
  InvoiceEventType2["Viewed"] = "viewed";
220
224
  return InvoiceEventType2;
@@ -305,10 +309,15 @@ var BusinessType = /* @__PURE__ */ ((BusinessType2) => {
305
309
  })(BusinessType || {});
306
310
  var BusinessPlan = /* @__PURE__ */ ((BusinessPlan2) => {
307
311
  BusinessPlan2["NONE"] = "none";
312
+ BusinessPlan2["STARTER"] = "starter";
313
+ BusinessPlan2["GROWTH"] = "growth";
314
+ BusinessPlan2["SCALE"] = "scale";
308
315
  BusinessPlan2["FULL"] = "full";
309
316
  BusinessPlan2["INTERNAL"] = "internal";
310
317
  return BusinessPlan2;
311
318
  })(BusinessPlan || {});
319
+ var PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
320
+ var PLAN_REQUIRED = "PLAN_REQUIRED";
312
321
  var BusinessStatus = /* @__PURE__ */ ((BusinessStatus2) => {
313
322
  BusinessStatus2["ACTIVE"] = "active";
314
323
  BusinessStatus2["DISABLED"] = "disabled";
@@ -324,7 +333,7 @@ var BusinessRole = /* @__PURE__ */ ((BusinessRole2) => {
324
333
  var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
325
334
  MembershipStatus2["ACTIVE"] = "ACTIVE";
326
335
  MembershipStatus2["PENDING_ACTIVATION"] = "PENDING_ACTIVATION";
327
- MembershipStatus2["SUSPENDED"] = "SUSPENDED";
336
+ MembershipStatus2["DISABLED"] = "DISABLED";
328
337
  return MembershipStatus2;
329
338
  })(MembershipStatus || {});
330
339
  var DEFAULT_BUSINESS_FUEL_SETTINGS = {
@@ -459,6 +468,8 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
459
468
  LinkDestination,
460
469
  MembershipStatus,
461
470
  NotificationType,
471
+ PLAN_LIMIT_REACHED,
472
+ PLAN_REQUIRED,
462
473
  PaymentOptions,
463
474
  PayoutPeriodType,
464
475
  PayoutRateSource,
package/dist/index.d.cts CHANGED
@@ -170,7 +170,8 @@ declare enum InvoiceStatus {
170
170
  Failed = "failed"
171
171
  }
172
172
  declare enum InvoiceItemType {
173
- Errand = "errand"
173
+ Errand = "errand",
174
+ Manual = "manual"
174
175
  }
175
176
  declare enum InvoiceGenerationType {
176
177
  Auto = "auto",
@@ -196,6 +197,7 @@ declare enum InvoiceEventType {
196
197
  LineAmountChanged = "line_amount_changed",
197
198
  PaymentRecorded = "payment_recorded",
198
199
  PaymentReversed = "payment_reversed",
200
+ PaymentUpdated = "payment_updated",
199
201
  StatusChanged = "status_changed",
200
202
  Viewed = "viewed"
201
203
  }
@@ -365,9 +367,25 @@ declare enum BusinessPlan {
365
367
  * without deleting anything. For a hard cut-off use `BusinessStatus`.
366
368
  */
367
369
  NONE = "none",
370
+ /** Paid tiers: same modules, different rider caps. */
371
+ STARTER = "starter",
372
+ GROWTH = "growth",
373
+ SCALE = "scale",
374
+ /** Pre-pricing businesses, grandfathered: no caps. */
368
375
  FULL = "full",
369
376
  INTERNAL = "internal"
370
377
  }
378
+ /**
379
+ * Plan caps. `null` is unlimited. `riders` counts every rider not archived,
380
+ * suspended ones included.
381
+ */
382
+ interface BusinessLimits {
383
+ riders: number | null;
384
+ }
385
+ /** 403 code: adding past a plan cap. */
386
+ declare const PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
387
+ /** 403 code: creating anything with no active plan (trial over, unpaid). */
388
+ declare const PLAN_REQUIRED = "PLAN_REQUIRED";
371
389
  /**
372
390
  * What a module looks like to one business.
373
391
  *
@@ -397,6 +415,11 @@ interface Business {
397
415
  officeNumber: string;
398
416
  type: BusinessType | `${BusinessType}`;
399
417
  plan: BusinessPlan | `${BusinessPlan}`;
418
+ /** Trial plan, in force until `trialEndsAt`. Kept after it ends. */
419
+ trialPlan: BusinessPlan | `${BusinessPlan}` | NullOrUndefined;
420
+ trialEndsAt: string | Date | NullOrUndefined;
421
+ /** The plan in force (trial included). Show this, not `plan`. */
422
+ effectivePlan: BusinessPlan | `${BusinessPlan}`;
400
423
  categoryId: string;
401
424
  address: string | NullOrUndefined;
402
425
  addressCoordinates: number[] | NullOrUndefined | {
@@ -452,6 +475,8 @@ interface Business {
452
475
  * learns the feature exists.
453
476
  */
454
477
  moduleStates: BusinessModuleStates;
478
+ /** Caps from `effectivePlan`. */
479
+ limits: BusinessLimits;
455
480
  }
456
481
  interface BusinessPg extends Business {
457
482
  pgId: any;
@@ -480,7 +505,7 @@ declare enum BusinessRole {
480
505
  declare enum MembershipStatus {
481
506
  ACTIVE = "ACTIVE",
482
507
  PENDING_ACTIVATION = "PENDING_ACTIVATION",
483
- SUSPENDED = "SUSPENDED"
508
+ DISABLED = "DISABLED"
484
509
  }
485
510
  interface OpeningHours {
486
511
  open: string;
@@ -588,6 +613,9 @@ interface BusinessMember {
588
613
  pgId: string;
589
614
  role: BusinessRole | `${BusinessRole}`;
590
615
  status: MembershipStatus | `${MembershipStatus}`;
616
+ disabledAt: string | NullOrUndefined;
617
+ disabledBy: string | NullOrUndefined;
618
+ disabledReason: string | NullOrUndefined;
591
619
  invitedBy: string | NullOrUndefined;
592
620
  userDetails: User | NullOrUndefined;
593
621
  invitedByUserDetails: User | NullOrUndefined;
@@ -618,34 +646,6 @@ declare enum VehicleType {
618
646
  Bike = "bike",
619
647
  Shuttle = "shuttle"
620
648
  }
621
- /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
622
- type GeoPoint = {
623
- type: 'Point';
624
- coordinates: [number, number];
625
- };
626
- /**
627
- * A trimmed-down Traccar position kept as the vehicle's latest fix. Carries the
628
- * scalar fields a GeoPoint can't — `speed`/`course` drive derived state
629
- * (moving vs. idle, heading), `recordedAt` gauges staleness.
630
- */
631
- type TrackerPosition = {
632
- latitude: number;
633
- longitude: number;
634
- speed?: number;
635
- course?: number;
636
- accuracy?: number;
637
- valid?: boolean;
638
- /** Traccar's moving/stopped determination — steadier than speed alone. */
639
- motion?: boolean;
640
- /** Engine on/off, when the device reports it. */
641
- ignition?: boolean;
642
- /** ISO time the GPS computed the position — the truest "when". */
643
- fixTime?: string;
644
- /** ISO time from the device's own clock (drift/buffering signal). */
645
- deviceTime?: string;
646
- /** ISO time Traccar received the report — lags `fixTime` when buffered. */
647
- serverTime?: string;
648
- };
649
649
  type Vehicle = {
650
650
  id: string;
651
651
  vehicleNumber: string;
@@ -656,15 +656,9 @@ type Vehicle = {
656
656
  businessId: string;
657
657
  shortName?: string;
658
658
  userId?: string;
659
- /** External GPS device uniqueId bound to this vehicle. */
660
- trackerId?: string;
661
- /** Latest known tracker position, as a GeoPoint for proximity queries. */
662
- location?: GeoPoint;
663
- /** Latest tracker fix with richer scalar fields (speed, course, …). */
664
- position?: TrackerPosition;
665
659
  };
666
660
  type VehicleWithRider = Vehicle & {
667
- riders: RiderWithUserDetails[];
661
+ riders: Rider[];
668
662
  };
669
663
  declare enum VehicleLogType {
670
664
  REFUEL = "REFUEL"
@@ -848,7 +842,6 @@ type Rider = {
848
842
  };
849
843
  vehicleNumber?: string;
850
844
  verified: boolean;
851
- active: boolean;
852
845
  updatedAt: Date;
853
846
  createdAt: Date;
854
847
  rating: number;
@@ -1038,11 +1031,6 @@ interface PendingErrand {
1038
1031
  rider: string;
1039
1032
  customerId: string;
1040
1033
  deliveryStatus: ErrandStatus;
1041
- invoice: {
1042
- invoiceStatus: string;
1043
- refId: string;
1044
- transactionId: string;
1045
- };
1046
1034
  nameOfItem: string;
1047
1035
  pickupDetails: {
1048
1036
  cityId: string;
@@ -1826,6 +1814,97 @@ interface PortalHandleAvailability {
1826
1814
  reason?: string;
1827
1815
  }
1828
1816
 
1817
+ /**
1818
+ * Platform-wide suggestions for businesses that haven't set their own values.
1819
+ * Prefill forms only — e.g. `business.settings.fuel?.revenuePercent ??
1820
+ * platform.fuel.revenuePercent`. Never applied to a business's calculations.
1821
+ */
1822
+ interface PlatformSettings {
1823
+ fuel: {
1824
+ /** Current pump price per litre, for prefilling refuel logs. */
1825
+ pumpPrice: number | null;
1826
+ revenuePercent: number | null;
1827
+ };
1828
+ riderPay: {
1829
+ defaultPercentage: number | null;
1830
+ };
1831
+ createdAt: string;
1832
+ updatedAt: string;
1833
+ }
1834
+
1835
+ /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
1836
+ type GeoPoint = {
1837
+ type: 'Point';
1838
+ coordinates: [number, number];
1839
+ };
1840
+ /** Lynqone's device kind, synced on import. */
1841
+ type TrackerType = 'car' | 'bike';
1842
+ /** `unbound`: no longer in the connected lynqone account. */
1843
+ type TrackerStatus = 'active' | 'unbound';
1844
+ type MotionState = 'moving' | 'stopped';
1845
+ /**
1846
+ * A trimmed-down Traccar position kept as the tracker's latest fix. Carries the
1847
+ * scalar fields a GeoPoint can't — `speed`/`course` drive derived state
1848
+ * (moving vs. idle, heading), `fixTime` gauges staleness.
1849
+ */
1850
+ type TrackerPosition = {
1851
+ latitude: number;
1852
+ longitude: number;
1853
+ speed?: number;
1854
+ course?: number;
1855
+ accuracy?: number;
1856
+ valid?: boolean;
1857
+ /** Traccar's moving/stopped determination — steadier than speed alone. */
1858
+ motion?: boolean;
1859
+ /** Engine on/off, when the device reports it. */
1860
+ ignition?: boolean;
1861
+ /** ISO time the GPS computed the position — the truest "when". */
1862
+ fixTime?: string;
1863
+ /** ISO time from the device's own clock (drift/buffering signal). */
1864
+ deviceTime?: string;
1865
+ /** ISO time Traccar received the report — lags `fixTime` when buffered. */
1866
+ serverTime?: string;
1867
+ /** Traccar's free-form attributes bag, as sent. */
1868
+ attributes?: Record<string, unknown>;
1869
+ };
1870
+ /**
1871
+ * A GPS tracker from the business's lynqone account. Only the last position is
1872
+ * kept; history stays in lynqone.
1873
+ */
1874
+ type Tracker = {
1875
+ id: string;
1876
+ businessId: string;
1877
+ /** Lynqone's tracker uuid. */
1878
+ lynqoneTrackerId: string;
1879
+ /** Device id, for display and search. */
1880
+ uniqueIdentifier: string;
1881
+ name?: string;
1882
+ type?: TrackerType;
1883
+ /** Unset means unassigned. A vehicle has at most one tracker. */
1884
+ vehicleId?: string;
1885
+ location?: GeoPoint;
1886
+ lastPosition?: TrackerPosition;
1887
+ lastSeenAt?: string;
1888
+ motionState?: MotionState;
1889
+ motionChangedAt?: string;
1890
+ batteryLevel?: number;
1891
+ lowBatteryAt?: string;
1892
+ status: TrackerStatus;
1893
+ createdAt: string;
1894
+ updatedAt: string;
1895
+ };
1896
+
1897
+ type IntegrationProvider = 'lynqone';
1898
+ type IntegrationStatus = 'connected' | 'disconnected' | 'error';
1899
+ /** What `GET /integrations/lynqone` returns. The key itself is never sent. */
1900
+ type LynqoneIntegrationSummary = {
1901
+ status: IntegrationStatus;
1902
+ connectedAt?: string;
1903
+ disconnectedAt?: string;
1904
+ lastError?: string;
1905
+ trackerCount: number;
1906
+ };
1907
+
1829
1908
  interface PaginateResult<T> {
1830
1909
  docs: T[];
1831
1910
  totalDocs: number;
@@ -1848,4 +1927,4 @@ declare enum LinkDestination {
1848
1927
  }
1849
1928
  type NullOrUndefined = null | undefined;
1850
1929
 
1851
- export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessFuelSettings, 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 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 Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, InvoiceStatus, type LatLng, LinkDestination, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type ModuleState, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, type PaginateResult, PaymentOptions, PayoutPeriodType, PayoutRateSource, type PendingErrand, 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 TrackerPosition, 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 };
1930
+ 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 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 };
package/dist/index.d.ts CHANGED
@@ -170,7 +170,8 @@ declare enum InvoiceStatus {
170
170
  Failed = "failed"
171
171
  }
172
172
  declare enum InvoiceItemType {
173
- Errand = "errand"
173
+ Errand = "errand",
174
+ Manual = "manual"
174
175
  }
175
176
  declare enum InvoiceGenerationType {
176
177
  Auto = "auto",
@@ -196,6 +197,7 @@ declare enum InvoiceEventType {
196
197
  LineAmountChanged = "line_amount_changed",
197
198
  PaymentRecorded = "payment_recorded",
198
199
  PaymentReversed = "payment_reversed",
200
+ PaymentUpdated = "payment_updated",
199
201
  StatusChanged = "status_changed",
200
202
  Viewed = "viewed"
201
203
  }
@@ -365,9 +367,25 @@ declare enum BusinessPlan {
365
367
  * without deleting anything. For a hard cut-off use `BusinessStatus`.
366
368
  */
367
369
  NONE = "none",
370
+ /** Paid tiers: same modules, different rider caps. */
371
+ STARTER = "starter",
372
+ GROWTH = "growth",
373
+ SCALE = "scale",
374
+ /** Pre-pricing businesses, grandfathered: no caps. */
368
375
  FULL = "full",
369
376
  INTERNAL = "internal"
370
377
  }
378
+ /**
379
+ * Plan caps. `null` is unlimited. `riders` counts every rider not archived,
380
+ * suspended ones included.
381
+ */
382
+ interface BusinessLimits {
383
+ riders: number | null;
384
+ }
385
+ /** 403 code: adding past a plan cap. */
386
+ declare const PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
387
+ /** 403 code: creating anything with no active plan (trial over, unpaid). */
388
+ declare const PLAN_REQUIRED = "PLAN_REQUIRED";
371
389
  /**
372
390
  * What a module looks like to one business.
373
391
  *
@@ -397,6 +415,11 @@ interface Business {
397
415
  officeNumber: string;
398
416
  type: BusinessType | `${BusinessType}`;
399
417
  plan: BusinessPlan | `${BusinessPlan}`;
418
+ /** Trial plan, in force until `trialEndsAt`. Kept after it ends. */
419
+ trialPlan: BusinessPlan | `${BusinessPlan}` | NullOrUndefined;
420
+ trialEndsAt: string | Date | NullOrUndefined;
421
+ /** The plan in force (trial included). Show this, not `plan`. */
422
+ effectivePlan: BusinessPlan | `${BusinessPlan}`;
400
423
  categoryId: string;
401
424
  address: string | NullOrUndefined;
402
425
  addressCoordinates: number[] | NullOrUndefined | {
@@ -452,6 +475,8 @@ interface Business {
452
475
  * learns the feature exists.
453
476
  */
454
477
  moduleStates: BusinessModuleStates;
478
+ /** Caps from `effectivePlan`. */
479
+ limits: BusinessLimits;
455
480
  }
456
481
  interface BusinessPg extends Business {
457
482
  pgId: any;
@@ -480,7 +505,7 @@ declare enum BusinessRole {
480
505
  declare enum MembershipStatus {
481
506
  ACTIVE = "ACTIVE",
482
507
  PENDING_ACTIVATION = "PENDING_ACTIVATION",
483
- SUSPENDED = "SUSPENDED"
508
+ DISABLED = "DISABLED"
484
509
  }
485
510
  interface OpeningHours {
486
511
  open: string;
@@ -588,6 +613,9 @@ interface BusinessMember {
588
613
  pgId: string;
589
614
  role: BusinessRole | `${BusinessRole}`;
590
615
  status: MembershipStatus | `${MembershipStatus}`;
616
+ disabledAt: string | NullOrUndefined;
617
+ disabledBy: string | NullOrUndefined;
618
+ disabledReason: string | NullOrUndefined;
591
619
  invitedBy: string | NullOrUndefined;
592
620
  userDetails: User | NullOrUndefined;
593
621
  invitedByUserDetails: User | NullOrUndefined;
@@ -618,34 +646,6 @@ declare enum VehicleType {
618
646
  Bike = "bike",
619
647
  Shuttle = "shuttle"
620
648
  }
621
- /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
622
- type GeoPoint = {
623
- type: 'Point';
624
- coordinates: [number, number];
625
- };
626
- /**
627
- * A trimmed-down Traccar position kept as the vehicle's latest fix. Carries the
628
- * scalar fields a GeoPoint can't — `speed`/`course` drive derived state
629
- * (moving vs. idle, heading), `recordedAt` gauges staleness.
630
- */
631
- type TrackerPosition = {
632
- latitude: number;
633
- longitude: number;
634
- speed?: number;
635
- course?: number;
636
- accuracy?: number;
637
- valid?: boolean;
638
- /** Traccar's moving/stopped determination — steadier than speed alone. */
639
- motion?: boolean;
640
- /** Engine on/off, when the device reports it. */
641
- ignition?: boolean;
642
- /** ISO time the GPS computed the position — the truest "when". */
643
- fixTime?: string;
644
- /** ISO time from the device's own clock (drift/buffering signal). */
645
- deviceTime?: string;
646
- /** ISO time Traccar received the report — lags `fixTime` when buffered. */
647
- serverTime?: string;
648
- };
649
649
  type Vehicle = {
650
650
  id: string;
651
651
  vehicleNumber: string;
@@ -656,15 +656,9 @@ type Vehicle = {
656
656
  businessId: string;
657
657
  shortName?: string;
658
658
  userId?: string;
659
- /** External GPS device uniqueId bound to this vehicle. */
660
- trackerId?: string;
661
- /** Latest known tracker position, as a GeoPoint for proximity queries. */
662
- location?: GeoPoint;
663
- /** Latest tracker fix with richer scalar fields (speed, course, …). */
664
- position?: TrackerPosition;
665
659
  };
666
660
  type VehicleWithRider = Vehicle & {
667
- riders: RiderWithUserDetails[];
661
+ riders: Rider[];
668
662
  };
669
663
  declare enum VehicleLogType {
670
664
  REFUEL = "REFUEL"
@@ -848,7 +842,6 @@ type Rider = {
848
842
  };
849
843
  vehicleNumber?: string;
850
844
  verified: boolean;
851
- active: boolean;
852
845
  updatedAt: Date;
853
846
  createdAt: Date;
854
847
  rating: number;
@@ -1038,11 +1031,6 @@ interface PendingErrand {
1038
1031
  rider: string;
1039
1032
  customerId: string;
1040
1033
  deliveryStatus: ErrandStatus;
1041
- invoice: {
1042
- invoiceStatus: string;
1043
- refId: string;
1044
- transactionId: string;
1045
- };
1046
1034
  nameOfItem: string;
1047
1035
  pickupDetails: {
1048
1036
  cityId: string;
@@ -1826,6 +1814,97 @@ interface PortalHandleAvailability {
1826
1814
  reason?: string;
1827
1815
  }
1828
1816
 
1817
+ /**
1818
+ * Platform-wide suggestions for businesses that haven't set their own values.
1819
+ * Prefill forms only — e.g. `business.settings.fuel?.revenuePercent ??
1820
+ * platform.fuel.revenuePercent`. Never applied to a business's calculations.
1821
+ */
1822
+ interface PlatformSettings {
1823
+ fuel: {
1824
+ /** Current pump price per litre, for prefilling refuel logs. */
1825
+ pumpPrice: number | null;
1826
+ revenuePercent: number | null;
1827
+ };
1828
+ riderPay: {
1829
+ defaultPercentage: number | null;
1830
+ };
1831
+ createdAt: string;
1832
+ updatedAt: string;
1833
+ }
1834
+
1835
+ /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
1836
+ type GeoPoint = {
1837
+ type: 'Point';
1838
+ coordinates: [number, number];
1839
+ };
1840
+ /** Lynqone's device kind, synced on import. */
1841
+ type TrackerType = 'car' | 'bike';
1842
+ /** `unbound`: no longer in the connected lynqone account. */
1843
+ type TrackerStatus = 'active' | 'unbound';
1844
+ type MotionState = 'moving' | 'stopped';
1845
+ /**
1846
+ * A trimmed-down Traccar position kept as the tracker's latest fix. Carries the
1847
+ * scalar fields a GeoPoint can't — `speed`/`course` drive derived state
1848
+ * (moving vs. idle, heading), `fixTime` gauges staleness.
1849
+ */
1850
+ type TrackerPosition = {
1851
+ latitude: number;
1852
+ longitude: number;
1853
+ speed?: number;
1854
+ course?: number;
1855
+ accuracy?: number;
1856
+ valid?: boolean;
1857
+ /** Traccar's moving/stopped determination — steadier than speed alone. */
1858
+ motion?: boolean;
1859
+ /** Engine on/off, when the device reports it. */
1860
+ ignition?: boolean;
1861
+ /** ISO time the GPS computed the position — the truest "when". */
1862
+ fixTime?: string;
1863
+ /** ISO time from the device's own clock (drift/buffering signal). */
1864
+ deviceTime?: string;
1865
+ /** ISO time Traccar received the report — lags `fixTime` when buffered. */
1866
+ serverTime?: string;
1867
+ /** Traccar's free-form attributes bag, as sent. */
1868
+ attributes?: Record<string, unknown>;
1869
+ };
1870
+ /**
1871
+ * A GPS tracker from the business's lynqone account. Only the last position is
1872
+ * kept; history stays in lynqone.
1873
+ */
1874
+ type Tracker = {
1875
+ id: string;
1876
+ businessId: string;
1877
+ /** Lynqone's tracker uuid. */
1878
+ lynqoneTrackerId: string;
1879
+ /** Device id, for display and search. */
1880
+ uniqueIdentifier: string;
1881
+ name?: string;
1882
+ type?: TrackerType;
1883
+ /** Unset means unassigned. A vehicle has at most one tracker. */
1884
+ vehicleId?: string;
1885
+ location?: GeoPoint;
1886
+ lastPosition?: TrackerPosition;
1887
+ lastSeenAt?: string;
1888
+ motionState?: MotionState;
1889
+ motionChangedAt?: string;
1890
+ batteryLevel?: number;
1891
+ lowBatteryAt?: string;
1892
+ status: TrackerStatus;
1893
+ createdAt: string;
1894
+ updatedAt: string;
1895
+ };
1896
+
1897
+ type IntegrationProvider = 'lynqone';
1898
+ type IntegrationStatus = 'connected' | 'disconnected' | 'error';
1899
+ /** What `GET /integrations/lynqone` returns. The key itself is never sent. */
1900
+ type LynqoneIntegrationSummary = {
1901
+ status: IntegrationStatus;
1902
+ connectedAt?: string;
1903
+ disconnectedAt?: string;
1904
+ lastError?: string;
1905
+ trackerCount: number;
1906
+ };
1907
+
1829
1908
  interface PaginateResult<T> {
1830
1909
  docs: T[];
1831
1910
  totalDocs: number;
@@ -1848,4 +1927,4 @@ declare enum LinkDestination {
1848
1927
  }
1849
1928
  type NullOrUndefined = null | undefined;
1850
1929
 
1851
- export { type AddonGroup, type AddonGroupItem, type AddressDetails, AddressTypes, type AggregatedErrand, AuthType, type Business, BusinessCapability, type BusinessCategory, type BusinessCourierLink, BusinessCourierLinkStatus, type BusinessFuelSettings, 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 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 Invoice, type InvoiceDrift, type InvoiceEvent, InvoiceEventType, InvoiceGenerationType, type InvoiceItem, InvoiceItemType, type InvoicePayment, InvoicePaymentMethod, InvoiceStatus, type LatLng, LinkDestination, type MaintenanceItem, type MaintenancePartUsage, type MaintenanceRecord, type MaintenanceStats, type MaintenanceStatsSummary, type MaintenanceTopItem, MembershipStatus, type ModuleState, type Notification, type NotificationData, NotificationType, type NullOrUndefined, type OpeningHours, type PaginateResult, PaymentOptions, PayoutPeriodType, PayoutRateSource, type PendingErrand, 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 TrackerPosition, 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 };
1930
+ 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 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 };
package/dist/index.js CHANGED
@@ -115,6 +115,7 @@ var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus2) => {
115
115
  })(InvoiceStatus || {});
116
116
  var InvoiceItemType = /* @__PURE__ */ ((InvoiceItemType2) => {
117
117
  InvoiceItemType2["Errand"] = "errand";
118
+ InvoiceItemType2["Manual"] = "manual";
118
119
  return InvoiceItemType2;
119
120
  })(InvoiceItemType || {});
120
121
  var InvoiceGenerationType = /* @__PURE__ */ ((InvoiceGenerationType2) => {
@@ -144,6 +145,7 @@ var InvoiceEventType = /* @__PURE__ */ ((InvoiceEventType2) => {
144
145
  InvoiceEventType2["LineAmountChanged"] = "line_amount_changed";
145
146
  InvoiceEventType2["PaymentRecorded"] = "payment_recorded";
146
147
  InvoiceEventType2["PaymentReversed"] = "payment_reversed";
148
+ InvoiceEventType2["PaymentUpdated"] = "payment_updated";
147
149
  InvoiceEventType2["StatusChanged"] = "status_changed";
148
150
  InvoiceEventType2["Viewed"] = "viewed";
149
151
  return InvoiceEventType2;
@@ -234,10 +236,15 @@ var BusinessType = /* @__PURE__ */ ((BusinessType2) => {
234
236
  })(BusinessType || {});
235
237
  var BusinessPlan = /* @__PURE__ */ ((BusinessPlan2) => {
236
238
  BusinessPlan2["NONE"] = "none";
239
+ BusinessPlan2["STARTER"] = "starter";
240
+ BusinessPlan2["GROWTH"] = "growth";
241
+ BusinessPlan2["SCALE"] = "scale";
237
242
  BusinessPlan2["FULL"] = "full";
238
243
  BusinessPlan2["INTERNAL"] = "internal";
239
244
  return BusinessPlan2;
240
245
  })(BusinessPlan || {});
246
+ var PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
247
+ var PLAN_REQUIRED = "PLAN_REQUIRED";
241
248
  var BusinessStatus = /* @__PURE__ */ ((BusinessStatus2) => {
242
249
  BusinessStatus2["ACTIVE"] = "active";
243
250
  BusinessStatus2["DISABLED"] = "disabled";
@@ -253,7 +260,7 @@ var BusinessRole = /* @__PURE__ */ ((BusinessRole2) => {
253
260
  var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
254
261
  MembershipStatus2["ACTIVE"] = "ACTIVE";
255
262
  MembershipStatus2["PENDING_ACTIVATION"] = "PENDING_ACTIVATION";
256
- MembershipStatus2["SUSPENDED"] = "SUSPENDED";
263
+ MembershipStatus2["DISABLED"] = "DISABLED";
257
264
  return MembershipStatus2;
258
265
  })(MembershipStatus || {});
259
266
  var DEFAULT_BUSINESS_FUEL_SETTINGS = {
@@ -387,6 +394,8 @@ export {
387
394
  LinkDestination,
388
395
  MembershipStatus,
389
396
  NotificationType,
397
+ PLAN_LIMIT_REACHED,
398
+ PLAN_REQUIRED,
390
399
  PaymentOptions,
391
400
  PayoutPeriodType,
392
401
  PayoutRateSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "2.1.3",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/business.ts CHANGED
@@ -22,7 +22,6 @@ export enum BusinessCapability {
22
22
  SELF_FULFILLMENT = 'self_fulfillment',
23
23
  }
24
24
 
25
-
26
25
  /**
27
26
  * Who carried an errand: the originating business's own rider, or the wider
28
27
  * network. The field rider-cost reporting splits on — own-rider cost against
@@ -65,10 +64,29 @@ export enum BusinessPlan {
65
64
  * without deleting anything. For a hard cut-off use `BusinessStatus`.
66
65
  */
67
66
  NONE = 'none',
67
+ /** Paid tiers: same modules, different rider caps. */
68
+ STARTER = 'starter',
69
+ GROWTH = 'growth',
70
+ SCALE = 'scale',
71
+ /** Pre-pricing businesses, grandfathered: no caps. */
68
72
  FULL = 'full',
69
73
  INTERNAL = 'internal',
70
74
  }
71
75
 
76
+ /**
77
+ * Plan caps. `null` is unlimited. `riders` counts every rider not archived,
78
+ * suspended ones included.
79
+ */
80
+ export interface BusinessLimits {
81
+ riders: number | null;
82
+ }
83
+
84
+ /** 403 code: adding past a plan cap. */
85
+ export const PLAN_LIMIT_REACHED = 'PLAN_LIMIT_REACHED';
86
+
87
+ /** 403 code: creating anything with no active plan (trial over, unpaid). */
88
+ export const PLAN_REQUIRED = 'PLAN_REQUIRED';
89
+
72
90
  /**
73
91
  * What a module looks like to one business.
74
92
  *
@@ -86,10 +104,7 @@ export enum BusinessPlan {
86
104
  */
87
105
  export type ModuleState = 'available' | 'locked' | 'hidden';
88
106
 
89
- export type BusinessModuleStates = Record<
90
- keyof BusinessModules,
91
- ModuleState
92
- >;
107
+ export type BusinessModuleStates = Record<keyof BusinessModules, ModuleState>;
93
108
 
94
109
  export enum BusinessStatus {
95
110
  ACTIVE = 'active',
@@ -104,6 +119,11 @@ export interface Business {
104
119
  officeNumber: string;
105
120
  type: BusinessType | `${BusinessType}`;
106
121
  plan: BusinessPlan | `${BusinessPlan}`;
122
+ /** Trial plan, in force until `trialEndsAt`. Kept after it ends. */
123
+ trialPlan: BusinessPlan | `${BusinessPlan}` | NullOrUndefined;
124
+ trialEndsAt: string | Date | NullOrUndefined;
125
+ /** The plan in force (trial included). Show this, not `plan`. */
126
+ effectivePlan: BusinessPlan | `${BusinessPlan}`;
107
127
  categoryId: string;
108
128
  address: string | NullOrUndefined;
109
129
  addressCoordinates:
@@ -169,6 +189,9 @@ export interface Business {
169
189
  * learns the feature exists.
170
190
  */
171
191
  moduleStates: BusinessModuleStates;
192
+
193
+ /** Caps from `effectivePlan`. */
194
+ limits: BusinessLimits;
172
195
  }
173
196
 
174
197
  export interface BusinessPg extends Business {
@@ -204,7 +227,7 @@ export enum BusinessRole {
204
227
  export enum MembershipStatus {
205
228
  ACTIVE = 'ACTIVE',
206
229
  PENDING_ACTIVATION = 'PENDING_ACTIVATION',
207
- SUSPENDED = 'SUSPENDED',
230
+ DISABLED = 'DISABLED',
208
231
  }
209
232
 
210
233
  export interface OpeningHours {
@@ -352,6 +375,9 @@ export interface BusinessMember {
352
375
  pgId: string;
353
376
  role: BusinessRole | `${BusinessRole}`;
354
377
  status: MembershipStatus | `${MembershipStatus}`;
378
+ disabledAt: string | NullOrUndefined;
379
+ disabledBy: string | NullOrUndefined;
380
+ disabledReason: string | NullOrUndefined;
355
381
  invitedBy: string | NullOrUndefined;
356
382
  userDetails: User | NullOrUndefined;
357
383
  invitedByUserDetails: User | NullOrUndefined;
package/src/errand.ts CHANGED
@@ -63,11 +63,6 @@ export interface PendingErrand {
63
63
  rider: string;
64
64
  customerId: string;
65
65
  deliveryStatus: ErrandStatus;
66
- invoice: {
67
- invoiceStatus: string;
68
- refId: string;
69
- transactionId: string;
70
- };
71
66
  nameOfItem: string;
72
67
  pickupDetails: {
73
68
  cityId: string;
package/src/index.ts CHANGED
@@ -38,3 +38,6 @@ export * from './stat';
38
38
  export * from './maintenance';
39
39
  export * from './whatsapp';
40
40
  export * from './portal';
41
+ export * from './platform';
42
+ export * from './tracker';
43
+ export * from './integration';
@@ -0,0 +1,12 @@
1
+ export type IntegrationProvider = 'lynqone';
2
+
3
+ export type IntegrationStatus = 'connected' | 'disconnected' | 'error';
4
+
5
+ /** What `GET /integrations/lynqone` returns. The key itself is never sent. */
6
+ export type LynqoneIntegrationSummary = {
7
+ status: IntegrationStatus;
8
+ connectedAt?: string;
9
+ disconnectedAt?: string;
10
+ lastError?: string;
11
+ trackerCount: number;
12
+ };
package/src/invoice.ts CHANGED
@@ -11,7 +11,8 @@ export enum InvoiceStatus {
11
11
 
12
12
  export enum InvoiceItemType {
13
13
  Errand = 'errand',
14
- // Future item types can be added here
14
+ // Added by hand; no errand behind it. A negative amount is a credit.
15
+ Manual = 'manual',
15
16
  }
16
17
 
17
18
  export enum InvoiceGenerationType {
@@ -41,6 +42,7 @@ export enum InvoiceEventType {
41
42
  LineAmountChanged = 'line_amount_changed',
42
43
  PaymentRecorded = 'payment_recorded',
43
44
  PaymentReversed = 'payment_reversed',
45
+ PaymentUpdated = 'payment_updated',
44
46
  StatusChanged = 'status_changed',
45
47
  Viewed = 'viewed',
46
48
  }
@@ -0,0 +1,17 @@
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/rider.ts CHANGED
@@ -36,7 +36,6 @@ export type Rider = {
36
36
  // vehicle: string | Vehicle;
37
37
  vehicleNumber?: string;
38
38
  verified: boolean;
39
- active: boolean;
40
39
  updatedAt: Date;
41
40
  createdAt: Date;
42
41
  rating: number;
package/src/tracker.ts ADDED
@@ -0,0 +1,66 @@
1
+ /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
2
+ export type GeoPoint = {
3
+ type: 'Point';
4
+ coordinates: [number, number];
5
+ };
6
+
7
+ /** Lynqone's device kind, synced on import. */
8
+ export type TrackerType = 'car' | 'bike';
9
+
10
+ /** `unbound`: no longer in the connected lynqone account. */
11
+ export type TrackerStatus = 'active' | 'unbound';
12
+
13
+ export type MotionState = 'moving' | 'stopped';
14
+
15
+ /**
16
+ * A trimmed-down Traccar position kept as the tracker's latest fix. Carries the
17
+ * scalar fields a GeoPoint can't — `speed`/`course` drive derived state
18
+ * (moving vs. idle, heading), `fixTime` gauges staleness.
19
+ */
20
+ export type TrackerPosition = {
21
+ latitude: number;
22
+ longitude: number;
23
+ speed?: number;
24
+ course?: number;
25
+ accuracy?: number;
26
+ valid?: boolean;
27
+ /** Traccar's moving/stopped determination — steadier than speed alone. */
28
+ motion?: boolean;
29
+ /** Engine on/off, when the device reports it. */
30
+ ignition?: boolean;
31
+ /** ISO time the GPS computed the position — the truest "when". */
32
+ fixTime?: string;
33
+ /** ISO time from the device's own clock (drift/buffering signal). */
34
+ deviceTime?: string;
35
+ /** ISO time Traccar received the report — lags `fixTime` when buffered. */
36
+ serverTime?: string;
37
+ /** Traccar's free-form attributes bag, as sent. */
38
+ attributes?: Record<string, unknown>;
39
+ };
40
+
41
+ /**
42
+ * A GPS tracker from the business's lynqone account. Only the last position is
43
+ * kept; history stays in lynqone.
44
+ */
45
+ export type Tracker = {
46
+ id: string;
47
+ businessId: string;
48
+ /** Lynqone's tracker uuid. */
49
+ lynqoneTrackerId: string;
50
+ /** Device id, for display and search. */
51
+ uniqueIdentifier: string;
52
+ name?: string;
53
+ type?: TrackerType;
54
+ /** Unset means unassigned. A vehicle has at most one tracker. */
55
+ vehicleId?: string;
56
+ location?: GeoPoint;
57
+ lastPosition?: TrackerPosition;
58
+ lastSeenAt?: string;
59
+ motionState?: MotionState;
60
+ motionChangedAt?: string;
61
+ batteryLevel?: number;
62
+ lowBatteryAt?: string;
63
+ status: TrackerStatus;
64
+ createdAt: string;
65
+ updatedAt: string;
66
+ };
package/src/vehicle.ts CHANGED
@@ -1,41 +1,11 @@
1
1
  import { Errand } from './errand';
2
- import { RiderWithUserDetails } from './rider';
2
+ import { Rider } from './rider';
3
3
 
4
4
  export enum VehicleType {
5
5
  Bike = 'bike',
6
6
  Shuttle = 'shuttle',
7
7
  }
8
8
 
9
- /** GeoJSON Point. `coordinates` is `[longitude, latitude]`. */
10
- export type GeoPoint = {
11
- type: 'Point';
12
- coordinates: [number, number];
13
- };
14
-
15
- /**
16
- * A trimmed-down Traccar position kept as the vehicle's latest fix. Carries the
17
- * scalar fields a GeoPoint can't — `speed`/`course` drive derived state
18
- * (moving vs. idle, heading), `recordedAt` gauges staleness.
19
- */
20
- export type TrackerPosition = {
21
- latitude: number;
22
- longitude: number;
23
- speed?: number;
24
- course?: number;
25
- accuracy?: number;
26
- valid?: boolean;
27
- /** Traccar's moving/stopped determination — steadier than speed alone. */
28
- motion?: boolean;
29
- /** Engine on/off, when the device reports it. */
30
- ignition?: boolean;
31
- /** ISO time the GPS computed the position — the truest "when". */
32
- fixTime?: string;
33
- /** ISO time from the device's own clock (drift/buffering signal). */
34
- deviceTime?: string;
35
- /** ISO time Traccar received the report — lags `fixTime` when buffered. */
36
- serverTime?: string;
37
- };
38
-
39
9
  export type Vehicle = {
40
10
  id: string;
41
11
  vehicleNumber: string;
@@ -47,16 +17,10 @@ export type Vehicle = {
47
17
 
48
18
  shortName?: string;
49
19
  userId?: string;
50
- /** External GPS device uniqueId bound to this vehicle. */
51
- trackerId?: string;
52
- /** Latest known tracker position, as a GeoPoint for proximity queries. */
53
- location?: GeoPoint;
54
- /** Latest tracker fix with richer scalar fields (speed, course, …). */
55
- position?: TrackerPosition;
56
20
  };
57
21
 
58
22
  export type VehicleWithRider = Vehicle & {
59
- riders: RiderWithUserDetails[];
23
+ riders: Rider[];
60
24
  };
61
25
 
62
26
  export enum VehicleLogType {