craterview 0.3.18 → 0.3.19

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 (3) hide show
  1. package/README.md +9 -9
  2. package/index.ts +16 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -164,17 +164,17 @@ Every field the API publishes on a job is exposed here.
164
164
  | `etaSeconds` | Seconds until the job is expected to finish, recomputed on every read — it counts down while the job runs. Absent once the job has settled. Estimated for your image's size when `upload()` could read it (or when you pass `inputMegapixels` to `submit()`), for a typical image otherwise |
165
165
  | `community` | True when the job is on the community queue: served after priority work, always taking a share of it, so it never stalls behind paid work |
166
166
  | `outputUrl`, `downloadUrl` | The result, presigned. One to display, one to save |
167
- | `thumbUrl` | A small JPEG of the result, for listings. Null when none was drawn |
167
+ | `thumbnailUrl` | A small JPEG of the job's picture, for listings — the result, or what the model worked from when it produced no file. Null when none was drawn |
168
168
  | `inputUrl` | The picture the model worked from — the region, where you named one |
169
169
  | `alphaUrl` | Only for a JPEG result of a picture with transparency, which JPEG cannot hold: the transparency as a grayscale JPEG, white where opaque. The result is then the colour alone |
170
170
  | `contentType` | The result's media type |
171
171
  | `outputBytes` | The result's size in bytes |
172
172
  | `blob()`, `arrayBuffer()` | Download the result |
173
173
 
174
- `result` is the whole of what the job produced, and the five rows above it that describe the
175
- file are getters onto `result.output` rather than separate fields — the API states those links
176
- once. A model with no file to hand back returns its answer in `result` and leaves every one of
177
- them null; the fields it answers with are its `result_schema` in `cv.models()`.
174
+ `result` is the whole of what the job produced, and the rows above it that describe the
175
+ result's file are getters onto `result.output` rather than separate fields — the API states
176
+ those links once. A model with no file to hand back returns its answer in `result` and leaves
177
+ every one of them null; the fields it answers with are its `result_schema` in `cv.models()`.
178
178
 
179
179
  `credits` is the only figure about cost the API states, and the price is fixed and published
180
180
  per model, so an invoice reconciles against `credits` alone. For how long a job took, subtract
@@ -198,13 +198,13 @@ a longer one.
198
198
  is signed in, so the second cannot be derived from the first. Both expire, so fetch the
199
199
  result rather than storing the link.
200
200
 
201
- `thumbUrl` and `inputUrl` are for building a job listing: a few-hundred-pixel preview so a
202
- page of results costs kilobytes, and the picture the model worked from so a result can be
201
+ `thumbnailUrl` and `inputUrl` are for building a job listing: a few-hundred-pixel preview so a
202
+ page of jobs costs kilobytes, and the picture the model worked from so a result can be
203
203
  shown against it. Where you named a region, `inputUrl` is that region — so a before-and-after
204
204
  is a true pair, and what was used is something you can look at rather than something to take
205
205
  on trust. It is not the file you uploaded: yours stays yours and is removed on its own
206
- schedule. Both expire with the result. A model that produces no file has no `thumbUrl`, but still
207
- has the picture it answered about.
206
+ schedule. Both expire with the job's other pictures. A model that produces no file has no
207
+ result to preview, so `thumbnailUrl` is a preview of the picture it answered about.
208
208
 
209
209
  ## Webhooks
210
210
 
package/index.ts CHANGED
@@ -18,7 +18,7 @@ import { imageSize } from "image-size";
18
18
  // Mirrored from package.json, which is the number a release bumps. It cannot be imported
19
19
  // from there — this ships as TypeScript, so the import would have to resolve in the
20
20
  // consumer's toolchain — so test/version.test.ts asserts the two agree.
21
- export const VERSION = "0.3.18";
21
+ export const VERSION = "0.3.19";
22
22
  const DEFAULT_BASE_URL = "https://api.craterview.ai";
23
23
  // The server rejects a longer wait outright, so asking for one costs a 422 rather than the
24
24
  // wait you asked for. `run()` clamps to this rather than letting that happen.
@@ -395,6 +395,12 @@ export interface JobData {
395
395
  * read them out of `result.output`.
396
396
  */
397
397
  result?: Record<string, unknown> | null;
398
+ /**
399
+ * A small JPEG of the job's picture, for a listing: the result, or the image the model
400
+ * worked from when it produced no file. Absent until the job succeeds, where none could be
401
+ * drawn, and once the job's pictures are deleted.
402
+ */
403
+ thumbnail_url?: string | null;
398
404
  /** Whole credits. TypeScript cannot say integer, but the API only ever sends one. */
399
405
  credits?: number | null;
400
406
  eta_seconds?: number | null;
@@ -423,17 +429,18 @@ export interface JobData {
423
429
  * by the same names.
424
430
  *
425
431
  * `result` is the whole of what the job produced. Where the model wrote a file,
426
- * `result.output` carries its links, and `outputUrl` / `downloadUrl` / `thumbUrl` /
432
+ * `result.output` carries its links, and `outputUrl` / `downloadUrl` /
427
433
  * `contentType` / `outputBytes` read out of it. `outputUrl` and `downloadUrl` are the same
428
434
  * object signed two ways: one to display, one to hand a person as a file. The disposition
429
435
  * is signed in, so the second cannot be derived from the first without the storage
430
436
  * credential. Both are presigned and expire — fetch the result rather than storing the link.
431
437
  *
432
- * `thumbUrl` is a small JPEG of the result, for showing a page of jobs without downloading
433
- * a page of full-size outputs. `inputUrl` is the picture the model worked from, so a result
434
- * can be shown against what it was made from. Both expire with the result. `alphaUrl` is
435
- * there only when you asked for a JPEG of a picture with transparency: the transparency, as
436
- * a file of its own.
438
+ * `thumbnailUrl` is a small JPEG of the job's picture — the result, or the image the model
439
+ * worked from when it produced no file — for showing a page of jobs without downloading a
440
+ * page of full-size pictures. `inputUrl` is the picture the model worked from, so a result
441
+ * can be shown against what it was made from. Both expire with the job's other pictures.
442
+ * `alphaUrl` is there only when you asked for a JPEG of a picture with transparency: the
443
+ * transparency, as a file of its own.
437
444
  *
438
445
  * `etaSeconds` is the whole of what is reported about waiting: how long until the result,
439
446
  * counting time spent waiting for a GPU as well as time spent on one. An estimate and never
@@ -468,6 +475,8 @@ export class Job {
468
475
  get flagged() { return this.data.flagged ?? null; }
469
476
  /** Retained past the ordinary expiry because you asked. */
470
477
  get kept() { return this.data.kept ?? false; }
478
+ /** A small JPEG of the job's picture, for a listing. Null where there is none. */
479
+ get thumbnailUrl() { return this.data.thumbnail_url ?? null; }
471
480
  /** Where this job stands with the public gallery, or null when it is not offered. */
472
481
  get gallery() { return this.data.gallery ?? null; }
473
482
  /** The whole answer, including where the file is when there is one. */
@@ -491,7 +500,6 @@ export class Job {
491
500
  * the disposition is signed in, so re-signing needs the storage credential.
492
501
  */
493
502
  get downloadUrl() { return (this.output["download_url"] as string) ?? null; }
494
- get thumbUrl() { return (this.output["thumbnail_url"] as string) ?? null; }
495
503
  /**
496
504
  * A link to the picture the model worked from. Where you named a region, this is that
497
505
  * region — so what was used is something you can look at rather than something to take on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "craterview",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "dependencies": {
5
5
  "image-size": "^2.0.4"
6
6
  },