mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(core): Support inserting dates to data store via the insert endpoint (#18404)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { z } from 'zod';
|
||||
import { Z } from 'zod-class';
|
||||
|
||||
import { dataStoreColumnNameSchema } from '../../schemas/data-store.schema';
|
||||
import {
|
||||
dataStoreColumnNameSchema,
|
||||
dataStoreColumnValueSchema,
|
||||
} from '../../schemas/data-store.schema';
|
||||
|
||||
export class AddDataStoreRowsDto extends Z.class({
|
||||
data: z.array(z.record(dataStoreColumnNameSchema, z.any())),
|
||||
data: z.array(z.record(dataStoreColumnNameSchema, dataStoreColumnValueSchema)),
|
||||
}) {}
|
||||
|
||||
@@ -56,4 +56,5 @@ export {
|
||||
type DataStoreRows,
|
||||
type DataStoreListOptions,
|
||||
type DataStoreUserTableName,
|
||||
dateTimeSchema,
|
||||
} from './schemas/data-store.schema';
|
||||
|
||||
@@ -51,6 +51,15 @@ export type DataStoreListOptions = Partial<ListDataStoreQueryDto> & {
|
||||
filter: { projectId: string };
|
||||
};
|
||||
|
||||
export const dateTimeSchema = z
|
||||
.string()
|
||||
.datetime({ offset: true })
|
||||
.transform((s) => new Date(s))
|
||||
.pipe(z.date());
|
||||
|
||||
// Dates are received as date strings and validated before insertion
|
||||
export const dataStoreColumnValueSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
||||
|
||||
export type DataStoreColumnJsType = string | number | boolean | Date;
|
||||
|
||||
export type DataStoreRows = Array<Record<string, DataStoreColumnJsType | null>>;
|
||||
|
||||
Reference in New Issue
Block a user