@epilot/pricing-client 2.1.1 → 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.
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/openapi.d.ts CHANGED
@@ -157,6 +157,50 @@ declare namespace Components {
157
157
  };
158
158
  }[];
159
159
  }
160
+ /**
161
+ * Represents a valid base price item from a client.
162
+ */
163
+ export interface BasePriceItemDto {
164
+ /**
165
+ * An additional structure to keep metadata related with the price item.
166
+ */
167
+ metadata?: /* A set of key-value pairs used to store meta data information about an entity. */ MetaData;
168
+ /**
169
+ * The quantity of products being purchased.
170
+ */
171
+ quantity?: number;
172
+ /**
173
+ * An arbitrary string attached to the price item. Often useful for displaying to users. Defaults to product name.
174
+ */
175
+ description?: string;
176
+ /**
177
+ * The id of the product.
178
+ */
179
+ product_id?: string;
180
+ /**
181
+ * The id of the price.
182
+ */
183
+ price_id?: string;
184
+ /**
185
+ * The taxes applied to the price item.
186
+ */
187
+ taxes?: (/* A valid tax rate from a client. */ TaxAmountDto)[];
188
+ /**
189
+ * The taxes applied to the price item.
190
+ */
191
+ recurrences?: (/* An amount associated with a specific recurrence. */ RecurrenceAmountDto)[];
192
+ /**
193
+ * The snapshot of the product linked to the price item.
194
+ */
195
+ _product?: /**
196
+ * The product entity
197
+ * example:
198
+ * {
199
+ * "$ref": "#/components/examples/product"
200
+ * }
201
+ */
202
+ Product;
203
+ }
160
204
  export type BillingPeriod = "weekly" | "monthly" | "every_quarter" | "every_6_months" | "yearly" | "one_time";
161
205
  /**
162
206
  * Supports shopping for products and services until ready for checkout.
@@ -373,7 +417,14 @@ declare namespace Components {
373
417
  /**
374
418
  * A set of [price](/api/pricing#tag/simple_price_schema) components that define the composite price.
375
419
  */
376
- price_components?: {
420
+ price_components?: /* A set of [price](/api/pricing#tag/simple_price_schema) components that define the composite price. */ /**
421
+ * The price entity schema for simple pricing
422
+ * example:
423
+ * {
424
+ * "$ref": "#/components/examples/price"
425
+ * }
426
+ */
427
+ Price[] | {
377
428
  $relation?: PriceComponentRelation[];
378
429
  };
379
430
  /**
@@ -543,29 +594,6 @@ declare namespace Components {
543
594
  * The id of the price.
544
595
  */
545
596
  price_id?: string;
546
- /**
547
- * The unit amount value
548
- */
549
- unit_amount?: number;
550
- /**
551
- * Three-letter ISO currency code, in lowercase.
552
- */
553
- unit_amount_currency?: /* Three-letter ISO currency code, in lowercase. */ /**
554
- * Three-letter ISO currency code, in lowercase. Must be a supported currency.
555
- * ISO 4217 CURRENCY CODES as specified in the documentation: https://www.iso.org/iso-4217-currency-codes.html
556
- *
557
- * example:
558
- * EUR
559
- */
560
- Currency;
561
- /**
562
- * The unit amount in cents to be charged, represented as a decimal string with at most 12 decimal places.
563
- */
564
- unit_amount_decimal?: string;
565
- /**
566
- * The flag for prices that contain price components.
567
- */
568
- is_composite_price?: boolean;
569
597
  /**
570
598
  * The taxes applied to the price item.
571
599
  */
@@ -574,21 +602,6 @@ declare namespace Components {
574
602
  * The taxes applied to the price item.
575
603
  */
576
604
  recurrences?: (/* An amount associated with a specific recurrence. */ RecurrenceAmountDto)[];
577
- _price?: /**
578
- * The price entity schema for simple pricing
579
- * example:
580
- * {
581
- * "$ref": "#/components/examples/price"
582
- * }
583
- */
584
- Price | /**
585
- * The price entity schema for dynamic pricing
586
- * example:
587
- * {
588
- * "$ref": "#/components/examples/composite-price"
589
- * }
590
- */
591
- CompositePrice;
592
605
  _product?: /**
593
606
  * The product entity
594
607
  * example:
@@ -600,7 +613,15 @@ declare namespace Components {
600
613
  /**
601
614
  * Contains price item configurations, per price component, when the main price item is a [composite price](/api/pricing#tag/dynamic_price_schema).
602
615
  */
603
- item_components?: /* Represents a valid price item from a client. */ PriceItemDto[];
616
+ item_components?: /* Represents a price input to the pricing library. */ PriceItemDto[];
617
+ _price?: /**
618
+ * The price entity schema for dynamic pricing
619
+ * example:
620
+ * {
621
+ * "$ref": "#/components/examples/composite-price"
622
+ * }
623
+ */
624
+ CompositePrice;
604
625
  }
605
626
  /**
606
627
  * Three-letter ISO currency code, in lowercase. Must be a supported currency.
@@ -621,6 +642,36 @@ declare namespace Components {
621
642
  email?: string;
622
643
  phone?: string;
623
644
  }
645
+ export type EntityId = string; // uuid
646
+ /**
647
+ * example:
648
+ * {
649
+ * "_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
650
+ * "_org": "123",
651
+ * "_schema": "contact",
652
+ * "_tags": [
653
+ * "example",
654
+ * "mock"
655
+ * ],
656
+ * "_created_at": "2021-02-09T12:41:43.662Z",
657
+ * "_updated_at": "2021-02-09T12:41:43.662Z"
658
+ * }
659
+ */
660
+ export interface EntityItem {
661
+ _id: EntityId /* uuid */;
662
+ /**
663
+ * Title of entity
664
+ */
665
+ _title: string;
666
+ /**
667
+ * Organization Id the entity belongs to
668
+ */
669
+ _org: string;
670
+ _schema: string;
671
+ _tags?: string[];
672
+ _created_at: string; // date-time
673
+ _updated_at: string; // date-time
674
+ }
624
675
  export interface EntityRelation {
625
676
  [name: string]: any;
626
677
  entity_id?: string;
@@ -631,6 +682,14 @@ declare namespace Components {
631
682
  * Error message
632
683
  */
633
684
  message: string;
685
+ /**
686
+ * The HTTP status code
687
+ */
688
+ status?: number;
689
+ /**
690
+ * The cause of the error (visible for bad requests - http 400)
691
+ */
692
+ cause?: string;
634
693
  }
635
694
  export interface File {
636
695
  [name: string]: any;
@@ -1119,9 +1178,30 @@ declare namespace Components {
1119
1178
  /**
1120
1179
  * The default tax rate applied to the price
1121
1180
  */
1122
- tax?: {
1181
+ tax?: /* The default tax rate applied to the price */ {
1123
1182
  $relation?: EntityRelation[];
1124
- };
1183
+ } | /**
1184
+ * the tax configuration
1185
+ * example:
1186
+ * {
1187
+ * "_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
1188
+ * "type": "VAT",
1189
+ * "description": "Tax description",
1190
+ * "behavior": "Exclusive",
1191
+ * "active": "true",
1192
+ * "region": "DE",
1193
+ * "region_label": "Germany",
1194
+ * "_org": "123",
1195
+ * "_schema": "tax",
1196
+ * "_tags": [
1197
+ * "example",
1198
+ * "mock"
1199
+ * ],
1200
+ * "_created_at": "2021-02-09T12:41:43.662Z",
1201
+ * "_updated_at": "2021-02-09T12:41:43.662Z"
1202
+ * }
1203
+ */
1204
+ Tax[];
1125
1205
  /**
1126
1206
  * Specifies whether the price is considered `inclusive` of taxes or `exclusive` of taxes.
1127
1207
  * One of `inclusive`, `exclusive`, or `unspecified`.
@@ -1231,14 +1311,6 @@ declare namespace Components {
1231
1311
  *
1232
1312
  */
1233
1313
  quantity?: number;
1234
- item?: /**
1235
- * The price entity schema for simple pricing
1236
- * example:
1237
- * {
1238
- * "$ref": "#/components/examples/price"
1239
- * }
1240
- */
1241
- Price;
1242
1314
  /**
1243
1315
  * An arbitrary set of tags attached to the composite price - component relation
1244
1316
  */
@@ -1344,7 +1416,7 @@ declare namespace Components {
1344
1416
  recurrences?: (/* An amount associated with a specific recurrence. */ RecurrenceAmount)[];
1345
1417
  }
1346
1418
  /**
1347
- * Represents a valid price item from a client.
1419
+ * Represents a price input to the pricing library.
1348
1420
  */
1349
1421
  export interface PriceItemDto {
1350
1422
  metadata?: /* A set of key-value pairs used to store meta data information about an entity. */ MetaData;
@@ -1364,29 +1436,6 @@ declare namespace Components {
1364
1436
  * The id of the price.
1365
1437
  */
1366
1438
  price_id?: string;
1367
- /**
1368
- * The unit amount value
1369
- */
1370
- unit_amount?: number;
1371
- /**
1372
- * Three-letter ISO currency code, in lowercase.
1373
- */
1374
- unit_amount_currency?: /* Three-letter ISO currency code, in lowercase. */ /**
1375
- * Three-letter ISO currency code, in lowercase. Must be a supported currency.
1376
- * ISO 4217 CURRENCY CODES as specified in the documentation: https://www.iso.org/iso-4217-currency-codes.html
1377
- *
1378
- * example:
1379
- * EUR
1380
- */
1381
- Currency;
1382
- /**
1383
- * The unit amount in cents to be charged, represented as a decimal string with at most 12 decimal places.
1384
- */
1385
- unit_amount_decimal?: string;
1386
- /**
1387
- * The flag for prices that contain price components.
1388
- */
1389
- is_composite_price?: boolean;
1390
1439
  /**
1391
1440
  * The taxes applied to the price item.
1392
1441
  */
@@ -1395,32 +1444,30 @@ declare namespace Components {
1395
1444
  * The taxes applied to the price item.
1396
1445
  */
1397
1446
  recurrences?: (/* An amount associated with a specific recurrence. */ RecurrenceAmountDto)[];
1398
- _price?: /**
1399
- * The price entity schema for simple pricing
1447
+ _product?: /**
1448
+ * The product entity
1400
1449
  * example:
1401
1450
  * {
1402
- * "$ref": "#/components/examples/price"
1451
+ * "$ref": "#/components/examples/product"
1403
1452
  * }
1404
1453
  */
1405
- Price | /**
1406
- * The price entity schema for dynamic pricing
1407
- * example:
1408
- * {
1409
- * "$ref": "#/components/examples/composite-price"
1410
- * }
1454
+ Product;
1455
+ /**
1456
+ * The unit amount value
1411
1457
  */
1412
- CompositePrice;
1458
+ unit_amount?: number;
1413
1459
  /**
1414
- * The product linked to the price item.
1460
+ * The unit amount in cents to be charged, represented as a decimal string with at most 12 decimal places.
1415
1461
  */
1416
- _product?: /**
1417
- * The product entity
1462
+ unit_amount_decimal?: string;
1463
+ _price?: /**
1464
+ * The price entity schema for simple pricing
1418
1465
  * example:
1419
1466
  * {
1420
- * "$ref": "#/components/examples/product"
1467
+ * "$ref": "#/components/examples/price"
1421
1468
  * }
1422
1469
  */
1423
- Product;
1470
+ Price;
1424
1471
  }
1425
1472
  /**
1426
1473
  * Tracks a set of product prices, quantities, (discounts) and taxes.
@@ -1443,7 +1490,7 @@ declare namespace Components {
1443
1490
  /**
1444
1491
  * A valid set of product prices, quantities, (discounts) and taxes from a client.
1445
1492
  */
1446
- export type PriceItemsDto = (/* Represents a valid price item from a client. */ PriceItemDto)[];
1493
+ export type PriceItemsDto = (/* Represents a price input to the pricing library. */ PriceItemDto)[];
1447
1494
  /**
1448
1495
  * The result from the calculation of a set of price items.
1449
1496
  */
@@ -1560,7 +1607,7 @@ declare namespace Components {
1560
1607
  /**
1561
1608
  * The price type.
1562
1609
  */
1563
- type: string;
1610
+ type?: string;
1564
1611
  /**
1565
1612
  * The price billing period.
1566
1613
  */
@@ -1585,7 +1632,7 @@ declare namespace Components {
1585
1632
  /**
1586
1633
  * The price type.
1587
1634
  */
1588
- type: string;
1635
+ type?: string;
1589
1636
  /**
1590
1637
  * The price billing period.
1591
1638
  */
@@ -1606,13 +1653,44 @@ declare namespace Components {
1606
1653
  export type SalesTax = "nontaxable" | "reduced" | "standard";
1607
1654
  /**
1608
1655
  * the tax configuration
1656
+ * example:
1657
+ * {
1658
+ * "_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
1659
+ * "type": "VAT",
1660
+ * "description": "Tax description",
1661
+ * "behavior": "Exclusive",
1662
+ * "active": "true",
1663
+ * "region": "DE",
1664
+ * "region_label": "Germany",
1665
+ * "_org": "123",
1666
+ * "_schema": "tax",
1667
+ * "_tags": [
1668
+ * "example",
1669
+ * "mock"
1670
+ * ],
1671
+ * "_created_at": "2021-02-09T12:41:43.662Z",
1672
+ * "_updated_at": "2021-02-09T12:41:43.662Z"
1673
+ * }
1609
1674
  */
1610
1675
  export interface Tax {
1611
1676
  [name: string]: any;
1677
+ _id: EntityId /* uuid */;
1678
+ /**
1679
+ * Title of entity
1680
+ */
1681
+ _title: string;
1682
+ /**
1683
+ * Organization Id the entity belongs to
1684
+ */
1685
+ _org: string;
1686
+ _schema: string;
1687
+ _tags?: string[];
1688
+ _created_at: string; // date-time
1689
+ _updated_at: string; // date-time
1612
1690
  type: "VAT" | "GST" | "Custom";
1613
1691
  description?: string;
1614
1692
  rate: number;
1615
- behavior: "Exclusive" | "Inclusive";
1693
+ behavior: "Exclusive" | "Inclusive" | "exclusive" | "inclusive";
1616
1694
  active?: boolean;
1617
1695
  region?: string;
1618
1696
  region_label?: string;
@@ -1626,26 +1704,104 @@ declare namespace Components {
1626
1704
  */
1627
1705
  amount?: number;
1628
1706
  /**
1629
- * The tax rate applied.
1707
+ * The tax rate applied. With the release of the tax management feature this field is being deprecated in favor of the tax field.
1708
+ */
1709
+ rate?: string;
1710
+ /**
1711
+ * The tax rate value applied (represented as an integer percentage, e.g, 19 or 7).
1712
+ * With the release of the tax management feature this field is being deprecated in favor of the tax field.
1713
+ *
1714
+ * example:
1715
+ * 19
1716
+ */
1717
+ rateValue?: number;
1718
+ /**
1719
+ * The tax applied.
1720
+ */
1721
+ tax?: /* The tax applied. */ /**
1722
+ * the tax configuration
1723
+ * example:
1724
+ * {
1725
+ * "_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
1726
+ * "type": "VAT",
1727
+ * "description": "Tax description",
1728
+ * "behavior": "Exclusive",
1729
+ * "active": "true",
1730
+ * "region": "DE",
1731
+ * "region_label": "Germany",
1732
+ * "_org": "123",
1733
+ * "_schema": "tax",
1734
+ * "_tags": [
1735
+ * "example",
1736
+ * "mock"
1737
+ * ],
1738
+ * "_created_at": "2021-02-09T12:41:43.662Z",
1739
+ * "_updated_at": "2021-02-09T12:41:43.662Z"
1740
+ * }
1741
+ */
1742
+ Tax;
1743
+ }
1744
+ /**
1745
+ * A tax amount associated with a specific tax rate.
1746
+ */
1747
+ export interface TaxAmountBreakdown {
1748
+ /**
1749
+ * The tax amount.
1750
+ */
1751
+ amount?: number;
1752
+ /**
1753
+ * The tax rate applied. With the release of the tax manager feature this field is being deprecated in favor of the tax field.
1630
1754
  */
1631
1755
  rate?: string;
1756
+ /**
1757
+ * The tax rate value applied. With the release of the tax manager feature this field is being deprecated in favor of the tax field.
1758
+ */
1759
+ rateValue?: number;
1632
1760
  /**
1633
1761
  * The tax applied.
1634
1762
  */
1635
- tax?: /* The tax applied. */ /* the tax configuration */ Tax;
1763
+ tax?: /* The tax applied. */ TaxBreakdownInfo;
1636
1764
  }
1637
1765
  /**
1638
1766
  * A valid tax rate from a client.
1639
1767
  */
1640
1768
  export interface TaxAmountDto {
1641
1769
  /**
1642
- * The tax rate applied.
1770
+ * The deprecated tax rate applied.
1771
+ * This field has been deprecated in favor of the new Tax Management. You should use the new tax fields pointing to a proper tax entity.
1772
+ *
1643
1773
  */
1644
1774
  rate?: string;
1645
1775
  /**
1646
1776
  * The tax applied.
1647
1777
  */
1648
- tax?: /* The tax applied. */ /* the tax configuration */ Tax;
1778
+ tax?: /* The tax applied. */ /**
1779
+ * the tax configuration
1780
+ * example:
1781
+ * {
1782
+ * "_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
1783
+ * "type": "VAT",
1784
+ * "description": "Tax description",
1785
+ * "behavior": "Exclusive",
1786
+ * "active": "true",
1787
+ * "region": "DE",
1788
+ * "region_label": "Germany",
1789
+ * "_org": "123",
1790
+ * "_schema": "tax",
1791
+ * "_tags": [
1792
+ * "example",
1793
+ * "mock"
1794
+ * ],
1795
+ * "_created_at": "2021-02-09T12:41:43.662Z",
1796
+ * "_updated_at": "2021-02-09T12:41:43.662Z"
1797
+ * }
1798
+ */
1799
+ Tax;
1800
+ }
1801
+ export interface TaxBreakdownInfo {
1802
+ rate?: number;
1803
+ type?: "VAT" | "GST" | "Custom";
1804
+ _id?: string;
1649
1805
  }
1650
1806
  /**
1651
1807
  * The total details with tax (and discount) aggregated totals.
@@ -1666,7 +1822,7 @@ declare namespace Components {
1666
1822
  /**
1667
1823
  * The aggregated price items tax amount per rate.
1668
1824
  */
1669
- taxes?: (/* A tax amount associated with a specific tax rate. */ TaxAmount)[];
1825
+ taxes?: (/* A tax amount associated with a specific tax rate. */ TaxAmountBreakdown)[];
1670
1826
  /**
1671
1827
  * The aggregated price items tax amount per rate.
1672
1828
  */