diff --git a/.nvmrc b/.nvmrc index 1fe81fb..0295f3b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1,2 +1,2 @@ -20.8.1 +20.10.0 diff --git a/Dockerfile b/Dockerfile index 0bbbd3b..171d61e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.8.1-alpine AS base +FROM node:20.10.0-alpine AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" diff --git a/README.md b/README.md index bcb0bd4..ed12097 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Like the `docker-compose` file there are also some recipes included in the repos - `npx @andreafspeziale/os-cli i cr -i books -f ./recipes/create-index.json` or `os-cli i cr -i books -f ./recipes/create-index.json` - `npx @andreafspeziale/os-cli d cr -i books -f ./recipes/create-documents.json` or `os-cli d cr -i books -f ./recipes/create-documents.json` -- `npx @andreafspeziale/os-cli d qr -i books -f ./recipes/query.json` or `os-cli d qr -i books -f ./recipes/query.json` +- `npx @andreafspeziale/os-cli d q -i books -f ./recipes/query.json` or `os-cli d q -i books -f ./recipes/query.json` ### Configuration > For proxy mode check [aws-sigv4-proxy](https://github.com/awslabs/aws-sigv4-proxy) diff --git a/package.json b/package.json index 3a599ef..6b97359 100644 --- a/package.json +++ b/package.json @@ -24,19 +24,19 @@ "engines": { "node": ">=18.16.1" }, - "packageManager": "pnpm@8.9.2", + "packageManager": "pnpm@8.12.1", "bin": { "os-cli": "dist/os-cli.js" }, "scripts": { "prepare": "husky install", "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "format": "prettier --write \"src/**/*.ts\"", "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/os-cli", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "lint": "eslint \"src/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", @@ -51,7 +51,7 @@ "@nestjs/core": "^10.0.0", "@opensearch-project/opensearch": "^2.3.0", "nest-commander": "^3.11.0", - "reflect-metadata": "^0.1.13", + "reflect-metadata": "^0.2.0", "winston": "^3.10.0", "zod": "^3.21.4", "zod-validation-error": "^1.3.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa8f75e..6b0531a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,13 +10,13 @@ dependencies: version: 3.370.0 '@nestjs/common': specifier: ^10.0.0 - version: 10.0.0(reflect-metadata@0.1.13)(rxjs@7.8.1) + version: 10.0.0(reflect-metadata@0.2.0)(rxjs@7.8.1) '@nestjs/config': specifier: ^3.0.0 - version: 3.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.1.13) + version: 3.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.2.0) '@nestjs/core': specifier: ^10.0.0 - version: 10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.1.13)(rxjs@7.8.1) + version: 10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.2.0)(rxjs@7.8.1) '@opensearch-project/opensearch': specifier: ^2.3.0 version: 2.3.0 @@ -24,8 +24,8 @@ dependencies: specifier: ^3.11.0 version: 3.11.0(@nestjs/common@10.0.0)(@nestjs/core@10.0.0)(@types/inquirer@8.2.6) reflect-metadata: - specifier: ^0.1.13 - version: 0.1.13 + specifier: ^0.2.0 + version: 0.2.0 winston: specifier: ^3.10.0 version: 3.10.0 @@ -1560,7 +1560,7 @@ packages: - webpack-cli dev: true - /@nestjs/common@10.0.0(reflect-metadata@0.1.13)(rxjs@7.8.1): + /@nestjs/common@10.0.0(reflect-metadata@0.2.0)(rxjs@7.8.1): resolution: {integrity: sha512-Fa2GDQJrO5TTTcpISWfm0pdPS62V+8YbxeG5CA01zMUI+dCO3v3oFf+BSjqCGUUo7GDNzDsjAejwGXuqA54RPw==} peerDependencies: class-transformer: '*' @@ -1574,26 +1574,26 @@ packages: optional: true dependencies: iterare: 1.2.1 - reflect-metadata: 0.1.13 + reflect-metadata: 0.2.0 rxjs: 7.8.1 tslib: 2.5.3 uid: 2.0.2 - /@nestjs/config@3.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.1.13): + /@nestjs/config@3.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.2.0): resolution: {integrity: sha512-fzASk1Uv6AjdE6uA1na8zpqRCXAhRpcfgpCVv3SAKlgJ3VR3bEjcI4G17WHLgLBsmPzI1ofdkSI451WLD1F1Rw==} peerDependencies: '@nestjs/common': ^8.0.0 || ^9.0.0 || ^10.0.0 reflect-metadata: ^0.1.13 dependencies: - '@nestjs/common': 10.0.0(reflect-metadata@0.1.13)(rxjs@7.8.1) + '@nestjs/common': 10.0.0(reflect-metadata@0.2.0)(rxjs@7.8.1) dotenv: 16.1.4 dotenv-expand: 10.0.0 lodash: 4.17.21 - reflect-metadata: 0.1.13 + reflect-metadata: 0.2.0 uuid: 9.0.0 dev: false - /@nestjs/core@10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.1.13)(rxjs@7.8.1): + /@nestjs/core@10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.2.0)(rxjs@7.8.1): resolution: {integrity: sha512-HFTdj4vsF+2qOaq97ZPRDle6Q/KyL5lmMah0/ZR0ie+e1/tnlvmlqw589xFACTemLJFFOjZMy763v+icO9u72w==} requiresBuild: true peerDependencies: @@ -1611,12 +1611,12 @@ packages: '@nestjs/websockets': optional: true dependencies: - '@nestjs/common': 10.0.0(reflect-metadata@0.1.13)(rxjs@7.8.1) + '@nestjs/common': 10.0.0(reflect-metadata@0.2.0)(rxjs@7.8.1) '@nuxtjs/opencollective': 0.3.2 fast-safe-stringify: 2.1.1 iterare: 1.2.1 path-to-regexp: 3.2.0 - reflect-metadata: 0.1.13 + reflect-metadata: 0.2.0 rxjs: 7.8.1 tslib: 2.5.3 uid: 2.0.2 @@ -1651,8 +1651,8 @@ packages: '@nestjs/platform-express': optional: true dependencies: - '@nestjs/common': 10.0.0(reflect-metadata@0.1.13)(rxjs@7.8.1) - '@nestjs/core': 10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.1.13)(rxjs@7.8.1) + '@nestjs/common': 10.0.0(reflect-metadata@0.2.0)(rxjs@7.8.1) + '@nestjs/core': 10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.2.0)(rxjs@7.8.1) tslib: 2.5.3 dev: true @@ -6385,8 +6385,8 @@ packages: '@types/inquirer': ^8.1.3 dependencies: '@golevelup/nestjs-discovery': 3.0.0 - '@nestjs/common': 10.0.0(reflect-metadata@0.1.13)(rxjs@7.8.1) - '@nestjs/core': 10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.1.13)(rxjs@7.8.1) + '@nestjs/common': 10.0.0(reflect-metadata@0.2.0)(rxjs@7.8.1) + '@nestjs/core': 10.0.0(@nestjs/common@10.0.0)(reflect-metadata@0.2.0)(rxjs@7.8.1) '@types/inquirer': 8.2.6 commander: 11.0.0 cosmiconfig: 8.2.0 @@ -7075,8 +7075,8 @@ packages: strip-indent: 3.0.0 dev: true - /reflect-metadata@0.1.13: - resolution: {integrity: sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==} + /reflect-metadata@0.2.0: + resolution: {integrity: sha512-vUN0wuk3MuhSVMfU/ImnPQAK8QZcXJ339DtVsP3jDscxCe6dT+PsOe3J1BYS9Ec2Fd4oC6ry6bCBebzTya0IYw==} /regexp.prototype.flags@1.5.0: resolution: {integrity: sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==} diff --git a/recipes/alias-filter.json b/recipes/alias-filter.json new file mode 100644 index 0000000..4b72e8c --- /dev/null +++ b/recipes/alias-filter.json @@ -0,0 +1,5 @@ +{ + "term": { + "date": "19970726" + } +} \ No newline at end of file diff --git a/src/aliases/aliases.module.ts b/src/aliases/aliases.module.ts new file mode 100644 index 0000000..065eeac --- /dev/null +++ b/src/aliases/aliases.module.ts @@ -0,0 +1,21 @@ +import { Module } from '@nestjs/common'; +import { + AliasCommand, + CreateAliasCommand, + GetAliasCommand, + ListAliasCommand, + RemoveAliasCommand, +} from './commands'; +import { AliasesService } from './aliases.service'; + +@Module({ + providers: [ + AliasesService, + AliasCommand, + GetAliasCommand, + CreateAliasCommand, + ListAliasCommand, + RemoveAliasCommand, + ], +}) +export class AliasesModule {} diff --git a/src/aliases/aliases.service.ts b/src/aliases/aliases.service.ts new file mode 100644 index 0000000..bf9f220 --- /dev/null +++ b/src/aliases/aliases.service.ts @@ -0,0 +1,46 @@ +import { Client } from '@opensearch-project/opensearch'; +import { Injectable } from '@nestjs/common'; +import { LoggerService } from '../logger'; +import { InjectOSClient } from '../os'; + +@Injectable() +export class AliasesService { + constructor( + private readonly logger: LoggerService, + @InjectOSClient() private readonly osClient: Client, + ) { + this.logger.setContext(AliasesService.name); + } + + async get(alias: string): Promise> { + return (await this.osClient.cat.aliases({ name: alias, format: 'json' })) + .body; + } + + async create( + alias: string, + index: string, + isWriteIndex: boolean, + filter: Record, + ): Promise> { + return ( + await this.osClient.indices.putAlias({ + name: alias, + index, + body: { + is_write_index: isWriteIndex, + filter, + }, + }) + ).body; + } + + async list(): Promise> { + return (await this.osClient.cat.aliases({ format: 'json' })).body; + } + + async remove(alias: string, index: string): Promise> { + return (await this.osClient.indices.deleteAlias({ name: alias, index })) + .body; + } +} diff --git a/src/aliases/commands/aliases.command.ts b/src/aliases/commands/aliases.command.ts new file mode 100644 index 0000000..c193bf9 --- /dev/null +++ b/src/aliases/commands/aliases.command.ts @@ -0,0 +1,26 @@ +import { Command, CommandRunner } from 'nest-commander'; +import { GetAliasCommand } from './get.command'; +import { CreateAliasCommand } from './create.command'; +import { ListAliasCommand } from './list.command'; +import { RemoveAliasCommand } from './remove.command'; + +@Command({ + name: 'aliases', + description: 'opensearch aliases related commands', + aliases: ['a'], + subCommands: [ + GetAliasCommand, + CreateAliasCommand, + ListAliasCommand, + RemoveAliasCommand, + ], +}) +export class AliasCommand extends CommandRunner { + constructor() { + super(); + } + + async run(): Promise { + process.stdout.write(this.command.helpInformation()); + } +} diff --git a/src/aliases/commands/create.command.ts b/src/aliases/commands/create.command.ts new file mode 100644 index 0000000..0e3693d --- /dev/null +++ b/src/aliases/commands/create.command.ts @@ -0,0 +1,119 @@ +import { z } from 'zod'; +import { SubCommand, CommandRunner, Option } from 'nest-commander'; +import { LoggerService } from '../../logger'; +import { AliasesService } from '../aliases.service'; +import { + validateAndParseOrExit, + validateFileOrExit, + ValidJsonPayloadFromString, +} from '../../common'; + +@SubCommand({ + name: 'create', + description: 'create alias or add index to it', + aliases: ['cr'], +}) +export class CreateAliasCommand extends CommandRunner { + constructor( + private readonly logger: LoggerService, + private readonly aliasesService: AliasesService, + ) { + super(); + this.logger.setContext(CreateAliasCommand.name); + } + + @Option({ + flags: '-a, --alias, ', + description: 'alias name', + required: true, + }) + parseAlias(val: string): string { + return val; + } + + @Option({ + flags: '-i, --index, ', + description: 'index name', + required: true, + }) + parseIndex(val: string): string { + return val; + } + + @Option({ + flags: '-wr, --write-index, ', + description: 'is write index', + required: false, + defaultValue: false, + }) + parseisWriteIndex(val: string): boolean { + return ( + validateAndParseOrExit(val, z.enum(['true', 'false']), this.logger) === + 'true' + ); + } + + @Option({ + flags: '-p, --payload, [string]', + description: 'inline alias custom filter JSON payload', + }) + parsePayload(val: string): Record { + return validateAndParseOrExit( + val, + ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), + this.logger, + ); + } + + @Option({ + flags: '-f, --file, [string]', + description: 'alias custom filter JSON payload file path', + }) + parseFile(val: string): Record { + return validateAndParseOrExit( + validateFileOrExit(val, this.logger), + ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), + this.logger, + ); + } + + async run( + passedParam: string[], + options: { + alias: string; + index: string; + writeIndex: boolean; + payload?: Record; + file?: Record; + }, + ): Promise { + this.logger.debug('Running command...', { + fn: this.run.name, + passedParam, + options, + }); + + try { + const res = await this.aliasesService.create( + options.alias, + options.index, + options.writeIndex, + options.payload || options.file || {}, + ); + + this.logger.log('Alias successfully created', { + fn: this.run.name, + res, + }); + } catch (error) { + this.logger.error('Error while creating alias', { + fn: this.run.name, + alias: options.alias, + index: options.index, + name: error.name, + body: error.meta.body, + statusCode: error.meta.statusCode, + }); + } + } +} diff --git a/src/aliases/commands/get.command.ts b/src/aliases/commands/get.command.ts new file mode 100644 index 0000000..0c45194 --- /dev/null +++ b/src/aliases/commands/get.command.ts @@ -0,0 +1,48 @@ +import { SubCommand, CommandRunner, Option } from 'nest-commander'; +import { LoggerService } from '../../logger'; +import { AliasesService } from '../aliases.service'; + +@SubCommand({ name: 'get', description: 'get alias', aliases: ['g'] }) +export class GetAliasCommand extends CommandRunner { + constructor( + private readonly logger: LoggerService, + private readonly aliasesService: AliasesService, + ) { + super(); + this.logger.setContext(GetAliasCommand.name); + } + + @Option({ + flags: '-a, --alias, ', + description: 'alias name', + required: true, + }) + parseAlias(val: string): string { + return val; + } + + async run(passedParam: string[], options: { alias: string }): Promise { + this.logger.debug('Running command...', { + fn: this.run.name, + passedParam, + options, + }); + + try { + const res = await this.aliasesService.get(options.alias); + + this.logger.log('Alias successfully retrieved', { + fn: this.run.name, + res, + }); + } catch (error) { + this.logger.error('Error while getting alias', { + fn: this.run.name, + alias: options.alias, + name: error.name, + body: error.meta.body, + statusCode: error.meta.statusCode, + }); + } + } +} diff --git a/src/aliases/commands/index.ts b/src/aliases/commands/index.ts new file mode 100644 index 0000000..9083ae4 --- /dev/null +++ b/src/aliases/commands/index.ts @@ -0,0 +1,5 @@ +export * from './aliases.command'; +export * from './get.command'; +export * from './create.command'; +export * from './list.command'; +export * from './remove.command'; diff --git a/src/aliases/commands/list.command.ts b/src/aliases/commands/list.command.ts new file mode 100644 index 0000000..688bc9c --- /dev/null +++ b/src/aliases/commands/list.command.ts @@ -0,0 +1,41 @@ +import { SubCommand, CommandRunner } from 'nest-commander'; +import { LoggerService } from '../../logger'; +import { AliasesService } from '../aliases.service'; + +@SubCommand({ name: 'list', description: 'list aliases', aliases: ['l'] }) +export class ListAliasCommand extends CommandRunner { + constructor( + private readonly logger: LoggerService, + private readonly aliasesService: AliasesService, + ) { + super(); + this.logger.setContext(ListAliasCommand.name); + } + + async run( + passedParam: string[], + options?: Record, + ): Promise { + this.logger.debug('Running command...', { + fn: this.run.name, + passedParam, + options, + }); + + try { + const res = await this.aliasesService.list(); + + this.logger.log('Alias list successfully retrieved', { + fn: this.run.name, + res, + }); + } catch (error) { + this.logger.error('Error while listing aliases', { + fn: this.run.name, + name: error.name, + body: error.meta.body, + statusCode: error.meta.statusCode, + }); + } + } +} diff --git a/src/aliases/commands/remove.command.ts b/src/aliases/commands/remove.command.ts new file mode 100644 index 0000000..a8350d7 --- /dev/null +++ b/src/aliases/commands/remove.command.ts @@ -0,0 +1,68 @@ +import { SubCommand, CommandRunner, Option } from 'nest-commander'; +import { LoggerService } from '../../logger'; +import { AliasesService } from '../aliases.service'; + +@SubCommand({ + name: 'remove', + description: 'remove index from alias', + aliases: ['rm'], +}) +export class RemoveAliasCommand extends CommandRunner { + constructor( + private readonly logger: LoggerService, + private readonly aliasesService: AliasesService, + ) { + super(); + this.logger.setContext(RemoveAliasCommand.name); + } + + @Option({ + flags: '-a, --alias, ', + description: 'alias name', + required: true, + }) + parseAlias(val: string): string { + return val; + } + + @Option({ + flags: '-i, --index, ', + description: 'index name', + required: true, + }) + parseIndex(val: string): string { + return val; + } + + async run( + passedParam: string[], + options: { alias: string; index: string }, + ): Promise { + this.logger.debug('Running command...', { + fn: this.run.name, + passedParam, + options, + }); + + try { + const res = await this.aliasesService.remove( + options.alias, + options.index, + ); + + this.logger.log('Alias successfully updated by removal', { + fn: this.run.name, + res, + }); + } catch (error) { + this.logger.error('Error while updating by removal alias', { + fn: this.run.name, + alias: options.alias, + index: options.index, + name: error.name, + body: error.meta.body, + statusCode: error.meta.statusCode, + }); + } + } +} diff --git a/src/aliases/index.ts b/src/aliases/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/common/utils.ts b/src/common/utils.ts index 44c391c..c0e9ab3 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -30,7 +30,7 @@ const validationErrorLogBuilder = ( }; }; -export const validateAndParsePayloadOrExit = ( +export const validateAndParseOrExit = ( p: string, schema: S, logger: LoggerService, @@ -39,7 +39,7 @@ export const validateAndParsePayloadOrExit = ( return schema.parse(p); } catch (error) { const { message, meta } = validationErrorLogBuilder( - 'validateAndParsePayloadOrExit', + 'validateAndParseOrExit', error, ); diff --git a/src/documents/commands/create.command.ts b/src/documents/commands/create.command.ts index a01c5aa..f6c1756 100644 --- a/src/documents/commands/create.command.ts +++ b/src/documents/commands/create.command.ts @@ -5,7 +5,7 @@ import { InquirerService, } from 'nest-commander'; import { - validateAndParsePayloadOrExit, + validateAndParseOrExit, validateFileOrExit, ValidJsonPayloadFromString, } from '../../common'; @@ -43,11 +43,7 @@ export class CreateDocumentsCommand extends CommandRunner { parsePayload( val: string, ): Record | Record[] { - return validateAndParsePayloadOrExit( - val, - ValidJsonPayloadFromString, - this.logger, - ); + return validateAndParseOrExit(val, ValidJsonPayloadFromString, this.logger); } @Option({ @@ -55,7 +51,7 @@ export class CreateDocumentsCommand extends CommandRunner { description: 'create index JSON payload file path', }) parseFile(val: string): Record | Record[] { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( validateFileOrExit(val, this.logger), ValidJsonPayloadFromString, this.logger, diff --git a/src/documents/commands/delete.command.ts b/src/documents/commands/delete.command.ts index 0c54178..c3648aa 100644 --- a/src/documents/commands/delete.command.ts +++ b/src/documents/commands/delete.command.ts @@ -7,7 +7,7 @@ import { } from 'nest-commander'; import { LoggerService } from '../../logger'; import { DocumentsService } from '../documents.service'; -import { validateAndParsePayloadOrExit } from '../../common'; +import { validateAndParseOrExit } from '../../common'; @SubCommand({ name: 'delete', @@ -39,7 +39,7 @@ export class DeleteDocumentsCommand extends CommandRunner { required: true, }) parseDocumentsIds(val: string): string[] { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( val, z.string().transform((val) => val.split(',')), this.logger, diff --git a/src/documents/commands/query.command.ts b/src/documents/commands/query.command.ts index b4ef65c..93edafd 100644 --- a/src/documents/commands/query.command.ts +++ b/src/documents/commands/query.command.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { SubCommand, CommandRunner, Option } from 'nest-commander'; import { - validateAndParsePayloadOrExit, + validateAndParseOrExit, validateFileOrExit, ValidJsonPayloadFromString, } from '../../common'; @@ -36,7 +36,7 @@ export class QueryDocumentsCommand extends CommandRunner { description: 'inline query documents JSON payload', }) parsePayload(val: string): Record { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( val, ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), this.logger, @@ -48,7 +48,7 @@ export class QueryDocumentsCommand extends CommandRunner { description: 'query documents JSON payload file path', }) parseFile(val: string): Record { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( validateFileOrExit(val, this.logger), ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), this.logger, diff --git a/src/indices/commands/create.command.ts b/src/indices/commands/create.command.ts index 31122b5..cf6d00f 100644 --- a/src/indices/commands/create.command.ts +++ b/src/indices/commands/create.command.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { SubCommand, CommandRunner, Option } from 'nest-commander'; import { LoggerService } from '../../logger'; import { - validateAndParsePayloadOrExit, + validateAndParseOrExit, validateFileOrExit, ValidJsonPayloadFromString, } from '../../common'; @@ -32,7 +32,7 @@ export class CreateIndexCommand extends CommandRunner { description: 'inline create index JSON payload', }) parsePayload(val: string): Record { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( val, ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), this.logger, @@ -44,7 +44,7 @@ export class CreateIndexCommand extends CommandRunner { description: 'create index JSON payload file path', }) parseFile(val: string): Record { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( validateFileOrExit(val, this.logger), ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), this.logger, diff --git a/src/indices/commands/update.command.ts b/src/indices/commands/update.command.ts index 2cc0cca..eb4ffe6 100644 --- a/src/indices/commands/update.command.ts +++ b/src/indices/commands/update.command.ts @@ -6,10 +6,7 @@ import { InquirerService, } from 'nest-commander'; import { LoggerService } from '../../logger'; -import { - validateAndParsePayloadOrExit, - validateFileOrExit, -} from '../../common'; +import { validateAndParseOrExit, validateFileOrExit } from '../../common'; import { ValidJsonPayloadFromString } from '../../common'; import { IndicesService } from '../indices.service'; @@ -38,7 +35,7 @@ export class UpdateIndexCommand extends CommandRunner { description: 'inline update index JSON payload', }) parsePayload(val: string): Record { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( val, ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), this.logger, @@ -50,7 +47,7 @@ export class UpdateIndexCommand extends CommandRunner { description: 'update index JSON payload file path', }) parseFile(val: string): Record { - return validateAndParsePayloadOrExit( + return validateAndParseOrExit( validateFileOrExit(val, this.logger), ValidJsonPayloadFromString.pipe(z.object({}).passthrough()), this.logger, diff --git a/src/os-cli.module.ts b/src/os-cli.module.ts index c5a49d0..9d3462a 100644 --- a/src/os-cli.module.ts +++ b/src/os-cli.module.ts @@ -7,6 +7,7 @@ import { DocumentsModule } from './documents'; import { TasksModule } from './tasks'; import { LoggerModule } from './logger'; import { OpenSearchModule } from './os'; +import { AliasesModule } from './aliases/aliases.module'; @Module({ imports: [ @@ -26,6 +27,7 @@ import { OpenSearchModule } from './os'; IndicesModule, DocumentsModule, TasksModule, + AliasesModule, ], }) export class OSCLIModule {}