@fabriktor/client 0.0.84 → 0.0.86

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.
@@ -3,6 +3,7 @@ export type IdempotencyStore = {
3
3
  get(method: string, path: string): string;
4
4
  reset(method: string, path: string): void;
5
5
  };
6
+ export declare function newIdempotencyKey(): string;
6
7
  export declare class DefaultIdempotencyStore implements IdempotencyStore {
7
8
  private tokens;
8
9
  get(method: string, path: string): string;
@@ -5,7 +5,7 @@
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
6
  import { HeaderIdempotency, HTTPMethodPatch, HTTPMethodPost, } from "@fabriktor/schema";
7
7
  export const idempotentMethods = new Set([HTTPMethodPost, HTTPMethodPatch]);
8
- function newToken() {
8
+ export function newIdempotencyKey() {
9
9
  return crypto.randomUUID();
10
10
  }
11
11
  function key(method, path) {
@@ -19,7 +19,7 @@ export class DefaultIdempotencyStore {
19
19
  if (current) {
20
20
  return current;
21
21
  }
22
- const next = newToken();
22
+ const next = newIdempotencyKey();
23
23
  this.tokens.set(k, next);
24
24
  return next;
25
25
  }
@@ -111,6 +111,7 @@ export class JobsClient {
111
111
  }),
112
112
  method: HTTPMethodGet,
113
113
  token,
114
+ signal: opts?.signal,
114
115
  });
115
116
  }
116
117
  async immediateJobFromProgram(opts) {
@@ -8,6 +8,7 @@ import { requiredToken } from "../core/auth.js";
8
8
  import { queryParams, withQuery } from "../core/col.js";
9
9
  import { newCRUDClient } from "../core/crud.js";
10
10
  import { errInvalidArgument } from "../core/err.js";
11
+ import { newIdempotencyKey } from "../core/idempotency.js";
11
12
  import { newMultipartClient } from "../core/multipart.js";
12
13
  import { buildPath } from "../core/path.js";
13
14
  const fileFieldName = "file";
@@ -70,6 +71,10 @@ export class StorageClient {
70
71
  token,
71
72
  body,
72
73
  signal,
74
+ // Download is a read-only POST. Each invocation is a new read, including
75
+ // after an aborted request whose key may already be stored by the server.
76
+ // Do not share mutation retry keys with concurrent or later downloads.
77
+ idempotency_key: newIdempotencyKey(),
73
78
  });
74
79
  }
75
80
  async deleteOne(col, opts) {
@@ -60,6 +60,7 @@ export class UsersClient {
60
60
  }),
61
61
  method: HTTPMethodGet,
62
62
  token,
63
+ signal: opts.signal,
63
64
  });
64
65
  }
65
66
  async bootstrap(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {