@polar-sh/sdk 0.17.3 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/FUNCTIONS.md +106 -0
  2. package/README.md +181 -30
  3. package/RUNTIMES.md +22 -0
  4. package/docs/sdks/checkouts/README.md +1 -1
  5. package/docs/sdks/files/README.md +5 -1
  6. package/funcs/filesCreate.js +1 -1
  7. package/funcs/filesDelete.d.ts +1 -1
  8. package/funcs/filesDelete.d.ts.map +1 -1
  9. package/funcs/filesDelete.js +1 -1
  10. package/funcs/filesDelete.js.map +1 -1
  11. package/funcs/filesUpdate.d.ts +1 -1
  12. package/funcs/filesUpdate.d.ts.map +1 -1
  13. package/funcs/filesUpdate.js +2 -2
  14. package/funcs/filesUpdate.js.map +1 -1
  15. package/funcs/filesUploaded.d.ts +1 -1
  16. package/funcs/filesUploaded.d.ts.map +1 -1
  17. package/funcs/filesUploaded.js +2 -2
  18. package/funcs/filesUploaded.js.map +1 -1
  19. package/hooks/hooks.d.ts.map +1 -1
  20. package/hooks/hooks.js +18 -0
  21. package/hooks/hooks.js.map +1 -1
  22. package/hooks/types.d.ts +3 -0
  23. package/hooks/types.d.ts.map +1 -1
  24. package/lib/config.d.ts +3 -3
  25. package/lib/config.js +3 -3
  26. package/lib/config.js.map +1 -1
  27. package/models/components/benefit.d.ts +2 -3
  28. package/models/components/benefit.d.ts.map +1 -1
  29. package/models/components/benefit.js +0 -3
  30. package/models/components/benefit.js.map +1 -1
  31. package/models/components/benefitadssubscriber.d.ts +7 -7
  32. package/models/components/benefitadssubscriber.d.ts.map +1 -1
  33. package/models/components/benefitadssubscriber.js +11 -11
  34. package/models/components/benefitadssubscriber.js.map +1 -1
  35. package/models/components/benefitgrant.d.ts +4 -5
  36. package/models/components/benefitgrant.d.ts.map +1 -1
  37. package/models/components/benefitgrant.js +0 -5
  38. package/models/components/benefitgrant.js.map +1 -1
  39. package/models/components/benefitgrantwebhook.d.ts +8 -9
  40. package/models/components/benefitgrantwebhook.d.ts.map +1 -1
  41. package/models/components/benefitgrantwebhook.js +0 -9
  42. package/models/components/benefitgrantwebhook.js.map +1 -1
  43. package/models/components/benefittype.d.ts +0 -3
  44. package/models/components/benefittype.d.ts.map +1 -1
  45. package/models/components/benefittype.js +0 -1
  46. package/models/components/benefittype.js.map +1 -1
  47. package/models/components/checkoutlinkproduct.d.ts +2 -24
  48. package/models/components/checkoutlinkproduct.d.ts.map +1 -1
  49. package/models/components/checkoutlinkproduct.js +3 -27
  50. package/models/components/checkoutlinkproduct.js.map +1 -1
  51. package/models/components/checkoutproduct.d.ts +2 -24
  52. package/models/components/checkoutproduct.d.ts.map +1 -1
  53. package/models/components/checkoutproduct.js +3 -27
  54. package/models/components/checkoutproduct.js.map +1 -1
  55. package/models/components/index.d.ts +0 -15
  56. package/models/components/index.d.ts.map +1 -1
  57. package/models/components/index.js +0 -15
  58. package/models/components/index.js.map +1 -1
  59. package/models/components/listresourceuserbenefit.d.ts +0 -9
  60. package/models/components/listresourceuserbenefit.d.ts.map +1 -1
  61. package/models/components/listresourceuserbenefit.js +0 -13
  62. package/models/components/listresourceuserbenefit.js.map +1 -1
  63. package/models/components/oauth2client.js +2 -2
  64. package/models/components/oauth2client.js.map +1 -1
  65. package/models/components/oauth2clientconfiguration.js +2 -2
  66. package/models/components/oauth2clientconfiguration.js.map +1 -1
  67. package/models/components/oauth2clientconfigurationupdate.js +2 -2
  68. package/models/components/oauth2clientconfigurationupdate.js.map +1 -1
  69. package/models/components/organizationfeaturesettings.d.ts +0 -5
  70. package/models/components/organizationfeaturesettings.d.ts.map +1 -1
  71. package/models/components/organizationfeaturesettings.js +0 -4
  72. package/models/components/organizationfeaturesettings.js.map +1 -1
  73. package/models/components/scope.d.ts +0 -6
  74. package/models/components/scope.d.ts.map +1 -1
  75. package/models/components/scope.js +0 -2
  76. package/models/components/scope.js.map +1 -1
  77. package/models/components/userorderproduct.d.ts +2 -24
  78. package/models/components/userorderproduct.d.ts.map +1 -1
  79. package/models/components/userorderproduct.js +3 -27
  80. package/models/components/userorderproduct.js.map +1 -1
  81. package/models/components/usersubscriptionproduct.d.ts +2 -24
  82. package/models/components/usersubscriptionproduct.d.ts.map +1 -1
  83. package/models/components/usersubscriptionproduct.js +3 -27
  84. package/models/components/usersubscriptionproduct.js.map +1 -1
  85. package/models/errors/index.d.ts +0 -1
  86. package/models/errors/index.d.ts.map +1 -1
  87. package/models/errors/index.js +0 -1
  88. package/models/errors/index.js.map +1 -1
  89. package/models/operations/benefitsupdate.d.ts +4 -4
  90. package/models/operations/benefitsupdate.d.ts.map +1 -1
  91. package/models/operations/benefitsupdate.js +0 -4
  92. package/models/operations/benefitsupdate.js.map +1 -1
  93. package/models/operations/filesupdate.d.ts +1 -1
  94. package/models/operations/filesuploaded.d.ts +1 -1
  95. package/models/operations/index.d.ts +0 -8
  96. package/models/operations/index.d.ts.map +1 -1
  97. package/models/operations/index.js +0 -8
  98. package/models/operations/index.js.map +1 -1
  99. package/models/operations/usersbenefitsget.d.ts +2 -6
  100. package/models/operations/usersbenefitsget.d.ts.map +1 -1
  101. package/models/operations/usersbenefitsget.js +0 -6
  102. package/models/operations/usersbenefitsget.js.map +1 -1
  103. package/package.json +1 -3
  104. package/sdk/sdk.d.ts +0 -3
  105. package/sdk/sdk.d.ts.map +1 -1
  106. package/sdk/sdk.js +0 -5
  107. package/sdk/sdk.js.map +1 -1
  108. package/src/funcs/filesCreate.ts +1 -1
  109. package/src/funcs/filesDelete.ts +3 -3
  110. package/src/funcs/filesUpdate.ts +7 -1
  111. package/src/funcs/filesUploaded.ts +7 -1
  112. package/src/hooks/hooks.ts +20 -0
  113. package/src/hooks/types.ts +9 -0
  114. package/src/lib/config.ts +3 -3
  115. package/src/models/components/benefit.ts +0 -10
  116. package/src/models/components/benefitadssubscriber.ts +12 -15
  117. package/src/models/components/benefitgrant.ts +0 -14
  118. package/src/models/components/benefitgrantwebhook.ts +0 -22
  119. package/src/models/components/benefittype.ts +0 -1
  120. package/src/models/components/checkoutlinkproduct.ts +4 -68
  121. package/src/models/components/checkoutproduct.ts +4 -66
  122. package/src/models/components/index.ts +0 -15
  123. package/src/models/components/listresourceuserbenefit.ts +0 -30
  124. package/src/models/components/oauth2client.ts +2 -2
  125. package/src/models/components/oauth2clientconfiguration.ts +2 -2
  126. package/src/models/components/oauth2clientconfigurationupdate.ts +2 -2
  127. package/src/models/components/organizationfeaturesettings.ts +0 -9
  128. package/src/models/components/scope.ts +0 -2
  129. package/src/models/components/userorderproduct.ts +4 -60
  130. package/src/models/components/usersubscriptionproduct.ts +4 -68
  131. package/src/models/errors/index.ts +0 -1
  132. package/src/models/operations/benefitsupdate.ts +0 -8
  133. package/src/models/operations/filesupdate.ts +1 -1
  134. package/src/models/operations/filesuploaded.ts +1 -1
  135. package/src/models/operations/index.ts +0 -8
  136. package/src/models/operations/usersbenefitsget.ts +0 -12
  137. package/src/sdk/sdk.ts +0 -6
  138. package/src/types/index.ts +1 -0
  139. package/src/types/webhooks.ts +7 -0
  140. package/types/index.d.ts +1 -0
  141. package/types/index.d.ts.map +1 -1
  142. package/types/webhooks.d.ts +4 -0
  143. package/types/webhooks.d.ts.map +1 -0
  144. package/types/webhooks.js +6 -0
  145. package/types/webhooks.js.map +1 -0
  146. package/docs/sdks/articles/README.md +0 -724
  147. package/funcs/articlesCreate.d.ts +0 -16
  148. package/funcs/articlesCreate.d.ts.map +0 -1
  149. package/funcs/articlesCreate.js +0 -99
  150. package/funcs/articlesCreate.js.map +0 -1
  151. package/funcs/articlesDelete.d.ts +0 -16
  152. package/funcs/articlesDelete.d.ts.map +0 -1
  153. package/funcs/articlesDelete.js +0 -105
  154. package/funcs/articlesDelete.js.map +0 -1
  155. package/funcs/articlesExport.d.ts +0 -16
  156. package/funcs/articlesExport.d.ts.map +0 -1
  157. package/funcs/articlesExport.js +0 -103
  158. package/funcs/articlesExport.js.map +0 -1
  159. package/funcs/articlesGet.d.ts +0 -17
  160. package/funcs/articlesGet.d.ts.map +0 -1
  161. package/funcs/articlesGet.js +0 -105
  162. package/funcs/articlesGet.js.map +0 -1
  163. package/funcs/articlesList.d.ts +0 -19
  164. package/funcs/articlesList.d.ts.map +0 -1
  165. package/funcs/articlesList.js +0 -138
  166. package/funcs/articlesList.js.map +0 -1
  167. package/funcs/articlesPreview.d.ts +0 -16
  168. package/funcs/articlesPreview.d.ts.map +0 -1
  169. package/funcs/articlesPreview.js +0 -106
  170. package/funcs/articlesPreview.js.map +0 -1
  171. package/funcs/articlesReceivers.d.ts +0 -17
  172. package/funcs/articlesReceivers.d.ts.map +0 -1
  173. package/funcs/articlesReceivers.js +0 -105
  174. package/funcs/articlesReceivers.js.map +0 -1
  175. package/funcs/articlesSend.d.ts +0 -16
  176. package/funcs/articlesSend.d.ts.map +0 -1
  177. package/funcs/articlesSend.js +0 -105
  178. package/funcs/articlesSend.js.map +0 -1
  179. package/funcs/articlesUpdate.d.ts +0 -17
  180. package/funcs/articlesUpdate.d.ts.map +0 -1
  181. package/funcs/articlesUpdate.js +0 -106
  182. package/funcs/articlesUpdate.js.map +0 -1
  183. package/models/components/article.d.ts +0 -68
  184. package/models/components/article.d.ts.map +0 -1
  185. package/models/components/article.js +0 -129
  186. package/models/components/article.js.map +0 -1
  187. package/models/components/articlebyline.d.ts +0 -28
  188. package/models/components/articlebyline.d.ts.map +0 -1
  189. package/models/components/articlebyline.js +0 -50
  190. package/models/components/articlebyline.js.map +0 -1
  191. package/models/components/articlecreate.d.ts +0 -93
  192. package/models/components/articlecreate.d.ts.map +0 -1
  193. package/models/components/articlecreate.js +0 -112
  194. package/models/components/articlecreate.js.map +0 -1
  195. package/models/components/articlepreview.d.ts +0 -32
  196. package/models/components/articlepreview.d.ts.map +0 -1
  197. package/models/components/articlepreview.js +0 -59
  198. package/models/components/articlepreview.js.map +0 -1
  199. package/models/components/articlereceivers.d.ts +0 -33
  200. package/models/components/articlereceivers.d.ts.map +0 -1
  201. package/models/components/articlereceivers.js +0 -76
  202. package/models/components/articlereceivers.js.map +0 -1
  203. package/models/components/articleupdate.d.ts +0 -85
  204. package/models/components/articleupdate.d.ts.map +0 -1
  205. package/models/components/articleupdate.js +0 -108
  206. package/models/components/articleupdate.js.map +0 -1
  207. package/models/components/articlevisibility.d.ts +0 -31
  208. package/models/components/articlevisibility.d.ts.map +0 -1
  209. package/models/components/articlevisibility.js +0 -51
  210. package/models/components/articlevisibility.js.map +0 -1
  211. package/models/components/benefitarticles.d.ts +0 -100
  212. package/models/components/benefitarticles.d.ts.map +0 -1
  213. package/models/components/benefitarticles.js +0 -107
  214. package/models/components/benefitarticles.js.map +0 -1
  215. package/models/components/benefitarticlesproperties.d.ts +0 -35
  216. package/models/components/benefitarticlesproperties.d.ts.map +0 -1
  217. package/models/components/benefitarticlesproperties.js +0 -68
  218. package/models/components/benefitarticlesproperties.js.map +0 -1
  219. package/models/components/benefitarticlessubscriber.d.ts +0 -99
  220. package/models/components/benefitarticlessubscriber.d.ts.map +0 -1
  221. package/models/components/benefitarticlessubscriber.js +0 -113
  222. package/models/components/benefitarticlessubscriber.js.map +0 -1
  223. package/models/components/benefitarticlessubscriberproperties.d.ts +0 -35
  224. package/models/components/benefitarticlessubscriberproperties.d.ts.map +0 -1
  225. package/models/components/benefitarticlessubscriberproperties.js +0 -68
  226. package/models/components/benefitarticlessubscriberproperties.js.map +0 -1
  227. package/models/components/benefitarticlesupdate.d.ts +0 -57
  228. package/models/components/benefitarticlesupdate.d.ts.map +0 -1
  229. package/models/components/benefitarticlesupdate.js +0 -79
  230. package/models/components/benefitarticlesupdate.js.map +0 -1
  231. package/models/components/benefitgrantarticlesproperties.d.ts +0 -25
  232. package/models/components/benefitgrantarticlesproperties.d.ts.map +0 -1
  233. package/models/components/benefitgrantarticlesproperties.js +0 -55
  234. package/models/components/benefitgrantarticlesproperties.js.map +0 -1
  235. package/models/components/bylineprofile.d.ts +0 -31
  236. package/models/components/bylineprofile.d.ts.map +0 -1
  237. package/models/components/bylineprofile.js +0 -70
  238. package/models/components/bylineprofile.js.map +0 -1
  239. package/models/components/listresourcearticle.d.ts +0 -33
  240. package/models/components/listresourcearticle.d.ts.map +0 -1
  241. package/models/components/listresourcearticle.js +0 -63
  242. package/models/components/listresourcearticle.js.map +0 -1
  243. package/models/errors/filenotfound.d.ts +0 -57
  244. package/models/errors/filenotfound.d.ts.map +0 -1
  245. package/models/errors/filenotfound.js +0 -88
  246. package/models/errors/filenotfound.js.map +0 -1
  247. package/models/operations/articlesdelete.d.ts +0 -29
  248. package/models/operations/articlesdelete.d.ts.map +0 -1
  249. package/models/operations/articlesdelete.js +0 -59
  250. package/models/operations/articlesdelete.js.map +0 -1
  251. package/models/operations/articlesexport.d.ts +0 -29
  252. package/models/operations/articlesexport.d.ts.map +0 -1
  253. package/models/operations/articlesexport.js +0 -68
  254. package/models/operations/articlesexport.js.map +0 -1
  255. package/models/operations/articlesget.d.ts +0 -29
  256. package/models/operations/articlesget.d.ts.map +0 -1
  257. package/models/operations/articlesget.js +0 -59
  258. package/models/operations/articlesget.js.map +0 -1
  259. package/models/operations/articleslist.d.ts +0 -141
  260. package/models/operations/articleslist.d.ts.map +0 -1
  261. package/models/operations/articleslist.js +0 -184
  262. package/models/operations/articleslist.js.map +0 -1
  263. package/models/operations/articlespreview.d.ts +0 -32
  264. package/models/operations/articlespreview.d.ts.map +0 -1
  265. package/models/operations/articlespreview.js +0 -71
  266. package/models/operations/articlespreview.js.map +0 -1
  267. package/models/operations/articlesreceivers.d.ts +0 -29
  268. package/models/operations/articlesreceivers.d.ts.map +0 -1
  269. package/models/operations/articlesreceivers.js +0 -59
  270. package/models/operations/articlesreceivers.js.map +0 -1
  271. package/models/operations/articlessend.d.ts +0 -29
  272. package/models/operations/articlessend.d.ts.map +0 -1
  273. package/models/operations/articlessend.js +0 -59
  274. package/models/operations/articlessend.js.map +0 -1
  275. package/models/operations/articlesupdate.d.ts +0 -32
  276. package/models/operations/articlesupdate.d.ts.map +0 -1
  277. package/models/operations/articlesupdate.js +0 -71
  278. package/models/operations/articlesupdate.js.map +0 -1
  279. package/sdk/articles.d.ts +0 -72
  280. package/sdk/articles.d.ts.map +0 -1
  281. package/sdk/articles.js +0 -103
  282. package/sdk/articles.js.map +0 -1
  283. package/src/funcs/articlesCreate.ts +0 -131
  284. package/src/funcs/articlesDelete.ts +0 -144
  285. package/src/funcs/articlesExport.ts +0 -136
  286. package/src/funcs/articlesGet.ts +0 -141
  287. package/src/funcs/articlesList.ts +0 -205
  288. package/src/funcs/articlesPreview.ts +0 -145
  289. package/src/funcs/articlesReceivers.ts +0 -138
  290. package/src/funcs/articlesSend.ts +0 -144
  291. package/src/funcs/articlesUpdate.ts +0 -145
  292. package/src/models/components/article.ts +0 -187
  293. package/src/models/components/articlebyline.ts +0 -33
  294. package/src/models/components/articlecreate.ts +0 -191
  295. package/src/models/components/articlepreview.ts +0 -65
  296. package/src/models/components/articlereceivers.ts +0 -87
  297. package/src/models/components/articleupdate.ts +0 -179
  298. package/src/models/components/articlevisibility.ts +0 -34
  299. package/src/models/components/benefitarticles.ts +0 -175
  300. package/src/models/components/benefitarticlesproperties.ts +0 -81
  301. package/src/models/components/benefitarticlessubscriber.ts +0 -189
  302. package/src/models/components/benefitarticlessubscriberproperties.ts +0 -86
  303. package/src/models/components/benefitarticlesupdate.ts +0 -102
  304. package/src/models/components/benefitgrantarticlesproperties.ts +0 -60
  305. package/src/models/components/bylineprofile.ts +0 -75
  306. package/src/models/components/listresourcearticle.ts +0 -82
  307. package/src/models/errors/filenotfound.ts +0 -102
  308. package/src/models/operations/articlesdelete.ts +0 -66
  309. package/src/models/operations/articlesexport.ts +0 -75
  310. package/src/models/operations/articlesget.ts +0 -66
  311. package/src/models/operations/articleslist.ts +0 -342
  312. package/src/models/operations/articlespreview.ts +0 -80
  313. package/src/models/operations/articlesreceivers.ts +0 -66
  314. package/src/models/operations/articlessend.ts +0 -66
  315. package/src/models/operations/articlesupdate.ts +0 -80
  316. package/src/sdk/articles.ts +0 -173
@@ -1,145 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import { PolarCore } from "../core.js";
6
- import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
- import * as M from "../lib/matchers.js";
8
- import { safeParse } from "../lib/schemas.js";
9
- import { RequestOptions } from "../lib/sdks.js";
10
- import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
11
- import { pathToFunc } from "../lib/url.js";
12
- import * as components from "../models/components/index.js";
13
- import {
14
- ConnectionError,
15
- InvalidRequestError,
16
- RequestAbortedError,
17
- RequestTimeoutError,
18
- UnexpectedClientError,
19
- } from "../models/errors/httpclienterrors.js";
20
- import * as errors from "../models/errors/index.js";
21
- import { SDKError } from "../models/errors/sdkerror.js";
22
- import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
- import * as operations from "../models/operations/index.js";
24
- import { Result } from "../types/fp.js";
25
-
26
- /**
27
- * Update Article
28
- *
29
- * @remarks
30
- * Update an article.
31
- */
32
- export async function articlesUpdate(
33
- client: PolarCore,
34
- request: operations.ArticlesUpdateRequest,
35
- options?: RequestOptions,
36
- ): Promise<
37
- Result<
38
- components.Article,
39
- | errors.NotPermitted
40
- | errors.ResourceNotFound
41
- | errors.HTTPValidationError
42
- | SDKError
43
- | SDKValidationError
44
- | UnexpectedClientError
45
- | InvalidRequestError
46
- | RequestAbortedError
47
- | RequestTimeoutError
48
- | ConnectionError
49
- >
50
- > {
51
- const parsed = safeParse(
52
- request,
53
- (value) => operations.ArticlesUpdateRequest$outboundSchema.parse(value),
54
- "Input validation failed",
55
- );
56
- if (!parsed.ok) {
57
- return parsed;
58
- }
59
- const payload = parsed.value;
60
- const body = encodeJSON("body", payload.ArticleUpdate, { explode: true });
61
-
62
- const pathParams = {
63
- id: encodeSimple("id", payload.id, {
64
- explode: false,
65
- charEncoding: "percent",
66
- }),
67
- };
68
-
69
- const path = pathToFunc("/v1/articles/{id}")(pathParams);
70
-
71
- const headers = new Headers({
72
- "Content-Type": "application/json",
73
- Accept: "application/json",
74
- });
75
-
76
- const secConfig = await extractSecurity(client._options.accessToken);
77
- const securityInput = secConfig == null ? {} : { accessToken: secConfig };
78
- const requestSecurity = resolveGlobalSecurity(securityInput);
79
-
80
- const context = {
81
- operationID: "articles:update",
82
- oAuth2Scopes: [],
83
-
84
- resolvedSecurity: requestSecurity,
85
-
86
- securitySource: client._options.accessToken,
87
- retryConfig: options?.retries
88
- || client._options.retryConfig
89
- || { strategy: "none" },
90
- retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
91
- };
92
-
93
- const requestRes = client._createRequest(context, {
94
- security: requestSecurity,
95
- method: "PATCH",
96
- path: path,
97
- headers: headers,
98
- body: body,
99
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
100
- }, options);
101
- if (!requestRes.ok) {
102
- return requestRes;
103
- }
104
- const req = requestRes.value;
105
-
106
- const doResult = await client._do(req, {
107
- context,
108
- errorCodes: ["403", "404", "422", "4XX", "5XX"],
109
- retryConfig: context.retryConfig,
110
- retryCodes: context.retryCodes,
111
- });
112
- if (!doResult.ok) {
113
- return doResult;
114
- }
115
- const response = doResult.value;
116
-
117
- const responseFields = {
118
- HttpMeta: { Response: response, Request: req },
119
- };
120
-
121
- const [result] = await M.match<
122
- components.Article,
123
- | errors.NotPermitted
124
- | errors.ResourceNotFound
125
- | errors.HTTPValidationError
126
- | SDKError
127
- | SDKValidationError
128
- | UnexpectedClientError
129
- | InvalidRequestError
130
- | RequestAbortedError
131
- | RequestTimeoutError
132
- | ConnectionError
133
- >(
134
- M.json(200, components.Article$inboundSchema),
135
- M.jsonErr(403, errors.NotPermitted$inboundSchema),
136
- M.jsonErr(404, errors.ResourceNotFound$inboundSchema),
137
- M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
138
- M.fail(["4XX", "5XX"]),
139
- )(response, { extraFields: responseFields });
140
- if (!result.ok) {
141
- return result;
142
- }
143
-
144
- return result;
145
- }
@@ -1,187 +0,0 @@
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
- ArticleVisibility,
12
- ArticleVisibility$inboundSchema,
13
- ArticleVisibility$outboundSchema,
14
- } from "./articlevisibility.js";
15
- import {
16
- BylineProfile,
17
- BylineProfile$inboundSchema,
18
- BylineProfile$Outbound,
19
- BylineProfile$outboundSchema,
20
- } from "./bylineprofile.js";
21
- import {
22
- Organization,
23
- Organization$inboundSchema,
24
- Organization$Outbound,
25
- Organization$outboundSchema,
26
- } from "./organization.js";
27
-
28
- export type Article = {
29
- id: string;
30
- slug: string;
31
- title: string;
32
- body: string;
33
- byline: BylineProfile;
34
- visibility: ArticleVisibility;
35
- userId: string | null;
36
- organizationId: string;
37
- organization: Organization;
38
- publishedAt: Date | null;
39
- paidSubscribersOnly: boolean | null;
40
- paidSubscribersOnlyEndsAt: Date | null;
41
- isPreview: boolean;
42
- isPinned: boolean;
43
- notifySubscribers: boolean | null;
44
- notificationsSentAt: Date | null;
45
- emailSentToCount: number | null;
46
- ogImageUrl: string | null;
47
- ogDescription: string | null;
48
- };
49
-
50
- /** @internal */
51
- export const Article$inboundSchema: z.ZodType<Article, z.ZodTypeDef, unknown> =
52
- z.object({
53
- id: z.string(),
54
- slug: z.string(),
55
- title: z.string(),
56
- body: z.string(),
57
- byline: BylineProfile$inboundSchema,
58
- visibility: ArticleVisibility$inboundSchema,
59
- user_id: z.nullable(z.string()),
60
- organization_id: z.string(),
61
- organization: Organization$inboundSchema,
62
- published_at: z.nullable(
63
- z.string().datetime({ offset: true }).transform(v => new Date(v)),
64
- ),
65
- paid_subscribers_only: z.nullable(z.boolean()),
66
- paid_subscribers_only_ends_at: z.nullable(
67
- z.string().datetime({ offset: true }).transform(v => new Date(v)),
68
- ),
69
- is_preview: z.boolean(),
70
- is_pinned: z.boolean(),
71
- notify_subscribers: z.nullable(z.boolean()),
72
- notifications_sent_at: z.nullable(
73
- z.string().datetime({ offset: true }).transform(v => new Date(v)),
74
- ),
75
- email_sent_to_count: z.nullable(z.number().int()),
76
- og_image_url: z.nullable(z.string()),
77
- og_description: z.nullable(z.string()),
78
- }).transform((v) => {
79
- return remap$(v, {
80
- "user_id": "userId",
81
- "organization_id": "organizationId",
82
- "published_at": "publishedAt",
83
- "paid_subscribers_only": "paidSubscribersOnly",
84
- "paid_subscribers_only_ends_at": "paidSubscribersOnlyEndsAt",
85
- "is_preview": "isPreview",
86
- "is_pinned": "isPinned",
87
- "notify_subscribers": "notifySubscribers",
88
- "notifications_sent_at": "notificationsSentAt",
89
- "email_sent_to_count": "emailSentToCount",
90
- "og_image_url": "ogImageUrl",
91
- "og_description": "ogDescription",
92
- });
93
- });
94
-
95
- /** @internal */
96
- export type Article$Outbound = {
97
- id: string;
98
- slug: string;
99
- title: string;
100
- body: string;
101
- byline: BylineProfile$Outbound;
102
- visibility: string;
103
- user_id: string | null;
104
- organization_id: string;
105
- organization: Organization$Outbound;
106
- published_at: string | null;
107
- paid_subscribers_only: boolean | null;
108
- paid_subscribers_only_ends_at: string | null;
109
- is_preview: boolean;
110
- is_pinned: boolean;
111
- notify_subscribers: boolean | null;
112
- notifications_sent_at: string | null;
113
- email_sent_to_count: number | null;
114
- og_image_url: string | null;
115
- og_description: string | null;
116
- };
117
-
118
- /** @internal */
119
- export const Article$outboundSchema: z.ZodType<
120
- Article$Outbound,
121
- z.ZodTypeDef,
122
- Article
123
- > = z.object({
124
- id: z.string(),
125
- slug: z.string(),
126
- title: z.string(),
127
- body: z.string(),
128
- byline: BylineProfile$outboundSchema,
129
- visibility: ArticleVisibility$outboundSchema,
130
- userId: z.nullable(z.string()),
131
- organizationId: z.string(),
132
- organization: Organization$outboundSchema,
133
- publishedAt: z.nullable(z.date().transform(v => v.toISOString())),
134
- paidSubscribersOnly: z.nullable(z.boolean()),
135
- paidSubscribersOnlyEndsAt: z.nullable(
136
- z.date().transform(v => v.toISOString()),
137
- ),
138
- isPreview: z.boolean(),
139
- isPinned: z.boolean(),
140
- notifySubscribers: z.nullable(z.boolean()),
141
- notificationsSentAt: z.nullable(z.date().transform(v => v.toISOString())),
142
- emailSentToCount: z.nullable(z.number().int()),
143
- ogImageUrl: z.nullable(z.string()),
144
- ogDescription: z.nullable(z.string()),
145
- }).transform((v) => {
146
- return remap$(v, {
147
- userId: "user_id",
148
- organizationId: "organization_id",
149
- publishedAt: "published_at",
150
- paidSubscribersOnly: "paid_subscribers_only",
151
- paidSubscribersOnlyEndsAt: "paid_subscribers_only_ends_at",
152
- isPreview: "is_preview",
153
- isPinned: "is_pinned",
154
- notifySubscribers: "notify_subscribers",
155
- notificationsSentAt: "notifications_sent_at",
156
- emailSentToCount: "email_sent_to_count",
157
- ogImageUrl: "og_image_url",
158
- ogDescription: "og_description",
159
- });
160
- });
161
-
162
- /**
163
- * @internal
164
- * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
165
- */
166
- export namespace Article$ {
167
- /** @deprecated use `Article$inboundSchema` instead. */
168
- export const inboundSchema = Article$inboundSchema;
169
- /** @deprecated use `Article$outboundSchema` instead. */
170
- export const outboundSchema = Article$outboundSchema;
171
- /** @deprecated use `Article$Outbound` instead. */
172
- export type Outbound = Article$Outbound;
173
- }
174
-
175
- export function articleToJSON(article: Article): string {
176
- return JSON.stringify(Article$outboundSchema.parse(article));
177
- }
178
-
179
- export function articleFromJSON(
180
- jsonString: string,
181
- ): SafeParseResult<Article, SDKValidationError> {
182
- return safeParse(
183
- jsonString,
184
- (x) => Article$inboundSchema.parse(JSON.parse(x)),
185
- `Failed to parse 'Article' from JSON`,
186
- );
187
- }
@@ -1,33 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import * as z from "zod";
6
- import { ClosedEnum } from "../../types/enums.js";
7
-
8
- export const ArticleByline = {
9
- User: "user",
10
- Organization: "organization",
11
- } as const;
12
- export type ArticleByline = ClosedEnum<typeof ArticleByline>;
13
-
14
- /** @internal */
15
- export const ArticleByline$inboundSchema: z.ZodNativeEnum<
16
- typeof ArticleByline
17
- > = z.nativeEnum(ArticleByline);
18
-
19
- /** @internal */
20
- export const ArticleByline$outboundSchema: z.ZodNativeEnum<
21
- typeof ArticleByline
22
- > = ArticleByline$inboundSchema;
23
-
24
- /**
25
- * @internal
26
- * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
27
- */
28
- export namespace ArticleByline$ {
29
- /** @deprecated use `ArticleByline$inboundSchema` instead. */
30
- export const inboundSchema = ArticleByline$inboundSchema;
31
- /** @deprecated use `ArticleByline$outboundSchema` instead. */
32
- export const outboundSchema = ArticleByline$outboundSchema;
33
- }
@@ -1,191 +0,0 @@
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
- ArticleByline,
12
- ArticleByline$inboundSchema,
13
- ArticleByline$outboundSchema,
14
- } from "./articlebyline.js";
15
- import {
16
- ArticleVisibility,
17
- ArticleVisibility$inboundSchema,
18
- ArticleVisibility$outboundSchema,
19
- } from "./articlevisibility.js";
20
-
21
- export type ArticleCreate = {
22
- /**
23
- * Title of the article.
24
- */
25
- title: string;
26
- /**
27
- * Slug of the article to be used in URLs. If no slug is provided one will be generated from the title.
28
- */
29
- slug?: string | null | undefined;
30
- /**
31
- * Body in string format. Either one of body or body_base64 is required.
32
- */
33
- body?: string | null | undefined;
34
- /**
35
- * Body in base64-encoded format. Can be helpful to bypass Web Application Firewalls (WAF). Either one of body or body_base64 is required.
36
- */
37
- bodyBase64?: string | null | undefined;
38
- /**
39
- * The ID of the organization owning the article. **Required unless you use an organization token.**
40
- */
41
- organizationId?: string | null | undefined;
42
- byline?: ArticleByline | undefined;
43
- visibility?: ArticleVisibility | undefined;
44
- /**
45
- * Set to true to only make this article available for subscribers to a paid subscription tier in the organization.
46
- */
47
- paidSubscribersOnly?: boolean | undefined;
48
- /**
49
- * If specified, time at which the article should no longer be restricted to paid subscribers. Only relevant if `paid_subscribers_only` is true.
50
- */
51
- paidSubscribersOnlyEndsAt?: Date | null | undefined;
52
- /**
53
- * Time of publishing. If this date is in the future, the post will be scheduled to publish at this time. If visibility is 'public', published_at will default to the current time.
54
- */
55
- publishedAt?: Date | null | undefined;
56
- /**
57
- * Set to true to deliver this article via email and/or notifications to subscribers.
58
- */
59
- notifySubscribers?: boolean | null | undefined;
60
- /**
61
- * If the article should be pinned
62
- */
63
- isPinned?: boolean | null | undefined;
64
- /**
65
- * Custom og:image URL value
66
- */
67
- ogImageUrl?: string | null | undefined;
68
- /**
69
- * Custom og:description value
70
- */
71
- ogDescription?: string | null | undefined;
72
- };
73
-
74
- /** @internal */
75
- export const ArticleCreate$inboundSchema: z.ZodType<
76
- ArticleCreate,
77
- z.ZodTypeDef,
78
- unknown
79
- > = z.object({
80
- title: z.string(),
81
- slug: z.nullable(z.string()).optional(),
82
- body: z.nullable(z.string()).optional(),
83
- body_base64: z.nullable(z.string()).optional(),
84
- organization_id: z.nullable(z.string()).optional(),
85
- byline: ArticleByline$inboundSchema.optional(),
86
- visibility: ArticleVisibility$inboundSchema.optional(),
87
- paid_subscribers_only: z.boolean().default(false),
88
- paid_subscribers_only_ends_at: z.nullable(
89
- z.string().datetime({ offset: true }).transform(v => new Date(v)),
90
- ).optional(),
91
- published_at: z.nullable(
92
- z.string().datetime({ offset: true }).transform(v => new Date(v)),
93
- ).optional(),
94
- notify_subscribers: z.nullable(z.boolean()).optional(),
95
- is_pinned: z.nullable(z.boolean()).optional(),
96
- og_image_url: z.nullable(z.string()).optional(),
97
- og_description: z.nullable(z.string()).optional(),
98
- }).transform((v) => {
99
- return remap$(v, {
100
- "body_base64": "bodyBase64",
101
- "organization_id": "organizationId",
102
- "paid_subscribers_only": "paidSubscribersOnly",
103
- "paid_subscribers_only_ends_at": "paidSubscribersOnlyEndsAt",
104
- "published_at": "publishedAt",
105
- "notify_subscribers": "notifySubscribers",
106
- "is_pinned": "isPinned",
107
- "og_image_url": "ogImageUrl",
108
- "og_description": "ogDescription",
109
- });
110
- });
111
-
112
- /** @internal */
113
- export type ArticleCreate$Outbound = {
114
- title: string;
115
- slug?: string | null | undefined;
116
- body?: string | null | undefined;
117
- body_base64?: string | null | undefined;
118
- organization_id?: string | null | undefined;
119
- byline?: string | undefined;
120
- visibility?: string | undefined;
121
- paid_subscribers_only: boolean;
122
- paid_subscribers_only_ends_at?: string | null | undefined;
123
- published_at?: string | null | undefined;
124
- notify_subscribers?: boolean | null | undefined;
125
- is_pinned?: boolean | null | undefined;
126
- og_image_url?: string | null | undefined;
127
- og_description?: string | null | undefined;
128
- };
129
-
130
- /** @internal */
131
- export const ArticleCreate$outboundSchema: z.ZodType<
132
- ArticleCreate$Outbound,
133
- z.ZodTypeDef,
134
- ArticleCreate
135
- > = z.object({
136
- title: z.string(),
137
- slug: z.nullable(z.string()).optional(),
138
- body: z.nullable(z.string()).optional(),
139
- bodyBase64: z.nullable(z.string()).optional(),
140
- organizationId: z.nullable(z.string()).optional(),
141
- byline: ArticleByline$outboundSchema.optional(),
142
- visibility: ArticleVisibility$outboundSchema.optional(),
143
- paidSubscribersOnly: z.boolean().default(false),
144
- paidSubscribersOnlyEndsAt: z.nullable(
145
- z.date().transform(v => v.toISOString()),
146
- ).optional(),
147
- publishedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
148
- notifySubscribers: z.nullable(z.boolean()).optional(),
149
- isPinned: z.nullable(z.boolean()).optional(),
150
- ogImageUrl: z.nullable(z.string()).optional(),
151
- ogDescription: z.nullable(z.string()).optional(),
152
- }).transform((v) => {
153
- return remap$(v, {
154
- bodyBase64: "body_base64",
155
- organizationId: "organization_id",
156
- paidSubscribersOnly: "paid_subscribers_only",
157
- paidSubscribersOnlyEndsAt: "paid_subscribers_only_ends_at",
158
- publishedAt: "published_at",
159
- notifySubscribers: "notify_subscribers",
160
- isPinned: "is_pinned",
161
- ogImageUrl: "og_image_url",
162
- ogDescription: "og_description",
163
- });
164
- });
165
-
166
- /**
167
- * @internal
168
- * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
169
- */
170
- export namespace ArticleCreate$ {
171
- /** @deprecated use `ArticleCreate$inboundSchema` instead. */
172
- export const inboundSchema = ArticleCreate$inboundSchema;
173
- /** @deprecated use `ArticleCreate$outboundSchema` instead. */
174
- export const outboundSchema = ArticleCreate$outboundSchema;
175
- /** @deprecated use `ArticleCreate$Outbound` instead. */
176
- export type Outbound = ArticleCreate$Outbound;
177
- }
178
-
179
- export function articleCreateToJSON(articleCreate: ArticleCreate): string {
180
- return JSON.stringify(ArticleCreate$outboundSchema.parse(articleCreate));
181
- }
182
-
183
- export function articleCreateFromJSON(
184
- jsonString: string,
185
- ): SafeParseResult<ArticleCreate, SDKValidationError> {
186
- return safeParse(
187
- jsonString,
188
- (x) => ArticleCreate$inboundSchema.parse(JSON.parse(x)),
189
- `Failed to parse 'ArticleCreate' from JSON`,
190
- );
191
- }
@@ -1,65 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import * as z from "zod";
6
- import { safeParse } from "../../lib/schemas.js";
7
- import { Result as SafeParseResult } from "../../types/fp.js";
8
- import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
-
10
- export type ArticlePreview = {
11
- /**
12
- * Email address to send the preview to. The user must be registered on Polar.
13
- */
14
- email: string;
15
- };
16
-
17
- /** @internal */
18
- export const ArticlePreview$inboundSchema: z.ZodType<
19
- ArticlePreview,
20
- z.ZodTypeDef,
21
- unknown
22
- > = z.object({
23
- email: z.string(),
24
- });
25
-
26
- /** @internal */
27
- export type ArticlePreview$Outbound = {
28
- email: string;
29
- };
30
-
31
- /** @internal */
32
- export const ArticlePreview$outboundSchema: z.ZodType<
33
- ArticlePreview$Outbound,
34
- z.ZodTypeDef,
35
- ArticlePreview
36
- > = z.object({
37
- email: z.string(),
38
- });
39
-
40
- /**
41
- * @internal
42
- * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
43
- */
44
- export namespace ArticlePreview$ {
45
- /** @deprecated use `ArticlePreview$inboundSchema` instead. */
46
- export const inboundSchema = ArticlePreview$inboundSchema;
47
- /** @deprecated use `ArticlePreview$outboundSchema` instead. */
48
- export const outboundSchema = ArticlePreview$outboundSchema;
49
- /** @deprecated use `ArticlePreview$Outbound` instead. */
50
- export type Outbound = ArticlePreview$Outbound;
51
- }
52
-
53
- export function articlePreviewToJSON(articlePreview: ArticlePreview): string {
54
- return JSON.stringify(ArticlePreview$outboundSchema.parse(articlePreview));
55
- }
56
-
57
- export function articlePreviewFromJSON(
58
- jsonString: string,
59
- ): SafeParseResult<ArticlePreview, SDKValidationError> {
60
- return safeParse(
61
- jsonString,
62
- (x) => ArticlePreview$inboundSchema.parse(JSON.parse(x)),
63
- `Failed to parse 'ArticlePreview' from JSON`,
64
- );
65
- }