@peable.to/shared-types 0.5.1 → 0.7.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.
@@ -1,3 +1,4 @@
1
+ import type { List, ListParams } from './list';
1
2
  /**
2
3
  * Peable Tax — the wire contract.
3
4
  *
@@ -27,7 +28,7 @@ export interface TaxAddress {
27
28
  country: string;
28
29
  /** ISO 3166-2 subdivision without the country prefix (`CA`, `QC`). */
29
30
  state?: string | null;
30
- postalCode?: string | null;
31
+ postal_code?: string | null;
31
32
  city?: string | null;
32
33
  line1?: string | null;
33
34
  line2?: string | null;
@@ -44,25 +45,25 @@ export interface TaxCode {
44
45
  export type TaxCalculationAccount = 'platform' | 'none';
45
46
  export interface TaxSettings {
46
47
  object: 'tax.settings';
47
- merchantId: string;
48
+ merchant_id: string;
48
49
  /** `active` once the owner approved; any edit returns it to `draft`. */
49
50
  status: 'draft' | 'active';
50
- legalName: string | null;
51
- headOffice: TaxAddress | null;
52
- defaultTaxCode: string;
53
- defaultTaxBehavior: TaxBehavior;
54
- calculationAccount: TaxCalculationAccount;
51
+ legal_name: string | null;
52
+ head_office: TaxAddress | null;
53
+ default_tax_code: string;
54
+ default_tax_behavior: TaxBehavior;
55
+ calculation_account: TaxCalculationAccount;
55
56
  /** The provider that calculates registered sales, when one is reachable. */
56
57
  provider: string | null;
57
- approvedAt: string | null;
58
- approvedBy: string | null;
59
- updatedAt: string | null;
58
+ approved_at: number | null;
59
+ approved_by: string | null;
60
+ updated_at: number | null;
60
61
  }
61
62
  export interface UpdateTaxSettingsParams {
62
- legalName?: string | null;
63
- headOffice?: TaxAddress | null;
64
- defaultTaxCode?: string;
65
- defaultTaxBehavior?: TaxBehavior;
63
+ legal_name?: string | null;
64
+ head_office?: TaxAddress | null;
65
+ default_tax_code?: string;
66
+ default_tax_behavior?: TaxBehavior;
66
67
  }
67
68
  export interface TaxRegistration {
68
69
  object: 'tax.registration';
@@ -71,38 +72,38 @@ export interface TaxRegistration {
71
72
  state: string | null;
72
73
  scheme: TaxRegistrationScheme;
73
74
  /** The government-issued number (VAT id, state permit), when there is one. */
74
- registrationNumber: string | null;
75
- activeFrom: string;
76
- expiresAt: string | null;
75
+ registration_number: string | null;
76
+ active_from: number;
77
+ expires_at: number | null;
77
78
  /** `pending_approval` until the owner approves; `scheduled` before activeFrom. */
78
79
  status: 'pending_approval' | 'scheduled' | 'active' | 'expired';
79
- approvedAt: string | null;
80
+ approved_at: number | null;
80
81
  /** The mirrored registration at the calculating provider, once synced. */
81
- providerRegistrationRef: string | null;
82
- createdAt: string;
82
+ provider_registration_ref: string | null;
83
+ created: number;
83
84
  }
84
85
  export interface CreateTaxRegistrationParams {
85
86
  country: string;
86
87
  state?: string | null;
87
88
  scheme: TaxRegistrationScheme;
88
- registrationNumber?: string | null;
89
- /** ISO timestamp; omitted means immediately on approval. */
90
- activeFrom?: string;
91
- expiresAt?: string | null;
89
+ registration_number?: string | null;
90
+ /** Unix seconds; omitted means immediately on approval. */
91
+ active_from?: number;
92
+ expires_at?: number | null;
92
93
  }
93
94
  export interface TaxProductCode {
94
95
  object: 'tax.product';
95
96
  /** The merchant's product or plan reference (a billing `planId`). */
96
- productRef: string;
97
- taxCode: string;
98
- updatedAt: string;
97
+ product_ref: string;
98
+ tax_code: string;
99
+ updated_at: number;
99
100
  }
100
101
  export type TaxLocationEvidenceItem = {
101
102
  type: 'billing_address';
102
103
  address: TaxAddress;
103
104
  } | {
104
105
  type: 'ip_address';
105
- ipAddress: string;
106
+ ip_address: string;
106
107
  country: string;
107
108
  state?: string | null;
108
109
  } | {
@@ -111,13 +112,13 @@ export type TaxLocationEvidenceItem = {
111
112
  };
112
113
  export interface CreateTaxLocationEvidenceParams {
113
114
  /** The customer this evidence is about; for billing, the `storeId`. */
114
- customerRef: string;
115
+ customer_ref: string;
115
116
  evidence: TaxLocationEvidenceItem[];
116
117
  }
117
118
  export interface TaxLocationEvidence {
118
119
  object: 'tax.location_evidence';
119
120
  id: string;
120
- customerRef: string;
121
+ customer_ref: string;
121
122
  /** Only `sufficient` evidence can be calculated against. */
122
123
  status: 'sufficient' | 'insufficient' | 'conflicting';
123
124
  /** The jurisdiction rule applied, e.g. `eu_digital_two_items`. */
@@ -129,8 +130,8 @@ export interface TaxLocationEvidence {
129
130
  country: string;
130
131
  state: string | null;
131
132
  }[];
132
- observedAt: string;
133
- expiresAt: string;
133
+ observed_at: number;
134
+ expires_at: number;
134
135
  livemode: boolean;
135
136
  }
136
137
  export interface TaxLineItemParams {
@@ -139,39 +140,39 @@ export interface TaxLineItemParams {
139
140
  amount: number;
140
141
  quantity?: number;
141
142
  /** Defaults to the product's tax code, then the merchant's default. */
142
- taxCode?: string;
143
+ tax_code?: string;
143
144
  /** Defaults to the merchant's default tax behavior. */
144
- taxBehavior?: TaxBehavior;
145
+ tax_behavior?: TaxBehavior;
145
146
  }
146
147
  export interface CreateTaxCalculationParams {
147
148
  currency: string;
148
- customerLocationEvidenceId: string;
149
- lineItems: TaxLineItemParams[];
149
+ customer_location_evidence_id: string;
150
+ line_items: TaxLineItemParams[];
150
151
  }
151
152
  export interface TaxBreakdownEntry {
152
153
  country: string;
153
154
  state: string | null;
154
155
  level: string | null;
155
- displayName: string | null;
156
- taxType: string | null;
156
+ display_name: string | null;
157
+ tax_type: string | null;
157
158
  /** Decimal string, e.g. `"20.0"`; null when no tax is imposed. */
158
- ratePercentage: string | null;
159
- taxableAmount: number;
159
+ rate_percentage: string | null;
160
+ taxable_amount: number;
160
161
  amount: number;
161
162
  inclusive: boolean;
162
163
  /** Provider reason, or Peable's own `not_registered` / `product_nontaxable`. */
163
- taxabilityReason: string;
164
+ taxability_reason: string;
164
165
  }
165
166
  export interface TaxCalculationLineItem {
166
167
  reference: string;
167
168
  quantity: number;
168
- taxCode: string;
169
- taxBehavior: TaxBehavior;
169
+ tax_code: string;
170
+ tax_behavior: TaxBehavior;
170
171
  /** As given: includes tax when inclusive. */
171
172
  amount: number;
172
- amountTax: number;
173
+ amount_tax: number;
173
174
  /** Excluding tax. */
174
- amountNet: number;
175
+ amount_net: number;
175
176
  breakdown: TaxBreakdownEntry[];
176
177
  }
177
178
  /** A frozen answer. `collection` says why the tax is what it is:
@@ -183,31 +184,31 @@ export interface TaxCalculation {
183
184
  id: string;
184
185
  currency: string;
185
186
  collection: 'collect' | 'not_registered' | 'nontaxable';
186
- registrationId: string | null;
187
+ registration_id: string | null;
187
188
  provider: string | null;
188
- providerCalculationRef: string | null;
189
- customerLocationEvidenceId: string;
189
+ provider_calculation_ref: string | null;
190
+ customer_location_evidence_id: string;
190
191
  country: string;
191
192
  state: string | null;
192
193
  /** What the customer pays. */
193
- amountTotal: number;
194
- amountNet: number;
195
- taxAmountExclusive: number;
196
- taxAmountInclusive: number;
197
- lineItems: TaxCalculationLineItem[];
198
- taxDate: string;
199
- createdAt: string;
200
- expiresAt: string;
194
+ amount_total: number;
195
+ amount_net: number;
196
+ tax_amount_exclusive: number;
197
+ tax_amount_inclusive: number;
198
+ line_items: TaxCalculationLineItem[];
199
+ tax_date: number;
200
+ created: number;
201
+ expires_at: number;
201
202
  livemode: boolean;
202
203
  }
203
204
  /** What a reversal gave back: the original calculation's amounts, scaled to
204
205
  * the refunded share and NEGATIVE (positive only when it reinstates an earlier
205
206
  * reversal, e.g. a refund the bank later failed). */
206
207
  export interface TaxTransactionReversal {
207
- amountTotal: number;
208
- amountNet: number;
209
- taxAmount: number;
210
- lineItems: TaxCalculationLineItem[];
208
+ amount_total: number;
209
+ amount_net: number;
210
+ tax_amount: number;
211
+ line_items: TaxCalculationLineItem[];
211
212
  }
212
213
  /** A calculation that was paid. Created by Peable when the payment it priced
213
214
  * is accepted on its rail; the report and filings are built from these.
@@ -219,13 +220,13 @@ export interface TaxTransaction {
219
220
  object: 'tax.transaction';
220
221
  id: string;
221
222
  type: 'transaction' | 'reversal';
222
- calculationId: string;
223
+ calculation_id: string;
223
224
  /** The rail's own object, e.g. the invoice id. */
224
225
  reference: string;
225
226
  rail: string;
226
- committedAt: string;
227
+ committed_at: number;
227
228
  /** The original transaction's id, for a reversal. */
228
- reversalOf: string | null;
229
+ reversal_of: string | null;
229
230
  reversal: TaxTransactionReversal | null;
230
231
  calculation: TaxCalculation;
231
232
  }
@@ -239,50 +240,46 @@ export interface CreateTaxReversalParams {
239
240
  * that is not yet reversed. */
240
241
  amount?: number;
241
242
  }
242
- export interface TaxTransactionList {
243
- object: 'list';
244
- data: TaxTransaction[];
245
- hasMore: boolean;
246
- }
247
- export interface ListTaxTransactionsParams {
248
- /** Inclusive ISO timestamp. */
249
- from: string;
250
- /** Exclusive ISO timestamp. */
251
- to: string;
252
- limit?: number;
253
- startingAfter?: string;
254
- }
243
+ export type TaxTransactionList = List<TaxTransaction>;
244
+ /**
245
+ * `GET /v1/tax/transactions`. `created` filters on `committed_at` — the tax
246
+ * date a filing period is judged by — and the list is newest first, like every
247
+ * other list.
248
+ */
249
+ export type ListTaxTransactionsParams = Omit<ListParams, 'expand'>;
255
250
  /** One filing line: totals per jurisdiction, registration, tax type and rate. */
256
251
  export interface TaxReportRow {
257
252
  country: string;
258
253
  state: string | null;
259
- registrationId: string | null;
254
+ registration_id: string | null;
260
255
  scheme: TaxRegistrationScheme | null;
261
256
  collection: TaxCalculation['collection'];
262
- taxType: string | null;
263
- ratePercentage: string | null;
257
+ tax_type: string | null;
258
+ rate_percentage: string | null;
264
259
  currency: string;
265
260
  transactions: number;
266
- /** Reversals netted into this row; `taxableAmount` and `taxAmount` are net. */
261
+ /** Reversals netted into this row; `taxable_amount` and `tax_amount` are net. */
267
262
  reversals: number;
268
- taxableAmount: number;
269
- taxAmount: number;
263
+ taxable_amount: number;
264
+ tax_amount: number;
270
265
  }
271
266
  export interface TaxReport {
272
267
  object: 'tax.report';
273
- from: string;
274
- to: string;
268
+ /** Inclusive, Unix seconds. */
269
+ from: number;
270
+ /** Exclusive, Unix seconds. */
271
+ to: number;
275
272
  rows: TaxReportRow[];
276
273
  }
277
274
  /** One tax line on a signed final invoice (`include: ['tax_lines']`). */
278
275
  export interface BillingInvoiceTaxLine {
279
- calculationId: string;
276
+ calculation_id: string;
280
277
  country: string;
281
278
  state: string | null;
282
- taxType: string | null;
283
- ratePercentage: string | null;
284
- taxableMinorUnits: number;
285
- taxMinorUnits: number;
279
+ tax_type: string | null;
280
+ rate_percentage: string | null;
281
+ taxable_minor_units: number;
282
+ tax_minor_units: number;
286
283
  inclusive: boolean;
287
- taxabilityReason: string;
284
+ taxability_reason: string;
288
285
  }
@@ -22,7 +22,7 @@ export type WebhookDeliveryStatus = 'pending' | 'delivered' | 'failed' | 'dead';
22
22
  export interface WebhookDelivery {
23
23
  id: string;
24
24
  object: 'webhook_delivery';
25
- merchantId: string;
25
+ merchant_id: string;
26
26
  /**
27
27
  * The `pi_…` this delivery is about — `null` when the event is not about a
28
28
  * payment.
@@ -32,20 +32,20 @@ export interface WebhookDelivery {
32
32
  * which is worse than a null: a consumer correlating on it would attach a
33
33
  * seller's readiness change to a payment that has nothing to do with it.
34
34
  */
35
- intentId: string | null;
36
- eventId: string;
37
- eventType: WebhookEventType;
35
+ intent_id: string | null;
36
+ event_id: string;
37
+ event_type: WebhookEventType;
38
38
  url: string;
39
39
  attempts: number;
40
40
  delivered: boolean;
41
- lastStatus: WebhookDeliveryStatus;
41
+ last_status: WebhookDeliveryStatus;
42
42
  /**
43
43
  * Why the last attempt did not succeed — operator-facing, never a secret.
44
44
  * Absent while pending with no attempts, and after a success.
45
45
  */
46
- lastError?: string;
47
- /** When the next attempt is due, ISO-8601. Absent once the delivery is terminal. */
48
- nextAttemptAt?: string;
49
- createdAt: string;
50
- updatedAt: string;
46
+ last_error?: string;
47
+ /** When the next attempt is due, Unix seconds. Absent once the delivery is terminal. */
48
+ next_attempt_at?: number;
49
+ created: number;
50
+ updated_at: number;
51
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peable.to/shared-types",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "Shared TypeScript types for the Peable Gateway — the wire contract shared by the backend, SDK, and frontend.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -74,6 +74,6 @@
74
74
  "@types/bun": "latest"
75
75
  },
76
76
  "dependencies": {
77
- "@peable.to/contracts": "0.2.1"
77
+ "@peable.to/contracts": "0.4.0"
78
78
  }
79
79
  }