@mydoormot/app-types 2.1.1 → 2.1.3

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.1.0 build /Users/chuksben/Desktop/projects/microservices/mydoormot/packages/app-types
2
+ > @mydoormot/app-types@2.1.2 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 14.90 KB
12
- ESM ⚡️ Build success in 59ms
13
- CJS dist/index.cjs 17.95 KB
14
- CJS ⚡️ Build success in 59ms
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
15
  DTS Build start
16
- DTS ⚡️ Build success in 738ms
17
- DTS dist/index.d.ts 55.42 KB
18
- DTS dist/index.d.cts 55.42 KB
16
+ DTS ⚡️ Build success in 723ms
17
+ DTS dist/index.d.ts 55.91 KB
18
+ DTS dist/index.d.cts 55.91 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mydoormot/app-types
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated business settings
8
+
9
+ ## 2.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Aded moduleStates
14
+
3
15
  ## 2.1.1
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,
@@ -305,7 +304,7 @@ var BusinessType = /* @__PURE__ */ ((BusinessType2) => {
305
304
  return BusinessType2;
306
305
  })(BusinessType || {});
307
306
  var BusinessPlan = /* @__PURE__ */ ((BusinessPlan2) => {
308
- BusinessPlan2["MVP"] = "mvp";
307
+ BusinessPlan2["NONE"] = "none";
309
308
  BusinessPlan2["FULL"] = "full";
310
309
  BusinessPlan2["INTERNAL"] = "internal";
311
310
  return BusinessPlan2;
@@ -335,7 +334,6 @@ var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
335
334
  defaultPercentage: null,
336
335
  periodType: null
337
336
  };
338
- var DEFAULT_BUSINESS_MODULES = {};
339
337
  var DEFAULT_BUSINESS_SETTINGS = {
340
338
  whatsappNotificationEnabled: true,
341
339
  whatsapp: {
@@ -359,7 +357,6 @@ var DEFAULT_BUSINESS_SETTINGS = {
359
357
  tiktok: null,
360
358
  website: null
361
359
  },
362
- modules: DEFAULT_BUSINESS_MODULES,
363
360
  fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
364
361
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
365
362
  };
@@ -442,7 +439,6 @@ var LinkDestination = /* @__PURE__ */ ((LinkDestination2) => {
442
439
  BusinessStatus,
443
440
  BusinessType,
444
441
  DEFAULT_BUSINESS_FUEL_SETTINGS,
445
- DEFAULT_BUSINESS_MODULES,
446
442
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
447
443
  DEFAULT_BUSINESS_SETTINGS,
448
444
  DeliveryStatus,
package/dist/index.d.cts CHANGED
@@ -358,10 +358,33 @@ declare enum BusinessType {
358
358
  * reaches customers by someone forgetting to hide it.
359
359
  */
360
360
  declare enum BusinessPlan {
361
- MVP = "mvp",
361
+ /**
362
+ * No tier at all — every module falls to its default of off.
363
+ *
364
+ * For a business that has bought nothing, or whose access is being pulled
365
+ * without deleting anything. For a hard cut-off use `BusinessStatus`.
366
+ */
367
+ NONE = "none",
362
368
  FULL = "full",
363
369
  INTERNAL = "internal"
364
370
  }
371
+ /**
372
+ * What a module looks like to one business.
373
+ *
374
+ * The distinction `modules` alone cannot make. A boolean says only on or off,
375
+ * so a dashboard reading it hides everything that is off — including things
376
+ * the business could have, which is how a feature disappears instead of
377
+ * inviting an upgrade.
378
+ *
379
+ * - `available` — they have it.
380
+ * - `locked` — real for this kind of business, their tier does not include
381
+ * it. Show the screen, show the pitch. This is the upsell.
382
+ * - `hidden` — no tier for their type ever grants it. A restaurant is not
383
+ * a lapsed courier; offering to sell them client-invoicing is
384
+ * noise.
385
+ */
386
+ type ModuleState = 'available' | 'locked' | 'hidden';
387
+ type BusinessModuleStates = Record<keyof BusinessModules, ModuleState>;
365
388
  declare enum BusinessStatus {
366
389
  ACTIVE = "active",
367
390
  DISABLED = "disabled"
@@ -416,13 +439,19 @@ interface Business {
416
439
  disabledReason: string | NullOrUndefined;
417
440
  settings: BusinessSettings | NullOrUndefined;
418
441
  /**
419
- * The resolved feature set — the plan's defaults with this business's own
420
- * overrides applied. Server-computed; read this, never `settings.modules`,
421
- * which holds only the deliberate exceptions.
442
+ * Which features this business has, from its `type` and `plan`.
443
+ * Server-computed, so no client has to know the plan map.
422
444
  */
423
445
  modules: Required<{
424
446
  [K in keyof BusinessModules]: boolean;
425
447
  }>;
448
+ /**
449
+ * Per module: available, locked, or hidden. Render from this, not from
450
+ * `modules` — a boolean cannot tell "you don't have this yet" apart from
451
+ * "this isn't for you", and hiding the first kind is how a customer never
452
+ * learns the feature exists.
453
+ */
454
+ moduleStates: BusinessModuleStates;
426
455
  }
427
456
  interface BusinessPg extends Business {
428
457
  pgId: any;
@@ -460,15 +489,9 @@ interface OpeningHours {
460
489
  /**
461
490
  * Which features a business sees.
462
491
  *
463
- * Every value is optional, and `undefined` means *inherit from the plan* — not
464
- * `false`. That distinction is the whole point: a stored `true` is a decision
465
- * somebody made, so the plan can never quietly take it back, while an unset key
466
- * follows whatever the plan says today. Storing a resolved default would
467
- * collapse the two and freeze every business on the defaults it was created
468
- * with.
469
- *
470
- * Resolve with `modulesForPlan(type, plan)[key] ?? ...` — never read a key off
471
- * this object directly.
492
+ * Purely a function of its `type` and `plan` — there is no per-business
493
+ * override layer. A business needing something its plan does not include moves
494
+ * plan; there is no third place to look.
472
495
  */
473
496
  interface BusinessModules {
474
497
  draftErrands?: boolean;
@@ -552,22 +575,11 @@ interface BusinessSettings {
552
575
  tiktok: string | null;
553
576
  website: string | null;
554
577
  };
555
- modules: BusinessModules;
556
578
  fuel?: BusinessFuelSettings;
557
579
  riderPay?: BusinessRiderPaySettings;
558
580
  }
559
581
  declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
560
582
  declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
561
- /**
562
- * @deprecated Defaults live in `modulesForPlan(type, plan)` on the server. This
563
- * was an all-`true` deny-list: every new feature shipped to every business
564
- * until someone remembered to switch it off, and writing it into each new
565
- * business made the stored value indistinguishable from a deliberate grant.
566
- *
567
- * Kept only so nothing importing it breaks mid-migration. Empty on purpose —
568
- * unset means inherit.
569
- */
570
- declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
571
583
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
572
584
  interface BusinessMember {
573
585
  id: string;
@@ -1836,4 +1848,4 @@ declare enum LinkDestination {
1836
1848
  }
1837
1849
  type NullOrUndefined = null | undefined;
1838
1850
 
1839
- 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 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 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -358,10 +358,33 @@ declare enum BusinessType {
358
358
  * reaches customers by someone forgetting to hide it.
359
359
  */
360
360
  declare enum BusinessPlan {
361
- MVP = "mvp",
361
+ /**
362
+ * No tier at all — every module falls to its default of off.
363
+ *
364
+ * For a business that has bought nothing, or whose access is being pulled
365
+ * without deleting anything. For a hard cut-off use `BusinessStatus`.
366
+ */
367
+ NONE = "none",
362
368
  FULL = "full",
363
369
  INTERNAL = "internal"
364
370
  }
371
+ /**
372
+ * What a module looks like to one business.
373
+ *
374
+ * The distinction `modules` alone cannot make. A boolean says only on or off,
375
+ * so a dashboard reading it hides everything that is off — including things
376
+ * the business could have, which is how a feature disappears instead of
377
+ * inviting an upgrade.
378
+ *
379
+ * - `available` — they have it.
380
+ * - `locked` — real for this kind of business, their tier does not include
381
+ * it. Show the screen, show the pitch. This is the upsell.
382
+ * - `hidden` — no tier for their type ever grants it. A restaurant is not
383
+ * a lapsed courier; offering to sell them client-invoicing is
384
+ * noise.
385
+ */
386
+ type ModuleState = 'available' | 'locked' | 'hidden';
387
+ type BusinessModuleStates = Record<keyof BusinessModules, ModuleState>;
365
388
  declare enum BusinessStatus {
366
389
  ACTIVE = "active",
367
390
  DISABLED = "disabled"
@@ -416,13 +439,19 @@ interface Business {
416
439
  disabledReason: string | NullOrUndefined;
417
440
  settings: BusinessSettings | NullOrUndefined;
418
441
  /**
419
- * The resolved feature set — the plan's defaults with this business's own
420
- * overrides applied. Server-computed; read this, never `settings.modules`,
421
- * which holds only the deliberate exceptions.
442
+ * Which features this business has, from its `type` and `plan`.
443
+ * Server-computed, so no client has to know the plan map.
422
444
  */
423
445
  modules: Required<{
424
446
  [K in keyof BusinessModules]: boolean;
425
447
  }>;
448
+ /**
449
+ * Per module: available, locked, or hidden. Render from this, not from
450
+ * `modules` — a boolean cannot tell "you don't have this yet" apart from
451
+ * "this isn't for you", and hiding the first kind is how a customer never
452
+ * learns the feature exists.
453
+ */
454
+ moduleStates: BusinessModuleStates;
426
455
  }
427
456
  interface BusinessPg extends Business {
428
457
  pgId: any;
@@ -460,15 +489,9 @@ interface OpeningHours {
460
489
  /**
461
490
  * Which features a business sees.
462
491
  *
463
- * Every value is optional, and `undefined` means *inherit from the plan* — not
464
- * `false`. That distinction is the whole point: a stored `true` is a decision
465
- * somebody made, so the plan can never quietly take it back, while an unset key
466
- * follows whatever the plan says today. Storing a resolved default would
467
- * collapse the two and freeze every business on the defaults it was created
468
- * with.
469
- *
470
- * Resolve with `modulesForPlan(type, plan)[key] ?? ...` — never read a key off
471
- * this object directly.
492
+ * Purely a function of its `type` and `plan` — there is no per-business
493
+ * override layer. A business needing something its plan does not include moves
494
+ * plan; there is no third place to look.
472
495
  */
473
496
  interface BusinessModules {
474
497
  draftErrands?: boolean;
@@ -552,22 +575,11 @@ interface BusinessSettings {
552
575
  tiktok: string | null;
553
576
  website: string | null;
554
577
  };
555
- modules: BusinessModules;
556
578
  fuel?: BusinessFuelSettings;
557
579
  riderPay?: BusinessRiderPaySettings;
558
580
  }
559
581
  declare const DEFAULT_BUSINESS_FUEL_SETTINGS: BusinessFuelSettings;
560
582
  declare const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings;
561
- /**
562
- * @deprecated Defaults live in `modulesForPlan(type, plan)` on the server. This
563
- * was an all-`true` deny-list: every new feature shipped to every business
564
- * until someone remembered to switch it off, and writing it into each new
565
- * business made the stored value indistinguishable from a deliberate grant.
566
- *
567
- * Kept only so nothing importing it breaks mid-migration. Empty on purpose —
568
- * unset means inherit.
569
- */
570
- declare const DEFAULT_BUSINESS_MODULES: BusinessModules;
571
583
  declare const DEFAULT_BUSINESS_SETTINGS: BusinessSettings;
572
584
  interface BusinessMember {
573
585
  id: string;
@@ -1836,4 +1848,4 @@ declare enum LinkDestination {
1836
1848
  }
1837
1849
  type NullOrUndefined = null | undefined;
1838
1850
 
1839
- 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 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 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 };
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 };
package/dist/index.js CHANGED
@@ -233,7 +233,7 @@ var BusinessType = /* @__PURE__ */ ((BusinessType2) => {
233
233
  return BusinessType2;
234
234
  })(BusinessType || {});
235
235
  var BusinessPlan = /* @__PURE__ */ ((BusinessPlan2) => {
236
- BusinessPlan2["MVP"] = "mvp";
236
+ BusinessPlan2["NONE"] = "none";
237
237
  BusinessPlan2["FULL"] = "full";
238
238
  BusinessPlan2["INTERNAL"] = "internal";
239
239
  return BusinessPlan2;
@@ -263,7 +263,6 @@ var DEFAULT_BUSINESS_RIDER_PAY_SETTINGS = {
263
263
  defaultPercentage: null,
264
264
  periodType: null
265
265
  };
266
- var DEFAULT_BUSINESS_MODULES = {};
267
266
  var DEFAULT_BUSINESS_SETTINGS = {
268
267
  whatsappNotificationEnabled: true,
269
268
  whatsapp: {
@@ -287,7 +286,6 @@ var DEFAULT_BUSINESS_SETTINGS = {
287
286
  tiktok: null,
288
287
  website: null
289
288
  },
290
- modules: DEFAULT_BUSINESS_MODULES,
291
289
  fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
292
290
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS
293
291
  };
@@ -369,7 +367,6 @@ export {
369
367
  BusinessStatus,
370
368
  BusinessType,
371
369
  DEFAULT_BUSINESS_FUEL_SETTINGS,
372
- DEFAULT_BUSINESS_MODULES,
373
370
  DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
374
371
  DEFAULT_BUSINESS_SETTINGS,
375
372
  DeliveryStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mydoormot/app-types",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/business.ts CHANGED
@@ -58,11 +58,39 @@ export enum BusinessType {
58
58
  * reaches customers by someone forgetting to hide it.
59
59
  */
60
60
  export enum BusinessPlan {
61
- MVP = 'mvp',
61
+ /**
62
+ * No tier at all — every module falls to its default of off.
63
+ *
64
+ * For a business that has bought nothing, or whose access is being pulled
65
+ * without deleting anything. For a hard cut-off use `BusinessStatus`.
66
+ */
67
+ NONE = 'none',
62
68
  FULL = 'full',
63
69
  INTERNAL = 'internal',
64
70
  }
65
71
 
72
+ /**
73
+ * What a module looks like to one business.
74
+ *
75
+ * The distinction `modules` alone cannot make. A boolean says only on or off,
76
+ * so a dashboard reading it hides everything that is off — including things
77
+ * the business could have, which is how a feature disappears instead of
78
+ * inviting an upgrade.
79
+ *
80
+ * - `available` — they have it.
81
+ * - `locked` — real for this kind of business, their tier does not include
82
+ * it. Show the screen, show the pitch. This is the upsell.
83
+ * - `hidden` — no tier for their type ever grants it. A restaurant is not
84
+ * a lapsed courier; offering to sell them client-invoicing is
85
+ * noise.
86
+ */
87
+ export type ModuleState = 'available' | 'locked' | 'hidden';
88
+
89
+ export type BusinessModuleStates = Record<
90
+ keyof BusinessModules,
91
+ ModuleState
92
+ >;
93
+
66
94
  export enum BusinessStatus {
67
95
  ACTIVE = 'active',
68
96
  DISABLED = 'disabled',
@@ -129,11 +157,18 @@ export interface Business {
129
157
  settings: BusinessSettings | NullOrUndefined;
130
158
 
131
159
  /**
132
- * The resolved feature set — the plan's defaults with this business's own
133
- * overrides applied. Server-computed; read this, never `settings.modules`,
134
- * which holds only the deliberate exceptions.
160
+ * Which features this business has, from its `type` and `plan`.
161
+ * Server-computed, so no client has to know the plan map.
135
162
  */
136
163
  modules: Required<{ [K in keyof BusinessModules]: boolean }>;
164
+
165
+ /**
166
+ * Per module: available, locked, or hidden. Render from this, not from
167
+ * `modules` — a boolean cannot tell "you don't have this yet" apart from
168
+ * "this isn't for you", and hiding the first kind is how a customer never
169
+ * learns the feature exists.
170
+ */
171
+ moduleStates: BusinessModuleStates;
137
172
  }
138
173
 
139
174
  export interface BusinessPg extends Business {
@@ -180,15 +215,9 @@ export interface OpeningHours {
180
215
  /**
181
216
  * Which features a business sees.
182
217
  *
183
- * Every value is optional, and `undefined` means *inherit from the plan* — not
184
- * `false`. That distinction is the whole point: a stored `true` is a decision
185
- * somebody made, so the plan can never quietly take it back, while an unset key
186
- * follows whatever the plan says today. Storing a resolved default would
187
- * collapse the two and freeze every business on the defaults it was created
188
- * with.
189
- *
190
- * Resolve with `modulesForPlan(type, plan)[key] ?? ...` — never read a key off
191
- * this object directly.
218
+ * Purely a function of its `type` and `plan` — there is no per-business
219
+ * override layer. A business needing something its plan does not include moves
220
+ * plan; there is no third place to look.
192
221
  */
193
222
  export interface BusinessModules {
194
223
  draftErrands?: boolean;
@@ -276,7 +305,6 @@ export interface BusinessSettings {
276
305
  tiktok: string | null;
277
306
  website: string | null;
278
307
  };
279
- modules: BusinessModules;
280
308
  fuel?: BusinessFuelSettings;
281
309
  riderPay?: BusinessRiderPaySettings;
282
310
  }
@@ -290,17 +318,6 @@ export const DEFAULT_BUSINESS_RIDER_PAY_SETTINGS: BusinessRiderPaySettings = {
290
318
  periodType: null,
291
319
  };
292
320
 
293
- /**
294
- * @deprecated Defaults live in `modulesForPlan(type, plan)` on the server. This
295
- * was an all-`true` deny-list: every new feature shipped to every business
296
- * until someone remembered to switch it off, and writing it into each new
297
- * business made the stored value indistinguishable from a deliberate grant.
298
- *
299
- * Kept only so nothing importing it breaks mid-migration. Empty on purpose —
300
- * unset means inherit.
301
- */
302
- export const DEFAULT_BUSINESS_MODULES: BusinessModules = {};
303
-
304
321
  export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
305
322
  whatsappNotificationEnabled: true,
306
323
  whatsapp: {
@@ -324,7 +341,6 @@ export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
324
341
  tiktok: null,
325
342
  website: null,
326
343
  },
327
- modules: DEFAULT_BUSINESS_MODULES,
328
344
  fuel: DEFAULT_BUSINESS_FUEL_SETTINGS,
329
345
  riderPay: DEFAULT_BUSINESS_RIDER_PAY_SETTINGS,
330
346
  };