/**
* To authenticate yourself, you need to provide the following:
*
* - `apiKey` belonging to your team.
* - `db` database name to connect to.
*
* To create a new API key or a database, go to
*/
export type HollowClientOptions = {
apiKey: string;
db: string;
region?: string;
provider?: string;
};
type BlockchainOption = {
/**
* Specify whether to store the value on blockchain (Arweave).
*
* If `undefined`, it defaults to storing the value on blockchain.
*/
blockchain?: 'arweave' | 'none';
};
type ExpireOption = {
/** Specify an expiration time (seconds) for your data. */
expire?: number;
};
/**
* **[HollowDB Client](https://docs.hollowdb.xyz/hollowdb/hollowdb-as-a-service#hollowdb-client)**
*
* HollowDB client provides a very simple interface, abstracting everything behind
* the scenes. Create a new client with `new` static function:
*
* ```ts
* const client = await HollowClient.new({
* apiKey: 'your-api-key',
* db: 'your-database-name',
* });
* ```
*
*
* You can do the 4 basic CRUD operations as shown below:
*
* ```ts
* await client.get(KEY);
* await client.put(KEY, VALUE);
* await client.update(KEY, VALUE);
* await client.remove(KEY);
* ```
*
* You can also do a multi-get:
*
* ```ts
* await client.getMulti([KEY1, KEY2, ...]);
* ```
*/
export class HollowClient {
protected readonly apiKey: string;
protected readonly db: string;
protected authToken: string;
protected readonly apiVersion = "v0";
protected BASE_URL: string;
private constructor();
/**
* Creates & authenticates a HollowDB client.
*
* ```ts
* type ValueType = {foo: number, bar: string};
*
* client = await HollowClient.new({
* apiKey: 'your-api-key',
* db: 'your-database-name',
* });
* ```
*
* You can provide a value type to the function to make all functions treat that type
* as the value type for your key-value database.
*/
static new(options: HollowClientOptions): Promise>;
/**
* **Returns the value at the given key.**
*
* This operation does not require proofs.
*
* If the key does not exist, `null` will be returned.
*/
get(key: string): Promise;
/**
* **Returns the value at the given keys.**
*
* This operation does not require proofs.
*
* The returned array is an array of values where `value[i]` is
* belongs to `key[i]`. If a key does not exist, `null` is returned
* for that key.
*/
getMulti(keys: string[]): Promise<(T | null)[]>;
/**
* **Puts a value at the given key.**
*
* The target key must be empty, i.e. this is not an upsert operation.
*
* This operation does not require proofs even if zero-knowledge is enabled.
*/
put(key: string, value: T, options?: ExpireOption): Promise;
put(key: string, value: T, options?: BlockchainOption): Promise;
/**
* **Puts an array of key-value pairs.**
*
* The target keys must be empty, i.e. this is not an upsert operation.
*
* This operation does not require proofs even if zero-knowledge is enabled.
*
* Returns an array of booleans that indicate whether each key-value pair has
* been succesfully put or not.
*
*/
putMulti(pairs: {
key: string;
value: T;
options?: ExpireOption;
}[]): Promise;
putMulti(pairs: {
key: string;
value: T;
options?: BlockchainOption;
}[]): Promise;
/** **Updates a value at the given key.**
*
* A zero-knowledge proof is optionally provided, which the service
* expects if the connected database has proofs enabled.
*/
update(key: string, value: T, proof?: object, options?: BlockchainOption): Promise;
update(key: string, value: T, proof?: object, options?: ExpireOption): Promise;
/** **Removes a value at the given key.**
*
* Subsequent `get` calls to this key shall return `null`.
*
* A zero-knowledge proof is optionally provided, which the service
* expects if the connected database has proofs enabled.
*/
remove(key: string, proof?: object, options?: BlockchainOption): Promise;
}
//# sourceMappingURL=index.d.ts.map