11import { ConnectionREST } from '../index.js' ;
22import { WeaviateAlias , WeaviateAliasResponse } from '../openapi/types.js' ;
3- import { Alias , CreateAliasInput , UpdateAliasInput } from './types.js' ;
3+ import { Alias , AliasListAllOpts , CreateAliasArgs , UpdateAliasArgs } from './types.js' ;
44
55export interface Aliases {
66 /**
@@ -9,19 +9,19 @@ export interface Aliases {
99 * The collection must exist prior to aliasing it.
1010 * One alias cannot be created for multiple collections simultaneously.
1111 *
12- * @param {string } [opt .collection] Original collection name.
13- * @param {string } [opt .alias] Alias for collection.
12+ * @param {string } args .collection Original collection name.
13+ * @param {string } args .alias Alias for collection.
1414 * @returns {Promise<void> } Awaitable promise.
1515 * */
16- create : ( opt : CreateAliasInput ) => Promise < void > ;
16+ create : ( args : CreateAliasArgs ) => Promise < void > ;
1717
1818 /**
1919 * List all aliases defined in the schema.
2020 *
21- * @param {string | undefined } collection Get all aliases defined for this collection.
21+ * @param {string | undefined } [opts. collection] Get all aliases defined for this collection.
2222 * @returns {Promise<Alias[] | undefined> } An array of aliases.
2323 */
24- listAll : ( collection ?: string ) => Promise < Alias [ ] | undefined > ;
24+ listAll : ( opts ?: AliasListAllOpts ) => Promise < Alias [ ] | undefined > ;
2525
2626 /**
2727 * Get information about an alias.
@@ -37,11 +37,11 @@ export interface Aliases {
3737 * To change the alias that points to the collection,
3838 * delete the alias and create a new one.
3939 *
40- * @param {string } [opt .alias] Alias to update.
41- * @param {string } [opt .collection] New collection the alias should point to.
40+ * @param {string } args .alias Alias to update.
41+ * @param {string } args .collection New collection the alias should point to.
4242 * @return {Promise<void> } Awaitable promise.
4343 */
44- update : ( opt : UpdateAliasInput ) => Promise < void > ;
44+ update : ( args : UpdateAliasArgs ) => Promise < void > ;
4545
4646 /**
4747 * Delete a collection alias.
@@ -54,11 +54,13 @@ export interface Aliases {
5454
5555const alias = ( connection : ConnectionREST ) : Aliases => {
5656 return {
57- create : ( opt : CreateAliasInput ) =>
58- connection . postReturn < WeaviateAlias , void > ( `/aliases/` , { ...opt , class : opt . collection } ) ,
59- listAll : ( collection ?: string ) =>
57+ create : ( args : CreateAliasArgs ) =>
58+ connection . postReturn < WeaviateAlias , void > ( `/aliases/` , { ...args , class : args . collection } ) ,
59+ listAll : ( opts ?: AliasListAllOpts ) =>
6060 connection
61- . get < WeaviateAliasResponse > ( `/aliases${ collection !== undefined ? '/?class=' + collection : '' } ` )
61+ . get < WeaviateAliasResponse > (
62+ `/aliases${ opts ?. collection !== undefined ? '/?class=' + opts . collection : '' } `
63+ )
6264 . then ( ( aliases ) =>
6365 aliases . aliases !== undefined
6466 ? aliases . aliases . map ( ( alias ) => ( { alias : alias . alias , collection : alias . class } ) )
@@ -68,8 +70,8 @@ const alias = (connection: ConnectionREST): Aliases => {
6870 connection
6971 . get < WeaviateAlias > ( `/aliases/${ alias } ` )
7072 . then ( ( alias ) => ( { alias : alias . alias ! , collection : alias . class ! } ) ) ,
71- update : ( opt : UpdateAliasInput ) =>
72- connection . put ( `/aliases/${ opt . alias } ` , { class : opt . newTargetCollection } ) ,
73+ update : ( args : UpdateAliasArgs ) =>
74+ connection . put ( `/aliases/${ args . alias } ` , { class : args . newTargetCollection } ) ,
7375 delete : ( alias : string ) => connection . delete ( `/aliases/${ alias } ` , null ) ,
7476 } ;
7577} ;
0 commit comments