Skip to content

Commit

Permalink
feat(kv): changed "interfaces" into "types"
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Ricart <[email protected]>
  • Loading branch information
aricart committed Dec 5, 2024
1 parent cd48c79 commit 8951aab
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion core/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3",
"@nats-io/nuid": "jsr:@nats-io/[email protected]"
}
}
}
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"typedoc": "^0.26.10",
"typescript": "^5.5.4"
}
}
}
2 changes: 1 addition & 1 deletion jetstream/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47"
}
}
}
2 changes: 1 addition & 1 deletion jetstream/import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"test_helpers": "../test_helpers/mod.ts",
"@std/io": "jsr:@std/[email protected]"
}
}
}
2 changes: 1 addition & 1 deletion jetstream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"typedoc": "^0.26.10",
"typescript": "^5.6.3"
}
}
}
4 changes: 2 additions & 2 deletions kv/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nats-io/kv",
"version": "3.0.0-27",
"version": "3.0.0-28",
"exports": {
".": "./src/mod.ts",
"./internal": "./src/internal_mod.ts"
Expand Down Expand Up @@ -36,4 +36,4 @@
"@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47",
"@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-34"
}
}
}
2 changes: 1 addition & 1 deletion kv/import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2",
"@std/io": "jsr:@std/[email protected]"
}
}
}
4 changes: 2 additions & 2 deletions kv/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nats-io/kv",
"version": "3.0.0-27",
"version": "3.0.0-28",
"files": [
"lib/",
"LICENSE",
Expand Down Expand Up @@ -43,4 +43,4 @@
"typedoc": "^0.26.10",
"typescript": "^5.6.3"
}
}
}
46 changes: 23 additions & 23 deletions kv/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
} from "@nats-io/jetstream";
import type { Payload, QueuedIterator } from "@nats-io/nats-core";

export interface KvEntry {
export type KvEntry = {
bucket: string;
key: string;
value: Uint8Array;
Expand All @@ -42,23 +42,23 @@ export interface KvEntry {
* may throw an exception if there's a conversion error
*/
string(): string;
}
};

export interface KvWatchEntry extends KvEntry {
export type KvWatchEntry = KvEntry & {
isUpdate: boolean;
}
};

/**
* An interface for encoding and decoding values
* Generic type for encoding and decoding values
* before they are stored or returned to the client.
*/
export interface KvCodec<T> {
export type KvCodec<T> = {
encode(k: T): T;

decode(k: T): T;
}
};

export interface KvCodecs {
export type KvCodecs = {
/**
* Codec for Keys in the KV
*/
Expand All @@ -67,9 +67,9 @@ export interface KvCodecs {
* Codec for Data in the KV
*/
value: KvCodec<Uint8Array>;
}
};

export interface KvLimits {
export type KvLimits = {
/**
* Sets the specified description on the stream of the KV.
*/
Expand Down Expand Up @@ -130,9 +130,9 @@ export interface KvLimits {
* servers 2.10.x and better.
*/
compression?: boolean;
}
};

export interface KvStatus extends KvLimits {
export type KvStatus = KvLimits & {
/**
* The simple name for a Kv - this name is typically prefixed by `KV_`.
*/
Expand All @@ -157,9 +157,9 @@ export interface KvStatus extends KvLimits {
* 2.10.x and better.
*/
metadata?: Record<string, string>;
}
};

export interface KvOptions extends KvLimits {
export type KvOptions = KvLimits & {
/**
* How long to wait in milliseconds for a response from the KV
*/
Expand Down Expand Up @@ -188,7 +188,7 @@ export interface KvOptions extends KvLimits {
* 2.10.x and better.
*/
metadata?: Record<string, string>;
}
};

export enum KvWatchInclude {
/**
Expand Down Expand Up @@ -233,7 +233,7 @@ export type KvWatchOptions = {
resumeFromRevision?: number;
};

export interface RoKV {
export type RoKV = {
/**
* Returns the KvEntry stored under the key if it exists or null if not.
* Note that the entry returned could be marked with a "DEL" or "PURGE"
Expand Down Expand Up @@ -272,9 +272,9 @@ export interface RoKV {
* @param filter - default is all keys
*/
keys(filter?: string | string[]): Promise<QueuedIterator<string>>;
}
};

export interface KV extends RoKV {
export type KV = RoKV & {
/**
* Creates a new entry ensuring that the entry does not exist (or
* the current version is deleted or the key is purged)
Expand Down Expand Up @@ -332,22 +332,22 @@ export interface KV extends RoKV {
* effectively deletes all data stored under the KV.
*/
destroy(): Promise<boolean>;
}
};

export interface KvPutOptions {
export type KvPutOptions = {
/**
* If set the KV must be at the current sequence or the
* put will fail.
*/
previousSeq: number;
}
};

export interface KvDeleteOptions {
export type KvDeleteOptions = {
/**
* If set the KV must be at the current sequence or the
* put will fail.
*/
previousSeq: number;
}
};

export const kvPrefix = "KV_";
2 changes: 1 addition & 1 deletion obj/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47",
"@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-34"
}
}
}
2 changes: 1 addition & 1 deletion obj/import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2",
"@std/io": "jsr:@std/[email protected]"
}
}
}
2 changes: 1 addition & 1 deletion obj/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"typedoc": "^0.26.10",
"typescript": "^5.6.3"
}
}
}
2 changes: 1 addition & 1 deletion services/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47"
}
}
}
2 changes: 1 addition & 1 deletion services/import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2",
"@std/io": "jsr:@std/[email protected]"
}
}
}
2 changes: 1 addition & 1 deletion services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"typedoc": "^0.26.10",
"typescript": "^5.6.3"
}
}
}
2 changes: 1 addition & 1 deletion transport-deno/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3",
"@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2"
}
}
}
4 changes: 2 additions & 2 deletions transport-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"shx": "^0.3.3",
"typescript": "5.6.3",
"@nats-io/jetstream": "3.0.0-34",
"@nats-io/kv": "3.0.0-27",
"@nats-io/kv": "3.0.0-28",
"@nats-io/obj": "3.0.0-29"
}
}
}

0 comments on commit 8951aab

Please sign in to comment.