@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,308 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+ import {
11
+ Address,
12
+ Address$inboundSchema,
13
+ Address$Outbound,
14
+ Address$outboundSchema,
15
+ } from "./address.js";
16
+ import {
17
+ CustomerStateBenefitGrant,
18
+ CustomerStateBenefitGrant$inboundSchema,
19
+ CustomerStateBenefitGrant$Outbound,
20
+ CustomerStateBenefitGrant$outboundSchema,
21
+ } from "./customerstatebenefitgrant.js";
22
+ import {
23
+ CustomerStateSubscription,
24
+ CustomerStateSubscription$inboundSchema,
25
+ CustomerStateSubscription$Outbound,
26
+ CustomerStateSubscription$outboundSchema,
27
+ } from "./customerstatesubscription.js";
28
+ import {
29
+ TaxIDFormat,
30
+ TaxIDFormat$inboundSchema,
31
+ TaxIDFormat$outboundSchema,
32
+ } from "./taxidformat.js";
33
+
34
+ export type CustomerStateMetadata = string | number | boolean;
35
+
36
+ export type CustomerStateTaxId = string | TaxIDFormat;
37
+
38
+ /**
39
+ * A customer along with additional state information:
40
+ *
41
+ * @remarks
42
+ *
43
+ * * Active subscriptions
44
+ * * Active benefits
45
+ */
46
+ export type CustomerState = {
47
+ /**
48
+ * The ID of the customer.
49
+ */
50
+ id: string;
51
+ /**
52
+ * Creation timestamp of the object.
53
+ */
54
+ createdAt: Date;
55
+ /**
56
+ * Last modification timestamp of the object.
57
+ */
58
+ modifiedAt: Date | null;
59
+ metadata: { [k: string]: string | number | boolean };
60
+ /**
61
+ * The ID of the customer in your system. This must be unique within the organization. Once set, it can't be updated.
62
+ */
63
+ externalId: string | null;
64
+ /**
65
+ * The email address of the customer. This must be unique within the organization.
66
+ */
67
+ email: string;
68
+ /**
69
+ * Whether the customer email address is verified. The address is automatically verified when the customer accesses the customer portal using their email address.
70
+ */
71
+ emailVerified: boolean;
72
+ /**
73
+ * The name of the customer.
74
+ */
75
+ name: string | null;
76
+ billingAddress: Address | null;
77
+ taxId: Array<string | TaxIDFormat | null> | null;
78
+ /**
79
+ * The ID of the organization owning the customer.
80
+ */
81
+ organizationId: string;
82
+ /**
83
+ * The customer's active subscriptions.
84
+ */
85
+ activeSubscriptions: Array<CustomerStateSubscription>;
86
+ /**
87
+ * The customer's active benefit grants.
88
+ */
89
+ grantedBenefits: Array<CustomerStateBenefitGrant>;
90
+ avatarUrl: string;
91
+ };
92
+
93
+ /** @internal */
94
+ export const CustomerStateMetadata$inboundSchema: z.ZodType<
95
+ CustomerStateMetadata,
96
+ z.ZodTypeDef,
97
+ unknown
98
+ > = z.union([z.string(), z.number().int(), z.boolean()]);
99
+
100
+ /** @internal */
101
+ export type CustomerStateMetadata$Outbound = string | number | boolean;
102
+
103
+ /** @internal */
104
+ export const CustomerStateMetadata$outboundSchema: z.ZodType<
105
+ CustomerStateMetadata$Outbound,
106
+ z.ZodTypeDef,
107
+ CustomerStateMetadata
108
+ > = z.union([z.string(), z.number().int(), z.boolean()]);
109
+
110
+ /**
111
+ * @internal
112
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
113
+ */
114
+ export namespace CustomerStateMetadata$ {
115
+ /** @deprecated use `CustomerStateMetadata$inboundSchema` instead. */
116
+ export const inboundSchema = CustomerStateMetadata$inboundSchema;
117
+ /** @deprecated use `CustomerStateMetadata$outboundSchema` instead. */
118
+ export const outboundSchema = CustomerStateMetadata$outboundSchema;
119
+ /** @deprecated use `CustomerStateMetadata$Outbound` instead. */
120
+ export type Outbound = CustomerStateMetadata$Outbound;
121
+ }
122
+
123
+ export function customerStateMetadataToJSON(
124
+ customerStateMetadata: CustomerStateMetadata,
125
+ ): string {
126
+ return JSON.stringify(
127
+ CustomerStateMetadata$outboundSchema.parse(customerStateMetadata),
128
+ );
129
+ }
130
+
131
+ export function customerStateMetadataFromJSON(
132
+ jsonString: string,
133
+ ): SafeParseResult<CustomerStateMetadata, SDKValidationError> {
134
+ return safeParse(
135
+ jsonString,
136
+ (x) => CustomerStateMetadata$inboundSchema.parse(JSON.parse(x)),
137
+ `Failed to parse 'CustomerStateMetadata' from JSON`,
138
+ );
139
+ }
140
+
141
+ /** @internal */
142
+ export const CustomerStateTaxId$inboundSchema: z.ZodType<
143
+ CustomerStateTaxId,
144
+ z.ZodTypeDef,
145
+ unknown
146
+ > = z.union([z.string(), TaxIDFormat$inboundSchema]);
147
+
148
+ /** @internal */
149
+ export type CustomerStateTaxId$Outbound = string | string;
150
+
151
+ /** @internal */
152
+ export const CustomerStateTaxId$outboundSchema: z.ZodType<
153
+ CustomerStateTaxId$Outbound,
154
+ z.ZodTypeDef,
155
+ CustomerStateTaxId
156
+ > = z.union([z.string(), TaxIDFormat$outboundSchema]);
157
+
158
+ /**
159
+ * @internal
160
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
161
+ */
162
+ export namespace CustomerStateTaxId$ {
163
+ /** @deprecated use `CustomerStateTaxId$inboundSchema` instead. */
164
+ export const inboundSchema = CustomerStateTaxId$inboundSchema;
165
+ /** @deprecated use `CustomerStateTaxId$outboundSchema` instead. */
166
+ export const outboundSchema = CustomerStateTaxId$outboundSchema;
167
+ /** @deprecated use `CustomerStateTaxId$Outbound` instead. */
168
+ export type Outbound = CustomerStateTaxId$Outbound;
169
+ }
170
+
171
+ export function customerStateTaxIdToJSON(
172
+ customerStateTaxId: CustomerStateTaxId,
173
+ ): string {
174
+ return JSON.stringify(
175
+ CustomerStateTaxId$outboundSchema.parse(customerStateTaxId),
176
+ );
177
+ }
178
+
179
+ export function customerStateTaxIdFromJSON(
180
+ jsonString: string,
181
+ ): SafeParseResult<CustomerStateTaxId, SDKValidationError> {
182
+ return safeParse(
183
+ jsonString,
184
+ (x) => CustomerStateTaxId$inboundSchema.parse(JSON.parse(x)),
185
+ `Failed to parse 'CustomerStateTaxId' from JSON`,
186
+ );
187
+ }
188
+
189
+ /** @internal */
190
+ export const CustomerState$inboundSchema: z.ZodType<
191
+ CustomerState,
192
+ z.ZodTypeDef,
193
+ unknown
194
+ > = z.object({
195
+ id: z.string(),
196
+ created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
197
+ modified_at: z.nullable(
198
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
199
+ ),
200
+ metadata: z.record(z.union([z.string(), z.number().int(), z.boolean()])),
201
+ external_id: z.nullable(z.string()),
202
+ email: z.string(),
203
+ email_verified: z.boolean(),
204
+ name: z.nullable(z.string()),
205
+ billing_address: z.nullable(Address$inboundSchema),
206
+ tax_id: z.nullable(
207
+ z.array(z.nullable(z.union([z.string(), TaxIDFormat$inboundSchema]))),
208
+ ),
209
+ organization_id: z.string(),
210
+ active_subscriptions: z.array(CustomerStateSubscription$inboundSchema),
211
+ granted_benefits: z.array(CustomerStateBenefitGrant$inboundSchema),
212
+ avatar_url: z.string(),
213
+ }).transform((v) => {
214
+ return remap$(v, {
215
+ "created_at": "createdAt",
216
+ "modified_at": "modifiedAt",
217
+ "external_id": "externalId",
218
+ "email_verified": "emailVerified",
219
+ "billing_address": "billingAddress",
220
+ "tax_id": "taxId",
221
+ "organization_id": "organizationId",
222
+ "active_subscriptions": "activeSubscriptions",
223
+ "granted_benefits": "grantedBenefits",
224
+ "avatar_url": "avatarUrl",
225
+ });
226
+ });
227
+
228
+ /** @internal */
229
+ export type CustomerState$Outbound = {
230
+ id: string;
231
+ created_at: string;
232
+ modified_at: string | null;
233
+ metadata: { [k: string]: string | number | boolean };
234
+ external_id: string | null;
235
+ email: string;
236
+ email_verified: boolean;
237
+ name: string | null;
238
+ billing_address: Address$Outbound | null;
239
+ tax_id: Array<string | string | null> | null;
240
+ organization_id: string;
241
+ active_subscriptions: Array<CustomerStateSubscription$Outbound>;
242
+ granted_benefits: Array<CustomerStateBenefitGrant$Outbound>;
243
+ avatar_url: string;
244
+ };
245
+
246
+ /** @internal */
247
+ export const CustomerState$outboundSchema: z.ZodType<
248
+ CustomerState$Outbound,
249
+ z.ZodTypeDef,
250
+ CustomerState
251
+ > = z.object({
252
+ id: z.string(),
253
+ createdAt: z.date().transform(v => v.toISOString()),
254
+ modifiedAt: z.nullable(z.date().transform(v => v.toISOString())),
255
+ metadata: z.record(z.union([z.string(), z.number().int(), z.boolean()])),
256
+ externalId: z.nullable(z.string()),
257
+ email: z.string(),
258
+ emailVerified: z.boolean(),
259
+ name: z.nullable(z.string()),
260
+ billingAddress: z.nullable(Address$outboundSchema),
261
+ taxId: z.nullable(
262
+ z.array(z.nullable(z.union([z.string(), TaxIDFormat$outboundSchema]))),
263
+ ),
264
+ organizationId: z.string(),
265
+ activeSubscriptions: z.array(CustomerStateSubscription$outboundSchema),
266
+ grantedBenefits: z.array(CustomerStateBenefitGrant$outboundSchema),
267
+ avatarUrl: z.string(),
268
+ }).transform((v) => {
269
+ return remap$(v, {
270
+ createdAt: "created_at",
271
+ modifiedAt: "modified_at",
272
+ externalId: "external_id",
273
+ emailVerified: "email_verified",
274
+ billingAddress: "billing_address",
275
+ taxId: "tax_id",
276
+ organizationId: "organization_id",
277
+ activeSubscriptions: "active_subscriptions",
278
+ grantedBenefits: "granted_benefits",
279
+ avatarUrl: "avatar_url",
280
+ });
281
+ });
282
+
283
+ /**
284
+ * @internal
285
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
286
+ */
287
+ export namespace CustomerState$ {
288
+ /** @deprecated use `CustomerState$inboundSchema` instead. */
289
+ export const inboundSchema = CustomerState$inboundSchema;
290
+ /** @deprecated use `CustomerState$outboundSchema` instead. */
291
+ export const outboundSchema = CustomerState$outboundSchema;
292
+ /** @deprecated use `CustomerState$Outbound` instead. */
293
+ export type Outbound = CustomerState$Outbound;
294
+ }
295
+
296
+ export function customerStateToJSON(customerState: CustomerState): string {
297
+ return JSON.stringify(CustomerState$outboundSchema.parse(customerState));
298
+ }
299
+
300
+ export function customerStateFromJSON(
301
+ jsonString: string,
302
+ ): SafeParseResult<CustomerState, SDKValidationError> {
303
+ return safeParse(
304
+ jsonString,
305
+ (x) => CustomerState$inboundSchema.parse(JSON.parse(x)),
306
+ `Failed to parse 'CustomerState' from JSON`,
307
+ );
308
+ }
@@ -0,0 +1,261 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+ import {
11
+ BenefitGrantCustomProperties,
12
+ BenefitGrantCustomProperties$inboundSchema,
13
+ BenefitGrantCustomProperties$Outbound,
14
+ BenefitGrantCustomProperties$outboundSchema,
15
+ } from "./benefitgrantcustomproperties.js";
16
+ import {
17
+ BenefitGrantDiscordProperties,
18
+ BenefitGrantDiscordProperties$inboundSchema,
19
+ BenefitGrantDiscordProperties$Outbound,
20
+ BenefitGrantDiscordProperties$outboundSchema,
21
+ } from "./benefitgrantdiscordproperties.js";
22
+ import {
23
+ BenefitGrantDownloadablesProperties,
24
+ BenefitGrantDownloadablesProperties$inboundSchema,
25
+ BenefitGrantDownloadablesProperties$Outbound,
26
+ BenefitGrantDownloadablesProperties$outboundSchema,
27
+ } from "./benefitgrantdownloadablesproperties.js";
28
+ import {
29
+ BenefitGrantGitHubRepositoryProperties,
30
+ BenefitGrantGitHubRepositoryProperties$inboundSchema,
31
+ BenefitGrantGitHubRepositoryProperties$Outbound,
32
+ BenefitGrantGitHubRepositoryProperties$outboundSchema,
33
+ } from "./benefitgrantgithubrepositoryproperties.js";
34
+ import {
35
+ BenefitGrantLicenseKeysProperties,
36
+ BenefitGrantLicenseKeysProperties$inboundSchema,
37
+ BenefitGrantLicenseKeysProperties$Outbound,
38
+ BenefitGrantLicenseKeysProperties$outboundSchema,
39
+ } from "./benefitgrantlicensekeysproperties.js";
40
+ import {
41
+ BenefitType,
42
+ BenefitType$inboundSchema,
43
+ BenefitType$outboundSchema,
44
+ } from "./benefittype.js";
45
+
46
+ export type CustomerStateBenefitGrantProperties =
47
+ | BenefitGrantCustomProperties
48
+ | BenefitGrantDownloadablesProperties
49
+ | BenefitGrantLicenseKeysProperties
50
+ | BenefitGrantDiscordProperties
51
+ | BenefitGrantGitHubRepositoryProperties;
52
+
53
+ /**
54
+ * An active benefit grant for a customer.
55
+ */
56
+ export type CustomerStateBenefitGrant = {
57
+ /**
58
+ * The ID of the grant.
59
+ */
60
+ id: string;
61
+ /**
62
+ * Creation timestamp of the object.
63
+ */
64
+ createdAt: Date;
65
+ /**
66
+ * Last modification timestamp of the object.
67
+ */
68
+ modifiedAt: Date | null;
69
+ /**
70
+ * The timestamp when the benefit was granted.
71
+ */
72
+ grantedAt: Date;
73
+ /**
74
+ * The ID of the benefit concerned by this grant.
75
+ */
76
+ benefitId: string;
77
+ benefitType: BenefitType;
78
+ properties:
79
+ | BenefitGrantCustomProperties
80
+ | BenefitGrantDownloadablesProperties
81
+ | BenefitGrantLicenseKeysProperties
82
+ | BenefitGrantDiscordProperties
83
+ | BenefitGrantGitHubRepositoryProperties;
84
+ };
85
+
86
+ /** @internal */
87
+ export const CustomerStateBenefitGrantProperties$inboundSchema: z.ZodType<
88
+ CustomerStateBenefitGrantProperties,
89
+ z.ZodTypeDef,
90
+ unknown
91
+ > = z.union([
92
+ BenefitGrantCustomProperties$inboundSchema,
93
+ BenefitGrantDownloadablesProperties$inboundSchema,
94
+ BenefitGrantLicenseKeysProperties$inboundSchema,
95
+ BenefitGrantDiscordProperties$inboundSchema,
96
+ BenefitGrantGitHubRepositoryProperties$inboundSchema,
97
+ ]);
98
+
99
+ /** @internal */
100
+ export type CustomerStateBenefitGrantProperties$Outbound =
101
+ | BenefitGrantCustomProperties$Outbound
102
+ | BenefitGrantDownloadablesProperties$Outbound
103
+ | BenefitGrantLicenseKeysProperties$Outbound
104
+ | BenefitGrantDiscordProperties$Outbound
105
+ | BenefitGrantGitHubRepositoryProperties$Outbound;
106
+
107
+ /** @internal */
108
+ export const CustomerStateBenefitGrantProperties$outboundSchema: z.ZodType<
109
+ CustomerStateBenefitGrantProperties$Outbound,
110
+ z.ZodTypeDef,
111
+ CustomerStateBenefitGrantProperties
112
+ > = z.union([
113
+ BenefitGrantCustomProperties$outboundSchema,
114
+ BenefitGrantDownloadablesProperties$outboundSchema,
115
+ BenefitGrantLicenseKeysProperties$outboundSchema,
116
+ BenefitGrantDiscordProperties$outboundSchema,
117
+ BenefitGrantGitHubRepositoryProperties$outboundSchema,
118
+ ]);
119
+
120
+ /**
121
+ * @internal
122
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
123
+ */
124
+ export namespace CustomerStateBenefitGrantProperties$ {
125
+ /** @deprecated use `CustomerStateBenefitGrantProperties$inboundSchema` instead. */
126
+ export const inboundSchema =
127
+ CustomerStateBenefitGrantProperties$inboundSchema;
128
+ /** @deprecated use `CustomerStateBenefitGrantProperties$outboundSchema` instead. */
129
+ export const outboundSchema =
130
+ CustomerStateBenefitGrantProperties$outboundSchema;
131
+ /** @deprecated use `CustomerStateBenefitGrantProperties$Outbound` instead. */
132
+ export type Outbound = CustomerStateBenefitGrantProperties$Outbound;
133
+ }
134
+
135
+ export function customerStateBenefitGrantPropertiesToJSON(
136
+ customerStateBenefitGrantProperties: CustomerStateBenefitGrantProperties,
137
+ ): string {
138
+ return JSON.stringify(
139
+ CustomerStateBenefitGrantProperties$outboundSchema.parse(
140
+ customerStateBenefitGrantProperties,
141
+ ),
142
+ );
143
+ }
144
+
145
+ export function customerStateBenefitGrantPropertiesFromJSON(
146
+ jsonString: string,
147
+ ): SafeParseResult<CustomerStateBenefitGrantProperties, SDKValidationError> {
148
+ return safeParse(
149
+ jsonString,
150
+ (x) =>
151
+ CustomerStateBenefitGrantProperties$inboundSchema.parse(JSON.parse(x)),
152
+ `Failed to parse 'CustomerStateBenefitGrantProperties' from JSON`,
153
+ );
154
+ }
155
+
156
+ /** @internal */
157
+ export const CustomerStateBenefitGrant$inboundSchema: z.ZodType<
158
+ CustomerStateBenefitGrant,
159
+ z.ZodTypeDef,
160
+ unknown
161
+ > = z.object({
162
+ id: z.string(),
163
+ created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
164
+ modified_at: z.nullable(
165
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
166
+ ),
167
+ granted_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
168
+ benefit_id: z.string(),
169
+ benefit_type: BenefitType$inboundSchema,
170
+ properties: z.union([
171
+ BenefitGrantCustomProperties$inboundSchema,
172
+ BenefitGrantDownloadablesProperties$inboundSchema,
173
+ BenefitGrantLicenseKeysProperties$inboundSchema,
174
+ BenefitGrantDiscordProperties$inboundSchema,
175
+ BenefitGrantGitHubRepositoryProperties$inboundSchema,
176
+ ]),
177
+ }).transform((v) => {
178
+ return remap$(v, {
179
+ "created_at": "createdAt",
180
+ "modified_at": "modifiedAt",
181
+ "granted_at": "grantedAt",
182
+ "benefit_id": "benefitId",
183
+ "benefit_type": "benefitType",
184
+ });
185
+ });
186
+
187
+ /** @internal */
188
+ export type CustomerStateBenefitGrant$Outbound = {
189
+ id: string;
190
+ created_at: string;
191
+ modified_at: string | null;
192
+ granted_at: string;
193
+ benefit_id: string;
194
+ benefit_type: string;
195
+ properties:
196
+ | BenefitGrantCustomProperties$Outbound
197
+ | BenefitGrantDownloadablesProperties$Outbound
198
+ | BenefitGrantLicenseKeysProperties$Outbound
199
+ | BenefitGrantDiscordProperties$Outbound
200
+ | BenefitGrantGitHubRepositoryProperties$Outbound;
201
+ };
202
+
203
+ /** @internal */
204
+ export const CustomerStateBenefitGrant$outboundSchema: z.ZodType<
205
+ CustomerStateBenefitGrant$Outbound,
206
+ z.ZodTypeDef,
207
+ CustomerStateBenefitGrant
208
+ > = z.object({
209
+ id: z.string(),
210
+ createdAt: z.date().transform(v => v.toISOString()),
211
+ modifiedAt: z.nullable(z.date().transform(v => v.toISOString())),
212
+ grantedAt: z.date().transform(v => v.toISOString()),
213
+ benefitId: z.string(),
214
+ benefitType: BenefitType$outboundSchema,
215
+ properties: z.union([
216
+ BenefitGrantCustomProperties$outboundSchema,
217
+ BenefitGrantDownloadablesProperties$outboundSchema,
218
+ BenefitGrantLicenseKeysProperties$outboundSchema,
219
+ BenefitGrantDiscordProperties$outboundSchema,
220
+ BenefitGrantGitHubRepositoryProperties$outboundSchema,
221
+ ]),
222
+ }).transform((v) => {
223
+ return remap$(v, {
224
+ createdAt: "created_at",
225
+ modifiedAt: "modified_at",
226
+ grantedAt: "granted_at",
227
+ benefitId: "benefit_id",
228
+ benefitType: "benefit_type",
229
+ });
230
+ });
231
+
232
+ /**
233
+ * @internal
234
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
235
+ */
236
+ export namespace CustomerStateBenefitGrant$ {
237
+ /** @deprecated use `CustomerStateBenefitGrant$inboundSchema` instead. */
238
+ export const inboundSchema = CustomerStateBenefitGrant$inboundSchema;
239
+ /** @deprecated use `CustomerStateBenefitGrant$outboundSchema` instead. */
240
+ export const outboundSchema = CustomerStateBenefitGrant$outboundSchema;
241
+ /** @deprecated use `CustomerStateBenefitGrant$Outbound` instead. */
242
+ export type Outbound = CustomerStateBenefitGrant$Outbound;
243
+ }
244
+
245
+ export function customerStateBenefitGrantToJSON(
246
+ customerStateBenefitGrant: CustomerStateBenefitGrant,
247
+ ): string {
248
+ return JSON.stringify(
249
+ CustomerStateBenefitGrant$outboundSchema.parse(customerStateBenefitGrant),
250
+ );
251
+ }
252
+
253
+ export function customerStateBenefitGrantFromJSON(
254
+ jsonString: string,
255
+ ): SafeParseResult<CustomerStateBenefitGrant, SDKValidationError> {
256
+ return safeParse(
257
+ jsonString,
258
+ (x) => CustomerStateBenefitGrant$inboundSchema.parse(JSON.parse(x)),
259
+ `Failed to parse 'CustomerStateBenefitGrant' from JSON`,
260
+ );
261
+ }