@clickraft/cli 0.1.2 → 0.1.4
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/CHANGELOG.md +3 -2
- package/dist/cli.js +42 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.js +42 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
## [0.1.
|
|
1
|
+
## [0.1.4](https://github.com/clickraft/cli/compare/v0.1.3...v0.1.4) (2026-05-23)
|
|
2
2
|
|
|
3
3
|
### Bug Fixes
|
|
4
4
|
|
|
5
|
-
* **
|
|
5
|
+
* **errors:** surface zod issue path in E_SCHEMA_MISMATCH messages ([723cc29](https://github.com/clickraft/cli/commit/723cc29cd65c8c34de523ce49974bd2504a119dd))
|
|
6
|
+
* **schemas:** allow null estimatedSeconds in POST /jobs response ([52a96b0](https://github.com/clickraft/cli/commit/52a96b0439be9cb2554b9cf192956c5afd731d37))
|
|
6
7
|
|
|
7
8
|
# Changelog
|
|
8
9
|
|
package/dist/cli.js
CHANGED
|
@@ -322,6 +322,31 @@ function toEnvelopeCode(code) {
|
|
|
322
322
|
}
|
|
323
323
|
var SIGINT_EXIT_CODE = 130;
|
|
324
324
|
|
|
325
|
+
// src/errors/schema-mismatch.ts
|
|
326
|
+
var MAX_ISSUES = 5;
|
|
327
|
+
function formatSchemaIssues(error) {
|
|
328
|
+
const issues = error.issues;
|
|
329
|
+
const shown = issues.slice(0, MAX_ISSUES).map(formatIssue);
|
|
330
|
+
const remaining = issues.length - shown.length;
|
|
331
|
+
const joined = shown.join("; ");
|
|
332
|
+
return remaining > 0 ? `${joined} (+${remaining} more)` : joined;
|
|
333
|
+
}
|
|
334
|
+
function formatIssue(issue) {
|
|
335
|
+
const path = formatPath(issue.path);
|
|
336
|
+
if (issue.code === "invalid_type") {
|
|
337
|
+
return `${path}: ${issue.code} (expected ${issue.expected}, received ${issue.received})`;
|
|
338
|
+
}
|
|
339
|
+
if (issue.code === "invalid_string") {
|
|
340
|
+
const validation = typeof issue.validation === "string" ? issue.validation : Object.keys(issue.validation)[0] ?? "string";
|
|
341
|
+
return `${path}: ${issue.code} (${validation})`;
|
|
342
|
+
}
|
|
343
|
+
return `${path}: ${issue.code}`;
|
|
344
|
+
}
|
|
345
|
+
function formatPath(path) {
|
|
346
|
+
if (path.length === 0) return "(root)";
|
|
347
|
+
return path.map(String).join(".");
|
|
348
|
+
}
|
|
349
|
+
|
|
325
350
|
// src/api/idempotency.ts
|
|
326
351
|
import { createHash, randomUUID } from "crypto";
|
|
327
352
|
function generateIdempotencyKey() {
|
|
@@ -589,12 +614,17 @@ function parseSuccessBody(args) {
|
|
|
589
614
|
}
|
|
590
615
|
const envelope = ServerSuccessSchema(args.responseSchema ?? z2.unknown()).safeParse(parsed);
|
|
591
616
|
if (!envelope.success) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
617
|
+
const issues = formatSchemaIssues(envelope.error);
|
|
618
|
+
throw new ApiError(
|
|
619
|
+
"SCHEMA_MISMATCH",
|
|
620
|
+
`Server response did not match the expected schema. Issues: ${issues}`,
|
|
621
|
+
{
|
|
622
|
+
status: args.statusCode,
|
|
623
|
+
requestId: args.requestId,
|
|
624
|
+
retryable: false,
|
|
625
|
+
redactedBody: redactAndTruncate(args.bodyText)
|
|
626
|
+
}
|
|
627
|
+
);
|
|
598
628
|
}
|
|
599
629
|
return envelope.data.data;
|
|
600
630
|
}
|
|
@@ -835,7 +865,7 @@ var GenerateCreateRequestSchema = z3.object({
|
|
|
835
865
|
var GenerateCreateResponseSchema = z3.object({
|
|
836
866
|
jobId: z3.string().uuid(),
|
|
837
867
|
status: z3.enum(["queued", "processing", "completed", "failed"]),
|
|
838
|
-
estimatedSeconds: z3.number().int().nonnegative(),
|
|
868
|
+
estimatedSeconds: z3.number().int().nonnegative().nullable(),
|
|
839
869
|
creditsCharged: z3.number().int().nonnegative()
|
|
840
870
|
}).strict();
|
|
841
871
|
var GenerationStatusSchema = z3.enum([
|
|
@@ -864,8 +894,8 @@ var GenerationResultSchema = z3.object({
|
|
|
864
894
|
errorMessage: z3.string().nullable(),
|
|
865
895
|
creditsCharged: z3.number().int().nonnegative(),
|
|
866
896
|
creditsRefunded: z3.boolean(),
|
|
867
|
-
startedAt: z3.string().
|
|
868
|
-
completedAt: z3.string().
|
|
897
|
+
startedAt: z3.string().nullable(),
|
|
898
|
+
completedAt: z3.string().nullable()
|
|
869
899
|
}).strict();
|
|
870
900
|
|
|
871
901
|
// src/commands/upload.ts
|
|
@@ -1276,7 +1306,7 @@ async function buildClient(opts) {
|
|
|
1276
1306
|
async function postAssetMetadata(args) {
|
|
1277
1307
|
return args.client.request({
|
|
1278
1308
|
method: "POST",
|
|
1279
|
-
path: "/
|
|
1309
|
+
path: "/assets",
|
|
1280
1310
|
body: {
|
|
1281
1311
|
filename: args.filename,
|
|
1282
1312
|
contentType: args.contentType,
|
|
@@ -1500,7 +1530,7 @@ async function generateGet(opts) {
|
|
|
1500
1530
|
const client = opts.client ?? await buildGenerateClient(opts);
|
|
1501
1531
|
return client.request({
|
|
1502
1532
|
method: "GET",
|
|
1503
|
-
path: `/
|
|
1533
|
+
path: `/jobs/${encodeURIComponent(opts.jobId)}`,
|
|
1504
1534
|
query: opts.waitSeconds && opts.waitSeconds > 0 ? { wait: opts.waitSeconds } : void 0,
|
|
1505
1535
|
responseSchema: GenerationResultSchema,
|
|
1506
1536
|
signal: opts.signal
|
|
@@ -1545,7 +1575,7 @@ async function generateCreate(opts) {
|
|
|
1545
1575
|
const body = buildRequestBody({ ...opts, referenceImages });
|
|
1546
1576
|
const created = await client.request({
|
|
1547
1577
|
method: "POST",
|
|
1548
|
-
path: "/
|
|
1578
|
+
path: "/jobs",
|
|
1549
1579
|
body,
|
|
1550
1580
|
responseSchema: GenerateCreateResponseSchema,
|
|
1551
1581
|
signal: opts.signal
|