@lars_hagemann/mediaserver-backend-plugin-types 1.1.2-beta → 1.2.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/types/{plugins/plugin.d.ts → plugin.d.ts} +5 -1
- package/types/ApiHandler.d.ts +0 -39
- package/types/DefaultDiContainer.d.ts +0 -23
- package/types/DiContainer.d.ts +0 -3
- package/types/collections/CollectionRepository.d.ts +0 -42
- package/types/collections/CollectionService.d.ts +0 -27
- package/types/common/ApiError.d.ts +0 -6
- package/types/common/EmptyObject.d.ts +0 -1
- package/types/common/EnvironmentError.d.ts +0 -7
- package/types/common/EnvironmentService.d.ts +0 -21
- package/types/common/LoggingService.d.ts +0 -18
- package/types/common/withErrorHandler.d.ts +0 -1
- package/types/documents/DocumentRepository.d.ts +0 -24
- package/types/documents/DocumentService.d.ts +0 -11
- package/types/files/FileService.d.ts +0 -25
- package/types/files/UploadService.d.ts +0 -25
- package/types/plugins/fileTypes.d.ts +0 -4
- package/types/plugins/standardPlugins.d.ts +0 -11
- package/types/redis/RedisClient.d.ts +0 -12
- package/types/sql/DbService.d.ts +0 -31
- package/types/sql/MigrationService.d.ts +0 -21
- package/types/sql/errors/ApiDatabaseError.d.ts +0 -5
- package/types/sql/errors/InvalidRowNumberError.d.ts +0 -7
- package/types/sql/errors/MigrationChecksumError.d.ts +0 -5
- package/types/sql/errors/MigrationOrderMismatchError.d.ts +0 -6
- package/types/sql/errors/MissingMigrationError.d.ts +0 -4
- package/types/sql/errors/NotConnectedError.d.ts +0 -4
- package/types/sql/errors/RowSchemaMismatchError.d.ts +0 -6
- package/types/sql/errors/TooManyConnectionsError.d.ts +0 -4
- package/types/state/BackendStateRepository.d.ts +0 -28
- package/types/state/BackendStateService.d.ts +0 -6
- package/types/tags/TagCache.d.ts +0 -13
- package/types/tags/TagParseError.d.ts +0 -4
- package/types/tags/TagRepository.d.ts +0 -43
- package/types/tags/TagService.d.ts +0 -24
- package/types/tags/TagSqlBuilder.d.ts +0 -89
- package/types/util/PaginatedResponse.d.ts +0 -13
- package/types/util/tag.d.ts +0 -3
- package/types/websocket/WebSocketService.d.ts +0 -13
package/package.json
CHANGED
package/types/ApiHandler.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { RequestHandler } from "express";
|
|
2
|
-
import type { ContainerBuilder } from "node-dependency-injection";
|
|
3
|
-
import { ApiError } from "./common/ApiError.js";
|
|
4
|
-
import type fileUpload from "express-fileupload";
|
|
5
|
-
import type { EmptyObject } from "./common/EmptyObject.js";
|
|
6
|
-
import type { IncomingHttpHeaders } from "http";
|
|
7
|
-
export declare class FileDownload {
|
|
8
|
-
readonly filepath: string;
|
|
9
|
-
readonly mimeType: string;
|
|
10
|
-
constructor(filepath: string, mimeType: string);
|
|
11
|
-
}
|
|
12
|
-
export declare class FileStream {
|
|
13
|
-
readonly filepath: string;
|
|
14
|
-
readonly mimeType: string;
|
|
15
|
-
readonly filename: string;
|
|
16
|
-
readonly startByte: number;
|
|
17
|
-
readonly endByte: number;
|
|
18
|
-
readonly totalSize: number;
|
|
19
|
-
constructor(filepath: string, mimeType: string, filename: string, startByte: number, endByte: number, totalSize: number);
|
|
20
|
-
}
|
|
21
|
-
type RangeHeader = {
|
|
22
|
-
start: number;
|
|
23
|
-
end: number;
|
|
24
|
-
};
|
|
25
|
-
type ApiResult<Response extends object> = {
|
|
26
|
-
status: number;
|
|
27
|
-
body: Response;
|
|
28
|
-
};
|
|
29
|
-
type ApiFunction<Params extends object, Response extends object, Body extends object, Query extends object> = (params: {
|
|
30
|
-
diContainer: ContainerBuilder;
|
|
31
|
-
query: Query;
|
|
32
|
-
body: Body;
|
|
33
|
-
params: Params;
|
|
34
|
-
files: fileUpload.FileArray | null | undefined;
|
|
35
|
-
headers: IncomingHttpHeaders;
|
|
36
|
-
}) => Promise<ApiResult<Response>>;
|
|
37
|
-
export declare const apiHandler: <Response extends object = EmptyObject, Query extends object = EmptyObject, Body extends object = EmptyObject, Params extends object = EmptyObject>(fn: ApiFunction<Params, Response, Body, Query>) => RequestHandler<Params, Response | ApiError, Body, Query, Record<string, unknown>>;
|
|
38
|
-
export declare const parseRangeHeader: (rangeHeader: string, fileSize: number) => RangeHeader | undefined;
|
|
39
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type ContainerBuilder } from "node-dependency-injection";
|
|
2
|
-
export declare const services: {
|
|
3
|
-
environment: string;
|
|
4
|
-
db: string;
|
|
5
|
-
migration: string;
|
|
6
|
-
logger: string;
|
|
7
|
-
document: string;
|
|
8
|
-
file: string;
|
|
9
|
-
websocket: string;
|
|
10
|
-
tag: string;
|
|
11
|
-
redis: string;
|
|
12
|
-
backendState: string;
|
|
13
|
-
upload: string;
|
|
14
|
-
collection: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const repositories: {
|
|
17
|
-
document: string;
|
|
18
|
-
tag: string;
|
|
19
|
-
tagCache: string;
|
|
20
|
-
backendState: string;
|
|
21
|
-
collection: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const defaultDiContainer: (diContainer: ContainerBuilder) => ContainerBuilder;
|
package/types/DiContainer.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { DbService } from "../sql/DbService.js";
|
|
2
|
-
import { type PaginatedResponse } from "../util/PaginatedResponse.js";
|
|
3
|
-
export type CollectionType = "dynamic" | "static";
|
|
4
|
-
export type Collection = {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
description: string | undefined;
|
|
8
|
-
filterExpression: string;
|
|
9
|
-
isFavorite: boolean;
|
|
10
|
-
type: CollectionType;
|
|
11
|
-
createdAt: Date;
|
|
12
|
-
updatedAt: Date;
|
|
13
|
-
};
|
|
14
|
-
export interface ListCollectionsRequest {
|
|
15
|
-
limit: number;
|
|
16
|
-
offset: number;
|
|
17
|
-
type: CollectionType | undefined;
|
|
18
|
-
}
|
|
19
|
-
export interface CreateCollectionRequest {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
filterExpression: string;
|
|
24
|
-
isFavorite: boolean;
|
|
25
|
-
type: CollectionType;
|
|
26
|
-
}
|
|
27
|
-
export interface UpdateCollectionRequest {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
description: string | null;
|
|
31
|
-
filterExpression: string;
|
|
32
|
-
isFavorite: boolean;
|
|
33
|
-
}
|
|
34
|
-
export declare class CollectionRepository {
|
|
35
|
-
private readonly dbService;
|
|
36
|
-
constructor(dbService: DbService);
|
|
37
|
-
listCollections({ limit, offset, type, }: ListCollectionsRequest): Promise<PaginatedResponse<Collection>>;
|
|
38
|
-
getCollection(id: string): Promise<Collection | null>;
|
|
39
|
-
createCollection(request: CreateCollectionRequest): Promise<Collection>;
|
|
40
|
-
updateCollection(request: UpdateCollectionRequest): Promise<Collection | null>;
|
|
41
|
-
deleteCollection(id: string): Promise<void>;
|
|
42
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Collection, CollectionRepository, CollectionType, UpdateCollectionRequest } from "./CollectionRepository.js";
|
|
2
|
-
import type { PaginatedResponse } from "../util/PaginatedResponse.js";
|
|
3
|
-
import type { TagService } from "../tags/TagService.js";
|
|
4
|
-
export interface CreateCollectionRequest {
|
|
5
|
-
name: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
filterExpression: string;
|
|
8
|
-
isFavorite: boolean;
|
|
9
|
-
type: CollectionType;
|
|
10
|
-
}
|
|
11
|
-
export declare class CollectionService {
|
|
12
|
-
private readonly collectionRepository;
|
|
13
|
-
private readonly tagService;
|
|
14
|
-
constructor(collectionRepository: CollectionRepository, tagService: TagService);
|
|
15
|
-
private validateFilterExpression;
|
|
16
|
-
listCollections(request: {
|
|
17
|
-
limit: number;
|
|
18
|
-
offset: number;
|
|
19
|
-
type: CollectionType | undefined;
|
|
20
|
-
}): Promise<PaginatedResponse<Collection>>;
|
|
21
|
-
getCollection(id: string): Promise<Collection>;
|
|
22
|
-
createCollection(request: CreateCollectionRequest): Promise<Collection>;
|
|
23
|
-
updateCollection(request: UpdateCollectionRequest): Promise<Collection>;
|
|
24
|
-
deleteCollection(id: string): Promise<void>;
|
|
25
|
-
addMember(collectionId: string, documentId: string): Promise<void>;
|
|
26
|
-
removeMember(collectionId: string, documentId: string): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type EmptyObject = Record<string, never>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ApiError } from "./ApiError.js";
|
|
2
|
-
export declare class MissingEnvironmentVariableError extends ApiError {
|
|
3
|
-
constructor(variableName: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class InvalidEnvironmentVariableError extends ApiError {
|
|
6
|
-
constructor(variableName: string, value: string, allowedValues?: string);
|
|
7
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { FileServiceConfig } from "../files/FileService.js";
|
|
2
|
-
import type { DbServiceConfig } from "../sql/DbService.js";
|
|
3
|
-
import type { MigrationServiceConfig } from "../sql/MigrationService.js";
|
|
4
|
-
declare const validStages: readonly ["development", "staging", "production"];
|
|
5
|
-
export declare class EnvironmentService {
|
|
6
|
-
private getStringEnvVar;
|
|
7
|
-
private getRequiredStringEnvVar;
|
|
8
|
-
private getNumberEnvVar;
|
|
9
|
-
private getRequiredNumberEnvVar;
|
|
10
|
-
get backendPort(): number;
|
|
11
|
-
get databaseConfig(): DbServiceConfig;
|
|
12
|
-
get stage(): (typeof validStages)[number];
|
|
13
|
-
get migrationServiceConfig(): MigrationServiceConfig;
|
|
14
|
-
get fileUploadSizeLimit(): number;
|
|
15
|
-
get websocketPort(): number;
|
|
16
|
-
get fileServiceConfig(): FileServiceConfig;
|
|
17
|
-
get redisHost(): string;
|
|
18
|
-
get redisPort(): number;
|
|
19
|
-
get logLevel(): string;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentService } from "./EnvironmentService.js";
|
|
2
|
-
export type Logger = {
|
|
3
|
-
debug: (message: string, ...args: unknown[]) => void;
|
|
4
|
-
info: (message: string, ...args: unknown[]) => void;
|
|
5
|
-
warn: (message: string, ...args: unknown[]) => void;
|
|
6
|
-
error: (message: string, ...args: unknown[]) => void;
|
|
7
|
-
critical: (message: string, ...args: unknown[]) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare class LoggingService implements Logger {
|
|
10
|
-
private readonly envService;
|
|
11
|
-
private readonly logger;
|
|
12
|
-
constructor(envService: EnvironmentService);
|
|
13
|
-
debug(message: string, ...args: unknown[]): void;
|
|
14
|
-
info(message: string, ...args: unknown[]): void;
|
|
15
|
-
warn(message: string, ...args: unknown[]): void;
|
|
16
|
-
error(message: string, ...args: unknown[]): void;
|
|
17
|
-
critical(message: string, ...args: unknown[]): void;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const withErrorHandler: <T extends (...args: any[]) => any | Promise<any>>(_target: unknown, _key: string, property: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { DbService } from "../sql/DbService.js";
|
|
2
|
-
export type CreateDocumentRequest = {
|
|
3
|
-
id: string;
|
|
4
|
-
basePath: string;
|
|
5
|
-
filename: string;
|
|
6
|
-
type: string;
|
|
7
|
-
};
|
|
8
|
-
export type Document = {
|
|
9
|
-
id: string;
|
|
10
|
-
mime: string;
|
|
11
|
-
previousId: string | undefined;
|
|
12
|
-
nextId: string | undefined;
|
|
13
|
-
queryIndex: number;
|
|
14
|
-
};
|
|
15
|
-
export type DocumentWithPathInfo = Document & {
|
|
16
|
-
base_path: string;
|
|
17
|
-
filename: string;
|
|
18
|
-
};
|
|
19
|
-
export declare class DocumentRepository {
|
|
20
|
-
private readonly dbService;
|
|
21
|
-
constructor(dbService: DbService);
|
|
22
|
-
createDocument(request: CreateDocumentRequest): Promise<void>;
|
|
23
|
-
getDocumentWithPathInfo(id: string): Promise<DocumentWithPathInfo>;
|
|
24
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CreateDocumentRequest, DocumentRepository } from "./DocumentRepository.js";
|
|
2
|
-
import type { TagService } from "../tags/TagService.js";
|
|
3
|
-
import { FileDownload, FileStream } from "../ApiHandler.js";
|
|
4
|
-
export declare class DocumentService {
|
|
5
|
-
private readonly documentRepository;
|
|
6
|
-
private readonly tagService;
|
|
7
|
-
constructor(documentRepository: DocumentRepository, tagService: TagService);
|
|
8
|
-
createDocument(request: CreateDocumentRequest): Promise<void>;
|
|
9
|
-
getDocumentThumbnail(id: string): Promise<string>;
|
|
10
|
-
getDocument(id: string, rangeHeader: string | undefined): Promise<FileDownload | FileStream>;
|
|
11
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
export type FileServiceConfig = {
|
|
3
|
-
defaultThumbnailPath: string;
|
|
4
|
-
documentStoreConfigPath: string;
|
|
5
|
-
};
|
|
6
|
-
type MoveDocumentResult = {
|
|
7
|
-
id: string;
|
|
8
|
-
basePath: string;
|
|
9
|
-
filename: string;
|
|
10
|
-
};
|
|
11
|
-
declare const documentStoreConfigSchema: z.ZodObject<{
|
|
12
|
-
stores: z.ZodArray<z.ZodObject<{
|
|
13
|
-
path: z.ZodString;
|
|
14
|
-
}, z.z.core.$strip>>;
|
|
15
|
-
}, z.z.core.$strip>;
|
|
16
|
-
export declare class FileService {
|
|
17
|
-
private readonly config;
|
|
18
|
-
private storeConfig?;
|
|
19
|
-
constructor();
|
|
20
|
-
getFileServiceConfig(): z.infer<typeof documentStoreConfigSchema> | undefined;
|
|
21
|
-
private findBasePathForDocument;
|
|
22
|
-
private createThumbnail;
|
|
23
|
-
moveDocument(source: string, type: string, extension: string, size: number): Promise<MoveDocumentResult>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { DocumentService } from "../documents/DocumentService.js";
|
|
2
|
-
import type { ApiTag } from "../tags/TagRepository.js";
|
|
3
|
-
import type { TagService } from "../tags/TagService.js";
|
|
4
|
-
import type { WebSocketService } from "../websocket/WebSocketService.js";
|
|
5
|
-
import type { FileService } from "./FileService.js";
|
|
6
|
-
type ProcessUploadDocument = {
|
|
7
|
-
name: string;
|
|
8
|
-
file: string;
|
|
9
|
-
size: number;
|
|
10
|
-
mimeType: string;
|
|
11
|
-
extension: string;
|
|
12
|
-
webSocketClientId: string;
|
|
13
|
-
tags: ApiTag[];
|
|
14
|
-
};
|
|
15
|
-
export declare class UploadService {
|
|
16
|
-
private readonly fileService;
|
|
17
|
-
private readonly documentService;
|
|
18
|
-
private readonly tagService;
|
|
19
|
-
private readonly webSocketServer;
|
|
20
|
-
constructor(fileService: FileService, documentService: DocumentService, tagService: TagService, webSocketServer: WebSocketService);
|
|
21
|
-
processUploadDocument(upload: ProcessUploadDocument): Promise<void>;
|
|
22
|
-
private notifyUploadSuccess;
|
|
23
|
-
private notifyUploadFailed;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { FileTypePlugin } from "./plugin.js";
|
|
2
|
-
export declare const fileTypes: Record<string, FileTypePlugin>;
|
|
3
|
-
export declare const addFileTypePlugin: (name: string, plugin: FileTypePlugin) => void;
|
|
4
|
-
export declare const getFileTypePluginByType: (type: string) => FileTypePlugin | undefined;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { FileTypePlugin } from "./plugin.js";
|
|
2
|
-
export declare const pdfPlugin: FileTypePlugin;
|
|
3
|
-
export declare const imagePlugin: FileTypePlugin;
|
|
4
|
-
export declare const videoPlugin: FileTypePlugin;
|
|
5
|
-
export declare const audioPlugin: FileTypePlugin;
|
|
6
|
-
export declare const standardPlugins: {
|
|
7
|
-
pdf: FileTypePlugin;
|
|
8
|
-
image: FileTypePlugin;
|
|
9
|
-
video: FileTypePlugin;
|
|
10
|
-
audio: FileTypePlugin;
|
|
11
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentService } from "../common/EnvironmentService.js";
|
|
2
|
-
export declare class RedisClient {
|
|
3
|
-
private readonly envService;
|
|
4
|
-
private readonly client;
|
|
5
|
-
private static buildEndpoint;
|
|
6
|
-
constructor(envService: EnvironmentService);
|
|
7
|
-
connect(): Promise<void>;
|
|
8
|
-
get(key: string): Promise<string | null>;
|
|
9
|
-
set(key: string, value: string): Promise<void>;
|
|
10
|
-
del(key: string): Promise<void>;
|
|
11
|
-
disconnect(): Promise<void>;
|
|
12
|
-
}
|
package/types/sql/DbService.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type ClientConfig, type QueryConfig } from "pg";
|
|
2
|
-
import type { EnvironmentService } from "../common/EnvironmentService.js";
|
|
3
|
-
import z from "zod";
|
|
4
|
-
import type { LoggingService } from "../common/LoggingService.js";
|
|
5
|
-
export type DbServiceConfig = ClientConfig;
|
|
6
|
-
type ZodSchemaType = z.ZodObject | z.ZodIntersection;
|
|
7
|
-
declare abstract class DbTask {
|
|
8
|
-
abstract one<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema>>;
|
|
9
|
-
abstract many<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema>[]>;
|
|
10
|
-
abstract any<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema>[]>;
|
|
11
|
-
abstract oneOrNone<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema> | null>;
|
|
12
|
-
abstract none(queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<void>;
|
|
13
|
-
abstract transaction(onTransaction: () => Promise<void>): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export declare class DbService implements DbTask {
|
|
16
|
-
private readonly logger;
|
|
17
|
-
private readonly configOverride?;
|
|
18
|
-
private readonly config;
|
|
19
|
-
private client_;
|
|
20
|
-
constructor(envService: EnvironmentService, logger: LoggingService, configOverride?: DbServiceConfig | undefined);
|
|
21
|
-
private get client();
|
|
22
|
-
connect(): Promise<void>;
|
|
23
|
-
disconnect(): Promise<void>;
|
|
24
|
-
one<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema>>;
|
|
25
|
-
many<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema>[]>;
|
|
26
|
-
any<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema>[]>;
|
|
27
|
-
oneOrNone<ResultSchema extends ZodSchemaType>(schema: ResultSchema, queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<z.infer<ResultSchema> | null>;
|
|
28
|
-
transaction(onTransaction: () => Promise<void>): Promise<void>;
|
|
29
|
-
none(queryTextOrConfig: string | QueryConfig<unknown[]>, values?: unknown[] | Record<string, unknown>): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentService } from "../common/EnvironmentService.js";
|
|
2
|
-
import type { DbService } from "./DbService.js";
|
|
3
|
-
import type { LoggingService } from "../common/LoggingService.js";
|
|
4
|
-
export type MigrationServiceConfig = {
|
|
5
|
-
migrationsDir: string;
|
|
6
|
-
ignoreChecksumMismatches: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare class MigrationService {
|
|
9
|
-
private readonly envService;
|
|
10
|
-
private readonly dbService;
|
|
11
|
-
private readonly logger;
|
|
12
|
-
constructor(envService: EnvironmentService, dbService: DbService, logger: LoggingService);
|
|
13
|
-
private checkMigrationsTableExists;
|
|
14
|
-
private setupMigrationsTable;
|
|
15
|
-
private calculateFileChecksum;
|
|
16
|
-
private listMigrationFiles;
|
|
17
|
-
private validateExistingMigrations;
|
|
18
|
-
private applyMigration;
|
|
19
|
-
private applyMissingMigrations;
|
|
20
|
-
migrate(): Promise<void>;
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ApiError } from "../../common/ApiError.js";
|
|
2
|
-
export declare class InvalidRowNumberError extends ApiError {
|
|
3
|
-
readonly rows: number | null;
|
|
4
|
-
readonly minExpected: number;
|
|
5
|
-
readonly maxExpected: number;
|
|
6
|
-
constructor(rows: number | null, minExpected: number, maxExpected: number);
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FileService } from "../files/FileService.js";
|
|
2
|
-
import type { DbService } from "../sql/DbService.js";
|
|
3
|
-
export interface StoreState {
|
|
4
|
-
free: number;
|
|
5
|
-
total: number;
|
|
6
|
-
used: number;
|
|
7
|
-
numberOfDocuments: number;
|
|
8
|
-
basePath: string;
|
|
9
|
-
}
|
|
10
|
-
export interface PluginState {
|
|
11
|
-
name: string;
|
|
12
|
-
trusted: boolean;
|
|
13
|
-
description: string;
|
|
14
|
-
}
|
|
15
|
-
export interface BackendState {
|
|
16
|
-
stores: StoreState[];
|
|
17
|
-
plugins: PluginState[];
|
|
18
|
-
uptime: number;
|
|
19
|
-
version: string;
|
|
20
|
-
commit: string;
|
|
21
|
-
}
|
|
22
|
-
export declare class BackendStateRepository {
|
|
23
|
-
private readonly dbService;
|
|
24
|
-
private readonly fileService;
|
|
25
|
-
constructor(dbService: DbService, fileService: FileService);
|
|
26
|
-
private getStoreState;
|
|
27
|
-
getBackendState(): Promise<BackendState>;
|
|
28
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BackendState, BackendStateRepository } from "./BackendStateRepository.js";
|
|
2
|
-
export declare class BackendStateService {
|
|
3
|
-
private readonly backendStateRepository;
|
|
4
|
-
constructor(backendStateRepository: BackendStateRepository);
|
|
5
|
-
getBackendState(): Promise<BackendState>;
|
|
6
|
-
}
|
package/types/tags/TagCache.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type MetaTag, type Tag } from "@lars_hagemann/tags";
|
|
2
|
-
import type { RedisClient } from "../redis/RedisClient.js";
|
|
3
|
-
export declare class TagCache {
|
|
4
|
-
private readonly redisClient;
|
|
5
|
-
constructor(redisClient: RedisClient);
|
|
6
|
-
init(tags: {
|
|
7
|
-
tag: Tag | MetaTag;
|
|
8
|
-
tagId: string;
|
|
9
|
-
}[]): Promise<void>;
|
|
10
|
-
tagToTagId(tag: Tag | MetaTag): Promise<string>;
|
|
11
|
-
onTagAdded(tag: Tag | MetaTag, tagId: string): Promise<void>;
|
|
12
|
-
onTagDeleted(tag: Tag | MetaTag): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { MetaTag, Tag } from "@lars_hagemann/tags";
|
|
2
|
-
import type { DbService } from "../sql/DbService.js";
|
|
3
|
-
import { type PaginatedResponse } from "../util/PaginatedResponse.js";
|
|
4
|
-
import type { Document } from "../documents/DocumentRepository.js";
|
|
5
|
-
import type { TagCache } from "./TagCache.js";
|
|
6
|
-
export interface ListTagsRequest {
|
|
7
|
-
limit: number;
|
|
8
|
-
offset: number;
|
|
9
|
-
tag: ApiTag;
|
|
10
|
-
}
|
|
11
|
-
export type ListDocumentsRequest = {
|
|
12
|
-
offset: number;
|
|
13
|
-
limit: number;
|
|
14
|
-
query: string;
|
|
15
|
-
seed?: string;
|
|
16
|
-
};
|
|
17
|
-
export type ApiTag = {
|
|
18
|
-
key: string;
|
|
19
|
-
value: string | undefined;
|
|
20
|
-
type: string;
|
|
21
|
-
};
|
|
22
|
-
export type ApiTagWithCount = ApiTag & {
|
|
23
|
-
usageCount: number;
|
|
24
|
-
};
|
|
25
|
-
export declare class TagRepository {
|
|
26
|
-
private readonly dbService;
|
|
27
|
-
private readonly tagCache;
|
|
28
|
-
private readonly sqlBuilder;
|
|
29
|
-
constructor(dbService: DbService, tagCache: TagCache);
|
|
30
|
-
listDocuments({ offset, limit, query, seed, }: ListDocumentsRequest): Promise<PaginatedResponse<Document>>;
|
|
31
|
-
listTags(request: ListTagsRequest): Promise<PaginatedResponse<ApiTagWithCount>>;
|
|
32
|
-
addTags(tags: ApiTag[]): Promise<void>;
|
|
33
|
-
addTagToDocument(documentId: string, tag: ApiTag): Promise<void>;
|
|
34
|
-
removeTagFromDocument(documentId: string, tag: Tag | MetaTag): Promise<void>;
|
|
35
|
-
getTagsForDocument(documentId: string): Promise<ApiTag[]>;
|
|
36
|
-
deleteTag(key: string, value: string): Promise<void>;
|
|
37
|
-
enumerateTags(): Promise<{
|
|
38
|
-
id: number;
|
|
39
|
-
key: string;
|
|
40
|
-
value: string | null;
|
|
41
|
-
type: string;
|
|
42
|
-
}[]>;
|
|
43
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MetaTag, Tag } from "@lars_hagemann/tags";
|
|
2
|
-
import type { ApiTag, ListDocumentsRequest, TagRepository } from "./TagRepository.js";
|
|
3
|
-
import type { PaginatedResponse } from "../util/PaginatedResponse.js";
|
|
4
|
-
import type { Document } from "../documents/DocumentRepository.js";
|
|
5
|
-
import type { TagCache } from "./TagCache.js";
|
|
6
|
-
export type ListTagsRequest = {
|
|
7
|
-
limit: number;
|
|
8
|
-
offset: number;
|
|
9
|
-
query: string;
|
|
10
|
-
};
|
|
11
|
-
export declare class TagService {
|
|
12
|
-
private tagRepository;
|
|
13
|
-
private readonly tagCache;
|
|
14
|
-
constructor(tagRepository: TagRepository, tagCache: TagCache);
|
|
15
|
-
static normalizeTag(tag: string, type?: string): ApiTag;
|
|
16
|
-
static toString(tag: Tag | MetaTag): string;
|
|
17
|
-
listTags(request: ListTagsRequest): Promise<PaginatedResponse<import("./TagRepository.js").ApiTagWithCount>>;
|
|
18
|
-
listDocuments(request: ListDocumentsRequest): Promise<PaginatedResponse<Document>>;
|
|
19
|
-
getTagsForDocument(documentId: string): Promise<ApiTag[]>;
|
|
20
|
-
addTagToDocument(documentId: string, tag: string, type?: string): Promise<void>;
|
|
21
|
-
removeTagFromDocument(documentId: string, tag: string): Promise<void>;
|
|
22
|
-
deleteTag(key: string, value: string): Promise<void>;
|
|
23
|
-
initIdCache(): Promise<void>;
|
|
24
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { MetaTag, Tag, type Filter } from "@lars_hagemann/tags";
|
|
2
|
-
import type { TagCache } from "./TagCache.js";
|
|
3
|
-
export type TagSqlBuilderConfig = {
|
|
4
|
-
userdataTableName: string;
|
|
5
|
-
userdataTableIdColumn: string;
|
|
6
|
-
userdataTableColumns: string[];
|
|
7
|
-
};
|
|
8
|
-
export type SelectStatement = {
|
|
9
|
-
with?: {
|
|
10
|
-
name: string;
|
|
11
|
-
body: string;
|
|
12
|
-
}[];
|
|
13
|
-
select: string[];
|
|
14
|
-
from: string;
|
|
15
|
-
joins?: {
|
|
16
|
-
join: "INNER" | "LEFT" | "RIGHT";
|
|
17
|
-
table: string;
|
|
18
|
-
on: string;
|
|
19
|
-
}[];
|
|
20
|
-
groupBy?: string;
|
|
21
|
-
having?: string;
|
|
22
|
-
sort?: {
|
|
23
|
-
field: "timestamp" | "random" | string;
|
|
24
|
-
direction?: "asc" | "desc";
|
|
25
|
-
nulls?: "first" | "last";
|
|
26
|
-
}[];
|
|
27
|
-
where?: string;
|
|
28
|
-
limit?: string | number;
|
|
29
|
-
offset?: string | number;
|
|
30
|
-
};
|
|
31
|
-
export type OnConflict = {
|
|
32
|
-
action: "DO NOTHING";
|
|
33
|
-
} | {
|
|
34
|
-
action: "DO UPDATE";
|
|
35
|
-
target?: string | string[];
|
|
36
|
-
set: {
|
|
37
|
-
[column: string]: string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export type UpdateStatement = {
|
|
41
|
-
table: string;
|
|
42
|
-
set: {
|
|
43
|
-
[column: string]: string;
|
|
44
|
-
};
|
|
45
|
-
where?: string;
|
|
46
|
-
onConflict?: OnConflict;
|
|
47
|
-
};
|
|
48
|
-
export type DeleteStatement = {
|
|
49
|
-
table: string;
|
|
50
|
-
where?: string;
|
|
51
|
-
};
|
|
52
|
-
export type InsertStatement = {
|
|
53
|
-
table: string;
|
|
54
|
-
columns: string[];
|
|
55
|
-
values: (string | number)[];
|
|
56
|
-
onConflict?: OnConflict;
|
|
57
|
-
};
|
|
58
|
-
export declare const buildQueryFromSelectStatement: (stmt: SelectStatement) => string;
|
|
59
|
-
export declare const buildQueryFromUpdateStatement: (stmt: UpdateStatement) => string;
|
|
60
|
-
export declare const buildQueryFromDeleteStatement: (stmt: DeleteStatement) => string;
|
|
61
|
-
export declare const buildQueryFromInsertStatement: (stmt: InsertStatement) => string;
|
|
62
|
-
export type TagSqlBuilderResult<T = SelectStatement, Parameters extends string[] = []> = {
|
|
63
|
-
success: false;
|
|
64
|
-
message: string;
|
|
65
|
-
} | {
|
|
66
|
-
success: true;
|
|
67
|
-
stmt: T;
|
|
68
|
-
};
|
|
69
|
-
export declare class TagSqlBuilder {
|
|
70
|
-
private readonly builderConfig;
|
|
71
|
-
private readonly tagCache;
|
|
72
|
-
private readonly currentParse;
|
|
73
|
-
constructor(builderConfig: TagSqlBuilderConfig, tagCache: TagCache);
|
|
74
|
-
private parseMetaTag;
|
|
75
|
-
private sqlFilterConditions;
|
|
76
|
-
private setupParse;
|
|
77
|
-
buildListFilteredEntitiesQuery(filter: Filter): Promise<TagSqlBuilderResult<SelectStatement, ["$limit", "$offset"]>>;
|
|
78
|
-
buildListEntityTagsQuery(): TagSqlBuilderResult<SelectStatement, [
|
|
79
|
-
"$entityId"
|
|
80
|
-
]>;
|
|
81
|
-
buildAddTagToEntityQuery(tag: Tag | MetaTag): Promise<TagSqlBuilderResult<InsertStatement, ["$entityId"]>>;
|
|
82
|
-
buildRemoveTagFromEntityQuery(tag: Tag | MetaTag): Promise<TagSqlBuilderResult<DeleteStatement, ["$entityId"]>>;
|
|
83
|
-
buildListTagsQuery(): TagSqlBuilderResult<SelectStatement, [
|
|
84
|
-
"$limit",
|
|
85
|
-
"$offset",
|
|
86
|
-
"$tagKey",
|
|
87
|
-
"$tagValue"
|
|
88
|
-
]>;
|
|
89
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
export type PaginatedResponse<T> = {
|
|
3
|
-
items: T[];
|
|
4
|
-
total: number;
|
|
5
|
-
};
|
|
6
|
-
export declare const withPaginationSchema: z.ZodObject<{
|
|
7
|
-
__total: z.ZodNumber;
|
|
8
|
-
}, z.z.core.$strip>;
|
|
9
|
-
export type WithPaginationSchema = z.infer<typeof withPaginationSchema>;
|
|
10
|
-
export declare const paginated: <T extends z.ZodObject>(schema: T) => z.ZodIntersection<T, z.ZodObject<{
|
|
11
|
-
__total: z.ZodNumber;
|
|
12
|
-
}, z.z.core.$strip>>;
|
|
13
|
-
export declare const toPaginatedResponse: <T extends z.infer<typeof withPaginationSchema>>(data: T[]) => PaginatedResponse<Omit<T, "__total">>;
|
package/types/util/tag.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentService } from "../common/EnvironmentService.js";
|
|
2
|
-
import type { LoggingService } from "../common/LoggingService.js";
|
|
3
|
-
export declare class WebSocketService {
|
|
4
|
-
private readonly logger;
|
|
5
|
-
private wss?;
|
|
6
|
-
private readonly port;
|
|
7
|
-
private readonly clients;
|
|
8
|
-
constructor(envService: EnvironmentService, logger: LoggingService);
|
|
9
|
-
private generateClientId;
|
|
10
|
-
start(): Promise<void>;
|
|
11
|
-
stop(): Promise<void>;
|
|
12
|
-
send(message: string, webSocketClientId: string): Promise<void>;
|
|
13
|
-
}
|