@lumavox/server 0.2.1 → 0.4.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/dist/upload.d.ts CHANGED
@@ -6,9 +6,11 @@
6
6
  *
7
7
  * - **The `PUT` carries no credential** — the URL is signed — and exactly
8
8
  * the `Content-Type` the ticket was asked for, which is signed into it.
9
- * - **Its timer is the ticket's lifetime** unless the caller sets one: the
10
- * URL is refused after it anyway, and a large file on a slow link is not
11
- * a call that timed out at the client's 30 s — and then sent twice more.
9
+ * - **Its timer runs to the ticket's `expires_at`** unless the caller sets
10
+ * one: the URL is refused after it anyway, and a large file on a slow
11
+ * link is not a call that timed out at the client's 30 s — and then sent
12
+ * twice more. A minute at least: the instant is the API's clock, and a
13
+ * machine whose clock runs ahead would otherwise time out at once.
12
14
  * - **A Blob, an ArrayBuffer or a typed array; a stream only with its
13
15
  * `size`**: a signed `PUT` needs `Content-Length`, which a stream cannot
14
16
  * say. On Workers the stream goes through `FixedLengthStream`, which is
@@ -30,8 +32,8 @@ export declare const sizeOf: (data: UploadData, size?: number) => number | undef
30
32
  export declare const typeOf: (data: UploadData, type?: string | null) => string;
31
33
  /** `type`, or a `TypeError` naming what to pass. */
32
34
  export declare function needType(data: UploadData, type?: string | null): string;
33
- /** The bytes, to a ticket's signed URL, valid for its `expires_in` seconds. */
35
+ /** The bytes, to a ticket's signed URL, valid until its `expires_at`. */
34
36
  export declare function put(api: Transport, ticket: {
35
37
  url: string;
36
- expires_in: number;
38
+ expires_at: string;
37
39
  }, data: UploadData, type: string, options: UploadOptions): Promise<void>;
package/dist/upload.js CHANGED
@@ -14,7 +14,9 @@ export function needType(data, type) {
14
14
  throw new TypeError("This upload needs its content_type.");
15
15
  return found;
16
16
  }
17
- /** The bytes, to a ticket's signed URL, valid for its `expires_in` seconds. */
17
+ /** The least time a `PUT` is given, whatever the ticket's clock says. */
18
+ const MIN_PUT_MS = 60_000;
19
+ /** The bytes, to a ticket's signed URL, valid until its `expires_at`. */
18
20
  export async function put(api, ticket, data, type, options) {
19
21
  let raw = data;
20
22
  const headers = {};
@@ -30,5 +32,9 @@ export async function put(api, ticket, data, type, options) {
30
32
  if (Fixed)
31
33
  raw = data.pipeThrough(new Fixed(size));
32
34
  }
33
- await api.request({ method: "PUT", path: ticket.url, raw, type, headers, open: true }, { ...options, timeoutMs: options.timeoutMs ?? ticket.expires_in * 1000 });
35
+ await api.request({ method: "PUT", path: ticket.url, raw, type, headers, open: true }, {
36
+ ...options,
37
+ timeoutMs: options.timeoutMs ??
38
+ Math.max(Date.parse(ticket.expires_at) - Date.now(), MIN_PUT_MS),
39
+ });
34
40
  }
package/dist/wait.d.ts CHANGED
@@ -6,9 +6,9 @@
6
6
  *
7
7
  * - **One set of in-progress states for every kind**: a generation is
8
8
  * `queued`, `submitted` or `running`, the rest `pending`, and a
9
- * knowledge file or page `importing` before that — which the document
10
- * does not list (left-overs #113; `STATUSES` in
11
- * `apps/api/src/knowledge/service.ts`). Anything else — `succeeded`,
9
+ * knowledge file or page `importing` before that (`STATUSES` in
10
+ * `apps/api/src/knowledge/service.ts`), which the document lists only
11
+ * since api 0.31.10. Anything else — `succeeded`,
12
12
  * `failed`, `moderated`, `ready`, or a state this release does not know
13
13
  * — ends the wait, so a new one cannot hang a caller.
14
14
  * - **It answers the last read, never throws for a failure**: a `failed`
@@ -27,13 +27,9 @@
27
27
  * the root `CLAUDE.md`; in their first second, 250 are.
28
28
  */
29
29
  import { type RequestOptions } from "./transport.js";
30
- /**
31
- * A job as each kind's read answers it: with a `status` — which the
32
- * document lets an asset and an entry leave out (it has a default), and
33
- * which, absent, is no work in progress.
34
- */
30
+ /** A job as each kind's read answers it: with its `status`. */
35
31
  export interface Job {
36
- status?: string;
32
+ status: string;
37
33
  }
38
34
  /**
39
35
  * Reads `read` until its status is final, starting from `first` (a job
package/dist/wait.js CHANGED
@@ -6,9 +6,9 @@
6
6
  *
7
7
  * - **One set of in-progress states for every kind**: a generation is
8
8
  * `queued`, `submitted` or `running`, the rest `pending`, and a
9
- * knowledge file or page `importing` before that — which the document
10
- * does not list (left-overs #113; `STATUSES` in
11
- * `apps/api/src/knowledge/service.ts`). Anything else — `succeeded`,
9
+ * knowledge file or page `importing` before that (`STATUSES` in
10
+ * `apps/api/src/knowledge/service.ts`), which the document lists only
11
+ * since api 0.31.10. Anything else — `succeeded`,
12
12
  * `failed`, `moderated`, `ready`, or a state this release does not know
13
13
  * — ends the wait, so a new one cannot hang a caller.
14
14
  * - **It answers the last read, never throws for a failure**: a `failed`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumavox/server",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "The Lumavox API from your server: end users, ephemeral keys and the rest, typed from the published OpenAPI document. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "type": "module",