@abyss-project/main 2.0.0 → 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.
Files changed (147) hide show
  1. package/dist/api/billing-account.admin.api.d.ts +7 -2
  2. package/dist/api/billing-account.admin.api.js +13 -1
  3. package/dist/api/billing-account.admin.api.js.map +1 -1
  4. package/dist/api/organization-billing.api.d.ts +11 -0
  5. package/dist/api/organization-billing.api.js +17 -1
  6. package/dist/api/organization-billing.api.js.map +1 -1
  7. package/dist/api/organization-external-identity.api.d.ts +7 -0
  8. package/dist/api/organization-external-identity.api.js +25 -0
  9. package/dist/api/organization-external-identity.api.js.map +1 -0
  10. package/dist/api/organization-member.admin.api.d.ts +2 -1
  11. package/dist/api/organization-member.admin.api.js +5 -1
  12. package/dist/api/organization-member.admin.api.js.map +1 -1
  13. package/dist/api/user-billing.api.d.ts +9 -0
  14. package/dist/api/user-billing.api.js +17 -1
  15. package/dist/api/user-billing.api.js.map +1 -1
  16. package/dist/constants/billing-catalog.constants.js +2 -27
  17. package/dist/constants/billing-catalog.constants.js.map +1 -1
  18. package/dist/constants/catalog-plan-quotas.constants.d.ts +2 -0
  19. package/dist/constants/catalog-plan-quotas.constants.js +70 -13
  20. package/dist/constants/catalog-plan-quotas.constants.js.map +1 -1
  21. package/dist/constants/enforcement-registry.constants.js +18 -72
  22. package/dist/constants/enforcement-registry.constants.js.map +1 -1
  23. package/dist/constants/index.d.ts +1 -0
  24. package/dist/constants/index.js +1 -0
  25. package/dist/constants/index.js.map +1 -1
  26. package/dist/constants/metric-price-scale.constants.d.ts +1 -0
  27. package/dist/constants/metric-price-scale.constants.js +12 -1
  28. package/dist/constants/metric-price-scale.constants.js.map +1 -1
  29. package/dist/constants/module-catalog.constants.d.ts +65 -0
  30. package/dist/constants/module-catalog.constants.js +336 -0
  31. package/dist/constants/module-catalog.constants.js.map +1 -0
  32. package/dist/constants/overage-base-rates.constants.js +1 -0
  33. package/dist/constants/overage-base-rates.constants.js.map +1 -1
  34. package/dist/constants/public-plans.constants.js +48 -84
  35. package/dist/constants/public-plans.constants.js.map +1 -1
  36. package/dist/constants/quota-metric-kind.constants.d.ts +2 -0
  37. package/dist/constants/quota-metric-kind.constants.js +12 -9
  38. package/dist/constants/quota-metric-kind.constants.js.map +1 -1
  39. package/dist/index.d.ts +20 -0
  40. package/dist/index.js +20 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/translate/en.translate.d.ts +24 -0
  43. package/dist/translate/en.translate.js +24 -0
  44. package/dist/translate/en.translate.js.map +1 -1
  45. package/dist/translate/fr.translate.d.ts +24 -0
  46. package/dist/translate/fr.translate.js +24 -0
  47. package/dist/translate/fr.translate.js.map +1 -1
  48. package/dist/types/enum/abyss-application-event.enum.d.ts +6 -0
  49. package/dist/types/enum/abyss-application-event.enum.js +6 -0
  50. package/dist/types/enum/abyss-application-event.enum.js.map +1 -1
  51. package/dist/types/enum/email-type.enum.d.ts +1 -0
  52. package/dist/types/enum/email-type.enum.js +1 -0
  53. package/dist/types/enum/email-type.enum.js.map +1 -1
  54. package/dist/types/enum/external-delivery.enum.d.ts +6 -0
  55. package/dist/types/enum/external-delivery.enum.js +11 -0
  56. package/dist/types/enum/external-delivery.enum.js.map +1 -0
  57. package/dist/types/enum/index.d.ts +2 -0
  58. package/dist/types/enum/index.js +2 -0
  59. package/dist/types/enum/index.js.map +1 -1
  60. package/dist/types/enum/organization-billing.enum.d.ts +15 -10
  61. package/dist/types/enum/organization-billing.enum.js +29 -10
  62. package/dist/types/enum/organization-billing.enum.js.map +1 -1
  63. package/dist/types/enum/organization-external-identity.enum.d.ts +17 -0
  64. package/dist/types/enum/organization-external-identity.enum.js +24 -0
  65. package/dist/types/enum/organization-external-identity.enum.js.map +1 -0
  66. package/dist/types/enum/organization-permission.enum.js.map +1 -1
  67. package/dist/types/enum/slack-webhook.enum.d.ts +3 -1
  68. package/dist/types/enum/slack-webhook.enum.js +2 -0
  69. package/dist/types/enum/slack-webhook.enum.js.map +1 -1
  70. package/dist/types/enum/token-type.enum.d.ts +2 -1
  71. package/dist/types/enum/token-type.enum.js +1 -0
  72. package/dist/types/enum/token-type.enum.js.map +1 -1
  73. package/dist/types/enum/user-notification-category.enum.d.ts +7 -1
  74. package/dist/types/enum/user-notification-category.enum.js +21 -1
  75. package/dist/types/enum/user-notification-category.enum.js.map +1 -1
  76. package/dist/types/enum/user-notification-content-type.enum.d.ts +20 -1
  77. package/dist/types/enum/user-notification-content-type.enum.js +3 -1
  78. package/dist/types/enum/user-notification-content-type.enum.js.map +1 -1
  79. package/dist/types/interface/api/index.d.ts +9 -0
  80. package/dist/types/interface/api/index.js +9 -0
  81. package/dist/types/interface/api/index.js.map +1 -1
  82. package/dist/types/interface/api/requests/billing-account.admin.request.d.ts +9 -0
  83. package/dist/types/interface/api/requests/billing-module.request.d.ts +25 -0
  84. package/dist/types/interface/api/requests/billing-module.request.js +3 -0
  85. package/dist/types/interface/api/requests/billing-module.request.js.map +1 -0
  86. package/dist/types/interface/api/requests/billing-snapshot-admin.request.d.ts +7 -0
  87. package/dist/types/interface/api/requests/billing-snapshot-admin.request.js +3 -0
  88. package/dist/types/interface/api/requests/billing-snapshot-admin.request.js.map +1 -0
  89. package/dist/types/interface/api/requests/organization-external-identity.request.d.ts +28 -0
  90. package/dist/types/interface/api/requests/organization-external-identity.request.js +3 -0
  91. package/dist/types/interface/api/requests/organization-external-identity.request.js.map +1 -0
  92. package/dist/types/interface/api/requests/organization-integration-webhook.request.d.ts +17 -1
  93. package/dist/types/interface/api/requests/organization-member.request.d.ts +3 -0
  94. package/dist/types/interface/api/requests/quota-offer.request.d.ts +10 -0
  95. package/dist/types/interface/api/requests/quota-offer.request.js +3 -0
  96. package/dist/types/interface/api/requests/quota-offer.request.js.map +1 -0
  97. package/dist/types/interface/api/responses/billing-account.admin.response.d.ts +10 -0
  98. package/dist/types/interface/api/responses/billing-estimate.response.d.ts +18 -0
  99. package/dist/types/interface/api/responses/billing-estimate.response.js +3 -0
  100. package/dist/types/interface/api/responses/billing-estimate.response.js.map +1 -0
  101. package/dist/types/interface/api/responses/billing-module.response.d.ts +21 -0
  102. package/dist/types/interface/api/responses/billing-module.response.js +3 -0
  103. package/dist/types/interface/api/responses/billing-module.response.js.map +1 -0
  104. package/dist/types/interface/api/responses/billing-snapshot-admin.response.d.ts +9 -0
  105. package/dist/types/interface/api/responses/billing-snapshot-admin.response.js +3 -0
  106. package/dist/types/interface/api/responses/billing-snapshot-admin.response.js.map +1 -0
  107. package/dist/types/interface/api/responses/organization-external-identity.response.d.ts +22 -0
  108. package/dist/types/interface/api/responses/organization-external-identity.response.js +3 -0
  109. package/dist/types/interface/api/responses/organization-external-identity.response.js.map +1 -0
  110. package/dist/types/interface/api/responses/organization-member.response.d.ts +8 -0
  111. package/dist/types/interface/api/responses/quota-offer.response.d.ts +27 -0
  112. package/dist/types/interface/api/responses/quota-offer.response.js +3 -0
  113. package/dist/types/interface/api/responses/quota-offer.response.js.map +1 -0
  114. package/dist/types/interface/index.d.ts +3 -0
  115. package/dist/types/interface/index.js +3 -0
  116. package/dist/types/interface/index.js.map +1 -1
  117. package/dist/types/interface/models/billing-account-addon.model.d.ts +16 -0
  118. package/dist/types/interface/models/billing-account-addon.model.js +3 -0
  119. package/dist/types/interface/models/billing-account-addon.model.js.map +1 -0
  120. package/dist/types/interface/models/billing-account.model.d.ts +1 -0
  121. package/dist/types/interface/models/external-delivery.model.d.ts +22 -0
  122. package/dist/types/interface/models/external-delivery.model.js +3 -0
  123. package/dist/types/interface/models/external-delivery.model.js.map +1 -0
  124. package/dist/types/interface/models/index.d.ts +1 -0
  125. package/dist/types/interface/models/index.js +1 -0
  126. package/dist/types/interface/models/index.js.map +1 -1
  127. package/dist/types/interface/models/organization-external-identity.model.d.ts +20 -0
  128. package/dist/types/interface/models/organization-external-identity.model.js +3 -0
  129. package/dist/types/interface/models/organization-external-identity.model.js.map +1 -0
  130. package/dist/types/interface/models/organization-member.model.d.ts +1 -0
  131. package/dist/types/interface/models/organization-service-quota.model.d.ts +1 -0
  132. package/dist/types/session.d.ts +8 -1
  133. package/dist/utils/billing-deep-link.utils.d.ts +15 -0
  134. package/dist/utils/billing-deep-link.utils.js +23 -0
  135. package/dist/utils/billing-deep-link.utils.js.map +1 -0
  136. package/dist/utils/billing.utils.d.ts +0 -2
  137. package/dist/utils/billing.utils.js +1 -6
  138. package/dist/utils/billing.utils.js.map +1 -1
  139. package/dist/utils/index.d.ts +1 -0
  140. package/dist/utils/index.js +1 -0
  141. package/dist/utils/index.js.map +1 -1
  142. package/dist/utils/pricing.utils.d.ts +21 -1
  143. package/dist/utils/pricing.utils.js +111 -4
  144. package/dist/utils/pricing.utils.js.map +1 -1
  145. package/package.json +2 -2
  146. package/tsconfig.build.json +4 -0
  147. package/tsconfig.json +35 -36
@@ -0,0 +1,21 @@
1
+ import { BillingAddonStatus } from '../../../enum/organization-billing.enum';
2
+ import { BillingModuleId } from '../../../../constants/module-catalog.constants';
3
+ import { IResponse } from '../type-message/response';
4
+ export interface IOwnedBillingModule {
5
+ moduleId: BillingModuleId;
6
+ label: string;
7
+ unit: string;
8
+ quantity: number;
9
+ status: BillingAddonStatus;
10
+ monthlyPriceCents: number;
11
+ pendingQuantity: number | null;
12
+ pendingEffectiveAt: string | null;
13
+ }
14
+ export interface IListBillingModulesData {
15
+ modules: IOwnedBillingModule[];
16
+ }
17
+ export type IListBillingModulesResponse = IResponse<IListBillingModulesData>;
18
+ export interface ISetBillingModuleQuantityData {
19
+ module: IOwnedBillingModule | null;
20
+ }
21
+ export type ISetBillingModuleQuantityResponse = IResponse<ISetBillingModuleQuantityData>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=billing-module.response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-module.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/billing-module.response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { IBillingDailySnapshot } from '../../models/billing-daily-snapshot.model';
2
+ import { IQuotaStateItemAdminBilling } from './billing-account.admin.response';
3
+ import { IResponse } from '../type-message/response';
4
+ export interface IListSnapshotsAdminBillingData {
5
+ snapshots: IBillingDailySnapshot[];
6
+ live: IQuotaStateItemAdminBilling[];
7
+ snapshotAsOf: string | null;
8
+ }
9
+ export type IListSnapshotsAdminBillingResponse = IResponse<IListSnapshotsAdminBillingData>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=billing-snapshot-admin.response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-snapshot-admin.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/billing-snapshot-admin.response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { IOrganizationExternalIdentity } from '../../models/organization-external-identity.model';
2
+ import { IResponse } from '../type-message/response';
3
+ export interface IGetConnectUrlOrganizationExternalIdentityData {
4
+ connectUrl: string;
5
+ }
6
+ export type IGetConnectUrlOrganizationExternalIdentityResponse = IResponse<IGetConnectUrlOrganizationExternalIdentityData>;
7
+ export interface IBindOrganizationExternalIdentityData {
8
+ organizationExternalIdentity: IOrganizationExternalIdentity;
9
+ }
10
+ export type IBindOrganizationExternalIdentityResponse = IResponse<IBindOrganizationExternalIdentityData>;
11
+ export interface IListPendingOrganizationExternalIdentityData {
12
+ organizationExternalIdentities: IOrganizationExternalIdentity[];
13
+ }
14
+ export type IListPendingOrganizationExternalIdentityResponse = IResponse<IListPendingOrganizationExternalIdentityData>;
15
+ export interface INameCandidateOrganizationExternalIdentityData {
16
+ organizationExternalIdentity: IOrganizationExternalIdentity;
17
+ }
18
+ export type INameCandidateOrganizationExternalIdentityResponse = IResponse<INameCandidateOrganizationExternalIdentityData>;
19
+ export interface IDismissCandidateOrganizationExternalIdentityData {
20
+ organizationExternalIdentity: IOrganizationExternalIdentity;
21
+ }
22
+ export type IDismissCandidateOrganizationExternalIdentityResponse = IResponse<IDismissCandidateOrganizationExternalIdentityData>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=organization-external-identity.response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-external-identity.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/organization-external-identity.response.ts"],"names":[],"mappings":""}
@@ -43,3 +43,11 @@ export interface IListUserIdsByPermissionOrganizationMemberAdminData {
43
43
  userIds: string[];
44
44
  }
45
45
  export type IListUserIdsByPermissionOrganizationMemberAdminResponse = IResponse<IListUserIdsByPermissionOrganizationMemberAdminData>;
46
+ export interface IOrganizationMemberAdminSummary {
47
+ userId: string;
48
+ displayName: string;
49
+ }
50
+ export interface IListMembersOrganizationMemberAdminData {
51
+ members: IOrganizationMemberAdminSummary[];
52
+ }
53
+ export type IListMembersOrganizationMemberAdminResponse = IResponse<IListMembersOrganizationMemberAdminData>;
@@ -0,0 +1,27 @@
1
+ import { BillingMetric, BillingService } from '../../../enum/organization-billing.enum';
2
+ import { BillingModuleId } from '../../../../constants/module-catalog.constants';
3
+ import { IResponse } from '../type-message/response';
4
+ export interface IQuotaOfferBranch {
5
+ kind: 'extension' | 'overage';
6
+ priceCents: number | null;
7
+ lot?: number;
8
+ moduleId?: BillingModuleId;
9
+ }
10
+ export interface IQuotaOffer {
11
+ service: BillingService;
12
+ metric: BillingMetric;
13
+ unit: string;
14
+ current: number;
15
+ includedLimit: number;
16
+ ceiling: number | null;
17
+ alertThreshold: number;
18
+ isSetting: boolean;
19
+ moduleSuspendedByPlan: boolean;
20
+ lotSize: number | null;
21
+ branches: IQuotaOfferBranch[];
22
+ asOf: 'live' | 'snapshot';
23
+ }
24
+ export interface IGetQuotaOfferData {
25
+ offer: IQuotaOffer;
26
+ }
27
+ export type IGetQuotaOfferResponse = IResponse<IGetQuotaOfferData>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=quota-offer.response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quota-offer.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/quota-offer.response.ts"],"names":[],"mappings":""}
@@ -23,8 +23,11 @@ export * from './models/report-notification-subscription.model';
23
23
  export * from './models/organization.model';
24
24
  export * from './models/organization-integration.model';
25
25
  export * from './models/organization-member.model';
26
+ export * from './models/organization-external-identity.model';
27
+ export * from './models/external-delivery.model';
26
28
  export * from './models/plan-template.model';
27
29
  export * from './models/billing-account.model';
30
+ export * from './models/billing-account-addon.model';
28
31
  export * from './models/organization-service-quota.model';
29
32
  export * from './models/organization-project-quota.model';
30
33
  export * from './models/usage-record.model';
@@ -39,8 +39,11 @@ __exportStar(require("./models/report-notification-subscription.model"), exports
39
39
  __exportStar(require("./models/organization.model"), exports);
40
40
  __exportStar(require("./models/organization-integration.model"), exports);
41
41
  __exportStar(require("./models/organization-member.model"), exports);
42
+ __exportStar(require("./models/organization-external-identity.model"), exports);
43
+ __exportStar(require("./models/external-delivery.model"), exports);
42
44
  __exportStar(require("./models/plan-template.model"), exports);
43
45
  __exportStar(require("./models/billing-account.model"), exports);
46
+ __exportStar(require("./models/billing-account-addon.model"), exports);
44
47
  __exportStar(require("./models/organization-service-quota.model"), exports);
45
48
  __exportStar(require("./models/organization-project-quota.model"), exports);
46
49
  __exportStar(require("./models/usage-record.model"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,yDAAuC;AACvC,gEAA8C;AAC9C,4EAA0D;AAC1D,6DAA2C;AAC3C,mEAAiD;AACjD,yEAAuD;AACvD,+DAA6C;AAC7C,+DAA6C;AAC7C,8DAA4C;AAC5C,mEAAiD;AACjD,oEAAkD;AAGlD,2DAAyC;AACzC,sEAAoD;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AC5C,0EAAwD;AACxD,qEAAmD;AACnD,gFAA8D;AAC9D,mEAAiD;AAGjD,+DAA6C;AAC7C,iEAA+C;AAC/C,uEAAqD;AACrD,4EAA0D;AAC1D,4EAA0D;AAC1D,8DAA4C;AAC5C,yDAAuC;AACvC,oEAAkD;AAClD,iEAA+C;AAC/C,0EAAwD;AACxD,6DAA2C;AAC3C,sEAAoD;AACpD,mEAAiD;AACjD,mEAAiD;AACjD,kEAAgD;AAChD,qEAAmD;AACnD,wEAAsD;AACtD,+DAA6C;AAC7C,8DAA4C;AAC5C,qEAAmD;AACnD,sDAAoC;AACpC,6DAA2C;AAC3C,qEAAmD;AACnD,iFAA+D;AAC/D,iEAA+C;AAC/C,oFAAkE;AAGlE,kEAAgD;AAGhD,mEAAiD;AAGjD,+DAA6C;AAO7C,gEAA8C;AAG9C,gEAA8C;AAC9C,wEAAsD;AACtD,2EAAyD;AACzD,oEAAkD;AAClD,yEAAuD;AAGvD,4DAA0C;AAG1C,4DAA0C;AAG1C,qEAAmD;AAGnD,qEAAmD;AAGnD,kEAAgD;AAGhD,iEAA+C;AAC/C,4DAA0C"}
@@ -0,0 +1,16 @@
1
+ import { BillingAddonStatus } from '../../enum';
2
+ import { BillingModuleId } from '../../../constants/module-catalog.constants';
3
+ import { IBillingAccount } from './billing-account.model';
4
+ export interface IBillingAccountAddon {
5
+ id?: string;
6
+ billingAccountId: string;
7
+ moduleId: BillingModuleId;
8
+ quantity: number;
9
+ stripeSubscriptionItemId: string | null;
10
+ status: BillingAddonStatus;
11
+ pendingEffectiveAt: Date | null;
12
+ pendingQuantity: number | null;
13
+ updatedAt?: Date;
14
+ createdAt?: Date;
15
+ billingAccount?: IBillingAccount;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=billing-account-addon.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-account-addon.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/billing-account-addon.model.ts"],"names":[],"mappings":""}
@@ -31,6 +31,7 @@ export interface IBillingAccount {
31
31
  stripePaymentMethodExpYear: number | null;
32
32
  currentPeriodStart: Date;
33
33
  currentPeriodEnd: Date;
34
+ billingAnchorDay: number | null;
34
35
  trialEndsAt: Date | null;
35
36
  unpaidStripeInvoiceIds: string[];
36
37
  openStripeDisputeIds: string[];
@@ -0,0 +1,22 @@
1
+ import { ExternalDeliveryStatus, ExternalMessagingPlatform } from '../../enum';
2
+ import { IOrganization } from './organization.model';
3
+ import { IUser } from './user.model';
4
+ import { IUserNotification } from './user-notification.model';
5
+ export interface IExternalDelivery {
6
+ id?: string;
7
+ userNotificationId?: string | null;
8
+ organizationId: string;
9
+ userId: string;
10
+ platform: ExternalMessagingPlatform;
11
+ organizationExternalIdentityId?: string | null;
12
+ status: ExternalDeliveryStatus;
13
+ attemptCount: number;
14
+ nextAttemptAt?: Date | null;
15
+ externalMessageId?: string | null;
16
+ lastError?: string | null;
17
+ updatedAt?: Date;
18
+ createdAt?: Date;
19
+ organization?: IOrganization;
20
+ user?: IUser;
21
+ userNotification?: IUserNotification;
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=external-delivery.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-delivery.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/external-delivery.model.ts"],"names":[],"mappings":""}
@@ -18,6 +18,7 @@ export * from './organization-integration.model';
18
18
  export * from './organization-member.model';
19
19
  export * from './plan-template.model';
20
20
  export * from './billing-account.model';
21
+ export * from './billing-account-addon.model';
21
22
  export * from './organization-service-quota.model';
22
23
  export * from './organization-project-quota.model';
23
24
  export * from './usage-record.model';
@@ -34,6 +34,7 @@ __exportStar(require("./organization-integration.model"), exports);
34
34
  __exportStar(require("./organization-member.model"), exports);
35
35
  __exportStar(require("./plan-template.model"), exports);
36
36
  __exportStar(require("./billing-account.model"), exports);
37
+ __exportStar(require("./billing-account-addon.model"), exports);
37
38
  __exportStar(require("./organization-service-quota.model"), exports);
38
39
  __exportStar(require("./organization-project-quota.model"), exports);
39
40
  __exportStar(require("./usage-record.model"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,yDAAuC;AACvC,qEAAmD;AACnD,sDAAoC;AACpC,4DAA0C;AAC1C,wDAAsC;AACtC,wDAAsC;AACtC,uDAAqC;AACrC,4DAA0C;AAC1C,6DAA2C;AAG3C,oDAAkC;AAClC,+DAA6C;AAG7C,gDAA8B;AAG9B,iDAA+B;AAG/B,uDAAqC;AACrC,mEAAiD;AACjD,8DAA4C;AAG5C,wDAAsC;AACtC,0DAAwC;AACxC,qEAAmD;AACnD,qEAAmD;AACnD,uDAAqC;AACrC,kDAAgC;AAChC,6DAA2C;AAC3C,0DAAwC;AACxC,mEAAiD;AACjD,sDAAoC;AACpC,+DAA6C;AAC7C,4DAA0C;AAC1C,4DAA0C;AAC1C,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAC/C,wDAAsC;AACtC,uDAAqC;AACrC,8DAA4C;AAC5C,+CAA6B;AAC7B,sDAAoC;AACpC,8DAA4C;AAC5C,0EAAwD;AACxD,0DAAwC;AACxC,6EAA2D;AAG3D,2DAAyC;AAGzC,4DAA0C;AAG1C,wDAAsC;AAGtC,yDAAuC;AACvC,iEAA+C;AAC/C,oEAAkD;AAClD,yDAAuC;AACvC,6DAA2C;AAC3C,kEAAgD;AAGhD,qDAAmC;AAGnC,qDAAmC;AAGnC,8DAA4C;AAG5C,8DAA4C;AAG5C,2DAAyC;AAGzC,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,yDAAuC;AACvC,qEAAmD;AACnD,sDAAoC;AACpC,4DAA0C;AAC1C,wDAAsC;AACtC,wDAAsC;AACtC,uDAAqC;AACrC,4DAA0C;AAC1C,6DAA2C;AAG3C,oDAAkC;AAClC,+DAA6C;AAG7C,gDAA8B;AAG9B,iDAA+B;AAG/B,uDAAqC;AACrC,mEAAiD;AACjD,8DAA4C;AAG5C,wDAAsC;AACtC,0DAAwC;AACxC,gEAA8C;AAC9C,qEAAmD;AACnD,qEAAmD;AACnD,uDAAqC;AACrC,kDAAgC;AAChC,6DAA2C;AAC3C,0DAAwC;AACxC,mEAAiD;AACjD,sDAAoC;AACpC,+DAA6C;AAC7C,4DAA0C;AAC1C,4DAA0C;AAC1C,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAC/C,wDAAsC;AACtC,uDAAqC;AACrC,8DAA4C;AAC5C,+CAA6B;AAC7B,sDAAoC;AACpC,8DAA4C;AAC5C,0EAAwD;AACxD,0DAAwC;AACxC,6EAA2D;AAG3D,2DAAyC;AAGzC,4DAA0C;AAG1C,wDAAsC;AAGtC,yDAAuC;AACvC,iEAA+C;AAC/C,oEAAkD;AAClD,yDAAuC;AACvC,6DAA2C;AAC3C,kEAAgD;AAGhD,qDAAmC;AAGnC,qDAAmC;AAGnC,8DAA4C;AAG5C,8DAA4C;AAG5C,2DAAyC;AAGzC,0DAAwC"}
@@ -0,0 +1,20 @@
1
+ import { ExternalIdentitySource, ExternalIdentityStatus, ExternalMessagingPlatform } from '../../enum';
2
+ import { IOrganization } from './organization.model';
3
+ import { IUser } from './user.model';
4
+ export interface IOrganizationExternalIdentity {
5
+ id?: string;
6
+ organizationId: string;
7
+ userId?: string | null;
8
+ platform: ExternalMessagingPlatform;
9
+ externalUserId: string;
10
+ externalWorkspaceId: string;
11
+ externalEnterpriseId?: string | null;
12
+ externalEmail?: string | null;
13
+ source: ExternalIdentitySource;
14
+ status: ExternalIdentityStatus;
15
+ lastVerifiedAt?: Date | null;
16
+ updatedAt?: Date;
17
+ createdAt?: Date;
18
+ organization?: IOrganization;
19
+ user?: IUser;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=organization-external-identity.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-external-identity.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/organization-external-identity.model.ts"],"names":[],"mappings":""}
@@ -8,6 +8,7 @@ export interface IOrganizationMember {
8
8
  organizationId: string;
9
9
  userId: string;
10
10
  permissions: OrganizationPermission[];
11
+ workEmail?: string | null;
11
12
  adultStatus?: boolean;
12
13
  updatedAt?: Date;
13
14
  createdAt?: Date;
@@ -9,6 +9,7 @@ export interface IServiceQuota {
9
9
  isOverridden: boolean;
10
10
  ceilingMode: QuotaCeilingMode;
11
11
  ceilingValue: number | null;
12
+ overageNanocentsPerUnit?: number | null;
12
13
  updatedAt?: Date;
13
14
  createdAt?: Date;
14
15
  billingAccount?: IBillingAccount;
@@ -1,4 +1,4 @@
1
- import { AbyssService, TokenType } from './enum';
1
+ import { AbyssService, ExternalMessagingPlatform, TokenType } from './enum';
2
2
  export type SessionToken = {
3
3
  emitter: AbyssService;
4
4
  expiration: string;
@@ -33,3 +33,10 @@ export type InvitationTokenPayload = {
33
33
  invitationId: string;
34
34
  email: string;
35
35
  };
36
+ export type ExternalIdentityBindingTokenPayload = {
37
+ tokenHistoryId: string;
38
+ type: TokenType.EXTERNAL_IDENTITY_BINDING;
39
+ userId: string;
40
+ organizationId: string;
41
+ platform: ExternalMessagingPlatform;
42
+ };
@@ -0,0 +1,15 @@
1
+ export declare enum BillingDeepLinkAction {
2
+ THRESHOLD = "threshold",
3
+ EXTENSION = "extension",
4
+ CEILING = "ceiling",
5
+ OVERAGE = "overage"
6
+ }
7
+ export interface BillingDeepLinkParams {
8
+ billingBaseUrl: string;
9
+ service: string;
10
+ metric: string;
11
+ action: BillingDeepLinkAction;
12
+ organizationId?: string;
13
+ returnUrl?: string;
14
+ }
15
+ export declare const buildBillingDeepLink: ({ billingBaseUrl, service, metric, action, organizationId, returnUrl, }: BillingDeepLinkParams) => string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBillingDeepLink = exports.BillingDeepLinkAction = void 0;
4
+ var BillingDeepLinkAction;
5
+ (function (BillingDeepLinkAction) {
6
+ BillingDeepLinkAction["THRESHOLD"] = "threshold";
7
+ BillingDeepLinkAction["EXTENSION"] = "extension";
8
+ BillingDeepLinkAction["CEILING"] = "ceiling";
9
+ BillingDeepLinkAction["OVERAGE"] = "overage";
10
+ })(BillingDeepLinkAction || (exports.BillingDeepLinkAction = BillingDeepLinkAction = {}));
11
+ const buildBillingDeepLink = ({ billingBaseUrl, service, metric, action, organizationId, returnUrl, }) => {
12
+ const params = new URLSearchParams({ service, metric, action });
13
+ if (returnUrl) {
14
+ params.set('return', returnUrl);
15
+ }
16
+ const base = billingBaseUrl.replace(/\/+$/, '');
17
+ const chemin = organizationId
18
+ ? `/org/${encodeURIComponent(organizationId)}/billing/consumption`
19
+ : '/dashboard/account/billing/consumption';
20
+ return `${base}${chemin}?${params.toString()}`;
21
+ };
22
+ exports.buildBillingDeepLink = buildBillingDeepLink;
23
+ //# sourceMappingURL=billing-deep-link.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-deep-link.utils.js","sourceRoot":"","sources":["../../src/utils/billing-deep-link.utils.ts"],"names":[],"mappings":";;;AAuBA,IAAY,qBASX;AATD,WAAY,qBAAqB;IAE/B,gDAAuB,CAAA;IAEvB,gDAAuB,CAAA;IAEvB,4CAAmB,CAAA;IAEnB,4CAAmB,CAAA;AACrB,CAAC,EATW,qBAAqB,qCAArB,qBAAqB,QAShC;AAyDM,MAAM,oBAAoB,GAAG,CAAC,EACnC,cAAc,EACd,OAAO,EACP,MAAM,EACN,MAAM,EACN,cAAc,EACd,SAAS,GACa,EAAU,EAAE;IAClC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;IAID,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAGhD,MAAM,MAAM,GAAG,cAAc;QAC3B,CAAC,CAAC,QAAQ,kBAAkB,CAAC,cAAc,CAAC,sBAAsB;QAClE,CAAC,CAAC,wCAAwC,CAAC;IAC7C,OAAO,GAAG,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AACjD,CAAC,CAAC;AAtBW,QAAA,oBAAoB,wBAsB/B"}
@@ -1,5 +1,3 @@
1
- import { BillingAccountStatus } from '../types/enum';
2
- export declare const isSubscriptionExpired: (status: BillingAccountStatus) => boolean;
3
1
  export interface ParsedQuotaUnit {
4
2
  multiplier: number;
5
3
  baseUnit: string;
@@ -1,11 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveQuotaAmount = exports.parseQuotaUnit = exports.isSubscriptionExpired = void 0;
4
- const enum_1 = require("../types/enum");
5
- const isSubscriptionExpired = (status) => {
6
- return status === enum_1.BillingAccountStatus.CANCELLED;
7
- };
8
- exports.isSubscriptionExpired = isSubscriptionExpired;
3
+ exports.resolveQuotaAmount = exports.parseQuotaUnit = void 0;
9
4
  const parseQuotaUnit = (unit) => {
10
5
  const raw = (unit ?? '').trim();
11
6
  if (!raw) {
@@ -1 +1 @@
1
- {"version":3,"file":"billing.utils.js","sourceRoot":"","sources":["../../src/utils/billing.utils.ts"],"names":[],"mappings":";;;AAAA,wCAAqD;AAK9C,MAAM,qBAAqB,GAAG,CAAC,MAA4B,EAAW,EAAE;IAC7E,O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AE,CAAC;AACpE,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B"}
@@ -23,3 +23,4 @@ export * from './invitation.utils';
23
23
  export * from './invoice-amounts.utils';
24
24
  export * from './resolve-user.utils';
25
25
  export * from './pricing.utils';
26
+ export * from './billing-deep-link.utils';
@@ -39,4 +39,5 @@ __exportStar(require("./invitation.utils"), exports);
39
39
  __exportStar(require("./invoice-amounts.utils"), exports);
40
40
  __exportStar(require("./resolve-user.utils"), exports);
41
41
  __exportStar(require("./pricing.utils"), exports);
42
+ __exportStar(require("./billing-deep-link.utils"), exports);
42
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,0DAAwC;AACxC,+CAA6B;AAC7B,iDAA+B;AAC/B,uDAAqC;AACrC,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,wDAAsC;AACtC,wDAAsC;AACtC,6DAA2C;AAC3C,8DAA4C;AAC5C,qDAAmC;AACnC,0DAAwC;AACxC,uDAAqC;AAIrC,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,0DAAwC;AACxC,+CAA6B;AAC7B,iDAA+B;AAC/B,uDAAqC;AACrC,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,wDAAsC;AACtC,wDAAsC;AACtC,6DAA2C;AAC3C,8DAA4C;AAC5C,qDAAmC;AACnC,0DAAwC;AACxC,uDAAqC;AAIrC,kDAAgC;AAChC,4DAA0C"}
@@ -1,9 +1,20 @@
1
+ import { BillingModuleId } from '../constants/module-catalog.constants';
1
2
  import { PriceTranche } from '../constants/metric-price-scale.constants';
2
3
  import { BillingMetric } from '../types/enum/organization-billing.enum';
3
4
  export declare const priceForQuantity: (scale: PriceTranche[], quantity: number) => number;
4
5
  export declare const quantityForBudget: (scale: PriceTranche[], budgetCents: number) => number;
5
6
  export declare const overageNanocentsPerUnit: (scale: PriceTranche[]) => number;
6
- export declare const resolveOverageNanocentsPerUnit: (metric: BillingMetric) => number | null;
7
+ export declare enum OverageRateSource {
8
+ NEGOTIATED = "NEGOTIATED",
9
+ MODULE_SCALE = "MODULE_SCALE",
10
+ CATALOG_FLAT = "CATALOG_FLAT",
11
+ NONE = "NONE"
12
+ }
13
+ export declare const resolveOverageRate: (metric: BillingMetric, accountNanocentsPerUnit?: number | null) => {
14
+ nanocentsPerUnit: number | null;
15
+ source: OverageRateSource;
16
+ };
17
+ export declare const resolveOverageNanocentsPerUnit: (metric: BillingMetric, accountNanocentsPerUnit?: number | null) => number | null;
7
18
  export declare const overageAmountCents: (nanocentsPerUnit: number, overageQuantity: number) => number;
8
19
  export declare const overagePriceCents: (metric: BillingMetric, includedQuantity: number, overageQuantity: number) => number;
9
20
  export interface PlanCapacityItem {
@@ -19,3 +30,12 @@ export interface OverageRateQuote {
19
30
  eur: number;
20
31
  }
21
32
  export declare const quoteOverageRate: (nanocentsPerUnit: number) => OverageRateQuote;
33
+ export interface StripePriceTier {
34
+ upTo: number | 'inf';
35
+ unitAmountDecimal: string;
36
+ }
37
+ export declare const shiftedTiersForModule: (scale: PriceTranche[], includedQuantity: number) => StripePriceTier[];
38
+ export declare const modulePriceCentsFor: (scale: PriceTranche[], includedQuantity: number, quantity: number) => number;
39
+ export declare const moduleMonthlyPriceCents: (moduleId: BillingModuleId, includedQuantity: number, quantity: number) => number;
40
+ export declare const remainingPeriodShare: (now: Date, periodStart: Date, periodEnd: Date) => number;
41
+ export declare const moduleProratedPriceCents: (moduleId: BillingModuleId, includedQuantity: number, quantity: number, now: Date, periodStart: Date, periodEnd: Date) => number;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.quoteOverageRate = exports.OVERAGE_QUOTE_QUANTITIES = exports.formatNanoCentsAsEur = exports.planCapacityShare = exports.planCapacityValueCents = exports.overagePriceCents = exports.overageAmountCents = exports.resolveOverageNanocentsPerUnit = exports.overageNanocentsPerUnit = exports.quantityForBudget = exports.priceForQuantity = void 0;
3
+ exports.moduleProratedPriceCents = exports.remainingPeriodShare = exports.moduleMonthlyPriceCents = exports.modulePriceCentsFor = exports.shiftedTiersForModule = exports.quoteOverageRate = exports.OVERAGE_QUOTE_QUANTITIES = exports.formatNanoCentsAsEur = exports.planCapacityShare = exports.planCapacityValueCents = exports.overagePriceCents = exports.overageAmountCents = exports.resolveOverageNanocentsPerUnit = exports.resolveOverageRate = exports.OverageRateSource = exports.overageNanocentsPerUnit = exports.quantityForBudget = exports.priceForQuantity = void 0;
4
4
  const overage_base_rates_constants_1 = require("../constants/overage-base-rates.constants");
5
+ const module_catalog_constants_1 = require("../constants/module-catalog.constants");
5
6
  const metric_price_scale_constants_1 = require("../constants/metric-price-scale.constants");
6
7
  const priceForQuantity = (scale, quantity) => {
7
8
  if (!Number.isFinite(quantity) || quantity <= 0) {
@@ -49,14 +50,40 @@ const quantityForBudget = (scale, budgetCents) => {
49
50
  exports.quantityForBudget = quantityForBudget;
50
51
  const overageNanocentsPerUnit = (scale) => scale[0].nanocentsPerUnit * metric_price_scale_constants_1.OVERAGE_MULTIPLIER;
51
52
  exports.overageNanocentsPerUnit = overageNanocentsPerUnit;
52
- const resolveOverageNanocentsPerUnit = (metric) => {
53
+ var OverageRateSource;
54
+ (function (OverageRateSource) {
55
+ OverageRateSource["NEGOTIATED"] = "NEGOTIATED";
56
+ OverageRateSource["MODULE_SCALE"] = "MODULE_SCALE";
57
+ OverageRateSource["CATALOG_FLAT"] = "CATALOG_FLAT";
58
+ OverageRateSource["NONE"] = "NONE";
59
+ })(OverageRateSource || (exports.OverageRateSource = OverageRateSource = {}));
60
+ const resolveOverageRate = (metric, accountNanocentsPerUnit) => {
61
+ if (accountNanocentsPerUnit !== undefined &&
62
+ accountNanocentsPerUnit !== null &&
63
+ Number.isFinite(accountNanocentsPerUnit)) {
64
+ return {
65
+ nanocentsPerUnit: accountNanocentsPerUnit,
66
+ source: OverageRateSource.NEGOTIATED,
67
+ };
68
+ }
53
69
  const scale = metric_price_scale_constants_1.METRIC_PRICE_SCALE[metric];
54
70
  if (scale) {
55
- return (0, exports.overageNanocentsPerUnit)(scale);
71
+ return {
72
+ nanocentsPerUnit: (0, exports.overageNanocentsPerUnit)(scale),
73
+ source: OverageRateSource.MODULE_SCALE,
74
+ };
56
75
  }
57
76
  const flat = overage_base_rates_constants_1.DEFAULT_OVERAGE_BASE_RATES[metric];
58
- return flat ? flat.rate * metric_price_scale_constants_1.NANOCENTS_PER_CENT : null;
77
+ if (flat) {
78
+ return {
79
+ nanocentsPerUnit: flat.rate * metric_price_scale_constants_1.NANOCENTS_PER_CENT,
80
+ source: OverageRateSource.CATALOG_FLAT,
81
+ };
82
+ }
83
+ return { nanocentsPerUnit: null, source: OverageRateSource.NONE };
59
84
  };
85
+ exports.resolveOverageRate = resolveOverageRate;
86
+ const resolveOverageNanocentsPerUnit = (metric, accountNanocentsPerUnit) => (0, exports.resolveOverageRate)(metric, accountNanocentsPerUnit).nanocentsPerUnit;
60
87
  exports.resolveOverageNanocentsPerUnit = resolveOverageNanocentsPerUnit;
61
88
  const overageAmountCents = (nanocentsPerUnit, overageQuantity) => {
62
89
  if (!Number.isFinite(nanocentsPerUnit) ||
@@ -115,4 +142,84 @@ const quoteOverageRate = (nanocentsPerUnit) => {
115
142
  };
116
143
  };
117
144
  exports.quoteOverageRate = quoteOverageRate;
145
+ const shiftedTiersForModule = (scale, includedQuantity) => {
146
+ const inclus = Number.isFinite(includedQuantity) ? Math.max(0, includedQuantity) : 0;
147
+ const tiers = [];
148
+ for (const tranche of scale) {
149
+ const taux = (tranche.nanocentsPerUnit / metric_price_scale_constants_1.NANOCENTS_PER_CENT).toString();
150
+ if (tranche.upToQuantity === null) {
151
+ tiers.push({ upTo: 'inf', unitAmountDecimal: taux });
152
+ break;
153
+ }
154
+ if (tranche.upToQuantity <= inclus) {
155
+ continue;
156
+ }
157
+ tiers.push({ upTo: tranche.upToQuantity - inclus, unitAmountDecimal: taux });
158
+ }
159
+ if (tiers.length === 0 && scale.length > 0) {
160
+ const dernier = scale[scale.length - 1];
161
+ tiers.push({
162
+ upTo: 'inf',
163
+ unitAmountDecimal: (dernier.nanocentsPerUnit / metric_price_scale_constants_1.NANOCENTS_PER_CENT).toString(),
164
+ });
165
+ }
166
+ return tiers;
167
+ };
168
+ exports.shiftedTiersForModule = shiftedTiersForModule;
169
+ const modulePriceCentsFor = (scale, includedQuantity, quantity) => {
170
+ if (!Number.isFinite(quantity) || quantity <= 0) {
171
+ return 0;
172
+ }
173
+ const tiers = (0, exports.shiftedTiersForModule)(scale, includedQuantity);
174
+ let restant = quantity;
175
+ let bornePrecedente = 0;
176
+ let centimes = 0;
177
+ for (const tier of tiers) {
178
+ const borne = tier.upTo === 'inf' ? Number.POSITIVE_INFINITY : tier.upTo;
179
+ const tranche = Math.min(restant, borne - bornePrecedente);
180
+ if (tranche > 0) {
181
+ centimes += tranche * Number(tier.unitAmountDecimal);
182
+ restant -= tranche;
183
+ }
184
+ bornePrecedente = borne;
185
+ if (restant <= 0) {
186
+ break;
187
+ }
188
+ }
189
+ return Math.round(centimes);
190
+ };
191
+ exports.modulePriceCentsFor = modulePriceCentsFor;
192
+ const moduleMonthlyPriceCents = (moduleId, includedQuantity, quantity) => {
193
+ const module = (0, module_catalog_constants_1.moduleById)(moduleId);
194
+ if (!module || !Number.isFinite(quantity) || quantity <= 0) {
195
+ return 0;
196
+ }
197
+ if (module.kind === module_catalog_constants_1.BillingModuleKind.UNLOCK) {
198
+ return module.flatPriceCents;
199
+ }
200
+ const scale = metric_price_scale_constants_1.METRIC_PRICE_SCALE[module.scaleKey];
201
+ if (!scale) {
202
+ return 0;
203
+ }
204
+ return (0, exports.modulePriceCentsFor)(scale, includedQuantity, quantity);
205
+ };
206
+ exports.moduleMonthlyPriceCents = moduleMonthlyPriceCents;
207
+ const remainingPeriodShare = (now, periodStart, periodEnd) => {
208
+ const debut = periodStart.getTime();
209
+ const fin = periodEnd.getTime();
210
+ const instant = now.getTime();
211
+ const duree = fin - debut;
212
+ if (!Number.isFinite(duree) || duree <= 0) {
213
+ return 0;
214
+ }
215
+ const restant = fin - instant;
216
+ if (restant <= 0) {
217
+ return 0;
218
+ }
219
+ return Math.min(1, restant / duree);
220
+ };
221
+ exports.remainingPeriodShare = remainingPeriodShare;
222
+ const moduleProratedPriceCents = (moduleId, includedQuantity, quantity, now, periodStart, periodEnd) => Math.floor((0, exports.moduleMonthlyPriceCents)(moduleId, includedQuantity, quantity) *
223
+ (0, exports.remainingPeriodShare)(now, periodStart, periodEnd));
224
+ exports.moduleProratedPriceCents = moduleProratedPriceCents;
118
225
  //# sourceMappingURL=pricing.utils.js.map