@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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ 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.1] - 2026-04-09
8
+
9
+ ### Changed
10
+
11
+ - **Product update simplified** — `update()` only modifies provided fields; omitted fields are preserved. `name`, `prices`, and `billingPeriod` (subscription) are now optional.
12
+
13
+ ### Documentation
14
+
15
+ - **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. Users should always use introspection for GraphQL queries.
16
+
17
+ ## [0.3.0] - 2026-04-09
18
+
19
+ ### Breaking Changes
20
+
21
+ - **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.
22
+ - **`CheckoutSessionProductType` enum removed** — No longer exported. Product type is determined server-side.
23
+ - **`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.
24
+
25
+ ### Added
26
+
27
+ - **`IssueSessionTokenParams.productId`** — New optional field. When provided without `storeId`, the server derives the store from the product.
28
+
29
+ ### Changed
30
+
31
+ - **`checkout.authenticated.create()`** — Now sends `productId` (instead of `storeId`) to `issue-session-token` endpoint for parallel session token + checkout session creation.
32
+
7
33
  ## [0.2.2] - 2026-04-03
8
34
 
9
35
  ### 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
- validateShortId("storeId", params.storeId, "STO");
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
- storeId: params.storeId,
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
  * });
@@ -684,20 +693,27 @@ var OnetimeProductsResource = class {
684
693
  /**
685
694
  * Update a one-time product. Creates a new version; skips if unchanged.
686
695
  *
687
- * @param params - Product update parameters (all content fields required)
696
+ * @param params - Product update parameters (only `id` is required)
688
697
  * @returns Updated product detail
689
698
  *
690
699
  * @example
700
+ * // Update only the name
691
701
  * const { product } = await client.onetimeProducts.update({
692
702
  * id: "PROD_xxx",
693
703
  * name: "E-Book v2",
704
+ * });
705
+ *
706
+ * @example
707
+ * // Update prices while preserving other fields
708
+ * const { product } = await client.onetimeProducts.update({
709
+ * id: "PROD_xxx",
694
710
  * prices: { USD: { amount: "39.00", taxCategory: "digital_goods" } },
695
711
  * });
696
712
  */
697
713
  async update(params) {
698
714
  validateShortId("id", params.id, "PROD");
699
- validateRequired("name", params.name);
700
- validatePrices("prices", params.prices);
715
+ if (params.name !== void 0) validateRequired("name", params.name);
716
+ if (params.prices) validatePrices("prices", params.prices);
701
717
  return this.http.post("/v1/actions/onetime-product/update-product", params);
702
718
  }
703
719
  /**
@@ -966,22 +982,29 @@ var SubscriptionProductsResource = class {
966
982
  /**
967
983
  * Update a subscription product. Creates a new version; skips if unchanged.
968
984
  *
969
- * @param params - Product update parameters (all content fields required)
985
+ * @param params - Product update parameters (only `id` is required)
970
986
  * @returns Updated product detail
971
987
  *
972
988
  * @example
989
+ * // Update only the name
973
990
  * const { product } = await client.subscriptionProducts.update({
974
991
  * id: "PROD_xxx",
975
992
  * name: "Pro Plan v2",
976
- * billingPeriod: "monthly",
977
- * prices: { USD: { amount: "14.99", taxCategory: "saas" } },
993
+ * });
994
+ *
995
+ * @example
996
+ * // Update prices and billing period
997
+ * const { product } = await client.subscriptionProducts.update({
998
+ * id: "PROD_xxx",
999
+ * billingPeriod: "yearly",
1000
+ * prices: { USD: { amount: "99.00", taxCategory: "saas" } },
978
1001
  * });
979
1002
  */
980
1003
  async update(params) {
981
1004
  validateShortId("id", params.id, "PROD");
982
- validateRequired("name", params.name);
983
- validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
984
- validatePrices("prices", params.prices);
1005
+ if (params.name !== void 0) validateRequired("name", params.name);
1006
+ if (params.billingPeriod !== void 0) validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
1007
+ if (params.prices) validatePrices("prices", params.prices);
985
1008
  return this.http.post("/v1/actions/subscription-product/update-product", params);
986
1009
  }
987
1010
  /**
@@ -1300,11 +1323,6 @@ var MediaType = /* @__PURE__ */ ((MediaType2) => {
1300
1323
  MediaType2["Video"] = "video";
1301
1324
  return MediaType2;
1302
1325
  })(MediaType || {});
1303
- var CheckoutSessionProductType = /* @__PURE__ */ ((CheckoutSessionProductType2) => {
1304
- CheckoutSessionProductType2["Onetime"] = "onetime";
1305
- CheckoutSessionProductType2["Subscription"] = "subscription";
1306
- return CheckoutSessionProductType2;
1307
- })(CheckoutSessionProductType || {});
1308
1326
  var ErrorLayer = /* @__PURE__ */ ((ErrorLayer2) => {
1309
1327
  ErrorLayer2["Gateway"] = "gateway";
1310
1328
  ErrorLayer2["User"] = "user";
@@ -1334,7 +1352,6 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
1334
1352
  // Annotate the CommonJS export names for ESM import in node:
1335
1353
  0 && (module.exports = {
1336
1354
  BillingPeriod,
1337
- CheckoutSessionProductType,
1338
1355
  EntityStatus,
1339
1356
  Environment,
1340
1357
  ErrorLayer,