@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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ All notable changes to `@waffo/pancake-ts` will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.3.0] - 2026-04-09
|
|
8
|
+
|
|
9
|
+
### Breaking Changes
|
|
10
|
+
|
|
11
|
+
- **Checkout params simplified** — `storeId` and `productType` removed from `CreateCheckoutSessionParams`, `AnonymousCheckoutParams`, and `AuthenticatedCheckoutParams`. The server now derives both from `productId` automatically. Only `productId` + `currency` are required.
|
|
12
|
+
- **`CheckoutSessionProductType` enum removed** — No longer exported. Product type is determined server-side.
|
|
13
|
+
- **`IssueSessionTokenParams.storeId` now optional** — Provide either `storeId` or `productId` (at least one required). When `productId` is given, the server derives the store from the product.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`IssueSessionTokenParams.productId`** — New optional field. When provided without `storeId`, the server derives the store from the product.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **`checkout.authenticated.create()`** — Now sends `productId` (instead of `storeId`) to `issue-session-token` endpoint for parallel session token + checkout session creation.
|
|
22
|
+
|
|
23
|
+
### Documentation
|
|
24
|
+
|
|
25
|
+
- **GraphQL type difference warning** — Added warnings in `graphql-guide.md`, `api-reference.md`, and external docs (EN/ZH/JA) clarifying that SDK TypeScript types reflect the REST API shape and differ from GraphQL schema types (e.g. `prices` is `Record<string, PriceInfo>` in REST but `[CurrencyPrice!]!` in GraphQL). Users should always use introspection for GraphQL queries.
|
|
26
|
+
|
|
7
27
|
## [0.2.2] - 2026-04-03
|
|
8
28
|
|
|
9
29
|
### Fixed
|
package/README.md
CHANGED
|
@@ -28,9 +28,7 @@ const client = new WaffoPancake({
|
|
|
28
28
|
|
|
29
29
|
// Create a checkout session — one call handles token + session + URL
|
|
30
30
|
const result = await client.checkout.authenticated.create({
|
|
31
|
-
storeId: "STO_xxx", // from Dashboard > Stores
|
|
32
31
|
productId: "PROD_xxx", // from Dashboard > Products
|
|
33
|
-
productType: "onetime",
|
|
34
32
|
currency: "USD",
|
|
35
33
|
buyerIdentity: req.user.email, // your user's identity
|
|
36
34
|
});
|
|
@@ -85,18 +83,14 @@ The merchant provides buyer identity — the SDK issues a session token, creates
|
|
|
85
83
|
```typescript
|
|
86
84
|
// Basic — buyer identity only
|
|
87
85
|
const result = await client.checkout.authenticated.create({
|
|
88
|
-
storeId: "STO_xxx",
|
|
89
86
|
productId: "PROD_xxx",
|
|
90
|
-
productType: "onetime",
|
|
91
87
|
currency: "USD",
|
|
92
88
|
buyerIdentity: "customer@example.com",
|
|
93
89
|
});
|
|
94
90
|
|
|
95
91
|
// With dynamic pricing — override stored price (e.g., coupon, volume discount)
|
|
96
92
|
const result = await client.checkout.authenticated.create({
|
|
97
|
-
storeId: "STO_xxx",
|
|
98
93
|
productId: "PROD_xxx",
|
|
99
|
-
productType: "onetime",
|
|
100
94
|
currency: "USD",
|
|
101
95
|
buyerIdentity: "customer@example.com",
|
|
102
96
|
priceSnapshot: { amount: "19.99", taxCategory: "digital_goods" },
|
|
@@ -104,9 +98,7 @@ const result = await client.checkout.authenticated.create({
|
|
|
104
98
|
|
|
105
99
|
// Subscription with trial control + billing detail pre-fill
|
|
106
100
|
const result = await client.checkout.authenticated.create({
|
|
107
|
-
storeId: "STO_xxx",
|
|
108
101
|
productId: "PROD_xxx",
|
|
109
|
-
productType: "subscription",
|
|
110
102
|
currency: "USD",
|
|
111
103
|
buyerIdentity: "customer@example.com",
|
|
112
104
|
withTrial: true, // force enable trial (false = skip, omit = default rules)
|
|
@@ -125,17 +117,13 @@ No buyer identity required — the buyer fills in billing details manually on th
|
|
|
125
117
|
|
|
126
118
|
```typescript
|
|
127
119
|
const result = await client.checkout.anonymous.create({
|
|
128
|
-
storeId: "STO_xxx",
|
|
129
120
|
productId: "PROD_xxx",
|
|
130
|
-
productType: "onetime",
|
|
131
121
|
currency: "USD",
|
|
132
122
|
});
|
|
133
123
|
|
|
134
124
|
// Also supports priceSnapshot and withTrial
|
|
135
125
|
const result = await client.checkout.anonymous.create({
|
|
136
|
-
storeId: "STO_xxx",
|
|
137
126
|
productId: "PROD_xxx",
|
|
138
|
-
productType: "subscription",
|
|
139
127
|
currency: "USD",
|
|
140
128
|
priceSnapshot: { amount: "4.99", taxCategory: "saas" },
|
|
141
129
|
withTrial: false, // skip trial for this session
|
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
BillingPeriod: () => BillingPeriod,
|
|
24
|
-
CheckoutSessionProductType: () => CheckoutSessionProductType,
|
|
25
24
|
EntityStatus: () => EntityStatus,
|
|
26
25
|
Environment: () => Environment,
|
|
27
26
|
ErrorLayer: () => ErrorLayer,
|
|
@@ -344,9 +343,7 @@ function validateBillingDetail(detail) {
|
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
345
|
function validateCheckoutCommon(params) {
|
|
347
|
-
validateShortId("storeId", params.storeId, "STO");
|
|
348
346
|
validateShortId("productId", params.productId, "PROD");
|
|
349
|
-
validateEnum("productType", params.productType, ["onetime", "subscription"]);
|
|
350
347
|
validateCurrencyCode("currency", params.currency);
|
|
351
348
|
if (params.priceSnapshot) {
|
|
352
349
|
validateAmountString("priceSnapshot.amount", params.priceSnapshot.amount);
|
|
@@ -372,13 +369,31 @@ var AuthResource = class {
|
|
|
372
369
|
* @returns Issued session token with expiration
|
|
373
370
|
*
|
|
374
371
|
* @example
|
|
372
|
+
* // By store ID
|
|
375
373
|
* const { token, expiresAt } = await client.auth.issueSessionToken({
|
|
376
374
|
* storeId: "STO_xxx",
|
|
377
375
|
* buyerIdentity: "customer@example.com",
|
|
378
376
|
* });
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* // By product ID (store derived automatically)
|
|
380
|
+
* const { token, expiresAt } = await client.auth.issueSessionToken({
|
|
381
|
+
* productId: "PROD_xxx",
|
|
382
|
+
* buyerIdentity: "customer@example.com",
|
|
383
|
+
* });
|
|
379
384
|
*/
|
|
380
385
|
async issueSessionToken(params) {
|
|
381
|
-
|
|
386
|
+
if (!params.storeId && !params.productId) {
|
|
387
|
+
throw new WaffoPancakeError(400, [
|
|
388
|
+
{ message: "Missing required field: provide storeId or productId", layer: "sdk" }
|
|
389
|
+
]);
|
|
390
|
+
}
|
|
391
|
+
if (params.storeId) {
|
|
392
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
393
|
+
}
|
|
394
|
+
if (params.productId) {
|
|
395
|
+
validateShortId("productId", params.productId, "PROD");
|
|
396
|
+
}
|
|
382
397
|
validateRequired("buyerIdentity", params.buyerIdentity);
|
|
383
398
|
return this.http.post("/v1/actions/auth/issue-session-token", params);
|
|
384
399
|
}
|
|
@@ -525,9 +540,7 @@ var CheckoutAnonymousResource = class {
|
|
|
525
540
|
*
|
|
526
541
|
* @example
|
|
527
542
|
* const result = await client.checkout.anonymous.create({
|
|
528
|
-
* storeId: "STO_xxx",
|
|
529
543
|
* productId: "PROD_xxx",
|
|
530
|
-
* productType: "onetime",
|
|
531
544
|
* currency: "USD",
|
|
532
545
|
* });
|
|
533
546
|
* // Redirect to result.checkoutUrl
|
|
@@ -561,9 +574,7 @@ var CheckoutAuthenticatedResource = class {
|
|
|
561
574
|
*
|
|
562
575
|
* @example
|
|
563
576
|
* const result = await client.checkout.authenticated.create({
|
|
564
|
-
* storeId: "STO_xxx",
|
|
565
577
|
* productId: "PROD_xxx",
|
|
566
|
-
* productType: "onetime",
|
|
567
578
|
* currency: "USD",
|
|
568
579
|
* buyerIdentity: "customer@example.com",
|
|
569
580
|
* });
|
|
@@ -575,7 +586,7 @@ var CheckoutAuthenticatedResource = class {
|
|
|
575
586
|
const { buyerIdentity, buyerEmail, ...sessionFields } = params;
|
|
576
587
|
const [tokenResult, sessionResult] = await Promise.all([
|
|
577
588
|
this.http.post("/v1/actions/auth/issue-session-token", {
|
|
578
|
-
|
|
589
|
+
productId: params.productId,
|
|
579
590
|
buyerIdentity
|
|
580
591
|
}, { idempotencyWindow: 60 }),
|
|
581
592
|
this.http.post("/v1/actions/checkout/create-session", {
|
|
@@ -615,9 +626,7 @@ var CheckoutResource = class {
|
|
|
615
626
|
*
|
|
616
627
|
* @example
|
|
617
628
|
* const session = await client.checkout.createSession({
|
|
618
|
-
* storeId: "STO_xxx",
|
|
619
629
|
* productId: "PROD_xxx",
|
|
620
|
-
* productType: "onetime",
|
|
621
630
|
* currency: "USD",
|
|
622
631
|
* buyerEmail: "customer@example.com",
|
|
623
632
|
* });
|
|
@@ -1300,11 +1309,6 @@ var MediaType = /* @__PURE__ */ ((MediaType2) => {
|
|
|
1300
1309
|
MediaType2["Video"] = "video";
|
|
1301
1310
|
return MediaType2;
|
|
1302
1311
|
})(MediaType || {});
|
|
1303
|
-
var CheckoutSessionProductType = /* @__PURE__ */ ((CheckoutSessionProductType2) => {
|
|
1304
|
-
CheckoutSessionProductType2["Onetime"] = "onetime";
|
|
1305
|
-
CheckoutSessionProductType2["Subscription"] = "subscription";
|
|
1306
|
-
return CheckoutSessionProductType2;
|
|
1307
|
-
})(CheckoutSessionProductType || {});
|
|
1308
1312
|
var ErrorLayer = /* @__PURE__ */ ((ErrorLayer2) => {
|
|
1309
1313
|
ErrorLayer2["Gateway"] = "gateway";
|
|
1310
1314
|
ErrorLayer2["User"] = "user";
|
|
@@ -1334,7 +1338,6 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|
|
|
1334
1338
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1335
1339
|
0 && (module.exports = {
|
|
1336
1340
|
BillingPeriod,
|
|
1337
|
-
CheckoutSessionProductType,
|
|
1338
1341
|
EntityStatus,
|
|
1339
1342
|
Environment,
|
|
1340
1343
|
ErrorLayer,
|