@clickraft/cli 0.1.3 → 0.1.5
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 +2 -3
- package/dist/cli.js +39 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.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([
|
|
@@ -2159,9 +2189,7 @@ var TokenRowSchema = z6.object({
|
|
|
2159
2189
|
expiresAt: z6.string(),
|
|
2160
2190
|
createdAt: z6.string()
|
|
2161
2191
|
}).strict();
|
|
2162
|
-
var TokensListResponseSchema = z6.
|
|
2163
|
-
tokens: z6.array(TokenRowSchema)
|
|
2164
|
-
}).strict();
|
|
2192
|
+
var TokensListResponseSchema = z6.array(TokenRowSchema);
|
|
2165
2193
|
async function listTokens(options) {
|
|
2166
2194
|
const config = await loadConfig({
|
|
2167
2195
|
flagProfile: options.profile,
|
|
@@ -2178,7 +2206,7 @@ async function listTokens(options) {
|
|
|
2178
2206
|
responseSchema: TokensListResponseSchema,
|
|
2179
2207
|
signal: options.signal
|
|
2180
2208
|
});
|
|
2181
|
-
return data
|
|
2209
|
+
return data;
|
|
2182
2210
|
}
|
|
2183
2211
|
|
|
2184
2212
|
// src/errors/format.ts
|