basic csv support
+ csv imports + import options + type detection + bool, number, date, text, email and json types supported
This commit is contained in:
21
types/csv.ts
Normal file
21
types/csv.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { CommonCSVReaderOptions } from "https://deno.land/x/csv@v0.8.0/reader.ts";
|
||||
|
||||
/**
|
||||
* Options object of `csv.readCSVObjects`.
|
||||
*/
|
||||
export type ParserOptions = Partial<CommonCSVReaderOptions>;
|
||||
|
||||
/**
|
||||
* Raw row object with string properties returned by `csv.readCSVObjects`.
|
||||
*/
|
||||
export type RawRow = {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Row object with values parsed accordingly to collection schema.
|
||||
*/
|
||||
export type ParsedRow = {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
[key: string]: any;
|
||||
};
|
34
types/pocketbase.ts
Normal file
34
types/pocketbase.ts
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* All the Pocketbase types supported by this tool.
|
||||
*/
|
||||
export const POCKETBASE_TYPE = {
|
||||
BOOL: "bool",
|
||||
NUMBER: "number",
|
||||
PLAIN_TEXT: "text",
|
||||
EMAIL: "email",
|
||||
JSON: "json",
|
||||
DATETIME: "date",
|
||||
} as const;
|
||||
|
||||
type ObjectValues<T> = T[keyof T];
|
||||
|
||||
/**
|
||||
* Supported Pocketbase data types.
|
||||
*/
|
||||
export type PocketbaseType = ObjectValues<typeof POCKETBASE_TYPE>;
|
||||
|
||||
/**
|
||||
* A row type schema for column value parsing.
|
||||
*/
|
||||
export type PocketbaseRowSchema = {
|
||||
[key: string]: PocketbaseType;
|
||||
};
|
||||
|
||||
/**
|
||||
* PocketBase system fields with autogenerated values that cannot be overriden (`base` collection type).
|
||||
*/
|
||||
export const POCKETBASE_SYSFIELD = [
|
||||
"id",
|
||||
"created",
|
||||
"updated",
|
||||
];
|
Reference in New Issue
Block a user