@crevio/sdk 0.4.14 → 0.4.16
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/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/customer.d.ts +1 -0
- package/dist/commonjs/models/customer.d.ts.map +1 -1
- package/dist/commonjs/models/customer.js +2 -0
- package/dist/commonjs/models/customer.js.map +1 -1
- package/dist/commonjs/models/form.d.ts +6 -5
- package/dist/commonjs/models/form.d.ts.map +1 -1
- package/dist/commonjs/models/form.js +8 -7
- package/dist/commonjs/models/form.js.map +1 -1
- package/dist/commonjs/models/formfield.d.ts +16 -0
- package/dist/commonjs/models/formfield.d.ts.map +1 -0
- package/dist/commonjs/models/formfield.js +61 -0
- package/dist/commonjs/models/formfield.js.map +1 -0
- package/dist/commonjs/models/formrequest.d.ts +8 -16
- package/dist/commonjs/models/formrequest.d.ts.map +1 -1
- package/dist/commonjs/models/formrequest.js +6 -14
- package/dist/commonjs/models/formrequest.js.map +1 -1
- package/dist/commonjs/models/formsubmission.d.ts +16 -6
- package/dist/commonjs/models/formsubmission.d.ts.map +1 -1
- package/dist/commonjs/models/formsubmission.js +26 -8
- package/dist/commonjs/models/formsubmission.js.map +1 -1
- package/dist/commonjs/models/formsubmissionrequest.d.ts +17 -12
- package/dist/commonjs/models/formsubmissionrequest.d.ts.map +1 -1
- package/dist/commonjs/models/formsubmissionrequest.js +10 -4
- package/dist/commonjs/models/formsubmissionrequest.js.map +1 -1
- package/dist/commonjs/models/index.d.ts +1 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +1 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/customer.d.ts +1 -0
- package/dist/esm/models/customer.d.ts.map +1 -1
- package/dist/esm/models/customer.js +2 -0
- package/dist/esm/models/customer.js.map +1 -1
- package/dist/esm/models/form.d.ts +6 -5
- package/dist/esm/models/form.d.ts.map +1 -1
- package/dist/esm/models/form.js +6 -5
- package/dist/esm/models/form.js.map +1 -1
- package/dist/esm/models/formfield.d.ts +16 -0
- package/dist/esm/models/formfield.d.ts.map +1 -0
- package/dist/esm/models/formfield.js +24 -0
- package/dist/esm/models/formfield.js.map +1 -0
- package/dist/esm/models/formrequest.d.ts +8 -16
- package/dist/esm/models/formrequest.d.ts.map +1 -1
- package/dist/esm/models/formrequest.js +5 -12
- package/dist/esm/models/formrequest.js.map +1 -1
- package/dist/esm/models/formsubmission.d.ts +16 -6
- package/dist/esm/models/formsubmission.d.ts.map +1 -1
- package/dist/esm/models/formsubmission.js +23 -6
- package/dist/esm/models/formsubmission.js.map +1 -1
- package/dist/esm/models/formsubmissionrequest.d.ts +17 -12
- package/dist/esm/models/formsubmissionrequest.d.ts.map +1 -1
- package/dist/esm/models/formsubmissionrequest.js +8 -3
- package/dist/esm/models/formsubmissionrequest.js.map +1 -1
- package/dist/esm/models/index.d.ts +1 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +1 -0
- package/dist/esm/models/index.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/lib/config.ts +2 -2
- package/src/models/customer.ts +5 -0
- package/src/models/form.ts +12 -11
- package/src/models/formfield.ts +48 -0
- package/src/models/formrequest.ts +13 -37
- package/src/models/formsubmission.ts +45 -13
- package/src/models/formsubmissionrequest.ts +30 -11
- package/src/models/index.ts +1 -0
package/src/models/form.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { safeParse } from "../lib/schemas.js";
|
|
|
8
8
|
import { ClosedEnum } from "../types/enums.js";
|
|
9
9
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
10
10
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
11
|
+
import { FormField, FormField$inboundSchema } from "./formfield.js";
|
|
11
12
|
|
|
12
13
|
export const Purpose = {
|
|
13
14
|
Newsletter: "newsletter",
|
|
@@ -17,7 +18,7 @@ export const Purpose = {
|
|
|
17
18
|
} as const;
|
|
18
19
|
export type Purpose = ClosedEnum<typeof Purpose>;
|
|
19
20
|
|
|
20
|
-
export type
|
|
21
|
+
export type Settings = {};
|
|
21
22
|
|
|
22
23
|
export type Form = {
|
|
23
24
|
id: string;
|
|
@@ -26,12 +27,12 @@ export type Form = {
|
|
|
26
27
|
name: string;
|
|
27
28
|
isPrimary: boolean;
|
|
28
29
|
confirmationRequired: boolean;
|
|
29
|
-
settings:
|
|
30
|
+
settings: Settings;
|
|
30
31
|
tagIds: Array<number>;
|
|
31
32
|
archivedAt: Date | null;
|
|
32
33
|
createdAt: Date;
|
|
33
34
|
updatedAt: Date;
|
|
34
|
-
formFields: Array<
|
|
35
|
+
formFields: Array<FormField>;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
/** @internal */
|
|
@@ -39,19 +40,19 @@ export const Purpose$inboundSchema: z.ZodNativeEnum<typeof Purpose> = z
|
|
|
39
40
|
.nativeEnum(Purpose);
|
|
40
41
|
|
|
41
42
|
/** @internal */
|
|
42
|
-
export const
|
|
43
|
-
|
|
43
|
+
export const Settings$inboundSchema: z.ZodType<
|
|
44
|
+
Settings,
|
|
44
45
|
z.ZodTypeDef,
|
|
45
46
|
unknown
|
|
46
47
|
> = z.object({});
|
|
47
48
|
|
|
48
|
-
export function
|
|
49
|
+
export function settingsFromJSON(
|
|
49
50
|
jsonString: string,
|
|
50
|
-
): SafeParseResult<
|
|
51
|
+
): SafeParseResult<Settings, SDKValidationError> {
|
|
51
52
|
return safeParse(
|
|
52
53
|
jsonString,
|
|
53
|
-
(x) =>
|
|
54
|
-
`Failed to parse '
|
|
54
|
+
(x) => Settings$inboundSchema.parse(JSON.parse(x)),
|
|
55
|
+
`Failed to parse 'Settings' from JSON`,
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -64,7 +65,7 @@ export const Form$inboundSchema: z.ZodType<Form, z.ZodTypeDef, unknown> = z
|
|
|
64
65
|
name: z.string(),
|
|
65
66
|
is_primary: z.boolean(),
|
|
66
67
|
confirmation_required: z.boolean(),
|
|
67
|
-
settings: z.lazy(() =>
|
|
68
|
+
settings: z.lazy(() => Settings$inboundSchema),
|
|
68
69
|
tag_ids: z.array(z.number().int()),
|
|
69
70
|
archived_at: z.nullable(
|
|
70
71
|
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
@@ -75,7 +76,7 @@ export const Form$inboundSchema: z.ZodType<Form, z.ZodTypeDef, unknown> = z
|
|
|
75
76
|
updated_at: z.string().datetime({ offset: true }).transform(v =>
|
|
76
77
|
new Date(v)
|
|
77
78
|
),
|
|
78
|
-
form_fields: z.array(
|
|
79
|
+
form_fields: z.array(FormField$inboundSchema),
|
|
79
80
|
}).transform((v) => {
|
|
80
81
|
return remap$(v, {
|
|
81
82
|
"is_primary": "isPrimary",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export type FormField = {
|
|
12
|
+
id: string;
|
|
13
|
+
object: string;
|
|
14
|
+
name: string;
|
|
15
|
+
fieldType: string;
|
|
16
|
+
required: boolean | null;
|
|
17
|
+
position: number | null;
|
|
18
|
+
options: Array<string>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const FormField$inboundSchema: z.ZodType<
|
|
23
|
+
FormField,
|
|
24
|
+
z.ZodTypeDef,
|
|
25
|
+
unknown
|
|
26
|
+
> = z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
object: z.string(),
|
|
29
|
+
name: z.string(),
|
|
30
|
+
field_type: z.string(),
|
|
31
|
+
required: z.nullable(z.boolean()),
|
|
32
|
+
position: z.nullable(z.number().int()),
|
|
33
|
+
options: z.array(z.string()),
|
|
34
|
+
}).transform((v) => {
|
|
35
|
+
return remap$(v, {
|
|
36
|
+
"field_type": "fieldType",
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export function formFieldFromJSON(
|
|
41
|
+
jsonString: string,
|
|
42
|
+
): SafeParseResult<FormField, SDKValidationError> {
|
|
43
|
+
return safeParse(
|
|
44
|
+
jsonString,
|
|
45
|
+
(x) => FormField$inboundSchema.parse(JSON.parse(x)),
|
|
46
|
+
`Failed to parse 'FormField' from JSON`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -5,43 +5,21 @@
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
6
|
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
7
|
|
|
8
|
-
export type FormRequestSettings = {};
|
|
9
|
-
|
|
10
8
|
export type FormRequest = {
|
|
11
|
-
name?: string |
|
|
12
|
-
isPrimary?: boolean |
|
|
13
|
-
confirmationRequired?: boolean |
|
|
14
|
-
settings?: FormRequestSettings | null | undefined;
|
|
15
|
-
tagIds?: Array<string> | undefined;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
isPrimary?: boolean | undefined;
|
|
11
|
+
confirmationRequired?: boolean | undefined;
|
|
16
12
|
archivedAt?: Date | null | undefined;
|
|
13
|
+
tagIds?: Array<string> | undefined;
|
|
17
14
|
};
|
|
18
15
|
|
|
19
|
-
/** @internal */
|
|
20
|
-
export type FormRequestSettings$Outbound = {};
|
|
21
|
-
|
|
22
|
-
/** @internal */
|
|
23
|
-
export const FormRequestSettings$outboundSchema: z.ZodType<
|
|
24
|
-
FormRequestSettings$Outbound,
|
|
25
|
-
z.ZodTypeDef,
|
|
26
|
-
FormRequestSettings
|
|
27
|
-
> = z.object({});
|
|
28
|
-
|
|
29
|
-
export function formRequestSettingsToJSON(
|
|
30
|
-
formRequestSettings: FormRequestSettings,
|
|
31
|
-
): string {
|
|
32
|
-
return JSON.stringify(
|
|
33
|
-
FormRequestSettings$outboundSchema.parse(formRequestSettings),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
16
|
/** @internal */
|
|
38
17
|
export type FormRequest$Outbound = {
|
|
39
|
-
name?: string |
|
|
40
|
-
is_primary?: boolean |
|
|
41
|
-
confirmation_required?: boolean |
|
|
42
|
-
settings?: FormRequestSettings$Outbound | null | undefined;
|
|
43
|
-
tag_ids?: Array<string> | undefined;
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
is_primary?: boolean | undefined;
|
|
20
|
+
confirmation_required?: boolean | undefined;
|
|
44
21
|
archived_at?: string | null | undefined;
|
|
22
|
+
tag_ids?: Array<string> | undefined;
|
|
45
23
|
};
|
|
46
24
|
|
|
47
25
|
/** @internal */
|
|
@@ -50,19 +28,17 @@ export const FormRequest$outboundSchema: z.ZodType<
|
|
|
50
28
|
z.ZodTypeDef,
|
|
51
29
|
FormRequest
|
|
52
30
|
> = z.object({
|
|
53
|
-
name: z.
|
|
54
|
-
isPrimary: z.
|
|
55
|
-
confirmationRequired: z.
|
|
56
|
-
settings: z.nullable(z.lazy(() => FormRequestSettings$outboundSchema))
|
|
57
|
-
.optional(),
|
|
58
|
-
tagIds: z.array(z.string()).optional(),
|
|
31
|
+
name: z.string().optional(),
|
|
32
|
+
isPrimary: z.boolean().optional(),
|
|
33
|
+
confirmationRequired: z.boolean().optional(),
|
|
59
34
|
archivedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
|
|
35
|
+
tagIds: z.array(z.string()).optional(),
|
|
60
36
|
}).transform((v) => {
|
|
61
37
|
return remap$(v, {
|
|
62
38
|
isPrimary: "is_primary",
|
|
63
39
|
confirmationRequired: "confirmation_required",
|
|
64
|
-
tagIds: "tag_ids",
|
|
65
40
|
archivedAt: "archived_at",
|
|
41
|
+
tagIds: "tag_ids",
|
|
66
42
|
});
|
|
67
43
|
});
|
|
68
44
|
|
|
@@ -8,29 +8,61 @@ import { safeParse } from "../lib/schemas.js";
|
|
|
8
8
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
10
|
|
|
11
|
-
export type
|
|
11
|
+
export type Value = string | Array<string>;
|
|
12
|
+
|
|
13
|
+
export type Answer = {
|
|
14
|
+
fieldType: string;
|
|
15
|
+
label: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
value: string | Array<string> | null;
|
|
18
|
+
options?: Array<string> | undefined;
|
|
19
|
+
};
|
|
12
20
|
|
|
13
21
|
export type FormSubmission = {
|
|
14
22
|
id: string;
|
|
15
23
|
object: string;
|
|
16
|
-
answers:
|
|
24
|
+
answers: Array<Answer>;
|
|
17
25
|
respondentType: string;
|
|
18
26
|
createdAt: Date;
|
|
19
|
-
respondentId:
|
|
20
|
-
formId:
|
|
27
|
+
respondentId: string;
|
|
28
|
+
formId: string;
|
|
21
29
|
};
|
|
22
30
|
|
|
23
31
|
/** @internal */
|
|
24
|
-
export const
|
|
25
|
-
z.
|
|
32
|
+
export const Value$inboundSchema: z.ZodType<Value, z.ZodTypeDef, unknown> = z
|
|
33
|
+
.union([z.string(), z.array(z.string())]);
|
|
34
|
+
|
|
35
|
+
export function valueFromJSON(
|
|
36
|
+
jsonString: string,
|
|
37
|
+
): SafeParseResult<Value, SDKValidationError> {
|
|
38
|
+
return safeParse(
|
|
39
|
+
jsonString,
|
|
40
|
+
(x) => Value$inboundSchema.parse(JSON.parse(x)),
|
|
41
|
+
`Failed to parse 'Value' from JSON`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const Answer$inboundSchema: z.ZodType<Answer, z.ZodTypeDef, unknown> = z
|
|
47
|
+
.object({
|
|
48
|
+
field_type: z.string(),
|
|
49
|
+
label: z.string(),
|
|
50
|
+
required: z.boolean(),
|
|
51
|
+
value: z.nullable(z.union([z.string(), z.array(z.string())])),
|
|
52
|
+
options: z.array(z.string()).optional(),
|
|
53
|
+
}).transform((v) => {
|
|
54
|
+
return remap$(v, {
|
|
55
|
+
"field_type": "fieldType",
|
|
56
|
+
});
|
|
57
|
+
});
|
|
26
58
|
|
|
27
|
-
export function
|
|
59
|
+
export function answerFromJSON(
|
|
28
60
|
jsonString: string,
|
|
29
|
-
): SafeParseResult<
|
|
61
|
+
): SafeParseResult<Answer, SDKValidationError> {
|
|
30
62
|
return safeParse(
|
|
31
63
|
jsonString,
|
|
32
|
-
(x) =>
|
|
33
|
-
`Failed to parse '
|
|
64
|
+
(x) => Answer$inboundSchema.parse(JSON.parse(x)),
|
|
65
|
+
`Failed to parse 'Answer' from JSON`,
|
|
34
66
|
);
|
|
35
67
|
}
|
|
36
68
|
|
|
@@ -42,11 +74,11 @@ export const FormSubmission$inboundSchema: z.ZodType<
|
|
|
42
74
|
> = z.object({
|
|
43
75
|
id: z.string(),
|
|
44
76
|
object: z.string(),
|
|
45
|
-
answers: z.lazy(() =>
|
|
77
|
+
answers: z.array(z.lazy(() => Answer$inboundSchema)),
|
|
46
78
|
respondent_type: z.string(),
|
|
47
79
|
created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
48
|
-
respondent_id: z.
|
|
49
|
-
form_id: z.
|
|
80
|
+
respondent_id: z.string(),
|
|
81
|
+
form_id: z.string(),
|
|
50
82
|
}).transform((v) => {
|
|
51
83
|
return remap$(v, {
|
|
52
84
|
"respondent_type": "respondentType",
|
|
@@ -5,31 +5,50 @@
|
|
|
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
|
+
|
|
8
13
|
export type FormSubmissionRequest = {
|
|
9
14
|
/**
|
|
10
|
-
* ID of the
|
|
15
|
+
* ID of the lead magnet block being submitted
|
|
11
16
|
*/
|
|
12
|
-
|
|
17
|
+
leadMagnetId: string;
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
19
|
+
* Respondent email address
|
|
15
20
|
*/
|
|
16
21
|
email: string;
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
23
|
+
* Respondent name (defaults to 'Lead' if omitted)
|
|
19
24
|
*/
|
|
20
25
|
name?: string | null | undefined;
|
|
21
26
|
/**
|
|
22
|
-
* Map of
|
|
27
|
+
* Map of form question IDs to answer values
|
|
23
28
|
*/
|
|
24
|
-
answers
|
|
29
|
+
answers?: Answers | undefined;
|
|
25
30
|
};
|
|
26
31
|
|
|
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
|
+
|
|
27
46
|
/** @internal */
|
|
28
47
|
export type FormSubmissionRequest$Outbound = {
|
|
29
|
-
|
|
48
|
+
lead_magnet_id: string;
|
|
30
49
|
email: string;
|
|
31
50
|
name?: string | null | undefined;
|
|
32
|
-
answers
|
|
51
|
+
answers?: Answers$Outbound | undefined;
|
|
33
52
|
};
|
|
34
53
|
|
|
35
54
|
/** @internal */
|
|
@@ -38,13 +57,13 @@ export const FormSubmissionRequest$outboundSchema: z.ZodType<
|
|
|
38
57
|
z.ZodTypeDef,
|
|
39
58
|
FormSubmissionRequest
|
|
40
59
|
> = z.object({
|
|
41
|
-
|
|
60
|
+
leadMagnetId: z.string(),
|
|
42
61
|
email: z.string(),
|
|
43
62
|
name: z.nullable(z.string()).optional(),
|
|
44
|
-
answers: z.
|
|
63
|
+
answers: z.lazy(() => Answers$outboundSchema).optional(),
|
|
45
64
|
}).transform((v) => {
|
|
46
65
|
return remap$(v, {
|
|
47
|
-
|
|
66
|
+
leadMagnetId: "lead_magnet_id",
|
|
48
67
|
});
|
|
49
68
|
});
|
|
50
69
|
|
package/src/models/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from "./file.js";
|
|
|
31
31
|
export * from "./filecreateresponse.js";
|
|
32
32
|
export * from "./filerequest.js";
|
|
33
33
|
export * from "./form.js";
|
|
34
|
+
export * from "./formfield.js";
|
|
34
35
|
export * from "./formrequest.js";
|
|
35
36
|
export * from "./formsubmission.js";
|
|
36
37
|
export * from "./formsubmissionrequest.js";
|