fresh-squeezy 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +1 -1
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/README.pt-BR.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/cli.js +677 -622
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +605 -578
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +264 -185
- package/dist/index.d.ts +264 -185
- package/dist/index.js +597 -578
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
- package/assets/fresh-squeezy-hero.png +0 -0
- package/bin/fresh-squeezy.js +0 -2
package/dist/index.d.cts
CHANGED
|
@@ -807,6 +807,113 @@ declare class HttpClient {
|
|
|
807
807
|
private buildUrl;
|
|
808
808
|
}
|
|
809
809
|
|
|
810
|
+
/**
|
|
811
|
+
* Subset of Lemon Squeezy discount attributes used by the discount validator.
|
|
812
|
+
* Full schema at https://docs.lemonsqueezy.com/api/discounts.
|
|
813
|
+
*/
|
|
814
|
+
interface DiscountAttributes extends GeneratedDiscountAttributes {
|
|
815
|
+
name: string;
|
|
816
|
+
code: string;
|
|
817
|
+
amount: number;
|
|
818
|
+
amount_type: "percent" | "fixed";
|
|
819
|
+
is_limited_to_products: boolean;
|
|
820
|
+
is_limited_redemptions: boolean;
|
|
821
|
+
max_redemptions: number;
|
|
822
|
+
starts_at: string | null;
|
|
823
|
+
expires_at: string | null;
|
|
824
|
+
status: "draft" | "published";
|
|
825
|
+
duration: "once" | "repeating" | "forever";
|
|
826
|
+
store_id: number;
|
|
827
|
+
created_at?: string;
|
|
828
|
+
updated_at?: string;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Subset of Lemon Squeezy license-key attributes used by the license key
|
|
833
|
+
* validator. Full schema at https://docs.lemonsqueezy.com/api/license-keys.
|
|
834
|
+
*/
|
|
835
|
+
interface LicenseKeyAttributes extends GeneratedLicenseKeyAttributes {
|
|
836
|
+
key_short: string;
|
|
837
|
+
status: "active" | "inactive" | "expired" | "disabled";
|
|
838
|
+
expires_at: string | null;
|
|
839
|
+
activation_limit: number | null;
|
|
840
|
+
instances_count: number;
|
|
841
|
+
disabled: boolean;
|
|
842
|
+
store_id: number;
|
|
843
|
+
created_at?: string;
|
|
844
|
+
updated_at?: string;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Subset of product attributes we need for validation. `status` drives the
|
|
849
|
+
* "unpublished product" check; `store_id` drives ownership checks.
|
|
850
|
+
*/
|
|
851
|
+
interface ProductAttributes extends GeneratedProductAttributes {
|
|
852
|
+
name: string;
|
|
853
|
+
slug: string;
|
|
854
|
+
description?: string | null;
|
|
855
|
+
status: "draft" | "published";
|
|
856
|
+
status_formatted?: string;
|
|
857
|
+
store_id: number;
|
|
858
|
+
buy_now_url?: string | null;
|
|
859
|
+
from_price?: number | null;
|
|
860
|
+
to_price?: number | null;
|
|
861
|
+
created_at?: string;
|
|
862
|
+
updated_at?: string;
|
|
863
|
+
}
|
|
864
|
+
declare function getProduct(http: HttpClient, productId: string | number): Promise<JsonApiResource<ProductAttributes>>;
|
|
865
|
+
/**
|
|
866
|
+
* List every product in the store, paginated. Used by the CLI's
|
|
867
|
+
* interactive product picker; without pagination only the first 25
|
|
868
|
+
* products are offered.
|
|
869
|
+
*/
|
|
870
|
+
declare function listProducts(http: HttpClient, storeId: string | number): Promise<JsonApiResource<ProductAttributes>[]>;
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Subset of store attributes fresh-squeezy reads.
|
|
874
|
+
* Full schema at https://docs.lemonsqueezy.com/api/stores.
|
|
875
|
+
*/
|
|
876
|
+
interface StoreAttributes extends GeneratedStoreAttributes {
|
|
877
|
+
name: string;
|
|
878
|
+
slug: string;
|
|
879
|
+
domain?: string | null;
|
|
880
|
+
url?: string | null;
|
|
881
|
+
country?: string;
|
|
882
|
+
currency?: string;
|
|
883
|
+
plan?: string;
|
|
884
|
+
created_at?: string;
|
|
885
|
+
updated_at?: string;
|
|
886
|
+
}
|
|
887
|
+
declare function getStore(http: HttpClient, storeId: string | number): Promise<JsonApiResource<StoreAttributes>>;
|
|
888
|
+
/**
|
|
889
|
+
* List every store reachable with the configured API key, paginated.
|
|
890
|
+
* Used by `validateConnection` to populate the connection summary, and by
|
|
891
|
+
* the CLI's `--all-stores` flag. Pagination matters here for accounts that
|
|
892
|
+
* own a large catalogue of stores.
|
|
893
|
+
*/
|
|
894
|
+
declare function listStores(http: HttpClient): Promise<JsonApiResource<StoreAttributes>[]>;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Subset of webhook attributes we read. `events` is an ordered list of
|
|
898
|
+
* subscribed event names; the validator cross-references these against the
|
|
899
|
+
* support manifest to catch missing subscriptions.
|
|
900
|
+
*/
|
|
901
|
+
interface WebhookAttributes extends GeneratedWebhookAttributes {
|
|
902
|
+
store_id: number;
|
|
903
|
+
url: string;
|
|
904
|
+
events: string[];
|
|
905
|
+
last_sent_at?: string | null;
|
|
906
|
+
created_at?: string;
|
|
907
|
+
updated_at?: string;
|
|
908
|
+
test_mode?: boolean;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* List every webhook registered on the store, walking pagination so a store
|
|
912
|
+
* with more than one page of webhooks doesn't produce a false
|
|
913
|
+
* `WEBHOOK_NOT_FOUND` from `validateWebhook`.
|
|
914
|
+
*/
|
|
915
|
+
declare function listWebhooksForStore(http: HttpClient, storeId: string | number): Promise<JsonApiResource<WebhookAttributes>[]>;
|
|
916
|
+
|
|
810
917
|
/**
|
|
811
918
|
* Subset of the Lemon Squeezy `users` resource attributes we rely on.
|
|
812
919
|
* Full schema at https://docs.lemonsqueezy.com/api/users.
|
|
@@ -881,31 +988,67 @@ interface ConnectionSummary {
|
|
|
881
988
|
* no downstream validator has anything useful to report.
|
|
882
989
|
*/
|
|
883
990
|
declare function validateConnection(http: HttpClient, mode: Mode): Promise<ValidationResult<ConnectionSummary>>;
|
|
991
|
+
/**
|
|
992
|
+
* Ask the Lemon Squeezy API which mode the configured key actually belongs to.
|
|
993
|
+
*
|
|
994
|
+
* Useful as a fail-fast check at app boot — e.g. refuse to start if a prod key
|
|
995
|
+
* is loaded into a staging deployment — without paying for a full doctor run.
|
|
996
|
+
* Returns `undefined` if the API doesn't surface `meta.test_mode` (older
|
|
997
|
+
* proxies, partial responses).
|
|
998
|
+
*
|
|
999
|
+
* Lives here rather than in `core/mode.ts` so the foundational `core/` layer
|
|
1000
|
+
* never imports from `resources/`; the pure `resolveActualMode` it delegates to
|
|
1001
|
+
* still lives in `core/`. Throws `FreshSqueezyError` on auth or network
|
|
1002
|
+
* failure; callers that want a structured non-throwing result should use
|
|
1003
|
+
* `validateConnection` instead.
|
|
1004
|
+
*/
|
|
1005
|
+
declare function fetchActualMode(http: HttpClient): Promise<Mode | undefined>;
|
|
884
1006
|
|
|
1007
|
+
interface DiscountValidationOptions {
|
|
1008
|
+
storeId: string | number;
|
|
1009
|
+
discountId: string | number;
|
|
1010
|
+
}
|
|
885
1011
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
1012
|
+
* Validate a Lemon Squeezy discount code. Catches the most common
|
|
1013
|
+
* misconfigurations: draft discounts that can't be redeemed, expired or
|
|
1014
|
+
* not-yet-active windows, invalid amounts (negative or >100% for percent
|
|
1015
|
+
* type), and store ownership mismatches.
|
|
1016
|
+
*
|
|
1017
|
+
* The redemption exhaustion check is deliberately conservative (v1): it only
|
|
1018
|
+
* flags when `is_limited_redemptions` is true and `max_redemptions` is zero,
|
|
1019
|
+
* because a full redemption count fetch against
|
|
1020
|
+
* `/v1/discount-redemptions?filter[discount_id]=` is YAGNI until a consumer
|
|
1021
|
+
* asks for it.
|
|
888
1022
|
*/
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1023
|
+
declare function validateDiscount(http: HttpClient, mode: Mode, options: DiscountValidationOptions): Promise<ValidationResult<DiscountAttributes>>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Pure attribute assertions for a discount: store ownership, draft/expiry/
|
|
1026
|
+
* activation windows, redemption exhaustion, and amount validity. No I/O, so
|
|
1027
|
+
* the rules are unit-testable with plain data.
|
|
1028
|
+
*/
|
|
1029
|
+
declare function checkDiscount(attrs: DiscountAttributes, options: {
|
|
1030
|
+
storeId: string | number;
|
|
1031
|
+
}): ValidationIssue[];
|
|
1032
|
+
|
|
1033
|
+
interface LicenseKeyValidationOptions {
|
|
1034
|
+
storeId: string | number;
|
|
1035
|
+
licenseKeyId: string | number;
|
|
901
1036
|
}
|
|
902
|
-
declare function getProduct(http: HttpClient, productId: string | number): Promise<JsonApiResource<ProductAttributes>>;
|
|
903
1037
|
/**
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
1038
|
+
* Validate a Lemon Squeezy license key. Surfaces disabled keys, expired
|
|
1039
|
+
* keys, keys at their activation limit, and store ownership mismatches — the
|
|
1040
|
+
* four states most likely to cause "why can't my customer activate?"
|
|
1041
|
+
* support tickets.
|
|
907
1042
|
*/
|
|
908
|
-
declare function
|
|
1043
|
+
declare function validateLicenseKey(http: HttpClient, mode: Mode, options: LicenseKeyValidationOptions): Promise<ValidationResult<LicenseKeyAttributes>>;
|
|
1044
|
+
/**
|
|
1045
|
+
* Pure attribute assertions for a license key: store ownership, disabled/
|
|
1046
|
+
* expired state, and activation-limit exhaustion. No I/O, so the rules are
|
|
1047
|
+
* unit-testable with plain data.
|
|
1048
|
+
*/
|
|
1049
|
+
declare function checkLicenseKey(attrs: LicenseKeyAttributes, options: {
|
|
1050
|
+
storeId: string | number;
|
|
1051
|
+
}): ValidationIssue[];
|
|
909
1052
|
|
|
910
1053
|
interface ProductValidationOptions {
|
|
911
1054
|
productId: string | number;
|
|
@@ -918,89 +1061,79 @@ interface ProductValidationOptions {
|
|
|
918
1061
|
* caught in the wild (unpublished product, wrong store, missing variants).
|
|
919
1062
|
*/
|
|
920
1063
|
declare function validateProduct(http: HttpClient, mode: Mode, options: ProductValidationOptions): Promise<ValidationResult<ProductAttributes>>;
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Subset of webhook attributes we read. `events` is an ordered list of
|
|
924
|
-
* subscribed event names; the validator cross-references these against the
|
|
925
|
-
* support manifest to catch missing subscriptions.
|
|
926
|
-
*/
|
|
927
|
-
interface WebhookAttributes extends GeneratedWebhookAttributes {
|
|
928
|
-
store_id: number;
|
|
929
|
-
url: string;
|
|
930
|
-
events: string[];
|
|
931
|
-
last_sent_at?: string | null;
|
|
932
|
-
created_at?: string;
|
|
933
|
-
updated_at?: string;
|
|
934
|
-
test_mode?: boolean;
|
|
935
|
-
}
|
|
936
1064
|
/**
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
* `
|
|
1065
|
+
* Pure attribute assertions for a product: store ownership, publish state, and
|
|
1066
|
+
* hosted-checkout availability. The variant-population rule needs a second
|
|
1067
|
+
* fetch and stays in `validateProduct`; everything here runs on plain data, so
|
|
1068
|
+
* the rules are unit-testable without a mock fetch.
|
|
940
1069
|
*/
|
|
941
|
-
declare function
|
|
1070
|
+
declare function checkProduct(attrs: ProductAttributes, options?: {
|
|
1071
|
+
expectedStoreId?: string | number;
|
|
1072
|
+
}): ValidationIssue[];
|
|
942
1073
|
|
|
943
|
-
interface
|
|
944
|
-
|
|
945
|
-
/** The public URL your app exposes for Lemon Squeezy to POST to. */
|
|
1074
|
+
interface VariantLink {
|
|
1075
|
+
title: string;
|
|
946
1076
|
url: string;
|
|
947
1077
|
}
|
|
948
1078
|
/**
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
* manifest's recommended + optional lists.
|
|
952
|
-
*
|
|
953
|
-
* Missing recommended events = error. Missing optional events = info, because
|
|
954
|
-
* not every integration needs them.
|
|
955
|
-
*/
|
|
956
|
-
declare function validateWebhook(http: HttpClient, mode: Mode, options: WebhookValidationOptions): Promise<ValidationResult<WebhookAttributes>>;
|
|
957
|
-
|
|
958
|
-
/**
|
|
959
|
-
* Subset of Lemon Squeezy discount attributes used by the discount validator.
|
|
960
|
-
* Full schema at https://docs.lemonsqueezy.com/api/discounts.
|
|
1079
|
+
* Variant attributes used by the product validator to detect
|
|
1080
|
+
* variant/price drift from the product they belong to.
|
|
961
1081
|
*/
|
|
962
|
-
interface
|
|
1082
|
+
interface VariantAttributes extends GeneratedVariantAttributes {
|
|
1083
|
+
product_id: number;
|
|
963
1084
|
name: string;
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
status: "draft" | "published";
|
|
973
|
-
|
|
974
|
-
|
|
1085
|
+
slug: string;
|
|
1086
|
+
description?: string | null;
|
|
1087
|
+
has_license_keys?: boolean;
|
|
1088
|
+
license_activation_limit?: number | null;
|
|
1089
|
+
is_license_limit_unlimited?: boolean;
|
|
1090
|
+
license_length_value?: number | null;
|
|
1091
|
+
license_length_unit?: "day" | "week" | "month" | "year" | null;
|
|
1092
|
+
is_license_length_unlimited?: boolean;
|
|
1093
|
+
status: "pending" | "draft" | "published";
|
|
1094
|
+
status_formatted?: string;
|
|
1095
|
+
is_subscription?: boolean;
|
|
1096
|
+
interval?: string | null;
|
|
1097
|
+
interval_count?: number | null;
|
|
1098
|
+
sort?: number;
|
|
1099
|
+
/**
|
|
1100
|
+
* Hosted-checkout-style links keyed by purpose. Added 2024-06-09 — older
|
|
1101
|
+
* SDK and validator versions don't surface this field, so consumers had
|
|
1102
|
+
* to read `meta.product_links` manually before. Optional because the
|
|
1103
|
+
* field is absent on older variants.
|
|
1104
|
+
*/
|
|
1105
|
+
links?: VariantLink[] | Record<string, string>;
|
|
975
1106
|
created_at?: string;
|
|
976
1107
|
updated_at?: string;
|
|
1108
|
+
test_mode?: boolean;
|
|
977
1109
|
}
|
|
978
|
-
|
|
979
|
-
interface DiscountValidationOptions {
|
|
980
|
-
storeId: string | number;
|
|
981
|
-
discountId: string | number;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
1110
|
/**
|
|
985
|
-
*
|
|
986
|
-
*
|
|
1111
|
+
* Extended variant attributes for subscription plan validation. In Lemon
|
|
1112
|
+
* Squeezy, "subscription plans" live as variants with `is_subscription: true`.
|
|
1113
|
+
* These fields are only present on subscription variants and are checked by
|
|
1114
|
+
* the subscription plan validator to catch misconfigured trial periods,
|
|
1115
|
+
* zero-price plans, and invalid billing intervals.
|
|
987
1116
|
*/
|
|
988
|
-
interface
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
created_at?: string;
|
|
997
|
-
updated_at?: string;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
interface LicenseKeyValidationOptions {
|
|
1001
|
-
storeId: string | number;
|
|
1002
|
-
licenseKeyId: string | number;
|
|
1117
|
+
interface SubscriptionVariantAttributes extends VariantAttributes {
|
|
1118
|
+
is_subscription: boolean;
|
|
1119
|
+
interval: string | null;
|
|
1120
|
+
interval_count: number | null;
|
|
1121
|
+
has_free_trial: boolean;
|
|
1122
|
+
trial_interval: string | null;
|
|
1123
|
+
trial_interval_count: number | null;
|
|
1124
|
+
price: number;
|
|
1003
1125
|
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Fetch a single variant by ID. Used by the subscription plan validator to
|
|
1128
|
+
* inspect subscription-specific fields (interval, trial, price).
|
|
1129
|
+
*/
|
|
1130
|
+
declare function getVariant<TAttr = VariantAttributes>(http: HttpClient, variantId: string | number): Promise<JsonApiResource<TAttr>>;
|
|
1131
|
+
/**
|
|
1132
|
+
* List every variant of the product, paginated so products with more than
|
|
1133
|
+
* one page of variants don't trip the `VARIANT_UNPUBLISHED` heuristic when
|
|
1134
|
+
* the only published variants happen to live past page 1.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function listVariantsForProduct(http: HttpClient, productId: string | number): Promise<JsonApiResource<VariantAttributes>[]>;
|
|
1004
1137
|
|
|
1005
1138
|
interface SubscriptionPlanValidationOptions {
|
|
1006
1139
|
storeId: string | number;
|
|
@@ -1015,30 +1148,43 @@ interface SubscriptionPlanSummary {
|
|
|
1015
1148
|
hasFreeTrial: boolean;
|
|
1016
1149
|
status: string;
|
|
1017
1150
|
}
|
|
1018
|
-
|
|
1019
1151
|
/**
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1152
|
+
* Validate a Lemon Squeezy "subscription plan", which is a variant with
|
|
1153
|
+
* `is_subscription: true`. Checks that the variant is actually a subscription,
|
|
1154
|
+
* has a valid billing interval, and that trial settings are consistent.
|
|
1155
|
+
*
|
|
1156
|
+
* Store cross-check requires fetching the parent product to read its
|
|
1157
|
+
* `store_id`. This is an extra network hop but catches the common mistake of
|
|
1158
|
+
* passing a variant ID from one store while targeting another. Accept the
|
|
1159
|
+
* `storeId` as advisory — if the product fetch fails the cross-check is
|
|
1160
|
+
* silently skipped rather than blocking the entire validation.
|
|
1022
1161
|
*/
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1162
|
+
declare function validateSubscriptionPlan(http: HttpClient, mode: Mode, options: SubscriptionPlanValidationOptions): Promise<ValidationResult<SubscriptionPlanSummary>>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Pure attribute assertions for a subscription variant: that it is actually a
|
|
1165
|
+
* subscription, has a valid interval / interval_count, is not free-priced, has
|
|
1166
|
+
* consistent trial settings, and is not a draft. The store cross-check needs a
|
|
1167
|
+
* second fetch and stays in `validateSubscriptionPlan`; everything here runs on
|
|
1168
|
+
* plain data, so the rules are unit-testable without a mock fetch.
|
|
1169
|
+
*/
|
|
1170
|
+
declare function checkSubscriptionPlan(attrs: SubscriptionVariantAttributes, options: {
|
|
1171
|
+
variantId: string | number;
|
|
1172
|
+
}): ValidationIssue[];
|
|
1173
|
+
|
|
1174
|
+
interface WebhookValidationOptions {
|
|
1175
|
+
storeId: string | number;
|
|
1176
|
+
/** The public URL your app exposes for Lemon Squeezy to POST to. */
|
|
1177
|
+
url: string;
|
|
1033
1178
|
}
|
|
1034
|
-
declare function getStore(http: HttpClient, storeId: string | number): Promise<JsonApiResource<StoreAttributes>>;
|
|
1035
1179
|
/**
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
1180
|
+
* Confirm a webhook matching `options.url` is registered against the given
|
|
1181
|
+
* store, and cross-reference its subscribed events against the support
|
|
1182
|
+
* manifest's recommended + optional lists.
|
|
1183
|
+
*
|
|
1184
|
+
* Missing recommended events = error. Missing optional events = info, because
|
|
1185
|
+
* not every integration needs them.
|
|
1040
1186
|
*/
|
|
1041
|
-
declare function
|
|
1187
|
+
declare function validateWebhook(http: HttpClient, mode: Mode, options: WebhookValidationOptions): Promise<ValidationResult<WebhookAttributes>>;
|
|
1042
1188
|
|
|
1043
1189
|
/**
|
|
1044
1190
|
* Optional targets for the doctor run. If a target is omitted, its validator
|
|
@@ -1189,21 +1335,11 @@ declare function resolveConfig(input?: FreshSqueezyConfig): ResolvedConfig;
|
|
|
1189
1335
|
*
|
|
1190
1336
|
* Pure function — exposed publicly so consumers can resolve a key's true mode
|
|
1191
1337
|
* from a `/v1/users/me` document they already have, without re-running the
|
|
1192
|
-
* full connection validator.
|
|
1338
|
+
* full connection validator. Keeping it free of any resource import is what
|
|
1339
|
+
* lets `core/` stay foundational (it never reaches up into `resources/`); the
|
|
1340
|
+
* I/O counterpart `fetchActualMode` lives in `validate/connection.ts`.
|
|
1193
1341
|
*/
|
|
1194
1342
|
declare function resolveActualMode(testMode: boolean | undefined): Mode | undefined;
|
|
1195
|
-
/**
|
|
1196
|
-
* Ask the Lemon Squeezy API which mode the configured key actually belongs to.
|
|
1197
|
-
*
|
|
1198
|
-
* Useful as a fail-fast check at app boot — e.g. refuse to start if a prod key
|
|
1199
|
-
* is loaded into a staging deployment — without paying for a full doctor run.
|
|
1200
|
-
* Returns `undefined` if the API doesn't surface `meta.test_mode` (older
|
|
1201
|
-
* proxies, partial responses).
|
|
1202
|
-
*
|
|
1203
|
-
* Throws `FreshSqueezyError` on auth or network failure; callers that want a
|
|
1204
|
-
* structured non-throwing result should use `validateConnection` instead.
|
|
1205
|
-
*/
|
|
1206
|
-
declare function fetchActualMode(http: HttpClient): Promise<Mode | undefined>;
|
|
1207
1343
|
|
|
1208
1344
|
/**
|
|
1209
1345
|
* Stable issue codes. Consumers may switch on these in CI — do not rename
|
|
@@ -1263,6 +1399,13 @@ declare function isOk(issues: ValidationIssue[]): boolean;
|
|
|
1263
1399
|
*/
|
|
1264
1400
|
declare function buildResult<T>(name: string, mode: ValidationResult["mode"], issues: ValidationIssue[], resource?: T, target?: ValidationTarget): ValidationResult<T>;
|
|
1265
1401
|
|
|
1402
|
+
/**
|
|
1403
|
+
* Verify a store exists and is reachable with the current API key. A 404
|
|
1404
|
+
* typically means the key belongs to a different account, not that the store
|
|
1405
|
+
* is gone — the suggested fix reflects that.
|
|
1406
|
+
*/
|
|
1407
|
+
declare function validateStore(http: HttpClient, mode: Mode, storeId: string | number): Promise<ValidationResult<StoreAttributes>>;
|
|
1408
|
+
|
|
1266
1409
|
type AffiliateStatus = "active" | "pending" | "disabled";
|
|
1267
1410
|
/**
|
|
1268
1411
|
* Affiliate attributes added with the 2025-01-21 Affiliates API surface.
|
|
@@ -1731,70 +1874,6 @@ interface UsageRecordAttributes extends GeneratedUsageRecordAttributes {
|
|
|
1731
1874
|
declare function getUsageRecord(http: HttpClient, usageRecordId: string | number): Promise<JsonApiResource<UsageRecordAttributes>>;
|
|
1732
1875
|
declare function listUsageRecordsForSubscriptionItem(http: HttpClient, subscriptionItemId: string | number): Promise<JsonApiResource<UsageRecordAttributes>[]>;
|
|
1733
1876
|
|
|
1734
|
-
interface VariantLink {
|
|
1735
|
-
title: string;
|
|
1736
|
-
url: string;
|
|
1737
|
-
}
|
|
1738
|
-
/**
|
|
1739
|
-
* Variant attributes used by the product validator to detect
|
|
1740
|
-
* variant/price drift from the product they belong to.
|
|
1741
|
-
*/
|
|
1742
|
-
interface VariantAttributes extends GeneratedVariantAttributes {
|
|
1743
|
-
product_id: number;
|
|
1744
|
-
name: string;
|
|
1745
|
-
slug: string;
|
|
1746
|
-
description?: string | null;
|
|
1747
|
-
has_license_keys?: boolean;
|
|
1748
|
-
license_activation_limit?: number | null;
|
|
1749
|
-
is_license_limit_unlimited?: boolean;
|
|
1750
|
-
license_length_value?: number | null;
|
|
1751
|
-
license_length_unit?: "day" | "week" | "month" | "year" | null;
|
|
1752
|
-
is_license_length_unlimited?: boolean;
|
|
1753
|
-
status: "pending" | "draft" | "published";
|
|
1754
|
-
status_formatted?: string;
|
|
1755
|
-
is_subscription?: boolean;
|
|
1756
|
-
interval?: string | null;
|
|
1757
|
-
interval_count?: number | null;
|
|
1758
|
-
sort?: number;
|
|
1759
|
-
/**
|
|
1760
|
-
* Hosted-checkout-style links keyed by purpose. Added 2024-06-09 — older
|
|
1761
|
-
* SDK and validator versions don't surface this field, so consumers had
|
|
1762
|
-
* to read `meta.product_links` manually before. Optional because the
|
|
1763
|
-
* field is absent on older variants.
|
|
1764
|
-
*/
|
|
1765
|
-
links?: VariantLink[] | Record<string, string>;
|
|
1766
|
-
created_at?: string;
|
|
1767
|
-
updated_at?: string;
|
|
1768
|
-
test_mode?: boolean;
|
|
1769
|
-
}
|
|
1770
|
-
/**
|
|
1771
|
-
* Extended variant attributes for subscription plan validation. In Lemon
|
|
1772
|
-
* Squeezy, "subscription plans" live as variants with `is_subscription: true`.
|
|
1773
|
-
* These fields are only present on subscription variants and are checked by
|
|
1774
|
-
* the subscription plan validator to catch misconfigured trial periods,
|
|
1775
|
-
* zero-price plans, and invalid billing intervals.
|
|
1776
|
-
*/
|
|
1777
|
-
interface SubscriptionVariantAttributes extends VariantAttributes {
|
|
1778
|
-
is_subscription: boolean;
|
|
1779
|
-
interval: string | null;
|
|
1780
|
-
interval_count: number | null;
|
|
1781
|
-
has_free_trial: boolean;
|
|
1782
|
-
trial_interval: string | null;
|
|
1783
|
-
trial_interval_count: number | null;
|
|
1784
|
-
price: number;
|
|
1785
|
-
}
|
|
1786
|
-
/**
|
|
1787
|
-
* Fetch a single variant by ID. Used by the subscription plan validator to
|
|
1788
|
-
* inspect subscription-specific fields (interval, trial, price).
|
|
1789
|
-
*/
|
|
1790
|
-
declare function getVariant<TAttr = VariantAttributes>(http: HttpClient, variantId: string | number): Promise<JsonApiResource<TAttr>>;
|
|
1791
|
-
/**
|
|
1792
|
-
* List every variant of the product, paginated so products with more than
|
|
1793
|
-
* one page of variants don't trip the `VARIANT_UNPUBLISHED` heuristic when
|
|
1794
|
-
* the only published variants happen to live past page 1.
|
|
1795
|
-
*/
|
|
1796
|
-
declare function listVariantsForProduct(http: HttpClient, productId: string | number): Promise<JsonApiResource<VariantAttributes>[]>;
|
|
1797
|
-
|
|
1798
1877
|
/**
|
|
1799
1878
|
* Support manifest: the locally reviewed source of truth for what
|
|
1800
1879
|
* fresh-squeezy explicitly understands on the Lemon Squeezy platform.
|
|
@@ -1936,4 +2015,4 @@ declare const ACKNOWLEDGED_CHANGELOG_ENTRIES: readonly [{
|
|
|
1936
2015
|
type RecommendedEvent = (typeof RECOMMENDED_WEBHOOK_EVENTS)[number];
|
|
1937
2016
|
type OptionalEvent = (typeof OPTIONAL_WEBHOOK_EVENTS)[number];
|
|
1938
2017
|
|
|
1939
|
-
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 DiscountRedemptionAttributes, type DoctorOptions, type DoctorReport, type DoctorValidators, ENV_KEYS, type FileAttributes, type FreshSqueezyClient, type FreshSqueezyConfig, FreshSqueezyError, 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 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 LicenseKeyInstanceAttributes, type Mode, OPTIONAL_WEBHOOK_EVENTS, type OptionalEvent, type OrderAttributes, type OrderFirstItem, type OrderItemAttributes, type OrderUrls, type PriceAttributes, type ProductAttributes, type ProductValidationOptions, RECOMMENDED_WEBHOOK_EVENTS, type RecommendedEvent, type ResolvedConfig, SUPPORTED_RESOURCES, type StoreAttributes, type SubscriptionAttributes, type SubscriptionInvoiceAttributes, type SubscriptionInvoiceBillingReason, type SubscriptionInvoiceStatus, type SubscriptionInvoiceUrls, type SubscriptionItemAttributes, type SubscriptionItemSummary, type SubscriptionItemUpdateAttributes, type SubscriptionPause, 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, createFreshSqueezy, doctor, fetchActualMode, getAffiliate, getAuthenticatedUser, getCheckout, getCustomer, getDiscountRedemption, getFile, getLicenseKeyInstance, getOrder, getOrderItem, getPrice, getProduct, getStore, getSubscription, getSubscriptionInvoice, getSubscriptionItem, getUsageRecord, getVariant, isOk, issue, listAffiliatesForStore, listCheckoutsForStore, listCustomersForStore, listDiscountRedemptionsForDiscount, listFilesForVariant, listLicenseKeyInstancesForLicenseKey, listOrderItemsForOrder, listProducts, listStores, listSubscriptionInvoicesForSubscription, listSubscriptionItemsForSubscription, listUsageRecordsForSubscriptionItem, listVariantsForProduct, listWebhooksForStore, resolveActualMode, resolveConfig, sameWebhookUrl, userResource, validateConnection, validateProduct, validateWebhook };
|
|
2018
|
+
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 DiscountRedemptionAttributes, type DiscountValidationOptions, type DoctorOptions, type DoctorReport, type DoctorValidators, ENV_KEYS, type FileAttributes, type FreshSqueezyClient, type FreshSqueezyConfig, FreshSqueezyError, 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 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 LicenseKeyInstanceAttributes, type LicenseKeyValidationOptions, type Mode, OPTIONAL_WEBHOOK_EVENTS, type OptionalEvent, type OrderAttributes, type OrderFirstItem, type OrderItemAttributes, type OrderUrls, type PriceAttributes, type ProductAttributes, type ProductValidationOptions, RECOMMENDED_WEBHOOK_EVENTS, type RecommendedEvent, type ResolvedConfig, 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, getAffiliate, getAuthenticatedUser, getCheckout, getCustomer, getDiscountRedemption, getFile, getLicenseKeyInstance, getOrder, getOrderItem, getPrice, getProduct, getStore, getSubscription, getSubscriptionInvoice, getSubscriptionItem, getUsageRecord, getVariant, isOk, issue, listAffiliatesForStore, listCheckoutsForStore, listCustomersForStore, listDiscountRedemptionsForDiscount, listFilesForVariant, listLicenseKeyInstancesForLicenseKey, listOrderItemsForOrder, listProducts, listStores, listSubscriptionInvoicesForSubscription, listSubscriptionItemsForSubscription, listUsageRecordsForSubscriptionItem, listVariantsForProduct, listWebhooksForStore, resolveActualMode, resolveConfig, sameWebhookUrl, userResource, validateConnection, validateDiscount, validateLicenseKey, validateProduct, validateStore, validateSubscriptionPlan, validateWebhook };
|