Skip to content

Commit

Permalink
Implement missing HTTP API methods
Browse files Browse the repository at this point in the history
Fixes DE-148. Fixes DE-149. Fixes DE-150. Fixes DE-151. Fixes DE-906. Fixes DE-932. Fixes DE-939. Fixes DE-949.
  • Loading branch information
pluma4345 committed Jan 6, 2025
1 parent 99d469f commit ffac1e8
Show file tree
Hide file tree
Showing 5 changed files with 388 additions and 13 deletions.
38 changes: 27 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ This driver uses semantic versioning:

### Added

- Added `db.compact` method (DE-906)

- Added `db.engineStats` method (DE-932)

- Added `db.getLicense` and `db.setLicense` methods (DE-949)

- Added `db.listQueryCacheEntries` method (DE-149)

- Added `db.clearQueryCache` method (DE-148)

- Added `db.getQueryCacheProperties` method (DE-150)

- Added `db.setQueryCacheProperties` method (DE-151)

- Added `collection.shards` method (DE-939)

- Added support for `mdi-prefixed` indexes (DE-956)

- Restored `fulltext` index type support (DE-957)
Expand Down Expand Up @@ -466,13 +482,13 @@ for upgrading your code to arangojs v10.

### Added

- Added `database.availability` method
- Added `db.availability` method

- Added `database.engine` method (DE-931)
- Added `db.engine` method (DE-931)

- Added `database.status` method ([#811](https://github.com/arangodb/arangojs/issues/811))
- Added `db.status` method ([#811](https://github.com/arangodb/arangojs/issues/811))

- Added `database.supportInfo` method
- Added `db.supportInfo` method

- Added `keepNull` option to `CollectionInsertOptions` type (DE-946)

Expand Down Expand Up @@ -1567,7 +1583,7 @@ For a detailed list of changes between pre-release versions of v7 see the

- Changed `db.createDatabase` return type to `Database`

- Renamed `database.setQueryTracking` to `database.queryTracking`
- Renamed `db.setQueryTracking` to `db.queryTracking`

The method will now return the existing query tracking properties or set the
new query tracking properties depending on whether an argument is provided.
Expand Down Expand Up @@ -1963,7 +1979,7 @@ For a detailed list of changes between pre-release versions of v7 see the

- Added support for ArangoDB 3.5 Analyzers API

See the documentation of the `database.analyzer` method and the `Analyzer`
See the documentation of the `db.analyzer` method and the `Analyzer`
instances for information on using this API.

- Added `collection.getResponsibleShard` method
Expand Down Expand Up @@ -2137,7 +2153,7 @@ For a detailed list of changes between pre-release versions of v7 see the

- Fixed `edgeCollection.save` not respecting options ([#554](https://github.com/arangodb/arangojs/issues/554))

- Fixed `database.createDatabase` TypeScript signature ([#561](https://github.com/arangodb/arangojs/issues/561))
- Fixed `db.createDatabase` TypeScript signature ([#561](https://github.com/arangodb/arangojs/issues/561))

## [6.5.0] - 2018-08-03

Expand Down Expand Up @@ -2178,19 +2194,19 @@ For a detailed list of changes between pre-release versions of v7 see the

- Added `ArangoError` and `CollectionType` to public exports

- Added `database.close` method
- Added `db.close` method

- Added `opts` parameter to `EdgeCollection#save`

## [6.3.0] - 2018-06-20

### Added

- Added `database.version` method
- Added `db.version` method

- Added `database.login` method
- Added `db.login` method

- Added `database.exists` method
- Added `db.exists` method

- Added `collection.exists` method

Expand Down
77 changes: 77 additions & 0 deletions src/administration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@
* @packageDocumentation
*/

//#region Administrative operation options
/**
* Options for compacting all databases on the server.
*/
export type CompactOptions = {
/**
* Whether compacted data should be moved to the minimum possible level.
*
* Default: `false`.
*/
changeLevel?: boolean;
/**
* Whether to compact the bottom-most level of data.
*
* Default: `false`.
*/
compactBottomMostLevel?: boolean;
};
//#endregion

//#region Administrative operation results
/**
* Result of retrieving database version information.
*/
Expand Down Expand Up @@ -62,6 +83,59 @@ export type EngineInfo = {
};
};

/**
* Performance and resource usage information about the storage engine.
*/
export type EngineStatsInfo = Record<
string,
string | number | Record<string, number | string>
>;

/**
* Information about the server license.
*/
export type LicenseInfo = {
/**
* Properties of the license.
*/
features: {
/**
* The timestamp of the expiration date of the license in seconds since the
* Unix epoch.
*/
expires?: number;
};
/**
* The hash value of the license.
*/
hash: string;
/**
* The encrypted license key in base 64 encoding, or `"none"` when running
* in the Community Edition.
*/
license?: string;
/**
* The status of the installed license.
*
* - `"good"`: The license is valid for more than 2 weeks.
*
* - `"expiring"`: The license is valid for less than 2 weeks.
*
* - `"expired"`: The license has expired.
*
* - `"read-only"`: The license has been expired for more than 2 weeks.
*/
status: "good" | "expiring" | "expired" | "read-only";
/**
* Whether the server is performing a database upgrade.
*/
upgrading: boolean;
/**
* The license version number.
*/
version: number;
};

/**
* Information about the server status.
*/
Expand Down Expand Up @@ -326,7 +400,9 @@ export type ClusterSupportInfo = {
*/
host: Record<string, any>;
};
//#endregion

//#region Queue time metrics
/**
* An object providing methods for accessing queue time metrics of the most
* recently received server responses if the server supports this feature.
Expand All @@ -348,3 +424,4 @@ export interface QueueTimeMetrics {
*/
getAvg(): number;
}
//#endregion
41 changes: 41 additions & 0 deletions src/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,34 @@ export interface DocumentCollection<
CollectionDescription & { revision: string; checksum: string }
>
>;
/**
* Retrieves the collection's shard IDs.
*
* @param details - If set to `true`, the response will include the responsible
* servers for each shard.
*/
shards(
details?: false
): Promise<
connection.ArangoApiResponse<
CollectionDescription & CollectionProperties & { shards: string[] }
>
>;
/**
* Retrieves the collection's shard IDs and the responsible servers for each
* shard.
*
* @param details - If set to `false`, the response will only include the
* shard IDs without the responsible servers for each shard.
*/
shards(
details: true
): Promise<
connection.ArangoApiResponse<
CollectionDescription &
CollectionProperties & { shards: Record<string, string[]> }
>
>;
/**
* Renames the collection and updates the instance's `name` to `newName`.
*
Expand Down Expand Up @@ -2492,6 +2520,19 @@ export class Collection<
});
}

shards(
details?: boolean
): Promise<
connection.ArangoApiResponse<
CollectionDescription & CollectionProperties & { shards: any }
>
> {
return this._db.request({
pathname: `/_api/collection/${encodeURIComponent(this._name)}/shards`,
search: { details },
});
}

async rename(newName: string) {
const result = await this._db.renameCollection(this._name, newName);
this._name = newName;
Expand Down
Loading

0 comments on commit ffac1e8

Please sign in to comment.