fresh-squeezy 0.2.0 → 0.3.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/index.d.ts CHANGED
@@ -160,6 +160,7 @@ interface GeneratedFileAttributes {
160
160
  version?: string | null;
161
161
  }
162
162
  interface GeneratedOrderAttributes {
163
+ affiliate_id?: number | null;
163
164
  created_at?: string | null;
164
165
  currency?: string | null;
165
166
  currency_rate?: string | number | null;
@@ -181,6 +182,7 @@ interface GeneratedOrderAttributes {
181
182
  } | null;
182
183
  identifier?: string | null;
183
184
  order_number?: number | null;
185
+ referral_amount?: number | null;
184
186
  refunded?: boolean | null;
185
187
  refunded_at?: string | null;
186
188
  setup_fee?: number | null;
@@ -260,6 +262,7 @@ interface GeneratedSubscriptionAttributes {
260
262
  variant_name?: string | null;
261
263
  }
262
264
  interface GeneratedSubscriptionInvoiceAttributes {
265
+ affiliate_id?: number | null;
263
266
  billing_reason?: string | null;
264
267
  card_brand?: string | null;
265
268
  card_last_four?: string | null;
@@ -270,6 +273,7 @@ interface GeneratedSubscriptionInvoiceAttributes {
270
273
  discount_total?: number | null;
271
274
  discount_total_formatted?: string | null;
272
275
  discount_total_usd?: number | null;
276
+ referral_amount?: number | null;
273
277
  refunded?: boolean | null;
274
278
  refunded_amount?: boolean | number | null;
275
279
  refunded_amount_formatted?: string | null;
@@ -600,22 +604,6 @@ declare const ENV_KEYS: {
600
604
  */
601
605
  declare const resolveConfig: (input?: FreshSqueezyConfig) => ResolvedConfig;
602
606
 
603
- /**
604
- * Domain-equality primitives for fresh-squeezy.
605
- *
606
- * These helpers encode "when are two values the same in our domain?" — separate
607
- * from the validators that consume them so the rules are testable on their own
608
- * and reusable from any future surface (init, dedupe, repair, etc.).
609
- */
610
- /**
611
- * Compare two webhook URLs ignoring trailing slashes and casing.
612
- *
613
- * Lemon Squeezy strips trailing slashes when persisting a webhook, but users
614
- * often paste the trailing-slash form into their config. The webhook validator
615
- * relies on this rule to match a configured URL against the registered list.
616
- */
617
- declare const sameWebhookUrl: (a: string, b: string) => boolean;
618
-
619
607
  /**
620
608
  * Unified error type for fresh-squeezy. All HTTP and validation failures that
621
609
  * bubble up to consumers pass through this class so caller code can branch on
@@ -638,787 +626,130 @@ declare class FreshSqueezyError extends Error {
638
626
  }
639
627
 
640
628
  /**
641
- * Map the boolean `meta.test_mode` flag from `/v1/users/me` to our `Mode` type.
642
- *
643
- * Returns `undefined` when the field is absent so older accounts and proxies
644
- * that don't surface the flag don't produce spurious mode mismatches. Lemon
645
- * Squeezy added `meta.test_mode` to the endpoint on 2024-01-05 (see API
646
- * changelog: https://docs.lemonsqueezy.com/api/getting-started/changelog).
629
+ * Typed attributes for every Lemon Squeezy object fresh-squeezy touches.
647
630
  *
648
- * Pure function — exposed publicly so consumers can resolve a key's true mode
649
- * from a `/v1/users/me` document they already have, without re-running the
650
- * full connection validator. Keeping it free of any resource import is what
651
- * lets `core/` stay foundational (it never reaches up into `resources/`); the
652
- * I/O counterpart `fetchActualMode` lives in `validate/connection.ts`.
631
+ * Each `*Attributes` extends the docs-generated `Generated*Attributes` and
632
+ * tightens the fields validators rely on. Ops return `unknown`; narrow with
633
+ * these, e.g. `(await lemon.orders.get(1)) as JsonApiResource<OrderAttributes>`.
653
634
  */
654
- declare const resolveActualMode: (testMode: boolean | undefined) => Mode | undefined;
655
-
656
635
  /**
657
- * Options for a single HTTP request.
658
- *
659
- * `path` is a Lemon Squeezy API path starting with `/v1/...`. The `query`
660
- * record is serialized via `URLSearchParams` (JSON:API bracket keys such as
661
- * `filter[store_id]` are accepted as-is and percent-encoded in the final URL).
636
+ * Subset of the Lemon Squeezy `users` resource attributes we rely on.
637
+ * Full schema at https://docs.lemonsqueezy.com/api/users.
662
638
  */
663
- interface RequestOptions {
664
- method?: "GET" | "POST" | "PATCH" | "DELETE";
665
- path: string;
666
- query?: Record<string, string | number | undefined>;
667
- /** JSON:API document or other request body; stringified when present. */
668
- body?: unknown;
669
- signal?: AbortSignal;
639
+ interface UserAttributes extends GeneratedUserAttributes {
640
+ name: string;
641
+ email: string;
642
+ color?: string;
643
+ avatar_url?: string | null;
644
+ has_custom_avatar?: boolean;
645
+ createdAt?: string;
646
+ updatedAt?: string;
670
647
  }
671
648
  /**
672
- * Low-level HTTP client. Callers usually go through resource/validator helpers,
673
- * but this is also exposed as the public escape hatch so consumers can reach
674
- * endpoints fresh-squeezy does not wrap yet.
675
- *
676
- * Responsibilities kept in this one place (per plan.md "one source of truth
677
- * for transport"):
678
- * - auth header injection
679
- * - query string serialization (JSON:API bracket keys via URLSearchParams)
680
- * - response parsing + error normalization
681
- * - surfacing HTTP status in `FreshSqueezyError`
649
+ * Document-level metadata on `/v1/users/me`.
682
650
  *
683
- * Retries, pagination helpers, and rate-limit handling live in separate files
684
- * so this layer stays small and obvious.
651
+ * `test_mode` was added to the endpoint on 2024-01-05 (per the Lemon Squeezy
652
+ * API changelog: https://docs.lemonsqueezy.com/api/getting-started/changelog).
653
+ * It reports whether the *key* being used is a test-mode key, independent of
654
+ * what the caller declared. The connection validator compares this against
655
+ * the caller's declared mode to catch the common "prod key in staging"
656
+ * (or vice versa) misconfiguration.
685
657
  */
686
- declare class HttpClient {
687
- private readonly config;
688
- constructor(config: ResolvedConfig);
689
- request<T>(options: RequestOptions): Promise<T>;
690
- /**
691
- * Fetch a single JSON:API resource and return its `data` object.
692
- */
693
- getResource<TAttr>(path: string): Promise<JsonApiResource<TAttr>>;
694
- /**
695
- * POST a JSON:API document and return the created `data` resource.
696
- *
697
- * @param path - API path starting with `/v1/...`.
698
- * @param body - JSON:API create document.
699
- * @returns The created resource.
700
- */
701
- postResource<TAttr>(path: string, body: unknown): Promise<JsonApiResource<TAttr>>;
702
- /**
703
- * PATCH a JSON:API document and return the updated `data` resource.
704
- *
705
- * @param path - API path starting with `/v1/...`.
706
- * @param body - JSON:API update document.
707
- * @returns The updated resource.
708
- */
709
- patchResource<TAttr>(path: string, body: unknown): Promise<JsonApiResource<TAttr>>;
710
- /**
711
- * DELETE a resource. Lemon Squeezy often returns an empty body on success.
712
- *
713
- * @param path - API path starting with `/v1/...`.
714
- * @returns Nothing — single void return, not a multi-field bag.
715
- */
716
- deleteResource(path: string): Promise<void>;
717
- /**
718
- * Fetch a single page of a JSON:API collection. Most callers want
719
- * `paginate()` instead — this method is kept for one-shot lookups where
720
- * the caller knows the result fits in a single page.
721
- */
722
- getCollection<TAttr>(path: string, query?: RequestOptions["query"]): Promise<JsonApiResource<TAttr>[]>;
723
- /**
724
- * Walk a JSON:API collection across every page and concatenate the
725
- * results. Lemon Squeezy returns 25 items per page by default; without
726
- * pagination, validators silently miss anything past the first page (e.g.
727
- * `validateWebhook` on a store with 26+ webhooks would falsely report
728
- * `WEBHOOK_NOT_FOUND` for any webhook on page 2).
729
- *
730
- * Stops as soon as `meta.page.lastPage` is reached. Falls back to a
731
- * single-page fetch if the API does not surface page metadata.
732
- *
733
- * Caller-supplied `page[number]` is honored as the starting page; we
734
- * advance from there. `page[size]` is left untouched so callers can tune
735
- * batch size (max 100 per Lemon Squeezy docs).
736
- */
737
- paginate<TAttr>(path: string, query?: RequestOptions["query"]): Promise<JsonApiResource<TAttr>[]>;
738
- private requestUrl;
658
+ interface UserMeta {
659
+ test_mode?: boolean;
739
660
  }
740
-
741
- type AffiliateStatus = "active" | "pending" | "disabled";
742
661
  /**
743
- * Affiliate attributes added with the 2025-01-21 Affiliates API surface.
744
- * No validator consumes these yet; the helpers give typed access while
745
- * preserving the raw request escape hatch for mutations and includes.
662
+ * Authenticated-user document with the `data` + `meta` block preserved.
663
+ * The connection validator needs the meta flag, so it reads the full
664
+ * `/v1/users/me` document rather than just `data`.
746
665
  */
747
- interface AffiliateAttributes extends GeneratedAffiliateAttributes {
748
- store_id: number;
749
- user_id: number;
750
- user_name: string;
751
- user_email: string;
752
- share_domain: string;
753
- status: AffiliateStatus;
754
- application_note?: string | null;
755
- products?: unknown;
756
- total_earnings: number;
757
- unpaid_earnings: number;
666
+ type AuthenticatedUserDocument = JsonApiDocument<UserAttributes> & {
667
+ meta?: UserMeta;
668
+ };
669
+ /**
670
+ * Subset of store attributes fresh-squeezy reads.
671
+ * Full schema at https://docs.lemonsqueezy.com/api/stores.
672
+ */
673
+ interface StoreAttributes extends GeneratedStoreAttributes {
674
+ name: string;
675
+ slug: string;
676
+ domain?: string | null;
677
+ url?: string | null;
678
+ country?: string;
679
+ currency?: string;
680
+ plan?: string;
758
681
  created_at?: string;
759
682
  updated_at?: string;
760
683
  }
761
- declare const getAffiliate: (http: HttpClient, affiliateId: string | number) => Promise<JsonApiResource<AffiliateAttributes>>;
762
- declare const listAffiliatesForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<AffiliateAttributes>[]>;
763
-
764
- type CheckoutLocale = "bg" | "hr" | "cs" | "da" | "nl" | "en" | "et" | "fil" | "fi" | "fr" | "de" | "el" | "hu" | "id" | "it" | "ja" | "ko" | "lv" | "lt" | "ms" | "mt" | "pl" | "pt" | "ro" | "ru" | "zh-CN" | "sk" | "sl" | "es" | "sv" | "th" | "tr" | "vi";
765
- interface CheckoutProductOptions {
766
- name?: string;
767
- description?: string;
768
- media?: string[];
769
- redirect_url?: string;
770
- receipt_button_text?: string;
771
- receipt_link_url?: string;
772
- receipt_thank_you_note?: string;
773
- enabled_variants?: number[];
774
- }
775
- interface CheckoutOptions {
776
- embed?: boolean;
777
- media?: boolean;
778
- logo?: boolean;
779
- desc?: boolean;
780
- discount?: boolean;
781
- subscription_preview?: boolean;
782
- /** Added 2024-03-28. */
783
- skip_trial?: boolean;
784
- /** Deprecated 2024-09-04; keep typed so old payloads still compile. */
785
- dark?: boolean;
786
- background_color?: string;
787
- headings_color?: string;
788
- primary_text_color?: string;
789
- secondary_text_color?: string;
790
- links_color?: string;
791
- borders_color?: string;
792
- checkbox_color?: string;
793
- active_state_color?: string;
794
- button_color?: string;
795
- button_text_color?: string;
796
- terms_privacy_color?: string;
797
- locale?: CheckoutLocale | string | null;
798
- }
799
- interface CheckoutVariantQuantity {
800
- variant_id: number;
801
- quantity: number;
802
- }
803
- interface CheckoutData {
804
- email?: string;
805
- name?: string;
806
- billing_address?: {
807
- country?: string;
808
- zip?: string;
809
- };
810
- tax_number?: string;
811
- discount_code?: string;
812
- custom?: Record<string, unknown>;
813
- /** Added 2023-08-23 for multi-variant checkout quantities. */
814
- variant_quantities?: CheckoutVariantQuantity[];
815
- }
816
- interface CheckoutPreview {
817
- currency: string;
818
- currency_rate: number | string;
819
- subtotal: number;
820
- discount_total: number;
821
- tax: number;
822
- total: number;
823
- subtotal_usd: number;
824
- discount_total_usd: number;
825
- tax_usd: number;
826
- total_usd: number;
827
- subtotal_formatted: string;
828
- discount_total_formatted: string;
829
- tax_formatted: string;
830
- total_formatted: string;
831
- }
832
- interface CheckoutAttributes extends GeneratedCheckoutAttributes {
684
+ /**
685
+ * Subset of product attributes we need for validation. `status` drives the
686
+ * "unpublished product" check; `store_id` drives ownership checks.
687
+ */
688
+ interface ProductAttributes extends GeneratedProductAttributes {
689
+ name: string;
690
+ slug: string;
691
+ description?: string | null;
692
+ status: "draft" | "published";
693
+ status_formatted?: string;
833
694
  store_id: number;
834
- variant_id: number;
835
- custom_price?: number | null;
836
- product_options?: CheckoutProductOptions;
837
- checkout_options?: CheckoutOptions;
838
- checkout_data?: CheckoutData;
839
- preview?: CheckoutPreview;
840
- expires_at?: string | null;
841
- url?: string;
695
+ buy_now_url?: string | null;
696
+ from_price?: number | null;
697
+ to_price?: number | null;
842
698
  created_at?: string;
843
699
  updated_at?: string;
844
- test_mode?: boolean;
845
700
  }
846
- /**
847
- * Retrieve a checkout (GET /v1/checkouts/:id).
848
- *
849
- * @param http - Shared API client.
850
- * @param checkoutId - Checkout id.
851
- * @returns The checkout resource.
852
- * @throws {FreshSqueezyError} On HTTP/network failure.
853
- *
854
- * @example
855
- * ```ts
856
- * const checkout = await getCheckout(http, 1);
857
- * ```
858
- */
859
- declare const getCheckout: (http: HttpClient, checkoutId: string | number) => Promise<JsonApiResource<CheckoutAttributes>>;
860
- /**
861
- * List checkouts for a store.
862
- *
863
- * @param http - Shared API client.
864
- * @param storeId - Store filter.
865
- * @returns Checkout resources.
866
- * @throws {FreshSqueezyError} On HTTP/network failure.
867
- *
868
- * @example
869
- * ```ts
870
- * const checkouts = await listCheckoutsForStore(http, 1);
871
- * ```
872
- */
873
- declare const listCheckoutsForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<CheckoutAttributes>[]>;
874
- /**
875
- * Create a checkout (POST /v1/checkouts).
876
- * Docs: https://docs.lemonsqueezy.com/api/checkouts/create-checkout
877
- *
878
- * @param http - Shared API client.
879
- * @param body - JSON:API create document (store + variant relationships).
880
- * @returns The created checkout (includes `url` for the hosted checkout).
881
- * @throws {FreshSqueezyError} On HTTP/network failure.
882
- *
883
- * @example
884
- * ```ts
885
- * const checkout = await createCheckout(http, {
886
- * data: {
887
- * type: "checkouts",
888
- * attributes: { checkout_data: { email: "buyer@example.com" } },
889
- * relationships: {
890
- * store: { data: { type: "stores", id: "1" } },
891
- * variant: { data: { type: "variants", id: "1" } },
892
- * },
893
- * },
894
- * });
895
- * ```
896
- */
897
- declare const createCheckout: (http: HttpClient, body: unknown) => Promise<JsonApiResource<CheckoutAttributes>>;
898
-
899
- type CustomerStatus = "subscribed" | "unsubscribed" | "archived" | "requires_verification" | "invalid_email" | "bounced";
900
- interface CustomerUrls {
901
- customer_portal?: string | null;
701
+ interface VariantLink {
702
+ title: string;
703
+ url: string;
902
704
  }
903
705
  /**
904
- * Lemon Squeezy customer attributes. The customer portal URL was called out
905
- * in the 2023-09-19 changelog and is useful for apps linking users back to
906
- * billing without another API shape.
706
+ * Variant attributes used by the product validator to detect
707
+ * variant/price drift from the product they belong to.
907
708
  */
908
- interface CustomerAttributes extends GeneratedCustomerAttributes {
909
- store_id: number;
910
- name: string;
911
- email: string;
912
- status: CustomerStatus;
913
- city?: string | null;
914
- region?: string | null;
915
- country?: string | null;
916
- total_revenue_currency: number;
917
- mrr: number;
918
- status_formatted: string;
919
- country_formatted?: string | null;
920
- total_revenue_currency_formatted: string;
921
- mrr_formatted: string;
922
- urls?: CustomerUrls;
923
- created_at?: string;
924
- updated_at?: string;
925
- test_mode?: boolean;
926
- }
927
- /**
928
- * Retrieve a customer (GET /v1/customers/:id).
929
- *
930
- * @param http - Shared API client.
931
- * @param customerId - Customer id.
932
- * @returns The customer resource.
933
- * @throws {FreshSqueezyError} On HTTP/network failure.
934
- *
935
- * @example
936
- * ```ts
937
- * const customer = await getCustomer(http, 1);
938
- * ```
939
- */
940
- declare const getCustomer: (http: HttpClient, customerId: string | number) => Promise<JsonApiResource<CustomerAttributes>>;
941
- /**
942
- * List customers for a store.
943
- *
944
- * @param http - Shared API client.
945
- * @param storeId - Store filter.
946
- * @returns Customer resources.
947
- * @throws {FreshSqueezyError} On HTTP/network failure.
948
- *
949
- * @example
950
- * ```ts
951
- * const customers = await listCustomersForStore(http, 1);
952
- * ```
953
- */
954
- declare const listCustomersForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<CustomerAttributes>[]>;
955
- /**
956
- * Create a customer (POST /v1/customers).
957
- * Docs: https://docs.lemonsqueezy.com/api/customers/create-customer
958
- *
959
- * @param http - Shared API client.
960
- * @param body - JSON:API create document.
961
- * @returns The created customer.
962
- * @throws {FreshSqueezyError} On HTTP/network failure.
963
- *
964
- * @example
965
- * ```ts
966
- * const customer = await createCustomer(http, {
967
- * data: {
968
- * type: "customers",
969
- * attributes: { name: "Ada", email: "ada@example.com" },
970
- * relationships: { store: { data: { type: "stores", id: "1" } } },
971
- * },
972
- * });
973
- * ```
974
- */
975
- declare const createCustomer: (http: HttpClient, body: unknown) => Promise<JsonApiResource<CustomerAttributes>>;
976
- /**
977
- * Update a customer (PATCH /v1/customers/:id).
978
- * Docs: https://docs.lemonsqueezy.com/api/customers/update-customer
979
- *
980
- * @param http - Shared API client.
981
- * @param customerId - Customer id.
982
- * @param body - JSON:API update document.
983
- * @returns The updated customer.
984
- * @throws {FreshSqueezyError} On HTTP/network failure.
985
- *
986
- * @example
987
- * ```ts
988
- * const customer = await updateCustomer(http, 1, {
989
- * data: { type: "customers", id: "1", attributes: { name: "Ada Lovelace" } },
990
- * });
991
- * ```
992
- */
993
- declare const updateCustomer: (http: HttpClient, customerId: string | number, body: unknown) => Promise<JsonApiResource<CustomerAttributes>>;
994
-
995
- interface DiscountRedemptionAttributes extends GeneratedDiscountRedemptionAttributes {
996
- discount_id: number;
997
- order_id: number;
998
- discount_name: string;
999
- discount_code: string;
1000
- discount_amount: number;
1001
- discount_amount_type: "percent" | "fixed";
1002
- amount: number;
1003
- created_at?: string;
1004
- updated_at?: string;
1005
- }
1006
- declare const getDiscountRedemption: (http: HttpClient, discountRedemptionId: string | number) => Promise<JsonApiResource<DiscountRedemptionAttributes>>;
1007
- declare const listDiscountRedemptionsForDiscount: (http: HttpClient, discountId: string | number) => Promise<JsonApiResource<DiscountRedemptionAttributes>[]>;
1008
-
1009
- /**
1010
- * Subset of Lemon Squeezy discount attributes used by the discount validator.
1011
- * Full schema at https://docs.lemonsqueezy.com/api/discounts.
1012
- */
1013
- interface DiscountAttributes extends GeneratedDiscountAttributes {
709
+ interface VariantAttributes extends GeneratedVariantAttributes {
710
+ product_id: number;
1014
711
  name: string;
1015
- code: string;
1016
- amount: number;
1017
- amount_type: "percent" | "fixed";
1018
- is_limited_to_products: boolean;
1019
- is_limited_redemptions: boolean;
1020
- max_redemptions: number;
1021
- starts_at: string | null;
1022
- expires_at: string | null;
1023
- status: "draft" | "published";
1024
- duration: "once" | "repeating" | "forever";
1025
- store_id: number;
1026
- created_at?: string;
1027
- updated_at?: string;
1028
- }
1029
- /**
1030
- * Fetch a single discount by ID. The validator uses the discount's
1031
- * `relationships.store` to confirm ownership against the caller's storeId.
1032
- *
1033
- * @param http - Shared API client.
1034
- * @param discountId - Discount id.
1035
- * @returns The discount resource.
1036
- * @throws {FreshSqueezyError} On HTTP/network failure.
1037
- *
1038
- * @example
1039
- * ```ts
1040
- * const discount = await getDiscount(http, 1);
1041
- * ```
1042
- */
1043
- declare const getDiscount: (http: HttpClient, discountId: string | number) => Promise<JsonApiResource<DiscountAttributes>>;
1044
- /**
1045
- * List discounts for a store (GET /v1/discounts?filter[store_id]=…).
1046
- *
1047
- * @param http - Shared API client.
1048
- * @param storeId - Store filter.
1049
- * @returns Discount resources.
1050
- * @throws {FreshSqueezyError} On HTTP/network failure.
1051
- *
1052
- * @example
1053
- * ```ts
1054
- * const discounts = await listDiscountsForStore(http, 1);
1055
- * ```
1056
- */
1057
- declare const listDiscountsForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<DiscountAttributes>[]>;
1058
- /**
1059
- * Create a discount (POST /v1/discounts). No update endpoint exists in the API.
1060
- * Docs: https://docs.lemonsqueezy.com/api/discounts/create-discount
1061
- *
1062
- * @param http - Shared API client.
1063
- * @param body - JSON:API create document.
1064
- * @returns The created discount.
1065
- * @throws {FreshSqueezyError} On HTTP/network failure.
1066
- *
1067
- * @example
1068
- * ```ts
1069
- * const discount = await createDiscount(http, {
1070
- * data: {
1071
- * type: "discounts",
1072
- * attributes: { name: "Launch", code: "LAUNCH10", amount: 10, amount_type: "percent" },
1073
- * relationships: { store: { data: { type: "stores", id: "1" } } },
1074
- * },
1075
- * });
1076
- * ```
1077
- */
1078
- declare const createDiscount: (http: HttpClient, body: unknown) => Promise<JsonApiResource<DiscountAttributes>>;
1079
- /**
1080
- * Delete a discount (DELETE /v1/discounts/:id).
1081
- * Docs: https://docs.lemonsqueezy.com/api/discounts/delete-discount
1082
- *
1083
- * @param http - Shared API client.
1084
- * @param discountId - Discount id.
1085
- * @returns Nothing on success.
1086
- * @throws {FreshSqueezyError} On HTTP/network failure.
1087
- *
1088
- * @example
1089
- * ```ts
1090
- * await deleteDiscount(http, 1);
1091
- * ```
1092
- */
1093
- declare const deleteDiscount: (http: HttpClient, discountId: string | number) => Promise<void>;
1094
-
1095
- /**
1096
- * Lemon Squeezy file attributes, generated from the public object docs.
1097
- * Exposed so consumers can type file-resource escape-hatch calls without
1098
- * waiting for a hand-written validator.
1099
- */
1100
- interface FileAttributes extends GeneratedFileAttributes {
1101
- }
1102
- declare const getFile: (http: HttpClient, fileId: string | number) => Promise<JsonApiResource<FileAttributes>>;
1103
- declare const listFilesForVariant: (http: HttpClient, variantId: string | number) => Promise<JsonApiResource<FileAttributes>[]>;
1104
-
1105
- /**
1106
- * Docs-backed ops matrix for Lemon Squeezy.
1107
- *
1108
- * Only verbs that exist at https://docs.lemonsqueezy.com/api are listed.
1109
- * Catalog resources (products, variants, prices, files, stores, …) are
1110
- * read-only. CI changelog scrape may propose gaps; this registry is what ships.
1111
- */
1112
- /** CLI / client verb tokens, including non-CRUD LS actions. */
1113
- type OpVerb = "get" | "list" | "create" | "update" | "delete" | "cancel" | "refund" | "generate-invoice" | "current-usage";
1114
- /**
1115
- * One implemented, documented operation.
1116
- *
1117
- * @remarks `docsPath` is the path under `/api/` on the LS docs site.
1118
- */
1119
- interface ResourceVerbSpec {
1120
- /** CLI resource token (singular), e.g. `webhook`. */
1121
- resource: string;
1122
- verb: OpVerb;
1123
- /** Docs path fragment, e.g. `webhooks/create-webhook`. */
1124
- docsPath: string;
1125
- /** Requires --yes or TTY confirm always (delete/cancel/refund). */
1126
- destructive?: boolean;
1127
- body?: "required" | "optional" | "none";
712
+ slug: string;
713
+ description?: string | null;
714
+ has_license_keys?: boolean;
715
+ license_activation_limit?: number | null;
716
+ is_license_limit_unlimited?: boolean;
717
+ license_length_value?: number | null;
718
+ license_length_unit?: "day" | "week" | "month" | "year" | null;
719
+ is_license_length_unlimited?: boolean;
720
+ status: "pending" | "draft" | "published";
721
+ status_formatted?: string;
722
+ is_subscription?: boolean;
723
+ interval?: string | null;
724
+ interval_count?: number | null;
725
+ sort?: number;
1128
726
  /**
1129
- * How list/get resolve the primary id filter.
1130
- * - `id` — --id
1131
- * - `store` — --store-ids (first) or store filter
1132
- * - `parent` — --parent-id (subscription, order, product, …)
727
+ * Hosted-checkout-style links keyed by purpose. Added 2024-06-09 — older
728
+ * SDK and validator versions don't surface this field, so consumers had
729
+ * to read `meta.product_links` manually before. Optional because the
730
+ * field is absent on older variants.
1133
731
  */
1134
- idRole?: "id" | "store" | "parent" | "none";
1135
- }
1136
- /**
1137
- * Implemented ops. Keep in sync with exports in `src/resources/*` and the
1138
- * CLI dispatcher. Do not register fantasy endpoints (e.g. product create).
1139
- */
1140
- declare const resourceRegistry: readonly ResourceVerbSpec[];
1141
- /**
1142
- * Normalize a CLI resource token to the singular registry key.
1143
- *
1144
- * @param resource - Raw token (`products`, `order_items`, `webhook`).
1145
- * @returns Canonical singular resource name used in `resourceRegistry`.
1146
- */
1147
- declare const normalizeResourceName: (resource: string) => string;
1148
- /**
1149
- * Look up a registry entry.
1150
- *
1151
- * @param resource - CLI resource token.
1152
- * @param verb - Op verb.
1153
- * @returns The spec, or undefined when not implemented / not in LS API.
1154
- */
1155
- declare const findResourceVerb: (resource: string, verb: string) => ResourceVerbSpec | undefined;
1156
- /**
1157
- * Unique resource names that have at least one verb.
1158
- *
1159
- * @returns Sorted resource tokens for help text / menus.
1160
- */
1161
- declare const listRegisteredResources: () => string[];
1162
- /**
1163
- * All verbs registered for a resource (empty when unknown).
1164
- *
1165
- * @param resource - CLI resource token (plural or singular).
1166
- * @returns Sorted verb list for help / menus.
1167
- */
1168
- declare const listRegisteredVerbs: (resource: string) => OpVerb[];
1169
-
1170
- /**
1171
- * Arguments for a single resource op invocation.
1172
- *
1173
- * One named input type — not a bag of unrelated returns.
1174
- */
1175
- interface InvokeOpArgs {
1176
- id?: string | number;
1177
- storeId?: string | number;
1178
- parentId?: string | number;
1179
- body?: unknown;
1180
- }
1181
- /**
1182
- * Dispatch a docs-backed resource verb through the thin resource helpers.
1183
- *
1184
- * @param http - Shared API client.
1185
- * @param resource - CLI resource token (`webhook`, `product`, …).
1186
- * @param verb - Op verb (`get`, `create`, `refund`, …).
1187
- * @param args - Ids / body for the call.
1188
- * @returns A single JSON:API resource, list, void, or action payload.
1189
- * @throws {FreshSqueezyError} When the verb is unknown or HTTP fails.
1190
- *
1191
- * @example
1192
- * ```ts
1193
- * const product = await invokeOp(http, "product", "get", { id: 42 });
1194
- * ```
1195
- */
1196
- declare const invokeOp: (http: HttpClient, resource: string, verb: OpVerb | string, args?: InvokeOpArgs) => Promise<unknown>;
1197
-
1198
- interface LicenseKeyInstanceAttributes extends GeneratedLicenseKeyInstanceAttributes {
1199
- license_key_id: number;
1200
- identifier: string;
1201
- name: string;
1202
- created_at?: string;
1203
- updated_at?: string;
1204
- }
1205
- declare const getLicenseKeyInstance: (http: HttpClient, licenseKeyInstanceId: string | number) => Promise<JsonApiResource<LicenseKeyInstanceAttributes>>;
1206
- declare const listLicenseKeyInstancesForLicenseKey: (http: HttpClient, licenseKeyId: string | number) => Promise<JsonApiResource<LicenseKeyInstanceAttributes>[]>;
1207
-
1208
- /**
1209
- * Subset of Lemon Squeezy license-key attributes used by the license key
1210
- * validator. Full schema at https://docs.lemonsqueezy.com/api/license-keys.
1211
- */
1212
- interface LicenseKeyAttributes extends GeneratedLicenseKeyAttributes {
1213
- key_short: string;
1214
- status: "active" | "inactive" | "expired" | "disabled";
1215
- expires_at: string | null;
1216
- activation_limit: number | null;
1217
- instances_count: number;
1218
- disabled: boolean;
1219
- store_id: number;
1220
- created_at?: string;
1221
- updated_at?: string;
1222
- }
1223
- /**
1224
- * Fetch a single license key by ID. Used by the license key validator to
1225
- * check activation limits, expiration, and store ownership.
1226
- *
1227
- * @param http - Shared API client.
1228
- * @param licenseKeyId - License key id.
1229
- * @returns The license key resource.
1230
- * @throws {FreshSqueezyError} On HTTP/network failure.
1231
- *
1232
- * @example
1233
- * ```ts
1234
- * const key = await getLicenseKey(http, 1);
1235
- * ```
1236
- */
1237
- declare const getLicenseKey: (http: HttpClient, licenseKeyId: string | number) => Promise<JsonApiResource<LicenseKeyAttributes>>;
1238
- /**
1239
- * List license keys for a store.
1240
- *
1241
- * @param http - Shared API client.
1242
- * @param storeId - Store filter.
1243
- * @returns License key resources.
1244
- * @throws {FreshSqueezyError} On HTTP/network failure.
1245
- *
1246
- * @example
1247
- * ```ts
1248
- * const keys = await listLicenseKeysForStore(http, 1);
1249
- * ```
1250
- */
1251
- declare const listLicenseKeysForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<LicenseKeyAttributes>[]>;
1252
- /**
1253
- * Update a license key (PATCH /v1/license-keys/:id) — e.g. `expires_at`, disabled.
1254
- * Docs: https://docs.lemonsqueezy.com/api/license-keys/update-license-key
1255
- *
1256
- * @param http - Shared API client.
1257
- * @param licenseKeyId - License key id.
1258
- * @param body - JSON:API update document.
1259
- * @returns The updated license key.
1260
- * @throws {FreshSqueezyError} On HTTP/network failure.
1261
- *
1262
- * @example
1263
- * ```ts
1264
- * const key = await updateLicenseKey(http, 1, {
1265
- * data: { type: "license-keys", id: "1", attributes: { disabled: true } },
1266
- * });
1267
- * ```
1268
- */
1269
- declare const updateLicenseKey: (http: HttpClient, licenseKeyId: string | number, body: unknown) => Promise<JsonApiResource<LicenseKeyAttributes>>;
1270
-
1271
- /**
1272
- * Order item attributes. `quantity` was added to the documented object in
1273
- * the 2024-12-06 changelog and is needed for multi-quantity reconciliation.
1274
- */
1275
- interface OrderItemAttributes extends GeneratedOrderItemAttributes {
1276
- order_id: number;
1277
- product_id: number;
1278
- variant_id: number;
1279
- product_name: string;
1280
- variant_name: string;
1281
- price: number;
1282
- quantity: number;
1283
- created_at?: string;
1284
- updated_at?: string;
1285
- }
1286
- declare const getOrderItem: (http: HttpClient, orderItemId: string | number) => Promise<JsonApiResource<OrderItemAttributes>>;
1287
- declare const listOrderItemsForOrder: (http: HttpClient, orderId: string | number) => Promise<JsonApiResource<OrderItemAttributes>[]>;
1288
-
1289
- interface OrderUrls {
1290
- receipt?: string;
1291
- }
1292
- interface OrderFirstItem {
1293
- id: number;
1294
- order_id?: number;
1295
- product_id: number;
1296
- variant_id: number;
1297
- product_name: string;
1298
- variant_name: string;
1299
- price: number;
1300
- quantity?: number;
1301
- created_at?: string;
1302
- updated_at?: string;
1303
- }
1304
- /**
1305
- * Subset of Lemon Squeezy order attributes fresh-squeezy understands.
1306
- *
1307
- * fresh-squeezy does not (yet) validate orders — the type is exported so
1308
- * consumers using the raw `client.request<OrderAttributes>()` escape hatch
1309
- * get a typed response that includes platform additions the official SDK
1310
- * has not yet picked up.
1311
- *
1312
- * Field provenance against the changelog
1313
- * (https://docs.lemonsqueezy.com/api/getting-started/changelog):
1314
- *
1315
- * - `status: "fraudulent"` — added 2024-09-10. Indicates a manual fraud
1316
- * flag; treat as terminal and refund or chargeback as appropriate.
1317
- * - `refunded_amount`, `refunded_amount_usd`, `refunded_amount_formatted`
1318
- * — added 2024-08-07. Useful for consumers reconciling partial refunds.
1319
- * - `tax_inclusive` — added 2024-02-05.
1320
- */
1321
- interface OrderAttributes extends GeneratedOrderAttributes {
1322
- store_id: number;
1323
- customer_id?: number;
1324
- identifier: string;
1325
- order_number: number;
1326
- user_name: string;
1327
- user_email: string;
1328
- currency: string;
1329
- currency_rate: string;
1330
- subtotal: number;
1331
- setup_fee?: number;
1332
- discount_total: number;
1333
- tax: number;
1334
- tax_inclusive?: boolean;
1335
- total: number;
1336
- refunded_amount?: number;
1337
- subtotal_usd?: number;
1338
- setup_fee_usd?: number;
1339
- discount_total_usd?: number;
1340
- tax_usd?: number;
1341
- total_usd?: number;
1342
- refunded_amount_usd?: number | null;
1343
- tax_name?: string | null;
1344
- tax_rate?: number | string | null;
1345
- refunded_amount_formatted?: string | null;
1346
- refunded?: boolean;
1347
- refunded_at?: string | null;
1348
- status: "pending" | "failed" | "paid" | "refunded" | "fraudulent" | "partial_refund";
1349
- status_formatted: string;
1350
- subtotal_formatted?: string;
1351
- setup_fee_formatted?: string;
1352
- discount_total_formatted?: string;
1353
- tax_formatted?: string;
1354
- total_formatted?: string;
1355
- first_order_item?: OrderFirstItem | null;
1356
- urls?: OrderUrls;
732
+ links?: VariantLink[] | Record<string, string>;
1357
733
  created_at?: string;
1358
734
  updated_at?: string;
1359
735
  test_mode?: boolean;
1360
736
  }
1361
737
  /**
1362
- * Fetch a single order by ID.
1363
- *
1364
- * @param http - Shared API client.
1365
- * @param orderId - Order id.
1366
- * @returns The order resource.
1367
- * @throws {FreshSqueezyError} On HTTP/network failure.
1368
- *
1369
- * @example
1370
- * ```ts
1371
- * const order = await getOrder(http, 1);
1372
- * ```
1373
- */
1374
- declare const getOrder: (http: HttpClient, orderId: string | number) => Promise<JsonApiResource<OrderAttributes>>;
1375
- /**
1376
- * List orders for a store.
1377
- *
1378
- * @param http - Shared API client.
1379
- * @param storeId - Store filter.
1380
- * @returns Order resources.
1381
- * @throws {FreshSqueezyError} On HTTP/network failure.
1382
- *
1383
- * @example
1384
- * ```ts
1385
- * const orders = await listOrdersForStore(http, 1);
1386
- * ```
1387
- */
1388
- declare const listOrdersForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<OrderAttributes>[]>;
1389
- /**
1390
- * Issue a full or partial order refund (POST /v1/orders/:id/refund).
1391
- * Docs: https://docs.lemonsqueezy.com/api/orders/issue-refund
1392
- *
1393
- * @param http - Shared API client.
1394
- * @param orderId - Order to refund.
1395
- * @param body - Optional JSON:API body (`attributes.amount` for partial).
1396
- * @returns The updated order after refund.
1397
- * @throws {FreshSqueezyError} On HTTP/network failure.
1398
- *
1399
- * @example
1400
- * ```ts
1401
- * const order = await refundOrder(http, 1);
1402
- * ```
1403
- */
1404
- declare const refundOrder: (http: HttpClient, orderId: string | number, body?: unknown) => Promise<JsonApiResource<OrderAttributes>>;
1405
- /**
1406
- * Generate an order invoice (POST /v1/orders/:id/generate-invoice).
1407
- * Docs: https://docs.lemonsqueezy.com/api/orders/generate-order-invoice
1408
- *
1409
- * @param http - Shared API client.
1410
- * @param orderId - Order id.
1411
- * @param body - Optional locale/name attributes document.
1412
- * @returns API response document (invoice URL payload).
1413
- * @throws {FreshSqueezyError} On HTTP/network failure.
1414
- *
1415
- * @example
1416
- * ```ts
1417
- * const invoice = await generateOrderInvoice(http, 1);
1418
- * ```
738
+ * Extended variant attributes for subscription plan validation. In Lemon
739
+ * Squeezy, "subscription plans" live as variants with `is_subscription: true`.
740
+ * These fields are only present on subscription variants and are checked by
741
+ * the subscription plan validator to catch misconfigured trial periods,
742
+ * zero-price plans, and invalid billing intervals.
1419
743
  */
1420
- declare const generateOrderInvoice: (http: HttpClient, orderId: string | number, body?: unknown) => Promise<unknown>;
1421
-
744
+ interface SubscriptionVariantAttributes extends VariantAttributes {
745
+ is_subscription: boolean;
746
+ interval: string | null;
747
+ interval_count: number | null;
748
+ has_free_trial: boolean;
749
+ trial_interval: string | null;
750
+ trial_interval_count: number | null;
751
+ price: number;
752
+ }
1422
753
  /**
1423
754
  * Subset of Lemon Squeezy price attributes. Prices are nested under
1424
755
  * variants in the API surface; consumers that read them directly via
@@ -1454,284 +785,127 @@ interface PriceAttributes extends GeneratedPriceAttributes {
1454
785
  updated_at?: string;
1455
786
  }
1456
787
  /**
1457
- * Fetch a single price by ID (read-only — no create/update/delete in LS API).
1458
- *
1459
- * @param http - Shared API client.
1460
- * @param priceId - Price id.
1461
- * @returns The price resource.
1462
- * @throws {FreshSqueezyError} On HTTP/network failure.
1463
- *
1464
- * @example
1465
- * ```ts
1466
- * const price = await getPrice(http, 1);
1467
- * ```
1468
- */
1469
- declare const getPrice: (http: HttpClient, priceId: string | number) => Promise<JsonApiResource<PriceAttributes>>;
1470
- /**
1471
- * List prices for a variant.
1472
- *
1473
- * @param http - Shared API client.
1474
- * @param variantId - Variant filter.
1475
- * @returns Price resources.
1476
- * @throws {FreshSqueezyError} On HTTP/network failure.
1477
- *
1478
- * @example
1479
- * ```ts
1480
- * const prices = await listPricesForVariant(http, 1);
1481
- * ```
788
+ * Lemon Squeezy file attributes, generated from the public object docs.
789
+ * Exposed so consumers can type file-resource escape-hatch calls without
790
+ * waiting for a hand-written validator.
1482
791
  */
1483
- declare const listPricesForVariant: (http: HttpClient, variantId: string | number) => Promise<JsonApiResource<PriceAttributes>[]>;
1484
-
792
+ interface FileAttributes extends GeneratedFileAttributes {
793
+ }
794
+ type CustomerStatus = "subscribed" | "unsubscribed" | "archived" | "requires_verification" | "invalid_email" | "bounced";
795
+ interface CustomerUrls {
796
+ customer_portal?: string | null;
797
+ }
1485
798
  /**
1486
- * Subset of product attributes we need for validation. `status` drives the
1487
- * "unpublished product" check; `store_id` drives ownership checks.
799
+ * Lemon Squeezy customer attributes. The customer portal URL was called out
800
+ * in the 2023-09-19 changelog and is useful for apps linking users back to
801
+ * billing without another API shape.
1488
802
  */
1489
- interface ProductAttributes extends GeneratedProductAttributes {
1490
- name: string;
1491
- slug: string;
1492
- description?: string | null;
1493
- status: "draft" | "published";
1494
- status_formatted?: string;
803
+ interface CustomerAttributes extends GeneratedCustomerAttributes {
1495
804
  store_id: number;
1496
- buy_now_url?: string | null;
1497
- from_price?: number | null;
1498
- to_price?: number | null;
805
+ name: string;
806
+ email: string;
807
+ status: CustomerStatus;
808
+ city?: string | null;
809
+ region?: string | null;
810
+ country?: string | null;
811
+ total_revenue_currency: number;
812
+ mrr: number;
813
+ status_formatted: string;
814
+ country_formatted?: string | null;
815
+ total_revenue_currency_formatted: string;
816
+ mrr_formatted: string;
817
+ urls?: CustomerUrls;
1499
818
  created_at?: string;
1500
819
  updated_at?: string;
820
+ test_mode?: boolean;
1501
821
  }
1502
- declare const getProduct: (http: HttpClient, productId: string | number) => Promise<JsonApiResource<ProductAttributes>>;
1503
- /**
1504
- * List every product in the store, paginated. Used by the CLI's
1505
- * interactive product picker; without pagination only the first 25
1506
- * products are offered.
1507
- */
1508
- declare const listProducts: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<ProductAttributes>[]>;
1509
-
1510
- /**
1511
- * Subset of store attributes fresh-squeezy reads.
1512
- * Full schema at https://docs.lemonsqueezy.com/api/stores.
1513
- */
1514
- interface StoreAttributes extends GeneratedStoreAttributes {
1515
- name: string;
1516
- slug: string;
1517
- domain?: string | null;
1518
- url?: string | null;
1519
- country?: string;
1520
- currency?: string;
1521
- plan?: string;
822
+ interface OrderUrls {
823
+ receipt?: string;
824
+ }
825
+ interface OrderFirstItem {
826
+ id: number;
827
+ order_id?: number;
828
+ product_id: number;
829
+ variant_id: number;
830
+ product_name: string;
831
+ variant_name: string;
832
+ price: number;
833
+ quantity?: number;
1522
834
  created_at?: string;
1523
835
  updated_at?: string;
1524
836
  }
1525
- declare const getStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<StoreAttributes>>;
1526
- /**
1527
- * List every store reachable with the configured API key, paginated.
1528
- * Used by `validateConnection` to populate the connection summary, and by
1529
- * the CLI's `--all-stores` flag. Pagination matters here for accounts that
1530
- * own a large catalogue of stores.
1531
- */
1532
- declare const listStores: (http: HttpClient) => Promise<JsonApiResource<StoreAttributes>[]>;
1533
-
1534
- type SubscriptionInvoiceStatus = "pending" | "paid" | "void" | "refunded" | "partial_refund";
1535
- type SubscriptionInvoiceBillingReason = "initial" | "renewal" | "updated";
1536
- interface SubscriptionInvoiceUrls {
1537
- invoice_url?: string;
1538
- }
1539
837
  /**
1540
- * Subscription invoice attributes, including fields added across the
1541
- * changelog: customer identity, tax inclusion, and partial refund amounts.
838
+ * Subset of Lemon Squeezy order attributes fresh-squeezy understands.
839
+ *
840
+ * fresh-squeezy does not (yet) validate orders — the type is exported so
841
+ * consumers using the raw `client.request<OrderAttributes>()` escape hatch
842
+ * get a typed response that includes platform additions the official SDK
843
+ * has not yet picked up.
844
+ *
845
+ * Field provenance against the changelog
846
+ * (https://docs.lemonsqueezy.com/api/getting-started/changelog):
847
+ *
848
+ * - `status: "fraudulent"` — added 2024-09-10. Indicates a manual fraud
849
+ * flag; treat as terminal and refund or chargeback as appropriate.
850
+ * - `refunded_amount`, `refunded_amount_usd`, `refunded_amount_formatted`
851
+ * — added 2024-08-07. Useful for consumers reconciling partial refunds.
852
+ * - `tax_inclusive` — added 2024-02-05.
1542
853
  */
1543
- interface SubscriptionInvoiceAttributes extends GeneratedSubscriptionInvoiceAttributes {
854
+ interface OrderAttributes extends GeneratedOrderAttributes {
1544
855
  store_id: number;
1545
- subscription_id: number;
1546
- customer_id: number;
856
+ customer_id?: number;
857
+ identifier: string;
858
+ order_number: number;
1547
859
  user_name: string;
1548
860
  user_email: string;
1549
- billing_reason: SubscriptionInvoiceBillingReason | string;
1550
- card_brand?: string | null;
1551
- card_last_four?: string | null;
1552
861
  currency: string;
1553
862
  currency_rate: string;
1554
- status: SubscriptionInvoiceStatus;
1555
- status_formatted: string;
1556
- refunded: boolean;
1557
- refunded_at: string | null;
1558
863
  subtotal: number;
864
+ setup_fee?: number;
1559
865
  discount_total: number;
1560
866
  tax: number;
1561
- tax_inclusive: boolean;
867
+ tax_inclusive?: boolean;
1562
868
  total: number;
1563
- refunded_amount: number;
1564
- subtotal_usd: number;
1565
- discount_total_usd: number;
1566
- tax_usd: number;
1567
- total_usd: number;
1568
- refunded_amount_usd: number;
1569
- subtotal_formatted: string;
1570
- discount_total_formatted: string;
1571
- tax_formatted: string;
1572
- total_formatted: string;
1573
- refunded_amount_formatted: string;
1574
- urls?: SubscriptionInvoiceUrls;
1575
- created_at?: string;
1576
- updated_at?: string;
1577
- test_mode?: boolean;
1578
- }
1579
- /**
1580
- * Retrieve a subscription invoice.
1581
- *
1582
- * @param http - Shared API client.
1583
- * @param subscriptionInvoiceId - Invoice id.
1584
- * @returns The invoice resource.
1585
- * @throws {FreshSqueezyError} On HTTP/network failure.
1586
- *
1587
- * @example
1588
- * ```ts
1589
- * const invoice = await getSubscriptionInvoice(http, 1);
1590
- * ```
1591
- */
1592
- declare const getSubscriptionInvoice: (http: HttpClient, subscriptionInvoiceId: string | number) => Promise<JsonApiResource<SubscriptionInvoiceAttributes>>;
1593
- /**
1594
- * List invoices for a subscription.
1595
- *
1596
- * @param http - Shared API client.
1597
- * @param subscriptionId - Parent subscription id.
1598
- * @returns Invoice resources.
1599
- * @throws {FreshSqueezyError} On HTTP/network failure.
1600
- *
1601
- * @example
1602
- * ```ts
1603
- * const invoices = await listSubscriptionInvoicesForSubscription(http, 1);
1604
- * ```
1605
- */
1606
- declare const listSubscriptionInvoicesForSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionInvoiceAttributes>[]>;
1607
- /**
1608
- * Refund a subscription invoice (POST /v1/subscription-invoices/:id/refund).
1609
- * Docs: https://docs.lemonsqueezy.com/api/subscription-invoices/issue-refund
1610
- *
1611
- * @param http - Shared API client.
1612
- * @param subscriptionInvoiceId - Invoice id.
1613
- * @param body - Optional partial-refund document.
1614
- * @returns The updated invoice.
1615
- * @throws {FreshSqueezyError} On HTTP/network failure.
1616
- *
1617
- * @example
1618
- * ```ts
1619
- * const invoice = await refundSubscriptionInvoice(http, 1);
1620
- * ```
1621
- */
1622
- declare const refundSubscriptionInvoice: (http: HttpClient, subscriptionInvoiceId: string | number, body?: unknown) => Promise<JsonApiResource<SubscriptionInvoiceAttributes>>;
1623
- /**
1624
- * Generate a subscription invoice PDF/URL.
1625
- * Docs: https://docs.lemonsqueezy.com/api/subscription-invoices/generate-subscription-invoice
1626
- *
1627
- * @param http - Shared API client.
1628
- * @param subscriptionInvoiceId - Invoice id.
1629
- * @param body - Optional generation attributes.
1630
- * @returns API response document.
1631
- * @throws {FreshSqueezyError} On HTTP/network failure.
1632
- *
1633
- * @example
1634
- * ```ts
1635
- * const doc = await generateSubscriptionInvoice(http, 1);
1636
- * ```
1637
- */
1638
- declare const generateSubscriptionInvoice: (http: HttpClient, subscriptionInvoiceId: string | number, body?: unknown) => Promise<unknown>;
1639
-
1640
- interface SubscriptionItemAttributes extends GeneratedSubscriptionItemAttributes {
1641
- subscription_id: number;
1642
- price_id: number;
1643
- quantity: number;
1644
- is_usage_based: boolean;
869
+ refunded_amount?: number;
870
+ subtotal_usd?: number;
871
+ setup_fee_usd?: number;
872
+ discount_total_usd?: number;
873
+ tax_usd?: number;
874
+ total_usd?: number;
875
+ refunded_amount_usd?: number | null;
876
+ tax_name?: string | null;
877
+ tax_rate?: number | string | null;
878
+ refunded_amount_formatted?: string | null;
879
+ refunded?: boolean;
880
+ refunded_at?: string | null;
881
+ status: "pending" | "failed" | "paid" | "refunded" | "fraudulent" | "partial_refund";
882
+ status_formatted: string;
883
+ subtotal_formatted?: string;
884
+ setup_fee_formatted?: string;
885
+ discount_total_formatted?: string;
886
+ tax_formatted?: string;
887
+ total_formatted?: string;
888
+ first_order_item?: OrderFirstItem | null;
889
+ urls?: OrderUrls;
1645
890
  created_at?: string;
1646
- updated_at?: string;
1647
- }
1648
- /**
1649
- * Attributes accepted by the update subscription item endpoint. The proration
1650
- * controls were added in the 2024-02-12 changelog.
1651
- */
1652
- interface SubscriptionItemUpdateAttributes {
1653
- quantity?: number;
1654
- invoice_immediately?: boolean;
1655
- disable_prorations?: boolean;
1656
- }
1657
- /**
1658
- * Retrieve a subscription item.
1659
- *
1660
- * @param http - Shared API client.
1661
- * @param subscriptionItemId - Item id.
1662
- * @returns The subscription item resource.
1663
- * @throws {FreshSqueezyError} On HTTP/network failure.
1664
- *
1665
- * @example
1666
- * ```ts
1667
- * const item = await getSubscriptionItem(http, 1);
1668
- * ```
1669
- */
1670
- declare const getSubscriptionItem: (http: HttpClient, subscriptionItemId: string | number) => Promise<JsonApiResource<SubscriptionItemAttributes>>;
1671
- /**
1672
- * List subscription items for a subscription.
1673
- *
1674
- * @param http - Shared API client.
1675
- * @param subscriptionId - Parent subscription id.
1676
- * @returns Subscription item resources.
1677
- * @throws {FreshSqueezyError} On HTTP/network failure.
1678
- *
1679
- * @example
1680
- * ```ts
1681
- * const items = await listSubscriptionItemsForSubscription(http, 1);
1682
- * ```
1683
- */
1684
- declare const listSubscriptionItemsForSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionItemAttributes>[]>;
1685
- /**
1686
- * Build a JSON:API update body for a subscription item (quantity / proration).
1687
- *
1688
- * @param subscriptionItemId - Item id embedded in the document.
1689
- * @param attributes - Fields accepted by the update endpoint.
1690
- * @returns A single JSON:API document (not multiple loose objects).
1691
- *
1692
- * @example
1693
- * ```ts
1694
- * const body = buildSubscriptionItemUpdateBody(1, { quantity: 3 });
1695
- * await updateSubscriptionItem(http, 1, body);
1696
- * ```
1697
- */
1698
- declare const buildSubscriptionItemUpdateBody: (subscriptionItemId: string | number, attributes: SubscriptionItemUpdateAttributes) => unknown;
1699
- /**
1700
- * Update a subscription item (PATCH /v1/subscription-items/:id).
1701
- * Docs: https://docs.lemonsqueezy.com/api/subscription-items/update-subscription-item
1702
- *
1703
- * @param http - Shared API client.
1704
- * @param subscriptionItemId - Item id.
1705
- * @param body - JSON:API update document.
1706
- * @returns The updated subscription item.
1707
- * @throws {FreshSqueezyError} On HTTP/network failure.
1708
- *
1709
- * @example
1710
- * ```ts
1711
- * const item = await updateSubscriptionItem(
1712
- * http,
1713
- * 1,
1714
- * buildSubscriptionItemUpdateBody(1, { quantity: 2 }),
1715
- * );
1716
- * ```
1717
- */
1718
- declare const updateSubscriptionItem: (http: HttpClient, subscriptionItemId: string | number, body: unknown) => Promise<JsonApiResource<SubscriptionItemAttributes>>;
891
+ updated_at?: string;
892
+ test_mode?: boolean;
893
+ }
1719
894
  /**
1720
- * Current-period usage for a usage-based subscription item.
1721
- * Docs: https://docs.lemonsqueezy.com/api/subscription-items/retrieve-subscription-item-current-usage
1722
- *
1723
- * @param http - Shared API client.
1724
- * @param subscriptionItemId - Item id.
1725
- * @returns Usage payload for the current billing period.
1726
- * @throws {FreshSqueezyError} On HTTP/network failure.
1727
- *
1728
- * @example
1729
- * ```ts
1730
- * const usage = await getSubscriptionItemCurrentUsage(http, 1);
1731
- * ```
895
+ * Order item attributes. `quantity` was added to the documented object in
896
+ * the 2024-12-06 changelog and is needed for multi-quantity reconciliation.
1732
897
  */
1733
- declare const getSubscriptionItemCurrentUsage: (http: HttpClient, subscriptionItemId: string | number) => Promise<unknown>;
1734
-
898
+ interface OrderItemAttributes extends GeneratedOrderItemAttributes {
899
+ order_id: number;
900
+ product_id: number;
901
+ variant_id: number;
902
+ product_name: string;
903
+ variant_name: string;
904
+ price: number;
905
+ quantity: number;
906
+ created_at?: string;
907
+ updated_at?: string;
908
+ }
1735
909
  /**
1736
910
  * URLs Lemon Squeezy attaches to a subscription so consumers can deep-link
1737
911
  * users to billing pages. The set has grown over time; we keep optional
@@ -1802,68 +976,82 @@ interface SubscriptionAttributes extends GeneratedSubscriptionAttributes {
1802
976
  /** Compatibility field for older fresh-squeezy consumers; prefer SubscriptionInvoiceAttributes.tax_inclusive. */
1803
977
  tax_inclusive?: boolean;
1804
978
  }
979
+ interface SubscriptionItemAttributes extends GeneratedSubscriptionItemAttributes {
980
+ subscription_id: number;
981
+ price_id: number;
982
+ quantity: number;
983
+ is_usage_based: boolean;
984
+ created_at?: string;
985
+ updated_at?: string;
986
+ }
1805
987
  /**
1806
- * Fetch a single subscription by ID.
1807
- *
1808
- * @param http - Shared API client.
1809
- * @param subscriptionId - Subscription id.
1810
- * @returns The subscription resource.
1811
- * @throws {FreshSqueezyError} On HTTP/network failure.
1812
- *
1813
- * @example
1814
- * ```ts
1815
- * const sub = await getSubscription(http, 1);
1816
- * ```
1817
- */
1818
- declare const getSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionAttributes>>;
1819
- /**
1820
- * List subscriptions for a store.
1821
- *
1822
- * @param http - Shared API client.
1823
- * @param storeId - Store filter.
1824
- * @returns Subscription resources.
1825
- * @throws {FreshSqueezyError} On HTTP/network failure.
1826
- *
1827
- * @example
1828
- * ```ts
1829
- * const subs = await listSubscriptionsForStore(http, 1);
1830
- * ```
988
+ * Attributes accepted by the update subscription item endpoint. The proration
989
+ * controls were added in the 2024-02-12 changelog.
1831
990
  */
1832
- declare const listSubscriptionsForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<SubscriptionAttributes>[]>;
991
+ interface SubscriptionItemUpdateAttributes {
992
+ quantity?: number;
993
+ invoice_immediately?: boolean;
994
+ disable_prorations?: boolean;
995
+ }
1833
996
  /**
1834
- * Update a subscription (PATCH /v1/subscriptions/:id) — plan change, pause, etc.
1835
- * Docs: https://docs.lemonsqueezy.com/api/subscriptions/update-subscription
997
+ * Build a JSON:API update body for a subscription item (quantity / proration).
1836
998
  *
1837
- * @param http - Shared API client.
1838
- * @param subscriptionId - Subscription id.
1839
- * @param body - JSON:API update document.
1840
- * @returns The updated subscription.
1841
- * @throws {FreshSqueezyError} On HTTP/network failure.
999
+ * @param subscriptionItemId - Item id embedded in the document.
1000
+ * @param attributes - Fields accepted by the update endpoint.
1001
+ * @returns A single JSON:API document (not multiple loose objects).
1842
1002
  *
1843
1003
  * @example
1844
1004
  * ```ts
1845
- * const sub = await updateSubscription(http, 1, {
1846
- * data: { type: "subscriptions", id: "1", attributes: { variant_id: 2 } },
1847
- * });
1005
+ * const body = buildSubscriptionItemUpdateBody(1, { quantity: 3 });
1006
+ * await lemon.subscriptionItems.update(1, body);
1848
1007
  * ```
1849
1008
  */
1850
- declare const updateSubscription: (http: HttpClient, subscriptionId: string | number, body: unknown) => Promise<JsonApiResource<SubscriptionAttributes>>;
1009
+ declare const buildSubscriptionItemUpdateBody: (subscriptionItemId: string | number, attributes: SubscriptionItemUpdateAttributes) => unknown;
1010
+ type SubscriptionInvoiceStatus = "pending" | "paid" | "void" | "refunded" | "partial_refund";
1011
+ type SubscriptionInvoiceBillingReason = "initial" | "renewal" | "updated";
1012
+ interface SubscriptionInvoiceUrls {
1013
+ invoice_url?: string;
1014
+ }
1851
1015
  /**
1852
- * Cancel a subscription (DELETE /v1/subscriptions/:id).
1853
- * Docs: https://docs.lemonsqueezy.com/api/subscriptions/cancel-subscription
1854
- *
1855
- * @param http - Shared API client.
1856
- * @param subscriptionId - Subscription id.
1857
- * @returns The cancelled subscription resource when the API returns one.
1858
- * @throws {FreshSqueezyError} On HTTP/network failure.
1859
- *
1860
- * @example
1861
- * ```ts
1862
- * const sub = await cancelSubscription(http, 1);
1863
- * ```
1016
+ * Subscription invoice attributes, including fields added across the
1017
+ * changelog: customer identity, tax inclusion, and partial refund amounts.
1864
1018
  */
1865
- declare const cancelSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionAttributes> | undefined>;
1866
-
1019
+ interface SubscriptionInvoiceAttributes extends GeneratedSubscriptionInvoiceAttributes {
1020
+ store_id: number;
1021
+ subscription_id: number;
1022
+ customer_id: number;
1023
+ user_name: string;
1024
+ user_email: string;
1025
+ billing_reason: SubscriptionInvoiceBillingReason | string;
1026
+ card_brand?: string | null;
1027
+ card_last_four?: string | null;
1028
+ currency: string;
1029
+ currency_rate: string;
1030
+ status: SubscriptionInvoiceStatus;
1031
+ status_formatted: string;
1032
+ refunded: boolean;
1033
+ refunded_at: string | null;
1034
+ subtotal: number;
1035
+ discount_total: number;
1036
+ tax: number;
1037
+ tax_inclusive: boolean;
1038
+ total: number;
1039
+ refunded_amount: number;
1040
+ subtotal_usd: number;
1041
+ discount_total_usd: number;
1042
+ tax_usd: number;
1043
+ total_usd: number;
1044
+ refunded_amount_usd: number;
1045
+ subtotal_formatted: string;
1046
+ discount_total_formatted: string;
1047
+ tax_formatted: string;
1048
+ total_formatted: string;
1049
+ refunded_amount_formatted: string;
1050
+ urls?: SubscriptionInvoiceUrls;
1051
+ created_at?: string;
1052
+ updated_at?: string;
1053
+ test_mode?: boolean;
1054
+ }
1867
1055
  type UsageRecordAction = "increment" | "set";
1868
1056
  interface UsageRecordAttributes extends GeneratedUsageRecordAttributes {
1869
1057
  subscription_item_id: number;
@@ -1873,271 +1061,321 @@ interface UsageRecordAttributes extends GeneratedUsageRecordAttributes {
1873
1061
  updated_at?: string;
1874
1062
  }
1875
1063
  /**
1876
- * Retrieve a usage record.
1877
- *
1878
- * @param http - Shared API client.
1879
- * @param usageRecordId - Usage record id.
1880
- * @returns The usage record resource.
1881
- * @throws {FreshSqueezyError} On HTTP/network failure.
1882
- *
1883
- * @example
1884
- * ```ts
1885
- * const record = await getUsageRecord(http, 1);
1886
- * ```
1887
- */
1888
- declare const getUsageRecord: (http: HttpClient, usageRecordId: string | number) => Promise<JsonApiResource<UsageRecordAttributes>>;
1889
- /**
1890
- * List usage records for a subscription item.
1891
- *
1892
- * @param http - Shared API client.
1893
- * @param subscriptionItemId - Parent subscription item id.
1894
- * @returns Usage record resources.
1895
- * @throws {FreshSqueezyError} On HTTP/network failure.
1896
- *
1897
- * @example
1898
- * ```ts
1899
- * const records = await listUsageRecordsForSubscriptionItem(http, 1);
1900
- * ```
1901
- */
1902
- declare const listUsageRecordsForSubscriptionItem: (http: HttpClient, subscriptionItemId: string | number) => Promise<JsonApiResource<UsageRecordAttributes>[]>;
1903
- /**
1904
- * Create a usage record (POST /v1/usage-records).
1905
- * Docs: https://docs.lemonsqueezy.com/api/usage-records/create-usage-record
1906
- *
1907
- * @param http - Shared API client.
1908
- * @param body - JSON:API create document.
1909
- * @returns The created usage record.
1910
- * @throws {FreshSqueezyError} On HTTP/network failure.
1911
- *
1912
- * @example
1913
- * ```ts
1914
- * const record = await createUsageRecord(http, {
1915
- * data: {
1916
- * type: "usage-records",
1917
- * attributes: { quantity: 5, action: "increment" },
1918
- * relationships: {
1919
- * "subscription-item": { data: { type: "subscription-items", id: "1" } },
1920
- * },
1921
- * },
1922
- * });
1923
- * ```
1064
+ * Subset of Lemon Squeezy discount attributes used by the discount validator.
1065
+ * Full schema at https://docs.lemonsqueezy.com/api/discounts.
1924
1066
  */
1925
- declare const createUsageRecord: (http: HttpClient, body: unknown) => Promise<JsonApiResource<UsageRecordAttributes>>;
1926
-
1067
+ interface DiscountAttributes extends GeneratedDiscountAttributes {
1068
+ name: string;
1069
+ code: string;
1070
+ amount: number;
1071
+ amount_type: "percent" | "fixed";
1072
+ is_limited_to_products: boolean;
1073
+ is_limited_redemptions: boolean;
1074
+ max_redemptions: number;
1075
+ starts_at: string | null;
1076
+ expires_at: string | null;
1077
+ status: "draft" | "published";
1078
+ duration: "once" | "repeating" | "forever";
1079
+ store_id: number;
1080
+ created_at?: string;
1081
+ updated_at?: string;
1082
+ }
1083
+ interface DiscountRedemptionAttributes extends GeneratedDiscountRedemptionAttributes {
1084
+ discount_id: number;
1085
+ order_id: number;
1086
+ discount_name: string;
1087
+ discount_code: string;
1088
+ discount_amount: number;
1089
+ discount_amount_type: "percent" | "fixed";
1090
+ amount: number;
1091
+ created_at?: string;
1092
+ updated_at?: string;
1093
+ }
1927
1094
  /**
1928
- * Subset of the Lemon Squeezy `users` resource attributes we rely on.
1929
- * Full schema at https://docs.lemonsqueezy.com/api/users.
1095
+ * Subset of Lemon Squeezy license-key attributes used by the license key
1096
+ * validator. Full schema at https://docs.lemonsqueezy.com/api/license-keys.
1930
1097
  */
1931
- interface UserAttributes extends GeneratedUserAttributes {
1098
+ interface LicenseKeyAttributes extends GeneratedLicenseKeyAttributes {
1099
+ key_short: string;
1100
+ status: "active" | "inactive" | "expired" | "disabled";
1101
+ expires_at: string | null;
1102
+ activation_limit: number | null;
1103
+ instances_count: number;
1104
+ disabled: boolean;
1105
+ store_id: number;
1106
+ created_at?: string;
1107
+ updated_at?: string;
1108
+ }
1109
+ interface LicenseKeyInstanceAttributes extends GeneratedLicenseKeyInstanceAttributes {
1110
+ license_key_id: number;
1111
+ identifier: string;
1932
1112
  name: string;
1933
- email: string;
1934
- color?: string;
1935
- avatar_url?: string | null;
1936
- has_custom_avatar?: boolean;
1937
- createdAt?: string;
1938
- updatedAt?: string;
1113
+ created_at?: string;
1114
+ updated_at?: string;
1115
+ }
1116
+ type CheckoutLocale = "bg" | "hr" | "cs" | "da" | "nl" | "en" | "et" | "fil" | "fi" | "fr" | "de" | "el" | "hu" | "id" | "it" | "ja" | "ko" | "lv" | "lt" | "ms" | "mt" | "pl" | "pt" | "ro" | "ru" | "zh-CN" | "sk" | "sl" | "es" | "sv" | "th" | "tr" | "vi";
1117
+ interface CheckoutProductOptions {
1118
+ name?: string;
1119
+ description?: string;
1120
+ media?: string[];
1121
+ redirect_url?: string;
1122
+ receipt_button_text?: string;
1123
+ receipt_link_url?: string;
1124
+ receipt_thank_you_note?: string;
1125
+ enabled_variants?: number[];
1126
+ }
1127
+ interface CheckoutOptions {
1128
+ embed?: boolean;
1129
+ media?: boolean;
1130
+ logo?: boolean;
1131
+ desc?: boolean;
1132
+ discount?: boolean;
1133
+ subscription_preview?: boolean;
1134
+ /** Added 2024-03-28. */
1135
+ skip_trial?: boolean;
1136
+ /** Deprecated 2024-09-04; keep typed so old payloads still compile. */
1137
+ dark?: boolean;
1138
+ background_color?: string;
1139
+ headings_color?: string;
1140
+ primary_text_color?: string;
1141
+ secondary_text_color?: string;
1142
+ links_color?: string;
1143
+ borders_color?: string;
1144
+ checkbox_color?: string;
1145
+ active_state_color?: string;
1146
+ button_color?: string;
1147
+ button_text_color?: string;
1148
+ terms_privacy_color?: string;
1149
+ locale?: CheckoutLocale | string | null;
1150
+ }
1151
+ interface CheckoutVariantQuantity {
1152
+ variant_id: number;
1153
+ quantity: number;
1154
+ }
1155
+ interface CheckoutData {
1156
+ email?: string;
1157
+ name?: string;
1158
+ billing_address?: {
1159
+ country?: string;
1160
+ zip?: string;
1161
+ };
1162
+ tax_number?: string;
1163
+ discount_code?: string;
1164
+ custom?: Record<string, unknown>;
1165
+ /** Added 2023-08-23 for multi-variant checkout quantities. */
1166
+ variant_quantities?: CheckoutVariantQuantity[];
1167
+ }
1168
+ interface CheckoutPreview {
1169
+ currency: string;
1170
+ currency_rate: number | string;
1171
+ subtotal: number;
1172
+ discount_total: number;
1173
+ tax: number;
1174
+ total: number;
1175
+ subtotal_usd: number;
1176
+ discount_total_usd: number;
1177
+ tax_usd: number;
1178
+ total_usd: number;
1179
+ subtotal_formatted: string;
1180
+ discount_total_formatted: string;
1181
+ tax_formatted: string;
1182
+ total_formatted: string;
1183
+ }
1184
+ interface CheckoutAttributes extends GeneratedCheckoutAttributes {
1185
+ store_id: number;
1186
+ variant_id: number;
1187
+ custom_price?: number | null;
1188
+ product_options?: CheckoutProductOptions;
1189
+ checkout_options?: CheckoutOptions;
1190
+ checkout_data?: CheckoutData;
1191
+ preview?: CheckoutPreview;
1192
+ expires_at?: string | null;
1193
+ url?: string;
1194
+ created_at?: string;
1195
+ updated_at?: string;
1196
+ test_mode?: boolean;
1939
1197
  }
1940
1198
  /**
1941
- * Document-level metadata on `/v1/users/me`.
1942
- *
1943
- * `test_mode` was added to the endpoint on 2024-01-05 (per the Lemon Squeezy
1944
- * API changelog: https://docs.lemonsqueezy.com/api/getting-started/changelog).
1945
- * It reports whether the *key* being used is a test-mode key, independent of
1946
- * what the caller declared. The connection validator compares this against
1947
- * the caller's declared mode to catch the common "prod key in staging"
1948
- * (or vice versa) misconfiguration.
1199
+ * Subset of webhook attributes we read. `events` is an ordered list of
1200
+ * subscribed event names; the validator cross-references these against the
1201
+ * support manifest to catch missing subscriptions.
1949
1202
  */
1950
- interface UserMeta {
1203
+ interface WebhookAttributes extends GeneratedWebhookAttributes {
1204
+ store_id: number;
1205
+ url: string;
1206
+ events: string[];
1207
+ last_sent_at?: string | null;
1208
+ created_at?: string;
1209
+ updated_at?: string;
1951
1210
  test_mode?: boolean;
1952
1211
  }
1212
+ type AffiliateStatus = "active" | "pending" | "disabled";
1953
1213
  /**
1954
- * Authenticated-user document with the `data` + `meta` block preserved.
1955
- * The connection validator needs the meta flag, so we return the full
1956
- * document here rather than just `data` as the collection helpers do.
1214
+ * Affiliate attributes added with the 2025-01-21 Affiliates API surface.
1215
+ * No validator consumes these yet; they type `lemon.affiliates.*` results.
1957
1216
  */
1958
- type AuthenticatedUserDocument = JsonApiDocument<UserAttributes> & {
1959
- meta?: UserMeta;
1960
- };
1217
+ interface AffiliateAttributes extends GeneratedAffiliateAttributes {
1218
+ store_id: number;
1219
+ user_id: number;
1220
+ user_name: string;
1221
+ user_email: string;
1222
+ share_domain: string;
1223
+ status: AffiliateStatus;
1224
+ application_note?: string | null;
1225
+ products?: unknown;
1226
+ total_earnings: number;
1227
+ unpaid_earnings: number;
1228
+ created_at?: string;
1229
+ updated_at?: string;
1230
+ }
1231
+
1961
1232
  /**
1962
- * Fetch the user associated with the API key. Primary use is the connection
1963
- * validator: a successful call confirms the key is valid, surfaces the
1964
- * account identity for logs, and exposes `meta.test_mode` for mode
1965
- * mismatch detection.
1966
- *
1967
- * @param http - Shared API client.
1968
- * @returns Full `/v1/users/me` document including `meta.test_mode`.
1969
- * @throws {FreshSqueezyError} On HTTP/network failure.
1233
+ * Options for a single HTTP request.
1970
1234
  *
1971
- * @example
1972
- * ```ts
1973
- * const doc = await getAuthenticatedUser(http);
1974
- * const mode = doc.meta?.test_mode ? "test" : "live";
1975
- * ```
1235
+ * `path` is a Lemon Squeezy API path starting with `/v1/...`. The `query`
1236
+ * record is serialized via `URLSearchParams` (JSON:API bracket keys such as
1237
+ * `filter[store_id]` are accepted as-is and percent-encoded in the final URL).
1976
1238
  */
1977
- declare const getAuthenticatedUser: (http: HttpClient) => Promise<AuthenticatedUserDocument>;
1978
-
1979
- interface VariantLink {
1980
- title: string;
1981
- url: string;
1239
+ interface RequestOptions {
1240
+ method?: "GET" | "POST" | "PATCH" | "DELETE";
1241
+ path: string;
1242
+ query?: Record<string, string | number | undefined>;
1243
+ /** JSON:API document or other request body; stringified when present. */
1244
+ body?: unknown;
1245
+ signal?: AbortSignal;
1982
1246
  }
1983
1247
  /**
1984
- * Variant attributes used by the product validator to detect
1985
- * variant/price drift from the product they belong to.
1248
+ * Low-level HTTP client. Callers usually go through resource/validator helpers,
1249
+ * but this is also exposed as the public escape hatch so consumers can reach
1250
+ * endpoints fresh-squeezy does not wrap yet.
1251
+ *
1252
+ * Responsibilities kept in this one place (the single transport chokepoint):
1253
+ * - auth header injection
1254
+ * - query string serialization (JSON:API bracket keys via URLSearchParams)
1255
+ * - response parsing + error normalization
1256
+ * - surfacing HTTP status in `FreshSqueezyError`
1257
+ * - walking paginated collections
1986
1258
  */
1987
- interface VariantAttributes extends GeneratedVariantAttributes {
1988
- product_id: number;
1989
- name: string;
1990
- slug: string;
1991
- description?: string | null;
1992
- has_license_keys?: boolean;
1993
- license_activation_limit?: number | null;
1994
- is_license_limit_unlimited?: boolean;
1995
- license_length_value?: number | null;
1996
- license_length_unit?: "day" | "week" | "month" | "year" | null;
1997
- is_license_length_unlimited?: boolean;
1998
- status: "pending" | "draft" | "published";
1999
- status_formatted?: string;
2000
- is_subscription?: boolean;
2001
- interval?: string | null;
2002
- interval_count?: number | null;
2003
- sort?: number;
1259
+ declare class HttpClient {
1260
+ private readonly config;
1261
+ constructor(config: ResolvedConfig);
1262
+ request<T>(options: RequestOptions): Promise<T>;
2004
1263
  /**
2005
- * Hosted-checkout-style links keyed by purpose. Added 2024-06-09 — older
2006
- * SDK and validator versions don't surface this field, so consumers had
2007
- * to read `meta.product_links` manually before. Optional because the
2008
- * field is absent on older variants.
1264
+ * Fetch a single JSON:API resource and return its `data` object.
2009
1265
  */
2010
- links?: VariantLink[] | Record<string, string>;
2011
- created_at?: string;
2012
- updated_at?: string;
2013
- test_mode?: boolean;
1266
+ getResource<TAttr>(path: string): Promise<JsonApiResource<TAttr>>;
1267
+ /**
1268
+ * Walk a JSON:API collection across every page and concatenate the
1269
+ * results. Lemon Squeezy returns 25 items per page by default; without
1270
+ * pagination, validators silently miss anything past the first page (e.g.
1271
+ * `validateWebhook` on a store with 26+ webhooks would falsely report
1272
+ * `WEBHOOK_NOT_FOUND` for any webhook on page 2).
1273
+ *
1274
+ * Stops as soon as `meta.page.lastPage` is reached. Falls back to a
1275
+ * single-page fetch if the API does not surface page metadata.
1276
+ *
1277
+ * Caller-supplied `page[number]` is honored as the starting page; we
1278
+ * advance from there. `page[size]` is left untouched so callers can tune
1279
+ * batch size (max 100 per Lemon Squeezy docs).
1280
+ */
1281
+ paginate<TAttr>(path: string, query?: RequestOptions["query"]): Promise<JsonApiResource<TAttr>[]>;
1282
+ private requestUrl;
2014
1283
  }
1284
+
2015
1285
  /**
2016
- * Extended variant attributes for subscription plan validation. In Lemon
2017
- * Squeezy, "subscription plans" live as variants with `is_subscription: true`.
2018
- * These fields are only present on subscription variants and are checked by
2019
- * the subscription plan validator to catch misconfigured trial periods,
2020
- * zero-price plans, and invalid billing intervals.
1286
+ * Docs-backed ops matrix for Lemon Squeezy.
1287
+ *
1288
+ * Only verbs that exist at https://docs.lemonsqueezy.com/api are listed.
1289
+ * Catalog resources (products, variants, prices, files, stores, …) are
1290
+ * read-only. CI changelog scrape may propose gaps; this registry is what ships.
2021
1291
  */
2022
- interface SubscriptionVariantAttributes extends VariantAttributes {
2023
- is_subscription: boolean;
2024
- interval: string | null;
2025
- interval_count: number | null;
2026
- has_free_trial: boolean;
2027
- trial_interval: string | null;
2028
- trial_interval_count: number | null;
2029
- price: number;
2030
- }
1292
+ /** CLI / client verb tokens, including non-CRUD LS actions. */
1293
+ type OpVerb = "get" | "list" | "create" | "update" | "delete" | "cancel" | "refund" | "generate-invoice" | "current-usage";
2031
1294
  /**
2032
- * Fetch a single variant by ID. Used by the subscription plan validator to
2033
- * inspect subscription-specific fields (interval, trial, price).
1295
+ * One implemented, documented operation.
1296
+ *
1297
+ * @remarks `docsPath` is the path under `/api/` on the LS docs site.
2034
1298
  */
2035
- declare const getVariant: <TAttr = VariantAttributes>(http: HttpClient, variantId: string | number) => Promise<JsonApiResource<TAttr>>;
1299
+ interface ResourceVerbSpec {
1300
+ /** CLI resource token (singular), e.g. `webhook`. */
1301
+ resource: string;
1302
+ verb: OpVerb;
1303
+ /** Docs path fragment, e.g. `webhooks/create-webhook`. */
1304
+ docsPath: string;
1305
+ /** Requires --yes or TTY confirm always (delete/cancel/refund). */
1306
+ destructive?: boolean;
1307
+ body?: "required" | "optional" | "none";
1308
+ /**
1309
+ * How list/get resolve the primary id filter.
1310
+ * - `id` — --id
1311
+ * - `store` — --store-ids (first) or store filter
1312
+ * - `parent` — --parent-id (subscription, order, product, …)
1313
+ */
1314
+ idRole?: "id" | "store" | "parent" | "none";
1315
+ }
2036
1316
  /**
2037
- * List every variant of the product, paginated so products with more than
2038
- * one page of variants don't trip the `VARIANT_UNPUBLISHED` heuristic when
2039
- * the only published variants happen to live past page 1.
1317
+ * Arguments for a single resource op invocation.
1318
+ *
1319
+ * One named input type — not a bag of unrelated returns.
2040
1320
  */
2041
- declare const listVariantsForProduct: (http: HttpClient, productId: string | number) => Promise<JsonApiResource<VariantAttributes>[]>;
2042
-
1321
+ interface InvokeOpArgs {
1322
+ id?: string | number;
1323
+ storeId?: string | number;
1324
+ parentId?: string | number;
1325
+ body?: unknown;
1326
+ }
2043
1327
  /**
2044
- * Subset of webhook attributes we read. `events` is an ordered list of
2045
- * subscribed event names; the validator cross-references these against the
2046
- * support manifest to catch missing subscriptions.
1328
+ * Implemented ops, one entry per documented resource verb. Keep in sync with
1329
+ * the nested client in `createFreshSqueezy`.
2047
1330
  */
2048
- interface WebhookAttributes extends GeneratedWebhookAttributes {
2049
- store_id: number;
2050
- url: string;
2051
- events: string[];
2052
- last_sent_at?: string | null;
2053
- created_at?: string;
2054
- updated_at?: string;
2055
- test_mode?: boolean;
2056
- }
1331
+ declare const resourceRegistry: readonly ResourceVerbSpec[];
2057
1332
  /**
2058
- * Retrieve one webhook by id.
2059
- *
2060
- * @param http - Shared API client.
2061
- * @param webhookId - Webhook id.
2062
- * @returns The webhook resource.
2063
- * @throws {FreshSqueezyError} On HTTP/network failure.
1333
+ * Normalize a CLI resource token to the singular registry key.
2064
1334
  *
2065
- * @example
2066
- * ```ts
2067
- * const webhook = await getWebhook(http, 1);
2068
- * ```
1335
+ * @param resource - Raw token (`products`, `order_items`, `webhook`).
1336
+ * @returns Canonical singular resource name used in `resourceRegistry`.
2069
1337
  */
2070
- declare const getWebhook: (http: HttpClient, webhookId: string | number) => Promise<JsonApiResource<WebhookAttributes>>;
1338
+ declare const normalizeResourceName: (resource: string) => string;
2071
1339
  /**
2072
- * List every webhook registered on the store, walking pagination so a store
2073
- * with more than one page of webhooks doesn't produce a false
2074
- * `WEBHOOK_NOT_FOUND` from `validateWebhook`.
2075
- *
2076
- * @param http - Shared API client.
2077
- * @param storeId - Store to filter.
2078
- * @returns All webhook resources for the store.
2079
- * @throws {FreshSqueezyError} On HTTP/network failure.
1340
+ * Look up a registry entry.
2080
1341
  *
2081
- * @example
2082
- * ```ts
2083
- * const webhooks = await listWebhooksForStore(http, 1);
2084
- * ```
1342
+ * @param resource - CLI resource token.
1343
+ * @param verb - Op verb.
1344
+ * @returns The spec, or undefined when not implemented / not in LS API.
2085
1345
  */
2086
- declare const listWebhooksForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<WebhookAttributes>[]>;
1346
+ declare const findResourceVerb: (resource: string, verb: string) => ResourceVerbSpec | undefined;
2087
1347
  /**
2088
- * Create a webhook (POST /v1/webhooks).
2089
- * Docs: https://docs.lemonsqueezy.com/api/webhooks/create-webhook
2090
- *
2091
- * @param http - Shared API client.
2092
- * @param body - JSON:API create document.
2093
- * @returns The created webhook.
2094
- * @throws {FreshSqueezyError} On HTTP/network failure.
1348
+ * Unique resource names that have at least one verb.
2095
1349
  *
2096
- * @example
2097
- * ```ts
2098
- * const webhook = await createWebhook(http, {
2099
- * data: {
2100
- * type: "webhooks",
2101
- * attributes: { url: "https://app.example.com/hook", events: ["order_created"] },
2102
- * relationships: { store: { data: { type: "stores", id: "1" } } },
2103
- * },
2104
- * });
2105
- * ```
1350
+ * @returns Sorted resource tokens for help text / menus.
2106
1351
  */
2107
- declare const createWebhook: (http: HttpClient, body: unknown) => Promise<JsonApiResource<WebhookAttributes>>;
1352
+ declare const listRegisteredResources: () => string[];
2108
1353
  /**
2109
- * Update a webhook (PATCH /v1/webhooks/:id).
2110
- * Docs: https://docs.lemonsqueezy.com/api/webhooks/update-webhook
2111
- *
2112
- * @param http - Shared API client.
2113
- * @param webhookId - Webhook id.
2114
- * @param body - JSON:API update document.
2115
- * @returns The updated webhook.
2116
- * @throws {FreshSqueezyError} On HTTP/network failure.
1354
+ * All verbs registered for a resource (empty when unknown).
2117
1355
  *
2118
- * @example
2119
- * ```ts
2120
- * const webhook = await updateWebhook(http, 1, {
2121
- * data: { type: "webhooks", id: "1", attributes: { events: ["order_created"] } },
2122
- * });
2123
- * ```
1356
+ * @param resource - CLI resource token (plural or singular).
1357
+ * @returns Sorted verb list for help / menus.
2124
1358
  */
2125
- declare const updateWebhook: (http: HttpClient, webhookId: string | number, body: unknown) => Promise<JsonApiResource<WebhookAttributes>>;
1359
+ declare const listRegisteredVerbs: (resource: string) => OpVerb[];
2126
1360
  /**
2127
- * Delete a webhook (DELETE /v1/webhooks/:id).
2128
- * Docs: https://docs.lemonsqueezy.com/api/webhooks/delete-webhook
1361
+ * Run a docs-backed resource verb: look it up in `resourceRegistry`, then make
1362
+ * the one HTTP call its verb rule describes.
2129
1363
  *
2130
1364
  * @param http - Shared API client.
2131
- * @param webhookId - Webhook id.
2132
- * @returns Nothing on success.
2133
- * @throws {FreshSqueezyError} On HTTP/network failure.
1365
+ * @param resource - CLI resource token (`webhook`, `product`, …).
1366
+ * @param verb - Op verb (`get`, `create`, `refund`, …).
1367
+ * @param args - Ids / body for the call.
1368
+ * @returns The JSON:API `data` (resource or list), the whole document for
1369
+ * endpoints that return only `meta` (invoices, usage), or undefined after a delete.
1370
+ * @throws {FreshSqueezyError} When the verb is unknown, an argument is missing, or HTTP fails.
2134
1371
  *
2135
1372
  * @example
2136
1373
  * ```ts
2137
- * await deleteWebhook(http, 1);
1374
+ * const product = await invokeOp(http, "product", "get", { id: 42 });
1375
+ * // GET /v1/products/42
2138
1376
  * ```
2139
1377
  */
2140
- declare const deleteWebhook: (http: HttpClient, webhookId: string | number) => Promise<void>;
1378
+ declare const invokeOp: (http: HttpClient, resource: string, verb: OpVerb | string, args?: InvokeOpArgs) => Promise<unknown>;
2141
1379
 
2142
1380
  /**
2143
1381
  * Connection validator summary attached to the `resource` field. Keeps the
@@ -2158,11 +1396,24 @@ interface ConnectionSummary {
2158
1396
  /** The mode the caller asked for at construction time. */
2159
1397
  declaredMode: Mode;
2160
1398
  }
1399
+ /**
1400
+ * Map the boolean `meta.test_mode` flag from `/v1/users/me` to our `Mode` type.
1401
+ *
1402
+ * Returns `undefined` when the field is absent so older accounts and proxies
1403
+ * that don't surface the flag don't produce spurious mode mismatches. Lemon
1404
+ * Squeezy added `meta.test_mode` to the endpoint on 2024-01-05 (see API
1405
+ * changelog: https://docs.lemonsqueezy.com/api/getting-started/changelog).
1406
+ *
1407
+ * Pure function — exposed publicly so consumers can resolve a key's true mode
1408
+ * from a `/v1/users/me` document they already have, without re-running the
1409
+ * full connection validator.
1410
+ */
1411
+ declare const resolveActualMode: (testMode: boolean | undefined) => Mode | undefined;
2161
1412
  /**
2162
1413
  * Verify that the API key works, surface the account identity + reachable
2163
1414
  * stores, and cross-check declared mode vs the key's true mode.
2164
1415
  *
2165
- * This is the first check every `doctor()` run performs; if it fails,
1416
+ * This is the first validator every `doctor()` run performs; if it fails,
2166
1417
  * no downstream validator has anything useful to report.
2167
1418
  */
2168
1419
  declare const validateConnection: (http: HttpClient, mode: Mode) => Promise<ValidationResult<ConnectionSummary>>;
@@ -2174,11 +1425,8 @@ declare const validateConnection: (http: HttpClient, mode: Mode) => Promise<Vali
2174
1425
  * Returns `undefined` if the API doesn't surface `meta.test_mode` (older
2175
1426
  * proxies, partial responses).
2176
1427
  *
2177
- * Lives here rather than in `core/mode.ts` so the foundational `core/` layer
2178
- * never imports from `resources/`; the pure `resolveActualMode` it delegates to
2179
- * still lives in `core/`. Throws `FreshSqueezyError` on auth or network
2180
- * failure; callers that want a structured non-throwing result should use
2181
- * `validateConnection` instead.
1428
+ * Throws `FreshSqueezyError` on auth or network failure; callers that want a
1429
+ * structured non-throwing result should use `validateConnection` instead.
2182
1430
  */
2183
1431
  declare const fetchActualMode: (http: HttpClient) => Promise<Mode | undefined>;
2184
1432
 
@@ -2290,6 +1538,14 @@ interface WebhookValidationOptions {
2290
1538
  /** The public URL your app exposes for Lemon Squeezy to POST to. */
2291
1539
  url: string;
2292
1540
  }
1541
+ /**
1542
+ * Compare two webhook URLs ignoring trailing slashes and casing.
1543
+ *
1544
+ * Lemon Squeezy strips trailing slashes when persisting a webhook, but users
1545
+ * often paste the trailing-slash form into their config. `validateWebhook`
1546
+ * relies on this rule to match a configured URL against the registered list.
1547
+ */
1548
+ declare const sameWebhookUrl: (a: string, b: string) => boolean;
2293
1549
  /**
2294
1550
  * Confirm a webhook matching `options.url` is registered against the given
2295
1551
  * store, and cross-reference its subscribed events against the support
@@ -2339,7 +1595,7 @@ interface DoctorValidators {
2339
1595
  declare const DEFAULT_VALIDATORS: DoctorValidators;
2340
1596
  /**
2341
1597
  * Compose every configured validator into a single report. This is the
2342
- * primary entry point for CI health checks: one call, one structured result,
1598
+ * primary entry point for CI pre-flight runs: one call, one structured result,
2343
1599
  * one exit code decision.
2344
1600
  *
2345
1601
  * Order is meaningful. Connection runs first because downstream validators
@@ -2475,7 +1731,7 @@ declare const ACKNOWLEDGED_CHANGELOG_ENTRIES: readonly [{
2475
1731
  }, {
2476
1732
  readonly date: "2025-06-11";
2477
1733
  readonly summary: "Added payment_processor attribute to Subscription objects.";
2478
- readonly handledBy: "Surfaced as SubscriptionAttributes.payment_processor in src/resources/subscriptions.ts.";
1734
+ readonly handledBy: "Surfaced as SubscriptionAttributes.payment_processor in src/resources/attributes.ts.";
2479
1735
  }, {
2480
1736
  readonly date: "2025-01-21";
2481
1737
  readonly summary: "Added Affiliates endpoints and affiliate_activated webhook.";
@@ -2483,11 +1739,11 @@ declare const ACKNOWLEDGED_CHANGELOG_ENTRIES: readonly [{
2483
1739
  }, {
2484
1740
  readonly date: "2024-12-06";
2485
1741
  readonly summary: "Added quantity parameter to OrderItem objects.";
2486
- readonly handledBy: "OrderItemAttributes.quantity (src/resources/orderItems.ts).";
1742
+ readonly handledBy: "OrderItemAttributes.quantity (src/resources/attributes.ts).";
2487
1743
  }, {
2488
1744
  readonly date: "2024-09-10";
2489
1745
  readonly summary: "Added fraudulent Order status.";
2490
- readonly handledBy: "OrderAttributes.status union includes 'fraudulent' (src/resources/orders.ts).";
1746
+ readonly handledBy: "OrderAttributes.status union includes 'fraudulent' (src/resources/attributes.ts).";
2491
1747
  }, {
2492
1748
  readonly date: "2024-09-04";
2493
1749
  readonly summary: "Added Issue an Order refund and Issue a Subscription Invoice refund endpoints.";
@@ -2499,7 +1755,7 @@ declare const ACKNOWLEDGED_CHANGELOG_ENTRIES: readonly [{
2499
1755
  }, {
2500
1756
  readonly date: "2024-06-09";
2501
1757
  readonly summary: "Added links property to Variant objects.";
2502
- readonly handledBy: "VariantAttributes.links (src/resources/variants.ts).";
1758
+ readonly handledBy: "VariantAttributes.links (src/resources/attributes.ts).";
2503
1759
  }, {
2504
1760
  readonly date: "2024-05-20";
2505
1761
  readonly summary: "Added Generate order invoice endpoint.";
@@ -2515,7 +1771,7 @@ declare const ACKNOWLEDGED_CHANGELOG_ENTRIES: readonly [{
2515
1771
  }, {
2516
1772
  readonly date: "2024-02-20";
2517
1773
  readonly summary: "Added urls.update_customer_portal to Subscription objects.";
2518
- readonly handledBy: "SubscriptionUrls.update_customer_portal (src/resources/subscriptions.ts).";
1774
+ readonly handledBy: "SubscriptionUrls.update_customer_portal (src/resources/attributes.ts).";
2519
1775
  }, {
2520
1776
  readonly date: "2024-02-12";
2521
1777
  readonly summary: "Added Generate subscription invoice endpoint and invoice_immediately / disable_prorations parameters.";
@@ -2870,4 +2126,4 @@ interface FreshSqueezyClient extends FreshSqueezyOps {
2870
2126
  */
2871
2127
  declare const createFreshSqueezy: (config?: FreshSqueezyConfig) => FreshSqueezyClient;
2872
2128
 
2873
- export { ACKNOWLEDGED_CHANGELOG_ENTRIES, type AffiliateAttributes, type AffiliateStatus, type AuthenticatedUserDocument, type CheckoutAttributes, type CheckoutData, type CheckoutLocale, type CheckoutOptions, type CheckoutPreview, type CheckoutProductOptions, type CheckoutVariantQuantity, type ConnectionSummary, type CustomerAttributes, type CustomerStatus, type CustomerUrls, DEFAULT_VALIDATORS, type DiscountAttributes, type DiscountRedemptionAttributes, type DiscountValidationOptions, type DoctorOptions, type DoctorReport, type DoctorValidators, ENV_KEYS, type FileAttributes, type FreshSqueezyClient, type FreshSqueezyConfig, FreshSqueezyError, type FreshSqueezyOps, GENERATED_LEMON_SQUEEZY_RESOURCES, GENERATED_LEMON_SQUEEZY_TYPE_SOURCE, type GeneratedAffiliateAttributes, type GeneratedCheckoutAttributes, type GeneratedCustomerAttributes, type GeneratedDiscountAttributes, type GeneratedDiscountRedemptionAttributes, type GeneratedFileAttributes, type GeneratedLemonSqueezyFieldMap, type GeneratedLemonSqueezyResourceName, type GeneratedLemonSqueezyResourceType, type GeneratedLicenseKeyAttributes, type GeneratedLicenseKeyInstanceAttributes, type GeneratedOrderAttributes, type GeneratedOrderItemAttributes, type GeneratedPriceAttributes, type GeneratedProductAttributes, type GeneratedStoreAttributes, type GeneratedSubscriptionAttributes, type GeneratedSubscriptionInvoiceAttributes, type GeneratedSubscriptionItemAttributes, type GeneratedUsageRecordAttributes, type GeneratedUserAttributes, type GeneratedVariantAttributes, type GeneratedWebhookAttributes, ISSUE_CODES, type InvokeOpArgs, type JsonApiCollection, type JsonApiDocument, type JsonApiResource, type LatestCheckoutDataFields, type LatestCheckoutFields, type LatestCheckoutOptionsFields, type LatestFieldsFor, type LatestLemonSqueezyFieldMap, type LatestLemonSqueezyResourceName, type LatestOrderFields, type LatestOrderItemFields, type LatestPriceFields, type LatestSubscriptionFields, type LatestSubscriptionInvoiceFields, type LatestSubscriptionItemUpdateFields, type LatestVariantFields, type LicenseKeyAttributes, type LicenseKeyInstanceAttributes, type LicenseKeyValidationOptions, type Mode, OPTIONAL_WEBHOOK_EVENTS, type OpVerb, type OptionalEvent, type OrderAttributes, type OrderFirstItem, type OrderItemAttributes, type OrderUrls, type PriceAttributes, type ProductAttributes, type ProductValidationOptions, RECOMMENDED_WEBHOOK_EVENTS, type RecommendedEvent, type ResolvedConfig, type ResourceVerbSpec, SUPPORTED_RESOURCES, type StoreAttributes, type SubscriptionAttributes, type SubscriptionInvoiceAttributes, type SubscriptionInvoiceBillingReason, type SubscriptionInvoiceStatus, type SubscriptionInvoiceUrls, type SubscriptionItemAttributes, type SubscriptionItemSummary, type SubscriptionItemUpdateAttributes, type SubscriptionPause, type SubscriptionPlanSummary, type SubscriptionPlanValidationOptions, type SubscriptionUrls, type SubscriptionVariantAttributes, type UsageRecordAction, type UsageRecordAttributes, type UserAttributes, type UserMeta, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidationTarget, type VariantAttributes, type VariantLink, type WebhookAttributes, type WebhookValidationOptions, type WithLatestLemonSqueezyFields, buildResult, buildSubscriptionItemUpdateBody, cancelSubscription, checkDiscount, checkLicenseKey, checkProduct, checkSubscriptionPlan, createCheckout, createCustomer, createDiscount, createFreshSqueezy, createUsageRecord, createWebhook, deleteDiscount, deleteWebhook, doctor, fetchActualMode, findResourceVerb, generateOrderInvoice, generateSubscriptionInvoice, getAffiliate, getAuthenticatedUser, getCheckout, getCustomer, getDiscount, getDiscountRedemption, getFile, getLicenseKey, getLicenseKeyInstance, getOrder, getOrderItem, getPrice, getProduct, getStore, getSubscription, getSubscriptionInvoice, getSubscriptionItem, getSubscriptionItemCurrentUsage, getUsageRecord, getVariant, getWebhook, invokeOp, isOk, issue, listAffiliatesForStore, listCheckoutsForStore, listCustomersForStore, listDiscountRedemptionsForDiscount, listDiscountsForStore, listFilesForVariant, listLicenseKeyInstancesForLicenseKey, listLicenseKeysForStore, listOrderItemsForOrder, listOrdersForStore, listPricesForVariant, listProducts, listRegisteredResources, listRegisteredVerbs, listStores, listSubscriptionInvoicesForSubscription, listSubscriptionItemsForSubscription, listSubscriptionsForStore, listUsageRecordsForSubscriptionItem, listVariantsForProduct, listWebhooksForStore, normalizeResourceName, refundOrder, refundSubscriptionInvoice, resolveActualMode, resolveConfig, resourceRegistry, sameWebhookUrl, updateCustomer, updateLicenseKey, updateSubscription, updateSubscriptionItem, updateWebhook, validateConnection, validateDiscount, validateLicenseKey, validateProduct, validateStore, validateSubscriptionPlan, validateWebhook };
2129
+ export { ACKNOWLEDGED_CHANGELOG_ENTRIES, type AffiliateAttributes, type AffiliateStatus, type AuthenticatedUserDocument, type CheckoutAttributes, type CheckoutData, type CheckoutLocale, type CheckoutOptions, type CheckoutPreview, type CheckoutProductOptions, type CheckoutVariantQuantity, type ConnectionSummary, type CustomerAttributes, type CustomerStatus, type CustomerUrls, DEFAULT_VALIDATORS, type DiscountAttributes, type DiscountRedemptionAttributes, type DiscountValidationOptions, type DoctorOptions, type DoctorReport, type DoctorValidators, ENV_KEYS, type FileAttributes, type FreshSqueezyClient, type FreshSqueezyConfig, FreshSqueezyError, type FreshSqueezyOps, GENERATED_LEMON_SQUEEZY_RESOURCES, GENERATED_LEMON_SQUEEZY_TYPE_SOURCE, type GeneratedAffiliateAttributes, type GeneratedCheckoutAttributes, type GeneratedCustomerAttributes, type GeneratedDiscountAttributes, type GeneratedDiscountRedemptionAttributes, type GeneratedFileAttributes, type GeneratedLemonSqueezyFieldMap, type GeneratedLemonSqueezyResourceName, type GeneratedLemonSqueezyResourceType, type GeneratedLicenseKeyAttributes, type GeneratedLicenseKeyInstanceAttributes, type GeneratedOrderAttributes, type GeneratedOrderItemAttributes, type GeneratedPriceAttributes, type GeneratedProductAttributes, type GeneratedStoreAttributes, type GeneratedSubscriptionAttributes, type GeneratedSubscriptionInvoiceAttributes, type GeneratedSubscriptionItemAttributes, type GeneratedUsageRecordAttributes, type GeneratedUserAttributes, type GeneratedVariantAttributes, type GeneratedWebhookAttributes, ISSUE_CODES, type InvokeOpArgs, type JsonApiCollection, type JsonApiDocument, type JsonApiResource, type LatestCheckoutDataFields, type LatestCheckoutFields, type LatestCheckoutOptionsFields, type LatestFieldsFor, type LatestLemonSqueezyFieldMap, type LatestLemonSqueezyResourceName, type LatestOrderFields, type LatestOrderItemFields, type LatestPriceFields, type LatestSubscriptionFields, type LatestSubscriptionInvoiceFields, type LatestSubscriptionItemUpdateFields, type LatestVariantFields, type LicenseKeyAttributes, type LicenseKeyInstanceAttributes, type LicenseKeyValidationOptions, type Mode, OPTIONAL_WEBHOOK_EVENTS, type OpVerb, type OptionalEvent, type OrderAttributes, type OrderFirstItem, type OrderItemAttributes, type OrderUrls, type PriceAttributes, type ProductAttributes, type ProductValidationOptions, RECOMMENDED_WEBHOOK_EVENTS, type RecommendedEvent, type ResolvedConfig, type ResourceVerbSpec, SUPPORTED_RESOURCES, type StoreAttributes, type SubscriptionAttributes, type SubscriptionInvoiceAttributes, type SubscriptionInvoiceBillingReason, type SubscriptionInvoiceStatus, type SubscriptionInvoiceUrls, type SubscriptionItemAttributes, type SubscriptionItemSummary, type SubscriptionItemUpdateAttributes, type SubscriptionPause, type SubscriptionPlanSummary, type SubscriptionPlanValidationOptions, type SubscriptionUrls, type SubscriptionVariantAttributes, type UsageRecordAction, type UsageRecordAttributes, type UserAttributes, type UserMeta, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidationTarget, type VariantAttributes, type VariantLink, type WebhookAttributes, type WebhookValidationOptions, type WithLatestLemonSqueezyFields, buildResult, buildSubscriptionItemUpdateBody, checkDiscount, checkLicenseKey, checkProduct, checkSubscriptionPlan, createFreshSqueezy, doctor, fetchActualMode, findResourceVerb, invokeOp, isOk, issue, listRegisteredResources, listRegisteredVerbs, normalizeResourceName, resolveActualMode, resolveConfig, resourceRegistry, sameWebhookUrl, validateConnection, validateDiscount, validateLicenseKey, validateProduct, validateStore, validateSubscriptionPlan, validateWebhook };