fresh-squeezy 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -92,597 +92,95 @@ var normalizeMode = (value) => {
92
92
  });
93
93
  };
94
94
 
95
- // src/core/equality.ts
96
- var sameWebhookUrl = (a, b) => {
97
- return normalizeWebhookUrl(a) === normalizeWebhookUrl(b);
98
- };
99
- var normalizeWebhookUrl = (raw) => {
100
- return raw.replace(/\/+$/, "").toLowerCase();
101
- };
102
-
103
- // src/core/mode.ts
104
- var resolveActualMode = (testMode) => {
105
- if (testMode === true) return "test";
106
- if (testMode === false) return "live";
107
- return void 0;
108
- };
109
-
110
- // src/resources/affiliates.ts
111
- var getAffiliate = async (http, affiliateId) => {
112
- return http.getResource(`/v1/affiliates/${affiliateId}`);
113
- };
114
- var listAffiliatesForStore = async (http, storeId) => {
115
- return http.paginate("/v1/affiliates", {
116
- "filter[store_id]": String(storeId)
117
- });
118
- };
119
-
120
- // src/resources/checkouts.ts
121
- var getCheckout = async (http, checkoutId) => {
122
- return http.getResource(`/v1/checkouts/${checkoutId}`);
123
- };
124
- var listCheckoutsForStore = async (http, storeId) => {
125
- return http.paginate("/v1/checkouts", {
126
- "filter[store_id]": String(storeId)
127
- });
128
- };
129
- var createCheckout = async (http, body) => {
130
- return http.postResource("/v1/checkouts", body);
131
- };
132
-
133
- // src/resources/customers.ts
134
- var getCustomer = async (http, customerId) => {
135
- return http.getResource(`/v1/customers/${customerId}`);
136
- };
137
- var listCustomersForStore = async (http, storeId) => {
138
- return http.paginate("/v1/customers", {
139
- "filter[store_id]": String(storeId)
140
- });
141
- };
142
- var createCustomer = async (http, body) => {
143
- return http.postResource("/v1/customers", body);
144
- };
145
- var updateCustomer = async (http, customerId, body) => {
146
- return http.patchResource(`/v1/customers/${customerId}`, body);
147
- };
148
-
149
- // src/resources/discountRedemptions.ts
150
- var getDiscountRedemption = async (http, discountRedemptionId) => {
151
- return http.getResource(
152
- `/v1/discount-redemptions/${discountRedemptionId}`
153
- );
154
- };
155
- var listDiscountRedemptionsForDiscount = async (http, discountId) => {
156
- return http.paginate("/v1/discount-redemptions", {
157
- "filter[discount_id]": String(discountId)
158
- });
159
- };
160
-
161
- // src/resources/discounts.ts
162
- var getDiscount = async (http, discountId) => {
163
- return http.getResource(`/v1/discounts/${discountId}`);
164
- };
165
- var listDiscountsForStore = async (http, storeId) => {
166
- return http.paginate("/v1/discounts", {
167
- "filter[store_id]": String(storeId)
168
- });
169
- };
170
- var createDiscount = async (http, body) => {
171
- return http.postResource("/v1/discounts", body);
172
- };
173
- var deleteDiscount = async (http, discountId) => {
174
- await http.deleteResource(`/v1/discounts/${discountId}`);
175
- };
176
-
177
- // src/resources/files.ts
178
- var getFile = async (http, fileId) => {
179
- return http.getResource(`/v1/files/${fileId}`);
180
- };
181
- var listFilesForVariant = async (http, variantId) => {
182
- return http.paginate("/v1/files", {
183
- "filter[variant_id]": String(variantId)
184
- });
185
- };
186
-
187
- // src/resources/licenseKeyInstances.ts
188
- var getLicenseKeyInstance = async (http, licenseKeyInstanceId) => {
189
- return http.getResource(
190
- `/v1/license-key-instances/${licenseKeyInstanceId}`
191
- );
192
- };
193
- var listLicenseKeyInstancesForLicenseKey = async (http, licenseKeyId) => {
194
- return http.paginate("/v1/license-key-instances", {
195
- "filter[license_key_id]": String(licenseKeyId)
196
- });
197
- };
198
-
199
- // src/resources/licenseKeys.ts
200
- var getLicenseKey = async (http, licenseKeyId) => {
201
- return http.getResource(`/v1/license-keys/${licenseKeyId}`);
202
- };
203
- var listLicenseKeysForStore = async (http, storeId) => {
204
- return http.paginate("/v1/license-keys", {
205
- "filter[store_id]": String(storeId)
206
- });
207
- };
208
- var updateLicenseKey = async (http, licenseKeyId, body) => {
209
- return http.patchResource(`/v1/license-keys/${licenseKeyId}`, body);
210
- };
211
-
212
- // src/resources/orderItems.ts
213
- var getOrderItem = async (http, orderItemId) => {
214
- return http.getResource(`/v1/order-items/${orderItemId}`);
215
- };
216
- var listOrderItemsForOrder = async (http, orderId) => {
217
- return http.paginate("/v1/order-items", {
218
- "filter[order_id]": String(orderId)
219
- });
220
- };
221
-
222
- // src/resources/orders.ts
223
- var getOrder = async (http, orderId) => {
224
- return http.getResource(`/v1/orders/${orderId}`);
225
- };
226
- var listOrdersForStore = async (http, storeId) => {
227
- return http.paginate("/v1/orders", {
228
- "filter[store_id]": String(storeId)
229
- });
230
- };
231
- var refundOrder = async (http, orderId, body) => {
232
- return http.postResource(`/v1/orders/${orderId}/refund`, body ?? {});
233
- };
234
- var generateOrderInvoice = async (http, orderId, body) => {
235
- return http.request({
236
- method: "POST",
237
- path: `/v1/orders/${orderId}/generate-invoice`,
238
- body: body ?? {}
239
- });
240
- };
241
-
242
- // src/resources/prices.ts
243
- var getPrice = async (http, priceId) => {
244
- return http.getResource(`/v1/prices/${priceId}`);
245
- };
246
- var listPricesForVariant = async (http, variantId) => {
247
- return http.paginate("/v1/prices", {
248
- "filter[variant_id]": String(variantId)
249
- });
250
- };
251
-
252
- // src/resources/products.ts
253
- var getProduct = async (http, productId) => {
254
- return http.getResource(`/v1/products/${productId}`);
255
- };
256
- var listProducts = async (http, storeId) => {
257
- return http.paginate("/v1/products", {
258
- "filter[store_id]": String(storeId)
259
- });
95
+ // src/resources/attributes.ts
96
+ var buildSubscriptionItemUpdateBody = (subscriptionItemId, attributes) => {
97
+ return {
98
+ data: {
99
+ type: "subscription-items",
100
+ id: String(subscriptionItemId),
101
+ attributes
102
+ }
103
+ };
260
104
  };
261
105
 
262
106
  // src/resources/registry.ts
263
- var resourceRegistry = [
264
- // users
265
- { resource: "user", verb: "get", docsPath: "users/retrieve-user", body: "none", idRole: "none" },
266
- // stores (read-only)
267
- { resource: "store", verb: "get", docsPath: "stores/retrieve-store", body: "none", idRole: "id" },
268
- {
269
- resource: "store",
270
- verb: "list",
271
- docsPath: "stores/list-all-stores",
272
- body: "none",
273
- idRole: "none"
274
- },
275
- // products (read-only)
276
- {
277
- resource: "product",
278
- verb: "get",
279
- docsPath: "products/retrieve-product",
280
- body: "none",
281
- idRole: "id"
282
- },
283
- {
284
- resource: "product",
285
- verb: "list",
286
- docsPath: "products/list-all-products",
287
- body: "none",
288
- idRole: "store"
289
- },
290
- // variants (read-only)
291
- {
292
- resource: "variant",
293
- verb: "get",
294
- docsPath: "variants/retrieve-variant",
295
- body: "none",
296
- idRole: "id"
297
- },
298
- {
299
- resource: "variant",
300
- verb: "list",
301
- docsPath: "variants/list-all-variants",
302
- body: "none",
303
- idRole: "parent"
304
- },
305
- // prices (read-only)
306
- { resource: "price", verb: "get", docsPath: "prices/retrieve-price", body: "none", idRole: "id" },
307
- {
308
- resource: "price",
309
- verb: "list",
310
- docsPath: "prices/list-all-prices",
311
- body: "none",
312
- idRole: "parent"
313
- },
314
- // files (read-only)
315
- { resource: "file", verb: "get", docsPath: "files/retrieve-file", body: "none", idRole: "id" },
316
- {
317
- resource: "file",
318
- verb: "list",
319
- docsPath: "files/list-all-files",
320
- body: "none",
321
- idRole: "parent"
322
- },
323
- // customers
324
- {
325
- resource: "customer",
326
- verb: "get",
327
- docsPath: "customers/retrieve-customer",
328
- body: "none",
329
- idRole: "id"
330
- },
331
- {
332
- resource: "customer",
333
- verb: "list",
334
- docsPath: "customers/list-all-customers",
335
- body: "none",
336
- idRole: "store"
337
- },
338
- {
339
- resource: "customer",
340
- verb: "create",
341
- docsPath: "customers/create-customer",
342
- body: "required",
343
- idRole: "none"
344
- },
345
- {
346
- resource: "customer",
347
- verb: "update",
348
- docsPath: "customers/update-customer",
349
- body: "required",
350
- idRole: "id"
351
- },
352
- // orders
353
- { resource: "order", verb: "get", docsPath: "orders/retrieve-order", body: "none", idRole: "id" },
354
- {
355
- resource: "order",
356
- verb: "list",
357
- docsPath: "orders/list-all-orders",
358
- body: "none",
359
- idRole: "store"
360
- },
361
- {
362
- resource: "order",
363
- verb: "refund",
364
- docsPath: "orders/issue-refund",
365
- body: "optional",
366
- destructive: true,
367
- idRole: "id"
368
- },
369
- {
370
- resource: "order",
371
- verb: "generate-invoice",
372
- docsPath: "orders/generate-order-invoice",
373
- body: "optional",
374
- idRole: "id"
375
- },
376
- // order-items (read-only)
377
- {
378
- resource: "order-item",
379
- verb: "get",
380
- docsPath: "order-items/retrieve-order-item",
381
- body: "none",
382
- idRole: "id"
383
- },
384
- {
385
- resource: "order-item",
386
- verb: "list",
387
- docsPath: "order-items/list-all-order-items",
388
- body: "none",
389
- idRole: "parent"
390
- },
391
- // subscriptions
392
- {
393
- resource: "subscription",
394
- verb: "get",
395
- docsPath: "subscriptions/retrieve-subscription",
396
- body: "none",
397
- idRole: "id"
398
- },
399
- {
400
- resource: "subscription",
401
- verb: "list",
402
- docsPath: "subscriptions/list-all-subscriptions",
403
- body: "none",
404
- idRole: "store"
405
- },
406
- {
407
- resource: "subscription",
408
- verb: "update",
409
- docsPath: "subscriptions/update-subscription",
410
- body: "required",
411
- idRole: "id"
412
- },
413
- {
414
- resource: "subscription",
415
- verb: "cancel",
416
- docsPath: "subscriptions/cancel-subscription",
417
- body: "none",
418
- destructive: true,
419
- idRole: "id"
420
- },
421
- // subscription-items
422
- {
423
- resource: "subscription-item",
424
- verb: "get",
425
- docsPath: "subscription-items/retrieve-subscription-item",
426
- body: "none",
427
- idRole: "id"
428
- },
429
- {
430
- resource: "subscription-item",
431
- verb: "list",
432
- docsPath: "subscription-items/list-all-subscription-items",
433
- body: "none",
434
- idRole: "parent"
435
- },
436
- {
437
- resource: "subscription-item",
438
- verb: "update",
439
- docsPath: "subscription-items/update-subscription-item",
440
- body: "required",
441
- idRole: "id"
442
- },
443
- {
444
- resource: "subscription-item",
445
- verb: "current-usage",
446
- docsPath: "subscription-items/retrieve-subscription-item-current-usage",
447
- body: "none",
448
- idRole: "id"
449
- },
450
- // subscription-invoices
451
- {
452
- resource: "subscription-invoice",
453
- verb: "get",
454
- docsPath: "subscription-invoices/retrieve-subscription-invoice",
455
- body: "none",
456
- idRole: "id"
457
- },
458
- {
459
- resource: "subscription-invoice",
460
- verb: "list",
461
- docsPath: "subscription-invoices/list-all-subscription-invoices",
462
- body: "none",
463
- idRole: "parent"
464
- },
465
- {
466
- resource: "subscription-invoice",
467
- verb: "refund",
468
- docsPath: "subscription-invoices/issue-refund",
469
- body: "optional",
470
- destructive: true,
471
- idRole: "id"
472
- },
473
- {
474
- resource: "subscription-invoice",
475
- verb: "generate-invoice",
476
- docsPath: "subscription-invoices/generate-subscription-invoice",
107
+ var VERB_RULES = {
108
+ get: { method: "GET", path: "/{id}", docs: "retrieve-{r}", body: "none" },
109
+ list: { method: "GET", path: "", docs: "list-all-{r}s", body: "none" },
110
+ create: { method: "POST", path: "", docs: "create-{r}", body: "required" },
111
+ update: { method: "PATCH", path: "/{id}", docs: "update-{r}", body: "required" },
112
+ delete: { method: "DELETE", path: "/{id}", docs: "delete-{r}", body: "none", destructive: true },
113
+ cancel: { method: "DELETE", path: "/{id}", docs: "cancel-{r}", body: "none", destructive: true },
114
+ refund: {
115
+ method: "POST",
116
+ path: "/{id}/refund",
117
+ docs: "issue-refund",
477
118
  body: "optional",
478
- idRole: "id"
479
- },
480
- // usage-records
481
- {
482
- resource: "usage-record",
483
- verb: "get",
484
- docsPath: "usage-records/retrieve-usage-record",
485
- body: "none",
486
- idRole: "id"
487
- },
488
- {
489
- resource: "usage-record",
490
- verb: "list",
491
- docsPath: "usage-records/list-all-usage-records",
492
- body: "none",
493
- idRole: "parent"
494
- },
495
- {
496
- resource: "usage-record",
497
- verb: "create",
498
- docsPath: "usage-records/create-usage-record",
499
- body: "required",
500
- idRole: "none"
501
- },
502
- // discounts
503
- {
504
- resource: "discount",
505
- verb: "get",
506
- docsPath: "discounts/retrieve-discount",
507
- body: "none",
508
- idRole: "id"
509
- },
510
- {
511
- resource: "discount",
512
- verb: "list",
513
- docsPath: "discounts/list-all-discounts",
514
- body: "none",
515
- idRole: "store"
516
- },
517
- {
518
- resource: "discount",
519
- verb: "create",
520
- docsPath: "discounts/create-discount",
521
- body: "required",
522
- idRole: "none"
523
- },
524
- {
525
- resource: "discount",
526
- verb: "delete",
527
- docsPath: "discounts/delete-discount",
528
- body: "none",
529
- destructive: true,
530
- idRole: "id"
531
- },
532
- // discount-redemptions (read-only)
533
- {
534
- resource: "discount-redemption",
535
- verb: "get",
536
- docsPath: "discount-redemptions/retrieve-discount-redemption",
537
- body: "none",
538
- idRole: "id"
539
- },
540
- {
541
- resource: "discount-redemption",
542
- verb: "list",
543
- docsPath: "discount-redemptions/list-all-discount-redemptions",
544
- body: "none",
545
- idRole: "parent"
546
- },
547
- // license-keys
548
- {
549
- resource: "license-key",
550
- verb: "get",
551
- docsPath: "license-keys/retrieve-license-key",
552
- body: "none",
553
- idRole: "id"
554
- },
555
- {
556
- resource: "license-key",
557
- verb: "list",
558
- docsPath: "license-keys/list-all-license-keys",
559
- body: "none",
560
- idRole: "store"
561
- },
562
- {
563
- resource: "license-key",
564
- verb: "update",
565
- docsPath: "license-keys/update-license-key",
566
- body: "required",
567
- idRole: "id"
568
- },
569
- // license-key-instances (read-only)
570
- {
571
- resource: "license-key-instance",
572
- verb: "get",
573
- docsPath: "license-key-instances/retrieve-license-key-instance",
574
- body: "none",
575
- idRole: "id"
576
- },
577
- {
578
- resource: "license-key-instance",
579
- verb: "list",
580
- docsPath: "license-key-instances/list-all-license-key-instances",
581
- body: "none",
582
- idRole: "parent"
583
- },
584
- // checkouts
585
- {
586
- resource: "checkout",
587
- verb: "get",
588
- docsPath: "checkouts/retrieve-checkout",
589
- body: "none",
590
- idRole: "id"
119
+ destructive: true
591
120
  },
592
- {
593
- resource: "checkout",
594
- verb: "list",
595
- docsPath: "checkouts/list-all-checkouts",
596
- body: "none",
597
- idRole: "store"
598
- },
599
- {
600
- resource: "checkout",
601
- verb: "create",
602
- docsPath: "checkouts/create-checkout",
603
- body: "required",
604
- idRole: "none"
605
- },
606
- // webhooks
607
- {
608
- resource: "webhook",
609
- verb: "get",
610
- docsPath: "webhooks/retrieve-webhook",
611
- body: "none",
612
- idRole: "id"
613
- },
614
- {
615
- resource: "webhook",
616
- verb: "list",
617
- docsPath: "webhooks/list-all-webhooks",
618
- body: "none",
619
- idRole: "store"
620
- },
621
- {
622
- resource: "webhook",
623
- verb: "create",
624
- docsPath: "webhooks/create-webhook",
625
- body: "required",
626
- idRole: "none"
627
- },
628
- {
629
- resource: "webhook",
630
- verb: "update",
631
- docsPath: "webhooks/update-webhook",
632
- body: "required",
633
- idRole: "id"
634
- },
635
- {
636
- resource: "webhook",
637
- verb: "delete",
638
- docsPath: "webhooks/delete-webhook",
639
- body: "none",
640
- destructive: true,
641
- idRole: "id"
642
- },
643
- // affiliates (read-only)
644
- {
645
- resource: "affiliate",
646
- verb: "get",
647
- docsPath: "affiliates/retrieve-affiliate",
648
- body: "none",
649
- idRole: "id"
650
- },
651
- {
652
- resource: "affiliate",
653
- verb: "list",
654
- docsPath: "affiliates/list-all-affiliates",
655
- body: "none",
656
- idRole: "store"
121
+ "generate-invoice": {
122
+ method: "POST",
123
+ path: "/{id}/generate-invoice",
124
+ docs: "generate-{r}-invoice",
125
+ body: "optional"
126
+ },
127
+ "current-usage": {
128
+ method: "GET",
129
+ path: "/{id}/current-usage",
130
+ docs: "retrieve-{r}-current-usage",
131
+ body: "none"
657
132
  }
133
+ };
134
+ var RESOURCES = [
135
+ ["user", ["get"]],
136
+ ["store", ["get", "list"]],
137
+ ["product", ["get", "list"], "store"],
138
+ ["variant", ["get", "list"], "product"],
139
+ ["price", ["get", "list"], "variant"],
140
+ ["file", ["get", "list"], "variant"],
141
+ ["customer", ["get", "list", "create", "update"], "store"],
142
+ ["order", ["get", "list", "refund", "generate-invoice"], "store"],
143
+ ["order-item", ["get", "list"], "order"],
144
+ ["subscription", ["get", "list", "update", "cancel"], "store"],
145
+ ["subscription-item", ["get", "list", "update", "current-usage"], "subscription"],
146
+ ["subscription-invoice", ["get", "list", "refund", "generate-invoice"], "subscription"],
147
+ ["usage-record", ["get", "list", "create"], "subscription-item"],
148
+ ["discount", ["get", "list", "create", "delete"], "store"],
149
+ ["discount-redemption", ["get", "list"], "discount"],
150
+ ["license-key", ["get", "list", "update"], "store"],
151
+ ["license-key-instance", ["get", "list"], "license-key"],
152
+ ["checkout", ["get", "list", "create"], "store"],
153
+ ["webhook", ["get", "list", "create", "update", "delete"], "store"],
154
+ ["affiliate", ["get", "list"], "store"]
658
155
  ];
659
- var RESOURCE_ALIASES = {
660
- products: "product",
661
- stores: "store",
662
- customers: "customer",
663
- orders: "order",
664
- "order-items": "order-item",
665
- subscriptions: "subscription",
666
- "subscription-items": "subscription-item",
667
- "subscription-invoices": "subscription-invoice",
668
- "usage-records": "usage-record",
669
- discounts: "discount",
670
- "discount-redemptions": "discount-redemption",
671
- "license-keys": "license-key",
672
- "license-key-instances": "license-key-instance",
673
- checkouts: "checkout",
674
- webhooks: "webhook",
675
- affiliates: "affiliate",
676
- variants: "variant",
677
- prices: "price",
678
- files: "file",
679
- users: "user"
156
+ var DOCS_PATH_EXCEPTIONS = {
157
+ "subscription-invoice:generate-invoice": "subscription-invoices/generate-subscription-invoice"
158
+ };
159
+ var USER_ME_PATH = "/v1/users/me";
160
+ var listIdRole = (listScope) => {
161
+ if (!listScope) return "none";
162
+ return listScope === "store" ? "store" : "parent";
163
+ };
164
+ var toSpec = (resource, verb, listScope) => {
165
+ const rule = VERB_RULES[verb];
166
+ const docsPath = DOCS_PATH_EXCEPTIONS[`${resource}:${verb}`] ?? `${resource}s/${rule.docs.replaceAll("{r}", resource)}`;
167
+ let idRole = rule.path.includes("{id}") ? "id" : "none";
168
+ if (verb === "list") idRole = listIdRole(listScope);
169
+ if (resource === "user") idRole = "none";
170
+ return {
171
+ resource,
172
+ verb,
173
+ docsPath,
174
+ body: rule.body,
175
+ ...rule.destructive ? { destructive: true } : {},
176
+ idRole
177
+ };
680
178
  };
179
+ var resourceRegistry = RESOURCES.flatMap(
180
+ ([resource, verbs, listScope]) => verbs.map((verb) => toSpec(resource, verb, listScope))
181
+ );
681
182
  var normalizeResourceName = (resource) => {
682
183
  const normalized = resource.replace(/_/g, "-").toLowerCase();
683
- if (RESOURCE_ALIASES[normalized]) {
684
- return RESOURCE_ALIASES[normalized];
685
- }
686
184
  if (normalized.endsWith("s") && normalized !== "status") {
687
185
  return normalized.slice(0, -1);
688
186
  }
@@ -699,280 +197,11 @@ var listRegisteredVerbs = (resource) => {
699
197
  const key = normalizeResourceName(resource);
700
198
  return resourceRegistry.filter((entry) => entry.resource === key).map((entry) => entry.verb).sort();
701
199
  };
702
-
703
- // src/resources/stores.ts
704
- var getStore = async (http, storeId) => {
705
- return http.getResource(`/v1/stores/${storeId}`);
706
- };
707
- var listStores = async (http) => {
708
- return http.paginate("/v1/stores");
709
- };
710
-
711
- // src/resources/subscriptionInvoices.ts
712
- var getSubscriptionInvoice = async (http, subscriptionInvoiceId) => {
713
- return http.getResource(
714
- `/v1/subscription-invoices/${subscriptionInvoiceId}`
715
- );
716
- };
717
- var listSubscriptionInvoicesForSubscription = async (http, subscriptionId) => {
718
- return http.paginate("/v1/subscription-invoices", {
719
- "filter[subscription_id]": String(subscriptionId)
720
- });
721
- };
722
- var refundSubscriptionInvoice = async (http, subscriptionInvoiceId, body) => {
723
- return http.postResource(
724
- `/v1/subscription-invoices/${subscriptionInvoiceId}/refund`,
725
- body ?? {}
726
- );
727
- };
728
- var generateSubscriptionInvoice = async (http, subscriptionInvoiceId, body) => {
729
- return http.request({
730
- method: "POST",
731
- path: `/v1/subscription-invoices/${subscriptionInvoiceId}/generate-invoice`,
732
- body: body ?? {}
733
- });
734
- };
735
-
736
- // src/resources/subscriptionItems.ts
737
- var getSubscriptionItem = async (http, subscriptionItemId) => {
738
- return http.getResource(
739
- `/v1/subscription-items/${subscriptionItemId}`
740
- );
741
- };
742
- var listSubscriptionItemsForSubscription = async (http, subscriptionId) => {
743
- return http.paginate("/v1/subscription-items", {
744
- "filter[subscription_id]": String(subscriptionId)
745
- });
746
- };
747
- var buildSubscriptionItemUpdateBody = (subscriptionItemId, attributes) => {
748
- return {
749
- data: {
750
- type: "subscription-items",
751
- id: String(subscriptionItemId),
752
- attributes
753
- }
754
- };
755
- };
756
- var updateSubscriptionItem = async (http, subscriptionItemId, body) => {
757
- return http.patchResource(
758
- `/v1/subscription-items/${subscriptionItemId}`,
759
- body
760
- );
761
- };
762
- var getSubscriptionItemCurrentUsage = async (http, subscriptionItemId) => {
763
- return http.request({
764
- path: `/v1/subscription-items/${subscriptionItemId}/current-usage`
765
- });
766
- };
767
-
768
- // src/resources/subscriptions.ts
769
- var getSubscription = async (http, subscriptionId) => {
770
- return http.getResource(`/v1/subscriptions/${subscriptionId}`);
771
- };
772
- var listSubscriptionsForStore = async (http, storeId) => {
773
- return http.paginate("/v1/subscriptions", {
774
- "filter[store_id]": String(storeId)
775
- });
776
- };
777
- var updateSubscription = async (http, subscriptionId, body) => {
778
- return http.patchResource(`/v1/subscriptions/${subscriptionId}`, body);
779
- };
780
- var cancelSubscription = async (http, subscriptionId) => {
781
- const doc = await http.request({
782
- method: "DELETE",
783
- path: `/v1/subscriptions/${subscriptionId}`
784
- });
785
- return doc?.data;
786
- };
787
-
788
- // src/resources/usageRecords.ts
789
- var getUsageRecord = async (http, usageRecordId) => {
790
- return http.getResource(`/v1/usage-records/${usageRecordId}`);
791
- };
792
- var listUsageRecordsForSubscriptionItem = async (http, subscriptionItemId) => {
793
- return http.paginate("/v1/usage-records", {
794
- "filter[subscription_item_id]": String(subscriptionItemId)
795
- });
796
- };
797
- var createUsageRecord = async (http, body) => {
798
- return http.postResource("/v1/usage-records", body);
799
- };
800
-
801
- // src/resources/users.ts
802
- var getAuthenticatedUser = async (http) => {
803
- return http.request({ path: "/v1/users/me" });
804
- };
805
-
806
- // src/resources/variants.ts
807
- var getVariant = async (http, variantId) => {
808
- return http.getResource(`/v1/variants/${variantId}`);
809
- };
810
- var listVariantsForProduct = async (http, productId) => {
811
- return http.paginate("/v1/variants", {
812
- "filter[product_id]": String(productId)
813
- });
814
- };
815
-
816
- // src/resources/webhooks.ts
817
- var getWebhook = async (http, webhookId) => {
818
- return http.getResource(`/v1/webhooks/${webhookId}`);
819
- };
820
- var listWebhooksForStore = async (http, storeId) => {
821
- return http.paginate("/v1/webhooks", {
822
- "filter[store_id]": String(storeId)
823
- });
824
- };
825
- var createWebhook = async (http, body) => {
826
- return http.postResource("/v1/webhooks", body);
827
- };
828
- var updateWebhook = async (http, webhookId, body) => {
829
- return http.patchResource(`/v1/webhooks/${webhookId}`, body);
830
- };
831
- var deleteWebhook = async (http, webhookId) => {
832
- await http.deleteResource(`/v1/webhooks/${webhookId}`);
833
- };
834
-
835
- // src/resources/invokeOp.ts
836
- var invokeOp = async (http, resource, verb, args = {}) => {
837
- const spec = findResourceVerb(resource, verb);
838
- if (!spec) {
839
- throw new FreshSqueezyError({
840
- code: "UNKNOWN_OP",
841
- message: `Unknown or unsupported op: ${verb} ${resource}. Run \`fresh-squeezy ops --list\`.`
842
- });
843
- }
844
- const key = `${spec.resource}:${spec.verb}`;
845
- switch (key) {
846
- case "user:get": {
847
- const doc = await getAuthenticatedUser(http);
848
- return doc.data;
849
- }
850
- case "store:get":
851
- return getStore(http, requireId(args, "store"));
852
- case "store:list":
853
- return listStores(http);
854
- case "product:get":
855
- return getProduct(http, requireId(args, "product"));
856
- case "product:list":
857
- return listProducts(http, requireStore(args));
858
- case "variant:get":
859
- return getVariant(http, requireId(args, "variant"));
860
- case "variant:list":
861
- return listVariantsForProduct(http, requireParent(args, "product"));
862
- case "price:get":
863
- return getPrice(http, requireId(args, "price"));
864
- case "price:list":
865
- return listPricesForVariant(http, requireParent(args, "variant"));
866
- case "file:get":
867
- return getFile(http, requireId(args, "file"));
868
- case "file:list":
869
- return listFilesForVariant(http, requireParent(args, "variant"));
870
- case "customer:get":
871
- return getCustomer(http, requireId(args, "customer"));
872
- case "customer:list":
873
- return listCustomersForStore(http, requireStore(args));
874
- case "customer:create":
875
- return createCustomer(http, requireBody(args));
876
- case "customer:update":
877
- return updateCustomer(http, requireId(args, "customer"), requireBody(args));
878
- case "order:get":
879
- return getOrder(http, requireId(args, "order"));
880
- case "order:list":
881
- return listOrdersForStore(http, requireStore(args));
882
- case "order:refund":
883
- return refundOrder(http, requireId(args, "order"), args.body);
884
- case "order:generate-invoice":
885
- return generateOrderInvoice(http, requireId(args, "order"), args.body);
886
- case "order-item:get":
887
- return getOrderItem(http, requireId(args, "order-item"));
888
- case "order-item:list":
889
- return listOrderItemsForOrder(http, requireParent(args, "order"));
890
- case "subscription:get":
891
- return getSubscription(http, requireId(args, "subscription"));
892
- case "subscription:list":
893
- return listSubscriptionsForStore(http, requireStore(args));
894
- case "subscription:update":
895
- return updateSubscription(http, requireId(args, "subscription"), requireBody(args));
896
- case "subscription:cancel":
897
- return cancelSubscription(http, requireId(args, "subscription"));
898
- case "subscription-item:get":
899
- return getSubscriptionItem(http, requireId(args, "subscription-item"));
900
- case "subscription-item:list":
901
- return listSubscriptionItemsForSubscription(http, requireParent(args, "subscription"));
902
- case "subscription-item:update":
903
- return updateSubscriptionItem(http, requireId(args, "subscription-item"), requireBody(args));
904
- case "subscription-item:current-usage":
905
- return getSubscriptionItemCurrentUsage(http, requireId(args, "subscription-item"));
906
- case "subscription-invoice:get":
907
- return getSubscriptionInvoice(http, requireId(args, "subscription-invoice"));
908
- case "subscription-invoice:list":
909
- return listSubscriptionInvoicesForSubscription(http, requireParent(args, "subscription"));
910
- case "subscription-invoice:refund":
911
- return refundSubscriptionInvoice(http, requireId(args, "subscription-invoice"), args.body);
912
- case "subscription-invoice:generate-invoice":
913
- return generateSubscriptionInvoice(http, requireId(args, "subscription-invoice"), args.body);
914
- case "usage-record:get":
915
- return getUsageRecord(http, requireId(args, "usage-record"));
916
- case "usage-record:list":
917
- return listUsageRecordsForSubscriptionItem(http, requireParent(args, "subscription-item"));
918
- case "usage-record:create":
919
- return createUsageRecord(http, requireBody(args));
920
- case "discount:get":
921
- return getDiscount(http, requireId(args, "discount"));
922
- case "discount:list":
923
- return listDiscountsForStore(http, requireStore(args));
924
- case "discount:create":
925
- return createDiscount(http, requireBody(args));
926
- case "discount:delete":
927
- await deleteDiscount(http, requireId(args, "discount"));
928
- return void 0;
929
- case "discount-redemption:get":
930
- return getDiscountRedemption(http, requireId(args, "discount-redemption"));
931
- case "discount-redemption:list":
932
- return listDiscountRedemptionsForDiscount(http, requireParent(args, "discount"));
933
- case "license-key:get":
934
- return getLicenseKey(http, requireId(args, "license-key"));
935
- case "license-key:list":
936
- return listLicenseKeysForStore(http, requireStore(args));
937
- case "license-key:update":
938
- return updateLicenseKey(http, requireId(args, "license-key"), requireBody(args));
939
- case "license-key-instance:get":
940
- return getLicenseKeyInstance(http, requireId(args, "license-key-instance"));
941
- case "license-key-instance:list":
942
- return listLicenseKeyInstancesForLicenseKey(http, requireParent(args, "license-key"));
943
- case "checkout:get":
944
- return getCheckout(http, requireId(args, "checkout"));
945
- case "checkout:list":
946
- return listCheckoutsForStore(http, requireStore(args));
947
- case "checkout:create":
948
- return createCheckout(http, requireBody(args));
949
- case "webhook:get":
950
- return getWebhook(http, requireId(args, "webhook"));
951
- case "webhook:list":
952
- return listWebhooksForStore(http, requireStore(args));
953
- case "webhook:create":
954
- return createWebhook(http, requireBody(args));
955
- case "webhook:update":
956
- return updateWebhook(http, requireId(args, "webhook"), requireBody(args));
957
- case "webhook:delete":
958
- await deleteWebhook(http, requireId(args, "webhook"));
959
- return void 0;
960
- case "affiliate:get":
961
- return getAffiliate(http, requireId(args, "affiliate"));
962
- case "affiliate:list":
963
- return listAffiliatesForStore(http, requireStore(args));
964
- default:
965
- throw new FreshSqueezyError({
966
- code: "UNKNOWN_OP",
967
- message: `Op registered but not wired: ${key}`
968
- });
969
- }
970
- };
971
- var requireId = (args, label) => {
200
+ var requireId = (args, spec) => {
972
201
  if (args.id === void 0 || args.id === "") {
973
202
  throw new FreshSqueezyError({
974
203
  code: "MISSING_ARG",
975
- message: `--id is required for this ${label} operation.`
204
+ message: `--id is required for this ${spec.resource} operation.`
976
205
  });
977
206
  }
978
207
  return args.id;
@@ -986,11 +215,11 @@ var requireStore = (args) => {
986
215
  }
987
216
  return args.storeId;
988
217
  };
989
- var requireParent = (args, label) => {
218
+ var requireParent = (args, parent) => {
990
219
  if (args.parentId === void 0 || args.parentId === "") {
991
220
  throw new FreshSqueezyError({
992
221
  code: "MISSING_ARG",
993
- message: `--parent-id (${label} id) is required for this list operation.`
222
+ message: `--parent-id (${parent} id) is required for this list operation.`
994
223
  });
995
224
  }
996
225
  return args.parentId;
@@ -1004,8 +233,44 @@ var requireBody = (args) => {
1004
233
  }
1005
234
  return args.body;
1006
235
  };
236
+ var listFilter = (spec, args) => {
237
+ const listScope = RESOURCES.find(([resource]) => resource === spec.resource)?.[2];
238
+ if (!listScope) return void 0;
239
+ const scopeId = listScope === "store" ? requireStore(args) : requireParent(args, listScope);
240
+ return { [`filter[${listScope.replace(/-/g, "_")}_id]`]: String(scopeId) };
241
+ };
242
+ var requestBody = (rule, args) => {
243
+ if (rule.body === "required") return requireBody(args);
244
+ if (rule.body === "optional") return args.body ?? {};
245
+ return void 0;
246
+ };
247
+ var invokeOp = async (http, resource, verb, args = {}) => {
248
+ const spec = findResourceVerb(resource, verb);
249
+ if (!spec) {
250
+ throw new FreshSqueezyError({
251
+ code: "UNKNOWN_OP",
252
+ message: `Unknown or unsupported op: ${verb} ${resource}. Run \`fresh-squeezy ops --list\`.`
253
+ });
254
+ }
255
+ if (spec.resource === "user") {
256
+ const doc2 = await http.request({ path: USER_ME_PATH });
257
+ return doc2.data;
258
+ }
259
+ const collectionPath = `/v1/${spec.resource}s`;
260
+ if (spec.verb === "list") {
261
+ return http.paginate(collectionPath, listFilter(spec, args));
262
+ }
263
+ const rule = VERB_RULES[spec.verb];
264
+ const path = collectionPath + rule.path.replace("{id}", () => String(requireId(args, spec)));
265
+ const doc = await http.request({
266
+ method: rule.method,
267
+ path,
268
+ body: requestBody(rule, args)
269
+ });
270
+ return doc?.data ?? doc;
271
+ };
1007
272
 
1008
- // src/validate/rules.ts
273
+ // src/validate/issues.ts
1009
274
  var ISSUE_CODES = {
1010
275
  AUTH_FAILED: "AUTH_FAILED",
1011
276
  MODE_MISMATCH: "MODE_MISMATCH",
@@ -1129,11 +394,19 @@ var checkStoreOwnership = (check) => {
1129
394
  };
1130
395
 
1131
396
  // src/validate/connection.ts
397
+ var resolveActualMode = (testMode) => {
398
+ if (testMode === true) return "test";
399
+ if (testMode === false) return "live";
400
+ return void 0;
401
+ };
402
+ var fetchUserDocument = (http) => {
403
+ return http.request({ path: "/v1/users/me" });
404
+ };
1132
405
  var validateConnection = async (http, mode) => {
1133
406
  const fetched = await probeCollection(
1134
407
  async () => {
1135
- const userDoc2 = await getAuthenticatedUser(http);
1136
- const stores2 = await listStores(http);
408
+ const userDoc2 = await fetchUserDocument(http);
409
+ const stores2 = await http.paginate("/v1/stores");
1137
410
  return { userDoc: userDoc2, stores: stores2 };
1138
411
  },
1139
412
  {
@@ -1183,7 +456,7 @@ var validateConnection = async (http, mode) => {
1183
456
  return buildResult("connection", mode, issues, summary);
1184
457
  };
1185
458
  var fetchActualMode = async (http) => {
1186
- const doc = await getAuthenticatedUser(http);
459
+ const doc = await fetchUserDocument(http);
1187
460
  return resolveActualMode(doc.meta?.test_mode);
1188
461
  };
1189
462
 
@@ -1193,12 +466,15 @@ var validateDiscount = async (http, mode, options) => {
1193
466
  label: `discount ${options.discountId}`,
1194
467
  id: String(options.discountId)
1195
468
  };
1196
- const fetched = await probeFetch(() => getDiscount(http, options.discountId), {
1197
- notFoundCode: ISSUE_CODES.DISCOUNT_NOT_FOUND,
1198
- notFoundMessage: `Discount ${options.discountId} not found.`,
1199
- notFoundFix: "Verify the discount ID in the Lemon Squeezy dashboard.",
1200
- notFoundContext: { discountId: String(options.discountId) }
1201
- });
469
+ const fetched = await probeFetch(
470
+ () => http.getResource(`/v1/discounts/${options.discountId}`),
471
+ {
472
+ notFoundCode: ISSUE_CODES.DISCOUNT_NOT_FOUND,
473
+ notFoundMessage: `Discount ${options.discountId} not found.`,
474
+ notFoundFix: "Verify the discount ID in the Lemon Squeezy dashboard.",
475
+ notFoundContext: { discountId: String(options.discountId) }
476
+ }
477
+ );
1202
478
  if (!fetched.ok) {
1203
479
  return buildResult("discount", mode, [fetched.issue], void 0, target);
1204
480
  }
@@ -1305,12 +581,15 @@ var validateLicenseKey = async (http, mode, options) => {
1305
581
  label: `license key ${options.licenseKeyId}`,
1306
582
  id: String(options.licenseKeyId)
1307
583
  };
1308
- const fetched = await probeFetch(() => getLicenseKey(http, options.licenseKeyId), {
1309
- notFoundCode: ISSUE_CODES.LICENSE_KEY_NOT_FOUND,
1310
- notFoundMessage: `License key ${options.licenseKeyId} not found.`,
1311
- notFoundFix: "Verify the license key ID in the Lemon Squeezy dashboard.",
1312
- notFoundContext: { licenseKeyId: String(options.licenseKeyId) }
1313
- });
584
+ const fetched = await probeFetch(
585
+ () => http.getResource(`/v1/license-keys/${options.licenseKeyId}`),
586
+ {
587
+ notFoundCode: ISSUE_CODES.LICENSE_KEY_NOT_FOUND,
588
+ notFoundMessage: `License key ${options.licenseKeyId} not found.`,
589
+ notFoundFix: "Verify the license key ID in the Lemon Squeezy dashboard.",
590
+ notFoundContext: { licenseKeyId: String(options.licenseKeyId) }
591
+ }
592
+ );
1314
593
  if (!fetched.ok) {
1315
594
  return buildResult(
1316
595
  "licenseKey",
@@ -1392,19 +671,24 @@ var validateProduct = async (http, mode, options) => {
1392
671
  label: `product ${options.productId}`,
1393
672
  id: String(options.productId)
1394
673
  };
1395
- const fetched = await probeFetch(() => getProduct(http, options.productId), {
1396
- notFoundCode: ISSUE_CODES.PRODUCT_NOT_FOUND,
1397
- notFoundMessage: `Product ${options.productId} not found.`,
1398
- notFoundFix: "Verify the product ID in the Lemon Squeezy dashboard.",
1399
- notFoundContext: { productId: String(options.productId) }
1400
- });
674
+ const fetched = await probeFetch(
675
+ () => http.getResource(`/v1/products/${options.productId}`),
676
+ {
677
+ notFoundCode: ISSUE_CODES.PRODUCT_NOT_FOUND,
678
+ notFoundMessage: `Product ${options.productId} not found.`,
679
+ notFoundFix: "Verify the product ID in the Lemon Squeezy dashboard.",
680
+ notFoundContext: { productId: String(options.productId) }
681
+ }
682
+ );
1401
683
  if (!fetched.ok) {
1402
684
  return buildResult("product", mode, [fetched.issue], void 0, target);
1403
685
  }
1404
686
  const attrs = fetched.resource.attributes;
1405
687
  issues.push(...checkProduct(attrs, { expectedStoreId: options.expectedStoreId }));
1406
688
  const variantsProbed = await probeCollection(
1407
- () => listVariantsForProduct(http, options.productId)
689
+ () => http.paginate("/v1/variants", {
690
+ "filter[product_id]": String(options.productId)
691
+ })
1408
692
  );
1409
693
  if (!variantsProbed.ok) {
1410
694
  issues.push({ ...variantsProbed.issue, severity: "warning" });
@@ -1473,12 +757,15 @@ var checkProduct = (attrs, options = {}) => {
1473
757
  // src/validate/store.ts
1474
758
  var validateStore = async (http, mode, storeId) => {
1475
759
  const target = { label: `store ${storeId}`, id: String(storeId) };
1476
- const fetched = await probeFetch(() => getStore(http, storeId), {
1477
- notFoundCode: ISSUE_CODES.STORE_NOT_FOUND,
1478
- notFoundMessage: `Store ${storeId} not found with the current API key.`,
1479
- notFoundFix: "Check the store ID and confirm the API key belongs to the account that owns it.",
1480
- notFoundContext: { storeId: String(storeId) }
1481
- });
760
+ const fetched = await probeFetch(
761
+ () => http.getResource(`/v1/stores/${storeId}`),
762
+ {
763
+ notFoundCode: ISSUE_CODES.STORE_NOT_FOUND,
764
+ notFoundMessage: `Store ${storeId} not found with the current API key.`,
765
+ notFoundFix: "Check the store ID and confirm the API key belongs to the account that owns it.",
766
+ notFoundContext: { storeId: String(storeId) }
767
+ }
768
+ );
1482
769
  if (!fetched.ok) {
1483
770
  return buildResult("store", mode, [fetched.issue], void 0, target);
1484
771
  }
@@ -1496,7 +783,7 @@ var validateSubscriptionPlan = async (http, mode, options) => {
1496
783
  id: String(options.variantId)
1497
784
  };
1498
785
  const fetched = await probeFetch(
1499
- () => getVariant(http, options.variantId),
786
+ () => http.getResource(`/v1/variants/${options.variantId}`),
1500
787
  {
1501
788
  notFoundCode: ISSUE_CODES.PLAN_VARIANT_NOT_FOUND,
1502
789
  notFoundMessage: `Variant ${options.variantId} not found.`,
@@ -1516,10 +803,13 @@ var validateSubscriptionPlan = async (http, mode, options) => {
1516
803
  const variant = fetched.resource;
1517
804
  const attrs = variant.attributes;
1518
805
  const issues = checkSubscriptionPlan(attrs, { variantId: options.variantId });
1519
- const productProbed = await probeFetch(() => getProduct(http, attrs.product_id), {
1520
- notFoundCode: ISSUE_CODES.PRODUCT_NOT_FOUND,
1521
- notFoundMessage: `Product ${attrs.product_id} not found.`
1522
- });
806
+ const productProbed = await probeFetch(
807
+ () => http.getResource(`/v1/products/${attrs.product_id}`),
808
+ {
809
+ notFoundCode: ISSUE_CODES.PRODUCT_NOT_FOUND,
810
+ notFoundMessage: `Product ${attrs.product_id} not found.`
811
+ }
812
+ );
1523
813
  if (productProbed.ok) {
1524
814
  const mismatch = checkStoreOwnership({
1525
815
  expectedStoreId: options.storeId,
@@ -1658,7 +948,7 @@ var ACKNOWLEDGED_CHANGELOG_ENTRIES = [
1658
948
  {
1659
949
  date: "2025-06-11",
1660
950
  summary: "Added payment_processor attribute to Subscription objects.",
1661
- handledBy: "Surfaced as SubscriptionAttributes.payment_processor in src/resources/subscriptions.ts."
951
+ handledBy: "Surfaced as SubscriptionAttributes.payment_processor in src/resources/attributes.ts."
1662
952
  },
1663
953
  {
1664
954
  date: "2025-01-21",
@@ -1668,12 +958,12 @@ var ACKNOWLEDGED_CHANGELOG_ENTRIES = [
1668
958
  {
1669
959
  date: "2024-12-06",
1670
960
  summary: "Added quantity parameter to OrderItem objects.",
1671
- handledBy: "OrderItemAttributes.quantity (src/resources/orderItems.ts)."
961
+ handledBy: "OrderItemAttributes.quantity (src/resources/attributes.ts)."
1672
962
  },
1673
963
  {
1674
964
  date: "2024-09-10",
1675
965
  summary: "Added fraudulent Order status.",
1676
- handledBy: "OrderAttributes.status union includes 'fraudulent' (src/resources/orders.ts)."
966
+ handledBy: "OrderAttributes.status union includes 'fraudulent' (src/resources/attributes.ts)."
1677
967
  },
1678
968
  {
1679
969
  date: "2024-09-04",
@@ -1688,7 +978,7 @@ var ACKNOWLEDGED_CHANGELOG_ENTRIES = [
1688
978
  {
1689
979
  date: "2024-06-09",
1690
980
  summary: "Added links property to Variant objects.",
1691
- handledBy: "VariantAttributes.links (src/resources/variants.ts)."
981
+ handledBy: "VariantAttributes.links (src/resources/attributes.ts)."
1692
982
  },
1693
983
  {
1694
984
  date: "2024-05-20",
@@ -1708,7 +998,7 @@ var ACKNOWLEDGED_CHANGELOG_ENTRIES = [
1708
998
  {
1709
999
  date: "2024-02-20",
1710
1000
  summary: "Added urls.update_customer_portal to Subscription objects.",
1711
- handledBy: "SubscriptionUrls.update_customer_portal (src/resources/subscriptions.ts)."
1001
+ handledBy: "SubscriptionUrls.update_customer_portal (src/resources/attributes.ts)."
1712
1002
  },
1713
1003
  {
1714
1004
  date: "2024-02-12",
@@ -1758,9 +1048,19 @@ var ACKNOWLEDGED_CHANGELOG_ENTRIES = [
1758
1048
  ];
1759
1049
 
1760
1050
  // src/validate/webhook.ts
1051
+ var sameWebhookUrl = (a, b) => {
1052
+ return normalizeWebhookUrl(a) === normalizeWebhookUrl(b);
1053
+ };
1054
+ var normalizeWebhookUrl = (raw) => {
1055
+ return raw.replace(/\/+$/, "").toLowerCase();
1056
+ };
1761
1057
  var validateWebhook = async (http, mode, options) => {
1762
1058
  const target = { label: options.url, url: options.url };
1763
- const fetched = await probeCollection(() => listWebhooksForStore(http, options.storeId));
1059
+ const fetched = await probeCollection(
1060
+ () => http.paginate("/v1/webhooks", {
1061
+ "filter[store_id]": String(options.storeId)
1062
+ })
1063
+ );
1764
1064
  if (!fetched.ok) {
1765
1065
  return buildResult("webhook", mode, [fetched.issue], void 0, target);
1766
1066
  }
@@ -1945,46 +1245,6 @@ var HttpClient = class {
1945
1245
  const doc = await this.request({ path });
1946
1246
  return doc.data;
1947
1247
  }
1948
- /**
1949
- * POST a JSON:API document and return the created `data` resource.
1950
- *
1951
- * @param path - API path starting with `/v1/...`.
1952
- * @param body - JSON:API create document.
1953
- * @returns The created resource.
1954
- */
1955
- async postResource(path, body) {
1956
- const doc = await this.request({ method: "POST", path, body });
1957
- return doc.data;
1958
- }
1959
- /**
1960
- * PATCH a JSON:API document and return the updated `data` resource.
1961
- *
1962
- * @param path - API path starting with `/v1/...`.
1963
- * @param body - JSON:API update document.
1964
- * @returns The updated resource.
1965
- */
1966
- async patchResource(path, body) {
1967
- const doc = await this.request({ method: "PATCH", path, body });
1968
- return doc.data;
1969
- }
1970
- /**
1971
- * DELETE a resource. Lemon Squeezy often returns an empty body on success.
1972
- *
1973
- * @param path - API path starting with `/v1/...`.
1974
- * @returns Nothing — single void return, not a multi-field bag.
1975
- */
1976
- async deleteResource(path) {
1977
- await this.request({ method: "DELETE", path });
1978
- }
1979
- /**
1980
- * Fetch a single page of a JSON:API collection. Most callers want
1981
- * `paginate()` instead — this method is kept for one-shot lookups where
1982
- * the caller knows the result fits in a single page.
1983
- */
1984
- async getCollection(path, query) {
1985
- const doc = await this.request({ path, query });
1986
- return doc.data;
1987
- }
1988
1248
  /**
1989
1249
  * Walk a JSON:API collection across every page and concatenate the
1990
1250
  * results. Lemon Squeezy returns 25 items per page by default; without
@@ -2178,81 +1438,24 @@ export {
2178
1438
  SUPPORTED_RESOURCES,
2179
1439
  buildResult,
2180
1440
  buildSubscriptionItemUpdateBody,
2181
- cancelSubscription,
2182
1441
  checkDiscount,
2183
1442
  checkLicenseKey,
2184
1443
  checkProduct,
2185
1444
  checkSubscriptionPlan,
2186
- createCheckout,
2187
- createCustomer,
2188
- createDiscount,
2189
1445
  createFreshSqueezy,
2190
- createUsageRecord,
2191
- createWebhook,
2192
- deleteDiscount,
2193
- deleteWebhook,
2194
1446
  doctor,
2195
1447
  fetchActualMode,
2196
1448
  findResourceVerb,
2197
- generateOrderInvoice,
2198
- generateSubscriptionInvoice,
2199
- getAffiliate,
2200
- getAuthenticatedUser,
2201
- getCheckout,
2202
- getCustomer,
2203
- getDiscount,
2204
- getDiscountRedemption,
2205
- getFile,
2206
- getLicenseKey,
2207
- getLicenseKeyInstance,
2208
- getOrder,
2209
- getOrderItem,
2210
- getPrice,
2211
- getProduct,
2212
- getStore,
2213
- getSubscription,
2214
- getSubscriptionInvoice,
2215
- getSubscriptionItem,
2216
- getSubscriptionItemCurrentUsage,
2217
- getUsageRecord,
2218
- getVariant,
2219
- getWebhook,
2220
1449
  invokeOp,
2221
1450
  isOk,
2222
1451
  issue,
2223
- listAffiliatesForStore,
2224
- listCheckoutsForStore,
2225
- listCustomersForStore,
2226
- listDiscountRedemptionsForDiscount,
2227
- listDiscountsForStore,
2228
- listFilesForVariant,
2229
- listLicenseKeyInstancesForLicenseKey,
2230
- listLicenseKeysForStore,
2231
- listOrderItemsForOrder,
2232
- listOrdersForStore,
2233
- listPricesForVariant,
2234
- listProducts,
2235
1452
  listRegisteredResources,
2236
1453
  listRegisteredVerbs,
2237
- listStores,
2238
- listSubscriptionInvoicesForSubscription,
2239
- listSubscriptionItemsForSubscription,
2240
- listSubscriptionsForStore,
2241
- listUsageRecordsForSubscriptionItem,
2242
- listVariantsForProduct,
2243
- listWebhooksForStore,
2244
1454
  normalizeResourceName,
2245
- refundOrder,
2246
- refundSubscriptionInvoice,
2247
1455
  resolveActualMode,
2248
1456
  resolveConfig,
2249
1457
  resourceRegistry,
2250
1458
  sameWebhookUrl,
2251
- updateCustomer,
2252
- updateLicenseKey,
2253
- updateSubscription,
2254
- updateSubscriptionItem,
2255
- updateWebhook,
2256
1459
  validateConnection,
2257
1460
  validateDiscount,
2258
1461
  validateLicenseKey,