@polar-sh/sdk 0.17.4 → 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 (284) 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/hooks/hooks.d.ts.map +1 -1
  6. package/hooks/hooks.js +18 -0
  7. package/hooks/hooks.js.map +1 -1
  8. package/hooks/types.d.ts +3 -0
  9. package/hooks/types.d.ts.map +1 -1
  10. package/lib/config.d.ts +3 -3
  11. package/lib/config.js +3 -3
  12. package/lib/config.js.map +1 -1
  13. package/models/components/benefit.d.ts +2 -3
  14. package/models/components/benefit.d.ts.map +1 -1
  15. package/models/components/benefit.js +0 -3
  16. package/models/components/benefit.js.map +1 -1
  17. package/models/components/benefitadssubscriber.d.ts +7 -7
  18. package/models/components/benefitadssubscriber.d.ts.map +1 -1
  19. package/models/components/benefitadssubscriber.js +11 -11
  20. package/models/components/benefitadssubscriber.js.map +1 -1
  21. package/models/components/benefitgrant.d.ts +4 -5
  22. package/models/components/benefitgrant.d.ts.map +1 -1
  23. package/models/components/benefitgrant.js +0 -5
  24. package/models/components/benefitgrant.js.map +1 -1
  25. package/models/components/benefitgrantwebhook.d.ts +8 -9
  26. package/models/components/benefitgrantwebhook.d.ts.map +1 -1
  27. package/models/components/benefitgrantwebhook.js +0 -9
  28. package/models/components/benefitgrantwebhook.js.map +1 -1
  29. package/models/components/benefittype.d.ts +0 -3
  30. package/models/components/benefittype.d.ts.map +1 -1
  31. package/models/components/benefittype.js +0 -1
  32. package/models/components/benefittype.js.map +1 -1
  33. package/models/components/checkoutlinkproduct.d.ts +2 -24
  34. package/models/components/checkoutlinkproduct.d.ts.map +1 -1
  35. package/models/components/checkoutlinkproduct.js +3 -27
  36. package/models/components/checkoutlinkproduct.js.map +1 -1
  37. package/models/components/checkoutproduct.d.ts +2 -24
  38. package/models/components/checkoutproduct.d.ts.map +1 -1
  39. package/models/components/checkoutproduct.js +3 -27
  40. package/models/components/checkoutproduct.js.map +1 -1
  41. package/models/components/index.d.ts +0 -15
  42. package/models/components/index.d.ts.map +1 -1
  43. package/models/components/index.js +0 -15
  44. package/models/components/index.js.map +1 -1
  45. package/models/components/listresourceuserbenefit.d.ts +0 -9
  46. package/models/components/listresourceuserbenefit.d.ts.map +1 -1
  47. package/models/components/listresourceuserbenefit.js +0 -13
  48. package/models/components/listresourceuserbenefit.js.map +1 -1
  49. package/models/components/oauth2client.js +2 -2
  50. package/models/components/oauth2client.js.map +1 -1
  51. package/models/components/oauth2clientconfiguration.js +2 -2
  52. package/models/components/oauth2clientconfiguration.js.map +1 -1
  53. package/models/components/oauth2clientconfigurationupdate.js +2 -2
  54. package/models/components/oauth2clientconfigurationupdate.js.map +1 -1
  55. package/models/components/organizationfeaturesettings.d.ts +0 -5
  56. package/models/components/organizationfeaturesettings.d.ts.map +1 -1
  57. package/models/components/organizationfeaturesettings.js +0 -4
  58. package/models/components/organizationfeaturesettings.js.map +1 -1
  59. package/models/components/scope.d.ts +0 -6
  60. package/models/components/scope.d.ts.map +1 -1
  61. package/models/components/scope.js +0 -2
  62. package/models/components/scope.js.map +1 -1
  63. package/models/components/userorderproduct.d.ts +2 -24
  64. package/models/components/userorderproduct.d.ts.map +1 -1
  65. package/models/components/userorderproduct.js +3 -27
  66. package/models/components/userorderproduct.js.map +1 -1
  67. package/models/components/usersubscriptionproduct.d.ts +2 -24
  68. package/models/components/usersubscriptionproduct.d.ts.map +1 -1
  69. package/models/components/usersubscriptionproduct.js +3 -27
  70. package/models/components/usersubscriptionproduct.js.map +1 -1
  71. package/models/operations/benefitsupdate.d.ts +4 -4
  72. package/models/operations/benefitsupdate.d.ts.map +1 -1
  73. package/models/operations/benefitsupdate.js +0 -4
  74. package/models/operations/benefitsupdate.js.map +1 -1
  75. package/models/operations/index.d.ts +0 -8
  76. package/models/operations/index.d.ts.map +1 -1
  77. package/models/operations/index.js +0 -8
  78. package/models/operations/index.js.map +1 -1
  79. package/models/operations/usersbenefitsget.d.ts +2 -6
  80. package/models/operations/usersbenefitsget.d.ts.map +1 -1
  81. package/models/operations/usersbenefitsget.js +0 -6
  82. package/models/operations/usersbenefitsget.js.map +1 -1
  83. package/package.json +1 -3
  84. package/sdk/sdk.d.ts +0 -3
  85. package/sdk/sdk.d.ts.map +1 -1
  86. package/sdk/sdk.js +0 -5
  87. package/sdk/sdk.js.map +1 -1
  88. package/src/hooks/hooks.ts +20 -0
  89. package/src/hooks/types.ts +9 -0
  90. package/src/lib/config.ts +3 -3
  91. package/src/models/components/benefit.ts +0 -10
  92. package/src/models/components/benefitadssubscriber.ts +12 -15
  93. package/src/models/components/benefitgrant.ts +0 -14
  94. package/src/models/components/benefitgrantwebhook.ts +0 -22
  95. package/src/models/components/benefittype.ts +0 -1
  96. package/src/models/components/checkoutlinkproduct.ts +4 -68
  97. package/src/models/components/checkoutproduct.ts +4 -66
  98. package/src/models/components/index.ts +0 -15
  99. package/src/models/components/listresourceuserbenefit.ts +0 -30
  100. package/src/models/components/oauth2client.ts +2 -2
  101. package/src/models/components/oauth2clientconfiguration.ts +2 -2
  102. package/src/models/components/oauth2clientconfigurationupdate.ts +2 -2
  103. package/src/models/components/organizationfeaturesettings.ts +0 -9
  104. package/src/models/components/scope.ts +0 -2
  105. package/src/models/components/userorderproduct.ts +4 -60
  106. package/src/models/components/usersubscriptionproduct.ts +4 -68
  107. package/src/models/operations/benefitsupdate.ts +0 -8
  108. package/src/models/operations/index.ts +0 -8
  109. package/src/models/operations/usersbenefitsget.ts +0 -12
  110. package/src/sdk/sdk.ts +0 -6
  111. package/src/types/index.ts +1 -0
  112. package/src/types/webhooks.ts +7 -0
  113. package/types/index.d.ts +1 -0
  114. package/types/index.d.ts.map +1 -1
  115. package/types/webhooks.d.ts +4 -0
  116. package/types/webhooks.d.ts.map +1 -0
  117. package/types/webhooks.js +6 -0
  118. package/types/webhooks.js.map +1 -0
  119. package/docs/sdks/articles/README.md +0 -724
  120. package/funcs/articlesCreate.d.ts +0 -16
  121. package/funcs/articlesCreate.d.ts.map +0 -1
  122. package/funcs/articlesCreate.js +0 -99
  123. package/funcs/articlesCreate.js.map +0 -1
  124. package/funcs/articlesDelete.d.ts +0 -16
  125. package/funcs/articlesDelete.d.ts.map +0 -1
  126. package/funcs/articlesDelete.js +0 -105
  127. package/funcs/articlesDelete.js.map +0 -1
  128. package/funcs/articlesExport.d.ts +0 -16
  129. package/funcs/articlesExport.d.ts.map +0 -1
  130. package/funcs/articlesExport.js +0 -103
  131. package/funcs/articlesExport.js.map +0 -1
  132. package/funcs/articlesGet.d.ts +0 -17
  133. package/funcs/articlesGet.d.ts.map +0 -1
  134. package/funcs/articlesGet.js +0 -105
  135. package/funcs/articlesGet.js.map +0 -1
  136. package/funcs/articlesList.d.ts +0 -19
  137. package/funcs/articlesList.d.ts.map +0 -1
  138. package/funcs/articlesList.js +0 -138
  139. package/funcs/articlesList.js.map +0 -1
  140. package/funcs/articlesPreview.d.ts +0 -16
  141. package/funcs/articlesPreview.d.ts.map +0 -1
  142. package/funcs/articlesPreview.js +0 -106
  143. package/funcs/articlesPreview.js.map +0 -1
  144. package/funcs/articlesReceivers.d.ts +0 -17
  145. package/funcs/articlesReceivers.d.ts.map +0 -1
  146. package/funcs/articlesReceivers.js +0 -105
  147. package/funcs/articlesReceivers.js.map +0 -1
  148. package/funcs/articlesSend.d.ts +0 -16
  149. package/funcs/articlesSend.d.ts.map +0 -1
  150. package/funcs/articlesSend.js +0 -105
  151. package/funcs/articlesSend.js.map +0 -1
  152. package/funcs/articlesUpdate.d.ts +0 -17
  153. package/funcs/articlesUpdate.d.ts.map +0 -1
  154. package/funcs/articlesUpdate.js +0 -106
  155. package/funcs/articlesUpdate.js.map +0 -1
  156. package/models/components/article.d.ts +0 -68
  157. package/models/components/article.d.ts.map +0 -1
  158. package/models/components/article.js +0 -129
  159. package/models/components/article.js.map +0 -1
  160. package/models/components/articlebyline.d.ts +0 -28
  161. package/models/components/articlebyline.d.ts.map +0 -1
  162. package/models/components/articlebyline.js +0 -50
  163. package/models/components/articlebyline.js.map +0 -1
  164. package/models/components/articlecreate.d.ts +0 -93
  165. package/models/components/articlecreate.d.ts.map +0 -1
  166. package/models/components/articlecreate.js +0 -112
  167. package/models/components/articlecreate.js.map +0 -1
  168. package/models/components/articlepreview.d.ts +0 -32
  169. package/models/components/articlepreview.d.ts.map +0 -1
  170. package/models/components/articlepreview.js +0 -59
  171. package/models/components/articlepreview.js.map +0 -1
  172. package/models/components/articlereceivers.d.ts +0 -33
  173. package/models/components/articlereceivers.d.ts.map +0 -1
  174. package/models/components/articlereceivers.js +0 -76
  175. package/models/components/articlereceivers.js.map +0 -1
  176. package/models/components/articleupdate.d.ts +0 -85
  177. package/models/components/articleupdate.d.ts.map +0 -1
  178. package/models/components/articleupdate.js +0 -108
  179. package/models/components/articleupdate.js.map +0 -1
  180. package/models/components/articlevisibility.d.ts +0 -31
  181. package/models/components/articlevisibility.d.ts.map +0 -1
  182. package/models/components/articlevisibility.js +0 -51
  183. package/models/components/articlevisibility.js.map +0 -1
  184. package/models/components/benefitarticles.d.ts +0 -100
  185. package/models/components/benefitarticles.d.ts.map +0 -1
  186. package/models/components/benefitarticles.js +0 -107
  187. package/models/components/benefitarticles.js.map +0 -1
  188. package/models/components/benefitarticlesproperties.d.ts +0 -35
  189. package/models/components/benefitarticlesproperties.d.ts.map +0 -1
  190. package/models/components/benefitarticlesproperties.js +0 -68
  191. package/models/components/benefitarticlesproperties.js.map +0 -1
  192. package/models/components/benefitarticlessubscriber.d.ts +0 -99
  193. package/models/components/benefitarticlessubscriber.d.ts.map +0 -1
  194. package/models/components/benefitarticlessubscriber.js +0 -113
  195. package/models/components/benefitarticlessubscriber.js.map +0 -1
  196. package/models/components/benefitarticlessubscriberproperties.d.ts +0 -35
  197. package/models/components/benefitarticlessubscriberproperties.d.ts.map +0 -1
  198. package/models/components/benefitarticlessubscriberproperties.js +0 -68
  199. package/models/components/benefitarticlessubscriberproperties.js.map +0 -1
  200. package/models/components/benefitarticlesupdate.d.ts +0 -57
  201. package/models/components/benefitarticlesupdate.d.ts.map +0 -1
  202. package/models/components/benefitarticlesupdate.js +0 -79
  203. package/models/components/benefitarticlesupdate.js.map +0 -1
  204. package/models/components/benefitgrantarticlesproperties.d.ts +0 -25
  205. package/models/components/benefitgrantarticlesproperties.d.ts.map +0 -1
  206. package/models/components/benefitgrantarticlesproperties.js +0 -55
  207. package/models/components/benefitgrantarticlesproperties.js.map +0 -1
  208. package/models/components/bylineprofile.d.ts +0 -31
  209. package/models/components/bylineprofile.d.ts.map +0 -1
  210. package/models/components/bylineprofile.js +0 -70
  211. package/models/components/bylineprofile.js.map +0 -1
  212. package/models/components/listresourcearticle.d.ts +0 -33
  213. package/models/components/listresourcearticle.d.ts.map +0 -1
  214. package/models/components/listresourcearticle.js +0 -63
  215. package/models/components/listresourcearticle.js.map +0 -1
  216. package/models/operations/articlesdelete.d.ts +0 -29
  217. package/models/operations/articlesdelete.d.ts.map +0 -1
  218. package/models/operations/articlesdelete.js +0 -59
  219. package/models/operations/articlesdelete.js.map +0 -1
  220. package/models/operations/articlesexport.d.ts +0 -29
  221. package/models/operations/articlesexport.d.ts.map +0 -1
  222. package/models/operations/articlesexport.js +0 -68
  223. package/models/operations/articlesexport.js.map +0 -1
  224. package/models/operations/articlesget.d.ts +0 -29
  225. package/models/operations/articlesget.d.ts.map +0 -1
  226. package/models/operations/articlesget.js +0 -59
  227. package/models/operations/articlesget.js.map +0 -1
  228. package/models/operations/articleslist.d.ts +0 -141
  229. package/models/operations/articleslist.d.ts.map +0 -1
  230. package/models/operations/articleslist.js +0 -184
  231. package/models/operations/articleslist.js.map +0 -1
  232. package/models/operations/articlespreview.d.ts +0 -32
  233. package/models/operations/articlespreview.d.ts.map +0 -1
  234. package/models/operations/articlespreview.js +0 -71
  235. package/models/operations/articlespreview.js.map +0 -1
  236. package/models/operations/articlesreceivers.d.ts +0 -29
  237. package/models/operations/articlesreceivers.d.ts.map +0 -1
  238. package/models/operations/articlesreceivers.js +0 -59
  239. package/models/operations/articlesreceivers.js.map +0 -1
  240. package/models/operations/articlessend.d.ts +0 -29
  241. package/models/operations/articlessend.d.ts.map +0 -1
  242. package/models/operations/articlessend.js +0 -59
  243. package/models/operations/articlessend.js.map +0 -1
  244. package/models/operations/articlesupdate.d.ts +0 -32
  245. package/models/operations/articlesupdate.d.ts.map +0 -1
  246. package/models/operations/articlesupdate.js +0 -71
  247. package/models/operations/articlesupdate.js.map +0 -1
  248. package/sdk/articles.d.ts +0 -72
  249. package/sdk/articles.d.ts.map +0 -1
  250. package/sdk/articles.js +0 -103
  251. package/sdk/articles.js.map +0 -1
  252. package/src/funcs/articlesCreate.ts +0 -131
  253. package/src/funcs/articlesDelete.ts +0 -144
  254. package/src/funcs/articlesExport.ts +0 -136
  255. package/src/funcs/articlesGet.ts +0 -141
  256. package/src/funcs/articlesList.ts +0 -205
  257. package/src/funcs/articlesPreview.ts +0 -145
  258. package/src/funcs/articlesReceivers.ts +0 -138
  259. package/src/funcs/articlesSend.ts +0 -144
  260. package/src/funcs/articlesUpdate.ts +0 -145
  261. package/src/models/components/article.ts +0 -187
  262. package/src/models/components/articlebyline.ts +0 -33
  263. package/src/models/components/articlecreate.ts +0 -191
  264. package/src/models/components/articlepreview.ts +0 -65
  265. package/src/models/components/articlereceivers.ts +0 -87
  266. package/src/models/components/articleupdate.ts +0 -179
  267. package/src/models/components/articlevisibility.ts +0 -34
  268. package/src/models/components/benefitarticles.ts +0 -175
  269. package/src/models/components/benefitarticlesproperties.ts +0 -81
  270. package/src/models/components/benefitarticlessubscriber.ts +0 -189
  271. package/src/models/components/benefitarticlessubscriberproperties.ts +0 -86
  272. package/src/models/components/benefitarticlesupdate.ts +0 -102
  273. package/src/models/components/benefitgrantarticlesproperties.ts +0 -60
  274. package/src/models/components/bylineprofile.ts +0 -75
  275. package/src/models/components/listresourcearticle.ts +0 -82
  276. package/src/models/operations/articlesdelete.ts +0 -66
  277. package/src/models/operations/articlesexport.ts +0 -75
  278. package/src/models/operations/articlesget.ts +0 -66
  279. package/src/models/operations/articleslist.ts +0 -342
  280. package/src/models/operations/articlespreview.ts +0 -80
  281. package/src/models/operations/articlesreceivers.ts +0 -66
  282. package/src/models/operations/articlessend.ts +0 -66
  283. package/src/models/operations/articlesupdate.ts +0 -80
  284. package/src/sdk/articles.ts +0 -173
@@ -1,138 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import { PolarCore } from "../core.js";
6
- import { encodeSimple } from "../lib/encodings.js";
7
- import * as M from "../lib/matchers.js";
8
- import { 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
- * Get Article Receivers Count
28
- *
29
- * @remarks
30
- * Get number of potential receivers for an article.
31
- */
32
- export async function articlesReceivers(
33
- client: PolarCore,
34
- request: operations.ArticlesReceiversRequest,
35
- options?: RequestOptions,
36
- ): Promise<
37
- Result<
38
- components.ArticleReceivers,
39
- | errors.HTTPValidationError
40
- | SDKError
41
- | SDKValidationError
42
- | UnexpectedClientError
43
- | InvalidRequestError
44
- | RequestAbortedError
45
- | RequestTimeoutError
46
- | ConnectionError
47
- >
48
- > {
49
- const parsed = safeParse(
50
- request,
51
- (value) => operations.ArticlesReceiversRequest$outboundSchema.parse(value),
52
- "Input validation failed",
53
- );
54
- if (!parsed.ok) {
55
- return parsed;
56
- }
57
- const payload = parsed.value;
58
- const body = null;
59
-
60
- const pathParams = {
61
- id: encodeSimple("id", payload.id, {
62
- explode: false,
63
- charEncoding: "percent",
64
- }),
65
- };
66
-
67
- const path = pathToFunc("/v1/articles/{id}/receivers")(pathParams);
68
-
69
- const headers = new Headers({
70
- Accept: "application/json",
71
- });
72
-
73
- const secConfig = await extractSecurity(client._options.accessToken);
74
- const securityInput = secConfig == null ? {} : { accessToken: secConfig };
75
- const requestSecurity = resolveGlobalSecurity(securityInput);
76
-
77
- const context = {
78
- operationID: "articles:receivers",
79
- oAuth2Scopes: [],
80
-
81
- resolvedSecurity: requestSecurity,
82
-
83
- securitySource: client._options.accessToken,
84
- retryConfig: options?.retries
85
- || client._options.retryConfig
86
- || { strategy: "none" },
87
- retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
88
- };
89
-
90
- const requestRes = client._createRequest(context, {
91
- security: requestSecurity,
92
- method: "GET",
93
- path: path,
94
- headers: headers,
95
- body: body,
96
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
97
- }, options);
98
- if (!requestRes.ok) {
99
- return requestRes;
100
- }
101
- const req = requestRes.value;
102
-
103
- const doResult = await client._do(req, {
104
- context,
105
- errorCodes: ["422", "4XX", "5XX"],
106
- retryConfig: context.retryConfig,
107
- retryCodes: context.retryCodes,
108
- });
109
- if (!doResult.ok) {
110
- return doResult;
111
- }
112
- const response = doResult.value;
113
-
114
- const responseFields = {
115
- HttpMeta: { Response: response, Request: req },
116
- };
117
-
118
- const [result] = await M.match<
119
- components.ArticleReceivers,
120
- | errors.HTTPValidationError
121
- | SDKError
122
- | SDKValidationError
123
- | UnexpectedClientError
124
- | InvalidRequestError
125
- | RequestAbortedError
126
- | RequestTimeoutError
127
- | ConnectionError
128
- >(
129
- M.json(200, components.ArticleReceivers$inboundSchema),
130
- M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
131
- M.fail(["4XX", "5XX"]),
132
- )(response, { extraFields: responseFields });
133
- if (!result.ok) {
134
- return result;
135
- }
136
-
137
- return result;
138
- }
@@ -1,144 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
-
5
- import * as z from "zod";
6
- import { PolarCore } from "../core.js";
7
- import { encodeSimple } from "../lib/encodings.js";
8
- import * as M from "../lib/matchers.js";
9
- import { safeParse } from "../lib/schemas.js";
10
- import { RequestOptions } from "../lib/sdks.js";
11
- import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
- import { pathToFunc } from "../lib/url.js";
13
- import {
14
- 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
- * Send Article
28
- *
29
- * @remarks
30
- * Send an article by email to all subscribers.
31
- */
32
- export async function articlesSend(
33
- client: PolarCore,
34
- request: operations.ArticlesSendRequest,
35
- options?: RequestOptions,
36
- ): Promise<
37
- Result<
38
- any,
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.ArticlesSendRequest$outboundSchema.parse(value),
54
- "Input validation failed",
55
- );
56
- if (!parsed.ok) {
57
- return parsed;
58
- }
59
- const payload = parsed.value;
60
- const body = null;
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}/send")(pathParams);
70
-
71
- const headers = new Headers({
72
- Accept: "application/json",
73
- });
74
-
75
- const secConfig = await extractSecurity(client._options.accessToken);
76
- const securityInput = secConfig == null ? {} : { accessToken: secConfig };
77
- const requestSecurity = resolveGlobalSecurity(securityInput);
78
-
79
- const context = {
80
- operationID: "articles:send",
81
- oAuth2Scopes: [],
82
-
83
- resolvedSecurity: requestSecurity,
84
-
85
- securitySource: client._options.accessToken,
86
- retryConfig: options?.retries
87
- || client._options.retryConfig
88
- || { strategy: "none" },
89
- retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
90
- };
91
-
92
- const requestRes = client._createRequest(context, {
93
- security: requestSecurity,
94
- method: "POST",
95
- path: path,
96
- headers: headers,
97
- body: body,
98
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
99
- }, options);
100
- if (!requestRes.ok) {
101
- return requestRes;
102
- }
103
- const req = requestRes.value;
104
-
105
- const doResult = await client._do(req, {
106
- context,
107
- errorCodes: ["400", "403", "404", "422", "4XX", "5XX"],
108
- retryConfig: context.retryConfig,
109
- retryCodes: context.retryCodes,
110
- });
111
- if (!doResult.ok) {
112
- return doResult;
113
- }
114
- const response = doResult.value;
115
-
116
- const responseFields = {
117
- HttpMeta: { Response: response, Request: req },
118
- };
119
-
120
- const [result] = await M.match<
121
- any,
122
- | errors.NotPermitted
123
- | errors.ResourceNotFound
124
- | errors.HTTPValidationError
125
- | SDKError
126
- | SDKValidationError
127
- | UnexpectedClientError
128
- | InvalidRequestError
129
- | RequestAbortedError
130
- | RequestTimeoutError
131
- | ConnectionError
132
- >(
133
- M.json(202, z.any()),
134
- M.fail([400, "4XX", "5XX"]),
135
- M.jsonErr(403, errors.NotPermitted$inboundSchema),
136
- M.jsonErr(404, errors.ResourceNotFound$inboundSchema),
137
- M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
138
- )(response, { extraFields: responseFields });
139
- if (!result.ok) {
140
- return result;
141
- }
142
-
143
- return result;
144
- }
@@ -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
- }