Skip to content

Commit ffac1e8

Browse files
committed
Implement missing HTTP API methods
Fixes DE-148. Fixes DE-149. Fixes DE-150. Fixes DE-151. Fixes DE-906. Fixes DE-932. Fixes DE-939. Fixes DE-949.
1 parent 99d469f commit ffac1e8

File tree

5 files changed

+388
-13
lines changed

5 files changed

+388
-13
lines changed

CHANGELOG.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ This driver uses semantic versioning:
1818

1919
### Added
2020

21+
- Added `db.compact` method (DE-906)
22+
23+
- Added `db.engineStats` method (DE-932)
24+
25+
- Added `db.getLicense` and `db.setLicense` methods (DE-949)
26+
27+
- Added `db.listQueryCacheEntries` method (DE-149)
28+
29+
- Added `db.clearQueryCache` method (DE-148)
30+
31+
- Added `db.getQueryCacheProperties` method (DE-150)
32+
33+
- Added `db.setQueryCacheProperties` method (DE-151)
34+
35+
- Added `collection.shards` method (DE-939)
36+
2137
- Added support for `mdi-prefixed` indexes (DE-956)
2238

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

467483
### Added
468484

469-
- Added `database.availability` method
485+
- Added `db.availability` method
470486

471-
- Added `database.engine` method (DE-931)
487+
- Added `db.engine` method (DE-931)
472488

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

475-
- Added `database.supportInfo` method
491+
- Added `db.supportInfo` method
476492

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

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

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

1570-
- Renamed `database.setQueryTracking` to `database.queryTracking`
1586+
- Renamed `db.setQueryTracking` to `db.queryTracking`
15711587

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

19641980
- Added support for ArangoDB 3.5 Analyzers API
19651981

1966-
See the documentation of the `database.analyzer` method and the `Analyzer`
1982+
See the documentation of the `db.analyzer` method and the `Analyzer`
19671983
instances for information on using this API.
19681984

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

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

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

21422158
## [6.5.0] - 2018-08-03
21432159

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

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

2181-
- Added `database.close` method
2197+
- Added `db.close` method
21822198

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

21852201
## [6.3.0] - 2018-06-20
21862202

21872203
### Added
21882204

2189-
- Added `database.version` method
2205+
- Added `db.version` method
21902206

2191-
- Added `database.login` method
2207+
- Added `db.login` method
21922208

2193-
- Added `database.exists` method
2209+
- Added `db.exists` method
21942210

21952211
- Added `collection.exists` method
21962212

src/administration.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@
88
* @packageDocumentation
99
*/
1010

11+
//#region Administrative operation options
12+
/**
13+
* Options for compacting all databases on the server.
14+
*/
15+
export type CompactOptions = {
16+
/**
17+
* Whether compacted data should be moved to the minimum possible level.
18+
*
19+
* Default: `false`.
20+
*/
21+
changeLevel?: boolean;
22+
/**
23+
* Whether to compact the bottom-most level of data.
24+
*
25+
* Default: `false`.
26+
*/
27+
compactBottomMostLevel?: boolean;
28+
};
29+
//#endregion
30+
31+
//#region Administrative operation results
1132
/**
1233
* Result of retrieving database version information.
1334
*/
@@ -62,6 +83,59 @@ export type EngineInfo = {
6283
};
6384
};
6485

86+
/**
87+
* Performance and resource usage information about the storage engine.
88+
*/
89+
export type EngineStatsInfo = Record<
90+
string,
91+
string | number | Record<string, number | string>
92+
>;
93+
94+
/**
95+
* Information about the server license.
96+
*/
97+
export type LicenseInfo = {
98+
/**
99+
* Properties of the license.
100+
*/
101+
features: {
102+
/**
103+
* The timestamp of the expiration date of the license in seconds since the
104+
* Unix epoch.
105+
*/
106+
expires?: number;
107+
};
108+
/**
109+
* The hash value of the license.
110+
*/
111+
hash: string;
112+
/**
113+
* The encrypted license key in base 64 encoding, or `"none"` when running
114+
* in the Community Edition.
115+
*/
116+
license?: string;
117+
/**
118+
* The status of the installed license.
119+
*
120+
* - `"good"`: The license is valid for more than 2 weeks.
121+
*
122+
* - `"expiring"`: The license is valid for less than 2 weeks.
123+
*
124+
* - `"expired"`: The license has expired.
125+
*
126+
* - `"read-only"`: The license has been expired for more than 2 weeks.
127+
*/
128+
status: "good" | "expiring" | "expired" | "read-only";
129+
/**
130+
* Whether the server is performing a database upgrade.
131+
*/
132+
upgrading: boolean;
133+
/**
134+
* The license version number.
135+
*/
136+
version: number;
137+
};
138+
65139
/**
66140
* Information about the server status.
67141
*/
@@ -326,7 +400,9 @@ export type ClusterSupportInfo = {
326400
*/
327401
host: Record<string, any>;
328402
};
403+
//#endregion
329404

405+
//#region Queue time metrics
330406
/**
331407
* An object providing methods for accessing queue time metrics of the most
332408
* recently received server responses if the server supports this feature.
@@ -348,3 +424,4 @@ export interface QueueTimeMetrics {
348424
*/
349425
getAvg(): number;
350426
}
427+
//#endregion

src/collections.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,34 @@ export interface DocumentCollection<
788788
CollectionDescription & { revision: string; checksum: string }
789789
>
790790
>;
791+
/**
792+
* Retrieves the collection's shard IDs.
793+
*
794+
* @param details - If set to `true`, the response will include the responsible
795+
* servers for each shard.
796+
*/
797+
shards(
798+
details?: false
799+
): Promise<
800+
connection.ArangoApiResponse<
801+
CollectionDescription & CollectionProperties & { shards: string[] }
802+
>
803+
>;
804+
/**
805+
* Retrieves the collection's shard IDs and the responsible servers for each
806+
* shard.
807+
*
808+
* @param details - If set to `false`, the response will only include the
809+
* shard IDs without the responsible servers for each shard.
810+
*/
811+
shards(
812+
details: true
813+
): Promise<
814+
connection.ArangoApiResponse<
815+
CollectionDescription &
816+
CollectionProperties & { shards: Record<string, string[]> }
817+
>
818+
>;
791819
/**
792820
* Renames the collection and updates the instance's `name` to `newName`.
793821
*
@@ -2492,6 +2520,19 @@ export class Collection<
24922520
});
24932521
}
24942522

2523+
shards(
2524+
details?: boolean
2525+
): Promise<
2526+
connection.ArangoApiResponse<
2527+
CollectionDescription & CollectionProperties & { shards: any }
2528+
>
2529+
> {
2530+
return this._db.request({
2531+
pathname: `/_api/collection/${encodeURIComponent(this._name)}/shards`,
2532+
search: { details },
2533+
});
2534+
}
2535+
24952536
async rename(newName: string) {
24962537
const result = await this._db.renameCollection(this._name, newName);
24972538
this._name = newName;

0 commit comments

Comments
 (0)