diff --git a/apps/cli/src/commands/environment/list.environment.ts b/apps/cli/src/commands/environment/list.environment.ts index 1ec3dcba..454f9b80 100644 --- a/apps/cli/src/commands/environment/list.environment.ts +++ b/apps/cli/src/commands/environment/list.environment.ts @@ -1,10 +1,12 @@ import BaseCommand from '../base.command' import { EnvironmentController } from '@keyshade/api-client' import { + CommandOption, type CommandActionData, type CommandArgument } from 'src/types/command/command.types' import { Logger } from '@/util/logger' +import { PAGINATION_OPTION } from '@/util/pagination-options' export class ListEnvironment extends BaseCommand { getName(): string { @@ -24,7 +26,11 @@ export class ListEnvironment extends BaseCommand { ] } - async action({ args }: CommandActionData): Promise { + getOptions(): CommandOption[] { + return PAGINATION_OPTION + } + + async action({ args, options }: CommandActionData): Promise { const [projectSlug] = args if (!projectSlug) { @@ -44,7 +50,7 @@ export class ListEnvironment extends BaseCommand { data: environments, error } = await environmentController.getAllEnvironmentsOfProject( - { projectSlug }, + { projectSlug, ...options }, headers ) diff --git a/apps/cli/src/commands/workspace/list.workspace.ts b/apps/cli/src/commands/workspace/list.workspace.ts index bcbeedb4..4f0dfda0 100644 --- a/apps/cli/src/commands/workspace/list.workspace.ts +++ b/apps/cli/src/commands/workspace/list.workspace.ts @@ -1,6 +1,8 @@ import BaseCommand from '@/commands/base.command' import { Logger } from '@/util/logger' import ControllerInstance from '@/util/controller-instance' +import { CommandActionData, CommandOption } from '@/types/command/command.types' +import { PAGINATION_OPTION } from '@/util/pagination-options' export default class ListWorkspace extends BaseCommand { getName(): string { @@ -11,12 +13,18 @@ export default class ListWorkspace extends BaseCommand { return 'Fetches all the workspace you have access to' } - async action(): Promise { + getOptions(): CommandOption[] { + return PAGINATION_OPTION + } + + async action({ options }: CommandActionData): Promise { Logger.info('Fetching all workspaces...') const { success, data, error } = await ControllerInstance.getInstance().workspaceController.getWorkspacesOfUser( - {}, + { + ...options + }, this.headers ) diff --git a/apps/cli/src/util/pagination-options.ts b/apps/cli/src/util/pagination-options.ts new file mode 100644 index 00000000..d7f50440 --- /dev/null +++ b/apps/cli/src/util/pagination-options.ts @@ -0,0 +1,31 @@ +import { CommandOption } from '@/types/command/command.types' + +export const PAGINATION_OPTION: CommandOption[] = [ + { + short: '-p', + long: '--page ', + description: 'Index of the page.' + }, + { + short: '-l', + long: '--limit ', + description: 'Total number of items per page.' + }, + { + short: '-o', + long: '--order ', + description: + 'Order to sort by - either ascending (ASC) or descending (DESC).', + choices: ['ASC', 'DESC'] + }, + { + short: '--sort', + long: '--sort ', + description: 'Field to sort by.' + }, + { + short: '-s', + long: '--search ', + description: 'Search term.' + } +] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 059f2704..a9028fe9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -252,10 +252,10 @@ importers: version: 7.4.2 jest: specifier: ^29.5.0 - version: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) + version: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) jest-mock-extended: specifier: ^3.0.5 - version: 3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3) + version: 3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3) prettier: specifier: ^3.0.0 version: 3.3.3 @@ -273,7 +273,7 @@ importers: version: 6.3.4 ts-jest: specifier: ^29.1.0 - version: 29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3) + version: 29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3) ts-loader: specifier: ^9.4.3 version: 9.5.1(typescript@5.3.3)(webpack@5.94.0(@swc/core@1.7.26)) @@ -325,7 +325,7 @@ importers: devDependencies: '@swc/cli': specifier: ^0.4.0 - version: 0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.2))(chokidar@3.6.0) + version: 0.4.0(@swc/core@1.7.26)(chokidar@3.6.0) '@swc/core': specifier: ^1.6.13 version: 1.7.26(@swc/helpers@0.5.2) @@ -10290,41 +10290,6 @@ snapshots: jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3))': - dependencies: - '@jest/console': 29.7.0 - '@jest/reporters': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.16.5 - ansi-escapes: 4.3.2 - chalk: 4.1.2 - ci-info: 3.9.0 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - jest-haste-map: 29.7.0 - jest-message-util: 29.7.0 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-resolve-dependencies: 29.7.0 - jest-runner: 29.7.0 - jest-runtime: 29.7.0 - jest-snapshot: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - jest-watcher: 29.7.0 - micromatch: 4.0.8 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-ansi: 6.0.1 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - - ts-node - '@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2))': dependencies: '@jest/console': 29.7.0 @@ -10597,7 +10562,7 @@ snapshots: webpack: 5.94.0(@swc/core@1.7.26) webpack-node-externals: 3.0.0 optionalDependencies: - '@swc/cli': 0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.2))(chokidar@3.6.0) + '@swc/cli': 0.4.0(@swc/core@1.7.26)(chokidar@3.6.0) '@swc/core': 1.7.26(@swc/helpers@0.5.2) transitivePeerDependencies: - esbuild @@ -11987,7 +11952,7 @@ snapshots: - supports-color - typescript - '@swc/cli@0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.2))(chokidar@3.6.0)': + '@swc/cli@0.4.0(@swc/core@1.7.26)(chokidar@3.6.0)': dependencies: '@mole-inc/bin-wrapper': 8.0.1 '@swc/core': 1.7.26(@swc/helpers@0.5.2) @@ -13672,21 +13637,6 @@ snapshots: sha.js: 2.4.11 optional: true - create-jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@jest/types': 29.6.3 - chalk: 4.1.2 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - jest-util: 29.7.0 - prompts: 2.4.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - create-jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@jest/types': 29.6.3 @@ -15765,25 +15715,6 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - '@jest/test-result': 29.7.0 - '@jest/types': 29.6.3 - chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - exit: 0.1.2 - import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - jest-util: 29.7.0 - jest-validate: 29.7.0 - yargs: 17.7.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest-cli@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) @@ -15803,37 +15734,6 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@babel/core': 7.25.2 - '@jest/test-sequencer': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.25.2) - chalk: 4.1.2 - ci-info: 3.9.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.7.0 - jest-environment-node: 29.7.0 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-runner: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - micromatch: 4.0.8 - parse-json: 5.2.0 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - optionalDependencies: - '@types/node': 20.16.5 - ts-node: 10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3) - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - jest-config@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@babel/core': 7.25.2 @@ -15935,9 +15835,9 @@ snapshots: slash: 3.0.0 stack-utils: 2.0.6 - jest-mock-extended@3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3): + jest-mock-extended@3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3): dependencies: - jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) + jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) ts-essentials: 10.0.2(typescript@5.3.3) typescript: 5.3.3 @@ -16092,18 +15992,6 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - '@jest/types': 29.6.3 - import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) @@ -18544,12 +18432,12 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3): + ts-jest@29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) + jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 @@ -18592,27 +18480,6 @@ snapshots: typescript: 5.3.3 webpack: 5.94.0(@swc/core@1.7.26) - ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3): - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.11 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.4 - '@types/node': 20.16.5 - acorn: 8.12.1 - acorn-walk: 8.3.4 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.3.3 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - optionalDependencies: - '@swc/core': 1.7.26(@swc/helpers@0.5.2) - optional: true - ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2): dependencies: '@cspotcode/source-map-support': 0.8.1