@waffo/pancake-ts 0.11.0 → 0.13.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
@@ -11,9 +11,9 @@ var WaffoPancakeError = class extends Error {
11
11
  }
12
12
  };
13
13
 
14
- // src/buyer-http-client.ts
14
+ // src/customer-http-client.ts
15
15
  var DEFAULT_BASE_URL = "https://api.waffo.ai";
16
- var BuyerHttpClient = class {
16
+ var CustomerHttpClient = class {
17
17
  token;
18
18
  baseUrl;
19
19
  _fetch;
@@ -327,7 +327,7 @@ var AuthResource = class {
327
327
  this.http = http;
328
328
  }
329
329
  /**
330
- * Issue a session token for a buyer.
330
+ * Issue a session token for a customer.
331
331
  *
332
332
  * @param params - Token issuance parameters
333
333
  * @returns Issued session token with expiration
@@ -361,122 +361,6 @@ var AuthResource = class {
361
361
  }
362
362
  };
363
363
 
364
- // src/resources/buyer.ts
365
- var BuyerSession = class {
366
- constructor(http) {
367
- this.http = http;
368
- this.graphql = new BuyerGraphQL(http);
369
- }
370
- /** GraphQL query access scoped to the buyer's data. */
371
- graphql;
372
- /**
373
- * Cancel a subscription order.
374
- *
375
- * @param params - Order to cancel
376
- * @returns Order ID and resulting status
377
- *
378
- * @example
379
- * const { orderId, status } = await buyer.cancelSubscription({ orderId: "ORD_xxx" });
380
- * // status: "canceled" (was pending) or "canceling" (was active)
381
- */
382
- async cancelSubscription(params) {
383
- validateShortId("orderId", params.orderId, "ORD");
384
- return unwrapAction(await this.http.post("/v1/actions/subscription-order/cancel-order", params));
385
- }
386
- /**
387
- * Cancel a one-time order (only while payment is still pending).
388
- *
389
- * @param params - Order to cancel
390
- * @returns Order ID and resulting status
391
- *
392
- * @example
393
- * const { orderId, status } = await buyer.cancelOnetimeOrder({ orderId: "ORD_xxx" });
394
- */
395
- async cancelOnetimeOrder(params) {
396
- validateShortId("orderId", params.orderId, "ORD");
397
- return unwrapAction(await this.http.post("/v1/actions/onetime-order/cancel-order", params));
398
- }
399
- /**
400
- * Reactivate a subscription that is in `canceling` status.
401
- *
402
- * @param params - Order to reactivate
403
- * @returns Order ID and resulting status
404
- *
405
- * @example
406
- * const { orderId, status } = await buyer.reactivateSubscription({ orderId: "ORD_xxx" });
407
- * // status: "active"
408
- */
409
- async reactivateSubscription(params) {
410
- validateShortId("orderId", params.orderId, "ORD");
411
- return unwrapAction(await this.http.post("/v1/actions/subscription-order/reactivate-order", params));
412
- }
413
- /**
414
- * Submit a refund request for a payment.
415
- *
416
- * @param params - Refund ticket details
417
- * @returns Created refund ticket
418
- *
419
- * @example
420
- * const { ticket } = await buyer.createRefundTicket({
421
- * paymentId: "PAY_xxx",
422
- * reason: "Product not as described",
423
- * requestedAmount: { amount: "29.00", currency: "USD" },
424
- * refundTicketMerchantExternalId: "REF-2026-00891",
425
- * });
426
- */
427
- async createRefundTicket(params) {
428
- validateShortId("paymentId", params.paymentId, "PAY");
429
- validateRequired("reason", params.reason);
430
- validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
431
- validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
432
- validateMaxLength("refundTicketMerchantExternalId", params.refundTicketMerchantExternalId, 128);
433
- return unwrapAction(await this.http.post("/v1/actions/refund-ticket/create-ticket", params));
434
- }
435
- /**
436
- * Resubmit a previously rejected refund ticket with updated details.
437
- *
438
- * @param params - Updated ticket details
439
- * @returns Updated refund ticket
440
- *
441
- * @example
442
- * const { ticket } = await buyer.resubmitRefundTicket({
443
- * ticketId: "TKT_xxx",
444
- * paymentId: "PAY_xxx",
445
- * reason: "Updated reason with more detail",
446
- * requestedAmount: { amount: "29.00", currency: "USD" },
447
- * });
448
- */
449
- async resubmitRefundTicket(params) {
450
- validateShortId("ticketId", params.ticketId, "TKT");
451
- validateShortId("paymentId", params.paymentId, "PAY");
452
- validateRequired("reason", params.reason);
453
- validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
454
- validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
455
- return unwrapAction(await this.http.post("/v1/actions/refund-ticket/resubmit-ticket", params));
456
- }
457
- };
458
- var BuyerGraphQL = class {
459
- constructor(http) {
460
- this.http = http;
461
- }
462
- /**
463
- * Execute a GraphQL query scoped to the buyer's data.
464
- *
465
- * @param params - GraphQL query and variables
466
- * @returns GraphQL response
467
- *
468
- * @example
469
- * const result = await buyer.graphql.query({
470
- * query: `query { orders { id status } }`,
471
- * });
472
- */
473
- async query(params) {
474
- validateRequired("query", params.query);
475
- const result = await this.http.post("/v1/graphql", params);
476
- return { data: result.data, errors: result.errors, warnings: result.warnings };
477
- }
478
- };
479
-
480
364
  // src/resources/checkout-anonymous.ts
481
365
  var CheckoutAnonymousResource = class {
482
366
  constructor(http) {
@@ -485,11 +369,11 @@ var CheckoutAnonymousResource = class {
485
369
  /**
486
370
  * Create an anonymous checkout session.
487
371
  *
488
- * @param params - Checkout parameters (no buyer identity required)
372
+ * @param params - Checkout parameters (no customer identity required)
489
373
  * @returns Session ID, checkout URL, and expiration
490
374
  *
491
375
  * @example
492
- * // Minimal — buyer fills everything on the page
376
+ * // Minimal — customer fills everything on the page
493
377
  * const result = await client.checkout.anonymous.create({
494
378
  * productId: "PROD_xxx",
495
379
  * currency: "USD",
@@ -529,7 +413,7 @@ var CheckoutAuthenticatedResource = class {
529
413
  * `buyerIdentity` and `buyerEmail` are independent inputs: identity is for the JWT,
530
414
  * email is for pre-filling the checkout page. The SDK forwards each to its own endpoint.
531
415
  *
532
- * @param params - Checkout parameters including buyer identity
416
+ * @param params - Checkout parameters including customer identity
533
417
  * @returns Session details with token-appended checkout URL
534
418
  *
535
419
  * @example
@@ -578,9 +462,9 @@ var CheckoutResource = class {
578
462
  this.anonymous = new CheckoutAnonymousResource(http);
579
463
  this.authenticated = new CheckoutAuthenticatedResource(http);
580
464
  }
581
- /** Anonymous checkout — no buyer identity, empty form. */
465
+ /** Anonymous checkout — no customer identity, empty form. */
582
466
  anonymous;
583
- /** Authenticated checkout — merchant provides buyer identity. */
467
+ /** Authenticated checkout — merchant provides customer identity. */
584
468
  authenticated;
585
469
  /**
586
470
  * Create a checkout session (low-level). Returns a URL to redirect the customer to.
@@ -606,6 +490,122 @@ var CheckoutResource = class {
606
490
  }
607
491
  };
608
492
 
493
+ // src/resources/customer.ts
494
+ var CustomerSession = class {
495
+ constructor(http) {
496
+ this.http = http;
497
+ this.graphql = new CustomerGraphQL(http);
498
+ }
499
+ /** GraphQL query access scoped to the customer's data. */
500
+ graphql;
501
+ /**
502
+ * Cancel a subscription order.
503
+ *
504
+ * @param params - Order to cancel
505
+ * @returns Order ID and resulting status
506
+ *
507
+ * @example
508
+ * const { orderId, status } = await customer.cancelSubscription({ orderId: "ORD_xxx" });
509
+ * // status: "canceled" (was pending) or "canceling" (was active)
510
+ */
511
+ async cancelSubscription(params) {
512
+ validateShortId("orderId", params.orderId, "ORD");
513
+ return unwrapAction(await this.http.post("/v1/actions/subscription-order/cancel-order", params));
514
+ }
515
+ /**
516
+ * Cancel a one-time order (only while payment is still pending).
517
+ *
518
+ * @param params - Order to cancel
519
+ * @returns Order ID and resulting status
520
+ *
521
+ * @example
522
+ * const { orderId, status } = await customer.cancelOnetimeOrder({ orderId: "ORD_xxx" });
523
+ */
524
+ async cancelOnetimeOrder(params) {
525
+ validateShortId("orderId", params.orderId, "ORD");
526
+ return unwrapAction(await this.http.post("/v1/actions/onetime-order/cancel-order", params));
527
+ }
528
+ /**
529
+ * Reactivate a subscription that is in `canceling` status.
530
+ *
531
+ * @param params - Order to reactivate
532
+ * @returns Order ID and resulting status
533
+ *
534
+ * @example
535
+ * const { orderId, status } = await customer.reactivateSubscription({ orderId: "ORD_xxx" });
536
+ * // status: "active"
537
+ */
538
+ async reactivateSubscription(params) {
539
+ validateShortId("orderId", params.orderId, "ORD");
540
+ return unwrapAction(await this.http.post("/v1/actions/subscription-order/reactivate-order", params));
541
+ }
542
+ /**
543
+ * Submit a refund request for a payment.
544
+ *
545
+ * @param params - Refund ticket details
546
+ * @returns Created refund ticket
547
+ *
548
+ * @example
549
+ * const { ticket } = await customer.createRefundTicket({
550
+ * paymentId: "PAY_xxx",
551
+ * reason: "Product not as described",
552
+ * requestedAmount: { amount: "29.00", currency: "USD" },
553
+ * refundTicketMerchantExternalId: "REF-2026-00891",
554
+ * });
555
+ */
556
+ async createRefundTicket(params) {
557
+ validateShortId("paymentId", params.paymentId, "PAY");
558
+ validateRequired("reason", params.reason);
559
+ validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
560
+ validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
561
+ validateMaxLength("refundTicketMerchantExternalId", params.refundTicketMerchantExternalId, 128);
562
+ return unwrapAction(await this.http.post("/v1/actions/refund-ticket/create-ticket", params));
563
+ }
564
+ /**
565
+ * Resubmit a previously rejected refund ticket with updated details.
566
+ *
567
+ * @param params - Updated ticket details
568
+ * @returns Updated refund ticket
569
+ *
570
+ * @example
571
+ * const { ticket } = await customer.resubmitRefundTicket({
572
+ * ticketId: "TKT_xxx",
573
+ * paymentId: "PAY_xxx",
574
+ * reason: "Updated reason with more detail",
575
+ * requestedAmount: { amount: "29.00", currency: "USD" },
576
+ * });
577
+ */
578
+ async resubmitRefundTicket(params) {
579
+ validateShortId("ticketId", params.ticketId, "TKT");
580
+ validateShortId("paymentId", params.paymentId, "PAY");
581
+ validateRequired("reason", params.reason);
582
+ validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
583
+ validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
584
+ return unwrapAction(await this.http.post("/v1/actions/refund-ticket/resubmit-ticket", params));
585
+ }
586
+ };
587
+ var CustomerGraphQL = class {
588
+ constructor(http) {
589
+ this.http = http;
590
+ }
591
+ /**
592
+ * Execute a GraphQL query scoped to the customer's data.
593
+ *
594
+ * @param params - GraphQL query and variables
595
+ * @returns GraphQL response
596
+ *
597
+ * @example
598
+ * const result = await customer.graphql.query({
599
+ * query: `query { orders { id status } }`,
600
+ * });
601
+ */
602
+ async query(params) {
603
+ validateRequired("query", params.query);
604
+ const result = await this.http.post("/v1/graphql", params);
605
+ return { data: result.data, errors: result.errors, warnings: result.warnings };
606
+ }
607
+ };
608
+
609
609
  // src/resources/graphql.ts
610
610
  var GraphQLResource = class {
611
611
  constructor(http) {
@@ -1297,29 +1297,45 @@ var WaffoPancake = class {
1297
1297
  this.webhooks = new WebhooksResource(this.http, config.webhookPublicKey);
1298
1298
  }
1299
1299
  /**
1300
- * Create a buyer session for self-service operations.
1300
+ * Create a customer session for self-service operations.
1301
1301
  *
1302
1302
  * The returned session uses Bearer token authentication and provides
1303
1303
  * methods for order cancellation, subscription management, refund tickets,
1304
1304
  * and scoped GraphQL queries.
1305
1305
  *
1306
1306
  * @param token - Session token from `client.auth.issueSessionToken()`
1307
- * @returns A buyer session with self-service methods
1307
+ * @returns A customer session with self-service methods
1308
1308
  *
1309
1309
  * @example
1310
1310
  * const { token } = await client.auth.issueSessionToken({
1311
1311
  * storeId: "STO_xxx",
1312
1312
  * buyerIdentity: "customer@example.com",
1313
1313
  * });
1314
- * const buyer = client.buyer(token);
1315
- * await buyer.cancelSubscription({ orderId: "ORD_xxx" });
1314
+ * const customer = client.customer(token);
1315
+ * await customer.cancelSubscription({ orderId: "ORD_xxx" });
1316
1316
  */
1317
- buyer(token) {
1318
- const buyerHttp = new BuyerHttpClient(token, {
1317
+ customer(token) {
1318
+ const customerHttp = new CustomerHttpClient(token, {
1319
1319
  baseUrl: this.config.baseUrl,
1320
1320
  fetch: this.config.fetch
1321
1321
  });
1322
- return new BuyerSession(buyerHttp);
1322
+ return new CustomerSession(customerHttp);
1323
+ }
1324
+ /**
1325
+ * Create a customer session for self-service operations.
1326
+ *
1327
+ * @param token - Session token from `client.auth.issueSessionToken()`
1328
+ * @returns A customer session with self-service methods
1329
+ *
1330
+ * @example
1331
+ * ```typescript
1332
+ * const session = client.buyer(token); // prefer client.customer(token)
1333
+ * ```
1334
+ *
1335
+ * @deprecated Use {@link WaffoPancake.customer} instead.
1336
+ */
1337
+ buyer(token) {
1338
+ return this.customer(token);
1323
1339
  }
1324
1340
  };
1325
1341