fresh-squeezy 0.1.13 → 0.1.15
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.md +56 -12
- package/dist/cli.js +1496 -328
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1136 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +901 -73
- package/dist/index.d.ts +901 -73
- package/dist/index.js +1106 -245
- package/dist/index.js.map +1 -1
- package/package.json +7 -10
package/dist/index.d.ts
CHANGED
|
@@ -757,7 +757,8 @@ interface RequestOptions {
|
|
|
757
757
|
method?: "GET" | "POST" | "PATCH" | "DELETE";
|
|
758
758
|
path: string;
|
|
759
759
|
query?: Record<string, string | number | undefined>;
|
|
760
|
-
body
|
|
760
|
+
/** JSON:API document or other request body; stringified when present. */
|
|
761
|
+
body?: unknown;
|
|
761
762
|
signal?: AbortSignal;
|
|
762
763
|
}
|
|
763
764
|
/**
|
|
@@ -783,6 +784,29 @@ declare class HttpClient {
|
|
|
783
784
|
* Fetch a single JSON:API resource and return its `data` object.
|
|
784
785
|
*/
|
|
785
786
|
getResource<TAttr>(path: string): Promise<JsonApiResource<TAttr>>;
|
|
787
|
+
/**
|
|
788
|
+
* POST a JSON:API document and return the created `data` resource.
|
|
789
|
+
*
|
|
790
|
+
* @param path - API path starting with `/v1/...`.
|
|
791
|
+
* @param body - JSON:API create document.
|
|
792
|
+
* @returns The created resource.
|
|
793
|
+
*/
|
|
794
|
+
postResource<TAttr>(path: string, body: unknown): Promise<JsonApiResource<TAttr>>;
|
|
795
|
+
/**
|
|
796
|
+
* PATCH a JSON:API document and return the updated `data` resource.
|
|
797
|
+
*
|
|
798
|
+
* @param path - API path starting with `/v1/...`.
|
|
799
|
+
* @param body - JSON:API update document.
|
|
800
|
+
* @returns The updated resource.
|
|
801
|
+
*/
|
|
802
|
+
patchResource<TAttr>(path: string, body: unknown): Promise<JsonApiResource<TAttr>>;
|
|
803
|
+
/**
|
|
804
|
+
* DELETE a resource. Lemon Squeezy often returns an empty body on success.
|
|
805
|
+
*
|
|
806
|
+
* @param path - API path starting with `/v1/...`.
|
|
807
|
+
* @returns Nothing — single void return, not a multi-field bag.
|
|
808
|
+
*/
|
|
809
|
+
deleteResource(path: string): Promise<void>;
|
|
786
810
|
/**
|
|
787
811
|
* Fetch a single page of a JSON:API collection. Most callers want
|
|
788
812
|
* `paginate()` instead — this method is kept for one-shot lookups where
|
|
@@ -827,6 +851,71 @@ interface DiscountAttributes extends GeneratedDiscountAttributes {
|
|
|
827
851
|
created_at?: string;
|
|
828
852
|
updated_at?: string;
|
|
829
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Fetch a single discount by ID. The validator uses the discount's
|
|
856
|
+
* `relationships.store` to confirm ownership against the caller's storeId.
|
|
857
|
+
*
|
|
858
|
+
* @param http - Shared API client.
|
|
859
|
+
* @param discountId - Discount id.
|
|
860
|
+
* @returns The discount resource.
|
|
861
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```ts
|
|
865
|
+
* const discount = await getDiscount(http, 1);
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
declare const getDiscount: (http: HttpClient, discountId: string | number) => Promise<JsonApiResource<DiscountAttributes>>;
|
|
869
|
+
/**
|
|
870
|
+
* List discounts for a store (GET /v1/discounts?filter[store_id]=…).
|
|
871
|
+
*
|
|
872
|
+
* @param http - Shared API client.
|
|
873
|
+
* @param storeId - Store filter.
|
|
874
|
+
* @returns Discount resources.
|
|
875
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```ts
|
|
879
|
+
* const discounts = await listDiscountsForStore(http, 1);
|
|
880
|
+
* ```
|
|
881
|
+
*/
|
|
882
|
+
declare const listDiscountsForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<DiscountAttributes>[]>;
|
|
883
|
+
/**
|
|
884
|
+
* Create a discount (POST /v1/discounts). No update endpoint exists in the API.
|
|
885
|
+
* Docs: https://docs.lemonsqueezy.com/api/discounts/create-discount
|
|
886
|
+
*
|
|
887
|
+
* @param http - Shared API client.
|
|
888
|
+
* @param body - JSON:API create document.
|
|
889
|
+
* @returns The created discount.
|
|
890
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```ts
|
|
894
|
+
* const discount = await createDiscount(http, {
|
|
895
|
+
* data: {
|
|
896
|
+
* type: "discounts",
|
|
897
|
+
* attributes: { name: "Launch", code: "LAUNCH10", amount: 10, amount_type: "percent" },
|
|
898
|
+
* relationships: { store: { data: { type: "stores", id: "1" } } },
|
|
899
|
+
* },
|
|
900
|
+
* });
|
|
901
|
+
* ```
|
|
902
|
+
*/
|
|
903
|
+
declare const createDiscount: (http: HttpClient, body: unknown) => Promise<JsonApiResource<DiscountAttributes>>;
|
|
904
|
+
/**
|
|
905
|
+
* Delete a discount (DELETE /v1/discounts/:id).
|
|
906
|
+
* Docs: https://docs.lemonsqueezy.com/api/discounts/delete-discount
|
|
907
|
+
*
|
|
908
|
+
* @param http - Shared API client.
|
|
909
|
+
* @param discountId - Discount id.
|
|
910
|
+
* @returns Nothing on success.
|
|
911
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* await deleteDiscount(http, 1);
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
declare const deleteDiscount: (http: HttpClient, discountId: string | number) => Promise<void>;
|
|
830
919
|
|
|
831
920
|
/**
|
|
832
921
|
* Subset of Lemon Squeezy license-key attributes used by the license key
|
|
@@ -843,6 +932,53 @@ interface LicenseKeyAttributes extends GeneratedLicenseKeyAttributes {
|
|
|
843
932
|
created_at?: string;
|
|
844
933
|
updated_at?: string;
|
|
845
934
|
}
|
|
935
|
+
/**
|
|
936
|
+
* Fetch a single license key by ID. Used by the license key validator to
|
|
937
|
+
* check activation limits, expiration, and store ownership.
|
|
938
|
+
*
|
|
939
|
+
* @param http - Shared API client.
|
|
940
|
+
* @param licenseKeyId - License key id.
|
|
941
|
+
* @returns The license key resource.
|
|
942
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```ts
|
|
946
|
+
* const key = await getLicenseKey(http, 1);
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
949
|
+
declare const getLicenseKey: (http: HttpClient, licenseKeyId: string | number) => Promise<JsonApiResource<LicenseKeyAttributes>>;
|
|
950
|
+
/**
|
|
951
|
+
* List license keys for a store.
|
|
952
|
+
*
|
|
953
|
+
* @param http - Shared API client.
|
|
954
|
+
* @param storeId - Store filter.
|
|
955
|
+
* @returns License key resources.
|
|
956
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```ts
|
|
960
|
+
* const keys = await listLicenseKeysForStore(http, 1);
|
|
961
|
+
* ```
|
|
962
|
+
*/
|
|
963
|
+
declare const listLicenseKeysForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<LicenseKeyAttributes>[]>;
|
|
964
|
+
/**
|
|
965
|
+
* Update a license key (PATCH /v1/license-keys/:id) — e.g. `expires_at`, disabled.
|
|
966
|
+
* Docs: https://docs.lemonsqueezy.com/api/license-keys/update-license-key
|
|
967
|
+
*
|
|
968
|
+
* @param http - Shared API client.
|
|
969
|
+
* @param licenseKeyId - License key id.
|
|
970
|
+
* @param body - JSON:API update document.
|
|
971
|
+
* @returns The updated license key.
|
|
972
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```ts
|
|
976
|
+
* const key = await updateLicenseKey(http, 1, {
|
|
977
|
+
* data: { type: "license-keys", id: "1", attributes: { disabled: true } },
|
|
978
|
+
* });
|
|
979
|
+
* ```
|
|
980
|
+
*/
|
|
981
|
+
declare const updateLicenseKey: (http: HttpClient, licenseKeyId: string | number, body: unknown) => Promise<JsonApiResource<LicenseKeyAttributes>>;
|
|
846
982
|
|
|
847
983
|
/**
|
|
848
984
|
* Subset of product attributes we need for validation. `status` drives the
|
|
@@ -861,13 +997,13 @@ interface ProductAttributes extends GeneratedProductAttributes {
|
|
|
861
997
|
created_at?: string;
|
|
862
998
|
updated_at?: string;
|
|
863
999
|
}
|
|
864
|
-
declare
|
|
1000
|
+
declare const getProduct: (http: HttpClient, productId: string | number) => Promise<JsonApiResource<ProductAttributes>>;
|
|
865
1001
|
/**
|
|
866
1002
|
* List every product in the store, paginated. Used by the CLI's
|
|
867
1003
|
* interactive product picker; without pagination only the first 25
|
|
868
1004
|
* products are offered.
|
|
869
1005
|
*/
|
|
870
|
-
declare
|
|
1006
|
+
declare const listProducts: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<ProductAttributes>[]>;
|
|
871
1007
|
|
|
872
1008
|
/**
|
|
873
1009
|
* Subset of store attributes fresh-squeezy reads.
|
|
@@ -884,14 +1020,14 @@ interface StoreAttributes extends GeneratedStoreAttributes {
|
|
|
884
1020
|
created_at?: string;
|
|
885
1021
|
updated_at?: string;
|
|
886
1022
|
}
|
|
887
|
-
declare
|
|
1023
|
+
declare const getStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<StoreAttributes>>;
|
|
888
1024
|
/**
|
|
889
1025
|
* List every store reachable with the configured API key, paginated.
|
|
890
1026
|
* Used by `validateConnection` to populate the connection summary, and by
|
|
891
1027
|
* the CLI's `--all-stores` flag. Pagination matters here for accounts that
|
|
892
1028
|
* own a large catalogue of stores.
|
|
893
1029
|
*/
|
|
894
|
-
declare
|
|
1030
|
+
declare const listStores: (http: HttpClient) => Promise<JsonApiResource<StoreAttributes>[]>;
|
|
895
1031
|
|
|
896
1032
|
/**
|
|
897
1033
|
* Subset of webhook attributes we read. `events` is an ordered list of
|
|
@@ -907,12 +1043,90 @@ interface WebhookAttributes extends GeneratedWebhookAttributes {
|
|
|
907
1043
|
updated_at?: string;
|
|
908
1044
|
test_mode?: boolean;
|
|
909
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Retrieve one webhook by id.
|
|
1048
|
+
*
|
|
1049
|
+
* @param http - Shared API client.
|
|
1050
|
+
* @param webhookId - Webhook id.
|
|
1051
|
+
* @returns The webhook resource.
|
|
1052
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```ts
|
|
1056
|
+
* const webhook = await getWebhook(http, 1);
|
|
1057
|
+
* ```
|
|
1058
|
+
*/
|
|
1059
|
+
declare const getWebhook: (http: HttpClient, webhookId: string | number) => Promise<JsonApiResource<WebhookAttributes>>;
|
|
910
1060
|
/**
|
|
911
1061
|
* List every webhook registered on the store, walking pagination so a store
|
|
912
1062
|
* with more than one page of webhooks doesn't produce a false
|
|
913
1063
|
* `WEBHOOK_NOT_FOUND` from `validateWebhook`.
|
|
1064
|
+
*
|
|
1065
|
+
* @param http - Shared API client.
|
|
1066
|
+
* @param storeId - Store to filter.
|
|
1067
|
+
* @returns All webhook resources for the store.
|
|
1068
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```ts
|
|
1072
|
+
* const webhooks = await listWebhooksForStore(http, 1);
|
|
1073
|
+
* ```
|
|
914
1074
|
*/
|
|
915
|
-
declare
|
|
1075
|
+
declare const listWebhooksForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<WebhookAttributes>[]>;
|
|
1076
|
+
/**
|
|
1077
|
+
* Create a webhook (POST /v1/webhooks).
|
|
1078
|
+
* Docs: https://docs.lemonsqueezy.com/api/webhooks/create-webhook
|
|
1079
|
+
*
|
|
1080
|
+
* @param http - Shared API client.
|
|
1081
|
+
* @param body - JSON:API create document.
|
|
1082
|
+
* @returns The created webhook.
|
|
1083
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1084
|
+
*
|
|
1085
|
+
* @example
|
|
1086
|
+
* ```ts
|
|
1087
|
+
* const webhook = await createWebhook(http, {
|
|
1088
|
+
* data: {
|
|
1089
|
+
* type: "webhooks",
|
|
1090
|
+
* attributes: { url: "https://app.example.com/hook", events: ["order_created"] },
|
|
1091
|
+
* relationships: { store: { data: { type: "stores", id: "1" } } },
|
|
1092
|
+
* },
|
|
1093
|
+
* });
|
|
1094
|
+
* ```
|
|
1095
|
+
*/
|
|
1096
|
+
declare const createWebhook: (http: HttpClient, body: unknown) => Promise<JsonApiResource<WebhookAttributes>>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Update a webhook (PATCH /v1/webhooks/:id).
|
|
1099
|
+
* Docs: https://docs.lemonsqueezy.com/api/webhooks/update-webhook
|
|
1100
|
+
*
|
|
1101
|
+
* @param http - Shared API client.
|
|
1102
|
+
* @param webhookId - Webhook id.
|
|
1103
|
+
* @param body - JSON:API update document.
|
|
1104
|
+
* @returns The updated webhook.
|
|
1105
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```ts
|
|
1109
|
+
* const webhook = await updateWebhook(http, 1, {
|
|
1110
|
+
* data: { type: "webhooks", id: "1", attributes: { events: ["order_created"] } },
|
|
1111
|
+
* });
|
|
1112
|
+
* ```
|
|
1113
|
+
*/
|
|
1114
|
+
declare const updateWebhook: (http: HttpClient, webhookId: string | number, body: unknown) => Promise<JsonApiResource<WebhookAttributes>>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Delete a webhook (DELETE /v1/webhooks/:id).
|
|
1117
|
+
* Docs: https://docs.lemonsqueezy.com/api/webhooks/delete-webhook
|
|
1118
|
+
*
|
|
1119
|
+
* @param http - Shared API client.
|
|
1120
|
+
* @param webhookId - Webhook id.
|
|
1121
|
+
* @returns Nothing on success.
|
|
1122
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```ts
|
|
1126
|
+
* await deleteWebhook(http, 1);
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
declare const deleteWebhook: (http: HttpClient, webhookId: string | number) => Promise<void>;
|
|
916
1130
|
|
|
917
1131
|
/**
|
|
918
1132
|
* Subset of the Lemon Squeezy `users` resource attributes we rely on.
|
|
@@ -954,12 +1168,12 @@ type AuthenticatedUserDocument = JsonApiDocument<UserAttributes> & {
|
|
|
954
1168
|
* account identity for logs, and exposes `meta.test_mode` for mode
|
|
955
1169
|
* mismatch detection.
|
|
956
1170
|
*/
|
|
957
|
-
declare
|
|
1171
|
+
declare const getAuthenticatedUser: (http: HttpClient) => Promise<AuthenticatedUserDocument>;
|
|
958
1172
|
/**
|
|
959
1173
|
* Backwards-compatible helper if a caller only wants the resource (old
|
|
960
1174
|
* `getAuthenticatedUser` shape). Internal — not re-exported from the root.
|
|
961
1175
|
*/
|
|
962
|
-
declare
|
|
1176
|
+
declare const userResource: (doc: AuthenticatedUserDocument) => JsonApiResource<UserAttributes>;
|
|
963
1177
|
|
|
964
1178
|
/**
|
|
965
1179
|
* Connection validator summary attached to the `resource` field. Keeps the
|
|
@@ -987,7 +1201,7 @@ interface ConnectionSummary {
|
|
|
987
1201
|
* This is the first check every `doctor()` run performs; if it fails,
|
|
988
1202
|
* no downstream validator has anything useful to report.
|
|
989
1203
|
*/
|
|
990
|
-
declare
|
|
1204
|
+
declare const validateConnection: (http: HttpClient, mode: Mode) => Promise<ValidationResult<ConnectionSummary>>;
|
|
991
1205
|
/**
|
|
992
1206
|
* Ask the Lemon Squeezy API which mode the configured key actually belongs to.
|
|
993
1207
|
*
|
|
@@ -1002,7 +1216,7 @@ declare function validateConnection(http: HttpClient, mode: Mode): Promise<Valid
|
|
|
1002
1216
|
* failure; callers that want a structured non-throwing result should use
|
|
1003
1217
|
* `validateConnection` instead.
|
|
1004
1218
|
*/
|
|
1005
|
-
declare
|
|
1219
|
+
declare const fetchActualMode: (http: HttpClient) => Promise<Mode | undefined>;
|
|
1006
1220
|
|
|
1007
1221
|
interface DiscountValidationOptions {
|
|
1008
1222
|
storeId: string | number;
|
|
@@ -1020,15 +1234,15 @@ interface DiscountValidationOptions {
|
|
|
1020
1234
|
* `/v1/discount-redemptions?filter[discount_id]=` is YAGNI until a consumer
|
|
1021
1235
|
* asks for it.
|
|
1022
1236
|
*/
|
|
1023
|
-
declare
|
|
1237
|
+
declare const validateDiscount: (http: HttpClient, mode: Mode, options: DiscountValidationOptions) => Promise<ValidationResult<DiscountAttributes>>;
|
|
1024
1238
|
/**
|
|
1025
1239
|
* Pure attribute assertions for a discount: store ownership, draft/expiry/
|
|
1026
1240
|
* activation windows, redemption exhaustion, and amount validity. No I/O, so
|
|
1027
1241
|
* the rules are unit-testable with plain data.
|
|
1028
1242
|
*/
|
|
1029
|
-
declare
|
|
1243
|
+
declare const checkDiscount: (attrs: DiscountAttributes, options: {
|
|
1030
1244
|
storeId: string | number;
|
|
1031
|
-
})
|
|
1245
|
+
}) => ValidationIssue[];
|
|
1032
1246
|
|
|
1033
1247
|
interface LicenseKeyValidationOptions {
|
|
1034
1248
|
storeId: string | number;
|
|
@@ -1040,15 +1254,15 @@ interface LicenseKeyValidationOptions {
|
|
|
1040
1254
|
* four states most likely to cause "why can't my customer activate?"
|
|
1041
1255
|
* support tickets.
|
|
1042
1256
|
*/
|
|
1043
|
-
declare
|
|
1257
|
+
declare const validateLicenseKey: (http: HttpClient, mode: Mode, options: LicenseKeyValidationOptions) => Promise<ValidationResult<LicenseKeyAttributes>>;
|
|
1044
1258
|
/**
|
|
1045
1259
|
* Pure attribute assertions for a license key: store ownership, disabled/
|
|
1046
1260
|
* expired state, and activation-limit exhaustion. No I/O, so the rules are
|
|
1047
1261
|
* unit-testable with plain data.
|
|
1048
1262
|
*/
|
|
1049
|
-
declare
|
|
1263
|
+
declare const checkLicenseKey: (attrs: LicenseKeyAttributes, options: {
|
|
1050
1264
|
storeId: string | number;
|
|
1051
|
-
})
|
|
1265
|
+
}) => ValidationIssue[];
|
|
1052
1266
|
|
|
1053
1267
|
interface ProductValidationOptions {
|
|
1054
1268
|
productId: string | number;
|
|
@@ -1060,16 +1274,16 @@ interface ProductValidationOptions {
|
|
|
1060
1274
|
* least one published variant. Surfaces the most common misconfigurations
|
|
1061
1275
|
* caught in the wild (unpublished product, wrong store, missing variants).
|
|
1062
1276
|
*/
|
|
1063
|
-
declare
|
|
1277
|
+
declare const validateProduct: (http: HttpClient, mode: Mode, options: ProductValidationOptions) => Promise<ValidationResult<ProductAttributes>>;
|
|
1064
1278
|
/**
|
|
1065
1279
|
* Pure attribute assertions for a product: store ownership, publish state, and
|
|
1066
1280
|
* hosted-checkout availability. The variant-population rule needs a second
|
|
1067
1281
|
* fetch and stays in `validateProduct`; everything here runs on plain data, so
|
|
1068
1282
|
* the rules are unit-testable without a mock fetch.
|
|
1069
1283
|
*/
|
|
1070
|
-
declare
|
|
1284
|
+
declare const checkProduct: (attrs: ProductAttributes, options?: {
|
|
1071
1285
|
expectedStoreId?: string | number;
|
|
1072
|
-
})
|
|
1286
|
+
}) => ValidationIssue[];
|
|
1073
1287
|
|
|
1074
1288
|
interface VariantLink {
|
|
1075
1289
|
title: string;
|
|
@@ -1127,13 +1341,13 @@ interface SubscriptionVariantAttributes extends VariantAttributes {
|
|
|
1127
1341
|
* Fetch a single variant by ID. Used by the subscription plan validator to
|
|
1128
1342
|
* inspect subscription-specific fields (interval, trial, price).
|
|
1129
1343
|
*/
|
|
1130
|
-
declare
|
|
1344
|
+
declare const getVariant: <TAttr = VariantAttributes>(http: HttpClient, variantId: string | number) => Promise<JsonApiResource<TAttr>>;
|
|
1131
1345
|
/**
|
|
1132
1346
|
* List every variant of the product, paginated so products with more than
|
|
1133
1347
|
* one page of variants don't trip the `VARIANT_UNPUBLISHED` heuristic when
|
|
1134
1348
|
* the only published variants happen to live past page 1.
|
|
1135
1349
|
*/
|
|
1136
|
-
declare
|
|
1350
|
+
declare const listVariantsForProduct: (http: HttpClient, productId: string | number) => Promise<JsonApiResource<VariantAttributes>[]>;
|
|
1137
1351
|
|
|
1138
1352
|
interface SubscriptionPlanValidationOptions {
|
|
1139
1353
|
storeId: string | number;
|
|
@@ -1159,7 +1373,7 @@ interface SubscriptionPlanSummary {
|
|
|
1159
1373
|
* `storeId` as advisory — if the product fetch fails the cross-check is
|
|
1160
1374
|
* silently skipped rather than blocking the entire validation.
|
|
1161
1375
|
*/
|
|
1162
|
-
declare
|
|
1376
|
+
declare const validateSubscriptionPlan: (http: HttpClient, mode: Mode, options: SubscriptionPlanValidationOptions) => Promise<ValidationResult<SubscriptionPlanSummary>>;
|
|
1163
1377
|
/**
|
|
1164
1378
|
* Pure attribute assertions for a subscription variant: that it is actually a
|
|
1165
1379
|
* subscription, has a valid interval / interval_count, is not free-priced, has
|
|
@@ -1167,9 +1381,9 @@ declare function validateSubscriptionPlan(http: HttpClient, mode: Mode, options:
|
|
|
1167
1381
|
* second fetch and stays in `validateSubscriptionPlan`; everything here runs on
|
|
1168
1382
|
* plain data, so the rules are unit-testable without a mock fetch.
|
|
1169
1383
|
*/
|
|
1170
|
-
declare
|
|
1384
|
+
declare const checkSubscriptionPlan: (attrs: SubscriptionVariantAttributes, options: {
|
|
1171
1385
|
variantId: string | number;
|
|
1172
|
-
})
|
|
1386
|
+
}) => ValidationIssue[];
|
|
1173
1387
|
|
|
1174
1388
|
interface WebhookValidationOptions {
|
|
1175
1389
|
storeId: string | number;
|
|
@@ -1184,7 +1398,7 @@ interface WebhookValidationOptions {
|
|
|
1184
1398
|
* Missing recommended events = error. Missing optional events = info, because
|
|
1185
1399
|
* not every integration needs them.
|
|
1186
1400
|
*/
|
|
1187
|
-
declare
|
|
1401
|
+
declare const validateWebhook: (http: HttpClient, mode: Mode, options: WebhookValidationOptions) => Promise<ValidationResult<WebhookAttributes>>;
|
|
1188
1402
|
|
|
1189
1403
|
/**
|
|
1190
1404
|
* Optional targets for the doctor run. If a target is omitted, its validator
|
|
@@ -1234,14 +1448,116 @@ declare const DEFAULT_VALIDATORS: DoctorValidators;
|
|
|
1234
1448
|
* The optional `validators` parameter lets tests inject fakes without a fetch
|
|
1235
1449
|
* mock; production callers omit it and get `DEFAULT_VALIDATORS`.
|
|
1236
1450
|
*/
|
|
1237
|
-
declare
|
|
1451
|
+
declare const doctor: (http: HttpClient, mode: Mode, options?: DoctorOptions, validators?: DoctorValidators) => Promise<DoctorReport>;
|
|
1238
1452
|
|
|
1239
1453
|
/**
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
* internals without breaking callers.
|
|
1454
|
+
* Nested resource namespaces for docs-backed Lemon Squeezy ops.
|
|
1455
|
+
* Methods only exist when the official API documents them (no product.create).
|
|
1243
1456
|
*/
|
|
1244
|
-
interface
|
|
1457
|
+
interface FreshSqueezyOps {
|
|
1458
|
+
users: {
|
|
1459
|
+
me: () => Promise<unknown>;
|
|
1460
|
+
};
|
|
1461
|
+
stores: {
|
|
1462
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1463
|
+
list: () => Promise<unknown>;
|
|
1464
|
+
};
|
|
1465
|
+
products: {
|
|
1466
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1467
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1468
|
+
};
|
|
1469
|
+
variants: {
|
|
1470
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1471
|
+
list: (productId: string | number) => Promise<unknown>;
|
|
1472
|
+
};
|
|
1473
|
+
prices: {
|
|
1474
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1475
|
+
list: (variantId: string | number) => Promise<unknown>;
|
|
1476
|
+
};
|
|
1477
|
+
files: {
|
|
1478
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1479
|
+
list: (variantId: string | number) => Promise<unknown>;
|
|
1480
|
+
};
|
|
1481
|
+
customers: {
|
|
1482
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1483
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1484
|
+
create: (body: unknown) => Promise<unknown>;
|
|
1485
|
+
update: (id: string | number, body: unknown) => Promise<unknown>;
|
|
1486
|
+
};
|
|
1487
|
+
orders: {
|
|
1488
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1489
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1490
|
+
refund: (id: string | number, body?: unknown) => Promise<unknown>;
|
|
1491
|
+
generateInvoice: (id: string | number, body?: unknown) => Promise<unknown>;
|
|
1492
|
+
};
|
|
1493
|
+
orderItems: {
|
|
1494
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1495
|
+
list: (orderId: string | number) => Promise<unknown>;
|
|
1496
|
+
};
|
|
1497
|
+
subscriptions: {
|
|
1498
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1499
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1500
|
+
update: (id: string | number, body: unknown) => Promise<unknown>;
|
|
1501
|
+
cancel: (id: string | number) => Promise<unknown>;
|
|
1502
|
+
};
|
|
1503
|
+
subscriptionItems: {
|
|
1504
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1505
|
+
list: (subscriptionId: string | number) => Promise<unknown>;
|
|
1506
|
+
update: (id: string | number, body: unknown) => Promise<unknown>;
|
|
1507
|
+
currentUsage: (id: string | number) => Promise<unknown>;
|
|
1508
|
+
};
|
|
1509
|
+
subscriptionInvoices: {
|
|
1510
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1511
|
+
list: (subscriptionId: string | number) => Promise<unknown>;
|
|
1512
|
+
refund: (id: string | number, body?: unknown) => Promise<unknown>;
|
|
1513
|
+
generateInvoice: (id: string | number, body?: unknown) => Promise<unknown>;
|
|
1514
|
+
};
|
|
1515
|
+
usageRecords: {
|
|
1516
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1517
|
+
list: (subscriptionItemId: string | number) => Promise<unknown>;
|
|
1518
|
+
create: (body: unknown) => Promise<unknown>;
|
|
1519
|
+
};
|
|
1520
|
+
discounts: {
|
|
1521
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1522
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1523
|
+
create: (body: unknown) => Promise<unknown>;
|
|
1524
|
+
delete: (id: string | number) => Promise<unknown>;
|
|
1525
|
+
};
|
|
1526
|
+
discountRedemptions: {
|
|
1527
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1528
|
+
list: (discountId: string | number) => Promise<unknown>;
|
|
1529
|
+
};
|
|
1530
|
+
licenseKeys: {
|
|
1531
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1532
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1533
|
+
update: (id: string | number, body: unknown) => Promise<unknown>;
|
|
1534
|
+
};
|
|
1535
|
+
licenseKeyInstances: {
|
|
1536
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1537
|
+
list: (licenseKeyId: string | number) => Promise<unknown>;
|
|
1538
|
+
};
|
|
1539
|
+
checkouts: {
|
|
1540
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1541
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1542
|
+
create: (body: unknown) => Promise<unknown>;
|
|
1543
|
+
};
|
|
1544
|
+
webhooks: {
|
|
1545
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1546
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1547
|
+
create: (body: unknown) => Promise<unknown>;
|
|
1548
|
+
update: (id: string | number, body: unknown) => Promise<unknown>;
|
|
1549
|
+
delete: (id: string | number) => Promise<unknown>;
|
|
1550
|
+
};
|
|
1551
|
+
affiliates: {
|
|
1552
|
+
get: (id: string | number) => Promise<unknown>;
|
|
1553
|
+
list: (storeId: string | number) => Promise<unknown>;
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* The public client. Validators stay flat; ops live under nested namespaces
|
|
1558
|
+
* that mirror docs-backed resources.
|
|
1559
|
+
*/
|
|
1560
|
+
interface FreshSqueezyClient extends FreshSqueezyOps {
|
|
1245
1561
|
/** Resolved mode (test or live). Surfaced so consumers can log it. */
|
|
1246
1562
|
readonly mode: Mode;
|
|
1247
1563
|
/** Raw HTTP escape hatch for endpoints fresh-squeezy does not wrap. */
|
|
@@ -1260,14 +1576,20 @@ interface FreshSqueezyClient {
|
|
|
1260
1576
|
* `LEMON_SQUEEZY_API_KEY`, `LEMON_SQUEEZY_STORE_ID`, and `LEMON_SQUEEZY_MODE`
|
|
1261
1577
|
* from `process.env`.
|
|
1262
1578
|
*
|
|
1579
|
+
* @param config - Optional overrides for key, mode, store, fetch.
|
|
1580
|
+
* @returns Client with validators + nested docs-backed ops.
|
|
1581
|
+
* @throws {FreshSqueezyError} When config is invalid (missing key, bad mode).
|
|
1582
|
+
*
|
|
1263
1583
|
* @example
|
|
1264
1584
|
* ```ts
|
|
1265
1585
|
* const lemon = createFreshSqueezy();
|
|
1266
1586
|
* const report = await lemon.doctor();
|
|
1267
1587
|
* if (!report.ok) process.exit(1);
|
|
1588
|
+
* const product = await lemon.products.get(42);
|
|
1589
|
+
* const webhook = await lemon.webhooks.create({ data: { type: "webhooks", … } });
|
|
1268
1590
|
* ```
|
|
1269
1591
|
*/
|
|
1270
|
-
declare
|
|
1592
|
+
declare const createFreshSqueezy: (config?: FreshSqueezyConfig) => FreshSqueezyClient;
|
|
1271
1593
|
|
|
1272
1594
|
/**
|
|
1273
1595
|
* Domain-equality primitives for fresh-squeezy.
|
|
@@ -1283,7 +1605,7 @@ declare function createFreshSqueezy(config?: FreshSqueezyConfig): FreshSqueezyCl
|
|
|
1283
1605
|
* often paste the trailing-slash form into their config. The webhook validator
|
|
1284
1606
|
* relies on this rule to match a configured URL against the registered list.
|
|
1285
1607
|
*/
|
|
1286
|
-
declare
|
|
1608
|
+
declare const sameWebhookUrl: (a: string, b: string) => boolean;
|
|
1287
1609
|
|
|
1288
1610
|
/**
|
|
1289
1611
|
* Unified error type for fresh-squeezy. All HTTP and validation failures that
|
|
@@ -1323,7 +1645,7 @@ declare const ENV_KEYS: {
|
|
|
1323
1645
|
* just `apiKey`), so callers can surface a clear setup error at construction
|
|
1324
1646
|
* time rather than at first request.
|
|
1325
1647
|
*/
|
|
1326
|
-
declare
|
|
1648
|
+
declare const resolveConfig: (input?: FreshSqueezyConfig) => ResolvedConfig;
|
|
1327
1649
|
|
|
1328
1650
|
/**
|
|
1329
1651
|
* Map the boolean `meta.test_mode` flag from `/v1/users/me` to our `Mode` type.
|
|
@@ -1339,7 +1661,7 @@ declare function resolveConfig(input?: FreshSqueezyConfig): ResolvedConfig;
|
|
|
1339
1661
|
* lets `core/` stay foundational (it never reaches up into `resources/`); the
|
|
1340
1662
|
* I/O counterpart `fetchActualMode` lives in `validate/connection.ts`.
|
|
1341
1663
|
*/
|
|
1342
|
-
declare
|
|
1664
|
+
declare const resolveActualMode: (testMode: boolean | undefined) => Mode | undefined;
|
|
1343
1665
|
|
|
1344
1666
|
/**
|
|
1345
1667
|
* Stable issue codes. Consumers may switch on these in CI — do not rename
|
|
@@ -1385,26 +1707,26 @@ declare const ISSUE_CODES: {
|
|
|
1385
1707
|
* Build a `ValidationIssue` with defaults for the common case.
|
|
1386
1708
|
* Extracted so every validator produces consistently shaped issues.
|
|
1387
1709
|
*/
|
|
1388
|
-
declare
|
|
1710
|
+
declare const issue: (code: string, severity: ValidationSeverity, message: string, extras?: {
|
|
1389
1711
|
suggestedFix?: string;
|
|
1390
1712
|
context?: ValidationIssue["context"];
|
|
1391
|
-
})
|
|
1713
|
+
}) => ValidationIssue;
|
|
1392
1714
|
/**
|
|
1393
1715
|
* Fold an issue list into a boolean. Used by every validator so `ok` is
|
|
1394
1716
|
* computed the same way everywhere.
|
|
1395
1717
|
*/
|
|
1396
|
-
declare
|
|
1718
|
+
declare const isOk: (issues: ValidationIssue[]) => boolean;
|
|
1397
1719
|
/**
|
|
1398
1720
|
* Compose a `ValidationResult` with the `ok` flag derived from issues.
|
|
1399
1721
|
*/
|
|
1400
|
-
declare
|
|
1722
|
+
declare const buildResult: <T>(name: string, mode: ValidationResult["mode"], issues: ValidationIssue[], resource?: T, target?: ValidationTarget) => ValidationResult<T>;
|
|
1401
1723
|
|
|
1402
1724
|
/**
|
|
1403
1725
|
* Verify a store exists and is reachable with the current API key. A 404
|
|
1404
1726
|
* typically means the key belongs to a different account, not that the store
|
|
1405
1727
|
* is gone — the suggested fix reflects that.
|
|
1406
1728
|
*/
|
|
1407
|
-
declare
|
|
1729
|
+
declare const validateStore: (http: HttpClient, mode: Mode, storeId: string | number) => Promise<ValidationResult<StoreAttributes>>;
|
|
1408
1730
|
|
|
1409
1731
|
type AffiliateStatus = "active" | "pending" | "disabled";
|
|
1410
1732
|
/**
|
|
@@ -1426,8 +1748,8 @@ interface AffiliateAttributes extends GeneratedAffiliateAttributes {
|
|
|
1426
1748
|
created_at?: string;
|
|
1427
1749
|
updated_at?: string;
|
|
1428
1750
|
}
|
|
1429
|
-
declare
|
|
1430
|
-
declare
|
|
1751
|
+
declare const getAffiliate: (http: HttpClient, affiliateId: string | number) => Promise<JsonApiResource<AffiliateAttributes>>;
|
|
1752
|
+
declare const listAffiliatesForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<AffiliateAttributes>[]>;
|
|
1431
1753
|
|
|
1432
1754
|
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";
|
|
1433
1755
|
interface CheckoutProductOptions {
|
|
@@ -1511,8 +1833,58 @@ interface CheckoutAttributes extends GeneratedCheckoutAttributes {
|
|
|
1511
1833
|
updated_at?: string;
|
|
1512
1834
|
test_mode?: boolean;
|
|
1513
1835
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1836
|
+
/**
|
|
1837
|
+
* Retrieve a checkout (GET /v1/checkouts/:id).
|
|
1838
|
+
*
|
|
1839
|
+
* @param http - Shared API client.
|
|
1840
|
+
* @param checkoutId - Checkout id.
|
|
1841
|
+
* @returns The checkout resource.
|
|
1842
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* ```ts
|
|
1846
|
+
* const checkout = await getCheckout(http, 1);
|
|
1847
|
+
* ```
|
|
1848
|
+
*/
|
|
1849
|
+
declare const getCheckout: (http: HttpClient, checkoutId: string | number) => Promise<JsonApiResource<CheckoutAttributes>>;
|
|
1850
|
+
/**
|
|
1851
|
+
* List checkouts for a store.
|
|
1852
|
+
*
|
|
1853
|
+
* @param http - Shared API client.
|
|
1854
|
+
* @param storeId - Store filter.
|
|
1855
|
+
* @returns Checkout resources.
|
|
1856
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1857
|
+
*
|
|
1858
|
+
* @example
|
|
1859
|
+
* ```ts
|
|
1860
|
+
* const checkouts = await listCheckoutsForStore(http, 1);
|
|
1861
|
+
* ```
|
|
1862
|
+
*/
|
|
1863
|
+
declare const listCheckoutsForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<CheckoutAttributes>[]>;
|
|
1864
|
+
/**
|
|
1865
|
+
* Create a checkout (POST /v1/checkouts).
|
|
1866
|
+
* Docs: https://docs.lemonsqueezy.com/api/checkouts/create-checkout
|
|
1867
|
+
*
|
|
1868
|
+
* @param http - Shared API client.
|
|
1869
|
+
* @param body - JSON:API create document (store + variant relationships).
|
|
1870
|
+
* @returns The created checkout (includes `url` for the hosted checkout).
|
|
1871
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1872
|
+
*
|
|
1873
|
+
* @example
|
|
1874
|
+
* ```ts
|
|
1875
|
+
* const checkout = await createCheckout(http, {
|
|
1876
|
+
* data: {
|
|
1877
|
+
* type: "checkouts",
|
|
1878
|
+
* attributes: { checkout_data: { email: "buyer@example.com" } },
|
|
1879
|
+
* relationships: {
|
|
1880
|
+
* store: { data: { type: "stores", id: "1" } },
|
|
1881
|
+
* variant: { data: { type: "variants", id: "1" } },
|
|
1882
|
+
* },
|
|
1883
|
+
* },
|
|
1884
|
+
* });
|
|
1885
|
+
* ```
|
|
1886
|
+
*/
|
|
1887
|
+
declare const createCheckout: (http: HttpClient, body: unknown) => Promise<JsonApiResource<CheckoutAttributes>>;
|
|
1516
1888
|
|
|
1517
1889
|
type CustomerStatus = "subscribed" | "unsubscribed" | "archived" | "requires_verification" | "invalid_email" | "bounced";
|
|
1518
1890
|
interface CustomerUrls {
|
|
@@ -1542,8 +1914,73 @@ interface CustomerAttributes extends GeneratedCustomerAttributes {
|
|
|
1542
1914
|
updated_at?: string;
|
|
1543
1915
|
test_mode?: boolean;
|
|
1544
1916
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1917
|
+
/**
|
|
1918
|
+
* Retrieve a customer (GET /v1/customers/:id).
|
|
1919
|
+
*
|
|
1920
|
+
* @param http - Shared API client.
|
|
1921
|
+
* @param customerId - Customer id.
|
|
1922
|
+
* @returns The customer resource.
|
|
1923
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1924
|
+
*
|
|
1925
|
+
* @example
|
|
1926
|
+
* ```ts
|
|
1927
|
+
* const customer = await getCustomer(http, 1);
|
|
1928
|
+
* ```
|
|
1929
|
+
*/
|
|
1930
|
+
declare const getCustomer: (http: HttpClient, customerId: string | number) => Promise<JsonApiResource<CustomerAttributes>>;
|
|
1931
|
+
/**
|
|
1932
|
+
* List customers for a store.
|
|
1933
|
+
*
|
|
1934
|
+
* @param http - Shared API client.
|
|
1935
|
+
* @param storeId - Store filter.
|
|
1936
|
+
* @returns Customer resources.
|
|
1937
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1938
|
+
*
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```ts
|
|
1941
|
+
* const customers = await listCustomersForStore(http, 1);
|
|
1942
|
+
* ```
|
|
1943
|
+
*/
|
|
1944
|
+
declare const listCustomersForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<CustomerAttributes>[]>;
|
|
1945
|
+
/**
|
|
1946
|
+
* Create a customer (POST /v1/customers).
|
|
1947
|
+
* Docs: https://docs.lemonsqueezy.com/api/customers/create-customer
|
|
1948
|
+
*
|
|
1949
|
+
* @param http - Shared API client.
|
|
1950
|
+
* @param body - JSON:API create document.
|
|
1951
|
+
* @returns The created customer.
|
|
1952
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1953
|
+
*
|
|
1954
|
+
* @example
|
|
1955
|
+
* ```ts
|
|
1956
|
+
* const customer = await createCustomer(http, {
|
|
1957
|
+
* data: {
|
|
1958
|
+
* type: "customers",
|
|
1959
|
+
* attributes: { name: "Ada", email: "ada@example.com" },
|
|
1960
|
+
* relationships: { store: { data: { type: "stores", id: "1" } } },
|
|
1961
|
+
* },
|
|
1962
|
+
* });
|
|
1963
|
+
* ```
|
|
1964
|
+
*/
|
|
1965
|
+
declare const createCustomer: (http: HttpClient, body: unknown) => Promise<JsonApiResource<CustomerAttributes>>;
|
|
1966
|
+
/**
|
|
1967
|
+
* Update a customer (PATCH /v1/customers/:id).
|
|
1968
|
+
* Docs: https://docs.lemonsqueezy.com/api/customers/update-customer
|
|
1969
|
+
*
|
|
1970
|
+
* @param http - Shared API client.
|
|
1971
|
+
* @param customerId - Customer id.
|
|
1972
|
+
* @param body - JSON:API update document.
|
|
1973
|
+
* @returns The updated customer.
|
|
1974
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
1975
|
+
*
|
|
1976
|
+
* @example
|
|
1977
|
+
* ```ts
|
|
1978
|
+
* const customer = await updateCustomer(http, 1, {
|
|
1979
|
+
* data: { type: "customers", id: "1", attributes: { name: "Ada Lovelace" } },
|
|
1980
|
+
* });
|
|
1981
|
+
* ```
|
|
1982
|
+
*/
|
|
1983
|
+
declare const updateCustomer: (http: HttpClient, customerId: string | number, body: unknown) => Promise<JsonApiResource<CustomerAttributes>>;
|
|
1547
1984
|
|
|
1548
1985
|
interface DiscountRedemptionAttributes extends GeneratedDiscountRedemptionAttributes {
|
|
1549
1986
|
discount_id: number;
|
|
@@ -1556,8 +1993,8 @@ interface DiscountRedemptionAttributes extends GeneratedDiscountRedemptionAttrib
|
|
|
1556
1993
|
created_at?: string;
|
|
1557
1994
|
updated_at?: string;
|
|
1558
1995
|
}
|
|
1559
|
-
declare
|
|
1560
|
-
declare
|
|
1996
|
+
declare const getDiscountRedemption: (http: HttpClient, discountRedemptionId: string | number) => Promise<JsonApiResource<DiscountRedemptionAttributes>>;
|
|
1997
|
+
declare const listDiscountRedemptionsForDiscount: (http: HttpClient, discountId: string | number) => Promise<JsonApiResource<DiscountRedemptionAttributes>[]>;
|
|
1561
1998
|
|
|
1562
1999
|
/**
|
|
1563
2000
|
* Lemon Squeezy file attributes, generated from the public object docs.
|
|
@@ -1566,8 +2003,8 @@ declare function listDiscountRedemptionsForDiscount(http: HttpClient, discountId
|
|
|
1566
2003
|
*/
|
|
1567
2004
|
interface FileAttributes extends GeneratedFileAttributes {
|
|
1568
2005
|
}
|
|
1569
|
-
declare
|
|
1570
|
-
declare
|
|
2006
|
+
declare const getFile: (http: HttpClient, fileId: string | number) => Promise<JsonApiResource<FileAttributes>>;
|
|
2007
|
+
declare const listFilesForVariant: (http: HttpClient, variantId: string | number) => Promise<JsonApiResource<FileAttributes>[]>;
|
|
1571
2008
|
|
|
1572
2009
|
interface LicenseKeyInstanceAttributes extends GeneratedLicenseKeyInstanceAttributes {
|
|
1573
2010
|
license_key_id: number;
|
|
@@ -1576,8 +2013,8 @@ interface LicenseKeyInstanceAttributes extends GeneratedLicenseKeyInstanceAttrib
|
|
|
1576
2013
|
created_at?: string;
|
|
1577
2014
|
updated_at?: string;
|
|
1578
2015
|
}
|
|
1579
|
-
declare
|
|
1580
|
-
declare
|
|
2016
|
+
declare const getLicenseKeyInstance: (http: HttpClient, licenseKeyInstanceId: string | number) => Promise<JsonApiResource<LicenseKeyInstanceAttributes>>;
|
|
2017
|
+
declare const listLicenseKeyInstancesForLicenseKey: (http: HttpClient, licenseKeyId: string | number) => Promise<JsonApiResource<LicenseKeyInstanceAttributes>[]>;
|
|
1581
2018
|
|
|
1582
2019
|
/**
|
|
1583
2020
|
* Order item attributes. `quantity` was added to the documented object in
|
|
@@ -1594,8 +2031,8 @@ interface OrderItemAttributes extends GeneratedOrderItemAttributes {
|
|
|
1594
2031
|
created_at?: string;
|
|
1595
2032
|
updated_at?: string;
|
|
1596
2033
|
}
|
|
1597
|
-
declare
|
|
1598
|
-
declare
|
|
2034
|
+
declare const getOrderItem: (http: HttpClient, orderItemId: string | number) => Promise<JsonApiResource<OrderItemAttributes>>;
|
|
2035
|
+
declare const listOrderItemsForOrder: (http: HttpClient, orderId: string | number) => Promise<JsonApiResource<OrderItemAttributes>[]>;
|
|
1599
2036
|
|
|
1600
2037
|
interface OrderUrls {
|
|
1601
2038
|
receipt?: string;
|
|
@@ -1670,11 +2107,65 @@ interface OrderAttributes extends GeneratedOrderAttributes {
|
|
|
1670
2107
|
test_mode?: boolean;
|
|
1671
2108
|
}
|
|
1672
2109
|
/**
|
|
1673
|
-
* Fetch a single order by ID.
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
2110
|
+
* Fetch a single order by ID.
|
|
2111
|
+
*
|
|
2112
|
+
* @param http - Shared API client.
|
|
2113
|
+
* @param orderId - Order id.
|
|
2114
|
+
* @returns The order resource.
|
|
2115
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2116
|
+
*
|
|
2117
|
+
* @example
|
|
2118
|
+
* ```ts
|
|
2119
|
+
* const order = await getOrder(http, 1);
|
|
2120
|
+
* ```
|
|
2121
|
+
*/
|
|
2122
|
+
declare const getOrder: (http: HttpClient, orderId: string | number) => Promise<JsonApiResource<OrderAttributes>>;
|
|
2123
|
+
/**
|
|
2124
|
+
* List orders for a store.
|
|
2125
|
+
*
|
|
2126
|
+
* @param http - Shared API client.
|
|
2127
|
+
* @param storeId - Store filter.
|
|
2128
|
+
* @returns Order resources.
|
|
2129
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2130
|
+
*
|
|
2131
|
+
* @example
|
|
2132
|
+
* ```ts
|
|
2133
|
+
* const orders = await listOrdersForStore(http, 1);
|
|
2134
|
+
* ```
|
|
2135
|
+
*/
|
|
2136
|
+
declare const listOrdersForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<OrderAttributes>[]>;
|
|
2137
|
+
/**
|
|
2138
|
+
* Issue a full or partial order refund (POST /v1/orders/:id/refund).
|
|
2139
|
+
* Docs: https://docs.lemonsqueezy.com/api/orders/issue-refund
|
|
2140
|
+
*
|
|
2141
|
+
* @param http - Shared API client.
|
|
2142
|
+
* @param orderId - Order to refund.
|
|
2143
|
+
* @param body - Optional JSON:API body (`attributes.amount` for partial).
|
|
2144
|
+
* @returns The updated order after refund.
|
|
2145
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2146
|
+
*
|
|
2147
|
+
* @example
|
|
2148
|
+
* ```ts
|
|
2149
|
+
* const order = await refundOrder(http, 1);
|
|
2150
|
+
* ```
|
|
1676
2151
|
*/
|
|
1677
|
-
declare
|
|
2152
|
+
declare const refundOrder: (http: HttpClient, orderId: string | number, body?: unknown) => Promise<JsonApiResource<OrderAttributes>>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Generate an order invoice (POST /v1/orders/:id/generate-invoice).
|
|
2155
|
+
* Docs: https://docs.lemonsqueezy.com/api/orders/generate-order-invoice
|
|
2156
|
+
*
|
|
2157
|
+
* @param http - Shared API client.
|
|
2158
|
+
* @param orderId - Order id.
|
|
2159
|
+
* @param body - Optional locale/name attributes document.
|
|
2160
|
+
* @returns API response document (invoice URL payload).
|
|
2161
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2162
|
+
*
|
|
2163
|
+
* @example
|
|
2164
|
+
* ```ts
|
|
2165
|
+
* const invoice = await generateOrderInvoice(http, 1);
|
|
2166
|
+
* ```
|
|
2167
|
+
*/
|
|
2168
|
+
declare const generateOrderInvoice: (http: HttpClient, orderId: string | number, body?: unknown) => Promise<unknown>;
|
|
1678
2169
|
|
|
1679
2170
|
/**
|
|
1680
2171
|
* Subset of Lemon Squeezy price attributes. Prices are nested under
|
|
@@ -1711,11 +2202,33 @@ interface PriceAttributes extends GeneratedPriceAttributes {
|
|
|
1711
2202
|
updated_at?: string;
|
|
1712
2203
|
}
|
|
1713
2204
|
/**
|
|
1714
|
-
* Fetch a single price by ID
|
|
1715
|
-
*
|
|
1716
|
-
*
|
|
2205
|
+
* Fetch a single price by ID (read-only — no create/update/delete in LS API).
|
|
2206
|
+
*
|
|
2207
|
+
* @param http - Shared API client.
|
|
2208
|
+
* @param priceId - Price id.
|
|
2209
|
+
* @returns The price resource.
|
|
2210
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2211
|
+
*
|
|
2212
|
+
* @example
|
|
2213
|
+
* ```ts
|
|
2214
|
+
* const price = await getPrice(http, 1);
|
|
2215
|
+
* ```
|
|
1717
2216
|
*/
|
|
1718
|
-
declare
|
|
2217
|
+
declare const getPrice: (http: HttpClient, priceId: string | number) => Promise<JsonApiResource<PriceAttributes>>;
|
|
2218
|
+
/**
|
|
2219
|
+
* List prices for a variant.
|
|
2220
|
+
*
|
|
2221
|
+
* @param http - Shared API client.
|
|
2222
|
+
* @param variantId - Variant filter.
|
|
2223
|
+
* @returns Price resources.
|
|
2224
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2225
|
+
*
|
|
2226
|
+
* @example
|
|
2227
|
+
* ```ts
|
|
2228
|
+
* const prices = await listPricesForVariant(http, 1);
|
|
2229
|
+
* ```
|
|
2230
|
+
*/
|
|
2231
|
+
declare const listPricesForVariant: (http: HttpClient, variantId: string | number) => Promise<JsonApiResource<PriceAttributes>[]>;
|
|
1719
2232
|
|
|
1720
2233
|
/**
|
|
1721
2234
|
* URLs Lemon Squeezy attaches to a subscription so consumers can deep-link
|
|
@@ -1788,11 +2301,66 @@ interface SubscriptionAttributes extends GeneratedSubscriptionAttributes {
|
|
|
1788
2301
|
tax_inclusive?: boolean;
|
|
1789
2302
|
}
|
|
1790
2303
|
/**
|
|
1791
|
-
* Fetch a single subscription by ID.
|
|
1792
|
-
*
|
|
1793
|
-
*
|
|
2304
|
+
* Fetch a single subscription by ID.
|
|
2305
|
+
*
|
|
2306
|
+
* @param http - Shared API client.
|
|
2307
|
+
* @param subscriptionId - Subscription id.
|
|
2308
|
+
* @returns The subscription resource.
|
|
2309
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2310
|
+
*
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```ts
|
|
2313
|
+
* const sub = await getSubscription(http, 1);
|
|
2314
|
+
* ```
|
|
2315
|
+
*/
|
|
2316
|
+
declare const getSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionAttributes>>;
|
|
2317
|
+
/**
|
|
2318
|
+
* List subscriptions for a store.
|
|
2319
|
+
*
|
|
2320
|
+
* @param http - Shared API client.
|
|
2321
|
+
* @param storeId - Store filter.
|
|
2322
|
+
* @returns Subscription resources.
|
|
2323
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2324
|
+
*
|
|
2325
|
+
* @example
|
|
2326
|
+
* ```ts
|
|
2327
|
+
* const subs = await listSubscriptionsForStore(http, 1);
|
|
2328
|
+
* ```
|
|
2329
|
+
*/
|
|
2330
|
+
declare const listSubscriptionsForStore: (http: HttpClient, storeId: string | number) => Promise<JsonApiResource<SubscriptionAttributes>[]>;
|
|
2331
|
+
/**
|
|
2332
|
+
* Update a subscription (PATCH /v1/subscriptions/:id) — plan change, pause, etc.
|
|
2333
|
+
* Docs: https://docs.lemonsqueezy.com/api/subscriptions/update-subscription
|
|
2334
|
+
*
|
|
2335
|
+
* @param http - Shared API client.
|
|
2336
|
+
* @param subscriptionId - Subscription id.
|
|
2337
|
+
* @param body - JSON:API update document.
|
|
2338
|
+
* @returns The updated subscription.
|
|
2339
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2340
|
+
*
|
|
2341
|
+
* @example
|
|
2342
|
+
* ```ts
|
|
2343
|
+
* const sub = await updateSubscription(http, 1, {
|
|
2344
|
+
* data: { type: "subscriptions", id: "1", attributes: { variant_id: 2 } },
|
|
2345
|
+
* });
|
|
2346
|
+
* ```
|
|
2347
|
+
*/
|
|
2348
|
+
declare const updateSubscription: (http: HttpClient, subscriptionId: string | number, body: unknown) => Promise<JsonApiResource<SubscriptionAttributes>>;
|
|
2349
|
+
/**
|
|
2350
|
+
* Cancel a subscription (DELETE /v1/subscriptions/:id).
|
|
2351
|
+
* Docs: https://docs.lemonsqueezy.com/api/subscriptions/cancel-subscription
|
|
2352
|
+
*
|
|
2353
|
+
* @param http - Shared API client.
|
|
2354
|
+
* @param subscriptionId - Subscription id.
|
|
2355
|
+
* @returns The cancelled subscription resource when the API returns one.
|
|
2356
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2357
|
+
*
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```ts
|
|
2360
|
+
* const sub = await cancelSubscription(http, 1);
|
|
2361
|
+
* ```
|
|
1794
2362
|
*/
|
|
1795
|
-
declare
|
|
2363
|
+
declare const cancelSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionAttributes> | undefined>;
|
|
1796
2364
|
|
|
1797
2365
|
type SubscriptionInvoiceStatus = "pending" | "paid" | "void" | "refunded" | "partial_refund";
|
|
1798
2366
|
type SubscriptionInvoiceBillingReason = "initial" | "renewal" | "updated";
|
|
@@ -1839,8 +2407,66 @@ interface SubscriptionInvoiceAttributes extends GeneratedSubscriptionInvoiceAttr
|
|
|
1839
2407
|
updated_at?: string;
|
|
1840
2408
|
test_mode?: boolean;
|
|
1841
2409
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
2410
|
+
/**
|
|
2411
|
+
* Retrieve a subscription invoice.
|
|
2412
|
+
*
|
|
2413
|
+
* @param http - Shared API client.
|
|
2414
|
+
* @param subscriptionInvoiceId - Invoice id.
|
|
2415
|
+
* @returns The invoice resource.
|
|
2416
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2417
|
+
*
|
|
2418
|
+
* @example
|
|
2419
|
+
* ```ts
|
|
2420
|
+
* const invoice = await getSubscriptionInvoice(http, 1);
|
|
2421
|
+
* ```
|
|
2422
|
+
*/
|
|
2423
|
+
declare const getSubscriptionInvoice: (http: HttpClient, subscriptionInvoiceId: string | number) => Promise<JsonApiResource<SubscriptionInvoiceAttributes>>;
|
|
2424
|
+
/**
|
|
2425
|
+
* List invoices for a subscription.
|
|
2426
|
+
*
|
|
2427
|
+
* @param http - Shared API client.
|
|
2428
|
+
* @param subscriptionId - Parent subscription id.
|
|
2429
|
+
* @returns Invoice resources.
|
|
2430
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2431
|
+
*
|
|
2432
|
+
* @example
|
|
2433
|
+
* ```ts
|
|
2434
|
+
* const invoices = await listSubscriptionInvoicesForSubscription(http, 1);
|
|
2435
|
+
* ```
|
|
2436
|
+
*/
|
|
2437
|
+
declare const listSubscriptionInvoicesForSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionInvoiceAttributes>[]>;
|
|
2438
|
+
/**
|
|
2439
|
+
* Refund a subscription invoice (POST /v1/subscription-invoices/:id/refund).
|
|
2440
|
+
* Docs: https://docs.lemonsqueezy.com/api/subscription-invoices/issue-refund
|
|
2441
|
+
*
|
|
2442
|
+
* @param http - Shared API client.
|
|
2443
|
+
* @param subscriptionInvoiceId - Invoice id.
|
|
2444
|
+
* @param body - Optional partial-refund document.
|
|
2445
|
+
* @returns The updated invoice.
|
|
2446
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2447
|
+
*
|
|
2448
|
+
* @example
|
|
2449
|
+
* ```ts
|
|
2450
|
+
* const invoice = await refundSubscriptionInvoice(http, 1);
|
|
2451
|
+
* ```
|
|
2452
|
+
*/
|
|
2453
|
+
declare const refundSubscriptionInvoice: (http: HttpClient, subscriptionInvoiceId: string | number, body?: unknown) => Promise<JsonApiResource<SubscriptionInvoiceAttributes>>;
|
|
2454
|
+
/**
|
|
2455
|
+
* Generate a subscription invoice PDF/URL.
|
|
2456
|
+
* Docs: https://docs.lemonsqueezy.com/api/subscription-invoices/generate-subscription-invoice
|
|
2457
|
+
*
|
|
2458
|
+
* @param http - Shared API client.
|
|
2459
|
+
* @param subscriptionInvoiceId - Invoice id.
|
|
2460
|
+
* @param body - Optional generation attributes.
|
|
2461
|
+
* @returns API response document.
|
|
2462
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2463
|
+
*
|
|
2464
|
+
* @example
|
|
2465
|
+
* ```ts
|
|
2466
|
+
* const doc = await generateSubscriptionInvoice(http, 1);
|
|
2467
|
+
* ```
|
|
2468
|
+
*/
|
|
2469
|
+
declare const generateSubscriptionInvoice: (http: HttpClient, subscriptionInvoiceId: string | number, body?: unknown) => Promise<unknown>;
|
|
1844
2470
|
|
|
1845
2471
|
interface SubscriptionItemAttributes extends GeneratedSubscriptionItemAttributes {
|
|
1846
2472
|
subscription_id: number;
|
|
@@ -1859,9 +2485,83 @@ interface SubscriptionItemUpdateAttributes {
|
|
|
1859
2485
|
invoice_immediately?: boolean;
|
|
1860
2486
|
disable_prorations?: boolean;
|
|
1861
2487
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
2488
|
+
/**
|
|
2489
|
+
* Retrieve a subscription item.
|
|
2490
|
+
*
|
|
2491
|
+
* @param http - Shared API client.
|
|
2492
|
+
* @param subscriptionItemId - Item id.
|
|
2493
|
+
* @returns The subscription item resource.
|
|
2494
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2495
|
+
*
|
|
2496
|
+
* @example
|
|
2497
|
+
* ```ts
|
|
2498
|
+
* const item = await getSubscriptionItem(http, 1);
|
|
2499
|
+
* ```
|
|
2500
|
+
*/
|
|
2501
|
+
declare const getSubscriptionItem: (http: HttpClient, subscriptionItemId: string | number) => Promise<JsonApiResource<SubscriptionItemAttributes>>;
|
|
2502
|
+
/**
|
|
2503
|
+
* List subscription items for a subscription.
|
|
2504
|
+
*
|
|
2505
|
+
* @param http - Shared API client.
|
|
2506
|
+
* @param subscriptionId - Parent subscription id.
|
|
2507
|
+
* @returns Subscription item resources.
|
|
2508
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2509
|
+
*
|
|
2510
|
+
* @example
|
|
2511
|
+
* ```ts
|
|
2512
|
+
* const items = await listSubscriptionItemsForSubscription(http, 1);
|
|
2513
|
+
* ```
|
|
2514
|
+
*/
|
|
2515
|
+
declare const listSubscriptionItemsForSubscription: (http: HttpClient, subscriptionId: string | number) => Promise<JsonApiResource<SubscriptionItemAttributes>[]>;
|
|
2516
|
+
/**
|
|
2517
|
+
* Build a JSON:API update body for a subscription item (quantity / proration).
|
|
2518
|
+
*
|
|
2519
|
+
* @param subscriptionItemId - Item id embedded in the document.
|
|
2520
|
+
* @param attributes - Fields accepted by the update endpoint.
|
|
2521
|
+
* @returns A single JSON:API document (not multiple loose objects).
|
|
2522
|
+
*
|
|
2523
|
+
* @example
|
|
2524
|
+
* ```ts
|
|
2525
|
+
* const body = buildSubscriptionItemUpdateBody(1, { quantity: 3 });
|
|
2526
|
+
* await updateSubscriptionItem(http, 1, body);
|
|
2527
|
+
* ```
|
|
2528
|
+
*/
|
|
2529
|
+
declare const buildSubscriptionItemUpdateBody: (subscriptionItemId: string | number, attributes: SubscriptionItemUpdateAttributes) => unknown;
|
|
2530
|
+
/**
|
|
2531
|
+
* Update a subscription item (PATCH /v1/subscription-items/:id).
|
|
2532
|
+
* Docs: https://docs.lemonsqueezy.com/api/subscription-items/update-subscription-item
|
|
2533
|
+
*
|
|
2534
|
+
* @param http - Shared API client.
|
|
2535
|
+
* @param subscriptionItemId - Item id.
|
|
2536
|
+
* @param body - JSON:API update document.
|
|
2537
|
+
* @returns The updated subscription item.
|
|
2538
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2539
|
+
*
|
|
2540
|
+
* @example
|
|
2541
|
+
* ```ts
|
|
2542
|
+
* const item = await updateSubscriptionItem(
|
|
2543
|
+
* http,
|
|
2544
|
+
* 1,
|
|
2545
|
+
* buildSubscriptionItemUpdateBody(1, { quantity: 2 }),
|
|
2546
|
+
* );
|
|
2547
|
+
* ```
|
|
2548
|
+
*/
|
|
2549
|
+
declare const updateSubscriptionItem: (http: HttpClient, subscriptionItemId: string | number, body: unknown) => Promise<JsonApiResource<SubscriptionItemAttributes>>;
|
|
2550
|
+
/**
|
|
2551
|
+
* Current-period usage for a usage-based subscription item.
|
|
2552
|
+
* Docs: https://docs.lemonsqueezy.com/api/subscription-items/retrieve-subscription-item-current-usage
|
|
2553
|
+
*
|
|
2554
|
+
* @param http - Shared API client.
|
|
2555
|
+
* @param subscriptionItemId - Item id.
|
|
2556
|
+
* @returns Usage payload for the current billing period.
|
|
2557
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2558
|
+
*
|
|
2559
|
+
* @example
|
|
2560
|
+
* ```ts
|
|
2561
|
+
* const usage = await getSubscriptionItemCurrentUsage(http, 1);
|
|
2562
|
+
* ```
|
|
2563
|
+
*/
|
|
2564
|
+
declare const getSubscriptionItemCurrentUsage: (http: HttpClient, subscriptionItemId: string | number) => Promise<unknown>;
|
|
1865
2565
|
|
|
1866
2566
|
type UsageRecordAction = "increment" | "set";
|
|
1867
2567
|
interface UsageRecordAttributes extends GeneratedUsageRecordAttributes {
|
|
@@ -1871,8 +2571,136 @@ interface UsageRecordAttributes extends GeneratedUsageRecordAttributes {
|
|
|
1871
2571
|
created_at?: string;
|
|
1872
2572
|
updated_at?: string;
|
|
1873
2573
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
2574
|
+
/**
|
|
2575
|
+
* Retrieve a usage record.
|
|
2576
|
+
*
|
|
2577
|
+
* @param http - Shared API client.
|
|
2578
|
+
* @param usageRecordId - Usage record id.
|
|
2579
|
+
* @returns The usage record resource.
|
|
2580
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2581
|
+
*
|
|
2582
|
+
* @example
|
|
2583
|
+
* ```ts
|
|
2584
|
+
* const record = await getUsageRecord(http, 1);
|
|
2585
|
+
* ```
|
|
2586
|
+
*/
|
|
2587
|
+
declare const getUsageRecord: (http: HttpClient, usageRecordId: string | number) => Promise<JsonApiResource<UsageRecordAttributes>>;
|
|
2588
|
+
/**
|
|
2589
|
+
* List usage records for a subscription item.
|
|
2590
|
+
*
|
|
2591
|
+
* @param http - Shared API client.
|
|
2592
|
+
* @param subscriptionItemId - Parent subscription item id.
|
|
2593
|
+
* @returns Usage record resources.
|
|
2594
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2595
|
+
*
|
|
2596
|
+
* @example
|
|
2597
|
+
* ```ts
|
|
2598
|
+
* const records = await listUsageRecordsForSubscriptionItem(http, 1);
|
|
2599
|
+
* ```
|
|
2600
|
+
*/
|
|
2601
|
+
declare const listUsageRecordsForSubscriptionItem: (http: HttpClient, subscriptionItemId: string | number) => Promise<JsonApiResource<UsageRecordAttributes>[]>;
|
|
2602
|
+
/**
|
|
2603
|
+
* Create a usage record (POST /v1/usage-records).
|
|
2604
|
+
* Docs: https://docs.lemonsqueezy.com/api/usage-records/create-usage-record
|
|
2605
|
+
*
|
|
2606
|
+
* @param http - Shared API client.
|
|
2607
|
+
* @param body - JSON:API create document.
|
|
2608
|
+
* @returns The created usage record.
|
|
2609
|
+
* @throws {FreshSqueezyError} On HTTP/network failure.
|
|
2610
|
+
*
|
|
2611
|
+
* @example
|
|
2612
|
+
* ```ts
|
|
2613
|
+
* const record = await createUsageRecord(http, {
|
|
2614
|
+
* data: {
|
|
2615
|
+
* type: "usage-records",
|
|
2616
|
+
* attributes: { quantity: 5, action: "increment" },
|
|
2617
|
+
* relationships: {
|
|
2618
|
+
* "subscription-item": { data: { type: "subscription-items", id: "1" } },
|
|
2619
|
+
* },
|
|
2620
|
+
* },
|
|
2621
|
+
* });
|
|
2622
|
+
* ```
|
|
2623
|
+
*/
|
|
2624
|
+
declare const createUsageRecord: (http: HttpClient, body: unknown) => Promise<JsonApiResource<UsageRecordAttributes>>;
|
|
2625
|
+
|
|
2626
|
+
/**
|
|
2627
|
+
* Docs-backed ops matrix for Lemon Squeezy.
|
|
2628
|
+
*
|
|
2629
|
+
* Only verbs that exist at https://docs.lemonsqueezy.com/api are listed.
|
|
2630
|
+
* Catalog resources (products, variants, prices, files, stores, …) are
|
|
2631
|
+
* read-only. CI changelog scrape may propose gaps; this registry is what ships.
|
|
2632
|
+
*/
|
|
2633
|
+
/** CLI / client verb tokens, including non-CRUD LS actions. */
|
|
2634
|
+
type OpVerb = "get" | "list" | "create" | "update" | "delete" | "cancel" | "refund" | "generate-invoice" | "current-usage";
|
|
2635
|
+
/**
|
|
2636
|
+
* One implemented, documented operation.
|
|
2637
|
+
*
|
|
2638
|
+
* @remarks `docsPath` is the path under `/api/` on the LS docs site.
|
|
2639
|
+
*/
|
|
2640
|
+
interface ResourceVerbSpec {
|
|
2641
|
+
/** CLI resource token (singular), e.g. `webhook`. */
|
|
2642
|
+
resource: string;
|
|
2643
|
+
verb: OpVerb;
|
|
2644
|
+
/** Docs path fragment, e.g. `webhooks/create-webhook`. */
|
|
2645
|
+
docsPath: string;
|
|
2646
|
+
/** Requires --yes or TTY confirm always (delete/cancel/refund). */
|
|
2647
|
+
destructive?: boolean;
|
|
2648
|
+
body?: "required" | "optional" | "none";
|
|
2649
|
+
/**
|
|
2650
|
+
* How list/get resolve the primary id filter.
|
|
2651
|
+
* - `id` — --id
|
|
2652
|
+
* - `store` — --store-ids (first) or store filter
|
|
2653
|
+
* - `parent` — --parent-id (subscription, order, product, …)
|
|
2654
|
+
*/
|
|
2655
|
+
idRole?: "id" | "store" | "parent" | "none";
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Implemented ops. Keep in sync with exports in `src/resources/*` and the
|
|
2659
|
+
* CLI dispatcher. Do not register fantasy endpoints (e.g. product create).
|
|
2660
|
+
*/
|
|
2661
|
+
declare const resourceRegistry: readonly ResourceVerbSpec[];
|
|
2662
|
+
/**
|
|
2663
|
+
* Look up a registry entry.
|
|
2664
|
+
*
|
|
2665
|
+
* @param resource - CLI resource token.
|
|
2666
|
+
* @param verb - Op verb.
|
|
2667
|
+
* @returns The spec, or undefined when not implemented / not in LS API.
|
|
2668
|
+
*/
|
|
2669
|
+
declare const findResourceVerb: (resource: string, verb: string) => ResourceVerbSpec | undefined;
|
|
2670
|
+
/**
|
|
2671
|
+
* Unique resource names that have at least one verb.
|
|
2672
|
+
*
|
|
2673
|
+
* @returns Sorted resource tokens for help text / menus.
|
|
2674
|
+
*/
|
|
2675
|
+
declare const listRegisteredResources: () => string[];
|
|
2676
|
+
|
|
2677
|
+
/**
|
|
2678
|
+
* Arguments for a single resource op invocation.
|
|
2679
|
+
*
|
|
2680
|
+
* One named input type — not a bag of unrelated returns.
|
|
2681
|
+
*/
|
|
2682
|
+
interface InvokeOpArgs {
|
|
2683
|
+
id?: string | number;
|
|
2684
|
+
storeId?: string | number;
|
|
2685
|
+
parentId?: string | number;
|
|
2686
|
+
body?: unknown;
|
|
2687
|
+
}
|
|
2688
|
+
/**
|
|
2689
|
+
* Dispatch a docs-backed resource verb through the thin resource helpers.
|
|
2690
|
+
*
|
|
2691
|
+
* @param http - Shared API client.
|
|
2692
|
+
* @param resource - CLI resource token (`webhook`, `product`, …).
|
|
2693
|
+
* @param verb - Op verb (`get`, `create`, `refund`, …).
|
|
2694
|
+
* @param args - Ids / body for the call.
|
|
2695
|
+
* @returns A single JSON:API resource, list, void, or action payload.
|
|
2696
|
+
* @throws {FreshSqueezyError} When the verb is unknown or HTTP fails.
|
|
2697
|
+
*
|
|
2698
|
+
* @example
|
|
2699
|
+
* ```ts
|
|
2700
|
+
* const product = await invokeOp(http, "product", "get", { id: 42 });
|
|
2701
|
+
* ```
|
|
2702
|
+
*/
|
|
2703
|
+
declare const invokeOp: (http: HttpClient, resource: string, verb: OpVerb | string, args?: InvokeOpArgs) => Promise<unknown>;
|
|
1876
2704
|
|
|
1877
2705
|
/**
|
|
1878
2706
|
* Support manifest: the locally reviewed source of truth for what
|
|
@@ -2015,4 +2843,4 @@ declare const ACKNOWLEDGED_CHANGELOG_ENTRIES: readonly [{
|
|
|
2015
2843
|
type RecommendedEvent = (typeof RECOMMENDED_WEBHOOK_EVENTS)[number];
|
|
2016
2844
|
type OptionalEvent = (typeof OPTIONAL_WEBHOOK_EVENTS)[number];
|
|
2017
2845
|
|
|
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 };
|
|
2846
|
+
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, listStores, listSubscriptionInvoicesForSubscription, listSubscriptionItemsForSubscription, listSubscriptionsForStore, listUsageRecordsForSubscriptionItem, listVariantsForProduct, listWebhooksForStore, refundOrder, refundSubscriptionInvoice, resolveActualMode, resolveConfig, resourceRegistry, sameWebhookUrl, updateCustomer, updateLicenseKey, updateSubscription, updateSubscriptionItem, updateWebhook, userResource, validateConnection, validateDiscount, validateLicenseKey, validateProduct, validateStore, validateSubscriptionPlan, validateWebhook };
|