@polar-sh/sdk 0.34.13 → 0.34.15

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 (204) hide show
  1. package/README.md +3 -1
  2. package/bin/mcp-server.js +63 -14
  3. package/bin/mcp-server.js.map +14 -13
  4. package/dist/commonjs/funcs/customerPortalCustomersDeletePaymentMethod.d.ts +2 -1
  5. package/dist/commonjs/funcs/customerPortalCustomersDeletePaymentMethod.d.ts.map +1 -1
  6. package/dist/commonjs/funcs/customerPortalCustomersDeletePaymentMethod.js +3 -2
  7. package/dist/commonjs/funcs/customerPortalCustomersDeletePaymentMethod.js.map +1 -1
  8. package/dist/commonjs/funcs/metersList.js +1 -0
  9. package/dist/commonjs/funcs/metersList.js.map +1 -1
  10. package/dist/commonjs/funcs/subscriptionsRevoke.d.ts +2 -1
  11. package/dist/commonjs/funcs/subscriptionsRevoke.d.ts.map +1 -1
  12. package/dist/commonjs/funcs/subscriptionsRevoke.js +3 -2
  13. package/dist/commonjs/funcs/subscriptionsRevoke.js.map +1 -1
  14. package/dist/commonjs/funcs/subscriptionsUpdate.d.ts +2 -1
  15. package/dist/commonjs/funcs/subscriptionsUpdate.d.ts.map +1 -1
  16. package/dist/commonjs/funcs/subscriptionsUpdate.js +3 -2
  17. package/dist/commonjs/funcs/subscriptionsUpdate.js.map +1 -1
  18. package/dist/commonjs/lib/config.d.ts +3 -3
  19. package/dist/commonjs/lib/config.js +3 -3
  20. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  21. package/dist/commonjs/mcp-server/server.js +1 -1
  22. package/dist/commonjs/models/components/checkoutlinkproduct.d.ts +1 -1
  23. package/dist/commonjs/models/components/checkoutproduct.d.ts +1 -1
  24. package/dist/commonjs/models/components/customerorderproduct.d.ts +1 -1
  25. package/dist/commonjs/models/components/customerproduct.d.ts +1 -1
  26. package/dist/commonjs/models/components/customersubscriptionproduct.d.ts +1 -1
  27. package/dist/commonjs/models/components/discountproduct.d.ts +1 -1
  28. package/dist/commonjs/models/components/meter.d.ts +5 -0
  29. package/dist/commonjs/models/components/meter.d.ts.map +1 -1
  30. package/dist/commonjs/models/components/meter.js +4 -0
  31. package/dist/commonjs/models/components/meter.js.map +1 -1
  32. package/dist/commonjs/models/components/meterupdate.d.ts +5 -0
  33. package/dist/commonjs/models/components/meterupdate.d.ts.map +1 -1
  34. package/dist/commonjs/models/components/meterupdate.js +11 -0
  35. package/dist/commonjs/models/components/meterupdate.js.map +1 -1
  36. package/dist/commonjs/models/components/orderproduct.d.ts +1 -1
  37. package/dist/commonjs/models/components/product.d.ts +1 -1
  38. package/dist/commonjs/models/components/productcreate.d.ts +1 -1
  39. package/dist/commonjs/models/components/scope.d.ts +6 -3
  40. package/dist/commonjs/models/components/scope.d.ts.map +1 -1
  41. package/dist/commonjs/models/components/scope.js +2 -1
  42. package/dist/commonjs/models/components/scope.js.map +1 -1
  43. package/dist/commonjs/models/components/subscriptioncycledevent.d.ts +74 -0
  44. package/dist/commonjs/models/components/subscriptioncycledevent.d.ts.map +1 -0
  45. package/dist/commonjs/models/components/subscriptioncycledevent.js +100 -0
  46. package/dist/commonjs/models/components/subscriptioncycledevent.js.map +1 -0
  47. package/dist/commonjs/models/components/subscriptioncycledmetadata.d.ts +29 -0
  48. package/dist/commonjs/models/components/subscriptioncycledmetadata.d.ts.map +1 -0
  49. package/dist/commonjs/models/components/subscriptioncycledmetadata.js +78 -0
  50. package/dist/commonjs/models/components/subscriptioncycledmetadata.js.map +1 -0
  51. package/dist/commonjs/models/components/subscriptionproductupdatedevent.d.ts +74 -0
  52. package/dist/commonjs/models/components/subscriptionproductupdatedevent.d.ts.map +1 -0
  53. package/dist/commonjs/models/components/subscriptionproductupdatedevent.js +100 -0
  54. package/dist/commonjs/models/components/subscriptionproductupdatedevent.js.map +1 -0
  55. package/dist/commonjs/models/components/subscriptionproductupdatedmetadata.d.ts +33 -0
  56. package/dist/commonjs/models/components/subscriptionproductupdatedmetadata.d.ts.map +1 -0
  57. package/dist/commonjs/models/components/subscriptionproductupdatedmetadata.js +86 -0
  58. package/dist/commonjs/models/components/subscriptionproductupdatedmetadata.js.map +1 -0
  59. package/dist/commonjs/models/components/subscriptionrecurringinterval.d.ts +6 -0
  60. package/dist/commonjs/models/components/subscriptionrecurringinterval.d.ts.map +1 -1
  61. package/dist/commonjs/models/components/subscriptionrecurringinterval.js +2 -0
  62. package/dist/commonjs/models/components/subscriptionrecurringinterval.js.map +1 -1
  63. package/dist/commonjs/models/components/subscriptionrevokedevent.d.ts +74 -0
  64. package/dist/commonjs/models/components/subscriptionrevokedevent.d.ts.map +1 -0
  65. package/dist/commonjs/models/components/subscriptionrevokedevent.js +100 -0
  66. package/dist/commonjs/models/components/subscriptionrevokedevent.js.map +1 -0
  67. package/dist/commonjs/models/components/subscriptionrevokedmetadata.d.ts +29 -0
  68. package/dist/commonjs/models/components/subscriptionrevokedmetadata.d.ts.map +1 -0
  69. package/dist/commonjs/models/components/subscriptionrevokedmetadata.js +78 -0
  70. package/dist/commonjs/models/components/subscriptionrevokedmetadata.js.map +1 -0
  71. package/dist/commonjs/models/components/systemevent.d.ts +15 -0
  72. package/dist/commonjs/models/components/systemevent.d.ts.map +1 -1
  73. package/dist/commonjs/models/components/systemevent.js +17 -0
  74. package/dist/commonjs/models/components/systemevent.js.map +1 -1
  75. package/dist/commonjs/models/errors/paymentmethodinusebyactivesubscription.d.ts +39 -0
  76. package/dist/commonjs/models/errors/paymentmethodinusebyactivesubscription.d.ts.map +1 -0
  77. package/dist/commonjs/models/errors/paymentmethodinusebyactivesubscription.js +88 -0
  78. package/dist/commonjs/models/errors/paymentmethodinusebyactivesubscription.js.map +1 -0
  79. package/dist/commonjs/models/errors/subscriptionlocked.d.ts +39 -0
  80. package/dist/commonjs/models/errors/subscriptionlocked.d.ts.map +1 -0
  81. package/dist/commonjs/models/errors/subscriptionlocked.js +88 -0
  82. package/dist/commonjs/models/errors/subscriptionlocked.js.map +1 -0
  83. package/dist/commonjs/models/operations/meterslist.d.ts +5 -0
  84. package/dist/commonjs/models/operations/meterslist.d.ts.map +1 -1
  85. package/dist/commonjs/models/operations/meterslist.js +4 -0
  86. package/dist/commonjs/models/operations/meterslist.js.map +1 -1
  87. package/dist/esm/funcs/customerPortalCustomersDeletePaymentMethod.d.ts +2 -1
  88. package/dist/esm/funcs/customerPortalCustomersDeletePaymentMethod.d.ts.map +1 -1
  89. package/dist/esm/funcs/customerPortalCustomersDeletePaymentMethod.js +3 -2
  90. package/dist/esm/funcs/customerPortalCustomersDeletePaymentMethod.js.map +1 -1
  91. package/dist/esm/funcs/metersList.js +1 -0
  92. package/dist/esm/funcs/metersList.js.map +1 -1
  93. package/dist/esm/funcs/subscriptionsRevoke.d.ts +2 -1
  94. package/dist/esm/funcs/subscriptionsRevoke.d.ts.map +1 -1
  95. package/dist/esm/funcs/subscriptionsRevoke.js +3 -2
  96. package/dist/esm/funcs/subscriptionsRevoke.js.map +1 -1
  97. package/dist/esm/funcs/subscriptionsUpdate.d.ts +2 -1
  98. package/dist/esm/funcs/subscriptionsUpdate.d.ts.map +1 -1
  99. package/dist/esm/funcs/subscriptionsUpdate.js +3 -2
  100. package/dist/esm/funcs/subscriptionsUpdate.js.map +1 -1
  101. package/dist/esm/lib/config.d.ts +3 -3
  102. package/dist/esm/lib/config.js +3 -3
  103. package/dist/esm/mcp-server/mcp-server.js +1 -1
  104. package/dist/esm/mcp-server/server.js +1 -1
  105. package/dist/esm/models/components/checkoutlinkproduct.d.ts +1 -1
  106. package/dist/esm/models/components/checkoutproduct.d.ts +1 -1
  107. package/dist/esm/models/components/customerorderproduct.d.ts +1 -1
  108. package/dist/esm/models/components/customerproduct.d.ts +1 -1
  109. package/dist/esm/models/components/customersubscriptionproduct.d.ts +1 -1
  110. package/dist/esm/models/components/discountproduct.d.ts +1 -1
  111. package/dist/esm/models/components/meter.d.ts +5 -0
  112. package/dist/esm/models/components/meter.d.ts.map +1 -1
  113. package/dist/esm/models/components/meter.js +4 -0
  114. package/dist/esm/models/components/meter.js.map +1 -1
  115. package/dist/esm/models/components/meterupdate.d.ts +5 -0
  116. package/dist/esm/models/components/meterupdate.d.ts.map +1 -1
  117. package/dist/esm/models/components/meterupdate.js +11 -0
  118. package/dist/esm/models/components/meterupdate.js.map +1 -1
  119. package/dist/esm/models/components/orderproduct.d.ts +1 -1
  120. package/dist/esm/models/components/product.d.ts +1 -1
  121. package/dist/esm/models/components/productcreate.d.ts +1 -1
  122. package/dist/esm/models/components/scope.d.ts +6 -3
  123. package/dist/esm/models/components/scope.d.ts.map +1 -1
  124. package/dist/esm/models/components/scope.js +2 -1
  125. package/dist/esm/models/components/scope.js.map +1 -1
  126. package/dist/esm/models/components/subscriptioncycledevent.d.ts +74 -0
  127. package/dist/esm/models/components/subscriptioncycledevent.d.ts.map +1 -0
  128. package/dist/esm/models/components/subscriptioncycledevent.js +62 -0
  129. package/dist/esm/models/components/subscriptioncycledevent.js.map +1 -0
  130. package/dist/esm/models/components/subscriptioncycledmetadata.d.ts +29 -0
  131. package/dist/esm/models/components/subscriptioncycledmetadata.d.ts.map +1 -0
  132. package/dist/esm/models/components/subscriptioncycledmetadata.js +40 -0
  133. package/dist/esm/models/components/subscriptioncycledmetadata.js.map +1 -0
  134. package/dist/esm/models/components/subscriptionproductupdatedevent.d.ts +74 -0
  135. package/dist/esm/models/components/subscriptionproductupdatedevent.d.ts.map +1 -0
  136. package/dist/esm/models/components/subscriptionproductupdatedevent.js +62 -0
  137. package/dist/esm/models/components/subscriptionproductupdatedevent.js.map +1 -0
  138. package/dist/esm/models/components/subscriptionproductupdatedmetadata.d.ts +33 -0
  139. package/dist/esm/models/components/subscriptionproductupdatedmetadata.d.ts.map +1 -0
  140. package/dist/esm/models/components/subscriptionproductupdatedmetadata.js +48 -0
  141. package/dist/esm/models/components/subscriptionproductupdatedmetadata.js.map +1 -0
  142. package/dist/esm/models/components/subscriptionrecurringinterval.d.ts +6 -0
  143. package/dist/esm/models/components/subscriptionrecurringinterval.d.ts.map +1 -1
  144. package/dist/esm/models/components/subscriptionrecurringinterval.js +2 -0
  145. package/dist/esm/models/components/subscriptionrecurringinterval.js.map +1 -1
  146. package/dist/esm/models/components/subscriptionrevokedevent.d.ts +74 -0
  147. package/dist/esm/models/components/subscriptionrevokedevent.d.ts.map +1 -0
  148. package/dist/esm/models/components/subscriptionrevokedevent.js +62 -0
  149. package/dist/esm/models/components/subscriptionrevokedevent.js.map +1 -0
  150. package/dist/esm/models/components/subscriptionrevokedmetadata.d.ts +29 -0
  151. package/dist/esm/models/components/subscriptionrevokedmetadata.d.ts.map +1 -0
  152. package/dist/esm/models/components/subscriptionrevokedmetadata.js +40 -0
  153. package/dist/esm/models/components/subscriptionrevokedmetadata.js.map +1 -0
  154. package/dist/esm/models/components/systemevent.d.ts +15 -0
  155. package/dist/esm/models/components/systemevent.d.ts.map +1 -1
  156. package/dist/esm/models/components/systemevent.js +17 -0
  157. package/dist/esm/models/components/systemevent.js.map +1 -1
  158. package/dist/esm/models/errors/paymentmethodinusebyactivesubscription.d.ts +39 -0
  159. package/dist/esm/models/errors/paymentmethodinusebyactivesubscription.d.ts.map +1 -0
  160. package/dist/esm/models/errors/paymentmethodinusebyactivesubscription.js +51 -0
  161. package/dist/esm/models/errors/paymentmethodinusebyactivesubscription.js.map +1 -0
  162. package/dist/esm/models/errors/subscriptionlocked.d.ts +39 -0
  163. package/dist/esm/models/errors/subscriptionlocked.d.ts.map +1 -0
  164. package/dist/esm/models/errors/subscriptionlocked.js +51 -0
  165. package/dist/esm/models/errors/subscriptionlocked.js.map +1 -0
  166. package/dist/esm/models/operations/meterslist.d.ts +5 -0
  167. package/dist/esm/models/operations/meterslist.d.ts.map +1 -1
  168. package/dist/esm/models/operations/meterslist.js +4 -0
  169. package/dist/esm/models/operations/meterslist.js.map +1 -1
  170. package/docs/sdks/polarcustomers/README.md +6 -5
  171. package/docs/sdks/subscriptions/README.md +2 -0
  172. package/examples/package-lock.json +1 -1
  173. package/jsr.json +1 -1
  174. package/package.json +1 -1
  175. package/src/funcs/customerPortalCustomersDeletePaymentMethod.ts +9 -1
  176. package/src/funcs/metersList.ts +1 -0
  177. package/src/funcs/subscriptionsRevoke.ts +9 -1
  178. package/src/funcs/subscriptionsUpdate.ts +9 -1
  179. package/src/lib/config.ts +3 -3
  180. package/src/mcp-server/mcp-server.ts +1 -1
  181. package/src/mcp-server/server.ts +1 -1
  182. package/src/models/components/checkoutlinkproduct.ts +1 -1
  183. package/src/models/components/checkoutproduct.ts +1 -1
  184. package/src/models/components/customerorderproduct.ts +1 -1
  185. package/src/models/components/customerproduct.ts +1 -1
  186. package/src/models/components/customersubscriptionproduct.ts +1 -1
  187. package/src/models/components/discountproduct.ts +1 -1
  188. package/src/models/components/meter.ts +11 -0
  189. package/src/models/components/meterupdate.ts +16 -0
  190. package/src/models/components/orderproduct.ts +1 -1
  191. package/src/models/components/product.ts +1 -1
  192. package/src/models/components/productcreate.ts +1 -1
  193. package/src/models/components/scope.ts +2 -1
  194. package/src/models/components/subscriptioncycledevent.ts +150 -0
  195. package/src/models/components/subscriptioncycledmetadata.ts +75 -0
  196. package/src/models/components/subscriptionproductupdatedevent.ts +152 -0
  197. package/src/models/components/subscriptionproductupdatedmetadata.ts +91 -0
  198. package/src/models/components/subscriptionrecurringinterval.ts +2 -0
  199. package/src/models/components/subscriptionrevokedevent.ts +150 -0
  200. package/src/models/components/subscriptionrevokedmetadata.ts +77 -0
  201. package/src/models/components/systemevent.ts +58 -2
  202. package/src/models/errors/paymentmethodinusebyactivesubscription.ts +87 -0
  203. package/src/models/errors/subscriptionlocked.ts +85 -0
  204. package/src/models/operations/meterslist.ts +9 -0
@@ -69,7 +69,7 @@ export type CustomerOrderProduct = {
69
69
  */
70
70
  description: string | null;
71
71
  /**
72
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
72
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
73
73
  */
74
74
  recurringInterval: SubscriptionRecurringInterval | null;
75
75
  /**
@@ -64,7 +64,7 @@ export type CustomerProduct = {
64
64
  */
65
65
  description: string | null;
66
66
  /**
67
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
67
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
68
68
  */
69
69
  recurringInterval: SubscriptionRecurringInterval | null;
70
70
  /**
@@ -69,7 +69,7 @@ export type CustomerSubscriptionProduct = {
69
69
  */
70
70
  description: string | null;
71
71
  /**
72
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
72
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
73
73
  */
74
74
  recurringInterval: SubscriptionRecurringInterval | null;
75
75
  /**
@@ -41,7 +41,7 @@ export type DiscountProduct = {
41
41
  */
42
42
  description: string | null;
43
43
  /**
44
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
44
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
45
45
  */
46
46
  recurringInterval: SubscriptionRecurringInterval | null;
47
47
  /**
@@ -78,6 +78,10 @@ export type Meter = {
78
78
  * The ID of the organization owning the meter.
79
79
  */
80
80
  organizationId: string;
81
+ /**
82
+ * Whether the meter is archived and the time it was archived.
83
+ */
84
+ archivedAt?: Date | null | undefined;
81
85
  };
82
86
 
83
87
  /** @internal */
@@ -268,11 +272,15 @@ export const Meter$inboundSchema: z.ZodType<Meter, z.ZodTypeDef, unknown> = z
268
272
  ),
269
273
  ]),
270
274
  organization_id: z.string(),
275
+ archived_at: z.nullable(
276
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
277
+ ).optional(),
271
278
  }).transform((v) => {
272
279
  return remap$(v, {
273
280
  "created_at": "createdAt",
274
281
  "modified_at": "modifiedAt",
275
282
  "organization_id": "organizationId",
283
+ "archived_at": "archivedAt",
276
284
  });
277
285
  });
278
286
 
@@ -292,6 +300,7 @@ export type Meter$Outbound = {
292
300
  | (UniqueAggregation$Outbound & { func: "unique" })
293
301
  | (CountAggregation$Outbound & { func: "count" });
294
302
  organization_id: string;
303
+ archived_at?: string | null | undefined;
295
304
  };
296
305
 
297
306
  /** @internal */
@@ -333,11 +342,13 @@ export const Meter$outboundSchema: z.ZodType<
333
342
  ),
334
343
  ]),
335
344
  organizationId: z.string(),
345
+ archivedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
336
346
  }).transform((v) => {
337
347
  return remap$(v, {
338
348
  createdAt: "created_at",
339
349
  modifiedAt: "modified_at",
340
350
  organizationId: "organization_id",
351
+ archivedAt: "archived_at",
341
352
  });
342
353
  });
343
354
 
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
6
7
  import { safeParse } from "../../lib/schemas.js";
7
8
  import { Result as SafeParseResult } from "../../types/fp.js";
8
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
@@ -78,6 +79,10 @@ export type MeterUpdate = {
78
79
  | (CountAggregation & { func: "count" })
79
80
  | null
80
81
  | undefined;
82
+ /**
83
+ * Whether the meter is archived. Archived meters are no longer used for billing.
84
+ */
85
+ isArchived?: boolean | null | undefined;
81
86
  };
82
87
 
83
88
  /** @internal */
@@ -265,6 +270,11 @@ export const MeterUpdate$inboundSchema: z.ZodType<
265
270
  ),
266
271
  ]),
267
272
  ).optional(),
273
+ is_archived: z.nullable(z.boolean()).optional(),
274
+ }).transform((v) => {
275
+ return remap$(v, {
276
+ "is_archived": "isArchived",
277
+ });
268
278
  });
269
279
 
270
280
  /** @internal */
@@ -281,6 +291,7 @@ export type MeterUpdate$Outbound = {
281
291
  | (CountAggregation$Outbound & { func: "count" })
282
292
  | null
283
293
  | undefined;
294
+ is_archived?: boolean | null | undefined;
284
295
  };
285
296
 
286
297
  /** @internal */
@@ -328,6 +339,11 @@ export const MeterUpdate$outboundSchema: z.ZodType<
328
339
  ),
329
340
  ]),
330
341
  ).optional(),
342
+ isArchived: z.nullable(z.boolean()).optional(),
343
+ }).transform((v) => {
344
+ return remap$(v, {
345
+ isArchived: "is_archived",
346
+ });
331
347
  });
332
348
 
333
349
  /**
@@ -38,7 +38,7 @@ export type OrderProduct = {
38
38
  */
39
39
  description: string | null;
40
40
  /**
41
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
41
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
42
42
  */
43
43
  recurringInterval: SubscriptionRecurringInterval | null;
44
44
  /**
@@ -72,7 +72,7 @@ export type Product = {
72
72
  */
73
73
  description: string | null;
74
74
  /**
75
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
75
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
76
76
  */
77
77
  recurringInterval: SubscriptionRecurringInterval | null;
78
78
  /**
@@ -80,7 +80,7 @@ export type ProductCreate = {
80
80
  */
81
81
  description?: string | null | undefined;
82
82
  /**
83
- * The recurring interval of the product. If `None`, the product is a one-time purchase.
83
+ * The recurring interval of the product. If `None`, the product is a one-time purchase.Note that the `day` and `week` values are for internal Polar staff use only.
84
84
  */
85
85
  recurringInterval: SubscriptionRecurringInterval | null;
86
86
  /**
@@ -10,7 +10,8 @@ export const Scope = {
10
10
  Profile: "profile",
11
11
  Email: "email",
12
12
  UserRead: "user:read",
13
- WebDefault: "web_default",
13
+ WebRead: "web:read",
14
+ WebWrite: "web:write",
14
15
  OrganizationsRead: "organizations:read",
15
16
  OrganizationsWrite: "organizations:write",
16
17
  CustomFieldsRead: "custom_fields:read",
@@ -0,0 +1,150 @@
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
+ Customer,
12
+ Customer$inboundSchema,
13
+ Customer$Outbound,
14
+ Customer$outboundSchema,
15
+ } from "./customer.js";
16
+ import {
17
+ SubscriptionCycledMetadata,
18
+ SubscriptionCycledMetadata$inboundSchema,
19
+ SubscriptionCycledMetadata$Outbound,
20
+ SubscriptionCycledMetadata$outboundSchema,
21
+ } from "./subscriptioncycledmetadata.js";
22
+
23
+ /**
24
+ * An event created by Polar when a subscription is cycled.
25
+ */
26
+ export type SubscriptionCycledEvent = {
27
+ /**
28
+ * The ID of the object.
29
+ */
30
+ id: string;
31
+ /**
32
+ * The timestamp of the event.
33
+ */
34
+ timestamp: Date;
35
+ /**
36
+ * The ID of the organization owning the event.
37
+ */
38
+ organizationId: string;
39
+ /**
40
+ * ID of the customer in your Polar organization associated with the event.
41
+ */
42
+ customerId: string | null;
43
+ /**
44
+ * The customer associated with the event.
45
+ */
46
+ customer: Customer | null;
47
+ /**
48
+ * ID of the customer in your system associated with the event.
49
+ */
50
+ externalCustomerId: string | null;
51
+ /**
52
+ * The source of the event. `system` events are created by Polar. `user` events are the one you create through our ingestion API.
53
+ */
54
+ source: "system";
55
+ /**
56
+ * The name of the event.
57
+ */
58
+ name: "subscription.cycled";
59
+ metadata: SubscriptionCycledMetadata;
60
+ };
61
+
62
+ /** @internal */
63
+ export const SubscriptionCycledEvent$inboundSchema: z.ZodType<
64
+ SubscriptionCycledEvent,
65
+ z.ZodTypeDef,
66
+ unknown
67
+ > = z.object({
68
+ id: z.string(),
69
+ timestamp: z.string().datetime({ offset: true }).transform(v => new Date(v)),
70
+ organization_id: z.string(),
71
+ customer_id: z.nullable(z.string()),
72
+ customer: z.nullable(Customer$inboundSchema),
73
+ external_customer_id: z.nullable(z.string()),
74
+ source: z.literal("system"),
75
+ name: z.literal("subscription.cycled"),
76
+ metadata: SubscriptionCycledMetadata$inboundSchema,
77
+ }).transform((v) => {
78
+ return remap$(v, {
79
+ "organization_id": "organizationId",
80
+ "customer_id": "customerId",
81
+ "external_customer_id": "externalCustomerId",
82
+ });
83
+ });
84
+
85
+ /** @internal */
86
+ export type SubscriptionCycledEvent$Outbound = {
87
+ id: string;
88
+ timestamp: string;
89
+ organization_id: string;
90
+ customer_id: string | null;
91
+ customer: Customer$Outbound | null;
92
+ external_customer_id: string | null;
93
+ source: "system";
94
+ name: "subscription.cycled";
95
+ metadata: SubscriptionCycledMetadata$Outbound;
96
+ };
97
+
98
+ /** @internal */
99
+ export const SubscriptionCycledEvent$outboundSchema: z.ZodType<
100
+ SubscriptionCycledEvent$Outbound,
101
+ z.ZodTypeDef,
102
+ SubscriptionCycledEvent
103
+ > = z.object({
104
+ id: z.string(),
105
+ timestamp: z.date().transform(v => v.toISOString()),
106
+ organizationId: z.string(),
107
+ customerId: z.nullable(z.string()),
108
+ customer: z.nullable(Customer$outboundSchema),
109
+ externalCustomerId: z.nullable(z.string()),
110
+ source: z.literal("system"),
111
+ name: z.literal("subscription.cycled"),
112
+ metadata: SubscriptionCycledMetadata$outboundSchema,
113
+ }).transform((v) => {
114
+ return remap$(v, {
115
+ organizationId: "organization_id",
116
+ customerId: "customer_id",
117
+ externalCustomerId: "external_customer_id",
118
+ });
119
+ });
120
+
121
+ /**
122
+ * @internal
123
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
124
+ */
125
+ export namespace SubscriptionCycledEvent$ {
126
+ /** @deprecated use `SubscriptionCycledEvent$inboundSchema` instead. */
127
+ export const inboundSchema = SubscriptionCycledEvent$inboundSchema;
128
+ /** @deprecated use `SubscriptionCycledEvent$outboundSchema` instead. */
129
+ export const outboundSchema = SubscriptionCycledEvent$outboundSchema;
130
+ /** @deprecated use `SubscriptionCycledEvent$Outbound` instead. */
131
+ export type Outbound = SubscriptionCycledEvent$Outbound;
132
+ }
133
+
134
+ export function subscriptionCycledEventToJSON(
135
+ subscriptionCycledEvent: SubscriptionCycledEvent,
136
+ ): string {
137
+ return JSON.stringify(
138
+ SubscriptionCycledEvent$outboundSchema.parse(subscriptionCycledEvent),
139
+ );
140
+ }
141
+
142
+ export function subscriptionCycledEventFromJSON(
143
+ jsonString: string,
144
+ ): SafeParseResult<SubscriptionCycledEvent, SDKValidationError> {
145
+ return safeParse(
146
+ jsonString,
147
+ (x) => SubscriptionCycledEvent$inboundSchema.parse(JSON.parse(x)),
148
+ `Failed to parse 'SubscriptionCycledEvent' from JSON`,
149
+ );
150
+ }
@@ -0,0 +1,75 @@
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
+
11
+ export type SubscriptionCycledMetadata = {
12
+ subscriptionId: string;
13
+ };
14
+
15
+ /** @internal */
16
+ export const SubscriptionCycledMetadata$inboundSchema: z.ZodType<
17
+ SubscriptionCycledMetadata,
18
+ z.ZodTypeDef,
19
+ unknown
20
+ > = z.object({
21
+ subscription_id: z.string(),
22
+ }).transform((v) => {
23
+ return remap$(v, {
24
+ "subscription_id": "subscriptionId",
25
+ });
26
+ });
27
+
28
+ /** @internal */
29
+ export type SubscriptionCycledMetadata$Outbound = {
30
+ subscription_id: string;
31
+ };
32
+
33
+ /** @internal */
34
+ export const SubscriptionCycledMetadata$outboundSchema: z.ZodType<
35
+ SubscriptionCycledMetadata$Outbound,
36
+ z.ZodTypeDef,
37
+ SubscriptionCycledMetadata
38
+ > = z.object({
39
+ subscriptionId: z.string(),
40
+ }).transform((v) => {
41
+ return remap$(v, {
42
+ subscriptionId: "subscription_id",
43
+ });
44
+ });
45
+
46
+ /**
47
+ * @internal
48
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
49
+ */
50
+ export namespace SubscriptionCycledMetadata$ {
51
+ /** @deprecated use `SubscriptionCycledMetadata$inboundSchema` instead. */
52
+ export const inboundSchema = SubscriptionCycledMetadata$inboundSchema;
53
+ /** @deprecated use `SubscriptionCycledMetadata$outboundSchema` instead. */
54
+ export const outboundSchema = SubscriptionCycledMetadata$outboundSchema;
55
+ /** @deprecated use `SubscriptionCycledMetadata$Outbound` instead. */
56
+ export type Outbound = SubscriptionCycledMetadata$Outbound;
57
+ }
58
+
59
+ export function subscriptionCycledMetadataToJSON(
60
+ subscriptionCycledMetadata: SubscriptionCycledMetadata,
61
+ ): string {
62
+ return JSON.stringify(
63
+ SubscriptionCycledMetadata$outboundSchema.parse(subscriptionCycledMetadata),
64
+ );
65
+ }
66
+
67
+ export function subscriptionCycledMetadataFromJSON(
68
+ jsonString: string,
69
+ ): SafeParseResult<SubscriptionCycledMetadata, SDKValidationError> {
70
+ return safeParse(
71
+ jsonString,
72
+ (x) => SubscriptionCycledMetadata$inboundSchema.parse(JSON.parse(x)),
73
+ `Failed to parse 'SubscriptionCycledMetadata' from JSON`,
74
+ );
75
+ }
@@ -0,0 +1,152 @@
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
+ Customer,
12
+ Customer$inboundSchema,
13
+ Customer$Outbound,
14
+ Customer$outboundSchema,
15
+ } from "./customer.js";
16
+ import {
17
+ SubscriptionProductUpdatedMetadata,
18
+ SubscriptionProductUpdatedMetadata$inboundSchema,
19
+ SubscriptionProductUpdatedMetadata$Outbound,
20
+ SubscriptionProductUpdatedMetadata$outboundSchema,
21
+ } from "./subscriptionproductupdatedmetadata.js";
22
+
23
+ /**
24
+ * An event created by Polar when a subscription changes the product.
25
+ */
26
+ export type SubscriptionProductUpdatedEvent = {
27
+ /**
28
+ * The ID of the object.
29
+ */
30
+ id: string;
31
+ /**
32
+ * The timestamp of the event.
33
+ */
34
+ timestamp: Date;
35
+ /**
36
+ * The ID of the organization owning the event.
37
+ */
38
+ organizationId: string;
39
+ /**
40
+ * ID of the customer in your Polar organization associated with the event.
41
+ */
42
+ customerId: string | null;
43
+ /**
44
+ * The customer associated with the event.
45
+ */
46
+ customer: Customer | null;
47
+ /**
48
+ * ID of the customer in your system associated with the event.
49
+ */
50
+ externalCustomerId: string | null;
51
+ /**
52
+ * The source of the event. `system` events are created by Polar. `user` events are the one you create through our ingestion API.
53
+ */
54
+ source: "system";
55
+ /**
56
+ * The name of the event.
57
+ */
58
+ name: "subscription.product_updated";
59
+ metadata: SubscriptionProductUpdatedMetadata;
60
+ };
61
+
62
+ /** @internal */
63
+ export const SubscriptionProductUpdatedEvent$inboundSchema: z.ZodType<
64
+ SubscriptionProductUpdatedEvent,
65
+ z.ZodTypeDef,
66
+ unknown
67
+ > = z.object({
68
+ id: z.string(),
69
+ timestamp: z.string().datetime({ offset: true }).transform(v => new Date(v)),
70
+ organization_id: z.string(),
71
+ customer_id: z.nullable(z.string()),
72
+ customer: z.nullable(Customer$inboundSchema),
73
+ external_customer_id: z.nullable(z.string()),
74
+ source: z.literal("system"),
75
+ name: z.literal("subscription.product_updated"),
76
+ metadata: SubscriptionProductUpdatedMetadata$inboundSchema,
77
+ }).transform((v) => {
78
+ return remap$(v, {
79
+ "organization_id": "organizationId",
80
+ "customer_id": "customerId",
81
+ "external_customer_id": "externalCustomerId",
82
+ });
83
+ });
84
+
85
+ /** @internal */
86
+ export type SubscriptionProductUpdatedEvent$Outbound = {
87
+ id: string;
88
+ timestamp: string;
89
+ organization_id: string;
90
+ customer_id: string | null;
91
+ customer: Customer$Outbound | null;
92
+ external_customer_id: string | null;
93
+ source: "system";
94
+ name: "subscription.product_updated";
95
+ metadata: SubscriptionProductUpdatedMetadata$Outbound;
96
+ };
97
+
98
+ /** @internal */
99
+ export const SubscriptionProductUpdatedEvent$outboundSchema: z.ZodType<
100
+ SubscriptionProductUpdatedEvent$Outbound,
101
+ z.ZodTypeDef,
102
+ SubscriptionProductUpdatedEvent
103
+ > = z.object({
104
+ id: z.string(),
105
+ timestamp: z.date().transform(v => v.toISOString()),
106
+ organizationId: z.string(),
107
+ customerId: z.nullable(z.string()),
108
+ customer: z.nullable(Customer$outboundSchema),
109
+ externalCustomerId: z.nullable(z.string()),
110
+ source: z.literal("system"),
111
+ name: z.literal("subscription.product_updated"),
112
+ metadata: SubscriptionProductUpdatedMetadata$outboundSchema,
113
+ }).transform((v) => {
114
+ return remap$(v, {
115
+ organizationId: "organization_id",
116
+ customerId: "customer_id",
117
+ externalCustomerId: "external_customer_id",
118
+ });
119
+ });
120
+
121
+ /**
122
+ * @internal
123
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
124
+ */
125
+ export namespace SubscriptionProductUpdatedEvent$ {
126
+ /** @deprecated use `SubscriptionProductUpdatedEvent$inboundSchema` instead. */
127
+ export const inboundSchema = SubscriptionProductUpdatedEvent$inboundSchema;
128
+ /** @deprecated use `SubscriptionProductUpdatedEvent$outboundSchema` instead. */
129
+ export const outboundSchema = SubscriptionProductUpdatedEvent$outboundSchema;
130
+ /** @deprecated use `SubscriptionProductUpdatedEvent$Outbound` instead. */
131
+ export type Outbound = SubscriptionProductUpdatedEvent$Outbound;
132
+ }
133
+
134
+ export function subscriptionProductUpdatedEventToJSON(
135
+ subscriptionProductUpdatedEvent: SubscriptionProductUpdatedEvent,
136
+ ): string {
137
+ return JSON.stringify(
138
+ SubscriptionProductUpdatedEvent$outboundSchema.parse(
139
+ subscriptionProductUpdatedEvent,
140
+ ),
141
+ );
142
+ }
143
+
144
+ export function subscriptionProductUpdatedEventFromJSON(
145
+ jsonString: string,
146
+ ): SafeParseResult<SubscriptionProductUpdatedEvent, SDKValidationError> {
147
+ return safeParse(
148
+ jsonString,
149
+ (x) => SubscriptionProductUpdatedEvent$inboundSchema.parse(JSON.parse(x)),
150
+ `Failed to parse 'SubscriptionProductUpdatedEvent' from JSON`,
151
+ );
152
+ }
@@ -0,0 +1,91 @@
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
+
11
+ export type SubscriptionProductUpdatedMetadata = {
12
+ subscriptionId: string;
13
+ oldProductId: string;
14
+ newProductId: string;
15
+ };
16
+
17
+ /** @internal */
18
+ export const SubscriptionProductUpdatedMetadata$inboundSchema: z.ZodType<
19
+ SubscriptionProductUpdatedMetadata,
20
+ z.ZodTypeDef,
21
+ unknown
22
+ > = z.object({
23
+ subscription_id: z.string(),
24
+ old_product_id: z.string(),
25
+ new_product_id: z.string(),
26
+ }).transform((v) => {
27
+ return remap$(v, {
28
+ "subscription_id": "subscriptionId",
29
+ "old_product_id": "oldProductId",
30
+ "new_product_id": "newProductId",
31
+ });
32
+ });
33
+
34
+ /** @internal */
35
+ export type SubscriptionProductUpdatedMetadata$Outbound = {
36
+ subscription_id: string;
37
+ old_product_id: string;
38
+ new_product_id: string;
39
+ };
40
+
41
+ /** @internal */
42
+ export const SubscriptionProductUpdatedMetadata$outboundSchema: z.ZodType<
43
+ SubscriptionProductUpdatedMetadata$Outbound,
44
+ z.ZodTypeDef,
45
+ SubscriptionProductUpdatedMetadata
46
+ > = z.object({
47
+ subscriptionId: z.string(),
48
+ oldProductId: z.string(),
49
+ newProductId: z.string(),
50
+ }).transform((v) => {
51
+ return remap$(v, {
52
+ subscriptionId: "subscription_id",
53
+ oldProductId: "old_product_id",
54
+ newProductId: "new_product_id",
55
+ });
56
+ });
57
+
58
+ /**
59
+ * @internal
60
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
61
+ */
62
+ export namespace SubscriptionProductUpdatedMetadata$ {
63
+ /** @deprecated use `SubscriptionProductUpdatedMetadata$inboundSchema` instead. */
64
+ export const inboundSchema = SubscriptionProductUpdatedMetadata$inboundSchema;
65
+ /** @deprecated use `SubscriptionProductUpdatedMetadata$outboundSchema` instead. */
66
+ export const outboundSchema =
67
+ SubscriptionProductUpdatedMetadata$outboundSchema;
68
+ /** @deprecated use `SubscriptionProductUpdatedMetadata$Outbound` instead. */
69
+ export type Outbound = SubscriptionProductUpdatedMetadata$Outbound;
70
+ }
71
+
72
+ export function subscriptionProductUpdatedMetadataToJSON(
73
+ subscriptionProductUpdatedMetadata: SubscriptionProductUpdatedMetadata,
74
+ ): string {
75
+ return JSON.stringify(
76
+ SubscriptionProductUpdatedMetadata$outboundSchema.parse(
77
+ subscriptionProductUpdatedMetadata,
78
+ ),
79
+ );
80
+ }
81
+
82
+ export function subscriptionProductUpdatedMetadataFromJSON(
83
+ jsonString: string,
84
+ ): SafeParseResult<SubscriptionProductUpdatedMetadata, SDKValidationError> {
85
+ return safeParse(
86
+ jsonString,
87
+ (x) =>
88
+ SubscriptionProductUpdatedMetadata$inboundSchema.parse(JSON.parse(x)),
89
+ `Failed to parse 'SubscriptionProductUpdatedMetadata' from JSON`,
90
+ );
91
+ }
@@ -6,6 +6,8 @@ import * as z from "zod";
6
6
  import { ClosedEnum } from "../../types/enums.js";
7
7
 
8
8
  export const SubscriptionRecurringInterval = {
9
+ Day: "day",
10
+ Week: "week",
9
11
  Month: "month",
10
12
  Year: "year",
11
13
  } as const;