@omni-graph/omni-model 0.2.28 → 0.2.29

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.
@@ -0,0 +1,13 @@
1
+ import { Discount } from '../../types';
2
+ import { TierSelectionItem } from "../../types/billing/bilingTypes";
3
+ export declare function applyDiscount(discount: Discount, originalPrice: number): number;
4
+ export declare function applyDiscounts(dicounts: Discount[], originalPrice: number): number;
5
+ export declare function computeTierPricing(tier: TierSelectionItem, currencyCode?: "USD"): {
6
+ priceMonthly: number;
7
+ priceAnnual: number;
8
+ currencyCode: string;
9
+ monthlyListPrice: number;
10
+ annualListPrice: number;
11
+ trialDays: number;
12
+ };
13
+ //# sourceMappingURL=billingFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billingFunctions.d.ts","sourceRoot":"","sources":["../../../src/functions/billing/billingFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAElE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAM/E;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAKlF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,EAAE,YAAY,GAAE,KAAa,GAAG;IACtF,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAA;CACpB,CAeA"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyDiscount = applyDiscount;
4
+ exports.applyDiscounts = applyDiscounts;
5
+ exports.computeTierPricing = computeTierPricing;
6
+ function applyDiscount(discount, originalPrice) {
7
+ var _a, _b;
8
+ if (discount.type === 'PERCENTAGE') {
9
+ return originalPrice * (1.0 - ((_a = discount.amount) !== null && _a !== void 0 ? _a : 0.0) / 100.0);
10
+ }
11
+ else {
12
+ return Math.max(0.0, originalPrice - ((_b = discount.amount) !== null && _b !== void 0 ? _b : 0.0));
13
+ }
14
+ }
15
+ function applyDiscounts(dicounts, originalPrice) {
16
+ const fixedDiscounts = dicounts.filter(discount => discount.type === 'FIXED');
17
+ const percentageDiscounts = dicounts.filter(discount => discount.type === 'PERCENTAGE');
18
+ const afterFixedDiscounts = fixedDiscounts.reduce((price, discount) => applyDiscount(discount, price), originalPrice);
19
+ return percentageDiscounts.reduce((price, discount) => applyDiscount(discount, price), afterFixedDiscounts);
20
+ }
21
+ function computeTierPricing(tier, currencyCode = "USD") {
22
+ var _a, _b;
23
+ const monthlyListPrice = tier.listPrice["USD"];
24
+ const monthlyDiscountedPrice = applyDiscounts(tier.discounts, monthlyListPrice);
25
+ const annualListPrice = monthlyListPrice * 12;
26
+ const annualBillingDiscount = (_b = (_a = tier.annualBillingDiscount) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : { type: "PERCENTAGE", amount: 0 };
27
+ const annualDiscountedPrice = applyDiscount(annualBillingDiscount, monthlyDiscountedPrice * 12);
28
+ return {
29
+ priceMonthly: monthlyDiscountedPrice,
30
+ priceAnnual: annualDiscountedPrice,
31
+ currencyCode,
32
+ monthlyListPrice,
33
+ annualListPrice,
34
+ trialDays: tier.trialDays
35
+ };
36
+ }
37
+ //# sourceMappingURL=billingFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billingFunctions.js","sourceRoot":"","sources":["../../../src/functions/billing/billingFunctions.ts"],"names":[],"mappings":";;AAGA,sCAMC;AAED,wCAKC;AAED,gDAsBC;AArCD,SAAgB,aAAa,CAAC,QAAkB,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B,GAAG,MAAA,MAAA,IAAI,CAAC,qBAAqB,0CAAE,IAAI,mCAAI,EAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAC,CAAA;IACjG,MAAM,qBAAqB,GAAG,aAAa,CAAC,qBAAqB,EAAE,sBAAsB,GAAG,EAAE,CAAC,CAAA;IAC/F,OAAO;QACH,YAAY,EAAE,sBAAsB;QACpC,WAAW,EAAE,qBAAqB;QAClC,YAAY;QACZ,gBAAgB;QAChB,eAAe;QACf,SAAS,EAAE,IAAI,CAAC,SAAS;KAC5B,CAAA;AAEL,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './testFunctions';
1
+ export * from './billing/billingFunctions';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./testFunctions"), exports);
17
+ __exportStar(require("./billing/billingFunctions"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA0C"}
@@ -0,0 +1,46 @@
1
+ export interface Discount {
2
+ name?: string;
3
+ amount: number;
4
+ type: DiscountType;
5
+ }
6
+ export type DiscountType = 'PERCENTAGE' | 'FIXED';
7
+ export interface TierSelectionItem {
8
+ id: string;
9
+ displayName?: string;
10
+ description?: string;
11
+ group: string;
12
+ isPublic: boolean;
13
+ isFree: boolean;
14
+ default: boolean;
15
+ isEnabled: boolean;
16
+ listPrice: Record<string, number>;
17
+ discounts: Discount[];
18
+ updatedAt?: string;
19
+ features: string[];
20
+ trialDays: number;
21
+ selected?: boolean;
22
+ discountsOffers?: DiscountOffer[];
23
+ freeTrial?: FreeTrialOffer;
24
+ annualBillingDiscount?: DiscountOffer;
25
+ }
26
+ export interface FreeTrial {
27
+ trialDays: number;
28
+ }
29
+ export interface DiscountOffer extends Offer<Discount> {
30
+ }
31
+ export interface FreeTrialOffer extends Offer<FreeTrial> {
32
+ }
33
+ export type OfferValidity = object;
34
+ export interface Offer<T> {
35
+ id: string;
36
+ displayName?: string;
37
+ description?: string;
38
+ offerType: 'DISCOUNT' | 'FREE_TRIAL' | 'CUSTOM_TIER';
39
+ isEnabled?: boolean;
40
+ reusable?: boolean;
41
+ validity?: OfferValidity;
42
+ validFrom?: string;
43
+ validTo?: string;
44
+ data?: T;
45
+ }
46
+ //# sourceMappingURL=bilingTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bilingTypes.d.ts","sourceRoot":"","sources":["../../../src/types/billing/bilingTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,OAAO,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC;IAClC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,qBAAqB,CAAC,EAAE,aAAa,CAAC;CACzC;AAED,MAAM,WAAW,SAAS;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,QAAQ,CAAC;CACrD;AAED,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,SAAS,CAAC;CACvD;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,MAAM,WAAW,KAAK,CAAC,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;CACZ"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=bilingTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bilingTypes.js","sourceRoot":"","sources":["../../../src/types/billing/bilingTypes.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- export { TestRecommendations } from './recommmendations/testRecommendations';
1
+ export { Discount } from './billing/bilingTypes';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC"}
@@ -1,6 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestRecommendations = void 0;
4
- var testRecommendations_1 = require("./recommmendations/testRecommendations");
5
- Object.defineProperty(exports, "TestRecommendations", { enumerable: true, get: function () { return testRecommendations_1.TestRecommendations; } });
6
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,8EAA2E;AAAnE,0HAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omni-graph/omni-model",
3
- "version": "0.2.28",
3
+ "version": "0.2.29",
4
4
  "description": "Models for the OmniGraph Services & Frontend",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,2 +0,0 @@
1
- export declare function testAdd(a: number, b: number): number;
2
- //# sourceMappingURL=testFunctions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/testFunctions.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,CAAC,EAAC,MAAM,EAAE,CAAC,EAAC,MAAM,GAAG,MAAM,CAElD"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.testAdd = testAdd;
4
- function testAdd(a, b) {
5
- return a + b;
6
- }
7
- //# sourceMappingURL=testFunctions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testFunctions.js","sourceRoot":"","sources":["../../src/functions/testFunctions.ts"],"names":[],"mappings":";;AAAA,0BAEC;AAFD,SAAgB,OAAO,CAAC,CAAQ,EAAE,CAAQ;IACtC,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC"}
@@ -1,5 +0,0 @@
1
- export declare class TestRecommendations {
2
- name?: string;
3
- age?: number;
4
- }
5
- //# sourceMappingURL=testRecommendations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testRecommendations.d.ts","sourceRoot":"","sources":["../../../src/types/recommmendations/testRecommendations.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestRecommendations = void 0;
4
- class TestRecommendations {
5
- }
6
- exports.TestRecommendations = TestRecommendations;
7
- //# sourceMappingURL=testRecommendations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testRecommendations.js","sourceRoot":"","sources":["../../../src/types/recommmendations/testRecommendations.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAmB;CAG/B;AAHD,kDAGC"}