@owlmeans/payment 0.1.18-rc.29 → 0.1.18-rc.30

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 (46) hide show
  1. package/README.md +2 -2
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/payment/SKILL.md +33 -1
  4. package/build/advertise.js +9 -2
  5. package/build/advertise.js.map +1 -1
  6. package/build/consts.d.ts +32 -0
  7. package/build/consts.d.ts.map +1 -1
  8. package/build/consts.js +44 -0
  9. package/build/consts.js.map +1 -1
  10. package/build/countries.d.ts +22 -0
  11. package/build/countries.d.ts.map +1 -0
  12. package/build/countries.js +66 -0
  13. package/build/countries.js.map +1 -0
  14. package/build/estimate.d.ts +57 -0
  15. package/build/estimate.d.ts.map +1 -0
  16. package/build/estimate.js +93 -0
  17. package/build/estimate.js.map +1 -0
  18. package/build/index.d.ts +2 -0
  19. package/build/index.d.ts.map +1 -1
  20. package/build/index.js +2 -0
  21. package/build/index.js.map +1 -1
  22. package/build/model/estimate.d.ts +5 -0
  23. package/build/model/estimate.d.ts.map +1 -0
  24. package/build/model/estimate.js +91 -0
  25. package/build/model/estimate.js.map +1 -0
  26. package/build/model/index.d.ts +1 -0
  27. package/build/model/index.d.ts.map +1 -1
  28. package/build/model/index.js +1 -0
  29. package/build/model/index.js.map +1 -1
  30. package/build/service.d.ts.map +1 -1
  31. package/build/service.js +10 -1
  32. package/build/service.js.map +1 -1
  33. package/build/types.d.ts +83 -1
  34. package/build/types.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/advertise.ts +9 -2
  37. package/src/consts.ts +48 -0
  38. package/src/countries.ts +71 -0
  39. package/src/estimate.ts +115 -0
  40. package/src/index.ts +2 -0
  41. package/src/model/estimate.ts +97 -0
  42. package/src/model/index.ts +1 -0
  43. package/src/service.ts +16 -2
  44. package/src/types.ts +89 -1
  45. package/tests/contract.spec.ts +60 -3
  46. package/tests/estimate.spec.ts +121 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@ server integration (`@owlmeans/server-payment`) implements against these contrac
8
8
  ## Installation
9
9
 
10
10
  ```bash
11
- bun add @owlmeans/payment@^0.1.18-rc.29
11
+ bun add @owlmeans/payment@^0.1.18-rc.30
12
12
  ```
13
13
 
14
14
  ## Concepts
@@ -129,7 +129,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
129
129
  your project's skill store (`.agents/skills/`):
130
130
 
131
131
  ```sh
132
- npx @owlmeans/agent-skills@^0.1.18-rc.28
132
+ npx @owlmeans/agent-skills@^0.1.18-rc.29
133
133
  ```
134
134
 
135
135
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/payment",
4
- "version": "0.1.18-rc.29",
5
- "generatedAt": "2026-09-16T17:32:31.941Z",
4
+ "version": "0.1.18-rc.30",
5
+ "generatedAt": "2026-09-18T19:03:53.989Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/payment
9
9
 
10
10
  **Layer:** Core
11
- **Install:** `"@owlmeans/payment": "^0.1.18-rc.29"` in `dependencies`
11
+ **Install:** `"@owlmeans/payment": "^0.1.18-rc.30"` in `dependencies`
12
12
 
13
13
  The contracts half of payments: the catalogue (products, plans, localizations), amount- and
14
14
  quantity-priced checkout, and the entitlement model — plan capabilities, counted limits, promos,
@@ -35,6 +35,9 @@ admission, the usage ledger, the two gate services — is the `entitlements` ski
35
35
  | `capabilityViewsOf` · `limitViewsOf` · `entitlementViewOf` · `reviveEntitlementView` · `capabilityOf` · `limitOf` · `hasLimitRoom` | Pure view builders and readers. |
36
36
  | `CreateCheckoutBody` (`planSku`) · `CreateCheckoutResponse` · `PortalLinkBody` · `PortalLinkResponse` (+ schemas) | Wire shapes an application's own checkout and portal protocols use. |
37
37
  | `CheckoutPricingMode` · `AmountCheckoutPolicy` / `QuantityCheckoutPolicy` (+ schemas) · `assertAmountCheckoutPolicy` · `assertQuantityCheckoutPolicy` · `assertCheckoutAmount` · `chargeAmountMinor` | Checkout pricing policies and their validation. |
38
+ | `PricingPolicy` (+ schema) · `DEFAULT_PRICING_POLICY` · `assertPricingPolicy` · `TaxBehavior` · `TaxEstimateStatus` · `TaxType` (+ schemas) | Declared tax/currency behaviour (see § Pricing policy and tax estimate). |
39
+ | `PriceEstimate` · `PriceEstimateBody` · `TaxEstimate` · `TaxRateEstimate` (+ schemas) · `estimateOf` · `ratePpmOf` | The tax/local-currency estimate read model and its pure math. |
40
+ | `COUNTRY_CURRENCIES` · `currencyOfCountry` · `COUNTRY_CODES` · `CountrySchema` | ISO 3166-1 → ISO 4217 reference map for a country picker. |
38
41
  | `EntitlementRefusal` · `CapabilityRequired` · `LimitExhausted` | Refusals — all `AuthForbidden`. |
39
42
  | `PaymentError` · `PaygateError` · `UnknownPaygate` · `PaygateMappingError` · `WebhookSetupError` · `PortalUnavailable` · `ProductError` · `UnknownProduct` · `UnknownPlan` · `PlanRequired` · `PlanRankConflict` · `LimitUnknown` · `LimitMisdeclared` · `PaymentIdentificationError` · `SubscriptionError` · `UnknownSubscription` | Faults (500), except `PortalUnavailable` (409). Importing the package registers every type's message under `errors.<type>` in the seven languages. |
40
43
 
@@ -206,6 +209,35 @@ to `amountMinor`, not the adjusted checkout subtotal or tax-inclusive total.
206
209
  Quantity checkout remains supported. It uses its reusable unit price and quantity policy; do not
207
210
  infer a pricing mode from the presence of `amountMinor`.
208
211
 
212
+ ## Pricing policy and tax estimate
213
+
214
+ `PricingPolicy` (a `PRICING_POLICY_RECORD_ID` singleton config record, `declarePaymentPricing` in
215
+ `@owlmeans/server-payment`) is what a checkout-owning application declares once for tax and
216
+ currency behaviour: `tax.automatic` (Stripe Tax on the session), `tax.behavior` (a synced price's
217
+ `TaxBehavior.Exclusive`/`Inclusive`, absent = leave it `unspecified`), `tax.collectTaxId`,
218
+ `tax.estimate` / `currency.estimate` (serve a tax/local-currency estimate endpoint — the estimate
219
+ requires `tax.automatic`, the currency one requires `currency.adaptive`), `currency.adaptive`
220
+ (Stripe Adaptive Pricing on the session). `PaymentService.pricingPolicy()` reads the declared record
221
+ or `DEFAULT_PRICING_POLICY` — the fixed behaviour every checkout had before this policy existed
222
+ (automatic tax and tax-id collection on, no forced behavior, no Adaptive Pricing, no estimate), so
223
+ an application that declares nothing sees no change.
224
+
225
+ `PriceEstimate` (built by `@owlmeans/server-payment`'s gateway, `estimatePrice`) is the read model:
226
+ `country`/`source` (`'request'`/`'customer'`), `currency`, `behavior`, `tax: TaxEstimate` (`status`
227
+ one of `TaxEstimateStatus` — `taxed`/`reverse-charge`/`none`/`at-checkout`/`location-required` —
228
+ plus `subtotalMinor`/`taxMinor`/`totalMinor`, `scalable`, and `rates: TaxRateEstimate[]` with
229
+ `ratePpm` parsed by `ratePpmOf` from Stripe's `percentage_decimal`, never `Number(x) * 10_000`),
230
+ and an optional `local` (currency + `exchangeRate`, from Stripe's FX Quotes). The pure helper
231
+ `estimateOf(amountMinor, estimate)` re-derives tax and a total for a DIFFERENT amount than the
232
+ estimate's own reference one — exact only when `scalable` and the behavior is `Exclusive`; both
233
+ `taxMinor`/`totalMinor` come back `null` otherwise, meaning "computed at checkout", never a wrong
234
+ number. When the source estimate carries `local`, the result's own `local` gives the subtotal, tax
235
+ and total in THAT currency (`subtotalAmount`/`taxAmount`/`totalAmount`, major units) alongside the
236
+ integration-currency ones — a UI shows one or the other, marking the local figures `≈`, never both
237
+ side by side. `COUNTRY_CURRENCIES` / `currencyOfCountry` / `COUNTRY_CODES` is a reference ISO 3166-1 →
238
+ ISO 4217 map for a country picker and the local-currency lookup — not a Stripe list, and a country
239
+ absent from it still gets a tax estimate, just no local-currency line.
240
+
209
241
  ## `shallowAuthentication` identifies, it does not authorize
210
242
 
211
243
  It reads the `profileId` out of an envelope token WITHOUT verifying the signature, and throws
@@ -1,7 +1,14 @@
1
1
  import { CONFIG_RECORD } from '@owlmeans/context';
2
2
  import { apiConfigPlugin, every } from '@owlmeans/api-config';
3
- import { L10N_RECORD_TYPE, PLAN_RECORD_TYPE, PRODUCT_RECORD_TYPE } from './consts.js';
4
- const advertisedRecordTypes = new Set([L10N_RECORD_TYPE, PLAN_RECORD_TYPE, PRODUCT_RECORD_TYPE]);
3
+ import { L10N_RECORD_TYPE, PLAN_RECORD_TYPE, PRICING_POLICY_RECORD_TYPE, PRODUCT_RECORD_TYPE } from './consts.js';
4
+ /**
5
+ * The pricing policy record carries only flags and TTLs (never a Stripe secret, an API version, or
6
+ * a migration switch — those stay in a backend-only plugin), so advertising it to the browser is
7
+ * safe.
8
+ */
9
+ const advertisedRecordTypes = new Set([
10
+ L10N_RECORD_TYPE, PLAN_RECORD_TYPE, PRODUCT_RECORD_TYPE, PRICING_POLICY_RECORD_TYPE,
11
+ ]);
5
12
  apiConfigPlugin({
6
13
  allow: {
7
14
  [CONFIG_RECORD]: every(true, value => value != null && typeof value === 'object'
@@ -1 +1 @@
1
- {"version":3,"file":"advertise.js","sourceRoot":"","sources":["../src/advertise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAErF,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAEhG,eAAe,CAAC;IACd,KAAK,EAAE;QACL,CAAC,aAAa,CAAC,EAAE,KAAK,CACpB,IAAI,EACJ,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;eAC9C,qBAAqB,CAAC,GAAG,CAAE,KAAiC,CAAC,UAAU,IAAI,EAAE,CAAC,CACpF;KACF;CACF,CAAC,CAAA"}
1
+ {"version":3,"file":"advertise.js","sourceRoot":"","sources":["../src/advertise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjH;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,0BAA0B;CACpF,CAAC,CAAA;AAEF,eAAe,CAAC;IACd,KAAK,EAAE;QACL,CAAC,aAAa,CAAC,EAAE,KAAK,CACpB,IAAI,EACJ,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;eAC9C,qBAAqB,CAAC,GAAG,CAAE,KAAiC,CAAC,UAAU,IAAI,EAAE,CAAC,CACpF;KACF;CACF,CAAC,CAAA"}
package/build/consts.d.ts CHANGED
@@ -71,6 +71,32 @@ export declare enum PortalFlow {
71
71
  Change = "change",
72
72
  PaymentMethod = "payment-method"
73
73
  }
74
+ /** Whether a price's amount includes tax, or tax is added on top — never inferred, always declared. */
75
+ export declare enum TaxBehavior {
76
+ Exclusive = "exclusive",
77
+ Inclusive = "inclusive"
78
+ }
79
+ /** What a price estimate says about tax at one billing country. */
80
+ export declare enum TaxEstimateStatus {
81
+ /** Tax is due and its rate(s) are in `TaxEstimate.rates`. */
82
+ Taxed = "taxed",
83
+ /** No tax because the buyer's tax id shifts liability to them (EU/GB reverse charge). */
84
+ ReverseCharge = "reverse-charge",
85
+ /** No tax for any other reason (not registered there, exempt, zero-rated). */
86
+ None = "none",
87
+ /** The gateway could not resolve a rate from what it was given; the real total shows at checkout. */
88
+ AtCheckout = "at-checkout",
89
+ /** No country was given and none could be inferred from the entity's paygate customer. */
90
+ LocationRequired = "location-required"
91
+ }
92
+ /** A tax type a rate carries, collapsed from Stripe's finer `tax_type` for display. */
93
+ export declare enum TaxType {
94
+ Vat = "vat",
95
+ Gst = "gst",
96
+ SalesTax = "sales-tax",
97
+ /** Any other Stripe `tax_type` (excise, lease, tourism, …). */
98
+ Tax = "tax"
99
+ }
74
100
  /** The paygate alias of subscriptions the application grants itself (a free plan, a comp). */
75
101
  export declare const INTERNAL_PAYGATE = "internal";
76
102
  export declare const ProductTypeSchema: JSONSchemaType<ProductType>;
@@ -82,6 +108,9 @@ export declare const SubscriptionStatusSchema: JSONSchemaType<SubscriptionStatus
82
108
  export declare const LimitKindSchema: JSONSchemaType<LimitKind>;
83
109
  export declare const LimitWindowSchema: JSONSchemaType<LimitWindow>;
84
110
  export declare const PortalFlowSchema: JSONSchemaType<PortalFlow>;
111
+ export declare const TaxBehaviorSchema: JSONSchemaType<TaxBehavior>;
112
+ export declare const TaxEstimateStatusSchema: JSONSchemaType<TaxEstimateStatus>;
113
+ export declare const TaxTypeSchema: JSONSchemaType<TaxType>;
85
114
  export declare const ProductTitleSchema: JSONSchemaType<string>;
86
115
  export declare const ProductDescriptionSchema: JSONSchemaType<string>;
87
116
  export declare const LocalizationLngSchema: JSONSchemaType<string>;
@@ -91,6 +120,9 @@ export declare const PLAN_RECORD_TYPE = "plan";
91
120
  export declare const PLAN_RECORD_PREFIX = "plan";
92
121
  export declare const L10N_RECORD_TYPE = "l10n";
93
122
  export declare const L10N_RECORD_PREFIX = "l10n";
123
+ /** A singleton record: at most one per configuration, at this fixed id. */
124
+ export declare const PRICING_POLICY_RECORD_TYPE = "pricing-policy";
125
+ export declare const PRICING_POLICY_RECORD_ID = "pricing-policy";
94
126
  export declare const DEFAULT_ALIAS = "payment";
95
127
  export declare const PAYMENT_SERVICE = "payment";
96
128
  //# sourceMappingURL=consts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRo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AM,aAAa,EAAE,cAAc,CAAC,OAAO,CAGjD,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,MAAM,CAErD,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,MAAM,CAE3D,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,MAAM,CAExD,CAAA;AAED,eAAO,MAAM,mBAAmB,YAAY,CAAA;AAC5C,eAAO,MAAM,qBAAqB,YAAsB,CAAA;AAExD,eAAO,MAAM,gBAAgB,SAAS,CAAA;AACtC,eAAO,MAAM,kBAAkB,SAAmB,CAAA;AAElD,eAAO,MAAM,gBAAgB,SAAS,CAAA;AACtC,eAAO,MAAM,kBAAkB,SAAmB,CAAA;AAElD,2EAA2E;AAC3E,eAAO,MAAM,0BAA0B,mBAAmB,CAAA;AAC1D,eAAO,MAAM,wBAAwB,mBAA6B,CAAA;AAElE,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC,eAAO,MAAM,eAAe,YAAgB,CAAA"}
package/build/consts.js CHANGED
@@ -84,6 +84,35 @@ export var PortalFlow;
84
84
  PortalFlow["Change"] = "change";
85
85
  PortalFlow["PaymentMethod"] = "payment-method";
86
86
  })(PortalFlow || (PortalFlow = {}));
87
+ /** Whether a price's amount includes tax, or tax is added on top — never inferred, always declared. */
88
+ export var TaxBehavior;
89
+ (function (TaxBehavior) {
90
+ TaxBehavior["Exclusive"] = "exclusive";
91
+ TaxBehavior["Inclusive"] = "inclusive";
92
+ })(TaxBehavior || (TaxBehavior = {}));
93
+ /** What a price estimate says about tax at one billing country. */
94
+ export var TaxEstimateStatus;
95
+ (function (TaxEstimateStatus) {
96
+ /** Tax is due and its rate(s) are in `TaxEstimate.rates`. */
97
+ TaxEstimateStatus["Taxed"] = "taxed";
98
+ /** No tax because the buyer's tax id shifts liability to them (EU/GB reverse charge). */
99
+ TaxEstimateStatus["ReverseCharge"] = "reverse-charge";
100
+ /** No tax for any other reason (not registered there, exempt, zero-rated). */
101
+ TaxEstimateStatus["None"] = "none";
102
+ /** The gateway could not resolve a rate from what it was given; the real total shows at checkout. */
103
+ TaxEstimateStatus["AtCheckout"] = "at-checkout";
104
+ /** No country was given and none could be inferred from the entity's paygate customer. */
105
+ TaxEstimateStatus["LocationRequired"] = "location-required";
106
+ })(TaxEstimateStatus || (TaxEstimateStatus = {}));
107
+ /** A tax type a rate carries, collapsed from Stripe's finer `tax_type` for display. */
108
+ export var TaxType;
109
+ (function (TaxType) {
110
+ TaxType["Vat"] = "vat";
111
+ TaxType["Gst"] = "gst";
112
+ TaxType["SalesTax"] = "sales-tax";
113
+ /** Any other Stripe `tax_type` (excise, lease, tourism, …). */
114
+ TaxType["Tax"] = "tax";
115
+ })(TaxType || (TaxType = {}));
87
116
  /** The paygate alias of subscriptions the application grants itself (a free plan, a comp). */
88
117
  export const INTERNAL_PAYGATE = 'internal';
89
118
  export const ProductTypeSchema = {
@@ -122,6 +151,18 @@ export const PortalFlowSchema = {
122
151
  type: 'string',
123
152
  enum: Object.values(PortalFlow)
124
153
  };
154
+ export const TaxBehaviorSchema = {
155
+ type: 'string',
156
+ enum: Object.values(TaxBehavior)
157
+ };
158
+ export const TaxEstimateStatusSchema = {
159
+ type: 'string',
160
+ enum: Object.values(TaxEstimateStatus)
161
+ };
162
+ export const TaxTypeSchema = {
163
+ type: 'string',
164
+ enum: Object.values(TaxType)
165
+ };
125
166
  export const ProductTitleSchema = {
126
167
  type: 'string', minLength: 1, maxLength: 128
127
168
  };
@@ -137,6 +178,9 @@ export const PLAN_RECORD_TYPE = 'plan';
137
178
  export const PLAN_RECORD_PREFIX = PLAN_RECORD_TYPE;
138
179
  export const L10N_RECORD_TYPE = 'l10n';
139
180
  export const L10N_RECORD_PREFIX = L10N_RECORD_TYPE;
181
+ /** A singleton record: at most one per configuration, at this fixed id. */
182
+ export const PRICING_POLICY_RECORD_TYPE = 'pricing-policy';
183
+ export const PRICING_POLICY_RECORD_ID = PRICING_POLICY_RECORD_TYPE;
140
184
  export const DEFAULT_ALIAS = 'payment';
141
185
  export const PAYMENT_SERVICE = DEFAULT_ALIAS;
142
186
  //# sourceMappingURL=consts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,wCAAyB,CAAA;AAC3B,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAED,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,4CAAqB,CAAA;IACrB,wCAAiB,CAAA;AACnB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AAED,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,kCAAa,CAAA;IACb,qDAAgC,CAAA;AAClC,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B;AAED,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,uCAAyB,CAAA;IACzB,qCAAuB,CAAA;AACzB,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB;AAED,MAAM,CAAN,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB;;;OAGG;IACH,yCAAyB,CAAA;AAC3B,CAAC,EAVW,YAAY,KAAZ,YAAY,QAUvB;AAED,MAAM,CAAN,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,qCAAe,CAAA;IACf,2CAAqB,CAAA;IACrB,yCAAmB,CAAA;IACnB,mEAAmE;IACnE,6CAAuB,CAAA;IACvB,yC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4
+ * that country, for the "≈ local total" line of a price estimate. Not a Stripe list: Stripe Tax can
5
+ * compute a rate for a country this map has no entry for (or none at all, `location-required`), and
6
+ * `currencyOfCountry` returning `null` just means the estimate carries no local-currency line, never
7
+ * a rejected request.
8
+ *
9
+ * A territory that circulates another country's currency (Ecuador, Kosovo, Puerto Rico, …) is
10
+ * mapped to that currency, not left out.
11
+ */
12
+ export declare const COUNTRY_CURRENCIES: Readonly<Record<string, string>>;
13
+ export declare const COUNTRY_CODES: readonly string[];
14
+ /** The lowercase ISO 4217 currency of a country, or `null` when this map has no entry for it. */
15
+ export declare const currencyOfCountry: (country: string) => string | null;
16
+ /**
17
+ * A permissive ISO 3166-1 alpha-2 shape (two uppercase letters) — not restricted to
18
+ * `COUNTRY_CURRENCIES`, so a country this map cannot name a currency for is still a valid request;
19
+ * it only loses the local-currency line of its estimate.
20
+ */
21
+ export declare const CountrySchema: JSONSchemaType<string>;
22
+ //# sourceMappingURL=countries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countries.d.ts","sourceRoot":"","sources":["../src/countries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2C9D,CAAA;AAEF,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAA0D,CAAA;AAErG,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,MAAM,GAAG,IACV,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,MAAM,CAEhD,CAAA"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ISO 3166-1 alpha-2 country code → lowercase ISO 4217 currency code — the currency circulating in
3
+ * that country, for the "≈ local total" line of a price estimate. Not a Stripe list: Stripe Tax can
4
+ * compute a rate for a country this map has no entry for (or none at all, `location-required`), and
5
+ * `currencyOfCountry` returning `null` just means the estimate carries no local-currency line, never
6
+ * a rejected request.
7
+ *
8
+ * A territory that circulates another country's currency (Ecuador, Kosovo, Puerto Rico, …) is
9
+ * mapped to that currency, not left out.
10
+ */
11
+ export const COUNTRY_CURRENCIES = Object.freeze({
12
+ AD: 'eur', AE: 'aed', AF: 'afn', AG: 'xcd', AI: 'xcd', AL: 'all', AM: 'amd', AO: 'aoa',
13
+ AR: 'ars', AS: 'usd', AT: 'eur', AU: 'aud', AW: 'awg', AX: 'eur', AZ: 'azn',
14
+ BA: 'bam', BB: 'bbd', BD: 'bdt', BE: 'eur', BF: 'xof', BG: 'bgn', BH: 'bhd', BI: 'bif',
15
+ BJ: 'xof', BL: 'eur', BM: 'bmd', BN: 'bnd', BO: 'bob', BQ: 'usd', BR: 'brl', BS: 'bsd',
16
+ BT: 'btn', BW: 'bwp', BY: 'byn', BZ: 'bzd',
17
+ CA: 'cad', CD: 'cdf', CF: 'xaf', CG: 'xaf', CH: 'chf', CI: 'xof', CK: 'nzd', CL: 'clp',
18
+ CM: 'xaf', CN: 'cny', CO: 'cop', CR: 'crc', CU: 'cup', CV: 'cve', CW: 'ang', CY: 'eur',
19
+ CZ: 'czk',
20
+ DE: 'eur', DJ: 'djf', DK: 'dkk', DM: 'xcd', DO: 'dop', DZ: 'dzd',
21
+ EC: 'usd', EE: 'eur', EG: 'egp', EH: 'mad', ER: 'ern', ES: 'eur', ET: 'etb',
22
+ FI: 'eur', FJ: 'fjd', FK: 'fkp', FM: 'usd', FO: 'dkk', FR: 'eur',
23
+ GA: 'xaf', GB: 'gbp', GD: 'xcd', GE: 'gel', GF: 'eur', GG: 'gbp', GH: 'ghs', GI: 'gip',
24
+ GL: 'dkk', GM: 'gmd', GN: 'gnf', GP: 'eur', GQ: 'xaf', GR: 'eur', GT: 'gtq', GU: 'usd',
25
+ GW: 'xof', GY: 'gyd',
26
+ HK: 'hkd', HN: 'hnl', HR: 'eur', HT: 'htg', HU: 'huf',
27
+ ID: 'idr', IE: 'eur', IL: 'ils', IM: 'gbp', IN: 'inr', IQ: 'iqd', IR: 'irr', IS: 'isk',
28
+ IT: 'eur',
29
+ JE: 'gbp', JM: 'jmd', JO: 'jod', JP: 'jpy',
30
+ KE: 'kes', KG: 'kgs', KH: 'khr', KI: 'aud', KM: 'kmf', KN: 'xcd', KP: 'kpw', KR: 'krw',
31
+ KW: 'kwd', KY: 'kyd', KZ: 'kzt',
32
+ LA: 'lak', LB: 'lbp', LC: 'xcd', LI: 'chf', LK: 'lkr', LR: 'lrd', LS: 'lsl', LT: 'eur',
33
+ LU: 'eur', LV: 'eur', LY: 'lyd',
34
+ MA: 'mad', MC: 'eur', MD: 'mdl', ME: 'eur', MF: 'eur', MG: 'mga', MH: 'usd', MK: 'mkd',
35
+ ML: 'xof', MM: 'mmk', MN: 'mnt', MO: 'mop', MQ: 'eur', MR: 'mru', MS: 'xcd', MT: 'eur',
36
+ MU: 'mur', MV: 'mvr', MW: 'mwk', MX: 'mxn', MY: 'myr', MZ: 'mzn',
37
+ NA: 'nad', NC: 'xpf', NE: 'xof', NG: 'ngn', NI: 'nio', NL: 'eur', NO: 'nok', NP: 'npr',
38
+ NR: 'aud', NU: 'nzd', NZ: 'nzd',
39
+ OM: 'omr',
40
+ PA: 'pab', PE: 'pen', PF: 'xpf', PG: 'pgk', PH: 'php', PK: 'pkr', PL: 'pln', PR: 'usd',
41
+ PS: 'ils', PT: 'eur', PW: 'usd', PY: 'pyg',
42
+ QA: 'qar',
43
+ RE: 'eur', RO: 'ron', RS: 'rsd', RU: 'rub', RW: 'rwf',
44
+ SA: 'sar', SB: 'sbd', SC: 'scr', SD: 'sdg', SE: 'sek', SG: 'sgd', SH: 'shp', SI: 'eur',
45
+ SK: 'eur', SL: 'sle', SM: 'eur', SN: 'xof', SO: 'sos', SR: 'srd', SS: 'ssp', ST: 'stn',
46
+ SV: 'usd', SX: 'ang', SY: 'syp', SZ: 'szl',
47
+ TC: 'usd', TD: 'xaf', TG: 'xof', TH: 'thb', TJ: 'tjs', TK: 'nzd', TL: 'usd', TM: 'tmt',
48
+ TN: 'tnd', TO: 'top', TR: 'try', TT: 'ttd', TV: 'aud', TW: 'twd', TZ: 'tzs',
49
+ UA: 'uah', UG: 'ugx', US: 'usd', UY: 'uyu', UZ: 'uzs',
50
+ VA: 'eur', VC: 'xcd', VE: 'ves', VG: 'usd', VI: 'usd', VN: 'vnd', VU: 'vuv',
51
+ WF: 'xpf', WS: 'wst',
52
+ YE: 'yer', YT: 'eur',
53
+ ZA: 'zar', ZM: 'zmw', ZW: 'zwl',
54
+ });
55
+ export const COUNTRY_CODES = Object.freeze(Object.keys(COUNTRY_CURRENCIES).sort());
56
+ /** The lowercase ISO 4217 currency of a country, or `null` when this map has no entry for it. */
57
+ export const currencyOfCountry = (country) => COUNTRY_CURRENCIES[country.toUpperCase()] ?? null;
58
+ /**
59
+ * A permissive ISO 3166-1 alpha-2 shape (two uppercase letters) — not restricted to
60
+ * `COUNTRY_CURRENCIES`, so a country this map cannot name a currency for is still a valid request;
61
+ * it only loses the local-currency line of its estimate.
62
+ */
63
+ export const CountrySchema = {
64
+ type: 'string', pattern: '^[A-Z]{2}$',
65
+ };
66
+ //# sourceMappingURL=countries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countries.js","sourceRoot":"","sources":["../src/countries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAqC,MAAM,CAAC,MAAM,CAAC;IAChF,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IACtF,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE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,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IACrD,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IAC3E,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IACpB,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IACpB,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;CAChC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,aAAa,GAAsB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAErG,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAiB,EAAE,CAClE,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAA;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY;CACtC,CAAA"}
@@ -0,0 +1,57 @@
1
+ import type { PriceEstimate, PricingPolicy } from './types.js';
2
+ /**
3
+ * Preserves today's fixed behavior for every consumer that declares no policy: automatic tax and
4
+ * tax-id collection stay on for every checkout (`taxOptions` before this policy existed), no
5
+ * `behavior` is forced onto a synced price, no Adaptive Pricing, and the estimate endpoints are off
6
+ * (a new capability, opt-in only).
7
+ */
8
+ export declare const DEFAULT_PRICING_POLICY: PricingPolicy;
9
+ /**
10
+ * @throws PaymentError when a tax estimate is served without automatic tax, a currency estimate is
11
+ * served without Adaptive Pricing, or a TTL is not a positive integer.
12
+ */
13
+ export declare const assertPricingPolicy: (policy: PricingPolicy) => PricingPolicy;
14
+ /**
15
+ * Stripe's `percentage_decimal` (e.g. `"23"`, `"8.875"`) as parts per million — `1_000_000` is
16
+ * `100%` — parsed digit by digit so it is exact where a float parse (`Number(x) * 10_000`) is not.
17
+ * Fractional digits past the fourth are truncated, not rounded: a quarter of a hundredth of a
18
+ * percent is already far finer than any real tax rate.
19
+ *
20
+ * @throws PaymentError when the string is not a plain (unsigned, non-exponential) decimal.
21
+ */
22
+ export declare const ratePpmOf: (percentageDecimal: string) => number;
23
+ export interface AmountEstimate {
24
+ subtotalMinor: number;
25
+ /** `null` when `estimate` cannot be rescaled to this amount (see `TaxEstimate.scalable`). */
26
+ taxMinor: number | null;
27
+ totalMinor: number | null;
28
+ /**
29
+ * The subtotal, tax and total in the country's own currency, in major units — present only
30
+ * alongside a non-`null` `totalMinor`. A UI showing `local` shows ONLY `local` for the tax and
31
+ * total (marked `≈`, since it is Stripe's own rate at read time, not the checkout rate); the
32
+ * integration-currency amounts stay the reference for bookkeeping, never a second figure to show
33
+ * alongside the converted one.
34
+ */
35
+ local?: {
36
+ currency: string;
37
+ subtotalAmount: number;
38
+ taxAmount: number;
39
+ totalAmount: number;
40
+ };
41
+ }
42
+ /**
43
+ * Re-derive tax and the local-currency total for `amountMinor` from a `PriceEstimate` already
44
+ * fetched for the SAME product/plan/country, so a UI can re-price a custom amount (the credit
45
+ * dialog) without a second Stripe Tax call ($0.05 each).
46
+ *
47
+ * Exact for `amountMinor === estimate.tax.subtotalMinor` (Stripe's own numbers, echoed back).
48
+ * Otherwise exact only for `TaxBehavior.Exclusive` with `estimate.tax.scalable` — a linear
49
+ * percentage rate scales; a flat fee, a reduced-rate portion, or several inclusive rates do not, and
50
+ * neither does rescaling an inclusive amount (its tax portion is carved OUT of the total by a
51
+ * different formula this helper does not attempt). Both cases return `null` amounts, meaning
52
+ * "computed at checkout".
53
+ *
54
+ * @throws PaymentError when `amountMinor` is not a non-negative safe integer.
55
+ */
56
+ export declare const estimateOf: (amountMinor: number, estimate: PriceEstimate) => AmountEstimate;
57
+ //# sourceMappingURL=estimate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../src/estimate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAGlB,CAAA;AAEnB;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,aAAa,KAAG,aAa3D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,sBAAuB,MAAM,KAAG,MAYrD,CAAA;AAKD,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAA;CAC7F;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,gBAAiB,MAAM,YAAY,aAAa,KAAG,cA0BzE,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { PaymentError } from './errors.js';
2
+ import { TaxBehavior } from './consts.js';
3
+ /**
4
+ * Preserves today's fixed behavior for every consumer that declares no policy: automatic tax and
5
+ * tax-id collection stay on for every checkout (`taxOptions` before this policy existed), no
6
+ * `behavior` is forced onto a synced price, no Adaptive Pricing, and the estimate endpoints are off
7
+ * (a new capability, opt-in only).
8
+ */
9
+ export const DEFAULT_PRICING_POLICY = Object.freeze({
10
+ tax: Object.freeze({ automatic: true, collectTaxId: true, estimate: false }),
11
+ currency: Object.freeze({ estimate: false }),
12
+ });
13
+ /**
14
+ * @throws PaymentError when a tax estimate is served without automatic tax, a currency estimate is
15
+ * served without Adaptive Pricing, or a TTL is not a positive integer.
16
+ */
17
+ export const assertPricingPolicy = (policy) => {
18
+ if (policy.tax.estimate && !policy.tax.automatic) {
19
+ throw new PaymentError('pricing-policy:tax-estimate-requires-automatic');
20
+ }
21
+ if (policy.currency.estimate && policy.currency.adaptive !== true) {
22
+ throw new PaymentError('pricing-policy:currency-estimate-requires-adaptive');
23
+ }
24
+ for (const ttl of [policy.tax.estimateTtlSeconds, policy.currency.estimateTtlSeconds]) {
25
+ if (ttl != null && (!Number.isSafeInteger(ttl) || ttl < 1)) {
26
+ throw new PaymentError('pricing-policy:ttl');
27
+ }
28
+ }
29
+ return policy;
30
+ };
31
+ /**
32
+ * Stripe's `percentage_decimal` (e.g. `"23"`, `"8.875"`) as parts per million — `1_000_000` is
33
+ * `100%` — parsed digit by digit so it is exact where a float parse (`Number(x) * 10_000`) is not.
34
+ * Fractional digits past the fourth are truncated, not rounded: a quarter of a hundredth of a
35
+ * percent is already far finer than any real tax rate.
36
+ *
37
+ * @throws PaymentError when the string is not a plain (unsigned, non-exponential) decimal.
38
+ */
39
+ export const ratePpmOf = (percentageDecimal) => {
40
+ const match = /^(\d+)(?:\.(\d+))?$/.exec(percentageDecimal.trim());
41
+ if (match == null) {
42
+ throw new PaymentError('tax-rate:percentage');
43
+ }
44
+ const [, whole, fraction = ''] = match;
45
+ const fractionPpm = Number(`${fraction}0000`.slice(0, 4));
46
+ const ppm = Number(whole) * 10_000 + fractionPpm;
47
+ if (!Number.isSafeInteger(ppm)) {
48
+ throw new PaymentError('tax-rate:percentage');
49
+ }
50
+ return ppm;
51
+ };
52
+ /** Stripe's own convention for a tax amount: half a unit rounds up. */
53
+ const roundHalfUp = (value) => Math.floor(value + 0.5);
54
+ /**
55
+ * Re-derive tax and the local-currency total for `amountMinor` from a `PriceEstimate` already
56
+ * fetched for the SAME product/plan/country, so a UI can re-price a custom amount (the credit
57
+ * dialog) without a second Stripe Tax call ($0.05 each).
58
+ *
59
+ * Exact for `amountMinor === estimate.tax.subtotalMinor` (Stripe's own numbers, echoed back).
60
+ * Otherwise exact only for `TaxBehavior.Exclusive` with `estimate.tax.scalable` — a linear
61
+ * percentage rate scales; a flat fee, a reduced-rate portion, or several inclusive rates do not, and
62
+ * neither does rescaling an inclusive amount (its tax portion is carved OUT of the total by a
63
+ * different formula this helper does not attempt). Both cases return `null` amounts, meaning
64
+ * "computed at checkout".
65
+ *
66
+ * @throws PaymentError when `amountMinor` is not a non-negative safe integer.
67
+ */
68
+ export const estimateOf = (amountMinor, estimate) => {
69
+ if (!Number.isSafeInteger(amountMinor) || amountMinor < 0) {
70
+ throw new PaymentError('price-estimate:amount');
71
+ }
72
+ const { tax, behavior, local } = estimate;
73
+ const sameAmount = amountMinor === tax.subtotalMinor;
74
+ const rescalable = sameAmount || (behavior === TaxBehavior.Exclusive && tax.scalable);
75
+ if (!rescalable) {
76
+ return { subtotalMinor: amountMinor, taxMinor: null, totalMinor: null };
77
+ }
78
+ // `sameAmount` trusts Stripe's own numbers outright; otherwise only Exclusive ever reaches here
79
+ // (`rescalable` above excludes an Inclusive amount that differs from the reference).
80
+ const taxMinor = sameAmount ? tax.taxMinor : tax.rates.reduce((sum, rate) => sum + roundHalfUp(amountMinor * rate.ratePpm / 1_000_000), 0);
81
+ const totalMinor = sameAmount ? tax.totalMinor : amountMinor + taxMinor;
82
+ const result = { subtotalMinor: amountMinor, taxMinor, totalMinor };
83
+ if (local != null) {
84
+ result.local = {
85
+ currency: local.currency,
86
+ subtotalAmount: amountMinor / 100 / local.exchangeRate,
87
+ taxAmount: taxMinor / 100 / local.exchangeRate,
88
+ totalAmount: totalMinor / 100 / local.exchangeRate,
89
+ };
90
+ }
91
+ return result;
92
+ };
93
+ //# sourceMappingURL=estimate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.js","sourceRoot":"","sources":["../src/estimate.ts"],"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C,QAAQ,KAAK,WAAW,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;IACrF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;IACzE,CAAC;IACD,gGAAgG;IAChG,qFAAqF;IACrF,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAC3D,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,WAAW,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,CAAC,CAC5E,CAAA;IACD,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,GAAG,QAAQ,CAAA;IACvE,MAAM,MAAM,GAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAA;IACnF,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,MAAM,CAAC,KAAK,GAAG;YACb,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,cAAc,EAAE,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY;YACtD,SAAS,EAAE,QAAQ,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY;YAC9C,WAAW,EAAE,UAAU,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY;SACnD,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
package/build/index.d.ts CHANGED
@@ -11,4 +11,6 @@ export * from './pricing.js';
11
11
  export * from './promo.js';
12
12
  export * from './limit.js';
13
13
  export * from './view.js';
14
+ export * from './countries.js';
15
+ export * from './estimate.js';
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA"}
package/build/index.js CHANGED
@@ -10,4 +10,6 @@ export * from './pricing.js';
10
10
  export * from './promo.js';
11
11
  export * from './limit.js';
12
12
  export * from './view.js';
13
+ export * from './countries.js';
14
+ export * from './estimate.js';
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { PriceEstimate, PriceEstimateBody, PricingPolicy } from '../types.js';
2
+ export declare const PricingPolicySchema: import("@owlmeans/entrypoint").EntrypointSchema<PricingPolicy>;
3
+ export declare const PriceEstimateBodySchema: import("@owlmeans/entrypoint").EntrypointSchema<PriceEstimateBody>;
4
+ export declare const PriceEstimateSchema: import("@owlmeans/entrypoint").EntrypointSchema<PriceEstimate>;
5
+ //# sourceMappingURL=estimate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/model/estimate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,EAAgC,MAAM,aAAa,CAAA;AAMhH,eAAO,MAAM,mBAAmB,gEA4BG,CAAA;AAEnC,eAAO,MAAM,uBAAuB,oEAQG,CAAA;AA6BvC,eAAO,MAAM,mBAAmB,gEAsBG,CAAA"}