@agentforge-io/sdk-server 4.90.0 → 4.92.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/dist/types.d.ts CHANGED
@@ -1639,6 +1639,136 @@ export interface CatalogPhotoUploadTarget {
1639
1639
  key: string;
1640
1640
  expiresInSeconds: number;
1641
1641
  }
1642
+ /** PDK-HIGGSFIELD — catalog photo studio. `cutout` removes the background of the REAL photo; `studio` generates a
1643
+ * reference-guided image from it, then removes the background. There is no free prompt. */
1644
+ export type CatalogPhotoStudioMode = 'cutout' | 'studio';
1645
+ /** Camera angle of a `studio` mode job (a fixed list: there is no free prompt). */
1646
+ export type CatalogPhotoStudioAngle = 'front' | 'three_quarter' | 'top';
1647
+ /**
1648
+ * Platform-side lifecycle of a studio job. `quoting` = row created, price not accepted yet (never run); `pending` /
1649
+ * `submitting` / `processing` occupy the product's single active-job slot together with `quoting`; `unknown` = a paid
1650
+ * call may or may not have gone through (never retried automatically).
1651
+ */
1652
+ export type CatalogPhotoStudioStatus = 'pending' | 'quoting' | 'submitting' | 'processing' | 'ready' | 'failed' | 'unknown' | 'attached' | 'discarded';
1653
+ /** PDK-HIGGSFIELD S2 — the image skills (server-side recipes; the prompts never leave the platform). */
1654
+ export type CatalogPhotoStudioSkill = 'product-cart' | 'ugc-model' | 'minimal-poster' | 'gravity-defying' | 'hero-offert' | 'cleanfly';
1655
+ /** `alpha_master` = transparent catalog master; `scene` = a finished picture (no background removal). */
1656
+ export type CatalogPhotoStudioOutput = 'alpha_master' | 'scene';
1657
+ /** The brand palette a skill job is painted with (the host resolves it; the platform validates and normalizes the hex values). */
1658
+ export interface CatalogPhotoStudioPalette {
1659
+ primary: string;
1660
+ accent?: string;
1661
+ surface: string;
1662
+ onSurface: string;
1663
+ mode: 'light' | 'dark';
1664
+ /** At most 2 extra brand colors (hex). */
1665
+ extra?: string[];
1666
+ }
1667
+ /**
1668
+ * Body of `studio.quote` (and the request part of `studio.create`). `sourceUrl` must be one of the product's photos.
1669
+ * Two shapes: `{ mode, angle?, sourceUrl }` (cutout / studio) or, with a `skill`, `{ skill, palette, note?, sourceUrl }`
1670
+ * (a skill takes no `mode` / `angle`; `palette` and `note` apply only together with a skill).
1671
+ */
1672
+ export interface CatalogPhotoStudioRequest {
1673
+ /** Omit when `skill` is set (a skill runs as studio). */
1674
+ mode?: CatalogPhotoStudioMode;
1675
+ /** Required by `studio` mode (the platform validates it). Never with a skill. */
1676
+ angle?: CatalogPhotoStudioAngle;
1677
+ sourceUrl: string;
1678
+ /** PDK-HIGGSFIELD S2 — an image skill. Errors: `INVALID_SKILL`, `PHOTO_REQUIRED`. */
1679
+ skill?: CatalogPhotoStudioSkill;
1680
+ /** Required with a skill (`INVALID_PALETTE`). */
1681
+ palette?: CatalogPhotoStudioPalette;
1682
+ /** Short art-direction note, at most 140 characters (`NOTE_TOO_LONG`; `NOTE_NOT_ALLOWED` when it asks for text to render). */
1683
+ note?: string;
1684
+ }
1685
+ export interface CatalogPhotoStudioQuote {
1686
+ mode: CatalogPhotoStudioMode;
1687
+ angle: CatalogPhotoStudioAngle | null;
1688
+ /** The skill slug; `null` for the plain cutout / studio modes. */
1689
+ skill: CatalogPhotoStudioSkill | null;
1690
+ output: CatalogPhotoStudioOutput;
1691
+ /** Steps of the job that have no published price (cutout's `remove_background`); `[]` for a scene skill. */
1692
+ unpricedSteps: string[];
1693
+ sourceUrl: string;
1694
+ /** Credits the job would cost; `null` for cutout (no published price). */
1695
+ credits: number | null;
1696
+ creditsExact: number | null;
1697
+ /** The workspace's Higgsfield balance now. */
1698
+ balance: number;
1699
+ /** `null` when the cost is unknown. */
1700
+ sufficient: boolean | null;
1701
+ rulesVersion: string;
1702
+ }
1703
+ export interface CreateCatalogPhotoStudioJobInput extends CatalogPhotoStudioRequest {
1704
+ /** 8-128 chars of letters, digits and `. _ : -`. Same key, same request → the same job (`replayed: true`). */
1705
+ idempotencyKey: string;
1706
+ /** Studio: the price the owner saw (the quote's `credits`). Cutout: explicit `null`. */
1707
+ confirmedCredits: number | null;
1708
+ /** The host's id of the person who asked (kept ≤ 128 chars; optional). */
1709
+ requestedBy?: string | null;
1710
+ }
1711
+ /** A studio job as the platform returns it (no provider ids). */
1712
+ export interface CatalogPhotoStudioJob {
1713
+ id: string;
1714
+ productId: string;
1715
+ mode: CatalogPhotoStudioMode;
1716
+ angle: CatalogPhotoStudioAngle | null;
1717
+ /** PDK-HIGGSFIELD S2 — the skill the job runs; `null` for cutout / studio. */
1718
+ skill: CatalogPhotoStudioSkill | null;
1719
+ /** The palette the prompt was built with (normalized); `null` without a skill. */
1720
+ palette: CatalogPhotoStudioPalette | null;
1721
+ /** The sanitized art-direction note; `null` when none. */
1722
+ note: string | null;
1723
+ sourceUrl: string;
1724
+ status: CatalogPhotoStudioStatus;
1725
+ stage: string;
1726
+ quotedCredits: number | null;
1727
+ rulesVersion: string;
1728
+ /** Candidate image; set while `ready` / `attached`. */
1729
+ resultUrl: string | null;
1730
+ /** Stable machine code when `failed` / `unknown` (never a provider message). */
1731
+ errorCode: string | null;
1732
+ errorMessage: string | null;
1733
+ /** `true` when `studio.resume` would be accepted (failed after the paid step for a recoverable cause). */
1734
+ resumable: boolean;
1735
+ createdAt: string;
1736
+ updatedAt: string;
1737
+ }
1738
+ /** One entry of `studio.skills()`. The prompts and model internals are not listed. */
1739
+ export interface CatalogPhotoStudioSkillInfo {
1740
+ slug: CatalogPhotoStudioSkill;
1741
+ label: {
1742
+ es: string;
1743
+ en: string;
1744
+ };
1745
+ purpose: {
1746
+ es: string;
1747
+ en: string;
1748
+ };
1749
+ /** e.g. `1:1`, `4:5`, `16:9`. */
1750
+ aspectRatio: string;
1751
+ /** The aspect the model generates (may differ from the delivered one). */
1752
+ generateAspect: string;
1753
+ /** Delivered size in pixels. */
1754
+ width: number;
1755
+ height: number;
1756
+ output: CatalogPhotoStudioOutput;
1757
+ }
1758
+ /** `studio.skills()` result. */
1759
+ export interface CatalogPhotoStudioSkills {
1760
+ rulesVersion: string;
1761
+ skills: CatalogPhotoStudioSkillInfo[];
1762
+ }
1763
+ /** `studio.create` result: the job plus whether it was a replay of the same idempotency key (HTTP 200 vs 201). */
1764
+ export type CatalogPhotoStudioCreated = CatalogPhotoStudioJob & {
1765
+ replayed: boolean;
1766
+ };
1767
+ /** `studio.attach` result. `product` is `null` when the job was already attached (idempotent replay). */
1768
+ export interface CatalogPhotoStudioAttachResult {
1769
+ job: CatalogPhotoStudioJob;
1770
+ product: CatalogProduct | null;
1771
+ }
1642
1772
  export interface SignCatalogPhotoUploadInput {
1643
1773
  /** image/jpeg, image/png, image/webp… (server whitelist). */
1644
1774
  contentType: string;
@@ -2582,6 +2712,12 @@ export interface CaseView {
2582
2712
  payment: CasePayment | null;
2583
2713
  /** AGF-PDK-DISPATCH-PROPOSAL — the latest proposed changes and their answer (absent on an older platform). */
2584
2714
  proposal?: CaseProposal | null;
2715
+ /**
2716
+ * PDK-RENTAL-DEAL R1 — a rental QUOTE request (`createDirectRental({ quote: true })`): where it is, every version the business sent
2717
+ * (newest last; snapshot, validity, answer, comment) and the agreed one. Null: not a quote (absent on an older platform). The lines still
2718
+ * waiting for a price are `cases.receipt(token).quote.pendingLines` (the receipt's lines carry the keys to price).
2719
+ */
2720
+ quote?: CaseQuote | null;
2585
2721
  /** AGF-AGENDA — who of the business attends it: your member reference (set with `cases.assign`). */
2586
2722
  assigneeRef: string | null;
2587
2723
  /** AGF-AGENDA — the time a booking holds, and how it reads («lunes, 9 de noviembre, 10:00–10:45»). */
@@ -2678,7 +2814,9 @@ export interface CreateOffCatalogLineInput {
2678
2814
  */
2679
2815
  export type CasePaymentStatus = 'unpaid' | 'awaiting_payment' | 'pending_confirmation' | 'paid' | 'rejected' | 'refunded' | 'partially_refunded' | 'reversed' | 'voided'
2680
2816
  /** PDK-STORE-CREDIT — «Fiado»: left on the customer's account (`cases.setOnAccount`). Neither to collect nor payable by chat. Absent on an older platform. */
2681
- | 'on_account';
2817
+ | 'on_account'
2818
+ /** PDK-RENTAL-DEAL R7 — some money came in, not all (an anticipo, a partial saldo). Only a case with payment entries reaches it. Absent on an older platform. */
2819
+ | 'partially_paid';
2682
2820
  /** The account the customer chose, as it was then (a later edit never rewrites a sale). */
2683
2821
  export interface CasePaymentAccount {
2684
2822
  id: string;
@@ -2734,13 +2872,35 @@ export interface CasePayment {
2734
2872
  * abono, never on the order). Absent otherwise and on an older platform; cleared when it goes back on account.
2735
2873
  */
2736
2874
  settledBy?: 'account';
2875
+ /** The plan frozen with the agreement: anticipo %, its amount, the deadline, the cancellation policy. */
2876
+ plan?: CasePaymentPlan;
2877
+ /** The case's money lives in its payment entries (`cases.payments`); the fields below are their projection. */
2878
+ ledger?: true;
2879
+ /** Confirmed money in − confirmed refunds. */
2880
+ paidCents?: number;
2881
+ /** Confirmed money in (refunds not subtracted). */
2882
+ grossPaidCents?: number;
2883
+ /** `max(total − paid, 0)` against the live receipt total (absent while the total is unknown). */
2884
+ balanceCents?: number;
2885
+ /** What the customer pays next: the anticipo still owed while it gates the case, else the balance. */
2886
+ dueNowCents?: number;
2887
+ /** Reported entries still waiting for the business. */
2888
+ pendingCents?: number;
2889
+ /** The anticipo still owed (0 when paid, waived or none). */
2890
+ anticipoDueCents?: number;
2891
+ /** `deposit_due`: a required anticipo is not in, so the case cannot be confirmed / dispatched (400 `deposit_due`). */
2892
+ gate?: 'deposit_due' | null;
2893
+ /** What has to go back: after the retention on a case that closed undone, or what was over-paid on a live one. */
2894
+ refundDueCents?: number;
2895
+ /** The money consequence frozen when the case closed undone (penalty tier, retained, to refund). */
2896
+ cancellation?: CaseCancellation;
2737
2897
  history: Array<{
2738
2898
  status: CasePaymentStatus;
2739
2899
  by: 'assistant' | 'customer' | 'business' | 'system';
2740
2900
  at: string;
2741
2901
  note?: string;
2742
2902
  amountCents?: number;
2743
- settledBy?: 'account';
2903
+ settledBy?: 'account' | 'ledger';
2744
2904
  }>;
2745
2905
  }
2746
2906
  /** The payment as a receipt's public link shows it (no proof image, only that one was sent). */
@@ -2772,6 +2932,37 @@ export interface CaseReceiptPayment {
2772
2932
  refundDue?: boolean;
2773
2933
  /** PDK-SERVICE-CHANGES S3 — what is still owed (+) or given back (−) after an accepted change moved the total; null/absent: nothing. */
2774
2934
  differenceCents?: number | null;
2935
+ /** `expiredAt` (R7-POLISH-2): the anticipo deadline passed with nothing paid and the platform cancelled the case (ISO); null otherwise; absent on an older platform. */
2936
+ plan?: {
2937
+ totalCents: number;
2938
+ anticipoPercent: number;
2939
+ anticipoCents: number;
2940
+ required: boolean;
2941
+ waived: boolean;
2942
+ dueAt: string | null;
2943
+ expiredAt?: string | null;
2944
+ cancelPolicyText: string;
2945
+ };
2946
+ paidCents?: number;
2947
+ balanceCents?: number | null;
2948
+ /** What «Cómo pagar» asks for now: the anticipo while it is owed, then the balance. */
2949
+ dueNowCents?: number | null;
2950
+ /** A reported transfer the business has not confirmed yet («En revisión»). */
2951
+ pendingCents?: number;
2952
+ anticipoDueCents?: number;
2953
+ gate?: 'deposit_due' | null;
2954
+ refundDueCents?: number;
2955
+ /** The money consequence once the case closed undone (null: none). `tier` is the applied `CancelPolicyTier` (or null). */
2956
+ cancellation?: {
2957
+ policyApplied: boolean;
2958
+ by: string;
2959
+ tier: CancelPolicyTier | null;
2960
+ retainedCents: number;
2961
+ refundCents: number;
2962
+ at: string;
2963
+ } | null;
2964
+ /** The customer's payments (no owner data, no proof URL, no actor, no App reference). */
2965
+ entries?: PublicCasePaymentEntry[];
2775
2966
  }
2776
2967
  /** AGF-CASE-RECEIPT — one product line, with the price it had when the receipt was issued. */
2777
2968
  export interface CaseReceiptLine {
@@ -2804,12 +2995,28 @@ export interface CaseReceiptLine {
2804
2995
  weigh?: string;
2805
2996
  /** The business typed its real weight: `qty` is that, not an estimate. */
2806
2997
  weighed?: boolean;
2807
- /** AGF-MENU-OPTIONS M2 — the options chosen; `unitCents` already includes them. */
2998
+ /**
2999
+ * AGF-MENU-OPTIONS M2 — the options chosen; `unitCents` already includes them.
3000
+ * `optionId`: the catalog option's id. `priceMode` (PDK-RENTAL-DEAL R1, rentals): `quote` = «a cotizar» (`deltaCents` is 0, not counted),
3001
+ * `per_trip` = `deltaCents` is charged once per unit, not × the periods.
3002
+ */
2808
3003
  options?: Array<{
2809
3004
  group: string;
2810
3005
  name: string;
2811
3006
  deltaCents: number;
3007
+ optionId?: string;
3008
+ priceMode?: RentalOptionMode;
2812
3009
  }>;
3010
+ /** PDK-RENTAL-DEAL R1 — names of the options that wait for a quote: the line is `priceKind: 'from'` («desde `unitCents`») until the business prices it. */
3011
+ quoteOptions?: string[];
3012
+ /** PDK-RENTAL-DEAL R1 — of `unitCents` (one unit over the whole range), the part charged once per unit (per-trip options): not × `periods.count`. */
3013
+ tripCents?: number;
3014
+ /** PDK-RENTAL-DEAL R1 — a line the business added in a quote (transporte, depósito…), not asked for by the customer (`offCatalog`, already priced). */
3015
+ extra?: true;
3016
+ /** PDK-RENTAL-DEAL R1 — the line of a `per_booking` option (a transport): charged once for the whole case, qty 1, key `booking#<option>`; the business may re-price it in a quote. */
3017
+ perBooking?: true;
3018
+ /** PDK-RENTAL-DEAL R1 — an extra line charged once (a trip), not × the rental's periods. */
3019
+ perTrip?: true;
2813
3020
  /** PDK-BUG-006 — the line is to go (packed for takeaway). Present only when `true`; absent means
2814
3021
  * eaten here, and also on receipts issued before this flag or by an older platform. */
2815
3022
  takeaway?: true;
@@ -3021,7 +3228,10 @@ export interface CaseProposalChange {
3021
3228
  */
3022
3229
  export interface CaseProposal {
3023
3230
  id: string;
3024
- /** `redone`: the customer chose «Rehacer pedido» (the order went back to being edited). */
3231
+ /**
3232
+ * `redone`: the customer chose «Rehacer pedido» (the order went back to being edited). A rental quote's proposal (`quote`) ends `accepted`,
3233
+ * or `withdrawn` for every other end (rejected, changes requested, expired, taken back): which one is `CaseView.quote.versions[n].status`.
3234
+ */
3025
3235
  status: 'pending' | 'accepted' | 'withdrawn' | 'redone';
3026
3236
  sentAt: string;
3027
3237
  answeredAt?: string;
@@ -3037,6 +3247,14 @@ export interface CaseProposal {
3037
3247
  offCatalog?: true;
3038
3248
  /** PDK-SERVICE-CHANGES — a quote of line prices (`cases.setLinePrice`, `answer: 'required'`): the customer must accept or reject (`requiresAnswer` is true, never auto-accepted); each accepted price becomes the line's price and the receipt is re-issued; a rejected one leaves the line as it was. */
3039
3249
  linePrice?: true;
3250
+ /**
3251
+ * PDK-RENTAL-DEAL R1 — a rental QUOTE version waiting for the customer (`cases.sendQuote`). It is NOT answered with `answerProposal` /
3252
+ * `receiptAnswerProposal` (400 `use_quote_answer`) but with `receiptAnswerQuote` / `answerQuote`. `changes` lists the lines priced in it.
3253
+ */
3254
+ quote?: {
3255
+ version: number;
3256
+ validUntil: string;
3257
+ };
3040
3258
  /** PDK-OFF-CATALOG — the customer MUST answer (a line is out or swapped, or its amount is over what they said × 1.2); payment waits for it. */
3041
3259
  requiresAnswer?: boolean;
3042
3260
  /**
@@ -3128,6 +3346,12 @@ export interface CaseReceipt {
3128
3346
  } | null;
3129
3347
  /** AGF-PDK-DISPATCH-PROPOSAL — the business's latest proposed changes and their answer (absent on an older platform). */
3130
3348
  proposal?: CaseProposal | null;
3349
+ /**
3350
+ * PDK-RENTAL-DEAL R1 — a rental QUOTE request: its status, the version in force and the history (sent / accepted / rejected /
3351
+ * changes_requested / superseded / expired, each with validity, total, comments), the lines still «a cotizar» and what the customer may do
3352
+ * now (`actions`). Answer with `cases.receiptAnswerQuote`. Null / absent: not a quote (or an older platform).
3353
+ */
3354
+ quote?: CaseReceiptQuote | null;
3131
3355
  /** PDK-SERVICE-CHANGES S3 — the customer may ask a change now (`cases.receiptRequestChange`); `changeReason` says why not. Absent on an older platform. */
3132
3356
  changeAllowed?: boolean;
3133
3357
  changeReason?: CaseChangeReason;
@@ -3644,7 +3868,14 @@ export interface CaseRental {
3644
3868
  };
3645
3869
  /** The rate of ONE period of ONE unit per product id when your App priced the lines (`periodRateCents`); absent: the catalog price. */
3646
3870
  periodRates?: Record<string, number>;
3871
+ /**
3872
+ * PDK-RENTAL-DEAL R1 — options charged apart from the periods, by the option's id or its lower-cased accent-free name (what you sent in
3873
+ * `lines[].optionPricing`): `quote` = «a cotizar», `per_trip` = charged once per unit, `per_booking` = once for the whole case. Absent: every option is charged per period.
3874
+ */
3875
+ optionModes?: Record<string, RentalOptionMode>;
3647
3876
  }
3877
+ /** PDK-RENTAL-DEAL R1 — how a rental option is charged when it is not «per period and unit». */
3878
+ export type RentalOptionMode = 'quote' | 'per_trip' | 'per_booking';
3648
3879
  /**
3649
3880
  * `POST /api/v1/cases/direct-rental` — an order of items rented over a time range. The body of `CreateDirectOrderInput`
3650
3881
  * (customer, lines, fields, destination, origin, payment, type, idempotencyKey…) plus `rental`. Without the options
@@ -3654,7 +3885,7 @@ export interface CaseRental {
3654
3885
  * price of ONE period (with the chosen `options`) × units × `rental.periods.count`. Never send totals; an App that owns a rate
3655
3886
  * table sends only the rate of one period per line (`lines[].periodRateCents`, R2d).
3656
3887
  */
3657
- export interface CreateDirectRentalInput extends Omit<CreateDirectOrderInput, 'lines' | 'reopens' | 'allowOffCatalog' | 'maxOffCatalogLines' | 'offCatalogLines'> {
3888
+ export interface CreateDirectRentalInput extends Omit<CreateDirectOrderInput, 'lines' | 'reopens'> {
3658
3889
  lines: Array<{
3659
3890
  productId: string;
3660
3891
  /** Units of the item (2 backhoes). */
@@ -3669,7 +3900,33 @@ export interface CreateDirectRentalInput extends Omit<CreateDirectOrderInput, 'l
3669
3900
  * The same product on two lines must use the same rate. Send the SAME unit as `rental.periods.unit`.
3670
3901
  */
3671
3902
  periodRateCents?: number;
3903
+ /**
3904
+ * PDK-RENTAL-DEAL R1 — options of THIS line that are not charged «per period and unit» (only for an App: an sk_ key bound to an App, 403
3905
+ * without it). `option` names an option the line chose (`options[].options`, by id or name); `mode`: `per_trip` = its price delta is charged
3906
+ * ONCE per unit, not × `rental.periods.count`; `per_booking` = ONCE for the whole case (a transport: not × units nor periods; it becomes its own
3907
+ * receipt line, `perBooking: true`, qty 1, even when several lines chose it); `quote` = it has no price: the line shows «desde» (without it) and waits
3908
+ * for the business's quote. A `quote` option makes the booking a quote request: it needs `quote: true` (400 `quote_required` otherwise).
3909
+ * An option the line did not choose, or one named twice with two modes, is a 400.
3910
+ */
3911
+ optionPricing?: Array<{
3912
+ option: string;
3913
+ mode: RentalOptionMode;
3914
+ }>;
3672
3915
  }>;
3916
+ /**
3917
+ * PDK-RENTAL-DEAL R1 — this is a QUOTE REQUEST, not a booking: the case stays `submitted` with `receipt.pricePending` (never instant, nothing
3918
+ * is paid), and the business answers with `cases.sendQuote`. Required when anything is pending a price: a line with a `quote` option, or
3919
+ * `offCatalogLines` (free-text extras the customer asks for: title + qty, with `allowOffCatalog: true`) — 400 `quote_required` otherwise;
3920
+ * `confirmation: 'instant'` with it is a 400 `quote_not_instant`. A rental with nothing pending behaves as before.
3921
+ */
3922
+ quote?: boolean;
3923
+ /**
3924
+ * PDK-RENTAL-DEAL R7 — partial payments: the anticipo (a % of the agreed total, rounded UP to 1 000 COP), its deadline and the cancellation
3925
+ * policy. Frozen on the case when it is agreed (on a quote request, when the customer accepts a version: send the plan with the quote request
3926
+ * as the default, or with `sendQuote` per version). 0 % and no enabled policy = no plan (the legacy single payment). 400 `invalid_payment_plan` /
3927
+ * `invalid_cancel_policy`. With a required anticipo, `confirmation: 'instant'` waits in `accepted` and confirms itself when the anticipo is in.
3928
+ */
3929
+ paymentPlan?: CasePaymentPlanInput;
3673
3930
  rental: {
3674
3931
  /** ISO instants with their offset (Z or ±hh:mm); at most 366 days apart. */
3675
3932
  startsAt: string;
@@ -3686,6 +3943,348 @@ export interface CreateDirectRentalInput extends Omit<CreateDirectOrderInput, 'l
3686
3943
  /** `review` (default): the business accepts it (`submitted`); `instant`: `confirmed` as it is made (your ledger guarantees the units). */
3687
3944
  confirmation?: 'review' | 'instant';
3688
3945
  }
3946
+ /** One tier of a cancellation policy: with a notice of at least `minHoursBefore` hours before the rental starts, retain `percent` % or `fixedCents`. */
3947
+ export interface CancelPolicyTier {
3948
+ /** Whole hours, 0 or more. Tiers are sorted highest first, strictly descending, and the LAST one is 0 (short notice, after the start, no-shows). */
3949
+ minHoursBefore: number;
3950
+ mode: 'percent' | 'fixed';
3951
+ /** `mode: 'percent'`: whole number 0–100 (rounded up to the peso). */
3952
+ percent?: number;
3953
+ /** `mode: 'fixed'`: positive whole cents. */
3954
+ fixedCents?: number;
3955
+ }
3956
+ /** The cancellation policy: 1–4 tiers when `enabled` (none needed when disabled). The retention is capped at what was paid. */
3957
+ export interface CancelPolicy {
3958
+ enabled: boolean;
3959
+ /** What a percent tier is a percent of: the agreed `total` (default) or the `anticipo`. */
3960
+ basis?: 'total' | 'anticipo';
3961
+ tiers: CancelPolicyTier[];
3962
+ }
3963
+ /** What a host App sends with a direct rental / a quote version: `paymentPlan`. */
3964
+ export interface CasePaymentPlanInput {
3965
+ /** Whole number 0–100. 0 with no enabled policy = no plan. */
3966
+ anticipoPercent: number;
3967
+ /** Hours from acceptance to the anticipo deadline, whole 1–168 (default 48). */
3968
+ anticipoDueHours?: number;
3969
+ /** ISO instant: the deadline is never after it (the platform also caps it at the rental start − 1 h). */
3970
+ notLaterThan?: string;
3971
+ cancelPolicy?: CancelPolicy;
3972
+ }
3973
+ /** The plan frozen on the case when the agreement is made (`CaseView.payment.plan`). */
3974
+ export interface CasePaymentPlan {
3975
+ totalCents: number;
3976
+ anticipoPercent: number;
3977
+ anticipoCents: number;
3978
+ /** Gates confirmation / dispatch (true when the anticipo is > 0). */
3979
+ required: boolean;
3980
+ waived?: {
3981
+ at: string;
3982
+ by: string;
3983
+ note: string;
3984
+ };
3985
+ dueHours: number;
3986
+ notLaterThan?: string;
3987
+ /** The anticipo deadline, set when the case is accepted. */
3988
+ dueAt?: string;
3989
+ acceptedAt?: string;
3990
+ /** The deadline was pushed (`cases.extendAnticipo`, or a late report was rejected). */
3991
+ extendedAt?: string;
3992
+ rejectExtended?: true;
3993
+ /** The expiry sweep claimed it: the case is being cancelled and no money is taken any more (409 `deposit_expired`). */
3994
+ expiredAt?: string;
3995
+ overdueNotifiedAt?: string;
3996
+ cancelPolicy?: CancelPolicy;
3997
+ frozenFrom: 'quote' | 'booking';
3998
+ quoteVersion?: number;
3999
+ /** An instant rental held in `accepted` until the anticipo is in: it confirms itself then. */
4000
+ autoConfirm?: true;
4001
+ frozenAt: string;
4002
+ }
4003
+ export type CasePaymentEntryKind = 'anticipo' | 'saldo' | 'other' | 'refund';
4004
+ export type CasePaymentEntryStatus = 'confirmed' | 'pending' | 'rejected';
4005
+ export type CasePaymentEntrySource = 'owner' | 'driver' | 'online' | 'customer';
4006
+ /** One row of a case's append-only payment ledger (`cases.payments`), as the business reads it. */
4007
+ export interface CasePaymentEntry {
4008
+ id: string;
4009
+ /** Position in the ledger, from 1. */
4010
+ seq: number;
4011
+ kind: CasePaymentEntryKind;
4012
+ /** Positive cents (a refund too: `kind: 'refund'` says the direction). */
4013
+ amountCents: number;
4014
+ status: CasePaymentEntryStatus;
4015
+ source: CasePaymentEntrySource;
4016
+ method: string | null;
4017
+ account: CasePaymentAccount | null;
4018
+ reference: string | null;
4019
+ proofUrl: string | null;
4020
+ note: string | null;
4021
+ /** `<caseCode>-P<seq>`: what the customer reads and the PDF prints. */
4022
+ receiptNo: string;
4023
+ actor: string | null;
4024
+ externalRef: Record<string, unknown> | null;
4025
+ /** A refund / reversal points at the entry it undoes. */
4026
+ reversesId: string | null;
4027
+ occurredAt: string;
4028
+ /** When it counted as money (confirmed). Null while pending / when rejected. */
4029
+ countedAt: string | null;
4030
+ resolvedAt: string | null;
4031
+ resolutionNote: string | null;
4032
+ }
4033
+ /** What the customer sees of an entry (`CaseReceipt.payment.entries`). */
4034
+ export interface PublicCasePaymentEntry {
4035
+ kind: CasePaymentEntryKind;
4036
+ amountCents: number;
4037
+ status: CasePaymentEntryStatus;
4038
+ methodName: string | null;
4039
+ receiptNo: string;
4040
+ occurredAt: string;
4041
+ countedAt: string | null;
4042
+ }
4043
+ export type CancelBy = 'customer' | 'business' | 'system';
4044
+ /** The money consequence of cancelling (`cases.cancellationPreview`). */
4045
+ export interface CancellationOutcome {
4046
+ by: CancelBy;
4047
+ /** The policy applies only when the CUSTOMER cancels (the business and the system cancel without a penalty by default). */
4048
+ policyApplied: boolean;
4049
+ /** Hours between the cancel and the rental start (negative after it); null without a start. */
4050
+ noticeHours: number | null;
4051
+ tier: CancelPolicyTier | null;
4052
+ /** Index into `plan.cancelPolicy.tiers` (absent on the customer's public preview). */
4053
+ tierIndex?: number | null;
4054
+ basis: 'total' | 'anticipo' | null;
4055
+ computedPenaltyCents: number;
4056
+ paidCents: number;
4057
+ retainedCents: number;
4058
+ refundCents: number;
4059
+ /** True when the case already closed undone: these are its frozen figures. */
4060
+ frozen: boolean;
4061
+ currency: string | null;
4062
+ }
4063
+ /** `CaseView.payment.cancellation`: the outcome frozen when the case closed undone. */
4064
+ export interface CaseCancellation extends Omit<CancellationOutcome, 'frozen' | 'currency' | 'tierIndex'> {
4065
+ tierIndex: number | null;
4066
+ at: string;
4067
+ /** The retention the team settled on when it differs from the suggestion (recorded with a reason on the refund entry). */
4068
+ agreedRetainedCents?: number;
4069
+ }
4070
+ /** `POST :id/payments` — money that came in. A confirmed entry. */
4071
+ export interface RecordCasePaymentInput {
4072
+ /** Positive whole cents; at most the balance (400 `exceeds_balance`). */
4073
+ amountCents: number;
4074
+ /** Informational: `anticipo` while it is owed, then `saldo`. Never `refund` (use `refundPayment`). */
4075
+ kind?: 'anticipo' | 'saldo' | 'other';
4076
+ /** How the money moved: one of the business's payment accounts… */
4077
+ accountId?: string;
4078
+ /** …or a method key (`efectivo`, `nequi`, `transferencia`…). One of the two is required (400 `method_required`). */
4079
+ method?: string;
4080
+ source?: 'owner' | 'driver';
4081
+ reference?: string;
4082
+ note?: string;
4083
+ /** Who of the business recorded it (≤ 120). */
4084
+ actor?: string;
4085
+ /** Your own reference (e.g. a POS ticket id); object, ≤ 1000 chars. */
4086
+ externalRef?: Record<string, unknown>;
4087
+ /** 8–120 of `A-Za-z0-9_.:-`, chosen and kept by the CALLER: the same key + body replays (`replayed: true`); another body → 409 `idempotency_conflict`. */
4088
+ idempotencyKey: string;
4089
+ }
4090
+ /** `POST :id/payments/refund` — money given back. */
4091
+ export interface RefundCasePaymentInput {
4092
+ /** Positive whole cents, at most what is paid (400 `exceeds_paid`). */
4093
+ amountCents: number;
4094
+ /** What the business keeps of what was paid. On a case cancelled under a policy, anything but the suggestion needs `reason` (400 `reason_required`). */
4095
+ retainedCents?: number;
4096
+ reason?: string;
4097
+ accountId?: string;
4098
+ method?: string;
4099
+ actor?: string;
4100
+ idempotencyKey: string;
4101
+ }
4102
+ /** What every ledger write answers: the case as it is now and the entry written. */
4103
+ export interface CasePaymentWriteResult {
4104
+ case: CaseView;
4105
+ entry: CasePaymentEntry;
4106
+ /** True when the same `idempotencyKey` + body had already been applied. */
4107
+ replayed: boolean;
4108
+ }
4109
+ /** PDK-RENTAL-DEAL R1 — the status of a rental quote. `requested`: the business owes a version (none yet, or the last one was withdrawn). */
4110
+ export type CaseQuoteStatus = 'requested' | 'sent' | 'changes_requested' | 'accepted' | 'rejected' | 'expired' | 'withdrawn';
4111
+ /** PDK-RENTAL-DEAL R1 — `sent`: waiting for the customer; the others are final for that version (`changes_requested`: the business sends the next). */
4112
+ export type CaseQuoteVersionStatus = 'sent' | 'accepted' | 'rejected' | 'changes_requested' | 'superseded' | 'expired' | 'withdrawn';
4113
+ /** PDK-RENTAL-DEAL R1b — what the customer asked the business for, recorded by the App (`cases.customerRequest`). */
4114
+ export type CaseCustomerRequestKind = 'asks_cancel' | 'asks_change';
4115
+ /** PDK-RENTAL-DEAL R1 — one line of a quote as the customer reads it. `unitCents` = one unit as charged (over the whole range for a rented item); `amountCents` = `unitCents` × `qty`. */
4116
+ export interface CaseQuoteLine {
4117
+ /** The receipt line's key. An extra the business added is `quote#n` here and becomes `off#n` on the receipt once accepted (`CaseQuoteVersion.extras[].key`). */
4118
+ key: string;
4119
+ title: string;
4120
+ qty: number;
4121
+ unit?: string;
4122
+ options?: Array<{
4123
+ group: string;
4124
+ name: string;
4125
+ deltaCents: number;
4126
+ priceMode?: RentalOptionMode;
4127
+ }>;
4128
+ periods?: {
4129
+ unit: string;
4130
+ count: number;
4131
+ unitCents: number | null;
4132
+ };
4133
+ unitCents: number;
4134
+ amountCents: number;
4135
+ /** The business priced this line in this version. */
4136
+ quoted?: true;
4137
+ /** A line the business added (transporte, depósito…). `perTrip`: charged once, not × the periods. */
4138
+ extra?: true;
4139
+ perTrip?: true;
4140
+ note?: string;
4141
+ breakdown?: CaseLinePriceBreakdownItem[];
4142
+ }
4143
+ /** PDK-RENTAL-DEAL R1 — a price as the version froze it (`unitCents`: ONE unit over the whole range, what `linePrices` stores). */
4144
+ export interface CaseQuotePrice {
4145
+ line: string;
4146
+ unitCents: number;
4147
+ per: 'range' | 'period';
4148
+ /** What was typed (`unitCents` ÷ periods when `per` is `period`). */
4149
+ inputCents: number;
4150
+ note?: string;
4151
+ breakdown?: CaseLinePriceBreakdownItem[];
4152
+ }
4153
+ /** PDK-RENTAL-DEAL R1 — a line the business added in a version, as frozen (`unitCents`: one unit as charged). `key`: its `off#n` on the receipt, once accepted. */
4154
+ export interface CaseQuoteExtra {
4155
+ key?: string;
4156
+ title: string;
4157
+ qty: number;
4158
+ unitCents: number;
4159
+ inputCents: number;
4160
+ perTrip: boolean;
4161
+ note?: string;
4162
+ }
4163
+ /** PDK-RENTAL-DEAL R1 — one immutable quote version, as the business reads it (`CaseView.quote.versions`). */
4164
+ export interface CaseQuoteVersion {
4165
+ version: number;
4166
+ id: string;
4167
+ status: CaseQuoteVersionStatus;
4168
+ sentAt: string;
4169
+ /** ISO instant: unanswered after it, the quote expires. */
4170
+ validUntil: string;
4171
+ /** The business's conditions note (what is included, cancellation…). */
4172
+ note: string | null;
4173
+ by: CaseLinePriceActor;
4174
+ currency: string | null;
4175
+ /** The whole order as it will be charged if this version is accepted. */
4176
+ lines: CaseQuoteLine[];
4177
+ deliveryCents: number | null;
4178
+ totalCents: number;
4179
+ /** The receipt revision it was made on. */
4180
+ revision: number;
4181
+ /** The inputs, resolved (what accepting applies). */
4182
+ prices: CaseQuotePrice[];
4183
+ extras: CaseQuoteExtra[];
4184
+ answeredAt?: string;
4185
+ answeredBy?: 'customer' | 'business' | 'system';
4186
+ /** The customer's words (`changes_requested`, or a reason when they rejected). */
4187
+ comment?: string;
4188
+ /** PDK-RENTAL-DEAL R7 — the payment plan sent with this version and the anticipo it makes on this version's total (promoted to `payment.plan` when the customer accepts THIS version). */
4189
+ paymentPlan?: CasePaymentPlanInput & {
4190
+ anticipoCents: number;
4191
+ };
4192
+ }
4193
+ /** PDK-RENTAL-DEAL R1 — `CaseView.quote`. */
4194
+ export interface CaseQuote {
4195
+ status: CaseQuoteStatus;
4196
+ requestedAt: string;
4197
+ /** The latest version (waiting for the customer, or how it ended); null before the first. */
4198
+ current: CaseQuoteVersion | null;
4199
+ /** Every version, oldest first. */
4200
+ versions: CaseQuoteVersion[];
4201
+ /** The version the customer accepted: the agreement. */
4202
+ agreedVersion: number | null;
4203
+ }
4204
+ /** PDK-RENTAL-DEAL R1 — a version on the public link: no inputs and no who. */
4205
+ export interface CaseReceiptQuoteVersion {
4206
+ version: number;
4207
+ status: CaseQuoteVersionStatus;
4208
+ sentAt: string;
4209
+ validUntil: string;
4210
+ note: string | null;
4211
+ currency: string | null;
4212
+ lines: CaseQuoteLine[];
4213
+ deliveryCents: number | null;
4214
+ totalCents: number;
4215
+ answeredAt?: string;
4216
+ comment?: string;
4217
+ /** PDK-RENTAL-DEAL R7 — the anticipo this version asks for and the cancellation policy, as the customer reads them before accepting. */
4218
+ payment?: {
4219
+ anticipoPercent: number;
4220
+ anticipoCents: number;
4221
+ anticipoDueHours?: number;
4222
+ cancelPolicyText: string;
4223
+ };
4224
+ }
4225
+ /** PDK-RENTAL-DEAL R1 — what a customer may do on a quote's receipt: `cancel` is the case's own cancel (`receiptCancel`). */
4226
+ export type CaseQuoteAction = 'accept' | 'reject' | 'changes_requested' | 'cancel';
4227
+ /** PDK-RENTAL-DEAL R1 — `CaseReceipt.quote`. */
4228
+ export interface CaseReceiptQuote {
4229
+ status: CaseQuoteStatus;
4230
+ requestedAt: string;
4231
+ /** The version in force (waiting for the customer, else the latest); null before the first. */
4232
+ current: CaseReceiptQuoteVersion | null;
4233
+ /** Every version, oldest first (the current one included). */
4234
+ versions: CaseReceiptQuoteVersion[];
4235
+ agreedVersion: number | null;
4236
+ /** The lines the business has not priced yet («a cotizar»): catalog lines (`quoteOptions`) and the free ones the customer asked for. */
4237
+ pendingLines: Array<{
4238
+ key: string;
4239
+ title: string;
4240
+ qty: number;
4241
+ quoteOptions?: string[];
4242
+ }>;
4243
+ /** What the customer may do now. `accept` / `reject` / `changes_requested` only while a version waits and is valid. */
4244
+ actions: CaseQuoteAction[];
4245
+ }
4246
+ /** PDK-RENTAL-DEAL R1 — what `cases.sendQuote` sends. */
4247
+ export interface SendCaseQuoteInput {
4248
+ /**
4249
+ * The price of every line nobody priced (receipt `key`: a catalog line with a `quote` option, or a pending free line `off#n`); a priced
4250
+ * catalog line may be re-priced too. 400 `prices_missing` (with `lines`) when a pending one has none. `unitCents` is ONE unit over the
4251
+ * WHOLE range (`per: 'range'`, default) or for ONE period (`per: 'period'`, × the rental's periods); 0 = «gratis». `breakdown` adds up to `unitCents`.
4252
+ */
4253
+ prices: Array<{
4254
+ line: string;
4255
+ unitCents: number;
4256
+ per?: 'range' | 'period';
4257
+ note?: string;
4258
+ breakdown?: CaseLinePriceBreakdownItem[];
4259
+ }>;
4260
+ /** Lines the business adds (transporte ida/regreso, depósito, horas extra…), at most 20: `unitCents` × `qty`, × the periods unless `perTrip`. */
4261
+ extras?: Array<{
4262
+ title: string;
4263
+ qty?: number;
4264
+ unitCents: number;
4265
+ perTrip?: boolean;
4266
+ note?: string;
4267
+ }>;
4268
+ /** ISO instant with offset, in the future and at most 90 days ahead. Unanswered after it, the quote expires and the case ends `cancelled` (by `system`). */
4269
+ validUntil: string;
4270
+ /** Conditions (≤ 1000): what is included, cancellation, deposit. */
4271
+ note?: string;
4272
+ /** Who of the business sends it (default `{ id: 'business' }`). */
4273
+ by?: CaseLinePriceActor;
4274
+ /**
4275
+ * PDK-RENTAL-DEAL R7 — the payment plan of THIS version (anticipo %, deadline, cancellation policy); a version sent without one keeps the plan
4276
+ * the quote request came with. It is frozen on the case when the customer accepts this version. 400 `invalid_payment_plan` / `invalid_cancel_policy`.
4277
+ */
4278
+ paymentPlan?: CasePaymentPlanInput;
4279
+ }
4280
+ /** PDK-RENTAL-DEAL R1 — the answer to a quote version: `cases.receiptAnswerQuote` (the customer) / `cases.answerQuote` (the business, by phone). */
4281
+ export interface CaseQuoteAnswerInput {
4282
+ answer: 'accept' | 'reject' | 'changes_requested';
4283
+ /** ≤ 1000. Required with `changes_requested`; with `reject` it is the reason (kept as the case's note, ≤ 500). */
4284
+ comment?: string;
4285
+ /** The version being answered: 409 `quote_stale` when it was replaced meanwhile. */
4286
+ version?: number;
4287
+ }
3689
4288
  /** `PATCH /api/v1/cases/:id/rental` — reschedule or extend: the new range (you already hold it). */
3690
4289
  export interface UpdateCaseRentalInput {
3691
4290
  startsAt: string;
@@ -3717,7 +4316,7 @@ export interface MoveCaseSlotInput {
3717
4316
  }
3718
4317
  import type { AppBillingWebhookEvent } from './resources/billing';
3719
4318
  import type { ContactPropertiesPatch } from './resources/contacts';
3720
- export type AppCaseWebhookEventName = 'case.submitted' | 'case.state_changed' | 'case.closed' | 'case.customer_request' | 'case.payment_changed' | 'case.proposal' | 'case.change';
4319
+ export type AppCaseWebhookEventName = 'case.submitted' | 'case.state_changed' | 'case.closed' | 'case.customer_request' | 'case.payment_changed' | 'case.proposal' | 'case.change' | 'case.deposit_overdue';
3721
4320
  export type AppWebhookEventName = AppCaseWebhookEventName | 'conversation.message' | 'channel.status_changed' | 'billing.plan_changed' | 'billing.trial_ended';
3722
4321
  export interface AppWebhook {
3723
4322
  url: string;
@@ -3786,12 +4385,37 @@ export interface AppCaseWebhookEvent extends AppWebhookEventBase {
3786
4385
  paymentStatus?: CasePaymentStatus;
3787
4386
  previousPaymentStatus?: CasePaymentStatus;
3788
4387
  /** `case.proposal` (AGF-PDK-DISPATCH-PROPOSAL): the business sent or withdrew changes, or they were answered. */
3789
- proposal?: 'sent' | 'accepted' | 'withdrawn' | 'redone';
4388
+ proposal?: 'sent' | 'accepted' | 'withdrawn' | 'redone' | 'quote_sent' | 'quote_accepted' | 'quote_rejected' | 'quote_changes_requested' | 'quote_expired';
4389
+ /**
4390
+ * PDK-RENTAL-DEAL R1 — with `proposal: 'quote_*'` (a `case.proposal` event; no new event name to subscribe to): the quote version it is about.
4391
+ * `quote_sent` (the business sent version N), `quote_accepted` (the case is now `accepted`), `quote_rejected` (the case ended `rejected`),
4392
+ * `quote_changes_requested` (read the version's `comment`; the case stays open), `quote_expired` (the case ended `cancelled` by `system`).
4393
+ */
4394
+ quoteVersion?: number;
3790
4395
  /**
3791
4396
  * `case.change` (PDK-SERVICE-CHANGES S3): a change request was `requested` (by the customer or the App), `accepted` or `rejected`
3792
4397
  * by the business, or `withdrawn` by the customer. `by` is who did this move; the case keeps its state while a change waits.
3793
4398
  */
3794
4399
  change?: 'requested' | 'accepted' | 'rejected' | 'withdrawn';
4400
+ /**
4401
+ * PDK-RENTAL-DEAL R7 — `case.payment_changed` / `case.deposit_overdue` on a case paid in parts: what it has paid, still owes and is asked now,
4402
+ * and the payment entry this move recorded. Absent on every case paid as a whole.
4403
+ */
4404
+ paidCents?: number;
4405
+ balanceCents?: number;
4406
+ dueNowCents?: number;
4407
+ entry?: {
4408
+ id: string;
4409
+ kind: CasePaymentEntryKind;
4410
+ amountCents: number;
4411
+ status: CasePaymentEntryStatus;
4412
+ method: string | null;
4413
+ source: CasePaymentEntrySource;
4414
+ receiptNo: string;
4415
+ };
4416
+ /** `case.deposit_overdue` (once, when money came in but the anticipo is still short after its deadline): the anticipo still owed and its (passed) deadline. No state change: the team decides. */
4417
+ anticipoDueCents?: number;
4418
+ dueAt?: string;
3795
4419
  /** AGF-ORDER-ORIGIN-POS — where the case came from (cases from before carry none). */
3796
4420
  origin?: CaseOrigin;
3797
4421
  };