@mydoormot/app-types 2.1.2 → 2.1.4

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.1 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.94 KB
12
- ESM ⚡️ Build success in 161ms
13
- CJS dist/index.cjs 17.98 KB
14
- CJS ⚡️ Build success in 171ms
15
- DTS Build start
16
- DTS ⚡️ Build success in 737ms
17
- DTS dist/index.d.ts 56.99 KB
18
- DTS dist/index.d.cts 56.99 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
+ ESM dist/index.js 15.04 KB
12
+ ESM ⚡️ Build success in 82ms
13
+ CJS dist/index.cjs 18.11 KB
14
+ CJS ⚡️ Build success in 83ms
15
+ DTS Build start
16
+ DTS ⚡️ Build success in 1467ms
17
+ DTS dist/index.d.ts 56.90 KB
18
+ DTS dist/index.d.cts 56.90 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 2.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated plan
8
+
9
+ ## 2.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated business settings
14
+
3
15
  ## 2.1.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -29,7 +29,6 @@ __export(src_exports, {
29
29
  BusinessStatus: () => BusinessStatus,
30
30
  BusinessType: () => BusinessType,
31
31
  DEFAULT_BUSINESS_FUEL_SETTINGS: () => DEFAULT_BUSINESS_FUEL_SETTINGS,
32
- DEFAULT_BUSINESS_MODULES: () => DEFAULT_BUSINESS_MODULES,
33
32
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: () => DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
34
33
  DEFAULT_BUSINESS_SETTINGS: () => DEFAULT_BUSINESS_SETTINGS,
35
34
  DeliveryStatus: () => DeliveryStatus,
@@ -50,6 +49,8 @@ __export(src_exports, {
50
49
  LinkDestination: () => LinkDestination,
51
50
  MembershipStatus: () => MembershipStatus,
52
51
  NotificationType: () => NotificationType,
52
+ PLAN_LIMIT_REACHED: () => PLAN_LIMIT_REACHED,
53
+ PLAN_REQUIRED: () => PLAN_REQUIRED,
53
54
  PaymentOptions: () => PaymentOptions,
54
55
  PayoutPeriodType: () => PayoutPeriodType,
55
56
  PayoutRateSource: () => PayoutRateSource,
@@ -306,11 +307,15 @@ var BusinessType = /* @__PURE__ */ ((BusinessType2) => {
306
307
  })(BusinessType || {});
307
308
  var BusinessPlan = /* @__PURE__ */ ((BusinessPlan2) => {
308
309
  BusinessPlan2["NONE"] = "none";
309
- BusinessPlan2["MVP"] = "mvp";
310
+ BusinessPlan2["STARTER"] = "starter";
311
+ BusinessPlan2["GROWTH"] = "growth";
312
+ BusinessPlan2["SCALE"] = "scale";
310
313
  BusinessPlan2["FULL"] = "full";
311
314
  BusinessPlan2["INTERNAL"] = "internal";
312
315
  return BusinessPlan2;
313
316
  })(BusinessPlan || {});
317
+ var PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
318
+ var PLAN_REQUIRED = "PLAN_REQUIRED";
314
319
  var BusinessStatus = /* @__PURE__ */ ((BusinessStatus2) => {
315
320
  BusinessStatus2["ACTIVE"] = "active";
316
321
  BusinessStatus2["DISABLED"] = "disabled";
@@ -336,7 +341,6 @@ var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
336
341
  defaultPercentage: null,
337
342
  periodType: null
338
343
  };
339
- var DEFAULT_BUSINESS_MODULES = {};
340
344
  var DEFAULT_BUSINESS_SETTINGS = {
341
345
  whatsappNotificationEnabled: true,
342
346
  whatsapp: {
@@ -360,7 +364,6 @@ var DEFAULT_BUSINESS_SETTINGS = {
360
364
  tiktok: null,
361
365
  website: null
362
366
  },
363
- modules: DEFAULT_BUSINESS_MODULES,
364
367
  fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
365
368
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
366
369
  };
@@ -443,7 +446,6 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
443
446
  BusinessStatus,
444
447
  BusinessType,
445
448
  DEFAULT_BUSINESS_FUEL_SETTINGS,
446
- DEFAULT_BUSINESS_MODULES,
447
449
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
448
450
  DEFAULT_BUSINESS_SETTINGS,
449
451
  DeliveryStatus,
@@ -464,6 +466,8 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
464
466
  LinkDestination,
465
467
  MembershipStatus,
466
468
  NotificationType,
469
+ PLAN_LIMIT_REACHED,
470
+ PLAN_REQUIRED,
467
471
  PaymentOptions,
468
472
  PayoutPeriodType,
469
473
  PayoutRateSource,
package/dist/index.d.cts CHANGED
@@ -362,15 +362,28 @@ declare enum BusinessPlan {
362
362
  * No tier at all — every module falls to its default of off.
363
363
  *
364
364
  * For a business that has bought nothing, or whose access is being pulled
365
- * without deleting anything. Per-business overrides in `settings.modules`
366
- * still apply on top: an override is a deliberate grant, and a plan change
367
- * must not silently revoke one. For a hard cut-off use `BusinessStatus`.
365
+ * without deleting anything. For a hard cut-off use `BusinessStatus`.
368
366
  */
369
367
  NONE = "none",
370
- MVP = "mvp",
368
+ /** Paid tiers: same modules, different rider caps. */
369
+ STARTER = "starter",
370
+ GROWTH = "growth",
371
+ SCALE = "scale",
372
+ /** Pre-pricing businesses, grandfathered: no caps. */
371
373
  FULL = "full",
372
374
  INTERNAL = "internal"
373
375
  }
376
+ /**
377
+ * Plan caps. `null` is unlimited. `riders` counts every rider not archived,
378
+ * suspended ones included.
379
+ */
380
+ interface BusinessLimits {
381
+ riders: number | null;
382
+ }
383
+ /** 403 code: adding past a plan cap. */
384
+ declare const PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
385
+ /** 403 code: creating anything with no active plan (trial over, unpaid). */
386
+ declare const PLAN_REQUIRED = "PLAN_REQUIRED";
374
387
  /**
375
388
  * What a module looks like to one business.
376
389
  *
@@ -400,6 +413,11 @@ interface Business {
400
413
  officeNumber: string;
401
414
  type: BusinessType | `${BusinessType}`;
402
415
  plan: BusinessPlan | `${BusinessPlan}`;
416
+ /** Trial plan, in force until `trialEndsAt`. Kept after it ends. */
417
+ trialPlan: BusinessPlan | `${BusinessPlan}` | NullOrUndefined;
418
+ trialEndsAt: string | Date | NullOrUndefined;
419
+ /** The plan in force (trial included). Show this, not `plan`. */
420
+ effectivePlan: BusinessPlan | `${BusinessPlan}`;
403
421
  categoryId: string;
404
422
  address: string | NullOrUndefined;
405
423
  addressCoordinates: number[] | NullOrUndefined | {
@@ -442,9 +460,8 @@ interface Business {
442
460
  disabledReason: string | NullOrUndefined;
443
461
  settings: BusinessSettings | NullOrUndefined;
444
462
  /**
445
- * The resolved feature set — the plan's defaults with this business's own
446
- * overrides applied. Server-computed; read this, never `settings.modules`,
447
- * which holds only the deliberate exceptions.
463
+ * Which features this business has, from its `type` and `plan`.
464
+ * Server-computed, so no client has to know the plan map.
448
465
  */
449
466
  modules: Required<{
450
467
  [K in keyof BusinessModules]: boolean;
@@ -456,6 +473,8 @@ interface Business {
456
473
  * learns the feature exists.
457
474
  */
458
475
  moduleStates: BusinessModuleStates;
476
+ /** Caps from `effectivePlan`. */
477
+ limits: BusinessLimits;
459
478
  }
460
479
  interface BusinessPg extends Business {
461
480
  pgId: any;
@@ -493,15 +512,9 @@ interface OpeningHours {
493
512
  /**
494
513
  * Which features a business sees.
495
514
  *
496
- * Every value is optional, and `undefined` means *inherit from the plan* — not
497
- * `false`. That distinction is the whole point: a stored `true` is a decision
498
- * somebody made, so the plan can never quietly take it back, while an unset key
499
- * follows whatever the plan says today. Storing a resolved default would
500
- * collapse the two and freeze every business on the defaults it was created
501
- * with.
502
- *
503
- * Resolve with `modulesForPlan(type, plan)[key] ?? ...` — never read a key off
504
- * this object directly.
515
+ * Purely a function of its `type` and `plan` — there is no per-business
516
+ * override layer. A business needing something its plan does not include moves
517
+ * plan; there is no third place to look.
505
518
  */
506
519
  interface BusinessModules {
507
520
  draftErrands?: boolean;
@@ -585,22 +598,11 @@ interface BusinessSettings {
585
598
  tiktok: string | null;
586
599
  website: string | null;
587
600
  };
588
- modules: BusinessModules;
589
601
  fuel?: BusinessFuelSettings;
590
602
  riderPay?: BusinessRiderPaySettings;
591
603
  }
592
604
  declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
593
605
  declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
594
- /**
595
- * @deprecated Defaults live in `modulesForPlan(type, plan)` on the server. This
596
- * was an all-`true` deny-list: every new feature shipped to every business
597
- * until someone remembered to switch it off, and writing it into each new
598
- * business made the stored value indistinguishable from a deliberate grant.
599
- *
600
- * Kept only so nothing importing it breaks mid-migration. Empty on purpose —
601
- * unset means inherit.
602
- */
603
- declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
604
606
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
605
607
  interface BusinessMember {
606
608
  id: string;
@@ -1869,4 +1871,4 @@ declare enum LinkDestination {
1869
1871
  }
1870
1872
  type NullOrUndefined = null | undefined;
1871
1873
 
1872
- 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_MODULES, 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 };
1874
+ 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 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, PLAN_LIMIT_REACHED, PLAN_REQUIRED, 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 };
package/dist/index.d.ts CHANGED
@@ -362,15 +362,28 @@ declare enum BusinessPlan {
362
362
  * No tier at all — every module falls to its default of off.
363
363
  *
364
364
  * For a business that has bought nothing, or whose access is being pulled
365
- * without deleting anything. Per-business overrides in `settings.modules`
366
- * still apply on top: an override is a deliberate grant, and a plan change
367
- * must not silently revoke one. For a hard cut-off use `BusinessStatus`.
365
+ * without deleting anything. For a hard cut-off use `BusinessStatus`.
368
366
  */
369
367
  NONE = "none",
370
- MVP = "mvp",
368
+ /** Paid tiers: same modules, different rider caps. */
369
+ STARTER = "starter",
370
+ GROWTH = "growth",
371
+ SCALE = "scale",
372
+ /** Pre-pricing businesses, grandfathered: no caps. */
371
373
  FULL = "full",
372
374
  INTERNAL = "internal"
373
375
  }
376
+ /**
377
+ * Plan caps. `null` is unlimited. `riders` counts every rider not archived,
378
+ * suspended ones included.
379
+ */
380
+ interface BusinessLimits {
381
+ riders: number | null;
382
+ }
383
+ /** 403 code: adding past a plan cap. */
384
+ declare const PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
385
+ /** 403 code: creating anything with no active plan (trial over, unpaid). */
386
+ declare const PLAN_REQUIRED = "PLAN_REQUIRED";
374
387
  /**
375
388
  * What a module looks like to one business.
376
389
  *
@@ -400,6 +413,11 @@ interface Business {
400
413
  officeNumber: string;
401
414
  type: BusinessType | `${BusinessType}`;
402
415
  plan: BusinessPlan | `${BusinessPlan}`;
416
+ /** Trial plan, in force until `trialEndsAt`. Kept after it ends. */
417
+ trialPlan: BusinessPlan | `${BusinessPlan}` | NullOrUndefined;
418
+ trialEndsAt: string | Date | NullOrUndefined;
419
+ /** The plan in force (trial included). Show this, not `plan`. */
420
+ effectivePlan: BusinessPlan | `${BusinessPlan}`;
403
421
  categoryId: string;
404
422
  address: string | NullOrUndefined;
405
423
  addressCoordinates: number[] | NullOrUndefined | {
@@ -442,9 +460,8 @@ interface Business {
442
460
  disabledReason: string | NullOrUndefined;
443
461
  settings: BusinessSettings | NullOrUndefined;
444
462
  /**
445
- * The resolved feature set — the plan's defaults with this business's own
446
- * overrides applied. Server-computed; read this, never `settings.modules`,
447
- * which holds only the deliberate exceptions.
463
+ * Which features this business has, from its `type` and `plan`.
464
+ * Server-computed, so no client has to know the plan map.
448
465
  */
449
466
  modules: Required<{
450
467
  [K in keyof BusinessModules]: boolean;
@@ -456,6 +473,8 @@ interface Business {
456
473
  * learns the feature exists.
457
474
  */
458
475
  moduleStates: BusinessModuleStates;
476
+ /** Caps from `effectivePlan`. */
477
+ limits: BusinessLimits;
459
478
  }
460
479
  interface BusinessPg extends Business {
461
480
  pgId: any;
@@ -493,15 +512,9 @@ interface OpeningHours {
493
512
  /**
494
513
  * Which features a business sees.
495
514
  *
496
- * Every value is optional, and `undefined` means *inherit from the plan* — not
497
- * `false`. That distinction is the whole point: a stored `true` is a decision
498
- * somebody made, so the plan can never quietly take it back, while an unset key
499
- * follows whatever the plan says today. Storing a resolved default would
500
- * collapse the two and freeze every business on the defaults it was created
501
- * with.
502
- *
503
- * Resolve with `modulesForPlan(type, plan)[key] ?? ...` — never read a key off
504
- * this object directly.
515
+ * Purely a function of its `type` and `plan` — there is no per-business
516
+ * override layer. A business needing something its plan does not include moves
517
+ * plan; there is no third place to look.
505
518
  */
506
519
  interface BusinessModules {
507
520
  draftErrands?: boolean;
@@ -585,22 +598,11 @@ interface BusinessSettings {
585
598
  tiktok: string | null;
586
599
  website: string | null;
587
600
  };
588
- modules: BusinessModules;
589
601
  fuel?: BusinessFuelSettings;
590
602
  riderPay?: BusinessRiderPaySettings;
591
603
  }
592
604
  declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
593
605
  declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
594
- /**
595
- * @deprecated Defaults live in `modulesForPlan(type, plan)` on the server. This
596
- * was an all-`true` deny-list: every new feature shipped to every business
597
- * until someone remembered to switch it off, and writing it into each new
598
- * business made the stored value indistinguishable from a deliberate grant.
599
- *
600
- * Kept only so nothing importing it breaks mid-migration. Empty on purpose —
601
- * unset means inherit.
602
- */
603
- declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
604
606
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
605
607
  interface BusinessMember {
606
608
  id: string;
@@ -1869,4 +1871,4 @@ declare enum LinkDestination {
1869
1871
  }
1870
1872
  type NullOrUndefined = null | undefined;
1871
1873
 
1872
- 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_MODULES, 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 };
1874
+ 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 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, PLAN_LIMIT_REACHED, PLAN_REQUIRED, 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 };
package/dist/index.js CHANGED
@@ -234,11 +234,15 @@ var BusinessType = /* @__PURE__ */ ((BusinessType2) => {
234
234
  })(BusinessType || {});
235
235
  var BusinessPlan = /* @__PURE__ */ ((BusinessPlan2) => {
236
236
  BusinessPlan2["NONE"] = "none";
237
- BusinessPlan2["MVP"] = "mvp";
237
+ BusinessPlan2["STARTER"] = "starter";
238
+ BusinessPlan2["GROWTH"] = "growth";
239
+ BusinessPlan2["SCALE"] = "scale";
238
240
  BusinessPlan2["FULL"] = "full";
239
241
  BusinessPlan2["INTERNAL"] = "internal";
240
242
  return BusinessPlan2;
241
243
  })(BusinessPlan || {});
244
+ var PLAN_LIMIT_REACHED = "PLAN_LIMIT_REACHED";
245
+ var PLAN_REQUIRED = "PLAN_REQUIRED";
242
246
  var BusinessStatus = /* @__PURE__ */ ((BusinessStatus2) => {
243
247
  BusinessStatus2["ACTIVE"] = "active";
244
248
  BusinessStatus2["DISABLED"] = "disabled";
@@ -264,7 +268,6 @@ var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
264
268
  defaultPercentage: null,
265
269
  periodType: null
266
270
  };
267
- var DEFAULT_BUSINESS_MODULES = {};
268
271
  var DEFAULT_BUSINESS_SETTINGS = {
269
272
  whatsappNotificationEnabled: true,
270
273
  whatsapp: {
@@ -288,7 +291,6 @@ var DEFAULT_BUSINESS_SETTINGS = {
288
291
  tiktok: null,
289
292
  website: null
290
293
  },
291
- modules: DEFAULT_BUSINESS_MODULES,
292
294
  fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
293
295
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
294
296
  };
@@ -370,7 +372,6 @@ export {
370
372
  BusinessStatus,
371
373
  BusinessType,
372
374
  DEFAULT_BUSINESS_FUEL_SETTINGS,
373
- DEFAULT_BUSINESS_MODULES,
374
375
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
375
376
  DEFAULT_BUSINESS_SETTINGS,
376
377
  DeliveryStatus,
@@ -391,6 +392,8 @@ export {
391
392
  LinkDestination,
392
393
  MembershipStatus,
393
394
  NotificationType,
395
+ PLAN_LIMIT_REACHED,
396
+ PLAN_REQUIRED,
394
397
  PaymentOptions,
395
398
  PayoutPeriodType,
396
399
  PayoutRateSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
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
@@ -62,16 +61,32 @@ export enum BusinessPlan {
62
61
  * No tier at all — every module falls to its default of off.
63
62
  *
64
63
  * For a business that has bought nothing, or whose access is being pulled
65
- * without deleting anything. Per-business overrides in `settings.modules`
66
- * still apply on top: an override is a deliberate grant, and a plan change
67
- * must not silently revoke one. For a hard cut-off use `BusinessStatus`.
64
+ * without deleting anything. For a hard cut-off use `BusinessStatus`.
68
65
  */
69
66
  NONE = 'none',
70
- MVP = 'mvp',
67
+ /** Paid tiers: same modules, different rider caps. */
68
+ STARTER = 'starter',
69
+ GROWTH = 'growth',
70
+ SCALE = 'scale',
71
+ /** Pre-pricing businesses, grandfathered: no caps. */
71
72
  FULL = 'full',
72
73
  INTERNAL = 'internal',
73
74
  }
74
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
+
75
90
  /**
76
91
  * What a module looks like to one business.
77
92
  *
@@ -89,10 +104,7 @@ export enum BusinessPlan {
89
104
  */
90
105
  export type ModuleState = 'available' | 'locked' | 'hidden';
91
106
 
92
- export type BusinessModuleStates = Record<
93
- keyof BusinessModules,
94
- ModuleState
95
- >;
107
+ export type BusinessModuleStates = Record<keyof BusinessModules, ModuleState>;
96
108
 
97
109
  export enum BusinessStatus {
98
110
  ACTIVE = 'active',
@@ -107,6 +119,11 @@ export interface Business {
107
119
  officeNumber: string;
108
120
  type: BusinessType | `${BusinessType}`;
109
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}`;
110
127
  categoryId: string;
111
128
  address: string | NullOrUndefined;
112
129
  addressCoordinates:
@@ -160,9 +177,8 @@ export interface Business {
160
177
  settings: BusinessSettings | NullOrUndefined;
161
178
 
162
179
  /**
163
- * The resolved feature set — the plan's defaults with this business's own
164
- * overrides applied. Server-computed; read this, never `settings.modules`,
165
- * which holds only the deliberate exceptions.
180
+ * Which features this business has, from its `type` and `plan`.
181
+ * Server-computed, so no client has to know the plan map.
166
182
  */
167
183
  modules: Required<{ [K in keyof BusinessModules]: boolean }>;
168
184
 
@@ -173,6 +189,9 @@ export interface Business {
173
189
  * learns the feature exists.
174
190
  */
175
191
  moduleStates: BusinessModuleStates;
192
+
193
+ /** Caps from `effectivePlan`. */
194
+ limits: BusinessLimits;
176
195
  }
177
196
 
178
197
  export interface BusinessPg extends Business {
@@ -219,15 +238,9 @@ export interface OpeningHours {
219
238
  /**
220
239
  * Which features a business sees.
221
240
  *
222
- * Every value is optional, and `undefined` means *inherit from the plan* — not
223
- * `false`. That distinction is the whole point: a stored `true` is a decision
224
- * somebody made, so the plan can never quietly take it back, while an unset key
225
- * follows whatever the plan says today. Storing a resolved default would
226
- * collapse the two and freeze every business on the defaults it was created
227
- * with.
228
- *
229
- * Resolve with `modulesForPlan(type, plan)[key] ?? ...` — never read a key off
230
- * this object directly.
241
+ * Purely a function of its `type` and `plan` — there is no per-business
242
+ * override layer. A business needing something its plan does not include moves
243
+ * plan; there is no third place to look.
231
244
  */
232
245
  export interface BusinessModules {
233
246
  draftErrands?: boolean;
@@ -315,7 +328,6 @@ export interface BusinessSettings {
315
328
  tiktok: string | null;
316
329
  website: string | null;
317
330
  };
318
- modules: BusinessModules;
319
331
  fuel?: BusinessFuelSettings;
320
332
  riderPay?: BusinessRiderPaySettings;
321
333
  }
@@ -329,17 +341,6 @@ export const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings = {
329
341
  periodType: null,
330
342
  };
331
343
 
332
- /**
333
- * @deprecated Defaults live in `modulesForPlan(type, plan)` on the server. This
334
- * was an all-`true` deny-list: every new feature shipped to every business
335
- * until someone remembered to switch it off, and writing it into each new
336
- * business made the stored value indistinguishable from a deliberate grant.
337
- *
338
- * Kept only so nothing importing it breaks mid-migration. Empty on purpose —
339
- * unset means inherit.
340
- */
341
- export const DEFAULT_BUSINESS_MODULES: BusinessModules = {};
342
-
343
344
  export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
344
345
  whatsappNotificationEnabled: true,
345
346
  whatsapp: {
@@ -363,7 +364,6 @@ export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
363
364
  tiktok: null,
364
365
  website: null,
365
366
  },
366
- modules: DEFAULT_BUSINESS_MODULES,
367
367
  fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
368
368
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
369
369
  };