@shware/purchase 1.8.9 → 1.9.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.
Files changed (128) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/dist/app-store/config.cjs +98 -128
  3. package/dist/app-store/config.cjs.map +1 -1
  4. package/dist/app-store/config.d.cts +31 -31
  5. package/dist/app-store/config.d.cts.map +1 -0
  6. package/dist/app-store/config.d.mts +39 -0
  7. package/dist/app-store/config.d.mts.map +1 -0
  8. package/dist/app-store/config.mjs +93 -91
  9. package/dist/app-store/config.mjs.map +1 -1
  10. package/dist/app-store/index.cjs +3 -31
  11. package/dist/app-store/index.d.cts +2 -3
  12. package/dist/app-store/index.d.mts +2 -0
  13. package/dist/app-store/index.mjs +1 -5
  14. package/dist/google-play/config.cjs +100 -123
  15. package/dist/google-play/config.cjs.map +1 -1
  16. package/dist/google-play/config.d.cts +31 -31
  17. package/dist/google-play/config.d.cts.map +1 -0
  18. package/dist/google-play/config.d.mts +39 -0
  19. package/dist/google-play/config.d.mts.map +1 -0
  20. package/dist/google-play/config.mjs +95 -86
  21. package/dist/google-play/config.mjs.map +1 -1
  22. package/dist/google-play/index.cjs +9 -42
  23. package/dist/google-play/index.d.cts +3 -4
  24. package/dist/google-play/index.d.mts +3 -0
  25. package/dist/google-play/index.mjs +2 -17
  26. package/dist/google-play/real-time-developer-notification.cjs +122 -81
  27. package/dist/google-play/real-time-developer-notification.cjs.map +1 -1
  28. package/dist/google-play/real-time-developer-notification.d.cts +119 -117
  29. package/dist/google-play/real-time-developer-notification.d.cts.map +1 -0
  30. package/dist/google-play/real-time-developer-notification.d.mts +150 -0
  31. package/dist/google-play/real-time-developer-notification.d.mts.map +1 -0
  32. package/dist/google-play/real-time-developer-notification.mjs +118 -53
  33. package/dist/google-play/real-time-developer-notification.mjs.map +1 -1
  34. package/dist/index.cjs +13 -48
  35. package/dist/index.d.cts +5 -6
  36. package/dist/index.d.mts +5 -0
  37. package/dist/index.mjs +2 -19
  38. package/dist/stripe/config.cjs +104 -133
  39. package/dist/stripe/config.cjs.map +1 -1
  40. package/dist/stripe/config.d.cts +35 -35
  41. package/dist/stripe/config.d.cts.map +1 -0
  42. package/dist/stripe/config.d.mts +43 -0
  43. package/dist/stripe/config.d.mts.map +1 -0
  44. package/dist/stripe/config.mjs +99 -96
  45. package/dist/stripe/config.mjs.map +1 -1
  46. package/dist/stripe/handler.cjs +25 -53
  47. package/dist/stripe/handler.cjs.map +1 -1
  48. package/dist/stripe/handler.d.cts +10 -9
  49. package/dist/stripe/handler.d.cts.map +1 -0
  50. package/dist/stripe/handler.d.mts +16 -0
  51. package/dist/stripe/handler.d.mts.map +1 -0
  52. package/dist/stripe/handler.mjs +25 -29
  53. package/dist/stripe/handler.mjs.map +1 -1
  54. package/dist/stripe/index.cjs +27 -74
  55. package/dist/stripe/index.d.cts +8 -12
  56. package/dist/stripe/index.d.mts +8 -0
  57. package/dist/stripe/index.mjs +5 -44
  58. package/dist/stripe/mapper.cjs +168 -219
  59. package/dist/stripe/mapper.cjs.map +1 -1
  60. package/dist/stripe/mapper.d.cts +115 -114
  61. package/dist/stripe/mapper.d.cts.map +1 -0
  62. package/dist/stripe/mapper.d.mts +158 -0
  63. package/dist/stripe/mapper.d.mts.map +1 -0
  64. package/dist/stripe/mapper.mjs +155 -182
  65. package/dist/stripe/mapper.mjs.map +1 -1
  66. package/dist/stripe/metadata.cjs +11 -35
  67. package/dist/stripe/metadata.cjs.map +1 -1
  68. package/dist/stripe/metadata.d.cts +9 -7
  69. package/dist/stripe/metadata.d.cts.map +1 -0
  70. package/dist/stripe/metadata.d.mts +12 -0
  71. package/dist/stripe/metadata.d.mts.map +1 -0
  72. package/dist/stripe/metadata.mjs +11 -11
  73. package/dist/stripe/metadata.mjs.map +1 -1
  74. package/dist/stripe/pending-checkout.cjs +55 -61
  75. package/dist/stripe/pending-checkout.cjs.map +1 -1
  76. package/dist/stripe/pending-checkout.d.cts +3 -1
  77. package/dist/stripe/pending-checkout.d.cts.map +1 -0
  78. package/dist/stripe/{pending-checkout.d.ts → pending-checkout.d.mts} +3 -1
  79. package/dist/stripe/pending-checkout.d.mts.map +1 -0
  80. package/dist/stripe/pending-checkout.mjs +52 -34
  81. package/dist/stripe/pending-checkout.mjs.map +1 -1
  82. package/dist/stripe/schema.cjs +30 -55
  83. package/dist/stripe/schema.cjs.map +1 -1
  84. package/dist/stripe/schema.d.cts +36 -37
  85. package/dist/stripe/schema.d.cts.map +1 -0
  86. package/dist/stripe/schema.d.mts +40 -0
  87. package/dist/stripe/schema.d.mts.map +1 -0
  88. package/dist/stripe/schema.mjs +28 -40
  89. package/dist/stripe/schema.mjs.map +1 -1
  90. package/dist/subscription/index.cjs +178 -80
  91. package/dist/subscription/index.cjs.map +1 -1
  92. package/dist/subscription/index.d.cts +136 -134
  93. package/dist/subscription/index.d.cts.map +1 -0
  94. package/dist/subscription/index.d.mts +150 -0
  95. package/dist/subscription/index.d.mts.map +1 -0
  96. package/dist/subscription/index.mjs +173 -51
  97. package/dist/subscription/index.mjs.map +1 -1
  98. package/dist/types.cjs +0 -19
  99. package/dist/types.d.cts +7 -6
  100. package/dist/types.d.cts.map +1 -0
  101. package/dist/types.d.mts +10 -0
  102. package/dist/types.d.mts.map +1 -0
  103. package/dist/types.mjs +1 -1
  104. package/package.json +40 -25
  105. package/dist/app-store/config.d.ts +0 -39
  106. package/dist/app-store/index.cjs.map +0 -1
  107. package/dist/app-store/index.d.ts +0 -3
  108. package/dist/app-store/index.mjs.map +0 -1
  109. package/dist/google-play/config.d.ts +0 -39
  110. package/dist/google-play/index.cjs.map +0 -1
  111. package/dist/google-play/index.d.ts +0 -4
  112. package/dist/google-play/index.mjs.map +0 -1
  113. package/dist/google-play/real-time-developer-notification.d.ts +0 -148
  114. package/dist/index.cjs.map +0 -1
  115. package/dist/index.d.ts +0 -6
  116. package/dist/index.mjs.map +0 -1
  117. package/dist/stripe/config.d.ts +0 -43
  118. package/dist/stripe/handler.d.ts +0 -15
  119. package/dist/stripe/index.cjs.map +0 -1
  120. package/dist/stripe/index.d.ts +0 -12
  121. package/dist/stripe/index.mjs.map +0 -1
  122. package/dist/stripe/mapper.d.ts +0 -157
  123. package/dist/stripe/metadata.d.ts +0 -10
  124. package/dist/stripe/schema.d.ts +0 -41
  125. package/dist/subscription/index.d.ts +0 -148
  126. package/dist/types.cjs.map +0 -1
  127. package/dist/types.d.ts +0 -9
  128. package/dist/types.mjs.map +0 -1
@@ -1,74 +1,68 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/stripe/pending-checkout.ts
21
- var pending_checkout_exports = {};
22
- __export(pending_checkout_exports, {
23
- addPendingCheckout: () => addPendingCheckout,
24
- getPendingCheckouts: () => getPendingCheckouts,
25
- removePendingCheckout: () => removePendingCheckout
26
- });
27
- module.exports = __toCommonJS(pending_checkout_exports);
28
- var KEY = "pending-checkout";
29
- var TTL = 60 * 60 * 1e3;
30
- var MAX = 5;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/stripe/pending-checkout.ts
3
+ /**
4
+ * Tracks checkouts that have been started but may not have been confirmed
5
+ * yet — e.g. the user paid on Stripe and closed the tab before being
6
+ * redirected back to the success page (where `confirmCheckoutSession` runs).
7
+ *
8
+ * IMPORTANT: this stores only the *session ids to retry confirmation on*, a
9
+ * best-effort retry hint — NOT the user's paid/balance state. The server
10
+ * remains the single source of truth for entitlements; on the next app boot
11
+ * we simply re-run the (idempotent, ownership-checked) confirm for each
12
+ * session so the credit balance reflects the purchase without waiting on the
13
+ * async Stripe webhook. Scoped to a single browser; cross-device is covered by
14
+ * the webhook backstop.
15
+ *
16
+ * A *list* (not a single value) is kept on purpose: localStorage is shared
17
+ * across tabs, so two concurrent checkouts — or a second checkout started
18
+ * before the first was reconciled — must not clobber each other.
19
+ */
20
+ const KEY = "pending-checkout";
21
+ /** Drop a hint after this long — an abandoned/unpaid checkout shouldn't retry forever. */
22
+ const TTL = 3600 * 1e3;
31
23
  function isFresh(entry) {
32
- return Date.now() - entry.ts <= TTL;
24
+ return Date.now() - entry.ts <= TTL;
33
25
  }
34
26
  function read() {
35
- try {
36
- const raw = localStorage.getItem(KEY);
37
- if (!raw) return [];
38
- const parsed = JSON.parse(raw);
39
- if (!Array.isArray(parsed)) return [];
40
- return parsed.filter(
41
- (e) => !!e && typeof e.sessionId === "string" && typeof e.ts === "number"
42
- );
43
- } catch {
44
- return [];
45
- }
27
+ try {
28
+ const raw = localStorage.getItem(KEY);
29
+ if (!raw) return [];
30
+ const parsed = JSON.parse(raw);
31
+ if (!Array.isArray(parsed)) return [];
32
+ return parsed.filter((e) => !!e && typeof e.sessionId === "string" && typeof e.ts === "number");
33
+ } catch {
34
+ return [];
35
+ }
46
36
  }
47
37
  function write(entries) {
48
- try {
49
- if (entries.length === 0) localStorage.removeItem(KEY);
50
- else localStorage.setItem(KEY, JSON.stringify(entries.slice(-MAX)));
51
- } catch {
52
- }
38
+ try {
39
+ if (entries.length === 0) localStorage.removeItem(KEY);
40
+ else localStorage.setItem(KEY, JSON.stringify(entries.slice(-5)));
41
+ } catch {}
53
42
  }
43
+ /** Record a started checkout to retry confirmation on later. Dedupes by session id. */
54
44
  function addPendingCheckout(sessionId) {
55
- const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);
56
- entries.push({ sessionId, ts: Date.now() });
57
- write(entries);
45
+ const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);
46
+ entries.push({
47
+ sessionId,
48
+ ts: Date.now()
49
+ });
50
+ write(entries);
58
51
  }
52
+ /** Fresh session ids awaiting confirmation. Persists the pruned list as a side effect. */
59
53
  function getPendingCheckouts() {
60
- const all = read();
61
- const fresh = all.filter(isFresh);
62
- if (fresh.length !== all.length) write(fresh);
63
- return fresh.map((e) => e.sessionId);
54
+ const all = read();
55
+ const fresh = all.filter(isFresh);
56
+ if (fresh.length !== all.length) write(fresh);
57
+ return fresh.map((e) => e.sessionId);
64
58
  }
59
+ /** Drop one session once it's confirmed (or known not to belong to this user). */
65
60
  function removePendingCheckout(sessionId) {
66
- write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));
61
+ write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));
67
62
  }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- addPendingCheckout,
71
- getPendingCheckouts,
72
- removePendingCheckout
73
- });
63
+ //#endregion
64
+ exports.addPendingCheckout = addPendingCheckout;
65
+ exports.getPendingCheckouts = getPendingCheckouts;
66
+ exports.removePendingCheckout = removePendingCheckout;
67
+
74
68
  //# sourceMappingURL=pending-checkout.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stripe/pending-checkout.ts"],"sourcesContent":["/**\n * Tracks checkouts that have been started but may not have been confirmed\n * yet — e.g. the user paid on Stripe and closed the tab before being\n * redirected back to the success page (where `confirmCheckoutSession` runs).\n *\n * IMPORTANT: this stores only the *session ids to retry confirmation on*, a\n * best-effort retry hint — NOT the user's paid/balance state. The server\n * remains the single source of truth for entitlements; on the next app boot\n * we simply re-run the (idempotent, ownership-checked) confirm for each\n * session so the credit balance reflects the purchase without waiting on the\n * async Stripe webhook. Scoped to a single browser; cross-device is covered by\n * the webhook backstop.\n *\n * A *list* (not a single value) is kept on purpose: localStorage is shared\n * across tabs, so two concurrent checkouts — or a second checkout started\n * before the first was reconciled — must not clobber each other.\n */\n\nconst KEY = 'pending-checkout';\n\n/** Drop a hint after this long — an abandoned/unpaid checkout shouldn't retry forever. */\nconst TTL = 60 * 60 * 1000; // 1 hour\n\n/** Cap the list so a string of abandoned checkouts can't grow it unbounded. */\nconst MAX = 5;\n\ntype Entry = { sessionId: string; ts: number };\n\nfunction isFresh(entry: Entry): boolean {\n return Date.now() - entry.ts <= TTL;\n}\n\nfunction read(): Entry[] {\n try {\n const raw = localStorage.getItem(KEY);\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter(\n (e): e is Entry => !!e && typeof e.sessionId === 'string' && typeof e.ts === 'number'\n );\n } catch {\n return [];\n }\n}\n\nfunction write(entries: Entry[]) {\n try {\n if (entries.length === 0) localStorage.removeItem(KEY);\n else localStorage.setItem(KEY, JSON.stringify(entries.slice(-MAX)));\n } catch {\n // ignore — storage unavailable / quota; the webhook still reconciles.\n }\n}\n\n/** Record a started checkout to retry confirmation on later. Dedupes by session id. */\nexport function addPendingCheckout(sessionId: string) {\n const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);\n entries.push({ sessionId, ts: Date.now() });\n write(entries);\n}\n\n/** Fresh session ids awaiting confirmation. Persists the pruned list as a side effect. */\nexport function getPendingCheckouts(): string[] {\n const all = read();\n const fresh = all.filter(isFresh);\n if (fresh.length !== all.length) write(fresh);\n return fresh.map((e) => e.sessionId);\n}\n\n/** Drop one session once it's confirmed (or known not to belong to this user). */\nexport function removePendingCheckout(sessionId: string) {\n write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,IAAM,MAAM;AAGZ,IAAM,MAAM,KAAK,KAAK;AAGtB,IAAM,MAAM;AAIZ,SAAS,QAAQ,OAAuB;AACtC,SAAO,KAAK,IAAI,IAAI,MAAM,MAAM;AAClC;AAEA,SAAS,OAAgB;AACvB,MAAI;AACF,UAAM,MAAM,aAAa,QAAQ,GAAG;AACpC,QAAI,CAAC,IAAK,QAAO,CAAC;AAClB,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,CAAC,MAAM,QAAQ,MAAM,EAAG,QAAO,CAAC;AACpC,WAAO,OAAO;AAAA,MACZ,CAAC,MAAkB,CAAC,CAAC,KAAK,OAAO,EAAE,cAAc,YAAY,OAAO,EAAE,OAAO;AAAA,IAC/E;AAAA,EACF,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEA,SAAS,MAAM,SAAkB;AAC/B,MAAI;AACF,QAAI,QAAQ,WAAW,EAAG,cAAa,WAAW,GAAG;AAAA,QAChD,cAAa,QAAQ,KAAK,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,CAAC,CAAC;AAAA,EACpE,QAAQ;AAAA,EAER;AACF;AAGO,SAAS,mBAAmB,WAAmB;AACpD,QAAM,UAAU,KAAK,EAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS;AAC5E,UAAQ,KAAK,EAAE,WAAW,IAAI,KAAK,IAAI,EAAE,CAAC;AAC1C,QAAM,OAAO;AACf;AAGO,SAAS,sBAAgC;AAC9C,QAAM,MAAM,KAAK;AACjB,QAAM,QAAQ,IAAI,OAAO,OAAO;AAChC,MAAI,MAAM,WAAW,IAAI,OAAQ,OAAM,KAAK;AAC5C,SAAO,MAAM,IAAI,CAAC,MAAM,EAAE,SAAS;AACrC;AAGO,SAAS,sBAAsB,WAAmB;AACvD,QAAM,KAAK,EAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS,CAAC;AACrE;","names":[]}
1
+ {"version":3,"file":"pending-checkout.cjs","names":[],"sources":["../../src/stripe/pending-checkout.ts"],"sourcesContent":["/**\n * Tracks checkouts that have been started but may not have been confirmed\n * yet — e.g. the user paid on Stripe and closed the tab before being\n * redirected back to the success page (where `confirmCheckoutSession` runs).\n *\n * IMPORTANT: this stores only the *session ids to retry confirmation on*, a\n * best-effort retry hint — NOT the user's paid/balance state. The server\n * remains the single source of truth for entitlements; on the next app boot\n * we simply re-run the (idempotent, ownership-checked) confirm for each\n * session so the credit balance reflects the purchase without waiting on the\n * async Stripe webhook. Scoped to a single browser; cross-device is covered by\n * the webhook backstop.\n *\n * A *list* (not a single value) is kept on purpose: localStorage is shared\n * across tabs, so two concurrent checkouts — or a second checkout started\n * before the first was reconciled — must not clobber each other.\n */\n\nconst KEY = 'pending-checkout';\n\n/** Drop a hint after this long — an abandoned/unpaid checkout shouldn't retry forever. */\nconst TTL = 60 * 60 * 1000; // 1 hour\n\n/** Cap the list so a string of abandoned checkouts can't grow it unbounded. */\nconst MAX = 5;\n\ntype Entry = { sessionId: string; ts: number };\n\nfunction isFresh(entry: Entry): boolean {\n return Date.now() - entry.ts <= TTL;\n}\n\nfunction read(): Entry[] {\n try {\n const raw = localStorage.getItem(KEY);\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter(\n (e): e is Entry => !!e && typeof e.sessionId === 'string' && typeof e.ts === 'number'\n );\n } catch {\n return [];\n }\n}\n\nfunction write(entries: Entry[]) {\n try {\n if (entries.length === 0) localStorage.removeItem(KEY);\n else localStorage.setItem(KEY, JSON.stringify(entries.slice(-MAX)));\n } catch {\n // ignore — storage unavailable / quota; the webhook still reconciles.\n }\n}\n\n/** Record a started checkout to retry confirmation on later. Dedupes by session id. */\nexport function addPendingCheckout(sessionId: string) {\n const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);\n entries.push({ sessionId, ts: Date.now() });\n write(entries);\n}\n\n/** Fresh session ids awaiting confirmation. Persists the pruned list as a side effect. */\nexport function getPendingCheckouts(): string[] {\n const all = read();\n const fresh = all.filter(isFresh);\n if (fresh.length !== all.length) write(fresh);\n return fresh.map((e) => e.sessionId);\n}\n\n/** Drop one session once it's confirmed (or known not to belong to this user). */\nexport function removePendingCheckout(sessionId: string) {\n write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAM,MAAM;;AAGZ,MAAM,MAAM,OAAU;AAOtB,SAAS,QAAQ,OAAuB;CACtC,OAAO,KAAK,IAAI,IAAI,MAAM,MAAM;AAClC;AAEA,SAAS,OAAgB;CACvB,IAAI;EACF,MAAM,MAAM,aAAa,QAAQ,GAAG;EACpC,IAAI,CAAC,KAAK,OAAO,CAAC;EAClB,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC;EACpC,OAAO,OAAO,QACX,MAAkB,CAAC,CAAC,KAAK,OAAO,EAAE,cAAc,YAAY,OAAO,EAAE,OAAO,QAC/E;CACF,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,SAAS,MAAM,SAAkB;CAC/B,IAAI;EACF,IAAI,QAAQ,WAAW,GAAG,aAAa,WAAW,GAAG;OAChD,aAAa,QAAQ,KAAK,KAAK,UAAU,QAAQ,MAAM,EAAI,CAAC,CAAC;CACpE,QAAQ,CAER;AACF;;AAGA,SAAgB,mBAAmB,WAAmB;CACpD,MAAM,UAAU,KAAK,CAAC,CAAC,QAAQ,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS;CAC5E,QAAQ,KAAK;EAAE;EAAW,IAAI,KAAK,IAAI;CAAE,CAAC;CAC1C,MAAM,OAAO;AACf;;AAGA,SAAgB,sBAAgC;CAC9C,MAAM,MAAM,KAAK;CACjB,MAAM,QAAQ,IAAI,OAAO,OAAO;CAChC,IAAI,MAAM,WAAW,IAAI,QAAQ,MAAM,KAAK;CAC5C,OAAO,MAAM,KAAK,MAAM,EAAE,SAAS;AACrC;;AAGA,SAAgB,sBAAsB,WAAmB;CACvD,MAAM,KAAK,CAAC,CAAC,QAAQ,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS,CAAC;AACrE"}
@@ -1,3 +1,4 @@
1
+ //#region src/stripe/pending-checkout.d.ts
1
2
  /**
2
3
  * Tracks checkouts that have been started but may not have been confirmed
3
4
  * yet — e.g. the user paid on Stripe and closed the tab before being
@@ -21,5 +22,6 @@ declare function addPendingCheckout(sessionId: string): void;
21
22
  declare function getPendingCheckouts(): string[];
22
23
  /** Drop one session once it's confirmed (or known not to belong to this user). */
23
24
  declare function removePendingCheckout(sessionId: string): void;
24
-
25
+ //#endregion
25
26
  export { addPendingCheckout, getPendingCheckouts, removePendingCheckout };
27
+ //# sourceMappingURL=pending-checkout.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-checkout.d.cts","names":[],"sources":["../../src/stripe/pending-checkout.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBAwDgB,mBAAmB;;iBAOnB;;iBAQA,sBAAsB"}
@@ -1,3 +1,4 @@
1
+ //#region src/stripe/pending-checkout.d.ts
1
2
  /**
2
3
  * Tracks checkouts that have been started but may not have been confirmed
3
4
  * yet — e.g. the user paid on Stripe and closed the tab before being
@@ -21,5 +22,6 @@ declare function addPendingCheckout(sessionId: string): void;
21
22
  declare function getPendingCheckouts(): string[];
22
23
  /** Drop one session once it's confirmed (or known not to belong to this user). */
23
24
  declare function removePendingCheckout(sessionId: string): void;
24
-
25
+ //#endregion
25
26
  export { addPendingCheckout, getPendingCheckouts, removePendingCheckout };
27
+ //# sourceMappingURL=pending-checkout.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-checkout.d.mts","names":[],"sources":["../../src/stripe/pending-checkout.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBAwDgB,mBAAmB;;iBAOnB;;iBAQA,sBAAsB"}
@@ -1,47 +1,65 @@
1
- // src/stripe/pending-checkout.ts
2
- var KEY = "pending-checkout";
3
- var TTL = 60 * 60 * 1e3;
4
- var MAX = 5;
1
+ //#region src/stripe/pending-checkout.ts
2
+ /**
3
+ * Tracks checkouts that have been started but may not have been confirmed
4
+ * yet — e.g. the user paid on Stripe and closed the tab before being
5
+ * redirected back to the success page (where `confirmCheckoutSession` runs).
6
+ *
7
+ * IMPORTANT: this stores only the *session ids to retry confirmation on*, a
8
+ * best-effort retry hint — NOT the user's paid/balance state. The server
9
+ * remains the single source of truth for entitlements; on the next app boot
10
+ * we simply re-run the (idempotent, ownership-checked) confirm for each
11
+ * session so the credit balance reflects the purchase without waiting on the
12
+ * async Stripe webhook. Scoped to a single browser; cross-device is covered by
13
+ * the webhook backstop.
14
+ *
15
+ * A *list* (not a single value) is kept on purpose: localStorage is shared
16
+ * across tabs, so two concurrent checkouts — or a second checkout started
17
+ * before the first was reconciled — must not clobber each other.
18
+ */
19
+ const KEY = "pending-checkout";
20
+ /** Drop a hint after this long — an abandoned/unpaid checkout shouldn't retry forever. */
21
+ const TTL = 3600 * 1e3;
5
22
  function isFresh(entry) {
6
- return Date.now() - entry.ts <= TTL;
23
+ return Date.now() - entry.ts <= TTL;
7
24
  }
8
25
  function read() {
9
- try {
10
- const raw = localStorage.getItem(KEY);
11
- if (!raw) return [];
12
- const parsed = JSON.parse(raw);
13
- if (!Array.isArray(parsed)) return [];
14
- return parsed.filter(
15
- (e) => !!e && typeof e.sessionId === "string" && typeof e.ts === "number"
16
- );
17
- } catch {
18
- return [];
19
- }
26
+ try {
27
+ const raw = localStorage.getItem(KEY);
28
+ if (!raw) return [];
29
+ const parsed = JSON.parse(raw);
30
+ if (!Array.isArray(parsed)) return [];
31
+ return parsed.filter((e) => !!e && typeof e.sessionId === "string" && typeof e.ts === "number");
32
+ } catch {
33
+ return [];
34
+ }
20
35
  }
21
36
  function write(entries) {
22
- try {
23
- if (entries.length === 0) localStorage.removeItem(KEY);
24
- else localStorage.setItem(KEY, JSON.stringify(entries.slice(-MAX)));
25
- } catch {
26
- }
37
+ try {
38
+ if (entries.length === 0) localStorage.removeItem(KEY);
39
+ else localStorage.setItem(KEY, JSON.stringify(entries.slice(-5)));
40
+ } catch {}
27
41
  }
42
+ /** Record a started checkout to retry confirmation on later. Dedupes by session id. */
28
43
  function addPendingCheckout(sessionId) {
29
- const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);
30
- entries.push({ sessionId, ts: Date.now() });
31
- write(entries);
44
+ const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);
45
+ entries.push({
46
+ sessionId,
47
+ ts: Date.now()
48
+ });
49
+ write(entries);
32
50
  }
51
+ /** Fresh session ids awaiting confirmation. Persists the pruned list as a side effect. */
33
52
  function getPendingCheckouts() {
34
- const all = read();
35
- const fresh = all.filter(isFresh);
36
- if (fresh.length !== all.length) write(fresh);
37
- return fresh.map((e) => e.sessionId);
53
+ const all = read();
54
+ const fresh = all.filter(isFresh);
55
+ if (fresh.length !== all.length) write(fresh);
56
+ return fresh.map((e) => e.sessionId);
38
57
  }
58
+ /** Drop one session once it's confirmed (or known not to belong to this user). */
39
59
  function removePendingCheckout(sessionId) {
40
- write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));
60
+ write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));
41
61
  }
42
- export {
43
- addPendingCheckout,
44
- getPendingCheckouts,
45
- removePendingCheckout
46
- };
62
+ //#endregion
63
+ export { addPendingCheckout, getPendingCheckouts, removePendingCheckout };
64
+
47
65
  //# sourceMappingURL=pending-checkout.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stripe/pending-checkout.ts"],"sourcesContent":["/**\n * Tracks checkouts that have been started but may not have been confirmed\n * yet — e.g. the user paid on Stripe and closed the tab before being\n * redirected back to the success page (where `confirmCheckoutSession` runs).\n *\n * IMPORTANT: this stores only the *session ids to retry confirmation on*, a\n * best-effort retry hint — NOT the user's paid/balance state. The server\n * remains the single source of truth for entitlements; on the next app boot\n * we simply re-run the (idempotent, ownership-checked) confirm for each\n * session so the credit balance reflects the purchase without waiting on the\n * async Stripe webhook. Scoped to a single browser; cross-device is covered by\n * the webhook backstop.\n *\n * A *list* (not a single value) is kept on purpose: localStorage is shared\n * across tabs, so two concurrent checkouts — or a second checkout started\n * before the first was reconciled — must not clobber each other.\n */\n\nconst KEY = 'pending-checkout';\n\n/** Drop a hint after this long — an abandoned/unpaid checkout shouldn't retry forever. */\nconst TTL = 60 * 60 * 1000; // 1 hour\n\n/** Cap the list so a string of abandoned checkouts can't grow it unbounded. */\nconst MAX = 5;\n\ntype Entry = { sessionId: string; ts: number };\n\nfunction isFresh(entry: Entry): boolean {\n return Date.now() - entry.ts <= TTL;\n}\n\nfunction read(): Entry[] {\n try {\n const raw = localStorage.getItem(KEY);\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter(\n (e): e is Entry => !!e && typeof e.sessionId === 'string' && typeof e.ts === 'number'\n );\n } catch {\n return [];\n }\n}\n\nfunction write(entries: Entry[]) {\n try {\n if (entries.length === 0) localStorage.removeItem(KEY);\n else localStorage.setItem(KEY, JSON.stringify(entries.slice(-MAX)));\n } catch {\n // ignore — storage unavailable / quota; the webhook still reconciles.\n }\n}\n\n/** Record a started checkout to retry confirmation on later. Dedupes by session id. */\nexport function addPendingCheckout(sessionId: string) {\n const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);\n entries.push({ sessionId, ts: Date.now() });\n write(entries);\n}\n\n/** Fresh session ids awaiting confirmation. Persists the pruned list as a side effect. */\nexport function getPendingCheckouts(): string[] {\n const all = read();\n const fresh = all.filter(isFresh);\n if (fresh.length !== all.length) write(fresh);\n return fresh.map((e) => e.sessionId);\n}\n\n/** Drop one session once it's confirmed (or known not to belong to this user). */\nexport function removePendingCheckout(sessionId: string) {\n write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));\n}\n"],"mappings":";AAkBA,IAAM,MAAM;AAGZ,IAAM,MAAM,KAAK,KAAK;AAGtB,IAAM,MAAM;AAIZ,SAAS,QAAQ,OAAuB;AACtC,SAAO,KAAK,IAAI,IAAI,MAAM,MAAM;AAClC;AAEA,SAAS,OAAgB;AACvB,MAAI;AACF,UAAM,MAAM,aAAa,QAAQ,GAAG;AACpC,QAAI,CAAC,IAAK,QAAO,CAAC;AAClB,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,CAAC,MAAM,QAAQ,MAAM,EAAG,QAAO,CAAC;AACpC,WAAO,OAAO;AAAA,MACZ,CAAC,MAAkB,CAAC,CAAC,KAAK,OAAO,EAAE,cAAc,YAAY,OAAO,EAAE,OAAO;AAAA,IAC/E;AAAA,EACF,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEA,SAAS,MAAM,SAAkB;AAC/B,MAAI;AACF,QAAI,QAAQ,WAAW,EAAG,cAAa,WAAW,GAAG;AAAA,QAChD,cAAa,QAAQ,KAAK,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,CAAC,CAAC;AAAA,EACpE,QAAQ;AAAA,EAER;AACF;AAGO,SAAS,mBAAmB,WAAmB;AACpD,QAAM,UAAU,KAAK,EAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS;AAC5E,UAAQ,KAAK,EAAE,WAAW,IAAI,KAAK,IAAI,EAAE,CAAC;AAC1C,QAAM,OAAO;AACf;AAGO,SAAS,sBAAgC;AAC9C,QAAM,MAAM,KAAK;AACjB,QAAM,QAAQ,IAAI,OAAO,OAAO;AAChC,MAAI,MAAM,WAAW,IAAI,OAAQ,OAAM,KAAK;AAC5C,SAAO,MAAM,IAAI,CAAC,MAAM,EAAE,SAAS;AACrC;AAGO,SAAS,sBAAsB,WAAmB;AACvD,QAAM,KAAK,EAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS,CAAC;AACrE;","names":[]}
1
+ {"version":3,"file":"pending-checkout.mjs","names":[],"sources":["../../src/stripe/pending-checkout.ts"],"sourcesContent":["/**\n * Tracks checkouts that have been started but may not have been confirmed\n * yet — e.g. the user paid on Stripe and closed the tab before being\n * redirected back to the success page (where `confirmCheckoutSession` runs).\n *\n * IMPORTANT: this stores only the *session ids to retry confirmation on*, a\n * best-effort retry hint — NOT the user's paid/balance state. The server\n * remains the single source of truth for entitlements; on the next app boot\n * we simply re-run the (idempotent, ownership-checked) confirm for each\n * session so the credit balance reflects the purchase without waiting on the\n * async Stripe webhook. Scoped to a single browser; cross-device is covered by\n * the webhook backstop.\n *\n * A *list* (not a single value) is kept on purpose: localStorage is shared\n * across tabs, so two concurrent checkouts — or a second checkout started\n * before the first was reconciled — must not clobber each other.\n */\n\nconst KEY = 'pending-checkout';\n\n/** Drop a hint after this long — an abandoned/unpaid checkout shouldn't retry forever. */\nconst TTL = 60 * 60 * 1000; // 1 hour\n\n/** Cap the list so a string of abandoned checkouts can't grow it unbounded. */\nconst MAX = 5;\n\ntype Entry = { sessionId: string; ts: number };\n\nfunction isFresh(entry: Entry): boolean {\n return Date.now() - entry.ts <= TTL;\n}\n\nfunction read(): Entry[] {\n try {\n const raw = localStorage.getItem(KEY);\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter(\n (e): e is Entry => !!e && typeof e.sessionId === 'string' && typeof e.ts === 'number'\n );\n } catch {\n return [];\n }\n}\n\nfunction write(entries: Entry[]) {\n try {\n if (entries.length === 0) localStorage.removeItem(KEY);\n else localStorage.setItem(KEY, JSON.stringify(entries.slice(-MAX)));\n } catch {\n // ignore — storage unavailable / quota; the webhook still reconciles.\n }\n}\n\n/** Record a started checkout to retry confirmation on later. Dedupes by session id. */\nexport function addPendingCheckout(sessionId: string) {\n const entries = read().filter((e) => isFresh(e) && e.sessionId !== sessionId);\n entries.push({ sessionId, ts: Date.now() });\n write(entries);\n}\n\n/** Fresh session ids awaiting confirmation. Persists the pruned list as a side effect. */\nexport function getPendingCheckouts(): string[] {\n const all = read();\n const fresh = all.filter(isFresh);\n if (fresh.length !== all.length) write(fresh);\n return fresh.map((e) => e.sessionId);\n}\n\n/** Drop one session once it's confirmed (or known not to belong to this user). */\nexport function removePendingCheckout(sessionId: string) {\n write(read().filter((e) => isFresh(e) && e.sessionId !== sessionId));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,MAAM;;AAGZ,MAAM,MAAM,OAAU;AAOtB,SAAS,QAAQ,OAAuB;CACtC,OAAO,KAAK,IAAI,IAAI,MAAM,MAAM;AAClC;AAEA,SAAS,OAAgB;CACvB,IAAI;EACF,MAAM,MAAM,aAAa,QAAQ,GAAG;EACpC,IAAI,CAAC,KAAK,OAAO,CAAC;EAClB,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC;EACpC,OAAO,OAAO,QACX,MAAkB,CAAC,CAAC,KAAK,OAAO,EAAE,cAAc,YAAY,OAAO,EAAE,OAAO,QAC/E;CACF,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,SAAS,MAAM,SAAkB;CAC/B,IAAI;EACF,IAAI,QAAQ,WAAW,GAAG,aAAa,WAAW,GAAG;OAChD,aAAa,QAAQ,KAAK,KAAK,UAAU,QAAQ,MAAM,EAAI,CAAC,CAAC;CACpE,QAAQ,CAER;AACF;;AAGA,SAAgB,mBAAmB,WAAmB;CACpD,MAAM,UAAU,KAAK,CAAC,CAAC,QAAQ,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS;CAC5E,QAAQ,KAAK;EAAE;EAAW,IAAI,KAAK,IAAI;CAAE,CAAC;CAC1C,MAAM,OAAO;AACf;;AAGA,SAAgB,sBAAgC;CAC9C,MAAM,MAAM,KAAK;CACjB,MAAM,QAAQ,IAAI,OAAO,OAAO;CAChC,IAAI,MAAM,WAAW,IAAI,QAAQ,MAAM,KAAK;CAC5C,OAAO,MAAM,KAAK,MAAM,EAAE,SAAS;AACrC;;AAGA,SAAgB,sBAAsB,WAAmB;CACvD,MAAM,KAAK,CAAC,CAAC,QAAQ,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,SAAS,CAAC;AACrE"}
@@ -1,59 +1,34 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/stripe/schema.ts
21
- var schema_exports = {};
22
- __export(schema_exports, {
23
- cancellationDetailsSchema: () => cancellationDetailsSchema,
24
- createCheckoutSessionSchema: () => createCheckoutSessionSchema
25
- });
26
- module.exports = __toCommonJS(schema_exports);
27
- var import_mini = require("zod/mini");
28
- var cancellationDetailsSchema = (0, import_mini.object)({
29
- comment: (0, import_mini.optional)((0, import_mini.nullable)((0, import_mini.string)().check((0, import_mini.maxLength)(1024)))),
30
- feedback: (0, import_mini.optional)(
31
- (0, import_mini.nullable)(
32
- (0, import_mini.enum)([
33
- "customer_service",
34
- "low_quality",
35
- "missing_features",
36
- "switched_service",
37
- "too_complex",
38
- "too_expensive",
39
- "unused",
40
- "other"
41
- ])
42
- )
43
- ),
44
- resubscribeIntent: (0, import_mini.optional)((0, import_mini.nullable)((0, import_mini.enum)(["maybe", "no", "yes"])))
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let zod_mini = require("zod/mini");
3
+ //#region src/stripe/schema.ts
4
+ const cancellationDetailsSchema = (0, zod_mini.object)({
5
+ comment: (0, zod_mini.optional)((0, zod_mini.nullable)((0, zod_mini.string)().check((0, zod_mini.maxLength)(1024)))),
6
+ feedback: (0, zod_mini.optional)((0, zod_mini.nullable)((0, zod_mini.enum)([
7
+ "customer_service",
8
+ "low_quality",
9
+ "missing_features",
10
+ "switched_service",
11
+ "too_complex",
12
+ "too_expensive",
13
+ "unused",
14
+ "other"
15
+ ]))),
16
+ resubscribeIntent: (0, zod_mini.optional)((0, zod_mini.nullable)((0, zod_mini.enum)([
17
+ "maybe",
18
+ "no",
19
+ "yes"
20
+ ])))
45
21
  });
46
22
  function createCheckoutSessionSchema(productIds) {
47
- return (0, import_mini.object)({
48
- quantity: (0, import_mini._default)((0, import_mini.int)().check((0, import_mini.gte)(1)), 1),
49
- productId: (0, import_mini.enum)(productIds),
50
- cancelUrl: (0, import_mini.optional)((0, import_mini.url)()),
51
- successUrl: (0, import_mini.optional)((0, import_mini.url)())
52
- });
23
+ return (0, zod_mini.object)({
24
+ quantity: (0, zod_mini._default)((0, zod_mini.int)().check((0, zod_mini.gte)(1)), 1),
25
+ productId: (0, zod_mini.enum)(productIds),
26
+ cancelUrl: (0, zod_mini.optional)((0, zod_mini.url)()),
27
+ successUrl: (0, zod_mini.optional)((0, zod_mini.url)())
28
+ });
53
29
  }
54
- // Annotate the CommonJS export names for ESM import in node:
55
- 0 && (module.exports = {
56
- cancellationDetailsSchema,
57
- createCheckoutSessionSchema
58
- });
30
+ //#endregion
31
+ exports.cancellationDetailsSchema = cancellationDetailsSchema;
32
+ exports.createCheckoutSessionSchema = createCheckoutSessionSchema;
33
+
59
34
  //# sourceMappingURL=schema.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stripe/schema.ts"],"sourcesContent":["import type { Stripe } from 'stripe';\nimport {\n _default,\n enum as _enum,\n gte,\n int,\n maxLength,\n nullable,\n object,\n optional,\n type output,\n string,\n url,\n} from 'zod/mini';\n\nexport const cancellationDetailsSchema = object({\n comment: optional(nullable(string().check(maxLength(1024)))),\n feedback: optional(\n nullable(\n _enum([\n 'customer_service',\n 'low_quality',\n 'missing_features',\n 'switched_service',\n 'too_complex',\n 'too_expensive',\n 'unused',\n 'other',\n ])\n )\n ),\n resubscribeIntent: optional(nullable(_enum(['maybe', 'no', 'yes']))),\n});\n\nexport function createCheckoutSessionSchema(productIds: string[]) {\n return object({\n quantity: _default(int().check(gte(1)), 1),\n productId: _enum(productIds),\n cancelUrl: optional(url()),\n successUrl: optional(url()),\n });\n}\n\nexport interface CancellationDetails extends output<typeof cancellationDetailsSchema> {\n reason?: Stripe.Subscription.CancellationDetails.Reason | null;\n}\n\nexport interface CreateCheckoutSessionDTO {\n productId: string;\n cancelUrl?: string;\n successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAYO;AAEA,IAAM,gCAA4B,oBAAO;AAAA,EAC9C,aAAS,0BAAS,0BAAS,oBAAO,EAAE,UAAM,uBAAU,IAAI,CAAC,CAAC,CAAC;AAAA,EAC3D,cAAU;AAAA,QACR;AAAA,UACE,YAAAA,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,uBAAmB,0BAAS,0BAAS,YAAAA,MAAM,CAAC,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAEM,SAAS,4BAA4B,YAAsB;AAChE,aAAO,oBAAO;AAAA,IACZ,cAAU,0BAAS,iBAAI,EAAE,UAAM,iBAAI,CAAC,CAAC,GAAG,CAAC;AAAA,IACzC,eAAW,YAAAA,MAAM,UAAU;AAAA,IAC3B,eAAW,0BAAS,iBAAI,CAAC;AAAA,IACzB,gBAAY,0BAAS,iBAAI,CAAC;AAAA,EAC5B,CAAC;AACH;","names":["_enum"]}
1
+ {"version":3,"file":"schema.cjs","names":[],"sources":["../../src/stripe/schema.ts"],"sourcesContent":["import type { Stripe } from 'stripe';\nimport {\n _default,\n enum as _enum,\n gte,\n int,\n maxLength,\n nullable,\n object,\n optional,\n type output,\n string,\n url,\n} from 'zod/mini';\n\nexport const cancellationDetailsSchema = object({\n comment: optional(nullable(string().check(maxLength(1024)))),\n feedback: optional(\n nullable(\n _enum([\n 'customer_service',\n 'low_quality',\n 'missing_features',\n 'switched_service',\n 'too_complex',\n 'too_expensive',\n 'unused',\n 'other',\n ])\n )\n ),\n resubscribeIntent: optional(nullable(_enum(['maybe', 'no', 'yes']))),\n});\n\nexport function createCheckoutSessionSchema(productIds: string[]) {\n return object({\n quantity: _default(int().check(gte(1)), 1),\n productId: _enum(productIds),\n cancelUrl: optional(url()),\n successUrl: optional(url()),\n });\n}\n\nexport interface CancellationDetails extends output<typeof cancellationDetailsSchema> {\n reason?: Stripe.Subscription.CancellationDetails.Reason | null;\n}\n\nexport interface CreateCheckoutSessionDTO {\n productId: string;\n cancelUrl?: string;\n successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;\n}\n"],"mappings":";;;AAeA,MAAa,6BAAA,GAAA,SAAA,OAAA,CAAmC;CAC9C,UAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,OAAA,CAAkC,CAAC,CAAC,OAAA,GAAA,SAAA,UAAA,CAAgB,IAAI,CAAC,CAAC,CAAC;CAC3D,WAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,KAAA,CAEU;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CACH,CACF;CACA,oBAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,KAAA,CAA2C;EAAC;EAAS;EAAM;CAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,4BAA4B,YAAsB;CAChE,QAAA,GAAA,SAAA,OAAA,CAAc;EACZ,WAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,IAAA,CAAuB,CAAC,CAAC,OAAA,GAAA,SAAA,IAAA,CAAU,CAAC,CAAC,GAAG,CAAC;EACzC,YAAA,GAAA,SAAA,KAAA,CAAiB,UAAU;EAC3B,YAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,IAAA,CAAwB,CAAC;EACzB,aAAA,GAAA,SAAA,SAAA,EAAA,GAAA,SAAA,IAAA,CAAyB,CAAC;CAC5B,CAAC;AACH"}
@@ -1,41 +1,40 @@
1
- import * as zod_v4_core from 'zod/v4/core';
2
- import * as zod_mini from 'zod/mini';
3
- import { output } from 'zod/mini';
4
- import { Stripe } from 'stripe';
5
-
6
- declare const cancellationDetailsSchema: zod_mini.ZodMiniObject<{
7
- comment: zod_mini.ZodMiniOptional<zod_mini.ZodMiniNullable<zod_mini.ZodMiniString<string>>>;
8
- feedback: zod_mini.ZodMiniOptional<zod_mini.ZodMiniNullable<zod_mini.ZodMiniEnum<{
9
- other: "other";
10
- customer_service: "customer_service";
11
- low_quality: "low_quality";
12
- missing_features: "missing_features";
13
- switched_service: "switched_service";
14
- too_complex: "too_complex";
15
- too_expensive: "too_expensive";
16
- unused: "unused";
17
- }>>>;
18
- resubscribeIntent: zod_mini.ZodMiniOptional<zod_mini.ZodMiniNullable<zod_mini.ZodMiniEnum<{
19
- maybe: "maybe";
20
- no: "no";
21
- yes: "yes";
22
- }>>>;
23
- }, zod_v4_core.$strip>;
24
- declare function createCheckoutSessionSchema(productIds: string[]): zod_mini.ZodMiniObject<{
25
- quantity: zod_mini.ZodMiniDefault<zod_mini.ZodMiniNumberFormat>;
26
- productId: zod_mini.ZodMiniEnum<{
27
- [x: string]: string;
28
- }>;
29
- cancelUrl: zod_mini.ZodMiniOptional<zod_mini.ZodMiniURL>;
30
- successUrl: zod_mini.ZodMiniOptional<zod_mini.ZodMiniURL>;
31
- }, zod_v4_core.$strip>;
1
+ import { Stripe } from "stripe";
2
+ import { output } from "zod/mini";
3
+ //#region src/stripe/schema.d.ts
4
+ declare const cancellationDetailsSchema: import("zod/mini").ZodMiniObject<{
5
+ comment: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNullable<import("zod/mini").ZodMiniString<string>>>;
6
+ feedback: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNullable<import("zod/mini").ZodMiniEnum<{
7
+ customer_service: "customer_service";
8
+ low_quality: "low_quality";
9
+ missing_features: "missing_features";
10
+ other: "other";
11
+ switched_service: "switched_service";
12
+ too_complex: "too_complex";
13
+ too_expensive: "too_expensive";
14
+ unused: "unused";
15
+ }>>>;
16
+ resubscribeIntent: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNullable<import("zod/mini").ZodMiniEnum<{
17
+ maybe: "maybe";
18
+ no: "no";
19
+ yes: "yes";
20
+ }>>>;
21
+ }, import("zod/v4/core").$strip>;
22
+ declare function createCheckoutSessionSchema(productIds: string[]): import("zod/mini").ZodMiniObject<{
23
+ quantity: import("zod/mini").ZodMiniDefault<import("zod/mini").ZodMiniNumberFormat>;
24
+ productId: import("zod/mini").ZodMiniEnum<{
25
+ [x: string]: string;
26
+ }>;
27
+ cancelUrl: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniURL>;
28
+ successUrl: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniURL>;
29
+ }, import("zod/v4/core").$strip>;
32
30
  interface CancellationDetails extends output<typeof cancellationDetailsSchema> {
33
- reason?: Stripe.Subscription.CancellationDetails.Reason | null;
31
+ reason?: Stripe.Subscription.CancellationDetails.Reason | null;
34
32
  }
35
33
  interface CreateCheckoutSessionDTO {
36
- productId: string;
37
- cancelUrl?: string;
38
- successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;
34
+ productId: string;
35
+ cancelUrl?: string;
36
+ successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;
39
37
  }
40
-
41
- export { type CancellationDetails, type CreateCheckoutSessionDTO, cancellationDetailsSchema, createCheckoutSessionSchema };
38
+ //#endregion
39
+ export { CancellationDetails, CreateCheckoutSessionDTO, cancellationDetailsSchema, createCheckoutSessionSchema };
40
+ //# sourceMappingURL=schema.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/stripe/schema.ts"],"mappings":";;;cAea,8CAAyB;;;;;;;;;;;;;;;;;;iBAmBtB,4BAA4B,0CAAoB;;;;;;;;UAS/C,4BAA4B,cAAc;EACzD,SAAS,OAAO,aAAa,oBAAoB;;UAGlC;EACf;EACA;EACA"}
@@ -0,0 +1,40 @@
1
+ import { output } from "zod/mini";
2
+ import { Stripe } from "stripe";
3
+ //#region src/stripe/schema.d.ts
4
+ declare const cancellationDetailsSchema: import("zod/mini").ZodMiniObject<{
5
+ comment: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNullable<import("zod/mini").ZodMiniString<string>>>;
6
+ feedback: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNullable<import("zod/mini").ZodMiniEnum<{
7
+ customer_service: "customer_service";
8
+ low_quality: "low_quality";
9
+ missing_features: "missing_features";
10
+ other: "other";
11
+ switched_service: "switched_service";
12
+ too_complex: "too_complex";
13
+ too_expensive: "too_expensive";
14
+ unused: "unused";
15
+ }>>>;
16
+ resubscribeIntent: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNullable<import("zod/mini").ZodMiniEnum<{
17
+ maybe: "maybe";
18
+ no: "no";
19
+ yes: "yes";
20
+ }>>>;
21
+ }, import("zod/v4/core").$strip>;
22
+ declare function createCheckoutSessionSchema(productIds: string[]): import("zod/mini").ZodMiniObject<{
23
+ quantity: import("zod/mini").ZodMiniDefault<import("zod/mini").ZodMiniNumberFormat>;
24
+ productId: import("zod/mini").ZodMiniEnum<{
25
+ [x: string]: string;
26
+ }>;
27
+ cancelUrl: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniURL>;
28
+ successUrl: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniURL>;
29
+ }, import("zod/v4/core").$strip>;
30
+ interface CancellationDetails extends output<typeof cancellationDetailsSchema> {
31
+ reason?: Stripe.Subscription.CancellationDetails.Reason | null;
32
+ }
33
+ interface CreateCheckoutSessionDTO {
34
+ productId: string;
35
+ cancelUrl?: string;
36
+ successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;
37
+ }
38
+ //#endregion
39
+ export { CancellationDetails, CreateCheckoutSessionDTO, cancellationDetailsSchema, createCheckoutSessionSchema };
40
+ //# sourceMappingURL=schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.mts","names":[],"sources":["../../src/stripe/schema.ts"],"mappings":";;;cAea,8CAAyB;;;;;;;;;;;;;;;;;;iBAmBtB,4BAA4B,0CAAoB;;;;;;;;UAS/C,4BAA4B,cAAc;EACzD,SAAS,OAAO,aAAa,oBAAoB;;UAGlC;EACf;EACA;EACA"}
@@ -1,44 +1,32 @@
1
- // src/stripe/schema.ts
2
- import {
3
- _default,
4
- enum as _enum,
5
- gte,
6
- int,
7
- maxLength,
8
- nullable,
9
- object,
10
- optional,
11
- string,
12
- url
13
- } from "zod/mini";
14
- var cancellationDetailsSchema = object({
15
- comment: optional(nullable(string().check(maxLength(1024)))),
16
- feedback: optional(
17
- nullable(
18
- _enum([
19
- "customer_service",
20
- "low_quality",
21
- "missing_features",
22
- "switched_service",
23
- "too_complex",
24
- "too_expensive",
25
- "unused",
26
- "other"
27
- ])
28
- )
29
- ),
30
- resubscribeIntent: optional(nullable(_enum(["maybe", "no", "yes"])))
1
+ import { _default, enum as enum$1, gte, int, maxLength, nullable, object, optional, string, url } from "zod/mini";
2
+ //#region src/stripe/schema.ts
3
+ const cancellationDetailsSchema = object({
4
+ comment: optional(nullable(string().check(maxLength(1024)))),
5
+ feedback: optional(nullable(enum$1([
6
+ "customer_service",
7
+ "low_quality",
8
+ "missing_features",
9
+ "switched_service",
10
+ "too_complex",
11
+ "too_expensive",
12
+ "unused",
13
+ "other"
14
+ ]))),
15
+ resubscribeIntent: optional(nullable(enum$1([
16
+ "maybe",
17
+ "no",
18
+ "yes"
19
+ ])))
31
20
  });
32
21
  function createCheckoutSessionSchema(productIds) {
33
- return object({
34
- quantity: _default(int().check(gte(1)), 1),
35
- productId: _enum(productIds),
36
- cancelUrl: optional(url()),
37
- successUrl: optional(url())
38
- });
22
+ return object({
23
+ quantity: _default(int().check(gte(1)), 1),
24
+ productId: enum$1(productIds),
25
+ cancelUrl: optional(url()),
26
+ successUrl: optional(url())
27
+ });
39
28
  }
40
- export {
41
- cancellationDetailsSchema,
42
- createCheckoutSessionSchema
43
- };
29
+ //#endregion
30
+ export { cancellationDetailsSchema, createCheckoutSessionSchema };
31
+
44
32
  //# sourceMappingURL=schema.mjs.map