initial
This commit is contained in:
436
ts/interfaces/index.ts
Normal file
436
ts/interfaces/index.ts
Normal file
@@ -0,0 +1,436 @@
|
||||
import type * as plugins from '../plugins.js';
|
||||
|
||||
/**
|
||||
* Configuration for S3 connection
|
||||
*/
|
||||
export interface IS3Config {
|
||||
endpoint: string;
|
||||
port?: number;
|
||||
accessKey: string;
|
||||
accessSecret: string;
|
||||
useSsl?: boolean;
|
||||
region?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for MongoDB connection
|
||||
*/
|
||||
export interface IMongoConfig {
|
||||
mongoDbUrl: string;
|
||||
mongoDbName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combined configuration for tsview
|
||||
*/
|
||||
export interface ITsViewConfig {
|
||||
s3?: IS3Config;
|
||||
mongo?: IMongoConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment configuration from .nogit/env.json (gitzone service format)
|
||||
*/
|
||||
export interface IEnvConfig {
|
||||
MONGODB_URL?: string;
|
||||
MONGODB_HOST?: string;
|
||||
MONGODB_PORT?: string;
|
||||
MONGODB_USER?: string;
|
||||
MONGODB_PASS?: string;
|
||||
MONGODB_NAME?: string;
|
||||
S3_HOST?: string;
|
||||
S3_PORT?: string;
|
||||
S3_ACCESSKEY?: string;
|
||||
S3_SECRETKEY?: string;
|
||||
S3_BUCKET?: string;
|
||||
S3_ENDPOINT?: string;
|
||||
S3_USESSL?: boolean | string;
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// TypedRequest interfaces for S3 API
|
||||
// ===========================================
|
||||
|
||||
export interface IReq_ListBuckets extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_ListBuckets
|
||||
> {
|
||||
method: 'listBuckets';
|
||||
request: {};
|
||||
response: {
|
||||
buckets: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_CreateBucket extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_CreateBucket
|
||||
> {
|
||||
method: 'createBucket';
|
||||
request: {
|
||||
bucketName: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_DeleteBucket extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_DeleteBucket
|
||||
> {
|
||||
method: 'deleteBucket';
|
||||
request: {
|
||||
bucketName: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IS3Object {
|
||||
key: string;
|
||||
size?: number;
|
||||
lastModified?: string;
|
||||
isPrefix?: boolean;
|
||||
}
|
||||
|
||||
export interface IReq_ListObjects extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_ListObjects
|
||||
> {
|
||||
method: 'listObjects';
|
||||
request: {
|
||||
bucketName: string;
|
||||
prefix?: string;
|
||||
delimiter?: string;
|
||||
};
|
||||
response: {
|
||||
objects: IS3Object[];
|
||||
prefixes: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_GetObject extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetObject
|
||||
> {
|
||||
method: 'getObject';
|
||||
request: {
|
||||
bucketName: string;
|
||||
key: string;
|
||||
};
|
||||
response: {
|
||||
content: string; // base64
|
||||
contentType: string;
|
||||
size: number;
|
||||
lastModified: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_GetObjectMetadata extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetObjectMetadata
|
||||
> {
|
||||
method: 'getObjectMetadata';
|
||||
request: {
|
||||
bucketName: string;
|
||||
key: string;
|
||||
};
|
||||
response: {
|
||||
contentType: string;
|
||||
size: number;
|
||||
lastModified: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_PutObject extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_PutObject
|
||||
> {
|
||||
method: 'putObject';
|
||||
request: {
|
||||
bucketName: string;
|
||||
key: string;
|
||||
content: string; // base64
|
||||
contentType: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_DeleteObject extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_DeleteObject
|
||||
> {
|
||||
method: 'deleteObject';
|
||||
request: {
|
||||
bucketName: string;
|
||||
key: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_CopyObject extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_CopyObject
|
||||
> {
|
||||
method: 'copyObject';
|
||||
request: {
|
||||
sourceBucket: string;
|
||||
sourceKey: string;
|
||||
destBucket: string;
|
||||
destKey: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// TypedRequest interfaces for MongoDB API
|
||||
// ===========================================
|
||||
|
||||
export interface IMongoDatabase {
|
||||
name: string;
|
||||
sizeOnDisk?: number;
|
||||
empty?: boolean;
|
||||
}
|
||||
|
||||
export interface IReq_ListDatabases extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_ListDatabases
|
||||
> {
|
||||
method: 'listDatabases';
|
||||
request: {};
|
||||
response: {
|
||||
databases: IMongoDatabase[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IMongoCollection {
|
||||
name: string;
|
||||
count?: number;
|
||||
}
|
||||
|
||||
export interface IReq_ListCollections extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_ListCollections
|
||||
> {
|
||||
method: 'listCollections';
|
||||
request: {
|
||||
databaseName: string;
|
||||
};
|
||||
response: {
|
||||
collections: IMongoCollection[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_CreateCollection extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_CreateCollection
|
||||
> {
|
||||
method: 'createCollection';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_FindDocuments extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_FindDocuments
|
||||
> {
|
||||
method: 'findDocuments';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
filter?: Record<string, unknown>;
|
||||
projection?: Record<string, unknown>;
|
||||
sort?: Record<string, number>;
|
||||
skip?: number;
|
||||
limit?: number;
|
||||
};
|
||||
response: {
|
||||
documents: Record<string, unknown>[];
|
||||
total: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_GetDocument extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetDocument
|
||||
> {
|
||||
method: 'getDocument';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
documentId: string;
|
||||
};
|
||||
response: {
|
||||
document: Record<string, unknown> | null;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_InsertDocument extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_InsertDocument
|
||||
> {
|
||||
method: 'insertDocument';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
document: Record<string, unknown>;
|
||||
};
|
||||
response: {
|
||||
insertedId: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_UpdateDocument extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_UpdateDocument
|
||||
> {
|
||||
method: 'updateDocument';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
documentId: string;
|
||||
update: Record<string, unknown>;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
modifiedCount: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_DeleteDocument extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_DeleteDocument
|
||||
> {
|
||||
method: 'deleteDocument';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
documentId: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
deletedCount: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_RunAggregation extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_RunAggregation
|
||||
> {
|
||||
method: 'runAggregation';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
pipeline: Record<string, unknown>[];
|
||||
};
|
||||
response: {
|
||||
results: Record<string, unknown>[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IMongoIndex {
|
||||
name: string;
|
||||
keys: Record<string, number>;
|
||||
unique?: boolean;
|
||||
sparse?: boolean;
|
||||
}
|
||||
|
||||
export interface IReq_ListIndexes extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_ListIndexes
|
||||
> {
|
||||
method: 'listIndexes';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
};
|
||||
response: {
|
||||
indexes: IMongoIndex[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_CreateIndex extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_CreateIndex
|
||||
> {
|
||||
method: 'createIndex';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
keys: Record<string, number>;
|
||||
options?: {
|
||||
unique?: boolean;
|
||||
sparse?: boolean;
|
||||
name?: string;
|
||||
};
|
||||
};
|
||||
response: {
|
||||
indexName: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_DropIndex extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_DropIndex
|
||||
> {
|
||||
method: 'dropIndex';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
indexName: string;
|
||||
};
|
||||
response: {
|
||||
success: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ICollectionStats {
|
||||
count: number;
|
||||
size: number;
|
||||
avgObjSize: number;
|
||||
storageSize: number;
|
||||
indexCount: number;
|
||||
}
|
||||
|
||||
export interface IReq_GetCollectionStats extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetCollectionStats
|
||||
> {
|
||||
method: 'getCollectionStats';
|
||||
request: {
|
||||
databaseName: string;
|
||||
collectionName: string;
|
||||
};
|
||||
response: {
|
||||
stats: ICollectionStats;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_GetServerStatus extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetServerStatus
|
||||
> {
|
||||
method: 'getServerStatus';
|
||||
request: {};
|
||||
response: {
|
||||
version: string;
|
||||
uptime: number;
|
||||
connections: {
|
||||
current: number;
|
||||
available: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user