@shopperlabs/shopper-types 2.5.0 → 2.6.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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Shopper Types definitions
6
6
 
7
- TypeScript types derived from the OpenAPI Spec (OAS) to be used in API clients for Laravel Shopper.
7
+ TypeScript types derived from the OpenAPI Spec (OAS) to be used in API clients for Shopper.
8
8
 
9
9
  ## Install
10
10
 
package/dist/cart.d.ts ADDED
@@ -0,0 +1,138 @@
1
+ import type { Channel } from './channel';
2
+ import type { DateEntity, Entity, Metadata } from './common';
3
+ import type { Country } from './country';
4
+ import type { Customer } from './customer';
5
+ import type { Discount } from './discount';
6
+ import type { TaxRate } from './tax';
7
+ import type { Zone } from './zone';
8
+ export declare enum CartAddressType {
9
+ BILLING = "billing",
10
+ SHIPPING = "shipping"
11
+ }
12
+ /**
13
+ * Cart model.
14
+ */
15
+ export interface Cart extends Entity {
16
+ /** The currency code for the cart. */
17
+ currency_code: string;
18
+ /** The coupon code applied to the cart. */
19
+ coupon_code: string | null;
20
+ /** The date the cart was completed (converted to order). */
21
+ completed_at: DateEntity | null;
22
+ /** The metadata of the cart. */
23
+ metadata: Metadata;
24
+ /** The customer ID. */
25
+ customer_id: number | null;
26
+ /** The channel ID. */
27
+ channel_id: number | null;
28
+ /** The zone ID. */
29
+ zone_id: number | null;
30
+ /** The cart lines. */
31
+ lines?: CartLine[];
32
+ /** The cart addresses. */
33
+ addresses?: CartAddress[];
34
+ /** The customer. */
35
+ customer?: Customer | null;
36
+ /** The channel. */
37
+ channel?: Channel | null;
38
+ /** The zone. */
39
+ zone?: Zone | null;
40
+ }
41
+ /**
42
+ * CartLine model.
43
+ */
44
+ export interface CartLine extends Entity {
45
+ /** The cart ID. */
46
+ cart_id: number;
47
+ /** The morph type of the purchasable entity. */
48
+ purchasable_type: string;
49
+ /** The morph ID of the purchasable entity. */
50
+ purchasable_id: number;
51
+ /** The quantity of the cart line. */
52
+ quantity: number;
53
+ /** The unit price amount (in cents). */
54
+ unit_price_amount: number;
55
+ /** The metadata of the cart line. */
56
+ metadata: Metadata;
57
+ /** The cart this line belongs to. */
58
+ cart?: Cart;
59
+ /** The purchasable entity (product or variant). */
60
+ purchasable?: Record<string, unknown>;
61
+ /** The price adjustments applied to this line. */
62
+ adjustments?: CartLineAdjustment[];
63
+ /** The tax lines applied to this line. */
64
+ taxLines?: CartLineTaxLine[];
65
+ }
66
+ /**
67
+ * CartAddress model.
68
+ */
69
+ export interface CartAddress extends Entity {
70
+ /** The cart ID. */
71
+ cart_id: number;
72
+ /** The address type (billing or shipping). */
73
+ type: CartAddressType;
74
+ /** The country ID. */
75
+ country_id: number | null;
76
+ /** The first name. */
77
+ first_name: string | null;
78
+ /** The last name. */
79
+ last_name: string;
80
+ /** The company name. */
81
+ company: string | null;
82
+ /** The primary street address. */
83
+ address_1: string;
84
+ /** The secondary street address. */
85
+ address_2: string | null;
86
+ /** The city. */
87
+ city: string;
88
+ /** The state/province. */
89
+ state: string | null;
90
+ /** The postal code. */
91
+ postal_code: string;
92
+ /** The phone number. */
93
+ phone: string | null;
94
+ /** The computed full name. */
95
+ full_name: string;
96
+ /** The cart this address belongs to. */
97
+ cart?: Cart;
98
+ /** The country. */
99
+ country?: Country | null;
100
+ }
101
+ /**
102
+ * CartLineAdjustment model — price adjustments (discounts) applied to a cart line.
103
+ */
104
+ export interface CartLineAdjustment extends Entity {
105
+ /** The cart line ID. */
106
+ cart_line_id: number;
107
+ /** The adjustment amount (in cents). */
108
+ amount: number;
109
+ /** The coupon/discount code. */
110
+ code: string | null;
111
+ /** The discount ID (if applied from a discount). */
112
+ discount_id: number | null;
113
+ /** The cart line this adjustment belongs to. */
114
+ cartLine?: CartLine;
115
+ /** The discount this adjustment comes from. */
116
+ discount?: Discount | null;
117
+ }
118
+ /**
119
+ * CartLineTaxLine model — tax applied to a cart line.
120
+ */
121
+ export interface CartLineTaxLine extends Entity {
122
+ /** The cart line ID. */
123
+ cart_line_id: number;
124
+ /** The tax code (e.g., "VAT", "GST"). */
125
+ code: string;
126
+ /** The tax name (e.g., "TVA 20%"). */
127
+ name: string;
128
+ /** The tax rate percentage (e.g., 20.0 for 20%). */
129
+ rate: number;
130
+ /** The calculated tax amount (in cents). */
131
+ amount: number;
132
+ /** The source tax rate ID. */
133
+ tax_rate_id: number | null;
134
+ /** The cart line this tax line belongs to. */
135
+ cartLine?: CartLine;
136
+ /** The source tax rate. */
137
+ taxRate?: TaxRate | null;
138
+ }
package/dist/cart.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CartAddressType = void 0;
4
+ var CartAddressType;
5
+ (function (CartAddressType) {
6
+ CartAddressType["BILLING"] = "billing";
7
+ CartAddressType["SHIPPING"] = "shipping";
8
+ })(CartAddressType || (exports.CartAddressType = CartAddressType = {}));
@@ -1,4 +1,8 @@
1
1
  import type { Zone } from './zone';
2
+ /**
3
+ * Check if a currency code does not use subunits (e.g., JPY, KRW).
4
+ */
5
+ export declare function isNoDivisionCurrency(currency: string): boolean;
2
6
  /**
3
7
  * Currency model.
4
8
  */
package/dist/currency.js CHANGED
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNoDivisionCurrency = isNoDivisionCurrency;
4
+ /**
5
+ * Check if a currency code does not use subunits (e.g., JPY, KRW).
6
+ */
7
+ function isNoDivisionCurrency(currency) {
8
+ return [
9
+ 'BIF', 'CLP', 'DJF', 'GNF', 'HTG', 'JPY', 'KMF', 'KRW', 'MGA',
10
+ 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XAG', 'XAU', 'XDR', 'XOF', 'XPF',
11
+ ].includes(currency);
12
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './address';
2
2
  export * from './attribute';
3
3
  export * from './brand';
4
4
  export * from './carrier';
5
+ export * from './cart';
5
6
  export * from './category';
6
7
  export * from './channel';
7
8
  export * from './collection';
@@ -20,4 +21,5 @@ export * from './product_tag';
20
21
  export * from './product';
21
22
  export * from './review';
22
23
  export * from './supplier';
24
+ export * from './tax';
23
25
  export * from './zone';
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ __exportStar(require("./address"), exports);
18
18
  __exportStar(require("./attribute"), exports);
19
19
  __exportStar(require("./brand"), exports);
20
20
  __exportStar(require("./carrier"), exports);
21
+ __exportStar(require("./cart"), exports);
21
22
  __exportStar(require("./category"), exports);
22
23
  __exportStar(require("./channel"), exports);
23
24
  __exportStar(require("./collection"), exports);
@@ -36,4 +37,5 @@ __exportStar(require("./product_tag"), exports);
36
37
  __exportStar(require("./product"), exports);
37
38
  __exportStar(require("./review"), exports);
38
39
  __exportStar(require("./supplier"), exports);
40
+ __exportStar(require("./tax"), exports);
39
41
  __exportStar(require("./zone"), exports);
package/dist/order.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Channel } from './channel';
3
3
  import type { DateEntity, Entity, Metadata } from './common';
4
4
  import type { Customer } from './customer';
5
5
  import type { PaymentMethod } from './payment_method';
6
+ import type { OrderTaxLine } from './tax';
6
7
  import type { Zone } from './zone';
7
8
  export declare enum OrderStatus {
8
9
  NEW = "new",
@@ -63,12 +64,12 @@ export interface Order extends Entity {
63
64
  number: string;
64
65
  /** The total price amount (in cents). */
65
66
  price_amount: number;
67
+ /** The tax amount (in cents). */
68
+ tax_amount: number | null;
66
69
  /** The notes for the order. */
67
70
  notes: string | null;
68
71
  /** The currency code for the order. */
69
72
  currency_code: string;
70
- /** The computed total amount. */
71
- total_amount?: number;
72
73
  /** The order status. */
73
74
  status: OrderStatus;
74
75
  /** The payment status. */
@@ -132,6 +133,8 @@ export interface OrderItem extends Entity {
132
133
  quantity: number;
133
134
  /** The unit price amount. */
134
135
  unit_price_amount: number | null;
136
+ /** The tax amount (in cents). */
137
+ tax_amount: number;
135
138
  /** The computed total (unit_price_amount * quantity). */
136
139
  total: number;
137
140
  /** The SKU of the order item. */
@@ -148,6 +151,8 @@ export interface OrderItem extends Entity {
148
151
  fulfillment_status: FulfillmentStatus | null;
149
152
  /** The order. */
150
153
  order?: Order;
154
+ /** The tax lines. */
155
+ taxLines?: OrderTaxLine[];
151
156
  /** The shipment. */
152
157
  shipment?: OrderShipping;
153
158
  }
@@ -212,6 +217,8 @@ export interface OrderShipping extends Entity {
212
217
  items?: OrderItem[];
213
218
  /** The shipment tracking events. */
214
219
  events?: OrderShippingEvent[];
220
+ /** The tax lines. */
221
+ taxLines?: OrderTaxLine[];
215
222
  }
216
223
  /**
217
224
  * OrderShippingEvent model.
package/dist/tax.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ import type { Country } from './country';
2
+ import type { Entity, Metadata } from './common';
3
+ /**
4
+ * TaxProvider model.
5
+ */
6
+ export interface TaxProvider extends Entity {
7
+ /** The provider identifier (e.g., "system", "stripe_tax"). */
8
+ identifier: string;
9
+ /** Whether the provider is enabled. */
10
+ is_enabled: boolean;
11
+ /** The tax zones using this provider. */
12
+ taxZones?: TaxZone[];
13
+ }
14
+ /**
15
+ * TaxZone model.
16
+ */
17
+ export interface TaxZone extends Entity {
18
+ /** The zone name. */
19
+ name: string | null;
20
+ /** The country ID. */
21
+ country_id: number;
22
+ /** The province code (for sub-country zones). */
23
+ province_code: string | null;
24
+ /** Whether prices in this zone include tax. */
25
+ is_tax_inclusive: boolean;
26
+ /** The parent zone ID. */
27
+ parent_id: number | null;
28
+ /** The tax provider ID. */
29
+ provider_id: number | null;
30
+ /** The metadata. */
31
+ metadata: Metadata;
32
+ /** The computed display name (country — name). */
33
+ display_name: string;
34
+ /** The country. */
35
+ country?: Country;
36
+ /** The parent zone. */
37
+ parent?: TaxZone | null;
38
+ /** The child zones. */
39
+ children?: TaxZone[];
40
+ /** The tax rates for this zone. */
41
+ rates?: TaxRate[];
42
+ /** The tax provider. */
43
+ provider?: TaxProvider | null;
44
+ }
45
+ /**
46
+ * TaxRate model.
47
+ */
48
+ export interface TaxRate extends Entity {
49
+ /** The rate name (e.g., "TVA", "Sales Tax"). */
50
+ name: string;
51
+ /** The rate code (e.g., "CM-TVA-20"). */
52
+ code: string | null;
53
+ /** The tax rate percentage (e.g., 20.0 for 20%). */
54
+ rate: number;
55
+ /** Whether this is the default rate for the zone. */
56
+ is_default: boolean;
57
+ /** Whether this rate can be combined with others. */
58
+ is_combinable: boolean;
59
+ /** The tax zone ID. */
60
+ tax_zone_id: number;
61
+ /** The metadata. */
62
+ metadata: Metadata;
63
+ /** The tax zone. */
64
+ taxZone?: TaxZone;
65
+ /** The rules for this rate. */
66
+ rules?: TaxRateRule[];
67
+ }
68
+ /**
69
+ * TaxRateRule model.
70
+ */
71
+ export interface TaxRateRule extends Entity {
72
+ /** The morph type of the reference (e.g., product type, category). */
73
+ reference_type: string;
74
+ /** The morph ID of the reference. */
75
+ reference_id: string;
76
+ /** The tax rate ID. */
77
+ tax_rate_id: number;
78
+ /** The tax rate. */
79
+ taxRate?: TaxRate;
80
+ }
81
+ /**
82
+ * OrderTaxLine model — snapshot tax applied to an order item or shipping.
83
+ */
84
+ export interface OrderTaxLine extends Entity {
85
+ /** The morph type (OrderItem or OrderShipping). */
86
+ taxable_type: string;
87
+ /** The morph ID. */
88
+ taxable_id: number;
89
+ /** The snapshot tax code (e.g., "VAT", "GST"). */
90
+ code: string;
91
+ /** The snapshot tax name (e.g., "TVA 20%"). */
92
+ name: string;
93
+ /** The snapshot tax rate percentage. */
94
+ rate: number;
95
+ /** The calculated tax amount (in cents). */
96
+ amount: number;
97
+ /** Optional reference to the source tax rate. */
98
+ tax_rate_id: number | null;
99
+ /** The source tax rate (if still exists). */
100
+ taxRate?: TaxRate | null;
101
+ }
package/dist/tax.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopperlabs/shopper-types",
3
- "version": "2.5.0",
4
- "description": "TypeScript types for Laravel Shopper",
3
+ "version": "2.6.0",
4
+ "description": "TypeScript types for Shopper",
5
5
  "author": "Arthur Monney <monneylobe@gmail.com> (https://arthurmonney.me)",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",