mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-27 23:07:12 +02:00
remove IDataStoreService interface and use RegExp
This commit is contained in:
parent
815688be79
commit
205078fc3e
|
|
@ -56,5 +56,4 @@ export {
|
|||
type DataStoreRows,
|
||||
type DataStoreListOptions,
|
||||
type DataStoreUserTableName,
|
||||
type IDataStoreService,
|
||||
} from './schemas/data-store.schema';
|
||||
|
|
|
|||
|
|
@ -1,16 +1,6 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
import type {
|
||||
AddDataStoreColumnDto,
|
||||
CreateDataStoreDto,
|
||||
DataStoreColumnResultDto,
|
||||
DataStoreResultDto,
|
||||
DeleteDataStoreColumnDto,
|
||||
ListDataStoreContentQueryDto,
|
||||
ListDataStoreQueryDto,
|
||||
MoveDataStoreColumnDto,
|
||||
UpdateDataStoreDto,
|
||||
} from '../dto';
|
||||
import type { ListDataStoreQueryDto } from '../dto';
|
||||
|
||||
export const dataStoreNameSchema = z.string().trim().min(1).max(128);
|
||||
export const dataStoreIdSchema = z.string().max(36);
|
||||
|
|
@ -23,7 +13,7 @@ export const dataStoreColumnNameSchema = z
|
|||
.min(1)
|
||||
.max(128)
|
||||
.regex(
|
||||
/^[a-zA-Z0-9][a-zA-Z0-9-]*$/,
|
||||
DATA_STORE_COLUMN_REGEX,
|
||||
'Only alphanumeric characters and non-leading dashes are allowed for column names',
|
||||
);
|
||||
export const dataStoreColumnTypeSchema = z.enum(['string', 'number', 'boolean', 'date']);
|
||||
|
|
@ -64,26 +54,3 @@ export type DataStoreListOptions = Partial<ListDataStoreQueryDto> & {
|
|||
export type DataStoreColumnJsType = string | number | boolean | Date;
|
||||
|
||||
export type DataStoreRows = Array<Record<PropertyKey, DataStoreColumnJsType | null>>;
|
||||
|
||||
export interface IDataStoreService {
|
||||
createDataStore(projectId: string, dto: CreateDataStoreDto): Promise<DataStoreResultDto>;
|
||||
updateDataStore(dataStoreId: string, dto: UpdateDataStoreDto): Promise<boolean>;
|
||||
getManyAndCount(
|
||||
options: DataStoreListOptions,
|
||||
): Promise<{ count: number; data: DataStoreResultDto[] }>;
|
||||
|
||||
deleteDataStoreByProjectId(projectId: string): Promise<boolean>;
|
||||
deleteDataStoreAll(): Promise<boolean>;
|
||||
deleteDataStore(dataStoreId: string): Promise<boolean>;
|
||||
|
||||
getColumns(dataStoreId: string): Promise<DataStoreColumnResultDto[]>;
|
||||
addColumn(dataStoreId: string, dto: AddDataStoreColumnDto): Promise<DataStoreColumnResultDto>;
|
||||
moveColumn(dataStoreId: string, columnId: string, dto: MoveDataStoreColumnDto): Promise<boolean>;
|
||||
deleteColumn(dataStoreId: string, dto: DeleteDataStoreColumnDto): Promise<boolean>;
|
||||
|
||||
getManyRowsAndCount(
|
||||
dataStoreId: string,
|
||||
dto: Partial<ListDataStoreContentQueryDto>,
|
||||
): Promise<{ count: number; data: DataStoreRows[] }>;
|
||||
insertRows(dataStoreId: string, rows: DataStoreRows): Promise<boolean>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import type {
|
|||
MoveDataStoreColumnDto,
|
||||
DataStoreListOptions,
|
||||
DataStoreRows,
|
||||
IDataStoreService,
|
||||
UpsertDataStoreRowsDto,
|
||||
} from '@n8n/api-types';
|
||||
import { UpdateDataStoreDto } from '@n8n/api-types/src/dto/data-store/update-data-store.dto';
|
||||
|
|
@ -20,7 +19,7 @@ import { DataStoreRepository } from './data-store.repository';
|
|||
import { toTableName } from './utils/sql-utils';
|
||||
|
||||
@Service()
|
||||
export class DataStoreService implements IDataStoreService {
|
||||
export class DataStoreService {
|
||||
constructor(
|
||||
private readonly dataStoreRepository: DataStoreRepository,
|
||||
private readonly dataStoreColumnRepository: DataStoreColumnRepository,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user