@waffo/pancake-ts 0.2.2 → 0.3.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.
@@ -5,7 +5,7 @@ Complete reference for all `@waffo/pancake-ts` resources, parameters, and return
5
5
  > **Conventions**:
6
6
  > - All amounts are in the **smallest currency unit** (e.g. 999 = $9.99 USD, 4500 = ¥4500 JPY)
7
7
  > - All timestamps are **ISO 8601 UTC** strings
8
- > - Product updates follow **immutable versioning** — each update creates a new version, skipped if content is unchanged
8
+ > - Product updates follow **immutable versioning** — only provided fields are updated (omitted fields are preserved), each update creates a new version, skipped if content is unchanged
9
9
  > - The **publish** flow promotes a test version to production
10
10
 
11
11
  ---
@@ -17,17 +17,25 @@ Complete reference for all `@waffo/pancake-ts` resources, parameters, and return
17
17
  Issue a buyer session token (JWT) for storefront authentication.
18
18
 
19
19
  ```typescript
20
+ // With storeId
20
21
  const { token, expiresAt } = await client.auth.issueSessionToken({
21
22
  storeId: "STO_xxx",
22
23
  buyerIdentity: "customer@example.com",
23
24
  });
25
+
26
+ // With productId (server derives storeId from the product)
27
+ const { token, expiresAt } = await client.auth.issueSessionToken({
28
+ productId: "PROD_xxx",
29
+ buyerIdentity: "customer@example.com",
30
+ });
24
31
  ```
25
32
 
26
33
  **Parameters `IssueSessionTokenParams`**:
27
34
 
28
35
  | Field | Type | Required | Description |
29
36
  |-------|------|----------|-------------|
30
- | `storeId` | `string` | Yes | Store ID |
37
+ | `storeId` | `string` | No | Store ID (at least one of `storeId` / `productId` required) |
38
+ | `productId` | `string` | No | Product ID (at least one of `storeId` / `productId` required; server derives store from product) |
31
39
  | `buyerIdentity` | `string` | Yes | Buyer identity (email or merchant-defined identifier) |
32
40
 
33
41
  **Returns `SessionToken`**:
@@ -270,10 +278,18 @@ const { product } = await client.onetimeProducts.create({
270
278
 
271
279
  Update a one-time product. Creates a new immutable version; skips if content is unchanged.
272
280
 
281
+ > Only `id` is required. Omitted fields keep their current values.
282
+
273
283
  ```typescript
284
+ // Update only the name
274
285
  const { product } = await client.onetimeProducts.update({
275
286
  id: "PROD_xxx",
276
287
  name: "E-Book: TypeScript Handbook v2",
288
+ });
289
+
290
+ // Update only the prices
291
+ const { product: p2 } = await client.onetimeProducts.update({
292
+ id: "PROD_xxx",
277
293
  prices: { USD: { amount: "39.00", taxCategory: "digital_goods" } },
278
294
  });
279
295
  ```
@@ -283,8 +299,8 @@ const { product } = await client.onetimeProducts.update({
283
299
  | Field | Type | Required | Description |
284
300
  |-------|------|----------|-------------|
285
301
  | `id` | `string` | Yes | Product ID |
286
- | `name` | `string` | Yes | Product name |
287
- | `prices` | `Prices` | Yes | Multi-currency prices |
302
+ | `name` | `string` | No | Product name |
303
+ | `prices` | `Prices` | No | Multi-currency prices |
288
304
  | `description` | `string` | No | Product description |
289
305
  | `media` | `MediaItem[]` | No | Media assets |
290
306
  | `successUrl` | `string` | No | Redirect URL after successful payment |
@@ -369,16 +385,35 @@ const { product } = await client.subscriptionProducts.create({
369
385
 
370
386
  Update a subscription product. Creates a new immutable version; skips if unchanged.
371
387
 
388
+ > Only `id` is required. Omitted fields keep their current values.
389
+
372
390
  ```typescript
391
+ // Update only the name
373
392
  const { product } = await client.subscriptionProducts.update({
374
393
  id: "PROD_xxx",
375
394
  name: "Pro Plan v2",
376
- billingPeriod: BillingPeriod.Monthly,
377
- prices: { USD: { amount: "14.99", taxCategory: "saas" } },
395
+ });
396
+
397
+ // Update billing period and prices
398
+ const { product: p2 } = await client.subscriptionProducts.update({
399
+ id: "PROD_xxx",
400
+ billingPeriod: BillingPeriod.Yearly,
401
+ prices: { USD: { amount: "99.00", taxCategory: "saas" } },
378
402
  });
379
403
  ```
380
404
 
381
- **Parameters `UpdateSubscriptionProductParams`**: Same as create, but `id` replaces `storeId`.
405
+ **Parameters `UpdateSubscriptionProductParams`**:
406
+
407
+ | Field | Type | Required | Description |
408
+ |-------|------|----------|-------------|
409
+ | `id` | `string` | Yes | Product ID |
410
+ | `name` | `string` | No | Product name |
411
+ | `billingPeriod` | `BillingPeriod` | No | Billing period |
412
+ | `prices` | `Prices` | No | Multi-currency prices |
413
+ | `description` | `string` | No | Product description |
414
+ | `media` | `MediaItem[]` | No | Media assets |
415
+ | `successUrl` | `string` | No | Redirect URL after successful payment |
416
+ | `metadata` | `Record<string, unknown>` | No | Custom metadata |
382
417
 
383
418
  **Returns `{ product: SubscriptionProductDetail }`**
384
419
 
@@ -607,9 +642,7 @@ Internally calls `POST /v1/actions/auth/issue-session-token` and `POST /v1/actio
607
642
  ```typescript
608
643
  // One-time product with buyer identity
609
644
  const result = await client.checkout.authenticated.create({
610
- storeId: "STO_xxx",
611
645
  productId: "PROD_xxx",
612
- productType: "onetime",
613
646
  currency: "USD",
614
647
  buyerIdentity: "customer@example.com",
615
648
  successUrl: "https://example.com/thank-you",
@@ -618,9 +651,7 @@ const result = await client.checkout.authenticated.create({
618
651
 
619
652
  // Subscription with trial and billing detail
620
653
  const subResult = await client.checkout.authenticated.create({
621
- storeId: "STO_xxx",
622
654
  productId: "PROD_yyy",
623
- productType: "subscription",
624
655
  currency: "USD",
625
656
  buyerIdentity: "customer@example.com",
626
657
  withTrial: true,
@@ -632,9 +663,7 @@ const subResult = await client.checkout.authenticated.create({
632
663
 
633
664
  | Field | Type | Required | Description |
634
665
  |-------|------|----------|-------------|
635
- | `storeId` | `string` | Yes | Store ID |
636
- | `productId` | `string` | Yes | Product ID |
637
- | `productType` | `CheckoutSessionProductType` | Yes | `"onetime"` or `"subscription"` |
666
+ | `productId` | `string` | Yes | Product ID (product type is auto-detected server-side) |
638
667
  | `currency` | `string` | Yes | Currency code (ISO 4217) |
639
668
  | `buyerIdentity` | `string` | Yes | Buyer identity (email or merchant-defined identifier) |
640
669
  | `buyerEmail` | `string` | No | Pre-filled buyer email (defaults to `buyerIdentity`) |
@@ -664,18 +693,14 @@ Internally calls `POST /v1/actions/checkout/create-session`.
664
693
 
665
694
  ```typescript
666
695
  const result = await client.checkout.anonymous.create({
667
- storeId: "STO_xxx",
668
696
  productId: "PROD_xxx",
669
- productType: "onetime",
670
697
  currency: "USD",
671
698
  });
672
699
  // => redirect buyer to result.checkoutUrl (buyer fills form manually)
673
700
 
674
701
  // With price snapshot override
675
702
  const snapshotResult = await client.checkout.anonymous.create({
676
- storeId: "STO_xxx",
677
703
  productId: "PROD_xxx",
678
- productType: "onetime",
679
704
  currency: "USD",
680
705
  priceSnapshot: { amount: "19.99", taxCategory: "digital_goods" },
681
706
  });
@@ -685,9 +710,7 @@ const snapshotResult = await client.checkout.anonymous.create({
685
710
 
686
711
  | Field | Type | Required | Description |
687
712
  |-------|------|----------|-------------|
688
- | `storeId` | `string` | Yes | Store ID |
689
- | `productId` | `string` | Yes | Product ID |
690
- | `productType` | `CheckoutSessionProductType` | Yes | `"onetime"` or `"subscription"` |
713
+ | `productId` | `string` | Yes | Product ID (product type is auto-detected server-side) |
691
714
  | `currency` | `string` | Yes | Currency code (ISO 4217) |
692
715
  | `priceSnapshot` | `PriceInfo` | No | Price snapshot override (reads from DB if omitted) |
693
716
  | `withTrial` | `boolean` | No | Enable trial period (subscription only) |
@@ -710,9 +733,7 @@ Create a checkout session directly. For most use cases, prefer `checkout.authent
710
733
 
711
734
  ```typescript
712
735
  const session = await client.checkout.createSession({
713
- storeId: "STO_xxx",
714
736
  productId: "PROD_xxx",
715
- productType: "onetime",
716
737
  currency: "USD",
717
738
  buyerEmail: "customer@example.com",
718
739
  });
@@ -722,9 +743,7 @@ const session = await client.checkout.createSession({
722
743
 
723
744
  | Field | Type | Required | Description |
724
745
  |-------|------|----------|-------------|
725
- | `storeId` | `string` | Yes | Store ID |
726
- | `productId` | `string` | Yes | Product ID |
727
- | `productType` | `CheckoutSessionProductType` | Yes | `"onetime"` or `"subscription"` |
746
+ | `productId` | `string` | Yes | Product ID (product type is auto-detected server-side) |
728
747
  | `currency` | `string` | Yes | Currency code (ISO 4217) |
729
748
  | `priceSnapshot` | `PriceInfo` | No | Price snapshot override (reads from DB if omitted) |
730
749
  | `withTrial` | `boolean` | No | Enable trial period (subscription only) |
@@ -762,6 +781,8 @@ const session = await client.checkout.createSession({
762
781
 
763
782
  Execute a typed GraphQL query. Only Query operations are supported — Mutations return a 403 error.
764
783
 
784
+ > **Note**: GraphQL field names may differ from SDK TypeScript types. For example, `prices` is `Record<string, PriceInfo>` in REST but `[CurrencyPrice!]!` in GraphQL. Use introspection (`__schema` / `__type` queries) to discover the exact schema. See [GraphQL Guide](./graphql-guide.md) for details.
785
+
765
786
  ```typescript
766
787
  interface StoresQuery {
767
788
  stores: Array<{ id: string; name: string; status: string }>;
@@ -7,6 +7,8 @@ The Waffo Pancake GraphQL API is **query-only** — Mutations are not supported
7
7
  Introspection is **enabled by default**. Use it during development to explore the full schema, discover available types, fields, and filter conditions.
8
8
 
9
9
  > **Recommended**: Always use introspection to stay in sync with the server — this guide covers common queries, but the schema is the source of truth.
10
+ >
11
+ > **Important**: The SDK's TypeScript types (e.g. `Prices`, `MediaItem`) reflect the **REST API** shape. The GraphQL schema may represent the same data differently — for example, `prices` is a `Record<string, PriceInfo>` in REST but `[CurrencyPrice!]!` (array of `{currency, priceInfo}`) in GraphQL. Always use introspection or the examples below for GraphQL field names, not the SDK type definitions.
10
12
 
11
13
  ### Discover All Query Fields
12
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waffo/pancake-ts",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "TypeScript SDK for Waffo Pancake API (Merchant API Key authentication)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",