@polar-sh/sdk 0.29.0 → 0.29.2

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 (271) hide show
  1. package/FUNCTIONS.md +5 -1
  2. package/README.md +48 -12
  3. package/bin/mcp-server.js +866 -148
  4. package/bin/mcp-server.js.map +29 -14
  5. package/dist/commonjs/funcs/customersGetState.d.ts +27 -0
  6. package/dist/commonjs/funcs/customersGetState.d.ts.map +1 -0
  7. package/dist/commonjs/funcs/customersGetState.js +121 -0
  8. package/dist/commonjs/funcs/customersGetState.js.map +1 -0
  9. package/dist/commonjs/funcs/customersGetStateExternal.d.ts +27 -0
  10. package/dist/commonjs/funcs/customersGetStateExternal.d.ts.map +1 -0
  11. package/dist/commonjs/funcs/customersGetStateExternal.js +121 -0
  12. package/dist/commonjs/funcs/customersGetStateExternal.js.map +1 -0
  13. package/dist/commonjs/lib/config.d.ts +2 -2
  14. package/dist/commonjs/lib/config.js +2 -2
  15. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  16. package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
  17. package/dist/commonjs/mcp-server/server.js +5 -1
  18. package/dist/commonjs/mcp-server/server.js.map +1 -1
  19. package/dist/commonjs/mcp-server/tools/customersGetState.d.ts +7 -0
  20. package/dist/commonjs/mcp-server/tools/customersGetState.d.ts.map +1 -0
  21. package/dist/commonjs/mcp-server/tools/customersGetState.js +40 -0
  22. package/dist/commonjs/mcp-server/tools/customersGetState.js.map +1 -0
  23. package/dist/commonjs/mcp-server/tools/customersGetStateExternal.d.ts +7 -0
  24. package/dist/commonjs/mcp-server/tools/customersGetStateExternal.d.ts.map +1 -0
  25. package/dist/commonjs/mcp-server/tools/customersGetStateExternal.js +40 -0
  26. package/dist/commonjs/mcp-server/tools/customersGetStateExternal.js.map +1 -0
  27. package/dist/commonjs/models/components/customer.d.ts +11 -5
  28. package/dist/commonjs/models/components/customer.d.ts.map +1 -1
  29. package/dist/commonjs/models/components/customer.js +2 -2
  30. package/dist/commonjs/models/components/customer.js.map +1 -1
  31. package/dist/commonjs/models/components/customercreate.d.ts +3 -0
  32. package/dist/commonjs/models/components/customercreate.d.ts.map +1 -1
  33. package/dist/commonjs/models/components/customercreate.js.map +1 -1
  34. package/dist/commonjs/models/components/customerordersubscription.d.ts +39 -0
  35. package/dist/commonjs/models/components/customerordersubscription.d.ts.map +1 -1
  36. package/dist/commonjs/models/components/customerordersubscription.js.map +1 -1
  37. package/dist/commonjs/models/components/customerstate.d.ts +143 -0
  38. package/dist/commonjs/models/components/customerstate.d.ts.map +1 -0
  39. package/dist/commonjs/models/components/customerstate.js +162 -0
  40. package/dist/commonjs/models/components/customerstate.js.map +1 -0
  41. package/dist/commonjs/models/components/customerstatebenefitgrant.d.ts +86 -0
  42. package/dist/commonjs/models/components/customerstatebenefitgrant.d.ts.map +1 -0
  43. package/dist/commonjs/models/components/customerstatebenefitgrant.js +141 -0
  44. package/dist/commonjs/models/components/customerstatebenefitgrant.js.map +1 -0
  45. package/dist/commonjs/models/components/customerstatesubscription.d.ts +162 -0
  46. package/dist/commonjs/models/components/customerstatesubscription.d.ts.map +1 -0
  47. package/dist/commonjs/models/components/customerstatesubscription.js +193 -0
  48. package/dist/commonjs/models/components/customerstatesubscription.js.map +1 -0
  49. package/dist/commonjs/models/components/customersubscription.d.ts +9 -0
  50. package/dist/commonjs/models/components/customersubscription.d.ts.map +1 -1
  51. package/dist/commonjs/models/components/customersubscription.js.map +1 -1
  52. package/dist/commonjs/models/components/customerupdate.d.ts +3 -0
  53. package/dist/commonjs/models/components/customerupdate.d.ts.map +1 -1
  54. package/dist/commonjs/models/components/customerupdate.js.map +1 -1
  55. package/dist/commonjs/models/components/licensekeycustomer.d.ts +11 -5
  56. package/dist/commonjs/models/components/licensekeycustomer.d.ts.map +1 -1
  57. package/dist/commonjs/models/components/licensekeycustomer.js +2 -2
  58. package/dist/commonjs/models/components/licensekeycustomer.js.map +1 -1
  59. package/dist/commonjs/models/components/ordercustomer.d.ts +11 -5
  60. package/dist/commonjs/models/components/ordercustomer.d.ts.map +1 -1
  61. package/dist/commonjs/models/components/ordercustomer.js +2 -2
  62. package/dist/commonjs/models/components/ordercustomer.js.map +1 -1
  63. package/dist/commonjs/models/components/ordersubscription.d.ts +39 -0
  64. package/dist/commonjs/models/components/ordersubscription.d.ts.map +1 -1
  65. package/dist/commonjs/models/components/ordersubscription.js.map +1 -1
  66. package/dist/commonjs/models/components/subscription.d.ts +39 -0
  67. package/dist/commonjs/models/components/subscription.d.ts.map +1 -1
  68. package/dist/commonjs/models/components/subscription.js.map +1 -1
  69. package/dist/commonjs/models/components/subscriptioncustomer.d.ts +11 -5
  70. package/dist/commonjs/models/components/subscriptioncustomer.d.ts.map +1 -1
  71. package/dist/commonjs/models/components/subscriptioncustomer.js +2 -2
  72. package/dist/commonjs/models/components/subscriptioncustomer.js.map +1 -1
  73. package/dist/commonjs/models/components/webhookcustomercreatedpayload.d.ts +47 -0
  74. package/dist/commonjs/models/components/webhookcustomercreatedpayload.d.ts.map +1 -0
  75. package/dist/commonjs/models/components/webhookcustomercreatedpayload.js +62 -0
  76. package/dist/commonjs/models/components/webhookcustomercreatedpayload.js.map +1 -0
  77. package/dist/commonjs/models/components/webhookcustomerdeletedpayload.d.ts +42 -0
  78. package/dist/commonjs/models/components/webhookcustomerdeletedpayload.d.ts.map +1 -0
  79. package/dist/commonjs/models/components/webhookcustomerdeletedpayload.js +62 -0
  80. package/dist/commonjs/models/components/webhookcustomerdeletedpayload.js.map +1 -0
  81. package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.d.ts +53 -0
  82. package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.d.ts.map +1 -0
  83. package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.js +62 -0
  84. package/dist/commonjs/models/components/webhookcustomerstatechangedpayload.js.map +1 -0
  85. package/dist/commonjs/models/components/webhookcustomerupdatedpayload.d.ts +46 -0
  86. package/dist/commonjs/models/components/webhookcustomerupdatedpayload.d.ts.map +1 -0
  87. package/dist/commonjs/models/components/webhookcustomerupdatedpayload.js +62 -0
  88. package/dist/commonjs/models/components/webhookcustomerupdatedpayload.js.map +1 -0
  89. package/dist/commonjs/models/components/webhookordercreatedpayload.d.ts +7 -0
  90. package/dist/commonjs/models/components/webhookordercreatedpayload.d.ts.map +1 -1
  91. package/dist/commonjs/models/components/webhookordercreatedpayload.js.map +1 -1
  92. package/dist/commonjs/models/components/webhooksubscriptioncreatedpayload.d.ts +2 -0
  93. package/dist/commonjs/models/components/webhooksubscriptioncreatedpayload.d.ts.map +1 -1
  94. package/dist/commonjs/models/components/webhooksubscriptioncreatedpayload.js.map +1 -1
  95. package/dist/commonjs/models/operations/customersgetstate.d.ts +32 -0
  96. package/dist/commonjs/models/operations/customersgetstate.d.ts.map +1 -0
  97. package/dist/commonjs/models/operations/customersgetstate.js +59 -0
  98. package/dist/commonjs/models/operations/customersgetstate.js.map +1 -0
  99. package/dist/commonjs/models/operations/customersgetstateexternal.d.ts +32 -0
  100. package/dist/commonjs/models/operations/customersgetstateexternal.d.ts.map +1 -0
  101. package/dist/commonjs/models/operations/customersgetstateexternal.js +68 -0
  102. package/dist/commonjs/models/operations/customersgetstateexternal.js.map +1 -0
  103. package/dist/commonjs/sdk/customers.d.ts +33 -0
  104. package/dist/commonjs/sdk/customers.d.ts.map +1 -1
  105. package/dist/commonjs/sdk/customers.js +36 -0
  106. package/dist/commonjs/sdk/customers.js.map +1 -1
  107. package/dist/commonjs/webhooks.d.ts +2 -2
  108. package/dist/commonjs/webhooks.d.ts.map +1 -1
  109. package/dist/commonjs/webhooks.js +36 -24
  110. package/dist/commonjs/webhooks.js.map +1 -1
  111. package/dist/esm/funcs/customersGetState.d.ts +27 -0
  112. package/dist/esm/funcs/customersGetState.d.ts.map +1 -0
  113. package/dist/esm/funcs/customersGetState.js +95 -0
  114. package/dist/esm/funcs/customersGetState.js.map +1 -0
  115. package/dist/esm/funcs/customersGetStateExternal.d.ts +27 -0
  116. package/dist/esm/funcs/customersGetStateExternal.d.ts.map +1 -0
  117. package/dist/esm/funcs/customersGetStateExternal.js +95 -0
  118. package/dist/esm/funcs/customersGetStateExternal.js.map +1 -0
  119. package/dist/esm/lib/config.d.ts +2 -2
  120. package/dist/esm/lib/config.js +2 -2
  121. package/dist/esm/mcp-server/mcp-server.js +1 -1
  122. package/dist/esm/mcp-server/server.d.ts.map +1 -1
  123. package/dist/esm/mcp-server/server.js +5 -1
  124. package/dist/esm/mcp-server/server.js.map +1 -1
  125. package/dist/esm/mcp-server/tools/customersGetState.d.ts +7 -0
  126. package/dist/esm/mcp-server/tools/customersGetState.d.ts.map +1 -0
  127. package/dist/esm/mcp-server/tools/customersGetState.js +37 -0
  128. package/dist/esm/mcp-server/tools/customersGetState.js.map +1 -0
  129. package/dist/esm/mcp-server/tools/customersGetStateExternal.d.ts +7 -0
  130. package/dist/esm/mcp-server/tools/customersGetStateExternal.d.ts.map +1 -0
  131. package/dist/esm/mcp-server/tools/customersGetStateExternal.js +37 -0
  132. package/dist/esm/mcp-server/tools/customersGetStateExternal.js.map +1 -0
  133. package/dist/esm/models/components/customer.d.ts +11 -5
  134. package/dist/esm/models/components/customer.d.ts.map +1 -1
  135. package/dist/esm/models/components/customer.js +2 -2
  136. package/dist/esm/models/components/customer.js.map +1 -1
  137. package/dist/esm/models/components/customercreate.d.ts +3 -0
  138. package/dist/esm/models/components/customercreate.d.ts.map +1 -1
  139. package/dist/esm/models/components/customercreate.js.map +1 -1
  140. package/dist/esm/models/components/customerordersubscription.d.ts +39 -0
  141. package/dist/esm/models/components/customerordersubscription.d.ts.map +1 -1
  142. package/dist/esm/models/components/customerordersubscription.js.map +1 -1
  143. package/dist/esm/models/components/customerstate.d.ts +143 -0
  144. package/dist/esm/models/components/customerstate.d.ts.map +1 -0
  145. package/dist/esm/models/components/customerstate.js +130 -0
  146. package/dist/esm/models/components/customerstate.js.map +1 -0
  147. package/dist/esm/models/components/customerstatebenefitgrant.d.ts +86 -0
  148. package/dist/esm/models/components/customerstatebenefitgrant.d.ts.map +1 -0
  149. package/dist/esm/models/components/customerstatebenefitgrant.js +111 -0
  150. package/dist/esm/models/components/customerstatebenefitgrant.js.map +1 -0
  151. package/dist/esm/models/components/customerstatesubscription.d.ts +162 -0
  152. package/dist/esm/models/components/customerstatesubscription.d.ts.map +1 -0
  153. package/dist/esm/models/components/customerstatesubscription.js +161 -0
  154. package/dist/esm/models/components/customerstatesubscription.js.map +1 -0
  155. package/dist/esm/models/components/customersubscription.d.ts +9 -0
  156. package/dist/esm/models/components/customersubscription.d.ts.map +1 -1
  157. package/dist/esm/models/components/customersubscription.js.map +1 -1
  158. package/dist/esm/models/components/customerupdate.d.ts +3 -0
  159. package/dist/esm/models/components/customerupdate.d.ts.map +1 -1
  160. package/dist/esm/models/components/customerupdate.js.map +1 -1
  161. package/dist/esm/models/components/licensekeycustomer.d.ts +11 -5
  162. package/dist/esm/models/components/licensekeycustomer.d.ts.map +1 -1
  163. package/dist/esm/models/components/licensekeycustomer.js +2 -2
  164. package/dist/esm/models/components/licensekeycustomer.js.map +1 -1
  165. package/dist/esm/models/components/ordercustomer.d.ts +11 -5
  166. package/dist/esm/models/components/ordercustomer.d.ts.map +1 -1
  167. package/dist/esm/models/components/ordercustomer.js +2 -2
  168. package/dist/esm/models/components/ordercustomer.js.map +1 -1
  169. package/dist/esm/models/components/ordersubscription.d.ts +39 -0
  170. package/dist/esm/models/components/ordersubscription.d.ts.map +1 -1
  171. package/dist/esm/models/components/ordersubscription.js.map +1 -1
  172. package/dist/esm/models/components/subscription.d.ts +39 -0
  173. package/dist/esm/models/components/subscription.d.ts.map +1 -1
  174. package/dist/esm/models/components/subscription.js.map +1 -1
  175. package/dist/esm/models/components/subscriptioncustomer.d.ts +11 -5
  176. package/dist/esm/models/components/subscriptioncustomer.d.ts.map +1 -1
  177. package/dist/esm/models/components/subscriptioncustomer.js +2 -2
  178. package/dist/esm/models/components/subscriptioncustomer.js.map +1 -1
  179. package/dist/esm/models/components/webhookcustomercreatedpayload.d.ts +47 -0
  180. package/dist/esm/models/components/webhookcustomercreatedpayload.d.ts.map +1 -0
  181. package/dist/esm/models/components/webhookcustomercreatedpayload.js +34 -0
  182. package/dist/esm/models/components/webhookcustomercreatedpayload.js.map +1 -0
  183. package/dist/esm/models/components/webhookcustomerdeletedpayload.d.ts +42 -0
  184. package/dist/esm/models/components/webhookcustomerdeletedpayload.d.ts.map +1 -0
  185. package/dist/esm/models/components/webhookcustomerdeletedpayload.js +34 -0
  186. package/dist/esm/models/components/webhookcustomerdeletedpayload.js.map +1 -0
  187. package/dist/esm/models/components/webhookcustomerstatechangedpayload.d.ts +53 -0
  188. package/dist/esm/models/components/webhookcustomerstatechangedpayload.d.ts.map +1 -0
  189. package/dist/esm/models/components/webhookcustomerstatechangedpayload.js +34 -0
  190. package/dist/esm/models/components/webhookcustomerstatechangedpayload.js.map +1 -0
  191. package/dist/esm/models/components/webhookcustomerupdatedpayload.d.ts +46 -0
  192. package/dist/esm/models/components/webhookcustomerupdatedpayload.d.ts.map +1 -0
  193. package/dist/esm/models/components/webhookcustomerupdatedpayload.js +34 -0
  194. package/dist/esm/models/components/webhookcustomerupdatedpayload.js.map +1 -0
  195. package/dist/esm/models/components/webhookordercreatedpayload.d.ts +7 -0
  196. package/dist/esm/models/components/webhookordercreatedpayload.d.ts.map +1 -1
  197. package/dist/esm/models/components/webhookordercreatedpayload.js.map +1 -1
  198. package/dist/esm/models/components/webhooksubscriptioncreatedpayload.d.ts +2 -0
  199. package/dist/esm/models/components/webhooksubscriptioncreatedpayload.d.ts.map +1 -1
  200. package/dist/esm/models/components/webhooksubscriptioncreatedpayload.js.map +1 -1
  201. package/dist/esm/models/operations/customersgetstate.d.ts +32 -0
  202. package/dist/esm/models/operations/customersgetstate.d.ts.map +1 -0
  203. package/dist/esm/models/operations/customersgetstate.js +31 -0
  204. package/dist/esm/models/operations/customersgetstate.js.map +1 -0
  205. package/dist/esm/models/operations/customersgetstateexternal.d.ts +32 -0
  206. package/dist/esm/models/operations/customersgetstateexternal.d.ts.map +1 -0
  207. package/dist/esm/models/operations/customersgetstateexternal.js +40 -0
  208. package/dist/esm/models/operations/customersgetstateexternal.js.map +1 -0
  209. package/dist/esm/sdk/customers.d.ts +33 -0
  210. package/dist/esm/sdk/customers.d.ts.map +1 -1
  211. package/dist/esm/sdk/customers.js +36 -0
  212. package/dist/esm/sdk/customers.js.map +1 -1
  213. package/dist/esm/webhooks.d.ts +2 -2
  214. package/dist/esm/webhooks.d.ts.map +1 -1
  215. package/dist/esm/webhooks.js +39 -27
  216. package/dist/esm/webhooks.js.map +1 -1
  217. package/docs/sdks/benefitgrants/README.md +10 -2
  218. package/docs/sdks/benefits/README.md +12 -2
  219. package/docs/sdks/checkoutlinks/README.md +10 -2
  220. package/docs/sdks/checkouts/README.md +16 -2
  221. package/docs/sdks/customers/README.md +206 -4
  222. package/docs/sdks/customfields/README.md +12 -2
  223. package/docs/sdks/discounts/README.md +12 -2
  224. package/docs/sdks/downloadables/README.md +10 -2
  225. package/docs/sdks/events/README.md +14 -2
  226. package/docs/sdks/externalorganizations/README.md +10 -2
  227. package/docs/sdks/files/README.md +8 -2
  228. package/docs/sdks/licensekeys/README.md +10 -2
  229. package/docs/sdks/meters/README.md +12 -2
  230. package/docs/sdks/metrics/README.md +6 -0
  231. package/docs/sdks/orders/README.md +10 -2
  232. package/docs/sdks/organizations/README.md +4 -4
  233. package/docs/sdks/polarlicensekeys/README.md +10 -2
  234. package/docs/sdks/polarorders/README.md +10 -2
  235. package/docs/sdks/polarsubscriptions/README.md +10 -2
  236. package/docs/sdks/products/README.md +12 -2
  237. package/docs/sdks/refunds/README.md +10 -2
  238. package/docs/sdks/repositories/README.md +10 -2
  239. package/docs/sdks/subscriptions/README.md +20 -4
  240. package/jsr.json +1 -1
  241. package/package.json +1 -1
  242. package/src/funcs/customersGetState.ts +195 -0
  243. package/src/funcs/customersGetStateExternal.ts +197 -0
  244. package/src/lib/config.ts +2 -2
  245. package/src/mcp-server/mcp-server.ts +1 -1
  246. package/src/mcp-server/server.ts +5 -1
  247. package/src/mcp-server/tools/customersGetState.ts +46 -0
  248. package/src/mcp-server/tools/customersGetStateExternal.ts +46 -0
  249. package/src/models/components/customer.ts +13 -7
  250. package/src/models/components/customercreate.ts +3 -0
  251. package/src/models/components/customerordersubscription.ts +39 -0
  252. package/src/models/components/customerstate.ts +308 -0
  253. package/src/models/components/customerstatebenefitgrant.ts +261 -0
  254. package/src/models/components/customerstatesubscription.ts +389 -0
  255. package/src/models/components/customersubscription.ts +9 -0
  256. package/src/models/components/customerupdate.ts +3 -0
  257. package/src/models/components/licensekeycustomer.ts +13 -7
  258. package/src/models/components/ordercustomer.ts +13 -7
  259. package/src/models/components/ordersubscription.ts +39 -0
  260. package/src/models/components/subscription.ts +39 -0
  261. package/src/models/components/subscriptioncustomer.ts +13 -7
  262. package/src/models/components/webhookcustomercreatedpayload.ts +93 -0
  263. package/src/models/components/webhookcustomerdeletedpayload.ts +88 -0
  264. package/src/models/components/webhookcustomerstatechangedpayload.ts +103 -0
  265. package/src/models/components/webhookcustomerupdatedpayload.ts +92 -0
  266. package/src/models/components/webhookordercreatedpayload.ts +7 -0
  267. package/src/models/components/webhooksubscriptioncreatedpayload.ts +2 -0
  268. package/src/models/operations/customersgetstate.ts +69 -0
  269. package/src/models/operations/customersgetstateexternal.ts +80 -0
  270. package/src/sdk/customers.ts +55 -0
  271. package/src/webhooks.ts +95 -78
@@ -0,0 +1,195 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { PolarCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ CustomerState,
15
+ CustomerState$inboundSchema,
16
+ } from "../models/components/customerstate.js";
17
+ import {
18
+ ConnectionError,
19
+ InvalidRequestError,
20
+ RequestAbortedError,
21
+ RequestTimeoutError,
22
+ UnexpectedClientError,
23
+ } from "../models/errors/httpclienterrors.js";
24
+ import {
25
+ HTTPValidationError,
26
+ HTTPValidationError$inboundSchema,
27
+ } from "../models/errors/httpvalidationerror.js";
28
+ import {
29
+ ResourceNotFound,
30
+ ResourceNotFound$inboundSchema,
31
+ } from "../models/errors/resourcenotfound.js";
32
+ import { SDKError } from "../models/errors/sdkerror.js";
33
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
34
+ import {
35
+ CustomersGetStateRequest,
36
+ CustomersGetStateRequest$outboundSchema,
37
+ } from "../models/operations/customersgetstate.js";
38
+ import { APICall, APIPromise } from "../types/async.js";
39
+ import { Result } from "../types/fp.js";
40
+
41
+ /**
42
+ * Get Customer State
43
+ *
44
+ * @remarks
45
+ * Get a customer state by ID.
46
+ *
47
+ * The customer state includes information about
48
+ * the customer's active subscriptions and benefits.
49
+ *
50
+ * It's the ideal endpoint to use when you need to get a full overview
51
+ * of a customer's status.
52
+ *
53
+ * **Scopes**: `customers:read` `customers:write`
54
+ */
55
+ export function customersGetState(
56
+ client: PolarCore,
57
+ request: CustomersGetStateRequest,
58
+ options?: RequestOptions,
59
+ ): APIPromise<
60
+ Result<
61
+ CustomerState,
62
+ | ResourceNotFound
63
+ | HTTPValidationError
64
+ | SDKError
65
+ | SDKValidationError
66
+ | UnexpectedClientError
67
+ | InvalidRequestError
68
+ | RequestAbortedError
69
+ | RequestTimeoutError
70
+ | ConnectionError
71
+ >
72
+ > {
73
+ return new APIPromise($do(
74
+ client,
75
+ request,
76
+ options,
77
+ ));
78
+ }
79
+
80
+ async function $do(
81
+ client: PolarCore,
82
+ request: CustomersGetStateRequest,
83
+ options?: RequestOptions,
84
+ ): Promise<
85
+ [
86
+ Result<
87
+ CustomerState,
88
+ | ResourceNotFound
89
+ | HTTPValidationError
90
+ | SDKError
91
+ | SDKValidationError
92
+ | UnexpectedClientError
93
+ | InvalidRequestError
94
+ | RequestAbortedError
95
+ | RequestTimeoutError
96
+ | ConnectionError
97
+ >,
98
+ APICall,
99
+ ]
100
+ > {
101
+ const parsed = safeParse(
102
+ request,
103
+ (value) => CustomersGetStateRequest$outboundSchema.parse(value),
104
+ "Input validation failed",
105
+ );
106
+ if (!parsed.ok) {
107
+ return [parsed, { status: "invalid" }];
108
+ }
109
+ const payload = parsed.value;
110
+ const body = null;
111
+
112
+ const pathParams = {
113
+ id: encodeSimple("id", payload.id, {
114
+ explode: false,
115
+ charEncoding: "percent",
116
+ }),
117
+ };
118
+
119
+ const path = pathToFunc("/v1/customers/{id}/state")(pathParams);
120
+
121
+ const headers = new Headers(compactMap({
122
+ Accept: "application/json",
123
+ }));
124
+
125
+ const secConfig = await extractSecurity(client._options.accessToken);
126
+ const securityInput = secConfig == null ? {} : { accessToken: secConfig };
127
+ const requestSecurity = resolveGlobalSecurity(securityInput);
128
+
129
+ const context = {
130
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
131
+ operationID: "customers:get_state",
132
+ oAuth2Scopes: [],
133
+
134
+ resolvedSecurity: requestSecurity,
135
+
136
+ securitySource: client._options.accessToken,
137
+ retryConfig: options?.retries
138
+ || client._options.retryConfig
139
+ || { strategy: "none" },
140
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
141
+ };
142
+
143
+ const requestRes = client._createRequest(context, {
144
+ security: requestSecurity,
145
+ method: "GET",
146
+ baseURL: options?.serverURL,
147
+ path: path,
148
+ headers: headers,
149
+ body: body,
150
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
151
+ }, options);
152
+ if (!requestRes.ok) {
153
+ return [requestRes, { status: "invalid" }];
154
+ }
155
+ const req = requestRes.value;
156
+
157
+ const doResult = await client._do(req, {
158
+ context,
159
+ errorCodes: ["404", "422", "4XX", "5XX"],
160
+ retryConfig: context.retryConfig,
161
+ retryCodes: context.retryCodes,
162
+ });
163
+ if (!doResult.ok) {
164
+ return [doResult, { status: "request-error", request: req }];
165
+ }
166
+ const response = doResult.value;
167
+
168
+ const responseFields = {
169
+ HttpMeta: { Response: response, Request: req },
170
+ };
171
+
172
+ const [result] = await M.match<
173
+ CustomerState,
174
+ | ResourceNotFound
175
+ | HTTPValidationError
176
+ | SDKError
177
+ | SDKValidationError
178
+ | UnexpectedClientError
179
+ | InvalidRequestError
180
+ | RequestAbortedError
181
+ | RequestTimeoutError
182
+ | ConnectionError
183
+ >(
184
+ M.json(200, CustomerState$inboundSchema),
185
+ M.jsonErr(404, ResourceNotFound$inboundSchema),
186
+ M.jsonErr(422, HTTPValidationError$inboundSchema),
187
+ M.fail("4XX"),
188
+ M.fail("5XX"),
189
+ )(response, { extraFields: responseFields });
190
+ if (!result.ok) {
191
+ return [result, { status: "complete", request: req, response }];
192
+ }
193
+
194
+ return [result, { status: "complete", request: req, response }];
195
+ }
@@ -0,0 +1,197 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { PolarCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ CustomerState,
15
+ CustomerState$inboundSchema,
16
+ } from "../models/components/customerstate.js";
17
+ import {
18
+ ConnectionError,
19
+ InvalidRequestError,
20
+ RequestAbortedError,
21
+ RequestTimeoutError,
22
+ UnexpectedClientError,
23
+ } from "../models/errors/httpclienterrors.js";
24
+ import {
25
+ HTTPValidationError,
26
+ HTTPValidationError$inboundSchema,
27
+ } from "../models/errors/httpvalidationerror.js";
28
+ import {
29
+ ResourceNotFound,
30
+ ResourceNotFound$inboundSchema,
31
+ } from "../models/errors/resourcenotfound.js";
32
+ import { SDKError } from "../models/errors/sdkerror.js";
33
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
34
+ import {
35
+ CustomersGetStateExternalRequest,
36
+ CustomersGetStateExternalRequest$outboundSchema,
37
+ } from "../models/operations/customersgetstateexternal.js";
38
+ import { APICall, APIPromise } from "../types/async.js";
39
+ import { Result } from "../types/fp.js";
40
+
41
+ /**
42
+ * Get Customer State by External ID
43
+ *
44
+ * @remarks
45
+ * Get a customer state by external ID.
46
+ *
47
+ * The customer state includes information about
48
+ * the customer's active subscriptions and benefits.
49
+ *
50
+ * It's the ideal endpoint to use when you need to get a full overview
51
+ * of a customer's status.
52
+ *
53
+ * **Scopes**: `customers:read` `customers:write`
54
+ */
55
+ export function customersGetStateExternal(
56
+ client: PolarCore,
57
+ request: CustomersGetStateExternalRequest,
58
+ options?: RequestOptions,
59
+ ): APIPromise<
60
+ Result<
61
+ CustomerState,
62
+ | ResourceNotFound
63
+ | HTTPValidationError
64
+ | SDKError
65
+ | SDKValidationError
66
+ | UnexpectedClientError
67
+ | InvalidRequestError
68
+ | RequestAbortedError
69
+ | RequestTimeoutError
70
+ | ConnectionError
71
+ >
72
+ > {
73
+ return new APIPromise($do(
74
+ client,
75
+ request,
76
+ options,
77
+ ));
78
+ }
79
+
80
+ async function $do(
81
+ client: PolarCore,
82
+ request: CustomersGetStateExternalRequest,
83
+ options?: RequestOptions,
84
+ ): Promise<
85
+ [
86
+ Result<
87
+ CustomerState,
88
+ | ResourceNotFound
89
+ | HTTPValidationError
90
+ | SDKError
91
+ | SDKValidationError
92
+ | UnexpectedClientError
93
+ | InvalidRequestError
94
+ | RequestAbortedError
95
+ | RequestTimeoutError
96
+ | ConnectionError
97
+ >,
98
+ APICall,
99
+ ]
100
+ > {
101
+ const parsed = safeParse(
102
+ request,
103
+ (value) => CustomersGetStateExternalRequest$outboundSchema.parse(value),
104
+ "Input validation failed",
105
+ );
106
+ if (!parsed.ok) {
107
+ return [parsed, { status: "invalid" }];
108
+ }
109
+ const payload = parsed.value;
110
+ const body = null;
111
+
112
+ const pathParams = {
113
+ external_id: encodeSimple("external_id", payload.external_id, {
114
+ explode: false,
115
+ charEncoding: "percent",
116
+ }),
117
+ };
118
+
119
+ const path = pathToFunc("/v1/customers/external/{external_id}/state")(
120
+ pathParams,
121
+ );
122
+
123
+ const headers = new Headers(compactMap({
124
+ Accept: "application/json",
125
+ }));
126
+
127
+ const secConfig = await extractSecurity(client._options.accessToken);
128
+ const securityInput = secConfig == null ? {} : { accessToken: secConfig };
129
+ const requestSecurity = resolveGlobalSecurity(securityInput);
130
+
131
+ const context = {
132
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
133
+ operationID: "customers:get_state_external",
134
+ oAuth2Scopes: [],
135
+
136
+ resolvedSecurity: requestSecurity,
137
+
138
+ securitySource: client._options.accessToken,
139
+ retryConfig: options?.retries
140
+ || client._options.retryConfig
141
+ || { strategy: "none" },
142
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
143
+ };
144
+
145
+ const requestRes = client._createRequest(context, {
146
+ security: requestSecurity,
147
+ method: "GET",
148
+ baseURL: options?.serverURL,
149
+ path: path,
150
+ headers: headers,
151
+ body: body,
152
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
153
+ }, options);
154
+ if (!requestRes.ok) {
155
+ return [requestRes, { status: "invalid" }];
156
+ }
157
+ const req = requestRes.value;
158
+
159
+ const doResult = await client._do(req, {
160
+ context,
161
+ errorCodes: ["404", "422", "4XX", "5XX"],
162
+ retryConfig: context.retryConfig,
163
+ retryCodes: context.retryCodes,
164
+ });
165
+ if (!doResult.ok) {
166
+ return [doResult, { status: "request-error", request: req }];
167
+ }
168
+ const response = doResult.value;
169
+
170
+ const responseFields = {
171
+ HttpMeta: { Response: response, Request: req },
172
+ };
173
+
174
+ const [result] = await M.match<
175
+ CustomerState,
176
+ | ResourceNotFound
177
+ | HTTPValidationError
178
+ | SDKError
179
+ | SDKValidationError
180
+ | UnexpectedClientError
181
+ | InvalidRequestError
182
+ | RequestAbortedError
183
+ | RequestTimeoutError
184
+ | ConnectionError
185
+ >(
186
+ M.json(200, CustomerState$inboundSchema),
187
+ M.jsonErr(404, ResourceNotFound$inboundSchema),
188
+ M.jsonErr(422, HTTPValidationError$inboundSchema),
189
+ M.fail("4XX"),
190
+ M.fail("5XX"),
191
+ )(response, { extraFields: responseFields });
192
+ if (!result.ok) {
193
+ return [result, { status: "complete", request: req, response }];
194
+ }
195
+
196
+ return [result, { status: "complete", request: req, response }];
197
+ }
package/src/lib/config.ts CHANGED
@@ -60,7 +60,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
60
60
  export const SDK_METADATA = {
61
61
  language: "typescript",
62
62
  openapiDocVersion: "0.1.0",
63
- sdkVersion: "0.29.0",
63
+ sdkVersion: "0.29.2",
64
64
  genVersion: "2.539.1",
65
- userAgent: "speakeasy-sdk/typescript 0.29.0 2.539.1 0.1.0 @polar-sh/sdk",
65
+ userAgent: "speakeasy-sdk/typescript 0.29.2 2.539.1 0.1.0 @polar-sh/sdk",
66
66
  } as const;
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.29.0",
22
+ currentVersion: "0.29.2",
23
23
  },
24
24
  });
25
25
 
@@ -13,6 +13,8 @@ import { tool$customersDelete } from "./tools/customersDelete.js";
13
13
  import { tool$customersDeleteExternal } from "./tools/customersDeleteExternal.js";
14
14
  import { tool$customersGet } from "./tools/customersGet.js";
15
15
  import { tool$customersGetExternal } from "./tools/customersGetExternal.js";
16
+ import { tool$customersGetState } from "./tools/customersGetState.js";
17
+ import { tool$customersGetStateExternal } from "./tools/customersGetStateExternal.js";
16
18
  import { tool$customersList } from "./tools/customersList.js";
17
19
  import { tool$customersUpdate } from "./tools/customersUpdate.js";
18
20
  import { tool$customersUpdateExternal } from "./tools/customersUpdateExternal.js";
@@ -42,7 +44,7 @@ export function createMCPServer(deps: {
42
44
  }) {
43
45
  const server = new McpServer({
44
46
  name: "Polar",
45
- version: "0.29.0",
47
+ version: "0.29.2",
46
48
  });
47
49
 
48
50
  const client = new PolarCore({
@@ -83,6 +85,8 @@ export function createMCPServer(deps: {
83
85
  tool(tool$customersGetExternal);
84
86
  tool(tool$customersUpdateExternal);
85
87
  tool(tool$customersDeleteExternal);
88
+ tool(tool$customersGetState);
89
+ tool(tool$customersGetStateExternal);
86
90
 
87
91
  return server;
88
92
  }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { customersGetState } from "../../funcs/customersGetState.js";
6
+ import { CustomersGetStateRequest$inboundSchema } from "../../models/operations/customersgetstate.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: CustomersGetStateRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$customersGetState: ToolDefinition<typeof args> = {
14
+ name: "customers_get-state",
15
+ description: `Get Customer State
16
+
17
+ Get a customer state by ID.
18
+
19
+ The customer state includes information about
20
+ the customer's active subscriptions and benefits.
21
+
22
+ It's the ideal endpoint to use when you need to get a full overview
23
+ of a customer's status.
24
+
25
+ **Scopes**: \`customers:read\` \`customers:write\``,
26
+ scopes: ["read", "customers"],
27
+ args,
28
+ tool: async (client, args, ctx) => {
29
+ const [result, apiCall] = await customersGetState(
30
+ client,
31
+ args.request,
32
+ { fetchOptions: { signal: ctx.signal } },
33
+ ).$inspect();
34
+
35
+ if (!result.ok) {
36
+ return {
37
+ content: [{ type: "text", text: result.error.message }],
38
+ isError: true,
39
+ };
40
+ }
41
+
42
+ const value = result.value;
43
+
44
+ return formatResult(value, apiCall);
45
+ },
46
+ };
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { customersGetStateExternal } from "../../funcs/customersGetStateExternal.js";
6
+ import { CustomersGetStateExternalRequest$inboundSchema } from "../../models/operations/customersgetstateexternal.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: CustomersGetStateExternalRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$customersGetStateExternal: ToolDefinition<typeof args> = {
14
+ name: "customers_get-state-external",
15
+ description: `Get Customer State by External ID
16
+
17
+ Get a customer state by external ID.
18
+
19
+ The customer state includes information about
20
+ the customer's active subscriptions and benefits.
21
+
22
+ It's the ideal endpoint to use when you need to get a full overview
23
+ of a customer's status.
24
+
25
+ **Scopes**: \`customers:read\` \`customers:write\``,
26
+ scopes: ["read", "customers"],
27
+ args,
28
+ tool: async (client, args, ctx) => {
29
+ const [result, apiCall] = await customersGetStateExternal(
30
+ client,
31
+ args.request,
32
+ { fetchOptions: { signal: ctx.signal } },
33
+ ).$inspect();
34
+
35
+ if (!result.ok) {
36
+ return {
37
+ content: [{ type: "text", text: result.error.message }],
38
+ isError: true,
39
+ };
40
+ }
41
+
42
+ const value = result.value;
43
+
44
+ return formatResult(value, apiCall);
45
+ },
46
+ };
@@ -27,6 +27,10 @@ export type CustomerTaxId = string | TaxIDFormat;
27
27
  * A customer in an organization.
28
28
  */
29
29
  export type Customer = {
30
+ /**
31
+ * The ID of the customer.
32
+ */
33
+ id: string;
30
34
  /**
31
35
  * Creation timestamp of the object.
32
36
  */
@@ -35,10 +39,6 @@ export type Customer = {
35
39
  * Last modification timestamp of the object.
36
40
  */
37
41
  modifiedAt: Date | null;
38
- /**
39
- * The ID of the object.
40
- */
41
- id: string;
42
42
  metadata: { [k: string]: string | number | boolean };
43
43
  /**
44
44
  * The ID of the customer in your system. This must be unique within the organization. Once set, it can't be updated.
@@ -52,9 +52,15 @@ export type Customer = {
52
52
  * Whether the customer email address is verified. The address is automatically verified when the customer accesses the customer portal using their email address.
53
53
  */
54
54
  emailVerified: boolean;
55
+ /**
56
+ * The name of the customer.
57
+ */
55
58
  name: string | null;
56
59
  billingAddress: Address | null;
57
60
  taxId: Array<string | TaxIDFormat | null> | null;
61
+ /**
62
+ * The ID of the organization owning the customer.
63
+ */
58
64
  organizationId: string;
59
65
  avatarUrl: string;
60
66
  };
@@ -157,11 +163,11 @@ export const Customer$inboundSchema: z.ZodType<
157
163
  z.ZodTypeDef,
158
164
  unknown
159
165
  > = z.object({
166
+ id: z.string(),
160
167
  created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
161
168
  modified_at: z.nullable(
162
169
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
163
170
  ),
164
- id: z.string(),
165
171
  metadata: z.record(z.union([z.string(), z.number().int(), z.boolean()])),
166
172
  external_id: z.nullable(z.string()),
167
173
  email: z.string(),
@@ -188,9 +194,9 @@ export const Customer$inboundSchema: z.ZodType<
188
194
 
189
195
  /** @internal */
190
196
  export type Customer$Outbound = {
197
+ id: string;
191
198
  created_at: string;
192
199
  modified_at: string | null;
193
- id: string;
194
200
  metadata: { [k: string]: string | number | boolean };
195
201
  external_id: string | null;
196
202
  email: string;
@@ -208,9 +214,9 @@ export const Customer$outboundSchema: z.ZodType<
208
214
  z.ZodTypeDef,
209
215
  Customer
210
216
  > = z.object({
217
+ id: z.string(),
211
218
  createdAt: z.date().transform(v => v.toISOString()),
212
219
  modifiedAt: z.nullable(z.date().transform(v => v.toISOString())),
213
- id: z.string(),
214
220
  metadata: z.record(z.union([z.string(), z.number().int(), z.boolean()])),
215
221
  externalId: z.nullable(z.string()),
216
222
  email: z.string(),
@@ -47,6 +47,9 @@ export type CustomerCreate = {
47
47
  * The email address of the customer. This must be unique within the organization.
48
48
  */
49
49
  email: string;
50
+ /**
51
+ * The name of the customer.
52
+ */
50
53
  name?: string | null | undefined;
51
54
  billingAddress?: Address | null | undefined;
52
55
  taxId?: Array<string | TaxIDFormat | null> | null | undefined;
@@ -36,20 +36,59 @@ export type CustomerOrderSubscription = {
36
36
  * The ID of the object.
37
37
  */
38
38
  id: string;
39
+ /**
40
+ * The amount of the subscription.
41
+ */
39
42
  amount: number | null;
43
+ /**
44
+ * The currency of the subscription.
45
+ */
40
46
  currency: string | null;
41
47
  recurringInterval: SubscriptionRecurringInterval;
42
48
  status: SubscriptionStatus;
49
+ /**
50
+ * The start timestamp of the current billing period.
51
+ */
43
52
  currentPeriodStart: Date;
53
+ /**
54
+ * The end timestamp of the current billing period.
55
+ */
44
56
  currentPeriodEnd: Date | null;
57
+ /**
58
+ * Whether the subscription will be canceled at the end of the current period.
59
+ */
45
60
  cancelAtPeriodEnd: boolean;
61
+ /**
62
+ * The timestamp when the subscription was canceled. The subscription might still be active if `cancel_at_period_end` is `true`.
63
+ */
46
64
  canceledAt: Date | null;
65
+ /**
66
+ * The timestamp when the subscription started.
67
+ */
47
68
  startedAt: Date | null;
69
+ /**
70
+ * The timestamp when the subscription will end.
71
+ */
48
72
  endsAt: Date | null;
73
+ /**
74
+ * The timestamp when the subscription ended.
75
+ */
49
76
  endedAt: Date | null;
77
+ /**
78
+ * The ID of the subscribed customer.
79
+ */
50
80
  customerId: string;
81
+ /**
82
+ * The ID of the subscribed product.
83
+ */
51
84
  productId: string;
85
+ /**
86
+ * The ID of the subscribed price.
87
+ */
52
88
  priceId: string;
89
+ /**
90
+ * The ID of the applied discount, if any.
91
+ */
53
92
  discountId: string | null;
54
93
  checkoutId: string | null;
55
94
  customerCancellationReason: CustomerCancellationReason | null;