@waffo/pancake-ts 0.2.2 → 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/CHANGELOG.md +20 -0
- package/README.md +0 -12
- package/dist/index.cjs +20 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -39
- package/dist/index.d.ts +17 -39
- package/dist/index.js +20 -16
- package/dist/index.js.map +1 -1
- package/docs/api-reference.md +14 -20
- package/docs/graphql-guide.md +2 -0
- package/package.json +1 -1
package/docs/api-reference.md
CHANGED
|
@@ -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` |
|
|
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`**:
|
|
@@ -607,9 +615,7 @@ Internally calls `POST /v1/actions/auth/issue-session-token` and `POST /v1/actio
|
|
|
607
615
|
```typescript
|
|
608
616
|
// One-time product with buyer identity
|
|
609
617
|
const result = await client.checkout.authenticated.create({
|
|
610
|
-
storeId: "STO_xxx",
|
|
611
618
|
productId: "PROD_xxx",
|
|
612
|
-
productType: "onetime",
|
|
613
619
|
currency: "USD",
|
|
614
620
|
buyerIdentity: "customer@example.com",
|
|
615
621
|
successUrl: "https://example.com/thank-you",
|
|
@@ -618,9 +624,7 @@ const result = await client.checkout.authenticated.create({
|
|
|
618
624
|
|
|
619
625
|
// Subscription with trial and billing detail
|
|
620
626
|
const subResult = await client.checkout.authenticated.create({
|
|
621
|
-
storeId: "STO_xxx",
|
|
622
627
|
productId: "PROD_yyy",
|
|
623
|
-
productType: "subscription",
|
|
624
628
|
currency: "USD",
|
|
625
629
|
buyerIdentity: "customer@example.com",
|
|
626
630
|
withTrial: true,
|
|
@@ -632,9 +636,7 @@ const subResult = await client.checkout.authenticated.create({
|
|
|
632
636
|
|
|
633
637
|
| Field | Type | Required | Description |
|
|
634
638
|
|-------|------|----------|-------------|
|
|
635
|
-
| `
|
|
636
|
-
| `productId` | `string` | Yes | Product ID |
|
|
637
|
-
| `productType` | `CheckoutSessionProductType` | Yes | `"onetime"` or `"subscription"` |
|
|
639
|
+
| `productId` | `string` | Yes | Product ID (product type is auto-detected server-side) |
|
|
638
640
|
| `currency` | `string` | Yes | Currency code (ISO 4217) |
|
|
639
641
|
| `buyerIdentity` | `string` | Yes | Buyer identity (email or merchant-defined identifier) |
|
|
640
642
|
| `buyerEmail` | `string` | No | Pre-filled buyer email (defaults to `buyerIdentity`) |
|
|
@@ -664,18 +666,14 @@ Internally calls `POST /v1/actions/checkout/create-session`.
|
|
|
664
666
|
|
|
665
667
|
```typescript
|
|
666
668
|
const result = await client.checkout.anonymous.create({
|
|
667
|
-
storeId: "STO_xxx",
|
|
668
669
|
productId: "PROD_xxx",
|
|
669
|
-
productType: "onetime",
|
|
670
670
|
currency: "USD",
|
|
671
671
|
});
|
|
672
672
|
// => redirect buyer to result.checkoutUrl (buyer fills form manually)
|
|
673
673
|
|
|
674
674
|
// With price snapshot override
|
|
675
675
|
const snapshotResult = await client.checkout.anonymous.create({
|
|
676
|
-
storeId: "STO_xxx",
|
|
677
676
|
productId: "PROD_xxx",
|
|
678
|
-
productType: "onetime",
|
|
679
677
|
currency: "USD",
|
|
680
678
|
priceSnapshot: { amount: "19.99", taxCategory: "digital_goods" },
|
|
681
679
|
});
|
|
@@ -685,9 +683,7 @@ const snapshotResult = await client.checkout.anonymous.create({
|
|
|
685
683
|
|
|
686
684
|
| Field | Type | Required | Description |
|
|
687
685
|
|-------|------|----------|-------------|
|
|
688
|
-
| `
|
|
689
|
-
| `productId` | `string` | Yes | Product ID |
|
|
690
|
-
| `productType` | `CheckoutSessionProductType` | Yes | `"onetime"` or `"subscription"` |
|
|
686
|
+
| `productId` | `string` | Yes | Product ID (product type is auto-detected server-side) |
|
|
691
687
|
| `currency` | `string` | Yes | Currency code (ISO 4217) |
|
|
692
688
|
| `priceSnapshot` | `PriceInfo` | No | Price snapshot override (reads from DB if omitted) |
|
|
693
689
|
| `withTrial` | `boolean` | No | Enable trial period (subscription only) |
|
|
@@ -710,9 +706,7 @@ Create a checkout session directly. For most use cases, prefer `checkout.authent
|
|
|
710
706
|
|
|
711
707
|
```typescript
|
|
712
708
|
const session = await client.checkout.createSession({
|
|
713
|
-
storeId: "STO_xxx",
|
|
714
709
|
productId: "PROD_xxx",
|
|
715
|
-
productType: "onetime",
|
|
716
710
|
currency: "USD",
|
|
717
711
|
buyerEmail: "customer@example.com",
|
|
718
712
|
});
|
|
@@ -722,9 +716,7 @@ const session = await client.checkout.createSession({
|
|
|
722
716
|
|
|
723
717
|
| Field | Type | Required | Description |
|
|
724
718
|
|-------|------|----------|-------------|
|
|
725
|
-
| `
|
|
726
|
-
| `productId` | `string` | Yes | Product ID |
|
|
727
|
-
| `productType` | `CheckoutSessionProductType` | Yes | `"onetime"` or `"subscription"` |
|
|
719
|
+
| `productId` | `string` | Yes | Product ID (product type is auto-detected server-side) |
|
|
728
720
|
| `currency` | `string` | Yes | Currency code (ISO 4217) |
|
|
729
721
|
| `priceSnapshot` | `PriceInfo` | No | Price snapshot override (reads from DB if omitted) |
|
|
730
722
|
| `withTrial` | `boolean` | No | Enable trial period (subscription only) |
|
|
@@ -762,6 +754,8 @@ const session = await client.checkout.createSession({
|
|
|
762
754
|
|
|
763
755
|
Execute a typed GraphQL query. Only Query operations are supported — Mutations return a 403 error.
|
|
764
756
|
|
|
757
|
+
> **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.
|
|
758
|
+
|
|
765
759
|
```typescript
|
|
766
760
|
interface StoresQuery {
|
|
767
761
|
stores: Array<{ id: string; name: string; status: string }>;
|
package/docs/graphql-guide.md
CHANGED
|
@@ -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
|
|