@waffo/pancake-ts 0.2.0 → 0.2.1
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 +16 -0
- package/dist/index.cjs +159 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -8
- package/dist/index.d.ts +17 -8
- package/dist/index.js +159 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -150,11 +150,14 @@ declare enum PaymentStatus {
|
|
|
150
150
|
*/
|
|
151
151
|
declare enum RefundTicketStatus {
|
|
152
152
|
Pending = "pending",
|
|
153
|
+
UnderReview = "under_review",
|
|
153
154
|
Approved = "approved",
|
|
154
155
|
Rejected = "rejected",
|
|
156
|
+
Returned = "returned",
|
|
155
157
|
Processing = "processing",
|
|
156
158
|
Succeeded = "succeeded",
|
|
157
|
-
Failed = "failed"
|
|
159
|
+
Failed = "failed",
|
|
160
|
+
Cancelled = "cancelled"
|
|
158
161
|
}
|
|
159
162
|
/**
|
|
160
163
|
* Refund status.
|
|
@@ -191,7 +194,9 @@ declare enum ErrorLayer {
|
|
|
191
194
|
GraphQL = "graphql",
|
|
192
195
|
Resource = "resource",
|
|
193
196
|
/** SDK-specific layer for email delivery errors (not part of the service-side error layers). */
|
|
194
|
-
Email = "email"
|
|
197
|
+
Email = "email",
|
|
198
|
+
/** SDK-side input validation (caught before network request). */
|
|
199
|
+
Sdk = "sdk"
|
|
195
200
|
}
|
|
196
201
|
/**
|
|
197
202
|
* Parameters for issuing a buyer session token.
|
|
@@ -367,7 +372,7 @@ interface UpdateRoleResult {
|
|
|
367
372
|
*
|
|
368
373
|
* @example
|
|
369
374
|
* // JPY ¥1000
|
|
370
|
-
* { amount: 1000, taxCategory: "software" }
|
|
375
|
+
* { amount: "1000", taxCategory: "software" }
|
|
371
376
|
*/
|
|
372
377
|
interface PriceInfo {
|
|
373
378
|
/** Price amount as display string (e.g., "9.99" for USD, "1000" for JPY) */
|
|
@@ -383,7 +388,7 @@ interface PriceInfo {
|
|
|
383
388
|
* @example
|
|
384
389
|
* {
|
|
385
390
|
* "USD": { amount: "9.99", taxCategory: "saas" },
|
|
386
|
-
* "EUR": { amount:
|
|
391
|
+
* "EUR": { amount: "8.99", taxCategory: "saas" }
|
|
387
392
|
* }
|
|
388
393
|
*/
|
|
389
394
|
type Prices = Record<string, PriceInfo>;
|
|
@@ -710,7 +715,7 @@ interface RefundTicket {
|
|
|
710
715
|
/** Submitter type (e.g., `"customer"`, `"merchant"`) */
|
|
711
716
|
submitterType: string;
|
|
712
717
|
/** Current version ID */
|
|
713
|
-
currentVersionId: string;
|
|
718
|
+
currentVersionId: string | null;
|
|
714
719
|
/** Reviewer ID (null if not yet reviewed) */
|
|
715
720
|
reviewerId: string | null;
|
|
716
721
|
/** Review timestamp (ISO 8601, null if not yet reviewed) */
|
|
@@ -724,9 +729,13 @@ interface RefundTicket {
|
|
|
724
729
|
/** Custom metadata */
|
|
725
730
|
metadata: Record<string, unknown>;
|
|
726
731
|
/** Current version number */
|
|
727
|
-
versionNumber: number;
|
|
732
|
+
versionNumber: number | null;
|
|
728
733
|
/** Current version data (includes reason, amount, etc.) */
|
|
729
|
-
versionData: Record<string, unknown
|
|
734
|
+
versionData: Record<string, unknown> | null;
|
|
735
|
+
/** Creation timestamp (ISO 8601) */
|
|
736
|
+
createdAt: string;
|
|
737
|
+
/** Last update timestamp (ISO 8601) */
|
|
738
|
+
updatedAt: string;
|
|
730
739
|
}
|
|
731
740
|
/**
|
|
732
741
|
* Parameters for anonymous checkout.
|
|
@@ -898,7 +907,7 @@ interface WebhookEventData {
|
|
|
898
907
|
* eventId: "PAY_5xK9mRtYvWnPqLsJ3hBfDe",
|
|
899
908
|
* storeId: "STO_2aUyqjCzEIiEcYMKj7TZtw",
|
|
900
909
|
* mode: "prod",
|
|
901
|
-
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount:
|
|
910
|
+
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: "29.00", taxAmount: "2.90", productName: "Pro Plan" }
|
|
902
911
|
* }
|
|
903
912
|
*/
|
|
904
913
|
interface WebhookEvent<T = WebhookEventData> {
|
package/dist/index.d.ts
CHANGED
|
@@ -150,11 +150,14 @@ declare enum PaymentStatus {
|
|
|
150
150
|
*/
|
|
151
151
|
declare enum RefundTicketStatus {
|
|
152
152
|
Pending = "pending",
|
|
153
|
+
UnderReview = "under_review",
|
|
153
154
|
Approved = "approved",
|
|
154
155
|
Rejected = "rejected",
|
|
156
|
+
Returned = "returned",
|
|
155
157
|
Processing = "processing",
|
|
156
158
|
Succeeded = "succeeded",
|
|
157
|
-
Failed = "failed"
|
|
159
|
+
Failed = "failed",
|
|
160
|
+
Cancelled = "cancelled"
|
|
158
161
|
}
|
|
159
162
|
/**
|
|
160
163
|
* Refund status.
|
|
@@ -191,7 +194,9 @@ declare enum ErrorLayer {
|
|
|
191
194
|
GraphQL = "graphql",
|
|
192
195
|
Resource = "resource",
|
|
193
196
|
/** SDK-specific layer for email delivery errors (not part of the service-side error layers). */
|
|
194
|
-
Email = "email"
|
|
197
|
+
Email = "email",
|
|
198
|
+
/** SDK-side input validation (caught before network request). */
|
|
199
|
+
Sdk = "sdk"
|
|
195
200
|
}
|
|
196
201
|
/**
|
|
197
202
|
* Parameters for issuing a buyer session token.
|
|
@@ -367,7 +372,7 @@ interface UpdateRoleResult {
|
|
|
367
372
|
*
|
|
368
373
|
* @example
|
|
369
374
|
* // JPY ¥1000
|
|
370
|
-
* { amount: 1000, taxCategory: "software" }
|
|
375
|
+
* { amount: "1000", taxCategory: "software" }
|
|
371
376
|
*/
|
|
372
377
|
interface PriceInfo {
|
|
373
378
|
/** Price amount as display string (e.g., "9.99" for USD, "1000" for JPY) */
|
|
@@ -383,7 +388,7 @@ interface PriceInfo {
|
|
|
383
388
|
* @example
|
|
384
389
|
* {
|
|
385
390
|
* "USD": { amount: "9.99", taxCategory: "saas" },
|
|
386
|
-
* "EUR": { amount:
|
|
391
|
+
* "EUR": { amount: "8.99", taxCategory: "saas" }
|
|
387
392
|
* }
|
|
388
393
|
*/
|
|
389
394
|
type Prices = Record<string, PriceInfo>;
|
|
@@ -710,7 +715,7 @@ interface RefundTicket {
|
|
|
710
715
|
/** Submitter type (e.g., `"customer"`, `"merchant"`) */
|
|
711
716
|
submitterType: string;
|
|
712
717
|
/** Current version ID */
|
|
713
|
-
currentVersionId: string;
|
|
718
|
+
currentVersionId: string | null;
|
|
714
719
|
/** Reviewer ID (null if not yet reviewed) */
|
|
715
720
|
reviewerId: string | null;
|
|
716
721
|
/** Review timestamp (ISO 8601, null if not yet reviewed) */
|
|
@@ -724,9 +729,13 @@ interface RefundTicket {
|
|
|
724
729
|
/** Custom metadata */
|
|
725
730
|
metadata: Record<string, unknown>;
|
|
726
731
|
/** Current version number */
|
|
727
|
-
versionNumber: number;
|
|
732
|
+
versionNumber: number | null;
|
|
728
733
|
/** Current version data (includes reason, amount, etc.) */
|
|
729
|
-
versionData: Record<string, unknown
|
|
734
|
+
versionData: Record<string, unknown> | null;
|
|
735
|
+
/** Creation timestamp (ISO 8601) */
|
|
736
|
+
createdAt: string;
|
|
737
|
+
/** Last update timestamp (ISO 8601) */
|
|
738
|
+
updatedAt: string;
|
|
730
739
|
}
|
|
731
740
|
/**
|
|
732
741
|
* Parameters for anonymous checkout.
|
|
@@ -898,7 +907,7 @@ interface WebhookEventData {
|
|
|
898
907
|
* eventId: "PAY_5xK9mRtYvWnPqLsJ3hBfDe",
|
|
899
908
|
* storeId: "STO_2aUyqjCzEIiEcYMKj7TZtw",
|
|
900
909
|
* mode: "prod",
|
|
901
|
-
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount:
|
|
910
|
+
* data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: "29.00", taxAmount: "2.90", productName: "Pro Plan" }
|
|
902
911
|
* }
|
|
903
912
|
*/
|
|
904
913
|
interface WebhookEvent<T = WebhookEventData> {
|
package/dist/index.js
CHANGED
|
@@ -210,6 +210,105 @@ var HttpClient = class {
|
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
+
// src/validation.ts
|
|
214
|
+
var SHORT_ID_REGEX = /^[A-Z]{2,4}_[A-Za-z0-9]+$/;
|
|
215
|
+
var CURRENCY_CODE_REGEX = /^[A-Z]{3}$/;
|
|
216
|
+
var COUNTRY_CODE_REGEX = /^[A-Z]{2}$/;
|
|
217
|
+
var AMOUNT_STRING_REGEX = /^\d+(\.\d+)?$/;
|
|
218
|
+
var SHORT_ID_LABELS = {
|
|
219
|
+
STO: "Store",
|
|
220
|
+
PROD: "Product",
|
|
221
|
+
ORD: "Order",
|
|
222
|
+
PAY: "Payment",
|
|
223
|
+
REF: "Refund",
|
|
224
|
+
TKT: "Ticket",
|
|
225
|
+
MER: "Merchant"
|
|
226
|
+
};
|
|
227
|
+
function fail(message) {
|
|
228
|
+
throw new WaffoPancakeError(400, [{ message, layer: "sdk" }]);
|
|
229
|
+
}
|
|
230
|
+
function validateRequired(field, value) {
|
|
231
|
+
if (value === void 0 || value === null) {
|
|
232
|
+
fail(`Missing required field: ${field}`);
|
|
233
|
+
}
|
|
234
|
+
if (typeof value === "string" && value.trim() === "") {
|
|
235
|
+
fail(`${field} cannot be empty`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function validateShortId(field, value, prefix) {
|
|
239
|
+
validateRequired(field, value);
|
|
240
|
+
const label = SHORT_ID_LABELS[prefix] ?? prefix;
|
|
241
|
+
if (!SHORT_ID_REGEX.test(value)) {
|
|
242
|
+
fail(`Invalid ${field}: expected ${label} Short ID format (${prefix}_xxx), got "${value}"`);
|
|
243
|
+
}
|
|
244
|
+
if (!value.startsWith(`${prefix}_`)) {
|
|
245
|
+
fail(`Invalid ${field}: expected ${prefix}_ prefix (${label}), got "${value.split("_")[0]}_"`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function validateCurrencyCode(field, value) {
|
|
249
|
+
validateRequired(field, value);
|
|
250
|
+
if (!CURRENCY_CODE_REGEX.test(value)) {
|
|
251
|
+
fail(`Invalid ${field}: expected 3-letter ISO 4217 currency code (e.g., "USD"), got "${value}"`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function validateAmountString(field, value) {
|
|
255
|
+
validateRequired(field, value);
|
|
256
|
+
if (!AMOUNT_STRING_REGEX.test(value)) {
|
|
257
|
+
fail(`Invalid ${field}: expected numeric string in display format (e.g., "9.99", "1000"), got "${value}"`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function validateEnum(field, value, allowed) {
|
|
261
|
+
validateRequired(field, value);
|
|
262
|
+
if (!allowed.includes(value)) {
|
|
263
|
+
fail(`Invalid ${field}: expected one of [${allowed.join(", ")}], got "${value}"`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function validatePositiveInteger(field, value) {
|
|
267
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
268
|
+
fail(`Invalid ${field}: expected positive integer, got ${value}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function validateCountryCode(field, value) {
|
|
272
|
+
validateRequired(field, value);
|
|
273
|
+
if (!COUNTRY_CODE_REGEX.test(value)) {
|
|
274
|
+
fail(`Invalid ${field}: expected 2-letter ISO 3166-1 country code (e.g., "US"), got "${value}"`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function validatePrices(field, prices) {
|
|
278
|
+
validateRequired(field, prices);
|
|
279
|
+
const entries = Object.entries(prices);
|
|
280
|
+
if (entries.length === 0) {
|
|
281
|
+
fail(`${field} must contain at least one currency`);
|
|
282
|
+
}
|
|
283
|
+
for (const [currency, info] of entries) {
|
|
284
|
+
validateCurrencyCode(`${field}.${currency} (key)`, currency);
|
|
285
|
+
validateAmountString(`${field}.${currency}.amount`, info.amount);
|
|
286
|
+
validateRequired(`${field}.${currency}.taxCategory`, info.taxCategory);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function validateBillingDetail(detail) {
|
|
290
|
+
validateCountryCode("billingDetail.country", detail.country);
|
|
291
|
+
if (typeof detail.isBusiness !== "boolean") {
|
|
292
|
+
fail(`Invalid billingDetail.isBusiness: expected boolean, got ${typeof detail.isBusiness}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function validateCheckoutCommon(params) {
|
|
296
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
297
|
+
validateShortId("productId", params.productId, "PROD");
|
|
298
|
+
validateEnum("productType", params.productType, ["onetime", "subscription"]);
|
|
299
|
+
validateCurrencyCode("currency", params.currency);
|
|
300
|
+
if (params.priceSnapshot) {
|
|
301
|
+
validateAmountString("priceSnapshot.amount", params.priceSnapshot.amount);
|
|
302
|
+
validateRequired("priceSnapshot.taxCategory", params.priceSnapshot.taxCategory);
|
|
303
|
+
}
|
|
304
|
+
if (params.billingDetail) {
|
|
305
|
+
validateBillingDetail(params.billingDetail);
|
|
306
|
+
}
|
|
307
|
+
if (params.expiresInSeconds !== void 0) {
|
|
308
|
+
validatePositiveInteger("expiresInSeconds", params.expiresInSeconds);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
213
312
|
// src/resources/auth.ts
|
|
214
313
|
var AuthResource = class {
|
|
215
314
|
constructor(http) {
|
|
@@ -228,6 +327,8 @@ var AuthResource = class {
|
|
|
228
327
|
* });
|
|
229
328
|
*/
|
|
230
329
|
async issueSessionToken(params) {
|
|
330
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
331
|
+
validateRequired("buyerIdentity", params.buyerIdentity);
|
|
231
332
|
return this.http.post("/v1/actions/auth/issue-session-token", params);
|
|
232
333
|
}
|
|
233
334
|
};
|
|
@@ -251,6 +352,7 @@ var BuyerSession = class {
|
|
|
251
352
|
* // status: "canceled" (was pending) or "canceling" (was active)
|
|
252
353
|
*/
|
|
253
354
|
async cancelSubscription(params) {
|
|
355
|
+
validateShortId("orderId", params.orderId, "ORD");
|
|
254
356
|
return this.http.post(
|
|
255
357
|
"/v1/actions/subscription-order/cancel-order",
|
|
256
358
|
params
|
|
@@ -266,6 +368,7 @@ var BuyerSession = class {
|
|
|
266
368
|
* const { orderId, status } = await buyer.cancelOnetimeOrder({ orderId: "ORD_xxx" });
|
|
267
369
|
*/
|
|
268
370
|
async cancelOnetimeOrder(params) {
|
|
371
|
+
validateShortId("orderId", params.orderId, "ORD");
|
|
269
372
|
return this.http.post(
|
|
270
373
|
"/v1/actions/onetime-order/cancel-order",
|
|
271
374
|
params
|
|
@@ -282,6 +385,7 @@ var BuyerSession = class {
|
|
|
282
385
|
* // status: "active"
|
|
283
386
|
*/
|
|
284
387
|
async reactivateSubscription(params) {
|
|
388
|
+
validateShortId("orderId", params.orderId, "ORD");
|
|
285
389
|
return this.http.post(
|
|
286
390
|
"/v1/actions/subscription-order/reactivate-order",
|
|
287
391
|
params
|
|
@@ -301,6 +405,10 @@ var BuyerSession = class {
|
|
|
301
405
|
* });
|
|
302
406
|
*/
|
|
303
407
|
async createRefundTicket(params) {
|
|
408
|
+
validateShortId("paymentId", params.paymentId, "PAY");
|
|
409
|
+
validateRequired("reason", params.reason);
|
|
410
|
+
validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
|
|
411
|
+
validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
|
|
304
412
|
return this.http.post(
|
|
305
413
|
"/v1/actions/refund-ticket/create-ticket",
|
|
306
414
|
params
|
|
@@ -321,6 +429,11 @@ var BuyerSession = class {
|
|
|
321
429
|
* });
|
|
322
430
|
*/
|
|
323
431
|
async resubmitRefundTicket(params) {
|
|
432
|
+
validateShortId("ticketId", params.ticketId, "TKT");
|
|
433
|
+
validateShortId("paymentId", params.paymentId, "PAY");
|
|
434
|
+
validateRequired("reason", params.reason);
|
|
435
|
+
validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
|
|
436
|
+
validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
|
|
324
437
|
return this.http.post(
|
|
325
438
|
"/v1/actions/refund-ticket/resubmit-ticket",
|
|
326
439
|
params
|
|
@@ -343,6 +456,7 @@ var BuyerGraphQL = class {
|
|
|
343
456
|
* });
|
|
344
457
|
*/
|
|
345
458
|
async query(params) {
|
|
459
|
+
validateRequired("query", params.query);
|
|
346
460
|
return this.http.post("/v1/graphql", params);
|
|
347
461
|
}
|
|
348
462
|
};
|
|
@@ -368,6 +482,7 @@ var CheckoutAnonymousResource = class {
|
|
|
368
482
|
* // Redirect to result.checkoutUrl
|
|
369
483
|
*/
|
|
370
484
|
async create(params) {
|
|
485
|
+
validateCheckoutCommon(params);
|
|
371
486
|
return this.http.post(
|
|
372
487
|
"/v1/actions/checkout/create-session",
|
|
373
488
|
params
|
|
@@ -403,6 +518,8 @@ var CheckoutAuthenticatedResource = class {
|
|
|
403
518
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
404
519
|
*/
|
|
405
520
|
async create(params) {
|
|
521
|
+
validateCheckoutCommon(params);
|
|
522
|
+
validateRequired("buyerIdentity", params.buyerIdentity);
|
|
406
523
|
const { buyerIdentity, buyerEmail, ...sessionFields } = params;
|
|
407
524
|
const [tokenResult, sessionResult] = await Promise.all([
|
|
408
525
|
this.http.post("/v1/actions/auth/issue-session-token", {
|
|
@@ -483,6 +600,7 @@ var GraphQLResource = class {
|
|
|
483
600
|
* });
|
|
484
601
|
*/
|
|
485
602
|
async query(params) {
|
|
603
|
+
validateRequired("query", params.query);
|
|
486
604
|
return this.http.post("/v1/graphql", params);
|
|
487
605
|
}
|
|
488
606
|
};
|
|
@@ -506,6 +624,9 @@ var OnetimeProductsResource = class {
|
|
|
506
624
|
* });
|
|
507
625
|
*/
|
|
508
626
|
async create(params) {
|
|
627
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
628
|
+
validateRequired("name", params.name);
|
|
629
|
+
validatePrices("prices", params.prices);
|
|
509
630
|
return this.http.post("/v1/actions/onetime-product/create-product", params);
|
|
510
631
|
}
|
|
511
632
|
/**
|
|
@@ -522,6 +643,9 @@ var OnetimeProductsResource = class {
|
|
|
522
643
|
* });
|
|
523
644
|
*/
|
|
524
645
|
async update(params) {
|
|
646
|
+
validateShortId("id", params.id, "PROD");
|
|
647
|
+
validateRequired("name", params.name);
|
|
648
|
+
validatePrices("prices", params.prices);
|
|
525
649
|
return this.http.post("/v1/actions/onetime-product/update-product", params);
|
|
526
650
|
}
|
|
527
651
|
/**
|
|
@@ -534,6 +658,7 @@ var OnetimeProductsResource = class {
|
|
|
534
658
|
* const { product } = await client.onetimeProducts.publish({ id: "PROD_xxx" });
|
|
535
659
|
*/
|
|
536
660
|
async publish(params) {
|
|
661
|
+
validateShortId("id", params.id, "PROD");
|
|
537
662
|
return this.http.post("/v1/actions/onetime-product/publish-product", params);
|
|
538
663
|
}
|
|
539
664
|
/**
|
|
@@ -549,6 +674,8 @@ var OnetimeProductsResource = class {
|
|
|
549
674
|
* });
|
|
550
675
|
*/
|
|
551
676
|
async updateStatus(params) {
|
|
677
|
+
validateShortId("id", params.id, "PROD");
|
|
678
|
+
validateEnum("status", params.status, ["active", "inactive"]);
|
|
552
679
|
return this.http.post("/v1/actions/onetime-product/update-status", params);
|
|
553
680
|
}
|
|
554
681
|
};
|
|
@@ -574,6 +701,7 @@ var OrdersResource = class {
|
|
|
574
701
|
* // status: "canceled" or "canceling"
|
|
575
702
|
*/
|
|
576
703
|
async cancelSubscription(params) {
|
|
704
|
+
validateShortId("orderId", params.orderId, "ORD");
|
|
577
705
|
return this.http.post("/v1/actions/subscription-order/cancel-order", params);
|
|
578
706
|
}
|
|
579
707
|
};
|
|
@@ -597,6 +725,9 @@ var StoreMerchantsResource = class {
|
|
|
597
725
|
* });
|
|
598
726
|
*/
|
|
599
727
|
async add(params) {
|
|
728
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
729
|
+
validateRequired("email", params.email);
|
|
730
|
+
validateEnum("role", params.role, ["admin", "member"]);
|
|
600
731
|
return this.http.post("/v1/actions/store-merchant/add-merchant", params);
|
|
601
732
|
}
|
|
602
733
|
/**
|
|
@@ -612,6 +743,8 @@ var StoreMerchantsResource = class {
|
|
|
612
743
|
* });
|
|
613
744
|
*/
|
|
614
745
|
async remove(params) {
|
|
746
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
747
|
+
validateShortId("merchantId", params.merchantId, "MER");
|
|
615
748
|
return this.http.post("/v1/actions/store-merchant/remove-merchant", params);
|
|
616
749
|
}
|
|
617
750
|
/**
|
|
@@ -628,6 +761,9 @@ var StoreMerchantsResource = class {
|
|
|
628
761
|
* });
|
|
629
762
|
*/
|
|
630
763
|
async updateRole(params) {
|
|
764
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
765
|
+
validateShortId("merchantId", params.merchantId, "MER");
|
|
766
|
+
validateEnum("role", params.role, ["admin", "member"]);
|
|
631
767
|
return this.http.post("/v1/actions/store-merchant/update-role", params);
|
|
632
768
|
}
|
|
633
769
|
};
|
|
@@ -647,6 +783,7 @@ var StoresResource = class {
|
|
|
647
783
|
* const { store } = await client.stores.create({ name: "My Store" });
|
|
648
784
|
*/
|
|
649
785
|
async create(params) {
|
|
786
|
+
validateRequired("name", params.name);
|
|
650
787
|
return this.http.post("/v1/actions/store/create-store", params);
|
|
651
788
|
}
|
|
652
789
|
/**
|
|
@@ -662,6 +799,7 @@ var StoresResource = class {
|
|
|
662
799
|
* });
|
|
663
800
|
*/
|
|
664
801
|
async update(params) {
|
|
802
|
+
validateShortId("id", params.id, "STO");
|
|
665
803
|
return this.http.post("/v1/actions/store/update-store", params);
|
|
666
804
|
}
|
|
667
805
|
/**
|
|
@@ -674,6 +812,7 @@ var StoresResource = class {
|
|
|
674
812
|
* const { store } = await client.stores.delete({ id: "STO_xxx" });
|
|
675
813
|
*/
|
|
676
814
|
async delete(params) {
|
|
815
|
+
validateShortId("id", params.id, "STO");
|
|
677
816
|
return this.http.post("/v1/actions/store/delete-store", params);
|
|
678
817
|
}
|
|
679
818
|
};
|
|
@@ -698,6 +837,8 @@ var SubscriptionProductGroupsResource = class {
|
|
|
698
837
|
* });
|
|
699
838
|
*/
|
|
700
839
|
async create(params) {
|
|
840
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
841
|
+
validateRequired("name", params.name);
|
|
701
842
|
return this.http.post("/v1/actions/subscription-product-group/create-group", params);
|
|
702
843
|
}
|
|
703
844
|
/**
|
|
@@ -713,6 +854,7 @@ var SubscriptionProductGroupsResource = class {
|
|
|
713
854
|
* });
|
|
714
855
|
*/
|
|
715
856
|
async update(params) {
|
|
857
|
+
validateRequired("id", params.id);
|
|
716
858
|
return this.http.post("/v1/actions/subscription-product-group/update-group", params);
|
|
717
859
|
}
|
|
718
860
|
/**
|
|
@@ -725,6 +867,7 @@ var SubscriptionProductGroupsResource = class {
|
|
|
725
867
|
* const { group } = await client.subscriptionProductGroups.delete({ id: "GRP_xxx" });
|
|
726
868
|
*/
|
|
727
869
|
async delete(params) {
|
|
870
|
+
validateRequired("id", params.id);
|
|
728
871
|
return this.http.post("/v1/actions/subscription-product-group/delete-group", params);
|
|
729
872
|
}
|
|
730
873
|
/**
|
|
@@ -737,6 +880,7 @@ var SubscriptionProductGroupsResource = class {
|
|
|
737
880
|
* const { group } = await client.subscriptionProductGroups.publish({ id: "GRP_xxx" });
|
|
738
881
|
*/
|
|
739
882
|
async publish(params) {
|
|
883
|
+
validateRequired("id", params.id);
|
|
740
884
|
return this.http.post("/v1/actions/subscription-product-group/publish-group", params);
|
|
741
885
|
}
|
|
742
886
|
};
|
|
@@ -761,6 +905,10 @@ var SubscriptionProductsResource = class {
|
|
|
761
905
|
* });
|
|
762
906
|
*/
|
|
763
907
|
async create(params) {
|
|
908
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
909
|
+
validateRequired("name", params.name);
|
|
910
|
+
validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
|
|
911
|
+
validatePrices("prices", params.prices);
|
|
764
912
|
return this.http.post("/v1/actions/subscription-product/create-product", params);
|
|
765
913
|
}
|
|
766
914
|
/**
|
|
@@ -778,6 +926,10 @@ var SubscriptionProductsResource = class {
|
|
|
778
926
|
* });
|
|
779
927
|
*/
|
|
780
928
|
async update(params) {
|
|
929
|
+
validateShortId("id", params.id, "PROD");
|
|
930
|
+
validateRequired("name", params.name);
|
|
931
|
+
validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
|
|
932
|
+
validatePrices("prices", params.prices);
|
|
781
933
|
return this.http.post("/v1/actions/subscription-product/update-product", params);
|
|
782
934
|
}
|
|
783
935
|
/**
|
|
@@ -790,6 +942,7 @@ var SubscriptionProductsResource = class {
|
|
|
790
942
|
* const { product } = await client.subscriptionProducts.publish({ id: "PROD_xxx" });
|
|
791
943
|
*/
|
|
792
944
|
async publish(params) {
|
|
945
|
+
validateShortId("id", params.id, "PROD");
|
|
793
946
|
return this.http.post("/v1/actions/subscription-product/publish-product", params);
|
|
794
947
|
}
|
|
795
948
|
/**
|
|
@@ -805,6 +958,8 @@ var SubscriptionProductsResource = class {
|
|
|
805
958
|
* });
|
|
806
959
|
*/
|
|
807
960
|
async updateStatus(params) {
|
|
961
|
+
validateShortId("id", params.id, "PROD");
|
|
962
|
+
validateEnum("status", params.status, ["active", "inactive"]);
|
|
808
963
|
return this.http.post("/v1/actions/subscription-product/update-status", params);
|
|
809
964
|
}
|
|
810
965
|
};
|
|
@@ -1073,11 +1228,14 @@ var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
|
|
|
1073
1228
|
})(PaymentStatus || {});
|
|
1074
1229
|
var RefundTicketStatus = /* @__PURE__ */ ((RefundTicketStatus2) => {
|
|
1075
1230
|
RefundTicketStatus2["Pending"] = "pending";
|
|
1231
|
+
RefundTicketStatus2["UnderReview"] = "under_review";
|
|
1076
1232
|
RefundTicketStatus2["Approved"] = "approved";
|
|
1077
1233
|
RefundTicketStatus2["Rejected"] = "rejected";
|
|
1234
|
+
RefundTicketStatus2["Returned"] = "returned";
|
|
1078
1235
|
RefundTicketStatus2["Processing"] = "processing";
|
|
1079
1236
|
RefundTicketStatus2["Succeeded"] = "succeeded";
|
|
1080
1237
|
RefundTicketStatus2["Failed"] = "failed";
|
|
1238
|
+
RefundTicketStatus2["Cancelled"] = "cancelled";
|
|
1081
1239
|
return RefundTicketStatus2;
|
|
1082
1240
|
})(RefundTicketStatus || {});
|
|
1083
1241
|
var RefundStatus = /* @__PURE__ */ ((RefundStatus2) => {
|
|
@@ -1105,6 +1263,7 @@ var ErrorLayer = /* @__PURE__ */ ((ErrorLayer2) => {
|
|
|
1105
1263
|
ErrorLayer2["GraphQL"] = "graphql";
|
|
1106
1264
|
ErrorLayer2["Resource"] = "resource";
|
|
1107
1265
|
ErrorLayer2["Email"] = "email";
|
|
1266
|
+
ErrorLayer2["Sdk"] = "sdk";
|
|
1108
1267
|
return ErrorLayer2;
|
|
1109
1268
|
})(ErrorLayer || {});
|
|
1110
1269
|
var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|