@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.
- package/FUNCTIONS.md +106 -0
- package/README.md +181 -30
- package/RUNTIMES.md +22 -0
- package/docs/sdks/checkouts/README.md +1 -1
- package/hooks/hooks.d.ts.map +1 -1
- package/hooks/hooks.js +18 -0
- package/hooks/hooks.js.map +1 -1
- package/hooks/types.d.ts +3 -0
- package/hooks/types.d.ts.map +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/models/components/benefit.d.ts +2 -3
- package/models/components/benefit.d.ts.map +1 -1
- package/models/components/benefit.js +0 -3
- package/models/components/benefit.js.map +1 -1
- package/models/components/benefitadssubscriber.d.ts +7 -7
- package/models/components/benefitadssubscriber.d.ts.map +1 -1
- package/models/components/benefitadssubscriber.js +11 -11
- package/models/components/benefitadssubscriber.js.map +1 -1
- package/models/components/benefitgrant.d.ts +4 -5
- package/models/components/benefitgrant.d.ts.map +1 -1
- package/models/components/benefitgrant.js +0 -5
- package/models/components/benefitgrant.js.map +1 -1
- package/models/components/benefitgrantwebhook.d.ts +8 -9
- package/models/components/benefitgrantwebhook.d.ts.map +1 -1
- package/models/components/benefitgrantwebhook.js +0 -9
- package/models/components/benefitgrantwebhook.js.map +1 -1
- package/models/components/benefittype.d.ts +0 -3
- package/models/components/benefittype.d.ts.map +1 -1
- package/models/components/benefittype.js +0 -1
- package/models/components/benefittype.js.map +1 -1
- package/models/components/checkoutlinkproduct.d.ts +2 -24
- package/models/components/checkoutlinkproduct.d.ts.map +1 -1
- package/models/components/checkoutlinkproduct.js +3 -27
- package/models/components/checkoutlinkproduct.js.map +1 -1
- package/models/components/checkoutproduct.d.ts +2 -24
- package/models/components/checkoutproduct.d.ts.map +1 -1
- package/models/components/checkoutproduct.js +3 -27
- package/models/components/checkoutproduct.js.map +1 -1
- package/models/components/index.d.ts +0 -15
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +0 -15
- package/models/components/index.js.map +1 -1
- package/models/components/listresourceuserbenefit.d.ts +0 -9
- package/models/components/listresourceuserbenefit.d.ts.map +1 -1
- package/models/components/listresourceuserbenefit.js +0 -13
- package/models/components/listresourceuserbenefit.js.map +1 -1
- package/models/components/oauth2client.js +2 -2
- package/models/components/oauth2client.js.map +1 -1
- package/models/components/oauth2clientconfiguration.js +2 -2
- package/models/components/oauth2clientconfiguration.js.map +1 -1
- package/models/components/oauth2clientconfigurationupdate.js +2 -2
- package/models/components/oauth2clientconfigurationupdate.js.map +1 -1
- package/models/components/organizationfeaturesettings.d.ts +0 -5
- package/models/components/organizationfeaturesettings.d.ts.map +1 -1
- package/models/components/organizationfeaturesettings.js +0 -4
- package/models/components/organizationfeaturesettings.js.map +1 -1
- package/models/components/scope.d.ts +0 -6
- package/models/components/scope.d.ts.map +1 -1
- package/models/components/scope.js +0 -2
- package/models/components/scope.js.map +1 -1
- package/models/components/userorderproduct.d.ts +2 -24
- package/models/components/userorderproduct.d.ts.map +1 -1
- package/models/components/userorderproduct.js +3 -27
- package/models/components/userorderproduct.js.map +1 -1
- package/models/components/usersubscriptionproduct.d.ts +2 -24
- package/models/components/usersubscriptionproduct.d.ts.map +1 -1
- package/models/components/usersubscriptionproduct.js +3 -27
- package/models/components/usersubscriptionproduct.js.map +1 -1
- package/models/operations/benefitsupdate.d.ts +4 -4
- package/models/operations/benefitsupdate.d.ts.map +1 -1
- package/models/operations/benefitsupdate.js +0 -4
- package/models/operations/benefitsupdate.js.map +1 -1
- package/models/operations/index.d.ts +0 -8
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +0 -8
- package/models/operations/index.js.map +1 -1
- package/models/operations/usersbenefitsget.d.ts +2 -6
- package/models/operations/usersbenefitsget.d.ts.map +1 -1
- package/models/operations/usersbenefitsget.js +0 -6
- package/models/operations/usersbenefitsget.js.map +1 -1
- package/package.json +1 -3
- package/sdk/sdk.d.ts +0 -3
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +0 -5
- package/sdk/sdk.js.map +1 -1
- package/src/hooks/hooks.ts +20 -0
- package/src/hooks/types.ts +9 -0
- package/src/lib/config.ts +3 -3
- package/src/models/components/benefit.ts +0 -10
- package/src/models/components/benefitadssubscriber.ts +12 -15
- package/src/models/components/benefitgrant.ts +0 -14
- package/src/models/components/benefitgrantwebhook.ts +0 -22
- package/src/models/components/benefittype.ts +0 -1
- package/src/models/components/checkoutlinkproduct.ts +4 -68
- package/src/models/components/checkoutproduct.ts +4 -66
- package/src/models/components/index.ts +0 -15
- package/src/models/components/listresourceuserbenefit.ts +0 -30
- package/src/models/components/oauth2client.ts +2 -2
- package/src/models/components/oauth2clientconfiguration.ts +2 -2
- package/src/models/components/oauth2clientconfigurationupdate.ts +2 -2
- package/src/models/components/organizationfeaturesettings.ts +0 -9
- package/src/models/components/scope.ts +0 -2
- package/src/models/components/userorderproduct.ts +4 -60
- package/src/models/components/usersubscriptionproduct.ts +4 -68
- package/src/models/operations/benefitsupdate.ts +0 -8
- package/src/models/operations/index.ts +0 -8
- package/src/models/operations/usersbenefitsget.ts +0 -12
- package/src/sdk/sdk.ts +0 -6
- package/src/types/index.ts +1 -0
- package/src/types/webhooks.ts +7 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/webhooks.d.ts +4 -0
- package/types/webhooks.d.ts.map +1 -0
- package/types/webhooks.js +6 -0
- package/types/webhooks.js.map +1 -0
- package/docs/sdks/articles/README.md +0 -724
- package/funcs/articlesCreate.d.ts +0 -16
- package/funcs/articlesCreate.d.ts.map +0 -1
- package/funcs/articlesCreate.js +0 -99
- package/funcs/articlesCreate.js.map +0 -1
- package/funcs/articlesDelete.d.ts +0 -16
- package/funcs/articlesDelete.d.ts.map +0 -1
- package/funcs/articlesDelete.js +0 -105
- package/funcs/articlesDelete.js.map +0 -1
- package/funcs/articlesExport.d.ts +0 -16
- package/funcs/articlesExport.d.ts.map +0 -1
- package/funcs/articlesExport.js +0 -103
- package/funcs/articlesExport.js.map +0 -1
- package/funcs/articlesGet.d.ts +0 -17
- package/funcs/articlesGet.d.ts.map +0 -1
- package/funcs/articlesGet.js +0 -105
- package/funcs/articlesGet.js.map +0 -1
- package/funcs/articlesList.d.ts +0 -19
- package/funcs/articlesList.d.ts.map +0 -1
- package/funcs/articlesList.js +0 -138
- package/funcs/articlesList.js.map +0 -1
- package/funcs/articlesPreview.d.ts +0 -16
- package/funcs/articlesPreview.d.ts.map +0 -1
- package/funcs/articlesPreview.js +0 -106
- package/funcs/articlesPreview.js.map +0 -1
- package/funcs/articlesReceivers.d.ts +0 -17
- package/funcs/articlesReceivers.d.ts.map +0 -1
- package/funcs/articlesReceivers.js +0 -105
- package/funcs/articlesReceivers.js.map +0 -1
- package/funcs/articlesSend.d.ts +0 -16
- package/funcs/articlesSend.d.ts.map +0 -1
- package/funcs/articlesSend.js +0 -105
- package/funcs/articlesSend.js.map +0 -1
- package/funcs/articlesUpdate.d.ts +0 -17
- package/funcs/articlesUpdate.d.ts.map +0 -1
- package/funcs/articlesUpdate.js +0 -106
- package/funcs/articlesUpdate.js.map +0 -1
- package/models/components/article.d.ts +0 -68
- package/models/components/article.d.ts.map +0 -1
- package/models/components/article.js +0 -129
- package/models/components/article.js.map +0 -1
- package/models/components/articlebyline.d.ts +0 -28
- package/models/components/articlebyline.d.ts.map +0 -1
- package/models/components/articlebyline.js +0 -50
- package/models/components/articlebyline.js.map +0 -1
- package/models/components/articlecreate.d.ts +0 -93
- package/models/components/articlecreate.d.ts.map +0 -1
- package/models/components/articlecreate.js +0 -112
- package/models/components/articlecreate.js.map +0 -1
- package/models/components/articlepreview.d.ts +0 -32
- package/models/components/articlepreview.d.ts.map +0 -1
- package/models/components/articlepreview.js +0 -59
- package/models/components/articlepreview.js.map +0 -1
- package/models/components/articlereceivers.d.ts +0 -33
- package/models/components/articlereceivers.d.ts.map +0 -1
- package/models/components/articlereceivers.js +0 -76
- package/models/components/articlereceivers.js.map +0 -1
- package/models/components/articleupdate.d.ts +0 -85
- package/models/components/articleupdate.d.ts.map +0 -1
- package/models/components/articleupdate.js +0 -108
- package/models/components/articleupdate.js.map +0 -1
- package/models/components/articlevisibility.d.ts +0 -31
- package/models/components/articlevisibility.d.ts.map +0 -1
- package/models/components/articlevisibility.js +0 -51
- package/models/components/articlevisibility.js.map +0 -1
- package/models/components/benefitarticles.d.ts +0 -100
- package/models/components/benefitarticles.d.ts.map +0 -1
- package/models/components/benefitarticles.js +0 -107
- package/models/components/benefitarticles.js.map +0 -1
- package/models/components/benefitarticlesproperties.d.ts +0 -35
- package/models/components/benefitarticlesproperties.d.ts.map +0 -1
- package/models/components/benefitarticlesproperties.js +0 -68
- package/models/components/benefitarticlesproperties.js.map +0 -1
- package/models/components/benefitarticlessubscriber.d.ts +0 -99
- package/models/components/benefitarticlessubscriber.d.ts.map +0 -1
- package/models/components/benefitarticlessubscriber.js +0 -113
- package/models/components/benefitarticlessubscriber.js.map +0 -1
- package/models/components/benefitarticlessubscriberproperties.d.ts +0 -35
- package/models/components/benefitarticlessubscriberproperties.d.ts.map +0 -1
- package/models/components/benefitarticlessubscriberproperties.js +0 -68
- package/models/components/benefitarticlessubscriberproperties.js.map +0 -1
- package/models/components/benefitarticlesupdate.d.ts +0 -57
- package/models/components/benefitarticlesupdate.d.ts.map +0 -1
- package/models/components/benefitarticlesupdate.js +0 -79
- package/models/components/benefitarticlesupdate.js.map +0 -1
- package/models/components/benefitgrantarticlesproperties.d.ts +0 -25
- package/models/components/benefitgrantarticlesproperties.d.ts.map +0 -1
- package/models/components/benefitgrantarticlesproperties.js +0 -55
- package/models/components/benefitgrantarticlesproperties.js.map +0 -1
- package/models/components/bylineprofile.d.ts +0 -31
- package/models/components/bylineprofile.d.ts.map +0 -1
- package/models/components/bylineprofile.js +0 -70
- package/models/components/bylineprofile.js.map +0 -1
- package/models/components/listresourcearticle.d.ts +0 -33
- package/models/components/listresourcearticle.d.ts.map +0 -1
- package/models/components/listresourcearticle.js +0 -63
- package/models/components/listresourcearticle.js.map +0 -1
- package/models/operations/articlesdelete.d.ts +0 -29
- package/models/operations/articlesdelete.d.ts.map +0 -1
- package/models/operations/articlesdelete.js +0 -59
- package/models/operations/articlesdelete.js.map +0 -1
- package/models/operations/articlesexport.d.ts +0 -29
- package/models/operations/articlesexport.d.ts.map +0 -1
- package/models/operations/articlesexport.js +0 -68
- package/models/operations/articlesexport.js.map +0 -1
- package/models/operations/articlesget.d.ts +0 -29
- package/models/operations/articlesget.d.ts.map +0 -1
- package/models/operations/articlesget.js +0 -59
- package/models/operations/articlesget.js.map +0 -1
- package/models/operations/articleslist.d.ts +0 -141
- package/models/operations/articleslist.d.ts.map +0 -1
- package/models/operations/articleslist.js +0 -184
- package/models/operations/articleslist.js.map +0 -1
- package/models/operations/articlespreview.d.ts +0 -32
- package/models/operations/articlespreview.d.ts.map +0 -1
- package/models/operations/articlespreview.js +0 -71
- package/models/operations/articlespreview.js.map +0 -1
- package/models/operations/articlesreceivers.d.ts +0 -29
- package/models/operations/articlesreceivers.d.ts.map +0 -1
- package/models/operations/articlesreceivers.js +0 -59
- package/models/operations/articlesreceivers.js.map +0 -1
- package/models/operations/articlessend.d.ts +0 -29
- package/models/operations/articlessend.d.ts.map +0 -1
- package/models/operations/articlessend.js +0 -59
- package/models/operations/articlessend.js.map +0 -1
- package/models/operations/articlesupdate.d.ts +0 -32
- package/models/operations/articlesupdate.d.ts.map +0 -1
- package/models/operations/articlesupdate.js +0 -71
- package/models/operations/articlesupdate.js.map +0 -1
- package/sdk/articles.d.ts +0 -72
- package/sdk/articles.d.ts.map +0 -1
- package/sdk/articles.js +0 -103
- package/sdk/articles.js.map +0 -1
- package/src/funcs/articlesCreate.ts +0 -131
- package/src/funcs/articlesDelete.ts +0 -144
- package/src/funcs/articlesExport.ts +0 -136
- package/src/funcs/articlesGet.ts +0 -141
- package/src/funcs/articlesList.ts +0 -205
- package/src/funcs/articlesPreview.ts +0 -145
- package/src/funcs/articlesReceivers.ts +0 -138
- package/src/funcs/articlesSend.ts +0 -144
- package/src/funcs/articlesUpdate.ts +0 -145
- package/src/models/components/article.ts +0 -187
- package/src/models/components/articlebyline.ts +0 -33
- package/src/models/components/articlecreate.ts +0 -191
- package/src/models/components/articlepreview.ts +0 -65
- package/src/models/components/articlereceivers.ts +0 -87
- package/src/models/components/articleupdate.ts +0 -179
- package/src/models/components/articlevisibility.ts +0 -34
- package/src/models/components/benefitarticles.ts +0 -175
- package/src/models/components/benefitarticlesproperties.ts +0 -81
- package/src/models/components/benefitarticlessubscriber.ts +0 -189
- package/src/models/components/benefitarticlessubscriberproperties.ts +0 -86
- package/src/models/components/benefitarticlesupdate.ts +0 -102
- package/src/models/components/benefitgrantarticlesproperties.ts +0 -60
- package/src/models/components/bylineprofile.ts +0 -75
- package/src/models/components/listresourcearticle.ts +0 -82
- package/src/models/operations/articlesdelete.ts +0 -66
- package/src/models/operations/articlesexport.ts +0 -75
- package/src/models/operations/articlesget.ts +0 -66
- package/src/models/operations/articleslist.ts +0 -342
- package/src/models/operations/articlespreview.ts +0 -80
- package/src/models/operations/articlesreceivers.ts +0 -66
- package/src/models/operations/articlessend.ts +0 -66
- package/src/models/operations/articlesupdate.ts +0 -80
- package/src/sdk/articles.ts +0 -173
|
@@ -1,136 +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 { encodeFormQuery } 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
|
-
* Export Articles
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* Export organization articles.
|
|
31
|
-
*/
|
|
32
|
-
export async function articlesExport(
|
|
33
|
-
client: PolarCore,
|
|
34
|
-
request: operations.ArticlesExportRequest,
|
|
35
|
-
options?: RequestOptions,
|
|
36
|
-
): Promise<
|
|
37
|
-
Result<
|
|
38
|
-
any,
|
|
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.ArticlesExportRequest$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 path = pathToFunc("/v1/articles/export")();
|
|
61
|
-
|
|
62
|
-
const query = encodeFormQuery({
|
|
63
|
-
"organization_id": payload.organization_id,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const headers = new Headers({
|
|
67
|
-
Accept: "application/json",
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const secConfig = await extractSecurity(client._options.accessToken);
|
|
71
|
-
const securityInput = secConfig == null ? {} : { accessToken: secConfig };
|
|
72
|
-
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
73
|
-
|
|
74
|
-
const context = {
|
|
75
|
-
operationID: "articles:export",
|
|
76
|
-
oAuth2Scopes: [],
|
|
77
|
-
|
|
78
|
-
resolvedSecurity: requestSecurity,
|
|
79
|
-
|
|
80
|
-
securitySource: client._options.accessToken,
|
|
81
|
-
retryConfig: options?.retries
|
|
82
|
-
|| client._options.retryConfig
|
|
83
|
-
|| { strategy: "none" },
|
|
84
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const requestRes = client._createRequest(context, {
|
|
88
|
-
security: requestSecurity,
|
|
89
|
-
method: "GET",
|
|
90
|
-
path: path,
|
|
91
|
-
headers: headers,
|
|
92
|
-
query: query,
|
|
93
|
-
body: body,
|
|
94
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
95
|
-
}, options);
|
|
96
|
-
if (!requestRes.ok) {
|
|
97
|
-
return requestRes;
|
|
98
|
-
}
|
|
99
|
-
const req = requestRes.value;
|
|
100
|
-
|
|
101
|
-
const doResult = await client._do(req, {
|
|
102
|
-
context,
|
|
103
|
-
errorCodes: ["422", "4XX", "5XX"],
|
|
104
|
-
retryConfig: context.retryConfig,
|
|
105
|
-
retryCodes: context.retryCodes,
|
|
106
|
-
});
|
|
107
|
-
if (!doResult.ok) {
|
|
108
|
-
return doResult;
|
|
109
|
-
}
|
|
110
|
-
const response = doResult.value;
|
|
111
|
-
|
|
112
|
-
const responseFields = {
|
|
113
|
-
HttpMeta: { Response: response, Request: req },
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const [result] = await M.match<
|
|
117
|
-
any,
|
|
118
|
-
| errors.HTTPValidationError
|
|
119
|
-
| SDKError
|
|
120
|
-
| SDKValidationError
|
|
121
|
-
| UnexpectedClientError
|
|
122
|
-
| InvalidRequestError
|
|
123
|
-
| RequestAbortedError
|
|
124
|
-
| RequestTimeoutError
|
|
125
|
-
| ConnectionError
|
|
126
|
-
>(
|
|
127
|
-
M.json(200, z.any()),
|
|
128
|
-
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
129
|
-
M.fail(["4XX", "5XX"]),
|
|
130
|
-
)(response, { extraFields: responseFields });
|
|
131
|
-
if (!result.ok) {
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return result;
|
|
136
|
-
}
|
package/src/funcs/articlesGet.ts
DELETED
|
@@ -1,141 +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
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* Get an article by ID.
|
|
31
|
-
*/
|
|
32
|
-
export async function articlesGet(
|
|
33
|
-
client: PolarCore,
|
|
34
|
-
request: operations.ArticlesGetRequest,
|
|
35
|
-
options?: RequestOptions,
|
|
36
|
-
): Promise<
|
|
37
|
-
Result<
|
|
38
|
-
components.Article,
|
|
39
|
-
| errors.ResourceNotFound
|
|
40
|
-
| errors.HTTPValidationError
|
|
41
|
-
| SDKError
|
|
42
|
-
| SDKValidationError
|
|
43
|
-
| UnexpectedClientError
|
|
44
|
-
| InvalidRequestError
|
|
45
|
-
| RequestAbortedError
|
|
46
|
-
| RequestTimeoutError
|
|
47
|
-
| ConnectionError
|
|
48
|
-
>
|
|
49
|
-
> {
|
|
50
|
-
const parsed = safeParse(
|
|
51
|
-
request,
|
|
52
|
-
(value) => operations.ArticlesGetRequest$outboundSchema.parse(value),
|
|
53
|
-
"Input validation failed",
|
|
54
|
-
);
|
|
55
|
-
if (!parsed.ok) {
|
|
56
|
-
return parsed;
|
|
57
|
-
}
|
|
58
|
-
const payload = parsed.value;
|
|
59
|
-
const body = null;
|
|
60
|
-
|
|
61
|
-
const pathParams = {
|
|
62
|
-
id: encodeSimple("id", payload.id, {
|
|
63
|
-
explode: false,
|
|
64
|
-
charEncoding: "percent",
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const path = pathToFunc("/v1/articles/{id}")(pathParams);
|
|
69
|
-
|
|
70
|
-
const headers = new Headers({
|
|
71
|
-
Accept: "application/json",
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const secConfig = await extractSecurity(client._options.accessToken);
|
|
75
|
-
const securityInput = secConfig == null ? {} : { accessToken: secConfig };
|
|
76
|
-
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
77
|
-
|
|
78
|
-
const context = {
|
|
79
|
-
operationID: "articles:get",
|
|
80
|
-
oAuth2Scopes: [],
|
|
81
|
-
|
|
82
|
-
resolvedSecurity: requestSecurity,
|
|
83
|
-
|
|
84
|
-
securitySource: client._options.accessToken,
|
|
85
|
-
retryConfig: options?.retries
|
|
86
|
-
|| client._options.retryConfig
|
|
87
|
-
|| { strategy: "none" },
|
|
88
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const requestRes = client._createRequest(context, {
|
|
92
|
-
security: requestSecurity,
|
|
93
|
-
method: "GET",
|
|
94
|
-
path: path,
|
|
95
|
-
headers: headers,
|
|
96
|
-
body: body,
|
|
97
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
98
|
-
}, options);
|
|
99
|
-
if (!requestRes.ok) {
|
|
100
|
-
return requestRes;
|
|
101
|
-
}
|
|
102
|
-
const req = requestRes.value;
|
|
103
|
-
|
|
104
|
-
const doResult = await client._do(req, {
|
|
105
|
-
context,
|
|
106
|
-
errorCodes: ["404", "422", "4XX", "5XX"],
|
|
107
|
-
retryConfig: context.retryConfig,
|
|
108
|
-
retryCodes: context.retryCodes,
|
|
109
|
-
});
|
|
110
|
-
if (!doResult.ok) {
|
|
111
|
-
return doResult;
|
|
112
|
-
}
|
|
113
|
-
const response = doResult.value;
|
|
114
|
-
|
|
115
|
-
const responseFields = {
|
|
116
|
-
HttpMeta: { Response: response, Request: req },
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const [result] = await M.match<
|
|
120
|
-
components.Article,
|
|
121
|
-
| errors.ResourceNotFound
|
|
122
|
-
| errors.HTTPValidationError
|
|
123
|
-
| SDKError
|
|
124
|
-
| SDKValidationError
|
|
125
|
-
| UnexpectedClientError
|
|
126
|
-
| InvalidRequestError
|
|
127
|
-
| RequestAbortedError
|
|
128
|
-
| RequestTimeoutError
|
|
129
|
-
| ConnectionError
|
|
130
|
-
>(
|
|
131
|
-
M.json(200, components.Article$inboundSchema),
|
|
132
|
-
M.jsonErr(404, errors.ResourceNotFound$inboundSchema),
|
|
133
|
-
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
134
|
-
M.fail(["4XX", "5XX"]),
|
|
135
|
-
)(response, { extraFields: responseFields });
|
|
136
|
-
if (!result.ok) {
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { PolarCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
|
-
import { encodeFormQuery } 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
|
-
import {
|
|
26
|
-
createPageIterator,
|
|
27
|
-
haltIterator,
|
|
28
|
-
PageIterator,
|
|
29
|
-
Paginator,
|
|
30
|
-
} from "../types/operations.js";
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* List Articles
|
|
34
|
-
*
|
|
35
|
-
* @remarks
|
|
36
|
-
* List articles.
|
|
37
|
-
*/
|
|
38
|
-
export async function articlesList(
|
|
39
|
-
client: PolarCore,
|
|
40
|
-
request: operations.ArticlesListRequest,
|
|
41
|
-
options?: RequestOptions,
|
|
42
|
-
): Promise<
|
|
43
|
-
PageIterator<
|
|
44
|
-
Result<
|
|
45
|
-
operations.ArticlesListResponse,
|
|
46
|
-
| errors.HTTPValidationError
|
|
47
|
-
| SDKError
|
|
48
|
-
| SDKValidationError
|
|
49
|
-
| UnexpectedClientError
|
|
50
|
-
| InvalidRequestError
|
|
51
|
-
| RequestAbortedError
|
|
52
|
-
| RequestTimeoutError
|
|
53
|
-
| ConnectionError
|
|
54
|
-
>,
|
|
55
|
-
{ page: number }
|
|
56
|
-
>
|
|
57
|
-
> {
|
|
58
|
-
const parsed = safeParse(
|
|
59
|
-
request,
|
|
60
|
-
(value) => operations.ArticlesListRequest$outboundSchema.parse(value),
|
|
61
|
-
"Input validation failed",
|
|
62
|
-
);
|
|
63
|
-
if (!parsed.ok) {
|
|
64
|
-
return haltIterator(parsed);
|
|
65
|
-
}
|
|
66
|
-
const payload = parsed.value;
|
|
67
|
-
const body = null;
|
|
68
|
-
|
|
69
|
-
const path = pathToFunc("/v1/articles/")();
|
|
70
|
-
|
|
71
|
-
const query = encodeFormQuery({
|
|
72
|
-
"is_pinned": payload.is_pinned,
|
|
73
|
-
"is_published": payload.is_published,
|
|
74
|
-
"is_subscribed": payload.is_subscribed,
|
|
75
|
-
"limit": payload.limit,
|
|
76
|
-
"organization_id": payload.organization_id,
|
|
77
|
-
"page": payload.page,
|
|
78
|
-
"slug": payload.slug,
|
|
79
|
-
"visibility": payload.visibility,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const headers = new Headers({
|
|
83
|
-
Accept: "application/json",
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const secConfig = await extractSecurity(client._options.accessToken);
|
|
87
|
-
const securityInput = secConfig == null ? {} : { accessToken: secConfig };
|
|
88
|
-
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
89
|
-
|
|
90
|
-
const context = {
|
|
91
|
-
operationID: "articles:list",
|
|
92
|
-
oAuth2Scopes: [],
|
|
93
|
-
|
|
94
|
-
resolvedSecurity: requestSecurity,
|
|
95
|
-
|
|
96
|
-
securitySource: client._options.accessToken,
|
|
97
|
-
retryConfig: options?.retries
|
|
98
|
-
|| client._options.retryConfig
|
|
99
|
-
|| { strategy: "none" },
|
|
100
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const requestRes = client._createRequest(context, {
|
|
104
|
-
security: requestSecurity,
|
|
105
|
-
method: "GET",
|
|
106
|
-
path: path,
|
|
107
|
-
headers: headers,
|
|
108
|
-
query: query,
|
|
109
|
-
body: body,
|
|
110
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
111
|
-
}, options);
|
|
112
|
-
if (!requestRes.ok) {
|
|
113
|
-
return haltIterator(requestRes);
|
|
114
|
-
}
|
|
115
|
-
const req = requestRes.value;
|
|
116
|
-
|
|
117
|
-
const doResult = await client._do(req, {
|
|
118
|
-
context,
|
|
119
|
-
errorCodes: ["422", "4XX", "5XX"],
|
|
120
|
-
retryConfig: context.retryConfig,
|
|
121
|
-
retryCodes: context.retryCodes,
|
|
122
|
-
});
|
|
123
|
-
if (!doResult.ok) {
|
|
124
|
-
return haltIterator(doResult);
|
|
125
|
-
}
|
|
126
|
-
const response = doResult.value;
|
|
127
|
-
|
|
128
|
-
const responseFields = {
|
|
129
|
-
HttpMeta: { Response: response, Request: req },
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const [result, raw] = await M.match<
|
|
133
|
-
operations.ArticlesListResponse,
|
|
134
|
-
| errors.HTTPValidationError
|
|
135
|
-
| SDKError
|
|
136
|
-
| SDKValidationError
|
|
137
|
-
| UnexpectedClientError
|
|
138
|
-
| InvalidRequestError
|
|
139
|
-
| RequestAbortedError
|
|
140
|
-
| RequestTimeoutError
|
|
141
|
-
| ConnectionError
|
|
142
|
-
>(
|
|
143
|
-
M.json(200, operations.ArticlesListResponse$inboundSchema, {
|
|
144
|
-
key: "Result",
|
|
145
|
-
}),
|
|
146
|
-
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
147
|
-
M.fail(["4XX", "5XX"]),
|
|
148
|
-
)(response, { extraFields: responseFields });
|
|
149
|
-
if (!result.ok) {
|
|
150
|
-
return haltIterator(result);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const nextFunc = (
|
|
154
|
-
responseData: unknown,
|
|
155
|
-
): {
|
|
156
|
-
next: Paginator<
|
|
157
|
-
Result<
|
|
158
|
-
operations.ArticlesListResponse,
|
|
159
|
-
| errors.HTTPValidationError
|
|
160
|
-
| SDKError
|
|
161
|
-
| SDKValidationError
|
|
162
|
-
| UnexpectedClientError
|
|
163
|
-
| InvalidRequestError
|
|
164
|
-
| RequestAbortedError
|
|
165
|
-
| RequestTimeoutError
|
|
166
|
-
| ConnectionError
|
|
167
|
-
>
|
|
168
|
-
>;
|
|
169
|
-
"~next"?: { page: number };
|
|
170
|
-
} => {
|
|
171
|
-
const page = request?.page || 0;
|
|
172
|
-
const nextPage = page + 1;
|
|
173
|
-
const numPages = dlv(responseData, "pagination.max_page");
|
|
174
|
-
if (numPages == null || numPages <= page) {
|
|
175
|
-
return { next: () => null };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (!responseData) {
|
|
179
|
-
return { next: () => null };
|
|
180
|
-
}
|
|
181
|
-
const results = dlv(responseData, "items");
|
|
182
|
-
if (!Array.isArray(results) || !results.length) {
|
|
183
|
-
return { next: () => null };
|
|
184
|
-
}
|
|
185
|
-
const limit = request?.limit || 0;
|
|
186
|
-
if (results.length < limit) {
|
|
187
|
-
return { next: () => null };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const nextVal = () =>
|
|
191
|
-
articlesList(
|
|
192
|
-
client,
|
|
193
|
-
{
|
|
194
|
-
...request,
|
|
195
|
-
page: nextPage,
|
|
196
|
-
},
|
|
197
|
-
options,
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
return { next: nextVal, "~next": { page: nextPage } };
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const page = { ...result, ...nextFunc(raw) };
|
|
204
|
-
return { ...page, ...createPageIterator(page, (v) => !v.ok) };
|
|
205
|
-
}
|
|
@@ -1,145 +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 { encodeJSON, 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 Preview
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* Send an article preview by email.
|
|
31
|
-
*/
|
|
32
|
-
export async function articlesPreview(
|
|
33
|
-
client: PolarCore,
|
|
34
|
-
request: operations.ArticlesPreviewRequest,
|
|
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.ArticlesPreviewRequest$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.ArticlePreview, { 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}/preview")(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:preview",
|
|
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: "POST",
|
|
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
|
-
any,
|
|
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(202, z.any()),
|
|
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
|
-
}
|