--- url: 'https://punchupworld.github.io/sheethuahua/guide/0-introduction.md' description: >- Overview of Sheethuahua — a set of schemas, transformers, type-safe parsers and formatters for CSV and Google Sheets data, with notes on Google Sheets rate limits. --- # Introduction CSV (or Google Sheets) is an easy to used data format. But it is quite unpredictable, and not that flexible. We aim to help you with **"Sheethuahua"**, a set of schemas, transformers, type-safe parsers and formatters. What you need to do is: 1. Define the **output schema** and **how each column is mapped and transformed** 2. Use the parser or formatter function to **validate and transform** CSV to JavaScript data and vice versa. Using [TypeBox](https://github.com/sinclairzx81/typebox), [d3-dsv](https://d3js.org/d3-dsv), [Web Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) (and [Tempo](https://tempo.formkit.com) for date transformer) under the hood, Sheethuahua should be supported by every modern browsers and back-end runtime. ## Notes for Google Sheets Google Sheets has a great potential of being an API read-only database with a user-friendly interface for content editor. But it has [a very low rate limit](https://developers.google.com/sheets/api/limits). **It should be used with Static Site Generation (SSG) or [caching](/plugin/caching.html)**. > WeVis's [Parliament Watch](https://parliamentwatch.wevis.info/) use Google Sheets as a database with SSG. --- --- url: 'https://punchupworld.github.io/sheethuahua/guide/1-getting-started.md' description: >- Installation instructions for the sheethuahua npm package (npm, yarn, pnpm, bun) and example imports of core functions. --- # Getting Started Sheethuahua is available on [NPM](https://www.npmjs.com/package/sheethuahua) package repository. ![NPM Version](https://img.shields.io/npm/v/sheethuahua) ::: code-group ```bash [npm] npm i sheethuahua ``` ```bash [yarn] yarn add sheethuahua ``` ```bash [pnpm] pnpm add sheethuahua ``` ```bash [bun] bun add sheethuahua ``` ::: The package provide functions *(schemas, transformers, parsers, and formatters)* that can be imported as needed. ```ts import { Column, Object, Spreadsheet, Tuple, asNumber, asString, // ... } from 'sheethuahua'; ``` ::: tip 🤖 LLM texts are available in [standard](/llms.txt) and [full](/llms-full.txt) version ::: --- --- url: 'https://punchupworld.github.io/sheethuahua/guide/2-schema.md' description: >- Schema definition using Column, Object, and Tuple — including nested schemas and type inference with StaticDecode. --- # Schema Schemas define how each row from CSV/Sheet will be transformed into. Let's assume this table is the input CSV data: | ID | Name | | --- | ------- | | 1 | Samoyed | | 2 | Shiba | ## Column [`Column()`](/references/functions/Column.html) map value from the column in the CSV/Sheets. If we describe schema as: ```ts import { Column, asString } from 'sheethuahua'; const schema = Column('Name', asString()); ``` > In each row, I want a value from column *"Name"* and parse is as a string. Then the output will be: ```ts ['Samoyed', 'Shiba']; ``` ## Object [`Object()`](/references/functions/Object.html) define an object data structure. If we describe schema as: ```ts import { Column, Object, asNumber, asString } from 'sheethuahua'; const schema = Object({ id: Column('ID', asNumber()), name: Column('Name', asString()), }); ``` Then the output will be: ```ts [ { id: 1, name: 'Samoyed' }, { id: 2, name: 'Shiba' }, ]; ``` ## Tuple [`Tuple()`](/references/functions/Tuple.html) define an array of the exact set of items. If we describe schema as: ```ts import { Tuple, Object, asNumber, asString } from 'sheethuahua'; const schema = Tuple([ id: Column('ID', asNumber()), name: Column('Name', asString()), ]) ``` Then the output will be: ```ts [ [1, 'Samoyed'], [2, 'Shiba'], ]; ``` ## Nested Both `Object` and `Tuple` can be nested. ```ts import { Column, Object, Tuple, asNumber, asString } from 'sheethuahua'; const schema = Object({ id: Column('ID', asNumber()), name: Column('Name', asString()), contact: Object({ email: Column('Email Address', asString()), phone: Column('Phone Number', asString().optional()), }), links: Tuple([Column('Link 1', asString()), Column('Link 2', asString())]), }); ``` > \[!NOTE] > Any column in CSV that is not referenced in the schema will be ignored. ## Infer Type Use [`StaticDecode`](/references/type-aliases/StaticDecode.html) to infer schema type ```ts import { type StaticDecode } from 'sheethuahua'; // type Person: { // id: number; // name: string; // } type Person = StaticDecode; ``` --- --- url: 'https://punchupworld.github.io/sheethuahua/guide/3-transformer.md' description: >- Transformers that decode/encode CSV string cells into typed values — built-in transformers (asString, asNumber, asBoolean, asDate, asOneOf, asArray), custom transformers via createTransformer, and optional/fallback variants. --- # Transformer Every cell in CSV/Sheets is a `string`. Transformers contain instructions about how to convert a string of each cell to be the data you want (decode) and convert it back (encode). `Column()` requires a transformer in the 2nd argument. For example, parse *"Count"* column as a number: ```ts Column('Count', asNumber()); ``` > Transformers are built on top of [TypeBox's Type Transform](https://github.com/sinclairzx81/typebox?tab=readme-ov-file#types-transform) ## Built-In Sheethuahua provide following transformers: | Transformers | Decode Output Type | Input Example | | ---------------------------------------------------------------- | ------------------------------------------- | --------------- | | [`asString()`](/references/functions/asString.html) | `string` | Text | | [`asNumber()`](/references/functions/asNumber.html) | `number` | Number | | [`asBoolean()`](/references/functions/asBoolean.html) | `boolean` | Checkbox | | [`asDate()`](/references/functions/asDate.html) | `Date` | Date | | [`asOneOf(values)`](/references/functions/asOneOf.html) | Union type of given `Literal` values | Dropdown | | [`asArray(itemTransformer)`](/references/functions/asArray.html) | An array of sub-transformer's decode output | Splittable text | Built-in transformers accept *options* for further decodes output validation. ```ts Column('Count', asNumber({ minimum: 0, maximum: 10 })); ``` See more about the *options* in each transformer's reference. ## DIY You can create your own transformer with [`createTransformer()`](/references/functions/createTransformer.html) ```ts{3-11} import { createTransformer, Column, type StaticDecode } from 'sheethuahua'; const asMarkdownList = createTransformer( // Decode function: string -> string[] (str) => str .split('\n') .map((line) => line.replace('- ', '').trim()) .filter((item) => item.length > 0), // Encode function (Optional): string[] -> string (items) => items.map(item => `- ${item}`).join('\n') ); const schema = Column('Items', asMarkdownList); // type Items: string[] type Items = StaticDecode; ``` ::: tip * Encode function is optional. If it isn't provided, a function returning an empty string will be used. (When you don't plan to use the [formatter](5-formatter)) * [TypeBox's Type](https://github.com/sinclairzx81/typebox?tab=readme-ov-file#types) can be supplied to the [`createTransformer()`](/references/functions/createTransformer.html) 3rd argument to validate the decode output and encode input. ::: ## Optional Variant Transformer required value by default and will throw when input is an empty string. If the column can be left empty you can call `.optional()` variant of the transformer. An empty cell will be parsed as `undefined` and omitted from `Object` instead of throwing an error. ```ts{3,8} const schema = Object({ id: Column('ID', asNumber()), name: Column('Name', asString().optional()), }); // type Person: { // id: number; // name?: string | undefined; // } type Person = StaticDecode; ``` ### Fallback You can provide a fallback value when column is empty instead of `undefined` ```ts{3,8} const schema = Object({ id: Column('ID', asNumber()), name: Column('Name', asString().optional('anonymous')), }); // type Person: { // id: number; // name: string; (will be 'anonymous' when the cell is empty) // } type Person = StaticDecode; ``` --- --- url: 'https://punchupworld.github.io/sheethuahua/guide/4-parser.md' description: >- Parsing CSV data from different sources — parseCsv for strings, fetchCsv for URLs, and Spreadsheet for Google Sheets, with debugging options. --- # Parser Parser validate and decode the input CSV from the given *data source* and the *schema*. If validation has failed, the error will be thrown. Let's use this schema as an example: ```ts import { Column, Object, asNumber, asString } from 'sheethuahua'; const schema = Object({ id: Column('ID', asNumber()), name: Column('Name', asString()), }); ``` ## parseCsv [`parseCsv()`](/references/functions/parseCsv.html) use CSV string as the data source. ```ts import { parseCsv } from 'sheethuahua'; const input = 'ID,Name\n1,A\n2,B\n'; // const output: { // id: number; // name: string; // }[] const output = parseCsv(input, schema); ``` ## fetchCsv [`fetchCsv()`](/references/functions/fetchCsv.html) use URL to the CSV file as the data source. ```ts import { fetchCsv } from 'sheethuahua'; // const output: { // id: number; // name: string; // }[] const output = await fetchCsv('https://url-to/data.csv', schema); ``` ## Spreadsheets [`Spreadsheets()`](/references/functions/Spreadsheet.html) use Google Sheets as a data source. Providing *Sheets ID* and call `.get()` to parse the data from specific sheet's name and corresponded schema. ::: tip *Sheets ID* can be found from the Google Sheets URL: `https://docs.google.com/spreadsheets/d/{sheetsId}/` ::: ```ts import { fetchCsv } from 'sheethuahua'; const sheets = Spreadsheet('google-sheets-id'); // const output: { // id: number; // name: string; // }[] const output = await sheets.get('SheetName', schema); ``` ::: warning 1. The sheets must be publicly accessible (At least anyone with the link can view). 2. Google Sheets has [a very low rate limit](https://developers.google.com/sheets/api/limits). It should be used with Static Site Generation (SSG) or [caching](/plugin/caching.html). ::: ## Debugging Sheethuahua does many things under the hood. If you run into any problem, you can enable debugging logs by setting `debug` to `true` in the parser options. ```ts parseCsv(input, schema, { debug: true }); await fetchCsv('https://url-to/data.csv', schema, { debug: true }); await sheets.get('SheetName', schema, { debug: true }); ``` --- --- url: 'https://punchupworld.github.io/sheethuahua/guide/5-formatter.md' description: >- Formatting JavaScript data back to CSV string using formatToCsv and schema-defined encoders — the inverse of parsing. --- # Formatter Formatter is the opposite of parser: it validates and encodes JavaScript data back to the CSV string with the given *schema*. If validation has failed, the error will be thrown. ::: info Parsing CSV to JavaScript data is many-to-one relationship: both 0 and 'false' will be parsed to `false` using `asBoolean`'s decoder. But formatting is one-one: `false` boolean will always be formatted to 'false' in CSV. So **formatter's CSV output might not be exactly the same with parser's CSV input**, even though it is equal when parsed back to be JavaScript data. ::: ## formatToCsv [`formatToCsv()`](/references/functions/formatToCsv.html) format the array of data back to be the CSV string using encoder defined in the given schema. ```ts{13} import { formatToCsv } from 'sheethuahua'; const schema = Object({ id: Column('ID', asNumber()), name: Column('Name', asString()), }); const data = [ { id: 1, name: 'Samoyed' }, { id: 2, name: 'Shiba' }, ]; const output = formatToCsv(data, schema); ``` The output value will be: ```csv ID,Name 1,Samoyed 2,Shiba ``` --- --- url: 'https://punchupworld.github.io/sheethuahua/plugin/caching.md' --- # Caching Caching generally making your application faster with the cost of some memory/storage, but it is even more important when using Sheethuahua with Google Sheets to avoid an issue with very low rate limiting. ## Spreadsheet Cache Sheethuahua currently provide caching in the Spreadsheet level with [`withCache`](/references/functions/withCache.html). Every request to every `table` will go through the caching layer automatically. [`withCache`](/references/functions/withCache.html) requires a [`CacheAdapter`](/references/interfaces/TCacheAdapter.html): an object containing `get` and `set` function to interact with the cache. Example with native JavaScript's Map for a simple in-memory cache: ```ts import { Spreadsheet, withCache } from 'sheethuahua'; const cache = new Map(); // Use Map as a simple in-memory cache const sheets = withCache(Spreadsheet('google-sheets-id'), cache); const output = sheets.get('sheet-name'); ``` You can replace the map with [ioredis](https://www.npmjs.com/package/ioredis), [node-cache](https://github.com/node-cache/node-cache), etc. or even your own implementation of [`CacheAdapter`](/references/interfaces/TCacheAdapter.html). --- --- url: 'https://punchupworld.github.io/sheethuahua/references.md' --- # sheethuahua ## Interfaces * [ArrayOptions](interfaces/ArrayOptions.md) * [DateOptions](interfaces/DateOptions.md) * [FetchOptions](interfaces/FetchOptions.md) * [NumberOptions](interfaces/NumberOptions.md) * [ParseOptions](interfaces/ParseOptions.md) * [SchemaOptions](interfaces/SchemaOptions.md) * [SheetOptions](interfaces/SheetOptions.md) * [StringOptions](interfaces/StringOptions.md) * [TCacheAdapter](interfaces/TCacheAdapter.md) * [TempoOptions](interfaces/TempoOptions.md) * [TObject](interfaces/TObject.md) * [TSpreadsheet](interfaces/TSpreadsheet.md) * [TTuple](interfaces/TTuple.md) * [WithCacheOptions](interfaces/WithCacheOptions.md) ## Type Aliases * [StaticDecode](type-aliases/StaticDecode.md) * [TColumn](type-aliases/TColumn.md) * [TCsvSchema](type-aliases/TCsvSchema.md) * [TLiteralValue](type-aliases/TLiteralValue.md) * [TMaybePromise](type-aliases/TMaybePromise.md) * [TTransformer](type-aliases/TTransformer.md) ## Variables * [ColumnKind](variables/ColumnKind.md) ## Functions * [asArray](functions/asArray.md) * [asBoolean](functions/asBoolean.md) * [asDate](functions/asDate.md) * [asNumber](functions/asNumber.md) * [asOneOf](functions/asOneOf.md) * [asString](functions/asString.md) * [Column](functions/Column.md) * [createTransformer](functions/createTransformer.md) * [fetchCsv](functions/fetchCsv.md) * [formatToCsv](functions/formatToCsv.md) * [Object](functions/Object.md) * [parseCsv](functions/parseCsv.md) * [Spreadsheet](functions/Spreadsheet.md) * [Tuple](functions/Tuple.md) * [withCache](functions/withCache.md) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/asArray.md' --- # Function: asArray() > **asArray**<`T`, `S`>(`itemTransformer`, `separator`, `options`?): [`TTransformer`](../type-aliases/TTransformer.md)<`Static`<`TDecodeType`<`S`>, `unknown`\[] & \[]>\[], `TArray`<`S`>> Create an array transformer. Split string with separator and apply itemTransformer to each item. ## Type Parameters | Type Parameter | | ------ | | `T` | | `S` *extends* `TSchema` | ## Parameters | Parameter | Type | Default value | Description | | ------ | ------ | ------ | ------ | | `itemTransformer` | [`TTransformer`](../type-aliases/TTransformer.md)<`T`, `S`> | `undefined` | Transformer for each item | | `separator` | `string` | `','` | A string that separate each item | | `options`? | [`ArrayOptions`](../interfaces/ArrayOptions.md) | `undefined` | Validation options (see [ArrayOptions](../interfaces/ArrayOptions.md)) | ## Returns [`TTransformer`](../type-aliases/TTransformer.md)<`Static`<`TDecodeType`<`S`>, `unknown`\[] & \[]>\[], `TArray`<`S`>> ## Example ```ts // Example: "food, transport, rent" -> ['food', 'transport', 'rent'] Column('categories', asArray(asString())); ``` ## Defined in [src/transformer/as-array.ts:17](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-array.ts#L17) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/asBoolean.md' --- # Function: asBoolean() > **asBoolean**(`options`?): [`TTransformer`](../type-aliases/TTransformer.md)<`boolean`, `TBoolean`> Create a boolean transformer. Accept case-insensitive *'true'* or *'false'* and *0* or *1*. ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `options`? | [`SchemaOptions`](../interfaces/SchemaOptions.md) | Validation options (see [SchemaOptions](../interfaces/SchemaOptions.md)) | ## Returns [`TTransformer`](../type-aliases/TTransformer.md)<`boolean`, `TBoolean`> ## Example ```ts Column('isDone', asBoolean()); ``` ## Defined in [src/transformer/as-boolean.ts:14](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-boolean.ts#L14) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/asDate.md' --- # Function: asDate() > **asDate**(`options`): [`TTransformer`](../type-aliases/TTransformer.md)<`Date`, `TDate`> Create a date transformer. Using [Tempo](https://tempo.formkit.com) to parse and format date string. ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `options` | [`TempoOptions`](../interfaces/TempoOptions.md) & [`DateOptions`](../interfaces/DateOptions.md) | [TempoOptions](../interfaces/TempoOptions.md) for parsing/formatting and [DateOptions](../interfaces/DateOptions.md) for validation | ## Returns [`TTransformer`](../type-aliases/TTransformer.md)<`Date`, `TDate`> ## Remarks Without format option, asDate expects [ISO 8601 format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format) ## Example ```ts // Default expect ISO 8601 format Column('createdAt', asDate()); // With custom format and timezone Column('createdAt', asDate({ format: 'DD/MM/YYYY', timezone: 'Asia/Bangkok' })); ``` ## Defined in [src/transformer/as-date.ts:46](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-date.ts#L46) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/asNumber.md' --- # Function: asNumber() > **asNumber**(`options`?): [`TTransformer`](../type-aliases/TTransformer.md)<`number`, `TNumber`> Create a number transformer ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `options`? | [`NumberOptions`](../interfaces/NumberOptions.md) | Validation options (see [NumberOptions](../interfaces/NumberOptions.md)) | ## Returns [`TTransformer`](../type-aliases/TTransformer.md)<`number`, `TNumber`> ## Example ```ts Column('score', asNumber()); ``` ## Defined in [src/transformer/as-number.ts:14](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-number.ts#L14) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/asOneOf.md' --- # Function: asOneOf() > **asOneOf**<`T`>(`values`, `options`?): [`TTransformer`](../type-aliases/TTransformer.md)<`T`\[`number`], `TUnion`<`TLiteral`<`T`\[`number`]>\[]>> Create an oneOf transformer. Value must be parsable as one of the given values. ## Type Parameters | Type Parameter | | ------ | | `T` *extends* [`TLiteralValue`](../type-aliases/TLiteralValue.md)\[] | ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `values` | readonly \[`T`] | An array of expected values | | `options`? | [`SchemaOptions`](../interfaces/SchemaOptions.md) | Validation options (see [NumberOptions](../interfaces/NumberOptions.md)) | ## Returns [`TTransformer`](../type-aliases/TTransformer.md)<`T`\[`number`], `TUnion`<`TLiteral`<`T`\[`number`]>\[]>> ## Example ```ts Column('status', asOneOf(['Todo', 'Doing', 'Done'])); ``` ## Defined in [src/transformer/as-one-of.ts:21](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-one-of.ts#L21) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/asString.md' --- # Function: asString() > **asString**(`options`?): [`TTransformer`](../type-aliases/TTransformer.md)<`string`, `TString`> Create a string transformer ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `options`? | [`StringOptions`](../interfaces/StringOptions.md) | Validation options (see [StringOptions](../interfaces/StringOptions.md)) | ## Returns [`TTransformer`](../type-aliases/TTransformer.md)<`string`, `TString`> ## Example ```ts Column('name', asString()); ``` ## Defined in [src/transformer/as-string.ts:14](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-string.ts#L14) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/Column.md' --- # Function: Column() > **Column**<`T`>(`name`, `transformer`): [`TColumn`](../type-aliases/TColumn.md)<`T`> Map with CSV Column with the corresponded transformer ## Type Parameters | Type Parameter | | ------ | | `T` *extends* `TTransform`<`TString`, `any`> | ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `name` | `string` | Column name | | `transformer` | `T` | Column transformer | ## Returns [`TColumn`](../type-aliases/TColumn.md)<`T`> ## Example ```ts Column('name', asString()); ``` ## Defined in [src/schema/column.ts:26](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/schema/column.ts#L26) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/functions/createTransformer.md --- # Function: createTransformer() ## createTransformer(decode, encode) > **createTransformer**<`T`>(`decode`, `encode`?): [`TTransformer`](../type-aliases/TTransformer.md)<`T`> Create custom transformer ### Type Parameters | Type Parameter | | ------ | | `T` | ### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `decode` | (`value`) => `T` | A function to parse string from CSV cell | | `encode`? | (`value`) => `string` | A function to format value back to string | ### Returns [`TTransformer`](../type-aliases/TTransformer.md)<`T`> ### Example ```ts const asMarkdownList = createTransformer( (str) => str .split('\n') .map((line) => line.replace('- ', '').trim()) .filter((item) => item.length > 0), ); ``` ### Defined in [src/transformer/create-transformer.ts:52](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/create-transformer.ts#L52) ## createTransformer(decode, encode, decodeSchema) > **createTransformer**<`S`, `T`>(`decode`, `encode`, `decodeSchema`): [`TTransformer`](../type-aliases/TTransformer.md)<`T`, `S`> Create a custom transformer ### Type Parameters | Type Parameter | Default type | | ------ | ------ | | `S` *extends* `TSchema` | - | | `T` | [`StaticDecode`](../type-aliases/StaticDecode.md)<`S`> | ### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `decode` | (`value`) => `unknown` | A function to parse string from CSV cell | | `encode` | (`value`) => `string` | A function to format value back to string | | `decodeSchema` | `S` | A schema to validate decoded value | ### Returns [`TTransformer`](../type-aliases/TTransformer.md)<`T`, `S`> ### Example ```ts const asMarkdownList = createTransformer( (str) => str .split('\n') .map((line) => line.replace('- ', '').trim()) .filter((item) => item.length > 0), (items) => items.map(item => `- ${item}`).join('\n') ); ``` ### Defined in [src/transformer/create-transformer.ts:72](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/create-transformer.ts#L72) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/fetchCsv.md' --- # Function: fetchCsv() > **fetchCsv**<`T`>(`url`, `schema`, `options`?): `Promise`<[`StaticDecode`](../type-aliases/StaticDecode.md)<`T`>\[]> Fetch CSV from the URL and parse according to the given schema ## Type Parameters | Type Parameter | | ------ | | `T` *extends* [`TCsvSchema`](../type-aliases/TCsvSchema.md) | ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `url` | `string` | URL to the CSV file | | `schema` | `T` | Output schema mapping of each row | | `options`? | [`FetchOptions`](../interfaces/FetchOptions.md) | Fetch options [FetchOptions](../interfaces/FetchOptions.md) | ## Returns `Promise`<[`StaticDecode`](../type-aliases/StaticDecode.md)<`T`>\[]> An array of objects corresponded to the table definition ## Throws If fail to fetch or parse the schema ## Example ```ts const output = await fetchCsv('https://url-to/data.csv', schema); ``` ## Defined in [src/parser/fetch-csv.ts:34](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/fetch-csv.ts#L34) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/formatToCsv.md' --- # Function: formatToCsv() > **formatToCsv**<`T`>(`array`, `schema`): `string` Format an array to CSV string ## Type Parameters | Type Parameter | | ------ | | `T` *extends* [`TCsvSchema`](../type-aliases/TCsvSchema.md) | ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `array` | [`StaticDecode`](../type-aliases/StaticDecode.md)<`T`>\[] | An array of data | | `schema` | `T` | Output schema mapping of each row | ## Returns `string` A CSV string ## Throws If fail to format the array ## Example ```ts const output = formatAsCsv([{ id: 1, name: 'a' }], schema); ``` ## Defined in [src/formatter/format-to-csv.ts:22](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/formatter/format-to-csv.ts#L22) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/Object.md' --- # Function: Object() > **Object**<`T`>(`properties`, `options`?): [`TObject`](../interfaces/TObject.md)<`T`> `[Json]` Creates an Object type ## Type Parameters | Type Parameter | | ------ | | `T` *extends* `TProperties` | ## Parameters | Parameter | Type | | ------ | ------ | | `properties` | `T` | | `options`? | `ObjectOptions` | ## Returns [`TObject`](../interfaces/TObject.md)<`T`> ## Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:43 --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/parseCsv.md' --- # Function: parseCsv() > **parseCsv**<`T`>(`content`, `schema`, `options`?): [`StaticDecode`](../type-aliases/StaticDecode.md)<`T`>\[] Parse the CSV string according to the given schema ## Type Parameters | Type Parameter | | ------ | | `T` *extends* [`TCsvSchema`](../type-aliases/TCsvSchema.md) | ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `content` | `string` | A string of CSV file content | | `schema` | `T` | Output schema mapping of each row | | `options`? | [`ParseOptions`](../interfaces/ParseOptions.md) | - | ## Returns [`StaticDecode`](../type-aliases/StaticDecode.md)<`T`>\[] An array of given schema ## Throws If fail to parse the schema ## Example ```ts const output = parseCsv('ID,Name\n1,A\n2,B\n', schema); ``` ## Defined in [src/parser/parse-csv.ts:39](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/parse-csv.ts#L39) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/Spreadsheet.md' --- # Function: Spreadsheet() > **Spreadsheet**(`sheetsId`, `globalOptions`): [`TSpreadsheet`](../interfaces/TSpreadsheet.md) Define a spreadsheet corresponded to a Google Sheets document. ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `sheetsId` | `string` | Google Sheets ID can be found from the URL `docs.google.com/spreadsheets/d/{sheetsId}/` | | `globalOptions` | [`SheetOptions`](../interfaces/SheetOptions.md) | [SheetOptions](../interfaces/SheetOptions.md) which will be applied in every `.get` call | ## Returns [`TSpreadsheet`](../interfaces/TSpreadsheet.md) A spreadsheet object ## Example ```ts const sheets = Spreadsheet('google-sheets-id'); ``` ## Defined in [src/parser/spreadsheet.ts:70](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/spreadsheet.ts#L70) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/Tuple.md' --- # Function: Tuple() > **Tuple**<`T`>(`items`, `options`?): [`TTuple`](../interfaces/TTuple.md)<`T`> `[Json]` Creates a Tuple type ## Type Parameters | Type Parameter | | ------ | | `T` *extends* `TSchema`\[] | ## Parameters | Parameter | Type | | ------ | ------ | | `items` | \[`...T[]`] | | `options`? | [`SchemaOptions`](../interfaces/SchemaOptions.md) | ## Returns [`TTuple`](../interfaces/TTuple.md)<`T`> ## Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:15 --- --- url: 'https://punchupworld.github.io/sheethuahua/references/functions/withCache.md' --- # Function: withCache() > **withCache**<`C`>(`spreadsheet`, `cache`, `options`): [`TSpreadsheet`](../interfaces/TSpreadsheet.md) Add caching capability to the spreadsheet object. ## Type Parameters | Type Parameter | | ------ | | `C` *extends* [`TCacheAdapter`](../interfaces/TCacheAdapter.md) | ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `spreadsheet` | [`TSpreadsheet`](../interfaces/TSpreadsheet.md) | A spreadsheet object | | `cache` | `C` | A cache adapter | | `options` | [`WithCacheOptions`](../interfaces/WithCacheOptions.md) | - | ## Returns [`TSpreadsheet`](../interfaces/TSpreadsheet.md) A spreadsheet object with underlying caching ## Example ```ts const cache = new Map(); // Use Map as a simple in-memory cache const sheets = withCache(Spreadsheet('google-sheets-id'), cache); const output = sheets.get('sheet-name') ``` ## Defined in [src/plugin/cache.ts:51](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/plugin/cache.ts#L51) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/ArrayOptions.md --- # Interface: ArrayOptions ## Extends * [`SchemaOptions`](SchemaOptions.md) ## Properties ### $id? > `optional` **$id**: `string` Id for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$id`](SchemaOptions.md#id) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$schema`](SchemaOptions.md#schema) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### contains? > `optional` **contains**: `TSchema` A schema for which some elements should match #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/array/array.d.ts:13 *** ### default? > `optional` **default**: `any` Default value for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`default`](SchemaOptions.md#default) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`description`](SchemaOptions.md#description) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`examples`](SchemaOptions.md#examples) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### maxContains? > `optional` **maxContains**: `number` A maximum number of contains schema matches #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/array/array.d.ts:17 *** ### maxItems? > `optional` **maxItems**: `number` The maximum number of items in this array #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/array/array.d.ts:9 *** ### minContains? > `optional` **minContains**: `number` A minimum number of contains schema matches #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/array/array.d.ts:15 *** ### minItems? > `optional` **minItems**: `number` The minimum number of items in this array #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/array/array.d.ts:7 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`readOnly`](SchemaOptions.md#readonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### title? > `optional` **title**: `string` Title of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`title`](SchemaOptions.md#title) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### uniqueItems? > `optional` **uniqueItems**: `boolean` Should this schema contain unique items #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/array/array.d.ts:11 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`writeOnly`](SchemaOptions.md#writeonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/DateOptions.md --- # Interface: DateOptions ## Extends * [`SchemaOptions`](SchemaOptions.md) ## Properties ### $id? > `optional` **$id**: `string` Id for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$id`](SchemaOptions.md#id) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$schema`](SchemaOptions.md#schema) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### default? > `optional` **default**: `any` Default value for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`default`](SchemaOptions.md#default) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`description`](SchemaOptions.md#description) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`examples`](SchemaOptions.md#examples) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### exclusiveMaximumTimestamp? > `optional` **exclusiveMaximumTimestamp**: `number` The exclusive maximum timestamp value #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/date/date.d.ts:5 *** ### exclusiveMinimumTimestamp? > `optional` **exclusiveMinimumTimestamp**: `number` The exclusive minimum timestamp value #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/date/date.d.ts:7 *** ### maximumTimestamp? > `optional` **maximumTimestamp**: `number` The maximum timestamp value #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/date/date.d.ts:9 *** ### minimumTimestamp? > `optional` **minimumTimestamp**: `number` The minimum timestamp value #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/date/date.d.ts:11 *** ### multipleOfTimestamp? > `optional` **multipleOfTimestamp**: `number` The multiple of timestamp value #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/date/date.d.ts:13 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`readOnly`](SchemaOptions.md#readonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### title? > `optional` **title**: `string` Title of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`title`](SchemaOptions.md#title) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`writeOnly`](SchemaOptions.md#writeonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/FetchOptions.md --- # Interface: FetchOptions Options for fetchCsv function ## Properties ### debug? > `optional` **debug**: `boolean` Enable debugging logs #### Default Value ```ts false ``` #### Defined in [src/parser/fetch-csv.ts:19](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/fetch-csv.ts#L19) *** ### fetchRequestInit? > `optional` **fetchRequestInit**: `RequestInit` Fetch requests configuration #### See #### Defined in [src/parser/fetch-csv.ts:14](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/fetch-csv.ts#L14) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/NumberOptions.md --- # Interface: NumberOptions ## Extends * [`SchemaOptions`](SchemaOptions.md) ## Properties ### $id? > `optional` **$id**: `string` Id for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$id`](SchemaOptions.md#id) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$schema`](SchemaOptions.md#schema) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### default? > `optional` **default**: `any` Default value for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`default`](SchemaOptions.md#default) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`description`](SchemaOptions.md#description) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`examples`](SchemaOptions.md#examples) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### exclusiveMaximum? > `optional` **exclusiveMaximum**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/number/number.d.ts:4 *** ### exclusiveMinimum? > `optional` **exclusiveMinimum**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/number/number.d.ts:5 *** ### maximum? > `optional` **maximum**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/number/number.d.ts:6 *** ### minimum? > `optional` **minimum**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/number/number.d.ts:7 *** ### multipleOf? > `optional` **multipleOf**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/number/number.d.ts:8 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`readOnly`](SchemaOptions.md#readonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### title? > `optional` **title**: `string` Title of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`title`](SchemaOptions.md#title) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`writeOnly`](SchemaOptions.md#writeonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/ParseOptions.md --- # Interface: ParseOptions Options for parseCsv function ## Properties ### debug? > `optional` **debug**: `boolean` Enable debugging logs #### Default Value ```ts false ``` #### Defined in [src/parser/parse-csv.ts:25](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/parse-csv.ts#L25) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/SchemaOptions.md --- # Interface: SchemaOptions ## Extended by * [`ArrayOptions`](ArrayOptions.md) * [`DateOptions`](DateOptions.md) * [`NumberOptions`](NumberOptions.md) * [`StringOptions`](StringOptions.md) ## Indexable \[`prop`: `string`]: `any` ## Properties ### $id? > `optional` **$id**: `string` Id for this schema #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### default? > `optional` **default**: `any` Default value for this schema #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### title? > `optional` **title**: `string` Title of this schema #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/SheetOptions.md --- # Interface: SheetOptions Options for Sheets getter function ## Properties ### debug? > `optional` **debug**: `boolean` Enable debugging logs #### Default Value ```ts false ``` #### Defined in [src/parser/spreadsheet.ts:34](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/spreadsheet.ts#L34) *** ### fetchRequestInit? > `optional` **fetchRequestInit**: `RequestInit` Fetch requests configuration #### See #### Defined in [src/parser/spreadsheet.ts:29](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/spreadsheet.ts#L29) *** ### headers? > `optional` **headers**: `number` How many rows are header rows. #### Default Value ```ts 1 ``` #### Remarks If has more than one row, the column name will be a combination of those rows. #### See #### Defined in [src/parser/spreadsheet.ts:24](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/spreadsheet.ts#L24) *** ### range? > `optional` **range**: `string` Which part of the sheet to use. #### Example ```ts "A1:B10" = A range from cell A1 through B10 "5:7" = Rows 5-7 "D:F" = Columns D-F ``` #### See #### Defined in [src/parser/spreadsheet.ts:17](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/spreadsheet.ts#L17) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/StringOptions.md --- # Interface: StringOptions ## Extends * [`SchemaOptions`](SchemaOptions.md) ## Properties ### $id? > `optional` **$id**: `string` Id for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$id`](SchemaOptions.md#id) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`$schema`](SchemaOptions.md#schema) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### contentEncoding? > `optional` **contentEncoding**: `StringContentEncodingOption` The content encoding for this string #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/string/string.d.ts:15 *** ### contentMediaType? > `optional` **contentMediaType**: `string` The content media type for this string #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/string/string.d.ts:17 *** ### default? > `optional` **default**: `any` Default value for this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`default`](SchemaOptions.md#default) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`description`](SchemaOptions.md#description) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`examples`](SchemaOptions.md#examples) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### format? > `optional` **format**: `StringFormatOption` A format this string should match #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/string/string.d.ts:13 *** ### maxLength? > `optional` **maxLength**: `number` The maximum string length #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/string/string.d.ts:7 *** ### minLength? > `optional` **minLength**: `number` The minimum string length #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/string/string.d.ts:9 *** ### pattern? > `optional` **pattern**: `string` A regular expression pattern this string should match #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/string/string.d.ts:11 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`readOnly`](SchemaOptions.md#readonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### title? > `optional` **title**: `string` Title of this schema #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`title`](SchemaOptions.md#title) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Inherited from [`SchemaOptions`](SchemaOptions.md).[`writeOnly`](SchemaOptions.md#writeonly) #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/TCacheAdapter.md --- # Interface: TCacheAdapter Cache adapter for caching plugins ## Properties ### get() > **get**: (`key`) => `unknown` Cache getter function #### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `key` | `string` | The key to store the parsed value (table name) | #### Returns `unknown` The corresponded parsed table rows value #### Defined in [src/plugin/cache.ts:19](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/plugin/cache.ts#L19) *** ### set() > **set**: (`key`, `value`) => `any` Cache setter function #### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `key` | `string` | The key to store the value under (table name) | | `value` | `unknown` | The paired value to store (parsed rows value) | #### Returns `any` #### Defined in [src/plugin/cache.ts:25](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/plugin/cache.ts#L25) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/TempoOptions.md --- # Interface: TempoOptions Options for Tempo to parse and format date string. ## Properties ### format? > `optional` **format**: `Format` The format that should be used to parse and format the date. #### Default Value ```ts ISO 8601 format ``` #### See [Tempo Format Tokens](https://tempo.formkit.com/#format-tokens) #### Defined in [src/transformer/as-date.ts:22](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-date.ts#L22) *** ### timezone? > `optional` **timezone**: `string` Timezone for the decode's input and encode's output date string. #### Default Value ```ts UTC ``` #### Defined in [src/transformer/as-date.ts:27](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/as-date.ts#L27) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/interfaces/TObject.md' --- # Interface: TObject\ ## Extends * `TSchema`.`ObjectOptions` ## Type Parameters | Type Parameter | Default type | | ------ | ------ | | `T` *extends* `TProperties` | `TProperties` | ## Properties ### \[Hint]? > `optional` **\[Hint]**: `string` #### Inherited from `TSchema.[Hint]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:26 *** ### \[Kind] > **\[Kind]**: `"Object"` #### Overrides `TSchema.[Kind]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:33 *** ### \[OptionalKind]? > `optional` **\[OptionalKind]**: `string` #### Inherited from `TSchema.[OptionalKind]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:25 *** ### \[ReadonlyKind]? > `optional` **\[ReadonlyKind]**: `string` #### Inherited from `TSchema.[ReadonlyKind]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:24 *** ### $id? > `optional` **$id**: `string` Id for this schema #### Inherited from `TSchema.$id` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Inherited from `TSchema.$schema` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### additionalProperties? > `optional` **additionalProperties**: `TAdditionalProperties` Additional property constraints for this object #### Overrides `ObjectOptions.additionalProperties` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:35 *** ### default? > `optional` **default**: `any` Default value for this schema #### Inherited from `TSchema.default` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Inherited from `TSchema.description` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Inherited from `TSchema.examples` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### maxProperties? > `optional` **maxProperties**: `number` The maximum number of properties allowed on this object #### Inherited from `ObjectOptions.maxProperties` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:30 *** ### minProperties? > `optional` **minProperties**: `number` The minimum number of properties allowed on this object #### Inherited from `ObjectOptions.minProperties` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:28 *** ### params > **params**: `unknown`\[] #### Inherited from `TSchema.params` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:27 *** ### properties > **properties**: `T` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:37 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Inherited from `TSchema.readOnly` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### required? > `optional` **required**: `string`\[] #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:38 *** ### static > **static**: `Evaluate`<`Readonly`<`Partial`<`Pick`<{ \[K in string | number | symbol]: Static\ }, `ReadonlyOptionalPropertyKeys`<`T`>>>> & `Readonly`<`Pick`<{ \[K in string | number | symbol]: Static\ }, `ReadonlyPropertyKeys`<`T`>>> & `Partial`<`Pick`<{ \[K in string | number | symbol]: Static\ }, `OptionalPropertyKeys`<`T`>>> & `Required`<`Pick`<{ \[K in string | number | symbol]: Static\ }, `Exclude`\ | `ReadonlyPropertyKeys`<`T`> | `OptionalPropertyKeys`<`T`>>>>> #### Overrides `TSchema.static` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:34 *** ### title? > `optional` **title**: `string` Title of this schema #### Inherited from `TSchema.title` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### type > **type**: `"object"` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts:36 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Inherited from `TSchema.writeOnly` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/TSpreadsheet.md --- # Interface: TSpreadsheet Spreadsheet object type ## Methods ### get() > **get**<`S`>(`sheet`, `schema`, `options`?): `Promise`<[`StaticDecode`](../type-aliases/StaticDecode.md)<`S`>\[]> Fetch and parse the sheet from given sheet name. #### Type Parameters | Type Parameter | | ------ | | `S` *extends* [`TCsvSchema`](../type-aliases/TCsvSchema.md) | #### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `sheet` | `string` | The sheet name | | `schema` | `S` | Output schema mapping of each row | | `options`? | [`SheetOptions`](SheetOptions.md) | [SheetOptions](SheetOptions.md) | #### Returns `Promise`<[`StaticDecode`](../type-aliases/StaticDecode.md)<`S`>\[]> An array of objects corresponded to the sheet definition #### Throws If fail to fetch or parse the sheet #### Example ```ts const output = await sheets.get('sheet-name', schema); ``` #### Defined in [src/parser/spreadsheet.ts:53](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/spreadsheet.ts#L53) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/interfaces/TTuple.md' --- # Interface: TTuple\ ## Extends * `TSchema` ## Type Parameters | Type Parameter | Default type | | ------ | ------ | | `T` *extends* `TSchema`\[] | `TSchema`\[] | ## Properties ### \[Hint]? > `optional` **\[Hint]**: `string` #### Inherited from `TSchema.[Hint]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:26 *** ### \[Kind] > **\[Kind]**: `"Tuple"` #### Overrides `TSchema.[Kind]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:6 *** ### \[OptionalKind]? > `optional` **\[OptionalKind]**: `string` #### Inherited from `TSchema.[OptionalKind]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:25 *** ### \[ReadonlyKind]? > `optional` **\[ReadonlyKind]**: `string` #### Inherited from `TSchema.[ReadonlyKind]` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:24 *** ### $id? > `optional` **$id**: `string` Id for this schema #### Inherited from `TSchema.$id` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:5 *** ### $schema? > `optional` **$schema**: `string` #### Inherited from `TSchema.$schema` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:3 *** ### additionalItems? > `optional` **additionalItems**: `false` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:10 *** ### default? > `optional` **default**: `any` Default value for this schema #### Inherited from `TSchema.default` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:11 *** ### description? > `optional` **description**: `string` Description of this schema #### Inherited from `TSchema.description` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:9 *** ### examples? > `optional` **examples**: `any` Example values matching this schema #### Inherited from `TSchema.examples` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:13 *** ### items? > `optional` **items**: `T` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:9 *** ### maxItems > **maxItems**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:12 *** ### minItems > **minItems**: `number` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:11 *** ### params > **params**: `unknown`\[] #### Inherited from `TSchema.params` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:27 *** ### readOnly? > `optional` **readOnly**: `boolean` Optional annotation for readOnly #### Inherited from `TSchema.readOnly` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:15 *** ### static > **static**: `TupleStatic`<`T`, `unknown`\[], \[]> #### Overrides `TSchema.static` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:7 *** ### title? > `optional` **title**: `string` Title of this schema #### Inherited from `TSchema.title` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:7 *** ### type > **type**: `"array"` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/tuple/tuple.d.ts:8 *** ### writeOnly? > `optional` **writeOnly**: `boolean` Optional annotation for writeOnly #### Inherited from `TSchema.writeOnly` #### Defined in node\_modules/@sinclair/typebox/build/cjs/type/schema/schema.d.ts:17 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/interfaces/WithCacheOptions.md --- # Interface: WithCacheOptions Options for with cache plugin ## Properties ### debug? > `optional` **debug**: `boolean` Enable debugging logs #### Default Value ```ts false ``` #### Defined in [src/plugin/cache.ts:36](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/plugin/cache.ts#L36) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/type-aliases/StaticDecode.md --- # Type Alias: StaticDecode\ > **StaticDecode**<`T`, `P`>: `StaticDecodeIsAny`<`T`> *extends* `true` ? `unknown` : `Static`<`TDecodeType`<`T`>, `P`> Creates an decoded static type from a TypeBox type ## Type Parameters | Type Parameter | Default type | | ------ | ------ | | `T` *extends* `TSchema` | - | | `P` *extends* `unknown`\[] | \[] | ## Defined in node\_modules/@sinclair/typebox/build/cjs/type/static/static.d.ts:29 --- --- url: 'https://punchupworld.github.io/sheethuahua/references/type-aliases/TColumn.md' --- # Type Alias: TColumn\ > **TColumn**<`T`>: `T` & `object` Column schema type ## Type declaration ### columnName > **columnName**: `string` ## Type Parameters | Type Parameter | Default type | | ------ | ------ | | `T` *extends* `TTransform`<`TString`, `any`> | `TTransform`<`TString`, `any`> | ## Defined in [src/schema/column.ts:11](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/schema/column.ts#L11) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/type-aliases/TCsvSchema.md --- # Type Alias: TCsvSchema > **TCsvSchema**: [`TColumn`](TColumn.md) | [`TObject`](../interfaces/TObject.md) | [`TTuple`](../interfaces/TTuple.md) Supported schema for CSV parsers ## Defined in [src/parser/parse-csv.ts:15](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/parser/parse-csv.ts#L15) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/type-aliases/TLiteralValue.md --- # Type Alias: TLiteralValue > **TLiteralValue**: `boolean` | `number` | `string` ## Defined in node\_modules/@sinclair/typebox/build/cjs/type/literal/literal.d.ts:3 --- --- url: >- https://punchupworld.github.io/sheethuahua/references/type-aliases/TMaybePromise.md --- # Type Alias: TMaybePromise\ > **TMaybePromise**<`T`>: `T` | `Promise`<`T`> Maybe a promise, or maybe not ## Type Parameters | Type Parameter | | ------ | | `T` | ## Defined in [src/plugin/cache.ts:8](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/plugin/cache.ts#L8) --- --- url: >- https://punchupworld.github.io/sheethuahua/references/type-aliases/TTransformer.md --- # Type Alias: TTransformer\ > **TTransformer**<`T`, `S`>: `TTransform`<`TString`, `T`> & `object` Transformer type ## Type declaration ### optional() > **optional**: <`D`>(`fallback`?) => \[`D`] *extends* \[`T`] ? `TTransform`<`TString`, `T`> : `TOptional`<`TTransform`<`TString`, `T` | `undefined`>> Get optional variant of this transformer #### Type Parameters | Type Parameter | | ------ | | `D` *extends* `T` | `undefined` | #### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `fallback`? | `D` | fallback value when the input is empty | #### Returns \[`D`] *extends* \[`T`] ? `TTransform`<`TString`, `T`> : `TOptional`<`TTransform`<`TString`, `T` | `undefined`>> TTransform, with optional kind if no fallback is given ### validateSchema > **validateSchema**: `S` A schema for decode's output and encode's input validation ## Type Parameters | Type Parameter | Default type | | ------ | ------ | | `T` | - | | `S` *extends* `TSchema` | `TAny` | ## Defined in [src/transformer/create-transformer.ts:18](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/transformer/create-transformer.ts#L18) --- --- url: 'https://punchupworld.github.io/sheethuahua/references/variables/ColumnKind.md' --- # Variable: ColumnKind > `const` **ColumnKind**: `"columnName"` = `'columnName'` Column kind property name for schema identification ## Defined in [src/schema/column.ts:6](https://github.com/punchupworld/sheethuahua/blob/2cbf6358d783c10e67307e3789381accd9b1b946/src/schema/column.ts#L6)