Start adding filters, migrate types to zod, update readme
All checks were successful
build / build (push) Successful in 1m22s

This commit is contained in:
2025-04-25 09:30:38 +09:30
parent d225ff9048
commit 7bc6ca8a39
3 changed files with 51 additions and 74 deletions

View File

@@ -1,21 +1,39 @@
import { Injectable, OnInit } from '@angular/core';
import * as duckdb from '@duckdb/duckdb-wasm';
import { connect } from 'rxjs';
import { z } from 'zod';
export interface Column {
name: string;
type: string;
}
export const Column = z.object({
name: z.string(),
type: z.string(),
});
export interface SortColumn {
name: string;
sortType: 'asc' | 'desc';
}
const SortColumn = z.object({
name: z.string(),
sortType: z.enum(['asc', 'desc']),
});
export interface RowsResponse {
rows: any[];
totalRows: bigint;
}
const Filter = z.object({
value: z.string().array(),
operator: z.enum(['and', 'or']),
matchType: z.enum([
'startsWith',
'contains',
'notContains',
'endsWith',
'equals',
'notEquals',
]),
});
const RowsResponse = z.object({
rows: z.any(),
totalRows: z.bigint(),
});
export type Column = z.infer<typeof Column>;
export type SortColumn = z.infer<typeof SortColumn>;
export type Filter = z.infer<typeof Filter>;
export type RowsResponse = z.infer<typeof RowsResponse>;
const sanitisedFileName = (file: File) =>
file.name.toLowerCase().replaceAll("'", '').replaceAll(/\s*/g, '');
@@ -104,7 +122,7 @@ export class DuckdbService {
numRows: number,
columns: Column[],
sorts: SortColumn[],
filters: unknown[],
filters: Filter[],
aggregations: unknown[],
): Promise<RowsResponse> {
const conn = await this.db.connect();