@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.
Files changed (192) hide show
  1. package/README.md +10 -7
  2. package/dist/commonjs/funcs/formsArchive.d.ts +19 -0
  3. package/dist/commonjs/funcs/formsArchive.d.ts.map +1 -0
  4. package/dist/commonjs/funcs/formsArchive.js +125 -0
  5. package/dist/commonjs/funcs/formsArchive.js.map +1 -0
  6. package/dist/commonjs/funcs/formsCreate.d.ts +3 -4
  7. package/dist/commonjs/funcs/formsCreate.d.ts.map +1 -1
  8. package/dist/commonjs/funcs/formsCreate.js +7 -14
  9. package/dist/commonjs/funcs/formsCreate.js.map +1 -1
  10. package/dist/commonjs/funcs/formsDelete.d.ts +19 -0
  11. package/dist/commonjs/funcs/formsDelete.d.ts.map +1 -0
  12. package/dist/commonjs/funcs/formsDelete.js +125 -0
  13. package/dist/commonjs/funcs/formsDelete.js.map +1 -0
  14. package/dist/commonjs/funcs/formsList.js +0 -2
  15. package/dist/commonjs/funcs/formsList.js.map +1 -1
  16. package/dist/commonjs/funcs/{subscribersCreate.d.ts → formsRestore.d.ts} +5 -4
  17. package/dist/commonjs/funcs/formsRestore.d.ts.map +1 -0
  18. package/dist/commonjs/funcs/{subscribersCreate.js → formsRestore.js} +18 -12
  19. package/dist/commonjs/funcs/formsRestore.js.map +1 -0
  20. package/dist/commonjs/funcs/formsSubmit.d.ts +19 -0
  21. package/dist/commonjs/funcs/formsSubmit.d.ts.map +1 -0
  22. package/dist/commonjs/funcs/formsSubmit.js +126 -0
  23. package/dist/commonjs/funcs/formsSubmit.js.map +1 -0
  24. package/dist/commonjs/funcs/formsUpdate.d.ts +1 -1
  25. package/dist/commonjs/funcs/formsUpdate.js +1 -1
  26. package/dist/commonjs/lib/config.d.ts +2 -2
  27. package/dist/commonjs/lib/config.js +2 -2
  28. package/dist/commonjs/models/form.d.ts +5 -17
  29. package/dist/commonjs/models/form.d.ts.map +1 -1
  30. package/dist/commonjs/models/form.js +8 -20
  31. package/dist/commonjs/models/form.js.map +1 -1
  32. package/dist/commonjs/models/formfield.d.ts +14 -1
  33. package/dist/commonjs/models/formfield.d.ts.map +1 -1
  34. package/dist/commonjs/models/formfield.js +13 -2
  35. package/dist/commonjs/models/formfield.js.map +1 -1
  36. package/dist/commonjs/models/formrequest.d.ts +63 -4
  37. package/dist/commonjs/models/formrequest.d.ts.map +1 -1
  38. package/dist/commonjs/models/formrequest.js +40 -5
  39. package/dist/commonjs/models/formrequest.js.map +1 -1
  40. package/dist/commonjs/models/formsubmissionrequest.d.ts +12 -17
  41. package/dist/commonjs/models/formsubmissionrequest.d.ts.map +1 -1
  42. package/dist/commonjs/models/formsubmissionrequest.js +4 -10
  43. package/dist/commonjs/models/formsubmissionrequest.js.map +1 -1
  44. package/dist/commonjs/models/index.d.ts +0 -1
  45. package/dist/commonjs/models/index.d.ts.map +1 -1
  46. package/dist/commonjs/models/index.js +0 -1
  47. package/dist/commonjs/models/index.js.map +1 -1
  48. package/dist/commonjs/models/operations/archiveform.d.ts +12 -0
  49. package/dist/commonjs/models/operations/archiveform.d.ts.map +1 -0
  50. package/dist/commonjs/models/{subscriberrequest.js → operations/archiveform.js} +7 -8
  51. package/dist/commonjs/models/operations/archiveform.js.map +1 -0
  52. package/dist/commonjs/models/operations/deleteform.d.ts +12 -0
  53. package/dist/commonjs/models/operations/deleteform.d.ts.map +1 -0
  54. package/dist/commonjs/models/operations/deleteform.js +49 -0
  55. package/dist/commonjs/models/operations/deleteform.js.map +1 -0
  56. package/dist/commonjs/models/operations/index.d.ts +3 -0
  57. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  58. package/dist/commonjs/models/operations/index.js +3 -0
  59. package/dist/commonjs/models/operations/index.js.map +1 -1
  60. package/dist/commonjs/models/operations/listforms.d.ts +0 -14
  61. package/dist/commonjs/models/operations/listforms.d.ts.map +1 -1
  62. package/dist/commonjs/models/operations/listforms.js +1 -13
  63. package/dist/commonjs/models/operations/listforms.js.map +1 -1
  64. package/dist/commonjs/models/operations/restoreform.d.ts +12 -0
  65. package/dist/commonjs/models/operations/restoreform.d.ts.map +1 -0
  66. package/dist/commonjs/models/operations/restoreform.js +49 -0
  67. package/dist/commonjs/models/operations/restoreform.js.map +1 -0
  68. package/dist/commonjs/sdk/forms.d.ts +30 -2
  69. package/dist/commonjs/sdk/forms.d.ts.map +1 -1
  70. package/dist/commonjs/sdk/forms.js +43 -3
  71. package/dist/commonjs/sdk/forms.js.map +1 -1
  72. package/dist/commonjs/sdk/sdk.d.ts +0 -3
  73. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  74. package/dist/commonjs/sdk/sdk.js +0 -4
  75. package/dist/commonjs/sdk/sdk.js.map +1 -1
  76. package/dist/esm/funcs/formsArchive.d.ts +19 -0
  77. package/dist/esm/funcs/formsArchive.d.ts.map +1 -0
  78. package/dist/esm/funcs/formsArchive.js +89 -0
  79. package/dist/esm/funcs/formsArchive.js.map +1 -0
  80. package/dist/esm/funcs/formsCreate.d.ts +3 -4
  81. package/dist/esm/funcs/formsCreate.d.ts.map +1 -1
  82. package/dist/esm/funcs/formsCreate.js +8 -15
  83. package/dist/esm/funcs/formsCreate.js.map +1 -1
  84. package/dist/esm/funcs/formsDelete.d.ts +19 -0
  85. package/dist/esm/funcs/formsDelete.d.ts.map +1 -0
  86. package/dist/esm/funcs/formsDelete.js +89 -0
  87. package/dist/esm/funcs/formsDelete.js.map +1 -0
  88. package/dist/esm/funcs/formsList.js +0 -2
  89. package/dist/esm/funcs/formsList.js.map +1 -1
  90. package/dist/esm/funcs/{subscribersCreate.d.ts → formsRestore.d.ts} +5 -4
  91. package/dist/esm/funcs/formsRestore.d.ts.map +1 -0
  92. package/dist/esm/funcs/{subscribersCreate.js → formsRestore.js} +18 -12
  93. package/dist/esm/funcs/formsRestore.js.map +1 -0
  94. package/dist/esm/funcs/formsSubmit.d.ts +19 -0
  95. package/dist/esm/funcs/formsSubmit.d.ts.map +1 -0
  96. package/dist/esm/funcs/formsSubmit.js +90 -0
  97. package/dist/esm/funcs/formsSubmit.js.map +1 -0
  98. package/dist/esm/funcs/formsUpdate.d.ts +1 -1
  99. package/dist/esm/funcs/formsUpdate.js +1 -1
  100. package/dist/esm/lib/config.d.ts +2 -2
  101. package/dist/esm/lib/config.js +2 -2
  102. package/dist/esm/models/form.d.ts +5 -17
  103. package/dist/esm/models/form.d.ts.map +1 -1
  104. package/dist/esm/models/form.js +6 -18
  105. package/dist/esm/models/form.js.map +1 -1
  106. package/dist/esm/models/formfield.d.ts +14 -1
  107. package/dist/esm/models/formfield.d.ts.map +1 -1
  108. package/dist/esm/models/formfield.js +12 -1
  109. package/dist/esm/models/formfield.js.map +1 -1
  110. package/dist/esm/models/formrequest.d.ts +63 -4
  111. package/dist/esm/models/formrequest.d.ts.map +1 -1
  112. package/dist/esm/models/formrequest.js +37 -4
  113. package/dist/esm/models/formrequest.js.map +1 -1
  114. package/dist/esm/models/formsubmissionrequest.d.ts +12 -17
  115. package/dist/esm/models/formsubmissionrequest.d.ts.map +1 -1
  116. package/dist/esm/models/formsubmissionrequest.js +3 -8
  117. package/dist/esm/models/formsubmissionrequest.js.map +1 -1
  118. package/dist/esm/models/index.d.ts +0 -1
  119. package/dist/esm/models/index.d.ts.map +1 -1
  120. package/dist/esm/models/index.js +0 -1
  121. package/dist/esm/models/index.js.map +1 -1
  122. package/dist/esm/models/operations/archiveform.d.ts +12 -0
  123. package/dist/esm/models/operations/archiveform.d.ts.map +1 -0
  124. package/dist/esm/models/operations/archiveform.js +12 -0
  125. package/dist/esm/models/operations/archiveform.js.map +1 -0
  126. package/dist/esm/models/operations/deleteform.d.ts +12 -0
  127. package/dist/esm/models/operations/deleteform.d.ts.map +1 -0
  128. package/dist/esm/models/operations/deleteform.js +12 -0
  129. package/dist/esm/models/operations/deleteform.js.map +1 -0
  130. package/dist/esm/models/operations/index.d.ts +3 -0
  131. package/dist/esm/models/operations/index.d.ts.map +1 -1
  132. package/dist/esm/models/operations/index.js +3 -0
  133. package/dist/esm/models/operations/index.js.map +1 -1
  134. package/dist/esm/models/operations/listforms.d.ts +0 -14
  135. package/dist/esm/models/operations/listforms.d.ts.map +1 -1
  136. package/dist/esm/models/operations/listforms.js +0 -12
  137. package/dist/esm/models/operations/listforms.js.map +1 -1
  138. package/dist/esm/models/operations/restoreform.d.ts +12 -0
  139. package/dist/esm/models/operations/restoreform.d.ts.map +1 -0
  140. package/dist/esm/models/operations/restoreform.js +12 -0
  141. package/dist/esm/models/operations/restoreform.js.map +1 -0
  142. package/dist/esm/sdk/forms.d.ts +30 -2
  143. package/dist/esm/sdk/forms.d.ts.map +1 -1
  144. package/dist/esm/sdk/forms.js +43 -3
  145. package/dist/esm/sdk/forms.js.map +1 -1
  146. package/dist/esm/sdk/sdk.d.ts +0 -3
  147. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  148. package/dist/esm/sdk/sdk.js +0 -4
  149. package/dist/esm/sdk/sdk.js.map +1 -1
  150. package/jsr.json +1 -1
  151. package/package.json +1 -1
  152. package/src/funcs/formsArchive.ts +178 -0
  153. package/src/funcs/formsCreate.ts +14 -22
  154. package/src/funcs/formsDelete.ts +178 -0
  155. package/src/funcs/formsList.ts +0 -2
  156. package/src/funcs/{subscribersCreate.ts → formsRestore.ts} +23 -17
  157. package/src/funcs/formsSubmit.ts +180 -0
  158. package/src/funcs/formsUpdate.ts +1 -1
  159. package/src/lib/config.ts +2 -2
  160. package/src/models/form.ts +12 -30
  161. package/src/models/formfield.ts +19 -2
  162. package/src/models/formrequest.ts +113 -8
  163. package/src/models/formsubmissionrequest.ts +11 -30
  164. package/src/models/index.ts +0 -1
  165. package/src/models/operations/archiveform.ts +31 -0
  166. package/src/models/operations/deleteform.ts +31 -0
  167. package/src/models/operations/index.ts +3 -0
  168. package/src/models/operations/listforms.ts +0 -20
  169. package/src/models/operations/restoreform.ts +31 -0
  170. package/src/sdk/forms.ts +75 -3
  171. package/src/sdk/sdk.ts +0 -6
  172. package/dist/commonjs/funcs/subscribersCreate.d.ts.map +0 -1
  173. package/dist/commonjs/funcs/subscribersCreate.js.map +0 -1
  174. package/dist/commonjs/models/subscriberrequest.d.ts +0 -20
  175. package/dist/commonjs/models/subscriberrequest.d.ts.map +0 -1
  176. package/dist/commonjs/models/subscriberrequest.js.map +0 -1
  177. package/dist/commonjs/sdk/subscribers.d.ts +0 -12
  178. package/dist/commonjs/sdk/subscribers.d.ts.map +0 -1
  179. package/dist/commonjs/sdk/subscribers.js +0 -22
  180. package/dist/commonjs/sdk/subscribers.js.map +0 -1
  181. package/dist/esm/funcs/subscribersCreate.d.ts.map +0 -1
  182. package/dist/esm/funcs/subscribersCreate.js.map +0 -1
  183. package/dist/esm/models/subscriberrequest.d.ts +0 -20
  184. package/dist/esm/models/subscriberrequest.d.ts.map +0 -1
  185. package/dist/esm/models/subscriberrequest.js +0 -13
  186. package/dist/esm/models/subscriberrequest.js.map +0 -1
  187. package/dist/esm/sdk/subscribers.d.ts +0 -12
  188. package/dist/esm/sdk/subscribers.d.ts.map +0 -1
  189. package/dist/esm/sdk/subscribers.js +0 -18
  190. package/dist/esm/sdk/subscribers.js.map +0 -1
  191. package/src/models/subscriberrequest.ts +0 -40
  192. package/src/sdk/subscribers.ts +0 -27
@@ -0,0 +1,180 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { CrevioCore } from "../core.js";
6
+ import { encodeJSON, 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
+ * Create form submission
32
+ *
33
+ * @remarks
34
+ * Submits an answer set to a specific Form. Customer is upserted by email; lead-magnet purpose forms also trigger delivery.
35
+ */
36
+ export function formsSubmit(
37
+ client: CrevioCore,
38
+ request: operations.CreateFormSubmissionForFormRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ models.FormSubmission,
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.CreateFormSubmissionForFormRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ models.FormSubmission,
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) =>
85
+ operations.CreateFormSubmissionForFormRequest$outboundSchema.parse(value),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = encodeJSON("body", payload.RequestBody, { explode: true });
93
+
94
+ const pathParams = {
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);
101
+
102
+ const headers = new Headers(compactMap({
103
+ "Content-Type": "application/json",
104
+ Accept: "application/json",
105
+ }));
106
+
107
+ const secConfig = await extractSecurity(client._options.apiKey);
108
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
109
+ const requestSecurity = resolveGlobalSecurity(securityInput);
110
+
111
+ const context = {
112
+ options: client._options,
113
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
114
+ operationID: "createFormSubmissionForForm",
115
+ oAuth2Scopes: null,
116
+
117
+ resolvedSecurity: requestSecurity,
118
+
119
+ securitySource: client._options.apiKey,
120
+ retryConfig: options?.retries
121
+ || client._options.retryConfig
122
+ || { strategy: "none" },
123
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
124
+ };
125
+
126
+ const requestRes = client._createRequest(context, {
127
+ security: requestSecurity,
128
+ method: "POST",
129
+ baseURL: options?.serverURL,
130
+ path: path,
131
+ headers: headers,
132
+ body: body,
133
+ userAgent: client._options.userAgent,
134
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
135
+ }, options);
136
+ if (!requestRes.ok) {
137
+ return [requestRes, { status: "invalid" }];
138
+ }
139
+ const req = requestRes.value;
140
+
141
+ const doResult = await client._do(req, {
142
+ context,
143
+ isErrorStatusCode: (statusCode: number) =>
144
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
145
+ retryConfig: context.retryConfig,
146
+ retryCodes: context.retryCodes,
147
+ });
148
+ if (!doResult.ok) {
149
+ return [doResult, { status: "request-error", request: req }];
150
+ }
151
+ const response = doResult.value;
152
+
153
+ const responseFields = {
154
+ HttpMeta: { Response: response, Request: req },
155
+ };
156
+
157
+ const [result] = await M.match<
158
+ models.FormSubmission,
159
+ | errors.ErrorT
160
+ | CrevioError
161
+ | ResponseValidationError
162
+ | ConnectionError
163
+ | RequestAbortedError
164
+ | RequestTimeoutError
165
+ | InvalidRequestError
166
+ | UnexpectedClientError
167
+ | SDKValidationError
168
+ >(
169
+ M.json(201, models.FormSubmission$inboundSchema),
170
+ M.jsonErr([400, 401, 403, 404, 422], errors.ErrorT$inboundSchema),
171
+ M.jsonErr(500, errors.ErrorT$inboundSchema),
172
+ M.fail("4XX"),
173
+ M.fail("5XX"),
174
+ )(response, req, { extraFields: responseFields });
175
+ if (!result.ok) {
176
+ return [result, { status: "complete", request: req, response }];
177
+ }
178
+
179
+ return [result, { status: "complete", request: req, response }];
180
+ }
@@ -31,7 +31,7 @@ import { Result } from "../types/fp.js";
31
31
  * Update form
32
32
  *
33
33
  * @remarks
34
- * Update a Form's name, settings, primary flag, confirmation behavior, or auto-tag list.
34
+ * Update a Form's name, settings, confirmation behavior, or auto-tag list.
35
35
  */
36
36
  export function formsUpdate(
37
37
  client: CrevioCore,
package/src/lib/config.ts CHANGED
@@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
61
61
  export const SDK_METADATA = {
62
62
  language: "typescript",
63
63
  openapiDocVersion: "1.0.0",
64
- sdkVersion: "0.4.16",
64
+ sdkVersion: "0.4.22",
65
65
  genVersion: "2.882.0",
66
- userAgent: "speakeasy-sdk/typescript 0.4.16 2.882.0 1.0.0 @crevio/sdk",
66
+ userAgent: "speakeasy-sdk/typescript 0.4.22 2.882.0 1.0.0 @crevio/sdk",
67
67
  } as const;
@@ -5,54 +5,39 @@
5
5
  import * as z from "zod/v3";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
7
  import { safeParse } from "../lib/schemas.js";
8
- import { ClosedEnum } from "../types/enums.js";
9
8
  import { Result as SafeParseResult } from "../types/fp.js";
10
9
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
11
10
  import { FormField, FormField$inboundSchema } from "./formfield.js";
12
11
 
13
- export const Purpose = {
14
- Newsletter: "newsletter",
15
- Contact: "contact",
16
- LeadMagnet: "lead_magnet",
17
- Custom: "custom",
18
- } as const;
19
- export type Purpose = ClosedEnum<typeof Purpose>;
20
-
21
- export type Settings = {};
12
+ export type FormSettings = {};
22
13
 
23
14
  export type Form = {
24
15
  id: string;
25
16
  object: string;
26
- purpose: Purpose;
27
17
  name: string;
28
- isPrimary: boolean;
29
- confirmationRequired: boolean;
30
- settings: Settings;
18
+ settings: FormSettings;
31
19
  tagIds: Array<number>;
32
20
  archivedAt: Date | null;
33
21
  createdAt: Date;
34
22
  updatedAt: Date;
23
+ confirmationRequired: boolean;
35
24
  formFields: Array<FormField>;
36
25
  };
37
26
 
38
27
  /** @internal */
39
- export const Purpose$inboundSchema: z.ZodNativeEnum<typeof Purpose> = z
40
- .nativeEnum(Purpose);
41
-
42
- /** @internal */
43
- export const Settings$inboundSchema: z.ZodType<
44
- Settings,
28
+ export const FormSettings$inboundSchema: z.ZodType<
29
+ FormSettings,
45
30
  z.ZodTypeDef,
46
31
  unknown
47
32
  > = z.object({});
48
33
 
49
- export function settingsFromJSON(
34
+ export function formSettingsFromJSON(
50
35
  jsonString: string,
51
- ): SafeParseResult<Settings, SDKValidationError> {
36
+ ): SafeParseResult<FormSettings, SDKValidationError> {
52
37
  return safeParse(
53
38
  jsonString,
54
- (x) => Settings$inboundSchema.parse(JSON.parse(x)),
55
- `Failed to parse 'Settings' from JSON`,
39
+ (x) => FormSettings$inboundSchema.parse(JSON.parse(x)),
40
+ `Failed to parse 'FormSettings' from JSON`,
56
41
  );
57
42
  }
58
43
 
@@ -61,11 +46,8 @@ export const Form$inboundSchema: z.ZodType<Form, z.ZodTypeDef, unknown> = z
61
46
  .object({
62
47
  id: z.string(),
63
48
  object: z.string(),
64
- purpose: Purpose$inboundSchema,
65
49
  name: z.string(),
66
- is_primary: z.boolean(),
67
- confirmation_required: z.boolean(),
68
- settings: z.lazy(() => Settings$inboundSchema),
50
+ settings: z.lazy(() => FormSettings$inboundSchema),
69
51
  tag_ids: z.array(z.number().int()),
70
52
  archived_at: z.nullable(
71
53
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
@@ -76,15 +58,15 @@ export const Form$inboundSchema: z.ZodType<Form, z.ZodTypeDef, unknown> = z
76
58
  updated_at: z.string().datetime({ offset: true }).transform(v =>
77
59
  new Date(v)
78
60
  ),
61
+ confirmation_required: z.boolean(),
79
62
  form_fields: z.array(FormField$inboundSchema),
80
63
  }).transform((v) => {
81
64
  return remap$(v, {
82
- "is_primary": "isPrimary",
83
- "confirmation_required": "confirmationRequired",
84
65
  "tag_ids": "tagIds",
85
66
  "archived_at": "archivedAt",
86
67
  "created_at": "createdAt",
87
68
  "updated_at": "updatedAt",
69
+ "confirmation_required": "confirmationRequired",
88
70
  "form_fields": "formFields",
89
71
  });
90
72
  });
@@ -5,19 +5,36 @@
5
5
  import * as z from "zod/v3";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
7
  import { safeParse } from "../lib/schemas.js";
8
+ import { ClosedEnum } from "../types/enums.js";
8
9
  import { Result as SafeParseResult } from "../types/fp.js";
9
10
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
11
 
12
+ export const FormFieldFieldType = {
13
+ Email: "email",
14
+ Text: "text",
15
+ Phone: "phone",
16
+ Textarea: "textarea",
17
+ Radio: "radio",
18
+ Select: "select",
19
+ Checkbox: "checkbox",
20
+ } as const;
21
+ export type FormFieldFieldType = ClosedEnum<typeof FormFieldFieldType>;
22
+
11
23
  export type FormField = {
12
24
  id: string;
13
25
  object: string;
14
26
  name: string;
15
- fieldType: string;
27
+ fieldType: FormFieldFieldType;
16
28
  required: boolean | null;
17
29
  position: number | null;
18
30
  options: Array<string>;
19
31
  };
20
32
 
33
+ /** @internal */
34
+ export const FormFieldFieldType$inboundSchema: z.ZodNativeEnum<
35
+ typeof FormFieldFieldType
36
+ > = z.nativeEnum(FormFieldFieldType);
37
+
21
38
  /** @internal */
22
39
  export const FormField$inboundSchema: z.ZodType<
23
40
  FormField,
@@ -27,7 +44,7 @@ export const FormField$inboundSchema: z.ZodType<
27
44
  id: z.string(),
28
45
  object: z.string(),
29
46
  name: z.string(),
30
- field_type: z.string(),
47
+ field_type: FormFieldFieldType$inboundSchema,
31
48
  required: z.nullable(z.boolean()),
32
49
  position: z.nullable(z.number().int()),
33
50
  options: z.array(z.string()),
@@ -4,22 +4,126 @@
4
4
 
5
5
  import * as z from "zod/v3";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
+ import { ClosedEnum } from "../types/enums.js";
8
+
9
+ export const FormRequestFieldType = {
10
+ Email: "email",
11
+ Text: "text",
12
+ Phone: "phone",
13
+ Textarea: "textarea",
14
+ Radio: "radio",
15
+ Select: "select",
16
+ Checkbox: "checkbox",
17
+ } as const;
18
+ export type FormRequestFieldType = ClosedEnum<typeof FormRequestFieldType>;
19
+
20
+ export type FormFieldsAttribute = {
21
+ /**
22
+ * FormField id (omit when creating)
23
+ */
24
+ id?: number | null | undefined;
25
+ /**
26
+ * User-facing label
27
+ */
28
+ name: string;
29
+ fieldType: FormRequestFieldType;
30
+ required?: boolean | undefined;
31
+ /**
32
+ * Zero-based ordinal
33
+ */
34
+ position?: number | undefined;
35
+ /**
36
+ * Required when field_type is radio/select/checkbox
37
+ */
38
+ options?: Array<string> | undefined;
39
+ /**
40
+ * Set true to remove this field
41
+ */
42
+ destroy?: boolean | undefined;
43
+ };
44
+
45
+ export type FormRequestSettings = {};
7
46
 
8
47
  export type FormRequest = {
9
48
  name?: string | undefined;
10
- isPrimary?: boolean | undefined;
11
- confirmationRequired?: boolean | undefined;
12
49
  archivedAt?: Date | null | undefined;
13
50
  tagIds?: Array<string> | undefined;
51
+ /**
52
+ * Nested-attributes payload for creating, updating, or destroying fields in one round-trip. Pass `id` to update an existing field; pass `_destroy: true` to remove one.
53
+ */
54
+ formFieldsAttributes?: Array<FormFieldsAttribute> | undefined;
55
+ settings?: FormRequestSettings | undefined;
14
56
  };
15
57
 
58
+ /** @internal */
59
+ export const FormRequestFieldType$outboundSchema: z.ZodNativeEnum<
60
+ typeof FormRequestFieldType
61
+ > = z.nativeEnum(FormRequestFieldType);
62
+
63
+ /** @internal */
64
+ export type FormFieldsAttribute$Outbound = {
65
+ id?: number | null | undefined;
66
+ name: string;
67
+ field_type: string;
68
+ required?: boolean | undefined;
69
+ position?: number | undefined;
70
+ options?: Array<string> | undefined;
71
+ _destroy?: boolean | undefined;
72
+ };
73
+
74
+ /** @internal */
75
+ export const FormFieldsAttribute$outboundSchema: z.ZodType<
76
+ FormFieldsAttribute$Outbound,
77
+ z.ZodTypeDef,
78
+ FormFieldsAttribute
79
+ > = z.object({
80
+ id: z.nullable(z.number().int()).optional(),
81
+ name: z.string(),
82
+ fieldType: FormRequestFieldType$outboundSchema,
83
+ required: z.boolean().optional(),
84
+ position: z.number().int().optional(),
85
+ options: z.array(z.string()).optional(),
86
+ destroy: z.boolean().optional(),
87
+ }).transform((v) => {
88
+ return remap$(v, {
89
+ fieldType: "field_type",
90
+ destroy: "_destroy",
91
+ });
92
+ });
93
+
94
+ export function formFieldsAttributeToJSON(
95
+ formFieldsAttribute: FormFieldsAttribute,
96
+ ): string {
97
+ return JSON.stringify(
98
+ FormFieldsAttribute$outboundSchema.parse(formFieldsAttribute),
99
+ );
100
+ }
101
+
102
+ /** @internal */
103
+ export type FormRequestSettings$Outbound = {};
104
+
105
+ /** @internal */
106
+ export const FormRequestSettings$outboundSchema: z.ZodType<
107
+ FormRequestSettings$Outbound,
108
+ z.ZodTypeDef,
109
+ FormRequestSettings
110
+ > = z.object({});
111
+
112
+ export function formRequestSettingsToJSON(
113
+ formRequestSettings: FormRequestSettings,
114
+ ): string {
115
+ return JSON.stringify(
116
+ FormRequestSettings$outboundSchema.parse(formRequestSettings),
117
+ );
118
+ }
119
+
16
120
  /** @internal */
17
121
  export type FormRequest$Outbound = {
18
122
  name?: string | undefined;
19
- is_primary?: boolean | undefined;
20
- confirmation_required?: boolean | undefined;
21
123
  archived_at?: string | null | undefined;
22
124
  tag_ids?: Array<string> | undefined;
125
+ form_fields_attributes?: Array<FormFieldsAttribute$Outbound> | undefined;
126
+ settings?: FormRequestSettings$Outbound | undefined;
23
127
  };
24
128
 
25
129
  /** @internal */
@@ -29,16 +133,17 @@ export const FormRequest$outboundSchema: z.ZodType<
29
133
  FormRequest
30
134
  > = z.object({
31
135
  name: z.string().optional(),
32
- isPrimary: z.boolean().optional(),
33
- confirmationRequired: z.boolean().optional(),
34
136
  archivedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
35
137
  tagIds: z.array(z.string()).optional(),
138
+ formFieldsAttributes: z.array(
139
+ z.lazy(() => FormFieldsAttribute$outboundSchema),
140
+ ).optional(),
141
+ settings: z.lazy(() => FormRequestSettings$outboundSchema).optional(),
36
142
  }).transform((v) => {
37
143
  return remap$(v, {
38
- isPrimary: "is_primary",
39
- confirmationRequired: "confirmation_required",
40
144
  archivedAt: "archived_at",
41
145
  tagIds: "tag_ids",
146
+ formFieldsAttributes: "form_fields_attributes",
42
147
  });
43
148
  });
44
149
 
@@ -5,50 +5,31 @@
5
5
  import * as z from "zod/v3";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
7
 
8
- /**
9
- * Map of form question IDs to answer values
10
- */
11
- export type Answers = {};
12
-
13
8
  export type FormSubmissionRequest = {
14
9
  /**
15
- * ID of the lead magnet block being submitted
10
+ * Form prefix_id being submitted
16
11
  */
17
- leadMagnetId: string;
12
+ formId: string;
18
13
  /**
19
- * Respondent email address
14
+ * Respondent email address. Used to upsert a Customer and, as a convenience, auto-fills the form's email field if no answer is provided for it.
20
15
  */
21
16
  email: string;
22
17
  /**
23
- * Respondent name (defaults to 'Lead' if omitted)
18
+ * Respondent name (defaults to email local-part if omitted). Auto-fills the form's first text field when present and not otherwise supplied via `answers`.
24
19
  */
25
20
  name?: string | null | undefined;
26
21
  /**
27
- * Map of form question IDs to answer values
22
+ * Map of form_field id answer value. Optional for simple email-only forms — pass `{}` and rely on the `email` auto-fill.
28
23
  */
29
- answers?: Answers | undefined;
24
+ answers: { [k: string]: any };
30
25
  };
31
26
 
32
- /** @internal */
33
- export type Answers$Outbound = {};
34
-
35
- /** @internal */
36
- export const Answers$outboundSchema: z.ZodType<
37
- Answers$Outbound,
38
- z.ZodTypeDef,
39
- Answers
40
- > = z.object({});
41
-
42
- export function answersToJSON(answers: Answers): string {
43
- return JSON.stringify(Answers$outboundSchema.parse(answers));
44
- }
45
-
46
27
  /** @internal */
47
28
  export type FormSubmissionRequest$Outbound = {
48
- lead_magnet_id: string;
29
+ form_id: string;
49
30
  email: string;
50
31
  name?: string | null | undefined;
51
- answers?: Answers$Outbound | undefined;
32
+ answers: { [k: string]: any };
52
33
  };
53
34
 
54
35
  /** @internal */
@@ -57,13 +38,13 @@ export const FormSubmissionRequest$outboundSchema: z.ZodType<
57
38
  z.ZodTypeDef,
58
39
  FormSubmissionRequest
59
40
  > = z.object({
60
- leadMagnetId: z.string(),
41
+ formId: z.string(),
61
42
  email: z.string(),
62
43
  name: z.nullable(z.string()).optional(),
63
- answers: z.lazy(() => Answers$outboundSchema).optional(),
44
+ answers: z.record(z.any()),
64
45
  }).transform((v) => {
65
46
  return remap$(v, {
66
- leadMagnetId: "lead_magnet_id",
47
+ formId: "form_id",
67
48
  });
68
49
  });
69
50
 
@@ -80,7 +80,6 @@ export * from "./reviewrequest.js";
80
80
  export * from "./security.js";
81
81
  export * from "./seo.js";
82
82
  export * from "./sociallink.js";
83
- export * from "./subscriberrequest.js";
84
83
  export * from "./subscription.js";
85
84
  export * from "./tag.js";
86
85
  export * from "./tagrequest.js";
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+
7
+ export type ArchiveFormRequest = {
8
+ id: string;
9
+ };
10
+
11
+ /** @internal */
12
+ export type ArchiveFormRequest$Outbound = {
13
+ id: string;
14
+ };
15
+
16
+ /** @internal */
17
+ export const ArchiveFormRequest$outboundSchema: z.ZodType<
18
+ ArchiveFormRequest$Outbound,
19
+ z.ZodTypeDef,
20
+ ArchiveFormRequest
21
+ > = z.object({
22
+ id: z.string(),
23
+ });
24
+
25
+ export function archiveFormRequestToJSON(
26
+ archiveFormRequest: ArchiveFormRequest,
27
+ ): string {
28
+ return JSON.stringify(
29
+ ArchiveFormRequest$outboundSchema.parse(archiveFormRequest),
30
+ );
31
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+
7
+ export type DeleteFormRequest = {
8
+ id: string;
9
+ };
10
+
11
+ /** @internal */
12
+ export type DeleteFormRequest$Outbound = {
13
+ id: string;
14
+ };
15
+
16
+ /** @internal */
17
+ export const DeleteFormRequest$outboundSchema: z.ZodType<
18
+ DeleteFormRequest$Outbound,
19
+ z.ZodTypeDef,
20
+ DeleteFormRequest
21
+ > = z.object({
22
+ id: z.string(),
23
+ });
24
+
25
+ export function deleteFormRequestToJSON(
26
+ deleteFormRequest: DeleteFormRequest,
27
+ ): string {
28
+ return JSON.stringify(
29
+ DeleteFormRequest$outboundSchema.parse(deleteFormRequest),
30
+ );
31
+ }
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  export * from "./addcustomertag.js";
6
+ export * from "./archiveform.js";
6
7
  export * from "./cancelsubscription.js";
7
8
  export * from "./confirmfileupload.js";
8
9
  export * from "./createformsubmissionforform.js";
@@ -11,6 +12,7 @@ export * from "./deletecheckoutlink.js";
11
12
  export * from "./deletecustomer.js";
12
13
  export * from "./deletediscount.js";
13
14
  export * from "./deletefile.js";
15
+ export * from "./deleteform.js";
14
16
  export * from "./deletepricevariant.js";
15
17
  export * from "./deleteproduct.js";
16
18
  export * from "./deletereview.js";
@@ -68,6 +70,7 @@ export * from "./pausesubscription.js";
68
70
  export * from "./positionreview.js";
69
71
  export * from "./removecustomertag.js";
70
72
  export * from "./requestx402access.js";
73
+ export * from "./restoreform.js";
71
74
  export * from "./resumesubscription.js";
72
75
  export * from "./testwebhookendpoint.js";
73
76
  export * from "./updateblogpost.js";