@fleetless/contracts 16.1.0-next.2 → 17.0.0-next.2

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/billing.d.ts CHANGED
@@ -63,12 +63,35 @@ export declare const viesPendingReason: z.ZodEnum<{
63
63
  vies_identifier_missing: "vies_identifier_missing";
64
64
  }>;
65
65
  export type ViesPendingReason = z.infer<typeof viesPendingReason>;
66
- /** Internal decision input; the complete direct response stays in protected Finance storage. */
66
+ /**
67
+ * **Which side of a VIES check was down** (fleetless/fleetless#1181). VIES is
68
+ * a relay: it asks the VAT register of the member state the VAT ID belongs
69
+ * to. `member_state`: VIES answered, and said that this country's register is
70
+ * down or busy. `vies`: VIES itself did not answer, or answered nothing it
71
+ * can be held to. `country` is the country that was asked for, in both
72
+ * scopes: the billing address's, so Greece is `GR` and never VIES's `EL`.
73
+ */
74
+ export declare const viesOutage: z.ZodObject<{
75
+ scope: z.ZodEnum<{
76
+ member_state: "member_state";
77
+ vies: "vies";
78
+ }>;
79
+ country: z.ZodString;
80
+ }, z.core.$strict>;
81
+ export type ViesOutage = z.infer<typeof viesOutage>;
82
+ /**
83
+ * Internal decision input; the complete direct response stays in protected
84
+ * Finance storage. `unavailable` names its outage, which `vatFor` passes on
85
+ * as `vies_outage`.
86
+ */
67
87
  export type ViesVerdict = {
68
88
  status: 'valid';
69
89
  requestIdentifier?: string | null;
70
90
  } | {
71
- status: 'invalid' | 'unavailable' | 'unverified';
91
+ status: 'invalid' | 'unverified';
92
+ } | {
93
+ status: 'unavailable';
94
+ outage: ViesOutage;
72
95
  };
73
96
  export declare const vatDecision: z.ZodDiscriminatedUnion<[z.ZodObject<{
74
97
  state: z.ZodLiteral<"eligible">;
@@ -78,14 +101,23 @@ export declare const vatDecision: z.ZodDiscriminatedUnion<[z.ZodObject<{
78
101
  outside_eu: "outside_eu";
79
102
  }>;
80
103
  rate_percent: z.ZodNumber;
104
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
105
+ state: z.ZodLiteral<"pending">;
106
+ reason: z.ZodLiteral<"vies_unavailable">;
107
+ vies_outage: z.ZodObject<{
108
+ scope: z.ZodEnum<{
109
+ member_state: "member_state";
110
+ vies: "vies";
111
+ }>;
112
+ country: z.ZodString;
113
+ }, z.core.$strict>;
81
114
  }, z.core.$strict>, z.ZodObject<{
82
115
  state: z.ZodLiteral<"pending">;
83
116
  reason: z.ZodEnum<{
84
- vies_unavailable: "vies_unavailable";
85
117
  vies_unverified: "vies_unverified";
86
118
  vies_identifier_missing: "vies_identifier_missing";
87
119
  }>;
88
- }, z.core.$strict>, z.ZodObject<{
120
+ }, z.core.$strict>], "reason">, z.ZodObject<{
89
121
  state: z.ZodLiteral<"refused">;
90
122
  rule: z.ZodEnum<{
91
123
  company_required: "company_required";
@@ -7391,13 +7423,8 @@ export declare const purchaseRefusalRule: z.ZodEnum<{
7391
7423
  public_email_domain: "public_email_domain";
7392
7424
  invoice_not_open: "invoice_not_open";
7393
7425
  }>;
7394
- export declare const purchaseIntentDraft: z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
7426
+ export declare const purchaseIntentDraft: z.ZodDiscriminatedUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
7395
7427
  state: z.ZodLiteral<"awaiting_vies">;
7396
- reason: z.ZodEnum<{
7397
- vies_unavailable: "vies_unavailable";
7398
- vies_unverified: "vies_unverified";
7399
- vies_identifier_missing: "vies_identifier_missing";
7400
- }>;
7401
7428
  next_attempt_at: z.ZodISODateTime;
7402
7429
  intent_id: z.ZodUUID;
7403
7430
  operation_key: z.ZodUUID;
@@ -7408,7 +7435,31 @@ export declare const purchaseIntentDraft: z.ZodDiscriminatedUnion<readonly [z.Zo
7408
7435
  payment_method_invoice: "payment_method_invoice";
7409
7436
  }>;
7410
7437
  invoice_id: z.ZodOptional<z.ZodUUID>;
7438
+ reason: z.ZodLiteral<"vies_unavailable">;
7439
+ vies_outage: z.ZodObject<{
7440
+ scope: z.ZodEnum<{
7441
+ member_state: "member_state";
7442
+ vies: "vies";
7443
+ }>;
7444
+ country: z.ZodString;
7445
+ }, z.core.$strict>;
7411
7446
  }, z.core.$strict>, z.ZodObject<{
7447
+ state: z.ZodLiteral<"awaiting_vies">;
7448
+ next_attempt_at: z.ZodISODateTime;
7449
+ intent_id: z.ZodUUID;
7450
+ operation_key: z.ZodUUID;
7451
+ operation: z.ZodEnum<{
7452
+ checkout: "checkout";
7453
+ paid_change: "paid_change";
7454
+ invoice_payment: "invoice_payment";
7455
+ payment_method_invoice: "payment_method_invoice";
7456
+ }>;
7457
+ invoice_id: z.ZodOptional<z.ZodUUID>;
7458
+ reason: z.ZodEnum<{
7459
+ vies_unverified: "vies_unverified";
7460
+ vies_identifier_missing: "vies_identifier_missing";
7461
+ }>;
7462
+ }, z.core.$strict>], "reason">, z.ZodObject<{
7412
7463
  state: z.ZodLiteral<"eligible">;
7413
7464
  quote: z.ZodObject<{
7414
7465
  currency: z.ZodLiteral<"eur">;
@@ -7528,13 +7579,8 @@ export declare const purchaseIntentAcceptedWithoutPayment: z.ZodObject<{
7528
7579
  }, z.core.$strict>;
7529
7580
  export type PurchaseIntentAcceptedWithoutPayment = z.infer<typeof purchaseIntentAcceptedWithoutPayment>;
7530
7581
  /** Public owner read. Accepted zero-charge changes have no provider payment. */
7531
- export declare const purchaseIntent: z.ZodDiscriminatedUnion<[z.ZodObject<{
7582
+ export declare const purchaseIntent: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
7532
7583
  state: z.ZodLiteral<"awaiting_vies">;
7533
- reason: z.ZodEnum<{
7534
- vies_unavailable: "vies_unavailable";
7535
- vies_unverified: "vies_unverified";
7536
- vies_identifier_missing: "vies_identifier_missing";
7537
- }>;
7538
7584
  next_attempt_at: z.ZodISODateTime;
7539
7585
  intent_id: z.ZodUUID;
7540
7586
  operation_key: z.ZodUUID;
@@ -7545,7 +7591,31 @@ export declare const purchaseIntent: z.ZodDiscriminatedUnion<[z.ZodObject<{
7545
7591
  payment_method_invoice: "payment_method_invoice";
7546
7592
  }>;
7547
7593
  invoice_id: z.ZodOptional<z.ZodUUID>;
7594
+ reason: z.ZodLiteral<"vies_unavailable">;
7595
+ vies_outage: z.ZodObject<{
7596
+ scope: z.ZodEnum<{
7597
+ member_state: "member_state";
7598
+ vies: "vies";
7599
+ }>;
7600
+ country: z.ZodString;
7601
+ }, z.core.$strict>;
7548
7602
  }, z.core.$strict>, z.ZodObject<{
7603
+ state: z.ZodLiteral<"awaiting_vies">;
7604
+ next_attempt_at: z.ZodISODateTime;
7605
+ intent_id: z.ZodUUID;
7606
+ operation_key: z.ZodUUID;
7607
+ operation: z.ZodEnum<{
7608
+ checkout: "checkout";
7609
+ paid_change: "paid_change";
7610
+ invoice_payment: "invoice_payment";
7611
+ payment_method_invoice: "payment_method_invoice";
7612
+ }>;
7613
+ invoice_id: z.ZodOptional<z.ZodUUID>;
7614
+ reason: z.ZodEnum<{
7615
+ vies_unverified: "vies_unverified";
7616
+ vies_identifier_missing: "vies_identifier_missing";
7617
+ }>;
7618
+ }, z.core.$strict>], "reason">, z.ZodObject<{
7549
7619
  state: z.ZodLiteral<"eligible">;
7550
7620
  quote: z.ZodObject<{
7551
7621
  currency: z.ZodLiteral<"eur">;
@@ -7660,23 +7730,41 @@ export declare const purchaseIntent: z.ZodDiscriminatedUnion<[z.ZodObject<{
7660
7730
  state: z.ZodLiteral<"accepted_no_payment">;
7661
7731
  }, z.core.$strict>], "state">;
7662
7732
  export type PurchaseIntent = z.infer<typeof purchaseIntent>;
7663
- export declare const checkoutResponse: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
7664
- state: z.ZodLiteral<"awaiting_vies">;
7665
- reason: z.ZodEnum<{
7666
- vies_unavailable: "vies_unavailable";
7667
- vies_unverified: "vies_unverified";
7668
- vies_identifier_missing: "vies_identifier_missing";
7733
+ export declare const checkoutResponse: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
7734
+ operation: z.ZodEnum<{
7735
+ checkout: "checkout";
7736
+ invoice_payment: "invoice_payment";
7737
+ payment_method_invoice: "payment_method_invoice";
7669
7738
  }>;
7739
+ state: z.ZodLiteral<"awaiting_vies">;
7670
7740
  next_attempt_at: z.ZodISODateTime;
7671
7741
  intent_id: z.ZodUUID;
7672
7742
  operation_key: z.ZodUUID;
7673
7743
  invoice_id: z.ZodOptional<z.ZodUUID>;
7744
+ reason: z.ZodLiteral<"vies_unavailable">;
7745
+ vies_outage: z.ZodObject<{
7746
+ scope: z.ZodEnum<{
7747
+ member_state: "member_state";
7748
+ vies: "vies";
7749
+ }>;
7750
+ country: z.ZodString;
7751
+ }, z.core.$strict>;
7752
+ }, z.core.$strict>, z.ZodObject<{
7674
7753
  operation: z.ZodEnum<{
7675
7754
  checkout: "checkout";
7676
7755
  invoice_payment: "invoice_payment";
7677
7756
  payment_method_invoice: "payment_method_invoice";
7678
7757
  }>;
7679
- }, z.core.$strict>, z.ZodObject<{
7758
+ state: z.ZodLiteral<"awaiting_vies">;
7759
+ next_attempt_at: z.ZodISODateTime;
7760
+ intent_id: z.ZodUUID;
7761
+ operation_key: z.ZodUUID;
7762
+ invoice_id: z.ZodOptional<z.ZodUUID>;
7763
+ reason: z.ZodEnum<{
7764
+ vies_unverified: "vies_unverified";
7765
+ vies_identifier_missing: "vies_identifier_missing";
7766
+ }>;
7767
+ }, z.core.$strict>], "reason">, z.ZodObject<{
7680
7768
  state: z.ZodLiteral<"eligible">;
7681
7769
  quote: z.ZodObject<{
7682
7770
  currency: z.ZodLiteral<"eur">;
@@ -9401,15 +9489,25 @@ export declare const checkoutStartResponse: z.ZodDiscriminatedUnion<[z.ZodObject
9401
9489
  intent_id: z.ZodUUID;
9402
9490
  operation_key: z.ZodUUID;
9403
9491
  operation: z.ZodLiteral<"checkout">;
9492
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
9493
+ state: z.ZodLiteral<"vies_unavailable">;
9494
+ field: z.ZodLiteral<"billing.vat_id">;
9495
+ reason: z.ZodLiteral<"vies_unavailable">;
9496
+ vies_outage: z.ZodObject<{
9497
+ scope: z.ZodEnum<{
9498
+ member_state: "member_state";
9499
+ vies: "vies";
9500
+ }>;
9501
+ country: z.ZodString;
9502
+ }, z.core.$strict>;
9404
9503
  }, z.core.$strict>, z.ZodObject<{
9405
9504
  state: z.ZodLiteral<"vies_unavailable">;
9406
9505
  field: z.ZodLiteral<"billing.vat_id">;
9407
9506
  reason: z.ZodEnum<{
9408
- vies_unavailable: "vies_unavailable";
9409
9507
  vies_unverified: "vies_unverified";
9410
9508
  vies_identifier_missing: "vies_identifier_missing";
9411
9509
  }>;
9412
- }, z.core.$strict>, z.ZodObject<{
9510
+ }, z.core.$strict>], "reason">, z.ZodObject<{
9413
9511
  state: z.ZodLiteral<"invalid_vat_id">;
9414
9512
  field: z.ZodLiteral<"billing.vat_id">;
9415
9513
  rule: z.ZodLiteral<"vat_id_invalid">;
@@ -9514,16 +9612,29 @@ export declare const checkoutOpenDetails: z.ZodObject<{
9514
9612
  checkout_url: z.ZodNullable<z.ZodURL>;
9515
9613
  }, z.core.$strict>;
9516
9614
  export type CheckoutOpenDetails = z.infer<typeof checkoutOpenDetails>;
9517
- /** `409 target_state_conflict` details when a paid change needs VIES and VIES did not answer. Nothing is stored. */
9518
- export declare const viesUnavailableDetails: z.ZodObject<{
9615
+ /**
9616
+ * `409 target_state_conflict` details when a paid change needs VIES and VIES did not answer. Nothing is stored.
9617
+ * With `reason: vies_unavailable`, `vies_outage` says which side was down.
9618
+ */
9619
+ export declare const viesUnavailableDetails: z.ZodDiscriminatedUnion<[z.ZodObject<{
9620
+ field: z.ZodLiteral<"billing.vat_id">;
9621
+ rule: z.ZodLiteral<"vies_unavailable">;
9622
+ reason: z.ZodLiteral<"vies_unavailable">;
9623
+ vies_outage: z.ZodObject<{
9624
+ scope: z.ZodEnum<{
9625
+ member_state: "member_state";
9626
+ vies: "vies";
9627
+ }>;
9628
+ country: z.ZodString;
9629
+ }, z.core.$strict>;
9630
+ }, z.core.$strict>, z.ZodObject<{
9519
9631
  field: z.ZodLiteral<"billing.vat_id">;
9520
9632
  rule: z.ZodLiteral<"vies_unavailable">;
9521
9633
  reason: z.ZodEnum<{
9522
- vies_unavailable: "vies_unavailable";
9523
9634
  vies_unverified: "vies_unverified";
9524
9635
  vies_identifier_missing: "vies_identifier_missing";
9525
9636
  }>;
9526
- }, z.core.$strict>;
9637
+ }, z.core.$strict>], "reason">;
9527
9638
  export type ViesUnavailableDetails = z.infer<typeof viesUnavailableDetails>;
9528
9639
  /** Lookup needs one identity, plus the expected operation; a mismatch discloses nothing. */
9529
9640
  export declare const purchaseIntentLookupQuery: z.ZodObject<{
@@ -9577,13 +9688,8 @@ export declare const purchaseConflictDetails: z.ZodDiscriminatedUnion<[z.ZodObje
9577
9688
  buyer_changed: "buyer_changed";
9578
9689
  not_eligible: "not_eligible";
9579
9690
  }>;
9580
- current_intent: z.ZodDiscriminatedUnion<[z.ZodObject<{
9691
+ current_intent: z.ZodDiscriminatedUnion<[z.ZodDiscriminatedUnion<[z.ZodObject<{
9581
9692
  state: z.ZodLiteral<"awaiting_vies">;
9582
- reason: z.ZodEnum<{
9583
- vies_unavailable: "vies_unavailable";
9584
- vies_unverified: "vies_unverified";
9585
- vies_identifier_missing: "vies_identifier_missing";
9586
- }>;
9587
9693
  next_attempt_at: z.ZodISODateTime;
9588
9694
  intent_id: z.ZodUUID;
9589
9695
  operation_key: z.ZodUUID;
@@ -9594,7 +9700,31 @@ export declare const purchaseConflictDetails: z.ZodDiscriminatedUnion<[z.ZodObje
9594
9700
  payment_method_invoice: "payment_method_invoice";
9595
9701
  }>;
9596
9702
  invoice_id: z.ZodOptional<z.ZodUUID>;
9703
+ reason: z.ZodLiteral<"vies_unavailable">;
9704
+ vies_outage: z.ZodObject<{
9705
+ scope: z.ZodEnum<{
9706
+ member_state: "member_state";
9707
+ vies: "vies";
9708
+ }>;
9709
+ country: z.ZodString;
9710
+ }, z.core.$strict>;
9597
9711
  }, z.core.$strict>, z.ZodObject<{
9712
+ state: z.ZodLiteral<"awaiting_vies">;
9713
+ next_attempt_at: z.ZodISODateTime;
9714
+ intent_id: z.ZodUUID;
9715
+ operation_key: z.ZodUUID;
9716
+ operation: z.ZodEnum<{
9717
+ checkout: "checkout";
9718
+ paid_change: "paid_change";
9719
+ invoice_payment: "invoice_payment";
9720
+ payment_method_invoice: "payment_method_invoice";
9721
+ }>;
9722
+ invoice_id: z.ZodOptional<z.ZodUUID>;
9723
+ reason: z.ZodEnum<{
9724
+ vies_unverified: "vies_unverified";
9725
+ vies_identifier_missing: "vies_identifier_missing";
9726
+ }>;
9727
+ }, z.core.$strict>], "reason">, z.ZodObject<{
9598
9728
  state: z.ZodLiteral<"eligible">;
9599
9729
  quote: z.ZodObject<{
9600
9730
  currency: z.ZodLiteral<"eur">;
@@ -9741,8 +9871,8 @@ export type CheckoutStatus = z.infer<typeof checkoutStatus>;
9741
9871
  export declare const vatIdStatus: z.ZodEnum<{
9742
9872
  valid: "valid";
9743
9873
  invalid: "invalid";
9744
- unavailable: "unavailable";
9745
9874
  unverified: "unverified";
9875
+ unavailable: "unavailable";
9746
9876
  }>;
9747
9877
  export type VatIdStatus = z.infer<typeof vatIdStatus>;
9748
9878
  /** `POST /api/billing/vat-id/check`'s body: the VAT-ID-on-blur check the checkout and `PATCH /api/billing/details` both use. */
@@ -9762,21 +9892,37 @@ export declare const vatIdCheckResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
9762
9892
  rule: z.ZodLiteral<"vat_id_invalid">;
9763
9893
  vat_id: z.ZodString;
9764
9894
  name: z.ZodNullable<z.ZodString>;
9765
- }, z.core.$strict>, z.ZodObject<{
9895
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
9766
9896
  state: z.ZodLiteral<"pending">;
9767
9897
  status: z.ZodEnum<{
9768
9898
  valid: "valid";
9899
+ unverified: "unverified";
9769
9900
  unavailable: "unavailable";
9901
+ }>;
9902
+ vat_id: z.ZodString;
9903
+ name: z.ZodNullable<z.ZodString>;
9904
+ reason: z.ZodLiteral<"vies_unavailable">;
9905
+ vies_outage: z.ZodObject<{
9906
+ scope: z.ZodEnum<{
9907
+ member_state: "member_state";
9908
+ vies: "vies";
9909
+ }>;
9910
+ country: z.ZodString;
9911
+ }, z.core.$strict>;
9912
+ }, z.core.$strict>, z.ZodObject<{
9913
+ state: z.ZodLiteral<"pending">;
9914
+ status: z.ZodEnum<{
9915
+ valid: "valid";
9770
9916
  unverified: "unverified";
9917
+ unavailable: "unavailable";
9771
9918
  }>;
9919
+ vat_id: z.ZodString;
9920
+ name: z.ZodNullable<z.ZodString>;
9772
9921
  reason: z.ZodEnum<{
9773
- vies_unavailable: "vies_unavailable";
9774
9922
  vies_unverified: "vies_unverified";
9775
9923
  vies_identifier_missing: "vies_identifier_missing";
9776
9924
  }>;
9777
- vat_id: z.ZodString;
9778
- name: z.ZodNullable<z.ZodString>;
9779
- }, z.core.$strict>], "state">;
9925
+ }, z.core.$strict>], "reason">], "state">;
9780
9926
  export type VatIdCheckResponse = z.infer<typeof vatIdCheckResponse>;
9781
9927
  /**
9782
9928
  * `POST /api/billing/change`'s body: the **absolute** target state, never a
@@ -9947,8 +10093,8 @@ export declare const billingAccount: z.ZodObject<{
9947
10093
  vat_id_status: z.ZodNullable<z.ZodEnum<{
9948
10094
  valid: "valid";
9949
10095
  invalid: "invalid";
9950
- unavailable: "unavailable";
9951
10096
  unverified: "unverified";
10097
+ unavailable: "unavailable";
9952
10098
  }>>;
9953
10099
  vat: z.ZodNullable<z.ZodObject<{
9954
10100
  treatment: z.ZodEnum<{
@@ -9980,9 +10126,6 @@ export declare const billingAccount: z.ZodObject<{
9980
10126
  vat_cents: z.ZodNumber;
9981
10127
  gross_cents: z.ZodNumber;
9982
10128
  }, z.core.$strip>>;
9983
- current_price: z.ZodNullable<z.ZodObject<{
9984
- net_cents: z.ZodNumber;
9985
- }, z.core.$strip>>;
9986
10129
  scheduled: z.ZodObject<{
9987
10130
  cycle: z.ZodNullable<z.ZodEnum<{
9988
10131
  monthly: "monthly";
@@ -10105,8 +10248,8 @@ export declare const billingView: z.ZodObject<{
10105
10248
  vat_id_status: z.ZodNullable<z.ZodEnum<{
10106
10249
  valid: "valid";
10107
10250
  invalid: "invalid";
10108
- unavailable: "unavailable";
10109
10251
  unverified: "unverified";
10252
+ unavailable: "unavailable";
10110
10253
  }>>;
10111
10254
  vat: z.ZodNullable<z.ZodObject<{
10112
10255
  treatment: z.ZodEnum<{
@@ -10138,9 +10281,6 @@ export declare const billingView: z.ZodObject<{
10138
10281
  vat_cents: z.ZodNumber;
10139
10282
  gross_cents: z.ZodNumber;
10140
10283
  }, z.core.$strip>>;
10141
- current_price: z.ZodNullable<z.ZodObject<{
10142
- net_cents: z.ZodNumber;
10143
- }, z.core.$strip>>;
10144
10284
  scheduled: z.ZodObject<{
10145
10285
  cycle: z.ZodNullable<z.ZodEnum<{
10146
10286
  monthly: "monthly";
@@ -10518,8 +10658,8 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
10518
10658
  vat_id_status: z.ZodNullable<z.ZodEnum<{
10519
10659
  valid: "valid";
10520
10660
  invalid: "invalid";
10521
- unavailable: "unavailable";
10522
10661
  unverified: "unverified";
10662
+ unavailable: "unavailable";
10523
10663
  }>>;
10524
10664
  vat: z.ZodNullable<z.ZodObject<{
10525
10665
  treatment: z.ZodEnum<{
@@ -10551,9 +10691,6 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
10551
10691
  vat_cents: z.ZodNumber;
10552
10692
  gross_cents: z.ZodNumber;
10553
10693
  }, z.core.$strip>>;
10554
- current_price: z.ZodNullable<z.ZodObject<{
10555
- net_cents: z.ZodNumber;
10556
- }, z.core.$strip>>;
10557
10694
  scheduled: z.ZodObject<{
10558
10695
  cycle: z.ZodNullable<z.ZodEnum<{
10559
10696
  monthly: "monthly";
@@ -10708,8 +10845,8 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
10708
10845
  vat_id_status: z.ZodNullable<z.ZodEnum<{
10709
10846
  valid: "valid";
10710
10847
  invalid: "invalid";
10711
- unavailable: "unavailable";
10712
10848
  unverified: "unverified";
10849
+ unavailable: "unavailable";
10713
10850
  }>>;
10714
10851
  vat: z.ZodNullable<z.ZodObject<{
10715
10852
  treatment: z.ZodEnum<{
@@ -10741,9 +10878,6 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
10741
10878
  vat_cents: z.ZodNumber;
10742
10879
  gross_cents: z.ZodNumber;
10743
10880
  }, z.core.$strip>>;
10744
- current_price: z.ZodNullable<z.ZodObject<{
10745
- net_cents: z.ZodNumber;
10746
- }, z.core.$strip>>;
10747
10881
  scheduled: z.ZodObject<{
10748
10882
  cycle: z.ZodNullable<z.ZodEnum<{
10749
10883
  monthly: "monthly";
@@ -10864,13 +10998,8 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
10864
10998
  }, z.core.$strict>]>;
10865
10999
  export type BillingChangeResponse = z.infer<typeof billingChangeResponse>;
10866
11000
  /** Confirmation/lookup recover the original decision, never a bare accepted change. */
10867
- export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
11001
+ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
10868
11002
  state: z.ZodLiteral<"awaiting_vies">;
10869
- reason: z.ZodEnum<{
10870
- vies_unavailable: "vies_unavailable";
10871
- vies_unverified: "vies_unverified";
10872
- vies_identifier_missing: "vies_identifier_missing";
10873
- }>;
10874
11003
  next_attempt_at: z.ZodISODateTime;
10875
11004
  intent_id: z.ZodUUID;
10876
11005
  operation_key: z.ZodUUID;
@@ -10881,7 +11010,31 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
10881
11010
  payment_method_invoice: "payment_method_invoice";
10882
11011
  }>;
10883
11012
  invoice_id: z.ZodOptional<z.ZodUUID>;
11013
+ reason: z.ZodLiteral<"vies_unavailable">;
11014
+ vies_outage: z.ZodObject<{
11015
+ scope: z.ZodEnum<{
11016
+ member_state: "member_state";
11017
+ vies: "vies";
11018
+ }>;
11019
+ country: z.ZodString;
11020
+ }, z.core.$strict>;
10884
11021
  }, z.core.$strict>, z.ZodObject<{
11022
+ state: z.ZodLiteral<"awaiting_vies">;
11023
+ next_attempt_at: z.ZodISODateTime;
11024
+ intent_id: z.ZodUUID;
11025
+ operation_key: z.ZodUUID;
11026
+ operation: z.ZodEnum<{
11027
+ checkout: "checkout";
11028
+ paid_change: "paid_change";
11029
+ invoice_payment: "invoice_payment";
11030
+ payment_method_invoice: "payment_method_invoice";
11031
+ }>;
11032
+ invoice_id: z.ZodOptional<z.ZodUUID>;
11033
+ reason: z.ZodEnum<{
11034
+ vies_unverified: "vies_unverified";
11035
+ vies_identifier_missing: "vies_identifier_missing";
11036
+ }>;
11037
+ }, z.core.$strict>], "reason">, z.ZodObject<{
10885
11038
  state: z.ZodLiteral<"eligible">;
10886
11039
  quote: z.ZodObject<{
10887
11040
  currency: z.ZodLiteral<"eur">;
@@ -11027,8 +11180,8 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
11027
11180
  vat_id_status: z.ZodNullable<z.ZodEnum<{
11028
11181
  valid: "valid";
11029
11182
  invalid: "invalid";
11030
- unavailable: "unavailable";
11031
11183
  unverified: "unverified";
11184
+ unavailable: "unavailable";
11032
11185
  }>>;
11033
11186
  vat: z.ZodNullable<z.ZodObject<{
11034
11187
  treatment: z.ZodEnum<{
@@ -11060,9 +11213,6 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
11060
11213
  vat_cents: z.ZodNumber;
11061
11214
  gross_cents: z.ZodNumber;
11062
11215
  }, z.core.$strip>>;
11063
- current_price: z.ZodNullable<z.ZodObject<{
11064
- net_cents: z.ZodNumber;
11065
- }, z.core.$strip>>;
11066
11216
  scheduled: z.ZodObject<{
11067
11217
  cycle: z.ZodNullable<z.ZodEnum<{
11068
11218
  monthly: "monthly";
@@ -11217,8 +11367,8 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
11217
11367
  vat_id_status: z.ZodNullable<z.ZodEnum<{
11218
11368
  valid: "valid";
11219
11369
  invalid: "invalid";
11220
- unavailable: "unavailable";
11221
11370
  unverified: "unverified";
11371
+ unavailable: "unavailable";
11222
11372
  }>>;
11223
11373
  vat: z.ZodNullable<z.ZodObject<{
11224
11374
  treatment: z.ZodEnum<{
@@ -11250,9 +11400,6 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
11250
11400
  vat_cents: z.ZodNumber;
11251
11401
  gross_cents: z.ZodNumber;
11252
11402
  }, z.core.$strip>>;
11253
- current_price: z.ZodNullable<z.ZodObject<{
11254
- net_cents: z.ZodNumber;
11255
- }, z.core.$strip>>;
11256
11403
  scheduled: z.ZodObject<{
11257
11404
  cycle: z.ZodNullable<z.ZodEnum<{
11258
11405
  monthly: "monthly";
package/dist/billing.js CHANGED
@@ -50,9 +50,35 @@ export const vatTreatment = z.enum(['de_standard', 'reverse_charge', 'outside_eu
50
50
  /** A refusal of a new paid purchase, never a restriction on free Basic. */
51
51
  export const payerRefusalRule = z.enum(['company_required', 'vat_id_required', 'vat_id_invalid']);
52
52
  export const viesPendingReason = z.enum(['vies_unavailable', 'vies_unverified', 'vies_identifier_missing']);
53
+ /**
54
+ * **Which side of a VIES check was down** (fleetless/fleetless#1181). VIES is
55
+ * a relay: it asks the VAT register of the member state the VAT ID belongs
56
+ * to. `member_state`: VIES answered, and said that this country's register is
57
+ * down or busy. `vies`: VIES itself did not answer, or answered nothing it
58
+ * can be held to. `country` is the country that was asked for, in both
59
+ * scopes: the billing address's, so Greece is `GR` and never VIES's `EL`.
60
+ */
61
+ export const viesOutage = z.object({
62
+ scope: z.enum(['member_state', 'vies']).meta({
63
+ description: "`member_state`: the VAT register of `country` does not answer VIES. `vies`: VIES itself does not answer.",
64
+ }),
65
+ country: countryCode.meta({ description: "The billing address's country whose VAT ID was asked for. Greece is `GR`, never VIES's `EL`." }),
66
+ }).strict();
67
+ /**
68
+ * A pending VIES answer in its two halves (fleetless/fleetless#1181):
69
+ * `vies_unavailable` always with `vies_outage`, the other two reasons never
70
+ * with one, since they are no outage. A split union, not a `.refine()`: the
71
+ * union renders to JSON Schema by itself, a refinement says nothing there.
72
+ */
73
+ function viesPending(shape) {
74
+ return z.discriminatedUnion('reason', [
75
+ z.object({ ...shape, reason: z.literal('vies_unavailable'), vies_outage: viesOutage }).strict(),
76
+ z.object({ ...shape, reason: viesPendingReason.exclude(['vies_unavailable']) }).strict(),
77
+ ]);
78
+ }
53
79
  export const vatDecision = z.discriminatedUnion('state', [
54
80
  z.object({ state: z.literal('eligible'), treatment: vatTreatment, rate_percent: z.number().int().min(0).max(100) }).strict(),
55
- z.object({ state: z.literal('pending'), reason: viesPendingReason }).strict(),
81
+ viesPending({ state: z.literal('pending') }),
56
82
  z.object({ state: z.literal('refused'), rule: payerRefusalRule }).strict(),
57
83
  ]);
58
84
  /**
@@ -79,7 +105,9 @@ export function vatFor(input) {
79
105
  ? { state: 'eligible', treatment: 'reverse_charge', rate_percent: 0 }
80
106
  : { state: 'pending', reason: 'vies_identifier_missing' };
81
107
  }
82
- return { state: 'pending', reason: vies.status === 'unavailable' ? 'vies_unavailable' : 'vies_unverified' };
108
+ if (vies.status === 'unavailable')
109
+ return { state: 'pending', reason: 'vies_unavailable', vies_outage: vies.outage };
110
+ return { state: 'pending', reason: 'vies_unverified' };
83
111
  }
84
112
  /** VIES's member-state code: `EL` for `GR`, the country otherwise. */
85
113
  export function viesCountry(country) {
@@ -694,9 +722,11 @@ function validateIntent(intent, ctx) {
694
722
  ctx.addIssue({ code: 'custom', path: ['payment'], message: 'Owner checkout and invoice payment require a hosted payment.' });
695
723
  }
696
724
  }
725
+ /** An intent waiting for the hourly VIES retry; with `vies_unavailable` it says which side was down at the last attempt. */
726
+ const awaitingVies = { ...intentIdentity, state: z.literal('awaiting_vies'), next_attempt_at: z.iso.datetime() };
697
727
  /** Unaccepted intents. No draft contains a provider redirect or billing decision. */
698
728
  const draftVariants = [
699
- z.object({ ...intentIdentity, state: z.literal('awaiting_vies'), reason: viesPendingReason, next_attempt_at: z.iso.datetime() }).strict(),
729
+ viesPending(awaitingVies),
700
730
  z.object({ ...intentIdentity, ...quoteIdentity, state: z.literal('eligible'), quote: purchaseQuote }).strict(),
701
731
  z.object({
702
732
  ...intentIdentity, operation: purchaseOperation, state: z.literal('held'), reason: purchaseHoldReason,
@@ -732,7 +762,7 @@ export const purchaseIntent = z.discriminatedUnion('state', [
732
762
  const nonChangeOperation = purchaseOperation.exclude(['paid_change']);
733
763
  const nonChangeChargeOperation = chargeOperation.exclude(['paid_change']);
734
764
  const nonChangeDraft = z.discriminatedUnion('state', [
735
- draftVariants[0].safeExtend({ operation: nonChangeChargeOperation }),
765
+ viesPending({ ...awaitingVies, operation: nonChangeChargeOperation }),
736
766
  draftVariants[1].safeExtend({ operation: nonChangeChargeOperation }),
737
767
  draftVariants[2].safeExtend({ operation: nonChangeOperation }),
738
768
  draftVariants[3].safeExtend({ operation: nonChangeChargeOperation }),
@@ -769,8 +799,8 @@ export const checkoutStartResponse = z.discriminatedUnion('state', [
769
799
  ...checkoutIntentIdentity, state: z.literal('eligible'), ...quoteIdentity, quote: purchaseQuote,
770
800
  display: billingDecisionDisplayResponse,
771
801
  }).strict().meta({ description: 'Eligible: the price is frozen and the display shown; one click on its button confirms.' }),
772
- z.object({ state: z.literal('vies_unavailable'), field: vatIdField, reason: viesPendingReason }).strict()
773
- .meta({ description: 'VIES did not confirm the VAT ID within its retries. Nothing is stored; check again.' }),
802
+ viesPending({ state: z.literal('vies_unavailable'), field: vatIdField })
803
+ .meta({ description: 'VIES did not confirm the VAT ID within its retries; with `vies_unavailable`, `vies_outage` says which side was down. Nothing is stored; check again.' }),
774
804
  z.object({ state: z.literal('invalid_vat_id'), field: vatIdField, rule: z.literal('vat_id_invalid') }).strict()
775
805
  .meta({ description: 'VIES says the VAT ID is invalid. Nothing is stored.' }),
776
806
  z.object({ state: z.literal('refused'), field: z.string().min(1), rule: purchaseRefusalRule }).strict()
@@ -829,12 +859,11 @@ export const checkoutOpenDetails = z.object({
829
859
  expires_at: z.iso.datetime().nullable().meta({ description: 'When the open payment expires at the provider, or `null` when unknown.' }),
830
860
  checkout_url: z.url().nullable().meta({ description: 'Where the open payment continues, or `null` when the provider no longer offers it.' }),
831
861
  }).strict();
832
- /** `409 target_state_conflict` details when a paid change needs VIES and VIES did not answer. Nothing is stored. */
833
- export const viesUnavailableDetails = z.object({
834
- field: vatIdField,
835
- rule: z.literal('vies_unavailable'),
836
- reason: viesPendingReason,
837
- }).strict();
862
+ /**
863
+ * `409 target_state_conflict` details when a paid change needs VIES and VIES did not answer. Nothing is stored.
864
+ * With `reason: vies_unavailable`, `vies_outage` says which side was down.
865
+ */
866
+ export const viesUnavailableDetails = viesPending({ field: vatIdField, rule: z.literal('vies_unavailable') });
838
867
  /** Lookup needs one identity, plus the expected operation; a mismatch discloses nothing. */
839
868
  export const purchaseIntentLookupQuery = z.object({
840
869
  operation_key: purchaseOperationKey.optional().meta({ description: 'The client operation key; supply this or intent_id, never both.' }),
@@ -888,7 +917,7 @@ const vatCheckIdentity = { vat_id: z.string(), name: z.string().nullable() };
888
917
  export const vatIdCheckResponse = z.discriminatedUnion('state', [
889
918
  z.object({ ...vatCheckIdentity, state: z.literal('eligible'), status: z.literal('valid') }).strict(),
890
919
  z.object({ ...vatCheckIdentity, state: z.literal('refused'), status: z.literal('invalid'), rule: z.literal('vat_id_invalid') }).strict(),
891
- z.object({ ...vatCheckIdentity, state: z.literal('pending'), status: z.enum(['valid', 'unverified', 'unavailable']), reason: viesPendingReason }).strict(),
920
+ viesPending({ ...vatCheckIdentity, state: z.literal('pending'), status: z.enum(['valid', 'unverified', 'unavailable']) }),
892
921
  ]);
893
922
  /**
894
923
  * `POST /api/billing/change`'s body: the **absolute** target state, never a
@@ -1003,15 +1032,6 @@ export const billingAccount = z.object({
1003
1032
  vat_cents: z.number().int().meta({ description: 'VAT on the next charge, in integer cents.' }),
1004
1033
  gross_cents: z.number().int().meta({ description: 'The next charge including VAT, in integer cents.' }),
1005
1034
  }).nullable().meta({ description: '`null` while a cancel is pending or nothing else renews.' }),
1006
- current_price: z.object({
1007
- net_cents: z.number().int().meta({
1008
- description: 'One period of the current plan, cycle and add-ons at the agreed price, excluding VAT, in integer cents.',
1009
- }),
1010
- }).nullable().meta({
1011
- description: 'What one period (`cycle`) of the current plan costs this organization: the price it agreed, which stays when the ' +
1012
- 'catalogue changes. Show this, not the catalogue price, as the price of a billed organization. `null` when no agreed ' +
1013
- 'price is recorded for the current plan, cycle and add-ons.',
1014
- }),
1015
1035
  scheduled: z.object({
1016
1036
  cycle: billingCycle.nullable().meta({ description: "A cycle change queued for the period's end, or `null`." }),
1017
1037
  addons: orgAddons.nullable().meta({ description: "Add-on counts queued for the period's end, or `null`." }),