@quiverai/sdk 0.4.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +1 -1
  2. package/dist/commonjs/lib/config.d.ts +2 -2
  3. package/dist/commonjs/lib/config.js +2 -2
  4. package/dist/commonjs/sdk/models/shared/generatesvgrequest.d.ts +6 -3
  5. package/dist/commonjs/sdk/models/shared/generatesvgrequest.d.ts.map +1 -1
  6. package/dist/commonjs/sdk/models/shared/generatesvgrequest.js +2 -2
  7. package/dist/commonjs/sdk/models/shared/generatesvgrequest.js.map +1 -1
  8. package/dist/commonjs/sdk/models/shared/imageinputreferenceinput.d.ts +10 -0
  9. package/dist/commonjs/sdk/models/shared/imageinputreferenceinput.d.ts.map +1 -0
  10. package/dist/commonjs/sdk/models/shared/imageinputreferenceinput.js +53 -0
  11. package/dist/commonjs/sdk/models/shared/imageinputreferenceinput.js.map +1 -0
  12. package/dist/commonjs/sdk/models/shared/index.d.ts +5 -0
  13. package/dist/commonjs/sdk/models/shared/index.d.ts.map +1 -1
  14. package/dist/commonjs/sdk/models/shared/index.js +5 -0
  15. package/dist/commonjs/sdk/models/shared/index.js.map +1 -1
  16. package/dist/commonjs/sdk/models/shared/model.d.ts +30 -2
  17. package/dist/commonjs/sdk/models/shared/model.d.ts.map +1 -1
  18. package/dist/commonjs/sdk/models/shared/model.js +17 -1
  19. package/dist/commonjs/sdk/models/shared/model.js.map +1 -1
  20. package/dist/commonjs/sdk/models/shared/svgcontenteventdata.d.ts +40 -0
  21. package/dist/commonjs/sdk/models/shared/svgcontenteventdata.d.ts.map +1 -0
  22. package/dist/commonjs/sdk/models/shared/svgcontenteventdata.js +57 -0
  23. package/dist/commonjs/sdk/models/shared/svgcontenteventdata.js.map +1 -0
  24. package/dist/commonjs/sdk/models/shared/svgdrafteventdata.d.ts +36 -0
  25. package/dist/commonjs/sdk/models/shared/svgdrafteventdata.d.ts.map +1 -0
  26. package/dist/commonjs/sdk/models/shared/svgdrafteventdata.js +56 -0
  27. package/dist/commonjs/sdk/models/shared/svgdrafteventdata.js.map +1 -0
  28. package/dist/commonjs/sdk/models/shared/svggeneratingeventdata.d.ts +36 -0
  29. package/dist/commonjs/sdk/models/shared/svggeneratingeventdata.d.ts.map +1 -0
  30. package/dist/commonjs/sdk/models/shared/svggeneratingeventdata.js +56 -0
  31. package/dist/commonjs/sdk/models/shared/svggeneratingeventdata.js.map +1 -0
  32. package/dist/commonjs/sdk/models/shared/svgreasoningeventdata.d.ts +36 -0
  33. package/dist/commonjs/sdk/models/shared/svgreasoningeventdata.d.ts.map +1 -0
  34. package/dist/commonjs/sdk/models/shared/svgreasoningeventdata.js +56 -0
  35. package/dist/commonjs/sdk/models/shared/svgreasoningeventdata.js.map +1 -0
  36. package/dist/commonjs/sdk/models/shared/svgresponse.d.ts +9 -0
  37. package/dist/commonjs/sdk/models/shared/svgresponse.d.ts.map +1 -1
  38. package/dist/commonjs/sdk/models/shared/svgresponse.js +1 -0
  39. package/dist/commonjs/sdk/models/shared/svgresponse.js.map +1 -1
  40. package/dist/commonjs/sdk/models/shared/svgstreamevent.d.ts +73 -18
  41. package/dist/commonjs/sdk/models/shared/svgstreamevent.d.ts.map +1 -1
  42. package/dist/commonjs/sdk/models/shared/svgstreamevent.js +74 -12
  43. package/dist/commonjs/sdk/models/shared/svgstreamevent.js.map +1 -1
  44. package/dist/commonjs/sdk/models/shared/svgstreameventdata.d.ts +6 -37
  45. package/dist/commonjs/sdk/models/shared/svgstreameventdata.d.ts.map +1 -1
  46. package/dist/commonjs/sdk/models/shared/svgstreameventdata.js +11 -20
  47. package/dist/commonjs/sdk/models/shared/svgstreameventdata.js.map +1 -1
  48. package/dist/commonjs/sdk/models/shared/svgusage.d.ts +20 -0
  49. package/dist/commonjs/sdk/models/shared/svgusage.d.ts.map +1 -1
  50. package/dist/commonjs/sdk/models/shared/svgusage.js.map +1 -1
  51. package/dist/esm/lib/config.d.ts +2 -2
  52. package/dist/esm/lib/config.js +2 -2
  53. package/dist/esm/sdk/models/shared/generatesvgrequest.d.ts +6 -3
  54. package/dist/esm/sdk/models/shared/generatesvgrequest.d.ts.map +1 -1
  55. package/dist/esm/sdk/models/shared/generatesvgrequest.js +2 -2
  56. package/dist/esm/sdk/models/shared/generatesvgrequest.js.map +1 -1
  57. package/dist/esm/sdk/models/shared/imageinputreferenceinput.d.ts +10 -0
  58. package/dist/esm/sdk/models/shared/imageinputreferenceinput.d.ts.map +1 -0
  59. package/dist/esm/sdk/models/shared/imageinputreferenceinput.js +16 -0
  60. package/dist/esm/sdk/models/shared/imageinputreferenceinput.js.map +1 -0
  61. package/dist/esm/sdk/models/shared/index.d.ts +5 -0
  62. package/dist/esm/sdk/models/shared/index.d.ts.map +1 -1
  63. package/dist/esm/sdk/models/shared/index.js +5 -0
  64. package/dist/esm/sdk/models/shared/index.js.map +1 -1
  65. package/dist/esm/sdk/models/shared/model.d.ts +30 -2
  66. package/dist/esm/sdk/models/shared/model.d.ts.map +1 -1
  67. package/dist/esm/sdk/models/shared/model.js +15 -0
  68. package/dist/esm/sdk/models/shared/model.js.map +1 -1
  69. package/dist/esm/sdk/models/shared/svgcontenteventdata.d.ts +40 -0
  70. package/dist/esm/sdk/models/shared/svgcontenteventdata.d.ts.map +1 -0
  71. package/dist/esm/sdk/models/shared/svgcontenteventdata.js +20 -0
  72. package/dist/esm/sdk/models/shared/svgcontenteventdata.js.map +1 -0
  73. package/dist/esm/sdk/models/shared/svgdrafteventdata.d.ts +36 -0
  74. package/dist/esm/sdk/models/shared/svgdrafteventdata.d.ts.map +1 -0
  75. package/dist/esm/sdk/models/shared/svgdrafteventdata.js +19 -0
  76. package/dist/esm/sdk/models/shared/svgdrafteventdata.js.map +1 -0
  77. package/dist/esm/sdk/models/shared/svggeneratingeventdata.d.ts +36 -0
  78. package/dist/esm/sdk/models/shared/svggeneratingeventdata.d.ts.map +1 -0
  79. package/dist/esm/sdk/models/shared/svggeneratingeventdata.js +19 -0
  80. package/dist/esm/sdk/models/shared/svggeneratingeventdata.js.map +1 -0
  81. package/dist/esm/sdk/models/shared/svgreasoningeventdata.d.ts +36 -0
  82. package/dist/esm/sdk/models/shared/svgreasoningeventdata.d.ts.map +1 -0
  83. package/dist/esm/sdk/models/shared/svgreasoningeventdata.js +19 -0
  84. package/dist/esm/sdk/models/shared/svgreasoningeventdata.js.map +1 -0
  85. package/dist/esm/sdk/models/shared/svgresponse.d.ts +9 -0
  86. package/dist/esm/sdk/models/shared/svgresponse.d.ts.map +1 -1
  87. package/dist/esm/sdk/models/shared/svgresponse.js +1 -0
  88. package/dist/esm/sdk/models/shared/svgresponse.js.map +1 -1
  89. package/dist/esm/sdk/models/shared/svgstreamevent.d.ts +73 -18
  90. package/dist/esm/sdk/models/shared/svgstreamevent.d.ts.map +1 -1
  91. package/dist/esm/sdk/models/shared/svgstreamevent.js +69 -11
  92. package/dist/esm/sdk/models/shared/svgstreamevent.js.map +1 -1
  93. package/dist/esm/sdk/models/shared/svgstreameventdata.d.ts +6 -37
  94. package/dist/esm/sdk/models/shared/svgstreameventdata.d.ts.map +1 -1
  95. package/dist/esm/sdk/models/shared/svgstreameventdata.js +10 -19
  96. package/dist/esm/sdk/models/shared/svgstreameventdata.js.map +1 -1
  97. package/dist/esm/sdk/models/shared/svgusage.d.ts +20 -0
  98. package/dist/esm/sdk/models/shared/svgusage.d.ts.map +1 -1
  99. package/dist/esm/sdk/models/shared/svgusage.js.map +1 -1
  100. package/jsr.json +1 -1
  101. package/package.json +1 -1
  102. package/src/lib/config.ts +2 -2
  103. package/src/sdk/models/shared/generatesvgrequest.ts +10 -7
  104. package/src/sdk/models/shared/imageinputreferenceinput.ts +45 -0
  105. package/src/sdk/models/shared/index.ts +5 -0
  106. package/src/sdk/models/shared/model.ts +55 -2
  107. package/src/sdk/models/shared/svgcontenteventdata.ts +72 -0
  108. package/src/sdk/models/shared/svgdrafteventdata.ts +67 -0
  109. package/src/sdk/models/shared/svggeneratingeventdata.ts +67 -0
  110. package/src/sdk/models/shared/svgreasoningeventdata.ts +67 -0
  111. package/src/sdk/models/shared/svgresponse.ts +10 -0
  112. package/src/sdk/models/shared/svgstreamevent.ts +174 -34
  113. package/src/sdk/models/shared/svgstreameventdata.ts +28 -49
  114. package/src/sdk/models/shared/svgusage.ts +20 -0
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import {
7
+ collectExtraKeys as collectExtraKeys$,
8
+ safeParse,
9
+ } from "../../../lib/schemas.js";
10
+ import { Result as SafeParseResult } from "../../types/fp.js";
11
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
12
+ import { SvgUsage, SvgUsage$inboundSchema } from "./svgusage.js";
13
+
14
+ export type SvgContentEventData = {
15
+ /**
16
+ * Credit cost for this completed SVG output. Emitted on `content` events.
17
+ */
18
+ credits?: number | undefined;
19
+ /**
20
+ * A unique identifier for the SVG output. For streaming multi-output requests (`n > 1`), each output has a distinct `id` and all events for that output reuse that same `id`.
21
+ */
22
+ id: string;
23
+ /**
24
+ * Zero-based output index for this event. Present for multi-output streams (`n > 1`).
25
+ */
26
+ index?: number | undefined;
27
+ /**
28
+ * The SVG markup (partial during draft, complete during content).
29
+ */
30
+ svg: string;
31
+ /**
32
+ * Optional reasoning text (present on reasoning events for some operations).
33
+ */
34
+ text?: string | undefined;
35
+ type: "content";
36
+ /**
37
+ * Deprecated. Use `credits` for billing values.
38
+ *
39
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
40
+ */
41
+ usage?: SvgUsage | undefined;
42
+ additionalProperties?: { [k: string]: any } | undefined;
43
+ };
44
+
45
+ /** @internal */
46
+ export const SvgContentEventData$inboundSchema: z.ZodType<
47
+ SvgContentEventData,
48
+ z.ZodTypeDef,
49
+ unknown
50
+ > = collectExtraKeys$(
51
+ z.object({
52
+ credits: z.number().int().optional(),
53
+ id: z.string(),
54
+ index: z.number().int().optional(),
55
+ svg: z.string(),
56
+ text: z.string().optional(),
57
+ type: z.literal("content"),
58
+ usage: SvgUsage$inboundSchema.optional(),
59
+ }).catchall(z.any()),
60
+ "additionalProperties",
61
+ true,
62
+ );
63
+
64
+ export function svgContentEventDataFromJSON(
65
+ jsonString: string,
66
+ ): SafeParseResult<SvgContentEventData, SDKValidationError> {
67
+ return safeParse(
68
+ jsonString,
69
+ (x) => SvgContentEventData$inboundSchema.parse(JSON.parse(x)),
70
+ `Failed to parse 'SvgContentEventData' from JSON`,
71
+ );
72
+ }
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import {
7
+ collectExtraKeys as collectExtraKeys$,
8
+ safeParse,
9
+ } from "../../../lib/schemas.js";
10
+ import { Result as SafeParseResult } from "../../types/fp.js";
11
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
12
+ import { SvgUsage, SvgUsage$inboundSchema } from "./svgusage.js";
13
+
14
+ export type SvgDraftEventData = {
15
+ /**
16
+ * A unique identifier for the SVG output. For streaming multi-output requests (`n > 1`), each output has a distinct `id` and all events for that output reuse that same `id`.
17
+ */
18
+ id: string;
19
+ /**
20
+ * Zero-based output index for this event. Present for multi-output streams (`n > 1`).
21
+ */
22
+ index?: number | undefined;
23
+ /**
24
+ * The SVG markup (partial during draft, complete during content).
25
+ */
26
+ svg: string;
27
+ /**
28
+ * Optional reasoning text (present on reasoning events for some operations).
29
+ */
30
+ text?: string | undefined;
31
+ type: "draft";
32
+ /**
33
+ * Deprecated. Use `credits` for billing values.
34
+ *
35
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
36
+ */
37
+ usage?: SvgUsage | undefined;
38
+ additionalProperties?: { [k: string]: any } | undefined;
39
+ };
40
+
41
+ /** @internal */
42
+ export const SvgDraftEventData$inboundSchema: z.ZodType<
43
+ SvgDraftEventData,
44
+ z.ZodTypeDef,
45
+ unknown
46
+ > = collectExtraKeys$(
47
+ z.object({
48
+ id: z.string(),
49
+ index: z.number().int().optional(),
50
+ svg: z.string(),
51
+ text: z.string().optional(),
52
+ type: z.literal("draft"),
53
+ usage: SvgUsage$inboundSchema.optional(),
54
+ }).catchall(z.any()),
55
+ "additionalProperties",
56
+ true,
57
+ );
58
+
59
+ export function svgDraftEventDataFromJSON(
60
+ jsonString: string,
61
+ ): SafeParseResult<SvgDraftEventData, SDKValidationError> {
62
+ return safeParse(
63
+ jsonString,
64
+ (x) => SvgDraftEventData$inboundSchema.parse(JSON.parse(x)),
65
+ `Failed to parse 'SvgDraftEventData' from JSON`,
66
+ );
67
+ }
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import {
7
+ collectExtraKeys as collectExtraKeys$,
8
+ safeParse,
9
+ } from "../../../lib/schemas.js";
10
+ import { Result as SafeParseResult } from "../../types/fp.js";
11
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
12
+ import { SvgUsage, SvgUsage$inboundSchema } from "./svgusage.js";
13
+
14
+ export type SvgGeneratingEventData = {
15
+ /**
16
+ * A unique identifier for the SVG output when available. Stable per output across streamed events.
17
+ */
18
+ id?: string | undefined;
19
+ /**
20
+ * Zero-based output index for this event. Present for multi-output streams (`n > 1`).
21
+ */
22
+ index?: number | undefined;
23
+ /**
24
+ * Optional SVG payload for forward compatibility.
25
+ */
26
+ svg?: string | undefined;
27
+ /**
28
+ * Optional generation status or reasoning text.
29
+ */
30
+ text?: string | undefined;
31
+ type: "generating";
32
+ /**
33
+ * Deprecated. Use `credits` for billing values.
34
+ *
35
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
36
+ */
37
+ usage?: SvgUsage | undefined;
38
+ additionalProperties?: { [k: string]: any } | undefined;
39
+ };
40
+
41
+ /** @internal */
42
+ export const SvgGeneratingEventData$inboundSchema: z.ZodType<
43
+ SvgGeneratingEventData,
44
+ z.ZodTypeDef,
45
+ unknown
46
+ > = collectExtraKeys$(
47
+ z.object({
48
+ id: z.string().optional(),
49
+ index: z.number().int().optional(),
50
+ svg: z.string().optional(),
51
+ text: z.string().optional(),
52
+ type: z.literal("generating"),
53
+ usage: SvgUsage$inboundSchema.optional(),
54
+ }).catchall(z.any()),
55
+ "additionalProperties",
56
+ true,
57
+ );
58
+
59
+ export function svgGeneratingEventDataFromJSON(
60
+ jsonString: string,
61
+ ): SafeParseResult<SvgGeneratingEventData, SDKValidationError> {
62
+ return safeParse(
63
+ jsonString,
64
+ (x) => SvgGeneratingEventData$inboundSchema.parse(JSON.parse(x)),
65
+ `Failed to parse 'SvgGeneratingEventData' from JSON`,
66
+ );
67
+ }
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import {
7
+ collectExtraKeys as collectExtraKeys$,
8
+ safeParse,
9
+ } from "../../../lib/schemas.js";
10
+ import { Result as SafeParseResult } from "../../types/fp.js";
11
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
12
+ import { SvgUsage, SvgUsage$inboundSchema } from "./svgusage.js";
13
+
14
+ export type SvgReasoningEventData = {
15
+ /**
16
+ * A unique identifier for the SVG output when available. Stable per output across streamed events.
17
+ */
18
+ id?: string | undefined;
19
+ /**
20
+ * Zero-based output index for this event. Present for multi-output streams (`n > 1`).
21
+ */
22
+ index?: number | undefined;
23
+ /**
24
+ * Optional SVG payload for forward compatibility.
25
+ */
26
+ svg?: string | undefined;
27
+ /**
28
+ * Optional reasoning text (present on reasoning events for some operations).
29
+ */
30
+ text?: string | undefined;
31
+ type: "reasoning";
32
+ /**
33
+ * Deprecated. Use `credits` for billing values.
34
+ *
35
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
36
+ */
37
+ usage?: SvgUsage | undefined;
38
+ additionalProperties?: { [k: string]: any } | undefined;
39
+ };
40
+
41
+ /** @internal */
42
+ export const SvgReasoningEventData$inboundSchema: z.ZodType<
43
+ SvgReasoningEventData,
44
+ z.ZodTypeDef,
45
+ unknown
46
+ > = collectExtraKeys$(
47
+ z.object({
48
+ id: z.string().optional(),
49
+ index: z.number().int().optional(),
50
+ svg: z.string().optional(),
51
+ text: z.string().optional(),
52
+ type: z.literal("reasoning"),
53
+ usage: SvgUsage$inboundSchema.optional(),
54
+ }).catchall(z.any()),
55
+ "additionalProperties",
56
+ true,
57
+ );
58
+
59
+ export function svgReasoningEventDataFromJSON(
60
+ jsonString: string,
61
+ ): SafeParseResult<SvgReasoningEventData, SDKValidationError> {
62
+ return safeParse(
63
+ jsonString,
64
+ (x) => SvgReasoningEventData$inboundSchema.parse(JSON.parse(x)),
65
+ `Failed to parse 'SvgReasoningEventData' from JSON`,
66
+ );
67
+ }
@@ -11,8 +11,17 @@ import { SvgUsage, SvgUsage$inboundSchema } from "./svgusage.js";
11
11
 
12
12
  export type SvgResponse = {
13
13
  created: number;
14
+ /**
15
+ * Credit cost for this request. Use this for billing instead of `usage` tokens.
16
+ */
17
+ credits?: number | undefined;
14
18
  data: Array<SvgDocument>;
15
19
  id: string;
20
+ /**
21
+ * Deprecated. Use `credits` for billing values.
22
+ *
23
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
24
+ */
16
25
  usage?: SvgUsage | undefined;
17
26
  };
18
27
 
@@ -23,6 +32,7 @@ export const SvgResponse$inboundSchema: z.ZodType<
23
32
  unknown
24
33
  > = z.object({
25
34
  created: z.number().int(),
35
+ credits: z.number().int().optional(),
26
36
  data: z.array(SvgDocument$inboundSchema),
27
37
  id: z.string(),
28
38
  usage: SvgUsage$inboundSchema.optional(),
@@ -4,7 +4,6 @@
4
4
 
5
5
  import * as z from "zod/v3";
6
6
  import { safeParse } from "../../../lib/schemas.js";
7
- import { ClosedEnum } from "../../types/enums.js";
8
7
  import { Result as SafeParseResult } from "../../types/fp.js";
9
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
9
  import {
@@ -12,28 +11,72 @@ import {
12
11
  SvgStreamEventData$inboundSchema,
13
12
  } from "./svgstreameventdata.js";
14
13
 
15
- /**
16
- * The SSE event name (sent via the `event:` line).
17
- */
18
- export const Event = {
19
- Reasoning: "reasoning",
20
- Draft: "draft",
21
- Content: "content",
22
- } as const;
23
- /**
24
- * The SSE event name (sent via the `event:` line).
25
- */
26
- export type Event = ClosedEnum<typeof Event>;
14
+ export type Four = {
15
+ /**
16
+ * The event payload. Shape depends on the `type` phase discriminator.
17
+ */
18
+ data: SvgStreamEventData;
19
+ /**
20
+ * The SSE event name (sent via the `event:` line).
21
+ */
22
+ event: "content";
23
+ /**
24
+ * Optional SSE event id (sent via the `id:` line).
25
+ */
26
+ id?: string | undefined;
27
+ /**
28
+ * Optional SSE retry value in milliseconds (sent via the `retry:` line).
29
+ */
30
+ retry?: number | undefined;
31
+ };
27
32
 
28
- /**
29
- * Server-sent event (SSE) envelope for SVG streaming operations. Each SSE message uses the `event:` line for the phase discriminator and the `data:` line for a JSON payload. For `n > 1`, events are interleaved: use `data.index` for output position and `data.id` as the stable per-output identifier. The stream terminates with `data: [DONE]`.
30
- */
31
- export type SvgStreamEvent = {
33
+ export type Three = {
34
+ /**
35
+ * The event payload. Shape depends on the `type` phase discriminator.
36
+ */
37
+ data: SvgStreamEventData;
38
+ /**
39
+ * The SSE event name (sent via the `event:` line).
40
+ */
41
+ event: "draft";
42
+ /**
43
+ * Optional SSE event id (sent via the `id:` line).
44
+ */
45
+ id?: string | undefined;
46
+ /**
47
+ * Optional SSE retry value in milliseconds (sent via the `retry:` line).
48
+ */
49
+ retry?: number | undefined;
50
+ };
51
+
52
+ export type Two = {
53
+ /**
54
+ * The event payload. Shape depends on the `type` phase discriminator.
55
+ */
56
+ data: SvgStreamEventData;
57
+ /**
58
+ * The SSE event name (sent via the `event:` line).
59
+ */
60
+ event: "reasoning";
61
+ /**
62
+ * Optional SSE event id (sent via the `id:` line).
63
+ */
64
+ id?: string | undefined;
65
+ /**
66
+ * Optional SSE retry value in milliseconds (sent via the `retry:` line).
67
+ */
68
+ retry?: number | undefined;
69
+ };
70
+
71
+ export type One = {
72
+ /**
73
+ * The event payload. Shape depends on the `type` phase discriminator.
74
+ */
32
75
  data: SvgStreamEventData;
33
76
  /**
34
77
  * The SSE event name (sent via the `event:` line).
35
78
  */
36
- event: Event;
79
+ event: "generating";
37
80
  /**
38
81
  * Optional SSE event id (sent via the `id:` line).
39
82
  */
@@ -44,29 +87,126 @@ export type SvgStreamEvent = {
44
87
  retry?: number | undefined;
45
88
  };
46
89
 
90
+ /**
91
+ * Server-sent event (SSE) envelope for SVG streaming operations. Each SSE message uses the `event:` line for the phase discriminator and the `data:` line for a JSON payload. For `n > 1`, events are interleaved: use `data.index` for output position and `data.id` as the stable per-output identifier. The stream terminates with `data: [DONE]`.
92
+ */
93
+ export type SvgStreamEvent = One | Two | Three | Four;
94
+
95
+ /** @internal */
96
+ export const Four$inboundSchema: z.ZodType<Four, z.ZodTypeDef, unknown> = z
97
+ .object({
98
+ data: z.string().transform((v, ctx) => {
99
+ try {
100
+ return JSON.parse(v);
101
+ } catch (err) {
102
+ ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
103
+ return z.NEVER;
104
+ }
105
+ }).pipe(SvgStreamEventData$inboundSchema),
106
+ event: z.literal("content"),
107
+ id: z.string().optional(),
108
+ retry: z.number().int().optional(),
109
+ });
110
+
111
+ export function fourFromJSON(
112
+ jsonString: string,
113
+ ): SafeParseResult<Four, SDKValidationError> {
114
+ return safeParse(
115
+ jsonString,
116
+ (x) => Four$inboundSchema.parse(JSON.parse(x)),
117
+ `Failed to parse 'Four' from JSON`,
118
+ );
119
+ }
120
+
47
121
  /** @internal */
48
- export const Event$inboundSchema: z.ZodNativeEnum<typeof Event> = z.nativeEnum(
49
- Event,
50
- );
122
+ export const Three$inboundSchema: z.ZodType<Three, z.ZodTypeDef, unknown> = z
123
+ .object({
124
+ data: z.string().transform((v, ctx) => {
125
+ try {
126
+ return JSON.parse(v);
127
+ } catch (err) {
128
+ ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
129
+ return z.NEVER;
130
+ }
131
+ }).pipe(SvgStreamEventData$inboundSchema),
132
+ event: z.literal("draft"),
133
+ id: z.string().optional(),
134
+ retry: z.number().int().optional(),
135
+ });
136
+
137
+ export function threeFromJSON(
138
+ jsonString: string,
139
+ ): SafeParseResult<Three, SDKValidationError> {
140
+ return safeParse(
141
+ jsonString,
142
+ (x) => Three$inboundSchema.parse(JSON.parse(x)),
143
+ `Failed to parse 'Three' from JSON`,
144
+ );
145
+ }
146
+
147
+ /** @internal */
148
+ export const Two$inboundSchema: z.ZodType<Two, z.ZodTypeDef, unknown> = z
149
+ .object({
150
+ data: z.string().transform((v, ctx) => {
151
+ try {
152
+ return JSON.parse(v);
153
+ } catch (err) {
154
+ ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
155
+ return z.NEVER;
156
+ }
157
+ }).pipe(SvgStreamEventData$inboundSchema),
158
+ event: z.literal("reasoning"),
159
+ id: z.string().optional(),
160
+ retry: z.number().int().optional(),
161
+ });
162
+
163
+ export function twoFromJSON(
164
+ jsonString: string,
165
+ ): SafeParseResult<Two, SDKValidationError> {
166
+ return safeParse(
167
+ jsonString,
168
+ (x) => Two$inboundSchema.parse(JSON.parse(x)),
169
+ `Failed to parse 'Two' from JSON`,
170
+ );
171
+ }
172
+
173
+ /** @internal */
174
+ export const One$inboundSchema: z.ZodType<One, z.ZodTypeDef, unknown> = z
175
+ .object({
176
+ data: z.string().transform((v, ctx) => {
177
+ try {
178
+ return JSON.parse(v);
179
+ } catch (err) {
180
+ ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
181
+ return z.NEVER;
182
+ }
183
+ }).pipe(SvgStreamEventData$inboundSchema),
184
+ event: z.literal("generating"),
185
+ id: z.string().optional(),
186
+ retry: z.number().int().optional(),
187
+ });
188
+
189
+ export function oneFromJSON(
190
+ jsonString: string,
191
+ ): SafeParseResult<One, SDKValidationError> {
192
+ return safeParse(
193
+ jsonString,
194
+ (x) => One$inboundSchema.parse(JSON.parse(x)),
195
+ `Failed to parse 'One' from JSON`,
196
+ );
197
+ }
51
198
 
52
199
  /** @internal */
53
200
  export const SvgStreamEvent$inboundSchema: z.ZodType<
54
201
  SvgStreamEvent,
55
202
  z.ZodTypeDef,
56
203
  unknown
57
- > = z.object({
58
- data: z.string().transform((v, ctx) => {
59
- try {
60
- return JSON.parse(v);
61
- } catch (err) {
62
- ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
63
- return z.NEVER;
64
- }
65
- }).pipe(SvgStreamEventData$inboundSchema),
66
- event: Event$inboundSchema,
67
- id: z.string().optional(),
68
- retry: z.number().int().optional(),
69
- });
204
+ > = z.union([
205
+ z.lazy(() => One$inboundSchema),
206
+ z.lazy(() => Two$inboundSchema),
207
+ z.lazy(() => Three$inboundSchema),
208
+ z.lazy(() => Four$inboundSchema),
209
+ ]);
70
210
 
71
211
  export function svgStreamEventFromJSON(
72
212
  jsonString: string,
@@ -4,66 +4,45 @@
4
4
 
5
5
  import * as z from "zod/v3";
6
6
  import { safeParse } from "../../../lib/schemas.js";
7
- import { ClosedEnum } from "../../types/enums.js";
8
7
  import { Result as SafeParseResult } from "../../types/fp.js";
9
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
- import { SvgUsage, SvgUsage$inboundSchema } from "./svgusage.js";
9
+ import {
10
+ SvgContentEventData,
11
+ SvgContentEventData$inboundSchema,
12
+ } from "./svgcontenteventdata.js";
13
+ import {
14
+ SvgDraftEventData,
15
+ SvgDraftEventData$inboundSchema,
16
+ } from "./svgdrafteventdata.js";
17
+ import {
18
+ SvgGeneratingEventData,
19
+ SvgGeneratingEventData$inboundSchema,
20
+ } from "./svggeneratingeventdata.js";
21
+ import {
22
+ SvgReasoningEventData,
23
+ SvgReasoningEventData$inboundSchema,
24
+ } from "./svgreasoningeventdata.js";
11
25
 
12
26
  /**
13
- * The event type indicating the phase.
27
+ * The event payload. Shape depends on the `type` phase discriminator.
14
28
  */
15
- export const Type = {
16
- Reasoning: "reasoning",
17
- Draft: "draft",
18
- Content: "content",
19
- } as const;
20
- /**
21
- * The event type indicating the phase.
22
- */
23
- export type Type = ClosedEnum<typeof Type>;
24
-
25
- export type SvgStreamEventData = {
26
- /**
27
- * A unique identifier for the SVG output. For streaming multi-output requests (`n > 1`), each output has a distinct `id` and all events for that output reuse that same `id`.
28
- */
29
- id: string;
30
- /**
31
- * Zero-based output index for this event. Present for multi-output streams (`n > 1`).
32
- */
33
- index?: number | undefined;
34
- /**
35
- * The SVG markup (partial during draft, complete during content).
36
- */
37
- svg: string;
38
- /**
39
- * Optional reasoning text (present on reasoning events for some operations).
40
- */
41
- text?: string | undefined;
42
- /**
43
- * The event type indicating the phase.
44
- */
45
- type: Type;
46
- usage?: SvgUsage | undefined;
47
- };
48
-
49
- /** @internal */
50
- export const Type$inboundSchema: z.ZodNativeEnum<typeof Type> = z.nativeEnum(
51
- Type,
52
- );
29
+ export type SvgStreamEventData =
30
+ | SvgContentEventData
31
+ | SvgDraftEventData
32
+ | SvgGeneratingEventData
33
+ | SvgReasoningEventData;
53
34
 
54
35
  /** @internal */
55
36
  export const SvgStreamEventData$inboundSchema: z.ZodType<
56
37
  SvgStreamEventData,
57
38
  z.ZodTypeDef,
58
39
  unknown
59
- > = z.object({
60
- id: z.string(),
61
- index: z.number().int().optional(),
62
- svg: z.string(),
63
- text: z.string().optional(),
64
- type: Type$inboundSchema,
65
- usage: SvgUsage$inboundSchema.optional(),
66
- });
40
+ > = z.union([
41
+ SvgContentEventData$inboundSchema,
42
+ SvgDraftEventData$inboundSchema,
43
+ SvgGeneratingEventData$inboundSchema,
44
+ SvgReasoningEventData$inboundSchema,
45
+ ]);
67
46
 
68
47
  export function svgStreamEventDataFromJSON(
69
48
  jsonString: string,
@@ -8,9 +8,29 @@ 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
+ /**
12
+ * Deprecated. Use `credits` for billing values.
13
+ *
14
+ * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible.
15
+ */
11
16
  export type SvgUsage = {
17
+ /**
18
+ * Deprecated. Token counts are retained for compatibility and may be zeroed.
19
+ *
20
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
21
+ */
12
22
  inputTokens: number;
23
+ /**
24
+ * Deprecated. Token counts are retained for compatibility and may be zeroed.
25
+ *
26
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
27
+ */
13
28
  outputTokens: number;
29
+ /**
30
+ * Deprecated. Token counts are retained for compatibility and may be zeroed.
31
+ *
32
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
33
+ */
14
34
  totalTokens: number;
15
35
  };
16
36