@waffo/pancake-ts 0.7.0 → 0.9.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/CHANGELOG.md +49 -0
- package/README.md +53 -1
- package/dist/index.cjs +125 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -55
- package/dist/index.d.ts +141 -55
- package/dist/index.js +125 -73
- package/dist/index.js.map +1 -1
- package/docs/api-reference.md +45 -41
- package/docs/graphql-guide.md +26 -0
- package/docs/webhook-guide.md +11 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,12 +23,10 @@ var BuyerHttpClient = class {
|
|
|
23
23
|
this._fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Send a Bearer-authenticated POST
|
|
26
|
+
* Send a Bearer-authenticated POST and return the full envelope plus HTTP status.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
* @returns Parsed `data` field from the response
|
|
31
|
-
* @throws {WaffoPancakeError} When the API returns errors
|
|
28
|
+
* Does NOT throw on `errors[]` or non-2xx status — caller inspects the result.
|
|
29
|
+
* Throws {@link WaffoPancakeError} only when the response body is not valid JSON.
|
|
32
30
|
*/
|
|
33
31
|
async post(path, body) {
|
|
34
32
|
const response = await this._fetch(`${this.baseUrl}${path}`, {
|
|
@@ -39,11 +37,13 @@ var BuyerHttpClient = class {
|
|
|
39
37
|
},
|
|
40
38
|
body: JSON.stringify(body)
|
|
41
39
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
let envelope;
|
|
41
|
+
try {
|
|
42
|
+
envelope = await response.json();
|
|
43
|
+
} catch {
|
|
44
|
+
throw new WaffoPancakeError(response.status, [{ message: `Non-JSON response from ${path}`, layer: "sdk" }]);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return { status: response.status, ...envelope };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -159,48 +159,64 @@ var HttpClient = class {
|
|
|
159
159
|
this._fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* Send a signed POST
|
|
162
|
+
* Send a signed POST and return the full envelope plus HTTP status.
|
|
163
163
|
*
|
|
164
164
|
* Behavior:
|
|
165
|
-
* -
|
|
166
|
-
* -
|
|
167
|
-
*
|
|
168
|
-
* -
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* @
|
|
165
|
+
* - Builds RSA-SHA256 signature (`X-Merchant-Id` / `X-Timestamp` / `X-Signature`)
|
|
166
|
+
* - Attaches `X-Idempotency-Key` (deterministic `sha256(merchantId + path + body)`)
|
|
167
|
+
* unless `options.noIdempotency` is set
|
|
168
|
+
* - When `options.idempotencyWindow` is set, a floored timestamp is mixed into the
|
|
169
|
+
* key so identical params produce a new key after the window elapses
|
|
170
|
+
* - Does NOT throw on `errors[]` or non-2xx status — caller inspects the result
|
|
171
|
+
* - Throws {@link WaffoPancakeError} only on transport failures (non-JSON body)
|
|
172
|
+
*
|
|
173
|
+
* @param path - API path (e.g. `/v1/actions/store/create-store`, `/v1/graphql`)
|
|
172
174
|
* @param body - Request body object
|
|
173
175
|
* @param options - Optional settings
|
|
174
|
-
* @
|
|
175
|
-
* @
|
|
176
|
-
* @throws {WaffoPancakeError} When the API returns errors
|
|
176
|
+
* @returns Parsed envelope with HTTP status
|
|
177
|
+
* @throws {WaffoPancakeError} When the response body is not valid JSON
|
|
177
178
|
*/
|
|
178
179
|
async post(path, body, options) {
|
|
179
180
|
const bodyStr = JSON.stringify(body);
|
|
180
|
-
const
|
|
181
|
-
const timestampSec = Math.floor(now / 1e3);
|
|
181
|
+
const timestampSec = Math.floor(Date.now() / 1e3);
|
|
182
182
|
const timestamp = timestampSec.toString();
|
|
183
183
|
const signature = signRequest("POST", path, timestamp, bodyStr, this.privateKey);
|
|
184
|
-
const
|
|
185
|
-
|
|
184
|
+
const headers = {
|
|
185
|
+
"Content-Type": "application/json",
|
|
186
|
+
"X-Merchant-Id": this.merchantId,
|
|
187
|
+
"X-Timestamp": timestamp,
|
|
188
|
+
"X-Signature": signature
|
|
189
|
+
};
|
|
190
|
+
if (!options?.noIdempotency) {
|
|
191
|
+
headers["X-Idempotency-Key"] = computeIdempotencyKey(this.merchantId, path, bodyStr, timestampSec, options);
|
|
192
|
+
}
|
|
186
193
|
const response = await this._fetch(`${this.baseUrl}${path}`, {
|
|
187
194
|
method: "POST",
|
|
188
|
-
headers
|
|
189
|
-
"Content-Type": "application/json",
|
|
190
|
-
"X-Merchant-Id": this.merchantId,
|
|
191
|
-
"X-Timestamp": timestamp,
|
|
192
|
-
"X-Signature": signature,
|
|
193
|
-
"X-Idempotency-Key": createHash2("sha256").update(idempotencyInput).digest("hex")
|
|
194
|
-
},
|
|
195
|
+
headers,
|
|
195
196
|
body: bodyStr
|
|
196
197
|
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
let envelope;
|
|
199
|
+
try {
|
|
200
|
+
envelope = await response.json();
|
|
201
|
+
} catch {
|
|
202
|
+
throw new WaffoPancakeError(response.status, [{ message: `Non-JSON response from ${path}`, layer: "sdk" }]);
|
|
200
203
|
}
|
|
201
|
-
return
|
|
204
|
+
return { status: response.status, ...envelope };
|
|
202
205
|
}
|
|
203
206
|
};
|
|
207
|
+
function computeIdempotencyKey(merchantId, path, bodyStr, timestampSec, options) {
|
|
208
|
+
const base = `${merchantId}:${path}:${bodyStr}`;
|
|
209
|
+
const input = options?.idempotencyWindow ? `${base}:${Math.floor(timestampSec / options.idempotencyWindow)}` : base;
|
|
210
|
+
return createHash2("sha256").update(input).digest("hex");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/resources/internal.ts
|
|
214
|
+
function unwrapAction(r) {
|
|
215
|
+
if (r.errors?.length) {
|
|
216
|
+
throw new WaffoPancakeError(r.status, r.errors);
|
|
217
|
+
}
|
|
218
|
+
return { ...r.data, ...r.warnings ? { warnings: r.warnings } : {} };
|
|
219
|
+
}
|
|
204
220
|
|
|
205
221
|
// src/validation.ts
|
|
206
222
|
var SHORT_ID_REGEX = /^[A-Z]{2,5}_[0-9A-Za-z]{22}$/;
|
|
@@ -255,6 +271,11 @@ function validateEnum(field, value, allowed) {
|
|
|
255
271
|
fail(`Invalid ${field}: expected one of [${allowed.join(", ")}], got "${value}"`);
|
|
256
272
|
}
|
|
257
273
|
}
|
|
274
|
+
function validateMaxLength(field, value, max) {
|
|
275
|
+
if (value !== void 0 && value.length > max) {
|
|
276
|
+
fail(`${field} must be at most ${max} characters, got ${value.length}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
258
279
|
function validatePositiveInteger(field, value) {
|
|
259
280
|
if (!Number.isInteger(value) || value <= 0) {
|
|
260
281
|
fail(`Invalid ${field}: expected positive integer, got ${value}`);
|
|
@@ -297,6 +318,7 @@ function validateCheckoutCommon(params) {
|
|
|
297
318
|
if (params.expiresInSeconds !== void 0) {
|
|
298
319
|
validatePositiveInteger("expiresInSeconds", params.expiresInSeconds);
|
|
299
320
|
}
|
|
321
|
+
validateMaxLength("orderMerchantExternalId", params.orderMerchantExternalId, 128);
|
|
300
322
|
}
|
|
301
323
|
|
|
302
324
|
// src/resources/auth.ts
|
|
@@ -335,7 +357,7 @@ var AuthResource = class {
|
|
|
335
357
|
validateShortId("productId", params.productId, "PROD");
|
|
336
358
|
}
|
|
337
359
|
validateRequired("buyerIdentity", params.buyerIdentity);
|
|
338
|
-
return this.http.post("/v1/actions/auth/issue-session-token", params);
|
|
360
|
+
return unwrapAction(await this.http.post("/v1/actions/auth/issue-session-token", params));
|
|
339
361
|
}
|
|
340
362
|
};
|
|
341
363
|
|
|
@@ -359,7 +381,7 @@ var BuyerSession = class {
|
|
|
359
381
|
*/
|
|
360
382
|
async cancelSubscription(params) {
|
|
361
383
|
validateShortId("orderId", params.orderId, "ORD");
|
|
362
|
-
return this.http.post("/v1/actions/subscription-order/cancel-order", params);
|
|
384
|
+
return unwrapAction(await this.http.post("/v1/actions/subscription-order/cancel-order", params));
|
|
363
385
|
}
|
|
364
386
|
/**
|
|
365
387
|
* Cancel a one-time order (only while payment is still pending).
|
|
@@ -372,7 +394,7 @@ var BuyerSession = class {
|
|
|
372
394
|
*/
|
|
373
395
|
async cancelOnetimeOrder(params) {
|
|
374
396
|
validateShortId("orderId", params.orderId, "ORD");
|
|
375
|
-
return this.http.post("/v1/actions/onetime-order/cancel-order", params);
|
|
397
|
+
return unwrapAction(await this.http.post("/v1/actions/onetime-order/cancel-order", params));
|
|
376
398
|
}
|
|
377
399
|
/**
|
|
378
400
|
* Reactivate a subscription that is in `canceling` status.
|
|
@@ -386,7 +408,7 @@ var BuyerSession = class {
|
|
|
386
408
|
*/
|
|
387
409
|
async reactivateSubscription(params) {
|
|
388
410
|
validateShortId("orderId", params.orderId, "ORD");
|
|
389
|
-
return this.http.post("/v1/actions/subscription-order/reactivate-order", params);
|
|
411
|
+
return unwrapAction(await this.http.post("/v1/actions/subscription-order/reactivate-order", params));
|
|
390
412
|
}
|
|
391
413
|
/**
|
|
392
414
|
* Submit a refund request for a payment.
|
|
@@ -399,6 +421,7 @@ var BuyerSession = class {
|
|
|
399
421
|
* paymentId: "PAY_xxx",
|
|
400
422
|
* reason: "Product not as described",
|
|
401
423
|
* requestedAmount: { amount: "29.00", currency: "USD" },
|
|
424
|
+
* refundTicketMerchantExternalId: "REF-2026-00891",
|
|
402
425
|
* });
|
|
403
426
|
*/
|
|
404
427
|
async createRefundTicket(params) {
|
|
@@ -406,7 +429,8 @@ var BuyerSession = class {
|
|
|
406
429
|
validateRequired("reason", params.reason);
|
|
407
430
|
validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
|
|
408
431
|
validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
|
|
409
|
-
|
|
432
|
+
validateMaxLength("refundTicketMerchantExternalId", params.refundTicketMerchantExternalId, 128);
|
|
433
|
+
return unwrapAction(await this.http.post("/v1/actions/refund-ticket/create-ticket", params));
|
|
410
434
|
}
|
|
411
435
|
/**
|
|
412
436
|
* Resubmit a previously rejected refund ticket with updated details.
|
|
@@ -428,7 +452,7 @@ var BuyerSession = class {
|
|
|
428
452
|
validateRequired("reason", params.reason);
|
|
429
453
|
validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
|
|
430
454
|
validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
|
|
431
|
-
return this.http.post("/v1/actions/refund-ticket/resubmit-ticket", params);
|
|
455
|
+
return unwrapAction(await this.http.post("/v1/actions/refund-ticket/resubmit-ticket", params));
|
|
432
456
|
}
|
|
433
457
|
};
|
|
434
458
|
var BuyerGraphQL = class {
|
|
@@ -448,7 +472,8 @@ var BuyerGraphQL = class {
|
|
|
448
472
|
*/
|
|
449
473
|
async query(params) {
|
|
450
474
|
validateRequired("query", params.query);
|
|
451
|
-
|
|
475
|
+
const result = await this.http.post("/v1/graphql", params);
|
|
476
|
+
return { data: result.data, errors: result.errors, warnings: result.warnings };
|
|
452
477
|
}
|
|
453
478
|
};
|
|
454
479
|
|
|
@@ -471,17 +496,20 @@ var CheckoutAnonymousResource = class {
|
|
|
471
496
|
* });
|
|
472
497
|
*
|
|
473
498
|
* @example
|
|
474
|
-
* // Pre-fill email
|
|
499
|
+
* // Pre-fill email + billing + attach business-side order reference
|
|
475
500
|
* const result = await client.checkout.anonymous.create({
|
|
476
501
|
* productId: "PROD_xxx",
|
|
477
502
|
* currency: "USD",
|
|
478
503
|
* buyerEmail: "customer@example.com",
|
|
479
504
|
* billingDetail: { country: "US", isBusiness: false, postcode: "10001" },
|
|
505
|
+
* orderMerchantExternalId: "ORDER-2026-00891",
|
|
480
506
|
* });
|
|
481
507
|
*/
|
|
482
508
|
async create(params) {
|
|
483
509
|
validateCheckoutCommon(params);
|
|
484
|
-
return
|
|
510
|
+
return unwrapAction(
|
|
511
|
+
await this.http.post("/v1/actions/checkout/create-session", params, { idempotencyWindow: 60 })
|
|
512
|
+
);
|
|
485
513
|
}
|
|
486
514
|
};
|
|
487
515
|
|
|
@@ -510,6 +538,7 @@ var CheckoutAuthenticatedResource = class {
|
|
|
510
538
|
* currency: "USD",
|
|
511
539
|
* buyerIdentity: "user-123",
|
|
512
540
|
* buyerEmail: "customer@example.com",
|
|
541
|
+
* orderMerchantExternalId: "ORDER-2026-00891",
|
|
513
542
|
* });
|
|
514
543
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
515
544
|
*/
|
|
@@ -528,12 +557,16 @@ var CheckoutAuthenticatedResource = class {
|
|
|
528
557
|
),
|
|
529
558
|
this.http.post("/v1/actions/checkout/create-session", sessionParams, { idempotencyWindow: 60 })
|
|
530
559
|
]);
|
|
560
|
+
const token = unwrapAction(tokenResult);
|
|
561
|
+
const session = unwrapAction(sessionResult);
|
|
562
|
+
const warnings = [...token.warnings ?? [], ...session.warnings ?? []];
|
|
531
563
|
return {
|
|
532
|
-
sessionId:
|
|
533
|
-
checkoutUrl: `${
|
|
534
|
-
expiresAt:
|
|
535
|
-
token:
|
|
536
|
-
tokenExpiresAt:
|
|
564
|
+
sessionId: session.sessionId,
|
|
565
|
+
checkoutUrl: `${session.checkoutUrl}#token=${token.token}`,
|
|
566
|
+
expiresAt: session.expiresAt,
|
|
567
|
+
token: token.token,
|
|
568
|
+
tokenExpiresAt: token.expiresAt,
|
|
569
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
537
570
|
};
|
|
538
571
|
}
|
|
539
572
|
};
|
|
@@ -567,7 +600,9 @@ var CheckoutResource = class {
|
|
|
567
600
|
* // Redirect to session.checkoutUrl
|
|
568
601
|
*/
|
|
569
602
|
async createSession(params) {
|
|
570
|
-
return
|
|
603
|
+
return unwrapAction(
|
|
604
|
+
await this.http.post("/v1/actions/checkout/create-session", params, { idempotencyWindow: 60 })
|
|
605
|
+
);
|
|
571
606
|
}
|
|
572
607
|
};
|
|
573
608
|
|
|
@@ -596,7 +631,8 @@ var GraphQLResource = class {
|
|
|
596
631
|
*/
|
|
597
632
|
async query(params) {
|
|
598
633
|
validateRequired("query", params.query);
|
|
599
|
-
|
|
634
|
+
const result = await this.http.post("/v1/graphql", params, { noIdempotency: true });
|
|
635
|
+
return { data: result.data, errors: result.errors, warnings: result.warnings };
|
|
600
636
|
}
|
|
601
637
|
};
|
|
602
638
|
|
|
@@ -622,7 +658,7 @@ var OnetimeProductsResource = class {
|
|
|
622
658
|
validateShortId("storeId", params.storeId, "STO");
|
|
623
659
|
validateRequired("name", params.name);
|
|
624
660
|
validatePrices("prices", params.prices);
|
|
625
|
-
return this.http.post("/v1/actions/onetime-product/create-product", params);
|
|
661
|
+
return unwrapAction(await this.http.post("/v1/actions/onetime-product/create-product", params));
|
|
626
662
|
}
|
|
627
663
|
/**
|
|
628
664
|
* Update a one-time product. Creates a new version; skips if unchanged.
|
|
@@ -648,7 +684,7 @@ var OnetimeProductsResource = class {
|
|
|
648
684
|
validateShortId("id", params.id, "PROD");
|
|
649
685
|
if (params.name !== void 0) validateRequired("name", params.name);
|
|
650
686
|
if (params.prices) validatePrices("prices", params.prices);
|
|
651
|
-
return this.http.post("/v1/actions/onetime-product/update-product", params);
|
|
687
|
+
return unwrapAction(await this.http.post("/v1/actions/onetime-product/update-product", params));
|
|
652
688
|
}
|
|
653
689
|
/**
|
|
654
690
|
* Publish a one-time product's test version to production.
|
|
@@ -661,7 +697,7 @@ var OnetimeProductsResource = class {
|
|
|
661
697
|
*/
|
|
662
698
|
async publish(params) {
|
|
663
699
|
validateShortId("id", params.id, "PROD");
|
|
664
|
-
return this.http.post("/v1/actions/onetime-product/publish-product", params);
|
|
700
|
+
return unwrapAction(await this.http.post("/v1/actions/onetime-product/publish-product", params));
|
|
665
701
|
}
|
|
666
702
|
/**
|
|
667
703
|
* Update a one-time product's status (active/inactive).
|
|
@@ -678,7 +714,7 @@ var OnetimeProductsResource = class {
|
|
|
678
714
|
async updateStatus(params) {
|
|
679
715
|
validateShortId("id", params.id, "PROD");
|
|
680
716
|
validateEnum("status", params.status, ["active", "inactive"]);
|
|
681
|
-
return this.http.post("/v1/actions/onetime-product/update-status", params);
|
|
717
|
+
return unwrapAction(await this.http.post("/v1/actions/onetime-product/update-status", params));
|
|
682
718
|
}
|
|
683
719
|
};
|
|
684
720
|
|
|
@@ -704,7 +740,7 @@ var OrdersResource = class {
|
|
|
704
740
|
*/
|
|
705
741
|
async cancelSubscription(params) {
|
|
706
742
|
validateShortId("orderId", params.orderId, "ORD");
|
|
707
|
-
return this.http.post("/v1/actions/subscription-order/cancel-order", params);
|
|
743
|
+
return unwrapAction(await this.http.post("/v1/actions/subscription-order/cancel-order", params));
|
|
708
744
|
}
|
|
709
745
|
};
|
|
710
746
|
|
|
@@ -730,7 +766,7 @@ var StoreMerchantsResource = class {
|
|
|
730
766
|
validateShortId("storeId", params.storeId, "STO");
|
|
731
767
|
validateRequired("email", params.email);
|
|
732
768
|
validateEnum("role", params.role, ["admin", "member"]);
|
|
733
|
-
return this.http.post("/v1/actions/store-merchant/add-merchant", params);
|
|
769
|
+
return unwrapAction(await this.http.post("/v1/actions/store-merchant/add-merchant", params));
|
|
734
770
|
}
|
|
735
771
|
/**
|
|
736
772
|
* Remove a merchant from a store.
|
|
@@ -747,7 +783,7 @@ var StoreMerchantsResource = class {
|
|
|
747
783
|
async remove(params) {
|
|
748
784
|
validateShortId("storeId", params.storeId, "STO");
|
|
749
785
|
validateShortId("merchantId", params.merchantId, "MER");
|
|
750
|
-
return this.http.post("/v1/actions/store-merchant/remove-merchant", params);
|
|
786
|
+
return unwrapAction(await this.http.post("/v1/actions/store-merchant/remove-merchant", params));
|
|
751
787
|
}
|
|
752
788
|
/**
|
|
753
789
|
* Update a merchant's role in a store.
|
|
@@ -766,7 +802,7 @@ var StoreMerchantsResource = class {
|
|
|
766
802
|
validateShortId("storeId", params.storeId, "STO");
|
|
767
803
|
validateShortId("merchantId", params.merchantId, "MER");
|
|
768
804
|
validateEnum("role", params.role, ["admin", "member"]);
|
|
769
|
-
return this.http.post("/v1/actions/store-merchant/update-role", params);
|
|
805
|
+
return unwrapAction(await this.http.post("/v1/actions/store-merchant/update-role", params));
|
|
770
806
|
}
|
|
771
807
|
};
|
|
772
808
|
|
|
@@ -786,7 +822,7 @@ var StoresResource = class {
|
|
|
786
822
|
*/
|
|
787
823
|
async create(params) {
|
|
788
824
|
validateRequired("name", params.name);
|
|
789
|
-
return this.http.post("/v1/actions/store/create-store", params);
|
|
825
|
+
return unwrapAction(await this.http.post("/v1/actions/store/create-store", params));
|
|
790
826
|
}
|
|
791
827
|
/**
|
|
792
828
|
* Update an existing store's settings.
|
|
@@ -818,7 +854,7 @@ var StoresResource = class {
|
|
|
818
854
|
*/
|
|
819
855
|
async update(params) {
|
|
820
856
|
validateShortId("id", params.id, "STO");
|
|
821
|
-
return this.http.post("/v1/actions/store/update-store", params);
|
|
857
|
+
return unwrapAction(await this.http.post("/v1/actions/store/update-store", params));
|
|
822
858
|
}
|
|
823
859
|
/**
|
|
824
860
|
* Soft-delete a store. Only the owner can delete.
|
|
@@ -831,7 +867,7 @@ var StoresResource = class {
|
|
|
831
867
|
*/
|
|
832
868
|
async delete(params) {
|
|
833
869
|
validateShortId("id", params.id, "STO");
|
|
834
|
-
return this.http.post("/v1/actions/store/delete-store", params);
|
|
870
|
+
return unwrapAction(await this.http.post("/v1/actions/store/delete-store", params));
|
|
835
871
|
}
|
|
836
872
|
};
|
|
837
873
|
|
|
@@ -857,7 +893,9 @@ var SubscriptionProductGroupsResource = class {
|
|
|
857
893
|
async create(params) {
|
|
858
894
|
validateShortId("storeId", params.storeId, "STO");
|
|
859
895
|
validateRequired("name", params.name);
|
|
860
|
-
return
|
|
896
|
+
return unwrapAction(
|
|
897
|
+
await this.http.post("/v1/actions/subscription-product-group/create-group", params)
|
|
898
|
+
);
|
|
861
899
|
}
|
|
862
900
|
/**
|
|
863
901
|
* Update a subscription product group. `productIds` is a full replacement.
|
|
@@ -873,7 +911,9 @@ var SubscriptionProductGroupsResource = class {
|
|
|
873
911
|
*/
|
|
874
912
|
async update(params) {
|
|
875
913
|
validateRequired("id", params.id);
|
|
876
|
-
return
|
|
914
|
+
return unwrapAction(
|
|
915
|
+
await this.http.post("/v1/actions/subscription-product-group/update-group", params)
|
|
916
|
+
);
|
|
877
917
|
}
|
|
878
918
|
/**
|
|
879
919
|
* Hard-delete a subscription product group.
|
|
@@ -886,7 +926,9 @@ var SubscriptionProductGroupsResource = class {
|
|
|
886
926
|
*/
|
|
887
927
|
async delete(params) {
|
|
888
928
|
validateRequired("id", params.id);
|
|
889
|
-
return
|
|
929
|
+
return unwrapAction(
|
|
930
|
+
await this.http.post("/v1/actions/subscription-product-group/delete-group", params)
|
|
931
|
+
);
|
|
890
932
|
}
|
|
891
933
|
/**
|
|
892
934
|
* Publish a test-environment group to production (upsert).
|
|
@@ -899,7 +941,9 @@ var SubscriptionProductGroupsResource = class {
|
|
|
899
941
|
*/
|
|
900
942
|
async publish(params) {
|
|
901
943
|
validateRequired("id", params.id);
|
|
902
|
-
return
|
|
944
|
+
return unwrapAction(
|
|
945
|
+
await this.http.post("/v1/actions/subscription-product-group/publish-group", params)
|
|
946
|
+
);
|
|
903
947
|
}
|
|
904
948
|
};
|
|
905
949
|
|
|
@@ -927,7 +971,9 @@ var SubscriptionProductsResource = class {
|
|
|
927
971
|
validateRequired("name", params.name);
|
|
928
972
|
validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
|
|
929
973
|
validatePrices("prices", params.prices);
|
|
930
|
-
return
|
|
974
|
+
return unwrapAction(
|
|
975
|
+
await this.http.post("/v1/actions/subscription-product/create-product", params)
|
|
976
|
+
);
|
|
931
977
|
}
|
|
932
978
|
/**
|
|
933
979
|
* Update a subscription product. Creates a new version; skips if unchanged.
|
|
@@ -956,7 +1002,9 @@ var SubscriptionProductsResource = class {
|
|
|
956
1002
|
if (params.billingPeriod !== void 0)
|
|
957
1003
|
validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
|
|
958
1004
|
if (params.prices) validatePrices("prices", params.prices);
|
|
959
|
-
return
|
|
1005
|
+
return unwrapAction(
|
|
1006
|
+
await this.http.post("/v1/actions/subscription-product/update-product", params)
|
|
1007
|
+
);
|
|
960
1008
|
}
|
|
961
1009
|
/**
|
|
962
1010
|
* Publish a subscription product's test version to production.
|
|
@@ -969,7 +1017,9 @@ var SubscriptionProductsResource = class {
|
|
|
969
1017
|
*/
|
|
970
1018
|
async publish(params) {
|
|
971
1019
|
validateShortId("id", params.id, "PROD");
|
|
972
|
-
return
|
|
1020
|
+
return unwrapAction(
|
|
1021
|
+
await this.http.post("/v1/actions/subscription-product/publish-product", params)
|
|
1022
|
+
);
|
|
973
1023
|
}
|
|
974
1024
|
/**
|
|
975
1025
|
* Update a subscription product's status (active/inactive).
|
|
@@ -986,7 +1036,9 @@ var SubscriptionProductsResource = class {
|
|
|
986
1036
|
async updateStatus(params) {
|
|
987
1037
|
validateShortId("id", params.id, "PROD");
|
|
988
1038
|
validateEnum("status", params.status, ["active", "inactive"]);
|
|
989
|
-
return
|
|
1039
|
+
return unwrapAction(
|
|
1040
|
+
await this.http.post("/v1/actions/subscription-product/update-status", params)
|
|
1041
|
+
);
|
|
990
1042
|
}
|
|
991
1043
|
};
|
|
992
1044
|
|
|
@@ -1143,7 +1195,7 @@ var WebhooksResource = class {
|
|
|
1143
1195
|
validateShortId("storeId", params.storeId, "STO");
|
|
1144
1196
|
validateRequired("channel", params.channel);
|
|
1145
1197
|
validateRequired("url", params.url);
|
|
1146
|
-
return this.http.post("/v1/actions/store/add-webhook", params);
|
|
1198
|
+
return unwrapAction(await this.http.post("/v1/actions/store/add-webhook", params));
|
|
1147
1199
|
}
|
|
1148
1200
|
/**
|
|
1149
1201
|
* Update an existing webhook (only `url`, `events`, and `secret` are mutable).
|
|
@@ -1163,7 +1215,7 @@ var WebhooksResource = class {
|
|
|
1163
1215
|
*/
|
|
1164
1216
|
async update(params) {
|
|
1165
1217
|
validateRequired("id", params.id);
|
|
1166
|
-
return this.http.post("/v1/actions/store/update-webhook", params);
|
|
1218
|
+
return unwrapAction(await this.http.post("/v1/actions/store/update-webhook", params));
|
|
1167
1219
|
}
|
|
1168
1220
|
/**
|
|
1169
1221
|
* Hard-delete a webhook. Historical `webhook_deliveries` rows are retained
|
|
@@ -1177,7 +1229,7 @@ var WebhooksResource = class {
|
|
|
1177
1229
|
*/
|
|
1178
1230
|
async remove(params) {
|
|
1179
1231
|
validateRequired("id", params.id);
|
|
1180
|
-
return this.http.post("/v1/actions/store/remove-webhook", params);
|
|
1232
|
+
return unwrapAction(await this.http.post("/v1/actions/store/remove-webhook", params));
|
|
1181
1233
|
}
|
|
1182
1234
|
/**
|
|
1183
1235
|
* Verify and parse an incoming webhook event.
|