@crevio/sdk 0.4.16 → 0.4.22
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/README.md +10 -7
- package/dist/commonjs/funcs/formsArchive.d.ts +19 -0
- package/dist/commonjs/funcs/formsArchive.d.ts.map +1 -0
- package/dist/commonjs/funcs/formsArchive.js +125 -0
- package/dist/commonjs/funcs/formsArchive.js.map +1 -0
- package/dist/commonjs/funcs/formsCreate.d.ts +3 -4
- package/dist/commonjs/funcs/formsCreate.d.ts.map +1 -1
- package/dist/commonjs/funcs/formsCreate.js +7 -14
- package/dist/commonjs/funcs/formsCreate.js.map +1 -1
- package/dist/commonjs/funcs/formsDelete.d.ts +19 -0
- package/dist/commonjs/funcs/formsDelete.d.ts.map +1 -0
- package/dist/commonjs/funcs/formsDelete.js +125 -0
- package/dist/commonjs/funcs/formsDelete.js.map +1 -0
- package/dist/commonjs/funcs/formsList.js +0 -2
- package/dist/commonjs/funcs/formsList.js.map +1 -1
- package/dist/commonjs/funcs/{subscribersCreate.d.ts → formsRestore.d.ts} +5 -4
- package/dist/commonjs/funcs/formsRestore.d.ts.map +1 -0
- package/dist/commonjs/funcs/{subscribersCreate.js → formsRestore.js} +18 -12
- package/dist/commonjs/funcs/formsRestore.js.map +1 -0
- package/dist/commonjs/funcs/formsSubmit.d.ts +19 -0
- package/dist/commonjs/funcs/formsSubmit.d.ts.map +1 -0
- package/dist/commonjs/funcs/formsSubmit.js +126 -0
- package/dist/commonjs/funcs/formsSubmit.js.map +1 -0
- package/dist/commonjs/funcs/formsUpdate.d.ts +1 -1
- package/dist/commonjs/funcs/formsUpdate.js +1 -1
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/form.d.ts +5 -17
- package/dist/commonjs/models/form.d.ts.map +1 -1
- package/dist/commonjs/models/form.js +8 -20
- package/dist/commonjs/models/form.js.map +1 -1
- package/dist/commonjs/models/formfield.d.ts +14 -1
- package/dist/commonjs/models/formfield.d.ts.map +1 -1
- package/dist/commonjs/models/formfield.js +13 -2
- package/dist/commonjs/models/formfield.js.map +1 -1
- package/dist/commonjs/models/formrequest.d.ts +63 -4
- package/dist/commonjs/models/formrequest.d.ts.map +1 -1
- package/dist/commonjs/models/formrequest.js +40 -5
- package/dist/commonjs/models/formrequest.js.map +1 -1
- package/dist/commonjs/models/formsubmissionrequest.d.ts +12 -17
- package/dist/commonjs/models/formsubmissionrequest.d.ts.map +1 -1
- package/dist/commonjs/models/formsubmissionrequest.js +4 -10
- package/dist/commonjs/models/formsubmissionrequest.js.map +1 -1
- package/dist/commonjs/models/index.d.ts +0 -1
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +0 -1
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/operations/archiveform.d.ts +12 -0
- package/dist/commonjs/models/operations/archiveform.d.ts.map +1 -0
- package/dist/commonjs/models/{subscriberrequest.js → operations/archiveform.js} +7 -8
- package/dist/commonjs/models/operations/archiveform.js.map +1 -0
- package/dist/commonjs/models/operations/deleteform.d.ts +12 -0
- package/dist/commonjs/models/operations/deleteform.d.ts.map +1 -0
- package/dist/commonjs/models/operations/deleteform.js +49 -0
- package/dist/commonjs/models/operations/deleteform.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +3 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +3 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/listforms.d.ts +0 -14
- package/dist/commonjs/models/operations/listforms.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listforms.js +1 -13
- package/dist/commonjs/models/operations/listforms.js.map +1 -1
- package/dist/commonjs/models/operations/restoreform.d.ts +12 -0
- package/dist/commonjs/models/operations/restoreform.d.ts.map +1 -0
- package/dist/commonjs/models/operations/restoreform.js +49 -0
- package/dist/commonjs/models/operations/restoreform.js.map +1 -0
- package/dist/commonjs/sdk/forms.d.ts +30 -2
- package/dist/commonjs/sdk/forms.d.ts.map +1 -1
- package/dist/commonjs/sdk/forms.js +43 -3
- package/dist/commonjs/sdk/forms.js.map +1 -1
- package/dist/commonjs/sdk/sdk.d.ts +0 -3
- package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
- package/dist/commonjs/sdk/sdk.js +0 -4
- package/dist/commonjs/sdk/sdk.js.map +1 -1
- package/dist/esm/funcs/formsArchive.d.ts +19 -0
- package/dist/esm/funcs/formsArchive.d.ts.map +1 -0
- package/dist/esm/funcs/formsArchive.js +89 -0
- package/dist/esm/funcs/formsArchive.js.map +1 -0
- package/dist/esm/funcs/formsCreate.d.ts +3 -4
- package/dist/esm/funcs/formsCreate.d.ts.map +1 -1
- package/dist/esm/funcs/formsCreate.js +8 -15
- package/dist/esm/funcs/formsCreate.js.map +1 -1
- package/dist/esm/funcs/formsDelete.d.ts +19 -0
- package/dist/esm/funcs/formsDelete.d.ts.map +1 -0
- package/dist/esm/funcs/formsDelete.js +89 -0
- package/dist/esm/funcs/formsDelete.js.map +1 -0
- package/dist/esm/funcs/formsList.js +0 -2
- package/dist/esm/funcs/formsList.js.map +1 -1
- package/dist/esm/funcs/{subscribersCreate.d.ts → formsRestore.d.ts} +5 -4
- package/dist/esm/funcs/formsRestore.d.ts.map +1 -0
- package/dist/esm/funcs/{subscribersCreate.js → formsRestore.js} +18 -12
- package/dist/esm/funcs/formsRestore.js.map +1 -0
- package/dist/esm/funcs/formsSubmit.d.ts +19 -0
- package/dist/esm/funcs/formsSubmit.d.ts.map +1 -0
- package/dist/esm/funcs/formsSubmit.js +90 -0
- package/dist/esm/funcs/formsSubmit.js.map +1 -0
- package/dist/esm/funcs/formsUpdate.d.ts +1 -1
- package/dist/esm/funcs/formsUpdate.js +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/form.d.ts +5 -17
- package/dist/esm/models/form.d.ts.map +1 -1
- package/dist/esm/models/form.js +6 -18
- package/dist/esm/models/form.js.map +1 -1
- package/dist/esm/models/formfield.d.ts +14 -1
- package/dist/esm/models/formfield.d.ts.map +1 -1
- package/dist/esm/models/formfield.js +12 -1
- package/dist/esm/models/formfield.js.map +1 -1
- package/dist/esm/models/formrequest.d.ts +63 -4
- package/dist/esm/models/formrequest.d.ts.map +1 -1
- package/dist/esm/models/formrequest.js +37 -4
- package/dist/esm/models/formrequest.js.map +1 -1
- package/dist/esm/models/formsubmissionrequest.d.ts +12 -17
- package/dist/esm/models/formsubmissionrequest.d.ts.map +1 -1
- package/dist/esm/models/formsubmissionrequest.js +3 -8
- package/dist/esm/models/formsubmissionrequest.js.map +1 -1
- package/dist/esm/models/index.d.ts +0 -1
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +0 -1
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/operations/archiveform.d.ts +12 -0
- package/dist/esm/models/operations/archiveform.d.ts.map +1 -0
- package/dist/esm/models/operations/archiveform.js +12 -0
- package/dist/esm/models/operations/archiveform.js.map +1 -0
- package/dist/esm/models/operations/deleteform.d.ts +12 -0
- package/dist/esm/models/operations/deleteform.d.ts.map +1 -0
- package/dist/esm/models/operations/deleteform.js +12 -0
- package/dist/esm/models/operations/deleteform.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +3 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +3 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/listforms.d.ts +0 -14
- package/dist/esm/models/operations/listforms.d.ts.map +1 -1
- package/dist/esm/models/operations/listforms.js +0 -12
- package/dist/esm/models/operations/listforms.js.map +1 -1
- package/dist/esm/models/operations/restoreform.d.ts +12 -0
- package/dist/esm/models/operations/restoreform.d.ts.map +1 -0
- package/dist/esm/models/operations/restoreform.js +12 -0
- package/dist/esm/models/operations/restoreform.js.map +1 -0
- package/dist/esm/sdk/forms.d.ts +30 -2
- package/dist/esm/sdk/forms.d.ts.map +1 -1
- package/dist/esm/sdk/forms.js +43 -3
- package/dist/esm/sdk/forms.js.map +1 -1
- package/dist/esm/sdk/sdk.d.ts +0 -3
- package/dist/esm/sdk/sdk.d.ts.map +1 -1
- package/dist/esm/sdk/sdk.js +0 -4
- package/dist/esm/sdk/sdk.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/formsArchive.ts +178 -0
- package/src/funcs/formsCreate.ts +14 -22
- package/src/funcs/formsDelete.ts +178 -0
- package/src/funcs/formsList.ts +0 -2
- package/src/funcs/{subscribersCreate.ts → formsRestore.ts} +23 -17
- package/src/funcs/formsSubmit.ts +180 -0
- package/src/funcs/formsUpdate.ts +1 -1
- package/src/lib/config.ts +2 -2
- package/src/models/form.ts +12 -30
- package/src/models/formfield.ts +19 -2
- package/src/models/formrequest.ts +113 -8
- package/src/models/formsubmissionrequest.ts +11 -30
- package/src/models/index.ts +0 -1
- package/src/models/operations/archiveform.ts +31 -0
- package/src/models/operations/deleteform.ts +31 -0
- package/src/models/operations/index.ts +3 -0
- package/src/models/operations/listforms.ts +0 -20
- package/src/models/operations/restoreform.ts +31 -0
- package/src/sdk/forms.ts +75 -3
- package/src/sdk/sdk.ts +0 -6
- package/dist/commonjs/funcs/subscribersCreate.d.ts.map +0 -1
- package/dist/commonjs/funcs/subscribersCreate.js.map +0 -1
- package/dist/commonjs/models/subscriberrequest.d.ts +0 -20
- package/dist/commonjs/models/subscriberrequest.d.ts.map +0 -1
- package/dist/commonjs/models/subscriberrequest.js.map +0 -1
- package/dist/commonjs/sdk/subscribers.d.ts +0 -12
- package/dist/commonjs/sdk/subscribers.d.ts.map +0 -1
- package/dist/commonjs/sdk/subscribers.js +0 -22
- package/dist/commonjs/sdk/subscribers.js.map +0 -1
- package/dist/esm/funcs/subscribersCreate.d.ts.map +0 -1
- package/dist/esm/funcs/subscribersCreate.js.map +0 -1
- package/dist/esm/models/subscriberrequest.d.ts +0 -20
- package/dist/esm/models/subscriberrequest.d.ts.map +0 -1
- package/dist/esm/models/subscriberrequest.js +0 -13
- package/dist/esm/models/subscriberrequest.js.map +0 -1
- package/dist/esm/sdk/subscribers.d.ts +0 -12
- package/dist/esm/sdk/subscribers.d.ts.map +0 -1
- package/dist/esm/sdk/subscribers.js +0 -18
- package/dist/esm/sdk/subscribers.js.map +0 -1
- package/src/models/subscriberrequest.ts +0 -40
- package/src/sdk/subscribers.ts +0 -27
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CrevioCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import { CrevioError } from "../models/errors/crevioerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as models from "../models/index.js";
|
|
26
|
+
import * as operations from "../models/operations/index.js";
|
|
27
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
28
|
+
import { Result } from "../types/fp.js";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Archive form
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Soft-deletes a Form by setting archived_at. The form stops appearing in the active list but its fields and submissions are preserved. Idempotent.
|
|
35
|
+
*/
|
|
36
|
+
export function formsArchive(
|
|
37
|
+
client: CrevioCore,
|
|
38
|
+
request: operations.ArchiveFormRequest,
|
|
39
|
+
options?: RequestOptions,
|
|
40
|
+
): APIPromise<
|
|
41
|
+
Result<
|
|
42
|
+
models.Form,
|
|
43
|
+
| errors.ErrorT
|
|
44
|
+
| CrevioError
|
|
45
|
+
| ResponseValidationError
|
|
46
|
+
| ConnectionError
|
|
47
|
+
| RequestAbortedError
|
|
48
|
+
| RequestTimeoutError
|
|
49
|
+
| InvalidRequestError
|
|
50
|
+
| UnexpectedClientError
|
|
51
|
+
| SDKValidationError
|
|
52
|
+
>
|
|
53
|
+
> {
|
|
54
|
+
return new APIPromise($do(
|
|
55
|
+
client,
|
|
56
|
+
request,
|
|
57
|
+
options,
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function $do(
|
|
62
|
+
client: CrevioCore,
|
|
63
|
+
request: operations.ArchiveFormRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
models.Form,
|
|
69
|
+
| errors.ErrorT
|
|
70
|
+
| CrevioError
|
|
71
|
+
| ResponseValidationError
|
|
72
|
+
| ConnectionError
|
|
73
|
+
| RequestAbortedError
|
|
74
|
+
| RequestTimeoutError
|
|
75
|
+
| InvalidRequestError
|
|
76
|
+
| UnexpectedClientError
|
|
77
|
+
| SDKValidationError
|
|
78
|
+
>,
|
|
79
|
+
APICall,
|
|
80
|
+
]
|
|
81
|
+
> {
|
|
82
|
+
const parsed = safeParse(
|
|
83
|
+
request,
|
|
84
|
+
(value) => operations.ArchiveFormRequest$outboundSchema.parse(value),
|
|
85
|
+
"Input validation failed",
|
|
86
|
+
);
|
|
87
|
+
if (!parsed.ok) {
|
|
88
|
+
return [parsed, { status: "invalid" }];
|
|
89
|
+
}
|
|
90
|
+
const payload = parsed.value;
|
|
91
|
+
const body = null;
|
|
92
|
+
|
|
93
|
+
const pathParams = {
|
|
94
|
+
id: encodeSimple("id", payload.id, {
|
|
95
|
+
explode: false,
|
|
96
|
+
charEncoding: "percent",
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
const path = pathToFunc("/forms/{id}/archive")(pathParams);
|
|
100
|
+
|
|
101
|
+
const headers = new Headers(compactMap({
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
106
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
107
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
108
|
+
|
|
109
|
+
const context = {
|
|
110
|
+
options: client._options,
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "archiveForm",
|
|
113
|
+
oAuth2Scopes: null,
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.apiKey,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "PATCH",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
body: body,
|
|
131
|
+
userAgent: client._options.userAgent,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
isErrorStatusCode: (statusCode: number) =>
|
|
142
|
+
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
143
|
+
retryConfig: context.retryConfig,
|
|
144
|
+
retryCodes: context.retryCodes,
|
|
145
|
+
});
|
|
146
|
+
if (!doResult.ok) {
|
|
147
|
+
return [doResult, { status: "request-error", request: req }];
|
|
148
|
+
}
|
|
149
|
+
const response = doResult.value;
|
|
150
|
+
|
|
151
|
+
const responseFields = {
|
|
152
|
+
HttpMeta: { Response: response, Request: req },
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const [result] = await M.match<
|
|
156
|
+
models.Form,
|
|
157
|
+
| errors.ErrorT
|
|
158
|
+
| CrevioError
|
|
159
|
+
| ResponseValidationError
|
|
160
|
+
| ConnectionError
|
|
161
|
+
| RequestAbortedError
|
|
162
|
+
| RequestTimeoutError
|
|
163
|
+
| InvalidRequestError
|
|
164
|
+
| UnexpectedClientError
|
|
165
|
+
| SDKValidationError
|
|
166
|
+
>(
|
|
167
|
+
M.json(200, models.Form$inboundSchema),
|
|
168
|
+
M.jsonErr([401, 403, 404, 422], errors.ErrorT$inboundSchema),
|
|
169
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
170
|
+
M.fail("4XX"),
|
|
171
|
+
M.fail("5XX"),
|
|
172
|
+
)(response, req, { extraFields: responseFields });
|
|
173
|
+
if (!result.ok) {
|
|
174
|
+
return [result, { status: "complete", request: req, response }];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return [result, { status: "complete", request: req, response }];
|
|
178
|
+
}
|
package/src/funcs/formsCreate.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { CrevioCore } from "../core.js";
|
|
6
|
-
import { encodeJSON
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
8
8
|
import * as M from "../lib/matchers.js";
|
|
9
9
|
import { compactMap } from "../lib/primitives.js";
|
|
@@ -23,23 +23,22 @@ import * as errors from "../models/errors/index.js";
|
|
|
23
23
|
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
24
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
25
|
import * as models from "../models/index.js";
|
|
26
|
-
import * as operations from "../models/operations/index.js";
|
|
27
26
|
import { APICall, APIPromise } from "../types/async.js";
|
|
28
27
|
import { Result } from "../types/fp.js";
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
|
-
* Create form
|
|
30
|
+
* Create form
|
|
32
31
|
*
|
|
33
32
|
* @remarks
|
|
34
|
-
*
|
|
33
|
+
* Creates a new Form, optionally with fields nested via form_fields_attributes. Use this to provision newsletter, contact, lead-magnet, or custom-purpose forms programmatically.
|
|
35
34
|
*/
|
|
36
35
|
export function formsCreate(
|
|
37
36
|
client: CrevioCore,
|
|
38
|
-
request:
|
|
37
|
+
request: models.FormRequest,
|
|
39
38
|
options?: RequestOptions,
|
|
40
39
|
): APIPromise<
|
|
41
40
|
Result<
|
|
42
|
-
models.
|
|
41
|
+
models.Form,
|
|
43
42
|
| errors.ErrorT
|
|
44
43
|
| CrevioError
|
|
45
44
|
| ResponseValidationError
|
|
@@ -60,12 +59,12 @@ export function formsCreate(
|
|
|
60
59
|
|
|
61
60
|
async function $do(
|
|
62
61
|
client: CrevioCore,
|
|
63
|
-
request:
|
|
62
|
+
request: models.FormRequest,
|
|
64
63
|
options?: RequestOptions,
|
|
65
64
|
): Promise<
|
|
66
65
|
[
|
|
67
66
|
Result<
|
|
68
|
-
models.
|
|
67
|
+
models.Form,
|
|
69
68
|
| errors.ErrorT
|
|
70
69
|
| CrevioError
|
|
71
70
|
| ResponseValidationError
|
|
@@ -81,23 +80,16 @@ async function $do(
|
|
|
81
80
|
> {
|
|
82
81
|
const parsed = safeParse(
|
|
83
82
|
request,
|
|
84
|
-
(value) =>
|
|
85
|
-
operations.CreateFormSubmissionForFormRequest$outboundSchema.parse(value),
|
|
83
|
+
(value) => models.FormRequest$outboundSchema.parse(value),
|
|
86
84
|
"Input validation failed",
|
|
87
85
|
);
|
|
88
86
|
if (!parsed.ok) {
|
|
89
87
|
return [parsed, { status: "invalid" }];
|
|
90
88
|
}
|
|
91
89
|
const payload = parsed.value;
|
|
92
|
-
const body = encodeJSON("body", payload
|
|
90
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
93
91
|
|
|
94
|
-
const
|
|
95
|
-
form_id: encodeSimple("form_id", payload.form_id, {
|
|
96
|
-
explode: false,
|
|
97
|
-
charEncoding: "percent",
|
|
98
|
-
}),
|
|
99
|
-
};
|
|
100
|
-
const path = pathToFunc("/forms/{form_id}/submissions")(pathParams);
|
|
92
|
+
const path = pathToFunc("/forms")();
|
|
101
93
|
|
|
102
94
|
const headers = new Headers(compactMap({
|
|
103
95
|
"Content-Type": "application/json",
|
|
@@ -111,7 +103,7 @@ async function $do(
|
|
|
111
103
|
const context = {
|
|
112
104
|
options: client._options,
|
|
113
105
|
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
114
|
-
operationID: "
|
|
106
|
+
operationID: "createForm",
|
|
115
107
|
oAuth2Scopes: null,
|
|
116
108
|
|
|
117
109
|
resolvedSecurity: requestSecurity,
|
|
@@ -155,7 +147,7 @@ async function $do(
|
|
|
155
147
|
};
|
|
156
148
|
|
|
157
149
|
const [result] = await M.match<
|
|
158
|
-
models.
|
|
150
|
+
models.Form,
|
|
159
151
|
| errors.ErrorT
|
|
160
152
|
| CrevioError
|
|
161
153
|
| ResponseValidationError
|
|
@@ -166,8 +158,8 @@ async function $do(
|
|
|
166
158
|
| UnexpectedClientError
|
|
167
159
|
| SDKValidationError
|
|
168
160
|
>(
|
|
169
|
-
M.json(201, models.
|
|
170
|
-
M.jsonErr([400, 401, 403,
|
|
161
|
+
M.json(201, models.Form$inboundSchema),
|
|
162
|
+
M.jsonErr([400, 401, 403, 422], errors.ErrorT$inboundSchema),
|
|
171
163
|
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
172
164
|
M.fail("4XX"),
|
|
173
165
|
M.fail("5XX"),
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CrevioCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import { CrevioError } from "../models/errors/crevioerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as models from "../models/index.js";
|
|
26
|
+
import * as operations from "../models/operations/index.js";
|
|
27
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
28
|
+
import { Result } from "../types/fp.js";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Delete form
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Permanently deletes a Form. Refuses with a 422 if the form has submissions — archive it instead via PATCH /forms/{id}/archive to preserve them.
|
|
35
|
+
*/
|
|
36
|
+
export function formsDelete(
|
|
37
|
+
client: CrevioCore,
|
|
38
|
+
request: operations.DeleteFormRequest,
|
|
39
|
+
options?: RequestOptions,
|
|
40
|
+
): APIPromise<
|
|
41
|
+
Result<
|
|
42
|
+
models.Form,
|
|
43
|
+
| errors.ErrorT
|
|
44
|
+
| CrevioError
|
|
45
|
+
| ResponseValidationError
|
|
46
|
+
| ConnectionError
|
|
47
|
+
| RequestAbortedError
|
|
48
|
+
| RequestTimeoutError
|
|
49
|
+
| InvalidRequestError
|
|
50
|
+
| UnexpectedClientError
|
|
51
|
+
| SDKValidationError
|
|
52
|
+
>
|
|
53
|
+
> {
|
|
54
|
+
return new APIPromise($do(
|
|
55
|
+
client,
|
|
56
|
+
request,
|
|
57
|
+
options,
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function $do(
|
|
62
|
+
client: CrevioCore,
|
|
63
|
+
request: operations.DeleteFormRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
models.Form,
|
|
69
|
+
| errors.ErrorT
|
|
70
|
+
| CrevioError
|
|
71
|
+
| ResponseValidationError
|
|
72
|
+
| ConnectionError
|
|
73
|
+
| RequestAbortedError
|
|
74
|
+
| RequestTimeoutError
|
|
75
|
+
| InvalidRequestError
|
|
76
|
+
| UnexpectedClientError
|
|
77
|
+
| SDKValidationError
|
|
78
|
+
>,
|
|
79
|
+
APICall,
|
|
80
|
+
]
|
|
81
|
+
> {
|
|
82
|
+
const parsed = safeParse(
|
|
83
|
+
request,
|
|
84
|
+
(value) => operations.DeleteFormRequest$outboundSchema.parse(value),
|
|
85
|
+
"Input validation failed",
|
|
86
|
+
);
|
|
87
|
+
if (!parsed.ok) {
|
|
88
|
+
return [parsed, { status: "invalid" }];
|
|
89
|
+
}
|
|
90
|
+
const payload = parsed.value;
|
|
91
|
+
const body = null;
|
|
92
|
+
|
|
93
|
+
const pathParams = {
|
|
94
|
+
id: encodeSimple("id", payload.id, {
|
|
95
|
+
explode: false,
|
|
96
|
+
charEncoding: "percent",
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
const path = pathToFunc("/forms/{id}")(pathParams);
|
|
100
|
+
|
|
101
|
+
const headers = new Headers(compactMap({
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
106
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
107
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
108
|
+
|
|
109
|
+
const context = {
|
|
110
|
+
options: client._options,
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "deleteForm",
|
|
113
|
+
oAuth2Scopes: null,
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.apiKey,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "DELETE",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
body: body,
|
|
131
|
+
userAgent: client._options.userAgent,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
isErrorStatusCode: (statusCode: number) =>
|
|
142
|
+
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
143
|
+
retryConfig: context.retryConfig,
|
|
144
|
+
retryCodes: context.retryCodes,
|
|
145
|
+
});
|
|
146
|
+
if (!doResult.ok) {
|
|
147
|
+
return [doResult, { status: "request-error", request: req }];
|
|
148
|
+
}
|
|
149
|
+
const response = doResult.value;
|
|
150
|
+
|
|
151
|
+
const responseFields = {
|
|
152
|
+
HttpMeta: { Response: response, Request: req },
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const [result] = await M.match<
|
|
156
|
+
models.Form,
|
|
157
|
+
| errors.ErrorT
|
|
158
|
+
| CrevioError
|
|
159
|
+
| ResponseValidationError
|
|
160
|
+
| ConnectionError
|
|
161
|
+
| RequestAbortedError
|
|
162
|
+
| RequestTimeoutError
|
|
163
|
+
| InvalidRequestError
|
|
164
|
+
| UnexpectedClientError
|
|
165
|
+
| SDKValidationError
|
|
166
|
+
>(
|
|
167
|
+
M.json(200, models.Form$inboundSchema),
|
|
168
|
+
M.jsonErr([401, 403, 404, 422], errors.ErrorT$inboundSchema),
|
|
169
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
170
|
+
M.fail("4XX"),
|
|
171
|
+
M.fail("5XX"),
|
|
172
|
+
)(response, req, { extraFields: responseFields });
|
|
173
|
+
if (!result.ok) {
|
|
174
|
+
return [result, { status: "complete", request: req, response }];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return [result, { status: "complete", request: req, response }];
|
|
178
|
+
}
|
package/src/funcs/formsList.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { CrevioCore } from "../core.js";
|
|
6
|
-
import {
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
8
8
|
import * as M from "../lib/matchers.js";
|
|
9
9
|
import { compactMap } from "../lib/primitives.js";
|
|
@@ -23,22 +23,23 @@ import * as errors from "../models/errors/index.js";
|
|
|
23
23
|
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
24
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
25
|
import * as models from "../models/index.js";
|
|
26
|
+
import * as operations from "../models/operations/index.js";
|
|
26
27
|
import { APICall, APIPromise } from "../types/async.js";
|
|
27
28
|
import { Result } from "../types/fp.js";
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Restore form
|
|
31
32
|
*
|
|
32
33
|
* @remarks
|
|
33
|
-
*
|
|
34
|
+
* Unarchives a previously archived Form so it appears in the active list again. Idempotent.
|
|
34
35
|
*/
|
|
35
|
-
export function
|
|
36
|
+
export function formsRestore(
|
|
36
37
|
client: CrevioCore,
|
|
37
|
-
request:
|
|
38
|
+
request: operations.RestoreFormRequest,
|
|
38
39
|
options?: RequestOptions,
|
|
39
40
|
): APIPromise<
|
|
40
41
|
Result<
|
|
41
|
-
models.
|
|
42
|
+
models.Form,
|
|
42
43
|
| errors.ErrorT
|
|
43
44
|
| CrevioError
|
|
44
45
|
| ResponseValidationError
|
|
@@ -59,12 +60,12 @@ export function subscribersCreate(
|
|
|
59
60
|
|
|
60
61
|
async function $do(
|
|
61
62
|
client: CrevioCore,
|
|
62
|
-
request:
|
|
63
|
+
request: operations.RestoreFormRequest,
|
|
63
64
|
options?: RequestOptions,
|
|
64
65
|
): Promise<
|
|
65
66
|
[
|
|
66
67
|
Result<
|
|
67
|
-
models.
|
|
68
|
+
models.Form,
|
|
68
69
|
| errors.ErrorT
|
|
69
70
|
| CrevioError
|
|
70
71
|
| ResponseValidationError
|
|
@@ -80,19 +81,24 @@ async function $do(
|
|
|
80
81
|
> {
|
|
81
82
|
const parsed = safeParse(
|
|
82
83
|
request,
|
|
83
|
-
(value) =>
|
|
84
|
+
(value) => operations.RestoreFormRequest$outboundSchema.parse(value),
|
|
84
85
|
"Input validation failed",
|
|
85
86
|
);
|
|
86
87
|
if (!parsed.ok) {
|
|
87
88
|
return [parsed, { status: "invalid" }];
|
|
88
89
|
}
|
|
89
90
|
const payload = parsed.value;
|
|
90
|
-
const body =
|
|
91
|
+
const body = null;
|
|
91
92
|
|
|
92
|
-
const
|
|
93
|
+
const pathParams = {
|
|
94
|
+
id: encodeSimple("id", payload.id, {
|
|
95
|
+
explode: false,
|
|
96
|
+
charEncoding: "percent",
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
const path = pathToFunc("/forms/{id}/restore")(pathParams);
|
|
93
100
|
|
|
94
101
|
const headers = new Headers(compactMap({
|
|
95
|
-
"Content-Type": "application/json",
|
|
96
102
|
Accept: "application/json",
|
|
97
103
|
}));
|
|
98
104
|
|
|
@@ -103,7 +109,7 @@ async function $do(
|
|
|
103
109
|
const context = {
|
|
104
110
|
options: client._options,
|
|
105
111
|
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
106
|
-
operationID: "
|
|
112
|
+
operationID: "restoreForm",
|
|
107
113
|
oAuth2Scopes: null,
|
|
108
114
|
|
|
109
115
|
resolvedSecurity: requestSecurity,
|
|
@@ -117,7 +123,7 @@ async function $do(
|
|
|
117
123
|
|
|
118
124
|
const requestRes = client._createRequest(context, {
|
|
119
125
|
security: requestSecurity,
|
|
120
|
-
method: "
|
|
126
|
+
method: "PATCH",
|
|
121
127
|
baseURL: options?.serverURL,
|
|
122
128
|
path: path,
|
|
123
129
|
headers: headers,
|
|
@@ -147,7 +153,7 @@ async function $do(
|
|
|
147
153
|
};
|
|
148
154
|
|
|
149
155
|
const [result] = await M.match<
|
|
150
|
-
models.
|
|
156
|
+
models.Form,
|
|
151
157
|
| errors.ErrorT
|
|
152
158
|
| CrevioError
|
|
153
159
|
| ResponseValidationError
|
|
@@ -158,8 +164,8 @@ async function $do(
|
|
|
158
164
|
| UnexpectedClientError
|
|
159
165
|
| SDKValidationError
|
|
160
166
|
>(
|
|
161
|
-
M.json(
|
|
162
|
-
M.jsonErr([
|
|
167
|
+
M.json(200, models.Form$inboundSchema),
|
|
168
|
+
M.jsonErr([401, 403, 404, 422], errors.ErrorT$inboundSchema),
|
|
163
169
|
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
164
170
|
M.fail("4XX"),
|
|
165
171
|
M.fail("5XX"),
|