mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
move shared CLI items to jslib
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import { BaseResponse } from './response/baseResponse';
|
||||
|
||||
export class Response {
|
||||
static error(error: any): Response {
|
||||
const res = new Response();
|
||||
res.success = false;
|
||||
if (typeof (error) === 'string') {
|
||||
res.message = error;
|
||||
} else {
|
||||
res.message = error.message != null ? error.message : error.toString();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static notFound(): Response {
|
||||
return Response.error('Not found.');
|
||||
}
|
||||
|
||||
static badRequest(message: string): Response {
|
||||
return Response.error(message);
|
||||
}
|
||||
|
||||
static multipleResults(ids: string[]): Response {
|
||||
let msg = 'More than one result was found. Try getting a specific object by `id` instead. ' +
|
||||
'The following objects were found:';
|
||||
ids.forEach((id) => {
|
||||
msg += '\n' + id;
|
||||
});
|
||||
return Response.error(msg);
|
||||
}
|
||||
|
||||
static success(data?: BaseResponse): Response {
|
||||
const res = new Response();
|
||||
res.success = true;
|
||||
res.data = data;
|
||||
return res;
|
||||
}
|
||||
|
||||
success: boolean;
|
||||
message: string;
|
||||
errorCode: number;
|
||||
data: BaseResponse;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export interface BaseResponse {
|
||||
object: string;
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { CipherWithIds } from 'jslib/models/export/cipherWithIds';
|
||||
import { CipherView } from 'jslib/models/view/cipherView';
|
||||
|
||||
import { BaseResponse } from 'jslib/cli/models/response/baseResponse';
|
||||
|
||||
import { AttachmentResponse } from './attachmentResponse';
|
||||
import { BaseResponse } from './baseResponse';
|
||||
import { LoginResponse } from './loginResponse';
|
||||
import { PasswordHistoryResponse } from './passwordHistoryResponse';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CollectionWithId } from 'jslib/models/export/collectionWithId';
|
||||
import { CollectionView } from 'jslib/models/view/collectionView';
|
||||
|
||||
import { BaseResponse } from './baseResponse';
|
||||
import { BaseResponse } from 'jslib/cli/models/response/baseResponse';
|
||||
|
||||
export class CollectionResponse extends CollectionWithId implements BaseResponse {
|
||||
object: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FolderWithId } from 'jslib/models/export/folderWithId';
|
||||
import { FolderView } from 'jslib/models/view/folderView';
|
||||
|
||||
import { BaseResponse } from './baseResponse';
|
||||
import { BaseResponse } from 'jslib/cli/models/response/baseResponse';
|
||||
|
||||
export class FolderResponse extends FolderWithId implements BaseResponse {
|
||||
object: string;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { BaseResponse } from './baseResponse';
|
||||
|
||||
export class ListResponse implements BaseResponse {
|
||||
object: string;
|
||||
data: BaseResponse[];
|
||||
|
||||
constructor(data: BaseResponse[]) {
|
||||
this.object = 'list';
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { BaseResponse } from './baseResponse';
|
||||
|
||||
export class MessageResponse implements BaseResponse {
|
||||
object: string;
|
||||
title: string;
|
||||
message: string;
|
||||
raw: string;
|
||||
noColor = false;
|
||||
|
||||
constructor(title: string, message: string) {
|
||||
this.object = 'message';
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseResponse } from './baseResponse';
|
||||
import { BaseResponse } from 'jslib/cli/models/response/baseResponse';
|
||||
|
||||
import { Organization } from 'jslib/models/domain/organization';
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { BaseResponse } from './baseResponse';
|
||||
|
||||
export class StringResponse implements BaseResponse {
|
||||
object: string;
|
||||
data: string;
|
||||
|
||||
constructor(data: string) {
|
||||
this.object = 'string';
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseResponse } from './baseResponse';
|
||||
import { BaseResponse } from 'jslib/cli/models/response/baseResponse';
|
||||
|
||||
export class TemplateResponse implements BaseResponse {
|
||||
object: string;
|
||||
|
||||
Reference in New Issue
Block a user