@quiverai/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/dist/commonjs/funcs/createSVGsGenerateSVG.d.ts +1 -2
- package/dist/commonjs/funcs/createSVGsGenerateSVG.d.ts.map +1 -1
- package/dist/commonjs/funcs/createSVGsGenerateSVG.js +9 -4
- package/dist/commonjs/funcs/createSVGsGenerateSVG.js.map +1 -1
- package/dist/commonjs/funcs/modelsGetModel.js +1 -1
- package/dist/commonjs/funcs/modelsGetModel.js.map +1 -1
- package/dist/commonjs/funcs/modelsListModels.js +1 -1
- package/dist/commonjs/funcs/modelsListModels.js.map +1 -1
- package/dist/commonjs/funcs/vectorizeSVGVectorizeSVG.d.ts +1 -2
- package/dist/commonjs/funcs/vectorizeSVGVectorizeSVG.d.ts.map +1 -1
- package/dist/commonjs/funcs/vectorizeSVGVectorizeSVG.js +9 -4
- package/dist/commonjs/funcs/vectorizeSVGVectorizeSVG.js.map +1 -1
- package/dist/commonjs/hooks/types.d.ts +1 -0
- package/dist/commonjs/hooks/types.d.ts.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/lib/encodings.js +12 -12
- package/dist/commonjs/lib/encodings.js.map +1 -1
- package/dist/commonjs/lib/event-streams.d.ts.map +1 -1
- package/dist/commonjs/lib/event-streams.js +28 -13
- package/dist/commonjs/lib/event-streams.js.map +1 -1
- package/dist/commonjs/lib/matchers.js +3 -3
- package/dist/commonjs/lib/matchers.js.map +1 -1
- package/dist/commonjs/lib/primitives.d.ts +1 -0
- package/dist/commonjs/lib/primitives.d.ts.map +1 -1
- package/dist/commonjs/lib/primitives.js +18 -0
- package/dist/commonjs/lib/primitives.js.map +1 -1
- package/dist/commonjs/lib/sdks.d.ts.map +1 -1
- package/dist/commonjs/lib/sdks.js +50 -16
- package/dist/commonjs/lib/sdks.js.map +1 -1
- package/dist/commonjs/sdk/createsvgs.d.ts +1 -2
- package/dist/commonjs/sdk/createsvgs.d.ts.map +1 -1
- package/dist/commonjs/sdk/createsvgs.js.map +1 -1
- package/dist/commonjs/sdk/models/operations/generatesvg.d.ts +15 -0
- package/dist/commonjs/sdk/models/operations/generatesvg.d.ts.map +1 -1
- package/dist/commonjs/sdk/models/operations/generatesvg.js +15 -1
- package/dist/commonjs/sdk/models/operations/generatesvg.js.map +1 -1
- package/dist/commonjs/sdk/models/operations/vectorizesvg.d.ts +15 -0
- package/dist/commonjs/sdk/models/operations/vectorizesvg.d.ts.map +1 -1
- package/dist/commonjs/sdk/models/operations/vectorizesvg.js +15 -1
- package/dist/commonjs/sdk/models/operations/vectorizesvg.js.map +1 -1
- package/dist/commonjs/sdk/models/shared/imageinputreference.d.ts +3 -0
- package/dist/commonjs/sdk/models/shared/imageinputreference.d.ts.map +1 -1
- package/dist/commonjs/sdk/models/shared/imageinputreference.js.map +1 -1
- package/dist/commonjs/sdk/models/shared/imageinputreferencebase64.d.ts +1 -1
- package/dist/commonjs/sdk/models/shared/imageinputreferenceurl.d.ts +1 -1
- package/dist/commonjs/sdk/models/shared/publicerrorenvelope.d.ts +0 -1
- package/dist/commonjs/sdk/models/shared/publicerrorenvelope.d.ts.map +1 -1
- package/dist/commonjs/sdk/models/shared/publicerrorenvelope.js +0 -1
- package/dist/commonjs/sdk/models/shared/publicerrorenvelope.js.map +1 -1
- package/dist/commonjs/sdk/models/shared/vectorizesvgrequest.d.ts +3 -0
- package/dist/commonjs/sdk/models/shared/vectorizesvgrequest.d.ts.map +1 -1
- package/dist/commonjs/sdk/models/shared/vectorizesvgrequest.js.map +1 -1
- package/dist/commonjs/sdk/vectorizesvg.d.ts +1 -2
- package/dist/commonjs/sdk/vectorizesvg.d.ts.map +1 -1
- package/dist/commonjs/sdk/vectorizesvg.js.map +1 -1
- package/dist/esm/funcs/createSVGsGenerateSVG.d.ts +1 -2
- package/dist/esm/funcs/createSVGsGenerateSVG.d.ts.map +1 -1
- package/dist/esm/funcs/createSVGsGenerateSVG.js +10 -5
- package/dist/esm/funcs/createSVGsGenerateSVG.js.map +1 -1
- package/dist/esm/funcs/modelsGetModel.js +1 -1
- package/dist/esm/funcs/modelsGetModel.js.map +1 -1
- package/dist/esm/funcs/modelsListModels.js +1 -1
- package/dist/esm/funcs/modelsListModels.js.map +1 -1
- package/dist/esm/funcs/vectorizeSVGVectorizeSVG.d.ts +1 -2
- package/dist/esm/funcs/vectorizeSVGVectorizeSVG.d.ts.map +1 -1
- package/dist/esm/funcs/vectorizeSVGVectorizeSVG.js +10 -5
- package/dist/esm/funcs/vectorizeSVGVectorizeSVG.js.map +1 -1
- package/dist/esm/hooks/types.d.ts +1 -0
- package/dist/esm/hooks/types.d.ts.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/lib/encodings.js +1 -1
- package/dist/esm/lib/encodings.js.map +1 -1
- package/dist/esm/lib/event-streams.d.ts.map +1 -1
- package/dist/esm/lib/event-streams.js +28 -13
- package/dist/esm/lib/event-streams.js.map +1 -1
- package/dist/esm/lib/matchers.js +1 -1
- package/dist/esm/lib/matchers.js.map +1 -1
- package/dist/esm/lib/primitives.d.ts +1 -0
- package/dist/esm/lib/primitives.d.ts.map +1 -1
- package/dist/esm/lib/primitives.js +17 -0
- package/dist/esm/lib/primitives.js.map +1 -1
- package/dist/esm/lib/sdks.d.ts.map +1 -1
- package/dist/esm/lib/sdks.js +50 -16
- package/dist/esm/lib/sdks.js.map +1 -1
- package/dist/esm/sdk/createsvgs.d.ts +1 -2
- package/dist/esm/sdk/createsvgs.d.ts.map +1 -1
- package/dist/esm/sdk/createsvgs.js.map +1 -1
- package/dist/esm/sdk/models/operations/generatesvg.d.ts +15 -0
- package/dist/esm/sdk/models/operations/generatesvg.d.ts.map +1 -1
- package/dist/esm/sdk/models/operations/generatesvg.js +13 -0
- package/dist/esm/sdk/models/operations/generatesvg.js.map +1 -1
- package/dist/esm/sdk/models/operations/vectorizesvg.d.ts +15 -0
- package/dist/esm/sdk/models/operations/vectorizesvg.d.ts.map +1 -1
- package/dist/esm/sdk/models/operations/vectorizesvg.js +13 -0
- package/dist/esm/sdk/models/operations/vectorizesvg.js.map +1 -1
- package/dist/esm/sdk/models/shared/imageinputreference.d.ts +3 -0
- package/dist/esm/sdk/models/shared/imageinputreference.d.ts.map +1 -1
- package/dist/esm/sdk/models/shared/imageinputreference.js.map +1 -1
- package/dist/esm/sdk/models/shared/imageinputreferencebase64.d.ts +1 -1
- package/dist/esm/sdk/models/shared/imageinputreferenceurl.d.ts +1 -1
- package/dist/esm/sdk/models/shared/publicerrorenvelope.d.ts +0 -1
- package/dist/esm/sdk/models/shared/publicerrorenvelope.d.ts.map +1 -1
- package/dist/esm/sdk/models/shared/publicerrorenvelope.js +0 -1
- package/dist/esm/sdk/models/shared/publicerrorenvelope.js.map +1 -1
- package/dist/esm/sdk/models/shared/vectorizesvgrequest.d.ts +3 -0
- package/dist/esm/sdk/models/shared/vectorizesvgrequest.d.ts.map +1 -1
- package/dist/esm/sdk/models/shared/vectorizesvgrequest.js.map +1 -1
- package/dist/esm/sdk/vectorizesvg.d.ts +1 -2
- package/dist/esm/sdk/vectorizesvg.d.ts.map +1 -1
- package/dist/esm/sdk/vectorizesvg.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/createSVGsGenerateSVG.ts +12 -7
- package/src/funcs/modelsGetModel.ts +1 -1
- package/src/funcs/modelsListModels.ts +1 -1
- package/src/funcs/vectorizeSVGVectorizeSVG.ts +12 -7
- package/src/hooks/types.ts +1 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/encodings.ts +1 -1
- package/src/lib/event-streams.ts +31 -13
- package/src/lib/matchers.ts +1 -1
- package/src/lib/primitives.ts +16 -0
- package/src/lib/sdks.ts +54 -17
- package/src/sdk/createsvgs.ts +1 -2
- package/src/sdk/models/operations/generatesvg.ts +37 -0
- package/src/sdk/models/operations/vectorizesvg.ts +37 -0
- package/src/sdk/models/shared/imageinputreference.ts +3 -0
- package/src/sdk/models/shared/imageinputreferencebase64.ts +1 -1
- package/src/sdk/models/shared/imageinputreferenceurl.ts +1 -1
- package/src/sdk/models/shared/publicerrorenvelope.ts +0 -1
- package/src/sdk/models/shared/vectorizesvgrequest.ts +3 -0
- package/src/sdk/vectorizesvg.ts +1 -2
- package/dist/commonjs/lib/dlv.d.ts +0 -14
- package/dist/commonjs/lib/dlv.d.ts.map +0 -1
- package/dist/commonjs/lib/dlv.js +0 -49
- package/dist/commonjs/lib/dlv.js.map +0 -1
- package/dist/commonjs/lib/is-plain-object.d.ts +0 -2
- package/dist/commonjs/lib/is-plain-object.d.ts.map +0 -1
- package/dist/commonjs/lib/is-plain-object.js +0 -41
- package/dist/commonjs/lib/is-plain-object.js.map +0 -1
- package/dist/esm/lib/dlv.d.ts +0 -14
- package/dist/esm/lib/dlv.d.ts.map +0 -1
- package/dist/esm/lib/dlv.js +0 -46
- package/dist/esm/lib/dlv.js.map +0 -1
- package/dist/esm/lib/is-plain-object.d.ts +0 -2
- package/dist/esm/lib/is-plain-object.d.ts.map +0 -1
- package/dist/esm/lib/is-plain-object.js +0 -38
- package/dist/esm/lib/is-plain-object.js.map +0 -1
- package/src/lib/dlv.ts +0 -53
- package/src/lib/is-plain-object.ts +0 -43
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { QuiverAICore } from "../core.js";
|
|
6
|
-
import { encodeJSON } from "../lib/encodings.js";
|
|
6
|
+
import { encodeJSON, 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";
|
|
@@ -22,7 +22,6 @@ import { QuiverAiError } from "../sdk/models/errors/quiveraierror.js";
|
|
|
22
22
|
import { ResponseValidationError } from "../sdk/models/errors/responsevalidationerror.js";
|
|
23
23
|
import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js";
|
|
24
24
|
import * as operations from "../sdk/models/operations/index.js";
|
|
25
|
-
import * as shared from "../sdk/models/shared/index.js";
|
|
26
25
|
import { APICall, APIPromise } from "../sdk/types/async.js";
|
|
27
26
|
import { Result } from "../sdk/types/fp.js";
|
|
28
27
|
|
|
@@ -39,7 +38,7 @@ export enum GenerateSVGAcceptEnum {
|
|
|
39
38
|
*/
|
|
40
39
|
export function createSVGsGenerateSVG(
|
|
41
40
|
client: QuiverAICore,
|
|
42
|
-
request:
|
|
41
|
+
request: operations.GenerateSVGRequest,
|
|
43
42
|
options?: RequestOptions & { acceptHeaderOverride?: GenerateSVGAcceptEnum },
|
|
44
43
|
): APIPromise<
|
|
45
44
|
Result<
|
|
@@ -63,7 +62,7 @@ export function createSVGsGenerateSVG(
|
|
|
63
62
|
|
|
64
63
|
async function $do(
|
|
65
64
|
client: QuiverAICore,
|
|
66
|
-
request:
|
|
65
|
+
request: operations.GenerateSVGRequest,
|
|
67
66
|
options?: RequestOptions & { acceptHeaderOverride?: GenerateSVGAcceptEnum },
|
|
68
67
|
): Promise<
|
|
69
68
|
[
|
|
@@ -83,14 +82,16 @@ async function $do(
|
|
|
83
82
|
> {
|
|
84
83
|
const parsed = safeParse(
|
|
85
84
|
request,
|
|
86
|
-
(value) =>
|
|
85
|
+
(value) => operations.GenerateSVGRequest$outboundSchema.parse(value),
|
|
87
86
|
"Input validation failed",
|
|
88
87
|
);
|
|
89
88
|
if (!parsed.ok) {
|
|
90
89
|
return [parsed, { status: "invalid" }];
|
|
91
90
|
}
|
|
92
91
|
const payload = parsed.value;
|
|
93
|
-
const body = encodeJSON("body", payload, {
|
|
92
|
+
const body = encodeJSON("body", payload.GenerateSVGRequest, {
|
|
93
|
+
explode: true,
|
|
94
|
+
});
|
|
94
95
|
|
|
95
96
|
const path = pathToFunc("/v1/svgs/generations")();
|
|
96
97
|
|
|
@@ -98,6 +99,10 @@ async function $do(
|
|
|
98
99
|
"Content-Type": "application/json",
|
|
99
100
|
Accept: options?.acceptHeaderOverride
|
|
100
101
|
|| "application/json;q=1, text/event-stream;q=0",
|
|
102
|
+
"x-trace-id": encodeSimple("x-trace-id", payload["x-trace-id"], {
|
|
103
|
+
explode: false,
|
|
104
|
+
charEncoding: "none",
|
|
105
|
+
}),
|
|
101
106
|
}));
|
|
102
107
|
|
|
103
108
|
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
@@ -174,7 +179,7 @@ async function $do(
|
|
|
174
179
|
operations.GenerateSVGResponse$inboundSchema,
|
|
175
180
|
{ hdrs: true, key: "Result" },
|
|
176
181
|
),
|
|
177
|
-
M.json(
|
|
182
|
+
M.json(500, operations.GenerateSVGResponse$inboundSchema, {
|
|
178
183
|
hdrs: true,
|
|
179
184
|
key: "Result",
|
|
180
185
|
}),
|
|
@@ -168,7 +168,7 @@ async function $do(
|
|
|
168
168
|
operations.GetModelResponse$inboundSchema,
|
|
169
169
|
{ hdrs: true, key: "Result" },
|
|
170
170
|
),
|
|
171
|
-
M.json(
|
|
171
|
+
M.json(500, operations.GetModelResponse$inboundSchema, {
|
|
172
172
|
hdrs: true,
|
|
173
173
|
key: "Result",
|
|
174
174
|
}),
|
|
@@ -145,7 +145,7 @@ async function $do(
|
|
|
145
145
|
operations.ListModelsResponse$inboundSchema,
|
|
146
146
|
{ hdrs: true, key: "Result" },
|
|
147
147
|
),
|
|
148
|
-
M.json(
|
|
148
|
+
M.json(500, operations.ListModelsResponse$inboundSchema, {
|
|
149
149
|
hdrs: true,
|
|
150
150
|
key: "Result",
|
|
151
151
|
}),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { QuiverAICore } from "../core.js";
|
|
6
|
-
import { encodeJSON } from "../lib/encodings.js";
|
|
6
|
+
import { encodeJSON, 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";
|
|
@@ -22,7 +22,6 @@ import { QuiverAiError } from "../sdk/models/errors/quiveraierror.js";
|
|
|
22
22
|
import { ResponseValidationError } from "../sdk/models/errors/responsevalidationerror.js";
|
|
23
23
|
import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js";
|
|
24
24
|
import * as operations from "../sdk/models/operations/index.js";
|
|
25
|
-
import * as shared from "../sdk/models/shared/index.js";
|
|
26
25
|
import { APICall, APIPromise } from "../sdk/types/async.js";
|
|
27
26
|
import { Result } from "../sdk/types/fp.js";
|
|
28
27
|
|
|
@@ -39,7 +38,7 @@ export enum VectorizeSVGAcceptEnum {
|
|
|
39
38
|
*/
|
|
40
39
|
export function vectorizeSVGVectorizeSVG(
|
|
41
40
|
client: QuiverAICore,
|
|
42
|
-
request:
|
|
41
|
+
request: operations.VectorizeSVGRequest,
|
|
43
42
|
options?: RequestOptions & { acceptHeaderOverride?: VectorizeSVGAcceptEnum },
|
|
44
43
|
): APIPromise<
|
|
45
44
|
Result<
|
|
@@ -63,7 +62,7 @@ export function vectorizeSVGVectorizeSVG(
|
|
|
63
62
|
|
|
64
63
|
async function $do(
|
|
65
64
|
client: QuiverAICore,
|
|
66
|
-
request:
|
|
65
|
+
request: operations.VectorizeSVGRequest,
|
|
67
66
|
options?: RequestOptions & { acceptHeaderOverride?: VectorizeSVGAcceptEnum },
|
|
68
67
|
): Promise<
|
|
69
68
|
[
|
|
@@ -83,14 +82,16 @@ async function $do(
|
|
|
83
82
|
> {
|
|
84
83
|
const parsed = safeParse(
|
|
85
84
|
request,
|
|
86
|
-
(value) =>
|
|
85
|
+
(value) => operations.VectorizeSVGRequest$outboundSchema.parse(value),
|
|
87
86
|
"Input validation failed",
|
|
88
87
|
);
|
|
89
88
|
if (!parsed.ok) {
|
|
90
89
|
return [parsed, { status: "invalid" }];
|
|
91
90
|
}
|
|
92
91
|
const payload = parsed.value;
|
|
93
|
-
const body = encodeJSON("body", payload, {
|
|
92
|
+
const body = encodeJSON("body", payload.VectorizeSVGRequest, {
|
|
93
|
+
explode: true,
|
|
94
|
+
});
|
|
94
95
|
|
|
95
96
|
const path = pathToFunc("/v1/svgs/vectorizations")();
|
|
96
97
|
|
|
@@ -98,6 +99,10 @@ async function $do(
|
|
|
98
99
|
"Content-Type": "application/json",
|
|
99
100
|
Accept: options?.acceptHeaderOverride
|
|
100
101
|
|| "application/json;q=1, text/event-stream;q=0",
|
|
102
|
+
"x-trace-id": encodeSimple("x-trace-id", payload["x-trace-id"], {
|
|
103
|
+
explode: false,
|
|
104
|
+
charEncoding: "none",
|
|
105
|
+
}),
|
|
101
106
|
}));
|
|
102
107
|
|
|
103
108
|
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
@@ -174,7 +179,7 @@ async function $do(
|
|
|
174
179
|
operations.VectorizeSVGResponse$inboundSchema,
|
|
175
180
|
{ hdrs: true, key: "Result" },
|
|
176
181
|
),
|
|
177
|
-
M.json(
|
|
182
|
+
M.json(500, operations.VectorizeSVGResponse$inboundSchema, {
|
|
178
183
|
hdrs: true,
|
|
179
184
|
key: "Result",
|
|
180
185
|
}),
|
package/src/hooks/types.ts
CHANGED
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.
|
|
65
|
-
genVersion: "2.
|
|
66
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
64
|
+
sdkVersion: "0.8.0",
|
|
65
|
+
genVersion: "2.903.5",
|
|
66
|
+
userAgent: "speakeasy-sdk/typescript 0.8.0 2.903.5 1.0.0 @quiverai/sdk",
|
|
67
67
|
} as const;
|
package/src/lib/encodings.ts
CHANGED
package/src/lib/event-streams.ts
CHANGED
|
@@ -26,22 +26,45 @@ export class EventStream<T extends SseMessage<unknown>>
|
|
|
26
26
|
opts?: { dataRequired?: boolean },
|
|
27
27
|
) {
|
|
28
28
|
const upstream = responseBody.getReader();
|
|
29
|
-
let buffer: Uint8Array = new Uint8Array();
|
|
29
|
+
let buffer: Uint8Array = new Uint8Array(4096);
|
|
30
|
+
let bufferLen = 0;
|
|
31
|
+
let searchStart = 0;
|
|
30
32
|
const state = { eventId: undefined as string | undefined };
|
|
31
33
|
const dataRequired = opts?.dataRequired ?? true;
|
|
32
34
|
super({
|
|
33
35
|
async pull(downstream) {
|
|
34
36
|
try {
|
|
35
37
|
while (true) {
|
|
36
|
-
const match = findBoundary(buffer);
|
|
38
|
+
const match = findBoundary(buffer, bufferLen, searchStart);
|
|
37
39
|
if (!match) {
|
|
40
|
+
// Bytes before the trailing MAX_BOUNDARY_LEN-1 were already
|
|
41
|
+
// scanned with full lookahead and cannot start a boundary even
|
|
42
|
+
// once more data arrives, so the next scan can skip them.
|
|
43
|
+
searchStart = Math.max(0, bufferLen - MAX_BOUNDARY_LEN + 1);
|
|
38
44
|
const chunk = await upstream.read();
|
|
39
45
|
if (chunk.done) return downstream.close();
|
|
40
|
-
|
|
46
|
+
if (bufferLen + chunk.value.length > buffer.length) {
|
|
47
|
+
const grown = new Uint8Array(
|
|
48
|
+
Math.max(buffer.length * 2, bufferLen + chunk.value.length),
|
|
49
|
+
);
|
|
50
|
+
grown.set(buffer.subarray(0, bufferLen));
|
|
51
|
+
buffer = grown;
|
|
52
|
+
}
|
|
53
|
+
buffer.set(chunk.value, bufferLen);
|
|
54
|
+
bufferLen += chunk.value.length;
|
|
41
55
|
continue;
|
|
42
56
|
}
|
|
43
57
|
const message = buffer.slice(0, match.index);
|
|
44
|
-
buffer
|
|
58
|
+
buffer.copyWithin(0, match.index + match.length, bufferLen);
|
|
59
|
+
bufferLen -= match.index + match.length;
|
|
60
|
+
if (buffer.length > 4096 && bufferLen <= buffer.length >> 2) {
|
|
61
|
+
// Release oversized capacity retained after an unusually large
|
|
62
|
+
// event so long-lived streams do not hold peak memory.
|
|
63
|
+
const shrunk = new Uint8Array(Math.max(4096, bufferLen * 2));
|
|
64
|
+
shrunk.set(buffer.subarray(0, bufferLen));
|
|
65
|
+
buffer = shrunk;
|
|
66
|
+
}
|
|
67
|
+
searchStart = 0;
|
|
45
68
|
const item = parseMessage(message, parse, state, dataRequired);
|
|
46
69
|
if (item && !item.done) return downstream.enqueue(item.value);
|
|
47
70
|
if (item?.done) {
|
|
@@ -89,13 +112,6 @@ export class EventStream<T extends SseMessage<unknown>>
|
|
|
89
112
|
}
|
|
90
113
|
}
|
|
91
114
|
|
|
92
|
-
function concatBuffer(a: Uint8Array, b: Uint8Array): Uint8Array {
|
|
93
|
-
const c = new Uint8Array(a.length + b.length);
|
|
94
|
-
c.set(a, 0);
|
|
95
|
-
c.set(b, a.length);
|
|
96
|
-
return c;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
115
|
const CR = 13;
|
|
100
116
|
const LF = 10;
|
|
101
117
|
const BOUNDARIES = [
|
|
@@ -108,12 +124,14 @@ const BOUNDARIES = [
|
|
|
108
124
|
[LF, CR], // \n\r
|
|
109
125
|
[LF, LF], // \n\n
|
|
110
126
|
];
|
|
127
|
+
const MAX_BOUNDARY_LEN = BOUNDARIES.reduce((m, b) => Math.max(m, b.length), 0);
|
|
111
128
|
|
|
112
129
|
function findBoundary(
|
|
113
130
|
buf: Uint8Array,
|
|
131
|
+
len: number,
|
|
132
|
+
from: number,
|
|
114
133
|
): { index: number; length: number } | null {
|
|
115
|
-
|
|
116
|
-
for (let i = 0; i < len; i++) {
|
|
134
|
+
for (let i = from; i < len; i++) {
|
|
117
135
|
if (buf[i] !== CR && buf[i] !== LF) continue;
|
|
118
136
|
for (const boundary of BOUNDARIES) {
|
|
119
137
|
if (i + boundary.length > len) continue;
|
package/src/lib/matchers.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ResponseValidationError } from "../sdk/models/errors/responsevalidation
|
|
|
6
6
|
import { SDKError } from "../sdk/models/errors/sdkerror.js";
|
|
7
7
|
import { ERR, OK, Result } from "../sdk/types/fp.js";
|
|
8
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
|
-
import { isPlainObject } from "./
|
|
9
|
+
import { isPlainObject } from "./primitives.js";
|
|
10
10
|
|
|
11
11
|
export type Encoding =
|
|
12
12
|
| "jsonl"
|
package/src/lib/primitives.ts
CHANGED
|
@@ -148,3 +148,19 @@ export function allRequired<V extends Record<string, unknown>>(
|
|
|
148
148
|
|
|
149
149
|
return v as ReturnType<typeof allRequired<V>>;
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
export function isPlainObject(
|
|
153
|
+
value: unknown,
|
|
154
|
+
): value is Record<string, unknown> {
|
|
155
|
+
if (value === null || typeof value !== "object") return false;
|
|
156
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
157
|
+
const proto = Object.getPrototypeOf(value);
|
|
158
|
+
if (proto === null || proto === Object.prototype) return true;
|
|
159
|
+
// cross-realm plain objects (vm contexts, iframes) inherit from a
|
|
160
|
+
// different realm's Object.prototype, which itself has a null prototype
|
|
161
|
+
try {
|
|
162
|
+
return Object.getPrototypeOf(proto) === null;
|
|
163
|
+
} catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/lib/sdks.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
matchContentType,
|
|
24
24
|
} from "./http.js";
|
|
25
25
|
import { Logger } from "./logger.js";
|
|
26
|
+
import { combineSignals } from "./primitives.js";
|
|
26
27
|
import { retry, RetryConfig } from "./retries.js";
|
|
27
28
|
import { SecurityState } from "./security.js";
|
|
28
29
|
|
|
@@ -128,27 +129,55 @@ export class ClientSDK {
|
|
|
128
129
|
if (path) {
|
|
129
130
|
baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
|
|
130
131
|
reqURL = new URL(path, baseURL);
|
|
132
|
+
if (!reqURL.search && baseURL.search) {
|
|
133
|
+
reqURL.search = baseURL.search;
|
|
134
|
+
}
|
|
131
135
|
} else {
|
|
132
136
|
reqURL = baseURL;
|
|
133
137
|
}
|
|
134
138
|
reqURL.hash = "";
|
|
135
139
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (typeof q !== "undefined") {
|
|
142
|
-
secQuery.push(q);
|
|
140
|
+
// Appends already-encoded query pairs to a query string, replacing any
|
|
141
|
+
// existing pairs with the same key so later sources take precedence.
|
|
142
|
+
const mergeQuery = (current: string, additions: string): string => {
|
|
143
|
+
if (!additions) {
|
|
144
|
+
return current;
|
|
143
145
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
const additionKeys = new Set(
|
|
147
|
+
additions
|
|
148
|
+
.split("&")
|
|
149
|
+
.filter((pair) => pair !== "")
|
|
150
|
+
.map((pair) => pair.split("=")[0] ?? ""),
|
|
151
|
+
);
|
|
152
|
+
const kept = current.split("&").filter((pair) => {
|
|
153
|
+
return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
|
|
154
|
+
});
|
|
155
|
+
return [...kept, additions].join("&");
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const encodeQueryRecord = (record: Record<string, unknown>): string => {
|
|
159
|
+
return Object.entries(record)
|
|
160
|
+
.map(([k, v]) => {
|
|
161
|
+
if (v == null) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const value = v;
|
|
165
|
+
return encodeForm(k, value, {
|
|
166
|
+
explode: Array.isArray(value),
|
|
167
|
+
charEncoding: "percent",
|
|
168
|
+
});
|
|
169
|
+
})
|
|
170
|
+
.filter((pair): pair is string => typeof pair !== "undefined")
|
|
171
|
+
.join("&");
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const finalQuery = [
|
|
175
|
+
query || "",
|
|
176
|
+
encodeQueryRecord(security?.queryParams || {}),
|
|
177
|
+
].reduce(mergeQuery, reqURL.search.slice(1));
|
|
148
178
|
|
|
149
179
|
if (finalQuery) {
|
|
150
|
-
|
|
151
|
-
reqURL.search = `?${q}`;
|
|
180
|
+
reqURL.search = `?${finalQuery}`;
|
|
152
181
|
}
|
|
153
182
|
|
|
154
183
|
const headers = new Headers(opHeaders);
|
|
@@ -194,9 +223,8 @@ export class ClientSDK {
|
|
|
194
223
|
...options?.fetchOptions,
|
|
195
224
|
...options,
|
|
196
225
|
};
|
|
197
|
-
if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) {
|
|
198
|
-
|
|
199
|
-
fetchOptions.signal = timeoutSignal;
|
|
226
|
+
if (!fetchOptions?.signal && conf.timeoutMs != null && conf.timeoutMs > 0) {
|
|
227
|
+
context.timeoutMs = conf.timeoutMs;
|
|
200
228
|
}
|
|
201
229
|
|
|
202
230
|
if (conf.body instanceof ReadableStream) {
|
|
@@ -243,10 +271,19 @@ export class ClientSDK {
|
|
|
243
271
|
>
|
|
244
272
|
> {
|
|
245
273
|
const { context, isErrorStatusCode } = options;
|
|
274
|
+
const timeoutMs = context.timeoutMs;
|
|
246
275
|
|
|
247
276
|
return retry(
|
|
248
277
|
async () => {
|
|
249
|
-
const
|
|
278
|
+
const cloned = request.clone();
|
|
279
|
+
let attempt = cloned;
|
|
280
|
+
if (timeoutMs != null && timeoutMs > 0) {
|
|
281
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
282
|
+
const combined = combineSignals(cloned.signal, timeoutSignal)
|
|
283
|
+
?? timeoutSignal;
|
|
284
|
+
attempt = new Request(cloned, { signal: combined });
|
|
285
|
+
}
|
|
286
|
+
const req = await this.#hooks.beforeRequest(context, attempt);
|
|
250
287
|
await logRequest(this.#logger, req).catch((e) =>
|
|
251
288
|
this.#logger?.log("Failed to log request:", e)
|
|
252
289
|
);
|
package/src/sdk/createsvgs.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from "../funcs/createSVGsGenerateSVG.js";
|
|
9
9
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
10
10
|
import * as operations from "./models/operations/index.js";
|
|
11
|
-
import * as shared from "./models/shared/index.js";
|
|
12
11
|
import { unwrapAsync } from "./types/fp.js";
|
|
13
12
|
|
|
14
13
|
export { GenerateSVGAcceptEnum } from "../funcs/createSVGsGenerateSVG.js";
|
|
@@ -21,7 +20,7 @@ export class CreateSVGs extends ClientSDK {
|
|
|
21
20
|
* Generates one or more SVGs from a prompt and optional references.
|
|
22
21
|
*/
|
|
23
22
|
async generateSVG(
|
|
24
|
-
request:
|
|
23
|
+
request: operations.GenerateSVGRequest,
|
|
25
24
|
options?: RequestOptions & { acceptHeaderOverride?: GenerateSVGAcceptEnum },
|
|
26
25
|
): Promise<operations.GenerateSVGResponse> {
|
|
27
26
|
return unwrapAsync(createSVGsGenerateSVG(
|
|
@@ -10,6 +10,14 @@ import { Result as SafeParseResult } from "../../types/fp.js";
|
|
|
10
10
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
11
|
import * as shared from "../shared/index.js";
|
|
12
12
|
|
|
13
|
+
export type GenerateSVGRequest = {
|
|
14
|
+
generateSVGRequest: shared.GenerateSVGRequest;
|
|
15
|
+
/**
|
|
16
|
+
* Optional client-supplied trace identifier. The API echoes this value in `X-Trace-ID` and includes it in request logs for client-side correlation.
|
|
17
|
+
*/
|
|
18
|
+
xTraceId?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
export type GenerateSVGResponseResult =
|
|
14
22
|
| shared.PublicErrorEnvelope
|
|
15
23
|
| shared.SvgResponse
|
|
@@ -23,6 +31,35 @@ export type GenerateSVGResponse = {
|
|
|
23
31
|
| EventStream<shared.SvgStreamEvent>;
|
|
24
32
|
};
|
|
25
33
|
|
|
34
|
+
/** @internal */
|
|
35
|
+
export type GenerateSVGRequest$Outbound = {
|
|
36
|
+
GenerateSVGRequest: shared.GenerateSVGRequest$Outbound;
|
|
37
|
+
"x-trace-id"?: string | undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
export const GenerateSVGRequest$outboundSchema: z.ZodType<
|
|
42
|
+
GenerateSVGRequest$Outbound,
|
|
43
|
+
z.ZodTypeDef,
|
|
44
|
+
GenerateSVGRequest
|
|
45
|
+
> = z.object({
|
|
46
|
+
generateSVGRequest: shared.GenerateSVGRequest$outboundSchema,
|
|
47
|
+
xTraceId: z.string().optional(),
|
|
48
|
+
}).transform((v) => {
|
|
49
|
+
return remap$(v, {
|
|
50
|
+
generateSVGRequest: "GenerateSVGRequest",
|
|
51
|
+
xTraceId: "x-trace-id",
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export function generateSVGRequestToJSON(
|
|
56
|
+
generateSVGRequest: GenerateSVGRequest,
|
|
57
|
+
): string {
|
|
58
|
+
return JSON.stringify(
|
|
59
|
+
GenerateSVGRequest$outboundSchema.parse(generateSVGRequest),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
26
63
|
/** @internal */
|
|
27
64
|
export const GenerateSVGResponseResult$inboundSchema: z.ZodType<
|
|
28
65
|
GenerateSVGResponseResult,
|
|
@@ -10,6 +10,14 @@ import { Result as SafeParseResult } from "../../types/fp.js";
|
|
|
10
10
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
11
|
import * as shared from "../shared/index.js";
|
|
12
12
|
|
|
13
|
+
export type VectorizeSVGRequest = {
|
|
14
|
+
vectorizeSVGRequest: shared.VectorizeSVGRequest;
|
|
15
|
+
/**
|
|
16
|
+
* Optional client-supplied trace identifier. The API echoes this value in `X-Trace-ID` and includes it in request logs for client-side correlation.
|
|
17
|
+
*/
|
|
18
|
+
xTraceId?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
export type VectorizeSVGResponseResult =
|
|
14
22
|
| shared.PublicErrorEnvelope
|
|
15
23
|
| shared.SvgResponse
|
|
@@ -23,6 +31,35 @@ export type VectorizeSVGResponse = {
|
|
|
23
31
|
| EventStream<shared.SvgStreamEvent>;
|
|
24
32
|
};
|
|
25
33
|
|
|
34
|
+
/** @internal */
|
|
35
|
+
export type VectorizeSVGRequest$Outbound = {
|
|
36
|
+
VectorizeSVGRequest: shared.VectorizeSVGRequest$Outbound;
|
|
37
|
+
"x-trace-id"?: string | undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
export const VectorizeSVGRequest$outboundSchema: z.ZodType<
|
|
42
|
+
VectorizeSVGRequest$Outbound,
|
|
43
|
+
z.ZodTypeDef,
|
|
44
|
+
VectorizeSVGRequest
|
|
45
|
+
> = z.object({
|
|
46
|
+
vectorizeSVGRequest: shared.VectorizeSVGRequest$outboundSchema,
|
|
47
|
+
xTraceId: z.string().optional(),
|
|
48
|
+
}).transform((v) => {
|
|
49
|
+
return remap$(v, {
|
|
50
|
+
vectorizeSVGRequest: "VectorizeSVGRequest",
|
|
51
|
+
xTraceId: "x-trace-id",
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export function vectorizeSVGRequestToJSON(
|
|
56
|
+
vectorizeSVGRequest: VectorizeSVGRequest,
|
|
57
|
+
): string {
|
|
58
|
+
return JSON.stringify(
|
|
59
|
+
VectorizeSVGRequest$outboundSchema.parse(vectorizeSVGRequest),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
26
63
|
/** @internal */
|
|
27
64
|
export const VectorizeSVGResponseResult$inboundSchema: z.ZodType<
|
|
28
65
|
VectorizeSVGResponseResult,
|
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
ImageInputReferenceUrl$outboundSchema,
|
|
15
15
|
} from "./imageinputreferenceurl.js";
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Image input reference. Accepts a network image URL or a base64-encoded image payload. Decoded images must be no larger than 12582912 bytes, 4096x4096 pixels, or 16777216 total pixels. Accepted direct media types: image/png, image/jpeg, image/webp, image/gif, image/svg+xml.
|
|
19
|
+
*/
|
|
17
20
|
export type ImageInputReference =
|
|
18
21
|
| ImageInputReferenceUrl
|
|
19
22
|
| ImageInputReferenceBase64;
|
|
@@ -6,7 +6,7 @@ import * as z from "zod/v3";
|
|
|
6
6
|
|
|
7
7
|
export type ImageInputReferenceBase64 = {
|
|
8
8
|
/**
|
|
9
|
-
* Base64-encoded image payload.
|
|
9
|
+
* Base64-encoded image payload. Decoded images must be no larger than 12582912 bytes, 4096x4096 pixels, or 16777216 total pixels. Accepted direct media types: image/png, image/jpeg, image/webp, image/gif, image/svg+xml.
|
|
10
10
|
*/
|
|
11
11
|
base64: string;
|
|
12
12
|
};
|
|
@@ -6,7 +6,7 @@ import * as z from "zod/v3";
|
|
|
6
6
|
|
|
7
7
|
export type ImageInputReferenceUrl = {
|
|
8
8
|
/**
|
|
9
|
-
* Network image URL. Only http/https URLs are allowed.
|
|
9
|
+
* Network image URL. Only http/https URLs are allowed. The API fetches the URL, follows up to 3 redirects, blocks private or reserved network targets, requires an image response content type, and applies the same decoded image limits as base64 inputs.
|
|
10
10
|
*/
|
|
11
11
|
url: string;
|
|
12
12
|
};
|
|
@@ -18,7 +18,6 @@ export const Code = {
|
|
|
18
18
|
InsufficientCredits: "insufficient_credits",
|
|
19
19
|
AccountFrozen: "account_frozen",
|
|
20
20
|
ModelNotFound: "model_not_found",
|
|
21
|
-
UpstreamError: "upstream_error",
|
|
22
21
|
InternalError: "internal_error",
|
|
23
22
|
} as const;
|
|
24
23
|
export type Code = ClosedEnum<typeof Code>;
|
|
@@ -24,6 +24,9 @@ export type VectorizeSVGRequest = {
|
|
|
24
24
|
* Auto-crop image to the dominant subject before vectorization.
|
|
25
25
|
*/
|
|
26
26
|
autoCrop?: boolean | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Image input reference. Accepts a network image URL or a base64-encoded image payload. Decoded images must be no larger than 12582912 bytes, 4096x4096 pixels, or 16777216 total pixels. Accepted direct media types: image/png, image/jpeg, image/webp, image/gif, image/svg+xml.
|
|
29
|
+
*/
|
|
27
30
|
image: ImageInputReference;
|
|
28
31
|
/**
|
|
29
32
|
* Upper bound for output token count.
|
package/src/sdk/vectorizesvg.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from "../funcs/vectorizeSVGVectorizeSVG.js";
|
|
9
9
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
10
10
|
import * as operations from "./models/operations/index.js";
|
|
11
|
-
import * as shared from "./models/shared/index.js";
|
|
12
11
|
import { unwrapAsync } from "./types/fp.js";
|
|
13
12
|
|
|
14
13
|
export { VectorizeSVGAcceptEnum } from "../funcs/vectorizeSVGVectorizeSVG.js";
|
|
@@ -21,7 +20,7 @@ export class VectorizeSVG extends ClientSDK {
|
|
|
21
20
|
* Converts an image input into an SVG output.
|
|
22
21
|
*/
|
|
23
22
|
async vectorizeSVG(
|
|
24
|
-
request:
|
|
23
|
+
request: operations.VectorizeSVGRequest,
|
|
25
24
|
options?: RequestOptions & {
|
|
26
25
|
acceptHeaderOverride?: VectorizeSVGAcceptEnum;
|
|
27
26
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param obj The object to walk
|
|
3
|
-
* @param key The key path to walk the object with
|
|
4
|
-
* @param def A default value to return if the result is undefined
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* dlv(obj, "a.b.c.d")
|
|
8
|
-
* @example
|
|
9
|
-
* dlv(object, ["a", "b", "c", "d"])
|
|
10
|
-
* @example
|
|
11
|
-
* dlv(object, "foo.bar.baz", "Hello, default value!")
|
|
12
|
-
*/
|
|
13
|
-
export declare function dlv<T = any>(obj: any, key: string | string[], def?: T, p?: number, undef?: never): T | undefined;
|
|
14
|
-
//# sourceMappingURL=dlv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dlv.d.ts","sourceRoot":"","sources":["../../../src/lib/dlv.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EACzB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACtB,GAAG,CAAC,EAAE,CAAC,EACP,CAAC,CAAC,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,KAAK,GACZ,CAAC,GAAG,SAAS,CAOf"}
|