@clipwright/core 0.31.0 → 0.33.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/CHANGELOG.md +59 -0
- package/dist/api-failure.d.ts +1 -0
- package/dist/api-failure.js +9 -4
- package/dist/api-failure.js.map +1 -1
- package/dist/assets.d.ts +262 -0
- package/dist/assets.js +121 -0
- package/dist/assets.js.map +1 -0
- package/dist/endpoints.js +11 -0
- package/dist/endpoints.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -1
- package/dist/faceless-price.d.ts +4 -0
- package/dist/faceless-price.js +4 -0
- package/dist/faceless-price.js.map +1 -1
- package/dist/generations.d.ts +16 -1
- package/dist/generations.js +3 -1
- package/dist/generations.js.map +1 -1
- package/dist/idempotency.d.ts +20 -0
- package/dist/idempotency.js +37 -0
- package/dist/idempotency.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/uploads.d.ts +79 -0
- package/dist/uploads.js +65 -7
- package/dist/uploads.js.map +1 -1
- package/package.json +6 -1
package/dist/uploads.js
CHANGED
|
@@ -10,7 +10,48 @@ export const UPLOAD_OBJECT_RETENTION_DAYS = 30;
|
|
|
10
10
|
/** No WebP on purpose: the probe cannot read its dimensions, and without them the format cannot be checked. */
|
|
11
11
|
export const UPLOAD_MEDIA_TYPES = ["image/png", "image/jpeg"];
|
|
12
12
|
export const UPLOADS_PATH = "/v1/uploads";
|
|
13
|
+
/** Remote uploads (clipwright#758): a server-side download, a presigned PUT, and the read that confirms one. */
|
|
14
|
+
export const UPLOAD_IMPORT_PATH = "/v1/uploads/import";
|
|
15
|
+
export const UPLOAD_INTENTS_PATH = "/v1/uploads/intents";
|
|
16
|
+
export const UPLOAD_ITEM_PATH = "/v1/uploads/:id";
|
|
17
|
+
/** A presigned PUT url lives 15 minutes; the intent it serves can be finished for a day. */
|
|
18
|
+
export const UPLOAD_PUT_URL_TTL_SECONDS = 900;
|
|
19
|
+
export const UPLOAD_INTENT_FINISH_SECONDS = 86_400;
|
|
20
|
+
/** The finisher's lease outlives its storage calls by 35 s, and those stay under the SDK's 30 s per request plus margin. */
|
|
21
|
+
export const UPLOAD_FINISH_LEASE_SECONDS = 60;
|
|
22
|
+
export const UPLOAD_FINISH_IO_DEADLINE_MS = 25_000;
|
|
23
|
+
/** A repeated key answers the earlier result only within a day and only while that result is still usable. */
|
|
24
|
+
export const IDEMPOTENCY_REPLAY_SECONDS = 86_400;
|
|
25
|
+
/** Outbound downloads: attempts per account per hour, imports at once per `api` instance, and one import's deadline. */
|
|
26
|
+
export const URL_FETCH_PER_HOUR = 30;
|
|
27
|
+
export const URL_FETCH_WINDOW_SECONDS = 3600;
|
|
28
|
+
export const URL_IMPORT_CONCURRENCY = 4;
|
|
29
|
+
export const URL_IMPORT_IMAGE_DEADLINE_MS = 20_000;
|
|
30
|
+
export const URL_IMPORT_MAX_REDIRECTS = 3;
|
|
31
|
+
/** The longest side a customer picture may have. */
|
|
32
|
+
export const UPLOAD_MAX_SIDE = 8192;
|
|
13
33
|
export const uploadId = z.string().regex(/^upl_[a-f0-9]{32}$/);
|
|
34
|
+
const sha256Hex = z.string().regex(/^[a-f0-9]{64}$/);
|
|
35
|
+
export const uploadImportRequest = z.strictObject({
|
|
36
|
+
url: z.string().url().startsWith("https://").max(2048),
|
|
37
|
+
});
|
|
38
|
+
/** `filename` is a hint for people and is not part of the request's identity. */
|
|
39
|
+
export const uploadIntentRequest = z.strictObject({
|
|
40
|
+
media_type: z.enum(UPLOAD_MEDIA_TYPES),
|
|
41
|
+
bytes: z.number().int().positive().max(UPLOAD_MAX_BYTES),
|
|
42
|
+
sha256: sha256Hex,
|
|
43
|
+
filename: z.string().min(1).max(200).optional(),
|
|
44
|
+
});
|
|
45
|
+
export const uploadIntentResponse = z.strictObject({
|
|
46
|
+
upload_id: uploadId,
|
|
47
|
+
put_url: z.string().url().startsWith("https://"),
|
|
48
|
+
put_headers: z.strictObject({
|
|
49
|
+
"content-type": z.enum(UPLOAD_MEDIA_TYPES),
|
|
50
|
+
"content-length": z.string().regex(/^\d+$/),
|
|
51
|
+
}),
|
|
52
|
+
expires_at: z.string().datetime(),
|
|
53
|
+
finish_by: z.string().datetime(),
|
|
54
|
+
});
|
|
14
55
|
export const uploadResponse = z.object({
|
|
15
56
|
upload_id: uploadId,
|
|
16
57
|
content_digest: z.string().regex(/^[a-f0-9]{64}$/).describe("SHA-256 of the original uploaded bytes; use it as the workflow asset content_digest."),
|
|
@@ -21,6 +62,11 @@ export const uploadResponse = z.object({
|
|
|
21
62
|
height: z.number().int().positive(),
|
|
22
63
|
expires_at: z.string().datetime(),
|
|
23
64
|
});
|
|
65
|
+
/** `GET /v1/uploads/{id}`: one upload with a link signed now, and when a generation or revision stops taking it. */
|
|
66
|
+
export const uploadItemResponse = uploadResponse.extend({ usable_until: z.string().datetime() });
|
|
67
|
+
export const uploadItemRead = uploadItemResponse.extend({
|
|
68
|
+
media_type: z.string().min(1), bytes: z.number().int().positive(),
|
|
69
|
+
}).loose();
|
|
24
70
|
/** `GET /v1/uploads`: the account's uploads a revision still takes, newest first, one per picture, each with a link signed now. */
|
|
25
71
|
export const uploadList = z.strictObject({
|
|
26
72
|
uploads: z.array(z.strictObject({
|
|
@@ -50,11 +96,23 @@ export function sniffUploadMediaType(bytes) {
|
|
|
50
96
|
export function uploadExtension(mediaType) {
|
|
51
97
|
return mediaType === "image/png" ? "png" : "jpg";
|
|
52
98
|
}
|
|
53
|
-
export const UPLOAD_IMAGE_DESCRIPTION = "
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"and content_digest directly: it is the SHA-256 of the original
|
|
59
|
-
"
|
|
99
|
+
export const UPLOAD_IMAGE_DESCRIPTION = "Get an upload_id and a signed https url for a PNG or JPEG up to 10 MB: from a LOCAL file (`path`, only when this " +
|
|
100
|
+
"server runs on your machine) or from a public https `url` that the server downloads (up to 20 seconds; redirects " +
|
|
101
|
+
"are followed up to 3 times). Pass the url as `image` to quote_ugc / make_ugc, and the upload_id as " +
|
|
102
|
+
"{upload_id, rights_confirmed: true} in references, first_frame or last_frame of quote_image, generate_image, " +
|
|
103
|
+
"quote_video and generate_video. The url is signed for 24 hours; the upload_id stays usable for 30 days. For " +
|
|
104
|
+
"workflow assets, use the upload_id as asset_id and content_digest directly: it is the SHA-256 of the original " +
|
|
105
|
+
"bytes. Set `aspect_ratio` EXPLICITLY to match the picture. For a file on your disk while this server is remote, " +
|
|
106
|
+
"use create_upload. Free: spends no credits; 20 uploads per day per account, and at most 30 url downloads per hour.";
|
|
107
|
+
export const CREATE_UPLOAD_DESCRIPTION = "Upload a LOCAL PNG or JPEG (up to 10 MB) through a one-time presigned PUT; use it when this server is remote and " +
|
|
108
|
+
"you have a shell. Pass media_type, the exact size in bytes and the file's sha256 (`sha256sum <file>` or " +
|
|
109
|
+
"`shasum -a 256 <file>`). Within 15 minutes run: `curl -X PUT -H 'content-type: <media_type>' --data-binary " +
|
|
110
|
+
"@<file> '<put_url>'` (curl sends the content-length itself; both headers must match what you declared). Once the " +
|
|
111
|
+
"PUT finished, the upload_id works as {upload_id, rights_confirmed: true} in quote_image, generate_image, " +
|
|
112
|
+
"quote_video and generate_video; before that they answer upload_not_finished. Call get_upload to confirm and to " +
|
|
113
|
+
"read content_digest, width and height; other tools that take an upload_id need that call first. Use the " +
|
|
114
|
+
"upload_id within 24 hours. Free; counts toward 20 uploads per day.";
|
|
115
|
+
export const GET_UPLOAD_DESCRIPTION = "Read one upload by upload_id: a freshly signed https url, content_digest, media_type, bytes, width, height and " +
|
|
116
|
+
"usable_until. After create_upload it also confirms the PUT: it answers upload_not_finished until the file is " +
|
|
117
|
+
"there and upload_expired after 24 hours. Free.";
|
|
60
118
|
//# sourceMappingURL=uploads.js.map
|
package/dist/uploads.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../src/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,4IAA4I;AAC5I,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C,+GAA+G;AAC/G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,YAAY,CAAU,CAAC;AAGvE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../src/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,4IAA4I;AAC5I,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C,+GAA+G;AAC/G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,YAAY,CAAU,CAAC;AAGvE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAC1C,gHAAgH;AAChH,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAA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nH,0GAA0G;IAC1G,6GAA6G;IAC7G,mHAAmH;IACnH,2GAA2G;IAC3G,iHAAiH;IACjH,0GAA0G;IAC1G,oEAAoE,CAAC;AAEvE,MAAM,CAAC,MAAM,sBAAsB,GACjC,iHAAiH;IACjH,+GAA+G;IAC/G,gDAAgD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clipwright/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Zod schemas and the shared request/response contract of the Clipwright UGC video API",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/seocombat/clipwright-mcp.git",
|
|
8
|
+
"directory": "packages/core"
|
|
9
|
+
},
|
|
5
10
|
"license": "MIT",
|
|
6
11
|
"author": "Dimantika Sp. z o.o.",
|
|
7
12
|
"homepage": "https://clipwright.io/?ref=npm",
|