summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-04-27 16:59:02 +0200
committerGitHub <noreply@github.com>2023-04-27 16:59:02 +0200
commit3fbb31c3c1f85011db9cc616dab0ef113342d7dd (patch)
tree173ca12c04de234dde9bab451215a8379ac34d0e /cli/tsc
parentb0264bea7de1901c1b3ed764454290d10613d14b (diff)
feat(kv): return ok bool from atomic commit (#18873)
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts41
1 files changed, 28 insertions, 13 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index f169e0254..8613da2ab 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -1545,6 +1545,10 @@ declare namespace Deno {
* relative significance of the types can be found in documentation for the
* {@linkcode Deno.KvKeyPart} type.
*
+ * Keys have a maximum size of 2048 bytes serialized. If the size of the key
+ * exceeds this limit, an error will be thrown on the operation that this key
+ * was passed to.
+ *
* @category KV
*/
export type KvKey = readonly KvKeyPart[];
@@ -1758,10 +1762,16 @@ declare namespace Deno {
/** @category KV */
export interface KvCommitResult {
+ ok: true;
/** The versionstamp of the value committed to KV. */
versionstamp: string;
}
+ /** @category KV */
+ export interface KvCommitError {
+ ok: false;
+ }
+
/** **UNSTABLE**: New API, yet to be vetted.
*
* A check to perform as part of a {@linkcode Deno.AtomicOperation}. The check
@@ -1803,11 +1813,13 @@ declare namespace Deno {
*
* The `commit` method of an atomic operation returns a value indicating
* whether checks passed and mutations were performed. If the operation failed
- * because of a failed check, the return value will be `null`. If the
+ * because of a failed check, the return value will be a
+ * {@linkcode Deno.KvCommitError} with an `ok: false` property. If the
* operation failed for any other reason (storage error, invalid value, etc.),
* an exception will be thrown. If the operation succeeded, the return value
- * will be a {@linkcode Deno.KvCommitResult} object containing the
- * versionstamp of the value committed to KV.
+ * will be a {@linkcode Deno.KvCommitResult} object with a `ok: true` property
+ * and the versionstamp of the value committed to KV.
+
*
* @category KV
*/
@@ -1857,17 +1869,19 @@ declare namespace Deno {
/**
* Commit the operation to the KV store. Returns a value indicating whether
* checks passed and mutations were performed. If the operation failed
- * because of a failed check, the return value will be `null`. If the
- * operation failed for any other reason (storage error, invalid value,
- * etc.), an exception will be thrown. If the operation succeeded, the
- * return value will be a {@linkcode Deno.KvCommitResult} object containing
- * the versionstamp of the value committed to KV.
+ * because of a failed check, the return value will be a {@linkcode
+ * Deno.KvCommitError} with an `ok: false` property. If the operation failed
+ * for any other reason (storage error, invalid value, etc.), an exception
+ * will be thrown. If the operation succeeded, the return value will be a
+ * {@linkcode Deno.KvCommitResult} object with a `ok: true` property and the
+ * versionstamp of the value committed to KV.
*
- * If the commit returns `null`, one may create a new atomic operation with
- * updated checks and mutations and attempt to commit it again. See the note
- * on optimistic locking in the documentation for {@linkcode Deno.AtomicOperation}.
+ * If the commit returns `ok: false`, one may create a new atomic operation
+ * with updated checks and mutations and attempt to commit it again. See the
+ * note on optimistic locking in the documentation for
+ * {@linkcode Deno.AtomicOperation}.
*/
- commit(): Promise<KvCommitResult | null>;
+ commit(): Promise<KvCommitResult | KvCommitError>;
}
/** **UNSTABLE**: New API, yet to be vetted.
@@ -1901,7 +1915,8 @@ declare namespace Deno {
* maximum length of 64 KiB after serialization. Serialization of both keys
* and values is somewhat opaque, but one can usually assume that the
* serialization of any value is about the same length as the resulting string
- * of a JSON serialization of that same value.
+ * of a JSON serialization of that same value. If theses limits are exceeded,
+ * an exception will be thrown.
*
* @category KV
*/